X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Favf%2Fdevice.c;h=67cb946379ff5447c305b8ebc10a6a207dd974e6;hb=149d0e28;hp=94b5ca4664811359b51e8561b342a4d991d77322;hpb=dd8e7d0e512425ec05de652a3c71028561e0f40a;p=vpp.git diff --git a/src/plugins/avf/device.c b/src/plugins/avf/device.c index 94b5ca46648..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,11 +505,33 @@ 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) { @@ -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, @@ -1295,6 +1345,31 @@ avf_interface_rx_mode_change (vnet_main_t * vnm, u32 hw_if_index, u32 qid, return 0; } +static void +avf_set_interface_next_node (vnet_main_t * vnm, u32 hw_if_index, + u32 node_index) +{ + avf_main_t *am = &avf_main; + vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index); + avf_device_t *ad = pool_elt_at_index (am->devices, hw->dev_instance); + + /* Shut off redirection */ + if (node_index == ~0) + { + ad->per_interface_next_index = node_index; + return; + } + + ad->per_interface_next_index = + vlib_node_add_next (vlib_get_main (), avf_input_node.index, node_index); +} + +static char *avf_tx_func_error_strings[] = { +#define _(n,s) s, + foreach_avf_tx_func_error +#undef _ +}; + /* *INDENT-OFF* */ VNET_DEVICE_CLASS (avf_device_class,) = { @@ -1303,6 +1378,9 @@ VNET_DEVICE_CLASS (avf_device_class,) = .format_device_name = format_avf_device_name, .admin_up_down_function = avf_interface_admin_up_down, .rx_mode_change_function = avf_interface_rx_mode_change, + .rx_redirect_to_node = avf_set_interface_next_node, + .tx_function_n_errors = AVF_TX_N_ERROR, + .tx_function_error_strings = avf_tx_func_error_strings, }; /* *INDENT-ON* */