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: 340252 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 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: 340250 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 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: 340248 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 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: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: 340249 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 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: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: 340246 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 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: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: 340245 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 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: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: 340251 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 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