[ovs-dev] [PATCH 1/3] Update some comments

Mark D. Gray mark.d.gray at intel.com
Fri Mar 6 15:37:36 UTC 2015


From: "Mark D. Gray" <mark.d.gray at intel.com>

Signed-off-by: Mark D. Gray <mark.d.gray at intel.com>
---
 lib/dpif-netdev.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index f01fecb..a0a0590 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -3547,7 +3547,10 @@ static bool
 dpcls_lookup(const struct dpcls *cls, const struct netdev_flow_key keys[],
              struct dpcls_rule **rules, const size_t cnt)
 {
-    /* The batch size 16 was experimentally found faster than 8 or 32. */
+    /* Process 'keys' in batch. Each of 'cnt' 'keys' are represented by 1
+     * bit in bitmask defined in 'maps' below.
+     *
+     * The batch size 16 was experimentally found faster than 8 or 32. */
     typedef uint16_t map_type;
 #define MAP_BITS (sizeof(map_type) * CHAR_BIT)
 
@@ -3559,12 +3562,15 @@ dpcls_lookup(const struct dpcls *cls, const struct netdev_flow_key keys[],
     map_type maps[N_MAPS];
     struct dpcls_subtable *subtable;
 
+    /* Initially set all bits to 1 but clear last couple of bits if 'cnt'
+     * is not a multiple of the batch size */
     memset(maps, 0xff, sizeof maps);
     if (cnt % MAP_BITS) {
         maps[N_MAPS - 1] >>= MAP_BITS - cnt % MAP_BITS; /* Clear extra bits. */
     }
     memset(rules, 0, cnt * sizeof *rules);
 
+    /* Iterate over subtables in classifier in priority order */
     PVECTOR_FOR_EACH (subtable, &cls->subtables) {
         const struct netdev_flow_key *mkeys = keys;
         struct dpcls_rule **mrules = rules;
@@ -3573,6 +3579,7 @@ dpcls_lookup(const struct dpcls *cls, const struct netdev_flow_key keys[],
 
         BUILD_ASSERT_DECL(sizeof remains == sizeof *maps);
 
+        /* Iterate over 'mkeys' and 'mrules' in 'N_MAPS' batches of 'MAP_BITS'*/
         for (m = 0; m < N_MAPS; m++, mkeys += MAP_BITS, mrules += MAP_BITS) {
             uint32_t hashes[MAP_BITS];
             const struct cmap_node *nodes[MAP_BITS];
@@ -3588,7 +3595,7 @@ dpcls_lookup(const struct dpcls *cls, const struct netdev_flow_key keys[],
                 hashes[i] = netdev_flow_key_hash_in_mask(&mkeys[i],
                                                          &subtable->mask);
             }
-            /* Lookup. */
+            /* Lookup */
             map = cmap_find_batch(&subtable->rules, map, hashes, nodes);
             /* Check results. */
             ULONG_FOR_EACH_1(i, map) {
-- 
1.9.3




More information about the dev mailing list