From patchwork Tue Sep 27 23:47:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12991489 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 04BA9C54EE9 for ; Tue, 27 Sep 2022 23:48:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229779AbiI0XsJ (ORCPT ); Tue, 27 Sep 2022 19:48:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230307AbiI0XsF (ORCPT ); Tue, 27 Sep 2022 19:48:05 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70084.outbound.protection.outlook.com [40.107.7.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50B051B2D1B; Tue, 27 Sep 2022 16:48:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nC42S6doZkL84lRYt0xNgGVUoCA/aDcAq/1oFGOGCviCjlS7EmPmMAG7e1s07ROs7bTpG951umCcHnsKGshkj43dTJgEL9WduDnb6KqIYg6/gBtlUB8zLxPDQ51SXNWTODGT9U7d6gFsUamgvQjPoBo0Ir5XF48EqrfDhEANRe0CD+/C2j0KNhzjixIJ28ZZR4MQcXcfRQS5HjZUW3tp8y9QMw5fGssMP3vodQOzprAdaZnzwmFVIuK23GXH2m/0Zrwn+C6JkxQeLXXfE5QlsAaHuzc0a961UY7atlk1ZE4W4BiO6BCZJeHUqlUQhWdpS7gUWMO/xhjfdYdBIacAdg== 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=9ZTbCbtrXUjwvvDefLKyJMI3M8s4YhJ3F33nF8oLNZg=; b=gTAKLHN5xnyteHkLWg/TFtjyCx3jCJb80WS20vPYK9QLOSLpEttvFlezNgNaFxEQHNzUci2HYJcByFs4cGnzih7TR/4z+kc2KbgfbAIBNF5D6t8SrgXy2SFQZJBXx9Vw7VefV+os18iuxB0nuJ11NwPHa1BQeHvQ4YqSOxZzRg9h2/uHW9bjddDu5kejV6uU5JN6Uj5AnQpOvY5+TEThZ/tFvUv9SXD1Zqx5XdvEzpiAyYbJR9oVymlARb1qQC6VlBE2VblI84L+fa1xI94FgpGLfJe747T1rrcUjCyd7OIrsyw3EitUUTuhLb8mOtIACO5UkBchVHqkzcEtuM0FHw== 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=9ZTbCbtrXUjwvvDefLKyJMI3M8s4YhJ3F33nF8oLNZg=; b=JVhErDlDXdhzGDkNILMA7r+EmwVMEt6XDFY873Mh++nr9+E030g1EAHoiL9P5xQFCiuOte14CLQNsLpLdqFvbO4gVdsYUQyH/9kDS6vAqhcafT4RzfVJCQKcsC+pAZhpUW7ANCOZyGkihORreihkYed3uI+styyK2nAmfZ6BF34= 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 DU0PR04MB9444.eurprd04.prod.outlook.com (2603:10a6:10:35c::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.20; Tue, 27 Sep 2022 23:48:01 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::a67a:849c:aeff:cad1]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::a67a:849c:aeff:cad1%7]) with mapi id 15.20.5654.025; Tue, 27 Sep 2022 23:48:01 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Xiaoliang Yang , Rui Sousa , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Horatiu Vultur , Andrew Lunn , Vivien Didelot , Florian Fainelli , Michael Walle , Vinicius Costa Gomes , Maxim Kochetkov , Colin Foster , Richie Pearn , Kurt Kanzenbach , Vladimir Oltean , Jamal Hadi Salim , Cong Wang , Jiri Pirko , linux-kernel@vger.kernel.org Subject: [PATCH v3 net-next 1/8] net/sched: query offload capabilities through ndo_setup_tc() Date: Wed, 28 Sep 2022 02:47:39 +0300 Message-Id: <20220927234746.1823648-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927234746.1823648-1-vladimir.oltean@nxp.com> References: <20220927234746.1823648-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR0501CA0025.eurprd05.prod.outlook.com (2603:10a6:800:60::11) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|DU0PR04MB9444:EE_ X-MS-Office365-Filtering-Correlation-Id: 1e415989-f57a-4cb0-cb7b-08daa0e2b658 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: m9ZA3P+7UFjKUrH4sApRVcdIVhK/R9JHdAEUBpcZfNccOrzdz0XuKsb4dL/OZKvYSwxRhhJ+ba1CUAGE624OWEOaUbOl0dMd56SHK+GnqZu3HKBBd/1EGPmO1TQFLO1p7dgSryRtXds8N7BNXmkofDzSwmiGcA+f+omsRRuOb6a4pwj4vKqkpR2LRoLhxTmQSTVmLMs/Zk2ZTts4ppijsMYPVsANTDCAOymEwBXRR1P81nT9qlZQd+kz7ZY9lJe9xRvzC9+uw6i4/i6M+5wC1AZSl0xKe3Z//F4dxbWag2IVtk+zpVxJAYbiLdApy/sPdB8tEbjiHuTMkRK7U41v5TQo9vIOEouk9IAk5L2a/XsOOVTRBkPvh1BbjZSP3fBFrP4ooibBO7b8ZEnFmDlwu3Lil246aIFgfOzGPsJQBUnKvsZE0Kdpu9SEBdr7E1Qp2qWaPTGxN/OYj93Ou3Q7iWePUQjlx+C5/4M7G8YD3zEMzlq6ylA2HogRT8y3WzM+6rxcGGRZtZMrntvK0UNl+Ppi5kUFA4SjftR9ZewikuqN70AFlFCfmTw4DEePCBEG7DUqjMAFGi00+9zbGAPRzJt1qnIljEbTZvgJVUqW4QTpY2sSzt8221BYvLw0dlyppX972ci1LQmMsS4yR0AOslrCwRD4ulb6T2L7XWzo8NrY0l8uh2suEs/RExTJehTADkZvGMXuFONcvc5f04TpoTiMCJ3HQF5zG1EhdQzH3iHEjs1FGYaDbh1GnWb06C3ObHbrups+UIPXC4+ImOtQ0WbdQAddHZ1Qms2/5LNQJAY= 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:(13230022)(4636009)(136003)(366004)(376002)(39860400002)(396003)(346002)(451199015)(7416002)(6512007)(966005)(41300700001)(6666004)(36756003)(6486002)(38350700002)(6506007)(6916009)(8676002)(86362001)(66476007)(4326008)(26005)(52116002)(8936002)(66946007)(83380400001)(38100700002)(316002)(54906003)(186003)(1076003)(2906002)(5660300002)(66556008)(478600001)(44832011)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: oeiSJXhyWQRUWnxI64SPGxNW1R+7a3PIP0Rk7UBtx0+nNLl0cvd6jLM1SfQnuYIDKcnGA/hqXyCrAZ1sWq3Q1RHg497zdbEfuIOUm28jrtTETNBllKZ56yef5+NZV72QBBCViH4Q9JITAoSXW1cdVRmy4LAYFIW3G+WD/Kb62HhA1LRFUd6d2gA4W3FwIuke0zD3axA3KxTN+DRUmXuz+w/H8A+lGF3vBIbmtUZxMeneewMEcwlWr6ceBzwUZur7uHdJFUS3S9VjpXl4CP64EFm7bkATlH8n5eWsjg3eB2ajhaYn+g1SuypLqFf4CIc3T9GQwZ//EY1QoLhlT958F3Vgq2X47WYv3JQz8K2fury+sEuWSyPRdZieEaIfclQ4HVtDXU4i6aRJN+wCz3pCgeDFVQvsMFtYRjx6y9zHwpSsJpDhIROd82Ld1/Z94K4VT8B3Aubx+vBE9iu50rX0VZvyo371nvhmYJfrbpBwJJolcHnUcPqyTBGra3AcrMfMCjARzLsDPUAwsm+48qMMBTy27wiMqZRK3fL+aYOOZHkoC+o1JIUA9GTeSJJWHn+MYOcufK0slyv3192DPnvdj25jUHTAm0fdyPTq2wX3KeeBzxW+wX5kHo5fhet63haBqdqDeaxb/YDrRwI38bUe2XCuDMA4ti3mhMxc76Ng6t3Ke5SRAw0i+xKh5iMwiewm4BGnQFJjMPJlkU4xHq3oqJgv2H/CseIVurazccAJvfkT8nbTdALBbqItiX8JECt77xYPFIO3TCBVEi1xg8EQh7aoX1vOUNp7wbikFl2ZjZxQ4gg5kHmHmnMpsrilabp52mdoEw2a0NZlDnqR5LzwrFkPsR0xytFw1CvM6Tli4fAHh0IC7ipyPVS7qTRQhoIlQehDEDkeApPFLOTN7S5+MwYX9djZkJPF+LvL3CgzJ75S2hu9LTt1hKd4JZdAHU0gCSkxHSzh4qbGB7MD1mtL61uD8VbwFlVvG5aPM/YdHc2Fm4qLkNDGhb4FZ37BZybqhEve5uu+tPcn7DQsOuq0XebgnVw6Fr2GT1JbP7QSG6kQ5U0eWJV49wgKiWbJRgb1zphtKn7jqJIdkteYm2gx8AWzRf1qZJIo+uujmupEUWPT+oTDUX9OJCi76jiribHTI0MO5cxUIlkACqozIEg4Ddok2RDV0QPJ/8QmIrLZc0BxNTbTlt9gJL5e5mkacIrZiVA6TWrg25PBqpXRdYnsvpOBDLgDLOaXgIIEBwO8FXQs+Mapm0XJ076WDUBB20Eyancyf5daS+RyCIMJz1TwDfOWAw9oXB6e7mWhJhMKe9eDcXeHL/CMTatTxCYaqg2t6XtaGGIJyesVi0MVopZDMOID29JO/R1jEy1gAwwUJ/xZbtNxhD7kbp6iSda3+/W6U1kmNqiszqy9XYYfftBeKtOKn3pOQgW7vz5VL97ZAD/H2dO/ZUH2oyZz1LdaPPO5xOOiRW+AmvfFYyUtDdV7GWwoB5O+vyH8I2VLbR4vqTUo/TpS6y7XryL6PrUQSRpzinRP3inwBVHtw60NXxnfvCw+KDC9pOiFhBSpYD+jvtVoqcSFOyhkPmX18yH7WKBGiowZfuupKZ+IVKRTtXhDhg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1e415989-f57a-4cb0-cb7b-08daa0e2b658 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2022 23:48:01.0546 (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: aAqoyUNjls/YlB8PYoXXf1KLBI2Y14D2spJ5gDgJRvyCJXqsYyU6gE9on9yGbwCJbHMpHfPi0r4Fr+yomuxzDA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9444 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org When adding optional new features to Qdisc offloads, existing drivers must reject the new configuration until they are coded up to act on it. Since modifying all drivers in lockstep with the changes in the Qdisc can create problems of its own, it would be nice if there existed an automatic opt-in mechanism for offloading optional features. Jakub proposes that we multiplex one more kind of call through ndo_setup_tc(): one where the driver populates a Qdisc-specific capability structure. First user will be taprio in further changes. Here we are introducing the definitions for the base functionality. Link: https://patchwork.kernel.org/project/netdevbpf/patch/20220923163310.3192733-3-vladimir.oltean@nxp.com/ Suggested-by: Jakub Kicinski Co-developed-by: Jakub Kicinski Signed-off-by: Jakub Kicinski Signed-off-by: Vladimir Oltean --- v2->v3: patch is new include/linux/netdevice.h | 1 + include/net/pkt_sched.h | 5 +++++ include/net/sch_generic.h | 3 +++ net/sched/sch_api.c | 17 +++++++++++++++++ 4 files changed, 26 insertions(+) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 9f42fc871c3b..b175d6769f72 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -940,6 +940,7 @@ struct net_device_path_ctx { }; enum tc_setup_type { + TC_QUERY_CAPS, TC_SETUP_QDISC_MQPRIO, TC_SETUP_CLSU32, TC_SETUP_CLSFLOWER, diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h index 2ff80cd04c5c..34600292fdfb 100644 --- a/include/net/pkt_sched.h +++ b/include/net/pkt_sched.h @@ -141,6 +141,11 @@ static inline struct net *qdisc_net(struct Qdisc *q) return dev_net(q->dev_queue->dev); } +struct tc_query_caps_base { + enum tc_setup_type type; + void *caps; +}; + struct tc_cbs_qopt_offload { u8 enable; s32 queue; diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index 32819299937d..d5517719af4e 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h @@ -677,6 +677,9 @@ qdisc_offload_graft_helper(struct net_device *dev, struct Qdisc *sch, { } #endif +void qdisc_offload_query_caps(struct net_device *dev, + enum tc_setup_type type, + void *caps, size_t caps_len); struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue, const struct Qdisc_ops *ops, struct netlink_ext_ack *extack); diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c index db1569fac57c..7c15f1f3da17 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c @@ -868,6 +868,23 @@ void qdisc_offload_graft_helper(struct net_device *dev, struct Qdisc *sch, } EXPORT_SYMBOL(qdisc_offload_graft_helper); +void qdisc_offload_query_caps(struct net_device *dev, + enum tc_setup_type type, + void *caps, size_t caps_len) +{ + const struct net_device_ops *ops = dev->netdev_ops; + struct tc_query_caps_base base = { + .type = type, + .caps = caps, + }; + + memset(caps, 0, caps_len); + + if (ops->ndo_setup_tc) + ops->ndo_setup_tc(dev, TC_QUERY_CAPS, &base); +} +EXPORT_SYMBOL(qdisc_offload_query_caps); + static void qdisc_offload_graft_root(struct net_device *dev, struct Qdisc *new, struct Qdisc *old, struct netlink_ext_ack *extack) From patchwork Tue Sep 27 23:47:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12991491 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 9F97CC07E9D for ; Tue, 27 Sep 2022 23:48:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231787AbiI0XsM (ORCPT ); Tue, 27 Sep 2022 19:48:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231278AbiI0XsJ (ORCPT ); Tue, 27 Sep 2022 19:48:09 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70084.outbound.protection.outlook.com [40.107.7.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0C7A1BBEE4; Tue, 27 Sep 2022 16:48:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LqtRmgAeAH2KUxNERkcSq9TUxeo1WaTtVApQZHQbKzBZJBM4DSxrmkFYh3c6mGlRI/QwLfAsGYRuE/K/M7hahKrFiAjaF9Nt/t4ZLaQ4XulqYLiPsEdznAAem9mSm07l/vRv2ZFIdD9D5kbPlbFrOWNLiPaNba58BkdxiVFNVDNR2ZVSMbUFdPvjCs4eOtyWoD+FMdwB42YVa4o2Y9AnkEOBky8L6OKL+/R0j5cB5RG6U1g+QLqJUtW4WF4yDQhqRjIse6cvGnpbb07JZHd8d4/d+IFufwcLAdviUYELAqiYTx68iogQAtmZWlFjXxA8IRKKry5hlp7AS5GxQYAr6Q== 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=iLc8s6Bn8XOsMpJP/GpFRRZy12/JvSSOvPPwV1i6x+8=; b=d5z7h5a38/CmZPhKf3vYBvDCrhROsQ/AhRTDbK1F0irUt2gEj+Dg+aSKgeJ/ZzzPWpEmfG9tTcA58cM/g/98RtfSkuJ3GfzS/CiJ1wMCkAwqIJtEGpbfpUZk3fhBkwjkTSDBdegvC1ev/pdO309b6ueu9WxS/8YhhDgHipsn5UpxLK9CsqiC7uYi6fJiRmwFhtZ06oefX06ewrdhMTsFOiGKsI0zdzsK4CVM3I/ghpH6VkbNVNbtTWoxjRzfgR8uszwR8m3TM8+nRmV2cmmcV+aNnWCh8NCOlZbSDiatnEJcT1XVoW+X6Y0otLVmgOvn04FzuJRzrj5WVeF8t5fNhg== 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=iLc8s6Bn8XOsMpJP/GpFRRZy12/JvSSOvPPwV1i6x+8=; b=QfJJh3l7lanlSFp/ZBwULCjQRAz7+vteFXyPO26bi3fjGZxGIUrgt/mBA14hcY/fJZVNmC8UL/y2fhIXvZaA1wFr0Lp1wivyhjhsFSUw1M9HMCJknE6IRk4Guky/1S0e2vaUyEEZuKMRhEJiqKH/t2oE6exIf+02E44ROYbiR60= 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 DU0PR04MB9444.eurprd04.prod.outlook.com (2603:10a6:10:35c::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.20; Tue, 27 Sep 2022 23:48:02 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::a67a:849c:aeff:cad1]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::a67a:849c:aeff:cad1%7]) with mapi id 15.20.5654.025; Tue, 27 Sep 2022 23:48:02 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Xiaoliang Yang , Rui Sousa , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Horatiu Vultur , Andrew Lunn , Vivien Didelot , Florian Fainelli , Michael Walle , Vinicius Costa Gomes , Maxim Kochetkov , Colin Foster , Richie Pearn , Kurt Kanzenbach , Vladimir Oltean , Jamal Hadi Salim , Cong Wang , Jiri Pirko , linux-kernel@vger.kernel.org Subject: [PATCH v3 net-next 2/8] net/sched: taprio: allow user input of per-tc max SDU Date: Wed, 28 Sep 2022 02:47:40 +0300 Message-Id: <20220927234746.1823648-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927234746.1823648-1-vladimir.oltean@nxp.com> References: <20220927234746.1823648-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR0501CA0025.eurprd05.prod.outlook.com (2603:10a6:800:60::11) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|DU0PR04MB9444:EE_ X-MS-Office365-Filtering-Correlation-Id: d5360a78-6b94-4ee4-0d71-08daa0e2b721 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oyrdULZj+G+82M6g4cHHjVvp4LooU20WufYXkd1gguUxoQtoIkzSyDNgqZfcKAuAhHFrzM8nZ8mz5cDaAwWKlgAyPHZFQlogk+jn65sgNV38ODweqSiDWNBekcQ/XimxoYT4qSo2mqX9OrKBFw8zx0xOhZmitwDGbBe/lswKERFAydnNgefaFzTFvyvn72Zhue/NvwXenMzYGpmphFbYEMtZjjA/BTX7aoLmhL8tSFLcTo+p2D1Gojw5JIWFLy1ehRZXl7eKJVLUQXUr4SDsvRfLCczCSlVREkeVWmzL4ddsTv4MIGD9RlaZzktlfltGnFG5P+HlSEJ07WICX6miRS2D5ep3kyNRn9e+lYlPFapv5blI8E5nJRa1pR9RG/lNMIXWn077UGkTxAH+ns5ICGQdyYs9mokOA+CYUy6lNqCB1AjHRz6cLtr9IQmFw1EO7l5SXC2rFsK91Ut2JsYClxgDOxQvSxSFJRYu2gFAQsLdz5a2JsENcFgz35d3FFn/E8Uays8B/Ibsz5YLDGVoUGzOzxMgCz/g2metJssMmP749tDAOOasHdX8D5byAQqsaFj3zLTM5L47ayOynJlSLWihrn0sLOnIjlCbSNHa+HK6fpqANT8pQOskQPLgnfnk8XgQnREigf9I8Z6+iXxijcXAJxPjfGvwAEJ7biWbbpaQsVId4LNw0y8Jw1iVm+aobbR8C8gI6dN6OyO6ZAe8g9p1n8o9kocId9mmZQrQOvIE9kosCQTY3TVxFF9gE9pFu0vogMSsMPyRc+nvGpI1pQ== 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:(13230022)(4636009)(136003)(366004)(376002)(39860400002)(396003)(346002)(451199015)(7416002)(6512007)(41300700001)(6666004)(36756003)(6486002)(38350700002)(6506007)(6916009)(8676002)(86362001)(66476007)(4326008)(26005)(52116002)(8936002)(66946007)(83380400001)(38100700002)(316002)(54906003)(186003)(1076003)(2906002)(5660300002)(66556008)(478600001)(44832011)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: U9XKp+t/VlRWMNWK66CiQWilOZx6nZIZPuamLgmdL6qje/xmBq+23CNRgMAy1I49mUb0siGa7ZTZ7tUYbMFFdhUmojpBlCdst5Txuk2aw4dkW/dm+0zMpLhFtWASMHtsfR4v0+xfCmGEHT5Gt59Df5FcZ+5B/4P4mwNFZwjILwMmn0ktRZGZs2cb8nApkQIGwBz3AV4AGdFZqf6FJkcHNXcvoNZcBnO+BSyrsoqKHnyK1htyv9evSvBfZlYixOT0Oscg2SbfF9t7sNxUdgk5SDrhsKmJ46ZPqBVnXHGO8V5YmSNFHcwKHuspwWnw8oBW/ja0RTPvJ7LcIPp4U2vBQFp0TbjS/4mMAKN7TEFMj20QwsNWLpsLaPgY6x1xQuB6IY9gC9HJJydsLpC97qtpzBys2m/YqYtbhDbEDWzaMxkCFpfpEiVZT/UNjQnD/lL3U32dgp2P509K7jdLiMrhPuAOvMB3Kuod54myu9AqLRj2l/IQ+WRRK4cKvnJ6rjbFuSJImKqayAdRyC2m7Ti9obdU+rc5b8eHl9FJ+WTRHQfFfxUYLpker9RDMpwt191ri0KarlBqAJOxpx3erUqpyl19Om+Vzz422iXEJw6oQhSgQ6zxvT4avpXcVhdMcgZ/HDokJM6FDr6sQwS9GFB1FHFuYgJnBSRMC1dGYiwHlLNw5Gt1yUaPz7DC/n3Q08aBS8d0TuLE9cTPJV2fZ107qaP6qsS8eoS+GIzdQsn+wS2WsWiHkp7RcG/g19HxlY8xMOCpsm+9IGFu/snqCi8wGWxdF4HDKrQoASAq8ModLWdb2ZSqRCEK1n8/89nAc+pnQpLaVGb2XV/5ytLdORxLHHP80MboQBpnxlJFQZfXjYeVsQNWx5/KavH0MTCTleGaWI8Wf0PT2HIGMdwmokIAqn6AxrRq/EW+VHUX+vMO1TLmM7c+6utzAdxA2fcvZgVwp+nlYxwVaX8cxbak9imfufkdb27suRQjBF7Va5NU6ATmK3BoRFqCuFON58pMtXg9ezoQwUkszEN5SuHZWC7PSSYiCfI+a4jps6VgCunoHeAAxIueLSCs+l17kmLo1MmYCE1K4OS6fHHXg8sguoghYHu8u9XpnIbOyd8ZGqXUY4WhKxH+HlbQgro0XNDHGThj8+drv089c/AMgFrXBWARMP9Rl+sY90h5Q7KVEFgYhV95L50rCNJeW9FNdr8q9dTqOwODNyyDs3681wWD9v44lwV0HOnrznguSl71la1gyhu3dKrJa7gy2uIpYYe7YOdYViLxSyY683YOF7s9XC/Tw6nGvQoDP2DihMf7LcIVxtDdX4b+xpwLjQvIUaUvBA5DV50OZtmuFIdbZ1OeI8F5vjDwxUbYpQb0bsKg5ScXV3wX8Tw9hL+HcftV6NoejKcdfvcSpwVR6ZKR4kIjMR7+A4gpoPu+nlnuRDUqsddgRdOpObkUK+be0VHr9PMvJZe3B96xVW7R7jyAShF8D7zeF83JtJMLFT4lrjQ7PskYl0v7wYimOT57K5/5/4qyHxn0FQbKC/ieWeNOq2KPwCHath+4DPyn5LnewaZ4rvck+GpNbn4jC4Cjlw0qvjD1Tm094y5tagZfyYCdw8rgmjprLw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d5360a78-6b94-4ee4-0d71-08daa0e2b721 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2022 23:48:02.3514 (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: stdxj+UVlYuLkTVZwd1JiV4A/bMEQ4SWwNXi0xhpsGzkc/AwR0iYtLVV/I2IMR1WqLNIWc1ny5/ijOAye7TN5A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9444 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org IEEE 802.1Q clause 12.29.1.1 "The queueMaxSDUTable structure and data types" and 8.6.8.4 "Enhancements for scheduled traffic" talk about the existence of a per traffic class limitation of maximum frame sizes, with a fallback on the port-based MTU. As far as I am able to understand, the 802.1Q Service Data Unit (SDU) represents the MAC Service Data Unit (MSDU, i.e. L2 payload), excluding any number of prepended VLAN headers which may be otherwise present in the MSDU. Therefore, the queueMaxSDU is directly comparable to the device MTU (1500 means L2 payload sizes are accepted, or frame sizes of 1518 octets, or 1522 plus one VLAN header). Drivers which offload this are directly responsible of translating into other units of measurement. To keep the fast path checks optimized, we keep 2 arrays in the qdisc, one for max_sdu translated into frame length (so that it's comparable to skb->len), and another for offloading and for dumping back to the user. Signed-off-by: Vladimir Oltean --- v1->v2: use qdisc_offload_query_caps(). This also gives an extack message to the user on lack of support for queueMaxSDU, which was not available before. include/net/pkt_sched.h | 5 ++ include/uapi/linux/pkt_sched.h | 11 +++ net/sched/sch_taprio.c | 152 ++++++++++++++++++++++++++++++++- 3 files changed, 167 insertions(+), 1 deletion(-) diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h index 34600292fdfb..38207873eda6 100644 --- a/include/net/pkt_sched.h +++ b/include/net/pkt_sched.h @@ -160,6 +160,10 @@ struct tc_etf_qopt_offload { s32 queue; }; +struct tc_taprio_caps { + bool supports_queue_max_sdu:1; +}; + struct tc_taprio_sched_entry { u8 command; /* TC_TAPRIO_CMD_* */ @@ -173,6 +177,7 @@ struct tc_taprio_qopt_offload { ktime_t base_time; u64 cycle_time; u64 cycle_time_extension; + u32 max_sdu[TC_MAX_QUEUE]; size_t num_entries; struct tc_taprio_sched_entry entries[]; diff --git a/include/uapi/linux/pkt_sched.h b/include/uapi/linux/pkt_sched.h index f292b467b27f..000eec106856 100644 --- a/include/uapi/linux/pkt_sched.h +++ b/include/uapi/linux/pkt_sched.h @@ -1232,6 +1232,16 @@ enum { #define TCA_TAPRIO_ATTR_FLAG_TXTIME_ASSIST _BITUL(0) #define TCA_TAPRIO_ATTR_FLAG_FULL_OFFLOAD _BITUL(1) +enum { + TCA_TAPRIO_TC_ENTRY_UNSPEC, + TCA_TAPRIO_TC_ENTRY_INDEX, /* u32 */ + TCA_TAPRIO_TC_ENTRY_MAX_SDU, /* u32 */ + + /* add new constants above here */ + __TCA_TAPRIO_TC_ENTRY_CNT, + TCA_TAPRIO_TC_ENTRY_MAX = (__TCA_TAPRIO_TC_ENTRY_CNT - 1) +}; + enum { TCA_TAPRIO_ATTR_UNSPEC, TCA_TAPRIO_ATTR_PRIOMAP, /* struct tc_mqprio_qopt */ @@ -1245,6 +1255,7 @@ enum { TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME_EXTENSION, /* s64 */ TCA_TAPRIO_ATTR_FLAGS, /* u32 */ TCA_TAPRIO_ATTR_TXTIME_DELAY, /* u32 */ + TCA_TAPRIO_ATTR_TC_ENTRY, /* nest */ __TCA_TAPRIO_ATTR_MAX, }; diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index 0bc6d90e1e51..435d866fcfa0 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -78,6 +78,8 @@ struct taprio_sched { struct sched_gate_list __rcu *admin_sched; struct hrtimer advance_timer; struct list_head taprio_list; + u32 max_frm_len[TC_MAX_QUEUE]; /* for the fast path */ + u32 max_sdu[TC_MAX_QUEUE]; /* for dump and offloading */ u32 txtime_delay; }; @@ -415,6 +417,9 @@ static int taprio_enqueue_one(struct sk_buff *skb, struct Qdisc *sch, struct Qdisc *child, struct sk_buff **to_free) { struct taprio_sched *q = qdisc_priv(sch); + struct net_device *dev = qdisc_dev(sch); + int prio = skb->priority; + u8 tc; /* sk_flags are only safe to use on full sockets. */ if (skb->sk && sk_fullsock(skb->sk) && sock_flag(skb->sk, SOCK_TXTIME)) { @@ -426,6 +431,11 @@ static int taprio_enqueue_one(struct sk_buff *skb, struct Qdisc *sch, return qdisc_drop(skb, sch, to_free); } + /* Devices with full offload are expected to honor this in hardware */ + tc = netdev_get_prio_tc_map(dev, prio); + if (skb->len > q->max_frm_len[tc]) + return qdisc_drop(skb, sch, to_free); + qdisc_qstats_backlog_inc(sch, skb); sch->q.qlen++; @@ -754,6 +764,11 @@ static const struct nla_policy entry_policy[TCA_TAPRIO_SCHED_ENTRY_MAX + 1] = { [TCA_TAPRIO_SCHED_ENTRY_INTERVAL] = { .type = NLA_U32 }, }; +static const struct nla_policy taprio_tc_policy[TCA_TAPRIO_TC_ENTRY_MAX + 1] = { + [TCA_TAPRIO_TC_ENTRY_INDEX] = { .type = NLA_U32 }, + [TCA_TAPRIO_TC_ENTRY_MAX_SDU] = { .type = NLA_U32 }, +}; + static const struct nla_policy taprio_policy[TCA_TAPRIO_ATTR_MAX + 1] = { [TCA_TAPRIO_ATTR_PRIOMAP] = { .len = sizeof(struct tc_mqprio_qopt) @@ -766,6 +781,7 @@ static const struct nla_policy taprio_policy[TCA_TAPRIO_ATTR_MAX + 1] = { [TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME_EXTENSION] = { .type = NLA_S64 }, [TCA_TAPRIO_ATTR_FLAGS] = { .type = NLA_U32 }, [TCA_TAPRIO_ATTR_TXTIME_DELAY] = { .type = NLA_U32 }, + [TCA_TAPRIO_ATTR_TC_ENTRY] = { .type = NLA_NESTED }, }; static int fill_sched_entry(struct taprio_sched *q, struct nlattr **tb, @@ -1216,7 +1232,8 @@ static int taprio_enable_offload(struct net_device *dev, { const struct net_device_ops *ops = dev->netdev_ops; struct tc_taprio_qopt_offload *offload; - int err = 0; + struct tc_taprio_caps caps; + int tc, err = 0; if (!ops->ndo_setup_tc) { NL_SET_ERR_MSG(extack, @@ -1224,6 +1241,19 @@ static int taprio_enable_offload(struct net_device *dev, return -EOPNOTSUPP; } + qdisc_offload_query_caps(dev, TC_SETUP_QDISC_TAPRIO, + &caps, sizeof(caps)); + + if (!caps.supports_queue_max_sdu) { + for (tc = 0; tc < TC_MAX_QUEUE; tc++) { + if (q->max_sdu[tc]) { + NL_SET_ERR_MSG_MOD(extack, + "Device does not handle queueMaxSDU"); + return -EOPNOTSUPP; + } + } + } + offload = taprio_offload_alloc(sched->num_entries); if (!offload) { NL_SET_ERR_MSG(extack, @@ -1233,6 +1263,9 @@ static int taprio_enable_offload(struct net_device *dev, offload->enable = 1; taprio_sched_to_offload(dev, sched, offload); + for (tc = 0; tc < TC_MAX_QUEUE; tc++) + offload->max_sdu[tc] = q->max_sdu[tc]; + err = ops->ndo_setup_tc(dev, TC_SETUP_QDISC_TAPRIO, offload); if (err < 0) { NL_SET_ERR_MSG(extack, @@ -1367,6 +1400,89 @@ static int taprio_parse_clockid(struct Qdisc *sch, struct nlattr **tb, return err; } +static int taprio_parse_tc_entry(struct Qdisc *sch, + struct nlattr *opt, + u32 max_sdu[TC_QOPT_MAX_QUEUE], + unsigned long *seen_tcs, + struct netlink_ext_ack *extack) +{ + struct nlattr *tb[TCA_TAPRIO_TC_ENTRY_MAX + 1] = { }; + struct net_device *dev = qdisc_dev(sch); + u32 val = 0; + int err, tc; + + err = nla_parse_nested(tb, TCA_TAPRIO_TC_ENTRY_MAX, opt, + taprio_tc_policy, extack); + if (err < 0) + return err; + + if (!tb[TCA_TAPRIO_TC_ENTRY_INDEX]) { + NL_SET_ERR_MSG_MOD(extack, "TC entry index missing"); + return -EINVAL; + } + + tc = nla_get_u32(tb[TCA_TAPRIO_TC_ENTRY_INDEX]); + if (tc >= TC_QOPT_MAX_QUEUE) { + NL_SET_ERR_MSG_MOD(extack, "TC entry index out of range"); + return -ERANGE; + } + + if (*seen_tcs & BIT(tc)) { + NL_SET_ERR_MSG_MOD(extack, "Duplicate TC entry"); + return -EINVAL; + } + + *seen_tcs |= BIT(tc); + + if (tb[TCA_TAPRIO_TC_ENTRY_MAX_SDU]) + val = nla_get_u32(tb[TCA_TAPRIO_TC_ENTRY_MAX_SDU]); + + if (val > dev->max_mtu) { + NL_SET_ERR_MSG_MOD(extack, "TC max SDU exceeds device max MTU"); + return -ERANGE; + } + + max_sdu[tc] = val; + + return 0; +} + +static int taprio_parse_tc_entries(struct Qdisc *sch, + struct nlattr *opt, + struct netlink_ext_ack *extack) +{ + struct taprio_sched *q = qdisc_priv(sch); + struct net_device *dev = qdisc_dev(sch); + u32 max_sdu[TC_QOPT_MAX_QUEUE]; + unsigned long seen_tcs = 0; + struct nlattr *n; + int tc, rem; + int err = 0; + + for (tc = 0; tc < TC_QOPT_MAX_QUEUE; tc++) + max_sdu[tc] = q->max_sdu[tc]; + + nla_for_each_nested(n, opt, rem) { + if (nla_type(n) != TCA_TAPRIO_ATTR_TC_ENTRY) + continue; + + err = taprio_parse_tc_entry(sch, n, max_sdu, &seen_tcs, extack); + if (err) + goto out; + } + + for (tc = 0; tc < TC_QOPT_MAX_QUEUE; tc++) { + q->max_sdu[tc] = max_sdu[tc]; + if (max_sdu[tc]) + q->max_frm_len[tc] = max_sdu[tc] + dev->hard_header_len; + else + q->max_frm_len[tc] = U32_MAX; /* never oversized */ + } + +out: + return err; +} + static int taprio_mqprio_cmp(const struct net_device *dev, const struct tc_mqprio_qopt *mqprio) { @@ -1445,6 +1561,10 @@ static int taprio_change(struct Qdisc *sch, struct nlattr *opt, if (err < 0) return err; + err = taprio_parse_tc_entries(sch, opt, extack); + if (err) + return err; + new_admin = kzalloc(sizeof(*new_admin), GFP_KERNEL); if (!new_admin) { NL_SET_ERR_MSG(extack, "Not enough memory for a new schedule"); @@ -1825,6 +1945,33 @@ static int dump_schedule(struct sk_buff *msg, return -1; } +static int taprio_dump_tc_entries(struct taprio_sched *q, struct sk_buff *skb) +{ + struct nlattr *n; + int tc; + + for (tc = 0; tc < TC_MAX_QUEUE; tc++) { + n = nla_nest_start(skb, TCA_TAPRIO_ATTR_TC_ENTRY); + if (!n) + return -EMSGSIZE; + + if (nla_put_u32(skb, TCA_TAPRIO_TC_ENTRY_INDEX, tc)) + goto nla_put_failure; + + if (nla_put_u32(skb, TCA_TAPRIO_TC_ENTRY_MAX_SDU, + q->max_sdu[tc])) + goto nla_put_failure; + + nla_nest_end(skb, n); + } + + return 0; + +nla_put_failure: + nla_nest_cancel(skb, n); + return -EMSGSIZE; +} + static int taprio_dump(struct Qdisc *sch, struct sk_buff *skb) { struct taprio_sched *q = qdisc_priv(sch); @@ -1863,6 +2010,9 @@ static int taprio_dump(struct Qdisc *sch, struct sk_buff *skb) nla_put_u32(skb, TCA_TAPRIO_ATTR_TXTIME_DELAY, q->txtime_delay)) goto options_error; + if (taprio_dump_tc_entries(q, skb)) + goto options_error; + if (oper && dump_schedule(skb, oper)) goto options_error; From patchwork Tue Sep 27 23:47:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12991492 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 AE978C54EE9 for ; Tue, 27 Sep 2022 23:48:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231759AbiI0Xss (ORCPT ); Tue, 27 Sep 2022 19:48:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231642AbiI0XsK (ORCPT ); Tue, 27 Sep 2022 19:48:10 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70084.outbound.protection.outlook.com [40.107.7.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 547E71BB20A; Tue, 27 Sep 2022 16:48:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EcFMmT06DCzgzNGnRyw8l+mNG7DWQMTvzrvmZudKAcZMVrmNcUUb1zj/pIuMKflr0G+1KJ4y9I4eiG3Ky2+mjxJH8MTspb/1ErDxbv54270GCcC3a2vf7H95+7enNH1oIff8WgDd4QsTeHjW/R7xNqUYiZrreVDEFftedhD4DmYIDwNOb3HYzeiRaT3s/OX2ZwU3WOtsaBMUyv1xqyuoJb76iHUUZ4hB6kr328NQbt/n55OF4Ab/b9afdLD4gGfklG5ZbJRM0mXw45WTB4ETrqHf5Qb/HcDCKMiyJgtgxCff9Y3YSmzlbnruuFXhWwjLOExgngxf6k6Gvw+VHFeWhw== 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=/C0aHcx8YYTL0CUt+aS3617l/CB0NMVBvv08wZdyfXM=; b=ckSDBr2GZbWe17B1Ec7+keOqIWrux2siBCGAdsdaHXDfF3//SYwV6N/rTYE6Gr9xfcfz4SZvGL6aLww2yWHJN9Ek2MCeUgL8k4h0JXfYLLwszM628cpkI75bPHt9/wg5miG0ZU3OnXWLedtINeSJFnsn1n1B+jKMAFSY8H4Twx9nwEUpZ68w4K6FxWzR0p3f9BGDpyVGdCScxeqTGjHb5JjhevYXkGg4nsWm2z33NSUlX0CLoFxeKCx5/8uSEClg9B7fV1CnYxezRy2NwIjR0+B8QEPovL/z/lJOMTeBuj9dcEBy2DTyFer1uH1CzBEEPVRVCOMaqO9hRrFIDCQjEg== 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=/C0aHcx8YYTL0CUt+aS3617l/CB0NMVBvv08wZdyfXM=; b=QmodO3FRbHNSWRofdwjSMfgPYWqiQwFYXpK3D3Vs6D/FuLZAdrdbQWO8k7Ob3P4NB7N8OtZv0wJRHqIzbB1ClFswhMN+F5Hmfdl7vsjfl5Zz9e44exLpkXrlVhOBHR/+g9MPuMnLP2bX0XCgL88vJoPAdF66pHzTtAjOjbkWg3k= 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 DU0PR04MB9444.eurprd04.prod.outlook.com (2603:10a6:10:35c::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.20; Tue, 27 Sep 2022 23:48:03 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::a67a:849c:aeff:cad1]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::a67a:849c:aeff:cad1%7]) with mapi id 15.20.5654.025; Tue, 27 Sep 2022 23:48:03 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Xiaoliang Yang , Rui Sousa , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Horatiu Vultur , Andrew Lunn , Vivien Didelot , Florian Fainelli , Michael Walle , Vinicius Costa Gomes , Maxim Kochetkov , Colin Foster , Richie Pearn , Kurt Kanzenbach , Vladimir Oltean , Jamal Hadi Salim , Cong Wang , Jiri Pirko , linux-kernel@vger.kernel.org Subject: [PATCH v3 net-next 3/8] net: dsa: felix: offload per-tc max SDU from tc-taprio Date: Wed, 28 Sep 2022 02:47:41 +0300 Message-Id: <20220927234746.1823648-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927234746.1823648-1-vladimir.oltean@nxp.com> References: <20220927234746.1823648-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR0501CA0025.eurprd05.prod.outlook.com (2603:10a6:800:60::11) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|DU0PR04MB9444:EE_ X-MS-Office365-Filtering-Correlation-Id: 9d3e230f-46ec-44dd-b194-08daa0e2b7eb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EVXNBd9rnAjRNxT5Ku7xBfDbhpUnd8AF0pF/cYhDnEzxtqwUYbdXPuuZMZjM8aW3l3Ksq0Xl9D09rCN9W7Xhd1jy4rsIvc2sf4euf/1pQXkx2+VXHuN3oOdR/X2cUIGtsP8J3npkQmD8UUQ8zR38XWV9xWDMg4oMME7u3Cai9qAk141syx74/cU+n8GtcsDKBhq60HAP7RVI0r6yvSsujgTE+jjCEQYmqWzHpg6Htb119hbD+B0xQXM6Muh5nI2saZLlxxmznCZTwTVvXp84aXdBQyNvZt6Fa1oaBgmW/07uKYo6IMn1UqY3tbGauNXKAv3+yNaXqsAzFnelSsYHkgf+kFLxV3et/5x0eLfGWpn0b8dVABo8ws+ZLXQuzEQpDQIjteAxg1JknS7y5WFtOsezD6xW+lwx+9iwEB7YrfKjLR3sWQoTLecyx6/hKnbzBDrb+046F+wCBLRzlXjbhYLNOgV3l0uFlXcM7Iz+apM+S7RbGiHit+/UvzIGqEUg/RP7qYYCRcqOC1faaVj9T8m/41PQmKCwkZ+uJ+jR+AwOrkJT5ekrXv5Ms9JFwn5aKD6+CNTlbh4Awj6ymOfPD1ecTw/0spdso+0AW8Br3qyjs2iah9BQxKIlg8lTg4sSHjNS7Dq4YW6bp7tg4HD25LrtrV2FWVTWYPz2qprVbSgxeDBycyMZ0IsckXA0jTGu5aTnWpiHg4PS4pp6wmNi007ilfwXEbaLMvxIOMlZIh8z43fCoeLw7Sea2tpDbLLvAleLzAiF8pCoW++hYmGEww== 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:(13230022)(4636009)(136003)(366004)(376002)(39860400002)(396003)(346002)(451199015)(7416002)(6512007)(41300700001)(6666004)(36756003)(6486002)(38350700002)(6506007)(6916009)(8676002)(86362001)(66476007)(4326008)(26005)(52116002)(8936002)(66946007)(83380400001)(38100700002)(316002)(54906003)(186003)(1076003)(2906002)(5660300002)(66556008)(478600001)(44832011)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UIllg//zdYMhVvt1tEIHORn6kIhlSkIKzyaZahH7TTBdkdGsCFsGtf5CYIUt0p+L4QR5GGyXA1VOleqoxD2X1zmvjALgixMRE9JND7bbbX+ByfrhZq325HuS2He0fOf4HPSdCqNKYkgtzDc2ybLaMZ9FIO8FDBj3ZuEAJUIgtITqfjVugPgzU0j+aZHvgTeNbEih7njYKYJ/A3QT4J7Vz+OL17ggoYw/PF1o2L4nkR5zJmjVkeCnGWfXFrfVzZvE58+DB/c2J4H/y/bIZuranwvUbp2hu0S8vHAH96O9OHmgT/s/fO1nL5FI0jWGRn+NIVD+KK3woY257ATBMcAIcywQ/X2bJGzFNHdJTaqzo+jDNtIT26SBxJQ55quJYJ7zC31B1o3xaNe7pG4vXM3/1/N5upIZHNLj9gUY7SM7fUdoLDxATFg1c33d1PBNk527wMpNNsu5asIe2MhbF4Xhgq7R2pOMUKDZ+7kBCiW2n77iyT6/oJOMQq7JCi/2QYG0yWh1TG3wHY/vV77tw6eBtO7a5g/IVEEL977kU56WKQxXSOXOUVoMtnqyp5IE9wug3v28HL2z1O+uIAnrwQVGSNxck5n84k6MA6Glm4MFexIsIwZdAOT9MuAn1GNh3h0Wj+QyPFFhvb1hWe8Fm+yrc9smhH+k0nLrsGOWdgkdck24CZcBxFbDoqePeGUWyn9ctsVuuWVXwwvJh9xyJrKeLcUhES6lNyJNsBRj1X9avxboUS2jxN7VVHR7ygiGSjsdxwd0MGCtAMDg0d4SfrIR9xtEatdLew1DA/FZWzPHBtlD94fj3yyPJobPcpPbmRofz6o5AP8vOB28zMAZO8xfEXkEi1NLSoBFN7qrCcMZXbBvo6DmN1v8ctHAapBl0dRHcD6Dj21ZMELzZDjO4AL/aqA8Yo4uDvnxkYV0unmCyjtKkaX/HsaSni0r+JHXyHrHuQ1XxfmxBz5bFb1IbxjJsFDj/wwfVG20dOWjDdQxG4BqkLOampLOKiWAAE5wSDb1f/vQP5XAJcGbZxkJ/So2bMsD5R9Y95d36FJG/a9fGSBgUurlZ8TJbtoyOauYyMwReN88syRUdJCvY3/d8D/jhnbCCqEgFA2r36jnU6tE9FRp7GlAN5Z4Sj7SEnM+ljq4BBWSfJ5Jcfy8AO5xzgtAieIgV2wikvtzNQVlnjOvpUw86a1FMrTx8ISR7N6fRc6fx9y+0s1H3aPxeqa4drzGUROBb2DfzBG7LFJjNPTXBCSJAm/VWNfWcFRDD9fiQF8+hmZp1pyLyHPvHioCfRh0h9mexHkiiI9Ra2ayharaNeVCwgiHd1/FjX1rRzDjVdO4vTZjICHeUNjh/fNRIuoIfm3uADRXYnS1F1ejjXemb4I0Qqnw9ldYgScVVnPRLl7OQDvjwl7IcfOBzoRghcpGIsvXEV+E1W9tGKKywiWUk6IBjJJ3uUIrp9jZ6Ln6gH0KQe4FPaFpUFSeIj9iNcFFdnY7WpWwiYMdihx6cnfFz5i2ynVc2K4+gVeOu9D9dcOoN89yF+anUrtsIDbtjxc2t2gaGtDDr2VMN/OKl3fz5xbmUSxV7Hm5b+Jhg/sb/jqeeLGGysWjyWN9WtegWvB/Cg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9d3e230f-46ec-44dd-b194-08daa0e2b7eb X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2022 23:48:03.6638 (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: kqrKsEL/buopAsK6v8vIw4Bk7DB1y3iSaypQii//H6a3jmJg7pqwsPZ6NQTdDsQ6sNf1OUvG16CviVvQUvmRGA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9444 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Our current vsc9959_tas_guard_bands_update() algorithm has a limitation imposed by the hardware design. To avoid packet overruns between one gate interval and the next (which would add jitter for scheduled traffic in the next gate), we configure the switch to use guard bands. These are as large as the largest packet which is possible to be transmitted. The problem is that at tc-taprio intervals of sizes comparable to a guard band, there isn't an obvious place in which to split the interval between the useful portion (for scheduling) and the guard band portion (where scheduling is blocked). For example, a 10 us interval at 1Gbps allows 1225 octets to be transmitted. We currently split the interval between the bare minimum of 33 ns useful time (required to schedule a single packet) and the rest as guard band. But 33 ns of useful scheduling time will only allow a single packet to be sent, be that packet 1200 octets in size, or 60 octets in size. It is impossible to send 2 60 octets frames in the 10 us window. Except that if we reduced the guard band (and therefore the maximum allowable SDU size) to 5 us, the useful time for scheduling is now also 5 us, so more packets could be scheduled. The hardware inflexibility of not scheduling according to individual packet lengths must unfortunately propagate to the user, who needs to tune the queueMaxSDU values if he wants to fit more small packets into a 10 us interval, rather than one large packet. Signed-off-by: Vladimir Oltean --- v1->v2: none v2->v3: implement TC_QUERY_CAPS for TC_SETUP_QDISC_TAPRIO drivers/net/dsa/ocelot/felix_vsc9959.c | 35 ++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c index 2ec49e42b3f4..db6a29c5fda0 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -1248,6 +1248,14 @@ static u32 vsc9959_port_qmaxsdu_get(struct ocelot *ocelot, int port, int tc) } } +static u32 vsc9959_tas_tc_max_sdu(struct tc_taprio_qopt_offload *taprio, int tc) +{ + if (!taprio || !taprio->max_sdu[tc]) + return 0; + + return taprio->max_sdu[tc] + ETH_HLEN + 2 * VLAN_HLEN + ETH_FCS_LEN; +} + /* 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 @@ -1257,6 +1265,7 @@ static u32 vsc9959_port_qmaxsdu_get(struct ocelot *ocelot, int port, int tc) static void vsc9959_tas_guard_bands_update(struct ocelot *ocelot, int port) { struct ocelot_port *ocelot_port = ocelot->ports[port]; + struct tc_taprio_qopt_offload *taprio; u64 min_gate_len[OCELOT_NUM_TC]; int speed, picos_per_byte; u64 needed_bit_time_ps; @@ -1266,6 +1275,8 @@ static void vsc9959_tas_guard_bands_update(struct ocelot *ocelot, int port) lockdep_assert_held(&ocelot->tas_lock); + taprio = ocelot_port->taprio; + val = ocelot_read_rix(ocelot, QSYS_TAG_CONFIG, port); tas_speed = QSYS_TAG_CONFIG_LINK_SPEED_X(val); @@ -1302,11 +1313,12 @@ static void vsc9959_tas_guard_bands_update(struct ocelot *ocelot, int port) "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); + vsc9959_tas_min_gate_lengths(taprio, min_gate_len); mutex_lock(&ocelot->fwd_domain_lock); for (tc = 0; tc < OCELOT_NUM_TC; tc++) { + u32 requested_max_sdu = vsc9959_tas_tc_max_sdu(taprio, tc); u64 remaining_gate_len_ps; u32 max_sdu; @@ -1317,7 +1329,7 @@ static void vsc9959_tas_guard_bands_update(struct ocelot *ocelot, int port) /* Setting QMAXSDU_CFG to 0 disables oversized frame * dropping. */ - max_sdu = 0; + max_sdu = requested_max_sdu; dev_dbg(ocelot->dev, "port %d tc %d min gate len %llu" ", sending all frames\n", @@ -1348,6 +1360,10 @@ static void vsc9959_tas_guard_bands_update(struct ocelot *ocelot, int port) */ if (max_sdu > 20) max_sdu -= 20; + + if (requested_max_sdu && requested_max_sdu < max_sdu) + max_sdu = requested_max_sdu; + dev_info(ocelot->dev, "port %d tc %d min gate length %llu" " ns not enough for max frame size %d at %d" @@ -1637,6 +1653,19 @@ static int vsc9959_qos_port_cbs_set(struct dsa_switch *ds, int port, return 0; } +static int vsc9959_qos_query_caps(struct tc_query_caps_base *base) +{ + switch (base->type) { + case TC_SETUP_QDISC_TAPRIO: { + struct tc_taprio_caps *caps = base->caps; + + caps->supports_queue_max_sdu = true; + } + default: + return -EOPNOTSUPP; + } +} + static int vsc9959_port_setup_tc(struct dsa_switch *ds, int port, enum tc_setup_type type, void *type_data) @@ -1644,6 +1673,8 @@ static int vsc9959_port_setup_tc(struct dsa_switch *ds, int port, struct ocelot *ocelot = ds->priv; switch (type) { + case TC_QUERY_CAPS: + return vsc9959_qos_query_caps(type_data); case TC_SETUP_QDISC_TAPRIO: return vsc9959_qos_port_tas_set(ocelot, port, type_data); case TC_SETUP_QDISC_CBS: From patchwork Tue Sep 27 23:47:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12991493 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 16422C07E9D for ; Tue, 27 Sep 2022 23:48:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231278AbiI0Xsu (ORCPT ); Tue, 27 Sep 2022 19:48:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231755AbiI0XsM (ORCPT ); Tue, 27 Sep 2022 19:48:12 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70084.outbound.protection.outlook.com [40.107.7.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4D591BF0D8; Tue, 27 Sep 2022 16:48:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ORHTHFMK0Bjaq2JQeOIJdl0qTDts0/m7QhDGNVwFu35fbr3No1lROlxSw1Nv3vld94ZDxBOXAufzYwX0RkO/syFFvcUKUp13KlbndFfylfTDnqIdvAIwTKtqJoS01eWsw/dZSgSeijCD1I67NvByN2PHWN8no1cBHjCYqcAgNXt1utPClB3zKbCgNFuqMbGN5XWM0uspdGItbut6B4LZ5kcj2qQ8LjoeG0dzOkl75eTHRwQ5mgRdZsqfFA9ehQNMfd2lrofwkW7DQD62kEEYBB2St4ZUVayjp/2ak1vB5Pe7aYMsdHC9NWhsEcsyrfzO/RA8StMTQi+bF7eCKiPGLw== 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=ODzc0lOKjPqguIXqdN9ULcmc5qbmmPPIdBuOdqYOwwQ=; b=hKR1C3sR4gz/W9D3UJxc0HXSRgbDkQk1vEqz6/s3xbz34TK5oXEiQKhPU1tLHxj/gFJ02gfLqlZTMhfk1DLz7kG7TvnuALK/o4vDX/SuQvrO6sbuZ41fY7aIcuTybd7XFJCYOBHt48h8tOAZgnmgYgxisUSIK9Dl201Wj95qFRCYB2nGygHVvy6uKmzJyX+okd+UvOnrTQ/fliKFaRI/GJuWrHbSVhewXPvyoaotsbqlRBtcIT2NuaqKcsW8lLCQ+mDFiMXsLYVS6RMwCInE6l3ry3J1sSOItfeu3XtIZ4/cHnWzc4uMN913traSeGW+uIKyRr7QrK8RNkJgefKbvg== 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=ODzc0lOKjPqguIXqdN9ULcmc5qbmmPPIdBuOdqYOwwQ=; b=qUTchwjf1myqY9zjy5BPZAhQangz+QgOf8huuC9nAlJbI2z4N7ii0GrEJF9JhDZ8lmyD5vFmVkdBOWyVVNkvtawWWYfkboy0iENBlJZ3k6Y60vksvTn4fwUpfDmXJD7r0OlAr/fHdw7k1z+Ud49gfW5rR5R95cx8jgqPpxKuXUU= 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 DU0PR04MB9444.eurprd04.prod.outlook.com (2603:10a6:10:35c::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.20; Tue, 27 Sep 2022 23:48:05 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::a67a:849c:aeff:cad1]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::a67a:849c:aeff:cad1%7]) with mapi id 15.20.5654.025; Tue, 27 Sep 2022 23:48:04 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Xiaoliang Yang , Rui Sousa , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Horatiu Vultur , Andrew Lunn , Vivien Didelot , Florian Fainelli , Michael Walle , Vinicius Costa Gomes , Maxim Kochetkov , Colin Foster , Richie Pearn , Kurt Kanzenbach , Vladimir Oltean , Jamal Hadi Salim , Cong Wang , Jiri Pirko , linux-kernel@vger.kernel.org Subject: [PATCH v3 net-next 4/8] net: dsa: hellcreek: refactor hellcreek_port_setup_tc() to use switch/case Date: Wed, 28 Sep 2022 02:47:42 +0300 Message-Id: <20220927234746.1823648-5-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927234746.1823648-1-vladimir.oltean@nxp.com> References: <20220927234746.1823648-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR0501CA0025.eurprd05.prod.outlook.com (2603:10a6:800:60::11) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|DU0PR04MB9444:EE_ X-MS-Office365-Filtering-Correlation-Id: c78a1993-5396-4fd5-2ee1-08daa0e2b8af X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NYQTijVv6/uhzSgt+r4APvx31W9xFelwIxbqNAR7gM6KSwA55ac1W6liIVk48PPbmmU2qyVQ+eycLzwBkPyHYrPYmjOVnemAbwL804l8nkMsQ5HkFMxUWdRA+E2PlDbwcVpjPlOA4cALv3Pg0nQ+CF+mBmUDF1S7p1IMYMEgpMchTLCfG0VJViA2goitGudoKMBRCXSRowWYlUkwUfrp2LoG9U8YY51TpaxV7zkIFXSvtASItJSunU8Wo+LcHfMykvAe6Ojv8PwYnD0yex8Hl2jHo5m9G9dgxvNS7P+cCdLSVVBD/FdspqugsbVaLh2s98Ny1F3mdMwzC1I0Q++OlUuLmQdSlbQ8bdyJmnGcWV+NfpY8ZzbC4TwRiRcSW9exW+g5htAHiSTTceqTG0aTSjDEACDhp3ASNmydF+d6q2gIia8uK/KpjJScVJpv7tr/6ky4EIczqpN/1RaFiHQTsb4pWmIcRXusQA2d+TCQRCc0FF6Eu8leHaUmZpCmRkLDiNI5BRVqpU81S2N2dYGo4LozR8YJn+JF2aD8EhT0yncIPx4jGb7EmweRHTYbXJWsGUm9mXzf0cDPk1YOv1ZEjPy9LY8BFwI+qrUo+v2J/gICeHToQZFzaA4OCGvamP7B3lEHR1AHym2xE74QIqmSbp9cddps+85jHEb+mBh3UeUl9n1aiEqggiT4t5FRpe6Olrtssy1APwvRnhSjsC3uY5Kf99FUJFArpYXXplDNw0jB2tBJ4OfTVD/sThTtsViYBb2htKlNMT/cN/URbuTKyQ== 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:(13230022)(4636009)(136003)(366004)(376002)(39860400002)(396003)(346002)(451199015)(7416002)(6512007)(41300700001)(6666004)(36756003)(6486002)(38350700002)(6506007)(6916009)(8676002)(86362001)(66476007)(4326008)(26005)(52116002)(8936002)(66946007)(83380400001)(38100700002)(316002)(54906003)(186003)(1076003)(2906002)(5660300002)(66556008)(478600001)(44832011)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1PcYQF5J7JEpumRhxl74rRWIiR1LlH/4HE5WdOpV8zYk3jD74rrMtMYdE+YmtgK2c2tBlGLUXML+Mdf2ql8j0exXiI0jk7VVU4wdzhvvR74ecBJ6+jzUcRt3x1hjkAZuhP8gZIMAhcZ+1w+MXewc3OQ00RGWPlKScbClzVaSFdL6I5LuM0+545EUKgCKJ+WjGIXDzXRWtUaxTwg1AZDlSFTrmkoeDoYffWsa88BrQSi10HTJiW1wg5KSsVARvIipxuVpk1rDJkujTfHBUamwaAZ9f49iTLxnxuIpoMuErkOBgfS5vweZfaLnQwl4Y4hqn6LesRNyJJqlZq79JRhHiQV8mwVY2jgAbPZiPC1QonHpxfHEjd1n8Vu5Qs+h3pTPUpUOI8xUNQN8a6l6jUbLkKcH0krWphUPS3VMieCoOAkw3RBoNwgyOVhejsnvjYNrzsfmhu22KKXSpY73LI3DJsHBvqkfFKiJRJ4JWdPfGFaygxN6yozHiWuy3g4T5X06fk8VqfmSj2mq0YMP49+bi2mu5/UjIT3k/Qas839fjLheWezmbFsYTBKwnHHSa9JOR2vEqka7idtKgZsdJioRPe4Ja4Ens6yNK5pap+h5mHEY+iqkIb0lRbkGN51Lg1M06+B/MFdNa7YYd05yPxjlPpGq4GZ3tXabPfXizQbutlnIYrCpN4tZwxX5aH4eGVJjaSK/JXBvitg5NKIK+ArjfmN1fyYX5fcOiYz8Mnp+2183vOnuc+1wtt+KE7zfMKP1Z6//DdhQa6qZfrJUxJdtsxmHwlNJx9AAxgdlZZfuXCZiZ8roM5CG1V+ipXR0Q/2wwKcSKUI/ZNN6FKGDg6C5AjQY3q0A1fopCOdVjFP71ityPcrSIOLCmRhA6zU+xLau/08pmhSY7A48+aBy2uorSU7CAmVJaAuOHj7QYs9u6P7Jf4uIAhXsjqiQt3dH4SnDrUryBHABnf+fe3XBn5z/FTPXkEWNrujOj1LDUS2in8Gz1uKDGkTK0LAcdV3VWdJHvyxE8lcsBmrEX4IwCVLD1Ol57wkNPmXk3p0e07n4me4PGrb49bt9Qb0n1sxz788+x+11QBu3npQg9JIWzof5DIayE4+uosqI6AK7Vs9UssJSVfIS3S60KW6pw6fOmxI5AmxatjzbLQLyMHYk6XeJE/de2Tw87kNwG7mQUNVoiYg4OpfQ313GMXpJcrnzxx+t7M0dY4gqBmooFSLTM5qO9/TiNsP6wI/d6KAMlyk2oRYlvbVvhBAJfchyy6i65BC8OjwTu3s92KAqgYNvxbBYeyd0Uwjaxrmv9I2XPNNv0TxUrPWYQe7YvcuuVhdCz+CKZbc7sfn/U53mqOc246YUbKShjJwgsvnBiE6PThifFbU7wrtM0womRR3tSlpFWuGBhNiaWpu09JLUH1+ui39lD27C2PZPaQxMuQdxQSgxIJTX4fakyWqlNVbtQIauNLwA3z9tyWN24ATmgGRBi6WodMyjRu1XjkqyLFQuDxUb/5DEc7gkEoFrpWTy8UsvQFEGCNUHfJFCDeFKVuyuK2v/fwHRMFlbomWHdhUB6FPn/hYO4YHG6xAIBas0jWHK5Glv4vdvpINbH880hgjQluDFEg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c78a1993-5396-4fd5-2ee1-08daa0e2b8af X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2022 23:48:04.9450 (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: ywIIgIG6JKQ4xwO2JnqmpovU57Kj+E66b+zqO1lVGD0/Y3jl27vj+T/PT03Y3zMWxsM0U5HYHr12dkEfIxeOtA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9444 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The following patch will need to make this function also respond to TC_QUERY_BASE, so make the processing more structured around the tc_setup_type. Signed-off-by: Vladimir Oltean --- v2->v3: patch is new drivers/net/dsa/hirschmann/hellcreek.c | 33 +++++++++++++++++++------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/drivers/net/dsa/hirschmann/hellcreek.c b/drivers/net/dsa/hirschmann/hellcreek.c index eac6ace7c5f9..ab830c8ac1b0 100644 --- a/drivers/net/dsa/hirschmann/hellcreek.c +++ b/drivers/net/dsa/hirschmann/hellcreek.c @@ -1809,22 +1809,39 @@ static bool hellcreek_validate_schedule(struct hellcreek *hellcreek, return true; } +static int hellcreek_tc_query_caps(struct tc_query_caps_base *base) +{ + switch (base->type) { + case TC_SETUP_QDISC_TAPRIO: { + struct tc_taprio_caps *caps = base->caps; + + caps->supports_queue_max_sdu = true; + } + default: + return -EOPNOTSUPP; + } +} + static int hellcreek_port_setup_tc(struct dsa_switch *ds, int port, enum tc_setup_type type, void *type_data) { - struct tc_taprio_qopt_offload *taprio = type_data; struct hellcreek *hellcreek = ds->priv; - if (type != TC_SETUP_QDISC_TAPRIO) - return -EOPNOTSUPP; + switch (type) { + case TC_SETUP_QDISC_TAPRIO: { + struct tc_taprio_qopt_offload *taprio = type_data; - if (!hellcreek_validate_schedule(hellcreek, taprio)) - return -EOPNOTSUPP; + if (!hellcreek_validate_schedule(hellcreek, taprio)) + return -EOPNOTSUPP; - if (taprio->enable) - return hellcreek_port_set_schedule(ds, port, taprio); + if (taprio->enable) + return hellcreek_port_set_schedule(ds, port, taprio); - return hellcreek_port_del_schedule(ds, port); + return hellcreek_port_del_schedule(ds, port); + } + default: + return -EOPNOTSUPP; + } } static const struct dsa_switch_ops hellcreek_ds_ops = { From patchwork Tue Sep 27 23:47:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12991494 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 542ACC54EE9 for ; Tue, 27 Sep 2022 23:48:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232047AbiI0Xsy (ORCPT ); Tue, 27 Sep 2022 19:48:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231985AbiI0Xse (ORCPT ); Tue, 27 Sep 2022 19:48:34 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70084.outbound.protection.outlook.com [40.107.7.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B16F1C4590; Tue, 27 Sep 2022 16:48:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Weqx4Tm+c1BnWMRN3ZDgbpZie+xt40oV0pWo3BTnncquRmHosiCw4MZHE/bXnIq0rArM3mQL1Yf6HSysTSpVlxB5wY0KoRSfTyTqhFFFpkQox2YZ+x/cijeIXtQ2aPotM8sA1Yqn+5CKB4Pl4N/oCs7bn0hwTrIJ0PKWD+Ou6Xthsn3RBcrYS56zoHVq0aO0qsV38HGVbDKkKXD2g9PrhgEk8WFUwOAH0CEg/iCWjw9lNV8773y/QkYgHdReMl0X874O6e3zBJtFJzUr78h0IMLoLwkhYeoRJG3+YZZG4uSQhYYsAanFTayDTNvqGFUSdaQkVwPnuZnDu+VjVNNW9w== 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=nWo4937FpvHkygxm7c+sgGfY1H3LCN13U8eA7eqLtEA=; b=oKnktyGXQrqyh5RtP0Ok4xGKKY51STCO8r21RQTNvLdXr85uokuj/dLbmlMvsTlpPzkfDV7xc19OpxMIPSDnSUwtMr0yCWHoY4kCdI7u1jj+ASl2vJisOHLtCUr+3ypQCZWAdHZoA0GlbDdmrTkhhWjKCbgafptv74tGnY2mUznchiG3YpRUFpfD7Z7FPwSSldX4HRr6Ld/2ePUofR6HrQgwpFSrCFDLbtgqQHT4h4OqquaiV+fbLjolkQI/U933V8Mt0aN3VCyRv79y/bwAceJLPjfbzege0xomcYsqJ8oofpq/44h7ES3I+lOFEWopur2KYGvmyZMnE9xcPT/T9A== 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=nWo4937FpvHkygxm7c+sgGfY1H3LCN13U8eA7eqLtEA=; b=F5/3xM4rAOpaP7opBQEQYyo11z9kkSjoEgCDidO2eBADNiuqgOcRH9sHf/3gjDzTf4AymvFY6jA0R9/0hGA1x0uLiDIqUnl9X0o/9Tl8Cv8EY/BuYbfy2olWkJ7KuK1FU9N5GabgTaKmLekHnN5s9UtXylvpTHY+IB2q6s8r3eI= 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 DU0PR04MB9444.eurprd04.prod.outlook.com (2603:10a6:10:35c::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.20; Tue, 27 Sep 2022 23:48:06 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::a67a:849c:aeff:cad1]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::a67a:849c:aeff:cad1%7]) with mapi id 15.20.5654.025; Tue, 27 Sep 2022 23:48:06 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Xiaoliang Yang , Rui Sousa , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Horatiu Vultur , Andrew Lunn , Vivien Didelot , Florian Fainelli , Michael Walle , Vinicius Costa Gomes , Maxim Kochetkov , Colin Foster , Richie Pearn , Kurt Kanzenbach , Vladimir Oltean , Jamal Hadi Salim , Cong Wang , Jiri Pirko , linux-kernel@vger.kernel.org Subject: [PATCH v3 net-next 5/8] net: dsa: hellcreek: Offload per-tc max SDU from tc-taprio Date: Wed, 28 Sep 2022 02:47:43 +0300 Message-Id: <20220927234746.1823648-6-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927234746.1823648-1-vladimir.oltean@nxp.com> References: <20220927234746.1823648-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR0501CA0025.eurprd05.prod.outlook.com (2603:10a6:800:60::11) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|DU0PR04MB9444:EE_ X-MS-Office365-Filtering-Correlation-Id: 262693e8-93ae-4eae-ac30-08daa0e2b972 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rZaWOoRRpvKSN32n8U4fJec6+luZwqY3fXVttJw2VtNEyTO+NqtCjltHN3fR8kbAKouHvEBBfHjrDmMJQYM/mHBiz9Da9UC9z2Aq7JH1z1idEAko1pvX1ac5PqP5PZ4lIp5tGmFXJ+1jlAN+kRi4pJqxvoiMu8673z/bRXX4p2WSre72GU28fzqDUGixpoP+aN49jooi9LnhwbFXbalZS1Tn1GMTfo8Kkq/zUXTEeQNQYzp+MIQP99lgds4mhYbBzhum2ccES8WuwnWC0Ti7tyD1sDdVXbeowL2lc/JQsigNlCP2Czh4OEOIO2uuKijFDNYYbMcEzz1IF+LW6Dub0MlIaT4CfMam+QAxpaI0F244yQfUAvh/BAj5yyn7sTtSGV6xquL0YWeJESDL6lSBs+Z6xmrlrjLr6j39PdsJ+StU+utA7iemH/Td2yHpc/Q1ZRMRqeiuuS+rEtCzQy5qM5wBSvMuQ/koV/SBg078vfefdiOMMD79Rzr1VaKc587H0VkaGiXemZeneHYPF8n2zhHEalLietfOCO/P7sPLIRhvFNfi9U/anD6BF81NUj/fCIMX5va0jResvTR73+lQ0o7QP26trapxuDDQ0Ldpop0Z0r2a3bSVaOdgn8Y+EaUS6Ckz4FGyhKZ46mrOCMuhdSFT128MhM1LA1Se88Lrk23VdOfH0RS+6KnGQQNNumI4s7bQE7iT6kSJJZShJHvtIWrHW99bAI8rGLs9fCYNMyvugV4PrEt2Aweju1aIng4MJzp4nyl9KLl1QJZxyL07Jw== 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:(13230022)(4636009)(136003)(366004)(376002)(39860400002)(396003)(346002)(451199015)(7416002)(6512007)(41300700001)(6666004)(36756003)(6486002)(38350700002)(6506007)(6916009)(8676002)(86362001)(66476007)(4326008)(26005)(52116002)(8936002)(66946007)(83380400001)(38100700002)(316002)(54906003)(186003)(1076003)(2906002)(5660300002)(66556008)(478600001)(44832011)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /kF25jAHlZWLdaxX6tkrviRBtVgkDtWpqvLPnWbAejKHuneT2AcQ0izDwESZDatprzt7qmDgwv918Glo/5qngnXPGkh84jbddmVddwID+rGu+bVnYxidh35UZX+wfzJk/sVBMsMnUU3Oi4QjnI0/fkP7xRRMwobnJPtAk9D/DHi1H3IqDarOJVK5avXlbyg+50H4ac81LVEnIzn8rJ6xSIXNoNfmSIwBXlnI/cQhXAPArgtp6QFwbV3tkAy4706qDPsmCrlDBoFoIR1wxW+bs/VH4kQw4Q4UN7BXa5WA5s+1Mag3A/N0mmZAkC7CcYsmLQ1IdFlieFSYUYUwlc0xDoH+eu0ChPXkjvesI3pzKJqqG335uSI6eYVoxi6Y2H1xG+idzwGwmyyr8GgksWDuU6u8FccAD/mso8th+oPBy9n47m+XVt6NWSDG2TUvabYXvvhBbA0bL/iBFxEZbeG1DX+rWrwcyUs6Hsj3WwY05I+PTgdVFQndshl2wsJldoqx2G1Bn5LwdySN0Vz8N7sJZI2RYTAyffLltx+3ZTIucnmqEYAgof/fMRrSE9R6DVMS7uJpIsFtIhfUv1zbef2xhFb2srmypRwszU+Uzaf7J6HCdHI6fNaNIGVBnfs7PYmder8iCRrguqGPkIqN3o7dWQAQmsJGY8tOlnk8fNVOB9rjOz+3ydiUjF0cuhLnvpBo+Dhqo5bq3twgPsVPSz2J1efaBH7hBVoj81U1JErCMrKMwx2YM8MS/UrS2S7uXTsfIaPhhhPFFnOI2+wDrS0JxRkBXgMkLOdrdFjXmu+bvH1lYYuNy8SCY5hOa//B+FudZOVt0cJhrBHeH7KdSVVCM8jeJkVG80Usmwy1T+0+4tOw/rgVBZPMqzOm0wiaIToO342uwY/gN3kih67kcclE+DOtU7nLeZb5Iu/sDbq3+1uiE5kcIiCyXig3c8FPOMQquImZ3kxFNHRi4gMIwv881Y1IH++CYzSHdS9AX3D2KwYE2X3OCbnPhyxuCpTVLPOYtohtJxIK7TyUpv+ohAOxWWXfkpfSPr9NvXs4Bcdvg0em71U4bNuw8W1JqqnMuTR7Qiw32v+9HiTQxeyuA3spYyf719O5Fh9w+MdgNHFC/qUhBU6igDSlan6Ly7WRMRG3O/jvvYcjfrerfZFDEe2ZlPvtzPWbewTS/GPcwNnTFYV5m0lp2ZW14xWFXCkE7OrpI3bPt4PdS8/H8/ZIlu03neKlvZVlV5EvSJEQpVyu7Xt6/w3IOpMjxWN8ylP4NR8r3RIt3r208BAOnMZJrhaHQwJX2WV2zHQHRtq9LlhAdm7bMbgKu2X3mGvatZaZV34779TuWaHXF6qA8/DWBqhBN++PoykvwURI0syPCpGmi8HqsBWKbLw2ijYw46uKuwbPBgiyKrvhogJWVuagBG8sO5Et2og0JgU8ZcmiuTZfAuCg0y66t73w81Ml1yE30vPXI5atKbha6YqskwmclMjX/13+V4L8qrHduCkD2fvqKAB7WvP9rFtwpS5105NvCZT4J2R5rgLPCledu1OBdeD3aIYInNB5Mv/HkHMnHnI5va4LBXghTrJ+4lMqjUGu03t3OUyv3Tgsu+v80zJdJVq1Sw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 262693e8-93ae-4eae-ac30-08daa0e2b972 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2022 23:48:06.1949 (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: GdJSehkyzowkig6IBl8n03yIJ2TqRE1tVnbKKhfp+qgKfr7mLnSv8fo540yxllt23UmJv3cZRG+ERJDLQUMU2w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9444 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Kurt Kanzenbach Add support for configuring the max SDU per priority and per port. If not specified, keep the default. Signed-off-by: Kurt Kanzenbach Signed-off-by: Vladimir Oltean --- v2->v3: implement TC_QUERY_CAPS for TC_SETUP_QDISC_TAPRIO drivers/net/dsa/hirschmann/hellcreek.c | 61 +++++++++++++++++++++++++- drivers/net/dsa/hirschmann/hellcreek.h | 7 +++ 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/hirschmann/hellcreek.c b/drivers/net/dsa/hirschmann/hellcreek.c index ab830c8ac1b0..22e52fe1ffb9 100644 --- a/drivers/net/dsa/hirschmann/hellcreek.c +++ b/drivers/net/dsa/hirschmann/hellcreek.c @@ -128,6 +128,16 @@ static void hellcreek_select_prio(struct hellcreek *hellcreek, int prio) hellcreek_write(hellcreek, val, HR_PSEL); } +static void hellcreek_select_port_prio(struct hellcreek *hellcreek, int port, + int prio) +{ + u16 val = port << HR_PSEL_PTWSEL_SHIFT; + + val |= prio << HR_PSEL_PRTCWSEL_SHIFT; + + hellcreek_write(hellcreek, val, HR_PSEL); +} + static void hellcreek_select_counter(struct hellcreek *hellcreek, int counter) { u16 val = counter << HR_CSEL_SHIFT; @@ -1537,6 +1547,45 @@ hellcreek_port_prechangeupper(struct dsa_switch *ds, int port, return ret; } +static void hellcreek_setup_maxsdu(struct hellcreek *hellcreek, int port, + const struct tc_taprio_qopt_offload *schedule) +{ + int tc; + + for (tc = 0; tc < 8; ++tc) { + u32 max_sdu = schedule->max_sdu[tc] + VLAN_ETH_HLEN - ETH_FCS_LEN; + u16 val; + + if (!schedule->max_sdu[tc]) + continue; + + dev_dbg(hellcreek->dev, "Configure max-sdu %u for tc %d on port %d\n", + max_sdu, tc, port); + + hellcreek_select_port_prio(hellcreek, port, tc); + + val = (max_sdu & HR_PTPRTCCFG_MAXSDU_MASK) << HR_PTPRTCCFG_MAXSDU_SHIFT; + + hellcreek_write(hellcreek, val, HR_PTPRTCCFG); + } +} + +static void hellcreek_reset_maxsdu(struct hellcreek *hellcreek, int port) +{ + int tc; + + for (tc = 0; tc < 8; ++tc) { + u16 val; + + hellcreek_select_port_prio(hellcreek, port, tc); + + val = (HELLCREEK_DEFAULT_MAX_SDU & HR_PTPRTCCFG_MAXSDU_MASK) + << HR_PTPRTCCFG_MAXSDU_SHIFT; + + hellcreek_write(hellcreek, val, HR_PTPRTCCFG); + } +} + static void hellcreek_setup_gcl(struct hellcreek *hellcreek, int port, const struct tc_taprio_qopt_offload *schedule) { @@ -1720,7 +1769,10 @@ static int hellcreek_port_set_schedule(struct dsa_switch *ds, int port, } hellcreek_port->current_schedule = taprio_offload_get(taprio); - /* Then select port */ + /* Configure max sdu */ + hellcreek_setup_maxsdu(hellcreek, port, hellcreek_port->current_schedule); + + /* Select tdg */ hellcreek_select_tgd(hellcreek, port); /* Enable gating and keep defaults */ @@ -1772,7 +1824,10 @@ static int hellcreek_port_del_schedule(struct dsa_switch *ds, int port) hellcreek_port->current_schedule = NULL; } - /* Then select port */ + /* Reset max sdu */ + hellcreek_reset_maxsdu(hellcreek, port); + + /* Select tgd */ hellcreek_select_tgd(hellcreek, port); /* Disable gating and return to regular switching flow */ @@ -1828,6 +1883,8 @@ static int hellcreek_port_setup_tc(struct dsa_switch *ds, int port, struct hellcreek *hellcreek = ds->priv; switch (type) { + case TC_QUERY_CAPS: + return hellcreek_tc_query_caps(type_data); case TC_SETUP_QDISC_TAPRIO: { struct tc_taprio_qopt_offload *taprio = type_data; diff --git a/drivers/net/dsa/hirschmann/hellcreek.h b/drivers/net/dsa/hirschmann/hellcreek.h index 9e303b8ab13c..4a678f7d61ae 100644 --- a/drivers/net/dsa/hirschmann/hellcreek.h +++ b/drivers/net/dsa/hirschmann/hellcreek.h @@ -37,6 +37,7 @@ #define HELLCREEK_VLAN_UNTAGGED_MEMBER 0x1 #define HELLCREEK_VLAN_TAGGED_MEMBER 0x3 #define HELLCREEK_NUM_EGRESS_QUEUES 8 +#define HELLCREEK_DEFAULT_MAX_SDU 1536 /* Register definitions */ #define HR_MODID_C (0 * 2) @@ -72,6 +73,12 @@ #define HR_PRTCCFG_PCP_TC_MAP_SHIFT 0 #define HR_PRTCCFG_PCP_TC_MAP_MASK GENMASK(2, 0) +#define HR_PTPRTCCFG (0xa9 * 2) +#define HR_PTPRTCCFG_SET_QTRACK BIT(15) +#define HR_PTPRTCCFG_REJECT BIT(14) +#define HR_PTPRTCCFG_MAXSDU_SHIFT 0 +#define HR_PTPRTCCFG_MAXSDU_MASK GENMASK(10, 0) + #define HR_CSEL (0x8d * 2) #define HR_CSEL_SHIFT 0 #define HR_CSEL_MASK GENMASK(7, 0) From patchwork Tue Sep 27 23:47:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12991495 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 56319C54EE9 for ; Tue, 27 Sep 2022 23:49:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232565AbiI0Xt1 (ORCPT ); Tue, 27 Sep 2022 19:49:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232414AbiI0Xsw (ORCPT ); Tue, 27 Sep 2022 19:48:52 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70084.outbound.protection.outlook.com [40.107.7.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 367A11D73D4; Tue, 27 Sep 2022 16:48:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OnCp8DFYEJrJsUpkLmj31cZSEoIazzLkiJxM62mx0AIUxwZ5S0o6MgtFjOwB2McnEdoWp5ug7/Ee21cn47/XSSP7mNYEZ/DTDvDBn8p2XpQlLP1kcOjDQMAao0pTQT9JrgPWbV4Hb1okSavpvTs+O+WcOTUFLt6/30J6T6q2abiOhxBJSMVYBaFtkclSTLjPLkvUNhau640ablXL/LoSoggWAjiA+ukv5Fx24+zzxcY/WRR0lpkLRwPQQh0dqQ6+i7YbLzGH3m7qwFz5NDmmuYxURhJ9iNOIGxkErjsePCErM94IiEv3CD+dzCkqOQjXfQvzD46GDG84FrHuT6dXEg== 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=Y2k9KX2EBBb9iLWrxxR5a9exb4A/6QiqWvZjyuSoIaw=; b=n9A0w9FdR/4rbibx1Nd184AcqNt4CCvZoWYRB3HTtd3GED/lg9J5ObWWA4wKfWvvs8v450bw2wgyFwCR9gtlLPesN0CM2r2KJI/p4yVrH2a+UJPCsQwXxN3refe2SW3PCEE260KS/j0GQU+K2t7cuYB3xgaZ8OJp/mArLK0MiRxAoP/j0tidOLyBoxBHCAeRuqMv4hizzWzUlFwoBUykPS0qcFzo0RVNYdB+wd7fqgytJaEA0E1o9VZAKxbPs6TmbvOGAaVIa9ityG0obxXz7+9NAniYnxKFET17YPfPr44hAExCrwSiLzJhYiurfJYHKtq7CHm0rPFfE/D6bLOZDA== 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=Y2k9KX2EBBb9iLWrxxR5a9exb4A/6QiqWvZjyuSoIaw=; b=PJXir/94bMgAR/j/QfnVDzoLNVrboHzvg42Xh+Dh/HlwhZtm4iDQFvcuPDBv2rJVISuTfHILk6pc1im1xhV04sfTwe+zhgl9EdKOV3fFXLj75OiuSH4SJoWBXHuChtID7Nrn4lYbc15RqUjxsdZe3LGIxpnjROvu/svYVDcSBxQ= 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 DU0PR04MB9444.eurprd04.prod.outlook.com (2603:10a6:10:35c::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.20; Tue, 27 Sep 2022 23:48:07 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::a67a:849c:aeff:cad1]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::a67a:849c:aeff:cad1%7]) with mapi id 15.20.5654.025; Tue, 27 Sep 2022 23:48:07 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Xiaoliang Yang , Rui Sousa , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Horatiu Vultur , Andrew Lunn , Vivien Didelot , Florian Fainelli , Michael Walle , Vinicius Costa Gomes , Maxim Kochetkov , Colin Foster , Richie Pearn , Kurt Kanzenbach , Vladimir Oltean , Jamal Hadi Salim , Cong Wang , Jiri Pirko , linux-kernel@vger.kernel.org Subject: [PATCH v3 net-next 6/8] net: enetc: cache accesses to &priv->si->hw Date: Wed, 28 Sep 2022 02:47:44 +0300 Message-Id: <20220927234746.1823648-7-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927234746.1823648-1-vladimir.oltean@nxp.com> References: <20220927234746.1823648-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR0501CA0025.eurprd05.prod.outlook.com (2603:10a6:800:60::11) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|DU0PR04MB9444:EE_ X-MS-Office365-Filtering-Correlation-Id: c49f7457-1cef-4508-0281-08daa0e2ba2f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5NJSRbe4YOxLgTaAccdg6J/1GEuTAxaZVv7ne02iyohbYOSOA3aVKbtqlF6v0ls+5JJ/5/7fF2rO/fzIn1odWA8qxxzsdBhJW5LECAgR6l3skKBdFjxA0PrP0316wYh0JtbZmS4JQzpxYmR8rJDtiLlcGefwaY8u1+0jCBqClmJPcuFXgQfpM50OKHv6881s8Ncldt8DmwAe6m8LNVg8W9DMOgNT7QeW+TgZop5wUS8/PvdGrbc07OUE50BHl+89Q2iCfKA+KwVUZMchY+7SpmDFTKgiiKgdIcLV5+579NytSe7c7nXvhTWmc56bLooi6Cz/JpyHWmxGopTJRqF76HHOeq9rzEcQhgEQoTo0K65O84Bs+9LUJZyvNxObA9AjNtq5Qko/0cpDQ7ikOJXRdzi0Pw6i0HFuXHW2rDxTcSfsi6I1Owoq0J/BhIwDUV3mZH9UkmMVKC5YtguSSlR+qZAvmfKk9sDA/tunF0ms6mC+3plW7Ck+4nxcWeW4Mdpkm3xtYrl0xFhUpF+m4VotwW2w5qdVdWPrTsFr3hE8mmESqu08g8Id88zUI0lUrSbOZSBzv0JRQs2hXPcw4nOEFOgOCN2BVRieGYI81AF6Ka8jyrnNIyFmoUUtCi5HGsHXun4aZeqjQfBjoj2QisRv4anYryC84uCnkBBf7nW++IiAIKenHsQAX5OcN+LcuqYYGUFqO03GmsMvNE62yJAHq717QuD9wSNgbA/8Ap3mqCjcxSGqMO6HtxIaOe21yrHIW+nLGLXm14gbcaTzSv+f2Q== 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:(13230022)(4636009)(136003)(366004)(376002)(39860400002)(396003)(346002)(451199015)(7416002)(30864003)(6512007)(41300700001)(6666004)(36756003)(6486002)(38350700002)(6506007)(6916009)(8676002)(86362001)(66476007)(4326008)(26005)(52116002)(8936002)(66946007)(83380400001)(38100700002)(316002)(54906003)(186003)(1076003)(2906002)(5660300002)(66556008)(478600001)(44832011)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Lu74FOQwvaRy2IKz3YTNaJOh2/vI/FP8Q3iukjtiXFR+bY+O9QScd8ofzmg93SMCwHxD0F905LVSVcdo6TT29EoE4NeNJoehKIN089ZW/GjV7R/Cctuma7/Augi7XB9YN2n0uxn63CB9BCV/DXtco9ElUPlSbejf633PaVv0WSYRPkCBm7Tf1AaAVEmtDG0cCfel9Lxh5OuSChNJ2p5YqVbdx594D5YRWMLgcpwLJFN0C4uE1zamdTfPGF9tQqwgVH5QPGAETXRpFFq1FCmTVDCGqG5OzB32BK0x4E713kc7aB+MuemtjTG44Vvgt9VzGBrX5eG3eJZpasoivzT1K4fGIeIOEtwNKkDdm0csonkLuPOBlRXMe7PnW4GqXcMMP/4wP/56Zc+Xg30ekAemSRenWF9UeVo3uMBWv8tsCWg/knftV2MPfda0izT3cdhsjYpfNsB0LrUz+9trkdDKbf4GCFBmpNo9YH8BwgqGUsDQBxbFlr2kAU3u+68cB6+6EWsxue2ZjciZ4kIqnyLqIhDmia9PV6HBWwG0r+rdSKwzmrmH5yBKcwFaM/7TPxagKdQw+HIymzCOISiRJOiirS8neXWWCwZbnAEliGznVd394wYWvU/zHQlKohhHb+XVqlF6dEaC3HfbcXucKO1AhVhIWBwsMgBFvIQmuQnotMEzDGrFHsQQTxihBpIkogG+NAghm4jScHwTR3P4SoiHUKclUuVBlTlZ+3gDTL9Wz3G7Dgw6P7G6dk9ywv7vHGfvPpzdP/GU9AWLJHYGSFDVCRAiKAPq5Hf8EzIEqy3Rj152XyIAfnJW3wPW1OG3V+HpYQXTugZi0sSmBljAq2D51DX9gSzcQlK3AMRczSZb/0MKAAEnw4AafgKzACGAxX3e6LbFkN3e/qQ5N54brbt9pvMKpjUWAtZLFECgZHXcuKvt1Cs5hQl5tyvIbxkixamrmyQan8FaENfvrAxDnddVzG0DozY13fnekOKoiUtq6zb2CE+7xGhHkqo5KTdnFGuqfMvuCviPhosg3+Vfox7CyST3Z9l7xPzqY1sD5rMus3Q/o4kcpQ0KdrDgwqmg+vExBVgfNyq1d6eaAA6Q49Gj8f+rDM/PfeByx1CJhkdsktjRfAjGKLghW20H3QdpgLueMK3Rd2lyG5WQ3cjW7wT2h3oUNoQ305y29BKW7+OzdSBgFWTCzIYs9ooLtlZNFpF1MptLVH5UqY+KbIlwKGst+1GWiCy9NpEHIjt80ZXd66hmRNSuTFl+HVGrSRwARV7ojLQ1gO4uVdkowXQKTZVn6fPwIhdJGhyF4ElV1bb6re2KPcRiOQXg9UQkA292NZqTB/8wRlkbEB6M3zStyfc+HXSguAcqg2/CjSMCcyMYpbm1at4N51eABLk1z5/TpTVfCQJVVCDu1Voc2IC5x8LerYSEg+IoPqlJgF8taejVmpi/WqiiloLb/vXQECi2lA+gICTbyyiL85q88L9GW6wYKLVQdLm9tB11Q0cdqk7ykKqYvfxTLfOT8pYFrR3a1OMJjrlPo0ecZHgwSEF7LUIFmTyurnswixogIu/OxE71563kBLvlAWHwhlI+i70wi/sP5eZnicnNV/pF5D5QGGljOQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c49f7457-1cef-4508-0281-08daa0e2ba2f X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2022 23:48:07.4761 (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: 163ghyLkmY4pxUfrMbIQEKS9x2LxzmeH5jwvOLRDaSICdPcQWB+htJUPcon73ntXk2myc3W01fWLDUw9mnS3oA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9444 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The &priv->si->hw construct dereferences 2 pointers and makes lines longer than they need to be, in turn making the code harder to read. Replace &priv->si->hw accesses with a "hw" variable when there are 2 or more accesses within a function that dereference this. This includes loops, since &priv->si->hw is a loop invariant. Signed-off-by: Vladimir Oltean --- v1->v3: none drivers/net/ethernet/freescale/enetc/enetc.c | 28 +++++---- drivers/net/ethernet/freescale/enetc/enetc.h | 9 +-- .../net/ethernet/freescale/enetc/enetc_qos.c | 60 +++++++++---------- 3 files changed, 49 insertions(+), 48 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index 9f5b921039bd..151fb3fa4806 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -2116,13 +2116,14 @@ static void enetc_setup_rxbdr(struct enetc_hw *hw, struct enetc_bdr *rx_ring) static void enetc_setup_bdrs(struct enetc_ndev_priv *priv) { + struct enetc_hw *hw = &priv->si->hw; int i; for (i = 0; i < priv->num_tx_rings; i++) - enetc_setup_txbdr(&priv->si->hw, priv->tx_ring[i]); + enetc_setup_txbdr(hw, priv->tx_ring[i]); for (i = 0; i < priv->num_rx_rings; i++) - enetc_setup_rxbdr(&priv->si->hw, priv->rx_ring[i]); + enetc_setup_rxbdr(hw, priv->rx_ring[i]); } static void enetc_clear_rxbdr(struct enetc_hw *hw, struct enetc_bdr *rx_ring) @@ -2155,13 +2156,14 @@ static void enetc_clear_txbdr(struct enetc_hw *hw, struct enetc_bdr *tx_ring) static void enetc_clear_bdrs(struct enetc_ndev_priv *priv) { + struct enetc_hw *hw = &priv->si->hw; int i; for (i = 0; i < priv->num_tx_rings; i++) - enetc_clear_txbdr(&priv->si->hw, priv->tx_ring[i]); + enetc_clear_txbdr(hw, priv->tx_ring[i]); for (i = 0; i < priv->num_rx_rings; i++) - enetc_clear_rxbdr(&priv->si->hw, priv->rx_ring[i]); + enetc_clear_rxbdr(hw, priv->rx_ring[i]); udelay(1); } @@ -2169,13 +2171,13 @@ static void enetc_clear_bdrs(struct enetc_ndev_priv *priv) static int enetc_setup_irqs(struct enetc_ndev_priv *priv) { struct pci_dev *pdev = priv->si->pdev; + struct enetc_hw *hw = &priv->si->hw; int i, j, err; for (i = 0; i < priv->bdr_int_num; i++) { int irq = pci_irq_vector(pdev, ENETC_BDR_INT_BASE_IDX + i); struct enetc_int_vector *v = priv->int_vector[i]; int entry = ENETC_BDR_INT_BASE_IDX + i; - struct enetc_hw *hw = &priv->si->hw; snprintf(v->name, sizeof(v->name), "%s-rxtx%d", priv->ndev->name, i); @@ -2263,13 +2265,14 @@ static void enetc_setup_interrupts(struct enetc_ndev_priv *priv) static void enetc_clear_interrupts(struct enetc_ndev_priv *priv) { + struct enetc_hw *hw = &priv->si->hw; int i; for (i = 0; i < priv->num_tx_rings; i++) - enetc_txbdr_wr(&priv->si->hw, i, ENETC_TBIER, 0); + enetc_txbdr_wr(hw, i, ENETC_TBIER, 0); for (i = 0; i < priv->num_rx_rings; i++) - enetc_rxbdr_wr(&priv->si->hw, i, ENETC_RBIER, 0); + enetc_rxbdr_wr(hw, i, ENETC_RBIER, 0); } static int enetc_phylink_connect(struct net_device *ndev) @@ -2436,6 +2439,7 @@ int enetc_setup_tc_mqprio(struct net_device *ndev, void *type_data) { struct enetc_ndev_priv *priv = netdev_priv(ndev); struct tc_mqprio_qopt *mqprio = type_data; + struct enetc_hw *hw = &priv->si->hw; struct enetc_bdr *tx_ring; int num_stack_tx_queues; u8 num_tc; @@ -2452,7 +2456,7 @@ int enetc_setup_tc_mqprio(struct net_device *ndev, void *type_data) /* Reset all ring priorities to 0 */ for (i = 0; i < priv->num_tx_rings; i++) { tx_ring = priv->tx_ring[i]; - enetc_set_bdr_prio(&priv->si->hw, tx_ring->index, 0); + enetc_set_bdr_prio(hw, tx_ring->index, 0); } return 0; @@ -2471,7 +2475,7 @@ int enetc_setup_tc_mqprio(struct net_device *ndev, void *type_data) */ for (i = 0; i < num_tc; i++) { tx_ring = priv->tx_ring[i]; - enetc_set_bdr_prio(&priv->si->hw, tx_ring->index, i); + enetc_set_bdr_prio(hw, tx_ring->index, i); } /* Reset the number of netdev queues based on the TC count */ @@ -2584,19 +2588,21 @@ static int enetc_set_rss(struct net_device *ndev, int en) static void enetc_enable_rxvlan(struct net_device *ndev, bool en) { struct enetc_ndev_priv *priv = netdev_priv(ndev); + struct enetc_hw *hw = &priv->si->hw; int i; for (i = 0; i < priv->num_rx_rings; i++) - enetc_bdr_enable_rxvlan(&priv->si->hw, i, en); + enetc_bdr_enable_rxvlan(hw, i, en); } static void enetc_enable_txvlan(struct net_device *ndev, bool en) { struct enetc_ndev_priv *priv = netdev_priv(ndev); + struct enetc_hw *hw = &priv->si->hw; int i; for (i = 0; i < priv->num_tx_rings; i++) - enetc_bdr_enable_txvlan(&priv->si->hw, i, en); + enetc_bdr_enable_txvlan(hw, i, en); } void enetc_set_features(struct net_device *ndev, netdev_features_t features) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h index 2cfe6944ebd3..748677b2ce1f 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h @@ -467,19 +467,20 @@ int enetc_set_psfp(struct net_device *ndev, bool en); static inline void enetc_get_max_cap(struct enetc_ndev_priv *priv) { + struct enetc_hw *hw = &priv->si->hw; u32 reg; - reg = enetc_port_rd(&priv->si->hw, ENETC_PSIDCAPR); + reg = enetc_port_rd(hw, ENETC_PSIDCAPR); priv->psfp_cap.max_streamid = reg & ENETC_PSIDCAPR_MSK; /* Port stream filter capability */ - reg = enetc_port_rd(&priv->si->hw, ENETC_PSFCAPR); + reg = enetc_port_rd(hw, ENETC_PSFCAPR); priv->psfp_cap.max_psfp_filter = reg & ENETC_PSFCAPR_MSK; /* Port stream gate capability */ - reg = enetc_port_rd(&priv->si->hw, ENETC_PSGCAPR); + reg = enetc_port_rd(hw, ENETC_PSGCAPR); priv->psfp_cap.max_psfp_gate = (reg & ENETC_PSGCAPR_SGIT_MSK); priv->psfp_cap.max_psfp_gatelist = (reg & ENETC_PSGCAPR_GCL_MSK) >> 16; /* Port flow meter capability */ - reg = enetc_port_rd(&priv->si->hw, ENETC_PFMCAPR); + reg = enetc_port_rd(hw, ENETC_PFMCAPR); priv->psfp_cap.max_psfp_meter = reg & ENETC_PFMCAPR_MSK; } diff --git a/drivers/net/ethernet/freescale/enetc/enetc_qos.c b/drivers/net/ethernet/freescale/enetc/enetc_qos.c index f8a2f02ce22d..2e783ef73690 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_qos.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_qos.c @@ -17,8 +17,9 @@ static u16 enetc_get_max_gcl_len(struct enetc_hw *hw) void enetc_sched_speed_set(struct enetc_ndev_priv *priv, int speed) { + struct enetc_hw *hw = &priv->si->hw; u32 old_speed = priv->speed; - u32 pspeed; + u32 pspeed, tmp; if (speed == old_speed) return; @@ -39,16 +40,15 @@ void enetc_sched_speed_set(struct enetc_ndev_priv *priv, int speed) } priv->speed = speed; - enetc_port_wr(&priv->si->hw, ENETC_PMR, - (enetc_port_rd(&priv->si->hw, ENETC_PMR) - & (~ENETC_PMR_PSPEED_MASK)) - | pspeed); + tmp = enetc_port_rd(hw, ENETC_PMR); + enetc_port_wr(hw, ENETC_PMR, (tmp & ~ENETC_PMR_PSPEED_MASK) | pspeed); } static int enetc_setup_taprio(struct net_device *ndev, struct tc_taprio_qopt_offload *admin_conf) { struct enetc_ndev_priv *priv = netdev_priv(ndev); + struct enetc_hw *hw = &priv->si->hw; struct enetc_cbd cbd = {.cmd = 0}; struct tgs_gcl_conf *gcl_config; struct tgs_gcl_data *gcl_data; @@ -61,15 +61,13 @@ static int enetc_setup_taprio(struct net_device *ndev, int err; int i; - if (admin_conf->num_entries > enetc_get_max_gcl_len(&priv->si->hw)) + if (admin_conf->num_entries > enetc_get_max_gcl_len(hw)) return -EINVAL; gcl_len = admin_conf->num_entries; - tge = enetc_rd(&priv->si->hw, ENETC_QBV_PTGCR_OFFSET); + tge = enetc_rd(hw, ENETC_QBV_PTGCR_OFFSET); if (!admin_conf->enable) { - enetc_wr(&priv->si->hw, - ENETC_QBV_PTGCR_OFFSET, - tge & (~ENETC_QBV_TGE)); + enetc_wr(hw, ENETC_QBV_PTGCR_OFFSET, tge & ~ENETC_QBV_TGE); priv->active_offloads &= ~ENETC_F_QBV; @@ -117,14 +115,11 @@ static int enetc_setup_taprio(struct net_device *ndev, cbd.cls = BDCR_CMD_PORT_GCL; cbd.status_flags = 0; - enetc_wr(&priv->si->hw, ENETC_QBV_PTGCR_OFFSET, - tge | ENETC_QBV_TGE); + enetc_wr(hw, ENETC_QBV_PTGCR_OFFSET, tge | ENETC_QBV_TGE); err = enetc_send_cmd(priv->si, &cbd); if (err) - enetc_wr(&priv->si->hw, - ENETC_QBV_PTGCR_OFFSET, - tge & (~ENETC_QBV_TGE)); + enetc_wr(hw, ENETC_QBV_PTGCR_OFFSET, tge & ~ENETC_QBV_TGE); enetc_cbd_free_data_mem(priv->si, data_size, tmp, &dma); @@ -138,6 +133,7 @@ int enetc_setup_tc_taprio(struct net_device *ndev, void *type_data) { struct tc_taprio_qopt_offload *taprio = type_data; struct enetc_ndev_priv *priv = netdev_priv(ndev); + struct enetc_hw *hw = &priv->si->hw; int err; int i; @@ -147,16 +143,14 @@ int enetc_setup_tc_taprio(struct net_device *ndev, void *type_data) return -EBUSY; for (i = 0; i < priv->num_tx_rings; i++) - enetc_set_bdr_prio(&priv->si->hw, - priv->tx_ring[i]->index, + enetc_set_bdr_prio(hw, priv->tx_ring[i]->index, taprio->enable ? i : 0); err = enetc_setup_taprio(ndev, taprio); if (err) for (i = 0; i < priv->num_tx_rings; i++) - enetc_set_bdr_prio(&priv->si->hw, - priv->tx_ring[i]->index, + enetc_set_bdr_prio(hw, priv->tx_ring[i]->index, taprio->enable ? 0 : i); return err; @@ -178,7 +172,7 @@ int enetc_setup_tc_cbs(struct net_device *ndev, void *type_data) struct tc_cbs_qopt_offload *cbs = type_data; u32 port_transmit_rate = priv->speed; u8 tc_nums = netdev_get_num_tc(ndev); - struct enetc_si *si = priv->si; + struct enetc_hw *hw = &priv->si->hw; u32 hi_credit_bit, hi_credit_reg; u32 max_interference_size; u32 port_frame_max_size; @@ -199,15 +193,15 @@ int enetc_setup_tc_cbs(struct net_device *ndev, void *type_data) * lower than this TC have been disabled. */ if (tc == prio_top && - enetc_get_cbs_enable(&si->hw, prio_next)) { + enetc_get_cbs_enable(hw, prio_next)) { dev_err(&ndev->dev, "Disable TC%d before disable TC%d\n", prio_next, tc); return -EINVAL; } - enetc_port_wr(&si->hw, ENETC_PTCCBSR1(tc), 0); - enetc_port_wr(&si->hw, ENETC_PTCCBSR0(tc), 0); + enetc_port_wr(hw, ENETC_PTCCBSR1(tc), 0); + enetc_port_wr(hw, ENETC_PTCCBSR0(tc), 0); return 0; } @@ -224,13 +218,13 @@ int enetc_setup_tc_cbs(struct net_device *ndev, void *type_data) * higher than this TC have been enabled. */ if (tc == prio_next) { - if (!enetc_get_cbs_enable(&si->hw, prio_top)) { + if (!enetc_get_cbs_enable(hw, prio_top)) { dev_err(&ndev->dev, "Enable TC%d first before enable TC%d\n", prio_top, prio_next); return -EINVAL; } - bw_sum += enetc_get_cbs_bw(&si->hw, prio_top); + bw_sum += enetc_get_cbs_bw(hw, prio_top); } if (bw_sum + bw >= 100) { @@ -239,7 +233,7 @@ int enetc_setup_tc_cbs(struct net_device *ndev, void *type_data) return -EINVAL; } - enetc_port_rd(&si->hw, ENETC_PTCMSDUR(tc)); + enetc_port_rd(hw, ENETC_PTCMSDUR(tc)); /* For top prio TC, the max_interfrence_size is maxSizedFrame. * @@ -259,8 +253,8 @@ int enetc_setup_tc_cbs(struct net_device *ndev, void *type_data) u32 m0, ma, r0, ra; m0 = port_frame_max_size * 8; - ma = enetc_port_rd(&si->hw, ENETC_PTCMSDUR(prio_top)) * 8; - ra = enetc_get_cbs_bw(&si->hw, prio_top) * + ma = enetc_port_rd(hw, ENETC_PTCMSDUR(prio_top)) * 8; + ra = enetc_get_cbs_bw(hw, prio_top) * port_transmit_rate * 10000ULL; r0 = port_transmit_rate * 1000000ULL; max_interference_size = m0 + ma + @@ -280,10 +274,10 @@ int enetc_setup_tc_cbs(struct net_device *ndev, void *type_data) hi_credit_reg = (u32)div_u64((ENETC_CLK * 100ULL) * hi_credit_bit, port_transmit_rate * 1000000ULL); - enetc_port_wr(&si->hw, ENETC_PTCCBSR1(tc), hi_credit_reg); + enetc_port_wr(hw, ENETC_PTCCBSR1(tc), hi_credit_reg); /* Set bw register and enable this traffic class */ - enetc_port_wr(&si->hw, ENETC_PTCCBSR0(tc), bw | ENETC_CBSE); + enetc_port_wr(hw, ENETC_PTCCBSR0(tc), bw | ENETC_CBSE); return 0; } @@ -293,6 +287,7 @@ int enetc_setup_tc_txtime(struct net_device *ndev, void *type_data) struct enetc_ndev_priv *priv = netdev_priv(ndev); struct tc_etf_qopt_offload *qopt = type_data; u8 tc_nums = netdev_get_num_tc(ndev); + struct enetc_hw *hw = &priv->si->hw; int tc; if (!tc_nums) @@ -304,12 +299,11 @@ int enetc_setup_tc_txtime(struct net_device *ndev, void *type_data) return -EINVAL; /* TSD and Qbv are mutually exclusive in hardware */ - if (enetc_rd(&priv->si->hw, ENETC_QBV_PTGCR_OFFSET) & ENETC_QBV_TGE) + if (enetc_rd(hw, ENETC_QBV_PTGCR_OFFSET) & ENETC_QBV_TGE) return -EBUSY; priv->tx_ring[tc]->tsd_enable = qopt->enable; - enetc_port_wr(&priv->si->hw, ENETC_PTCTSDR(tc), - qopt->enable ? ENETC_TSDE : 0); + enetc_port_wr(hw, ENETC_PTCTSDR(tc), qopt->enable ? ENETC_TSDE : 0); return 0; } From patchwork Tue Sep 27 23:47:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12991496 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 6602BC54EE9 for ; Tue, 27 Sep 2022 23:50:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232618AbiI0XuM (ORCPT ); Tue, 27 Sep 2022 19:50:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232620AbiI0Xta (ORCPT ); Tue, 27 Sep 2022 19:49:30 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70084.outbound.protection.outlook.com [40.107.7.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD04D1D983D; Tue, 27 Sep 2022 16:48:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MyElL/FF/jhyYo9RT1WG6v+gRk/hBnySyMlK6XSrlOKXFUToLoKhUR4aGw0xsMLimUrP24uVTm/V+rF0HLj2kvbGkcd9OvkQ0P1u63IvTMJ7i1IaOm/70PXdgXzLk3ALuJemzc9l9npoyLUYhvtuk/EKkh6ZPq+penWmZsSsuORl0dsbYRXk7Qp7SHzPmmYd8dwxNbcDjGXbhLH3EZPA7Mxe2iyEUHgASrxKIM8vMr9IrSQmhCSnkDdumUb7FOfkbt0DzcmmzK1WWvVPQdLZc8ZQcH75Qai+/m6TUHz6ezBo8J7fzljetf/iMGPmrZcLmNMU2KKIxzA4vBrhAKWkKA== 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=hhjdW8+kQiEUx8E/PIKOnug/ItS5WoqfM30DiT7cNTY=; b=NzZopajgWizMhgL4KjthZcn8kPXUfvctUoRPJfJghbs000vKX6q//AtJA0MWb5GWU7OWLeAz150UCcPjR9/q7IJBFbHhobfeXmKfkQb2q5wu3GUCqgmujXTlfFt4tIKZsOrDNsInJNQUuF9IPggh7tirWyhum4W2DHUZP0l1IjgoLt75cXhGMj5ibLIYRX24Ma1a5dBx6mHVLXr6PdKVwIO0bDi2QxlwecfGo1TnWkFAqsJB4IGHU8U7zfhKO4k0x3C+p+OQTLgK6eQl7MlQgIiUQ2NLsMyursws7PHMdRI9gyzq9nxpc/OhYuwA9ZfpozgTIUmXqUmjUVs907/5Xw== 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=hhjdW8+kQiEUx8E/PIKOnug/ItS5WoqfM30DiT7cNTY=; b=Dx1RRyWQAwkYFEZnQIgfwMBm8kiD9UfD1oeRe7xOZcBcOfexFwkAzJ1aRJ8FICJOm3Yz2B1IXd8Ja7L/7dymAj0hiQOIU3e5s8bcMUfcKs1a0rxMpnzd5t6tYhAxxFo6Ce/+926mPEF3Q+fsjS4u8i4IMjAQSEcyGPYjRvWnSoA= 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 DU0PR04MB9444.eurprd04.prod.outlook.com (2603:10a6:10:35c::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.20; Tue, 27 Sep 2022 23:48:08 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::a67a:849c:aeff:cad1]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::a67a:849c:aeff:cad1%7]) with mapi id 15.20.5654.025; Tue, 27 Sep 2022 23:48:08 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Xiaoliang Yang , Rui Sousa , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Horatiu Vultur , Andrew Lunn , Vivien Didelot , Florian Fainelli , Michael Walle , Vinicius Costa Gomes , Maxim Kochetkov , Colin Foster , Richie Pearn , Kurt Kanzenbach , Vladimir Oltean , Jamal Hadi Salim , Cong Wang , Jiri Pirko , linux-kernel@vger.kernel.org Subject: [PATCH v3 net-next 7/8] net: enetc: use common naming scheme for PTGCR and PTGCAPR registers Date: Wed, 28 Sep 2022 02:47:45 +0300 Message-Id: <20220927234746.1823648-8-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927234746.1823648-1-vladimir.oltean@nxp.com> References: <20220927234746.1823648-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR0501CA0025.eurprd05.prod.outlook.com (2603:10a6:800:60::11) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|DU0PR04MB9444:EE_ X-MS-Office365-Filtering-Correlation-Id: 0277a776-efca-49c2-e21d-08daa0e2baf4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Pxu3V4lGZTLCFpJ6jk715voF0pnucqs9b+rnj85MIJJ5PQ0GhPN8jeWBTzcxOpfap5c+PsyMvOI4KSC/xvecdigXJQtkyj6u4ZXnCmQuz+958CqsZfaCGrqo6NI95GCaNch65BM2W7pua8F7RcpHX/kqZ7dX6jO/8kLfP0tcQK/BFypBK5hTTNnRPfGFq3INOdZ3ugkRtm/UmADxs4jwvHGzpVqa+TxlInVHoI3nlCpuB7jx/dfoUU9OHLF48QDzpGYIFBddjxBW5Toz+VsKl8djwlpViWsPE7JAGdt6/iVjl3GqvFd5q0kG9MA6woo6gRaycnIJLoe9eDzGEtxPdhpFOtrsbNAgy89eVdt75NpYSYsPH10EdGM8ZPSsxE/oM6QD+R7pyD77OZS3YRGA7P8otVKtogOub7w2Qk1ouW9GHZAG+1/MfOMvtFns2eDeBGkP/iKwtugGj73ou3sMj8AUYrknZiN4HPSclL9M73uzvoHl79SfW1F7rIA2s84O8uNf8D4GryMx2L4s1szOREkN0M2OzEOTB/I3AryFkDp9okMGjFnd0hHMSdLtU5GPvXIwfRBJaURgdq1B6c/GRiC+7N/uC57jSI5LV0WKlN2zvzqrlJEjb39wN4MyW/vwGh6onlEZp3eybjjst19xarned9Ix+gXi6cpuacfQdXbOBA62rJl0dESI1lfrztH2NTKWxMfJFH0zDjQ0FY5PsEVJDaHOC3UfW1qxc1vBM0xhiM35ojTaq3IdDiR808iPCYvbkIAj/Sl8kIkHii4XaPFl3aNnBnruIo1IE0o24u0= 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:(13230022)(4636009)(136003)(366004)(376002)(39860400002)(396003)(346002)(451199015)(7416002)(6512007)(966005)(41300700001)(6666004)(36756003)(6486002)(38350700002)(6506007)(6916009)(8676002)(86362001)(66476007)(4326008)(26005)(52116002)(8936002)(66946007)(83380400001)(38100700002)(316002)(54906003)(186003)(1076003)(2906002)(5660300002)(66556008)(478600001)(44832011)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: E+KlFIdwRx+uP7z2WYzUzP6YCYqDLU6bdFQwxdF5KENOGYFEdtXn6yuAnnuCCiL0kU44bm/En9H6akWDtdR+H5lSoznwdkWRDOXEy4jUIweOEnwAj2mcmZQlgJgvqeFtXka+D9SQn5wxFTArDUvIp+uPcJ9wTzP9/UBCObNqyvhT3BVahxRN9Y4Sv0O5CkVJLFVLgiZP330mliR3zatc6uKmyxWkStZFZAkWfka2Y+heNQD+HNK/DbCthkpK8AbgaUgsvWkD80JoFn8xojWfyYlfiRmBUOpdZCXwPVMAkohWff3oElFgamlUzMbpDtnqiFK90bhuPJTAEM/MS8k4MHRjbBpCFbUrbQl8vOkcHj5H9vinHaVsYdjrxSuM1aD6P/jQ9PHdb9hOvKWlIrD80lF7zXRZjk1DkvhYBTCs+g56htMue1ajT6nIk9Bnkv9PO54+otmqtX6hORc2k7kPqgyL4u+F6jVDYu9ppMW8pxd6lzQbfvcOtic4D9cY1tWHtkuO2QCsMQ/kQgk7gsowx9BTNLZy/JwtQIvqRMJuEn2FjfHV3MHfX8D9/3yWS0F82MN16W8bcGpjQyWPBoyh1IdmtO7kAVXKbgI/Vp8TViUShEdTNv9aMGeybJ66SPrhTTZmE8yTq/6WAqxBQMohCJXjmnbMEhdDEr9OOTk6DUMyuYaseq/hYzhk6YLDlxD58SCYOuaLJO400DLZUzE63ISNhjmjfoyJTSDgd4lnqHHRrIrUk3OnDOuNP5B+Ss29mvzn1c6W221fne6R4I//504H6TitYHuAgz0eVBCFmBrJQBxXIwQojN2gR/cqHo/BXA+Z7DCg/65Bl8FwwKB2uu1L5/4fTDr9gya86lnY/EY1G9a0d8x4DTcvpEeNwzD4HU7QREp7WxK+1Zw3wtjY3agqUmpe1/y4nKlEppItw3qtC9zqLaj3qcm6TLj8NVsMFnBpgyfKdorQKdUfqtr9Gkd2+Qa7p9MyCIxKzs27gH6PtXVbWkTK+qdsRXiG++LxQPEfdaaDQpOdtvI3oWE4Nqn2Z5CDfai1nGpNmOAJYnrK0uMt8jiCqsOEuLT0P9SQXSQaT2DbvMhU5SiybvdJpce+BNaEDpoWsYzv/Qx4eXynfe1cpAMOwvIHNLJUxabdPrHybZ65nNfU53n+CMWanE16cNniBTpN34qFPJXJw/QO3g8aSHpMSeUj9Gl8YR/OysQeT+TBGScJnA3/p0e6rKT+tqovf4+OjQb+wbc65suYL9nFMViA4MKGuzldm+4g9WaW6BG2rmDYsjXAH7DdXnJ9Yd19k41cZy3K7XgGoaS4GF63GRY4OkypOBCrMYZbN0dRbHZWWIxWIpAw0u/IGrWs+Xl0LjknPzr19gT+SyRFo0EvHEty713J3+aBOTs+inWRT2P7SM7+kXMS7YlExRWZdCWetC4GSArMKslFWvwrRcHxqUKT326pocfyyOVI/LStmFfzK3vOuVhZSe0xvNtT/F69lheoz2X2o7UtWnHfTYAd0FaE6nB4eUCYFOuEvrp/Pud8mFKULVjVvEBJzZhLJJhHn8VkkQO1QwFyoNAe6GE14H4zIqLkadQxmjxJK6NYpvaxv1OLT4r8NHs4dQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0277a776-efca-49c2-e21d-08daa0e2baf4 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2022 23:48:08.7572 (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: UY8LsPvSYY1/qhuH6XIR/kA3JzVAOEIxjxteB2uBofysK+KESwx96i9shlxyR5N0H4cU8rU4jEyEO79IJFnSVw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9444 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The Port Time Gating Control Register (PTGCR) and Port Time Gating Capability Register (PTGCAPR) have definitions in the driver which aren't in line with the other registers. Rename these. Signed-off-by: Vladimir Oltean --- v1->v2: patch is new (actually taken from the separate preliminary series at https://patchwork.kernel.org/project/netdevbpf/patch/20220921144349.1529150-2-vladimir.oltean@nxp.com/) v2->v3: none drivers/net/ethernet/freescale/enetc/enetc_hw.h | 10 +++++----- drivers/net/ethernet/freescale/enetc/enetc_qos.c | 13 ++++++------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc_hw.h b/drivers/net/ethernet/freescale/enetc/enetc_hw.h index 0b85e37a00eb..18ca1f42b1f7 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_hw.h +++ b/drivers/net/ethernet/freescale/enetc/enetc_hw.h @@ -945,13 +945,13 @@ static inline u32 enetc_usecs_to_cycles(u32 usecs) } /* port time gating control register */ -#define ENETC_QBV_PTGCR_OFFSET 0x11a00 -#define ENETC_QBV_TGE BIT(31) -#define ENETC_QBV_TGPE BIT(30) +#define ENETC_PTGCR 0x11a00 +#define ENETC_PTGCR_TGE BIT(31) +#define ENETC_PTGCR_TGPE BIT(30) /* Port time gating capability register */ -#define ENETC_QBV_PTGCAPR_OFFSET 0x11a08 -#define ENETC_QBV_MAX_GCL_LEN_MASK GENMASK(15, 0) +#define ENETC_PTGCAPR 0x11a08 +#define ENETC_PTGCAPR_MAX_GCL_LEN_MASK GENMASK(15, 0) /* Port time specific departure */ #define ENETC_PTCTSDR(n) (0x1210 + 4 * (n)) diff --git a/drivers/net/ethernet/freescale/enetc/enetc_qos.c b/drivers/net/ethernet/freescale/enetc/enetc_qos.c index 2e783ef73690..ee28cb62afe8 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_qos.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_qos.c @@ -11,8 +11,7 @@ static u16 enetc_get_max_gcl_len(struct enetc_hw *hw) { - return enetc_rd(hw, ENETC_QBV_PTGCAPR_OFFSET) - & ENETC_QBV_MAX_GCL_LEN_MASK; + return enetc_rd(hw, ENETC_PTGCAPR) & ENETC_PTGCAPR_MAX_GCL_LEN_MASK; } void enetc_sched_speed_set(struct enetc_ndev_priv *priv, int speed) @@ -65,9 +64,9 @@ static int enetc_setup_taprio(struct net_device *ndev, return -EINVAL; gcl_len = admin_conf->num_entries; - tge = enetc_rd(hw, ENETC_QBV_PTGCR_OFFSET); + tge = enetc_rd(hw, ENETC_PTGCR); if (!admin_conf->enable) { - enetc_wr(hw, ENETC_QBV_PTGCR_OFFSET, tge & ~ENETC_QBV_TGE); + enetc_wr(hw, ENETC_PTGCR, tge & ~ENETC_PTGCR_TGE); priv->active_offloads &= ~ENETC_F_QBV; @@ -115,11 +114,11 @@ static int enetc_setup_taprio(struct net_device *ndev, cbd.cls = BDCR_CMD_PORT_GCL; cbd.status_flags = 0; - enetc_wr(hw, ENETC_QBV_PTGCR_OFFSET, tge | ENETC_QBV_TGE); + enetc_wr(hw, ENETC_PTGCR, tge | ENETC_PTGCR_TGE); err = enetc_send_cmd(priv->si, &cbd); if (err) - enetc_wr(hw, ENETC_QBV_PTGCR_OFFSET, tge & ~ENETC_QBV_TGE); + enetc_wr(hw, ENETC_PTGCR, tge & ~ENETC_PTGCR_TGE); enetc_cbd_free_data_mem(priv->si, data_size, tmp, &dma); @@ -299,7 +298,7 @@ int enetc_setup_tc_txtime(struct net_device *ndev, void *type_data) return -EINVAL; /* TSD and Qbv are mutually exclusive in hardware */ - if (enetc_rd(hw, ENETC_QBV_PTGCR_OFFSET) & ENETC_QBV_TGE) + if (enetc_rd(hw, ENETC_PTGCR) & ENETC_PTGCR_TGE) return -EBUSY; priv->tx_ring[tc]->tsd_enable = qopt->enable; From patchwork Tue Sep 27 23:47:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12991497 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 2DC5AC6FA83 for ; Tue, 27 Sep 2022 23:50:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232557AbiI0Xuj (ORCPT ); Tue, 27 Sep 2022 19:50:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232541AbiI0XuD (ORCPT ); Tue, 27 Sep 2022 19:50:03 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70084.outbound.protection.outlook.com [40.107.7.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5E771DCC64; Tue, 27 Sep 2022 16:48:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Df3nawH1pmTO/RWpmXmt1REnf0GRbC1Zp9l14CTYkjV0eJpodQos9Kgn110ticNymYgk8tBFBWULwAuTo2c8alIK4IGlfXYLP5ocILwG5mii9MWYx73ElIbZhMCU5qNUcD/MYo4yD9mghavfhrWxouGMjh5zZQRjY6z6bVqcNOuYUXSLUe79brKtpO9iEcP0/onkHMqXv8GYSzWSN5RzhRshGrPot/v0s5QJ1sjnmSmbujVNjbr23olwiuPpBCsMcGOmGk/q37Eeh3r3TotzlC3/DvIeP7ruqlHgQTJLJ/9m1pv8mtIHYJIHaJnS6wF+pFkisaaB6TQ1mhhyP4hRqw== 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=aqcjgH6LKi3PibKIAig3lHNnby+SLPB7547ljDCPQKo=; b=BsJXeRNOjpVkRCRDlXn0MYr92xJ0fmX9KTNhee6U7A1NlZDqWrahVXUhRZdmD5BAdcc4iXXQq85lazuFbf6Cp3YItVcYkX9BtkBtjoa2aNejWhMJ8TmzErlJtKlGnPQjl9MDTsaXew9ITPjMgdt7fanGLfEbJWNg8AzyR/PXkpT2HyfEJNjQ1z+SaZWBpFZ+gBLVof2K8nWZdQTpljrp5b/JLTK/tZAzJc99JRTv2K9Bqgd+CgVxZTulro5Ea5g+NTMDy1JLN9QGQhkVYngeF38+Hwmv/MagKMNx+C/S9cj/G4W3S8B0K8OUB5q3yS5EwSEGVSl+DYmKCUxjcUnVZg== 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=aqcjgH6LKi3PibKIAig3lHNnby+SLPB7547ljDCPQKo=; b=STXfqC4MiJUUrGJl7tGgfACPxfEq+J0Vg7MANDXRwFFDvjxrERH10lLQWHZpFGVauUpaXAI53SIrlR3Xq25QV6jzXb3zLEvqFc2uprxmA3PwNNLNrugGh4fIXIA4xZwx3REBs5qNx58tkVNIeJCyMRyykHtuUhPvVDS2RC2ysIM= 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 DU0PR04MB9444.eurprd04.prod.outlook.com (2603:10a6:10:35c::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.20; Tue, 27 Sep 2022 23:48:10 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::a67a:849c:aeff:cad1]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::a67a:849c:aeff:cad1%7]) with mapi id 15.20.5654.025; Tue, 27 Sep 2022 23:48:10 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Xiaoliang Yang , Rui Sousa , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Horatiu Vultur , Andrew Lunn , Vivien Didelot , Florian Fainelli , Michael Walle , Vinicius Costa Gomes , Maxim Kochetkov , Colin Foster , Richie Pearn , Kurt Kanzenbach , Vladimir Oltean , Jamal Hadi Salim , Cong Wang , Jiri Pirko , linux-kernel@vger.kernel.org Subject: [PATCH v3 net-next 8/8] net: enetc: offload per-tc max SDU from tc-taprio Date: Wed, 28 Sep 2022 02:47:46 +0300 Message-Id: <20220927234746.1823648-9-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927234746.1823648-1-vladimir.oltean@nxp.com> References: <20220927234746.1823648-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: VI1PR0501CA0025.eurprd05.prod.outlook.com (2603:10a6:800:60::11) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|DU0PR04MB9444:EE_ X-MS-Office365-Filtering-Correlation-Id: 14c77b51-1823-482e-5f64-08daa0e2bbb8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: L9iQYplfH2pgDmZ1Au9/tzQydGwwULzkahrH52UxiIf8vnlYVfaNErLDXkvkM283IS0qqHaA8cqBEecmaUdA0/plg4WdjFVHtS0wm0fvgMdGpk15tIBMagNB9dfvGeJPmGnz23WQlHka1YDyLykp49jMhAIphlRIRMMawmM26rvcron57OV5fOVqobOgQCkusHlg54GuFvBWjs1fP8t5Nimt1pGD1+9apo3X228xitF7oQRTXquLKi2tJMri2m0I/QklhoVUL/eMq7YNTz3u1Zktv0gNRdd41trMqE/wMPpgSMiNOBDN9nLB9G935asvUIT0/ai2bTDZyvTetRAvePLqzyU07UYs7RNCCty9lhf42uLh4+AOjQ8rf2rN5fqbeGX7Ug8cNQAwlHVsbtUm/F+8hD0rykAqLXoCOsQepa6PS5jYbpJA1Qjv9PLHKYY+nmg2GU0y22dCFYXqpA23tvp/vYW5a2Eke1634kDFBisS/7TYtNB0+iPSZFGmIqG3c83f01oen3k4IeyW8sEwpin9xYYQNCsTTjPUJlwehkGGk5OzcVVvxyNF7NXBum92xR5byHwtiG4SbaxCK3UsO8oebWR7+/n4SzcFQrw9SLWMHFSlz5izgIU4ZdT1i79VeT+Ws4DX33SRpf5Hp1qi5w/Zw7nKM+vmSEOnfmk4BSHUJAfM0x5uBvo9n8vdzwaymg44pTscmruyVr2ED9hMUqYpF3kHIBNV3KfYrLSCZuRdgOJo8cpDerJJbh037+DWbBdDhJgopZdshaFvlLu2qg== 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:(13230022)(4636009)(136003)(366004)(376002)(39860400002)(396003)(346002)(451199015)(7416002)(6512007)(41300700001)(6666004)(36756003)(6486002)(38350700002)(6506007)(6916009)(8676002)(86362001)(66476007)(4326008)(26005)(52116002)(8936002)(66946007)(83380400001)(38100700002)(316002)(54906003)(186003)(1076003)(2906002)(5660300002)(66556008)(478600001)(44832011)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BNnv0jzRgAK3OuhP8VbFsFgCnk4mRIUuKj1Z13HfaZ0jEhK3dMRfDaiyH61y5q+HdiiRlIJL3YrKSTZb3tO9PbklueydZiiabXq8ma7Mc0pACMHRoTaw7nP2XZk9taI7Iy6P0M0S12zsnrBv3+W5qibH661wv8P8A7I9ADRKJbG3GHFt4QtXTRxP4N+lKwXk8IALE8LFASLFYzbRd72AT158JnHkVu5c+Ni8d4sB4blnelm6bpgnIuBYVpr8xs9T5VbQ7m9fwrFpgTzdswAXf/5ujgDrPKXzqbCSE3p1nzN4Y5UP9vvOfaiNyglBUFLmrNu8cFTqm5rGPhV0z3uWqruIw1P3c3fVvV92KiGG+mP1QJkF7NlcHhCk3qteEoBsK5/VVoixlm94pS96krlTT2Otl17Xt9FuMpDyRQAaZVlplX9fq4IA7FzEraQyEDi13saIHOxS2ca7dfKcSiYEh2aMqnRwxuYD4+0W6ehXs1iYrys6WVLGCSV0d1aw7jKPPqEC5ifM1WXWIkvVQxcgFXqk1fJWpsLLzx1fpoCUbB3IuL06wM7mp8CdXI5IWlwJECLVjLnFxUyEWjFt+1lBLCzWXRC6kS1NYvyXtpP0D95utK8/KacQWhGCTListIPbWf6xuqk8qOzTwHLprRgCohzxYtJebH/21sKlfe/XPxFzun4cVyilvpnYVybeup0oBL5+YD58J+8Bj0HnrwwqkkgTVHem4rSSzUp2WwUBqkvZHa0kRELaDrYsZYJZr7dpXoZt7W5752B7Opmfbu0KKD7HjuemRm0juNG9qQG7QPB+k07kJuqWl1ydjRwv+hvOLbGI/G0PT//isVH1bSLQp70VWW1Y8Cid975rXYvKqmg1BSIbb/n1Awy45STE1tZWMqq5dmn0CCDdLsMr5Po+UL1/MF4s3AIGZTH05HW2PjldckdjwBU9OVc5zoIa8jnODZiwL+0o3VfOKxtE64Xq9LUnuSxo3y0bAlTC3yXJMfwx5pq52dvFnoMgCGeO/j0B/fM0M7bHBm1l1WE+YT1n08TPypwh/ggdyi69nE+fED8uPQFApPpGD3YyOkUxdTjS5e1IDEygb5YmD28eyy6RaSG56wlhe6xwxWiKE5hQ2oU8VRJjUhWV27xn6inSCd8A5lu7+i27r8YYxmngJfQ+4qd4Dxr4fGNgVUrKa07PpdNcDeogT79//snW0DigcCyw26iD+Rm4NLBC9OuRM9ATE+cham6WPz7AYGRUEF/fyNp77e07K5yLf43ZySnUjbIQ0BVbWdsbRVXBg6plExc53rvMp1Qsuyk0QdeS14B2X1CNW6nuuRr5EtthTPc+f+utZ/+0IaN1OkLd6R5zawrKwNApsm8hiSK/EjNr5rFpmtuuaBch94GTyiEnJJ4eVmzB7/221cH9FEBvZ32a6Z9NowvQ8mF7SEthQ44o3KHf7IXbJdFsl16nchdnCwxj6UAnHnwJE90NYA2+92zFwKFRdyrtmatmNFS4ejoQljk3QZTpYkbgLAXxKGk3z5ZKcplSctPvwo9n39atIG/fM/f0U9MudnO7kiqosYgvwqPqdUpFZ/dCt7CtU6QbujA58IrcqGL+XcfNin8OTzh+NF5HCg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 14c77b51-1823-482e-5f64-08daa0e2bbb8 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2022 23:48:10.0228 (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: vhMgC7g1+cxTODtIQZA8o1qqFzat0mmEi28p7QjVBOjewtgxnsEhdKZuHZv0lAJPLej+P21YGTYRJYhAY2C3IQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9444 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The driver currently sets the PTCMSDUR register statically to the max MTU supported by the interface. Keep this logic if tc-taprio is absent or if the max_sdu for a traffic class is 0, and follow the requested max SDU size otherwise. Signed-off-by: Vladimir Oltean --- v1->v2: none v2->v3: implement TC_QUERY_CAPS with TC_SETUP_QDISC_TAPRIO drivers/net/ethernet/freescale/enetc/enetc.h | 5 +++ .../net/ethernet/freescale/enetc/enetc_pf.c | 27 ++++++++++++++-- .../net/ethernet/freescale/enetc/enetc_qos.c | 31 +++++++++++++++++-- 3 files changed, 57 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h index 748677b2ce1f..161930a65f61 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h @@ -453,7 +453,11 @@ static inline void enetc_cbd_free_data_mem(struct enetc_si *si, int size, data, *dma); } +void enetc_reset_ptcmsdur(struct enetc_hw *hw); +void enetc_set_ptcmsdur(struct enetc_hw *hw, u32 *queue_max_sdu); + #ifdef CONFIG_FSL_ENETC_QOS +int enetc_qos_query_caps(struct net_device *ndev, void *type_data); int enetc_setup_tc_taprio(struct net_device *ndev, void *type_data); void enetc_sched_speed_set(struct enetc_ndev_priv *priv, int speed); int enetc_setup_tc_cbs(struct net_device *ndev, void *type_data); @@ -521,6 +525,7 @@ static inline int enetc_psfp_disable(struct enetc_ndev_priv *priv) } #else +#define enetc_qos_query_caps(ndev, type_data) -EOPNOTSUPP #define enetc_setup_tc_taprio(ndev, type_data) -EOPNOTSUPP #define enetc_sched_speed_set(priv, speed) (void)0 #define enetc_setup_tc_cbs(ndev, type_data) -EOPNOTSUPP diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c index bb7750222691..bdf94335ee99 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c @@ -516,15 +516,34 @@ static void enetc_port_si_configure(struct enetc_si *si) enetc_port_wr(hw, ENETC_PSIVLANFMR, ENETC_PSIVLANFMR_VS); } -static void enetc_configure_port_mac(struct enetc_hw *hw) +void enetc_set_ptcmsdur(struct enetc_hw *hw, u32 *max_sdu) { int tc; - enetc_port_wr(hw, ENETC_PM0_MAXFRM, - ENETC_SET_MAXFRM(ENETC_RX_MAXFRM_SIZE)); + for (tc = 0; tc < 8; tc++) { + u32 val = ENETC_MAC_MAXFRM_SIZE; + + if (max_sdu[tc]) + val = max_sdu[tc] + VLAN_ETH_HLEN; + + enetc_port_wr(hw, ENETC_PTCMSDUR(tc), val); + } +} + +void enetc_reset_ptcmsdur(struct enetc_hw *hw) +{ + int tc; for (tc = 0; tc < 8; tc++) enetc_port_wr(hw, ENETC_PTCMSDUR(tc), ENETC_MAC_MAXFRM_SIZE); +} + +static void enetc_configure_port_mac(struct enetc_hw *hw) +{ + enetc_port_wr(hw, ENETC_PM0_MAXFRM, + ENETC_SET_MAXFRM(ENETC_RX_MAXFRM_SIZE)); + + enetc_reset_ptcmsdur(hw); enetc_port_wr(hw, ENETC_PM0_CMD_CFG, ENETC_PM0_CMD_PHY_TX_EN | ENETC_PM0_CMD_TXP | ENETC_PM0_PROMISC); @@ -738,6 +757,8 @@ static int enetc_pf_setup_tc(struct net_device *ndev, enum tc_setup_type type, void *type_data) { switch (type) { + case TC_QUERY_CAPS: + return enetc_qos_query_caps(ndev, type_data); case TC_SETUP_QDISC_MQPRIO: return enetc_setup_tc_mqprio(ndev, type_data); case TC_SETUP_QDISC_TAPRIO: diff --git a/drivers/net/ethernet/freescale/enetc/enetc_qos.c b/drivers/net/ethernet/freescale/enetc/enetc_qos.c index ee28cb62afe8..e6416332ec79 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_qos.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_qos.c @@ -7,6 +7,7 @@ #include #include #include +#include #include static u16 enetc_get_max_gcl_len(struct enetc_hw *hw) @@ -67,6 +68,7 @@ static int enetc_setup_taprio(struct net_device *ndev, tge = enetc_rd(hw, ENETC_PTGCR); if (!admin_conf->enable) { enetc_wr(hw, ENETC_PTGCR, tge & ~ENETC_PTGCR_TGE); + enetc_reset_ptcmsdur(hw); priv->active_offloads &= ~ENETC_F_QBV; @@ -122,10 +124,13 @@ static int enetc_setup_taprio(struct net_device *ndev, enetc_cbd_free_data_mem(priv->si, data_size, tmp, &dma); - if (!err) - priv->active_offloads |= ENETC_F_QBV; + if (err) + return err; - return err; + enetc_set_ptcmsdur(hw, admin_conf->max_sdu); + priv->active_offloads |= ENETC_F_QBV; + + return 0; } int enetc_setup_tc_taprio(struct net_device *ndev, void *type_data) @@ -1594,3 +1599,23 @@ int enetc_setup_tc_psfp(struct net_device *ndev, void *type_data) return 0; } + +int enetc_qos_query_caps(struct net_device *ndev, void *type_data) +{ + struct enetc_ndev_priv *priv = netdev_priv(ndev); + struct tc_query_caps_base *base = type_data; + struct enetc_si *si = priv->si; + + switch (base->type) { + case TC_SETUP_QDISC_TAPRIO: { + struct tc_taprio_caps *caps = base->caps; + + if (si->hw_features & ENETC_SI_F_QBV) + caps->supports_queue_max_sdu = true; + + return 0; + } + default: + return -EOPNOTSUPP; + } +}