*/
#include <vlib/vlib.h>
+#include <vppinfra/ring.h>
#include <vlib/unix/unix.h>
#include <vlib/pci/pci.h>
#include <vnet/ethernet/ethernet.h>
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);
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");
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);
vec_validate_aligned (txq->bufs, txq->size, CLIB_CACHE_LINE_BYTES);
txq->qtx_tail = ad->bar0 + AVF_QTX_TAIL (qid);
+ /* initialize ring of pending RS slots */
+ clib_ring_new_aligned (txq->rs_slots, 32, CLIB_CACHE_LINE_BYTES);
+
ad->n_tx_queues = clib_min (ad->num_queue_pairs, qid + 1);
return 0;
}
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];
rxq->vsi_id = ad->vsi_id;
rxq->queue_id = i;
- rxq->max_pkt_size = 1518;
+ rxq->max_pkt_size = ETHERNET_MAX_PACKET_BYTES;
if (i < vec_len (ad->rxqs))
{
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);
}
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);
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)
"(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;
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;
txq->n_enqueued);
}
vec_free (txq->bufs);
+ clib_ring_free (txq->rs_slots);
}
/* *INDENT-ON* */
vec_free (ad->txqs);
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);
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;
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;
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;
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;