From patchwork Mon Apr 3 10:34:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13197994 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 704DFC761A6 for ; Mon, 3 Apr 2023 10:35:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232043AbjDCKfG (ORCPT ); Mon, 3 Apr 2023 06:35:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231401AbjDCKfC (ORCPT ); Mon, 3 Apr 2023 06:35:02 -0400 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2064.outbound.protection.outlook.com [40.107.105.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A62230C0; Mon, 3 Apr 2023 03:35:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kkPicQG3Mwn+zelksmPh0rvapsOVgQXuGIshggOzs/O+qpUyuA6ZgqoE8aicyic+uNGmAUMfYHFgCLJmnJnlpcNFrE3xN3HVs0xPVVpd2rw8kqRgJbbY7Jx9yB3KHVq25+kNdpZT/I7T1AYwwj9y9T5VtowM3jxQ3fo56EgtCetL2/OfIzGBAaLrrb7l7MpTSXbBnL+q7z4Xyi2s1I9aWGb2VqZRpRIyv9k51fe3R4xxLgz8ccnS4SNqB/3nL43BZAqUpvXCe3p+ZemF5Gr+5vOJoJxeJomDmwaVWqhMoifTxronRqmS9PqIneS6lMOqq1PnXpKmbNWyQ/sztqZumA== 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=UY/aF5uCNJirWMIsyFHU5hjMEXepo7qEsPXSzwR9Vys=; b=d8yZVmySdflxey90Yq/2ZVVB4zffOTKScdgQIScHtGHy4O+YnPB1iQ4bE9Bs/cwrPk4C0/BhV3d6TTFYJYOl5F5itzNc3Ru0RgyjvmzHSqGIf4c58w6uVRgoNW4uHKd78Hw/1olbpgZfJ3P5aRQLHWT2HiQLuTUVWy0LrED97RWBGF/3Eq/QVTGJZ/I0QzLfPek4Tj1iIOftysLi/ZPEMwGCS3jGmOO+tAK9drfhQ47vULZU1E8Thfz3Y++xoUSgCQ11yXDHALhQwtueNLNPWLvcO5RGNOk2u1nRZgVgoEDU7vitEhXPWxrH9ljpVIBjlRq/uuFVLBca505uaxSljw== 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=UY/aF5uCNJirWMIsyFHU5hjMEXepo7qEsPXSzwR9Vys=; b=ol5iU2XgWqNkgEOBMdFHHl49n+vED/bzcoEBHmU4T1Q326hu+2pGYd92trcGYHeRECPJvm+1kgHPD325AOJvudnY/EPhYqPu0L9upFMB8KwYsjkDb6zmd7VlSw0wISNUwa5e3aD4e5HJGt0v+xT8qEWJ5aG7+Gh3huB/Xdt1ar8= 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 AS4PR04MB9292.eurprd04.prod.outlook.com (2603:10a6:20b:4e7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.29; Mon, 3 Apr 2023 10:34:58 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::dfa2:5d65:fad:a2a5]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::dfa2:5d65:fad:a2a5%3]) with mapi id 15.20.6254.026; Mon, 3 Apr 2023 10:34:58 +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 v4 net-next 1/9] net: ethtool: create and export ethtool_dev_mm_supported() Date: Mon, 3 Apr 2023 13:34:32 +0300 Message-Id: <20230403103440.2895683-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230403103440.2895683-1-vladimir.oltean@nxp.com> References: <20230403103440.2895683-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR0P281CA0221.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:ac::17) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AS4PR04MB9292:EE_ X-MS-Office365-Filtering-Correlation-Id: b1056332-5de2-4e39-f36e-08db342f1274 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RKptN/TXpaVQeWuVRnqW/Rgkwi4NFpseU6ZDKxgxXQbqZthlvtr8nGfCE1/JPKnpyhsXOAUnE7woo3Ye76YWEhnqSaAOH8PA7IWjzVWZMh5eqb+cDzK1QNUdknE2iEhTg4d4cEMjgiLW/BP61a0+RQseK8eUnWKfG6bOY5lAvNFSoA9PXj6BPbO/VSfhcCi3Y1knt5mkIz45+6/YrIt67MbpQylz2PV7xH1IXpNkStWToi2ePrBUByLcVgXjVT+NdmpmT3+WbTzpjjU9yUjwfeHBfEyVR4klpcpYH1L+KMnLbMiF62MDsnjgM5pGwFb4ElrwiabjswEVoCE+ZEXx66mxOCSDH0nxCHlDL6QtUKwJ6vz03bOCGR+eWQLN4lrkEbtQu/iAwEzokTHaowSE27hIw7aJYa8yucHpPDeDKgrFIHBWjyYpeluokrBXfkvShttJdOS+FmYd7x/z8GfPyZ+AENcgUDQUEKwMOXcZChiekR1zKyCo1wwozCHCe6WzFUqIuJqddweyuOosU7mzc9pjytBV4wD7uRdOUNIVtebY6ExOyszG1uCbJLwtdzjwH/ziVawyVLQ31sYtsBbavGa7Fl51gCpua8WeIH+ZhTFYXZ5yUkaRhw1azWY/J3uk 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)(136003)(39860400002)(376002)(346002)(366004)(396003)(451199021)(26005)(1076003)(6506007)(186003)(38350700002)(38100700002)(6512007)(86362001)(316002)(54906003)(41300700001)(7416002)(5660300002)(44832011)(66556008)(66476007)(4326008)(66946007)(8676002)(6916009)(478600001)(52116002)(8936002)(6666004)(6486002)(36756003)(2616005)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: oVuhACjhAENuuOC/7phPgONv/X4B4qFMdIxiRUi3RcJ2WVGtwe2787NffkgO9CLxOhNGkMuOiDyX8WWqbRFsbRc6Jl1X2Nlz6uZUXfLvtyxOrCZKFpWVq66QkkopAYN/fXnpTS0A8tjGr/0whuJzfuPfAuyubaZZq9uPunJrbdETqUWcGpUhvhOjy/8LrIOHlLS2mFhBMWBDi8ON5Ua+5ES1gbY6V/vO0p4kM5sj8OUqKSASSxgn5NrqcmlaTOvV9aaevS9xNP7S/8uOx9THhXBw5F3lEoC4L+CFP3rb6Hk1/4q6Vaw8vRrNdlTUPPt0bmHYv9A8XATeaorH5bORJAEO98VIehJM96BQkTEXZCdESkKw7rrrTSukVl5xIzHahYA9nV1jmuF1ErQ60L+Fz/DuzKyTwgjH5iZxC6M7f2K4U1zjvo0BTm6bvPZuUwjlwPKRFQGL92kfSbFjLMJw1KgG+tXtID8qirbC+5sRyM3TCWLQgJuPi1BKBErxDEX95YejzmSXLduztkP/JWVT9kU5lNABDlmQacdzTwc8ejaEym7eO061SUeMLibH2VioPy8z6yaYjuGGNW2FHPhVHQXChC7QSvfmpOc0qwuF/xEHqyYw7lvyMkVscpZu7HgcK0X66ElvPABXujskLJ00GFESVyAhIeDl2wZWyZBpwa5LPHUhg2ACOETg1PbfPz3cbh0mecl89Fig2rNpQ2daWBo7mrngOaum/ruup3CFJXgpPGidR0KDyrlaDl0WWNCTJb9jpFNnkB1Mihp0Mkp2++jxWETNd9kbO5rDpZKhiRQJNTAtK+0qD1kt4S+UrGpculXQTefIGr54mhtsaTqBACDSRdfGM9k7cjvjt1cQXxohA/+al8HOP6u2vdZomUBtbiiWYWutKLyRdKHR6lCR4GozX5QajSBi4TmEcaI39iFCO9WF7L1vp92o34VC9cDBuatP9VApxPt35EUQXpW6EfV7Ry6VuiXJUacI9WxLIA8fcJcbqGi/lltYQxS4tg4we/i+Og0myI5lYRuCnom+SKSivCQq6vmcNjGRrJzzDuBz8TU9QKV0jVUxyRZXIYzGIs673rrG5xObIhwn7flyiUcioUk35XX76d6bc4MlwShh6vkSF5Ry5DkNvVHNs2vUIrkGl5StYaHazOcwwsXr8f28vcr40OT80YEtxzXYFtFWg0R618CT3Nkxk2ZUUDeO258tSpdZ7D3zInIU3q8p34Rafh/DrTDmmNzg3/gjBGnhv66hW0XBx6F8Qpe2lIGVr012WPI71cLWEbz0wIdAbPTe0ssilIRZjJC6VzzBwf1PIkmSaS7Y0N2RNaO+8wCbUzmDEL/pa6V2Y6DL9Mtl+T/4hbPE3y4lPnFSqI9UNQ6CqGlVOhbJA3Nx5EPNfZ+IZ/YuWSA0eNNi1wG6WKIzjHckuNi4OJVEUMmO7AMkQN79wXjYyAi+tMkgA2Cgz+p8FkoLrAFn/BGjUT0GdFipYQUcFgAwLM9fWYE2NkcfpWUM/AQlnMUcdHJqTpFTmfQ1mwblO+CbbZdwcWvrkbQN1PRc9GXmRjHVeciGdq5gc7bqLgX6UL4oP/A0k57AmC2pk9k/usG34SITORWW3Zsbxw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b1056332-5de2-4e39-f36e-08db342f1274 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2023 10:34:58.2977 (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: 5dWNy+QN/yNZXRoHgIRoEtgbcqmGffwDyiuoOBu7Ob9WLEj9lgbuWvxJ75ULZJAqZsbBQwpIaIYE82ANcyhJdA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR04MB9292 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 --- v3->v4: none v2->v3: 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 Mon Apr 3 10:34:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13197995 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 84DE9C77B60 for ; Mon, 3 Apr 2023 10:35:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232206AbjDCKfK (ORCPT ); Mon, 3 Apr 2023 06:35:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231448AbjDCKfD (ORCPT ); Mon, 3 Apr 2023 06:35:03 -0400 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2064.outbound.protection.outlook.com [40.107.105.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1963F2D51; Mon, 3 Apr 2023 03:35:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d1dCZOu9J1FOVcwu4gcigmtVNTc3+mefEZayuSTsUCJFZuGOBhWGNyQpNOV967CeSjw7HNJkOdIdxTa1AYll1yY5Ft9NC5ZqZBZZOpAX6baau3g9xMClbn3auSfmNZwrcf+SMkRAxH0mCZfmmin1wASMRZ0dTdY+ivdCpKk+zLwyl6C8LZIjW62DGVvmx468jki7M04eF6DozxRiooQDzE4BmlWrZvTv+/TwRPRClpvahRDWTZPURZyf9Uos0Ovhwd5ig5LQJlxEENIzApbx7ysMYnz7ePWahAC5iVLfR3u0s1kaasMyVleeMKfJ2VufncYw2j1+OwFsuL8C/4Q0cQ== 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=dHR+Em53mXNFOhp8OKYBi4y9+SSYpR64IKXLzh5xz/s=; b=nfS/+31GrpZlL09WXFrQ4pRuCgQ9Z+D+WjorO9yqCM/RRdGi70Qskea0obKDq/t2Nq8fg3ZGEMmBmtIkEku6Ifl1sFAq6ZIwV2fjTdtPBYAuMU4ZALFEiZ5qwfPSjH5i4QHx3E7xtKYSiYSOsgbAbQhVoQElt/V6fOlrLkqKZ83SIzlgWQGW4NbnV+PZEflMQBWy+M0kn0ztQ6/h1kIhZfQ6sxXuYczs3592N+qMetuXTLbJ7oY9JRNB5RGTUpP5OmGyXAjVMrTqJCXU3+f0jXbgRElJt3y3jvRiibn0nBkWjavQQFbLjN7HJDMLlAL/Qpof/m64AHIw/VfXvOOWJg== 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=dHR+Em53mXNFOhp8OKYBi4y9+SSYpR64IKXLzh5xz/s=; b=Mcs70Uyp+HY8Fg0SZxLNAGBvoCbmQgDhOI1NdhPHmT3tY4UJv1RDbExD2oNpUK3GtCpnR3CR/oOkRXWcO6gQ3xHNmAsKDSJ1BFhVHP0P6LtVztYU6vVlmdvIG/+DotGyr6rFoScShf/6E6WTvP1QLgKB06GiZXxG5zMpJ/7mJbc= 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 AS4PR04MB9292.eurprd04.prod.outlook.com (2603:10a6:20b:4e7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.29; Mon, 3 Apr 2023 10:35:00 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::dfa2:5d65:fad:a2a5]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::dfa2:5d65:fad:a2a5%3]) with mapi id 15.20.6254.026; Mon, 3 Apr 2023 10:35:00 +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 v4 net-next 2/9] net/sched: mqprio: simplify handling of nlattr portion of TCA_OPTIONS Date: Mon, 3 Apr 2023 13:34:33 +0300 Message-Id: <20230403103440.2895683-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230403103440.2895683-1-vladimir.oltean@nxp.com> References: <20230403103440.2895683-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR0P281CA0221.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:ac::17) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AS4PR04MB9292:EE_ X-MS-Office365-Filtering-Correlation-Id: 62ac9251-de2d-402e-d08a-08db342f1378 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: m6QxJh1n3B3CpQGNEyUCFtvSsRBs5ID1IsOg1n8t354F375VAgUvN4/KlpS1NofcgHGLMprQfOp4Gqa4M24Db+bCrOs5YNi8ms5lIsGzd2Yjy6jrC5CE3xdCVqT2j227D0OHCFe/6vJKAyFM1ELvMrsn2tIe0Y/N8ngO/uO3VjCZKAl4IDP42g6t+TONq94mwvh52JDGoDIFdW11vDJY2VJZYbkRatD842yT5M7RNelu29EBtt9Oexz7TYRoNZ7Je2C8RP3tYEq+1cNMHkUkiijJxa1P3gxj6rczJs871BstLWFLOwXh58oqNulEPZbrWE3qzAK56mQ4J4rx71sncLJjQhR5yDE6mm44rbghCrjIWZxZw8EXP9T20ggHky3nI+R/5DwMkHPsdehenxRdO021egvoZGlbMVEN1iOOX92dMFqfyJi1ipcwZdhyCLMtQQWq1ESyg723pj6ShyyIauYpCbJ2BEaVeNyoftSyeOz6isrXeBPgw0Ww92nMj5s2qPjP0vaiJbkLMUJreWa7kKJgGDmpVZ4jsYPuXuYKZd/umDfc2iU/9d5lNiCOlFa0lIcXto69Ce+qfmTzP7VGFSCcMcKdBSYfFAWLwOlq/wWN/9WchD5KkfncnnlHLLcB 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)(136003)(39860400002)(376002)(346002)(366004)(396003)(451199021)(26005)(1076003)(6506007)(186003)(38350700002)(38100700002)(6512007)(86362001)(316002)(54906003)(41300700001)(7416002)(5660300002)(44832011)(66556008)(66476007)(4326008)(66946007)(8676002)(6916009)(478600001)(52116002)(8936002)(6666004)(6486002)(36756003)(2616005)(2906002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: X/a8CJ2aIYr1uk9HYZ4wqe9lJvcfhRaD0m3srcmJ0UOnxZra3oLqOpAAkpn+lwQ5gaSyeR15C0/YSi6UnPhBB38ly7QoVsEQ3GmjZ+KXQytH0OwwnGblThR0m1XcyCwKYCrJ9EK01NV3hQZHlzs1b+mVJ1TLSDkEjRb4JzyFybgammPtJRSnirN/EUzkVAdi4An3J4xSuX4J893ezSu3sZHTv2emSCfg3h5ktAc/1mzdFKBuMsEfC7sL3o5nPSfgbHA+hs9/Fp9HgH/9Ks34fRj0EmV4h+tzYL97BUHbUwysV2UckdRztFBx25hxXCcrN6y6k2WtE9B0B/1IMdBFzSzyjoBkvMYbxqVWNUshAJKShz9Rmr58GKghaVo1YPBc8AU8bv890UZpJqahZwHvpFYQt2dsjmNboNY2jVLCV5F2sWH2YOEjcVQu9kt4AqR2hqEAWYwV/Ri0X04WaSoUdp9yn3dIXPjz43dt7b4pFtwX+ZBlc8C4jyN0mzWNichvrYJQzrQZvyPR6XiIh/mg3oGg/ZXVqbTmvK2QYOCTdR6IqZv5dWlW7forhQdCH7IYAxss9rrgIqdq7LhjUDoM5jEUuVLJrt8OmG6nqwlFc0+c4tYfAg81TJgEawdknvGAgb+LUTwK/CuHbMlUnq3C1algSZHbzusTHrDvNW/3Luw2JW4qmD9KpTQKirzZPpcNvLLasqTiQC+8a2NnQ9BjQBA5fqZ6lSDU7VoPG1MVzuBj1jn3YvPtCP6/rvuuDX4r4pnMsYw5PDLDaPSk2+t7Fxm3C0Ots/vQ5izeSCn7gcOAJamkXbFGlyfSZgXL8UAhpxGOQJ9aA0RWoN/WZHwY4cGJbNemm9ZrOsQWT+4QQRWlMVNFZ672PluwlNni5LVEy7SQjeRzK3FWmevuTJcHb5AeVX/mf/DUsAL132ga5esfvm0DWeyox/4h+yZRkrggKoNvDhH1ZJgVMrSfdI9SPI2cugdK3LVpdjCbnjPcfHBVT39WKldf3eUbO+Uv4qUhTyMp6lxHkUZxnNvy6Cq5Ps1rVfFniWbF0SHdXpK2wuKRTY80A9g8lXSLEoVjMikqvMvngZK5ilRuZ5vK0+2Kje5Av+MJUT9qvnvZwsfWsdL7TCBMkOaEzQkzDkUll7kyV3OWwFQyUsdzCNwJd+WVJNltGc36Wd9Ioy6OHqw7jpGOrH5SuZygmmpxflMCDn5MIZVcdep5NRjcfnQRhRIglaYK0csrq8EjCHtb/pvNGQuAiBxPauF7DTqxY5u5EgDnftTDVpO0N2DzURXq37hvDtFnJdJT58+FB77M+eVzNbjwgVAD8cuMEJdbQnZggLo6m9f9oMCqTe9gNQTAF/MPpKfNbMlcqvZ2jruaBotKkFWirUHtFbfmr6qNp3m/1lCy0XuiPclqhk5c8z6/qF7SFtIJKaF1JoLg6c5XtBf+cL9DYQPLE2vdOp7KGPq+kKyn7Tmjz0Svo5eldwvimFfHYFQ8GpQbdGWvZhQDDu0ie+01xmbZpOvaymMVqDvqRnZ4ocX0LWSuTgEFC10TTBWbqJifjSgRh8ATwS0f//MYIZDLSZm7vqelY7kix96+KI+N85zXw2+aGfJ6VR/iBjGr0A== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 62ac9251-de2d-402e-d08a-08db342f1378 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2023 10:35:00.0723 (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: BKO+++QoEc2rnRXLpWL+F645q/2o5ESE5cjMe0cKqt8lEOR+jJN5a91f6IYci78GBfT7pigpc3FcdSwct0dD0A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR04MB9292 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->v4: 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 48ed87b91086..94093971da5e 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 Mon Apr 3 10:34:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13197996 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 1D746C761A6 for ; Mon, 3 Apr 2023 10:35:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231741AbjDCKfN (ORCPT ); Mon, 3 Apr 2023 06:35:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231899AbjDCKfE (ORCPT ); Mon, 3 Apr 2023 06:35:04 -0400 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2064.outbound.protection.outlook.com [40.107.105.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40F7030C0; Mon, 3 Apr 2023 03:35:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Yf/2dyxkOyn/S+4cG3C87CRMFoPG7Gw8SX/q7javzp6nJ3qMjFiRqQavnbHIIB90gk+XoV06q81zRI6jH/h6ckl+wYzI7gFGfYBweqfZbnc+ccLwsg4qwUZBi5gL4Y7VO7bKkw/TeC2Aq6WKKPrUVs3zFSC57BvMEx2TEiyRiMl4ydiLIv6Hzl4unMk/wLe+BCiD0e+EN1DGLqhLVQTD/AQPQbWrMOnei6tHkzepMxq5lw+tB9HTeuZGOOublSGHwGcKb/vhrHqdNEiUYB44uKHRU0bwiAT41Iajn8JauoyXnX1bbXjqYrZjw16cLBexH/pTIn2GE9mUzEd1HgoTHA== 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=pvzSie3aWoYHN/vBqu+xf4Et325hToTaMuTZofsfdvk=; b=Sz92Om1D0C43meAbsLctHrtzUhThL/hN9muBRwS+gdGQID1rmUUv6fC49tlCoOmh3ZwAMFzZgO1Pn6KI74uk5zaTmI2mdlYFkGh0GN3kD0cjpX5btWRDyIaiDuVMYNfnsWXc93YpY9V2epcpxAlTo3ivaXe/eKCcN0jMXr9Egwb5rEGGAPKFUEv18hBK4EkGRe/AQTLW61i2eioCAjKWE4r11Ae3AyKXHN7yMYmPbTunltG9OB2WHzwPd7jZ6fE0sMjgJ7pOJe2sKJqnc+yUe4nNejQGT8gcFE8dJiFEBopWTqc8u4HrSNyaPuWwmT+1rLQl0RclZ+l4iJShe2/saA== 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=pvzSie3aWoYHN/vBqu+xf4Et325hToTaMuTZofsfdvk=; b=Eil0GJ+R9fBly/QxFJpzn5RZ2DrrPtfqHoNKl2RIlwcUvuNlDYv4Q4cXx1e7X+HSJcwCitJUyNPc1LosL2dxM86A1VaAOsBiF9rszzn4JyuqE0fg7TQtNLr+0d0q1JoVGZdWJaNzJfBxQ7GL7pdbd++XlQQzJrnYHISVPwsHYuM= 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 AS4PR04MB9292.eurprd04.prod.outlook.com (2603:10a6:20b:4e7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.29; Mon, 3 Apr 2023 10:35:01 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::dfa2:5d65:fad:a2a5]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::dfa2:5d65:fad:a2a5%3]) with mapi id 15.20.6254.026; Mon, 3 Apr 2023 10:35:01 +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 v4 net-next 3/9] net/sched: mqprio: add extack to mqprio_parse_nlattr() Date: Mon, 3 Apr 2023 13:34:34 +0300 Message-Id: <20230403103440.2895683-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230403103440.2895683-1-vladimir.oltean@nxp.com> References: <20230403103440.2895683-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR0P281CA0221.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:ac::17) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AS4PR04MB9292:EE_ X-MS-Office365-Filtering-Correlation-Id: 94a5e21a-1a9c-45f9-5de8-08db342f148d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4aEywu5ol0sOeD/ew5WZyJ0Y/9DSfsDB31++3NGGK6xgE/3bF0uOs8dfgcvHjsD08o0Y3ZO+lBTRG9ZxytebVKGiuvb6qQ3Q9EJd0h4iYz9OPQcmivnl0F9x1Gy7ukjVpG8oFFeHBd1TGKC8kUQnpDRBDqcqPU2Jq2pJ9749TQiilYEjqyLgFHxVBrR7HK7pbc+bDJBZDkahs3sF5+ghbUXCxcQk96HtjLrCKIXRBszfNYFNMcl69A04RP3sf62UMVnp6j0tnMw5S0J+cgvsqKHUU5UPCNYH3+QIJ7JOJvW0nCcAa0iBbrpf59OEKwdJUL/mj13+yKGPnqFkfNwikdfs39kd5KzZGw60zOoebh88q1fUPd3Kh+xTc7ApeKCBTbydput9yrRGElwYX9fBH80Keynr/ncCrgv6lJ1Vbhsj3ydhSdnQUg/W86xB9pB2y/5QyDdgr7mFwVznpC3rmiGulXyrtU0v5N9fKktROee5tKAH+NxECtbTZ0DMGI3tRCM4aHofXVhwj8j/C4ILjFtRsUZMcTbTmEWP6m9HqEQX/pTURdavAH6rV8ipyPm/mLmHMpMt3hciyxMoe3Dj2i8Jw0bIrKWwy1EC40jjy5zP9IC1iz9YCDrlmLHzMRL8 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)(136003)(39860400002)(376002)(346002)(366004)(396003)(451199021)(26005)(1076003)(6506007)(186003)(38350700002)(38100700002)(6512007)(86362001)(316002)(54906003)(41300700001)(7416002)(5660300002)(44832011)(66556008)(66476007)(4326008)(66946007)(8676002)(6916009)(478600001)(52116002)(8936002)(6666004)(6486002)(36756003)(2616005)(2906002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IyQDSRtLsb/0IIj7tOKIF6EC/yG87gNVH5XVXtVXF+He9ZY16v5gZOCC9VbeJzPzyWCDLbJEs9hjOmyOMq1MQGrut+BHvCjeKHmVbZbhuo6YmnOSfEeu+53vFFCDTQcHh9OdmAunk22ftzRM2X8p1lsH9TG2CNri91NgYhzfry6iOUpGFSiTJIOG52ftrlrPveTfwCAg06ZskDyUvB4fmFnJMz8lqpTJWMc+dHL75YGn5dYiuYeXImnF8o0sQNYiyuTIZdVEBl9xWeuh+aRfJmfno68549Aibn5Wx2FJ0HtdKCWlvTR154z1dw0UhHFlO78icPPJCq+tbRGUnZplZ2MJcOnFUyJmAPPP0Yu5aoHyJN4jKhKyDIgPGVmdaiyAtZRAkRIKlf9qLoeEPqWTZnYwpNKBPlE7M2U1g78UCpVZJLxql9WnN8//+bKWXAzeNo5H+WUrFZ2GtW86vut7f97wAsGOsBSZtjEpjB3/zeAtHmWdXztYBmT7GaXO90Y7DwEYWgwvS8ThftV1LWC3e2u3Zf3TnsGJCFMpFpxJaG1T3SpQUd1RXpzNNAZJFDwdtJgxIcxr0lKaT/jZno6BAj/PdeIYODndmDJHfGXt7lpDk3+sM0XIpp2jp7GNg4BKn6L0rU7hjOYDz61t7gzFgcLnqVPBfa7AE34nq+SuyxY7wuwKKE2n+CpRs9XJKX+RaDlk1HGjdE/XQ0zkrTTo9iqJ2roUQ3FJDvlcV3o0pvVvE68MRqXN6RK9rDwfYEJyn9A1ludDa/yNidp7oGnriw4OHInNrT8PG0XmXJujtc1CAFPno/jed/d+NqyKx5brFpswCiyCxRegcmPQb6/XQiF0oqIqPHu0t4MAuTqg47obzMRAoyOxhTcJz3rHgZXlph012aMLjwRJUA9hvVdIDs5tS28PQEClE+WAI/wC6MVuLeaMggoIHHfO22X1/kO50FPfmv/z/OjMPIpLOBpbYxw6G21er97w9nxLFuRH+o1xMBEPOiu5nlrEXlkDWoYDTlayZPpqX/MeLN1qS/fcKhChIbsnVtFJyD4ZZueR0KfmofyD7vNT9VYRWgdQj2cifkZCC4c4kpRDTSBpdRZ7/0PSAV7/NcDhEzKnhFH4lqfS6UnQScngYqkF+exmDOJJSOWEFftMGc673b/+3TPCFZOIJ4BvYs6cuAcoYlTqL3ifE60mA7UH6xCQ03nO/NNg+xjL7VDZpuBHILuUuFJv4tLlzDkgGqmQZlycL0va9ZddAvQfEHqtok2J/gr3DyfTYDOnzc2zIVgZ1GLaZL4hEX6ux4UQeiTH33mgc0U9vh8n5y/5pUdemsZZGml8FzQKUiFhdb1qJimty0AZHRvuBVoxv8w2QwCYa+H5jOvz9Z32VJLzSoGKn4/t8YtV6me3WX6askeP8A3jfe7sJ7c54NP2fdK/ksD8uguXae5av/ZBLV5lD6JbJuDPkVaaw1cARAV61ScGOFaHt4Q8yR2uPg1IYi0q6o17ET7QKcsa6XwBNaG7VEWFdJEKYYozkb2PakNzq4NcCkbEabP+HMsYWB+t5hLsmQBMTrjlgUEabm3e1Tu3BcafwMy9NDKD8Uh2VYa2gU/Hf7f6sD0LNRJgoQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 94a5e21a-1a9c-45f9-5de8-08db342f148d X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2023 10:35:01.8507 (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: 2TB4azNzzguMTLWmZY322CTnzHWk1kwtcsE767PXfe0lcL2Mx3PtnioNV6132oOweJvA7+obB7Q3TNrSbA1TJA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR04MB9292 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->v4: 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 94093971da5e..5a9261c38b95 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] = *(u64 *)nla_data(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] = *(u64 *)nla_data(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 Mon Apr 3 10:34:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13197997 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 0DEC1C761A6 for ; Mon, 3 Apr 2023 10:35:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232047AbjDCKfW (ORCPT ); Mon, 3 Apr 2023 06:35:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231982AbjDCKfF (ORCPT ); Mon, 3 Apr 2023 06:35:05 -0400 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2064.outbound.protection.outlook.com [40.107.105.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C7592D51; Mon, 3 Apr 2023 03:35:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OJFTDs9tau6BpIMWJjzxpvEAnc5WsfDUzmOC3dhXnSB1aX72xxKyMdRgoKz5NF5ALYWjzBvrqTWeipKkxbc5hNdQ45xnXtmZI6OpVmV5iGazsm6AL68AVLJ3xtJ6xj8L83bw9iyx4oCENNJiO9UdWAON504GuR/hJBvMC9GKgI00fyMiPIV55Zr+1jDdfkYEzjFBdeH1i3Sfu17LafIWNCWuJOp5McO5Tq9F6scKEQu0/GR7+8iIrWKwB0EfGucdOApwW4Zn+Ff/BRLi0tyMcewE+GvvNPbPUeJo7otxT1YG/4mmLAy3kw+viyR5RjHI/SlwJWhoHbfzjullGA6eCw== 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=ORaf51nFqoVISRd7cxFxH7jxD3Jlon0OGjdhoeIF108=; b=QAEi/I9li/11fs1/pSuF7FqCyHpr4iPk1y5ltKSnWFYP5BS87uoZMvT1qOJ0N9PLbqIkNekLc6ZINtL5ZIGiVgzyJQkJhkgbXnOhDZn5YhE55MPj//K/1HaK05NYTNG1Y6LTAMnfvf9Wj4764VEWiV1tcJxoERVdGySXzg33eZxW3IMonz0Zk34y7Sspw+G7LkG8+3y17mU9Tjl/Sr889TRcV70L4wXEqUCMboq9aTLaBHSjYukPXOl8iXv+6dyAORurtukraEG27rwD8xBrj4BhCqpbBc+2IxDRRBpw/p5k2YVwmDEMHkckFFa/bgW/k/EXNBJHggcQ60XXnjZsBA== 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=ORaf51nFqoVISRd7cxFxH7jxD3Jlon0OGjdhoeIF108=; b=YbWzmJaSDNo8zZU75RU74q6JK7xQ0vmCFW9QT2V9hGhrPTugbnRZzhMtNcQRtidBz4Q08RaLzD7wK2sFz/CWtID7u5HDeAg2QdnRhve/Phsu3FV1sPH/MIUqfW+qFJe/65daUvVgVkqsINb/GCgDwxitW3t9wuWOXkIDVt4r+v4= 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 AS4PR04MB9292.eurprd04.prod.outlook.com (2603:10a6:20b:4e7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.29; Mon, 3 Apr 2023 10:35:03 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::dfa2:5d65:fad:a2a5]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::dfa2:5d65:fad:a2a5%3]) with mapi id 15.20.6254.026; Mon, 3 Apr 2023 10:35:03 +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 v4 net-next 4/9] net/sched: mqprio: add an extack message to mqprio_parse_opt() Date: Mon, 3 Apr 2023 13:34:35 +0300 Message-Id: <20230403103440.2895683-5-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230403103440.2895683-1-vladimir.oltean@nxp.com> References: <20230403103440.2895683-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR0P281CA0221.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:ac::17) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AS4PR04MB9292:EE_ X-MS-Office365-Filtering-Correlation-Id: 81c3043e-7ef5-43f2-9d53-08db342f1593 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +z1/5MlVXRUyqNhbKe+RJcrJti/9sGdbUWJAN6yvs8BibePxZoHhxfbTOj8hny+OeHLGtQu0sLcP9AMiGR0eTSXAZRsg4tGqrarwW5+e8/Rsn1OLYAI87KgF4IIY37O9Lr+ZLDEbueoxx8djh/bhfRwsql9Vo9oNFWF7LV4tu2j41u1a6Z/a1ewAsRX92Nlzx8F+2oGNw/H24bKZS4yaJM/TMdC1Q//2TtBUcku3UnFFPv+C3rXQ8HWFvbl6GKX0UPvtcuyca9i0/KC90Dui/brDf8Kiac2Uvo9Wlrn4UtAdK+uD8DXqBsfHZQpfhydfhw38gyJsRIOVpLi1iAG1bOYQygMBPI8wdWwCgwlbVf+JtBPS9qjRah52ZPqaTz2PUt2omq3p7kdzcx9Gxk/kPRBCEeJsd5PuABHIvIkEFBqkrecueMQeUzpB1auxO7plSCps11Agn87wSJnLWTw+SG81d8MtSL28lH1YL7RYb0wF91DPEKj+qq4kf8ybfAhvGlCfuc+2dTN21S3+PS9dvee4hx4rMgakyXU26QXOxPAlmjFLMhu/1AP50ptLbSnLiGGoYkNhiheDLjZM/3T/07afBGiNzUIWKQRu/vIyigc= 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)(136003)(39860400002)(376002)(346002)(366004)(396003)(451199021)(26005)(1076003)(6506007)(186003)(38350700002)(38100700002)(6512007)(86362001)(316002)(54906003)(41300700001)(7416002)(15650500001)(5660300002)(44832011)(66556008)(66476007)(4326008)(66946007)(8676002)(6916009)(478600001)(52116002)(8936002)(6666004)(6486002)(966005)(36756003)(2616005)(2906002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MgXxGoMi8ysKlXVzZhPCyet86orWGScvxfeAb1mVVy6q62G6OwIUrhSC1/sSACbxZxMoiXmGTHLI/qWLkZEwUjPOhp2gQRHBYq6xYjBc++q34/xETTPZBHoLfo43l32ZpGO0lWT4yLFzlepFoOCxmoEubcYTU4a/V39v+lXeRaBIuWxYdp+ieRTg0cLvCPrQzeziZMNRNFa/zG1c/Jeec44b+PybbAjfbEXq5D1rAPamdJcVML4Y2U2YhFRt1FD8K7RVmfiJs22UItCr+ElkJMXfFoKkf5PMOoj3u26+89jdD3sDy9GeTdztKcDJeZxYhVWsyiRFYfhp5HbkkSkp3W1CFQd2Izhm8vHcS4Y1tR2OGDjR7UJFP9VGsmI1fq5LZwxWRzqdY6/VtUI+Nbg6e+r122NkaFse5xTZxrXzivA891+xzxWuF5EokdQqghzs1ajHfyNtfWowTc/ZrJqPFkhbJjHq5HYwZYNFNPzJj9ZVKoXSJtVIEjB5OtI3cLqi1v9I2eY+FzJ1lP0N9REboZsM54Hf9wW3KU0YHCdTL1HrSOnK76TFiA1oiIfGfVyxJjVKc2q6rUVwYqOYuZbcPRPu2KuDYSU8C4DWQyJBOEuq6QkO5yD3obWXOyqObZjua9cHMBFVcJwsK8aEwz/obpCYXuc8g/dXzA0lq8HoaEgvN2FeV/HlovVNX1EZJVp4L3eTxL3DqPXYo5QUpdW6bjxtEHDV7m3sNa9InbPAWGC3TCkcd7yo2sxXaTKx9vLapX/1Bqi05GyZZ3DkX3bN8Pu22dTqjvUVVUl+aQY1dvIS3EFeYrt3t141j1x4opllMgtub+ppc8U3ClOCPk9ftBXI6TLA/M2aWb+INLLiNhOZmpR9ffIwodEmkYUi23IerjOLH413X/UTjmh+U18hYr2EUfwvQDch6ndzPJaDUmn/grPh3HCfFZdB1LTZDsGfPOsEptNZqPWWtBolXi24/3Oz0JYP9RCq3pWu39miaI039+zGCAbv7ZJyqGYmCEz2BdeRjHDWK5tWoECqtivrzj2HdpH0H2n2UUz4jX39NDopRsrGCFQYqDdM1HAXXeXYoCmLkEwBtXdxvxmdG7d/ZNWmU3Vu3B0BtfXaUwCp2M4+Bi+p42Bg5/Cdg3jtokA7tGPYCItuU7KKadB8VU9sKLqcR6QrgS+JTULfww58nwJdD0ypJIOh5P3sZuzkdm7ghg30byaWaWwy6wbn4tI9hxp0r0oZjAylHZLlyBIISa+xgUkGBRhljOeJAdcVGu9ZkvTY2Qidmyrp1eTahvuW8AwxjZlJlXip4D6Rqzo5TvOd/a0NqEXfJ+utDcv05quibundjSOtGauKuIMarhbFX8oeNQhmbtS6OnK6DCcMRV/8UPYKnJSCjnSAIiROT0SBSojQ2uUwsqShjW4z+niKIoampGDPYfS0MBNvOia3wQWW7f4K+ntap376Daw0WqF61gMezTzVkf5BTFCAcw0Cl9b9f2r/BXd0yHdeFeIjGW2P1VWxiT1J+JdVfx6Zk7qy2mLLkrZsHczFlDt7K17HTN+FH8dH9tHs5+EhUSUX+hcoXz1xbnElE8afbTRGabRp2Ld4BdFQULKR9ko0MnxCgw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 81c3043e-7ef5-43f2-9d53-08db342f1593 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2023 10:35:03.5143 (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: 0FjQiy/sXGScOiMERLxL6KpAbA22CJ+psrSAYlLyj3YtqVCowkLOzRlDbSsx9h371wCsef6UZfuiNU+ka/5D9Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR04MB9292 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->v4: 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 5a9261c38b95..9ee5a9a9b9e9 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 Mon Apr 3 10:34:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13197998 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 E8FA3C76196 for ; Mon, 3 Apr 2023 10:35:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232364AbjDCKfy (ORCPT ); Mon, 3 Apr 2023 06:35:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232292AbjDCKfs (ORCPT ); Mon, 3 Apr 2023 06:35:48 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2086.outbound.protection.outlook.com [40.107.22.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02D0530F5; Mon, 3 Apr 2023 03:35:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jzM211MyUEIJSAGY6WIBrUIBbee1nd+/7x0zjghrURXh9rbB9x5j43wYi//Ua1Yo6mkYt04nYSbjEt7EsOuUHsAalWzJNyKcyaQz6oqq0vYFOUYdU8Slnr5SMZV7cafZg1h2iPb1fPmd5mFgI+Il7XUX4ng3YHNvsEdJwuo8XJ+T0Tq1lzCDr7nZiL+oSIpiV3AWxiXteQL7DIkDVY59Nxu++nTYawiNrO77SQ/VoFNJQjR6miH54qpAR1USEyQJcXeKDerCAImcb0RMBve2zB9A9Xi0OiWvJNgpB9FeoFL7taabb91NI7yvV+1u5mSDFgBICgcqGS0XM4a421RUNw== 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=sNfbPUlIN6M3l2O1riS4BqLVSlYkxDQlrmGoDDa57Mk=; b=R5/P6q08Dj0W/JEHUi4FvJIr0wff35vNhVZPUNZTza37fbwu+i0qKe0moijLfA2PvY+bFgwOepjKQsXAWVfpJ1i1RN4I3+5x66RpzCrojYCU78hMQpmvNq53Yt7qS8wWSzZDHUGxmT7GPkW/CGkJv5vOXVi4sa4FYnCLMEjaV6bzZMCazTkRPwB5/ymv6n4qvUkQO+/hmRylJ0ycWIrE6YbArGzQNGycQUAt1c9bYtvKL6mkxFXlLrdW5RvZkxXJtx6Pgvu5sPQAbdMaTit0O0LZVtoMIY+ASMiZ7ePrj7bRM+l4sRB1Z/g+SmEszmUeH6r3EW86FQthpRPfC+Hiug== 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=sNfbPUlIN6M3l2O1riS4BqLVSlYkxDQlrmGoDDa57Mk=; b=rRcge7Mrl59SKP62D90nbSGvUVYkm2XOM2XLRZRl/GcEmXNgampvCT/hpDimkK+uaH5SjQkUr54Ec5nYhwwn0OSQlfBjG/LajApu4Khd42rEa2XDWbMOWMyfb15HJd8Urn0dG0lwGyFqmqKIbV8fS5jRB0Hpswzh6JriV7Y07vM= 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 AS4PR04MB9292.eurprd04.prod.outlook.com (2603:10a6:20b:4e7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.29; Mon, 3 Apr 2023 10:35:05 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::dfa2:5d65:fad:a2a5]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::dfa2:5d65:fad:a2a5%3]) with mapi id 15.20.6254.026; Mon, 3 Apr 2023 10:35:05 +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 v4 net-next 5/9] net/sched: pass netlink extack to mqprio and taprio offload Date: Mon, 3 Apr 2023 13:34:36 +0300 Message-Id: <20230403103440.2895683-6-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230403103440.2895683-1-vladimir.oltean@nxp.com> References: <20230403103440.2895683-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR0P281CA0221.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:ac::17) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AS4PR04MB9292:EE_ X-MS-Office365-Filtering-Correlation-Id: 6dc4e4db-dc1a-4668-f122-08db342f168d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wkbNkRk5ieRsyM+TcgG06utf47Dot+c7USDJrJXggxRLFWjB4eVIZc3yL8qBhLCB1fWRGjqCXaTGLBlickqQGWWLCfTu592EQhbkBs+yTbGkuDobZnm4lBzLFbOE/iKex7pZCjLXBH3bbXmiKLrYOdD922/O3IBneqsZ3uYGsRy2j+/rF6RtoyNmDJ/Ynm7p92N0yhQSAI4ANRPmwlPV05l+31VpB2B6AOU2ESgfc8+7AeuPgmpERGYxzbwTh7DWtX8GRTlNq1oUFWD+itkTAThmWqiSC/qSysF1iq+sccBnwXxJvQHKpv7sCJ7pD2EX9Psmf2jNh80H3ZvroFVnQvOLjvHGUuyhgdYjaD+TB/lb2eb6Z2lnWhOf5m/95XEWI9jXcmR6O/KMGl5IXsAr1/Bz+Wu9ug8qktnEOoEqq99M5kVrrzxUitxzPNNwMJ0UJtJRsyeMVWy9uFX+7kXgDMa5J/rMbG4Ko6oShv8/q/3rZY0A6yiaR6PkAY8vVvAWcpKXs0cNEcIieJ8CslKlwZNv/4fqhVBylTtahqIdSkLhnuaQuKLHtuZic/qb8NFVbbVkC0PF5/5IjNVsrrznclSzLrfS8iscvZs9Di9jIKv51Lr1USFcV/9Fxi8a8mwe 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)(136003)(39860400002)(376002)(346002)(366004)(396003)(451199021)(26005)(1076003)(6506007)(186003)(38350700002)(38100700002)(6512007)(86362001)(316002)(54906003)(41300700001)(7416002)(5660300002)(44832011)(66556008)(66476007)(4326008)(66946007)(8676002)(6916009)(478600001)(52116002)(8936002)(6666004)(6486002)(36756003)(2616005)(2906002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8sZGKgQPZXswnc5gBby6QCJxVqlr24gWt0pb9/y51Tk8n4JwMq/XaAo6SqWFh+tFx2OGpnMqjDpLLlu/Pduc/HN5ReY4SuPoet1gqoEvLeLTIjSj7r2kgmyjnFw2jGqrKSnkksTWPOrH67A1VcVSspa+FkqW1ifCWOt9GA6KBUvIpopekZvUvI477K1mL1NNrw+GZMBrQ00PsXmxOJb5iqkeGGohU4LdW7kHJoctXHSvwlGxjcsBsRZoUQZlDbJSWbu570QXq7q/VrYOIjizkkAqD5phZzr3pRTvIfWCD41gaQR+fEVoxoOcs+2Dx3AjsvF2xsp8ughj3ExZXA243hZ7e8M5hjKIBj1hQkTTlpvPFLag+NeJmnRFinoTT00JhT6p+qPFUJqS6bMjaaRbva/ysk8YUdfsMfdkg8A2DrB4aP7YwOeFLgl0/B1bnvptfkWQdGItRcaEnpXHvmnpeu7Qhzf8aeU8dGZD7Qd9Plj/sZek/RO13X91bNHvS9vcoEGN5MCNhalNjUfbz20SFpjy79UdWwI8X33cYWLLojn+FTC/4+UbQHHifqDCbacrkcsV2ewCzs3lf4DlzgYiyrQFK124X8O6Dn4mYaIlR60hdlApvwLO9T4+SsV9XbJbjPki4xuJn7op+ayuiDUaHrp0j8QWyfW311zMKS6M0hRgDZioa7557mBiYfCtEGqHRF1sIlZ5DCmXRuRyDpO2GQ0AqzfYOKd9dppnJ4H1QTjV3sBCiIHnKiejqXxFy8Y0C/P0AmwfN9uje32hAkbET5cIsSEOws7s22QhKH8Q6c5AhaOBnnP12u6cLHBWyUxxOAb31516XzE8BBFYq4Ns8XQUCjyOe91GwPmMqJrJt0Rnc2aIaFpEyOMA9/pL36QbqxUjCdhoVDIryw6pbJqAiDAsfNLZURXxGi695HF5LZP9J7wYI8zIezjtwjfzpiB1iMEuxMZdFcXzrVlKHLX7bmDOC3TBV62iuWp0VbcZzgMF2UV3V8Z8aMGLlpcZSdExtQk1I0QtWTp3TQ1glDJb/ht3i5APZF6JwMn+QDL8yeb+UqCqKL1i2CXoy1hbTfwSp1vKH0KS5797Mjlr9sZm6ADNnK4rdELroRuTApj74mkyiG+t2mwLY0D+ZZlUijYSWta5g2fLAIGeH/fsxQ45fzMRrm+rrJUlepYGBrwgtrzV6GuM+PLJ4FhU040n/7VWmFZnj4Jc1rrIjqAIciNCTOzmnNmCjFHs2fPOWrWVVT0GPdO8UBKbYHVIRbTrwYEYGd0CqXbksLVviWADsYCmU+3INPAx/jc+H4T/Q10VdkmibasZWRkk7fxwsamnvs4nEORe8el9L+t/ZH+lFLDwnTfxpXYc21Kgu2o/kCTYYMY5UimeFUI+7UED4W8deRgdkrkOP9cz+yNLUImTX86uGRPeem36Z0E85MtY89eDT9rnzy/QDvG9/I4ziWYy4Dqgb8xD9Fk96x+Tw5fyQ5kUEU5hfDoXZ2VCACowpcGz9Bjwp/pPjjADC4ybwnrstMOFysW1Ep6lok6PgfBkxC3q9L0nL1KY/JfUPWf/nYvYkFj3ABKFv+tEMjsRm0+YOjbv0ieMj8yJNSoGy8NhE2jInA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6dc4e4db-dc1a-4668-f122-08db342f168d X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2023 10:35:05.1768 (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: XjxjHhJnTitZk7VaAqqH9JP+5BkwTaJBKxZHuZeCIAN4ds8a3aEnvkOI/n/Ljbyvo1XPhG6hu6Mgz/im2If08Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR04MB9292 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->v4: 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 9ee5a9a9b9e9..5287ff60b3f9 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 Mon Apr 3 10:34:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13198000 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 935CAC77B60 for ; Mon, 3 Apr 2023 10:36:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232419AbjDCKgQ (ORCPT ); Mon, 3 Apr 2023 06:36:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232049AbjDCKfx (ORCPT ); Mon, 3 Apr 2023 06:35:53 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2086.outbound.protection.outlook.com [40.107.22.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB0331285D; Mon, 3 Apr 2023 03:35:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WzYLbD2Bvk6BuxWHIRL731C80n3IFSFWSD9K1pCRECV1gemLnjhfB+7YTdJ7B/BWsgS/1HJzqKM3ZR48tw1bg6ck+1UbGmw7tgsmjOct9pSpHV18/ftBBoexvFsR/kfTh1ZtGM5t2vOKxCKf1oGkfsSgF7zJvSZZEaVjmlbh007D/95rnstsgmiuwWtbHi1xv6vmNJ+9PjNLHqI/Ofr2nGd56g1D8vCSBJimYklrX9pXNz/u7ParT4HBsnZUokvr6DgeY3VDEqgDPw5juIXyoTpDWsXMThnCojF9yisjjmgm/OCSuAzd9ibwXJnrHWnkF5G7wVWHQlxRjO7GDRVxRQ== 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=alCPmv8FaTs0aFVBKiC7WnHF2DdMCJiTJQx9TQbQLJU=; b=E2vygINyK0CoU/89JL3ZnIpcn9BWDDo3V16LMjO3DX8ePtgbNp9VuG9l/2xHEjTF3p2EPZWr6ciJOxMogQzgHRG/5uFwioZiPf5N6hs36x3TMIpmJP1AyHtSHqNsqUwkLbBVwg2NWfRYl5z7jEdSmihxpicm8U0Jtlev6vg1RvgEdbZduRuoQPPBw4eBO883TNOnGAi1alKbI7OEDVq0SpApvKWPkD2w0qYSBvh/StgqtKZD1RNDxiz6NVJ8kckJWQNs053EJxVjX6mbpmPALtSZi6FLlaOwH0ekHUHEGNgWHu3ulULZhRRf5pYsjppjl35YrOJjX1wtRd1G/62vcQ== 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=alCPmv8FaTs0aFVBKiC7WnHF2DdMCJiTJQx9TQbQLJU=; b=YunkMOAOeHvCdPm5Z+gow0OL9FIw71xGm/UlQIaA5Df1nl97Oqdwt0H6FhPC+M4DThglnDpeuJp726oeZBRjvovopTMarXSmy0oVDAdKl5mz0dxQTzwVMjCaDCj3zx/e64aC5UZs5eDucOd8oYqoSH/TfmaQRAsMphG2uTizpjs= 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 AS4PR04MB9292.eurprd04.prod.outlook.com (2603:10a6:20b:4e7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.29; Mon, 3 Apr 2023 10:35:08 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::dfa2:5d65:fad:a2a5]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::dfa2:5d65:fad:a2a5%3]) with mapi id 15.20.6254.026; Mon, 3 Apr 2023 10:35:07 +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 v4 net-next 6/9] net/sched: mqprio: allow per-TC user input of FP adminStatus Date: Mon, 3 Apr 2023 13:34:37 +0300 Message-Id: <20230403103440.2895683-7-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230403103440.2895683-1-vladimir.oltean@nxp.com> References: <20230403103440.2895683-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR0P281CA0221.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:ac::17) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AS4PR04MB9292:EE_ X-MS-Office365-Filtering-Correlation-Id: 26b5d49b-7988-4fca-3090-08db342f1794 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1Tg+eH+aSmoXxNgKIdW7GjQD4NEAJYlTmaYn2JuNLyEc4oE5VKCD90pQ+pOAzZv5vP1KhzrOOMkreMs5s6Gey5EkN05ZoOJP6Avv1NmJON0iwpQxE9oS1UpxklUYF/1eap/ZzGjFu94t7ZEV5Tk97KYDOEHuw0Ozchx60UZCHp8hZi2vYw/mezWy5Z2U4/DO31XoM1P0rq2FSfdYTcMX4xUYEfzGySROJrUMyvxd37+X287+XszaIM4MKPiWk/poifYwxnK5E4KnXT6j7Q0xNGQe7ZhbaQwaKDjXytZj8HCkogDzCaLFAUDWbR00C/Xa37k25Si2Xw8Vqd9POgub6Ht8j9esE9d6aZbk2tax64GOWzvooPfFcf2RvaL85SGc7i+KXEjAF+Tibfrqi4aqFPgVzH+8m+oMdOk+vywfJgMdlX5Ka5OnRSqvcWaHakB3nqfJ+q0u4EZ7+KDz58WZaOCG9nw3M32hz/x0PUvRhRKAS/nLmr+oajjBhh7RMkZqWj91EHqqhYjwGoE3UsPV816DONRBdC/gAGkr0TSJnXKMihsPFhK57dvIVqLCu4cFT9w9SyUxuZvjQuJjrDHWjoM335XVBSK8dDEPLCvfGxjTWSIlLzQwC+BOEwotXN8t 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)(136003)(39860400002)(376002)(346002)(366004)(396003)(451199021)(26005)(1076003)(6506007)(186003)(38350700002)(38100700002)(6512007)(86362001)(316002)(54906003)(41300700001)(7416002)(5660300002)(30864003)(44832011)(66556008)(66476007)(4326008)(66946007)(8676002)(6916009)(478600001)(52116002)(8936002)(6666004)(6486002)(36756003)(2616005)(2906002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CiZfLRcJA68U+UVuYKIvpWbh5dwM9TbE07SuNAKe6hXka0hoKmP/+kDesYmQRU6UiB1zf8cJlQ7RzpIOy2X9subyUNBsDhiJbfuYVaah19fUqloFUBDL16Nsb4bPl5KxtUxlswnP2cmEo9Xg19UBAUor1gqDC8iTDzDVOX/lUpDZxGMoWD81KLpzFS9DqZPy9vhIuOOPb+xPVaNs96s2UP/vKgyWDLMdf46E81Sg/i8VhZZcbT2J7pDK8+R/kT3uGTJez07ViHpxhyUXD2PXq81jRQa3Nb64sHA37yM95LvVlQBZk5hH7oiFRjaLsCEyktuYNRI4CEIXLrRrPCPqtguYn+zy8TZiYeqONQzHNdu8utCSg1oyqDEMopYQChCMHh0A2qSSG8otF6P7sbszvqZ5BFfLR3X6DlFU8BmBdDuRx0ME/UFtQ+iUDybxJ297zLU6SnWdn0RqMb5HsEHdNudchMFqY2Y2G7/pwXiUIf0boqBKYM+Qz0GC6vozlrH9lX6M64iiCLmxOh3RQmccDrfZHDIVF+HKQgxhw9gzyEwo6mXmTOVGVZzW1MAt4Nfz2xpB1QxPfcNLrmb3JDvHfBvYMEuwBB8AUc7oHuwhfEs1g5uQQVr1ldrGlGUwXrKFcD9LRnhixxyWUeSGlPWCjHRScvusqI8ndvTt5erBkTZAm5Qjm1zeK8FkM1/ORdjOf39Kb3eJMobumLRrpnIv9IX/dHFWFb27K0cYrDQbd2j4Ua3Vki5TKJXTwpR156LlvHwv/UrJJgkzyFgQ77gvo084gpt45njvY6+AnRyb2nKX8lT2YviEJsbPCApEj5tzI0LU27RZv0cMTGpSnMtfrcJ6msNCXLeyobHIF3nz89vhnIfncUw5jypYtR57gDf+EsuQrrYtnxUClyvYUZKMeqFVyFfqwgQjnusGR0NwX4LDtMjgONEOEDmoUW7YeOQrfaKCw5J33h9PIBJK7L3Ag9sP3huoREG0MdtHaXXKi/cgV8LqTdaTgmeKw1xYNq2vFRTTb9qFKI5Yv4OZx+2tXmgnO5bb88mWUSjJNwBPsZPh8y2QfBrNqaD3haITc8nhy6bLi4lvk8P7wGCBelsL/2EsMwKpqZOazqXo5BdUv0duJIqMxZwBlpWIBSWk52+gZbqPo7If8CbY/vBrtA5JVeYu1SKH0B7O8JkUE0EZ7naMUVrqlzsUVbbySxvWLOIGjwS4JC5Gjg2xkGNeSdTnC9RqvFK7bcwsT+3osPUhuN+K0kV5+ULlC66p5kpn/OJ0zC0FQPK4v0VQh2y4SG+ODcowZDT4BLYIgxrc8py4cHdeLMpGUHFSk9QDZD8KYKAfJEJo+Ryo+OThONvwVjLezTN2Kg7Nd655UGa8WpFphPAdYdt8pVin9WidfUTqQsjG/00jD+RrOj/NbOPG4TSDGSOn743X0kP117vq42/u8spzicWyWa6Pl5qvNjJ79nr2v0AOKqd8bgG+RHVPeKrxRWC2WiTHwF7B13AcIMjkyjneQqf3fUb21LvSV2teRV81aF+xpJKJGOyvHc4QROSIz90KwZqfoCYZ3ORR/ANYG0wUxCyfKWMOcjADfaxgrBxkBO1UNfHrdR1x6WWNBOmnpw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 26b5d49b-7988-4fca-3090-08db342f1794 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2023 10:35:06.8567 (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: f91ZvzR3TUIA9j6+RC23BS/TwmbGeEZDg9bN2/bHNWMYWx0JeSioJjdzjchaDtrnqjcv4EfS15GO28R3yZL7Ag== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR04MB9292 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 --- 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 | 127 ++++++++++++++++++++++++++++++++- net/sched/sch_mqprio_lib.c | 14 ++++ net/sched/sch_mqprio_lib.h | 2 + 5 files changed, 159 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 5287ff60b3f9..bc158a7fd6ba 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,94 @@ 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 (!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(extack, "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 +319,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 +339,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 +357,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 +510,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 +587,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 Mon Apr 3 10:34:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13198001 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 3A2BFC76196 for ; Mon, 3 Apr 2023 10:37:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232093AbjDCKg5 (ORCPT ); Mon, 3 Apr 2023 06:36:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231285AbjDCKg3 (ORCPT ); Mon, 3 Apr 2023 06:36:29 -0400 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2086.outbound.protection.outlook.com [40.107.22.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2055618814; Mon, 3 Apr 2023 03:35:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aYBlyB3i1HnFhZB63iL4k17PCnjQMdw+6u6oETn47iVWcmiaae2F+1wmtYZh/ncur5V+rlSgkbzrHHMDtAvbKka6VnrmP/oLQ40xLWh0S0p+gRN8TEtAxDWdBAD37ZfoJ6gFrCOyBEVV+5B7fPJXi6q4bQX806RW1ljNZ8ccdsWTbwOzt7nYas+NGM+ZRgLeW6kDgTg3P6FWjnFsG5IBELZv6auoHopYEUsOKnDUsjMo5jrqarXNHrewez4MX1adTLwJFe1nP+6kE1MTCRQ17+IMGz8RuJggRgoI9kIiNchjRiHRLOKsUSWe4uxPUVm+Av6kiS9Kho9MgxtLeevwpA== 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=Xnn6SUEXvga/kGi9NL4C2sICKQm8Xp7hPuNKrgZf3Iw=; b=CFNg20lqjHIFlw/MB6yD1THmW/YktJy+62oizaiEpA9+Ky1YU2tL+Sg2IxklXl/IcMzAkLe30bKr6xjFxM0T8Wn5FQ+wjJz5sw7kbbDK/k53FA3bm22kIkPtnZigb+26ZM0cOotp5qaBmOBzW6XJB+nuXIFFwBR96dD8mpkGKW/aIyXkftw8yI7335/c0poVWxTejNavD+p1Mon9goRtm3rIMxpYlGG77t/DAMR1auxQ1YZ3gGNlNtT5k+ij0dlRKP5XILJAiqecJgeXhqjFZ7boq2OkUE+NJtSQgvQkMpxe44GuMexuTXfWY2A0amzsoI/3PLWnCG5EVR1+hmbJYw== 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=Xnn6SUEXvga/kGi9NL4C2sICKQm8Xp7hPuNKrgZf3Iw=; b=W/S2GHC+xwjpCtRjAPfdrCEwkf9JGpmQlD7ZKWf+vC37a+saNxkhYnjUhgMeY37jO8x+KwG/l8Ggue1OtEM6xcipFXGvi8297t6GnEEn/l2M/2lMmLXOG6Cm//4yL8muP7NZeBVKUOVQbxbBS10E3xoVk3nUD5PUMyifM0T9sLI= 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 AS4PR04MB9292.eurprd04.prod.outlook.com (2603:10a6:20b:4e7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.29; Mon, 3 Apr 2023 10:35:08 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::dfa2:5d65:fad:a2a5]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::dfa2:5d65:fad:a2a5%3]) with mapi id 15.20.6254.026; Mon, 3 Apr 2023 10:35:08 +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 v4 net-next 7/9] net/sched: taprio: allow per-TC user input of FP adminStatus Date: Mon, 3 Apr 2023 13:34:38 +0300 Message-Id: <20230403103440.2895683-8-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230403103440.2895683-1-vladimir.oltean@nxp.com> References: <20230403103440.2895683-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR0P281CA0221.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:ac::17) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AS4PR04MB9292:EE_ X-MS-Office365-Filtering-Correlation-Id: 14d46c10-a1a8-4c13-e6b6-08db342f1890 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OdIj2e0vqV38pZ3p0DDyK9BONOWRRoHmmGSyclCAesCi29apZvTecpXeo3gHYPeRBSsdXtXn/ZbPSpyF7jIHIt91TOIjabHHlx0OuSm8xNwwOW4ii6yz22UKc6C0pGuRIVYWJC9RcmTB4+e9HBoG6Zzkqk79ylP0WmtW3bYazV6POCJR7XFaNx/+suH32n1duMNbqaCuUIV41gtd753Ibb+sWkC+rcLyd2O0v8vld2McENN9ZK6qB35IHRO0s7+3LmV9xe4cBUhNO1E4bYRDy9NWwNf3Ac1bT6kIFBzqE9pTeslb3atvh+Gs6ool4y4sTsXujUchoVlci1GHKVvKtSUGuj8K2X4GqhsHCwWZ/pDA0G46DEoLZ9KgWrAz7ILrpB0vsymFtp9UXECca/2B6ZWic3IlenOmORlJITC7RSQCQfLQzbgSXgD8NOaIL/4hXi5h2i/JtrdPZhHPQhOTTyUp+jVQppdErfZiVgl3w+FD9SRb5GAkbTEUEr0Wjzpf4tihERySDzTCQ2t9vT3HkSflK64lFPGdq/38SkBX8RWcJmDZ4Iw4EqZpcuIl0IK5z7vY3gktF/AbaHzwoMZxS8vdb9vbesqi/c1ouCSCuWPSayq3JRdXRv+GWFd+rcOJ 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)(136003)(39860400002)(376002)(346002)(366004)(396003)(451199021)(26005)(1076003)(6506007)(186003)(38350700002)(38100700002)(6512007)(86362001)(316002)(54906003)(41300700001)(7416002)(5660300002)(44832011)(66556008)(66476007)(4326008)(66946007)(8676002)(6916009)(478600001)(52116002)(8936002)(6666004)(6486002)(36756003)(2616005)(2906002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ULHkn15YaFLB0wjV7vVddJyEMHYGj/cJ8RrSGSjuP69tsGpIBHGD2M+MuxWm/0oQb6VxmoCh/LzRvDwqCNqzrdavKjp7CxZyj/sSdZ1/CJPlWvBzso/Hx6oWrXianxOfsn+AjY44vu0okeoElWEbJQH4bHt+Hu+FvgwOuh5MPgA5xKmbd+BSPUly1WvuMVS0iWd8r4SzcIETcWz6otXHVR+Jjki8th/X0A8UI6NcuYpuyaL3FleztRGRwD7t+hVdqtwO3yphkjGejj0rKCFZhV6xHwjdyVkT2rRUZZGE4l4DCo9MGkp6+IONbB3CHqNFxGbquyHi2baRxgtLYPBH+zetlDTQ9jOA9j+j9segftaooE/jP3bcNC2gQQIElmmwNL2gzrozKH/VIabjcVw/2+LigPWKhp20x3TEnxhJlKurjrDhXzBCy90jM3v+PzHXpdX0XHjFmtRbJBH10RoRjwHZxoAAodp13wnFB75qVVFSMOeYR56JeG344KU5MGRXF05cETm12DY20KRU3EWZ6RomCEAEAU0MjrK7ot9sRj2jcnkzfIGCZy2HuFYVcfHiE3vt3B/vmlj/1qm8clE7/jOajaEU9BH8KXdMU8sXQl6l4EzSj93t0g3j4r6mIsVz2A+AE33gBt1cRu+r2pouSvrYCxG5QAUt85yLPZSKmdIRMHmBJSqSQ0JWiFHQaP4vqtyzLiNXmyYjhWU0M5Q6UuC9ormjWdWYTMvboU5fBzes1H9uexrIvaA70Po1iqmsOQapkQndGUQqXDIz8jt4DlDZGuWImh1QeIJpVBUOrE1L/ZEK89uLqj58dgf3KeBV5mxXfaE1ZUyfjY09gLqzWuFDnWjHkWEu0/giKEYIDQZLCXQhEatye9yAFhHn1nODHcHG/MooUnXJ9T3QQAUAdAl55nyaZ1cThRV9M1O6ZnJHN470z5ru4vIv9TA+pWRnVKGX9xinmG2NGMrI0kdGxo3euoCC3vd9RH02lbyxcppBPvT856JeTVz/28NcD8u0u4ToxNOKrd8QLUf1+xyaHk6noiZBpAqCwU/x3tx7HhLPttzk0DdOuyucnflN7/T2LNT3pThArkN2qpMzJsv9kT/res5srw6NRc0xJXv/OihGeH+XRFAltg1NYB+nmpL96sgQzOq+uDClxEw8HbFMQCRD6DNGWFIAcWZ8O7AKq2QUwA6Ffadx5yzYBn7EDT56u+viXaW0CPotEEdnEyZLRfH/6QpHfpa1czQAgrNWVmSZYZtJVgdg0hRI1+UYnkKeZva2+EIk8u1IO5HbcAa/lhFG8vVWX14q8z8cu5Pq7y+V5C1afvINoobDrjLJKy2QEk9WEvPdvdc5pXmDuC7cLyBHSC+5LVhK2msSusx7lLUmFygtmepy4GAOSUfuUkyxKxr3BOkIIHp1rS4zEoD/VSRuqx6iZInmlmAciyHsV0OoejCwg4KLlZuz3g6W3zee04nv/4gIbNttc/kwcZyiOgFTNAN8q3q+Fm4/TIkZWlJAiW00W2Zk6/ceY1fq0+DSCkp3eH76NScUk4PHBG/qd6OI5fiDIcwUPWbuj9lI1yXk+WPCL204g3rRgk5YqHQLP5oDyYirZRu29Lx59qt4FA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 14d46c10-a1a8-4c13-e6b6-08db342f1890 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2023 10:35:08.5380 (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: 4aPxr+1VvkEnu6hFdTy1Y2cx4xkNbIMhkeFS7OspXqfXxc6/nB7pNdhIdsyJM+akdkDx/WEcIztKagBJpwzUeA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR04MB9292 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 --- v3->v4: none v2->v3: 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 Mon Apr 3 10:34:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13198002 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 4F042C76196 for ; Mon, 3 Apr 2023 10:37:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231982AbjDCKhg (ORCPT ); Mon, 3 Apr 2023 06:37:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231655AbjDCKhD (ORCPT ); Mon, 3 Apr 2023 06:37:03 -0400 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on20618.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eaf::618]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 607EB12875; Mon, 3 Apr 2023 03:36:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d16OT57Mm4s3lkBXG2BvM+HvOFyrCJnotImw7XXPi3ik0F471huwjWxql5+hHUiCwF6IueRdMQ7PM5Co+NRW75o/USoz3+Ws6Oi717jveIpD5R7OGtIA2/93XykLsvbS0OxP/iMZSn5i66oknCrrSP2ndiCpHfI9u9yJxamBds54Kzg7BEZf4R5bn/vaUaNxL3S7cT4TBBzZo4CmWV4MJWkdkMOJ4jQ/cJJyDZZ5dUeDCXkIOBJL5WUHFNVDhw3uxCXaZwjOuFCZWUjcJg4+P693/MZ1b49ZAXnc+7I5ysWjTyNg2oCI/ms0js5+swVqePCG2efPvWCVveQWWu2fcQ== 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=VIEbuwGFx0j3/eVF8eQ7Yt7xrWD7sp6ajUPav85rFx8=; b=WJfSNKdazQtV7g8JhYM2yvTfrBpbtfE3zAwwx3iZRdSA3TrfDY/Sg7GMu/0cP8l2QmZ0Vehl8FcSYqNbGxLO3JVeMZ7p6SJ5g7t0wCedmBbeMbt1HTqK7tT0nDhwBfOSe52Xl/lxdmsm/2K1rcKOfHvtJFZJxftKoL3GW+IBkUBjUOFdfCMVnBFzAXvDG1lN/PAb0Ob/J4GuKVlfbrphQLZ9RH4T6detKJWrBkh5z9jNydq2x1FqjM3Lyhlxrmjqu1keJQtMMNVmF+hIr/oX6hILSqJLGeyXRM6NSrVaizDO8R8bpoagH5FdUjuwv9iobD0lgs48chvzI9GG+vr9ZA== 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=VIEbuwGFx0j3/eVF8eQ7Yt7xrWD7sp6ajUPav85rFx8=; b=ICXZcUWEFvogWF0vnFX/zDAIFejWnSJZGfnzeC/6h9hFI7mR6hNM96hJWsxycTsa7VGw2gVCWaQKFLoBDxUwK7ltMdE3sEsy/kCpC+xAS6/QAe7TUvkMwT9P/d1s//MgCPQNCkPx8YOf9ISfRZysLIQeAAOrDpLCmavOT5c8Le4= 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 AS4PR04MB9292.eurprd04.prod.outlook.com (2603:10a6:20b:4e7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.29; Mon, 3 Apr 2023 10:35:10 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::dfa2:5d65:fad:a2a5]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::dfa2:5d65:fad:a2a5%3]) with mapi id 15.20.6254.026; Mon, 3 Apr 2023 10:35:10 +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 v4 net-next 8/9] net: enetc: rename "mqprio" to "qopt" Date: Mon, 3 Apr 2023 13:34:39 +0300 Message-Id: <20230403103440.2895683-9-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230403103440.2895683-1-vladimir.oltean@nxp.com> References: <20230403103440.2895683-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR0P281CA0221.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:ac::17) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AS4PR04MB9292:EE_ X-MS-Office365-Filtering-Correlation-Id: 5fef957f-ed1f-423a-ff2d-08db342f198f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FRE8+snUODInuCFt6xS7mQF6Fzs5BVpCvNLr+PxZSlIUb2ubeeOG0cLGTMWbxt4pR0eNKsDXcQHGEisp51EV1a4e9He/cvTBpm6JV7+Bq0n2v2FpsidkHPbUhtqXmssyzQJdndiLq7Ucg4dIe6vvqilqPXJdmpLiq2InDgYh8WymsbamruVZSNzajgQCNqVP+7WhKZP4v24FbWEX7ju81+JsC5VocFxhA4XmCnSNf1O4XzSbawzSTc9HHwQB7jERB8BwwzrZvH3hJBawh6nTXAAL9eAwCla0ScNBGKegCvVW5hc6tvesToviXyr/a6ruEkA6TckVrYTUkpPxJEKwbriikNhP8g2H0b+xk2KwI876tO0IjJDcNVVb5JqypApQgIdK8HUNvAZsY+jpv3R3qa5ZJ5YiNR7yCDtCFnJ+GiS86FfRZSUFWr2j5E+0AnBKa3ueQMRvI5xXOp7F2X5VHYveiIKdN1p4QGaiMKG1dkOEC/zDxNwWQJq/y80/ZWeqYauv2pFWla647PZv7IKvd60N8I3xHMhzP2CZMcJ3b3RfXMn5TKNLkAFNZSItBflClpun1NlAhzjWadpR75NWLeEqlJNkrNe+9o4BitCZ8cXUzMnaJ+UPtiJ43DB8/OL4 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)(136003)(39860400002)(376002)(346002)(366004)(396003)(451199021)(26005)(1076003)(6506007)(186003)(38350700002)(38100700002)(6512007)(86362001)(316002)(54906003)(41300700001)(7416002)(5660300002)(44832011)(66556008)(66476007)(4326008)(66946007)(8676002)(6916009)(478600001)(52116002)(8936002)(6666004)(6486002)(36756003)(2616005)(2906002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UafAnyEoGvJpLss5qURFsYXhxrHh+zKbeirAPsyNNHyikof6yGsXTEgbTol6Z8xy/Bv3uvF6e1kRfXPItfrGgM4AjaIHPkNf5b/thdAqL7n6GLQbH8gP7RmJpNM2eQaJsmfNufg6212K5lf5+PR5PJ/nw9adzdaN7+NXJ5hQNJILYQ+AsQZzCmShJ0YbzmgMNT3oLdAYcyAQ0MdTZ7K8nkaeXPvEZgXRkFuXWoSOJukNswNLvjwGd+Aex7SJBktvuN2IbKQK+oypL81fFVGROFn6ZsoKopsr5S5o6waAFqAUt8IIVcse4vo75GHwuQoUaq3fH9X6BKoXghuC7W4jS4pb0oskPPekkg4WC1beuXtCMGaGSaT9gmQ+C5wjxnTN0HdWm/qtJJRIoo9t13eZB30oej36ZOfyGGsbdUOCWkScLgfy0uqmEqXyBi5Pn/o4fPhEvuZ2wW9mw46Rmi0VVK9MoYwUNJ0TZ4A0A11mOlOPKuNAvNA8JmucrIim5jxQFCxvdds4tV650oWHrpWSRAakB9SlPu/tG8mprp9y8WXuBEMxGxf8F2P2hUAFJpwz7Wc8cfduSiB/yvpEYS1SfuCf2nHari9iNRaPfXgvcs/ktSLeJ6wShtkU8WuTpyVfo61ua3Rx4fRg1IDefD5m5CRnCDubIFalbGXnCr+kwsyhThxYwgAnXL6oKtzwQdWAiM+bAHKwTyrTC61euyGOjRmYLckyih+MqU3pNcZ8ebeohnaOJRVmFV80IkOU0JYMBLUHCRJ55ZfISTL3KGUyJQUUrq8jLQ0fKxqT1E7aJp1ntx6+WnKsCCJ2UrgL5iCyXXltH3DD6sGVb82EBV3mL1w+zfmUSoUB71UTubq8nmvWUB54zh4Ld59mbh/HNXJ8UBaKu07hTQBWmMaJYn3WtQSTh38jVULLs7I07gAyyr4pujZyuC46zXmSapyEYmmoT+RAwBSgG5VslrlKoB7vsPrW88/cZIxxAo5jxC8qu2GzEk/PXCgNev0eqLksKiBLMDuk638AmhSHtnopUCGGC+yjETr6qFUrb/0nMPO4jSOVx5Bczmk3XPCndKiQtt7pHwNSFTufDsS/Dhc2rWVTpi6LzN65Uj4A091wFPi6GHbrQYziT8Wt38gsL8bdVRERdyoobEEszHVDE1G75bIMxPv8+LwzKic4qlxddPdpOgO79OY8UXql9jgWEstburIbP5Td/mVq99xMCqg+X3N/RLaTvsucoUUCguVou5EldnXt94144wOj0C3WhOBZOxZIG0j/1WT7/gDcsHc/T/l4IN2ph9tLjPp4XcqXvQFIkkGhiNkILYJPjr6AVkPH3NpoQlVD+QaUj74Vcgkb7MHsktMRqG+3xrGaEXYwgA8AMniUQlJaiMA/ekzWVr93meG62sE9HbcJ1n7KoT/oaV30hhUb3qn2CkLf1u1X4clEN3luT+OCmF2Bi8ruEsCnCZhqWcDGuOai1RqlaWPjIqX3P52+25igTvLbHaZCAY4trqi3beAI4AR2TUASkVeBG50jsTNIwHQ+y4sJgWVuXW1bVdX20JwJqXk35UR3ZVC8WPGEfFBr/1W76D/SfJDRcVszVhC5g5y8eXNCTE1d0MXGPg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5fef957f-ed1f-423a-ff2d-08db342f198f X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2023 10:35:10.2442 (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: 8Mp3wnOYGP8+PjfohlNh8ZEzhY1/mcN7r8Vo/DCm3rBKx8Mkc5Ywyx5g14LWTsFXR0Dj/hQuBXPRAnrGFfaJ4g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR04MB9292 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->v4: 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 Mon Apr 3 10:34:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13197999 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 564F6C761A6 for ; Mon, 3 Apr 2023 10:36:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232403AbjDCKgM (ORCPT ); Mon, 3 Apr 2023 06:36:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232346AbjDCKfx (ORCPT ); Mon, 3 Apr 2023 06:35:53 -0400 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2064.outbound.protection.outlook.com [40.107.104.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06E0AF74E; Mon, 3 Apr 2023 03:35:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IDa0W10bAPqF+w+BuYj+9SslsIr697SAEfQcbVEiwBCyvgwkC5EETF8y1LqTaZ4hu/FTyJYlKJ2UDJOoUIW1Cgdm/eLZhSl2cjXW8MauxfiGWpS+mLxDfSgEyA74IUWkyhmPIjBkz4rakMQ5miufBnZwcqMB8tbs93gg6ginLbV4nCmvYr6l5xGZ7Z2JYILHDB7UVJl49gh9Z8z5a/3QAiGL7N1/5wMkw79Y7Rk62JHS5VxsLUWvcdbsZ+uc8mNbTDrIhhwVcbybUY3o9vZ2Yl7jMiHgioe+4bZIhG9T9+CU+c1KT1GukKwKVqTj0WfJXTDDcbzDQqqVY88mIrn/ug== 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=z8zEq79FjoG5oEijxtnUWrNee5FdcLjHhpKH5V2iIiY=; b=AzW3y0hwknv3gzGF1vEyjknkViDutpNT0ktf7/grFQwTFEW90mHfrXD2bWnKHq/EmWEz4qsuxCx6YWSbxxn/KHtT8IrQ4I+UE1rVxMQCSriabKuUtiEkcKLlAq3KFldhZhqs5MBos4yH4n2Peg+RzUVRjqLUnspMY7MKS91BN6CnIPgTTG8okQMWdLo5APsCjhQpVW4/s43m0W3iqSwa2CPzjCqPdvYEU1z4I7aoZ1/O5zkNBX0W29lBVgH91tt5GmUcPuRWbDh3Wj2nfoQqdfpqcl9ddXXMzzy6+30NEPnhvArfaSs3BEp2PoRZ6qrQP7Pr7fxv5W00qTA0hw1LuQ== 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=z8zEq79FjoG5oEijxtnUWrNee5FdcLjHhpKH5V2iIiY=; b=XP/C8ZLMHnL/fVVfBaduMV2JgRaLO5aos2iu29iZt045J1m5mXNeoezxs2TqZHNB3KE7FVYUDZ672lZfciVmk3X4pnKsxBgwJ2W/Trho/y4ZQSREd5nRVidHUvFMrHvKNdW83f0zk3sbA3agGKdZaGSBDiSLoM9dCvwBfScN9eY= 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 PA4PR04MB7536.eurprd04.prod.outlook.com (2603:10a6:102:e1::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.33; Mon, 3 Apr 2023 10:35:12 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::dfa2:5d65:fad:a2a5]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::dfa2:5d65:fad:a2a5%3]) with mapi id 15.20.6254.026; Mon, 3 Apr 2023 10:35:12 +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 v4 net-next 9/9] net: enetc: add support for preemptible traffic classes Date: Mon, 3 Apr 2023 13:34:40 +0300 Message-Id: <20230403103440.2895683-10-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230403103440.2895683-1-vladimir.oltean@nxp.com> References: <20230403103440.2895683-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: FR0P281CA0221.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:ac::17) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|PA4PR04MB7536:EE_ X-MS-Office365-Filtering-Correlation-Id: 920ea710-592a-4d66-79ec-08db342f1a91 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TDHxl62FuaBBW868WBysHFe56KqDHimnr6L/6HTDES2o6d8oClq9cnbydCPYzy+VB24u4FyHrVQUkrJDEzO+YSj+Z9KZuanu3k/WNONdTCwL/krlE8zEk2gkLU7ERbqQbKaOBfG59hbGyXRnnKmcUpSwDoTWRRz39nXKGIy+EZNHP3s6FD4qV9gjM1QvKHIVInXrhc725jbJWqbLz+1vEkD/o0GZG4sL1Fpve65J9seN6QLmREA8w/fJ1h27XR/s8h1W1E5oExasoZ3/ZDAHKO2p3noZ/SakZqjZsuMwlR9iO1XZqKP1DanOFi8NBC4Zf42AXzlQpblmpJTItoH/edTuEslEy+ebxpBOyDFYSi5eGrKfnXAkt85gVlqtI88un3GH1suhZfTpnK4IkfqmoE79Qgt3KfDUdbYV246CJQ1c1RypTMRowYfPlU+04ccrlhzCKuaWad4Sp1pUKmv+AB176zLNE+GSQdRZMyZPFuwHzH5zRKM03Wm0c6/qyZTwMoQEjQ+//pHh3vairO4TtOPmssKwDUecbEFMztXF4pqVlYv8r1v8w07RH8K9p6FtDYwgEIY7QAdzTXsc/XfLK6X+rbfpAm2nGISvEaBlvsxXTDoTWHBLvnTKAvH0OxYo 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)(136003)(39860400002)(376002)(346002)(366004)(451199021)(8676002)(6916009)(66556008)(66476007)(66946007)(54906003)(316002)(478600001)(8936002)(44832011)(7416002)(41300700001)(5660300002)(38100700002)(38350700002)(4326008)(186003)(83380400001)(2616005)(52116002)(6486002)(6666004)(1076003)(26005)(6506007)(6512007)(86362001)(36756003)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: q45ZhJyBBfyUoQ9uXGmEnJmfDwrVsUjdCQKy03GPS4mdNZImFF9KWcD47roim+HMPk0S3mDvG94mWHUNIPPhzr9rw1BjC6eEqs2dQPZyGw/tmkhqju+BvyeuUYWmu/K3viUkoAICw7WUlVEdz923QKvfcHTDZGRP+8+X6JND8s4HLhd2ERvuFzcM+8zyCWEI+/bKp5UezpRm1YD3X2/idm1hlUm7KJ47qgy4WAfprNFLhbJpSBqRlxkqA0XGGbiBwUUam5XhAZkPyakiCS95+HFx3K1DI2PcGTRSicpGlnzhDdHDnuLBru+QOUr0DRrufGC3Nm+wy4MuYGJK8CUy75+pB0+IkusTNQsqQx1N1A5UED77Hm8XE5Rd6iFYtMSOYE6f6StT3S8qQ/592++RsgWV++6mr0vbzWAAtIJduF5/SFRFxjw75MnMS/ywrrgeHCILJEDFSqSgOOGHAwCoRy4uA062Ivp02iGDoc1/TF/5/d3f0/k/U1aQpLnksCsJNhaH9syqaC6KAm0Z2VAL+sniIZGz4iQVa6lUBcp4GTPdY0uaEw1IRr5Kx1Dl6pqeOF9RAg0dFHREY984tU6VNZ5bWRstPMEMTwadcHtiQimyRXQfJzKow2kiwbsp/IvAWeuuRfBbApSU/UnTbVes6q5ILH4D1vPe0adCNfAFZse3SRV6zjvOmlRl+tBdC7cRrg5BSd+r2eWd1eeygIaCI54hw1o6fBR8/sKUP9glVeSNL0TAX/N0uSxkXmdSudq9hmHzh9rYncVUIr56qgFKp0fzkQePgX9hZRHTjU11p8GYAbJngZ3lJWQYJ6xtPYyl72Vq4mT+DnGU0Tpxhxb9otsy8F4YOWLEB5PulWWaLz9J6uZ8M0cMpM8rbdBb7LdQ0oUENG0u1ZKNJlJCP+ccEv3UjJEuLaFutXNsCoYUFt3akmwvKRyDIFI3SXQWSzQUbehZVA+j5cs7oNDXdNWJ04FGl+wiaXwMKY48gEbjRcZRidQi6XeAOyjqyze5TOvMDZDyEjlaXUqMVHEHWX54pjVEHjG68oPeUtQ9/5HpcSlLyPMNBIgYzBRJf830TXOkbnvkmWvtBlCxHTbcv71ISOmM/fAt04Kd+xAkR9dIxOc56nr0g4ZNN4PEOcQ72m4uox4iXNaEfZWWgs2bc4prHHkLv6v3cDkYJK6pFlXegYPk/MYIDkFcST/Hd2/MoOUWWFpsv5SlQrfnF9lqoHscB07R6e6ZZRp+H0zYlwKP1aUejSAO/VLWAKHmgD5ZK7g0R1DEOcWTAtznBF3Cohbbev3oXNXDKw9X+GItE1Qp8hRVKj/ChK1vtLAQ8Gi2VKgpfI/r8zWVhp/ClUh6QciMUw8usk7zkIk/fgqu7YeFYuK5Z/g5qCmrhItFLfssPGL165knltgmrTi/fA4/ic/8DajZPFypxXNQnQOr7fq5wOnijPN/tB+P6NHBBRRK+8XA1mIpz7eoVuMf2HPmCMZ3g+hC4i5fm254S9ID30Yw++5YXCgmjRKqdgBEIv8lkCw8XevikXaw6qnReHmE4+P9+8wQ/AeEyKLa4Jrdo1LUdgPALP0z1/yoC7hfxehVsOYgSFadLUvhgczEuFe89R+URw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 920ea710-592a-4d66-79ec-08db342f1a91 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2023 10:35:11.8878 (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: rP5FP6wUUfnPJYdugtGpzNNGBqF5TdFjilYV98MnEgJHF6R+IVqPPdincZEI4+3I12n3FhLBR/ERQPFxYD6ONw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7536 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->v4: 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)