From patchwork Sat Oct 31 10:29:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 315920 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable 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 20AD9C5517A for ; Sat, 31 Oct 2020 10:30:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D59A02074F for ; Sat, 31 Oct 2020 10:30:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="CeXVvJfj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726812AbgJaK3n (ORCPT ); Sat, 31 Oct 2020 06:29:43 -0400 Received: from mail-am6eur05on2083.outbound.protection.outlook.com ([40.107.22.83]:28640 "EHLO EUR05-AM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726753AbgJaK3i (ORCPT ); Sat, 31 Oct 2020 06:29:38 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JIbMlOt83zHd/qcWAihWmUzqG+lKmf1WB4XnrYpud+ysqcdEmvh0ZoE/8cQtD4XXxO/Kg/UXRaPEfHaZXwjVUKJ1bv8QoaHFCYa/Bm4zp1N3Anpdo67ZgY/e6p5O0X7hHRZ6BXJsyczRiovOShJbmGUVe84HyzBCSAJ8Z4pqIEGmgdjxAA9Rrvwjps6yE59cyUbe8CnTXvGoAh0rAuyg7a1QNT768kwtIZZtGvfi1xBKuj+mgYfryxG0ZqXUOFeZ1pwBipDmWIIF3Cjq22DwllJrRdLuVuWdnR+e4zhKuYcn5M21hW5FOu4CzWN/Jz24hp0q2GePU+LRmUcXLGXDQg== 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=EfZn2CdJleb1VrEeWX7DxsdfPbGgOUM7dYtYsf1PVIc=; b=OERMC4Q5ZeFTeYsRl7l6YplgUGiKIrkNROCBp21p8nFv0H9BfoipWr4BhM0vVn8Zi4RLDJ8Y/TAPV8JT+n5hilOaFQgJXicu7TBIjZ8zFCzy9nMA1SxFFUvJoUg9Px7954EdYEvwq8VkJ8h70CcpotfjfZYk2vX2HfpL+svVNvykXaq2FxrVZGbqDFt3x4xPLLU7Yf7e7+vI0eMmdLlK0KFuTZZuDXyPthjnAal7iN7lHjeiF1a5D8VsGD0JHzDQhOVHsF0nMM2Oh5wDPDoGmGX9Q+wU0JTpX3JjiiliMv/yCkDyopwvAYfHNCz+yG3SGiF3/QAGFP1uunDn7KH2FA== 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=EfZn2CdJleb1VrEeWX7DxsdfPbGgOUM7dYtYsf1PVIc=; b=CeXVvJfjsy6bhoAPKNpdeyhZuy/MV4t/1WuKdWwh70B5KoLaA15fzHvMYvVT1+bk93i8avLKEOXeaSSlnvVEOHSrmpdnAUy910HxI6Na2DWB7v31UlK+/tV8cUaA5nNxPypnsSCtMLw9UJFOWDXPj06FT7zAJ7EInUdqxJQ8QPs= Authentication-Results: microchip.com; dkim=none (message not signed) header.d=none; microchip.com; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) by VE1PR04MB6637.eurprd04.prod.outlook.com (2603:10a6:803:126::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.27; Sat, 31 Oct 2020 10:29:28 +0000 Received: from VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::983b:73a7:cc93:e63d]) by VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::983b:73a7:cc93:e63d%3]) with mapi id 15.20.3499.029; Sat, 31 Oct 2020 10:29:28 +0000 From: Vladimir Oltean To: Microchip Linux Driver Support , Claudiu Manoil , Alexandre Belloni , Andrew Lunn , Vivien Didelot , Florian Fainelli , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 2/7] net: mscc: ocelot: don't reset the pvid to 0 when deleting it Date: Sat, 31 Oct 2020 12:29:11 +0200 Message-Id: <20201031102916.667619-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201031102916.667619-1-vladimir.oltean@nxp.com> References: <20201031102916.667619-1-vladimir.oltean@nxp.com> X-Originating-IP: [188.25.2.177] X-ClientProxiedBy: VI1PR08CA0170.eurprd08.prod.outlook.com (2603:10a6:800:d1::24) 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.177) by VI1PR08CA0170.eurprd08.prod.outlook.com (2603:10a6:800:d1::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Sat, 31 Oct 2020 10:29:28 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: d69e79cb-1aaf-4275-20f3-08d87d87d8c3 X-MS-TrafficTypeDiagnostic: VE1PR04MB6637: 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: N+u6Y5oScT0FEQde4YIEhC0p9BY0cWrbHS3cLLv6LwRKqUjxRK4wTDuMtYMk8Du3GVA9jcIOCW8O1MmXVrlS3VlfQYBNWG5JTT9l2HkuBA+10snBGnu0Cky5v/eK2BIe6S5nHiL75lIHm77xXIx/aQdpNZmZyFXbiI3TgPAaiyqcyMHerIXjWcXCV3tkdLsIRrQVBnqo+RDakFtFgkx64gJojTdFHy8ilN/HBlZNxlokcXenqass74uqIIfHkKVqGWTgL8fAOwtg6pZIc8BihGSJpCUnPStKifzx7ICe4+GszuAKmX67KGDf2q/ZYmfoWAQ5MLMJPoEiAOWzkogPpaNDZ0CPzF+dD+csgPkCv5LD+FwrR02IzghSDPaeMzaiuOAD8xEfFAtfZu851hjDxXY4ymdYBBBh+VjQEhnDfKuBXxvN3XLN2aIXQGNULGex8Vh5Ix95jhnSPFBS0T7D8dmU+TZJsO3m9EVw4MwrTmM= 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)(376002)(346002)(136003)(396003)(39850400004)(366004)(66556008)(1076003)(316002)(956004)(86362001)(66476007)(8936002)(83380400001)(2906002)(110136005)(66946007)(8676002)(36756003)(6512007)(6666004)(16526019)(186003)(52116002)(6506007)(44832011)(26005)(966005)(6486002)(69590400008)(478600001)(2616005)(5660300002)(921003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: PuoZd8IkoaCwRCX42Cg7iAUGyED+w4P6tsc5XeTh5/UuUS1zKsA4C5ZrfNd2h8Y4VZviOMZ/zsacuB1m9LrxhXoMrzoF9ERcLE/vCX5+Gf2tjhysY2ocg0veJx15uaZ0HVjWcbe6VB1gCeGOCAWgli4SGHbBPpbCJaL5Ks1XOLoBTIzuROVfiu2K6i8bwlubnccVHmGtTKcHEPzV8wgj7nGzzzDTT0sL9UeoH1p3I+v1pUj9saWUlyCvMH1/67FYeFhV9CR7RtBj2aA/xW/vdppLa8b0X39DyPTIKRFWZy8HZv5gjBizfV7WVk4p2Ff2UtVtI6BgRkFQrfu4lI6x1/53DosOS4BZwmGWnIDdA5qfuu+AQJdSVKt3OtBH/2wR615JFp2KHDw8WMbxRwDrj2IV7mEkHFoTEOQBPCyIe6M0VDzEhMMI6qB4gbs52jiBE1borZ3tgpINkQ0NR3JOvSDWIKWi3Wof750kDE4A3ylZPRxU5V5VKXDqvx+AOhjs38chqLlz8ICKWYPpO5b6h4QY4siYNqakBmAaO6ZDvByiF/6gDWiucZZropa2HV3cJibuF1ruHreW14Rl5piauG1cBooqkUSmKzXazzvih2Bvfp44uVDyufDZLJw+Ud51UpgO0Zp1OgwMpBGRt6ijQw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d69e79cb-1aaf-4275-20f3-08d87d87d8c3 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5696.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2020 10:29:28.6167 (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: 1l3CMLlyBE6yS3ewfeloPBoXK8UoeL1xJxHHkVqLYnQg1B8zigqYGc8bmntD2Fg40JaXhyY63CXINlCg5XCHIg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6637 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org I have no idea why this code is here, but I have 2 hypotheses: 1. A desperate attempt to keep untagged traffic working when the bridge deletes the pvid on a port. There was a fairly okay discussion here: https://lore.kernel.org/netdev/CA+h21hrRMrLH-RjBGhEJSTZd6_QPRSd3RkVRQF-wNKkrgKcRSA@mail.gmail.com/#t which established that in vlan_filtering=1 mode, the absence of a pvid should denote that the ingress port should drop untagged and priority tagged traffic. While in vlan_filtering=0 mode, nothing should change. So in vlan_filtering=1 mode, we should simply let things happen, and not attempt to save the day. And in vlan_filtering=0 mode, the pvid is 0 anyway, no need to do anything. 2. The driver encodes the native VLAN (ocelot_port->vid) value of 0 as special, meaning "not valid". There are checks based on that. But there are no such checks for the ocelot_port->pvid value of 0. In fact, that's a perfectly valid value, which is used in standalone mode. Maybe there was some confusion and the author thought that 0 means "invalid" here as well. In conclusion, delete the code*. *in fact we'll add it back later, in a slightly different form, but for an entirely different reason than the one for which this exists now. Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/mscc/ocelot.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index bc5b15d7bce7..ae25a79bf907 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -293,10 +293,6 @@ int ocelot_vlan_del(struct ocelot *ocelot, int port, u16 vid) if (ret) return ret; - /* Ingress */ - if (ocelot_port->pvid == vid) - ocelot_port_set_pvid(ocelot, port, 0); - /* Egress */ if (ocelot_port->vid == vid) ocelot_port_set_native_vlan(ocelot, port, 0); From patchwork Sat Oct 31 10:29:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 315919 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable 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 EA830C55178 for ; Sat, 31 Oct 2020 10:30:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B6ACF20791 for ; Sat, 31 Oct 2020 10:30:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="FliEp/dv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726913AbgJaKaM (ORCPT ); Sat, 31 Oct 2020 06:30:12 -0400 Received: from mail-am6eur05on2083.outbound.protection.outlook.com ([40.107.22.83]:28640 "EHLO EUR05-AM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726774AbgJaK3l (ORCPT ); Sat, 31 Oct 2020 06:29:41 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Yzi6mXRg+HD4N6gHg+8gvgb0qTtmjnN8E5eH8dYSGZBvXaMSmpg0VYR4D7opv2BePEkEAS53a1AgSRm3g8+B3hJPr7OhRDsEqfGq+mVTl/LfiiDpUSwg1bOTGM2nfY+VWwlshaznvJjbTY+zmA7GF7HSImQkBqt0vHCIqN23dNXSfVI5bgBdTyp77lDWQmLj8+P7155zwpglos7HCzxtongEyJkNNYRNDPV4TZjpPGWzPVCFhIJRYLuotUXlRm2yA5jaEmWS7Zq7uVED+3G3eAQVdJeVgvFEkjP92zbe8xXsvSndaHCJ6f8S80Cra0qVn58OfsawbOWg1BLi4yx/oQ== 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=UKtpJaD0SCyg+CYmRIXJ7EzcIbBTTXsnqtX2g3RhboY=; b=fgJZhUNwi+9RDBmniMI/46JrdMOpE/2lJbeDZ8g5DJ91gyH5LKwA/IBzAHLVEhRMRpsifPv+YAXJQCS7YLjByS2k9R+eVaVkhb7XdQVLlAW3Tiz7/KXuPd+wa0gzL3+lgJft1s15zmpGHi/b1okofXJx2FXVSMeq0IPRyq/lmDTDvHdy4J/pxm6vb8JGEHUVnl4CkXGiKYD/Ultg8pDwgMZIs/Z1youJ8tWUrewurXf0z7/8xUs2l+V4KJ7jSDkVlz2QSO386ayCQ519ZCDA4ZzHLSieUZAbTuiFPPYByTckVSUhvp6+bge74JRGu5FNFqHIdIshNbrtOpeerkpz2w== 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=UKtpJaD0SCyg+CYmRIXJ7EzcIbBTTXsnqtX2g3RhboY=; b=FliEp/dv46zW8Yjp/ylE3+MCeeQdVkm2zNzBNuROS2C7k5+V0ExcJZnSlMEx/MJ9PmeiDttzKB8RKqQWcv7rVooj8L0WI7cBs80nvU5fhoI85E6+bTNzw4xn6ulN5vnfi2XCyaUkgliDImcAoHZgBDVuE/4/HcjjBYosndvJDec= Authentication-Results: microchip.com; dkim=none (message not signed) header.d=none; microchip.com; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) by VE1PR04MB6637.eurprd04.prod.outlook.com (2603:10a6:803:126::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.27; Sat, 31 Oct 2020 10:29:30 +0000 Received: from VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::983b:73a7:cc93:e63d]) by VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::983b:73a7:cc93:e63d%3]) with mapi id 15.20.3499.029; Sat, 31 Oct 2020 10:29:30 +0000 From: Vladimir Oltean To: Microchip Linux Driver Support , Claudiu Manoil , Alexandre Belloni , Andrew Lunn , Vivien Didelot , Florian Fainelli , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 4/7] net: mscc: ocelot: add a "valid" boolean to struct ocelot_vlan Date: Sat, 31 Oct 2020 12:29:13 +0200 Message-Id: <20201031102916.667619-5-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201031102916.667619-1-vladimir.oltean@nxp.com> References: <20201031102916.667619-1-vladimir.oltean@nxp.com> X-Originating-IP: [188.25.2.177] X-ClientProxiedBy: VI1PR08CA0170.eurprd08.prod.outlook.com (2603:10a6:800:d1::24) 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.177) by VI1PR08CA0170.eurprd08.prod.outlook.com (2603:10a6:800:d1::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Sat, 31 Oct 2020 10:29:29 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 793191d5-a45c-47f5-8986-08d87d87d992 X-MS-TrafficTypeDiagnostic: VE1PR04MB6637: 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: 2z2dPlMNYPkVNFFQGrUBRpkF/yTW8PqwFg0h8se6Hd/xGkxl05/as/pz2Czfjqhp5OGXvIaIqLXsljdvO5LfG30xeyCFgle0VAGjcwgwKqa0w/paItKiZrtHNMLHaUQY+MPW2bg+j14GBxcsVnV/NHELOmO6R+WAfU+NbN5dD2GuX9SbV18aVvdQHZ4zBY3x7xQ1EOicnZq7zpJYD57zGVhPaVSQPLKjKJ4lm+yS+JvpzIa/Ad78LIv7Pn20lA80I7A68pyuV5hClX+l3OnK4dUD9qN6MWJR+axsXQAdirLeHrDEpscVfa8kQtJXw7ETxl0wIP1oKX1dfv/OmBRt0lGo4NJwYKOM/Ulgru471XFfap3I0FwLgMvN+fdmtBGmZPzAbtc56q+MbI91eCcqrw== 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)(376002)(346002)(136003)(396003)(39850400004)(366004)(66556008)(1076003)(316002)(956004)(86362001)(66476007)(8936002)(83380400001)(2906002)(110136005)(66946007)(8676002)(36756003)(6512007)(6666004)(16526019)(186003)(52116002)(6506007)(44832011)(26005)(6486002)(69590400008)(478600001)(2616005)(5660300002)(921003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Tktj649tLH5arm2tptdyqgQOnlNDk95LvjHOX9a7nGArunwfRAKNvRe8k/Ipf5HPGFlP8PZUx62sSb+JGSl6aGLwK8RapO6XKY7/rHd7j8WMlaKnCn9shBE6U54O1e+i/FfkaZkoAjM/5Uy5xmO6xvK8m9cTwy5hWvlneVWJpsEvzj14Q5gEe4696w3DDkWFApnt4cj/U2A7R5zkKVKPSA5pokl2mw7fJUC6L9sjDCRnnEzQDQSWSgcB0OjZG9fQsyr9KqYChl8ZHDrQZpJ5J2rVQ47rNTmYeqmJm5+dfe25fY2ghQ2f3f0cXLRJNJ3GHGraT/eSC4DBDWUwL6huWzxag8F1mFGt2AhEFScCwKaCvp1KH1AOCG7qt0HXt/1af5odcSbDNp2ezcCTswI4rt+nIs07NaubyPmSk8o52yb0keoqa/zJ58dOUyUrc51FxFYvml3AGk5xbyszMxU/xlwiGde6JW6vqzkyzljYy8tuRKw224Y17X9YsVBK0Z+MOGjD+wfM6F8Top3MCht0oP/T6xrnIOTc5gtlIfhr1uwdKoc17rlg1BEJyCHLzcP4pV+ZHl2mhl/YFZyeIpLw6FChnoS/oqAOlzWCq6DGhiw17EyF2ocqo1/7rCIzwAOWH7hcY37Vy54mlHpW5PPfSw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 793191d5-a45c-47f5-8986-08d87d87d992 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5696.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2020 10:29:29.9410 (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: v1nDCwYbXcdqKrV3FoZ5wSKtv1haC0rHKTuS3njZ/r7fkLnDkN+axiPYM029WLdDSGZ+ZyDLNQa/4qJToNuOzw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6637 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Currently we are checking in some places whether the port has a native VLAN on egress or not, by comparing the ocelot_port->vid value with zero. That works, because VID 0 can never be a native VLAN configured by the bridge, but now we want to make similar checks for the pvid. That won't work, because there are cases when we do have the pvid set to 0 (not by the bridge, by ourselves, but still.. it's confusing). And we can't encode a negative value into an u16, so add a bool to the structure. Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/mscc/ocelot.c | 27 ++++++++++++++------------- include/soc/mscc/ocelot.h | 1 + 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index a7e724ae01f7..d49e34430e23 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -153,22 +153,22 @@ static int ocelot_port_set_native_vlan(struct ocelot *ocelot, int port, struct ocelot_port *ocelot_port = ocelot->ports[port]; u32 val = 0; - if (ocelot_port->native_vlan.vid != native_vlan.vid) { - /* Always permit deleting the native VLAN (vid = 0) */ - if (ocelot_port->native_vlan.vid && native_vlan.vid) { - dev_err(ocelot->dev, - "Port already has a native VLAN: %d\n", - ocelot_port->native_vlan.vid); - return -EBUSY; - } - ocelot_port->native_vlan = native_vlan; + /* Deny changing the native VLAN, but always permit deleting it */ + if (ocelot_port->native_vlan.vid != native_vlan.vid && + ocelot_port->native_vlan.valid && native_vlan.valid) { + dev_err(ocelot->dev, + "Port already has a native VLAN: %d\n", + ocelot_port->native_vlan.vid); + return -EBUSY; } + ocelot_port->native_vlan = native_vlan; + ocelot_rmw_gix(ocelot, REW_PORT_VLAN_CFG_PORT_VID(native_vlan.vid), REW_PORT_VLAN_CFG_PORT_VID_M, REW_PORT_VLAN_CFG, port); - if (ocelot_port->vlan_aware && !ocelot_port->native_vlan.vid) + if (ocelot_port->vlan_aware && !ocelot_port->native_vlan.valid) /* If port is vlan-aware and tagged, drop untagged and priority * tagged frames. */ @@ -182,7 +182,7 @@ static int ocelot_port_set_native_vlan(struct ocelot *ocelot, int port, ANA_PORT_DROP_CFG, port); if (ocelot_port->vlan_aware) { - if (ocelot_port->native_vlan.vid) + if (native_vlan.valid) /* Tag all frames except when VID == DEFAULT_VLAN */ val = REW_TAG_CFG_TAG_CFG(1); else @@ -273,6 +273,7 @@ int ocelot_vlan_add(struct ocelot *ocelot, int port, u16 vid, bool pvid, struct ocelot_vlan pvid_vlan; pvid_vlan.vid = vid; + pvid_vlan.valid = true; ocelot_port_set_pvid(ocelot, port, pvid_vlan); } @@ -281,6 +282,7 @@ int ocelot_vlan_add(struct ocelot *ocelot, int port, u16 vid, bool pvid, struct ocelot_vlan native_vlan; native_vlan.vid = vid; + native_vlan.valid = true; ret = ocelot_port_set_native_vlan(ocelot, port, native_vlan); if (ret) return ret; @@ -303,9 +305,8 @@ int ocelot_vlan_del(struct ocelot *ocelot, int port, u16 vid) /* Egress */ if (ocelot_port->native_vlan.vid == vid) { - struct ocelot_vlan native_vlan; + struct ocelot_vlan native_vlan = {0}; - native_vlan.vid = 0; ocelot_port_set_native_vlan(ocelot, port, native_vlan); } diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index baf6a498f7d1..67c2af1c4c5c 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -572,6 +572,7 @@ struct ocelot_vcap_block { }; struct ocelot_vlan { + bool valid; u16 vid; }; From patchwork Sat Oct 31 10:29:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 315921 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable 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 D6807C4742C for ; Sat, 31 Oct 2020 10:30:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9294920729 for ; Sat, 31 Oct 2020 10:30:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="ojuf5fKs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726868AbgJaK3z (ORCPT ); Sat, 31 Oct 2020 06:29:55 -0400 Received: from mail-am6eur05on2083.outbound.protection.outlook.com ([40.107.22.83]:28640 "EHLO EUR05-AM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726814AbgJaK3r (ORCPT ); Sat, 31 Oct 2020 06:29:47 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LUijkm0gbziZtGJhDlCj069zKqDzVwlR6v5S8PiCyNjAQgCjk3UiN59h6pdkNZF2xDqWYsjwJBj2zN9ROlccvXvqvkP0V2W7sh4kZVy7JwzyX3ABLe64dK8qzy2tqFeXbvyxhpVQ3XEbK5vNbJlUBevxq9Ox6QwkNRmPiSV739zueLT5X4yDGVv9VvH8Eswx5yAdqKOHH3znl8i1EZvO0IkVfXY987vPytsNaBofkt9jV8TXnahy4k0ytjB9Cm65S2yCLe+S6Q4lqXcZDUIhIJx0Gy+cunpevTvIPKDRxjfU0Fa6pVdwubquQOUr7d/n8/dV0Tl9Sfi86xn6bW/vwA== 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=x2HSsPE8m7xe7Is0PNkYOzDLyYIDZmkh4PtszMvtH3E=; b=eFv5I0WiSrk/5Y16MLXBlTt8p9W/MyxtPg6nVC4qobFP8Af2CWzq8xOnytxydDegXydQ+Cq/V92ixuSSUA2H+GDV7c+fEa0qP5LXtdpr53u0QVPwg14sguAW6Qw89qGp2HkQzQNgqHLcTnGC31B0Agn5cpdnyRJXrrbShH1iLBwGZe5qHYKv6WafP97kLY5idqAep8Cid0kgNvsC/mi3RrTEGnCY81LZqIMR6pufkmgdN4FXFCaXK4+5K0SH+WBaGLOsZ1YoSJuGjh7KVqLv/C4DIS52q72a4bQ/W8OZNd8df49DKWGpCnzPPz04QrpYOPwiu6pN22hN5qAd0MPnMg== 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=x2HSsPE8m7xe7Is0PNkYOzDLyYIDZmkh4PtszMvtH3E=; b=ojuf5fKs4xi77HcyVt4u4wsPeNoZ6ymtK6Gzl3XkDrfpf15c1fgS+vPfAXlr8KdzZUALuWgmczmoQPbpP6oxXkzj7RtZhq+GXZ9FKcun+I2FDWd0gEpPAUlcnYmnAi2CDHFXDs1sGociHtpRKHv8u61MehfQQ32TI7ErLHkh7VU= Authentication-Results: microchip.com; dkim=none (message not signed) header.d=none; microchip.com; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5696.eurprd04.prod.outlook.com (2603:10a6:803:e7::13) by VE1PR04MB6637.eurprd04.prod.outlook.com (2603:10a6:803:126::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.27; Sat, 31 Oct 2020 10:29:31 +0000 Received: from VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::983b:73a7:cc93:e63d]) by VI1PR04MB5696.eurprd04.prod.outlook.com ([fe80::983b:73a7:cc93:e63d%3]) with mapi id 15.20.3499.029; Sat, 31 Oct 2020 10:29:31 +0000 From: Vladimir Oltean To: Microchip Linux Driver Support , Claudiu Manoil , Alexandre Belloni , Andrew Lunn , Vivien Didelot , Florian Fainelli , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 6/7] net: mscc: ocelot: deny changing the native VLAN from the prepare phase Date: Sat, 31 Oct 2020 12:29:15 +0200 Message-Id: <20201031102916.667619-7-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201031102916.667619-1-vladimir.oltean@nxp.com> References: <20201031102916.667619-1-vladimir.oltean@nxp.com> X-Originating-IP: [188.25.2.177] X-ClientProxiedBy: VI1PR08CA0170.eurprd08.prod.outlook.com (2603:10a6:800:d1::24) 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.177) by VI1PR08CA0170.eurprd08.prod.outlook.com (2603:10a6:800:d1::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Sat, 31 Oct 2020 10:29:30 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 461c8130-d2a5-4d67-a2ea-08d87d87da73 X-MS-TrafficTypeDiagnostic: VE1PR04MB6637: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ikbks3Xh0Ov343aqGYR9usEG5tuCybGR1HagGZvHDOR3L6WjWSNVpd8R1JIabeFYEq6SFTonrDhCVSLf7poklnK+La4pKTKqjezyvZdzHoeLAO66TuN4XdMTPP3c87FUAfjkihTYAzIlKrRzvO/dZA+TilanDNWtd+thRrA/vMace6t0cLLnG3qCvgdok1GthmHkZVLLBF/A7oqApZvSCz9z3ZYWSM9SC6eLJ+Tk9fwFYfxSNeZUrtVWg262N1zfZoOdx+kv0Y7xbNlMy8i4WMz/X/Nxzk+PFBWVKYX/h6PYKkInZfI5PV4EcYInetmyNJhZn6sXKCrguBsvPW/4mLACFCpORTD5GhtCKXh0vfBni/foh0hdscNbVs7oUNwfnTfoJ4gh6dhZGH/QwdEK/A== 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)(376002)(346002)(136003)(396003)(39850400004)(366004)(66556008)(1076003)(316002)(956004)(86362001)(66476007)(8936002)(83380400001)(2906002)(110136005)(66946007)(8676002)(36756003)(6512007)(6666004)(16526019)(186003)(52116002)(6506007)(44832011)(26005)(6486002)(69590400008)(478600001)(2616005)(5660300002)(921003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: WX8a72XfUoo41ChoOnESu7HHD87V110rUf9ANh0gcmcVm+BOqaTaeyZ1n3/XE/G/jFKeOXn66uTGZPDgUp/0CunZ7ScJecLqENy1gqfOI+gYXtecQDaBJPt62Rzu0LfWlpfd2EIAN2HgbdRybWLlx4OP7VHzpUDHl6ikQUYiFHei+wQhNv06MUhPVlJmWDNmDlqjXWqO/BQnj1/h6rKwCglyi7tHli86i5Jn7mWHwAwMIyG7xr390Jytnl0mUagCUB6m4ugelgJrj5Hotls7HbBaMRqkNcZ47CyoHTmWXJzqihyCe78YdpuYJRVhA9coxAVH7WoYa4Rw3UUGGHdLGmwGVYG8QQZ9R3rYdg14CPIA7Hz/Q5RIXx8/Znwya3wCjZXfKWBL5sv6VOtcR173+Fn6AFgUeZnEUGSMxzMSrnPUCx4qLYSgeeifnwwoQg/XgWXJO0mL/N54B8WEhH7DTwRNfBYqRFxxHHDAD85B1ikSg2+JNBY6/hJU0/N3WC/NwZgg9eO9x3QVK4EL56DlAyD++ul/wqjVTWklRcAx/Uy40gWDi67/TGzy/mwkLMXPsheNBEBi54sSXhlegYu/eLlkPacFAXl6EF9NP0W6ctMgvCA6YhsuYVLy1PxN09Wtk+WgDEDBLRIHYDR2flX02w== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 461c8130-d2a5-4d67-a2ea-08d87d87da73 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5696.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2020 10:29:31.3752 (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: GYM4wClC3xQRuph7RSmE4354pepDvAbA6GCfP4rC+YypfVTDe4b92lkPaGdS4n67oRHXUmkfkzeiWLT4pnnpmQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6637 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Put the preparation phase of switchdev VLAN objects to some good use, and move the check we already had, for preventing the existence of more than one egress-untagged VLAN per port, to the preparation phase of the addition. Signed-off-by: Vladimir Oltean --- drivers/net/dsa/ocelot/felix.c | 13 +++++++- drivers/net/ethernet/mscc/ocelot.c | 41 +++++++++++++++----------- drivers/net/ethernet/mscc/ocelot_net.c | 22 ++++++++++++-- include/soc/mscc/ocelot.h | 2 ++ 4 files changed, 57 insertions(+), 21 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index f791860d495f..3848f6bc922b 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -112,10 +112,21 @@ static void felix_bridge_leave(struct dsa_switch *ds, int port, ocelot_port_bridge_leave(ocelot, port, br); } -/* This callback needs to be present */ static int felix_vlan_prepare(struct dsa_switch *ds, int port, const struct switchdev_obj_port_vlan *vlan) { + struct ocelot *ocelot = ds->priv; + u16 vid, flags = vlan->flags; + int err; + + for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) { + err = ocelot_vlan_prepare(ocelot, port, vid, + flags & BRIDGE_VLAN_INFO_PVID, + flags & BRIDGE_VLAN_INFO_UNTAGGED); + if (err) + return err; + } + return 0; } diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 60186fc99280..2632fe2d2448 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -147,21 +147,12 @@ static int ocelot_vlant_set_mask(struct ocelot *ocelot, u16 vid, u32 mask) return ocelot_vlant_wait_for_completion(ocelot); } -static int ocelot_port_set_native_vlan(struct ocelot *ocelot, int port, - struct ocelot_vlan native_vlan) +static void ocelot_port_set_native_vlan(struct ocelot *ocelot, int port, + struct ocelot_vlan native_vlan) { struct ocelot_port *ocelot_port = ocelot->ports[port]; u32 val = 0; - /* Deny changing the native VLAN, but always permit deleting it */ - if (ocelot_port->native_vlan.vid != native_vlan.vid && - ocelot_port->native_vlan.valid && native_vlan.valid) { - dev_err(ocelot->dev, - "Port already has a native VLAN: %d\n", - ocelot_port->native_vlan.vid); - return -EBUSY; - } - ocelot_port->native_vlan = native_vlan; ocelot_rmw_gix(ocelot, REW_PORT_VLAN_CFG_PORT_VID(native_vlan.vid), @@ -182,8 +173,6 @@ static int ocelot_port_set_native_vlan(struct ocelot *ocelot, int port, ocelot_rmw_gix(ocelot, val, REW_TAG_CFG_TAG_CFG_M, REW_TAG_CFG, port); - - return 0; } /* Default vlan to clasify for untagged frames (may be zero) */ @@ -259,6 +248,24 @@ int ocelot_port_vlan_filtering(struct ocelot *ocelot, int port, } EXPORT_SYMBOL(ocelot_port_vlan_filtering); +int ocelot_vlan_prepare(struct ocelot *ocelot, int port, u16 vid, bool pvid, + bool untagged) +{ + struct ocelot_port *ocelot_port = ocelot->ports[port]; + + /* Deny changing the native VLAN, but always permit deleting it */ + if (untagged && ocelot_port->native_vlan.vid != vid && + ocelot_port->native_vlan.valid) { + dev_err(ocelot->dev, + "Port already has a native VLAN: %d\n", + ocelot_port->native_vlan.vid); + return -EBUSY; + } + + return 0; +} +EXPORT_SYMBOL(ocelot_vlan_prepare); + int ocelot_vlan_add(struct ocelot *ocelot, int port, u16 vid, bool pvid, bool untagged) { @@ -285,9 +292,7 @@ int ocelot_vlan_add(struct ocelot *ocelot, int port, u16 vid, bool pvid, native_vlan.vid = vid; native_vlan.valid = true; - ret = ocelot_port_set_native_vlan(ocelot, port, native_vlan); - if (ret) - return ret; + ocelot_port_set_native_vlan(ocelot, port, native_vlan); } return 0; @@ -1193,7 +1198,9 @@ int ocelot_port_bridge_leave(struct ocelot *ocelot, int port, return ret; ocelot_port_set_pvid(ocelot, port, pvid); - return ocelot_port_set_native_vlan(ocelot, port, native_vlan); + ocelot_port_set_native_vlan(ocelot, port, native_vlan); + + return 0; } EXPORT_SYMBOL(ocelot_port_bridge_leave); diff --git a/drivers/net/ethernet/mscc/ocelot_net.c b/drivers/net/ethernet/mscc/ocelot_net.c index cf5c2a0ddfc0..c65ae6f75a16 100644 --- a/drivers/net/ethernet/mscc/ocelot_net.c +++ b/drivers/net/ethernet/mscc/ocelot_net.c @@ -206,6 +206,17 @@ static void ocelot_port_adjust_link(struct net_device *dev) ocelot_adjust_link(ocelot, port, dev->phydev); } +static int ocelot_vlan_vid_prepare(struct net_device *dev, u16 vid, bool pvid, + bool untagged) +{ + struct ocelot_port_private *priv = netdev_priv(dev); + struct ocelot_port *ocelot_port = &priv->port; + struct ocelot *ocelot = ocelot_port->ocelot; + int port = priv->chip_port; + + return ocelot_vlan_prepare(ocelot, port, vid, pvid, untagged); +} + static int ocelot_vlan_vid_add(struct net_device *dev, u16 vid, bool pvid, bool untagged) { @@ -812,9 +823,14 @@ static int ocelot_port_obj_add_vlan(struct net_device *dev, u16 vid; for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) { - ret = ocelot_vlan_vid_add(dev, vid, - vlan->flags & BRIDGE_VLAN_INFO_PVID, - vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED); + bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID; + bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED; + + if (switchdev_trans_ph_prepare(trans)) + ret = ocelot_vlan_vid_prepare(dev, vid, pvid, + untagged); + else + ret = ocelot_vlan_vid_add(dev, vid, pvid, untagged); if (ret) return ret; } diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index 67c2af1c4c5c..ea1de185f2e4 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -747,6 +747,8 @@ int ocelot_fdb_add(struct ocelot *ocelot, int port, const unsigned char *addr, u16 vid); int ocelot_fdb_del(struct ocelot *ocelot, int port, const unsigned char *addr, u16 vid); +int ocelot_vlan_prepare(struct ocelot *ocelot, int port, u16 vid, bool pvid, + bool untagged); int ocelot_vlan_add(struct ocelot *ocelot, int port, u16 vid, bool pvid, bool untagged); int ocelot_vlan_del(struct ocelot *ocelot, int port, u16 vid);