From patchwork Fri Sep 2 21:57:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12964724 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3CA66C6FA82 for ; Fri, 2 Sep 2022 21:57:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230012AbiIBV5Y (ORCPT ); Fri, 2 Sep 2022 17:57:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229605AbiIBV5W (ORCPT ); Fri, 2 Sep 2022 17:57:22 -0400 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2054.outbound.protection.outlook.com [40.107.249.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B170F54B8; Fri, 2 Sep 2022 14:57:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=muBummFQeZiVOc3YmsQ1izfEWdG9WgCqmoFVWMv245YX9uOUw0ksUpBfObxiScUiX3gWpwuN3nCb8oHSxf+om/JokkoRRHn1d2H/83Juq8AchdDCqF+Cdl6l90ENR4pxevl58riPERTnOgHfKxGaPWvLvcub1PrXl7HAXNLgPeMg5zVDZW3ALKYKLmmrLRCqz8toxD8MpQIJKTc7NpfDTKnNBYMlE61tZ68H5rtMX3c1vlcjngSlzXp7t7LnT4fYMFtYvUisFjeD8zFXKxxkJrp1Souytp8FxIEhNfI4KiMHrLL8bsiqqRiJseI2qBB8FA0Mojwf5orHfpTv236hOA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=J3CB2Dy+VeKkavKXMISZQ4qABPzcOdUuqBzZ066lvTI=; b=Ywv3xrhOPBl9dnA5oqFmM4H39Xhzg7o5n9Yh3gYLPpIygWMXgA9D5zrddokfqzmo1buivcL44VizUi3JsfG5cF3JioAVNgal0mbCXNwpfy768saS03bKPXUHt6ze5MRZDEWgsSenKdYhWaIw4NXwdHNaOb5HCPZ2ZvqlLQd0ZAH7+OTO0Dpr2b2BJbu0cMcfHgAzf5KgDdr7N3emL7J9MzIiQmfwUUEwOWBPro/iYx+a36hDpsrKdP3YN4iehiwSThZDXCqUu+8avP+yR5Hj2tYskWFLPb+Nof/nVm2tdjFKjepMiIc0/LHPUCjawv+Hb+VVI5i2ITQfFzjhaSTQTw== 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=J3CB2Dy+VeKkavKXMISZQ4qABPzcOdUuqBzZ066lvTI=; b=eKK+VObuR5TxYfeYb0Pmo5eLRv2R8mGLjYuoW5TNecWGf7k1C4/mZelhPi5UcT/Pjn3OuYrxueJZckHFRVz+t4bbv1rXjYKEtTwVto6W5JbPS2NNGdNTgZZB1dIhcmaulPazAAQTa3O4KjQk2PB5j7Dd/febCJZe4iVLIaANziw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR04MB4576.eurprd04.prod.outlook.com (2603:10a6:803:74::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.21; Fri, 2 Sep 2022 21:57:16 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3412:9d57:ec73:fef3]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3412:9d57:ec73:fef3%5]) with mapi id 15.20.5588.010; Fri, 2 Sep 2022 21:57:16 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Xiaoliang Yang , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , Vivien Didelot , Florian Fainelli , Michael Walle , Vinicius Costa Gomes , Maxim Kochetkov , Colin Foster , Richie Pearn , linux-kernel@vger.kernel.org Subject: [PATCH net 1/3] net: dsa: felix: allow small tc-taprio windows to send at least some packets Date: Sat, 3 Sep 2022 00:57:00 +0300 Message-Id: <20220902215702.3895073-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220902215702.3895073-1-vladimir.oltean@nxp.com> References: <20220902215702.3895073-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE0P281CA0013.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:a::23) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 960dbe92-d86e-4556-ba9b-08da8d2e1916 X-MS-TrafficTypeDiagnostic: VI1PR04MB4576:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BhrqjjhjMuOzj1XaXVebO7ljaEwc1kd+tBgWaqXI2cJZ2d4KXRH8asB03QjrdsrBquW9x3MXLqtyJkwUaW95q+pgPUmuckgkb9e2os3F+iawEhc9iqzgCVjmAjNoKJq6hrFhPHeW7iC6UOhlEwowQB2RcS+OlHnUoU1eYLuH8OMSRjlhhaaiC1uP5v2k3tifZeD2+fZ0+sU0xuQ9j4qkBWA1pDTzel9vjau5fjFPt7et26n8HDsexO1NX9X1+alQ0uZ1m58EnmT94fjJ9V2Dq3qPqVgC2ZbEdtpanWzCIQ8BN56O7HHziUqxG4fgE4kBxMXIF4+ptHONPcz++7Qx9e7TdZzz3kcb1X0r85dmW/F1neTB6vWDLGx1iSStgh+KDUp4rj4o9jWgPyWCZ40t/LO/esqcv0uePMBOv/dlTJDiJesU3wJvt65X3zPBOB9hdPRGa/jw4MQcScuKfQ9vDpjURCA2/wje7hGm+LRv6n0HyOZxowcopOJryClFj7UumIrcve+OxMvsdiuV+0k9LpHyc9mQevm5TGiwKwjC682szZh3FH8hD2bgX98XwkURDEpb6lDMKEjalkvOOyO8qoZsJd/PXH0GqwfHihsQ/bXkdT64Q0DOoyWqaCTQR3uEWm7m8y1P7bkkCcne94snjce2odzRmwwi1YRumemGJwPjPz/peE54L/toDOYl7XMuTHLfn3dEdiCAGvFLNfAiLd/t5gjUtpemNGF+WkNduzBrQr+aGf0YjT5/QR31WmhGlxmdqo+GXAjmrIk4SIjJbQ== 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:(13230016)(4636009)(376002)(39860400002)(136003)(396003)(366004)(346002)(6916009)(36756003)(316002)(54906003)(38350700002)(186003)(38100700002)(1076003)(2616005)(86362001)(52116002)(2906002)(83380400001)(41300700001)(66556008)(66946007)(478600001)(4326008)(66476007)(6666004)(8676002)(6486002)(8936002)(7416002)(44832011)(6512007)(6506007)(5660300002)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XknUz/bHILFQNxIdDlJ5zoNeMBHRHPTQuHfYW2PYdD7uSMLkHbQtf+C4vsEZyJFyGSiyu7AdMUBC6ExxoyLmp9jreInemgNl16fphj6xk560hMtlgNrMKdyw6W9ddXUNX+8ytHztAA854MhfAmwlmhGaaF3aRMZAjFDsdnxiZK76bKr2RH2cFwHjxPLj3aHHTAZqWHHWqMGw5u1m8e0aWiYEFO4CLOHxYt3Ff+323WYPceCTdIxSVOwStKPecQeqvAKEba/N2fCUr+DV/Y59nVBcj7hChx5bcHF5hhClvGKzwdNG2SwHN8PWjEoyj1RLVTzqDg/T8wreWaGKpEwM5O/SYAxM+jxGOY75hDYytHXuWPP4gZ855Qj1/Uofu5Noeu/EiCiua1exK7o4ylChYS8puqgMu2HskgaWmPOtrgakmjIYn3tb1n34y3mYBzKIEsimyW8v2hy9RuH4N7XMfwXhld71up6y+722GUsyQLDdoZJbS8JpkG0kl4lIYPK3XEnNzYgVyLbubNxfA+95ysigvrcjLqLxoBzoqAsxCeZeqK5xP5DnRopiMdn0ubRXUDfGgUUbePUKSKnTL43xjJYvL/NlnKYvIuI0V/wuuXDuUckEqpNoNvfCZYFBm8LIMs5qn4G33zxKwrpPVC+0VXZGh5Yx7qV9brLjNrUD5icp9Iej//HrB/FLrKwKgbO1/dIv1aZuKSKXIrl5YCmbK74nW3CVB3hImyRT0iN6NiGkkgEjwmbHHUFjegvPrxcXaQkUxMxtYValqGAWdX8oaW/LSlFbIqTl+P/OkRsBPZZd8KqmkyX/KCECd6Z3Q544sMVZh9IqheB9+JwdsPheDta6TYH1dk0UyzoAhWbOcBkwB9XEhr4x2vmTDhM1E+UWYZUqvWTTKQitWCb89N03TMtsP0Gsu5mefhnyEDFUUzYRg6SlXR/MroNhSyzgzTqaiYkKAF2LDuDxmiturhCas4Re/8APEIsFT5/Hy+ML1olATYAZNlt2IAaJztg0CBIstzgiTrdJS+9CU7cx9j27YIcELpeKYFx3HceSfWLgUB+o14VP7bWJeRInq6Ws+RdqLXDeuR/o9IBnzsh0JB8nxASJUNkHSj2WsirPjrLj5psgfPlX9dzwcaVGRFMvNZ7On3E6SG+brMM0Tdb2ZArNWLPUiQj6VlWCuM28pHAAs1yv5kvsV5eT4tXVDWfCoP/2foCMxPtWlyGFn+0LKUvtTU82zi8PbuQKR56f6FHTdnFOqsw7CdZOE9/+YaPYcktiRluLbL4XDFcGIwOiGI8SpNb8PI3jfIsCg56PwB2gKbZydTOzKFKMJO9PrbLv7lZXlvPLhQdP5w3mLE2vW1UEOUh+T6Vmx2j3hA6Z8u5rz5SRff45hjLYf4lEbMtHupHb9n1dFq2Ro3POxIXLdj24vUYhPHEKG8v8Xi6cDko/YJdijLx4JUp7M6h85OpR1gT4a7AOKjpTKO3Vi6XAYs+dVrQ17rPVL0zy9LP1qLsJoigWxWvi9Nqv9Q+bYXFO36rfx0cGh0rML06EqOjVUrnHBZP+IA6sasjFZJVhGrpR2EgZtS+JtQUlBY28VMW85xFoLNPmwgpg+G/DYd2wodiQyw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 960dbe92-d86e-4556-ba9b-08da8d2e1916 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Sep 2022 21:57:15.6840 (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: V+pA4Rrsxzm61tlPxU/zC9pbD6PGI4ONLpmzR/slRVj09pD7esq0Dv6Z432oFpf0CIirZOqOiVKiEgcIFI7isA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4576 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The blamed commit broke tc-taprio schedules such as this one: tc qdisc replace dev $swp1 root taprio \ num_tc 8 \ map 0 1 2 3 4 5 6 7 \ queues 1@0 1@1 1@2 1@3 1@4 1@5 1@6 1@7 \ base-time 0 \ sched-entry S 0x7f 990000 \ sched-entry S 0x80 10000 \ flags 0x2 because the gate entry for TC 7 (S 0x80 10000 ns) now has a static guard band added earlier than its 'gate close' event, such that packet overruns won't occur in the worst case of the largest packet possible. Since guard bands are statically determined based on the per-tc QSYS_QMAXSDU_CFG_* with a fallback on the port-based QSYS_PORT_MAX_SDU, we need to discuss depending on kernel version, since the driver, prior to commit 55a515b1f5a9 ("net: dsa: felix: drop oversized frames with tc-taprio instead of hanging the port"), did not touch QSYS_QMAXSDU_CFG_*, and therefore relied on QSYS_PORT_MAX_SDU. 1 (before vsc9959_tas_guard_bands_update): QSYS_PORT_MAX_SDU defaults to 1518, and at gigabit this introduces a static guard band (independent of packet sizes) of 12144 ns. But this is larger than the time window itself, of 10000 ns. So, the queue system never considers a frame with TC 7 as eligible for transmission, since the gate practically never opens, and these frames are forever stuck in the TX queues and hang the port. 2 (after vsc9959_tas_guard_bands_update): We make an effort to set QSYS_QMAXSDU_CFG_7 to 1230 bytes, and this enables oversized frame dropping for everything larger than that. But QSYS_QMAXSDU_CFG_7 plays 2 roles. One is oversized frame dropping, the other is the per-tc static guard band. When we calculated QSYS_QMAXSDU_CFG_7 to be 1230, we considered no guard band at all, and the entire time window available for transmission, which is not the case. The larger QSYS_QMAXSDU_CFG_7 is, the larger the static guard band for the tc is, too. In both cases, frames with any size (even 60 bytes sans FCS) are stuck on egress rather than being considered for scheduling on TC 7, even if they fit. This is because the static guard band is way too large. Considering the current situation, with vsc9959_tas_guard_bands_update(), frames between 60 octets and 1230 octets in size are not eligible for oversized dropping (because they are smaller than QSYS_QMAXSDU_CFG_7), but won't be considered as eligible for scheduling either, because the min_gate_len[7] (10000 ns) - the guard band determined by QSYS_QMAXSDU_CFG_7 (1230 octets * 8 ns per octet == 9840 ns) is smaller than their transmit time. A solution that is quite outrageous is to limit the minimum valid gate interval acceptable through tc-taprio, such that intervals, when transformed into L1 frame bit times, are never smaller than twice the MTU of the interface. However, the tc-taprio UAPI operates in ns, and the link speed can change at runtime (to 10 Mbps, where the transmission time of 1 octet is 800 ns). And since the max MTU is around 9000, we'd have to limit the tc-taprio intervals to be no smaller than 14.4 ms on the premise that it is possible for the link to renegotiate to 10 Mbps, which is astonishingly limiting for real use cases, where the entire *cycle* (here we're talking about a single interval) must be 100 us or lower. The solution is to modify vsc9959_tas_guard_bands_update() to take into account that the static per-tc guard bands consume time out of our time window too, not just packet transmission. The unknown which needs to be determined is the max admissible frame size. Both the useful bit time and the guard band size will depend on this unknown variable, so dividing the available 10000 ns into 2 halves sounds like the ideal strategy. In this case, we will program QSYS_QMAXSDU_CFG_7 with a maximum frame length (and guard band size) of 605 octets (this includes FCS but not IPG and preamble/SFD). With this value, everything of L2 size 601 (sans FCS) and higher is considered as oversized, and the guard band is low enough (605 + HSCH_MISC.FRM_ADJ, at 1Gbps => 5000 ns) in order to not disturb the scheduling of any frame smaller than L2 size 601. Fixes: 297c4de6f780 ("net: dsa: felix: re-enable TAS guard band mode") Signed-off-by: Vladimir Oltean --- drivers/net/dsa/ocelot/felix_vsc9959.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c index 1cdce8a98d1d..6fa4e0161b34 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -1599,9 +1599,10 @@ static void vsc9959_tas_guard_bands_update(struct ocelot *ocelot, int port) u32 max_sdu; if (min_gate_len[tc] == U64_MAX /* Gate always open */ || - min_gate_len[tc] * PSEC_PER_NSEC > needed_bit_time_ps) { + min_gate_len[tc] * PSEC_PER_NSEC > 2 * needed_bit_time_ps) { /* Setting QMAXSDU_CFG to 0 disables oversized frame - * dropping. + * dropping and leaves just the port-based static + * guard band. */ max_sdu = 0; dev_dbg(ocelot->dev, @@ -1612,9 +1613,17 @@ static void vsc9959_tas_guard_bands_update(struct ocelot *ocelot, int port) /* If traffic class doesn't support a full MTU sized * frame, make sure to enable oversize frame dropping * for frames larger than the smallest that would fit. + * + * However, the exact same register, * QSYS_QMAXSDU_CFG_*, + * controls not only oversized frame dropping, but also + * per-tc static guard band lengths. Therefore, the max + * SDU supported by this tc is determined by splitting + * its time window into 2: one for the useful traffic + * and one for the guard band. Both halves have the + * length equal to one max sized packet. */ max_sdu = div_u64(min_gate_len[tc] * PSEC_PER_NSEC, - picos_per_byte); + 2 * picos_per_byte); /* A TC gate may be completely closed, which is a * special case where all packets are oversized. * Any limit smaller than 64 octets accomplishes this From patchwork Fri Sep 2 21:57:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12964725 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 897E2C6FA86 for ; Fri, 2 Sep 2022 21:57:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229761AbiIBV5Z (ORCPT ); Fri, 2 Sep 2022 17:57:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229910AbiIBV5X (ORCPT ); Fri, 2 Sep 2022 17:57:23 -0400 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2054.outbound.protection.outlook.com [40.107.249.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 310F0F54B6; Fri, 2 Sep 2022 14:57:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lcXxsti46/d2pz+eAOpVTnVpsDTt1HzGvagnm5+tESpMb1N/vhWDCvwnoouUPpzVYpRm+ittPO3JgL32hTodG7gJ0YAbVan2aKo/3YvCjliY75zBYsEFz5Iiv3tYNf5Kjwj9CazJMLDI7qwHeQl4Il2CrJJv0+p1pCTlWj71hdorYWlkFPmwWU97wg4XTGLHzp6wHAUZy3DqsTRHiFf0+uRLCRu3cIqOBFc0rf6AMqdloBbFZNRn9qeuJBbTlkDeh4Il5jCrGBFz3KM3BISNaMyCAWzEG+lr8NjNwxUZXK9TDU0FUxpbo7ffDBttAInSIibiNEeKIdGL1VQHErojPA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=U2IiMMu0q3PevM76SqvW3WwLO0bAufGDClB2DAycvgc=; b=Yp4+k5NO5bjJ+98gNynUJQaoJ0DBlfXXWLlV5IUkoCTdWKr+E0mCnz8BbcOvLPcaFtnyP4xjXL6TtG7lqpVffNTkpzbsGWdk+LEE4soBkrYvrW/eLCzj9TDLGuEBS0TQ6ChLLLNl9u815XC7v/m8OGwicB3Pysr+Ch7MkmuXqZCH4niFXagtNXVid1mP15sDkZ9ljsaQ4rDo/p7xjp9Y7uMHq18UXrn2tb72MNQnanpUNJA3Gom7826FubbUE972iCMtyH5lZkIEXp0y14ukG1uJfTduLDxbRCNVXhmx/gEi45JX8ePH89imPaHi4QTNuFnAVFuK0li6IjX1zQP4Ug== 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=U2IiMMu0q3PevM76SqvW3WwLO0bAufGDClB2DAycvgc=; b=rxrA6YPO70MFp1U7okfurh89959ODEzKKkVmiu0IOv6Fs/NDI8V/yePQfLRRTtu3XoLbn/YYc0nb7lExsGiJXZ+VYbhU691QeotvQPYzejUgx/ZQHJzDBpjeA5OOd+HiO7P599N4K6ZEm8W09EeKayxP+XhFmFibrNFMj0zPYGM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR04MB4576.eurprd04.prod.outlook.com (2603:10a6:803:74::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.21; Fri, 2 Sep 2022 21:57:16 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3412:9d57:ec73:fef3]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3412:9d57:ec73:fef3%5]) with mapi id 15.20.5588.010; Fri, 2 Sep 2022 21:57:16 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Xiaoliang Yang , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , Vivien Didelot , Florian Fainelli , Michael Walle , Vinicius Costa Gomes , Maxim Kochetkov , Colin Foster , Richie Pearn , linux-kernel@vger.kernel.org Subject: [PATCH net 2/3] net: dsa: felix: disable cut-through forwarding for frames oversized for tc-taprio Date: Sat, 3 Sep 2022 00:57:01 +0300 Message-Id: <20220902215702.3895073-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220902215702.3895073-1-vladimir.oltean@nxp.com> References: <20220902215702.3895073-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE0P281CA0013.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:a::23) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3ac5cd55-c403-4fbf-d78c-08da8d2e19b8 X-MS-TrafficTypeDiagnostic: VI1PR04MB4576:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: U8DHrmcKsiqCCw+M3VgdyTZVNv9n2CkRepiBVej47iQdjoEvpPeqk5Q1S+4uXH0e3HP8FCYU7p9bKMPeCWqh4XyAJlKCfdR6ZH1lrAgi83SohXitJu4NV/sabhfxjo0f0KIQVh3c6TGZr5RInlltGE5rucpn3DAnVBTwg45EKNXZOmoguAeLLk/GyVe5z89zirpkaFgw8qnEXEAD9TbDxbkARidLnYJF75LcqfKN0XGWJr0Le23mBS+7JPAOGFro8n+8PMasUDIVLrZewe1BJufY+9kFPMUqDq+L1ZzU8MLHL3gWP0njVYjwEJ6/ARgt/SNaI3JhqL7YZkPOkfPKNyo49RMO7u9vfd8CxQqMUH3x2LbI+XfCR1qk51ZI46QY+c/BGhPJeEGMjcZDlt77XHCs9v3CU/YyV80ra1RZu4RJz9SHe8kuJ3ggeIbGO/z3AHRlEVXIHle3ipEH0tAyQV4Cf1o/MvQ/+NQUjBwUMwwj747oy7bOhoxQi/8Skz8xMmnUpfgYR7e56uH52fd93tbLHw/rmb+pTnUz6cZdRorZ9gYqlPKWAviHrYHrC26s0/xRzKKAYliUWOoDT3qOSAqnzxsKswvYPmnyiUUeOj/QGSOhoua79npGinKc6UAadO6p4TbHxSR0GW0U6wBjOGfC3/Yz4g7AtxyW+wc54FzMWmF3AOOY1yXKJrzjPpvAzUO3IJ51oKZBYOpvX3rqp4ksMGz1NGbgv35l/ZGUpDfsFvNNW88pIMZUZSg6BhseczRKXLHoaIpFa238eMuJJQ== 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:(13230016)(4636009)(376002)(39860400002)(136003)(396003)(366004)(346002)(6916009)(36756003)(316002)(54906003)(38350700002)(186003)(38100700002)(1076003)(2616005)(86362001)(52116002)(2906002)(83380400001)(41300700001)(66556008)(66946007)(478600001)(4326008)(66476007)(6666004)(8676002)(6486002)(8936002)(7416002)(44832011)(6512007)(6506007)(5660300002)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: C+EzAR8M2uNlkytDJKQEAaZMWaqmPDcgStno1tuGUyD9cAUBAtPD0LJqbdiPO4ErGhCYg9o50nbh1uxKxG1aoMYaBAVgaXyBby8v3KzIwPW3w7i2km28eEZULtXxxnUNVvO+dMgc8Ej9kiNl/XRwQP5Ubrq4A+fuORJympEyCDs/EpFot2PYNXiOVk2fkG5jBvH35zTgi87JpEDV6cM4spCAO6dZrb8VDtPqxJ6xWACZtuVIwLlq6m3DKcTJ0I+ZGXEXsXoXYq3xJK2bMb/kbqkuCKtx/vcVjiQiGS/hTZNnKy1kosr4OS8gZyOXiZE6QQ21rxjFg5eqSOvs0bzYXPsWwB/m3z7yADDuKsSjurqOmLmf1NgweW+IdMOLbCQb49Q95BEdmwR0pn9mjEGmHLUd8+LfXb33qBcuH+YSyFKISvKoc7j4s31UbpNKgMaNujd2Pt07gyoFQKad0X0IRAaPa2V/irKyozZAZz41FTUbJuRDYokKZf2RxJnppyQPcZVaF39iB+1/1Gv0nE3E0BmcW72UFPE3YNztqcYLBCL15+75sU2XjEbYEEUfs+swn3kJIIEg4bJYIcOyyO3Yyc8AbYMsIGLZVGqH90ovwukRB4dmb6oR0Et7r9erpvrciM8i9QdyElgTtm5c68ZjE9p8Ewp2cCSxRZ7Ebj6gcMI2OY1rdaKKcy2oMRF9FE7bI+GvfHbwKMPEG926kcUffHCZov9ADY8rtv+C57TWVNxKU8D4Rp03ElrfpDSUmCgtlsSoNBu7m0LiFCpEPqsorrJnBZTK6rTm+K1zwWSOmQQu80+sDFCrFJjPTq3w4tnBHzuy4OgXI8Qd2UUFIxExTRFZbfwqHQonIrkcBKFLSDDgCp04dSZjIW+ofH3hfgowWvcgz1a+7xi9JbNUc3vjLps86SgL36KUIbbaqc30nc9ail8tL6uCjXlxoYLio/kZ++OA8RV2nf+AxaiR8l36Sk6EgQchQAcjDyvNTxUX8aZmCCQtq1xbL7vTiVvFDjuMh1wEDZ520MtwKTasG3SMr9S1a+kOuZI11zhgqFkJq0UO+iuRIbvIlBwtJ4dfyFxbP3KJ+M4UuUgqiJOYIV3Qiyavv63EOH/gMU9NR/WMgfJ/TODs/NB1cC0h3Rcf/h3O7+AfdNFhLfhH9Po/LfObjq/wWC2ACCnSYGAgmbCiLMLVmE42+H0080oV8+/t3h3eQYXNVtmqqTKoWaKUVm36T/CE9qGhuNLn7ABAFAp01nwStlJDF7fDJge2ggJL4t3axE8aHQdaaWxhYVdZxeCrS2MJbkIP/JydP34Na0cLTkvy0JYP5hT1xzmCElTFSch25qh2Lg0+MGv6H1owGUCPjR66DwHDaXcxMFdy4j08ZKAPrB2GMBllNilGH1qnexoh7yy5XI5XKBygeIK/skyi8wl82cXBgiuPXGb/5lGY1vmqZIgwnaSBhNigZsinw+W3Ro6X1nlsKV5behLUq5E6kqBL3ut0zx1IBHDF7WqwYjuaAbYyVUSjVn4E4N672greecmm7/eEmyhtwkyK4CX/auXkKtd525NyQLtulmX6EOt3iPT9DdhanwX4LzIJf+JrmGeoF4Nb6ocvFY6JBmdXww== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3ac5cd55-c403-4fbf-d78c-08da8d2e19b8 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Sep 2022 21:57:16.7933 (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: 6mKl7Y+MffZ5LdP59avEZpmI17x54Cpbx/nyBj3sbWrVM+LCzq0WZSyfkdmb6txtd18RXLM0bxtuvDEoWozqxQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4576 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Experimentally, it looks like when QSYS_QMAXSDU_CFG_7 is set to 605, frames even way larger than 601 octets are transmitted even though these should be considered as oversized, according to the documentation, and dropped. Since oversized frame dropping depends on frame size, which is only known at the EOF stage, and therefore not at SOF when cut-through forwarding begins, it means that the switch cannot take QSYS_QMAXSDU_CFG_* into consideration for traffic classes that are cut-through. Since cut-through forwarding has no UAPI to control it, and the driver enables it based on the mantra "if we can, then why not", the strategy is to alter vsc9959_cut_through_fwd() to take into consideration which tc's have oversize frame dropping enabled, and disable cut-through for them. Then, from vsc9959_tas_guard_bands_update(), we re-trigger the cut-through determination process. There are 2 strategies for vsc9959_cut_through_fwd() to determine whether a tc has oversized dropping enabled or not. One is to keep a bit mask of traffic classes per port, and the other is to read back from the hardware registers (a non-zero value of QSYS_QMAXSDU_CFG_* means the feature is enabled). We choose reading back from registers, because struct ocelot_port is shared with drivers (ocelot, seville) that don't support either cut-through nor tc-taprio, and we don't have a felix specific extension of struct ocelot_port. Furthermore, reading registers from the Felix hardware is quite cheap, since they are memory-mapped. Fixes: 55a515b1f5a9 ("net: dsa: felix: drop oversized frames with tc-taprio instead of hanging the port") Signed-off-by: Vladimir Oltean --- drivers/net/dsa/ocelot/felix_vsc9959.c | 122 ++++++++++++++++--------- 1 file changed, 79 insertions(+), 43 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c index 6fa4e0161b34..35ce08b485f3 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -1539,6 +1539,65 @@ static void vsc9959_tas_min_gate_lengths(struct tc_taprio_qopt_offload *taprio, min_gate_len[tc] = 0; } +/* ocelot_write_rix is a macro that concatenates QSYS_MAXSDU_CFG_* with _RSZ, + * so we need to spell out the register access to each traffic class in helper + * functions, to simplify callers + */ +static void vsc9959_port_qmaxsdu_set(struct ocelot *ocelot, int port, int tc, + u32 max_sdu) +{ + switch (tc) { + case 0: + ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_0, + port); + break; + case 1: + ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_1, + port); + break; + case 2: + ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_2, + port); + break; + case 3: + ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_3, + port); + break; + case 4: + ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_4, + port); + break; + case 5: + ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_5, + port); + break; + case 6: + ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_6, + port); + break; + case 7: + ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_7, + port); + break; + } +} + +static u32 vsc9959_port_qmaxsdu_get(struct ocelot *ocelot, int port, int tc) +{ + switch (tc) { + case 0: return ocelot_read_rix(ocelot, QSYS_QMAXSDU_CFG_0, port); + case 1: return ocelot_read_rix(ocelot, QSYS_QMAXSDU_CFG_1, port); + case 2: return ocelot_read_rix(ocelot, QSYS_QMAXSDU_CFG_2, port); + case 3: return ocelot_read_rix(ocelot, QSYS_QMAXSDU_CFG_3, port); + case 4: return ocelot_read_rix(ocelot, QSYS_QMAXSDU_CFG_4, port); + case 5: return ocelot_read_rix(ocelot, QSYS_QMAXSDU_CFG_5, port); + case 6: return ocelot_read_rix(ocelot, QSYS_QMAXSDU_CFG_6, port); + case 7: return ocelot_read_rix(ocelot, QSYS_QMAXSDU_CFG_7, port); + default: + return 0; + } +} + /* Update QSYS_PORT_MAX_SDU to make sure the static guard bands added by the * switch (see the ALWAYS_GUARD_BAND_SCH_Q comment) are correct at all MTU * values (the default value is 1518). Also, for traffic class windows smaller @@ -1595,6 +1654,8 @@ static void vsc9959_tas_guard_bands_update(struct ocelot *ocelot, int port) vsc9959_tas_min_gate_lengths(ocelot_port->taprio, min_gate_len); + mutex_lock(&ocelot->fwd_domain_lock); + for (tc = 0; tc < OCELOT_NUM_TC; tc++) { u32 max_sdu; @@ -1646,47 +1707,14 @@ static void vsc9959_tas_guard_bands_update(struct ocelot *ocelot, int port) max_sdu); } - /* ocelot_write_rix is a macro that concatenates - * QSYS_MAXSDU_CFG_* with _RSZ, so we need to spell out - * the writes to each traffic class - */ - switch (tc) { - case 0: - ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_0, - port); - break; - case 1: - ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_1, - port); - break; - case 2: - ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_2, - port); - break; - case 3: - ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_3, - port); - break; - case 4: - ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_4, - port); - break; - case 5: - ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_5, - port); - break; - case 6: - ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_6, - port); - break; - case 7: - ocelot_write_rix(ocelot, max_sdu, QSYS_QMAXSDU_CFG_7, - port); - break; - } + vsc9959_port_qmaxsdu_set(ocelot, port, tc, max_sdu); } ocelot_write_rix(ocelot, maxlen, QSYS_PORT_MAX_SDU, port); + + ocelot->ops->cut_through_fwd(ocelot); + + mutex_unlock(&ocelot->fwd_domain_lock); } static void vsc9959_sched_speed_set(struct ocelot *ocelot, int port, @@ -2779,7 +2807,7 @@ static void vsc9959_cut_through_fwd(struct ocelot *ocelot) { struct felix *felix = ocelot_to_felix(ocelot); struct dsa_switch *ds = felix->ds; - int port, other_port; + int tc, port, other_port; lockdep_assert_held(&ocelot->fwd_domain_lock); @@ -2823,19 +2851,27 @@ static void vsc9959_cut_through_fwd(struct ocelot *ocelot) min_speed = other_ocelot_port->speed; } - /* Enable cut-through forwarding for all traffic classes. */ - if (ocelot_port->speed == min_speed) + /* Enable cut-through forwarding for all traffic classes that + * don't have oversized dropping enabled, since this check is + * bypassed in cut-through mode. + */ + if (ocelot_port->speed == min_speed) { val = GENMASK(7, 0); + for (tc = 0; tc < OCELOT_NUM_TC; tc++) + if (vsc9959_port_qmaxsdu_get(ocelot, port, tc)) + val &= ~BIT(tc); + } + set: tmp = ocelot_read_rix(ocelot, ANA_CUT_THRU_CFG, port); if (tmp == val) continue; dev_dbg(ocelot->dev, - "port %d fwd mask 0x%lx speed %d min_speed %d, %s cut-through forwarding\n", + "port %d fwd mask 0x%lx speed %d min_speed %d, %s cut-through forwarding on TC mask 0x%x\n", port, mask, ocelot_port->speed, min_speed, - val ? "enabling" : "disabling"); + val ? "enabling" : "disabling", val); ocelot_write_rix(ocelot, val, ANA_CUT_THRU_CFG, port); } From patchwork Fri Sep 2 21:57:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12964726 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 793C1C6FA82 for ; Fri, 2 Sep 2022 21:57:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230125AbiIBV5d (ORCPT ); Fri, 2 Sep 2022 17:57:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229504AbiIBV5Y (ORCPT ); Fri, 2 Sep 2022 17:57:24 -0400 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2054.outbound.protection.outlook.com [40.107.249.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5225F54B8; Fri, 2 Sep 2022 14:57:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IKl+5u9plnZ14KeNk9V9FJhuaExFeuF4YVaqDU6CHQAZbYkHsa4DjX3965E/FaV5kOEhgc5R144SRkqKPLW5TPqlXrSFE0lvaud0Gq9pStlqSPZNgTR6eK9OYlillMmw7hRrdwYexGW0pEzEcGAzwRclqc42Xa8BaVCQjNgXDwckI2EMPtYBgxNZxjoiCexxC/1M0hD/X6D9r19pEgQIaLIDP4SuKsqVLYfD9O+2x4GPQH/b2BWpjdNolMsNEbK3odhRlluc321OPJji7VmfyLwEqUGbwtULRzGLtqltP6YnR70nQU3EAXU6pOhmdGAnudI225DLGwOXL5uLx752dg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8nHBMUwQTCMHMGEnjTu6m4JdPEHbzPTr1Bv36Gxb0aY=; b=WZAwI0MDeuUHwXg7o03HnSd7MCrcBV+nRwUXS+0tiC4R3cIFT8BQ/Ruawg42zWzQFwX+iY4vBb690EEknpiKx45X5ee4JA+9hpEoYQwzRgA8oiH4J1jBAZEdGMZoe4404MSgbK9WfCLGDi7dCMPFsDscpLK0p5XP+vgjVxiHyAlATas1jPRjwOBx3eKF5KWEBBAJ8+nI0hdBS7HvsCAVAG2tpp2gXMvXvVK/Hq6blSI0xqqSgg7QKfeMDrU13pL6UNAft2ByKoPQq+YnhwlK6/u/HAz0805suSS70gwsnIKC0CyJC56w7E3bc/4ZAa0gI37lIdiwyE7rMIdJ5GyobA== 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=8nHBMUwQTCMHMGEnjTu6m4JdPEHbzPTr1Bv36Gxb0aY=; b=ToNuodaAV9FMYG3i5ZgwXWA8/gmMuBCd4F2NjrTQtMbdq61dfvU1Z45KbSh1I+5nA+mmVt8tRcW3VbkrI7JFGa/oy5BYwb9jatFAJF/33yQ6qdDfS93JurWc9t03kiCqE8K3IxZyLnXc15GVAKqFTcLB4/o38vbvrQlXHTyqpkQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR04MB4576.eurprd04.prod.outlook.com (2603:10a6:803:74::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.21; Fri, 2 Sep 2022 21:57:18 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3412:9d57:ec73:fef3]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3412:9d57:ec73:fef3%5]) with mapi id 15.20.5588.010; Fri, 2 Sep 2022 21:57:18 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Xiaoliang Yang , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , Vivien Didelot , Florian Fainelli , Michael Walle , Vinicius Costa Gomes , Maxim Kochetkov , Colin Foster , Richie Pearn , linux-kernel@vger.kernel.org Subject: [PATCH net 3/3] net: dsa: felix: access QSYS_TAG_CONFIG under tas_lock in vsc9959_sched_speed_set Date: Sat, 3 Sep 2022 00:57:02 +0300 Message-Id: <20220902215702.3895073-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220902215702.3895073-1-vladimir.oltean@nxp.com> References: <20220902215702.3895073-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE0P281CA0013.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:a::23) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 47649cf8-931c-4ee1-7dbf-08da8d2e1a64 X-MS-TrafficTypeDiagnostic: VI1PR04MB4576:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: g++G5XIVAMvivwSxH1jY+8oxmw8Bw+j/S9IZ4zsl0V9GEhtPSn0Teu3XEvLwBxWp33fBNDtqUSCV+dIp34oA4nZZRe6hV634jHykuLA1AFd7w5hADh7gEHCL2VL4Ed8DSHOCpKiPir8IO7ahcRK8PUz+5XCnHJORxzVkdfpXr3vcsH79eDjVsd4mAzAepixTq2SlHSO0dYujhdzpaGFO0n7DfiUKVNwEWY3EG/UpJAP8vLhuNgYCcpSV6/2oYfURG8leLlRSdle4Is+p0GUtYWY8WsNKM4UwyxWIjNFeXnRyPbTN0K1cvjPf0oXP8UYA2xvMUIdr+C9FqJlC4sxOGbXo3H0NQo6N27p5+FBV0SQRWkyiDnChcmoYnu+/D60HSTlO7J6jjMh+6GsE1I73EU2fjfc6daMfbGXqi/YFhOofn9BxOmcaRcZG8rdq4kuv4pwhUEzrfgtB82jF3eE9tw8pNF4WD5zv0M0qIaPxKXkgkSaD2MnL+KWb8m7EGETHZbDBUlqejlmzYJExdtSHRw51JYol+ieNZqn4qfioAkJCM2ErzM7IyN9TCPDK0Wb4dJZH/FvZ+F7RdpsU50BZMlYm/tc51KXRsxRhcplKhdDi4JWk+7kFTI3+fmPWuyoCf/bBqUcMO1z8PbSY9uUQzy5i/n6eiA9+0ZXGQKsEPsMxswyr5ihiSD7fY9x/jKJppIyxYnuqf7loXzuSJN9F79LwWhgTl6d0POKVC6TQeKi6jHBFs249MiPWMzkEVhxc++HtO9hW/c3QPVMoAR86Fw== 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:(13230016)(4636009)(376002)(39860400002)(136003)(396003)(366004)(346002)(6916009)(36756003)(316002)(54906003)(38350700002)(186003)(38100700002)(1076003)(2616005)(86362001)(52116002)(2906002)(83380400001)(41300700001)(66556008)(66946007)(478600001)(4326008)(66476007)(6666004)(8676002)(6486002)(8936002)(7416002)(44832011)(6512007)(6506007)(5660300002)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MprNVvYEcOc2aVwMaGNAUCaB2k8e7fYh4hTXjP5FvdRK2TSKrvemAXlb0ZIEeGp1Uaor2fqW9aC/YQfOjqNIiN9NN+LSl3sSO2Qm058yKm8WnxDsZczmA4d5UgKe+2wlxiyLIx5HPZ/cff7mYezk6vt7sYppoagZL6gN3yTAneqdDvduzcYZa/v4sGKKIDVCx5F4mu7HT2y4h4QrDsRrVkfb9m8xTUlEA79CFykPsUJcHUQryNgI+7I3EkWwCpGNcFiM3S+kX613vW5KOFTGYtwdlYgB4ioHoCiU6SRKLor2SxL2cppzQdnSvdK8mV3aAp2Cu53AeN4K6K8m6Bcn41WNgpfVk5Hy4CJTrxTg5l0rdlTGDjXfLI61hdt9Ng8WFE6dd8jpcCwzqaEs/HXI85xVW4vJU66TrLN+G7Vntb5PpxMcB/rPSgocSRrHVyMgvVigH+T322UtsLeoz6Aa6nkpsef0o0LRJ7RguzeHtyRToryZJEXQGngGorYIIYCU+hlI86pLWclJLz3DaLedzDH55CY+sWoQjbW24LuK3Tcqvp1R5HsHFhX/vUxGmFgwNIBJcnG9WDBcUvwH8aK8qXqPl4WLmUHKy1NluiTIP/flzkln1hdDtMC/9Mdf32XGQKdqNk/jjOG4IhVlQTTwaPwJ9AePStG4ii0nHCvww6kM0TzLFwQRVMPMwxZzIb/up9osJQr0HyyG0yog5+Seeq0yMP0+qOqGcFoQYGGMsFM212F5o9GHOvNFyeb6JE9zeyeZjrusEE+hSZKqRVGkjceUMbaj46e7UwmrEMRmMa0tYpP02K0btcKd05qMmjGem+erUiQIPTQAfuGzXFhZqYM9ag8xpozRKoDifQ/+/QgZoewkqaBeQ8igtY+DblJcIV87ISZes9g7p7PrDKvKnPx8p4A9ThpieH1cxWDpbP2NYEPjkRpWZD6PNab7oiVQMSGj5TZ7jjepRzuxDGe2LVqAd/X6EQw9n15IOjXwnsh02e8OVXUjjSMjrejLMYk6uO+ACrD2EbYBvLwVeblHz1Z9bC8XEgvMfY25C2mjKSWWnZKU2nExCLE3rup5s2dczZ+m/hDAcRbHopSyfIUhL68lxOOhnDmYcWVTTFG6ZuW+t6XmXwQtfT2t0R2INguk/4Zfs6ljp1P/1LSFCnkdEsosDkdxXGg4t0cBIUMitkyKXkBEFVidc2WnG3hL+15CnQcjw5cai3jRXeTdmOdQctQIqTFAOELtrxYNOtHWLbuoApy8gtMbC2fNDpf4fS1fye2GLvNrI5h7JgNQD4VbyHBt7RPs/pXP4Y3H3vXcIc8yN8edidjRuJS1XV/yQ58Pc+SYG0LEMyYYj/0sI0z6xKt1JUBvMlIZUAYfuOUd67xY/rtxuauJYlPlNyd2GRBcT/Shup3MsEAcVtxYtuHenz6d0y2OK0K49+kCiM3eeiLvH+paAweR/i3nipLz501KThkH5M4qGUUa/sivUv4mNHywai+KCqXRlLtpoyT/TZDV6emr6TpIjBg9nH/PxvQUY1RExoPCFzgzBjEQaNq3nxTEqJHKERQVq5P8pvfxFZKm6BlCTBC/iHr4A0Bk+CPMtJakKLsczipKArRpQmiP/g== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 47649cf8-931c-4ee1-7dbf-08da8d2e1a64 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Sep 2022 21:57:17.9339 (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: tC6JSnDkdRBHoajg1bXAp5mV63caNOikGxBz00TiGQLCD1SnhWoVrhB42KhF87Y+g9X/PjygHc/B052UvQctuQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4576 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The read-modify-write of QSYS_TAG_CONFIG from vsc9959_sched_speed_set() runs unlocked with respect to the other functions that access it, which are vsc9959_tas_guard_bands_update(), vsc9959_qos_port_tas_set() and vsc9959_tas_clock_adjust(). All the others are under ocelot->tas_lock, so move the vsc9959_sched_speed_set() access under that lock as well, to resolve the concurrency. Fixes: 55a515b1f5a9 ("net: dsa: felix: drop oversized frames with tc-taprio instead of hanging the port") Signed-off-by: Vladimir Oltean --- drivers/net/dsa/ocelot/felix_vsc9959.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c index 35ce08b485f3..db0aec807965 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -1741,13 +1741,13 @@ static void vsc9959_sched_speed_set(struct ocelot *ocelot, int port, break; } + mutex_lock(&ocelot->tas_lock); + ocelot_rmw_rix(ocelot, QSYS_TAG_CONFIG_LINK_SPEED(tas_speed), QSYS_TAG_CONFIG_LINK_SPEED_M, QSYS_TAG_CONFIG, port); - mutex_lock(&ocelot->tas_lock); - if (ocelot_port->taprio) vsc9959_tas_guard_bands_update(ocelot, port);