From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26B5AC43381 for ; Wed, 27 Feb 2019 01:15:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E8409218CD for ; Wed, 27 Feb 2019 01:15:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tzr2PeEk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729700AbfB0BPB (ORCPT ); Tue, 26 Feb 2019 20:15:01 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:45815 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727998AbfB0BO7 (ORCPT ); Tue, 26 Feb 2019 20:14:59 -0500 Received: by mail-pf1-f193.google.com with SMTP id v21so7105393pfm.12; Tue, 26 Feb 2019 17:14:58 -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=xdJhj6/KPsXtmI8sxeS4sEhQiluHyols6G0sMJAn/vE=; b=tzr2PeEkAhYSplvnsv1G0ptCpq6TDu3RAuaemwmV/PJsb0+xwobUzQo8MrqDRafRGu 0XsG0kIpc20QpBEWrnnHI48kE6Ts9Mr59QnixwyCywPRO1/0Q8NtBgyLNdrmYr0nNSnH 8yqwc/Q3S2lisXY2IiANpAnOSZ9zgTwJm0wN4Zpfxf4d0c6KGhxWzSa2Kahca4Pom8fL 3/bLXPVtIrdG010D5XoE5pDcqSWUu2kllpkSASAf5t9cOqHOt8dA0bdbWyRn6f2qul8L 2QFZR4Y5tHdSjeeStns9BoRmjDYpsJWPhCRBpadpeY8S8ZH6uD68MR6KEO9ODwm0TqzJ clbQ== 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=xdJhj6/KPsXtmI8sxeS4sEhQiluHyols6G0sMJAn/vE=; b=VMlKQSeC5k6GjwAuLIGuMJoVWeJSPpcH4Cak3QCPrawtsp5mbNRdMwNOcB8P1YUjEJ uvMjVb3HzQIfmLPdSCs48iByFulpFdaxJ+RSE1MLkBQkTGLzQYbrfxUcq7qsTYFSNLtF zELef9gxvWo1vgu/GXDzqfMUCUhVU87NG32S9A6UQOC7iIbafDb/+q+q2MW1XDWJcPgF 4jI/a1Jy8vqYU+ozSChudRwTja3ymBgYSnqvmqxbDCR2YmfKOooEh+EWRfvnRmQVFJ4r 4N+GwuHgm0C38xm22XR2uRxeFy4YygXUcxFKQaOHft/hCiZBDFffFe94zFgnBL3dbrqU goJA== X-Gm-Message-State: AHQUAuZIJBpTTYT5TgTeh8yTTCJK2AnOOz+y5XpCVN8P/3D67YOumP3g 2uAkqJ0dmJmnzln39UPmC2J9gvMq X-Google-Smtp-Source: AHgI3Iak/jI8J59DWnmfRyCcu39Hp7TyPkNZiwZBNf5ahlGI5D4UOFIoRy2pZ7ZKuozdGsK1cbJ16A== X-Received: by 2002:a63:4247:: with SMTP id p68mr395283pga.30.1551230098193; Tue, 26 Feb 2019 17:14:58 -0800 (PST) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.250]) by smtp.gmail.com with ESMTPSA id q28sm21885221pgl.35.2019.02.26.17.14.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Feb 2019 17:14:57 -0800 (PST) From: Florian Fainelli To: netdev@vger.kernel.org Cc: Florian Fainelli , "David S. Miller" , Ido Schimmel , linux-kernel@vger.kernel.org (open list), devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), bridge@lists.linux-foundation.org (moderated list:ETHERNET BRIDGE), jiri@mellanox.com, andrew@lunn.ch, vivien.didelot@gmail.com Subject: [PATCH net-next v2 5/8] net: mscc: ocelot: Handle SWITCHDEV_PORT_ATTR_SET Date: Tue, 26 Feb 2019 17:14:24 -0800 Message-Id: <20190227011427.16487-6-f.fainelli@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190227011427.16487-1-f.fainelli@gmail.com> References: <20190227011427.16487-1-f.fainelli@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Following patches will change the way we communicate setting a port's attribute and use notifiers to perform those tasks. Ocelot does not currently have an atomic notifier registered for switchdev events, so we need to register one in order to deal with atomic context SWITCHDEV_PORT_ATTR_SET events. Signed-off-by: Florian Fainelli --- drivers/net/ethernet/mscc/ocelot.c | 27 ++++++++++++++++++++++++ drivers/net/ethernet/mscc/ocelot.h | 1 + drivers/net/ethernet/mscc/ocelot_board.c | 2 ++ 3 files changed, 30 insertions(+) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 195306d05bcd..83a678b11757 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -1582,6 +1582,28 @@ struct notifier_block ocelot_netdevice_nb __read_mostly = { }; EXPORT_SYMBOL(ocelot_netdevice_nb); +static int ocelot_switchdev_event(struct notifier_block *unused, + unsigned long event, void *ptr) +{ + struct net_device *dev = switchdev_notifier_info_to_dev(ptr); + int err; + + switch (event) { + case SWITCHDEV_PORT_ATTR_SET: + err = switchdev_handle_port_attr_set(dev, ptr, + ocelot_netdevice_dev_check, + ocelot_port_attr_set); + return notifier_from_errno(err); + } + + return NOTIFY_DONE; +} + +struct notifier_block ocelot_switchdev_nb __read_mostly = { + .notifier_call = ocelot_switchdev_event, +}; +EXPORT_SYMBOL(ocelot_switchdev_nb); + static int ocelot_switchdev_blocking_event(struct notifier_block *unused, unsigned long event, void *ptr) { @@ -1600,6 +1622,11 @@ 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: + err = switchdev_handle_port_attr_set(dev, ptr, + ocelot_netdevice_dev_check, + ocelot_port_attr_set); + return notifier_from_errno(err); } return NOTIFY_DONE; diff --git a/drivers/net/ethernet/mscc/ocelot.h b/drivers/net/ethernet/mscc/ocelot.h index 086775f7b52f..ba3b3380b4d0 100644 --- a/drivers/net/ethernet/mscc/ocelot.h +++ b/drivers/net/ethernet/mscc/ocelot.h @@ -499,6 +499,7 @@ int ocelot_probe_port(struct ocelot *ocelot, u8 port, struct phy_device *phy); extern struct notifier_block ocelot_netdevice_nb; +extern struct notifier_block ocelot_switchdev_nb; extern struct notifier_block ocelot_switchdev_blocking_nb; #endif diff --git a/drivers/net/ethernet/mscc/ocelot_board.c b/drivers/net/ethernet/mscc/ocelot_board.c index ca3ea2fbfcd0..2c1121d86edf 100644 --- a/drivers/net/ethernet/mscc/ocelot_board.c +++ b/drivers/net/ethernet/mscc/ocelot_board.c @@ -329,6 +329,7 @@ static int mscc_ocelot_probe(struct platform_device *pdev) } register_netdevice_notifier(&ocelot_netdevice_nb); + register_switchdev_notifier(&ocelot_switchdev_nb); register_switchdev_blocking_notifier(&ocelot_switchdev_blocking_nb); dev_info(&pdev->dev, "Ocelot switch probed\n"); @@ -345,6 +346,7 @@ static int mscc_ocelot_remove(struct platform_device *pdev) ocelot_deinit(ocelot); unregister_switchdev_blocking_notifier(&ocelot_switchdev_blocking_nb); + unregister_switchdev_notifier(&ocelot_switchdev_nb); unregister_netdevice_notifier(&ocelot_netdevice_nb); return 0; -- 2.17.1