Skip to content

Commit

Permalink
Make XVIO compatible with RTE_FLOW
Browse files Browse the repository at this point in the history
Add a new parameter to virtio-forwarder to make it compatible with
DPDK RTE_FLOW. There are three modes that can be used:
1.`NULL` represents a non-dpdk RTE_FLOW mode.
2.If 0 is written, the default token value will be used.
3.Manually fill the token value in the format of the UUID.

Signed-off-by: Zerun Fu <[email protected]>
Reviewed-by: Peng Zhang <[email protected]>
Signed-off-by: Louis Peens <[email protected]>
  • Loading branch information
zerun-fu authored and louis-peens committed Feb 23, 2023
1 parent cda550c commit 2787a43
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 1 deletion.
6 changes: 6 additions & 0 deletions dpdk_eal.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ int dpdk_eal_initialize(const struct dpdk_conf *conf)
add_arg(&argv, &argc, conf->huge_dir);
add_arg(&argv, &argc, "--file-prefix");
add_arg(&argv, &argc, "virtio-forwarder_");
#if RTE_VERSION_NUM(20, 8, 0, 0) <= RTE_VERSION
if (conf->enable_vfio_vf_token) {
add_arg(&argv, &argc, "--vfio-vf-token");
add_arg(&argv, &argc, conf->vfio_vf_token);
}
#endif

/* Unlink the hugepages after mapping to ensure they're gone when app exits. */
add_arg(&argv, &argc, "--huge-unlink");
Expand Down
5 changes: 5 additions & 0 deletions dpdk_eal.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,20 @@
#define _DPDK_EAL_H

#include <stdint.h>
#include <stdbool.h>

#define VFIO_VF_TOKEN_LEN 37

struct dpdk_conf {
unsigned log_level;
unsigned master_lcore;
char huge_dir[32];
char vfio_vf_token[VFIO_VF_TOKEN_LEN];
uint64_t core_bitmap;
unsigned use_jumbo:1;
unsigned enable_tso:1;
unsigned enable_same_numa:1;
bool enable_vfio_vf_token;
};

int dpdk_eal_initialize(const struct dpdk_conf *conf);
Expand Down
1 change: 1 addition & 0 deletions startup/vio4wd-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,5 @@ fi
${VIRTIOFWD_DYNAMIC_SOCKETS:+--dynamic-sockets} \
${VIRTIOFWD_CPU_NIC_SAME_NUMA:+--same-numa} \
${CPU_PINS_CMD_LINE} \
${VIRTIOFWD_VFIO_VF_TOKEN:+--vfio-vf-token="$VIRTIOFWD_VFIO_VF_TOKEN"} \
${STATIC_VFS_CMD_LINE}
15 changes: 15 additions & 0 deletions startup/virtioforwarder
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,21 @@ VIRTIOFWD_DYNAMIC_SOCKETS=
# then enable this option.
# Set to anything non-null to enable
VIRTIOFWD_CPU_NIC_SAME_NUMA=

# This VF token can be passed to DPDK by using EAL parameter ``--vfio-vf-token``.
# The token will be used for all PF and VF ports within the application. This
# token is used in conjunction with the DPDK RTE_FLOW offload function. When
# using RTE_FLOW, ensure that the token is consistent with applications such as OVS.
# (default: 14d63f20-8445-11ea-8900-1f9ce7d5650d)
#
# There are three modes that can be used: NULL represents a non-DPDK RTE_FLOW
# mode, the ``--vfio-vf-token`` parameter will not passed. If you fill in 0, the
# default token value is used. The last mode is manually write the token value in
# the format of the UUID.
# VIRTIOFWD_VFIO_VF_TOKEN=
# VIRTIOFWD_VFIO_VF_TOKEN=0
# VIRTIOFWD_VFIO_VF_TOKEN=14d63f20-8445-11ea-8900-1f9ce7d5650d
VIRTIOFWD_VFIO_VF_TOKEN=
#-------------------------------------------------------------------------------


Expand Down
28 changes: 27 additions & 1 deletion virtio_forwarder_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@
#define DEFAULT_VHOSTUSER_PATH "/tmp" /* /var/run/virtio-forwarder */
#define DEFAULT_VHOSTUSER_SOCKNAME "virtio-forwarder%u.sock"
#define DAEMONNAME "virtio-forwarder"
#if RTE_VERSION_NUM(20, 8, 0, 0) <= RTE_VERSION
#define DEFAULT_VFIO_VF_TOKEN "14d63f20-8445-11ea-8900-1f9ce7d5650d"
#endif

static bool running = true;
static bool must_stop = false;
Expand Down Expand Up @@ -616,6 +619,24 @@ cmdline_enable_same_numa(void *opaque __attribute__((unused)),
return 0;
}

#if RTE_VERSION_NUM(20, 8, 0, 0) <= RTE_VERSION
static int
cmdline_set_vfio_vf_token(void *opaque __attribute__((unused)),
const char *arg,
int opt_index __attribute__((unused)))
{
if (strcmp(arg, "\0") == 0) {
dpdk_cfg.enable_vfio_vf_token = false;
} else if (strcmp(arg, "0") == 0) {
dpdk_cfg.enable_vfio_vf_token = true;
} else {
dpdk_cfg.enable_vfio_vf_token = true;
snprintf(dpdk_cfg.vfio_vf_token, VFIO_VF_TOKEN_LEN, arg);
}
return 0;
}
#endif

static int configure_signals(void)
{
sigset_t sigset;
Expand Down Expand Up @@ -672,6 +693,9 @@ cmdline_opt_t opts[] = {
{ "enable-jumbo", 'J', 0, cmdline_enable_jumbo, 0, "Enable jumbo frame support for the relay (increases hugepage memory requirement)" },
{ "enable-mrgbuf", 'R', 0, cmdline_enable_mrgbuf, 0, "Enable virtio RX buffer merging (can impact small packet performance)" },
{ "add-pci-vf", 'P', 0, cmdline_add_static_vf, 1, "Add a static VF, <PCI>=<virtio_id>, e.g. 0000:05:08.1=1" },
#if RTE_VERSION_NUM(20, 8, 0, 0) <= RTE_VERSION
{ "vfio-vf-token", 't', 0, cmdline_set_vfio_vf_token, 1, "Add a token to use all PF and VF ports within the application (default: "DEFAULT_VFIO_VF_TOKEN")" },
#endif
#if RTE_VERSION_NUM(16, 7, 0, 0) <= RTE_VERSION
{ "vhostuser-client", 'i', 0, cmdline_enable_vhostclient, 0, "Use vhostuser in client mode (default: server mode)" },
#endif
Expand Down Expand Up @@ -707,7 +731,9 @@ int main(int argc, char *argv[])
dpdk_cfg.log_level = DEFAULT_LOG_LEVEL;
dpdk_cfg.master_lcore = DEFAULT_MASTER_LCORE;
snprintf(dpdk_cfg.huge_dir, 32, DEFAULT_HUGE_PATH);

#if RTE_VERSION_NUM(20, 8, 0, 0) <= RTE_VERSION
snprintf(dpdk_cfg.vfio_vf_token, VFIO_VF_TOKEN_LEN, DEFAULT_VFIO_VF_TOKEN);
#endif
snprintf(ovsdb_cfg.ovsdb_sock_path, 128, DEFAULT_OVSDB_SOCK);

snprintf(zmq_config_ep, sizeof zmq_config_ep, DEFAULT_ZMQ_CONFIG_EP);
Expand Down

0 comments on commit 2787a43

Please sign in to comment.