Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp976225ima; Fri, 1 Feb 2019 14:09:03 -0800 (PST) X-Google-Smtp-Source: ALg8bN77F/JUBIOSTsXGuBX7kMs8gRqJXzJ/y64jjGIb/yZBHcza9KIMCuYcBg7O8DGeC80/MfDj X-Received: by 2002:a62:4549:: with SMTP id s70mr40761420pfa.233.1549058943448; Fri, 01 Feb 2019 14:09:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549058943; cv=none; d=google.com; s=arc-20160816; b=S+nnRpOKjkkdSSNXUVFlQKXl7ZkpxCgqKEos3l6QyXv4sBvvt6Xtt9i0B5zON2fbve lIXwWbZStXjBMdMJQqrB0TmD8Lu0q4XBdMB3/l05c0GBAr93RxtLYaOu5Pknft3e1v/0 wF3OcKPCozGLzCXbvHFHUaDQLWsOchFRW04sJmJRFt/bUYZH0EVCf+AyLwBilWAxSAmc VOsLX8Hd9mddt8bhfi+A6/JpV94GfshAx+WmwTZohL+uXlfcmg4G26LJzW8Bpv1DV6Tm 1r6evdOYDqzyeoIz35KK/XNUYJ7or/zmHZvGyLSZyjsfPgt/ImzGTAX1L7dwpzAh+/8W tonw== 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=WVEHNsHDA6/vqXNVWaoWZR+03PraIBRPRrx8fH+NeCo=; b=EGOsE41jT/l/J4MlyiM12n34uYe9MTIF9ZsaNDDadm7k/Vlj889R4XSBOxBbL/1wQj TiDQ+1ZcOPJodfCyJaiTda8NPgR688/YK1FFcTPqjhYELSsy7HCLwRLsK/6BgQNPYIUs zTFs6gYaGFXx2ChkFrHxogruJ3z+AF256cy3PsX04QH+kVbQMoibvbL9hnIZSde/ooKM S5NyM4YuxM1ByByhDrOtWCE5G5UCMKyeyG4DwAMqebQL6xLirA8q4UApoYCkTbhAwVID NbZ+vfspHcDK4M9KK9NpxItZyavaZ14/oMyGYAGijhZaWntJg/hNLlvyfPzEEpwpjLUt dbSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mJFqFjju; 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 m10si8093822plt.295.2019.02.01.14.08.48; Fri, 01 Feb 2019 14:09:03 -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=mJFqFjju; 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 S1727469AbfBAWI0 (ORCPT + 99 others); Fri, 1 Feb 2019 17:08:26 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:44091 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727382AbfBAWIX (ORCPT ); Fri, 1 Feb 2019 17:08:23 -0500 Received: by mail-pl1-f193.google.com with SMTP id p4so610348plq.11; Fri, 01 Feb 2019 14:08:22 -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=WVEHNsHDA6/vqXNVWaoWZR+03PraIBRPRrx8fH+NeCo=; b=mJFqFjjuzY+1JIDU4W1Y7VyHLJHhHNL+L1/NMxmkxrctXpmVv6h3dS78wORdiHDPwx 2AKPJlKirGulu+apviWMEvMETGli+1mg6XW3XL44DBIRDdcA4ocRlC/TKMHy5sLbNYUy gc1cMW3Jy0AQwi8Si3eBx8tSm+d6irOjrjd2lbpoVgH+wSqC79GAEHX4fVsLjCEepnun ZYEc9faiolGUwJM1I+AWcHLx09wRELEY8SfCXXw02sBwsWVWdfNHJwOaYN7NUZiK/RDI hQ/BV2aeOdoCKw3fvqAkh/o6/BEUHU9MnLMOQLiWS7zKnG6ZuAtiIgJe7tz3/RqgyloL E5Cw== 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=WVEHNsHDA6/vqXNVWaoWZR+03PraIBRPRrx8fH+NeCo=; b=P1iWoD+2+iujRpOr9OdVtDmOnoGQlx8s8PT0Ab9g0QFfh1UFzbL4JHn0t33yaAT9l3 W3oGvLgnVsUYRrLI8C8Hu+WxJdVIY46du0gbWdNPyGtkVX0XYkAJerMI4YO2nMF0O56M vw1+i1/Ten2VcToCfgtrB50QeaQzocSZXiH30vzgkiUpBWSn4xVc0FqO+H0rlHF96P4B myA92ThqR4S6msfos37MK4xZCVqdnETsdyGWQiGzU0+y5yI9ffboQnzlKIpKqnL4UYtG l3vrQS4oe5Kiy6oygd4CSS8OZT9FhnCeO1u1WIvrW5Qfw9ZhjjUh25O+PEYuZR25Svfd /zvg== X-Gm-Message-State: AJcUukex5xaX9shq0UAnD90GkMZXeaRJQuHIxtnlw57XlzR3VKwgIsVx 6cJOWqsvbgnQgqci5oCj6opeMKTZ X-Received: by 2002:a17:902:6b0c:: with SMTP id o12mr42017462plk.291.1549058902123; Fri, 01 Feb 2019 14:08:22 -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.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Feb 2019 14:08:21 -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 09/13] mlxsw: switchx2: Handle SWITCHDEV_PORT_ATTR_GET event Date: Fri, 1 Feb 2019 14:06:53 -0800 Message-Id: <20190201220657.30170-10-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 check that thet network device maps to the one that switchx2 manages. Signed-off-by: Florian Fainelli --- .../net/ethernet/mellanox/mlxsw/switchx2.c | 43 ++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/switchx2.c b/drivers/net/ethernet/mellanox/mlxsw/switchx2.c index 2d4f213e154d..82fb8f1bb6e9 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/switchx2.c +++ b/drivers/net/ethernet/mellanox/mlxsw/switchx2.c @@ -923,6 +923,36 @@ static const struct switchdev_ops mlxsw_sx_port_switchdev_ops = { .switchdev_port_attr_get = mlxsw_sx_port_attr_get, }; +static int mlxsw_sx_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; + + rc = mlxsw_sx_port_attr_get(dev, port_attr_info->attr); + port_attr_info->handled = true; + return notifier_from_errno(rc); +} + +static int mlxsw_sx_swdev_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 != &mlxsw_sx_port_netdev_ops) + return NOTIFY_DONE; + + switch (event) { + case SWITCHDEV_PORT_ATTR_GET: + return mlxsw_sx_port_attr_event(event, dev, ptr); + } + + return NOTIFY_DONE; +} + static int mlxsw_sx_hw_id_get(struct mlxsw_sx *mlxsw_sx) { char spad_pl[MLXSW_REG_SPAD_LEN] = {0}; @@ -1638,6 +1668,10 @@ static void mlxsw_sx_fini(struct mlxsw_core *mlxsw_core) mlxsw_sx_ports_remove(mlxsw_sx); } +static struct notifier_block mlxsw_sx_swdev_nb = { + .notifier_call = mlxsw_sx_swdev_blocking_event, +}; + static const struct mlxsw_config_profile mlxsw_sx_config_profile = { .used_max_vepa_channels = 1, .max_vepa_channels = 0, @@ -1698,10 +1732,14 @@ static int __init mlxsw_sx_module_init(void) { int err; - err = mlxsw_core_driver_register(&mlxsw_sx_driver); + err = register_switchdev_blocking_notifier(&mlxsw_sx_swdev_nb); if (err) return err; + err = mlxsw_core_driver_register(&mlxsw_sx_driver); + if (err) + goto err_unregister_notifier; + err = mlxsw_pci_driver_register(&mlxsw_sx_pci_driver); if (err) goto err_pci_driver_register; @@ -1710,6 +1748,8 @@ static int __init mlxsw_sx_module_init(void) err_pci_driver_register: mlxsw_core_driver_unregister(&mlxsw_sx_driver); +err_unregister_notifier: + unregister_switchdev_blocking_notifier(&mlxsw_sx_swdev_nb); return err; } @@ -1717,6 +1757,7 @@ static void __exit mlxsw_sx_module_exit(void) { mlxsw_pci_driver_unregister(&mlxsw_sx_pci_driver); mlxsw_core_driver_unregister(&mlxsw_sx_driver); + unregister_switchdev_blocking_notifier(&mlxsw_sx_swdev_nb); } module_init(mlxsw_sx_module_init); -- 2.17.1