From patchwork Wed Jul 28 21:54:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 488423 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 1E5B2C432BE for ; Wed, 28 Jul 2021 21:55:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0113860F5E for ; Wed, 28 Jul 2021 21:55:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232146AbhG1VzC (ORCPT ); Wed, 28 Jul 2021 17:55:02 -0400 Received: from mail-eopbgr80074.outbound.protection.outlook.com ([40.107.8.74]:44933 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232105AbhG1Vy6 (ORCPT ); Wed, 28 Jul 2021 17:54:58 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QuW9RDskP60anVIilVqb2vo5KvgVoJznRZDKMcXDhn6X9CDc1KF0EVdexEAlE5zCNud5VGgUe4tqueZCSW8cm1s5npdJunFmZQym2j/Ns2s/hNuQfI65jBEQoz0vUDReK7l7dtUHOWw+Td3DybnJJJsR5T7OUlAikj8pd8O/bbNwTM51vDFmaT86GO3/XpXA+TljbS8mWN8anDK+OAY67uvB30QDR/58/C2W+st52XsmwRoEOBtDzrfOTiOBNEPWiB1YS/7wTj79GTQmHjSMKi6CUBeB1bKdUW6i3bdbZJrHwK4IVJUUbDPbCmY5oX55Y/1ASRG/NuDwC92FtY+XiA== 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=mMDe0WF+12KkAs+ITz58M23qo+Y+aiXpLm2Pmuk5eGM=; b=l7/bF8dvh1Gr0tqEcCf1cbXy3GUYsOy/n7fIP/Fsdjgpg6BPgbAFKa/RTCUV8lNWt8qYi/K9HXEkxZYFy0Mu/nmkGP0QNwtiAjv8iwT+1ezy1r7MdyPHmQ+yh/ok+KnUqspmuVRoRsrwrhas3W/AXG+uVvwPA/rO5SfzdaMGJdFTDL3DOOP1Mjfespl7G8tL/S+yeNMVPkyH1LVscsR9x8ayzQmfXgMzLnArwkTW8UegbGm/WWFn5c5/4i8NgRELPW9mKhVNaON1XGXxSOKKm3AioQ9obhMt1MGHciWnlCh64yJTBhDA2Jov4i08zopXbGBQqezoSYYfbfqJuANDrA== 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=mMDe0WF+12KkAs+ITz58M23qo+Y+aiXpLm2Pmuk5eGM=; b=LKtqN0AJoYRWKnyuSM5/jnVWm69ihGHLjmjRTeTe+BHo174clehPfbjofAJxJwKXxZ5ziUcfATzBlC5eySSNSwExfMmysbLFVD7ufRVHDchlXgh5o9GhY94k6vEwPtIvcDHXAJlBboM1f4tn0B17X9w/OBX5LqEsO5RK/4adFhU= 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 AM0PR04MB5121.eurprd04.prod.outlook.com (2603:10a6:208:c1::16) by AM0PR04MB4564.eurprd04.prod.outlook.com (2603:10a6:208:74::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.17; Wed, 28 Jul 2021 21:54:54 +0000 Received: from AM0PR04MB5121.eurprd04.prod.outlook.com ([fe80::8f3:e338:fc71:ae62]) by AM0PR04MB5121.eurprd04.prod.outlook.com ([fe80::8f3:e338:fc71:ae62%5]) with mapi id 15.20.4373.018; Wed, 28 Jul 2021 21:54:54 +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 1/3] net: dsa: sja1105: reset the port pvid when leaving a VLAN-aware bridge Date: Thu, 29 Jul 2021 00:54:27 +0300 Message-Id: <20210728215429.3989666-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210728215429.3989666-1-vladimir.oltean@nxp.com> References: <20210728215429.3989666-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM8P191CA0015.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:21a::20) To AM0PR04MB5121.eurprd04.prod.outlook.com (2603:10a6:208:c1::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (82.76.66.29) by AM8P191CA0015.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:21a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.21 via Frontend Transport; Wed, 28 Jul 2021 21:54:53 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 75feff23-ca97-43e1-506f-08d952125521 X-MS-TrafficTypeDiagnostic: AM0PR04MB4564: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:639; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: I8urinc1vbC5nn76AD8MNKG7IYQGwyQ1utda16bRua5+V8fddAUixf2+3IyVOooodZ5YjiHFmxxsZpmQyqDSonRjsATNb1VS6LTAESQWy5jnTjV+DiokJeUtMBYsOaq1vTF4BnkRBWKVopejHzwIb/iBPTFrcaG1uc3vmj270Z1IHToYKwL904xxU3OvyhSt4OtI8XkcpIOpk0OVUGmEWn7Hbs13tuFijLmOAPKw5Xbt8HCaqyo/l6EmcrGRgTnl4FSSvfGegldWdUqrJ02zz2YDuWRUqB6bw6ROC2G9wyeJpX6OXCFaYek5GTCGPSzOdhFpfyt5LH0xudS2mNISM2cpfu01IN5j+auV+WEF52qwPI3rOx2Z3Te1jdwUQZgBG+rP/NLq285O9yjn3u6NPK7R8rkc3rjMNs0GwhAU8I47u5pQr4rAcUWsp37ea0ol6Jv7G6QJSOTR7KQVyJu+VdpBhqkFIrVI7tLgXEnLLFwbhX1McWetB4YC/rMYyLhuAGHAgMpx4xbrVjFbYW8i7IQMRX2MC76hfr8p8EjzeZU7wojznHTJch68ozvGKRl4nIOKBtIDWwQYbrrC2VqDfEMga7PSYpm88kJHuLvh9NLcBJW5MQPgSlUhX4Q1tjd3L79QingX7ErTCi7sC3fK35EjWw3k2xnXGs4M09e789Hy5rdT8vQiiWJYpd7ZbidrYJ3ZJp6/wkTuzsxQORmJTw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5121.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(26005)(83380400001)(6486002)(86362001)(110136005)(36756003)(66946007)(4326008)(316002)(8676002)(54906003)(66476007)(66556008)(6512007)(2616005)(956004)(44832011)(2906002)(6506007)(1076003)(8936002)(186003)(38100700002)(38350700002)(508600001)(52116002)(6666004)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: f4i/2TENiIiB64NNKixVeu3AFTVEfGh6RLd6dzNOCzz/VICDYXN3xo50qe97gUgP1rt7DMpbrVNepn5HFU2z00bKLluPlOskl/OFXdTO3PG6pDvNgDFvvMhewJo8nl9Jphzsf84G407BPbJFpQDtewNwwRNC3u6wrtSUGMqMRQkk06k5Lsdes42QX/1AFI98xc2WLQiK+ICD0oLTiSTE6vjOe9k7nxgXGw39uFm92UbNncfRcRoPWrUfLSnv4zaKVvMj9tCaKO38o7vOKxdsHDLxXn9ufaAdTV3byTJHEmQq0OMxzXwx+JR5pgSpVinv1vCHPe8y/lZVMcvTihBWlYmR78mR38fcIlq3vP0SWZcM7BohwEYd1OeMfS8rL+3t1fVtIBZ/g9KLM4PLBe1P6CIiDk128YrY9BcrqpJfkJ0n0P0GaUUvRFIh7quDREX8fRceG//O9/OG/W3/hxrmKSU1EYDbgWtcAkdz+m5JKS67lk2a59BgEi7R3HibCZs7ZD352jyZEd+56wgOyFljmWECYXQrI+a2842y+hm/62/ZD8kQp1l9Oodb64b6R/aJKrNwCruIMsqA4lVNhqyA1HJdq4jj1quKTMxiKN4y98zyKB0V9YUmD5322gsFp60SSMg5n2QCKMVv8hji8biplAQgjWj4OMK2Cbn01FPz/ikzdkTDYvGssUozAc5JnuaEucGbSHtZ4alopC3pAdkxGZGKmC8733YvM8h6ohG9Uxefr/2fThOuQjPIftyxtvUD+OaecsWs9AUkpGlT2+aA2S5IfWcMLpsWHBkbcrUOgPiiubQtxq5L1AGbaNoCQuUE7O+kFVW1yTBR8KOm/BsNM9WupHq3C87asjyfnd2yhryKc+yKGPhNeTCXzfVcD6a1WmysVCKlND5hzmCLQhrDqbSHxMkfgg63G6zIyzFpFmPC+ME2axofr/IwGOUq5uqhWrVpHSxsGJF0pPIBYIIHyAV9IXW1wpKA8bQDX7KKd6mO4sW53wt4QGi8FefaCTThvqYaxPdEChLUKNkNrn17kx/TuWj41TAOiKopYrXEdTuAJrowrtZC6/FYvQg367FKxnEkEZIgDczKjJ4PD4wzgtZTwbaympCKYnty+IFxLCuBE/Uq7+9jL1Iia38G6NVZVJb4RoxF5GmTRI9V0DvHAV28CV/X63tfESrMu6cqDVQ+St1tt4oe9yxCuWlsWKikKopJu7VqzjlH9S0fzEnWvO5b6udC5R5P6exvd3mEwFMlPh2DEH5T1GLWcCp3KcudcEb3/OI2lWCO2+I5CTGwmCvBat8BKQmOophQwW5ANv88j7nISllizbt6lLdU3Evi X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 75feff23-ca97-43e1-506f-08d952125521 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5121.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2021 21:54:54.2460 (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: GggK3VLjk3lbNrcZPrua7nHT4kDM4j3UYxISiPtESSsPAh9Amxd4e1VoY2j6j+Tx7k3GOhhWtYru8rfOg51oTA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4564 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Now that we no longer have the ultra-central sja1105_build_vlan_table(), we need to be more careful about checking all corner cases manually. For example, when a port leaves a VLAN-aware bridge, it becomes standalone so its pvid should become a tag_8021q RX VLAN again. However, sja1105_commit_pvid() only gets called from sja1105_bridge_vlan_add() and from sja1105_vlan_filtering(), and no VLAN awareness change takes place (VLAN filtering is a global setting for sja1105, so the switch remains VLAN-aware overall). This means that we need to put another sja1105_commit_pvid() call in sja1105_bridge_member(). Fixes: 6dfd23d35e75 ("net: dsa: sja1105: delete vlan delta save/restore logic") Signed-off-by: Vladimir Oltean Reviewed-by: Florian Fainelli --- drivers/net/dsa/sja1105/sja1105_main.c | 62 ++++++++++++++------------ 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index 3047704c24d3..293c77622657 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -57,6 +57,35 @@ static bool sja1105_can_forward(struct sja1105_l2_forwarding_entry *l2_fwd, return !!(l2_fwd[from].reach_port & BIT(to)); } +static int sja1105_pvid_apply(struct sja1105_private *priv, int port, u16 pvid) +{ + struct sja1105_mac_config_entry *mac; + + mac = priv->static_config.tables[BLK_IDX_MAC_CONFIG].entries; + + if (mac[port].vlanid == pvid) + return 0; + + mac[port].vlanid = pvid; + + return sja1105_dynamic_config_write(priv, BLK_IDX_MAC_CONFIG, port, + &mac[port], true); +} + +static int sja1105_commit_pvid(struct dsa_switch *ds, int port) +{ + struct dsa_port *dp = dsa_to_port(ds, port); + struct sja1105_private *priv = ds->priv; + u16 pvid; + + if (dp->bridge_dev && br_vlan_enabled(dp->bridge_dev)) + pvid = priv->bridge_pvid[port]; + else + pvid = priv->tag_8021q_pvid[port]; + + return sja1105_pvid_apply(priv, port, pvid); +} + static int sja1105_init_mac_settings(struct sja1105_private *priv) { struct sja1105_mac_config_entry default_mac = { @@ -1656,6 +1685,10 @@ static int sja1105_bridge_member(struct dsa_switch *ds, int port, if (rc) return rc; + rc = sja1105_commit_pvid(ds, port); + if (rc) + return rc; + return sja1105_manage_flood_domains(priv); } @@ -1955,35 +1988,6 @@ int sja1105_static_config_reload(struct sja1105_private *priv, return rc; } -static int sja1105_pvid_apply(struct sja1105_private *priv, int port, u16 pvid) -{ - struct sja1105_mac_config_entry *mac; - - mac = priv->static_config.tables[BLK_IDX_MAC_CONFIG].entries; - - if (mac[port].vlanid == pvid) - return 0; - - mac[port].vlanid = pvid; - - return sja1105_dynamic_config_write(priv, BLK_IDX_MAC_CONFIG, port, - &mac[port], true); -} - -static int sja1105_commit_pvid(struct dsa_switch *ds, int port) -{ - struct dsa_port *dp = dsa_to_port(ds, port); - struct sja1105_private *priv = ds->priv; - u16 pvid; - - if (dp->bridge_dev && br_vlan_enabled(dp->bridge_dev)) - pvid = priv->bridge_pvid[port]; - else - pvid = priv->tag_8021q_pvid[port]; - - return sja1105_pvid_apply(priv, port, pvid); -} - static enum dsa_tag_protocol sja1105_get_tag_protocol(struct dsa_switch *ds, int port, enum dsa_tag_protocol mp) From patchwork Wed Jul 28 21:54:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 488422 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 D7D8DC432BE for ; Wed, 28 Jul 2021 21:55:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C1FD360F12 for ; Wed, 28 Jul 2021 21:55:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232130AbhG1VzI (ORCPT ); Wed, 28 Jul 2021 17:55:08 -0400 Received: from mail-eopbgr80074.outbound.protection.outlook.com ([40.107.8.74]:44933 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232105AbhG1VzE (ORCPT ); Wed, 28 Jul 2021 17:55:04 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MFz8WJ+7p0VslFpioOZ6J17x6sbg4kW+41mgLERW7i5PV7dXlWSscL1bTAS0iOH4l5yGakRH1HItrvC7yR+DyrTeaixpblgKpk6ey6OIxhTdqSIRbH9JYOB3CcvAUkIGVSZ/RrGnbleTjEbArQZ3GrWU319VnYIm8i5UQoWUS8OGZ6QxKUeThTtN42r2Hb4bJ1ZyPiWnF25EMkuDUC5OF8AE3a9F9bRlzFHHzBpMNVXbhdbcbwhcmRx4W9tdFLgrpSimfk/d1jNtcf2oVHR10xVoflQu71Y3flKC5fYk9KBilk+6aqtvIYe0tj4NDuaVwiRLbzoVCs+ubi2ysrWxWA== 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=jJm7eEQZOay5O3nbeepwlLz01m38N4QObNs35l+mDGA=; b=XXdBp5Rpkz3gS+pqzBtp3jgw+5BedUXGe4MZDCTMQJBk2ltCDBbOzKM/JKIRkUJS+Eb7vjon7bqbOliMBHeTEQkWgfrAd0AU+LV3kdBSKRdJs2v+5gx1DCY6UcDejE1PofbPgy1YGhGseq/CXoyfXJxv/EehH79ZlKMMvPSJwyv4+UbKydwJMPTeAttun4ZjMWPNuA75wDZtEdGAdgDscdHT5KYFNrAPYPlkaAbk0/bFYEuOgi+aHJaFOiw2AzMJjGz9QxxiUmpNy2afXu3eHkapSleWJmDcjXlBY4NWNwGb9NaOhbQe5/k/YTlv95f2sCnknywQ+NiLGKEufQSjYg== 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=jJm7eEQZOay5O3nbeepwlLz01m38N4QObNs35l+mDGA=; b=TLaUad/Z19TteqtVxNxKreM/fVrBUhe3SqJdYs2lyMhnrm0uQOfYiY+TmL1/nVLfkcfzrpJppI4Wy0ueIs8PGFFnpkREPp9OiB+wdxd9IBtp92kzSqJNqBg+Veee7vG0GXdcLpkrZGGrADKTy6LeoNs/AS60n3s+7PKk3iWPbgg= 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 AM0PR04MB5121.eurprd04.prod.outlook.com (2603:10a6:208:c1::16) by AM0PR04MB4564.eurprd04.prod.outlook.com (2603:10a6:208:74::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.17; Wed, 28 Jul 2021 21:54:55 +0000 Received: from AM0PR04MB5121.eurprd04.prod.outlook.com ([fe80::8f3:e338:fc71:ae62]) by AM0PR04MB5121.eurprd04.prod.outlook.com ([fe80::8f3:e338:fc71:ae62%5]) with mapi id 15.20.4373.018; Wed, 28 Jul 2021 21:54:55 +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 3/3] net: dsa: tag_sja1105: fix control packets on SJA1110 being received on an imprecise port Date: Thu, 29 Jul 2021 00:54:29 +0300 Message-Id: <20210728215429.3989666-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210728215429.3989666-1-vladimir.oltean@nxp.com> References: <20210728215429.3989666-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM8P191CA0015.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:21a::20) To AM0PR04MB5121.eurprd04.prod.outlook.com (2603:10a6:208:c1::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (82.76.66.29) by AM8P191CA0015.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:21a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.21 via Frontend Transport; Wed, 28 Jul 2021 21:54:55 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 02f70db7-d9bc-42ba-4a0d-08d9521255f5 X-MS-TrafficTypeDiagnostic: AM0PR04MB4564: 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: i8r1fQKj4x4dPsiP58KCXU+dFhdFY6/G7+i2RQIX2jjsdXm5OjN9/Bst8OcXrGaWFqevSQjeI7ezSsm81KWCVDbyxDp8vSAI6eQvwZ/piK/0S2M3rImAwwHBcNdcnrxh20vVrtZ9Jj+xS3LAOE2zBZtV2QYuz3SSprmyARvD3Zk16eb8gjbHwFdahH/4gvKKOUgl8I2VWJzrzDqmJxpm9pXmJoTgjtpIhM1SGkosgzPvTypB0WV1DovyDyBFYxZuPy3IOG5S2eUswQTvgCk7y5gR/XwPl4YcIgJ9//wUgd98tTFFNi655Lczn3NHsIN6NyHHSjLGPGuqQr3t7Kykj6YJ3pJ0nR1zWStNSPntOSSPS6RKkDNYzP6IVvxCT+BDMhDth2PsXoVLCmSYsQWOYG4XF9xhBJ2S/FfO1MQG+YEchUBfosVtfrYbi45ryn00BKLKVMNbzmMneY6IxYomfYRnJqukg2Op4ScViJnSmAFa9BVDz4ptBBK6GRQx1Vf7DC3iedj2y/hKZCZjDXtaT9WyELLnvBipKErTjfaLy8igW1SE6JfLz6UIiMf8DFgSoW4OrEo/5cG+rnnCM5pzROqljmkzwEulLisMwQfWa/qKbZwBlgWEQu3yZbxCSk05fGJLlxjoT8YDs3Xis70RMBK/pq/L/P1RRidKUPeQ2VUgegoJ4+z69apLClwnSfFnoGYrMMg05h+L/vvo40g3jg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5121.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(26005)(83380400001)(6486002)(86362001)(110136005)(36756003)(66946007)(4326008)(316002)(8676002)(54906003)(66476007)(66556008)(6512007)(2616005)(956004)(44832011)(2906002)(6506007)(1076003)(8936002)(186003)(38100700002)(38350700002)(508600001)(52116002)(6666004)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7F6sHOyijJGVUfmEJdzU8/6m2ULRYnz2n5i2Wq3bPS3vdccZftX6l9cLg2ppiVfVF1W83Z/xw9uH5DSHdkw9+mmrch8rjva51Spu/ueSdfueyTXUVT3R6lIkXgCQDacy37UjVx9pvo6ijboWPqyc+uu9XxIiV+P6IGOYEMPMuDNaXLTz22iQNoOSxh/NuMKmJyQmrPhlLJOmEtORN5fCKSBnC+Sl3wnTAarOK6j5VphppyX8CT9Yn6xQWk5fPw2DzskXRLg1aXb0NcM9V6/SYBIfwqpY7OGT03KIJWCRouX4O871eFL5oTlEZ8/v4rhN43ENcw/2jm3S25H46B4DX5XFfErvapiTLYqcZg8gsQgHN0EYR3lOgWpkWs4ChIIlvMfYlVv6Zl2NqlokhFaHsMmmCIm7bfSEswqC/QN4kJjV+KbMpbxqMSn3mSvUESgBhSLIG2RuPgznZFx/AIY3vCKwNO87OvrQtZl/4RQTz802l6b/F0y3dnegJjwFO4GbdLxFS8n8fcAWYbuL899czjuH61/0vUdrqVHf2xejKhsu8TRC8fcxbnF1JjmjmPqeN7M5fRORx3pVRXpcjNU7OefE2lEtTx2Sv+MMcBvm1Pg0FiqiqGArUFbKFGYDCDTHIfzFNDmhcV0mi3VmpIi0bjXF38lWw0MbfMOx1zP1zI6+P9+QFLRcpQmXTgKldmD+uuBBAiifYBIloiqyYo39Qw1I87Zuc9/7nlygu37wp/t5ag+PXtKTSbC4e5h8cE4VgTcJj2uAN7nkFZmdD9FzkzfMk01pTSm1QOL0nrrezcAuAZAIhKiyC+envucnVa0v5TJz8JhPtTdGt8UQpNFdliISg/XoN/+YPJCL1KeSW2ZDUhYyWdw+noJtEPi0UtAFBD4d0dCZaC40J0JF37Vh6rxdNC+r+wlyfid9MiSsA2Jd2TyFIWRZ1GZNAU6gle3Wkq1637LzcARXM3Dmam9UQxhf2XEUWQSoZKG5Hp6PlueaXVntu6WmuF1254488izfZw5sXN0Em4Iwj3jrM+yTSydZmOk0dHdNcRB+MamynymYLzy2Oq0WFHbZQoTUFbgxZ7X96DtyPR3xUHZmsSDYHL7rPv6GYU24PtkJA1KJJD5NcIs9PEi5+yWJYXCqJcGjojHgs7HgjSmfE9julnmKGSLVnKKvVIWElWCty9fihWOAGSUYDfyBf1f3rSkON6enKP6nMo/fEu++o4wwRmzRQBFFB/AozJ+33ZnaJgeLeO7P6YnrDrSpSdFdOiKUTQTPJ0yOSIQiI7fwsorppWizWax2WwHli1fUzevkJAnumRsQ/yBxUnr8eUqLNRsnMohv X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 02f70db7-d9bc-42ba-4a0d-08d9521255f5 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5121.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2021 21:54:55.6582 (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: jZifxiGHEmViLrfw+37qFltDw3lOB8zH0TjdBPy9cUsr601hWhXI0hx/2K/FY0YCvFNUNeKZe6NtKtWIt/lrbA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4564 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On RX, a control packet with SJA1110 will have: - an in-band control extension (DSA tag) composed of a header and an optional trailer (if it is a timestamp frame). We can (and do) deduce the source port and switch id from this. - a VLAN header, which can either be the tag_8021q RX VLAN (pvid) or the bridge VLAN. The sja1105_vlan_rcv() function attempts to deduce the source port and switch id a second time from this. The basic idea is that even though we don't need the source port information from the tag_8021q header if it's a control packet, we do need to strip that header before we pass it on to the network stack. The problem is that we call sja1105_vlan_rcv for ports under VLAN-aware bridges, and that function tells us it couldn't identify a tag_8021q header, so we need to perform imprecise RX by VID. Well, we don't, because we already know the source port and switch ID. This patch drops the return value from sja1105_vlan_rcv and we just look at the source_port and switch_id values from sja1105_rcv and sja1110_rcv which were initialized to -1. If they are still -1 it means we need to perform imprecise RX. Fixes: 884be12f8566 ("net: dsa: sja1105: add support for imprecise RX") Signed-off-by: Vladimir Oltean --- net/dsa/tag_sja1105.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/net/dsa/tag_sja1105.c b/net/dsa/tag_sja1105.c index cddee4b499d8..c1f993d592ef 100644 --- a/net/dsa/tag_sja1105.c +++ b/net/dsa/tag_sja1105.c @@ -368,10 +368,11 @@ static bool sja1110_skb_has_inband_control_extension(const struct sk_buff *skb) return ntohs(eth_hdr(skb)->h_proto) == ETH_P_SJA1110; } -/* Returns true for imprecise RX and sets the @vid. - * Returns false for precise RX and sets @source_port and @switch_id. +/* If the VLAN in the packet is a tag_8021q one, set @source_port and + * @switch_id and strip the header. Otherwise set @vid and keep it in the + * packet. */ -static bool sja1105_vlan_rcv(struct sk_buff *skb, int *source_port, +static void sja1105_vlan_rcv(struct sk_buff *skb, int *source_port, int *switch_id, u16 *vid) { struct vlan_ethhdr *hdr = (struct vlan_ethhdr *)skb_mac_header(skb); @@ -382,15 +383,11 @@ static bool sja1105_vlan_rcv(struct sk_buff *skb, int *source_port, else vlan_tci = ntohs(hdr->h_vlan_TCI); - if (vid_is_dsa_8021q_rxvlan(vlan_tci & VLAN_VID_MASK)) { - dsa_8021q_rcv(skb, source_port, switch_id); - return false; - } + if (vid_is_dsa_8021q_rxvlan(vlan_tci & VLAN_VID_MASK)) + return dsa_8021q_rcv(skb, source_port, switch_id); /* Try our best with imprecise RX */ *vid = vlan_tci & VLAN_VID_MASK; - - return true; } static struct sk_buff *sja1105_rcv(struct sk_buff *skb, @@ -399,7 +396,6 @@ static struct sk_buff *sja1105_rcv(struct sk_buff *skb, { int source_port = -1, switch_id = -1; struct sja1105_meta meta = {0}; - bool imprecise_rx = false; struct ethhdr *hdr; bool is_link_local; bool is_meta; @@ -413,8 +409,7 @@ static struct sk_buff *sja1105_rcv(struct sk_buff *skb, if (sja1105_skb_has_tag_8021q(skb)) { /* Normal traffic path. */ - imprecise_rx = sja1105_vlan_rcv(skb, &source_port, &switch_id, - &vid); + sja1105_vlan_rcv(skb, &source_port, &switch_id, &vid); } else if (is_link_local) { /* Management traffic path. Switch embeds the switch ID and * port ID into bytes of the destination MAC, courtesy of @@ -433,7 +428,7 @@ static struct sk_buff *sja1105_rcv(struct sk_buff *skb, return NULL; } - if (imprecise_rx) + if (source_port == -1 || switch_id == -1) skb->dev = dsa_find_designated_bridge_port_by_vid(netdev, vid); else skb->dev = dsa_master_find_slave(netdev, switch_id, source_port); @@ -550,7 +545,6 @@ static struct sk_buff *sja1110_rcv(struct sk_buff *skb, struct packet_type *pt) { int source_port = -1, switch_id = -1; - bool imprecise_rx = false; u16 vid; skb->offload_fwd_mark = 1; @@ -564,10 +558,9 @@ static struct sk_buff *sja1110_rcv(struct sk_buff *skb, /* Packets with in-band control extensions might still have RX VLANs */ if (likely(sja1105_skb_has_tag_8021q(skb))) - imprecise_rx = sja1105_vlan_rcv(skb, &source_port, &switch_id, - &vid); + sja1105_vlan_rcv(skb, &source_port, &switch_id, &vid); - if (imprecise_rx) + if (source_port == -1 || switch_id == -1) skb->dev = dsa_find_designated_bridge_port_by_vid(netdev, vid); else skb->dev = dsa_master_find_slave(netdev, switch_id, source_port);