From patchwork Mon Jul 26 16:55:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 486190 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 CA0A9C4338F for ; Mon, 26 Jul 2021 16:58:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AF2C160E08 for ; Mon, 26 Jul 2021 16:58:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233113AbhGZQSB (ORCPT ); Mon, 26 Jul 2021 12:18:01 -0400 Received: from mail-eopbgr00065.outbound.protection.outlook.com ([40.107.0.65]:22840 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S241196AbhGZQPk (ORCPT ); Mon, 26 Jul 2021 12:15:40 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kxaHPcMzjNWpd7jP3GmqEr8nnfAq0nMTNhG/r7sAC3rG9jD3QPb3w6I+LxF8+vPvxZkhFN9HKm2WvB93NcgU7zGiyAK4BSa4aXf3cFeAv4JYzY5NF3LIBmT9Uth76TfFFGrOyeJXEE+MIF1dob0AgELjtXfWE6ZTAHZT1ooMJaj3xtLhSr0yjqjSAwpQrb1k6fTgg1BFGrsjOPU+y6FqECp4vnpaFwnpl6TTZmoKAxxxq5NouOZJWpJhYTgqrI2YKeBt2Ym3gHGTjM5NKyvVd75J8MnkC82RvsdhSpCA3SWm/qdi03ebuCNShkZ/xx0gAquuqNRGRWjCyeFqYR/pjw== 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=O+H/gpV6Kl/UMoP4E5sDMwPZ8hUHIbCfSKLMgU4eMM4=; b=iXJJSIH2MQcKHuPx/FR7YaTYr9Ol2/Rb/XI9b3nJ81d7n27m6EUiDV+YC5qITLPhY04rhBeF7nHgDPUEA8eMbfjlEPCsZo5Ex8hHKabkLe4hP22ZuOiNAo1sWwLd1NpvawtGHmZtOEnfXeIJEN4gwtOncrQXNtlSY2xauLt+VqYcvxoVUA6ePutusebc3ELPw54L/h1uMaTX/nqZdN7n6Nftr5yMOt0g9vGJ2rWw0/82fvlPvAnPG5TCZP/bMEdoTQg+8qqIgoTzVJSGt3374CyCbFiPcahfveEqIyF7MxKCPLusoeGhv56AVUiGddtMf36/GhDl9d0cdo8VUi/7PQ== 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=O+H/gpV6Kl/UMoP4E5sDMwPZ8hUHIbCfSKLMgU4eMM4=; b=LQxGLPFn7PTjxQ2eJINSKd8HVBG2kGM0ctVkB0BeFkDvXJ/ZuYLx4Fc4ZBzl41KNy4SdW+oXsF3IW8MVGuldLuNxuDx5h2crSLbDv5FL05sWjX0wHHamqa4b5W+8ppWP3yziPaZuHWf7YhsyG5GETbHy1JS33rlb4SJIB3rEnZc= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VE1PR04MB7328.eurprd04.prod.outlook.com (2603:10a6:800:1a5::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.25; Mon, 26 Jul 2021 16:56:00 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0%2]) with mapi id 15.20.4352.031; Mon, 26 Jul 2021 16:56:00 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Florian Fainelli , Andrew Lunn , Vivien Didelot , Roopa Prabhu , Nikolay Aleksandrov , Ido Schimmel , Jiri Pirko Subject: [PATCH net-next 1/9] net: bridge: update BROPT_VLAN_ENABLED before notifying switchdev in br_vlan_filter_toggle Date: Mon, 26 Jul 2021 19:55:28 +0300 Message-Id: <20210726165536.1338471-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210726165536.1338471-1-vladimir.oltean@nxp.com> References: <20210726165536.1338471-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR05CA0078.eurprd05.prod.outlook.com (2603:10a6:208:136::18) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (82.76.66.29) by AM0PR05CA0078.eurprd05.prod.outlook.com (2603:10a6:208:136::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.26 via Frontend Transport; Mon, 26 Jul 2021 16:55:58 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6c20b94a-fd8d-461a-864d-08d950563e71 X-MS-TrafficTypeDiagnostic: VE1PR04MB7328: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: quVwtkSCw71PcEGTCV8Y/HpZQL3rYeT8vGnd1CRrFE/qxOV4EOCrJ1vrfiY6OITlPZQytw2RFpt7wpFbBdh7+Eu3Wl2XoJm0BiNfKP555GCluleAuXe1+coC7ygKrgWsJKhNuNjbBHmgJNJiVFmKjhYPrXTKn5tl4+AP6RUnyZ9aQ1n6iCROHexCd0Fe5BjHBfxp1Ej6b3jJe3mUZ84ChGPqn9toB4avSv6JBixt8GuHMCxf/il66RlhMMX++8NQSXx4ptZUd40jHTZa9Dt2Jj+GttFc+Hlr7opZE/hkSkrYPM9xUH6KDVynYRVgsLF+3mgKxGjKNBVdlh9tAVMzhmuUK/siKTK1Fz33bLDVP42Lj2+qOOasladXmgYhOSro4vDC8bSUaK/h0HZkoq+RRCmI5HH6hJRix9PiqEGNNgYzqPxAlCBV0EK8g7StMac51WM36BQKi7XUnbDfG1VZK8cmnVe/j+ZI64zJ3SAeaaT/ZRWiBDLClsCafd2S0amlshm+uL7Hiy4PGcM6qNCkW6j04VVgrfztGIXSw9mdG+xDg3R7vfNOoKtNLXuqRpU6PdilUw0Kk2adnpLaczthw/ankNHlyNjuzA8HmNOktto9CoDftAQo0Od53ZH0xLE/ntoY0mK4zpJox/hCm8taJUMfSmORW/kGsbf5Gbb0zZuJV0PQXXm0bWrHfZ3GT4BDwOcwj9Q4ae1GFTutB8RtXLj38KH+2UaQ1pd/9HTe++g= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5136.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(39850400004)(136003)(346002)(366004)(36756003)(38350700002)(38100700002)(83380400001)(478600001)(44832011)(956004)(6666004)(86362001)(2616005)(2906002)(52116002)(8676002)(8936002)(7416002)(66556008)(5660300002)(66946007)(54906003)(110136005)(66476007)(316002)(26005)(6512007)(6506007)(186003)(1076003)(4326008)(6486002)(309714004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: di8c6eF+TPnb7FFet7If1WUMSAujzXD0D7fW06rus4l4UxfmRYWy3hUHRVyXMXaVMHyBOU9whkuunER5wQYiDbymjcYVicIX2JLs0pLHSPpbvCklRp/p/zIfs0agCuecc/rpvmt45CHBwNEtGca63JQddHeWDp0EkC5jfHD6PzXlipu89da/pZi+zz8FnuszarpQl3qKU4pnDMKq4vhmAl4E9SRSbXQ4oKGwYzbglgRChGJM3WmIBjcNPLh/yEL1oQ0soN1tx+jp4mi1Cs5vYda+UNNawUjrv/Mw4HN5Bm9PePzk2oZFX/XfHpYU2kMn3Q/sCX7K4LdIbLU9aDDFXY1yykPXDpEa5r23QkECf9Un9/EXoad4qTUsJB0c+/QBv/FZGa+TLFwm1cPgjhJxu/MUTCcL+rg3W/xibr3Ee9hyuR6u+HechLK4WIgV38SsUaktiBSKM2i47ET8Ry/OtfcXdhlMeMwtIuj32hpwkyg3ey1P1ooPDJ3cPIo2o67bbm/ELNyhFbAD1yxTPiL4yaVg+G7yG8/5YEIsTXG9z5fWW7CYryLsAt4zwMA92BHpeydizqNGx0hBG4psuB/9zZ1ExhtNRoKlXKNrZSrNbtU46mbcQZl9O5XxOlfzUqLEbtv895DBCU0P1Dg0c5nPiV6y0SmxWSiEXp21sRSApTVz1WP0ptlAd1mlUhCqY2x+em6mUqFXjMR9tp7B907CTZv4bPWRRK6QBZQI/+c/d4TZ94GD18BYNOULGRxKJBGUro/wbtdFULREA0IbCOcSNdBvhJTWrtxY4ZL+gx7H1fu/7Ze2PZfsIWBJvQAY3KTo9PLYVS+PlwIwE06SkP9uX6MyvATBmgN3cx1f/ayQAyUEWnvxkl40SWNsvJYdDxqqlxMnHnJm1T07NZWz45i51vmtztDz3IgHeI3ltNWklYpTy8lqbZRFkB1jfpRXESon94hzO4Is5Kt1kqVxNjW9EyEePHueEPVSLaVuzrBiCObPeosMres8IKWuybR47WjFbpLCXbpUikW8QyMx/KGq4t/N5wtjnRlibyCFOMhmiwrg4ZzgLoditGjeIgA+RAy0TNloeAqqYnDJgr0awpGRTzzFXD2N8bv7Fho68SxHrYkgYqKOoR3AN+kXm2Suw0v7H/7Vn23z0pKnHXphB46yWWPd3Yzs9GDAldnsZIlJNXVPp+DXQya4psgtFbpYVBGA74zX/sFq878yOijbdRjiudNki6pa5eswDLaGpg2GzpF3KOaG1auwOEnz3xHxWm4LhAOFOnR9b7yr7owNCvggGVjz2CHG+770wP/r1b7zaIzpQRA9AHEdynIG9ZFnr4x6 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6c20b94a-fd8d-461a-864d-08d950563e71 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jul 2021 16:55:59.6751 (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: cVzjs8NX5jLPttgCqSUou9+q0vQCxTu2aH81EVPkStYVkPgZA4wKloIjwvaQtZ6RU+bbwgnEjagXRF70SrHCvA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7328 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING is notified by the bridge from two places: - nbp_vlan_init(), during bridge port creation - br_vlan_filter_toggle(), during a netlink/sysfs/ioctl change requested by user space If a switchdev driver uses br_vlan_enabled(br_dev) inside its handler for the SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING attribute notifier, different things will be seen depending on whether the bridge calls from the first path or the second: - in nbp_vlan_init(), br_vlan_enabled() reflects the current state of the bridge - in br_vlan_filter_toggle(), br_vlan_enabled() reflects the past state of the bridge This can lead in some cases to complications in driver implementation, which can be avoided if these could reliably use br_vlan_enabled(). Nothing seems to depend on this behavior, and it seems overall more straightforward for br_vlan_enabled() to return the proper value even during the SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING notifier, so temporarily enable the bridge option, then revert it if the switchdev notifier failed. Cc: Roopa Prabhu Cc: Nikolay Aleksandrov Cc: Ido Schimmel Cc: Jiri Pirko Signed-off-by: Vladimir Oltean --- net/bridge/br_vlan.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c index 325600361487..805206f31795 100644 --- a/net/bridge/br_vlan.c +++ b/net/bridge/br_vlan.c @@ -840,11 +840,14 @@ int br_vlan_filter_toggle(struct net_bridge *br, unsigned long val, if (br_opt_get(br, BROPT_VLAN_ENABLED) == !!val) return 0; + br_opt_toggle(br, BROPT_VLAN_ENABLED, !!val); + err = switchdev_port_attr_set(br->dev, &attr, extack); - if (err && err != -EOPNOTSUPP) + if (err && err != -EOPNOTSUPP) { + br_opt_toggle(br, BROPT_VLAN_ENABLED, !val); return err; + } - br_opt_toggle(br, BROPT_VLAN_ENABLED, !!val); br_manage_promisc(br); recalculate_group_addr(br); br_recalculate_fwd_mask(br); From patchwork Mon Jul 26 16:55:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 486181 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 3343DC4338F for ; Mon, 26 Jul 2021 17:00:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1681060F57 for ; Mon, 26 Jul 2021 17:00:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235671AbhGZQT4 (ORCPT ); Mon, 26 Jul 2021 12:19:56 -0400 Received: from mail-eopbgr150077.outbound.protection.outlook.com ([40.107.15.77]:42242 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S242038AbhGZQQ6 (ORCPT ); Mon, 26 Jul 2021 12:16:58 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Hm1XqWxYjpGvx1sbKbl6YDC5hO8Wro8ccPMoZKuDakUO1P9jRatbWoqelGRdXrKtnlCLmCht6Fa4eLbFfpC40Hfnx9FxdI8gnPGDTtWYMSlWUHH8YOfO5Xe91xEDT1CkxVAIoILg3XXe0FtBo2+3dHwBw5djHHFcJGwlaHWOGq62fv43Rf74loIEHwbMMs0K0EoHXpCBbUHv8fHcJaztEuo0+IrN9ENlWU7GfOPX37YVPdrKfghPbKRNPQwY8zLDXSqqcA5AEGcDIvS2VQQrMbW7GjDup6UQKQfmJVTxwgQNqz6aSGYufIVvtHTzWfF041sI14SuhxW5sRlDSfpjqg== 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=6luHFJoDp3oT1b1WOGU7ERfpGkWlcbXSMyTT640UT24=; b=hN77uC7PEd8/aseh+cD96Sr1EN0v2bToDtmf1qcxdjJmdDRiamopzPp8OKn8kKYXp1nJcaYZHX7I60JZBMAn/+J2bSLzvsXgtN27h10h2T29pawjSVJPjzVD+KdvAjJR+9lNl5laywi8gKzYz8mnCKVP3lUytmEMiXG/Y/LXdyKxkpyGcxaqIux10AUIxt4J2GBud8P+eHqjdOwVZpxa62ROWGPYdfs9hQbf/+l67mRwPdhaovyufgZ+v7aIBg7IWs+GwAO+46E8/NM7almHBrkAU8//REj9E8rMzV08TyG79/vLc29BrrEXX0yveMcSUZq87xeWlPbchWo1XnnsZQ== 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=6luHFJoDp3oT1b1WOGU7ERfpGkWlcbXSMyTT640UT24=; b=cjc/Eb19ym7c2irCwJZBgcNfG3ow/kGg+JNnBETOJ8E90Np1TYGo5nfiDFE4kfgx13Iqyn3oM8QlVaWM9YDk10Ydr6slQeJ04K8ll/GM6KFV6wuQDQYWC3+gphFngnYcA3ig58xFt6/W4BsUE8rLbSF7CfvcV9shqrzfJEPepyM= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VE1PR04MB7328.eurprd04.prod.outlook.com (2603:10a6:800:1a5::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.25; Mon, 26 Jul 2021 16:56:04 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0%2]) with mapi id 15.20.4352.031; Mon, 26 Jul 2021 16:56:04 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Florian Fainelli , Andrew Lunn , Vivien Didelot Subject: [PATCH net-next 6/9] net: dsa: sja1105: deny more than one VLAN-aware bridge Date: Mon, 26 Jul 2021 19:55:33 +0300 Message-Id: <20210726165536.1338471-7-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210726165536.1338471-1-vladimir.oltean@nxp.com> References: <20210726165536.1338471-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR05CA0078.eurprd05.prod.outlook.com (2603:10a6:208:136::18) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (82.76.66.29) by AM0PR05CA0078.eurprd05.prod.outlook.com (2603:10a6:208:136::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.26 via Frontend Transport; Mon, 26 Jul 2021 16:56:04 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ff9d4531-8cb9-46a4-3e15-08d95056417f X-MS-TrafficTypeDiagnostic: VE1PR04MB7328: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HcyuOy6BufWe11b0159Z+9yzwXyKakZxcTG5Fr/0CuqQEuh6ATLMqGx4Sm1kDZkBDdfRQ19e7rvZQy13qHlLcJL8IYAl99kTtBVaQTYKKRTPWdbVcvC3zrw4QKoNG/hohV3G8f7B7KTMjW55L6CrJaXQnesD1Aw0K8cEIxn3nWSHPcEA7q/hfgmW89e+7B1+1Ufyz2xmBuVXE+RIOBmeXIx/w8gKYlmRFxxEYb6nqAZRk+ArIqHEmV3oNnTsx8Z6M9GMJ4aWnjSXKeWZuCFfanG4JOy/RBAKfVdqMSwCQ2sWUBPB1m0H7+L2py/rgIVTeAB4ZLAQXcX6fnr92ZG74F8XT4M2vsFQrZBZQtbMZqDTQ6uqGlCqQ6AJR6Kir3f7YxRvcvi/+bU0kXOIDhn+1dB+NO3WB+R6LDIgxm+WY5z3QEJuNsnR0N3G+NiVOjCNMPVt7mkYn4eAodws8X3q2HOZj2iAvfN8/j8JaSpSgx6o5ZBLS55LQR0tiH+ywWb57d52/0/VtCa44yzYWWOl3FK0CqQly7PKEf6han8cW30OuyaPtGCMTNUVz1hjCOHpOY38ixMn1GxE9MDQraGd0IzctLbCPbRZm1P5cizHptm7MGSz/isSN7+Ni1PJXGWiq3uLq5HaTh3N7z0OK9a++pTYdrDEzrVw3KIqlR0oJgHq8tOpakuMhZgAxGrie4amISUPvDu1OOOkyz6KBuTMww== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5136.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(39850400004)(136003)(346002)(366004)(36756003)(38350700002)(38100700002)(83380400001)(478600001)(44832011)(956004)(6666004)(86362001)(2616005)(2906002)(52116002)(8676002)(8936002)(66556008)(5660300002)(66946007)(54906003)(110136005)(66476007)(316002)(26005)(6512007)(6506007)(186003)(1076003)(4326008)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SjAkCcIzoQsCaooGyqZgGU0Yycj02FQnmxacjvcCQMdsTUuYTe4HTXVzhfD/zA1FTHLlXBeGaeLqj1ML2DLZROp3KG3Yru9r65LN8D4KR9xFcPNWwU99LSUu0pD7PCNJzlYiI9VOKzuZpqM2eKAaKNrrLlkdwHVAldoGsxbFIpBwqNu8UhXuFO57U83GhFXt6C7ryAwAJ06KbPOeu8GRTzfbIh68dsCD5kVZJcGCl7q03pLg3JC3qrhJnAudaYJ1UaM4yJhO61Ywc0sjzdnty74+Y2kuFRfobyn0zRYca6yPEzkiK4Fe8Y6rkTYmahXYJn8MF/Gvu6AAzslUcLmcbJrT1ntNlYi92VkhhIn7yGEnQY7Ug4H2Z81I2XmKOImHGxA05InoGtWHKBUolXVEKyX53nvMgVy1qtD1suLl+0bPys085D2YTzToGGRwlRkQXjlvVGK4AGtSPgr/zn+X5BTcr3AooESc5CgxSeN7typHk/p2w1d/fpWWsgTLoXmTwnCVrT1JxFBlCIYWJ7FXUywmW8GK8vB05M6GkxjAq93zU/+VqZxnI1MMH0qTcnJz8cC3bqHFo/ggX/s8q6wyqDxOq5dSbEjPrQ/Cdit1tnLw9+pYOp0YsGri4i0mro1y4mmjyN8i5LS0FUxUEyGyWW6dVx5H+gr+qnd5DbTD6lkqxhczYd6GJ4cdG2bv50OX79g0E69Q3oHqbgauKbqLb1usoB6aMe3TRz6I7m5EfIdPg7ifM9yn42yuAIupaD6CtPKaGgF4tUFJSYwIzqICd4sLW2yCL6XLZjJ4u3pAb0iL4dGRjOTMHI6pzmqQJYDa4n2/zfXxyLUiXGMQizfriicxq6Urt2ZEpln0fDC+d5rGyngzTw8Zaz7S01PTIxzOIQLGYIlGD3rBta48h6N89CxRuTh/DGu2ywQ0uKw3lxnxeqDaItzwO8OfCdy3JuWqBhBghWlsSLmsAhU8Z3gX6/xEKbv/y0R+SKlcPsSWX/tHEiTFMjRtOZfrvSoYCGPMtThzkz3t7uHCZgYjUY70l+701cDby6rsT3Eqh1WRbKmH6OVT0MmpKPeN6O6qd79oKBA9g6gny3GUbSh1if/X8E4OtclNF6hDa45ZCuJt1exdM1VuddIef47rS65YJTuaIpNBearJpXNNXWtQvtFKs/Rc21xVXlo6ID/Q2zOrBZQY2kK6hFefqWaheOqP8ii6akeTHXDQcpr2kF0MEYQsoINt5U/HLNpt1umH+vRdJUeGzPw5A4T+A5f1D2YYSyGftAe4xF2R+tF4Qu6oZstbnzBhua+WljEj+MTTMZ8GXqlRbRNtC6hmlwgIZR60ewRV X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ff9d4531-8cb9-46a4-3e15-08d95056417f X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jul 2021 16:56:04.7722 (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: cIkGdA1IGusEiqWxjNyaZ3fDnTfN68PXTO3fyEmO32dyZlXI3m7t99mKDodGvEFg8qSEqOa6tPmCfqQbD6cC2Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7328 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org With tag_sja1105.c's only ability being to perform an imprecise RX procedure and identify whether a packet comes from a VLAN-aware bridge or not, we have no way to determine whether a packet with VLAN ID 5 comes from, say, br0 or br1. Actually we could, but it would mean that we need to restrict all VLANs from br0 to be different from all VLANs from br1, and this includes the default_pvid, which makes a setup with 2 VLAN-aware bridges highly imprectical. The fact of the matter is that this isn't even that big of a practical limitation, since even with a single VLAN-aware bridge we can pretty much enforce forwarding isolation based on the VLAN port membership. So in the end, tell the user that they need to model their setup using a single VLAN-aware bridge. Signed-off-by: Vladimir Oltean --- drivers/net/dsa/sja1105/sja1105_main.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index a380f37fd22d..ef63226fed2b 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -2257,12 +2257,25 @@ static int sja1105_prechangeupper(struct dsa_switch *ds, int port, { struct netlink_ext_ack *extack = info->info.extack; struct net_device *upper = info->upper_dev; + struct dsa_switch_tree *dst = ds->dst; + struct dsa_port *dp; if (is_vlan_dev(upper)) { NL_SET_ERR_MSG_MOD(extack, "8021q uppers are not supported"); return -EBUSY; } + if (netif_is_bridge_master(upper)) { + list_for_each_entry(dp, &dst->ports, list) { + if (dp->bridge_dev && dp->bridge_dev != upper && + br_vlan_enabled(dp->bridge_dev)) { + NL_SET_ERR_MSG_MOD(extack, + "Only one VLAN-aware bridge is supported"); + return -EBUSY; + } + } + } + return 0; } From patchwork Mon Jul 26 16:55:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 486180 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 ADD0CC4338F for ; Mon, 26 Jul 2021 17:00:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 84DBF60E08 for ; Mon, 26 Jul 2021 17:00:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237362AbhGZQUG (ORCPT ); Mon, 26 Jul 2021 12:20:06 -0400 Received: from mail-eopbgr00054.outbound.protection.outlook.com ([40.107.0.54]:5443 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235362AbhGZQRf (ORCPT ); Mon, 26 Jul 2021 12:17:35 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vn0nSFDtBVsRswhv2NKktfFbzqwo0wVtQQw0K2pmIXdLarNbaHu9tWq9JnfrlF2WmuuiZAx9s0s/o4Jy0ql4VGSJoIEQZffJZHHSl3VDgI5WYRMNsjqrEkoMiC8Xd3XYr/CyTlJSF0buTsyXa3sGMm24b08Wz5WdPvk71HBt9gU51dSDiOB6WTMOizKXZLEAAyOF64dm14AECZH4765sLGwagvg5w/giKIe64o+6VLATtLfyAzBW6Wiu00gez6KZTpGrIlRCIRR3U8IOKTVxf1j4RjQChK4aE1eiB+o2A87s3Egc4AvX38R0R2k1dNhwmVtxsrulCohDThiXr8z+Aw== 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=bgE7F7mCSpuKklzYDJmABGj3KAFByeZRY1ulcmGRyJM=; b=N8iMsb/4PBZYYGtZw1q7rqyLVCgEybLTiLw1udf2/+GkxF1nN6p0Z6G5bm8cIciYswr5NPbvu4QHouxbWfF490lb/FWyieG/4l/T3ZbAQwwH+vNVwxMG7p24FJ0EXhkhPgIHUeflUPdDaDYg7SR9Piv05R5N4GBouFt1PUg3QfyrgvbS0O7Y4kE6u3Up3tO9OM7ycpsMV9wbOCc5XnLqHGa6S+E09/JpiVlqp218T+SVU919QGmDFgsjFWkG+HNFyaFkFvOU3oK/IgIKzPKQaQzyZSMdd+UTWsU1ka5vRfr1WJDKT8I+EinqwZcxQxiaIAcyq+LzsBGoIItJWrDNSQ== 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=bgE7F7mCSpuKklzYDJmABGj3KAFByeZRY1ulcmGRyJM=; b=mkCmibZN6yetav9f2GExo9jUOOj/OweYI/SUem9Hofk4rxnW0QIWzeY8AFOXGhqilqmanKkxOau7xDfftXWaHVRGzqAlaUAGjQO267LoRUdMMfT8yz0OZ6v8vntThSQyTK2QbB+EiF0KPPr39yJdrcvO6LbwV8KYQS9mEP2rdCk= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VE1PR04MB7328.eurprd04.prod.outlook.com (2603:10a6:800:1a5::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.25; Mon, 26 Jul 2021 16:56:06 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::109:1995:3e6b:5bd0%2]) with mapi id 15.20.4352.031; Mon, 26 Jul 2021 16:56:06 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" Cc: Florian Fainelli , Andrew Lunn , Vivien Didelot Subject: [PATCH net-next 8/9] net: dsa: sja1105: add bridge TX data plane offload based on tag_8021q Date: Mon, 26 Jul 2021 19:55:35 +0300 Message-Id: <20210726165536.1338471-9-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210726165536.1338471-1-vladimir.oltean@nxp.com> References: <20210726165536.1338471-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR05CA0078.eurprd05.prod.outlook.com (2603:10a6:208:136::18) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (82.76.66.29) by AM0PR05CA0078.eurprd05.prod.outlook.com (2603:10a6:208:136::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.26 via Frontend Transport; Mon, 26 Jul 2021 16:56:05 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b79a27f5-e0d9-4304-6bcb-08d950564293 X-MS-TrafficTypeDiagnostic: VE1PR04MB7328: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SMzQzbBr9V98fdVulHCEYOU4o9QLpawO0Y8eS7eX8gV+dffbGvzRhiVTM1W7uxe9TS07S9385QEeNd/Th7+GcSkdvumGiKD7Zw0BTzdrcbHKSmMd6baP/jcQf+FLICB/Gr3bQXiS96Pik+IdDzmJQDDf/Cb84AbgXh+ro3pGQmXlydZ1W7qfYsXBKey3EvYIM05aUys1ztLA1v1GZD6bkr4UCQfdmSpnjQFwBKvcniT0R02UOFuQgBYshl2QhlwtaHNy6DoxIF0KJAjgONm7iT6Ou0kvi+eksNQC9xi8qgsHut9+HcdtWSIrxWxCVdraLESXhLw8zDEfeZMwLKqQXHTfrvvlFIYUFzUhC8w/ffN/1FxzxaPsa5S+H80yrjDJBSb3b+yMxJPD2XtQ4kSAf1S/vlhO7FDKwC3v3suIrR6fjyHfLvezHK6oEsXDpv4vT5U6CXsgBSvPJCC75kJuKn7nziPSV5QIlgycP4esSaV3ZsHkJOz7LbfGhBIrF6c3zx/1uDYIvuWPgHYiFJ6Maq+9TsrcVjw7o+1IvChvj+v+qk9txA+MlC/yedbtel7LwcvpfBzJ+twaXvRRhUVzDD8Bqocu8oTBAXJf/So/07x1jCKOUOoAWaKYOMog8WEKu8Z/yVyK534F0bjuPZTd6DXCvOZK5LScvnDoZsYT+LLd0LNqYxUaCWCjlWr1ltsutWEVEQp9GCZwAvZ96wTXcg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5136.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(39850400004)(136003)(346002)(366004)(36756003)(38350700002)(38100700002)(83380400001)(478600001)(44832011)(956004)(6666004)(86362001)(2616005)(2906002)(52116002)(8676002)(8936002)(66556008)(5660300002)(66946007)(54906003)(110136005)(66476007)(316002)(26005)(6512007)(6506007)(186003)(1076003)(4326008)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LpVeBHO+syCAwHKJKLFiDw4bLNsF0ZiIa+Y37BG5mKQOQDUxHEoQbu7ToT9HrlokL3OIHXrEldpXk3Jz3OnBygSUpxbj1O9vuyNDY1WA5v6lX1Fy4a9tJScF7IevUEt2QGety+LqBKu45327Ct1PqmpjY9iPa7hxo0LF0EQZIVW14mFXibb9Sxs1IGknrODW0eYTjy3TOoWeA0yRUAiw21cvgs4jikuimSyEtTHFUr8kU4bTYG9VFT0S3VCmfaDIArAvMJi8lUj+XDmjTM7dGGMRCG8OfX4W2z8bYvhiGYqR+SKeg974ObqKnwP53xDkS4hom15awy2cvpOBxNeogBeppzP20aWlcKDZDyBkBqvYYo3OCjnzLqA1ahtcUSEVU7Z/1kotil+SX0tbi/KxsE/i0qkT60Mos+WI8Mpedh4cM1/xkWkoXR2WSBpPuKUIbnCa9gmhzfi4hBr9Dzk7lUwLJKTH8nuwQS5atjvstrffA+yPRMwnGSIVCLHkt+3OaiR4GcE/Lm4kISBNcICl1EY22gCPWIUZrnMHB9U3Fgc6z6HJefV1hp0JmfHj8yh8lgFQugQHZ6VQsib7c6KNVaHV5kS6iZ5QR2x2/0AWiFLVx49pS51B6rjNoDEhsT2n7pXxiNvlgkY7DKDMD/uSfeqXhAC5D/iaKjZA44D7zu81+zmYIFQ2chy409VPXkdMMWMQOAYvGYoPtaURgHJ96LBgc6K0VXSRijvBc4jygVyU0xXQYhMRWKCfeG40dpiG87GaaNt9FUNfFeFb2OrtjXGJuF3FeRjJhM87HIyCuo5qGjDtpDHbFnLBi+xhG2a6ERGkEP8aZxWonQpMPdP96kZgv6hEuXM9De8vH/T4HZN9H/mxAuA6xBTTU0vVvp/dhRFkzbinb/W7jICqIziXfUoL/K4/rMhSVK4yvjdlJ9/qW7OPaOuekMcpD+3uqyCdIwer/x1x/wasnHox22g6iv5lPpmCIAv0Jg7iBIGjATgXoi2k0HMEuVNwNzoM4n3hn/IVjSJ2Ed+mX2xRPTTqByKlEjlG1ZnCmTEGyFlnUmqnsQI+WlUaac1HZ6Xn7f/rG4NZINYERDSsJr0huHiiA7lEIF9K3NibYJQeHXcr6SuQCaAaOLVbcCuG7hVJOqfMrvA2d1PQp2lkrPeLUvf+lyYnpvlWJ69mjreDjVbtgQWwnLuk5o0NwaCmJCZI+VuO5HMjwGS9z/wogzCaTmGfFoxuNyT9zptkFw1yEhjZbaJnjLNPprzsh/ugDFCWE8XAzycGUcpR7bpaiqq3ZLsjj1DdF8bc9JyVys6zZ9suwhTQv1PwJ8aJtpfDNpBLjkqS X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b79a27f5-e0d9-4304-6bcb-08d950564293 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jul 2021 16:56:06.5931 (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: YNxfqq6qj3oYzfA4SD3tlae6wZ/wj1+9u2dW8zKhvfOUENyJA28ERJpl5YJtH+iKLKfTUDpnoPNLAbkocs+M+w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7328 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The main desire for having this feature in sja1105 is to support network stack termination for traffic coming from a VLAN-aware bridge. For sja1105, offloading the bridge data plane means sending packets as-is, with the proper VLAN tag, to the chip. The chip will look up its FDB and forward them to the correct destination port. But we support bridge data plane offload even for VLAN-unaware bridges, and the implementation there is different. In fact, VLAN-unaware bridging is governed by tag_8021q, so it makes sense to have the .bridge_fwd_offload_add() implementation fully within tag_8021q. The key difference is that we only support 1 VLAN-aware bridge, but we support multiple VLAN-unaware bridges. So we need to make sure that the forwarding domain is not crossed by packets injected from the stack. For this, we introduce the concept of a tag_8021q TX VLAN for bridge forwarding offload. As opposed to the regular TX VLANs which contain only 2 ports (the user port and the CPU port), a bridge data plane TX VLAN is "multicast" (or "imprecise"): it contains all the ports that are part of a certain bridge, and the hardware will select where the packet goes within this "imprecise" forwarding domain. Each VLAN-unaware bridge has its own "imprecise" TX VLAN, so we make use of the unique "bridge_num" provided by DSA for the data plane offload. We use the same 3 bits from the tag_8021q VLAN ID format to encode this bridge number. Note that these 3 bit positions have been used before for sub-VLANs in best-effort VLAN filtering mode. The difference is that for best-effort, the sub-VLANs were only valid on RX (and it was documented that the sub-VLAN field needed to be transmitted as zero). Whereas for the bridge data plane offload, these 3 bits are only valid on TX. Signed-off-by: Vladimir Oltean --- drivers/net/dsa/sja1105/sja1105_main.c | 4 +++ include/linux/dsa/8021q.h | 10 ++++++ net/dsa/tag_8021q.c | 48 +++++++++++++++++++++++--- net/dsa/tag_sja1105.c | 31 +++++++++++++++++ 4 files changed, 89 insertions(+), 4 deletions(-) diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index a6a671f0fca5..da042e211dda 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -2367,6 +2367,8 @@ static int sja1105_setup(struct dsa_switch *ds) */ ds->vlan_filtering_is_global = true; ds->untag_bridge_pvid = true; + /* tag_8021q has 3 bits for the VBID, and the value 0 is reserved */ + ds->num_fwd_offloading_bridges = 7; /* Advertise the 8 egress queues */ ds->num_tx_queues = SJA1105_NUM_TC; @@ -2880,6 +2882,8 @@ static const struct dsa_switch_ops sja1105_switch_ops = { .tag_8021q_vlan_add = sja1105_dsa_8021q_vlan_add, .tag_8021q_vlan_del = sja1105_dsa_8021q_vlan_del, .port_prechangeupper = sja1105_prechangeupper, + .port_bridge_tx_fwd_offload = dsa_tag_8021q_bridge_tx_fwd_offload, + .port_bridge_tx_fwd_unoffload = dsa_tag_8021q_bridge_tx_fwd_unoffload, }; static const struct of_device_id sja1105_dt_ids[]; diff --git a/include/linux/dsa/8021q.h b/include/linux/dsa/8021q.h index ec5abfcdefd1..c7fa4a3498fe 100644 --- a/include/linux/dsa/8021q.h +++ b/include/linux/dsa/8021q.h @@ -35,6 +35,16 @@ struct sk_buff *dsa_8021q_xmit(struct sk_buff *skb, struct net_device *netdev, void dsa_8021q_rcv(struct sk_buff *skb, int *source_port, int *switch_id); +int dsa_tag_8021q_bridge_tx_fwd_offload(struct dsa_switch *ds, int port, + struct net_device *br, + int bridge_num); + +void dsa_tag_8021q_bridge_tx_fwd_unoffload(struct dsa_switch *ds, int port, + struct net_device *br, + int bridge_num); + +u16 dsa_8021q_bridge_tx_fwd_offload_vid(int bridge_num); + u16 dsa_8021q_tx_vid(struct dsa_switch *ds, int port); u16 dsa_8021q_rx_vid(struct dsa_switch *ds, int port); diff --git a/net/dsa/tag_8021q.c b/net/dsa/tag_8021q.c index 51dcde7db26b..654697ebb6f3 100644 --- a/net/dsa/tag_8021q.c +++ b/net/dsa/tag_8021q.c @@ -17,7 +17,7 @@ * * | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | * +-----------+-----+-----------------+-----------+-----------------------+ - * | DIR | RSV | SWITCH_ID | RSV | PORT | + * | DIR | VBID| SWITCH_ID | VBID | PORT | * +-----------+-----+-----------------+-----------+-----------------------+ * * DIR - VID[11:10]: @@ -30,9 +30,10 @@ * SWITCH_ID - VID[8:6]: * Index of switch within DSA tree. Must be between 0 and 7. * - * RSV - VID[5:4]: - * To be used for further expansion of PORT or for other purposes. - * Must be transmitted as zero and ignored on receive. + * VBID - { VID[9], VID[5:4] }: + * Virtual bridge ID. If between 1 and 7, packet targets the broadcast + * domain of a bridge. If transmitted as zero, packet targets a single + * port. Field only valid on transmit, must be ignored on receive. * * PORT - VID[3:0]: * Index of switch port. Must be between 0 and 15. @@ -50,11 +51,30 @@ #define DSA_8021Q_SWITCH_ID(x) (((x) << DSA_8021Q_SWITCH_ID_SHIFT) & \ DSA_8021Q_SWITCH_ID_MASK) +#define DSA_8021Q_VBID_HI_SHIFT 9 +#define DSA_8021Q_VBID_HI_MASK GENMASK(9, 9) +#define DSA_8021Q_VBID_LO_SHIFT 4 +#define DSA_8021Q_VBID_LO_MASK GENMASK(5, 4) +#define DSA_8021Q_VBID_HI(x) (((x) & GENMASK(2, 2)) >> 2) +#define DSA_8021Q_VBID_LO(x) ((x) & GENMASK(1, 0)) +#define DSA_8021Q_VBID(x) \ + (((DSA_8021Q_VBID_LO(x) << DSA_8021Q_VBID_LO_SHIFT) & \ + DSA_8021Q_VBID_LO_MASK) | \ + ((DSA_8021Q_VBID_HI(x) << DSA_8021Q_VBID_HI_SHIFT) & \ + DSA_8021Q_VBID_HI_MASK)) + #define DSA_8021Q_PORT_SHIFT 0 #define DSA_8021Q_PORT_MASK GENMASK(3, 0) #define DSA_8021Q_PORT(x) (((x) << DSA_8021Q_PORT_SHIFT) & \ DSA_8021Q_PORT_MASK) +u16 dsa_8021q_bridge_tx_fwd_offload_vid(int bridge_num) +{ + /* The VBID value of 0 is reserved for precise TX */ + return DSA_8021Q_DIR_TX | DSA_8021Q_VBID(bridge_num + 1); +} +EXPORT_SYMBOL_GPL(dsa_8021q_bridge_tx_fwd_offload_vid); + /* Returns the VID to be inserted into the frame from xmit for switch steering * instructions on egress. Encodes switch ID and port ID. */ @@ -387,6 +407,26 @@ int dsa_tag_8021q_bridge_leave(struct dsa_switch *ds, return 0; } +int dsa_tag_8021q_bridge_tx_fwd_offload(struct dsa_switch *ds, int port, + struct net_device *br, + int bridge_num) +{ + u16 tx_vid = dsa_8021q_bridge_tx_fwd_offload_vid(bridge_num); + + return dsa_port_tag_8021q_vlan_add(dsa_to_port(ds, port), tx_vid); +} +EXPORT_SYMBOL_GPL(dsa_tag_8021q_bridge_tx_fwd_offload); + +void dsa_tag_8021q_bridge_tx_fwd_unoffload(struct dsa_switch *ds, int port, + struct net_device *br, + int bridge_num) +{ + u16 tx_vid = dsa_8021q_bridge_tx_fwd_offload_vid(bridge_num); + + dsa_port_tag_8021q_vlan_del(dsa_to_port(ds, port), tx_vid); +} +EXPORT_SYMBOL_GPL(dsa_tag_8021q_bridge_tx_fwd_unoffload); + /* Set up a port's tag_8021q RX and TX VLAN for standalone mode operation */ static int dsa_tag_8021q_port_setup(struct dsa_switch *ds, int port) { diff --git a/net/dsa/tag_sja1105.c b/net/dsa/tag_sja1105.c index f142a933c5e2..cddee4b499d8 100644 --- a/net/dsa/tag_sja1105.c +++ b/net/dsa/tag_sja1105.c @@ -133,6 +133,31 @@ static u16 sja1105_xmit_tpid(struct sja1105_port *sp) return sp->xmit_tpid; } +static struct sk_buff *sja1105_imprecise_xmit(struct sk_buff *skb, + struct net_device *netdev) +{ + struct dsa_port *dp = dsa_slave_to_port(netdev); + struct net_device *br = dp->bridge_dev; + u16 tx_vid; + + /* If the port is under a VLAN-aware bridge, just slide the + * VLAN-tagged packet into the FDB and hope for the best. + * This works because we support a single VLAN-aware bridge + * across the entire dst, and its VLANs cannot be shared with + * any standalone port. + */ + if (br_vlan_enabled(br)) + return skb; + + /* If the port is under a VLAN-unaware bridge, use an imprecise + * TX VLAN that targets the bridge's entire broadcast domain, + * instead of just the specific port. + */ + tx_vid = dsa_8021q_bridge_tx_fwd_offload_vid(dp->bridge_num); + + return dsa_8021q_xmit(skb, netdev, sja1105_xmit_tpid(dp->priv), tx_vid); +} + static struct sk_buff *sja1105_xmit(struct sk_buff *skb, struct net_device *netdev) { @@ -141,6 +166,9 @@ static struct sk_buff *sja1105_xmit(struct sk_buff *skb, u16 queue_mapping = skb_get_queue_mapping(skb); u8 pcp = netdev_txq_to_tc(netdev, queue_mapping); + if (skb->offload_fwd_mark) + return sja1105_imprecise_xmit(skb, netdev); + /* Transmitting management traffic does not rely upon switch tagging, * but instead SPI-installed management routes. Part 2 of this * is the .port_deferred_xmit driver callback. @@ -165,6 +193,9 @@ static struct sk_buff *sja1110_xmit(struct sk_buff *skb, __be16 *tx_header; int trailer_pos; + if (skb->offload_fwd_mark) + return sja1105_imprecise_xmit(skb, netdev); + /* Transmitting control packets is done using in-band control * extensions, while data packets are transmitted using * tag_8021q TX VLANs.