DPDK patches and discussions
 help / color / mirror / Atom feed
From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com,
	Chaoyong He <chaoyong.he@corigine.com>
Subject: [PATCH 5/8] net/nfp: remove the custom round macro
Date: Fri, 19 May 2023 10:59:47 +0800	[thread overview]
Message-ID: <20230519025950.1642943-6-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20230519025950.1642943-1-chaoyong.he@corigine.com>

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


  parent reply	other threads:[~2023-05-19  3:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` [PATCH 3/8] net/nfp: modify the Rx descriptor struct Chaoyong He
2023-05-19  2:59 ` [PATCH 4/8] net/nfp: modify the txq struct Chaoyong He
2023-05-19  2:59 ` Chaoyong He [this message]
2023-05-19  2:59 ` [PATCH 6/8] net/nfp: remove the unneeded comment Chaoyong He
2023-05-19  2:59 ` [PATCH 7/8] net/nfp: revise cast from void pointer 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

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=20230519025950.1642943-6-chaoyong.he@corigine.com \
    --to=chaoyong.he@corigine.com \
    --cc=dev@dpdk.org \
    --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).