Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp976901ima; Fri, 1 Feb 2019 14:09:43 -0800 (PST) X-Google-Smtp-Source: ALg8bN7lcPonAfUkz59GZyHtL/Drq1Ucyo4umcq2h8t4yK1nak5dDkA3HBluXCwbr6KsbAfnz0vm X-Received: by 2002:a17:902:f082:: with SMTP id go2mr41509969plb.115.1549058983682; Fri, 01 Feb 2019 14:09:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549058983; cv=none; d=google.com; s=arc-20160816; b=eG5HvuSkOLKMcL91y4qEgoA0CDYa5pKCuNUdOPi6QgBMmaa5zfxTGAGH39UnhzbKEA uGrJh8eprDZYitYJUGd4CvNit3P4sAKlXC/MMsQuTVP20WhvSdLyJdrkzTaw7PfNUzYz UniMd740ve1asGO1OQcHzY/a8457iOakwgF91uIT4t6XKiDnuDSvcsWgUFxRWqCU0x4b K1M/COQRa2hTkSjShcL3wbHljHbR0tIY/zSgg6hmiO2QFA1MUvNRRc/2hbnbsQPlAzrl N+5Fp1wvaFTxKGvHkRDLotxXqa89pZba1JqlaaPQMJJaFMH9HAeIeTM/+RQv2/+NdZN1 EhQQ== 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=d0nRYwYgw+BvFa1D+GykoH9AaCUY4nMLAH6xm5Ojg0w=; b=w98tEZ8fnrd9TiZA0XjyzayEyHk8oVDREqhzvQ55SPz1X9cj0PtE2sugdDgNMqBqUc mYbudrXfGn/h5ckLz/UoGVxe02DuVHaNaHaf+dCIWX3qxwckynQt5egmcyMsz+1x4Xa1 n154f4haLbqqMVxYBkIcBeUpFypdj6mX8P8l6E4JKW0Dfjp2cBhln9GDjNWNQiZPKtFF opPSB5HZ6j5Hi0NtR2Ij0ZkWetVN2tB8sjfxDSBLoND2fcUtVOIBodJILUdYCTAxCj0M J3ty8HJOW1QurxF0mHVB44puld6zoFrP4iXPU6eH4TbYzpqY6yobKQvDatKtmQ6mkxPo BRkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ufXaa+0t; 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 b11si7818898pgb.536.2019.02.01.14.09.28; Fri, 01 Feb 2019 14:09:43 -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=ufXaa+0t; 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 S1727528AbfBAWIb (ORCPT + 99 others); Fri, 1 Feb 2019 17:08:31 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:38200 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727438AbfBAWI0 (ORCPT ); Fri, 1 Feb 2019 17:08:26 -0500 Received: by mail-pf1-f196.google.com with SMTP id q1so3883915pfi.5; Fri, 01 Feb 2019 14:08:25 -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=d0nRYwYgw+BvFa1D+GykoH9AaCUY4nMLAH6xm5Ojg0w=; b=ufXaa+0t2BtBz+FNsqjVwDo3ktP3OhVjGwYo5GsiYuBMi6cZ+pVveHq2CTr4n57+aE ttGR4rSfJtF63USmPFxV3q30bvrAaUOBwpf5hJoOxnnaU8U79BXh8/YMGwcPIwsaRwY1 ZdSCJLU5m/+/6pJZYBAcXfP9HWhemIjZyMi0/9EYpGFg6OZS4kqvkuP/9ijEUBU3TtR1 EfGIwE4GrLcc3qvzPckFa4ff5CyI8BxD0ukf/D/0LFnvVDxP8Rj5qrjO0RoY4xo6Z2F0 KZLnpPJsr13Zp9cyL3D5RuHtFsxTmyjOMVTjxNKlOcb/pWCvb27uO02HO3fehw1v4H0W uhoA== 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=d0nRYwYgw+BvFa1D+GykoH9AaCUY4nMLAH6xm5Ojg0w=; b=PwxsbWjI8iU1ah1I/hDnASRtORxbMMjQSwTVo7rV5G/LYttMN9OFODKepMD6UlS/7a 6UBJR94aWg3HAmEtgE++6svhOceQ2QYOafDjyinnw/tXfCvNaarOhG0zxVpK/4aDlbFg Q9Nf0C/GlpqrB5NheE28Zi+wspWKQC9krk4RpEwUlEGcXnDy6I4uZqAPUMRRgvpDTSM/ jUU1eOajEA6Rk6MsFhlQTSGa7yIttrQ/bTPj4CzL5iEjLOYeD2mE66Fw71Oe4jWfwnRX NkhAorx4FEl8+hVlZBEhYnTU75mmnefTy+KnFMDoWyWZYlLVh7R5Vq6KKBDs2wfm5lID zhlA== X-Gm-Message-State: AJcUukcrStdxmqdpWpOU3YxnTQL+ISVoGE2wgGjLNsHqH7DMnCeHpI8G lJjAtppt0RK8NAwB2BWZJSDGeJnz X-Received: by 2002:a62:ab0d:: with SMTP id p13mr41193716pff.211.1549058904751; Fri, 01 Feb 2019 14:08:24 -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.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Feb 2019 14:08:23 -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 10/13] net/mlx5e: Handle SWITCHDEV_PORT_ATTR_GET event Date: Fri, 1 Feb 2019 14:06:54 -0800 Message-Id: <20190201220657.30170-11-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 mlx5e/en_rep.c 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 set of representors given that mlx5e_rep_register_vport_reps() gets called for an Ethernet device. Signed-off-by: Florian Fainelli --- .../net/ethernet/mellanox/mlx5/core/en_main.c | 4 +- .../net/ethernet/mellanox/mlx5/core/en_rep.c | 45 ++++++++++++++++++- .../net/ethernet/mellanox/mlx5/core/en_rep.h | 2 +- 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index dee0c8f3d4e9..fcfe1c9d3575 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -5036,7 +5036,9 @@ static void *mlx5e_add(struct mlx5_core_dev *mdev) #ifdef CONFIG_MLX5_ESWITCH if (MLX5_ESWITCH_MANAGER(mdev) && mlx5_eswitch_mode(mdev->priv.eswitch) == SRIOV_OFFLOADS) { - mlx5e_rep_register_vport_reps(mdev); + err = mlx5e_rep_register_vport_reps(mdev); + if (err) + return NULL; return mdev; } #endif diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c index 04736212a21c..9bac78e111c6 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c @@ -1289,6 +1289,21 @@ static const struct switchdev_ops mlx5e_rep_switchdev_ops = { .switchdev_port_attr_get = mlx5e_attr_get, }; +static int mlx5e_rep_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; + + rc = mlx5e_attr_get(dev, port_attr_info->attr); + port_attr_info->handled = true; + + return notifier_from_errno(rc); +} + static const struct net_device_ops mlx5e_netdev_ops_vf_rep = { .ndo_open = mlx5e_vf_rep_open, .ndo_stop = mlx5e_vf_rep_close, @@ -1321,6 +1336,22 @@ static const struct net_device_ops mlx5e_netdev_ops_uplink_rep = { .ndo_get_vf_stats = mlx5e_get_vf_stats, }; +static int mlx5e_rep_swdev_blocking_event(struct notifier_block *nb, + unsigned long event, void *ptr) +{ + struct net_device *netdev = switchdev_notifier_info_to_dev(ptr); + + if (netdev->netdev_ops != &mlx5e_netdev_ops_vf_rep) + return NOTIFY_DONE; + + switch (event) { + case SWITCHDEV_PORT_ATTR_GET: + return mlx5e_rep_swdev_port_attr_event(event, netdev, ptr); + } + + return NOTIFY_DONE; +} + bool mlx5e_eswitch_rep(struct net_device *netdev) { if (netdev->netdev_ops == &mlx5e_netdev_ops_vf_rep || @@ -1798,11 +1829,20 @@ static void *mlx5e_vport_rep_get_proto_dev(struct mlx5_eswitch_rep *rep) return rpriv->netdev; } -void mlx5e_rep_register_vport_reps(struct mlx5_core_dev *mdev) +static struct notifier_block mlx5e_rep_swdev_nb = { + .notifier_call = mlx5e_rep_swdev_blocking_event, +}; + +int mlx5e_rep_register_vport_reps(struct mlx5_core_dev *mdev) { struct mlx5_eswitch *esw = mdev->priv.eswitch; int total_vfs = MLX5_TOTAL_VPORTS(mdev); int vport; + int rc; + + rc = register_switchdev_blocking_notifier(&mlx5e_rep_swdev_nb); + if (rc) + return rc; for (vport = 0; vport < total_vfs; vport++) { struct mlx5_eswitch_rep_if rep_if = {}; @@ -1812,6 +1852,8 @@ void mlx5e_rep_register_vport_reps(struct mlx5_core_dev *mdev) rep_if.get_proto_dev = mlx5e_vport_rep_get_proto_dev; mlx5_eswitch_register_vport_rep(esw, vport, &rep_if, REP_ETH); } + + return rc; } void mlx5e_rep_unregister_vport_reps(struct mlx5_core_dev *mdev) @@ -1822,4 +1864,5 @@ void mlx5e_rep_unregister_vport_reps(struct mlx5_core_dev *mdev) for (vport = total_vfs - 1; vport >= 0; vport--) mlx5_eswitch_unregister_vport_rep(esw, vport, REP_ETH); + unregister_switchdev_blocking_notifier(&mlx5e_rep_swdev_nb); } diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.h b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.h index edd722824697..b9e0507f6100 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.h @@ -162,7 +162,7 @@ struct mlx5e_rep_sq { }; void *mlx5e_alloc_nic_rep_priv(struct mlx5_core_dev *mdev); -void mlx5e_rep_register_vport_reps(struct mlx5_core_dev *mdev); +int mlx5e_rep_register_vport_reps(struct mlx5_core_dev *mdev); void mlx5e_rep_unregister_vport_reps(struct mlx5_core_dev *mdev); bool mlx5e_is_uplink_rep(struct mlx5e_priv *priv); int mlx5e_add_sqs_fwd_rules(struct mlx5e_priv *priv); -- 2.17.1