From patchwork Tue Dec 8 12:07:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 11958277 X-Patchwork-Delegate: kuba@kernel.org 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 72810C4167B for ; Tue, 8 Dec 2020 12:09:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2DA63236FB for ; Tue, 8 Dec 2020 12:09:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729271AbgLHMJT (ORCPT ); Tue, 8 Dec 2020 07:09:19 -0500 Received: from mail-eopbgr80078.outbound.protection.outlook.com ([40.107.8.78]:17934 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727650AbgLHMJT (ORCPT ); Tue, 8 Dec 2020 07:09:19 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lvBn1G7Mt5Czl6tUOeRP51J0ChUqMY5GifuQgLNVogT/XFlkncXyCxVtHpozQcBChg0ghfVopCXCDuHGStztDXbtd0IAeawFofSGm3q3jcHfeYKFFUMZo8acHt0bFXRqV7zHCadEeDFHn4g7eGKUg+AHPMZiikDANA4hElX3hkRonmmT4ErsZQZAchpwJtWjrZAgyB3CSJtxrXYxQaFzjKRUExTVhSUxHfAz6qIneKM89I+gpvRnkN3opxabESOegzr+zVMUgRvbMvsq42a5dtynojwWFo5v9DkQ3aWUagPjQv2X8XbMeC3gnTu4kGKaQdl3Hs1fk/CAtLAukczDEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GcxTilh+gt1aD6xeu9SHqJKWmikkvjsGBD30XcM3pBk=; b=b54ocslh6Yb+aP/m9k+E4ZSNFVAK+QsrftvCyIfXdWmreUih9CBSuFBuErek3tGyv6sTNH+pj2h0uKU2R/cknHqew1kr9BE8GuPcZ45/MDaINJAuYtgS4d11f7u85ylg6JlYXMgdtaDxIY+YH5Az1j/arK3JacRcnSdqSYg6JMWLTZzaAP638hOkVchdOlashHkWdfOtQaKJBHQBbexEg4B0FSu+iFdTvVJeMiiyuWWwDICyp35S+h7A83lWQAv9xi/RGJVbOJMG0uyrmoWkBVjvF9r/AHigtKOjpLE1PZYq2igqnzaZJCHrrrZVmzGQXezws9bR0T6sG+OIEjnN3A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GcxTilh+gt1aD6xeu9SHqJKWmikkvjsGBD30XcM3pBk=; b=N4iUX1/Li/HOxAuR4APdd44DJy27yIOrNMAo8KrE+Ao73jI0YDfOJ12KbEyIV8zWbQugFWvJmJ4f8ahVwk8jHrm2WiZUaxP7NRhiS/CQb1SPyBzbKYxh+FbXKZ5USH90KjRxTQCF9REvr5bsE742Alg+PCHnkVpaGqzqKExw+3c= Authentication-Results: waldekranz.com; dkim=none (message not signed) header.d=none;waldekranz.com; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) by VI1PR04MB5693.eurprd04.prod.outlook.com (2603:10a6:803:e2::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21; Tue, 8 Dec 2020 12:08:22 +0000 Received: from VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84]) by VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84%5]) with mapi id 15.20.3632.021; Tue, 8 Dec 2020 12:08:21 +0000 From: Vladimir Oltean To: Tobias Waldekranz Cc: "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org, UNGLinuxDriver@microchip.com, Alexandre Belloni , Andrew Lunn , Florian Fainelli , Vivien Didelot , Claudiu Manoil Subject: [RFC PATCH net-next 01/16] net: mscc: ocelot: offload bridge port flags to device Date: Tue, 8 Dec 2020 14:07:47 +0200 Message-Id: <20201208120802.1268708-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201208120802.1268708-1-vladimir.oltean@nxp.com> References: <20201208120802.1268708-1-vladimir.oltean@nxp.com> X-Originating-IP: [188.25.2.120] X-ClientProxiedBy: AM9P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::21) To VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.2.120) by AM9P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17 via Frontend Transport; Tue, 8 Dec 2020 12:08:19 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 47eda28a-182f-424a-2e02-08d89b71f46b X-MS-TrafficTypeDiagnostic: VI1PR04MB5693: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: d1f9dTmeJJQrkYoh0sFRZsmYARm38B1scXZbsnFO3AYhFK1Ul3aM2CPxXdYa0le+Q4NSjETaOnXv8i0d0Egg2tRAEQmZ2j0XOmxyFnvpC/bXi4TOtxOr9rmm7xunceX24pRfh0TY/knki29HLCj5tkajfBq1xMs8mZmyUEK8ZCsQEclrtaEmZ3ahxn6b7O8EMgG/yczRwUDYtl6IvTICKw7wlaH0WUW05cncU/y/kGKXDfSWHUOCxklqkrGNlZ7Ygi8NNVdpZjkfbUGe/vQ2Qht7TL+RQn1q8nB+ZNyWBWx45gS3r2O2hteHLg85HIlz4V4kKVqcz4H/ygvVpeFLGANUbPMXmgyfiOU0JN3Zop5gbTzlgxkDALCnYcqRkn7M X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5696.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(498600001)(5660300002)(956004)(83380400001)(2616005)(69590400008)(4326008)(54906003)(6506007)(6486002)(44832011)(66556008)(2906002)(36756003)(186003)(6512007)(6666004)(6916009)(66946007)(66476007)(26005)(16526019)(86362001)(52116002)(1076003)(8676002)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: AYVFVgz+0og/uJlPmwseOk/5117tyA0SizNl2Rak5ihJoVzi4bHOGiQiUjdATleNUi7vq/FKDlJ6d/CYcsW2EYL4d34fG1ePfGn17aXBuI/p2cZ2ZnYrQw+20YKmHmGLrn6Sy4381FwvUFclUPYRWkN0ezkjLMnHpmdS33KNgaWpgMN2rk1PPoWKYy1gUFRcq38EWo79nNp8j6Rg7M8OxJnxXxYyfnGO3nHkP7gzpdV50QJHdJw2QT91X58uP/NqJtjnJflwMTHMtxkIVw1OOINCcnFALYDWPeCYQtIYXkOcdXjGUbhxcRXxa8I9EdzEXU4iak9O699bhCP7CH/KtdjjTcoEhWCpxhMHYNX96FnLwkl8UG8k6r4K9kOPAzdhhiB6noEnhXyQ53ra2aEgDZkVO2Xg+sHxwhFsmEOQM7No4rPCSrEBw4qR9JX0ssz8tGVycFB+IE2/5BzXMCufGeqS6wCyJ5noR6Ata3aSW/sGrRUAkl0Pi0WRtkStTRsDFlk4azKxS2/PhZbGrWYnY8NSvasXm9AeFCo4wyB+rmB0f6Bo9n55luywwVxkP3MV3LAckSlyYyu+Akj+zISYlYaH9BK+2dUv91K2Ti2rlHcq3TAxesV+qYyc0qZ6pGJruqqn+47BFAJ0KO+kaY7xWCa8wbLm+MO9ty2cRLg0xiTObEYOvwE0bR09baDmkr3KvSK9THWJfXRC3c3imb3Sesh6a/dcvbOTyQAN9iluDK+XtE34HlhdwHvlLhxgLYzkJYr/Nn4bNYGHO3xiX1a6AbcmXnBTeZmzzev5FGUI2Mz2ceLmmJwGZ7sysRum+WrgMyyYBQMnX4wyXFcOgue58z0jkfPvuJPcnJeXLukeGog7Arh7dU7CZf3FM9qSXxWIU7KxEWZ1qFMsl0rEh+H+IeeqBs6Nm5VpwJfNkw/Gh2Xc1rh0LsX58B+7E41GIx3OrCkdn2ky2e/mJrYnAnA+4J/aRXcfGIQhUfZcluaxRkve2CHZtbFxw3mhZfUTv9ah X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 47eda28a-182f-424a-2e02-08d89b71f46b X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5696.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2020 12:08:20.9948 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: r2jXSS/8Kyzo6jq4Hwvsy5eO0Jofu/t0uHZK5nw7vYhKlfk1S5VH9ByqOMpVHfbAjJx3vYg4qPtq39/GiOabew== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5693 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC We should not be unconditionally enabling address learning, since doing that is actively detrimential when a port is standalone and not offloading a bridge. Namely, if a port in the switch is standalone and others are offloading the bridge, then we could enter a situation where we learn an address towards the standalone port, but the bridged ports could not forward the packet there, because the CPU is the only path between the standalone and the bridged ports. The solution of course is to not enable address learning unless the bridge asks for it. Currently this is the only bridge port flag we are looking at. The others (flooding etc) are TBD. Signed-off-by: Vladimir Oltean Reviewed-by: Alexandre Belloni --- drivers/net/ethernet/mscc/ocelot.c | 21 ++++++++++++++++++++- drivers/net/ethernet/mscc/ocelot.h | 3 +++ drivers/net/ethernet/mscc/ocelot_net.c | 4 ++++ include/soc/mscc/ocelot.h | 2 ++ 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index b9626eec8db6..7a5c534099d3 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -883,6 +883,7 @@ EXPORT_SYMBOL(ocelot_get_ts_info); void ocelot_bridge_stp_state_set(struct ocelot *ocelot, int port, u8 state) { + struct ocelot_port *ocelot_port = ocelot->ports[port]; u32 port_cfg; int p, i; @@ -896,7 +897,8 @@ void ocelot_bridge_stp_state_set(struct ocelot *ocelot, int port, u8 state) ocelot->bridge_fwd_mask |= BIT(port); fallthrough; case BR_STATE_LEARNING: - port_cfg |= ANA_PORT_PORT_CFG_LEARN_ENA; + if (ocelot_port->brport_flags & BR_LEARNING) + port_cfg |= ANA_PORT_PORT_CFG_LEARN_ENA; break; default: @@ -1178,6 +1180,7 @@ EXPORT_SYMBOL(ocelot_port_bridge_join); int ocelot_port_bridge_leave(struct ocelot *ocelot, int port, struct net_device *bridge) { + struct ocelot_port *ocelot_port = ocelot->ports[port]; struct ocelot_vlan pvid = {0}, native_vlan = {0}; struct switchdev_trans trans; int ret; @@ -1200,6 +1203,10 @@ int ocelot_port_bridge_leave(struct ocelot *ocelot, int port, ocelot_port_set_pvid(ocelot, port, pvid); ocelot_port_set_native_vlan(ocelot, port, native_vlan); + ocelot_port->brport_flags = 0; + ocelot_rmw_gix(ocelot, 0, ANA_PORT_PORT_CFG_LEARN_ENA, + ANA_PORT_PORT_CFG, port); + return 0; } EXPORT_SYMBOL(ocelot_port_bridge_leave); @@ -1391,6 +1398,18 @@ int ocelot_get_max_mtu(struct ocelot *ocelot, int port) } EXPORT_SYMBOL(ocelot_get_max_mtu); +void ocelot_port_bridge_flags(struct ocelot *ocelot, int port, + unsigned long flags, + struct switchdev_trans *trans) +{ + struct ocelot_port *ocelot_port = ocelot->ports[port]; + + if (switchdev_trans_ph_prepare(trans)) + return; + + ocelot_port->brport_flags = flags; +} + void ocelot_init_port(struct ocelot *ocelot, int port) { struct ocelot_port *ocelot_port = ocelot->ports[port]; diff --git a/drivers/net/ethernet/mscc/ocelot.h b/drivers/net/ethernet/mscc/ocelot.h index 291d39d49c4e..739bd201d951 100644 --- a/drivers/net/ethernet/mscc/ocelot.h +++ b/drivers/net/ethernet/mscc/ocelot.h @@ -102,6 +102,9 @@ struct ocelot_multicast { struct ocelot_pgid *pgid; }; +void ocelot_port_bridge_flags(struct ocelot *ocelot, int port, + unsigned long flags, + struct switchdev_trans *trans); int ocelot_port_fdb_do_dump(const unsigned char *addr, u16 vid, bool is_static, void *data); int ocelot_mact_learn(struct ocelot *ocelot, int port, diff --git a/drivers/net/ethernet/mscc/ocelot_net.c b/drivers/net/ethernet/mscc/ocelot_net.c index 9ba7e2b166e9..93ecd5274156 100644 --- a/drivers/net/ethernet/mscc/ocelot_net.c +++ b/drivers/net/ethernet/mscc/ocelot_net.c @@ -882,6 +882,10 @@ static int ocelot_port_attr_set(struct net_device *dev, case SWITCHDEV_ATTR_ID_BRIDGE_MC_DISABLED: ocelot_port_attr_mc_set(ocelot, port, !attr->u.mc_disabled); break; + case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS: + ocelot_port_bridge_flags(ocelot, port, attr->u.brport_flags, + trans); + break; default: err = -EOPNOTSUPP; break; diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index 2f4cd3288bcc..50514c087231 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -581,6 +581,8 @@ struct ocelot_port { struct regmap *target; + unsigned long brport_flags; + bool vlan_aware; /* VLAN that untagged frames are classified to, on ingress */ struct ocelot_vlan pvid_vlan; From patchwork Tue Dec 8 12:07:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 11958279 X-Patchwork-Delegate: kuba@kernel.org 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 A1EFBC433FE for ; Tue, 8 Dec 2020 12:09:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 50DAC239D0 for ; Tue, 8 Dec 2020 12:09:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729276AbgLHMJY (ORCPT ); Tue, 8 Dec 2020 07:09:24 -0500 Received: from mail-eopbgr80048.outbound.protection.outlook.com ([40.107.8.48]:13187 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727650AbgLHMJX (ORCPT ); Tue, 8 Dec 2020 07:09:23 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CVndl1q6QmfUjDWswp2B+8FR0gYLboRIEYCN+WzPdbJBTS26pJgqwH3CptRyezyn23MIyHWSYgRHA7Iyc7+Y7NwiHdr4LQpjwlHpkhjV6UbGHIEG7dl4OvicP62soAg5bENiPtG/VOi/jK4oHUfJi1XXy+D8N+R9TIrvKLcCcUOHQZ4HzgciBVaFf1UxJDUK2767lNyyEB1d7TCKjclhGv0GSKQWTs8TqyWJUST0X1Fqt9bopLhwPYzWGi8tclyE2IjogWiS0Vpc410nmaEljkeoVEqd9HFLByLcJFoUr8zo6lmbFBlON4NC9sVkGmP5WGpTyDo9N0gz+GRKvPl8gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mC+/LJuLGZhWWYdd19R01xP4ACEd3zBhKZBBPkbOsHk=; b=YVJSDcYtEQPV3IHFqHLK97cy23FMHdn4ERy0EoKv/L/BLfFUFu/uHFC9Y7ccluNv9sz+XaH0acQ+mmUlXW5O6jV4153PCgLB6P2sLGia5/1F8dGfh4e6ZKIUdTVYY8Bsr6KID8wxgdYG0l1kbXvbg0452zEUFYAqYQbljtzoYgK5cqjkRA7TGrbEhfhYxGBWCeHhXvjj2fbpPsT0UPl/Ny9b2JZ5LTZpbK2LEHL32Za1ZzT144+urnzk3Pe3zumPtN7x5B3FEobiILSP5nHAbvbk2xQuQg/xTj60GW4Ss41sF/H1+pOCjcVmrJj5Qfiaz2PRHD5wowM/tZr2lc8npQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mC+/LJuLGZhWWYdd19R01xP4ACEd3zBhKZBBPkbOsHk=; b=ARpAGtdePhJd27ZHM7xDHxLldwfINgcIsuUvCd4MrJ9PQi1UEuTBPgtxxnIMEhuijXzWjP540VyEIpKu4m9LkcyDRklsaKJ/7KfjyTYA1uoErNe9iQTugihLtK3gL9pjDAq802M7h9O8NU76I6W6XeSkBjUSriWO5y93OfMIVZE= Authentication-Results: waldekranz.com; dkim=none (message not signed) header.d=none;waldekranz.com; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) by VI1PR04MB5693.eurprd04.prod.outlook.com (2603:10a6:803:e2::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21; Tue, 8 Dec 2020 12:08:22 +0000 Received: from VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84]) by VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84%5]) with mapi id 15.20.3632.021; Tue, 8 Dec 2020 12:08:22 +0000 From: Vladimir Oltean To: Tobias Waldekranz Cc: "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org, UNGLinuxDriver@microchip.com, Alexandre Belloni , Andrew Lunn , Florian Fainelli , Vivien Didelot , Claudiu Manoil Subject: [RFC PATCH net-next 02/16] net: mscc: ocelot: allow offloading of bridge on top of LAG Date: Tue, 8 Dec 2020 14:07:48 +0200 Message-Id: <20201208120802.1268708-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201208120802.1268708-1-vladimir.oltean@nxp.com> References: <20201208120802.1268708-1-vladimir.oltean@nxp.com> X-Originating-IP: [188.25.2.120] X-ClientProxiedBy: AM9P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::21) To VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.2.120) by AM9P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17 via Frontend Transport; Tue, 8 Dec 2020 12:08:21 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 8d7cd39a-416d-40f0-b22f-08d89b71f547 X-MS-TrafficTypeDiagnostic: VI1PR04MB5693: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HT/9yn2F8zWA0TpGX7DNibyz62ujBDaDJayPOBSPTKrs8zOqTzNWSArbwA6UFiqfdy1voobWncrZ8kbvSEMhd8pyuCZh8nGHX7bgNtbAqz7TisMstKC6r+MYrvm8NXDqxCYMYEjRqMZXrVnMawdA/WsHEMSjmUa0U2DH8RQ+VDuxMzFQe3YucEAbcciLeku7oxKGtGXT/geuJ9/LSYy5vRvxRq8EfuB6IA9GNU/V+V/BUczikhVa1RWi7N+rD/hVOrDMPqAOy6KtxoALYqQvX3enBAWF8ry6/QTuX2DemEl9fiEd0H8cUkTvHhvBbVyCRnQEz4vbwCYujXUWOqIshzdc86rlmLN4X0e8nkqXDuSBkL/PfxH7AeIiY8zSTIl+ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5696.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(498600001)(5660300002)(956004)(83380400001)(2616005)(69590400008)(4326008)(54906003)(6506007)(6486002)(44832011)(66556008)(2906002)(36756003)(186003)(6512007)(6666004)(6916009)(66946007)(66476007)(26005)(16526019)(86362001)(52116002)(1076003)(8676002)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 3dJVLdDicMVh349M2qCpmV7+79ohK+xkBkuNYY0x8P4phFESBB1T6yZifqOErls6zMlml0lt+xijBGfu1aYmK4oI9MuwFFH3XIxttvQbqrZi7DXs3wHdNR8oMKkoj0gKjO/9wv74cfbVgXv3TbEvQYU7lfCJePNryDAYVlvNo8aqi8J1fNvlPFy5qll8xa9uEhGFWxQ7bwqBxinvoT2dxU6lS9pV+OPqF6ee0O/jo7Ugzblx1UyF/hLrFmHuZTWKcQnFa114zwPeKdF6whFINHmiHDwyBY+b3yHlDlxgyU8ZdBnhWqZR9KmHTUfKjByHoDbsaF3/SgC5gqb7I/JKs2TVFLPeW5rHK9yHLWZH393+UPbZZyGOG758tRV8ul3K1+M67RjHzgqR9HsDNQc0LBohUdHgNd4j7CRqFiKJsObQ6fjo/n9P1HT++tRXiU0/Sp7rfmNuns5WWNxPYwxHL4ayKbHuu4wiwlN194AtYxLp7rZss94WxYcMSOwv+wJbXa2EOGdDLFxkQ0dINdhD927tiPO3DSWxoLcrVGJtmGWmjwKXWlg9Kd154cM3ZTOVxlRNRZ6M7KYKJnTp4veyPhwNHQmU5yoXz59Jr/8HBgHDYSlbtl00MwH1IY0wOeHtGTaABd1bCqps5l8nxJ527J7m7+4Wtp61EdxemoNr5Qlwi1GEpJ8dv77YUsQ1dqMNls37PJyu+vgKoy9NCwz5/wIbDNuU4VgsrOtrG+yHMNa3CM7+26VXQbUDWBOCg08yyx1M+ONS5B5R7hN7h/rq8EvSQmVaUU1i60QArq7VlsIyMuT+7sfW92Mr0s4yM6PAdtsUjQt5x2uqBNKhPYT9q+0qDfF9+7j5+RnF0YsC6M7jWr2hxeAixSUjTbAIgNbGgXsNwvTLgc5DKwcnpeoAKUYo5r74ROvgZiHtqzjLvXeyDuKYsq6v7vMQJdVDY10RmtUOgrZPCAXIFadjjHAN+Lplxcu/gt//Xha5SFpz2aS/5P5xJKeIKIy7fLRw4ULG X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8d7cd39a-416d-40f0-b22f-08d89b71f547 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5696.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2020 12:08:22.4399 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: a1o/Nzb1ePNM3CPCBzfOZfogfqySLcYBCw3GoOR0xf6LPTQy/iWCSB5HXvmbULSNHEj5vRvT+YFtu/bqdhDweA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5693 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Commit 7afb3e575e5a ("net: mscc: ocelot: don't handle netdev events for other netdevs") was too aggressive, and it made ocelot_netdevice_event react only to network interface events emitted for the ocelot switch ports. In fact, only the PRECHANGEUPPER should have had that check. When we ignore all events that are not for us, we miss the fact that the upper of the LAG changes, and the bonding interface gets enslaved to a bridge. This is an operation we could offload under certain conditions. Signed-off-by: Vladimir Oltean Reviewed-by: Alexandre Belloni --- drivers/net/ethernet/mscc/ocelot_net.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot_net.c b/drivers/net/ethernet/mscc/ocelot_net.c index 93ecd5274156..6fb2a813e694 100644 --- a/drivers/net/ethernet/mscc/ocelot_net.c +++ b/drivers/net/ethernet/mscc/ocelot_net.c @@ -1047,10 +1047,8 @@ static int ocelot_netdevice_event(struct notifier_block *unused, struct net_device *dev = netdev_notifier_info_to_dev(ptr); int ret = 0; - if (!ocelot_netdevice_dev_check(dev)) - return 0; - if (event == NETDEV_PRECHANGEUPPER && + ocelot_netdevice_dev_check(dev) && netif_is_lag_master(info->upper_dev)) { struct netdev_lag_upper_info *lag_upper_info = info->upper_info; struct netlink_ext_ack *extack; From patchwork Tue Dec 8 12:07:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 11958287 X-Patchwork-Delegate: kuba@kernel.org 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 3C1F6C433FE for ; Tue, 8 Dec 2020 12:09:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EF81A23406 for ; Tue, 8 Dec 2020 12:09:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729305AbgLHMJ4 (ORCPT ); Tue, 8 Dec 2020 07:09:56 -0500 Received: from mail-eopbgr80053.outbound.protection.outlook.com ([40.107.8.53]:11267 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727550AbgLHMJz (ORCPT ); Tue, 8 Dec 2020 07:09:55 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hmXSg79QeXyxGQl6s1wvLx8nYmEB6ALgoG1JMlGIgKRGeFxOypHpJ0xvCDZoHN85SKtesxupAgxGy1CbC/IWSitCFhp7Wdr3reC7x9VY7GFgM9dRyw/V35hoXnV2BJpSsaDmT+i6s+Sai1Qxu9I0Hnrq5wuUf6o0SOyFDKG32Rev48FmKM1cLAoDxv8HnOLx5t5vDIy9YZj50huuFsnEvvDgMpakN3Nu/S5JhIzIEHUYrk8+IA/7IYnGoxfim2NZqK16ELZwi7fYWktQg6Loq9i45F1OGU8oYsQzLAAtWKFMAn1LDL5aUDAddOyQGjbEVo7RAYgNX0lf4LWTNHFepQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8DaZUhNkgZuXL1dKYDb/d58bbSIhY6QJ5vhZlaxJ1vk=; b=eM0n4MMc1bk45iGZhj7i2gFe/IdFtTmwFNvdNTO3eA2TmJx0qgawAKd2TICO6HAdmd/9ZYIkDMfRR0WHZxqZjw8/tX0xxH8F15ujlxtG2LTTjh1gTka81oOpOJrRJMieopMaws3sDnu0zcp8YFL4UJZ4K/dtq9agIE9WdKBLJThq0lD8ydhxa1OiwLWXcvYQwD23eYfyF/TK6smDKFcv8Dz7tkiqly97/6PlsspMy0S4vgzZwtF/ZWFbJ36E1rWwIU8Ec7OgtSsx5qtvmNQk3PozEFblHpXn3VSfYBkiFf7R0iXOLap3Bu6/t/GFDBKhxtuLA5/QZGnBaOW/fm6qVQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8DaZUhNkgZuXL1dKYDb/d58bbSIhY6QJ5vhZlaxJ1vk=; b=EkEahh2Ydd33DPrTK3bj4TL8RczXsHd5lX355ryOthrGFJDpu0GJuk0VZAK0AGMmapbm5g239BI+1y27uqcfkrubUd3IY65Gmaw4YTUFaACi/h53CYNkTaX3aVKkFw839WIYYberdb6+Nb05kEJ+TvGxCTFBA2c+yb1YiOOuyI8= Authentication-Results: waldekranz.com; dkim=none (message not signed) header.d=none;waldekranz.com; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) by VI1PR04MB5693.eurprd04.prod.outlook.com (2603:10a6:803:e2::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21; Tue, 8 Dec 2020 12:08:23 +0000 Received: from VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84]) by VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84%5]) with mapi id 15.20.3632.021; Tue, 8 Dec 2020 12:08:23 +0000 From: Vladimir Oltean To: Tobias Waldekranz Cc: "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org, UNGLinuxDriver@microchip.com, Alexandre Belloni , Andrew Lunn , Florian Fainelli , Vivien Didelot , Claudiu Manoil Subject: [RFC PATCH net-next 03/16] net: mscc: ocelot: rename ocelot_netdevice_port_event to ocelot_netdevice_changeupper Date: Tue, 8 Dec 2020 14:07:49 +0200 Message-Id: <20201208120802.1268708-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201208120802.1268708-1-vladimir.oltean@nxp.com> References: <20201208120802.1268708-1-vladimir.oltean@nxp.com> X-Originating-IP: [188.25.2.120] X-ClientProxiedBy: AM9P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::21) To VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.2.120) by AM9P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17 via Frontend Transport; Tue, 8 Dec 2020 12:08:22 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: b5adbc3b-b82e-42db-916b-08d89b71f627 X-MS-TrafficTypeDiagnostic: VI1PR04MB5693: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: I3x1TAME4Pm0hRucA3Cu46yNP0lRcnaamGUWVAPVphhHVwIwRrB813unOQAtOfc71BCuJk5/877v4EsNajVf6B88Sg2jhXpu466V7ayCp8oLqCIQV+0lTOJuWNmfRR4Fodsqj0aMjrBYHTUJF5DY0WPY5erYkgzcepOkcZeKGjDuLiaY/gO9HnO2mZnSF/QqyIwn3fuZQ1+u7D7Cbhz7ytgLaDLQeCuTnZJCbTyDxZfOaG81eAy84Q7oIwQzpgrwsiv8A3U1bzWvxA+S7LCKR4PEg05S//VYIsx1qaIa5pHpoKLCFhrtIdGKkztgRZabr/jule6o47hEuh8P5Dgd7UDc1i0GqDTLINaftBa+kPDFprJO1asFJ1cvh8kc/Y9a X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5696.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(498600001)(5660300002)(956004)(83380400001)(2616005)(69590400008)(4326008)(54906003)(6506007)(6486002)(44832011)(66556008)(2906002)(36756003)(186003)(6512007)(6666004)(6916009)(66946007)(66476007)(26005)(16526019)(86362001)(52116002)(1076003)(8676002)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 47loPXEIMa553/HEZW8f0s24u0T31VbS13OVquN4RarJ0fx69Vbksc0pxY9ECSEMf1u/9u5MBmmWP1YbgZfx9sl2l/C9s5Ubza9upS5TVmJS9nb7f/NhR2T1ICflcd3nG8RCp8cAJblEitnxwmdIrSPTwRoyFZ6ORanGHDqXa1DDrmXFuj0ZxV+p3FghlYVXbiY7vkM+xIPOJYyUwTgLl51+krK0ZLFnBqop8M3gVQi3xpWUAj6FrVROovNSE+MQrvnvGL8mnDOPR17VzKQu9XeA8WejCP1Rw6zzvJ86VNFTuxM27mFzhClBjKebfGmnuzl7UHzDlp2hvnTjTYy74e6co4g8I/kdDcAMMLR3brQeufA+0wVesiNCydHEx+t+63tDkHdC338NMlDtuAghJkkEABG2kuHamoFx0Ztz3u/kl1zPpvxKM1vTCVomQhzxAAL0OykuwRjGmGdBdKwqp9QnqP82vuq9Z3niXhjcE0Upp/72IURBUYmkAUezSJJtQIwCwHqO9FvScLlYz24QY7khLjYHeAMsXGN3ZEd+dJdL2p6iSdXCJNLdaD4s/JG/jc3Nc3/NoN/7bAL+Y9HncoucIzQMZ5CXn9ufRqE4STgAcPtONkK2joEKejsGOdYwK+HwAYX5uw8Pq+/fCXOfGZgdaaTReWGjCwEtYWZsTWMM5TPvvUtWBjKZNy/o6IXLiKbf0ThpusTe/cEC4qHIALdwxjBy9AMO13bwSFbD+P73dPbDIgSG4ag3y1oajBUV/ZMt8GkeY3IByTz+ZVQv7Z7qBgBKHXmJQ49Z4IUydrSnqJZiThdwQD06NJTQNpAyEZsBUqU6Tjt+gbon72eHkSbmolScg5eFBDkrUaanjJIbcnA8kGIAta8j5ZPRa6Nb1dTv6vJhJwfqlFYyo6V/FXLZn49ebA0bjRCEQtvzMmn3AmbeZM3Z7rQgLxQDfzjrI3Tt41hg330wavKawjuw7aNInW7aJEKLVnd2tDCqO8OY7coIJKR+AkrJnA+/nLkB X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b5adbc3b-b82e-42db-916b-08d89b71f627 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5696.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2020 12:08:23.8881 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: hOJMrWyUl5I0wKdwB//k7Jbh95ObbZr6D5ZVliB3+j0WmNUF34SnLBQTTJeHMns+/iFtNVCb8jpJhUY9e2JZGQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5693 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC ocelot_netdevice_port_event treats a single event, NETDEV_CHANGEUPPER. So we can remove the check for the type of event, and rename the function to be more suggestive, since there already is a function with a very similar name of ocelot_netdevice_event. Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/mscc/ocelot_net.c | 59 ++++++++++++-------------- 1 file changed, 27 insertions(+), 32 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot_net.c b/drivers/net/ethernet/mscc/ocelot_net.c index 6fb2a813e694..50765a3b1c44 100644 --- a/drivers/net/ethernet/mscc/ocelot_net.c +++ b/drivers/net/ethernet/mscc/ocelot_net.c @@ -1003,9 +1003,8 @@ static int ocelot_port_obj_del(struct net_device *dev, return ret; } -static int ocelot_netdevice_port_event(struct net_device *dev, - unsigned long event, - struct netdev_notifier_changeupper_info *info) +static int ocelot_netdevice_changeupper(struct net_device *dev, + struct netdev_notifier_changeupper_info *info) { struct ocelot_port_private *priv = netdev_priv(dev); struct ocelot_port *ocelot_port = &priv->port; @@ -1013,28 +1012,22 @@ static int ocelot_netdevice_port_event(struct net_device *dev, int port = priv->chip_port; int err = 0; - switch (event) { - case NETDEV_CHANGEUPPER: - if (netif_is_bridge_master(info->upper_dev)) { - if (info->linking) { - err = ocelot_port_bridge_join(ocelot, port, - info->upper_dev); - } else { - err = ocelot_port_bridge_leave(ocelot, port, - info->upper_dev); - } - } - if (netif_is_lag_master(info->upper_dev)) { - if (info->linking) - err = ocelot_port_lag_join(ocelot, port, - info->upper_dev); - else - ocelot_port_lag_leave(ocelot, port, + if (netif_is_bridge_master(info->upper_dev)) { + if (info->linking) { + err = ocelot_port_bridge_join(ocelot, port, info->upper_dev); + } else { + err = ocelot_port_bridge_leave(ocelot, port, + info->upper_dev); } - break; - default: - break; + } + if (netif_is_lag_master(info->upper_dev)) { + if (info->linking) + err = ocelot_port_lag_join(ocelot, port, + info->upper_dev); + else + ocelot_port_lag_leave(ocelot, port, + info->upper_dev); } return err; @@ -1063,17 +1056,19 @@ static int ocelot_netdevice_event(struct notifier_block *unused, } } - if (netif_is_lag_master(dev)) { - struct net_device *slave; - struct list_head *iter; + if (event == NETDEV_CHANGEUPPER) { + if (netif_is_lag_master(dev)) { + struct net_device *slave; + struct list_head *iter; - netdev_for_each_lower_dev(dev, slave, iter) { - ret = ocelot_netdevice_port_event(slave, event, info); - if (ret) - goto notify; + netdev_for_each_lower_dev(dev, slave, iter) { + ret = ocelot_netdevice_changeupper(slave, event, info); + if (ret) + goto notify; + } + } else { + ret = ocelot_netdevice_changeupper(dev, event, info); } - } else { - ret = ocelot_netdevice_port_event(dev, event, info); } notify: From patchwork Tue Dec 8 12:07:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 11958295 X-Patchwork-Delegate: kuba@kernel.org 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 A8339C4167B for ; Tue, 8 Dec 2020 12:10:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 671F0236FB for ; Tue, 8 Dec 2020 12:10:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729343AbgLHMKL (ORCPT ); Tue, 8 Dec 2020 07:10:11 -0500 Received: from mail-eopbgr70082.outbound.protection.outlook.com ([40.107.7.82]:43431 "EHLO EUR04-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729286AbgLHMKK (ORCPT ); Tue, 8 Dec 2020 07:10:10 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cyjXZXsynyHqIShdeNCxCpGZLpJGBcPEt2tI8ei0ESgW1Ce7H+TDsviXsiUO3EgZwBlsayBKP1+M1r2J9YzehjbMCK9dUmp/5//WrERN8va6DLR/L007xtyMEFuKTPnKScKczR04mrh04+vuSskYmUIZT231u5hPmnFAVWBsn9RIhTXYuY5LCkr8zJUgKLjVjWur2/Duefdtke7DHZMyrhDG65/0JqhtHb5EozWmtFFrAFFyAZNaivCw9aHOIZ/Td05XDi/BXgX5AZ+cmzsKQoK6q+gwdorvaTqgONgRwcz65wrk5mj+O5/4D0JobSJGlTontSb/Djo+Qb2mg8m/EA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xEQfj5pnIWtEqMGn6qpXmVhBqBi132UFkkhrtPu/Nmc=; b=V7qGptN4Q6Xi4ET297N+rl+Yxs+LPLVrmy5OEHuHDUPVRx+VevTArb1TZAaE2rqXMFCtuCsLDOSMYM/KWAdNiqv1rKP0Y8YDHWagg5JGdwwMkAYENvDRkKdHrVkEAlWeAq/kBSBmOV/vzLnpwrWcN7iAfs7QfpdncgWhPa+uwO5UYcDvCkWxIvgIY8yi9jwEPwvul5p9ck30ZkoZQqyclbGP2e5Q9DOXe22nLpmLC3a1JsBynbESGfwA0+oPZVDHrPRMW9Q0bJpUFve9JA/qcU21Tt67L0ORzx9Jo2yI3anuH/wpaVg9JMobN+0Wk7peYzpFJ7sLCsbJ5JlW4Vdk0A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xEQfj5pnIWtEqMGn6qpXmVhBqBi132UFkkhrtPu/Nmc=; b=UOn44+skPz8Wd9kjSaZHfbRN7xxSKskVEHnf415gBR62m1oAjDwrPFt5gVdvqAi+g/YCXLaDgGxRBfuQtxZCqa6DAWC6sIjcD+97OHiWG/9y2VHLufg8nlkRRG8sPpHPvekSo35Eeh9Vi2R5v60SNRDP8Tr+2nT1RXfNQeSKuU0= Authentication-Results: waldekranz.com; dkim=none (message not signed) header.d=none;waldekranz.com; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) by VI1PR04MB5693.eurprd04.prod.outlook.com (2603:10a6:803:e2::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21; Tue, 8 Dec 2020 12:08:25 +0000 Received: from VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84]) by VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84%5]) with mapi id 15.20.3632.021; Tue, 8 Dec 2020 12:08:25 +0000 From: Vladimir Oltean To: Tobias Waldekranz Cc: "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org, UNGLinuxDriver@microchip.com, Alexandre Belloni , Andrew Lunn , Florian Fainelli , Vivien Didelot , Claudiu Manoil Subject: [RFC PATCH net-next 04/16] net: mscc: ocelot: use a switch-case statement in ocelot_netdevice_event Date: Tue, 8 Dec 2020 14:07:50 +0200 Message-Id: <20201208120802.1268708-5-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201208120802.1268708-1-vladimir.oltean@nxp.com> References: <20201208120802.1268708-1-vladimir.oltean@nxp.com> X-Originating-IP: [188.25.2.120] X-ClientProxiedBy: AM9P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::21) To VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.2.120) by AM9P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17 via Frontend Transport; Tue, 8 Dec 2020 12:08:24 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: e9ed5cae-ab9f-4ca3-d08f-08d89b71f6ff X-MS-TrafficTypeDiagnostic: VI1PR04MB5693: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2399; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 14ZoDxTWOO6rIcHjDHMYFjG+H7K1j4v5L30OsP3I/nDq5LYft+dJF7mO3unVxU69GV4ZjPD9bWdpcS4+KEleIck5M6jjiJ/PMPlaadAb1Iw9n0tQCEp05+5gKmvx/+dxYT5xO1jMpfbB8Gv4xG1T34FtsRn6mGTHLP83Y5nlW+m0XjrP2bP8s3xYUkhOa6g4KbO+mLKArbK92VmhO2Bk70z5NuyeAD6FFMpS096TsnKzu+O/EjHnTMHN71kfCQQz3lY2bC7T7GEE9nnQ2vQVC90G/mn3VT/F7SiX+IOcRM4ClVm7Q4z7ivTtoZI0ERXJ95E5+m9v2P1EEwaA10P6CoeNVxT7seZbi0JhbyGxLU34woOi3DxQ13sCi2Dk8/QR X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5696.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(498600001)(5660300002)(956004)(83380400001)(2616005)(69590400008)(4326008)(54906003)(6506007)(6486002)(44832011)(66556008)(2906002)(36756003)(186003)(6512007)(6666004)(6916009)(66946007)(66476007)(26005)(16526019)(86362001)(52116002)(1076003)(8676002)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: l1XSIvYCaxPfvMsjsCpJVSCIW91g4bT0eos5wB2Ji7G5zAKp3U6hOqJdEUGsr5Ud/bZP1GiIKDxaLcJUBvDjJUD39q8WcdE/5DknCc2ql1Fl0JgJjzBTlYpF956vwd+zomjbPIV8Grhh64hLBU1I9vLwRTXNarqY6OpWeUCqE3svXCdRacBgFhS5p8kiOX53B+x1evBHDHlYtoZZ5R72zzkOJh5M2W9hQwyLVZAvd92vz5dIWWyvoyCLO4sLeUxIS+rDQ4B824q8ye+JEwKAsddBb580C8i3l9kpykvjqnPMAP9GIR6KdjqE9u5OfwzgPI8+VGZp9GdxkJueXjqr1LdMEN+hn0/Ksjjg2fqB/3jk5G588WRHMS5qXsJF1t9KwnNjbQOigR3Mkz3bc6yVqF0wCFj90LUwnmMyQYKnOQ1ySuPr92So5jw1i7+bqrf+CAXLXzoBhgUH3drknw98UhSMuLDAXoJOQsPv4Sqzx+ID4nzUju5CL7KJy4IxjEFfPkrvjkWjC/VGiSRmODmkohrEMDyz9lDtCZL+9EGZ7GKegzhmjvXc5/iAAdtOBJ1OmGCYyqE4P+AG0pE/eK9Op0w4Drjkx3bP0SZT4JtrXReYZkr0XfLS22LrwI7saE6//lB/QH/n5xvNWlXDT1D0TLDrRj7LlzBQ3h/lbCe4CAQj/G4EWhAISIqtQoPo5XoZYdV27SC9XobZow8jWpMPwN6BWzfzWSWVpy8BS8N/kfEVqbZRVP3c07fXPgmyCxbkiB2/OzgncRH9y/+xq7Zq5s3mw93txMxv8CoZWtrcMgxmMkinRayHsMiIKOnYYOe/Aaf9tzUirR14i7RX50sjdPM3oc+e9Sw0BHiHbyWeHutUPnMMPP+lZ5IQPNOx8oX5GYNw9I9Fz91SeM81W1ZIX51EcGC0Xkx3iUntR1R5Bg0xtMd/2qw7yl/GPcYxHiRRPMbp4GFEUDwdT+LTr/Irs4uLGEY4wCrNBnJw5M5RMa63y+ZokQGJQoteDMkyZcvf X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e9ed5cae-ab9f-4ca3-d08f-08d89b71f6ff X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5696.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2020 12:08:25.2543 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 7V5FiDzu6eIl+yvk5rG4z2rZIQOYfunfkLesMOugDjNG/dBXMo3Y0YdEFUVeWIVgxd9SYTS4pLKjY1QvlulWZw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5693 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Make ocelot's net device event handler more streamlined by structuring it in a similar way with others. The inspiration here was dsa_slave_netdevice_event. Signed-off-by: Vladimir Oltean Reviewed-by: Alexandre Belloni --- drivers/net/ethernet/mscc/ocelot_net.c | 68 +++++++++++++++++--------- 1 file changed, 45 insertions(+), 23 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot_net.c b/drivers/net/ethernet/mscc/ocelot_net.c index 50765a3b1c44..47b620967156 100644 --- a/drivers/net/ethernet/mscc/ocelot_net.c +++ b/drivers/net/ethernet/mscc/ocelot_net.c @@ -1030,49 +1030,71 @@ static int ocelot_netdevice_changeupper(struct net_device *dev, info->upper_dev); } - return err; + return notifier_from_errno(err); +} + +static int +ocelot_netdevice_lag_changeupper(struct net_device *dev, + struct netdev_notifier_changeupper_info *info) +{ + struct net_device *lower; + struct list_head *iter; + int err = NOTIFY_DONE; + + netdev_for_each_lower_dev(dev, lower, iter) { + err = ocelot_netdevice_changeupper(lower, info); + if (err) + return notifier_from_errno(err); + } + + return NOTIFY_DONE; } static int ocelot_netdevice_event(struct notifier_block *unused, unsigned long event, void *ptr) { - struct netdev_notifier_changeupper_info *info = ptr; struct net_device *dev = netdev_notifier_info_to_dev(ptr); - int ret = 0; - if (event == NETDEV_PRECHANGEUPPER && - ocelot_netdevice_dev_check(dev) && - netif_is_lag_master(info->upper_dev)) { - struct netdev_lag_upper_info *lag_upper_info = info->upper_info; + switch (event) { + case NETDEV_PRECHANGEUPPER: { + struct netdev_notifier_changeupper_info *info = ptr; + struct netdev_lag_upper_info *lag_upper_info; struct netlink_ext_ack *extack; + if (!ocelot_netdevice_dev_check(dev)) + break; + + if (!netif_is_lag_master(info->upper_dev)) + break; + + lag_upper_info = info->upper_info; + if (lag_upper_info && lag_upper_info->tx_type != NETDEV_LAG_TX_TYPE_HASH) { extack = netdev_notifier_info_to_extack(&info->info); NL_SET_ERR_MSG_MOD(extack, "LAG device using unsupported Tx type"); - ret = -EINVAL; - goto notify; + return NOTIFY_BAD; } + + break; } + case NETDEV_CHANGEUPPER: { + struct netdev_notifier_changeupper_info *info = ptr; - if (event == NETDEV_CHANGEUPPER) { - if (netif_is_lag_master(dev)) { - struct net_device *slave; - struct list_head *iter; + if (ocelot_netdevice_dev_check(dev)) + return ocelot_netdevice_changeupper(dev, info); - netdev_for_each_lower_dev(dev, slave, iter) { - ret = ocelot_netdevice_changeupper(slave, event, info); - if (ret) - goto notify; - } - } else { - ret = ocelot_netdevice_changeupper(dev, event, info); - } + if (netif_is_lag_master(dev)) + return ocelot_netdevice_lag_changeupper(dev, info); + + break; + } + default: + break; } -notify: - return notifier_from_errno(ret); + return NOTIFY_DONE; } struct notifier_block ocelot_netdevice_nb __read_mostly = { From patchwork Tue Dec 8 12:07:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 11958281 X-Patchwork-Delegate: kuba@kernel.org 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 D3C2DC4361B for ; Tue, 8 Dec 2020 12:09:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 892B1236FB for ; Tue, 8 Dec 2020 12:09:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729348AbgLHMJl (ORCPT ); Tue, 8 Dec 2020 07:09:41 -0500 Received: from mail-eopbgr80078.outbound.protection.outlook.com ([40.107.8.78]:17934 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729343AbgLHMJl (ORCPT ); Tue, 8 Dec 2020 07:09:41 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Kok5QayCfDNF8Gtiy6SF8m+Hx6TINySVyhBUmrxfZ3XJr5dbyMdkWthqCzhNz7qxNpnTEbWqbhSCcysQ+3LTZSoyp3BVv86VDOA34xuZuQg6AbMj/N4QFmM37N+OA9xkUPkH5VKSQdiU+tSGCpkO8bGWMTNWX2ZvidQkM8QCHwi4/XCVgGa9YKsSPD3VoqjnCgNzXVU8fKCwrRmRIHSqlX0IoYDAVap7J2k71iweiawl1XmblNpXvcOerDGbYmyyiHUZvzOcUVPQ0vvhAg4hqzyaAjpNGC4NAtG8irg6tufF1IDTubQUNJ6aYRJ2kLvByLVo3TutxpRp6C5JCsCOBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=n36USH50cpLgULEquqv35fT1Rapnt6FXLE48rPBxn1w=; b=jheZ3LwyPCjpUUDImTiFO5JQBEcrV2m0EjD4wnPT/j6usZmQJabaRhZI+VQ3m9cnZSIrI1OG3OgJ4MEFr/X7mWn9U+qrFbnDJ4NJRLFBMT6AiP5t6UWdtstpRFmsxHXczIhVFMQxcPrFYRgsAvCSFS4oNRSin4fOADVGEu7V807DEoTTK3pjcEcwfLeMX9bHe9NUdUahT30KwJINEemwZTwf0df6CpWGeeW5EihnXC15dwBgTUlSA03SO1UzS64Iem2movCxgrCvHDL3TL9aQXPE/l+wMqob/bBvKacMXFg94bvGR1guspEnI8Dln6I0ErPfVNTdPP7Hkhw+yy/ULA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=n36USH50cpLgULEquqv35fT1Rapnt6FXLE48rPBxn1w=; b=jVSimT0u5T/B4EX0pfAoLEiM3m7orcsAmDSpIS/zCUfdFV0smpJdETCTLpLWAI5PlhKS0cRmfVUmrltnM6Yfde2BjBM4H7EWkXQegyNaL+w3pOy6CBmZOdr+g6e1nhD00zZ10mlesgG7w0HHCmVophSIQONKwtPpSc733R/y2EU= Authentication-Results: waldekranz.com; dkim=none (message not signed) header.d=none;waldekranz.com; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) by VI1PR04MB5693.eurprd04.prod.outlook.com (2603:10a6:803:e2::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21; Tue, 8 Dec 2020 12:08:26 +0000 Received: from VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84]) by VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84%5]) with mapi id 15.20.3632.021; Tue, 8 Dec 2020 12:08:26 +0000 From: Vladimir Oltean To: Tobias Waldekranz Cc: "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org, UNGLinuxDriver@microchip.com, Alexandre Belloni , Andrew Lunn , Florian Fainelli , Vivien Didelot , Claudiu Manoil Subject: [RFC PATCH net-next 05/16] net: mscc: ocelot: don't refuse bonding interfaces we can't offload Date: Tue, 8 Dec 2020 14:07:51 +0200 Message-Id: <20201208120802.1268708-6-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201208120802.1268708-1-vladimir.oltean@nxp.com> References: <20201208120802.1268708-1-vladimir.oltean@nxp.com> X-Originating-IP: [188.25.2.120] X-ClientProxiedBy: AM9P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::21) To VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.2.120) by AM9P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17 via Frontend Transport; Tue, 8 Dec 2020 12:08:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 61705ad2-381c-4f00-257d-08d89b71f7d7 X-MS-TrafficTypeDiagnostic: VI1PR04MB5693: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uccEhK1BfvifwjF1ii12/HX1XUiN9t+LwQQA5PRRCLKVzdbYfRhSddtCcBpegkRF4YRX1SbhrLm9aaNAgDYq31qA6Q2hPN/aZ7jYnH2xamyDwBbqe2SQ1I44aKSWWggORHFnmCds8kcL22UiPFdGmkLK9TqKlfsoiaEOH0MEbMk+A95CD1G4iH1kzu/qLN7QceMc9HaBksHmQm2yavU74PRs8tBILsKU1E5vQH6yB+K5rLUgnPBUzmIq+bdHbMNxikku6P0OE/lAMIymb0DdFyLc19Hi+2f4hhVSXVoq5OeQWiYmRmqN/1V4KEMv25kHSB3uYFrHyJtSB1fFizD0RBPZrnbEjmVoEpE2aG/0W4Dd/pSndgqhxkmbuhXW6dIT X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5696.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(498600001)(5660300002)(956004)(83380400001)(2616005)(69590400008)(4326008)(54906003)(6506007)(6486002)(44832011)(66556008)(2906002)(36756003)(186003)(6512007)(6666004)(6916009)(66946007)(66476007)(26005)(16526019)(86362001)(52116002)(1076003)(8676002)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: pMGffQ179wwaIlk37K9OrR6RipaP9wI9XtHRhs6oVHm4yWbi6W5j3oROZ+g5MSUxsE2vrUzpf+y90aadVYJ+RbzHBx7U001Bthb4EJedEGolE2/BHSTSA0oalNDMi+lZyzaNikEqDZbnG5KylUxT+2pF9q8BDCrJOi4XfiV9F9lStt6yUQAbY+CfJus5g1N/uykMwWZLYz1vMjEEabvsMsWtfptPdEFbWuC1ykpDBq94s0ugF8CF5dxBqeK/HhKL/KoRt8N12MLyBDKtnzLIWIJFl1RYOwgQss5JYAhn19MkQ1g7OoFSB0ELDn7UAbUnEaCoS1qd64RqnDohAaeUHIqKak9jGUAIrdeQ17awXVW3K97U/nAVBq9QlEYupRMYoHjDe5R8WOX1HOAgt36g+K/y+GeznTKylPHE0CWulSJYefrTA7xhAkTzY1zVYJrrZBE0zzwu4Fzz0MaHB1g0fp5kHNnaNHU9l0elXKvBW+x+P/FJrcAxAP1s27Ccw4R1/rn6kRGaxCysHVJDjzfLrlcJgKwSiI3+fai032fbKmzNqLgOP+D9h0nlpAxxZmN64ydsVSSYQaeGRhk+hvQBqJ12vwfAjebWT/+GrxUMHL2s8KbI8iIkxriiHc3R8lni+oV9FTw42Ylz+BaM7Ipb7CoVzHIk7cfTA/HCBtFDDcz3blARqD+S+gCc2pApJWzUh8Omxb07na2RlisYOLkzov5eYCUgmpXvTO1plMYd98I0X3BJx+T6TuBu9IgHzm7V0QbwXTPrLs4COE+X/xjKO7Oy4nDdVBZTK94jo5rf2NN0GSKLiGZwDW/5Oe8U5HjF2wLGnUu4bcuiy2tGyjDiTq2tHDvCXX+RXL1Qz5xhN2YB0WOQWxyeGyhW8UEGPYkIn94ylF0CEmLevSVlbaMqta2pdixKGBpU2sXouRb5kDkcw6MpYCBghtCHIHbz5wtdoOGJmk4CduA4TTf/aWfiTlYf1AN6dX06gPAbKGi+OL+I382LHqHGUy+BT4Ym95o0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 61705ad2-381c-4f00-257d-08d89b71f7d7 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5696.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2020 12:08:26.6935 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: XwTr3qfFcbSbi/2G69Bg+18wRDmsqwgxZI2T/uLRrkHE3E1BMbYWO3sEwWCUz31qCBQ4Sgoioz4mekbUJXJPOQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5693 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Since switchdev/DSA exposes network interfaces that fulfill many of the same user space expectations that dedicated NICs do, it makes sense to not deny bonding interfaces with a bonding policy that we cannot offload, but instead allow the bonding driver to select the egress interface in software. Signed-off-by: Vladimir Oltean Reviewed-by: Alexandre Belloni --- drivers/net/ethernet/mscc/ocelot_net.c | 38 ++++++++++---------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot_net.c b/drivers/net/ethernet/mscc/ocelot_net.c index 47b620967156..77957328722a 100644 --- a/drivers/net/ethernet/mscc/ocelot_net.c +++ b/drivers/net/ethernet/mscc/ocelot_net.c @@ -1022,6 +1022,15 @@ static int ocelot_netdevice_changeupper(struct net_device *dev, } } if (netif_is_lag_master(info->upper_dev)) { + struct netdev_lag_upper_info *lag_upper_info; + + lag_upper_info = info->upper_info; + + /* Only offload what we can */ + if (lag_upper_info && + lag_upper_info->tx_type != NETDEV_LAG_TX_TYPE_HASH) + return NOTIFY_DONE; + if (info->linking) err = ocelot_port_lag_join(ocelot, port, info->upper_dev); @@ -1037,10 +1046,16 @@ static int ocelot_netdevice_lag_changeupper(struct net_device *dev, struct netdev_notifier_changeupper_info *info) { + struct netdev_lag_upper_info *lag_upper_info = info->upper_info; struct net_device *lower; struct list_head *iter; int err = NOTIFY_DONE; + /* Can't offload LAG => also do bridging in software */ + if (lag_upper_info && + lag_upper_info->tx_type != NETDEV_LAG_TX_TYPE_HASH) + return NOTIFY_DONE; + netdev_for_each_lower_dev(dev, lower, iter) { err = ocelot_netdevice_changeupper(lower, info); if (err) @@ -1056,29 +1071,6 @@ static int ocelot_netdevice_event(struct notifier_block *unused, struct net_device *dev = netdev_notifier_info_to_dev(ptr); switch (event) { - case NETDEV_PRECHANGEUPPER: { - struct netdev_notifier_changeupper_info *info = ptr; - struct netdev_lag_upper_info *lag_upper_info; - struct netlink_ext_ack *extack; - - if (!ocelot_netdevice_dev_check(dev)) - break; - - if (!netif_is_lag_master(info->upper_dev)) - break; - - lag_upper_info = info->upper_info; - - if (lag_upper_info && - lag_upper_info->tx_type != NETDEV_LAG_TX_TYPE_HASH) { - extack = netdev_notifier_info_to_extack(&info->info); - NL_SET_ERR_MSG_MOD(extack, "LAG device using unsupported Tx type"); - - return NOTIFY_BAD; - } - - break; - } case NETDEV_CHANGEUPPER: { struct netdev_notifier_changeupper_info *info = ptr; From patchwork Tue Dec 8 12:07:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 11958285 X-Patchwork-Delegate: kuba@kernel.org 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 2A147C4167B for ; Tue, 8 Dec 2020 12:09:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DFB3423A52 for ; Tue, 8 Dec 2020 12:09:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729365AbgLHMJr (ORCPT ); Tue, 8 Dec 2020 07:09:47 -0500 Received: from mail-eopbgr80048.outbound.protection.outlook.com ([40.107.8.48]:13187 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729343AbgLHMJq (ORCPT ); Tue, 8 Dec 2020 07:09:46 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jQPN+ThoSzNP/swK+Pu2ePrIEFdjuyMaY9FoR6fJ65HQzXc8iGmDJKjVGyLDV8AjV9MKvupOVfP+znUK6x/NjnE6gnhYjkNd8vn/0v50JqMkfDmWUGaEWHY3GVdO4G4VdkWtrJK8ioUzGGoOsrCLC1qYKo2GarNIvRPGsGuk6r6BPtFzmzaDQ9L66msWMevknc8eMyWk2KVoTBsFzlfgU/4TfJWlJxBof5U+EZHHiSNiRUpbjMzrYJ0WQHlOtRHJeFXQhyDtWbA1GYR9HskSR4ZlgskLen0MMiI8Wuv4PZzvgD5G4FEAdzE4kaezwG+VbwBFe/HtyWLLidvteFTvGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=I8CzEddcZ2lTnGOUJZnBEQa60I3qWsy/+rzWEAgQLZ0=; b=CZWjhjbvR97W6NF4WMz21r8iJvHTQlryHJ6JgN7egoAEg3so4tu2GOj28755a8X6ziDczsUYcgeJfplbvB9lkjZXodyRJrUAdO4mlW6kq+ddrr0yb2vL9HArGLaVFz7J4g1v66iUrvSIRCvDhpMtHIfY7EM54mQPFqpDjqUpRBMZQev/iENYp04XEaNdil4JdfLJ9t+M4DCAInpTxBQoul0KN60MJeK9XjTCqbGvGcNMwjC2PxJbovOQMNhS9KYYegO/jO8oPPkW/TUT0uHZTvVYlcE8UuFuo9lH0kGwsZXHDoT1ovlsNjHieMEb+ZVdX60g7u7IUC9zfTg2GckZAQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=I8CzEddcZ2lTnGOUJZnBEQa60I3qWsy/+rzWEAgQLZ0=; b=EMTn0HkNTDyRJqOQMEf6KR7tOxhwbv0B9KgBLQQTZSs7+RPvRGZTjUU2fooJtr4SnQI8ju0npXeu+462psEulIlKGMpymoWdV17md8sDeF2EdrauROOsBBKR89iMs0hHaOTtsL91V5qJNucQ9dYkQuXeiarmAaFkUKYpCJ1YQ0I= Authentication-Results: waldekranz.com; dkim=none (message not signed) header.d=none;waldekranz.com; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) by VI1PR04MB5693.eurprd04.prod.outlook.com (2603:10a6:803:e2::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21; Tue, 8 Dec 2020 12:08:28 +0000 Received: from VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84]) by VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84%5]) with mapi id 15.20.3632.021; Tue, 8 Dec 2020 12:08:28 +0000 From: Vladimir Oltean To: Tobias Waldekranz Cc: "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org, UNGLinuxDriver@microchip.com, Alexandre Belloni , Andrew Lunn , Florian Fainelli , Vivien Didelot , Claudiu Manoil Subject: [RFC PATCH net-next 06/16] net: mscc: ocelot: use ipv6 in the aggregation code Date: Tue, 8 Dec 2020 14:07:52 +0200 Message-Id: <20201208120802.1268708-7-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201208120802.1268708-1-vladimir.oltean@nxp.com> References: <20201208120802.1268708-1-vladimir.oltean@nxp.com> X-Originating-IP: [188.25.2.120] X-ClientProxiedBy: AM9P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::21) To VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.2.120) by AM9P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17 via Frontend Transport; Tue, 8 Dec 2020 12:08:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 0ebce3ef-686a-4ce2-d5ed-08d89b71f8a8 X-MS-TrafficTypeDiagnostic: VI1PR04MB5693: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Eo0RZKbKnmSF26VhumAIi8IEjLV/P+4O4MR43khbDMmO0FOE4FSheBGTl53+/4e5k8VycdFL5FQdDJJiNudYbxii/AoWa/EFEZX/9pfLRxjLnC/bP/mCgCCrEIFTbhbuOEh1GqfNdONZS9cetW7jQNkl4Pm28ao7OuCz+DjAmpitELZEjnIXybDr+JEqiksHUNJyjPfDRFRAWUYpDd1FR1hsjvF8agRaJiVsRVK7BWbBAvgzLegOj54AHgF7S9W8WHlQoskuOAYSIXHPIvefUthTgqFNSIybhvsxqe9czYVpahplL7OYTv90OYQbrVVj1wtoA9/PfL3rOapSQvh8MGjgegYuZQjpR/CmQaMjkq87tMLtpx6Hu1ovB3N1zHKk X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5696.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(498600001)(5660300002)(956004)(83380400001)(2616005)(69590400008)(4326008)(54906003)(6506007)(6486002)(44832011)(66556008)(2906002)(36756003)(186003)(6512007)(6666004)(6916009)(66946007)(66476007)(26005)(16526019)(86362001)(52116002)(1076003)(8676002)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: mytDkpTU2tPds6WKbJqeKJDeeBOrIaLH1nGEpjUMC6GYKO2CkHPfL88y21XZxKFlIyOtlGKHH7M80MFNhLPEotqVVT30Wkmm2S5Qmx6+jG6nzlx5yH027H5ZkRqBJ3/O6fpN2ULuQVbVmWX+gwnJbv5jX+pyQlxX1l9fnCtvjT556omkZTusoiGqEt4BMdNnGXbOXiJYjJZRGRUWmURFtFhz99p8B3gJtr+n7l8Q3GblpoiZrq5fstAK61iGCctrdHcc3in0fDsgIQzjVReaaaHOoKIPhHPnziTxFl7iVuVAZzGHRL91TaT5G44TSz7Rll5hc3VSU9Z/FqMHQdTpGHy+ajqYnKvWkIWgu3bEBHXtL35qw3j2xJnolfBM7rWJTI5uisYMTyQl2/aSVJgCUp7FL/OQlJe2sbbAraRitefmtLnhnM37qUTj461LVtMbmNUTX4Fn683SuDaps1UM6JTJdnCbRmNUxS9taWreqJflWjy/0IW2D1A1/6Itsaxge9h7lLO+6MQQxcKxjJvSmA8Caj4f3CHMx6KlHSEPq6US9Mp/ghGbctp/s9D6bmq/YhU75WGuq5gKz1cPFtYtq7EgWI5OKYQ3d3zJ8MIBR/OUe6K4wP9r5FqyATiSBFHQlo1ymidxUe4bIlA6KRMhnRCGjOr7yboeJMeBymwHCHRtCLXJ7MbgRLao+V+lxLRxCUfHbIJ0nvoorHF5mypZ5LGrr/sYF7ZtKMetCnM3o5lTVH81ut96wFhEGFvrGmSXfNac1flw7O6NV6IK4O6zMvMzdmzxZ3GEpMLCi0DfLmPNpzKm/AnR68YTXI4UCsVZYYZpCgyilOKYIb8UtC2ptG3gVQlVQec+HwkX3mhj0OtJSPbHFsE+sEXECyvi6Fw+i57c6+x3aj1rH9AwFDDIWrCFem+IzyumcO2Y0YqmNAApE/nSqg/iosXyv4jEpNIpq68cnYY5LISCYJsUsx5giOgY62zqO5z65f6Dy4zQSI1waWW9OXw8pwV921lt2bhC X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0ebce3ef-686a-4ce2-d5ed-08d89b71f8a8 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5696.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2020 12:08:28.0458 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: MaTGTZ8liwrORrqJ6Hz9vP9SjgMMIzIs0kbbUomerbz3Nwu7Md5D2vwlXIzaGnLUio2J8vIySM39k2NLpyMjng== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5693 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC IPv6 header information is not currently part of the entropy source for the 4-bit aggregation code used for LAG offload, even though it could be. The hardware reference manual says about these fields: ANA::AGGR_CFG.AC_IP6_TCPUDP_PORT_ENA Use IPv6 TCP/UDP port when calculating aggregation code. Configure identically for all ports. Recommended value is 1. ANA::AGGR_CFG.AC_IP6_FLOW_LBL_ENA Use IPv6 flow label when calculating AC. Configure identically for all ports. Recommended value is 1. Integration with the xmit_hash_policy of the bonding interface is TBD. Signed-off-by: Vladimir Oltean Reviewed-by: Alexandre Belloni --- drivers/net/ethernet/mscc/ocelot.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 7a5c534099d3..13e86dd71e5a 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -1557,7 +1557,10 @@ int ocelot_init(struct ocelot *ocelot) ocelot_write(ocelot, ANA_AGGR_CFG_AC_SMAC_ENA | ANA_AGGR_CFG_AC_DMAC_ENA | ANA_AGGR_CFG_AC_IP4_SIPDIP_ENA | - ANA_AGGR_CFG_AC_IP4_TCPUDP_ENA, ANA_AGGR_CFG); + ANA_AGGR_CFG_AC_IP4_TCPUDP_ENA | + ANA_AGGR_CFG_AC_IP6_FLOW_LBL_ENA | + ANA_AGGR_CFG_AC_IP6_TCPUDP_ENA, + ANA_AGGR_CFG); /* Set MAC age time to default value. The entry is aged after * 2*AGE_PERIOD From patchwork Tue Dec 8 12:07:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 11958291 X-Patchwork-Delegate: kuba@kernel.org 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 02A73C433FE for ; Tue, 8 Dec 2020 12:10:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A9CE9236FB for ; Tue, 8 Dec 2020 12:10:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729331AbgLHMKF (ORCPT ); Tue, 8 Dec 2020 07:10:05 -0500 Received: from mail-eopbgr80078.outbound.protection.outlook.com ([40.107.8.78]:17934 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729311AbgLHMKF (ORCPT ); Tue, 8 Dec 2020 07:10:05 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XUYuuu575Rz2P3x1czDETAIvJu8jkbu0Wg/tdbgfzq+juUzkLX6AagUrbk+VCYVvcVcGoips5DWBQaxS+KGJEyGxkoxuvM8zOOWLcC76p2Ru1BxuVEQ7utj2nFPXxkFYmBW3fBIAiFmQcALQiEFQClELp/X8GB3MY8Bg4H1XKi2RKkFua6VPqrD3q5KI/6TEPNYcvcNUmEtbZY6O/95wFLgHyJ2Tl3QYW4qETz6TKLvRHAFF8UysIBu9SXJ4hLXIwSvGs2gQK26obMrmf97CZqS/17VjRYjylBEyFfSVMclNQV0RGwfpX6TpNkJU5/i2lgn/OP5DG7q9vhWTt8vQ8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kRETVR006LNcUpsPbVaccUpm+GSdPynh4RDE95Gucqc=; b=JXgiMGWwbPlVvVBrWq19nY7X7NuZ8xZJ0LtEri4bgNwJB5uLPL9Ay5vr/t97SnIB4VyG8yYGQKcFGHBIoRRql+dSzYTNAHY9SpnHNAvwEhIGjKMKAu2RCTRing2Pwb/1kn6/X7atKcL/5koVFxXjUCwyH9luUAD4wU9VVpOH/4GiqNndAStAjAEx0Fq/qJzS3sxGT0ms4L5pmb3wIt6JLHi3JC6mM4nZGWgb7YqeM9cSKwW4KyT/T9igvFWU00xnROKfEF3gFliTDdNapHo7R7LncByc8zUucRFlXrbS8FuTzxOS17TbcPVxBMAXUog26fadkk0nXsUia0ehvpCmPg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kRETVR006LNcUpsPbVaccUpm+GSdPynh4RDE95Gucqc=; b=YguYu4F6n365gNUjX4NyIlnuiGRuuDXR66k1l0OCO8XzxuIcaMB9kh0+uvzC9OXarUosWyTdjqOBvjT+MQbGryQ5hFHiZuHU6HI3BNM5oRThzRXozfLThbWJoYNmY9gSMhXHGWt9Wjv/ExpwiFOu6Z0W71n/csN1Ewz0+J30y9Y= Authentication-Results: waldekranz.com; dkim=none (message not signed) header.d=none;waldekranz.com; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) by VI1PR04MB5693.eurprd04.prod.outlook.com (2603:10a6:803:e2::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21; Tue, 8 Dec 2020 12:08:29 +0000 Received: from VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84]) by VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84%5]) with mapi id 15.20.3632.021; Tue, 8 Dec 2020 12:08:29 +0000 From: Vladimir Oltean To: Tobias Waldekranz Cc: "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org, UNGLinuxDriver@microchip.com, Alexandre Belloni , Andrew Lunn , Florian Fainelli , Vivien Didelot , Claudiu Manoil Subject: [RFC PATCH net-next 07/16] net: mscc: ocelot: set up the bonding mask in a way that avoids a net_device Date: Tue, 8 Dec 2020 14:07:53 +0200 Message-Id: <20201208120802.1268708-8-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201208120802.1268708-1-vladimir.oltean@nxp.com> References: <20201208120802.1268708-1-vladimir.oltean@nxp.com> X-Originating-IP: [188.25.2.120] X-ClientProxiedBy: AM9P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::21) To VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.2.120) by AM9P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17 via Frontend Transport; Tue, 8 Dec 2020 12:08:28 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 4cb8ef8c-356a-4f11-d46f-08d89b71f97a X-MS-TrafficTypeDiagnostic: VI1PR04MB5693: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ITXkVngC0vikOVXfRHYqi8HtpeTsEsSSCUtIoP4kHYV1ALusz5cRTofjndrdndrH5BjG5lFe1+m+HmQdXzxjoTH5+6tZm4mXwDVtnfJUhdV7Obv5rm7nWXuOgXPDhi8fJsU6eupL/lyQdt38YWFBrAOxROFdW9V1ASv62YcIwYKIDcaBIz9j2+TDK2MqHp3J319b0aX6qLGTNYu0ESlAr+x4rkoGO/xGLj3x7qismPHIBwGYNYeGZc1YCjDKDypUgWfcmLENHc6mmj2QCc6n9J/4eZ+n+cUW0mY9qeKSKq/L0XbSv+RWo1ODKe07kTqw1Fl3q0oeoOyXan1YVLBSsdw+jsQYfjnBK6cJssltPUWYpuzFkLu37vTs72I/nuZ8 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5696.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(498600001)(5660300002)(956004)(83380400001)(2616005)(69590400008)(4326008)(54906003)(6506007)(6486002)(44832011)(66556008)(2906002)(36756003)(186003)(6512007)(6666004)(6916009)(66946007)(66476007)(26005)(16526019)(86362001)(52116002)(1076003)(8676002)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: RJnG4w86fDs/UGQqdxj+tsQyHaLoKz7uFWHYdNWq+GDXIOd3kFg4Yin76HKkx68s9FDQligoafUZKEm48Wsucx2Ls4l04RbeobzwqSjo/QetkHyrSgP4UWvw/kW0WhHf5ygVyGNXxurLIWrXm/YzZJQeaN7+8sZJcflI63QAj+HU81vL4uTO/CM75TX3vysDuWw/4m+K2YjVZtK4E+tAJK3VB8f7l1GL6+jNYIh3Acnn8Vd9PjnCypx1VZp7X2H6XdEytWDQILp5NvVUzUGlMseVS0mxRv4cXjsxEGS+iSTvERU09GJssWSQIzmCXmO9cMAfID1OJcJYnG075advvPos5vH+B1HFGWuiO0ZCVIszymzQNxcx6spuTKGcpbm5M4+VaZz27Lh8vITE94QI5XJSGRKHjIA8wFoHNTu9cfVSQk0nkmo60YthPMxaTP898ai+M5ZmSIPvJ56A68RnzAhvbLV9QoaN1ZKFkQHMlJhRpoYC5Sr/D3UDEmI7bCWPqU04Qb52/G+D5qnogOKKGQJdps3pesbRc3lfMTJyfceLjy0BPBzbroR3WNcZxZ8nj39+P6rSiNdSv+ozJEf9pI8Q3B1ZyZ55Ud159rWUTsjG3FJeDiAqJhMghM2xW4CKnotTCAjLTesDxNV/hG5cPKTWvLmk2UEm7TlrBayK2cuoNGnssKUVMeha82neIyYm1DMo2z0znASy8sXlw1K56OfFS4AoNSwVOJhqpdONpA2PP7U5jPL41Wuy2ZXlJmlpEvLOg1+8z/O3h/VuM4fUbY5PM9cKmZX/glNt49znqkZ11FQ99uA7MZ1M8pHNAf14aAVn98bVCMjYJtNvmR3UbcAE1k5+5ec3vm05hAZ/T04m2VSsUWB6Mkk87Enl8VCRJf8LXewFHPfMDm9T3ME5tPKVpzF4bB/fNLoOY6FRDeDtukcYqGVcjY5T2kpH2bCJnOVtWmYJi0i/TaBWxFOLa4ruHkx38kiVlplytGSiPd+iOWmYOtbY4VL/86pSiatE X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4cb8ef8c-356a-4f11-d46f-08d89b71f97a X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5696.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2020 12:08:29.5509 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: i7kL7jqa+0XwN0CrIRHUoYygrZEf6sFvuKiLSuu0vflA5WtkprMeU3zck/IwH9Ri7zPoCrhYFdP9ha60ixxE+A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5693 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Since this code should be called from pure switchdev as well as from DSA, we must find a way to determine the bonding mask not by looking directly at the net_device lowers of the bonding interface, since those could have different private structures. We keep a pointer to the bonding upper interface, if present, in struct ocelot_port. Then the bonding mask becomes the bitwise OR of all ports that have the same bonding upper interface. This adds a duplication of functionality with the current "lags" array, but the duplication will be short-lived, since further patches will remove the latter completely. Signed-off-by: Vladimir Oltean Reviewed-by: Alexandre Belloni --- drivers/net/ethernet/mscc/ocelot.c | 29 ++++++++++++++++++++++------- include/soc/mscc/ocelot.h | 2 ++ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 13e86dd71e5a..30dee1f957d1 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -881,6 +881,24 @@ int ocelot_get_ts_info(struct ocelot *ocelot, int port, } EXPORT_SYMBOL(ocelot_get_ts_info); +static u32 ocelot_get_bond_mask(struct ocelot *ocelot, struct net_device *bond) +{ + u32 bond_mask = 0; + int port; + + for (port = 0; port < ocelot->num_phys_ports; port++) { + struct ocelot_port *ocelot_port = ocelot->ports[port]; + + if (!ocelot_port) + continue; + + if (ocelot_port->bond == bond) + bond_mask |= BIT(port); + } + + return bond_mask; +} + void ocelot_bridge_stp_state_set(struct ocelot *ocelot, int port, u8 state) { struct ocelot_port *ocelot_port = ocelot->ports[port]; @@ -1272,17 +1290,12 @@ static void ocelot_setup_lag(struct ocelot *ocelot, int lag) int ocelot_port_lag_join(struct ocelot *ocelot, int port, struct net_device *bond) { - struct net_device *ndev; u32 bond_mask = 0; int lag, lp; - rcu_read_lock(); - for_each_netdev_in_bond_rcu(bond, ndev) { - struct ocelot_port_private *priv = netdev_priv(ndev); + ocelot->ports[port]->bond = bond; - bond_mask |= BIT(priv->chip_port); - } - rcu_read_unlock(); + bond_mask = ocelot_get_bond_mask(ocelot, bond); lp = __ffs(bond_mask); @@ -1315,6 +1328,8 @@ void ocelot_port_lag_leave(struct ocelot *ocelot, int port, u32 port_cfg; int i; + ocelot->ports[port]->bond = NULL; + /* Remove port from any lag */ for (i = 0; i < ocelot->num_phys_ports; i++) ocelot->lags[i] &= ~BIT(port); diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index 50514c087231..b812bdff1da1 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -597,6 +597,8 @@ struct ocelot_port { phy_interface_t phy_mode; u8 *xmit_template; + + struct net_device *bond; }; struct ocelot { From patchwork Tue Dec 8 12:07:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 11958293 X-Patchwork-Delegate: kuba@kernel.org 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 547DCC4361B for ; Tue, 8 Dec 2020 12:10:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0AB52236FB for ; Tue, 8 Dec 2020 12:10:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729337AbgLHMKK (ORCPT ); Tue, 8 Dec 2020 07:10:10 -0500 Received: from mail-eopbgr80048.outbound.protection.outlook.com ([40.107.8.48]:13187 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729311AbgLHMKJ (ORCPT ); Tue, 8 Dec 2020 07:10:09 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NWk9OhexDFmfEvyqSv+u3UVpmTrn2/DYbMHP06HABH1VLun5lURRSX5jWJVE1iAppA4pPUWr0FDxTlgvJFlofOEpj3gX1lrnPFIjPD8bG7gnZVSeoTwMZ0nZKAXJ9Nn5OM4iN+C41lLigYfoej7nSUvPP74Nkk1cwiGQpLWTSnY45wKVd6iB0IaoP5U0ZKbePMCQUstFv08LALnF/Hn4Fm8ciNpBULMNbAZAx5Jl6qyS6+RV/TgycxSubEk14QEF/j9wgIpL3XhqYph5AjfQdyEXQwJuCHML30GsNMW0Y3vVev77z0jzn5sGEBSuN9DFLa6gGB0wqLOki3b/6qd76w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NxmwXWoBeVfTqsM3ZgGd7KJtBAO/Ap/XYUeGxFFQwD8=; b=MZ1m7Wz8LHzOE9w9ljWOVfcAVjFetpABJfBdNqMEVTi+ERSRmLZ4bhTcB7nw91UIX+yzctB79druTzIdXryu8ihz62fSFzSKxWaN+7h6gyBKkw5+ujCOYyIWtdS9wfrWSTckau8A1hkmXJkkEohp0bVW06cahmojj6yxGp/fZ7PK4wVhlGo5hppEmCa3mcLYEXr0F83XujmD4qepFpz+OOM1Wsu6bbL9VuQsn4dZnRz5yE7bmHQ6RpStziGT0B4tfFSkTxuUXMezfYKLggDtvpKHBsJc3LjpZntK1z3afpaaAe/5O5vK2mYN5akm90i2i/GHt10JIYD1r9jom/w90w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NxmwXWoBeVfTqsM3ZgGd7KJtBAO/Ap/XYUeGxFFQwD8=; b=tEWRGa8F/HpXlL3lTDxLfVpTlrhr9oaLgpUG+kHO+tUL5/EDJuz9qAcPHTX6SLIeBWi1FIzvwFzQ14csSQ12jMfyyuhntcT0SutDH26cIdm7mQG5OuqizA9BDzyD25aJGfw1m1y0paxDMVdqqpM4+iGOC+viVP6YApeSpRN0CtI= Authentication-Results: waldekranz.com; dkim=none (message not signed) header.d=none;waldekranz.com; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) by VI1PR04MB5693.eurprd04.prod.outlook.com (2603:10a6:803:e2::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21; Tue, 8 Dec 2020 12:08:31 +0000 Received: from VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84]) by VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84%5]) with mapi id 15.20.3632.021; Tue, 8 Dec 2020 12:08:31 +0000 From: Vladimir Oltean To: Tobias Waldekranz Cc: "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org, UNGLinuxDriver@microchip.com, Alexandre Belloni , Andrew Lunn , Florian Fainelli , Vivien Didelot , Claudiu Manoil Subject: [RFC PATCH net-next 08/16] net: mscc: ocelot: avoid unneeded "lp" variable in LAG join Date: Tue, 8 Dec 2020 14:07:54 +0200 Message-Id: <20201208120802.1268708-9-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201208120802.1268708-1-vladimir.oltean@nxp.com> References: <20201208120802.1268708-1-vladimir.oltean@nxp.com> X-Originating-IP: [188.25.2.120] X-ClientProxiedBy: AM9P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::21) To VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.2.120) by AM9P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17 via Frontend Transport; Tue, 8 Dec 2020 12:08:29 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 52e4c759-9ddf-4f1e-da06-08d89b71fa63 X-MS-TrafficTypeDiagnostic: VI1PR04MB5693: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rAAq5SgVzwz3QQCHpDPTfdk2px7QhwAnMD607t3oDP41zXovwC1VgDM2AqN6pwncW/jgcYglbzha4QONuRFMjshmNzpdc3uwC8LUa7vEqwHIk4JdCfcL4mmrdnTDpwow8yrOvbQ1z6AVGNoh2o4tcUiHjpwQPXEwc5Na9p9gSiIw8kxjbgr5F4ZQo0lKx0ktSi2ij6ZLDhn8oDM6rsIEglkLkFCqqEXHkHH04zhTczNlXdttKx9B6U/pd9flD0qSk//XaFjtImXJdqkFVJk9/Arms2rh4sCyJjjDlsN4u0SE839JOs0RXoKfzr5ws8uWai8kFMDnSW4QECGKPhvGQmQVN7MoM7T8K3eL1Vy0nGIq9iCh2PMPUje8liIFY855 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5696.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(498600001)(5660300002)(956004)(83380400001)(2616005)(69590400008)(4326008)(54906003)(6506007)(6486002)(44832011)(66556008)(2906002)(36756003)(186003)(6512007)(6666004)(6916009)(66946007)(66476007)(26005)(16526019)(86362001)(52116002)(1076003)(8676002)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: /HDHCCm1nfUewc7lpjujhmxFsn/IDOar3xkU14VqGdhcEwXlNmy67RJcodJGWq+5Tiy3zRvwPaM4EoSfNh8mR/YtsroYO762zRzWvxVg5sdMTMPwuTDe8scvyg3mNMNvnPHDD4pBCxrYVSHkvzhDHcfIsv64A/bPHj+1RLy6Vwa8SuG4uovNGwb3yKe1msqEWCpZ7qULCAFiWFzn/6jVlJjxSXGE4kOydyD+7WQFMCnRYANPEWfnS9VKHYZ9uTO1m4W7vXZCVXbton5nxjNG6kKe2LGCbyIEqkddQPwrjv38q5kjoSDZthyJwOGp7Pz01kXDziHA9XXyZ5a/nJ3FU7MgTFV4drsk/MDBftcZwHaHb05VSQtdC/wNzogm4pbOlUTy5iYxj3dIuXJcaj5l48Zz26NwBOly34Ka+DcZlsHiW9v7LdHyOE05LB1jFBE2I1rrz1smFbguNGBhh6xkb5EofxbCNqmkreK4iE4hGGl+xJBsjgOdNeKetqVCnc/hg82eDXkiUvy1WRwIdEUv94PZWnEasdyYw6xpeGvD5BsxxTaIWjKiPRW+Q1uSnnVBULHrneCcQJq7ZBOUS1zP8JKZhAxP7h+RLazxmd4PQWpMDSxiFYfkec+jmStFQrIB+USRcW6PWZZuLtSHXnIHM3MPtdjJk++ODyIKeCO5IyvUixqtNZGn50m04CBAL/SfOZbTl7yStMIGYxm6sHSct/W8RSI/0+XVYtKCrWkmTzcq2Plp4rSK9dInfznhEAcmnakl0s+hk/+jSloRBi/O8Q9b6sBOKfKenRZkGXdZo/n1EzGj7sWAq2As6FR7/E0zJwxW27k/5Sp1xkQ9q8gGcROVYrF2Xv8RC9ojwRmpdT6amdO2ePJ2YgCcMu3R0GSJxa0HY9XgtCEAVKROnYWQ+r9vV7oa2KbqAIG4Kb9cqbzkfYXhBelQov1sXnQqsqND6DWXbs1IVuQcQaeKulHIfpgjqIZSTaalvZAzIDCrME7IVA+j7nyTxHos6qaSIC6e X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 52e4c759-9ddf-4f1e-da06-08d89b71fa63 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5696.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2020 12:08:31.0331 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: sAGZ/doje1oBzu/FU/TuuUSsScdkSfP06gVl5uVfbqmaFJ7S59EoHgnMkfccpyeVp1Xap7caCf3Znc2+5jl8pQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5693 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC The index of the LAG is equal to the logical port ID that all the physical port members have, which is further equal to the index of the first physical port that is a member of the LAG. The code gets a bit carried away with logic like this: if (a == b) c = a; else c = b; which can be simplified, of course, into: c = b; (with a being port, b being lp, c being lag) This further makes the "lp" variable redundant, since we can use "lag" everywhere where "lp" (logical port) was used. So instead of a "c = b" assignment, we can do a complete deletion of b. Only one comment here: if (bond_mask) { lp = __ffs(bond_mask); ocelot->lags[lp] = 0; } lp was clobbered before, because it was used as a temporary variable to hold the new smallest port ID from the bond. Now that we don't have "lp" any longer, we'll just avoid the temporary variable and zeroize the bonding mask directly. Signed-off-by: Vladimir Oltean Reviewed-by: Alexandre Belloni --- drivers/net/ethernet/mscc/ocelot.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 30dee1f957d1..080fd4ce37ea 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -1291,28 +1291,24 @@ int ocelot_port_lag_join(struct ocelot *ocelot, int port, struct net_device *bond) { u32 bond_mask = 0; - int lag, lp; + int lag; ocelot->ports[port]->bond = bond; bond_mask = ocelot_get_bond_mask(ocelot, bond); - lp = __ffs(bond_mask); + lag = __ffs(bond_mask); /* If the new port is the lowest one, use it as the logical port from * now on */ - if (port == lp) { - lag = port; + if (port == lag) { ocelot->lags[port] = bond_mask; bond_mask &= ~BIT(port); - if (bond_mask) { - lp = __ffs(bond_mask); - ocelot->lags[lp] = 0; - } + if (bond_mask) + ocelot->lags[__ffs(bond_mask)] = 0; } else { - lag = lp; - ocelot->lags[lp] |= BIT(port); + ocelot->lags[lag] |= BIT(port); } ocelot_setup_lag(ocelot, lag); From patchwork Tue Dec 8 12:07:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 11958297 X-Patchwork-Delegate: kuba@kernel.org 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 82F85C433FE for ; Tue, 8 Dec 2020 12:10:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3964C236FB for ; Tue, 8 Dec 2020 12:10:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729370AbgLHMKW (ORCPT ); Tue, 8 Dec 2020 07:10:22 -0500 Received: from mail-eopbgr80053.outbound.protection.outlook.com ([40.107.8.53]:11267 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728225AbgLHMKW (ORCPT ); Tue, 8 Dec 2020 07:10:22 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dPhhKf3SHEAbH6Lh81eSNcHidEJJoJRCF0b2r1K7wMrXBUpxiZ8k/Ygr/0Q4HGKB6uMukPd/VsKN/P1wBYi0hxlj9W82gZh0WHGhMETiCYPl/xBJ20MUqWslkqcfOYdX8F06tWzD+mrofYQRoaibwSk2GVFtGhBy4pqXk4I0aoSJH142PTwfk+PkAfJpYIOg6yncst/YuEF+N0ZFoMoWDCMaWOZKMGHUNO1yi4Dze7TZSOmU3jOk1eHWT5oQGipeQhOlIL+16U+bLFjr4Dwyoowl/0G41jAfZ5FWZjQg76qxTWNszwcgenb3O2gikqghnTAt1DxgptlShjFeKm+3Vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NQ+yDshFxLrHsMJoy1p5icoXZrMB4r2eRlp5oabdWNo=; b=Qmz7RwV6Rg39rzplHhH4ozmtjMeF0UgJ8R2AFtAvMl3gcZIuTbN4x0LdrBlBZR/Qso3oEjWKQnWtjI9dAF6FrYyGvtqOoPfb75vX+IZWANRg2/dxfnrFTQbT/KOK5TI2PQGkikCvO/RdGrb+7khrKByZXkzQ5YPUkAsnJ9s1ztjREjjMALtRr9B3K8a3N2tfNj5NOSLSIJsmgRWaNdL51OcrKO2de8WUnnlK3/0XdRZs08wiAsBB6ei2xkizzk2beTAt2dMCqe5VM+RYz6MTBoql9dKcAboGrvd5enTNC8bTx30kwpzG9RaFsXG8pG8Y3wPMlZGRoDo4QYaDmw/j0w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NQ+yDshFxLrHsMJoy1p5icoXZrMB4r2eRlp5oabdWNo=; b=TOoRLqSshAa5wST1Q4CEV3DCGrUGsSZ/REF6cxZbx0BUK0nNc6Tr1W9K8cwlxAflk4OZz+UFWraHyjHCyEcfkdH9Oy0nlbioR5HRPj4pVqrodLkoCu0RVp1ukLMZOu4/eR55ANmGWC5jX36su08FbxMwYg6RqGjsRnVFukqLtPA= Authentication-Results: waldekranz.com; dkim=none (message not signed) header.d=none;waldekranz.com; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) by VI1PR04MB5693.eurprd04.prod.outlook.com (2603:10a6:803:e2::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21; Tue, 8 Dec 2020 12:08:32 +0000 Received: from VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84]) by VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84%5]) with mapi id 15.20.3632.021; Tue, 8 Dec 2020 12:08:32 +0000 From: Vladimir Oltean To: Tobias Waldekranz Cc: "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org, UNGLinuxDriver@microchip.com, Alexandre Belloni , Andrew Lunn , Florian Fainelli , Vivien Didelot , Claudiu Manoil Subject: [RFC PATCH net-next 09/16] net: mscc: ocelot: use "lag" variable name in ocelot_bridge_stp_state_set Date: Tue, 8 Dec 2020 14:07:55 +0200 Message-Id: <20201208120802.1268708-10-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201208120802.1268708-1-vladimir.oltean@nxp.com> References: <20201208120802.1268708-1-vladimir.oltean@nxp.com> X-Originating-IP: [188.25.2.120] X-ClientProxiedBy: AM9P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::21) To VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.2.120) by AM9P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17 via Frontend Transport; Tue, 8 Dec 2020 12:08:31 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 1c7cc400-7e1c-4272-6b27-08d89b71fb43 X-MS-TrafficTypeDiagnostic: VI1PR04MB5693: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kKgqkXYG3lYtHv3ZW5z4l7/9xwyFT1SawQ9n1WxINwP8/0Iw7A+lgrZGj8b/g2biJDUXLiWnn97B6r83j1oDEtqDzIhRv8W8jnIFEq/zog+e1S39w3iYB1zlyxnMsVdnvKllbaCImekraHEn2aF4Ebe82g+LpyAn+b1dOS7Gr49vLO8hhah3LMTeUPMCSLqCiIRu9IvNWRJR5X/Ry11jRVWSCRjOkfQ0KjabThdJFFykbNptjBtJ4ebkHH0j492vAa8wEnW0SlzBUMGsgppQdReBXY3HckSgh16WgHwK3FJuN2zr4A/32TSSwINVmcgCUK3oiv97PHmdxe8uwZG7RG34Yq41dbvKBy3q8LdoZuIEq/T8euBE0SOruU6WmMWp X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5696.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(498600001)(5660300002)(956004)(83380400001)(2616005)(69590400008)(4326008)(54906003)(6506007)(6486002)(44832011)(66556008)(2906002)(36756003)(186003)(6512007)(6666004)(6916009)(66946007)(66476007)(26005)(16526019)(86362001)(52116002)(1076003)(8676002)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: WzepqqrznlE/WIeLL6wnmdKAZ0kl379ZbN+ozvlQ2L3hxyVa+9mLLurTNyrM59Z6XaPkujcAYbypVF9hXD/Ro46vMBApr3Vy5r2rotkBGx0x6I46oilci+uE1/L9JRy/AY3e8W3a2M1AjimhqMgSYUwr9SWrV1sMyF5oPomnY4luRC8GL076mO//OiWqSGAqReelosLRtnKFYbsNql09FotPRpR34EU1S0SZIt9vrI7QQKfTGtqxiAUSuJdsLmtXTE07oiCxKyygDj3EgqLAWvfgzH3nWG4cAQkBP0Vxp86fgtl81YvhB/GxApFPRv7YibL23+4u8YetorgDnkFBN6hbWphtnQdypJ5SsoSOTLx3ozy+OdjeHTkBJFVyvUX5tSkZfPXqsc7QFPNxS67yXxqhcs+2ieb/q/l3ia4XI+1xbyn5yga238GYNy0FxK8C0vyqX4/Xx3qS8mQm8/spM/s87tQQXaO7hT/KTj/VD87z27b+RIlWiz3gp8ex4kQMGqayIwmvZ7FEdEAwJGnFX85ILGkL5nOeUBEtyeocZvZi27N8qpeIdax0+LvKso+df0BYYJKFI2tsQPIcCGeBKaSomfrgxqmhPYvG7VHozBUQ8ChUpjyAocFTG3hRysAi3ROsQoVSzwlvO5Ig4t2uHk/km76y3Bo8auaH3jsGF34vKL1LMrAQOkHeIoctUfTKCgEcLX2enaoLUR69qFcsqYL7h0T6qXalgykOaf3cxzRxZENpBonHYGTWd+PgvqpxWL2RX5Y61PN2MZnyKVCw1R7mg82pWe88B4eBeMs3g+iHrF+J7e3++G4mYgum70I3o6dkQ2IgLRIfvr5hxVBYnCtIe7r8n3+NYkZEojEsXb6chszaddlbe/zld27XsAu9yr5djTq6nu7ZiGjaximc+6pZ+DK3cDiTczYX3vQOnxIYenTXpOhdnNoEcAYdnKbZ06tcDz7fLeTQ1H1rPdOa/CNyQlwLyT1HySmYShVJ0cogR2OfAPs/7E1h8/VtmBA2 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1c7cc400-7e1c-4272-6b27-08d89b71fb43 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5696.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2020 12:08:32.5032 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 7d4g/alotSbBV3uz+WHSehPe9IgrCIamRfH2utseZ1pBBzSOOXy6+bCSxJ70u95CuvYTWejeirvnbb6m1NRusQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5693 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC In anticipation of further simplification, make it more clear what we're iterating over. Signed-off-by: Vladimir Oltean Reviewed-by: Alexandre Belloni --- drivers/net/ethernet/mscc/ocelot.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 080fd4ce37ea..c3c6682e6e79 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -903,7 +903,7 @@ void ocelot_bridge_stp_state_set(struct ocelot *ocelot, int port, u8 state) { struct ocelot_port *ocelot_port = ocelot->ports[port]; u32 port_cfg; - int p, i; + int p; if (!(BIT(port) & ocelot->bridge_mask)) return; @@ -928,14 +928,17 @@ void ocelot_bridge_stp_state_set(struct ocelot *ocelot, int port, u8 state) ocelot_write_gix(ocelot, port_cfg, ANA_PORT_PORT_CFG, port); /* Apply FWD mask. The loop is needed to add/remove the current port as - * a source for the other ports. + * a source for the other ports. If the source port is in a bond, then + * all the other ports from that bond need to be removed from this + * source port's forwarding mask. */ for (p = 0; p < ocelot->num_phys_ports; p++) { if (ocelot->bridge_fwd_mask & BIT(p)) { unsigned long mask = ocelot->bridge_fwd_mask & ~BIT(p); + int lag; - for (i = 0; i < ocelot->num_phys_ports; i++) { - unsigned long bond_mask = ocelot->lags[i]; + for (lag = 0; lag < ocelot->num_phys_ports; lag++) { + unsigned long bond_mask = ocelot->lags[lag]; if (!bond_mask) continue; From patchwork Tue Dec 8 12:07:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 11958303 X-Patchwork-Delegate: kuba@kernel.org 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 41274C433FE for ; Tue, 8 Dec 2020 12:11:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DFAF023406 for ; Tue, 8 Dec 2020 12:11:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729376AbgLHMK2 (ORCPT ); Tue, 8 Dec 2020 07:10:28 -0500 Received: from mail-eopbgr80078.outbound.protection.outlook.com ([40.107.8.78]:17934 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728225AbgLHMK2 (ORCPT ); Tue, 8 Dec 2020 07:10:28 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QU36r5h4q1buqJUYpAud492qtFDvH1Pi1FAjbg4EwQXTClbpMbXf0XiOWFVhJpGfWhC2ILeEYBirsP0QJxnuC6qx7HBI0xiV2BimPDANju1te2fpeK6ctUPTYcPlUaCQgNYTMQYK0YL0e6rbGbqIKdFA/uZzwIwpXaxdLkzx2PGPBphPIb5vtFo2LbFoRWd6OP25eCVPKu3kUtjYoPC4H7Rcr2hOBYl3cccWZP948dwVGLTFXn6OErM5vR7oA5VxNQr3Fybo2zwgbJlC1idrRIiOJ/JRCcJ8CMH4wEfZN6ZoSj4pBsyiGILdSoN4FZHP8a/KCSInqlZRsNCPduvbOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Qux83wrs16eIBVb2JDmK4eQdIy7C7nQOfT88As8AhAQ=; b=XUOpcXxRyVevudE7IzSC/BcAy6+RObvsP2jXWrWw3ZY2pCnMhrtJxA+j8PgvK1XTrEjR9FWniCwVSnRMqOG25K1ryF3cj3KyxsskEXbr2b4u0ZBlDPmtsZR+Ugc9uHaKfV7hpjgcv5yyh7p74JvWVrAhmENg9tBCYrP/WYcPP2Dk0WgPPQVxFJJhxuLKQGPDQU/N/yD3AJQ/S7SvcnTQSpetQtsYRFRgAV/m9CPyFbyRzwvTOnNDUifnBHCvwFULzXjYpy9F8rs7vzgJqV8Uoc74YMsymOniiNTIdOOM7p4mZv+28+F5e8QILWQ7zUiTUlgN6NTDdfguPJM5IEh20w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Qux83wrs16eIBVb2JDmK4eQdIy7C7nQOfT88As8AhAQ=; b=Gw3R83wv7vgvN7hUNRadFZ1QjCQzynrEuXw3aSQInnFibIaYABXlE/SjLOvjzc195c5HSM5BYEhgt0G3pR0RhTer/wOCcU1mYHM+p/hDi0bwZmpE2d9yDT5ZkjZMk927wIOWdJesZweh18eoTmeQPacTQ5K96CIqs0L/9TkOh7s= Authentication-Results: waldekranz.com; dkim=none (message not signed) header.d=none;waldekranz.com; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) by VI1PR04MB5693.eurprd04.prod.outlook.com (2603:10a6:803:e2::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21; Tue, 8 Dec 2020 12:08:34 +0000 Received: from VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84]) by VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84%5]) with mapi id 15.20.3632.021; Tue, 8 Dec 2020 12:08:34 +0000 From: Vladimir Oltean To: Tobias Waldekranz Cc: "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org, UNGLinuxDriver@microchip.com, Alexandre Belloni , Andrew Lunn , Florian Fainelli , Vivien Didelot , Claudiu Manoil Subject: [RFC PATCH net-next 10/16] net: mscc: ocelot: reapply bridge forwarding mask on bonding join/leave Date: Tue, 8 Dec 2020 14:07:56 +0200 Message-Id: <20201208120802.1268708-11-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201208120802.1268708-1-vladimir.oltean@nxp.com> References: <20201208120802.1268708-1-vladimir.oltean@nxp.com> X-Originating-IP: [188.25.2.120] X-ClientProxiedBy: AM9P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::21) To VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.2.120) by AM9P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17 via Frontend Transport; Tue, 8 Dec 2020 12:08:32 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 0ce04669-3603-406c-bcf4-08d89b71fc47 X-MS-TrafficTypeDiagnostic: VI1PR04MB5693: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CLM5Y+TL50Q+pFoTAcl94wSFwiZMsVXRYrH9kTk412fkPLRjs4qALO44yhnn9FIgTxOf24zlJc6keF5rYHAHE42+sDuTO86WrxzfRWHwulHdiMakKybwZdfaYOe1nKA8VQ2DCidzBFmGRbJKm/zWk8lP/AfNcFJLcpsPRR3MRme1WjcQ9pGX5BvK/vckQcTMu1VxswEs57QDNgY4BSrzbsiBXRPu7Sk5/+RqvQb9ku8AeyASpMqDSwBkxtqHlMEdsGS5QTjTOSh4sdZT4t0/iGiCPcUE/WGRkFecoHKjNz9XRRNEyrSR94AoxelqUvF95Crkd7t7UwKGD86ZzAkXkyGZz4nj8EgXwIaYPrH5Z69rEyKS4Nm7Cip4n+Xcw9xG X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5696.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(498600001)(5660300002)(956004)(83380400001)(2616005)(69590400008)(4326008)(54906003)(6506007)(6486002)(44832011)(66556008)(2906002)(36756003)(186003)(6512007)(6666004)(6916009)(66946007)(66476007)(26005)(16526019)(86362001)(52116002)(1076003)(8676002)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: YIaWfWMAMprg6kVliT/uDUnwbYYIzdZ0gloYvkn7UZrRP9Z6Eq6Y0SO80fnvctE+17UAAP0/sKFdg77nVh7UJS+N3e1hVa6br+B6myrqgRh9LjB2RKxRsV6XiV13vUEhpQqAECXVqH1ELPAmHXrLGwONwdQw1pzko/jClLGVZQvrs3p0OsIH80f6UNmjcq5Nk9n+9XEIQTUFy5JvVu4oEBcwa+fWAB9snN7r7HmhPtsBnBch1NsdJY01VDW1HCos4dbd/RRAV9QjHfIla4HHX/IAsWKqJ5/rz9FX1Pj66heB4tI8gZuFdPFqbskabHO3obm3ryAJRo8jhGSGwSqAJGl9RPdSZrR/9/xyk2ZVGZkJVYMdd2U0gK2ObFXeP0tU+AE+fQoJkmEvjSrmxMxsg6P31RAAkd7FhRBWUGtQmlof/rGyaXxVTlDEto1DSuQmw0jTk/DmJt3S+YpONvflVttqwwpvJUUGFzf0ercBPJBiXitkC/o3RyVIfH+YBbs2Vp3oSOB8z+dkcAUvAFnRXxaiCPmNlSegjy7hs3aceEj89CHywh+/v+dnp700Q1Ktn3ad9giwf6C0m4BgqUZGR1wVTxpgebRNzaAvN0JpzFcSw6pgvCQBCntuCL33YSb29hKl4JdCss5PiuxRVUa4q2lSSB+CZo3hcMCuyZT3E2l3nPl5DK5fUlIFubbRBpUlIZ5fDJ8e63/h+xRK1X2FXhNeTF2xRAUSR9IEMzs6i9DGwcLx4/S0HFznYjPttP9yYya61KjFuImk3PzIgtOOHl5NUhg1YGQ2uxxseOrlTVlaD6isdyrOj63tbwLOV2sDlSGGQS1d5o4m5f9AaPMEpNJGFKfD2IfvL9uVLYeLAcIPaMmBtk6iDI8IjNbrznPXWcY+UcJKQCQhjmk/zIygH7RYqRlVT9Wu9allDFIZR9O7G5R/S84L9qBNyhiteXcfyDfYlhpPQXe0a1rH2H1nSTgMaQaJNlPQFIofOYRml9nkm7Hgft41kNg+npDhEXVM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0ce04669-3603-406c-bcf4-08d89b71fc47 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5696.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2020 12:08:34.1063 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: tEKjC/Hm7HKR53j1O+Lj7Yd9x66RyeNkyS9ejsgCDrY7y+7EgQH0LwPdTsWeafcTuriIvSZ3lgH7aCYs0p/+Bw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5693 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Applying the bridge forwarding mask currently is done only on the STP state changes for any port. But it depends on both STP state changes, and bonding interface state changes. Export the bit that recalculates the forwarding mask so that it could be reused, and call it when a port starts and stops offloading a bonding interface. Signed-off-by: Vladimir Oltean Reviewed-by: Alexandre Belloni --- drivers/net/ethernet/mscc/ocelot.c | 68 +++++++++++++++++------------- 1 file changed, 38 insertions(+), 30 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index c3c6682e6e79..ee0fcee8e09a 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -899,11 +899,45 @@ static u32 ocelot_get_bond_mask(struct ocelot *ocelot, struct net_device *bond) return bond_mask; } +static void ocelot_apply_bridge_fwd_mask(struct ocelot *ocelot) +{ + int port; + + /* Apply FWD mask. The loop is needed to add/remove the current port as + * a source for the other ports. If the source port is in a bond, then + * all the other ports from that bond need to be removed from this + * source port's forwarding mask. + */ + for (port = 0; port < ocelot->num_phys_ports; port++) { + if (ocelot->bridge_fwd_mask & BIT(port)) { + unsigned long mask = ocelot->bridge_fwd_mask & ~BIT(port); + int lag; + + for (lag = 0; lag < ocelot->num_phys_ports; lag++) { + unsigned long bond_mask = ocelot->lags[lag]; + + if (!bond_mask) + continue; + + if (bond_mask & BIT(port)) { + mask &= ~bond_mask; + break; + } + } + + ocelot_write_rix(ocelot, mask, + ANA_PGID_PGID, PGID_SRC + port); + } else { + ocelot_write_rix(ocelot, 0, + ANA_PGID_PGID, PGID_SRC + port); + } + } +} + void ocelot_bridge_stp_state_set(struct ocelot *ocelot, int port, u8 state) { struct ocelot_port *ocelot_port = ocelot->ports[port]; u32 port_cfg; - int p; if (!(BIT(port) & ocelot->bridge_mask)) return; @@ -927,35 +961,7 @@ void ocelot_bridge_stp_state_set(struct ocelot *ocelot, int port, u8 state) ocelot_write_gix(ocelot, port_cfg, ANA_PORT_PORT_CFG, port); - /* Apply FWD mask. The loop is needed to add/remove the current port as - * a source for the other ports. If the source port is in a bond, then - * all the other ports from that bond need to be removed from this - * source port's forwarding mask. - */ - for (p = 0; p < ocelot->num_phys_ports; p++) { - if (ocelot->bridge_fwd_mask & BIT(p)) { - unsigned long mask = ocelot->bridge_fwd_mask & ~BIT(p); - int lag; - - for (lag = 0; lag < ocelot->num_phys_ports; lag++) { - unsigned long bond_mask = ocelot->lags[lag]; - - if (!bond_mask) - continue; - - if (bond_mask & BIT(p)) { - mask &= ~bond_mask; - break; - } - } - - ocelot_write_rix(ocelot, mask, - ANA_PGID_PGID, PGID_SRC + p); - } else { - ocelot_write_rix(ocelot, 0, - ANA_PGID_PGID, PGID_SRC + p); - } - } + ocelot_apply_bridge_fwd_mask(ocelot); } EXPORT_SYMBOL(ocelot_bridge_stp_state_set); @@ -1315,6 +1321,7 @@ int ocelot_port_lag_join(struct ocelot *ocelot, int port, } ocelot_setup_lag(ocelot, lag); + ocelot_apply_bridge_fwd_mask(ocelot); ocelot_set_aggr_pgids(ocelot); return 0; @@ -1350,6 +1357,7 @@ void ocelot_port_lag_leave(struct ocelot *ocelot, int port, ocelot_write_gix(ocelot, port_cfg | ANA_PORT_PORT_CFG_PORTID_VAL(port), ANA_PORT_PORT_CFG, port); + ocelot_apply_bridge_fwd_mask(ocelot); ocelot_set_aggr_pgids(ocelot); } EXPORT_SYMBOL(ocelot_port_lag_leave); From patchwork Tue Dec 8 12:07:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 11958301 X-Patchwork-Delegate: kuba@kernel.org 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 60D2EC4361B for ; Tue, 8 Dec 2020 12:11:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1C8D3236FB for ; Tue, 8 Dec 2020 12:11:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729382AbgLHMKd (ORCPT ); Tue, 8 Dec 2020 07:10:33 -0500 Received: from mail-eopbgr80048.outbound.protection.outlook.com ([40.107.8.48]:13187 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728225AbgLHMKd (ORCPT ); Tue, 8 Dec 2020 07:10:33 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k4Q9YrPBMF+eFiId6gv2sIE1SuIEPRaWipnSCQC4MdIDvIp7uHNXIzX4GlTkIUuIFy5THyB3OCaXZR45WCcpQcMb69aAL8zG3mhlmYq6J0h/lpL6kzowG/whHNTTXjvLPH/B4cLX5s20u+Yh/txz8fXqgO/fRgLaHT3mQvzAB5OPJRAUD8D++g0HCH8kASZgqPscyJQooQoLaDRfxMojl4q+tvL9JKK80J7OOKRy96oRWnngWzlOghUkgetxPvNKiceV7uK7eUQCeqWxrSH5tNKGyCIZrVe4S/S2eSY5vV/myr0EPXYosnhiJG2OTFPH+yQYlDOCBXFHzmgUvCAXyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ntiixDI4A7drEzDtNKutSC4G83RAlXCKSEqnj4MT9AM=; b=Az6G+g1L/btOJoOplpgaKChvwshZu2h3mPyhDHOAQgNDaAWUiN5uie40+V2jEPIxtm7HFDEHPIm0S/CDTbqfFUp+LJbJMoy7kwKu41d1I+IqFWVg/oPTNtZQqWyRgyhjoDRF1lZawl2zOl3UlXyl5007MdGc7nSTFvb5dUiEKUBHoHnrvlphtKRuwBKRB4aAbFQbraY++fxvNVYlP5YJq0c53ALBAMV4MinyH+EQU4N9q8Zx0w16jX/xq24BhBGGpH4LlqSUOd6lJ2kVuJ1QUdrGsovEQHcdGrz0zyO4wDRn4xLYMXFFGPbzxq/ody5pFcI8krsFD/DqHsf1gB5sUw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ntiixDI4A7drEzDtNKutSC4G83RAlXCKSEqnj4MT9AM=; b=bq5J0jgMjGmm2xHpxnlOkdBT5+TeeLSkGTRrdM2x2Gnuu3uqNNpoSFat/FOJI+siknHORCpqB+W3BlriA1kVwMXFekW93c1gY3LZkb8rcEd/RTHtbsN8eCH/OR8IoVOwAZYsAv5gp5MzB5gG2BLY1xsjWfNb6uYrwGHmAdzPOpE= Authentication-Results: waldekranz.com; dkim=none (message not signed) header.d=none;waldekranz.com; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) by VI1PR04MB5693.eurprd04.prod.outlook.com (2603:10a6:803:e2::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21; Tue, 8 Dec 2020 12:08:35 +0000 Received: from VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84]) by VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84%5]) with mapi id 15.20.3632.021; Tue, 8 Dec 2020 12:08:35 +0000 From: Vladimir Oltean To: Tobias Waldekranz Cc: "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org, UNGLinuxDriver@microchip.com, Alexandre Belloni , Andrew Lunn , Florian Fainelli , Vivien Didelot , Claudiu Manoil Subject: [RFC PATCH net-next 11/16] net: mscc: ocelot: set up logical port IDs centrally Date: Tue, 8 Dec 2020 14:07:57 +0200 Message-Id: <20201208120802.1268708-12-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201208120802.1268708-1-vladimir.oltean@nxp.com> References: <20201208120802.1268708-1-vladimir.oltean@nxp.com> X-Originating-IP: [188.25.2.120] X-ClientProxiedBy: AM9P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::21) To VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.2.120) by AM9P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17 via Frontend Transport; Tue, 8 Dec 2020 12:08:34 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 4029e702-2e60-40b4-1282-08d89b71fd16 X-MS-TrafficTypeDiagnostic: VI1PR04MB5693: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: W8NodFvsU1h1uCUeXUYl9qIjhJ0BtsthyhQNof40S7Qdo64J5i0aL5FHq6DpVEtL4N42enrnvoJFTzmmB6o0GakRjTLu0CMc2GD19U59Es/qlJKBbCZKJvQmrMzyjY1d9dzNYfQYkjoemHTxlvLY5aUF3OwCXEnJWXHs7L8Rsllt/e/IO+tAklMgscxNsNty9OKYvnkmui1zq8NM6IdJczc33vaO1qCaeWc5p/fNjGYEtXkqVhnaUzdUpI76XSKYPwOKxLglIXeK91DADhRP8CN/tvwCYD6fpq5Ei8NH1R8JFaV5p2wodkcaNBxrLABF1olPMMgXz1GH7GcEp93KTdL3/sDGWzmsnaaOydgSHQaDIcKC/2jY8kHFF98OF41H X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5696.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(498600001)(5660300002)(956004)(83380400001)(2616005)(69590400008)(4326008)(54906003)(6506007)(6486002)(44832011)(66556008)(2906002)(36756003)(186003)(6512007)(6666004)(6916009)(66946007)(66476007)(26005)(16526019)(86362001)(52116002)(1076003)(8676002)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: +Kv0Xwkhukqgeh7HKQQgAKYQwML/6Ouy+kBxulx1neqHcFr6oxkU7ZIHY4B4oJ3t6jsb+1ifSS5abeAGo+2X01SrwZhOQDE3RChabydZNClsnPxxARC/tKhsu5Qr5UFOr/7rUJwcp+pbbDuoucXBxLwodr5bHyiD6fThR9fftyUQgusBLKjwv7ySYxPLj+wSv65ydQd9Fg6RAObLZoPbEmtLQ8v11CFfNBplfrx8DEFtAxzH63keM8Jl3LdfiFGACypW7vs4gczfOMDtsl5/LilR8bRrc3gWJjh8v2X743x0uypKJlsuv5Iwiv6cWES1Ss3ioFwep0XeQZNt9cGA98itv8MT1cttQSwr5a8F9DkAzg6d8zhcqmE7z0IDi/xqDCnq4BtxPFhRCbYudCSnuFx5yXNXDjy+UVb7VgkhsCoOkeJ565NjsypTpH1uodmbZ7WlAWtUyqHseG7nA7uv+vae+yV3anzyTjGZFOK3+tP3L6gyvMUs1NvjMMFtMAzgbpZmkoMMj9aZpyzj0ZpS3xor8MmfK3iG5lI2kVh1RlQyoQFe385DySIs97Bzt9gLqvns+5mvhqIGEGbqXamlP8yUxhQqVMCwcRDcUP5RR9Eymm0az9nI7YHuvNXHiTNLhlfekw5AdbE5u+pQ3HmWMauP5sZadspasHd8pqyAuH1pIKAD/A7WVxIoAc79YBJEprXQcCg+TxxxpNA0vMscSwx3/IYtuacmAugFE9VdTrw46BXcAAAJcQpkqV4i0TkKxSUjgixqikSoPkjB+ohaada9tAq9B6srDmpf1YY6WiCUPW5ZBpHSbrz7yWSrFGFVtbWJd9jE1d4sVmwGvLyjzEzaNz3kRkSlKEh+wvPt7JrJBAWXv3M8FOpTT76xm2dE1/1Wslrv3CfxuBb2MR6/yKGERVgl3/wWI+YRcNjp62m/n7eVluQiQMnhj3NGTzA6d0X+eHvqJnwr3BPkz+f6G1swanZuGrCqnxQHOtKIjAqQM4so+eCidcqqCTzUizL8 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4029e702-2e60-40b4-1282-08d89b71fd16 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5696.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2020 12:08:35.4605 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: QGfwmx9rRjMPAb181BXt45VqWOI1JCg7Ro+HTSBbAjg5ltzxlTyJKe58cBXSkOXd6oADHgJSUcTg8SdGd3wuJw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5693 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC The setup of logical port IDs is done in two places: from the inconclusively named ocelot_setup_lag and from ocelot_port_lag_leave, a function that also calls ocelot_setup_lag (which apparently does an incomplete setup of the LAG). To improve this situation, we can rename ocelot_setup_lag into ocelot_setup_logical_port_ids, and drop the "lag" argument. It will now set up the logical port IDs of all switch ports, which may be just slightly more inefficient but more maintainable. Signed-off-by: Vladimir Oltean Reviewed-by: Alexandre Belloni --- drivers/net/ethernet/mscc/ocelot.c | 47 ++++++++++++++++++------------ 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index ee0fcee8e09a..1a98c24af056 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -1279,20 +1279,36 @@ static void ocelot_set_aggr_pgids(struct ocelot *ocelot) } } -static void ocelot_setup_lag(struct ocelot *ocelot, int lag) +/* When offloading a bonding interface, the switch ports configured under the + * same bond must have the same logical port ID, equal to the physical port ID + * of the lowest numbered physical port in that bond. Otherwise, in standalone/ + * bridged mode, each port has a logical port ID equal to its physical port ID. + */ +static void ocelot_setup_logical_port_ids(struct ocelot *ocelot) { - unsigned long bond_mask = ocelot->lags[lag]; - unsigned int p; + int port; - for_each_set_bit(p, &bond_mask, ocelot->num_phys_ports) { - u32 port_cfg = ocelot_read_gix(ocelot, ANA_PORT_PORT_CFG, p); + for (port = 0; port < ocelot->num_phys_ports; port++) { + struct ocelot_port *ocelot_port = ocelot->ports[port]; + struct net_device *bond; + + if (!ocelot_port) + continue; - port_cfg &= ~ANA_PORT_PORT_CFG_PORTID_VAL_M; + bond = ocelot_port->bond; + if (bond) { + int lag = __ffs(ocelot_get_bond_mask(ocelot, bond)); - /* Use lag port as logical port for port i */ - ocelot_write_gix(ocelot, port_cfg | - ANA_PORT_PORT_CFG_PORTID_VAL(lag), - ANA_PORT_PORT_CFG, p); + ocelot_rmw_gix(ocelot, + ANA_PORT_PORT_CFG_PORTID_VAL(lag), + ANA_PORT_PORT_CFG_PORTID_VAL_M, + ANA_PORT_PORT_CFG, port); + } else { + ocelot_rmw_gix(ocelot, + ANA_PORT_PORT_CFG_PORTID_VAL(port), + ANA_PORT_PORT_CFG_PORTID_VAL_M, + ANA_PORT_PORT_CFG, port); + } } } @@ -1320,7 +1336,7 @@ int ocelot_port_lag_join(struct ocelot *ocelot, int port, ocelot->lags[lag] |= BIT(port); } - ocelot_setup_lag(ocelot, lag); + ocelot_setup_logical_port_ids(ocelot); ocelot_apply_bridge_fwd_mask(ocelot); ocelot_set_aggr_pgids(ocelot); @@ -1331,7 +1347,6 @@ EXPORT_SYMBOL(ocelot_port_lag_join); void ocelot_port_lag_leave(struct ocelot *ocelot, int port, struct net_device *bond) { - u32 port_cfg; int i; ocelot->ports[port]->bond = NULL; @@ -1348,15 +1363,9 @@ void ocelot_port_lag_leave(struct ocelot *ocelot, int port, ocelot->lags[n] = ocelot->lags[port]; ocelot->lags[port] = 0; - - ocelot_setup_lag(ocelot, n); } - port_cfg = ocelot_read_gix(ocelot, ANA_PORT_PORT_CFG, port); - port_cfg &= ~ANA_PORT_PORT_CFG_PORTID_VAL_M; - ocelot_write_gix(ocelot, port_cfg | ANA_PORT_PORT_CFG_PORTID_VAL(port), - ANA_PORT_PORT_CFG, port); - + ocelot_setup_logical_port_ids(ocelot); ocelot_apply_bridge_fwd_mask(ocelot); ocelot_set_aggr_pgids(ocelot); } From patchwork Tue Dec 8 12:07:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 11958307 X-Patchwork-Delegate: kuba@kernel.org 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 89F80C4167B for ; Tue, 8 Dec 2020 12:11:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 45657239D0 for ; Tue, 8 Dec 2020 12:11:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729389AbgLHMKh (ORCPT ); Tue, 8 Dec 2020 07:10:37 -0500 Received: from mail-eopbgr70082.outbound.protection.outlook.com ([40.107.7.82]:43431 "EHLO EUR04-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729377AbgLHMKg (ORCPT ); Tue, 8 Dec 2020 07:10:36 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L6xbVbWeNNLy+ExKwL1+PWxhOnI4+qySnMaLF5Y6YPJQ+vznykSvHCyb8NSpk45H+uMzrEe9S1OfkYSucQRyS9tl/6swG5QpzrqJniOHsDzY6pQSlQhfPqjc8J07lnV5AM3fq3f3Ig15bTf9DxlOx/b7DGZh3dOgLtKBv0Y5xmwBj4pE1LFxdVvPBlHsoLqNQwHSNXD5K0bdg10P7Io90b8sD2syO6RZWrBpRPtcyvBmI/QvD4V4/1js0lCyxg+uO6etUP5FErnnvzY/EALCIrTXviRSEa3US44cmxuR16aNcK703/YX6zk6ExYa4SY8TCzA8lwb6xlZlrMo3gMdtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IWdlw0+R+nYJDW62R+04Nm+7bdWnO8wFYrJXMhvlNjc=; b=FDVWdeA+GVpPs6hltkrWPJ6hYhSIlc2NERXuqpkBYOpSOG+svbon5CnJ9nn5Cb3lzaSngLycDTGWzf/i7TlQaazHbEqN2dWH3Q5vH38F2/+FiFzT9MMk8iDr+2bLH0ojrSU3b4rjkSwVqde3Q3EuHDoKT05rSWrcdMIhqphLsEN3a3kBgc5V0mVVFxpzdarolr6hfR438eHBNsHftfgz+5VY/NGVHTicb8V05PeROT94M4LXBd2zCc6lZfXFJoaSVUAErOdfJP3DM6A/ilaP0Xoo+XpA/tXLV81ktpjOOnGaKC1kIRalTbAWv8GaiagGVViU/EwOAyYKmemjRaGwvw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IWdlw0+R+nYJDW62R+04Nm+7bdWnO8wFYrJXMhvlNjc=; b=Y1md6TZFPSQoxJfXI397It2NjwUTFwEKWEJ3Q4/VIx5/OTvUPs15sQWvS8+KaUyaUC3DfY/qSHyiL7EHVmEyshw1X20O1h2plj2Pnq4TJWRwGXb9N7N/U4G07k7UeFiXLD597Tb/PRZ3e7/RVBMxAu+uY6wgMgx4vRDViIqZLBs= Authentication-Results: waldekranz.com; dkim=none (message not signed) header.d=none;waldekranz.com; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) by VI1PR04MB5693.eurprd04.prod.outlook.com (2603:10a6:803:e2::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21; Tue, 8 Dec 2020 12:08:37 +0000 Received: from VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84]) by VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84%5]) with mapi id 15.20.3632.021; Tue, 8 Dec 2020 12:08:37 +0000 From: Vladimir Oltean To: Tobias Waldekranz Cc: "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org, UNGLinuxDriver@microchip.com, Alexandre Belloni , Andrew Lunn , Florian Fainelli , Vivien Didelot , Claudiu Manoil Subject: [RFC PATCH net-next 12/16] net: mscc: ocelot: drop the use of the "lags" array Date: Tue, 8 Dec 2020 14:07:58 +0200 Message-Id: <20201208120802.1268708-13-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201208120802.1268708-1-vladimir.oltean@nxp.com> References: <20201208120802.1268708-1-vladimir.oltean@nxp.com> X-Originating-IP: [188.25.2.120] X-ClientProxiedBy: AM9P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::21) To VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.2.120) by AM9P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17 via Frontend Transport; Tue, 8 Dec 2020 12:08:35 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 93a9ab57-beac-4314-a39a-08d89b71fdf5 X-MS-TrafficTypeDiagnostic: VI1PR04MB5693: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oDlz8avr+2m1ZAwbIdJezzWhYiIb1YLl908K9EeKuiJkTpKW8lidkjmW7sehgU8+UuXQTaGqRp9nkVJ6CfBLBp5FGScaCZKcECT/+tyirkqO8q1hcpWidwbkUisHq8SbAfZhqj7qF91KGbbrrcXrZolcpHooXjjUFdRBsWv3azRLhhysrAQ3zFKtr8bp+HI5CRfDX5y2SqHCQf3rbkZJawiHdHmm6fgBAsgShcF9MPWhw9jkOVmGtwLA9U/NmGJyqj8DIWeQYC2obzw6cAPCZwC/n/i6Um89DTJtNeCmKM+WtlDTjNh+XzQ2b0gcoKe+DgiVI0sebwEApMeG259NCiXS+FLmDuE9CVO+hS1C7LMZz0CYDVFdledjhHGrvOwP X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5696.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(498600001)(5660300002)(956004)(83380400001)(2616005)(69590400008)(4326008)(54906003)(6506007)(6486002)(44832011)(66556008)(2906002)(36756003)(186003)(6512007)(6666004)(6916009)(66946007)(66476007)(26005)(16526019)(86362001)(52116002)(1076003)(8676002)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: i5HMabItg6eOLG8rmxQOohi2FL5BcpnsY45fY35WvJUUubUyNQp8asCvN0QUmkTXGRwmpwBOfrsUbLOn7mEQkX9hQCATTvOoHvzpgXe7+wXwSG21+ATl3t8TYT0i2kGYM60i4UYG0I0ycEKguF69dK73VbUcOMD3L2auec3sJkhIzRxEjJr2S9d4daxa5cSOi9RAJuS5VJsAW2Dsiz06pNubcSjYAxUUBrJq21qN5idy93jNf3zJsigcoHK+DjEQoT4gj4Ue113nQVc0iqFFYoVi+FEA146DsIV6Mv4SeAG+HedRq9n9njWx8Jf+lMA4bTymME4Hk1ZBj59vvQUO9yW64ssASxq+M6tY0sjX3BMMrVrHPF8pOjbZi2CysBaX283dnUf8iUKpB+tyAdY1JqXU0ek1n1QcH8lNipEgeBqvWD+Qf8JlReOwzyOZTUQrssh1gjr5E8k/WFEkRpeKwIJBA3PLkEug0ICnnSABIDJxE9EO6TtRsBEFMnkyMBoSMtTiezP4dL8zli9JwIRcZ6vLjjDL+UVMB/RxpBKb0W4/Q3AlDRGmLMnXthkBGB7za8sG7+2Fo9GWiyf8EsF6XREJs6AgfdWBn94tVcehdnRvQMmwPnlPipMoZbBHUOBEdE7SZ48J2yLzdNde34stGn9CR/Tke1a/8oHtO5R4dPZzYVXKYdR/KB1/Zg3MsWpAcRZDZIqTaBU9gK+ahalxGp65zYg5QpV1WwCXAIxGcMElAQ9VvXCKgUm/X0MRnLH+YZjat7iGkha9BoqCAmoiBt3AI6PclK27MX2B3YNLX+Ges2zFXYTwFyNEsLLMYuSpbDXuT1aSzIQQzzUwl6McajJSDT/2IjFrpZrfU6xCLF/NVNZzp3qoH1bAEK5FjJA6R7H5iScSAEt72+i6U2mEuMXE7K60S8tiK+XJzgXNMviFARlr+HwebajF0vFrtlcNlvLWUDjwR8lOLf1nB+TpPW998Rueyoz71DL/RVETKdtoFqv9WeRlMy5JqvQMaspi X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 93a9ab57-beac-4314-a39a-08d89b71fdf5 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5696.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2020 12:08:37.0446 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: z5xJ8I3CRA62PvXdJqSn7whe4Yxxq7iEjuJJfv3eXbdlUvvfzbw9hw4VPwgxW/Qk815oo0MXPwyLfrpoKBnlFA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5693 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC We can now simplify the implementation by always using ocelot_get_bond_mask to look up the other ports that are offloading the same bonding interface as us. In ocelot_set_aggr_pgids, the code had a way to uniquely iterate through LAGs. We need to achieve the same behavior by marking each LAG as visited, which we do now by temporarily allocating an array of pointers to bonding uppers of each port, and marking each bonding upper as NULL once it has been treated by the first port that is a member. And because we now do some dynamic allocation, we need to propagate errors from ocelot_set_aggr_pgid all the way to ocelot_port_lag_leave. Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/mscc/ocelot.c | 104 ++++++++++--------------- drivers/net/ethernet/mscc/ocelot.h | 4 +- drivers/net/ethernet/mscc/ocelot_net.c | 4 +- include/soc/mscc/ocelot.h | 2 - 4 files changed, 47 insertions(+), 67 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 1a98c24af056..d4dbba66aa65 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -909,21 +909,17 @@ static void ocelot_apply_bridge_fwd_mask(struct ocelot *ocelot) * source port's forwarding mask. */ for (port = 0; port < ocelot->num_phys_ports; port++) { - if (ocelot->bridge_fwd_mask & BIT(port)) { - unsigned long mask = ocelot->bridge_fwd_mask & ~BIT(port); - int lag; + struct ocelot_port *ocelot_port = ocelot->ports[port]; - for (lag = 0; lag < ocelot->num_phys_ports; lag++) { - unsigned long bond_mask = ocelot->lags[lag]; + if (!ocelot_port) + continue; - if (!bond_mask) - continue; + if (ocelot->bridge_fwd_mask & BIT(port)) { + unsigned long mask = ocelot->bridge_fwd_mask & ~BIT(port); + struct net_device *bond = ocelot_port->bond; - if (bond_mask & BIT(port)) { - mask &= ~bond_mask; - break; - } - } + if (bond) + mask &= ~ocelot_get_bond_mask(ocelot, bond); ocelot_write_rix(ocelot, mask, ANA_PGID_PGID, PGID_SRC + port); @@ -1238,10 +1234,16 @@ int ocelot_port_bridge_leave(struct ocelot *ocelot, int port, } EXPORT_SYMBOL(ocelot_port_bridge_leave); -static void ocelot_set_aggr_pgids(struct ocelot *ocelot) +static int ocelot_set_aggr_pgids(struct ocelot *ocelot) { + struct net_device **bonds; int i, port, lag; + bonds = kcalloc(ocelot->num_phys_ports, sizeof(struct net_device *), + GFP_KERNEL); + if (!bonds) + return -ENOMEM; + /* Reset destination and aggregation PGIDS */ for_each_unicast_dest_pgid(ocelot, port) ocelot_write_rix(ocelot, BIT(port), ANA_PGID_PGID, port); @@ -1250,16 +1252,26 @@ static void ocelot_set_aggr_pgids(struct ocelot *ocelot) ocelot_write_rix(ocelot, GENMASK(ocelot->num_phys_ports - 1, 0), ANA_PGID_PGID, i); + for (port = 0; port < ocelot->num_phys_ports; port++) { + struct ocelot_port *ocelot_port = ocelot->ports[port]; + + if (!ocelot_port) + continue; + + bonds[port] = ocelot_port->bond; + } + /* Now, set PGIDs for each LAG */ for (lag = 0; lag < ocelot->num_phys_ports; lag++) { unsigned long bond_mask; int aggr_count = 0; u8 aggr_idx[16]; - bond_mask = ocelot->lags[lag]; - if (!bond_mask) + if (!bonds[lag]) continue; + bond_mask = ocelot_get_bond_mask(ocelot, bonds[lag]); + for_each_set_bit(port, &bond_mask, ocelot->num_phys_ports) { // Destination mask ocelot_write_rix(ocelot, bond_mask, @@ -1276,7 +1288,19 @@ static void ocelot_set_aggr_pgids(struct ocelot *ocelot) ac |= BIT(aggr_idx[i % aggr_count]); ocelot_write_rix(ocelot, ac, ANA_PGID_PGID, i); } + + /* Mark the bonding interface as visited to avoid applying + * the same config again + */ + for (i = lag + 1; i < ocelot->num_phys_ports; i++) + if (bonds[i] == bonds[lag]) + bonds[i] = NULL; + + bonds[lag] = NULL; } + + kfree(bonds); + return 0; } /* When offloading a bonding interface, the switch ports configured under the @@ -1315,59 +1339,22 @@ static void ocelot_setup_logical_port_ids(struct ocelot *ocelot) int ocelot_port_lag_join(struct ocelot *ocelot, int port, struct net_device *bond) { - u32 bond_mask = 0; - int lag; - ocelot->ports[port]->bond = bond; - bond_mask = ocelot_get_bond_mask(ocelot, bond); - - lag = __ffs(bond_mask); - - /* If the new port is the lowest one, use it as the logical port from - * now on - */ - if (port == lag) { - ocelot->lags[port] = bond_mask; - bond_mask &= ~BIT(port); - if (bond_mask) - ocelot->lags[__ffs(bond_mask)] = 0; - } else { - ocelot->lags[lag] |= BIT(port); - } - ocelot_setup_logical_port_ids(ocelot); ocelot_apply_bridge_fwd_mask(ocelot); - ocelot_set_aggr_pgids(ocelot); - - return 0; + return ocelot_set_aggr_pgids(ocelot); } EXPORT_SYMBOL(ocelot_port_lag_join); -void ocelot_port_lag_leave(struct ocelot *ocelot, int port, - struct net_device *bond) +int ocelot_port_lag_leave(struct ocelot *ocelot, int port, + struct net_device *bond) { - int i; - ocelot->ports[port]->bond = NULL; - /* Remove port from any lag */ - for (i = 0; i < ocelot->num_phys_ports; i++) - ocelot->lags[i] &= ~BIT(port); - - /* if it was the logical port of the lag, move the lag config to the - * next port - */ - if (ocelot->lags[port]) { - int n = __ffs(ocelot->lags[port]); - - ocelot->lags[n] = ocelot->lags[port]; - ocelot->lags[port] = 0; - } - ocelot_setup_logical_port_ids(ocelot); ocelot_apply_bridge_fwd_mask(ocelot); - ocelot_set_aggr_pgids(ocelot); + return ocelot_set_aggr_pgids(ocelot); } EXPORT_SYMBOL(ocelot_port_lag_leave); @@ -1543,11 +1530,6 @@ int ocelot_init(struct ocelot *ocelot) } } - ocelot->lags = devm_kcalloc(ocelot->dev, ocelot->num_phys_ports, - sizeof(u32), GFP_KERNEL); - if (!ocelot->lags) - return -ENOMEM; - ocelot->stats = devm_kcalloc(ocelot->dev, ocelot->num_phys_ports * ocelot->num_stats, sizeof(u64), GFP_KERNEL); diff --git a/drivers/net/ethernet/mscc/ocelot.h b/drivers/net/ethernet/mscc/ocelot.h index 739bd201d951..bef8d5f8e6e5 100644 --- a/drivers/net/ethernet/mscc/ocelot.h +++ b/drivers/net/ethernet/mscc/ocelot.h @@ -114,8 +114,8 @@ int ocelot_mact_forget(struct ocelot *ocelot, const unsigned char mac[ETH_ALEN], unsigned int vid); int ocelot_port_lag_join(struct ocelot *ocelot, int port, struct net_device *bond); -void ocelot_port_lag_leave(struct ocelot *ocelot, int port, - struct net_device *bond); +int ocelot_port_lag_leave(struct ocelot *ocelot, int port, + struct net_device *bond); struct net_device *ocelot_port_to_netdev(struct ocelot *ocelot, int port); int ocelot_netdev_to_port(struct net_device *dev); diff --git a/drivers/net/ethernet/mscc/ocelot_net.c b/drivers/net/ethernet/mscc/ocelot_net.c index 77957328722a..93aaa631e347 100644 --- a/drivers/net/ethernet/mscc/ocelot_net.c +++ b/drivers/net/ethernet/mscc/ocelot_net.c @@ -1035,8 +1035,8 @@ static int ocelot_netdevice_changeupper(struct net_device *dev, err = ocelot_port_lag_join(ocelot, port, info->upper_dev); else - ocelot_port_lag_leave(ocelot, port, - info->upper_dev); + err = ocelot_port_lag_leave(ocelot, port, + info->upper_dev); } return notifier_from_errno(err); diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index b812bdff1da1..0cd45659430f 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -639,8 +639,6 @@ struct ocelot { enum ocelot_tag_prefix inj_prefix; enum ocelot_tag_prefix xtr_prefix; - u32 *lags; - struct list_head multicast; struct list_head pgids; From patchwork Tue Dec 8 12:07:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 11958305 X-Patchwork-Delegate: kuba@kernel.org 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 A0AECC1B0D9 for ; Tue, 8 Dec 2020 12:11:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7048223406 for ; Tue, 8 Dec 2020 12:11:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729393AbgLHMKo (ORCPT ); Tue, 8 Dec 2020 07:10:44 -0500 Received: from mail-eopbgr80053.outbound.protection.outlook.com ([40.107.8.53]:11267 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729377AbgLHMKo (ORCPT ); Tue, 8 Dec 2020 07:10:44 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Uo87JvIjiR31xCEG8s3/7pTR1ParhQTrHxj6ZiPoCsxtwB6+yfWiEmp7lARUCXHwPXHJci9NA434pBHPIZIU9bKUGkxNWE/+aiB65Pw/uRrPdVXYp820RLqKp1F99VjrrKGzoLDEx2QwrduqMZbJnrl+PRgz/OjlfggfnF33wFLkXnqOYHfgJasmAlC2lWpUG+7ktvpK0UcTSdPVxOEI35frhH4ML+KsCdMWW0T9xVDVU0sdVmV83p09bx9TClNImLnqfzjYRYnLeMTniNqcVR0cVHS/j+I1C5WccNod+9k4O4iXw85IVP+nP1GgnzCFcdjIDa+KjoTguyNeUkax2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+ehBH6TsgDRDrIphbpd5YlZ5x0mQB7cLsE95AIYHzoA=; b=angRSYc8CjOwBh7M51cBdxx2EFhhE1I5nOURX57LIkoMI8jxzW6JWUDop01m5SqA7g7cy54MQDLBqR/6BfC/KPap1M2Vyb0pMxaqm0NK9N0vG1Kkw8OTrTBxNnoIjsyEhauI1NhC8LGMIu4D/nP8LSfrnU+5i7Ls+FNzn0RjlX9RmmY6vnpgHow1V+0XVZlBQL9UQDBLL7/Ce/uz3LIUtq7vtfpvOoA8DmbatN8OAp60p1IxSSEmUwsrL8WY0483Agm0lE7v1NZEqxFZcTxZ5PKR+YWmhr0XeQhUvZtXSPsoUVhZgmRqmuwjmv7xJh0S6MP4mA4PUyBPfR1WHrOXzQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+ehBH6TsgDRDrIphbpd5YlZ5x0mQB7cLsE95AIYHzoA=; b=rGPi7XF6uhStKOzcbx2HZeXKfBZXFKIOOMurVDqZe7q6I2ywb41fOTcAmpVxz8xP5aC242S9qRko2PjEsR8VPMfj/4MqBaFOUDXqQxOVPQE0oCEqyjS/T4ccQRrsNELk0cUIcjlqblZlDjVTONxuOpzZl1LWzMixhCbFnvZvgIk= Authentication-Results: waldekranz.com; dkim=none (message not signed) header.d=none;waldekranz.com; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) by VI1PR04MB5693.eurprd04.prod.outlook.com (2603:10a6:803:e2::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21; Tue, 8 Dec 2020 12:08:38 +0000 Received: from VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84]) by VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84%5]) with mapi id 15.20.3632.021; Tue, 8 Dec 2020 12:08:38 +0000 From: Vladimir Oltean To: Tobias Waldekranz Cc: "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org, UNGLinuxDriver@microchip.com, Alexandre Belloni , Andrew Lunn , Florian Fainelli , Vivien Didelot , Claudiu Manoil Subject: [RFC PATCH net-next 13/16] net: mscc: ocelot: rename aggr_count to num_ports_in_lag Date: Tue, 8 Dec 2020 14:07:59 +0200 Message-Id: <20201208120802.1268708-14-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201208120802.1268708-1-vladimir.oltean@nxp.com> References: <20201208120802.1268708-1-vladimir.oltean@nxp.com> X-Originating-IP: [188.25.2.120] X-ClientProxiedBy: AM9P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::21) To VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.2.120) by AM9P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17 via Frontend Transport; Tue, 8 Dec 2020 12:08:37 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: bde782da-f78d-47fb-0038-08d89b71fedb X-MS-TrafficTypeDiagnostic: VI1PR04MB5693: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4125; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: guO/a2426VUa8oR8qyGGpkz441hjRmEPfo6SAFQVacRsSQHJVkt5w1DwvP/gIH9m2CEybHQCECxRHl47KXDd1LvXDCkKPzDXawWRTCcsQV7EUoh6HR4p5GoGkWWHaaeR0W8+FAIMmb45lgAe2yLBI4RX/+yQB0uqRAtEgLQuoLCfGSVVoZ07tyO6gty/BvS4g25jGRBfwX3QBhMgEePJT9qdS1sUf/6Ox5YDurpynmldSUGqk75CMBL+aAymXojfDZBn38fHfcf69XmPsOSz9tvsSLkrHfhUte/ABiJp1xJjFpIUs3OKGeZxHcPvdO7Znd0Co1DJ2KARaGoCOpAJB6rLMeBowmvO0kjLe6uMmJc094tJ2tDztA3Twza04h9E X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5696.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(498600001)(5660300002)(956004)(83380400001)(2616005)(69590400008)(4326008)(54906003)(6506007)(6486002)(44832011)(66556008)(2906002)(36756003)(186003)(6512007)(6666004)(6916009)(66946007)(66476007)(26005)(16526019)(86362001)(52116002)(1076003)(8676002)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: ThofDMo6yTj012Pxa901nz3KR4kXwRBfiMNyCbLtQ3d7DqZ1EtHVNgN8YrmU6loyDEjF0B9HkPPjM/IWpv9rrMqZdF1NqqCbT2X3z9Ez+xEjZFYqVb6PjQRIOISdL+GSqetAT/C71xWc8S4FzhCCkXxrmBQvIwVuUCA/8rIKb/CzEUhKV8xESEoqkM//GvrEaFOZ2K8gtRMJsberAADnWNdopc2r+ksPlKbsRwAdbD/RHKLN/m/+ZXMPE44FaIARKV1OtFk1j5KO5mzpeVakpYw+JwkcUV8irxBjeMVd2sgFNy9ukm3tGqc6Y3C2DT0OTYQzF+mdbtItFbQc1VtDBPY+dpgpSGmOoy00bOllzGQ7rHYCtbSM82pOs5DyV1B0oYqpes99dwCbAN8yxRDVQunF53952pa+QkVvWea7Yfqw+ItFBp0aYr0qP+GXIT/AitafOkElglnmag1Lh3Lev4ODoC/BIWAAEDRGjqVCuFWNsWhUZpvuCzupvMQ+ilWSe7ma1dYu8wNhMonb7m+TfamKg78iBNDOYL+yfWJYEc/jNPEJd2vLrdS2jkXBqAhr8AUt2adRyEP4MVgRXYxJWUPyrnLIpOqQZBUWowOPPZtyfuXeuOOipwi7xY7c7EQvZ0ckeIyBlcoK6uPQd4OKwCdXHCpkJNmkFP/3IaGkquh30xFxH74iTLKmC1LRQqMFZUTAu1rUPXNIlzbr5SIF5YUgJRCzW/WQg+7HW6IyaIbIue1ceHmTZsjhO89KQHxkCKPRGo+g1MUCIDUjBm9PJbHGdEesQoowUTFWKsJtFRZQGrByJnt3dFoTSS2GJmde5/WCsrGtKmBHjaGdzpeFMDNwMMMgGDjgX7j4yRPBig9+SwIt+BjLe7MFJm1N+ArJobewx033hgMPBBGGc2m5s/bR8+X4iM3VvA+B0c8KZGLFvxKVWmGoe97AHKdWolTWLvTPZdQtBF+mVHgig3vbKQY0bVjQQK9k0hkgEjm79RlVJ2jxK8DKHDN60lBwc32G X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: bde782da-f78d-47fb-0038-08d89b71fedb X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5696.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2020 12:08:38.4558 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: sTcAvC0d7LsMC8TgAq/TrdzN0TOL1LSXtm5Cq5R1T23krtMLloShuUmQAYL/92fOV8JDRfWkfgGNr+KrthqWQg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5693 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC It makes it a bit easier to read and understand the code that deals with balancing the 16 aggregation codes among the ports in a certain LAG. Signed-off-by: Vladimir Oltean Reviewed-by: Alexandre Belloni --- drivers/net/ethernet/mscc/ocelot.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index d4dbba66aa65..d87e80a15ca5 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -1263,8 +1263,8 @@ static int ocelot_set_aggr_pgids(struct ocelot *ocelot) /* Now, set PGIDs for each LAG */ for (lag = 0; lag < ocelot->num_phys_ports; lag++) { + int num_ports_in_lag = 0; unsigned long bond_mask; - int aggr_count = 0; u8 aggr_idx[16]; if (!bonds[lag]) @@ -1276,8 +1276,7 @@ static int ocelot_set_aggr_pgids(struct ocelot *ocelot) // Destination mask ocelot_write_rix(ocelot, bond_mask, ANA_PGID_PGID, port); - aggr_idx[aggr_count] = port; - aggr_count++; + aggr_idx[num_ports_in_lag++] = port; } for_each_aggr_pgid(ocelot, i) { @@ -1285,7 +1284,7 @@ static int ocelot_set_aggr_pgids(struct ocelot *ocelot) ac = ocelot_read_rix(ocelot, ANA_PGID_PGID, i); ac &= ~bond_mask; - ac |= BIT(aggr_idx[i % aggr_count]); + ac |= BIT(aggr_idx[i % num_ports_in_lag]); ocelot_write_rix(ocelot, ac, ANA_PGID_PGID, i); } From patchwork Tue Dec 8 12:08:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 11958309 X-Patchwork-Delegate: kuba@kernel.org 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 0EBD2C1B0E3 for ; Tue, 8 Dec 2020 12:11:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C7F1F23406 for ; Tue, 8 Dec 2020 12:11:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729402AbgLHMK4 (ORCPT ); Tue, 8 Dec 2020 07:10:56 -0500 Received: from mail-eopbgr80078.outbound.protection.outlook.com ([40.107.8.78]:17934 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728225AbgLHMK4 (ORCPT ); Tue, 8 Dec 2020 07:10:56 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VX6fkBSW+PDEzfPBmRMswccN5i0AKKMwBZtSyXYQ1lRwrccHL+svLyMcslq8cKv4tGuIIwsmc/2W3J0h/cSQrN35NQew3KXDs4hVw9ehrUYz6+9zD4TG+zGF6ykx2pKcaGDIXEuC+gB7/fmU12YXbamteANrRs/6qJR3wHBGdqwitm9old5ynTbNc3ZxCrGf4YRvgomDGgVw/YLgwWP//zMFH7ZxcmllsioXchmHSnDhIcOXTh+G3dGGHsXsm3kloOG3398bsYcdSztrzgUFJfjVJ+aUsIt7Hpnozab2Am2Zcy3l6QPA751a7wwcJSXqeMOlnDadbK151XdTvpT1Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XkX35sVFOq2OvFjHDuCNIrj0kVichhKGPeUZl7On4jQ=; b=kHatDfvC9Kv/mkoVAQ0gSoaHBpAgIM3gpjP9ifgAswEhRiWAeJxAG4S8abGo0FancOB34vtPm8LDwnZlkzl5LXxyYTngsaUncEpmkH6Ffk5OOPtqlg52UwuRk1aw8S6VKaDVUBqBN13g5s5NkcVlf+DX8pAEoUz3fD8LC3ivsFSzGwX7qBdIo7tdr/lBAdnOquFoGu2OMI+mX7mWNRSiVZngxQfcpyVBywAGaIIQmq7ZWUMyj6qVqMyj8sExBY5XzPQ7W5YXgTFL8pdId8KuzBllL6IaALcp14BzTlXTOragcekN7ceBX52XF/aHKXBwm6QV7g+Ql9y6mzFCvH0c8Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XkX35sVFOq2OvFjHDuCNIrj0kVichhKGPeUZl7On4jQ=; b=VvYdlK7PY76yr9eQ+1+wBescIVmM/kpQB4zcXizkeD26S1Jl18DMVTpxlDXmXg4306PqB2j7qM2DHluzkqHBRE5OBN0dTfge7wtJM1Ev2eK9EJHb6jdddxzt4h68N8trg3RfJzVKDsN4jG/88tapXlGnCDBQ+B2MXk2XydC5GSE= Authentication-Results: waldekranz.com; dkim=none (message not signed) header.d=none;waldekranz.com; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) by VI1PR04MB5693.eurprd04.prod.outlook.com (2603:10a6:803:e2::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.21; Tue, 8 Dec 2020 12:08:39 +0000 Received: from VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84]) by VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84%5]) with mapi id 15.20.3632.021; Tue, 8 Dec 2020 12:08:39 +0000 From: Vladimir Oltean To: Tobias Waldekranz Cc: "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org, UNGLinuxDriver@microchip.com, Alexandre Belloni , Andrew Lunn , Florian Fainelli , Vivien Didelot , Claudiu Manoil Subject: [RFC PATCH net-next 14/16] net: mscc: ocelot: rebalance LAGs on link up/down events Date: Tue, 8 Dec 2020 14:08:00 +0200 Message-Id: <20201208120802.1268708-15-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201208120802.1268708-1-vladimir.oltean@nxp.com> References: <20201208120802.1268708-1-vladimir.oltean@nxp.com> X-Originating-IP: [188.25.2.120] X-ClientProxiedBy: AM9P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::21) To VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.2.120) by AM9P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17 via Frontend Transport; Tue, 8 Dec 2020 12:08:38 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 45220bb2-8d85-4638-0b8f-08d89b71ffb0 X-MS-TrafficTypeDiagnostic: VI1PR04MB5693: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iavvUG/Rzq2A6aEKm3PFS+CfKbFdVLurjCJsCdv021dgQ7IbkN55Xu/QCqo9jA5Cfb/DMp/ml1ckmB/9QMWmLV86UxnaEG5HWsnDbMhB+K7w1GsiAZbufucU622Z/e/VPsQTTliNAAAFF+VmluKMGkjJRiUMsbW39ZshEfRZptvR7lXo+xgh++CXPRQGAm0TPlmIJBHyjDjNIrNwVR4i/ZwwJ9Xedc16hY9kiVcysR7ipYzsaR79c8Ur4hbMSbIoNHSVuaeJNYqNTom/ySIRRdSajW6WAFVRoGhE/jKN0XVtaB+VwHdbryZS3ws4GFqomz7/2K7JwTcDR3iKrNr7z1sgEwYhprNbdGgte+VFZDX+HbR/Yu3QWqjAWzppqJty X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5696.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(498600001)(5660300002)(956004)(83380400001)(2616005)(69590400008)(4326008)(54906003)(6506007)(6486002)(44832011)(66556008)(2906002)(36756003)(186003)(6512007)(6666004)(6916009)(66946007)(66476007)(26005)(16526019)(86362001)(52116002)(1076003)(8676002)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: sBr/u6YqWOoYWkultN/Sir1uAGSP3NE/QqdrH2qimscS2TY3jdPPCKn4u6Sn9vH47TcdDKBaCb92voLSesuWOxUVFpSoN/+hIDj+C66NG11bQxDxylsgtK03owCLLo5+r97+bAGCeWJGqtlbOkH+GH/ey7iGiuy3ObxNHh+v0rFGRuub4o8sHlDFew9JtqxsLshY+h44phXuqxhJcIvldWsK82KAgFuxuptgfCQCS6/h7rFyxzAuh7cGNE8Kp1QB1nDm42SEftDIIyR09S0U8pkxl4DSWY9tSsb3om1TmZc/sT++NK1R2/l+xeqv5v4pdLe10jZikKiZ1OPQcqI+wLHvIeNZqAmBJTCiKJ2nzYu/nQouIl1HCgdR0RDac6ScIRULvEDAaAbrm6srX4v+JepfE6ZVLGuvP8+01sjVEB0ZiMWkG4PYL1aA2p+sHrmPfXppDHelSBnCOD/gRHENIMR/rBjff+24xjvpPFjxY0QRPcW0iQ0IFp4fyxVGRUIu/fIv6DsJuicRLUmYjKWvbHLEeoX4thcCzrPr6tzAnvMaN5UX4kACJT3vNKBlI/TYcattRefS2924VIpSiBWNmjzQSmu9RrSQ2mqweXFb+a6CKydzrUF63eETmrA4bkTJfaAHRGs8/DA9067nZwR7yoVqJ48POM1FlYAvgeRfHpM836ZpFm8Pd81nMNYlle0lXZ+JAvd0cneS6BvJuJ4w8hMmCNyQBPtU9hxyFuEX7z5hJBHeSJ/ZYfCXr7hcMYigOMGelD2GqsRBVsEr8lavv6hBiLUossCdhO/nRnOQg0vTgtWaHnT+U5IYWptLwtMyZuXwuFVWDUKbGzIAN3Dbj3JoTKoHwKaOSRDxA97GIIGaj1bfwNDgW3JlbTYdW7KNmYMEzizgR2Nh218yvxFQiGfDwmRZtcEQtbze0BhmjtcV2YCnJi7urIad2W/b7YsXxSmlWWYqc3lJRNWrgCTgwKgozFmOFcop5c475tBZp4wRAU+8akqr56WQP9DKsRzF X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 45220bb2-8d85-4638-0b8f-08d89b71ffb0 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5696.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2020 12:08:39.8860 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: FjC84fhcPGKXQlwjoV+X4rmvNoZjke5LKb5Y/kAHe/Q43IBtpdpINPhIqDtjGptL4IZnxhdvqf/cbrISJWssfg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5693 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC At present there is an issue when ocelot is offloading a bonding interface, but one of the links of the physical ports goes down. Traffic keeps being hashed towards that destination, and of course gets dropped on egress. Monitor the netdev notifier events emitted by the bonding driver for changes in the physical state of lower interfaces, to determine which ports are active and which ones are no longer. Then extend ocelot_get_bond_mask to return either the configured bonding interfaces, or the active ones, depending on a boolean argument. The code that does rebalancing only needs to do so among the active ports, whereas the bridge forwarding mask and the logical port IDs still need to look at the permanently bonded ports. Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/mscc/ocelot.c | 43 ++++++++++++++++++++------ drivers/net/ethernet/mscc/ocelot.h | 2 ++ drivers/net/ethernet/mscc/ocelot_net.c | 26 ++++++++++++++++ include/soc/mscc/ocelot.h | 1 + 4 files changed, 63 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index d87e80a15ca5..5c71d121048d 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -881,7 +881,8 @@ int ocelot_get_ts_info(struct ocelot *ocelot, int port, } EXPORT_SYMBOL(ocelot_get_ts_info); -static u32 ocelot_get_bond_mask(struct ocelot *ocelot, struct net_device *bond) +static u32 ocelot_get_bond_mask(struct ocelot *ocelot, struct net_device *bond, + bool just_active_ports) { u32 bond_mask = 0; int port; @@ -892,8 +893,12 @@ static u32 ocelot_get_bond_mask(struct ocelot *ocelot, struct net_device *bond) if (!ocelot_port) continue; - if (ocelot_port->bond == bond) + if (ocelot_port->bond == bond) { + if (just_active_ports && !ocelot_port->lag_tx_active) + continue; + bond_mask |= BIT(port); + } } return bond_mask; @@ -919,7 +924,7 @@ static void ocelot_apply_bridge_fwd_mask(struct ocelot *ocelot) struct net_device *bond = ocelot_port->bond; if (bond) - mask &= ~ocelot_get_bond_mask(ocelot, bond); + mask &= ~ocelot_get_bond_mask(ocelot, bond, false); ocelot_write_rix(ocelot, mask, ANA_PGID_PGID, PGID_SRC + port); @@ -1261,22 +1266,22 @@ static int ocelot_set_aggr_pgids(struct ocelot *ocelot) bonds[port] = ocelot_port->bond; } - /* Now, set PGIDs for each LAG */ + /* Now, set PGIDs for each active LAG */ for (lag = 0; lag < ocelot->num_phys_ports; lag++) { - int num_ports_in_lag = 0; + int num_active_ports = 0; unsigned long bond_mask; u8 aggr_idx[16]; if (!bonds[lag]) continue; - bond_mask = ocelot_get_bond_mask(ocelot, bonds[lag]); + bond_mask = ocelot_get_bond_mask(ocelot, bonds[lag], true); for_each_set_bit(port, &bond_mask, ocelot->num_phys_ports) { // Destination mask ocelot_write_rix(ocelot, bond_mask, ANA_PGID_PGID, port); - aggr_idx[num_ports_in_lag++] = port; + aggr_idx[num_active_ports++] = port; } for_each_aggr_pgid(ocelot, i) { @@ -1284,7 +1289,11 @@ static int ocelot_set_aggr_pgids(struct ocelot *ocelot) ac = ocelot_read_rix(ocelot, ANA_PGID_PGID, i); ac &= ~bond_mask; - ac |= BIT(aggr_idx[i % num_ports_in_lag]); + /* Don't do division by zero if there was no active + * port. Just make all aggregation codes zero. + */ + if (num_active_ports) + ac |= BIT(aggr_idx[i % num_active_ports]); ocelot_write_rix(ocelot, ac, ANA_PGID_PGID, i); } @@ -1320,7 +1329,8 @@ static void ocelot_setup_logical_port_ids(struct ocelot *ocelot) bond = ocelot_port->bond; if (bond) { - int lag = __ffs(ocelot_get_bond_mask(ocelot, bond)); + int lag = __ffs(ocelot_get_bond_mask(ocelot, bond, + false)); ocelot_rmw_gix(ocelot, ANA_PORT_PORT_CFG_PORTID_VAL(lag), @@ -1357,6 +1367,21 @@ int ocelot_port_lag_leave(struct ocelot *ocelot, int port, } EXPORT_SYMBOL(ocelot_port_lag_leave); +int ocelot_port_lag_change(struct ocelot *ocelot, int port, + struct netdev_lag_lower_state_info *info) +{ + struct ocelot_port *ocelot_port = ocelot->ports[port]; + bool is_active = info->link_up && info->tx_enabled; + + if (ocelot_port->lag_tx_active == is_active) + return 0; + + ocelot_port->lag_tx_active = is_active; + + /* Rebalance the LAGs */ + return ocelot_set_aggr_pgids(ocelot); +} + /* Configure the maximum SDU (L2 payload) on RX to the value specified in @sdu. * The length of VLAN tags is accounted for automatically via DEV_MAC_TAGS_CFG. * In the special case that it's the NPI port that we're configuring, the diff --git a/drivers/net/ethernet/mscc/ocelot.h b/drivers/net/ethernet/mscc/ocelot.h index bef8d5f8e6e5..0860125b623c 100644 --- a/drivers/net/ethernet/mscc/ocelot.h +++ b/drivers/net/ethernet/mscc/ocelot.h @@ -116,6 +116,8 @@ int ocelot_port_lag_join(struct ocelot *ocelot, int port, struct net_device *bond); int ocelot_port_lag_leave(struct ocelot *ocelot, int port, struct net_device *bond); +int ocelot_port_lag_change(struct ocelot *ocelot, int port, + struct netdev_lag_lower_state_info *info); struct net_device *ocelot_port_to_netdev(struct ocelot *ocelot, int port); int ocelot_netdev_to_port(struct net_device *dev); diff --git a/drivers/net/ethernet/mscc/ocelot_net.c b/drivers/net/ethernet/mscc/ocelot_net.c index 93aaa631e347..714fc99f8339 100644 --- a/drivers/net/ethernet/mscc/ocelot_net.c +++ b/drivers/net/ethernet/mscc/ocelot_net.c @@ -1065,6 +1065,23 @@ ocelot_netdevice_lag_changeupper(struct net_device *dev, return NOTIFY_DONE; } +static int +ocelot_netdevice_changelowerstate(struct net_device *dev, + struct netdev_lag_lower_state_info *linfo) +{ + struct ocelot_port_private *priv = netdev_priv(dev); + struct ocelot_port *ocelot_port = &priv->port; + struct ocelot *ocelot = ocelot_port->ocelot; + int port = priv->chip_port; + int err; + + if (!ocelot_port->bond) + return NOTIFY_DONE; + + err = ocelot_port_lag_change(ocelot, port, linfo); + return notifier_from_errno(err); +} + static int ocelot_netdevice_event(struct notifier_block *unused, unsigned long event, void *ptr) { @@ -1082,6 +1099,15 @@ static int ocelot_netdevice_event(struct notifier_block *unused, break; } + case NETDEV_CHANGELOWERSTATE: { + struct netdev_notifier_changelowerstate_info *info = ptr; + + if (!ocelot_netdevice_dev_check(dev)) + break; + + return ocelot_netdevice_changelowerstate(dev, + info->lower_state_info); + } default: break; } diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index 0cd45659430f..8a44b9064789 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -599,6 +599,7 @@ struct ocelot_port { u8 *xmit_template; struct net_device *bond; + bool lag_tx_active; }; struct ocelot { From patchwork Tue Dec 8 12:08:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 11958283 X-Patchwork-Delegate: kuba@kernel.org 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 AB252C433FE for ; Tue, 8 Dec 2020 12:09:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5EAC023406 for ; Tue, 8 Dec 2020 12:09:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729342AbgLHMJa (ORCPT ); Tue, 8 Dec 2020 07:09:30 -0500 Received: from mail-eopbgr20047.outbound.protection.outlook.com ([40.107.2.47]:44741 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729286AbgLHMJa (ORCPT ); Tue, 8 Dec 2020 07:09:30 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hU+zQ47QX7BJ1D0qmuQFjyOpSiZO6hrJharEM7qR6bIPjdfga4HmbMaUekLbUyzTuAcdBw+ZqfnsmHGTV08r9skP36x1/ZXNrjANqTmAl8jVvny3v6HTlDjrUaw1WokCUKQ3J+z/TNEX6b0hbaCuD6HPtDcCp20ptk756JOwKFOrXd81FNwOZP8etu4UZpOs5Bf5l1qFdhJAvHg7JIVEibzE4Vvmt0wmf7r95PQCz0+1xx+6DSdIsxRgol50T7t1NMlwMDRZ7AuZiQVD4E2OqZKZJtvbDKPWw9Oj7YK5oHKj6j2adNv9kMx3aiLZbOcnsqwU325EEvRR7qY/id1Rjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fOgyI5iApfuztVH4SMENpM3XW2UpBgRTVLoiHrm64uM=; b=DHAzjJ/DlvqeVf4HIHXwjpiuoLhd2Ja+TQHiK6Oj6BDik48tcUHJ+Q2jTKp+5ONOb/DkDbVj174TrV1Nrwq4IT5a2xzr2jRAhft7dTme54MksUyrden35G+6k0j74j+7e2MOuKaY/gKdtI4JhFM+NEwDQ3w0L0ROHhnsYj32HRhjwZGYpSQ4aRIVhUig1GQcLpb7r3ROMSUPAeY2MiGQtQY3jOWiGtonvPq0YQnRwgaMlicBTSO24SNTG+dG/L4mLa2ZxSd5UIB9J9pk+IY2AoeH29COMMaGIJ69a8NZBl5QriZGWm+MXLib/VUs7kg1pnPuATBvNWD4OAGPAUWjuw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fOgyI5iApfuztVH4SMENpM3XW2UpBgRTVLoiHrm64uM=; b=X2VTGOZQFn4azqWAhX2T7n5WVTDEwrK1eB7sdmzRs9/EIGmAEUN4jzNRX3otE9bG9aPwtjxNC8hufFQzkWfMYzc+cjU3K4S7py/9Qm1/HuPW1CcvAvpOzaY+9wZCAc2hmIh6ctHHUa0EVAvgLHlJ64p/bSjERLwXGM9QNZNyMCY= Authentication-Results: waldekranz.com; dkim=none (message not signed) header.d=none;waldekranz.com; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) by VI1PR04MB5853.eurprd04.prod.outlook.com (2603:10a6:803:e3::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.18; Tue, 8 Dec 2020 12:08:41 +0000 Received: from VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84]) by VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84%5]) with mapi id 15.20.3632.021; Tue, 8 Dec 2020 12:08:41 +0000 From: Vladimir Oltean To: Tobias Waldekranz Cc: "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org, UNGLinuxDriver@microchip.com, Alexandre Belloni , Andrew Lunn , Florian Fainelli , Vivien Didelot , Claudiu Manoil Subject: [RFC PATCH net-next 15/16] net: dsa: felix: propagate the LAG offload ops towards the ocelot lib Date: Tue, 8 Dec 2020 14:08:01 +0200 Message-Id: <20201208120802.1268708-16-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201208120802.1268708-1-vladimir.oltean@nxp.com> References: <20201208120802.1268708-1-vladimir.oltean@nxp.com> X-Originating-IP: [188.25.2.120] X-ClientProxiedBy: AM9P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::21) To VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.2.120) by AM9P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17 via Frontend Transport; Tue, 8 Dec 2020 12:08:40 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 6ddfe25d-978d-4a1c-5781-08d89b72008b X-MS-TrafficTypeDiagnostic: VI1PR04MB5853: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3173; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wH+8KQSF5PZ48qT/1BRfL64aY5fmuJwpRQJgg/H3N5D+8k2BhUF7tl8i4p4qxyqnAD+lnABR82Z99Fp1Z8YqD4YzNlwsEI2JWvlHAMlQR0A3CqIUz3hsoZ2WtLkxv/SAiAiPRGA2d1uShZuRBaHkkWJCIUurRY+6lNgHg8I3ysrs4ztEvtYFUTe6zlj/Be9O0inQR1N0wUko+7Nv3kZDp4RG+iMxnKY2+hTcw4oA0+MCR0Xx95Ayc6/tus1wSeecl+7x1qjSk5shohxNBXtnaO8ErLsgigEoRWFnSxIoHBcky6zeOZAs7P1zzkKR9pCLl2+nIlbDnKAmIAgt1VYXZzFb0euaHdC50omSiIgWNzat/35Sn5dbNKxXtFE8B15h X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5696.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(1076003)(52116002)(6512007)(44832011)(6666004)(54906003)(186003)(26005)(6506007)(2906002)(5660300002)(86362001)(16526019)(8676002)(66556008)(4326008)(83380400001)(36756003)(8936002)(6916009)(956004)(498600001)(66476007)(69590400008)(6486002)(2616005)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: +jmuCiph+507D7jWg8Z4qwWg0xWylIPPs6qgM+D4XV9NbYe7MrRnNEvvV1hNOH4zKLRv3KEQ67Fbp/tD5pIj+B+SxE4WJMUBoqsWCk3o287UDk2enzpRtnuzdRmZpCv8qdjWDN0UIDQ4edtI9MFVNU7hff3bEYzbP6BwMAqzQZrOtbNNtPhwAiFZNFODo4hZcZciUHAP486uNu3BbDmZrLdbxfFdQnq2+UVVA4jLqm90Jy0W5j3dwXBaqbztpgOG/nC7aOb8qF6cDAXFq5HYQwWhgn6orfCF/bF0fVHDp0uN1TLYbwJA/iMA6lSEcgRh9baS/fh5yK1OoYlbFKuqoFR/GCyFos8FJZc0lMHzzWtbI8/Ej1oRCr5MQ2vmFUUDms2llobjhyEX3UQ853pu+IJlGqmD1GqS21p4q1J/Zz33Bb6wgeL94IfPHaQ8XsqdJtpW8XyZtMN8WuTp2F0DTK0S5ffPYPbg19vUkaotD6w6aXyoTCpIjULQchS1Ut3ryagolybAolpE+QScZD3v+8rqTFd9iUfplfT4uOe2ex3kAo+3j8LDEsH9QKei+1hPU3t2rKICn7uYJCabVbnaGGpnANb7tJYPY6UEO/vTkTcyZSqhQf6P1woXQqYhJ2A4+0DX7g6Rp+Gt5iakTyfjCxNuC2TPCTz2NhTPA5u+WU9OL6csp+GCS554TtS4xR2pSWB7WaWAh7TYSxQZnTNFqHqgyFc6Mo7yZj7b4kqqHphHi25hqLOxtL9ztuzmHEe/ooZluN7QpArHslftxlSoWW8YlTclqmMoMPgtxIkqCNQkDa4uRrcMb0/De8Y92Doc+L/BTi9vJATMYPIzHb7VIRuci/TCEwGAlJi8DGxI9hL3llpBWbX3iymxbdifCvEk8Y1z9kt8Vz0VFlwW4BOMqX9MSYVxfuYkbUqD21Fm8FSZRi5ra63yZbBLbSjzSHsu7YmldFBi4XqMKO/Tepl5ENLLMAWcXgquUHG17O9mvbMbR1UdRcz67QW1Q2Wf7Evw X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6ddfe25d-978d-4a1c-5781-08d89b72008b X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5696.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2020 12:08:41.2912 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vkA7dG+/fdaiP1aqloib5Jiy5mOSPss2ql6gqDbp5CYO1kZ/1JVoR5f2gy60cMHTJ7ZR5GIYy+qf5RyXBUkVDQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5853 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC The ocelot switch has been supporting LAG offload since its initial commit, however felix could not make use of that, due to lack of a LAG abstraction in DSA. Now that we have that, let's forward DSA's calls towards the ocelot library, who will deal with setting up the bonding. Note that ocelot_port_lag_leave can return an error due to memory allocation but we are currently ignoring that, because the DSA method returns void. Signed-off-by: Vladimir Oltean --- drivers/net/dsa/ocelot/felix.c | 27 +++++++++++++++++++++++++++ drivers/net/ethernet/mscc/ocelot.c | 1 + drivers/net/ethernet/mscc/ocelot.h | 6 ------ include/soc/mscc/ocelot.h | 6 ++++++ 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index 7dc230677b78..53ed182fac12 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -112,6 +112,30 @@ static void felix_bridge_leave(struct dsa_switch *ds, int port, ocelot_port_bridge_leave(ocelot, port, br); } +static int felix_lag_join(struct dsa_switch *ds, int port, + struct net_device *lag_dev) +{ + struct ocelot *ocelot = ds->priv; + + return ocelot_port_lag_join(ocelot, port, lag_dev); +} + +static void felix_lag_leave(struct dsa_switch *ds, int port, + struct net_device *lag_dev) +{ + struct ocelot *ocelot = ds->priv; + + ocelot_port_lag_leave(ocelot, port, lag_dev); +} + +static int felix_lag_change(struct dsa_switch *ds, int port, + struct netdev_lag_lower_state_info *linfo) +{ + struct ocelot *ocelot = ds->priv; + + return ocelot_port_lag_change(ocelot, port, linfo); +} + static int felix_vlan_prepare(struct dsa_switch *ds, int port, const struct switchdev_obj_port_vlan *vlan) { @@ -803,6 +827,9 @@ const struct dsa_switch_ops felix_switch_ops = { .port_mdb_del = felix_mdb_del, .port_bridge_join = felix_bridge_join, .port_bridge_leave = felix_bridge_leave, + .port_lag_join = felix_lag_join, + .port_lag_leave = felix_lag_leave, + .port_lag_change = felix_lag_change, .port_stp_state_set = felix_bridge_stp_state_set, .port_vlan_prepare = felix_vlan_prepare, .port_vlan_filtering = felix_vlan_filtering, diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 5c71d121048d..cd7a2e558301 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -1381,6 +1381,7 @@ int ocelot_port_lag_change(struct ocelot *ocelot, int port, /* Rebalance the LAGs */ return ocelot_set_aggr_pgids(ocelot); } +EXPORT_SYMBOL(ocelot_port_lag_change); /* Configure the maximum SDU (L2 payload) on RX to the value specified in @sdu. * The length of VLAN tags is accounted for automatically via DEV_MAC_TAGS_CFG. diff --git a/drivers/net/ethernet/mscc/ocelot.h b/drivers/net/ethernet/mscc/ocelot.h index 0860125b623c..3141ccde6a66 100644 --- a/drivers/net/ethernet/mscc/ocelot.h +++ b/drivers/net/ethernet/mscc/ocelot.h @@ -112,12 +112,6 @@ int ocelot_mact_learn(struct ocelot *ocelot, int port, unsigned int vid, enum macaccess_entry_type type); int ocelot_mact_forget(struct ocelot *ocelot, const unsigned char mac[ETH_ALEN], unsigned int vid); -int ocelot_port_lag_join(struct ocelot *ocelot, int port, - struct net_device *bond); -int ocelot_port_lag_leave(struct ocelot *ocelot, int port, - struct net_device *bond); -int ocelot_port_lag_change(struct ocelot *ocelot, int port, - struct netdev_lag_lower_state_info *info); struct net_device *ocelot_port_to_netdev(struct ocelot *ocelot, int port); int ocelot_netdev_to_port(struct net_device *dev); diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index 8a44b9064789..7c104f08796d 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -780,5 +780,11 @@ int ocelot_port_mdb_add(struct ocelot *ocelot, int port, const struct switchdev_obj_port_mdb *mdb); int ocelot_port_mdb_del(struct ocelot *ocelot, int port, const struct switchdev_obj_port_mdb *mdb); +int ocelot_port_lag_join(struct ocelot *ocelot, int port, + struct net_device *bond); +int ocelot_port_lag_leave(struct ocelot *ocelot, int port, + struct net_device *bond); +int ocelot_port_lag_change(struct ocelot *ocelot, int port, + struct netdev_lag_lower_state_info *info); #endif From patchwork Tue Dec 8 12:08:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 11958289 X-Patchwork-Delegate: kuba@kernel.org 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,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 14AB7C4361B for ; Tue, 8 Dec 2020 12:10:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CF6D223406 for ; Tue, 8 Dec 2020 12:10:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729327AbgLHMKD (ORCPT ); Tue, 8 Dec 2020 07:10:03 -0500 Received: from mail-db8eur05on2068.outbound.protection.outlook.com ([40.107.20.68]:47712 "EHLO EUR05-DB8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729306AbgLHMKC (ORCPT ); Tue, 8 Dec 2020 07:10:02 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VR9YLiBKBd+MqVaFtfPm8g/eIffkZZw4t32OexTq28FtBHJmbEH4y6LWDB3lxnz0PfijCOYGH169cTToykCUbMav//yxx6F+zsOCMVK5Wu5qEuBE29ciSx9KEwyVnTdQBIsw3Q+OugQJdmp5OY57WUT/P3z2Cuaar2ihpl2cseBMoLHotC1uj+PzAiLiNg6GNePPqAJtgkDxT9+xA31GmXvkDLxmksM9VyXwGmcyK2+6QFyhLOKyduHNwpastTbMWOTQUVr/lbxWtmY1/FBnXjaHAWK+7L+E7U14tdwbGjmmu8Sn7s4dGcfTdqL6M88HUmj6uHplUx/wo/CFEX4UjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EJiFJi3lm9kXPI+NVL8+GW24sAQhlq0Kx0pJ2EBbUHM=; b=ZRzKNpH68Cv1gUCAyOnatdcTCD+T7wXr+bzYTOgjlU1zFBuke7H0TeHfj7CM2ZjB5kdu0XBiy5yy1bIYL0ynVl5TfGaALbDWVkH/J7nyvhBXJGuhMKQ3uOsVYbJ+VdLOXgi/dnEDNmQsQc5VqDsOmv8AdEg7MdUiiwskfhQDqB5upMfKVaQ8Svben0cpz+xoLZ3U18QZqMSbrIwg/OqP4vmQuWuYzGoQE97aIfmvZ3lZKiqiIMk2eCAFKqZo6FnOt0rj4Ui3QajWBD/5xzndpM9uKJRtr7xnvUkQbsBCM7D8kTDKuMijD0SNtSeJoIV6ArUN5ZnsaG8ntHaBbyl3sQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EJiFJi3lm9kXPI+NVL8+GW24sAQhlq0Kx0pJ2EBbUHM=; b=K2URbb08TTG8KZTvwqCi02q6TrB04xX8Kt6zLQ4hHCThhH2EJD+e3RWUOYyt8Ba9np7RkBh5W222zDroTZwDBizMUbcEQioHprrl9x6dXFRGUyWYh6lh53p37MGTQxHOiN9A7QgjbYix4ONveIVgg6o30pR8p2RSZMwnzVNL1Q4= Authentication-Results: waldekranz.com; dkim=none (message not signed) header.d=none;waldekranz.com; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) by VI1PR04MB5853.eurprd04.prod.outlook.com (2603:10a6:803:e3::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.18; Tue, 8 Dec 2020 12:08:42 +0000 Received: from VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84]) by VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::2dd6:8dc:2da7:ad84%5]) with mapi id 15.20.3632.021; Tue, 8 Dec 2020 12:08:42 +0000 From: Vladimir Oltean To: Tobias Waldekranz Cc: "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org, UNGLinuxDriver@microchip.com, Alexandre Belloni , Andrew Lunn , Florian Fainelli , Vivien Didelot , Claudiu Manoil Subject: [RFC PATCH net-next 16/16] net: dsa: ocelot: tell DSA that we can offload link aggregation Date: Tue, 8 Dec 2020 14:08:02 +0200 Message-Id: <20201208120802.1268708-17-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201208120802.1268708-1-vladimir.oltean@nxp.com> References: <20201208120802.1268708-1-vladimir.oltean@nxp.com> X-Originating-IP: [188.25.2.120] X-ClientProxiedBy: AM9P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::21) To VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (188.25.2.120) by AM9P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:21d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17 via Frontend Transport; Tue, 8 Dec 2020 12:08:41 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: d1fffa9e-ad94-4d9e-80f2-08d89b720164 X-MS-TrafficTypeDiagnostic: VI1PR04MB5853: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hsstPPbFFYZdv1A6w5QJMkvMkA/E9jYb0QbOTqDyB6nQD08Eh0jDdjILRQlxT/3sVXIFNaP8a/lt8uX0uH3HP+4vkxdWHlLV4XpNdd5WPLNC+EuI4YP1kbtr4s8cVUhk9ZUC2Dhv5QMdwJdaaNM1Eweo0e/XL++QdNAPJ8QKR/XYXLt3rX77v1XmGMDMI8p2+oFz5VYmwrIxYXNpYvFRW2XLT62/zq3QNW5M3ioF1RhUsKdsIvxQ/8APLa09K2mwTDNYxKZIxazAo1CDsBrfZHiDhyhKzTGGoALtXH+5lG1C6awEnxs4tQFWknavREitAt2hx5SgGk3uFy+dKogTTNvNbIpkRoUAaqqBN91kv+9SbAjfJC08My4ySWZT1EJw X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5696.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(1076003)(52116002)(6512007)(44832011)(4744005)(6666004)(54906003)(186003)(26005)(6506007)(2906002)(5660300002)(86362001)(16526019)(8676002)(66556008)(4326008)(36756003)(8936002)(6916009)(956004)(498600001)(66476007)(69590400008)(6486002)(2616005)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 9fHK4XrK/tty3V4KZCp6k+noMA+B/3xqBbkNeGtCXcejIjRz/yMdPpsw7xNsn4Pp2HVeG0nRscuAD5PoHfMnM3CrQD8d9m3iOLa5pe72nSgI8za9F4hTQCv7ths+5CXFWjCellzMpE7hs0xeA/M7+HwVrPODpzjahiQF93ZrpzDa+K1D7qLusRD62W+f3naIOvUJhifRqoxUG3bR8b77TAdwWZTA4jP7NFh6oHFyD+QefnJJp1VdJLy1qP4Ol0q4+87AKl8z/HXnZ5aZrrGLqDBUAPFhdsXug3g9Kj9ykgz/b5E90uHJVrgmwaaYcsPuYaZbWOFRSBiRl3q0Zc5ljQgx3oWxRB/BFRc34UzSs3N7TuR+Mphip4mV1L/kISu5Er9MdjzQ+LSqXlry9v3MKDSeWQACz76Jtubtpmh7PQdthlmIodrPriMYvBAIFgJVwo6u4u7N76x2EMDR1VyKDux76j8afFzV5012Iqvoj9lbDiO3PPZ1x5unbHxXnmFVJFzMNHo7ixPSzjlDVO9Bvr1EwUSnlbsl+HvOHdT4WuvHKngr4kkJRPmqfkGj30rdlNJA0DG7iaojLNNu1Gvf80bdZMF0ZC9atkDsItg5Ahj5ufqi/8fDTq+wMflkqq4HQ82foNS5T59h0F0D2625SYTsNR/8gOiB60nx8MApwqU3x58DDFE825clbQzAevcV8FhSJy0VZYM1qKn7LYJKb3bBCxXkmPO8blqchoY9X8wjlNZSlPEdIs6BfvoKsansY+BBF3Oa2dFdGqWm7lNDFTFr+9/lyGVbnlN6f8CDmvSaocWmu/Cq5Iy4aYhVYnkJrcLDfjd/nOFmYKe5MaoEwn60+O47MuqkMr9g+Tx6SqQhWTVPiWHPxeAp2fJlLlMQEL3Iu/sHqiH/eRWIo68R8XvViYbS2nQXMmGRHDlisoQPXFepDkg9wWbaCJocYEeRA0Cx4kBBR/BlEPW36nphNuCzxVbHQe31hfz4dkEMmSaGwOLzZsyQ2ZMldIVzOgxd X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d1fffa9e-ad94-4d9e-80f2-08d89b720164 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5696.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2020 12:08:42.7784 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Qm2ASgYJZqg7tKeGC112WDU4LU1nF1cyQ1SXLnriGVw/LJT4T22lJLKdxJPJVDi5oCWy7v+I46U+hrJRbMfQyA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5853 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC For preallocation purposes, we need to specify the maximum number of individual bonding/team devices that we can offload, which in our case is equal to the number of physical interfaces. Signed-off-by: Vladimir Oltean --- drivers/net/dsa/ocelot/felix.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index 53ed182fac12..ad73aaa4457c 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -653,6 +653,7 @@ static int felix_setup(struct dsa_switch *ds) ds->mtu_enforcement_ingress = true; ds->configure_vlan_while_not_filtering = true; + ds->num_lags = ds->num_ports; return 0; }