Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp976067ima; Fri, 1 Feb 2019 14:08:53 -0800 (PST) X-Google-Smtp-Source: ALg8bN4Q3NJ8TsF3+bdLOWDNJOh9THULM50WQvYl8ZzU8e9o5W1xf2YmlGQgnYjhBbgcjxGWGNMD X-Received: by 2002:a17:902:bd86:: with SMTP id q6mr40149667pls.16.1549058933740; Fri, 01 Feb 2019 14:08:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549058933; cv=none; d=google.com; s=arc-20160816; b=Mua27hp38bCiYCw17nPo4r15GI3ShEDvqVCN07kI1AqPajy59eE7d8ENTSNxYwQhTK WXjKrbWgM3zy0tvi3V08iRgRjRLY4owgA8PbkN8Y5A6ifUTk5NSmdMeGwUpYvQHtd29Q Dzt0BngbLL3l824njP30Jg6DzuxmlnwUaX26Ja8FWODqQp7MdV2BxOYE60gsn9FQP2Fk 8BJWVWLgj6xdqcb+Zzt8qfs6MCecPYOB1KUrsuZNyW2xdW1nJaFMFYxUDDkKA4ZiX3gB 4Khz2X9CDrhrT/u6RMbjCzFGxctJlu7MMVFCR6iCEaTLlzoFjGA4Q2H3RsdReT5iwNKP 81kw== 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=S+T17e/diI+UiXLEq42atmBhalipvIFURLEZX7VprqE=; b=ak26ZgKb0I5NjCUZ308WlTxyxGFYobMZ/087UEZAFqcGBDY4HQ8Qj1AHIyUxSm1djd DSyGkQij6bqlfOVl9SqL3JMSTPBwZZ6Z/zsVtOo+BLpcSzTddxYugKHDbRN4EBQlhHyf weY336/ZiSFDg4V+8Y2MCiuSAfQdDchVajvy9N7FQ8wV3BXWlmeMR4KTqQ91UYiOPagY hHiSRzI+AJrcBqJUzUyTZNuEmEHVcuJ7B4ho9dsEWfVsyIroeI7+jQRdTL4ZipwUaf3V wJEP+JqRU2FF7zyI3diysMDTZAUPmMuN539OGY1Fd0mJX2H0RDeJHkUD+m58aLQ7aK2f S9uA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RS6E6qvr; 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 f4si8086859pfc.234.2019.02.01.14.08.38; Fri, 01 Feb 2019 14:08:53 -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=RS6E6qvr; 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 S1727331AbfBAWIV (ORCPT + 99 others); Fri, 1 Feb 2019 17:08:21 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:36546 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727280AbfBAWIT (ORCPT ); Fri, 1 Feb 2019 17:08:19 -0500 Received: by mail-pf1-f194.google.com with SMTP id b85so3888373pfc.3; Fri, 01 Feb 2019 14:08:17 -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=S+T17e/diI+UiXLEq42atmBhalipvIFURLEZX7VprqE=; b=RS6E6qvrnOpEaP08PWRhkUXtx+fZBzOSLxkmBGNKRl7wGLlaPAeI7jwk4JH6me8HkO uA9FGSq9Zyu7N5TV1LNn7qhGHU6Zzvi5bPnBbPvo6TIQuUickHUUUwzQys8I+zfWYMW7 w+/pF10mK3aBEmT4kbDscd6YkY0K6Z+qrTshpkOFjS/TJSvMQJiCSQNEO0ed6iKFynWo rF4dy9fz9krQqM7D11nb018IKg6XxfBjpW6c2zlsYHWmFUJJ+eDio0hZ0SiudVDs/Vf7 PHW+YnGRcxnPncKG5E2I6jNTpas8FaQAFtgRIcYZLioNCbLgYDPuwbAFpUKEJIrfyqxr wMDg== 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=S+T17e/diI+UiXLEq42atmBhalipvIFURLEZX7VprqE=; b=Kf2TKk15ucCEiGgB0HGKRQNQc2FZkkLeMnV/4YXvWrE4K6qzkmgjuR9T3nwzVVxRGy P/8qztEtFlTAlECGeHInv6jl7EHn4dPoVNKcZ2ggXpedwFPzhux2sbk7/URo8wUyYLcd ouC7MB3HFajy2Ah0QZ8nNT7PG0xe0doO5leXjc549voWh1b7xbWVR2iOhRw9r0TLGhbT 9ZY6+t1eTr/72EeJ8ZKS9tGAoZyAtK6AT2OqIBgDqKPSEdUzwFCGKaXKUfQCZaZjcy/V PuSNBoit6y89/D3Pg4mvGUwBQRYY1uReaftFqJ9mvvvCn1UX7Vt6HktNPvI/kMSRLb88 bn4w== X-Gm-Message-State: AJcUukebkDZGSLM862jOwoJKuSBJ23c6Ed0o3Epsi9Wkr2SWVBLnMt4x MIOwiJbNbLczGfYwFqbxfXNdYP66 X-Received: by 2002:a62:3c1:: with SMTP id 184mr41500977pfd.56.1549058897139; Fri, 01 Feb 2019 14:08:17 -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.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Feb 2019 14:08:16 -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 07/13] bnxt: Handle SWITCHDEV_PORT_ATTR_GET event Date: Fri, 1 Feb 2019 14:06:51 -0800 Message-Id: <20190201220657.30170-8-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 bnxt 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 PF from a VF by comparing the network device's netdev_ops with the ones that this driver manages. Signed-off-by: Florian Fainelli --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 58 ++++++++++++++++++- drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c | 4 +- drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.h | 8 +++ 3 files changed, 67 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 6a512871176b..c3178ca4a004 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -10045,6 +10045,45 @@ static const struct net_device_ops bnxt_netdev_ops = { .ndo_get_phys_port_name = bnxt_get_phys_port_name }; +static int bnxt_swdev_port_attr_event(unsigned long event, + struct net_device *dev, + struct switchdev_notifier_port_attr_info *port_attr_info) +{ + int rc; + + if (event != SWITCHDEV_PORT_ATTR_GET) + return NOTIFY_DONE; + + if (bnxt_dev_is_vf_rep(dev)) + rc = bnxt_vf_rep_port_attr_get(dev, port_attr_info->attr); + else + rc = bnxt_port_attr_get(netdev_priv(dev), port_attr_info->attr); + + port_attr_info->handled = true; + return notifier_from_errno(rc); +} + +static int bnxt_switchdev_blocking_event(struct notifier_block *nb, + unsigned long event, void *ptr) +{ + struct net_device *dev = switchdev_notifier_info_to_dev(ptr); + + if (dev->netdev_ops != &bnxt_netdev_ops && + !bnxt_dev_is_vf_rep(dev)) + return NOTIFY_DONE; + + switch (event) { + case SWITCHDEV_PORT_ATTR_GET: + return bnxt_swdev_port_attr_event(event, dev, ptr); + } + + return NOTIFY_DONE; +} + +static struct notifier_block bnxt_swdev_blocking_nb = { + .notifier_call = bnxt_switchdev_blocking_event, +}; + static void bnxt_remove_one(struct pci_dev *pdev) { struct net_device *dev = pci_get_drvdata(pdev); @@ -10817,8 +10856,24 @@ static struct pci_driver bnxt_pci_driver = { static int __init bnxt_init(void) { + int rc; + bnxt_debug_init(); - return pci_register_driver(&bnxt_pci_driver); + rc = register_switchdev_blocking_notifier(&bnxt_swdev_blocking_nb); + if (rc) + goto err_debug; + + rc = pci_register_driver(&bnxt_pci_driver); + if (rc) + goto err_unreg_notifier; + + return rc; + +err_unreg_notifier: + unregister_switchdev_notifier(&bnxt_swdev_blocking_nb); +err_debug: + bnxt_debug_exit(); + return rc; } static void __exit bnxt_exit(void) @@ -10826,6 +10881,7 @@ static void __exit bnxt_exit(void) pci_unregister_driver(&bnxt_pci_driver); if (bnxt_pf_wq) destroy_workqueue(bnxt_pf_wq); + unregister_switchdev_notifier(&bnxt_swdev_blocking_nb); bnxt_debug_exit(); } diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c index 9a25c05aa571..a06f93b49dd5 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c @@ -237,8 +237,8 @@ static void bnxt_vf_rep_get_drvinfo(struct net_device *dev, strlcpy(info->version, DRV_MODULE_VERSION, sizeof(info->version)); } -static int bnxt_vf_rep_port_attr_get(struct net_device *dev, - struct switchdev_attr *attr) +int bnxt_vf_rep_port_attr_get(struct net_device *dev, + struct switchdev_attr *attr) { struct bnxt_vf_rep *vf_rep = netdev_priv(dev); diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.h b/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.h index d7287651422f..ba24ac222182 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.h @@ -32,6 +32,8 @@ bool bnxt_dev_is_vf_rep(struct net_device *dev); int bnxt_dl_eswitch_mode_get(struct devlink *devlink, u16 *mode); int bnxt_dl_eswitch_mode_set(struct devlink *devlink, u16 mode, struct netlink_ext_ack *extack); +int bnxt_vf_rep_port_attr_get(struct net_device *dev, + struct switchdev_attr *attr); #else @@ -61,5 +63,11 @@ static inline bool bnxt_dev_is_vf_rep(struct net_device *dev) { return false; } + +static inline int bnxt_vf_rep_port_attr_get(struct net_device *dev, + struct switchdev_attr *attr) +{ + return -EOPNOTSUPP; +} #endif /* CONFIG_BNXT_SRIOV */ #endif /* BNXT_VFR_H */ -- 2.17.1