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=-7.0 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED 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 BF4B7C43381 for ; Fri, 22 Feb 2019 16:56:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7ADDA2070B for ; Fri, 22 Feb 2019 16:56:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b="j5g/CElJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726505AbfBVQ4g (ORCPT ); Fri, 22 Feb 2019 11:56:36 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:41898 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725942AbfBVQ4g (ORCPT ); Fri, 22 Feb 2019 11:56:36 -0500 Received: by mail-pf1-f193.google.com with SMTP id d25so1365949pfn.8 for ; Fri, 22 Feb 2019 08:56:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :organization:mime-version:content-transfer-encoding; bh=xfpciFhOzP+T3i6Ppi4X0+WcWYTMcWfvBTiDiraiYMU=; b=j5g/CElJ2P40SxLrNSBO1xiGzQNitsPFKP1JzX3hSVx8vqGcUcVkWVbDxOEOtsLXDv lbcdZQ/2hzW+FrovbO6PtON4nDwh/U/Etd/pm+LpcYwSY5+PB0H615hAUEqkcmEh+b+n 359RBxoHoFLi1A9+JJmKWg0bW8uWL3Ov0NNh4o08xKwCFMIbSPDya1ReOsXihmLewPf4 V744oWZtpr7vUKNGtqRFXbhrF01YC7p3SCRvGGJrd1X0onVL8Ql/MYANtu3/ERVH9C1s 7GinLWyQGxIB7PXqopnk5KPc1AmkjxhyddHfRu2VVMo24cndK/4ZyCZcdU6qNL2xFfbc 1LmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=xfpciFhOzP+T3i6Ppi4X0+WcWYTMcWfvBTiDiraiYMU=; b=gxU0Yeey7HcMD9nEIKYUZRjUTSc/iUFgBSlWUwFYXm1H3yb4HaDLVQJL2tbWJVyttf bi0sAtEsJL+Mz12GuLzN5F7Q2rlGa9/5QA5PGKukHQ1TlhV9kLmHmfs8/T8Yyk/AE/xa cIKqRqzz2Wc3YzQHcYYdS5H4J+yUjBSptxy3Y0Fecyie+KTFyDTGJog59ObWQZGRIwSy I61iIsmlQNMGE1GdGH0olcgmii3rfWE+972YPGAwmBDOqpsN6Cc17T7d6xVTSrGZj224 DerHK/VG3w9nRNFOJGroYMLzFPJQOYQyLwgx1/c4Plf+3yxIP0h1ufVJrZJfBKwv1xSc yemg== X-Gm-Message-State: AHQUAuZoJd1daevVY5KZZ17srGpbJat93cW1jZ3doVO5R13P4Tt48+Io S19t42Fj7/8rmRHpySJiOsrsfA== X-Google-Smtp-Source: AHgI3IYCL03Jdr0liJwXYxWOYvmGAZwckVUu3hQUxMMBJhpeIo0ZompSqmPItiH627aTfJs0WSgdog== X-Received: by 2002:a65:5003:: with SMTP id f3mr4885782pgo.39.1550854595127; Fri, 22 Feb 2019 08:56:35 -0800 (PST) Received: from cakuba.netronome.com ([2601:646:8e00:1b7a::3]) by smtp.gmail.com with ESMTPSA id m13sm4677795pff.175.2019.02.22.08.56.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Feb 2019 08:56:34 -0800 (PST) Date: Fri, 22 Feb 2019 08:56:30 -0800 From: Jakub Kicinski To: Michal Kubecek 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: <20190222085630.6e9e764c@cakuba.netronome.com> In-Reply-To: <20190222095131.GQ23151@unicorn.suse.cz> References: <20190221174620.12144-1-jakub.kicinski@netronome.com> <20190221174620.12144-4-jakub.kicinski@netronome.com> <20190222095131.GQ23151@unicorn.suse.cz> Organization: Netronome Systems, Ltd. MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Fri, 22 Feb 2019 10:51:31 +0100, Michal Kubecek wrote: > 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)? Yes, only reference is held, the expectation is that drivers free netdevs before they unregister devlink. The devlink vs rtnl ordering gets a bit tricky, drivers should definitely not expect rtnl to be held in this NDO. If the caller comes from rtnl path (like ethtool) it will likely have to release rtnl before taking devlink->lock.