From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752559AbcLJAV6 (ORCPT ); Fri, 9 Dec 2016 19:21:58 -0500 Received: from mail-pf0-f173.google.com ([209.85.192.173]:35301 "EHLO mail-pf0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751693AbcLJAV4 (ORCPT ); Fri, 9 Dec 2016 19:21:56 -0500 Date: Fri, 9 Dec 2016 16:21:48 -0800 From: Stephen Hemminger To: Haiyang Zhang Cc: Greg KH , KY Srinivasan , "olaf@aepfle.de" , "linux-kernel@vger.kernel.org" , "bjorn.helgaas@gmail.com" , "apw@canonical.com" , "devel@linuxdriverproject.org" , "leann.ogasawara@canonical.com" , "jasowang@redhat.com" Subject: Re: [PATCH 3/3] hv_netvsc: Implement VF matching based on serial numbers Message-ID: <20161209162148.44887938@xeon-e3> In-Reply-To: References: <1481185988-30383-1-git-send-email-kys@exchange.microsoft.com> <1481186023-30429-1-git-send-email-kys@exchange.microsoft.com> <1481186023-30429-3-git-send-email-kys@exchange.microsoft.com> <20161208155604.GA4601@kroah.com> <20161209073122.GB1513@kroah.com> <20161209102030.1f550c5a@xeon-e3> <20161209122935.2bd0779e@xeon-e3> <20161209134510.22087f81@xeon-e3> <20161209140509.1dd7cad2@xeon-e3> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 9 Dec 2016 22:35:05 +0000 Haiyang Zhang 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).