DPDK patches and discussions
 help / color / mirror / Atom feed
From: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
To: dev@dpdk.org
Cc: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Subject: [dpdk-dev] [PATCH v2 3/6] net/mlx5: reduce Tx and Rx structure size
Date: Wed, 14 Sep 2016 14:18:04 +0200	[thread overview]
Message-ID: <99a0037387eda2a6b57351c695269c61a80470f8.1473854800.git.nelio.laranjeiro@6wind.com> (raw)
In-Reply-To: <cover.1473854800.git.nelio.laranjeiro@6wind.com>
In-Reply-To: <cover.1473854800.git.nelio.laranjeiro@6wind.com>

PMD uses only power of two number of Completion Queue Elements, storing the
number of elements in log2 helps to reduce the size of the container to
store it.

Signed-off-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
---
 drivers/net/mlx5/mlx5_rxq.c  | 2 +-
 drivers/net/mlx5/mlx5_rxtx.c | 8 ++++----
 drivers/net/mlx5/mlx5_rxtx.h | 4 ++--
 drivers/net/mlx5/mlx5_txq.c  | 2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index d9db368..f6f4315 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -881,7 +881,7 @@ rxq_setup(struct rxq_ctrl *tmpl)
 	if (elts == NULL)
 		return ENOMEM;
 	tmpl->rxq.rq_db = rwq->rq.db;
-	tmpl->rxq.cqe_n = ibcq->cqe + 1;
+	tmpl->rxq.cqe_n = log2above(ibcq->cqe);
 	tmpl->rxq.cq_ci = 0;
 	tmpl->rxq.rq_ci = 0;
 	tmpl->rxq.cq_db = cq->dbrec;
diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c
index e132727..4f28aa9 100644
--- a/drivers/net/mlx5/mlx5_rxtx.c
+++ b/drivers/net/mlx5/mlx5_rxtx.c
@@ -166,8 +166,8 @@ txq_complete(struct txq *txq) __attribute__((always_inline));
 static inline void
 txq_complete(struct txq *txq)
 {
-	const unsigned int cqe_n = txq->cqe_n;
 	const unsigned int elts_n = 1 << txq->elts_n;
+	const unsigned int cqe_n = 1 << txq->cqe_n;
 	const unsigned int cqe_cnt = cqe_n - 1;
 	uint16_t elts_free = txq->elts_tail;
 	uint16_t elts_tail;
@@ -427,9 +427,9 @@ mlx5_tx_dbrec(struct txq *txq)
 static inline void
 tx_prefetch_cqe(struct txq *txq, uint16_t ci)
 {
-	volatile struct mlx5_cqe64 *cqe;
+	volatile struct mlx5_cqe *cqe;
 
-	cqe = &(*txq->cqes)[ci & (txq->cqe_n - 1)].cqe64;
+	cqe = &(*txq->cqes)[ci & ((1 << txq->cqe_n) - 1)];
 	rte_prefetch0(cqe);
 }
 
@@ -1272,8 +1272,8 @@ uint16_t
 mlx5_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, uint16_t pkts_n)
 {
 	struct rxq *rxq = dpdk_rxq;
-	const unsigned int cqe_cnt = rxq->cqe_n - 1;
 	const unsigned int wqe_cnt = (1 << rxq->elts_n) - 1;
+	const unsigned int cqe_cnt = (1 << rxq->cqe_n) - 1;
 	const unsigned int sges_n = rxq->sges_n;
 	struct rte_mbuf *pkt = NULL;
 	struct rte_mbuf *seg = NULL;
diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h
index 3ba3913..224614e 100644
--- a/drivers/net/mlx5/mlx5_rxtx.h
+++ b/drivers/net/mlx5/mlx5_rxtx.h
@@ -110,13 +110,13 @@ struct rxq {
 	unsigned int vlan_strip:1; /* Enable VLAN stripping. */
 	unsigned int crc_present:1; /* CRC must be subtracted. */
 	unsigned int sges_n:2; /* Log 2 of SGEs (max buffers per packet). */
+	unsigned int cqe_n:4; /* Log 2 of CQ elements. */
 	unsigned int elts_n:4; /* Log 2 of Mbufs. */
 	unsigned int port_id:8;
 	volatile uint32_t *rq_db;
 	volatile uint32_t *cq_db;
 	uint16_t rq_ci;
 	uint16_t cq_ci;
-	uint16_t cqe_n; /* Number of CQ elements. */
 	volatile struct mlx5_wqe_data_seg(*wqes)[];
 	volatile struct mlx5_cqe(*cqes)[];
 	struct rxq_zip zip; /* Compressed context. */
@@ -245,10 +245,10 @@ struct txq {
 	uint16_t elts_tail; /* First element awaiting completion. */
 	uint16_t elts_comp; /* Counter since last completion request. */
 	uint16_t cq_ci; /* Consumer index for completion queue. */
-	uint16_t cqe_n; /* Number of CQ elements. */
 	uint16_t wqe_ci; /* Consumer index for work queue. */
 	uint16_t wqe_n; /* Number of WQ elements. */
 	uint16_t elts_n:4; /* (*elts)[] length (in log2). */
+	uint16_t cqe_n:4; /* Number of CQ elements (in log2). */
 	uint16_t bf_offset; /* Blueflame offset. */
 	uint16_t bf_buf_size; /* Blueflame size. */
 	uint16_t max_inline; /* Multiple of RTE_CACHE_LINE_SIZE to inline. */
diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c
index 9055016..6145b69 100644
--- a/drivers/net/mlx5/mlx5_txq.c
+++ b/drivers/net/mlx5/mlx5_txq.c
@@ -212,7 +212,7 @@ txq_setup(struct txq_ctrl *tmpl, struct txq_ctrl *txq_ctrl)
 		      "it should be set to %u", RTE_CACHE_LINE_SIZE);
 		return EINVAL;
 	}
-	tmpl->txq.cqe_n = ibcq->cqe + 1;
+	tmpl->txq.cqe_n = log2above(ibcq->cqe);
 	tmpl->txq.qp_num_8s = qp->ctrl_seg.qp_num << 8;
 	tmpl->txq.wqes =
 		(volatile struct mlx5_wqe64 (*)[])
-- 
2.1.4

  parent reply	other threads:[~2016-09-14 12:18 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-07  7:09 [dpdk-dev] [PATCH 0/6] net/mlx5: performance improvement Nelio Laranjeiro
2016-09-07  7:09 ` [dpdk-dev] [PATCH 1/6] net/mlx5: rework hardware structures Nelio Laranjeiro
2016-09-07  7:09 ` [dpdk-dev] [PATCH 2/6] net/mlx5: reduce Tx and Rx structure size Nelio Laranjeiro
2016-09-07  7:09 ` [dpdk-dev] [PATCH 3/6] " Nelio Laranjeiro
2016-09-07  7:09 ` [dpdk-dev] [PATCH 4/6] net/mlx5: reduce Tx " Nelio Laranjeiro
2016-09-07  7:09 ` [dpdk-dev] [PATCH 5/6] net/mlx5: reduce Tx and Rx " Nelio Laranjeiro
2016-09-07  7:09 ` [dpdk-dev] [PATCH 6/6] net/mlx5: remove gather loop on segments Nelio Laranjeiro
2016-09-14 12:18 ` [dpdk-dev] [PATCH v2 0/6] net/mlx5: performance improvement Nelio Laranjeiro
2016-09-19 16:17   ` Bruce Richardson
2016-09-20  7:25     ` Nélio Laranjeiro
2016-09-20  8:53   ` [dpdk-dev] [PATCH v3 " Nelio Laranjeiro
2016-09-20  8:53     ` [dpdk-dev] [PATCH v3 1/6] net/mlx5: rework hardware structures Nelio Laranjeiro
2016-09-20  8:53     ` [dpdk-dev] [PATCH v3 2/6] net/mlx5: reduce memory overhead of Rx/Tx descriptors Nelio Laranjeiro
2016-09-20  8:53     ` [dpdk-dev] [PATCH v3 3/6] net/mlx5: reduce memory overhead for CQE handling Nelio Laranjeiro
2016-09-20  8:53     ` [dpdk-dev] [PATCH v3 4/6] net/mlx5: reduce memory overhead for BF handling Nelio Laranjeiro
2016-09-20  8:53     ` [dpdk-dev] [PATCH v3 5/6] net/mlx5: reduce memory overhead for WQE handling Nelio Laranjeiro
2016-09-20  8:53     ` [dpdk-dev] [PATCH v3 6/6] net/mlx5: remove gather loop on segments Nelio Laranjeiro
2016-09-21 10:22     ` [dpdk-dev] [PATCH v3 0/6] net/mlx5: performance improvement Bruce Richardson
2016-09-14 12:18 ` [dpdk-dev] [PATCH v2 1/6] net/mlx5: rework hardware structures Nelio Laranjeiro
2016-09-19 16:14   ` Bruce Richardson
2016-09-20  7:09     ` Nélio Laranjeiro
2016-09-14 12:18 ` [dpdk-dev] [PATCH v2 2/6] net/mlx5: reduce Tx and Rx structure size Nelio Laranjeiro
2016-09-14 12:18 ` Nelio Laranjeiro [this message]
2016-09-14 12:18 ` [dpdk-dev] [PATCH v2 4/6] net/mlx5: reduce Tx " Nelio Laranjeiro
2016-09-14 12:18 ` [dpdk-dev] [PATCH v2 5/6] net/mlx5: reduce Tx and Rx " Nelio Laranjeiro
2016-09-14 12:18 ` [dpdk-dev] [PATCH v2 6/6] net/mlx5: remove gather loop on segments Nelio Laranjeiro

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=99a0037387eda2a6b57351c695269c61a80470f8.1473854800.git.nelio.laranjeiro@6wind.com \
    --to=nelio.laranjeiro@6wind.com \
    --cc=adrien.mazarguil@6wind.com \
    --cc=dev@dpdk.org \
    /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).