summaryrefslogtreecommitdiffstats
path: root/src/plugins/avf
diff options
context:
space:
mode:
authorJakub Grajciar <jgrajcia@cisco.com>2018-06-26 12:58:22 +0200
committerDamjan Marion <dmarion@me.com>2018-06-27 16:16:28 +0000
commit6c9b9644450b5ee5672b1e0f66257b0e09fb0734 (patch)
tree4073aeed75b0f022ec6a174e6ed40a7d58a9cff0 /src/plugins/avf
parent99d7a72cbcad959e805e8e8b5efb112e9def69c2 (diff)
avf: binary API and configurable RX/TX queue size
Change-Id: Ibd3a8d28d8f1df2bc14c42e48498f6ac26081192 Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
Diffstat (limited to 'src/plugins/avf')
-rw-r--r--src/plugins/avf/avf.api59
-rw-r--r--src/plugins/avf/avf.h9
-rw-r--r--src/plugins/avf/avf_all_api_h.h26
-rw-r--r--src/plugins/avf/avf_api.c161
-rw-r--r--src/plugins/avf/avf_msg_enum.h39
-rw-r--r--src/plugins/avf/avf_test.c233
-rw-r--r--src/plugins/avf/cli.c9
-rw-r--r--src/plugins/avf/device.c37
-rw-r--r--src/plugins/avf/virtchnl.h5
9 files changed, 566 insertions, 12 deletions
diff --git a/src/plugins/avf/avf.api b/src/plugins/avf/avf.api
new file mode 100644
index 00000000000..096d45b8c82
--- /dev/null
+++ b/src/plugins/avf/avf.api
@@ -0,0 +1,59 @@
+/*
+ *------------------------------------------------------------------
+ * Copyright (c) 2018 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *------------------------------------------------------------------
+ */
+
+option version = "1.0.0";
+
+/** \brief
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+ @param pci_addr - pci address as unsigned 32bit integer:
+ 0-15 domain, 16-23 bus, 24-28 slot, 29-31 function
+ ddddddddddddddddbbbbbbbbsssssfff
+ @param rxq_size - receive queue size
+ @param txq_size - transmit queue size
+*/
+
+autoreply define avf_create
+{
+ u32 client_index;
+ u32 context;
+
+ u32 pci_addr;
+ i32 enable_elog;
+ u16 rxq_size;
+ u16 txq_size;
+};
+
+/** \brief
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+ @param sw_if_index - interface index
+*/
+
+autoreply define avf_delete
+{
+ u32 client_index;
+ u32 context;
+
+ u32 sw_if_index;
+};
+
+/*
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/src/plugins/avf/avf.h b/src/plugins/avf/avf.h
index bd5af01adf8..c8074ebf6c7 100644
--- a/src/plugins/avf/avf.h
+++ b/src/plugins/avf/avf.h
@@ -15,6 +15,9 @@
*------------------------------------------------------------------
*/
+#ifndef _AVF_H_
+#define _AVF_H_
+
#include <avf/virtchnl.h>
#include <vlib/log.h>
@@ -158,6 +161,8 @@ STATIC_ASSERT (VNET_DEVICE_INPUT_N_NEXT_NODES < 256, "too many next nodes");
typedef struct
{
+ u16 msg_id_base;
+
avf_device_t *devices;
avf_per_thread_data_t *per_thread_data;
vlib_physmem_region_index_t physmem_region;
@@ -175,6 +180,8 @@ typedef struct
{
vlib_pci_addr_t addr;
int enable_elog;
+ u16 rxq_size;
+ u16 txq_size;
/* return */
int rv;
clib_error_t *error;
@@ -259,6 +266,8 @@ typedef struct
avf_rx_vector_entry_t rxve;
} avf_input_trace_t;
+#endif /* AVF_H */
+
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/plugins/avf/avf_all_api_h.h b/src/plugins/avf/avf_all_api_h.h
new file mode 100644
index 00000000000..63cf826c1b5
--- /dev/null
+++ b/src/plugins/avf/avf_all_api_h.h
@@ -0,0 +1,26 @@
+/*
+ *------------------------------------------------------------------
+ * Copyright (c) 2018 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *------------------------------------------------------------------
+ */
+
+#include <avf/avf.api.h>
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/src/plugins/avf/avf_api.c b/src/plugins/avf/avf_api.c
new file mode 100644
index 00000000000..7c5925244ca
--- /dev/null
+++ b/src/plugins/avf/avf_api.c
@@ -0,0 +1,161 @@
+/*
+ *------------------------------------------------------------------
+ * Copyright (c) 2018 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *------------------------------------------------------------------
+ */
+
+#include <vlib/vlib.h>
+#include <vlib/unix/unix.h>
+#include <vlib/pci/pci.h>
+#include <vnet/ethernet/ethernet.h>
+
+#include <avf/avf.h>
+
+#include <vlibapi/api.h>
+#include <vlibmemory/api.h>
+
+/* define message IDs */
+#include <avf/avf_msg_enum.h>
+
+/* define message structures */
+#define vl_typedefs
+#include <avf/avf_all_api_h.h>
+#undef vl_typedefs
+
+/* define generated endian-swappers */
+#define vl_endianfun
+#include <avf/avf_all_api_h.h>
+#undef vl_endianfun
+
+/* instantiate all the print functions we know about */
+#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
+#define vl_printfun
+#include <avf/avf_all_api_h.h>
+#undef vl_printfun
+
+/* get the API version number */
+#define vl_api_version(n,v) static u32 api_version=(v);
+#include <avf/avf_all_api_h.h>
+#undef vl_api_version
+
+#include <vlibapi/api_helper_macros.h>
+
+#define foreach_avf_plugin_api_msg \
+_(AVF_CREATE, avf_create) \
+_(AVF_DELETE, avf_delete)
+
+static void
+vl_api_avf_create_t_handler (vl_api_avf_create_t * mp)
+{
+ vlib_main_t *vm = vlib_get_main ();
+ avf_main_t *am = &avf_main;
+ vl_api_avf_create_reply_t *rmp;
+ avf_create_if_args_t args;
+ int rv = 0;
+
+ memset (&args, 0, sizeof (avf_create_if_args_t));
+
+ args.enable_elog = ntohl (mp->enable_elog);
+ args.addr.as_u32 = ntohl (mp->pci_addr);
+ args.rxq_size = ntohl (mp->rxq_size);
+ args.txq_size = ntohl (mp->txq_size);
+
+ avf_create_if (vm, &args);
+
+ rv = args.rv;
+
+ REPLY_MACRO (VL_API_AVF_CREATE_REPLY + am->msg_id_base);
+}
+
+static void
+vl_api_avf_delete_t_handler (vl_api_avf_delete_t * mp)
+{
+ vlib_main_t *vm = vlib_get_main ();
+ vnet_main_t *vnm = vnet_get_main ();
+ avf_main_t *am = &avf_main;
+ vl_api_avf_delete_reply_t *rmp;
+ avf_device_t *ad;
+ vnet_hw_interface_t *hw;
+ int rv = 0;
+
+ hw = vnet_get_sup_hw_interface (vnm, htonl (mp->sw_if_index));
+ if (hw == NULL || avf_device_class.index != hw->dev_class_index)
+ {
+ rv = VNET_API_ERROR_INVALID_INTERFACE;
+ goto reply;
+ }
+
+ ad = pool_elt_at_index (am->devices, hw->dev_instance);
+
+ avf_delete_if (vm, ad);
+
+reply:
+ REPLY_MACRO (VL_API_AVF_DELETE_REPLY + am->msg_id_base);
+}
+
+#define vl_msg_name_crc_list
+#include <avf/avf_all_api_h.h>
+#undef vl_msg_name_crc_list
+
+static void
+setup_message_id_table (avf_main_t * avm, api_main_t * am)
+{
+#define _(id,n,crc) \
+ vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + avm->msg_id_base);
+ foreach_vl_msg_name_crc_avf;
+#undef _
+}
+
+/* set tup the API message handling tables */
+static clib_error_t *
+avf_plugin_api_hookup (vlib_main_t * vm)
+{
+ avf_main_t *avm = &avf_main;
+ api_main_t *am = &api_main;
+ u8 *name;
+
+ /* construct the API name */
+ name = format (0, "avf_%08x%c", api_version, 0);
+
+ /* ask for a correctly-sized block of API message decode slots */
+ avm->msg_id_base = vl_msg_api_get_msg_ids
+ ((char *) name, VL_MSG_FIRST_AVAILABLE);
+
+#define _(N,n) \
+ vl_msg_api_set_handlers((VL_API_##N + avm->msg_id_base), \
+ #n, \
+ vl_api_##n##_t_handler, \
+ vl_noop_handler, \
+ vl_api_##n##_t_endian, \
+ vl_api_##n##_t_print, \
+ sizeof(vl_api_##n##_t), 1);
+ foreach_avf_plugin_api_msg;
+#undef _
+
+ /* set up the (msg_name, crc, message-id) table */
+ setup_message_id_table (avm, am);
+
+ vec_free (name);
+ return 0;
+}
+
+VLIB_API_INIT_FUNCTION (avf_plugin_api_hookup);
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/src/plugins/avf/avf_msg_enum.h b/src/plugins/avf/avf_msg_enum.h
new file mode 100644
index 00000000000..8b92629fed6
--- /dev/null
+++ b/src/plugins/avf/avf_msg_enum.h
@@ -0,0 +1,39 @@
+/*
+ *------------------------------------------------------------------
+ * Copyright (c) 2018 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *------------------------------------------------------------------
+ */
+
+#ifndef _AVF_MSG_ENUM_H_
+#define _AVF_MSG_ENUM_H_
+
+#include <vppinfra/byte_order.h>
+
+#define vl_msg_id(n,h) n,
+typedef enum
+{
+#include <avf/avf_all_api_h.h>
+ VL_MSG_FIRST_AVAILABLE,
+} vl_msg_id_t;
+#undef vl_msg_id
+
+#endif /* AVF_MSG_ENUM_H */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/src/plugins/avf/avf_test.c b/src/plugins/avf/avf_test.c
new file mode 100644
index 00000000000..c980779eeac
--- /dev/null
+++ b/src/plugins/avf/avf_test.c
@@ -0,0 +1,233 @@
+/*
+ *------------------------------------------------------------------
+ * Copyright (c) 2018 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *------------------------------------------------------------------
+ */
+
+#include <vlib/vlib.h>
+#include <vlib/unix/unix.h>
+#include <vlib/pci/pci.h>
+#include <vnet/ethernet/ethernet.h>
+
+#include <vat/vat.h>
+#include <vlibapi/api.h>
+#include <vlibmemory/api.h>
+
+#include <vppinfra/error.h>
+#include <avf/avf.h>
+
+#define __plugin_msg_base avf_test_main.msg_id_base
+#include <vlibapi/vat_helper_macros.h>
+
+/* declare message IDs */
+#include <avf/avf_msg_enum.h>
+
+/* define message structures */
+#define vl_typedefs
+#include <avf/avf_all_api_h.h>
+#undef vl_typedefs
+
+/* declare message handlers for each api */
+#define vl_endianfun
+#include <avf/avf_all_api_h.h>
+#undef vl_endianfun
+
+/* instantiate all the print functions we know about */
+#define vl_print(handle, ...)
+#define vl_printfun
+#include <avf/avf_all_api_h.h>
+#undef vl_printfun
+
+/* get API version number */
+#define vl_api_version(n,v) static u32 api_version=(v);
+#include <avf/avf_all_api_h.h>
+#undef vp_api_version
+
+typedef struct
+{
+ /* API message ID base */
+ u16 msg_id_base;
+ vat_main_t *vat_main;
+} avf_test_main_t;
+
+avf_test_main_t avf_test_main;
+
+#define foreach_standard_reply_retval_handler \
+_(avf_create_reply) \
+_(avf_delete_reply)
+
+#define _(n) \
+ static void vl_api_##n##_t_handler \
+ (vl_api_##n##_t * mp) \
+ { \
+ vat_main_t * vam = avf_test_main.vat_main; \
+ i32 retval = ntohl(mp->retval); \
+ if (vam->async_mode) { \
+ vam->async_errors += (retval < 0); \
+ } else { \
+ vam->retval = retval; \
+ vam->result_ready = 1; \
+ } \
+ }
+foreach_standard_reply_retval_handler;
+#undef _
+
+#define foreach_vpe_api_reply_msg \
+_(AVF_CREATE_REPLY, avf_create_reply) \
+_(AVF_DELETE_REPLY, avf_delete_reply)
+
+/* avf create API */
+static int
+api_avf_create (vat_main_t * vam)
+{
+ unformat_input_t *i = vam->input;
+ vl_api_avf_create_t *mp;
+ avf_create_if_args_t args;
+ int ret;
+ u32 x[4];
+
+ memset (&args, 0, sizeof (avf_create_if_args_t));
+
+ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (i, "%x:%x:%x.%x", &x[0], &x[1], &x[2], &x[3]))
+ {
+ args.addr.domain = x[0];
+ args.addr.bus = x[1];
+ args.addr.slot = x[2];
+ args.addr.function = x[3];
+ }
+ else if (unformat (i, "elog"))
+ args.enable_elog = 1;
+ else if (unformat (i, "rx-queue-size %u", &args.rxq_size))
+ ;
+ else if (unformat (i, "tx-queue-size %u", &args.txq_size))
+ ;
+ else
+ {
+ clib_warning ("unknown input '%U'", format_unformat_error, i);
+ return -99;
+ }
+ }
+
+ M (AVF_CREATE, mp);
+
+ mp->pci_addr = clib_host_to_net_u32 (args.addr.as_u32);
+ mp->enable_elog = clib_host_to_net_u16 (args.enable_elog);
+ mp->rxq_size = clib_host_to_net_u16 (args.rxq_size);
+ mp->txq_size = clib_host_to_net_u16 (args.txq_size);
+
+ S (mp);
+ W (ret);
+
+ return ret;
+}
+
+/* avf delete API */
+static int
+api_avf_delete (vat_main_t * vam)
+{
+ unformat_input_t *i = vam->input;
+ vl_api_avf_delete_t *mp;
+ u32 sw_if_index = 0;
+ u8 index_defined = 0;
+ int ret;
+
+ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (i, "sw_if_index %u", &sw_if_index))
+ index_defined = 1;
+ else
+ {
+ clib_warning ("unknown input '%U'", format_unformat_error, i);
+ return -99;
+ }
+ }
+
+ if (!index_defined)
+ {
+ errmsg ("missing sw_if_index\n");
+ return -99;
+ }
+
+ M (AVF_DELETE, mp);
+
+ mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
+
+ S (mp);
+ W (ret);
+
+ return ret;
+}
+
+/*
+ * List of messages that the api test plugin sends,
+ * and that the data plane plugin processes
+ */
+#define foreach_vpe_api_msg \
+_(avf_create, "<pci-address> [rx-queue-size <size>] " \
+ "[tx-queue-size <size>]") \
+_(avf_delete, "<sw_if_index>")
+
+static void
+avf_vat_api_hookup (vat_main_t * vam)
+{
+ avf_test_main_t *avm __attribute__ ((unused)) = &avf_test_main;
+#define _(N,n) \
+ vl_msg_api_set_handlers((VL_API_##N + avm->msg_id_base), \
+ #n, \
+ vl_api_##n##_t_handler, \
+ vl_noop_handler, \
+ vl_api_##n##_t_endian, \
+ vl_api_##n##_t_print, \
+ sizeof(vl_api_##n##_t), 1);
+ foreach_vpe_api_reply_msg;
+#undef _
+
+#define _(n,h) \
+ hash_set_mem (vam->function_by_name, #n, api_##n);
+ foreach_vpe_api_msg;
+#undef _
+
+#define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
+ foreach_vpe_api_msg;
+#undef _
+}
+
+clib_error_t *
+vat_plugin_register (vat_main_t * vam)
+{
+ avf_test_main_t *avm = &avf_test_main;
+ u8 *name;
+
+ avm->vat_main = vam;
+
+ name = format (0, "avf_%08x%c", api_version, 0);
+ avm->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name);
+
+ if (avm->msg_id_base != (u16) ~ 0)
+ avf_vat_api_hookup (vam);
+
+ vec_free (name);
+
+ return 0;
+}
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/src/plugins/avf/cli.c b/src/plugins/avf/cli.c
index ba9f5600f99..3ccf45aaf7e 100644
--- a/src/plugins/avf/cli.c
+++ b/src/plugins/avf/cli.c
@@ -32,6 +32,7 @@ avf_create_command_fn (vlib_main_t * vm, unformat_input_t * input,
{
unformat_input_t _line_input, *line_input = &_line_input;
avf_create_if_args_t args;
+ u32 tmp;
memset (&args, 0, sizeof (avf_create_if_args_t));
@@ -45,13 +46,16 @@ avf_create_command_fn (vlib_main_t * vm, unformat_input_t * input,
;
else if (unformat (line_input, "elog"))
args.enable_elog = 1;
+ else if (unformat (line_input, "rx-queue-size %u", &tmp))
+ args.rxq_size = tmp;
+ else if (unformat (line_input, "tx-queue-size %u", &tmp))
+ args.txq_size = tmp;
else
return clib_error_return (0, "unknown input `%U'",
format_unformat_error, input);
}
unformat_free (line_input);
-
avf_create_if (vm, &args);
return args.error;
@@ -60,7 +64,8 @@ avf_create_command_fn (vlib_main_t * vm, unformat_input_t * input,
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (avf_create_command, static) = {
.path = "create interface avf",
- .short_help = "create interface avf <pci-address>",
+ .short_help = "create interface avf <pci-address> "
+ "[rx-queue-size <size>] [tx-queue-size <size>]",
.function = avf_create_command_fn,
};
/* *INDENT-ON* */
diff --git a/src/plugins/avf/device.c b/src/plugins/avf/device.c
index a08a952dd04..0a7de09060e 100644
--- a/src/plugins/avf/device.c
+++ b/src/plugins/avf/device.c
@@ -213,7 +213,7 @@ avf_cmd_rx_ctl_reg_write (vlib_main_t * vm, avf_device_t * ad, u32 reg,
}
clib_error_t *
-avf_rxq_init (vlib_main_t * vm, avf_device_t * ad, u16 qid)
+avf_rxq_init (vlib_main_t * vm, avf_device_t * ad, u16 qid, u16 rxq_size)
{
avf_main_t *am = &avf_main;
avf_rxq_t *rxq;
@@ -222,7 +222,7 @@ avf_rxq_init (vlib_main_t * vm, avf_device_t * ad, u16 qid)
vec_validate_aligned (ad->rxqs, qid, CLIB_CACHE_LINE_BYTES);
rxq = vec_elt_at_index (ad->rxqs, qid);
- rxq->size = AVF_RXQ_SZ;
+ rxq->size = rxq_size;
rxq->next = 0;
rxq->descs = vlib_physmem_alloc_aligned (vm, am->physmem_region, &error,
rxq->size * sizeof (avf_rx_desc_t),
@@ -254,7 +254,7 @@ avf_rxq_init (vlib_main_t * vm, avf_device_t * ad, u16 qid)
}
clib_error_t *
-avf_txq_init (vlib_main_t * vm, avf_device_t * ad, u16 qid)
+avf_txq_init (vlib_main_t * vm, avf_device_t * ad, u16 qid, u16 txq_size)
{
avf_main_t *am = &avf_main;
avf_txq_t *txq;
@@ -272,7 +272,7 @@ avf_txq_init (vlib_main_t * vm, avf_device_t * ad, u16 qid)
vec_validate_aligned (ad->txqs, qid, CLIB_CACHE_LINE_BYTES);
txq = vec_elt_at_index (ad->txqs, qid);
- txq->size = AVF_TXQ_SZ;
+ txq->size = txq_size;
txq->next = 0;
txq->descs = vlib_physmem_alloc_aligned (vm, am->physmem_region, &error,
txq->size * sizeof (avf_tx_desc_t),
@@ -398,8 +398,11 @@ retry:
if (d->v_opcode != op)
{
- err = clib_error_return (0, "unexpected message receiver [v_opcode = %u"
- "expected %u]", d->v_opcode, op);
+ err =
+ clib_error_return (0,
+ "unexpected message receiver [v_opcode = %u, "
+ "expected %u, v_retval %d]", d->v_opcode, op,
+ d->v_retval);
goto done;
}
@@ -658,7 +661,8 @@ retry:
}
clib_error_t *
-avf_device_init (vlib_main_t * vm, avf_device_t * ad)
+avf_device_init (vlib_main_t * vm, avf_device_t * ad,
+ avf_create_if_args_t * args)
{
virtchnl_version_info_t ver = { 0 };
virtchnl_vf_resource_t res = { 0 };
@@ -719,11 +723,11 @@ avf_device_init (vlib_main_t * vm, avf_device_t * ad)
/*
* Init Queues
*/
- if ((error = avf_rxq_init (vm, ad, 0)))
+ if ((error = avf_rxq_init (vm, ad, 0, args->rxq_size)))
return error;
for (i = 0; i < tm->n_vlib_mains; i++)
- if ((error = avf_txq_init (vm, ad, i)))
+ if ((error = avf_txq_init (vm, ad, i, args->txq_size)))
return error;
if ((error = avf_op_config_vsi_queues (vm, ad)))
@@ -1067,6 +1071,19 @@ avf_create_if (vlib_main_t * vm, avf_create_if_args_t * args)
vlib_pci_dev_handle_t h;
clib_error_t *error = 0;
+ /* check input args */
+ args->rxq_size = (args->rxq_size == 0) ? AVF_RXQ_SZ : args->rxq_size;
+ args->txq_size = (args->txq_size == 0) ? AVF_TXQ_SZ : args->txq_size;
+
+ if ((args->rxq_size & (args->rxq_size - 1))
+ || (args->txq_size & (args->txq_size - 1)))
+ {
+ args->rv = VNET_API_ERROR_INVALID_VALUE;
+ args->error =
+ clib_error_return (error, "queue size must be a power of two");
+ return;
+ }
+
pool_get (am->devices, ad);
ad->dev_instance = ad - am->devices;
ad->per_interface_next_index = ~0;
@@ -1141,7 +1158,7 @@ avf_create_if (vlib_main_t * vm, avf_create_if_args_t * args)
/* FIXME detect */
ad->flags |= AVF_DEVICE_F_IOVA;
- if ((error = avf_device_init (vm, ad)))
+ if ((error = avf_device_init (vm, ad, args)))
goto error;
/* create interface */
diff --git a/src/plugins/avf/virtchnl.h b/src/plugins/avf/virtchnl.h
index 3b85b0ebd62..f016110b53e 100644
--- a/src/plugins/avf/virtchnl.h
+++ b/src/plugins/avf/virtchnl.h
@@ -15,6 +15,9 @@
*------------------------------------------------------------------
*/
+#ifndef _AVF_VIRTCHNL_H_
+#define _AVF_VIRTCHNL_H_
+
#define VIRTCHNL_VERSION_MAJOR 1
#define VIRTCHNL_VERSION_MINOR 1
@@ -352,6 +355,8 @@ typedef struct
STATIC_ASSERT_SIZEOF (virtchnl_rss_lut_t, 6);
+#endif /* AVF_VIRTCHNL_H */
+
/*
* fd.io coding-style-patch-verification: ON
*