diff mbox series

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

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

Commit Message

Github ODP bot Oct. 20, 2017, 10 a.m. UTC
From: Petri Savolainen <petri.savolainen@linaro.org>


Added packet metadata for ones complement sum over IP
payload in a packet. 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: e3108af2f0b58c2ceca422b418439bba5de04b11
 ** Merge commit sha: c389b738fd956b2cd0077d9e5425be938179fdb2
 **/
 include/odp/api/spec/packet.h       | 17 +++++++++++++++++
 include/odp/api/spec/packet_flags.h |  9 +++++++++
 2 files changed, 26 insertions(+)
diff mbox series

Patch

diff --git a/include/odp/api/spec/packet.h b/include/odp/api/spec/packet.h
index 62ecf70e1..55793ff20 100644
--- a/include/odp/api/spec/packet.h
+++ b/include/odp/api/spec/packet.h
@@ -1437,6 +1437,23 @@  void odp_packet_l3_chksum_insert(odp_packet_t pkt, int l3);
 void odp_packet_l4_chksum_insert(odp_packet_t pkt, int l4);
 
 /**
+ * Ones' complement sum of IP payload data
+ *
+ * Returns 16-bit ones' complement sum calculated over IP payload data in the
+ * packet (includes L4 headers, excludes Ethernet CRC). 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.
+ *
+ * Use odp_packet_has_ones_comp() to check if the sum has been set.
+ *
+ * @param pkt     Packet handle
+ *
+ * @return Ones' complement sum of IP payload data
+ */
+uint16_t odp_packet_ones_comp(odp_packet_t pkt);
+
+/**
  * Packet flow hash value
  *
  * Returns the hash generated from the packet header. Use
diff --git a/include/odp/api/spec/packet_flags.h b/include/odp/api/spec/packet_flags.h
index 377b75ba0..31979ac4b 100644
--- a/include/odp/api/spec/packet_flags.h
+++ b/include/odp/api/spec/packet_flags.h
@@ -277,6 +277,15 @@  int odp_packet_has_sctp(odp_packet_t pkt);
 int odp_packet_has_icmp(odp_packet_t pkt);
 
 /**
+ * Check for ones' complement sum
+ *
+ * @param pkt Packet handle
+ * @retval non-zero if packet contains ones' complement sum
+ * @retval 0 if packet does not contain ones' complement sum
+ */
+int odp_packet_has_ones_comp(odp_packet_t pkt);
+
+/**
  * Check for packet flow hash
  *
  * @param pkt Packet handle