From patchwork Sun Feb 19 13:53:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 59156 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp857138wrn; Sun, 19 Feb 2023 05:57:40 -0800 (PST) X-Google-Smtp-Source: AK7set//drf1Zj+b3C+068GxJZ2iM+XGxvw2QjM4Zgp+vtL2ni51/KwlzzYd2xu669BLYIJz/uxW X-Received: by 2002:aa7:dc0b:0:b0:474:a583:2e1a with SMTP id b11-20020aa7dc0b000000b00474a5832e1amr1585227edu.12.1676815059902; Sun, 19 Feb 2023 05:57:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1676815059; cv=pass; d=google.com; s=arc-20160816; b=tyXQVvXm4fxQlQtqdKF8ZbIRAbiMPrBb2ECZhzNEvWcOKvLSDqIlhpq5mUDkEbbCMS 6GSKrC2i/5i+p2W7zL9gM8YAWMqcNtwVQKRJXpb1u+KuAv2U26GKkr3UoUCJ3n6eLcUU INnWX/3dV54iFBtxM1N0w0LHDlcT4ESS2Cbw+VUxl34iSDj+P9VKnV3BOE1ThTjpsZPc q7yDTRmONeA9v3D5YUgy+RcFCi0b7Lx4wcf51C/ublz/wjdO/tnt5yRN3CnBUPmLPcrb t+n7FIwAFUuA+8MTlfohgTRkhBekinSVPPL64Wzfh0TYCpbf2krg+vEP1aKZBxk9D3aH 7nWA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4ifzCyDc/Iq2TIwUwjzFqoMcukuy6moC10jjJvogVZU=; b=L2RABgBFMikwR7luMRdNoMCHMC6ZyCe/MOsBgCpDqf/5wQGe3sfW9F/+8h79ffINvy Czr6Ru3yyYAKhUvxtQy0rXchAnTPO0gfJ7keuegjWcM5Yg/dXyXBsP+Pj8hZYAv3l5lF 2mpsD7c+J8EMajaulXEOFUttVwS2f7kMV2cQG2xbUe3FHW9IHkjOWt14u4saXBF31NnX 3UzuYl522OUxaY4ndnSE017uTYzZB6/DTlXcCCn/xResLjJM00c/QtKK/EJOPXeH8RsB LiOHENJYegQEanCCLR+DhVtVaggA5xnwRGK+7UT0FmYHWMSkkVaYMCGXoOyK827C6k9/ t4bw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=AY+vtnOK; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m13-20020aa7d34d000000b004accbc82a5fsi11887660edr.422.2023.02.19.05.57.16; Sun, 19 Feb 2023 05:57:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=AY+vtnOK; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229975AbjBSNzd (ORCPT + 99 others); Sun, 19 Feb 2023 08:55:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230166AbjBSNzJ (ORCPT ); Sun, 19 Feb 2023 08:55:09 -0500 Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on2084.outbound.protection.outlook.com [40.107.14.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 383A7125B8; Sun, 19 Feb 2023 05:54:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aBLFXZJ4WGqMVH9/a5GGZezBr8aAh6zhjL+p+MndXQH6PQtalx3+qnGG68uF9xUJhzTbzgwgCGhmOgNQwctfFEpDE0TqzTREmRX5qzGybQKqTa7HtFXtP/yzVPvU+OgjLoZSLgSn0H2xlYOlHE4Md+n4K+8oXwNX2NANk/oT0msrGvuAbrlur1qpRUyiLtGHcVQuJieNsqgo7JG69BvHoUv1ZWJievo27wfoMBpO0b1MPXtPeQm7170bapNpA0kbxXyxD1Zp21tAGMca5S4ikez1TzLLA5P0NVK5z4CK5WLHMiyPTc0xkW5OCeOVpDWl4KR4Fx/oVqQjDtO20ylOzw== 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=4ifzCyDc/Iq2TIwUwjzFqoMcukuy6moC10jjJvogVZU=; b=W8z8E2mHT6v6gxw9PsSBfzBvOgG96LwIvJaXzz+3sbmQirGGiE8O5HzpzzqInsyr5OXy/7zqy4ayK5wLF7Q1jSaI3+lzz7ICJeE4zdn8S2xGRt37O7+QY6H5+Ucq3WRypy0Ei34fSVZAcFG2ZevjyziRDMtyCl+QbTAW90pgouiApx0mr2WrkSU4yqCkARqyxzAl0NnObIgZlQ//JsdhcxFVC8FPVYKd8PQXOfRG+t3RfxTYCZCqNylObelwomj+HqnUW6r6DOVXv1bIHczIknnYJKksi1vqiC2W09jgM6ash+0+iMm9L5ImUUxXJdUhckozsqLSPOO87EBS2TGVCQ== 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=4ifzCyDc/Iq2TIwUwjzFqoMcukuy6moC10jjJvogVZU=; b=AY+vtnOKDBaQ9DbSE+8ZivjuMrMU8d1SKb7x9dtSZRrUp7tBFzEV0EmnOxaTywtRXsWtpChgbikQkGj3qP/lwB+WZXguvJ6ZUsVkUptv2x7qBsaRiVj3g+qDJrmTIW2Lq64yMv3ZXlIpwalAYL0vPwogBOYw9TJC9xiIarQ4kZ4= 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 PAXPR04MB8238.eurprd04.prod.outlook.com (2603:10a6:102:1bc::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.17; Sun, 19 Feb 2023 13:53:57 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6111.018; Sun, 19 Feb 2023 13:53:57 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vinicius Costa Gomes , Kurt Kanzenbach , Gerhard Engleder , Amritha Nambiar , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , Florian Fainelli , Ferenc Fejes , Xiaoliang Yang , Roger Quadros , Pranavi Somisetty , Harini Katakam , linux-kernel@vger.kernel.org, Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Wong Vee Khee , Michael Sit Wei Hong , Jacob Keller Subject: [PATCH v2 net-next 10/12] net/sched: taprio: allow per-TC user input of FP adminStatus Date: Sun, 19 Feb 2023 15:53:06 +0200 Message-Id: <20230219135309.594188-11-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230219135309.594188-1-vladimir.oltean@nxp.com> References: <20230219135309.594188-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0136.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7c::6) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB8238:EE_ X-MS-Office365-Filtering-Correlation-Id: 85f28dd7-f70a-45f8-1d5c-08db1280bec8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zYK9zyswMiHJSSCOyBFxr5tILiEVnHLw7Jtl7IaxoRw+rwOWH/VJ1LCAOp1K7Ic2GKIz1dwg0L1YXRD2BnO6/To8uiqiIEKp6lP34yuRx0bIJhrYca3C65hux/1PnZJExUv5Pj+q1wPSiqlCUEp9F65Hp+5SZtwoIrkVvQBfuX/4zQNpMvqGGkSP4IkUd1VknnoShNvdwpavno7b1OlzBOf00/oTho/AUjAg0mJJlf7TIbDa/9XUETw298CNxix1YFxvHDUg4cOavT9T5NRPWZPJg7jugLF3fhep6NpwigaqR0EX2O6yon2A8p2uzPSA48CPl0L5Cde5jy6ym7e+Vh99Oor5TLcV2iI24VMtSpDDYSa7/sdCNss5TMqnUtjJ8/KFBqzg/DP6Xl23DXUH4/RUtU77A2ndpg4cV+hFXbW1PtLeqU/SapiZ+405X2J+1aaH+2uQoOz/TfzbVA5yg2NwSTXUcco3ewZUFYR5SJbNbt0Rjiz8DtBYNPEG/6Dw7WrYF3aDwqnmVkJxGAhPgGyTJAsgsGI6oAhr8cAToHf5FkM0A+cax5vM+UvTCucTjKOH4cHvPWE4eOMV0Xcu9sbk2TaC8d6MNBUFlEmZxjepG0uTbArLAERqiEHxrIvuOYVUMTWbpNecNijXVmVQtf7GjOAz36/DhvhLLjL1M0KNZmiki2WvsjGsRbHIUMJwQM5pHTPho9OoGxY3yuxisQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(396003)(346002)(136003)(39860400002)(366004)(376002)(451199018)(8676002)(66556008)(66946007)(66476007)(5660300002)(7416002)(4326008)(8936002)(41300700001)(6916009)(44832011)(86362001)(38100700002)(38350700002)(6512007)(6666004)(6506007)(186003)(26005)(2616005)(83380400001)(52116002)(6486002)(478600001)(1076003)(36756003)(316002)(54906003)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: G+Qt9Z2rSOouPVgoINs7pIrPvKMn4Ttcf/48lzKEZOg1UUeP9RYKDNrVJi/KaOaApzaBVKbxkUpGkh8qqMHiokYn/5n++8BuEIqh2w1kOwWAEpsmq+IYtN9Y/dyPDN61guXgqjuDJLlmA3rwlq3OSjUPiTsvbPwsmG5RdobRmgbKxMenm7Xc9dujhnzcLQu4Focf8sbsPTO7SCwsAgsw0KMq6d5oP+yNhwNgdbd3QHxxEHWUZQ5FE9LGqpwKoPeWnnXMwtv/lV9BkzqF4UDBxsg79N3+FDTZ6YT2LoR5T+07CUorjywEnRwnzYg0OKPLh8dfmGegWLuR3fgCJZ/ZDbD5zV+Jcd/tqSKrKFXuemuAtmALaMjKFIpyAFKtBTA1JeXAMfqje6mYk2AkwdqdHtr30S2qoaAXuw0jFZ0qkai4o4l0DuocFKcaeJvM4UPOcuDcHqc7tOTabIXvQ6Sfm9OQjzGJf2Q+oQMXGh9Bt9v+Y0jrfmVkBFV2kHxFHClFnPWrDf6C3XqNcM7w3F7jiZiwXtQ9CPHBQHwkoJcRfIhLcs/KNEDQrCt9u7Fa6qfG/o8oO2AoWtW3fLBzY3ATOEqPCsTQjBThBqhDzZ2PFyE1zkvWbMUl4I8/z2FPSKUsTU8PmpetGFUTyfo45RCwr07veaUdtx75aD+OEcMdWbbSRI0gTInhdkP1R8QOsO+8PGSBHJ0LACOnazQgpaGw6cvVJnsBUSeUjX0+Hhea1kR1B/4LM48zAU2pQ9XO2KbY8/LsYEK9SbL4liy156uBtpkjYODdTfHdbXOk0CTkbelVhy9eBm18F9XLlB30e7eTa+limxtXL+eEaVBXZue55R+vqjfyi5QLEw4ysqQViypt3lMnFq+8hVy6NruEogb7M6MUzOmZc2o3QYHwUFTKmLPur3Lil0XNVrVlzq1OIRyN0A8hkWE9r2DLDe8ibveyobfxYeVYgjkj22kdEfne45By724B5FCPHmE0MRz0V6GRX69iWSfqEVk7QnwgfvQAz3uMPy2Sq0O9Y6vZldsXHF1V2MBJbYzyMWyLEohJnGlZ0TcMFGLJ2yWSmSSd4Ye2cjxlb7P3ZAfti+DSx7gfYprZ0ea+IVbsT8C5gSK/iq+EsuQ3FTdAh+8oONaH7umuh1aeUPk5KkkV+qmPfknNJKZ8DwvIsNazUBAg+HC/uPlNvr0664z66bhxup7mZhRdqtZbCDCUk5UDE1lPqHm3dY9D7ZRjI8tTJlYqlVLiZWqghlB18sRT+9i78wsrJWRSieWCRrr20IE0IC60PbgM7wvyuMfHG+GPKk9+VZ41PABr3gYQtKaz0nYfjD7NUCGNegG5Cy/fS+TNml35/JWatGP7w56fy3mykFJapI/5SKI2Q8vdVQmfqnBTQ6FT+9s7MXHBZdM6bXofmkCiOSiK8BYEmH8ZspAaCQflKRp7KMaHl1SJOuu5rUFhnngNfUofe1LzUgO5xSPoTBmb0Q/G1IqgyiIRqMPwuDnNoAabsw0saSSbe57uHqMtumtLBss/aUhJJTy5cyUXJCQ+U7WZjWuvQV4h8Uk2cJRh5FC08RhByjTiE4pg7v/Iy3APG6Wz2cKDlGnXmFseRjnIsq/Kmg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 85f28dd7-f70a-45f8-1d5c-08db1280bec8 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Feb 2023 13:53:57.1612 (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: 3sjTRgJx8ooHCpwNvhz0UOzyw6KfoyD6HhNnDvAFDYrUGRNfdPFGUQtg5fZwrpezzsytWGAuPWSVfIu3zV2J5w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8238 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758268028133093095?= X-GMAIL-MSGID: =?utf-8?q?1758268028133093095?= This is a duplication of the FP adminStatus logic introduced for tc-mqprio. Offloading is done through the tc_mqprio_qopt_offload structure embedded within tc_taprio_qopt_offload. So practically, if a device driver is written to treat the mqprio portion of taprio just like standalone mqprio, it gets unified handling of frame preemption. I would have reused more code with taprio, but this is mostly netlink attribute parsing, which is hard to transform into generic code without having something that stinks as a result. We have the same variables with the same semantics, just different nlattr type values (TCA_MQPRIO_TC_ENTRY=5 vs TCA_TAPRIO_ATTR_TC_ENTRY=12; TCA_MQPRIO_TC_ENTRY_FP=2 vs TCA_TAPRIO_TC_ENTRY_FP=3, etc) and consequently, different policies for the nest. Every time nla_parse_nested() is called, an on-stack table "tb" of nlattr pointers is allocated statically, up to the maximum understood nlattr type. That array size is hardcoded as a constant, but when transforming this into a common parsing function, it would become either a VLA (which the Linux kernel rightfully doesn't like) or a call to the allocator. Having FP adminStatus in tc-taprio can be seen as addressing the 802.1Q Annex S.3 "Scheduling and preemption used in combination, no HOLD/RELEASE" and S.4 "Scheduling and preemption used in combination with HOLD/RELEASE" use cases. HOLD and RELEASE events are emitted towards the underlying MAC Merge layer when the schedule hits a Set-And-Hold-MAC or a Set-And-Release-MAC gate operation. So within the tc-taprio UAPI space, one can distinguish between the 2 use cases by choosing whether to use the TC_TAPRIO_CMD_SET_AND_HOLD and TC_TAPRIO_CMD_SET_AND_RELEASE gate operations within the schedule, or just TC_TAPRIO_CMD_SET_GATES. A small part of the change is dedicated to refactoring the max_sdu nlattr parsing to put all logic under the "if" that tests for presence of that nlattr. Signed-off-by: Vladimir Oltean --- v1->v2: slightly reword commit message include/uapi/linux/pkt_sched.h | 1 + net/sched/sch_taprio.c | 65 +++++++++++++++++++++++++++------- 2 files changed, 53 insertions(+), 13 deletions(-) diff --git a/include/uapi/linux/pkt_sched.h b/include/uapi/linux/pkt_sched.h index b8d29be91b62..51a7addc56c6 100644 --- a/include/uapi/linux/pkt_sched.h +++ b/include/uapi/linux/pkt_sched.h @@ -1252,6 +1252,7 @@ enum { TCA_TAPRIO_TC_ENTRY_UNSPEC, TCA_TAPRIO_TC_ENTRY_INDEX, /* u32 */ TCA_TAPRIO_TC_ENTRY_MAX_SDU, /* u32 */ + TCA_TAPRIO_TC_ENTRY_FP, /* u32 */ /* add new constants above here */ __TCA_TAPRIO_TC_ENTRY_CNT, diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index 9781b47962bb..c799361adea4 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -96,6 +97,7 @@ struct taprio_sched { struct list_head taprio_list; int cur_txq[TC_MAX_QUEUE]; u32 max_sdu[TC_MAX_QUEUE]; /* save info from the user */ + u32 fp[TC_QOPT_MAX_QUEUE]; /* only for dump and offloading */ u32 txtime_delay; }; @@ -994,6 +996,9 @@ static const struct nla_policy entry_policy[TCA_TAPRIO_SCHED_ENTRY_MAX + 1] = { 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 }, + [TCA_TAPRIO_TC_ENTRY_FP] = NLA_POLICY_RANGE(NLA_U32, + TC_FP_EXPRESS, + TC_FP_PREEMPTIBLE), }; static const struct nla_policy taprio_policy[TCA_TAPRIO_ATTR_MAX + 1] = { @@ -1514,6 +1519,7 @@ static int taprio_enable_offload(struct net_device *dev, offload->enable = 1; mqprio_qopt_reconstruct(dev, &offload->mqprio.qopt); taprio_sched_to_offload(dev, sched, offload, &caps); + mqprio_fp_to_offload(q->fp, &offload->mqprio); for (tc = 0; tc < TC_MAX_QUEUE; tc++) offload->max_sdu[tc] = q->max_sdu[tc]; @@ -1655,13 +1661,14 @@ static int taprio_parse_clockid(struct Qdisc *sch, struct nlattr **tb, static int taprio_parse_tc_entry(struct Qdisc *sch, struct nlattr *opt, u32 max_sdu[TC_QOPT_MAX_QUEUE], + u32 fp[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; + u32 val; err = nla_parse_nested(tb, TCA_TAPRIO_TC_ENTRY_MAX, opt, taprio_tc_policy, extack); @@ -1686,15 +1693,18 @@ static int taprio_parse_tc_entry(struct Qdisc *sch, *seen_tcs |= BIT(tc); - if (tb[TCA_TAPRIO_TC_ENTRY_MAX_SDU]) + 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; + } - if (val > dev->max_mtu) { - NL_SET_ERR_MSG_MOD(extack, "TC max SDU exceeds device max MTU"); - return -ERANGE; + max_sdu[tc] = val; } - max_sdu[tc] = val; + if (tb[TCA_TAPRIO_TC_ENTRY_FP]) + fp[tc] = nla_get_u32(tb[TCA_TAPRIO_TC_ENTRY_FP]); return 0; } @@ -1704,29 +1714,51 @@ static int taprio_parse_tc_entries(struct Qdisc *sch, 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]; + bool have_preemption = false; unsigned long seen_tcs = 0; + u32 fp[TC_QOPT_MAX_QUEUE]; struct nlattr *n; int tc, rem; int err = 0; - for (tc = 0; tc < TC_QOPT_MAX_QUEUE; tc++) + for (tc = 0; tc < TC_QOPT_MAX_QUEUE; tc++) { max_sdu[tc] = q->max_sdu[tc]; + fp[tc] = q->fp[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, + err = taprio_parse_tc_entry(sch, n, max_sdu, fp, &seen_tcs, extack); if (err) - goto out; + return err; } - for (tc = 0; tc < TC_QOPT_MAX_QUEUE; tc++) + for (tc = 0; tc < TC_QOPT_MAX_QUEUE; tc++) { q->max_sdu[tc] = max_sdu[tc]; + q->fp[tc] = fp[tc]; + if (fp[tc] != TC_FP_EXPRESS) + have_preemption = true; + } + + if (have_preemption) { + if (!FULL_OFFLOAD_IS_ENABLED(q->flags)) { + NL_SET_ERR_MSG(extack, + "Preemption only supported with full offload"); + return -EOPNOTSUPP; + } + + if (!ethtool_dev_mm_supported(dev)) { + NL_SET_ERR_MSG(extack, + "Device does not support preemption"); + return -EOPNOTSUPP; + } + } -out: return err; } @@ -2007,7 +2039,7 @@ static int taprio_init(struct Qdisc *sch, struct nlattr *opt, { struct taprio_sched *q = qdisc_priv(sch); struct net_device *dev = qdisc_dev(sch); - int i; + int i, tc; spin_lock_init(&q->current_entry_lock); @@ -2064,6 +2096,9 @@ static int taprio_init(struct Qdisc *sch, struct nlattr *opt, q->qdiscs[i] = qdisc; } + for (tc = 0; tc < TC_QOPT_MAX_QUEUE; tc++) + q->fp[tc] = TC_FP_EXPRESS; + taprio_detect_broken_mqprio(q); return taprio_change(sch, opt, extack); @@ -2207,6 +2242,7 @@ static int dump_schedule(struct sk_buff *msg, } static int taprio_dump_tc_entries(struct sk_buff *skb, + struct taprio_sched *q, struct sched_gate_list *sched) { struct nlattr *n; @@ -2224,6 +2260,9 @@ static int taprio_dump_tc_entries(struct sk_buff *skb, sched->max_sdu[tc])) goto nla_put_failure; + if (nla_put_u32(skb, TCA_TAPRIO_TC_ENTRY_FP, q->fp[tc])) + goto nla_put_failure; + nla_nest_end(skb, n); } @@ -2265,7 +2304,7 @@ 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 (oper && taprio_dump_tc_entries(skb, oper)) + if (oper && taprio_dump_tc_entries(skb, q, oper)) goto options_error; if (oper && dump_schedule(skb, oper))