diff mbox series

[ovs-dev,v4,3/7] dpif-netdev: add subtable-lookup-prio-get command.

Message ID 20200618165354.87787-4-harry.van.haaren@intel.com
State Superseded
Headers show
Series DPCLS Subtable ISA Optimization | expand

Commit Message

Harry van Haaren June 18, 2020, 4:53 p.m. UTC
This commit adds ia new command, "dpif-netdev/subtable-lookup-prio-get"
which prints the available sutable lookup functions in this OVS binary.
Example output from the command:

Available lookup functions (priority : name)
        0 : autovalidator
        1 : generic

Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>

---

v4:
- Add "prio" to name for consistency with "set" command (William Tu)
- Fix typo (William Tu)
---
 lib/dpif-netdev.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

Comments

William Tu June 27, 2020, 6:27 p.m. UTC | #1
On Thu, Jun 18, 2020 at 9:53 AM Harry van Haaren
<harry.van.haaren@intel.com> wrote:
>
> This commit adds ia new command, "dpif-netdev/subtable-lookup-prio-get"
> which prints the available sutable lookup functions in this OVS binary.
> Example output from the command:
>
> Available lookup functions (priority : name)
>         0 : autovalidator
>         1 : generic
>
> Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
>
LGTM.
Acked-by: William Tu <u9012063@gmail.com>
diff mbox series

Patch

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index f7cc85145..b23dddb50 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -1264,6 +1264,30 @@  sorted_poll_thread_list(struct dp_netdev *dp,
     *n = k;
 }
 
+static void
+dpif_netdev_subtable_lookup_get(struct unixctl_conn *conn, int argc OVS_UNUSED,
+                                const char *argv[] OVS_UNUSED,
+                                void *aux OVS_UNUSED)
+{
+    /* Get a list of all lookup functions */
+    struct dpcls_subtable_lookup_info_t *lookup_funcs = NULL;
+    int32_t count = dpcls_subtable_lookup_info_get(&lookup_funcs);
+    if (count < 0) {
+        unixctl_command_reply_error(conn, "error getting lookup names");
+        return;
+    }
+
+    /* Add all lookup functions to reply string */
+    struct ds reply = DS_EMPTY_INITIALIZER;
+    ds_put_cstr(&reply, "Available lookup functions (priority : name)\n");
+    for (int i = 0; i < count; i++) {
+        ds_put_format(&reply, "\t%d : %s\n", lookup_funcs[i].prio,
+                      lookup_funcs[i].name);
+    }
+    unixctl_command_reply(conn, ds_cstr(&reply));
+    ds_destroy(&reply);
+}
+
 static void
 dpif_netdev_subtable_lookup_set(struct unixctl_conn *conn, int argc,
                                 const char *argv[], void *aux OVS_UNUSED)
@@ -1528,6 +1552,9 @@  dpif_netdev_init(void)
                              "[lookup_func] [prio] [dp]",
                              2, 3, dpif_netdev_subtable_lookup_set,
                              NULL);
+    unixctl_command_register("dpif-netdev/subtable-lookup-prio-get", "",
+                             0, 0, dpif_netdev_subtable_lookup_get,
+                             NULL);
     return 0;
 }