patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Kevin Traynor <ktraynor@redhat.com>
To: Long Li <longli@microsoft.com>
Cc: dpdk stable <stable@dpdk.org>
Subject: patch 'net/netvsc: fix hot adding multiple VF PCI devices' has been queued to stable release 21.11.2
Date: Wed, 25 May 2022 17:27:54 +0100	[thread overview]
Message-ID: <20220525162847.711753-2-ktraynor@redhat.com> (raw)
In-Reply-To: <20220525162847.711753-1-ktraynor@redhat.com>

Hi,

FYI, your patch has been queued to stable release 21.11.2

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 05/30/22. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/kevintraynor/dpdk-stable

This queued commit can be viewed at:
https://github.com/kevintraynor/dpdk-stable/commit/8ab93b06bcf03b86b7d1c021350736568e85e690

Thanks.

Kevin

---
From 8ab93b06bcf03b86b7d1c021350736568e85e690 Mon Sep 17 00:00:00 2001
From: Long Li <longli@microsoft.com>
Date: Thu, 24 Mar 2022 10:46:17 -0700
Subject: [PATCH] net/netvsc: fix hot adding multiple VF PCI devices

[ upstream commit 7fc4c0997b046e2874a9806431b3d267bb684b41 ]

This patch fixes two issues with hot removing/adding a VF PCI device:
1. The original device argument is lost when it's hot added
2. If there are multiple VFs hot adding at the same time, some of the
   VFs may not get added successfully because only one single VF status
   is stored in the netvsc.

Fix these by storing the original device arguments and maintain a list
of hot add contexts to deal with multiple VF devices.

Fixes: a2a23a794b ("net/netvsc: support VF device hot add/remove")

Signed-off-by: Long Li <longli@microsoft.com>
---
 drivers/net/netvsc/hn_ethdev.c | 78 +++++++++++++++++++++++++++-------
 drivers/net/netvsc/hn_var.h    | 12 +++++-
 drivers/net/netvsc/hn_vf.c     |  4 ++
 3 files changed, 77 insertions(+), 17 deletions(-)

diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c
index 8a950403ac..0a357d3645 100644
--- a/drivers/net/netvsc/hn_ethdev.c
+++ b/drivers/net/netvsc/hn_ethdev.c
@@ -555,7 +555,8 @@ static void netvsc_hotplug_retry(void *args)
 {
 	int ret;
-	struct hn_data *hv = args;
+	struct hv_hotadd_context *hot_ctx = args;
+	struct hn_data *hv = hot_ctx->hv;
 	struct rte_eth_dev *dev = &rte_eth_devices[hv->port_id];
-	struct rte_devargs *d = &hv->devargs;
+	struct rte_devargs *d = &hot_ctx->da;
 	char buf[256];
 
@@ -567,8 +568,11 @@ static void netvsc_hotplug_retry(void *args)
 
 	PMD_DRV_LOG(DEBUG, "%s: retry count %d",
-		    __func__, hv->eal_hot_plug_retry);
+		    __func__, hot_ctx->eal_hot_plug_retry);
 
-	if (hv->eal_hot_plug_retry++ > NETVSC_MAX_HOTADD_RETRY)
-		return;
+	if (hot_ctx->eal_hot_plug_retry++ > NETVSC_MAX_HOTADD_RETRY) {
+		PMD_DRV_LOG(NOTICE, "Failed to parse PCI device retry=%d",
+			    hot_ctx->eal_hot_plug_retry);
+		goto free_hotadd_ctx;
+	}
 
 	snprintf(buf, sizeof(buf), "/sys/bus/pci/devices/%s/net", d->name);
@@ -603,5 +607,5 @@ static void netvsc_hotplug_retry(void *args)
 		if (req.ifr_hwaddr.sa_family != ARPHRD_ETHER) {
 			closedir(di);
-			return;
+			goto free_hotadd_ctx;
 		}
 		memcpy(eth_addr.addr_bytes, req.ifr_hwaddr.sa_data,
@@ -612,6 +616,11 @@ static void netvsc_hotplug_retry(void *args)
 				    "Found matching MAC address, adding device %s network name %s",
 				    d->name, dir->d_name);
+
+			/* If this device has been hot removed from this
+			 * parent device, restore its args.
+			 */
 			ret = rte_eal_hotplug_add(d->bus->name, d->name,
-						  d->args);
+						  hv->vf_devargs ?
+						  hv->vf_devargs : "");
 			if (ret) {
 				PMD_DRV_LOG(ERR,
@@ -625,10 +634,18 @@ static void netvsc_hotplug_retry(void *args)
 		 */
 		closedir(di);
-		return;
+		goto free_hotadd_ctx;
 	}
 	closedir(di);
 retry:
 	/* The device is still being initialized, retry after 1 second */
-	rte_eal_alarm_set(1000000, netvsc_hotplug_retry, hv);
+	rte_eal_alarm_set(1000000, netvsc_hotplug_retry, hot_ctx);
+	return;
+
+free_hotadd_ctx:
+	rte_spinlock_lock(&hv->hotadd_lock);
+	LIST_REMOVE(hot_ctx, list);
+	rte_spinlock_unlock(&hv->hotadd_lock);
+
+	rte_free(hot_ctx);
 }
 
@@ -638,5 +655,6 @@ netvsc_hotadd_callback(const char *device_name, enum rte_dev_event_type type,
 {
 	struct hn_data *hv = arg;
-	struct rte_devargs *d = &hv->devargs;
+	struct hv_hotadd_context *hot_ctx;
+	struct rte_devargs *d;
 	int ret;
 
@@ -650,9 +668,20 @@ netvsc_hotadd_callback(const char *device_name, enum rte_dev_event_type type,
 			break;
 
+		hot_ctx = rte_zmalloc("NETVSC-HOTADD", sizeof(*hot_ctx),
+				      rte_mem_page_size());
+
+		if (!hot_ctx) {
+			PMD_DRV_LOG(ERR, "Failed to allocate hotadd context");
+			return;
+		}
+
+		hot_ctx->hv = hv;
+		d = &hot_ctx->da;
+
 		ret = rte_devargs_parse(d, device_name);
 		if (ret) {
 			PMD_DRV_LOG(ERR,
 				    "devargs parsing failed ret=%d", ret);
-			return;
+			goto free_ctx;
 		}
 
@@ -661,6 +690,9 @@ netvsc_hotadd_callback(const char *device_name, enum rte_dev_event_type type,
 			 * PCI device is a VF device
 			 */
-			hv->eal_hot_plug_retry = 0;
-			rte_eal_alarm_set(1000000, netvsc_hotplug_retry, hv);
+			rte_spinlock_lock(&hv->hotadd_lock);
+			LIST_INSERT_HEAD(&hv->hotadd_list, hot_ctx, list);
+			rte_spinlock_unlock(&hv->hotadd_lock);
+			rte_eal_alarm_set(1000000, netvsc_hotplug_retry, hot_ctx);
+			return;
 		}
 
@@ -668,6 +700,8 @@ netvsc_hotadd_callback(const char *device_name, enum rte_dev_event_type type,
 		 * sent from VSP
 		 */
-
+free_ctx:
+		rte_free(hot_ctx);
 		break;
+
 	default:
 		break;
@@ -1004,4 +1038,5 @@ hn_dev_close(struct rte_eth_dev *dev)
 	int ret;
 	struct hn_data *hv = dev->data->dev_private;
+	struct hv_hotadd_context *hot_ctx;
 
 	PMD_INIT_FUNC_TRACE();
@@ -1009,5 +1044,12 @@ hn_dev_close(struct rte_eth_dev *dev)
 		return 0;
 
-	rte_eal_alarm_cancel(netvsc_hotplug_retry, &hv->devargs);
+	rte_spinlock_lock(&hv->hotadd_lock);
+	while (!LIST_EMPTY(&hv->hotadd_list)) {
+		hot_ctx = LIST_FIRST(&hv->hotadd_list);
+		rte_eal_alarm_cancel(netvsc_hotplug_retry, hot_ctx);
+		LIST_REMOVE(hot_ctx, list);
+		rte_free(hot_ctx);
+	}
+	rte_spinlock_unlock(&hv->hotadd_lock);
 
 	ret = hn_vf_close(dev);
@@ -1098,4 +1140,7 @@ eth_hn_dev_init(struct rte_eth_dev *eth_dev)
 	PMD_INIT_FUNC_TRACE();
 
+	rte_spinlock_init(&hv->hotadd_lock);
+	LIST_INIT(&hv->hotadd_list);
+
 	vmbus = container_of(device, struct rte_vmbus_device, device);
 	eth_dev->dev_ops = &hn_eth_dev_ops;
@@ -1222,4 +1267,7 @@ eth_hn_dev_uninit(struct rte_eth_dev *eth_dev)
 	hn_dev_close(eth_dev);
 
+	free(hv->vf_devargs);
+	hv->vf_devargs = NULL;
+
 	hn_detach(hv);
 	hn_chim_uninit(eth_dev);
diff --git a/drivers/net/netvsc/hn_var.h b/drivers/net/netvsc/hn_var.h
index fbb3995507..416c042a27 100644
--- a/drivers/net/netvsc/hn_var.h
+++ b/drivers/net/netvsc/hn_var.h
@@ -127,4 +127,11 @@ struct hn_vf_ctx {
 };
 
+struct hv_hotadd_context {
+	LIST_ENTRY(hv_hotadd_context) list;
+	struct hn_data *hv;
+	struct rte_devargs da;
+	int eal_hot_plug_retry;
+};
+
 struct hn_data {
 	struct rte_vmbus_device *vmbus;
@@ -176,6 +183,7 @@ struct hn_data {
 	struct vmbus_channel *channels[HN_MAX_CHANNELS];
 
-	struct rte_devargs devargs;
-	int		eal_hot_plug_retry;
+	rte_spinlock_t	hotadd_lock;
+	LIST_HEAD(hotadd_list, hv_hotadd_context) hotadd_list;
+	char		*vf_devargs;
 };
 
diff --git a/drivers/net/netvsc/hn_vf.c b/drivers/net/netvsc/hn_vf.c
index ebb9c60147..62948bf889 100644
--- a/drivers/net/netvsc/hn_vf.c
+++ b/drivers/net/netvsc/hn_vf.c
@@ -130,4 +130,8 @@ static void hn_remove_delayed(void *args)
 			    port_id, ret);
 
+	/* Record the device parameters for possible hotplug events */
+	if (dev->devargs && dev->devargs->args)
+		hv->vf_devargs = strdup(dev->devargs->args);
+
 	ret = rte_eth_dev_close(port_id);
 	if (ret)
-- 
2.34.3

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2022-05-25 17:26:58.703712477 +0100
+++ 0002-net-netvsc-fix-hot-adding-multiple-VF-PCI-devices.patch	2022-05-25 17:26:58.529828276 +0100
@@ -1 +1 @@
-From 7fc4c0997b046e2874a9806431b3d267bb684b41 Mon Sep 17 00:00:00 2001
+From 8ab93b06bcf03b86b7d1c021350736568e85e690 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 7fc4c0997b046e2874a9806431b3d267bb684b41 ]
+
@@ -16 +17,0 @@
-Cc: stable@dpdk.org


  reply	other threads:[~2022-05-25 16:29 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-25 16:27 patch 'test/mem: disable ASan when accessing unallocated memory' " Kevin Traynor
2022-05-25 16:27 ` Kevin Traynor [this message]
2022-05-25 16:27 ` patch 'net/nfp: remove unneeded header inclusion' " Kevin Traynor
2022-05-25 16:27 ` patch 'net/bonding: fix RSS key config with extended key length' " Kevin Traynor
2022-05-25 16:27 ` patch 'net/cxgbe: fix port ID in Rx mbuf' " Kevin Traynor
2022-05-25 16:27 ` patch 'net/cxgbe: fix Tx queue stuck with mbuf chain coalescing' " Kevin Traynor
2022-05-25 16:27 ` patch 'net/vhost: fix access to freed memory' " Kevin Traynor
2022-05-25 16:28 ` patch 'net/virtio: restore some optimisations with AVX512' " Kevin Traynor
2022-05-25 16:28 ` patch 'net/vhost: fix TSO feature default disablement' " Kevin Traynor
2022-05-25 16:28 ` patch 'vhost: fix missing virtqueue lock protection' " Kevin Traynor
2022-05-25 16:28 ` patch 'vdpa/mlx5: fix interrupt trash that leads to crash' " Kevin Traynor
2022-05-25 16:28 ` patch 'vdpa/mlx5: fix dead loop when process interrupted' " Kevin Traynor
2022-05-25 16:28 ` patch 'net/dpaa: fix event queue detach' " Kevin Traynor
2022-05-25 16:28 ` patch 'doc: update matching versions in ice guide' " Kevin Traynor
2022-05-25 16:28 ` patch 'net/bonding: fix stopping non-active slaves' " Kevin Traynor
2022-05-25 16:28 ` patch 'net/bonding: fix slave stop and remove on port close' " Kevin Traynor
2022-05-25 16:28 ` patch 'net/tap: fix interrupt handler freeing' " Kevin Traynor
2022-05-25 16:28 ` patch 'ethdev: fix build with vtune option' " Kevin Traynor
2022-05-25 16:28 ` patch 'net/hns3: fix order of clearing imissed register in PF' " Kevin Traynor
2022-05-25 16:28 ` patch 'net/hns3: fix MAC and queues HW statistics overflow' " Kevin Traynor
2022-05-25 16:28 ` patch 'net/hns3: fix pseudo-sharing between threads' " Kevin Traynor
2022-05-25 16:28 ` patch 'net/hns3: fix mbuf free on Tx done cleanup' " Kevin Traynor
2022-05-25 16:28 ` patch 'net/hns3: fix RSS disable' " Kevin Traynor
2022-05-25 16:28 ` patch 'net/hns3: fix rollback on RSS hash update' " Kevin Traynor
2022-05-25 16:28 ` patch 'net/hns3: remove redundant RSS tuple field' " Kevin Traynor
2022-05-25 16:28 ` patch 'ethdev: fix RSS update when RSS is disabled' " Kevin Traynor
2022-05-25 16:28 ` patch 'net/hns3: remove unnecessary RSS switch' " Kevin Traynor
2022-05-25 16:28 ` patch 'app/testpmd: check statistics query before printing' " Kevin Traynor
2022-05-25 16:28 ` patch 'app/testpmd: fix MTU verification' " Kevin Traynor
2022-05-25 16:28 ` patch 'net/cnxk: add message on flow parsing failure' " Kevin Traynor
2022-05-25 16:28 ` patch 'common/cnxk: fix unaligned access to device memory' " Kevin Traynor
2022-05-25 16:28 ` patch 'common/cnxk: fix null pointer dereference' " Kevin Traynor
2022-05-25 16:28 ` patch 'net/cnxk: fix uninitialized variables' " Kevin Traynor
2022-05-25 16:28 ` patch 'common/cnxk: fix SQ flush sequence' " Kevin Traynor
2022-05-25 16:35   ` Kevin Traynor
2022-05-25 16:28 ` patch 'net/cnxk: add barrier after meta batch free in scalar' " Kevin Traynor
2022-05-25 16:28 ` patch 'net/bnxt: fix reordering in NEON Rx' " Kevin Traynor
2022-05-25 16:28 ` patch 'net/bnxt: fix device capability reporting' " Kevin Traynor
2022-05-25 16:28 ` patch 'net/bnxt: remove unused macro' " Kevin Traynor
2022-05-25 16:28 ` patch 'net/bnxt: fix Rx configuration' " Kevin Traynor
2022-05-25 16:28 ` patch 'net/bnxt: fix RSS action' " Kevin Traynor
2022-05-25 16:28 ` patch 'net/bnxt: fix ring group on Rx restart' " Kevin Traynor
2022-05-25 16:28 ` patch 'net/bnxt: check duplicate queue IDs' " Kevin Traynor
2022-05-25 16:28 ` patch 'net/bnxt: handle queue stop during RSS flow create' " Kevin Traynor
2022-05-25 16:28 ` patch 'net/bnxt: avoid unnecessary endianness conversion' " Kevin Traynor
2022-05-25 16:28 ` patch 'net/bnxt: fix speed autonegotiation' " Kevin Traynor
2022-05-25 16:28 ` patch 'net/bnxt: force PHY update on certain configurations' " Kevin Traynor
2022-05-25 16:28 ` patch 'net/bnxt: fix link status when port is stopped' " Kevin Traynor
2022-05-25 16:28 ` patch 'net/bnxt: recheck FW readiness if in reset process' " Kevin Traynor
2022-05-25 16:28 ` patch 'net/bnxt: fix freeing VNIC filters' " Kevin Traynor
2022-05-25 16:28 ` patch 'net/mlx5: fix no-green metering with RSS' " Kevin Traynor
2022-05-25 16:28 ` patch 'doc: fix build with sphinx 4.5' " Kevin Traynor
2022-05-25 16:28 ` patch 'eventdev/eth_rx: fix telemetry Rx stats reset' " Kevin Traynor
2022-05-25 16:28 ` patch 'event/cnxk: fix out of bounds access in test' " Kevin Traynor
2022-05-25 16:28 ` patch 'eal/x86: fix unaligned access for small memcpy' " Kevin Traynor
2022-05-25 16:28 ` patch 'devargs: fix leak on hotplug failure' " Kevin Traynor

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=20220525162847.711753-2-ktraynor@redhat.com \
    --to=ktraynor@redhat.com \
    --cc=longli@microsoft.com \
    --cc=stable@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).