From patchwork Fri Feb 1 22:06:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 10793819 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D4600922 for ; Fri, 1 Feb 2019 22:10:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C48A832ED9 for ; Fri, 1 Feb 2019 22:10:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B7CC43328D; Fri, 1 Feb 2019 22:10:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A034832ED9 for ; Fri, 1 Feb 2019 22:10:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726872AbfBAWIF (ORCPT ); Fri, 1 Feb 2019 17:08:05 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:34477 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726116AbfBAWID (ORCPT ); Fri, 1 Feb 2019 17:08:03 -0500 Received: by mail-pg1-f195.google.com with SMTP id d9so57158pgl.1; Fri, 01 Feb 2019 14:08:03 -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=LbwCkocaVeKZW46o1m4njjA34ZciXtRR3TEQF+D/wBU=; b=RFbBGgNSMA6OPWPHXUTOpWh/ElFGHNdZwtHYgjM61k3NqlIo9dpC1aLxyPM4V8B5uy VKgkSPbqCZVF89TOX5KKfknEYZkSAusJsz3zry5+OGxQqOLnod2HicqtQJSdjMp62FxU uFRVjsCTiOQ5LfQPA6xFh/aP2edW0aF5wki3f7oeGe260yH+EBt4rtV7ujyfDNOzbMiW pqAFHKx5EYwfqLAqBvVq1wOSfLvxPoafCjWmGLE3n/G06h2Cq33InUW/QhNB/GVkBR7E gGLDbQSzk+/7tJ74M1qU3STSgHY/CmB+U2F3NKlbaApqiHWdIITWfMBlA8EPxXUKNFM2 9iGg== 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=LbwCkocaVeKZW46o1m4njjA34ZciXtRR3TEQF+D/wBU=; b=G08xC/FWwBqSKke0ZK6OC5KAP1IgFaNaKb2+bIH+Oq0p1+b4l7l7voPrlBRrjya8u6 wF0JPUCNf/Z3vGvdD3kX9VCwjhSTY9HuDdjkj2Dyf1kc4pmPrjPEWxcYD9mn/D/amx3Z vPWHU9+tPgrEHTzhRKHsyXcGWSqElUOhh1QLdoJ+hX63OIlppcrY+rehU7+NHpOHK0ME VHuTFXe6jRea9JSLRiiggTQKiWmGTLVPBi0/z0IdZhMXewCLd4h84ZPc2uWIcsiO1MN3 4CIYUNAYecSS39OtLonixdapzrcb9e3bRfMORxXgPwEiD8HmU+qPdYWmx2hLiQ4/FK0E mfBg== X-Gm-Message-State: AJcUukccAzjxMkLEEwD3WqLXbhgt8zrQUH1/Pf81YE1OBoELNWjwttrZ b0unEB/8Ba8NTfTrKPCQ+jz8iRL4 X-Google-Smtp-Source: ALg8bN47oyaYouRemq/rIUKbK6tZSG2xrL3h7i78UEiZiMWmlflWy2C1l14xqAFJRhKqEasJI7PSsg== X-Received: by 2002:a63:7e1a:: with SMTP id z26mr36401986pgc.216.1549058882394; Fri, 01 Feb 2019 14:08:02 -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.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Feb 2019 14:08:01 -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 01/13] switchdev: Add SWITCHDEV_PORT_ATTR_SET, SWITCHDEV_PORT_ATTR_GET Date: Fri, 1 Feb 2019 14:06:45 -0800 Message-Id: <20190201220657.30170-2-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-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In preparation for allowing switchdev enabled drivers to veto specific attribute settings from within the context of the caller, introduce a new switchdev notifier type for port attributes. Suggested-by: Ido Schimmel Signed-off-by: Florian Fainelli --- include/net/switchdev.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/net/switchdev.h b/include/net/switchdev.h index 63843ae5dc81..e62fb2693e00 100644 --- a/include/net/switchdev.h +++ b/include/net/switchdev.h @@ -145,6 +145,9 @@ enum switchdev_notifier_type { SWITCHDEV_VXLAN_FDB_ADD_TO_DEVICE, SWITCHDEV_VXLAN_FDB_DEL_TO_DEVICE, SWITCHDEV_VXLAN_FDB_OFFLOADED, + + SWITCHDEV_PORT_ATTR_SET, /* Blocking. */ + SWITCHDEV_PORT_ATTR_GET, /* Blocking. */ }; struct switchdev_notifier_info { @@ -167,6 +170,13 @@ struct switchdev_notifier_port_obj_info { bool handled; }; +struct switchdev_notifier_port_attr_info { + struct switchdev_notifier_info info; /* must be first */ + struct switchdev_attr *attr; + struct switchdev_trans *trans; + bool handled; +}; + static inline struct net_device * switchdev_notifier_info_to_dev(const struct switchdev_notifier_info *info) { From patchwork Fri Feb 1 22:06:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 10793817 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0D63F922 for ; Fri, 1 Feb 2019 22:10:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F135632ED9 for ; Fri, 1 Feb 2019 22:10:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E44C532F13; Fri, 1 Feb 2019 22:10:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C72832ED9 for ; Fri, 1 Feb 2019 22:10:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726643AbfBAWKI (ORCPT ); Fri, 1 Feb 2019 17:10:08 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:41390 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726905AbfBAWIG (ORCPT ); Fri, 1 Feb 2019 17:08:06 -0500 Received: by mail-pf1-f195.google.com with SMTP id b7so3874858pfi.8; Fri, 01 Feb 2019 14:08:05 -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=+1Zk2PiDZisJMq0/a8SJAvhMJmNAIi6Lssg2ko3q5F4=; b=BpiVXYoVfsUFnaMTdAP8HoVRfeWlLCkzeuE8KdONfzWzAUjGopUS7k7B2ZFf7c6bxW s7cmqNwWRpysApa4ITRHqtaPZYfMKEny9yxTne/IPfbZjSw4Xgu+hTlx8otTMT3Px7+x YrGL8Pqcpy0p7kg6fEghIxblZ0j90LurVnxMAZsS/kOFeDuoU/SX135NK12ThWvls80z uJ2v9QvJ2YWnbvfvell9Zo1f8kF4Mj1q7yxo3RPnFb6mu0Q4dep7rFn0rS9Mioit3gTl m5woJg9qRKue+j2dpos0engiTinnTuiaGH2HpG+LXqa7wc5Fzn5+QR8AivXkD1LcrwEw d4hw== 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=+1Zk2PiDZisJMq0/a8SJAvhMJmNAIi6Lssg2ko3q5F4=; b=qs77w/hZEAhSOmK590oJQB3K96NMFY1F7jHhXevZJ2Cj7l0Qony+DKkyEFKc2C//2l v/FY3AomK89nIkV1vSNidgIukCbXSmCqumMoZwP3uoRUSXPS/Xtl9t+dMXjs/oPBbsFb PC67eum7tUy3junM7B04Dk2/lam+SDusggHmX828DawCBhFxi52mQPvaabGGtuQxRJKh vj3ja6OQ7TEzoVBDIxm+1tBFvoYUYQ0exRsTYbZFbXRPw5j+3mo1dN/qy5GUPKhu8vLQ vZSyRZ7mOyGQIBucnkd3+REvRx35FjgL95s0KUIEGSRUHXQFCfP2IbkBFp+T5mmLPzR/ IW9A== X-Gm-Message-State: AHQUAuakqQr9nHLD13FLI7s8mU2LdctHXIyF3PgRyvOIx8cCMx/8hASD aMuAaqufPR9bgfelAyGTzPj8UoLy X-Google-Smtp-Source: AHgI3Ibygr1MEEPAJUeeIxuBOR2v+dVHjva/BA27w8cmejBypTL3IEo0KYsfailo9LatKwNbdyi9/A== X-Received: by 2002:a63:1c09:: with SMTP id c9mr1457569pgc.200.1549058884839; Fri, 01 Feb 2019 14:08:04 -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.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Feb 2019 14:08:04 -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 02/13] rocker: Handle SWITCHDEV_PORT_ATTR_GET/SET Date: Fri, 1 Feb 2019 14:06:46 -0800 Message-Id: <20190201220657.30170-3-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-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 rocker to support receiving notifier events targeting SWITCHDEV_PORT_ATTR_GET/SET and simply translate that into the existing rocker_port_attr_{set,get} calls. Signed-off-by: Florian Fainelli --- drivers/net/ethernet/rocker/rocker_main.c | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/net/ethernet/rocker/rocker_main.c b/drivers/net/ethernet/rocker/rocker_main.c index 62a205eba9f7..f25f7b4345b8 100644 --- a/drivers/net/ethernet/rocker/rocker_main.c +++ b/drivers/net/ethernet/rocker/rocker_main.c @@ -2827,6 +2827,27 @@ rocker_switchdev_port_obj_event(unsigned long event, struct net_device *netdev, return notifier_from_errno(err); } +static int +rocker_switchdev_port_attr_event(unsigned long event, struct net_device *netdev, + struct switchdev_notifier_port_attr_info + *port_attr_info) +{ + int err = -EOPNOTSUPP; + + switch (event) { + case SWITCHDEV_PORT_ATTR_SET: + err = rocker_port_attr_set(netdev, port_attr_info->attr, + port_attr_info->trans); + break; + case SWITCHDEV_PORT_ATTR_GET: + err = rocker_port_attr_get(netdev, port_attr_info->attr); + break; + } + + port_attr_info->handled = true; + return notifier_from_errno(err); +} + static int rocker_switchdev_blocking_event(struct notifier_block *unused, unsigned long event, void *ptr) { @@ -2839,6 +2860,9 @@ static int rocker_switchdev_blocking_event(struct notifier_block *unused, case SWITCHDEV_PORT_OBJ_ADD: case SWITCHDEV_PORT_OBJ_DEL: return rocker_switchdev_port_obj_event(event, dev, ptr); + case SWITCHDEV_PORT_ATTR_SET: + case SWITCHDEV_PORT_ATTR_GET: + return rocker_switchdev_port_attr_event(event, dev, ptr); } return NOTIFY_DONE; From patchwork Fri Feb 1 22:06:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 10793813 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 23B5014E1 for ; Fri, 1 Feb 2019 22:10:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 13C4D32F11 for ; Fri, 1 Feb 2019 22:10:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 072C032F25; Fri, 1 Feb 2019 22:10:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9F78232F11 for ; Fri, 1 Feb 2019 22:10:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727027AbfBAWIJ (ORCPT ); Fri, 1 Feb 2019 17:08:09 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:38108 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726116AbfBAWII (ORCPT ); Fri, 1 Feb 2019 17:08:08 -0500 Received: by mail-pl1-f193.google.com with SMTP id e5so3887762plb.5; Fri, 01 Feb 2019 14:08:08 -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=FKCIMCyyfN1QkkeHgOqs2oTy49pc5Z+rv4NjsW0Dv0o=; b=DD257aAjioCFNHxiYzBeOgHIb9oZEXYgIWX6U9NMdBDijp+PBdL5YOlQ+NqHlCZxHK YSRNs0O7nmbfucgo8K/9Kj4N9eEWUJcLBEqU8yqKNvkNoXnCHtpEgEtmWQgt9Hi3z9Fh qVQFWnnlNJSKNAWd1aZ8CPazEOQyinBg5Y6N+ffxExKOhXMOoCmWME8S0NJN/Ew3Jb7S gedunAfF8p3aDtfTSAhryRvV02ZXdBVOR5YNVmCIkb+EkGR7MfHGKp8mcNUGZ72Wt+WQ mOTHJDgEel8XOXVbZWIghpDLRH19K2+MXkgIYwPdfwuWz88LMv0wUETDnX3WyMXum3+o e94g== 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=FKCIMCyyfN1QkkeHgOqs2oTy49pc5Z+rv4NjsW0Dv0o=; b=be2PZNuL29/E7kQZygajX2nlnFTpIXE0yvbpBwqAWAxXDyxv4q5RIbPk8HQMj7n2LV TnrqcFzExKYezK6/CvmD1U6xZ86tq//GdH1XS6n0UzhjjEyJ5vGjmDZuDTXZSBGJbYcP S7A5QusRwxgJRgI63g7EXC1curjpFIhckiM4vVsEmW3fwQmDcKiX4iRCKyQ9fqJ9MO9o fWNxxtqDdYr/lDLCOvys30mI0iAcOiVhYhqu8Xq3HsNRFNiNz5IvaOV3UxIu77l4w3GZ Z06hIxFKb4ObASRzR/lnPVV1mE32xZr3qS/mazTEh3NRmfcG9QPEybPcXoNq8X5EWvRl +JzA== X-Gm-Message-State: AJcUukcD5kpF2HlkcD/W5gcupf9VnyQe0FRjsfrpwH3xmLUQ5tWY3Mzd 4UkJdFqpcLNlX6iCunrvPehagYV2 X-Google-Smtp-Source: ALg8bN5f9VF8ObGdMSocNNty0nu+ftWtyuORRxXb5O+3ntXPqb+HQqBBv4pV4RuPkoWwjBoyRzmC7A== X-Received: by 2002:a17:902:724a:: with SMTP id c10mr42186693pll.51.1549058887257; Fri, 01 Feb 2019 14:08:07 -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.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Feb 2019 14:08:06 -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 03/13] net: dsa: Handle SWITCHDEV_PORT_ATTR_GET/SET Date: Fri, 1 Feb 2019 14:06:47 -0800 Message-Id: <20190201220657.30170-4-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-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 DSA to support receiving notifier events targeting SWITCHDEV_PORT_ATTR_GET/SET and simply translate that into the existing dsa_slave_port_attr_{set,get} calls. Signed-off-by: Florian Fainelli --- net/dsa/slave.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 91de3a663226..bc7d5092a1c7 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -1549,6 +1549,27 @@ dsa_slave_switchdev_port_obj_event(unsigned long event, return notifier_from_errno(err); } +static int +dsa_slave_switchdev_port_attr_event(unsigned long event, + struct net_device *netdev, + struct switchdev_notifier_port_attr_info *port_attr_info) +{ + int err = -EOPNOTSUPP; + + switch (event) { + case SWITCHDEV_PORT_ATTR_SET: + err = dsa_slave_port_attr_set(netdev, port_attr_info->attr, + port_attr_info->trans); + break; + case SWITCHDEV_PORT_ATTR_GET: + err = dsa_slave_port_attr_get(netdev, port_attr_info->attr); + break; + } + + port_attr_info->handled = true; + return notifier_from_errno(err); +} + static int dsa_slave_switchdev_blocking_event(struct notifier_block *unused, unsigned long event, void *ptr) { @@ -1561,6 +1582,9 @@ static int dsa_slave_switchdev_blocking_event(struct notifier_block *unused, case SWITCHDEV_PORT_OBJ_ADD: /* fall through */ case SWITCHDEV_PORT_OBJ_DEL: return dsa_slave_switchdev_port_obj_event(event, dev, ptr); + case SWITCHDEV_PORT_ATTR_SET: /* fallthrough */ + case SWITCHDEV_PORT_ATTR_GET: + return dsa_slave_switchdev_port_attr_event(event, dev, ptr); } return NOTIFY_DONE; From patchwork Fri Feb 1 22:06:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 10793811 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 752E4922 for ; Fri, 1 Feb 2019 22:10:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 61BCB32ED9 for ; Fri, 1 Feb 2019 22:10:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 509A132F25; Fri, 1 Feb 2019 22:10:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E9B3632ED9 for ; Fri, 1 Feb 2019 22:10:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727094AbfBAWIL (ORCPT ); Fri, 1 Feb 2019 17:08:11 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:43176 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727068AbfBAWIK (ORCPT ); Fri, 1 Feb 2019 17:08:10 -0500 Received: by mail-pl1-f194.google.com with SMTP id gn14so3878801plb.10; Fri, 01 Feb 2019 14:08:10 -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=7WmijFqzuqz1KotgSCwjHOSZrSkpByjh6pj33/dW9ug=; b=fhVihm7cJ7mJIdfoZZqjirUZ/PmWZ0q9xHlFia/0EYWqZZzSXcfOHppUWIL380lfhM lQkhrkwWy8t7vpkSl39ti9X5YxbkVN6Wxq2mePHHpClph8a/iV6egW4PrGkjlsgcDUQe UjimpNZbvNo017806FzlHeIVdeMCqZXopiosWO9qgBLpR5TS3lZAZfRisCPwItuvw1Uq XG7F9hnud39qasi6KIT4m81pXOduo/tNMdV7Rc25SGFY/AG/agDABw/LnD8FKWj12evp ntkPf+gAwK1Ybw3PuOuIQ8hgCmm9Xo9dxNELc1kmJyJ39LQp+YSYphqP7r7y+nArnCoC 4JsA== 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=7WmijFqzuqz1KotgSCwjHOSZrSkpByjh6pj33/dW9ug=; b=sfoltEfNFG26TQjHNl64fzwDPBTCIfefm5935StMvZUKlryPHB0tYP3Das+Qr0UwaH HOFqnX0rcf1rQIyJf0oZeIWBzo3qfYaXxLjA5h5i9MQde+AiIVd/7najetlbCIeblFRU OY9SFMnrzOtsGaBnTyWn/kaATse0+TUEfWndYshnRi7k/FcMDNbI5ZD2m9SqCwUY+Vz4 kyu2IcOPq7HgzyjLriTocfODbT/8pnxiXq6RZ9cUetH9K813si5mjr7NlsChJi3NdoZr RkJomd8h6vzoYLKaICcOpwhdCMKpi47UG5Ko3BSIL6v0r8iAbpdeaTYyPe8eN+Rv/wft 71iw== X-Gm-Message-State: AJcUukeRbkXSL37XynPx20gQAUCBc5i+vTN9pML0eDjxr050DuSkduAh N6ckAB4Wem+0VWs1CVkBU7jNLgPN X-Google-Smtp-Source: ALg8bN7TkQCvIb8E6M29Z4CG2Fs+aEvvtqQTH+cgPe9s20nCLfx+vxssmR1cJb+lM9WxbcOlcdSqvg== X-Received: by 2002:a17:902:6acc:: with SMTP id i12mr40371951plt.148.1549058889563; Fri, 01 Feb 2019 14:08:09 -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.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Feb 2019 14:08:08 -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 04/13] mlxsw: spectrum_switchdev: Handle SWITCHDEV_PORT_ATTR_GET/SET Date: Fri, 1 Feb 2019 14:06:48 -0800 Message-Id: <20190201220657.30170-5-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-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 mlxsw to support receiving notifier events targeting SWITCHDEV_PORT_ATTR_GET/SET and simply translate that into the existing mlxsw_sp_port_attr_{set,get} calls. Signed-off-by: Florian Fainelli --- .../mellanox/mlxsw/spectrum_switchdev.c | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c index 0f4e68d31cc3..7c0df736587c 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c @@ -3442,6 +3442,26 @@ mlxsw_sp_switchdev_handle_vxlan_obj_del(struct net_device *vxlan_dev, } } +static int +mlxsw_sp_switchdev_port_attr_event(unsigned long event, struct net_device *dev, + struct switchdev_notifier_port_attr_info *port_attr_info) +{ + int err = -EOPNOTSUPP; + + switch (event) { + case SWITCHDEV_PORT_ATTR_SET: + err = mlxsw_sp_port_attr_set(dev, port_attr_info->attr, + port_attr_info->trans); + break; + case SWITCHDEV_PORT_ATTR_GET: + err = mlxsw_sp_port_attr_get(dev, port_attr_info->attr); + break; + } + + port_attr_info->handled = true; + return notifier_from_errno(err); +} + static int mlxsw_sp_switchdev_blocking_event(struct notifier_block *unused, unsigned long event, void *ptr) { @@ -3465,6 +3485,9 @@ static int mlxsw_sp_switchdev_blocking_event(struct notifier_block *unused, mlxsw_sp_port_dev_check, mlxsw_sp_port_obj_del); return notifier_from_errno(err); + case SWITCHDEV_PORT_ATTR_SET: + case SWITCHDEV_PORT_ATTR_GET: + return mlxsw_sp_switchdev_port_attr_event(event, dev, ptr); } return NOTIFY_DONE; From patchwork Fri Feb 1 22:06:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 10793809 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5EBB6184E for ; Fri, 1 Feb 2019 22:09:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4FE7F32F11 for ; Fri, 1 Feb 2019 22:09:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E23832ED9; Fri, 1 Feb 2019 22:09:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D502D32ED9 for ; Fri, 1 Feb 2019 22:09:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727165AbfBAWIP (ORCPT ); Fri, 1 Feb 2019 17:08:15 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:37420 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727068AbfBAWIO (ORCPT ); Fri, 1 Feb 2019 17:08:14 -0500 Received: by mail-pg1-f193.google.com with SMTP id c25so3567493pgb.4; Fri, 01 Feb 2019 14:08:12 -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=tivljFOS893zZmUss1AVjf+i1kweQ2vQNLirRIESz1o=; b=grqUg/HuLwUO9b1Sjll2jaggLwu4Jh8KL9FlDzkr5JkdKC/QbEayWQQgTiOPC8Mrwo vlOlOLsxCHMlsNxfOfB6KWHsvFv6dzqvrN7nB59vdK0ixcmsfozpMuOZJ7zYM5Kd7a9M cZUKWtLQ/V9TnKBZctnE29cvSpFueo7IYMmltfDAD7iD1yHc/zLrHMvCPpVuY8DNbaza ifYcYOXo79jhtvLK+VpPaNaztdfZKGZC34MROPbx/FA32PeJoPGS7Hh9/RxYNKUWjWgj O6BY4AfCDvZXudJdX1Foj6/BIOeZQMGAXOHQdK0txUjZxWBeydhkmPKMaWKBY3rWZKfr h2ZA== 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=tivljFOS893zZmUss1AVjf+i1kweQ2vQNLirRIESz1o=; b=IBiMRxsHUJ08Ner+QggH9yamZnmJVWvV4DeDRzl84zjpllimGPRyIHtFSM+p5PwIYn pZ9rkME3vOt4hqZ15BcZxVWTOAk9609/BnQ7bmPLYuMrfbPsIgW+GDc9MefFo6R2+RMP t6MgLolISpHfWuxthoVNLrJx/I+CFgFn2mrEcd+43fQNaRUVYRe5iVfn5Bkbm2rFXtch /PXZhkgBHe/p/NTgVZ9+OYk49Wm4ruKwlVRYt2iAYY3oAbHnIiwPbEH4ke3ok9VfaJRu DmR7WW3h/++MldYXzGUBIHgZDHb5DIiSU2isTlp1OS1+OkvuutZlkNrzSjq1hrOo5i09 w5cA== X-Gm-Message-State: AHQUAubCE2dhT9FHZgwZo4nesGpVRbpJbIv229gTCop+8RTgd9eqnAIJ wk+vf/nTKu7uZlQYBHJt0oEwb7AH X-Google-Smtp-Source: AHgI3IbR9i5uG9whlGG/K7jeaJuS+eNly5PVbFi97tkN8wsH7NnnJg+fW6pHwQwFWOht72h4fi/VmA== X-Received: by 2002:a65:49c9:: with SMTP id t9mr3843831pgs.184.1549058892085; Fri, 01 Feb 2019 14:08:12 -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.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Feb 2019 14:08:11 -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 05/13] net: mscc: ocelot: Handle SWITCHDEV_PORT_ATTR_GET/SET Date: Fri, 1 Feb 2019 14:06:49 -0800 Message-Id: <20190201220657.30170-6-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-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 ocelot to support receiving notifier events targeting SWITCHDEV_PORT_ATTR_GET/SET and simply translate that into the existing ocelot_port_attr_{set,get} calls. Signed-off-by: Florian Fainelli --- drivers/net/ethernet/mscc/ocelot.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index c6a575eb0ff5..8043347a1ed4 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -1589,6 +1589,27 @@ struct notifier_block ocelot_netdevice_nb __read_mostly = { }; EXPORT_SYMBOL(ocelot_netdevice_nb); +static int +ocelot_switchdev_port_attr_event(unsigned long event, + struct net_device *netdev, + struct switchdev_notifier_port_attr_info *port_attr_info) +{ + int err = -EOPNOTSUPP; + + switch (event) { + case SWITCHDEV_PORT_ATTR_SET: + err = ocelot_port_attr_set(netdev, port_attr_info->attr, + port_attr_info->trans); + break; + case SWITCHDEV_PORT_ATTR_GET: + err = ocelot_port_attr_get(netdev, port_attr_info->attr); + break; + } + + port_attr_info->handled = true; + return notifier_from_errno(err); +} + static int ocelot_switchdev_blocking_event(struct notifier_block *unused, unsigned long event, void *ptr) { @@ -1607,6 +1628,9 @@ static int ocelot_switchdev_blocking_event(struct notifier_block *unused, ocelot_netdevice_dev_check, ocelot_port_obj_del); return notifier_from_errno(err); + case SWITCHDEV_PORT_ATTR_SET: + case SWITCHDEV_PORT_ATTR_GET: + return ocelot_switchdev_port_attr_event(event, dev, ptr); } return NOTIFY_DONE; From patchwork Fri Feb 1 22:06:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 10793807 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E298C922 for ; Fri, 1 Feb 2019 22:09:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D423432E9E for ; Fri, 1 Feb 2019 22:09:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C6C8B32F11; Fri, 1 Feb 2019 22:09:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B39A32E9E for ; Fri, 1 Feb 2019 22:09:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727192AbfBAWIQ (ORCPT ); Fri, 1 Feb 2019 17:08:16 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:45126 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727172AbfBAWIQ (ORCPT ); Fri, 1 Feb 2019 17:08:16 -0500 Received: by mail-pl1-f196.google.com with SMTP id a14so3868221plm.12; Fri, 01 Feb 2019 14:08:15 -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=EdvrqqPZG0RgbxnptDAB2xEG3F6tOGq5U35WAFrinLM=; b=NMwusL59e8LfyNukpg+9B8SRXJf4O3Z+ARaXPyWpHixRDIn6Im0+RieGNy9wP0WZoK sL8azsQ3duXP//83E1I5Y1VrzWsy+xR+PMHLa9yKVIFiIHpe8zTtiOM3GH2ProZalQAI QynYityGiwK8mqEZ/ahD+ubU4pvdXa9miaDtcKB32gk5sG8OmjVjGDRsObtC4d0Bi764 hBAAKgxonZB+PdEhbxYqaiIM0idvesPTM+RTIxnb8D+2Rbn5A98g309F0U528uwkRq5g AFG6/jxCABwT9uW7gBNA2FX21v/G6siMomGj8oYeY+4Hx5W7dywBcY02kusA8gKHlNbF Fwvg== 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=EdvrqqPZG0RgbxnptDAB2xEG3F6tOGq5U35WAFrinLM=; b=R2npwtq5M1LszeKEFJpaoKFgU+IbhdalMSndz4EVlumwl9oeqX16OX3tXmvbCWEiZ+ rkoxemGSuisEaEoLg0xu/7NsKrtj+QuxjnKrlwlSOwqL+am80vVGUqRaBlYI+SuOXf4O TYBEMR4xubm6I99KI3OXEACQL+E0KMhof74F7uFBN7nxDCTw/wV3B0bruCx0KGfUdVgJ Eul0xndzi5ukSk1+41zZAWNQNcunUVD6sVhzLcjzb46rERyThLSh+3971+4Uaubd0tlS VNGmKTJt7LMWFQRWBefi62JYBRHIRMH8z2kxDEFiwRA0b5I3rbkqZX8vhmhF8d+yCw3F oGxw== X-Gm-Message-State: AJcUukdaS9Iuv4aT0nv0mE9kytgWtnYUeUXm9FW6BBl62PBTIa4+TQGm NYF0S2udKsmad3LR0xk4Ma6OulZz X-Google-Smtp-Source: ALg8bN5Lh0tscJjEvu47XQxN0Ee13nVs9I7Tt/Dfb5i80Oxe4NkraPsbHXWoLKSvbwb4fTUQ1zC5xg== X-Received: by 2002:a17:902:848f:: with SMTP id c15mr34045596plo.119.1549058894650; Fri, 01 Feb 2019 14:08:14 -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.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Feb 2019 14:08:13 -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 06/13] staging: fsl-dpaa2: ethsw: Handle SWITCHDEV_PORT_ATTR_GET/SET Date: Fri, 1 Feb 2019 14:06:50 -0800 Message-Id: <20190201220657.30170-7-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-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 ethsw to support receiving notifier events targeting SWITCHDEV_PORT_ATTR_GET/SET and simply translate that into the existing swdev_port_attr_{set,get} calls. Signed-off-by: Florian Fainelli --- drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c index daabaceeea52..b18e112d84e6 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c @@ -1103,6 +1103,27 @@ ethsw_switchdev_port_obj_event(unsigned long event, struct net_device *netdev, return notifier_from_errno(err); } +static int +ethsw_switchdev_port_attr_event(unsigned long event, + struct net_device *netdev, + struct switchdev_notifier_port_attr_info *port_attr_info) +{ + int err = -EOPNOTSUPP; + + switch (event) { + case SWITCHDEV_PORT_ATTR_SET: + err = swdev_port_attr_set(netdev, port_attr_info->attr, + port_attr_info->trans); + break; + case SWITCHDEV_PORT_ATTR_GET: + err = swdev_port_attr_get(netdev, port_attr_info->attr); + break; + } + + port_attr_info->handled = true; + return notifier_from_errno(err); +} + static int port_switchdev_blocking_event(struct notifier_block *unused, unsigned long event, void *ptr) { @@ -1115,6 +1136,9 @@ static int port_switchdev_blocking_event(struct notifier_block *unused, case SWITCHDEV_PORT_OBJ_ADD: /* fall through */ case SWITCHDEV_PORT_OBJ_DEL: return ethsw_switchdev_port_obj_event(event, dev, ptr); + case SWITCHDEV_PORT_ATTR_SET: + case SWITCHDEV_PORT_ATTR_GET: + return ethsw_switchdev_port_attr_event(event, dev, ptr); } return NOTIFY_DONE; From patchwork Fri Feb 1 22:06:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 10793799 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 45097922 for ; Fri, 1 Feb 2019 22:09:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0DEFD3258B for ; Fri, 1 Feb 2019 22:09:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 00DF0325EF; Fri, 1 Feb 2019 22:09:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7302C3258B for ; Fri, 1 Feb 2019 22:09:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727290AbfBAWIU (ORCPT ); Fri, 1 Feb 2019 17:08:20 -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-Google-Smtp-Source: ALg8bN5LNNL0Dhaq4dEfmya15TWqj0PF4bPO1oBAszIt2yI6kn1qUWF+udsnIcTYsLYRFo/ujk2q0w== 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-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 */ From patchwork Fri Feb 1 22:06:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 10793797 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1F200184E for ; Fri, 1 Feb 2019 22:09:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E77893258A for ; Fri, 1 Feb 2019 22:09:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DA502325EF; Fri, 1 Feb 2019 22:09:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 54CA23258A for ; Fri, 1 Feb 2019 22:09:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727348AbfBAWIW (ORCPT ); Fri, 1 Feb 2019 17:08:22 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:33749 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727312AbfBAWIV (ORCPT ); Fri, 1 Feb 2019 17:08:21 -0500 Received: by mail-pf1-f196.google.com with SMTP id c123so3897994pfb.0; Fri, 01 Feb 2019 14:08:20 -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=ADHtnf2Pyj7Bb3/Osgn+6/bvWFlSO/mVEntxDCFTFHg=; b=aEnvDuZf2q2uToeKMG64FV2JZJmWkZU58TMfGpEQ2A489Od1iGs9Qt5g4k8DgKmVCM xKqGXnqKfUV1LXYlAp2/gd00E/L0eTTIZ/F2Yytlvm/9VUykbtIs3ONkMf6KPVoir4Pw Jyq/FlGUCtXm3wg39JKQV5yxn/4x+R9Z7i1nxGPYnF3OBZhNj4fkqp9PxIGlQ/MMLQ8c Z/YdlwuC+2KVvJNhap/EcK/MNYgoBOi4lCwGU4OFDV344DdR+ptLuIlfhNPeHmWonFMQ 5U5u+DaYrBKRfLeKHDjRFw4TqYwqfiAmp7Gbb3pFW+2m1k0ZHyKzO9v39jkaPRKPauMa Os0A== 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=ADHtnf2Pyj7Bb3/Osgn+6/bvWFlSO/mVEntxDCFTFHg=; b=P1paGSbf3r6y6U5YRJ4KB8nDuS850mI74TTN1IMlO7cf0QbAtzb9gmdOG0D3iq2h6i vyXffT9Nz08O5rr+zwbSKCv1KMSOPlQg2MWAnsS/rtDQH21SiTSBF8ggBQsOjjRnloap I4yZ6dxIQ21G9VM6ipKBFFm4btrPe1LPza2gWmnusU+oJGYrG9DOLpSO7smC5HV1VAr8 nFa1YE1G4mkk3yMyuuNcMLSEti+u3odNO++YvGp7e9Bk+sJGgZAeeKZ1+O7AEjlDCdri CdZEtxVErojGfnv/gyLQuM+PynSWBe7rDf0G8r84D6BjCKH3Ak7P0dU7rzzVqARRCRBD PsWw== X-Gm-Message-State: AHQUAuYhUorPfSChyeYuNoNIP1wWj2QIMyit/kFROGXhnP0kNArEKSZu lnwmCk3GiCZdvWzKlGi6UKSLsYxO X-Google-Smtp-Source: AHgI3Iba5jsGxoXHqXMZb+6zYCQhnXp3mJs1a4NSMSkT3l9wejkidJAyikZQAQNmYBKa/tzbLzdprA== X-Received: by 2002:a65:49cd:: with SMTP id t13mr4016431pgs.376.1549058899738; Fri, 01 Feb 2019 14:08:19 -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.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Feb 2019 14:08:18 -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 08/13] liquidio: Handle SWITCHDEV_PORT_ATTR_GET event Date: Fri, 1 Feb 2019 14:06:52 -0800 Message-Id: <20190201220657.30170-9-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-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 PF part of the driver, and we register another blocking switchdev notifier, following what was done with the existing netdevice notifier within the VF representor driver. Signed-off-by: Florian Fainelli --- .../net/ethernet/cavium/liquidio/lio_main.c | 48 ++++++++++++++++++- .../net/ethernet/cavium/liquidio/lio_vf_rep.c | 45 ++++++++++++++++- 2 files changed, 91 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c b/drivers/net/ethernet/cavium/liquidio/lio_main.c index 3d24133e5e49..b9d48e4181fc 100644 --- a/drivers/net/ethernet/cavium/liquidio/lio_main.c +++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c @@ -162,6 +162,8 @@ static int liquidio_set_vf_link_state(struct net_device *netdev, int vfidx, static struct handshake handshake[MAX_OCTEON_DEVICES]; static struct completion first_stage; +static int liquidio_switchdev_blocking_event(struct notifier_block *nb, + unsigned long event, void *ptr); static void octeon_droq_bh(unsigned long pdev) { @@ -469,12 +471,25 @@ static struct pci_driver liquidio_pci_driver = { #endif }; +static struct notifier_block liquidio_blocking_nb = { + .notifier_call = liquidio_switchdev_blocking_event, +}; + /** * \brief register PCI driver */ static int liquidio_init_pci(void) { - return pci_register_driver(&liquidio_pci_driver); + int rc; + + rc = register_switchdev_blocking_notifier(&liquidio_blocking_nb); + if (rc) + return rc; + rc = pci_register_driver(&liquidio_pci_driver); + if (rc) + unregister_switchdev_blocking_notifier(&liquidio_blocking_nb); + + return rc; } /** @@ -483,6 +498,7 @@ static int liquidio_init_pci(void) static void liquidio_deinit_pci(void) { pci_unregister_driver(&liquidio_pci_driver); + unregister_switchdev_blocking_notifier(&liquidio_blocking_nb); } /** @@ -3261,6 +3277,36 @@ static const struct net_device_ops lionetdevops = { .ndo_get_vf_stats = liquidio_get_vf_stats, }; +static int lio_pf_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 = lio_pf_switchdev_attr_get(dev, port_attr_info->attr); + + port_attr_info->handled = true; + return notifier_from_errno(rc); +} + +static int liquidio_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 != &lionetdevops) + return NOTIFY_DONE; + + switch (event) { + case SWITCHDEV_PORT_ATTR_GET: + return lio_pf_attr_event(event, dev, ptr); + } + + return NOTIFY_DONE; +} + /** \brief Entry point for the liquidio module */ static int __init liquidio_init(void) diff --git a/drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c b/drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c index de61060721c4..d396c004c1be 100644 --- a/drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c +++ b/drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c @@ -468,6 +468,21 @@ static const struct switchdev_ops lio_vf_rep_switchdev_ops = { .switchdev_port_attr_get = lio_vf_rep_attr_get, }; +static int lio_vf_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 = lio_vf_rep_attr_get(dev, port_attr_info->attr); + port_attr_info->handled = true; + + return notifier_from_errno(rc); +} + static void lio_vf_rep_fetch_stats(struct work_struct *work) { @@ -538,7 +553,6 @@ lio_vf_rep_create(struct octeon_device *oct) if (register_netdev(ndev)) { dev_err(&oct->pci_dev->dev, "VF rep nerdev registration failed\n"); - free_netdev(ndev); goto cleanup; } @@ -664,20 +678,49 @@ static struct notifier_block lio_vf_rep_netdev_notifier = { .notifier_call = lio_vf_rep_netdev_event, }; +static int lio_vf_rep_swdev_event(struct notifier_block *nb, + unsigned long event, void *ptr) +{ + struct net_device *ndev = switchdev_notifier_info_to_dev(ptr); + + if (ndev->netdev_ops != &lio_vf_rep_ndev_ops) + return NOTIFY_DONE; + + switch (event) { + case SWITCHDEV_PORT_ATTR_GET: + return lio_vf_rep_swdev_port_attr_event(event, ndev, ptr); + } + + return NOTIFY_DONE; +} + +static struct notifier_block lio_vf_rep_swdev_nb = { + .notifier_call = lio_vf_rep_swdev_event, +}; + int lio_vf_rep_modinit(void) { + int rc; + if (register_netdevice_notifier(&lio_vf_rep_netdev_notifier)) { pr_err("netdev notifier registration failed\n"); return -EFAULT; } + rc = register_switchdev_blocking_notifier(&lio_vf_rep_swdev_nb); + if (rc) { + unregister_netdevice_notifier(&lio_vf_rep_netdev_notifier); + return rc; + } + return 0; } void lio_vf_rep_modexit(void) { + unregister_switchdev_blocking_notifier(&lio_vf_rep_swdev_nb); if (unregister_netdevice_notifier(&lio_vf_rep_netdev_notifier)) pr_err("netdev notifier unregister failed\n"); } From patchwork Fri Feb 1 22:06:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 10793795 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 03D1B14E1 for ; Fri, 1 Feb 2019 22:09:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BEB303258B for ; Fri, 1 Feb 2019 22:09:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B2BB3325EF; Fri, 1 Feb 2019 22:09:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4438E3258B for ; Fri, 1 Feb 2019 22:09:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727449AbfBAWIZ (ORCPT ); Fri, 1 Feb 2019 17:08:25 -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-Google-Smtp-Source: ALg8bN7czyIItSX6mC+lYi9u4WKeOO+wZqlrtggBXdhwSnQuaF8wHMVnd+3G9mdgxGKqqVGxx5ewFw== 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-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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); From patchwork Fri Feb 1 22:06:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 10793793 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CE661922 for ; Fri, 1 Feb 2019 22:09:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F41F3258A for ; Fri, 1 Feb 2019 22:09:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 334B7325EF; Fri, 1 Feb 2019 22:09:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A34933258A for ; Fri, 1 Feb 2019 22:09:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727487AbfBAWIa (ORCPT ); Fri, 1 Feb 2019 17:08:30 -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-Google-Smtp-Source: ALg8bN7dGetpsRt7sWuGC2QAdBn2H+C9JN82l8qmaOY/oCStiZOMTqPkAAkN9Tm06rjLXPQwZZi/YQ== 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-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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); From patchwork Fri Feb 1 22:06:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 10793791 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4E361922 for ; Fri, 1 Feb 2019 22:09:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D6BB33258B for ; Fri, 1 Feb 2019 22:09:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C3B4F3258A; Fri, 1 Feb 2019 22:09:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 337EC3258A for ; Fri, 1 Feb 2019 22:09:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727511AbfBAWIa (ORCPT ); Fri, 1 Feb 2019 17:08:30 -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-Google-Smtp-Source: ALg8bN7dZc8Ee/XVx2Rpmpd5JiP+yRwQ1p8ynfhNaejdlnVy9IfbNPYlt2BjbmcWLuFp6/Q68UOCsg== 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-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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, ...); From patchwork Fri Feb 1 22:06:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 10793789 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D98A4922 for ; Fri, 1 Feb 2019 22:08:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF54E30F8D for ; Fri, 1 Feb 2019 22:08:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AEB8130E6C; Fri, 1 Feb 2019 22:08:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C73652F5F7 for ; Fri, 1 Feb 2019 22:08:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727690AbfBAWIs (ORCPT ); Fri, 1 Feb 2019 17:08:48 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:40762 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726297AbfBAWIb (ORCPT ); Fri, 1 Feb 2019 17:08:31 -0500 Received: by mail-pg1-f195.google.com with SMTP id z10so3556202pgp.7; Fri, 01 Feb 2019 14:08:30 -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=04O41FbtAgkXOgQua67kjcOBDU2UbpbkCof4gdxmXAg=; b=DWQtqjFAp/EFRXjtzJVijfxL13hxzWPXWrXn8AMdh1vyBc1ShDgTwc79WI02XMCGRL Rg2To9T44DeIQ9WNVidzBkLc+Sib3i9TDiAwcKVyjvxM3Eb8IgTHLV59l4m48q5PhGMi o1EtQQ8fBDchlWfLBpbXH7TKJ/f75H3n68X4gCVemI08pIhJy1DK8E2BSt1V86/kRtK5 ylLDKTDRI7LkKf9vJilxyMSJTTjJ+se5vGBSLLXFpNI0bAjfeRVi3eXBBsg76PNXqbYD //VsG+zo4/WmBB5owVmeTkyY4jvRusdk03qoKoebhJsFMgM+Vkmume+FRdA56yCvgLaU HJ5Q== 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=04O41FbtAgkXOgQua67kjcOBDU2UbpbkCof4gdxmXAg=; b=piBLAmPCpuv9gzgQt+xcbHN0c/6+g48lenipFY4R3xhfbG3FxdMF126Pq6bMhS2REc pwpNZ2JX+eEpktmcgAXCMLviXqxvzvmjbdXUQOFrc6O+wShXbYLqtIC+zuZcZ1Ds+cO/ SWkZ09664N935SgJU2HjqxO7WYFLA0OESrN5QO2fpiO9ApHM3WrtgsSB5AZNjYxPSalV 3RNGi2+8Bn1C8EOF6PLCTyB2Fy3BHXDtgOQ7XR8xtILe2ORdkZsWFFK82cosXniS66Gu 2Zlr/j4WTyg2fvwBgTW3h6fA99y5kfB4QzbGPicaQSiIgk6x2HUTxcppqOUjOmWRrj28 DkaA== X-Gm-Message-State: AHQUAubTyz2Zaf6bELRBQVNAFVd/U2QglbLbIe2mEXZ8BxqU9Wkn0QBS j8pc3oH+VD1i4NdXlxjFoEYxrWxG X-Google-Smtp-Source: AHgI3IZx/LHZM1kP2e/f5uUHasGGpzGyT/o0sSwpNXNITurE8NKtBwUeri8CfQR0MDSFljjLyODWNg== X-Received: by 2002:a63:5320:: with SMTP id h32mr3980916pgb.414.1549058909880; Fri, 01 Feb 2019 14:08:29 -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.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Feb 2019 14:08:28 -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 12/13] netdevsim: Handle SWITCHDEV_PORT_ATTR_GET event Date: Fri, 1 Feb 2019 14:06:56 -0800 Message-Id: <20190201220657.30170-13-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-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 netdevsim 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. Signed-off-by: Florian Fainelli --- drivers/net/netdevsim/netdev.c | 43 +++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/drivers/net/netdevsim/netdev.c b/drivers/net/netdevsim/netdev.c index 8d8e2b3f263e..817d94cec90f 100644 --- a/drivers/net/netdevsim/netdev.c +++ b/drivers/net/netdevsim/netdev.c @@ -168,6 +168,20 @@ static const struct switchdev_ops nsim_switchdev_ops = { .switchdev_port_attr_get = nsim_port_attr_get, }; +static int nsim_switchdev_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 = nsim_port_attr_get(dev, port_attr_info->attr); + port_attr_info->handled = true; + return notifier_from_errno(rc); +} + static int nsim_init(struct net_device *dev) { char sdev_ddir_name[10], sdev_link_name[32]; @@ -495,6 +509,26 @@ static const struct net_device_ops nsim_netdev_ops = { .ndo_bpf = nsim_bpf, }; +static int nsim_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 != &nsim_netdev_ops) + return NOTIFY_DONE; + + switch (event) { + case SWITCHDEV_PORT_ATTR_GET: + return nsim_switchdev_port_attr_event(event, dev, ptr); + } + + return NOTIFY_DONE; +} + +static struct notifier_block nsim_swdev_blocking_nb = { + .notifier_call = nsim_swdev_blocking_event, +}; + static void nsim_setup(struct net_device *dev) { ether_setup(dev); @@ -583,10 +617,14 @@ static int __init nsim_module_init(void) goto err_debugfs_destroy; } - err = bus_register(&nsim_bus); + err = register_switchdev_blocking_notifier(&nsim_swdev_blocking_nb); if (err) goto err_sdir_destroy; + err = bus_register(&nsim_bus); + if (err) + goto err_unreg_notifier; + err = nsim_devlink_init(); if (err) goto err_unreg_bus; @@ -601,6 +639,8 @@ static int __init nsim_module_init(void) nsim_devlink_exit(); err_unreg_bus: bus_unregister(&nsim_bus); +err_unreg_notifier: + unregister_switchdev_blocking_notifier(&nsim_swdev_blocking_nb); err_sdir_destroy: debugfs_remove_recursive(nsim_sdev_ddir); err_debugfs_destroy: @@ -613,6 +653,7 @@ static void __exit nsim_module_exit(void) rtnl_link_unregister(&nsim_link_ops); nsim_devlink_exit(); bus_unregister(&nsim_bus); + unregister_switchdev_blocking_notifier(&nsim_swdev_blocking_nb); debugfs_remove_recursive(nsim_sdev_ddir); debugfs_remove_recursive(nsim_ddir); } From patchwork Fri Feb 1 22:06:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 10793787 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9C2DB14E1 for ; Fri, 1 Feb 2019 22:08:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E1D22E310 for ; Fri, 1 Feb 2019 22:08:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6D72632F72; Fri, 1 Feb 2019 22:08:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA8732E310 for ; Fri, 1 Feb 2019 22:08:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727608AbfBAWIf (ORCPT ); Fri, 1 Feb 2019 17:08:35 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:38548 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727602AbfBAWIe (ORCPT ); Fri, 1 Feb 2019 17:08:34 -0500 Received: by mail-pg1-f194.google.com with SMTP id g189so3565346pgc.5; Fri, 01 Feb 2019 14:08:33 -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=XLkDYhUb/aZ1XjvGin6JaZPz43hidzlD+os/K3dazis=; b=ulsj/1GjaOjkm+1DZHql3SXOgGAoXiWvvbYcHo0I0cVNrWG1B2imZ4/cr/QU+DGKJW cmgpgWWsGx0a27x5LrVHHu2E+PdqwIsEnA6eslQUY5rnGVXEGaOT01EZmK1BJDaLMViy lzQkRgkOo1X5d6yzg17qI82922e0IifLEXH7HDvTcns1RMjowlVEOaE6lTqO8qMqXSml 24K7RhlDGtqgVPtH3VA9UD3GN7MpmQBOR6nmjKYJWL4s8QdbwoWuQLWfCOlKDeZQ1IMl Pf2p5G6LDNPbtvDs1Pq7uZTAzYnGjXekTYwXij03L1WptQVw5ekYHZ+fz+AP333O1jkE 8abw== 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=XLkDYhUb/aZ1XjvGin6JaZPz43hidzlD+os/K3dazis=; b=PjWHyAWep8Ntv5zn6QoYdFYA21Vfz2QAcxRa4qazRR+IXg7Vp/By0dluWm/a/SW7nN MSYkR0NxBPTQdDAZvdVV5wEbIE87sl7t4TaoZ2tBVmi2WGk5MwoujAeROBxeNY+Lj00H OblDDCW+TFySHiVeOOT/EEC54pp/eHTbsbueJm59ohm4d/MuUoI3qkeZRssDcs2X0xHi 6zPmGlgE7QMK97DlR/NvAON88gnRe7jgZIxjV2DWKdkoO8TZmZgMOrBCa6FBB9znsQA1 1RCnEDXiI19Bw3UxzdcgU/RbF+EcOUdA+HT9A3ulLiHgZ9EKlkQ1CPDvv7KyrGmrfzYa mmcQ== X-Gm-Message-State: AHQUAuadKMY3D5cJpC6CRzxMIIJprw/SKmQcizQ4mSExRTPXNFE29f7T XD0UH0KXkiwdQg9IqGYJzhfAmCQd X-Google-Smtp-Source: AHgI3IbNuIb7cdUp+wyrNFAY7/UHzGSnDPfwUPxkkckcwbeFHIFs+HSYi1mVFDw1ADA/ESOvbUrj9w== X-Received: by 2002:a65:5c4b:: with SMTP id v11mr3957068pgr.333.1549058912422; Fri, 01 Feb 2019 14:08:32 -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.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Feb 2019 14:08:31 -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 13/13] net: switchdev: Replace port attr get/set SDO with a notification Date: Fri, 1 Feb 2019 14:06:57 -0800 Message-Id: <20190201220657.30170-14-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-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Drop switchdev_ops.switchdev_port_attr_get and _set. Drop the uses of this field from all clients, which were migrated to use switchdev notification in the previous patches. Add a new function switchdev_port_attr_notify() that sends the switchdev notifications SWITCHDEV_PORT_ATTR_GET and _SET. Update switchdev_port_attr_get() to dispatch to this new function. Drop __switchdev_port_attr_set() and update switchdev_port_attr_set() likewise. Signed-off-by: Florian Fainelli --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 5 - drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c | 5 - .../net/ethernet/cavium/liquidio/lio_main.c | 5 - .../net/ethernet/cavium/liquidio/lio_vf_rep.c | 5 - .../net/ethernet/mellanox/mlx5/core/en_rep.c | 7 -- .../net/ethernet/mellanox/mlxsw/spectrum.c | 12 -- .../net/ethernet/mellanox/mlxsw/spectrum.h | 2 - .../mellanox/mlxsw/spectrum_switchdev.c | 13 --- .../net/ethernet/mellanox/mlxsw/switchx2.c | 5 - drivers/net/ethernet/mscc/ocelot.c | 6 - .../ethernet/netronome/nfp/nfp_net_common.c | 2 - .../net/ethernet/netronome/nfp/nfp_net_repr.c | 2 - drivers/net/ethernet/netronome/nfp/nfp_port.c | 4 - drivers/net/ethernet/rocker/rocker_main.c | 6 - drivers/net/netdevsim/netdev.c | 5 - drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 6 - include/linux/netdevice.h | 3 - include/net/switchdev.h | 18 --- net/dsa/slave.c | 6 - net/switchdev/switchdev.c | 107 ++++++------------ 20 files changed, 37 insertions(+), 187 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index c3178ca4a004..78d2d76de1a7 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -10007,10 +10007,6 @@ static int bnxt_swdev_port_attr_get(struct net_device *dev, return bnxt_port_attr_get(netdev_priv(dev), attr); } -static const struct switchdev_ops bnxt_switchdev_ops = { - .switchdev_port_attr_get = bnxt_swdev_port_attr_get -}; - static const struct net_device_ops bnxt_netdev_ops = { .ndo_open = bnxt_open, .ndo_start_xmit = bnxt_start_xmit, @@ -10439,7 +10435,6 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) dev->netdev_ops = &bnxt_netdev_ops; dev->watchdog_timeo = BNXT_TX_TIMEOUT; dev->ethtool_ops = &bnxt_ethtool_ops; - SWITCHDEV_SET_OPS(dev, &bnxt_switchdev_ops); pci_set_drvdata(pdev, dev); rc = bnxt_alloc_hwrm_resources(bp); diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c index a06f93b49dd5..13db3bf4271f 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c @@ -248,10 +248,6 @@ int bnxt_vf_rep_port_attr_get(struct net_device *dev, return bnxt_port_attr_get(vf_rep->bp, attr); } -static const struct switchdev_ops bnxt_vf_rep_switchdev_ops = { - .switchdev_port_attr_get = bnxt_vf_rep_port_attr_get -}; - static const struct ethtool_ops bnxt_vf_rep_ethtool_ops = { .get_drvinfo = bnxt_vf_rep_get_drvinfo }; @@ -392,7 +388,6 @@ static void bnxt_vf_rep_netdev_init(struct bnxt *bp, struct bnxt_vf_rep *vf_rep, dev->netdev_ops = &bnxt_vf_rep_netdev_ops; dev->ethtool_ops = &bnxt_vf_rep_ethtool_ops; - SWITCHDEV_SET_OPS(dev, &bnxt_vf_rep_switchdev_ops); /* Just inherit all the featues of the parent PF as the VF-R * uses the RX/TX rings of the parent PF */ diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c b/drivers/net/ethernet/cavium/liquidio/lio_main.c index b9d48e4181fc..19ebf2a3aa49 100644 --- a/drivers/net/ethernet/cavium/liquidio/lio_main.c +++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c @@ -3222,10 +3222,6 @@ lio_pf_switchdev_attr_get(struct net_device *dev, struct switchdev_attr *attr) return 0; } -static const struct switchdev_ops lio_pf_switchdev_ops = { - .switchdev_port_attr_get = lio_pf_switchdev_attr_get, -}; - static int liquidio_get_vf_stats(struct net_device *netdev, int vfidx, struct ifla_vf_stats *vf_stats) { @@ -3580,7 +3576,6 @@ static int setup_nic_devices(struct octeon_device *octeon_dev) * netdev tasks. */ netdev->netdev_ops = &lionetdevops; - SWITCHDEV_SET_OPS(netdev, &lio_pf_switchdev_ops); retval = netif_set_real_num_rx_queues(netdev, num_oqueues); if (retval) { diff --git a/drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c b/drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c index d396c004c1be..0aa64ffae8b6 100644 --- a/drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c +++ b/drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c @@ -464,10 +464,6 @@ lio_vf_rep_attr_get(struct net_device *dev, struct switchdev_attr *attr) return 0; } -static const struct switchdev_ops lio_vf_rep_switchdev_ops = { - .switchdev_port_attr_get = lio_vf_rep_attr_get, -}; - static int lio_vf_rep_swdev_port_attr_event(unsigned long event, struct net_device *dev, struct switchdev_notifier_port_attr_info *port_attr_info) @@ -539,7 +535,6 @@ lio_vf_rep_create(struct octeon_device *oct) ndev->min_mtu = LIO_MIN_MTU_SIZE; ndev->max_mtu = LIO_MAX_MTU_SIZE; ndev->netdev_ops = &lio_vf_rep_ndev_ops; - SWITCHDEV_SET_OPS(ndev, &lio_vf_rep_switchdev_ops); vf_rep = netdev_priv(ndev); memset(vf_rep, 0, sizeof(*vf_rep)); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c index 9bac78e111c6..1925ab62631c 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c @@ -1285,10 +1285,6 @@ static int mlx5e_uplink_rep_set_mac(struct net_device *netdev, void *addr) return 0; } -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) @@ -1423,9 +1419,6 @@ static void mlx5e_build_rep_netdev(struct net_device *netdev) netdev->watchdog_timeo = 15 * HZ; - - netdev->switchdev_ops = &mlx5e_rep_switchdev_ops; - netdev->features |= NETIF_F_HW_TC | NETIF_F_NETNS_LOCAL; netdev->hw_features |= NETIF_F_HW_TC; diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c index a88169738b4a..e87a5e634fc1 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c @@ -3207,7 +3207,6 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port, } mlxsw_sp_port->default_vlan = mlxsw_sp_port_vlan; - mlxsw_sp_port_switchdev_init(mlxsw_sp_port); mlxsw_sp->ports[local_port] = mlxsw_sp_port; err = register_netdev(dev); if (err) { @@ -3224,7 +3223,6 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port, err_register_netdev: mlxsw_sp->ports[local_port] = NULL; - mlxsw_sp_port_switchdev_fini(mlxsw_sp_port); mlxsw_sp_port_vlan_destroy(mlxsw_sp_port_vlan); err_port_vlan_create: err_port_pvid_set: @@ -3267,7 +3265,6 @@ static void mlxsw_sp_port_remove(struct mlxsw_sp *mlxsw_sp, u8 local_port) mlxsw_core_port_clear(mlxsw_sp->core, local_port, mlxsw_sp); unregister_netdev(mlxsw_sp_port->dev); /* This calls ndo_stop */ mlxsw_sp->ports[local_port] = NULL; - mlxsw_sp_port_switchdev_fini(mlxsw_sp_port); mlxsw_sp_port_vlan_flush(mlxsw_sp_port, true); mlxsw_sp_port_nve_fini(mlxsw_sp_port); mlxsw_sp_tc_qdisc_fini(mlxsw_sp_port); @@ -3988,12 +3985,6 @@ static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core, goto err_span_init; } - err = mlxsw_sp_switchdev_init(mlxsw_sp); - if (err) { - dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize switchdev\n"); - goto err_switchdev_init; - } - err = mlxsw_sp_counter_pool_init(mlxsw_sp); if (err) { dev_err(mlxsw_sp->bus_info->dev, "Failed to init counter pool\n"); @@ -4064,8 +4055,6 @@ static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core, err_afa_init: mlxsw_sp_counter_pool_fini(mlxsw_sp); err_counter_pool_init: - mlxsw_sp_switchdev_fini(mlxsw_sp); -err_switchdev_init: mlxsw_sp_span_fini(mlxsw_sp); err_span_init: mlxsw_sp_lag_fini(mlxsw_sp); @@ -4128,7 +4117,6 @@ static void mlxsw_sp_fini(struct mlxsw_core *mlxsw_core) mlxsw_sp_nve_fini(mlxsw_sp); mlxsw_sp_afa_fini(mlxsw_sp); mlxsw_sp_counter_pool_fini(mlxsw_sp); - mlxsw_sp_switchdev_fini(mlxsw_sp); mlxsw_sp_span_fini(mlxsw_sp); mlxsw_sp_lag_fini(mlxsw_sp); mlxsw_sp_buffers_fini(mlxsw_sp); diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h index 1fa5c81b209f..f81914203098 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h @@ -375,8 +375,6 @@ u32 mlxsw_sp_bytes_cells(const struct mlxsw_sp *mlxsw_sp, u32 bytes); /* spectrum_switchdev.c */ int mlxsw_sp_switchdev_init(struct mlxsw_sp *mlxsw_sp); void mlxsw_sp_switchdev_fini(struct mlxsw_sp *mlxsw_sp); -void mlxsw_sp_port_switchdev_init(struct mlxsw_sp_port *mlxsw_sp_port); -void mlxsw_sp_port_switchdev_fini(struct mlxsw_sp_port *mlxsw_sp_port); int mlxsw_sp_rif_fdb_op(struct mlxsw_sp *mlxsw_sp, const char *mac, u16 fid, bool adding); void diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c index 7c0df736587c..19f647c4c4df 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c @@ -1962,11 +1962,6 @@ static struct mlxsw_sp_port *mlxsw_sp_lag_rep_port(struct mlxsw_sp *mlxsw_sp, return NULL; } -static const struct switchdev_ops mlxsw_sp_port_switchdev_ops = { - .switchdev_port_attr_get = mlxsw_sp_port_attr_get, - .switchdev_port_attr_set = mlxsw_sp_port_attr_set, -}; - static int mlxsw_sp_bridge_8021q_port_join(struct mlxsw_sp_bridge_device *bridge_device, struct mlxsw_sp_bridge_port *bridge_port, @@ -3575,11 +3570,3 @@ void mlxsw_sp_switchdev_fini(struct mlxsw_sp *mlxsw_sp) kfree(mlxsw_sp->bridge); } -void mlxsw_sp_port_switchdev_init(struct mlxsw_sp_port *mlxsw_sp_port) -{ - mlxsw_sp_port->dev->switchdev_ops = &mlxsw_sp_port_switchdev_ops; -} - -void mlxsw_sp_port_switchdev_fini(struct mlxsw_sp_port *mlxsw_sp_port) -{ -} diff --git a/drivers/net/ethernet/mellanox/mlxsw/switchx2.c b/drivers/net/ethernet/mellanox/mlxsw/switchx2.c index 82fb8f1bb6e9..1f1aca664b73 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/switchx2.c +++ b/drivers/net/ethernet/mellanox/mlxsw/switchx2.c @@ -919,10 +919,6 @@ static int mlxsw_sx_port_attr_get(struct net_device *dev, return 0; } -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) @@ -1064,7 +1060,6 @@ static int __mlxsw_sx_port_eth_create(struct mlxsw_sx *mlxsw_sx, u8 local_port, dev->netdev_ops = &mlxsw_sx_port_netdev_ops; dev->ethtool_ops = &mlxsw_sx_port_ethtool_ops; - dev->switchdev_ops = &mlxsw_sx_port_switchdev_ops; err = mlxsw_sx_port_dev_addr_get(mlxsw_sx_port); if (err) { diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 8043347a1ed4..1b7833ee8cc6 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -1330,11 +1330,6 @@ static int ocelot_port_obj_del(struct net_device *dev, return ret; } -static const struct switchdev_ops ocelot_port_switchdev_ops = { - .switchdev_port_attr_get = ocelot_port_attr_get, - .switchdev_port_attr_set = ocelot_port_attr_set, -}; - static int ocelot_port_bridge_join(struct ocelot_port *ocelot_port, struct net_device *bridge) { @@ -1664,7 +1659,6 @@ int ocelot_probe_port(struct ocelot *ocelot, u8 port, dev->netdev_ops = &ocelot_port_netdev_ops; dev->ethtool_ops = &ocelot_ethtool_ops; - dev->switchdev_ops = &ocelot_port_switchdev_ops; dev->hw_features |= NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_RXFCS; dev->features |= NETIF_F_HW_VLAN_CTAG_FILTER; diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c index c2c5e7e3aab0..46f0f29e31cd 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c @@ -3815,8 +3815,6 @@ static void nfp_net_netdev_init(struct nfp_net *nn) netdev->netdev_ops = &nfp_net_netdev_ops; netdev->watchdog_timeo = msecs_to_jiffies(5 * 1000); - SWITCHDEV_SET_OPS(netdev, &nfp_port_switchdev_ops); - /* MTU range: 68 - hw-specific max */ netdev->min_mtu = ETH_MIN_MTU; netdev->max_mtu = nn->max_mtu; diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c index 69d7aebda09b..eb6e95cc460e 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c @@ -336,8 +336,6 @@ int nfp_repr_init(struct nfp_app *app, struct net_device *netdev, netdev->max_mtu = pf_netdev->max_mtu; - SWITCHDEV_SET_OPS(netdev, &nfp_port_switchdev_ops); - /* Set features the lower device can support with representors */ if (repr_cap & NFP_NET_CFG_CTRL_LIVE_ADDR) netdev->priv_flags |= IFF_LIVE_ADDR_CHANGE; diff --git a/drivers/net/ethernet/netronome/nfp/nfp_port.c b/drivers/net/ethernet/netronome/nfp/nfp_port.c index 578477242ae9..77781fc2eaa6 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_port.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_port.c @@ -55,10 +55,6 @@ nfp_port_attr_get(struct net_device *netdev, struct switchdev_attr *attr) return 0; } -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) diff --git a/drivers/net/ethernet/rocker/rocker_main.c b/drivers/net/ethernet/rocker/rocker_main.c index f25f7b4345b8..52082c7690ea 100644 --- a/drivers/net/ethernet/rocker/rocker_main.c +++ b/drivers/net/ethernet/rocker/rocker_main.c @@ -2139,11 +2139,6 @@ static int rocker_port_obj_del(struct net_device *dev, return err; } -static const struct switchdev_ops rocker_port_switchdev_ops = { - .switchdev_port_attr_get = rocker_port_attr_get, - .switchdev_port_attr_set = rocker_port_attr_set, -}; - struct rocker_fib_event_work { struct work_struct work; union { @@ -2597,7 +2592,6 @@ static int rocker_probe_port(struct rocker *rocker, unsigned int port_number) rocker_port_dev_addr_init(rocker_port); dev->netdev_ops = &rocker_port_netdev_ops; dev->ethtool_ops = &rocker_port_ethtool_ops; - dev->switchdev_ops = &rocker_port_switchdev_ops; netif_tx_napi_add(dev, &rocker_port->napi_tx, rocker_port_poll_tx, NAPI_POLL_WEIGHT); netif_napi_add(dev, &rocker_port->napi_rx, rocker_port_poll_rx, diff --git a/drivers/net/netdevsim/netdev.c b/drivers/net/netdevsim/netdev.c index 817d94cec90f..b0dca4f99018 100644 --- a/drivers/net/netdevsim/netdev.c +++ b/drivers/net/netdevsim/netdev.c @@ -164,10 +164,6 @@ nsim_port_attr_get(struct net_device *dev, struct switchdev_attr *attr) } } -static const struct switchdev_ops nsim_switchdev_ops = { - .switchdev_port_attr_get = nsim_port_attr_get, -}; - static int nsim_switchdev_port_attr_event(unsigned long event, struct net_device *dev, struct switchdev_notifier_port_attr_info *port_attr_info) @@ -228,7 +224,6 @@ static int nsim_init(struct net_device *dev) goto err_bpf_uninit; SET_NETDEV_DEV(dev, &ns->dev); - SWITCHDEV_SET_OPS(dev, &nsim_switchdev_ops); err = nsim_devlink_setup(ns); if (err) diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c index b18e112d84e6..4d0eb2ed062d 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c @@ -924,11 +924,6 @@ static int swdev_port_obj_del(struct net_device *netdev, return err; } -static const struct switchdev_ops ethsw_port_switchdev_ops = { - .switchdev_port_attr_get = swdev_port_attr_get, - .switchdev_port_attr_set = swdev_port_attr_set, -}; - /* For the moment, only flood setting needs to be updated */ static int port_bridge_join(struct net_device *netdev, struct net_device *upper_dev) @@ -1458,7 +1453,6 @@ static int ethsw_probe_port(struct ethsw_core *ethsw, u16 port_idx) SET_NETDEV_DEV(port_netdev, dev); port_netdev->netdev_ops = ðsw_port_ops; port_netdev->ethtool_ops = ðsw_port_ethtool_ops; - port_netdev->switchdev_ops = ðsw_port_switchdev_ops; /* Set MTU limits */ port_netdev->min_mtu = ETH_MIN_MTU; diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index a57b9a853aab..1176292f3d62 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -1826,9 +1826,6 @@ struct net_device { #endif const struct net_device_ops *netdev_ops; const struct ethtool_ops *ethtool_ops; -#ifdef CONFIG_NET_SWITCHDEV - const struct switchdev_ops *switchdev_ops; -#endif #ifdef CONFIG_NET_L3_MASTER_DEV const struct l3mdev_ops *l3mdev_ops; #endif diff --git a/include/net/switchdev.h b/include/net/switchdev.h index e62fb2693e00..61a97f2a8fb0 100644 --- a/include/net/switchdev.h +++ b/include/net/switchdev.h @@ -115,21 +115,6 @@ void *switchdev_trans_item_dequeue(struct switchdev_trans *trans); typedef int switchdev_obj_dump_cb_t(struct switchdev_obj *obj); -/** - * struct switchdev_ops - switchdev operations - * - * @switchdev_port_attr_get: Get a port attribute (see switchdev_attr). - * - * @switchdev_port_attr_set: Set a port attribute (see switchdev_attr). - */ -struct switchdev_ops { - int (*switchdev_port_attr_get)(struct net_device *dev, - struct switchdev_attr *attr); - int (*switchdev_port_attr_set)(struct net_device *dev, - const struct switchdev_attr *attr, - struct switchdev_trans *trans); -}; - enum switchdev_notifier_type { SWITCHDEV_FDB_ADD_TO_BRIDGE = 1, SWITCHDEV_FDB_DEL_TO_BRIDGE, @@ -234,7 +219,6 @@ int switchdev_handle_port_obj_del(struct net_device *dev, int (*del_cb)(struct net_device *dev, const struct switchdev_obj *obj)); -#define SWITCHDEV_SET_OPS(netdev, ops) ((netdev)->switchdev_ops = (ops)) #else static inline void switchdev_deferred_process(void) @@ -333,8 +317,6 @@ switchdev_handle_port_obj_del(struct net_device *dev, return 0; } -#define SWITCHDEV_SET_OPS(netdev, ops) do {} while (0) - #endif #endif /* _LINUX_SWITCHDEV_H_ */ diff --git a/net/dsa/slave.c b/net/dsa/slave.c index bc7d5092a1c7..a11f9678610c 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -1048,11 +1048,6 @@ static const struct net_device_ops dsa_slave_netdev_ops = { .ndo_get_stats64 = dsa_slave_get_stats64, }; -static const struct switchdev_ops dsa_slave_switchdev_ops = { - .switchdev_port_attr_get = dsa_slave_port_attr_get, - .switchdev_port_attr_set = dsa_slave_port_attr_set, -}; - static struct device_type dsa_type = { .name = "dsa", }; @@ -1312,7 +1307,6 @@ int dsa_slave_create(struct dsa_port *port) eth_hw_addr_inherit(slave_dev, master); slave_dev->priv_flags |= IFF_NO_QUEUE; slave_dev->netdev_ops = &dsa_slave_netdev_ops; - slave_dev->switchdev_ops = &dsa_slave_switchdev_ops; slave_dev->min_mtu = 0; slave_dev->max_mtu = ETH_MAX_MTU; SET_NETDEV_DEVTYPE(slave_dev, &dsa_type); diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c index cd78253de31d..b7f1cf0c7f4c 100644 --- a/net/switchdev/switchdev.c +++ b/net/switchdev/switchdev.c @@ -174,81 +174,31 @@ static int switchdev_deferred_enqueue(struct net_device *dev, return 0; } -/** - * switchdev_port_attr_get - Get port attribute - * - * @dev: port device - * @attr: attribute to get - */ -int switchdev_port_attr_get(struct net_device *dev, struct switchdev_attr *attr) +static int switchdev_port_attr_notify(enum switchdev_notifier_type nt, + struct net_device *dev, + struct switchdev_attr *attr, + struct switchdev_trans *trans) { - const struct switchdev_ops *ops = dev->switchdev_ops; - struct net_device *lower_dev; - struct list_head *iter; - struct switchdev_attr first = { - .id = SWITCHDEV_ATTR_ID_UNDEFINED - }; - int err = -EOPNOTSUPP; + int err; + int rc; - if (ops && ops->switchdev_port_attr_get) - return ops->switchdev_port_attr_get(dev, attr); + struct switchdev_notifier_port_attr_info attr_info = { + .attr = attr, + .trans = trans, + .handled = false, + }; - if (attr->flags & SWITCHDEV_F_NO_RECURSE) + rc = call_switchdev_blocking_notifiers(nt, dev, &attr_info.info, NULL); + err = notifier_to_errno(rc); + if (err) { + WARN_ON(!attr_info.handled); return err; - - /* Switch device port(s) may be stacked under - * bond/team/vlan dev, so recurse down to get attr on - * each port. Return -ENODATA if attr values don't - * compare across ports. - */ - - netdev_for_each_lower_dev(dev, lower_dev, iter) { - err = switchdev_port_attr_get(lower_dev, attr); - if (err) - break; - if (first.id == SWITCHDEV_ATTR_ID_UNDEFINED) - first = *attr; - else if (memcmp(&first, attr, sizeof(*attr))) - return -ENODATA; - } - - return err; -} -EXPORT_SYMBOL_GPL(switchdev_port_attr_get); - -static int __switchdev_port_attr_set(struct net_device *dev, - const struct switchdev_attr *attr, - struct switchdev_trans *trans) -{ - const struct switchdev_ops *ops = dev->switchdev_ops; - struct net_device *lower_dev; - struct list_head *iter; - int err = -EOPNOTSUPP; - - if (ops && ops->switchdev_port_attr_set) { - err = ops->switchdev_port_attr_set(dev, attr, trans); - goto done; - } - - if (attr->flags & SWITCHDEV_F_NO_RECURSE) - goto done; - - /* Switch device port(s) may be stacked under - * bond/team/vlan dev, so recurse down to set attr on - * each port. - */ - - netdev_for_each_lower_dev(dev, lower_dev, iter) { - err = __switchdev_port_attr_set(lower_dev, attr, trans); - if (err) - break; } -done: - if (err == -EOPNOTSUPP && attr->flags & SWITCHDEV_F_SKIP_EOPNOTSUPP) - err = 0; + if (!attr_info.handled) + return -EOPNOTSUPP; - return err; + return 0; } static int switchdev_port_attr_set_now(struct net_device *dev, @@ -267,7 +217,9 @@ static int switchdev_port_attr_set_now(struct net_device *dev, */ trans.ph_prepare = true; - err = __switchdev_port_attr_set(dev, attr, &trans); + err = switchdev_port_attr_notify(SWITCHDEV_PORT_ATTR_SET, + dev, (struct switchdev_attr *)attr, + &trans); if (err) { /* Prepare phase failed: abort the transaction. Any * resources reserved in the prepare phase are @@ -286,7 +238,9 @@ static int switchdev_port_attr_set_now(struct net_device *dev, */ trans.ph_prepare = false; - err = __switchdev_port_attr_set(dev, attr, &trans); + err = switchdev_port_attr_notify(SWITCHDEV_PORT_ATTR_SET, + dev, (struct switchdev_attr *)attr, + &trans); WARN(err, "%s: Commit of attribute (id=%d) failed.\n", dev->name, attr->id); switchdev_trans_items_warn_destroy(dev, &trans); @@ -338,6 +292,19 @@ int switchdev_port_attr_set(struct net_device *dev, } EXPORT_SYMBOL_GPL(switchdev_port_attr_set); +/** + * switchdev_port_attr_get - Get port attribute + * + * @dev: port device + * @attr: attribute to get + */ +int switchdev_port_attr_get(struct net_device *dev, struct switchdev_attr *attr) +{ + return switchdev_port_attr_notify(SWITCHDEV_PORT_ATTR_GET, dev, + attr, NULL); +} +EXPORT_SYMBOL_GPL(switchdev_port_attr_get); + static size_t switchdev_obj_size(const struct switchdev_obj *obj) { switch (obj->id) {