This commit adds a new command to allow the user to switch
the active action implementation at runtime. A probe function
is executed before switching the implementation, to ensure
the CPU is capable of running the ISA required.

Usage:
  $ ovs-appctl dpif-netdev/action-impl-set scalar

This commit also adds a new command to retrieve the list of available
action implementations. This can be used by to check what implementations
of actions are available and what implementation is active during runtime.

Usage:
   $ ovs-appctl dpif-netdev/action-impl-get

Signed-off-by: Emma Finn <[email protected]>

---
v3:
- Refactored to fix unit test failures
---
v2:
- Refactor to fix build warnings
---
---
 lib/dpif-netdev.c         | 39 +++++++++++++++++++++++++++++++++++++++
 lib/odp-execute-private.c | 14 ++++++++++++++
 lib/odp-execute.h         |  3 +++
 3 files changed, 56 insertions(+)

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 277e0d6c3..9684bbbc4 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -59,6 +59,7 @@
 #include "netdev-vport.h"
 #include "netlink.h"
 #include "odp-execute.h"
+#include "odp-execute-private.h"
 #include "odp-util.h"
 #include "openvswitch/dynamic-string.h"
 #include "openvswitch/list.h"
@@ -1310,6 +1311,38 @@ error:
     ds_destroy(&reply);
 }
 
+static void
+action_impl_set(struct unixctl_conn *conn, int argc OVS_UNUSED,
+                const char *argv[] OVS_UNUSED, void *aux OVS_UNUSED)
+{
+    struct ds reply = DS_EMPTY_INITIALIZER;
+
+    int32_t err = odp_actions_impl_set(argv[1]);
+    if (err) {
+        ds_put_format(&reply, "action implementation %s not found.\n",
+                      argv[1]);
+        const char *reply_str = ds_cstr(&reply);
+        unixctl_command_reply_error(conn, reply_str);
+        VLOG_ERR("%s", reply_str);
+        ds_destroy(&reply);
+        return;
+    }
+
+    ds_put_format(&reply, "action implementation set to %s.\n", argv[1]);
+    unixctl_command_reply(conn, ds_cstr(&reply));
+    ds_destroy(&reply);
+}
+
+static void
+action_impl_get(struct unixctl_conn *conn, int argc OVS_UNUSED,
+                const char *argv[] OVS_UNUSED, void *aux OVS_UNUSED)
+{
+    struct ds reply = DS_EMPTY_INITIALIZER;
+    odp_execute_action_get(&reply);
+    unixctl_command_reply(conn, ds_cstr(&reply));
+    ds_destroy(&reply);
+}
+
 static void
 dpif_netdev_pmd_rebalance(struct unixctl_conn *conn, int argc,
                           const char *argv[], void *aux OVS_UNUSED)
@@ -1547,6 +1580,12 @@ dpif_netdev_init(void)
     unixctl_command_register("dpif-netdev/miniflow-parser-get", "",
                              0, 0, dpif_miniflow_extract_impl_get,
                              NULL);
+    unixctl_command_register("dpif-netdev/action-impl-set", "name",
+                             1, 1, action_impl_set,
+                             NULL);
+    unixctl_command_register("dpif-netdev/action-impl-get", "",
+                             0, 0, action_impl_get,
+                             NULL);
     return 0;
 }
 
diff --git a/lib/odp-execute-private.c b/lib/odp-execute-private.c
index 3260dc664..2301194a0 100644
--- a/lib/odp-execute-private.c
+++ b/lib/odp-execute-private.c
@@ -74,6 +74,20 @@ odp_execute_action_set(const char *name,
     return -1;
 }
 
+void
+odp_execute_action_get(struct ds *string)
+{
+    uint32_t i;
+
+    ds_put_cstr(string, "Available Actions implementations:\n");
+    for (i = 0; i < ACTION_IMPL_MAX; i++) {
+        ds_put_format(string, "  %s (available: %s, active: %s)\n",
+                      action_impls[i].name,
+                      action_impls[i].available ? "True" : "False",
+                      i == active_action_impl_index ? "True" : "False");
+    }
+}
+
 void
 odp_execute_action_init(void)
 {
diff --git a/lib/odp-execute.h b/lib/odp-execute.h
index 6441392b9..4f4cdc4ac 100644
--- a/lib/odp-execute.h
+++ b/lib/odp-execute.h
@@ -23,6 +23,7 @@
 #include <stdint.h>
 #include "openvswitch/types.h"
 
+struct ds;
 struct nlattr;
 struct dp_packet;
 struct pkt_metadata;
@@ -32,6 +33,8 @@ struct dp_packet_batch;
 /* Called once at initialization time. */
 void odp_execute_init(void);
 
+/* Runtime update get/set functionality. */
+int32_t odp_actions_impl_get(struct ds *name);
 int32_t odp_actions_impl_set(const char *name);
 
 typedef void (*odp_execute_cb)(void *dp, struct dp_packet_batch *batch,
-- 
2.25.1

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to