[2/8] net/nfp: modify the rxq struct

Message ID 20230519025950.1642943-3-chaoyong.he@corigine.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series make the logic conform the coding style of DPDK |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Chaoyong He May 19, 2023, 2:59 a.m. UTC
  Modify the struct nfp_net_rxq, remove the unused fields,
change the type of some fields and make the comment message
more suitable.

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
 drivers/net/nfp/flower/nfp_flower.c           | 13 ++-
 drivers/net/nfp/flower/nfp_flower_ctrl.c      |  6 +-
 .../net/nfp/flower/nfp_flower_representor.c   |  3 -
 drivers/net/nfp/nfp_rxtx.c                    | 26 +++---
 drivers/net/nfp/nfp_rxtx.h                    | 80 +++++++++----------
 5 files changed, 55 insertions(+), 73 deletions(-)
  

Patch

diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index 4d60660a77..8847849adc 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -311,8 +311,8 @@  nfp_flower_pf_recv_pkts(void *rx_queue,
 	 * We need different counters for packets given to the caller
 	 * and packets sent to representors
 	 */
-	int avail = 0;
-	int avail_multiplexed = 0;
+	uint16_t avail = 0;
+	uint16_t avail_multiplexed = 0;
 	uint64_t dma_addr;
 	uint32_t meta_portid;
 	uint16_t nb_hold = 0;
@@ -364,7 +364,7 @@  nfp_flower_pf_recv_pkts(void *rx_queue,
 		new_mb = rte_pktmbuf_alloc(rxq->mem_pool);
 		if (unlikely(new_mb == NULL)) {
 			PMD_RX_LOG(DEBUG,
-			"RX mbuf alloc failed port_id=%u queue_id=%d",
+			"RX mbuf alloc failed port_id=%hu queue_id=%hu",
 				rxq->port_id, rxq->qidx);
 			nfp_net_mbuf_alloc_failed(rxq);
 			break;
@@ -464,7 +464,7 @@  nfp_flower_pf_recv_pkts(void *rx_queue,
 	if (nb_hold == 0)
 		return nb_hold;
 
-	PMD_RX_LOG(DEBUG, "RX port_id=%u queue_id=%d, %d packets received",
+	PMD_RX_LOG(DEBUG, "RX port_id=%hu queue_id=%hu, %hu packets received",
 			rxq->port_id, rxq->qidx, nb_hold);
 
 	nb_hold += rxq->nb_rx_hold;
@@ -475,7 +475,7 @@  nfp_flower_pf_recv_pkts(void *rx_queue,
 	 */
 	rte_wmb();
 	if (nb_hold > rxq->rx_free_thresh) {
-		PMD_RX_LOG(DEBUG, "port=%u queue=%d nb_hold=%u avail=%d",
+		PMD_RX_LOG(DEBUG, "port=%hu queue=%hu nb_hold=%hu avail=%hu",
 				rxq->port_id, rxq->qidx, nb_hold, avail);
 		nfp_qcp_ptr_add(rxq->qcp_fl, NFP_QCP_WRITE_PTR, nb_hold);
 		nb_hold = 0;
@@ -783,9 +783,7 @@  nfp_flower_init_ctrl_vnic(struct nfp_net_hw *hw)
 		/* Hw queues mapping based on firmware configuration */
 		rxq->qidx = i;
 		rxq->fl_qcidx = i * hw->stride_rx;
-		rxq->rx_qcidx = rxq->fl_qcidx + (hw->stride_rx - 1);
 		rxq->qcp_fl = hw->rx_bar + NFP_QCP_QUEUE_OFF(rxq->fl_qcidx);
-		rxq->qcp_rx = hw->rx_bar + NFP_QCP_QUEUE_OFF(rxq->rx_qcidx);
 
 		/*
 		 * Tracking mbuf size for detecting a potential mbuf overflow due to
@@ -798,7 +796,6 @@  nfp_flower_init_ctrl_vnic(struct nfp_net_hw *hw)
 
 		rxq->rx_count = CTRL_VNIC_NB_DESC;
 		rxq->rx_free_thresh = DEFAULT_RX_FREE_THRESH;
-		rxq->drop_en = 1;
 
 		/*
 		 * Allocate RX ring hardware descriptors. A memzone large enough to
diff --git a/drivers/net/nfp/flower/nfp_flower_ctrl.c b/drivers/net/nfp/flower/nfp_flower_ctrl.c
index 1855e73c14..72c0d5e7d9 100644
--- a/drivers/net/nfp/flower/nfp_flower_ctrl.c
+++ b/drivers/net/nfp/flower/nfp_flower_ctrl.c
@@ -68,8 +68,8 @@  nfp_flower_ctrl_vnic_recv(void *rx_queue,
 		new_mb = rte_pktmbuf_alloc(rxq->mem_pool);
 		if (unlikely(new_mb == NULL)) {
 			PMD_RX_LOG(ERR,
-				"RX mbuf alloc failed port_id=%u queue_id=%u",
-				rxq->port_id, (unsigned int)rxq->qidx);
+				"RX mbuf alloc failed port_id=%u queue_id=%hu",
+				rxq->port_id, rxq->qidx);
 			nfp_net_mbuf_alloc_failed(rxq);
 			break;
 		}
@@ -143,7 +143,7 @@  nfp_flower_ctrl_vnic_recv(void *rx_queue,
 	 */
 	rte_wmb();
 	if (nb_hold >= rxq->rx_free_thresh) {
-		PMD_RX_LOG(DEBUG, "port=%hu queue=%d nb_hold=%hu avail=%hu",
+		PMD_RX_LOG(DEBUG, "port=%hu queue=%hu nb_hold=%hu avail=%hu",
 			rxq->port_id, rxq->qidx, nb_hold, avail);
 		nfp_qcp_ptr_add(rxq->qcp_fl, NFP_QCP_WRITE_PTR, nb_hold);
 		nb_hold = 0;
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index 3eb76cb489..94a04e6235 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -46,9 +46,7 @@  nfp_pf_repr_rx_queue_setup(struct rte_eth_dev *dev,
 	/* Hw queues mapping based on firmware configuration */
 	rxq->qidx = queue_idx;
 	rxq->fl_qcidx = queue_idx * hw->stride_rx;
-	rxq->rx_qcidx = rxq->fl_qcidx + (hw->stride_rx - 1);
 	rxq->qcp_fl = hw->rx_bar + NFP_QCP_QUEUE_OFF(rxq->fl_qcidx);
-	rxq->qcp_rx = hw->rx_bar + NFP_QCP_QUEUE_OFF(rxq->rx_qcidx);
 
 	/*
 	 * Tracking mbuf size for detecting a potential mbuf overflow due to
@@ -62,7 +60,6 @@  nfp_pf_repr_rx_queue_setup(struct rte_eth_dev *dev,
 	rxq->rx_count = nb_desc;
 	rxq->port_id = dev->data->port_id;
 	rxq->rx_free_thresh = rx_conf->rx_free_thresh;
-	rxq->drop_en = rx_conf->rx_drop_en;
 
 	/*
 	 * Allocate RX ring hardware descriptors. A memzone large enough to
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index 190498abc7..b34a9b9374 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -40,8 +40,8 @@  nfp_net_rx_fill_freelist(struct nfp_net_rxq *rxq)
 		struct rte_mbuf *mbuf = rte_pktmbuf_alloc(rxq->mem_pool);
 
 		if (mbuf == NULL) {
-			PMD_DRV_LOG(ERR, "RX mbuf alloc failed queue_id=%u",
-				(unsigned int)rxq->qidx);
+			PMD_DRV_LOG(ERR, "RX mbuf alloc failed queue_id=%hu",
+				rxq->qidx);
 			return -ENOMEM;
 		}
 
@@ -379,7 +379,6 @@  nfp_net_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 	uint64_t dma_addr;
 	uint16_t avail;
 
-	avail = 0;
 	rxq = rx_queue;
 	if (unlikely(rxq == NULL)) {
 		/*
@@ -387,12 +386,13 @@  nfp_net_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 		 * enabled. But the queue needs to be configured
 		 */
 		PMD_RX_LOG(ERR, "RX Bad queue");
-		return avail;
+		return 0;
 	}
 
 	hw = rxq->hw;
-	nb_hold = 0;
 
+	avail = 0;
+	nb_hold = 0;
 	while (avail < nb_pkts) {
 		rxb = &rxq->rxbufs[rxq->rd_p];
 		if (unlikely(rxb == NULL)) {
@@ -417,8 +417,8 @@  nfp_net_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 		new_mb = rte_pktmbuf_alloc(rxq->mem_pool);
 		if (unlikely(new_mb == NULL)) {
 			PMD_RX_LOG(DEBUG,
-			"RX mbuf alloc failed port_id=%u queue_id=%u",
-				rxq->port_id, (unsigned int)rxq->qidx);
+			"RX mbuf alloc failed port_id=%u queue_id=%hu",
+					rxq->port_id, rxq->qidx);
 			nfp_net_mbuf_alloc_failed(rxq);
 			break;
 		}
@@ -495,8 +495,8 @@  nfp_net_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 	if (nb_hold == 0)
 		return nb_hold;
 
-	PMD_RX_LOG(DEBUG, "RX  port_id=%u queue_id=%u, %d packets received",
-		   rxq->port_id, (unsigned int)rxq->qidx, nb_hold);
+	PMD_RX_LOG(DEBUG, "RX  port_id=%hu queue_id=%hu, %hu packets received",
+		   rxq->port_id, rxq->qidx, avail);
 
 	nb_hold += rxq->nb_rx_hold;
 
@@ -506,9 +506,8 @@  nfp_net_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 	 */
 	rte_wmb();
 	if (nb_hold > rxq->rx_free_thresh) {
-		PMD_RX_LOG(DEBUG, "port=%u queue=%u nb_hold=%u avail=%u",
-			   rxq->port_id, (unsigned int)rxq->qidx,
-			   (unsigned int)nb_hold, (unsigned int)avail);
+		PMD_RX_LOG(DEBUG, "port=%hu queue=%hu nb_hold=%hu avail=%hu",
+			   rxq->port_id, rxq->qidx, nb_hold, avail);
 		nfp_qcp_ptr_add(rxq->qcp_fl, NFP_QCP_WRITE_PTR, nb_hold);
 		nb_hold = 0;
 	}
@@ -605,9 +604,7 @@  nfp_net_rx_queue_setup(struct rte_eth_dev *dev,
 	/* Hw queues mapping based on firmware configuration */
 	rxq->qidx = queue_idx;
 	rxq->fl_qcidx = queue_idx * hw->stride_rx;
-	rxq->rx_qcidx = rxq->fl_qcidx + (hw->stride_rx - 1);
 	rxq->qcp_fl = hw->rx_bar + NFP_QCP_QUEUE_OFF(rxq->fl_qcidx);
-	rxq->qcp_rx = hw->rx_bar + NFP_QCP_QUEUE_OFF(rxq->rx_qcidx);
 
 	/*
 	 * Tracking mbuf size for detecting a potential mbuf overflow due to
@@ -621,7 +618,6 @@  nfp_net_rx_queue_setup(struct rte_eth_dev *dev,
 	rxq->rx_count = nb_desc;
 	rxq->port_id = dev->data->port_id;
 	rxq->rx_free_thresh = rx_conf->rx_free_thresh;
-	rxq->drop_en = rx_conf->rx_drop_en;
 
 	/*
 	 * Allocate RX ring hardware descriptors. A memzone large enough to
diff --git a/drivers/net/nfp/nfp_rxtx.h b/drivers/net/nfp/nfp_rxtx.h
index 235f083dcf..c433e084c5 100644
--- a/drivers/net/nfp/nfp_rxtx.h
+++ b/drivers/net/nfp/nfp_rxtx.h
@@ -213,81 +213,73 @@  struct nfp_net_rx_desc {
 };
 
 struct nfp_net_rxq {
-	struct nfp_net_hw *hw;	/* Backpointer to nfp_net structure */
+	/** Backpointer to nfp_net structure */
+	struct nfp_net_hw *hw;
 
-	 /*
-	  * @qcp_fl and @qcp_rx are pointers to the base addresses of the
-	  * freelist and RX queue controller peripheral queue structures on the
-	  * NFP
-	  */
+	/**
+	 * Point to the base addresses of the freelist queue
+	 * controller peripheral queue structures on the NFP.
+	 */
 	uint8_t *qcp_fl;
-	uint8_t *qcp_rx;
 
-	/*
-	 * Read and Write pointers.  @wr_p and @rd_p are host side
-	 * pointer, they are free running and have little relation to
-	 * the QCP pointers. @wr_p is where the driver adds new
-	 * freelist descriptors and @rd_p is where the driver start
-	 * reading descriptors for newly arrive packets from.
+	/**
+	 * Host side read pointer, free running and have little relation
+	 * to the QCP pointers. It is where the driver start reading
+	 * descriptors for newly arrive packets from.
 	 */
 	uint32_t rd_p;
 
-	/*
+	/**
+	 * The index of the QCP queue relative to the RX queue BAR
+	 * used for the freelist.
+	 */
+	uint32_t fl_qcidx;
+
+	/**
 	 * For each buffer placed on the freelist, record the
-	 * associated SKB
+	 * associated mbuf.
 	 */
 	struct nfp_net_dp_buf *rxbufs;
 
-	/*
-	 * Information about the host side queue location.  @rxds is
-	 * the virtual address for the queue
+	/**
+	 * Information about the host side queue location.
+	 * It is the virtual address for the queue.
 	 */
 	struct nfp_net_rx_desc *rxds;
 
-	/*
+	/**
 	 * The mempool is created by the user specifying a mbuf size.
 	 * We save here the reference of the mempool needed in the RX
 	 * path and the mbuf size for checking received packets can be
-	 * safely copied to the mbuf using the NFP_NET_RX_OFFSET
+	 * safely copied to the mbuf using the NFP_NET_RX_OFFSET.
 	 */
 	struct rte_mempool *mem_pool;
 	uint16_t mbuf_size;
 
-	/*
+	/**
 	 * Next two fields are used for giving more free descriptors
-	 * to the NFP
+	 * to the NFP.
 	 */
 	uint16_t rx_free_thresh;
 	uint16_t nb_rx_hold;
 
-	 /* the size of the queue in number of descriptors */
+	 /** The size of the queue in number of descriptors */
 	uint16_t rx_count;
 
-	/*
-	 * Fields above this point fit in a single cache line and are all used
-	 * in the RX critical path. Fields below this point are just used
-	 * during queue configuration or not used at all (yet)
-	 */
-
-	/* referencing dev->data->port_id */
+	/** Referencing dev->data->port_id */
 	uint16_t port_id;
 
-	uint8_t  crc_len; /* Not used by now */
-	uint8_t  drop_en; /* Not used by now */
-
-	/* DMA address of the queue */
-	__le64 dma;
+	/** The queue index from Linux's perspective */
+	uint16_t qidx;
 
-	/*
-	 * Queue information: @qidx is the queue index from Linux's
-	 * perspective.  @fl_qcidx is the index of the Queue
-	 * Controller peripheral queue relative to the RX queue BAR
-	 * used for the freelist and @rx_qcidx is the Queue Controller
-	 * Peripheral index for the RX queue.
+	/**
+	 * At this point 60 bytes have been used for all the fields in the
+	 * RX critical path. We have room for 4 bytes and still all placed
+	 * in a cache line.
 	 */
-	int qidx;
-	int fl_qcidx;
-	int rx_qcidx;
+
+	/** DMA address of the queue */
+	uint64_t dma;
 } __rte_aligned(64);
 
 static inline void