From patchwork Tue Jun 28 14:52:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12898405 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 28869C433EF for ; Tue, 28 Jun 2022 14:53:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347398AbiF1Ow6 (ORCPT ); Tue, 28 Jun 2022 10:52:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347381AbiF1Ow5 (ORCPT ); Tue, 28 Jun 2022 10:52:57 -0400 Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30049.outbound.protection.outlook.com [40.107.3.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FA6832062; Tue, 28 Jun 2022 07:52:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XQZHigmldVJEcr+qkP1apkUIOz4kX7X52CO4m0APHdVRIDZUr01WJDjMXupz8FHwg48EVGiI3P4v3QE8frtJiUSnpunb3eGH1VSYzVr3Sb+g3bvte0UqzkMoidW2JuzjKgMJIwRg9VD2wfVpUOT/AGxFWX+A6JIliLvQ0SQIwzupFID+bRC8LyPi+piADEVEGKRvowRR4gI/uF/E19yipmAFN5oQYc/4g031Y1ZXyBMUHqkT1u1TJIuKfNqdqm48Rh/MgZKr8qXp2fJ6AKoEs1tDZuJCpLuVjYNlnYcblebqf/iM79CNRu1nYuI+V49k37RryHonJROpTK+HD7gzgQ== 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=tW3YVwfaQ6p7S8rFYbrMLcidiVZurAYL5jC3TpLXvxw=; b=oI7DU/qTD2JusfWR/ywZzmXMFvw6Z2/pKhM3W/Bz48q/acA/+SrlUNxtWaUObVt8wbTAKkVHmhsusG2gE6Vl8q5jAEfXglAqPYlapFvMrIBbX2yLIZ29PKaZeBE761k805mH6JetMJOM9zZgJ8Z+FlqOd4hxuE3y6pGuW/YtjzH/re+Kru++X/GaXM4xpQIj5xCMqbN01PQ4HyeaJfujsMvtTp/SgcFnVaVGJgguuIjFaxGDaIb05qLHgBVgYPNjZbK6SC8cUXlZMDyT0hQdzsvVCRq7dTsmBE7JHkXStbonGz7p85JEcj2bxaaclAAEc/2FY/rt/fO4h9dK7d3MIQ== 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=tW3YVwfaQ6p7S8rFYbrMLcidiVZurAYL5jC3TpLXvxw=; b=Q5M4hA5/DzWu7hXGUz0nX9WgS6L/pKXROcHF+Aw7M7JjWK09+7eO9nKqHc3NA9wQjwt/6K5R2V6srL7ylGKtC/2JjS+voiNfyh6JRtlSCYXCleQzGYr9DVFnh9o9dAynBJDbYOTGAbV+lgl7HTfmWHX419zZjbCTq9oMmgGBpW4= 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 AM0PR0402MB3810.eurprd04.prod.outlook.com (2603:10a6:208:e::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.18; Tue, 28 Jun 2022 14:52:54 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::94fe:9cbe:247b:47ea]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::94fe:9cbe:247b:47ea%7]) with mapi id 15.20.5373.018; Tue, 28 Jun 2022 14:52:54 +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 v2 net-next 1/4] net: dsa: felix: keep reference on entire tc-taprio config Date: Tue, 28 Jun 2022 17:52:35 +0300 Message-Id: <20220628145238.3247853-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220628145238.3247853-1-vladimir.oltean@nxp.com> References: <20220628145238.3247853-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: LO4P265CA0104.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2c3::8) 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: e2b9409f-1ec7-442d-8daf-08da5915e184 X-MS-TrafficTypeDiagnostic: AM0PR0402MB3810:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1ZQ2kBJPx8pl/mkQsWSjQRKRZlSJx/rjyWzgb/ojc4ly7xVCfC9el0Ly1zD4Es0yd2aLbHgmdjwI3rzerBWlykrkKLRBtW7ZnrItoV1FDYM6KPcTjzaX3FpMsu4BP4rQBquySTARLpupVH0LCZ69at5Ttk2a99erCAFHmz5ZGc1MmqE5JtBdthoKcoEaszibJI3MPqhfYQP7HxY41NDo4k91RN9E06FbuEksV94P1hwKfEawqCKp2/xt2ncj3JfGkLiSsKq2EVUJ2ecV5F0jeDUO4FHknItsPOWPwSCAAJHOtldfxuTfpbOe3aon7S5cBCqXx4Nj7XJZqq6VLzJ897+XzghoAyCJojlElidcXcbX4FKUotABmosIIx0a8/qxeOEz5RyuoXj2uvcO7PIIgg40o5qqb6nW/ZdN7SeHb3csZ+CPZd1Kl02VrTmTyVnk1EVYLfCuUmTINyFogEBJGtUPoEOs5I2+tfL+qw31Nwejt90Rl7StPBkrABsVQY5P0ObP5RGyVVCFC9nrx5cQnUHJBcFDQ8ObFCMe8zabqA1QO76zxvyA0JMZ730q2UrV+ujIMBh4V953YS/AXVM075uOSYRM3U42tLvsXPbavk27CRruNcUiOHaZONyWpwDv1aFTYDFfTg8NGDPlEMFPRFo32zciXK+qqPwLTu72SQeWolq9Zo9SYcID95XVcdukp6IJZEbNlVdBRzTDP6/X+5JdNXMU5riKV2xvAMi5ail0Pyd2tmUhtg2xxEVNXKlgOb+3f8GQ9m0mgvB72oPyj7O69MErQjvfUH8iPuEpHQw= 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)(136003)(366004)(346002)(396003)(376002)(39860400002)(2616005)(38350700002)(38100700002)(41300700001)(54906003)(316002)(7416002)(44832011)(1076003)(26005)(66946007)(66476007)(6916009)(66556008)(8676002)(36756003)(4326008)(6486002)(86362001)(6512007)(2906002)(186003)(52116002)(8936002)(6666004)(478600001)(83380400001)(5660300002)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nxou2B94i2QxXo+6jmWoihpc8/61T72mgMM+8gt3Ul3iqWIC6jov5WGTufYAvoTwNiVDkor5jDMMdXieLaWBe+WBwR22H99OjZspyBMFh1612xtZ9Jusreppr2AVpjvI88AYJyk5BG4wK7aHulq+/0AHpX6lu4P3Ae75i8potA/bdcdTpBfyZiHW9x9S5GD8fe9kfnXmcpRhDFLrSxdCcw5uGlMebAncht0Nlf88s2YdJd9YA/Xyvd8kXfhdmmxmLmDiMz1c4lxEkDAJljK+WjJmbYd3UeFlH71VfaZJtwT+vNciyb3W6PlZo4agBYvM45umxfp1XHyF64Iu54jXHVucYmmnc8fRihpMsbJsjoYQi82dA7MiTVZraW2DshwOv2hKlaPAJ9fJn+gYvpyOBWRS9wj2KXlmbgqdCBs2Qv+WDZFHezCVgmvHd+juVBRkfPGPUhMOG6j/KMICHe/OjDKo1F1xD1Hc+z8Kk07z7+MPcPrAnX5EnY4r/Wbpuei6ENA1i0RO6x9t1O+YkTJFc8sVOJSo13+INW4d9l66huVsLLCKelqOGzkPWl8mYZ7FTlfRaFQTBv1SwUd2VGtD9BM/CTjeX9GJSsgvgfwlcfl6N0WvVGKegjy6cKbbjlymHux2IwWQmboY6sWacPue17hNVyLYla7eitXmB85RkP6GCVEnH60y8iwq/VwbZWkE0rWT995GbaORXRATMv/dtssLmZwSM2Wi7VzX5pGH6GNVYePsUn8ZPYZqLti/ACjeIV7gBKBdLXR/VUnrGRt7r5tD580QlGOOrH+X4B45k56Pn5YJLAshkJbWOIn8tUru+gQB9Ybs3hZwyg0qek9vjuLpHfyuuj+sjuov+mLCN43ykGWPEA8DSQRRRjA8aGc9IfvnV184KptN3MA/SKmGGW5zCF6SRXehyuEr2F30dT6uG+6z/1gwLy1ig637mTh78TdSl1tIx5K10BmtRTVNNlSjiRg/09xjACv/+7TnceXeTtOV1L2dNOGEuENoxwZPu8L/77S785roCBSLqROfBlZL/KLLxHB1LTgKiWehQdDxufTdxTFUQvQSJ9z0Dqb5CcVMRSak9cHOWC5L/M+XOy3pshA9pDT+ZOv0V86NgJuUelT9m8NKASCduUpiuYFis9rSFcmEJXXUWt4PVcROzdcqxeoIQKp2YsZV5r6VbIGJqxHaQOIla4zBIlBDK5UrhLMU2yphy0FPbaDEwyrE21qj3Zdi7gHqC5aQJOAKQzIAG66/0giooQdyhP0Fz4lTmm11CzZFIdnMeW6nG4WXz1tag8h1rjbab3GSlNGTkTpxatyfJSn/+iBn4Pg1ur/S147f/+jUmOOOYv2G2FksbR9GRbMJhUsRVgYVs4SQmvecmDvSrOI50+Xp3Pnu1OrGf1Gkq8+WQ+ihZr6R9Y8gslBAUEX5A+KKocf1XJWc0kN7Li8qVutJaGwzQXjCYX6Fr2ZjJ69w/pjPI7NNjlqJGkRtfy1vAkHF9KTeRqjBFPrBv2Wtq0R21Gm+BcK0ve3Zu+hdgHw3+TOBkWXBhbl5a6w+fEnPIvy8b38uG9X5Bvc7v8L7gVvDHMtmwZvNa1Dw8W7/95duXllfygT/IDtRDw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e2b9409f-1ec7-442d-8daf-08da5915e184 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jun 2022 14:52:54.0498 (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: iSi+tpCybxq+U0kNzD5Y/lheIZek6jv5/PF3lH8bFVwjPbEdEuxHhYymJHdlO5eAEDrR/RbmNhJqhjrHFkUAsQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3810 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org In a future change we will need to remember the entire tc-taprio config on all ports rather than just the base time, so use the taprio_offload_get() helper function to replace ocelot_port->base_time with ocelot_port->taprio. Signed-off-by: Vladimir Oltean --- v1->v2: none drivers/net/dsa/ocelot/felix_vsc9959.c | 23 +++++++++++++---------- include/soc/mscc/ocelot.h | 5 ++--- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c index dd9085ae0922..44bbbba4d528 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -1210,6 +1210,9 @@ static int vsc9959_qos_port_tas_set(struct ocelot *ocelot, int port, QSYS_TAG_CONFIG_INIT_GATE_STATE_M, QSYS_TAG_CONFIG, port); + taprio_offload_free(ocelot_port->taprio); + ocelot_port->taprio = NULL; + mutex_unlock(&ocelot->tas_lock); return 0; } @@ -1258,8 +1261,6 @@ static int vsc9959_qos_port_tas_set(struct ocelot *ocelot, int port, QSYS_TAG_CONFIG_SCH_TRAFFIC_QUEUES_M, QSYS_TAG_CONFIG, port); - ocelot_port->base_time = taprio->base_time; - vsc9959_new_base_time(ocelot, taprio->base_time, taprio->cycle_time, &base_ts); ocelot_write(ocelot, base_ts.tv_nsec, QSYS_PARAM_CFG_REG_1); @@ -1282,6 +1283,10 @@ static int vsc9959_qos_port_tas_set(struct ocelot *ocelot, int port, ret = readx_poll_timeout(vsc9959_tas_read_cfg_status, ocelot, val, !(val & QSYS_TAS_PARAM_CFG_CTRL_CONFIG_CHANGE), 10, 100000); + if (ret) + goto err; + + ocelot_port->taprio = taprio_offload_get(taprio); err: mutex_unlock(&ocelot->tas_lock); @@ -1291,17 +1296,18 @@ static int vsc9959_qos_port_tas_set(struct ocelot *ocelot, int port, static void vsc9959_tas_clock_adjust(struct ocelot *ocelot) { + struct tc_taprio_qopt_offload *taprio; struct ocelot_port *ocelot_port; struct timespec64 base_ts; - u64 cycletime; int port; u32 val; mutex_lock(&ocelot->tas_lock); for (port = 0; port < ocelot->num_phys_ports; port++) { - val = ocelot_read_rix(ocelot, QSYS_TAG_CONFIG, port); - if (!(val & QSYS_TAG_CONFIG_ENABLE)) + ocelot_port = ocelot->ports[port]; + taprio = ocelot_port->taprio; + if (!taprio) continue; ocelot_rmw(ocelot, @@ -1315,11 +1321,8 @@ static void vsc9959_tas_clock_adjust(struct ocelot *ocelot) QSYS_TAG_CONFIG_INIT_GATE_STATE_M, QSYS_TAG_CONFIG, port); - cycletime = ocelot_read(ocelot, QSYS_PARAM_CFG_REG_4); - ocelot_port = ocelot->ports[port]; - - vsc9959_new_base_time(ocelot, ocelot_port->base_time, - cycletime, &base_ts); + vsc9959_new_base_time(ocelot, taprio->base_time, + taprio->cycle_time, &base_ts); ocelot_write(ocelot, base_ts.tv_nsec, QSYS_PARAM_CFG_REG_1); ocelot_write(ocelot, lower_32_bits(base_ts.tv_sec), diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index 3737570116c3..ac151ecc7f19 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -670,6 +670,8 @@ struct ocelot_port { /* VLAN that untagged frames are classified to, on ingress */ const struct ocelot_bridge_vlan *pvid_vlan; + struct tc_taprio_qopt_offload *taprio; + phy_interface_t phy_mode; unsigned int ptp_skbs_in_flight; @@ -692,9 +694,6 @@ struct ocelot_port { int bridge_num; int speed; - - /* Store the AdminBaseTime of EST fetched from userspace. */ - s64 base_time; }; struct ocelot { From patchwork Tue Jun 28 14:52:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12898407 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 D2E8BCCA479 for ; Tue, 28 Jun 2022 14:53:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347409AbiF1OxB (ORCPT ); Tue, 28 Jun 2022 10:53:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347397AbiF1Ow6 (ORCPT ); Tue, 28 Jun 2022 10:52:58 -0400 Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30049.outbound.protection.outlook.com [40.107.3.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0237326DD; Tue, 28 Jun 2022 07:52:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bs9ySQAafDk+XqUyCuogWd4LK+822l2et/JlbwuwSv6j4rkUlrzltM1zx9Nps0Lh7ayK+5RxiQtC5aupjW1X2VsJ2N3O5dwTtxGQmyKb21u5y0cFar6QayiNzGHfaQwERucuOyppKxn8PCUbJelqsajzUCDCupJWW3b7RBxkE153TxvRx8EtOe6RnvhnBzvoJi72vOoD/XGfk4sneh17ZUMNQWIzu3L9fOSkWWkVS4+b/WGKlptDOObYy1lbUBXmwbRtmOjfZZdgEy4qaOmii2vsn18WDyehzXFtkVuf7Izuslcvlr+mET2XHtx7/NEj2CAWPDo6Sar2g7L09U93gg== 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=HDICeUUAwwEEWAaVrYL2+O0y30yQirKOLe+a3ijqBWA=; b=TKhYFLcOU1pQ+SDabvf6DtolZdc795gxJ46EBHSwbdm/WoH6L2eWL+95iHtIwMQSHfAKKddR0SestSD42T49wtQmbZKO3zpYvjja7GP9rdNpzeyjaGLkCN6rw8tumgZjlN1v7uv81q7s4PJBc76B62t+O831sma2i57YvpI0Wcaf0QdpLB7fAD4+qPoqEJDFlu09Jzea0TWiiyCMTU1KGR+fpJd71r0pXUXDdGKl+U5IrbDYxdxqXBV0g+SJwDpxqUKKVeUOCe2wTDD+IEyAS9tdYK6q14DS+zPmn5oYSHXcE3RHTIrA6yT3hL66nlhfgeglY67mQeRp2DwS/wylMg== 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=HDICeUUAwwEEWAaVrYL2+O0y30yQirKOLe+a3ijqBWA=; b=cbtSFGrdJMkqVnBey3GJSSGGaooAb+ZfUpwhNN9WDPTzXbu3G9vsBi5StZsnmwUa8383ZPYJbta4S9m+lVPJgzF4UYTR4KA5LKSWI0FM1sUP+uLB4WbJvfqj2TEQRYOUT51E8qjXY6JCpJnmsAT/PisXwlpTz2XUXSvXqpqqWmk= 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 AM0PR0402MB3810.eurprd04.prod.outlook.com (2603:10a6:208:e::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.18; Tue, 28 Jun 2022 14:52:55 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::94fe:9cbe:247b:47ea]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::94fe:9cbe:247b:47ea%7]) with mapi id 15.20.5373.018; Tue, 28 Jun 2022 14:52:55 +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 v2 net-next 2/4] net: dsa: felix: keep QSYS_TAG_CONFIG_INIT_GATE_STATE(0xFF) out of rmw Date: Tue, 28 Jun 2022 17:52:36 +0300 Message-Id: <20220628145238.3247853-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220628145238.3247853-1-vladimir.oltean@nxp.com> References: <20220628145238.3247853-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: LO4P265CA0104.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2c3::8) 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: bccabef0-e658-49c9-06f9-08da5915e286 X-MS-TrafficTypeDiagnostic: AM0PR0402MB3810:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QUiAbLuZxBXZ8O6FogDhm0xMPABP7tR4s4+v8xdmIhEUJIXGaspAHW/3SsXXErE2reItUS1zPwFJpWbz3aE8xY+/p1lQbIWBhq/gZvVAmvfMvefsk8tz4gqYEYuDT3FdfPSKF6G/FiNFlqnRBRFClX/QP3enagUIi5Id7X6i0FadmJ4mUFi57NJXvhPsrJJxiNGoQFpT8VDxXUgTdyyVVwL4zqglhtRWxTH9Iob6kXcxtYXCBQ/1h2EaMkrHtFlN7hyurk/E+2Yasp2Wu6tvv5hQUBf3r05EHLL5Y98E6/Gnh7yp1cMcrjRLVTWIXL5URfK6GDphbCUkD5xbzFesTonmHGtFr5LmdHw/aJle412h+7kmC7YCM8e4VoVksgbSyLGsjl43DXkxZQttkd+A+iI0qqpKqmZTro1Qxt+AgNfAD5mJ7NkzrHdTbO/kLYFDdWHtCoWXvmVzP16O2VmY+Vsr1EnQDJsnQvn7ZWeF9ATBvC6DvlqGfq2MAyygBWSCoNeYJsoXWm9u40xSzay/QNuJIpnamwOUINWIJyCqnSX+rMLVjLaWiuopc2sBFOhE1tKY04E8DCgKJCd8PgMigoW1Ys7dfDZVjS5ErABL34Trev49PHjl7Q+mHt0fPLRtnJbtt3dclJ74vIARf6RWLqcfidth+1Q0yHbY58TyAc3WjojzviiHQwBnHVpO4wxFNvj7HnQUjo8MmKBg1MdTpSD2QdFQweBo5MM8KBftFKnWye61YlWfH0FiP1Vq+XcRtk3+ptG4t/flRlqnfvPOSSzslVIMK2bkcoVUmaP0jOM= 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)(136003)(366004)(346002)(396003)(376002)(39860400002)(2616005)(38350700002)(38100700002)(41300700001)(54906003)(316002)(7416002)(44832011)(1076003)(26005)(66946007)(66476007)(6916009)(66556008)(8676002)(36756003)(4326008)(6486002)(86362001)(6512007)(2906002)(186003)(52116002)(8936002)(6666004)(478600001)(83380400001)(5660300002)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /cIFBp9BsAAhoWfX7YI963i7h6fW874K4G8CIR3jBrRqtdWRnJtMBQJJ3dmIIJHfpHwrLEYWTvHl7laqrbaXIJVrEoTziVIa/cIBMiDQFysq1vPu/7Ne43yrdG3zlGkvXnl+/SLKrSC+lz7Z8ColFqsBWJ0OR0QpHiibZMfktU61uJDHYiy/Ob6Qtba8kdxFm0Mwqhk1uStqZ8wmwQK2DvYMq3/bCfKpQelPO8n8nR2rr/GqVAj2lJW0q67qn0PCYI+EEspA4AEKx+9gy365/IdyY+fleOgy0YMBHqGCxQProsV1GS0TOFOUI3cK+IzWv9Iw23ey+qiWEyCEiR/oRmilNbZBoY7RY9LkrdFVO/gKzVBxOZJwn8juX6msAFow4tPc9fLPaerV8CIYh2hdnRWsSo4HyjE3IhtPIr/xJY1jKjypYB88TP1aMadfvR8JqcrhMSTxynmOaMHeBrdW0cznDfxuMC3pdzt1obGrdnKIzGluU0PvKgcO7r4vcum9H+u9Fx7dc2nOIhiF6GXoB9zIXy+AlbQ3ItNA/lwW1iE91kXcJvHiEDh5PT84WQJZCMy7krwzb2RRVEvJSA6UOxIFYoj/m11FlCFWrK/aoOFlr5I8QSIWrmCYjPpaQYGMeju8+trhwnC5RkwbepOTTI9YV82bQA12BiQCm8OKuhKfzHCpyMStvdbADmrg8Naim0oyqN2+eECQwpSaW4ocO28eMOjZOik4r08RP4gWoyOBjCjrMiNs38LPM21N7ZZKGyocoRJ4u3mBXDstIjb6jPqzmI9+Db4sqP0jMUIQHHS4FrC+OmZ6UanjpjvvqDO9GUJ33jqLC3ccjyADuGSOBEMV8Xu7dZb398qZEtbh5GrTa923XsTpoe0yNmSzNqVIiwvCCLjxO2S9l9AEikgkugghq0nsDN3zsloFhUnFvd/K5t3RRsO8Lnc4X1fyquLkmfIWSB8+tnledBW0W317KLp9SsX45IWUWFh9Q7p+UKdizir0jJMOgvvYfzXPvpiIzORuQOUzkXeUkkKbwIxrPW/PXoAf7AFNhKPzD71Q3v8ljP9Th3mzy1WVU4aa++OxS/vHsyiwXmOtZMaPjktmN2LyDNqN32QcWqjl+ccxM2PMwLwhbNDmvv2eeB7NduvVxNc8ES1Dd+zpyPO3MGu/MLKYMqmAOIrWTewDsP82Jal8OQL4rA3UhY9mV1oZIXdvuDOYRysLfLGORxSiEYid5DXyEa/BW5r8L12N4ksOu6/xv8EpJJkg0zk8cMlXNoUyyJEXqfpRBdXbWB2WBb6NjNsIoINkJ8Ml2n4E4WiN4/Gwl8+k9pAfx8FqB3orCPAZyRH0OWcvFvPhMOWFbGr/XrsvG1S1elXlAFavAuJGgDg21/wORVAyvvkzLN0qTNz21UMnCpGTiUaOsDwfCI0EMcgqHSX8Pjt9chrag6F01i0RffBsb8dxe4eJxtB0ZklEobmQVee6g7kkwqyoIRCRaRx40Zn1S4SNbkXzkciWUKD3+tN7/YdM3HSJJUaOo3o3BbtYkpJiNuQ64GjrT4zHOiqo+KzsfAW6LZTXyeP/j9FIRN3knSt4KJ6RgSrjxVis4x7u5BR0x9u1ABfifgTnQg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: bccabef0-e658-49c9-06f9-08da5915e286 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jun 2022 14:52:55.7528 (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: J1hYZJKvnur/+DFS5oGdkIXHD7H29P8sZTmLEZLuIX+MbJ1yKR8SNn3eZCOn7hgRnL7FW3wcBMgCEZ26lS+WEg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3810 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org In vsc9959_tas_clock_adjust(), the INIT_GATE_STATE field is not changed, only the ENABLE field. Similarly for the disabling of the time-aware shaper in vsc9959_qos_port_tas_set(). To reflect this, keep the QSYS_TAG_CONFIG_INIT_GATE_STATE_M mask out of the read-modify-write procedure to make it clearer what is the intention of the code. Signed-off-by: Vladimir Oltean --- v1->v2: none drivers/net/dsa/ocelot/felix_vsc9959.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c index 44bbbba4d528..7573254274b3 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -1204,10 +1204,7 @@ static int vsc9959_qos_port_tas_set(struct ocelot *ocelot, int port, mutex_lock(&ocelot->tas_lock); if (!taprio->enable) { - ocelot_rmw_rix(ocelot, - QSYS_TAG_CONFIG_INIT_GATE_STATE(0xFF), - QSYS_TAG_CONFIG_ENABLE | - QSYS_TAG_CONFIG_INIT_GATE_STATE_M, + ocelot_rmw_rix(ocelot, 0, QSYS_TAG_CONFIG_ENABLE, QSYS_TAG_CONFIG, port); taprio_offload_free(ocelot_port->taprio); @@ -1315,10 +1312,8 @@ static void vsc9959_tas_clock_adjust(struct ocelot *ocelot) QSYS_TAS_PARAM_CFG_CTRL_PORT_NUM_M, QSYS_TAS_PARAM_CFG_CTRL); - ocelot_rmw_rix(ocelot, - QSYS_TAG_CONFIG_INIT_GATE_STATE(0xFF), - QSYS_TAG_CONFIG_ENABLE | - QSYS_TAG_CONFIG_INIT_GATE_STATE_M, + /* Disable time-aware shaper */ + ocelot_rmw_rix(ocelot, 0, QSYS_TAG_CONFIG_ENABLE, QSYS_TAG_CONFIG, port); vsc9959_new_base_time(ocelot, taprio->base_time, @@ -1337,11 +1332,9 @@ static void vsc9959_tas_clock_adjust(struct ocelot *ocelot) QSYS_TAS_PARAM_CFG_CTRL_CONFIG_CHANGE, QSYS_TAS_PARAM_CFG_CTRL); - ocelot_rmw_rix(ocelot, - QSYS_TAG_CONFIG_INIT_GATE_STATE(0xFF) | + /* Re-enable time-aware shaper */ + ocelot_rmw_rix(ocelot, QSYS_TAG_CONFIG_ENABLE, QSYS_TAG_CONFIG_ENABLE, - QSYS_TAG_CONFIG_ENABLE | - QSYS_TAG_CONFIG_INIT_GATE_STATE_M, QSYS_TAG_CONFIG, port); } mutex_unlock(&ocelot->tas_lock); From patchwork Tue Jun 28 14:52:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12898408 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 EBBE7C43334 for ; Tue, 28 Jun 2022 14:53:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347416AbiF1OxE (ORCPT ); Tue, 28 Jun 2022 10:53:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347381AbiF1OxB (ORCPT ); Tue, 28 Jun 2022 10:53:01 -0400 Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30051.outbound.protection.outlook.com [40.107.3.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B8B6326DD; Tue, 28 Jun 2022 07:53:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CfP0qAGE9hgqk42vodZbTytKzukEkZc/GsLcK0Vij2WBygddZG0MYdLd5YuEkpOTWqacXSNruVBcOYL75+wRWWGQEHyiX1f5/J0O5gQpv5o00Cxk4PZ2mV45+UTQv4Mc5lC/LUjIvnaMeUN2magTfgow0FSU3h+hftruTtksFDppX9exW/q3gekfy5yCk9TH7fUPzuQqW90pKdOc5IKvZOJLuEy1V++iT4QiSlXPs2T4CPVax1hZNnVJT5hAl4Y3xNAcEemf+N4JaxOzucbfrhtMqxajeVoM0TDAQraAgJBX10DPKyUuKMZ9PCn3OZzqYmUD2OYCqBcXf/6nGRX3AQ== 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=KmLBoKNeINzsXLr7nlnE3iJlHMzIIU90dWna5z0GasQ=; b=gmitkTw5oTdnHBLkAzCa/qsbRSpIftsVzEv/KxBH9H5QjDT38446HpSV7vJceH04WyBV5kor7jCkxs3JgmjTcEV3p9jnCQgjoScMKoFjPWUgIYyXwMXlnKcpV6GzZMX4vTwJNMEkjHJEZf9R9l9cBQSOu877iN2q907omUK0WceeTbQsWr8wNzNEwUOlEWev7MgF4SWsRG5m6K28NXm3Kru17TlSUqZXNyqKipinvuOGedn6jL5NoJ0RjD5lmywcYrX30f/ZeGm5A557aQOVmRckxx6sWgnpXrnlgzbAFlvGtcli00RCSddOhGZM2syaY7k+MkMO5LHjFJhDEE4rVg== 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=KmLBoKNeINzsXLr7nlnE3iJlHMzIIU90dWna5z0GasQ=; b=UcJkk/2Ao6/zxiB3Jt3iSLgJQTv1bVY7LETSSYzbfT/bPRnLGYNu8P4nMB+Y6DXL6QRc0anlKyBekySR483i/p6MsLqSLf1w17SDqZYskNlC5SE/6/X0jxzi7m70TEz9i6FhtQi2RPczUdygJyBdKfEPfkdlRrbW8aEoTjxLm0Q= 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 AM0PR0402MB3810.eurprd04.prod.outlook.com (2603:10a6:208:e::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.18; Tue, 28 Jun 2022 14:52:57 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::94fe:9cbe:247b:47ea]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::94fe:9cbe:247b:47ea%7]) with mapi id 15.20.5373.018; Tue, 28 Jun 2022 14:52:57 +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 v2 net-next 3/4] net: dsa: felix: drop oversized frames with tc-taprio instead of hanging the port Date: Tue, 28 Jun 2022 17:52:37 +0300 Message-Id: <20220628145238.3247853-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220628145238.3247853-1-vladimir.oltean@nxp.com> References: <20220628145238.3247853-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: LO4P265CA0104.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2c3::8) 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: 9b3221b4-a95b-4fe3-44d7-08da5915e38c X-MS-TrafficTypeDiagnostic: AM0PR0402MB3810:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IX+T5RT10ItYyzgCkRAr7jJRiAcTrE7Uc0YjRbZYGqOfpFhwfCmsxshUQfer/xO9679f2CmdNH3RcQQHXROlna5plKzfKMhZPTALyTRM9Ww3kE9JfE7vr8wH/scjIsqiuKyltQOgw7dcDr09ohq+KWUcw6i6mSWiQkDpRqH3u0pajwL2w3p6Y1n+R8003JYla2tFC+Ah1caDDQQ/OwzFBGX0mFqYQcyT4dCbLetHecmLELVzjx0DpVjWxL0CKu3VJIWNoE50S7LoQZ2rrF92SIY0++nsSkc1VdMEiSRT8JiHi0L8hv4PEmaHLKTNnVi493JFQZFi3vF/o3+3UAFjmg5nl5IOlqmaiHaPNIiLA2Val4ktDTiPe+FDHV+9WAdA85PHCv1xWcdNkYf+eVv2d92y1MCUhnugQ/N5KgLPK1tmsENjXO5k+B9bNJ7SQtFrVYoDD0WWcCZkyMoCxs2nnuy3ABbdjyRg6vr975FwDx00jZ2obPIX46pZJUaigpP4kUQj7xsC4oFTLkM4evYki7iPXA2XYFNQNoI+gCDRJBv5KwEpVMO2d8haRIW8LBPGGkF2HjNwj2y/pHjSpzVkoS+vJkDnB7WnXLuZHmG8pneNX2kyMXLOAiAQSTG2VKcLAQ9Ip/E72gIcyF4aQKHd7wfoDHSkYPVu7RhulbnumTtFqXlQFTgIGVWnLG2GxWJNDW2zyHPcWZsLnUGWx0EfvnrHA48C5p4kZJTBo32uKE0UbLB+2RQKYNxdfwWkwgnIfqGvTUF6DQmYL7kvx94deaCUhxiBT+qj2jFrz1yXla4= 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)(136003)(366004)(346002)(396003)(376002)(39860400002)(2616005)(38350700002)(38100700002)(41300700001)(54906003)(316002)(7416002)(44832011)(1076003)(26005)(66946007)(66476007)(6916009)(66556008)(8676002)(36756003)(4326008)(6486002)(86362001)(6512007)(2906002)(186003)(52116002)(8936002)(6666004)(478600001)(83380400001)(5660300002)(6506007)(30864003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pfuelfM7mjUWhr3uGZITT6yIKcEkNHjCj00miCTzNJ/bMRdOq7ql8lp9RWWZlVQ+si8eio5+WuQwbSOTIh2Q1SkGpwcpp4k6Q+fRVuOKKcYv6IgAgLooHI5tEVk3AQ+LO/GXYx9XzCHrLXOhkf1ySWs8dzm7YpSo8y1rbRV0kL1jaUwVqMb43FYpAoBamBzHejp+zN9mt9cyXce7ufHHyQL7JrI859+7h/Cc6GB8r/8J6FAsEo2+8TuE8Zic4xFEy3b2ahrQe/5lCkT4vzYETApvau7u0b8da7V6011+XSs3YfjCwXDKro0w51vr06u3wzWB9D9v/RWL9Ar35TFPMjp/AdMcIacTaJw/kQhYfX0NyXqftLdS5oqKBAHFMSomU+MR+CuPfaN6giF04niwdUoGhJHtQa1/V+sn/Tyz9pFb2P8WHAF7RBTw1yGXaLoFo5Ts8ZzQUtu9Ij1x7XqRaGKBf0jhAZXumXSN+JMjgnGDFqPEHBJ5PARiAa7JWq7er7rxMosDG0JOnh2SLKPAzUp7jdmf2iO7s8/8c9LRviHXjTNxgFBaiLqqlEgDwuDWrVSG3X3qUTq9clW357IWRwM0rD/Kq6tAhQKBADIyjA7vQgRx6jmw1v4E3UxoeKqlVmjhtQHnITqnVSvdnFW/71CjMjv40B/MG50cYHDHbmCj6g+BdIEmGs8jIg0MnkDdO8wNKi/3eWhLocJMi/QdqaJCCOYRw/XUxJimZBeOrJ7JiskSulOhHZos1G2eLmOO54QoWIn9DWpoQH9nHHSrw+vMcIlrV2GSfQ/UDyEgV0M14n8eExtYKe6NYDF+UIB9Ky8DQI9yaH6TH3aC6xtCNKQir6v3QTalvUU6S4VOy0ai4oQZBrbM+z0gn1WBaI3EfpvqB5SF8wdbFfWWpGbTwvmtP4vZOcbAW7CKFUne96mWGRxTTX22BsOgZC0HRbA9KbM+5S1N0gMk/XOhjaZVogrH+XL9GJUPvcpCZL91p5vvyA2QVTCpJ1jZj+lfNYcLdhPym6PoYkxvYOAxT0pZBDLTW/AqIForyjTP+Pwg9nZ3DYinq9nPdBle8UVLlomJX/l5PojoGEvvEPkSDOXjVs04qxGPAbZuEjZ7JX4mzs7Q2DcaVuNKfo0yGjp/A1QXThLZao8bwoQQTCSxUyWKM8lYifDJs+zP+PX9XetY1LFZl3EvEP/8BYcibNCtDsrolGuygWE7q4PjcImPpdIvJVSgMzHrcZ06bFktIgfHvUz1YCJqDv8F2UXh5wp14kkZy+/m/BKUQGmmjX2W0avKxMbrP7BAoHkwYhclo/aoy/65rq3o7QyARUUcM5XON9APehCxr64q3XHlofzFU+Rrl3vD5DdQLOrgUZKzVf+0tEQ1S/bNqrp/Xrmp8T8ywHAK8mt4+8JHnQxUT6BhgfGRcFwhziTeYOX5NaZ7cR2YWTMRc+OPRvOUxgSgdOqBCxge8o1FZXkgfRbBXyQWMJEWlotLmI8ou9/1w7vmKJ9429EbEHReTcm2U8AJQ0xm0rCGxOMza1truhV6V8h46uwk5ZpIep0mcCcCh3+tqAyY0VMRttO0IUNWkxbfxSeqiRPARGoDVA8GZNuK8J4cZ5mU1g== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9b3221b4-a95b-4fe3-44d7-08da5915e38c X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jun 2022 14:52:57.4714 (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: ALEAH5LC89btdT56yA3x0x+K8bVkE7EfKXLPILSDcO7ClDww6TwQEo+RJVqnIvphujCDjIu75Sr7Qoe3qbeFTg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3810 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Currently, sending a packet into a time gate too small for it (or always closed) causes the queue system to hold the frame forever. Even worse, this frame isn't subject to aging either, because for that to happen, it needs to be scheduled for transmission in the first place. But the frame will consume buffer memory and frame references while it is forever held in the queue system. Before commit a4ae997adcbd ("net: mscc: ocelot: initialize watermarks to sane defaults"), this behavior was somewhat subtle, as the switch had a more intricately tuned default watermark configuration out of reset, which did not allow any single port and tc to consume the entire switch buffer space. Nonetheless, the held frames are still there, and they reduce the total backplane capacity of the switch. However, after the aforementioned commit, the behavior can be very clearly seen, since we deliberately allow each {port, tc} to consume the entire shared buffer of the switch minus the reservations (and we disable all reservations by default). That is to say, we allow a permanently closed tc-taprio gate to hang the entire switch. A careful inspection of the documentation shows that the QSYS:Q_MAX_SDU per-port-tc registers serve 2 purposes: one is for guard band calculation (when zero, this falls back to QSYS:PORT_MAX_SDU), and the other is to enable oversized frame dropping (when non-zero). Currently the QSYS:Q_MAX_SDU registers are all zero, so oversized frame dropping is disabled. The goal of the change is to enable it seamlessly. For that, we need to hook into the MTU change, tc-taprio change, and port link speed change procedures, since we depend on these variables. Frames are not dropped on egress due to a queue system oversize condition, instead that egress port is simply excluded from the mask of valid destination ports for the packet. If there are no destination ports at all, the ingress counter that increments is the generic "drop_tail" in ethtool -S. The issue exists in various forms since the tc-taprio offload was introduced. Fixes: de143c0e274b ("net: dsa: felix: Configure Time-Aware Scheduler via taprio offload") Reported-by: Richie Pearn Signed-off-by: Vladimir Oltean --- v1->v2: - reword commit message regarding "drop_tail" counter - hardcode 1000 rather than PSEC_PER_NSEC to eliminate dependency on include/linux/time64.h change (to be fixed up later) drivers/net/dsa/ocelot/felix.c | 9 ++ drivers/net/dsa/ocelot/felix.h | 1 + drivers/net/dsa/ocelot/felix_vsc9959.c | 201 +++++++++++++++++++++++++ 3 files changed, 211 insertions(+) diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index 3e07dc39007a..859196898a7d 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -1553,9 +1553,18 @@ static void felix_txtstamp(struct dsa_switch *ds, int port, static int felix_change_mtu(struct dsa_switch *ds, int port, int new_mtu) { struct ocelot *ocelot = ds->priv; + struct ocelot_port *ocelot_port = ocelot->ports[port]; + struct felix *felix = ocelot_to_felix(ocelot); ocelot_port_set_maxlen(ocelot, port, new_mtu); + mutex_lock(&ocelot->tas_lock); + + if (ocelot_port->taprio && felix->info->tas_guard_bands_update) + felix->info->tas_guard_bands_update(ocelot, port); + + mutex_unlock(&ocelot->tas_lock); + return 0; } diff --git a/drivers/net/dsa/ocelot/felix.h b/drivers/net/dsa/ocelot/felix.h index 9e07eb7ee28d..deb8dde1fc19 100644 --- a/drivers/net/dsa/ocelot/felix.h +++ b/drivers/net/dsa/ocelot/felix.h @@ -53,6 +53,7 @@ struct felix_info { struct phylink_link_state *state); int (*port_setup_tc)(struct dsa_switch *ds, int port, enum tc_setup_type type, void *type_data); + void (*tas_guard_bands_update)(struct ocelot *ocelot, int port); void (*port_sched_speed_set)(struct ocelot *ocelot, int port, u32 speed); struct regmap *(*init_regmap)(struct ocelot *ocelot, diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c index 7573254274b3..27d8b56cc21c 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -1127,9 +1127,199 @@ static void vsc9959_mdio_bus_free(struct ocelot *ocelot) mdiobus_free(felix->imdio); } +/* Extract shortest continuous gate open intervals in ns for each traffic class + * of a cyclic tc-taprio schedule. If a gate is always open, the duration is + * considered U64_MAX. If the gate is always closed, it is considered 0. + */ +static void vsc9959_tas_min_gate_lengths(struct tc_taprio_qopt_offload *taprio, + u64 min_gate_len[OCELOT_NUM_TC]) +{ + struct tc_taprio_sched_entry *entry; + u64 gate_len[OCELOT_NUM_TC]; + int tc, i, n; + + /* Initialize arrays */ + for (tc = 0; tc < OCELOT_NUM_TC; tc++) { + min_gate_len[tc] = U64_MAX; + gate_len[tc] = 0; + } + + /* If we don't have taprio, consider all gates as permanently open */ + if (!taprio) + return; + + n = taprio->num_entries; + + /* Walk through the gate list twice to determine the length + * of consecutively open gates for a traffic class, including + * open gates that wrap around. We are just interested in the + * minimum window size, and this doesn't change what the + * minimum is (if the gate never closes, min_gate_len will + * remain U64_MAX). + */ + for (i = 0; i < 2 * n; i++) { + entry = &taprio->entries[i % n]; + + for (tc = 0; tc < OCELOT_NUM_TC; tc++) { + if (entry->gate_mask & BIT(tc)) { + gate_len[tc] += entry->interval; + } else { + /* Gate closes now, record a potential new + * minimum and reinitialize length + */ + if (min_gate_len[tc] > gate_len[tc]) + min_gate_len[tc] = gate_len[tc]; + gate_len[tc] = 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 + * than one MTU sized frame, update QSYS_QMAXSDU_CFG to enable oversized frame + * dropping, such that these won't hang the port, as they will never be sent. + */ +static void vsc9959_tas_guard_bands_update(struct ocelot *ocelot, int port) +{ + struct ocelot_port *ocelot_port = ocelot->ports[port]; + u64 min_gate_len[OCELOT_NUM_TC]; + int speed, picos_per_byte; + u64 needed_bit_time_ps; + u32 val, maxlen; + u8 tas_speed; + int tc; + + lockdep_assert_held(&ocelot->tas_lock); + + val = ocelot_read_rix(ocelot, QSYS_TAG_CONFIG, port); + tas_speed = QSYS_TAG_CONFIG_LINK_SPEED_X(val); + + switch (tas_speed) { + case OCELOT_SPEED_10: + speed = SPEED_10; + break; + case OCELOT_SPEED_100: + speed = SPEED_100; + break; + case OCELOT_SPEED_1000: + speed = SPEED_1000; + break; + case OCELOT_SPEED_2500: + speed = SPEED_2500; + break; + default: + return; + } + + picos_per_byte = (USEC_PER_SEC * 8) / speed; + + val = ocelot_port_readl(ocelot_port, DEV_MAC_MAXLEN_CFG); + /* MAXLEN_CFG accounts automatically for VLAN. We need to include it + * manually in the bit time calculation, plus the preamble and SFD. + */ + maxlen = val + 2 * VLAN_HLEN; + /* Consider the standard Ethernet overhead of 8 octets preamble+SFD, + * 4 octets FCS, 12 octets IFG. + */ + needed_bit_time_ps = (maxlen + 24) * picos_per_byte; + + dev_dbg(ocelot->dev, + "port %d: max frame size %d needs %llu ps at speed %d\n", + port, maxlen, needed_bit_time_ps, speed); + + vsc9959_tas_min_gate_lengths(ocelot_port->taprio, min_gate_len); + + for (tc = 0; tc < OCELOT_NUM_TC; tc++) { + u32 max_sdu; + + if (min_gate_len[tc] == U64_MAX /* Gate always open */ || + min_gate_len[tc] * 1000 > needed_bit_time_ps) { + /* Setting QMAXSDU_CFG to 0 disables oversized frame + * dropping. + */ + max_sdu = 0; + dev_dbg(ocelot->dev, + "port %d tc %d min gate len %llu" + ", sending all frames\n", + port, tc, min_gate_len[tc]); + } else { + /* 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. + */ + max_sdu = div_u64(min_gate_len[tc] * 1000, + 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 + */ + if (!max_sdu) + max_sdu = 1; + /* Take L1 overhead into account, but just don't allow + * max_sdu to go negative or to 0. Here we use 20 + * because QSYS_MAXSDU_CFG_* already counts the 4 FCS + * octets as part of packet size. + */ + if (max_sdu > 20) + max_sdu -= 20; + dev_info(ocelot->dev, + "port %d tc %d min gate length %llu" + " ns not enough for max frame size %d at %d" + " Mbps, dropping frames over %d" + " octets including FCS\n", + port, tc, min_gate_len[tc], maxlen, speed, + 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; + } + } + + ocelot_write_rix(ocelot, maxlen, QSYS_PORT_MAX_SDU, port); +} + static void vsc9959_sched_speed_set(struct ocelot *ocelot, int port, u32 speed) { + struct ocelot_port *ocelot_port = ocelot->ports[port]; u8 tas_speed; switch (speed) { @@ -1154,6 +1344,13 @@ static void vsc9959_sched_speed_set(struct ocelot *ocelot, int port, 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); + + mutex_unlock(&ocelot->tas_lock); } static void vsc9959_new_base_time(struct ocelot *ocelot, ktime_t base_time, @@ -1210,6 +1407,8 @@ static int vsc9959_qos_port_tas_set(struct ocelot *ocelot, int port, taprio_offload_free(ocelot_port->taprio); ocelot_port->taprio = NULL; + vsc9959_tas_guard_bands_update(ocelot, port); + mutex_unlock(&ocelot->tas_lock); return 0; } @@ -1284,6 +1483,7 @@ static int vsc9959_qos_port_tas_set(struct ocelot *ocelot, int port, goto err; ocelot_port->taprio = taprio_offload_get(taprio); + vsc9959_tas_guard_bands_update(ocelot, port); err: mutex_unlock(&ocelot->tas_lock); @@ -2303,6 +2503,7 @@ static const struct felix_info felix_info_vsc9959 = { .port_modes = vsc9959_port_modes, .port_setup_tc = vsc9959_port_setup_tc, .port_sched_speed_set = vsc9959_sched_speed_set, + .tas_guard_bands_update = vsc9959_tas_guard_bands_update, .init_regmap = ocelot_regmap_init, }; From patchwork Tue Jun 28 14:52:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12898409 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 D0BB0C43334 for ; Tue, 28 Jun 2022 14:53:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347450AbiF1Oxf (ORCPT ); Tue, 28 Jun 2022 10:53:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347415AbiF1OxE (ORCPT ); Tue, 28 Jun 2022 10:53:04 -0400 Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30051.outbound.protection.outlook.com [40.107.3.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C42532EC8; Tue, 28 Jun 2022 07:53:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LldfNQVqdgM/t3SdO6navghocMhELmF00Jhra9J/q4Zbd23meDm8KPO2m9RbHR5FooqqDmx/5KbCqYl43MhDGPl1S2pf3SUiNZGlbn/HE/yFKd+cKvbpKYnFwHjNlDbz8ldqT8CsTTsEEpNrhxSwfY0Yt16XmVFJPZ7GVt4YsygAflmsEZ24YkiiGHR8OTd3CUHsWiLgbP3YQFzKcXizp8y5cCI8KVyQXbydXbm8j10UO6YjCQNU+QNK2d9vB0JpM4Qab/J57H/0nnArD2KDcBV+eKMYZj2eF3TJ6mhpLkn9oJmZw5GHnqWCGRUG/oIXhZErSqxpfJYCNYsNpdkU0Q== 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=fYUoBVQCi7erbsZejismTN36Y+bW2Za8NS4F81gaox8=; b=kvnK+bLHn/GWGCcJ4mLjzv4GZALfKqOWxhkztLrQXi90/h4HJvF66YEWsjmxU8qugEh9Q7BfXeD8JEVjQy8OpmgkEEuf+GgRs27LaMavrl8r6aBs2c/90VD6c++Q6r6lRndgAYYG6XnmxRBzy8xpx+mSM4gwlNiMq8kc/wrJdzwAHTF0Yo+mRtqI0snZz2WelllgpNV+Lrjqs7FrhgWhKfdbxCsZ52icwGI6oqiRT7I+QS9yQ7RP9Ps3AxZpFGEiE/8bdVHmmF4+YAKHAhTg/3wfhBbRWx6qm6Pr3o3d0AjRvm1IeZzS77ptOTckeQucOCLnB5eOaevTHFIpVziJcQ== 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=fYUoBVQCi7erbsZejismTN36Y+bW2Za8NS4F81gaox8=; b=DE6uYpkGJzzz/OEDvVehss9/wyQaGz3/4NlnpwqIJm+BOXfW5N8Vn1/RtR2JgCyIUAiZas2MoDpAErcoW+2vywDliAlGS8hgxDPQv4pWLrmQgvCLQ1k6rKq8/bPh0Bx1w3dosdY5i4MJ3tBlpYenSDq7zkWa7M+qQTNAkW/WX90= 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 AM0PR0402MB3810.eurprd04.prod.outlook.com (2603:10a6:208:e::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.18; Tue, 28 Jun 2022 14:52:59 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::94fe:9cbe:247b:47ea]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::94fe:9cbe:247b:47ea%7]) with mapi id 15.20.5373.018; Tue, 28 Jun 2022 14:52:59 +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, Andy Lutomirski , Thomas Gleixner , Vincenzo Frascino Subject: [PATCH v2 net-next 4/4] time64.h: consolidate uses of PSEC_PER_NSEC Date: Tue, 28 Jun 2022 17:52:38 +0300 Message-Id: <20220628145238.3247853-5-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220628145238.3247853-1-vladimir.oltean@nxp.com> References: <20220628145238.3247853-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: LO4P265CA0104.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2c3::8) 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: 869e8d27-b5ab-43b8-1e72-08da5915e4af X-MS-TrafficTypeDiagnostic: AM0PR0402MB3810:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tacW+2JsiHe4YaqmzgwGmMTk21xZMIdq51DYF/Ea8WPLOHSKdNNI8FFI956s8tAkBy6iqmUyi7YSAGT7JASfupWbT4maPi6SQhKYbimO12x7Hi/pMupu8Mx10j3BXQrMjFZ+fzTT53xS7v1NwtfUGQLwW3Xc6mU4IPSpTAJfldvXne7Gs9kvIePlJvPc8vEqMx+MXAZT75tAG1DB8JdsJX1BbfUFMs0czEW7cPaU582Vf3cICUhdtk2vtCzvKIbGUkyda7WlqB+uWc/1vYgFdvsBsPFxP/HtUyQ+p5QgS/QOWQKzMat3hXWvwq8oIyeC2CXqLdYs0zktcqvTaNXEUx4R9L9rWpCQ1sCJzAsGRF+umM2HNDu325pUhUfhQGN55WA0BCyLfAzqswEpDKwoK+tsV4/NyAXdIJ0kbr+K8Skb+A8drzlftw9Tk4WvZX5lA0VCvRZfhKS8dFefAEwUAacb8U1EN1gH0Cz/o4/RdUA9GZXtxAI+wAcOUOVmPeFgkB+MQXqIdnMCU8jF225D3rynUX0cyGuszSVuBo7wkUreWIGghcLNVB87U1qyizgMyRtNhitUyKbCeSPzMeNFwKFL5f8s9ZEv9NQaM7zJlpruZea7AkDI4MD+QaOg/tkbRkQ9mdteDRQCPEnUqEg9ECWqw6bMNpU/U1iM3bhxdwbrgWtSqZiGHBTNO+2ijR86epvKUL3xeiJuXyL0ap71ukoO2HMR/qhl9oNWiV5bWM83MEDEmy3fLj5mDsnNFPIx9xiL9cHXZrk8qwNMZfJlArx4mQFpEd2ZI/edlnaX0Bs= 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)(136003)(366004)(346002)(396003)(376002)(39860400002)(2616005)(38350700002)(38100700002)(41300700001)(54906003)(316002)(7416002)(44832011)(1076003)(26005)(66946007)(66476007)(6916009)(66556008)(8676002)(36756003)(4326008)(6486002)(86362001)(6512007)(2906002)(186003)(52116002)(8936002)(6666004)(478600001)(83380400001)(5660300002)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YPE5Wgck2B8rSBICxGbiE+Ngw+MsGjNpg/i8E1F/Unnzv6slWp7xHKXJgieuQTf3ISUTjTndk/Dht8gPkDoE0RG8SCDbuCd7My8WpkXzBiySPCfUr8xiJ94tj1M2T8YyMsDXWGWkTQYVm8Ry2dLdGGB+yWGp1Rtw+fanz8ZMllAMugGJrCdlxeBWKUx5eH9/TVyqrRq2H2UOicDqzyN2BOngLc86rLPwYMgWWwtB+2CGQBR+6wTC4VFvAA3cf0RzitGfFWUAQcglSCrLBSBF7ozfakIZL9h0/c43QvL+AY1pNhWn1+XoR6PSJC/vfgbS07ax6m+QeK4+BWZvsCuJRAL83ReOR59Qe+k0pYTX3PHeUDSFCNYcYG0TsjVSrsMqPzihQW/3G6qEiNYOs7z8hukZXu4FnFnsFVdswrV73MK6Ecxarm89ICJFg+l4drIeNcyoyL97TsgjnM7Y3uEIsEdeeiASBiFkF+qd7qs/XQimQFHwHcaKIpR+sIjRX6LJpTZ+eMSrMpms559dv5gtdIhplQi3IlW3exd8vdrwCqxF+0R7ixS9KvLDho1fmAjtP4qRR7WC1aF6+yYC4IIO292X+RMGskaGcbEmHKpIp3nnUmgyeb8wumNzW2vo1S73I2lfpsvIlf3PINNolSM3qM5rMvLHVAzpVJO3RU3GkUU8ah/iuMJKzPZ/14sCYu2heiXBN82MU2+4+Fsn/GC/F5l64cRq3YVDSfGTqBZMKYlDSJIXyZFtEfF4y9MQTMRSA1bxxYrLuDSO0h/+qGAC4cMqV0lrDgFJ8zeLegnl/s99PAu0JS/Q0KVSmy69R0+IMbY/yzZ9UVOERMwyHxzdvRNrfZJZVKPtcB4haBYFzz9edIfcwtOBsan4BA8g/CTlEl0TQieHcN6qmXwNCBg85WqVBzv5YYh34pYd4lxmvyyaSVHo20xg8SWIcGRRbx5BMbM61IC3uhBjr3zextLz+WJ5u/1XmKCvI5JjQ2X3eN0eAIxyTyWXCPvJPVaiGYhxaO1xnSEh5f8CHjGOQvcvZVJsg1ZlFYCPCUvmuQJlBIO2GwQcI8CSx4kMsmmrWqbudBNW/GgQPFihTuz037+ugvwn8YNl8dtBI5fUnPzOZts6U263Gm+iFBOsfDLXCzBsFgwiX5Ef3qPb1PIcf4dKZRDAbuupZY1hQ19GEYLvD2R0tOCFaqe+VUY2dBoYalUjqJ4ujU11L1osVHhz6uLPCb+Efb2dpAzet2QqJJHwni5ZzbnYMoPtLARzk5Kk7pOvAKcZG+HHQS6+7BAkVUY1qC4leY47ktMivS+ARX7SHDuYCDIMbcCCVerRZguvpiJP9GAQjD5B7X4iky3QcQuRVCqwCnOYXHH77g9o2W9SZey4D3DZRKQIeeJzNe2GswJBmEcWU5aY5PPx/ntuK+V5WOcuswtbBvwODNp3A1btPvz5bwusLfNL7qLK14rdYRKmFTSYDInvGztr3K2EKUGHyblDoEKQ09c+o/jTb9cjksvbJBXPIfszB09QN2VCHw6nIoexuSD1Enrid+VCc4ap92mesvLo18FEDU3WCgGEDhDHLmaJABG9DEWTVNgylbG7GaHfXF/ELtQmXyfjKyugNA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 869e8d27-b5ab-43b8-1e72-08da5915e4af X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jun 2022 14:52:59.3620 (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: CzLbYX8HpX6ySvUvS8f860hQY8o5H/YFtsS6uyhp50XRdINSkxyuOQnLvCWKk/ttYuZFoO+ZVP9F645nhIhPsw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3810 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Time-sensitive networking code needs to work with PTP times expressed in nanoseconds, and with packet transmission times expressed in picoseconds, since those would be fractional at higher than gigabit speed when expressed in nanoseconds. Convert the existing uses in tc-taprio and the ocelot/felix DSA driver to a PSEC_PER_NSEC macro. This macro is placed in include/linux/time64.h as opposed to its relatives (PSEC_PER_SEC etc) from include/vdso/time64.h because the vDSO library does not (yet) need/use it. Cc: Andy Lutomirski Cc: Thomas Gleixner Cc: Vincenzo Frascino Signed-off-by: Vladimir Oltean Reviewed-by: Vincenzo Frascino # for the vDSO parts --- v1->v2: - move PSEC_PER_NSEC to include/linux/time64.h - add missing include of linux/time.h drivers/net/dsa/ocelot/felix_vsc9959.c | 5 +++-- include/linux/time64.h | 3 +++ net/sched/sch_taprio.c | 5 +++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c index 27d8b56cc21c..28bd4892c30a 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "felix.h" #define VSC9959_NUM_PORTS 6 @@ -1235,7 +1236,7 @@ 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] * 1000 > needed_bit_time_ps) { + min_gate_len[tc] * PSEC_PER_NSEC > needed_bit_time_ps) { /* Setting QMAXSDU_CFG to 0 disables oversized frame * dropping. */ @@ -1249,7 +1250,7 @@ static void vsc9959_tas_guard_bands_update(struct ocelot *ocelot, int port) * frame, make sure to enable oversize frame dropping * for frames larger than the smallest that would fit. */ - max_sdu = div_u64(min_gate_len[tc] * 1000, + max_sdu = div_u64(min_gate_len[tc] * PSEC_PER_NSEC, picos_per_byte); /* A TC gate may be completely closed, which is a * special case where all packets are oversized. diff --git a/include/linux/time64.h b/include/linux/time64.h index 81b9686a2079..2fb8232cff1d 100644 --- a/include/linux/time64.h +++ b/include/linux/time64.h @@ -20,6 +20,9 @@ struct itimerspec64 { struct timespec64 it_value; }; +/* Parameters used to convert the timespec values: */ +#define PSEC_PER_NSEC 1000L + /* Located here for timespec[64]_valid_strict */ #define TIME64_MAX ((s64)~((u64)1 << 63)) #define TIME64_MIN (-TIME64_MAX - 1) diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index b9c71a304d39..0b941dd63d26 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -176,7 +177,7 @@ static ktime_t get_interval_end_time(struct sched_gate_list *sched, static int length_to_duration(struct taprio_sched *q, int len) { - return div_u64(len * atomic64_read(&q->picos_per_byte), 1000); + return div_u64(len * atomic64_read(&q->picos_per_byte), PSEC_PER_NSEC); } /* Returns the entry corresponding to next available interval. If @@ -551,7 +552,7 @@ static struct sk_buff *taprio_peek(struct Qdisc *sch) static void taprio_set_budget(struct taprio_sched *q, struct sched_entry *entry) { atomic_set(&entry->budget, - div64_u64((u64)entry->interval * 1000, + div64_u64((u64)entry->interval * PSEC_PER_NSEC, atomic64_read(&q->picos_per_byte))); }