Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next,v2] hv_netvsc: fix vf serial matching with pci slot info
@ 2018-10-12 20:55 Haiyang Zhang
  2018-10-12 22:20 ` [PATCH net-next, v2] " Stephen Hemminger
  0 siblings, 1 reply; 3+ messages in thread
From: Haiyang Zhang @ 2018-10-12 20:55 UTC (permalink / raw)
  To: davem, netdev
  Cc: haiyangz, kys, sthemmin, olaf, vkuznets, devel, linux-kernel

From: Haiyang Zhang <haiyangz@microsoft.com>

The VF device's serial number is saved as a string in PCI slot's
kobj name, not the slot->number. This patch corrects the netvsc
driver, so the VF device can be successfully paired with synthetic
NIC.

Fixes: 00d7ddba1143 ("hv_netvsc: pair VF based on serial number")
Reported-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/net/hyperv/netvsc_drv.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 9bcaf204a7d4..ded623862003 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -2030,14 +2030,15 @@ static void netvsc_vf_setup(struct work_struct *w)
 	rtnl_unlock();
 }
 
-/* Find netvsc by VMBus serial number.
- * The PCI hyperv controller records the serial number as the slot.
+/* Find netvsc by VF serial number.
+ * The PCI hyperv controller records the serial number as the slot kobj name.
  */
 static struct net_device *get_netvsc_byslot(const struct net_device *vf_netdev)
 {
 	struct device *parent = vf_netdev->dev.parent;
 	struct net_device_context *ndev_ctx;
 	struct pci_dev *pdev;
+	u32 serial;
 
 	if (!parent || !dev_is_pci(parent))
 		return NULL; /* not a PCI device */
@@ -2048,16 +2049,22 @@ static struct net_device *get_netvsc_byslot(const struct net_device *vf_netdev)
 		return NULL;
 	}
 
+	if (kstrtou32(kobject_name(&pdev->slot->kobj), 10, &serial)) {
+		netdev_notice(vf_netdev, "Invalid vf serial:%s\n",
+			      pdev->slot->kobj.name);
+		return NULL;
+	}
+
 	list_for_each_entry(ndev_ctx, &netvsc_dev_list, list) {
 		if (!ndev_ctx->vf_alloc)
 			continue;
 
-		if (ndev_ctx->vf_serial == pdev->slot->number)
+		if (ndev_ctx->vf_serial == serial)
 			return hv_get_drvdata(ndev_ctx->device_ctx);
 	}
 
 	netdev_notice(vf_netdev,
-		      "no netdev found for slot %u\n", pdev->slot->number);
+		      "no netdev found for vf serial:%u\n", serial);
 	return NULL;
 }
 
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next, v2] hv_netvsc: fix vf serial matching with pci slot info
  2018-10-12 20:55 [PATCH net-next,v2] hv_netvsc: fix vf serial matching with pci slot info Haiyang Zhang
@ 2018-10-12 22:20 ` Stephen Hemminger
  2018-10-12 22:27   ` Haiyang Zhang
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2018-10-12 22:20 UTC (permalink / raw)
  To: Haiyang Zhang
  Cc: olaf, netdev, haiyangz, linux-kernel, devel, vkuznets, davem

On Fri, 12 Oct 2018 20:55:15 +0000
Haiyang Zhang <haiyangz@linuxonhyperv.com> wrote:

Thanks for fixing this.

  
> +	if (kstrtou32(kobject_name(&pdev->slot->kobj), 10, &serial)) {
> +		netdev_notice(vf_netdev, "Invalid vf serial:%s\n",
> +			      pdev->slot->kobj.name);
> +		return NULL;
> +	}

Shouldn't this use kobject_name() in the message as well.

Looking at the pci.h code there is already an API to get name from
slot (it uses kobject_name()). So please use that one.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH net-next, v2] hv_netvsc: fix vf serial matching with pci slot info
  2018-10-12 22:20 ` [PATCH net-next, v2] " Stephen Hemminger
@ 2018-10-12 22:27   ` Haiyang Zhang
  0 siblings, 0 replies; 3+ messages in thread
From: Haiyang Zhang @ 2018-10-12 22:27 UTC (permalink / raw)
  To: Stephen Hemminger, Haiyang Zhang
  Cc: davem@davemloft.net, netdev@vger.kernel.org, olaf@aepfle.de,
	linux-kernel@vger.kernel.org, devel@linuxdriverproject.org,
	vkuznets



> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Friday, October 12, 2018 6:21 PM
> To: Haiyang Zhang <haiyangz@linuxonhyperv.com>
> Cc: Haiyang Zhang <haiyangz@microsoft.com>; davem@davemloft.net;
> netdev@vger.kernel.org; olaf@aepfle.de; linux-kernel@vger.kernel.org;
> devel@linuxdriverproject.org; vkuznets <vkuznets@redhat.com>
> Subject: Re: [PATCH net-next, v2] hv_netvsc: fix vf serial matching with pci slot
> info
> 
> On Fri, 12 Oct 2018 20:55:15 +0000
> Haiyang Zhang <haiyangz@linuxonhyperv.com> wrote:
> 
> Thanks for fixing this.
> 
> 
> > +	if (kstrtou32(kobject_name(&pdev->slot->kobj), 10, &serial)) {
> > +		netdev_notice(vf_netdev, "Invalid vf serial:%s\n",
> > +			      pdev->slot->kobj.name);
> > +		return NULL;
> > +	}
> 
> Shouldn't this use kobject_name() in the message as well.
> 
> Looking at the pci.h code there is already an API to get name from slot (it uses
> kobject_name()). So please use that one.

Sure, I will look for that api. Thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-10-12 22:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-12 20:55 [PATCH net-next,v2] hv_netvsc: fix vf serial matching with pci slot info Haiyang Zhang
2018-10-12 22:20 ` [PATCH net-next, v2] " Stephen Hemminger
2018-10-12 22:27   ` Haiyang Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox