From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC0FEC43381 for ; Fri, 22 Feb 2019 09:51:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A2A502081B for ; Fri, 22 Feb 2019 09:51:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726890AbfBVJvf (ORCPT ); Fri, 22 Feb 2019 04:51:35 -0500 Received: from mx2.suse.de ([195.135.220.15]:39972 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726867AbfBVJve (ORCPT ); Fri, 22 Feb 2019 04:51:34 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 56301B083; Fri, 22 Feb 2019 09:51:33 +0000 (UTC) Received: by unicorn.suse.cz (Postfix, from userid 1000) id AF895E00A5; Fri, 22 Feb 2019 10:51:31 +0100 (CET) Date: Fri, 22 Feb 2019 10:51:31 +0100 From: Michal Kubecek To: Jakub Kicinski Cc: davem@davemloft.net, jiri@resnulli.us, andrew@lunn.ch, f.fainelli@gmail.com, netdev@vger.kernel.org, oss-drivers@netronome.com Subject: Re: [PATCH net-next 3/5] devlink: create a special NDO for getting the devlink instance Message-ID: <20190222095131.GQ23151@unicorn.suse.cz> References: <20190221174620.12144-1-jakub.kicinski@netronome.com> <20190221174620.12144-4-jakub.kicinski@netronome.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190221174620.12144-4-jakub.kicinski@netronome.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Thu, Feb 21, 2019 at 09:46:18AM -0800, Jakub Kicinski wrote: > Instead of iterating over all devlink ports add a NDO which > will return the devlink instance from the driver. > > Suggested-by: Jiri Pirko > Signed-off-by: Jakub Kicinski > --- > include/linux/netdevice.h | 6 ++++ > net/core/devlink.c | 62 +++++++++++++-------------------------- > 2 files changed, 26 insertions(+), 42 deletions(-) > > diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h > index aab4d9f6613d..eebcef6b8191 100644 > --- a/include/linux/netdevice.h > +++ b/include/linux/netdevice.h > @@ -940,6 +940,8 @@ struct dev_ifalias { > char ifalias[]; > }; > > +struct devlink; > + > /* > * This structure defines the management hooks for network devices. > * The following hooks can be defined; unless noted otherwise, they are > @@ -1248,6 +1250,9 @@ struct dev_ifalias { > * that got dropped are freed/returned via xdp_return_frame(). > * Returns negative number, means general error invoking ndo, meaning > * no frames were xmit'ed and core-caller will free all frames. > + * struct devlink *(*ndo_get_devlink)(struct net_device *dev); > + * Get devlink instance associated with a given netdev. > + * Called with a reference on the device only, rtnl_lock is not held. The formulation is a bit ambiguous. Do I understand correctly that what it says is that device reference is sufficient and rtnl_lock is not necessary (but there is no harm if caller holds rtnl_lock)? Michal