From patchwork Mon Aug 7 19:33:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13344841 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AD4F416425 for ; Mon, 7 Aug 2023 19:38:02 +0000 (UTC) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2074.outbound.protection.outlook.com [40.107.104.74]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA93C1726; Mon, 7 Aug 2023 12:37:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Kc0WtwpI6/xuub7DATIUWnq+fCE1U9qULCwZTUrA+10gL37PduChPP+qWgAnv5ZoW91LCgjVvW2qcDYP2SWDFhiBLwRdc5WCOEq+hKN9gG3KmM2IioKPdjya7A2YU5ff5eA/zKdhObHjNO/wuUlLjY0KjEV0PUKjfusmamLxvV45zbwO2Z7NJjAXulxOBizDzWthqfsFifp3/MmKhrohxhgJus5MWEIkClDMy6eH8PqK3SmwBtavSRCV0QE9qaUefCU02ZKGyxQkef4McJfwC/kZf8aoDCiu7BTAazkSfaUZKceQsTnjA4t4Qs4GtDgvGtUu3y8axDCged+oFyj2pw== 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=y8ji/QFNFkYozc1uGEnu/Wm4/4KzmkqxPvEJ7tFXBd4=; b=BWGKPMSHVUr/14K9YPKS+ec9EZxnTymFjzCJ1QivVeFjgunSN2+q20dXTrOZXcT7z2Tpks/WOP8KLOQ1JhfKb2YmpXke17oJmtYEgmCHhBYWVtsMjN+05+ZSh6uWVx8R60fqBQW1j8vlo+3nyuGxIv3xYFd95U1Po7hnUDqEg7r8kIf5CwZ3c6PfNQsbSEQ6Z0RfacjQzHsIgPNawa02KcXB5eiNUD2Yo1GXWSHtcAvAeI9YSpmSGEqQctph2ctr0RBKkLWzBxFTgHIjaiBPLH8ApPKbXt1Q2qdig61E4Nh0+0Tgju9hNFEUxvOWdRhyZ48NycRTC1W2hl1We1WrMA== 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=y8ji/QFNFkYozc1uGEnu/Wm4/4KzmkqxPvEJ7tFXBd4=; b=ebcTyI6TNjTAA98sMU8MIa8SYRM4WRwAO7lBFNPIzShEBGSNA5EnsGV9ngvzBUM8XlUaeTfNSC3O6OV6cRFo0VM8NUI3mZ39MQljvYxWbgPxYwFip4FN08PHL5iNwfFqH10BwQ4k3frpoxQy4XBLhgh+Xu6lS7Jb9z4HCxBv/9I= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by DB9PR04MB9451.eurprd04.prod.outlook.com (2603:10a6:10:368::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.26; Mon, 7 Aug 2023 19:37:33 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::d4ed:20a0:8c0a:d9cf]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::d4ed:20a0:8c0a:d9cf%6]) with mapi id 15.20.6652.026; Mon, 7 Aug 2023 19:37:33 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vinicius Costa Gomes , linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org, Muhammad Husaini Zulkifli , Peilin Ye , Pedro Tammela , Richard Cochran , Zhengchao Shao , Maxim Georgiev Subject: [PATCH v4 net-next 01/11] net/sched: taprio: don't access q->qdiscs[] in unoffloaded mode during attach() Date: Mon, 7 Aug 2023 22:33:14 +0300 Message-Id: <20230807193324.4128292-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807193324.4128292-1-vladimir.oltean@nxp.com> References: <20230807193324.4128292-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR01CA0136.eurprd01.prod.exchangelabs.com (2603:10a6:208:168::41) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|DB9PR04MB9451:EE_ X-MS-Office365-Filtering-Correlation-Id: d8dd46bb-250b-40c0-1ff0-08db977dbf1a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iqWQJ0VxLTfuLjaQZayxo2Wthp6fj35ROpy5h3tG0pEFb0XkJpmyN0/dFP8uearywIgtv2JQ8J6mb0JWA2uNrVAlt3fMsbq558ZXhRm0IMM2OG5dbKunp1pnuo16DZVaJeHtcq1PyfwM3plWT50Npew/iPpENGrU8GUeyWlaEEfu+P0ns6GFMGjpfN7k9wBMrX4oA+heKZ2O+OxAmpcs8BKqeYsu1DdJ2yI/34gQkYMkUIc96eR5vDcDXlFBggMkpxoV6bhPAmerCzG1WjeOu5yFubIxaqkYLGEhHuaID8kxkz19zGOA/+0nFMt/IPULAq0ckwQVV7OE/ZNR5SNsrEK/wj5j1ggbYzC5/sZyGC83f6tFNhys4Xv97NgmTpLdoVwruVTFRvsXQByo8XiKs/rSlQ5zTCqSDuynjMHBb30CIcfJ+l06Icc9jHaFCD8DVI6QxF49DVS1NoA0RzTt4bHbEXGQAnfevYKM5mO+901mtwjPFU4fzjG3ClpKccrBNWS+47ZImJlajXp7AKoRQcTR5D39sLYb5QZYQR5n594fGikf8Kfbq5H8Un0l2Vanc3DE9TLNaBFQEC2XhAbvEHVplI9Q2bxeWJIFXk8lYI/2x1xi3TiXPPMyMG/eNHjN X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(39860400002)(346002)(136003)(396003)(366004)(186006)(1800799003)(451199021)(1076003)(41300700001)(26005)(2906002)(5660300002)(44832011)(83380400001)(7416002)(8676002)(8936002)(2616005)(6916009)(86362001)(316002)(6506007)(54906003)(38350700002)(38100700002)(6486002)(66476007)(66556008)(478600001)(52116002)(66946007)(6666004)(6512007)(4326008)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DrFA0OOR62MxE7N71OdGFnw/q4OZgd1RW2MGAGCfq4Re7EvvGVL6GBSD8hyCVjJ3OnCFixb1BRpuY0+Fu2WHC7NIol66K2ypwsLway57WbvsClww2jedmV/fzO/9537VljXhTMObKJxMj15QAOTOTeqkYuBSEWEpc7bbvZB60ktG5+N3frxtzMwjXJ6nk13C0lwzNgjRpaz4jIIfyIfvQ6zN/9pwKCUj4C+8Qj3/oTCsxkW3riWZjL33k0SCbc4EfGVK7zfKN5MOZjRNL9yHJFP+qQCP5wCBCuc6M9ukV/2tl95YnWxXRDOESAL8Tnp2XYX5LmXL0qjwmMtQKQ0T72zX8MVnAAIwmicVHjU8W5KikfQEWhN5RlN0okfAkveLJ66h07y7EMXCfcKF3orsmUewVjFoBVteFM7vj9tP7ZahhP6iUpQf3txUz4CpNB8FsNoLgIlOVS2Rdh/SbrOSv4jU69AYky7jlE8Vsu/71GU2It4ElEfOlx7nrKlLcN+ZBIjXGkIVSqVcjRU34txaEr8njKxRFCCMFkcdTid0Y4+s4rNuaTSfWiRHiy3/kFZ5G32BgwVYrnBF72KLSyUfA4gPBZm28BiBsemCjrE7+ZmKyg78mUPg1NmTjawIkRaxsvDgtnSO1y1RdAz/gT2I34dQlCa7BNIH/qtUmom3XOfnwGysvjUfZmQ0W443dE6PgeIVbhd0ZXvjRm+W5vFlHq8agj+6omZHNqPcL0kBTq9Hik9qLtIe2jaF3Vl1/ZAsChQOZa+7fX/pjntKJ6IqCKtipUbyzA3c5bnTkCaeJOeQ0j6vuzxWxGI5/IGVx4gBP6PeCM37yD9Yy/Cbmx/LUAW2M+L7WZYLRHYHngaivt0UqD6y2P9RdcXYt9rLfsKZBmOmxwYbzAxQqZkvcKfOBO6PchS5NvdFgeUr6VhurFWq9OlHThkAw0TsRjhu2I4aecakHHISumXhSydEAT5PMw2exDJ182gWIOHGLkhH0veYNmc5jvV9AQeuiue53lQDlzf3Tjikk6V0JdITKK0ewamh5GbBylQgJQdsIIvZq8jeKqtiTKMno0X1WIdmXTsXDDFTPSlg/usLV1TQlwbu5EYXULOVboMaamEjdKsZT27ASZiL26RePncnsfO8piaQN9nnK35XUUTvEqBSaN2F3Z8rKs6XD+8YA7adEfGb5V+KDBPS8mioiGr7vGLZ+V/NdjYEBZALy6wz9ikXZvOQECHxP2diVRJH1z2ZKk3M6CWUoxu6lmCTU9aiMOrZYNboWORpGxZo6QQbQRElo94W5pvqxjdya0qYJuYJKL9wQaZ3u2d7+iG9Q/Dh38AzJxTdUrYf1MdPpjqsW+3oH+gEna+3K9jkB4EuhyEYNS3BUgLAxQNBjSRQbrNDYbbN9F/UurlUaX50hifC2FgZZpjpyUWOROsCItZe5N+l8I/GTZ0HzYsGuMGE2v5s7alWiTA+r8SOaGZIdWu/MSOzXtYn1bi28kFfYkqCfK/TJFxFSFeSeaEtqfa00GGZIEBtWm5vCManOV0r9RhdbH+mpNXe07ZjHLjf3Gj8E6fvjzt7Df0TMr5CdsoIYRTuVzYzhIMlDRo6q2BV8eKMBjBOgvnVyg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d8dd46bb-250b-40c0-1ff0-08db977dbf1a X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2023 19:37:33.7476 (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: JeZeFE8NCAuJggBnu5YNU5KujvjopoW8R/ovFBZikJUCZP4oSwJGCjSoMX/iJ2e4eoJYOUykBJW0aLvoqn822A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9451 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org This is a simple code transformation with no intended behavior change, just to make it absolutely clear that q->qdiscs[] is only attached to the child taprio classes in full offload mode. Right now we use the q->qdiscs[] variable in taprio_attach() for software mode too, but that is quite confusing and avoidable. We use it only to reach the netdev TX queue, but we could as well just use netdev_get_tx_queue() for that. Signed-off-by: Vladimir Oltean --- v1->v4: none net/sched/sch_taprio.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index 8c9cfff7fd05..1cbc7fcd56c0 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -2145,14 +2145,20 @@ static void taprio_attach(struct Qdisc *sch) /* Attach underlying qdisc */ for (ntx = 0; ntx < dev->num_tx_queues; ntx++) { - struct Qdisc *qdisc = q->qdiscs[ntx]; + struct netdev_queue *dev_queue = netdev_get_tx_queue(dev, ntx); struct Qdisc *old; if (FULL_OFFLOAD_IS_ENABLED(q->flags)) { + struct Qdisc *qdisc = q->qdiscs[ntx]; + qdisc->flags |= TCQ_F_ONETXQUEUE | TCQ_F_NOPARENT; - old = dev_graft_qdisc(qdisc->dev_queue, qdisc); + old = dev_graft_qdisc(dev_queue, qdisc); } else { - old = dev_graft_qdisc(qdisc->dev_queue, sch); + /* In software mode, attach the root taprio qdisc + * to all netdev TX queues, so that dev_qdisc_enqueue() + * goes through taprio_enqueue(). + */ + old = dev_graft_qdisc(dev_queue, sch); qdisc_refcount_inc(sch); } if (old) From patchwork Mon Aug 7 19:33:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13344842 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB8D316417 for ; Mon, 7 Aug 2023 19:38:05 +0000 (UTC) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2063.outbound.protection.outlook.com [40.107.104.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0AC6199B; Mon, 7 Aug 2023 12:37:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=idP3zYQUSjq2Y+wERmbFR16kfTQ6Txm23O5lAdzdr3ccMHVzoK37yom255tFNLEQImxN5EWpTQ8VM3QpS+4+ZIz8c8bQVbI84UgMstSk7RnJYPo9cskRY4GOAL8Ep5xzTargUjq9NMo8ZvmPZcoSKbR8r1GSuifc/voUJYpq9nDqUY5p0+beLO88MquLQNOusLeOSODlWYUpp2QRsvdOsz+YZKzvYdwO7H5LSfq5qoUhR+hNiTWoGwZTFX/FS8ugKFIwHIWj/lOw/OF3AQpAAWPfG06N2lANWGi8dg3GTmS56/EjDfodzl+p9mLsEswTSx1AHuMjZfqS0vkBAu/9nQ== 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=TLrUkw55ki6hrR4d8Q6Vef9ZHs/RcJuIxgE/ZmBSc7A=; b=ApZ2CsbqHetmXt6vo3Pi+TQtnUCOIogtYr7hTGE38/BEEqtq292vfnddgoPUHNW5RmX4N3C98phClgB3RKw7uYeFbJyHTsj3HDOOovMHKEqmIiawiXGE5abB8eaxqddbel3EsTArb2BlukVLz0gL7j2Z87WkS05PdWgcI/mjWBSShrkyzQk/3xLBZbTMDgFiGVhroAbTZ/8obgRfsRrMWKYLRM/H6bwelKRts52xMtwwXOa4ljRfom7dJ6OXFB2z8W/FFhgYiKEC6jZuKJUA9Us3rW9Ls4DGNVYbLkrs4fl9KthdYBeIQVvqSZzKn9cbFsK2j21Netyonwl5MaY5Qg== 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=TLrUkw55ki6hrR4d8Q6Vef9ZHs/RcJuIxgE/ZmBSc7A=; b=YpgyiGFH64BYHn78eUchfdOYmXmTaYIBYB56jjtc49MyynXGx4VIU9+FCDVK150mla+zRRimwcJgbYp1grJEwvCcztrqtjPoXXIf8R9DW1WZDLuUJ2YHHhnXht5oRHb0LcPKCtfo+oPrWQAuqHnPK4GEqCjZihfD9gY/qqbHHCY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by DB9PR04MB9451.eurprd04.prod.outlook.com (2603:10a6:10:368::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.26; Mon, 7 Aug 2023 19:37:35 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::d4ed:20a0:8c0a:d9cf]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::d4ed:20a0:8c0a:d9cf%6]) with mapi id 15.20.6652.026; Mon, 7 Aug 2023 19:37:34 +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 , linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org, Muhammad Husaini Zulkifli , Peilin Ye , Pedro Tammela , Richard Cochran , Zhengchao Shao , Maxim Georgiev Subject: [PATCH v4 net-next 02/11] net/sched: taprio: keep child Qdisc refcount elevated at 2 in offload mode Date: Mon, 7 Aug 2023 22:33:15 +0300 Message-Id: <20230807193324.4128292-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807193324.4128292-1-vladimir.oltean@nxp.com> References: <20230807193324.4128292-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR01CA0136.eurprd01.prod.exchangelabs.com (2603:10a6:208:168::41) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|DB9PR04MB9451:EE_ X-MS-Office365-Filtering-Correlation-Id: 94970e8b-63a2-403b-296d-08db977dbfc8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +BwNYeZUpM6ahbN8YW+CJ89CMccOqZB8e547Fai7VfILfrMIDfEQoqNav4v2KA8RcmncZuWFk3slZpKg9jIwY3RqEoc/k5Sc388l/3NtI/uNbJzrmFhoxs8MGvl4bl+dIH3Y6tFaoO0Oa0gWQrqNHQLBPRH3cDCIigu78IT+b9mUnh3aYxz8cgpy9D9O+gxbZixjE7Bl9oeB7z1EUpYRSInK5Al2/WSbUF7nxm8MsLb6aZ3Yrf/Oar/+tMHfH29ZHGpDEaydalRqntntF1FQBqaYOhXFetYqgRgh/Sp7rzJwJ5lCbY7NBEeXlQIub4YjG4vFid3/SewxDhvEeXiTtTaSHLEsV+0D/g89si0LEj0I6YDxYW8PZVeN98jcmyLNAmZKnab7W/YCC/LCtwQVBPQyYePTG5xEBOn2Wfy2+1CoO+t8sEiEJR+b7rWEFUcuPqs+buvrkbTg54c/KGpXoIuFj6yr22wCaaL3I2ndq/NonzbtoOKtrkykj9ihUiu4t2Er9EWQ8VQOq6moB87girM2SZGc0VGK22FNDerPQkr9gpFXljpgcOg1dZom5gl73LzYMJO0V6fk1sAr5ubRi5GFu6Pk8dlEIjOdXidk4qE8QUpg0yGqiCFE9r+9vv/n X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(39860400002)(346002)(136003)(396003)(366004)(186006)(1800799003)(451199021)(1076003)(41300700001)(26005)(2906002)(5660300002)(44832011)(83380400001)(7416002)(8676002)(8936002)(2616005)(6916009)(86362001)(316002)(6506007)(54906003)(38350700002)(38100700002)(6486002)(66476007)(66556008)(478600001)(52116002)(66946007)(6666004)(6512007)(4326008)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rExyUs2J32Z8mT0/vfFjVjvNWIppMwlb4ZHKQmccNyWvfp8aX8CQjt5JtliKuDyYGa7zaWIX7yWWbQn26TW3b6qt6yQJy/2rxAsXBPdgoqqIC6eh1jMEd7unkzA669nG6WFm572+vQhTXQG4ufg/M39zBDee58E0VJxzkV65YiMyU+0ArcSla2BvbnQWIXDJa8pYIqpJkUHxIf/wjuPdCP4XLSazBa5N2DnrpLdaL0tkIS53jrqwd+qwre6FfqwwaV77EpUDlKv5/o1SeJ047AAa4+tS7uQ5CORDWLmKh3wKGFa3ByLuFkjoXqay7fN2hIjqsGvHKzeFB+/eLAlrMAOBu21lVJg9gkexeMAdx+/qZcgt7uWpaIkHGXp8Fa79uUoorp+D4hMNdEwH7lZLbCpiLztHR46jeEy5JMNWknuK7bjSkzkYftgQJfxXjAXanFxp9wf+R65d2cAOzK6SmFeFIsHxftbvjGahC48NWykcyhqCCVMe9S3EYX3LsVmhKnipUh6O6h9NACzl8MSRzjZuzQYwmOJ6lhIkUrjOUOJTx16Gpd4oYv3CZdTTE/mEZ61L7NziNr5RneVeGmT4VAADOlG1PC45GP6QqToyHbm7+Fzn7IDJnnAErHWJPzq5hhTahL8FIFtdAFeXjmcBJ5MOMAxLT6lawHD6wARPiB2WA5Y/bBL3rIcLAoZ0eWgtlHTso0+CzRA/farRmKXaptKSrwS69dVot2DaycnvdLk59K3fGHvfw45eRthT2yKV2OClAP9mNBgsnpGrx2TRFQ/wGFmTmvLB/oGaggfEYGOgG01wjoE409jPTPgm5UB2AdltNHvbhT5dDES5FqFOzWLN8NiXLT/w356nqO4d4AmPzsVvZwAlt0eigE6IDF3/VXoN+l5WJo/X/zLu4bgpq0vr3YHg69zySKwfcvSeKnwGYTzYq/dH/PabsQDlctf5R1LagN0z+A7SkDah+//CpwTLJ8PvfB8S6egxNiLpqIx4tPXlR7czqbESeDk7/glgYgPpGeOMroKpEdRa4/rFcTdbIi0vM5M1Hug1q9/8GQH+peRaFY8qp0C1CynhKZVjn/Zk3awj9zL52HOMmcHsI8TwLBFsv+n9+rylzSPAZAG7OnYHRk7FMDMhUmKrA14ncnAQK+Gt2n0+LfNrBUp1WDnhZm4eZHihd8ina7IgTGMUWG2FstOgzzKf9/UXDQqFs0AoX5U0UQBup61xauUhltWxTdB/O+kKJSMzkfbXImAW7vNaIkUJb5hm8+j9+ThkEvQgHqq39V4buhyUEa2DOIkq6gVFaP/3d5H8ubiMuensaeOFdnT8puyW7Fov2zHBI9v7lRA0BO565TTC/knpZxmQrB3yJjoLrxwaXtwVSYuCGMcB6uwqmC9Pmu5G36fIQDC4YNgpZs57nz8By845g4LGTOS9qICPF1FrY0FKdFXHNYhakDmVX0ChadiE/qEgfgQcgxxkA/E1sv2UlGsDPxzuY7bw38REBnVtlE+megJ0MqsryBLYiNVZ0QrEYDWdwNgCeLQ1cymlI302dpwaPq1C+y9hSSZaRAZR6VStinW7RP43EPrhuVtO86Y1tHTiRWy/0bK28MvoNfT/KftKfg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 94970e8b-63a2-403b-296d-08db977dbfc8 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2023 19:37:34.8762 (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: P4tTKBA01Bg0pGjMm0BBRfnTZ74XoeHRbcOWEkIeFw4W0vCkx5zuvDUV/jmS+cCgJInjuEMRMBymsxvdhUQz8g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9451 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Normally, Qdiscs have one reference on them held by their owner and one held for each TXQ to which they are attached, however this is not the case with the children of an offloaded taprio. Instead, the taprio qdisc currently lives in the following fragile equilibrium. In the software scheduling case, taprio attaches itself (the root Qdisc) to all TXQs, thus having a refcount of 1 + the number of TX queues. In this mode, the q->qdiscs[] children are not visible directly to the Qdisc API. The lifetime of the Qdiscs from this private array lasts until qdisc_destroy() -> taprio_destroy(). In the fully offloaded case, the root taprio has a refcount of 1, and all child q->qdiscs[] also have a refcount of 1. The child q->qdiscs[] are attached to the netdev TXQs directly and thus are visible to the Qdisc API, however taprio loses a reference to them very early - during qdisc_graft(parent==NULL) -> taprio_attach(). At that time, taprio frees the q->qdiscs[] array to not leak memory, but interestingly, it does not release a reference on these qdiscs because it doesn't effectively own them - they are created by taprio but owned by the Qdisc core, and will be freed by qdisc_graft(parent==NULL, new==NULL) -> qdisc_put(old) when the Qdisc is deleted or when the child Qdisc is replaced with something else. My interest is to change this equilibrium such that taprio also owns a reference on the q->qdiscs[] child Qdiscs for the lifetime of the root Qdisc, including in full offload mode. I want this because I would like taprio_leaf(), taprio_dump_class(), taprio_dump_class_stats() to have insight into q->qdiscs[] for the software scheduling mode - currently they look at dev_queue->qdisc_sleeping, which is, as mentioned, the same as the root taprio. The following set of changes is necessary: - don't free q->qdiscs[] early in taprio_attach(), free it late in taprio_destroy() for consistency with software mode. But: - currently that's not possible, because taprio doesn't own a reference on q->qdiscs[]. So hold that reference - once during the initial attach() and once during subsequent graft() calls when the child is changed. - always keep track of the current child in q->qdiscs[], even for full offload mode, so that we free in taprio_destroy() what we should, and not something stale. Signed-off-by: Vladimir Oltean --- v2->v4: none v1->v2: - fix refcount not dropping to 0 after a graft operation - spotted by Paolo - slightly reword commit message and comments net/sched/sch_taprio.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index 1cbc7fcd56c0..7c1fc3dc3e55 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -2146,30 +2146,31 @@ static void taprio_attach(struct Qdisc *sch) /* Attach underlying qdisc */ for (ntx = 0; ntx < dev->num_tx_queues; ntx++) { struct netdev_queue *dev_queue = netdev_get_tx_queue(dev, ntx); - struct Qdisc *old; + struct Qdisc *old, *dev_queue_qdisc; if (FULL_OFFLOAD_IS_ENABLED(q->flags)) { struct Qdisc *qdisc = q->qdiscs[ntx]; + /* In offload mode, the root taprio qdisc is bypassed + * and the netdev TX queues see the children directly + */ qdisc->flags |= TCQ_F_ONETXQUEUE | TCQ_F_NOPARENT; - old = dev_graft_qdisc(dev_queue, qdisc); + dev_queue_qdisc = qdisc; } else { /* In software mode, attach the root taprio qdisc * to all netdev TX queues, so that dev_qdisc_enqueue() * goes through taprio_enqueue(). */ - old = dev_graft_qdisc(dev_queue, sch); - qdisc_refcount_inc(sch); + dev_queue_qdisc = sch; } + old = dev_graft_qdisc(dev_queue, dev_queue_qdisc); + /* The qdisc's refcount requires to be elevated once + * for each netdev TX queue it is grafted onto + */ + qdisc_refcount_inc(dev_queue_qdisc); if (old) qdisc_put(old); } - - /* access to the child qdiscs is not needed in offload mode */ - if (FULL_OFFLOAD_IS_ENABLED(q->flags)) { - kfree(q->qdiscs); - q->qdiscs = NULL; - } } static struct netdev_queue *taprio_queue_get(struct Qdisc *sch, @@ -2198,13 +2199,23 @@ static int taprio_graft(struct Qdisc *sch, unsigned long cl, if (dev->flags & IFF_UP) dev_deactivate(dev); + /* In offload mode, the child Qdisc is directly attached to the netdev + * TX queue, and thus, we need to keep its refcount elevated in order + * to counteract qdisc_graft()'s call to qdisc_put() once per TX queue. + * However, save the reference to the new qdisc in the private array in + * both software and offload cases, to have an up-to-date reference to + * our children. + */ + *old = q->qdiscs[cl - 1]; if (FULL_OFFLOAD_IS_ENABLED(q->flags)) { - *old = dev_graft_qdisc(dev_queue, new); - } else { - *old = q->qdiscs[cl - 1]; - q->qdiscs[cl - 1] = new; + WARN_ON_ONCE(dev_graft_qdisc(dev_queue, new) != *old); + if (new) + qdisc_refcount_inc(new); + if (*old) + qdisc_put(*old); } + q->qdiscs[cl - 1] = new; if (new) new->flags |= TCQ_F_ONETXQUEUE | TCQ_F_NOPARENT; From patchwork Mon Aug 7 19:33:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13344844 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E09C7168B3 for ; Mon, 7 Aug 2023 19:38:09 +0000 (UTC) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2046.outbound.protection.outlook.com [40.107.104.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0ABF19BA; Mon, 7 Aug 2023 12:37:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=amxkys2ghYlEpfdpmcw2DLIzkBHfBBQ7doAz8aKm5ucxLWDw1hP9OTFHmz3JFygokfLwilPONvCyYBT1Y9Yw+uPwb0z7/deRzUVhImANnnzxq5fbDp4AcSEwRr6i+53dJjSREm9aG+Z7ANl8enI/tsZBYklF4LGJ7SlXOWQZ4vAfhA10xgM29vdpbtV6Nu1gqLus97Xbliq5JNbBNtnAogkINqNMkp/CPoawr8N2O1xOcKujHpqqBZfF7mX/0ZJtPrBQLUlkCr2+0wflfcJOOALpM0cRnJznhYgpCAe1MIqsupTh5w3MLXGKpQ5KH1nS5BpIJOX/295KmLGw7Jz4YA== 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=eb4g2bn2KbeapoZ/NtR22nKdzSOsgjXCn/w5rivG9Ms=; b=N2sx4oq6YeA6J8li278LyNeXKJqod9pR0TQfg8OcQodDRWOJO/ToUhzW8CWNiHgpSX0ch+jyap2wvAFftVCpB9BhNF7Tj0KAj1qACaO0Jd5cUZkf+hutYPwRjlBr0M3Mo73VyDL+QemuMNP//e1FuF4TGskeiAPqwjAGoEUGO29JLYoWZymi3bDZYb9tKMyYE+rLINWhaF4/kSOohgyKXg6QR6rReCBv9/4aKHNHqGZPZ65BdiKybbCnwG0yyUd+APWzyPoEAs4dfgpnEXB/0GS3OMMzXOxi+Mx7/5Ef98VMOaTB/qV08+ULB0N/ago1ZaZxeOXvDbzlTr38nxFdfw== 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=eb4g2bn2KbeapoZ/NtR22nKdzSOsgjXCn/w5rivG9Ms=; b=ORiJbAPQ+fcS869mb/BvopIEMSGCw3aAPM/jTkXifLN1X7CjarY6nMB8esLvsIGwPz0greIL/UHhP0VwklFvU6vC/gYg9+LWI5zZtHCpkNc8mphxh1K/+PBtloEng6AHVonRV4DuqLUUkqn0uRl1fm1j7OQN4WpxuJkYia6Bu+w= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by DB9PR04MB9451.eurprd04.prod.outlook.com (2603:10a6:10:368::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.26; Mon, 7 Aug 2023 19:37:36 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::d4ed:20a0:8c0a:d9cf]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::d4ed:20a0:8c0a:d9cf%6]) with mapi id 15.20.6652.026; Mon, 7 Aug 2023 19:37:36 +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 , linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org, Muhammad Husaini Zulkifli , Peilin Ye , Pedro Tammela , Richard Cochran , Zhengchao Shao , Maxim Georgiev Subject: [PATCH v4 net-next 03/11] net/sched: taprio: try again to report q->qdiscs[] to qdisc_leaf() Date: Mon, 7 Aug 2023 22:33:16 +0300 Message-Id: <20230807193324.4128292-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807193324.4128292-1-vladimir.oltean@nxp.com> References: <20230807193324.4128292-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR01CA0136.eurprd01.prod.exchangelabs.com (2603:10a6:208:168::41) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|DB9PR04MB9451:EE_ X-MS-Office365-Filtering-Correlation-Id: 76ac0363-ce45-4345-59df-08db977dc07d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nGn3pXoLmke/LBa3eEo9ud/ZhBwAzxmjoaUBCF5omhpuzS502L9hgw7YZcsmFXylLqOVe395n4QuLQg0kB3/3/qG2rcdtUWAYHccm5C2heWfIodXj91bPvcLpkDjkL75eA+wQF1ljIGgwUJADFZYKaZWQMNek4UeSE3PhxWvLcj++IrK0Xy1OvOFQ3bXPr+A2SbiCNaeLfzUH9E6MsMO0kBebnIZC9kKjov0KP+TlO5ATU3TEinbcLvqBr9+RmnHJf7PV0IcgOepxtFvLDYvQWFb2rKqdEYWhXWrJTZVY6nJFYb0eQjWcl9GuFjKbXktww7bHag6AEK8hkdGooNCEDjdcIOOFoXCaIxF17FrUeHjfEIDt4aZRx3SxZ8SRF0UGFEcHFCXzQqtER0vsXisacmtG/1Evh7QbCxfnU4PPRvX4VPlkOH+o1QWbpAyblMvaxapU2/sRifiB5R8Ziqxta5JExNuRVl15n2eDCPGvzl2kn7a8yBeTXBwsiEkO012TQgl6l7wnP95eqMneB2FcD3MdQzxnQ84LUlPMrHs0MURdqQN/lle0zwQ/0VhCatYQcTkuMYYQnwM394orzSTyhJ6+OUOkDIOmLzw6O+uQziMVgZSZlBeQQb7mtMX7Zoj X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(39860400002)(346002)(136003)(396003)(366004)(186006)(1800799003)(451199021)(1076003)(41300700001)(26005)(2906002)(5660300002)(44832011)(83380400001)(7416002)(8676002)(8936002)(2616005)(6916009)(86362001)(316002)(6506007)(54906003)(38350700002)(38100700002)(6486002)(66476007)(66556008)(478600001)(52116002)(66946007)(6666004)(6512007)(4326008)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 939Iat91FbZIpcF0ORkUfb3H8WPikun7l/ndKj3eMCxtTTe9d26k7+K8N45SeikeElJsUkqa8lwW1n3G8flYNLvwNEBWXNF5gQIF4w3eolZcXtFP0mVmKndN+iHmi8dsrywymrs2C4dsBrSknYWrskQSECJgTyOelNzV/qWXz8qIlZUXnLzJ4ykoU/k3G86S0q7H4UTEetqqyzdTqisktTCkmtZr90V7nzOJyWm4dwC9IY6/34EWYfirM/xrLKifxQIdeT8tWmIx9WZ35FBTroC1169g+KTnzYIh8amUkS2O3dwBoA0sFixJ+ic+3/K5K+t/SxvNCLfWpA+wf8S99AXa+5TxNooPTJaA51tC3E2j6kr5g+oiORUC1UCsLdbMEQnIdSRLgxohUHJKaO/G3AG4LpNPf+UfhE3kMAVaySpzgWrUoeUnuGJZfrDc5ItEOtstczFrde87P1BoVqWBx0QAztc+hRDddX0V+hfDBK869OCTNg2nBtCDXnT6T21ZsSkasE8lsHhTs7p0tR0TA3dWwHPUKMRhKs2fKhW7ojbSNdLHMxOQJqqeXgxixE0ck0baI4hioQZT2qJPlWEe3Z8+xyv7vKigWXWuZsSVdMZdyvFZ+Q3SYJ6cXRhLJtbvmtQG/vy7vVCxjrC1eaEPe9gy5EG8PsEF15CG4U7qhgREe9/Q9+tcSt42mjhIJVSHJs4fvSSepD+kNgV1q2ceXhHGgThlUvbKsKzuspLDxedy3I/x8q+FPYhOqELMAFvOpOzTH5AlVttK+jgKICP2S0rDFE2aq4seCmdQ6/ZDWXCXNK8ADSGrkyLdipzaxCT5060tmWsnT1tIn/9bBndp7o5uinZn8H7BKlB6buldGh2/yCGE5FZCOqV9zyb5NPmMap8RAJOcmpSKE0xVgeJ15R/IwxM1ZDgfTA9e01wOQspls6JOJjx8hiQxW7ikwPdyM6Ss0HFAP2MlzTACDlXH7gEHBVuxYVvNPCBHBUlqecvdgd15+WocGRpNNyyfO18QKYvAgUY1fM+llD5izb47NPyfy+eXdGftFV19NocjVys4KITp5aWKLNOSJqsuHzBnRfHyjen91G2SctW7UzUhGGy8al5HWjBpyfc6+aV5dMB/gcU4j5WsL0JBWg/Y0ETeWaSHw7b+KhK62K6XnQQzberjZmKaGSqvkQQ/MN+8/6ALlIR2zxBzuI6ElgMVSuvY0JCvcEGChupA98YvAoCfhKOIvC+nekESNXxkvGGLe9YJ8/CSklXxeB/jS4GdD4JP4nGleb4bwez2b4hJbtyAHu+7Ko5HynzL4bbX0oL7IzzHwKTZ60jIswJoNQcZwTOOgJv3PfQrH7XW6DSfyUwh8vqVeFDvAh7WIRJaEB6oO9XpHmFZptl7DmqEIcZqe4yWGDEGDp8nk3U+TUk/u8WzZ4KyCZxsBkq++gU14J/oC+Rpt8wfIgkfXVTDpr1DUPlT5ozIPXsd6G1L4u6jpFziutZhsRsksc/AtiEyKA25nUcN5tCH2w/+ta8fnW/1I2w2FvMvveudfB/qrx7D5GhLRRCi2+zABRwIKniFqHpGR6eFbtntO/iX1HJ19Vd3/QsCymo1DpB76BWP7j644XzQWg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 76ac0363-ce45-4345-59df-08db977dc07d X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2023 19:37:36.0860 (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: KDpzV8BmLeJiRf67jpojMSmJDBQh0Zk3lnYedW2SEFYTc3lKrIK1jZB3uvMUWkzNJxylfwGmuMMpOA0xHiBWAQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9451 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org This is another stab at commit 1461d212ab27 ("net/sched: taprio: make qdisc_leaf() see the per-netdev-queue pfifo child qdiscs"), later reverted in commit af7b29b1deaa ("Revert "net/sched: taprio: make qdisc_leaf() see the per-netdev-queue pfifo child qdiscs""). I believe that the problems that caused the revert were fixed, and thus, this change is identical to the original patch. Its purpose is to properly reject attaching a software taprio child qdisc to a software taprio parent. Because unoffloaded taprio currently reports itself (the root Qdisc) as the return value from qdisc_leaf(), then the process of attaching another taprio as child to a Qdisc class of the root will just result in a Qdisc_ops :: change() call for the root. Whereas that's not we want. We want Qdisc_ops :: init() to be called for the taprio child, in order to give the taprio child a chance to check whether its sch->parent is TC_H_ROOT or not (and reject this configuration). Signed-off-by: Vladimir Oltean --- v2->v4: none v1->v2: rebase on top of rtnl_dereference() change for txq->qdisc_sleeping net/sched/sch_taprio.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index 7c1fc3dc3e55..831e6f3fda2a 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -2453,12 +2453,14 @@ static int taprio_dump(struct Qdisc *sch, struct sk_buff *skb) static struct Qdisc *taprio_leaf(struct Qdisc *sch, unsigned long cl) { - struct netdev_queue *dev_queue = taprio_queue_get(sch, cl); + struct taprio_sched *q = qdisc_priv(sch); + struct net_device *dev = qdisc_dev(sch); + unsigned int ntx = cl - 1; - if (!dev_queue) + if (ntx >= dev->num_tx_queues) return NULL; - return rtnl_dereference(dev_queue->qdisc_sleeping); + return q->qdiscs[ntx]; } static unsigned long taprio_find(struct Qdisc *sch, u32 classid) From patchwork Mon Aug 7 19:33:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13344843 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C90A4168A0 for ; Mon, 7 Aug 2023 19:38:09 +0000 (UTC) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2074.outbound.protection.outlook.com [40.107.104.74]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92E0B198C; Mon, 7 Aug 2023 12:38:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JqSDEIDJr3UUjHQfbZzkZbDTtBphi83j822QP846SGvB8GdK0JESW/MFwgjuQVA7uIPy5gUkF/Z/LVr7YkhNjSN9aPDzu0nd+NbFNZpiG81WdC05jlv58z0RZ+a73QXIP9u5p7Chh5oz85qHED5Va7XfKjnBqiizvdJKS07PQhrcSHBFnoQO+oLpeOrzrua/Yt6OFWLsvA3u42SSfpM10Kez6oq55TfV/2pkUSGRoyEbb0FSwqudMmGPA1jtFCT1hJbJ0xpGzdCR+ySTgx8ro7HlCMSvrVZOIJ9FAf9kUstuCGN+NlQa0XJwDWEmHo7fb5190b1h7q6hg/PRHQUF4w== 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=++Os2aWfMEm3xY1Hlw2mvgEOKcfutHpDMexqcLDtSsE=; b=l6inirFYpxC/rwZFi/lCSu/Jcd4qhSJ/ATIGgPcv7l1wZC1TG6268hVMZHEx9j+T0I22e/agI8XUoDEUQRXsPW9Pzzb+o8IqB7snzsybo5qghfPSDvG3KoL9ooPHu4szpHmgvBzsKhjhksTyRPnbfx1pCnDztvKzWbY5znMiUZDZgUCD8rezhYZiJGBEs2LngvK5OnZLTB+OoSAu/RKIcF/ttiroWv0rqggtnwA9Idh0HwqG2AZOYkm433xEew5NnsXiRcyc0n8tNKv2paDIbUjBTtkIZBG683IW8JLjkssqMrW9zWBFeYmkolzVrsTpwrXQixCsB0/Mkj/NLK2Liw== 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=++Os2aWfMEm3xY1Hlw2mvgEOKcfutHpDMexqcLDtSsE=; b=RSSyci5fe0IeSXZdXlZyyG8/Qr3P1DRGOxdgeysxT+P8mnI7DoptAF4ZKhLvGxRdJQBKzfk8eSus26RAlilR266s2f792aNKdJDBUiwNBQvda7CTT2XUNojhYaL4jVCQIJbZWaOuhFgRZEHqQ33M02EQVv0AuuCYtHr706YbduI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by DB9PR04MB9451.eurprd04.prod.outlook.com (2603:10a6:10:368::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.26; Mon, 7 Aug 2023 19:37:37 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::d4ed:20a0:8c0a:d9cf]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::d4ed:20a0:8c0a:d9cf%6]) with mapi id 15.20.6652.026; Mon, 7 Aug 2023 19:37:37 +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 , linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org, Muhammad Husaini Zulkifli , Peilin Ye , Pedro Tammela , Richard Cochran , Zhengchao Shao , Maxim Georgiev Subject: [PATCH v4 net-next 04/11] net/sched: taprio: delete misleading comment about preallocating child qdiscs Date: Mon, 7 Aug 2023 22:33:17 +0300 Message-Id: <20230807193324.4128292-5-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807193324.4128292-1-vladimir.oltean@nxp.com> References: <20230807193324.4128292-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR01CA0136.eurprd01.prod.exchangelabs.com (2603:10a6:208:168::41) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|DB9PR04MB9451:EE_ X-MS-Office365-Filtering-Correlation-Id: 832eac62-d7a1-4ad3-6362-08db977dc12b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kjME+6Y/GStfbpRyhoWjUCF2NjuROQz6eDV8OPydw+IpCbJVrEFKg7+R0oZxTP/QkMwnP7mSD6MtOlO/pEfam6rCTY1e0IhRTNxCV6e2OSDMvat/nmkRwu6ltN46p0SUofSLyWlLaAwBGg2H8wqgCXDx0BsFtBcmK7EuGcBJ21xzuW4kDZF4p9M3BQcL5o8HRiEY27U+mUGJCrvRZle5jTdE2vX18THKNl35bj6aVaJPyRyDFUvqmWqNeuv84//XNsIZgVAdaa+Akl6QBwIDjbRtzVWrQK0yYw0RWvKyvAJ8VqGEAfwuliwunX429fKiEQJW+UtIym9rx2/SRj/BKfmmtukoGIn5HMOl8skekYUgkbHrpBJcbavc57f80jPPvSf5vPgRRTSgpWiQF7nPlk1zxdWtFnRU2CL0/bS0CbKXKQbe9hg6+LKxcAaQ1BMAmwGxMNOfDO4pQxDgtiss3wPMMwNAkWD/gpKADLpOkCMYZ6cjT9CpEGfH9qiydtrBWdZH60TfROyoi0r4MM+YJrvLMfH9SoaF9Wi5BZoldNqvC0dvx5LDZgyorM+NXO6Yj+iQOb25sEKJs4gYMuI6DM1MKEIh2rx/v63ctL+QegV2kcF8UzYyxzfnJpAsMGLX X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(39860400002)(346002)(136003)(396003)(366004)(186006)(1800799003)(451199021)(1076003)(41300700001)(26005)(2906002)(5660300002)(44832011)(83380400001)(7416002)(8676002)(8936002)(2616005)(6916009)(86362001)(316002)(6506007)(54906003)(38350700002)(38100700002)(6486002)(66476007)(66556008)(478600001)(52116002)(66946007)(6666004)(6512007)(4326008)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5zlm8yHhO06jMaDeWRNJg2R8QtMjHs2fDJgqVK4nos/Q3TtCDBn/v6elnim+/3cfMqh+KJ1+x6OGaJ8Ix7wvRK1IfFE7L3ggKbNJIZygE/ljgcfQgQYp/K6OCxHIAU6yJbzTVBCE6YHrBy6+TQJ8T1+zNMn8abkTbdF/icY/ygIiOQO4KXxIG7okTmBEo4BrzVhV+7r889YAEfCM3nnzd2baniSnXgdKm1rdJ5TqhH57Mobm0SteXqA4jlDgMyV2ZDxc1y+q9HW25cpJnExYImgtyc3Z5cJ/Nl9LxXRUzay0oUbb/nnpfLCH4UwBu2NLsPt2LrfDCVzC5oLu0GSqdI3HkjvdIZQiQLbM6qGCnEnDnYrr1I/xO5Tn6P2uuv4PQk9aWlqurQ8Wl32EWMhPZoIsxn/tNpUMouF1ckRnjOd4gMaKmzHZ1iIhuWQ2N98I5IWUWbcdyGhf9tXKpY4WlM+DclRXJ9ZriPZzmXMim5KlmmTRP+4AEFch2yO3n/+V05o3tQgCDUInvSJQk0FqFz84S0ovlxA9d/ASx3uukOXwa9osVh4lK4ULvf8D23ChGShZH9X4INGXL9lA6xv4k6cxag2Lb8xJC85uwGICmLT4sdUKxECaHTnq/mTru/PM9bw3yJGbzMsfNYFF8zQkaMGlHPEhaS51vQ0qxWEp+sbbQbLvFYjh4oIgXzrucBtqq1IqnBufA0XHsD2TOoPHqflwiS4ApDZD26OoINxP5ENOJL1Hs1bwmH+gmjiTEaogIzmn+XriGDGCqyvQ/0ClDbUc1TbXDEfKOPIHspeEPOXscOVKdp9iAhkdlI/0iJVJgdjX+KF1Z/evgERwskoJkKoJwrfZBK0bvbcQw3FTbe2amE9+1KQx+JZZ6CGYjae4e6HOjXO5kswtl9cNYq0v0nq/Ba/rsMxdTXfTlxw2o5loMjXtvfzokb70olihxm3AezKSgCrmvCh0lHN8hcUPsp9bk5JVS3MZMIgIJrblacRan+Sqf9hiIu/y93M2Tq1Ohtr6iFCCMLy6riGwphLaqneCR/0cCFsts7UNoQLoH9OGf9CTL1/AkpAswROMWytVEaBL4XuHTHeC9MP0EMT9+U64Bzj6z9gRbkxIG44WjvGDZNhUVJkak8N1+8aSy55jbPh3wlG/wyibtrsmFpp2Nqg/YLbNZxHHpLtJNxSiGGP85HgHX88z4wJPKip+bsfMqrMXaau3qSkBRTTzDfP7Qe79lO6Ggx4NCsWLP9DmvJYNGUuPt5Hy8HS8ded7qx+v47VZvBoYb42kvM47PTpNcGM998WVvwvURXLIQeETdH0XZUObhJ2kp9uAKhziOi+i4fUGZEHcrKxaz9dGTnR5i4K/WHqfC3FU7Pq9JGSbTeqOuWQ7wYXITiEaBafslALh8EqYF7EYIB8+/zo5wvXAq4SmESZx8g5joUBJLRXa4e/sIVZIxHcZNojJtN7phFQ64KeUCD8BPYSjaHbKoHqltjwQk0bTYDJn2CK/pk0W6kDQIlGWQmyejp57qCWXOythgxL7mvzsV/F7hxjPtHYqLs/F7WYdU/TsHe9h4YelL1q+/HEeMOkw3APCFfWDxDkc1q9xXU9bshD2cssHQWAkjg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 832eac62-d7a1-4ad3-6362-08db977dc12b X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2023 19:37:37.1721 (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: cdZPYGS0ylu0W92wjK37ncwxKG1eE43ocGX89UbGzD6lj00elR2QsuvYIS+ntMqlmPDoHPcvkg8ZRM2U30ifbA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9451 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org As mentioned in commit af7b29b1deaa ("Revert "net/sched: taprio: make qdisc_leaf() see the per-netdev-queue pfifo child qdiscs"") - unlike mqprio, taprio doesn't use q->qdiscs[] only as a temporary transport between Qdisc_ops :: init() and Qdisc_ops :: attach(). Delete the comment, which is just stolen from mqprio, but there, the usage patterns are a lot different, and this is nothing but confusing. Signed-off-by: Vladimir Oltean --- v1->v4: none net/sched/sch_taprio.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index 831e6f3fda2a..d5693bd52e93 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -2099,11 +2099,8 @@ static int taprio_init(struct Qdisc *sch, struct nlattr *opt, return -EOPNOTSUPP; } - /* pre-allocate qdisc, attachment can't fail */ - q->qdiscs = kcalloc(dev->num_tx_queues, - sizeof(q->qdiscs[0]), + q->qdiscs = kcalloc(dev->num_tx_queues, sizeof(q->qdiscs[0]), GFP_KERNEL); - if (!q->qdiscs) return -ENOMEM; From patchwork Mon Aug 7 19:33:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13344845 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F82E168B3 for ; Mon, 7 Aug 2023 19:38:11 +0000 (UTC) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2063.outbound.protection.outlook.com [40.107.104.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD8D9172C; Mon, 7 Aug 2023 12:38:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D+tpPBEcHyaljTpIswF8fNpDS5k1LZsjp+y6OtHvJZ3MAblGg3Cpk2CHm183MhvEDUwXR7pYRgg960xQtNeyQU57jfVh6MOI85tNQHngle5K3D5g3wbb75aeuRBpYpBrnFjPZW6yDJAwEJeVJ2jpYLgVPHumzOxt17eaBkwDi+T6J5Loe1zW9fq6m7fcZqVUvxY9AnRpv3fG86GGnI51te/gFgfLyVqMEp4+ehMHNsxGlI4zDAGfwHNoxbB2Cxw2wzuqID5V8NhaiR3WKkQNhZvlS/4Ba2u8axHMbK1K94lnMz3CSeVIYOimUIAV1rRbznEDnVC3vjrvPkTFcXz/JA== 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=rsF/yoN2msUZ792uUMQYCbZxXSYWf9JklEycafTispI=; b=Zmfw2/KMMH7RA3cqPljYAoSBo1OwWs4EWwkBXI1iisPBFfKFPTZ+vfhHjo5q1Vs3qM337Pw7bszXi5ClGUQKgY2nWJ5qwSMUxikJ7vjLlaM5quAOl64aHrj+AuOrMfTDEeT6J9TTD9uubzoFR4nBOlQw/Q3W8074Xzs6fN7vpGV4Dx1e8+yGkfoWGryhGLqBdvuj+Hhcr510VWQxM8PAdAqvG/L34jpBHgEzEIa768yyToFQycHD/uXyNzFYehD+ukez5R6KTFMKOlDmkk1TmMLlh39tvks97PPkBoLEhuhu1fFc7LcKn+IzUIs0wufIYQfXOgeQfWn0Gpmnk2O+8A== 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=rsF/yoN2msUZ792uUMQYCbZxXSYWf9JklEycafTispI=; b=s7LJBJwEaOeqbXQxqaPx4XOus4V+mOxSktm0Uo5XnE7afyIC/knyG71B68EmeFvm0HWTWtvfMdaXXaTI8IOVUwJ80kF4zeskPHYQ6IMdXKTyqo6VvS5h4noSqvh1PcBTSDFiBwdj8O3/e+NB6T+keWr5EaOG5oGFketZmIvBLnQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by DB9PR04MB9451.eurprd04.prod.outlook.com (2603:10a6:10:368::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.26; Mon, 7 Aug 2023 19:37:38 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::d4ed:20a0:8c0a:d9cf]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::d4ed:20a0:8c0a:d9cf%6]) with mapi id 15.20.6652.026; Mon, 7 Aug 2023 19:37:38 +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 , linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org, Muhammad Husaini Zulkifli , Peilin Ye , Pedro Tammela , Richard Cochran , Zhengchao Shao , Maxim Georgiev Subject: [PATCH v4 net-next 05/11] net/sched: taprio: dump class stats for the actual q->qdiscs[] Date: Mon, 7 Aug 2023 22:33:18 +0300 Message-Id: <20230807193324.4128292-6-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807193324.4128292-1-vladimir.oltean@nxp.com> References: <20230807193324.4128292-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR01CA0136.eurprd01.prod.exchangelabs.com (2603:10a6:208:168::41) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|DB9PR04MB9451:EE_ X-MS-Office365-Filtering-Correlation-Id: 73414922-1a09-48fe-e391-08db977dc1cf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ydAQHtQFHDe7DP0eBJ0nmxuhJzR8u/XPA+7JRJJS8zm0tkxwNnX6OSio8P0hDywFEbLmcXXwwtUCjKmS0yrLOkifkwqSRqO01S6otqnPz3Xyo1R8yWaxk3bWmJX4knSgYn4oHCejWtMjufdCOjeJ+hVtaAZ1T1W/BSuK5BQ+zoEvv1qvHGaQS/ROEt3QtxZU6NGRg9uXK92/H1ak2w6IiHasoGcZ+p0U3bJe0ZUlFktByXq7p0Esb35JESBetGecUzt7aI65Gq4zh3sdRSJsoC3b4aKUng5Crjf/w76H19H0BMoMG+91jVKLuUvSwhH3vgdNlLXYEN7aWfSkzE6IWZ03X49z2ffPLnbzhCncJ5BeCgsVga50AN52ampUrM9IP4EDZtNrXB6AN2RI2cUTpiJaI9BnNto17BizzxDT+5VmEymezgybwSJuf9hTrCoW2t/7pXJV03NuswUq5muwufy9phpWMfnuPM1VElsehYUXGqQLcedYi/ZRVBBlixMQosYhYEAk0tzl0trKmY4hAD2B6UVwsKfHWhbYMAV6V89xSIMH5o88PO03b/ImiEIpdwkeg9lV0di5GMYNSKfzTv4m8ZTl7ZZS8EUGWfovKi8= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(39860400002)(346002)(136003)(396003)(366004)(186006)(1800799003)(451199021)(1076003)(41300700001)(26005)(2906002)(5660300002)(44832011)(83380400001)(7416002)(8676002)(8936002)(2616005)(6916009)(86362001)(316002)(6506007)(54906003)(38350700002)(38100700002)(6486002)(66476007)(66556008)(478600001)(52116002)(66946007)(6666004)(6512007)(966005)(4326008)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CK1nuBlQBTroKeocsvb5MeFaXapb4WjLyXyYLVO26YY22zmSD94EDQ2L+MzdddjejEgoS5R26noGAZ6Lti7JdeRrlq35zqPiHuqkV1BoRfV0ljlqo9F7c8mWwFJps1ERpGtKuWPYE0302Aa3REhExbkRDGOhUt0dDYEVott/dZxLnMrPuTtkcVH6jupIC0Dqwy8+106quqbkkvyv/iIe9kCn14Y1fmJSn/cn9X40XPMpq3Yg+iBNNmJFs/za5g6Aj2RVNpNhsD34GqDYFyBCy9M3DsDzUQtehEHHtY03qGgUo7f+SfDuGUZZf7MmY+tOWxrnuyHyod3b16q6tQqHl0YP7iXLVCmsJxPA/LM2mtc7U0o7IUTwYvMqJUWP1JqzpWP1klxIMv7g05Fjdien9sNUFmY5dtNOQ3UMv0mWdeY1652FGXGZfWvLtM8e6AHUrbRt8vilovenrZugJnqM4MSsbilGtJs3Z9uA+U/YCO7DnHL2+0uheRFRf0RmJeAy6gLvDoSAKpVidDGRIqxdUj/d7Tw0403JNGPfdIzWFFUxAUiLL7Jihyu9ScKIstAqJwLytzGx5n8634PsnrE9kwveTuzXeCUckVvSs0c8w2GmrnMoUje6Gm3pjDhQEY1qFRWKyAfzD6TcHRTajxIzEtaTaoa3mdU5BKjAsvjujW7NZuacNJc0SEJb+cyGAbWEdgqThO0/9HhXCOcpPX+RubKe1BnHQA7hTrV5F7V9ZLA4TbzZIAR56Fkq+Np/g9nblDLkiWxqCKjyPUOUjGBbFutKSFM8AIOK6P0yhuva9njxkpQnvdjbbNCeHc5s1S3+VxbHGcdLQxWNk9UlbeUQOTBd6jgaA/UbNIOcpjfS2vrEjH+yRLPT4Vuft2gr692BTCAON7ibP/ylieL71B9lJSMgGJF/jrScBGbbGEIu1TxT4yrjd/kSsttgDY5JYJUdSJCIYLy8aKHSLjLjA8ddwRQ7FOrP/MZHf5owpOix3oUOtaQKVuKp6ymrJzrs0sPx6oMVfxEaMKM5zsPytLOMly+xM2Hn1bRwJoQqpPOv2o78xikO3y9GzKbpjhdngyzTa0oKVBIiXfn+ZRZJ+/gbr2jwWcgF0THDXaiUiFhe9CjBVHEN5oJPncMszTX83Bl8onzJDlwv1Z53nCKjqhbtZBIw8wkemDSHBMbeesZfBg8hPa2Wm5W/Nc5FjIG8RG2bF/RJIluR8TLYFvOduV9zLvqIRaBkf3VqHt1hSgXMU3qIN81vFsFqlME19KxKIsbKT/Y4ICXbKtUqD4ElsNRs4jXkqzeR+zcW7TsdbBWWV78+vf+ylJuEIYJmCno8JCcY1k4tSvgQAq6Q0/4mJyk1pFb8PKXE6amoTm7hH0Qp7hwNgg6eRUyRq3MRWedKTCu67oB/lWQjAOTAGYx00pONm/gaeU2yZgw9nE4LkqTvvzwe+nuBsDd8intFs4ccqPJtRJ8tQyL8/YjWjssBN/jnQlVy+GHD4d8xWfYB5xqugoxsJ9ooE3Dym8JjRKOQMO34gtV//Xn4NYfcMnyS6++8N2CGI/1HvwWq2n3wnPpVGmIo9gamyiuGZzmdw59m2spmu2dRr7xD1wzZzJIif1Tyxg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 73414922-1a09-48fe-e391-08db977dc1cf X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2023 19:37:38.3306 (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: AsH6KcAfiwllaFJE06jZfpufs8Zf4NOTxJnjomEjr2UkN3RRGNfLjBxIpQmw7Vr0c3FzzirsvlHyi3J0Gn5PaA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9451 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org This makes a difference for the software scheduling mode, where dev_queue->qdisc_sleeping is the same as the taprio root Qdisc itself, but when we're talking about what Qdisc and stats get reported for a traffic class, the root taprio isn't what comes to mind, but q->qdiscs[] is. To understand the difference, I've attempted to send 100 packets in software mode through class 8001:5, and recorded the stats before and after the change. Here is before: $ tc -s class show dev eth0 class taprio 8001:1 root leaf 8001: Sent 9400 bytes 100 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 window_drops 0 class taprio 8001:2 root leaf 8001: Sent 9400 bytes 100 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 window_drops 0 class taprio 8001:3 root leaf 8001: Sent 9400 bytes 100 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 window_drops 0 class taprio 8001:4 root leaf 8001: Sent 9400 bytes 100 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 window_drops 0 class taprio 8001:5 root leaf 8001: Sent 9400 bytes 100 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 window_drops 0 class taprio 8001:6 root leaf 8001: Sent 9400 bytes 100 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 window_drops 0 class taprio 8001:7 root leaf 8001: Sent 9400 bytes 100 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 window_drops 0 class taprio 8001:8 root leaf 8001: Sent 9400 bytes 100 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 window_drops 0 and here is after: class taprio 8001:1 root Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 window_drops 0 class taprio 8001:2 root Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 window_drops 0 class taprio 8001:3 root Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 window_drops 0 class taprio 8001:4 root Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 window_drops 0 class taprio 8001:5 root Sent 9400 bytes 100 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 window_drops 0 class taprio 8001:6 root Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 window_drops 0 class taprio 8001:7 root Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 window_drops 0 class taprio 8001:8 root leaf 800d: Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 window_drops 0 The most glaring (and expected) difference is that before, all class stats reported the global stats, whereas now, they really report just the counters for that traffic class. Finally, Pedro Tammela points out that there is a tc selftest which checks specifically which handle do the child Qdiscs corresponding to each class have. That's changing here - taprio no longer reports tcm->tcm_info as the same handle "1:" as itself (the root Qdisc), but 0 (the handle of the default pfifo child Qdiscs). Since iproute2 does not print a child Qdisc handle of 0, adjust the test's expected output. Link: https://lore.kernel.org/netdev/3b83fcf6-a5e8-26fb-8c8a-ec34ec4c3342@mojatatu.com/ Signed-off-by: Vladimir Oltean --- v3->v4: none v2->v3: fix selftest broken by the change v1->v2: - reword commit message - rebase on top of the TAPRIO_CMD_TC_STATS -> TAPRIO_CMD_QUEUE_STATS change net/sched/sch_taprio.c | 8 +++----- .../selftests/tc-testing/tc-tests/qdiscs/taprio.json | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index d5693bd52e93..1cb5e41c0ec7 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -2472,11 +2472,11 @@ static unsigned long taprio_find(struct Qdisc *sch, u32 classid) static int taprio_dump_class(struct Qdisc *sch, unsigned long cl, struct sk_buff *skb, struct tcmsg *tcm) { - struct netdev_queue *dev_queue = taprio_queue_get(sch, cl); + struct Qdisc *child = taprio_leaf(sch, cl); tcm->tcm_parent = TC_H_ROOT; tcm->tcm_handle |= TC_H_MIN(cl); - tcm->tcm_info = rtnl_dereference(dev_queue->qdisc_sleeping)->handle; + tcm->tcm_info = child->handle; return 0; } @@ -2486,16 +2486,14 @@ static int taprio_dump_class_stats(struct Qdisc *sch, unsigned long cl, __releases(d->lock) __acquires(d->lock) { - struct netdev_queue *dev_queue = taprio_queue_get(sch, cl); + struct Qdisc *child = taprio_leaf(sch, cl); struct tc_taprio_qopt_offload offload = { .cmd = TAPRIO_CMD_QUEUE_STATS, .queue_stats = { .queue = cl - 1, }, }; - struct Qdisc *child; - child = rtnl_dereference(dev_queue->qdisc_sleeping); if (gnet_stats_copy_basic(d, NULL, &child->bstats, true) < 0 || qdisc_qstats_copy(d, child) < 0) return -1; diff --git a/tools/testing/selftests/tc-testing/tc-tests/qdiscs/taprio.json b/tools/testing/selftests/tc-testing/tc-tests/qdiscs/taprio.json index 08d4861c2e78..860b55df0d6d 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/qdiscs/taprio.json +++ b/tools/testing/selftests/tc-testing/tc-tests/qdiscs/taprio.json @@ -104,7 +104,7 @@ "cmdUnderTest": "$TC qdisc add dev $ETH root handle 1: taprio num_tc 3 map 2 2 1 0 2 2 2 2 2 2 2 2 2 2 2 2 queues 1@0 1@0 1@0 base-time 1000000000 sched-entry S 01 300000 flags 0x1 clockid CLOCK_TAI", "expExitCode": "0", "verifyCmd": "$TC class show dev $ETH", - "matchPattern": "class taprio 1:[0-9]+ root leaf 1:", + "matchPattern": "class taprio 1:[0-9]+ root", "matchCount": "8", "teardown": [ "echo \"1\" > /sys/bus/netdevsim/del_device" From patchwork Mon Aug 7 19:33:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13344848 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86D2B171A8 for ; Mon, 7 Aug 2023 19:38:17 +0000 (UTC) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2074.outbound.protection.outlook.com [40.107.104.74]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF49B1BDA; Mon, 7 Aug 2023 12:38:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hXBDOhW8LGqIYqEhnArF9gnmzXnknuN674lnPWi6cU5qjP5v7ya++X7T5eQbGL1Cthn7jUPCq6yRlcDC2i3Yvd5d6yh84TLEw8r++T54SJd2nckVzft7JISdAxBAmjIky5U894KQssTJsH3niTg4HBqradI4KR5/WWne1Q4o+iDcBmsx7py642v94+USPsrl393BWgFePPkOcHf3sZa6bQKRxYPKxu0NEFxd6Jlshd0URRx+fqaul6QYuqAFA+I1aNqv3XGrXKYZv6JG6Jf+uuSEC7w1sry65V9VQYVg9P4c9Xyb+/NP0P4BIyZ6YebeY/yyiPWqt4cR2jk2Dq6tMA== 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=y1S93DoefvE7VVmG1C7WPf5K+qiqJVvjXRJKXz4mdU0=; b=S5Cl6VTE+8NnL17pMFVHWRzH/eUKWtrj/QJ4ttZltH6DFAshXI3kvUeofjefI+gCrJDuITuJOGSKqjOjaoaXfCSWRojYvp+A8uhCT+8vZmAq+u/kOWxWMMnJPq3qdSLy8l1hchffxdFWPqW/ahvrsPTwr4D/Srm5sDHOiV7ZvcyRDWC3frshXI9olkUkXLf7U6RyMSy75UvjL4FbBGiApcr9L5V4gpk/n5U1iRcK3rK8uJ9QrhsOLyoeFKOtbJHq/PbgLTm1aXfg4Kbudb8T+pLtoGvZzza9h8ByxHatGP+C3jHC5hH/Jc1gmXxglXOdLljENvhY0LjEx6gN/13i+g== 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=y1S93DoefvE7VVmG1C7WPf5K+qiqJVvjXRJKXz4mdU0=; b=j+zUHykY5ixIwyGTdKSLnn/rsol3EF5jb0BCqY/4Kw3GO18emy4N/IRVsfZEUz3EpwSg4niDIE7VxGxF+O9FuIZ973E2zhMTDkorlfSPsREftYcVgLiMhGbjk+h9jfE4dv6cUmRmPf05tTkbc2NHHFIi2s3kuKut9/UDwjI70io= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by DB9PR04MB9451.eurprd04.prod.outlook.com (2603:10a6:10:368::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.26; Mon, 7 Aug 2023 19:37:39 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::d4ed:20a0:8c0a:d9cf]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::d4ed:20a0:8c0a:d9cf%6]) with mapi id 15.20.6652.026; Mon, 7 Aug 2023 19:37:39 +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 , linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org, Muhammad Husaini Zulkifli , Peilin Ye , Pedro Tammela , Richard Cochran , Zhengchao Shao , Maxim Georgiev Subject: [PATCH v4 net-next 06/11] net: ptp: create a mock-up PTP Hardware Clock driver Date: Mon, 7 Aug 2023 22:33:19 +0300 Message-Id: <20230807193324.4128292-7-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807193324.4128292-1-vladimir.oltean@nxp.com> References: <20230807193324.4128292-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR01CA0136.eurprd01.prod.exchangelabs.com (2603:10a6:208:168::41) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|DB9PR04MB9451:EE_ X-MS-Office365-Filtering-Correlation-Id: 5a4076b1-69e8-4352-b1b5-08db977dc282 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sBVXjgNjn86rrWHq1oadVIQDJqiMpbY+Z+B7+VP4Censm9GrIxI9UlQamg2os5PoeOw5Mh4tuvBS4gHeuiP1pnbupzdAiB8lJnZYmZIQlsAKv8cYF8K/86pp3p30bmkLXWRxBK0TI1wFQbywQQLIfGxSMj8Uhp5oTYJ4TNcYEVQ6wq3vs6MAwsyp+awjEEjfDku97sIItitz7dJe73+sgIWueS8psibH0lUNYZNmIyoKyBGuD40yVmxqCZvnssPZydzA2OJqNZ8Lb9Y/GGRC9oE5pfaXhjLzlUn/fA19nNRkMNk/9LCSL3TqeePvhEb8QJgF30ieSZsGkyPVvRi5AtnZWBbwaYPo11TAmOm0A6pR8WgumZccYHB+yRzU0P4gSTfrQeV+YJpA2hoi1Av+gVIhoSksjpToLRExtP9AvXvbcld/iFDbst0ulaX9i2OxWwMxZGaAP7TG+Rk8Fju3qYMIHFLY0sfWNVCQ9g7G7bOzD7MB5YyahHctYYJv2rtTuAVTFcSLScxPdxDWmRv8OdE/nBaM9F4G9udjgVl5aJFwicG1HHL87dKsBXRTDbANVTp1e5aPoCRHz/uds4F39AwJzmOSkFNRAKCI1xcT5n4= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(39860400002)(346002)(136003)(396003)(366004)(186006)(1800799003)(451199021)(1076003)(41300700001)(26005)(2906002)(5660300002)(44832011)(83380400001)(7416002)(8676002)(66899021)(8936002)(2616005)(6916009)(86362001)(316002)(6506007)(54906003)(38350700002)(38100700002)(6486002)(66476007)(66556008)(478600001)(52116002)(66946007)(6666004)(6512007)(4326008)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lkEt+LEddiWYm303pqxjYeXtZcxOkbaXz86lH6q8/MdEc76/8b1k2FjC40gckojoaIJs4jeRkFXqBIOkffTRpK45mlBWvLx3wcylMoPLypEbfyVHYa5V9rzmvS9QAt/oVBxLHNiR3yuFkr2NfoRsFKRBKZq5HKAehlY36A6fgvheyOu+Wq0ZSAVG+Rp6ifLroTD8WqJK7xcseE/SZ7obI1jUtJMg9AFIzKmwNeVdRODSjwMF98OCzMCM/ju+MdQV7HTbsCawdtyzRkiGUnbWSh9CJyBUqzm+6e6MmvpJBURcdIJX5zd7XTS5IFcNGxw8cWjoUbBn8EB6zjkF4OuYnw8SXHpne12hcPGMUjTAcNzfihgiLMTiA/QRSFjnltNZCfmnBi2M+NQ8wHznhgX2PUYjxhWglKWfHhbqm/1NecLrrbYYT9goefrBj/lDnK6LE4FYo0ZJrIVZpzdPInFvupO24ZgJN/TOv8/m594bjFvvz3+yfwtAawZJUgmwQivJkaNbPNP5Q668YfjpeEhz4mqsqOfRRUg0DwmwIdm2++9OhQSMM6IJKvJsw2ZMP8Oyl5xlDeTFb2Oqpvrm5AcqSX0iiN1R+5QlieE4IrBBgIWsqP3PUpy/5gup5EgMEEe0QScY7Iq7m8aHOkLjwJ0NQN+g3ipf1WEkLmw2JHz6N2Sc/QhpK+ST5SAcZUhDwgRSzrUlwrlRTWEWXRL6JOEC9mvrKruxLhau8xArTd2o0Dlv4shlaWiWQvEiHVwpljDJtLzVAxhTarOLieHGpfdLCHmhuwnQ+WJW1DJtmzPVUw05iqbC1wPf7QuY9FRn/o8LP2UuGl4AnJJZQEWtZe7obyuSE1kdsQhRJGWiPePP2TlgNceOB9U/VSY1+icTfkCBKV/S18X5jvSUUHUofh+IA8aCilXjHC8Ys8/u3aqxAX+opHjES5yYyrKFbInV862uuhBsYcqBkz4eJTt3rZc0YbbTX7PLX6+1emMtTuqwqbrSwVxU7krjb7J53AsHMD9JAEXNHKaVioA/Q824h0r+ciYPfhlD6osrncgtDPDdo1M9P+ARunl4V5C4e80uZrltt4miZOvMrmcxnzEttLIHZYU47S0G8/OlYQO9IwcVY4wI4Av75tvBVAnaPZzYJ666EzamwZPgdd4y0MUYYPB9epMD4RDYiYixsOO/jwdQYZ+9otEfJwuSGeeXO0PKIOlWhAZciLOXoN/Aqad4jAzIjBL98VsXlnFpjfC3H0Lo5xlEykz6TfP1Hm2h1y9NCLnuI+PJE1fR0BcfZQY7kEKJ9zTfbawjil2WJSPaEa+fnl5GSagIq24vHKMmbNmM6PzBJ1CPA2e61Q3Yv02Knmdgqf5O3QMZoHJ2H+97HKvcAzQno+AA66kKpmvNCnCt7mxWFYfbeG06YngpjXkK4By9vyjJHtX+RUyt+MR7rz22svDAqeJVElVCEJYKlgm8J6vgLKtiKTvXOzQH4YmnKgdRv+ZRMvyfCjgg/kGdc0qg66oqss60kkbBFr53FsnGE4CE+PwLe2YVppZm+WpaDztS3q4Z6mNTrEPrfZJwSGeW/0cH2G7sKCobqcYETLe5RxifX0sZmifVushH8Omn15nROA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5a4076b1-69e8-4352-b1b5-08db977dc282 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2023 19:37:39.4406 (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: 9JdDWisr1Jh198SdKfdseP868zRr53oXkEYjilwnn7sx/txjMqbQ6pqjnd7p5b4C6FIvNqIG3xlKkFuZaKdhkg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9451 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org There are several cases where virtual net devices may benefit from having a PTP clock, and these have to do with testing. I can see at least netdevsim and veth as potential users of a common mock-up PTP hardware clock driver. The proposed idea is to create an object which emulates PTP clock operations on top of the unadjustable CLOCK_MONOTONIC_RAW plus a software-controlled time domain via a timecounter/cyclecounter and then link that PHC to the netdevsim device. The driver is fully functional for its intended purpose, and it successfully passes the PTP selftests. $ cd tools/testing/selftests/ptp/ $ ./phc.sh /dev/ptp2 TEST: settime [ OK ] TEST: adjtime [ OK ] TEST: adjfreq [ OK ] Signed-off-by: Vladimir Oltean --- v3->v4: - s/spin_lock_bh/spin_lock/ - s/ktime_to_ns(ktime_get_raw())/ktime_get_raw_ns()/ - s/mock_phc_lock/phc->lock/ v2->v3: - split off ptp_mock into separate patch - fix ptp_mock compilation as a module - turn phc->lock into a global spinlock - drop bogus support for ptp_clock_register() ever returning NULL - add MAINTAINERS entry v1->v2: patch is new MAINTAINERS | 7 ++ drivers/ptp/Kconfig | 11 +++ drivers/ptp/Makefile | 1 + drivers/ptp/ptp_mock.c | 175 +++++++++++++++++++++++++++++++++++++++ include/linux/ptp_mock.h | 38 +++++++++ 5 files changed, 232 insertions(+) create mode 100644 drivers/ptp/ptp_mock.c create mode 100644 include/linux/ptp_mock.h diff --git a/MAINTAINERS b/MAINTAINERS index 5e2bb1059ab6..6d8f36d6aae9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -17171,6 +17171,13 @@ F: drivers/ptp/* F: include/linux/ptp_cl* K: (?:\b|_)ptp(?:\b|_) +PTP MOCKUP CLOCK SUPPORT +M: Vladimir Oltean +L: netdev@vger.kernel.org +S: Maintained +F: drivers/ptp/ptp_mock.c +F: include/linux/ptp_mock.h + PTP VIRTUAL CLOCK SUPPORT M: Yangbo Lu L: netdev@vger.kernel.org diff --git a/drivers/ptp/Kconfig b/drivers/ptp/Kconfig index 32dff1b4f891..ed9d97a032f1 100644 --- a/drivers/ptp/Kconfig +++ b/drivers/ptp/Kconfig @@ -155,6 +155,17 @@ config PTP_1588_CLOCK_IDTCM To compile this driver as a module, choose M here: the module will be called ptp_clockmatrix. +config PTP_1588_CLOCK_MOCK + tristate "Mock-up PTP clock" + depends on PTP_1588_CLOCK + help + This driver offers a set of PTP clock manipulation operations over + the system monotonic time. It can be used by virtual network device + drivers to emulate PTP capabilities. + + To compile this driver as a module, choose M here: the module + will be called ptp_mock. + config PTP_1588_CLOCK_VMW tristate "VMware virtual PTP clock" depends on ACPI && HYPERVISOR_GUEST && X86 diff --git a/drivers/ptp/Makefile b/drivers/ptp/Makefile index 553f18bf3c83..dea0cebd2303 100644 --- a/drivers/ptp/Makefile +++ b/drivers/ptp/Makefile @@ -16,6 +16,7 @@ ptp-qoriq-y += ptp_qoriq.o ptp-qoriq-$(CONFIG_DEBUG_FS) += ptp_qoriq_debugfs.o obj-$(CONFIG_PTP_1588_CLOCK_IDTCM) += ptp_clockmatrix.o obj-$(CONFIG_PTP_1588_CLOCK_IDT82P33) += ptp_idt82p33.o +obj-$(CONFIG_PTP_1588_CLOCK_MOCK) += ptp_mock.o obj-$(CONFIG_PTP_1588_CLOCK_VMW) += ptp_vmw.o obj-$(CONFIG_PTP_1588_CLOCK_OCP) += ptp_ocp.o obj-$(CONFIG_PTP_DFL_TOD) += ptp_dfl_tod.o diff --git a/drivers/ptp/ptp_mock.c b/drivers/ptp/ptp_mock.c new file mode 100644 index 000000000000..e7b459c846a2 --- /dev/null +++ b/drivers/ptp/ptp_mock.c @@ -0,0 +1,175 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright 2023 NXP + * + * Mock-up PTP Hardware Clock driver for virtual network devices + * + * Create a PTP clock which offers PTP time manipulation operations + * using a timecounter/cyclecounter on top of CLOCK_MONOTONIC_RAW. + */ + +#include +#include +#include + +/* Clamp scaled_ppm between -2,097,152,000 and 2,097,152,000, + * and thus "adj" between -68,719,476 and 68,719,476 + */ +#define MOCK_PHC_MAX_ADJ_PPB 32000000 +/* Timestamps from ktime_get_raw() have 1 ns resolution, so the scale factor + * (MULT >> SHIFT) needs to be 1. Pick SHIFT as 31 bits, which translates + * MULT(freq 0) into 0x80000000. + */ +#define MOCK_PHC_CC_SHIFT 31 +#define MOCK_PHC_CC_MULT (1 << MOCK_PHC_CC_SHIFT) +#define MOCK_PHC_FADJ_SHIFT 9 +#define MOCK_PHC_FADJ_DENOMINATOR 15625ULL + +/* The largest cycle_delta that timecounter_read_delta() can handle without a + * 64-bit overflow during the multiplication with cc->mult, given the max "adj" + * we permit, is ~8.3 seconds. Make sure readouts are more frequent than that. + */ +#define MOCK_PHC_REFRESH_INTERVAL (HZ * 5) + +#define info_to_phc(d) container_of((d), struct mock_phc, info) + +struct mock_phc { + struct ptp_clock_info info; + struct ptp_clock *clock; + struct timecounter tc; + struct cyclecounter cc; + spinlock_t lock; +}; + +static u64 mock_phc_cc_read(const struct cyclecounter *cc) +{ + return ktime_get_raw_ns(); +} + +static int mock_phc_adjfine(struct ptp_clock_info *info, long scaled_ppm) +{ + struct mock_phc *phc = info_to_phc(info); + s64 adj; + + adj = (s64)scaled_ppm << MOCK_PHC_FADJ_SHIFT; + adj = div_s64(adj, MOCK_PHC_FADJ_DENOMINATOR); + + spin_lock(&phc->lock); + timecounter_read(&phc->tc); + phc->cc.mult = MOCK_PHC_CC_MULT + adj; + spin_unlock(&phc->lock); + + return 0; +} + +static int mock_phc_adjtime(struct ptp_clock_info *info, s64 delta) +{ + struct mock_phc *phc = info_to_phc(info); + + spin_lock(&phc->lock); + timecounter_adjtime(&phc->tc, delta); + spin_unlock(&phc->lock); + + return 0; +} + +static int mock_phc_settime64(struct ptp_clock_info *info, + const struct timespec64 *ts) +{ + struct mock_phc *phc = info_to_phc(info); + u64 ns = timespec64_to_ns(ts); + + spin_lock(&phc->lock); + timecounter_init(&phc->tc, &phc->cc, ns); + spin_unlock(&phc->lock); + + return 0; +} + +static int mock_phc_gettime64(struct ptp_clock_info *info, struct timespec64 *ts) +{ + struct mock_phc *phc = info_to_phc(info); + u64 ns; + + spin_lock(&phc->lock); + ns = timecounter_read(&phc->tc); + spin_unlock(&phc->lock); + + *ts = ns_to_timespec64(ns); + + return 0; +} + +static long mock_phc_refresh(struct ptp_clock_info *info) +{ + struct timespec64 ts; + + mock_phc_gettime64(info, &ts); + + return MOCK_PHC_REFRESH_INTERVAL; +} + +int mock_phc_index(struct mock_phc *phc) +{ + return ptp_clock_index(phc->clock); +} +EXPORT_SYMBOL_GPL(mock_phc_index); + +struct mock_phc *mock_phc_create(struct device *dev) +{ + struct mock_phc *phc; + int err; + + phc = kzalloc(sizeof(*phc), GFP_KERNEL); + if (!phc) { + err = -ENOMEM; + goto out; + } + + phc->info = (struct ptp_clock_info) { + .owner = THIS_MODULE, + .name = "Mock-up PTP clock", + .max_adj = MOCK_PHC_MAX_ADJ_PPB, + .adjfine = mock_phc_adjfine, + .adjtime = mock_phc_adjtime, + .gettime64 = mock_phc_gettime64, + .settime64 = mock_phc_settime64, + .do_aux_work = mock_phc_refresh, + }; + + phc->cc = (struct cyclecounter) { + .read = mock_phc_cc_read, + .mask = CYCLECOUNTER_MASK(64), + .mult = MOCK_PHC_CC_MULT, + .shift = MOCK_PHC_CC_SHIFT, + }; + + spin_lock_init(&phc->lock); + timecounter_init(&phc->tc, &phc->cc, 0); + + phc->clock = ptp_clock_register(&phc->info, dev); + if (IS_ERR(phc->clock)) { + err = PTR_ERR(phc->clock); + goto out_free_phc; + } + + ptp_schedule_worker(phc->clock, MOCK_PHC_REFRESH_INTERVAL); + + return phc; + +out_free_phc: + kfree(phc); +out: + return ERR_PTR(err); +} +EXPORT_SYMBOL_GPL(mock_phc_create); + +void mock_phc_destroy(struct mock_phc *phc) +{ + ptp_clock_unregister(phc->clock); + kfree(phc); +} +EXPORT_SYMBOL_GPL(mock_phc_destroy); + +MODULE_DESCRIPTION("Mock-up PTP Hardware Clock driver"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/ptp_mock.h b/include/linux/ptp_mock.h new file mode 100644 index 000000000000..72eb401034d9 --- /dev/null +++ b/include/linux/ptp_mock.h @@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Mock-up PTP Hardware Clock driver for virtual network devices + * + * Copyright 2023 NXP + */ + +#ifndef _PTP_MOCK_H_ +#define _PTP_MOCK_H_ + +struct device; +struct mock_phc; + +#if IS_ENABLED(CONFIG_PTP_1588_CLOCK_MOCK) + +struct mock_phc *mock_phc_create(struct device *dev); +void mock_phc_destroy(struct mock_phc *phc); +int mock_phc_index(struct mock_phc *phc); + +#else + +static inline struct mock_phc *mock_phc_create(struct device *dev) +{ + return NULL; +} + +static inline void mock_phc_destroy(struct mock_phc *phc) +{ +} + +static inline int mock_phc_index(struct mock_phc *phc) +{ + return -1; +} + +#endif + +#endif /* _PTP_MOCK_H_ */ From patchwork Mon Aug 7 19:33:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13344846 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F16FC168B3 for ; Mon, 7 Aug 2023 19:38:14 +0000 (UTC) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2046.outbound.protection.outlook.com [40.107.104.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEE9A1BD7; Mon, 7 Aug 2023 12:38:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bbwTMNOwmjEocb36i1eD5mehWn4bODRtDOhaJtSGi2VzZ6jjUqIsnusbvU9lmYvy4oiDaxZMnowu4TLyb1Y0XJTw+EKwlJSh8lXJUiLdBRU4ZOjt1fHmztmQ2RtccT6LJy8kMnt86lI+ELOSrFIg9fQ7QKTd0SZB55cHXA4/rIIy8XeOhvBUhqElG6r5UXdLBMdHYFmWqnDMkHqNRTfSqCSp3brk2lSObX38yznV0s9rsL0YvJd7i5DDRA5UcA8029vF+rUXMCAHhMep7eEpEzOdY3dQ3xOvyXpu+/w7vaM5bx7VEiV/SoUd5hdP+hGw3NpmzMJM769qmtA2sDUkmQ== 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=XfJPKgZjo6ilxMpG0/qkczuBn9OzDPEQf75G/MfVZSE=; b=BI5FI/TaI+GGDEmapgckz+ztJUWxJ8nutPx/aQJEM4VST0tTDPjC+fOyxxiYPON+cqxaJIKbNwDq4KFd20fD3oX9qQhdlrtGpO9m1yx9vruYYoCKbmZCdKAiLxgXMqrAUldpGsN046ksy1TS9T8P+YJgLVFusn+vV+xsoq2/FG0zEwUSsfqIdqzpVQhbIkKQHWl8RoJjAKDHa/VZ48HulT2hl14XM/ORmhWYHp1K7KhKlblhgHTbKNKJtr9L95y1PCDJBaO+yUgqJvll+q4cBMby1CbXp8tmuo7X6fo5JgJbYdeyES38VLMLmaxUO0HJEata0305yiwRtdLax/kklQ== 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=XfJPKgZjo6ilxMpG0/qkczuBn9OzDPEQf75G/MfVZSE=; b=B+xHM59KM8p1Gtwk+0axclzkwJ0rz1ak3TZ5XPUU8dRs5qg3i63lNtM3B+5KLM/w4ZhfV529UDPmBbRLKy5bNyQhNScJrsp1J5iAre5IUaQFhhAHHnHBgqZgeRmgDBPiL7liqd4sYKHrSNjDYvNFrGxdpNTAhVqGm3FyfcAVeCw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by DB9PR04MB9451.eurprd04.prod.outlook.com (2603:10a6:10:368::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.26; Mon, 7 Aug 2023 19:37:40 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::d4ed:20a0:8c0a:d9cf]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::d4ed:20a0:8c0a:d9cf%6]) with mapi id 15.20.6652.026; Mon, 7 Aug 2023 19:37:40 +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 , linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org, Muhammad Husaini Zulkifli , Peilin Ye , Pedro Tammela , Richard Cochran , Zhengchao Shao , Maxim Georgiev Subject: [PATCH v4 net-next 07/11] net: netdevsim: use mock PHC driver Date: Mon, 7 Aug 2023 22:33:20 +0300 Message-Id: <20230807193324.4128292-8-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807193324.4128292-1-vladimir.oltean@nxp.com> References: <20230807193324.4128292-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR01CA0136.eurprd01.prod.exchangelabs.com (2603:10a6:208:168::41) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|DB9PR04MB9451:EE_ X-MS-Office365-Filtering-Correlation-Id: d79afeb3-33ae-493c-f6a0-08db977dc32b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /dpqiaiEwORhhPRtL1De0sBK5PQTRNQKyPjYOdNxs2ORzSm/ir8MsalXwo+rVntgiUEr5VvwBT9BS/ARjabVpucFcXgV6VjM/mkpQ2k7wdxij6CNe/DX+sxiCj+CpR5ZkCIYWbSYrK8/TT0XHfEdWd8As0pUJM3yjvIDx9ClL9/YyhAi1RIi6znKCbGyfDGQwV7C8RmbAlr3FaELhR0bcaNfYg2P2nUGbRdzro+vHRirCQzjErSjs3qU6jXm7wN013qy1FSVHNFHZE+vQrXPYqju2sH9EaCxsdPvQy7q1XK6GleFhrvIOcK4Mk+zRlfEtAh9qrU+5O/xjTGyv1CBCJqEP8jxOSsc7mzfFy6XEbej4TH5pqKn5UKiLXLyiaTMc3tYyojYGUycl0ScfQKAyM6HVSXmwmFNzDj88I6RqfrUdo9xhe9+BUUvDGctC1+56Blnr8PuAW5xdOeFmPxKXgsJdp8v5yf7jnJ5BoUZzCmrLcKra6t4V4c3eZiVSSQKVAbKZX9HlYH3J9QIM70pY3GikXRm/z+hp2/NCP7ist+TZFg5JVo4gOAwj/4t7lw4DdjwsrUxGBoIL+WM8uRJlvH21udfukqYeNGZNtcwc9zlLx4EpU/uNnGJcmmXFYZr X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(39860400002)(346002)(136003)(396003)(366004)(186006)(1800799003)(451199021)(1076003)(41300700001)(26005)(2906002)(5660300002)(44832011)(83380400001)(7416002)(8676002)(8936002)(2616005)(6916009)(86362001)(316002)(6506007)(54906003)(38350700002)(38100700002)(6486002)(66476007)(66556008)(478600001)(52116002)(66946007)(6666004)(6512007)(4326008)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: q6Nu/jo2Z8Dv77LTISbxVb9rOoMCq8IfetPy23/n+Ohhs1oihbUhcAsx6Ki9PvFNh8+QYIab6DMpYPZrX9SuLJGJjBps+uZmPVVPUdcsCleSBPQtSEOg487GkzDKI3mbhtnyxXCs8oW1Cz0YSUpBNK3gNlq9S/KzWWmIK2s59/twCzgV5+UJ6ftA3hqDg/blshe8P/eHLXZrZixiV5sgLXffdmQiy1BMHPsgU3XHXfKJ9m+SRpvkqFMLBuI89NymvTPQovEXhiwviQyXMGiI84Rd7XuVLEz9P1RjHOEnLgDjxL7bxlQ1q70syUKIYeO0hOgWVqcCDFLiNdRHHKgKYNSh96VxeouYr+eq85U2JPocKrm2jnd8cMqYsvG7ZkfKYHG2XVcXGJ1fdC9c7eTz58t9nvkZzYIAyNaAmcdauAWpahJBhQMMEHJnuy07vr2VgCdiK6D1QULG3ARjRjrMP+807qSTJLgbrEYrvPAZXVMzEtwDOwDqQR3c/qeYAoDOb10pLMjaLVoD4OsKHW1IVQOhMJYD4Sd6w9kep5nasDvQGBU7ZhS4V5x3wyWZ3lZTePE+DwQckO9hZo1wCVwKlU/C5kX/mhU7nZaibAnBWn5uuAiX6s2y9Eb/6fueIMWR0d9JaHIAb5cshnM00p/zjrfsMwlIXiXORE2/gykAs/jH/og0giwXIz/gnBnb/tIXOh+UvRBFgru9IwkYcU0nemNbPTj2GZ6Q395ySAAhZ2yrcLg2O9BZDu5S9ZnrHNCEp+1GaXurVdFjuvwR6AHoHAtUzdHq5iFCtWoKK/vqu/qYjt5MrpPx7dUzZ677x2ZS8atEDOPu61A0zsBc2R09/TWzoEQKQJrhDcYsdm8RXJignW6HvpM5PTW0/mu7ZkRzLoXoMyiICuBPuXvaT0izguavAkjY8+o9t6l6aeDzI1lmEaROG9TnniW1GUkAM3ngPX2LrXPttR/wdMf7EBR+UUtS/jGIO8WkuEOmIFtnQg9fTZUrAE687VX+anOE9hJ5OibsLoNQkQEKfMC4BknFkze2KPenMH3MzMgLbNdKPI1xAqc9YceFKt6uO45dN14GgOcsf6T/J9GEuyIrXusMeEQz0hX5+md5tbYfR+BGaOe/gyVRoCHdKN8A3veBrSHlxrQqyyC32gnXBDnn9eRG658ah90iJ20KlWjHW9Peyf5h/n7Os1KSW2gPxSbmWJ2xPC2u3Zr3DEKuF65mlpXvLELhMzFljegPhYCnbWaJJ1twGLe6dX+pmb6REX4c55VvkvMx229Kqv2NHTeScCzgrXyaf9l/HlitC73Sj/iG/1ceH6AM1PJziDgbkEetVfU81/jmGxHyPWeGcz2IElPkF9hdIHXCk3Ll7/mbaZoaK2/jze3I0YD38hWyfRKeKKewb2iLWdAKtOASrP2B0cguExQOmjajsqf68ttOUXCZvp9iiGyyYEfCZ325FI8lMLJxQ4t6Bcb3zx2Z1swSdMeHdWv4Ft7XR0myw5hjrEHVjQgfnH6Hd0FPmUP0WsBX8gog/8lqrxVWe4aWtox428TyEKswS5M3k6fCmc0M9WtlHK0a+/2IvNmbo52ZBj5hqSzvMkARRDz290Aw2yUGXcOjNg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d79afeb3-33ae-493c-f6a0-08db977dc32b X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2023 19:37:40.5551 (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: KnKInOcUNR5KtnqC8+yAlfBIhU8HoEM6/qeof39WqLpUAtb/Q8sDMIuEyf58MMXFOIq7822gxVjyKFzqLXBKMQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9451 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org I'd like to make netdevsim offload tc-taprio, but currently, this Qdisc emits a ETHTOOL_GET_TS_INFO call to the driver to make sure that it has a PTP clock, so that it is reasonably capable of offloading the schedule. By using the mock PHC driver, that becomes possible. Hardware timestamping is not necessary, and netdevsim does not support packet I/O anyway. Signed-off-by: Vladimir Oltean --- v3->v4: none v2->v3: split off from common patch with ptp_mock introduction v1->v2: patch is new drivers/net/Kconfig | 1 + drivers/net/netdevsim/ethtool.c | 11 +++++++++++ drivers/net/netdevsim/netdev.c | 11 ++++++++++- drivers/net/netdevsim/netdevsim.h | 2 ++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 368c6f5b327e..4953c1494723 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -592,6 +592,7 @@ config NETDEVSIM depends on INET depends on IPV6 || IPV6=n depends on PSAMPLE || PSAMPLE=n + depends on PTP_1588_CLOCK_MOCK || PTP_1588_CLOCK_MOCK=n select NET_DEVLINK help This driver is a developer testing tool and software model that can diff --git a/drivers/net/netdevsim/ethtool.c b/drivers/net/netdevsim/ethtool.c index ffd9f84b6644..bd546d4d26c6 100644 --- a/drivers/net/netdevsim/ethtool.c +++ b/drivers/net/netdevsim/ethtool.c @@ -140,6 +140,16 @@ nsim_set_fecparam(struct net_device *dev, struct ethtool_fecparam *fecparam) return 0; } +static int nsim_get_ts_info(struct net_device *dev, + struct ethtool_ts_info *info) +{ + struct netdevsim *ns = netdev_priv(dev); + + info->phc_index = mock_phc_index(ns->phc); + + return 0; +} + static const struct ethtool_ops nsim_ethtool_ops = { .supported_coalesce_params = ETHTOOL_COALESCE_ALL_PARAMS, .get_pause_stats = nsim_get_pause_stats, @@ -153,6 +163,7 @@ static const struct ethtool_ops nsim_ethtool_ops = { .set_channels = nsim_set_channels, .get_fecparam = nsim_get_fecparam, .set_fecparam = nsim_set_fecparam, + .get_ts_info = nsim_get_ts_info, }; static void nsim_ethtool_ring_init(struct netdevsim *ns) diff --git a/drivers/net/netdevsim/netdev.c b/drivers/net/netdevsim/netdev.c index 0c8daeb0d62b..2a4a0c4065cf 100644 --- a/drivers/net/netdevsim/netdev.c +++ b/drivers/net/netdevsim/netdev.c @@ -291,13 +291,19 @@ static void nsim_setup(struct net_device *dev) static int nsim_init_netdevsim(struct netdevsim *ns) { + struct mock_phc *phc; int err; + phc = mock_phc_create(&ns->nsim_bus_dev->dev); + if (IS_ERR(phc)) + return PTR_ERR(phc); + + ns->phc = phc; ns->netdev->netdev_ops = &nsim_netdev_ops; err = nsim_udp_tunnels_info_create(ns->nsim_dev, ns->netdev); if (err) - return err; + goto err_phc_destroy; rtnl_lock(); err = nsim_bpf_init(ns); @@ -320,6 +326,8 @@ static int nsim_init_netdevsim(struct netdevsim *ns) err_utn_destroy: rtnl_unlock(); nsim_udp_tunnels_info_destroy(ns->netdev); +err_phc_destroy: + mock_phc_destroy(ns->phc); return err; } @@ -383,6 +391,7 @@ void nsim_destroy(struct netdevsim *ns) rtnl_unlock(); if (nsim_dev_port_is_pf(ns->nsim_dev_port)) nsim_udp_tunnels_info_destroy(dev); + mock_phc_destroy(ns->phc); free_netdev(dev); } diff --git a/drivers/net/netdevsim/netdevsim.h b/drivers/net/netdevsim/netdevsim.h index 7be98b7dcca9..028c825b86db 100644 --- a/drivers/net/netdevsim/netdevsim.h +++ b/drivers/net/netdevsim/netdevsim.h @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -93,6 +94,7 @@ struct netdevsim { struct net_device *netdev; struct nsim_dev *nsim_dev; struct nsim_dev_port *nsim_dev_port; + struct mock_phc *phc; u64 tx_packets; u64 tx_bytes; From patchwork Mon Aug 7 19:33:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13344847 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8286D171A7 for ; Mon, 7 Aug 2023 19:38:17 +0000 (UTC) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2063.outbound.protection.outlook.com [40.107.104.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA0361BFF; Mon, 7 Aug 2023 12:38:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Hrf3OFLR9gemHjZX7Vsuo2EQwGm2hHmDELFrPEnDHuo6XdEQVYvLdtWRgH5y6gbwAv3rGZDYeiFsomxa15p4GOU6L21ndzMrJFDvISCdmIwFZ58CJQrst5D7mEAzmmGCkFKkIhO0GYea6BvkXOwq1YMwWuGyKdKU9VOGQHsp6bk0cV+W4IxPGfd/G55L1rjQXvjupokNnZ6qKDev2cLUlXK/n/lD8OTjjcFMr9YjtaAamo/n904H2FOUzt3ahx7FirfGfieitctDMqbKS+OKqI6gcmdor4uSp1KzXZf4nsbzG5kf+J2AGR+zRL6KyiCfx7I+ANTZ6mU8TVcrFobqiA== 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=G+bU1uxiNPiImEetcfeiOA0elVzTOu+QmBn2RC/WRtA=; b=ChuO0BlOXwS86sjZ6BizRbTPshsL6eybqBE85RSzkAADWXMft/k+owSK1TLK9tF22aVKXaifeh7gRh57doNGXskuATdB32delVd9VK5wwMIBCjCgFUIfIE2BZaiGqN1VOWA4rAqQqBKOcowFjuNkfziVAboigSoIx2UJZz5Cp5RtVELmuvWenAlBBMyQH2zzBrUDUZtZu7KdGXwb4P4sHj9FUguqUjSeDuKDoKPlV6GDkuAqUnWZ4wHqLBPxzXoNQXmW7hGM64FMlA5lKfoYxioFqs63RE6iX5qzw31ShRQ/JwrUZpWOiLozbZugOfwWc4d+gxk+/uX5hU3Tr5jV0g== 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=G+bU1uxiNPiImEetcfeiOA0elVzTOu+QmBn2RC/WRtA=; b=OS8aaw9o3cVgUMVuy6v8rZF1iPh1YPV2+52qOmWFYJ+VQ69EwVaO0HHegrvGKNbjyUZnadbG/QV1lFnIbadV2Fk0POjNp6zDiPfDEhKoqZhAKJMmqdkTNZnjp80VK/skRlonw+7Cd3oQuzl0h5+W9tZF+r3sQTp2JDGskCBPKaw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by DB9PR04MB9451.eurprd04.prod.outlook.com (2603:10a6:10:368::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.26; Mon, 7 Aug 2023 19:37:41 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::d4ed:20a0:8c0a:d9cf]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::d4ed:20a0:8c0a:d9cf%6]) with mapi id 15.20.6652.026; Mon, 7 Aug 2023 19:37: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 , linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org, Muhammad Husaini Zulkifli , Peilin Ye , Pedro Tammela , Richard Cochran , Zhengchao Shao , Maxim Georgiev Subject: [PATCH v4 net-next 08/11] net: netdevsim: mimic tc-taprio offload Date: Mon, 7 Aug 2023 22:33:21 +0300 Message-Id: <20230807193324.4128292-9-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807193324.4128292-1-vladimir.oltean@nxp.com> References: <20230807193324.4128292-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR01CA0136.eurprd01.prod.exchangelabs.com (2603:10a6:208:168::41) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|DB9PR04MB9451:EE_ X-MS-Office365-Filtering-Correlation-Id: 4ed35dd2-3039-48e5-3b71-08db977dc3d5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Zyd+9WWe7mSP2S+Cv+RPwzCTvgKe+T85y36TSqcTW02BgQHheCUw+b5vaVGZfn0JzIJYVemDzk6w9oT52/bDSXQX4uDUaee1bkc8ry+hV4NaelvppV882FT9g6KaTRuIcxpKsaKvBxSlPzZIN1flvhukbqFf+jSM/+76CD1TSptBNMQVA7Nxrw3NrG/Dl55/QhygIyhqnb0437jTgytYkazjSjM5x4ye/SPqACFLtf+SqOWYwONy9wVX0kvRo4i4MtAWjO5nZZFmkF3oLo5nZUqjrDHZtCEYK+WrCO8Dl3oLSnly/sJcQo6zb1EruBuymr+AKZzYtCRY7SdwFckni8e1L0bHaROKh3PkcWKV5SPEFpfcz4TCv/nOW714k92r12KhZIatQjM8HUOzXm4divlPNatUpK2z2eijiY5932xkfYoI0eoML29xPHfnfmg9R8/7S1MQx4novDovbbpB81MUNhVgBJTcLZ2jRC7Jbe3MzPpjLqNPYUlFnbQbYFTyEKTDm8pZ1FWwnEOpqRZ7qU3RrVcRcQUR/6wLlDTG0YMjAwI0dHOF/RZejxlIR1h6578QeGuTxTJ0Xlb5lfObD/iaE8UJ9CpOqBqz9EOaCYYLUTjTY2PddPjs20hm+oLF X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(39860400002)(346002)(136003)(396003)(366004)(186006)(1800799003)(451199021)(1076003)(41300700001)(26005)(2906002)(5660300002)(44832011)(83380400001)(7416002)(8676002)(8936002)(2616005)(6916009)(86362001)(316002)(6506007)(54906003)(38350700002)(38100700002)(6486002)(66476007)(66556008)(478600001)(52116002)(66946007)(6666004)(6512007)(4326008)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wkX7dXyLxA+Owy2yEFGh/GJ2M3TLD97BiwetmJkNYaK6++BAw/CmhPu3sTMxCX1pTzMFg8YH/CFrcY7bGb2RjtqnaAuOAlODwZTbCnOZjdKGfj4ANbQq1UuIWZTX8WODrogz7RWiKVrEQmZ/fzyZOvr9r3Yc7Znvp45813xzDLqVPDrxVGKQiygA0czvNCwZ8r346evRXjiHNapYFcTwarVN6ubY3zms3MfB2CFExY+a8GSxQv9+uQMNl3ALEL5A+/kbjmuinsDWRw23oSnALRnZcA0MYIHhmUfuRabH4OsQSi/b78oR/3xdgqLrA2A+PSNFKH2KK1UsAu5MXC46VfYf/icCxWhu9ouyayU0f/RL+stLNY1lk6cVK45noxZ00xYJACM0UsO2jngNYmRqP5f5Kdtr6rmu6V64lJovuiF76BQ8HPznDBazF2Z9uF2/iv+mrjHWJy/BFyEbebtOJX2RsYwcN5xbalWd0d7FsKuWto9mh3dnsVJjPJlkm+kzjEeUVaF455u54syrhohUPyyx11F+c8pMKhlLUFmBdiohesfXCpsmBPvYTG/akxbrI9SDxuiBOqXHx161wPaPiBQK74VGPWXHgXfitWQc/1262FSCov6nWBZBP1ZNjUwoOjgmayCRGyocakuYaUliG/NFf0zRwqS4gXnYl4wk+4leY5iHJca9Yf0Wzu+Dy0W0dr3KASdA3414SiLMXsJLB6X4ENRhEPoIQmF6vB6WVnZroRk5Z4PbamchM11iE0zRDCMq4IVBvlHrjETXpeZcChpQrexY65/UpeHPdBdKsfcAm55/fhulUS4+KdO+qjiBzg/SM2LHo/mJwZxE5ZerLi4apIAdXWC3FiZd/7qLL+pOl9xag1gOdKBrblaFARLBi7ESRrHAlbfzLuY75jlCoGZ2VEFHLTLi/FGCyoHyc+LKAHsT0rnoSTn3KKU/dy5IrSl4EERY9aNy7Y38PrY29gVplMLP/Bxx/g19NwhqfNtsLGxVVGhpq0gmx0tqSHArjRcts4yBmihU0dUkyhTWZzAPGaGP1pAJVinQvdAVcPn+h5jcxZL4kP7xz1Yb8jtVt5fkbsoIPGXQc8aocNmYvYjnixmmVxy8fOpSHU88nwpu7NvA4O2U++NlO+uKk2RaxrxV8rWhPKNboyWf9SQg5xka/WzUHLrP+gWFAulXDpf+iV5SOwCoLdDO+VnBuSFy7wToaCvxB6t7CozA8E1lPBfEuUALWdV3JSYXlqExoSRmuMyLJLZmnpYepNJJQlHTOA08hNTIh6RiTy9X1x6sWe7xMShC8wAldKka0OYkXymkSic//bkIjrfAKFLSKssLH/81GDyBpezruEEK8NbTUFWDeBFEEvPtp0lrv1xqahYgcmYfeDqum584epVYF9MvLsM4SZex0xQ1aWM0/CALRFOigHsTLE3WVikM+OuYjPFimrliCayCYeLAmlSBLgzX1QaffkMO/V59c/CGTAJ8/0bRdOWSORVVGejGDak1Xua2HNAj71alHqCNi1Pa5u1L/ZlJ2h9xksRlHDWzEahYHvHrv6GF7SWg9vPTrZ1C+djkGzi9As6cuorzKaAKCOu2kjqLlmxG+JI0PJnlRrszIQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4ed35dd2-3039-48e5-3b71-08db977dc3d5 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2023 19:37:41.6851 (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: 7ThjjrAkJIvCun5qa8AswfBkVkYQ8P0agMfuPf0aSQrKHrxS9d5KCBFjUG9iaq12qof+a9/UpXlzrCXsa2cX/g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9451 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org To be able to use netdevsim for tc-testing with an offloaded tc-taprio schedule, it needs to report a PTP clock (which it now does), and to accept ndo_setup_tc(TC_SETUP_QDISC_TAPRIO) calls. Since netdevsim has no packet I/O, this doesn't do anything intelligent, it only allows taprio offload code paths to go through some level of automated testing. Signed-off-by: Vladimir Oltean --- v2->v4: none v1->v2: patch is new drivers/net/netdevsim/netdev.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/net/netdevsim/netdev.c b/drivers/net/netdevsim/netdev.c index 2a4a0c4065cf..2eac92f49631 100644 --- a/drivers/net/netdevsim/netdev.c +++ b/drivers/net/netdevsim/netdev.c @@ -209,6 +209,31 @@ static int nsim_set_vf_link_state(struct net_device *dev, int vf, int state) return 0; } +static void nsim_taprio_stats(struct tc_taprio_qopt_stats *stats) +{ + stats->window_drops = 0; + stats->tx_overruns = 0; +} + +static int nsim_setup_tc_taprio(struct net_device *dev, + struct tc_taprio_qopt_offload *offload) +{ + int err = 0; + + switch (offload->cmd) { + case TAPRIO_CMD_REPLACE: + case TAPRIO_CMD_DESTROY: + break; + case TAPRIO_CMD_STATS: + nsim_taprio_stats(&offload->stats); + break; + default: + err = -EOPNOTSUPP; + } + + return err; +} + static LIST_HEAD(nsim_block_cb_list); static int @@ -217,6 +242,8 @@ nsim_setup_tc(struct net_device *dev, enum tc_setup_type type, void *type_data) struct netdevsim *ns = netdev_priv(dev); switch (type) { + case TC_SETUP_QDISC_TAPRIO: + return nsim_setup_tc_taprio(dev, type_data); case TC_SETUP_BLOCK: return flow_block_cb_setup_simple(type_data, &nsim_block_cb_list, From patchwork Mon Aug 7 19:33:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13344849 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C37F016417 for ; Mon, 7 Aug 2023 19:38:24 +0000 (UTC) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2046.outbound.protection.outlook.com [40.107.104.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE9401FFC; Mon, 7 Aug 2023 12:38:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZeIpxcy62o39xSVdIHpfAyjFkVNYjJT+Cxy16i16UcJDlpOdZ1BuRcnwk4aGfbvxNalS773TavzFXL5Sys8/6gmlHplDOhwjg0RZtAYXhAa00zAFkGv2TsNy91wvcLyomUytM9Lp1p5cK6Fc6oy6N684HSdmPaB+OxgoBjPydCIVHKuvujxrHQtqf8fRqgrbB3lVZEsD7PSjYtfRBQRWXAcDMMd46pTflhr9wLSYrMRL7Z2B30PbVmmA+6vtMHz53QpoOOXVbRKYoKqnCZoSewXS1qYZnRKeVT7q7j7NzVDNPKsValHliKSd3JGVv6OzqRz+6lhQOt0c11KNun+kBg== 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=Ec+hvhmb1NwBXUODdrdxAAF6frPZkuXpBjTF2kk5A90=; b=ZwQ3iEjdJXcHWaC7+eXWFtlAiGqFeoM86t4P6VHdUL7TfaJxKmo0yR/TYZyRS8LXcp0HfIP+4EgsgP9DO3JQzfsYyzr5E6b5R7EmQ94Y5pBIZWPrjYRBODq1MRf3tr/b5QG+Rqvj4Omab7H4amua/Bss2G6gdvd3SLdltMJZ+uAqnFFeV5iN2yeXhwOfKXJE9d8Ul4yf/ZSdcvo3beQfO1JzslYJ82hqWq+S8wDd3TVoIk+Hw1sxDocZ3JyWUj26r31ukX7X7DMWCpZBGrTMxKeDjVc8Xji1pXRkc0J6WVsnZZLkoPrRb+WO0Y2CzQ70/KI83QZemLpPqGiWHgGAmg== 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=Ec+hvhmb1NwBXUODdrdxAAF6frPZkuXpBjTF2kk5A90=; b=OFbysyCqBRRjwmNbNpmtXt8MnId5CG+Hkd3nEhHh/yKAkW4+2BRWdQJxUxWH1Y48/9lOO7y5xJyowR7gERY757ok4272fTxpf6giJ9UiMrZIKNboBiNp04GOkZE7NARbRipECvgvmvywvKZoR6z8VpmEbdNjyyJcsZj9es6Ym+w= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by DB9PR04MB9451.eurprd04.prod.outlook.com (2603:10a6:10:368::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.26; Mon, 7 Aug 2023 19:37:42 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::d4ed:20a0:8c0a:d9cf]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::d4ed:20a0:8c0a:d9cf%6]) with mapi id 15.20.6652.026; Mon, 7 Aug 2023 19:37:42 +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 , linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org, Muhammad Husaini Zulkifli , Peilin Ye , Pedro Tammela , Richard Cochran , Zhengchao Shao , Maxim Georgiev , Victor Nogueira Subject: [PATCH v4 net-next 09/11] selftests/tc-testing: add ptp_mock Kconfig dependency Date: Mon, 7 Aug 2023 22:33:22 +0300 Message-Id: <20230807193324.4128292-10-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807193324.4128292-1-vladimir.oltean@nxp.com> References: <20230807193324.4128292-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR01CA0136.eurprd01.prod.exchangelabs.com (2603:10a6:208:168::41) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|DB9PR04MB9451:EE_ X-MS-Office365-Filtering-Correlation-Id: 04863b86-9d9c-435f-0998-08db977dc488 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: McfWql2TkZYnz0orXTOgtNvNcda/xnHkZFUGvrU9VsLQWmt0oxrTWjQVKjifS04fIbrpFiy+r32LHhSNovfJj+5tCxsqOk93Pk5+zTwesbEsys6bixdBDBkenuJrg6il7hU1MCd8R82HLC4IEXDxdAPwSjw0G3IS7EtoTdqyeauCnp8BKnHmD41eCMv09fchQXFBSkEwuQ3RIshLcA4WJe7V46jgCcLUSRJ+o1yirM7ycHI0q09Vy5EjlhmPIiMbIvdFn45Yw9meiuVH9lF94wSg1FyXHp/pkDZ43DIJ0UxrT3wqLRvL8PxzhAwDUiy3MYSw3y6NTaJdl/YDRLdFZx9ev4kxhbF/03w2PbMxsVBwKITbxXE8MoRRWm+65RO5RFvVdfoEl0mRXthFlNJ2k57wvTlxyVw0Jy9HXvdzPfhup8u+02/AsSHS6KqI9AplZJaBF4aEJBAYF4u0JYoSgogQWiIAr9uwz7uEfrKrEv6P7XJFgLrt5ZAiMXv7hQxCmndWAdPdf0Jt4RTi0Z0csEABEhF/7KsCUcPR7Ivh+/R7NT6WZdvNJc9Lx6c6IXI9x00MCom8ZMdC1+3GIO8rtNT1BmylnIe4LmpJ+Vd8wODZMgBsuckG1Cw0/+SUdTAt X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(39860400002)(346002)(136003)(396003)(366004)(186006)(1800799003)(451199021)(1076003)(41300700001)(26005)(2906002)(5660300002)(44832011)(83380400001)(7416002)(8676002)(4744005)(8936002)(2616005)(6916009)(86362001)(316002)(6506007)(54906003)(38350700002)(38100700002)(6486002)(66476007)(66556008)(478600001)(52116002)(66946007)(6666004)(6512007)(4326008)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IvcgsayO5XijRQ+jLGsD2jEu+MaUOiZRuD5e11b/3aSdWMOBK4b6Z4bBFHXgPko82sXb3EyIlAtWlofVtyFFSuPiFvscG3NqBhQpOXmwN1/ElxnxvDiemNZrrq2LxtctMGFpsp9fB7vDCouVnRTDhFuK2j7vV4V3NPPgnziNMYuBhli5XF3W2pZ+zgB9dMSOpnyk1YJB5wKssm7LqY2yDHjMQb+w5iuyBqDB1kFW2M4Ldz8/MclSC+RWrDHopQ9AdDoSpJosIgme0/Lu4/iIsiwwwSlbnk+cxFpKj/0WfnSoqTm9FKk/n00e4lZFUFH1zTEn0QBZTGzpuBTwuuGafnrMRef9EathS3nS4gAsA8d20jJa99BKyFY3g2BPIixsACZ8xlzuIJffHjP6K9DVmJkb4bYs4YK89NPtT4EWy+kR9Da7I9EzlEMt0lvEJTw++YHwfmCytJMf5CjgV6TIqwFnCJS779Qj3EfmBlTC6OdF6XhQkMGmX8eMkxbIOawn3OoQ1hIpuHJa88Yjt/4kWSo4SaGzCIWFYVcwi7GOOwhl8OhdmsZNNoWjAR+r+IgLs1KJzYSCuWjTKx1pGE4bQqF8/q8BqjBxjcPbSQOy20vGXwQ1csFinpTDE8qjJz8RhomA8bWJVNTBqXk3wxEJIp/LQZkaWx/ydNOFNikrLCKI+mrJbsMobNRvffaQKZ6hLJXd7ZLeRkFiFMBrq542cyXhNQ8frBarpsCWwiZEgrb7k19Ga54ENZygAkTkoWuJxjTPGgCMFXCpFb5qjHVser47W5uRNMdimCmxsALwLjloyCTDPYszpFQym2KIEQgit5JMAIK/k3axynhauV8mJp7U9G9+LvplSpN8NjSHyWY9QOclaZCjSVdf9oU6NrQp8L6DI2OvDC2FbYMhuSdojBqx8lirCEYRuPVxK7YuuZnEQaUYymF2njxP8GrgcZ0rBUCLSKWYf4vTBcT6NglBLqyjPA20lAcmb2TuVDikLQEyh08PI7F7tSwwt3Sp1PU7E/qmEqxYZ11kLusgqajBOq2/mWmyQcNDrUNqiXO5VFxJ48h/ORElPDxBV27qJx4VNccHjEI4NS5A08BhCWjYuCWpiLmlmLwq8HqB487N9MzjeJKPonFrbiuxmCnbxtix+yliPsaSXtGt4YoFYAYofGMkdTRU+ssGTIHxHbz0l7p9HpY658slRz2bDIKrSzEuQfZv8Ca4TS4KhAJVespHnTE9tzgfZcYYoaCWxc35mqimXVHJBYw6Obdh6QjH53bnxUAYq0O9TisZOOi3J9MDg5C71SydCrHqPkljx2g1sHM0Nq9kzfG9+tWdovf1KvpHqK8ofzyETHnU6FcqDxsA4IyM3IZIuVraKi7vox04xren1kc3fU9A8TTPRJF5yYngc7JyLRmtR6G07tPX7dBTml6Vd8kGE0go8J/CRYBmoiZiLKqHBF4XbtXfn+uydTgjeROpTJlj8vBrLdExGEAEcYPNa4Z74FecOB9+AkkWAPIz3hu6GMujGTRTsLTSsOgn7TEfsqVRNLD6odywgPzKSNB7FSWljD/VDRx5HhGvd2kIIIgmpHLykNO8kY9Fi9OzivLetM8yFMWZEkCKLCMK6g== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 04863b86-9d9c-435f-0998-08db977dc488 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2023 19:37:42.8449 (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: TDFosRaq86HeAlgadBmembILNk+XdIw4XGPOvFEAQ+AqQUQtkyRLXXETpy9hu6dh4UJMyH+xu5E87F41PWlnNA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9451 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org For offloaded tc-taprio testing with netdevsim, the mock-up PHC driver is used. Suggested-by: Victor Nogueira Signed-off-by: Vladimir Oltean --- v3->v4: patch is new tools/testing/selftests/tc-testing/config | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/tc-testing/config b/tools/testing/selftests/tc-testing/config index 71706197ba0f..5aa8705751f0 100644 --- a/tools/testing/selftests/tc-testing/config +++ b/tools/testing/selftests/tc-testing/config @@ -96,10 +96,11 @@ CONFIG_NET_SCH_FIFO=y CONFIG_NET_SCH_ETS=m CONFIG_NET_SCH_RED=m CONFIG_NET_SCH_FQ_PIE=m -CONFIG_NETDEVSIM=m # ## Network testing # CONFIG_CAN=m CONFIG_ATM=y +CONFIG_NETDEVSIM=m +CONFIG_PTP_1588_CLOCK_MOCK=m From patchwork Mon Aug 7 19:33:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13344851 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 42DE9171B2 for ; Mon, 7 Aug 2023 19:38:34 +0000 (UTC) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2074.outbound.protection.outlook.com [40.107.104.74]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A99CD210E; Mon, 7 Aug 2023 12:38:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YqSt/FMT9/09rCOkXl7L6Zwz4BPAQcGj2CHLl2edE5JB6WW4ZxVJ9s0cktBxcuv2F9vA9VMnvEXJ5gyx0xt+O1FUBQoQQqfiuEkqHU5fMyJBkL+6Tj8WgzccbN4SUEC1mYdfdduAUa0yiaLmhfEdB2rDmWSAE43gYthqv7ZwTgGFs7xQ8wRmuRrYC/o5MX9OC9lSh5IK5j/5i2Ou6lPV3aQwtR+Bo46xfYT+7cKcKrTDqYYyCOxIDfjVr+Y2WFMYs2kZrvTogm2LrJwWvqR3VY0VCnoWGbbpR8ewUUakiHF9UgD8fwq+ygsvqdX1y9UD/MaItDI5dxDFCKsWqLTluw== 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=kjrN9GQQoUjes+E+zAVZMFtIhSOlOE/TXQ5ItcnhiRs=; b=bZ2AaD0O/gwxxQOrNChI7oUPSPzSCGWDMYvwLRx+bf+jrlo+9zjMTL+egCu/ZFZFEhlt8R74Jv8z08IGTLqCBNZ8Gq9mNC1VYnDGjwibYD2/0mlRKl+XHMdvnyS4D/mGTxfi9zbuUAnwAxmnPc8OUppGm1YVP30CVtqytnOlQBQno3VfByQWyDVBFq36PHu+v8Z6f4W/G5M6O8V2ZjalVk8OignZgPIgOwquxPCThQsewb1aeRGoUJ9e8zHhs6CGkV743AYecv9iP6vZAzYAejgLPZxpZ98ATIyrxv/HUiOkn1SYQKSyDaVC/VMBgWq7LX/IOdguZdrhh4mLb03Mkg== 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=kjrN9GQQoUjes+E+zAVZMFtIhSOlOE/TXQ5ItcnhiRs=; b=fpg6cjLnJWRinsiD0eVTkgit39rs6ZePoFcCfMyKxpd/+B29btsTsyNVXVJwRgpE8q3CmVzsG98QEUIHI5qBTyvCpm+Nzgkb+MqalrJJBbWMu9nZ8mulk6slQJJBsycNlrRc21lhyPn7IY0lTqu0LAZMUvpGS99KILvM7Q6afz0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by DB9PR04MB9451.eurprd04.prod.outlook.com (2603:10a6:10:368::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.26; Mon, 7 Aug 2023 19:37:44 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::d4ed:20a0:8c0a:d9cf]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::d4ed:20a0:8c0a:d9cf%6]) with mapi id 15.20.6652.026; Mon, 7 Aug 2023 19:37:44 +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 , linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org, Muhammad Husaini Zulkifli , Peilin Ye , Pedro Tammela , Richard Cochran , Zhengchao Shao , Maxim Georgiev Subject: [PATCH v4 net-next 10/11] selftests/tc-testing: test that taprio can only be attached as root Date: Mon, 7 Aug 2023 22:33:23 +0300 Message-Id: <20230807193324.4128292-11-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807193324.4128292-1-vladimir.oltean@nxp.com> References: <20230807193324.4128292-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR01CA0136.eurprd01.prod.exchangelabs.com (2603:10a6:208:168::41) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|DB9PR04MB9451:EE_ X-MS-Office365-Filtering-Correlation-Id: 2e2f995f-0551-44d1-7394-08db977dc557 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ayit6om9XjCkI4jDOP5+tqVtf2mvYEiZXfoCQMM5zH8gXlPCkm90HPsV2T10Il6MqQIcSMQj1mgXZuX067xUWJ9s2gJzzV75tP4KMKw9tyd6cEAEtZ4G4+VGJu7Vr7SmoSJ9UWEWnQ9GcXNYxiOzGpEhRvvUUa/bx7F9hQ87e+l+F6SszarswpUe3LNsHUpOpbQf3bQ86w5OxF8SO4nhQ6x3sJZjUU2ZgGd1eNIkdvuWC9E4U09VvRutpjf+nmeNIgJq1Np2bMkzraxWoQBfE8C07a/4mI7FpO/ibbvJYHVDKs4021kwBlI9OS0+t7jqJ+XQSk0iETh73vj0uQaDippVjRwsPCjOeMbVOsqS2InxSmWy7fyDkwIe1yANBfx9YG7Agc+wV8Q5a6OQvlReNOR2yYKAlcERmhMpIUYEju3WKw+d0Nt7IUSw2lf1DcIZPj8ZqEQOryYFm8J+vYoa+F7pTgEmhWoRzbCPFTALucxcJMIPqyZoRUa/CPRtzccjmi5I0v/2r9Nzr2liZRL7eCUqmo5OkX8GdOzeXp6vHQkKdCnDLzc8JbpeamzTsECJICfsdE8ljrf922YTwgoASnUt2Nzt82U3tEMP/ErFC3SdX8SXM4GejN4u+0bITP6M5ITNKhNY3QnDfXgTuCm0DQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(39860400002)(346002)(136003)(396003)(366004)(186006)(1800799003)(451199021)(1076003)(41300700001)(26005)(2906002)(5660300002)(44832011)(83380400001)(7416002)(8676002)(8936002)(2616005)(6916009)(86362001)(316002)(6506007)(54906003)(38350700002)(38100700002)(6486002)(66476007)(66556008)(478600001)(52116002)(66946007)(6666004)(6512007)(966005)(4326008)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NiD0/lpznLJfeeRp9ffS8GIpByRidJ6yoRXAMB6yqRshhyp35QsTFTFyRI+Q4AEGU/8qhiVWtfir3wN+/ps3dNPwhTgOywRw0ofRkkrAJorWOin0Xx0FDCgqfG7SmwI8rs06vssaiUlgLcYGxfKBr/XY1fQ6P/LkbcjUzpDV6FzzTh+bhUkevOiz4ZlFkxOSi+fu5WXSmlvj8LyIwOD1z3M2VHtGf77tAD88s/oc5AtLJGvx/wA9UIW10XcY7zI2t49Xu7i6IUwOGfUrXHWU886Y4LKrUOiH5CEN+a4AnoHyOnQQvwWkKxAu/8AY5sufbmZZK76P2oOELEzJzLxsZoWHGMRazF9y9g6wj8U5RC07+FW2Z/YjuS3v7YRVQ20Q6rSfvMEeGJnuzoI/Kwsil/z4FpJWBxMRIQstgmmS5NRri5mBiqsGp2mhugMbKy+AxaNazLf/LluH8STWE2R9Te+Sf6g3YQittW74aBzGksRvaHNP2KE9XN0ToMm1yi+M1hnTZJT6r55p2Mmf7O2aIBJCbISix0MTgozx/PG7DDKWUwM+6OX8/tuwWKK0bX2GSzOdPzhwQfMzVivofm1Hb5L6M+/bGEFD7M+wcA3Ph1qSiF00LcKRJ55mtS1nWkmMFdNVvnZGdmtW1MuhlSfX+kb3kelh+VidUwSOecTi2oB16FZIW9typdUzhgq1y0CarXosxgzIkCMwAwgkA07fq4H+EwsliveEOIWFMABm+oKLLEdK3TFUpdzGITYwP4Ny60KVqXTKalsMp9QSlToMjwmEfhMo8+b32M6g91dl3bl8Tq2XMDYMqbhkgFKP9Wyb8Z0vAAuJ+S9JPfZbvvXd57j6GRNquFGhcKuNa8iT7WzDc8NuGvFNO5vE19V08Y86ex9hR34HBSgl+TD4ElZswTZmXy1DpxdwD4wmzcdOlbN0OTLcWIWkredQC1dEOSM/ekIH335ZVNSr4XAOyza8eFxzwA0x9hQmARkmoJ/YVhyWz4PEHGtdsxa4t59a/Rrwh8MPpd19vFaCSfnnKP2HlIIi3+JcSrD9a0L8fV0PWB/Y4IN4XDF7XExyeyqu7VSh1/u40807wrXF6Rp61+3sP4nleoSleMSUx4Xs7myIbuVupZiiUV2CBTrjgdQmcQfZXbwsrC0RiJHXG8NuN9+fnrMCKVh1WR0+UcNP0Yc970zxlU+nGWKfUG5PxKlJ3A4pMmQ9H1l+UY45KIYhBPYeuIUbdLWtejrCwv4g1PIsGGn6R+qivwfjR5RtMtn9SWWn1m9Oz9cRuaTtF/IveppcRyRLa0XNZnO/MQ7OE5oOvX8sQZw4pdBSEGK2DMMccoKgR3WaNKlSTSQBj4SS22mxsL1bQq+tYyS+P+xheo74kM3HgljWQuNvvQWsoniNUmJAidscrMp9ZbFFSPPRoc/XrZiGWLjdmd4yNBLlTXKXXv/eCZLOw/lrJJ3Y/BNhKfBtHq7JgLUyt9QoTCLNOTVvJk2ssOb9jhfHSde8h94CjBsaGvLwCYlfz2hGQb7l8R/VEZDeGkcg7nC8OlRfpB9S3kG5EQuLLSxF7q9n6dwOYNowXczUeyFogJ0cAZBNdGv5mMP2lfq6ArBd6lCktFMPXg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2e2f995f-0551-44d1-7394-08db977dc557 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2023 19:37:44.1633 (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: YzJnwEa4RkTfP0/vNZSGIT3a/1hwdSuRac7nbKPV7y1hPGxUQt4f9WDaHUINRkL19f+ydPd2+2rFEp64vCrudA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9451 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Check that the "Can only be attached as root qdisc" error message from taprio is effective by attempting to attach it to a class of another taprio qdisc. That operation should fail. In the bug that was squashed by change "net/sched: taprio: try again to report q->qdiscs[] to qdisc_leaf()", grafting a child taprio to a root software taprio would be misinterpreted as a change() to the root taprio. Catch this by looking at whether the base-time of the root taprio has changed to follow the base-time of the child taprio, something which should have absolutely never happened assuming correct semantics. Vinicius points out that looking at "base_time" in the tc qdisc show output is unreliable because user space is in a race with the kernel applying the setting. So we create a helper bash script which waits while there is any pending schedule. Link: https://lore.kernel.org/netdev/87il9w0xx7.fsf@intel.com/ Signed-off-by: Vladimir Oltean Reviewed-by: Pedro Tammela --- v3->v4: introduce (and use) taprio_wait_for_admin.sh. The test depends upon this taprio patch to work properly: https://patchwork.kernel.org/project/netdevbpf/patch/20230807160827.4087483-2-vladimir.oltean@nxp.com/ Note: I couldn't find a way around the horrible tcmd.safe_substitute(NAMES) and the string quoting (no possibility to perform complex shell operations) than to put the logic I needed in a separate shell script and execute that. v2->v3: none v1->v2: patch is new .../tc-testing/taprio_wait_for_admin.sh | 16 ++++++ .../tc-testing/tc-tests/qdiscs/taprio.json | 50 +++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100755 tools/testing/selftests/tc-testing/taprio_wait_for_admin.sh diff --git a/tools/testing/selftests/tc-testing/taprio_wait_for_admin.sh b/tools/testing/selftests/tc-testing/taprio_wait_for_admin.sh new file mode 100755 index 000000000000..f5335e8ad6b4 --- /dev/null +++ b/tools/testing/selftests/tc-testing/taprio_wait_for_admin.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +TC="$1"; shift +ETH="$1"; shift + +# The taprio architecture changes the admin schedule from a hrtimer and not +# from process context, so we need to wait in order to make sure that any +# schedule change actually took place. +while :; do + has_admin="$($TC -j qdisc show dev $ETH root | jq '.[].options | has("admin")')" + if [ "$has_admin" = "false" ]; then + break; + fi + + sleep 1 +done diff --git a/tools/testing/selftests/tc-testing/tc-tests/qdiscs/taprio.json b/tools/testing/selftests/tc-testing/tc-tests/qdiscs/taprio.json index 860b55df0d6d..f475967c509f 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/qdiscs/taprio.json +++ b/tools/testing/selftests/tc-testing/tc-tests/qdiscs/taprio.json @@ -156,5 +156,55 @@ "teardown": [ "echo \"1\" > /sys/bus/netdevsim/del_device" ] + }, + { + "id": "39b4", + "name": "Reject grafting taprio as child qdisc of software taprio", + "category": [ + "qdisc", + "taprio" + ], + "plugins": { + "requires": "nsPlugin" + }, + "setup": [ + "echo \"1 1 8\" > /sys/bus/netdevsim/new_device", + "$TC qdisc replace dev $ETH handle 8001: parent root stab overhead 24 taprio 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 base-time 0 sched-entry S ff 20000000 clockid CLOCK_TAI", + "./taprio_wait_for_admin.sh $TC $ETH" + ], + "cmdUnderTest": "$TC qdisc replace dev $ETH parent 8001:7 taprio 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 base-time 200 sched-entry S ff 20000000 clockid CLOCK_TAI", + "expExitCode": "2", + "verifyCmd": "bash -c \"./taprio_wait_for_admin.sh $TC $ETH && $TC -j qdisc show dev $ETH root | jq '.[].options.base_time'\"", + "matchPattern": "0", + "matchCount": "1", + "teardown": [ + "$TC qdisc del dev $ETH root", + "echo \"1\" > /sys/bus/netdevsim/del_device" + ] + }, + { + "id": "e8a1", + "name": "Reject grafting taprio as child qdisc of offloaded taprio", + "category": [ + "qdisc", + "taprio" + ], + "plugins": { + "requires": "nsPlugin" + }, + "setup": [ + "echo \"1 1 8\" > /sys/bus/netdevsim/new_device", + "$TC qdisc replace dev $ETH handle 8001: parent root stab overhead 24 taprio 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 base-time 0 sched-entry S ff 20000000 flags 0x2", + "./taprio_wait_for_admin.sh $TC $ETH" + ], + "cmdUnderTest": "$TC qdisc replace dev $ETH parent 8001:7 taprio 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 base-time 200 sched-entry S ff 20000000 flags 0x2", + "expExitCode": "2", + "verifyCmd": "bash -c \"./taprio_wait_for_admin.sh $TC $ETH && $TC -j qdisc show dev $ETH root | jq '.[].options.base_time'\"", + "matchPattern": "0", + "matchCount": "1", + "teardown": [ + "$TC qdisc del dev $ETH root", + "echo \"1\" > /sys/bus/netdevsim/del_device" + ] } ] From patchwork Mon Aug 7 19:33:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13344850 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D2A78171D1 for ; Mon, 7 Aug 2023 19:38:25 +0000 (UTC) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2063.outbound.protection.outlook.com [40.107.104.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8E771BFE; Mon, 7 Aug 2023 12:38:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YO9mfXrF4vBKoVKDSym9u0ZdbitkgkAvsKyqGRLdQPIuV0T3XxJkEHcTF+PEKkATvXOM3KS3TfhA7TIle4oHbJkLivujRedfhuAS9loRbI+VUe/CPSKtUDSTmmywkkjfZPIfcx03n4N9TJiRIovEFC63atz2zSDh1C00UReQmQBSduhz5WBVi8q20Kfl7KTi9BxX+xpwYh9FyvV94KlPBtD5apEiwxkGyn3QraikPyQppiv6JELKmWY4ReahhwMTsSoJ14FSt5ALLjTAsDA0leLDGgHHW43IuoZIpMSOIat2PeIe5rbrtchg/oX+HpiyqAdL+G1MoL1eL9qDLidoKQ== 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=A3xMrLEX1BqcLSxrITZlrQvBSaLNXcOGJHw9v5sDdBY=; b=LBBtWaevY0p5yAOIsGAMIO5emXWdgwIkEzsMc+EKZaIDmLYuUpMi4n0zNBFjeSMtwEAe2lMqRiNfC8SGdrpyUof4Rnhz4ijVS/iXk9C0VyMsBcIcxbew0sokKDr5YN3brEsXVU156/DBt3TQLJfrBdNWW+PrdfrWvjtJp8vIXDLzdX+WLz5Kl6bwra2lRq1sliQs6n55XnGtYLtfr+6dQxY2QQav20/HEoxyd9GvfHArVAkUUDAyyc2+vpZ6dRzXXqoISUgzIacnS/Jiv2haLrmJl/H9cUhXPFTsY7V51nmTE027oy/JQ5mGu5D6XiWWTQf8Va2OYkRVh18lEGjRVQ== 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=A3xMrLEX1BqcLSxrITZlrQvBSaLNXcOGJHw9v5sDdBY=; b=BMBeZZVc23cxdA8pc+GB01SLuQdCJJPtO5bSQ2wsSrpKbnTfnGu0EhkwT/8zidVgozdCuh+zBOHQX4QqDyIF16EZwjhNrA4KUL9Dw+6WVvc6UOX51+Appt5V/5ibxh5SDKhewpUFhrEVoDurtnuOjOKz4fFsIHc0qxCqBjToKMs= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by DB9PR04MB9451.eurprd04.prod.outlook.com (2603:10a6:10:368::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.26; Mon, 7 Aug 2023 19:37:45 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::d4ed:20a0:8c0a:d9cf]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::d4ed:20a0:8c0a:d9cf%6]) with mapi id 15.20.6652.026; Mon, 7 Aug 2023 19:37:45 +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 , linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org, Muhammad Husaini Zulkifli , Peilin Ye , Pedro Tammela , Richard Cochran , Zhengchao Shao , Maxim Georgiev Subject: [PATCH v4 net-next 11/11] selftests/tc-testing: verify that a qdisc can be grafted onto a taprio class Date: Mon, 7 Aug 2023 22:33:24 +0300 Message-Id: <20230807193324.4128292-12-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807193324.4128292-1-vladimir.oltean@nxp.com> References: <20230807193324.4128292-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR01CA0136.eurprd01.prod.exchangelabs.com (2603:10a6:208:168::41) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|DB9PR04MB9451:EE_ X-MS-Office365-Filtering-Correlation-Id: f9d84cc8-35d7-4013-b879-08db977dc600 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JSVevBwQgYa69oIV7J9hZ4EtXSDFcHR+CEqSYHBgVNR0FX/pIogbVIAz4zjaRT9uCqk2JLduXwFRVSnDDYVPq2E5e8Wpq9MNDazoceJJFi2Rj8CXK2CNhPaLMjC+J5GmVl4T9dc53rWX3P9vBuPyDfIIgtouFmjifgSKZMBSf1bE20HAOn8SNhEJ/pM6YcXeAtsypplAHoqHhfk7kFC4WJ4wVSpuaRiFSzX4D6aor2ddE1+4hE+8BqmMH5mDhxBCxqu1igyOzHoCKu5oQTh6isksFxfW2+7CcxbwwiAjWVXI5p2gYv3EhDd0ja2bYgV3CHPYz3eW/XO7VkUlEFpyqjkzUUw4x39HgodY64cG80879REDICRFX8E3VaorMsM376F7hrUa9nXEvEaISowuBS3vYidvR7eTrYpQGaz4x6xSQ9TSmTAX1TvDuIEttcMs6sgXv6XofjnqQGIFhTL/4hThBsLahOmzDb5I3h1GdPRXSFpj5tWb5425ZM/tZTGJ5i/bwCdHSeajIy/iZWb/oEHCZdPb/CK590WfFRMUMXWRYTq0M4/6NypeOCWAwE1fEVOWfq4QGhE1DH8Coh3c1UkcPi9f8YpybuI9lxWcu9Ixk9jIo6PKrTVckPqLT8Lf X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(39860400002)(346002)(136003)(396003)(366004)(186006)(1800799003)(451199021)(15650500001)(1076003)(41300700001)(26005)(2906002)(5660300002)(44832011)(83380400001)(7416002)(8676002)(8936002)(2616005)(6916009)(86362001)(316002)(6506007)(54906003)(38350700002)(38100700002)(6486002)(66476007)(66556008)(478600001)(52116002)(66946007)(6666004)(6512007)(4326008)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +HABeMmt2QZsAS1xllHzQmFQEv+VIkqz1IRk+A8UkTAYtLrv2VJY/Lp5w6N6Q41AkL9kt23YQJgwO5LJUqUUnTb8EG8vLNR2qF+eam01Oy7fYh22Jx4yP5t9YoPfgyFJ/C7YTxdC6H8sg+MoyK9Tl5mlB5TacXwIufJs+QfayE4x8a676b9nxinz4KHdvkmXI2BLB70EVlJ4BQxaChiRR0HZmFathZIeDCB0YM418GeasoiBy0RZ/2KICXXp+dZtsyj1TBsvwKRSV8CLTu9M+yddzZL3C7/hkbdZnpCQgYIT557z1lbKDLbo8MTPaHvU1h4urXqq3LhzgbWBR/G/pwa/QV+mivsPPL2Tbh+3II+KSzpJekU62lAuy/eLXvoNtrmx3TEqlRbpR4zX32ag4VReOPDXDFlcGWi9iO7S6naVhJQMxLcT/i1cTIBbF/MMkzmbx8PKrqLXoAFl0rFbuiTjjGYYyvRipaLdAaL4HZYWmKMYIYxQ1k+8mzG30CVF4YfE0I+aGoEx1Ti7SmCBZxWqJlgBOeoVvdbFjHlVCGN29TUyNk9secVCTEHHwV0KeaxDSAakREjVycFoK+rkIFnCwge3gE9rLy7ePruBofPzUkzfg/vO6WyMKN9x5y/1EmO7ojWaAaFgb55WvbvH2nYpms0S7LT2yGbkmMZWYFL8a1L4/Bq6edNwYKaD/nDZqZCIYCuz/SmM0t+hL1OjoFlJq829iOjiig3t1HMW9vEMgAtM27kPOhUdozMcdeDkairASJHRoCYm53S2xNWbsY0yBCeq87PKYl/Pi+3Ko+hvM9VCv9XAu3AwGwtJpfmsiret4OiSHcwQt+BUrUyxVACFB8/RCGVGVAr1l7499kma56zhAuGLFp2dPe+zoo8Sbe78cBib1Z+SoCEF8o1ExIZddYT5CZTF35tXBjGbk2OoKHpTpeJuryP9Zp5IjLcFItOmP1wF/qiIVuys4i0jTRaxeNhAt0VO2mx82GyjXeMlkg1EzZiPeAB8Ku7NXH40OTMl/KG+cPrDFV7j927eWcgCLPg6+nQfVXcWA1/p4vOGkp3xz0VwxDlyaseaw63OvGFK6FqBs6WA2C4JmHf9i6x/M0KguVttGJDq/S1tvgpmjpqm47XpdzBa4EKl80L+JN7Cb1Xf3nhni18oDQJA9iSKgjYe/uZ/aSlxSRcJe59iaULnHYAof+2hrvdRD45sb7tcG9BZxstHTnHIHAFPCi/BDhBs6Mmh8+EYWgv1ON0EUyqqP7lMYAW3Xjn6LHeDUyxPlb0wg379bvw3wVcA1CMd6o5qLHPEqJ+7RFs+pQp9nxsWiNZ/DsSFa2aRkPKK7So4+bXaNvarhHxkOYslen/TnVqpnelBrsZdXv7wdEKnjX7+BI1mKnGOCO3lhAVMsOcLw8OYd83pjHgWzunKvpicPvor9B8ZE//C0WWL+PGFPljsET/6ZkZFn820vwv8tDm1swUpNVkkdK9nhtUxSl/mqtQbRQ+oy+2P2rUOam/5tuYMfpnvuEzzLCe7Imra81flMlMJ3sWmIRSFZD5tw1Ylt1M8gGGHDfYmvmhfYeLG0TnpEFjOQMNrMoGoDBIwDfT30jNR1MDwOyUjVbPLrw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f9d84cc8-35d7-4013-b879-08db977dc600 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2023 19:37:45.3584 (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: tb8k29buXQruybpWREu5pL7/sbnmoWmCU42WpU2Z40n9ELoTHalOGww7QaYqTqiZdiZRRfdLZtHGuSdI64kDow== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9451 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org The reason behind commit af7b29b1deaa ("Revert "net/sched: taprio: make qdisc_leaf() see the per-netdev-queue pfifo child qdiscs"") was that the patch it reverted caused a crash when attaching a CBS shaper to one of the taprio classes. Prevent that from happening again by adding a test case for it, which now passes correctly in both offload and software modes. Signed-off-by: Vladimir Oltean Reviewed-by: Pedro Tammela --- v3->v4: none v2->v3: fix expected output for test 6a83 (missing "refcnt 2") v1->v2: patch is new .../tc-testing/tc-tests/qdiscs/taprio.json | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tools/testing/selftests/tc-testing/tc-tests/qdiscs/taprio.json b/tools/testing/selftests/tc-testing/tc-tests/qdiscs/taprio.json index f475967c509f..0599635c4bc6 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/qdiscs/taprio.json +++ b/tools/testing/selftests/tc-testing/tc-tests/qdiscs/taprio.json @@ -206,5 +206,55 @@ "$TC qdisc del dev $ETH root", "echo \"1\" > /sys/bus/netdevsim/del_device" ] + }, + { + "id": "a7bf", + "name": "Graft cbs as child of software taprio", + "category": [ + "qdisc", + "taprio", + "cbs" + ], + "plugins": { + "requires": "nsPlugin" + }, + "setup": [ + "echo \"1 1 8\" > /sys/bus/netdevsim/new_device", + "$TC qdisc replace dev $ETH handle 8001: parent root stab overhead 24 taprio 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 base-time 0 sched-entry S ff 20000000 clockid CLOCK_TAI" + ], + "cmdUnderTest": "$TC qdisc replace dev $ETH handle 8002: parent 8001:8 cbs idleslope 20000 sendslope -980000 hicredit 30 locredit -1470", + "expExitCode": "0", + "verifyCmd": "$TC -d qdisc show dev $ETH", + "matchPattern": "qdisc cbs 8002: parent 8001:8 hicredit 30 locredit -1470 sendslope -980000 idleslope 20000 offload 0", + "matchCount": "1", + "teardown": [ + "$TC qdisc del dev $ETH root", + "echo \"1\" > /sys/bus/netdevsim/del_device" + ] + }, + { + "id": "6a83", + "name": "Graft cbs as child of offloaded taprio", + "category": [ + "qdisc", + "taprio", + "cbs" + ], + "plugins": { + "requires": "nsPlugin" + }, + "setup": [ + "echo \"1 1 8\" > /sys/bus/netdevsim/new_device", + "$TC qdisc replace dev $ETH handle 8001: parent root stab overhead 24 taprio 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 base-time 0 sched-entry S ff 20000000 flags 0x2" + ], + "cmdUnderTest": "$TC qdisc replace dev $ETH handle 8002: parent 8001:8 cbs idleslope 20000 sendslope -980000 hicredit 30 locredit -1470", + "expExitCode": "0", + "verifyCmd": "$TC -d qdisc show dev $ETH", + "matchPattern": "qdisc cbs 8002: parent 8001:8 refcnt 2 hicredit 30 locredit -1470 sendslope -980000 idleslope 20000 offload 0", + "matchCount": "1", + "teardown": [ + "$TC qdisc del dev $ETH root", + "echo \"1\" > /sys/bus/netdevsim/del_device" + ] } ]