From patchwork Sat Feb 4 13:52:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13128693 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 D78EEC636D6 for ; Sat, 4 Feb 2023 13:53:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233769AbjBDNxc (ORCPT ); Sat, 4 Feb 2023 08:53:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233744AbjBDNxa (ORCPT ); Sat, 4 Feb 2023 08:53:30 -0500 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2077.outbound.protection.outlook.com [40.107.20.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 988F9B448 for ; Sat, 4 Feb 2023 05:53:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mHnxT5w59DNHppYEMyV/Nw1z4xumdoladFqpkYPlb/bFddnM+Ox3XP9cIV1jFYIVq6WhaBgQSmIqtV9PSqyunRgvBOMvFDYzr4tHFJ902gLy6OKemFwheSMnNO/8tzwvD6/cD8QuBNyU6yTbQhpDoBAC/IW60ps2e5mCcAlNQ3kOUsGcRtMI9tJbYUI491cYt4xDvZVSEeAy7ZfMbTqJaMDvsWdWsRTmepRzVmPY7YU6BTeQZNRYDzgtbPCslxdRhKpavO5K2XWeRkylS5EUx/K0WhUyUz6Sm0x7oT8zVTuqVdXFM2BL4+6ys61XaLv7Ffgb8BnEcpzhLypYbO+Sag== 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=EE5hw7FnxoPzKEIdmOSTMmIKMUAui5diJHTJ5FAYQrY=; b=K2nU+UDaYP9BkvyJIXVocXkjyBeTAznYBgVOPPo9lwBLo44h6HDloEyBLj1v2rIw7yOchWTCM1Dq9G0NPYeXDRGMSj3QG4NnBbAuJ3GlQpOx2Rm2raHy4veJAnvezuGUiQR7iNC5kUu4JiK3uSu2FnjulU74uQJAxM7mbtz58MHPUHynF+CVlbgvquthTLAyyDOqDOPcZVGaD2r+zyYq7uoXT5BHnQ6ytSieVP0NPgYysxNIixQjMMQd9bLhN/NJgSjTSdA+74Yd1Enu2DFmx+/yr4SnlEKPgiRMqCrAc7NxezNbVpN2Rkr2DQn8ECnZqrpVwRdVGBEjiiQbJb8xEQ== 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=EE5hw7FnxoPzKEIdmOSTMmIKMUAui5diJHTJ5FAYQrY=; b=sywqtBQzk3AydiUOprv6Y0ASe5jp5wHdWh8J0W2+Q48Zx1pnAKX5ihU+CYx+Bv7mQD1BMS5bxwzGOS5KMqfBSASGvFLJnJzn9Bj8swzERfuaIJTQ2h12vxhnZbRa1Pc1wLz+q3Tn0qzALD7j7ISLELbzeH8JVfJZXeH9oAaLYLo= 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 PAXPR04MB8783.eurprd04.prod.outlook.com (2603:10a6:102:20e::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.32; Sat, 4 Feb 2023 13:53:26 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6064.032; Sat, 4 Feb 2023 13:53:26 +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 v6 net-next 01/13] net/sched: mqprio: refactor nlattr parsing to a separate function Date: Sat, 4 Feb 2023 15:52:55 +0200 Message-Id: <20230204135307.1036988-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230204135307.1036988-1-vladimir.oltean@nxp.com> References: <20230204135307.1036988-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0141.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7c::13) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB8783:EE_ X-MS-Office365-Filtering-Correlation-Id: 71f41a95-39be-4a66-728f-08db06b72fd5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bxRAqFelbdD7PEwDKkeEnxeRPDbv8E56767KIRpSJ2j7rDGSk/scjVSBXOK2fuoBLi1bl5afDs/m5SABQFrPtLtf1Ew8S21DfHzn5ynmFDI7TCa/gM/JF6IDr1RpLtKpDR8frk88u10WVCSAOOb92viIalHJXw78/SXDwUzoFlUJ6ddp+fWPjPaxKNxyupTE9ypLA8BZW9g1Nz7vjtPRItgBBy1NqWpExVWdbH4sQvXrsF9Ts/XUAHHouJAmZ3fSAsFw+uUNvoOYSW6bN9BaQxNo8pTWF1Er+/1GOdESIgEffVAuUVuhd3WIg/3FT8ksnbXD8XdBRGJ9x0um7a2c6DDDoGsvkhboDFMQH7wgpE1I67GZOMMwZR5Rejo5q5RfYeRXyosxikmMwoJe5UAD4Q59msmPAI3T7fxPIwK4SZMVAdbcEkLPARddfheO4CvDw37Ow7MSF+eDpWPVOkH/w6Tx4Z1bsav0MxvXOnB7gWhPS/Lkr1mYIuTG8s2C031GpNq07rbOJQFhL/VEtANHkQPRmCAWNJSeK3hTFrQsJLcTp85CJH2QDA7MlOxaoZt1NOWkxqcnE5nEVwn0Gii243PjqJ0056ZNUioRHiEQNVUWMjHYbqbHY6he89phQ2ifyP9sD2emZsBpecMZDU9BWJ2MpEYJB16G7gqlo2i/cS5c4cia0jU/U9622i6IbzoOu7lVDcYboDhcQGIcTwFNLQ== 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)(346002)(39860400002)(136003)(396003)(376002)(366004)(451199018)(478600001)(6486002)(2906002)(52116002)(26005)(6512007)(186003)(66476007)(66946007)(6666004)(6506007)(1076003)(41300700001)(8676002)(8936002)(6916009)(66556008)(4326008)(44832011)(7416002)(316002)(5660300002)(54906003)(38100700002)(38350700002)(86362001)(36756003)(83380400001)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hkvqe+uz5mnq1SgoYXi9bkGW++4d1UgoopqekCv9ZD7Nc5HBBnDRrjbRFuyyUQq7KNFQa/fRQoDteJkOXTN1p9ATtnm3WFN6rMf572t/ciGj26uLYWc2gAyaqQDtOZAg5GCbDf+lv2FG2+n8iCbxa1syTLlqNprG44VFq7VVwwEk4v3a6ILGZlTS025wFzfsDM4aQOTYdf+Z25/Zh8X0Q3+jGV8uP8m937kKXUl0OB+zrTaliuq5ZMzdAtuD7mAaFMAR+l9RdicresDdMkc3VuPtRDs6b6kc8yi4DgfzN1cSENYaUKaqmAvLpxLTJTgtXjyL9cyZ88ZqXsYShouW9wvMIBKE4AZ8KHF2+lvIsThHZrHgssidF+BE+jiJmdEEjd8s4ueCwvLbtN5eihpX18/oEecBpR7VLZsdBnjGAPcrDabMvq/V8BGEwZVp478FVA6FUx1kpMw4NlKJZ4qz2W2NowjxUnGjSmd2wG5eIo/OLxKoGDx5rgYHNy/TARDDJLD0AhCmz4vIsqc3NNOvVWNqZzu8mCbtzRLpNEqQTG7fFVl1lKQEPdqzPtlYXK2HbP7r9BKUZBb46lp2kOaEpPvXn3kiFx1fIORkj1Qv7jSkn6sgL1jKUzlHUekZ8SrgQP6F5SG9Jm/Z6ld7jEIqdopotBi4//hs/2F07jXYqvM2h+49TMz9GYW7J54acF1xIqU/wt5vAQRyweSlXuAr93z/CkfcFKBXv0ae0l0wSRIKVY0kWEqUE03RUyp1STYLOED8AoBVUNJ4G0irypsem+Joc1ABRWnDcliHf9eCmJuFFA/HkIxcG4bBrbnOkUuPL8Ll6gmbtJrJHjblhOv6sh+gk5tQLL852fezMkg3cillHHszBna0obx5uK+kIeWncTV08DYJsYHrjTXMWWQtujjJNT3kGdRjz4n6T9q4DwIpFJ7xtXeu1HNfscIFG+V4UKZAiu/rP33eUc5LSJWnD2bfgSjSA4U4iRsmaXkrvcj+RP8QnM9nhFpH6vN5vSzs9feYFlhhXblbXDaWy6/0ls4vfjQKD+xDfntrNIM2n/KBK7RUizLD9ZQxUgjLYXItgvwZXXVitMaggIJcZKeexlG27ZcdrWG4iNxdev/KoH9x8nSSOjybRm7clYWLNgyGk2rSjszSl+cX1y+DOJvfUsR3wBC4JvZx+c3v7FKyqdgWCL1nSGbmSn4SwDoZ7rRediW0Ex7SEodbMU52qEBI0QOASwP/h0EuUGGUXuqz/vKOROpAlWLz9eRuGY6IPwmh1B+pItX7eKlvsYevW+BiLioGmE6+yjdYo5hNtnx0uTrhT856iJGJYlR27AVT/gRs8sHa1+x6xeE7axhF1fLMXgU4w7LJWszO1AyORIH9mDpUnw04D1i7rJgTb3ZHCEBG79VHo1zpkZoE0dXvUmxWzy04c1BOr3lhDcSBmbyw2E1KuliCrvCvJSpKlZWO3pT9HZeS5zrbaVdlqlQ/H3BBwLUjykSjG+YJ95hskCWxuhUE3HIfLgvazwBLayfh2uqMIW3/ZO7poJuQz1FkmonF5dpMcFLKkhVuv+UHQudW59aV+yQnNcaHqIqbsU8vdJgIfyKkaV6M0JlJwVqtn0SOtQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 71f41a95-39be-4a66-728f-08db06b72fd5 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2023 13:53:26.7793 (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: zgHnMC6JPs48GPzVAiYDhEQX3VIW3suRz9IrgbvHlMVxbryi427zrgazI5I4mFHlsPwBzK/FFAUml5IuK3m6aA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8783 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->v6: 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 Sat Feb 4 13:52:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13128694 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 57F07C61DA4 for ; Sat, 4 Feb 2023 13:53:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233744AbjBDNxh (ORCPT ); Sat, 4 Feb 2023 08:53:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233771AbjBDNxc (ORCPT ); Sat, 4 Feb 2023 08:53:32 -0500 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2077.outbound.protection.outlook.com [40.107.20.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD561769C for ; Sat, 4 Feb 2023 05:53:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GioukWIFp61N3KISkk70O0dUcsUpo61MlcB0FpRE0AJ2tmVGGtcsyaPTSgK6tbKDNpSSC3OTC0Gv7yhEpV1FsXWIgBLcT3kn/7FS0pHbvjIYiiCm6JE/xwEpOd1qSnjecZEO49uSVv7Imyqinh18wsSyHxqpbtx7LtDcwmQYShHvyJ6SJmWqOjtjmqwMCtL+nYy4s481U0JFndggh03KBSL7U/JZ06lGDpviTATf+6PEyQF5U1JjY/iTW7gYC1KKRyed3dy5HNqr16LRoEAJEUrF/NjLEGT4AWPrjgpP88LXaM53OiCIhgGHbXr2S4yXnYJGE1yt1fEo6UXlNlgp/g== 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=woRM4qOFTszniTdHyRhts8jr5N7Rpe1JdmrdLJZJbXM=; b=E9e7z+giAfxDTyZmSIiXfshGShiRBSLVH9wKi9uStTOjPYLKWnjdap15jZkVhZbTGuONVF0vEYQLFUPljK4Ff5roy/tVvb6h7nx8Kvkejzg5eBrhw2M5CWDrr1hp9elhW2YDs51rGgd3n/4H7TBCcdUvHQI+Abc4w2Xo8u9FowmyXhPnOynCbU0F4hHkuFdidtHiQyipids51eltxGg5zjGXPXyxZt3ix/zx6AW3cSXsdcFAdXlNItYA5t8tjjmbEYU5ERSC3SqSRvYEuSQwDDtHDv6vgPrIGuIj1oxBRIHcPjO6Y2SiHSvRtNJ9QBqwypK9u5mm+QKWWzEmwUvzHg== 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=woRM4qOFTszniTdHyRhts8jr5N7Rpe1JdmrdLJZJbXM=; b=RNtPpbeGkCTkDXRkJRkz9F+T2ieVnTCFM3EfGlrOTpoX3d5+fib1BwFPP2fQ+VTgjYL2TAW9f4ksF/gBbyc5kOPi1CaTBWzFEjB2EQO04FOGavmooFq3SZiyaaq2EXS/uBOf4GWzmpUTUruhMFLz69uKKa51ObMezT3WhWd2rog= 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 PAXPR04MB8783.eurprd04.prod.outlook.com (2603:10a6:102:20e::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.32; Sat, 4 Feb 2023 13:53:28 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6064.032; Sat, 4 Feb 2023 13:53:28 +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 v6 net-next 02/13] net/sched: mqprio: refactor offloading and unoffloading to dedicated functions Date: Sat, 4 Feb 2023 15:52:56 +0200 Message-Id: <20230204135307.1036988-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230204135307.1036988-1-vladimir.oltean@nxp.com> References: <20230204135307.1036988-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0141.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7c::13) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB8783:EE_ X-MS-Office365-Filtering-Correlation-Id: 240c7d42-d1fc-4313-83bf-08db06b73131 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Iq9j08Ds8WI1jpZrJFYXvakdNCACqiaGHkT4AUF9q94Wupu6kXuE9PhmYlg8sCKK7Ym80KyVgUIfYLKxg3SH6vUMjdOKoCcBlEvYARPamozp9OYFdULn/4c545pO1IKudchaIl4BTNQOD/oCDgG3VtT51BohB+Q8p8OlDn8/oePdO37AXgthoVhI8s2UUY16gh8wRV4rLhSscFlx+OrPrlbnhafHQG5glZ9i3k9JPUIZGltqYVqJR0p+VYkbjkelEJbgZ/2vMem+2uDm2/UJvha+oWFZMK1vT+S+19CeBV/1Ab1c3mkNzrBbhWNo52iVW65YM4pL1SbRsAojWcd4ZO6AYcatooU3DAx3iPFk4MuqkiplCBRA46geP2Eu9B4U7sZbwdhOMZw/3NLf3k1WV+XswozlmH++bA0PqlTqk/KZbnr5ALrzxXaR0KYE1H4yx6+EsZZsas8jk7vN34ZH9Bfad/nsWM5jijbvkizKJOOatmra/QZEE2IBKTmlHw2a+sZ3tkEur2zQF1RRGe/MN5UlEAlziH07gHAcPobNb6lmPCL8ecm3cB5xAjt9T8jN7wpR4zyhbqGMS/32954ZNNHtsVIfeDuZOopeX+ofoxb77TEFyUEJ8WiYeFDxE0moIV3zW/zcFFs/Xt3l4hwu5FRHVJknEMVMGpZQwMlz9dp8JpDzDOD51S3oIljfX4hMWQWAJhcGRoYtKguhwCFGCg== 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)(346002)(39860400002)(136003)(396003)(376002)(366004)(451199018)(478600001)(6486002)(2906002)(52116002)(26005)(6512007)(186003)(66476007)(66946007)(6666004)(6506007)(1076003)(41300700001)(8676002)(8936002)(6916009)(66556008)(4326008)(44832011)(7416002)(316002)(5660300002)(54906003)(38100700002)(38350700002)(86362001)(36756003)(83380400001)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RPBmIVy/AGS2SaZAAoa9WsePlTuk2eXfhs5z00GpIvdkmajs5FAAA51FC2R2SKffgQxLqHsUcDRz2jNiT+mzgJTu2xodS5qPY6zJCDuoHGSekMTYVURGxhyzDxAZvenWeciqjiVyAgKTQXZEAFXKjbHcmm7SjpjiFoZRQzTy/pH+zf8WZDaloz/PSLCBhy3qjghVmRzpU38JN8qxo1g+n/uhTxapU80Z0V0s3FP97OVltvKC9vku6c5AUjZHkzg9RjdoAb701LB2QkGyaeBnvguKmhkJeFAGgdpIP5pRwUUeALe1JoSX6OLoTntwklIEptuANd7WJvJmmMYtPWmJr31E5hsB1E5q6I1mmR2HUyCwLo2u8enMBGgdTshpjxTIEJ0wLwyzla4LzUutViavNFeI77gs8MsK22B/GdTLXu4ABDsyd6trEPAVRkxfoeOHaiqBn7yAiL4KZY4lAJStY4pfxzSCq4RfEyUh2iS2OB4ZqjwPcvIzuklUiHeyn0tcnl57hK3c7q3f1VWeO/TvEkNMrYWBJK5U55IIR1G76pg+1PBc+/UUainNIb+rOAZoNbhHU4irBZXXHv0IwXe1iU2UkCq9fKuwJeAfzHXTzDhAQBrxFuBiGXHiHRzEe7jSl7YUn4LrZWDNgm8LqVgzuwjBszU6Zs1/aM81tSXoLtBQW4UT1UCR07Qe/RtAYl7KOkhZDi6yR8yF3TE7KEM2Njb7voMMuw5J7+TXfFh/DAfH3/YSMDfx6g5mGaoNWEECw94XbDY9weKTOIcAmwE0yB/AV4jXT5MDhIFWwc4Af56XTk3733y02PiNcsw4CymFSGPc9h/F0XyRPbdNSehhvd8O+m7TdAZ9/1C0e+Burfd6SS9G1hKM/xYmpO/nN9u6V8c/p9I0tHpuJQqtqEts/9l3xx1CQIz3qOTQPemDocWZZLU96y8b7exHh4ZZ5OVGZ7PnTRNX1hA26epHy9Fse7oNvUNoC4v+E1xKGUBEcEXkf87SgjecIHKIPCs40y9uvrjxusEbb4zPTzKIy8730BOWrFQ+KkOiANPQ6rZMuIkTLI1HIwOZWrY+zezky8vBk4EZpLgxa0dmma01Ftdza1gjuoHU3S4i0De4Nu+je23L4qbLvH7sKzMMRObDwxlDnJm/Y847iKNcgIsYpQEyI1Iv2CODlHIN5KDcGjRvQtINHe/8OXPFuMd5NvyEWti5YiVMrcZrEJmSKzb8NgMannqA8RJsxH9NhOiyO0YfKVGt6lY+2Z2XsQGe8YKhdflEAEMt7Rqn9h4crt1Fw/rdUlidlbOdhNUbGfG9TkYKUak6kiaF19Z3TMbDTNeLmJErweAoEt6+Ua1+LtRzMPfRu20ZrVr9D1RnFs4VKxcGvlZZ3bcQBHos4/EEIp1Wuv/DzKt3CK8OmVg/XmAvVlXxxFrv89qPiaqb9S/Zg3kYz8Stij1i9s87G+IQhXRRdvXOrQ1YX/QXs3vatHGvmNA5y3fYxN5twNPbtFntOC9VwtQLgvQcx5MHXGH0Dr2xMe4A2cTZQiTq7hqTYoENnrk2YMqYMOfzgHhCyGBIWi99x4ETSk94wFQTRQKalfhgH4xoV5bY+ojxzOrSOEwMnjF/PQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 240c7d42-d1fc-4313-83bf-08db06b73131 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2023 13:53:27.9198 (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: y9azsdDayyANpjN2Xr+vbsL/OEztQCaAsnG/XUPfvOPrv3FT8IgGent0pJed5Y7v1RO0Yyq0XvURYHj1C6K9vw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8783 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->v6: 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 Sat Feb 4 13:52:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13128695 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 CE43EC636CC for ; Sat, 4 Feb 2023 13:53:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233863AbjBDNxj (ORCPT ); Sat, 4 Feb 2023 08:53:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233777AbjBDNxe (ORCPT ); Sat, 4 Feb 2023 08:53:34 -0500 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2077.outbound.protection.outlook.com [40.107.20.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3162C1A4BE for ; Sat, 4 Feb 2023 05:53:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eowhFb3sRCJ7nYgaAgOsg+1PzufpaMEfMvL3qh9vaF6q4em3ddMUGhTkICNRAiKBjROjZmV+F1EUYu/FhIxloOnZleT96NQz1eCIGXWXStf3OqdKSSVq7XHvmOxMFNnD50C5PTCtGmn0agXaZtssujI81IUYa6aZrdB95axF3Hrq3F2nmLjliysRcNsx0YCVBekVjMlPoEnUa6mGRiTKCtOZlUHGzfpPT8HRc8bgZhLmk9nrv/zp1U/ou0svMcemBGR+j8xaToiHPS+/Tq0OrYluBw3HzT6sPDchYyRbKIhrDdCSnIw+hPqaSKav8SRj8tz91udHcc0yscmcigrkmA== 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=1K/OcOJj0xS+OemUsGdbff6O7KyYYXNi2+x1OFms8Kc=; b=I2NUAm8lOQCBD4pLdND89tvhJ1LIa0pAvnHaxSQMlZGsjq3NSF4qWTRRjlmbxeW/QOLwGkfgSF8PJzrs+S13xyoueKxQbQTCVcQmrn3FKhk15YTUuBPBz8AZL77e07mAu+g6tnd4szOKlbjwaMxJTEFcZ3xDOQf4uEf6uaooNVc4z3i40YT79JS6vgNO/MJh3GbZIrwkNk81sdJwHh0bA0gi0eq1lv4OigGdfImNbFfCA0bfthMGSA9stytrLO42YRQiO/kQ0z/Ydi4bQhUhvdLiDBZ8G5bxo7/L2oG7MHcmkOnG/Uy6GpvYuWxRq6YOXpbK0ugJHYLRB3L5TyXHLg== 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=1K/OcOJj0xS+OemUsGdbff6O7KyYYXNi2+x1OFms8Kc=; b=pxBAfuEZNLgyYKqPREaispQXSBvJdtxbZvimRe5e9NSXL4a1dk0Q+36u5JLoKtccntypW5tQymnz8WAHtj1j1L6GH7kuVjsHw6Qz8eaLZ0iQ2ETvCpvYLiSSE7G/KOL1PGlk8BHQBpW8Ehgr5lYRTEiU+Fn45XSZACd+FVqESwI= 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 PAXPR04MB8783.eurprd04.prod.outlook.com (2603:10a6:102:20e::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.32; Sat, 4 Feb 2023 13:53:29 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6064.032; Sat, 4 Feb 2023 13:53:29 +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 v6 net-next 03/13] net/sched: move struct tc_mqprio_qopt_offload from pkt_cls.h to pkt_sched.h Date: Sat, 4 Feb 2023 15:52:57 +0200 Message-Id: <20230204135307.1036988-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230204135307.1036988-1-vladimir.oltean@nxp.com> References: <20230204135307.1036988-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0141.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7c::13) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB8783:EE_ X-MS-Office365-Filtering-Correlation-Id: 0af186ef-21da-4435-c1bf-08db06b73237 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ud67RPKI8rk6WBAbzh8xiYMQidGmLQiKL4jR9VJAyEgdfwgpy8K8xBvuS0tY1QTB7MvaKNL+2O+VMJefVoB19HlFEKiQzNPLChS24lxwWFiu62Q/LHHijBZs5cpN0MH5GxLUSpQtvqlveJxJHGJ5mkn9IYAQ24pyjFVjsaV6DXWObeCsSbGAhpeckE3TqSuMBSyaXpX4Yo3ifjuWiy3bqJZqhGZ+cabw/eEtwafC0ZOFPMAKDFqWZAlF5VbvTuD30cOYOvRCVxN2MS0zto3sKQRT0CvReWXu8ZHn2rY4fweVyVdiRQq//RIHwZWtl198Uf8SRda1G0Ch49Gy2CI0jhoxn9x5pQyx0Na7665NUd6xQMTxRjrssdwCtWd+5ICqWtXz0llv7teL5ywkUkWDEcTodKWcrSMlQcw0ioZSxaQo/5/fGQ9uwmy4VO4nXyaTWqKpd5CZ6myLTUEaGQbokM64dBuKQyFm13JIJkqYnhLyShkmHO8vtWw6VVDgI4+3MMTL5BRchblVg4CbX87IAb9tPlX2RoRsXM0fy5nOgg8upp9SGfdN+KG/WFf6xAk8KlttfO4Dy/0UImXsbpqxuXZNUuFsYAVzV8/pbnne5njA3DVmaHkMgDKqn20xhB586xN5ivM+r09zaOxHFBcCoyS22oCNbiVuHEtaSn7bECVyndMVjr2SdNKD0aIqemyI 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)(346002)(39860400002)(136003)(396003)(376002)(366004)(451199018)(478600001)(6486002)(2906002)(52116002)(26005)(6512007)(186003)(66476007)(66946007)(6666004)(6506007)(1076003)(41300700001)(8676002)(8936002)(6916009)(66556008)(4326008)(44832011)(7416002)(316002)(5660300002)(54906003)(38100700002)(38350700002)(86362001)(36756003)(83380400001)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: j9V9lkNRi/Uig7ma8mvNpqVqfkK9/e9zbECjw6c7DSafKy0rpXZNHVg0ms1AH7cATaTTlyRvl0ngFtNtFjKuF4fZKxEPVOtx94Q2o63qs0qZfiRX28R6+t85JMnKI5mODyOUa0YwezDprE42XHu+4gTILlWTdqvASdDoOo1nlP16x/wanXYHbKyX2/PAXQt4W0hOUgrCkr4bjvlYswh6gxrzx3+93r23C0uu4pqQSjjEUXbXW4RPnCGp3MpXHOhkEs9XKQuqWbQDxpwi39X8H5KeiZ4NCJfQWL1qF1bMuxkXfJqZtboyqKKyumbJZSTdHE5460uDjh+uHJflerJ9DFNu7aExBWAVhopMpKTihm5k5X94DeeNV4M51tTQcJLGo51wXjyAej7EXxNG6Kz+74NSkpyf7NZ90BksVRBari+VSM8MlJgmlPiHY0mII6PDysnTk9bq7AN+YjzKVSgyz+0frOeDJYpdXNCw/BNK+BY3LOIzSykyaFwh9DcyBgj7HAjKsTtPC2UGbV1BAv7LOk0LjIWgCLM7Bu4gwEUW9n0C67DnPbITz/Gdrc5cKmGGL5uy49V5+ttFxjcmSBSj2vDIScP46I/2W6cjZq83VyROb3E/pDO47+MfGW3XKNEYMyT8wJtE+bJtqGQhra+ZxocFNUN+/Mz9SOW9nEe9/GrJVIV8jlyzK4VggvkMzf4gRd5W7/1HOY9KBieZnu0XNigwfNZnSrAETBsZ+IT9W5/xT/K9IfWlDBrqtnW0VKb869Vz/q8jJKLT8CFud35ammDXhhVKZb8VPvAAeo4+PJKYAYKeJr2RUnN/VQLSS9Ps4SRbZ3OlYycv0HQz83Li2dpYW2jGOORE9Ff3X+fb5hMLJ7eyt2ZnY52tFeXhkaekldfzSwfbekQzd3xETIsSTM2SB3pIlmUWDw4WI62K/iO/34PyXhUd61zkBirEJMXFqbMx1pid9L8DdAzbBIUdE7VN5Gr251+8bCtOOGuz/vQnrGHVHX8crrTRp0DeIIEDwUmwNku4KrWKlEBDie0z8L0XXoFgVR/VlopMaPgoocZDLPCXNPty5pzwtbbiVHj+2PVUZJcfr6md7ZJl0YvpZJuEzfXZg66os+3w3nX5aUlFZl7a1jt4Anh+Ll03cfSYB+zfyGXEfHHKgTiAM6C4Au3sorveo55cjvls7qTzkHt6g+rg7wp/K3RAMwy31iSH8SifvPmj/QXIs8svbWlNBi8ZXmvD/6KXtMx08+hQSvk4f0pLZOl1C4Xkk5TQtx7E6CGCAv0C/XaVaLQbrb7XLwQ/MuF9/a/2U5HnMiePrS5rXEx/7qrgVn7jpMn7jXxQ9JFtl44VRLY2z11GD69EnZiHJVtCqh16w9V2Z0nknWvMZ5nE7+wCRFx/UvlRFktqLF56MxIl6ai0+v6CyoqbEApoFdhPZ8r00i5j14XFpJlgHRX6CH/tCluJoI5xEHRlmCWX3P3ghtA/i+0nPCA0PI+vlQSgFKZD3HsUr3mesjL2rHcNxqLSVB3CFW536CY9hwrMoEvWYg82T/87nGicpHW85ISGXrSNY+caI83fucJ+D3UaODiW8ABONtMx9okXvyE6KPz3FE5pWwp7M5YPcQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0af186ef-21da-4435-c1bf-08db06b73237 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2023 13:53:29.7009 (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: wyWRsmoukipMDoUv0JjD6COqlaGdB+t+itO8wcmMc3u99hxHi/g7MuB0TU4609YBoIXtLsFExdW6SjUzl4m4iA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8783 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->v6: 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 3d26ff4122e0..d684f2a8626d 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 Sat Feb 4 13:52:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13128696 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 85CD7C61DA4 for ; Sat, 4 Feb 2023 13:53:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233864AbjBDNxk (ORCPT ); Sat, 4 Feb 2023 08:53:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233814AbjBDNxg (ORCPT ); Sat, 4 Feb 2023 08:53:36 -0500 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2077.outbound.protection.outlook.com [40.107.20.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1685019F21 for ; Sat, 4 Feb 2023 05:53:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CfDmCTd1xfNDmQHsSuxvBWx5O0RCvNu+Dsiq30IQX4Fvg0+zJxBJn6xh44pRqzbCb2G424xk3m+AMwGM+RelsgDGnl2FVz/jsZ0oI37EQiFd5grsPYTimIS21auz0n/7zVXzentJgU7m8nt/7Iw4OtHPSxHXXSZbXBoj+eZRuIDlVuRWIvmVt1J4BVnXA7gg1fuLAJDqNp1E7VwD3NsLm+1pxgFGajS398n6e0Vu//xe1Uy3afCTcXyLwNCGAByvAEvJ0frN5QchTr1K+HLAJSqiJ5cdbaSw8he3ifu12MgUMkrFLBAw+EFIZfprjHMCXijU+ZiVH85Ck7VUcJL8OQ== 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=WqNc7yQrRO/QSkpmYvhOla8lr8eFwxdEii0A69t/cqQ=; b=Rt107ytTHfal4iva0Emm+FLBQ+cB5Jvq6ZMf7w+mcLhZJqNAqUEnAywTISyXGaa3onDfx7BNKI0xxx57W8BzaQhrJ/DtUtGIYeMmilJGkKWKGCrT6paXRlttHuHKpi7VJHfFeAm0vrAx0caHZA3GWeOCHUm5XDZoc+ssNaEtJToX7Zru54jLJOW0tzM9nn7pf2wc4WzNuT0fC4Bg5RhlJwTvJ9PoPerOfiEORQQU3E8QyPyLxIQMJ1tY+3+FEvKU6m7AbPsgH4rYByRZUuWoTLl6jGwIXL8jncuSbwrrpSm3FOkR9PPPYQ2EWz9KVFK5ZxmqiNsM5C9P+JC36iDdZQ== 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=WqNc7yQrRO/QSkpmYvhOla8lr8eFwxdEii0A69t/cqQ=; b=IwAk5N9ToE7Z1E+wsOl40QwssVAnBm8YmJphP8J5KTCIwOE3jgYVeKwno1/nne0Hs8dCXc/qI4xGCGOX6woA1aAuo9wMxhaY1C20L5RKwhyQ9ZqhEJSYaxtLSLwb84mrIc4/bpXVRhTp8V4gr706PXXJIFrNuEi1v0lz7EXNc9I= 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 PAXPR04MB8783.eurprd04.prod.outlook.com (2603:10a6:102:20e::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.32; Sat, 4 Feb 2023 13:53:31 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6064.032; Sat, 4 Feb 2023 13:53:30 +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 v6 net-next 04/13] net/sched: mqprio: allow reverse TC:TXQ mappings Date: Sat, 4 Feb 2023 15:52:58 +0200 Message-Id: <20230204135307.1036988-5-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230204135307.1036988-1-vladimir.oltean@nxp.com> References: <20230204135307.1036988-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0141.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7c::13) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB8783:EE_ X-MS-Office365-Filtering-Correlation-Id: df161e7e-f200-49bf-2cac-08db06b732e8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Z39NTU+Bu9FUsxVj+japfAQQDr5LrvewnDkzroZVVKO5viT2ajehJGFb+8bVcyaPBto7GFOkX6KcIH/oqCOdoZt+nvZVLDs0063PnGjuYW4C/9F2wJpp4oeMUKKWSJELrZ3WS0JhCTiz0IltaScQSyjrJuoidZCJ06ddha/99qFA28xxYmQd2tXDBMQTgPe/yGv/9CUt5Fe6KKpVHU/jYXy8nz3lo9PDUuUkQEVpEr5fd+llV+rRHjB4eL1gp5kXp6W59y+koEtLn50sHxqd8LzvlVznmwOj4hmagSS3LA118iBc5xeLXB5BNFl/57gJoBNYPW232YBaLkhBYQ/h5ev2aukp+/x2POqq2VaF5MJN7zzI39VLE0yCSl2kIs5WxD8Lphl9u1h82qmu4ZdOHRFRZi6jRCt7giOe7tbQ46Gb+F0Z9y5GWXkJI0EaFZWfIoMQ9sRe4wALKebJ75SGU8Z2uiFk1TP+tvz7BNOsJny/Mh56HE+R+kfNfoGfYavLe5T5Jbh/1CJU7Xujv7P+v1Ld2sZ+ZKXNuTRV2HvWCzviuhXxVCp0OJzmWp1jcikzDNW1SI4dmcyAI9PMQK16LkOHR7Gk8NRZOOVWFdSd+u71f8E/tctxRnVWmKt97i8l/tQnVnHcTUKLX2wNv60F9VvAzAI5afkmsb6rFCq5pY1wyEqgRDA9jM1yXK0BxiNpVAHxNWNxbLaN/qch/5uhF7pvp9xB3j8GcG44/+jhBTTFxXttkJg6UBD3eJfBQqpiDRgCyIGRnNJZJV15VkT8Xg== 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)(346002)(39860400002)(136003)(396003)(376002)(366004)(451199018)(478600001)(966005)(6486002)(2906002)(52116002)(26005)(6512007)(186003)(66476007)(66946007)(6666004)(6506007)(1076003)(41300700001)(8676002)(8936002)(6916009)(66556008)(4326008)(44832011)(7416002)(316002)(5660300002)(54906003)(38100700002)(38350700002)(86362001)(36756003)(83380400001)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pa4HUAsScXq9vU/ggdBdt0tejwA58o78BLbiUDgWnzmbzBxqKbGEBgkLEXl3+sE41bIuVSU93RM+ivFaqG6IiT8LlPzUnxb7BLuubdirMYv6RwhVU9fGtT37ec2S/kzhF2VrOod/6sm23hntNvpxZsoxx+1d9ALE2+gO/00EmGOSDTa3ed7EWz6yGd1FD/Z9aO347GYh0jXutRCfbXAhFfGR2jNbVFwfiich02eMh0LvQoM6gtARJYUKXC+/H0IXN2YR/y7wli/y6HiWItSdoRH3neN6m1iFc+HIK505T3Cp5PGuU8chudTWwVqIktrGuk8mSKbc5Is8lD0MQicALGcj/oA5EMibDBvj3s/hCb5mQZfhNhBY3vs4C373vy2XJ6+LGE1Zrk7JBKPufluf4YOSoUKqUpXhRV50gdGsxGLDmlILmhtcxI+JuwsyEvKCwgnS2Y60ECbP5BjjkiJn49ehR8gmFuKc4OQcCV8HnQOisLMXEM4SNKxAJVwsZEqZzLukM8Az+ki/k782Lepo+iTRPCBWLpmxxJc9y/VtyrBmvEw5U5JLrxAQPiXwaU+z7Rgbu8U2psScsbJvbn4EMpcRH/iDoU1DWPHtDWIK+7Zu18MFUbft9S35cB2ts0MTwnuRR3GyashvcgAWV8NCtvmMemsLZ7B3lPl17m8TmNOum3uh+Rk7Oc0ly84F87yGri8gwl0g4/IDpBSF+qISHReC6B6LWiIPIqXfjz4+JyD7mbmBDL/6zaXZ2qKRvL5Hn+5gm26RzPoBk4SAnPMu8DKmfYi76jk/ahHr9WL/PcYlpABSbzHHzzvIpRfKBczX61RT6CBg0djwhXAlTpzNNkaRzWh70rW0f9pwTYMtVgDsmlV9wTUeCjrwn92QVu57Uw+AUccgzARHobHLQHGhU/OfPXNjrGHboovk1LZcaoySP7Z2p7BktFEDVTwQ4gWGULCYOkkFVUwLlgDRmjU1VaBm6Sr5GMnJeSW2WMC/8CBZCRUv6H0/Gr+HETYT62bHPu5FkkRvANmiRUWAbsxbgN5dAYcc0gVGuxETsVjTiqk0KUl7JJxrssR4pNkFtNnoQOwPmQvFKr1OueOlvdWVq6tMGstA3LOQ8I0EcIFm2FkoE7NHDECzGWlSR/3Nhp0phpTzuQdumzV8+7G2u9SzwEH0GSUyTqCmzaC2JeoYv85GNmwQmi7ZszZOmW+j9in5RZF8R2OBtMC3Iho9gYk7vkYnVusr6bExXZpHiSjsg56MtCI73vBd3sNfAis9YnPV6pu8m5Mbny09hTdgRlUOOvnx5zVaEtXhT40Jw5akT2M8VCjUJKn0zoC7WT/olv/G2O1pxYBcT06l51X26bQ46tsDhrog29tQciDp0c3QWtmpUudz8tBJv2gOqfZ2k1VTfPqnL+jFT370XSmqHnIALHemsgRsvFKHC6vYIlmUYGlE6Hbk/YWnsKfKR3njWgV5lxemSpe+FWGs5QEVx2h5/qiRHS2d5qHc+pBrOXKI2g22PnH2M2nGbVC53qTHL1tjNr/IZF3kN+wsPjVl+Hdls8vQ5l+QtaGSDbuJG7zdjUxGKJR0kFE60W6TjWolbk3TSpzKOUdNAf8wcVtBTdEzUw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: df161e7e-f200-49bf-2cac-08db06b732e8 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2023 13:53:30.9040 (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: W+PKlXb7UgfmNSUOVSa4U5Zr0yiuhZgLZuxxCRO3PFAndhnkkR3SPCPCLU1eL7ouN0Bk3osUicqYqJGs3kAj8Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8783 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 --- v5->v6: none 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 Sat Feb 4 13:52:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13128697 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 73E89C61DA4 for ; Sat, 4 Feb 2023 13:53:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233895AbjBDNxy (ORCPT ); Sat, 4 Feb 2023 08:53:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232230AbjBDNxi (ORCPT ); Sat, 4 Feb 2023 08:53:38 -0500 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2077.outbound.protection.outlook.com [40.107.20.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5201E14EBA for ; Sat, 4 Feb 2023 05:53:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E0niH+tAHiTRks+qpC4CLNkyiLlUtRV+FwPbRVfO9kdGEeTRaJnn0eX8Wz/jejPEM6g5/1RAxZuJ++ILEQlx09Zhd8ZDdTm2mpMU5lMpTtzBPc4xMtRVdKuGCJfMqe2T9c9ADA4Us73baL8pwUmHAfwrhTFBhPClQ7EY2NkB5euPTOw2in6nlPS4lVAmzS44t/rPCrbqXCykxdPQETRqnWnaxD6j/iK7ll8z+SlnULaV9KscTFC3to/aZcX3AnGAXmubOGYuMewaMDIgFJVFTivISz2qXJ/tY/8ApI+XnpN4eQ0e3MMgm2DJGZQBnUPvAw/nhkpQb6i2ESYW8xrlMg== 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=xccDVn1n4vG8BCXayeiGASZGfI/DCNWiZh93zHxuSY4=; b=HNC2kn1Pk8i4HQrCnrH1QtjpQl2cFoOsNt31UaoYmGt/C4ocs9441OBILsnCphViR8dPyCM98d2P0kDGFGZT4uE92rN/C3KOZOlIRiaTI2VlAYD6L8uYTxvTSQK0aNNK8dBHGz/vZ3Kih99M/HwSeK1fNTtJ6C9GAJG4R4MXQJNBQnHZYBYTZPqBvRjQ9EjoQl6+R36OvS+exTw855r2VBuk+tjNuHU5v3p6KrqAhPmBetnQntqKcl1LesEgrVA6kJcXY+MBwUbvHdlzq2UMkgaO1O67MCWAWf9C2yXpl9SqfaNHmsoWAbw/Wnp/GSE3g4mHga1umkuwSdMGQA0xIw== 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=xccDVn1n4vG8BCXayeiGASZGfI/DCNWiZh93zHxuSY4=; b=iui9gxdWts0F6lxc/CxvWLkREu6pVkVnafh+U8p+kxsCU/lFGJ0/dq8nFSUTqv5PAPdKd24L/z2aUzZ+lVms0GolMO/eHJev2UI6Gbhed3/Vh8rspU1wOG4dfLipmQq7JiLlgR2u3WDKeE0QyJuJUZYS5HqcRUjMU/rXYRCrELw= 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 PAXPR04MB8783.eurprd04.prod.outlook.com (2603:10a6:102:20e::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.32; Sat, 4 Feb 2023 13:53:32 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6064.032; Sat, 4 Feb 2023 13:53:32 +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 v6 net-next 05/13] net/sched: mqprio: allow offloading drivers to request queue count validation Date: Sat, 4 Feb 2023 15:52:59 +0200 Message-Id: <20230204135307.1036988-6-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230204135307.1036988-1-vladimir.oltean@nxp.com> References: <20230204135307.1036988-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0141.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7c::13) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB8783:EE_ X-MS-Office365-Filtering-Correlation-Id: 6f32f874-7b95-4f5d-8329-08db06b733a4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XZfmoGKEWwPQ3D7c1jxGiB7ytG9jGvLNjVkuNGrk+aFI5UuMlDInb8VThl3zV/Fv0IF0JfwmaxR8q6uiL8XrEMrtfcbKQ5qFmJUQdeJId2D6PIeyJJwd7Fd4pzdmMp+rRHmrPVdyy2iVG49wRSeWE+bZhDpuJJNIkTOQEaQg52azEFOWBAtHWi0thnNBl8M0pmoAiLPlRSjEaVrsXyMPE9t5DFist2cwOLDplOBqkAKKEFGkf7RaW/44DZHJBdjAZKiXc7q2qqy/ApsAvxF2bd0OrTGifgmOTpgz52uiiJfvXWjxUs1Iyj5clHOLPq7Jlgj78kVO+SMFYv3azNetUp71E6a/d+FdPXy0yKlDYKPLMYPoqpAQivn1F1wVYrn+LDhPvwoY4MOBrjh4twSpiZ8ZFmCfM/+ivOx5QpQKUSQ/UWhZzKxJDAExYhVt8Hj6otw7zg3VxaJjIRYtuLFhn7lr89fiZQdtwNzaNh58Y+J84IyYI9Bs4fdCjC4vbtAy0GjxQEIQXguFl4t0+sfrgMsB6a9pB2bbFtTLjyToABj3LdztctyG5q8lHIKhZ9ErD97Rt6VMqrIa7ALNANmmG7YhX59j0tEqwptiTO2g/9Z38tCqond3IbmftFSaZTgU9xeD0vIa4ZrDGh2RCHmgR02AUwaihjZ5ZO4V1mLIO+C/sUhwBqTCf2iE8K7pBsOcQDpKQMVXNxYSXiqM02twHg== 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)(346002)(39860400002)(136003)(396003)(376002)(366004)(451199018)(478600001)(6486002)(2906002)(52116002)(26005)(6512007)(186003)(66476007)(66946007)(6666004)(6506007)(1076003)(41300700001)(8676002)(8936002)(6916009)(66556008)(4326008)(44832011)(7416002)(316002)(5660300002)(54906003)(38100700002)(38350700002)(86362001)(36756003)(83380400001)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WmIcwk2GKQR3DvmtQaiNIrYYO6UwVdh21TRY082doXP+tip7HAaTOWMl+YI4OQiK5KwtHVZ3YkeDsWpgWqYq8GrU8m+3wWy3M0MkvuqUWnePiGIMX6lovLcm3s+nMdk1yTsAsovIOraOwlg6TlU+IC5TS/mW/otultXYSX8gWZwkLmWs2ZaiJOkQ4dNCkptFoXNq2U7hspynBm86eY5gySt3HCDEiZqOqftlvqRgYDFJOkjEqTLlBfrFXqFksAva4zzUSYX9OjuDZRdULoHARYaDv07VY9JSR65tWef9ShD5WF7kGt7Ui5XwYK5qpuzQpUTLyzmBx4qd8OaLyI3UphvlKpIcexNNEYdih1bdcUE86EAs1DORmrsyYFKUqba+sjYs4wrHj6h6vwLnG2L+zYLyT1y0vE4g8JNvjuwL8oNPIMwEd74aLl1Yiu5uMJtqI1qgl7ILqtWw3Evz4wRzseAEnnlRiBrENnPSfvb0ex+AdabuDtR5C+Fi2mHNM3vIVGucVgGDBeSlQZ2NrxCZNAiBoTd7E6fD+PKoisviAdaV+Ewqr3zYGw8T7GY1tkhQsVxM10RZVK5rqz2olsJDfVlbfoIxGlGcIdTAn0y/UYDsdu3XteyQ945HeZV8yORjuDSrXyNsHIpdgZAKWF1iLIBqe7jHKjuLJOaTFtXLLJ3ouyqFvm/RZtXgw1i04sg0mc0TKgN9X1r5uwGSoms6Xl+8luanYTiXDRwSw8cUw1t9gfmNU/prUoMJqEmn+Q6TvOaR9VV/amiBqxnAE9fRPYpoXtzPzr/BFeQG+SPskM5EdWCaINhhI+PPGITB1XxOkQ/DNf5kEFDgYCKKzuixWQOSUaCJjLL0y6y62+GkrW9r6IGOzhtXgYCTt1F28uvEqhEj2gebQqLPiAN5E2uEMf7K0RW1uL71jDJWn/e9lrtpEp+y3B38fuZtTcBFXhG2BCp89SfgNBpJg5LuazbD2iItCEnkmjfBSGR+ICIP9banLRUJXfT1C6F2j01JacYiYiHl8HPWOvGlVhQ1ZD4sLPnNn9E9r0UMOYdHsbZiqJaUY0Zi35WJ6+Q+YklWMj3ou/GS8K4hmwdYq5v7LiDa+U9e1xsDteTOKK2ay3vnQGoGWkn7aeoGSh9z/T7vsd4mn1BHJ2tFWvakpqPs38BQRucw3sq4yWcPnMnnmPFLC9ySoEEoxBQ+r8K0mh59XOvAKZvLF6/txqpP9i/Pue9FbcKcsdkI/PNQeLdEkt2FPlqsFON4X/8UJIpSQ7BuzhF11/lQg+xq2dVfqlQ+PIdA0NyEQGFvL3/4iWPqvGLOO2rkQOc8thuQ/vfSq/Z9lCljFbN8T87mgZW0LChmygXGu5sVcX8onsG4KILK31YmjQKDDDqxg/FGUnWwZjaJZPAuCnr8OHW5BuUsIlD3IkYG96jqMIG6UPPUytCeLptCD883u1U6ifvX3OnOIQb0F/HORVmxXd1n7ty+afZz+QVTmxUybVMOcgg1qiHYrBcquwCU3H7kjxsTVYx8Zw5qiqmgWRBHmwaqKoFf1YLhFMjgshff0pAD+GaeHfcjEPIwKlOjJRXZO48evJa42JYI7HPw/C5HeCK23UbUljrJHYfoig== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6f32f874-7b95-4f5d-8329-08db06b733a4 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2023 13:53:32.0602 (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: XxKIDhciLyFmBFetNZVQJR3GiGF8YudF8o0Egk2VahBK+iPg2vJxD4a2O6tavPmpRdqSc47PEj+uDpq/W3eAVw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8783 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 --- v5->v6: slightly reword validation comment for clarification purposes 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 | 81 ++++++++++++++++++++++++++--------------- 2 files changed, 56 insertions(+), 29 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..0f04b17588ca 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) @@ -131,35 +161,24 @@ static int mqprio_parse_opt(struct net_device *dev, struct tc_mqprio_qopt *qopt) if (qopt->hw > TC_MQPRIO_HW_OFFLOAD_MAX) qopt->hw = TC_MQPRIO_HW_OFFLOAD_MAX; - /* 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. + /* If hardware offload is requested, we will leave 3 options to the + * device driver: + * - populate the queue counts itself (and ignore what was requested) + * - validate the provided queue counts by itself (and apply them) + * - request queue count validation here (and apply them) */ - 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 +273,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 +292,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 Sat Feb 4 13:53:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13128698 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 6AAD1C636D6 for ; Sat, 4 Feb 2023 13:53:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233907AbjBDNxz (ORCPT ); Sat, 4 Feb 2023 08:53:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233814AbjBDNxw (ORCPT ); Sat, 4 Feb 2023 08:53:52 -0500 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2077.outbound.protection.outlook.com [40.107.20.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49F471E1F5 for ; Sat, 4 Feb 2023 05:53:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UuV84bHMbigvRd8ecCBPdr5d7oKQuzA3egoyb0i80X+/ft+Vzbm9Qwsih8KRdQV3pG50MsXejAjJqPotedBa9a3aq8MyobVadyyn94XhYgdbINolf61CPIMt4EE15EfrErcaZeOMqb1Ll6lOwG5otsFzvU9F19ju18Qj7YWDsS5PoxnYMWk798qT2zcaccD1vDyFPeFuki00JLs5VykApON5N4i0P+ZoB3aeSfRDPm6MdxKatlevJtEW8mUR/RIwVAAeNXaYeiKZZxNfrl/DywLV/dG0z0Y85N+XVTT92E625oNftca+ttf9fidQ0FqwmE7KQ1aTBbBNSaeXiQNOJA== 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=2rMm7sYJETPfWxdLE+G4Xt/rlOvNc7yxfyGcTKQRjSc=; b=fxx/CZC9YfOUSGbm1yAEoR0rSIWqNVWjRNFrUq26DOYW2xk7+iDegFdT1lmOb4ACJg1Z+KvMotC+X0q4xWSWEIPaNjNQveTo4Zr/FsaTFh7vCd7UytCDodlBY3e4SxyZSe8KOsCyfppwRQci0NdEgKmhRQx7mqTnsANilBYNAlF2QZRW7eXSsuF0mCBwDAFWB1rNqnBUQIM64awbaBGAd2JnEjWjGOHtKpop4Ta0BtRZAKserHDa3wKdWVa3Hbh7R3DY2//ql2hogNbKCRX9GCHvpiUyYzFhH5AcaSv4S8z2laGpP+nvqyCJ6n8/VydjIDLMHdeCN9Q3N7VH4vdAww== 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=2rMm7sYJETPfWxdLE+G4Xt/rlOvNc7yxfyGcTKQRjSc=; b=BlUEPgpyfZLO+c/OCTqxo3n5DedLKC4VVlnP4FFWFh620DlKG6yiGyrTFlWzyksYFx2YYmpju7pYrbYf+FFWir8A5QJ/IY0rJlZht1eAmxbOvbDI83CU5MDUh+JdxOg2mYibPIb9jhS8qEb/WpR9feSPfhC+v8WIOuwEc28OnWM= 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 PAXPR04MB8783.eurprd04.prod.outlook.com (2603:10a6:102:20e::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.32; Sat, 4 Feb 2023 13:53:33 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6064.032; Sat, 4 Feb 2023 13:53:33 +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 v6 net-next 06/13] net/sched: mqprio: add extack messages for queue count validation Date: Sat, 4 Feb 2023 15:53:00 +0200 Message-Id: <20230204135307.1036988-7-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230204135307.1036988-1-vladimir.oltean@nxp.com> References: <20230204135307.1036988-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0141.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7c::13) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB8783:EE_ X-MS-Office365-Filtering-Correlation-Id: 6662dbf0-e4e8-4da2-ee06-08db06b73454 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MP0LAnTaJB8sRVTpxy5+bkkLWz3b9WzDvDoP2k14KPPk+VKD35oEPctMy8QuhStZ/Gc4NEllNJiaL2kUdlwV1F0QcvFUmBRihtxyHTmNr3W4xmBiyb5NgxBIsh8WQakKuKn6cavZ3XEl6GDAKSYjxfloyLKeS6L0MvS2P3k8n90mQw6VUSJnjlWt0/3hc43mZajq2F47IOw8TcYSGvdcrDQ1Ux2DaNJgHXSElvd74KBhQDoaiBogbq50B8jsdDwue2j6ccVYoYPtKtf3NBoDKkLYVR9uj6uE21K85Nj7E6TgYevKRQzCQmXP2ZYsd7ht7RKMVpFfYsTAFuG2YO5ZnfYu+QAZgQQSAdddKKlF2wJ4lAtt8Wf54d5eXcycvabo+pgii2zZEP+gzUJezl7s7OYl27CuZw3nA6p1jO8UeJivqzI/y9HeSoAFxMxxh3L90KlkSnEUb00YcBes8Mp98QP3Everayjum7WNRYipAmbxPtJUCY1s8uTktoJFpRbJoWBIu54j+TmAxZhAqzI69KemNYeknErfwapSQndYDBnJ9aOjC6hv8vO9wqyJ5ZD9gF7CkM/ygZZVPh6+H9lwcWEVnTZuJs17rvevIZI+wG/agR2C2P7TeH6l4Y39L9+vVbf/IxozYpH+fkMLWKeDhUCNQQVg7Hy5T9L4iRaoscS94JWtciGd45H+WTd4CTGGLo1R8ySCCKORRy82Og0QZw== 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)(346002)(39860400002)(136003)(396003)(376002)(366004)(451199018)(478600001)(6486002)(2906002)(52116002)(26005)(6512007)(186003)(66476007)(66946007)(6666004)(6506007)(1076003)(41300700001)(8676002)(8936002)(6916009)(66556008)(4326008)(44832011)(15650500001)(7416002)(316002)(5660300002)(54906003)(38100700002)(38350700002)(86362001)(36756003)(83380400001)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: klpPZmu9XDc6EBD5qMbW+7/4eTJBtgBYsdvvNpGt6l/OlyvS7i+pPxRV6BzK6JR6Oxlza0pjB+3u5RSuyvPO7RgrSsicl5zY9mdGV4ktVDk+valiyZNvTilZBm2yqaYiWIoSS5EeYk81otosp+F8gJ9pOvKH+QfmPdADTiviu9uTRKxwoBCNa5fAdK8RqlsCDBLH20U8VjOMW0Uam41EAsPWrJhvxOD55FcpUhDNt7v/18LU6tIBtz1fxNJGR88o4cL7gQnEiy+eWT/WnDCFKoO0WHLLWr/8rA+mLjLEL6YJPw+FPcnkIdQ3FwultLaqgBQTY4RyGcM/9wrNkvukQn+SM7VReTC2RQSZsw6RfNebTFOx9IRLPquo67g0UF+2lOs9rqrXDdqUMPnWWmz3WGp6Nu4QDVFRMfezyXNyuK5sPt0NSv2notPdA3EWNRMIuJGh62A1A4/v4uqZx2bxPW+z6QqdVGrtXPQ4AdMKdr8OZE0vXgegdbvPzP2mPr8d+5yup06ZcDOR9apapjZceq4wx/lha+ZD7OPDTvl8s8xEJcxQkeZH/aOW+/U+CivJ2y/13+pgTJU0ZLR493CE9yjDWMt+/qYJTqtqtKsY3Jt2woHNnzvwXUglxTDx4aWnjf7xH5ZgJFX1GedQ/mAFw9nsupo5lAPUVTRG0i49Ge8unxDOXGxj3WmPnTWHp4UIF/Baz3ZWxcq5fIENxiVNsnCwmyZpyvKm0cHMLnqkMhr0cOBvyLkj+suams0t9pBdZympwTVye4oJokCVGeGMmqHcH+P1d1275Yu6HbT8TAHydnpnokcABODV7gP3eRPjrsUG9/sc7Y0nXgLS1CIw7hLXK7ExtW+YG5ISGn7SWK0x8IywQl5pPjZCT0XcLcbcdm7b7bzoPkngIq1JziTYExCI14qgKn/HB3855dYisrOWOS6OWW5V7THNDegZRkUr225rcXpPLa2XAtqfwFUoeS7w3sQ2fWpcFE2QsJm8KgT57Wl6+DvgFHsOd5atld8xdnu8qLP+1EakzJ/mnscr5YxT8Bchr2RZFYk++P1mVmDDzMzkp0/nBMyfzpZ/CgKPqQjPJ8MaLaSlReiMckYNQwPkA6pyDfQtt2/aRUjOR79iAksnmXdRkPbsCpNuVxBXb9hz5etFmiyLATynPQbLfcgSi8DuhjXPuuR/mczcxQFhTJ4qj+ZqZlnwD4KkH/Ha7qJrbAFwBvnS334N2Rs2D6b3uRkyCcuEgfpXgOXLVyx5AEnq6pAHCX3rrTXOsCnibA3edYT+oXz4qqPNWwBpevsguflyQw8NRtfld8TIp0GEEhYhrhS02JfY1H6Oh+41Le+2sJaIX5twt3p30GWKamWts+vQrK/sNTRL32V+CwRpjfQRxCjNMjKlllfRHldELavbJ+oIHNutm9IdoimUHL9p62JTwkPEDhPmmEL+OJ6/it2fUnGb9e0dDUoAaNaO6nGO1QaNmNVbhk4xvV1wHrjZf5yWg4WYaSTwput85YHBXY92jBH2laQEJLvZwxybweEpjlKefezpV4Hsx9h5BgIJC1CroYGcTFKg/At2vS8L3C7E99WVjB7lGEUkRpezjDaF1BjaG1o16Dql6KZUZw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6662dbf0-e4e8-4da2-ee06-08db06b73454 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2023 13:53:33.3413 (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: sIVuYmp2Iorj0/vI3b5VJZJmcROvyAy9WhkNsCUBoAMc/7sKvocnFseYfsIMJKM4XgiVPyTHAEwwQPJgt5etvw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8783 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 --- v5->v6: none 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 0f04b17588ca..d2a2dc068408 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; @@ -168,7 +186,7 @@ static int mqprio_parse_opt(struct net_device *dev, struct tc_mqprio_qopt *qopt, * - request queue count validation here (and apply them) */ 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; } @@ -296,7 +314,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)); @@ -330,7 +348,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 Sat Feb 4 13:53:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13128700 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 02B00C636D6 for ; Sat, 4 Feb 2023 13:54:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233821AbjBDNyC (ORCPT ); Sat, 4 Feb 2023 08:54:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233143AbjBDNxx (ORCPT ); Sat, 4 Feb 2023 08:53:53 -0500 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2077.outbound.protection.outlook.com [40.107.20.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC8B834037 for ; Sat, 4 Feb 2023 05:53:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mARF21AuQyiWpZ270PqnzF4jJ1bM/EHPdpyFAknNoHz3MSSVom4StN160x5TaWAxqduxZ/cxEed7f0yss+HS++DGgoGHRMifLkAkTNnwsDhe9j/d5uA9tGokyWN6M1EvhlBr5ZRdc0SiV9RIjB9sEmAgOuU/5iVbUI/cRsNHlf2bPSi3T/UP4j3oMdzYKVv1VvgYRYmVm3+/W6RUg/CMO/c/rkDTSnOp0b0+5tUw1YG95wo401wCSsiMq+al0jcfaVulYvryC6ceuVtFZaGKTPnYDSgdiq+d3V1Lm2o7lXEgArqLCkSgfQryanWCVMJNxAwLM+gfJdU16UCd9+FLeA== 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=rSBScky2drnV5xp0ii2dFtv5lhAzk85dvZQu6Ze5Uxo=; b=Arpr1kvYxQm625VoHqZgh3woP5YtK725+D9twhJP1Bw4Pi7fgSeiE6Wi61kmnrRm8YbG0+23/7L/TOn8cRj2QJ4w/yyyhf9R/Dbjq5URgUhSu5V4PYkFmVSUDKyhaqm/IrPOxILUWGP6lKJS5e4ia+dSWKcJNrheNIJSmtl84ZRQGDwm0kUKS4i9wOhUDw3SQzFyMHsXtPpwylQzJWsRBNO4DcaAWYmypVRmxlry2ecpgqqHPeEr7id2dVrFISmOAw3T4cRb59mG1yivmo9m/GFtSxpMY40wi940CvoE5Ek7zd/0NyWJiDACxs+3Y5n8a85kGfsusI6f7ddzSJJ3uw== 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=rSBScky2drnV5xp0ii2dFtv5lhAzk85dvZQu6Ze5Uxo=; b=pozJ1P4YvjRvpbVYxl6/naOM8xC1zbmLdzusWFup40iOMaxYhel8amcPuawbQ/E5atY618NhoOjeGKaKWilpxbpzQr0JHhsJXYZZkQ2xZcNTR6kG23/N8ySQSTRZ9yF9uqceJJb89ikXWWH4oZZ8VJglyXrtpG6Ti2hN7A3SQJg= 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 PAXPR04MB8783.eurprd04.prod.outlook.com (2603:10a6:102:20e::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.32; Sat, 4 Feb 2023 13:53:34 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6064.032; Sat, 4 Feb 2023 13:53:34 +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 v6 net-next 07/13] net/sched: taprio: centralize mqprio qopt validation Date: Sat, 4 Feb 2023 15:53:01 +0200 Message-Id: <20230204135307.1036988-8-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230204135307.1036988-1-vladimir.oltean@nxp.com> References: <20230204135307.1036988-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0141.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7c::13) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB8783:EE_ X-MS-Office365-Filtering-Correlation-Id: 679c1f0e-ec41-4239-4473-08db06b73511 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sQ8ZxBMzFIWznleYsSe8k0g/mHK7VyXU4CZ/lmB1nuzpcVIglq11/fSClr74+cW6RvNQtQKUYx9iKtvU/9v2YSx0y/i8Dp4piwQghrE055J64c5PsrNwyojrTyq8LntM72Wv8MeUCu9IV1QeVJsDGw6rSDZkUdzJD23V1CXh3sryqAMxUvGmfSdyRRbHlWjdwgUZKk3iVuh4mBhu9kBG3jgPIkc5baa6tqo0IOAS1OW3JjDffBk82yRvbUO0tHwkx7ErA9TS0yf5aOV/ZH+ATi/teEQcEk+138lUa6wxI0GJbLfRAh6z7idol52kakgGaI5IlTeRgFoSoZFncU6GFCTwwwdW1XmnVBk7iVZVSJM6eTtHlLkKj5XUln/6XLyfyx/gE+Q2ABeZxeb4emwPLlCYJFSelZZZSFc1rWPD7ms1zG3PJ0tkNkxCBOJ+/pLdV42khUriZwarmr/KlmwxMcDml7fBNMigKxh4Xe3WEcoZRjIIEnLccWyYjJu06xhA0hv9Zx0zHT62IZdZo64e6ZPvtaoI2mcr18kRgSCy3geutzHtIwdvl5dGGTRf7gjcOq2cftZLhZxrrFt13rdHkCEr5GJA8TV3lzs/72G4ZZmosZ3anB92tDcLKMTUrmEmW0FhgwR/lxDLi0fNDKEHploKXGDTMHOvXNPNKiP0WpoOY3y1hr+tpBjcEPjtPZHY1NRueDRXJj3ZpxvfiYni5Q== 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)(346002)(39860400002)(136003)(396003)(376002)(366004)(451199018)(478600001)(6486002)(2906002)(52116002)(26005)(6512007)(186003)(66476007)(66946007)(6666004)(6506007)(1076003)(41300700001)(8676002)(8936002)(6916009)(66556008)(4326008)(44832011)(30864003)(7416002)(316002)(5660300002)(54906003)(38100700002)(38350700002)(86362001)(36756003)(83380400001)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: T6S4a+Sc8pT373k6YiGP5qZraegvu4HZR7VRXQ+rPuoZNko3AUNI8JKJ+b6J4SSSlhvGm+0oza66EGCO7uuRjHMO/EhuQ9dlgEoMLbOSXZCj4biDSss/r7JDg3dVoFlRRXO6XqIKhBsF+d4p92qHmQBUGnLwY6/ZDrgy9yPTyMbp7hPfIF/sFfCym0lee03a8CLmLx6IhmZiwsnYIf6gEsdIIGAFzjwWl8AVUBPomREd4C91PPLiGXXjCS/Z12aC28MSREMxwOT6HjCEP5gqZzEtq2MozqKw5lVyVYVbqeNR9fDAp7F6aqaYYKHGoAiHASRjgNQb+fBqOB2NzvqKK/g/f9G5skcNl8FdwVQUl2JtYjBB33Z9POoHVf9ajHynPQaDkZjJBSnaNRWOfhpyRD/Gc++wBg8+V+qEeDoZedw3mgag8gSKfxBkmhF5qT7JsYpSvyjV9mTJGHB7GgyhqbSzAh7J3gxjU7+Sjsi/doyfHXI5IVfUN/ibucID2rT9cdns275XWbE+0Ze+j2Wpef/+P4rjmcc+Wiet9LTwNth8/63A5sv3nH+JEZODjbOLZ3gW94MhIy5I54IEAQkMMZyIOL6IXLC0YzQ1KTkkaWhGKmJ1r3MOYAvyx8NNW0h5eKx4cdgQcbVLQFicoCblJmESZw4dt2AhXFKYmeqjiLCyXZUPFISfCz9/XnmxNf8f2MM62tJh/nkhf1B71xSSOhJCXZ03Jd9JiMZAcsJuabcjNKN8nO2SA1YE6EAVWptoLZLm2gwCvCtTO486RI7cqwW2RW2T8wnadPIHdrx0q32GmyWmr2NNSr6tdPDPiU+HRUoyA4E221tHMct8E6sE3XssZ/14v0lOtigdsl4NLdX/46NDmt9a7ebe3VWWr6pvgbQh5fsA/u1mPN+JVdmKl0zxTZHYkcZ948um5tDXXlHLVgcu0DyzTKNxUUItenmUApSK/M2fTH1HW2gsMkUPqV/3CGc+pL56uBjES5305OoPBS4yUfUbkofw2vGiyXNSABkQV5SEQravcxn2UNEmpmZhAA+oCGmXipDNJzHuK1E1cBHWMKTjO9ybz/qv86hu/iCuh1z+42OVkNfVF52PrMbyzHTkcfLOuXIgPqPMUiD03J63apC5E0EQVOX1rcSVb6gOkMu5IWakZZoNegSybN7zc3a7T9oT035fEdYf2iUSmyhW2e+IcoUN/lecsAnB7e4pzIUE+66/A3ZgD6CX/TgHQ3HSoJKYep6cSD6LkRKjnFxVFnit9IP6lete+Qf9h+P6PgpUQr8YxeUtWb79n1LOc/Kohx09PbmpYpMv58+9pfrkl9TtJe29TJ+e0MiaFuNQfMK/ntNiEfkQ5LkSG3ZEJgf3aw+gLSDuPdmUVdGVFUPTYMoSiuoKxvvwY0xKokR+HwNBtzlrtnoBriIFiHMke6zBH8SN/pfqsKLHC5gxySM4ze0cYhrVJtMwA4R3uLu/opLR/UtDN4A46hijUK4g+k9G3unHWgOOrpNWZsnF+bw9eVWNJPG6eggNT3bj4CWNW8riPAf0huau+m2dPAvG1P5U9Glt7nbPqTqUYh3gjWGgOtPazkZtfHK1ng0z6OByhTr2ZszpC4bcxN6tTw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 679c1f0e-ec41-4239-4473-08db06b73511 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2023 13:53:34.5444 (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: 3X8aRKzXI7UeYZJ01L10E4JWs/+5JMiWaO3JqpM0sL5AsbExlCIzOVjm6atg+EZhn/TGRLISMfZBznVLNhjUnQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8783 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 Reviewed-by: Simon Horman Reviewed-by: Gerhard Engleder --- v5->v6: - add back lost comment above intervals_overlap() - fix allow_overlapping_txqs being passed as false for txtime-assist 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 | 103 +++++++++++++++++++++++++++++++++++++ net/sched/sch_mqprio_lib.h | 16 ++++++ net/sched/sch_taprio.c | 49 +++--------------- 6 files changed, 143 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 d2a2dc068408..9303d2a1e840 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 @@ -185,11 +124,11 @@ static int mqprio_parse_opt(struct net_device *dev, struct tc_mqprio_qopt *qopt, * - validate the provided queue counts by itself (and apply them) * - request queue count validation here (and apply them) */ - 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..e782b412a000 --- /dev/null +++ b/net/sched/sch_mqprio_lib.c @@ -0,0 +1,103 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include +#include +#include +#include +#include + +#include "sch_mqprio_lib.h" + +/* 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, + 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, + allow_overlapping_txqs, + 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 Sat Feb 4 13:53:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13128702 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 7184BC636D6 for ; Sat, 4 Feb 2023 13:54:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233905AbjBDNyO (ORCPT ); Sat, 4 Feb 2023 08:54:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233911AbjBDNxz (ORCPT ); Sat, 4 Feb 2023 08:53:55 -0500 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2077.outbound.protection.outlook.com [40.107.20.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC60137F29 for ; Sat, 4 Feb 2023 05:53:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VlB8LWUSdk4BNBEsb2D1D/hzJnmbOdxY6qcBdTOBXffPb7ngLnXWAgYtN52ZHN+1wMrZ9OIxTo0rRcsDcVsZlsKsRaQgMyGmouJnwEJY1LaX7ZKQYBnfnHXv9pjew2D4+JHOq2G6GpuwWC3VSKH9wtDRZ0tgnq5e/H6W//jvAJIDiuI0d5BAXHhPgS6xI4Fu1gl7irZaUN55Ve36LH28HjGtSt+0EwAEUi/iuxnsfnP86Xujz5KvmQu07dHkWMDsFV2oP6RIKr0Elh9in6pTGc8Rpi0HDGjYC9JCF3init10VaK21tPGjSY7mBvSzlgEgioN8PisqL6MemnCZ5wACw== 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=j7ph2qvn6Ax/zsgcJ+oe4RoqAv0RrsS8vh/MaNU93YY=; b=cF6RE2i/B9dxnSywwrhtYpuIcLjAOgE5kK+IprdkSSQsUxjPBF6TV4Ym7s/eJjIPa4aTCHxpoFKu3Un9ONASDG/4eIMRZJB2ikf2TN7SpFd6kT+eS0EbUiiGgGQvuiRXj3ODlwATp4hvHB6c/32Dxs8JYpTtBcjgvg05OiCOJ6qeu4SRfsgvSAqjMlQcG9CwaXNr+HoFUwBdG7l69xyQPa3haZ/8s9/QC4y9nf/0qdObWX1wQtu+otmZr6NiQcGcOhkGlyEKu0ho37PApI+oztrHqH2V3sn6/v4Ek+fVaosvSip3jCxNE6qF8/AOgUTDfXze/TihwyWjwrXcg5h1UQ== 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=j7ph2qvn6Ax/zsgcJ+oe4RoqAv0RrsS8vh/MaNU93YY=; b=KIRfrJccTxR4T/wSSsBpi3rb0NiOyBDrV0SSe0Fdzk7xX1WcpxLCY2nePhSvkhEm6PtaOD2ymX+rnfuR9NuIzzOPeVniayNGSasVzL4XpLvqvD1EtgEUSLZlndJYiKicBSn2OxO7FnLsxTfU63mM2dSs2eoBEP3KjUxitJClVC4= 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 PAXPR04MB8783.eurprd04.prod.outlook.com (2603:10a6:102:20e::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.32; Sat, 4 Feb 2023 13:53:35 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6064.032; Sat, 4 Feb 2023 13:53:35 +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 v6 net-next 08/13] net/sched: refactor mqprio qopt reconstruction to a library function Date: Sat, 4 Feb 2023 15:53:02 +0200 Message-Id: <20230204135307.1036988-9-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230204135307.1036988-1-vladimir.oltean@nxp.com> References: <20230204135307.1036988-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0141.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7c::13) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB8783:EE_ X-MS-Office365-Filtering-Correlation-Id: 59eb8fb9-d710-47ca-2419-08db06b735d7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RxVdekRGOjzyecvWxY4lC6XeCovTh8K6MIaE3rt4Dcz4lOPgttAcK3ZdWpXqXpqaRfhbqxrvZVrO0uLHG5mP+oE56yCbfHJGu+DnoqDz0xwcF43xnBoSmUAfyPEHJcM9eC1aEfV9nEzIWZHQzvYJfIvAOijipFtWCl++nswC29IVVWYV+bgRCGvO7XLG2v7exP993fHRVnShlKRTsNN0zELG9Nr5+ZEqgw9mekm8jPHJtrnbtTm/bgAcs4yoP0fDAFv1Hh/XJ3vYg8b2ebvGOB6TOjwlrAT0LgfvhVoGvqIO3c0jCiAQPm/8fAn8KNWRmNRVqiSlQvQTyUb5j9UerL2hjtxS55E/+PuDBsW16uVVtjYS+VsYjQqooPyVhIoO2Qh3aH5jXttkjm+bnq6+M8MSHdWfbI2dnYFp24GkKH9X5bfx8RaejO5K0d/SlXMXqkw6/4vWquxYmi2BlqEfV2MlqTL/Kv0kEGtt2ifqzCskZiAq4TREQ3LGomEtmw7YiOfb46ZeMomrje4CQ6RFIW7U3VTfeFHvte/FW4OkUrxttReplQ4kf3ixTfFWef8d+k2C+NYPHRc9ZeMXbUPVCKdiBV8b1hiOIHZGiToZhVNRobvElyTZotlZgPm1c9IGL6gVtenM6C/4Qi2WDsP1swq+DE+4miaAF527OpC60ly8yALdtR43UAnpF6SXmk+bRa0cwE1IvASh+ePDnhvxRA== 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)(346002)(39860400002)(136003)(396003)(376002)(366004)(451199018)(478600001)(6486002)(2906002)(52116002)(26005)(6512007)(186003)(66476007)(66946007)(6666004)(6506007)(1076003)(41300700001)(8676002)(8936002)(6916009)(66556008)(4326008)(44832011)(7416002)(316002)(5660300002)(54906003)(38100700002)(38350700002)(86362001)(36756003)(83380400001)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cp+uBUwM141r1mB2mDhiupqRNkg57rMOcqtllOGM2KYgKKghe2lHhQnH+FeDHM/nN87Uq/sbQXI+HTQZeIU2xBvpCom6VSlMKshLSWzkQUyF7PjcA1d47MwTDb9uDSlz0RFRG2M1bTimJaZOjoTq9cb+484q1gr5HOP7cKcD+2K8VXOhyZYH1ukpjnVVkRt5PqQR0NFaDHphe4u3+vigg7O+Nt6XBcxTXpo4Wp9DUaIGclRLD96sf2/sxpo7ZXAIVlCoGtZei6OdsTI7GRXF0maoXcbhmv54/hHuTqOkuLgWOjxsELNWogQCxkRYxY3hV2mWXfXtmqp9Qf6hSrlrCJx97p+DvoEtUgpvt8uywfBOXBqsVAEkxl/qkmJ80XIKfGGiR236BBFU/FOmq8kMQ2DnY69ELedDE2LTXfYyjJ2TwUn2TJ6nyFuVvlvMPNk5Fgs5AvP1TSAcZduw7At4APp7Qe2fzRO33tvEkBXbq8yfBRSxpUcUH4pXpCkkKUNDNwifVoD6SOfkOOLZ+6dkpQTiGDUxc1EeeuKkifRjtFLFfcUz1M2qbBKgHD40e9+IJsnI24VeDJo7rk5Pgpy2uCwN2M0/VpNqiE16j76yUpHXW70kkyaDdPp5skrbgdMhUCZQOMiQZyQkWGwhgSOOmddYaOX86gpkHg7wXiohnuhY7419OfP/5fq8teqZSbUfGxImE8mWbqjJLYP9zVB6NFyvUCYwJJBYEDjSwOokchDzuqx8DS95BIYlsNlgRd2EX8deB2CaKZS9eRNLrHORBFMyw9CDKdz0ibGj0ohePp1hgk/gYQH30DCxZ2jS5zRIU5bMqeIxOthMdEfhu7oMl5Ukxxk3HBORjslzTmFUNhDDI9tE9xQe4sYtsvy0TTlw0duUXoAlp0wNDg2BXRZcDKy0IeM8+Pddzgur2Z6nqw8r6eKZnOjbVBZWfug2/FrcIJT4e/pqgwE26ZZbpLiDlVVlxekMw4o1b7LoSDbbJxZCYdZ8pc9S0924BnRym/KxSJt9xn7VGMUvsY0jtgnEl29p7BrmXjvGzhZHaS0ZjO4gj+M5RiPR/hiHnGOBIbnocuDt5kJgKzG5TTJcBZYnrUcXlIFXVNw9CCiuGWX/c/Ntq9ccjjogdjOG5/ge6+nTL4zZg0NJtUtbXSw5AwQYT4BBW1i9HXaxZIMjZWbMfIRH1MRN4HYfYUpAiXqrx47o8Nyjb/wUalZxmB4F1sDDIdj/xRc1iUx3Y8MBsGIpviA1Cc7WbzN8z4bjY+IAW0Jiu10dWT34u8sFVYFEKWuYGIJeYL+xT4pGBHOBciouz1DExs1/WMeywgZLr2APV2fbhEy2iBStP9q9zfI0vngbLYgcpSxNk7734JFk3GC/BDRhg8ShpBenDXVywFFHuGRRzOaMEokB1gF7pq8eQL8TvMOeibRl4s/pO6wweqqNKtRcGZGeVO52ViAXuzuqDZN44EcFdeRZSfELx5A2iVh3qa2Tu4F1lwTqvWju0KjGykPhpsFOkxCKa9ZoSaVFZo0bsgt/HR0ydpAmSnC6NEws5z7pdtSOrMr6d8jgbJzsPGX4EFgjcKh8uRpuKCiyHVhz4udgCOHDDVO3ELqQHLf+Rg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 59eb8fb9-d710-47ca-2419-08db06b735d7 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2023 13:53:35.7474 (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: 9FAjR6Q0M+6pCqWo5WNRK37bteMIJloLDG9irVnTQJ1vQYd5jvb2mAz6vTrkhcVriNFKlfx9HK5yOG57OtMHcQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8783 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 --- v5->v6: none 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 9303d2a1e840..48ed87b91086 100644 --- a/net/sched/sch_mqprio.c +++ b/net/sched/sch_mqprio.c @@ -406,7 +406,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); @@ -430,15 +430,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 e782b412a000..c58a533b8ec5 100644 --- a/net/sched/sch_mqprio_lib.c +++ b/net/sched/sch_mqprio_lib.c @@ -100,4 +100,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 Sat Feb 4 13:53:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13128699 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 4F45DC636CC for ; Sat, 4 Feb 2023 13:54:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230126AbjBDNyA (ORCPT ); Sat, 4 Feb 2023 08:54:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233857AbjBDNxx (ORCPT ); Sat, 4 Feb 2023 08:53:53 -0500 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2073.outbound.protection.outlook.com [40.107.20.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EA172B29F for ; Sat, 4 Feb 2023 05:53:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GrsM3tlAlpsH/BvDOKMfsNqeUt2Hs0nm237xgr7yXg3wAad30xNbMHeF6sR1zOk191HkEJHWspXdAbp3cpbTJjxq1LWGIGJMPcd38K/kO9bnJw4L9OLIABh1/T7i3sFbUz+DWYnAaT/S1YrFfN0sFWIwl/us0Xr6P7efYZLmdm+hI2hGGkNg9kaFno8hyGGTm4sSw4r1JxwAArtI8T4K1yVngIKrEFav+lwrze0R+acAz/LHckZNdOBN9RjK2XOxs8CNSEke6ivknIcO2a+TnZ9Uy9+NDqGtvav2VHIiH95UGKTc5Q/YqZF3PcmmDuUnnxtZYMBP1eEwENcihbsXGQ== 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=nM5373owzpfIS6CkhVu0xYHFFake2BpmMqiTF1R14FE=; b=n5MRg2G6it67PavCtGGx9iNzdZ42/gyBBTY0MYIJKemviiIKWEQf4mlTLUrd1Kzv7jqQChjL+7i3RdcB8uGLfepZakHRg50y/qs1/eKkn0P7HOY3diotgVpbv843mc9LykYGYi60Edtcs1/YlC38B03t/CIURlbiGjNDJg2raWAhdAU4e5u34PPNyOvCDhMg46A6onOUiWN9tUP9QlzAKNM73DRi3Qeb5dC5CCjT7u5LlKILPIlmvv9iz6DtNCkVV1XhU6fYrLMtBzAC3cQRPOVvJPxC6ihStvbbIH7kjYyMLQEHNPtSshxRT5H8vrwuH44peImcmZnPvnNx6HymLA== 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=nM5373owzpfIS6CkhVu0xYHFFake2BpmMqiTF1R14FE=; b=YQfdMzA1S6QHobVXUejLBRZsTupLkCyjs5Tsy+ovWXWrwv9DX6UxVi72vCbNyY/i9ggCo+msLCsB7OtRM49Yw3Ygor2wZZeMaGrtG1UGbcl2r1iL7lZUpXCP26Ye8DNRP+mueb2eSWuOELWA7cmIymR4797PF/w9Ce3DqBtjQyM= 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 AS8PR04MB9047.eurprd04.prod.outlook.com (2603:10a6:20b:442::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.32; Sat, 4 Feb 2023 13:53:37 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6064.032; Sat, 4 Feb 2023 13:53:36 +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 v6 net-next 09/13] net/sched: taprio: pass mqprio queue configuration to ndo_setup_tc() Date: Sat, 4 Feb 2023 15:53:03 +0200 Message-Id: <20230204135307.1036988-10-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230204135307.1036988-1-vladimir.oltean@nxp.com> References: <20230204135307.1036988-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0141.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7c::13) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|AS8PR04MB9047:EE_ X-MS-Office365-Filtering-Correlation-Id: 53ca27a5-602e-48bc-2cb7-08db06b73685 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4MhXUnFZvA5fILCVL3rwKPiy8hwH9Zpa/yXWpxiqQLHsCwAPd8LTi0pDa/tpoBXlEyI0GJ+zTKu3ZVuMUwyK81sc88lYTZ0CIPXV+189bYAaHFKHpH8ES4K9lOZvGEkNnm5XenvV3fMgkq5UDJgmlT9lL6dNEcngwztaj5yFy7NwfdMGqKab4QQA+Tk9g5Q1kz9MWTl3tsTUDsNNNxu0RTZvGOjFTB/sACDmf8Z2ndh2v678gf23U58eWZbl1olGbXmdKYFLjcAY6Dcdga8jbgg0iu7WfpsgvL0Y2bR1h2SB6kcGlUrJfudo3nyGyQ7gAUOMoXd+B8IXPds79xhvAb/9znkmOkXc6HE3s5fDiznX9lvA+ZKml1HYujb8M1qIXHEvZidTtbE9CZjDxp7HI3bu0b3TzG6cgxQuplvYVFlelZ/3fKLmDWZwDvCh0x/e2AhTOFnkG/RxScKKTH+mbvwhOYA415mp53oQx4ZTuTl6Gh5sTWQ3xlhJZqjus+epYn54VqlOoIVfG1bWL4TyKqjmYw+uNP2+RnjNwpliok213RkR3sG1nm2WJIpIN54jsF/pfb5Rabe+eI7wMPO7NCQLfSZld+hRvIP6+Vtq9vjnDQuOviSELxwlzj2KEB7uwdzo/UM9232sbuQV0sIsVprISKK8Mc5PRIxmvINNbX0perrjRamxaJ2k0uyylo5IUyNBn6tX7LaHztieW30Jtg== 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)(396003)(136003)(366004)(39860400002)(346002)(451199018)(86362001)(36756003)(38100700002)(38350700002)(7416002)(41300700001)(4326008)(8676002)(5660300002)(8936002)(6916009)(66476007)(54906003)(316002)(66946007)(66556008)(2906002)(44832011)(2616005)(83380400001)(478600001)(6486002)(52116002)(186003)(26005)(6512007)(6666004)(6506007)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: inZ4mXMVxkBX7tqGW1u0bpY/HvTRmN6O5d6oddoqJNhiGsK8gjhY7UkIWzVsyGNH8fGfAffuLoiEpiRT+0wS78eRVuzblg75InYfrPnGAOLA7e2MoMUW44i8TuDgJsfPFYFC841Ii62KYN46JJGuLlZZbMl+dEO0PnfxI4N8wnpg8uKKG4uy7AyvJ4P17dseJHZJ25+ayYaSrvGgFLvHpXo6TU9q1RSUyqhYFfULR4jukxtaaAlC18ao228mLeF6+EmSWUOAwuky52zK2aJEWkR4VOw8jBqzTmfwFKSy7Mx57iluJFRWMwVGhlfblZRu9BIu7aa7wE2HyNa7UgkWIuXi/ILqvIDoPrcUM/DLwRF6dX0iOReGMgFOElHN+s4PeB2WRFzSrc+t2Hdy/xKpFJc9gNjqOxXrJw02G07Uj9BZMc4zJq984kYXEMsJ1xPz0u3hGdWzN37uwzeI3cLpg8YhF3Sdco9yKypd9OovelsHqW2IrilmPyw1nPIBzfHcERyxEPkwf8OYb04xSbe/vj6vfiexdbk9K+FteQzIQRa7U7cahcOtldMq8aYwlJBze0t9BLw3FP2wa90xW7iVKqostdouuttaIDq8dla205H1SbMMOdBM0GT0by/OjznU9XGqBT9Yt2ZShYAmW7Xz8/0Rsqq6yW/7dNVbdKslzoDmHmzMu/uUJBqX21UY/zvmZvwbUquqsyoF8w1SFi3anEAPrujQBxyAaWrmNQZwmU0S4JV0EIbppRUAs0wjVyaAmjn9plRKr+Kdt83Ma/XeWMYhwq3AmbHYKDdQJK62xBX8HLp/LFJ7ZIxDDpPFFc5iYV6mxqyS1+FBKHMEI4zgakAxIy22zlYvJNM1OeXXMdsTbySYGgtRyCAcgkNVnCLQTf2AnNODul0clVHXxThjUDaGkVeKM109QrqlWQTkKlhvhm8mNNldQ/46FOT6BKS+ZEdS3Ea77Z9JgmtqDQjUYkMCFu9zD1tAT7Glz3NzS+FjCZjmxKxRKghjeBaCaXSemhtti6T5fqgb+AHnisO52QCkzf6OcOesIPv6r/aX7KpHY9O+AOwSXbfd+QNsXYpUFmB15mbZhS+TI5LMtwO6WkD5dJlDnoA5z9H2wrso51ndt11r/ppZ73aUPKfI47sRb10vkE1vksqNX9cQFCMuxUsBzGiHss775yOayHZrOwif24i4s0raOOjmgHHqh8gCF1lYpql4hLfhOq/umVolcNQdcsMZV/diGrnr6SacduHXkWel5O1hUlsdCrOuGaVDojoylutpuLrh5EGj1uaoQH/QrDbLloGT/MBB2ppr9tizmsbSZwP01mobiJ0BJxNk5lroP9gljy4DPPymnH0hvTwR6y+OU/ChIftsE/VrFoZIymP8bA9/asXtcyHWl0ZVmbIFUd21BtQrMX1XsyDDgiJLaG0sqzRcOr/xhEWglwO/BhehBnqEnUYKnS/BSTiTACi2vz6qdVz2HEf7RI9glAUqRv9qtcwp6kCqP2r4wDMj3u7sfSBU8MEp5SrcOAX3uoOa4HixyUBWIS4WWU//XCuZ/qD8JjMH2qv9IfXpFDe0dleQbqR/bsajUtkAUccp3RwPPpjAekkiGljXJzqBTw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 53ca27a5-602e-48bc-2cb7-08db06b73685 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2023 13:53:36.8723 (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: nXqaBlgO3hut9gyoVMQDX738q4qCe7Vw0gqC5avEYcdbiqzKVdIVZ311H0xa6xgJGuFTJClZR3wBYcKUkM7SCQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB9047 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 --- v5->v6: none 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 Sat Feb 4 13:53:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13128701 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 2816AC61DA4 for ; Sat, 4 Feb 2023 13:54:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233870AbjBDNyM (ORCPT ); Sat, 4 Feb 2023 08:54:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231953AbjBDNxz (ORCPT ); Sat, 4 Feb 2023 08:53:55 -0500 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2073.outbound.protection.outlook.com [40.107.20.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F75637B57 for ; Sat, 4 Feb 2023 05:53:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ac8MJcAKJEhtazc/FY2cnlavXlukg3sS3xDUNR56woGS0QrxWoQLpPqJdCjp354MljHm+sn5g6zOJKj4ZymGrmZEn2/De2Am9v7Yh1Tn7CUbE/izMk2ZCkb8T5L2bMCu6Dqg3/3yiw7o5z6W3bgn5blxSGsJdiXMqXle7VIbtIJvTnuPYc1ZAgQX04mXvJjFs7w9niP7xAki885SChVUKNYV7slFv+2FhVtZ6HzXHqA0HJ1ft6GRwiz6AB/0ZZxVBnjvxEjUUK2TILvWBclz8FZhZDOq11gy+PA+zM4uEOklNLHato32T6Mzdk/wNmXjA2fHalNJbq5FlzmbUuD4KA== 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=m41dzHH4A6TZOgJg4yBTTHMYDS0g6S1wm8WWZ/AwGyU=; b=bg29zMtKg4Omd5DD33lGBnPwWCb6YD32rjR6mlTp/gAvR2OEoBTtf5YZr/Z0xW41stp9uDs6Arbnu1xpm9Qo4QA4i4cVMKBiFljdbyiFpRJGt9CmGTr4H0y31RimqmS5mnCRztlF9xkHYKl3v27ztryCbsNjGCnT6lVJ8wgoYBBP5alFDtBqbwV3Mk8kxSrf+l3mKkKmzGhu3YzeXZ8d0fImQeHtUHRPmse4iPXlusFzs1TuvWYVDHNvNG2CXN6jH0BNCUueMgX2R0aIXnd7RIHf8P6/PxDEylgfJW37GOF7Pf/fk+hbBMnWTleEYzPKH4oQ9dfhlyNQXOrlk0i73w== 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=m41dzHH4A6TZOgJg4yBTTHMYDS0g6S1wm8WWZ/AwGyU=; b=qXptIb7Z+KqBoJ1Vt2zd/ul+UqGPAZOZVxk60iPm2ZwIICJQVkcmKwec19FO3LZSkfTE/mLKp1P8gfKTgEkum242ExGRsMDFKoamdSA287jnjM5oln9vO8ZGWL8HPB8rwA7+AFDv34N6IfbDUA5GOMmktsory4Rr+lsPGBxv26U= 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 AS8PR04MB9047.eurprd04.prod.outlook.com (2603:10a6:20b:442::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.32; Sat, 4 Feb 2023 13:53:38 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6064.032; Sat, 4 Feb 2023 13:53:38 +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 v6 net-next 10/13] net/sched: taprio: only pass gate mask per TXQ for igc, stmmac, tsnep, am65_cpsw Date: Sat, 4 Feb 2023 15:53:04 +0200 Message-Id: <20230204135307.1036988-11-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230204135307.1036988-1-vladimir.oltean@nxp.com> References: <20230204135307.1036988-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0141.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7c::13) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|AS8PR04MB9047:EE_ X-MS-Office365-Filtering-Correlation-Id: ee321b3c-c798-43e5-6eb1-08db06b7374d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UX0IKyJoQ86t1b5oKShtmL4i6ErFRzzBsG80W3snqz+S9n6FXrhZ/jworxnL+eiEHBBT5gcrGn3tayauZ7KyDzyPAlU7FNf7Jk7C289bMnVskKe7FR2QtiHya8EJ6FqpFjUGADzpWK9rDNekwxCqNc5TyO5G3B9DLMEnAc+7Ia+IfrhaZ1rHUq8tNQPvXt2ZBZlu/t9Zdejl/MTSD4wXwEpGtfdBR7UBEwQbyTBjy+PB3E5vqwGBoDNdWoBTTYMkgcWf5MTpa7jNBCoNsK3YgZ2QV+9XdyNW4mPtrtXbrg+HkA13XeCAdEKjjQcxLVAxlGmpXPKRwolclGS90ynBasIQ69Vc4zR3tLSNqRtSbI5mkhTejGWLGgM3WjkNAU68K90y8JD4jSQdoXeUxHjR5WHzMaVzJpzJ7uxhU6VOTFwBu0wSt7CKbmuPEaIorb+jFddS6Vg7UjsMo8rRt1mltYSJQtSehemYiymT4yJAPClaQrmyo7nywVG7ACUjrrAKQ1QAZNS7bJisXctsicVhrDcNDhC9DsCefMsrxWNnVsscreDcemWYDNYezgen+4BY5YmPHV4luO4SqUnAoKOEERCNO6aeFqRx3S4NFdLhXAPbMmk9PF+rPR2n42wzCvCH9h2NJYpekyZTkaPvhPp7vlD62HwgMl/B5kWJVKUJ52Gy13Wfi033Ygk8mx1oIQnjI8qYai9ri9gMmvwZUag3Ds77t/E8eDXyJxO8lGxVZLM= 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)(396003)(136003)(366004)(39860400002)(346002)(451199018)(86362001)(36756003)(38100700002)(38350700002)(7416002)(41300700001)(4326008)(8676002)(5660300002)(8936002)(6916009)(66476007)(54906003)(316002)(66946007)(66556008)(2906002)(44832011)(30864003)(2616005)(83380400001)(478600001)(6486002)(966005)(52116002)(186003)(26005)(6512007)(6666004)(6506007)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: JAGSfEXl9/jX2cMXjoLOqMsB++4N0wlbdThU9UhNJF5K+ig9mvKLTk3zWePFqLxSOTC55RUNJzqp86yVFzw+pidTxdeVfJwxQ48+9tqYKBJuwnEIOCWYxD3HDB70SmN80BG8Jsx+r5b6hTUik50HK+uyeRkopeRYg2RdQ41/cH2rmp0vFv9pamSKiFxYOWPpTNWV2pFGtge4YA4hqVe3Ze4yRTgwg3la+MwSfQh5KzOXxIFv3iXePXPwRnBy30aAsv0vZnRtV0QJD7qeMtYDYKvn/Gi6SCAEbqfOVCPYZCgNw4Cpl4+vNzxY3qG3Jr0jiDcn2D4NOESybB5K/9mjIDvzJM8AUFtx7HT9nWbjeqiK19TE2zZYtSw1mgtHYIceOnhIpMpDJ44/YPFusi35PZC+FTHVcQuqo9xF7Gppha1uy4NpDnLaPrC6OG9IvrPDVeGhyUa2xH03bXXidJ1zdIQ3xa+nzlJoMYQP+N9sAtmF9li68Mhty9erOaXu0V4uxLRyxHDiKraVMzBDzd0RHDUrPzVosCLk8Sb8j7e5twK/QJmBeIEBkyynBpPjmhIG5obYULFRPfYHuVuNLdIwszVqetEm9KFHJ5TCrl+gR7CEQLJ5GHfj2RVXyc4TlZ7xWBm79S6op9gK5zxEK1SYlmJNRxnxt1Kk+oOOOZ9TYnvYA7SpadVFug+0L9AwA9bIMTD9r+k7bL0mgoRrbuCJe5SXYvZ9PDen7cjauNGUYSMxWNSeIueIlpFdRFF5E5ZK8v/EhpkyGOdfCYP0rb5SJpsX/YuTvZ5PmHRpc1btXoErilHsh3bAHOccVOiYQCuBT7gp+cbXoikdFcJIW50s2KQB80f6QhgsOsM+op8o/niRc5/eaISMC3wqGUMC+0tSjKLzjJQBpnkM5MdSfYg7N3aKTiiKVLD2lJQAzj46uw17BcQ+QP1FH/X6wJKtymx1BnOzK11YRCIMP76DaxJtVpa9SGsMTqlco45saFd8R6RBvP+uppU2lJXLuC/PM4wsqy+9NSK9uly9wt2ZAG99fERE5Xt1jk5HgCf4kcsv3JQctm6xGLeqGmUAr5iFlwXAUzjzVQ+fOD3mlYe5rt2aixZbtinVrBk+01VrMcNJovQTLIcK4dWq5iztGeiVsOynb2Ugu7fgrl0+qpQDP/4/88s2SU3N8zFLgox8CYCc0TXMAmd4jBRYK/OwV4NFQRWbi4dMXsItW2dlM4iVKlAHY1nPKAsip5Co/Sul1TwITJFFkx+aSpWYv6PNUrgXRUavh8NCEf/6Ni46oe0KsB+XnVsBxDKC3RucYzQBTUSxC0gur8OzMeQr6jWLROl+GK51yAyVmd3ArnSXh9zIiMtVUGoZpcdQEIQmF14smeRLW39i6bTwz+f44NW2MtNJfvwVsRCcvyuPz0t99qhb7MtRQxbm4ZYn2XkmStMFDlmGueCCtPYynlc42/pfk6pRnx41veiLsKi6rTq8cJQQNRsiMVya1nKpFHWBnBQMMckBZGnfCCGfKYKQDkbfArfAo6QsIvumTPN0cdvSUEt7zt3TrFPPfZmMZcwCSNKI62ia+CGSaxBZhz0CPTfq/jwvsVyM2DZDmu+xj5FLZP/G3BSTmA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ee321b3c-c798-43e5-6eb1-08db06b7374d X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2023 13:53:38.2316 (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: Uz523UxHKYUA4yHj7+3pOmiCMim/woB+K3IlYYuT1Y6qrM9a6F74TSvekQzFa0+qxQ2KNax4r7bainn4dT307g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB9047 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. This definitely sounds closer to a per-TC gate mask rather than a per-TXQ one, and TI documentation does seem to recomment an identity mapping between TCs and TXQs. However, Roger Quadros would like to do some testing before making changes, so I'm leaving this driver to operate as it did before, for now. Link with more details at the end. Based on this breakdown, we have 5 drivers with a gate mask per TC and 4 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. Link: https://patchwork.kernel.org/project/netdevbpf/patch/20230202003621.2679603-15-vladimir.oltean@nxp.com/#25193204 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 --- v5->v6: add am65_cpsw to the list of drivers with gate mask per TXQ 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 ++++++++++++++++ drivers/net/ethernet/ti/am65-cpsw-qos.c | 22 ++++++++++++++++++ include/net/pkt_sched.h | 1 + net/sched/sch_taprio.c | 11 ++++++--- 8 files changed, 102 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 6ddcbc8b7b6a..cf7f6a5eea3d 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 1a5b8dab5e9b..f44e4e4b4f16 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -5992,6 +5992,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/drivers/net/ethernet/ti/am65-cpsw-qos.c b/drivers/net/ethernet/ti/am65-cpsw-qos.c index e162771893af..8dc2c3085dcf 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-qos.c +++ b/drivers/net/ethernet/ti/am65-cpsw-qos.c @@ -585,6 +585,26 @@ static int am65_cpsw_setup_taprio(struct net_device *ndev, void *type_data) return am65_cpsw_set_taprio(ndev, type_data); } +static int am65_cpsw_tc_query_caps(struct net_device *ndev, void *type_data) +{ + struct tc_query_caps_base *base = type_data; + + switch (base->type) { + case TC_SETUP_QDISC_TAPRIO: { + struct tc_taprio_caps *caps = base->caps; + + if (!IS_ENABLED(CONFIG_TI_AM65_CPSW_TAS)) + return -EOPNOTSUPP; + + caps->gate_mask_per_txq = true; + + return 0; + } + default: + return -EOPNOTSUPP; + } +} + static int am65_cpsw_qos_clsflower_add_policer(struct am65_cpsw_port *port, struct netlink_ext_ack *extack, struct flow_cls_offload *cls, @@ -765,6 +785,8 @@ int am65_cpsw_qos_ndo_setup_tc(struct net_device *ndev, enum tc_setup_type type, void *type_data) { switch (type) { + case TC_QUERY_CAPS: + return am65_cpsw_tc_query_caps(ndev, type_data); case TC_SETUP_QDISC_TAPRIO: return am65_cpsw_setup_taprio(ndev, type_data); case TC_SETUP_BLOCK: 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 Sat Feb 4 13:53: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: 13128703 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 7A6F7C61DA4 for ; Sat, 4 Feb 2023 13:54:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233924AbjBDNyQ (ORCPT ); Sat, 4 Feb 2023 08:54:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233871AbjBDNx4 (ORCPT ); Sat, 4 Feb 2023 08:53:56 -0500 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2073.outbound.protection.outlook.com [40.107.20.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FA5BAD06 for ; Sat, 4 Feb 2023 05:53:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bEvVJiVegXUhx7EJ4BPDnrO0JA00I0HRscbC+K/m/DO7qqc9ksPqKnbGFEigHFR7Z5jOp0W0NS8ezvJA7CgG0kk46YX8F11Gl6xdNYoylEm85OLhpBZKacottHwnohYrg1ZzTC1vDjrtkcaajBXfBKu208gsOfFSt4SqY7bmYEFGfkgbeCopZvB0lXzpqiFlrMKA90oLr2uVs8azZ+353nP4hhwc5umf+zaR/m2pop43mCutciJVpn1PYuyIthLtGn/dH2+OI8k04bMJfHoA8fVK92OxefWo6InvA/2kfLN9H8vs8u1vsnJeN9xa/km58WTMHOTQEnYTDXfDe8Vsqw== 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=v/uH/sz4RyLoJMk6h9eDuJ6WW/JapGIDIidh4it4K8Q=; b=d/qtqnIaUKC5WAEasrALu6xCvf4hu70h6JCTEpf5GlT8BLnQs+Wx7lm4MbjD8RkSDEtn2OpVGi2Xp0PsCEGapPYBvXUAzYRP9R8yqr8RnAkVNED95RAHvXreKOmDS89y3fLHgYsYaShjxbKGBmLbzaZ+BY73CN/BiMThBwZFWmQK8VfKGYbq2hf588ig+0jY/7SPVMWsYfu3UKPOzaNVrGLDq9A1L+j2WGmx+jH9DPGLcfUGNWmWJvJBw2A2xYFZciSNN8UliaR0xsDX4TcyrbLz+S16tYw72C8WyxUb97Z3XA3ryAiuUw96jvFsYikftMECPNws7GRHKvaNYPf4tg== 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=v/uH/sz4RyLoJMk6h9eDuJ6WW/JapGIDIidh4it4K8Q=; b=eFNmeTwTpJ60FfWa104LSxdCq9q97gWJQaAPP/4iv2wWtRSNRkwlx9n7ZLX7G6DpWoi6tTQ7N+aputEWSLY6t7sbXdoXR9j7ISmQEhxcg7YeFQ0MXfU5avbPd86vcWVzQkXGzYgsf+jPwlatXMvzLNk9jlzVtHCaQ5BWYHX4Kqw= 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 AS8PR04MB9047.eurprd04.prod.outlook.com (2603:10a6:20b:442::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.32; Sat, 4 Feb 2023 13:53:39 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6064.032; Sat, 4 Feb 2023 13:53:39 +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 v6 net-next 11/13] net: enetc: request mqprio to validate the queue counts Date: Sat, 4 Feb 2023 15:53:05 +0200 Message-Id: <20230204135307.1036988-12-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230204135307.1036988-1-vladimir.oltean@nxp.com> References: <20230204135307.1036988-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0141.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7c::13) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|AS8PR04MB9047:EE_ X-MS-Office365-Filtering-Correlation-Id: 6da92379-edb5-4dda-3be6-08db06b73800 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: P6qKR8mMGzASO9MmCF0WxFMpCUPRL7IQo++X46F+Fn6r+Beza1tpLW6xZ2JHZRwoWfr+COCdniYReCougl0UdtYojT5v7wSWfcbIjrk6mSjY8RsExG7Ivjy5eF+QOvmkMuoEsln4gO0tzZTRS/vPQitNx5RRzT2sFU48tT7D+/dURr7F/5g0FO8KSC1x7Q0fnqv899G6svQKKkoaDGhV478KDsMo35YGXfdm9tylMPiB1+Wp4ESiRaYD/PiIwp8rz7eHGwVJpA9qayCkpMx8Ewoa9jMUsU5/99XeIlcVyIuSA38F7/zGC8uJS3aauJVr1ekJ0XWy1bKouoC4uJwNrhkfBIV4YO0VECDb3hPToC8ir4ZZJ+aEJlbHUFha0ZHzRP7o3oUMTH0mQFPStoPNwPH8wPgaWYArD90DxQ6xwLJShHLL8Z2esDZQVglYWfQlE/CBzNPQRjHOovzliRBxOUJmrF/X984CcjtOi084SelErhZh9W/mhqVipG6VAKJecbwfQPLHe1LkKi//rhmBmDZlSjwyPFnuXGEcNTGa9gnbPaAXcsP92Y4zqJ0XTM1FGQheFPURT7/O/D6OH0eYcRQsQ0RqErE75iL5OAkgcNOX2ZP8ciBzmuo4nOFZ6GB9wZ7ZE5Y3RodTnE7jYKQkO6mOX2X3URbdS82/i3kX2K4IW/hqV4Du8ZdYfpExuvd/o5u7FOtKaY5DQQZD1XjqjA== 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)(396003)(136003)(366004)(39860400002)(346002)(451199018)(86362001)(36756003)(38100700002)(38350700002)(7416002)(41300700001)(4326008)(8676002)(5660300002)(8936002)(6916009)(66476007)(54906003)(316002)(66946007)(66556008)(15650500001)(2906002)(44832011)(2616005)(83380400001)(478600001)(6486002)(52116002)(186003)(26005)(6512007)(6666004)(6506007)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /71OYuk3tony00NswhK10DbY2DCKkDGyPxWchFfetxVB3c7qMIabaZ2Bwsbq+zNt3/WMcpVj0gcuHr1/66HWpU97pFaChR4F/gmUyIasYRY5bVe+uZwJOHOYS4XrC5Ox1rteGLDySpmmDFy/tLcXt3Ktpb+RhPH3NVkXpLpWJoItwSigmc2YREG6lFgcvDGhkWEZ+m21w1NEf5v9Qj4347BkfQ9g6cv6d9DpbecKOgqkeXdTiCXZWc3Y10AdOMtaPJrii2U285ehZkP9mg+vrPoxsIli+Mvg5VHiONM2nUwLD/KMjTAqQ7ubzZjN7LhVaJ6dcyGmp7+5cr7povb8glEkyHCMvufTKsdTssQliqP3S1oJEgY/nfNJcV8SZ217bpktzWwR5r8GyBJ/1ehcxPsBQ5SJ3MSgg8GxwajPb5MTawnxUfkYmZLjfdQeCUkntvVB9s7h0Ir31BQlubpx9phBJN9Pr4LgElkDw2RBMPqbccNwGKm9pHq7bFs5YRPHCLsKYOf5YYVhx50HG2VLdm9WPNUSIumhrXzQgA/YGd9oGtrdiXmdP9CYs4dDhy+j0pPauKbumOd8t7eRAg53ZLuImRZir4VUea+cafDtzfAXO8bNzOk2Ibvro3gdJWuB5p/EQy6vrw8nus05URNLOKQ19h4krupGrRMv1B/e2J+YzT7QgclGrqH6XerebSem3UjXCZ44K3qkhdDb1P933uqTT88Sgp5C8uoW3uGC8wOSlvQAthdBNXAPZ6oLbvavJA450u9UF/RTtJbhAqEjFINIMZQEfWeXmFY1SAL01yCfheKV6yKdl4sLk13ouNsqlghGBBWVw0OwD9+gDTHa/ZSdrE+XE1Udaa5/zEDCNzk+ZPeKzrL35pJD8J8FK6c89G8a2xF/lCiCdKWpHPcxxgF3DBCBdqQziSWBqf5e2ThUSXExni6APIWkcYGimB1gO+lCOVPQqX3TPnpA3ch9H3Hh9/Tf9F117vM88OmYN7nj2hD1pJvYs4chfW/gMx+spS+J17CBszzMll8R45YrwnaFaMsSqjDsj1ZQW/XtrLGPinQSw9VcJ12nJcyyxOC0PvdPRucGX9Y6j+dzWSY2qRbBhpx3yfeUtlWsnrd9jRCic8pEX2MwGmXLqGNrjgLFcFGnHIVGvx19PntH8WM8Yo3X46VOiSedvwWEgScfxZrm7sQuJYoJjgpmA2AX33386iRLraj9lqQHSRwfMOw01xnyoguOn9Buayy8vPYnAj6+IGuCZhKuWKwyRGPDLVUSUIubGWPdoC/DEdoqEcO3U7LuZ8O63N4To+j0PyeUnPQXw1BWKBAzJHr48g9BLKkBioeqKaENOFbb6pDERokXXzoKqcmcmxe20xJYLL52NR70o8p6UiDPAzJjVQJfWVKLKFsnOmi0QvJrQo5wTD2kJo4ZnpToWaIyVcONLfj8DMqgTsp4eT2x2UFetMyA5oQ8tC5VR0f8+CZ/iIFqnK+aCieyPN15ej6Ar0D3+CfL7IihBwn3RH6VSMujtcd7Ingi2sOCDglE2V2JntAP0vwpIw01DyNKXR2v1DmgD/neKEYGilOREqgq+Hd/vBSkEVHycj/0/Gz6cTQH/c6x5GudEw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6da92379-edb5-4dda-3be6-08db06b73800 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2023 13:53:39.3253 (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: wMLeHqU/0yZZ3P4W2hOvc/hiTE2wFcbU43m2cSP+edr8lVt88pOpi25ucxtdQrb2AueYRxUuKCgYiiMqNLsqAA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB9047 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 --- v5->v6: none 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 Sat Feb 4 13:53:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13128704 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 D452FC636CC for ; Sat, 4 Feb 2023 13:54:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233143AbjBDNyR (ORCPT ); Sat, 4 Feb 2023 08:54:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233875AbjBDNx6 (ORCPT ); Sat, 4 Feb 2023 08:53:58 -0500 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2073.outbound.protection.outlook.com [40.107.20.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E285314EBA for ; Sat, 4 Feb 2023 05:53:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D2ZxljniJVG4/z05zcdq2wqsHj9ljpMV1Slp+dID45z52broZR+CTImhrej/V0GBh3kvUNO/kQQDRpL7X/bE2eimJSkfT3KGRoup73OmN5fTrqXlsfZ1p8TrMFgzpxKckRB37yBzbKbaMZHfp3PD268+1TmJ7M/a7BcwNL91G399xfKbScP+kV9oasNfRwhcjpvBOaNUjakRcprfBDlqPUiaGCA6WGIPdw3NfMExn3pJxIg/oWK4NeQJ8uxMu62DmX2/6e1CC2txRs44QilF0hr/gXaB0CdkbUyBr8ODdLnu2VAt6DLMbvFJ858DVkegM3ykgtNW3UoRlRTRWufZ4g== 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=XlR235Q8kefiM7iSzRPZA1RXbKfnUPLCCrHtnLNCIH8=; b=dzoIemcash3C6Mp2TkN07tza5hzU4MxYmqJwJ7fR0hV3DfRvlB//9ZbFNx1BqDdM0Sd41sIdLM8d9GgQExEFT1n98vqQqwcXh6u9WKN1/OFObSU3ORv0cq9hJVGvLHRLU8sGTp0av2iHHrAj5u0fRKXjI6JT2FfL8XpEFrOIsdEL2lAZyC7hz7IB6oKdHAWYZ/kV7kqOCiHgFGLISpbSjSJ/SRjw0h0XnqkQ9CdthewP79pJNqXj/lqqRpIBZ0ieME64+VZwl36x3sN5wAM+ZGxhnvhCznIZPGOHqGjey43uI61lbTbBcaGeYbbMsFaRiirgMTtJNK+KJNkD1rcMjA== 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=XlR235Q8kefiM7iSzRPZA1RXbKfnUPLCCrHtnLNCIH8=; b=EQ3yot2NTvdbth7/UDUjMJ5w6cOg4lo6z9lj+GU//bgwKq6km8/fYV/o6wjiplwh9fHjDXkKIj91fAHoAW3nTx0w6xQxYenz/piXtA1I4ecRlCYYR3r9NP+CdXqSCRe8+1k1rCetAIis7nK/NvoISUyNjn2K8mTt1hgjX1ISaoI= 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 AS8PR04MB9047.eurprd04.prod.outlook.com (2603:10a6:20b:442::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.32; Sat, 4 Feb 2023 13:53:40 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6064.032; Sat, 4 Feb 2023 13:53:40 +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 v6 net-next 12/13] net: enetc: act upon the requested mqprio queue configuration Date: Sat, 4 Feb 2023 15:53:06 +0200 Message-Id: <20230204135307.1036988-13-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230204135307.1036988-1-vladimir.oltean@nxp.com> References: <20230204135307.1036988-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0141.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7c::13) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|AS8PR04MB9047:EE_ X-MS-Office365-Filtering-Correlation-Id: 82efffaf-7aa3-471f-58f8-08db06b738a2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: smLjEKVjnGOXByPx+31kxqwE5TD1ZBHfk8IwYRDatKGGgHvtAThqcknCmL/JTUzV8ZVcwgM9fCI3CkervxdQMFEySjPx4IV6gwg63aLqBRa0XZMFH+b3vecELY2ATDiX2fVnX+OdbmKPxG89yMGQEXGTtfAlh0IKRZ3WwHJEs64jJcJsrFlWBDMZAJ+W2vbd/ZDOMJozNgIuXdXuMMA+BQKLw/EQFIIRppOaSMBburE1yyGWuVNZRFXtCpqrDKLRUBRb0ugFmzLuVwgH4GaSNmCLopirQTsfF+r1vRId7kmg+BeUVx/Kziiok/TFddPFzj/ZVn8qlnjHWLTYQbR+l+drHWsvmPnXjlCS6LA+COzuTM6SNWrD0c40c0kgVXACGlfBpCk91q7dLS3wnco7o8Bjb/x8rTxfmGSAmi58BHUzIFnSpxwWThLuuwHn3SI3DFfgBEYIjmQTpwKFUX3AeJGoJiY0plpvIkNPQ4l9J/2VWdJoMAiowJbU8h2OgSaEXJ1FEwfIHjk0IR0vnvfzxLbqnFTLCqw2NGd87k8R0BY82LgdflpOSK/tYBB42ULtIYVaJmjtIsOtl7Xn7Cd2HfQDxgu6hU/wsrUiHlpccVzkfxetNCqnax1ic8Rrwcrx2jJTewahxFQR7TX9BHFceu4l/GCbEGfxFEAsy+NptWN/cCIFWdGAiny7ikpFVjOOedX+heBLav0xHzhiMOVTCQ== 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)(396003)(136003)(366004)(39860400002)(346002)(451199018)(86362001)(36756003)(38100700002)(38350700002)(7416002)(41300700001)(4326008)(8676002)(5660300002)(8936002)(6916009)(66476007)(54906003)(316002)(66946007)(66556008)(2906002)(44832011)(2616005)(83380400001)(478600001)(6486002)(52116002)(186003)(26005)(6512007)(6666004)(6506007)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: a82uHlQF4dyRuy8cPLqe6nO9Tx1ttBHCtNgLMFawg29R8Yhxp8GKynLC1ABAQki2NG9y3C2gekidYaQdj5QoRlhBGvkm/M6I99XPAgD5dz06Uqa64efujHHcKa8J28XywS8HLblcrLXy0QODnFqKplUQfDwatzmach1Jz2/OyUyTnZr7Df2QMHCKdIqMjhH7eabhJ0hwv9Ybknvsp3jvQW1RAQMrYkK7mq7ei3Uu/nrdU4cYE//YXo6wMt4whuNQTOD+nVOnBlj7NAjMUjgZk8L7ocKSlrua79mRbMm4sQ3CDpuU3CMg434PQjfJToNN3sFGx6pz7PyJJZ631uKV9fcTzrcAxMILAiM+kxeaVVGA4DmLOCmoQyAYQJfQZvauHVFF0g3mCi/I76I5JzJ8xNXmpoASicOPw7HCL6ZuHzObt1SJZmhStgMNzB910nBzeJA5+G20B62VGU/LAloUCvdTDYOmwrCJJCgQ4BxMOijS/Eq0Gp/I3NZqrSMm65kTZWoitN+gsdbB0Q8Byb4LUbuDdEiBqbrgT/4dsi7p25RIxM/zS+VTOAclFPOOQjxqlA03lv9mj5j029KIxbATGSCeBRCCDn5fsdVU/NXe1vTZ8Hdkl59MHv6VvbC10HSPyPpkwULrZ6Ce1eIoFyq2E4DM5sYvYkyMmKJ8jolPajuhN7UeFtrdK8GD/gWU/KDYFNG3m6HyJGB3TZWDxohuOfP2Ksx+PuM5B70nVe35FNxzEDuiLdxSAYerK52BzIUcDey3f0jvb1OZ5esWtrxj8I7zTFXScUdR6rd/5jNJ2tFKnnyfNDlc1qnjbOQWDq8q+Fe26XMBYLBvyNKew7IZhdYnONz4v0H33NgXMmW/nm3r6K4Iu87y+Wr6rzCzv4P/71kQrZWA38eGcZMiX9MInllaaL/WprOkWKfQy4wD+uZfhior6mzIbRkpexQDdeAGEDvsB4CnhYM2kseKjbez/Ld9qEx92+e/gDk2HzJ1y2ea+WdAwd4noHwwfFbFFbLjwJ5mvJgi+KhVhCmGnmAPPJ4bujZ6sN+lcwhw3HaYd70Tote3UMlOEts22MI6xJ9/4vwMJxMNWtGlAfNzXTxge2YZkNWf7g7bM6nn+FB+fii59MeiXLGsECBimJlg+ZKXpjV+bNQ/TFsxDbguvGBpE4qUcBBtMvCMIq1lc52+Wrcmu0jADqXI2Dcwia0EDr4SNktHI0eOP7MwVwYF9wNLp452LvnKZYyTpUyLmuSnQMGmI9KS29novXM8G2/JfloLwNQJIAuN1NYA9t4g6OZVH3/E2uOqJfMLlKtiW5gIV4tHisPLHJHHwkRwEWgEDMRe6g2EEwcjHINIC+yr/qin8aG8pA5gR6I/aQxhdqnq2daLJfYAdRLLTxhLzQvKNE4m89tlyC76XiPvGD/VOiHiyRtF7ymvo8JJKD+Lw1vwjip1Lr0otrQKKhQcMA5Lhvd8jbdyHsXgoftI+ICjk3kv+XeydgBnwDU/ZmMFuFtO4wNJoawBUwcfriCl2Qdt58uZcLn7QmhmTd3ea7EJIylXINszpBwxeACyGSZIQD7D+hgJdgDB5TFFnowkNcLC/tA5t2k/ugLa/J3rPXe3ZAe6gw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 82efffaf-7aa3-471f-58f8-08db06b738a2 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2023 13:53:40.4033 (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: EhrN1jv5KwJY4KytFg615S/G7zfPGqt3CMMaWFiehS7Q/Qys+BZIsm8Rge7Sz/Od0JaFYBnv3/2QXMHQEnHblQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB9047 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 --- v5->v6: none 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 Sat Feb 4 13:53: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: 13128705 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 1469AC636D6 for ; Sat, 4 Feb 2023 13:54:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233928AbjBDNyU (ORCPT ); Sat, 4 Feb 2023 08:54:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233803AbjBDNx7 (ORCPT ); Sat, 4 Feb 2023 08:53:59 -0500 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2073.outbound.protection.outlook.com [40.107.20.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0D2936690 for ; Sat, 4 Feb 2023 05:53:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f38xodMpKP8mEyulTudAzWcevdJiXbE5RoGoa73K7AZO75n2ZFXr71TRvBm/GLI1XsgpARDaXgmNIjUO//OhqhPnWlL7fDwgjoMz8a4qusComyFaxDZfZT7sGdDAY8Emqqle4H5La2qMbFchxEoy8Z05zpqK1AuJ55DeLV7QabRXCZSmZhh2uVMPGc0dBBH6+WJgSuMLgACOdg+lcyT/57VLZQ7A4Y2jaJfwH4mkVFflAiZViXPIUvUCPuYCc8/hgAr+SRyQaTOQ45Py72v68bbC38Co4CP4Qrxza6Uty8TmBUa7YK8L6xSpTnQ2fuv+CigAUhFdFuKYfzvooob34g== 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=KWz86TSIWf/nchPE348NiIrhi7d60mgikE0WHGlBhm0=; b=HsRPu6wzKH+dH4mgUImALTdLgojstZsJhWkkZ/Pl165eS62jZL+k12JnVXK62PLRe0V/oGnz6xIeARFZvW66arnP6Pf3lG7PCq94sZgifDRWbJ41rY2loziE4APTYc2w5H1GtzqWZ3Nwg15s1k4/kgfK3JSt2NSteY+g9PqJRkY/Lmbd7PitL1c92Uxt3yFe9F4OYC8lmF8xbtfUMnVBYHL6cPgIJytbM7zEkIw0SuX8T0MYOsy8XqHQKMPJgwYYWeKBh4q7KioxI4GnKirWHAz+NChuUvfRQT8dUNxDT+Z17CVJ/reJjcsFEiC/jAe7nYmhmikVb9AbyR580UqIdQ== 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=KWz86TSIWf/nchPE348NiIrhi7d60mgikE0WHGlBhm0=; b=k9K5wyah6+S8vwc546frESuFRAbsEXv4vr40Sqw6dSM2NwVO+oI4dHLAqgr7quSOvRW3YKxlHVy06JdbIm5NmDeJHI9Da8kO96BfgWWEeSciTRyg9N/o0KpVYpVaxv9nFT9JqXEihmEQNil0CDiDA0R4rlhSKbdFMsX2zBF3e/8= 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 AS8PR04MB9047.eurprd04.prod.outlook.com (2603:10a6:20b:442::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.32; Sat, 4 Feb 2023 13:53:41 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6064.032; Sat, 4 Feb 2023 13:53:41 +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 v6 net-next 13/13] net: enetc: act upon mqprio queue config in taprio offload Date: Sat, 4 Feb 2023 15:53:07 +0200 Message-Id: <20230204135307.1036988-14-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230204135307.1036988-1-vladimir.oltean@nxp.com> References: <20230204135307.1036988-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0141.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7c::13) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|AS8PR04MB9047:EE_ X-MS-Office365-Filtering-Correlation-Id: 98800733-4a27-4a32-3a97-08db06b73949 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hGxscZOjY/XimMgcVwD2Sgk1AiWLQCohzvrKofocEx4lEWhoiKlQxGAaI88l+d7f3zpWZUceB786JLS1ysU3E35bTLFp1T5rjLKicQ/injFRMYUpFb2bEOGWOtbqNqIiO9aHeWGHwu7+MIMwsrslNDnXvwwgRDsJCn6ya+grhActyhgR9JXxWCbysG1Gd5I3NEkOnQwHgxeVxyGa+MKeVy9pmRErkcP7z2O3wrLDuxrDEfiL8Ltwk+oPmoqFW9AQn5RxOcAktEQIADK7sT9OgySgJn5HhwXNiTlNy4L4KOSSV79Wsz/Uv83JuWmo2+tqzm/gsRH++Ut665uIuhREj2C2ZyJ7jiphnZvwQhykH6Xob2PbPSRqwyEsXjBJz/ykKbWGNP0gOjlsMM8zcnf+OP9K9bpX6wfWyDAVFsNCteEKUj4BCr7jKfMrIdwAmXHdX9DqV625OZJp75ZpgA++5v5ovUrtnUV5JAn+SRSGUSH+GvUzx0rhhoUNeCkr9i4h6NQ7cxK5gV+GcqY4HU8ukJXqmicGPH2m65vdjY4ByvBw7VQGqsAezlg/pIRC8Z3EhaItIt5L0jfFd5vItZt3jo7TgewZc6EzIg4f86bUMf+3+3d4TEnCklq37SvgwvWqbVdonAwfe/j7ZPPcqxUkxL9wt3FM9YwF0HBcHPLXlKcMo56irprI0DQhVpxET6CZOv3snd1ndREE5AisAfD5+g== 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)(396003)(136003)(366004)(39860400002)(346002)(451199018)(86362001)(36756003)(38100700002)(38350700002)(7416002)(41300700001)(4326008)(8676002)(5660300002)(8936002)(6916009)(66476007)(54906003)(316002)(66946007)(66556008)(2906002)(44832011)(2616005)(83380400001)(478600001)(6486002)(52116002)(186003)(26005)(6512007)(6666004)(6506007)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: b+IfAVxLNIteS+VSkjGqA8RHkHRAj7EREGS1WqSfxc3SOGZYkSIDYAXsTN7c3ZVL5RfHI1aSay3V/TMV75+T4034p6dStM0iny6DVigz1haUT8sqljz7ZUwIQyeVsdKL/RAq6n5JpLF89aB/17t/9W8SY7BtGqv8ueTxM5d2U3WJ7QK8sa2kOAS3pJxqWwqdlbice2X9NWVd1znNaR+yLYTLHWbvthj+xp6ZOm5L5qYko4DpJ0e6oDF4Of6uYvgBr3HX7zdhxuMHy06fQqr3yNKYdb1uNyBo6RRG3cHXfkgtlGmb6RF89xcSTbwLf0neZnCaEMUe/HYcMMm5EZiJ0/qD2JMH1OTP1BfGdt+rVj6uoLN9tpLiQMbm7yIdHFlJMtp9OZ2zprWWxTb9rumqLJazwegeXGexHQHEDA7tntWymj17acxHxEtKn5ul4vgXorWF1x/6Hen6u2aw5iaONDFa/gOSRGp0KFiA0VsNwmpvOhluQxmpevM6slXs51ABuKmuvdEV42ZfkQyyQu8m5zFBwJ/VjYl9QMPD3gfFjlRgkry6mlzUFqH7ejJ+v5NY2VOapgMTj3PbTBSTZ0Zr51ZsNPKvSAs0X3PGxAk4gDdrZuaRx+HzdaLhj8F8ANSPWu/VRPPjhjCG5hbPaJD1W2xakWzGdFszMWpJvmTTyUYvQicFauNUbe2FxesUvQp/+cr4L1/a80cfhIabVUUK8ULC+WtGmOc6xMihD7sPAWxsFndwsvMnqFbFvGEn1EsXz1Iz1R4+9pk7WaGOdyCOJDCWCtg2n6QJ1o0xgj8pbOavqVUkNLDs1iOjcGcRnMRnd2i5HHsAC3ORSf6wQ+2E6GFWafTjQorvpNRQeK5auak9RLIJcwV2IYZqp+Vh2XaICBx9br1uJxMQXI+wEOHBY2gCqWUI2cAkjx7QhJS0FJFjkDtFzTBoBkSehiF91Ek0M/tR2Jr/Dn1/ge5KP8isdKC0HAE0YG7u5Xs4GP2HOqaSejrDqwxPoEIx3nw7qkI8jMtHa5mAAIxqKX50NtTtIYgeDncNwo5kP+EAwoZzPGlLqhXjjIs5oah+eJOsu2mrQ4Xt5N+l+NSjDSzhJgHXLnew/h8+LYNHbPkQOHIzNFpwJ6uxQJ+YJ5UTFvThfTT82+kDpoZthAZLOFUsY4hha3KKKaVqVi5NjgpukVsrS+v6JFwBBgbJEG/FEqQzwdd4n1LbUoD0ieIhbesc55XSFrnh9f77msfV+TLFnC8cz4YAlMiiF6SLbFGtyylx0N1bsAEDg6m9Qu295yhwFuOD7f19bHuOXhsIdzbZNQp4IThBb9b+q3pAf47Votkn+xpL7w88uypSCzrmOaKn5+8bnd+cwT0t7gKASx5M/OdGCPo1Ro4u/yolpCs2CQEkW2a9SyqmEBDSfUQU8kF6ysWArG3omi/LT6Yuup6BDTCOuBNGquPoJLfzcQva8GyY0LbyshljGr49xnISAXDxKjS6iAJv0f9JDGEgSTmtBSswUGUo9Pnavfq63gEv5sQDpOTbSqyZodLT2HCSDYkwDLqqbuIe5eOaFxkA6WLnVoQNkM2zq2frBrQmG4bOEzX6TZeieqOmg2b3+ogepj9ddJlgtw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 98800733-4a27-4a32-3a97-08db06b73949 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2023 13:53:41.5126 (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: rLzCdlhlSSarxMJBWlES9pn30erS4XfUA8NUohIENRyIeY4nl4bg2E/EuSFgLWxqZiF59E3UjgiW4X2h4W0zlg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB9047 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->v6: 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;