diff mbox series

[ovs-dev,v3,2/5] dpif-netdev: Refactor hash function to own header.

Message ID 20220628084507.3024769-3-kumar.amber@intel.com
State Superseded
Headers show
Series DPIF AVX512 Recirculation | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed

Commit Message

Kumar Amber June 28, 2022, 8:45 a.m. UTC
The refactor allows us to use hash function accross
multiple files which was earlier restricted to
dpif-netdev.c only.

Signed-off-by: Kumar Amber <kumar.amber@intel.com>
Signed-off-by: Cian Ferriter <cian.ferriter@intel.com>
Co-authored-by: Cian Ferriter <cian.ferriter@intel.com>

---
v3:
- Fix minor comments from Harry.
---
---
 lib/dpif-netdev-private-dpcls.h | 23 +++++++++++++++++++++++
 lib/dpif-netdev.c               | 22 ----------------------
 2 files changed, 23 insertions(+), 22 deletions(-)
diff mbox series

Patch

diff --git a/lib/dpif-netdev-private-dpcls.h b/lib/dpif-netdev-private-dpcls.h
index 2a9279437..1b37ecb16 100644
--- a/lib/dpif-netdev-private-dpcls.h
+++ b/lib/dpif-netdev-private-dpcls.h
@@ -25,6 +25,7 @@ 
 
 #include "cmap.h"
 #include "openvswitch/thread.h"
+#include "dpif-netdev-private-dpif.h"
 
 #ifdef  __cplusplus
 extern "C" {
@@ -125,6 +126,28 @@  dpif_netdev_packet_get_rss_hash_orig_pkt(struct dp_packet *packet,
     return hash;
 }
 
+static inline uint32_t
+dpif_netdev_packet_get_rss_hash(struct dp_packet *packet,
+                                const struct miniflow *mf)
+{
+    uint32_t hash, recirc_depth;
+
+    if (OVS_LIKELY(dp_packet_rss_valid(packet))) {
+        hash = dp_packet_get_rss_hash(packet);
+    } else {
+        hash = miniflow_hash_5tuple(mf, 0);
+        dp_packet_set_rss_hash(packet, hash);
+    }
+
+    /* The RSS hash must account for the recirculation depth to avoid
+     * collisions in the exact match cache */
+    recirc_depth = *recirc_depth_get_unsafe();
+    if (OVS_UNLIKELY(recirc_depth)) {
+        hash = hash_finish(hash, recirc_depth);
+    }
+    return hash;
+}
+
 /* Allow other implementations to call dpcls_lookup() for subtable search. */
 bool
 dpcls_lookup(struct dpcls *cls, const struct netdev_flow_key *keys[],
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index f65d9ee8c..c4e47f715 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -7807,28 +7807,6 @@  dp_netdev_upcall(struct dp_netdev_pmd_thread *pmd, struct dp_packet *packet_,
                          actions, wc, put_actions, dp->upcall_aux);
 }
 
-static inline uint32_t
-dpif_netdev_packet_get_rss_hash(struct dp_packet *packet,
-                                const struct miniflow *mf)
-{
-    uint32_t hash, recirc_depth;
-
-    if (OVS_LIKELY(dp_packet_rss_valid(packet))) {
-        hash = dp_packet_get_rss_hash(packet);
-    } else {
-        hash = miniflow_hash_5tuple(mf, 0);
-        dp_packet_set_rss_hash(packet, hash);
-    }
-
-    /* The RSS hash must account for the recirculation depth to avoid
-     * collisions in the exact match cache */
-    recirc_depth = *recirc_depth_get_unsafe();
-    if (OVS_UNLIKELY(recirc_depth)) {
-        hash = hash_finish(hash, recirc_depth);
-    }
-    return hash;
-}
-
 struct packet_batch_per_flow {
     unsigned int byte_count;
     uint16_t tcp_flags;