From: Long Wu <long...@corigine.com> This commit supports configuring multiple Rx queues for flower representor port.
Signed-off-by: Long Wu <long...@corigine.com> Reviewed-by: Chaoyong He <chaoyong...@corigine.com> Reviewed-by: Peng Zhang <peng.zh...@corigine.com> --- drivers/net/nfp/flower/nfp_flower.c | 8 ++-- drivers/net/nfp/flower/nfp_flower.h | 2 +- .../net/nfp/flower/nfp_flower_representor.c | 40 +++++++++++++------ .../net/nfp/flower/nfp_flower_representor.h | 2 +- drivers/net/nfp/nfp_rxtx.c | 4 +- 5 files changed, 35 insertions(+), 21 deletions(-) diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c index fa272790bc..8d781658ea 100644 --- a/drivers/net/nfp/flower/nfp_flower.c +++ b/drivers/net/nfp/flower/nfp_flower.c @@ -126,24 +126,24 @@ nfp_flower_get_repr(struct nfp_net_hw_priv *hw_priv, } bool -nfp_flower_pf_dispatch_pkts(struct nfp_net_hw_priv *hw_priv, +nfp_flower_pf_dispatch_pkts(struct nfp_net_rxq *rxq, struct rte_mbuf *mbuf, uint32_t port_id) { struct nfp_flower_representor *repr; - repr = nfp_flower_get_repr(hw_priv, port_id); + repr = nfp_flower_get_repr(rxq->hw_priv, port_id); if (repr == NULL) { PMD_RX_LOG(ERR, "Can not get repr for port %u", port_id); return false; } - if (repr->ring == NULL) { + if (repr->ring == NULL || repr->ring[rxq->qidx] == NULL) { PMD_RX_LOG(ERR, "No ring available for repr_port %s", repr->name); return false; } - if (rte_ring_enqueue(repr->ring, (void *)mbuf) != 0) + if (rte_ring_enqueue(repr->ring[rxq->qidx], (void *)mbuf) != 0) return false; return true; diff --git a/drivers/net/nfp/flower/nfp_flower.h b/drivers/net/nfp/flower/nfp_flower.h index b0d8fb0ed4..1dc868fb68 100644 --- a/drivers/net/nfp/flower/nfp_flower.h +++ b/drivers/net/nfp/flower/nfp_flower.h @@ -110,7 +110,7 @@ nfp_flower_support_decap_v2(const struct nfp_app_fw_flower *app_fw_flower) int nfp_init_app_fw_flower(struct nfp_net_hw_priv *hw_priv); void nfp_uninit_app_fw_flower(struct nfp_net_hw_priv *hw_priv); int nfp_secondary_init_app_fw_flower(struct nfp_net_hw_priv *hw_priv); -bool nfp_flower_pf_dispatch_pkts(struct nfp_net_hw_priv *hw_priv, +bool nfp_flower_pf_dispatch_pkts(struct nfp_net_rxq *rxq, struct rte_mbuf *mbuf, uint32_t port_id); uint16_t nfp_flower_pf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c index 130795357d..96433b9f87 100644 --- a/drivers/net/nfp/flower/nfp_flower_representor.c +++ b/drivers/net/nfp/flower/nfp_flower_representor.c @@ -138,13 +138,14 @@ nfp_flower_repr_dev_stop(struct rte_eth_dev *dev) static int nfp_flower_repr_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id, - __rte_unused uint16_t nb_rx_desc, + uint16_t nb_rx_desc, unsigned int socket_id, __rte_unused const struct rte_eth_rxconf *rx_conf, __rte_unused struct rte_mempool *mb_pool) { struct nfp_net_rxq *rxq; struct nfp_net_hw *pf_hw; + char ring_name[RTE_RING_NAMESIZE]; struct nfp_flower_representor *repr; repr = dev->data->dev_private; @@ -156,6 +157,15 @@ nfp_flower_repr_rx_queue_setup(struct rte_eth_dev *dev, if (rxq == NULL) return -ENOMEM; + snprintf(ring_name, sizeof(ring_name), "%s-%s-%u", repr->name, "Rx", rx_queue_id); + repr->ring[rx_queue_id] = rte_ring_create(ring_name, nb_rx_desc, + rte_socket_id(), 0); + if (repr->ring[rx_queue_id] == NULL) { + PMD_DRV_LOG(ERR, "rte_ring_create failed for rx queue %u", rx_queue_id); + rte_free(rxq); + return -ENOMEM; + } + rxq->hw = pf_hw; rxq->qidx = rx_queue_id; rxq->port_id = dev->data->port_id; @@ -249,18 +259,18 @@ nfp_flower_repr_rx_burst(void *rx_queue, dev = &rte_eth_devices[rxq->port_id]; repr = dev->data->dev_private; - if (unlikely(repr->ring == NULL)) { + if (unlikely(repr->ring == NULL) || + unlikely(repr->ring[rxq->qidx] == NULL)) { PMD_RX_LOG(ERR, "representor %s has no ring configured!", repr->name); return 0; } - total_dequeue = rte_ring_dequeue_burst(repr->ring, (void *)rx_pkts, - nb_pkts, &available); + total_dequeue = rte_ring_dequeue_burst(repr->ring[rxq->qidx], + (void *)rx_pkts, nb_pkts, &available); if (total_dequeue != 0) { - PMD_RX_LOG(DEBUG, "Representor Rx burst for %s, port_id: %#x, " - "received: %u, available: %u", repr->name, - repr->port_id, total_dequeue, available); + PMD_RX_LOG(DEBUG, "Port: %#x, queue: %hu received: %u, available: %u", + repr->port_id, rxq->qidx, total_dequeue, available); data_len = 0; for (i = 0; i < total_dequeue; i++) @@ -328,12 +338,16 @@ static void nfp_flower_repr_free_queue(struct rte_eth_dev *eth_dev) { uint16_t i; + struct nfp_flower_representor *repr; for (i = 0; i < eth_dev->data->nb_tx_queues; i++) rte_free(eth_dev->data->tx_queues[i]); - for (i = 0; i < eth_dev->data->nb_rx_queues; i++) + for (i = 0; i < eth_dev->data->nb_rx_queues; i++) { + repr = eth_dev->data->dev_private; + rte_ring_free(repr->ring[i]); rte_free(eth_dev->data->rx_queues[i]); + } } static void @@ -378,7 +392,7 @@ nfp_flower_repr_uninit(struct rte_eth_dev *eth_dev) repr = eth_dev->data->dev_private; rte_free(repr->repr_xstats_base); - rte_ring_free(repr->ring); + rte_free(repr->ring); if (repr->repr_type == NFP_REPR_TYPE_PHYS_PORT) { index = NFP_FLOWER_CMSG_PORT_PHYS_PORT_NUM(repr->port_id); @@ -627,9 +641,11 @@ nfp_flower_repr_init(struct rte_eth_dev *eth_dev, */ snprintf(ring_name, sizeof(ring_name), "%s_%s", init_repr_data->name, "ring"); numa_node = rte_socket_id(); - repr->ring = rte_ring_create(ring_name, 256, numa_node, RING_F_SC_DEQ); + repr->ring = rte_zmalloc_socket(ring_name, + sizeof(struct rte_ring *) * app_fw_flower->pf_hw->max_rx_queues, + RTE_CACHE_LINE_SIZE, numa_node); if (repr->ring == NULL) { - PMD_DRV_LOG(ERR, "rte_ring_create failed for %s", ring_name); + PMD_DRV_LOG(ERR, "Ring create failed for %s", ring_name); return -ENOMEM; } @@ -704,7 +720,7 @@ nfp_flower_repr_init(struct rte_eth_dev *eth_dev, mac_cleanup: rte_free(eth_dev->data->mac_addrs); ring_cleanup: - rte_ring_free(repr->ring); + rte_free(repr->ring); return ret; } diff --git a/drivers/net/nfp/flower/nfp_flower_representor.h b/drivers/net/nfp/flower/nfp_flower_representor.h index c068c4462c..70ca7b97db 100644 --- a/drivers/net/nfp/flower/nfp_flower_representor.h +++ b/drivers/net/nfp/flower/nfp_flower_representor.h @@ -17,7 +17,7 @@ struct nfp_flower_representor { char name[RTE_ETH_NAME_MAX_LEN]; struct rte_ether_addr mac_addr; struct nfp_app_fw_flower *app_fw_flower; - struct rte_ring *ring; + struct rte_ring **ring; struct rte_eth_link link; struct rte_eth_stats repr_stats; diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c index da41a0e663..05218537f7 100644 --- a/drivers/net/nfp/nfp_rxtx.c +++ b/drivers/net/nfp/nfp_rxtx.c @@ -419,7 +419,6 @@ nfp_net_recv_pkts(void *rx_queue, struct nfp_net_dp_buf *rxb; struct nfp_net_rx_desc *rxds; uint16_t avail_multiplexed = 0; - struct nfp_net_hw_priv *hw_priv; rxq = rx_queue; if (unlikely(rxq == NULL)) { @@ -432,7 +431,6 @@ nfp_net_recv_pkts(void *rx_queue, } hw = rxq->hw; - hw_priv = rxq->hw_priv; while (avail + avail_multiplexed < nb_pkts) { rxb = &rxq->rxbufs[rxq->rd_p]; @@ -523,7 +521,7 @@ nfp_net_recv_pkts(void *rx_queue, if (((meta.flags >> NFP_NET_META_PORTID) & 0x1) == 0) { rx_pkts[avail++] = mb; - } else if (nfp_flower_pf_dispatch_pkts(hw_priv, mb, meta.port_id)) { + } else if (nfp_flower_pf_dispatch_pkts(rxq, mb, meta.port_id)) { avail_multiplexed++; } else { rte_pktmbuf_free(mb); -- 2.39.1