dpif-netdev: properly maintain exact match cache hit counter
authorAndy Zhou <azhou@ovn.org>
Tue, 26 Jan 2016 02:43:47 +0000 (18:43 -0800)
committerAndy Zhou <azhou@ovn.org>
Thu, 28 Jan 2016 01:23:02 +0000 (17:23 -0800)
Current logic counts dropped packet as cache hit which is not
correct. This patch removes dropped packet to improve accuracy.

Signed-off-by: Andy Zhou <azhou@ovn.org>
Acked-by: Daniele Di Proietto <diproiettod@vmware.com>
lib/dpif-netdev.c

index ad6b202..9d399a0 100644 (file)
@@ -3308,13 +3308,14 @@ emc_processing(struct dp_netdev_pmd_thread *pmd, struct dp_packet **packets,
 {
     struct emc_cache *flow_cache = &pmd->flow_cache;
     struct netdev_flow_key key;
-    size_t i, notfound_cnt = 0;
+    size_t i, n_missed = 0, n_dropped = 0;
 
     for (i = 0; i < cnt; i++) {
         struct dp_netdev_flow *flow;
 
         if (OVS_UNLIKELY(dp_packet_size(packets[i]) < ETH_HEADER_LEN)) {
             dp_packet_delete(packets[i]);
+            n_dropped++;
             continue;
         }
 
@@ -3332,17 +3333,17 @@ emc_processing(struct dp_netdev_pmd_thread *pmd, struct dp_packet **packets,
             dp_netdev_queue_batches(packets[i], flow, &key.mf, batches,
                                     n_batches);
         } else {
-            if (i != notfound_cnt) {
-                dp_packet_swap(&packets[i], &packets[notfound_cnt]);
+            if (i != n_missed) {
+                dp_packet_swap(&packets[i], &packets[n_missed]);
             }
 
-            keys[notfound_cnt++] = key;
+            keys[n_missed++] = key;
         }
     }
 
-    dp_netdev_count_packet(pmd, DP_STAT_EXACT_HIT, cnt - notfound_cnt);
+    dp_netdev_count_packet(pmd, DP_STAT_EXACT_HIT, cnt - n_dropped - n_missed);
 
-    return notfound_cnt;
+    return n_missed;
 }
 
 static inline void