From patchwork Wed Mar 27 15:19:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 1067116 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=resnulli.us Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=resnulli-us.20150623.gappssmtp.com header.i=@resnulli-us.20150623.gappssmtp.com header.b="kNTc4Zjo"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 44TsBW4D0Qz9sPj for ; Thu, 28 Mar 2019 02:20:18 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729474AbfC0PUR (ORCPT ); Wed, 27 Mar 2019 11:20:17 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:33373 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731663AbfC0PUO (ORCPT ); Wed, 27 Mar 2019 11:20:14 -0400 Received: by mail-wr1-f67.google.com with SMTP id q1so19089375wrp.0 for ; Wed, 27 Mar 2019 08:20:13 -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=4t+aPajHrpa8YmzAL2MlWc+B5MdKyK/Fq94C08p8U/0=; b=kNTc4ZjoscuOZQChdv561ARIgabCt77rNfIKxLl5+p1VetTy3rVc9Nxg7HF6k1c/w7 oVtP+mG9PFgI49B/4OlVdwQX4WWOo6Ic6GgISGBtznrBZyL03xdaAWBqM8WruViZc3uZ +ur4zCb1Upr2sz2tSGf5XvrbP7KAev5z9DhskTfYBN4cpn3Kdbf9F02qQl67So3lS1aX JHUzVgQyWP18Cts7AJmPGONmWBqYMI7E3Kc7eAfLBhdYxC1aYT1NzoB6APXAxmSnEKDH Pl2qGED017Nl155uM2vTMWf5bPSIDKal38eZUJe1ZqOW4FtQ9wOAkar0Cx6h7irvXZMX wuaA== 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=4t+aPajHrpa8YmzAL2MlWc+B5MdKyK/Fq94C08p8U/0=; b=CfcxYK1ANQlw3zzMRdyv3VoP8Q0NpUPvrVvRuw9Kmt+NHTCyse8GgtKqY2RmThPbPw lRO1WRmeQqs39/J0iLKzT05sa0Pf2Iei7z8pr3Wo9aDN0Sp+iBk1Z9tnbLmW1FaczR+v skAIbUBHSiBDk5qhAdhRJmE+XdtkkgNpxpGMgCAB+uvkHb7vKdjJe6vWd/eo5RdJiSem 3VWjFO0pqv04k/SkbrmbxXdU11F3VLOXFB9yu/6i6fLxcv5Zw+hZHqxCzxfqda2Hd59i Wv5sEFhC/OEFp9zRnWZQDMEDBFdipP1FC5Ysxc7dkf6WImNEuxRQVAuNlHh3aVjxFRiq WCfA== X-Gm-Message-State: APjAAAVRQWqSDDCNYmK8bWKjV+yuiBooU3fpjajj2Wme/lmmsPBNtWNf GNjsLR1RrXjGSUqhq2xPeVQsANnDGTA= X-Google-Smtp-Source: APXvYqwWcKG05IHgb5xSePf0v8l3XZYFlUFf+1RWlDi6mSf8cnb7W8CGk29NxpF7CDs2HX9uxomq7g== X-Received: by 2002:adf:ec0a:: with SMTP id x10mr7389270wrn.193.1553700012917; Wed, 27 Mar 2019 08:20:12 -0700 (PDT) Received: from localhost (ip-94-113-223-73.net.upcbroadband.cz. [94.113.223.73]) by smtp.gmail.com with ESMTPSA id w14sm5764527wrr.16.2019.03.27.08.20.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 Mar 2019 08:20:12 -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 v3 12/12] net: devlink: add warning for ndo_get_phys_port_name set when not needed Date: Wed, 27 Mar 2019 16:19:58 +0100 Message-Id: <20190327151958.2649-13-jiri@resnulli.us> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190327151958.2649-1-jiri@resnulli.us> References: <20190327151958.2649-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, it should set the devlink port attributes as well. Then the devlink core is able to obtain physical port name 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 Reviewed-by: Jakub Kicinski --- v1->v2: - new patch --- net/core/devlink.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/net/core/devlink.c b/net/core/devlink.c index 6bbd07e3861e..dc3a99148ee7 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -5358,6 +5358,24 @@ 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) { + /* 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) { + /* 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); + } __devlink_port_type_set(devlink_port, DEVLINK_PORT_TYPE_ETH, netdev); } EXPORT_SYMBOL_GPL(devlink_port_type_eth_set);