Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753679AbcLBHOU (ORCPT ); Fri, 2 Dec 2016 02:14:20 -0500 Received: from mail-bn3nam01on0129.outbound.protection.outlook.com ([104.47.33.129]:39328 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751829AbcLBHOS (ORCPT ); Fri, 2 Dec 2016 02:14:18 -0500 From: KY Srinivasan To: Greg KH CC: "linux-kernel@vger.kernel.org" , "devel@linuxdriverproject.org" , "olaf@aepfle.de" , "apw@canonical.com" , "vkuznets@redhat.com" , "jasowang@redhat.com" , "leann.ogasawara@canonical.com" , Haiyang Zhang Subject: RE: [PATCH 02/15] hyperv: Add a function to detect hv_device Thread-Topic: [PATCH 02/15] hyperv: Add a function to detect hv_device Thread-Index: AQHSS+hcRHtOOpPMlEiibc7N0eIJt6DzjS2AgACaP1CAABDUgIAAAKew Date: Fri, 2 Dec 2016 07:14:03 +0000 Message-ID: References: <1480613287-7748-1-git-send-email-kys@exchange.microsoft.com> <1480613332-7788-1-git-send-email-kys@exchange.microsoft.com> <1480613332-7788-2-git-send-email-kys@exchange.microsoft.com> <20161201203547.GB1602@kroah.com> <20161202064805.GA19267@kroah.com> In-Reply-To: <20161202064805.GA19267@kroah.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=kys@microsoft.com; x-originating-ip: [50.135.110.52] x-ms-office365-filtering-correlation-id: 7a70f0ea-c059-45aa-25fc-08d41a82cbd4 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:BN3PR03MB1414; x-microsoft-exchange-diagnostics: 1;BN3PR03MB1414;7:gIlr/UebE7mLyTs6BYC2EcSbPTapmZ7u2ByQvmOKSntZaDK/3C2lMEUhbLk2GmffWcwsmXDt9BO9gpJUwqdLsAEnRb7aErVC85bB+x79mINzSokY5CPxdRtWJiClqsOA1X+DcUqLMq28nA5X81LyxzKuNUGfan651alz6QgEt/GADDw/db4TipKph/zHnNE27BmFDqWOeTIrKinbGMR9iweMadVRZ0lbZ+GxTKozwmQWuvJfYSlT83Y6BOcLJMQJkVoliglcgNjcczj4NgX3ePh6LGtgXEMl9LkElRzWQEd/vUewJT83Tk4BRI4SvOLRTS67ADkrBy4+Dbfdeag6+VhnHe3UIg0Sb1p46d4sKh9+wJ3r/iDj1whSCeXtpWjDfowwShMXeagDJZ6dzUtRpGv74jMQtcKuuxlgzW/XoLtLmQQS2EDBy5334RLRIdPhoRhxpF/U2qJ25Zm61SDfsO7JAbCNHrq09GXvZgMSwec= x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(9452136761055)(140211028294663)(198206253151910); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(61425038)(6040375)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6055026)(61426038)(61427038)(6041248)(20161123560025)(20161123564025)(20161123555025)(20161123562025)(6047074)(6072148);SRVR:BN3PR03MB1414;BCL:0;PCL:0;RULEID:(304825118);SRVR:BN3PR03MB1414; x-forefront-prvs: 0144B30E41 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(7916002)(189002)(199003)(24454002)(377454003)(52314003)(13464003)(54534003)(74316002)(33656002)(81166006)(4001430100002)(8936002)(8676002)(10090500001)(81156014)(2906002)(3280700002)(68736007)(9686002)(3660700001)(50986999)(54356999)(105586002)(101416001)(5005710100001)(6506004)(92566002)(106116001)(3846002)(189998001)(6116002)(106356001)(10290500002)(102836003)(97736004)(99286002)(4326007)(305945005)(5660300001)(6916009)(110136003)(107886002)(8990500004)(122556002)(93886004)(7696004)(2900100001)(76176999)(38730400001)(86362001)(39410400001)(66066001)(7846002)(86612001)(7736002)(76576001)(229853002)(2950100002)(77096006)(39450400002);DIR:OUT;SFP:1102;SCL:1;SRVR:BN3PR03MB1414;H:DM5PR03MB2490.namprd03.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Dec 2016 07:14:03.1349 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR03MB1414 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id uB27EPRa015231 Content-Length: 4612 Lines: 119 > -----Original Message----- > From: Greg KH [mailto:gregkh@linuxfoundation.org] > Sent: Thursday, December 1, 2016 10:48 PM > To: KY Srinivasan > Cc: linux-kernel@vger.kernel.org; devel@linuxdriverproject.org; > olaf@aepfle.de; apw@canonical.com; vkuznets@redhat.com; > jasowang@redhat.com; leann.ogasawara@canonical.com; Haiyang Zhang > > Subject: Re: [PATCH 02/15] hyperv: Add a function to detect hv_device > > On Fri, Dec 02, 2016 at 06:02:29AM +0000, KY Srinivasan wrote: > > > > > > > -----Original Message----- > > > From: Greg KH [mailto:gregkh@linuxfoundation.org] > > > Sent: Thursday, December 1, 2016 12:36 PM > > > To: KY Srinivasan > > > Cc: linux-kernel@vger.kernel.org; devel@linuxdriverproject.org; > > > olaf@aepfle.de; apw@canonical.com; vkuznets@redhat.com; > > > jasowang@redhat.com; leann.ogasawara@canonical.com; Haiyang Zhang > > > > > > Subject: Re: [PATCH 02/15] hyperv: Add a function to detect hv_device > > Ugh, please fix your email client... > > > > > > > On Thu, Dec 01, 2016 at 09:28:39AM -0800, kys@exchange.microsoft.com > > > wrote: > > > > From: Haiyang Zhang > > > > > > > > Signed-off-by: Haiyang Zhang > > > > Signed-off-by: K. Y. Srinivasan > > > > --- > > > > drivers/hv/vmbus_drv.c | 6 ++++++ > > > > include/linux/hyperv.h | 2 ++ > > > > 2 files changed, 8 insertions(+), 0 deletions(-) > > > > > > > > diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c > > > > index 0276d2e..1730ac0 100644 > > > > --- a/drivers/hv/vmbus_drv.c > > > > +++ b/drivers/hv/vmbus_drv.c > > > > @@ -692,6 +692,12 @@ struct onmessage_work_context { > > > > struct hv_message msg; > > > > }; > > > > > > > > +bool device_is_hyperv(struct device *dev) > > > > +{ > > > > + return dev->release == vmbus_device_release; > > > > +} > > > > +EXPORT_SYMBOL_GPL(device_is_hyperv); > > > > > > Wait, eek, no! That's NOT how you determine a device type, if you > > > really even ever need to do that. > > > > > > Why are you needing this? You should always "just know" what type of > > > device a struct device * is, that's what we rely on in the driver model. > > > Otherwise things get messy very very quickly. > > > > > > Sorry, I can't take this without a ton of justification, and even then, > > > you need to do this correctly (and no, I'm not going to tell you how to > > > do that as I don't like it being done...) > > > > > Greg, > > > > To support SR-IOV, netvsc registers for all netdev events. For netdev > events related to the > > VF interface, we need to do some special processing. And so, we need to > determine > > if the device that is generating the netdev event is Hyper-V device or not > > (passed through the PCI pass through driver). Is this justification sufficient. > > As you have observed, currently there is no user of this API and that is > because netvsc > > will be the user. To avoid cross-tree dependency, we wanted to get this > functionality in first > > before submitting the netvsc patch. > > See, you do have some text for a changelog! > > {grumble...} > > No, I don't think this is a good justification, where are you going to > put this "check" into the networking stack? Your driver should only be > binding to devices of this "type" anyway, so by that logic, it already > "knows" that the device is of this type. > > In other words, why do you need this and PCI or USB doesn't? Why is > hyperv "special"? On Hyper-V, each VF interface (SR-IOV interface) is paired with an instance of the synthetic interface that is managed by netvsc. When the VF interface comes up, we need to associate the VF instance with the corresponding netvsc instance. To do this without modifying the VF drivers, netvsc registers for netdev events. In the netdev event handler (in netvsc) currently I am doing the association based on the MAC address - this code is currently committed upstream (see drivers/net/hyperv/netvsc_drv.c netvsc_register_vf()). Going forward, we want to base this association based on a sequence number that the host publishes both for the VF as well as the corresponding synthetic (netvsc) instance. You are right, netvsc already knows that the devices it is managing belong to vmbus. Since we are registering for netdev events, we will get notified for devices that may not be vmbus devices and that is where this new API will be used. If the device is a vmbus device we can extract the sequence number to implement the match. Regards, K. Y