From patchwork Thu Jan 7 01:24:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 358748 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 47785C433E0 for ; Thu, 7 Jan 2021 01:26:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 128CE2312E for ; Thu, 7 Jan 2021 01:26:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726479AbhAGBZz (ORCPT ); Wed, 6 Jan 2021 20:25:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726297AbhAGBZy (ORCPT ); Wed, 6 Jan 2021 20:25:54 -0500 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13CDFC0612F0 for ; Wed, 6 Jan 2021 17:25:14 -0800 (PST) Received: by mail-ed1-x52b.google.com with SMTP id g24so6139848edw.9 for ; Wed, 06 Jan 2021 17:25:14 -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 :mime-version:content-transfer-encoding; bh=YCzyhGgTWWel+e7I1WlhjYvXmgKVK+ZX8TJG9dMRlqs=; b=Mblm5laarpgC14v9v4JeaQawUYt8RYtVhHqZwZODtBCTQvpCIHWhf4UPQHj5d7B4sm ac4pkyRxtQmLRX7dAMFf8UVimMcSp6kpgGJe1lpzJ6Xc87o4mQtH2/Sx2ieyrNRJOk3v 6yLaoowsa91d6p2r5wu5HQYZ9J3uuhCQxKZbKrYu2WuXVFQnzDyJLQdvxzeVhA5rzpIu +/fZ1ANmbpPP7W1BM1QdFQPa4UfxSc0pv4rdu3cyHmMwQK5jIj4vtvpr9LzBpRuHe3ox Sk00TZllArVgnp3eZGdM4gDsfFS+lixMxIHYJd9s+dbzsVMehmkq/98qttYaIg8tNae7 0J2A== 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:mime-version:content-transfer-encoding; bh=YCzyhGgTWWel+e7I1WlhjYvXmgKVK+ZX8TJG9dMRlqs=; b=RT7J25OELoCZQOLKxJB3P9wsOcR977UOtxBZM+qG9M7EyMrjtjuXHHl37QgkpskE00 myO6TBmVIJQ9kgKw252eAyC3coZuguOWD+cKO2d8bX1G8p/q3pzaHjr0EGugQCuIZ5jg 8Q/7UxQqes2Pj1oBIe8twU8wMnV2IycSGjUMrPXeCl+kwgdBwRXy/H8L9+IMPhcLk7f0 4oMK7YP7nY2elCzgOtgpEbtHscN+RBLnPVMdC+hGQxQQS3Kruopq6Q5p2rirkvudkxaD WF1s1yj0dxl8ohq3Y/kf4ILnzNR5sj86g+ljQNZWD0HQeST4VLedGN5UbLsqHcVTtzwg qo3A== X-Gm-Message-State: AOAM5301xWdiiC0eFpHsG5NwlApk5lCPob3HK0FwgwZ6P71lQjzNOsEl kZAg0o5biBgatNwOAT46MIY= X-Google-Smtp-Source: ABdhPJyk3WD8gQYwUAcbu0ZLekfGKrxwfnadaO4kgk+9QYcjwiRP6q4y8U3ucBujsLCt4l5g+DFhaw== X-Received: by 2002:a05:6402:312b:: with SMTP id dd11mr5925745edb.308.1609982712803; Wed, 06 Jan 2021 17:25:12 -0800 (PST) Received: from localhost.localdomain (5-12-227-87.residential.rdsnet.ro. [5.12.227.87]) by smtp.gmail.com with ESMTPSA id a6sm2041858edv.74.2021.01.06.17.25.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jan 2021 17:25:12 -0800 (PST) From: Vladimir Oltean To: Florian Fainelli , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Cc: Andrew Lunn , Vivien Didelot , bcm-kernel-feedback-list@broadcom.com, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH v2 net-next 1/4] net: dsa: move the Broadcom tag information in a separate header file Date: Thu, 7 Jan 2021 03:24:00 +0200 Message-Id: <20210107012403.1521114-2-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107012403.1521114-1-olteanv@gmail.com> References: <20210107012403.1521114-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vladimir Oltean It is a bit strange to see something as specific as Broadcom SYSTEMPORT bits in the main DSA include file. Move these away into a separate header, and have the tagger and the SYSTEMPORT driver include them. Signed-off-by: Vladimir Oltean Acked-by: Florian Fainelli --- Changes in v2: None. MAINTAINERS | 1 + drivers/net/ethernet/broadcom/bcmsysport.c | 1 + include/linux/dsa/brcm.h | 16 ++++++++++++++++ include/net/dsa.h | 6 ------ net/dsa/tag_brcm.c | 1 + 5 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 include/linux/dsa/brcm.h diff --git a/MAINTAINERS b/MAINTAINERS index 7c1e45c416b1..3854aca806f5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3400,6 +3400,7 @@ L: openwrt-devel@lists.openwrt.org (subscribers-only) S: Supported F: Documentation/devicetree/bindings/net/dsa/brcm,b53.yaml F: drivers/net/dsa/b53/* +F: include/linux/dsa/brcm.h F: include/linux/platform_data/b53.h BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c index b1ae9eb8f247..9ef743d6ba67 100644 --- a/drivers/net/ethernet/broadcom/bcmsysport.c +++ b/drivers/net/ethernet/broadcom/bcmsysport.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include diff --git a/include/linux/dsa/brcm.h b/include/linux/dsa/brcm.h new file mode 100644 index 000000000000..47545a948784 --- /dev/null +++ b/include/linux/dsa/brcm.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0-only + * Copyright (C) 2014 Broadcom Corporation + */ + +/* Included by drivers/net/ethernet/broadcom/bcmsysport.c and + * net/dsa/tag_brcm.c + */ +#ifndef _NET_DSA_BRCM_H +#define _NET_DSA_BRCM_H + +/* Broadcom tag specific helpers to insert and extract queue/port number */ +#define BRCM_TAG_SET_PORT_QUEUE(p, q) ((p) << 8 | q) +#define BRCM_TAG_GET_PORT(v) ((v) >> 8) +#define BRCM_TAG_GET_QUEUE(v) ((v) & 0xff) + +#endif diff --git a/include/net/dsa.h b/include/net/dsa.h index 4e60d2610f20..af9a4f9ee764 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -873,12 +873,6 @@ static inline int call_dsa_notifiers(unsigned long val, struct net_device *dev, } #endif -/* Broadcom tag specific helpers to insert and extract queue/port number */ -#define BRCM_TAG_SET_PORT_QUEUE(p, q) ((p) << 8 | q) -#define BRCM_TAG_GET_PORT(v) ((v) >> 8) -#define BRCM_TAG_GET_QUEUE(v) ((v) & 0xff) - - netdev_tx_t dsa_enqueue_skb(struct sk_buff *skb, struct net_device *dev); int dsa_port_get_phy_strings(struct dsa_port *dp, uint8_t *data); int dsa_port_get_ethtool_phy_stats(struct dsa_port *dp, uint64_t *data); diff --git a/net/dsa/tag_brcm.c b/net/dsa/tag_brcm.c index e934dace3922..e2577a7dcbca 100644 --- a/net/dsa/tag_brcm.c +++ b/net/dsa/tag_brcm.c @@ -5,6 +5,7 @@ * Copyright (C) 2014 Broadcom Corporation */ +#include #include #include #include From patchwork Thu Jan 7 01:24:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 358747 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 72C5BC43381 for ; Thu, 7 Jan 2021 01:26:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 47B7B2312A for ; Thu, 7 Jan 2021 01:26:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726532AbhAGBZ6 (ORCPT ); Wed, 6 Jan 2021 20:25:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726297AbhAGBZz (ORCPT ); Wed, 6 Jan 2021 20:25:55 -0500 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17A88C0612F1 for ; Wed, 6 Jan 2021 17:25:15 -0800 (PST) Received: by mail-ed1-x536.google.com with SMTP id y24so6139609edt.10 for ; Wed, 06 Jan 2021 17:25: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 :mime-version:content-transfer-encoding; bh=J5314oOLBwOSaPqs3GfHrm1zBklYsaL3mcAsr73qJYY=; b=mCetRwcFj9CuD/PaI1tSEH2mAATl4zyWm9TKhatwacGUvvIbywqnOOUF7pPTZtyYCF vRwTaYcxjhlCK+7DbfKjXVA1S1gqx2TqOlBGBdKHP7Ar9ofU5ZvdoadhRkRQTeqnB0lw oPlFD6mFgh/qu9Qw94WQ8t5LWShnxt6w4hRLZ0zcKIFb6+EO4cKFt6JmBKImjo73Sttu lMaFjxJi4O8KepHV5Iy6hhn2ghg/+MHBIf1iVB8AlLw/QKM7Rk/J36wOLtk9TZvcODq6 57wD1r0A+o05bX4EtoYczLdLMy8Fo3KAy8IWaVMn8mEq72uMW5cscQ7w/64a+DAvdEcU Qdpg== 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:mime-version:content-transfer-encoding; bh=J5314oOLBwOSaPqs3GfHrm1zBklYsaL3mcAsr73qJYY=; b=WibTl+gDaHvGZw/IhYIvK2y8LfPiBCeI4sd+XuOARv1vb4RpljzcuP3K0zOzeTm572 ZHGgKTmiAlSosM3zLwAuQk8QOnEMEVjpC1EGwKMohSDBOUH8ynwGRbA7IDztBp+xQGbF iuE40Xr1xUW6FIWj/CWPt17fR5WwJfbXZMIoKu+Y9aPyCKjR/MhrzVdlw9dMypiptS2U FO63FPQ6C65lU/+bUziwV+f4U8Lno6MVN8p1j7DAxwoGZedh0Xb8l0r39SJFT/hKgGMY ejjdTIJ5sryOa2VLnebtE7wJSG3Skm2pA8TGX8tD0usXd1YKl1CDk4wza53RnEMkIfzq 9ztw== X-Gm-Message-State: AOAM533UnrK2F0y1JCt0b/eda6FxF194UgHH7SYfMMZlaBdEvwtdnHSm L7bk84yKDfOg/1tm815PJ2+LKKw/2NSLKw== X-Google-Smtp-Source: ABdhPJxCiJMEmv2u78EZefGwnEGLOoN5P/Nx6pOs7J35gu2dc7j+PajEHt1QCzTfjqnhjscYu2sfaw== X-Received: by 2002:a50:d646:: with SMTP id c6mr5708437edj.177.1609982713815; Wed, 06 Jan 2021 17:25:13 -0800 (PST) Received: from localhost.localdomain (5-12-227-87.residential.rdsnet.ro. [5.12.227.87]) by smtp.gmail.com with ESMTPSA id a6sm2041858edv.74.2021.01.06.17.25.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jan 2021 17:25:13 -0800 (PST) From: Vladimir Oltean To: Florian Fainelli , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Cc: Andrew Lunn , Vivien Didelot , bcm-kernel-feedback-list@broadcom.com, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH v2 net-next 2/4] net: dsa: export dsa_slave_dev_check Date: Thu, 7 Jan 2021 03:24:01 +0200 Message-Id: <20210107012403.1521114-3-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107012403.1521114-1-olteanv@gmail.com> References: <20210107012403.1521114-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vladimir Oltean Using the NETDEV_CHANGEUPPER notifications, drivers can be aware when they are enslaved to e.g. a bridge by calling netif_is_bridge_master(). Export this helper from DSA to get the equivalent functionality of determining whether the upper interface of a CHANGEUPPER notifier is a DSA switch interface or not. Signed-off-by: Vladimir Oltean Acked-by: Florian Fainelli --- Changes in v2: None. include/net/dsa.h | 6 ++++++ net/dsa/dsa_priv.h | 1 - net/dsa/slave.c | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/net/dsa.h b/include/net/dsa.h index af9a4f9ee764..5badfd6403c5 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -855,6 +855,7 @@ int register_dsa_notifier(struct notifier_block *nb); int unregister_dsa_notifier(struct notifier_block *nb); int call_dsa_notifiers(unsigned long val, struct net_device *dev, struct dsa_notifier_info *info); +bool dsa_slave_dev_check(const struct net_device *dev); #else static inline int register_dsa_notifier(struct notifier_block *nb) { @@ -871,6 +872,11 @@ static inline int call_dsa_notifiers(unsigned long val, struct net_device *dev, { return NOTIFY_DONE; } + +static inline bool dsa_slave_dev_check(const struct net_device *dev) +{ + return false; +} #endif netdev_tx_t dsa_enqueue_skb(struct sk_buff *skb, struct net_device *dev); diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h index 7c96aae9062c..33c082f10bb9 100644 --- a/net/dsa/dsa_priv.h +++ b/net/dsa/dsa_priv.h @@ -172,7 +172,6 @@ extern const struct dsa_device_ops notag_netdev_ops; void dsa_slave_mii_bus_init(struct dsa_switch *ds); int dsa_slave_create(struct dsa_port *dp); void dsa_slave_destroy(struct net_device *slave_dev); -bool dsa_slave_dev_check(const struct net_device *dev); int dsa_slave_suspend(struct net_device *slave_dev); int dsa_slave_resume(struct net_device *slave_dev); int dsa_slave_register_notifier(void); diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 4a0498bf6c65..c01bc7ebeb14 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -1924,6 +1924,7 @@ bool dsa_slave_dev_check(const struct net_device *dev) { return dev->netdev_ops == &dsa_slave_netdev_ops; } +EXPORT_SYMBOL_GPL(dsa_slave_dev_check); static int dsa_slave_changeupper(struct net_device *dev, struct netdev_notifier_changeupper_info *info) From patchwork Thu Jan 7 01:24:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 358746 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham 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 6AD11C433E6 for ; Thu, 7 Jan 2021 01:26:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2DC4C2312C for ; Thu, 7 Jan 2021 01:26:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726663AbhAGBZ6 (ORCPT ); Wed, 6 Jan 2021 20:25:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726482AbhAGBZ4 (ORCPT ); Wed, 6 Jan 2021 20:25:56 -0500 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1ACF3C0612F3 for ; Wed, 6 Jan 2021 17:25:16 -0800 (PST) Received: by mail-ej1-x62c.google.com with SMTP id qw4so7510431ejb.12 for ; Wed, 06 Jan 2021 17:25:16 -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 :mime-version:content-transfer-encoding; bh=9hcFonlCv5i0BsUw49e8mYBm+WY5pAuaSjOGGq/fj10=; b=FTcsa4osk0+iRvNL9Uvz/FkguW4aZj+ObHzk0W2ZMVbPxgLvDNX7Spt7e3EofPb1jr ZAJHigTVvpwghNQhsWDMEZD56kpehmjWvl7euNoCGR0cRDywzrFf2+ovIxQfvrQcoHaQ Jyi83ESsmaNX7R7Ar0UPzsUtch2tS2jJX3WL0JQye2qsjLKoIBmTBKYqce8f5QyfrBko 67ALEVT2T/IvCsKm+yz+94DfTLsxY7DoY4QU7YZhA48u4V3EV8sjhwKviYmr/3r6F/aC PSdySGPRiu2qVgChDPs75Y6GpWcaNjiOWWP1mcsjef2FYaI7OPOlfF1m5G/BZ3FJrcIx JYhA== 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:mime-version:content-transfer-encoding; bh=9hcFonlCv5i0BsUw49e8mYBm+WY5pAuaSjOGGq/fj10=; b=X8KDnoiFb4/5sS56dvhyMxsTtozjIspoDxKTkvbdJn18C0Iig5XFR4PEXw9wuZgEM3 IBSTnZ15VzK1FL2P7JzMzqloe+/vy+zE3TtNqF36zzQygXXu/7BKrQP8VhRn4twn5Nqn j6OTmpDpaqZjXzN7nnM3T6nBMjgnlE0eiFF/ZEfQt4YR9tQVH+codAyXAaDaofXb/dx9 9m7pP98imYNrQey5ya75OT7CcDCAnOT72saBpKGDr8BtjCJMJKatQmV1/T2ctVjmntt5 b4FezJNmch4j1MpZ9ocVpySJ80ULnrOfKkz9bw+eK8kDoCRX4MYHEt6sT9mJJ4KtFMrj HbDg== X-Gm-Message-State: AOAM5312NlHlpZ9Qj3pUgZ2jYWUiP84Yhhdy3lIU891pOuOVoZ6jn6rM 6K/jl3Up83qOsrmUFw8qsYA= X-Google-Smtp-Source: ABdhPJzQAOJOO/YUPyIzz50/PiWCoNkbSHBuwNq1aJlJASqLt2fNQLEdVseksrdYwa3dpHBDSqxmUQ== X-Received: by 2002:a17:906:56ca:: with SMTP id an10mr4766481ejc.498.1609982714869; Wed, 06 Jan 2021 17:25:14 -0800 (PST) Received: from localhost.localdomain (5-12-227-87.residential.rdsnet.ro. [5.12.227.87]) by smtp.gmail.com with ESMTPSA id a6sm2041858edv.74.2021.01.06.17.25.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jan 2021 17:25:14 -0800 (PST) From: Vladimir Oltean To: Florian Fainelli , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Cc: Andrew Lunn , Vivien Didelot , bcm-kernel-feedback-list@broadcom.com, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH v2 net-next 3/4] net: systemport: use standard netdevice notifier to detect DSA presence Date: Thu, 7 Jan 2021 03:24:02 +0200 Message-Id: <20210107012403.1521114-4-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107012403.1521114-1-olteanv@gmail.com> References: <20210107012403.1521114-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vladimir Oltean The SYSTEMPORT driver maps each port of the embedded Broadcom DSA switch port to a certain queue of the master Ethernet controller. For that it currently uses a dedicated notifier infrastructure which was added in commit 60724d4bae14 ("net: dsa: Add support for DSA specific notifiers"). However, since commit 2f1e8ea726e9 ("net: dsa: link interfaces with the DSA master to get rid of lockdep warnings"), DSA is actually an upper of the Broadcom SYSTEMPORT as far as the netdevice adjacency lists are concerned. So naturally, the plain NETDEV_CHANGEUPPER net device notifiers are emitted. It looks like there is enough API exposed by DSA to the outside world already to make the call_dsa_notifiers API redundant. So let's convert its only user to plain netdev notifiers. Signed-off-by: Vladimir Oltean Tested-by: Florian Fainelli --- Changes in v2: Kept the container_of(nb, struct bcm_sysport_priv, dsa_notifier) in the code, which repairs an issue introduced in v1. drivers/net/ethernet/broadcom/bcmsysport.c | 81 ++++++++++------------ drivers/net/ethernet/broadcom/bcmsysport.h | 2 +- 2 files changed, 37 insertions(+), 46 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c index 9ef743d6ba67..a8b20441ca7c 100644 --- a/drivers/net/ethernet/broadcom/bcmsysport.c +++ b/drivers/net/ethernet/broadcom/bcmsysport.c @@ -2311,33 +2311,22 @@ static const struct net_device_ops bcm_sysport_netdev_ops = { .ndo_select_queue = bcm_sysport_select_queue, }; -static int bcm_sysport_map_queues(struct notifier_block *nb, - struct dsa_notifier_register_info *info) +static int bcm_sysport_map_queues(struct net_device *dev, + struct net_device *slave_dev) { + struct dsa_port *dp = dsa_port_from_netdev(slave_dev); + struct bcm_sysport_priv *priv = netdev_priv(dev); struct bcm_sysport_tx_ring *ring; - struct bcm_sysport_priv *priv; - struct net_device *slave_dev; unsigned int num_tx_queues; unsigned int q, qp, port; - struct net_device *dev; - - priv = container_of(nb, struct bcm_sysport_priv, dsa_notifier); - if (priv->netdev != info->master) - return 0; - - dev = info->master; /* We can't be setting up queue inspection for non directly attached * switches */ - if (info->switch_number) + if (dp->ds->index) return 0; - if (dev->netdev_ops != &bcm_sysport_netdev_ops) - return 0; - - port = info->port_number; - slave_dev = info->info.dev; + port = dp->index; /* On SYSTEMPORT Lite we have twice as less queues, so we cannot do a * 1:1 mapping, we can only do a 2:1 mapping. By reducing the number of @@ -2377,27 +2366,16 @@ static int bcm_sysport_map_queues(struct notifier_block *nb, return 0; } -static int bcm_sysport_unmap_queues(struct notifier_block *nb, - struct dsa_notifier_register_info *info) +static int bcm_sysport_unmap_queues(struct net_device *dev, + struct net_device *slave_dev) { + struct dsa_port *dp = dsa_port_from_netdev(slave_dev); + struct bcm_sysport_priv *priv = netdev_priv(dev); struct bcm_sysport_tx_ring *ring; - struct bcm_sysport_priv *priv; - struct net_device *slave_dev; unsigned int num_tx_queues; - struct net_device *dev; unsigned int q, qp, port; - priv = container_of(nb, struct bcm_sysport_priv, dsa_notifier); - if (priv->netdev != info->master) - return 0; - - dev = info->master; - - if (dev->netdev_ops != &bcm_sysport_netdev_ops) - return 0; - - port = info->port_number; - slave_dev = info->info.dev; + port = dp->index; num_tx_queues = slave_dev->real_num_tx_queues; @@ -2418,17 +2396,30 @@ static int bcm_sysport_unmap_queues(struct notifier_block *nb, return 0; } -static int bcm_sysport_dsa_notifier(struct notifier_block *nb, - unsigned long event, void *ptr) +static int bcm_sysport_netdevice_event(struct notifier_block *nb, + unsigned long event, void *ptr) { - int ret = NOTIFY_DONE; + struct net_device *dev = netdev_notifier_info_to_dev(ptr); + struct netdev_notifier_changeupper_info *info = ptr; + struct bcm_sysport_priv *priv; + int ret = 0; + + priv = container_of(nb, struct bcm_sysport_priv, netdev_notifier); + if (priv->netdev != dev) + return NOTIFY_DONE; switch (event) { - case DSA_PORT_REGISTER: - ret = bcm_sysport_map_queues(nb, ptr); - break; - case DSA_PORT_UNREGISTER: - ret = bcm_sysport_unmap_queues(nb, ptr); + case NETDEV_CHANGEUPPER: + if (dev->netdev_ops != &bcm_sysport_netdev_ops) + return NOTIFY_DONE; + + if (!dsa_slave_dev_check(info->upper_dev)) + return NOTIFY_DONE; + + if (info->linking) + ret = bcm_sysport_map_queues(dev, info->upper_dev); + else + ret = bcm_sysport_unmap_queues(dev, info->upper_dev); break; } @@ -2601,9 +2592,9 @@ static int bcm_sysport_probe(struct platform_device *pdev) priv->rx_max_coalesced_frames = 1; u64_stats_init(&priv->syncp); - priv->dsa_notifier.notifier_call = bcm_sysport_dsa_notifier; + priv->netdev_notifier.notifier_call = bcm_sysport_netdevice_event; - ret = register_dsa_notifier(&priv->dsa_notifier); + ret = register_netdevice_notifier(&priv->netdev_notifier); if (ret) { dev_err(&pdev->dev, "failed to register DSA notifier\n"); goto err_deregister_fixed_link; @@ -2630,7 +2621,7 @@ static int bcm_sysport_probe(struct platform_device *pdev) return 0; err_deregister_notifier: - unregister_dsa_notifier(&priv->dsa_notifier); + unregister_netdevice_notifier(&priv->netdev_notifier); err_deregister_fixed_link: if (of_phy_is_fixed_link(dn)) of_phy_deregister_fixed_link(dn); @@ -2648,7 +2639,7 @@ static int bcm_sysport_remove(struct platform_device *pdev) /* Not much to do, ndo_close has been called * and we use managed allocations */ - unregister_dsa_notifier(&priv->dsa_notifier); + unregister_netdevice_notifier(&priv->netdev_notifier); unregister_netdev(dev); if (of_phy_is_fixed_link(dn)) of_phy_deregister_fixed_link(dn); diff --git a/drivers/net/ethernet/broadcom/bcmsysport.h b/drivers/net/ethernet/broadcom/bcmsysport.h index 3a5cb6f128f5..fefd3ccf0379 100644 --- a/drivers/net/ethernet/broadcom/bcmsysport.h +++ b/drivers/net/ethernet/broadcom/bcmsysport.h @@ -787,7 +787,7 @@ struct bcm_sysport_priv { struct u64_stats_sync syncp; /* map information between switch port queues and local queues */ - struct notifier_block dsa_notifier; + struct notifier_block netdev_notifier; unsigned int per_port_num_tx_queues; struct bcm_sysport_tx_ring *ring_map[DSA_MAX_PORTS * 8];