DPDK patches and discussions
 help / color / mirror / Atom feed
From: Tomasz Duszynski <tdu@semihalf.com>
To: dev@dpdk.org
Cc: jck@semihalf.com, mw@semihalf.com, dima@marvell.com,
	nsamsono@marvell.com, Jianbo.liu@arm.com
Subject: [dpdk-dev] [PATCH 3/5] net/mrvl: fix oversize bpool handling
Date: Thu, 11 Jan 2018 16:35:41 +0100	[thread overview]
Message-ID: <1515684943-32506-4-git-send-email-tdu@semihalf.com> (raw)
In-Reply-To: <1515684943-32506-1-git-send-email-tdu@semihalf.com>

From: Natalie Samsonov <nsamsono@marvell.com>

Don't return mbuf to dpdk pool if failed to get buffer from the bpool.
Fix maximum bpool size calculation to prevent unnecessary bpool
oversize cases when working with small rx queues.

Fixes: 0ddc9b8 ("net/mrvl: add net PMD skeleton")

Signed-off-by: Natalie Samsonov <nsamsono@marvell.com>
---
 drivers/net/mrvl/mrvl_ethdev.c | 41 ++++++++++++++++++++++++++++++-----------
 1 file changed, 30 insertions(+), 11 deletions(-)

diff --git a/drivers/net/mrvl/mrvl_ethdev.c b/drivers/net/mrvl/mrvl_ethdev.c
index 5c3b700..e650bf8 100644
--- a/drivers/net/mrvl/mrvl_ethdev.c
+++ b/drivers/net/mrvl/mrvl_ethdev.c
@@ -165,6 +165,8 @@ static int mrvl_lcore_first;
 static int mrvl_lcore_last;
 static int mrvl_dev_num;

+static int mrvl_fill_bpool(struct mrvl_rxq *rxq, int num);
+
 static inline int
 mrvl_get_bpool_size(int pp2_id, int pool_id)
 {
@@ -461,20 +463,13 @@ mrvl_dev_start(struct rte_eth_dev *dev)
 {
 	struct mrvl_priv *priv = dev->data->dev_private;
 	char match[MRVL_MATCH_LEN];
-	int ret;
+	int ret = 0, def_init_size;

 	snprintf(match, sizeof(match), "ppio-%d:%d",
 		 priv->pp_id, priv->ppio_id);
 	priv->ppio_params.match = match;

 	/*
-	 * Calculate the maximum bpool size for refill feature to 1.5 of the
-	 * configured size. In case the bpool size will exceed this value,
-	 * superfluous buffers will be removed
-	 */
-	priv->bpool_max_size = priv->bpool_init_size +
-			      (priv->bpool_init_size >> 1);
-	/*
 	 * Calculate the minimum bpool size for refill feature as follows:
 	 * 2 default burst sizes multiply by number of rx queues.
 	 * If the bpool size will be below this value, new buffers will
@@ -482,6 +477,29 @@ mrvl_dev_start(struct rte_eth_dev *dev)
 	 */
 	priv->bpool_min_size = priv->nb_rx_queues * MRVL_BURST_SIZE * 2;

+	/* In case initial bpool size configured in queues setup is
+	 * smaller than minimum size add more buffers
+	 */
+	def_init_size = priv->bpool_min_size + MRVL_BURST_SIZE * 2;
+	if (priv->bpool_init_size < def_init_size) {
+		int buffs_to_add = def_init_size - priv->bpool_init_size;
+
+		priv->bpool_init_size += buffs_to_add;
+		ret = mrvl_fill_bpool(dev->data->rx_queues[0], buffs_to_add);
+		if (ret)
+			RTE_LOG(ERR, PMD, "Failed to add buffers to bpool\n");
+	}
+
+	/*
+	 * Calculate the maximum bpool size for refill feature as follows:
+	 * maximum number of descriptors in rx queue multiply by number
+	 * of rx queues plus minimum bpool size.
+	 * In case the bpool size will exceed this value, superfluous buffers
+	 * will be removed
+	 */
+	priv->bpool_max_size = (priv->nb_rx_queues * MRVL_PP2_RXD_MAX) +
+				priv->bpool_min_size;
+
 	ret = pp2_ppio_init(&priv->ppio_params, &priv->ppio);
 	if (ret) {
 		RTE_LOG(ERR, PMD, "Failed to init ppio\n");
@@ -1769,14 +1787,15 @@ mrvl_rx_pkt_burst(void *rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 				q->priv->bpool_init_size);

 			for (i = 0; i < pkt_to_remove; i++) {
-				pp2_bpool_get_buff(hif, bpool, &buff);
+				ret = pp2_bpool_get_buff(hif, bpool, &buff);
+				if (ret)
+					break;
 				mbuf = (struct rte_mbuf *)
 					(cookie_addr_high | buff.cookie);
 				rte_pktmbuf_free(mbuf);
 			}
 			mrvl_port_bpool_size
-				[bpool->pp2_id][bpool->id][core_id] -=
-								pkt_to_remove;
+				[bpool->pp2_id][bpool->id][core_id] -= i;
 		}
 		rte_spinlock_unlock(&q->priv->lock);
 	}
--
2.7.4

  parent reply	other threads:[~2018-01-11 15:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-11 15:35 [dpdk-dev] [PATCH 0/5] net/mrvl: fix recently found pmd issues Tomasz Duszynski
2018-01-11 15:35 ` [dpdk-dev] [PATCH 1/5] net/mrvl: fix multiple probe issue Tomasz Duszynski
2018-01-11 15:35 ` [dpdk-dev] [PATCH 2/5] net/mrvl: fix hif objects allocation Tomasz Duszynski
2018-01-12 19:13   ` Ferruh Yigit
2018-01-15  6:53     ` Tomasz Duszynski
2018-01-11 15:35 ` Tomasz Duszynski [this message]
2018-01-11 15:35 ` [dpdk-dev] [PATCH 4/5] net/mrvl: fix shadow queue tail and size calculations Tomasz Duszynski
2018-01-11 15:35 ` [dpdk-dev] [PATCH 5/5] net/mrvl: keep shadow txqs inside pmd txq Tomasz Duszynski
2018-01-12 19:13 ` [dpdk-dev] [PATCH 0/5] net/mrvl: fix recently found pmd issues Ferruh Yigit
2018-01-15  7:35   ` Tomasz Duszynski

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=1515684943-32506-4-git-send-email-tdu@semihalf.com \
    --to=tdu@semihalf.com \
    --cc=Jianbo.liu@arm.com \
    --cc=dev@dpdk.org \
    --cc=dima@marvell.com \
    --cc=jck@semihalf.com \
    --cc=mw@semihalf.com \
    --cc=nsamsono@marvell.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).