@@ -35,6 +35,9 @@ Post-v2.17.0
- Userspace datapath:
* Add actions auto-validator function to compare different actions
implementations against default implementation.
+ * Add command line option to switch between different actions
+ implementations available at run time.
+
v2.17.0 - 17 Feb 2022
@@ -262,3 +262,11 @@ PMDs in the case where no value is specified. By default "scalar" is used.
\fIstudy_cnt\fR defaults to 128 and indicates the number of packets that the
"study" miniflow implementation must parse before choosing an optimal
implementation.
+
+.IP "\fBdpif-netdev/action-impl-show\fR
+Lists the actions implementations that are available and highlights the
+currently enabled one.
+.
+.IP "\fBdpif-netdev/action-impl-set\fR \fIaction_impl\fR"
+Sets the action implementation to any available implementation. By default
+"scalar" is used.
@@ -63,6 +63,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"
@@ -1387,6 +1388,37 @@ 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;
+
+ int err = odp_actions_impl_set(argv[1]);
+ if (err) {
+ ds_put_format(&reply,
+ "Error: unknown action implementation, %s, specified!\n",
+ argv[1]);
+ unixctl_command_reply_error(conn, ds_cstr(&reply));
+ } else {
+ 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_show(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_info(&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)
@@ -1624,6 +1656,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-show", "",
+ 0, 0, action_impl_show,
+ NULL);
return 0;
}
@@ -68,6 +68,18 @@ odp_execute_action_set(const char *name,
return -EINVAL;
}
+void
+odp_execute_action_get_info(struct ds *string)
+{
+ ds_put_cstr(string, "Available Actions implementations:\n");
+ for (int 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 ? "Yes" : "No",
+ i == active_action_impl_index ? "Yes" : "No");
+ }
+}
+
void
odp_execute_action_init(void)
{
@@ -85,4 +85,7 @@ int action_autoval_init(struct odp_execute_action_impl *self);
int odp_execute_action_set(const char *name,
struct odp_execute_action_impl *active);
+void odp_execute_action_get_info(struct ds *name);
+
+
#endif /* ODP_EXTRACT_PRIVATE */
@@ -23,6 +23,7 @@
#include <stdint.h>
#include "openvswitch/types.h"
+struct ds;
struct nlattr;
struct dp_packet;
struct pkt_metadata;
@@ -36,6 +37,7 @@ typedef void (*odp_execute_action_cb)(struct dp_packet_batch *batch,
const struct nlattr *action);
int odp_actions_impl_set(const char *name);
+int odp_actions_impl_get(struct ds *name);
typedef void (*odp_execute_cb)(void *dp, struct dp_packet_batch *batch,
const struct nlattr *action, bool should_steal);
@@ -1200,3 +1200,33 @@ ovs-appctl: ovs-vswitchd: server returned an error
OVS_VSWITCHD_STOP
AT_CLEANUP
+
+AT_SETUP([PMD - ovs-actions configuration])
+OVS_VSWITCHD_START([], [], [], [--dummy-numa 0,0])
+AT_CHECK([ovs-vsctl add-port br0 p1 -- set Interface p1 type=dummy-pmd])
+
+dnl Scalar impl is set by default.
+AT_CHECK([ovs-vsctl show], [], [stdout])
+AT_CHECK([ovs-appctl dpif-netdev/action-impl-show | grep "scalar"], [], [dnl
+ scalar (available: Yes, active: Yes)
+])
+
+AT_CHECK([ovs-appctl dpif-netdev/action-impl-show | grep "autovalidator"], [], [dnl
+ autovalidator (available: Yes, active: No)
+])
+
+dnl Set the autovalidator impl to active.
+AT_CHECK([ovs-appctl dpif-netdev/action-impl-set autovalidator], [0], [dnl
+Action implementation set to autovalidator.
+])
+
+AT_CHECK([ovs-appctl dpif-netdev/action-impl-show | grep "scalar"], [], [dnl
+ scalar (available: Yes, active: No)
+])
+
+AT_CHECK([ovs-appctl dpif-netdev/action-impl-show | grep "autovalidator"], [], [dnl
+ autovalidator (available: Yes, active: Yes)
+])
+
+OVS_VSWITCHD_STOP
+AT_CLEANUP