* [PATCH 1/8] net/nfp: reuse the ring buffer struct
2023-05-19 2:59 [PATCH 0/8] make the logic conform the coding style of DPDK Chaoyong He
@ 2023-05-19 2:59 ` Chaoyong He
2023-05-19 2:59 ` [PATCH 2/8] net/nfp: modify the rxq struct Chaoyong He
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Chaoyong He @ 2023-05-19 2:59 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, niklas.soderlund, Chaoyong He
Reuse the ring buffer struct, make the code more readable.
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 | 2 +-
drivers/net/nfp/flower/nfp_flower_ctrl.c | 2 +-
drivers/net/nfp/nfp_rxtx.c | 4 ++--
drivers/net/nfp/nfp_rxtx.h | 14 ++++++--------
4 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index 159f88f5ae..4d60660a77 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -320,7 +320,7 @@ nfp_flower_pf_recv_pkts(void *rx_queue,
struct nfp_net_hw *hw;
struct rte_mbuf *new_mb;
struct nfp_net_rxq *rxq;
- struct nfp_net_rx_buff *rxb;
+ struct nfp_net_dp_buf *rxb;
struct nfp_net_rx_desc *rxds;
struct nfp_flower_representor *repr;
diff --git a/drivers/net/nfp/flower/nfp_flower_ctrl.c b/drivers/net/nfp/flower/nfp_flower_ctrl.c
index 937829c23c..1855e73c14 100644
--- a/drivers/net/nfp/flower/nfp_flower_ctrl.c
+++ b/drivers/net/nfp/flower/nfp_flower_ctrl.c
@@ -30,7 +30,7 @@ nfp_flower_ctrl_vnic_recv(void *rx_queue,
struct nfp_net_hw *hw;
struct nfp_net_rxq *rxq;
struct rte_mbuf *new_mb;
- struct nfp_net_rx_buff *rxb;
+ struct nfp_net_dp_buf *rxb;
struct nfp_net_rx_desc *rxds;
rxq = rx_queue;
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index 9eaa0b89c1..190498abc7 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -28,7 +28,7 @@
static int
nfp_net_rx_fill_freelist(struct nfp_net_rxq *rxq)
{
- struct nfp_net_rx_buff *rxe = rxq->rxbufs;
+ struct nfp_net_dp_buf *rxe = rxq->rxbufs;
uint64_t dma_addr;
unsigned int i;
@@ -371,7 +371,7 @@ nfp_net_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
{
struct nfp_net_rxq *rxq;
struct nfp_net_rx_desc *rxds;
- struct nfp_net_rx_buff *rxb;
+ struct nfp_net_dp_buf *rxb;
struct nfp_net_hw *hw;
struct rte_mbuf *mb;
struct rte_mbuf *new_mb;
diff --git a/drivers/net/nfp/nfp_rxtx.h b/drivers/net/nfp/nfp_rxtx.h
index 4d0c88529b..235f083dcf 100644
--- a/drivers/net/nfp/nfp_rxtx.h
+++ b/drivers/net/nfp/nfp_rxtx.h
@@ -98,6 +98,10 @@ struct nfp_meta_parsed {
#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
+struct nfp_net_dp_buf {
+ struct rte_mbuf *mbuf;
+};
+
struct nfp_net_txq {
struct nfp_net_hw *hw; /* Backpointer to nfp_net structure */
@@ -128,9 +132,7 @@ struct nfp_net_txq {
* For each descriptor keep a reference to the mbuf and
* DMA address used until completion is signalled.
*/
- struct {
- struct rte_mbuf *mbuf;
- } *txbufs;
+ struct nfp_net_dp_buf *txbufs;
/*
* Information about the host side queue location. @txds is
@@ -210,10 +212,6 @@ struct nfp_net_rx_desc {
};
};
-struct nfp_net_rx_buff {
- struct rte_mbuf *mbuf;
-};
-
struct nfp_net_rxq {
struct nfp_net_hw *hw; /* Backpointer to nfp_net structure */
@@ -238,7 +236,7 @@ struct nfp_net_rxq {
* For each buffer placed on the freelist, record the
* associated SKB
*/
- struct nfp_net_rx_buff *rxbufs;
+ struct nfp_net_dp_buf *rxbufs;
/*
* Information about the host side queue location. @rxds is
--
2.39.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/8] net/nfp: modify the rxq struct
2023-05-19 2:59 [PATCH 0/8] make the logic conform the coding style of DPDK Chaoyong He
2023-05-19 2:59 ` [PATCH 1/8] net/nfp: reuse the ring buffer struct Chaoyong He
@ 2023-05-19 2:59 ` Chaoyong He
2023-05-19 2:59 ` [PATCH 3/8] net/nfp: modify the Rx descriptor struct Chaoyong He
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Chaoyong He @ 2023-05-19 2:59 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, niklas.soderlund, Chaoyong He
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(-)
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
--
2.39.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 3/8] net/nfp: modify the Rx descriptor struct
2023-05-19 2:59 [PATCH 0/8] make the logic conform the coding style of DPDK Chaoyong He
2023-05-19 2:59 ` [PATCH 1/8] net/nfp: reuse the ring buffer struct Chaoyong He
2023-05-19 2:59 ` [PATCH 2/8] net/nfp: modify the rxq struct Chaoyong He
@ 2023-05-19 2:59 ` Chaoyong He
2023-05-19 2:59 ` [PATCH 4/8] net/nfp: modify the txq struct Chaoyong He
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Chaoyong He @ 2023-05-19 2:59 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, niklas.soderlund, Chaoyong He
Modify the struct nfp_net_rx_desc, change the type of the
fields, make it meet the DPDK coding style.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
drivers/net/nfp/nfp_rxtx.h | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/net/nfp/nfp_rxtx.h b/drivers/net/nfp/nfp_rxtx.h
index c433e084c5..83dc9960e8 100644
--- a/drivers/net/nfp/nfp_rxtx.h
+++ b/drivers/net/nfp/nfp_rxtx.h
@@ -191,24 +191,24 @@ struct nfp_net_rx_desc {
union {
/* Freelist descriptor */
struct {
- __le16 dma_addr_hi;
+ uint16_t dma_addr_hi;
uint8_t spare;
uint8_t dd;
- __le32 dma_addr_lo;
+ uint32_t dma_addr_lo;
} __rte_packed fld;
/* RX descriptor */
struct {
- __le16 data_len;
+ uint16_t data_len;
uint8_t reserved;
uint8_t meta_len_dd;
- __le16 flags;
- __le16 vlan;
+ uint16_t flags;
+ uint16_t vlan;
} __rte_packed rxd;
- __le32 vals[2];
+ uint32_t vals[2];
};
};
--
2.39.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 4/8] net/nfp: modify the txq struct
2023-05-19 2:59 [PATCH 0/8] make the logic conform the coding style of DPDK Chaoyong He
` (2 preceding siblings ...)
2023-05-19 2:59 ` [PATCH 3/8] net/nfp: modify the Rx descriptor struct Chaoyong He
@ 2023-05-19 2:59 ` Chaoyong He
2023-05-19 2:59 ` [PATCH 5/8] net/nfp: remove the custom round macro Chaoyong He
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Chaoyong He @ 2023-05-19 2:59 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, niklas.soderlund, Chaoyong He
Modify the struct nfp_net_txq, 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 | 7 +--
.../net/nfp/flower/nfp_flower_representor.c | 3 -
drivers/net/nfp/nfd3/nfp_nfd3_dp.c | 7 +--
drivers/net/nfp/nfdk/nfp_nfdk_dp.c | 7 +--
drivers/net/nfp/nfp_rxtx.c | 4 +-
drivers/net/nfp/nfp_rxtx.h | 63 ++++++++-----------
6 files changed, 35 insertions(+), 56 deletions(-)
diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index 8847849adc..9a08ae3b75 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -508,7 +508,7 @@ nfp_flower_pf_xmit_pkts(void *tx_queue,
hw = txq->hw;
txds = &txq->txds[txq->wr_p];
- PMD_TX_LOG(DEBUG, "working for queue %d at pos %u and %u packets",
+ PMD_TX_LOG(DEBUG, "working for queue %hu at pos %u and %hu packets",
txq->qidx, txq->wr_p, nb_pkts);
if ((nfp_net_nfd3_free_tx_desc(txq) < nb_pkts) || (nfp_net_nfd3_txq_full(txq)))
@@ -685,7 +685,7 @@ nfp_flower_init_vnic_common(struct nfp_net_hw *hw, const char *vnic_type)
static int
nfp_flower_init_ctrl_vnic(struct nfp_net_hw *hw)
{
- uint32_t i;
+ uint16_t i;
int ret = 0;
uint16_t n_txq;
uint16_t n_rxq;
@@ -869,9 +869,6 @@ nfp_flower_init_ctrl_vnic(struct nfp_net_hw *hw)
txq->tx_count = CTRL_VNIC_NB_DESC;
txq->tx_free_thresh = DEFAULT_RX_FREE_THRESH;
- txq->tx_pthresh = DEFAULT_TX_PTHRESH;
- txq->tx_hthresh = DEFAULT_TX_HTHRESH;
- txq->tx_wthresh = DEFAULT_TX_WTHRESH;
/* Queue mapping based on firmware configuration */
txq->qidx = i;
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index 94a04e6235..0479eb4792 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -151,9 +151,6 @@ nfp_pf_repr_tx_queue_setup(struct rte_eth_dev *dev,
txq->tx_count = nb_desc;
txq->tx_free_thresh = tx_free_thresh;
- txq->tx_pthresh = tx_conf->tx_thresh.pthresh;
- txq->tx_hthresh = tx_conf->tx_thresh.hthresh;
- txq->tx_wthresh = tx_conf->tx_thresh.wthresh;
/* queue mapping based on firmware configuration */
txq->qidx = queue_idx;
diff --git a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
index 909156d69c..1a960fbe63 100644
--- a/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
+++ b/drivers/net/nfp/nfd3/nfp_nfd3_dp.c
@@ -112,7 +112,7 @@ nfp_net_nfd3_xmit_pkts(void *tx_queue,
hw = txq->hw;
txds = &txq->txds[txq->wr_p];
- PMD_TX_LOG(DEBUG, "working for queue %u at pos %d and %u packets",
+ PMD_TX_LOG(DEBUG, "working for queue %hu at pos %d and %hu packets",
txq->qidx, txq->wr_p, nb_pkts);
if (nfp_net_nfd3_free_tx_desc(txq) < NFD3_TX_DESC_PER_PKT * nb_pkts ||
@@ -126,7 +126,7 @@ nfp_net_nfd3_xmit_pkts(void *tx_queue,
pkt = *tx_pkts;
issued_descs = 0;
- PMD_TX_LOG(DEBUG, "queue: %u. Sending %u packets", txq->qidx, nb_pkts);
+ PMD_TX_LOG(DEBUG, "queue: %hu. Sending %hu packets", txq->qidx, nb_pkts);
/* Sending packets */
for (i = 0; i < nb_pkts && free_descs > 0; i++) {
@@ -304,9 +304,6 @@ nfp_net_nfd3_tx_queue_setup(struct rte_eth_dev *dev,
txq->tx_count = nb_desc * NFD3_TX_DESC_PER_PKT;
txq->tx_free_thresh = tx_free_thresh;
- txq->tx_pthresh = tx_conf->tx_thresh.pthresh;
- txq->tx_hthresh = tx_conf->tx_thresh.hthresh;
- txq->tx_wthresh = tx_conf->tx_thresh.wthresh;
/* queue mapping based on firmware configuration */
txq->qidx = queue_idx;
diff --git a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
index 12233393fc..b35aa9a610 100644
--- a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
+++ b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
@@ -164,7 +164,7 @@ nfp_net_nfdk_xmit_pkts(void *tx_queue,
txq = tx_queue;
hw = txq->hw;
- PMD_TX_LOG(DEBUG, "working for queue %u at pos %d and %u packets",
+ PMD_TX_LOG(DEBUG, "working for queue %hu at pos %d and %hu packets",
txq->qidx, txq->wr_p, nb_pkts);
if (nfp_net_nfdk_free_tx_desc(txq) < NFDK_TX_DESC_PER_SIMPLE_PKT * nb_pkts ||
@@ -175,7 +175,7 @@ nfp_net_nfdk_xmit_pkts(void *tx_queue,
if (unlikely(free_descs == 0))
return 0;
- PMD_TX_LOG(DEBUG, "queue: %u. Sending %u packets", txq->qidx, nb_pkts);
+ PMD_TX_LOG(DEBUG, "queue: %hu. Sending %hu packets", txq->qidx, nb_pkts);
/* Sending packets */
while (npkts < nb_pkts && free_descs > 0) {
@@ -398,9 +398,6 @@ nfp_net_nfdk_tx_queue_setup(struct rte_eth_dev *dev,
txq->tx_count = nb_desc * NFDK_TX_DESC_PER_SIMPLE_PKT;
txq->tx_free_thresh = tx_free_thresh;
- txq->tx_pthresh = tx_conf->tx_thresh.pthresh;
- txq->tx_hthresh = tx_conf->tx_thresh.hthresh;
- txq->tx_wthresh = tx_conf->tx_thresh.wthresh;
/* queue mapping based on firmware configuration */
txq->qidx = queue_idx;
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index b34a9b9374..8283953702 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -679,14 +679,14 @@ nfp_net_tx_free_bufs(struct nfp_net_txq *txq)
uint32_t qcp_rd_p;
int todo;
- PMD_TX_LOG(DEBUG, "queue %u. Check for descriptor with a complete"
+ PMD_TX_LOG(DEBUG, "queue %hu. Check for descriptor with a complete"
" status", txq->qidx);
/* Work out how many packets have been sent */
qcp_rd_p = nfp_qcp_read(txq->qcp_q, NFP_QCP_READ_PTR);
if (qcp_rd_p == txq->rd_p) {
- PMD_TX_LOG(DEBUG, "queue %u: It seems harrier is not sending "
+ PMD_TX_LOG(DEBUG, "queue %hu: It seems harrier is not sending "
"packets (%u, %u)", txq->qidx,
qcp_rd_p, txq->rd_p);
return 0;
diff --git a/drivers/net/nfp/nfp_rxtx.h b/drivers/net/nfp/nfp_rxtx.h
index 83dc9960e8..4a310c0083 100644
--- a/drivers/net/nfp/nfp_rxtx.h
+++ b/drivers/net/nfp/nfp_rxtx.h
@@ -14,7 +14,6 @@
#ifndef _NFP_RXTX_H_
#define _NFP_RXTX_H_
-#include <linux/types.h>
#include <rte_io.h>
#define NFP_DESC_META_LEN(d) ((d)->rxd.meta_len_dd & PCIE_DESC_RX_META_LEN_MASK)
@@ -103,63 +102,55 @@ struct nfp_net_dp_buf {
};
struct nfp_net_txq {
- struct nfp_net_hw *hw; /* Backpointer to nfp_net structure */
-
- /*
- * Queue information: @qidx is the queue index from Linux's
- * perspective. @tx_qcidx is the index of the Queue
- * Controller Peripheral queue relative to the TX queue BAR.
- * @cnt is the size of the queue in number of
- * descriptors. @qcp_q is a pointer to the base of the queue
- * structure on the NFP
- */
+ /** Backpointer to nfp_net structure */
+ struct nfp_net_hw *hw;
+
+ /** Point to the base of the queue structure on the NFP. */
uint8_t *qcp_q;
- /*
- * 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 *
- * @qcp_rd_p is a local copy queue controller peripheral read pointer
+ /**
+ * Host side read and write pointer, they are free running and
+ * have little relation to the QCP pointers.
*/
-
uint32_t wr_p;
uint32_t rd_p;
+ /** The size of the queue in number of descriptors. */
uint32_t tx_count;
uint32_t tx_free_thresh;
- /*
+ /**
* For each descriptor keep a reference to the mbuf and
* DMA address used until completion is signalled.
*/
struct nfp_net_dp_buf *txbufs;
- /*
- * Information about the host side queue location. @txds is
- * the virtual address for the queue, @dma is the DMA address
- * of the queue and @size is the size in bytes for the queue
- * (needed for free)
+ /**
+ * Information about the host side queue location.
+ * It is the virtual address for the queue.
*/
union {
struct nfp_net_nfd3_tx_desc *txds;
struct nfp_net_nfdk_tx_desc *ktxds;
};
- /*
- * At this point 48 bytes have been used for all the fields in the
- * TX critical path. We have room for 8 bytes and still all placed
- * in a cache line. We are not using the threshold values below but
- * if we need to, we can add the most used in the remaining bytes.
- */
- uint32_t tx_rs_thresh; /* not used by now. Future? */
- uint32_t tx_pthresh; /* not used by now. Future? */
- uint32_t tx_hthresh; /* not used by now. Future? */
- uint32_t tx_wthresh; /* not used by now. Future? */
+ /** The index of the QCP queue relative to the TX queue BAR. */
+ uint32_t tx_qcidx;
+
+ /** The queue index from Linux's perspective. */
+ uint16_t qidx;
uint16_t port_id;
- uint16_t data_pending; /* used by nfdk only */
- int qidx;
- int tx_qcidx;
- __le64 dma;
+
+ /** Used by NFDk only */
+ uint16_t data_pending;
+
+ /**
+ * At this point 58 bytes have been used for all the fields in the
+ * TX critical path. We have room for 6 bytes and still all placed
+ * in a cache line.
+ */
+ uint64_t dma;
} __rte_aligned(64);
/* RX and freelist descriptor format */
--
2.39.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 5/8] net/nfp: remove the custom round macro
2023-05-19 2:59 [PATCH 0/8] make the logic conform the coding style of DPDK Chaoyong He
` (3 preceding siblings ...)
2023-05-19 2:59 ` [PATCH 4/8] net/nfp: modify the txq struct Chaoyong He
@ 2023-05-19 2:59 ` Chaoyong He
2023-05-19 2:59 ` [PATCH 6/8] net/nfp: remove the unneeded comment Chaoyong He
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Chaoyong He @ 2023-05-19 2:59 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, niklas.soderlund, Chaoyong He
Remove the custom round macro, use the macro provide by
the DPDK.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
drivers/net/nfp/nfdk/nfp_nfdk_dp.c | 9 +++++----
drivers/net/nfp/nfpcore/nfp_rtsym.c | 4 ++--
drivers/net/nfp/nfpcore/nfp_rtsym.h | 19 -------------------
3 files changed, 7 insertions(+), 25 deletions(-)
diff --git a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
index b35aa9a610..9b815800bb 100644
--- a/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
+++ b/drivers/net/nfp/nfdk/nfp_nfdk_dp.c
@@ -70,8 +70,8 @@ nfp_net_nfdk_tx_maybe_close_block(struct nfp_net_txq *txq,
n_descs++;
/* Don't count metadata descriptor, for the round down to work out */
- if (round_down(txq->wr_p, NFDK_TX_DESC_BLOCK_CNT) !=
- round_down(txq->wr_p + n_descs, NFDK_TX_DESC_BLOCK_CNT))
+ if (RTE_ALIGN_FLOOR(txq->wr_p, NFDK_TX_DESC_BLOCK_CNT) !=
+ RTE_ALIGN_FLOOR(txq->wr_p + n_descs, NFDK_TX_DESC_BLOCK_CNT))
goto close_block;
if (txq->data_pending + pkt->pkt_len > NFDK_TX_MAX_DATA_PER_BLOCK)
@@ -293,8 +293,9 @@ nfp_net_nfdk_xmit_pkts(void *tx_queue,
}
used_descs = ktxds - txq->ktxds - txq->wr_p;
- if (round_down(txq->wr_p, NFDK_TX_DESC_BLOCK_CNT) !=
- round_down(txq->wr_p + used_descs - 1, NFDK_TX_DESC_BLOCK_CNT)) {
+ if (RTE_ALIGN_FLOOR(txq->wr_p, NFDK_TX_DESC_BLOCK_CNT) !=
+ RTE_ALIGN_FLOOR(txq->wr_p + used_descs - 1,
+ NFDK_TX_DESC_BLOCK_CNT)) {
PMD_TX_LOG(INFO, "Used descs cross block boundary");
goto xmit_end;
}
diff --git a/drivers/net/nfp/nfpcore/nfp_rtsym.c b/drivers/net/nfp/nfpcore/nfp_rtsym.c
index 850667adf8..9713605580 100644
--- a/drivers/net/nfp/nfpcore/nfp_rtsym.c
+++ b/drivers/net/nfp/nfpcore/nfp_rtsym.c
@@ -113,8 +113,8 @@ __nfp_rtsym_table_read(struct nfp_cpp *cpp, const struct nfp_mip *mip)
return NULL;
/* Align to 64 bits */
- symtab_size = round_up(symtab_size, 8);
- strtab_size = round_up(strtab_size, 8);
+ symtab_size = RTE_ALIGN_CEIL(symtab_size, 8);
+ strtab_size = RTE_ALIGN_CEIL(strtab_size, 8);
rtsymtab = malloc(symtab_size);
if (rtsymtab == NULL)
diff --git a/drivers/net/nfp/nfpcore/nfp_rtsym.h b/drivers/net/nfp/nfpcore/nfp_rtsym.h
index d2856e19c3..8b494211bc 100644
--- a/drivers/net/nfp/nfpcore/nfp_rtsym.h
+++ b/drivers/net/nfp/nfpcore/nfp_rtsym.h
@@ -15,25 +15,6 @@
#define NFP_RTSYM_TARGET_LMEM -1
#define NFP_RTSYM_TARGET_EMU_CACHE -7
-/*
- * This looks more complex than it should be. But we need to get the type for
- * the ~ right in round_down (it needs to be as wide as the result!), and we
- * want to evaluate the macro arguments just once each.
- */
-#define __round_mask(x, y) ((__typeof__(x))((y) - 1))
-
-#define round_up(x, y) \
- (__extension__ ({ \
- typeof(x) _x = (x); \
- ((((_x) - 1) | __round_mask(_x, y)) + 1); \
- }))
-
-#define round_down(x, y) \
- (__extension__ ({ \
- typeof(x) _x = (x); \
- ((_x) & ~__round_mask(_x, y)); \
- }))
-
/*
* Structure describing a run-time NFP symbol.
*
--
2.39.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 6/8] net/nfp: remove the unneeded comment
2023-05-19 2:59 [PATCH 0/8] make the logic conform the coding style of DPDK Chaoyong He
` (4 preceding siblings ...)
2023-05-19 2:59 ` [PATCH 5/8] net/nfp: remove the custom round macro Chaoyong He
@ 2023-05-19 2:59 ` Chaoyong He
2023-05-19 2:59 ` [PATCH 7/8] net/nfp: revise cast from void pointer Chaoyong He
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Chaoyong He @ 2023-05-19 2:59 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, niklas.soderlund, Chaoyong He
Remove the unneeded comment at the head and tail of
some source files.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
drivers/net/nfp/nfp_common.c | 15 ---------------
drivers/net/nfp/nfp_common.h | 14 --------------
drivers/net/nfp/nfp_cpp_bridge.c | 14 --------------
drivers/net/nfp/nfp_cpp_bridge.h | 14 --------------
drivers/net/nfp/nfp_ctrl.h | 11 -----------
drivers/net/nfp/nfp_ethdev.c | 14 --------------
drivers/net/nfp/nfp_ethdev_vf.c | 14 --------------
drivers/net/nfp/nfp_rxtx.c | 8 --------
drivers/net/nfp/nfp_rxtx.h | 14 --------------
9 files changed, 118 deletions(-)
diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c
index de05fe8e95..634afbf1b5 100644
--- a/drivers/net/nfp/nfp_common.c
+++ b/drivers/net/nfp/nfp_common.c
@@ -5,14 +5,6 @@
* Small portions derived from code Copyright(c) 2010-2015 Intel Corporation.
*/
-/*
- * vim:shiftwidth=8:noexpandtab
- *
- * @file dpdk/pmd/nfp_common.c
- *
- * Netronome vNIC DPDK Poll-Mode Driver: Common files
- */
-
#include <rte_byteorder.h>
#include <rte_common.h>
#include <rte_log.h>
@@ -1963,10 +1955,3 @@ nfp_net_init_metadata_format(struct nfp_net_hw *hw)
hw->meta_format = NFP_NET_METAFORMAT_SINGLE;
}
}
-
-/*
- * Local variables:
- * c-file-style: "Linux"
- * indent-tabs-mode: t
- * End:
- */
diff --git a/drivers/net/nfp/nfp_common.h b/drivers/net/nfp/nfp_common.h
index 76f4eef980..914903f587 100644
--- a/drivers/net/nfp/nfp_common.h
+++ b/drivers/net/nfp/nfp_common.h
@@ -3,14 +3,6 @@
* All rights reserved.
*/
-/*
- * vim:shiftwidth=8:noexpandtab
- *
- * @file dpdk/pmd/nfp_net_pmd.h
- *
- * Netronome NFP_NET PMD
- */
-
#ifndef _NFP_COMMON_H_
#define _NFP_COMMON_H_
@@ -514,9 +506,3 @@ void nfp_net_init_metadata_format(struct nfp_net_hw *hw);
((struct nfp_app_fw_flower *)app_fw_priv)
#endif /* _NFP_COMMON_H_ */
-/*
- * Local variables:
- * c-file-style: "Linux"
- * indent-tabs-mode: t
- * End:
- */
diff --git a/drivers/net/nfp/nfp_cpp_bridge.c b/drivers/net/nfp/nfp_cpp_bridge.c
index 78a680453b..88cd1aa572 100644
--- a/drivers/net/nfp/nfp_cpp_bridge.c
+++ b/drivers/net/nfp/nfp_cpp_bridge.c
@@ -5,14 +5,6 @@
* Small portions derived from code Copyright(c) 2010-2015 Intel Corporation.
*/
-/*
- * vim:shiftwidth=8:noexpandtab
- *
- * @file dpdk/pmd/nfp_cpp_bridge.c
- *
- * Netronome vNIC DPDK Poll-Mode Driver: CPP Bridge
- */
-
#include <unistd.h>
#include <sys/ioctl.h>
@@ -453,9 +445,3 @@ nfp_cpp_bridge_service_func(void *args)
return 0;
}
-/*
- * Local variables:
- * c-file-style: "Linux"
- * indent-tabs-mode: t
- * End:
- */
diff --git a/drivers/net/nfp/nfp_cpp_bridge.h b/drivers/net/nfp/nfp_cpp_bridge.h
index 8ff7a22fbd..85289e158b 100644
--- a/drivers/net/nfp/nfp_cpp_bridge.h
+++ b/drivers/net/nfp/nfp_cpp_bridge.h
@@ -5,14 +5,6 @@
* Small portions derived from code Copyright(c) 2010-2015 Intel Corporation.
*/
-/*
- * vim:shiftwidth=8:noexpandtab
- *
- * @file dpdk/pmd/nfp_cpp_bridge.h
- *
- * Netronome vNIC DPDK Poll-Mode Driver: CPP Bridge header file
- */
-
#ifndef _NFP_CPP_BRIDGE_H_
#define _NFP_CPP_BRIDGE_H_
@@ -30,9 +22,3 @@ int nfp_enable_cpp_service(struct nfp_pf_dev *pf_dev);
int nfp_map_service(uint32_t service_id);
#endif /* _NFP_CPP_BRIDGE_H_ */
-/*
- * Local variables:
- * c-file-style: "Linux"
- * indent-tabs-mode: t
- * End:
- */
diff --git a/drivers/net/nfp/nfp_ctrl.h b/drivers/net/nfp/nfp_ctrl.h
index c8ca14e017..bca31ac311 100644
--- a/drivers/net/nfp/nfp_ctrl.h
+++ b/drivers/net/nfp/nfp_ctrl.h
@@ -3,11 +3,6 @@
* All rights reserved.
*/
-/*
- * vim:shiftwidth=8:noexpandtab
- *
- * Netronome network device driver: Control BAR layout
- */
#ifndef _NFP_CTRL_H_
#define _NFP_CTRL_H_
@@ -434,9 +429,3 @@ nfp_net_cfg_ctrl_rss(uint32_t hw_cap)
}
#endif /* _NFP_CTRL_H_ */
-/*
- * Local variables:
- * c-file-style: "Linux"
- * indent-tabs-mode: t
- * End:
- */
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index d48534fd61..3a56726388 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -5,14 +5,6 @@
* Small portions derived from code Copyright(c) 2010-2015 Intel Corporation.
*/
-/*
- * vim:shiftwidth=8:noexpandtab
- *
- * @file dpdk/pmd/nfp_ethdev.c
- *
- * Netronome vNIC DPDK Poll-Mode Driver: Main entry point
- */
-
#include <rte_common.h>
#include <ethdev_driver.h>
#include <ethdev_pci.h>
@@ -1295,9 +1287,3 @@ static struct rte_pci_driver rte_nfp_net_pf_pmd = {
RTE_PMD_REGISTER_PCI(net_nfp_pf, rte_nfp_net_pf_pmd);
RTE_PMD_REGISTER_PCI_TABLE(net_nfp_pf, pci_id_nfp_pf_net_map);
RTE_PMD_REGISTER_KMOD_DEP(net_nfp_pf, "* igb_uio | uio_pci_generic | vfio");
-/*
- * Local variables:
- * c-file-style: "Linux"
- * indent-tabs-mode: t
- * End:
- */
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index 7521a6ec90..f8135fa0c8 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -5,14 +5,6 @@
* Small portions derived from code Copyright(c) 2010-2015 Intel Corporation.
*/
-/*
- * vim:shiftwidth=8:noexpandtab
- *
- * @file dpdk/pmd/nfp_ethdev_vf.c
- *
- * Netronome vNIC VF DPDK Poll-Mode Driver: Main entry point
- */
-
#include <rte_alarm.h>
#include "nfpcore/nfp_mip.h"
@@ -510,9 +502,3 @@ static struct rte_pci_driver rte_nfp_net_vf_pmd = {
RTE_PMD_REGISTER_PCI(net_nfp_vf, rte_nfp_net_vf_pmd);
RTE_PMD_REGISTER_PCI_TABLE(net_nfp_vf, pci_id_nfp_vf_net_map);
RTE_PMD_REGISTER_KMOD_DEP(net_nfp_vf, "* igb_uio | uio_pci_generic | vfio");
-/*
- * Local variables:
- * c-file-style: "Linux"
- * indent-tabs-mode: t
- * End:
- */
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index 8283953702..2409f63205 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -5,14 +5,6 @@
* Small portions derived from code Copyright(c) 2010-2015 Intel Corporation.
*/
-/*
- * vim:shiftwidth=8:noexpandtab
- *
- * @file dpdk/pmd/nfp_rxtx.c
- *
- * Netronome vNIC DPDK Poll-Mode Driver: Rx/Tx functions
- */
-
#include <ethdev_driver.h>
#include <ethdev_pci.h>
diff --git a/drivers/net/nfp/nfp_rxtx.h b/drivers/net/nfp/nfp_rxtx.h
index 4a310c0083..f72c54fb25 100644
--- a/drivers/net/nfp/nfp_rxtx.h
+++ b/drivers/net/nfp/nfp_rxtx.h
@@ -3,14 +3,6 @@
* All rights reserved.
*/
-/*
- * vim:shiftwidth=8:noexpandtab
- *
- * @file dpdk/pmd/nfp_rxtx.h
- *
- * Netronome NFP Rx/Tx specific header file
- */
-
#ifndef _NFP_RXTX_H_
#define _NFP_RXTX_H_
@@ -331,9 +323,3 @@ void nfp_net_set_meta_vlan(struct nfp_net_meta_raw *meta_data,
uint8_t layer);
#endif /* _NFP_RXTX_H_ */
-/*
- * Local variables:
- * c-file-style: "Linux"
- * indent-tabs-mode: t
- * End:
- */
--
2.39.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 7/8] net/nfp: revise cast from void pointer
2023-05-19 2:59 [PATCH 0/8] make the logic conform the coding style of DPDK Chaoyong He
` (5 preceding siblings ...)
2023-05-19 2:59 ` [PATCH 6/8] net/nfp: remove the unneeded comment Chaoyong He
@ 2023-05-19 2:59 ` Chaoyong He
2023-05-19 2:59 ` [PATCH 8/8] net/nfp: revise the logic of MAC address Chaoyong He
2023-05-19 13:55 ` [PATCH 0/8] make the logic conform the coding style of DPDK Ferruh Yigit
8 siblings, 0 replies; 10+ messages in thread
From: Chaoyong He @ 2023-05-19 2:59 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, niklas.soderlund, Chaoyong He
When cast from void pointer to other pointer type, there is not need
to use '()' for force cast.
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 | 20 +++----
.../net/nfp/flower/nfp_flower_representor.c | 30 +++++------
drivers/net/nfp/nfp_common.c | 12 ++---
drivers/net/nfp/nfp_ethdev.c | 2 +-
drivers/net/nfp/nfp_ethdev_vf.c | 2 +-
drivers/net/nfp/nfp_flow.c | 54 +++++++++----------
drivers/net/nfp/nfp_rxtx.c | 2 +-
drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c | 2 +-
8 files changed, 60 insertions(+), 64 deletions(-)
diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index 9a08ae3b75..72933e55d0 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -60,7 +60,7 @@ nfp_pf_repr_disable_queues(struct rte_eth_dev *dev)
uint32_t update = 0;
struct nfp_flower_representor *repr;
- repr = (struct nfp_flower_representor *)dev->data->dev_private;
+ repr = dev->data->dev_private;
hw = repr->app_fw_flower->pf_hw;
nn_cfg_writeq(hw, NFP_NET_CFG_TXRS_ENABLE, 0);
@@ -89,7 +89,7 @@ nfp_flower_pf_start(struct rte_eth_dev *dev)
struct nfp_net_hw *hw;
struct nfp_flower_representor *repr;
- repr = (struct nfp_flower_representor *)dev->data->dev_private;
+ repr = dev->data->dev_private;
hw = repr->app_fw_flower->pf_hw;
/* Disabling queues just in case... */
@@ -149,19 +149,19 @@ nfp_flower_pf_stop(struct rte_eth_dev *dev)
struct nfp_net_rxq *this_rx_q;
struct nfp_flower_representor *repr;
- repr = (struct nfp_flower_representor *)dev->data->dev_private;
+ repr = dev->data->dev_private;
hw = repr->app_fw_flower->pf_hw;
nfp_pf_repr_disable_queues(dev);
/* Clear queues */
for (i = 0; i < dev->data->nb_tx_queues; i++) {
- this_tx_q = (struct nfp_net_txq *)dev->data->tx_queues[i];
+ this_tx_q = dev->data->tx_queues[i];
nfp_net_reset_tx_queue(this_tx_q);
}
for (i = 0; i < dev->data->nb_rx_queues; i++) {
- this_rx_q = (struct nfp_net_rxq *)dev->data->rx_queues[i];
+ this_rx_q = dev->data->rx_queues[i];
nfp_net_reset_rx_queue(this_rx_q);
}
@@ -189,7 +189,7 @@ nfp_flower_pf_close(struct rte_eth_dev *dev)
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return 0;
- repr = (struct nfp_flower_representor *)dev->data->dev_private;
+ repr = dev->data->dev_private;
hw = repr->app_fw_flower->pf_hw;
pf_dev = hw->pf_dev;
app_fw_flower = NFP_PRIV_TO_APP_FW_FLOWER(pf_dev->app_fw_priv);
@@ -204,12 +204,12 @@ nfp_flower_pf_close(struct rte_eth_dev *dev)
/* Clear queues */
for (i = 0; i < dev->data->nb_tx_queues; i++) {
- this_tx_q = (struct nfp_net_txq *)dev->data->tx_queues[i];
+ this_tx_q = dev->data->tx_queues[i];
nfp_net_reset_tx_queue(this_tx_q);
}
for (i = 0; i < dev->data->nb_rx_queues; i++) {
- this_rx_q = (struct nfp_net_rxq *)dev->data->rx_queues[i];
+ this_rx_q = dev->data->rx_queues[i];
nfp_net_reset_rx_queue(this_rx_q);
}
@@ -814,7 +814,7 @@ nfp_flower_init_ctrl_vnic(struct nfp_net_hw *hw)
/* Saving physical and virtual addresses for the RX ring */
rxq->dma = (uint64_t)tz->iova;
- rxq->rxds = (struct nfp_net_rx_desc *)tz->addr;
+ rxq->rxds = tz->addr;
/* Mbuf pointers array for referencing mbufs linked to RX descriptors */
rxq->rxbufs = rte_zmalloc_socket("rxq->rxbufs",
@@ -877,7 +877,7 @@ nfp_flower_init_ctrl_vnic(struct nfp_net_hw *hw)
/* Saving physical and virtual addresses for the TX ring */
txq->dma = (uint64_t)tz->iova;
- txq->txds = (struct nfp_net_nfd3_tx_desc *)tz->addr;
+ txq->txds = tz->addr;
/* Mbuf pointers array for referencing mbufs linked to TX descriptors */
txq->txbufs = rte_zmalloc_socket("txq->txbufs",
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index 0479eb4792..86b7d1a220 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -32,7 +32,7 @@ nfp_pf_repr_rx_queue_setup(struct rte_eth_dev *dev,
const struct rte_memzone *tz;
struct nfp_flower_representor *repr;
- repr = (struct nfp_flower_representor *)dev->data->dev_private;
+ repr = dev->data->dev_private;
hw = repr->app_fw_flower->pf_hw;
/* Allocating rx queue data structure */
@@ -78,7 +78,7 @@ nfp_pf_repr_rx_queue_setup(struct rte_eth_dev *dev,
/* Saving physical and virtual addresses for the RX ring */
rxq->dma = (uint64_t)tz->iova;
- rxq->rxds = (struct nfp_net_rx_desc *)tz->addr;
+ rxq->rxds = tz->addr;
/* mbuf pointers array for referencing mbufs linked to RX descriptors */
rxq->rxbufs = rte_zmalloc_socket("rxq->rxbufs",
@@ -116,7 +116,7 @@ nfp_pf_repr_tx_queue_setup(struct rte_eth_dev *dev,
const struct rte_memzone *tz;
struct nfp_flower_representor *repr;
- repr = (struct nfp_flower_representor *)dev->data->dev_private;
+ repr = dev->data->dev_private;
hw = repr->app_fw_flower->pf_hw;
tx_free_thresh = (tx_conf->tx_free_thresh) ? tx_conf->tx_free_thresh :
@@ -161,7 +161,7 @@ nfp_pf_repr_tx_queue_setup(struct rte_eth_dev *dev,
/* Saving physical and virtual addresses for the TX ring */
txq->dma = (uint64_t)tz->iova;
- txq->txds = (struct nfp_net_nfd3_tx_desc *)tz->addr;
+ txq->txds = tz->addr;
/* mbuf pointers array for referencing mbufs linked to TX descriptors */
txq->txbufs = rte_zmalloc_socket("txq->txbufs",
@@ -207,7 +207,7 @@ nfp_flower_repr_link_update(struct rte_eth_dev *dev,
[NFP_NET_CFG_STS_LINK_RATE_100G] = RTE_ETH_SPEED_NUM_100G,
};
- repr = (struct nfp_flower_representor *)dev->data->dev_private;
+ repr = dev->data->dev_private;
link = &repr->link;
pf_hw = repr->app_fw_flower->pf_hw;
@@ -273,7 +273,7 @@ nfp_flower_repr_dev_configure(struct rte_eth_dev *dev)
struct rte_eth_rxmode *rxmode;
struct nfp_flower_representor *repr;
- repr = (struct nfp_flower_representor *)dev->data->dev_private;
+ repr = dev->data->dev_private;
pf_hw = repr->app_fw_flower->pf_hw;
dev_conf = &dev->data->dev_conf;
@@ -295,7 +295,7 @@ nfp_flower_repr_dev_start(struct rte_eth_dev *dev)
struct nfp_flower_representor *repr;
struct nfp_app_fw_flower *app_fw_flower;
- repr = (struct nfp_flower_representor *)dev->data->dev_private;
+ repr = dev->data->dev_private;
app_fw_flower = repr->app_fw_flower;
if (repr->repr_type == NFP_REPR_TYPE_PHYS_PORT) {
@@ -314,7 +314,7 @@ nfp_flower_repr_dev_stop(struct rte_eth_dev *dev)
struct nfp_flower_representor *repr;
struct nfp_app_fw_flower *app_fw_flower;
- repr = (struct nfp_flower_representor *)dev->data->dev_private;
+ repr = dev->data->dev_private;
app_fw_flower = repr->app_fw_flower;
nfp_flower_cmsg_port_mod(app_fw_flower, repr->port_id, false);
@@ -339,7 +339,7 @@ nfp_flower_repr_rx_queue_setup(struct rte_eth_dev *dev,
struct nfp_net_hw *pf_hw;
struct nfp_flower_representor *repr;
- repr = (struct nfp_flower_representor *)dev->data->dev_private;
+ repr = dev->data->dev_private;
pf_hw = repr->app_fw_flower->pf_hw;
/* Allocating rx queue data structure */
@@ -367,7 +367,7 @@ nfp_flower_repr_tx_queue_setup(struct rte_eth_dev *dev,
struct nfp_net_hw *pf_hw;
struct nfp_flower_representor *repr;
- repr = (struct nfp_flower_representor *)dev->data->dev_private;
+ repr = dev->data->dev_private;
pf_hw = repr->app_fw_flower->pf_hw;
/* Allocating tx queue data structure */
@@ -390,7 +390,7 @@ nfp_flower_repr_stats_get(struct rte_eth_dev *ethdev,
{
struct nfp_flower_representor *repr;
- repr = (struct nfp_flower_representor *)ethdev->data->dev_private;
+ repr = ethdev->data->dev_private;
rte_memcpy(stats, &repr->repr_stats, sizeof(struct rte_eth_stats));
return 0;
@@ -401,7 +401,7 @@ nfp_flower_repr_stats_reset(struct rte_eth_dev *ethdev)
{
struct nfp_flower_representor *repr;
- repr = (struct nfp_flower_representor *)ethdev->data->dev_private;
+ repr = ethdev->data->dev_private;
memset(&repr->repr_stats, 0, sizeof(struct rte_eth_stats));
return 0;
@@ -413,7 +413,7 @@ nfp_flower_repr_mac_addr_set(struct rte_eth_dev *ethdev,
{
struct nfp_flower_representor *repr;
- repr = (struct nfp_flower_representor *)ethdev->data->dev_private;
+ repr = ethdev->data->dev_private;
rte_ether_addr_copy(mac_addr, &repr->mac_addr);
rte_ether_addr_copy(mac_addr, ethdev->data->mac_addrs);
@@ -584,7 +584,7 @@ nfp_flower_pf_repr_init(struct rte_eth_dev *eth_dev,
struct nfp_flower_representor *init_repr_data;
/* Cast the input representor data to the correct struct here */
- init_repr_data = (struct nfp_flower_representor *)init_params;
+ init_repr_data = init_params;
/* Memory has been allocated in the eth_dev_create() function */
repr = eth_dev->data->dev_private;
@@ -639,7 +639,7 @@ nfp_flower_repr_init(struct rte_eth_dev *eth_dev,
struct nfp_flower_representor *init_repr_data;
/* Cast the input representor data to the correct struct here */
- init_repr_data = (struct nfp_flower_representor *)init_params;
+ init_repr_data = init_params;
app_fw_flower = init_repr_data->app_fw_flower;
/* Memory has been allocated in the eth_dev_create() function */
diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c
index 634afbf1b5..b7a7296999 100644
--- a/drivers/net/nfp/nfp_common.c
+++ b/drivers/net/nfp/nfp_common.c
@@ -1404,7 +1404,7 @@ nfp_net_irq_unmask(struct rte_eth_dev *dev)
void
nfp_net_dev_interrupt_delayed_handler(void *param)
{
- struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
+ struct rte_eth_dev *dev = param;
nfp_net_link_update(dev, 0);
rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
@@ -1420,7 +1420,7 @@ nfp_net_dev_interrupt_handler(void *param)
{
int64_t timeout;
struct rte_eth_link link;
- struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
+ struct rte_eth_dev *dev = param;
PMD_DRV_LOG(DEBUG, "We got a LSC interrupt!!!");
@@ -1840,7 +1840,7 @@ nfp_net_stop_rx_queue(struct rte_eth_dev *dev)
struct nfp_net_rxq *this_rx_q;
for (i = 0; i < dev->data->nb_rx_queues; i++) {
- this_rx_q = (struct nfp_net_rxq *)dev->data->rx_queues[i];
+ this_rx_q = dev->data->rx_queues[i];
nfp_net_reset_rx_queue(this_rx_q);
}
}
@@ -1852,7 +1852,7 @@ nfp_net_close_rx_queue(struct rte_eth_dev *dev)
struct nfp_net_rxq *this_rx_q;
for (i = 0; i < dev->data->nb_rx_queues; i++) {
- this_rx_q = (struct nfp_net_rxq *)dev->data->rx_queues[i];
+ this_rx_q = dev->data->rx_queues[i];
nfp_net_reset_rx_queue(this_rx_q);
nfp_net_rx_queue_release(dev, i);
}
@@ -1865,7 +1865,7 @@ nfp_net_stop_tx_queue(struct rte_eth_dev *dev)
struct nfp_net_txq *this_tx_q;
for (i = 0; i < dev->data->nb_tx_queues; i++) {
- this_tx_q = (struct nfp_net_txq *)dev->data->tx_queues[i];
+ this_tx_q = dev->data->tx_queues[i];
nfp_net_reset_tx_queue(this_tx_q);
}
}
@@ -1877,7 +1877,7 @@ nfp_net_close_tx_queue(struct rte_eth_dev *dev)
struct nfp_net_txq *this_tx_q;
for (i = 0; i < dev->data->nb_tx_queues; i++) {
- this_tx_q = (struct nfp_net_txq *)dev->data->tx_queues[i];
+ this_tx_q = dev->data->tx_queues[i];
nfp_net_reset_tx_queue(this_tx_q);
nfp_net_tx_queue_release(dev, i);
}
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 3a56726388..06146050ff 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -542,7 +542,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
pci_dev->addr.domain, pci_dev->addr.bus,
pci_dev->addr.devid, pci_dev->addr.function);
- hw->ctrl_bar = (uint8_t *)pci_dev->mem_resource[0].addr;
+ hw->ctrl_bar = pci_dev->mem_resource[0].addr;
if (hw->ctrl_bar == NULL) {
PMD_DRV_LOG(ERR,
"hw->ctrl_bar is NULL. BAR0 not configured");
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index f8135fa0c8..bac8df6142 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -289,7 +289,7 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
hw = NFP_NET_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
- hw->ctrl_bar = (uint8_t *)pci_dev->mem_resource[0].addr;
+ hw->ctrl_bar = pci_dev->mem_resource[0].addr;
if (hw->ctrl_bar == NULL) {
PMD_DRV_LOG(ERR,
"hw->ctrl_bar is NULL. BAR0 not configured");
diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c
index fdf5c0f40e..b46acf6a39 100644
--- a/drivers/net/nfp/nfp_flow.c
+++ b/drivers/net/nfp/nfp_flow.c
@@ -93,7 +93,7 @@ nfp_flow_dev_to_priv(struct rte_eth_dev *dev)
{
struct nfp_flower_representor *repr;
- repr = (struct nfp_flower_representor *)dev->data->dev_private;
+ repr = dev->data->dev_private;
return repr->app_fw_flower->flow_priv;
}
@@ -726,8 +726,7 @@ nfp_flow_key_layers_calculate_items(const struct rte_flow_item items[],
if (port_id->id >= RTE_MAX_ETHPORTS)
return -ERANGE;
ethdev = &rte_eth_devices[port_id->id];
- representor = (struct nfp_flower_representor *)
- ethdev->data->dev_private;
+ representor = ethdev->data->dev_private;
key_ls->port = rte_cpu_to_be_32(representor->port_id);
break;
case RTE_FLOW_ITEM_TYPE_VLAN:
@@ -2047,7 +2046,7 @@ nfp_flow_action_output(char *act_data,
return -ERANGE;
ethdev = &rte_eth_devices[port_id->id];
- representor = (struct nfp_flower_representor *)ethdev->data->dev_private;
+ representor = ethdev->data->dev_private;
act_size = sizeof(struct nfp_fl_act_output);
output = (struct nfp_fl_act_output *)act_data;
@@ -2083,7 +2082,7 @@ nfp_flow_action_set_mac(char *act_data,
set_eth->head.len_lw = act_size >> NFP_FL_LW_SIZ;
set_eth->reserved = 0;
- set_mac = (const struct rte_flow_action_set_mac *)action->conf;
+ set_mac = action->conf;
if (mac_src_flag) {
rte_memcpy(&set_eth->eth_addr[RTE_ETHER_ADDR_LEN],
set_mac->mac_addr, RTE_ETHER_ADDR_LEN);
@@ -2133,7 +2132,7 @@ nfp_flow_action_set_ip(char *act_data,
set_ip->head.len_lw = act_size >> NFP_FL_LW_SIZ;
set_ip->reserved = 0;
- set_ipv4 = (const struct rte_flow_action_set_ipv4 *)action->conf;
+ set_ipv4 = action->conf;
if (ip_src_flag) {
set_ip->ipv4_src = set_ipv4->ipv4_addr;
set_ip->ipv4_src_mask = RTE_BE32(0xffffffff);
@@ -2154,7 +2153,7 @@ nfp_flow_action_set_ipv6(char *act_data,
const struct rte_flow_action_set_ipv6 *set_ipv6;
set_ip = (struct nfp_fl_act_set_ipv6_addr *)act_data;
- set_ipv6 = (const struct rte_flow_action_set_ipv6 *)action->conf;
+ set_ipv6 = action->conf;
if (ip_src_flag)
set_ip->head.jump_id = NFP_FL_ACTION_OPCODE_SET_IPV6_SRC;
@@ -2191,7 +2190,7 @@ nfp_flow_action_set_tp(char *act_data,
set_tp->head.len_lw = act_size >> NFP_FL_LW_SIZ;
set_tp->reserved = 0;
- set_tp_conf = (const struct rte_flow_action_set_tp *)action->conf;
+ set_tp_conf = action->conf;
if (tp_src_flag) {
set_tp->src_port = set_tp_conf->port;
set_tp->src_port_mask = RTE_BE16(0xffff);
@@ -2223,12 +2222,9 @@ nfp_flow_action_push_vlan(char *act_data,
push_vlan->head.len_lw = act_size >> NFP_FL_LW_SIZ;
push_vlan->reserved = 0;
- push_vlan_conf = (const struct rte_flow_action_of_push_vlan *)
- action->conf;
- vlan_pcp_conf = (const struct rte_flow_action_of_set_vlan_pcp *)
- (action + 1)->conf;
- vlan_vid_conf = (const struct rte_flow_action_of_set_vlan_vid *)
- (action + 2)->conf;
+ push_vlan_conf = action->conf;
+ vlan_pcp_conf = (action + 1)->conf;
+ vlan_vid_conf = (action + 2)->conf;
vid = rte_be_to_cpu_16(vlan_vid_conf->vlan_vid) & 0x0fff;
pcp = vlan_pcp_conf->vlan_pcp & 0x07;
@@ -2256,7 +2252,7 @@ nfp_flow_action_set_ttl(char *act_data,
ttl_tos->head.jump_id = NFP_FL_ACTION_OPCODE_SET_IPV4_TTL_TOS;
ttl_tos->head.len_lw = act_size >> NFP_FL_LW_SIZ;
- ttl_conf = (const struct rte_flow_action_set_ttl *)action->conf;
+ ttl_conf = action->conf;
ttl_tos->ipv4_ttl = ttl_conf->ttl_value;
ttl_tos->ipv4_ttl_mask = 0xff;
ttl_tos->reserved = 0;
@@ -2280,7 +2276,7 @@ nfp_flow_action_set_hl(char *act_data,
tc_hl->head.jump_id = NFP_FL_ACTION_OPCODE_SET_IPV6_TC_HL_FL;
tc_hl->head.len_lw = act_size >> NFP_FL_LW_SIZ;
- ttl_conf = (const struct rte_flow_action_set_ttl *)action->conf;
+ ttl_conf = action->conf;
tc_hl->ipv6_hop_limit = ttl_conf->ttl_value;
tc_hl->ipv6_hop_limit_mask = 0xff;
tc_hl->reserved = 0;
@@ -2304,7 +2300,7 @@ nfp_flow_action_set_tos(char *act_data,
ttl_tos->head.jump_id = NFP_FL_ACTION_OPCODE_SET_IPV4_TTL_TOS;
ttl_tos->head.len_lw = act_size >> NFP_FL_LW_SIZ;
- tos_conf = (const struct rte_flow_action_set_dscp *)action->conf;
+ tos_conf = action->conf;
ttl_tos->ipv4_tos = tos_conf->dscp;
ttl_tos->ipv4_tos_mask = 0xff;
ttl_tos->reserved = 0;
@@ -2328,7 +2324,7 @@ nfp_flow_action_set_tc(char *act_data,
tc_hl->head.jump_id = NFP_FL_ACTION_OPCODE_SET_IPV6_TC_HL_FL;
tc_hl->head.len_lw = act_size >> NFP_FL_LW_SIZ;
- tos_conf = (const struct rte_flow_action_set_dscp *)action->conf;
+ tos_conf = action->conf;
tc_hl->ipv6_tc = tos_conf->dscp;
tc_hl->ipv6_tc_mask = 0xff;
tc_hl->reserved = 0;
@@ -2719,9 +2715,9 @@ nfp_flow_action_vxlan_encap_v4(struct nfp_app_fw_flower *app_fw_flower,
size_t act_pre_size = sizeof(struct nfp_fl_act_pre_tun);
size_t act_set_size = sizeof(struct nfp_fl_act_set_tun);
- eth = (const struct rte_flow_item_eth *)vxlan_data->items[0].spec;
- ipv4 = (const struct rte_flow_item_ipv4 *)vxlan_data->items[1].spec;
- vxlan = (const struct rte_flow_item_vxlan *)vxlan_data->items[3].spec;
+ eth = vxlan_data->items[0].spec;
+ ipv4 = vxlan_data->items[1].spec;
+ vxlan = vxlan_data->items[3].spec;
pre_tun = (struct nfp_fl_act_pre_tun *)actions;
memset(pre_tun, 0, act_pre_size);
@@ -2756,9 +2752,9 @@ nfp_flow_action_vxlan_encap_v6(struct nfp_app_fw_flower *app_fw_flower,
size_t act_pre_size = sizeof(struct nfp_fl_act_pre_tun);
size_t act_set_size = sizeof(struct nfp_fl_act_set_tun);
- eth = (const struct rte_flow_item_eth *)vxlan_data->items[0].spec;
- ipv6 = (const struct rte_flow_item_ipv6 *)vxlan_data->items[1].spec;
- vxlan = (const struct rte_flow_item_vxlan *)vxlan_data->items[3].spec;
+ eth = vxlan_data->items[0].spec;
+ ipv6 = vxlan_data->items[1].spec;
+ vxlan = vxlan_data->items[3].spec;
pre_tun = (struct nfp_fl_act_pre_tun *)actions;
memset(pre_tun, 0, act_pre_size);
@@ -3626,7 +3622,7 @@ nfp_flow_process(struct nfp_flower_representor *representor,
nfp_flower_update_meta_tci(nfp_flow->payload.unmasked_data, new_mask_id);
/* Calculate and store the hash_key for later use */
- hash_data = (char *)(nfp_flow->payload.unmasked_data);
+ hash_data = nfp_flow->payload.unmasked_data;
nfp_flow->hash_key = rte_jhash(hash_data, nfp_flow->length, priv->hash_seed);
/* Find the flow in hash table */
@@ -3716,7 +3712,7 @@ nfp_flow_validate(struct rte_eth_dev *dev,
struct nfp_flow_priv *priv;
struct nfp_flower_representor *representor;
- representor = (struct nfp_flower_representor *)dev->data->dev_private;
+ representor = dev->data->dev_private;
priv = representor->app_fw_flower->flow_priv;
nfp_flow = nfp_flow_setup(representor, attr, items, actions, error, true);
@@ -3751,7 +3747,7 @@ nfp_flow_create(struct rte_eth_dev *dev,
struct nfp_app_fw_flower *app_fw_flower;
struct nfp_flower_representor *representor;
- representor = (struct nfp_flower_representor *)dev->data->dev_private;
+ representor = dev->data->dev_private;
app_fw_flower = representor->app_fw_flower;
priv = app_fw_flower->flow_priv;
@@ -3813,7 +3809,7 @@ nfp_flow_destroy(struct rte_eth_dev *dev,
struct nfp_app_fw_flower *app_fw_flower;
struct nfp_flower_representor *representor;
- representor = (struct nfp_flower_representor *)dev->data->dev_private;
+ representor = dev->data->dev_private;
app_fw_flower = representor->app_fw_flower;
priv = app_fw_flower->flow_priv;
@@ -3949,7 +3945,7 @@ nfp_flow_stats_get(struct rte_eth_dev *dev,
return;
}
- query = (struct rte_flow_query_count *)data;
+ query = data;
reset = query->reset;
memset(query, 0, sizeof(*query));
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index 2409f63205..3c78557221 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -630,7 +630,7 @@ nfp_net_rx_queue_setup(struct rte_eth_dev *dev,
/* Saving physical and virtual addresses for the RX ring */
rxq->dma = (uint64_t)tz->iova;
- rxq->rxds = (struct nfp_net_rx_desc *)tz->addr;
+ rxq->rxds = tz->addr;
/* mbuf pointers array for referencing mbufs linked to RX descriptors */
rxq->rxbufs = rte_zmalloc_socket("rxq->rxbufs",
diff --git a/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c b/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c
index edf4088747..9d63e0ee73 100644
--- a/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c
+++ b/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c
@@ -835,7 +835,7 @@ nfp6000_init(struct nfp_cpp *cpp, struct rte_pci_device *dev)
if (nfp6000_set_barsz(dev, desc) < 0)
goto error;
- desc->cfg = (char *)dev->mem_resource[0].addr;
+ desc->cfg = dev->mem_resource[0].addr;
nfp_enable_bars(desc);
--
2.39.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 8/8] net/nfp: revise the logic of MAC address
2023-05-19 2:59 [PATCH 0/8] make the logic conform the coding style of DPDK Chaoyong He
` (6 preceding siblings ...)
2023-05-19 2:59 ` [PATCH 7/8] net/nfp: revise cast from void pointer Chaoyong He
@ 2023-05-19 2:59 ` Chaoyong He
2023-05-19 13:55 ` [PATCH 0/8] make the logic conform the coding style of DPDK Ferruh Yigit
8 siblings, 0 replies; 10+ messages in thread
From: Chaoyong He @ 2023-05-19 2:59 UTC (permalink / raw)
To: dev; +Cc: oss-drivers, niklas.soderlund, Chaoyong He
Drop the usage of customed macro and function about MAC address,
using the macro and function from framework.
Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
.../net/nfp/flower/nfp_flower_representor.c | 3 +--
drivers/net/nfp/nfp_common.c | 11 -----------
drivers/net/nfp/nfp_common.h | 4 +---
drivers/net/nfp/nfp_ethdev.c | 17 +++++++----------
drivers/net/nfp/nfp_ethdev_vf.c | 18 ++++++++----------
drivers/net/nfp/nfp_flow.c | 6 +++---
drivers/net/nfp/nfpcore/nfp_nsp.h | 4 +---
drivers/net/nfp/nfpcore/nfp_nsp_eth.c | 8 ++++----
8 files changed, 25 insertions(+), 46 deletions(-)
diff --git a/drivers/net/nfp/flower/nfp_flower_representor.c b/drivers/net/nfp/flower/nfp_flower_representor.c
index 86b7d1a220..c3764b4de7 100644
--- a/drivers/net/nfp/flower/nfp_flower_representor.c
+++ b/drivers/net/nfp/flower/nfp_flower_representor.c
@@ -768,8 +768,7 @@ nfp_flower_repr_alloc(struct nfp_app_fw_flower *app_fw_flower)
flower_repr.vf_id = i + 1;
/* Copy the real mac of the interface to the representor struct */
- rte_ether_addr_copy((struct rte_ether_addr *)eth_port->mac_addr,
- &flower_repr.mac_addr);
+ rte_ether_addr_copy(ð_port->mac_addr, &flower_repr.mac_addr);
sprintf(flower_repr.name, "flower_repr_p%d", i);
/*
diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c
index b7a7296999..c9fea765a4 100644
--- a/drivers/net/nfp/nfp_common.c
+++ b/drivers/net/nfp/nfp_common.c
@@ -453,17 +453,6 @@ nfp_net_cfg_queue_setup(struct nfp_net_hw *hw)
hw->qcp_cfg = hw->tx_bar + NFP_QCP_QUEUE_ADDR_SZ;
}
-#define ETH_ADDR_LEN 6
-
-void
-nfp_eth_copy_mac(uint8_t *dst, const uint8_t *src)
-{
- int i;
-
- for (i = 0; i < ETH_ADDR_LEN; i++)
- dst[i] = src[i];
-}
-
void
nfp_net_write_mac(struct nfp_net_hw *hw, uint8_t *mac)
{
diff --git a/drivers/net/nfp/nfp_common.h b/drivers/net/nfp/nfp_common.h
index 914903f587..47df0510c5 100644
--- a/drivers/net/nfp/nfp_common.h
+++ b/drivers/net/nfp/nfp_common.h
@@ -232,7 +232,7 @@ struct nfp_net_hw {
#endif
#endif
- uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
+ struct rte_ether_addr mac_addr;
/* Records starting point for counters */
struct rte_eth_stats eth_stats_base;
@@ -428,7 +428,6 @@ void nfp_net_log_device_information(const struct nfp_net_hw *hw);
void nfp_net_enable_queues(struct rte_eth_dev *dev);
void nfp_net_disable_queues(struct rte_eth_dev *dev);
void nfp_net_params_setup(struct nfp_net_hw *hw);
-void nfp_eth_copy_mac(uint8_t *dst, const uint8_t *src);
void nfp_net_write_mac(struct nfp_net_hw *hw, uint8_t *mac);
int nfp_net_set_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr);
int nfp_configure_rx_interrupt(struct rte_eth_dev *dev,
@@ -463,7 +462,6 @@ int nfp_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id);
int nfp_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id);
void nfp_net_params_setup(struct nfp_net_hw *hw);
void nfp_net_cfg_queue_setup(struct nfp_net_hw *hw);
-void nfp_eth_copy_mac(uint8_t *dst, const uint8_t *src);
void nfp_net_dev_interrupt_handler(void *param);
void nfp_net_dev_interrupt_delayed_handler(void *param);
int nfp_net_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 06146050ff..722ec17dce 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -45,8 +45,7 @@ nfp_net_pf_read_mac(struct nfp_app_fw_nic *app_fw_nic, int port)
nfp_eth_table = nfp_eth_read_ports(app_fw_nic->pf_dev->cpp);
- nfp_eth_copy_mac((uint8_t *)&hw->mac_addr,
- (uint8_t *)&nfp_eth_table->ports[port].mac_addr);
+ rte_ether_addr_copy(&nfp_eth_table->ports[port].mac_addr, &hw->mac_addr);
free(nfp_eth_table);
return 0;
@@ -654,19 +653,18 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
}
nfp_net_pf_read_mac(app_fw_nic, port);
- nfp_net_write_mac(hw, (uint8_t *)&hw->mac_addr);
+ nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
- tmp_ether_addr = (struct rte_ether_addr *)&hw->mac_addr;
+ tmp_ether_addr = &hw->mac_addr;
if (!rte_is_valid_assigned_ether_addr(tmp_ether_addr)) {
PMD_INIT_LOG(INFO, "Using random mac address for port %d", port);
/* Using random mac addresses for VFs */
- rte_eth_random_addr(&hw->mac_addr[0]);
- nfp_net_write_mac(hw, (uint8_t *)&hw->mac_addr);
+ rte_eth_random_addr(&hw->mac_addr.addr_bytes[0]);
+ nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
}
/* Copying mac address to DPDK eth_dev struct */
- rte_ether_addr_copy((struct rte_ether_addr *)hw->mac_addr,
- ð_dev->data->mac_addrs[0]);
+ rte_ether_addr_copy(&hw->mac_addr, eth_dev->data->mac_addrs);
if ((hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
eth_dev->data->dev_flags |= RTE_ETH_DEV_NOLIVE_MAC_ADDR;
@@ -677,8 +675,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
"mac=" RTE_ETHER_ADDR_PRT_FMT,
eth_dev->data->port_id, pci_dev->id.vendor_id,
pci_dev->id.device_id,
- hw->mac_addr[0], hw->mac_addr[1], hw->mac_addr[2],
- hw->mac_addr[3], hw->mac_addr[4], hw->mac_addr[5]);
+ RTE_ETHER_ADDR_BYTES(&hw->mac_addr));
/* Registering LSC interrupt handler */
rte_intr_callback_register(pci_dev->intr_handle,
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index bac8df6142..ce55e3b728 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -23,10 +23,10 @@ nfp_netvf_read_mac(struct nfp_net_hw *hw)
uint32_t tmp;
tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR));
- memcpy(&hw->mac_addr[0], &tmp, 4);
+ memcpy(&hw->mac_addr.addr_bytes[0], &tmp, 4);
tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR + 4));
- memcpy(&hw->mac_addr[4], &tmp, 2);
+ memcpy(&hw->mac_addr.addr_bytes[4], &tmp, 2);
}
static int
@@ -406,18 +406,17 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
nfp_netvf_read_mac(hw);
- tmp_ether_addr = (struct rte_ether_addr *)&hw->mac_addr;
+ tmp_ether_addr = &hw->mac_addr;
if (!rte_is_valid_assigned_ether_addr(tmp_ether_addr)) {
PMD_INIT_LOG(INFO, "Using random mac address for port %d",
port);
/* Using random mac addresses for VFs */
- rte_eth_random_addr(&hw->mac_addr[0]);
- nfp_net_write_mac(hw, (uint8_t *)&hw->mac_addr);
+ rte_eth_random_addr(&hw->mac_addr.addr_bytes[0]);
+ nfp_net_write_mac(hw, &hw->mac_addr.addr_bytes[0]);
}
/* Copying mac address to DPDK eth_dev struct */
- rte_ether_addr_copy((struct rte_ether_addr *)hw->mac_addr,
- ð_dev->data->mac_addrs[0]);
+ rte_ether_addr_copy(&hw->mac_addr, eth_dev->data->mac_addrs);
if ((hw->cap & NFP_NET_CFG_CTRL_LIVE_ADDR) == 0)
eth_dev->data->dev_flags |= RTE_ETH_DEV_NOLIVE_MAC_ADDR;
@@ -425,11 +424,10 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
PMD_INIT_LOG(INFO, "port %d VendorID=0x%x DeviceID=0x%x "
- "mac=%02x:%02x:%02x:%02x:%02x:%02x",
+ "mac=" RTE_ETHER_ADDR_PRT_FMT,
eth_dev->data->port_id, pci_dev->id.vendor_id,
pci_dev->id.device_id,
- hw->mac_addr[0], hw->mac_addr[1], hw->mac_addr[2],
- hw->mac_addr[3], hw->mac_addr[4], hw->mac_addr[5]);
+ RTE_ETHER_ADDR_BYTES(&hw->mac_addr));
if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
/* Registering LSC interrupt handler */
diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c
index b46acf6a39..cb7073f361 100644
--- a/drivers/net/nfp/nfp_flow.c
+++ b/drivers/net/nfp/nfp_flow.c
@@ -85,7 +85,7 @@ struct nfp_mask_id_entry {
struct nfp_pre_tun_entry {
uint16_t mac_index;
uint16_t ref_cnt;
- uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
+ struct rte_ether_addr mac_addr;
} __rte_aligned(32);
static inline struct nfp_flow_priv *
@@ -2894,7 +2894,7 @@ nfp_pre_tun_table_check_add(struct nfp_flower_representor *repr,
}
entry->ref_cnt = 1U;
- memcpy(entry->mac_addr, repr->mac_addr.addr_bytes, RTE_ETHER_ADDR_LEN);
+ rte_ether_addr_copy(&repr->mac_addr, &entry->mac_addr);
/* 0 is considered a failed match */
for (i = 1; i < NFP_TUN_PRE_TUN_RULE_LIMIT; i++) {
@@ -2954,7 +2954,7 @@ nfp_pre_tun_table_check_del(struct nfp_flower_representor *repr,
}
entry->ref_cnt = 1U;
- memcpy(entry->mac_addr, repr->mac_addr.addr_bytes, RTE_ETHER_ADDR_LEN);
+ rte_ether_addr_copy(&repr->mac_addr, &entry->mac_addr);
/* 0 is considered a failed match */
for (i = 1; i < NFP_TUN_PRE_TUN_RULE_LIMIT; i++) {
diff --git a/drivers/net/nfp/nfpcore/nfp_nsp.h b/drivers/net/nfp/nfpcore/nfp_nsp.h
index 50cdec3a58..9905b2d3d3 100644
--- a/drivers/net/nfp/nfpcore/nfp_nsp.h
+++ b/drivers/net/nfp/nfpcore/nfp_nsp.h
@@ -157,8 +157,6 @@ enum nfp_eth_fec {
#define NFP_FEC_REED_SOLOMON RTE_BIT32(NFP_FEC_REED_SOLOMON_BIT)
#define NFP_FEC_DISABLED RTE_BIT32(NFP_FEC_DISABLED_BIT)
-#define ETH_ALEN 6
-
/**
* struct nfp_eth_table - ETH table information
* @count: number of table entries
@@ -205,7 +203,7 @@ struct nfp_eth_table {
enum nfp_eth_fec fec;
enum nfp_eth_aneg aneg;
- uint8_t mac_addr[ETH_ALEN];
+ struct rte_ether_addr mac_addr;
uint8_t label_port;
uint8_t label_subport;
diff --git a/drivers/net/nfp/nfpcore/nfp_nsp_eth.c b/drivers/net/nfp/nfpcore/nfp_nsp_eth.c
index f8d1416d4b..01b4652280 100644
--- a/drivers/net/nfp/nfpcore/nfp_nsp_eth.c
+++ b/drivers/net/nfp/nfpcore/nfp_nsp_eth.c
@@ -115,7 +115,7 @@ union eth_table_entry {
struct {
uint64_t port;
uint64_t state;
- uint8_t mac_addr[6];
+ uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
uint8_t resv[2];
uint64_t control;
};
@@ -163,8 +163,8 @@ nfp_eth_copy_mac_reverse(uint8_t *dst, const uint8_t *src)
{
int i;
- for (i = 0; i < (int)ETH_ALEN; i++)
- dst[ETH_ALEN - i - 1] = src[i];
+ for (i = 0; i < RTE_ETHER_ADDR_LEN; i++)
+ dst[RTE_ETHER_ADDR_LEN - i - 1] = src[i];
}
static void
@@ -194,7 +194,7 @@ nfp_eth_port_translate(struct nfp_nsp *nsp, const union eth_table_entry *src,
dst->interface = FIELD_GET(NSP_ETH_STATE_INTERFACE, state);
dst->media = FIELD_GET(NSP_ETH_STATE_MEDIA, state);
- nfp_eth_copy_mac_reverse(dst->mac_addr, src->mac_addr);
+ nfp_eth_copy_mac_reverse(&dst->mac_addr.addr_bytes[0], src->mac_addr);
dst->label_port = FIELD_GET(NSP_ETH_PORT_PHYLABEL, port);
dst->label_subport = FIELD_GET(NSP_ETH_PORT_LABEL, port);
--
2.39.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/8] make the logic conform the coding style of DPDK
2023-05-19 2:59 [PATCH 0/8] make the logic conform the coding style of DPDK Chaoyong He
` (7 preceding siblings ...)
2023-05-19 2:59 ` [PATCH 8/8] net/nfp: revise the logic of MAC address Chaoyong He
@ 2023-05-19 13:55 ` Ferruh Yigit
8 siblings, 0 replies; 10+ messages in thread
From: Ferruh Yigit @ 2023-05-19 13:55 UTC (permalink / raw)
To: Chaoyong He, dev; +Cc: oss-drivers, niklas.soderlund
On 5/19/2023 3:59 AM, Chaoyong He wrote:
> Modify some logic of nfp PMD, to make it conform the coding style
> of DPDK.
>
> Also remove some unnecessary macro and functions which DPDK has
> already provided.
>
> Chaoyong He (8):
> net/nfp: reuse the ring buffer struct
> net/nfp: modify the rxq struct
> net/nfp: modify the Rx descriptor struct
> net/nfp: modify the txq struct
> net/nfp: remove the custom round macro
> net/nfp: remove the unneeded comment
> net/nfp: revise cast from void pointer
> net/nfp: revise the logic of MAC address
Series applied to dpdk-next-net/main, thanks.
^ permalink raw reply [flat|nested] 10+ messages in thread