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.zh...@arm.com>
Reviewed-by: Malvika Gupta <malvika.gu...@arm.com>
Reviewed-by: Ruifeng Wang <ruifeng.w...@arm.com>
Signed-off-by: Yanqin Wei <yanqin....@arm.com>
---
 lib/dpif-netdev.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

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)) {
-- 
2.17.1

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to