Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp1235721img; Tue, 26 Feb 2019 17:15:56 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ7gC82R111aA0dFGsl6UrcmehzusFYCwpwAnK1O81O2p1NI2A4FqfjE5Q8rCriWFEewQ29 X-Received: by 2002:a63:541:: with SMTP id 62mr384944pgf.172.1551230155966; Tue, 26 Feb 2019 17:15:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551230155; cv=none; d=google.com; s=arc-20160816; b=Z5BTY0Kqi9TvEnXNW+WzjLqtt/X2qBbDmrj7sab1BzUOlxz6VM7d2DOBluX3mC959q bJBqD6FzjLvNzI3sFT5dLYp3FR7b0+rwcqnTC3BFfqWHm8MHe3lgyNlWzSDFAxHPIDOV oSnCd1ZcP+r9eX+Q61LvcM/qJwX/6ffAz0eyr9mciRGZJ4C6PJXCsp9B7o6HjmOMuRdi WEyCMJ6g//twpilQCBdlxMyZyLwg96kSCbwlbCKRsQ3QYrxWBK3wFoAfVsAoUZlEp9qR myfv7fhFe5WONWk+jbcU4IXXQYkLrenR7wZcd7dRQqMn8DGREuOBSKGD8mHPVE8yGhjR p3oQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=xdJhj6/KPsXtmI8sxeS4sEhQiluHyols6G0sMJAn/vE=; b=zrZXaob/fE/c9D8+kT7+uuuMTHwL8nx4v2zT5Uv5HoV67OEuh1stltQ1oM5IBBNfqi X7Fs4cAY9QtQFQQrL7IsIBrvz916EvK5sta3Kd+jWGJJBxHij9dEngUnQxHiv5SdGmvY 191RhmtQNPANOsyXtOgJxkecad2sPI9dXius0cU3OEsw9R71pK/Bv+Uyvsxbsk//do66 5g+ZLkDs1ez6zOYkpYw1qYDdyef1SVCS2s8vqhWyp5e0w9sSdRkeL0p9WXXVAY4yWC0K 15XLuUYNHI4fqgVu/BOgf61P62YiwlhA1VX0fNF7J2F67Hewpx7ncYQSzafJshE5yONa xPJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tzr2PeEk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b2si3923247pla.287.2019.02.26.17.15.41; Tue, 26 Feb 2019 17:15:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tzr2PeEk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729705AbfB0BPB (ORCPT + 99 others); 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-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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Following patches will change the way we communicate 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