summaryrefslogtreecommitdiffstats
path: root/src/plugins/avf
diff options
context:
space:
mode:
authorSteven Luong <sluong@cisco.com>2020-09-28 12:25:22 -0700
committerDamjan Marion <dmarion@me.com>2020-09-29 09:00:26 +0000
commit8b388e35b2aeca39c277453337751d14aeba0d40 (patch)
tree5f745cdd4e63f915726b23b0fd940fbcd30e1a2d /src/plugins/avf
parent4537c30925050ffa34c33e6a481f07f1ec0a01ff (diff)
avf: validate queue size config
Check CLI queue size is within the range of 64 and 4096 Enhance show hardware to display queue size and number of queues. Type: improvement Signed-off-by: Steven Luong <sluong@cisco.com> Change-Id: I360e3cdb2e69e4ea7380ed924e71a5ae84ed4b64
Diffstat (limited to 'src/plugins/avf')
-rw-r--r--src/plugins/avf/avf.h3
-rw-r--r--src/plugins/avf/device.c50
-rw-r--r--src/plugins/avf/format.c12
3 files changed, 52 insertions, 13 deletions
diff --git a/src/plugins/avf/avf.h b/src/plugins/avf/avf.h
index 43741dcad83..32d9cc61015 100644
--- a/src/plugins/avf/avf.h
+++ b/src/plugins/avf/avf.h
@@ -22,6 +22,9 @@
#include <vlib/log.h>
+#define AVF_QUEUE_SZ_MAX 4096
+#define AVF_QUEUE_SZ_MIN 64
+
#define AVF_AQ_ENQ_SUSPEND_TIME 50e-6
#define AVF_AQ_ENQ_MAX_WAIT_TIME 250e-3
diff --git a/src/plugins/avf/device.c b/src/plugins/avf/device.c
index 0481e61b294..d7115044c05 100644
--- a/src/plugins/avf/device.c
+++ b/src/plugins/avf/device.c
@@ -1418,28 +1418,56 @@ avf_delete_if (vlib_main_t * vm, avf_device_t * ad, int with_barrier)
clib_mem_free (ad);
}
-void
-avf_create_if (vlib_main_t * vm, avf_create_if_args_t * args)
+static u8
+avf_validate_queue_size (avf_create_if_args_t * args)
{
- vnet_main_t *vnm = vnet_get_main ();
- avf_main_t *am = &avf_main;
- avf_device_t *ad, **adp;
- vlib_pci_dev_handle_t h;
clib_error_t *error = 0;
- int i;
- /* 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)))
+ if ((args->rxq_size > AVF_QUEUE_SZ_MAX)
+ || (args->txq_size > AVF_QUEUE_SZ_MAX))
+ {
+ args->rv = VNET_API_ERROR_INVALID_VALUE;
+ args->error =
+ clib_error_return (error, "queue size must not be greater than %u",
+ AVF_QUEUE_SZ_MAX);
+ return 1;
+ }
+ if ((args->rxq_size < AVF_QUEUE_SZ_MIN)
+ || (args->txq_size < AVF_QUEUE_SZ_MIN))
+ {
+ args->rv = VNET_API_ERROR_INVALID_VALUE;
+ args->error =
+ clib_error_return (error, "queue size must not be smaller than %u",
+ AVF_QUEUE_SZ_MIN);
+ return 1;
+ }
+ 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;
+ return 1;
}
+ return 0;
+}
+
+void
+avf_create_if (vlib_main_t * vm, avf_create_if_args_t * args)
+{
+ vnet_main_t *vnm = vnet_get_main ();
+ avf_main_t *am = &avf_main;
+ avf_device_t *ad, **adp;
+ vlib_pci_dev_handle_t h;
+ clib_error_t *error = 0;
+ int i;
+
+ /* check input args */
+ if (avf_validate_queue_size (args) != 0)
+ return;
pool_get (am->devices, adp);
adp[0] = ad = clib_mem_alloc_aligned (sizeof (avf_device_t),
diff --git a/src/plugins/avf/format.c b/src/plugins/avf/format.c
index e5da0e2bbf6..2c4eaf79041 100644
--- a/src/plugins/avf/format.c
+++ b/src/plugins/avf/format.c
@@ -90,8 +90,16 @@ format_avf_device (u8 * s, va_list * args)
avf_device_t *ad = avf_get_device (i);
u32 indent = format_get_indent (s);
u8 *a = 0;
-
- s = format (s, "flags: %U", format_avf_device_flags, ad);
+ avf_rxq_t *rxq = vec_elt_at_index (ad->rxqs, 0);
+ avf_txq_t *txq = vec_elt_at_index (ad->txqs, 0);
+
+ s = format (s, "rx: queues %u, desc %u (min %u max %u)", ad->n_rx_queues,
+ rxq->size, AVF_QUEUE_SZ_MIN, AVF_QUEUE_SZ_MAX);
+ s = format (s, "\n%Utx: queues %u, desc %u (min %u max %u)",
+ format_white_space, indent, ad->n_tx_queues, txq->size,
+ AVF_QUEUE_SZ_MIN, AVF_QUEUE_SZ_MAX);
+ s = format (s, "\n%Uflags: %U", format_white_space, indent,
+ format_avf_device_flags, ad);
s = format (s, "\n%Uoffload features: %U", format_white_space, indent,
format_avf_vf_cap_flags, ad->feature_bitmap);