From: "Chen Jing D(Mark)" <jing.d.c...@intel.com> Vector TX use different way to manage TX queue, it's necessary to use different functions to reset TX queue and release mbuf in TX queue. So, introduce 2 function pointers to do such ops.
Signed-off-by: Chen Jing D(Mark) <jing.d.chen at intel.com> --- drivers/net/fm10k/fm10k.h | 9 +++++++++ drivers/net/fm10k/fm10k_ethdev.c | 21 ++++++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h index 0a4c174..2bead12 100644 --- a/drivers/net/fm10k/fm10k.h +++ b/drivers/net/fm10k/fm10k.h @@ -204,11 +204,14 @@ struct fifo { uint16_t *endp; }; +struct fm10k_txq_ops; + struct fm10k_tx_queue { struct rte_mbuf **sw_ring; struct fm10k_tx_desc *hw_ring; uint64_t hw_ring_phys_addr; struct fifo rs_tracker; + const struct fm10k_txq_ops *ops; /* txq ops */ uint16_t last_free; uint16_t next_free; uint16_t nb_free; @@ -225,6 +228,11 @@ struct fm10k_tx_queue { uint16_t queue_id; }; +struct fm10k_txq_ops { + void (*release_mbufs)(struct fm10k_tx_queue *txq); + void (*reset)(struct fm10k_tx_queue *txq); +}; + #define MBUF_DMA_ADDR(mb) \ ((uint64_t) ((mb)->buf_physaddr + (mb)->data_off)) @@ -338,4 +346,5 @@ uint16_t fm10k_recv_scattered_pkts_vec(void *, struct rte_mbuf **, uint16_t); uint16_t fm10k_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts); +void fm10k_txq_vec_setup(struct fm10k_tx_queue *txq); #endif diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c index a46a349..88bd887 100644 --- a/drivers/net/fm10k/fm10k_ethdev.c +++ b/drivers/net/fm10k/fm10k_ethdev.c @@ -292,6 +292,11 @@ tx_queue_disable(struct fm10k_hw *hw, uint16_t qnum) return 0; } +static const struct fm10k_txq_ops def_txq_ops = { + .release_mbufs = tx_queue_free, + .reset = tx_queue_reset, +}; + static int fm10k_dev_configure(struct rte_eth_dev *dev) { @@ -571,7 +576,8 @@ fm10k_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id) PMD_INIT_FUNC_TRACE(); if (tx_queue_id < dev->data->nb_tx_queues) { - tx_queue_reset(dev->data->tx_queues[tx_queue_id]); + struct fm10k_tx_queue *q = dev->data->tx_queues[tx_queue_id]; + q->ops->reset(q); /* reset head and tail pointers */ FM10K_WRITE_REG(hw, FM10K_TDH(tx_queue_id), 0); @@ -837,8 +843,10 @@ fm10k_dev_queue_release(struct rte_eth_dev *dev) PMD_INIT_FUNC_TRACE(); if (dev->data->tx_queues) { - for (i = 0; i < dev->data->nb_tx_queues; i++) - fm10k_tx_queue_release(dev->data->tx_queues[i]); + for (i = 0; i < dev->data->nb_tx_queues; i++) { + struct fm10k_tx_queue *txq = dev->data->tx_queues[i]; + txq->ops->release_mbufs(txq); + } } if (dev->data->rx_queues) { @@ -1454,7 +1462,8 @@ fm10k_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_id, * different socket than was previously used. */ if (dev->data->tx_queues[queue_id] != NULL) { - tx_queue_free(dev->data->tx_queues[queue_id]); + struct fm10k_tx_queue *txq = dev->data->tx_queues[queue_id]; + txq->ops->release_mbufs(txq); dev->data->tx_queues[queue_id] = NULL; } @@ -1470,6 +1479,7 @@ fm10k_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_id, q->nb_desc = nb_desc; q->port_id = dev->data->port_id; q->queue_id = queue_id; + q->ops = &def_txq_ops; q->tail_ptr = (volatile uint32_t *) &((uint32_t *)hw->hw_addr)[FM10K_TDT(queue_id)]; if (handle_txconf(q, conf)) @@ -1528,9 +1538,10 @@ fm10k_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_id, static void fm10k_tx_queue_release(void *queue) { + struct fm10k_tx_queue *q = queue; PMD_INIT_FUNC_TRACE(); - tx_queue_free(queue); + q->ops->release_mbufs(q); } static int -- 1.7.7.6