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=-1.0 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS 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 CA1BCC43381 for ; Fri, 22 Feb 2019 18:53:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8F7AB2070B for ; Fri, 22 Feb 2019 18:53:33 +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="aANLj+YG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726131AbfBVSxc (ORCPT ); Fri, 22 Feb 2019 13:53:32 -0500 Received: from mail-qt1-f193.google.com ([209.85.160.193]:39191 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725832AbfBVSxc (ORCPT ); Fri, 22 Feb 2019 13:53:32 -0500 Received: by mail-qt1-f193.google.com with SMTP id o6so3681750qtk.6 for ; Fri, 22 Feb 2019 10:53:31 -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=A0vb9ISXednOx7QDZ49RZhi2mB2zTsEunLUVMQl4Nzo=; b=aANLj+YGuTXv/qtt9u/wyYRIow+obsuTPdG53JZ8vP3zp2DiZ7z9r4Icp9PLZIaZbh 199N5IW3/r6VjkySJYv+gBWtglTiJjJYu8eN0gkZNYtrxZkHiQzKv5Zav9FKY3qxNjdq 6sIVIkmGs6MX+KtXqmaeFFaPP+imO8gVWBQzbuwRa2HCJ79UJVQnJDzwKVEyAuwkUg0U L9X6LIDw6be8WMzSIRjcXPaeWWnkcb3nG95Xe4q/Pn07ZdpSgzjIijMHnbdnSagEBpap UST0hCaXHnY6qHhqDBdxNeDVEreo0TYqw5FShwALnYdLNuW/+4N6LU5vuX+j1YyME8XL L37A== 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=A0vb9ISXednOx7QDZ49RZhi2mB2zTsEunLUVMQl4Nzo=; b=sjO9E86CdzD1Cwrnuz0m/edXoXUzIisbGR5f0TAYGKMo1k7VYtrHlpPGZ3J5+9tGku ni7aSt/XQzsa0GmX0TjTtBKmlbDMfqtpJ9rJ4wZRpqAeLFdHYf6hu5UolJC09IvuZxBI szD/7PR69PQRBjt4A1pQXu9kY9K//iG45imbcF5sJG/ok4JOXXYdqLvU/zppYbceWy3D PhDeVn0VivQg2yjHHt+H0XwRhoQFNdIsA4eOyWLr1IUKi/8x6sGl71NmtPfKxmDUZFj0 EDEl3pB3mZi3ll653ys8sEJBOuZAwjqNN9wZCa5+VVH/ZijdVVlsoV+gKoWLFzhHfreI Aoag== X-Gm-Message-State: AHQUAuZnklFqyKQSs2AjFOoGEeWKpEAaLO9pmZSG4hNzofAhgK/I5o6H gd4KLlOoaquSRTtUqBVpmz+pfQ== X-Google-Smtp-Source: AHgI3IbEUoBrCarAc2bDChYy+md2psHf35ybgrgZMQVw8Sy8ECOhZ89WZSvoFteGxMKXmTzYjUy26A== X-Received: by 2002:a0c:8876:: with SMTP id 51mr4218089qvm.38.1550861610666; Fri, 22 Feb 2019 10:53:30 -0800 (PST) Received: from cakuba.netronome.com ([66.60.152.14]) by smtp.gmail.com with ESMTPSA id h58sm1477914qtb.89.2019.02.22.10.53.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Feb 2019 10:53:30 -0800 (PST) Date: Fri, 22 Feb 2019 10:53:26 -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 4/5] nfp: add .ndo_get_devlink Message-ID: <20190222105326.2340c856@cakuba.netronome.com> In-Reply-To: <20190222172715.GT23151@unicorn.suse.cz> References: <20190221174620.12144-1-jakub.kicinski@netronome.com> <20190221174620.12144-5-jakub.kicinski@netronome.com> <20190222100450.GR23151@unicorn.suse.cz> <20190222090204.20c410e3@cakuba.netronome.com> <20190222172715.GT23151@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 18:27:15 +0100, Michal Kubecek wrote: > > > Maybe it would be safer not to call ndo_get_devlink directly and have > > > an inline wrapper like > > > > > > #if IS_ENABLED(CONFIG_NET_DEVLINK) > > > static inline struct devlink *dev_get_devlink(struct net_device *dev) > > > { > > > if (dev->netdev_ops->ndo_get_devlink) > > > return dev->netdev_ops->ndo_get_devlink(); > > > else > > > retrurn NULL; > > > } > > > #else > > > static inline struct devlink *dev_get_devlink(struct net_device *dev) > > > { > > > return NULL; > > > } > > > #endif > > > > > > so that one can simply call the wrapper and check return value for NULL. > > > > Only devlink code can call this ndo, and it doesn't exist with > > DEVLINK=n. I don't dislike wrappers for NDOs, but I'll defer to Jiri > > to decide if we want a wrapper here (without the #if/#else, just the > > first part for code clarity) :) > > If the NDO is only supposed to be called from devlink code (or, more > precisely, code built only with CONFIG_DEVLINK=y), it should be IMHO > mentioned in its description. Another option would be enforcing it by > adding #ifdef around the ndo_get_devlink entry in struct net_device_ops > but that would require using ifdefs also in each driver providing the > NDO which seems inconvenient. Yes, let's just go with your first proposal of a static inline helper. I think it's the cleanest solution.