From patchwork Sun Feb 19 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: 13145873 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 E8F61C64EC4 for ; Sun, 19 Feb 2023 13:53:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229837AbjBSNxq (ORCPT ); Sun, 19 Feb 2023 08:53:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229994AbjBSNxo (ORCPT ); Sun, 19 Feb 2023 08:53:44 -0500 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2052.outbound.protection.outlook.com [40.107.104.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DD1910F0; Sun, 19 Feb 2023 05:53:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X2MO8PiPthWBLh6a4SOjb5UZIANTW7KF9s8hcuIM50i4WK5Iqt6L3cbU6hpDQIYPPVN4+Mrlt9JPjw5FZY7VXE5v6jQY9rb4D1sEGX4bQ9NdQmIF7qTmqNNjR7TSLjVosDFh73DLOle1QKgQ4J5Mc8Yd8WNMsAly5FujqM2SB5uXerKWIEwp0HGeA4931cJKZKz3XQQqDYV7JMjmsP6Xg3GrBlpleKc2ejp57BgdglNiBeHiOikTFP/iMs/EHu4iNmKOaEhMH+znphQgpsSrkDizZkLl/Vj7SwZDCsiYLz/eKMWEuiFVXSsYgZv0x01gYGypvmrsWALbZjrS+hyV4w== 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=hl7MclDXQJW4H3dwkVvndquCv9OyPf3JcRdtSaz4Ths=; b=DdSD0lpL5VkK+OzfNDkTfsbrueH1oi/+ZVxJNrNBU/e0jNE5KvA2HDQ1omGhwWdUcjQZ7Tq5Dt0ZHR7mgl4SG6W13hcuJHbepYdo50JmU9YG7wcntZRxTQFm299Vqza2Co+9ETR6U6+BtcS/ZI7zShysCX/LqQVFsIc3ot9QaRVFiG8ml8klYNcIrzYL3fIrg7fOHJ1fpZ41lBrOfE6WBAnFLxz30MailZss9nlAj5eIM88/YQgs8v6XlCJrvvZh5p0r3TjnzXoFqgMm+m8r8WOPBax+fIp/J2zyAW86qjUNqOEAp6uI7+ua8Sy3+WZGjW6Hiv31AfAF5jfDEpD/wg== 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=hl7MclDXQJW4H3dwkVvndquCv9OyPf3JcRdtSaz4Ths=; b=Nd8RFfa2lLb/yA6mWlFo9+CrIdtX5TZoW6SVFRO0tDJtgfU55BzfHGRwuTPvjgpN4yx+qpqS8wBy8IRiNfGGsijctWnLtvfBC7BciRkVS3sZadIowpoQjShsrYnBfJcw361+n/JpqAZuOSd/Ov5P3/GaxY7XlALRn7Gyty/5AA8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by PAXPR04MB8238.eurprd04.prod.outlook.com (2603:10a6:102:1bc::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.17; Sun, 19 Feb 2023 13:53: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.6111.018; Sun, 19 Feb 2023 13:53:41 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vinicius Costa Gomes , Kurt Kanzenbach , Gerhard Engleder , Amritha Nambiar , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , Florian Fainelli , Ferenc Fejes , Xiaoliang Yang , Roger Quadros , Pranavi Somisetty , Harini Katakam , linux-kernel@vger.kernel.org, Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Wong Vee Khee , Michael Sit Wei Hong , Jacob Keller Subject: [PATCH v2 net-next 02/12] net: mscc: ocelot: add support for mqprio offload Date: Sun, 19 Feb 2023 15:52:58 +0200 Message-Id: <20230219135309.594188-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230219135309.594188-1-vladimir.oltean@nxp.com> References: <20230219135309.594188-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0136.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:7c::6) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PAXPR04MB8238:EE_ X-MS-Office365-Filtering-Correlation-Id: 46cde5f2-fa84-405b-0ae3-08db1280b527 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZkXbG9ef/eYAcH1Iut2zpHs/5sj3onXJZBHw4R3A2QFeTKyyZW+6T3cXkgRiW/lFfNC7UzHGow2Tg3K8au8sBX/n/db7DY2vJ4AUfPdU0g2FgsmHbzHYZxj6AAdw9G/pbQYZrcU1eMwcqKNnYQm3WsYy5HURhNQJmEUU82E3A0N+EDCQJrXWJichOCyehYdSfK4TW5Fhq48Jyf0FasXunFfiBBxaA8Spv0qiOboIEacuxaqJO/Dgk2IyQmV78/a7+oqWalxy6gsKrJbhiqpXQpWxDqEUIMazsc2GXKnrElxGpQLDC7Upyxr+kj2OZQUhAkWV5SF4KcdL+EXZFZLgOhsDnqNyMkdWEFONI8C1jRKLhNpSxfStr9/Yff9qBPYjIQM20Zed6wWu0yps7V9jlN9W2RgYxAcqhKoFDCkHpHU0AhKfWjr7F0OyLmfXV3eq+IX0HPz6o3E0YJPmRa64tjYg1bpOSRRokHYSJhB6nQXeWPKz88qzpC8IyRH+47K5/rvQRPXLus7MJWncuOb4iFIC+9beTzXzp4THYpo53MU/Z1IssSY5bOGyqw33Y22RNoqK/aetckbkaBw2gWWMfsp97UWWD2VZXZTJk4Q5wDIyp7TFt0Sx+sB9ZS6B+iMOUiUxQYsgGaVfUVwe7i9SAXDhF8Cm2k5fewOi1767Ch6WPH0nGXh/SsrzM6l4KvQttp2G5K4NscUHN8nfBfDYmQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(396003)(346002)(136003)(39860400002)(366004)(376002)(451199018)(8676002)(66556008)(66946007)(66476007)(5660300002)(7416002)(4326008)(8936002)(41300700001)(6916009)(44832011)(86362001)(38100700002)(38350700002)(6512007)(6666004)(6506007)(186003)(26005)(2616005)(83380400001)(52116002)(6486002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AzZn6mru98YQ939ZHYps2hrRLi4szfa9xhQYpvD8IC1jJsqOs1mZEBtWXiCOAJ+WGZ4Wxg8Z7d2FlTpgd1F8pJcSWRFflZYWkvKjmopFFWrclIvSdHZ2F9cIw62F6aMvTzJIJTei9EbvRiIR4RBm3jen6QzJRoy4n8ayLmf8aNe4syrjjrT9PSSu+flE6E90XzJ7xeuOn+uk194AXuiLOF/+inr0XvFVGPF+4HP2blI4erjjgGtyJ33H6iUukOJ/OOzRFkgq3BxT08a2mKNFJHqGBqc0hSNzeVJQcEHrtNyFVSIU9TQYUNOPNFB7jwh6L60fKHEkZRuzidP3TziVkgkSssUO+KCFvTRhdwkQhDYcA2yzFudo3CobQQugJT/ynAApOKugdlyhXl/uBbnrSzmqc58I/X+XVKoIVptKvSJP8MAmRhMcr9sdHA3Hg5tQvi8eBQddZn4TG65o1iGJtSbw8j/53X7C6hlWFpdRw97BF83mf74woYmIYhFvj/LrLNn6M5/I4rpJeMDFDXzuMFQIuvVbQDoy7xEASe9VgTJ12A1tkamqyyqOexe8wT5tLBJHsunB/RM79mSHCXW0/8vLQFgK232swJEihfXQ8EEnYLvpC5UCrbZHjuVp076nCDsmacBtquUjfGfJ4GJh31QBRDZA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 46cde5f2-fa84-405b-0ae3-08db1280b527 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Feb 2023 13:53:40.9280 (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: t5sjtOhkCTOpNmIJ+tlzZ3nKNBkWshgBHM5aJb1sXWvo785rgi8bHotH7i+L6ZjERx3dLCKM/rAnvbddid9WBg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8238 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This doesn't apply anything to hardware and in general doesn't do anything that the software variant doesn't do, except for checking that there isn't more than 1 TXQ per TC (TXQs for a DSA switch are a dubious concept anyway). The reason we add this is to be able to parse one more field added to struct tc_mqprio_qopt_offload, namely preemptible_tcs. Signed-off-by: Vladimir Oltean --- v1->v2: none drivers/net/dsa/ocelot/felix_vsc9959.c | 9 +++++ drivers/net/ethernet/mscc/ocelot.c | 48 ++++++++++++++++++++++++++ include/soc/mscc/ocelot.h | 4 +++ 3 files changed, 61 insertions(+) diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c index 354aa3dbfde7..3df71444dde1 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -1612,6 +1612,13 @@ static int vsc9959_qos_port_cbs_set(struct dsa_switch *ds, int port, static int vsc9959_qos_query_caps(struct tc_query_caps_base *base) { 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; @@ -1635,6 +1642,8 @@ static int vsc9959_port_setup_tc(struct dsa_switch *ds, int port, return vsc9959_qos_query_caps(type_data); case TC_SETUP_QDISC_TAPRIO: return vsc9959_qos_port_tas_set(ocelot, port, type_data); + case TC_SETUP_QDISC_MQPRIO: + return ocelot_port_mqprio(ocelot, port, type_data); case TC_SETUP_QDISC_CBS: return vsc9959_qos_port_cbs_set(ds, port, type_data); default: diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 08acb7b89086..20557a9c46e6 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include "ocelot.h" #include "ocelot_vcap.h" @@ -2602,6 +2603,53 @@ void ocelot_port_mirror_del(struct ocelot *ocelot, int from, bool ingress) } EXPORT_SYMBOL_GPL(ocelot_port_mirror_del); +static void ocelot_port_reset_mqprio(struct ocelot *ocelot, int port) +{ + struct net_device *dev = ocelot->ops->port_to_netdev(ocelot, port); + + netdev_reset_tc(dev); +} + +int ocelot_port_mqprio(struct ocelot *ocelot, int port, + struct tc_mqprio_qopt_offload *mqprio) +{ + struct net_device *dev = ocelot->ops->port_to_netdev(ocelot, port); + struct tc_mqprio_qopt *qopt = &mqprio->qopt; + int num_tc = qopt->num_tc; + int tc, err; + + if (!num_tc) { + ocelot_port_reset_mqprio(ocelot, port); + return 0; + } + + err = netdev_set_num_tc(dev, num_tc); + if (err) + return err; + + for (tc = 0; tc < num_tc; tc++) { + if (qopt->count[tc] != 1) { + netdev_err(dev, "Only one TXQ per TC supported\n"); + return -EINVAL; + } + + err = netdev_set_tc_queue(dev, tc, 1, qopt->offset[tc]); + if (err) + goto err_reset_tc; + } + + err = netif_set_real_num_tx_queues(dev, num_tc); + if (err) + goto err_reset_tc; + + return 0; + +err_reset_tc: + ocelot_port_reset_mqprio(ocelot, port); + return err; +} +EXPORT_SYMBOL_GPL(ocelot_port_mqprio); + void ocelot_init_port(struct ocelot *ocelot, int port) { struct ocelot_port *ocelot_port = ocelot->ports[port]; diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index 2080879e4134..27ff770a6c53 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -11,6 +11,8 @@ #include #include +struct tc_mqprio_qopt_offload; + /* Port Group IDs (PGID) are masks of destination ports. * * For L2 forwarding, the switch performs 3 lookups in the PGID table for each @@ -1145,6 +1147,8 @@ int ocelot_port_set_mm(struct ocelot *ocelot, int port, struct netlink_ext_ack *extack); int ocelot_port_get_mm(struct ocelot *ocelot, int port, struct ethtool_mm_state *state); +int ocelot_port_mqprio(struct ocelot *ocelot, int port, + struct tc_mqprio_qopt_offload *mqprio); #if IS_ENABLED(CONFIG_BRIDGE_MRP) int ocelot_mrp_add(struct ocelot *ocelot, int port,