summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorStanislav Zaikin <stanislav.zaikin@46labs.com>2023-06-22 16:46:01 +0200
committerBeno�t Ganne <bganne@cisco.com>2023-06-27 11:42:42 +0000
commit7f27ed666ecc4cf5db7ca76b3eba40f7d9092909 (patch)
tree75e381786744ab93a08a8759f0d7859e806cd017 /src/plugins
parent5fe1cf80cad75a2e08450303410fb484cdc708ad (diff)
af_xdp: create_api_v3 without namespace keyword
Namespace keyword is reverved c++ word, so it's not possible to include vapi header for af_xdp plugin and use it. Type: fix Signed-off-by: Stanislav Zaikin <stanislav.zaikin@46labs.com> Change-Id: I42a0e0a89ff2c407090d3c18c1bc5a5605ddf032
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/af_xdp/af_xdp.api48
-rw-r--r--src/plugins/af_xdp/api.c32
-rw-r--r--src/plugins/af_xdp/test_api.c52
3 files changed, 132 insertions, 0 deletions
diff --git a/src/plugins/af_xdp/af_xdp.api b/src/plugins/af_xdp/af_xdp.api
index 2ccd5c41fa4..4c2908e2037 100644
--- a/src/plugins/af_xdp/af_xdp.api
+++ b/src/plugins/af_xdp/af_xdp.api
@@ -57,6 +57,7 @@ define af_xdp_create
vl_api_af_xdp_flag_t flags [default=0];
string prog[256];
option vat_help = "<host-if linux-ifname> [name ifname] [rx-queue-size size] [tx-queue-size size] [num-rx-queues <num|all>] [prog pathname] [zero-copy|no-zero-copy] [no-syscall-lock]";
+ option deprecated;
};
/** \brief
@@ -88,6 +89,7 @@ define af_xdp_create_v2
string prog[256];
string namespace[64];
option vat_help = "<host-if linux-ifname> [name ifname] [rx-queue-size size] [tx-queue-size size] [num-rx-queues <num|all>] [prog pathname] [netns ns] [zero-copy|no-zero-copy] [no-syscall-lock]";
+ option deprecated;
};
/** \brief
@@ -101,6 +103,7 @@ define af_xdp_create_reply
u32 context;
i32 retval;
vl_api_interface_index_t sw_if_index;
+ option deprecated;
};
/** \brief
@@ -114,6 +117,7 @@ define af_xdp_create_v2_reply
u32 context;
i32 retval;
vl_api_interface_index_t sw_if_index;
+ option deprecated;
};
/** \brief
@@ -122,6 +126,50 @@ define af_xdp_create_v2_reply
@param sw_if_index - interface index
*/
+/** \brief
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+ @param host_if - Linux netdev interface name
+ @param name - new af_xdp interface name (optional)
+ @param rxq_num - number of receive queues. 65535 can be used as special value to request all available queues (optional)
+ @param rxq_size - receive queue size (optional)
+ @param txq_size - transmit queue size (optional)
+ @param mode - operation mode (optional)
+ @param flags - flags (optional)
+ @param prog - eBPF program path (optional)
+ @param netns - netns of nic (optional)
+*/
+
+autoendian define af_xdp_create_v3
+{
+ u32 client_index;
+ u32 context;
+
+ string host_if[64];
+ string name[64];
+ u16 rxq_num [default=1];
+ u16 rxq_size [default=0];
+ u16 txq_size [default=0];
+ vl_api_af_xdp_mode_t mode [default=0];
+ vl_api_af_xdp_flag_t flags [default=0];
+ string prog[256];
+ string netns[64];
+ option vat_help = "<host-if linux-ifname> [name ifname] [rx-queue-size size] [tx-queue-size size] [num-rx-queues <num|all>] [prog pathname] [netns ns] [zero-copy|no-zero-copy] [no-syscall-lock]";
+};
+
+/** \brief
+ @param context - sender context, to match reply w/ request
+ @param retval - return value for request
+ @param sw_if_index - software index for the new af_xdp interface
+*/
+
+autoendian define af_xdp_create_v3_reply
+{
+ u32 context;
+ i32 retval;
+ vl_api_interface_index_t sw_if_index;
+};
+
autoreply define af_xdp_delete
{
u32 client_index;
diff --git a/src/plugins/af_xdp/api.c b/src/plugins/af_xdp/api.c
index 659825a73b6..3e9a3fe2578 100644
--- a/src/plugins/af_xdp/api.c
+++ b/src/plugins/af_xdp/api.c
@@ -116,6 +116,38 @@ vl_api_af_xdp_create_v2_t_handler (vl_api_af_xdp_create_v2_t *mp)
}
static void
+vl_api_af_xdp_create_v3_t_handler (vl_api_af_xdp_create_v3_t *mp)
+{
+ vlib_main_t *vm = vlib_get_main ();
+ af_xdp_main_t *rm = &af_xdp_main;
+ vl_api_af_xdp_create_v3_reply_t *rmp;
+ af_xdp_create_if_args_t args;
+ int rv;
+
+ clib_memset (&args, 0, sizeof (af_xdp_create_if_args_t));
+
+ args.linux_ifname = mp->host_if[0] ? (char *) mp->host_if : 0;
+ args.name = mp->name[0] ? (char *) mp->name : 0;
+ args.prog = mp->prog[0] ? (char *) mp->prog : 0;
+ args.netns = mp->netns[0] ? (char *) mp->netns : 0;
+ args.mode = af_xdp_api_mode (mp->mode);
+ args.flags = af_xdp_api_flags (mp->flags);
+ args.rxq_size = mp->rxq_size;
+ args.txq_size = mp->txq_size;
+ args.rxq_num = mp->rxq_num;
+
+ af_xdp_create_if (vm, &args);
+ rv = args.rv;
+
+ /* clang-format off */
+ REPLY_MACRO2_END (VL_API_AF_XDP_CREATE_V3_REPLY,
+ ({
+ rmp->sw_if_index = args.sw_if_index;
+ }));
+ /* clang-format on */
+}
+
+static void
vl_api_af_xdp_delete_t_handler (vl_api_af_xdp_delete_t * mp)
{
vlib_main_t *vm = vlib_get_main ();
diff --git a/src/plugins/af_xdp/test_api.c b/src/plugins/af_xdp/test_api.c
index 46ba6f100ee..581697e341d 100644
--- a/src/plugins/af_xdp/test_api.c
+++ b/src/plugins/af_xdp/test_api.c
@@ -126,6 +126,40 @@ api_af_xdp_create_v2 (vat_main_t *vam)
return ret;
}
+/* af_xdp create v2 API */
+static int
+api_af_xdp_create_v3 (vat_main_t *vam)
+{
+ vl_api_af_xdp_create_v3_t *mp;
+ af_xdp_create_if_args_t args;
+ int ret;
+
+ if (!unformat_user (vam->input, unformat_af_xdp_create_if_args, &args))
+ {
+ clib_warning ("unknown input `%U'", format_unformat_error, vam->input);
+ return -99;
+ }
+
+ M (AF_XDP_CREATE, mp);
+
+ snprintf ((char *) mp->host_if, sizeof (mp->host_if), "%s",
+ args.linux_ifname ?: "");
+ snprintf ((char *) mp->name, sizeof (mp->name), "%s", args.name ?: "");
+ snprintf ((char *) mp->netns, sizeof (mp->netns), "%s", args.netns ?: "");
+ mp->rxq_num = args.rxq_num;
+ mp->rxq_size = args.rxq_size;
+ mp->txq_size = args.txq_size;
+ mp->mode = api_af_xdp_mode (args.mode);
+ if (args.flags & AF_XDP_CREATE_FLAGS_NO_SYSCALL_LOCK)
+ mp->flags |= AF_XDP_API_FLAGS_NO_SYSCALL_LOCK;
+ snprintf ((char *) mp->prog, sizeof (mp->prog), "%s", args.prog ?: "");
+
+ S (mp);
+ W (ret);
+
+ return ret;
+}
+
/* af_xdp-create reply handler */
static void
vl_api_af_xdp_create_reply_t_handler (vl_api_af_xdp_create_reply_t * mp)
@@ -162,6 +196,24 @@ vl_api_af_xdp_create_v2_reply_t_handler (vl_api_af_xdp_create_v2_reply_t *mp)
vam->regenerate_interface_table = 1;
}
+/* af_xdp-create v3 reply handler */
+static void
+vl_api_af_xdp_create_v3_reply_t_handler (vl_api_af_xdp_create_v2_reply_t *mp)
+{
+ vat_main_t *vam = af_xdp_test_main.vat_main;
+ i32 retval = mp->retval;
+
+ if (retval == 0)
+ {
+ fformat (vam->ofp, "created af_xdp with sw_if_index %d\n",
+ mp->sw_if_index);
+ }
+
+ vam->retval = retval;
+ vam->result_ready = 1;
+ vam->regenerate_interface_table = 1;
+}
+
/* af_xdp delete API */
static int
api_af_xdp_delete (vat_main_t * vam)