diff mbox series

[ovs-dev,v1,5/6] dpif-netdev: remove unnecessary key length calculation in fast path

Message ID 20200602071005.29925-6-Yanqin.Wei@arm.com
State Changes Requested
Headers show
Series Memory access optimization for flow scalability of userspace datapath. | expand

Commit Message

Yanqin Wei June 2, 2020, 7:10 a.m. UTC
Key length is only useful for emc table. This patch moves the key length
calculation into emc_change_entry for fast path performance.

Reviewed-by: Lijian Zhang <Lijian.Zhang@arm.com>
Reviewed-by: Malvika Gupta <Malvika.Gupta@arm.com>
Reviewed-by: Ruifeng Wang <Ruifeng.Wang@arm.com>
Signed-off-by: Yanqin Wei <Yanqin.Wei@arm.com>
---
 lib/dpif-netdev.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index d575edefd..6ff8194ab 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -2846,8 +2846,8 @@  emc_change_entry(struct emc_entry *ce, struct dp_netdev_flow *flow,
         }
     }
     if (key) {
-        ce->key.len = key->len;
-        memcpy(&ce->key.mf, &key->mf, key->len);
+        ce->key.len = netdev_flow_key_size(miniflow_n_values(&key->mf));
+        memcpy(&ce->key.mf, &key->mf, ce->key.len);
     }
 }
 
@@ -6541,8 +6541,6 @@  smc_lookup_batch(struct dp_netdev_pmd_thread *pmd,
                     tcp_flags = miniflow_get_tcp_flags(&keys[i].mf);
 
                     /* SMC hit and emc miss, we insert into EMC */
-                    keys[i].len =
-                        netdev_flow_key_size(miniflow_n_values(&keys[i].mf));
                     emc_probabilistic_insert(pmd, &keys[i], flow);
                     /* Add these packets into the flow map in the same order
                      * as received.
@@ -6831,10 +6829,6 @@  fast_path_processing(struct dp_netdev_pmd_thread *pmd,
     int lookup_cnt = 0, add_lookup_cnt;
     bool any_miss;
 
-    for (size_t i = 0; i < cnt; i++) {
-        /* Key length is needed in all the cases, hash computed on demand. */
-        keys[i]->len = netdev_flow_key_size(miniflow_n_values(&keys[i]->mf));
-    }
     /* Get the classifier for the in_port */
     cls = dp_netdev_pmd_lookup_dpcls(pmd, in_port);
     if (OVS_LIKELY(cls)) {