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=-9.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,USER_AGENT_GIT 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 E3E62C4360F for ; Wed, 3 Apr 2019 12:24:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B82C82084B for ; Wed, 3 Apr 2019 12:24:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=resnulli-us.20150623.gappssmtp.com header.i=@resnulli-us.20150623.gappssmtp.com header.b="NtmqIeTz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726539AbfDCMYr (ORCPT ); Wed, 3 Apr 2019 08:24:47 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:47052 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726372AbfDCMYo (ORCPT ); Wed, 3 Apr 2019 08:24:44 -0400 Received: by mail-wr1-f65.google.com with SMTP id t17so8016566wrw.13 for ; Wed, 03 Apr 2019 05:24:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3X6xaTH7tARkyh11VpH35Y8Gd1jzENjmvZWMgNNtn+8=; b=NtmqIeTzWKJj/LjWI2fnLrVSQwyZo7G1LuJcvwly6rVWXUE/eOlzcEVSOtAwH7LQYy AL6t5M3wOpXWlXNNqlFimAJdfNZsRyTq9cr9ByjHB9HslG+aOGi8lCJJbVsGZxjXjhuA MpK2FniWisV++o8MSyGm0vpj5X+ankM7Tuv7LqlucVnL9zjACMRBOCVpvBBckzPsop4l Lua88QZh0meL+rlxma292CgjlHtnYziimulRIGVW1uIqGX2JM+lf0e6PNFpAb52u36kl W9y/2g9CC4jg3B8Huq+dzgto0AMH8NfvQZy3jEjTksR0QvynVLECY/NZMFWB3npandt4 sh1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3X6xaTH7tARkyh11VpH35Y8Gd1jzENjmvZWMgNNtn+8=; b=Ygns/X+CcpiTq5EQ4LdNGj1dEJvc6ftZQqTW0iGYTPeq7UWTOItRAG3+Kl4MGIcCPN GLVxt6aosPbcEAOHcV4sr0+ryXletWo0vVjIXdv4tWMVaTeGV6AWUkp1xjZIYfg0RsUT fIHsS3e5YNhTWECkyJuyjwy9McuMxcznSlIkgpOwLXMzRCcpXAij5HnkPvTokj8lw10T EZ/8ONDb0IhDr8Rcz5c2pjnLWFfnerlKE79bicZBc2Y+VAS647yFRp3QFWjB2qhiHQWd ODE5KCOxD73S4IZZ8xKX5X9vEw5PorLh80Z2CKWO67oRytFitGd+jGhPVQgTcSCii+Ba cZdg== X-Gm-Message-State: APjAAAXNXlX7FzSa7Zlu1rrMv8JOhZGZO/bMkp7u9e9HP02uFhp/O0Tf u6xoRkFB36ueS8FwXoKxkzKDYOwQJ8E= X-Google-Smtp-Source: APXvYqx6kLl6qmOi8Liu1cCUxZI/r4ojIBQjkQP0ve2QbsUHjC5KcgDI/4SgyPDUAL6Rt+F0VoumfQ== X-Received: by 2002:a5d:4c88:: with SMTP id z8mr41135367wrs.291.1554294283028; Wed, 03 Apr 2019 05:24:43 -0700 (PDT) Received: from localhost (mail.chocen-mesto.cz. [85.163.43.2]) by smtp.gmail.com with ESMTPSA id o10sm19655104wru.54.2019.04.03.05.24.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Apr 2019 05:24:42 -0700 (PDT) From: Jiri Pirko To: netdev@vger.kernel.org Cc: davem@davemloft.net, mlxsw@mellanox.com, idosch@mellanox.com, jakub.kicinski@netronome.com, f.fainelli@gmail.com, andrew@lunn.ch, vivien.didelot@gmail.com, michael.chan@broadcom.com Subject: [patch net-next v4 13/13] net: devlink: add warning for ndo_get_port_parent_id set when not needed Date: Wed, 3 Apr 2019 14:24:27 +0200 Message-Id: <20190403122427.3057-14-jiri@resnulli.us> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190403122427.3057-1-jiri@resnulli.us> References: <20190403122427.3057-1-jiri@resnulli.us> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jiri Pirko Currently if the driver registers devlink port instance, he should set the devlink port attributes as well. Then the devlink core is able to obtain switch id itself, no need for driver to implement the ndo. Once all drivers will implement devlink port registration, this ndo should be removed. This warning guides new drivers to do things as they should be done. Signed-off-by: Jiri Pirko --- v3->v4: - fix warning to be done in case ndo is defined and returns -EOPNOTSUPP rfc->v1: - new patch --- net/core/devlink.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/net/core/devlink.c b/net/core/devlink.c index d9fbf94ea2a3..b2715a187a11 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -5358,24 +5358,38 @@ static void __devlink_port_type_set(struct devlink_port *devlink_port, void devlink_port_type_eth_set(struct devlink_port *devlink_port, struct net_device *netdev) { + const struct net_device_ops *ops = netdev->netdev_ops; + /* If driver registers devlink port, it should set devlink port * attributes accordingly so the compat functions are called * and the original ops are not used. */ - if (netdev->netdev_ops->ndo_get_phys_port_name) { + if (ops->ndo_get_phys_port_name) { /* Some drivers use the same set of ndos for netdevs * that have devlink_port registered and also for * those who don't. Make sure that ndo_get_phys_port_name * returns -EOPNOTSUPP here in case it is defined. * Warn if not. */ - const struct net_device_ops *ops = netdev->netdev_ops; char name[IFNAMSIZ]; int err; err = ops->ndo_get_phys_port_name(netdev, name, sizeof(name)); WARN_ON(err != -EOPNOTSUPP); } + if (ops->ndo_get_port_parent_id) { + /* Some drivers use the same set of ndos for netdevs + * that have devlink_port registered and also for + * those who don't. Make sure that ndo_get_port_parent_id + * returns -EOPNOTSUPP here in case it is defined. + * Warn if not. + */ + struct netdev_phys_item_id ppid; + int err; + + err = ops->ndo_get_port_parent_id(netdev, &ppid); + WARN_ON(err != -EOPNOTSUPP); + } __devlink_port_type_set(devlink_port, DEVLINK_PORT_TYPE_ETH, netdev); } EXPORT_SYMBOL_GPL(devlink_port_type_eth_set); -- 2.17.2