Commit 3d7d10b9 authored by Haiyang Zhang's avatar Haiyang Zhang Committed by Greg Kroah-Hartman

hv_netvsc: fix vf serial matching with pci slot info

[ Upstream commit 00547955 ]

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: 00d7ddba ("hv_netvsc: pair VF based on serial number")
Reported-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: default avatarHaiyang Zhang <haiyangz@microsoft.com>
Reviewed-by: default avatarStephen Hemminger <sthemmin@microsoft.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b85000e8
...@@ -2022,14 +2022,15 @@ static void netvsc_vf_setup(struct work_struct *w) ...@@ -2022,14 +2022,15 @@ static void netvsc_vf_setup(struct work_struct *w)
rtnl_unlock(); rtnl_unlock();
} }
/* Find netvsc by VMBus serial number. /* Find netvsc by VF serial number.
* The PCI hyperv controller records the serial number as the slot. * 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) static struct net_device *get_netvsc_byslot(const struct net_device *vf_netdev)
{ {
struct device *parent = vf_netdev->dev.parent; struct device *parent = vf_netdev->dev.parent;
struct net_device_context *ndev_ctx; struct net_device_context *ndev_ctx;
struct pci_dev *pdev; struct pci_dev *pdev;
u32 serial;
if (!parent || !dev_is_pci(parent)) if (!parent || !dev_is_pci(parent))
return NULL; /* not a PCI device */ return NULL; /* not a PCI device */
...@@ -2040,16 +2041,22 @@ static struct net_device *get_netvsc_byslot(const struct net_device *vf_netdev) ...@@ -2040,16 +2041,22 @@ static struct net_device *get_netvsc_byslot(const struct net_device *vf_netdev)
return NULL; return NULL;
} }
if (kstrtou32(pci_slot_name(pdev->slot), 10, &serial)) {
netdev_notice(vf_netdev, "Invalid vf serial:%s\n",
pci_slot_name(pdev->slot));
return NULL;
}
list_for_each_entry(ndev_ctx, &netvsc_dev_list, list) { list_for_each_entry(ndev_ctx, &netvsc_dev_list, list) {
if (!ndev_ctx->vf_alloc) if (!ndev_ctx->vf_alloc)
continue; continue;
if (ndev_ctx->vf_serial == pdev->slot->number) if (ndev_ctx->vf_serial == serial)
return hv_get_drvdata(ndev_ctx->device_ctx); return hv_get_drvdata(ndev_ctx->device_ctx);
} }
netdev_notice(vf_netdev, 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; return NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment