table: add table entry priority
authorCristian Dumitrescu <cristian.dumitrescu@intel.com>
Tue, 16 Feb 2021 20:46:45 +0000 (20:46 +0000)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 23 Mar 2021 17:49:41 +0000 (18:49 +0100)
Add support for table entry priority, which is required for the
wildcard match/ACL table type.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
lib/librte_pipeline/rte_swx_ctl.c
lib/librte_table/rte_swx_table.h

index 6bef9c3..2e4538b 100644 (file)
@@ -386,6 +386,9 @@ table_entry_duplicate(struct rte_swx_ctl_pipeline *ctl,
                               entry->key_mask,
                               table->params.key_size);
                }
+
+               /* key_priority. */
+               new_entry->key_priority = entry->key_priority;
        }
 
        if (data_duplicate) {
@@ -1672,6 +1675,28 @@ rte_swx_ctl_pipeline_table_entry_read(struct rte_swx_ctl_pipeline *ctl,
        tokens += 1 + table->info.n_match_fields;
        n_tokens -= 1 + table->info.n_match_fields;
 
+       /*
+        * Match priority.
+        */
+       if (n_tokens && !strcmp(tokens[0], "priority")) {
+               char *priority = tokens[1];
+               uint32_t val;
+
+               if (n_tokens < 2)
+                       goto error;
+
+               /* Parse. */
+               val = strtoul(priority, &priority, 0);
+               if (priority[0])
+                       goto error;
+
+               /* Copy to entry. */
+               entry->key_priority = val;
+
+               tokens += 2;
+               n_tokens -= 2;
+       }
+
        /*
         * Action.
         */
@@ -1768,6 +1793,8 @@ table_entry_printf(FILE *f,
                        fprintf(f, "%02x", entry->key_mask[i]);
        }
 
+       fprintf(f, " priority %u", entry->key_priority);
+
        fprintf(f, " action %s ", action->info.name);
        for (i = 0; i < action->data_size; i++)
                fprintf(f, "%02x", entry->action_data[i]);
index 5a3137e..0044671 100644 (file)
@@ -89,6 +89,15 @@ struct rte_swx_table_entry {
         */
        uint64_t key_signature;
 
+       /** Key priority for the current entry. Useful for wildcard match (as
+        * match rules are commonly overlapping with other rules), ignored for
+        * exact match (as match rules never overlap, hence all rules have the
+        * same match priority) and for LPM (match priority is driven by the
+        * prefix length, with non-overlapping prefixes essentially having the
+        * same match priority). Value 0 indicates the highest match priority.
+        */
+       uint32_t key_priority;
+
        /** Action ID for the current entry. */
        uint64_t action_id;