X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Favf%2Fdevice.c;h=8f75b8284681e25dd666c38e157d890986e98008;hb=refs%2Fchanges%2F64%2F19964%2F4;hp=f6a00a1d30a6d871888c6e5ad724e1f692890be3;hpb=c879c149d66d556b9b8183374c601004cecbf982;p=vpp.git diff --git a/src/plugins/avf/device.c b/src/plugins/avf/device.c index f6a00a1d30a..8f75b828468 100644 --- a/src/plugins/avf/device.c +++ b/src/plugins/avf/device.c @@ -224,9 +224,14 @@ avf_rxq_init (vlib_main_t * vm, avf_device_t * ad, u16 qid, u16 rxq_size) rxq = vec_elt_at_index (ad->rxqs, qid); rxq->size = rxq_size; rxq->next = 0; - rxq->descs = vlib_physmem_alloc_aligned (vm, rxq->size * - sizeof (avf_rx_desc_t), - 2 * CLIB_CACHE_LINE_BYTES); + rxq->descs = vlib_physmem_alloc_aligned_on_numa (vm, rxq->size * + sizeof (avf_rx_desc_t), + 2 * CLIB_CACHE_LINE_BYTES, + ad->numa_node); + + rxq->buffer_pool_index = + vlib_buffer_pool_get_default_for_numa (vm, ad->numa_node); + if (rxq->descs == 0) return vlib_physmem_last_error (vm); @@ -237,7 +242,8 @@ avf_rxq_init (vlib_main_t * vm, avf_device_t * ad, u16 qid, u16 rxq_size) vec_validate_aligned (rxq->bufs, rxq->size, CLIB_CACHE_LINE_BYTES); rxq->qrx_tail = ad->bar0 + AVF_QRX_TAIL (qid); - n_alloc = vlib_buffer_alloc (vm, rxq->bufs, rxq->size - 8); + n_alloc = vlib_buffer_alloc_from_pool (vm, rxq->bufs, rxq->size - 8, + rxq->buffer_pool_index); if (n_alloc == 0) return clib_error_return (0, "buffer allocation error"); @@ -278,9 +284,10 @@ avf_txq_init (vlib_main_t * vm, avf_device_t * ad, u16 qid, u16 txq_size) txq = vec_elt_at_index (ad->txqs, qid); txq->size = txq_size; txq->next = 0; - txq->descs = vlib_physmem_alloc_aligned (vm, txq->size * - sizeof (avf_tx_desc_t), - 2 * CLIB_CACHE_LINE_BYTES); + txq->descs = vlib_physmem_alloc_aligned_on_numa (vm, txq->size * + sizeof (avf_tx_desc_t), + 2 * CLIB_CACHE_LINE_BYTES, + ad->numa_node); if (txq->descs == 0) return vlib_physmem_last_error (vm); @@ -370,7 +377,7 @@ avf_send_to_pf (vlib_main_t * vm, avf_device_t * ad, virtchnl_ops_t op, int n_retry = 5; - /* supppres interrupt in the next adminq receive slot + /* suppress interrupt in the next adminq receive slot as we are going to wait for response we only need interrupts when event is received */ d = &ad->arq[ad->arq_next_slot]; @@ -554,7 +561,7 @@ avf_config_promisc_mode (vlib_main_t * vm, avf_device_t * ad) virtchnl_promisc_info_t pi = { 0 }; pi.vsi_id = ad->vsi_id; - pi.flags = 1; + pi.flags = FLAG_VF_UNICAST_PROMISC | FLAG_VF_MULTICAST_PROMISC; return avf_send_to_pf (vm, ad, VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE, &pi, sizeof (virtchnl_promisc_info_t), 0, 0); } @@ -587,7 +594,7 @@ avf_op_config_vsi_queues (vlib_main_t * vm, avf_device_t * ad) { avf_rxq_t *q = vec_elt_at_index (ad->rxqs, i); rxq->ring_len = q->size; - rxq->databuffer_size = VLIB_BUFFER_DEFAULT_FREE_LIST_BYTES; + rxq->databuffer_size = vlib_buffer_get_default_data_size (vm); rxq->dma_ring_addr = avf_dma_addr (vm, ad, (void *) q->descs); avf_reg_write (ad, AVF_QRX_TAIL (i), q->size - 1); } @@ -650,14 +657,19 @@ 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; + int i = 0; qs.vsi_id = ad->vsi_id; qs.rx_queues = rx; qs.tx_queues = tx; - for (i = 0; i < ad->n_rx_queues; i++) + while (rx) { - avf_rxq_t *rxq = vec_elt_at_index (ad->rxqs, i); - avf_reg_write (ad, AVF_QRX_TAIL (i), rxq->n_enqueued); + if (rx & (1 << i)) + { + avf_rxq_t *rxq = vec_elt_at_index (ad->rxqs, i); + avf_reg_write (ad, AVF_QRX_TAIL (i), rxq->n_enqueued); + rx &= ~(1 << i); + } + i++; } return avf_send_to_pf (vm, ad, VIRTCHNL_OP_ENABLE_QUEUES, &qs, sizeof (virtchnl_queue_select_t), 0, 0); @@ -715,7 +727,7 @@ avf_request_queues (vlib_main_t * vm, avf_device_t * ad, u16 num_queue_pairs) sizeof (virtchnl_vf_res_request_t)); /* - * if PF respondes, the request failed + * if PF responds, the request failed * else PF initializes restart and avf_send_to_pf returns an error */ if (!error) @@ -776,7 +788,7 @@ avf_device_init (vlib_main_t * vm, avf_main_t * am, avf_device_t * ad, "(remote %d.%d)", ver.major, ver.minor); /* - * OP_GET_VF_RESOUCES + * OP_GET_VF_RESOURCES */ if ((error = avf_op_get_vf_resources (vm, ad, &res))) return error; @@ -847,10 +859,8 @@ avf_device_init (vlib_main_t * vm, avf_main_t * am, avf_device_t * ad, if ((error = avf_op_add_eth_addr (vm, ad, 1, ad->hwaddr))) return error; - if ((error = avf_op_enable_queues (vm, ad, ad->n_rx_queues, 0))) - return error; - - if ((error = avf_op_enable_queues (vm, ad, 0, ad->n_tx_queues))) + if ((error = avf_op_enable_queues (vm, ad, pow2_mask (ad->n_rx_queues), + pow2_mask (ad->n_tx_queues)))) return error; ad->flags |= AVF_DEVICE_F_INITIALIZED; @@ -1223,6 +1233,7 @@ avf_create_if (vlib_main_t * vm, avf_create_if_args_t * args) return; } ad->pci_dev_handle = h; + ad->numa_node = vlib_pci_get_numa_node (vm, h); vlib_pci_set_private_data (vm, h, ad->dev_instance); @@ -1243,8 +1254,11 @@ avf_create_if (vlib_main_t * vm, avf_create_if_args_t * args) if ((error = vlib_pci_enable_msix_irq (vm, h, 0, 2))) goto error; - if (!(ad->atq = vlib_physmem_alloc (vm, sizeof (avf_aq_desc_t) * - AVF_MBOX_LEN))) + ad->atq = vlib_physmem_alloc_aligned_on_numa (vm, sizeof (avf_aq_desc_t) * + AVF_MBOX_LEN, + CLIB_CACHE_LINE_BYTES, + ad->numa_node); + if (ad->atq == 0) { error = vlib_physmem_last_error (vm); goto error; @@ -1253,8 +1267,11 @@ avf_create_if (vlib_main_t * vm, avf_create_if_args_t * args) if ((error = vlib_pci_map_dma (vm, h, ad->atq))) goto error; - if (!(ad->arq = vlib_physmem_alloc (vm, sizeof (avf_aq_desc_t) * - AVF_MBOX_LEN))) + ad->arq = vlib_physmem_alloc_aligned_on_numa (vm, sizeof (avf_aq_desc_t) * + AVF_MBOX_LEN, + CLIB_CACHE_LINE_BYTES, + ad->numa_node); + if (ad->arq == 0) { error = vlib_physmem_last_error (vm); goto error; @@ -1263,8 +1280,11 @@ avf_create_if (vlib_main_t * vm, avf_create_if_args_t * args) if ((error = vlib_pci_map_dma (vm, h, ad->arq))) goto error; - if (!(ad->atq_bufs = vlib_physmem_alloc (vm, AVF_MBOX_BUF_SZ * - AVF_MBOX_LEN))) + ad->atq_bufs = vlib_physmem_alloc_aligned_on_numa (vm, AVF_MBOX_BUF_SZ * + AVF_MBOX_LEN, + CLIB_CACHE_LINE_BYTES, + ad->numa_node); + if (ad->atq_bufs == 0) { error = vlib_physmem_last_error (vm); goto error; @@ -1273,8 +1293,11 @@ avf_create_if (vlib_main_t * vm, avf_create_if_args_t * args) if ((error = vlib_pci_map_dma (vm, h, ad->atq_bufs))) goto error; - if (!(ad->arq_bufs = vlib_physmem_alloc (vm, AVF_MBOX_BUF_SZ * - AVF_MBOX_LEN))) + ad->arq_bufs = vlib_physmem_alloc_aligned_on_numa (vm, AVF_MBOX_BUF_SZ * + AVF_MBOX_LEN, + CLIB_CACHE_LINE_BYTES, + ad->numa_node); + if (ad->arq_bufs == 0) { error = vlib_physmem_last_error (vm); goto error; @@ -1410,12 +1433,8 @@ clib_error_t * avf_init (vlib_main_t * vm) { avf_main_t *am = &avf_main; - clib_error_t *error; vlib_thread_main_t *tm = vlib_get_thread_main (); - if ((error = vlib_call_init_function (vm, pci_bus_init))) - return error; - vec_validate_aligned (am->per_thread_data, tm->n_vlib_mains - 1, CLIB_CACHE_LINE_BYTES); @@ -1425,7 +1444,12 @@ avf_init (vlib_main_t * vm) return 0; } -VLIB_INIT_FUNCTION (avf_init); +/* *INDENT-OFF* */ +VLIB_INIT_FUNCTION (avf_init) = +{ + .runs_after = VLIB_INITS ("pci_bus_init"), +}; +/* *INDENT-OFF* */ /* * fd.io coding-style-patch-verification: ON