2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-30 22:05:19 +00:00

dpif-netdev: Add command to switch dpif implementation.

This commit adds a new command to allow the user to switch
the active DPIF implementation at runtime. A probe function
is executed before switching the DPIF implementation, to ensure
the CPU is capable of running the ISA required. For example, the
below code will switch to the AVX512 enabled DPIF assuming
that the runtime CPU is capable of running AVX512 instructions:

 $ ovs-appctl dpif-netdev/dpif-impl-set dpif_avx512

A new configuration flag is added to allow selection of the
default DPIF. This is useful for running the unit-tests against
the available DPIF implementations, without modifying each unit test.

The design of the testing & validation for ISA optimized DPIF
implementations is based around the work already upstream for DPCLS.
Note however that a DPCLS lookup has no state or side-effects, allowing
the auto-validator implementation to perform multiple lookups and
provide consistent statistic counters.

The DPIF component does have state, so running two implementations in
parallel and comparing output is not a valid testing method, as there
are changes in DPIF statistic counters (side effects). As a result, the
DPIF is tested directly against the unit-tests.

Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
Co-authored-by: Cian Ferriter <cian.ferriter@intel.com>
Signed-off-by: Cian Ferriter <cian.ferriter@intel.com>
Acked-by: Flavio Leitner <fbl@sysclose.org>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
This commit is contained in:
Harry van Haaren
2021-07-09 15:58:18 +00:00
committed by Ian Stokes
parent 9ac84a1a36
commit abb807e27d
10 changed files with 302 additions and 15 deletions

View File

@@ -469,8 +469,6 @@ static void dp_netdev_execute_actions(struct dp_netdev_pmd_thread *pmd,
const struct flow *flow,
const struct nlattr *actions,
size_t actions_len);
static int32_t dp_netdev_input(struct dp_netdev_pmd_thread *,
struct dp_packet_batch *, odp_port_t port_no);
static void dp_netdev_recirculate(struct dp_netdev_pmd_thread *,
struct dp_packet_batch *);
@@ -967,6 +965,66 @@ dpif_netdev_subtable_lookup_set(struct unixctl_conn *conn, int argc OVS_UNUSED,
ds_destroy(&reply);
}
static void
dpif_netdev_impl_set(struct unixctl_conn *conn, int argc OVS_UNUSED,
const char *argv[], void *aux OVS_UNUSED)
{
/* This function requires just one parameter, the DPIF name. */
const char *dpif_name = argv[1];
struct shash_node *node;
static const char *error_description[2] = {
"Unknown DPIF implementation",
"CPU doesn't support the required instruction for",
};
ovs_mutex_lock(&dp_netdev_mutex);
int32_t err = dp_netdev_impl_set_default_by_name(dpif_name);
if (err) {
struct ds reply = DS_EMPTY_INITIALIZER;
ds_put_format(&reply, "DPIF implementation not available: %s %s.\n",
error_description[ (err == -ENOTSUP) ], dpif_name);
const char *reply_str = ds_cstr(&reply);
unixctl_command_reply_error(conn, reply_str);
VLOG_ERR("%s", reply_str);
ds_destroy(&reply);
ovs_mutex_unlock(&dp_netdev_mutex);
return;
}
SHASH_FOR_EACH (node, &dp_netdevs) {
struct dp_netdev *dp = node->data;
/* Get PMD threads list, required to get DPCLS instances. */
size_t n;
struct dp_netdev_pmd_thread **pmd_list;
sorted_poll_thread_list(dp, &pmd_list, &n);
for (size_t i = 0; i < n; i++) {
struct dp_netdev_pmd_thread *pmd = pmd_list[i];
if (pmd->core_id == NON_PMD_CORE_ID) {
continue;
}
/* Initialize DPIF function pointer to the newly configured
* default. */
dp_netdev_input_func default_func = dp_netdev_impl_get_default();
atomic_uintptr_t *pmd_func = (void *) &pmd->netdev_input_func;
atomic_store_relaxed(pmd_func, (uintptr_t) default_func);
};
}
ovs_mutex_unlock(&dp_netdev_mutex);
/* Reply with success to command. */
struct ds reply = DS_EMPTY_INITIALIZER;
ds_put_format(&reply, "DPIF implementation set to %s.\n", dpif_name);
const char *reply_str = ds_cstr(&reply);
unixctl_command_reply(conn, reply_str);
VLOG_INFO("%s", reply_str);
ds_destroy(&reply);
}
static void
dpif_netdev_pmd_rebalance(struct unixctl_conn *conn, int argc,
const char *argv[], void *aux OVS_UNUSED)
@@ -1189,6 +1247,10 @@ dpif_netdev_init(void)
unixctl_command_register("dpif-netdev/subtable-lookup-prio-get", "",
0, 0, dpif_netdev_subtable_lookup_get,
NULL);
unixctl_command_register("dpif-netdev/dpif-impl-set",
"dpif_implementation_name",
1, 1, dpif_netdev_impl_set,
NULL);
return 0;
}
@@ -6126,8 +6188,10 @@ dp_netdev_configure_pmd(struct dp_netdev_pmd_thread *pmd, struct dp_netdev *dp,
hmap_init(&pmd->send_port_cache);
cmap_init(&pmd->tx_bonds);
/* Initialize the DPIF function pointer to the default scalar version. */
pmd->netdev_input_func = dp_netdev_input;
/* Initialize DPIF function pointer to the default configured version. */
dp_netdev_input_func default_func = dp_netdev_impl_get_default();
atomic_uintptr_t *pmd_func = (void *) &pmd->netdev_input_func;
atomic_init(pmd_func, (uintptr_t) default_func);
/* init the 'flow_cache' since there is no
* actual thread created for NON_PMD_CORE_ID. */
@@ -7100,7 +7164,7 @@ dp_netdev_input__(struct dp_netdev_pmd_thread *pmd,
}
}
static int32_t
int32_t
dp_netdev_input(struct dp_netdev_pmd_thread *pmd,
struct dp_packet_batch *packets,
odp_port_t port_no)