aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/avf
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/avf')
-rw-r--r--src/plugins/avf/avf.api2
-rw-r--r--src/plugins/avf/avf.h1
-rw-r--r--src/plugins/avf/avf_api.c1
-rw-r--r--src/plugins/avf/avf_test.c14
-rw-r--r--src/plugins/avf/cli.c5
-rw-r--r--src/plugins/avf/device.c76
6 files changed, 80 insertions, 19 deletions
diff --git a/src/plugins/avf/avf.api b/src/plugins/avf/avf.api
index cbded705e49..1cca17fa1af 100644
--- a/src/plugins/avf/avf.api
+++ b/src/plugins/avf/avf.api
@@ -23,6 +23,7 @@ option version = "1.0.0";
@param pci_addr - pci address as unsigned 32bit integer:
0-15 domain, 16-23 bus, 24-28 slot, 29-31 function
ddddddddddddddddbbbbbbbbsssssfff
+ @param rxq_num - number of receive queues
@param rxq_size - receive queue size
@param txq_size - transmit queue size
*/
@@ -34,6 +35,7 @@ define avf_create
u32 pci_addr;
i32 enable_elog;
+ u16 rxq_num;
u16 rxq_size;
u16 txq_size;
};
diff --git a/src/plugins/avf/avf.h b/src/plugins/avf/avf.h
index eeb4fa21759..187e5c2cd69 100644
--- a/src/plugins/avf/avf.h
+++ b/src/plugins/avf/avf.h
@@ -203,6 +203,7 @@ typedef struct
{
vlib_pci_addr_t addr;
int enable_elog;
+ u16 rxq_num;
u16 rxq_size;
u16 txq_size;
/* return */
diff --git a/src/plugins/avf/avf_api.c b/src/plugins/avf/avf_api.c
index 3bb720b27f2..8cb585ded2c 100644
--- a/src/plugins/avf/avf_api.c
+++ b/src/plugins/avf/avf_api.c
@@ -68,6 +68,7 @@ vl_api_avf_create_t_handler (vl_api_avf_create_t * mp)
args.enable_elog = ntohl (mp->enable_elog);
args.addr.as_u32 = ntohl (mp->pci_addr);
+ args.rxq_num = ntohs (mp->rxq_num);
args.rxq_size = ntohs (mp->rxq_size);
args.txq_size = ntohs (mp->txq_size);
diff --git a/src/plugins/avf/avf_test.c b/src/plugins/avf/avf_test.c
index 7bcb1081179..fbb125cee9d 100644
--- a/src/plugins/avf/avf_test.c
+++ b/src/plugins/avf/avf_test.c
@@ -93,6 +93,7 @@ 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;
+ uint32_t tmp;
int ret;
u32 x[4];
@@ -109,10 +110,12 @@ api_avf_create (vat_main_t * vam)
}
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 if (unformat (i, "rx-queue-size %u", &tmp))
+ args.rxq_size = tmp;
+ else if (unformat (i, "tx-queue-size %u", &tmp))
+ args.txq_size = tmp;
+ else if (unformat (i, "num-rx-queues %u", &tmp))
+ args.rxq_num = tmp;
else
{
clib_warning ("unknown input '%U'", format_unformat_error, i);
@@ -124,6 +127,7 @@ api_avf_create (vat_main_t * vam)
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_num = clib_host_to_net_u16 (args.rxq_num);
mp->rxq_size = clib_host_to_net_u16 (args.rxq_size);
mp->txq_size = clib_host_to_net_u16 (args.txq_size);
@@ -194,7 +198,7 @@ api_avf_delete (vat_main_t * vam)
*/
#define foreach_vpe_api_msg \
_(avf_create, "<pci-address> [rx-queue-size <size>] " \
- "[tx-queue-size <size>]") \
+ "[tx-queue-size <size>] [num-rx-queues <size>]") \
_(avf_delete, "<sw_if_index>")
static void
diff --git a/src/plugins/avf/cli.c b/src/plugins/avf/cli.c
index bf4415177be..cd5f02dea3e 100644
--- a/src/plugins/avf/cli.c
+++ b/src/plugins/avf/cli.c
@@ -50,6 +50,8 @@ avf_create_command_fn (vlib_main_t * vm, unformat_input_t * input,
args.rxq_size = tmp;
else if (unformat (line_input, "tx-queue-size %u", &tmp))
args.txq_size = tmp;
+ else if (unformat (line_input, "num-rx-queues %u", &tmp))
+ args.rxq_num = tmp;
else
return clib_error_return (0, "unknown input `%U'",
format_unformat_error, input);
@@ -65,7 +67,8 @@ avf_create_command_fn (vlib_main_t * vm, unformat_input_t * input,
VLIB_CLI_COMMAND (avf_create_command, static) = {
.path = "create interface avf",
.short_help = "create interface avf <pci-address> "
- "[rx-queue-size <size>] [tx-queue-size <size>]",
+ "[rx-queue-size <size>] [tx-queue-size <size>] "
+ "[num-rx-queues <size>]",
.function = avf_create_command_fn,
};
/* *INDENT-ON* */
diff --git a/src/plugins/avf/device.c b/src/plugins/avf/device.c
index ea4d82aaf4b..67cb946379f 100644
--- a/src/plugins/avf/device.c
+++ b/src/plugins/avf/device.c
@@ -497,6 +497,7 @@ clib_error_t *
avf_op_config_rss_lut (vlib_main_t * vm, avf_device_t * ad)
{
int msg_len = sizeof (virtchnl_rss_lut_t) + ad->rss_lut_size - 1;
+ int i;
u8 msg[msg_len];
virtchnl_rss_lut_t *rl;
@@ -504,12 +505,34 @@ avf_op_config_rss_lut (vlib_main_t * vm, avf_device_t * ad)
rl = (virtchnl_rss_lut_t *) msg;
rl->vsi_id = ad->vsi_id;
rl->lut_entries = ad->rss_lut_size;
+ for (i = 0; i < ad->rss_lut_size; i++)
+ rl->lut[i] = i % ad->n_rx_queues;
return avf_send_to_pf (vm, ad, VIRTCHNL_OP_CONFIG_RSS_LUT, msg, msg_len, 0,
0);
}
clib_error_t *
+avf_op_config_rss_key (vlib_main_t * vm, avf_device_t * ad)
+{
+ int msg_len = sizeof (virtchnl_rss_key_t) + ad->rss_key_size - 1;
+ int i;
+ u8 msg[msg_len];
+ virtchnl_rss_key_t *rk;
+
+ memset (msg, 0, msg_len);
+ rk = (virtchnl_rss_key_t *) msg;
+ rk->vsi_id = ad->vsi_id;
+ rk->key_len = ad->rss_key_size;
+ uword seed = random_default_seed ();
+ for (i = 0; i < ad->rss_key_size; i++)
+ rk->key[i] = (u8) random_uword ((u32 *) & seed);
+
+ return avf_send_to_pf (vm, ad, VIRTCHNL_OP_CONFIG_RSS_KEY, msg, msg_len, 0,
+ 0);
+}
+
+clib_error_t *
avf_op_disable_vlan_stripping (vlib_main_t * vm, avf_device_t * ad)
{
return avf_send_to_pf (vm, ad, VIRTCHNL_OP_DISABLE_VLAN_STRIPPING, 0, 0, 0,
@@ -618,11 +641,15 @@ clib_error_t *
avf_op_enable_queues (vlib_main_t * vm, avf_device_t * ad, u32 rx, u32 tx)
{
virtchnl_queue_select_t qs = { 0 };
+ int i;
qs.vsi_id = ad->vsi_id;
qs.rx_queues = rx;
qs.tx_queues = tx;
- avf_rxq_t *rxq = vec_elt_at_index (ad->rxqs, 0);
- avf_reg_write (ad, AVF_QRX_TAIL (0), rxq->n_enqueued);
+ for (i = 0; i < ad->n_rx_queues; i++)
+ {
+ avf_rxq_t *rxq = vec_elt_at_index (ad->rxqs, i);
+ avf_reg_write (ad, AVF_QRX_TAIL (i), rxq->n_enqueued);
+ }
return avf_send_to_pf (vm, ad, VIRTCHNL_OP_ENABLE_QUEUES, &qs,
sizeof (virtchnl_queue_select_t), 0, 0);
}
@@ -705,7 +732,7 @@ done:
}
clib_error_t *
-avf_device_init (vlib_main_t * vm, avf_device_t * ad,
+avf_device_init (vlib_main_t * vm, avf_main_t * am, avf_device_t * ad,
avf_create_if_args_t * args)
{
virtchnl_version_info_t ver = { 0 };
@@ -767,20 +794,37 @@ avf_device_init (vlib_main_t * vm, avf_device_t * ad,
if ((error = avf_config_promisc_mode (vm, ad)))
return error;
- if ((ad->feature_bitmap & VIRTCHNL_VF_OFFLOAD_RSS_PF) &&
- (error = avf_op_config_rss_lut (vm, ad)))
- return error;
-
/*
* Init Queues
*/
- if ((error = avf_rxq_init (vm, ad, 0, args->rxq_size)))
- return error;
+ if (args->rxq_num == 0)
+ {
+ args->rxq_num = 1;
+ }
+ else if (args->rxq_num > ad->num_queue_pairs)
+ {
+ args->rxq_num = ad->num_queue_pairs;
+ vlib_log_warn (am->log_class, "Requested more rx queues than"
+ "queue pairs available. Using %u rx queues.",
+ args->rxq_num);
+ }
+
+ for (i = 0; i < args->rxq_num; i++)
+ if ((error = avf_rxq_init (vm, ad, i, args->rxq_size)))
+ return error;
for (i = 0; i < tm->n_vlib_mains; i++)
if ((error = avf_txq_init (vm, ad, i, args->txq_size)))
return error;
+ if ((ad->feature_bitmap & VIRTCHNL_VF_OFFLOAD_RSS_PF) &&
+ (error = avf_op_config_rss_lut (vm, ad)))
+ return error;
+
+ if ((ad->feature_bitmap & VIRTCHNL_VF_OFFLOAD_RSS_PF) &&
+ (error = avf_op_config_rss_key (vm, ad)))
+ return error;
+
if ((error = avf_op_config_vsi_queues (vm, ad)))
return error;
@@ -788,7 +832,8 @@ avf_device_init (vlib_main_t * vm, avf_device_t * ad,
return error;
avf_irq_0_enable (ad);
- avf_irq_n_enable (ad, 0);
+ for (i = 0; i < ad->n_rx_queues; i++)
+ avf_irq_n_enable (ad, i);
if ((error = avf_op_add_eth_addr (vm, ad, 1, ad->hwaddr)))
return error;
@@ -1041,6 +1086,7 @@ avf_irq_n_handler (vlib_pci_dev_handle_t h, u16 line)
uword pd = vlib_pci_get_private_data (h);
avf_device_t *ad = pool_elt_at_index (am->devices, pd);
u16 qid;
+ int i;
if (ad->flags & AVF_DEVICE_F_ELOG)
{
@@ -1065,7 +1111,8 @@ avf_irq_n_handler (vlib_pci_dev_handle_t h, u16 line)
qid = line - 1;
if (vec_len (ad->rxqs) > qid && ad->rxqs[qid].int_mode != 0)
vnet_device_input_set_interrupt_pending (vnm, ad->hw_if_index, qid);
- avf_irq_n_enable (ad, 0);
+ for (i = 0; i < vec_len (ad->rxqs); i++)
+ avf_irq_n_enable (ad, i);
}
void
@@ -1131,6 +1178,7 @@ avf_create_if (vlib_main_t * vm, avf_create_if_args_t * args)
avf_device_t *ad;
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;
@@ -1219,7 +1267,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, args)))
+ if ((error = avf_device_init (vm, am, ad, args)))
goto error;
/* create interface */
@@ -1237,7 +1285,9 @@ avf_create_if (vlib_main_t * vm, avf_create_if_args_t * args)
hw->flags |= VNET_HW_INTERFACE_FLAG_SUPPORTS_INT_MODE;
vnet_hw_interface_set_input_node (vnm, ad->hw_if_index,
avf_input_node.index);
- vnet_hw_interface_assign_rx_thread (vnm, ad->hw_if_index, 0, ~0);
+
+ for (i = 0; i < ad->n_rx_queues; i++)
+ vnet_hw_interface_assign_rx_thread (vnm, ad->hw_if_index, i, ~0);
if (pool_elts (am->devices) == 1)
vlib_process_signal_event (vm, avf_process_node.index,