From patchwork Thu Feb 2 00:36:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13125115 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 7D0FCC636CD for ; Thu, 2 Feb 2023 00:36:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229770AbjBBAgt (ORCPT ); Wed, 1 Feb 2023 19:36:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229748AbjBBAgs (ORCPT ); Wed, 1 Feb 2023 19:36:48 -0500 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2071.outbound.protection.outlook.com [40.107.22.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA5CC728FB for ; Wed, 1 Feb 2023 16:36:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FGGQZYMe9Rk+8ogMmi3feLvrSSaPq6iUqvODaSvhp885JdHc5o59w7XlGrKHhnPrgytnMSbnrjx1tOakOza6t5BgNkFtv9gOagLH26gPcQjj8JF3q/Oyhq/7K+RZY2zsJbYRsGqgBdFX4l7XgDHkqTdH8l3Hs4W/239rY8Tj3l5S6RSVdNlTwOg65iEPiU9+WokeBmHMYHr8+BIaoPLgyhVVv9tag94NiIb1wTbwfDrPNPKcIjRe8LqQG+I0/S95z0Ja4BhvTDQN+cbTgDVxy4mZyJf1AbmDFrKdseF/XIydQuCL1j2Wt/RDHk4fX1iwszCHwrCrX1jcnaMLdiVsMQ== 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=JzvFRB36DIVC1OPSD3f2i/e/n5whkwOblsVCFdWt76I=; b=iBWtUSqmXPDELj9fO7/O+pr1aAm+25TeMlKNXXCLa4bpxZtjll5z2xl1SA6RoujhgH9wVBHTmtUb9nh0cOmH9Q4CLidBBhNKFK3xE1DMKZb+i97HT1SH6X4tET80LMIa6vz4cYKozMTabhoMmveCWyPW9pDZcGtSKIDlyG/EW/YgBcI77XB+9l/syB1SLVr2NTCu2GhP10ABmRGEb03LL/HQOvm0dQtht3Z5UYF7+rDwZZU+aaiNb4Wxnzg+KSaoOgDnRIY6HFxADgLYV/YS4IKlq+bbBeN3ArEWvKgOyJB2gpJTv/CN9rnWsKBbE75KaSUmnu6En67Ilirq8rA3kA== 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=JzvFRB36DIVC1OPSD3f2i/e/n5whkwOblsVCFdWt76I=; b=DAdoll1Uc8tC8ziSffbJ17a1vv+qKS8A7P6pXRgx8StGIPvN1eBtffJQOpk5JDVZHnfH1gwY/FTUzpJsCdQCMJsXFkrOokFbYXuBMpPw8NIxtQJ+oM2uaSr9RezubTPvnNLffKwXbgAiFc+fAcD6bLFpr4zbW0KtlAJRQQMRLKA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by DU2PR04MB8789.eurprd04.prod.outlook.com (2603:10a6:10:2e0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Thu, 2 Feb 2023 00:36:44 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%3]) with mapi id 15.20.6043.038; Thu, 2 Feb 2023 00:36:44 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Vinicius Costa Gomes , Kurt Kanzenbach , Jacob Keller , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Simon Horman Subject: [PATCH v5 net-next 01/17] net: enetc: simplify enetc_num_stack_tx_queues() Date: Thu, 2 Feb 2023 02:36:05 +0200 Message-Id: <20230202003621.2679603-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202003621.2679603-1-vladimir.oltean@nxp.com> References: <20230202003621.2679603-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0032.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:22::20) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|DU2PR04MB8789:EE_ X-MS-Office365-Filtering-Correlation-Id: 8bc8a0e5-2b5d-4d06-6aef-08db04b58f0e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0z0Mmk0hfcp9I3RjxBg4gB/Braoomoasf0KzbvcngQVotsBsfjFkbCL421rBzTMfjCuhmGKWTkihXsqMsj7QrCV8h2nt8Pm4CJonB91TTv4FcsLlTyxWjQp6biB2cPXDgAciHQeK1OeeQtKtkcvosoDOkWOpYoG9u5UUhRpfYnpNmoETwHJ88uqyuohiYiYJg/WYl2M2X0rQosYf28iRinHonLJvEnlfgtLKj9hmLDrT9ca7hlRL0NWdYEtQG72UXhvwseBKgRroNcW6ma5I1INiTIMjiXZGRz5031Z0HISjKDAlFvj7fDZdC72sdBK9DdQNEvJYEcsxn7krkBp2dbbCHzQbgC/51U4ffaCEkpca+Ov51tI2+WKcukKUC+wkNWnH+xUYvr4B/oRyief4EekptZSMMKqgcTTBpS/jgkYbR07porxAtVCh22pnbhZl5oFLG6UZQJUGQUmY4bmbuzTzi1BmDKoEY6h7HK8RHIFpgPjFdm9LHgMl13edBVPOP+N6NyXQtHIyIjA0E/RsHWkXjz0RqZQeyNtgG70fatwNuHb4bD8VWAJcHKG0aKWGW80ZbobiWqII48Q6NjdV6E/3N+n/fMJRHo5nsCNiaw9blYFM/hDB5eUdnr2XhQ7IuydNDgV6SfBuzv5k4sxsmY69Brd3eTgOGEMlPKbmeWrMBJgGaSvKDZie4uK+Fi6EgJCZ1QEZtp2m0U8bjrrE7g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(376002)(136003)(366004)(396003)(39860400002)(346002)(451199018)(36756003)(2616005)(7416002)(6666004)(52116002)(478600001)(2906002)(6486002)(38350700002)(86362001)(38100700002)(8936002)(54906003)(1076003)(6506007)(66556008)(8676002)(5660300002)(316002)(6916009)(41300700001)(44832011)(66476007)(66946007)(4326008)(6512007)(26005)(83380400001)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: I4qW2TN7prhmkF82kNMgI9h3CJoUZSIdtyY+rQUSgu9mJY3rzzCqrCF923BF7ycUJgn8zQTRme9g0mGQpDCqEqqmgtACSA+nFsVB9YilGNIzkBUH8TMLNMINSzBqaL4254ulGlwrokCSBtzUPYiy2k7qCdQ7Qy6uKdp0dO5Y+BxGCBnY6YsVSDMY5OXci3dTFcr+tXhwYNZ++0Gi+XJyGuICJZRU5c7w8LiUGKEgvKmzrPq+vECvI+pdnq8dY2MQMZBU/QLfnmNR4F1X17de9HIEhHh1noyT+q4qvwn7e3P7AycmKfy9UiEsm6UxsLwhRj/Mht2LzBYVOPfChvDrFxfQvQU21tBlHLD0HT1qx6O2dzIlQVoPca+m/FPIIhmSdm9RKRI+loYDHhPvmvgkohUm/l1n69i6CMjeNcNr4b6JMGb1BKFh85lA6gCcplirZcwT09Bp1HtUu65TjlPBCVOtBAhUDB9wpkA1vebtqiP4N4ngIKOjyXE+iCgDN1IlEStuiIIxx5zuNu/QfS1xDUkavssBxG/r5Gae3plXtlO44nB3w+yQYqC4qL7feQffFYtksrkGcCIb2N/frg5o3h1Rkx+qBB9LNNQ0bXIHr+GWqcs41hFskpZQ4H/eQ/HLeDhotCFoS61WdfyEqcNQ59dYxWMYBMYsYvao84I45QkR69Moqs2BzmDbtdlARVe3wprXZ9S0PgIX1VvGMfyDgW5MaMv5YlZPE+VzD6p2XK5quSsJrKMp3wykfGME5Q0KTGMyAs7xHUuLXOutCX5vxyZGYFZQhCPhL0JTRQ2V9llHoXdq7AZxubNXGdQzyelKWErcZaLJqMRC90u2xxk3DLxdOan36xzYh3un7CTHZK8z51/KbuztbRcbKh0nwI+w1xP4puRz0+dKpvJvaFNW1jul0DFiJnfdEO3JgUN416Jc7LbqDFCyeqXBeyyLNWQrik1xbG5CnQxS/7PBN9u9uPAhjU5V/glSwWmT8ZFrDVMGcpQSW8DVkQoTHIBo7/Zw/AUbfqvFink3pdpBrCveeXhdbXdXTjgqwb3hXDBYBrpIiLIrqqxwuWSazwsIxcGXGwlbAuUkjox1UPfV5frteQLNWjbfV67s0XGyTt/0kMpjJeZqFHSTkXseRiWNj0e2c7zgugv1Yv752xdssdeJM6xRF7ObM4hVq8l373vhzIQx5Ik/dYmuQj9XZf4QM92keMzlAAL+dI6S2ElOFcQ5qXtJ3cARlVSq6LUGP1sfreUh7GH//KqI2/lcNoUQ7kU5pbZgOPBGxcgEjE3nmJTRWYRYQXBBy6RimVcaKjLvnhldQHNaPhbTx7X0xaFVpLMQTbzs7phBP214Zd9RZTA0oTk4pCnqJyBX1/zPOKEb/liKfOf7a9yrtcP75eOxirjhCLeO9N5jjgOwEwu9N1nMYMsUPZnKBeHq0+CN2WjKRpW/GekTNaU2FnocOue0VHKKALVpTsSbT/p2FNsjkhKgenpyOy8ew3YUjFrNQb50OeNhcDSo2eRGS/+qD2J/aKNdmit5Szkv5w/UvgwQOCGBWX+YnnNlDvd/dI4tEd4qbMzSnWiBkSMyJQq/FnPHcTPJ2RbjcW2aRHoZiMSM1ROdkw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8bc8a0e5-2b5d-4d06-6aef-08db04b58f0e X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2023 00:36:44.5453 (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: qlPy7EnDMBKBw57HZx4z4F9BgkTRxand1F3lfSRNCahFq47+hB7ByUVODCHqeqbGCDFXdfpZhvfvOozxYMrctA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8789 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org We keep a pointer to the xdp_prog in the private netdev structure as well; what's replicated per RX ring is done so just for more convenient access from the NAPI poll procedure. Simplify enetc_num_stack_tx_queues() by looking at priv->xdp_prog rather than iterating through the information replicated per RX ring. Signed-off-by: Vladimir Oltean Reviewed-by: Simon Horman --- v2->v5: none v1->v2: patch is new drivers/net/ethernet/freescale/enetc/enetc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index 159ae740ba3c..3a80f259b17e 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -28,11 +28,9 @@ EXPORT_SYMBOL_GPL(enetc_port_mac_wr); static int enetc_num_stack_tx_queues(struct enetc_ndev_priv *priv) { int num_tx_rings = priv->num_tx_rings; - int i; - for (i = 0; i < priv->num_rx_rings; i++) - if (priv->rx_ring[i]->xdp.prog) - return num_tx_rings - num_possible_cpus(); + if (priv->xdp_prog) + return num_tx_rings - num_possible_cpus(); return num_tx_rings; } From patchwork Thu Feb 2 00:36:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13125116 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 97441C636CD for ; Thu, 2 Feb 2023 00:37:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229929AbjBBAg6 (ORCPT ); Wed, 1 Feb 2023 19:36:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229761AbjBBAgt (ORCPT ); Wed, 1 Feb 2023 19:36:49 -0500 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2071.outbound.protection.outlook.com [40.107.22.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E69DD728ED for ; Wed, 1 Feb 2023 16:36:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QdZJKOR0JP4WvIgw3ikuVgzTux1Pd4YYtSbTYZWfcIvTWlrykUN/IIEpaH8PTERo+btDXunb8y8tWBngQlqTZ8Ukj4jIAJinm6RevSff17EUjlOvsPMZv/Lz3lMhrGMvV2WNXc5LHqoHf/A7WQ96QDCTFSKQDXnSX/yrbLl0DKsWfpMQ1UvMK9RSQeuhXq/aoA6eJLvk0x/qQClZhIM5oCHSWZZWKqPLA2apizFUq7AuP5OZUcDdbco5FnjzFjNo99rOk1UNiWY/1xhlLLVwnfRZrisfeu6Nhm+YVivX7OyjV6fpeuk+WixpkLLcYrzn+lEsY9YANxc5vbzhKjAJLA== 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=hUkV8hVFtLj8XSHhnYa1NuwQqscyeHfh3LuHvJhwsi8=; b=hpfohRjuqQ7tGbWewnSm62DDQB03zOHelYKdwTjolqKH8qUNLFNyrJYtjnX79Mu04afCV1VxT2ezrvfaD0rlBt+l8dcoSGsL5dUqJGW5/cTbu0NukF02wlz4cjQHTJn1G5H9/evkaYpvJwJhc1CK+Odmj5NX6CU8ehk5+0thoxu+3nMqLcdWG7su5qcLkzohCjCbUhVuzqGWy/HRgvF9y1F6jSAu8y47K8QlqG5NQbvNWmKEwC2g9WS0oyTtcAIeFXKXiFxhn+X10EARtd+McK0QDpwniP0whtOZ3Gr+iq75NtKuer+Vwp/L9jQkCqxRKvpVqyyY04qi2b6HIaGvBg== 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=hUkV8hVFtLj8XSHhnYa1NuwQqscyeHfh3LuHvJhwsi8=; b=g+81dO6DDZlDeIkdwzfgffaMoi9uQ8HF3K1/Fiwdmb1rfkPMkllMY+LoCXitTB7zpaVuDvO1Vt61ATZo+YkeFMwN56MUgkXbz3WdcQFisLCjhJahRjOhXqHubvmLtNyM1FRXmuGHofFYteYBENgseEGq5B4jDGt2CwqWPP+SfTY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by DU2PR04MB8789.eurprd04.prod.outlook.com (2603:10a6:10:2e0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Thu, 2 Feb 2023 00:36:45 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%3]) with mapi id 15.20.6043.038; Thu, 2 Feb 2023 00:36:45 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Vinicius Costa Gomes , Kurt Kanzenbach , Jacob Keller , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Simon Horman Subject: [PATCH v5 net-next 02/17] net: enetc: allow the enetc_reconfigure() callback to fail Date: Thu, 2 Feb 2023 02:36:06 +0200 Message-Id: <20230202003621.2679603-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202003621.2679603-1-vladimir.oltean@nxp.com> References: <20230202003621.2679603-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0032.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:22::20) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|DU2PR04MB8789:EE_ X-MS-Office365-Filtering-Correlation-Id: a4cbbd67-e130-4e8f-8413-08db04b58fee X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oirv59xsPe4V/GoTp29IgJZsAqw5by1gK3U1CY1+cGDbOvQf+cc+cOjX0zngayaYicAMlTK0+FvLRPv5lcaWCjyMateasvQ71swICOdIMA4+Hhr7EUM5ERiDjTIhgIDwPhTyFDo7yoBn4ccWvm3dEm/d0ELWbIVZcBsEcuoeTigXd2lxt2tL5Dj2iADj6ccqJvpTmuzB0V6LEOyEfS+iK7Ig8/DzDpbZabkquGoJ4bFPAddAg4ucakmp6wVK/tMvOutgDDRUorXsFBQHcZ+dZ6Lj4ri3lFW5uoyLQAKASYP31quwetpbwFo0qZZO5V/bdbJB1JbQ1SV3ie9KA4i4H24oO7mqU1/dTDa/N7/4SHKuJplID1Gtu7wCjF6ncaSvWqy5pfsfL1TGhlNoTHMMWImK1Q5L5QQExSoybvko1LK70cILXqaq8mXXbB55vgag5cR0PLcPGOraKGci0EPqyyZS7qZV6RDblyj6K2RgNCdtdchqYiZEnQ5ebrAEwG/kbJ4rLcfB/lqWL1B1YFeGaYDtq59dh2qHlAi24yS9tPJVHGBV4K8a5iZThX4QjBjEKUmZSWyekESSe99sUfm4aFfy4dN40+O5/SiRARTD1jF3vCDmrPopReZJZm9Pl7AqB29irdEet69qWKGitZx8iXy3foAnHq6JTr7gOe4ZfDPVO3UPke2GYKqzsrL5Y2bLLcXMNmY9/+J3JoQJjqaang== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(376002)(136003)(366004)(396003)(39860400002)(346002)(451199018)(36756003)(2616005)(7416002)(6666004)(52116002)(478600001)(2906002)(6486002)(38350700002)(86362001)(38100700002)(8936002)(54906003)(1076003)(6506007)(66556008)(8676002)(5660300002)(316002)(6916009)(41300700001)(44832011)(66476007)(66946007)(4326008)(6512007)(26005)(83380400001)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6DuxcsDd6Vd90HHmbkIJGLrvIuPjVwU3wyS0NwHiNGtfLqIYCEuevV6vcYBXzHQFfIykIhFa+o875wAAeejt3BTDdgrioMJ/kThgLs8vEdd3L2BSgc+fdyoWOs2W7U6Pfwvkc/OF6AukATaYFCkotQbChBj+FHD3JFOQ9+1pYHbAO2uNoTkhUokoIZ8W4J65ztgeGBocpZhpUyFBwVE3XwgpPDtiiHvrf3XvF3ARDFdUh6+RQQKQovnZg1Agjc/3idPY4xDz+O+706Ag1Tjl1lUM2pVGPD0En5+fGszCtdR7nHJ/SkIB/Z+i2uYnD5iktJeqH38UoqwHSgpBoVRjYUcOWXLTo3KlWWXL0NLbCpSDlgxpIzRNmaRiQQBK9ArhFbrHLSDn73dvM5LKa/tLYjAJhEyOkUtwx5p1kdJHDnozHLBg976AkIM60Kf+wmr41wOf8IL7Qn0MxSfyQ3qpqygVSlWbv/ScO5LfF5+QlCiAVCi1XhzY3OFcLUhz7JnJd2prFxGNpNsa06I50wQd0V4iBP9zQ2FX6ZOmaVgcCY+VSsbOcC4IKy6Ym/fYJaII/Rwxq+xjZL9hF21LMOzFGO6ydoIanKkwtmE5iSobU/mPuCWewkXYhBnWuAw+V/UBOTfnYu75uSba32DBD4ClUY7+ObWb+YS3tqynpm/NOXxnQqwO4F/1ZlxWLSPHpAJjHiSo7cGhQqIk2JKYGfMM4zJ/rPda0Egnug4nayC6FwaNOzFWeqYyZHspVd7hjm7Sh2qLq/KfwgxrwbwT0sQj40KqBARFVFV/Lm22wSpYmKieg+n4bxQfGBZX5n+BjWKdoMoWz+0NgLyJc16i2zKJEujJKKBI8dl8+Xa+7/BVH+Py/yaMnSLfi0wKQS+IPB+sEDgd2FMxTLK1aS0GQgP6/1oAWFuKqUgKJd3TLsTY3UkRUBzoah1vHBYEqG+OEuSMjrgSR/5mwkmpIXSx7lsnrPsVVhXPulJNYeSoZekvfk26D6qCf8KtarjgFoAZw/TFVs0KmO/UKvqQJKPRyTvvQYvZFp2RCmNtc5AiV+3wS8aVDEqxMxQFw1J3g8wC3TEL9orfQMal2xKXjBsPr5T8qmt5BpyV2PgBBZzA913HVuTCORtvgCy5bXKFTCGuw7+Q44JsXlQ4JfTGwRYWtvwsGJM1llObP136MwwgVHHIX11d7CYOqSaoNTwSKJ+P8jeXevFDDZrH4gGIuZ0PFUR6Alb7mIscatrz14sdWhf6OkqgtnzzC4NcQ+xPyl7p5Qsqzs+icL9OU5mwXkzZw8BRLzSkXPuQbWJjJlXbAjOxRLNW/qLW/7n+7BKJ3aR2i3WtlPdVkO3e9g3qXtdh8i0klhSjbI7mkL6MJX3NJZWHowE4F6FtzbIAvv4qInSrKkSbkKLIRq0xkfct7j0sVM4DMhtIEHmsnODyObjrKZtqWaeF2a+GiA7wtBV53sz6ixTi4NW7MM0z+B/pRkgkxRsBSW2GI+45sX181e3fvDl+ln8SZdlcJ6x1UAS0CBAfjJVMBPopzGVaYztPwQ54mq4FIynKXxaIkZHsEP+XPibsPOtR+tjCNMqPlnj6Cyq0rtIwWBa056quDGgYLbhiVjAJ0A== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a4cbbd67-e130-4e8f-8413-08db04b58fee X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2023 00:36:45.5140 (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: 99o0Sy5vQJdfPCjxBO+Ukqe0EW0hAfGWnYhtNp2C488L90fJNv/PQO8AglVnaP3ePJt2aGl4H2cgbjQReM0fuw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8789 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org enetc_reconfigure() was modified in commit c33bfaf91c4c ("net: enetc: set up XDP program under enetc_reconfigure()") to take an optional callback that runs while the netdev is down, but this callback currently cannot fail. Code up the error handling so that the interface is restarted with the old resources if the callback fails. Signed-off-by: Vladimir Oltean Reviewed-by: Simon Horman --- v2->v5: none v1->v2: patch is new drivers/net/ethernet/freescale/enetc/enetc.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index 3a80f259b17e..5d7eeb1b5a23 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -2574,8 +2574,11 @@ static int enetc_reconfigure(struct enetc_ndev_priv *priv, bool extended, * without reconfiguration. */ if (!netif_running(priv->ndev)) { - if (cb) - cb(priv, ctx); + if (cb) { + err = cb(priv, ctx); + if (err) + return err; + } return 0; } @@ -2596,8 +2599,11 @@ static int enetc_reconfigure(struct enetc_ndev_priv *priv, bool extended, enetc_free_rxtx_rings(priv); /* Interface is down, run optional callback now */ - if (cb) - cb(priv, ctx); + if (cb) { + err = cb(priv, ctx); + if (err) + goto out_restart; + } enetc_assign_tx_resources(priv, tx_res); enetc_assign_rx_resources(priv, rx_res); @@ -2606,6 +2612,10 @@ static int enetc_reconfigure(struct enetc_ndev_priv *priv, bool extended, return 0; +out_restart: + enetc_setup_bdrs(priv, extended); + enetc_start(priv->ndev); + enetc_free_rx_resources(rx_res, priv->num_rx_rings); out_free_tx_res: enetc_free_tx_resources(tx_res, priv->num_tx_rings); out: From patchwork Thu Feb 2 00:36:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13125117 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 5BCD2C05027 for ; Thu, 2 Feb 2023 00:37:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229973AbjBBAhA (ORCPT ); Wed, 1 Feb 2023 19:37:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229748AbjBBAgv (ORCPT ); Wed, 1 Feb 2023 19:36:51 -0500 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2071.outbound.protection.outlook.com [40.107.22.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16AD873758 for ; Wed, 1 Feb 2023 16:36:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=biKDtlLjemOvTXQKkeAM91tpJXdJPMPSkgv5lTx8gwVMoiV9chiSoRxus08v9pyoIuYigbQhd3C1OrpNgB+Bx/eCT9ut6nbsdKmC0R4QY4jujwIjChov/Hbxg5mA6sGHnP00PR8jb+ql1BRxN9V9ycXdekiMMIPcsuKTuQ0fsoF8Qbqda8aUj/zEEHMkN/Yb7k8hS2oxDUzID53HoZVdlW73Aygz6y9x3UQiJRgomHIIHhBjt+5gDaU6CX9lAv7y7nJ5M3ftek3hK7fnUL7aQafuFMi993M6td+gKdD6nlR53JFEmkjMnfJ/drmPCLAzyDySjTfvEoVSawrNKHLf8w== 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=TTTZTvyVNe41cKDA4uBXDcAKiM8yQQaQ/28SH2xi6KQ=; b=iYlNEXNzV9l3kTOUXNbKzyfJ0Rgm14y/hjNw7dLPULfAVLpOxASyKr7A/PEwtRwz4mFjCCtD63XJqX+kdO2UcYwn0wadIx+kCq55Yiikf3Wh4NbtOGJVALMXmRp6rOIWOVRmAprAEVEJsUQMXKeLqTOCKNYIKl9BwcPOPQVS5fvFtofP7dbSeh0wqCkYypQXH+l3z6afDThGB1vzdN7kHjroxPl7aZ08520TrlsMB5A2tqnGESZLN8CJrGKXKu3fSxGhCUM9BDqYVQyMzmRyLyKiMyy2REiOoKM6SEE7MJd/PKuZU+BlR9Q7GfyHqjjtsXhomoalxWDl8+VGfkok7A== 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=TTTZTvyVNe41cKDA4uBXDcAKiM8yQQaQ/28SH2xi6KQ=; b=BaZ0UtoN1nKGfI0y7q0//eXBTF97P0n/atD+BXd7Wlrcu6M5he1pgETQFla+wpOq03gERETB/2XtxOsxM5S/pzkLi1+1iTE1DRo8d38htI7Q5Js5mWUmKq8pVqVswbMg7rcsRpstMzZcA/sUoSLg5Q4Br49ljz8IWGheRL/dxiE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by DU2PR04MB8789.eurprd04.prod.outlook.com (2603:10a6:10:2e0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Thu, 2 Feb 2023 00:36:46 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%3]) with mapi id 15.20.6043.038; Thu, 2 Feb 2023 00:36:46 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Vinicius Costa Gomes , Kurt Kanzenbach , Jacob Keller , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Simon Horman Subject: [PATCH v5 net-next 03/17] net: enetc: recalculate num_real_tx_queues when XDP program attaches Date: Thu, 2 Feb 2023 02:36:07 +0200 Message-Id: <20230202003621.2679603-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202003621.2679603-1-vladimir.oltean@nxp.com> References: <20230202003621.2679603-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0032.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:22::20) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|DU2PR04MB8789:EE_ X-MS-Office365-Filtering-Correlation-Id: 8dc755c9-b3aa-4821-8f06-08db04b5907d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xjs/gbfpx0NfS2v4pYfEnOhZjtUfSuGeUy/RUmSRjxbXiE1DP3cHlNRQx75+pfmWirv7TdOmbMhSaSHmbhe1VuJUTE1LiKZT29XWIrgbm+XEMRu0Rkk0FBWq5PIYdXzfVnvBfYVx43P3dmJkONBaphHhReSYkG97NrZTe7hziPRXpTVMDlgyGdJm7yeFqi92uasuZC9A4BHSKh56TuHr4kT/mVYx6L2Z9hapah0Nj+rXWG3i7hZURHg+K8t0rw7T85fBWL3ZqUSdC8P23vR9hDQHvrgcquzKD/Dcpuv6xm5kMxMc5F2lOhAuwJ+SyjFSzeev6Rm1xEHBU0OuCWNYt/utFPCAQV1ApaYUvlO4b+iU79D5hAbvGa9ih0jVdceuFq1lIIl+RfsWgF9j4hVLV69Zk04ofVynT9VoegAUsD9N+y9cVp2KS9KpbZHveNX9yvBDgEZ4HNShmR6JsL1EPJOLobLkpLurjDCYAthBhGqpBPWe/I2Jvo6BanZoeYMsphJnGckMBH6bTkvTRYdGccPYyttlEl6FsaILcbgb7KBDYQu5FhBN1e7FpsD0NEiWT4WtITc5cifl89R/7V6IGoNypEKSylcFF7/hkLt4PU6o7m7+OxeW+Qx8UktzmwLxhloezF7PRNLBbdfLNePTdGU/+Q4vKPoRU3sfYCLe/kWq1G8GVaob1yurgWtCD7FDpgN/b97hSSJaAN3N185Raw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(376002)(136003)(366004)(396003)(39860400002)(346002)(451199018)(36756003)(2616005)(7416002)(6666004)(52116002)(478600001)(2906002)(6486002)(38350700002)(86362001)(38100700002)(8936002)(54906003)(1076003)(6506007)(66556008)(8676002)(5660300002)(316002)(6916009)(41300700001)(44832011)(66476007)(66946007)(4326008)(6512007)(26005)(83380400001)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tibdi7dNyzemsE1OYmqYIkKPdoA2hc7VSM/5wyncuO6O1L/mC6pan/aX1TfurropoN99oa0I7qE2xHBdgCKpGKNrTTt/io+U+eVjE41LDla6ujxhhdTPbG78B65lWUYUWJFhOZIx9b57gWycnecOBvkPi3rVQ4nHBG7Y6M6SQmok06hrKParL5VK2Ztf3tvrMpIMKEzY8WQRi99imVzh+N5+o++3077472wv5blyZSAHDfX4w3aPvDzFfWyXCSYCVcxJ2rwYuRLCBXPmMZ41ftJKYPkyLNzpFwGGa/STlCHIkxefoLAbItc/afr25Ck9l6s3pGtv76C0jVPj3vlFvHShfU57v6NM+tDlOFkKmmUKrla+LkauYETa0zPEe6PeAKryGV/vIYh2JCzjyYQKBskKyHem4/kfuF6nVgXadBGfprb1iU1Hk2N+ZehcrfFgvmd7Pl4Tp0alGhgr2zW8SSxBhAZNe+zGx3iqDvwl5R8NKXICVQG63ITGeGYJLuWwW5cpTEamPvw392fPCdw2GuiuzOH3zd+LS+HjvAVTaaBGEA7Ja/b34dT5Kq5YGrxiJ2NeC8bpEqboHIAdTzrwqIGT3zG8Bz6X1P5hQ6qEQvW22NAcmtOeKbAtXXaJDQrJJbxrcBWPCEG95T2aaBt+KtvWNVj5crB3qn7uS6Op5SEMhlA/69R5g1tRfGQEYXbODStO9pD2WODBJ4ZUG86XGOzOSVePvxp1Fg9k10uxnWbE928a/LYq7qzmudsb3YucMV9583RQTBrK7Hvwbm7Fn1st7xvbuPriUtFrlKKICuEs0bpx0IQ8kOEYZvcV/l051zFPg1UTlR9jP6720CLAbg5ygwnDUgr+L8zLSlGi5z7KgBy10sslC1HdKGajopaWkZdIJytIEh7S0H/a/soLHF961oiFgWuiluFk2XvVy3yNWLJVhnduXIz+uzzjyQVtDMj+WoAE0P/FA6dX9EWbp1c710xMrHB4tpdL87uFyTKLVms7ToKZNlZp09/LgPapS45dgWn/uFtB+8zuJSfuqMO/U8lYtn4gfGUMaqR26uX6iOwg9GRvlTRXFDRGa/XzvVqyzxu89WptbcQ5cYRReqIgWY5cbj8BMNXzRZDoLXxTFapoRuhow8YD6qw6lD4JFf2kmfZM3E1D7sMQUM8QxY1JPZrf2CwNf0SWZZikqhdaRus92XDooQa8v3hhZWlAFh3VrOS2sB3YEMoqjPSSL9s2dZW+jZzYBVww0A8a8qvLJrTyeP7VWTmbs0vHaPgzKxxs6K3a0zIrmWY1zNUkY8KqqIzqgt7ytsK8oBuGEbtknQolp9juU/7+vNT2aez0P+SoKAw8+DGMXok8iomBgl3B/zZErrOy1yeD+kdQi2Zq5g5zhsgL1lMWMbvogsK95Dy7oWNU559WayXK/Q9hxWzl/a7vr1uuEMMRYgrH5xMur9R4f5dom6hK3rfAkkx0fexPoLwbniDQePZ/6ZYICpdI2m7g8GhJ+8Lh+zOMAmtYUoz16996MP4EAUmXvxVBJtn93bpkCjwCcsAc3+bcaInqgXkptDLW4Rt3EgprlDpmj/VONU9i2Cvdj/KlHjfCk8Pm7YZhD2vW/rrMTpiTKQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8dc755c9-b3aa-4821-8f06-08db04b5907d X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2023 00:36:46.6077 (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: WZ8obsED4KtsoWshq6TXqsFU2EsKEQYo4ApuoltRXCaZoEsyYcnnF7RRvcJ8sLn5i+xfH3uBdgo582MBU5jphw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8789 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Since the blamed net-next commit, enetc_setup_xdp_prog() no longer goes through enetc_open(), and therefore, the function which was supposed to detect whether a BPF program exists (in order to crop some TX queues from network stack usage), enetc_num_stack_tx_queues(), no longer gets called. We can move the netif_set_real_num_rx_queues() call to enetc_alloc_msix() (probe time), since it is a runtime invariant. We can do the same thing with netif_set_real_num_tx_queues(), and let enetc_reconfigure_xdp_cb() explicitly recalculate and change the number of stack TX queues. Fixes: c33bfaf91c4c ("net: enetc: set up XDP program under enetc_reconfigure()") Signed-off-by: Vladimir Oltean Reviewed-by: Simon Horman --- v2->v5: none v1->v2: patch is new drivers/net/ethernet/freescale/enetc/enetc.c | 35 ++++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index 5d7eeb1b5a23..e18a6c834eb4 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -2454,7 +2454,6 @@ int enetc_open(struct net_device *ndev) { struct enetc_ndev_priv *priv = netdev_priv(ndev); struct enetc_bdr_resource *tx_res, *rx_res; - int num_stack_tx_queues; bool extended; int err; @@ -2480,16 +2479,6 @@ int enetc_open(struct net_device *ndev) goto err_alloc_rx; } - num_stack_tx_queues = enetc_num_stack_tx_queues(priv); - - err = netif_set_real_num_tx_queues(ndev, num_stack_tx_queues); - if (err) - goto err_set_queues; - - err = netif_set_real_num_rx_queues(ndev, priv->num_rx_rings); - if (err) - goto err_set_queues; - enetc_tx_onestep_tstamp_init(priv); enetc_assign_tx_resources(priv, tx_res); enetc_assign_rx_resources(priv, rx_res); @@ -2498,8 +2487,6 @@ int enetc_open(struct net_device *ndev) return 0; -err_set_queues: - enetc_free_rx_resources(rx_res, priv->num_rx_rings); err_alloc_rx: enetc_free_tx_resources(tx_res, priv->num_tx_rings); err_alloc_tx: @@ -2683,9 +2670,18 @@ EXPORT_SYMBOL_GPL(enetc_setup_tc_mqprio); static int enetc_reconfigure_xdp_cb(struct enetc_ndev_priv *priv, void *ctx) { struct bpf_prog *old_prog, *prog = ctx; - int i; + int num_stack_tx_queues; + int err, i; old_prog = xchg(&priv->xdp_prog, prog); + + num_stack_tx_queues = enetc_num_stack_tx_queues(priv); + err = netif_set_real_num_tx_queues(priv->ndev, num_stack_tx_queues); + if (err) { + xchg(&priv->xdp_prog, old_prog); + return err; + } + if (old_prog) bpf_prog_put(old_prog); @@ -2906,6 +2902,7 @@ EXPORT_SYMBOL_GPL(enetc_ioctl); int enetc_alloc_msix(struct enetc_ndev_priv *priv) { struct pci_dev *pdev = priv->si->pdev; + int num_stack_tx_queues; int first_xdp_tx_ring; int i, n, err, nvec; int v_tx_rings; @@ -2982,6 +2979,16 @@ int enetc_alloc_msix(struct enetc_ndev_priv *priv) } } + num_stack_tx_queues = enetc_num_stack_tx_queues(priv); + + err = netif_set_real_num_tx_queues(priv->ndev, num_stack_tx_queues); + if (err) + goto fail; + + err = netif_set_real_num_rx_queues(priv->ndev, priv->num_rx_rings); + if (err) + goto fail; + first_xdp_tx_ring = priv->num_tx_rings - num_possible_cpus(); priv->xdp_tx_ring = &priv->tx_ring[first_xdp_tx_ring]; From patchwork Thu Feb 2 00:36:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13125118 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 BDD9AC05027 for ; Thu, 2 Feb 2023 00:37:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230000AbjBBAhC (ORCPT ); Wed, 1 Feb 2023 19:37:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229771AbjBBAgw (ORCPT ); Wed, 1 Feb 2023 19:36:52 -0500 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2071.outbound.protection.outlook.com [40.107.22.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 626EA7448D for ; Wed, 1 Feb 2023 16:36:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RTLWahfSHaoOkm5fUxoAASz12rI47OYpVy7Qo3Gq/7f6pHMlrBAoMvJC9jsjdLzFRc9igv7yHMaYkQuwA4q3YcABDjHEv3VOKDnUcH/DJ8RCok6qh40aa5vIt+7M0M/lC/GcXCxok9Qf9FKFMD9ddkDLkEI/jRrWvBaXZpqxvbP//6BXABWivnFn7HuVlSXLxZtH6tu4dF0lTwx4xqkFaSYpbxbrvI6UhlHvq3gr5e1RxrYLzL5sFThpma5K+sQ1weML5wNuY7l26TgsP6WzSqKfTS1V7fIuIXskzUljyEoNkVH4nzK7SGnCRizYljQ//XGY+ve/e3avbjNUxG1NcQ== 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=phRpJmmvFQyOX+MBbEgtVUQHxKl7oEH5uBFN0twIGEQ=; b=F0090w6RI3MbQwD99LedRE0gnFDzYN+sV4emrhd38wAGbnE37cEugjiwtnpD8HxWa2AbmNNzFImpTsy9HGUTsbsoV0xJx9e/62g99oHNUyRaNO3pQPg6kKQot8vL4nnauxHbs5xW+kQuLQvkZ3sOHa5oUad9Joq6t+R+SFDsdLIllarY9jNwxQci5rhHM0qjGSEtsPF/Bbb02GhckFv4vWugjq4jnQrWEIgadx1bPSO3SXPMdzVNP5mm8i5anNy8w58lG/XfFPvsudU/aOJLtctTK38tK8jB92n8X27FO3EdBxP8Oi0Vg8c6OxYMYZhEtZEdX2IcXZI1PXRtqefTWA== 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=phRpJmmvFQyOX+MBbEgtVUQHxKl7oEH5uBFN0twIGEQ=; b=ZdTzfNjljontLslTwjbMV//FB6p94ABduW9r1v0OGW+7UdvELyp+LtvBH3RYxKpyTSrBtLgO1gYyKYTQ0fUZXIzQWTxPxdXE4W6KSLr2h5Z2zkmbAVrVx8Zw4aCnYvPZoJRlpE1OHKxmTTZUHh5cuPMWZSLBfpgvmTOFD+UZ1Bg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by DU2PR04MB8789.eurprd04.prod.outlook.com (2603:10a6:10:2e0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Thu, 2 Feb 2023 00:36:48 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%3]) with mapi id 15.20.6043.038; Thu, 2 Feb 2023 00:36:48 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Vinicius Costa Gomes , Kurt Kanzenbach , Jacob Keller , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Simon Horman Subject: [PATCH v5 net-next 04/17] net: enetc: ensure we always have a minimum number of TXQs for stack Date: Thu, 2 Feb 2023 02:36:08 +0200 Message-Id: <20230202003621.2679603-5-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202003621.2679603-1-vladimir.oltean@nxp.com> References: <20230202003621.2679603-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0032.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:22::20) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|DU2PR04MB8789:EE_ X-MS-Office365-Filtering-Correlation-Id: 7d65b114-8313-49a5-df23-08db04b59196 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5sytAdP901PLB+InVW5sBTq514DzH1ApJOWJaLrTuAIHcNWRVsnm7QFLlJA3SbAaqYU8o3dsJkl/fgZJ6Wt9up4C+VBTvmbMENok7Wcdk9ygos9ylAYXkbm+7ra/62epKRMyK47ERK6o5fyleoCVeXxiCduR4KYFqKuMXzgNVzy3yBuzRE1UzLbEpXgA+7RFoK2Byog+zngwaL4O7VARXy1Uv1K41R7R8fFZAIPtDWsZWe6MfV3rE/eHcoYSZXei0zToclF061ocejOKKYbHloYlFGc6Sl1/wIXGV643MVZncVuHJVVrKhiMNsghGaIjpUmt3UmxsIbv/55InM6u7RbU77Ig+NY3n1R1bK9erNjNKh4zEAkPs3VkCzDUbbQ7LpTxsMujv7Z4ORTzEKlE5H6bfJu40xklupsABud6oYJ3GWBr8d28QffZNu5EpYy/W74FLGzZV8WbjyxyqPH7JAC/k+0w9cbhKk/mSEiVfIIQR6/SQSDRg7V3opKKCD/hsNX71wLIT20acbV/Q/AWl6yENWNLB/Oov0G3hOUOCWvHe5vCODhI0pKwigwij/XoaTV+gvjGNnnakIdB6Iv3g79Ita5WCcR/20rIZWr2dGgQuWiXlJ/ddp2GlQOCN109+Y6QvJThmoOveN0slOqgO9Ghy+0dJuh5Ampmy1R6dpaOysrfL+2DGmlsme1e9s7PKSJccK8xJtSmoa6oQIXxzw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(376002)(136003)(366004)(396003)(39860400002)(346002)(451199018)(36756003)(2616005)(7416002)(6666004)(52116002)(478600001)(2906002)(6486002)(38350700002)(86362001)(38100700002)(8936002)(54906003)(1076003)(6506007)(66556008)(8676002)(5660300002)(316002)(6916009)(41300700001)(44832011)(66476007)(66946007)(4326008)(6512007)(26005)(83380400001)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hlckUfHkSs4jdXZYx7OsJjRLZQflEiYt9jPirz8/Pcbnuk6JfLJuJL9I+s/Yd2U+o/7jY07OhxLqJugB0QW/rwVrWlmX3YYgZj470oB21QD1QSCrL8r7LuTuzqp922oOUko9WLed19ZlU/PdX5k1Y9XsCSD/UDXq4V5qJJ3pvMA/Uzpc1WljYK5nqWhJXJipi8/kph6ZWI7l8aRcRN/QS0u6lUVrMHIpNlOjov2uwsO8f1ekk+qH7GkN5MS2Phyp1h/1driqR23J0geZk3VOpVVa2eb1Y4zhFRtGFW9Mq5p9oqWyQqoC3A1L0ZMyZq0M6S5wrRvD0kj9wcQ60EN5YCRXwtqLwWlIaS3ALNuXO6tjqkO4jTv4yFrKKaSHCr7dANpVIpagWr1cdBKjj73W78Xbxrbg3oCE3/VzAtQaKI38iGD/sNMbuzCTSRGfF2oeepkIZ46k/vJy7kMN+HZWwjxn/6zTftfCa1S5z5dd3GohxjEOgVNsc1CtN3YlO+TZ1ouiobvlaI+23Q0W7H38IA2XuZfUY1Z39coce5rQ1gc1vu6QQYr5FTde2Yq/gfAJ+82ZVcZTXLwYc4KKA/jkApaRpkwE/DPDo5uaFQNIyFJx/ziweB23isuUuuS7bk37sQ0ap+ojFXSiFCWIXs5TH7rsC2goZQFxpong+RkBSShDCIVt5pMszctHYjy2hNsS3EGQX65QqUqioAC3j/sV+rHPlKEl7SdU2oXNUV5e+52Xq7Lvfdp3npWBjBC9RRS6c8VV45dWpwSr49q45TYkQjHahOPIn2GGPduZOTpE+pTHBJo7E+pR03B1MAUlX9Qg2otG8vgp5q8Ye8gp6xMXXqSfZUrXFt7dKb2Oi5VhoEefUMQqj8wJgXamhMf9L2XWEzCzZCDdOv1v3/LCClQMpxY1xR0epGj1y1DZsWj3WgAK6IckH3RPybfSUP7xdi2aCcrarJmJQr6G7JFnsceNryMaQLsLHBWtJ6/3965HxhSG5MqVedCZpM/7uSKprpuMCiGteO32kY6+c1SszJuvzH3Bf7bY2OlIJEibINptB8hDVYC/dhxi4m7m5piIEgkyuwP57c88D1XkR83h/6ovsc48TmwLZ26abu43BXXZKDWS81HVo0R6WgroPeWv49aXXCEvSz2TLSi6+Qij694gqhhSNsRGnIsGBJNRVNCFs41/QasW1/900hLClkC7cCSqffdZptq/nQyIkrRncYMeP6RCEJiM0EKLZbIGOgLSMl5r4RNowlbNTGwgLtlltUnUFkBVaDrysnoK0fth/USpwYzMY2fAH6xmENMA4Nt2L9TibvI8LFrgzsEoNWGyUo5TBO/AZIvo/Y7j8ebETaVuD9mt51fwKAUbPTGFzuTFxsxZZ4/a6eLz3g9Otq2SQWnX5ps+116I2AWc3FyW5rozInBJtD/B07BIXpCH3vXjEMtMkQcp7t36nrsMrtsggkwFoFPUYMuDrCgh2Wd3IBHjuyGlB8BzD4JKkckNWyFdv3kytAgIf+LIXM530LYSupZbQ3/463BUUt5rl2W7DXbVgaBxVT4gdovgn/oS50pw3NgqjeB4YpkEJ0ZO2c64b/jXxPbnp3znCmaV6c52GLp3nQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7d65b114-8313-49a5-df23-08db04b59196 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2023 00:36:48.7950 (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: CV54FBhZt0Yjp5vHam/nFVOgne4HYK6leSmIV5iiXzev6pRxvrvY4KJih+q2nLbWeisKOSDv8G2wBHFrU/Kh6A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8789 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Currently it can happen that an mqprio qdisc is installed with num_tc 8, and this will reserve 8 (out of 8) TXQs for the network stack. Then we can attach an XDP program, and this will crop 2 TXQs, leaving just 6 for mqprio. That's not what the user requested, and we should fail it. On the other hand, if mqprio isn't requested, we still give the 8 TXQs to the network stack (with hashing among a single traffic class), but then, cropping 2 TXQs for XDP is fine, because the user didn't explicitly ask for any number of TXQs, so no expectations are violated. Simply put, the logic that mqprio should impose a minimum number of TXQs for the network never existed. Let's say (more or less arbitrarily) that without mqprio, the driver expects a minimum number of TXQs equal to the number of CPUs (on NXP LS1028A, that is either 1, or 2). And with mqprio, mqprio gives the minimum required number of TXQs. Signed-off-by: Vladimir Oltean Reviewed-by: Simon Horman --- v3->v5: none v2->v3: move min_num_stack_tx_queues definition so it doesn't conflict with the ethtool mm patches I haven't submitted yet for enetc (and also to make use of a 4 byte hole) v1->v2: patch is new drivers/net/ethernet/freescale/enetc/enetc.c | 14 ++++++++++++++ drivers/net/ethernet/freescale/enetc/enetc.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index e18a6c834eb4..1c0aeaa13cde 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -2626,6 +2626,7 @@ int enetc_setup_tc_mqprio(struct net_device *ndev, void *type_data) if (!num_tc) { netdev_reset_tc(ndev); netif_set_real_num_tx_queues(ndev, num_stack_tx_queues); + priv->min_num_stack_tx_queues = num_possible_cpus(); /* Reset all ring priorities to 0 */ for (i = 0; i < priv->num_tx_rings; i++) { @@ -2656,6 +2657,7 @@ int enetc_setup_tc_mqprio(struct net_device *ndev, void *type_data) /* Reset the number of netdev queues based on the TC count */ netif_set_real_num_tx_queues(ndev, num_tc); + priv->min_num_stack_tx_queues = num_tc; netdev_set_num_tc(ndev, num_tc); @@ -2702,9 +2704,20 @@ static int enetc_reconfigure_xdp_cb(struct enetc_ndev_priv *priv, void *ctx) static int enetc_setup_xdp_prog(struct net_device *ndev, struct bpf_prog *prog, struct netlink_ext_ack *extack) { + int num_xdp_tx_queues = prog ? num_possible_cpus() : 0; struct enetc_ndev_priv *priv = netdev_priv(ndev); bool extended; + if (priv->min_num_stack_tx_queues + num_xdp_tx_queues > + priv->num_tx_rings) { + NL_SET_ERR_MSG_FMT_MOD(extack, + "Reserving %d XDP TXQs does not leave a minimum of %d TXQs for network stack (total %d available)", + num_xdp_tx_queues, + priv->min_num_stack_tx_queues, + priv->num_tx_rings); + return -EBUSY; + } + extended = !!(priv->active_offloads & ENETC_F_RX_TSTAMP); /* The buffer layout is changing, so we need to drain the old @@ -2989,6 +3002,7 @@ int enetc_alloc_msix(struct enetc_ndev_priv *priv) if (err) goto fail; + priv->min_num_stack_tx_queues = num_possible_cpus(); first_xdp_tx_ring = priv->num_tx_rings - num_possible_cpus(); priv->xdp_tx_ring = &priv->tx_ring[first_xdp_tx_ring]; diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h index 1fe8dfd6b6d4..e21d096c5a90 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h @@ -369,6 +369,9 @@ struct enetc_ndev_priv { struct psfp_cap psfp_cap; + /* Minimum number of TX queues required by the network stack */ + unsigned int min_num_stack_tx_queues; + struct phylink *phylink; int ic_mode; u32 tx_ictt; From patchwork Thu Feb 2 00:36:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13125119 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 0A994C636CD for ; Thu, 2 Feb 2023 00:37:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230003AbjBBAhF (ORCPT ); Wed, 1 Feb 2023 19:37:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229816AbjBBAgx (ORCPT ); Wed, 1 Feb 2023 19:36:53 -0500 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2071.outbound.protection.outlook.com [40.107.22.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD45174490 for ; Wed, 1 Feb 2023 16:36:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TI4j+2BEI5Ci40HqrjuvrzmM5rtqtH7DOrjRcExk7C1Q5FQwDiXPKHA1bRHv2376K5IvSzvjZk0J/v3TsL3XtrC/9/uTyiz2ThzXiSTjWwAJSn6ZLlOZOm3/AUTB5jcdX5cg58ikdF8bLiO4bxNWTbG5JYdYJG7njCd1jX4DIE2FtG20V7wrEyuOEMPvhDVWJsPb7b+W1J/V6+i18Ssx035iG52zspW/hJB3kY0zbPvImAuNr5mlzOTNmlO9Cg492U500rka10aq8kEoOD9VemmhSjCMvNpnT4KYKAldq/d3NphzsFcCRCi6YjnMj6/wf5x7/maOV4GbbwUhLgtr4w== 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=8lTB/mhBtR4Quu7d2WK+ct8sbygmU39Dwc7aGY1bivI=; b=hYnkIIcZUinI5bV0GUJeqf+1D8MWdcFr85yM1OHn/0H1Yl+TmwsBVRSdj56zIVw/4HPhxDeF0xjRob60tYbNiSe/KuJEVof7Tjw1GGPOwV0Hqs2xT3JpwvtmZYxqhc6Dfm6rUw+bN/OicKdrIQWBLhTXVkOSGrk18dS0g9uoJbe0g+6K1wn9zI9jJ+68NLelSWOT0BRlmsx5sCteJdWFTHiujo7BNzi4YGNoN7vuw5E5qtDsWHH2Lih7qt9WWNSqYEVt+Ps184bIXB7Z+esjVFbc0d7H7LqTYPG85piAcGg25mVF81MjB4uD4UMOguxdKq7pPfk4+XbNhwiMkX9AKA== 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=8lTB/mhBtR4Quu7d2WK+ct8sbygmU39Dwc7aGY1bivI=; b=hdWNXOppiNriNNvAaPy4wAboVXQdjr4z5yycs1DhHEac9oI6/yuOZP3kjAi8XOo+xUvIcikhsFmoOPpQPe5LBP9L7vKAtVGH4mi7GAfQjyObHOdqjHi4LiH3iTW0U3EQ1z37kXi2zLkYhfPUyHqXWi2uS37h+LJdDCv+K4K5Xsk= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by DU2PR04MB8789.eurprd04.prod.outlook.com (2603:10a6:10:2e0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Thu, 2 Feb 2023 00:36:51 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%3]) with mapi id 15.20.6043.038; Thu, 2 Feb 2023 00:36:50 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Vinicius Costa Gomes , Kurt Kanzenbach , Jacob Keller , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Simon Horman Subject: [PATCH v5 net-next 05/17] net/sched: mqprio: refactor nlattr parsing to a separate function Date: Thu, 2 Feb 2023 02:36:09 +0200 Message-Id: <20230202003621.2679603-6-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202003621.2679603-1-vladimir.oltean@nxp.com> References: <20230202003621.2679603-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0032.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:22::20) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|DU2PR04MB8789:EE_ X-MS-Office365-Filtering-Correlation-Id: 7aedc90a-2779-429b-a679-08db04b592a6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /4CFS0fjTu/MUMyaGzhcFqoOkqpfkRuuEJSNACHJPKnYP7Mf3A7sGTj+RqSYUNQp+A8+OzCXWYU7W3MLlaKfhjPxWYgyZlZeM31Bpyhdf3BVyBV5zY0c1NU3eqTW25zQdZGu7si7zkpJclGNhMjSfdCamJQVgqI6MhhqS7/CYDYE8on3IbDdaDxu1GrJSC78E4W8LyTRC8/JhtjyvqQLnXrqRKeYTcn0pY88d+vlpd3yef6+0Xqaiu8sLsVcU+KiW5teOAQDx7/S5X6Qu40Yt4TTj2TpJQbNVhiQkznKbEAGMPrhdogtpyVxj8pfM0YV8imdhiBW3nHTlBM4X6uF7Kd1S7QhkvXYpI49Lda83D0DSGYeLjPPkKfEVEfgwASTSeg/rW9gfLEeLs739eQPuSY5KzzwS1k2cjykRGSQmNH3D+zXwhmSkoaM2/Ct6yn8lWOs8ljHWhQsqPX8Z87iTjs9VrwPM6RT5phyURHzwCdSt7cKnMljrE9S9k995reoWkHx26omwgcPsTfl5zKAZmvi9u5tdMKnFqdIDZeiVSw/lPsWxEo7ks2YamTQ3Ar0/HjXmWf3tDa8yZ8moDGM2kNOtahjAQSTNNBiPxQTT2B2oSrow3fy5G1qP6YpP1TewL8X+zavUvG2a5ETm5szwl3lwle+AOqALMvURRsZeIqgh0fxWPU9x5N28MVUWhrWoiUNxZVItnt4EqR5eqt35g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(376002)(136003)(366004)(396003)(39860400002)(346002)(451199018)(36756003)(2616005)(7416002)(6666004)(52116002)(478600001)(2906002)(6486002)(38350700002)(86362001)(38100700002)(8936002)(54906003)(1076003)(6506007)(66556008)(8676002)(5660300002)(316002)(6916009)(41300700001)(44832011)(66476007)(66946007)(4326008)(6512007)(26005)(83380400001)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wVIb8kkymVWBHCo8U5arUy7Hv0jMYhb5s1ZcZ4WZL9T8VlW4BdHFfRXqyxvbsEOGqj6LkA/XltDnfCfsSUbTCfdaSaXQM2jx6m1da81t1SxQwSPjuyCEZ9HBqfXQnvm/jq6+bDXevMX1E4vEo7vAdId29ET9nEQNiAOHbpobaj7YX2lSbY0gbT+4FaIIeLGiNjmJuc3tZCrlcryiArr/RIMINb6Hy5iV6T6dZuVdKLSIe3VgLE+Y+mSOThy6+XMQL9hvbnZyBpQJQKVetX8FPfyuzOmrhHwJtQtCOdxWbsMewRjpZXfZEaAPwUJxLl1+PGLZskD62d1k4fh01ypCe1Iw13bs2eGVf/vuvFOrQbUPEawH5cnB6mvXnAWxEJhrMFJYx3OB9AZ/4WUeqSm0zNyiFU7XF37iTnR2c7OBJjzUjIplyzxfFiNRwHaIY3qXGWl8EpXZt1VJAHSWW55o0WnuE9S45PoFCGZtTadmezhncw8Zs/5mxOdFFBAXHiEtywGrVyi6V9z6Gis/rWCH6apDgiUdhmh7LhuhCMZq1bjdzjLu0/HGNAIaPYCGuGgV+CKLbIGl+G26g9ufdHfbeKFeiR09q5mRuWxNTWPpegnu5hbvgovTOc0sGn4D/61SjArbqxszIlJlEMDGIMp9xu83CVPu0xiVw4WtYuNj1q6vQaxJbNuJ0dSDnfF7d0TViXM0XzK2zR/RXSjnfg61li4YudxR60FWhCMHVnH3w91affwXl5GQHrnxR0B3466TT0EvMYmr8GEs/sZ1bRr0QIhCV6UwU03doGlzmrhYXRqIpuSYV1ooZnyq0jV3Wemni+ksxVs6ZfrXQUl4llu8ZageiylX7x0RaGMsvmgtvMeBq3hRzQYMVnmCf4A1/12GjJFlY+MPVBiduePRupczhoa1fDX26cM/zX9HHOcIdAXV9UTpKb/5BODMbISH323HpVEhDBQrqRbNps5eDjiIaZfBMpoAgj6MPmOt9lJD0zolcz79TZepPRB+cjPq49DWwmJ/5NS8S4IIllycV0gxIPTqgzwAJ0+QJRWoYseZ3CYcIaVntGCDB/zfWzkQQAqeExnnOjNMmSZbOL9q9KzMjeYyfR/o4kicqUdRXVz3MTAZR0zaQpG3WKQJFPgmv1UJctrOJXdyQT5N+3DZ+BzdzQyNSnCWKmSa1sclVYhTa3jBLAVW2k7K+53TOKMbXGlLM8EselRS7pBFYdZKX2qDJVQrWDmUsxqWPlzQNtfG/IFUVZrAsPY5QIatOlVPPNzGpVQRsE+kmCD3cfXwXAlDqBgruuWnCBpelDT4d9o6Cpzy6EjryzJ4FGCbnBe1mbtTC7sbzebM+GCA6nyQZl7+Tw0+wFoV1A4NUh4frXAbo+a4ukDI9OZ7B9v9tghD9U7DuScqYcGd0K83jPi0V9YPqKQwvLU/cKR0UZf1+3LEZ+n8SNlww6FQoqQuLGCS+L9hAwJSq1obn6xPr5QMZrgLeWDwAR6RfRlA09twNiJn59oN0MZzkRGUXEexXPaKLm05jD04MUyKF4yd6YT6OQHPeIvy2335RNkTCUEr/GYWTmZN09PhyyIcZZXXBkNnn06M0RTje5MuahPsRnHc8k1p9w== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7aedc90a-2779-429b-a679-08db04b592a6 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2023 00:36:50.8887 (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: wSyALUvQ8M0IFGaS1h9M6VqNHlo2RcXeF7fvR0y5Ix3R5cFGmhbMthBCc5tMtWDfeOIF7/q+ehTxLbhSgNs8lQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8789 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org mqprio_init() is quite large and unwieldy to add more code to. Split the netlink attribute parsing to a dedicated function. Signed-off-by: Vladimir Oltean Reviewed-by: Jacob Keller Reviewed-by: Simon Horman --- v1->v5: none net/sched/sch_mqprio.c | 114 +++++++++++++++++++++++------------------ 1 file changed, 63 insertions(+), 51 deletions(-) diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c index 4c68abaa289b..d2d8a02ded05 100644 --- a/net/sched/sch_mqprio.c +++ b/net/sched/sch_mqprio.c @@ -130,6 +130,67 @@ static int parse_attr(struct nlattr *tb[], int maxtype, struct nlattr *nla, return 0; } +static int mqprio_parse_nlattr(struct Qdisc *sch, struct tc_mqprio_qopt *qopt, + struct nlattr *opt) +{ + struct mqprio_sched *priv = qdisc_priv(sch); + 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 (!qopt->hw) + return -EINVAL; + + if (tb[TCA_MQPRIO_MODE]) { + priv->flags |= TC_MQPRIO_F_MODE; + priv->mode = *(u16 *)nla_data(tb[TCA_MQPRIO_MODE]); + } + + if (tb[TCA_MQPRIO_SHAPER]) { + priv->flags |= TC_MQPRIO_F_SHAPER; + priv->shaper = *(u16 *)nla_data(tb[TCA_MQPRIO_SHAPER]); + } + + if (tb[TCA_MQPRIO_MIN_RATE64]) { + if (priv->shaper != TC_MQPRIO_SHAPER_BW_RATE) + return -EINVAL; + i = 0; + nla_for_each_nested(attr, tb[TCA_MQPRIO_MIN_RATE64], + rem) { + if (nla_type(attr) != TCA_MQPRIO_MIN_RATE64) + return -EINVAL; + if (i >= qopt->num_tc) + break; + priv->min_rate[i] = *(u64 *)nla_data(attr); + i++; + } + priv->flags |= TC_MQPRIO_F_MIN_RATE; + } + + if (tb[TCA_MQPRIO_MAX_RATE64]) { + if (priv->shaper != TC_MQPRIO_SHAPER_BW_RATE) + return -EINVAL; + i = 0; + nla_for_each_nested(attr, tb[TCA_MQPRIO_MAX_RATE64], + rem) { + if (nla_type(attr) != TCA_MQPRIO_MAX_RATE64) + return -EINVAL; + if (i >= qopt->num_tc) + break; + priv->max_rate[i] = *(u64 *)nla_data(attr); + i++; + } + priv->flags |= TC_MQPRIO_F_MAX_RATE; + } + + return 0; +} + static int mqprio_init(struct Qdisc *sch, struct nlattr *opt, struct netlink_ext_ack *extack) { @@ -139,9 +200,6 @@ static int mqprio_init(struct Qdisc *sch, struct nlattr *opt, struct Qdisc *qdisc; int i, err = -EOPNOTSUPP; struct tc_mqprio_qopt *qopt = NULL; - struct nlattr *tb[TCA_MQPRIO_MAX + 1]; - struct nlattr *attr; - int rem; int len; BUILD_BUG_ON(TC_MAX_QUEUE != TC_QOPT_MAX_QUEUE); @@ -166,55 +224,9 @@ static int mqprio_init(struct Qdisc *sch, struct nlattr *opt, len = nla_len(opt) - NLA_ALIGN(sizeof(*qopt)); if (len > 0) { - err = parse_attr(tb, TCA_MQPRIO_MAX, opt, mqprio_policy, - sizeof(*qopt)); - if (err < 0) + err = mqprio_parse_nlattr(sch, qopt, opt); + if (err) return err; - - if (!qopt->hw) - return -EINVAL; - - if (tb[TCA_MQPRIO_MODE]) { - priv->flags |= TC_MQPRIO_F_MODE; - priv->mode = *(u16 *)nla_data(tb[TCA_MQPRIO_MODE]); - } - - if (tb[TCA_MQPRIO_SHAPER]) { - priv->flags |= TC_MQPRIO_F_SHAPER; - priv->shaper = *(u16 *)nla_data(tb[TCA_MQPRIO_SHAPER]); - } - - if (tb[TCA_MQPRIO_MIN_RATE64]) { - if (priv->shaper != TC_MQPRIO_SHAPER_BW_RATE) - return -EINVAL; - i = 0; - nla_for_each_nested(attr, tb[TCA_MQPRIO_MIN_RATE64], - rem) { - if (nla_type(attr) != TCA_MQPRIO_MIN_RATE64) - return -EINVAL; - if (i >= qopt->num_tc) - break; - priv->min_rate[i] = *(u64 *)nla_data(attr); - i++; - } - priv->flags |= TC_MQPRIO_F_MIN_RATE; - } - - if (tb[TCA_MQPRIO_MAX_RATE64]) { - if (priv->shaper != TC_MQPRIO_SHAPER_BW_RATE) - return -EINVAL; - i = 0; - nla_for_each_nested(attr, tb[TCA_MQPRIO_MAX_RATE64], - rem) { - if (nla_type(attr) != TCA_MQPRIO_MAX_RATE64) - return -EINVAL; - if (i >= qopt->num_tc) - break; - priv->max_rate[i] = *(u64 *)nla_data(attr); - i++; - } - priv->flags |= TC_MQPRIO_F_MAX_RATE; - } } /* pre-allocate qdisc, attachment can't fail */ From patchwork Thu Feb 2 00:36:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13125120 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 9C3F2C05027 for ; Thu, 2 Feb 2023 00:37:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230013AbjBBAhP (ORCPT ); Wed, 1 Feb 2023 19:37:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229926AbjBBAg6 (ORCPT ); Wed, 1 Feb 2023 19:36:58 -0500 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2071.outbound.protection.outlook.com [40.107.22.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3596E744B4 for ; Wed, 1 Feb 2023 16:36:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BEZioXTUlvkQzMrDw6edjIuKiM92ukPX023cKd32VkZLvxQEGeI16wmuHdmcTm8KcLEyP+aqnbyvFmZF9qvxBMnbDJHZv2yuDOn5rMwjqtFlkDL/lPRnu4b2tCWeW0JXq0YoQk1r7EVAktq+VTmi+5KexUK+HyAYSFU5i0OUU+zbAW+tBok9tnd/SaPUDMGdbXbCqS+ougJdZ4JioRpMudjRTZvA+WWKHgvGlAFSZF7IoRsw8ntR0xgVaKtKHyGJ//w+f015s+R+95bWwAlOvXsIivGXBGUNNJJwPMpNWEkT5BCRpywSnHoCkvotZh/FBDjhIlhHY4lYfYJgVrHTag== 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=cuncC9AhLoKBsJXbQNrdK2IQvKSzZsW+vgArceErrQQ=; b=KsCzjZdGPl4qoth2eq0XGCVgxzjKKLOHA1HgiaSjZi9H2lDPgcEWqRHUF7yTpjT0cXIidN31dm9LhHx3u2thqW68wMqcAMltGJnLCYaaDQKo8SeKUpUNoNoBSiwHdw1M+TS2XeIl9pb4rRKDx3dj7MS7cVfya3SW/MiM0ewbISDnAG/M0NpQgzDzx9VTq4V02ZDTRPrXyV2fu5RwmNcaLUtKNLngiusc+YK9gPHU2gDTlDHb1nehxE0eQ5zXcYLX6bvDt23Ug3cyNkI6ko5VT1x9VgDvLi6rS0YmjHirN0zNrNVOkPnct2FZlmKKo5j7ViDCAETekKWzhHohvQD43g== 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=cuncC9AhLoKBsJXbQNrdK2IQvKSzZsW+vgArceErrQQ=; b=Y1WmArCNJfE3l9V1qYJHYq0UHVdDEGe/sjDlrVMpSUkjWRXOmCgXJkzQz1+kUvMuw7mXhQwltO+5C7ItOI63wZ2I9lVyKxuC/giwl9brtVfJAtUzY279i6xhD/DG2BxjlTWX0Bye8oEPfaOIf6SxBPkhflaRoOF7NtdR7ec4I30= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by DU2PR04MB8789.eurprd04.prod.outlook.com (2603:10a6:10:2e0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Thu, 2 Feb 2023 00:36:52 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%3]) with mapi id 15.20.6043.038; Thu, 2 Feb 2023 00:36:52 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Vinicius Costa Gomes , Kurt Kanzenbach , Jacob Keller , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Simon Horman Subject: [PATCH v5 net-next 06/17] net/sched: mqprio: refactor offloading and unoffloading to dedicated functions Date: Thu, 2 Feb 2023 02:36:10 +0200 Message-Id: <20230202003621.2679603-7-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202003621.2679603-1-vladimir.oltean@nxp.com> References: <20230202003621.2679603-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0032.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:22::20) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|DU2PR04MB8789:EE_ X-MS-Office365-Filtering-Correlation-Id: f63db26e-a19c-4a02-a52e-08db04b593ef X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0V6J2fxN+QwKVRiLTCdze41FfpeQ/bIPcRjC9OBXVv6Dpga6F0d4N6gYDkgf9bbtZsa2RoocNzisUBxZc0dz/5QChds/OrtPjukafz98P8Ak+HjBlxFGZbfWjPP2Nc6yQRqPcbHLHMvFGFG69RYSwuZN5/9GFkchG/UlJWSLawrOWu3IwYEalHoBW/Va+lIxNmeqO9gv9XqwflnCwtPyPGSFJ2gDUggRLk5Jay767rQWBJQcO8kawnTc4Vu3/Yi+TL2nmZi6x/s4WFcqESz+iJCBvs2mie6Zr5Oa9PMaLrUqpCipeem+Nde0YWT8bW2rmxyefq/KGbLxy+v2Ypea0XyRe5eyoIAgJY/WSzhwssCInPrj/pt6xbeRmw3jayQEVOKUe60IjQAUQThKpgsOai/D0iqIjDpoHuMYZR1iQODjPf7tkUCV1Mrj5k6CDhV1cVlxwkwz55jeSP6BEeciOVZYjNHiPF25z9Jetl2hwuzDp9bJo6dH6r24wqnTKQCITpMFIk8D5bba/QBNTUwZg+keOJVhuW8c0CTW/t71ApibQP22mAZ+QiKwJ74QE1iloEDUX3PPs1nFWkDC42NqrZ8+yHDiLlyECRDnbk0D7/0RTl78TuPZY/k6wlT2KlMBaAe0CCV/5cxlPOQqcRW3JUzBTyDiBovDKGKzUU9x+KLXMfQW1WzIwsXDdII7Er+zruJDRWWCtVesyI6qmYd7Bg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(376002)(136003)(366004)(396003)(39860400002)(346002)(451199018)(36756003)(2616005)(7416002)(6666004)(52116002)(478600001)(2906002)(6486002)(38350700002)(86362001)(38100700002)(8936002)(54906003)(1076003)(6506007)(66556008)(8676002)(5660300002)(316002)(6916009)(41300700001)(44832011)(66476007)(66946007)(4326008)(6512007)(26005)(83380400001)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QOEru6Lnflxh+VKLUSFgyG2gaDYWGPGxCUKk9k9fuOu6fkQHSTXrTIH2jUcn+tsycvrzUiE7FcHEY+rI+S5CZ43EYx9pmwpg/xl1XnArk4S61nlblPQCXAvRDhbxtPQaQ1pOVploGMFQlwP5CHpe96jzUiQdS0xfhR89f4WtG/S5yYoH6wlrPq3kF2uQhRoG7MCkLVQ5XTuq3BZxoETzqxzIMumhLcs9+bTS77MtfybhsiYY0xEXlVCSBqCtf0Xk82vtLfNo0cNaZX83iiHTiYoEOyS9Kx2thO7Jkr11ghCKJ8y9Kd50yWCwxD/IpMiZcUozIrIAsISM01D67uSYeLKTnJlKuUgzJ/NVHiv8zqZPugQkimdeZG3xJAJv+QQGpUmzveYqAI7CbMOo4K3pj3TZT4X6FOr8x1H+qG/MIkJlxY0xowzMqAPkKCyzgV0aqyWPP0M+jk0lPsbAYGTBEIV03KlEiziTjwnhNzV3h6x49duZ0lNGKkxTj6GcJN3kb7UPUgwcQuLNnXxmsv/FOaGCrv/T6JzPqm1drn+pN743y89SFrKojRkQir/ESZ9sZJlkKbrNqDNC1oLj1YLY/OM860+aIz+++RspoxabnR+rS/JY8xV/0Nnkmf+2xsLuXi+9Drgki2KSGJvUbrH0z4TPw/TY8jn1kdBqfo4gf0QktRGeBuLNIwnwPoMn7830CYBNw/ttIVuMEWiV0HvHeIZzVNj4GwaSSOpTsHMFZ2ogurwX+15JPDnLY4XSR5Ac/xZp6gZEUC/EI54+104bCHvj2pK2qMbCHKlV2uzjo7Dvu3leQl3hxheEQOumgXyecjVsMOWd5Q7rMXNoMj8qraS0TKEtWzcCLj8P0JL6HrSSx/w0LHtDyMuTiloT0aBU4HcBJMvgtz38rkPb8G8bxMM+mapYJZiFi3Z/Br3N4OmTppkV4COvwYCVAHz/SjJH4KJfI0k31uWkgTo/dO0xkhLYD8slMk+KAwiFCn0OIXHMpItyH1H/FLJQdiohKowlF94dbxO9Mj4sVNW9x7XieFjhhFbH4UzQs25s2U+r/2XarWtI7HAufYMcjVxlJHNBahPTDRTYBNV/TZ94aDrxA0Q8kiynFEMzAYyF/VINXdspbEa+UiO1we8I3qeCXuyZLeG+3vYlezb6PwJ/jzVl8eit5eMYZrjgf0V4hHEyliqz6RJSj66dl+G4kjPSGPiYYCam+oZwwcgHTTLlX5LlCcm289QAu0iVL98tLpxEiGfcC/kxwWlTH0VnJdln7ArNZYfGYgadl0+8Hr6fdnJ6ebjUgz/+7pdgTUemd76Q08kiCnK8oSkV6Pay40SZsO5j9T2DX4yDa4LfNJSBmVG11+L7enpMV1OanES0Ch8tijyZD0ahbFPZnUkmkRPM9lTMa7sRjEIJ5ZRR0a9FuaCHrc6dMZMgUez6cDKsJdj2kg3NcC0idryVlCWFsuEJzv5yZuAVzX5AJfUbNXPmS4BXwnRfIrnb5LQQlwr+X5+OsKnXwYKRBdgtxPF2JOZf0dvnZStkUS48PqLhBkoLSp8EnZTnaWGoz2baKNtTcDPgk0/Z/F1xYOg7Bu5pckb6ZvbUYM+Y/E1ur4EMCDXbazsHfA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f63db26e-a19c-4a02-a52e-08db04b593ef X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2023 00:36:52.4510 (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: I096ndMyh46EpKbldpnmIb73Im8g1QsJSib+VqmQt/7QSd4dknjK4CJ3d+sVyzigNbC4GuVxuMB5CDST2yAdfQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8789 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Some more logic will be added to mqprio offloading, so split that code up from mqprio_init(), which is already large, and create a new function, mqprio_enable_offload(), similar to taprio_enable_offload(). Also create the opposite function mqprio_disable_offload(). Signed-off-by: Vladimir Oltean Reviewed-by: Jacob Keller Reviewed-by: Simon Horman --- v1->v5: none net/sched/sch_mqprio.c | 102 ++++++++++++++++++++++++----------------- 1 file changed, 59 insertions(+), 43 deletions(-) diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c index d2d8a02ded05..3579a64da06e 100644 --- a/net/sched/sch_mqprio.c +++ b/net/sched/sch_mqprio.c @@ -27,6 +27,61 @@ struct mqprio_sched { u64 max_rate[TC_QOPT_MAX_QUEUE]; }; +static int mqprio_enable_offload(struct Qdisc *sch, + const struct tc_mqprio_qopt *qopt) +{ + struct tc_mqprio_qopt_offload mqprio = {.qopt = *qopt}; + struct mqprio_sched *priv = qdisc_priv(sch); + struct net_device *dev = qdisc_dev(sch); + int err, i; + + switch (priv->mode) { + case TC_MQPRIO_MODE_DCB: + if (priv->shaper != TC_MQPRIO_SHAPER_DCB) + return -EINVAL; + break; + case TC_MQPRIO_MODE_CHANNEL: + mqprio.flags = priv->flags; + if (priv->flags & TC_MQPRIO_F_MODE) + mqprio.mode = priv->mode; + if (priv->flags & TC_MQPRIO_F_SHAPER) + mqprio.shaper = priv->shaper; + if (priv->flags & TC_MQPRIO_F_MIN_RATE) + for (i = 0; i < mqprio.qopt.num_tc; i++) + mqprio.min_rate[i] = priv->min_rate[i]; + if (priv->flags & TC_MQPRIO_F_MAX_RATE) + for (i = 0; i < mqprio.qopt.num_tc; i++) + mqprio.max_rate[i] = priv->max_rate[i]; + break; + default: + return -EINVAL; + } + + err = dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_QDISC_MQPRIO, + &mqprio); + if (err) + return err; + + priv->hw_offload = mqprio.qopt.hw; + + return 0; +} + +static void mqprio_disable_offload(struct Qdisc *sch) +{ + struct tc_mqprio_qopt_offload mqprio = { { 0 } }; + struct mqprio_sched *priv = qdisc_priv(sch); + struct net_device *dev = qdisc_dev(sch); + + switch (priv->mode) { + case TC_MQPRIO_MODE_DCB: + case TC_MQPRIO_MODE_CHANNEL: + dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_QDISC_MQPRIO, + &mqprio); + break; + } +} + static void mqprio_destroy(struct Qdisc *sch) { struct net_device *dev = qdisc_dev(sch); @@ -41,22 +96,10 @@ static void mqprio_destroy(struct Qdisc *sch) kfree(priv->qdiscs); } - if (priv->hw_offload && dev->netdev_ops->ndo_setup_tc) { - struct tc_mqprio_qopt_offload mqprio = { { 0 } }; - - switch (priv->mode) { - case TC_MQPRIO_MODE_DCB: - case TC_MQPRIO_MODE_CHANNEL: - dev->netdev_ops->ndo_setup_tc(dev, - TC_SETUP_QDISC_MQPRIO, - &mqprio); - break; - default: - return; - } - } else { + if (priv->hw_offload && dev->netdev_ops->ndo_setup_tc) + mqprio_disable_offload(sch); + else netdev_set_num_tc(dev, 0); - } } static int mqprio_parse_opt(struct net_device *dev, struct tc_mqprio_qopt *qopt) @@ -253,36 +296,9 @@ static int mqprio_init(struct Qdisc *sch, struct nlattr *opt, * supplied and verified mapping */ if (qopt->hw) { - struct tc_mqprio_qopt_offload mqprio = {.qopt = *qopt}; - - switch (priv->mode) { - case TC_MQPRIO_MODE_DCB: - if (priv->shaper != TC_MQPRIO_SHAPER_DCB) - return -EINVAL; - break; - case TC_MQPRIO_MODE_CHANNEL: - mqprio.flags = priv->flags; - if (priv->flags & TC_MQPRIO_F_MODE) - mqprio.mode = priv->mode; - if (priv->flags & TC_MQPRIO_F_SHAPER) - mqprio.shaper = priv->shaper; - if (priv->flags & TC_MQPRIO_F_MIN_RATE) - for (i = 0; i < mqprio.qopt.num_tc; i++) - mqprio.min_rate[i] = priv->min_rate[i]; - if (priv->flags & TC_MQPRIO_F_MAX_RATE) - for (i = 0; i < mqprio.qopt.num_tc; i++) - mqprio.max_rate[i] = priv->max_rate[i]; - break; - default: - return -EINVAL; - } - err = dev->netdev_ops->ndo_setup_tc(dev, - TC_SETUP_QDISC_MQPRIO, - &mqprio); + err = mqprio_enable_offload(sch, qopt); if (err) return err; - - priv->hw_offload = mqprio.qopt.hw; } else { netdev_set_num_tc(dev, qopt->num_tc); for (i = 0; i < qopt->num_tc; i++) From patchwork Thu Feb 2 00:36:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13125121 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 97326C636CD for ; Thu, 2 Feb 2023 00:37:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230091AbjBBAhR (ORCPT ); Wed, 1 Feb 2023 19:37:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229935AbjBBAg7 (ORCPT ); Wed, 1 Feb 2023 19:36:59 -0500 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2071.outbound.protection.outlook.com [40.107.22.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2345728FB for ; Wed, 1 Feb 2023 16:36:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UssMj6n0jYvs2aBa/Xtacvya53Uax0ZzwoZb6tvJJ8bm0pX877BoE+fUB85VsxQVtlv8+zMshxR2bmKrfcrO9QnlPkd+VQT9+Qve8rHX4OH7SmyjduV7wpcz7jD8L0HlIQvGbNJVxTSARIlTbmAo79OxbtotPC4rckI1JEh5B2/dGNExLnWcJywDGPi1qhjYknWIOMGNPevXwyko+mRrsKoJGNrfE9bSMyEY/6i3rz7aw2+QGC7c0KHWL+R7jXPKojjGGzK1JmVxTh8JqFzFye7GI03Zw/cdFhUAqC2u+gM3CKqE6lPG9gBgNvka58OJ7FBe6Yk26RaX98R7H5ze6Q== 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=jiVDKvg8Ribmwtk80xku02iHmEjFPvv0A1ckS7YcwCs=; b=AmxtlUgM5q2+fIEv7nxPnJEH4lHiXx7dfrAkiYq/UIB3RtUVdr1xXhdjVd5DcPmZ7hEL9vUuf4g89Wwhr14HY6BD6A2Uph0j8z0MWO81ov2WTjrrhrgVk83u8JzT8MchxCck7He9dqGMBVd4p6yRY80nRl/lWFUPmruMLSmOXyEgzUZMEs1gwIkYuPBJmyBiV+JCblNueDFRY9pmhNb2TC8oeyxT1ukLS6GjEVSi125t8T4652X+ZVPf0j5D/wgWFygIh66EqqVPRtVol4yqOFHaJKFzV1J8eL2829vfq/wGr5cYcHZcHe8tuOo6R4/AwbYSZxgtc/vfDiWf4EErtQ== 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=jiVDKvg8Ribmwtk80xku02iHmEjFPvv0A1ckS7YcwCs=; b=dedH4IqbksjrdL2SUygg2LkCCE9yQHbHIvo6IAOa0hE28Pkr9qaF+vPOLevz5MpgnBgEWksStAnNrAt5NTr+B1yVJMuDHmWwEv7kmg9x/vYstPHgT4ZLSfXygWQKxeCuCuWPckQ0Jsu3cG3naap6EPb1qBHRl2A9Jv1EK+b7xdQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by DU2PR04MB8789.eurprd04.prod.outlook.com (2603:10a6:10:2e0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Thu, 2 Feb 2023 00:36:54 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%3]) with mapi id 15.20.6043.038; Thu, 2 Feb 2023 00:36:54 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Vinicius Costa Gomes , Kurt Kanzenbach , Jacob Keller , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Simon Horman , Igor Russkikh , Yisen Zhuang , Salil Mehta , Jesse Brandeburg , Tony Nguyen , Thomas Petazzoni , Saeed Mahameed , Leon Romanovsky , Horatiu Vultur , Lars Povlsen , Steen Hegelund , Daniel Machon , UNGLinuxDriver@microchip.com Subject: [PATCH v5 net-next 07/17] net/sched: move struct tc_mqprio_qopt_offload from pkt_cls.h to pkt_sched.h Date: Thu, 2 Feb 2023 02:36:11 +0200 Message-Id: <20230202003621.2679603-8-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202003621.2679603-1-vladimir.oltean@nxp.com> References: <20230202003621.2679603-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0032.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:22::20) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|DU2PR04MB8789:EE_ X-MS-Office365-Filtering-Correlation-Id: a0a9ca9f-5500-49ca-f7a9-08db04b594e9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cfM1mKLGvpFOsJ0WaZeDzW3hFsxm8RaWeijEmjvJ4U+zVY1IDTUVAlP4mH6gIip5LFoUT06zKeyrWlGM4B36SiIziBrcGvs9Zw8kZn6W0K3QqZh5tl5SDlgp6Fo481kFGsMtsqq7om4lw73x9G8yvMk+PO7qBEPg1fqa9DHvq87rZujr9EnfxVwuW88tqRdki9Xi4dpvY9LQCba+spbz3M+j73upCp8c1BqyfSWDr9V378XEyCtOov9d5gIjnhJuH5elSFFVhFPz1xkaL39IULWP95eIgcXXLFXDLE8d1cY6ki/5QtN/G06SF5320TS/owuldAC6NhsturUJYi/y2joN3bREhuVEmARFN406vZDfz+JukT/lwjOGUJZMJGpO/pTvjfkHpNca1L8xOU7O6nsOrdXkqV4ubuAKxX6u2GOSz6k1fH4cnIrQ7l2G2fFUR7OHyKdzLpqYFWqr5Wz/U7dxI82dd+DYK6L8/XCK64T+2MASuA3S5nj5c0CGfdHq9cHEC4CmLLiowvXfUjgzST2lY6szlGEtZz4xn3A8cybCtFaz1iVJK2fDJX9BSokYMzkQWglwB1RqccipJnZx1qFpuPFbF4IdzMm2hJCUSq+TZ4pJUEI3VR+iHYBgVjq5aD+6jl4eGnEtbnUtVZHwiztX4pg46t00oO8LagDc9Xaj5R1mIq64c2/8ndZXsxLw X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(376002)(136003)(366004)(396003)(39860400002)(346002)(451199018)(36756003)(2616005)(7416002)(6666004)(52116002)(478600001)(2906002)(6486002)(38350700002)(86362001)(38100700002)(8936002)(54906003)(1076003)(6506007)(66556008)(8676002)(5660300002)(316002)(6916009)(41300700001)(44832011)(66476007)(66946007)(4326008)(6512007)(26005)(83380400001)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OpoKdRwiOsIZ/Zs5r27wx/Sd9e6w9pvT98JaK/KWEczAXvK4FQkXtxBS79mJ3AlZqdP5yxodY9cr2rgM35RXDRr8uB5Ks5y5l643w8gCUgKwkif5ELBiJ2bLqz5MhUlAdSl2uftWxodr8vsrtVCibxtDT7KajtvqlsU/nmq582Eql0UskD7msk5/SJaPHqTKbzOHVVp3bUIjt0XLu20MyBXp/E46QflNPDl0xd7sBs23qXoSY4Tips9KEXjjD+uoneqvgrBF2d/qhJju2WgtNMlnG9oFjY96s38ewCDEH3GKnK6tIFdXV3j4HjrQtPD/XKBoxySkAaOMGmzEL2NHpUHDlB/1EbAeaV8Vmy8cGX57MF55EQq206zSG1am7+5/j/c5pSwxMtkpHXDrAjG1B5zc9ZqLEmwIZr+uPJi55sOYBk2THKYwrr2K3S4x/pG9px5ATJ2P+qL32We34VqZUgRAQQLcEonC6EgGU0bMtI0o2PfX/tpmFpIrNDOh9fYbiuF+wykizqMa7OSCXzkAtd6PHGPqzB5L0/gycAMF4IYuK5x0VihH+YRx3gDVrfU0MrN8m4w30Ebex2DSNqBdtNJkOViUD8J8EM2xCNZQqicQj0+1wSDfmIvq4RK5/AXub/pbg7qxJKpEYJeLWQfs50d6DWhdUWtKf4tz/GCmz5CzwUhLGp8ymaM3PpGxCg2n4VwrnV1/JVSWzOk+5UzJ2DwTpikYkHiAjZPrEmBG0lL+kedupZrAiFJW/4IZ9R1i3fnNCEkxsKWJo90dia8Nd/RPS0uiFVjjBEXgzVw9BbANsV+eaGXPMR8dWHIM1AuG2rXumLmuOOnnYC7O5U+lLMk3ZmW5lHRAIpzzHazN7zppLo1LdlAME/4RqZMRfxTYqDJEO4u4SZeqjGG2gRo1WqkpuZDOHjhwmbwN9FRZemho5T4ZBbP5EK+wchKCjoxqdlBd73YslSdL+wFRlNnZnY4ZIuIzIMu0Vu81jd5b8nWW3nSvnxXiL54Wj/F+UXVJlWY9U2H9jCGwLSO+di8gYLd9wPqM/Djtr7U1Dm5GYZtGynmU4p3MBxF9uAil6TZrSriRdpIDcUljg2rSv8BZUKxH2+nmHVGnR5zC+MhRlxxHBR2GLCgEzCpc1gE0o51nGYRAytZg55CYiYZnc5JbFP5a0lEIlvM+SaPJAk03li2zT98iZfU0X/H6NYLkWWEYjVT3wOwfUPD6gPju+7oCtjE3eZzjf7yarv4Vp/UJzO+1DgITtBiPDDK/NWDtbV0nNQdMz+DPMnYWVYqSRJ6elUjTtU+HoEsMbSQyMCtdPrAtNJTMQIs4Sjcb9XUfCGq9H7Vv0j02pBf86OCJOYihdR8sZGD3HngaQy72s/jOgdBZTxzoYOHs6IlG04H/q9zKWGQlnlHd6elY8A/ZWHCpoP2mKrDY8CIkCoAB3FV3vBAp4FJXI/j4M/a3fJU2qoLFvvj5NNxhXqz9/MrM3usef6pROOdD6goazYJ1JYOXO5txM9utgmx5eFuwL4aQR/0Zejjm2Jl7YwpYe5SpE5mQsXaE3ZFk6oBeIu0Oaba9u7Peg6HEUnqDyC+A9jI9YrekCj/luy30Kt19x8kcctWBzQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a0a9ca9f-5500-49ca-f7a9-08db04b594e9 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2023 00:36:53.9197 (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: fZraIYmpIkGqwvt6MsgFUGipXZxHDpnxt+5SKLKkytdnsF5n7zHNYpIesdCErZOA8eruv3j0sBtSwh9xxALI2w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8789 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Since mqprio is a scheduler and not a classifier, move its offload structure to pkt_sched.h, where struct tc_taprio_qopt_offload also lies. Also update some header inclusions in drivers that access this structure, to the best of my abilities. Cc: Igor Russkikh Cc: Yisen Zhuang Cc: Salil Mehta Cc: Jesse Brandeburg Cc: Tony Nguyen Cc: Thomas Petazzoni Cc: Saeed Mahameed Cc: Leon Romanovsky Cc: Horatiu Vultur Cc: Lars Povlsen Cc: Steen Hegelund Cc: Daniel Machon Cc: UNGLinuxDriver@microchip.com Signed-off-by: Vladimir Oltean Reviewed-by: Simon Horman --- v4->v5: none v3->v4: shouldn't have removed "#include " from ti cpsw v2->v3: none v1->v2: - update some header inclusions in drivers - fix typo (said "taprio" instead of "mqprio") drivers/net/ethernet/aquantia/atlantic/aq_main.c | 1 + drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_mqprio.h | 2 +- drivers/net/ethernet/hisilicon/hns3/hnae3.h | 1 + drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 1 + drivers/net/ethernet/intel/i40e/i40e.h | 1 + drivers/net/ethernet/intel/iavf/iavf.h | 1 + drivers/net/ethernet/intel/ice/ice.h | 1 + drivers/net/ethernet/marvell/mvneta.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 1 + drivers/net/ethernet/microchip/lan966x/lan966x_tc.c | 1 + drivers/net/ethernet/microchip/sparx5/sparx5_tc.c | 1 + drivers/net/ethernet/ti/cpsw_priv.c | 1 + include/net/pkt_cls.h | 10 ---------- include/net/pkt_sched.h | 10 ++++++++++ 14 files changed, 22 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_main.c b/drivers/net/ethernet/aquantia/atlantic/aq_main.c index 77609dc0a08d..0b2a52199914 100644 --- a/drivers/net/ethernet/aquantia/atlantic/aq_main.c +++ b/drivers/net/ethernet/aquantia/atlantic/aq_main.c @@ -21,6 +21,7 @@ #include #include #include +#include #include MODULE_LICENSE("GPL v2"); diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_mqprio.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_mqprio.h index be96f1dc0372..d4a862a9fd7d 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_mqprio.h +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_mqprio.h @@ -4,7 +4,7 @@ #ifndef __CXGB4_TC_MQPRIO_H__ #define __CXGB4_TC_MQPRIO_H__ -#include +#include #define CXGB4_EOSW_TXQ_DEFAULT_DESC_NUM 128 diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h index 17137de9338c..40f4306449eb 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h @@ -32,6 +32,7 @@ #include #include #include +#include #define HNAE3_MOD_VERSION "1.0" diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index b4c4fb873568..25be7f8ac7cd 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h index 60e351665c70..38c341b9f368 100644 --- a/drivers/net/ethernet/intel/i40e/i40e.h +++ b/drivers/net/ethernet/intel/i40e/i40e.h @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include diff --git a/drivers/net/ethernet/intel/iavf/iavf.h b/drivers/net/ethernet/intel/iavf/iavf.h index 23bc000e77b8..232bc61d9eee 100644 --- a/drivers/net/ethernet/intel/iavf/iavf.h +++ b/drivers/net/ethernet/intel/iavf/iavf.h @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h index ae93ae488bc2..ef6b91abce70 100644 --- a/drivers/net/ethernet/intel/ice/ice.h +++ b/drivers/net/ethernet/intel/ice/ice.h @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c index f8925cac61e4..a48588c80317 100644 --- a/drivers/net/ethernet/marvell/mvneta.c +++ b/drivers/net/ethernet/marvell/mvneta.c @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include /* Registers */ diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index 0e87432ec6f1..7de21a1ef009 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include "eswitch.h" #include "en.h" diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_tc.c b/drivers/net/ethernet/microchip/lan966x/lan966x_tc.c index 80625ba0b354..cf0cc7562d04 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_tc.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_tc.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0+ #include +#include #include "lan966x_main.h" diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_tc.c b/drivers/net/ethernet/microchip/sparx5/sparx5_tc.c index 205246b5af82..e80f3166db7d 100644 --- a/drivers/net/ethernet/microchip/sparx5/sparx5_tc.c +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_tc.c @@ -5,6 +5,7 @@ */ #include +#include #include "sparx5_tc.h" #include "sparx5_main.h" diff --git a/drivers/net/ethernet/ti/cpsw_priv.c b/drivers/net/ethernet/ti/cpsw_priv.c index 758295c898ac..e966dd47e2db 100644 --- a/drivers/net/ethernet/ti/cpsw_priv.c +++ b/drivers/net/ethernet/ti/cpsw_priv.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "cpsw.h" #include "cpts.h" diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h index 4cabb32a2ad9..cd410a87517b 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h @@ -788,16 +788,6 @@ struct tc_cls_bpf_offload { bool exts_integrated; }; -struct tc_mqprio_qopt_offload { - /* struct tc_mqprio_qopt must always be the first element */ - struct tc_mqprio_qopt qopt; - u16 mode; - u16 shaper; - u32 flags; - u64 min_rate[TC_QOPT_MAX_QUEUE]; - u64 max_rate[TC_QOPT_MAX_QUEUE]; -}; - /* This structure holds cookie structure that is passed from user * to the kernel for actions and classifiers */ diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h index 38207873eda6..6c5e64e0a0bb 100644 --- a/include/net/pkt_sched.h +++ b/include/net/pkt_sched.h @@ -160,6 +160,16 @@ struct tc_etf_qopt_offload { s32 queue; }; +struct tc_mqprio_qopt_offload { + /* struct tc_mqprio_qopt must always be the first element */ + struct tc_mqprio_qopt qopt; + u16 mode; + u16 shaper; + u32 flags; + u64 min_rate[TC_QOPT_MAX_QUEUE]; + u64 max_rate[TC_QOPT_MAX_QUEUE]; +}; + struct tc_taprio_caps { bool supports_queue_max_sdu:1; }; From patchwork Thu Feb 2 00:36:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13125122 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 6AB15C05027 for ; Thu, 2 Feb 2023 00:37:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230225AbjBBAhT (ORCPT ); Wed, 1 Feb 2023 19:37:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229651AbjBBAhE (ORCPT ); Wed, 1 Feb 2023 19:37:04 -0500 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2071.outbound.protection.outlook.com [40.107.22.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5334973753 for ; Wed, 1 Feb 2023 16:36:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fjtv8IZCZOH6BfC7a5JhoAV+U5BjoOnwhlG+2zmRbyIKIeENtZnepjbMiSKFairWqQ6D8vWqA1MNZUaTifztYN0xyadNa4fkJCoC7WOuGLgSpsmqX7FakSUiiJtmVzEMn7nwpSPIW//I9mAOUdU2doe0XHld7I3EAsEIwszkaaUPBD283jiSHj+IXmwTkfglhODZ/JdxV/dtMlBrLTcLsLnFX4hsJS8phwS4XzqAW403Qvm2DqiPFwmdgsEneg5Rwpe/WA2+T2MckfuHfVS8bo7t6S+IvdyfDgVX3MvAvfgF5fqQeNpC05PswgLhenQ163D9vHu1GNi7uG9huoNrWg== 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=JTzQbQ/RGwzZ/YqnqdMqI1okfDA1OKEO4RIJiq52XPA=; b=cayCb0u9TYgkJru4lijvTZiyOekD26wMHG2tzLKAhhDwjm10Ci1VFNRgvOX4cHnEpPY0Gi6kfxuMU5LIN8X3I/0nSTDhBc/NJERGvJvV97Z0ZVFyb2EUfDKBqqIupKhEw8SlxC5oV7aLrwoFBRcViOlg2rtcM08qWIbV+XyMdDn6OAKAv6i6IawKfct83SAmLpEKjjdmE6fp/yKLlRf6nl/+7AnsNAG3bbuHKCk/oRYIocDdEnMHRejUPP8WkLEP/uYOFbUUKckfSc+oCqXMnjYbjmr34E9ceN/bGWdb/IbknO737PO7G/U7z3rjaR+upYQWxK4fqWtfCycVE0Y5qw== 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=JTzQbQ/RGwzZ/YqnqdMqI1okfDA1OKEO4RIJiq52XPA=; b=hw0WZlkpA4QzxdP6dOXI2ltIkbW8I6KQvXh0wRr2nge/IdlizYBwBpv99H5hVTH8F0XPko1qUOpGDZC08Zms8fIim8Qndb96AIyEftdoKXo9Lo5SnRv6UC3bcQctiWbMHnTYHpIS2fh7PLe9wV62edC179q8B4gWPmJWKQkT1Es= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by DU2PR04MB8789.eurprd04.prod.outlook.com (2603:10a6:10:2e0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Thu, 2 Feb 2023 00:36:55 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%3]) with mapi id 15.20.6043.038; Thu, 2 Feb 2023 00:36:55 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Vinicius Costa Gomes , Kurt Kanzenbach , Jacob Keller , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Simon Horman Subject: [PATCH v5 net-next 08/17] net/sched: mqprio: allow reverse TC:TXQ mappings Date: Thu, 2 Feb 2023 02:36:12 +0200 Message-Id: <20230202003621.2679603-9-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202003621.2679603-1-vladimir.oltean@nxp.com> References: <20230202003621.2679603-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0032.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:22::20) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|DU2PR04MB8789:EE_ X-MS-Office365-Filtering-Correlation-Id: a9099e56-15ca-4179-8b6e-08db04b59582 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wjsm1E0P/beOjFbcVZbu02LABCtCX47xSSiCCVHswywXCBu7Bnd/O3XhQnu6fLfsKzwfSzzZ/Ne3IT6winDFoOCg8CjhwtU+F8zkH49et+TXeVA3PdVLMgZrVmEIx/4xbmoWPI0QiTrSA3BL0Jrm/xE4tclldcoz2o5+UcJza92UhVx/LnMvfRxpcF7JPR1vT4Mp3KCoub23WtrPDRQ8qg0DIciLIrKr8R7tH8rSPXWYGgeqHwHXqhgAg/wgS13yxsOehkgoU1iKo2E2UQZMG9O4/sMMshNH4FxZhFc/eQxMsjbxHCDWNvCzBhPwtqmzj8uvrKbFVxWmhXlmG33Qe7D9xCd3B9Y4m6xwuN9TOSer3ZxuxvBk2yMim2H1PNPJCQe5saVrncU5/ADuGAOFSG4hne1aAoc6UqXcomxknyWvwhyf0XaDAI30GMCsA86QwugeH4xiOuuKlDT7RXSakCevsurIvrrRFQbXGSTtc2d46EdoZ8k6lE2OHbbP976VrewDKzjyJaCzcqD238TAnk5NJNhMQmVcA5QqJ0XeG63VEu3H+pnQGu2T5VNsZN057ZK3l0FtO2gRSTPoDwtkWZ3nnJQd5OOZwAMBlbPf1l8GQ/o+GvLGdFkGG5BN/5/vQsDRC8efkoj6WgbMdyr1L0a9q/chWZ1ig8JFE/ge8zUPlxC7uVyEaKgAkzDeubOi0k3HIJ86ylKNHROy/T9jrUb/on9Yha2tpObOBDBne9MrO7+umRqNnjsJk6+y9/MVFPectewj9n1Gf6L59hg7IQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(376002)(136003)(366004)(396003)(39860400002)(346002)(451199018)(36756003)(2616005)(7416002)(6666004)(966005)(52116002)(478600001)(2906002)(6486002)(38350700002)(86362001)(38100700002)(8936002)(54906003)(1076003)(6506007)(66556008)(8676002)(5660300002)(316002)(6916009)(41300700001)(44832011)(66476007)(66946007)(4326008)(6512007)(26005)(83380400001)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kxWe4lcC7XqUyTHylteszSeAxfVAxog5riOxwXqcyqWRJGwscss4AEnqZYeOqPIX/Eb498jkr75JZfvuznSOrdWuroWGtPcBnWxvCe3a+DsZbKkQyfy2Yw7WeIS/l7KI7UXYDVCmySeM4ntX/Suhq62i9UR5GFfTgpM4gSdZzhOf5CXBzek1EYGp/hnOB9+Yc2J4AuIVP6kviO0PGTH/FFyUideLK1+ZAMhGjadms/9b2kd/6KXKpbBdaGiof8Zn/eoRefxTuwxmVGg1ImrbmleiSdEYUZWquUvwP4r5MzUbtrdPdYE8LUPOF2+F+/q0G7HLeGLwrDCJwlFYuNsOYFTSBbgP/FIcWpg7EH6xfyG0CiDpGF5c99qiuAblbmxwwrGVNPMyG844XFtelQGnwxyIN/vzqqDi4sm5BL6klTo/atRtwc7YvpPaeWdq48xiwtNTGysOjS5mUDn5PuGhI+Ysd1QXHcM9kNKqrB4j0vAzcvUNlQwtbh28l7GYNtetmL8Vvtit8a+NfanWjT3d0yrsIQnejLipwWcZY9VO+gb75z0H4G6VIMIk37s7OyxcKq5KREwY7XIW3uvSzJxgJGY2bvLU7JQ44U+iMwd/SvaucmcLFyhjMwV0tngqIqJipt6J7oOeR1AHpotlpwcdB0yx7lyjqEeWVwsJi/Y1Q0KV9M6703GB+j60QpEQGZY6AVUVd4eqqyPONPIzBdYt7SC4EUKHDhmvUw6HNbWTeIIr/SEMOIYbGLK5L6DmfoC/xe/j4tlgvSFmoHdMZ1/asZdMBgJkyKUjQ1eFXz3XA/l+rxvbsT0ZRLVN/BMKpX5Sm51JcUmFzUCjn9te04Lpoh0Sb/vvhY2X9iX6Hr1thPwY2+1++QaArlKzmgSINjC5DrAuMUHPh4a3oN2itZqVXopH9qRJdTMzlOwHHrZJqEr2Sf9MlN0jGOuD6TD8tJLP97UUAEv8b7LIhfMkX3E3Yafc1hnTuctav5TOnWHS7VVsTwRnhomgvfnyy+f4lzKiIJDMT6KUsXLtzAIUpAGCRIrrNCJ6Y595yiDy0Ol47ULc/uqIWsWns3LEPFtfY7IZFZDT1jd1VTJckrlz3JW/yEVLOCw80UW3ztRC5LmAU5ZlYQ7wNqcrm22FYd14to83EpxmEMD66rxLOArr5IumwPUGJZHBhSg8piCtqCk7IKNmGxI58XhmyZY6phrauBU4NKIGTK6fXL20bqg1KMsE653/VtjkkUfE346aPH0kHllqgChZEEo3+UKJMIBTusV8Usb8wWs2TzZsVfhC5monlU6Jengyfmywi4uDBU0dNF/QAkfmgUs+J9Kl3/fVw+5xxqLTjcmyM6AGTidquwdi5h03cQazvr8adeTpMGgCbw4Vhyf+5tSCr0/FH8+lHEEf5i2a3LisrQmlIhTy93Rk63yq3iuchgNat3iTNpIDqJDUXcYgVpJrH1584uW4xGx9D/2FXeyWtSGcDhFe5C3aWw4W2qDJMwq7KeJlT/X+ghzAiBhyCRLw6TzUSiUgewB26JDuSFhWN7xAgxLVj61RJM8SEu5zjbc6yNERqM042yBCrXrMT6eBXqplAqayafsaMeYtYh+ptvasutRMGp8EXw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a9099e56-15ca-4179-8b6e-08db04b59582 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2023 00:36:54.9977 (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: fflHExwT7ZPSPXh9aOKqj6dx/RL3jZv1sZtt99Ka2SsH96fmZmW5RxdS926IfGjGhoKjiTyUPiYKFRwR7b/wsQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8789 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org By imposing that the last TXQ of TC i is smaller than the first TXQ of any TC j (j := i+1 .. n), mqprio imposes a strict ordering condition for the TXQ indices (they must increase as TCs increase). Claudiu points out that the complexity of the TXQ count validation is too high for this logic, i.e. instead of iterating over j, it is sufficient that the TXQ indices of TC i and i + 1 are ordered, and that will eventually ensure global ordering. This is true, however it doesn't appear to me that is what the code really intended to do. Instead, based on the comments, it just wanted to check for overlaps (and this isn't how one does that). So the following mqprio configuration, which I had recommended to Vinicius more than once for igb/igc (to account for the fact that on this hardware, lower numbered TXQs have higher dequeue priority than higher ones): num_tc 4 map 0 1 2 3 queues 1@3 1@2 1@1 1@0 is in fact denied today by mqprio. The full story is that in fact, it's only denied with "hw 0"; if hardware offloading is requested, mqprio defers TXQ range overlap validation to the device driver (a strange decision in itself). This is most certainly a bug, but it's not one that has any merit for being fixed on "stable" as far as I can tell. This is because mqprio always rejected a configuration which was in fact valid, and this has shaped the way in which mqprio configuration scripts got built for various hardware (see igb/igc in the link below). Therefore, one could consider it to be merely an improvement for mqprio to allow reverse TC:TXQ mappings. Link: https://patchwork.kernel.org/project/netdevbpf/patch/20230130173145.475943-9-vladimir.oltean@nxp.com/#25188310 Link: https://patchwork.kernel.org/project/netdevbpf/patch/20230128010719.2182346-6-vladimir.oltean@nxp.com/#25186442 Signed-off-by: Vladimir Oltean Reviewed-by: Simon Horman Reviewed-by: Gerhard Engleder --- v4->v5: patch is new net/sched/sch_mqprio.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c index 3579a64da06e..25ab215641a2 100644 --- a/net/sched/sch_mqprio.c +++ b/net/sched/sch_mqprio.c @@ -27,6 +27,14 @@ struct mqprio_sched { u64 max_rate[TC_QOPT_MAX_QUEUE]; }; +/* Returns true if the intervals [a, b) and [c, d) overlap. */ +static bool intervals_overlap(int a, int b, int c, int d) +{ + int left = max(a, c), right = min(b, d); + + return left < right; +} + static int mqprio_enable_offload(struct Qdisc *sch, const struct tc_mqprio_qopt *qopt) { @@ -144,7 +152,10 @@ static int mqprio_parse_opt(struct net_device *dev, struct tc_mqprio_qopt *qopt) /* Verify that the offset and counts do not overlap */ for (j = i + 1; j < qopt->num_tc; j++) { - if (last > qopt->offset[j]) + if (intervals_overlap(qopt->offset[i], last, + qopt->offset[j], + qopt->offset[j] + + qopt->count[j])) return -EINVAL; } } From patchwork Thu Feb 2 00:36:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13125123 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 AD6B4C636D3 for ; Thu, 2 Feb 2023 00:37:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229816AbjBBAhV (ORCPT ); Wed, 1 Feb 2023 19:37:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229848AbjBBAhE (ORCPT ); Wed, 1 Feb 2023 19:37:04 -0500 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2071.outbound.protection.outlook.com [40.107.22.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECABC74A69 for ; Wed, 1 Feb 2023 16:37:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O708ntO0JUk3MX9sA0U1FpiKe/blkzXVEmkGz+nphS16yoOi5rO1L+BH/rpARo5ryXfICahfzRoZKC6yNRzOxazhbTANRsbluf/9wNaL+aB24D/xf86aK4ACfqo5yDPaudi6Qsqw+Ev6WTWEV24g6zonfhbKCpHewy4ZZO89TaRF46mAx0n2kimnAUs7rWiZUhi+cib674DRsEhm9C5cqiF5D2yU6ObLxhYAaXFcpv3sXJ+3en+VHjfhuFFPTD9qZKTE8+dDNVkinqApW+NaVMT7pq8WxaHhumAAbOlEi9Z+2Vx2lNFMEzCBw4VPZpeo9vm4cSB18buphN6DGyfiUw== 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=hkKNoEy6Qpj9GK8h/uFSmsqpDjd3rkOGTueOcHo6oY8=; b=TlZIqsryenwnrLshgiA7Wb+7PjaTevrDrQPQFBfTteSxkMI0lv7TDRPQ9BpMW1/tRgP13Vz9Xo3LiCaoVJpEyaqf0G8lNKMDJCDk+zhefbcO6gxWFPFdSVlFmBUWrb1QkUhM6kiQBVsoa4wQYU739Tyl6c/b7JWqJcPnlPu832dXXd5TSkHtMqWFyY5wY7Cau0FqkYfbaV4TfjB0iRCBuxHZk1GC+9jdtnAdrk5Qa3v5eA9Rm7OBiQNUPMiQr6Wbv3agMwtRogPEKUC31cRx16a7xXwSQMAnaKDbIwVuMuZnx2i8QIsfyjAQCFz+wNe5ZlMiRxI4vvqWaGJB8nwANA== 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=hkKNoEy6Qpj9GK8h/uFSmsqpDjd3rkOGTueOcHo6oY8=; b=OC/uWdmrYIJbleJYQ1BHo2Gi8DUcOiQn6z9Qxy0srfdD+jBX0o+7S6Et8EwjDOPFqmvARLGBmIug4Yi9Suf3c65k6mcCXHWjI7lefkcFtH5+082hrfvbz9C+vbyWGz45ox9M17xTLfB3qmt9IR2GqAhuhAST1fcOQ8M3AVBExxg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by DU2PR04MB8789.eurprd04.prod.outlook.com (2603:10a6:10:2e0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Thu, 2 Feb 2023 00:36:56 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%3]) with mapi id 15.20.6043.038; Thu, 2 Feb 2023 00:36:56 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Vinicius Costa Gomes , Kurt Kanzenbach , Jacob Keller , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Simon Horman Subject: [PATCH v5 net-next 09/17] net/sched: mqprio: allow offloading drivers to request queue count validation Date: Thu, 2 Feb 2023 02:36:13 +0200 Message-Id: <20230202003621.2679603-10-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202003621.2679603-1-vladimir.oltean@nxp.com> References: <20230202003621.2679603-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0032.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:22::20) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|DU2PR04MB8789:EE_ X-MS-Office365-Filtering-Correlation-Id: 1e4c007a-ecbb-402a-4634-08db04b59622 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pUMdhKhD7fTgysnCRo899Rl2mWZkoredosvxnnHGoHW61dljZOAxkLDTCpeilWfsqDBgeI37li8XSqFULRytZFa3xVC7n5GJfarR2c58E3BHhYNY6/rN9dcxTD1ednnPjL+5kCtl59sF7JntlpV2ET0WrCbOblVPVxTuhymqFGoL61rvfg+4qf0FFLH7i7ZRwVxehZGUt2bEiSG0LDg4g7COBUYdg9S/0D7pvyPuVLzLGx7D+p4RQPHVUlcEbaEaVDEm0KKmnyz/sckPKdrM4ktB+NzPQl488jSam6V7iguUEPWBHkM9TOKttA77dnMlWU91SBEo/B7mrcRBZSWbNwx6LGOrJF+4hyJam+qT8iQCZBbiBNW4FaLcfg6eKdUbddA6kxZ/9Rxa/GCyUM6w0IYWRUCg+2kX/rE/YmjUeKmXmJSTEiKm9YR7OBzmO8Riyo4gn/QhEvV98QWx/C4GcmFYQT41W/LiWYeWmxiDctBHCsNUtNSVK/rqwBFCgcxuLZTzD7+yCPjDcgWoSmkwc+GrBznykJWtnY4M96wdRvqgBajatarKa0snb15slwczprApepc6LewAaxT6qSYYVa2ihyIpfCuudGkFqz7G2blhP58XUD37Vj8FRTdniLRiegMXXymukUqqVHqVtS4fbUZDPfmfS1OzphnQ/n+40hrbN2EYgDrZpQw0Zuoh2fTmnb+oZcz1P9tZj1HLnXd3Xw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(376002)(136003)(366004)(396003)(39860400002)(346002)(451199018)(36756003)(2616005)(7416002)(6666004)(52116002)(478600001)(2906002)(6486002)(38350700002)(86362001)(38100700002)(8936002)(54906003)(1076003)(6506007)(66556008)(8676002)(5660300002)(316002)(6916009)(41300700001)(44832011)(66476007)(66946007)(4326008)(6512007)(26005)(83380400001)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Abbv7rSJBLT7ces/mp/iJqZULI1J1khdowrCKYgMRfbSr41zM8jvoMUkBVHDgGKA2pNU1km7Ib6F1b6x61QP0ZrUnP79GzYaAmFNg7SV9E2TafwTiTCWgA89c/zm6JHbipFLi8z62nIY7QVAkFfYjSGPbUne06sNA7A8U5g62XH6NWFD1Rwrqxa8TyA+d81inELvWX11OxHMrLH32OI6DGUGK/FL53VTJcWuGaqWiRKfh/KrH3rvIt1D9aAa6FnVlc1/ehSuL/2JqxMkzio7huWGGA4sV2hWXJSyH3wCBzcwUsQbvh4MCnPdVQrPuq/nVeMruD9OpUdLVBFKfi8EYIfWskUz4Zn0Tz2Xz7vr4WoNyqe2qScXA0sV7HwkX/0509GUc4UdvF36QbmZJnhvetNEPpygp9prVGYO30otxT4747VdGhXlpiZN9meox2DHFM5EwBPlBgbPzYMVOOpI1Ot0/CbFxAA43IgMdbbcnvkC3SXiOwyi+hIFm2xBJ232seW0Z3fGPDQFDwF4wxooPRJthCoqW4+57kdu1b2D26feH9CkNcXW/zcxiIrZyAsWXf1BDJQ+5v24eAL52W6Jv4K23ouIkdMiK0vWGPcT4VsiKSvYwYnYXrugSsrfj1rlEyoPjjBgRHSMtWF+fNhbdZApEdwMGwlD/xmKCv7wfFaW1umtFB3n3CQnx9586DJqhouSyGfKrw8/al7RALguFpwjYGlmtachYxI+49ngHsoR8sduogDh073jYvb2b4XqwOpDPFPjv0fQpERKtkH0lud0g8K3JAAcqwP4BNEYRFHvESaiPKOpVVVKqzAOHME//n5enYk9SXYQNFUTsNF18qt5j7940NIC+kS/QuXtwMO/8a+AMYdRii4QTVM3nk8dStxnkDf6IcYTUZhjrsUyk19eyu5NKqwAIed6NYKtDKrwFDkuOcmSPz0fnxwYAYUiGSlBwbD99ecBCSkke1pW1KQKMtN33OU/x2AZQiSE8XmY1PXFnXT2GkgBeixodIV3wgylqt3H1TKMSNYRXHk+Uo7p63EjHFXDETtFikhani4MRqqam4ejQooVr1z/iuLqPi8zokrLW+Ta3fNTOUT/w/9hY5cEokAixqS4R0tvxC0df5H/x/Yh3AcTiVi0xaWwH4W0VHnxwzmUurONCzV/UpDWy6V/hRUjlNcztHC/NI0zS1pGGUcN6T5htsye4x/gbizUbZySRXIi9erBJTjaWTbct2Cknvu7gH4G+CF58/LmzPuMVwrkB/gY2S9ugHva9nXzoYg39k0g3Gc6QXA+COlc5hh75LkQznFwO13+GBa8ARKFpnxmoJz92dQHtimIK9PO35vE7MAPSXkT3VMxxIY4WtJ7yKmLnsG/lbZJv+63l/NAd8SDxC8fluksRxkmR8h+72SuqYEzI1Zeo2oOppGkGu33P2M2Q76+5IZ6XZbA7QXBGPaQtJ1ADYRaT2cvZz/73N60+PNkQzOcqwpsqnQF5/7qciuSNQIZLBzhUA5i8YZ4Ha1BuAXT3AxdFPuGEx187IY74c6CM19ybTdRuBW73wGvDJC4ifpdAsgJ/aVNWWEV0u61965/Si6M1iVEhpWNCqiWEGxS7ObZRFoCnA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1e4c007a-ecbb-402a-4634-08db04b59622 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2023 00:36:55.9196 (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: K/xrsqxYZXrfpbHF1mbOkYCXWfXJtLIpcVXHQCpuJz3bqg3cbJAm20fXLd+IplS00P4WgNJtSUyrStvswl74Aw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8789 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org mqprio_parse_opt() proudly has a comment: /* If hardware offload is requested we will leave it to the device * to either populate the queue counts itself or to validate the * provided queue counts. */ Unfortunately some device drivers did not get this memo, and don't validate the queue counts, or populate them. In case drivers don't want to populate the queue counts themselves, just act upon the requested configuration, it makes sense to introduce a tc capability, and make mqprio query it, so they don't have to do the validation themselves. Signed-off-by: Vladimir Oltean Reviewed-by: Jacob Keller Reviewed-by: Simon Horman --- v4->v5: - call qdisc_offload_query_caps() from mqprio_init() - call mqprio_validate_queue_counts() only once, from mqprio_parse_opt() v1->v4: none include/net/pkt_sched.h | 4 +++ net/sched/sch_mqprio.c | 75 ++++++++++++++++++++++++++--------------- 2 files changed, 52 insertions(+), 27 deletions(-) diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h index 6c5e64e0a0bb..02e3ccfbc7d1 100644 --- a/include/net/pkt_sched.h +++ b/include/net/pkt_sched.h @@ -160,6 +160,10 @@ struct tc_etf_qopt_offload { s32 queue; }; +struct tc_mqprio_caps { + bool validate_queue_counts:1; +}; + struct tc_mqprio_qopt_offload { /* struct tc_mqprio_qopt must always be the first element */ struct tc_mqprio_qopt qopt; diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c index 25ab215641a2..466fbcb5de08 100644 --- a/net/sched/sch_mqprio.c +++ b/net/sched/sch_mqprio.c @@ -35,6 +35,35 @@ static bool intervals_overlap(int a, int b, int c, int d) return left < right; } +static int mqprio_validate_queue_counts(struct net_device *dev, + const struct tc_mqprio_qopt *qopt) +{ + int i, j; + + for (i = 0; i < qopt->num_tc; i++) { + unsigned int last = qopt->offset[i] + qopt->count[i]; + + /* Verify the queue count is in tx range being equal to the + * real_num_tx_queues indicates the last queue is in use. + */ + if (qopt->offset[i] >= dev->real_num_tx_queues || + !qopt->count[i] || + last > dev->real_num_tx_queues) + return -EINVAL; + + /* Verify that the offset and counts do not overlap */ + for (j = i + 1; j < qopt->num_tc; j++) { + if (intervals_overlap(qopt->offset[i], last, + qopt->offset[j], + qopt->offset[j] + + qopt->count[j])) + return -EINVAL; + } + } + + return 0; +} + static int mqprio_enable_offload(struct Qdisc *sch, const struct tc_mqprio_qopt *qopt) { @@ -110,9 +139,10 @@ static void mqprio_destroy(struct Qdisc *sch) netdev_set_num_tc(dev, 0); } -static int mqprio_parse_opt(struct net_device *dev, struct tc_mqprio_qopt *qopt) +static int mqprio_parse_opt(struct net_device *dev, struct tc_mqprio_qopt *qopt, + const struct tc_mqprio_caps *caps) { - int i, j; + int i, err; /* Verify num_tc is not out of max range */ if (qopt->num_tc > TC_MAX_QUEUE) @@ -133,33 +163,20 @@ static int mqprio_parse_opt(struct net_device *dev, struct tc_mqprio_qopt *qopt) /* If hardware offload is requested we will leave it to the device * to either populate the queue counts itself or to validate the - * provided queue counts. If ndo_setup_tc is not present then - * hardware doesn't support offload and we should return an error. + * provided queue counts (or to request validation on its behalf). */ - if (qopt->hw) - return dev->netdev_ops->ndo_setup_tc ? 0 : -EINVAL; - - for (i = 0; i < qopt->num_tc; i++) { - unsigned int last = qopt->offset[i] + qopt->count[i]; - - /* Verify the queue count is in tx range being equal to the - * real_num_tx_queues indicates the last queue is in use. - */ - if (qopt->offset[i] >= dev->real_num_tx_queues || - !qopt->count[i] || - last > dev->real_num_tx_queues) - return -EINVAL; - - /* Verify that the offset and counts do not overlap */ - for (j = i + 1; j < qopt->num_tc; j++) { - if (intervals_overlap(qopt->offset[i], last, - qopt->offset[j], - qopt->offset[j] + - qopt->count[j])) - return -EINVAL; - } + if (!qopt->hw || caps->validate_queue_counts) { + err = mqprio_validate_queue_counts(dev, qopt); + if (err) + return err; } + /* 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) + return -EINVAL; + return 0; } @@ -254,6 +271,7 @@ static int mqprio_init(struct Qdisc *sch, struct nlattr *opt, struct Qdisc *qdisc; int i, err = -EOPNOTSUPP; struct tc_mqprio_qopt *qopt = NULL; + struct tc_mqprio_caps caps; int len; BUILD_BUG_ON(TC_MAX_QUEUE != TC_QOPT_MAX_QUEUE); @@ -272,8 +290,11 @@ static int mqprio_init(struct Qdisc *sch, struct nlattr *opt, if (!opt || nla_len(opt) < sizeof(*qopt)) return -EINVAL; + qdisc_offload_query_caps(dev, TC_SETUP_QDISC_MQPRIO, + &caps, sizeof(caps)); + qopt = nla_data(opt); - if (mqprio_parse_opt(dev, qopt)) + if (mqprio_parse_opt(dev, qopt, &caps)) return -EINVAL; len = nla_len(opt) - NLA_ALIGN(sizeof(*qopt)); From patchwork Thu Feb 2 00:36:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13125124 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 91839C636CD for ; Thu, 2 Feb 2023 00:37:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229940AbjBBAhY (ORCPT ); Wed, 1 Feb 2023 19:37:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230017AbjBBAhQ (ORCPT ); Wed, 1 Feb 2023 19:37:16 -0500 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2071.outbound.protection.outlook.com [40.107.22.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AE3574C03 for ; Wed, 1 Feb 2023 16:37:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mh24nRT0K3sSmJcLnCbebm67fF2/H0C0SDOM+EdfGb+39pQKx4MSkhnVRXiLhyQWFmjhyoetJ5iI3vzTo+m3aWx5J3iBM8fxtiqOPiQKFkF8NE2qztYmRTdLdqoJ9pT7vUq8sGXWwZ391k+IaokfDT3bACaZ/EKOnCU8Aj/sUG9G7v4j5Jf76QI9GS1ih827R25vuBJ40qvL1b8UKlEHAzQmJkuv3NYeuSY8XIAVoQ3tRg0icn1h6Vuuwx9GkCa6hsXRg6lDzhIU70V0SGqbIjZcI93USqiJ52JJOkdTQwH1HmhRYbDOYyIbRI304B0v7YUJhNOGlIUa/IHyapWsKg== 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=zPu9L9SMPosHKaSS66Ncqh7IFWxQBxNYCkfBsEfEV1k=; b=UsOsNvqP01aJICtZB/gdhGTWNb5EnxrSdpl7evSRRt1rA7eXRz8vgtaYjXrvEq8mplyqy1JJjz3I80frOzffXU+KigTCBox/qGFNjshIXAm8L8zpXAXJG5gd1tQf51cEzcmxbjmjQUTkCzIqqK/fmsZq9c/hEYxRIxMKRPFyjbjqpNj43GHRZceYIVZFb4ccKLuVLL4AycF00xFXn6+TCe5OOxfXowBSRMEH5WYMUHX7jvdXd0YrNdPu1tYRlaRKn4VYidLHgdbGnuFLpzJOiAkQv4S5x3188j9nPvSoMdQldI1OtwQonw40mnF7tp2WSfiUYGtCyhDdHEhZN1skXA== 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=zPu9L9SMPosHKaSS66Ncqh7IFWxQBxNYCkfBsEfEV1k=; b=jy/mXn8/t0NZdxylTnCq84Da6N6MZmkCggtLA7xMYMDjUyYJwTspH21z1UzNJ+ZQckJ1nOEpd2nJ8xN5Sj8+LDV/wO0BY5i9MhRSmUVPhV1X+5aEFghVFy6bV9Jefd6IYOyu7zvSdCJ7O8wGDr9dPGkftH3h7aho6id5rAOGi2s= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by DU2PR04MB8789.eurprd04.prod.outlook.com (2603:10a6:10:2e0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Thu, 2 Feb 2023 00:36:57 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%3]) with mapi id 15.20.6043.038; Thu, 2 Feb 2023 00:36:57 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Vinicius Costa Gomes , Kurt Kanzenbach , Jacob Keller , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Simon Horman Subject: [PATCH v5 net-next 10/17] net/sched: mqprio: add extack messages for queue count validation Date: Thu, 2 Feb 2023 02:36:14 +0200 Message-Id: <20230202003621.2679603-11-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202003621.2679603-1-vladimir.oltean@nxp.com> References: <20230202003621.2679603-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0032.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:22::20) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|DU2PR04MB8789:EE_ X-MS-Office365-Filtering-Correlation-Id: 5d26e372-aa07-4ec8-d9ff-08db04b596ba X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: B2Y12aMITHMorWv8JeogZn37tfqEPVJRnN30RbnOCcarpP/9aw06RnVcqiO3eRecEXMqhykzjJqTSBm8JP2/7KpOu+Zr+1LYw0U8xsYUcFtiKmvp05qBlCqiMZAlLna4l368KLMNGoOZy3XNuEMzX3EaRBwz5wSAx7tJJGbAy0MFPhOAnYUK807CDW5JqrqKIyymavLRAdxq+1rR1jQtOfxPcJZohJ7VrVCjNRhG0m2egroJjlkEnCxsso8J3e7YTPuW3Y/edRenUMkIA4dhZUbddrrymcs6U6DKd/QBt4F7QW8uNg8rIkCDKIGSmTJu5zooqxmMlR+OV/S9yLjxwrPLoOOcTIDf4vXx4Yly0AAJWnG5/e0O/4QXfxagbhKoredOMBpQjgMt5rRIUahJ8km23BAX1NO1i6ayDNe2fYue2WSgIW1Uqv1nuxQH2w79eoYm1jsJrZQd6ssSc3LxBGi0DIWxbr+ga2QemF4xdT8+M3w16rVJOR2tdKT0hR5g9VR6Pcnn1cNkdN69fDkHU0gT84Mq703TYN32aBZweU4xwaGv2kMNhjE6ffxf+VsMNkIGWdDgOmSJXDLtPdEbBRq1RilzamheEVjfm8HLQuJfPQ/X+mTrS3OOp8NQTZ5xlGiJ20Pom611u+AxMue6LMNZByVZC6Ftr5LCFeXEZJBFVw9ZN+OpNsfxQNbYfKvfV7vtXHK+K7ZNAKg8HlCRGA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(376002)(136003)(366004)(396003)(39860400002)(346002)(451199018)(36756003)(2616005)(7416002)(6666004)(52116002)(478600001)(2906002)(15650500001)(6486002)(38350700002)(86362001)(38100700002)(8936002)(54906003)(1076003)(6506007)(66556008)(8676002)(5660300002)(316002)(6916009)(41300700001)(44832011)(66476007)(66946007)(4326008)(6512007)(26005)(83380400001)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Woe0h5jpnEc9lIYP9ftpULa0/aorjTI3XJfdMrayyallawTB6DcSD2rcM1ZWTIpU2SM5bQWXmIPFBBmlVeQ34mnpL3NfowQgSfEPpSAwRkWsq19YGSt8bIP/RzOgdu8+f37sZFEUli3OvN4uOJGC32hTh4cqpfSJ8lZCJuS3xCuh9K5gCxq4q11GY4eByqWj7MoSnaEUhz9XY1BJEIJ9wiAJ8EYflIsqNTe/mFVeI9FjGurSbQpyFPV1+rqIRUSr3PrUocO5m0J/Rjb9J1MqVXoTyxIMEfTF9vruK5UStcAaRjmrLyZ8Wf4uiTfH6iEiHd6wmeYJ0hAyowvvqDltiqsz6z7dPb2fOSHOg2TAPzq1BEI4rDrTfUx0Qd8LATnc2Uq5Ym293UX9MDwbuEg7Eq9/QVIGXpJvgQekDtqtK0X/zxxa7XdpnKPZ5Y6LbYYkTkKWcIdIYZxq/Ffya9HehjLMrCo9SDQebjRt077i3+IKf1aHyD7704IGkX41ghHrSbzwSTC8T3QO+uAJbwibxFV7AqpiCsh7QjIWMhLXGBBRaR47a3haXPD8u+qkF8/VMg+MJ8fFow3y78KWcWFUrTwvzp3TjaLANwk2R7pzZv/X3jWrfcIVx8ew6gtxHMl2DFE5iAtDJwncEeGfKcePp4+u6p0OhQLKE4tgRbFWmnZWzcMpGyMiUO+uOvyZrVtm0rpNa7lVU1sBpg6nYyfpwzvbjTCOVbp3m8Zbaa1Cd9iGUKuMF/pjYiYXzEGtPnYeimYwQff7U+GN4F6kcnw4qTlfwLDyHnmsNvo3vocMagn6upfX9r6uOnR4am12BnKPdy40qAFo0iPGQnKyqlNxswMOXGUYKS3rST+K/9h3P7AZXaaIIrMsH0VfMVRwNeFXTaBlb6vAgBENn5naZTadFzPU6SD7yN88u1ztZA5ZyORDnjUtGtRBDpBlF8UqTAfn50dta29ycBJ+5X81lWFUf80FEpg42dQdZTGcnfjGfRbCBI/VXyf2Ay95+LSq6CuCMMWHy28nJODn24aTPez3AOpi6VllMPFnw8BmaHu33ChsxWZxuv7TbwPCfnMHJ1XQY489p3oyZbPQ6FjqhNsPKSylX8vxmcESJbjhS1HF54kOLZkQGSirVSL1PWZXolW1E3k7qy2rn1FinvxCLNkxqeC46fS9BAy26v/fM1JJ5lnWpy3jFQ4VZIsPlP7Uw2kzCxKW0zE7YAdbp62D2HWMYJavdREnEonFXCOXUcv9DBR+EKIVdZyAD0fmACtWpD7BhgdM5y54r+uIn3H49tRabNmqvdmgHTN5vD0qkN5pHONAROhJqsm8mO2zDItUcjrg6wPrsiDtLDVlKl12UJZ01taLvekOwcQMtA25fZFKgLSP3X/LNPPrR1MWGdooZnoe66uWUKdOBvfAA2zCGI1gCxS5wSwyqNCSOjVl88aGTC4Hynif+4fD2G3nNpeOr+oZy4O6P5I7ImemL9et66nSiGUdzJo2NE2cyPvXg4zNjNAcQhyWcV+5B3HJovAO+VNqbSBBS9xcDs5dkT3C8y4z4rUuj6/s/H5vMkmTmrIWS9jFufygDrcUGaZnOfTuwgpbvyNsv0DKM4WatKFm9zZefg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5d26e372-aa07-4ec8-d9ff-08db04b596ba X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2023 00:36:57.1851 (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: 4BkSPNCXzvZNKzh+juLTwbhBar3Se7y32t8qSJ9OY82kdNvqN214GpsfqJF8qmZcO1mhzRzyFKqOq87vFA8spQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8789 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org To make mqprio more user-friendly, create netlink extended ack messages which say exactly what is wrong about the queue counts. This uses the new support for printf-formatted extack messages. Example: $ tc qdisc add dev eno0 root handle 1: mqprio num_tc 8 \ map 0 1 2 3 4 5 6 7 queues 3@0 1@1 1@2 1@3 1@4 1@5 1@6 1@7 hw 0 Error: sch_mqprio: TC 0 queues 3@0 overlap with TC 1 queues 1@1. Signed-off-by: Vladimir Oltean Reviewed-by: Jacob Keller Reviewed-by: Simon Horman --- v4->v5: change extack message to say full TXQ range of TC i v1->v4: none net/sched/sch_mqprio.c | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c index 466fbcb5de08..3b6832278d83 100644 --- a/net/sched/sch_mqprio.c +++ b/net/sched/sch_mqprio.c @@ -36,28 +36,44 @@ static bool intervals_overlap(int a, int b, int c, int d) } static int mqprio_validate_queue_counts(struct net_device *dev, - const struct tc_mqprio_qopt *qopt) + const struct tc_mqprio_qopt *qopt, + struct netlink_ext_ack *extack) { int i, j; for (i = 0; i < qopt->num_tc; i++) { unsigned int last = qopt->offset[i] + qopt->count[i]; + if (!qopt->count[i]) { + NL_SET_ERR_MSG_FMT_MOD(extack, "No queues for TC %d", + i); + return -EINVAL; + } + /* Verify the queue count is in tx range being equal to the * real_num_tx_queues indicates the last queue is in use. */ if (qopt->offset[i] >= dev->real_num_tx_queues || - !qopt->count[i] || - last > dev->real_num_tx_queues) + last > dev->real_num_tx_queues) { + NL_SET_ERR_MSG_FMT_MOD(extack, + "Queues %d:%d for TC %d exceed the %d TX queues available", + qopt->count[i], qopt->offset[i], + i, dev->real_num_tx_queues); return -EINVAL; + } /* Verify that the offset and counts do not overlap */ for (j = i + 1; j < qopt->num_tc; j++) { if (intervals_overlap(qopt->offset[i], last, qopt->offset[j], qopt->offset[j] + - qopt->count[j])) + qopt->count[j])) { + NL_SET_ERR_MSG_FMT_MOD(extack, + "TC %d queues %d@%d overlap with TC %d queues %d@%d", + i, qopt->count[i], qopt->offset[i], + j, qopt->count[j], qopt->offset[j]); return -EINVAL; + } } } @@ -65,7 +81,8 @@ static int mqprio_validate_queue_counts(struct net_device *dev, } static int mqprio_enable_offload(struct Qdisc *sch, - const struct tc_mqprio_qopt *qopt) + 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); @@ -140,7 +157,8 @@ static void mqprio_destroy(struct Qdisc *sch) } static int mqprio_parse_opt(struct net_device *dev, struct tc_mqprio_qopt *qopt, - const struct tc_mqprio_caps *caps) + const struct tc_mqprio_caps *caps, + struct netlink_ext_ack *extack) { int i, err; @@ -166,7 +184,7 @@ static int mqprio_parse_opt(struct net_device *dev, struct tc_mqprio_qopt *qopt, * provided queue counts (or to request validation on its behalf). */ if (!qopt->hw || caps->validate_queue_counts) { - err = mqprio_validate_queue_counts(dev, qopt); + err = mqprio_validate_queue_counts(dev, qopt, extack); if (err) return err; } @@ -294,7 +312,7 @@ static int mqprio_init(struct Qdisc *sch, struct nlattr *opt, &caps, sizeof(caps)); qopt = nla_data(opt); - if (mqprio_parse_opt(dev, qopt, &caps)) + if (mqprio_parse_opt(dev, qopt, &caps, extack)) return -EINVAL; len = nla_len(opt) - NLA_ALIGN(sizeof(*qopt)); @@ -328,7 +346,7 @@ static int mqprio_init(struct Qdisc *sch, struct nlattr *opt, * supplied and verified mapping */ if (qopt->hw) { - err = mqprio_enable_offload(sch, qopt); + err = mqprio_enable_offload(sch, qopt, extack); if (err) return err; } else { From patchwork Thu Feb 2 00:36:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13125125 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 32E4FC05027 for ; Thu, 2 Feb 2023 00:37:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230136AbjBBAh3 (ORCPT ); Wed, 1 Feb 2023 19:37:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230131AbjBBAhR (ORCPT ); Wed, 1 Feb 2023 19:37:17 -0500 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2071.outbound.protection.outlook.com [40.107.22.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2342F7448D for ; Wed, 1 Feb 2023 16:37:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e6u8C5CbL5ySc/p7NlMkI1AzimyJavTreoCgX0baDbdpiSIEA3Puy/ZGyWEFJStCFF19i4JbvFD+imPkj9U/Akh1abzVsrBi0PbVdlAVU6WWZOZl2fIclAZJkL0PBGJ1yxxJRd22oycD4UdOEHSUHgyDw9HOOYb9DZyzRcc8u0tzsC3JR6IJl9J2SURFpxtvIkfa3qLQ2sLSNwTXpiNevPCHCcwoBoJIhDlcCucXfCNKCGOCX5SWfExHzbb0wBPQdWLUL32h11jerhhD2/NrH4NimZnykx5tlowMkHDT+c78g4/5DoEb6NoyMRSYUly6UlwqixaKuzbs9Eoq8oGSFw== 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=5OHxym3zSKqe4O0DeBlok5hGMlnqeAD7RS55cysdQw8=; b=A0959HNT/sSvSeO5itxgdwn/lDvn2gbvf8yHuU0cXaYjK1FbNYIgmp4EuqrHfeHprBx1+OK/Xgz7ukZf+if08WTvv4Tahta7fg3zUE8+AXGsZ08SlHuBglJhqhz7KieuR2rIjgATBxRpl1Mypegh3DCAI1i3b+0eV8XcnMsQKI8CasHE7oD/rfIufNYcgw6oFSUIcE/0+JgixXNni+rdowHYNxXQKRl54t3GFwB7P4lUQNrOgQnxbijDon53dw/enaUEpDUvxL5qLemwB4jVirsRPgscSGmHVnvfSPnsMUX0K+b1BYS4Tnx/bCF5V4PjlU/6MUJeDv0A/IAYQnG9jQ== 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=5OHxym3zSKqe4O0DeBlok5hGMlnqeAD7RS55cysdQw8=; b=s1adM0LHIXGWBoyzOk4/qq9aqVSIFAE9WpPocm08iwKjlIeWMFdAhAcS8Fv1qLDe+GPdg/wIgkbHSq0AOaJQguMQr2MySRFq5Ra6EG3TNITkPSZTircixRKPBqVOSa0+yERgW7/EYqkii+wRiLxc5LqHcxZO/iKFAaowgvcrqeI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by DU2PR04MB8789.eurprd04.prod.outlook.com (2603:10a6:10:2e0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Thu, 2 Feb 2023 00:36:58 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%3]) with mapi id 15.20.6043.038; Thu, 2 Feb 2023 00:36:58 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Vinicius Costa Gomes , Kurt Kanzenbach , Jacob Keller , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Simon Horman Subject: [PATCH v5 net-next 11/17] net/sched: taprio: centralize mqprio qopt validation Date: Thu, 2 Feb 2023 02:36:15 +0200 Message-Id: <20230202003621.2679603-12-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202003621.2679603-1-vladimir.oltean@nxp.com> References: <20230202003621.2679603-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0032.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:22::20) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|DU2PR04MB8789:EE_ X-MS-Office365-Filtering-Correlation-Id: ab385a97-8509-4826-a733-08db04b5976d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0q06kTLu+VbNzijI5Xb+Ersc4yRlPqcmapj+5ghRJS+hp0CjdcPVIuwzsq90h/N3eVPSCMEYURmhLUwl4zUjOAWyLWqAhVCgY9ftPvZX++IgkAZn9DIAXNQZNodTIUGxzv/gQDz/Vv5C1aTmAiZgphCrG56gWLQnVK03lWAgkm0Ll71tJOwWQDsIeCBR+MgsAVZV+/trKfwswRu6g+wLRnQ6rsnzeNTf8XewDPx/uvJMEIrTgLTVDdYe5XXs8BCjXP/E3LcbQKXNIOg/I6dVnxTGwb+A0ZevfiyKTFhS4Lbuouj+8XjW64xrGiKhbWfSNUE+RBdPMB95TyTN/rI6xy9uvcyHZM8JoYP5HWZcOcQ7cSA/1raNOztKvLo2OJRcONRx0Mi/48K03kU7fLr7CHV+CnuWGL+bFjMoUAQOD0RPCvAx+7jSJnHNnVSFhMVCCHQ6luBIIrGj6gng4ctXJSsh2HcVjoNFmFlmE8YRA8LpyQgIApYb8GV6It0qwEI9DaBHjME6ZbeFZlVQ+fBhdLCjyVU2HEG04aHS/ZwRAyM5+Yk+bzf16dcyJqm3fUuXdvSFHlArzhyy1J6QZqVH5GTw6PjhSI1PLOYyBx7ixHEx2aC1ydD4QeLLZDY1ryDa446hIXjcgrxPJtpUr3VGg4CvmJ47FmR+zxuyLv4YkUS96f4nLA4WpZ4EncXEAuB1cTaTBW9cEOYr/722gwdFng== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(376002)(136003)(366004)(396003)(39860400002)(346002)(451199018)(36756003)(2616005)(7416002)(6666004)(52116002)(478600001)(2906002)(6486002)(38350700002)(86362001)(38100700002)(8936002)(54906003)(1076003)(6506007)(66556008)(8676002)(30864003)(5660300002)(316002)(6916009)(41300700001)(44832011)(66476007)(66946007)(4326008)(6512007)(26005)(83380400001)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zrYIFX/1MKhGWPqsPOzVmbjs1kBiFymAKL/DjXPuCiRXrQKDeKYt4wumbsDau4H52i8D1Fyo3ANzMU2I3z/5yzUH/Jx2pJT7XoooT6eukWhY9JELPcSQcR+ZBBHSgtmPxfWNKJjY52vLJCATcrtKra6lRdCodcxZRAIibGsU2ijqZgszA417E0WXO1AACkn+DY4Lj9slFoVlpdsAYxQ3yEpZcIWdSKrKMPLGas1jcW6y6T4RiN/tTcyyriOcukn8gWLuNTHYzwmfrJUMJFxh83uYzRvUiGkp4WtGgCtSTpLPbeZnBLAeTXPCvETqSy86IxrI+D+bV045JE0MGMk39WYrX5oONl04wIZwPloGPU+Gp/uWfBjIWec1s4M9x4BQafz4XErNBVVyWJOCGU4XRtsdU/7bWePL9L+YYrkAF8ej/485kGolP+5cCW+asN2G22vJSBwt5UUxyJYX+tVckVLcBY4W4QoMP/OluctjG1SHAngo3kOZTHomPCxilkPApl4MLyk4WOqwiz4D4HU7dB/cZrnWZRYJYictBsqRd2UghGUUPhvsA5PqsyqCd+vpju3sAaSDcFnRP1Ccc7qVlzRsj/u8TOPhJKbZZE94rMR7dAkzor8VeaJYRileBGbUTBzdNJ+iGGE5nqh/8GukXCBseFI2FBmdQHb26B3EQ3zXYiJr4RJedwLiHZ9KZrJbNz4ICPXa0JLG2zEDht0MDANtmkNhaU4zPTRcenbsHQFIfcb/92ZqY4UyvbPOoAsJ8m3oixlG1T68WYWRfUG3OOb6Aq8mr77acwkYbERzR4hg8PtsPHgLPNQR0D9uzDH6H8YtNToQHyB8T+CEO/1smbJFUe5o8ZnvTf5OUYaSFRR4ECn1OGDCY0V3VP+UMfscDrSelqKPWooai4GraQ+uLn5JT6FSVUjEFvYfHwSObl8xhtJ3yrWIIB5At/6elFKXG6UXSZXrLPqN8w4qWSx3QXQWnFEIAMt8Cmlfxn44PsCTrfFO4+NHgsivGX8QUzMhZvPP8AJhWNi6Q7boQ+VDoFmszxHWmAXHeeQWiF5DGZbyJjVi7WHjBuxSrVru37Yok7H9XJ266MOdwOh7UGnZogyqJfYkpKoixt+biuE8Mr0clH/8lmLFCwNqM7MX4lRacdcKPGMG5uab37N6CmtVW8wPgtWCr713YeK4Jy3/kxUCjitc3wIcusPWOJpqimXKXj5Jtm9VMrLH9VF7ZNbwvDJsz9qBRhpim/gLviSh3s0GvNlthhwNyrjhmmssV4K3aGv35bjVO38BAfm+ARTTRzDYxz0ND8bcxHAfgUiYc/ec03aGpanOwUeVmBxs+vw96QuRlndFnBpn+dFsiI6gusbnkQr8xnNYZi7CSz6Qyb31etXe0OCMjDR8F07l4hKuOJ15wMv65pCifINViPsMT7NwoIq/3g511R40bVAms8NbvsJtkc2NdkaEs+j1eZZL/OtGIJelquWqwrwFa+gB5Ny0Au50+1Hg8fSf7mttBJEEKvHuUryaMpJd9sp1/dNQAD10zS790fbSLHt5Up4mKD+aA6v4rLZYtoYaYClf2SgWi04ecQP2RRmLiMIx+clRv9T9opo8XsbgfycYllQLig== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ab385a97-8509-4826-a733-08db04b5976d X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2023 00:36:58.3100 (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: 4TIr1fbGP4oyUAEUIigoBTosiEhA7T4yfZ/NSHufBGZ/1EsRovLibcxOSWepbN4JxBvuMSIzVY0rEUNBA6LaCA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8789 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org There is a lot of code in taprio which is "borrowed" from mqprio. It makes sense to put a stop to the "borrowing" and start actually reusing code. Because taprio and mqprio are built as part of different kernel modules, code reuse can only take place either by writing it as static inline (limiting), putting it in sch_generic.o (not generic enough), or creating a third auto-selectable kernel module which only holds library code. I opted for the third variant. In a previous change, mqprio gained support for reverse TC:TXQ mappings, something which taprio still denies. Make taprio use the same validation logic so that it supports this configuration as well. The taprio code didn't enforce TXQ overlaps in txtime-assist mode and that looks intentional, even if I've no idea why that might be. Preserve that, but add a comment. There isn't any dedicated MAINTAINERS entry for mqprio, so nothing to update there. Signed-off-by: Vladimir Oltean Signed-off-by: Simon Horman Reviewed-by: Gerhard Engleder --- v4->v5: patch is new net/sched/Kconfig | 7 +++ net/sched/Makefile | 1 + net/sched/sch_mqprio.c | 77 +++------------------------- net/sched/sch_mqprio_lib.c | 100 +++++++++++++++++++++++++++++++++++++ net/sched/sch_mqprio_lib.h | 16 ++++++ net/sched/sch_taprio.c | 49 +++--------------- 6 files changed, 140 insertions(+), 110 deletions(-) create mode 100644 net/sched/sch_mqprio_lib.c create mode 100644 net/sched/sch_mqprio_lib.h diff --git a/net/sched/Kconfig b/net/sched/Kconfig index de18a0dda6df..f5acb535413d 100644 --- a/net/sched/Kconfig +++ b/net/sched/Kconfig @@ -195,8 +195,14 @@ config NET_SCH_ETF To compile this code as a module, choose M here: the module will be called sch_etf. +config NET_SCH_MQPRIO_LIB + tristate + help + Common library for manipulating mqprio queue configurations. + config NET_SCH_TAPRIO tristate "Time Aware Priority (taprio) Scheduler" + select NET_SCH_MQPRIO_LIB help Say Y here if you want to use the Time Aware Priority (taprio) packet scheduling algorithm. @@ -253,6 +259,7 @@ config NET_SCH_DRR config NET_SCH_MQPRIO tristate "Multi-queue priority scheduler (MQPRIO)" + select NET_SCH_MQPRIO_LIB help Say Y here if you want to use the Multi-queue Priority scheduler. This scheduler allows QOS to be offloaded on NICs that have support diff --git a/net/sched/Makefile b/net/sched/Makefile index dd14ef413fda..7911eec09837 100644 --- a/net/sched/Makefile +++ b/net/sched/Makefile @@ -52,6 +52,7 @@ obj-$(CONFIG_NET_SCH_DRR) += sch_drr.o obj-$(CONFIG_NET_SCH_PLUG) += sch_plug.o obj-$(CONFIG_NET_SCH_ETS) += sch_ets.o obj-$(CONFIG_NET_SCH_MQPRIO) += sch_mqprio.o +obj-$(CONFIG_NET_SCH_MQPRIO_LIB) += sch_mqprio_lib.o obj-$(CONFIG_NET_SCH_SKBPRIO) += sch_skbprio.o obj-$(CONFIG_NET_SCH_CHOKE) += sch_choke.o obj-$(CONFIG_NET_SCH_QFQ) += sch_qfq.o diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c index 3b6832278d83..b10f0683d39b 100644 --- a/net/sched/sch_mqprio.c +++ b/net/sched/sch_mqprio.c @@ -17,6 +17,8 @@ #include #include +#include "sch_mqprio_lib.h" + struct mqprio_sched { struct Qdisc **qdiscs; u16 mode; @@ -27,59 +29,6 @@ struct mqprio_sched { u64 max_rate[TC_QOPT_MAX_QUEUE]; }; -/* Returns true if the intervals [a, b) and [c, d) overlap. */ -static bool intervals_overlap(int a, int b, int c, int d) -{ - int left = max(a, c), right = min(b, d); - - return left < right; -} - -static int mqprio_validate_queue_counts(struct net_device *dev, - const struct tc_mqprio_qopt *qopt, - struct netlink_ext_ack *extack) -{ - int i, j; - - for (i = 0; i < qopt->num_tc; i++) { - unsigned int last = qopt->offset[i] + qopt->count[i]; - - if (!qopt->count[i]) { - NL_SET_ERR_MSG_FMT_MOD(extack, "No queues for TC %d", - i); - return -EINVAL; - } - - /* Verify the queue count is in tx range being equal to the - * real_num_tx_queues indicates the last queue is in use. - */ - if (qopt->offset[i] >= dev->real_num_tx_queues || - last > dev->real_num_tx_queues) { - NL_SET_ERR_MSG_FMT_MOD(extack, - "Queues %d:%d for TC %d exceed the %d TX queues available", - qopt->count[i], qopt->offset[i], - i, dev->real_num_tx_queues); - return -EINVAL; - } - - /* Verify that the offset and counts do not overlap */ - for (j = i + 1; j < qopt->num_tc; j++) { - if (intervals_overlap(qopt->offset[i], last, - qopt->offset[j], - qopt->offset[j] + - qopt->count[j])) { - NL_SET_ERR_MSG_FMT_MOD(extack, - "TC %d queues %d@%d overlap with TC %d queues %d@%d", - i, qopt->count[i], qopt->offset[i], - j, qopt->count[j], qopt->offset[j]); - return -EINVAL; - } - } - } - - return 0; -} - static int mqprio_enable_offload(struct Qdisc *sch, const struct tc_mqprio_qopt *qopt, struct netlink_ext_ack *extack) @@ -160,17 +109,7 @@ static int mqprio_parse_opt(struct net_device *dev, struct tc_mqprio_qopt *qopt, const struct tc_mqprio_caps *caps, struct netlink_ext_ack *extack) { - int i, err; - - /* Verify num_tc is not out of max range */ - if (qopt->num_tc > TC_MAX_QUEUE) - return -EINVAL; - - /* Verify priority mapping uses valid tcs */ - for (i = 0; i < TC_BITMASK + 1; i++) { - if (qopt->prio_tc_map[i] >= qopt->num_tc) - return -EINVAL; - } + int err; /* Limit qopt->hw to maximum supported offload value. Drivers have * the option of overriding this later if they don't support the a @@ -183,11 +122,11 @@ static int mqprio_parse_opt(struct net_device *dev, struct tc_mqprio_qopt *qopt, * to either populate the queue counts itself or to validate the * provided queue counts (or to request validation on its behalf). */ - if (!qopt->hw || caps->validate_queue_counts) { - err = mqprio_validate_queue_counts(dev, qopt, extack); - if (err) - return err; - } + err = mqprio_validate_qopt(dev, qopt, + !qopt->hw || caps->validate_queue_counts, + false, extack); + if (err) + return err; /* If ndo_setup_tc is not present then hardware doesn't support offload * and we should return an error. diff --git a/net/sched/sch_mqprio_lib.c b/net/sched/sch_mqprio_lib.c new file mode 100644 index 000000000000..b8cb412871b7 --- /dev/null +++ b/net/sched/sch_mqprio_lib.c @@ -0,0 +1,100 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include +#include +#include +#include +#include + +#include "sch_mqprio_lib.h" + +static bool intervals_overlap(int a, int b, int c, int d) +{ + int left = max(a, c), right = min(b, d); + + return left < right; +} + +static int mqprio_validate_queue_counts(struct net_device *dev, + const struct tc_mqprio_qopt *qopt, + bool allow_overlapping_txqs, + struct netlink_ext_ack *extack) +{ + int i, j; + + for (i = 0; i < qopt->num_tc; i++) { + unsigned int last = qopt->offset[i] + qopt->count[i]; + + if (!qopt->count[i]) { + NL_SET_ERR_MSG_FMT_MOD(extack, "No queues for TC %d", + i); + return -EINVAL; + } + + /* Verify the queue count is in tx range being equal to the + * real_num_tx_queues indicates the last queue is in use. + */ + if (qopt->offset[i] >= dev->real_num_tx_queues || + last > dev->real_num_tx_queues) { + NL_SET_ERR_MSG_FMT_MOD(extack, + "Queues %d:%d for TC %d exceed the %d TX queues available", + qopt->count[i], qopt->offset[i], + i, dev->real_num_tx_queues); + return -EINVAL; + } + + if (allow_overlapping_txqs) + continue; + + /* Verify that the offset and counts do not overlap */ + for (j = i + 1; j < qopt->num_tc; j++) { + if (intervals_overlap(qopt->offset[i], last, + qopt->offset[j], + qopt->offset[j] + + qopt->count[j])) { + NL_SET_ERR_MSG_FMT_MOD(extack, + "TC %d queues %d@%d overlap with TC %d queues %d@%d", + i, qopt->count[i], qopt->offset[i], + j, qopt->count[j], qopt->offset[j]); + return -EINVAL; + } + } + } + + return 0; +} + +int mqprio_validate_qopt(struct net_device *dev, struct tc_mqprio_qopt *qopt, + bool validate_queue_counts, + bool allow_overlapping_txqs, + struct netlink_ext_ack *extack) +{ + int i, err; + + /* Verify num_tc is not out of max range */ + if (qopt->num_tc > TC_MAX_QUEUE) { + NL_SET_ERR_MSG(extack, + "Number of traffic classes is outside valid range"); + return -EINVAL; + } + + /* Verify priority mapping uses valid tcs */ + for (i = 0; i <= TC_BITMASK; i++) { + if (qopt->prio_tc_map[i] >= qopt->num_tc) { + NL_SET_ERR_MSG(extack, + "Invalid traffic class in priority to traffic class mapping"); + return -EINVAL; + } + } + + if (validate_queue_counts) { + err = mqprio_validate_queue_counts(dev, qopt, false, extack); + if (err) + return err; + } + + return 0; +} +EXPORT_SYMBOL_GPL(mqprio_validate_qopt); + +MODULE_LICENSE("GPL"); diff --git a/net/sched/sch_mqprio_lib.h b/net/sched/sch_mqprio_lib.h new file mode 100644 index 000000000000..353787a25648 --- /dev/null +++ b/net/sched/sch_mqprio_lib.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __SCH_MQPRIO_LIB_H +#define __SCH_MQPRIO_LIB_H + +#include + +struct net_device; +struct netlink_ext_ack; +struct tc_mqprio_qopt; + +int mqprio_validate_qopt(struct net_device *dev, struct tc_mqprio_qopt *qopt, + bool validate_queue_counts, + bool allow_overlapping_txqs, + struct netlink_ext_ack *extack); + +#endif diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index c322a61eaeea..888a29ee1da6 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -26,6 +26,8 @@ #include #include +#include "sch_mqprio_lib.h" + static LIST_HEAD(taprio_list); #define TAPRIO_ALL_GATES_OPEN -1 @@ -924,7 +926,7 @@ static int taprio_parse_mqprio_opt(struct net_device *dev, struct netlink_ext_ack *extack, u32 taprio_flags) { - int i, j; + bool allow_overlapping_txqs = TXTIME_ASSIST_IS_ENABLED(taprio_flags); if (!qopt && !dev->num_tc) { NL_SET_ERR_MSG(extack, "'mqprio' configuration is necessary"); @@ -937,52 +939,17 @@ static int taprio_parse_mqprio_opt(struct net_device *dev, if (dev->num_tc) return 0; - /* Verify num_tc is not out of max range */ - if (qopt->num_tc > TC_MAX_QUEUE) { - NL_SET_ERR_MSG(extack, "Number of traffic classes is outside valid range"); - return -EINVAL; - } - /* taprio imposes that traffic classes map 1:n to tx queues */ if (qopt->num_tc > dev->num_tx_queues) { NL_SET_ERR_MSG(extack, "Number of traffic classes is greater than number of HW queues"); return -EINVAL; } - /* Verify priority mapping uses valid tcs */ - for (i = 0; i <= TC_BITMASK; i++) { - if (qopt->prio_tc_map[i] >= qopt->num_tc) { - NL_SET_ERR_MSG(extack, "Invalid traffic class in priority to traffic class mapping"); - return -EINVAL; - } - } - - for (i = 0; i < qopt->num_tc; i++) { - unsigned int last = qopt->offset[i] + qopt->count[i]; - - /* Verify the queue count is in tx range being equal to the - * real_num_tx_queues indicates the last queue is in use. - */ - if (qopt->offset[i] >= dev->num_tx_queues || - !qopt->count[i] || - last > dev->real_num_tx_queues) { - NL_SET_ERR_MSG(extack, "Invalid queue in traffic class to queue mapping"); - return -EINVAL; - } - - if (TXTIME_ASSIST_IS_ENABLED(taprio_flags)) - continue; - - /* Verify that the offset and counts do not overlap */ - for (j = i + 1; j < qopt->num_tc; j++) { - if (last > qopt->offset[j]) { - NL_SET_ERR_MSG(extack, "Detected overlap in the traffic class to queue mapping"); - return -EINVAL; - } - } - } - - return 0; + /* For some reason, in txtime-assist mode, we allow TXQ ranges for + * different TCs to overlap, and just validate the TXQ ranges. + */ + return mqprio_validate_qopt(dev, qopt, true, allow_overlapping_txqs, + extack); } static int taprio_get_start_time(struct Qdisc *sch, From patchwork Thu Feb 2 00:36:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13125127 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 76156C636CD for ; Thu, 2 Feb 2023 00:37:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230432AbjBBAhq (ORCPT ); Wed, 1 Feb 2023 19:37:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229781AbjBBAhS (ORCPT ); Wed, 1 Feb 2023 19:37:18 -0500 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2071.outbound.protection.outlook.com [40.107.22.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA51174C3F for ; Wed, 1 Feb 2023 16:37:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SkSt0E4LbfuZ2pgSc0/A6xW623tvk6kHJV2L3sbFs6tww1FDDt+/mTpQctlPbdEtOXiA0p0ddC3uuZgUkvFty3e/zAla/GsegApycVQPZrTpB2qthMeGY5LUJAAFGNmISK2toyj7HlcR/sHPlATZuR4xi8Odtf/fP/dyB0RtvDbvuPLPrNlBf39gHaPRGu5bQdQxe69Kk9sdd2lr3ZRdMxCwQcaTORu0ZpeOMtLCycrLfuyzKdd7Uk6hImbhoLzXGzKnuIFn075Tqat4L4DPlK0c27RqeIMALVd6W2wBEL/6XUqQ7+km45Q0f5N9wYRGFM1OzVTUpskl7imIMLdjLA== 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=Prt7wkkxqWopvzne3iRQr7SzGf2xuaY3ocfgp1tKZfk=; b=AUxkX6McbtCxyuujtC6I5AA940Of70sgOCjBIAK7IxyKXNgJ3oS+07r8rNL2MqbQOavn+E9fR5Gcw31Rc+ngftX+IkzFEOeCQY9F13g6cg98srMlYUDvOKQxZODFFJvFbKKiGCTnrb62qBulECMBTR+Stau97jwhvwd6EV8VUoE8SyyeGYJSDoLv5uLKQLMBHCw7bHnem5df40cFuMmRfMZexSGuo+rBXrim7QDausSLwyJhPtU01HfOBoBt8YKJFAx9S6egZ3+aza3iGz5BY0YbHvhC7fK+GZ4cX7O8y13hD8wQGslD43Ny0MTLPptcc5LdxGQeRFheXUMD41lv3w== 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=Prt7wkkxqWopvzne3iRQr7SzGf2xuaY3ocfgp1tKZfk=; b=Y5zSG8Lp2/LLEFlBTSyQjLreZ/n22FZKHE6kO3sSg+k6Z2e1tie5lnax7AN1EMIOFlVj4zMWNOeeBDW2atpI6iWtFDd2n8FahhCIoTeneonTi/TsS9dSsgw73lGsz7St+sXzFMTzpBu4qUG3JmmHQIRUy/NAbBLOXne8UPvqtBk= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by DU2PR04MB8789.eurprd04.prod.outlook.com (2603:10a6:10:2e0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Thu, 2 Feb 2023 00:36:59 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%3]) with mapi id 15.20.6043.038; Thu, 2 Feb 2023 00:36:59 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Vinicius Costa Gomes , Kurt Kanzenbach , Jacob Keller , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Simon Horman Subject: [PATCH v5 net-next 12/17] net/sched: refactor mqprio qopt reconstruction to a library function Date: Thu, 2 Feb 2023 02:36:16 +0200 Message-Id: <20230202003621.2679603-13-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202003621.2679603-1-vladimir.oltean@nxp.com> References: <20230202003621.2679603-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0032.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:22::20) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|DU2PR04MB8789:EE_ X-MS-Office365-Filtering-Correlation-Id: 7ad3baf5-2329-4e6e-add8-08db04b5983a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Llzlf+EHA7kuEUMKTgULU393dYGLxAJLzSKn0umPtW6phyGhzWd9qmtOXi5AzSpz179tw+/LfIfCmpWBRQfvDTqjj680MbUlLBc1NacyiSVBOT+RQASGTNQVNC6veScT2EwYPtlv+mQiqcFrcTPSIFEjq+Gvr+/XDTFIFbZWHfhMEFePJoDDlq6Hi6Gu6jC1Xzth1/5ljjkpOWzWdmqcH7WePHc/IZ6wfQEdqYCwiMzNLWDUbyl2GylxcrqmES6H8XWCpDdsZJUJgMk/GZyiCqLLVLns7eZDJ4XxeSv9KRzHpMOXNGOK2/6miFYuKr0BJAwYFlvX6s19tg8h+UXqMowEwPTMQB4J/w20WUa9TRIfCetTzcTd6qWatIuRDKEfspcgaZ3uk2TSvGPIC3a0dUYznSBOzIBT6fCEixRcFcb5mXBGEvTIGR1EC2B2LZfeOzT2dP7rwHxJ6teQYaw0MGgodzvzgST4M8jTUwKwof7S6lYBliHx/d++UVlKIk8S4OHom8fI8RrtJKqQqhMVGsNTg0hVNhO41onxYsqz6bI8XMvDsAOaJVUBgd809dKEII2LgEk17Hs96s7vKyQwagSsEcAVwN8Zc7N2KHt9T5dWYUJlEoVKzuvJBZhF7jBANKleBjU8eUTNAriHWlfbmQYsAIGqSYplsq10nZdgo9w/MIRFtBmMBVuBDNfKZlB+X361+cHWJ4dalqgKj+WK6A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(376002)(136003)(366004)(396003)(39860400002)(346002)(451199018)(36756003)(2616005)(7416002)(6666004)(52116002)(478600001)(2906002)(6486002)(38350700002)(86362001)(38100700002)(8936002)(54906003)(1076003)(6506007)(66556008)(8676002)(5660300002)(316002)(6916009)(41300700001)(44832011)(66476007)(66946007)(4326008)(6512007)(26005)(83380400001)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: o1SOlkSAu9ff77N3nBFCFrCNpi8r5wm9y7NZ1VcC8Ak+Wd/YIXVFKUjesgnwVZgKbEdw0drkeHl8/nVr9ybE5Xh1fwOVd2fs4GSq/q1wIJPzhKfFP8ldpHFWGfIWeMe37YUp7DWXd4jMGpUONGxrvV35M3tYr0pBNs9ftqGpXpOnXIUPHfcNdyErSBjgsWdfY9WJfjxQW1sAswio/6x+dvus2x69EGxNtwCIxiLR9rqhlVw6NZeHbYt1P45MJ6z5waV/yNeSfLExtIs77aBCMRxP59zj7fkAgsl+BvOKZLdASL0Uyby7YmBL4quKQ40Mt1jVrzNRaEQiTwKiMoyPuuIkA6p3A4A3auxip9Vm1DqKG4hQ1fwVW0i6J/mwDFjr+0xcIgV4reT3Fz90yT4Hjeu1b6p6E6Dt9sHizg6Y8XxFDG1Jc7iD3SoBllhTNIRYNYcluCIw2RwObRLIV+71OTxbm+RRd+rhu4EmJAroaAQOH2Tqc5hWE2gfaoNwUdzb53L6su/2AboQmJwD4D4D1nERypBjDUSsA07R8UqYob8nv3aTTFBj0Hwh99PKFwjzD82lWu1j6mfcm1mBF6Bnyhi+WRVaqH0G8iV6XV0HAsUqyr1IOCO6plMOgj9YFnux6cty3xhX8Kub1Yq0Zrk4tMqIWOVTG2+HJl7AL20alZPPKKbVQbaEYjq3Dwv8L0FZnqYKX9gxvrLS2f+y70xMZfTn0OIBES94dmuwciFUWywSEov0xCOni+8SGQx1FAvdox6/f6MMfeEwYTFvKmSEEZ4wOZI9pBHafpwfux42NzifEyf4KnIEZJbX9Ail2s98FxUi4xHuiuUelEst6KmmIP9pvEtjbnWfaMw13Hmr5iiYwBlZejRJNn83Pp2u1MsvT7K+6SwVc/OrV/eRtaRWO+lnNXJpiEp7NRklTO/cXS3P8H55u4U+AL5Gictnhra1/69MiiZvakqjtw80JoBs/MY2tpsPxTdas08pD1DyU7WsrCOOV/1dyops2pmuYpvcHRENAtZAtZZ8JecsiCmq2vfbFNgIAM76q+hXxy5w6BWFeKr7PogGY4nZZK8SS91arqrFgMuUE7nAw1Tt/7/qCCia5D+qEO+KlWyr+RYHd07ZbENwl90I44Via/Cfos/ECANVtIi2+IRX41T+zOhpnWQ3kyxTA9iVvr36aK1+kvS+dAeuTd2zptOfEhQ3kC2dw0OoF+rR4Jq0NrLeD/Wi0BDDZDjuSnHBh3ZbTImeon80j+jcrXBzXRH+/eE+ccEPyJ8idgzEQ3yfwjuo1+JHcLDCQsJcFYHkx763d3Uz7iovtGImaIdzeCwCK1qFtSYJKAX5MrgHGgZLo2TE96ziM7NRmcpHMPtMB93iBJL0BlP48B5MKIC+yTe71Exsjr7fRawC2UOwe3YMgK23h8x6NE/8jdSEk80DrHnlYzHekFRizEIJIPuME47frzn9og2hEct/Ynh8FZTmpbQsX/TV7WaRfe8fet9O6Mt+o/Aj2cC2mXsvSg4pFNdLwuyJXj+yXm3r+ZHgl/PCx/7w+qj4ksExWGjlaWoINfSUht+5WcawYPELa8p9EcLe/dbsbndgc2lVKci2xBXR/Awk+7ARbw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7ad3baf5-2329-4e6e-add8-08db04b5983a X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2023 00:36:59.5599 (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: dFVr7rg/8Ytl9eHFUFM1fAZ9IDebJbKW8RJwaPLyE6k24QuF1R8krITvHPMBBN8ptlC7IKLxkkTI3zLBA5Q+eg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8789 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The taprio qdisc will need to reconstruct a struct tc_mqprio_qopt from netdev settings once more in a future patch, but this code was already written twice, once in taprio and once in mqprio. Refactor the code to a helper in the common mqprio library. Signed-off-by: Vladimir Oltean Reviewed-by: Simon Horman --- v4->v5: patch is new net/sched/sch_mqprio.c | 10 ++-------- net/sched/sch_mqprio_lib.c | 14 ++++++++++++++ net/sched/sch_mqprio_lib.h | 2 ++ net/sched/sch_taprio.c | 9 +-------- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c index b10f0683d39b..fd25fef52ecb 100644 --- a/net/sched/sch_mqprio.c +++ b/net/sched/sch_mqprio.c @@ -404,7 +404,7 @@ static int mqprio_dump(struct Qdisc *sch, struct sk_buff *skb) struct nlattr *nla = (struct nlattr *)skb_tail_pointer(skb); struct tc_mqprio_qopt opt = { 0 }; struct Qdisc *qdisc; - unsigned int ntx, tc; + unsigned int ntx; sch->q.qlen = 0; gnet_stats_basic_sync_init(&sch->bstats); @@ -428,15 +428,9 @@ static int mqprio_dump(struct Qdisc *sch, struct sk_buff *skb) spin_unlock_bh(qdisc_lock(qdisc)); } - opt.num_tc = netdev_get_num_tc(dev); - memcpy(opt.prio_tc_map, dev->prio_tc_map, sizeof(opt.prio_tc_map)); + mqprio_qopt_reconstruct(dev, &opt); opt.hw = priv->hw_offload; - for (tc = 0; tc < netdev_get_num_tc(dev); tc++) { - opt.count[tc] = dev->tc_to_txq[tc].count; - opt.offset[tc] = dev->tc_to_txq[tc].offset; - } - if (nla_put(skb, TCA_OPTIONS, sizeof(opt), &opt)) goto nla_put_failure; diff --git a/net/sched/sch_mqprio_lib.c b/net/sched/sch_mqprio_lib.c index b8cb412871b7..f57bb0869bb7 100644 --- a/net/sched/sch_mqprio_lib.c +++ b/net/sched/sch_mqprio_lib.c @@ -97,4 +97,18 @@ int mqprio_validate_qopt(struct net_device *dev, struct tc_mqprio_qopt *qopt, } EXPORT_SYMBOL_GPL(mqprio_validate_qopt); +void mqprio_qopt_reconstruct(struct net_device *dev, struct tc_mqprio_qopt *qopt) +{ + int tc, num_tc = netdev_get_num_tc(dev); + + qopt->num_tc = num_tc; + memcpy(qopt->prio_tc_map, dev->prio_tc_map, sizeof(qopt->prio_tc_map)); + + for (tc = 0; tc < num_tc; tc++) { + qopt->count[tc] = dev->tc_to_txq[tc].count; + qopt->offset[tc] = dev->tc_to_txq[tc].offset; + } +} +EXPORT_SYMBOL_GPL(mqprio_qopt_reconstruct); + MODULE_LICENSE("GPL"); diff --git a/net/sched/sch_mqprio_lib.h b/net/sched/sch_mqprio_lib.h index 353787a25648..63f725ab8761 100644 --- a/net/sched/sch_mqprio_lib.h +++ b/net/sched/sch_mqprio_lib.h @@ -12,5 +12,7 @@ int mqprio_validate_qopt(struct net_device *dev, struct tc_mqprio_qopt *qopt, bool validate_queue_counts, bool allow_overlapping_txqs, struct netlink_ext_ack *extack); +void mqprio_qopt_reconstruct(struct net_device *dev, + struct tc_mqprio_qopt *qopt); #endif diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index 888a29ee1da6..6b3cecbe9f1f 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -1948,18 +1948,11 @@ static int taprio_dump(struct Qdisc *sch, struct sk_buff *skb) struct sched_gate_list *oper, *admin; struct tc_mqprio_qopt opt = { 0 }; struct nlattr *nest, *sched_nest; - unsigned int i; oper = rtnl_dereference(q->oper_sched); admin = rtnl_dereference(q->admin_sched); - opt.num_tc = netdev_get_num_tc(dev); - memcpy(opt.prio_tc_map, dev->prio_tc_map, sizeof(opt.prio_tc_map)); - - for (i = 0; i < netdev_get_num_tc(dev); i++) { - opt.count[i] = dev->tc_to_txq[i].count; - opt.offset[i] = dev->tc_to_txq[i].offset; - } + mqprio_qopt_reconstruct(dev, &opt); nest = nla_nest_start_noflag(skb, TCA_OPTIONS); if (!nest) From patchwork Thu Feb 2 00:36:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13125129 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 9ECEBC636D3 for ; Thu, 2 Feb 2023 00:37:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229991AbjBBAhs (ORCPT ); Wed, 1 Feb 2023 19:37:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230204AbjBBAhS (ORCPT ); Wed, 1 Feb 2023 19:37:18 -0500 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2071.outbound.protection.outlook.com [40.107.22.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D82B74A52 for ; Wed, 1 Feb 2023 16:37:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UsiNOuT8R3MaFDA56o/3f987D4pAwqAamf+TOUdEdmbydV7LP3i3v6J5Oe2Fc2ZfIf/fu3dGQoLcai4EZN+IS8skmyNMZiWCwQ+LssaAIa6touljDkf89g49zT4D6H96JrnPTn+Sbs7WY8899YeqxHqGzi2rVkFP9yZiEx/oPTooMb1lRIKz+sBH4o563bXt63Xx1lZWtWPoNOKUravJl/uatg0Cloji0EOav8uJxKiQv+VXxgVHyTRAxD8faP9fXnvBQcaQfzDRDrlMi+RcW2xIHGYjfl3osyqZu8Ehrd9xnSbVKj4WEDWTdRALeYvsLR2FDKlR1mPHoLW6sI/0GQ== 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=kMV/ySYwawjmBB8IVm+8r9nGNX+h+koTQwiiBtQnjd4=; b=VpB9raOL6R1zexxOfPT2twys3fPADdOVCKDJ7uTOvWgA54ChVFdnaitlfNdUOW9Z4oGZp0i1by5aEtyC50P5Mehnz3FFcmBGQwDq4kN4L+3MtfFNM1zHCKym2vX58H25xTy7xw0NxKqlAzGXyl8OEttVhyyJOaz1KQKYfLRtjjuNT0QyzblQlg77ovn1UgvDs+vDpoU9rLSoCP6kwNRWFAV/mVOiylCyVgkhV0e3zJ0JTPDxk7tDtvz9pbHKdaia+DvNri9zaM3rc1H4Fxfah1zEzl+dUGATy14xLxmm7PZ3yP2k/GaFT7DvniCwljoDlk2XKlF3NQeHev8f11TJvA== 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=kMV/ySYwawjmBB8IVm+8r9nGNX+h+koTQwiiBtQnjd4=; b=F9vNOOXErVBz+U7/PEFud+0TdOwZ/O9JtmqLOf7KD3Le3a+wjfdSpT8meuUvv0Dg93+iIGXddsW7c8zaNLeU3XsxTc08uyyGKPfiYi2ykRxjx+CTDySgRNiqR7fe9amALk/ZTU44kilgGGBtn5utdzl7UMP4fUGcug41R/QHVZg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by DU2PR04MB8789.eurprd04.prod.outlook.com (2603:10a6:10:2e0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Thu, 2 Feb 2023 00:37:00 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%3]) with mapi id 15.20.6043.038; Thu, 2 Feb 2023 00:37:00 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Vinicius Costa Gomes , Kurt Kanzenbach , Jacob Keller , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Simon Horman Subject: [PATCH v5 net-next 13/17] net/sched: taprio: pass mqprio queue configuration to ndo_setup_tc() Date: Thu, 2 Feb 2023 02:36:17 +0200 Message-Id: <20230202003621.2679603-14-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202003621.2679603-1-vladimir.oltean@nxp.com> References: <20230202003621.2679603-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0032.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:22::20) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|DU2PR04MB8789:EE_ X-MS-Office365-Filtering-Correlation-Id: cd14cc1e-d8fb-4db3-688e-08db04b598da X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JDhTX2FXlDUcxWnCusi/gXDW7V6BeOfSUmfzdL+rTLxM5wTvvcdCUziJ88rDPTKH26hPiIkTf8SIkWsGvLxJ6W5fCp+4oTtpsMQDQGvCo6GiIQj4MaV/gEHBgKEbCm6PaUlfc+Oq0TNuPyG7u5Vzqr44zTm0Bh4gohAWNU6DM2yODIlQ4E9y1n72wKF9duI7ZC9dVBAlxVeeo89IUgx94ZmeFlq6YBw5ybOduyAjENg3nYMh6krhL5ip2sT8fKmDfr1SwCBSwXedJiZ0chqY/SfEQOysnm9U8dYDyp2P9cvbKNeHEOONww6H5BLkdBQQU19nLE11RTcHcFxxie5kzbxbQ4mbRFBYtExIGaxqoZZd17eM/3jvx9iHz4T1SLcHD4CW8T34wgDvMz12sr97gR/M82cDkwbgbtVYyDpEdUPdfxUoY1zA0qBtXVqPXlutzZDn7mAm2IlGHB56NqdvCCD3lkVUpQMU0sEwQuJovpAuXYMwSDMB2RZSUwOa8h8NvJUlGBepeJv45R1Zo0+ikK8yweM8aspgfkVA3tl9vMrpPmM0xmKH4UK1btJ/8pzr2ZF4TnI6YvxvflD2qoEoeUyFVTTF30ifBrRD9SVtlb98i7WkMrIKo2dMv2wOs8J7ANGN/vBebdnfg3VGAtSstIIwBLkg955SKeBkJbqOStixGFP1IoJYeacJJBQd3aor5OrHXE19b7WNG1qvimgTLA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(376002)(136003)(366004)(396003)(39860400002)(346002)(451199018)(36756003)(2616005)(7416002)(6666004)(52116002)(478600001)(2906002)(6486002)(38350700002)(86362001)(38100700002)(8936002)(54906003)(1076003)(6506007)(66556008)(8676002)(5660300002)(316002)(6916009)(41300700001)(44832011)(66476007)(66946007)(4326008)(6512007)(26005)(83380400001)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Bsp6e1t67bZmJWa1fzgAThf1KiqaNHXzJCx9hJdjEKt/rvpBJ0h/PW5usEwA8TfyrEYp4RY4AZyjUd4BJBJePvinDjP8iW4Qc3VqTjoKyo71YQ7b2gdHSs72xkiuyr6g2d+jUfGgLTXGl6GBwo3lePMlog051eDmHmkgCV1sYcyLTzHQGMlPO/S4QfJSo5ab6NGiA6zqu5AuJY3SFj15VS3+lQUtwzHW7bZl0EK0QnuTomZ+cqpjHAUzV+L4pwatCnBhRJuprJpjNILUsysUFaacd/LEI3NTHvl5LQATNMSzy+4TOnhmejjkcxJaVPRSHPHjYnPtaQB4J9NHzUNUHvnpYL9RYc5v6eNvJb04nAJHC4hJ8wvNGXCB2bKAgfXOBYhwz76ddDa/BVr7osEaHimK388F6NZzQQsYTbi9mZsYUUTwY+1+cw/KMpEJdvTYEHhdsTXQYNIPwfjMBTjzV0IyeMoiERyc5KYfE28Hq067c26IIpjcD3aLnc1Uwsb9ceGmLaSRypy/o2j+V1e7KWrLtbALaE7A60ZURXm2qoV1k70fgDYwycK4+VISGn3FN+E+QxipM3b77Y7o8d7T0GvDcnvcPqZ1b1vo0zDDNuqf09bmywLYgR8Wa44LypcBlNC4JORoMJU1IOrosKc7Bk54lgLBpQjI2k9hbEVQ4dULdmrNPjt6QHYGylafD4cqGKyNp8fhY2mJBJf94T1Mcr4aPVu57CTQthB6ZHcEdOxN2Rvbnm/kLp4rKK5bUaTmyXb78fbHbjySP0ikiCvGML1ECcCsi2KjkAe/4uB3O3HMG7LkwvX2VPIev8tbF7ryTmNcN1xqCTms7ioPcg0dHE6y4qjg5fzHLzMe/eCsv3qQyhugtG0ubAF7j3MbBhyZF7dPc4kZwWIEDPzfzUvihi0HyHpkz1etLRWPlUK50wPsZ2ypXPcLgkCqNyrwyYwlAP1bRXG1bf2v+8F0tXxqKaLgI9BWWdN7MTmnRQKntTmQIl8792OgPZwHOrN8K4+sQp27Bj3nP+Cu0X8El//A3pvgFyRThbYehndCASgApNfrFXRNLAnpUWgyZgSrG+r8Dkmy0JaynQlXhQ0EsoLxjEr91nTRLY+Z/Du9VXnIOZQtHfO5Qfp0NDTp4AUD+CwjHS1iEQhnx2KOcIbmSiE4UFw9QdahIivrQeWDd+AAsdyxEIPwgOONAGqbYzI9qiChB80RCKisto0IXfkRbBOwbHmjIC4BUVHzorh1foEVWKUYmokvO1EdeWNbA1FOl7fMRDeiocur5bwcU4dYH4kt24BVWTvH7zmOQea0Jlv3M/0lJ7mdVYsoyE+GVrAhjEa0WLOVidS/iaJIBHLDbg5fe8te3pQh9V7TzhpIV3vyh2jzzpEnSWZAbxVLr/GrfCsrIEHDwG42phH0xxtx8CnW92k6NKN7QPncwGDSMfUNED6lWEEiBzCOvaEt1Q5UYbXoHIXZoi0IXsieC0mw99JoY9P4OIiyy+k+QgSugY8VLeGH36Nv4X1cgcwIUiasFlwMwFBYEBjgzbSXXaPqtDnKpz87TratG2bCJ/6y7k5GbfN+aD4lxBLk5IJJwIr3r27NqrklC/Y+Ro7zVcJOXTFKuQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: cd14cc1e-d8fb-4db3-688e-08db04b598da X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2023 00:37:00.6692 (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: NLAqybU8KgV5M2A15L3lv4OqLU/qLmmQ5j085mPRnI8g4wvbCRFEtFKIvi2u/ZOlUVlWNbLE73Y4QC7l0Fy0lQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8789 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The taprio qdisc does not currently pass the mqprio queue configuration down to the offloading device driver. So the driver cannot act upon the TXQ counts/offsets per TC, or upon the prio->tc map. It was probably assumed that the driver only wants to offload num_tc (see TC_MQPRIO_HW_OFFLOAD_TCS), which it can get from netdev_get_num_tc(), but there's clearly more to the mqprio configuration than that. I've considered 2 mechanisms to remedy that. First is to pass a struct tc_mqprio_qopt_offload as part of the tc_taprio_qopt_offload. The second is to make taprio actually call TC_SETUP_QDISC_MQPRIO, *in addition to* TC_SETUP_QDISC_TAPRIO. The difference is that in the first case, existing drivers (offloading or not) all ignore taprio's mqprio portion currently, whereas in the second case, we could control whether to call TC_SETUP_QDISC_MQPRIO, based on a new capability. The question is which approach would be better. I'm afraid that calling TC_SETUP_QDISC_MQPRIO unconditionally (not based on a taprio capability bit) would risk introducing regressions. For example, taprio doesn't populate (or validate) qopt->hw, as well as mqprio.flags, mqprio.shaper, mqprio.min_rate, mqprio.max_rate. In comparison, adding a capability is functionally equivalent to just passing the mqprio in a way that drivers can ignore it, except it's slightly more complicated to use it (need to set the capability). Ultimately, what made me go for the "mqprio in taprio" variant was that it's easier for offloading drivers to interpret the mqprio qopt slightly differently when it comes from taprio vs when it comes from mqprio, should that ever become necessary. Signed-off-by: Vladimir Oltean Reviewed-by: Simon Horman --- v4->v5: - reword commit message - mqprio_qopt_reconstruct() has been added in a previous patch, to consolidate existing code v2->v4: none v1->v2: reconstruct the mqprio queue configuration structure include/net/pkt_sched.h | 1 + net/sched/sch_taprio.c | 1 + 2 files changed, 2 insertions(+) diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h index 02e3ccfbc7d1..ace8be520fb0 100644 --- a/include/net/pkt_sched.h +++ b/include/net/pkt_sched.h @@ -187,6 +187,7 @@ struct tc_taprio_sched_entry { }; struct tc_taprio_qopt_offload { + struct tc_mqprio_qopt_offload mqprio; u8 enable; ktime_t base_time; u64 cycle_time; diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index 6b3cecbe9f1f..aba8a16842c1 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -1228,6 +1228,7 @@ static int taprio_enable_offload(struct net_device *dev, return -ENOMEM; } offload->enable = 1; + mqprio_qopt_reconstruct(dev, &offload->mqprio.qopt); taprio_sched_to_offload(dev, sched, offload); for (tc = 0; tc < TC_MAX_QUEUE; tc++) From patchwork Thu Feb 2 00:36:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13125130 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 A8450C636CD for ; Thu, 2 Feb 2023 00:37:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231127AbjBBAht (ORCPT ); Wed, 1 Feb 2023 19:37:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230226AbjBBAhT (ORCPT ); Wed, 1 Feb 2023 19:37:19 -0500 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2071.outbound.protection.outlook.com [40.107.22.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6506D74487 for ; Wed, 1 Feb 2023 16:37:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DT8XuBQx+sHBJ3ig3yeO5Yh0tfZ0BMWytiQfFm5OTjb1waSvd/EM3vS8rKNuiYlrQ1WdHa2AnUNdShJcUk85aYKDu5c5r65VfADUbR7XFS0asFIa4Ir0I3op33ngzbnhFhHuYL+a1DbvPt1AlTjV/UvOkuLB6xOukCtzruQuNN3f8ANI+zCzpu3cLH/AErZPRR8PpVPtSy9gJ51PrW1C6A4JXHaF8cqNRPv1ggqheczXG2KiIuL6Fn3xETJpVoFl7orSgUKQILnJ5+63kRbOU8+kSL+FbX8ztA3icot414LndCMwJhxkUqo3AiAgAW+IHO7kaYlzuNWw3890MTnx6w== 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=4imiyEOBQrJSL3KAuggZVYeoW53b3ulHUGh/+5d7CIY=; b=atABAZcU+C6EaVJQWOTKUVBMrQw3UdG4r7jAw/cuRNRK2loD6VPOw+pUyH79RLPK+oTWSX8nwGq1FoYkxFlez6wAGXsmC8P7fEaCvBRlv2hLl8U9Pq4lNAo+5S2ELCjs/O8snZrd01RpHm4IT+EtX4fgbZFfSAJQchfv6Y6iwfcMOhGMb9iHiw0AKXZub588xIt6TSiTX7nPY112zDzt2RY95P9Rj9FpnAY7tirwQSfWzit/zGU/6vRI+/pvIAbKnEVFLzal9MRpL5VLbyaJP8p4GCfBWBMyYxbNPcICG20v+TJ4Jcd4BqsLIWCGhSUEEVYZ1dwpFF2Wq05wgd+59A== 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=4imiyEOBQrJSL3KAuggZVYeoW53b3ulHUGh/+5d7CIY=; b=NS0IHVsNUuelGqSTnQQyFKl7nCmFDiAOOcYflopXqOWFfoatQZtxqo8qE+K/7lj5sNTXHwLXPJwDiifxr8iDNCOjrbErFg8ozwPBinKImcXpLnd3zzCpMO0RGNBkqmCUmXy2w7AEvNq+l1JWhfMufXeDDLpv/kGX7xBe7HR2zqY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by DU2PR04MB8789.eurprd04.prod.outlook.com (2603:10a6:10:2e0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Thu, 2 Feb 2023 00:37:02 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%3]) with mapi id 15.20.6043.038; Thu, 2 Feb 2023 00:37:02 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Vinicius Costa Gomes , Kurt Kanzenbach , Jacob Keller , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Simon Horman , Horatiu Vultur , Siddharth Vadapalli , Roger Quadros , Gerhard Engleder Subject: [PATCH v5 net-next 14/17] net/sched: taprio: only calculate gate mask per TXQ for igc, stmmac and tsnep Date: Thu, 2 Feb 2023 02:36:18 +0200 Message-Id: <20230202003621.2679603-15-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202003621.2679603-1-vladimir.oltean@nxp.com> References: <20230202003621.2679603-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0032.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:22::20) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|DU2PR04MB8789:EE_ X-MS-Office365-Filtering-Correlation-Id: dd2428ec-8e57-44c3-d17c-08db04b599a9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9z/SJRkSLqx47Vcxc0N2iT2g8Fk+HRJ3/a9xhQQ1QgtmfKFCnojQV7EUDeX/FAi3nWVuolbyfrCQEDDHBXVoSykWtIH45pncklzcqEn2aV8z3XN5CG1EV2UmvTSg5P/io8vELfW78OWeXwloh+hfc3EJckzLnh6NX2E6Fb5rhYhpgIOhp20TjCaVR+IwpEe9o1ureP2A31WrzhG8TK3IzZjWHOeHohcDFvLAdoVLK/jWZsUIAEdMISH0g3kNK8D3MWah2voHpBh8T7dYBvjoe3UGLHvGj9eV0m42jhrzxoWIuZt1hQ1DY9bWV1IoC+FF/uLWLUsQYzES3W2WumrkLXqjL11aE+UJAr2u0islJ5Yjtmiu2asmDDd6uc+bxrodWiIpZYRDcLlXoB401zy+lATxYlXALJOxWxpnjHdPSTGUyDuH+zrj5EhnRrC+VDPBhFCIUfEUqb+/p5UpGAWWogDY5yzJoKvQhUoFx4JYQJ0c6CWwWV8/zeXmcI5mlpljmIHSr0HMhhJdGwiaZaQGhv+wxJ350yqxQ0k6iOZHRZOnkAF0JtrJPhK9W2C4zUI8W0kJoQA0yOH5uLRjhiV2HrSWHRHRqTo+8bBS9nK0/G6YDWHzkbIzpTSHJEuIRarmeLJh7qG7/63FEcEfocKq7LUeagGRmkxlL23r45L1CS9BAbNSYx12MIm2AVqS1A8pfigFt3ou+BLCWXbk2lJXuQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(376002)(136003)(366004)(396003)(39860400002)(346002)(451199018)(36756003)(2616005)(7416002)(6666004)(52116002)(478600001)(2906002)(6486002)(38350700002)(86362001)(38100700002)(8936002)(54906003)(1076003)(6506007)(66556008)(8676002)(30864003)(5660300002)(316002)(6916009)(41300700001)(44832011)(66476007)(66946007)(4326008)(6512007)(26005)(83380400001)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jy3ouq9t2KigyQyCsjFaH1Af0KnOm87E0Uf6NNsTbxAm40FsJyfAI8HNjK+3BX5rWmG/SEKf6qHfffYEO+KvaDVbJ697UJKJFV9B38t0g2r1okc79DmmoU53S3FoZoJ7dgVQD28UDZoGbIRWwth4JcV6ZDqJ0fDQuBdgA/psMrmsrTW75b9gSUAnOSV8Lkg/VKEwe5nABE8xSn3pNWCJE8g1P33tT4llDnAUdVHODqB3AupLWHoCoWjQigfe3BXEvf7H5YAPCS/6vKx0MZd+pVXmntfpKQ2dnX8m/wWzavpANjnRJkMlcekZK33GM2qDtVo/s/HhZdNZ5BnJSe9GgywW0nNQFf5MiodmKNkr0debFdIEOAjAhF+VmSYBs0RRzQuE8BU3GfOAR3ZUmxm7+q1dJAk24DD8y8MJAc5OmTIS/2sO3A4gkrudBXtAqPe/1EmYX6jzt1bUDH2GPcQYUfUQtiGpryk/wPkyun5uL4s6bsGqf/TKiop5WpF0D4a0h2Rq5h1Rycy2vHvQK7JMUs+tqEabUa0ASx+dJnZXhasiKSor6A9GspqDHeJvF3kv/q6eTEjOeCzcm4Eq09QDm0RU4W9r99ed4/+VPHclcbjbpiyiKtUVbszZEfG5TWHVq9eytambYD3h0Z8XbAuY9GY+5l1tlg72XzVENDaMPUtb3a+zvkCPAZFg0tjEeoCsN3epNCyOzhcMcni2p50eXgPTl42tgwnDtIK+g7e9e66k3btZCcLzAOOVAHG/iO4+ru2Cfiz8yQtIV50zcf51KKxZjhOni65OpzpsEOuUQYKPGfUsE/7pz43qc06+e5dFgLbH5US5yKBccpYXxJPTvsgvLF2Jt2EzTOAnJMMgDj4/a0JaAhDX/KoenlzdL01CQyfZWuJpqpfTpI+WYcSP25eCAOpfGL3HZw8nSzX7UzwQ/27rKelf+KEtrC/yOBdg+NynCjwZ3lbA3bvi4Gblm/W1vNOioltXSVpxDyrv8K5/O4mLruFnZ2CCaNlNpaI6EwAbK0ilfF5pUoBz3YhpBnH/HnLRn/7GNcJEj8JOX/0IxdNmwn3uOmHOjOYrwZtVw9QEdCFl3kdMel5R35+RQvRslrlKni9CUJ47py5QFV3DDvt1bdDkTU/++Qxqr2D0q0dl/8sipPgwAj2h29ttJw4q5gQvVgXj6iut+8Mt03jCzkyOM+NPT6rVEAjoa07GFyVsN9qgvko8dMbUkgWV4rDot51vR62wzxHXnaItTQRgal1/S77I3R261hHrQpHe9H9UxNDYMp3B3eqpelWYJwe4Nr01w6hMvH/qqedhFGVfujMJ/MNaLraXW095i98lOWrvI+DEaD2PUdnrRyLXPgYswncrlOjdS02ZKKsDelkRHVxQZzQ0vEgyWn7v592VEK61ffnx3TO0ljY2NaWOj6G1NICEMtjaGdApN9s6jXrjb2CFBQO8cImYEws31+U9ZOpJ0gGm6GbXaec65YJOJLLS6L2Ggp9oJvahsdPWZbrRzxC8B5HbudSQoXVimG5qOYel/p46sYs1yBbMbhzq6Zpha3UD3pBk5dHjrkEbTmmu0+ln6Pn6ddGmiLPP9Ow1EB7nDLy7tw3l30YYPr3RKQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: dd2428ec-8e57-44c3-d17c-08db04b599a9 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2023 00:37:01.9660 (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: AZE+A39eiWPKTMo1LI/mimRbrePn9Gf7KGHPo0veVDAvLLhPa32s7lvEwofcI0uJSbN/Idve4pZehTsDUJCf2A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8789 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org There are 2 classes of in-tree drivers currently: - those who act upon struct tc_taprio_sched_entry :: gate_mask as if it holds a bit mask of TXQs - those who act upon the gate_mask as if it holds a bit mask of TCs When it comes to the standard, IEEE 802.1Q-2018 does say this in the second paragraph of section 8.6.8.4 Enhancements for scheduled traffic: | A gate control list associated with each Port contains an ordered list | of gate operations. Each gate operation changes the transmission gate | state for the gate associated with each of the Port's traffic class | queues and allows associated control operations to be scheduled. In typically obtuse language, it refers to a "traffic class queue" rather than a "traffic class" or a "queue". But careful reading of 802.1Q clarifies that "traffic class" and "queue" are in fact synonymous (see 8.6.6 Queuing frames): | A queue in this context is not necessarily a single FIFO data structure. | A queue is a record of all frames of a given traffic class awaiting | transmission on a given Bridge Port. The structure of this record is not | specified. i.o.w. their definition of "queue" isn't the Linux TX queue. The gate_mask really is input into taprio via its UAPI as a mask of traffic classes, but taprio_sched_to_offload() converts it into a TXQ mask. The breakdown of drivers which handle TC_SETUP_QDISC_TAPRIO is: - hellcreek, felix, sja1105: these are DSA switches, it's not even very clear what TXQs correspond to, other than purely software constructs. Only the mqprio configuration with 8 TCs and 1 TXQ per TC makes sense. So it's fine to convert these to a gate mask per TC. - enetc: I have the hardware and can confirm that the gate mask is per TC, and affects all TXQs (BD rings) configured for that priority. - igc: in igc_save_qbv_schedule(), the gate_mask is clearly interpreted to be per-TXQ. - tsnep: Gerhard Engleder clarifies that even though this hardware supports at most 1 TXQ per TC, the TXQ indices may be different from the TC values themselves, and it is the TXQ indices that matter to this hardware. So keep it per-TXQ as well. - stmmac: I have a GMAC datasheet, and in the EST section it does specify that the gate events are per TXQ rather than per TC. - lan966x: again, this is a switch, and while not a DSA one, the way in which it implements lan966x_mqprio_add() - by only allowing num_tc == NUM_PRIO_QUEUES (8) - makes it clear to me that TXQs are a purely software construct here as well. They seem to map 1:1 with TCs. - am65_cpsw: from looking at am65_cpsw_est_set_sched_cmds(), I get the impression that the fetch_allow variable is treated like a prio_mask. I haven't studied this driver's interpretation of the prio_tc_map, but that definitely sounds closer to a per-TC gate mask rather than a per-TXQ one. Based on this breakdown, we have 6 drivers with a gate mask per TC and 3 with a gate mask per TXQ. So let's make the gate mask per TXQ the opt-in and the gate mask per TC the default. Benefit from the TC_QUERY_CAPS feature that Jakub suggested we add, and query the device driver before calling the proper ndo_setup_tc(), and figure out if it expects one or the other format. Cc: Horatiu Vultur Cc: Siddharth Vadapalli Cc: Roger Quadros Signed-off-by: Vladimir Oltean Acked-by: Kurt Kanzenbach # hellcreek Reviewed-by: Gerhard Engleder Reviewed-by: Simon Horman --- v3->v5: none v2->v3: adjust commit message in light of what Kurt has said v1->v2: - rewrite commit message - also opt in stmmac and tsnep drivers/net/ethernet/engleder/tsnep_tc.c | 21 +++++++++++++++++ drivers/net/ethernet/intel/igc/igc_main.c | 23 +++++++++++++++++++ drivers/net/ethernet/stmicro/stmmac/hwif.h | 5 ++++ .../net/ethernet/stmicro/stmmac/stmmac_main.c | 2 ++ .../net/ethernet/stmicro/stmmac/stmmac_tc.c | 20 ++++++++++++++++ include/net/pkt_sched.h | 1 + net/sched/sch_taprio.c | 11 ++++++--- 7 files changed, 80 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/engleder/tsnep_tc.c b/drivers/net/ethernet/engleder/tsnep_tc.c index c4c6e1357317..d083e6684f12 100644 --- a/drivers/net/ethernet/engleder/tsnep_tc.c +++ b/drivers/net/ethernet/engleder/tsnep_tc.c @@ -403,12 +403,33 @@ static int tsnep_taprio(struct tsnep_adapter *adapter, return 0; } +static int tsnep_tc_query_caps(struct tsnep_adapter *adapter, + struct tc_query_caps_base *base) +{ + switch (base->type) { + case TC_SETUP_QDISC_TAPRIO: { + struct tc_taprio_caps *caps = base->caps; + + if (!adapter->gate_control) + return -EOPNOTSUPP; + + caps->gate_mask_per_txq = true; + + return 0; + } + default: + return -EOPNOTSUPP; + } +} + int tsnep_tc_setup(struct net_device *netdev, enum tc_setup_type type, void *type_data) { struct tsnep_adapter *adapter = netdev_priv(netdev); switch (type) { + case TC_QUERY_CAPS: + return tsnep_tc_query_caps(adapter, type_data); case TC_SETUP_QDISC_TAPRIO: return tsnep_taprio(adapter, type_data); default: diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c index e86b15efaeb8..cce1dea51f76 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -6205,12 +6205,35 @@ static int igc_tsn_enable_cbs(struct igc_adapter *adapter, return igc_tsn_offload_apply(adapter); } +static int igc_tc_query_caps(struct igc_adapter *adapter, + struct tc_query_caps_base *base) +{ + struct igc_hw *hw = &adapter->hw; + + switch (base->type) { + case TC_SETUP_QDISC_TAPRIO: { + struct tc_taprio_caps *caps = base->caps; + + if (hw->mac.type != igc_i225) + return -EOPNOTSUPP; + + caps->gate_mask_per_txq = true; + + return 0; + } + default: + return -EOPNOTSUPP; + } +} + static int igc_setup_tc(struct net_device *dev, enum tc_setup_type type, void *type_data) { struct igc_adapter *adapter = netdev_priv(dev); switch (type) { + case TC_QUERY_CAPS: + return igc_tc_query_caps(adapter, type_data); case TC_SETUP_QDISC_TAPRIO: return igc_tsn_enable_qbv_scheduling(adapter, type_data); diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h index 592b4067f9b8..16a7421715cb 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h @@ -567,6 +567,7 @@ struct tc_cbs_qopt_offload; struct flow_cls_offload; struct tc_taprio_qopt_offload; struct tc_etf_qopt_offload; +struct tc_query_caps_base; struct stmmac_tc_ops { int (*init)(struct stmmac_priv *priv); @@ -580,6 +581,8 @@ struct stmmac_tc_ops { struct tc_taprio_qopt_offload *qopt); int (*setup_etf)(struct stmmac_priv *priv, struct tc_etf_qopt_offload *qopt); + int (*query_caps)(struct stmmac_priv *priv, + struct tc_query_caps_base *base); }; #define stmmac_tc_init(__priv, __args...) \ @@ -594,6 +597,8 @@ struct stmmac_tc_ops { stmmac_do_callback(__priv, tc, setup_taprio, __args) #define stmmac_tc_setup_etf(__priv, __args...) \ stmmac_do_callback(__priv, tc, setup_etf, __args) +#define stmmac_tc_query_caps(__priv, __args...) \ + stmmac_do_callback(__priv, tc, query_caps, __args) struct stmmac_counters; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index b7e5af58ab75..17a7ea1cb961 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -5991,6 +5991,8 @@ static int stmmac_setup_tc(struct net_device *ndev, enum tc_setup_type type, struct stmmac_priv *priv = netdev_priv(ndev); switch (type) { + case TC_QUERY_CAPS: + return stmmac_tc_query_caps(priv, priv, type_data); case TC_SETUP_BLOCK: return flow_block_cb_setup_simple(type_data, &stmmac_block_cb_list, diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c index 2cfb18cef1d4..9d55226479b4 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c @@ -1107,6 +1107,25 @@ static int tc_setup_etf(struct stmmac_priv *priv, return 0; } +static int tc_query_caps(struct stmmac_priv *priv, + struct tc_query_caps_base *base) +{ + switch (base->type) { + case TC_SETUP_QDISC_TAPRIO: { + struct tc_taprio_caps *caps = base->caps; + + if (!priv->dma_cap.estsel) + return -EOPNOTSUPP; + + caps->gate_mask_per_txq = true; + + return 0; + } + default: + return -EOPNOTSUPP; + } +} + const struct stmmac_tc_ops dwmac510_tc_ops = { .init = tc_init, .setup_cls_u32 = tc_setup_cls_u32, @@ -1114,4 +1133,5 @@ const struct stmmac_tc_ops dwmac510_tc_ops = { .setup_cls = tc_setup_cls, .setup_taprio = tc_setup_taprio, .setup_etf = tc_setup_etf, + .query_caps = tc_query_caps, }; diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h index ace8be520fb0..fd889fc4912b 100644 --- a/include/net/pkt_sched.h +++ b/include/net/pkt_sched.h @@ -176,6 +176,7 @@ struct tc_mqprio_qopt_offload { struct tc_taprio_caps { bool supports_queue_max_sdu:1; + bool gate_mask_per_txq:1; }; struct tc_taprio_sched_entry { diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index aba8a16842c1..1c95785932b9 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -1170,7 +1170,8 @@ static u32 tc_map_to_queue_mask(struct net_device *dev, u32 tc_mask) static void taprio_sched_to_offload(struct net_device *dev, struct sched_gate_list *sched, - struct tc_taprio_qopt_offload *offload) + struct tc_taprio_qopt_offload *offload, + const struct tc_taprio_caps *caps) { struct sched_entry *entry; int i = 0; @@ -1184,7 +1185,11 @@ static void taprio_sched_to_offload(struct net_device *dev, e->command = entry->command; e->interval = entry->interval; - e->gate_mask = tc_map_to_queue_mask(dev, entry->gate_mask); + if (caps->gate_mask_per_txq) + e->gate_mask = tc_map_to_queue_mask(dev, + entry->gate_mask); + else + e->gate_mask = entry->gate_mask; i++; } @@ -1229,7 +1234,7 @@ static int taprio_enable_offload(struct net_device *dev, } offload->enable = 1; mqprio_qopt_reconstruct(dev, &offload->mqprio.qopt); - taprio_sched_to_offload(dev, sched, offload); + taprio_sched_to_offload(dev, sched, offload, &caps); for (tc = 0; tc < TC_MAX_QUEUE; tc++) offload->max_sdu[tc] = q->max_sdu[tc]; From patchwork Thu Feb 2 00:36:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13125131 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 55E15C63797 for ; Thu, 2 Feb 2023 00:37:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231129AbjBBAhu (ORCPT ); Wed, 1 Feb 2023 19:37:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230246AbjBBAhX (ORCPT ); Wed, 1 Feb 2023 19:37:23 -0500 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2071.outbound.protection.outlook.com [40.107.22.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B36073756 for ; Wed, 1 Feb 2023 16:37:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q15eBr1Fr3BHdrIs6lYjbGI5M4QRlIRbAwPKS8DEVtBYjIxd4ax2087ghkv6BLbJdrS7R6vz+CbcpbxplBnhuaOrIVt5k6zWqspbSq+a3yWZ4uhkSEEDWVPe3HCj7oIM2cGJ17+SfN63GSd0guDjyg4EkMU2ADwkYbdetthrU4fL2aHn3u1sxxCvhnzqcufC51Olouekdna73yPiWW+A3QVtBwtBJzX6WICfWQVqfMbrFe37/6aTOhcJIzXSdIVc2gyjYOZH53RbsFNUjh1R35Dlc99854Nsd5yIszbz0MyTWWgGvb/s62fHJDU1FnJToiCUnfOU6JEfLoZedjWHFw== 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=2FBEq4ybasGW5G6VJAGtDMnppERIivx9WnZY0z0Xb4Y=; b=BUYP1o/ZlqLBsxlPp+yi0Si4b5otMA1mLab3to6fPmEfHMqAJJ7hp/v9Hyx65Cg2zDFpRPDwoQIEbytcXpr1EvHVpvWeg/agJ/z6PWRF5Uwp7VJxr7SZHxZafWylS+YATPHGosAkIz9PRrboiA+vlMUtLLzZ8YNPRPAyetJ9K2ZzVDpjdv3AtAprZofOlscxmc8YuBrsFDulM0PWz28+z50jfcV7xOpEQZB1zQQnDOnBMu5oEnmBmQ0DfeAMQ0An26JymMLkvyJ8PpuEPA7g5LLUlswISn4fkQIY9ijW9vYlMtY+LxYphk7lLg1WJkGk/Fs7NMg9M6zMXcx/MWxx1g== 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=2FBEq4ybasGW5G6VJAGtDMnppERIivx9WnZY0z0Xb4Y=; b=APcGGcviGCqrSPlQexb/6hiL1Sy/9GP8ipwzQvabomiBqPVQ0Lfsmomb6OWZ99xMyqQHqcy5qvbsFqGeOmaflfkbcuJ0RBevth9hEBKBCY9aquauDH32JPYVu2fV3HW1/olMLxJl0GBBKB+RNWS+918HDfbDs0BlnKl+8yA8msE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by DU2PR04MB8789.eurprd04.prod.outlook.com (2603:10a6:10:2e0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Thu, 2 Feb 2023 00:37:03 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%3]) with mapi id 15.20.6043.038; Thu, 2 Feb 2023 00:37:02 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Vinicius Costa Gomes , Kurt Kanzenbach , Jacob Keller , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Simon Horman Subject: [PATCH v5 net-next 15/17] net: enetc: request mqprio to validate the queue counts Date: Thu, 2 Feb 2023 02:36:19 +0200 Message-Id: <20230202003621.2679603-16-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202003621.2679603-1-vladimir.oltean@nxp.com> References: <20230202003621.2679603-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0032.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:22::20) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|DU2PR04MB8789:EE_ X-MS-Office365-Filtering-Correlation-Id: 87458429-4b9e-4709-c799-08db04b59a44 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: L8ZlJgEqRB+zlxqVP4dXI/VcSUNM9vKEKsTxUEDoTxfIhqXK65o3AJLpgcHENPGrVgzvX5gopcb3jC1QwqPgYFcM1rqOb6phdmuVAtKgcSDPz733MuiKJmEYgZW0B8sLr8Sz0ZbIrU+Eb6F8Ge5cu9hbNtzY/GA4D8j1OpLYoOfMiH9EOAYlLq+2b1UC1zBIdVN4nHcYlO7uD4oWdl3zYtQGpRghpa13U0elP62uknUEscQyh7ZlHw6B4pwd0d0W8hXzkwffjyid0x9qbqdWMg9yR8ETPcMAt8pHINMC4KOhA3+FA80/tAwKeklxirVwIdKm+OHvY0YnA6nFQ76vNeXWMOFfE74obmFU4yKKA7IAWqe9e1J7YTUd0V/wkcZ/C+0bNEM27sHpJYl2CXq4WAHVtlnJ9NmpKPk67yiPY4L1i9ps3TKpGAyDxnM9ZGlC6XIjSio2j+EtjiMn9LCic6rtZBerseG3k3kBhCH7pBjHiKSOACexwLC/G9Jkh98US3rqhOFw/zpa21LHA+XnCa57p7DgC4kT5xla+yR4tZVpEI3a/iPuZaZqtQErqclaDWUp2Q/TKRrYis1sbgSmKti64bacSj8efHvzt9Tp+YTTQTKpxG9dwVfZLw3wcr67fSpqjFetnZnOL2yHf5UAgBsUs5dqLzqgMp5tidcJUygT+tx3DWgb3qi4kslYxwMvL7NrkiyiArgEkQVlKJGo2A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(376002)(136003)(366004)(396003)(39860400002)(346002)(451199018)(36756003)(2616005)(7416002)(6666004)(52116002)(478600001)(2906002)(15650500001)(6486002)(38350700002)(86362001)(38100700002)(8936002)(54906003)(1076003)(6506007)(66556008)(8676002)(5660300002)(316002)(6916009)(41300700001)(44832011)(66476007)(66946007)(4326008)(6512007)(26005)(83380400001)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UHxs4GB5E51LCIFKVAhUC6N+ms5UH6KZhaIwXjQQgqxa0JWfbmSzwAqDoAjceTuF0ESzFViDXDoHMhB+svYDGW7Q78nrAu6CBBokVGQInxsvSahi8C5jlWn1+iz1WTLCYsuOUWvNnGx3hvaOleBwdV3EzA+ZTzzErDOR6hMqm5Z7+tDj2s/RLcoz7OJhe2azQMzyqQbMzuQzoiuAnQwuiPP9Ca0tsicmlI9BFqGPJF3eoYo91is6tZLgg2Fxel34+EcjfNqgfoqicYxw6ONyvE1hW3iogHH4zSUMXgeTLXlpWtyfc9jTbooFBWTYp/btD6S1qRdWNFX93vsfMjNN+5Pv0NXqXb4J3fr27dhzCuszMr3CBgOn99z835aux7zV5ikTX2e1CU939TwbZDaaQamI5alwjFSqoNk6lJqiNPFsnl+3RjTv9WT55mlm073CBfPrcszY54IyQWPNKxLCnRhqbUPGzUJ2TrC1rdAssh91KIwhAPg4tA2KNPeE8Ow5siyCK2CLS8O2+03/WJMmAA1zNBBE1hb4QTqkwxQzgDx5mJQCwceDHS9PXuJhULmBVW7+G2O7oSkGXxQfXSKFqBujlawpR7sMYCVh/p1J4fhhOAnVwni9Pv1tzkQnFMeBZUu9c91Y9wgt8ZoeS8Su6RmOIOrSDBKs3rMG7M5mn6fm/h42PvXRTgJM03EhYuCJzmKUWeZGdEhjQYXn/hoQPZG8M/u4g+yMOf/eQoQqnit9j7BAVf2baFb7ymsutvGkrnXmcYCutCTKXzBeyVKLmOFgQMPTMKVjBTQC+ZifJxmk0Sk4MX0tJDzk7GATjRRLyeInEzsCJt+hlrXgn8Ocgr60gdA60mPfmlarRicwaQpha6nttA8Ujpk38w7CBSwrQZxtw0/WZ1FZUKeEsolyXGBB7Cyty5hadT4CiwdZgfg51QHZLsY/vf0eWlQ1Gym5JHVVKqTkkoXKxVHs+UET6eQZwRclauPNybhQ0qGwNauJ3wX5Uh+1hFVXxiJsda2U+KsRMASiGXVdkSlfc3CLGnIEY2LigVyFkGznlk0J+h6mBlQCJ/D7T/VyNlIYHXMqfpoopFeCD+p/LLTn9AzLwoGGOVBqSri9zPTcI91ZGvP71HDYnKtzhsUSQEYfOrwl2a06xuX4sgHfzy3NIdWVMvPfdUseY6uBo/tYOOZtjWOkd6LauxYAMMgFgSOYSGcoL/4gCjs8ec17eSEC2JSr1nAGw7M0fmxnmHbT2n9WJmxTgoysymLii8U8nEZJG+nduar/vpJ3JdTKv9uZOohFhzn5ASyoWWoaiuubAuzOpIfJljHGTOdfDfLSY23o+65inrweqnmpBsSJnoSiqBspmIIC++dLVrKfsK67qOodcMqjC0y4WJiBUQpXE7oAAZieciiz9E8TH9vVpc4qWuM2CNVScx/1jpoKgICKhVHiXSxtAy5+O2nOHVM3iTpe3vEOs5pLQFcQVYc6+ZBM5cPwg4BdtpUdi3Zq8hwWusllJJ8I3unQDxasp+KTyO6PgBsOoZPspB1ccinPE+pZQhFqnWl47mGkETXNszhapS7KNpBAwEawTkY44OTHN7aJ2K0+E5LcY62DiZVm46KFCNTzEQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 87458429-4b9e-4709-c799-08db04b59a44 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2023 00:37:02.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: j1J4TqcgMnf794MWDRkPXv3SPvhXw53IrAz6HDNOa6dqZFknNok7RCXL+rKTPUmiYaFaW/YUIgTvK1Wd0v5VKg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8789 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The enetc driver does not validate the mqprio queue configuration, so it currently allows things like this: $ tc qdisc add dev swp0 root handle 1: mqprio num_tc 8 \ map 0 1 2 3 4 5 6 7 queues 3@0 1@1 1@2 1@3 1@4 1@5 1@6 1@7 hw 1 But also things like this, completely omitting the queue configuration: $ tc qdisc add dev eno0 root handle 1: mqprio num_tc 8 \ map 0 1 2 3 4 5 6 7 hw 1 By requesting validation via the mqprio capability structure, this is no longer allowed, and we bring what is accepted by hardware in line with what is accepted by software. The check that num_tc <= real_num_tx_queues also becomes superfluous and can be dropped, because mqprio_validate_queue_counts() validates that no TXQ range exceeds real_num_tx_queues. That is a stronger check, because there is at least 1 TXQ per TC, so there are at least as many TXQs as TCs. Signed-off-by: Vladimir Oltean Reviewed-by: Jacob Keller Reviewed-by: Simon Horman --- v4->v5: slightly reword commit message v2->v4: none v1->v2: move the deletion of the num_tc check to this patch, and add an explanation for it drivers/net/ethernet/freescale/enetc/enetc.c | 7 ------- drivers/net/ethernet/freescale/enetc/enetc_qos.c | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index 1c0aeaa13cde..e4718b50cf31 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -2638,13 +2638,6 @@ int enetc_setup_tc_mqprio(struct net_device *ndev, void *type_data) return 0; } - /* Check if we have enough BD rings available to accommodate all TCs */ - if (num_tc > num_stack_tx_queues) { - netdev_err(ndev, "Max %d traffic classes supported\n", - priv->num_tx_rings); - return -EINVAL; - } - /* For the moment, we use only one BD ring per TC. * * Configure num_tc BD rings with increasing priorities. diff --git a/drivers/net/ethernet/freescale/enetc/enetc_qos.c b/drivers/net/ethernet/freescale/enetc/enetc_qos.c index fcebb54224c0..6e0b4dd91509 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_qos.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_qos.c @@ -1611,6 +1611,13 @@ int enetc_qos_query_caps(struct net_device *ndev, void *type_data) struct enetc_si *si = priv->si; switch (base->type) { + case TC_SETUP_QDISC_MQPRIO: { + struct tc_mqprio_caps *caps = base->caps; + + caps->validate_queue_counts = true; + + return 0; + } case TC_SETUP_QDISC_TAPRIO: { struct tc_taprio_caps *caps = base->caps; From patchwork Thu Feb 2 00:36:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13125128 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 8A658C05027 for ; Thu, 2 Feb 2023 00:37:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229848AbjBBAhr (ORCPT ); Wed, 1 Feb 2023 19:37:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229991AbjBBAhS (ORCPT ); Wed, 1 Feb 2023 19:37:18 -0500 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2044.outbound.protection.outlook.com [40.107.15.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2A3D74C09 for ; Wed, 1 Feb 2023 16:37:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iU7jQe6YdOXDtP7h92jgTF2m+uz2ExLHk9LGJpFKC45t7rDsvdx63PzUb8HozOH6NhSkJnBn6C5aeCftOEFBHWcVdfoSMIbYFpGEMK3mQCXnGDdVtMIFJ1hmJQrEBsN+3a/hJGg69QTQx4S0vHN0DMSyz0oLnKPaKyxP+uVBuMBtModgmqV/TsgfnBnJBn1tM9ajBrOL7E005QKRavPG9aB3JUHRFq9plBN5TQ8XP/i2Nl6CHqPcff+x2gWCJd5iDGDbYWKWmaSJtJ1jyPTd6GpvKC9CGKPbLlqwzSmduB416KQadSgJCf/tm1bQevYDUYRy9IfY9y1jHkiMOKrbzA== 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=h/c2wmNxoxkamfjwqc4PX7zHFrZ96xKuRjzD6ZJODa0=; b=AMfLekR1qojIa+OH8wQybn+B24HsoteA0xb/aHex+IfVGXouoLo/+ORBgaNCOzz2XXyZMinEkL6bBmSx1qb2ruOSW8cM3JqBTqhw5TQCwFymOVJ+UfRaNpPSEa2KmQfRAXYieyRUbuRBTZR8cN0GNBc5NaJ7llALCicDUBXFRdQipy5+GRT5JOrfV0xS4vqyRgLr28Na4VJUZ5USdUZt8rkzu9IlxNINtONK84pe8n+UV7/FLwD0mtnwciJKOFPopgQjXZFLyMBWS6XtXrKYAwitSQbw31OM2T5xuqPUpDPg9+I6U/hvexN2Hi3LWxq6u1dthe+V9R07ABOcXskK6g== 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=h/c2wmNxoxkamfjwqc4PX7zHFrZ96xKuRjzD6ZJODa0=; b=PgPZsx7JV+2zu+D3t2frIcC9QiLaZ9yvla51aq6I2lU/j140EwNiP4EJjJ0z+bjJh2yFbdJktDZgONrfloM+0ynKMDkMg2vFkaLZ+9mGCOTapJKwU4B2zyAfmpQnZtSdnvpQOh9fgfapyXuZV+uqHjAvrJpi2NFuqHnvYDLaDB4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by DB9PR04MB8362.eurprd04.prod.outlook.com (2603:10a6:10:241::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.25; Thu, 2 Feb 2023 00:37:04 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%3]) with mapi id 15.20.6043.038; Thu, 2 Feb 2023 00:37:03 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Vinicius Costa Gomes , Kurt Kanzenbach , Jacob Keller , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Simon Horman Subject: [PATCH v5 net-next 16/17] net: enetc: act upon the requested mqprio queue configuration Date: Thu, 2 Feb 2023 02:36:20 +0200 Message-Id: <20230202003621.2679603-17-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202003621.2679603-1-vladimir.oltean@nxp.com> References: <20230202003621.2679603-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0032.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:22::20) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|DB9PR04MB8362:EE_ X-MS-Office365-Filtering-Correlation-Id: 9af981aa-bd1e-4f51-96ca-08db04b59ad8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KeScCZUmKPU6OCoCwr5ILQcJPaQs7jagqLefNCT8MEhaXIvXjSastE1VShcLRoOhmu/GAWtBPzsU6gGvLn/quPw617txLDb2Ni9Z2UT5jqiFj1lv0GOQiAC1AK56heq1aQqLU2rkMfG8MTnszOcXsmU54u3OonSOj+6+JX8NUL1eYIOrS6D4y0oEI9EZYLLqyFcLmVWRwO2u7JKpWVcuwR2tga8hZfMYh56ABwODbYspU1RtWmsyfHR74RspF/4G3PkxwcBvXF93roCeVwwf5NBl1px/WKCT/Cwey6BofiP6c8OtErA+UFiKXNTPmxllViUCsqhLGVsWJnRCJQJqb0tfG+DZPJNxd+m6fO4pumPUCM9cMMCpZVuShK1N3ue/3u8ErRUFSICv8GeJNanyyiQ6WVdoIDp2THrkO7YQrI1nlAeEfsya0hnS7hSfCvHkCfefSqFqStl0l2VvCcZ1bgqYrTb3wuL6jeycwK4PPvuDSAf5nC8TcdtsFtIHu5otlDFxanASCPV5s9sBjkdQgeGQCRiZKQQjV0Ac5bOkKEtWeHr+BjcnmYLkYIKyNyTnp9Jqe+khWpsy35LAwOP/XxSRbwCIPCNrALFUStjaOzDRaG2QtMMi0wSCToHm3aD1O5ASQrCLIzglzVjeMCxwqej+uU+do/GArh7bnrkKMv7mWqEqo5XD32hoaTKxHlu8QQyTgydhu8ICa3JSlqYQrQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(366004)(39860400002)(376002)(136003)(396003)(346002)(451199018)(478600001)(44832011)(54906003)(38100700002)(38350700002)(316002)(6486002)(83380400001)(52116002)(7416002)(1076003)(6506007)(86362001)(5660300002)(2906002)(6666004)(186003)(8676002)(26005)(6512007)(36756003)(2616005)(4326008)(41300700001)(66556008)(66476007)(6916009)(66946007)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Kdyuvj7bMqJkjEgDaiHfpocwtUODJOHJfUlsgFt4IoeNbbwfgm8ZKsSZJW0P2f/xBl5EBytdRzZ2j3DELDBaVLzF4sdiWYalB3KmB2gopDsrVgSntBePM7tmRuQE29io8Ka/7j8djdtSJZg2lhF/omMuRAkA2fOo6sW97NDkY6BLX2D8Q5MB8ef/eWz9atuM5JDzTN2tTsN+PJOmbHiAUMOiWXobXLTqPn307mx10CloBN/urHDqg/FuuuwXkJBR63TQ87/WiCoijNwy40yC4ktMzGSlKJGLMeir8QhS55M2YgGxIjWHFKi4WC8GMEBlkKKd8bJT3MzE86xg4MiOYqnXKVyuc5q1DPpcm2WtWxWeOfTnyG+SjeOI9KsoIF3ld8N3uuaDBldhEbAXn2ESJ2AwsktRicJ5/LHxwotPsjXRIEnPVcAcMC3ukAWjyBbnfcOaBv4C2Juaccev4/z7L/jGYohRJLmxrndD/zisO8z9quNBGyerQo7n+Rg0chDNMyxJjiXX4jRWCVqZckijdp4aeRbnVhUGAl/Psj4qVRE9AzlcFcH5NShf3pNttOqW/DzEGosI+SyW3VaAIpBe/KdZymwmTx90zsBcHVqNRLd7xtAIftV5QrXtxe+QHOLgFQBt6dgztXDT9W4MI7aNDEivApTQi+YpVrDjEdt0ITlPcIumMZKLFm/2dMbHyAg1rWEqh0UbYGbbCzJ0BoujAlKFx6aknc4jYvsKlnhLMuAvVfQxYb/CmCZAHgerfIid4wSYMMbIKIeZQuqCagITCY/IA3qzw1Ar7XJXGdIFEW483lzwZjqXxn+Kf+RLVNTEbvRn+qdivN2e3/H+xrSDQMGhczXb9pzbRoUd4wPCRjJyp0BVRMGHCbT/zSRJVu19DumpbOvwYCjqP+2bF/fmfEc9U/MyzGW2mR7/9aRW1Djq/H74eiWpP+tOyLfFw8BQx99wkmmKiZEwE+ZQbEEpMcn8jV0T85nkrvUWvI5FGhOZr+ZZ4rJc1+j1PGIhagx4yX8UosGgxGFKGkNjgNs0PR4P4ApYx+pr5CLARaHu1HdXsTQYTzTv46EcrEuhloONDLeOLgEfgJEKIeRYB6gCaC2fvmKASypv4sbmxtpfaLb/QobLZTtqCpDSAiwNT3hZa1Qr/+CIIznVP8PIR4t/SjpYTWCQyz+ecHAA488sypQP0McdV0WVtN1NpdfcKcbHIG9bhIcP43C+UKWVSf8BdDdB0iEbu1jGsONHrJ2gFb1RiZfnq+XHLZ3zIHU/91ZVyQOyjyYqLUcz6z1ZkEbD2kd6oXO5FBhNX9doQxUb7tAGOcbSEkcjh7bGU4u+pApjF9b5+8twXa7SWCgZusxVQsJjLLA2fRxPbLwKnu1rJei4Jkwpo1uZ9G0igbSo++IHSu5331Es6ILgttvjxosHa/9iWFJWyImbp1OIepSk9/IUBTi1X2oV9ZLBDiFoodRDsj1ETMzTRHjUahrK4rao697zMJvjF65d1/O3JViHGDJ5XkNmWuBtMhXvWFbZBgzmeIOxr2kSAJIepu0Ph2fbSV1kkIT38Asd2ruzy2NVqo3bHxy5yVsH3LjjjOWbVNQHuaXhG4GhGC7Nzd/+aTSD3w== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9af981aa-bd1e-4f51-96ca-08db04b59ad8 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2023 00:37:03.8409 (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: belxvH9jDiIsKxKlfSx2+5Xo1oCdBBWrRH/Xn9RYqQTj1d5KCQyoVPr5GguPhq9npvepR80i48LqHav0PfzdjQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8362 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Regardless of the requested queue count per traffic class, the enetc driver allocates a number of TX rings equal to the number of TCs, and hardcodes a queue configuration of "1@0 1@1 ... 1@max-tc". Other configurations are silently ignored and treated the same. Improve that by allowing what the user requests to be actually fulfilled. This allows more than one TX ring per traffic class. For example: $ tc qdisc add dev eno0 root handle 1: mqprio num_tc 4 \ map 0 0 1 1 2 2 3 3 queues 2@0 2@2 2@4 2@6 [ 146.267648] fsl_enetc 0000:00:00.0 eno0: TX ring 0 prio 0 [ 146.273451] fsl_enetc 0000:00:00.0 eno0: TX ring 1 prio 0 [ 146.283280] fsl_enetc 0000:00:00.0 eno0: TX ring 2 prio 1 [ 146.293987] fsl_enetc 0000:00:00.0 eno0: TX ring 3 prio 1 [ 146.300467] fsl_enetc 0000:00:00.0 eno0: TX ring 4 prio 2 [ 146.306866] fsl_enetc 0000:00:00.0 eno0: TX ring 5 prio 2 [ 146.313261] fsl_enetc 0000:00:00.0 eno0: TX ring 6 prio 3 [ 146.319622] fsl_enetc 0000:00:00.0 eno0: TX ring 7 prio 3 $ tc qdisc del dev eno0 root [ 178.238418] fsl_enetc 0000:00:00.0 eno0: TX ring 0 prio 0 [ 178.244369] fsl_enetc 0000:00:00.0 eno0: TX ring 1 prio 0 [ 178.251486] fsl_enetc 0000:00:00.0 eno0: TX ring 2 prio 0 [ 178.258006] fsl_enetc 0000:00:00.0 eno0: TX ring 3 prio 0 [ 178.265038] fsl_enetc 0000:00:00.0 eno0: TX ring 4 prio 0 [ 178.271557] fsl_enetc 0000:00:00.0 eno0: TX ring 5 prio 0 [ 178.277910] fsl_enetc 0000:00:00.0 eno0: TX ring 6 prio 0 [ 178.284281] fsl_enetc 0000:00:00.0 eno0: TX ring 7 prio 0 $ tc qdisc add dev eno0 root handle 1: 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 hw 1 [ 186.113162] fsl_enetc 0000:00:00.0 eno0: TX ring 0 prio 0 [ 186.118764] fsl_enetc 0000:00:00.0 eno0: TX ring 1 prio 1 [ 186.124374] fsl_enetc 0000:00:00.0 eno0: TX ring 2 prio 2 [ 186.130765] fsl_enetc 0000:00:00.0 eno0: TX ring 3 prio 3 [ 186.136404] fsl_enetc 0000:00:00.0 eno0: TX ring 4 prio 4 [ 186.142049] fsl_enetc 0000:00:00.0 eno0: TX ring 5 prio 5 [ 186.147674] fsl_enetc 0000:00:00.0 eno0: TX ring 6 prio 6 [ 186.153305] fsl_enetc 0000:00:00.0 eno0: TX ring 7 prio 7 The driver used to set TC_MQPRIO_HW_OFFLOAD_TCS, near which there is this comment in the UAPI header: TC_MQPRIO_HW_OFFLOAD_TCS, /* offload TCs, no queue counts */ which is what enetc was doing up until now (and no longer is; we offload queue counts too), remove that assignment. Signed-off-by: Vladimir Oltean Reviewed-by: Simon Horman --- v4->v5: - slightly reword commit message - increment num_stack_tx_queues by "count" at a time, not by 1 v2->v4: none v1->v2: move the mqprio teardown to enetc_reset_tc_mqprio(), and also call it on the error path drivers/net/ethernet/freescale/enetc/enetc.c | 101 +++++++++++++------ 1 file changed, 70 insertions(+), 31 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index e4718b50cf31..2fc712b24d12 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -2609,56 +2609,95 @@ static int enetc_reconfigure(struct enetc_ndev_priv *priv, bool extended, return err; } -int enetc_setup_tc_mqprio(struct net_device *ndev, void *type_data) +static void enetc_debug_tx_ring_prios(struct enetc_ndev_priv *priv) +{ + int i; + + for (i = 0; i < priv->num_tx_rings; i++) + netdev_dbg(priv->ndev, "TX ring %d prio %d\n", i, + priv->tx_ring[i]->prio); +} + +static void enetc_reset_tc_mqprio(struct net_device *ndev) { struct enetc_ndev_priv *priv = netdev_priv(ndev); - struct tc_mqprio_qopt *mqprio = type_data; struct enetc_hw *hw = &priv->si->hw; struct enetc_bdr *tx_ring; int num_stack_tx_queues; - u8 num_tc; int i; num_stack_tx_queues = enetc_num_stack_tx_queues(priv); - mqprio->hw = TC_MQPRIO_HW_OFFLOAD_TCS; - num_tc = mqprio->num_tc; - if (!num_tc) { - netdev_reset_tc(ndev); - netif_set_real_num_tx_queues(ndev, num_stack_tx_queues); - priv->min_num_stack_tx_queues = num_possible_cpus(); - - /* Reset all ring priorities to 0 */ - for (i = 0; i < priv->num_tx_rings; i++) { - tx_ring = priv->tx_ring[i]; - tx_ring->prio = 0; - enetc_set_bdr_prio(hw, tx_ring->index, tx_ring->prio); - } + netdev_reset_tc(ndev); + netif_set_real_num_tx_queues(ndev, num_stack_tx_queues); + priv->min_num_stack_tx_queues = num_possible_cpus(); + + /* Reset all ring priorities to 0 */ + for (i = 0; i < priv->num_tx_rings; i++) { + tx_ring = priv->tx_ring[i]; + tx_ring->prio = 0; + enetc_set_bdr_prio(hw, tx_ring->index, tx_ring->prio); + } + + enetc_debug_tx_ring_prios(priv); +} +int enetc_setup_tc_mqprio(struct net_device *ndev, void *type_data) +{ + struct enetc_ndev_priv *priv = netdev_priv(ndev); + struct tc_mqprio_qopt *mqprio = type_data; + struct enetc_hw *hw = &priv->si->hw; + int num_stack_tx_queues = 0; + u8 num_tc = mqprio->num_tc; + struct enetc_bdr *tx_ring; + int offset, count; + int err, tc, q; + + if (!num_tc) { + enetc_reset_tc_mqprio(ndev); return 0; } - /* For the moment, we use only one BD ring per TC. - * - * Configure num_tc BD rings with increasing priorities. - */ - for (i = 0; i < num_tc; i++) { - tx_ring = priv->tx_ring[i]; - tx_ring->prio = i; - enetc_set_bdr_prio(hw, tx_ring->index, tx_ring->prio); + err = netdev_set_num_tc(ndev, num_tc); + if (err) + return err; + + for (tc = 0; tc < num_tc; tc++) { + offset = mqprio->offset[tc]; + count = mqprio->count[tc]; + num_stack_tx_queues += count; + + err = netdev_set_tc_queue(ndev, tc, count, offset); + if (err) + goto err_reset_tc; + + for (q = offset; q < offset + count; q++) { + tx_ring = priv->tx_ring[q]; + /* The prio_tc_map is skb_tx_hash()'s way of selecting + * between TX queues based on skb->priority. As such, + * there's nothing to offload based on it. + * Make the mqprio "traffic class" be the priority of + * this ring group, and leave the Tx IPV to traffic + * class mapping as its default mapping value of 1:1. + */ + tx_ring->prio = tc; + enetc_set_bdr_prio(hw, tx_ring->index, tx_ring->prio); + } } - /* Reset the number of netdev queues based on the TC count */ - netif_set_real_num_tx_queues(ndev, num_tc); - priv->min_num_stack_tx_queues = num_tc; + err = netif_set_real_num_tx_queues(ndev, num_stack_tx_queues); + if (err) + goto err_reset_tc; - netdev_set_num_tc(ndev, num_tc); + priv->min_num_stack_tx_queues = num_stack_tx_queues; - /* Each TC is associated with one netdev queue */ - for (i = 0; i < num_tc; i++) - netdev_set_tc_queue(ndev, i, 1, i); + enetc_debug_tx_ring_prios(priv); return 0; + +err_reset_tc: + enetc_reset_tc_mqprio(ndev); + return err; } EXPORT_SYMBOL_GPL(enetc_setup_tc_mqprio); From patchwork Thu Feb 2 00:36:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13125126 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 3D461C636D3 for ; Thu, 2 Feb 2023 00:37:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230294AbjBBAha (ORCPT ); Wed, 1 Feb 2023 19:37:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230169AbjBBAhR (ORCPT ); Wed, 1 Feb 2023 19:37:17 -0500 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2044.outbound.protection.outlook.com [40.107.15.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2233D74A78 for ; Wed, 1 Feb 2023 16:37:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Tyyxut22TDu2UPX2kutrRGrCCkd7scOBR50hT7SAidniOs7wVrPV7ZxgtmYJVCl6OAYiBp6TjpgoWAm4t9n2uplN5ng0t9p0fl4aBzi+pkyXWTANYM+FlMr1ipIFF7MDxaYb9JRbNxEEbvJaKR3kDBMBc/GD8GA+4Zy476971iKWRX+Ow+TJp1hDYHAHNsyKfXUEc+eJxvX3f/+85rLbaEFcDCyaDuoiCTmcCOAh9pItlNzE9k9+Y2yRqCh96/Cz/qefS8sl3Yvtk3iBUmNwBb2Dlzl7Ph/h57fKNY+RXBN7/eQ/CZmV/7wYFNL71x410Y81i40Ka8ufX6OoKQK5hw== 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=YFVwGu0C9hzv3/ETbyfGNJUofY4pT/mrgrNetqntAAQ=; b=BG+ZyG4LJTdGU5EXjTtUPA5NwHahUS6/7zsIu/HZar9mDwuHvMMhI8MmHd0CfTJU8w+UeHT6mFRdtYL7qW4MehhL68O4oWITJDBpXbBpW4HIEtgws2NCNS8H8tsEpe+Y3DUcss7C/PGvrk/753a3BNvu0b28HlOpccqaYV9FdbyMxEsXwxfoCUgEwocnyKJ1CA3RvNYgmCQy1bk6nAaNVza9IeDbvRGCboscCk7EGipYgjkjaHGXt7vv9TJPo18HCg7oekmvwkz+wjzt/TfF8zyNUAe3kSg6bnkAWjtRhJR+8rbDyGd0KFm84dLFFidLQrVrQWvHdAsx5IVnFDUVDA== 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=YFVwGu0C9hzv3/ETbyfGNJUofY4pT/mrgrNetqntAAQ=; b=U6K2pxOoNteUdQyR7O/Q4vngJXAgR9bRQut1PAgANb3Mo/eAu9JMPgYjg3qBwymk+XukldyoxtgammLCk7nA0ZdyIgQZ09vI/+eFHI+/10hZSirNh8nq8ImzCULUUTXP+4EO4lFbABwP/m87ZhL19jtbUlbumGepsh155oiPeJA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by DB9PR04MB8362.eurprd04.prod.outlook.com (2603:10a6:10:241::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.25; Thu, 2 Feb 2023 00:37:04 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%3]) with mapi id 15.20.6043.038; Thu, 2 Feb 2023 00:37:04 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Vinicius Costa Gomes , Kurt Kanzenbach , Jacob Keller , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Simon Horman Subject: [PATCH v5 net-next 17/17] net: enetc: act upon mqprio queue config in taprio offload Date: Thu, 2 Feb 2023 02:36:21 +0200 Message-Id: <20230202003621.2679603-18-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202003621.2679603-1-vladimir.oltean@nxp.com> References: <20230202003621.2679603-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0032.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:22::20) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|DB9PR04MB8362:EE_ X-MS-Office365-Filtering-Correlation-Id: ceff6723-4070-49ad-a150-08db04b59b67 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BdxPK9MqEBBGXsRNDBsVTf0QSRmWGUyazGWf6XSrD+5w/E1X4xdtIoM3RMq2ktHaCGKFRltlNWJ35Y/HEvO0WW5CcAv9ifknqDa4H/L85qu2Jchr4+oqNmW2pPXcj8D+XU5nMs+tWmIAncEJjFWXl9kcyEfhjfjjI+lN2bSa4oSA76B8PBMzk4+jsfP7Dp7+gOxpjQqtMG7cfkfibhgU7SM4PycsVHs3Bcox0qJHbmZLlqP9taNsAYsmNOhDhhwkqTY0TwPzxvGz8/lCwTRWnnMvT13j3oQ/82j1JLw0+uBRml/o3duHTzjuwIMWuC4txbz56W03ag80V988wRT1QxmICsQBmqQ4ZtoJ0ERCDYDPdZnwHoWz6OT5nO21u9qH3ZuZoSosUlBFhnZudweW4YgdAXxX7SwG5HgC5uskfwjwBOdtf2mshmzXZICW/fgo9YC+QsIDe5V9Z/Jw4TfAE1fu94hbpObq1Ho8D7vVL1D9j0fCTP5eE0W/1i69Cin7kwBNcP83LpCqdP0c1s31CbkHIDHwvqwEK5SkWgOdi7qJdc1hXn1JMU8qCFfRewSjJ1rrbbDiadGmLHcwrMAbEYcq9OXlQ4vmIoaYMbLNbA5qBNkdMvxr2aoaEYjVIpbSHsGLzV4VDBv44//tsFbRdQRneV+0VkdK8+gI8UQySIS4n8XU97CbbPVJSz01b/lKDSSFXF+bdIL/qslkfaJpkQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(366004)(39860400002)(376002)(136003)(396003)(346002)(451199018)(478600001)(44832011)(54906003)(38100700002)(38350700002)(316002)(6486002)(83380400001)(52116002)(7416002)(1076003)(6506007)(86362001)(5660300002)(2906002)(6666004)(186003)(8676002)(26005)(6512007)(36756003)(2616005)(4326008)(41300700001)(66556008)(66476007)(6916009)(66946007)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: C2qIdiomomRqM8A1aOQff7Qq8h1V9e4TtgoE7cdWmcgk1lOA5sVHgW17/n/zwd386e1E51xukX2uUtf5J5qAv/XgVowf8ng9T41DANMgKRXOh/prV3RH1R79sJhQVdHKNKBHzaw6Kpbzadhi4guo35aKAdg4b86ZnIhE72pI40Db7+qt2di9n27FGmRC2YookErm2qnCv7sjQyrLFJG5TEdu3uHzUouEKiLKU7Xx9YnY2jMfnFM0e2rAG87KcDtdovxcCiCX2Aj1hnzUOMXFc6D7Ws85eNpleVLKdBFH1pSrilip/5wtoJ0niR2d/+IW38n+BfCKl10Zwc36PrjpnkwCLVbNFju8eJoUK3gycMsDAa93nWLEx12D0/pI6Burz4ghDW6QXjNXreBk13Ul9LU1xrixsgXVV+TdSirXS+B6Pz+K+hjDeCcE1m9etwRepGtmra/wpnC3YkhBqf0QjaanHqNW+CIJW3tYYBDGU7nvobCdothD8xs5c0n6YzLe4eXd/ov56BwPB6nbQI7N4uQtvNOXIdI71MPqaAT4NBBNsH7zG6KgYzJTqP3egcjS/Gyv/QMtDI1oxk6HBHPClhA6o223D9oRiaqUlT9NFN73inzRqXnIkBwgfjisi5FMQOwfgGQbI+eiDGCBGf5v40lQopufxiHOecOjeIRhaslnsTth7BVcH/nA6ect7sfRp2MGHFODdvLW+5HhZaG9Q4kZ2xMiVOGnRM4A/T/zOi7o1ZGPL18xWiRno22MnSvilCFizGCr1YSmyqwSWTUHPOyJ7EN/F5wc8/Y6P/Taf2uHN5ZcqsqJj2y2Ofbv3Ugk5+Wd3tQ/qQ2S6lXlj0/EAeYXgGmoVBOHhUS7cs8DNaab4XN6cCQj6lWahFYDvhd0xx5HGaGJLPMynEkRypZR897Mg+nwrtuJQKgJWFPRI6nGc0LXz4lUfvVFEvb5X+WeKtVmxgYa0H3+ES6Xa4q+VcBSiKaTDekoFiLCWjWwIdBW/yo4B5AUjnyjWWOWN8VIUHwrION5I/oCwSCK7c1JgGQM2E6zU8TTVy5cRno3gZkf+xOiX5GnXEG2ygEimmrq8uS7CJ8CT1Y1AO9yfCy0W9Zxf483lApI9KBk9WXeBfwDzWSrcL7/5DcRmkfYU0ToUoLVYYoBSeVEa0AwCs/dRfa9nrqCZPJVkow8ZjFVcMtm59M5LIveV6owvKB1MXVYXwo/+HGUCnaeacQvAM9M3ljXyhIUVxT+Qjp5WJeI78XQgxPV847dpL2dLjBfy3r/tuhzseynqFnLPwn0GHtUcrsDZCtnVpwAl0ggopOVsof7cz09xrB932K2pvv69RJrly4TRMxDerKCdaJHvFAN9oz55RasHjkAeWAvKIBAJFEM6XD9SgHDzD3IZgk6WKxBZflr8DeUzJnvttBxWYSCEHR1F97sTaE+oyOYwNmQCcXnU+CjzsbkrnmdVmhHLUmcyx+i7Kr/19KXfnzHEYBUT/cD/gRPOB0gGeGZ53c4YdPEHxfKo9hOVKfYqeltS3XwUj25L+S57lf4ZhM0Y5C/xCqzrgHPp/OdhFNBrC/JDhUOOly9POq8O7mlV9rDopvjR0cCmsGrjM3wpyGPuw+6jQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ceff6723-4070-49ad-a150-08db04b59b67 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2023 00:37:04.8252 (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: C3A2NKQVPbqTXJgwKQKfDcyiWoSXJuea7HIgs36jy3Jxa8PXXcUHdyniUg+SXTWPUHo1IKsyDe/LheHgF88xtQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8362 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org We assume that the mqprio queue configuration from taprio has a simple 1:1 mapping between prio and traffic class, and one TX queue per TC. That might not be the case. Actually parse and act upon the mqprio config. Signed-off-by: Vladimir Oltean Reviewed-by: Jacob Keller Reviewed-by: Simon Horman --- v1->v5: none .../net/ethernet/freescale/enetc/enetc_qos.c | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc_qos.c b/drivers/net/ethernet/freescale/enetc/enetc_qos.c index 6e0b4dd91509..130ebf6853e6 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_qos.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_qos.c @@ -136,29 +136,21 @@ int enetc_setup_tc_taprio(struct net_device *ndev, void *type_data) { struct tc_taprio_qopt_offload *taprio = type_data; struct enetc_ndev_priv *priv = netdev_priv(ndev); - struct enetc_hw *hw = &priv->si->hw; - struct enetc_bdr *tx_ring; - int err; - int i; + int err, i; /* TSD and Qbv are mutually exclusive in hardware */ for (i = 0; i < priv->num_tx_rings; i++) if (priv->tx_ring[i]->tsd_enable) return -EBUSY; - for (i = 0; i < priv->num_tx_rings; i++) { - tx_ring = priv->tx_ring[i]; - tx_ring->prio = taprio->enable ? i : 0; - enetc_set_bdr_prio(hw, tx_ring->index, tx_ring->prio); - } + err = enetc_setup_tc_mqprio(ndev, &taprio->mqprio); + if (err) + return err; err = enetc_setup_taprio(ndev, taprio); if (err) { - for (i = 0; i < priv->num_tx_rings; i++) { - tx_ring = priv->tx_ring[i]; - tx_ring->prio = taprio->enable ? 0 : i; - enetc_set_bdr_prio(hw, tx_ring->index, tx_ring->prio); - } + taprio->mqprio.qopt.num_tc = 0; + enetc_setup_tc_mqprio(ndev, &taprio->mqprio); } return err;