From patchwork Mon Feb 20 12:23:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 59421 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1284788wrn; Mon, 20 Feb 2023 04:43:20 -0800 (PST) X-Google-Smtp-Source: AK7set+OKenH6v8hnP70Fn1TP18g6yKBWtSXx17HSHEGxWOCxf0/i2uMHZwJIp1Ra70RSFirWkbp X-Received: by 2002:a17:90b:1d07:b0:234:2c8b:6db5 with SMTP id on7-20020a17090b1d0700b002342c8b6db5mr2256581pjb.40.1676896999884; Mon, 20 Feb 2023 04:43:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1676896999; cv=pass; d=google.com; s=arc-20160816; b=rzwqW0+5lXAO2qiaFRxFFRQUeCk5uoNO3qpLwLNYo/jo+zYVM6vPvmyRs2R7XVRNv5 mHxCa01ljdiAV1uMkuUl24U5LqYj1gaW255+uVHGNoq5G9A331sAXcvXPVphB8sn6Wu8 RPLJwgaTZARcuyvatbRs3Y2pvF9BEib6ychM+4ln8uUdTN4GAko7/CMXbCzoemMOklmF n6SPxw8QZxn4PjuX2YGqeZmoUDrgzz/gao0/XObMhD8m4Ir7Xkq2YjpJlPTLIPbKS/G2 2HsqlVmT412VG0ew46VWpuj7hL8lMuXvN44d60DeL4moa5cijIC38fGDc8YKgegQBxI+ cjsw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LJJHpv+/7xNv6dxt2WGU34vlzBhJxDWViEn0or0+cLo=; b=hgwjpLrRReyfJCb78VjIvuogO2qsTrt4sB4oCJ0mWdQqX+74zOyp6O3Oxe/4WzQAtS 0L4JuEFJNqO8uGOoviw/NxaUQG7ufBLRpNcaTvZuOQk11fE0XGwmxSrLKRKpzWlwzWVF jk5obASXWKuj/l1ZVqH3mJXgMhmp0C6Qr1V+g1FPjx6OaNMllWv7IbNV8icORei/YfZF LR2Z6ZIQ3Ik1R4/9rNRhxMAN9bvrQsq/gvmbBVvAonSWjdtht2isG9sfd+Hd9ePQSvKj kcdt0FiC8eBpLW0GSv9kNZJKmtFc/SeWXfseXjzkRFlUZPAKWaDYkv8kfQsQ3pIwKv+i ZRFg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b="KIJERY/J"; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p12-20020a17090a2d8c00b0023312fad927si1210523pjd.100.2023.02.20.04.43.07; Mon, 20 Feb 2023 04:43:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b="KIJERY/J"; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232048AbjBTM00 (ORCPT + 99 others); Mon, 20 Feb 2023 07:26:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231787AbjBTM0W (ORCPT ); Mon, 20 Feb 2023 07:26:22 -0500 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2054.outbound.protection.outlook.com [40.107.15.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E39B1C7FC; Mon, 20 Feb 2023 04:25:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Blm7fxeen+Jem2kF6Wxrrn8vuWyi71fETcUKSfj5D+KIgnUk+bcVwVQBlb9hcoVU71eOJLfMDFpIaL+EuqSTbJe2f9jIGXqfnPSe+lhsL21mSNUVJgytEG1E66dZBO/lXPk8+eesuj9b8q3ldC3q4vpfMQ1JhT39a+M2Y97vB7/Q+ZIWxzq1Fm2mdUG2O8ZH4wtSDKhoktr/tCj/zw0aor7eHzxblgfrj3XcZ89vZKR0MwK0wVOjKEbEekGjc1NISerNJiMdalKJstM7YiaPcUU0Za814wjwj/mHafPXCkHVbnceLs9oo2Jm4qTGwbO1M8YUmq3vLWkyARaCynnzqA== 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=LJJHpv+/7xNv6dxt2WGU34vlzBhJxDWViEn0or0+cLo=; b=LO3kcEtQypCw9rVjP6hVf1QiihGqyHPKujUmceAxT2BocDizrZkcd43nr4d6IIpED9hozTNH0K77UBh+9SnrCMjpR6wgC5gcc9noVGc/ECCDEpNdoolgcH4L2JkNmxqA5QWF55seKXYQbA8aMLA3c0nf9OVT53cxQWU/JjRZeZSjAiYATkVzjdnfzxf0PZSPqSjNAk4avqv2Lqzw+wlLYCaU+0fiy01z7MID6Ah35teLfe5peC3AP5i/eBEG4RMDB2GQ0U3kyNnLKro8HYEm1VD+0utQC5YcYXwzKW/3yiYre5KoaGDvTZFsLFzGlnMhpQxZAgnscUCzgd31uG7h7w== 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=LJJHpv+/7xNv6dxt2WGU34vlzBhJxDWViEn0or0+cLo=; b=KIJERY/JgUPqlg24KZVReOOMckQOBVpot0E53fR2Yu4vtqG9jpIWZhlrOEH+DrqTzXU6nz825w8abxXXY5lRo9htOCe7n0a+8wyC/2LeMosbCRoIGqoegz/NaQhjRLtMovgAwXGAvu/1cTlhA+oOqNfTlKVp9L2pA/WmNZE3RkA= 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 PA4PR04MB7725.eurprd04.prod.outlook.com (2603:10a6:102:f1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.19; Mon, 20 Feb 2023 12:24:24 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6111.019; Mon, 20 Feb 2023 12:24:24 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vinicius Costa Gomes , Kurt Kanzenbach , Gerhard Engleder , Amritha Nambiar , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , Florian Fainelli , Ferenc Fejes , Xiaoliang Yang , Roger Quadros , Pranavi Somisetty , Harini Katakam , Giuseppe Cavallaro , Alexandre Torgue , Michael Sit Wei Hong , Mohammad Athari Bin Ismail , Jacob Keller , linux-kernel@vger.kernel.org Subject: [PATCH v3 net-next 12/13] net: mscc: ocelot: add support for preemptible traffic classes Date: Mon, 20 Feb 2023 14:23:42 +0200 Message-Id: <20230220122343.1156614-13-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220122343.1156614-1-vladimir.oltean@nxp.com> References: <20230220122343.1156614-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0183.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:8d::17) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PA4PR04MB7725:EE_ X-MS-Office365-Filtering-Correlation-Id: 206d8fd2-09a5-47ca-92fe-08db133d6700 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hVNfeLFXtvnYV47PG2wG9gfE5Yg9WTDAEw4OdveqSRyVjTrYvYlj+eB+oSx08BQGrsAxyZT7DBQNuTGqQ8JetUIObkONmy9IUSIkJ2RuhWexIi6rfOeprY9lwIblxs9FUOGo8DtjsPV6rLBnART6j3/VEYREZaXumIBnJpuJMhPT20X7uG6IXjRXE6T8F/EMUM+LSkZSPhl2LkNItHsQgGngXCG3806X5AALiF47AMGMbdG79Dze8+aNtPeswVY4V4N+WWKeeaWQ0T6DxNiRHo1ylUeOCjA2ldRD098oqfEYYmB+ULwGyE1kZ+a+PKTmQ1be8CgyrmJ5Y3oKfJDruNRZ0zXLU6nNbXri37dX7NjNSayJBylvl1Nros0792h+RAloEM0RUB0NYOQpWgZnnC4iXlAoU546VdIhVJVpnf90Ka9C5DA7UKXCr6ld3IiIUKkz3qR/INr5eM8Jh34RZPGVmZTDZBCjUiy4hi/AE3sUK1nR7CFYFgNizpjy+HYA45pzX+6YfcWHEjbGDCWORHW37nDEKCUjRYMVVgpXMZKDAaY/lincn+E6rNCX3YRKSSBY8hDX6VpKpM2zI4v0thzEOTmxVyrj/AGo0M14WHIGWXAJ5jdijDoLPn0JqO2K1lCaaJTyNKKwCBdwu0mnYhu2tYNINAdpQjg/MbNAcfsUDRzaZzkW70fwOMfJ0uiy82/lSQTls6kuy36ctA1S0Q== 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:(13230025)(4636009)(366004)(346002)(39860400002)(136003)(376002)(396003)(451199018)(8676002)(6916009)(4326008)(66556008)(316002)(6486002)(66476007)(54906003)(66946007)(7416002)(52116002)(8936002)(5660300002)(41300700001)(86362001)(36756003)(478600001)(38100700002)(1076003)(38350700002)(6506007)(26005)(186003)(6512007)(6666004)(2616005)(2906002)(44832011)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: n++sqc9eSpHzi5vg6agry+shjCjnjQGi+y5Xv3FP8UxklURwcUJ/PCh3k0kNK3mI9fjE4Yptv71RKbEDquUxtSULbLQ7jB1y7IZnrsaOhNZMCjzrF0fmFbIvz3PiDlfZQFpC7y+w5ptDyGuqnqD0NcJQT4QzmzcKaDoLPj44byyCPUGa+L+sFsWafmbVJ6adLeiHi6tfZJs2eMaIp8lTtiB6erMCcPmxXYKgrSNcm1nqtyYkw5kBlstP1W7IdDIvX6g7RBcRiwT2O8SoTkFJNZstYaChF0rPoi4/xeCW91n7rcGziwH81otexfqKBZBaiefWcyUAGgsi/tdYYf+34l3PV5CJZC3HiqNXDxoRmG5KG2PtnKoT7yISGWGGS4/4cdw5Tt0JiGyed4SXYQxQgfnEWfxbVB7h18jhE6vRewHwKFdA6Xk60arL1gHZFFOOjvNXXs4+2XFzaq+0fW7vmP6PiDYiodT/LvoUHethy9K+DQK7wAeQSvDXuL74XFCLtzd4go711zSR5kwj9OqpAZ+2BmT+XE0zHbKqWyx5Mpjv+wvwFTbjnZNvAD2/ibNecoJF1OEpERg8Igr602gdd8tgv7j8qy2ALmbryWq6deuIqrcer+Tagt9idrZkxukkxYHwr/fBArb9LKil6XiYMIW3dYXOcIyHq2Wo9OQO7oex6bYn6TZnGkv3RNQNjnxfiFDRMfS60MnQ+3i4kMgbGuuNzmr3c7ccseRMnwf0ZxAkYhBf8ij/Jgl44z757L0c6MN79eH8SDU9DKE1MJU7101hNLy2AczynTDmi7+n8QOcjo3PPtIGkJIrntqZqR9u0q+odKLc3Sof1ea7YSD90FGb7vnZBMrxLtkUadjx4mX0OnSDVqwvQhgrovZFZjOegBVN6C3rUlc/Ey7X2wdxKHytPpzQKrgOy7gN3If7J3S/ZB7kCeCNhJH8XDiRrPYX9dbCYm1ONeZRKNazW8grJdwnRQcdt95KMpaQckl8/BqF9pvHKQQEtY/kOvgvKbrDjNz94VpuDFmJn/xunbPxt+RvgZ5oXX1oO2Y5ODvhw7O3diJ9bSx7bRuOb6Mwk/PYuo0hRV0E0YYvimTM64FGDh8b0tG3qtqbT6yrvC/nUy+Zh81dFQhI4ZFtlSjEce/dsJuTbOXn+5VbndVQj05lFWndbO1Qj9RKVodcMTdXV7DbtH4sedzJpFqQuixox7gADrEaCa6VGWKeqyqA3RHwkG8UMw8ez1u7cmfMiXLvNnuG9+9Yup7O4tHnCOuPtgyXVfT0JkGlGzJCEvorynRnSd+QL2y8eiNEDaaDXn4UCucsv9BEUFueRRtAx3XrDZgeCMTT/tH4LPNBURa5YLJdsH+UkbHM08B4809Sjxk2jGJUUPk/QYkOgGU9AQwA+TeJ/cLzbwo1cM0tTPLy2rPBV5hEjUYiHYEwwofEIsIAj+VoTXwXhBDusL5kIiBXSyT7vFkjsnV5dImstQrn6wnoAzAJyCm0rraC9DBGDCzqlcvYIe1tmzORMFcq5U0pYMqStfrIUWAnh4mf1/KY7gUfpbJxJFkbLNHKr2gJ2yLUyfyNLqlsMCOK21IZb8kmVpYGCuF1ir6LBkdWyrkPRDdKEg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 206d8fd2-09a5-47ca-92fe-08db133d6700 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2023 12:24:24.7268 (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: QkY+hxGMGqKkQLbxkKhDn8WnPnc1RIz3JjW1qh8nNhs3V5LtymXPFZSiro3NbYaRx/zPWxBNO3tKnX/xUbFOWw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7725 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758353948411877938?= X-GMAIL-MSGID: =?utf-8?q?1758353948411877938?= In order to not transmit (preemptible) frames which will be received by the link partner as corrupted (because it doesn't support FP), the hardware requires the driver to program the QSYS_PREEMPTION_CFG_P_QUEUES register only after the MAC Merge layer becomes active (verification succeeds, or was disabled). There are some cases when FP is known (through experimentation) to be broken. Give priority to FP over cut-through switching, and disable FP for known broken link modes. Signed-off-by: Vladimir Oltean --- v2->v3: fix build error caused by "default" switch case with no code v1->v2: none drivers/net/dsa/ocelot/felix_vsc9959.c | 13 ++++++- drivers/net/ethernet/mscc/ocelot.c | 3 ++ drivers/net/ethernet/mscc/ocelot.h | 2 + drivers/net/ethernet/mscc/ocelot_mm.c | 52 ++++++++++++++++++++++++++ include/soc/mscc/ocelot.h | 2 + 5 files changed, 70 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c index 81fcdccacd8b..c6a5cf57dcc6 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -1343,6 +1343,7 @@ static void vsc9959_sched_speed_set(struct ocelot *ocelot, int port, u32 speed) { struct ocelot_port *ocelot_port = ocelot->ports[port]; + struct ocelot_mm_state *mm = &ocelot->mm[port]; u8 tas_speed; switch (speed) { @@ -1374,6 +1375,11 @@ static void vsc9959_sched_speed_set(struct ocelot *ocelot, int port, vsc9959_tas_guard_bands_update(ocelot, port); mutex_unlock(&ocelot->tas_lock); + + /* Workaround for hardware bug */ + mutex_lock(&mm->lock); + ocelot_port_update_preemptible_tcs(ocelot, port); + mutex_unlock(&mm->lock); } static void vsc9959_new_base_time(struct ocelot *ocelot, ktime_t base_time, @@ -2519,6 +2525,7 @@ static void vsc9959_cut_through_fwd(struct ocelot *ocelot) for (port = 0; port < ocelot->num_phys_ports; port++) { struct ocelot_port *ocelot_port = ocelot->ports[port]; + struct ocelot_mm_state *mm = &ocelot->mm[port]; int min_speed = ocelot_port->speed; unsigned long mask = 0; u32 tmp, val = 0; @@ -2559,10 +2566,12 @@ static void vsc9959_cut_through_fwd(struct ocelot *ocelot) /* Enable cut-through forwarding for all traffic classes that * don't have oversized dropping enabled, since this check is - * bypassed in cut-through mode. + * bypassed in cut-through mode. Also exclude preemptible + * traffic classes, since these would hang the port for some + * reason, if sent as cut-through. */ if (ocelot_port->speed == min_speed) { - val = GENMASK(7, 0); + val = GENMASK(7, 0) & ~mm->preemptible_tcs; for (tc = 0; tc < OCELOT_NUM_TC; tc++) if (vsc9959_port_qmaxsdu_get(ocelot, port, tc)) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 8227d2027c94..b53fbeb6bf4a 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -2608,6 +2608,7 @@ static void ocelot_port_reset_mqprio(struct ocelot *ocelot, int port) struct net_device *dev = ocelot->ops->port_to_netdev(ocelot, port); netdev_reset_tc(dev); + ocelot_port_update_fp(ocelot, port, 0); } int ocelot_port_mqprio(struct ocelot *ocelot, int port, @@ -2644,6 +2645,8 @@ int ocelot_port_mqprio(struct ocelot *ocelot, int port, if (err) goto err_reset_tc; + ocelot_port_update_fp(ocelot, port, mqprio->preemptible_tcs); + return 0; err_reset_tc: diff --git a/drivers/net/ethernet/mscc/ocelot.h b/drivers/net/ethernet/mscc/ocelot.h index e9a0179448bf..fa9b69ba198c 100644 --- a/drivers/net/ethernet/mscc/ocelot.h +++ b/drivers/net/ethernet/mscc/ocelot.h @@ -110,6 +110,8 @@ int ocelot_stats_init(struct ocelot *ocelot); void ocelot_stats_deinit(struct ocelot *ocelot); int ocelot_mm_init(struct ocelot *ocelot); +void ocelot_port_update_fp(struct ocelot *ocelot, int port, + unsigned long preemptible_tcs); extern struct notifier_block ocelot_netdevice_nb; extern struct notifier_block ocelot_switchdev_nb; diff --git a/drivers/net/ethernet/mscc/ocelot_mm.c b/drivers/net/ethernet/mscc/ocelot_mm.c index 0a8f21ae23f0..f7766927bdd2 100644 --- a/drivers/net/ethernet/mscc/ocelot_mm.c +++ b/drivers/net/ethernet/mscc/ocelot_mm.c @@ -49,6 +49,57 @@ static enum ethtool_mm_verify_status ocelot_mm_verify_status(u32 val) } } +void ocelot_port_update_preemptible_tcs(struct ocelot *ocelot, int port) +{ + struct ocelot_port *ocelot_port = ocelot->ports[port]; + struct ocelot_mm_state *mm = &ocelot->mm[port]; + u32 val = 0; + + lockdep_assert_held(&mm->lock); + + /* Only commit preemptible TCs when MAC Merge is active. + * On NXP LS1028A, when using QSGMII, the port hangs if transmitting + * preemptible frames at any other link speed than gigabit, so avoid + * preemption at lower speeds in this PHY mode. + */ + if ((ocelot_port->phy_mode != PHY_INTERFACE_MODE_QSGMII || + ocelot_port->speed == SPEED_1000) && + (mm->verify_status == ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED || + mm->verify_status == ETHTOOL_MM_VERIFY_STATUS_DISABLED)) + val = mm->preemptible_tcs; + + ocelot_rmw_rix(ocelot, QSYS_PREEMPTION_CFG_P_QUEUES(val), + QSYS_PREEMPTION_CFG_P_QUEUES_M, + QSYS_PREEMPTION_CFG, port); +} +EXPORT_SYMBOL_GPL(ocelot_port_update_preemptible_tcs); + +void ocelot_port_update_fp(struct ocelot *ocelot, int port, + unsigned long preemptible_tcs) +{ + struct ocelot_mm_state *mm = &ocelot->mm[port]; + + mutex_lock(&mm->lock); + + if (mm->preemptible_tcs == preemptible_tcs) + goto out_unlock; + + mm->preemptible_tcs = preemptible_tcs; + + /* Cut through switching doesn't work for preemptible priorities, + * so disable it. + */ + mutex_lock(&ocelot->fwd_domain_lock); + ocelot->ops->cut_through_fwd(ocelot); + mutex_unlock(&ocelot->fwd_domain_lock); + + ocelot_port_update_preemptible_tcs(ocelot, port); + +out_unlock: + mutex_unlock(&mm->lock); +} +EXPORT_SYMBOL_GPL(ocelot_port_update_fp); + void ocelot_port_mm_irq(struct ocelot *ocelot, int port) { struct ocelot_port *ocelot_port = ocelot->ports[port]; @@ -66,6 +117,7 @@ void ocelot_port_mm_irq(struct ocelot *ocelot, int port) "Port %d MAC Merge verification state %s\n", port, mm_verify_state_to_string(verify_status)); mm->verify_status = verify_status; + ocelot_port_update_preemptible_tcs(ocelot, port); } if (val & DEV_MM_STAT_MM_STATUS_PRMPT_ACTIVE_STICKY) { diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index 27ff770a6c53..7ee7a29e7c51 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -748,6 +748,7 @@ struct ocelot_mm_state { struct mutex lock; enum ethtool_mm_verify_status verify_status; bool tx_active; + u8 preemptible_tcs; }; struct ocelot_port; @@ -1149,6 +1150,7 @@ int ocelot_port_get_mm(struct ocelot *ocelot, int port, struct ethtool_mm_state *state); int ocelot_port_mqprio(struct ocelot *ocelot, int port, struct tc_mqprio_qopt_offload *mqprio); +void ocelot_port_update_preemptible_tcs(struct ocelot *ocelot, int port); #if IS_ENABLED(CONFIG_BRIDGE_MRP) int ocelot_mrp_add(struct ocelot *ocelot, int port,