DPDK patches and discussions
 help / color / mirror / Atom feed
From: Andrew Rybchenko <arybchenko@solarflare.com>
To: <dev@dpdk.org>
Subject: [dpdk-dev] [PATCH 12/13] net/sfc: support changing the number of transmit queues
Date: Fri, 31 Mar 2017 11:22:22 +0100	[thread overview]
Message-ID: <1490955743-9868-13-git-send-email-arybchenko@solarflare.com> (raw)
In-Reply-To: <1490955743-9868-1-git-send-email-arybchenko@solarflare.com>

Fixes: a8ad8cf83f01 ("net/sfc: provide basic stubs for Tx subsystem")

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@solarflare.com>
---
 drivers/net/sfc/sfc_tx.c | 79 +++++++++++++++++++++++++++++++++++-------------
 1 file changed, 58 insertions(+), 21 deletions(-)

diff --git a/drivers/net/sfc/sfc_tx.c b/drivers/net/sfc/sfc_tx.c
index 1605eaa..b8581d1 100644
--- a/drivers/net/sfc/sfc_tx.c
+++ b/drivers/net/sfc/sfc_tx.c
@@ -289,14 +289,37 @@ sfc_tx_check_mode(struct sfc_adapter *sa, const struct rte_eth_txmode *txmode)
 	return rc;
 }
 
+/**
+ * Destroy excess queues that are no longer needed after reconfiguration
+ * or complete close.
+ */
+static void
+sfc_tx_fini_queues(struct sfc_adapter *sa, unsigned int nb_tx_queues)
+{
+	int sw_index;
+
+	SFC_ASSERT(nb_tx_queues <= sa->txq_count);
+
+	sw_index = sa->txq_count;
+	while (--sw_index >= (int)nb_tx_queues) {
+		if (sa->txq_info[sw_index].txq != NULL)
+			sfc_tx_qfini(sa, sw_index);
+	}
+
+	sa->txq_count = nb_tx_queues;
+}
+
 int
 sfc_tx_configure(struct sfc_adapter *sa)
 {
 	const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
 	const struct rte_eth_conf *dev_conf = &sa->eth_dev->data->dev_conf;
-	unsigned int sw_index;
+	const unsigned int nb_tx_queues = sa->eth_dev->data->nb_tx_queues;
 	int rc = 0;
 
+	sfc_log_init(sa, "nb_tx_queues=%u (old %u)",
+		     nb_tx_queues, sa->txq_count);
+
 	/*
 	 * The datapath implementation assumes absence of boundary
 	 * limits on Tx DMA descriptors. Addition of these checks on
@@ -311,28 +334,49 @@ sfc_tx_configure(struct sfc_adapter *sa)
 	if (rc != 0)
 		goto fail_check_mode;
 
-	sa->txq_count = sa->eth_dev->data->nb_tx_queues;
+	if (nb_tx_queues == sa->txq_count)
+		goto done;
 
-	sa->txq_info = rte_calloc_socket("sfc-txqs", sa->txq_count,
-					 sizeof(sa->txq_info[0]), 0,
-					 sa->socket_id);
-	if (sa->txq_info == NULL)
-		goto fail_txqs_alloc;
+	if (sa->txq_info == NULL) {
+		sa->txq_info = rte_calloc_socket("sfc-txqs", nb_tx_queues,
+						 sizeof(sa->txq_info[0]), 0,
+						 sa->socket_id);
+		if (sa->txq_info == NULL)
+			goto fail_txqs_alloc;
+	} else {
+		struct sfc_txq_info *new_txq_info;
+
+		if (nb_tx_queues < sa->txq_count)
+			sfc_tx_fini_queues(sa, nb_tx_queues);
+
+		new_txq_info =
+			rte_realloc(sa->txq_info,
+				    nb_tx_queues * sizeof(sa->txq_info[0]), 0);
+		if (new_txq_info == NULL && nb_tx_queues > 0)
+			goto fail_txqs_realloc;
+
+		sa->txq_info = new_txq_info;
+		if (nb_tx_queues > sa->txq_count)
+			memset(&sa->txq_info[sa->txq_count], 0,
+			       (nb_tx_queues - sa->txq_count) *
+			       sizeof(sa->txq_info[0]));
+	}
 
-	for (sw_index = 0; sw_index < sa->txq_count; ++sw_index) {
-		rc = sfc_tx_qinit_info(sa, sw_index);
+	while (sa->txq_count < nb_tx_queues) {
+		rc = sfc_tx_qinit_info(sa, sa->txq_count);
 		if (rc != 0)
 			goto fail_tx_qinit_info;
+
+		sa->txq_count++;
 	}
 
+done:
 	return 0;
 
 fail_tx_qinit_info:
-	rte_free(sa->txq_info);
-	sa->txq_info = NULL;
-
+fail_txqs_realloc:
 fail_txqs_alloc:
-	sa->txq_count = 0;
+	sfc_tx_close(sa);
 
 fail_check_mode:
 fail_tx_dma_desc_boundary:
@@ -343,17 +387,10 @@ sfc_tx_configure(struct sfc_adapter *sa)
 void
 sfc_tx_close(struct sfc_adapter *sa)
 {
-	int sw_index;
-
-	sw_index = sa->txq_count;
-	while (--sw_index >= 0) {
-		if (sa->txq_info[sw_index].txq != NULL)
-			sfc_tx_qfini(sa, sw_index);
-	}
+	sfc_tx_fini_queues(sa, 0);
 
 	rte_free(sa->txq_info);
 	sa->txq_info = NULL;
-	sa->txq_count = 0;
 }
 
 int
-- 
2.9.3

  parent reply	other threads:[~2017-03-31 10:22 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-31 10:22 [dpdk-dev] [PATCH 00/13] net/sfc: fix device reconfigure Andrew Rybchenko
2017-03-31 10:22 ` [dpdk-dev] [PATCH 01/13] net/sfc: clarify interrupts support function names Andrew Rybchenko
2017-03-31 10:22 ` [dpdk-dev] [PATCH 02/13] net/sfc: bind EvQ DMA space to EvQ type and type-local index Andrew Rybchenko
2017-03-31 10:22 ` [dpdk-dev] [PATCH 03/13] net/sfc: remove unused max entries from EvQ info Andrew Rybchenko
2017-03-31 10:22 ` [dpdk-dev] [PATCH 04/13] net/sfc: move EvQ entries to the EvQ control structure Andrew Rybchenko
2017-03-31 10:22 ` [dpdk-dev] [PATCH 05/13] net/sfc: remove flags from EvQ info Andrew Rybchenko
2017-03-31 10:22 ` [dpdk-dev] [PATCH 06/13] net/sfc: remove EvQ info array to simplify reconfigure Andrew Rybchenko
2017-03-31 10:22 ` [dpdk-dev] [PATCH 07/13] net/sfc: move event support init to attach stage Andrew Rybchenko
2017-03-31 10:22 ` [dpdk-dev] [PATCH 08/13] net/sfc: initialize port data on attach Andrew Rybchenko
2017-03-31 10:22 ` [dpdk-dev] [PATCH 09/13] net/sfc: clarify Rx subsystem configure/close function names Andrew Rybchenko
2017-03-31 10:22 ` [dpdk-dev] [PATCH 10/13] net/sfc: clarify Tx " Andrew Rybchenko
2017-03-31 10:22 ` [dpdk-dev] [PATCH 11/13] net/sfc: support changing the number of receive queues Andrew Rybchenko
2017-03-31 10:22 ` Andrew Rybchenko [this message]
2017-03-31 10:22 ` [dpdk-dev] [PATCH 13/13] net/sfc: fix device reconfigure Andrew Rybchenko
2017-03-31 15:31 ` [dpdk-dev] [PATCH 00/13] " 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=1490955743-9868-13-git-send-email-arybchenko@solarflare.com \
    --to=arybchenko@solarflare.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).