From patchwork Tue Apr 11 18:01:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13207998 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 58823C76196 for ; Tue, 11 Apr 2023 18:02:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229944AbjDKSC2 (ORCPT ); Tue, 11 Apr 2023 14:02:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229704AbjDKSCZ (ORCPT ); Tue, 11 Apr 2023 14:02:25 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2045.outbound.protection.outlook.com [40.107.8.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C63A526F; Tue, 11 Apr 2023 11:02:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EXmJ5ZJefObgBj1AwQeTnzsyBG8VY8q7ddVFvxZAWecup3jcXqwUFrqLvPXMuJhlyoU6szgBcei+ODx2JMxwmfUFdvD5oF+EMihtyUJOvhk+t7RbzmgOj/9yA4DgCcAXdqRJxXJWE1Pj8kJFO+TKg6gHeq6RtZxPw1vFRDJtPtXZyIIOPnx2gbqCSQP51W14O4AU7kytrF6MGdZS1gVfvGk8/fmJfhekPItd+ZgO5G0C+zioHodLdIuyixCgVa+MgY2QL0gFVMbBZFxsaIZVreFtoFT0QL3LjIfu623SRyq/CUcFtSZKbbSXwBz5tDUyHj8qPfSw37J6c5T7cqD0nw== 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=DRlHOmwW41YQtyFWjVl/V+zXFVnDXS5/0/VJAR9BzIw=; b=jyqyz7Gl+ioPz1ZxuNJccEiXvuY3rlwTxBSY6UDhegOYPaeggxwA5Abi8it020/jXFDoitnoOrfH/5oM+WNd5zdWOBuY+GOpBi6p5p3oukD2Tq7x6KRRZaMBFJsXduNn4LVnTlMPDheJTTTytI5VGHFNfqPAK8NrCz5LXpqwk2OheduNPpJEFH89+J3VWQRpeswiBSeViei0XtD8NzD8z7JECVjumGmYgK7cgDz5QQNqi2QrkfTn+2pSpGa84QBsjguSzzFi6mr4bjQ8PJXsrZuFWJsfLUmxZkRSeFuYZbHi91bNYa9UUZ4tSJokhqM59l7Um+huJzDplgWiTxxafg== 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=DRlHOmwW41YQtyFWjVl/V+zXFVnDXS5/0/VJAR9BzIw=; b=EvMN4h+PWU5brElmIQ9ksemIY94bNvDU6YXAoOVg89M6S3/RQwjdA377ADMwe1apN2vrSBrNUwFB0cKllR6ZbDjNMVHkY6hqy1G7lH6Lzf9gMHxQ1nMzAiB9T9hlySPjb+2snF9Jds6jKGm0BAPgxjJ0II4831QXC6wN9IrevPo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by AS8PR04MB7829.eurprd04.prod.outlook.com (2603:10a6:20b:2a7::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Tue, 11 Apr 2023 18:02:22 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::55b1:d2dd:4327:912b]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::55b1:d2dd:4327:912b%5]) with mapi id 15.20.6298.028; Tue, 11 Apr 2023 18:02:22 +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 , Ferenc Fejes , Xiaoliang Yang , Roger Quadros , Pranavi Somisetty , Harini Katakam , Giuseppe Cavallaro , Alexandre Torgue , Michael Sit Wei Hong , Mohammad Athari Bin Ismail , Oleksij Rempel , Jacob Keller , linux-kernel@vger.kernel.org, Ferenc Fejes , Simon Horman Subject: [PATCH v5 net-next 1/9] net: ethtool: create and export ethtool_dev_mm_supported() Date: Tue, 11 Apr 2023 21:01:49 +0300 Message-Id: <20230411180157.1850527-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230411180157.1850527-1-vladimir.oltean@nxp.com> References: <20230411180157.1850527-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR2P281CA0186.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9f::20) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AS8PR04MB7829:EE_ X-MS-Office365-Filtering-Correlation-Id: 10fa4c78-6e62-4990-3aaa-08db3ab6e5f3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7vnuzg3ydmXXqLu3v4ppNRBCyoewPv+o4v88/FDOuQZi0/Ebf2TeHAVUSeYmsess/klwVjpvNwUEqYmixyAndn5MewneROkvJjl7uRgWb+1teq7/IV/RkKostltYZybKmedEaNbB0U7ICFEuDOZIDPRDaQn+5mFcp5h7F5rN2bPGYVOCbZFJdGNB57SYGadPqoNstlH3KOYL+UsQQIM0MG4c96QktoIb0MVz+I7yCgBOJBSYKsxmxMEzHuG4DDg8/wu4AvyPI0PYhPxqV8UL8ulGm9DZq0zjjgtc7DkKGlir27Tuwiqj3cB+XEkH9zliqFGwpG0a+YO9tiS8OQsNjIoEGntpFHhx3i7hMnI0NWaZtuXG8+CPlaATRPyt1yVbpw4mOCcKz4nIJqudUet4EzuH9dTgs1VxmNirR3I2aSMMsqNB1EHcnsWp9MjqRGsgc7s8EVyBfqcqwMKq2WJ2A2SmX8FOIvasMdKR5fbjDK4fTkrqRySlbszI7QQgj5Ypt2mxaqbOM3ThoHAMv7YbUpxykFVKe9httY9zP0HRlv8Pnf/HNKvVVXlVgJ5KtQ5IdiF/UKjPczoOOiQLb9mQtm1AH0XOVf+ZYoq+C/MQMcWLurAHbulF1bp+FEL8Tk3l X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(366004)(136003)(346002)(39860400002)(376002)(451199021)(41300700001)(478600001)(86362001)(316002)(54906003)(8676002)(52116002)(6916009)(66946007)(66556008)(4326008)(66476007)(8936002)(6486002)(5660300002)(7416002)(44832011)(2616005)(186003)(36756003)(38100700002)(38350700002)(26005)(6506007)(6512007)(1076003)(2906002)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fyyNJr6CU2r9/NxK+40OXFSC2Sy2Zp2EwnlkwfgQppuoxUfsLEbW98wMhYv+eiLdGDyeLjyCjHLdSzA+YXz1QW+Pgw35UurSi44WuwONTdYpWHgBghZ7ZNpav78zNEBEtEvyn+4AmyGdnx2J3j2Ztmezwd5k0ZsBtahaR1oitouS+sQryEujHqUtivo4jqbbFIewwZ8V0h4Ku5anFS13CuGzjTXZgWId3cHFAqRb9NfsgcHcrBvAZPezZw//i9WzU6r6689B3y6moN2E/wXzJwkBM5Ii1Oc/0ifsj+BtTse09JIHVltFaebCL0bJKZT8dF42ickrwWPmCTHyn6c2xOj2BE9UeqKC4OwNDAmDFkkOjSv0TvROCHVVuJE0pP5+HvEAsQBFchOLsY/sg+hbKOCTGxapv3jTShe0jtfA3tnXu/JIckfuMWzg0YRvAEJORu5RCJmn2gjqx7SDrJ8K5qdExMgss6a3yDnHiwhRKdriXGYUXDTn7Er4WIB6ZjaobIYxX+/at3PJe768q5KhEXxVzSI5lOqML+tMlvbz0JTRFunmCxCHQEc5bEkoCLzJ6aJzEoxxRJQ8i8UfZV659OcYgvR7jbJyMb7m6p06CC75PwSmPWjesnLiUxRCOBQ3CisXepWDA+g5WmcFpORszFJLl92tkmyadDzudIOR63vAPJJitQfnt2aQAJlbG9gLg/zyNPsccKpcDwQ5ta0YdP5FM/UzcpAn1TjRHd8YqGCFL9DO7Xf2m0a96ZuZlN909ZpOZp6nq05jI9tSsLASFCm9VSKEfY3MuN4BzX3jalt/auNG93pGfrSXct60F8lxjEqy6Z257Qk9af2kpmWclnBDy8SHhO28AJ6nWG19A5ncotAP5+RkldtcI48449MqRVDCA3fBB5UVHEMUynzah30tbP2pMFnpq9AS2vSL0TUgJLF28pXTamQaQBzcfiJLD8fE20Wwkk4IYV6VWDBNLnlr+V6Tn9zopPZrEkLuHmMpICGEOz+PJKd3KueAKSZBkc1/eY3gpbJ8G0gvrZSH1w81JXV4w6LCoVAyh7WLZIAbX5ylvQaW9658IwDW4ZrW8kC8kuw1VjMIczL63UJd0gFF96XiXrPLuDM8oR6Snk2lUyFjww4zFwRStOmNnuaLO9JEiaiOfUlXIayv1poIW43f31xm8aAdsrUaZ5zs21v0C5AaA2FvB2TcplfAEjmTxDKrG4EWALYk63r6a2WdSPQIUqbPPAa+amhapTu+c224B+0uUkxmPZu7ysg5Yimj+BCI3DkxOkNhQmx8iK348vfJMD2i0mDB+UYyIfNVvMk/mFlo/BGWQbUFkbD0uuwqESrChtLSrPCSgDZqLxsySKXhGRxzyAbwK2E903Wh/EqjkwOTDU4Mr622BhCG4lUurNndrhoK09Ajye0f06bVhChutpLpM78zBBnyo6zfy89N9j70ui2Vz/u4J4e+u3g2mAfi2d4kZYtR/pzXAVN88PHdxs+8QzVjJ1RXQ/g8QfJsTv/K0Bf0RHhHob6Ta7Vaws7NAHhprGLfKXrFhHU4PuwRvZh0Emy+Ijf6tqDIv/LL4zNOoMjIB38WdrWrUqVu7vh0K6KeRN+Czh+ds/IZSg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 10fa4c78-6e62-4990-3aaa-08db3ab6e5f3 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 18:02:22.1630 (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: KNH8aGfC4NQ8qyhWto9Zxuj+IzSASPJYOWap8pQS+Nl1GWr6zA8gq/fh5vpzfAGIUHASTWyWhmLtNvHWtFc1Xg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7829 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Create a wrapper over __ethtool_dev_mm_supported() which also calls ethnl_ops_begin() and ethnl_ops_complete(). It can be used by other code layers, such as tc, to make sure that preemptible TCs are supported (this is true if an underlying MAC Merge layer exists). Signed-off-by: Vladimir Oltean Reviewed-by: Ferenc Fejes Reviewed-by: Simon Horman --- v2->v5: none v1->v2: - don't touch net/sched/sch_mqprio.c in this patch - add missing EXPORT_SYMBOL_GPL(ethtool_dev_mm_supported) include/linux/ethtool_netlink.h | 6 ++++++ net/ethtool/mm.c | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/include/linux/ethtool_netlink.h b/include/linux/ethtool_netlink.h index 17003b385756..fae0dfb9a9c8 100644 --- a/include/linux/ethtool_netlink.h +++ b/include/linux/ethtool_netlink.h @@ -39,6 +39,7 @@ void ethtool_aggregate_pause_stats(struct net_device *dev, struct ethtool_pause_stats *pause_stats); void ethtool_aggregate_rmon_stats(struct net_device *dev, struct ethtool_rmon_stats *rmon_stats); +bool ethtool_dev_mm_supported(struct net_device *dev); #else static inline int ethnl_cable_test_alloc(struct phy_device *phydev, u8 cmd) @@ -112,5 +113,10 @@ ethtool_aggregate_rmon_stats(struct net_device *dev, { } +static inline bool ethtool_dev_mm_supported(struct net_device *dev) +{ + return false; +} + #endif /* IS_ENABLED(CONFIG_ETHTOOL_NETLINK) */ #endif /* _LINUX_ETHTOOL_NETLINK_H_ */ diff --git a/net/ethtool/mm.c b/net/ethtool/mm.c index fce3cc2734f9..e00d7d5cea7e 100644 --- a/net/ethtool/mm.c +++ b/net/ethtool/mm.c @@ -249,3 +249,26 @@ bool __ethtool_dev_mm_supported(struct net_device *dev) return !ret; } + +bool ethtool_dev_mm_supported(struct net_device *dev) +{ + const struct ethtool_ops *ops = dev->ethtool_ops; + bool supported; + int ret; + + ASSERT_RTNL(); + + if (!ops) + return false; + + ret = ethnl_ops_begin(dev); + if (ret < 0) + return false; + + supported = __ethtool_dev_mm_supported(dev); + + ethnl_ops_complete(dev); + + return supported; +} +EXPORT_SYMBOL_GPL(ethtool_dev_mm_supported); From patchwork Tue Apr 11 18:01:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13207999 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 AF17BC77B70 for ; Tue, 11 Apr 2023 18:02:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229712AbjDKSCb (ORCPT ); Tue, 11 Apr 2023 14:02:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229834AbjDKSC1 (ORCPT ); Tue, 11 Apr 2023 14:02:27 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2045.outbound.protection.outlook.com [40.107.8.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4AE1526F; Tue, 11 Apr 2023 11:02:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=li9OUysshzh40t/9khDNV+Uxa+wUyCBDHm/6EcbViVddtdR+AySIQ0qw5oKzd/NX/GCSFuawGc+nRCVGnk5C/sxP79j4X4beWdg92YIM4GGsPuj31Q7lDxkKy5b9hH6DglM+ej2ASS9d54CoANwmSUE73yWdLKx5Pm6LgQaYuzi2vBe9u40v2jrHbO6YpRzp3qymS1o3AfP1T32M4g5KpBMxs9M7RBSX/BgfqBw3Tbnwhpu/9tEBLgrh46FVBcyrVVGY8LHrFwBhKX6u7Y7ZCB8Roqye3iItDMFk86uiRw4szLGHqhnS9G7ebn7oPMY/iBG/+513o6LA5dF1Xl2Exw== 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=YHICxalMYFf3wJI2upcaICK+32vwVcjiEmzN8xDnquc=; b=P8HfNPO3yGU9tijACQKr0zGpbmIwUdOBYiALkRxeRDPEYrRneyQJ2W/S9QmglNAE5S8C1thGkqSDliREACweih4dL92K3F1kzrVQNKnvKPNklffkpStdHCEekJYYby9ff95tYPP+QL5Knlb+nw8gydxnauO/jpeI7gNCf5+6SIDayxfC3H6keoCddn1RoUyIixFn9cVSIo4w4ZsNdABXOoSR41G/31VeZVj0BFT5xVRSPdcIGZeKfKqvKTWyAlDGuoTvDGj0QRdfMa6fpxhTZ/u52to8Fou4NLjXuiD1940pyUsfyhNy85otYzkPmUDa97f3NL6VgfFhqhgZrq4fUQ== 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=YHICxalMYFf3wJI2upcaICK+32vwVcjiEmzN8xDnquc=; b=FCyi3UZxXjev/pLYkM3BQjKDmKwDZwCEZBaUHBqiq8/TuW5goKL4Gw2kNjWKFkgqi6d3brgjYalIZ7arCB0OEwWJCI9QA1l6HU4qrFjtGK0nTaFGuGpLROsGIlAwz1G7huMdUOgSjyYf3VIHaxLGZl0u34wklGU6+UM6RwAc0Io= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by AS8PR04MB7829.eurprd04.prod.outlook.com (2603:10a6:20b:2a7::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Tue, 11 Apr 2023 18:02:23 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::55b1:d2dd:4327:912b]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::55b1:d2dd:4327:912b%5]) with mapi id 15.20.6298.028; Tue, 11 Apr 2023 18:02:23 +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 , Ferenc Fejes , Xiaoliang Yang , Roger Quadros , Pranavi Somisetty , Harini Katakam , Giuseppe Cavallaro , Alexandre Torgue , Michael Sit Wei Hong , Mohammad Athari Bin Ismail , Oleksij Rempel , Jacob Keller , linux-kernel@vger.kernel.org, Ferenc Fejes , Simon Horman Subject: [PATCH v5 net-next 2/9] net/sched: mqprio: simplify handling of nlattr portion of TCA_OPTIONS Date: Tue, 11 Apr 2023 21:01:50 +0300 Message-Id: <20230411180157.1850527-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230411180157.1850527-1-vladimir.oltean@nxp.com> References: <20230411180157.1850527-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR2P281CA0186.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9f::20) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AS8PR04MB7829:EE_ X-MS-Office365-Filtering-Correlation-Id: e5ce62a9-6dc2-4829-efdf-08db3ab6e6ef X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: r4GpMN4zYY6UeAFDpcFcE8OehCj87RyR6Onp7VNKewQZ38YOQd3oB8Rvhdm1jwEzU3NibBM8yTEuS0Gkbap+LfwAeUQupSH1fkXNYBUnczLOy34tTGC7Na1K2qlhYR2zsd0hdaIII/BV28hBtyCAJ087G0rLYyYHFAWcLy9OA+/tShQnBmehTX8hJ3QAqbuqi0SHm4a0OYi+0IDXQ/N5qVOrMORfQY6p+r6MuydCds0gm6U/EVRrxB8yWbZ5PYcnuEzTkAz7WXpfn1Cx+gOyqXG8DVrKnFE/Pat97UNYSHPuDtpAkWLLRWNv/Pvceg9kH8ZJCmSdZG1fM1XRb4/eHsVbrKlaqmso18ypG1Q1tixCymE9xerRfGAF4fj6/eIbgJ8jJFM6ZXaZAlOvcdvbtAXhfoTVqfmHpv7rgtcy76apWNKzCYMI2NWjgwW1O1agV5JwQ50JQ8RN2ztaP2Fl/SO3Cix7NymWGmODWD/oVM9Q1Hx80P64wVTKp7HRgklsT4gLK3fOA2RDh/MaoszM16EQiBHwU+CXzyxJsoyxdeH8Sp7p2jx3+37KRrWd1wSKSt3n0jY1CEbmUTabJvDHOf1n6vCX1/2JOmDudkyJ+9Vu+jTZmlC555/sANOUQvds X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(366004)(136003)(346002)(39860400002)(376002)(451199021)(41300700001)(478600001)(86362001)(316002)(54906003)(8676002)(52116002)(6916009)(66946007)(66556008)(4326008)(66476007)(8936002)(6486002)(5660300002)(7416002)(44832011)(2616005)(186003)(36756003)(38100700002)(38350700002)(26005)(6506007)(6512007)(1076003)(83380400001)(2906002)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: JvROdNK7oFLYZc+1wutND6ia3cAx+ePCRsAisNYZgIjWVvQAnba+oaXQEvZlSUVwbWWOq76skbnoEabP3vz0MBQcKAIbPNAo5PMuAcEZw2+z6WKGQ9yEQ6v/U7qIwdSipXNdMh6R/9jnLlvjlyflkgIXr8b4rVQ+LWDDRZzshBrvRgpj4am1noGVFWvFhW0GIXDXBumILqaKnQp6QWSPJW1a3mTxAZ//8XdUk0jONPvOY4aoZH8anyeRNzJtqpE8OSEknQlsCPiUP5zUcsn10mTkgPPEJ/yWrfVV3JnuXYCdQfmRw4ZyKdWoXMJHaZsVVpQzXvWI8+W5b3grFGktF2QReKkWyLfzCIXKmsgXq6mohEfQIw1fciyAEaJ4jGLSSSC9Cxs5unvEIACp+Xg6y2rhTqLrtG5LrFRhZk39eNlmiE0lSDa5W7CqCnqgWssBoiy1jWt313QCM7SPesvVYaKX4vf8QpGtivDi3otJ9ns8qdPkUok5Ajb1CgVboDhSrd1Qs279glsmzxrSRmcnYBfVcF8XcdsUxLyULMKN41wDZmkaddDRR2OMd5irdZDyZC95GASD1gn2gLRoyM3iAiL6o+o7/dYyHDrEdd5QawIRUE027W39umCOHVnsdtUSRNHpXIWd7FDmEaiazLWkb1cidllQ0g7KkNA8SSaP8KxIWSmCt8oX1xkWWA1outQa4ER6bHfHtjvzd4fK6WLYe1Fy1g3Dbtr8MN37Swzj5zRZJU1uP2veT4fZl/nA6Qr6aEevgPLmtbIICHczgDX3xlwF3j85SIjOQylm1SEmyYiHPWJV1xQpEqEqjRFYVJ+x9xuUFtXuam2ssAvnaVSXs7VOX1lYwBZCsXsARYv0xTxSaGB6a6E9TwLMEVsfG/nDYpgkmLyRVbzH8mUP3fEepqOvXm9/cG+Xqvke5lzoOKiAWXu4nKgayVvkVCJ++H8YADHvH+qUJ6SpFBo8FWlnZAOc8XADdjRWhKQuDfauL+ybY4i2Mx43YFQQgf8Z4j20YZEqxUl22rOYeCwclGgNM6+T7unLQxo+uqLNmO61Y/H9geRLHIKbsN9x075Dwmg8G76UreBSYG4W5AzaFfJta6S4Uzu+ZFS5hHkB6IJX1y4v3GeRNFZaynSgZqut3grq5SF8e6X01oI//k7ik+p9DzWSxdxb4l8SueWMGYEb18IbmcoJJjFBIG2WD9ybeuauz1D4EmX1bv4WoZcsZyYtvw/bxt354sEoGEziJRvz/4e78+SBh9OZOYml/2wgnN4rrZkdXPyPNchFMMWUMz4Ved/q+fxyZQSzzjZR1/KyoMuSRDcHEPDrFpF1BXiTnKffHAEzp87xYIvew2YgfrGaHxmli52Fty5fPe1YUB11RNFk7xV0skZvTIZkUBrJb1BWXmAiOyHH1rzpGpfUOXHCXJYhEwOBBawuaZ7fPaJ0u3kVyjuKe+qyr7q9Uk3BznZqqLsiyy9qTwxpgw9GRoHQvTwYIb2chx5PMARTOrrwgyWNj3y9C2lEUFggtQhNQGld2wrjeUdMHAHwOQalG+TkD3eONExcgv0elkizsdaua0br89yFM9bcwph93i738W00AJp9DUhvCC9KD1vmXQIAyA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e5ce62a9-6dc2-4829-efdf-08db3ab6e6ef X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 18:02:23.8427 (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: XvWb2A846lsAGUFYJbM1GAA0Y805I2rTlBBqbBXYgwf+4na7Ne+Wx6fNUeH3YA/GO9BIo00fRtNbzkeXN9sXjA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7829 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org In commit 4e8b86c06269 ("mqprio: Introduce new hardware offload mode and shaper in mqprio"), the TCA_OPTIONS format of mqprio was extended to contain a fixed portion (of size NLA_ALIGN(sizeof struct tc_mqprio_qopt)) and a variable portion of other nlattrs (in the TCA_MQPRIO_* type space) following immediately afterwards. In commit feb2cf3dcfb9 ("net/sched: mqprio: refactor nlattr parsing to a separate function"), we've moved the nlattr handling to a smaller function, but yet, a small parse_attr() still remains, and the larger mqprio_parse_nlattr() still does not have access to the beginning, and the length, of the TCA_OPTIONS region containing these other nlattrs. In a future change, the mqprio qdisc will need to iterate through this nlattr region to discover other attributes, so eliminate parse_attr() and add 2 variables in mqprio_parse_nlattr() which hold the beginning and the length of the nlattr range. We avoid the need to memset when nlattr_opt_len has insufficient length by pre-initializing the table "tb". Signed-off-by: Vladimir Oltean Reviewed-by: Ferenc Fejes Reviewed-by: Simon Horman Acked-by: Jamal Hadi Salim --- v1->v5: none net/sched/sch_mqprio.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c index fdd6a6575a54..89e5dfb22db6 100644 --- a/net/sched/sch_mqprio.c +++ b/net/sched/sch_mqprio.c @@ -146,32 +146,26 @@ static const struct nla_policy mqprio_policy[TCA_MQPRIO_MAX + 1] = { [TCA_MQPRIO_MAX_RATE64] = { .type = NLA_NESTED }, }; -static int parse_attr(struct nlattr *tb[], int maxtype, struct nlattr *nla, - const struct nla_policy *policy, int len) -{ - int nested_len = nla_len(nla) - NLA_ALIGN(len); - - if (nested_len >= nla_attr_size(0)) - return nla_parse_deprecated(tb, maxtype, - nla_data(nla) + NLA_ALIGN(len), - nested_len, policy, NULL); - - memset(tb, 0, sizeof(struct nlattr *) * (maxtype + 1)); - return 0; -} - +/* Parse the other netlink attributes that represent the payload of + * TCA_OPTIONS, which are appended right after struct tc_mqprio_qopt. + */ static int mqprio_parse_nlattr(struct Qdisc *sch, struct tc_mqprio_qopt *qopt, struct nlattr *opt) { + struct nlattr *nlattr_opt = nla_data(opt) + NLA_ALIGN(sizeof(*qopt)); + int nlattr_opt_len = nla_len(opt) - NLA_ALIGN(sizeof(*qopt)); struct mqprio_sched *priv = qdisc_priv(sch); - struct nlattr *tb[TCA_MQPRIO_MAX + 1]; + struct nlattr *tb[TCA_MQPRIO_MAX + 1] = {}; struct nlattr *attr; int i, rem, err; - err = parse_attr(tb, TCA_MQPRIO_MAX, opt, mqprio_policy, - sizeof(*qopt)); - if (err < 0) - return err; + if (nlattr_opt_len >= nla_attr_size(0)) { + err = nla_parse_deprecated(tb, TCA_MQPRIO_MAX, nlattr_opt, + nlattr_opt_len, mqprio_policy, + NULL); + if (err < 0) + return err; + } if (!qopt->hw) return -EINVAL; From patchwork Tue Apr 11 18:01:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13208000 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 9FD33C76196 for ; Tue, 11 Apr 2023 18:02:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229995AbjDKSCd (ORCPT ); Tue, 11 Apr 2023 14:02:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229872AbjDKSC2 (ORCPT ); Tue, 11 Apr 2023 14:02:28 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2045.outbound.protection.outlook.com [40.107.8.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A4CD5593; Tue, 11 Apr 2023 11:02:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C+depjGJc6mUe+8SvwJMREKtkUeMQcWztMBuCHBK/OcuHPo5f3stcLS5ebwGkoUwCnZstQ9c1Q942aSpe2xCBm32dUthbd5VU3e5LD9UNjzZaoOCgDxzk6l6qDfYrec9+0xEhwtF5JQYEDXcRivpT7GW2yVC/qcdmezwilIwDSk+WANubdXKdm0fLBiLMlvniWq9CW7oYfVTuh6AyX3STu3IiNH+3cfIBMOKNIx+1ejwfYBKgl92PkTsXfJI8qpR1Z9plz9jvSdlZMJlPP91a02XHVhR6cLS52UER2i2SE9I6DuaEwPfwhGDsKkxgpSoziG4D6LMzgGkHH4s735pPg== 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=D4MfKnnorVexmxTPclAKEWkprWBM20wpATNp+uMF4dY=; b=cP0RDcLKA6gH8k12Uu0svesTgzfuUSgviHkq4EWRzhiJtja+9dvIB4FAuhZ/AF5H9ENNLHSLM9EztDxnS/H9pQrsnNwLJPjRFu5J5XSLtFA6MP2dxUgObgJz6XfPGsZafpyuDqgFzLhdifpaZj99Uwi53YDtI/0n27xWd6SBq+tsv9IaZnfKR1RdjNg1u5lrHLY8thE5MAEoXgOk1wVcxXw/YX2SZuCu9IV0HOYBXsiOOAA6wSrwODT1d1RB5uDq35M/nlp7jwV4/GpS06mcsGzTSlXXcwK/7Y50nZdoJye1rR9NBCtYtQo3/qjK510mBoWe8EB9pEUV5CtYev1EVw== 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=D4MfKnnorVexmxTPclAKEWkprWBM20wpATNp+uMF4dY=; b=i3iQnLboKSUpuaUwF9j4wwszzbPWjKESdWWO6/7jzJE8wile3TWBbggCslZYO7CWryC+MCvibfptR045sX3YHH2Z1sQTCoSnhVwxDAREddqofYWgQY+LdDglPwFCleBT1wrMGRLylEWEUZU+JqXlup10oPGWmTMc589TZkeMf84= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by AS8PR04MB7829.eurprd04.prod.outlook.com (2603:10a6:20b:2a7::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Tue, 11 Apr 2023 18:02:25 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::55b1:d2dd:4327:912b]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::55b1:d2dd:4327:912b%5]) with mapi id 15.20.6298.028; Tue, 11 Apr 2023 18:02:25 +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 , Ferenc Fejes , Xiaoliang Yang , Roger Quadros , Pranavi Somisetty , Harini Katakam , Giuseppe Cavallaro , Alexandre Torgue , Michael Sit Wei Hong , Mohammad Athari Bin Ismail , Oleksij Rempel , Jacob Keller , linux-kernel@vger.kernel.org, Ferenc Fejes , Simon Horman Subject: [PATCH v5 net-next 3/9] net/sched: mqprio: add extack to mqprio_parse_nlattr() Date: Tue, 11 Apr 2023 21:01:51 +0300 Message-Id: <20230411180157.1850527-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230411180157.1850527-1-vladimir.oltean@nxp.com> References: <20230411180157.1850527-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR2P281CA0186.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9f::20) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AS8PR04MB7829:EE_ X-MS-Office365-Filtering-Correlation-Id: c660420b-c188-4b89-a524-08db3ab6e7ec X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: x0H/Ebw0OSvuNjvgLY3wdgmL1Z61KmCskJSKNq6GsDm8ZH27GkiFhwy1ML7acw10TsMAo1xrC1OSk2bfaEt0XWfGEraqyyfJfk83Dj1bF3flbxKnM6vb7yAhIFHBUDHxoTCd1wVARvE0uKTulxNHMYeOyZqwKSo3MaHGo+am+JwoyP1CcRnifjbVGKKMKywQFFECPfCj0lKiji4OaG6Y8xJRf2SWQcO508rjj4YOptALv1h7LHejKnkJb1q8/4dGamgZ5qMr/gCvN3gWIN236FyvGU1B/thdSrmYHrvfg5/mhxXS6HugmSC92f7nAoIfg+M0K1ltaXnLTgYxUD4g4N3E0O+d9RmTSQN9leYGtPetFzzgReMvWMUGwhqC2uKsFuS+/0BkdVrdTpiWngopKataJStt2C70FVdCfn8I5n3DpO0DifpGCvQ+IF+JT2olOtZ20bm43OggKnxfVaMZRIbjlb44e2HSeS3TN04MEg1rBCDyQD1I7cmsatI+1i8cEtq3S+a32/NmzLvzXvFVwXbRlOAY4gGqtg8GrQFagj8hMVI0aMqzn6KPf33ZnLSgfsVXVtDY2T1+1mSSXE9MNyjcUAcqmGePYo8IiZkFTkTgxbSTAauvgXxnS1wnIEDI X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(366004)(136003)(346002)(39860400002)(376002)(451199021)(41300700001)(478600001)(86362001)(316002)(54906003)(8676002)(52116002)(6916009)(66946007)(66556008)(4326008)(66476007)(8936002)(6486002)(5660300002)(7416002)(44832011)(2616005)(186003)(36756003)(38100700002)(38350700002)(26005)(6506007)(6512007)(1076003)(83380400001)(2906002)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WjJZJB7JWDdWexrWpUFheuz51PExbtFz0Er8v1CbQ3I5sA6n2fSpyTGL9M0WIqFIkNg3hxnOU/lo+JsV58yZNkTB7mYzPsRvr+wCQUwY1tV+E39hqnrO9wQFYedorwCf5orvmdBNNMlilnNxXl2bOjnUXK6uf/Gl+kTO+In1dcwtMA4w9N6YJrUR5IaHJ1kK2QE06FKyp5BLeWGNaj8ZCCgyLXYURO7IouPntlb5F/zRR3NZbGMXCu4SVg6tXYPIoRq0JXBjP6BrSqW+vzVgGL5hW/vVKD6+JqWHsKYWKfiEl4ODvY0jtwu2KLCA53FvsflNLg6wDLGhkV5HwYmAMaOLsp2PqYxr+axunx7HdozCX/iZxZEbIDva9yhVhjJIsS8QuLqb5rkjUJghuM59B6CjFqNJE9xX3Y8I3OUyO4u1pEoeH9z0FTrgeyq1TdaI3T/ka5yVC/iR9Qqjq6H4+UO+fCvtENYSb6blirhV8E5Sdc4k8z8on9+lWxMn+T897R/9hH6KP14+7Z7FD2qhvkZivi2JCG0iOV34uvHpoVqb45dksohcfYpEE1UWfEgw6tQ4cnWJ/eUffCMGY/HnZBPDB56er/HZndvEnSMXgjCzQQ20KfNPpBugGjSnyHijmKcxaLxv+sxm7DC1x3MuF0ZIUbULYSB9diUsvDoQArWpLbAsl64SF87+xxApP8cAHBN/1C9PAKqlfiVAuiBVDWh4P5wgalf2LCnmli9Ckv8HEsC+1QP9HYjNilZhocYvqxD3/5bWcPascYbbdHno+MKJNDLKLHrcByeoOzdLAAO6yXH8zDv0m+EBrR7PVrrrtQ+sJ5SM7Np00MGFYE5N6PMXupfyOvUX7aVHlUmsuKOtdF6zx0rHZH/fsLpGLg9+wwc6a7pBT73OXY84HfT7dcTx5R1kgDTMznViMcqeWYqQAo1Er5pcHBPuzARfy0FvA1+4ALFANPWMHBCTNAhigE0/blirtWUTufb0/zZBtX+NWIMeSsUxh7Gzm/cHD8vu8j06hftL6FbikyRKusFMbAunK8HBKZFVRPfCLCipA7gQUwIWKP84JCPTXhitI5Vse/xXM57UpPmrOGMQ7oMZa36MSDVIxkrKYLVOsnh6FP2WH+onIrM8UzU0XZ8xBJpL5C2s7LB2DdJM+4yWHUnH2Q3uXn/3SCiVGwFvO8hCyu21fIHY6U7yyRXwdKYrPtRGHePG5NI8KkSqric6mXdHM59BleDnApgJLdDfrRRdcb0ScBknWbj2MdtPJVwDtHFj/ixUHmg9iGPt9OlreHRwgvFaWBuKuYNWq96w0P73PZrXk71wu8XHwXPgEd6raYZZ+8SCSDIj85hWtuEqaKTGJjn5bSo/BC+op/enUFx+U6+tGPoXsCJH1/6RQ3UPO7PtoGc8qyQJlbht3Lf5cwDfcly67T5Yk9KVzUfcnOnyYdDG3YSClZ3ed8UKb2H4bOK4l0CcaEbj0jOKIeUCo9bEgPSMF6MR2xht6FKC14P+arXRPr6fwSnnN8X+VjVezFq1TU3aJbdIEeSwpC3+Q4Sagmmt1fAfxDZbPMebkIobVCX8CXZpX6UAUt+Wsn4+Azm+IUqeHajs14rp6eCR/TzjWg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c660420b-c188-4b89-a524-08db3ab6e7ec X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 18:02:25.4624 (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: BvTuKR794MPQBJBBLqxLt/JCep2u1UP8dy4mO6e8yRSMmx06ziFWekS3U62EB7E5ky8YlFc4PNvLbFGQT7szZw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7829 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Netlink attribute parsing in mqprio is a minesweeper game, with many options having the possibility of being passed incorrectly and the user being none the wiser. Try to make errors less sour by giving user space some information regarding what went wrong. Signed-off-by: Vladimir Oltean Reviewed-by: Ferenc Fejes Reviewed-by: Simon Horman Acked-by: Jamal Hadi Salim --- v1->v5: none net/sched/sch_mqprio.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c index 89e5dfb22db6..8e8151ca8307 100644 --- a/net/sched/sch_mqprio.c +++ b/net/sched/sch_mqprio.c @@ -150,7 +150,8 @@ static const struct nla_policy mqprio_policy[TCA_MQPRIO_MAX + 1] = { * TCA_OPTIONS, which are appended right after struct tc_mqprio_qopt. */ static int mqprio_parse_nlattr(struct Qdisc *sch, struct tc_mqprio_qopt *qopt, - struct nlattr *opt) + struct nlattr *opt, + struct netlink_ext_ack *extack) { struct nlattr *nlattr_opt = nla_data(opt) + NLA_ALIGN(sizeof(*qopt)); int nlattr_opt_len = nla_len(opt) - NLA_ALIGN(sizeof(*qopt)); @@ -167,8 +168,11 @@ static int mqprio_parse_nlattr(struct Qdisc *sch, struct tc_mqprio_qopt *qopt, return err; } - if (!qopt->hw) + if (!qopt->hw) { + NL_SET_ERR_MSG(extack, + "mqprio TCA_OPTIONS can only contain netlink attributes in hardware mode"); return -EINVAL; + } if (tb[TCA_MQPRIO_MODE]) { priv->flags |= TC_MQPRIO_F_MODE; @@ -181,13 +185,19 @@ static int mqprio_parse_nlattr(struct Qdisc *sch, struct tc_mqprio_qopt *qopt, } if (tb[TCA_MQPRIO_MIN_RATE64]) { - if (priv->shaper != TC_MQPRIO_SHAPER_BW_RATE) + if (priv->shaper != TC_MQPRIO_SHAPER_BW_RATE) { + NL_SET_ERR_MSG_ATTR(extack, tb[TCA_MQPRIO_MIN_RATE64], + "min_rate accepted only when shaper is in bw_rlimit mode"); return -EINVAL; + } i = 0; nla_for_each_nested(attr, tb[TCA_MQPRIO_MIN_RATE64], rem) { - if (nla_type(attr) != TCA_MQPRIO_MIN_RATE64) + if (nla_type(attr) != TCA_MQPRIO_MIN_RATE64) { + NL_SET_ERR_MSG_ATTR(extack, attr, + "Attribute type expected to be TCA_MQPRIO_MIN_RATE64"); return -EINVAL; + } if (i >= qopt->num_tc) break; priv->min_rate[i] = nla_get_u64(attr); @@ -197,13 +207,19 @@ static int mqprio_parse_nlattr(struct Qdisc *sch, struct tc_mqprio_qopt *qopt, } if (tb[TCA_MQPRIO_MAX_RATE64]) { - if (priv->shaper != TC_MQPRIO_SHAPER_BW_RATE) + if (priv->shaper != TC_MQPRIO_SHAPER_BW_RATE) { + NL_SET_ERR_MSG_ATTR(extack, tb[TCA_MQPRIO_MAX_RATE64], + "max_rate accepted only when shaper is in bw_rlimit mode"); return -EINVAL; + } i = 0; nla_for_each_nested(attr, tb[TCA_MQPRIO_MAX_RATE64], rem) { - if (nla_type(attr) != TCA_MQPRIO_MAX_RATE64) + if (nla_type(attr) != TCA_MQPRIO_MAX_RATE64) { + NL_SET_ERR_MSG_ATTR(extack, attr, + "Attribute type expected to be TCA_MQPRIO_MAX_RATE64"); return -EINVAL; + } if (i >= qopt->num_tc) break; priv->max_rate[i] = nla_get_u64(attr); @@ -252,7 +268,7 @@ static int mqprio_init(struct Qdisc *sch, struct nlattr *opt, len = nla_len(opt) - NLA_ALIGN(sizeof(*qopt)); if (len > 0) { - err = mqprio_parse_nlattr(sch, qopt, opt); + err = mqprio_parse_nlattr(sch, qopt, opt, extack); if (err) return err; } From patchwork Tue Apr 11 18:01:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13208001 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 95651C76196 for ; Tue, 11 Apr 2023 18:02:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229579AbjDKSCo (ORCPT ); Tue, 11 Apr 2023 14:02:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229960AbjDKSC3 (ORCPT ); Tue, 11 Apr 2023 14:02:29 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2045.outbound.protection.outlook.com [40.107.8.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39A345B86; Tue, 11 Apr 2023 11:02:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZlnJX1Pddn6lroe/yNESAUEYOtwpMNRPuh3iTFrN5oxtPIGf5hbOR4cGyIc7XvK3C7nPaYL883uCBYRhvA8Vd7vjphPl+RUoJyQGaTg1NW5uv041NFXkkFY+LR1u2cemUj9hP6ap7rQ1ANbL35l5ZWwDtDatDJblnGXzC+2XiJNgYcnVel/NcT0bsMVHq89L3wMsiVOW0KdoyArKurrMS35I/5qd5t0IQd+T4DLHAcOEv+njpjRuolMj30XPuaNgMTKXlrwJb24r6Ik0rDOsweEfNgKak52iBrPKhm21bR9kzBxMfVz2w361QFSe2+KoeInpe/uD5d4QLgNuo0iZIA== 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=6lAGmooedVC7J+3mmfkvE02wUN+57K6a6L3sSPi5grs=; b=SqgKw5c7kEDuw4nBMDyZNM9SphuOMxuwVo1qsuPjhHXchGDS9J8ZAFwcXebSzuAld+gRBPfKON5TWfita3SFb6nl6Hm1+tgmwTtb2s7t/pE/Hjd4VpNREviGLP/LKEtlKKJMiTxXluBE5y1Goc4ilML4zwv8vVfL3vwG7ENKPkNSnvdduoc/Oh0QTcK2Tx+a0ETH8QuKz+yO2QyQckMFmhYMUI7CnjrcAONLM7eyVwZ0hunyQ+fMuJDYWeAlMCBIzhhPlMehroKhxnEaEawrr1ZQ4/J8YG61ZoPuxkJyc/heuSRteIaNidXqkEvaY1H8YHA8jsyNtJAuV4AEh4OF3g== 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=6lAGmooedVC7J+3mmfkvE02wUN+57K6a6L3sSPi5grs=; b=Eyn3c3n7M3PyrA3EN1loHPnaQVx6RUhp4mMmk5jD3iae5jO86cKrbHFmMSlHiIxIF+75vXEVW8a/erq0bDyvR7PzGvFwIO6vwl2vjWJ2YBzncKM6ER0SXMaHnJHIC8nXIercZ9G6W8tbnlXZgwwTS282KohL1WgDXqpay/0zQfQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by AS8PR04MB7829.eurprd04.prod.outlook.com (2603:10a6:20b:2a7::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Tue, 11 Apr 2023 18:02:27 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::55b1:d2dd:4327:912b]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::55b1:d2dd:4327:912b%5]) with mapi id 15.20.6298.028; Tue, 11 Apr 2023 18:02:27 +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 , Ferenc Fejes , Xiaoliang Yang , Roger Quadros , Pranavi Somisetty , Harini Katakam , Giuseppe Cavallaro , Alexandre Torgue , Michael Sit Wei Hong , Mohammad Athari Bin Ismail , Oleksij Rempel , Jacob Keller , linux-kernel@vger.kernel.org, Ferenc Fejes , Simon Horman Subject: [PATCH v5 net-next 4/9] net/sched: mqprio: add an extack message to mqprio_parse_opt() Date: Tue, 11 Apr 2023 21:01:52 +0300 Message-Id: <20230411180157.1850527-5-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230411180157.1850527-1-vladimir.oltean@nxp.com> References: <20230411180157.1850527-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR2P281CA0186.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9f::20) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AS8PR04MB7829:EE_ X-MS-Office365-Filtering-Correlation-Id: 46d81490-c833-4382-f807-08db3ab6e8e6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ig41anPhV12x3SqvHrZfPlccNhy4Qly5skzgsRxVId32p7+u5GxsdLfRgp0LrGQ2PlkrG7qesqdFj66ho04qhRcIFJB6Z6/LZfNltKnZCcX5OV/sgXJzBaNYnox7MZOQ+i/T68r8on8sf3fYvuP5tiX4FHUNgOicoshWqzP3ZSsz5FKSncmQmyGTDvP4dunoRxAza78BG3Ht6zc7P1g1MfWmHMmfkFSTun3pdwKWnfIrRAaIXSmRzE92IDzs1fJCWa8awOkSQ38sXUaR4majlWXzBDrAm3r85hWk18b0rbn4uRRArIdtiklbGES3PglzGPo8h1iyFLb5guAsDGnlTIt0X/yWBQqekfDl3qkCVD6kKxeGaxmHxBUz2yT+Kt02Rwd4Zqh81DCnzMF+B/cf5GmNh65AZmkpKoYXaVcFFBdSuBDppbhdaj4w9byOSnnmeFNMFqHZd7W1ZozfGzotj1wwyWss4Sb5NO1bkUDc3+epG01IWbp/DKOEHWKIe4azUBu9FA70nQp9bvEwwZi87Zts4U8a+GHDvfiFM5LPaHbUmdyONg7ALp+B+pZvxzZLMopY6kB2pth4kQGgGFr4tpdy8SCUMCEfLtU7TATX97I= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(366004)(136003)(346002)(39860400002)(376002)(451199021)(41300700001)(478600001)(86362001)(316002)(54906003)(8676002)(52116002)(6916009)(66946007)(66556008)(4326008)(66476007)(8936002)(966005)(6486002)(5660300002)(7416002)(44832011)(2616005)(186003)(36756003)(38100700002)(38350700002)(26005)(6506007)(6512007)(1076003)(83380400001)(2906002)(6666004)(15650500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uZcQVDisoF1fmFkqtMRr5YtIEh1RzzPBauO1tmCz4wkDZouydwyfGq7l1JJAm/ZWdaaczZN9HLrHjFjyiaK072XHeu5gPg2ExlByHPZQy1a5RIYL4z/0geNh0J3ZtrTP2AUuhJlJw8jC3eyD4I4sn5Q7ReEFOUtBijEOU5Rgxd/OaUv/N237zrmV1bQBZ03j6sZm4jIMQBWyJ+RiUXCGJnUTxedJlxyLj2JOpxK7nsBN0TG33CRKI8fDVYkMy1pkDessvqb1CJvbqGLDNZoo/hpC7ST0fFcXLG1WXr4UlX2C6G+rtW9yDarmHPUcf2lj3G/tAwJ4olISLoK2zTGdEiNHRRUhFWCYkcuLn64rZhVpRUB/oV/j+R4UjcPvThOxk4lpT9+0dAUR3TQ6bD2bGh/+xowngODbd2R1Slar+OrA48p0mlCfNdCP5PYXX2+gz5CWtp08DmnsV5Xidi79vP5M1S4vcV/QLbwu0E0neL9TLL7bCQ/8w6E/s0Qjee/bM+l0z7a10clM1/ByPdv9WdQtWlZu2VgK+rLHdsAU5lWWmefiV89oLxlLZzXlfiqw0FDNOghoGnvf3ntSs5eGU3EtWOi3HlJvQVUXkvFnQOwiqAAQ1GULTgrLElRXr9l0qsLD+ahnf/sO/9PUat8nWVT3QuGJlNWpb68riqSaHVl50wNPx8fRFApMk2VtldFpB/BcWAcV8HOjNQX7XM2VdZ1Qai7/K3nX2A/6nDXGoA6O0JhAzKriY8eo2SJgrYopJ6lDiy4AtkMSHJfqXU23S8U5Qk6Y8oqmJuaYEsNm6xzTUwsubLgHTTqS/Zfo6QFTa1HTHJp3CjdKz0RwFjgi9ElFXGRtsMC5r3sZRn/0GA/X1+pxqdUl7V1x4sA+oLdVU2vSoOgsc3OJnp8UzfK8tiagYgNQS5mw2NWm76ltrQtkB+HyayJukFC8WHxvNNsiny1iylU3Ltl+t7fajaunC5D7lusBggg4QjsMJ3NCJ8HyZYOfhnKx3eMS1lf1GavvxvhxHu200g4yJik1X+8Hf3wlTxozO9Mzw7VC04Fy3P0wmwH0mPqzvMFPXdgEPxyh6dNva3jU02m5DYg81OS1olqXIJ159MrnDFi42+M8DUuu0EM8pc++cojRDnkkG6i8UCeWbXaxx/rGpjOABr7gmGhpjIx7Aw6qgH3rLdAnAMfQuaeydJisMihGcn9BjKFRtY7PB0hqlck6/Gew+sEuPrMddlksZyv9/O7vL+/3tgtBAjn361Q9Na52LQFIg169rg1PGpTxoAca+ZaXTHxoEVRdNbZKM/pNK3n2l6OlOc+e/rfxKa7mQszmDSmBQ3INL/k6QfbJqjqgoAvi2IO0suUaJ1ls+Mg2qrzanUN7bPJ092JW9vIS5h/2FxMLIOTeODsHHiGCbtGRslzJZBUbydYI8GkH4j+pIRWnETTZBAfa6kvd+Gzk7hdtc1jaB/6t5tnlfqC7XILDsyHM112/UrQwjW6MZRDsm1etO2bxgLoeTRozKIIcHynaqDpK7ThgOXUnuHthxES9qmFpP2XRluUU4ztOjl86kCZ6w8+oVtonWv09TUgeqRx1qCGIpCwsxH2aiCygTe0E4fprFSUfyQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 46d81490-c833-4382-f807-08db3ab6e8e6 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 18:02:27.0999 (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: XxhCXOWfaZGeJdp6WPPEnJJKnJ6zAJz0d45mBkdHzqRNIIlhD4M2Y136mzEWPee0Ax6hAPmp/EPU3UlzlpENMA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7829 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Ferenc reports that a combination of poor iproute2 defaults and obscure cases where the kernel returns -EINVAL make it difficult to understand what is wrong with this command: $ ip link add veth0 numtxqueues 8 numrxqueues 8 type veth peer name veth1 $ tc qdisc add dev veth0 root mqprio num_tc 8 map 0 1 2 3 4 5 6 7 \ queues 1@0 1@1 1@2 1@3 1@4 1@5 1@6 1@7 RTNETLINK answers: Invalid argument Hopefully with this patch, the cause is clearer: Error: Device does not support hardware offload. The kernel was (and still is) rejecting this because iproute2 defaults to "hw 1" if this command line option is not specified. Link: https://lore.kernel.org/netdev/ede5e9a2f27bf83bfb86d3e8c4ca7b34093b99e2.camel@inf.elte.hu/ Signed-off-by: Vladimir Oltean Reviewed-by: Ferenc Fejes Reviewed-by: Simon Horman Acked-by: Jamal Hadi Salim --- v3->v5: none v2->v3: change link from patchwork to lore v1->v2: slightly reword last paragraph of commit message net/sched/sch_mqprio.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c index 8e8151ca8307..aae4d64dbf3f 100644 --- a/net/sched/sch_mqprio.c +++ b/net/sched/sch_mqprio.c @@ -133,8 +133,11 @@ static int mqprio_parse_opt(struct net_device *dev, struct tc_mqprio_qopt *qopt, /* If ndo_setup_tc is not present then hardware doesn't support offload * and we should return an error. */ - if (qopt->hw && !dev->netdev_ops->ndo_setup_tc) + if (qopt->hw && !dev->netdev_ops->ndo_setup_tc) { + NL_SET_ERR_MSG(extack, + "Device does not support hardware offload"); return -EINVAL; + } return 0; } From patchwork Tue Apr 11 18:01:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13208002 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 41F3CC76196 for ; Tue, 11 Apr 2023 18:03:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230150AbjDKSDC (ORCPT ); Tue, 11 Apr 2023 14:03:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230034AbjDKSCn (ORCPT ); Tue, 11 Apr 2023 14:02:43 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2045.outbound.protection.outlook.com [40.107.8.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1AD361B5; Tue, 11 Apr 2023 11:02:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=frBUxP1RaKbwP1DmJHW3W0n7b4yxtHHXr/D+hUXYNZCtpmKpWzIHvMSmV44+XBbdrvDrvfEV1J+uXVGf7SmcfYxSVsBeojSPt8flj6GlxcoGHXpRVDgeke7payZVdJX1pOxXqS7gli3nYMQI2fTQR6ZjPGipEvQvy5AELFkppSWMAJtafiQi4zAabd6rtPBLs4gjsgpB1w5Bm2xn8IzGpfXxE6DFLzyC+MPHIKEvmUBHlSGvDs/p8KVRzQu7sytzHYXzQwaTqUPipypzXQ+c5xGzBeLlG2whWHetGOqqzeXP96asVa1jsbEw0VIYhiTyqG2XXXKgeWjdjkGSTlRr7A== 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=VP9EEfl5mIhmjubsT9Ff9sFexFj057nS6x8TfZsyEj8=; b=TI4G+iQfnvNtYhAZKBXslop0d38QEgzuN25ud+TXG0OwWxnMPNUxWWMUVlBd5reb6bUvvMDGWSn1vWBI6J+1F0MRYi4aO8wNFq2ZA1IDcjkBVg4qplO8SrCBQGO2woQztjtcQGvC8YTYXj1Z5KGL5VHClc51cj/QFN0ovETTipJdRMmwiayevUub4kFa5MdRYM29uFk9tWNJl1fQoEjOMbhWg+/zGnabeSDkNpCUlVgLG2NoKzfI/TFGccMFuSkOfeYpR1zgv/UP4Tj/cF8T4oUoTmoCxjib1Xa2Rf/XwjvXBrIDEY2KsSKsY3TtzPZjDkUHHUJa+OX9OoSvnC7goA== 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=VP9EEfl5mIhmjubsT9Ff9sFexFj057nS6x8TfZsyEj8=; b=Q8hWAEyyqzSlD1vqtsnD8nZCtvKdSxfUGOpSvSwnB/IGgkgrWPQNopdjri1f8VA6mHqQOgwlttiJCjeL3uypx6UQoqBnQtrCq3bYq79/eB6mEfXnh1YELaPAqkzr6t9u4NSgKKicfR2eDNSM1/+s1WImY4Upa4XeFinMYmHF+iw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by AS8PR04MB7829.eurprd04.prod.outlook.com (2603:10a6:20b:2a7::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Tue, 11 Apr 2023 18:02:28 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::55b1:d2dd:4327:912b]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::55b1:d2dd:4327:912b%5]) with mapi id 15.20.6298.028; Tue, 11 Apr 2023 18:02:28 +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 , Ferenc Fejes , Xiaoliang Yang , Roger Quadros , Pranavi Somisetty , Harini Katakam , Giuseppe Cavallaro , Alexandre Torgue , Michael Sit Wei Hong , Mohammad Athari Bin Ismail , Oleksij Rempel , Jacob Keller , linux-kernel@vger.kernel.org, Simon Horman Subject: [PATCH v5 net-next 5/9] net/sched: pass netlink extack to mqprio and taprio offload Date: Tue, 11 Apr 2023 21:01:53 +0300 Message-Id: <20230411180157.1850527-6-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230411180157.1850527-1-vladimir.oltean@nxp.com> References: <20230411180157.1850527-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR2P281CA0186.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9f::20) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AS8PR04MB7829:EE_ X-MS-Office365-Filtering-Correlation-Id: 073a089d-5caf-41c9-8658-08db3ab6e9dc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GCZ7OpPBEuvtIHFX6hvvMt8oX382EW8zsGPFk8gNo3oXx3cHDEDgssIwd260haUnErqXrlV8yGtca8hYmvPTi9SppwKuyi9QEG5J5JMsKzbKteMpf89yRbUaFBk47BkrkCZT9f3zUp0/rdV9b8DECV7DXgndy2lDmIKqRAw3Hp2z0+ZaAKE4ikLSPx4nFGp1KSQVHXq/fyd9rT3+h0Rt0fxgnB7Vn9LnivirroVFXXPScEotHpITG8xPiyxHW1LAEMqegD1nXahNqnQqLoKv0m0aJlyan6bE7BArekboNKEnX5KakX3a33eujIjevt/u5Fxu/pIUrGOi7smO1cNGR5kuf9Wk7BvzUKKazctCFFKAo9lmnr2ZHtxQXXWd1PkY9vNblKM6q6KzQb+pSUmioNPPcSPVaGLg3raow9Y2YGNNz7AOuyc4H2YncWfIVOPeVDFboyGElB1Pz1b2+mD/rjkn7X5Kw5AU8HJQSv+lZIS5UMks2IZJ135OdxRuoivh20nfbVXl4Ot+SP9idHSg3ZXy54r/at1lDKJlpnnb/0b2fJdQ7YBlbRZRqlGeF+ZXso/oiBWtjwoA4KjLya7B1blBowDmp/ciavof/Lm06zgQxQ4Nh3J5GaJiHCW0NFAL X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(366004)(136003)(346002)(39860400002)(376002)(451199021)(41300700001)(478600001)(86362001)(316002)(54906003)(8676002)(52116002)(6916009)(66946007)(66556008)(4326008)(66476007)(8936002)(6486002)(5660300002)(7416002)(44832011)(2616005)(186003)(36756003)(38100700002)(38350700002)(26005)(6506007)(6512007)(1076003)(83380400001)(2906002)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qSsmE8y/XbnDXgJMZSt14+5MPCGIjKOZpAGxQPB4TZbdHFW08e+vtER1JDFJ3l8YNA/DRBbOWly2NB4WploISG4G+cIL4PWwx6iwdNcIJKF1iTUjimreGVAIkfCpGh69iH5znrDjn3mUeOiQHz9zrokK2SzfUmjPVakGSXTd47EiKMhRiSJXjfwdpGfr7+uDDkdk2JZ9XxWwQB7WAqk+zkaIbXHInzhdW8zWEXzJY+Q46eTJTUTOIZLUFjD+MNPSkdeG2jkIwbY8FUn3XlJpNR/ILYted7g53I2u5D1gQA/UCSIFPG24EKTk+FbddUcxQepuzD9w09bG7NGMzEMDpSCSQyCpERtVkOaOJxoFmaeQ9pwMTfQt7vt/xZYRwY5fWdoKTfXhqDgT6dLZZeer2nTyZZJLSY17OexUTdWiqKfOYyl1C1QGUCXli4Mm5Rp3v/DENJpBFR1HkD8/0xdp02u6YAXmbefZoMFtKbFSbXOvB6Slge8ssmTLlnHwKHAG2/sFiYUlPkIjrvOapa0407ncJLV0BknWfxS9xodgjuNT+I7v/0hU6ArY2GfvtfkAGUo9dGHmafu6hTuTLGVsnNIY/NPxIlVY7YCXMUnoIFzPRKKNM0O3cdVKYzWLHAbhNJnNxyurQxe9dhsKLuRTu8mdMPk+vSB8QR1sBK6nkNIbQW2lS3wXcfxzNlMOiChGSGHsx+MBW+Ur2eXMJR+rGM+etgLGJOAh4mjSkYT7TR0CJRsQ8HxMSTdG5UPpWVMoSGIdnfdtJq2SJiee/YwVwYjopUDeb/1ojLBBo6rUxTXubvR1WS55J+aYEjNp2PZCvTi5MkOVyp0yg5cunm6YZWkBRCX6D/5jmbX+jetI5D3L2UDgE+l8dQweGpdqjxCoMlyVt89nGsmC9jSeRYMSLRZ6GLXFvIkBbc0okQ5rpjjFud+cQaC/63R3z2aFV51mNBs9M6/dLigX0cnyX2rImoBmnqDIVgNivYqBpRFhFxF9LJSt8pCY0KAv6QYjnNVoxrBVXR/I5tE4XgprUBhpkm5iYmbFnymw/DR5pJQSCOzn26AuOWMQUpOg1RDnAoHpI4AQg/uDlg0Mmc9fVtgji0HvhM461Twt5I98NiKkHl//Shd6Zu4VZktdhqKYx8mqLo4LsvWokpfqs0mqSuV8eP0O4CllfcnywQxIoXwCtSuGeAuZ84WyyYNbudblakTV1RH6dZ7CwYEqisfNeLz7x5gZFDPMaUZ4/Fp89KjK8dKwcPGydoY6qINLHuLwEmAkpQaPB/MQcmsU2PT11bdsg1uK0SD91cDVg8TOyIPbrvYZ3QqrimmbjNGnb0qm9g35qrAaY+O8gn+LTWYC1CK2v96BTPbB9DKgXB3ORWrGyZbkRFMnH390GuTaiK/7Lxs73MHYV6FKOMAe3zfRkCy3nHf8GmH1CuHZUbCya8QNYNxUtJ8u/RPOlJSos00NIgLjAi/76JPiDlg7ohYdzFg3Z9BwsMtw7eaQJJmbeycSypTVAZonZ++60wrP+wnrAAYv4PLojNWG0DI20S1f+a/4raF6mu44lj2kRfye4WhyxIFmen3ezVYApB37jfNYv9w370bAReLaRzgBg5DqsBCeUQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 073a089d-5caf-41c9-8658-08db3ab6e9dc X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 18:02:28.7140 (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: 2J2MdSccaAMq9yYyXLvdIY3g2u47oKtmBdxxSUYdxuho/+WLsIggcW5BHhbpmy6VzNARf1aVSU9u0D7wpfv1Qg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7829 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org With the multiplexed ndo_setup_tc() model which lacks a first-class struct netlink_ext_ack * argument, the only way to pass the netlink extended ACK message down to the device driver is to embed it within the offload structure. Do this for struct tc_mqprio_qopt_offload and struct tc_taprio_qopt_offload. Since struct tc_taprio_qopt_offload also contains a tc_mqprio_qopt_offload structure, and since device drivers might effectively reuse their mqprio implementation for the mqprio portion of taprio, we make taprio set the extack in both offload structures to point at the same netlink extack message. In fact, the taprio handling is a bit more tricky, for 2 reasons. First is because the offload structure has a longer lifetime than the extack structure. The driver is supposed to populate the extack synchronously from ndo_setup_tc() and leave it alone afterwards. To not have any use-after-free surprises, we zero out the extack pointer when we leave taprio_enable_offload(). The second reason is because taprio does overwrite the extack message on ndo_setup_tc() error. We need to switch to the weak form of setting an extack message, which preserves a potential message set by the driver. Signed-off-by: Vladimir Oltean Reviewed-by: Simon Horman Acked-by: Jamal Hadi Salim --- v3->v5: none v2->v3: patch is new include/net/pkt_sched.h | 2 ++ net/sched/sch_mqprio.c | 5 ++++- net/sched/sch_taprio.c | 12 ++++++++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h index bb0bd69fb655..b43ed4733455 100644 --- a/include/net/pkt_sched.h +++ b/include/net/pkt_sched.h @@ -166,6 +166,7 @@ struct tc_mqprio_caps { struct tc_mqprio_qopt_offload { /* struct tc_mqprio_qopt must always be the first element */ struct tc_mqprio_qopt qopt; + struct netlink_ext_ack *extack; u16 mode; u16 shaper; u32 flags; @@ -193,6 +194,7 @@ struct tc_taprio_sched_entry { struct tc_taprio_qopt_offload { struct tc_mqprio_qopt_offload mqprio; + struct netlink_ext_ack *extack; u8 enable; ktime_t base_time; u64 cycle_time; diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c index aae4d64dbf3f..67d77495c8fd 100644 --- a/net/sched/sch_mqprio.c +++ b/net/sched/sch_mqprio.c @@ -33,9 +33,12 @@ static int mqprio_enable_offload(struct Qdisc *sch, const struct tc_mqprio_qopt *qopt, struct netlink_ext_ack *extack) { - struct tc_mqprio_qopt_offload mqprio = {.qopt = *qopt}; struct mqprio_sched *priv = qdisc_priv(sch); struct net_device *dev = qdisc_dev(sch); + struct tc_mqprio_qopt_offload mqprio = { + .qopt = *qopt, + .extack = extack, + }; int err, i; switch (priv->mode) { diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index 1f469861eae3..cbad43019172 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -1520,7 +1520,9 @@ static int taprio_enable_offload(struct net_device *dev, return -ENOMEM; } offload->enable = 1; + offload->extack = extack; mqprio_qopt_reconstruct(dev, &offload->mqprio.qopt); + offload->mqprio.extack = extack; taprio_sched_to_offload(dev, sched, offload, &caps); for (tc = 0; tc < TC_MAX_QUEUE; tc++) @@ -1528,14 +1530,20 @@ static int taprio_enable_offload(struct net_device *dev, err = ops->ndo_setup_tc(dev, TC_SETUP_QDISC_TAPRIO, offload); if (err < 0) { - NL_SET_ERR_MSG(extack, - "Device failed to setup taprio offload"); + NL_SET_ERR_MSG_WEAK(extack, + "Device failed to setup taprio offload"); goto done; } q->offloaded = true; done: + /* The offload structure may linger around via a reference taken by the + * device driver, so clear up the netlink extack pointer so that the + * driver isn't tempted to dereference data which stopped being valid + */ + offload->extack = NULL; + offload->mqprio.extack = NULL; taprio_offload_free(offload); return err; From patchwork Tue Apr 11 18:01:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13208003 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 8E5A4C77B6F for ; Tue, 11 Apr 2023 18:03:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230249AbjDKSDE (ORCPT ); Tue, 11 Apr 2023 14:03:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230053AbjDKSCn (ORCPT ); Tue, 11 Apr 2023 14:02:43 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2045.outbound.protection.outlook.com [40.107.8.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98E826A7E; Tue, 11 Apr 2023 11:02:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CkLCNQQPjz+RBWzNPHpjUI/9H7yW1C8Clk1IdHVKdvTnqzM4FsL+fbkKV624imnNrrObtkv0siH8DOBZE13TezxembYRkEZkHX3JW9+WstFHHfxIOICREthB4Tsx9gPwDTEU8+EtG6a5COO8HRaNKiNuQyEAbWQKSU07OxYxsNpd5anRxU+QyrHy6Nv21iNzx/eQQTpXuVvvvvQ8g3rQI2i+FsPaB0xdvDDzWb/kH+m00ZnBq8oAvjUSGW+CVqYy2HJTuMmZedDb6UXMEPg+Gt4rC+wxHSEbk/m1/Pbe45L3rfgZWQg/DZPTROLv2Ho8MyaPH66MbJfiJPvatlrXFw== 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=OeLEPyStBO8JT73LZKkycLEh9m3oBOZVC+NT+wuALJ4=; b=LgX9T4Y9SDYB1QXvLZtxUMXl6UoXDxC7FZibY8FRmPQgVUYhRVSkRzZ/c5qc6IJcmt1by3ScoRHskY29tX87cIClty5pwqWMTqTx0+/xsStYPVD2mg1P44K+Bd+yg9ktsD9Va6tGQ4MkJEG/sdWvftfTRvbZuqQvswiWcBXu8JB8zaXdWeKbLHXHlbSMRsbGeyMQ41HbrrlegsEIStrEUb+sBbqYRrQfy7lJnh6Z2VeTJtXUs6MaslLKH0lEPr/IbRWhGZZHBHfwDnBY2oK7hKjDWwnGXZMEDiVu9UAOzmdyDdd/OjBXZlsP8bOawUGL/rotwpki6gMvPir4GcIMMg== 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=OeLEPyStBO8JT73LZKkycLEh9m3oBOZVC+NT+wuALJ4=; b=IqHAYWA8+P0oidyN4vesp5giEvaL9xDQIeNbzSzEC81T5rMZKNPlJOLwDaCCeQHymnrcOyIMdpxBbQML86rRoYk72v4pxs+CnZPJlgEmgyvt3E+HhBtVK/pZ88sLdigaAEUHFJzht3+oJzF8uwpcpo1KG/feByRpV/rrBQq9Ln4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by AS8PR04MB7829.eurprd04.prod.outlook.com (2603:10a6:20b:2a7::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Tue, 11 Apr 2023 18:02:30 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::55b1:d2dd:4327:912b]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::55b1:d2dd:4327:912b%5]) with mapi id 15.20.6298.028; Tue, 11 Apr 2023 18:02:30 +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 , Ferenc Fejes , Xiaoliang Yang , Roger Quadros , Pranavi Somisetty , Harini Katakam , Giuseppe Cavallaro , Alexandre Torgue , Michael Sit Wei Hong , Mohammad Athari Bin Ismail , Oleksij Rempel , Jacob Keller , linux-kernel@vger.kernel.org, Ferenc Fejes , Simon Horman Subject: [PATCH v5 net-next 6/9] net/sched: mqprio: allow per-TC user input of FP adminStatus Date: Tue, 11 Apr 2023 21:01:54 +0300 Message-Id: <20230411180157.1850527-7-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230411180157.1850527-1-vladimir.oltean@nxp.com> References: <20230411180157.1850527-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR2P281CA0186.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9f::20) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AS8PR04MB7829:EE_ X-MS-Office365-Filtering-Correlation-Id: d247d78e-1405-4aac-d95a-08db3ab6ead6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: n3fSZh0woepsY8It1trOGFKKKjAZ7cdIL8Jsnu6Nzc0ZVOLXlnJMk9GEX/vGcyTxJfYRxAaqu2iTl2OIFD4r0FI12op2mzXTzlO4tLeNncyzIEDWKHWxzxeitIge4XYRG86wrVFhYWweTKpLlOUBCoYOqiZ2dD9jZ68or7DHcM0PZkuafEXagEkoTTsR8S0bFnifS86PvzVIgaDF0EGeuGoXH74HTaw60cTTaiAH6cBYHgZa8qonW81HhBkxNh4ytc/2/8rkK0PuCWk03X6vdFLSUkzUZYlt+2yHDWTOZccj+GMF7r+qpjW/B8YQe0c5S2cs1qlOSNADEoZFfX+cnrwvxLiEiWYPrzeVOXvgLvOQ0yhCl/5porKGZEQRMGvhj+i7n1at4wL9GFi5dITzZxefw04asULN1/O5p6/kDaPBIVEifhok5udWfxrrxKKCfTnBP3DhT2kKDQwc8d56LBWtIHSlnuGnGbHm7zt9dp6ZgTMWJRvf2qT9FzIVHk8UNetC1RmbGarqotG/IDsn1Z3xn5GgzlhAabZFomYq+39l5CR7KC0F+gu/8XSfAh8/kiVe3p5ir8aawNjco3//ZpJpLHnB7gy1EqMbmNuoNJzgb+ZOZPee8/6vEaAZkOob X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(366004)(136003)(346002)(39860400002)(376002)(451199021)(41300700001)(478600001)(86362001)(316002)(54906003)(8676002)(52116002)(6916009)(66946007)(66556008)(4326008)(66476007)(8936002)(6486002)(5660300002)(30864003)(7416002)(44832011)(2616005)(186003)(36756003)(38100700002)(38350700002)(26005)(6506007)(6512007)(1076003)(83380400001)(2906002)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: EwMCe3HNxGC2pH40XFxLfX5BF+D5cLx0oDdCHjodBUTp/w0egA0TztKgYbaEVqijHNBOvgMvj1GwzEqzM7Bo/eVOaJ0gm3MdPxn3+Nn9ZcbB0rlhnYp4SbtJ2Z2jDD0NiaSzr6pjYPdnH937s3VZgJso0ScrdQ2U+wTsqh53FpNuSoZQ09Iz0aYU7X3jwSXbLz1JbvimmiNReWHPIgwQt1UKSBKs2fqonZIiHFw/BMFwdLQZ164t8CXoljeax/p0f8kXlWlVZouEOuJvyof0SdWr7y1Yzp3tRN/0EzTGAlanJkqY7I8NS8EBK9WTpJ/msCmmpBWzF5WANavQpOHN/TbQZpKmkDwh9vMYH08eYJAbn7pHIp3Py0rRCtiHofPMORcC2e5twhVb1KeFnVksCKeLEFX5cRBE3Fr/iT41PNMRrp6epB0packWrL1z+qqiPTXaskfjRcax7XDB61B38q4mjIqKJ2XpS03RG/JsZ7TuluFTCgr80srtBgrPVwrQyLD9Fi31k/OEDbEftUqZSABKVSlJzAcsFPE1mjoFdFPGGXQy3U48GX0Gk3rRAfn7lBlU1whlZtarcyKF5T4fBB23xjC4MJUvdJYVTfxi5taSb2YWon8v8YFAFsRtcTTNHbQLhtkVX5YNSd6r6nTkaZprXH2Mrlpa2EDdADu7WiLazW6K/YosjLjaO/F44mUWGYhLu2R7Mk1RN9TrxWnHUmBglfklcSUyxpkUkqmfFQHjuQ7lbD0WlsUX2m4Ev8PTppPsaIdkSqj48x2OhBm8Oa1yw2J/e721KQ8fD0/A089SmcpIXeki3swYQyZevR/hE4BXZx0vu1tgpKWFvrFWohsiRarmQudw5+ijFmDYxUM1hqFUAdWCKsGwCRg3zCuk8busr76mvkbdgw+RCCTI+wNtnvWTmCaTS/fw3dGOFH/8eDu5MKOK3whuonxlCP75phnhmn9B1UmcdBd+CoYO3Tep/qtrE4RmuK7kGMEmvANe3hY272gJyrXmgYzSpeQPfiTiKcMuj5LeliYKKDOlVG+aDwJ8qjhQFEbEUXei2nJy3a7dw6LRGBaiNJR5y6xUCUhFXDsbrXsfQBY77kXZsMQ9R2944KgM5JAb5HMBhJ4aAh9JInnzlmj7dgTdOzJE5kSx7wSIrWC99q/jyxHCUoq/583Pjgkjr1lH/02k/uebEVAbPreA57/dL4rGZ9ysdF2nDOENBoYiQSVl4LA8yKKbTxVEr3pUq2tbw7u2iHREFIpWikaeT8WqJz4EAWBrnMSbbaegquCuIipnSDvoTtgQpr4AALFBEEWNDjdl6ZAEicj9qqw9R4f8xrUCbBUTqov0KdbXprKSFgNRCywv4YYVhW2dQYzzRiKttjuqJTeMDAaFLdgc1yxj517FPzKHUGN/Gn7rEG1+y0fpyT5XL+K3OlLKOASnuOftQUalfsNDvrTmxmt7sIRSCEbJhIfBw2jLR/Sz0XQ71zWmxLmIFoV6Guuaxa+ipBuewkgf/LgDX4QbRDLWZpyI91R/Q/jBta8MAl+w2UCWQ04yHZiuvlRm6opinI6wIZo5M5zLSYcMWxyRmonxmUYeHuuPnjmlkiSNYOje6ENNwecLmHwZ5Q== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d247d78e-1405-4aac-d95a-08db3ab6ead6 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 18:02:30.3730 (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: efxkBUnMrfDCUQE8VXQaIoPEc8v2rzISUs1n4hN9Dq07B23KeI5BHRLaP56cbHq85yTPuxQsDsyWbLkgCO1c4Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7829 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org IEEE 802.1Q-2018 clause 6.7.2 Frame preemption specifies that each packet priority can be assigned to a "frame preemption status" value of either "express" or "preemptible". Express priorities are transmitted by the local device through the eMAC, and preemptible priorities through the pMAC (the concepts of eMAC and pMAC come from the 802.3 MAC Merge layer). The FP adminStatus is defined per packet priority, but 802.1Q clause 12.30.1.1.1 framePreemptionAdminStatus also says that: | Priorities that all map to the same traffic class should be | constrained to use the same value of preemption status. It is impossible to ignore the cognitive dissonance in the standard here, because it practically means that the FP adminStatus only takes distinct values per traffic class, even though it is defined per priority. I can see no valid use case which is prevented by having the kernel take the FP adminStatus as input per traffic class (what we do here). In addition, this also enforces the above constraint by construction. User space network managers which wish to expose FP adminStatus per priority are free to do so; they must only observe the prio_tc_map of the netdev (which presumably is also under their control, when constructing the mqprio netlink attributes). The reason for configuring frame preemption as a property of the Qdisc layer is that the information about "preemptible TCs" is closest to the place which handles the num_tc and prio_tc_map of the netdev. If the UAPI would have been any other layer, it would be unclear what to do with the FP information when num_tc collapses to 0. A key assumption is that only mqprio/taprio change the num_tc and prio_tc_map of the netdev. Not sure if that's a great assumption to make. Having FP in tc-mqprio can be seen as an implementation of the use case defined in 802.1Q Annex S.2 "Preemption used in isolation". There will be a separate implementation of FP in tc-taprio, for the other use cases. Signed-off-by: Vladimir Oltean Reviewed-by: Ferenc Fejes Reviewed-by: Simon Horman --- v4->v5: - don't initialize tb twice, nla_parse_nested() does it - use NL_REQ_ATTR_CHECK() and NL_SET_ERR_MSG_ATTR() for TCA_MQPRIO_TC_ENTRY_INDEX v3->v4: none v2->v3: none v1->v2: - slightly reword commit message - move #include to this patch - remove self-evident comment "only for dump and offloading" include/net/pkt_sched.h | 1 + include/uapi/linux/pkt_sched.h | 16 +++++ net/sched/sch_mqprio.c | 128 ++++++++++++++++++++++++++++++++- net/sched/sch_mqprio_lib.c | 14 ++++ net/sched/sch_mqprio_lib.h | 2 + 5 files changed, 160 insertions(+), 1 deletion(-) diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h index b43ed4733455..f436688b6efc 100644 --- a/include/net/pkt_sched.h +++ b/include/net/pkt_sched.h @@ -172,6 +172,7 @@ struct tc_mqprio_qopt_offload { u32 flags; u64 min_rate[TC_QOPT_MAX_QUEUE]; u64 max_rate[TC_QOPT_MAX_QUEUE]; + unsigned long preemptible_tcs; }; struct tc_taprio_caps { diff --git a/include/uapi/linux/pkt_sched.h b/include/uapi/linux/pkt_sched.h index 000eec106856..b8d29be91b62 100644 --- a/include/uapi/linux/pkt_sched.h +++ b/include/uapi/linux/pkt_sched.h @@ -719,6 +719,11 @@ enum { #define __TC_MQPRIO_SHAPER_MAX (__TC_MQPRIO_SHAPER_MAX - 1) +enum { + TC_FP_EXPRESS = 1, + TC_FP_PREEMPTIBLE = 2, +}; + struct tc_mqprio_qopt { __u8 num_tc; __u8 prio_tc_map[TC_QOPT_BITMASK + 1]; @@ -732,12 +737,23 @@ struct tc_mqprio_qopt { #define TC_MQPRIO_F_MIN_RATE 0x4 #define TC_MQPRIO_F_MAX_RATE 0x8 +enum { + TCA_MQPRIO_TC_ENTRY_UNSPEC, + TCA_MQPRIO_TC_ENTRY_INDEX, /* u32 */ + TCA_MQPRIO_TC_ENTRY_FP, /* u32 */ + + /* add new constants above here */ + __TCA_MQPRIO_TC_ENTRY_CNT, + TCA_MQPRIO_TC_ENTRY_MAX = (__TCA_MQPRIO_TC_ENTRY_CNT - 1) +}; + enum { TCA_MQPRIO_UNSPEC, TCA_MQPRIO_MODE, TCA_MQPRIO_SHAPER, TCA_MQPRIO_MIN_RATE64, TCA_MQPRIO_MAX_RATE64, + TCA_MQPRIO_TC_ENTRY, __TCA_MQPRIO_MAX, }; diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c index 67d77495c8fd..dc5a0ff50b14 100644 --- a/net/sched/sch_mqprio.c +++ b/net/sched/sch_mqprio.c @@ -5,6 +5,7 @@ * Copyright (c) 2010 John Fastabend */ +#include #include #include #include @@ -27,6 +28,7 @@ struct mqprio_sched { u32 flags; u64 min_rate[TC_QOPT_MAX_QUEUE]; u64 max_rate[TC_QOPT_MAX_QUEUE]; + u32 fp[TC_QOPT_MAX_QUEUE]; }; static int mqprio_enable_offload(struct Qdisc *sch, @@ -63,6 +65,8 @@ static int mqprio_enable_offload(struct Qdisc *sch, return -EINVAL; } + mqprio_fp_to_offload(priv->fp, &mqprio); + err = dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_QDISC_MQPRIO, &mqprio); if (err) @@ -145,13 +149,95 @@ static int mqprio_parse_opt(struct net_device *dev, struct tc_mqprio_qopt *qopt, return 0; } +static const struct +nla_policy mqprio_tc_entry_policy[TCA_MQPRIO_TC_ENTRY_MAX + 1] = { + [TCA_MQPRIO_TC_ENTRY_INDEX] = NLA_POLICY_MAX(NLA_U32, + TC_QOPT_MAX_QUEUE), + [TCA_MQPRIO_TC_ENTRY_FP] = NLA_POLICY_RANGE(NLA_U32, + TC_FP_EXPRESS, + TC_FP_PREEMPTIBLE), +}; + static const struct nla_policy mqprio_policy[TCA_MQPRIO_MAX + 1] = { [TCA_MQPRIO_MODE] = { .len = sizeof(u16) }, [TCA_MQPRIO_SHAPER] = { .len = sizeof(u16) }, [TCA_MQPRIO_MIN_RATE64] = { .type = NLA_NESTED }, [TCA_MQPRIO_MAX_RATE64] = { .type = NLA_NESTED }, + [TCA_MQPRIO_TC_ENTRY] = { .type = NLA_NESTED }, }; +static int mqprio_parse_tc_entry(u32 fp[TC_QOPT_MAX_QUEUE], + struct nlattr *opt, + unsigned long *seen_tcs, + struct netlink_ext_ack *extack) +{ + struct nlattr *tb[TCA_MQPRIO_TC_ENTRY_MAX + 1]; + int err, tc; + + err = nla_parse_nested(tb, TCA_MQPRIO_TC_ENTRY_MAX, opt, + mqprio_tc_entry_policy, extack); + if (err < 0) + return err; + + if (NL_REQ_ATTR_CHECK(extack, opt, tb, TCA_MQPRIO_TC_ENTRY_INDEX)) { + NL_SET_ERR_MSG(extack, "TC entry index missing"); + return -EINVAL; + } + + tc = nla_get_u32(tb[TCA_MQPRIO_TC_ENTRY_INDEX]); + if (*seen_tcs & BIT(tc)) { + NL_SET_ERR_MSG_ATTR(extack, tb[TCA_MQPRIO_TC_ENTRY_INDEX], + "Duplicate tc entry"); + return -EINVAL; + } + + *seen_tcs |= BIT(tc); + + if (tb[TCA_MQPRIO_TC_ENTRY_FP]) + fp[tc] = nla_get_u32(tb[TCA_MQPRIO_TC_ENTRY_FP]); + + return 0; +} + +static int mqprio_parse_tc_entries(struct Qdisc *sch, struct nlattr *nlattr_opt, + int nlattr_opt_len, + struct netlink_ext_ack *extack) +{ + struct mqprio_sched *priv = qdisc_priv(sch); + struct net_device *dev = qdisc_dev(sch); + 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++) + fp[tc] = priv->fp[tc]; + + nla_for_each_attr(n, nlattr_opt, nlattr_opt_len, rem) { + if (nla_type(n) != TCA_MQPRIO_TC_ENTRY) + continue; + + err = mqprio_parse_tc_entry(fp, n, &seen_tcs, extack); + if (err) + goto out; + } + + for (tc = 0; tc < TC_QOPT_MAX_QUEUE; tc++) { + priv->fp[tc] = fp[tc]; + if (fp[tc] == TC_FP_PREEMPTIBLE) + have_preemption = true; + } + + if (have_preemption && !ethtool_dev_mm_supported(dev)) { + NL_SET_ERR_MSG(extack, "Device does not support preemption"); + return -EOPNOTSUPP; + } +out: + return err; +} + /* Parse the other netlink attributes that represent the payload of * TCA_OPTIONS, which are appended right after struct tc_mqprio_qopt. */ @@ -234,6 +320,13 @@ static int mqprio_parse_nlattr(struct Qdisc *sch, struct tc_mqprio_qopt *qopt, priv->flags |= TC_MQPRIO_F_MAX_RATE; } + if (tb[TCA_MQPRIO_TC_ENTRY]) { + err = mqprio_parse_tc_entries(sch, nlattr_opt, nlattr_opt_len, + extack); + if (err) + return err; + } + return 0; } @@ -247,7 +340,7 @@ static int mqprio_init(struct Qdisc *sch, struct nlattr *opt, int i, err = -EOPNOTSUPP; struct tc_mqprio_qopt *qopt = NULL; struct tc_mqprio_caps caps; - int len; + int len, tc; BUILD_BUG_ON(TC_MAX_QUEUE != TC_QOPT_MAX_QUEUE); BUILD_BUG_ON(TC_BITMASK != TC_QOPT_BITMASK); @@ -265,6 +358,9 @@ static int mqprio_init(struct Qdisc *sch, struct nlattr *opt, if (!opt || nla_len(opt) < sizeof(*qopt)) return -EINVAL; + for (tc = 0; tc < TC_QOPT_MAX_QUEUE; tc++) + priv->fp[tc] = TC_FP_EXPRESS; + qdisc_offload_query_caps(dev, TC_SETUP_QDISC_MQPRIO, &caps, sizeof(caps)); @@ -415,6 +511,33 @@ static int dump_rates(struct mqprio_sched *priv, return -1; } +static int mqprio_dump_tc_entries(struct mqprio_sched *priv, + struct sk_buff *skb) +{ + struct nlattr *n; + int tc; + + for (tc = 0; tc < TC_QOPT_MAX_QUEUE; tc++) { + n = nla_nest_start(skb, TCA_MQPRIO_TC_ENTRY); + if (!n) + return -EMSGSIZE; + + if (nla_put_u32(skb, TCA_MQPRIO_TC_ENTRY_INDEX, tc)) + goto nla_put_failure; + + if (nla_put_u32(skb, TCA_MQPRIO_TC_ENTRY_FP, priv->fp[tc])) + goto nla_put_failure; + + nla_nest_end(skb, n); + } + + return 0; + +nla_put_failure: + nla_nest_cancel(skb, n); + return -EMSGSIZE; +} + static int mqprio_dump(struct Qdisc *sch, struct sk_buff *skb) { struct net_device *dev = qdisc_dev(sch); @@ -465,6 +588,9 @@ static int mqprio_dump(struct Qdisc *sch, struct sk_buff *skb) (dump_rates(priv, &opt, skb) != 0)) goto nla_put_failure; + if (mqprio_dump_tc_entries(priv, skb)) + goto nla_put_failure; + return nla_nest_end(skb, nla); nla_put_failure: nlmsg_trim(skb, nla); diff --git a/net/sched/sch_mqprio_lib.c b/net/sched/sch_mqprio_lib.c index c58a533b8ec5..83b3793c4012 100644 --- a/net/sched/sch_mqprio_lib.c +++ b/net/sched/sch_mqprio_lib.c @@ -114,4 +114,18 @@ void mqprio_qopt_reconstruct(struct net_device *dev, struct tc_mqprio_qopt *qopt } EXPORT_SYMBOL_GPL(mqprio_qopt_reconstruct); +void mqprio_fp_to_offload(u32 fp[TC_QOPT_MAX_QUEUE], + struct tc_mqprio_qopt_offload *mqprio) +{ + unsigned long preemptible_tcs = 0; + int tc; + + for (tc = 0; tc < TC_QOPT_MAX_QUEUE; tc++) + if (fp[tc] == TC_FP_PREEMPTIBLE) + preemptible_tcs |= BIT(tc); + + mqprio->preemptible_tcs = preemptible_tcs; +} +EXPORT_SYMBOL_GPL(mqprio_fp_to_offload); + MODULE_LICENSE("GPL"); diff --git a/net/sched/sch_mqprio_lib.h b/net/sched/sch_mqprio_lib.h index 63f725ab8761..079f597072e3 100644 --- a/net/sched/sch_mqprio_lib.h +++ b/net/sched/sch_mqprio_lib.h @@ -14,5 +14,7 @@ int mqprio_validate_qopt(struct net_device *dev, struct tc_mqprio_qopt *qopt, struct netlink_ext_ack *extack); void mqprio_qopt_reconstruct(struct net_device *dev, struct tc_mqprio_qopt *qopt); +void mqprio_fp_to_offload(u32 fp[TC_QOPT_MAX_QUEUE], + struct tc_mqprio_qopt_offload *mqprio); #endif From patchwork Tue Apr 11 18:01:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13208004 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 414FAC77B73 for ; Tue, 11 Apr 2023 18:03:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229966AbjDKSDH (ORCPT ); Tue, 11 Apr 2023 14:03:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230101AbjDKSDB (ORCPT ); Tue, 11 Apr 2023 14:03:01 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2045.outbound.protection.outlook.com [40.107.8.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FCAC659B; Tue, 11 Apr 2023 11:02:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jizysYVs99OjiwKWW5bhugdBT5bgeuFB+Pvaun6eHfCttcizmgS8uCn1IHfZGKPBtfbkN9wFisTlICFgsKYPFzvRfb+5V9jP2Bwd+oW+Zp/FBFutsKkTJp4trL25NpoYGN8PIYuL6vj6k+FSajTWU7ZwAZizFhVpsAu0aQa4Oib696GWJozjSxpBY6lqu5B/203O+f5FO6bNJiKWa6yYX0WF19VLKEglYMgPvUHLtY5xOBSX0B/fprO0/bUXjSch6ftnuUN2Dmg9GyMYG1ZZZhfG15Zz+BcFBRvJyBVOEJrG+PuorOOe16kmLMwADfxfp+syVDtsqyDMaFvpPqoWxg== 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=RWBEKXk3cVTgf+JhaSef1csrtsJlV25cbTm4fpz0yHs=; b=OMflONDBz2LUFlmyyxqieNuEyVyvEQYrsLoK9GV3rDx2NyryVlpj4PsD4sDtUNDTJf3p+62RZqWKAEig8L+kAUNOj1sJSg54d80nl9edEysSpn6m50CTSyWQmQsS9aK3mdFFVCu7gMP5qf0uCLGMxl8XIAA8tb0tp8Vgfs+HDnoOwfO7m3RJTNOs3M/M37RKpp2wFSbab5hwFVZ07vTYOBHqpQlF8MiolRNG5Gr4F4hnyVLYXnIADb/MMxFc3m43TmL6CH9qCUh4A62r31LLiJclslLLAVbT6OoGTQAYO8IZ2FLjetErog6ecqVVioFsPsuEmB0PpKoKxkpkCO8bXw== 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=RWBEKXk3cVTgf+JhaSef1csrtsJlV25cbTm4fpz0yHs=; b=QWvwcxRbJjKi6QI2EM1MvwNqmZRRbNyafa5nq+RL7NzFKkse0VBQslzBmwilBne34CKk0mWpvmUS623ukmT2COR9CAinPyQ7sIbq60pazPlKMsijOLSuiZwWyLqf/sEIFnpcMLSXeB7Hx2lnGn3zHLtXcF5kezzRgtqm0CTulFg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by AS8PR04MB7829.eurprd04.prod.outlook.com (2603:10a6:20b:2a7::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Tue, 11 Apr 2023 18:02:32 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::55b1:d2dd:4327:912b]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::55b1:d2dd:4327:912b%5]) with mapi id 15.20.6298.028; Tue, 11 Apr 2023 18:02:32 +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 , Ferenc Fejes , Xiaoliang Yang , Roger Quadros , Pranavi Somisetty , Harini Katakam , Giuseppe Cavallaro , Alexandre Torgue , Michael Sit Wei Hong , Mohammad Athari Bin Ismail , Oleksij Rempel , Jacob Keller , linux-kernel@vger.kernel.org, Ferenc Fejes , Simon Horman Subject: [PATCH v5 net-next 7/9] net/sched: taprio: allow per-TC user input of FP adminStatus Date: Tue, 11 Apr 2023 21:01:55 +0300 Message-Id: <20230411180157.1850527-8-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230411180157.1850527-1-vladimir.oltean@nxp.com> References: <20230411180157.1850527-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR2P281CA0186.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9f::20) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AS8PR04MB7829:EE_ X-MS-Office365-Filtering-Correlation-Id: b96645c9-cd24-49ba-8e86-08db3ab6ebd3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dodq3kWRHtKBHxjqrY1zstXP+tCqeip6wR0cYYVTuMh7mYfIxnCqkT6iXO1n4DGt4TPrwbGokkp7Ono5QZEHYxEqDkyWcpv3fdPPkN+lNUOeK+t4oNH1FSRLTQ0gktfia9Gg9uf2Cd5A6p7meTRxnMAk43HTvs2jNsF+yqsRFPswADq6zeAbGtr6siPvNZNowbNk3ks8gpFg0pKDu78cMRnu9EQxxcWWl4Hh8yi+lpg+Z8PFjicBbEgIMNdv6rbWBUaTImSxQ+r13Issqv/BPbIerGH66vbwOPgiOhOVQEWmVBlO7iU9TdJy5HTWxks9PwN7oufL7r4uCaZO9WaqLDDD8vzM1s3ruj8g4HD+LKda6uYVCgkiMP3ZYuvDXd8MIk1qJtdwiRPRnf1TwMjmL/m7YkA8jmvVByKEJ7X2vUwMUOMff35LrlVzxk6UAVqI1JotaRe2EUA/G90qgvBEid5iTsRkoFm6NFpxM71B4oz5aRxRo34k58rCnFbl/5z6GR0dWN5fGLq31nXmU/WOvwebwKDK9oImbjKBIAemd5BA3t5eNDyH/Z65c2xuusy3QjJT8xmqxXJ8cBZe87Zx6/dP9i5QKiZVNJSSuk59ZcmF0x1LwnE99kBh6b8kB1um X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(366004)(136003)(346002)(39860400002)(376002)(451199021)(41300700001)(478600001)(86362001)(316002)(54906003)(8676002)(52116002)(6916009)(66946007)(66556008)(4326008)(66476007)(8936002)(6486002)(5660300002)(7416002)(44832011)(2616005)(186003)(36756003)(38100700002)(38350700002)(26005)(6506007)(6512007)(1076003)(83380400001)(2906002)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: M4FVfLgTbR+o/ZnV85nhMAf+oFtrXqVTQ2YgpsV9bWJNctoH7Ny+QbAu6qR/QckOc+W01pEU1EhXHa9Y5W05m/FhzYty28LeLm/jJ5uJC1m3OAAg1APlr9MRYacD3qxHQdTZBWXCybkagvVQAUXDIMdMZlkEehWnSuMEIi+rmLv5kZGn1iGN7Sj73YSNz/O5G47dN/nhDns+LJWKw+rc1CbCkVtv7fHnt5jMYnhwttS3NxO2sXISYtmC/0Li2wxo+iwk36eoJa9FNcOf2SyhMXJEJjY8byvL55Ds9l0YO4Eepcw7bTEEfpBEG+Jfrh+SglxUUiKWNW3sbYQbDohm32C8+OZjio7IHhX/Xs8zxzDYpBOS2ARaSeDPmdyaEOTU9puoTrGH+kG8Hv+Sr2m9TmsP/fijKQJDWwX59OMbnq6hVvedhtQp71sDZypocXtDv1YKNVlebrlfUxMLdqGjNx0sZeJyR6LEYW2yAnoTaF2OifkFVjGYPkE8Xr/A+K8XHx0Ir7mwsrBBSRN8vF+gixdeEXmQiZEA8wAHBuZHZgKWzJ/eoiAKljIWFcDWVhC/Jlai4/fwsQDwkmyHzS9Ulf1z/3V2izXE+em42Baky/OxwEcThPqwKj9Nr08kCCw5oT6dIWrBbHAkXaoRJ0dk8hgDk7JAZPkrRvz+EpzKUTJi585GEENtPQRR+apvuCMZkcWkYjg5DtsrWYTZGeO+xweaUsVOquwHo6M0oIlKmh4rDwKag9/z6BSFH8bAu8kjm+hjoezI+rihb5DMMGm2bf9CKKF5+RU3+vQ0scCOMRTpnNzxOzbTLlHYrhlqlD6lu0wxb/GiT3olz0cJUdp05rL9cK3WFkbY2/wiVTpjfjGp3TDRSSvfB0AQZs4T3DJenu2L2XXQvEioQPC3fMxIn2ILeuLAeOLYl0dm8onyziEvPGozfdcSdUmlR9UWvoK+4GQJ2Obs8adQ3vPAJhg6pmYluJLfzZi1/oUJx2UGtjU4UWQa3VvMxQ4JNdKdq4b40HgT0Z9X1C+jC9DpNabKc5PLGhezjBYZwjs2q3sRzEfQBOgJij5PYYdtDo3VAy+sy1MrsG4BqsHRv2KfmRew9nhioQq/x2fx5N5K038hm9zxioDHWTZSfRdRu7EU3bUsptrzZ6SMj36iUAj/7RrGFvT04afl+PPrFMzASiS1IXnOkK2CZXD7asneRTChuBoOIjCie2RWJthyL9puOXgjHHSXQ9Z1Ah5oQOEuIPyZAqO7EaZv6rX9k76ZrnmQTWmHBNVArBnJlzyafYkEJ41oX0TfpyJTsMDeDuHNHYI3Y5YtAQKIfqsdSFllkIR5Wu5B0m53az15TPA6aIlxCrBPrzSd56USOtQMz6BVXkgyAVHrityXzMuwiy036Gt10iNuAYxYq2Is2SHD4iJ2IGbH+gOt6e3jznN1XVRVSFChsmLIzHxqKNBpCSBwobvL4QpCtYDaLHETQcEIbUsXuxnpfoJh1dvAar58DZlX6jDl2k79MJ5d69cqmYmRkmXEvqHOF6g2CaO36oihqEeZeXFhMs/zqTZWokuCvCASdhvhqjrNYv+a1RhLIyjYLErfga8vCn9Mc1TCcCHCSWlzAyeMMQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b96645c9-cd24-49ba-8e86-08db3ab6ebd3 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 18:02:31.9839 (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: E/uSxGFYz1NXg5O3YN0Su46RSL0PAIvMv8clSrKn3Ce0XxICaUkLchG35Cn59zVTs5o8C6bbE4kc6UmYZEjmmA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7829 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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 Reviewed-by: Ferenc Fejes Reviewed-by: Simon Horman --- v2->v5: none 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 cbad43019172..76db9a10ef50 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; }; @@ -1002,6 +1004,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] = { @@ -1524,6 +1529,7 @@ static int taprio_enable_offload(struct net_device *dev, mqprio_qopt_reconstruct(dev, &offload->mqprio.qopt); offload->mqprio.extack = extack; 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]; @@ -1671,13 +1677,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); @@ -1702,15 +1709,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; } @@ -1720,29 +1730,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; } @@ -2023,7 +2055,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); @@ -2080,6 +2112,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); @@ -2223,6 +2258,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; @@ -2240,6 +2276,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); } @@ -2281,7 +2320,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)) From patchwork Tue Apr 11 18:01:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13208005 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 3D7DCC76196 for ; Tue, 11 Apr 2023 18:03:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230306AbjDKSD2 (ORCPT ); Tue, 11 Apr 2023 14:03:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230162AbjDKSDC (ORCPT ); Tue, 11 Apr 2023 14:03:02 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2045.outbound.protection.outlook.com [40.107.8.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B13A72A0; Tue, 11 Apr 2023 11:02:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MfVT2pkDNpVIsQBBngvkU2jiMUTXVEjOW6eb5TtwUgxjkD2RLxUODW/b9MgyR+a9A4d3qisPQ5zDt4gHgmNAeEjtbUVf+u0i58qi8/sEyFLXGTXkw52pUduZ/FgwVyCw1QWj4++C+kSTuVWAJSTq1JqxygBPFNXpEccfvSQ3WkXqeYJhwmsCp3Ns4FeTTpvMbgRjGXDyATVMhDxsQWhoC36ZaT57ROMllrd4zlwV9dKkRAUz5MuyFPT+0P6t76gkI7x14rCgdIVz80m8vMKJ7nK+yfJLJneoaMKaQK1KBYikXS8PpqYw/a14cIc4I+l/5B89c+fTBU1Iae0DaMx2lg== 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=8ibzyDIzyxK8wkd+gwWQcZvSuqbjizmgAVPXOz8zkv8=; b=Y1pURlKLQrHL8MBn/SGuyc9cdQIfZicLQmJ9Qw51E7ni3HCWAgHqMOUsDIDg8PRYvuzpjtpqBKQNtVlDzuXmCCCXZS09w6JC9+46ow80O+XaM7BicGKD3FQg2Wom1dn4nVvwwUKe4k2AdBZSILo4YTv7jZkM5fmDjuVBsz511dknzFIcJLv/EDv3lLIf15Fri6RaRGCyvBw+4rFG2/5JhCyKeZYvyJ96NuGQhBJElJpj0DVh+2a8zZiva7fhqHPaOjNw8hCapfSi2m5IEEZhPzz+WEburZ72ojJQBxF2V7Yy7ZwooXzuLDXTjkzdxNEp749abdndL9IqeTNHkhEq5Q== 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=8ibzyDIzyxK8wkd+gwWQcZvSuqbjizmgAVPXOz8zkv8=; b=Z5MigyqbUbjeOngZWDIVDZX0iuh3EQ3Mk/SX09R/ch6uG4NsgYmHSbnnL7KPUrbJg6ik6dh5ZXbt99TK59+uKnK5pQAMnGwcuY1grllSQTcth0DuTz1+9xjHu0YfzNGJX1yV3+IjcpgiupIWdBRgzUrY55DX+ERzTAsYVOeI9SM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by AS8PR04MB7829.eurprd04.prod.outlook.com (2603:10a6:20b:2a7::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Tue, 11 Apr 2023 18:02:33 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::55b1:d2dd:4327:912b]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::55b1:d2dd:4327:912b%5]) with mapi id 15.20.6298.028; Tue, 11 Apr 2023 18:02:33 +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 , Ferenc Fejes , Xiaoliang Yang , Roger Quadros , Pranavi Somisetty , Harini Katakam , Giuseppe Cavallaro , Alexandre Torgue , Michael Sit Wei Hong , Mohammad Athari Bin Ismail , Oleksij Rempel , Jacob Keller , linux-kernel@vger.kernel.org, Ferenc Fejes , Simon Horman Subject: [PATCH v5 net-next 8/9] net: enetc: rename "mqprio" to "qopt" Date: Tue, 11 Apr 2023 21:01:56 +0300 Message-Id: <20230411180157.1850527-9-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230411180157.1850527-1-vladimir.oltean@nxp.com> References: <20230411180157.1850527-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR2P281CA0186.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9f::20) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AS8PR04MB7829:EE_ X-MS-Office365-Filtering-Correlation-Id: 592095e7-a8e9-4e14-ba84-08db3ab6ecc6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tQOGhkdIsljEv4n0JuT/+gLpqHIvFxrIVbkk8s5Jrcigz5kODMAd4/doBItwC95Y/dj/EGL0l/g00x789KC7h0gtb/3OspqlQwe9XoDEmHA8q6r55qFOQ0VEZr+ppjCEm0WXRdKzNZGW67RoT4wlLzSgZA16A/IvVbjABrcWI4gWNJarQbTdP76GI70JZjXMrsyfS3GHDvae6oxpoU/JacB188RxbyM5kCIZWeZHIky1FwJWczKCav6oYqMmtAQJ2d3pPtpXYBJp3ZzyQk0zJAaHoFmL5s5MdeNStukcttnWCCUxgeNoiOVfL1A52kc9OCqbDFK3DM8VZTXcNRcZLs67eqwNZWlgh5F56pPktfiyRz3p8P/EcL5nyJ0tPcigrpCJRzykrfXBsHKoacj/t189nDtxyrIzY5GdS+A8RcSih+ySOg125qPL8qEdXkAei53y0dUsat1lvWHMH5LBhFz0V2JWHE4XMhgVbnooeWN5ZNQwlPyiwYGrq9RBriKj2eqteMhRZ755o95upgm0Z8OQVCDUYN85mQAFIuaMvmBV+fDB+XLSFiVmCnbx/+6p6erJJiqgk2W/htV1Zj1/9m67BdtKk/XZEdGEvufm+Xta3rrjWgUV8tJFBmSlGVdx X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(366004)(136003)(346002)(39860400002)(376002)(451199021)(41300700001)(478600001)(86362001)(316002)(54906003)(8676002)(52116002)(6916009)(66946007)(66556008)(4326008)(66476007)(8936002)(6486002)(5660300002)(7416002)(44832011)(2616005)(186003)(36756003)(38100700002)(38350700002)(26005)(6506007)(6512007)(1076003)(83380400001)(2906002)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qA93SM5FvQsAMd5S/6R6nhgjqXxYxNIbmJ4evwURar+O3YONovDE5m8w7ClYPEslWOsczo7tG8DCGGxRHJqG3dpetMRUnFjW69U9xwV45FaLhdEFEmcTyHjRX9KXjBc0P1pQ11xCqJtJA0nrsFPj+4h+LafQ/RoxDmVG2EiOiRjip3lxEvlx8S5t34SIDn6vRdyprrHDABgN+ErbraLoIhChHDuOz7WMl/ShNiYvCjrbPz4QdMEO4aALNjsYkiILhTx9fd8F4vAko8bb9y8xEDlXQ3tq3PP4ikHXmSSD4stPje6T1GorSe+Kex/mWEZlmk/w0WHY/C9m3no5UtKqPiu/so0KDlw3oNn7yHEFgArz+evUorA9CyWho54ptKE2QLVqsNSlK8/t/SiZRgJtCeoBe5gXhH3UvbQMDo5g49bL3iTINhlM1OnWjCZPsH0if4LM+J+N/ii+VMNoJhG177dxCGqD3FXLM5fCge6u3Fp34WaG9eineTi3hDR3+BeIv33WQ1MczTjfXtTrCItvRtTDSFYkWFbj8I5XHBFr5Mmf+TqE/v0OTKfqywi19rZKQB2R00TUljQ+5vPUg8RX2B6CisMEBCdcdHeSfHRJ895OKGU0diJjiu9dDARrzJVGRQb242mBPThKV9Q2mwQ+mWg1PdG/3hF5F9E1mG8zeQlUesxVlpzF762AQi9o8UN8uFBYsX1iwfvUr6/umb8NeAdnM0pNbD2SqS/ksehULsxG3i9HGXb26YPfYpPtPNkCENBVf6r12lbC5Fk74q5BtajR9CQSgyoC/0knC3nnSeR6ugFglA2g1+NUdsIhLRSASuP/kWRP9UAVQgVcj2cc0VwQUs/cuEcRZqqNJ3RZLCtC0rBmQkoa6SNsR/V1lI7hPbB0xNMFOS3LXN1AJtMBZymdkGb68cfd0VPIUl+QSuLjfXpAXurnXgVwG2IeLSoMvxxcytrmaY1RG/RszNo1ONecE43BzkkF3bvqp4OiG4nmQzVuQ1HtpRpXquLbzSsYy8r83m86V5W+YCNR5ZJOpAjl5Z9+scfRfKkIdLWTchehdwNe6aijtzdb2L387XaGuCezhGS6JrUcunZtqUqA78sWPUGDHzSNVCNWK3vPfF8geIQ0s0CofuPu9S67Lm8tb0J9iIQsOp/IUGDcw8wnLmLLtrhzS7gZYuE6/xYGPD8SqLUD94Ap4IRemYJXMlH+YiQsASoljv5eQlKjWDYCsxW13Ng2cl3wCt6KDETXOOMiAl90Y4ZpaiH4P1cKDqQrIvygCUdDvgDAQPpmgNA6trhIB5ybFKRqwCQ5NUJ2Wr1rgF4JJg2M6MqfZilR4e8geCkrRjCnVHjb9eRGU4tYCTYtW3iL0qDJOw6+GkR8izJA/qOJBS+t2Bphcp39Iidurm4L1n3agfS627s95/8QaLwdS7a8fADyKmi8SBV/hMN1tlZVfffuPXw6KdrSlWpzXVLMtAAXTMcBZZ0ynu85moG6eNr7Cv//gxjgKQxgkEDKLyk55deP0mi4qCQjdDjOyIquG5eFE0CWWgr3y3QYSaGyvbBOQFXhyYbEFYk1eSal6Vsp2TGN4+Q5ObUNjsp5T/hL+n5TviGAWMNWLtvd9A== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 592095e7-a8e9-4e14-ba84-08db3ab6ecc6 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 18:02:33.5791 (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: 1py0PjVnpJF5+EvZ9yDGFrTaYsjnZRIO/s6P5l7TNSuDKCk+DMyXB+UlGJZNQhLy/u91Vo3wgMy3hk1g3Ipw4g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7829 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org To gain access to the larger encapsulating structure which has the type tc_mqprio_qopt_offload, rename just the "qopt" field as "qopt". Signed-off-by: Vladimir Oltean Reviewed-by: Ferenc Fejes Reviewed-by: Simon Horman --- v1->v5: none drivers/net/ethernet/freescale/enetc/enetc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index 2fc712b24d12..e0207b01ddd6 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -2644,12 +2644,13 @@ static void enetc_reset_tc_mqprio(struct net_device *ndev) int enetc_setup_tc_mqprio(struct net_device *ndev, void *type_data) { + struct tc_mqprio_qopt_offload *mqprio = type_data; struct enetc_ndev_priv *priv = netdev_priv(ndev); - struct tc_mqprio_qopt *mqprio = type_data; + struct tc_mqprio_qopt *qopt = &mqprio->qopt; struct enetc_hw *hw = &priv->si->hw; int num_stack_tx_queues = 0; - u8 num_tc = mqprio->num_tc; struct enetc_bdr *tx_ring; + u8 num_tc = qopt->num_tc; int offset, count; int err, tc, q; @@ -2663,8 +2664,8 @@ int enetc_setup_tc_mqprio(struct net_device *ndev, void *type_data) return err; for (tc = 0; tc < num_tc; tc++) { - offset = mqprio->offset[tc]; - count = mqprio->count[tc]; + offset = qopt->offset[tc]; + count = qopt->count[tc]; num_stack_tx_queues += count; err = netdev_set_tc_queue(ndev, tc, count, offset); From patchwork Tue Apr 11 18:01:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13208006 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 DD441C76196 for ; Tue, 11 Apr 2023 18:03:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230305AbjDKSDn (ORCPT ); Tue, 11 Apr 2023 14:03:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230142AbjDKSD1 (ORCPT ); Tue, 11 Apr 2023 14:03:27 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2045.outbound.protection.outlook.com [40.107.8.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC8036EA7; Tue, 11 Apr 2023 11:02:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dK77XLcMC827j4A/P6VufF6T0veZTdtxZBC9JBvFa/ydzK05gPMdB4HRXlYMfsWnDJVL4q9ckXI19zURZgFZrgYwsL/I7bqBCkwwSg2jGuyfT75xjSx188dY/le5PjdC2h2H7guJtsBiI9PQqTMS4Zuhu3AaSL7sS+mUYWT4btjp3m4NBfKLIG7OM/y5yjomG/DbR5f9O/xTUJ8QBw1lptTVioIPp8SmKsqN57jtaRIqMwkAmrIwbtYxEcKz7LNGHVcwckpKJyxr64SiBkvgp8qOEzzPq8MkraNTb3STK4qja9eIpTKSlxwieZfpfeAF2KE45mLfJu9hQiQtjWZFwA== 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=0N/dWuSF87eveOxh8QCSo2VOz8UBVReAh/8tIVl5dnA=; b=EAoGlhY1oeuVcCVJpblvaOvH3OnACHysf3nPgLMYj/dIzO3E/yIuaeX67ZuPUBnfKzXMHzz6O7/bLtufgiH9vml74BmBP/t5mAIOwpU9yR09P0bSyH44l2H2yUuAZSFQQeN23+NbommghLqLLipalvwq0eHlwLnoa8JDr5XUUJ5S75JQhfRgZxY0XHwa0l3XJZTGfqhZ3GMMLQuMUWxIMWMo6suerZiTWPuelqbly0/GcTyxXDJgf6WmhginPiaoV3Svlbp4ESyIfqSr5dNAqI0tM6/sXkMPl0eHUE9FTylQ6jtMxEBaH+APhrLkJQbYLCt2u9wKwQvYtKHyExC37w== 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=0N/dWuSF87eveOxh8QCSo2VOz8UBVReAh/8tIVl5dnA=; b=T7PfuwMzsyymwH8cou3Fvo39j7LnTuEvJolMFiDXYAtQlo/2UhRHm4nxKY3p+TdzeKmku3nDWR4sa6aUmaoHuzPNSUTc5rRc0FsgDBjcjZHcxAgtqyNOvdSSl/lkkxTBkLgpDjRQx1Jb1W3Ujaz9Rd2hkDOxnkwoXDxOF33Z8Cg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by AS8PR04MB7829.eurprd04.prod.outlook.com (2603:10a6:20b:2a7::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Tue, 11 Apr 2023 18:02:35 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::55b1:d2dd:4327:912b]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::55b1:d2dd:4327:912b%5]) with mapi id 15.20.6298.028; Tue, 11 Apr 2023 18:02:35 +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 , Ferenc Fejes , Xiaoliang Yang , Roger Quadros , Pranavi Somisetty , Harini Katakam , Giuseppe Cavallaro , Alexandre Torgue , Michael Sit Wei Hong , Mohammad Athari Bin Ismail , Oleksij Rempel , Jacob Keller , linux-kernel@vger.kernel.org, Ferenc Fejes , Simon Horman Subject: [PATCH v5 net-next 9/9] net: enetc: add support for preemptible traffic classes Date: Tue, 11 Apr 2023 21:01:57 +0300 Message-Id: <20230411180157.1850527-10-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230411180157.1850527-1-vladimir.oltean@nxp.com> References: <20230411180157.1850527-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR2P281CA0186.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9f::20) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AS8PR04MB7829:EE_ X-MS-Office365-Filtering-Correlation-Id: cddf9702-73e1-44c4-48c4-08db3ab6edbc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /LhkmNdJazOHt2QThu1MEHDmFXmuU0ndVS3xdcLbsMm0XcWD31C8ELHHZgGOaep2ncw/rOoV5sAcZIMsaVrXObcg2sh6LWAxD4Tt4foo+sZhR1oDTNcv0YsiX1iKpaC1TmV0P8FhTbhAoHb/5t6CtjkhTD34QvRUW0Q3tvrcF7GxjeuEmQRjYTW2/AMir8k1gXISLjKGpbqSCfTeILY3UZ7gNL/pXtoAkX7hymQEuYc8XsOx0iknj0Tcv+bMIBLfuQ6RP33qrd6HUfVPsy3B54cLlcyUXCOXAoBCDlRCqyE3GPW51h1wGjvJd4iwfFLbkaeOnVgsCQAZCM4SeQQXZEeQc1CTMo9fbre/79grb7n3Zg/pD9dvcEvr2H7oOyRGNU/8mKHnD0zEcGOXMnNDi0WRLgcCodWUZPBLWzCnOozEBNf4q+YNPyEq1eJ9XTbHs89PuKb+Ur4Qpp1wwq51LDt8OR7Y2Jg9KCDMuFORC+XGp6cW+TeuWZ3Roztkg+Bv0GpjBSX8JMDrdplWJJdEEw4PSXgNOLUeJQ6gU3oPB81ISL0qEh4ntXluIJC5ZoVoH9ajJrxzokizPPMBegfhAA5lwbJegIEqgGGpHr8AD0sk+GvivADHf/fr4c7ZMcA4 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(366004)(136003)(346002)(39860400002)(376002)(451199021)(41300700001)(478600001)(86362001)(316002)(54906003)(8676002)(52116002)(6916009)(66946007)(66556008)(4326008)(66476007)(8936002)(6486002)(5660300002)(7416002)(44832011)(2616005)(186003)(36756003)(38100700002)(38350700002)(26005)(6506007)(6512007)(1076003)(83380400001)(2906002)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /zU8r+Qsbnt58hT3jTD5gc2TLiEXO1CsvhTNopKBlX8YjQPTSzxzZjM+ezULVYRuOYlgJO7NvyAbNY6U7P3wRvgobV7+k5ts1bpQVfpIneop2JJRX3H5e7CEAVy5MDnWSqnvTcM8s7q8Zs54A5CFGxFNgpVve6OKwkNSU21pCnktnLudDJC4rV/RdnZ0DGHVp+YWVQTVCFvZYo0pNk2SfoVDhgeEmtVO+zT2x81KkdUgtSwCNUaE6BuSAoC1eSWjwq2p7n3GixiAv3Cke22ctnTC2DkRzlvAaFZABd7GJUI2U6it0h8b0WV6PTHPiP5HN1iSobuhs4pvmBfAtZCIDPBvmBeYC5A/vn1gK2vm2a1dYovH85LdFlWbzogI3vbxImfjYJYd+z1uHwgUk4jMzyHuRW/HsutRzfn0TkHh5IS3rs6gdxah645KDvYFXLf5nmHJOqfW07wKFdL4OP+caNy73EWDhir2nq+QBwDyxL1bF/Mzc4SRjjqfzFk20bx1h9E1Ywf/jLBZGKzi+i59Th1iYanKM48sk8q5KAmQdd5MUx1OV1GPtMTjfjUYc5cIIaZUP+q+tTSk7lcQI1xcLGF/AtigGa3OxBGYfGvH/QsUGqDkQm4jVu4pPKpJy52ffYITSXPL7hwJ12e2K21H95sJivakhd66j/wPUe+XxvL2vVz+PxXRnCjezXuKc76jxNdeHcZWBG2XzwytVyNFCQR1QIyAPJrIevmcZT+Ae1ndwoWEC0EbsOdNwjlxk8VhCt7MMU3UfRPjmWZWKImhrDD1/irHQ5czqLe57DQswznktLDqPJRhtJ1garVjvSsijWifdtj9HUQ/xV/4bnXe1zvQCoGjXl3c8m3b4gifUXrp8L36EiN8swXferOnpjTg3FFHgehvssTTYo+OFnECWmssNeM/dcFm1hQDSAQSgbIj0S/z14k5f/QOQRYmoZixUuW7O5jRmRHWKXDFfP2xieDh6jrT/08oi1g1sU5QtSbix3yA7R621PWQrgOcb5KSLmN0qZecEaeDgBMFq7x7IQf3WC1GYiopElkLoV/RDCUMPq7OwvSRLz5ExkBfLqV+s42p6OTC9tHheQyg0kl/ZMTTNCP9fjKgt1WdQmSUtPSY+KbFJSSTqx8fDMWZ5HOCezyDlqxeqhiMu2V462im0NNjQp8bi157qJ4XVsiAMuyjsT+mBOSfIhmZ9wx9In6psY3KYIAqIgUQi29kWuz0Y9OCNZSeWLbHoZyVDkesGQ0TfRjeiJ6uvRyIoiHFORLLJHOkK5E7p4Hm/eYeJkCCcyVuSAZPAT6FdBhF1c2TsTiaSy02/hOp7kecjV68Y1hbBdvKshSaW2fwjK31NONFyZN06HFKZuY/xd9Xm/pS9QyaTkWAr04vvf06wWRQp4zFhgndu97bcerX39drigLVsUFa5AwPdk2IsaL6OGzsx9ozQIchaUAap0D6t4ty35BDW5EGCubeiGfF5NaxSBS+nYgbovtN6VKXf2/dXZ8ca1505QnVGQGDskCcWbeuSmqejiOHcZ6fo25UPjstPEnDdrjS8hpvCAR2m1eKHsnmNJtUeXc35R3r3AjFMGTI8fazHycfdvaHS5JwbtvpA7u/Fw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: cddf9702-73e1-44c4-48c4-08db3ab6edbc X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 18:02:35.1965 (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: MpPvov5XJLAGuyMyG83X3pkQCA46zCtMHCJnbUMDcktVEWpLSV4uugSZDfqSRdruJhZzfyDhjuVjQYLRaXWwZA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7829 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org PFs which support the MAC Merge layer also have a set of 8 registers called "Port traffic class N frame preemption register (PTC0FPR - PTC7FPR)". Through these, a traffic class (group of TX rings of same dequeue priority) can be mapped to the eMAC or to the pMAC. There's nothing particularly spectacular here. We should probably only commit the preemptible TCs to hardware once the MAC Merge layer became active, but unlike Felix, we don't have an IRQ that notifies us of that. We'd have to sleep for up to verifyTime (127 ms) to wait for a resolution coming from the verification state machine; not only from the ndo_setup_tc() code path, but also from enetc_mm_link_state_update(). Since it's relatively complicated and has a relatively small benefit, I'm not doing it. Signed-off-by: Vladimir Oltean Reviewed-by: Ferenc Fejes Reviewed-by: Simon Horman --- v1->v5: none drivers/net/ethernet/freescale/enetc/enetc.c | 22 +++++++++++++++++++ drivers/net/ethernet/freescale/enetc/enetc.h | 1 + .../net/ethernet/freescale/enetc/enetc_hw.h | 4 ++++ 3 files changed, 27 insertions(+) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index e0207b01ddd6..41c194c1672d 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -25,6 +25,24 @@ void enetc_port_mac_wr(struct enetc_si *si, u32 reg, u32 val) } EXPORT_SYMBOL_GPL(enetc_port_mac_wr); +void enetc_set_ptcfpr(struct enetc_hw *hw, unsigned long preemptible_tcs) +{ + u32 val; + int tc; + + for (tc = 0; tc < 8; tc++) { + val = enetc_port_rd(hw, ENETC_PTCFPR(tc)); + + if (preemptible_tcs & BIT(tc)) + val |= ENETC_PTCFPR_FPE; + else + val &= ~ENETC_PTCFPR_FPE; + + enetc_port_wr(hw, ENETC_PTCFPR(tc), val); + } +} +EXPORT_SYMBOL_GPL(enetc_set_ptcfpr); + static int enetc_num_stack_tx_queues(struct enetc_ndev_priv *priv) { int num_tx_rings = priv->num_tx_rings; @@ -2640,6 +2658,8 @@ static void enetc_reset_tc_mqprio(struct net_device *ndev) } enetc_debug_tx_ring_prios(priv); + + enetc_set_ptcfpr(hw, 0); } int enetc_setup_tc_mqprio(struct net_device *ndev, void *type_data) @@ -2694,6 +2714,8 @@ int enetc_setup_tc_mqprio(struct net_device *ndev, void *type_data) enetc_debug_tx_ring_prios(priv); + enetc_set_ptcfpr(hw, mqprio->preemptible_tcs); + return 0; err_reset_tc: diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h index 8010f31cd10d..143078a9ef16 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h @@ -486,6 +486,7 @@ static inline void enetc_cbd_free_data_mem(struct enetc_si *si, int size, void enetc_reset_ptcmsdur(struct enetc_hw *hw); void enetc_set_ptcmsdur(struct enetc_hw *hw, u32 *queue_max_sdu); +void enetc_set_ptcfpr(struct enetc_hw *hw, unsigned long preemptible_tcs); #ifdef CONFIG_FSL_ENETC_QOS int enetc_qos_query_caps(struct net_device *ndev, void *type_data); diff --git a/drivers/net/ethernet/freescale/enetc/enetc_hw.h b/drivers/net/ethernet/freescale/enetc/enetc_hw.h index de2e0ee8cdcb..36bb2d6d5658 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_hw.h +++ b/drivers/net/ethernet/freescale/enetc/enetc_hw.h @@ -965,6 +965,10 @@ static inline u32 enetc_usecs_to_cycles(u32 usecs) return (u32)div_u64(usecs * ENETC_CLK, 1000000ULL); } +/* Port traffic class frame preemption register */ +#define ENETC_PTCFPR(n) (0x1910 + (n) * 4) /* n = [0 ..7] */ +#define ENETC_PTCFPR_FPE BIT(31) + /* port time gating control register */ #define ENETC_PTGCR 0x11a00 #define ENETC_PTGCR_TGE BIT(31)