diff mbox

[API-NEXT,v8,1/3] api: packet: allow access to packet flow hash values

Message ID 1440759940-17679-2-git-send-email-zoltan.kiss@linaro.org
State Accepted
Commit 88dbd4cbee3e48ff0ec708728331aa9782a7eb7f
Headers show

Commit Message

Zoltan Kiss Aug. 28, 2015, 11:05 a.m. UTC
Applications can read the computed hash (if any) and set it if they want
to store any extra information in it.

Signed-off-by: Zoltan Kiss <zoltan.kiss@linaro.org>
Reviewed-by: Petri Savolainen <petri.savolainen@nokia.com>
Reviewed-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>
---
v2:
- focus on RSS hash only
- use setter/getter's

v3:
- do not mention pointers
- add a note
- add new patches for implementation and test

v4: I've accidentally skipped this version

v5:
- use separate flag get and clear, as hash can have any value (that maps to
checking ol_flags in DPDK)
- change terminology to "flow hash", it reflects better what is actually hashed
- add function to generate hash by the platform

v6:
- remove stale function definition from the end of packet.h
- spell out in hash_set that if platform cares about the validity of this value,
  it has to maintain it internally.
- with the above change OVS doesn't need the hash generator function anymore,
  so remove that too. We can introduce it later on.

v7: add more comments on Bala's request

v8:
- previous version doesn't contain the mentioned changes, resend it
- fix grammar on Petri's note

 include/odp/api/packet.h       | 37 +++++++++++++++++++++++++++++++++++++
 include/odp/api/packet_flags.h | 18 ++++++++++++++++++
 2 files changed, 55 insertions(+)
diff mbox

Patch

diff --git a/include/odp/api/packet.h b/include/odp/api/packet.h
index 3a454b5..5d46b7b 100644
--- a/include/odp/api/packet.h
+++ b/include/odp/api/packet.h
@@ -605,6 +605,43 @@  uint32_t odp_packet_l4_offset(odp_packet_t pkt);
 int odp_packet_l4_offset_set(odp_packet_t pkt, uint32_t offset);
 
 /**
+ * Packet flow hash value
+ *
+ * Returns the hash generated from the packet header. Use
+ * odp_packet_has_flow_hash() to check if packet contains a hash.
+ *
+ * @param      pkt      Packet handle
+ *
+ * @return  Hash value
+ *
+ * @note Zero can be a valid hash value.
+ * @note The hash algorithm and the header fields defining the flow (therefore
+ * used for hashing) is platform dependent. It is possible a platform doesn't
+ * generate any hash at all.
+ * @note The returned hash is either the platform generated (if any), or if
+ * odp_packet_flow_hash_set() were called then the value set there.
+ */
+uint32_t odp_packet_flow_hash(odp_packet_t pkt);
+
+/**
+ * Set packet flow hash value
+ *
+ * Store the packet flow hash for the packet and sets the flow hash flag. This
+ * enables (but does not require!) application to reflect packet header
+ * changes in the hash.
+ *
+ * @param      pkt              Packet handle
+ * @param      flow_hash        Hash value to set
+ *
+ * @note If the platform needs to keep the original hash value, it has to
+ * maintain it internally. Overwriting the platform provided value doesn't
+ * change how the platform handles this packet after it.
+ * @note The application is not required to keep this hash valid for new or
+ * modified packets.
+ */
+void odp_packet_flow_hash_set(odp_packet_t pkt, uint32_t flow_hash);
+
+/**
  * Tests if packet is segmented
  *
  * @param pkt  Packet handle
diff --git a/include/odp/api/packet_flags.h b/include/odp/api/packet_flags.h
index bfbcc94..7c3b247 100644
--- a/include/odp/api/packet_flags.h
+++ b/include/odp/api/packet_flags.h
@@ -191,6 +191,15 @@  int odp_packet_has_sctp(odp_packet_t pkt);
 int odp_packet_has_icmp(odp_packet_t pkt);
 
 /**
+ * Check for packet flow hash
+ *
+ * @param pkt Packet handle
+ * @retval non-zero if packet contains a hash value
+ * @retval 0 if packet does not contain a hash value
+ */
+int odp_packet_has_flow_hash(odp_packet_t pkt);
+
+/**
  * Set flag for L2 header, e.g. ethernet
  *
  * @param pkt Packet handle
@@ -327,6 +336,15 @@  void odp_packet_has_sctp_set(odp_packet_t pkt, int val);
 void odp_packet_has_icmp_set(odp_packet_t pkt, int val);
 
 /**
+ * Clear flag for packet flow hash
+ *
+ * @param pkt Packet handle
+ *
+ * @note Set this flag is only possible through odp_packet_flow_hash_set()
+ */
+void odp_packet_has_flow_hash_clr(odp_packet_t pkt);
+
+/**
  * @}
  */