diff mbox series

[API-NEXT,v4,1/3] api: packet: ones complement sum

Message ID 1510228830-21766-2-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [API-NEXT,v4,1/3] api: packet: ones complement sum | expand

Commit Message

Github ODP bot Nov. 9, 2017, noon UTC
From: Petri Savolainen <petri.savolainen@linaro.org>


Added packet metadata for ones complement sum over
packet data. Some NICs calculate the sum during packet
input (at least for IP fragments) and store the value
into the packet descriptor. This offloads L4 checksum
calculation for IP fragments as SW does not need sum
all payload data, but just combine pre-calculated
sums from packet descriptors and remove extra header fields
from the sum.

Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org>

---
/** Email created from pull request 242 (psavol:next-checksum-metadata)
 ** https://github.com/Linaro/odp/pull/242
 ** Patch: https://github.com/Linaro/odp/pull/242.patch
 ** Base sha: d22c949cc466bf28de559855a1cb525740578137
 ** Merge commit sha: 02aa905e6f9d4be66e19ccdb577e40a293be2902
 **/
 include/odp/api/spec/packet.h | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
diff mbox series

Patch

diff --git a/include/odp/api/spec/packet.h b/include/odp/api/spec/packet.h
index fac7790ba..8e1575600 100644
--- a/include/odp/api/spec/packet.h
+++ b/include/odp/api/spec/packet.h
@@ -1437,6 +1437,26 @@  void odp_packet_l3_chksum_insert(odp_packet_t pkt, int insert);
 void odp_packet_l4_chksum_insert(odp_packet_t pkt, int insert);
 
 /**
+ * Ones' complement sum of packet data
+ *
+ * Returns 16-bit ones' complement sum that was calculated over a portion of
+ * packet data during a packet processing operation (e.g. packet input or
+ * IPSEC offload). The data range is output with 'range' parameter, and usually
+ * includes IP payload (L4 headers and payload). When 'range.length' is zero,
+ * the sum has not been calculated. In case of odd number of bytes,
+ * calculation uses a zero byte as padding at the end. The sum may be used as
+ * part of e.g. UDP/TCP checksum checking, especially with IP fragments.
+ *
+ * @param      pkt    Packet handle
+ * @param[out] range  Data range of the sum (output). The calculation started
+ *                    from range.offset and included range.length bytes. When
+ *                    range.length is zero, the sum has not been calculated.
+ *
+ * @return Ones' complement sum over the data range
+ */
+uint16_t odp_packet_ones_comp(odp_packet_t pkt, odp_packet_data_range_t *range);
+
+/**
  * Packet flow hash value
  *
  * Returns the hash generated from the packet header. Use