From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com,
James Hershaw <james.hershaw@corigine.com>,
Chaoyong He <chaoyong.he@corigine.com>
Subject: [PATCH 3/3] net/nfp: remove ASSERT() macro
Date: Fri, 3 Feb 2023 15:57:36 +0800 [thread overview]
Message-ID: <20230203075736.18616-4-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20230203075736.18616-1-chaoyong.he@corigine.com>
From: James Hershaw <james.hershaw@corigine.com>
Remove usage of the rte_panic() function from the nfp PMD.
As the ASSERT(x) macro was only used twice in the PMD, it is better
remove it altogether and rework the code where it was used as it
is a very small change to make.
Signed-off-by: James Hershaw <james.hershaw@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
drivers/net/nfp/flower/nfp_flower.c | 8 +++-----
drivers/net/nfp/nfp_logs.h | 2 --
drivers/net/nfp/nfp_rxtx.c | 7 ++-----
3 files changed, 5 insertions(+), 12 deletions(-)
diff --git a/drivers/net/nfp/flower/nfp_flower.c b/drivers/net/nfp/flower/nfp_flower.c
index e0e94e0a36..f1424a010d 100644
--- a/drivers/net/nfp/flower/nfp_flower.c
+++ b/drivers/net/nfp/flower/nfp_flower.c
@@ -491,7 +491,7 @@ nfp_flower_pf_xmit_pkts(void *tx_queue,
struct rte_mbuf **tx_pkts,
uint16_t nb_pkts)
{
- int i = 0;
+ int i;
int pkt_size;
int dma_size;
uint64_t dma_addr;
@@ -522,7 +522,7 @@ nfp_flower_pf_xmit_pkts(void *tx_queue,
issued_descs = 0;
/* Sending packets */
- while ((i < nb_pkts) && free_descs) {
+ for (i = 0; i < nb_pkts && free_descs > 0; i++) {
/* Grabbing the mbuf linked to the current descriptor */
lmbuf = &txq->txbufs[txq->wr_p].mbuf;
/* Warming the cache for releasing the mbuf later on */
@@ -561,7 +561,7 @@ nfp_flower_pf_xmit_pkts(void *tx_queue,
*/
pkt_size = pkt->pkt_len;
- while (pkt != NULL) {
+ while (pkt != NULL && free_descs > 0) {
/* Copying TSO, VLAN and cksum info */
*txds = txd;
@@ -583,7 +583,6 @@ nfp_flower_pf_xmit_pkts(void *tx_queue,
txds->data_len = txd.data_len;
txds->dma_addr_hi = (dma_addr >> 32) & 0xff;
txds->dma_addr_lo = (dma_addr & 0xffffffff);
- ASSERT(free_descs > 0);
free_descs--;
txq->wr_p++;
@@ -607,7 +606,6 @@ nfp_flower_pf_xmit_pkts(void *tx_queue,
lmbuf = &txq->txbufs[txq->wr_p].mbuf;
issued_descs++;
}
- i++;
}
xmit_end:
diff --git a/drivers/net/nfp/nfp_logs.h b/drivers/net/nfp/nfp_logs.h
index 5da384e53f..b7632ee72c 100644
--- a/drivers/net/nfp/nfp_logs.h
+++ b/drivers/net/nfp/nfp_logs.h
@@ -24,10 +24,8 @@ extern int nfp_logtype_init;
#ifdef RTE_ETHDEV_DEBUG_TX
#define PMD_TX_LOG(level, fmt, args...) \
RTE_LOG(level, PMD, "%s() tx: " fmt "\n", __func__, ## args)
-#define ASSERT(x) if (!(x)) rte_panic("NFP_NET: x")
#else
#define PMD_TX_LOG(level, fmt, args...) do { } while (0)
-#define ASSERT(x) do { } while (0)
#endif
extern int nfp_logtype_cpp;
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index 5f23128ac9..a5907cc428 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -968,12 +968,11 @@ nfp_net_nfd3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pk
pkt = *tx_pkts;
- i = 0;
issued_descs = 0;
PMD_TX_LOG(DEBUG, "queue: %u. Sending %u packets",
txq->qidx, nb_pkts);
/* Sending packets */
- while ((i < nb_pkts) && free_descs) {
+ for (i = 0; i < nb_pkts && free_descs > 0; i++) {
memset(&meta_data, 0, sizeof(meta_data));
/* Grabbing the mbuf linked to the current descriptor */
lmbuf = &txq->txbufs[txq->wr_p].mbuf;
@@ -1010,7 +1009,7 @@ nfp_net_nfd3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pk
*/
pkt_size = pkt->pkt_len;
- while (pkt) {
+ while (pkt != NULL && free_descs > 0) {
/* Copying TSO, VLAN and cksum info */
*txds = txd;
@@ -1034,7 +1033,6 @@ nfp_net_nfd3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pk
txds->data_len = txd.data_len;
txds->dma_addr_hi = (dma_addr >> 32) & 0xff;
txds->dma_addr_lo = (dma_addr & 0xffffffff);
- ASSERT(free_descs > 0);
free_descs--;
txq->wr_p++;
@@ -1061,7 +1059,6 @@ nfp_net_nfd3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pk
lmbuf = &txq->txbufs[txq->wr_p].mbuf;
issued_descs++;
}
- i++;
}
xmit_end:
--
2.29.3
next prev parent reply other threads:[~2023-02-03 7:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-03 7:57 [PATCH 0/3] remove usage of rte_panic() and ASSERT() from PMD Chaoyong He
2023-02-03 7:57 ` [PATCH 1/3] net/nfp: remove panic usage during reconfig Chaoyong He
2023-02-03 7:57 ` [PATCH 2/3] net/nfp: remove panic usage for multisegment Tx Chaoyong He
2023-02-03 7:57 ` Chaoyong He [this message]
2023-02-03 18:57 ` [PATCH 0/3] remove usage of rte_panic() and ASSERT() from PMD Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230203075736.18616-4-chaoyong.he@corigine.com \
--to=chaoyong.he@corigine.com \
--cc=dev@dpdk.org \
--cc=james.hershaw@corigine.com \
--cc=niklas.soderlund@corigine.com \
--cc=oss-drivers@corigine.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).