Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp976357ima; Fri, 1 Feb 2019 14:09:12 -0800 (PST) X-Google-Smtp-Source: ALg8bN7Y08MHKrlGALKtVeYk3G8rlwCXHtj9P9frICHbXylP4alxZjG3zQlAoXMoaYHr6TJ3t6EP X-Received: by 2002:a62:9719:: with SMTP id n25mr42543210pfe.240.1549058952719; Fri, 01 Feb 2019 14:09:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549058952; cv=none; d=google.com; s=arc-20160816; b=rTk1a7Dq2UAlq1c0p0OAPUY5X1eKH3NtYJBxbzhtTMiMZ8PPhlRpA4Yf5bDXF1dDYk 4+Zy38SzxnjgGF3TmLDktynnGq7tjvQPLGuSZ8x50BLQ85AqFltiVqvf12SjKJABX+CZ M4ydGsyFuMdBdbENA6K/DCOG5AjdL+5ZFj/tHLSeYpkyoUGpPBIzh++kce3YCfKh0/cV DxDoPyti1gnCDWCDPq5SGueKgsy+K0C9ARbNLhv+ppV3Ln9WCT8DYYtvZ1DQcXWJkL1+ zYEw2CjsjAz2yJU26l/qCuU+rYz8j1YsAS1vWm9PCmMkIZvoh2ue/SIBn6cX3spk7Hby YXAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=DWtHrAlD/PuoBaMP5Yacl9yw0RDRTuKpO9kH1XLTeNg=; b=rgeGHusyXJi8iWzLKx5aCYUr4dAk8/dPLCrH1V4oUtNoJKDwGYyBrKwzwxF2STLcQ9 d+dWsv+kABlSmUHaGvizCZqcxQvFEs5MsLcR0WLbNaeneydpI/hIkg1ruOOLkb3LL5cc wrv2yYxEkVK9ykPWrxprivuTyXlLjL78uNkq3ZRJH2Rf2DkSJ+5Gealg7ORsD9iJOduU 860gNElcphKyiRIhuedmDp/iuLpOviPZrgrcCsntbKnwqclNROQOosy59GumdDyzi733 +pKYW39pcuMxy/7QG91ZOwOVK0n88dcuQ2LhGTCMjP7acdZD3ny5qP+LMe/Uo/UtxBU5 8yPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=X6KzAO+3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i69si8505779pgd.71.2019.02.01.14.08.57; Fri, 01 Feb 2019 14:09:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=X6KzAO+3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727586AbfBAWIc (ORCPT + 99 others); Fri, 1 Feb 2019 17:08:32 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:40759 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727382AbfBAWI3 (ORCPT ); Fri, 1 Feb 2019 17:08:29 -0500 Received: by mail-pg1-f195.google.com with SMTP id z10so3556161pgp.7; Fri, 01 Feb 2019 14:08:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DWtHrAlD/PuoBaMP5Yacl9yw0RDRTuKpO9kH1XLTeNg=; b=X6KzAO+3EiAaIB+E+D/zBPdFOZHti5dUNmhAUtSAhPvajk89ieumQr8YIsojKRffNT LDFoL872dhZqMyjAPq1HqlgCgbOhUTM78s9bX1QVXpLljThCsu6WiwreqHxhVBvuctPv zJ63TSJskDj2Oe1h54DEjsUqPHsT7j0QOkJfnKfWRoism9EdJ4pTNgBj+rgMZ4Aly+qz UN9HSAcGp24cWt9EM1war4touzwM2M6qawTinbAM7OfhL84XmpOINz1jTfsl2XoM9slg 1i2AzFIx9K6XVFarMw+1d3oQthfKlPfHqZZGnkmwGYaVDpnZPapCI9OADV3vWnpKUC/v S4sQ== 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=DWtHrAlD/PuoBaMP5Yacl9yw0RDRTuKpO9kH1XLTeNg=; b=dVHNQQwe6FQoRjrWFeASkNvE2/5rVSRxdb1UBUUrcD0pYXb7bHL+Tdb9SGKqMEQevg p1/65KC4nNgW+hrivaV1klSE+aVjZm3czuDzaBxZ979/bxnWUEspxoR/5k+pHN8gBM5n Zhnwdig9P7ohpx6POVBK3lBKV89+wfXQlo0vmeN+xKRAHYPM+1Ih7J7Jm/QIP533BrGt Zu7e5k4Pnv7ld6yzMcybGVbhG2Et7cs3oredIe3StCG6qqru1K0zGBAvQL8LPhxrOWps SSFcGsmg30J4eojgxqPOZty2GGRpMYruzEE3k0RJWAdrTaVKzeNf/p1rk7HvVdR4nVQI w0mg== X-Gm-Message-State: AJcUukeC3RlzmJ9IiafO40AKZ1XCHZ+mh3CoFr7TqTozN/qDMed2bk1S VnZXxgBtrhTaqRLeMJWsn5iqaflf X-Received: by 2002:a62:c21c:: with SMTP id l28mr40722350pfg.74.1549058907164; Fri, 01 Feb 2019 14:08:27 -0800 (PST) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.250]) by smtp.gmail.com with ESMTPSA id 78sm11142208pft.184.2019.02.01.14.08.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Feb 2019 14:08:26 -0800 (PST) From: Florian Fainelli To: netdev@vger.kernel.org Cc: Florian Fainelli , Michael Chan , "David S. Miller" , Derek Chickles , Satanand Burla , Felix Manlunas , Saeed Mahameed , Leon Romanovsky , Jiri Pirko , Ido Schimmel , Alexandre Belloni , Microchip Linux Driver Support , Jakub Kicinski , Ioana Radulescu , Ioana Ciornei , Greg Kroah-Hartman , Ivan Vecera , Andrew Lunn , Vivien Didelot , Dirk van der Merwe , "Francois H. Theron" , Simon Horman , Quentin Monnet , Daniel Borkmann , Eric Dumazet , John Hurley , Edwin Peer , linux-kernel@vger.kernel.org (open list), linux-rdma@vger.kernel.org (open list:MELLANOX MLX5 core VPI driver), oss-drivers@netronome.com (open list:NETRONOME ETHERNET DRIVERS), devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM) Subject: [RFC net-next 11/13] nfp: Handle SWITCHDEV_PORT_ATTR_GET event Date: Fri, 1 Feb 2019 14:06:55 -0800 Message-Id: <20190201220657.30170-12-f.fainelli@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190201220657.30170-1-f.fainelli@gmail.com> References: <20190201220657.30170-1-f.fainelli@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Following patches will change the way we communicate getting or setting a port's attribute and use a blocking notifier to perform those tasks. Prepare nfp to support receiving notifier events targeting SWITCHDEV_PORT_ATTR_GET and simply translate that into the existing switchdev_ops::switchdev_port_attr_get operation. We register a single blocking switchdev notifier for the entire driver instance and we differentiate a "net" from a "repr" by comparing the network device's netdev_ops with the ones that this driver manages. Signed-off-by: Florian Fainelli --- drivers/net/ethernet/netronome/nfp/nfp_main.c | 14 +++++++++++++- drivers/net/ethernet/netronome/nfp/nfp_net.h | 3 +++ .../net/ethernet/netronome/nfp/nfp_net_common.c | 17 +++++++++++++++++ drivers/net/ethernet/netronome/nfp/nfp_port.c | 15 +++++++++++++++ drivers/net/ethernet/netronome/nfp/nfp_port.h | 5 ++++- 5 files changed, 52 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/nfp_main.c b/drivers/net/ethernet/netronome/nfp/nfp_main.c index 6c10e8d119e4..50c111280cd4 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_main.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_main.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "nfpcore/nfp.h" #include "nfpcore/nfp_cpp.h" @@ -708,6 +709,10 @@ static void nfp_pci_remove(struct pci_dev *pdev) pci_disable_device(pdev); } +static struct notifier_block nfp_swdev_blocking_nb = { + .notifier_call = nfp_switchdev_blocking_event, +}; + static struct pci_driver nfp_pci_driver = { .name = nfp_driver_name, .id_table = nfp_pci_device_ids, @@ -725,9 +730,13 @@ static int __init nfp_main_init(void) nfp_net_debugfs_create(); + err = register_switchdev_blocking_notifier(&nfp_swdev_blocking_nb); + if (err) + goto err_destroy_debugfs; + err = pci_register_driver(&nfp_pci_driver); if (err < 0) - goto err_destroy_debugfs; + goto err_unreg_notifier; err = pci_register_driver(&nfp_netvf_pci_driver); if (err) @@ -737,6 +746,8 @@ static int __init nfp_main_init(void) err_unreg_pf: pci_unregister_driver(&nfp_pci_driver); +err_unreg_notifier: + unregister_switchdev_blocking_notifier(&nfp_swdev_blocking_nb); err_destroy_debugfs: nfp_net_debugfs_destroy(); return err; @@ -746,6 +757,7 @@ static void __exit nfp_main_exit(void) { pci_unregister_driver(&nfp_netvf_pci_driver); pci_unregister_driver(&nfp_pci_driver); + unregister_switchdev_blocking_notifier(&nfp_swdev_blocking_nb); nfp_net_debugfs_destroy(); } diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net.h b/drivers/net/ethernet/netronome/nfp/nfp_net.h index be37c2d6151c..57f7d6d634ea 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net.h +++ b/drivers/net/ethernet/netronome/nfp/nfp_net.h @@ -915,4 +915,7 @@ static inline void nfp_net_debugfs_dir_clean(struct dentry **dir) } #endif /* CONFIG_NFP_DEBUG */ +int nfp_switchdev_blocking_event(struct notifier_block *nb, + unsigned long event, void *ptr); + #endif /* _NFP_NET_H_ */ diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c index 7d2d4241498f..c2c5e7e3aab0 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c @@ -3955,3 +3955,20 @@ void nfp_net_clean(struct nfp_net *nn) unregister_netdev(nn->dp.netdev); nfp_net_reconfig_wait_posted(nn); } + +int nfp_switchdev_blocking_event(struct notifier_block *nb, + unsigned long event, void *ptr) +{ + struct net_device *dev = switchdev_notifier_info_to_dev(ptr); + + if (!nfp_netdev_is_nfp_repr(dev) && + !nfp_netdev_is_nfp_net(dev)) + return NOTIFY_DONE; + + switch (event) { + case SWITCHDEV_PORT_ATTR_GET: + return nfp_port_switchdev_attr_event(event, dev, ptr); + } + + return NOTIFY_DONE; +} diff --git a/drivers/net/ethernet/netronome/nfp/nfp_port.c b/drivers/net/ethernet/netronome/nfp/nfp_port.c index 86bc149ca231..578477242ae9 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_port.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_port.c @@ -59,6 +59,21 @@ const struct switchdev_ops nfp_port_switchdev_ops = { .switchdev_port_attr_get = nfp_port_attr_get, }; +int nfp_port_switchdev_attr_event(unsigned long event, + struct net_device *netdev, + struct switchdev_notifier_port_attr_info *port_attr_info) +{ + int rc; + + if (event != SWITCHDEV_PORT_ATTR_GET) + return NOTIFY_DONE; + + rc = nfp_port_attr_get(netdev, port_attr_info->attr); + port_attr_info->handled = true; + + return notifier_from_errno(rc); +} + int nfp_port_setup_tc(struct net_device *netdev, enum tc_setup_type type, void *type_data) { diff --git a/drivers/net/ethernet/netronome/nfp/nfp_port.h b/drivers/net/ethernet/netronome/nfp/nfp_port.h index b2479a2a49e5..35342f88f715 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_port.h +++ b/drivers/net/ethernet/netronome/nfp/nfp_port.h @@ -10,6 +10,7 @@ struct net_device; struct nfp_app; struct nfp_pf; struct nfp_port; +struct switchdev_notifier_port_attr_info; /** * enum nfp_port_type - type of port NFP can switch traffic to @@ -90,7 +91,9 @@ struct nfp_port { }; extern const struct ethtool_ops nfp_port_ethtool_ops; -extern const struct switchdev_ops nfp_port_switchdev_ops; + +int nfp_port_switchdev_attr_event(unsigned long event, struct net_device *dev, + struct switchdev_notifier_port_attr_info *port_attr_info); __printf(2, 3) u8 *nfp_pr_et(u8 *data, const char *fmt, ...); -- 2.17.1