On Fri, 9 Dec 2016 22:35:05 +0000 Haiyang Zhang <haiyangz@xxxxxxxxxxxxx> wrote: > > > > > > > > Emulated NIC is already excluded in start of netvc notifier handler. > > > > > > > > static int netvsc_netdev_event(struct notifier_block *this, > > > > unsigned long event, void *ptr) > > > > { > > > > struct net_device *event_dev = netdev_notifier_info_to_dev(ptr); > > > > > > > > /* Skip our own events */ > > > > if (event_dev->netdev_ops == &device_ops) > > > > return NOTIFY_DONE; > > > > > > > > > > Emulated device is not based on netvsc. It's the native Linux > > (dec100M?) > > > Driver. So this line doesn't exclude it. And how about other NIC type > > > may be added in the future? > > > > Sorry, forgot about that haven't used emulated device in years. > > The emulated device should appear to be on a PCI bus, but the serial > > would not match?? > > It's not a vmbus device, not a hv_pci device either. Hv_PCI is a subset > of vmbus devices. So emulated NIC won't have hv_pci serial number. > > In my patch, the following code ensure, we only try to get serial number > after confirming it's vmbus and hv_pci device: > > + if (!dev_is_vmbus(dev)) > + continue; > + > + hdev = device_to_hv_device(dev); > + if (hdev->device_id != HV_PCIE) > + continue; Ok, the walk back up the device tree is logically ok, but I don't know enough about PCI device tree to be assured that it is safe. Also, you could short circuit away most of the unwanted devices by making sure the vf_netdev->dev.parent is a PCI device. Also the loop to look for serial number in the devices on the hv_pci bus could be made a separate function and have a short circuit return (although it probably doesn't matter since there will only be on e PCI VF device per bus there). _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel