From patchwork Mon Feb 20 12:23:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 59408 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1276590wrn; Mon, 20 Feb 2023 04:24:55 -0800 (PST) X-Google-Smtp-Source: AK7set+FRR5nuBWkuN9pM5pUxQ/vUOUUs53qn/r6dO3g/0Zfy13+r4znDncynYV2wsnvLwEvGl2T X-Received: by 2002:a17:90b:3e86:b0:234:28ac:ec57 with SMTP id rj6-20020a17090b3e8600b0023428acec57mr2794853pjb.21.1676895895328; Mon, 20 Feb 2023 04:24:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1676895895; cv=pass; d=google.com; s=arc-20160816; b=vmXrqtmF88syVNomWM6IWoEZGZ9Vx4L6exl9B9Zh3jmGn6DvykgH3cYskltn3K/m3t haLnDUp8HswsMVfI685uAx1R9/RLxyPLcwIVxrBnqrQst2o/KqMOkyWA9ifk7iJ39Ipj yVDM6fHhMGoqgtHnXhHeEuLNA/AQONK32zB/Aw22dnwlzSH6PeOF8zEaQ+0J/q0APUBw zDStV4iqZHM0Nr7gWgkAuMeTzojEniBwuJHCVg/mfc0fXF+1SrXlIQI1xuYx3tQ49ozw dVBx/uU6GAg2wsKFQuqgDupOQ4qZG1goDy27CriuyO1XTQLd/THV21DsKiFPybZJqahu KRcA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HrOGSjADdNGnCxvTN6zOO/6ulh5BCUN1mw5+cZI5gn8=; b=MzVDiKTj2hTJbrfg1MqhEHAX5EJhN0BdRW16iBBMBVgTXMuR4BaxiQVNJEG9z83laX Vs96wzDj22Vg4FtwfmALCLoupT4pxO+A+01Spo7P8pd36oyG3EN7G0DDw8Swm6SCn1Ej lpmKG8MkNWCZ4wdvG+4vjU7CUBWXgdk7wJR7wehgg+JzNj6FoRHVuSMR+tH5gjRgo46b dV5aoeYntQrFY91FEBy7KVlKQPUObxtr/QoIzKmkekfYwvUefWLWHH4f+AdPEU5jDWw+ nSWKdNfosfhLbTCH181m5ZUs6GVh2QEm3U8rzvZ8+r4wF90XNmGp0memph5oBPAIK2PG NE7A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=LeePMcEU; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f17-20020a17090ac29100b0022bb6a9677csi15172616pjt.35.2023.02.20.04.24.41; Mon, 20 Feb 2023 04:24:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=LeePMcEU; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232019AbjBTMYF (ORCPT + 99 others); Mon, 20 Feb 2023 07:24:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231983AbjBTMYB (ORCPT ); Mon, 20 Feb 2023 07:24:01 -0500 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2056.outbound.protection.outlook.com [40.107.105.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECD321814E; Mon, 20 Feb 2023 04:23:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oVB/lkz7kyFuib5CxBPmjFB+I7IrPeduiJqyLi80F3aCaSiR17IErG4TieCE4ftvmnuWnszjhjc0CchXGl5nt+/BEIQLOVBx2E6i/Iu0LgzZjsep+oH+H5dmanioT2UosMvOQ94JOHi50Wy7SZ+aGI2Vghr1oUbF/cLHBauAbs6V5MA2vEikYrqaCLRfQZBUpVGc1p/d4KW5NCI634thqvIBr63lU4j8nQmQQigkjejEZ2uXwrfoag/yir++cvp0+eB1eOFvDhyoUy2wro0CwWqLuyeFlaEZgPtlGr725D3pvviRkwVXWmCjbT3PM728FKp0PDsHxUi+51ZbIG1MJQ== 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=HrOGSjADdNGnCxvTN6zOO/6ulh5BCUN1mw5+cZI5gn8=; b=k8B8CBYz5t0ZkUdcKKByTIdBEnoTGFvOMgryLt9gq2rVrt+WgpRIWYslhNapGrFfECb7brKIAeFRN3nfE0GT9Lvv+RC3pebUlKgFlgN4bp9dDha6onZI0FfxzdCuAJX1g8aCprsXbrKSVXBNit3+L2ZWHXmEzuXDrbVwvUXuQL/2swcJBHNalmRl+3RwE7Tqd8Tzp5KPDNw6hHGczs/CZ9vyoUsdq8OMN9s0ZpKeZQrAn+1E5fgWr7/ORVda3947vvj1YHu7bJVMIDiWr3pv+V6yirCIO1hzHnUK2+3HzK1q3xGqO/icFF1aRvJFPOml0bmILE9LJ6QERX3VkV9Q3g== 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=HrOGSjADdNGnCxvTN6zOO/6ulh5BCUN1mw5+cZI5gn8=; b=LeePMcEUy9v7mfqkxoGUJEhEWPj0XH3uGdq5QNOA6bgWeB5HMuJEZCyvts/FULFdAtxSyoIX2CT6fpYlBdUM03v35dX4GPXkBN/xiEvzan4mJZC0p4e3fla4LWyr8ePXPGLrYK7dnG52RPnfjjwXD8/eBecJWSH3wkl9j923c10= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by PA4PR04MB7725.eurprd04.prod.outlook.com (2603:10a6:102:f1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.19; Mon, 20 Feb 2023 12:23:58 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6111.019; Mon, 20 Feb 2023 12:23:58 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vinicius Costa Gomes , Kurt Kanzenbach , Gerhard Engleder , Amritha Nambiar , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , Florian Fainelli , Ferenc Fejes , Xiaoliang Yang , Roger Quadros , Pranavi Somisetty , Harini Katakam , Giuseppe Cavallaro , Alexandre Torgue , Michael Sit Wei Hong , Mohammad Athari Bin Ismail , Jacob Keller , linux-kernel@vger.kernel.org, Ferenc Fejes Subject: [PATCH v3 net-next 01/13] net: ethtool: fix __ethtool_dev_mm_supported() implementation Date: Mon, 20 Feb 2023 14:23:31 +0200 Message-Id: <20230220122343.1156614-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220122343.1156614-1-vladimir.oltean@nxp.com> References: <20230220122343.1156614-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0183.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:8d::17) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PA4PR04MB7725:EE_ X-MS-Office365-Filtering-Correlation-Id: 53a6edba-8f10-46d0-701e-08db133d571d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ryd/cK3upBN7ykMEltpHUvYF9wvBlUD55QAmdlDHi0pIYn0bGgEIHCkSdMeBEZmiAQ++hZ5Je1qtF41Uz0a0uAe4qgGJeukeOTo2BETMykqgGQ6iMRXVTMczO67hSuqt89NOqENpNdSgkZ7UYIq+4xUhX8WbFf2cPViYbopSThSBWhn63BLl8mulyzlmK8fKfmI1GlCJ/gxON/ngPRwiwmzRjF9L6Ke1+spEB7/dqxoW7ax+yIUu/aKuXR73ZJfLj+6B5jqneTSGj6szt/eaP5s2sv8plOt6678Dx7cVFZivmwaD6gACBhpFK1TFhRQJ2otdJi9uPpA91mo6I9O0kz3bpd5wim/mXtfkMT+CPuxJo1btAhUPeVwnflvJlRqbJE4qu0/scKrSBAl1EgGkm9cXHAgA6Qmgxph4jcG2Kw0b5ZrLPb/bOEEVhILkDtJ05vS1XyvGVv3BQ+1zq96KN528nX6F0T41py5k1jU8GTf/zhTUPUdd4/cUCg8MyGQDnn1y8GdPRj1sftoVZ+daALcUoDoLOuaRF3605oe0V2oM3lCvnW7PgcG8akEjn2pMEa8izGamtK10Pq9jsLqjSy8sHpcOqzhB30jPIPkvG8bQ4o6DlrMX5D5mAvVHV3qkWCVvzMBhtbgScgkJ+wRd3IA4taFdOxXppmigWz3gxHqsBLPWVv3emyKW0ME0F7hHM5MZRe0GV3JNcPlRjrM0Yg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(366004)(346002)(39860400002)(136003)(376002)(396003)(451199018)(8676002)(6916009)(4326008)(66556008)(316002)(6486002)(66476007)(54906003)(66946007)(7416002)(966005)(52116002)(8936002)(5660300002)(41300700001)(86362001)(36756003)(478600001)(38100700002)(1076003)(38350700002)(6506007)(26005)(186003)(6512007)(6666004)(2616005)(4744005)(2906002)(44832011)(83380400001)(309714004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wJNyBMhjZREkWqtX+qUQOR1LriCGaY8ZEZi0J/KwRMVEAhTr0gRBm4MXDfP3j4ZyD3nSLPNV6P3ktYmSY4KYHklJZ3EeJ7+/7irg9AnWBzxw6YrwUUxwMmIvgwlmo+/R4UydIERuFBswI2fIRbXjIbB4OnmUUfitMEAYMbuSHnyfdOX8jnWVSMKyL4Ru8RY3e+i94VRKdNopMQ826Vg6f349YWz/TYhOrYfK7bvDD8yQpPFqofvx2lmduQqePFkvMT5ceElu9UBvjYh13SXLLlInATFaG2ptDySLarzhIQroehDXeT/YHHInOG71U9+3ScKbC7fezmsUVDhUSpUgFFOMg0rF4BkhLgb4X48SohidbVnmAJVWh8vXWc9F+4AUSWnyseWt108hf1vQscwNZVzNmWPtSYxAss7bEYLg58BMAkdbKSDbka+0+K1AOIJKoX/In06dzeqVJBT7o2hi+Q3vtfj8WvTdzEPByJCEmswkKiFZvGd7GMjkdW8PjAkIkqflWiPHpsMLmUugdNXcDAAM1tvR5pzeTxdwnOt5CRhb69TqG6iWgfezx4HPdcSqei4oQesfJHbnsCa3CBo1MBapfApChn81MUi2Gu6pelRLMI7xDsloOvKTLagubCLzFwXzgwBaauGpjAa3JjuAJ9OsDrJLTFBTKOsfq6BO2Ih/whSv8z6a2w3ajkpLapbvMcNGk0hKa4Ii8VawRc72GzPd/APZGSDg5l1nF34aaZB6LNjU368sQkb0QeqoBVSG/gjYF/toVWINdLr0XNiWh+LARr3hnNXww7AqdOPjEM/1HDEfWF7oJGqhQ5uG16qPCbOBrvNX17TWdnjINvXLkr5SDMgyHYV3B4kz6eg4G0qSgnqK4GWAo7uh+1YTHe1CGyvtxUWGXPfJqwuyu2Q2puPEm4um/OfMMRAkKcbmVxIozLwnWor3thfl3hdKkXqFDEGXeV6q8RaC2xJ0qbYnfEpgr1Eb7y/PR+/YomP2lujnTV07CE9y2RZfW+hM4wC+VXLU/1l8GY08W+AisT1PshLOqSaecLPvppsrVAnBHzwlD08xlGGwXJBnS/ILgsJlxDBi1FkxozoWRzqNabAJoGak/Vvn/BCG7NPH03OHuud+E79g/PAOwPzKyUTmMhozkHkSF455Yr3+dqxGphcEw9D5RsTIGEyDRrbsatNbOYisShEyP2fAn0bXOFEyibA0k9/vMR1bexL2p7aejwTS9d6w9qZHTb3sgRS7wbUeKiljMgkK7ZHQSJXyLoMrXxmn2+GSf2uAVmYDQS1x1bQODE1r8osKTzstVw4ReyIFjMDzRkEPUjmQfRtLpI7BiRUG6+VsQXQh33L+recfwnPFF7rVPbEskxKIr9SXshFAYE3IeYAVnLne4jupOCr7R4nN/CLSa4Sn+Egm3sDzwoe6D/mdL4iJgplBuToyojpzj0njL03WerSKrocDKfdXpHD1JPSR+xVbBaQP0G5XKgisBffidiUj/JKVgM0G1M+i8HUZy7QEz7eqmRsN+e/CZkW29iKiIZFXdMhrl3OHCSeiK/YsbMa9Q3uOjyAqgm25YFT1tYVPUHqAacol0SPFKqsfO03g5fKP2lUSnW7vqOnJhw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 53a6edba-8f10-46d0-701e-08db133d571d X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2023 12:23:58.2286 (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: GuetE4Y7WrY9/KFB6CZaT8IlOlhy+JC1vxoOKwzKqQryvIIKkKofn8AFgWYPSkSJnffbUFDXLKKBoAzuzFG2TQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7725 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_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758352790260786155?= X-GMAIL-MSGID: =?utf-8?q?1758352790260786155?= The MAC Merge layer is supported when ops->get_mm() returns 0. The implementation was changed during review, and in this process, a bug was introduced. Link: https://lore.kernel.org/netdev/20230111161706.1465242-5-vladimir.oltean@nxp.com/ Fixes: 04692c9020b7 ("net: ethtool: netlink: retrieve stats from multiple sources (eMAC, pMAC)") Signed-off-by: Vladimir Oltean Reviewed-by: Ferenc Fejes --- v2->v3: change link from patchwork to lore v1->v2: none net/ethtool/mm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ethtool/mm.c b/net/ethtool/mm.c index e612856eed8c..fce3cc2734f9 100644 --- a/net/ethtool/mm.c +++ b/net/ethtool/mm.c @@ -247,5 +247,5 @@ bool __ethtool_dev_mm_supported(struct net_device *dev) if (ops && ops->get_mm) ret = ops->get_mm(dev, &state); - return !!ret; + return !ret; } From patchwork Mon Feb 20 12:23:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 59410 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1276804wrn; Mon, 20 Feb 2023 04:25:25 -0800 (PST) X-Google-Smtp-Source: AK7set+ZA8xWW7DrPpyYe8pYfIfU4yYdoLtVn8cWK92ufP2bZDzdaAqyv62KP0xWWT50XJ+A9dB5 X-Received: by 2002:a05:6a00:4c13:b0:5a8:b6ec:3aac with SMTP id ea19-20020a056a004c1300b005a8b6ec3aacmr1046769pfb.15.1676895925112; Mon, 20 Feb 2023 04:25:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1676895925; cv=pass; d=google.com; s=arc-20160816; b=SiaNCNZ7uNnDPjaWuGApx3SgSCKu9y3PWaWGtGJOmgX/LuhJuuqoGZLDgDj9qwS349 ITAGRlbF7Fo7VsWVWz7SBdHA26oBJ7Ur57otFZRoFOPCczQKOuO4JdTdcvW58WsEB0gc NWvNgihbAXZ14ewl1fto8qTIa/SiruNvXNC78frmjUrewbrEfxT8y93cYWRrQwba/EOt 8I+e+GzoUNsDotBJ7AWqJQIj8ThbPfF8aJOPBDpARpLupcujbyGTBicH1mUDmdybjdrD 2VdXncp/1dQSrJXTHv9ymRoDiYVNKAGmw6Znh4Va4/lZTlnqblVyflZ9AEdEIxgOgAR9 xbNQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SLHC8lf6x9GUPNeM2T6eLRz5ylPxg4Z4zvhGOMXOzvg=; b=we8vTSmAlexoGoRXTZQLj435UpISgOBDEVgVhuBx+75odED4onUA6YJeFT7qIMhtVU /mkQ6Xki/obrGXaLkCAjrEDpuLqVO+j8SBM0qHO/BrEL6UmPCN47YNo/XA+lFkcR5REx VaA0kALVVl0JepeqeSkP7BGcqDlGrBYWfTRkS3tOfd+7OWTeNXjxELmfdOmrh/SQVRO+ 0IQYRnCXhQRliPT1Y7/SfjikjEjfXperWeyGCkHGzv9olGO2kquvTaoABkgKJe83P7ec mR+M4njTi1EzqmNNlib6LeePKyVrNxeIKFkwLrejreVR7nxJTdctPEECz4iRLEcbP0Zs LB3w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b="rWvu+e/R"; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j191-20020a638bc8000000b004fb1c44a4d1si4254884pge.212.2023.02.20.04.25.02; Mon, 20 Feb 2023 04:25:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b="rWvu+e/R"; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232025AbjBTMYR (ORCPT + 99 others); Mon, 20 Feb 2023 07:24:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232018AbjBTMYE (ORCPT ); Mon, 20 Feb 2023 07:24:04 -0500 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2079.outbound.protection.outlook.com [40.107.15.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52D0C1BAFE; Mon, 20 Feb 2023 04:24:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mb58l6aotNSo5T4IgV3rwi/XYELoAm8C6w5eGH8OtN6uCWHWeRQyWQqVwgqF5lUDrs3l+S5LkZrTouDnn6XnbhJQZ1YC24+uYxS6JQrmDkATuICkN9y2+6aCGwmyTNeyL4QVCiYr1VmSfU+KThki3kVOcenMksoFyrv4r8CpFPXc9zIUESSvWV0hwUrlq1NnD49e/vxCRWDf8bwp4P7FH1mwZ89wh6nf6JhCGbq5epX/NpS9f+XdAliSJYOQzLwTZ/K9gaI0/bxDmq5qwMFZ0EhcEa+VuC+ZV3O6ZagPah05Slx5gvyL4WuO3FchaPs1sc2jCAJPD91cd6rcAzXTKA== 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=SLHC8lf6x9GUPNeM2T6eLRz5ylPxg4Z4zvhGOMXOzvg=; b=DwftXMhzWvdh2N9xyJ3sMdgEE1npXLXgdo+67GcMjW7ekL5NB0wlgOzeO8iNbXwtu8PloPp7yeqBuqZnqyQ1WPc9FNLRxmlzgGNEojArkKYAgXtw3a7/ADoULb3xM3X1XzJ7VJyqAoj/ayKqrT1e0BOtqqo/Aw24MZa8Py3HtKr22I/KiX3l/E6wA7/jEYKy5We6T5SlDfSIQrLm57CKn+TWW+DH6/cgUIA79Z0Zn1FYmxF6rPShNfEw7XS4HqcYTAXUdjlgCbw8Fu4rhC+Av5qPLb3pFxA0zZItFc8B9CckHIlWBHj4lOvWL+yWXn1RfcQZKZg3D8qm5x7cvjbJTg== 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=SLHC8lf6x9GUPNeM2T6eLRz5ylPxg4Z4zvhGOMXOzvg=; b=rWvu+e/R+ZchjxG8VeTF086k3d6PXvySMSnpOPMmetSIy1kcTkyoNMa6Wz6hUPbejSWw0u8nHVIARC4OCBeUW3DuXk8AcUaXKoJ2GRONLOBkzl6LbFXp5Hv/lDOOYL9zc7R4mq2tBKixXwSsmdvvIX11ewaeoaytI/O/schPmFE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by PA4PR04MB7725.eurprd04.prod.outlook.com (2603:10a6:102:f1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.19; Mon, 20 Feb 2023 12:24:00 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6111.019; Mon, 20 Feb 2023 12:24:00 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vinicius Costa Gomes , Kurt Kanzenbach , Gerhard Engleder , Amritha Nambiar , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , Florian Fainelli , Ferenc Fejes , Xiaoliang Yang , Roger Quadros , Pranavi Somisetty , Harini Katakam , Giuseppe Cavallaro , Alexandre Torgue , Michael Sit Wei Hong , Mohammad Athari Bin Ismail , Jacob Keller , linux-kernel@vger.kernel.org, Ferenc Fejes Subject: [PATCH v3 net-next 02/13] net: ethtool: create and export ethtool_dev_mm_supported() Date: Mon, 20 Feb 2023 14:23:32 +0200 Message-Id: <20230220122343.1156614-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220122343.1156614-1-vladimir.oltean@nxp.com> References: <20230220122343.1156614-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0183.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:8d::17) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PA4PR04MB7725:EE_ X-MS-Office365-Filtering-Correlation-Id: 30e014fd-7528-4ac0-6ac0-08db133d58a4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0zkrJwLevwulBkYHyRB3tapuEin1YK7Jy3a/ky4Juh69VOqE+EfRF4RIxX/38UlYfXnAONDG85YBKZTNGwpLHoLq6xVLr/780e41uuTJEluOP7HhH5J1YZKdIC3oNBpIaWHrqDg/aQW/koKN9GS8fFcojwKcsvG9nUXR/bRlksTGY8/2S92XZ4VpBDIXYYGgq5hdIRdcq80EedPS966BIglMVtYyxdc+h8ROuMjuk2w+BT/rXajSeX+LphKec/KdLFToakNzcGnJFonA/4YQ67FI4eXyhmbRBqkY26XABmD26G4dOwhK+36SNPwAdr+rPiCVrHLc11PJaED+lpnFibeVvleXhPZJ2N9gxiK8c/YC22a6YtoWmftk1hrkpMPd0b4LxrD1n5rIIsaDojPh4/Pr8rmkRAgZ/0cH2Bl8daD3AVsylzvgVIC9p8qv5b6aiMYVil+F+CLNlmAq+4agbox0R0XSm/wwAvsPE7f0mUgjPI09ng+ncKQ1NIUT7HeKlqPjKUt+RKrIL8KJtLuk0JeYXBQMW+hmK7ak4TjqLmqAym2PKPoR1o66NzNUu3hQMwNahoHODiODmXZJi1tm/hYY7YrBm+xnDEVmvbSI6WbxIqE76NwOC10ZV46FHqfurSE3KLFULHBk/lzEm9by++rprvA+HgaGLM6/MIx4fgMW87sTBpTOUuZ37xUtw8zNxUms3TrXQMGGCT3j5rBtrw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(366004)(346002)(39860400002)(136003)(376002)(396003)(451199018)(8676002)(6916009)(4326008)(66556008)(316002)(6486002)(66476007)(54906003)(66946007)(7416002)(52116002)(8936002)(5660300002)(41300700001)(86362001)(36756003)(478600001)(38100700002)(1076003)(38350700002)(6506007)(26005)(186003)(6512007)(6666004)(2616005)(2906002)(44832011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6qqPHthMlxQIaKfNZmPP8wZdOyG4OrrVrCsMDA0QDk6iSM4LvDDePIUrEO7Ah8tPlb7iUIPnqDrEjOu2vmlurmJbFFG04qwiCY2kklXSSgk32QfnAmqKBSVrJA7J5sXjIeQwTFNxuKKpoN9bGXLvW0Tq4iMwIaDljcX8/4/LBJXsLV6GzY44YuDiWWUX6FJxBQtiRhfB9SSc3V8MZexB7IhEl76vOwtP4GZxqYRCBLu6/a0Zaed+pEqWF4SaWw1TSwW2zXS6L0RccOY3G4iybcYMtgimSMzpIRSOpt7K+/899V0oGiIQre2Jd+046OOq+ySIz8OMwabZlksUR2yMeJCEJvYb04DFpY2FCq+vSN6w4HE9VO1lC9g71xgkvbFoqFlqbgtADElsd7xtlL6LVMFVYM8tdWupZJswZJQb7bquIGA8rCqG5/GN0WWv5MddLnHe3bZ6xA4Hlpm9g3uIJLQdJnEIv7+VH9+LLSbeQmaqDFGeF6vM67G/merHbljn5Wun6TzE8s7uaOhF09UVSSQ4lc9tWIQHe0Kc9sHJUPniNLpDBQrtD/CBwc4HGpl3Duef46DgVsV3nPwhsxN/h/NNFswv+eA4DRkVgSG7/kY7WZ3I5Wtwxggl9taTs6zM6w1KcfJ6wAn3Gn4n/Acvjv31N+lyc2XfAQo+XK+3u+Ma7aI5VaUjQgk4zllb4GQioZ3e0ZYqJ+epUg4324tn0oIWIpWKy1jBRfhLmwGJY7vuXKXC7Zex655MKQ1+i0wZ85cyZCuNcePoZgjJNsEny68zJOfDtVmjTptq2F5CUndjsj6xo/MXqNF0GGwnayWN5CgsLU+tMKOvxrP8KAv8wbL3fp+2wCHWlWhunx2TRHaY9eFF+rAk+dGuYh1+Hp4eTN5aUqZwYzjF3Rc95o+qPFZQwwdJYVLCjE1PWfamC/bzPnIDyVYLQqJBE1zHS7OsgFmTdv5SSc4ymNh+KwgfFa39imrehJcY0CzBeLezu0ziAEjEXsngtHFY1LrqbC3FS72L+7zxeEB9EMw3KBprIiHCENkA/pWm+64oN/vZ2ltMQSO0LTH4xEONKmZvGjkQHvzkqpBXQC+JU8QvHrXak0hktruuS+SSb13t0Knn/vdPSFmJ0VPUR3dVSyohnywv5q/Lo6M3xTZWO9diAF0zg41/xM+1dna2abC7JOpeWVQnRiLai/Y1GTbz42xianICj2TbkqSfq/VzctGgoRhkUKulIRY2mQ8LQlXAH6Da381z34bNFdasukkxqmKx4E8TD6wLzPZsfEIiz/1fuqZR971PJzN/oGoG8nSD4wDhzPQ+Ua+Uptqx9bNAUDGsW33Z3G3fkdnaCodG88yKlRNcVbxu1/kVSDNJmNFgi15MjarRny33VM/1eV21tVFIxGIkPg2AZ+/ER3wpsaHM5maKm7g74ZwDc+86dTqegE+gmqiFVee1uQgy4DI9Fs2xteJJK2rYcDrVEbK4neU1iJkF6cC2jRW5zCnGtGgXjI7ZaJkpmxd5v1a/+ZQEfY0mJwJ/ID2aaGRNdO9i82T9BMA0q6MunUzca4vPbs1D/3JZCtdkZ89IrsETcvCJyRNtj9C7DmQAVwstyPl+ANqyZ61z7A== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 30e014fd-7528-4ac0-6ac0-08db133d58a4 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2023 12:24:00.7441 (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: XeiYf6nO3aU10/ehX+UpewjiObwScvPPei1m/C63lRtyJGnH+EHmP87x9mNqypW2QGox8YE1q9o74GQE9F9xKQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7725 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_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758352821653854468?= X-GMAIL-MSGID: =?utf-8?q?1758352821653854468?= Create a wrapper over __ethtool_dev_mm_supported() which also calls ethnl_ops_begin() and ethnl_ops_complete(). It can be used by other code layers, such as tc, to make sure that preemptible TCs are supported (this is true if an underlying MAC Merge layer exists). Signed-off-by: Vladimir Oltean Reviewed-by: Ferenc Fejes --- v2->v3: none v1->v2: - don't touch net/sched/sch_mqprio.c in this patch - add missing EXPORT_SYMBOL_GPL(ethtool_dev_mm_supported) include/linux/ethtool_netlink.h | 6 ++++++ net/ethtool/mm.c | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/include/linux/ethtool_netlink.h b/include/linux/ethtool_netlink.h index 17003b385756..fae0dfb9a9c8 100644 --- a/include/linux/ethtool_netlink.h +++ b/include/linux/ethtool_netlink.h @@ -39,6 +39,7 @@ void ethtool_aggregate_pause_stats(struct net_device *dev, struct ethtool_pause_stats *pause_stats); void ethtool_aggregate_rmon_stats(struct net_device *dev, struct ethtool_rmon_stats *rmon_stats); +bool ethtool_dev_mm_supported(struct net_device *dev); #else static inline int ethnl_cable_test_alloc(struct phy_device *phydev, u8 cmd) @@ -112,5 +113,10 @@ ethtool_aggregate_rmon_stats(struct net_device *dev, { } +static inline bool ethtool_dev_mm_supported(struct net_device *dev) +{ + return false; +} + #endif /* IS_ENABLED(CONFIG_ETHTOOL_NETLINK) */ #endif /* _LINUX_ETHTOOL_NETLINK_H_ */ diff --git a/net/ethtool/mm.c b/net/ethtool/mm.c index fce3cc2734f9..e00d7d5cea7e 100644 --- a/net/ethtool/mm.c +++ b/net/ethtool/mm.c @@ -249,3 +249,26 @@ bool __ethtool_dev_mm_supported(struct net_device *dev) return !ret; } + +bool ethtool_dev_mm_supported(struct net_device *dev) +{ + const struct ethtool_ops *ops = dev->ethtool_ops; + bool supported; + int ret; + + ASSERT_RTNL(); + + if (!ops) + return false; + + ret = ethnl_ops_begin(dev); + if (ret < 0) + return false; + + supported = __ethtool_dev_mm_supported(dev); + + ethnl_ops_complete(dev); + + return supported; +} +EXPORT_SYMBOL_GPL(ethtool_dev_mm_supported); From patchwork Mon Feb 20 12:23:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 59411 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1276876wrn; Mon, 20 Feb 2023 04:25:37 -0800 (PST) X-Google-Smtp-Source: AK7set/67sM0TTEilQhZ4UwxGkVXCH6b513XhssZFPywlfM6H5Z4N9vvDbROm2jv9czos16AX7jF X-Received: by 2002:a05:6a20:8ba0:b0:b8:ca86:d1e8 with SMTP id m32-20020a056a208ba000b000b8ca86d1e8mr8620352pzh.14.1676895936677; Mon, 20 Feb 2023 04:25:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1676895936; cv=pass; d=google.com; s=arc-20160816; b=PXvPz9mepoVIA12YapSiZnwmJn1ArlnN0/ITRxNuvjkGUTIvWcIHcegzCuoK+rkQES t/OAuB1GG5SosF1zoM2ULCleO7byaQKw2KyFuG5g+us+QxzBCMv8kuFq+YuuOKxXT5VM Zuc7HgqieyoQdv7HXJ6KpMycmeL9yrpHP97aUF4DK+4UKupdCe4WBay5naJ3zG3obCTr RDcFSRO3XQoUD8hsb3KgxcCVN150jDqdx3mK3+4yZNxWJOu+/cj7mH/VXStXd+3t3ecV 2JPeTJI3SS5t0MqWwUEegPxDvp+x1Vl9HeSQ+s2OK3AMwZ/cKCRDVukFs/3OoNvq7VOg ncPQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=m9EZg6hgUN/dPAkIluWwcqmYHyResOBRpUhAQpACT28=; b=ax46eeJSm+fMtvTFIK7z9NiDQeEh3xPSyQLlOk50e68boWggPDUfssHZ1/zsN+duc3 sVrLw8N9e3CWexMaZgOOkLSjEKsJpIBwJZoX2bEcIaGxGZGyFGYKPLHPzemyovKqtlkK 1V04QClthx8KkErl9wXLqSeVFs6lmp14sPKuc4PHSA0uH1sRitJpP3RTqhGC7HbZAZ2X DOg/bjCTlMtpZCj9YnOt5ojW2MP4/QEc6rhVkrtviGKfF0nsTjr5UkwILAUdW8eDtiFZ 7OxKUdJspPghEpcTQA0nwKO9QQCzKRpmKm7849I4KOEMs97+KrY4VHK4JCD17NyHCbrT BiOA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=Dr+LPQGr; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b6-20020a63d806000000b004fb944d4acdsi14597806pgh.367.2023.02.20.04.25.23; Mon, 20 Feb 2023 04:25:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=Dr+LPQGr; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232045AbjBTMYU (ORCPT + 99 others); Mon, 20 Feb 2023 07:24:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232023AbjBTMYG (ORCPT ); Mon, 20 Feb 2023 07:24:06 -0500 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2079.outbound.protection.outlook.com [40.107.15.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6B6E1C335; Mon, 20 Feb 2023 04:24:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WRo4v9Hn62gzM3kfZhGY31e2s06HVha1fuqE+U3+g081koy0kwqqW/TXzwDB+h/orNxGwlP+Dkv7FKpbeDM2cAaJIljmuHPo9aRzM9NRKPNrh1W4zSgs1+YB5tqQ/iAFsyiI9dbB5YJR4ZSf/nkLrLzMhUNIfBjve6AGngd38THrNzyZPUr7TiY5TKFOFgK4xpJxtoUqDEgIrTAd42Ml75wpubm7K0kiBTpnklSizJob3T55LypIl69MLrLR9Ms52OX5jogzQ76UhYrWsVBhNKgI6iTWxyqS0orVFn67cWdcPCl/j6PivgAPFvqXxqDVlxzCBPFTgFpsTwdyudlltA== 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=m9EZg6hgUN/dPAkIluWwcqmYHyResOBRpUhAQpACT28=; b=EK57XGBhTe0CBiPhuJOgKFt/H/6KmyrMbT5XMwEYI1v475fE+mH1P1541s4ZOE3BcR9dGBYDWDj3J0ScL54dA2beGrYjABOsAMoKF7ipRUAjckkEh2ppSX/P5Ml1EiEZCBiHcpfC7xhXdZ7lxJfSKRBQsAkiqtlwQJtcmkvKLynkB6Sm+DxgXky/1Flp/eJgqVMJvNkaV1kihgN2dla/Q+z2Mn5im/UZDIEgv27HFApcrrA1o0fyjRi5xcBt1eVoJByjfahK0HI/BaV8iA2mM0U4Z0RbaS12uKniYTfncj59ZpcWHnO6vEFo7EKMX+Zk2Wa6Awu0nfJqFgdWfCKiCw== 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=m9EZg6hgUN/dPAkIluWwcqmYHyResOBRpUhAQpACT28=; b=Dr+LPQGrfPyoTLQ6ANQdZ+/2bpTxuD1JL2g1BbZ84SMHiiu5FtJQ2LZqtLaDVg/rLBJVdKxp7DkDl83I3oQu97Sey59Xto7+Nl79vyipyzy1iFDoiUmWXYwHgPoF7MyRZy4uoXmwEGZSffhK6y1onrXuB7BSFMqVyEAKMPjwwn4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by PA4PR04MB7725.eurprd04.prod.outlook.com (2603:10a6:102:f1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.19; Mon, 20 Feb 2023 12:24:03 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6111.019; Mon, 20 Feb 2023 12:24:03 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vinicius Costa Gomes , Kurt Kanzenbach , Gerhard Engleder , Amritha Nambiar , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , Florian Fainelli , Ferenc Fejes , Xiaoliang Yang , Roger Quadros , Pranavi Somisetty , Harini Katakam , Giuseppe Cavallaro , Alexandre Torgue , Michael Sit Wei Hong , Mohammad Athari Bin Ismail , Jacob Keller , linux-kernel@vger.kernel.org, Ferenc Fejes Subject: [PATCH v3 net-next 03/13] net/sched: mqprio: simplify handling of nlattr portion of TCA_OPTIONS Date: Mon, 20 Feb 2023 14:23:33 +0200 Message-Id: <20230220122343.1156614-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220122343.1156614-1-vladimir.oltean@nxp.com> References: <20230220122343.1156614-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0183.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:8d::17) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PA4PR04MB7725:EE_ X-MS-Office365-Filtering-Correlation-Id: 35d7992e-9601-4482-3e7e-08db133d5a24 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1mJWe/0sA+JGI22kY9o6nfNvQE0z1iT0QCYfztEM31VKnKYf4OOerdTZr0xVRYjWmr2P2JzlV42Dv+S/O9ysoQVOWXNbLAeLLnFELERidgExJggdIbI3vYkmfUYxr29O+nVG9PzSMtRdsxMeIhIeOfN8dOGih8OBAz8jj5maXfKlHTh8BETvu1VrZQz+CzAulPpZU7YOGyZTRqP0Fm27DboUrvRFgY5A6TI/RKZD7d1b+WIYCRSIKRJXqXnS6maxyafqL7ipBa/zyGVBvPuxlvOnc10o/mcxNdhIAiCVzyNhO8Rlk1bwCledfmSwMRSRdZjc65jS20RMknVDuWVUH8fL9vD0C0SCQlzJ/1BKuUBsksUgJdZGfJwrgw5vRdxg+Mr703mIbLaMCv6tsbmalSskIFpCxG5UMg4Dfl8Ru8hUjdk7dcoID0UhP1hjxx71bzRm8TS0Ps9J+CE2wug1kZD2qroCbYEVY5mhOi6nitKhBsou1lsHi7zDyJnoNdsZ5qBSsSpO5oV94lRkCD//KDGc4F0bAo7enwdYXapsmR2oZPqX+wgbM7Oi5sSlMZhJe04uHSlS3o9s9pL34y5om6F05AZ9RYBxJB3+b8mjKp7usXXaGRxgTOTRFKnm3u5QhbkuSfz0uOzhSeqS04Rw4pdYGKoZnd7R39dpLTFcoM2xyFux7zT/kWH4Cy+wzzwgbZ3eDdeZDikipW+d3ecfaA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(366004)(346002)(39860400002)(136003)(376002)(396003)(451199018)(8676002)(6916009)(4326008)(66556008)(316002)(6486002)(66476007)(54906003)(66946007)(7416002)(52116002)(8936002)(5660300002)(41300700001)(86362001)(36756003)(478600001)(38100700002)(1076003)(38350700002)(6506007)(26005)(186003)(6512007)(6666004)(2616005)(2906002)(44832011)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XLfFqcsfCv3fCQl872yi13Qnn942eAYpBeaxZwA6Oc13se1R3NWJYb/oIFdi0Lyq44L0LW28gIs6/y4rIjNSrDxtxG8wbtyMhKKrOWtTLHUoGqCV9fI1SgSdZPqv2pzaEeg86/vwZKAQagNip9f0B58HNVnMELF4CHYxfhw8uguyFCIsNSbEYvI2MaQuwBrN1YLtam1fBHp6fUZdnC4ypoovY8jxeH47FNpflKWd9Do77r4xKFChbW6wc/ypfr/9CPgI/+qBQaU86uopd8VnoJnnaVUt8VLNius4K4PFKSPW8OkXpsTewYZ+ihYWAzEqO2Kk7eBwVePRdMNYQBmQDwqrtoLapZoQoYbpbkDdDxc5MrAzAt0oXNFO9QO+mEMyFtV8J3Hb4DnFySs8nGiI2uFhYvfOtBI86vQq3gxUdTohGWGl876PQatPY7NJZ2xBLQ6B/cFijCSq+sZ6npjN2Wk8CT0BnRAAJovuRKXsIJ2BZp/jYW/SgrcToWNiYbVE8IK/JL7ssH76K7BRuxIs6ICYqqthv9AhFzTEzmFPaWzUBjJi2fujaOYNEO7pnlvDvABk31+G6KBUozIFS3P/m6DTDMnGLAgEJNcRLeAb6S47/uCKz82oH2VZm9/9dd5SUbZpsH/OO8X9aLR9QQalbmdPQfNew2hNwcrxYVQ+FlHyGj96DIsQvcNGS1G13CZ24M10cphb108lXEVxAmeDTmsw4Kahq7PhGBqF7ChcVr3OieSI9SyMPs/+ykAILhXdPYBmT0KUV8L/9/BYDfdAYGSTi3NDZuNafJZDBK8CxJ86VqhNHU2zjnk9jpcW4c2YxsRndAjE0VLadD/vLqvnUUJkGHx0MMn/WBI788GjVxaqoMRNhV6TGCGAALRbyuChqPEBWlv/QQIX0OlkR1rc+H0psWqVUtIDuNnAPj42FcARiUptqHSi7+LMeKQpHzRoZu5MJx6NbNBXQAFBZ0r+lcVtFYEWV75bD5RAjVUVqrr3je0hZ0Lx8BYzdY/EDjUqXwa3q6hVYD0vzlt1BJblb9s3CJup6bARLwteg3wzj5XMztICpOk7iRWjaLcsavKa2uXz1fDu6iRf2dmX/9vK81PFrLxRBD3SI1yddLcB6EIAnRGxXHhLARr3RwmoVfjR4fBUcnMGO7dDsjycEPbm/mk6MMgy1jNq5+tBOCDl7U7OW0qmGld56wFCVJbPHWQfAt8VllvSVTJS8sgGukdJ2FzYyv29HZQC9Aqigf9VLys5GxCgQqN9jrXwaC614mROPKhc4NJ1ig29KeMPnF8IQ2Ut98NgMt6dWToPB487krHCF6LSut/L5//AKpisiXoFpJ5K0i6i22KQY7xEyYQgPGa6lCM6y6AXMzr1niTP9zUtLjDeQs+Yb07+g8a+ph0OrlwU8Ay2N8TM8yiXkhjYMrNMEtETqu0i34xWRLD9B3KB48N38hYZG/Z89+GU2xJpC3aALG2is0w5zCeh+N+qGimNVzdgD2NVxnY2Moe8NCqUdHmev+VSMoBDN393wttJuKotz1/eHfegQoftdNQomopA+I6kkL3TRi1WpfdQuXtjE4fj4HScWIbo2ezobmTaR7TrrdGMEXp+X27yoVe5IA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 35d7992e-9601-4482-3e7e-08db133d5a24 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2023 12:24:03.2283 (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: 9EoS3hWEcesVce+kjXFuas0D3BsxA1QUwNh30g90Jr8ZhGFzoTva/bN4McMoS2+gKHpCPjzvmeZbTv7fimzHYQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7725 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_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758352833610490841?= X-GMAIL-MSGID: =?utf-8?q?1758352833610490841?= In commit 4e8b86c06269 ("mqprio: Introduce new hardware offload mode and shaper in mqprio"), the TCA_OPTIONS format of mqprio was extended to contain a fixed portion (of size NLA_ALIGN(sizeof struct tc_mqprio_qopt)) and a variable portion of other nlattrs (in the TCA_MQPRIO_* type space) following immediately afterwards. In commit feb2cf3dcfb9 ("net/sched: mqprio: refactor nlattr parsing to a separate function"), we've moved the nlattr handling to a smaller function, but yet, a small parse_attr() still remains, and the larger mqprio_parse_nlattr() still does not have access to the beginning, and the length, of the TCA_OPTIONS region containing these other nlattrs. In a future change, the mqprio qdisc will need to iterate through this nlattr region to discover other attributes, so eliminate parse_attr() and add 2 variables in mqprio_parse_nlattr() which hold the beginning and the length of the nlattr range. We avoid the need to memset when nlattr_opt_len has insufficient length by pre-initializing the table "tb". Signed-off-by: Vladimir Oltean Reviewed-by: Ferenc Fejes --- v1->v3: none net/sched/sch_mqprio.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c index 48ed87b91086..94093971da5e 100644 --- a/net/sched/sch_mqprio.c +++ b/net/sched/sch_mqprio.c @@ -146,32 +146,26 @@ static const struct nla_policy mqprio_policy[TCA_MQPRIO_MAX + 1] = { [TCA_MQPRIO_MAX_RATE64] = { .type = NLA_NESTED }, }; -static int parse_attr(struct nlattr *tb[], int maxtype, struct nlattr *nla, - const struct nla_policy *policy, int len) -{ - int nested_len = nla_len(nla) - NLA_ALIGN(len); - - if (nested_len >= nla_attr_size(0)) - return nla_parse_deprecated(tb, maxtype, - nla_data(nla) + NLA_ALIGN(len), - nested_len, policy, NULL); - - memset(tb, 0, sizeof(struct nlattr *) * (maxtype + 1)); - return 0; -} - +/* Parse the other netlink attributes that represent the payload of + * TCA_OPTIONS, which are appended right after struct tc_mqprio_qopt. + */ static int mqprio_parse_nlattr(struct Qdisc *sch, struct tc_mqprio_qopt *qopt, struct nlattr *opt) { + struct nlattr *nlattr_opt = nla_data(opt) + NLA_ALIGN(sizeof(*qopt)); + int nlattr_opt_len = nla_len(opt) - NLA_ALIGN(sizeof(*qopt)); struct mqprio_sched *priv = qdisc_priv(sch); - struct nlattr *tb[TCA_MQPRIO_MAX + 1]; + struct nlattr *tb[TCA_MQPRIO_MAX + 1] = {}; struct nlattr *attr; int i, rem, err; - err = parse_attr(tb, TCA_MQPRIO_MAX, opt, mqprio_policy, - sizeof(*qopt)); - if (err < 0) - return err; + if (nlattr_opt_len >= nla_attr_size(0)) { + err = nla_parse_deprecated(tb, TCA_MQPRIO_MAX, nlattr_opt, + nlattr_opt_len, mqprio_policy, + NULL); + if (err < 0) + return err; + } if (!qopt->hw) return -EINVAL; From patchwork Mon Feb 20 12:23:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 59412 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1276892wrn; Mon, 20 Feb 2023 04:25:40 -0800 (PST) X-Google-Smtp-Source: AK7set8CR5+sE2AMweY50o8kN8qfXuNKbo0hU1ahwBxbsE1gDFW/ejQ4991fjHmUT6AOK8muRWBd X-Received: by 2002:a05:6a20:7291:b0:be:b137:9d1c with SMTP id o17-20020a056a20729100b000beb1379d1cmr12155086pzk.37.1676895939859; Mon, 20 Feb 2023 04:25:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1676895939; cv=pass; d=google.com; s=arc-20160816; b=ILX/3RGH2DUMxbYua5CSktgmU/i/lAeTkvCSZKHSWMLKvNabiKuBe6r2Wd7Sh37E60 GFYcaZZod9sj8QLUfTL1MYUXJry1ExMfkin8ky7ZcEuJQHyKqK0PWuuwHs9JCoOMjtxC qnERSxvThi5wdfcXVFHlMw8rJuspE2tWJwFqiICCLc6/LVVZN5PjrZNcCeOHnHjgZVuK PpoHx3U6dnA4OFGD4cD6ZCIGkpiGdJcMWQhrsnj+fXgt/yonpWqR37q1tps1eXa4W9r+ aVskv1wuchpFwb5qUFV7tX00iys68P2QdCOTI6Lxo/V9o7TxkIE4/RTxbqYZ1Er5/E5n ELlA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QyyofujqUIRJiXljGPJ3G/lvIRLm5Yx2jXCQIilfv9A=; b=XyldiG5Vx7qIQI3mQQVOSD+cIQqyvDwgJNnSegj9Do8X0TQcU1fGt/R1Ce48J/UH0f x0BxviklV4i8zYqtNHueC80cfCgsIt3WjWgkmv3qVLqqF3PURCS5MY7svejMIx0BCt5P 6hF+WplztVvclIsUdZ5YiF2PzuqG/S7iF3M0juXuikZ6XlwBNc84zxEGPktrr7zwp8xx 9BXdor97wX5ud2HaD3SxhIuaA1GlvfW1zqgQh0xIe+CjjORm47SRQh7R95DSxFUQWi5A FdWrXpb8haAaooquSrhZW8R6eXQ5+5caTUsjeERONNSUrEC+HpWkOIRvj1/ptcBfQEgL wGhw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=hNDGAX7k; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s73-20020a63774c000000b004d2621d6a70si15118299pgc.163.2023.02.20.04.25.27; Mon, 20 Feb 2023 04:25:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=hNDGAX7k; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232056AbjBTMYY (ORCPT + 99 others); Mon, 20 Feb 2023 07:24:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232038AbjBTMYR (ORCPT ); Mon, 20 Feb 2023 07:24:17 -0500 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2079.outbound.protection.outlook.com [40.107.15.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A6DA1C322; Mon, 20 Feb 2023 04:24:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D6+0aNYciQQQIhCokmgPM7WapN6OkqmlPhUh34d1NtsH3tyjDZrD5NFx4zL0Bo2I1xgWVLi4CDp7EFxETk4qdm9IVr9rD9hpOqr13BFNdOTn9rRXn5U1srJyLcX84qibj09MLTlazsl0K3aQGGjLFIePRyP6hXwBbVr6lQoneV4YjvU7C0Kw6FnSs//7kAatv48KTd3zJ6Icq8Z+ikRHTfBpm46WfL9ej1KIFIQLx1DiOHJpZ7ckj0atMfE/6s8Dmhc3SE/PzG8ufrIQU3dqvqv45sGKKf7dNONXWuWYzdn5XWGC+cr7Bq5e3uSsSALlSkW/9udvgDDYnJkeb61BnA== 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=QyyofujqUIRJiXljGPJ3G/lvIRLm5Yx2jXCQIilfv9A=; b=A84WNTwAMiLu6DkrU3/DB7arxqdO2NMw/G/ipTsmzSldQtmNCfMWSSdBOtxJ1a1C5wlCj42FCZ8flWEGISi5xZ6vd/4kzC/gTio/gRHgrqnduKQMLZ3WTSjHJqoD23wdMR6rjW0FnIasTfJ/8MQxsfledQqeUexfgeiKBj+kiK6oFiOYeocMsq9R2CYUHcEw2qg1yL1TTkOjlTiOPuQLt3Ffys83C14dZYJ8AVQm4dCNBzvaMh88GVIrsiVgJGna3h2WNiIBb2qnFHNK+T15JxM2y99zQ+6xX4UeijkcmuA8JYCvsE08EC99MDIe/BzEYZiBGd9KNMFqXwnB74+QnA== 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=QyyofujqUIRJiXljGPJ3G/lvIRLm5Yx2jXCQIilfv9A=; b=hNDGAX7k1UbntYhSIsOUiLpShLxDxvMg4Db3d20kOADLbWtf+2UsaK6XaWc/ICku9mhhBSIEjLH1VfmKzWc2Sa7r3ys3fTaXepg4ptYJlH+5Rsrth2ULRrz6xRKJFBQx7TzkBkXOQyF621nHI63K0z90b+KLWJ7PQrTYYKfny0E= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by PA4PR04MB7725.eurprd04.prod.outlook.com (2603:10a6:102:f1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.19; Mon, 20 Feb 2023 12:24:05 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6111.019; Mon, 20 Feb 2023 12:24:05 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vinicius Costa Gomes , Kurt Kanzenbach , Gerhard Engleder , Amritha Nambiar , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , Florian Fainelli , Ferenc Fejes , Xiaoliang Yang , Roger Quadros , Pranavi Somisetty , Harini Katakam , Giuseppe Cavallaro , Alexandre Torgue , Michael Sit Wei Hong , Mohammad Athari Bin Ismail , Jacob Keller , linux-kernel@vger.kernel.org, Ferenc Fejes Subject: [PATCH v3 net-next 04/13] net/sched: mqprio: add extack to mqprio_parse_nlattr() Date: Mon, 20 Feb 2023 14:23:34 +0200 Message-Id: <20230220122343.1156614-5-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220122343.1156614-1-vladimir.oltean@nxp.com> References: <20230220122343.1156614-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0183.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:8d::17) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PA4PR04MB7725:EE_ X-MS-Office365-Filtering-Correlation-Id: 3f4ecc86-8459-4f46-eb45-08db133d5b9c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JRuw5s5zJEFg7hAJxfw9Geh8iHGKfMI/9DU4YLehuZo/G8EjJW+JAbNu++hcDYYE2HSyftwAhRrs3w1Bi8qEQatj7DwbAL0gZks3ZV3AiQzJeK/9Nm8l2ddWaeyP1PINzkiEEPVTRADEq3LFwKyF55uxKLcgzYdkv819JuX7EHEsyvFuNsfnVxA1Yt5FtvXLk0i67TfnGFYDbUf/72EOeczxyfvP2sBAKCuklX75uxU6ek7I6vVdkS7YZFsQyg0U/0zxJiV9odgbILVhSJmykstg3oxRYBPRCtMdSszSp6ULvYbO1wa0pOtBqt4ycuXNaD5hpeeUNH4PbOlPAN3A65SEjWMnJ9ksDLihUauOr/bEUOXz4umr3L5MTbjVlgX5TPMfAE4Mm0lqR4QU4ZD4AxiWjYRjl418+GTbw+0YHO2sGdNfmee3jqfiAhr9S5WA/7vJVt6tX98llrPTInOKfaoOOi+j/1UGtcgW3hqiIO8jQtmZ2jwrXyQgeDLQ9nosNgQG9iVgH7mBF3plL32FclRYncbj++BF6cjFCBs1dVSRWobHFRakWd8eTL7wR32JUKu2yXEiGQ/tnBzTbq999EC9DLSINgSwn5PHbUMjCg1maCbd3T7Y0c5/jZO0smjNRQ0p/6/IvMoiICjFbRIFJP6cZ7Bjp4egi7JaW75pDxvW/ikG17QAYMNxGwYQ6UHIBYUk5Xw2x5uOE2Rc5lx3IA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(366004)(346002)(39860400002)(136003)(376002)(396003)(451199018)(8676002)(6916009)(4326008)(66556008)(316002)(6486002)(66476007)(54906003)(66946007)(7416002)(52116002)(8936002)(5660300002)(41300700001)(86362001)(36756003)(478600001)(38100700002)(1076003)(38350700002)(6506007)(26005)(186003)(6512007)(6666004)(2616005)(2906002)(44832011)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0fQQ69r3esQq3Pc1YJx0wLKgsByhSxuajWBe4yLerOoxkf7DGrIKgCv2TunWTv5z06QDQ8D6j+9L/MCH780grMMhUMcycEHN34JMAE1MSiDSje29wCM3GPrbhypXW6G8B44WrIiO0b+ri9aD6PvIWDTMEkTI/DXBQZDcwfUgOFQVJt5Ptjo6qJ8t70TBrLzOpFJUPH5+3CAyFJUAJTA6Z6P9GhTFdAQsCRAkBj/EWkkxptfG4w+BjGAINMLQjju6UECbMcCKbu0Q+um0fY5n09QGKnnDRzvka5fYkQL87iIcqaX1j1ZBcd2xQ91UN7zcJB5LdpSKtv1DCkML7kpRDJT5WYE8ff5ZyDeWkYRWnyRzutlqHzgdnXS7Swb/cutmZpHg01P/2JHD/RBKr+tJHeaumJMRaSyeujAs91bg5Y6RWeLeXwEZTdizhiAnBoKmNXKNh954dg2g4XX3FBTxOO5tXxBxfwRiKdJPImGrZ0mVXFgvAc1qzztFp7JXhu6UQpdLkYZnOLFgJhaIRIjqePThAhsHAngLSxGSoGf6D9phn2MWoE77H+c16eSQr9HOG7Xkzn3j+5Eju8X6UmowClhX8C+J+9tmHCOjXW5OPqOO58Znhq4HCLc8GG977kenzn43qwbJ8qBpclvmGS8XYrAFrj0y3YCIh79NXJb59uAQYJLsYME5SsWbDczblFBcK0tn/wRpNUbdVhPuS0dPPG9fqMUUQQvih/Pakxb32+I1YEmUesQm0znEQvMubk+0r2diBq+t5pSlN9qNctOi/eEyM4vXSNNFI7EGAJcQ27j4CgShc3jMKQxP4cA+fIYhEDqkqhZUE28yWlOo+ahpD2wZC0aZM3Hdb6XhBOHGuwQ/MfGfJdqOVj2Npe8ZLcFgOWmJKlPCzM3o+iPNSuuUcFJ98I6EU0C6ULPDkBHRpadKDwzsFm6fF5hULLe018RScaHco2gXR5tvS0vknjzA07Z4nfmFOqV7HSu678/90HqVkR25OrUOHdHEg2zWOxfRUT8YTnmn8Zct2bqh8C8/FYPb0r2JLlO/KQWSbfvRkYJoxKxe1WM0VAfBhE5ekcTqhnraKGlMbtjua+/4jwZpyMyGhWwwopwu5gMWmMUgp7N6/1bcoPDLTVyTI02e1zRWa+NuS2cJZCLa1bTWkjjCFn0CrmGulMawleF3og+n3DYTa7wsdQqfk+34W3LaKH5NDuKh5bQNNqOd2rOrHB2PO8QETpJFGAuQCGM0EXSkrrunEJH/9KjvRdyiAzHPOVusN8MjpD/+NMYcJZDLCUR1jcl30iPyTMopP6kodB3pnb4WJMumpARBPrUB6JE1rqOdbJPnUf37GEErDzs4eLZYaHYuWigrA/IDsmqTMNCby9NwKkkOeK66HyLOjJjE4UdgfaEomUWhaIRI4Z8JjyftW9gCZdYi4r6w/msk25WM43yEw3oqPHqTVU68lAZ7aEmMIdTkfq1T6YfIpwVmmkisgAwXqsVl5fpb34+yamiqr7BPFeQ50HHBJRMdaVakOxyzUSVZugRSIGg/YH1lDJBLjsVZo9lTJKF5N17h/vZeX3Ml28qQU1yhBo1y5dCOAY5N3LAiP+ngdngfkd7HOfrQfA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3f4ecc86-8459-4f46-eb45-08db133d5b9c X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2023 12:24:05.6187 (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: u715lqPIu3IVgnS4Fh6Auwc/2n3naKSIui8e4IouWdzCSwd8x0kA6JpQAQ8SxExbTYmdvAgZ15hgTLM0eu5yiA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7725 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_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758352837130035403?= X-GMAIL-MSGID: =?utf-8?q?1758352837130035403?= Netlink attribute parsing in mqprio is a minesweeper game, with many options having the possibility of being passed incorrectly and the user being none the wiser. Try to make errors less sour by giving user space some information regarding what went wrong. Signed-off-by: Vladimir Oltean Reviewed-by: Ferenc Fejes --- v1->v3: none net/sched/sch_mqprio.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c index 94093971da5e..5a9261c38b95 100644 --- a/net/sched/sch_mqprio.c +++ b/net/sched/sch_mqprio.c @@ -150,7 +150,8 @@ static const struct nla_policy mqprio_policy[TCA_MQPRIO_MAX + 1] = { * TCA_OPTIONS, which are appended right after struct tc_mqprio_qopt. */ static int mqprio_parse_nlattr(struct Qdisc *sch, struct tc_mqprio_qopt *qopt, - struct nlattr *opt) + struct nlattr *opt, + struct netlink_ext_ack *extack) { struct nlattr *nlattr_opt = nla_data(opt) + NLA_ALIGN(sizeof(*qopt)); int nlattr_opt_len = nla_len(opt) - NLA_ALIGN(sizeof(*qopt)); @@ -167,8 +168,11 @@ static int mqprio_parse_nlattr(struct Qdisc *sch, struct tc_mqprio_qopt *qopt, return err; } - if (!qopt->hw) + if (!qopt->hw) { + NL_SET_ERR_MSG(extack, + "mqprio TCA_OPTIONS can only contain netlink attributes in hardware mode"); return -EINVAL; + } if (tb[TCA_MQPRIO_MODE]) { priv->flags |= TC_MQPRIO_F_MODE; @@ -181,13 +185,19 @@ static int mqprio_parse_nlattr(struct Qdisc *sch, struct tc_mqprio_qopt *qopt, } if (tb[TCA_MQPRIO_MIN_RATE64]) { - if (priv->shaper != TC_MQPRIO_SHAPER_BW_RATE) + if (priv->shaper != TC_MQPRIO_SHAPER_BW_RATE) { + NL_SET_ERR_MSG_ATTR(extack, tb[TCA_MQPRIO_MIN_RATE64], + "min_rate accepted only when shaper is in bw_rlimit mode"); return -EINVAL; + } i = 0; nla_for_each_nested(attr, tb[TCA_MQPRIO_MIN_RATE64], rem) { - if (nla_type(attr) != TCA_MQPRIO_MIN_RATE64) + if (nla_type(attr) != TCA_MQPRIO_MIN_RATE64) { + NL_SET_ERR_MSG_ATTR(extack, attr, + "Attribute type expected to be TCA_MQPRIO_MIN_RATE64"); return -EINVAL; + } if (i >= qopt->num_tc) break; priv->min_rate[i] = *(u64 *)nla_data(attr); @@ -197,13 +207,19 @@ static int mqprio_parse_nlattr(struct Qdisc *sch, struct tc_mqprio_qopt *qopt, } if (tb[TCA_MQPRIO_MAX_RATE64]) { - if (priv->shaper != TC_MQPRIO_SHAPER_BW_RATE) + if (priv->shaper != TC_MQPRIO_SHAPER_BW_RATE) { + NL_SET_ERR_MSG_ATTR(extack, tb[TCA_MQPRIO_MAX_RATE64], + "max_rate accepted only when shaper is in bw_rlimit mode"); return -EINVAL; + } i = 0; nla_for_each_nested(attr, tb[TCA_MQPRIO_MAX_RATE64], rem) { - if (nla_type(attr) != TCA_MQPRIO_MAX_RATE64) + if (nla_type(attr) != TCA_MQPRIO_MAX_RATE64) { + NL_SET_ERR_MSG_ATTR(extack, attr, + "Attribute type expected to be TCA_MQPRIO_MAX_RATE64"); return -EINVAL; + } if (i >= qopt->num_tc) break; priv->max_rate[i] = *(u64 *)nla_data(attr); @@ -252,7 +268,7 @@ static int mqprio_init(struct Qdisc *sch, struct nlattr *opt, len = nla_len(opt) - NLA_ALIGN(sizeof(*qopt)); if (len > 0) { - err = mqprio_parse_nlattr(sch, qopt, opt); + err = mqprio_parse_nlattr(sch, qopt, opt, extack); if (err) return err; } From patchwork Mon Feb 20 12:23:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 59420 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1284591wrn; Mon, 20 Feb 2023 04:42:54 -0800 (PST) X-Google-Smtp-Source: AK7set+pT6K6bl5LrTDhx7oATtOSSBqtwgWHi7ChO0RYYfOUSNcd9ZvoSit1Rrl8/hkDZl1h4Rj0 X-Received: by 2002:a17:90a:e7ca:b0:230:d6a8:a9e9 with SMTP id kb10-20020a17090ae7ca00b00230d6a8a9e9mr2459239pjb.48.1676896973707; Mon, 20 Feb 2023 04:42:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1676896973; cv=pass; d=google.com; s=arc-20160816; b=N4AzLgSPAH6dQULdPARcPg7aPx2eOiCAJYnAwlQX/CzS/rfQpwx/Wrcyiyslacc19e KzQNoIYOSWUegUKEA8iVaA5FwIEPToI2b3ltPLoX8CJVUaDS81ld6f56DDLxAwAVuL6U WBR+fuFZzP2dkcw+LNrmODA/8KgGvpDlIpNmmAfGuKR1Av+mG5F0q7Os/KrrS/BrDlY9 ql0OX467qnuuANeOn45kTJjTyiJ/X5GnDezk37YxLKD5Yx5fz6qMfd62equaJ44KiZgP wJQ/O4ISxkThdgg0eaW7zwsn3tAH7Atw6rZDDIsB4HIyMXLKIQ49Tn3favhsCQMLiiG1 UCTQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=31NXDItaO3nwoXsGNg/z8WeaQTyKw4MZ3sYySyK7YJY=; b=dyHt9ttBTCUPx/ed9hmq8TuRhF0KBBF7I8k11GxcNJDsZI4011ZHqy9ALnr8tX41E3 mtNxSx3vNrVzQZU0iEblhtGI8a1M14RE0NQjzYDSnQldlB3NoXi95lv7nl9NmlChaAqf qGZIkrFIdBwroKkw2GsEFudhgHznhqtbo5Lss6vkQ+hDjxmnP0A93aXgcBz0xKE/JPHz l1noD3GC1DGfolTH6MklQNVPAj1QPNit4ka4WjD0viRT34UhDT5wuAl966IOBvIcWl6i kM1/oTpi2zUG9dHwQ8cwsSGuzysNK5TagJMhCRWLvnqMkg4TrlELV+DawZObRXufNAC2 60lQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=P0fLopy7; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q15-20020a17090a1b0f00b00233e26df9dcsi6073642pjq.127.2023.02.20.04.42.41; Mon, 20 Feb 2023 04:42:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=P0fLopy7; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232097AbjBTMYj (ORCPT + 99 others); Mon, 20 Feb 2023 07:24:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232064AbjBTMYT (ORCPT ); Mon, 20 Feb 2023 07:24:19 -0500 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2054.outbound.protection.outlook.com [40.107.15.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54A251B561; Mon, 20 Feb 2023 04:24:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dMRU6TFud0bgpjf06c0sk8P+8EhzTTFuXBXLT2q3CUjubO33Vsn7zlUgdD5+FJ2130HPiWEJ8tK7Cqq0TlufVido1IhRanwOgvk1B7gRhw9GteIE7xycZOGOjN/he7EOAezNxJLR8SwL1e8HKfQPUT6txo2HadbuVASvd1MdCw6LHL/peFTpbsDVvy1gdhdTF3xwwI2a2yHO53bL7WyYgPwMKyc3w2HTGtCDj3V15eEvjd3qfrX3CWbwkU+0Nuu2TGJ8INW7paauHCARW0OKcm4ec/Mj9gDHP135rsXtD0pEKBkPMOK6V6CJHknsd/o4MTVYoReddv7Y7iItHDaKLw== 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=31NXDItaO3nwoXsGNg/z8WeaQTyKw4MZ3sYySyK7YJY=; b=DdOsbi09zm59Ya+pWtQ8FZDdizvyjoBIDJPRFNij8a0JAlgVIB2UKrQFCM0GYvMEysYaqJiCTcVoa3RXmu6JdF1PdpHg8636wvjK8nk8rFVVau7N/LJ6ir/xA+UfUXtss45mfxGfXFnqs2renVo+eWgySMRGbPgrSKbUcZ0pk5bCWyxo7Thv5ZAiyoyfj2D5+4kLWUZsXMpWGGEgqM9TpqEGfiE/Y42um/7DsOsL62i41wZ5SmooVR+yFrc21MCdoITOVBrNAPXVkV7QAv302Yku/BTdgzyTOY81PmejoJ5PLR2kCBDVrxCmDR7IIavD17FLG8U0oV9x87flCTuHSQ== 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=31NXDItaO3nwoXsGNg/z8WeaQTyKw4MZ3sYySyK7YJY=; b=P0fLopy759sySraP5cGzUPshINjIi9ysjPEkdzQhgqckQE+M6nHq/g2OD9zYX9zViBWA/q0s3FgFFoJK//L7MV22/ahJG3Fe3JoCx1ZHxalZRKPjZx0DJ9+QEBE+CB6CAOrTf9mHUaL/o6tiYxD7QMQSmKpzmFr16FCdmtTVORw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by PA4PR04MB7725.eurprd04.prod.outlook.com (2603:10a6:102:f1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.19; Mon, 20 Feb 2023 12:24:08 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6111.019; Mon, 20 Feb 2023 12:24:08 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vinicius Costa Gomes , Kurt Kanzenbach , Gerhard Engleder , Amritha Nambiar , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , Florian Fainelli , Ferenc Fejes , Xiaoliang Yang , Roger Quadros , Pranavi Somisetty , Harini Katakam , Giuseppe Cavallaro , Alexandre Torgue , Michael Sit Wei Hong , Mohammad Athari Bin Ismail , Jacob Keller , linux-kernel@vger.kernel.org, Ferenc Fejes Subject: [PATCH v3 net-next 05/13] net/sched: mqprio: add an extack message to mqprio_parse_opt() Date: Mon, 20 Feb 2023 14:23:35 +0200 Message-Id: <20230220122343.1156614-6-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220122343.1156614-1-vladimir.oltean@nxp.com> References: <20230220122343.1156614-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0183.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:8d::17) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PA4PR04MB7725:EE_ X-MS-Office365-Filtering-Correlation-Id: 7da9ab75-2b4d-4d38-e7fd-08db133d5d04 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: do0shaaIuSRe5w56Xh9qa8qV3z4ATv4k/PKjfEMJ3Ud8AI52Gj7YhyhBHeq6cl+acQrDniqH4iHG6Cu3GLuvi9Luai1jC7daUOgDsoHpv9qnA+YMf0bWv7UgEHSA+DIW3nar3kfZKTH+mOk7XufcEJSk8BejXh7h2TLpAlz7DeOCbEmbrqGTFaU0F0EGa/YQ7ZFrp/wiI5LrSONIN9d3+DyDf6aBBRHoqq3rRCtYQEyfYppNdDVYZAqe1CByAb1mjHHU5YeggEIC7C285/oLyuOvWu7+mouqkhq3zybLMi397Bxgad0FSfjuLaG+//kHDRTD/GJJYZ/Rpsb7yM+H3MvLGnPVqCfcmyXwmytWyzRqNcGNjEpvX8UaaygiFQ7Kwf8qnh1oGQ9INjfnmusaGmy3g5AZ7b8FRUWHsgdfhywjpKfHC9tURebzvDkuHONmc36QhxPNogEHFMz2CsipBxXA2PySMJsuXLYO+f9yCIu0EttqxeOu1THG9G1HhrCW/y2ximWfF+WDIfHf7Y8yzhjFOAv/YfwPaww2Maj+NG+sXxA/wBbJkRw90VDXrQUqPmKVMMvbRzvzY+Ntq6BeMVuzQx/xI28I4Jf1HpFs5YMiLpwpkM0SGvVuye4uQNakXVtXH0kM8DA1NgnQsispyDOxt3HkRjVrIHQYehQLgJUksc5xk2rjk0pWXYdW2QWF X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(366004)(346002)(39860400002)(136003)(376002)(396003)(451199018)(8676002)(6916009)(4326008)(66556008)(316002)(6486002)(66476007)(54906003)(66946007)(7416002)(966005)(52116002)(8936002)(5660300002)(41300700001)(86362001)(36756003)(478600001)(38100700002)(1076003)(38350700002)(6506007)(26005)(186003)(6512007)(6666004)(2616005)(2906002)(44832011)(15650500001)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UyNUkaKSACsoGC4oL0V5uNwT1jzNqaqpLlcGi9hMiPXMNqTYis0IvnIQ2vThh8KFlGNMLXh1WN6Xs/cAivf+H0Hf6+5QLRd5nDiNDJvf0PouZlHksf+OQl7RfhihJUFtKKvLTssy2PzacuOIJGfvAHFTTb14f1QwYI76mE2pZFvHp9Q9VUwPnNL2YROwqnvKFMkc3brLU8txSFAEOG7+zAvBs1+YWCzhKVm1KIdaqxZR5cApBfyVD2YtiEU3UnHwX6fxXDgg7mzNsDTcIQm8eSs4xVhNSSoe1PSHCx9bMZBxggo1rgLl2SPM/ggtTdgq10AUHAhFM19vFIVahcoV46wWxbbES4TDhrc8Kf28HAbM8Ru2xPpJLIhJ1M3iZZr3fT5rwFIlrrFWQo8u+IQoiiJMp4Idn7IS1L1Wvcg3wM9fN62V2AIlWD4HYD7rPGui0eCpXlQYXfAeJx0dCYbTuMhwTHnuQ6W1yLAlogQfkhEN4/o4pKCiy12eJiproRbKf18BR0gsZAJ4x/tqd8OmgoMvUdwq11RHLZpemHO8j2oFabLd42H23fcbf8C9xPYyg5n3ICCUaIYgmmBAeP33GLsjrK/ye9Rl5a6s3v5DDUY65ZDNqW2cOpTuxkLac68WepfBkhuVsvX6KLCUVDakjFxilrhwPrbvoSQjmlYrxyIU3cYSkCbdiGXvGCRlQ6NgM714HP7RbwTxq+vq3hWwEmPjHM1H5HXb9Sd3jqS3rnIAMrlL/SABg+2wth4fWQ2vdzR0dM3ufQP8lxPIi0B9rby/I12UDALyf6oFCy3GQPZlZWsIiX3H+YnwLPuvBW9pFeWpcT85OKx+mTkplzIE314eLAHpA0kI8GoVH5mGpfv2QiWIE7OErn/EFJ2xqti9FlVxEgm4d8oZtxFmiC6EYPBWv8Rif9awgC23B/a+R8fuxv4KLXGLmmVRCdP152R612s//76w2xqT2Xy5lUzRhLLtUvFlE2hNUMZxRidI0prCjfkskUb8JJOLcUUDqLbfV2aMOB6spKeuxq4vf9pMEfhPBHekpP0V1ribC7JMuQ1/V7CGnwdPD1QYVM1jRpkGsc3V5paGu741eBoqYhy8FlxoFUKyosGQl5nRqQGAolbYLmN6Jnw6ULQpu2GEljOWjSxx5MOVFzPvkeX61nc8sBOB7/lRt8zskMYD16QB2Xol9ZtbdiDkNMbE4nCo//Oc+XvCEvJY2P7vCWXqUkeDszsRzwmoEdPyyMJWenYG1ORobk9uRu53bSp5G/BHTXcMYfEn9GQA+j7ZK53yEw0pdJGq5/V4SoUGI36uSQl9+EoVNVhDpY+DwnuMipKxR5DC7py7aRMBRChd0i9hL/U0Qc1wFgERGLsMeG2yXF8lUhdpyr4l9cncaYdv+CojhUiGbgBNk22YCzTOhqr0qUuItnIlufLe5kInRM3Lh36mh3f5ksjM67CEA9+CwyvAry0s8sfp6qcHxaMhkdfC+IlbI4D+m3B440x++Venyy/Fi8FBndDVq5ql97l1Db920sbuznC9e2RqUL4VuL3T0aZBJe7YLm+PXbzYmymOPArYM0UG2g1Si44DwhVaJUjHgW/Tr9gSpa6y3Aa2c61YY/HQ6w== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7da9ab75-2b4d-4d38-e7fd-08db133d5d04 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2023 12:24:07.9779 (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: VzFSeRmAZmZjIgFo33uylsdC8dJ689bdJIgfwo3PYE0750qJYoZcNzpYoJ1n+XXT6+pYuapMHE4J42sAWAkyIQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7725 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_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758353920872182104?= X-GMAIL-MSGID: =?utf-8?q?1758353920872182104?= Ferenc reports that a combination of poor iproute2 defaults and obscure cases where the kernel returns -EINVAL make it difficult to understand what is wrong with this command: $ ip link add veth0 numtxqueues 8 numrxqueues 8 type veth peer name veth1 $ tc qdisc add dev veth0 root mqprio num_tc 8 map 0 1 2 3 4 5 6 7 \ queues 1@0 1@1 1@2 1@3 1@4 1@5 1@6 1@7 RTNETLINK answers: Invalid argument Hopefully with this patch, the cause is clearer: Error: Device does not support hardware offload. The kernel was (and still is) rejecting this because iproute2 defaults to "hw 1" if this command line option is not specified. Link: https://lore.kernel.org/netdev/ede5e9a2f27bf83bfb86d3e8c4ca7b34093b99e2.camel@inf.elte.hu/ Signed-off-by: Vladimir Oltean Reviewed-by: Ferenc Fejes --- v2->v3: change link from patchwork to lore v1->v2: slightly reword last paragraph of commit message net/sched/sch_mqprio.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c index 5a9261c38b95..9ee5a9a9b9e9 100644 --- a/net/sched/sch_mqprio.c +++ b/net/sched/sch_mqprio.c @@ -133,8 +133,11 @@ static int mqprio_parse_opt(struct net_device *dev, struct tc_mqprio_qopt *qopt, /* If ndo_setup_tc is not present then hardware doesn't support offload * and we should return an error. */ - if (qopt->hw && !dev->netdev_ops->ndo_setup_tc) + if (qopt->hw && !dev->netdev_ops->ndo_setup_tc) { + NL_SET_ERR_MSG(extack, + "Device does not support hardware offload"); return -EINVAL; + } return 0; } From patchwork Mon Feb 20 12:23:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 59416 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1283520wrn; Mon, 20 Feb 2023 04:40:17 -0800 (PST) X-Google-Smtp-Source: AK7set/ViDvb4XK/70h5sqgmU0EeYMWtGlYyj1iYcQgRuMrMEsVC4O2+Gz+5AvPYmDADcj1z/A7t X-Received: by 2002:a17:902:fb10:b0:199:190c:3c15 with SMTP id le16-20020a170902fb1000b00199190c3c15mr1850494plb.49.1676896817500; Mon, 20 Feb 2023 04:40:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1676896817; cv=pass; d=google.com; s=arc-20160816; b=LaNOXAu/wDXCUVHcBJVXnJTH5PhDzF9B55c7Cz3nZvODhd3+hig+nGVLSj5GuR3S3F ASQ9ZG+zdnNAzoODiHxLregdR1BHEpRYvOC2SMRqyee3EaE6vAgse9hIjyXAn4bjH98v XFnLsP6ZIX4qpsU+7BTi1RLpop1C/xKXUlPbOQ+ncilgP6q8FIwW39efQSQZc+lwJpAQ vhahPzQNnndtHCogQaCWDUByZ/gaYoffXpb7ICDsrvogONyXGjVyhrfWLN1RrNb33i68 HPRJYZgihHJ7zXBU9d+izhl2ZKNfn5SYAuwMFqsUV2mPitzRuCYLGGH2wgWNfmlfvzkY wIsg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=InaTY6K8I6vtUgqHdvNLhqv7r2tvZqsSyR+0THPOCL8=; b=J0HGYkA62Mj5jCrB4jNiAO0ukymlD+Cy3RYMSDM0vvUnRJ+stD2zHXDKT9/Jd1K6lx erPr60ZGb2oZ/n4PBkl8Q69XX+RdQN4ed6BeOqNbGil1zKpcwIROPWZGzk4Ddkgi3GMl 8TkbpKjngMB56+LQrAYYpl2HN9N3IPV56GHSkk6Jo0kSy+pVigRMCz59pUc6j4m/xNOM veRgVtvZnk9tyJCvgemQVAAPkcJralrvsDatysi+bRKjh+ZHYvWSBNhPmgNDESL/KMU6 UXNTmZidS3Pw4HDb7jLCAq7NJlsDBZD0iRqwzBCg4JmLXvRMswQUj5CVX3IqVMUQt6C6 XF1Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=knOIAGHw; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g12-20020a170902c38c00b0019a72178acdsi9332444plg.380.2023.02.20.04.40.05; Mon, 20 Feb 2023 04:40:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=knOIAGHw; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232087AbjBTMZB (ORCPT + 99 others); Mon, 20 Feb 2023 07:25:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232091AbjBTMYf (ORCPT ); Mon, 20 Feb 2023 07:24:35 -0500 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2054.outbound.protection.outlook.com [40.107.15.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E5081C592; Mon, 20 Feb 2023 04:24:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iNeco7JYAeIcZoLhddkZ2iPmHaPzlwpkNHYd71Wk5Lp2jLLwHAls1JlDbpYt3G1HK2Kwmfulylm+pF8pOTBAY7E8rnm5wA3U2yqwhCnl0JhS+twPEpWBCVaKc9WYNpnlXetShHjI+8RxaYE1izrimuNFTnEhDX6bC137bbpfowuGGmEI6/f/pOeH39bwmQHvDXBFHBs8K+RDudRSHerxwJuptbY7QKlBmOYqUL6E3Z8pr6fi7X2+UM9yNa9AnARFv2wb9PvTpzqrjuW5Qgls2UZrosKqDdXGnC3kjD0AyEwgpxK1RX5mSDHxzGehnLzpzN2VkkLvF4fFF4dU9mLSJA== 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=InaTY6K8I6vtUgqHdvNLhqv7r2tvZqsSyR+0THPOCL8=; b=TIcO8EbPTFNzXM5RtgXMtnfGfci91gVPZnXnme5bjBblN/F2Pt6DZAiwC6M0ViL3IQGxe32XTgivKRDoIxMRsQj6Nx/gcJGtfo+gs0lTh1hVzpyMmLFUu7adsI3iKQ0QYpofhYXDZ7PDlEyghQhC/JOQv8UID+swg39+7QQzxS1tiRyW6PFmFnZSb2u5dAPMPzvX5lLb9nSRd73H4+TjjVWuclTbRdQo+fcGgnirt8dSU26SkXOfT7eb9Fh28+m9Lt3pb4qkRO1OVGh52Z5DG+t6r2Nn8ZMPXvqCHVYRFCHWm+tZpR484tJTXekcs91NdH8Uhp3c0DjnUOrPmm8KKw== 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=InaTY6K8I6vtUgqHdvNLhqv7r2tvZqsSyR+0THPOCL8=; b=knOIAGHwkpE94+haHPuGwb4LBPC6CqnmHmYOYR3iLWxqYy24nXH+chP7Hiay1xSf1SWcYdlGeEio6RU83X9u6nNIZuxnu/Hg3fmHkMhaU6dPoQ+qa045Y0cmuDEShF4zgjbkUkmOLl9JwMxG288VrHtCbYwKiDicoxOvpNYHBIo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by PA4PR04MB7725.eurprd04.prod.outlook.com (2603:10a6:102:f1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.19; Mon, 20 Feb 2023 12:24:10 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6111.019; Mon, 20 Feb 2023 12:24:10 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vinicius Costa Gomes , Kurt Kanzenbach , Gerhard Engleder , Amritha Nambiar , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , Florian Fainelli , Ferenc Fejes , Xiaoliang Yang , Roger Quadros , Pranavi Somisetty , Harini Katakam , Giuseppe Cavallaro , Alexandre Torgue , Michael Sit Wei Hong , Mohammad Athari Bin Ismail , Jacob Keller , linux-kernel@vger.kernel.org Subject: [PATCH v3 net-next 06/13] net/sched: pass netlink extack to mqprio and taprio offload Date: Mon, 20 Feb 2023 14:23:36 +0200 Message-Id: <20230220122343.1156614-7-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220122343.1156614-1-vladimir.oltean@nxp.com> References: <20230220122343.1156614-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0183.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:8d::17) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PA4PR04MB7725:EE_ X-MS-Office365-Filtering-Correlation-Id: 5ef9a81c-434f-4558-1ff7-08db133d5e68 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0a1mYMNQbrbpH4XK/Bmt0Bb4HzZJYZ4C4Y4v5LoxRCNlCoJRPGCS74ulKq0qtfZQPKoF5sJiBIWTgZxQTwTY2m0tsAbxCfVhi2lcS4TbdKVJqp39ABVlyYxVGMalSW4hFPEAp5i71lmuWnsibmCUUNUYeD3eB2bceYfeA7xjyK4nbiw9ylFSQpqm5Cp040LguDVoQIutj4dHNP+PuSYftdubehNH+EzStzsAGFfOc2TRagPzRI4874T8Ehztj6CM5GOd6PXdAxOoDzoC11IgoihFnoEIDnb/0JiCDLTkxxfT7lR4EgHy2JUnq+IEJhKshAlq2gdu37sVoEUZGVpBi5W0S1ayL417/F7geDXuMWtJeHuaoPsmLmU6O2FgcXJRF9VY7ff6/sminaqGpjytRDqp1X59F8AwKB4UWH36uSEFEVTgKPUIu99NB8bKsNx9Lb19ixzwBuLQ06LrSiyIhoWs3m7Ikix8u5wvUjslQ/f/hF0uzN9g0e4v9AvKdbTsO56hgucERRgarouoDZ6Nk173fWVp7f/hbN5+nibPmLNTD/y1Livl8d1lQrF1r3LlUyVfoW2LE7jcDnaDn5kOhwHthAs5gVGd5KYaexPa/LXu9BwRpVQ0OfZO5zT319LbQCfjUD+bVbEcxA7ieqaFxdumtyWZr/gnFPaewtwBNlZsXlRxU5hoDxFJXYDmaUk5NJOz1zw3MkVl7d4s/dvmFQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(366004)(346002)(39860400002)(136003)(376002)(396003)(451199018)(8676002)(6916009)(4326008)(66556008)(316002)(6486002)(66476007)(54906003)(66946007)(7416002)(52116002)(8936002)(5660300002)(41300700001)(86362001)(36756003)(478600001)(38100700002)(1076003)(38350700002)(6506007)(26005)(186003)(6512007)(6666004)(2616005)(2906002)(44832011)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YSc1LQ9yp86OtQe5VJ1FPnDcqArEGQ9SlnIxoTRyBIEL9CavfmT9Ez4GfU91+kHDDPxEL50odJSsOjJKTgJVHwNKQTUn7LolVz7FOWPh9rk2QfV4XCJiw8fhxxmtcDzapjpKvQbHDb3GXmkELf5SG6TlWnwHrLyavuadqKTULk+4EilQDcZ4ZrT7gkhmBWBGwgZ8y7wjtOlqwlmYd/m24YgD5ekn3eG70R9+SXBLnJweLgdiiMhJgkYcUzP9JIkPAN45PRqbNdNQ5373yMt8JEoamaqJvmQ6YjoPts8hlTl9Jm7i/spU8kK3SASzvHwrLc4FK/Zeg0L6XHZ/HfQApFjDxtbKot4xo9+WLwl8Ww9TEfK1Em8YFjERpiZe0ZBKUNdBesNZXT09PYjMjUf5GL93ctc2cdEg5trxwFpPyD2gYy0LsGSN6efqFk2BwfzFa2H3OwxAlkV0+V45rY9kAh7+sdjqSn2dv8/10iExNzoXHSGdG8RSxkLgzSJyG5h8t8dry6G0WkR0wgw9EPOOFsYd1C8yza5sEcoXeVKJa02V9aZP844vFsQrPWRPI166PF3IGS1qMl0hywpAP2BZlPoRiHalgURlPb2FmgSvcahtZKajZUsD/zwFbXlHxn0s6b4nW2qrsOq48lkQWx7pCOj8/P/4iyoStCM+jaN1yrTQlWXK5rFangkpWDWXTP+Bhj3DtltMZvWb2yR+/VLN70681kkR+rfyULOXXCzhltnpVAnrnWRhKFdHlKrBNU0HS+rxRGLzc8NMC/Q5XJXBWRO7B4YAasW0LUe/iRHqZ1kZMMmv9Y4/i1fuSxgT06x9OjVdHxufVfH9yNzJmFjQBOgRihqOC3ouWtAvRiuve1hSbIKRPKeUglEi04/odXBeQDUUDritCPr/c6TidwUa9yJ+Fw8xT/druj2ehKu6jOJajFnOwMTLmaC9EYIxcy3M6ilIjyXU3Bd+3uM05zXhlByBqVJT2cHSwT2PhWrPV2PkmvM+PHx5Qe/5oCxL9AHtyvED8lqmVonqH43E3iIpRb7Ksr4jK7zXaLJ3jxmx7lmTHrD9KZno16T3KIVSaNX2Ie6LfjzfO/bj1DrEx42yveD7OsjTttB6ETY0p7Z0ZFX1nJxmnCdIFrpnBsX4Ux+QIn27kp6SLhRHPA7NxV/NPoKxBwChvNcKZxzWyNSi5JQRlCRe4kIGiDGJJtkUBU2ZlIJ0CSx6HSKNyqnG/m4d1MTABFvih8AWOXb9zqLdWkpwnmo8h03CR7XWhlQMLlfCiYjQD00i8V9ER81MUWPQkyckZoCCXhdx0RmMQzy+5GzWYjgDTkbhTSvQspg2DUXbrvd9oznaJ+/gxhePvmUmWsC35jiuypiYcIkHAbJ80EVCCJU328zhX5VuiW0F4R7ii2da/mN97+kzIOxnixY52vP92h7SjuGydLnn+trJp9WdrjtCamiiHJ198C1BWJYpnbMS8aVzLbWKJ08rDqsztvymGJ6nvedRNKp5bVzp+a+QWAHp7z+54MLDQ6dl46h4d01N22f6Os439Ef0au3faU+HjQwNjuW//yWc9m+dC3geQxWkDH2OQhMMFjsQyx0TuhfRlubwTh5TKJDWOblxJA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5ef9a81c-434f-4558-1ff7-08db133d5e68 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2023 12:24:10.3215 (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: wNtBOrvoILK4CSMgCUBGo2HK+FSlq8vuUqxdNMOCVQa3rwmRrKbcm+4B33A357ZHTG0GG+byoSO0/FxpDNn/Ag== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7725 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_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758353757062827209?= X-GMAIL-MSGID: =?utf-8?q?1758353757062827209?= With the multiplexed ndo_setup_tc() model which lacks a first-class struct netlink_ext_ack * argument, the only way to pass the netlink extended ACK message down to the device driver is to embed it within the offload structure. Do this for struct tc_mqprio_qopt_offload and struct tc_taprio_qopt_offload. Since struct tc_taprio_qopt_offload also contains a tc_mqprio_qopt_offload structure, and since device drivers might effectively reuse their mqprio implementation for the mqprio portion of taprio, we make taprio set the extack in both offload structures to point at the same netlink extack message. In fact, the taprio handling is a bit more tricky, for 2 reasons. First is because the offload structure has a longer lifetime than the extack structure. The driver is supposed to populate the extack synchronously from ndo_setup_tc() and leave it alone afterwards. To not have any use-after-free surprises, we zero out the extack pointer when we leave taprio_enable_offload(). The second reason is because taprio does overwrite the extack message on ndo_setup_tc() error. We need to switch to the weak form of setting an extack message, which preserves a potential message set by the driver. Signed-off-by: Vladimir Oltean --- v2->v3: patch is new include/net/pkt_sched.h | 2 ++ net/sched/sch_mqprio.c | 5 ++++- net/sched/sch_taprio.c | 12 ++++++++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h index 2016839991a4..fc688c7e9595 100644 --- a/include/net/pkt_sched.h +++ b/include/net/pkt_sched.h @@ -167,6 +167,7 @@ struct tc_mqprio_caps { struct tc_mqprio_qopt_offload { /* struct tc_mqprio_qopt must always be the first element */ struct tc_mqprio_qopt qopt; + struct netlink_ext_ack *extack; u16 mode; u16 shaper; u32 flags; @@ -194,6 +195,7 @@ struct tc_taprio_sched_entry { struct tc_taprio_qopt_offload { struct tc_mqprio_qopt_offload mqprio; + struct netlink_ext_ack *extack; u8 enable; ktime_t base_time; u64 cycle_time; diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c index 9ee5a9a9b9e9..5287ff60b3f9 100644 --- a/net/sched/sch_mqprio.c +++ b/net/sched/sch_mqprio.c @@ -33,9 +33,12 @@ static int mqprio_enable_offload(struct Qdisc *sch, const struct tc_mqprio_qopt *qopt, struct netlink_ext_ack *extack) { - struct tc_mqprio_qopt_offload mqprio = {.qopt = *qopt}; struct mqprio_sched *priv = qdisc_priv(sch); struct net_device *dev = qdisc_dev(sch); + struct tc_mqprio_qopt_offload mqprio = { + .qopt = *qopt, + .extack = extack, + }; int err, i; switch (priv->mode) { diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index 1f469861eae3..cbad43019172 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -1520,7 +1520,9 @@ static int taprio_enable_offload(struct net_device *dev, return -ENOMEM; } offload->enable = 1; + offload->extack = extack; mqprio_qopt_reconstruct(dev, &offload->mqprio.qopt); + offload->mqprio.extack = extack; taprio_sched_to_offload(dev, sched, offload, &caps); for (tc = 0; tc < TC_MAX_QUEUE; tc++) @@ -1528,14 +1530,20 @@ static int taprio_enable_offload(struct net_device *dev, err = ops->ndo_setup_tc(dev, TC_SETUP_QDISC_TAPRIO, offload); if (err < 0) { - NL_SET_ERR_MSG(extack, - "Device failed to setup taprio offload"); + NL_SET_ERR_MSG_WEAK(extack, + "Device failed to setup taprio offload"); goto done; } q->offloaded = true; done: + /* The offload structure may linger around via a reference taken by the + * device driver, so clear up the netlink extack pointer so that the + * driver isn't tempted to dereference data which stopped being valid + */ + offload->extack = NULL; + offload->mqprio.extack = NULL; taprio_offload_free(offload); return err; From patchwork Mon Feb 20 12:23:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 59418 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1283934wrn; Mon, 20 Feb 2023 04:41:19 -0800 (PST) X-Google-Smtp-Source: AK7set9Nvk97bazAovfClfiZiPYCkL37iuonzyr2Mvnj/ZjkMmOWzirYJl7JzUSRYFk4S/wpboH2 X-Received: by 2002:a17:90b:4ac3:b0:22b:fd93:7286 with SMTP id mh3-20020a17090b4ac300b0022bfd937286mr972038pjb.4.1676896879123; Mon, 20 Feb 2023 04:41:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1676896879; cv=pass; d=google.com; s=arc-20160816; b=VMsJwvQub43JJ3avcjtH/5wA8KFfYhkqXw57MxieVEZ40s9kqxlIjxfc2jJY+mWpFm 8YF2d8wWYuu1nhx0WWYPMviqnf3f9J8fKi5CfM8oNh0h82RJEQJ0OTTFdXDUgW+7WESe Jgfj/Hs21ooSWaMWizp5jvMWKBO1wOM0XQXfftcV7Uewq334ESxV71vQ3xVnd5H0An6h to312AdLTViUSssiQozH9j06hfzPrCwMr/0c2h7e19tDUamvrBkiI4d9oci+reHk1GRP cuEHtEkh0gDLelgOG/0M+s4slrxC6/tGESftwOw0LdTZhi4JS35NQZqXtrh517GalTIM g3Ww== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=o7ouJPnAh/3p8IFwec6nIeLcyjjo4eZKQQdYBAvXiV4=; b=pAZrzoz/XmbiBjbt3J3i+cfqba+o3i3GEiuejDfHfR0C48VwjOpOhSNgLjI2c6HJ6R jZDjM8dxTfReC87sH602B1BvHZV+owl3+ReoUI88HbVPtYVv3IGiVUvKx/pQWRsrIiVn Xww2n4wMDMtFoPo0+pIue7QvJRyJunh4Cp0ChCHduZHcpe/ct23cofW13Xj0kxyl2mfV 9i/qk0TuAUUy945Y264pZ19jdzXIvBN4A16HYVV9UnHUSSYsCTA9flbQzL3OtXHjodmg lBgF+XVqtmlidOt2+sWDk4hFYpAuYLuBjz49H5Rkk27zCSDaCTo/46DazS5/oZ4skgLX wDTg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=OEu82JX5; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ch8-20020a17090af40800b00233bafad308si749699pjb.150.2023.02.20.04.41.06; Mon, 20 Feb 2023 04:41:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=OEu82JX5; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232055AbjBTMZX (ORCPT + 99 others); Mon, 20 Feb 2023 07:25:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232099AbjBTMZD (ORCPT ); Mon, 20 Feb 2023 07:25:03 -0500 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2071.outbound.protection.outlook.com [40.107.15.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F21C1C7F7; Mon, 20 Feb 2023 04:24:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FYozqq/w8l7ImlTPrNrfm6dD+yteVceRu42cU0jXVrfH9zTKmBr5CD8bX+wlUVPMm8HEqQ53tUQfUYUehK4tNrV5YZ3m5o7ykcVVcZie7O4nshgXZ3zGb6PhKNkqC50wSrH+csdfOJTQEvTNEgZeF58W3AeCqrs6kI2fldA6qB5NOUngXUQa0SwN/7ikGdpsW0X/hOnyFnGuPHRn8ysttcr/6zPqj8STev4YLI+lgzhVUb2Ho2AhZTjCLFsAp+sc/4IkzT5bEnLrtc69Pds9AEP/qSx3et7mtqhXfGc5N6ZZqVeHBTaCB+j5dEkR/pXpVbZ/fllS8n21CIoId9buwg== 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=o7ouJPnAh/3p8IFwec6nIeLcyjjo4eZKQQdYBAvXiV4=; b=gjNnn7oqB8PAdvQlrHuHJQX3T1WKdkNbB1Qzp0OoB9Ybo2nm3FGFhNn2jApb7lCq0Z/4RZBPFpEJ5H7JYV0UEbfRfOGdrmtua9NZC9b7KGi4HQoqnkw0OVEVYIl1CHF/npkmLtLsEJ0dSYUDH+gW0vDRpXqWuD/ZXBzXkG7dMjA9Ibm5SpfqAI3kmRWtpAiMHGW34pybOkvm/q6M7ZVaKqQXItIQ8vmGiwZP6to/RfMDa+aqNdoP3hIJnAtlMVURSHqiK7WZ267TCm22Dnt8d40za/bcZFkmIui5Nzg96xzwNacFWdsLsJHY7hsp/JZvfisjNuEbt5CF80ZBTmGvPw== 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=o7ouJPnAh/3p8IFwec6nIeLcyjjo4eZKQQdYBAvXiV4=; b=OEu82JX5CGzcrmz88Rz+f5gt+1hFxmHNysJu8Y7EWjh3ZhRhdcUuZyeNCpSuIjll7lVFaa8yflmVj3ya/F1Tvf2QY2L9hTNYzi7X2zUD9Hm+KgU932K59cdZJn4TV5eiQp1yZAHqq4BYlbROl4pegnizjcyE+1TvOt3rxaHRD4A= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by PA4PR04MB7725.eurprd04.prod.outlook.com (2603:10a6:102:f1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.19; Mon, 20 Feb 2023 12:24:12 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6111.019; Mon, 20 Feb 2023 12:24:12 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vinicius Costa Gomes , Kurt Kanzenbach , Gerhard Engleder , Amritha Nambiar , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , Florian Fainelli , Ferenc Fejes , Xiaoliang Yang , Roger Quadros , Pranavi Somisetty , Harini Katakam , Giuseppe Cavallaro , Alexandre Torgue , Michael Sit Wei Hong , Mohammad Athari Bin Ismail , Jacob Keller , linux-kernel@vger.kernel.org, Ferenc Fejes Subject: [PATCH v3 net-next 07/13] net/sched: mqprio: allow per-TC user input of FP adminStatus Date: Mon, 20 Feb 2023 14:23:37 +0200 Message-Id: <20230220122343.1156614-8-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220122343.1156614-1-vladimir.oltean@nxp.com> References: <20230220122343.1156614-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0183.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:8d::17) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PA4PR04MB7725:EE_ X-MS-Office365-Filtering-Correlation-Id: 99538b90-9d5c-4396-4375-08db133d5fd7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pwRMpTGV8rOZegWpdeuK54ouY0qWN9WxdluYL+ZEr79e6ga/NFct0Q9z7hOOq5zJS3YPkJrCgreeuGiOXCpFbYBPYXgzmSQwEtlXdW44lOcPgIaIs5t3kPVbsQv8iJP5zb4NPDDdIQ3gzM4vpJYjtPpcAXupFd82cdLtF0/YIwz3zDdMI+ycEQY3fryyuf2zF8flXcCWBz3o01fJ0IEerD+JHBR97sXF02mryeHn7g1o1yCxA1mGPu3h///MhC+UVKcE/h/bTLrXBDQcxayNRtxJwVdC7j788WoAbCtZaFjQ4JvLJNhG8uf1A7Wl4/b+lYbrvlJSFP4HCneC4sSQaIM6syBAgE8ZQLsVDlV1UKFGV3DOwx1ruFyvD8nUgcL0WQ/Ga8iwVMkoCS28zcuA0t33qXpj069X2yB6q5EoKzB9NX7ezBRO3jm7kBtODvzkaXZSN1a4sHlVoAxywL8SMS4DMHIIIBef6KzaEBbeBoujw5hEHYENNZfnhgdgD1L0iAQJZIJG6makMqbkF5J+5fWU3o3kr0Kp2F6662/jB5ZSAnpBm12n78BgKi+zXxP23ZlvUss4GBw7LtHmRrHTfcg79GidpCMkAzUEsSJFNIdz58bpRQh3KyAC0VUz7WUTUJPeO5PnJ7a7UvbjMeT1jghNCWpZ8coE4QZp6ItyUUWSof1mJlYo0z1DJSXfaQOxN27l9a9h97zEj8biv7HHtA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(366004)(346002)(39860400002)(136003)(376002)(396003)(451199018)(8676002)(6916009)(4326008)(66556008)(316002)(6486002)(66476007)(54906003)(66946007)(7416002)(52116002)(30864003)(8936002)(5660300002)(41300700001)(86362001)(36756003)(478600001)(38100700002)(1076003)(38350700002)(6506007)(26005)(186003)(6512007)(6666004)(2616005)(2906002)(44832011)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +QXiGY906zfyEZ2Ai1ny2z7Tw/ujW8Ct/pYnrQ2P0wKYVHvBldaUGwqHk2GQ9E2fhFFRkoBaE20Y4ocM69s8zlWHgboDMiUgmY4edqlfFnCq51stn5PO8T2LXJegbOQ/gnb73q3/fAUmRMhjAK1PJ77+E5aSNmSZ3yO6VyMeT0TCu/Qt8SaHNHFNdBB9GUmf8R+z+4SPsXVS84m+PmBznihdhg2HgdbEmjLzHW7ifcmupqZkxf4wsFp7dNWBlNEm3FosfREhchIcUR+k5eVnmkx0CO35lZEQv+5RACLnU2KHPRHJnPTJkDoe+KjXHKDnG/wDWZVl4pR6KqngeKIU1bjW7WbCnq+1BvahmLrRTAt++hXV55a9LF1vM0+kwxs35D7ccJ5wbpQ17qC5GgnmnjQLzmO6ONYXIjwF+FNpM091lmBodicvnKTqmbOmHDy8cBlj+1a3UeMPMgopuqXNALhKDhq9FJvkQt5SmBV+aAuDhmOg+qOoUplVIJPHmfUbe9lZjAaPDaM/R92gl2wiphdLaGh6D71E7wf9W6FbvrS/E3m9vqMQQpWjh1zVZA74E2kqxcwQbBHbcx3/aot9iokN8yllo3k5ca+oMASCvpCwUB9mC9iTzL9VkqwMJhMDUtmpMgsd6VWt18UciXSw108vSIZ5Scgismy9OlGBp21EYQDyTYXwwdCUb3oGiLt4YIlbBr8FUeYBc5nOi/OLoTB7i/wOpqTEwAD+n5RyBweVO/8673hmC81VulcxlFR/pWEwLKuKIDSJqX0/2/YbOQ49XG7QpsSG9IZXqD1QpiDPr2zNGx2WzchSUpzGzvcBwHFVHsYdzzg6wsykSOxTmvRjgPfhonJgvFAWeXQC8VQcPWbN59yyxbPaG9kYyGuVLTAhGbh9qGFxrBzoMUKL5VK7Tg3Q4vWC7TrryBQSHTsLhcZ1h2fvyYbLcf4u5RN1P4EafNtHc+3WES9W8XH+iCJ26RU7XcR7v0NQmABi93be5SDY1RviEtz/ua9SCSqMbGlIqLOFKOtMPLG6ARvPaiBczUUSZZt65DWCMLovcL0IjF38aVV97iQjVa4WwMv6hRjXcdviicEsB6/qgMUV46kTk6J9vaLI0FUrkteOTeYFMZmvF+QQJalnfty0i9DXLo2HOs5+Ea1uh9lvgPzAZ1rBZwnX33ZLYPTziuRXOlVO7KKztYatHuwCuYw++P3O5mIkrjknJtCKxfhaNUdPIICpa2YIBeo5YW8yLU5l4P2S5cyMjO6JzSBQYhysbNT2gT4V4fAypegU0os0kbDij7omlToFX6QbaRyw548ugYiTDlggUrvpBpJLHS9Ibr8UXNN4TtJKoap4DX1gMQc9Vwas7xwFXXkjZ6L0K+/77NDUP8JUChaPQ0O0ywMqgjQNFKmIVJYXXgvY1e+N8mwolkFOuBcsbmdRViwJGNYZPG8i32nbbRWwQnsQguYfFcNekr0gYTkQfueCLq4tW6Mq8mgCVeuWyni/yKoi+47NWrzuWKq/hjQCBc0WyCm8yBNUN10atZ3NEbSn/qyzWzSte8E4M+TeFdhXQijMi5b40G7lpRcjVKxHg2+Q4gMjRKE8ZcsbVWeWOafqPvRlNAkelQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 99538b90-9d5c-4396-4375-08db133d5fd7 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2023 12:24:12.7432 (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: DsN3ZE92Pn30dRtxN55ruRNmU9Eoe0UMv3u2fAXmFyNkupaXkFgrHj+shGNTv3xE40aTyf8H0wb1ZrSO8iJc+g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7725 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_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758353821566062195?= X-GMAIL-MSGID: =?utf-8?q?1758353821566062195?= IEEE 802.1Q-2018 clause 6.7.2 Frame preemption specifies that each packet priority can be assigned to a "frame preemption status" value of either "express" or "preemptible". Express priorities are transmitted by the local device through the eMAC, and preemptible priorities through the pMAC (the concepts of eMAC and pMAC come from the 802.3 MAC Merge layer). The FP adminStatus is defined per packet priority, but 802.1Q clause 12.30.1.1.1 framePreemptionAdminStatus also says that: | Priorities that all map to the same traffic class should be | constrained to use the same value of preemption status. It is impossible to ignore the cognitive dissonance in the standard here, because it practically means that the FP adminStatus only takes distinct values per traffic class, even though it is defined per priority. I can see no valid use case which is prevented by having the kernel take the FP adminStatus as input per traffic class (what we do here). In addition, this also enforces the above constraint by construction. User space network managers which wish to expose FP adminStatus per priority are free to do so; they must only observe the prio_tc_map of the netdev (which presumably is also under their control, when constructing the mqprio netlink attributes). The reason for configuring frame preemption as a property of the Qdisc layer is that the information about "preemptible TCs" is closest to the place which handles the num_tc and prio_tc_map of the netdev. If the UAPI would have been any other layer, it would be unclear what to do with the FP information when num_tc collapses to 0. A key assumption is that only mqprio/taprio change the num_tc and prio_tc_map of the netdev. Not sure if that's a great assumption to make. Having FP in tc-mqprio can be seen as an implementation of the use case defined in 802.1Q Annex S.2 "Preemption used in isolation". There will be a separate implementation of FP in tc-taprio, for the other use cases. Signed-off-by: Vladimir Oltean Reviewed-by: Ferenc Fejes --- v2->v3: none v1->v2: - slightly reword commit message - move #include to this patch - remove self-evident comment "only for dump and offloading" include/net/pkt_sched.h | 1 + include/uapi/linux/pkt_sched.h | 16 +++++ net/sched/sch_mqprio.c | 127 ++++++++++++++++++++++++++++++++- net/sched/sch_mqprio_lib.c | 14 ++++ net/sched/sch_mqprio_lib.h | 2 + 5 files changed, 159 insertions(+), 1 deletion(-) diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h index fc688c7e9595..f4f758963c84 100644 --- a/include/net/pkt_sched.h +++ b/include/net/pkt_sched.h @@ -173,6 +173,7 @@ struct tc_mqprio_qopt_offload { u32 flags; u64 min_rate[TC_QOPT_MAX_QUEUE]; u64 max_rate[TC_QOPT_MAX_QUEUE]; + unsigned long preemptible_tcs; }; struct tc_taprio_caps { diff --git a/include/uapi/linux/pkt_sched.h b/include/uapi/linux/pkt_sched.h index 000eec106856..b8d29be91b62 100644 --- a/include/uapi/linux/pkt_sched.h +++ b/include/uapi/linux/pkt_sched.h @@ -719,6 +719,11 @@ enum { #define __TC_MQPRIO_SHAPER_MAX (__TC_MQPRIO_SHAPER_MAX - 1) +enum { + TC_FP_EXPRESS = 1, + TC_FP_PREEMPTIBLE = 2, +}; + struct tc_mqprio_qopt { __u8 num_tc; __u8 prio_tc_map[TC_QOPT_BITMASK + 1]; @@ -732,12 +737,23 @@ struct tc_mqprio_qopt { #define TC_MQPRIO_F_MIN_RATE 0x4 #define TC_MQPRIO_F_MAX_RATE 0x8 +enum { + TCA_MQPRIO_TC_ENTRY_UNSPEC, + TCA_MQPRIO_TC_ENTRY_INDEX, /* u32 */ + TCA_MQPRIO_TC_ENTRY_FP, /* u32 */ + + /* add new constants above here */ + __TCA_MQPRIO_TC_ENTRY_CNT, + TCA_MQPRIO_TC_ENTRY_MAX = (__TCA_MQPRIO_TC_ENTRY_CNT - 1) +}; + enum { TCA_MQPRIO_UNSPEC, TCA_MQPRIO_MODE, TCA_MQPRIO_SHAPER, TCA_MQPRIO_MIN_RATE64, TCA_MQPRIO_MAX_RATE64, + TCA_MQPRIO_TC_ENTRY, __TCA_MQPRIO_MAX, }; diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c index 5287ff60b3f9..bc158a7fd6ba 100644 --- a/net/sched/sch_mqprio.c +++ b/net/sched/sch_mqprio.c @@ -5,6 +5,7 @@ * Copyright (c) 2010 John Fastabend */ +#include #include #include #include @@ -27,6 +28,7 @@ struct mqprio_sched { u32 flags; u64 min_rate[TC_QOPT_MAX_QUEUE]; u64 max_rate[TC_QOPT_MAX_QUEUE]; + u32 fp[TC_QOPT_MAX_QUEUE]; }; static int mqprio_enable_offload(struct Qdisc *sch, @@ -63,6 +65,8 @@ static int mqprio_enable_offload(struct Qdisc *sch, return -EINVAL; } + mqprio_fp_to_offload(priv->fp, &mqprio); + err = dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_QDISC_MQPRIO, &mqprio); if (err) @@ -145,13 +149,94 @@ static int mqprio_parse_opt(struct net_device *dev, struct tc_mqprio_qopt *qopt, return 0; } +static const struct +nla_policy mqprio_tc_entry_policy[TCA_MQPRIO_TC_ENTRY_MAX + 1] = { + [TCA_MQPRIO_TC_ENTRY_INDEX] = NLA_POLICY_MAX(NLA_U32, + TC_QOPT_MAX_QUEUE), + [TCA_MQPRIO_TC_ENTRY_FP] = NLA_POLICY_RANGE(NLA_U32, + TC_FP_EXPRESS, + TC_FP_PREEMPTIBLE), +}; + static const struct nla_policy mqprio_policy[TCA_MQPRIO_MAX + 1] = { [TCA_MQPRIO_MODE] = { .len = sizeof(u16) }, [TCA_MQPRIO_SHAPER] = { .len = sizeof(u16) }, [TCA_MQPRIO_MIN_RATE64] = { .type = NLA_NESTED }, [TCA_MQPRIO_MAX_RATE64] = { .type = NLA_NESTED }, + [TCA_MQPRIO_TC_ENTRY] = { .type = NLA_NESTED }, }; +static int mqprio_parse_tc_entry(u32 fp[TC_QOPT_MAX_QUEUE], + struct nlattr *opt, + unsigned long *seen_tcs, + struct netlink_ext_ack *extack) +{ + struct nlattr *tb[TCA_MQPRIO_TC_ENTRY_MAX + 1] = { }; + int err, tc; + + err = nla_parse_nested(tb, TCA_MQPRIO_TC_ENTRY_MAX, opt, + mqprio_tc_entry_policy, extack); + if (err < 0) + return err; + + if (!tb[TCA_MQPRIO_TC_ENTRY_INDEX]) { + NL_SET_ERR_MSG(extack, "TC entry index missing"); + return -EINVAL; + } + + tc = nla_get_u32(tb[TCA_MQPRIO_TC_ENTRY_INDEX]); + if (*seen_tcs & BIT(tc)) { + NL_SET_ERR_MSG(extack, "Duplicate tc entry"); + return -EINVAL; + } + + *seen_tcs |= BIT(tc); + + if (tb[TCA_MQPRIO_TC_ENTRY_FP]) + fp[tc] = nla_get_u32(tb[TCA_MQPRIO_TC_ENTRY_FP]); + + return 0; +} + +static int mqprio_parse_tc_entries(struct Qdisc *sch, struct nlattr *nlattr_opt, + int nlattr_opt_len, + struct netlink_ext_ack *extack) +{ + struct mqprio_sched *priv = qdisc_priv(sch); + struct net_device *dev = qdisc_dev(sch); + bool have_preemption = false; + unsigned long seen_tcs = 0; + u32 fp[TC_QOPT_MAX_QUEUE]; + struct nlattr *n; + int tc, rem; + int err = 0; + + for (tc = 0; tc < TC_QOPT_MAX_QUEUE; tc++) + fp[tc] = priv->fp[tc]; + + nla_for_each_attr(n, nlattr_opt, nlattr_opt_len, rem) { + if (nla_type(n) != TCA_MQPRIO_TC_ENTRY) + continue; + + err = mqprio_parse_tc_entry(fp, n, &seen_tcs, extack); + if (err) + goto out; + } + + for (tc = 0; tc < TC_QOPT_MAX_QUEUE; tc++) { + priv->fp[tc] = fp[tc]; + if (fp[tc] == TC_FP_PREEMPTIBLE) + have_preemption = true; + } + + if (have_preemption && !ethtool_dev_mm_supported(dev)) { + NL_SET_ERR_MSG(extack, "Device does not support preemption"); + return -EOPNOTSUPP; + } +out: + return err; +} + /* Parse the other netlink attributes that represent the payload of * TCA_OPTIONS, which are appended right after struct tc_mqprio_qopt. */ @@ -234,6 +319,13 @@ static int mqprio_parse_nlattr(struct Qdisc *sch, struct tc_mqprio_qopt *qopt, priv->flags |= TC_MQPRIO_F_MAX_RATE; } + if (tb[TCA_MQPRIO_TC_ENTRY]) { + err = mqprio_parse_tc_entries(sch, nlattr_opt, nlattr_opt_len, + extack); + if (err) + return err; + } + return 0; } @@ -247,7 +339,7 @@ static int mqprio_init(struct Qdisc *sch, struct nlattr *opt, int i, err = -EOPNOTSUPP; struct tc_mqprio_qopt *qopt = NULL; struct tc_mqprio_caps caps; - int len; + int len, tc; BUILD_BUG_ON(TC_MAX_QUEUE != TC_QOPT_MAX_QUEUE); BUILD_BUG_ON(TC_BITMASK != TC_QOPT_BITMASK); @@ -265,6 +357,9 @@ static int mqprio_init(struct Qdisc *sch, struct nlattr *opt, if (!opt || nla_len(opt) < sizeof(*qopt)) return -EINVAL; + for (tc = 0; tc < TC_QOPT_MAX_QUEUE; tc++) + priv->fp[tc] = TC_FP_EXPRESS; + qdisc_offload_query_caps(dev, TC_SETUP_QDISC_MQPRIO, &caps, sizeof(caps)); @@ -415,6 +510,33 @@ static int dump_rates(struct mqprio_sched *priv, return -1; } +static int mqprio_dump_tc_entries(struct mqprio_sched *priv, + struct sk_buff *skb) +{ + struct nlattr *n; + int tc; + + for (tc = 0; tc < TC_QOPT_MAX_QUEUE; tc++) { + n = nla_nest_start(skb, TCA_MQPRIO_TC_ENTRY); + if (!n) + return -EMSGSIZE; + + if (nla_put_u32(skb, TCA_MQPRIO_TC_ENTRY_INDEX, tc)) + goto nla_put_failure; + + if (nla_put_u32(skb, TCA_MQPRIO_TC_ENTRY_FP, priv->fp[tc])) + goto nla_put_failure; + + nla_nest_end(skb, n); + } + + return 0; + +nla_put_failure: + nla_nest_cancel(skb, n); + return -EMSGSIZE; +} + static int mqprio_dump(struct Qdisc *sch, struct sk_buff *skb) { struct net_device *dev = qdisc_dev(sch); @@ -465,6 +587,9 @@ static int mqprio_dump(struct Qdisc *sch, struct sk_buff *skb) (dump_rates(priv, &opt, skb) != 0)) goto nla_put_failure; + if (mqprio_dump_tc_entries(priv, skb)) + goto nla_put_failure; + return nla_nest_end(skb, nla); nla_put_failure: nlmsg_trim(skb, nla); diff --git a/net/sched/sch_mqprio_lib.c b/net/sched/sch_mqprio_lib.c index c58a533b8ec5..83b3793c4012 100644 --- a/net/sched/sch_mqprio_lib.c +++ b/net/sched/sch_mqprio_lib.c @@ -114,4 +114,18 @@ void mqprio_qopt_reconstruct(struct net_device *dev, struct tc_mqprio_qopt *qopt } EXPORT_SYMBOL_GPL(mqprio_qopt_reconstruct); +void mqprio_fp_to_offload(u32 fp[TC_QOPT_MAX_QUEUE], + struct tc_mqprio_qopt_offload *mqprio) +{ + unsigned long preemptible_tcs = 0; + int tc; + + for (tc = 0; tc < TC_QOPT_MAX_QUEUE; tc++) + if (fp[tc] == TC_FP_PREEMPTIBLE) + preemptible_tcs |= BIT(tc); + + mqprio->preemptible_tcs = preemptible_tcs; +} +EXPORT_SYMBOL_GPL(mqprio_fp_to_offload); + MODULE_LICENSE("GPL"); diff --git a/net/sched/sch_mqprio_lib.h b/net/sched/sch_mqprio_lib.h index 63f725ab8761..079f597072e3 100644 --- a/net/sched/sch_mqprio_lib.h +++ b/net/sched/sch_mqprio_lib.h @@ -14,5 +14,7 @@ int mqprio_validate_qopt(struct net_device *dev, struct tc_mqprio_qopt *qopt, struct netlink_ext_ack *extack); void mqprio_qopt_reconstruct(struct net_device *dev, struct tc_mqprio_qopt *qopt); +void mqprio_fp_to_offload(u32 fp[TC_QOPT_MAX_QUEUE], + struct tc_mqprio_qopt_offload *mqprio); #endif From patchwork Mon Feb 20 12:23:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 59415 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1283312wrn; Mon, 20 Feb 2023 04:39:48 -0800 (PST) X-Google-Smtp-Source: AK7set/EQlEoABt//4evUAdJWRVmOWy9Gfm+/oYnTQ3MBdf2uOz7u602b5B7AOQ/YFpHKJRNDnhP X-Received: by 2002:a17:902:ec91:b0:199:527d:42c3 with SMTP id x17-20020a170902ec9100b00199527d42c3mr2972456plg.24.1676896788123; Mon, 20 Feb 2023 04:39:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1676896788; cv=pass; d=google.com; s=arc-20160816; b=mU9CkzMs16ea5CNaIJxqjwY5YrakNArigKnuujqIy0b7VdYYNnK10zmZoQ3p0DMOuA /83VnNXrTOzlp8enPN/qEcIpnV/CH7bPIadmNVC4uZaY590l5wr0ELkFp5UTnkmsnZuJ 3+A3IS7Gv0KltqodWQzf+eqgjXym/agD+T51rkQOpMxW7aP2MBWAt9+ld/Pt4/lfYzRM D4Pxz3ctgcAeHderZM72YwLOfyWucMq6c2MkFzqNQihnc9u4H58XxiMAzKgy7ZaMUyib oWO4Jn2CfOD2P00158oUVq8yvqQxqwJqtyOkM80I4wiANoQWB1MFxMGYvW9hIyAjwhFy 7gBA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=b215qCVn8hRuvfP2vtMGROGT+pxgylLl6oiOh2pB/EQ=; b=NBXExrssx7DljFvrsZIn+XM0rH6pTiGkClkPEkpRU315XlwtRxDz9QHcorWLypNIZB BSLSJtPFtElx4xtXTVFv7Q55xOZxqE1YjUYlT7kLzpl2LnI5EVdu6PsbQw75+eYv2jIo ZMwJCFcDq2bQ9sYKh1b8jWI+fG0GGAtLoU/rQtwz/XA4wQKTodfcREYka9azhdKCDNbO rXgxM6M+VANmXzZ1SSM5wQyR6xeFmGVuvLwHz5xUN4u+kloA1nFCuU725n7R9hx43ixe 80eI6h3HJpKXYIdTn3R2glxUSpNDgB5KFqege93dcqXSMWIMfjzl0Vxp906Vs1CTcZ9y +xhA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=GNjVLFeb; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z13-20020a170903018d00b0019aa6450ff3si11250246plg.585.2023.02.20.04.39.34; Mon, 20 Feb 2023 04:39:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=GNjVLFeb; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232091AbjBTMZ0 (ORCPT + 99 others); Mon, 20 Feb 2023 07:25:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232106AbjBTMZF (ORCPT ); Mon, 20 Feb 2023 07:25:05 -0500 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2054.outbound.protection.outlook.com [40.107.15.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 200971C7E2; Mon, 20 Feb 2023 04:24:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F3yH2e1aExJAn3nXEEJqfDlnBLbevBzOWK0YNqcBoLS+FwnT7pQiK86wbM3pqgcr444MCoVw6XoQD97qirhGHnbQBW4J+IAloQp0lgoMcdzJYIwLXcbqk7b9WFcLRlo8vD0pMZpbltbHW2TjWHC/X1T6g5t4qf2vyn6m/fFqQe8IKx9b2trkAwH6jemodD1hBhRRa8KRPAQWmELg3qNifIe0COwg4w/8Upn+15mZPZyRLcNTXVkK+5fEZVAwqSZ96xzkJf5D8XfjVB4P/bwVUUzSJ7Wu2fAlXbozgBz1B+/RoJCd254ewBETHiD8UBdM9Iazf0beE+x/mrJwtm4+RQ== 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=b215qCVn8hRuvfP2vtMGROGT+pxgylLl6oiOh2pB/EQ=; b=icK0Jlq3NpEcMKOlx5w2uWEmHS/PIVVmh1/eSVkhInKKpjObhgYMewD2e/Jn0XoD4B0/f4B/JHgfBFpccmd6fKxQfnODJIooWt5gytv/B92Uga2PZoGAn1X9+pzF0vrwoBNINqfFH5F1YRslSFwbbd7Cb1z1eSqDBnQn1opBAIGWVn72uAmjeSbUrXWKlUzuGumJ1VYL9Yt9eDif69eqj2HozZh32zxSTNCAE/8Z5HZLUptn2Eso7n7CGYRjkYkb367Id0t2FXKZ6JgqvMGWhhqgnfM9dMjm4X4pypK0ASLXaK8J7zv6mI1kNM4xwjBt0GPxPY0S1vjxiqwVg6C+UA== 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=b215qCVn8hRuvfP2vtMGROGT+pxgylLl6oiOh2pB/EQ=; b=GNjVLFeblHtEWLyIobNhuzPZM+8kAfTxMzwtZ2Ileom+TXydvWRO/GXPcbG3mATEtTEKjs0mYZyF8mkoM7aQQFi1f53pZ3Yw+9UGokm9GhUKa/CYFN9MEXh4HOOh+KtjdMfzRw0cRS2VLUsiHglwVOB5xHcSJDDrTbVTET2nvjI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by PA4PR04MB7725.eurprd04.prod.outlook.com (2603:10a6:102:f1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.19; Mon, 20 Feb 2023 12:24:15 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6111.019; Mon, 20 Feb 2023 12:24:15 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vinicius Costa Gomes , Kurt Kanzenbach , Gerhard Engleder , Amritha Nambiar , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , Florian Fainelli , Ferenc Fejes , Xiaoliang Yang , Roger Quadros , Pranavi Somisetty , Harini Katakam , Giuseppe Cavallaro , Alexandre Torgue , Michael Sit Wei Hong , Mohammad Athari Bin Ismail , Jacob Keller , linux-kernel@vger.kernel.org, Ferenc Fejes Subject: [PATCH v3 net-next 08/13] net/sched: taprio: allow per-TC user input of FP adminStatus Date: Mon, 20 Feb 2023 14:23:38 +0200 Message-Id: <20230220122343.1156614-9-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220122343.1156614-1-vladimir.oltean@nxp.com> References: <20230220122343.1156614-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0183.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:8d::17) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PA4PR04MB7725:EE_ X-MS-Office365-Filtering-Correlation-Id: 0f15fd6b-5930-47ef-2ba1-08db133d614b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3U9G/aSg2yGje+llwfpNyl2kuc/tDy+IwsLQTDOxfuRZQn1C7iSBVHaZdCJWxktCYpta4Pgu8bZs6kLZKLqpyhWPMfiXM1PJDIZsVh/iwItjdhhAdia2CeLrU+IlbvPKw6TSExQPdR7J9Jpm5J7K910Rrd7U+Y5c01OyVzBcOOdSTeIdAHRiK6PlNsDzk/QDCrU3wdSH9OQsh3GxBpAWnhoNLXpfBFLkTLguasDPQ3E9Rnbynk0rACcasta2b/pPynCEH16+VmsjgtArzInk0cpksmz8Kj6BinlyBQdl01An+LIVQfXsD5EuEVWecx621//9CHtK2Hvtvd+qLVA9gVyQBHfNMnrtJh1AcCRT2Q/w+lZyO+bSIsvPnFiIlfWKG/O8U2I9qdeoKo4pbT4y1lVJXDiri9tnWTysiPzQjVuh3smIps3p4jbnx3npA36V2G8lKgUaajs7sJVRLw8hBKKH1pCeB7JxmTpLzKRQ/dgjs5EIL1w7spFlpUq7YsadzWhZ+E16l9k/JQpgwUEt1S6OaAwMNRbQKfm9K5n13TydII3+UzNgaDvpuGLbjMds0XL6uf1jmXhpHkRscYc5iOXo8RPC4vO1YC8sYkW+IbYcIh/Xc5I/CEiJbnB+FIYH5wI5BRRJMe+ZPL/eu6hbgrwvAvLKY8JK+GGu/CP+xwac1zLU0rWrb6klaYvfXxGCRuSC0DJWquc9NnpQgF3/+w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(366004)(346002)(39860400002)(136003)(376002)(396003)(451199018)(8676002)(6916009)(4326008)(66556008)(316002)(6486002)(66476007)(54906003)(66946007)(7416002)(52116002)(8936002)(5660300002)(41300700001)(86362001)(36756003)(478600001)(38100700002)(1076003)(38350700002)(6506007)(26005)(186003)(6512007)(6666004)(2616005)(2906002)(44832011)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QrirDxdwd3Hjxx4ZXwjyKQYAH72hNwKg6dLeqTGeugzySZDS/qiqgxwSPaw/9bDhl4xOlSmCYtXgEVHYkksBI/J+WtqxV+PmJSmBLO3Q+Did0dU5OxtNtiOiqMhGo/CA30lcrzIK+dIOuaepKUe+oPjY+7xMTvlliU/HXUcM0Itez7N9QCFqANCcxnu6yNiNbF+T5ZriE6SRsTr+NfhfcjTSsnuqo3fGyPdBT3XcfAc9V3F2yFMUyj/X3jVtZm55J6W3BKB4DhpftKCzFKXX/1h5tnx4nRVZ5o7UpK1aJAA4VrJPRJz892IdmEJVEnW2OEXdzUZFw2qU+IQ42Y3lV5KUyQwlqJXNqtIeANfL5A3tatAhlYD/2gWeueeUf8VE1jBlPE1rETnPhAh2OLBgj4LyrhcHn2VMD3wVuMJWyafRiysPE/d6YH0zQAUxkhe9Rj529J73SQPhBtvX4YOpD7GDntax/8TI0CPaIbG6Nuf16kyzTcpWKEgQxtMHWodaKfS3okM08chpw9UWGp0iurBxvXUH3hiq9NL0R3DCITHdD2bXDpzUt5YY/i09KawSBj0RQYLMWmlgR6Dw9ax4/pZvRicqhbbf7wMeo9NISeiedJb8UNGJaOUNEPdsOFKj0uHtmVV5iyY98UwG+LaDfOJHUb5UPvIXm/d7pJwMn/C3BaV4BM+t9KctNkEe/ESgcxGcB6FmJl2fw38QbdUyixLm9Tw62smsIZ3YirisqqmZSEDoOWWkFXqJqyIlW4sQetrrwBXy+72sU3LmbTFJYI2GqaoNb8BLWv+uzYav9uqfSCmq8uU8CnWuilLf8+8qGscn83ucu+H1P4zxcwwMow4d7jrMc2oS9ujZNvpPm7xjWwPpdi022msgHd2mH+F0BZnVl9H460YRgLIz/ZNzZN1u35IMV6itz0ffSTAXIwNeD9aN/mVTzo+SSJviEb8eMitzMuB+GdosR7YCCCaGkmDJjub25FcOq8l1PGwJPagHiVXEm44GaMUQjAzKB/d2M7jl8Z6z+bzCqfDqeOwIwN66nzbbUFGdoAn6coNfhJKy40/VZIcFkqJ1O7lXTuLpkKwGaDmcIa1LQWw6kP1nx/CmVcq2vlD0WxpL0g93qwvtJHWqxs1P21ULqfH6/Yzf3srqP+f1eArxjLF/wOvB1lYXLetSu5G7tlkyuD9vHwCtCoMSrQs9vqCvAiEQkoCAaLSZKOFaHimpDG9ZbRv1B+Vh1IorZh1tDMXG77xMI8jhMQ9WN721iPkpgB+z59XXzh9aGtTwNnnQOYTP8xpnkiPJVgVf3IRa+iFWhTOfhWDUdXDRKesbLZ458MOXGxi3EdfZtLVzic7BXlSl6ZMU3Oy3TQcFdHdok6coU7+ngFS2mcSQowytEiqTTzTxWMRItJauGUf3/vQa4GkgkcOxIId4R3lrZUx2426cLs/ls6vvryFUIfs0cRrUzqyT8MeGCdHha6m9QYgnmk9wacMu+uCI8dIxTU+nchHY6v9M3c3uhIkT158eAkfm9O1fVggFRasNW03egLLE40rirh7sMldU4rMBeSImDyimFoLDgGINMRsl8s3//xVDOIGhaCtbhCNOvIyVzDjV9fPUNtOc+w== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0f15fd6b-5930-47ef-2ba1-08db133d614b X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2023 12:24:15.2274 (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: Q9iYcvTk4pv3Q58lIvD+NdE6dWM4cToTxYHqDR3g9ripHC+O2ba9ZGrmgdFc/1Ace00/qJK3U8x2rVs7xC6waQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7725 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_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758353726795603333?= X-GMAIL-MSGID: =?utf-8?q?1758353726795603333?= This is a duplication of the FP adminStatus logic introduced for tc-mqprio. Offloading is done through the tc_mqprio_qopt_offload structure embedded within tc_taprio_qopt_offload. So practically, if a device driver is written to treat the mqprio portion of taprio just like standalone mqprio, it gets unified handling of frame preemption. I would have reused more code with taprio, but this is mostly netlink attribute parsing, which is hard to transform into generic code without having something that stinks as a result. We have the same variables with the same semantics, just different nlattr type values (TCA_MQPRIO_TC_ENTRY=5 vs TCA_TAPRIO_ATTR_TC_ENTRY=12; TCA_MQPRIO_TC_ENTRY_FP=2 vs TCA_TAPRIO_TC_ENTRY_FP=3, etc) and consequently, different policies for the nest. Every time nla_parse_nested() is called, an on-stack table "tb" of nlattr pointers is allocated statically, up to the maximum understood nlattr type. That array size is hardcoded as a constant, but when transforming this into a common parsing function, it would become either a VLA (which the Linux kernel rightfully doesn't like) or a call to the allocator. Having FP adminStatus in tc-taprio can be seen as addressing the 802.1Q Annex S.3 "Scheduling and preemption used in combination, no HOLD/RELEASE" and S.4 "Scheduling and preemption used in combination with HOLD/RELEASE" use cases. HOLD and RELEASE events are emitted towards the underlying MAC Merge layer when the schedule hits a Set-And-Hold-MAC or a Set-And-Release-MAC gate operation. So within the tc-taprio UAPI space, one can distinguish between the 2 use cases by choosing whether to use the TC_TAPRIO_CMD_SET_AND_HOLD and TC_TAPRIO_CMD_SET_AND_RELEASE gate operations within the schedule, or just TC_TAPRIO_CMD_SET_GATES. A small part of the change is dedicated to refactoring the max_sdu nlattr parsing to put all logic under the "if" that tests for presence of that nlattr. Signed-off-by: Vladimir Oltean Reviewed-by: Ferenc Fejes --- v2->v3: none v1->v2: slightly reword commit message include/uapi/linux/pkt_sched.h | 1 + net/sched/sch_taprio.c | 65 +++++++++++++++++++++++++++------- 2 files changed, 53 insertions(+), 13 deletions(-) diff --git a/include/uapi/linux/pkt_sched.h b/include/uapi/linux/pkt_sched.h index b8d29be91b62..51a7addc56c6 100644 --- a/include/uapi/linux/pkt_sched.h +++ b/include/uapi/linux/pkt_sched.h @@ -1252,6 +1252,7 @@ enum { TCA_TAPRIO_TC_ENTRY_UNSPEC, TCA_TAPRIO_TC_ENTRY_INDEX, /* u32 */ TCA_TAPRIO_TC_ENTRY_MAX_SDU, /* u32 */ + TCA_TAPRIO_TC_ENTRY_FP, /* u32 */ /* add new constants above here */ __TCA_TAPRIO_TC_ENTRY_CNT, diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index cbad43019172..76db9a10ef50 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -96,6 +97,7 @@ struct taprio_sched { struct list_head taprio_list; int cur_txq[TC_MAX_QUEUE]; u32 max_sdu[TC_MAX_QUEUE]; /* save info from the user */ + u32 fp[TC_QOPT_MAX_QUEUE]; /* only for dump and offloading */ u32 txtime_delay; }; @@ -1002,6 +1004,9 @@ static const struct nla_policy entry_policy[TCA_TAPRIO_SCHED_ENTRY_MAX + 1] = { static const struct nla_policy taprio_tc_policy[TCA_TAPRIO_TC_ENTRY_MAX + 1] = { [TCA_TAPRIO_TC_ENTRY_INDEX] = { .type = NLA_U32 }, [TCA_TAPRIO_TC_ENTRY_MAX_SDU] = { .type = NLA_U32 }, + [TCA_TAPRIO_TC_ENTRY_FP] = NLA_POLICY_RANGE(NLA_U32, + TC_FP_EXPRESS, + TC_FP_PREEMPTIBLE), }; static const struct nla_policy taprio_policy[TCA_TAPRIO_ATTR_MAX + 1] = { @@ -1524,6 +1529,7 @@ static int taprio_enable_offload(struct net_device *dev, mqprio_qopt_reconstruct(dev, &offload->mqprio.qopt); offload->mqprio.extack = extack; taprio_sched_to_offload(dev, sched, offload, &caps); + mqprio_fp_to_offload(q->fp, &offload->mqprio); for (tc = 0; tc < TC_MAX_QUEUE; tc++) offload->max_sdu[tc] = q->max_sdu[tc]; @@ -1671,13 +1677,14 @@ static int taprio_parse_clockid(struct Qdisc *sch, struct nlattr **tb, static int taprio_parse_tc_entry(struct Qdisc *sch, struct nlattr *opt, u32 max_sdu[TC_QOPT_MAX_QUEUE], + u32 fp[TC_QOPT_MAX_QUEUE], unsigned long *seen_tcs, struct netlink_ext_ack *extack) { struct nlattr *tb[TCA_TAPRIO_TC_ENTRY_MAX + 1] = { }; struct net_device *dev = qdisc_dev(sch); - u32 val = 0; int err, tc; + u32 val; err = nla_parse_nested(tb, TCA_TAPRIO_TC_ENTRY_MAX, opt, taprio_tc_policy, extack); @@ -1702,15 +1709,18 @@ static int taprio_parse_tc_entry(struct Qdisc *sch, *seen_tcs |= BIT(tc); - if (tb[TCA_TAPRIO_TC_ENTRY_MAX_SDU]) + if (tb[TCA_TAPRIO_TC_ENTRY_MAX_SDU]) { val = nla_get_u32(tb[TCA_TAPRIO_TC_ENTRY_MAX_SDU]); + if (val > dev->max_mtu) { + NL_SET_ERR_MSG_MOD(extack, "TC max SDU exceeds device max MTU"); + return -ERANGE; + } - if (val > dev->max_mtu) { - NL_SET_ERR_MSG_MOD(extack, "TC max SDU exceeds device max MTU"); - return -ERANGE; + max_sdu[tc] = val; } - max_sdu[tc] = val; + if (tb[TCA_TAPRIO_TC_ENTRY_FP]) + fp[tc] = nla_get_u32(tb[TCA_TAPRIO_TC_ENTRY_FP]); return 0; } @@ -1720,29 +1730,51 @@ static int taprio_parse_tc_entries(struct Qdisc *sch, struct netlink_ext_ack *extack) { struct taprio_sched *q = qdisc_priv(sch); + struct net_device *dev = qdisc_dev(sch); u32 max_sdu[TC_QOPT_MAX_QUEUE]; + bool have_preemption = false; unsigned long seen_tcs = 0; + u32 fp[TC_QOPT_MAX_QUEUE]; struct nlattr *n; int tc, rem; int err = 0; - for (tc = 0; tc < TC_QOPT_MAX_QUEUE; tc++) + for (tc = 0; tc < TC_QOPT_MAX_QUEUE; tc++) { max_sdu[tc] = q->max_sdu[tc]; + fp[tc] = q->fp[tc]; + } nla_for_each_nested(n, opt, rem) { if (nla_type(n) != TCA_TAPRIO_ATTR_TC_ENTRY) continue; - err = taprio_parse_tc_entry(sch, n, max_sdu, &seen_tcs, + err = taprio_parse_tc_entry(sch, n, max_sdu, fp, &seen_tcs, extack); if (err) - goto out; + return err; } - for (tc = 0; tc < TC_QOPT_MAX_QUEUE; tc++) + for (tc = 0; tc < TC_QOPT_MAX_QUEUE; tc++) { q->max_sdu[tc] = max_sdu[tc]; + q->fp[tc] = fp[tc]; + if (fp[tc] != TC_FP_EXPRESS) + have_preemption = true; + } + + if (have_preemption) { + if (!FULL_OFFLOAD_IS_ENABLED(q->flags)) { + NL_SET_ERR_MSG(extack, + "Preemption only supported with full offload"); + return -EOPNOTSUPP; + } + + if (!ethtool_dev_mm_supported(dev)) { + NL_SET_ERR_MSG(extack, + "Device does not support preemption"); + return -EOPNOTSUPP; + } + } -out: return err; } @@ -2023,7 +2055,7 @@ static int taprio_init(struct Qdisc *sch, struct nlattr *opt, { struct taprio_sched *q = qdisc_priv(sch); struct net_device *dev = qdisc_dev(sch); - int i; + int i, tc; spin_lock_init(&q->current_entry_lock); @@ -2080,6 +2112,9 @@ static int taprio_init(struct Qdisc *sch, struct nlattr *opt, q->qdiscs[i] = qdisc; } + for (tc = 0; tc < TC_QOPT_MAX_QUEUE; tc++) + q->fp[tc] = TC_FP_EXPRESS; + taprio_detect_broken_mqprio(q); return taprio_change(sch, opt, extack); @@ -2223,6 +2258,7 @@ static int dump_schedule(struct sk_buff *msg, } static int taprio_dump_tc_entries(struct sk_buff *skb, + struct taprio_sched *q, struct sched_gate_list *sched) { struct nlattr *n; @@ -2240,6 +2276,9 @@ static int taprio_dump_tc_entries(struct sk_buff *skb, sched->max_sdu[tc])) goto nla_put_failure; + if (nla_put_u32(skb, TCA_TAPRIO_TC_ENTRY_FP, q->fp[tc])) + goto nla_put_failure; + nla_nest_end(skb, n); } @@ -2281,7 +2320,7 @@ static int taprio_dump(struct Qdisc *sch, struct sk_buff *skb) nla_put_u32(skb, TCA_TAPRIO_ATTR_TXTIME_DELAY, q->txtime_delay)) goto options_error; - if (oper && taprio_dump_tc_entries(skb, oper)) + if (oper && taprio_dump_tc_entries(skb, q, oper)) goto options_error; if (oper && dump_schedule(skb, oper)) From patchwork Mon Feb 20 12:23:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 59419 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1284556wrn; Mon, 20 Feb 2023 04:42:47 -0800 (PST) X-Google-Smtp-Source: AK7set8mt9nFzETToNwfDgrI2GRmw4r12ivvI8fPuYAdh5CnW/yh0d1n1d+G6mlnmSxKk2MsVAsX X-Received: by 2002:a17:902:c40b:b0:19a:964e:d6d2 with SMTP id k11-20020a170902c40b00b0019a964ed6d2mr838439plk.48.1676896967397; Mon, 20 Feb 2023 04:42:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1676896967; cv=pass; d=google.com; s=arc-20160816; b=RKhhrc6yLKrzgB2LU0ePzVl1p3BbyNfFvqtjNC13iu+t2jfZVjCW8i+lKh0AIjUoNH IlNwgRwef6AJSySGBw+/6mFzn6h4iOMaczWt5Q8Ik/N0OHhazIVaFm0uM0pDy+/TJqE7 pBKlOLeVu3zSRWA/7zUMM+PcPXqoPnR9TPP24y4+nUNSpJLnVZF0YdHTeaSzW9ZQmDif sB9xFRfCYv6WFRwLhJ/RYW5TGBUBuv8J0NMnL84oGglCbN8Y226YrS5BQ2dDjodTEfVt PoYOO+HWLiDmXiEcEMPjWUDv3wUaH7FRle/uIB5aEOsPIUAdfc/Ng2QGwDBWJrsgz03K 5n+g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=P4ulBNbC+xUMiqkXZUQaW3mr3nHm+pzcba5ZADkMH18=; b=WRd1v4uAyJUvHmwMpAS7aH/vO9lm25O2qbMHECEQvGX1rlu3gENo+SLVphOGW5Bg5z CcJmfMKVgXhk5sEuxbRJKaV6WPG972nc6RFOf30WkjT1t6JQ2iEQQ32y5kizpIMrCgRG wqEPizf8vm3k0j7fkgm7v8WGy/Opxm1oLVi4gLFs890w6nsiZDG5SrXd2MLGu1olz/dc ULRZeWfYsIFbrBqyZm7w1ACh/Hup4N1g1z3yQTT2BTenv4O3rVSqnReqXLZB7KCpk9pb LbKrFp6e7QbgfSirFdOP1wDcBleM6Hnq1alFCk3rEQxSq2oOj6u/Fp//2cOwDNy26Tk2 d6Ng== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=QlkfB4B0; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e9-20020a17090301c900b00194967b7badsi10642695plh.591.2023.02.20.04.42.33; Mon, 20 Feb 2023 04:42:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=QlkfB4B0; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232096AbjBTMZv (ORCPT + 99 others); Mon, 20 Feb 2023 07:25:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232132AbjBTMZf (ORCPT ); Mon, 20 Feb 2023 07:25:35 -0500 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2071.outbound.protection.outlook.com [40.107.15.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58DE31C592; Mon, 20 Feb 2023 04:25:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U/EW7cZo+gn2Zrl/S4T1kRc2QnBcO9aUvpQ9Y7I9DyOwYRM3kw6/gHsj/eQAPmNNJ4fGnvyV/PR8g+AoFFbNv3R84N5GYDRQPc5jEWWyWwYtUkyUqnW8QnD3FiQB1Dvp+x3/SBcWc+ai88csFyJ5cYHtKheQi5cYKJ3yIzrh2N7cskhPQDcwjzVtoDsfpqa2wlFwdAABFxND8hOWgNFiIJPpmPZUI+VkiFmNErP8cOJw/LEVBe/SS0tBZs1HOG30Wo6WBdpWCSyX38LGohM+3bC+7iqKtT5/abUhuLRzwG4GypZbzfbiZonS4QT/1SQnLj9fVL1riKJ+OelNcXsH9w== 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=P4ulBNbC+xUMiqkXZUQaW3mr3nHm+pzcba5ZADkMH18=; b=cIV71Js0nDeGlbSkVEQmJJCEBG33goWuP4cctaYU6eUUqNGcQSAPPBvFod41CgbzWIGarccqnbl7/oTa61QTOUU38vls30KHkgvUCoLhZ/T6zW3TgsVHCEPrroD/vbUQmYZ3a9LY1fudWDPKxB5EgTi6kIQaGgyF0Qn9YPA0XDKBm55MMFYLC2R+KxmxlrzNJfNjwWkRfoOeWg/vWN7s5qSe1Pa/xgiuN5z2NNvyIXaUyGTr+L6gojGTLav8qAuzL9yggboV4psDYB1IMdJkjNnh0kOCaZeMTgf3r0yYzieA4QvP89pthZzvIiIVgQ+3WNWWICoJFFiwfzDF7Nq8zA== 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=P4ulBNbC+xUMiqkXZUQaW3mr3nHm+pzcba5ZADkMH18=; b=QlkfB4B0XwJXMiRMMR5OGhvAFvyoAKY8Wh8N+MCaLyPopKZ4whFxhYxiBDSHl2bL5iP1F458NelKKbUeBHGU2nCOP+x1gZ2moeHZ/OmLn7K0fK6SNv8EWcEPnDoS5N/eHlUER1csMqK6k0fRGqEbU6htbMX06LjnRRBRo5Lp2wo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by PA4PR04MB7725.eurprd04.prod.outlook.com (2603:10a6:102:f1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.19; Mon, 20 Feb 2023 12:24:17 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6111.019; Mon, 20 Feb 2023 12:24:17 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vinicius Costa Gomes , Kurt Kanzenbach , Gerhard Engleder , Amritha Nambiar , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , Florian Fainelli , Ferenc Fejes , Xiaoliang Yang , Roger Quadros , Pranavi Somisetty , Harini Katakam , Giuseppe Cavallaro , Alexandre Torgue , Michael Sit Wei Hong , Mohammad Athari Bin Ismail , Jacob Keller , linux-kernel@vger.kernel.org, Ferenc Fejes Subject: [PATCH v3 net-next 09/13] net: enetc: rename "mqprio" to "qopt" Date: Mon, 20 Feb 2023 14:23:39 +0200 Message-Id: <20230220122343.1156614-10-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220122343.1156614-1-vladimir.oltean@nxp.com> References: <20230220122343.1156614-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0183.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:8d::17) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PA4PR04MB7725:EE_ X-MS-Office365-Filtering-Correlation-Id: ddea0066-5d33-404c-7627-08db133d62c1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +zuYMSARG4H9bcVtezGDToQRulaiZmjAUeIQt2/541/hHikMpeDWlfsBW462waR0XGL2HKj92vwg4RijRVt/SqY+MgG4nG9gziou32cWWzSOC96X6Thrcxiamzoq4uAsvrWXuKKfWt+wz4PQDuwWCFEhH90mVhvYMlJhaBZCIdwnnysLR8p0hcdmk8m2+c7/OjjsU/xNK1XfvlE2Dry5VT4raRHm6ur9M1HlVTwO1MiiuC/13BALboXqAgNnZSF/AV9w9ovD2FKE6frRp3J+kj6yfUhQE/E0hvIMWXxAvrSYodLnaW2ej1mvB9vEoUCeijQhqzFjIkrcb6QOAJWofLpPYAywR4EaWNDq5fgQ2S0IXka2UMJe7tFTNWJVWnbRYojivQlM57sHdC9/tS5htClKlFomFY5ve4xX9xiTlJEveW/QRfImc5Fc5hO1nlyDzAn9KpqJktMuEYG2dlbkEEHNj28e1fju/vmK6OFVtTAUeE1wTn2TGYEyR2EACRpGq1ij+DtZnnNHWO6c/A4M/+Ms91teNRwt8i5rdYC8eHRfwdc729tao2TNJID1HoDi6l1WJ7MK/Irvd3GPpKB8yHM8laytTv2PxfQYpg2aNnVLDhz5CIqzWdtHHTK3mxfT91VUwDUMvptVu/3xaUkIA1C1xgDw3y3hJdHqQFZajJXxDI/kGN20fKQMAH334F0hSXuEYkv9A/Id/c+9TMk1aQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(366004)(346002)(39860400002)(136003)(376002)(396003)(451199018)(8676002)(6916009)(4326008)(66556008)(316002)(6486002)(66476007)(54906003)(66946007)(7416002)(52116002)(8936002)(5660300002)(41300700001)(86362001)(36756003)(478600001)(38100700002)(1076003)(38350700002)(6506007)(26005)(186003)(6512007)(6666004)(2616005)(2906002)(44832011)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Ib+P3AHHZCvhU+KQOmGiJWEZw4+2HeSPEkLSaR7hAJzBR6Ja4EnMpbiVJliBqRhItCijMA7aqx2P1JY6XW1UawicyKx5u9unfC4W6VBM1E93kBs96W+bWJae8LaXxUnvl6567uqmvTtzVyVIbJfj6eMzaU6xJOgsyOQPOgGG9EhqhLRhGJt/bEpHGaCEgHG5yiogvrk7pIl1zikldRVsmukUm/kuWTUGj58Kmn6JP2m6+g6lGj86VtPp4s40j7GOXKkVnXNyLwcq1j+WZXmxJs8XzDaFroXo4WOaWZKdaiV4LfR3Dxh5dgdIDJfTRpZSsyl48a1nHJDmifmqOTc1MnfG3UAugj0nTm2q8/AlR3D6if1K1KfGgI+3ptjg6r9Xh7XMGUKaCIVcjrUTwm1ytevALxsG726pYW+oEW0APYhaRwV/hZif8E0blLZkws7vPO125MC3TVITGTcyDthckgMSuUM96S8Rf0KsiWdEKqjSQsGjidyNtJzz8ifyMO8x+0PR0knSEe1j59mM0riALHrExlIj/F1r2xqGNxDHOj82MTZj+goy3yM5/xff9Bs0Xre5uvsL9Pr38Th321rZFrXbL2TXq+wfovfai8nFDaegD2xmGvN3fxzTVhzTVXZXrua0RZZIX9esdVOWZzCid7e+wJkvbmoQ/hF/kq+assHbtiH+7WdlJMXD5y+ZDj54oVPAHaoCuMZkWRHGkNKy0BVHMNwo6a8Al8sb7CQHX5qBzRVd7K09PseVtLL1ipfcsl9djEDY2GdMQEUTUBpki2j/GefCMYdxl2diVYdWqNoQlFj1IV8VuM64mcnszacyDtvPY+9zEUhWT0LBJER6H0oVq3PgHuUqnL9s0HNeIZVwasYizvC7lAkNrY6KnQ2p09mXxVC5fblLbFCU2qa7Kjw5CJrCwigdJn/VaPIcicZ4iavSQBNLnQVhYd+K/xIxPx4HJ+Vn56Va8MlhhA3EHTg2xoSLihWGUFYBlMU2ePZyynNRc1WlaFKO350+BcpkK3NuV3r6mqnRKEcaK3d8qD19fzHoRetdU2w8tIDdcLpmCUUof3iOuBffcSMI0uH61P7/c/kbTtHufTdr3EcrQjUPKasKlu9brMlURuZMh+Kbf2sbpRmM8eMTr/NEtpIEk46dYD7+g0ZAKKtFw9sE5dT4If/q/njmIhN8hSWOSOXrtp71bapHTbVI/1AdXh7p39/+FJPZa5b0p0KZA5UlbhkLN5eMsyokzt7IPY3nVA+buPhaC1OlIcHeuoQUCfttxj97W/pzOgRqMYVswlW2cNA4sVXbXOC1xSFIdT7GQK4PveqKatca+8FeGykyAlwkUWXWKUf5oL8knIenUCBNKUougi7BBOEJQO80CaMzvSWgnxcsMNUDPSMJ0tCCQsKdRduKRduVzwKNQBbxbTXvzDI4SaUbLHbC7crjxTYQ5BLdDGIomO1cDVcY+rxAwEKibcrs2D2r1Prt6Yomzl5vZ3pcmzEuskUgf4i3vrVh0/dqs+LnVbeD9f0N3aC5XqDrKWvidKGykW2afwvmZ2hBIWmwe17R5EpjpO/+a3dttyWTlJPQixDUYSRKbeJFHTu+g6ccXmjOeOQ0kcgLvqCY/w== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ddea0066-5d33-404c-7627-08db133d62c1 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2023 12:24:17.5866 (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: RXCz2ivTRlIEi+4uecV9vPQ/pAvyHvkmYU5iqBUiYH4DpQNs6t6Gh2qWxPK4yeQGDS/BWcfnAM8ERZffFbUACw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7725 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_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758353914273824727?= X-GMAIL-MSGID: =?utf-8?q?1758353914273824727?= To gain access to the larger encapsulating structure which has the type tc_mqprio_qopt_offload, rename just the "qopt" field as "qopt". Signed-off-by: Vladimir Oltean Reviewed-by: Ferenc Fejes --- v1->v3: none drivers/net/ethernet/freescale/enetc/enetc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index 2fc712b24d12..e0207b01ddd6 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -2644,12 +2644,13 @@ static void enetc_reset_tc_mqprio(struct net_device *ndev) int enetc_setup_tc_mqprio(struct net_device *ndev, void *type_data) { + struct tc_mqprio_qopt_offload *mqprio = type_data; struct enetc_ndev_priv *priv = netdev_priv(ndev); - struct tc_mqprio_qopt *mqprio = type_data; + struct tc_mqprio_qopt *qopt = &mqprio->qopt; struct enetc_hw *hw = &priv->si->hw; int num_stack_tx_queues = 0; - u8 num_tc = mqprio->num_tc; struct enetc_bdr *tx_ring; + u8 num_tc = qopt->num_tc; int offset, count; int err, tc, q; @@ -2663,8 +2664,8 @@ int enetc_setup_tc_mqprio(struct net_device *ndev, void *type_data) return err; for (tc = 0; tc < num_tc; tc++) { - offset = mqprio->offset[tc]; - count = mqprio->count[tc]; + offset = qopt->offset[tc]; + count = qopt->count[tc]; num_stack_tx_queues += count; err = netdev_set_tc_queue(ndev, tc, count, offset); From patchwork Mon Feb 20 12:23:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 59413 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1277428wrn; Mon, 20 Feb 2023 04:27:01 -0800 (PST) X-Google-Smtp-Source: AK7set8Q2Q6R9E59fHq9Uq07fijTqiRtzNQCYT3vJ9agAmimFq8IzeVy1C6KlQ3eHVcpDryVfGDr X-Received: by 2002:a17:90a:ba91:b0:236:6e16:6d5b with SMTP id t17-20020a17090aba9100b002366e166d5bmr1145815pjr.20.1676896021593; Mon, 20 Feb 2023 04:27:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1676896021; cv=pass; d=google.com; s=arc-20160816; b=ux1QFDQfECbuEDiwaGWAcCEVwC8HKiVxy5usQ9rbuyJtsEHSzXdaj+JVV/E1T4Bj8u wY6bhLfAddruVChQAnP0s4XNBIBtseexgl0KCHWb0Rk2Lm2QyvHtZlcvKiyMBluITUy7 60deIj/1eUgyFuJpttek6unEm7sej704towEUOzNjKU509uEHcsPfubrkBMxcB7TznfV /LrSexxF0uOuJTntqUJt/yaBqKHbly43A6M/AXlG4zWWvcCpyfK0iM4sCfPjNTSncAed BP6wRL+ZdWPBZvchq6w7OlhmUX0fzUTiR9E6gECTlEJBFJa2jeoiDpdxAGFXz8E2y//o YpVQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Ef+WqSHJ4A7CEjmveL5Kl3y8W8XRdCPHWrgCjRqbdP8=; b=elRkWSNCeTnUsTO7lk9+ATzGGcDNFDNkxg6YV8rWcy+4AImrVKThEDUORIKZfKyLkl RxrE7xH33FErOQ6Rm/DBgNyC2BJRSzW1Q+S7VkLaDRg0ynXEtJwdM53WYPvuuCkCoeIR MwbpU7dHyd4hYtMA4fNleo9Lzjv1rpCkj/GdMt4amjq4aaWtG6sWN0X3Knv8kPxqeN8o wLUDl/AGR2OjpsU37ulamoMGEYvEajqu4m+G1WsmofTXj9dfWVLeW3rpymJ931pKO5/R 1SBKqc0LDEC4IXl/l3qWm9CeReEBXcnbc86Xa8F2cF8T8Dw1961woLzOzDCCZwX75g/3 eIHA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=bk5wXCYM; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c8-20020a17090a8d0800b002339ac5a127si2808432pjo.139.2023.02.20.04.26.49; Mon, 20 Feb 2023 04:27:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=bk5wXCYM; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232114AbjBTMZy (ORCPT + 99 others); Mon, 20 Feb 2023 07:25:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232134AbjBTMZg (ORCPT ); Mon, 20 Feb 2023 07:25:36 -0500 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2054.outbound.protection.outlook.com [40.107.15.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42A951C5A8; Mon, 20 Feb 2023 04:25:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H3VCmVzy7Vz9s/iynKVc79pF+tzv90ZgptYrfnswdsNerWOo2OACePcvcgFY8RAoHCvY/evboj1T3vzE6kXo/xyvdt6GKJk9vWRJnQ5imTvve7kgG9HPvEGinTX7REQWl+6vmubPCBJRPPIB+GumUeMBXS+LygnzGA2AbXo49C0fFdCnS1vJ/0uVyEtrhvlL5b+cs7rrIOQ5K63LB71E/LvmTS9/9zhtTfU3BpP7HlD8l15YkHLPqJ8dsTrwtQAH7uafBhU8eBlHr1IMFsxJfv/qXqSiSORePkTWDuNmoQPgBoEFHbUXU9b0yJ3gTFpo/AlXJGsWxqFnpzXrtQxg5A== 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=Ef+WqSHJ4A7CEjmveL5Kl3y8W8XRdCPHWrgCjRqbdP8=; b=TncbHhN9GQtpvxLvsAzyZZwgU/LUXWZ1HSRra/eSdd1EkG6wU3Xm+FTfrBwl0E9eWNyhvGVtcvuFfBzxdfeCTL6a3zrk80mVFnw7r0j9UGCimygkxJckOOF+/soYjtzHQaQIpsHIGqnDpeW+qj1wg9f4DZbhd908yrg5TcCJ9P5raiK5paxvW9xP+aALrB1zeJYNespP9OVnuWqUXsQsHctGw6pWow9KUv7km+SLr/nd9dw2iC2G+QHX8xe/8De9x88Z941qo/F4QBK7GKJoQ/etUgdME74bzlhqANgvjqQxIyLnOGMhJ04iZVr/f325KMFAxoWT5DPASm1jXqdUSA== 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=Ef+WqSHJ4A7CEjmveL5Kl3y8W8XRdCPHWrgCjRqbdP8=; b=bk5wXCYMmLswigP7/zaP1C0oEYqUtCW+TEtC4ToK9fBmbO8HIT6jMkngJkMHwft92Z+GJznIVpWY1huYb0sEP8oFex3f85Jk2oAlAmwYx11Ejo0c/LvnA2Qd/S2oplEaF+p39QlbyR2u7eT4dIKQx4S5Daj9N8N7cyDaxwh15X4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by PA4PR04MB7725.eurprd04.prod.outlook.com (2603:10a6:102:f1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.19; Mon, 20 Feb 2023 12:24:20 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6111.019; Mon, 20 Feb 2023 12:24:20 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vinicius Costa Gomes , Kurt Kanzenbach , Gerhard Engleder , Amritha Nambiar , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , Florian Fainelli , Ferenc Fejes , Xiaoliang Yang , Roger Quadros , Pranavi Somisetty , Harini Katakam , Giuseppe Cavallaro , Alexandre Torgue , Michael Sit Wei Hong , Mohammad Athari Bin Ismail , Jacob Keller , linux-kernel@vger.kernel.org, Ferenc Fejes Subject: [PATCH v3 net-next 10/13] net: mscc: ocelot: add support for mqprio offload Date: Mon, 20 Feb 2023 14:23:40 +0200 Message-Id: <20230220122343.1156614-11-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220122343.1156614-1-vladimir.oltean@nxp.com> References: <20230220122343.1156614-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0183.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:8d::17) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PA4PR04MB7725:EE_ X-MS-Office365-Filtering-Correlation-Id: 973680fb-9fc1-41f6-1074-08db133d6427 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s3m9dIuT0hnCQlt9Xz4vMcBcPC/ExRITjrENDFNHNoiBhsyISMc/ZDlk/gdjLOUmq617u2/dykgN8ZrBe5noPhDXRH13JHAwPef3Jb/j+IbId0VeTvkivnzlIUSGfZYWWWl5/3pmgCeLZ9qwh4GCwKOF12lxi5dm8OtQP7iV+TbJrwpcjbu/kCzGDLva8p0uHotBywmiBm2lBxri+NmSj9pxHp60wOEZc87FVB96o8SmO+OjsLCMeeG2I5iVbLnqH9H8ns9pOXnN/pFA5lO0zJd1F2qTozV447KGr+PVvmc5M8qi+oazAl5D8cBsM7vdwhUui5syUzILXMeTXPZGmxTEuRTLysnrDauYjY8j2Cs0gg/R4zNVpJbIChxCFpQJlIlvI2l1ngfyF5Wix+T/2JlA+2zTP7FRDESSCyduela8FvNTHG3Rfss5wLQvVIY0tzHIfdRgr5hJIaQ9FiXR+ipL34YtyHQXuSVRSJ8324IG7VhWGMt8kdAk94UW8XkyHltMgvP8eMIVu8yjyY8zlF48UdrcZaYx8jIjhRbLQH0F7iKWtnW/93RtiSN/Jp3cXCGYnPVunfw1PVR0UGECOYNKS6kWZZr7NnEiLtEKkrK79UeoL2pXsqNogkaPXVhsm+GFjKGE0OrcYgFUfXesbIFuSPsjQ8J4KkNXL5HaCJyb6mKQlDhi3e+TruqXMzO0jp9R8DR98n0YAjzjHSXIpg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(366004)(346002)(39860400002)(136003)(376002)(396003)(451199018)(8676002)(6916009)(4326008)(66556008)(316002)(6486002)(66476007)(54906003)(66946007)(7416002)(52116002)(8936002)(5660300002)(41300700001)(86362001)(36756003)(478600001)(38100700002)(1076003)(38350700002)(6506007)(26005)(186003)(6512007)(6666004)(2616005)(2906002)(44832011)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lE+PgYfMWX2Cphz4ywKte+BbxtpJvlDRUsVpl0DUVJkThbZt8Po/vLOx1PfQ1mty1A+Uv0AkS/qpp51h2oBJgu2+N1SeLr5tGuISQYyHVwKldM/aMKjo48i7r2EUTJlw0yWCDpmgExuU+sU3oVf8Fs5O80IEgy5MtjvPsxLx6APrSp5+cOc1JyDc2cu4nxrCTg63217NYWLk5WgRP2oX+/KzmbLr5g/zXMZLtBni54+mQUe0n20PINZLBnFOSFOFxn4MRM3iEk0D+Ofx+GhR15Wxapea3AFFRaIJvMulXLyNF9FFAC3aCn5xhx0mfmMtFByY2BxbX4HPuigR9b6Zt4I0/AvYQY9wdsejKckGe5/oudW70i9neXgmIS5dp8fstTvycaXtVIePNSYPlKPWVlRJ7sNzuEO04eQnarnjA/hqiiS3izmaMYyLUA95HA8cl8TzIps8/WLrjgxjwgEh2dfL7RiD//h2LUt+rMM1Ri4mljOEspRTmlt03qNTzSqwMtPPDw8HxBwqj1LazDEUZTiblS/QgImJoNRXbUH0Tg8vMR3P1MnIZjY7SBN5Th4hpdlW03ajSgAxk9ZwXFMY5hOHqjMpPYEprAj25sYorK+Js7bMIlqfBBF3JXisrPlZL7y8V2/ngP9u4/Qb36V0KM2is72G9eol2NYkJLKw3BV1aNIXQrGjnx5hkWV4tWMNd8fC3ZM2K6FC2R3rL5sTo2rhA3IqKwFtdMc16CdDsSLqGrjU0eKJAUz5AELDrzzwvTeOhpwUoaX1pCUg5Ys+Bf5daEeU1dqBFHYxXXNOzanLpYa9ERSuGg8WvBWeJ+BSd3NCQvNqSO6eMEg+hdmoeqN0EzWiSeEXGBQmQ6+amXnJStawejJdhakKCCsglXqlpwfEI2Yg7qFADVJ/0NUhlPKNaxK94i6Dm+5u8PluL6wdYkKnYiRMh7b5XaW/bc7FM50w3tEfTYFTq50zT0AsnEoVzGJhinzcPdBZX7SiTG6w8yI9+vMNWrX06zdDwbHZW5pl3gL+NUT8INxp6Qk62FIEs0gVPExFiiUjTuomgDLsj/ETv6MipftZ8pAhRXUSNzYAYz7mXlmmLt/aPKVbuvEBQfdyS4g97yLrTP9y/LUACTGk86+TPmNzR39GFLyvmSYI5D/UBLbGXjTHItD+qJCQbHxptKwkD8ozsYCs+s8sCgpNOktIf+2y9O5P6bqohAq8Qt/DNF+LmalLGyaaL3B3/50UWPvW25Q8DzLzZKI4JPLiKcUp7tsIPm2A0TmQWfrBlDAXwzt2C6ZFpJ+z9LOmB7EhA9zG7CVqPwDgxGjfg1Bc7+Ksx6kcowXryuPLPRhSQSAWwP3w8H512YHf0FBAmemFp114EEoigASc/vIlxWL0PsyWy7UwBm/yqv22I/LnN/Q3mNBOsJffUgbGbMN7c+zvUKQ2wJphZknz8lPR1VuUaOxp/PGdY9bwwVS/F55oa9ujRFFmh+e5c9MUtEeJjurGFy7OEz67c8+WqWoNEA3Yd/L7ckJAGDqZI6/2EiCDI38FBKKDREcr8qHPb1wf91YouANb1/wfbxp/w11ye07NkqRx4Jp+oyxKxrR0n/dRuJD0cbI+ekCcJDa4kg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 973680fb-9fc1-41f6-1074-08db133d6427 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2023 12:24:20.0084 (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: Yr0ty8k/F3e0vhmnF05WzvoyxvmMuY5p5tP2sd1RBU7lTfYjtzQTiDr6bCXrCgasXFMUG4qNNRbTObyRENg79g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7725 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_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758352923039781105?= X-GMAIL-MSGID: =?utf-8?q?1758352923039781105?= This doesn't apply anything to hardware and in general doesn't do anything that the software variant doesn't do, except for checking that there isn't more than 1 TXQ per TC (TXQs for a DSA switch are a dubious concept anyway). The reason we add this is to be able to parse one more field added to struct tc_mqprio_qopt_offload, namely preemptible_tcs. Signed-off-by: Vladimir Oltean Reviewed-by: Ferenc Fejes --- v2->v3: use NL_SET_ERR_MSG_MOD() instead of netdev_err() v1->v2: none drivers/net/dsa/ocelot/felix_vsc9959.c | 9 +++++ drivers/net/ethernet/mscc/ocelot.c | 50 ++++++++++++++++++++++++++ include/soc/mscc/ocelot.h | 4 +++ 3 files changed, 63 insertions(+) diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c index 354aa3dbfde7..3df71444dde1 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -1612,6 +1612,13 @@ static int vsc9959_qos_port_cbs_set(struct dsa_switch *ds, int port, static int vsc9959_qos_query_caps(struct tc_query_caps_base *base) { switch (base->type) { + case TC_SETUP_QDISC_MQPRIO: { + struct tc_mqprio_caps *caps = base->caps; + + caps->validate_queue_counts = true; + + return 0; + } case TC_SETUP_QDISC_TAPRIO: { struct tc_taprio_caps *caps = base->caps; @@ -1635,6 +1642,8 @@ static int vsc9959_port_setup_tc(struct dsa_switch *ds, int port, return vsc9959_qos_query_caps(type_data); case TC_SETUP_QDISC_TAPRIO: return vsc9959_qos_port_tas_set(ocelot, port, type_data); + case TC_SETUP_QDISC_MQPRIO: + return ocelot_port_mqprio(ocelot, port, type_data); case TC_SETUP_QDISC_CBS: return vsc9959_qos_port_cbs_set(ds, port, type_data); default: diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 08acb7b89086..8227d2027c94 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include "ocelot.h" #include "ocelot_vcap.h" @@ -2602,6 +2603,55 @@ void ocelot_port_mirror_del(struct ocelot *ocelot, int from, bool ingress) } EXPORT_SYMBOL_GPL(ocelot_port_mirror_del); +static void ocelot_port_reset_mqprio(struct ocelot *ocelot, int port) +{ + struct net_device *dev = ocelot->ops->port_to_netdev(ocelot, port); + + netdev_reset_tc(dev); +} + +int ocelot_port_mqprio(struct ocelot *ocelot, int port, + struct tc_mqprio_qopt_offload *mqprio) +{ + struct net_device *dev = ocelot->ops->port_to_netdev(ocelot, port); + struct netlink_ext_ack *extack = mqprio->extack; + struct tc_mqprio_qopt *qopt = &mqprio->qopt; + int num_tc = qopt->num_tc; + int tc, err; + + if (!num_tc) { + ocelot_port_reset_mqprio(ocelot, port); + return 0; + } + + err = netdev_set_num_tc(dev, num_tc); + if (err) + return err; + + for (tc = 0; tc < num_tc; tc++) { + if (qopt->count[tc] != 1) { + NL_SET_ERR_MSG_MOD(extack, + "Only one TXQ per TC supported"); + return -EINVAL; + } + + err = netdev_set_tc_queue(dev, tc, 1, qopt->offset[tc]); + if (err) + goto err_reset_tc; + } + + err = netif_set_real_num_tx_queues(dev, num_tc); + if (err) + goto err_reset_tc; + + return 0; + +err_reset_tc: + ocelot_port_reset_mqprio(ocelot, port); + return err; +} +EXPORT_SYMBOL_GPL(ocelot_port_mqprio); + void ocelot_init_port(struct ocelot *ocelot, int port) { struct ocelot_port *ocelot_port = ocelot->ports[port]; diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index 2080879e4134..27ff770a6c53 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -11,6 +11,8 @@ #include #include +struct tc_mqprio_qopt_offload; + /* Port Group IDs (PGID) are masks of destination ports. * * For L2 forwarding, the switch performs 3 lookups in the PGID table for each @@ -1145,6 +1147,8 @@ int ocelot_port_set_mm(struct ocelot *ocelot, int port, struct netlink_ext_ack *extack); int ocelot_port_get_mm(struct ocelot *ocelot, int port, struct ethtool_mm_state *state); +int ocelot_port_mqprio(struct ocelot *ocelot, int port, + struct tc_mqprio_qopt_offload *mqprio); #if IS_ENABLED(CONFIG_BRIDGE_MRP) int ocelot_mrp_add(struct ocelot *ocelot, int port, From patchwork Mon Feb 20 12:23:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 59414 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1282133wrn; Mon, 20 Feb 2023 04:37:26 -0800 (PST) X-Google-Smtp-Source: AK7set+kOzRRsDhSIUZyhGXZ55n/o583g8HfeuOiFBYiX07RXzy6nJjbPJg+XyR5It4gAe3089oh X-Received: by 2002:a05:6a20:6d28:b0:c0:5903:d4cd with SMTP id fv40-20020a056a206d2800b000c05903d4cdmr183477pzb.50.1676896646149; Mon, 20 Feb 2023 04:37:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1676896646; cv=pass; d=google.com; s=arc-20160816; b=gQ++yNdgVoGT0q7lSG3zLaCoocnk1hSe7L/SvRk9KxvTbvO5ntEFBlubVJ80oSkwK7 9vdG1iqE6BFZvp0L+yafdWk2dSjS4rn1VQvmSJ+aRFdJyNVtZDbu9HwjsZgggutNihi2 sPahTDUWr097hb/ROtefRheUgm1H9bI4a+64mWUwFQpTUzPsD8Ai2YLS5xwLudouY+Gu 33b6yBYxjIgVSOBE1blLo1PblkfZCIM3PKGsrKsyftIRivrUXfOuQdAuxP/NE5ZuRQNY QzX88dgqei8zql6MkmORrt23xmE+9jzj5D/rjRD35BNFlnKJcG40x2Mb2lRF1AeQLRJF MKTA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=AKvejzi45NCPS+k3v7NmJ2nLVbtdy2DS1s3Bg0kzn9k=; b=amu1Sk7VsweT6rLUG6/APgqd2Pbyvt/kAU1hUfrQ5I9zgU8zia4GnF/lScAfqEaTtX MBOdqJUAzXnaNtdf1wOZ9LDQfyNPluviNPtL/H5fW7cX9px9pK2ThYr/rhHkQbtE2XAD 2FpHQBpgV4wcLfuTXSFG9WBw8O5Jzacne4XuloC0F7Gp3Xh2ZTVjnXimGWw+pzQKJSYo UpsihMi2FkV1SLgorNFSf6tb0ZG8AFvvPfZNpABmwPtCQgfib56ge9srkP0I+A9miQJN t+zYtjcjqcT0SMqRY/DUb4UqoRs2JKsHvNQb+LKTkDk6vT9KFNPxe4OJe3FBulbzuLUh JHWA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=rDTxC67b; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k62-20020a638441000000b004fc29a62bbbsi3613722pgd.229.2023.02.20.04.37.13; Mon, 20 Feb 2023 04:37:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=rDTxC67b; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232004AbjBTM0X (ORCPT + 99 others); Mon, 20 Feb 2023 07:26:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231891AbjBTM0V (ORCPT ); Mon, 20 Feb 2023 07:26:21 -0500 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2071.outbound.protection.outlook.com [40.107.15.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E61371C7F5; Mon, 20 Feb 2023 04:25:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nGyvwRQSshBftf26arAZ5LCEKhAnflHthqKv80MSCsdZc6IJAwKycDZaHFhpPC6zWfMbMhgJRHGVhzOSVKCj5ITzwzV1/yE7fbvDdGhIcM4KDG+GuDDH5n7vhdTj5SLM2x+7gL5LrZ1L8ihS+UT6oTzQXJ/qtRvEjpJLJm/zq6aLu6ttMyEosUaRRRcPCNDRNY/ie6Frjc12eOy2XLiM1pxj1aozJVjPFMfE+1qLtrByndUUa9idR6kxaSxKeoMWknLDMN8iuuacM3rZKTcfsHcavJWjrxinjI+Bc3ZUFSRQposGTfMccs+0F3QOB2uFarIE7eDj56IY7k7dEXkFWQ== 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=AKvejzi45NCPS+k3v7NmJ2nLVbtdy2DS1s3Bg0kzn9k=; b=nOr4xjohzoxhEaM3wXqYU5weMYiYEYtt2VbnmQUMVQjUoTJP8NwXJsLSAwRobBn9i1vxKtLM8szJnZNfkfoLJ+wMmbnPhxmy5ym++siGRAFxGh8kn/Sh3NgO4FAtAXuwo0+InoWLhPSUKGOBTMNGemnJe2mh5e2p64x3diS+w2RxuHicFFfrzyQ5m/dvPZZPWZflHKvrFYrD/VS99svxkfkOgGwqGQY8vXPKfFKaxS+an1TA2wKGeO2pCaHuVvo4v7lssKCAthMlSo03/boGGvbY3oF8Loy+w3QAcC8yFnkTOcAcsj1nh4a90sJ+ig7uTZKz+GnO0oMdbEb+b1sY0Q== 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=AKvejzi45NCPS+k3v7NmJ2nLVbtdy2DS1s3Bg0kzn9k=; b=rDTxC67bByUBHpixS1RdvqBpQKCa4SHRa0X/kj4fqqKHv6nE1b76fm61mKmZOI14wh2M1wUYxP1fQOpN87M55kUzfNG8cLwYbNakvZijrmmBBgvW6jWNCBhnV6SDWF68sdTVVcatt1luyzxqS5NA0OyIdoIl8uAyTpU8rvYdD1g= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by PA4PR04MB7725.eurprd04.prod.outlook.com (2603:10a6:102:f1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.19; Mon, 20 Feb 2023 12:24:22 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6111.019; Mon, 20 Feb 2023 12:24:22 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vinicius Costa Gomes , Kurt Kanzenbach , Gerhard Engleder , Amritha Nambiar , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , Florian Fainelli , Ferenc Fejes , Xiaoliang Yang , Roger Quadros , Pranavi Somisetty , Harini Katakam , Giuseppe Cavallaro , Alexandre Torgue , Michael Sit Wei Hong , Mohammad Athari Bin Ismail , Jacob Keller , linux-kernel@vger.kernel.org, Ferenc Fejes Subject: [PATCH v3 net-next 11/13] net: dsa: felix: act upon the mqprio qopt in taprio offload Date: Mon, 20 Feb 2023 14:23:41 +0200 Message-Id: <20230220122343.1156614-12-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220122343.1156614-1-vladimir.oltean@nxp.com> References: <20230220122343.1156614-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0183.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:8d::17) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PA4PR04MB7725:EE_ X-MS-Office365-Filtering-Correlation-Id: aaae7c8e-bd60-4915-5aeb-08db133d659d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LDW6SBO4R/Kygz9kpEAG3KaXM15YwtSdP6iJtDjXCAwsCG4++Ge0/MPk4kTDVQbpWpxC5VOnR/oJZ7J7UzyFwEy2Qy6Nhoj5JVnqSRjf1cxN5ppHpfBjtsfqxPqKxWmpQ9fsSuMe+482ECeXcHNV2LzBfbcrot/mGKRvr6QOa/mv9W/qvWWTDRlV/FrbLeNPs9yJS9RWqf9mHeiwv4CGZKP7UAbf66lv0O3WyvUiA3VKrpBMymRK8teKfCzt/2IX6n5a/DJUXWsZPoBqXUfnIvP6Kgf+yZpm6RyKWdGBirUJb70L8faDwGJHnevYLaRRyj6myqJybqrKB3eY/RscnKpyneGaTyED1T3YbZzfAH+d6F/OraYDYOAYff2611nuDTjyxWsgVQPpUnWWpN1xXk1dc7qmu+cGmPTD+76zFNMBKmmYJGk5nJaYwKsJnloi4hVUv275w0ymTfwcCZCnFiBr7a+X6uUgPKRxql52Fl8YaXs/2hNtj0m7OUytDWFWujCyN+G5Cfe20S+gQvymkHk1/Fd1AHlOMZK5nc4ovhPAsvB90CjyPGPPXKFzdHC141Nz+X6Kf40mDcSeRA4T2gkcrsdsGHBPqc+x9XR0oWQoEsA7B9yGTif5f/K2afHMrLWwrKfqrr06DlELGxyoM5yUipmPPsHraqgtB/QSU8SvuUezFAh5LTA5CqooLmcvNRQz7wgJxOL7cDopdwsX+w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(366004)(346002)(39860400002)(136003)(376002)(396003)(451199018)(8676002)(6916009)(4326008)(66556008)(316002)(6486002)(66476007)(54906003)(66946007)(7416002)(52116002)(8936002)(5660300002)(41300700001)(86362001)(36756003)(478600001)(38100700002)(1076003)(38350700002)(6506007)(26005)(186003)(6512007)(6666004)(2616005)(2906002)(44832011)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IYMpHMq+ZePdPm286/QghewWW2csSqBipGQrUXYXYaBcDVSA215HYLay0gxW59hN5ZXUCNxXOFV42yoWuDoX6viwyO/S1ueH7k2jOgbEPa3wtxbAJwjwY5LFFmpHg23e8A9furnPEiddWbVouUWA5rdDoLUUnCTr0eYwjepFtwBSbHypYlTnV+eGmmafW0p5HKoZ1ZnwgKbV5EcOw9w2j/5cY9fZWtiBW4imVOtsRttbx+DTIWe0sKWz4jAbLqoeNwWPSOnosnNw0vuJ79US6x1wG2o5wJ0F71bYDM2MqHK0i0e5uSX05l9ddeee90IqEaF04s6FFlz/fRLJUb0IFy7Y/WA48j3uBbflXJsfqlq4bMzQ5gb08ZlePNP1LCBI++5y8dbUXmZPU3OMtZunTqke21ctXmNgmcsjBdcBtToP0ShuqRMYcM1zVkOJGagwjfXg6sXOCAjC+JYuhHnJDBwECycRIrLC36VfmIBYGiQR/SKcb7aphD8qAuT4taWTSqxLpwJCEWmoyJ8rzkdAtSiJiIZ2Te0I2lVwKw8k6sFFOCtg4v2GMGmgwt5MCO5yxGaRpmycTAI0+2iPsD1kQwWS9GuY/oWSKROfOkuK0/3S9ap2zwa/TlYvYf9cALicyQT8oxVZvHWywGmZCO7wtJEZYfiWfQJrEjWQlR8oCXCeuQh6R/7396/HLCXrr4JEKE0z1ELWqIHz+McPboyJNazS5BcBqh4zMpSS/0bHPd2LjEbIE6SkNHf1d7uKinditWtX+UyNvr1KvRv1I1QLCB7NBfTVQnpIKuL69dJuEp6r+OlesgP2BjDdpO8eF0ozcbNHIs6QS8/oHfU4CzKPU/9uwnlarHX1zZsV+XT8ILhmpPqZ25uSdXydoW1kPJx+sxOAePSiaplklj0C/EFIy3Uq17webFIoDIlITqo3oKhcj8FLx806gke9EQuDUNdelb9mBEzmWvJtUU3EAevsa/NDezLn1h0kcZOt6UqIDG9CoHmGoRa1zcVdLdu7hw5SuT4w/Vj7ZKG0RWHWfa5OzwOp29AFpYl+wQmNRDw9JPzxwlmj5Tb/qTI5NK14P2AMWLS+WX/Q/IRiOHhaEKU+z4W7nfQhL18hdzQ2nP575ZzZ8H/uKqSYi20llA52UqcqkDk8rYWpKCu9r41YT1OoOfmf9fObdAis3Lrrc6NV4bnZj1fDRVJm5gzGXkhSOdXUWJedMtEWuljHGUVrRIIpcj/9jQYAJhf1ZvQilNQuGcJP3XaGzkign1tRXEC7krdwmjT2Y0fMIwphJOL9LKSBpuYOr3ESjirtueh3Tv9IqRcVv4VaVLzfaICEx2WVhbMWjcZ7wFAzBNeFciItY76sDXd74dygxCdPVMqf4ef3zJ+BT0GvCJyMQnJGInY6iN1uuT3xR3d3Nzd95b0uXtlb7HJ4V0rbGkdNFogxnPZIpL5rN+SmynrRzwKGFDXgmW49O+BKBV1FV8lRBLaSKc62WJnl+JFh8dyNrjVDMMqdhuEBOez7bj8BHmnDkP0nZjUQPNwfw6k3I1ujj2cVUYLZyU5lMyP2zPq0M5dQG6ans7uY6ZzJXmfpBOriirKtRZQkPNcRnocbLNHpC2/sJUnLGA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: aaae7c8e-bd60-4915-5aeb-08db133d659d X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2023 12:24:22.4301 (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: IBQIkzPYnVCjfFHDr+Bk9++OzqDxn5pazPWt4zn3YHVN6McZXbm7MMVBRlngx0vcHbjcUUYYkOG7cmRsWSAkeQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7725 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_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758353577518193294?= X-GMAIL-MSGID: =?utf-8?q?1758353577518193294?= The mqprio queue configuration can appear either through TC_SETUP_QDISC_MQPRIO or through TC_SETUP_QDISC_TAPRIO. Make sure both are treated in the same way. Code does nothing new for now (except for rejecting multiple TXQs per TC, which is a useless concept with DSA switches). Signed-off-by: Vladimir Oltean Reviewed-by: Ferenc Fejes --- v2->v3: slightly reword commit message v1->v2: none drivers/net/dsa/ocelot/felix_vsc9959.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c index 3df71444dde1..81fcdccacd8b 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -1424,6 +1424,7 @@ static int vsc9959_qos_port_tas_set(struct ocelot *ocelot, int port, mutex_lock(&ocelot->tas_lock); if (!taprio->enable) { + ocelot_port_mqprio(ocelot, port, &taprio->mqprio); ocelot_rmw_rix(ocelot, 0, QSYS_TAG_CONFIG_ENABLE, QSYS_TAG_CONFIG, port); @@ -1436,15 +1437,19 @@ static int vsc9959_qos_port_tas_set(struct ocelot *ocelot, int port, return 0; } + ret = ocelot_port_mqprio(ocelot, port, &taprio->mqprio); + if (ret) + goto err_unlock; + if (taprio->cycle_time > NSEC_PER_SEC || taprio->cycle_time_extension >= NSEC_PER_SEC) { ret = -EINVAL; - goto err; + goto err_reset_tc; } if (taprio->num_entries > VSC9959_TAS_GCL_ENTRY_MAX) { ret = -ERANGE; - goto err; + goto err_reset_tc; } /* Enable guard band. The switch will schedule frames without taking @@ -1468,7 +1473,7 @@ static int vsc9959_qos_port_tas_set(struct ocelot *ocelot, int port, val = ocelot_read(ocelot, QSYS_PARAM_STATUS_REG_8); if (val & QSYS_PARAM_STATUS_REG_8_CONFIG_PENDING) { ret = -EBUSY; - goto err; + goto err_reset_tc; } ocelot_rmw_rix(ocelot, @@ -1503,12 +1508,19 @@ static int vsc9959_qos_port_tas_set(struct ocelot *ocelot, int port, !(val & QSYS_TAS_PARAM_CFG_CTRL_CONFIG_CHANGE), 10, 100000); if (ret) - goto err; + goto err_reset_tc; ocelot_port->taprio = taprio_offload_get(taprio); vsc9959_tas_guard_bands_update(ocelot, port); -err: + mutex_unlock(&ocelot->tas_lock); + + return 0; + +err_reset_tc: + taprio->mqprio.qopt.num_tc = 0; + ocelot_port_mqprio(ocelot, port, &taprio->mqprio); +err_unlock: mutex_unlock(&ocelot->tas_lock); return ret; From patchwork Mon Feb 20 12:23:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 59421 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1284788wrn; Mon, 20 Feb 2023 04:43:20 -0800 (PST) X-Google-Smtp-Source: AK7set+OKenH6v8hnP70Fn1TP18g6yKBWtSXx17HSHEGxWOCxf0/i2uMHZwJIp1Ra70RSFirWkbp X-Received: by 2002:a17:90b:1d07:b0:234:2c8b:6db5 with SMTP id on7-20020a17090b1d0700b002342c8b6db5mr2256581pjb.40.1676896999884; Mon, 20 Feb 2023 04:43:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1676896999; cv=pass; d=google.com; s=arc-20160816; b=rzwqW0+5lXAO2qiaFRxFFRQUeCk5uoNO3qpLwLNYo/jo+zYVM6vPvmyRs2R7XVRNv5 mHxCa01ljdiAV1uMkuUl24U5LqYj1gaW255+uVHGNoq5G9A331sAXcvXPVphB8sn6Wu8 RPLJwgaTZARcuyvatbRs3Y2pvF9BEib6ychM+4ln8uUdTN4GAko7/CMXbCzoemMOklmF n6SPxw8QZxn4PjuX2YGqeZmoUDrgzz/gao0/XObMhD8m4Ir7Xkq2YjpJlPTLIPbKS/G2 2HsqlVmT412VG0ew46VWpuj7hL8lMuXvN44d60DeL4moa5cijIC38fGDc8YKgegQBxI+ cjsw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LJJHpv+/7xNv6dxt2WGU34vlzBhJxDWViEn0or0+cLo=; b=hgwjpLrRReyfJCb78VjIvuogO2qsTrt4sB4oCJ0mWdQqX+74zOyp6O3Oxe/4WzQAtS 0L4JuEFJNqO8uGOoviw/NxaUQG7ufBLRpNcaTvZuOQk11fE0XGwmxSrLKRKpzWlwzWVF jk5obASXWKuj/l1ZVqH3mJXgMhmp0C6Qr1V+g1FPjx6OaNMllWv7IbNV8icORei/YfZF LR2Z6ZIQ3Ik1R4/9rNRhxMAN9bvrQsq/gvmbBVvAonSWjdtht2isG9sfd+Hd9ePQSvKj kcdt0FiC8eBpLW0GSv9kNZJKmtFc/SeWXfseXjzkRFlUZPAKWaDYkv8kfQsQ3pIwKv+i ZRFg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b="KIJERY/J"; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p12-20020a17090a2d8c00b0023312fad927si1210523pjd.100.2023.02.20.04.43.07; Mon, 20 Feb 2023 04:43:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b="KIJERY/J"; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232048AbjBTM00 (ORCPT + 99 others); Mon, 20 Feb 2023 07:26:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231787AbjBTM0W (ORCPT ); Mon, 20 Feb 2023 07:26:22 -0500 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2054.outbound.protection.outlook.com [40.107.15.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E39B1C7FC; Mon, 20 Feb 2023 04:25:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Blm7fxeen+Jem2kF6Wxrrn8vuWyi71fETcUKSfj5D+KIgnUk+bcVwVQBlb9hcoVU71eOJLfMDFpIaL+EuqSTbJe2f9jIGXqfnPSe+lhsL21mSNUVJgytEG1E66dZBO/lXPk8+eesuj9b8q3ldC3q4vpfMQ1JhT39a+M2Y97vB7/Q+ZIWxzq1Fm2mdUG2O8ZH4wtSDKhoktr/tCj/zw0aor7eHzxblgfrj3XcZ89vZKR0MwK0wVOjKEbEekGjc1NISerNJiMdalKJstM7YiaPcUU0Za814wjwj/mHafPXCkHVbnceLs9oo2Jm4qTGwbO1M8YUmq3vLWkyARaCynnzqA== 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=LJJHpv+/7xNv6dxt2WGU34vlzBhJxDWViEn0or0+cLo=; b=LO3kcEtQypCw9rVjP6hVf1QiihGqyHPKujUmceAxT2BocDizrZkcd43nr4d6IIpED9hozTNH0K77UBh+9SnrCMjpR6wgC5gcc9noVGc/ECCDEpNdoolgcH4L2JkNmxqA5QWF55seKXYQbA8aMLA3c0nf9OVT53cxQWU/JjRZeZSjAiYATkVzjdnfzxf0PZSPqSjNAk4avqv2Lqzw+wlLYCaU+0fiy01z7MID6Ah35teLfe5peC3AP5i/eBEG4RMDB2GQ0U3kyNnLKro8HYEm1VD+0utQC5YcYXwzKW/3yiYre5KoaGDvTZFsLFzGlnMhpQxZAgnscUCzgd31uG7h7w== 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=LJJHpv+/7xNv6dxt2WGU34vlzBhJxDWViEn0or0+cLo=; b=KIJERY/JgUPqlg24KZVReOOMckQOBVpot0E53fR2Yu4vtqG9jpIWZhlrOEH+DrqTzXU6nz825w8abxXXY5lRo9htOCe7n0a+8wyC/2LeMosbCRoIGqoegz/NaQhjRLtMovgAwXGAvu/1cTlhA+oOqNfTlKVp9L2pA/WmNZE3RkA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by PA4PR04MB7725.eurprd04.prod.outlook.com (2603:10a6:102:f1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.19; Mon, 20 Feb 2023 12:24:24 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6111.019; Mon, 20 Feb 2023 12:24:24 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vinicius Costa Gomes , Kurt Kanzenbach , Gerhard Engleder , Amritha Nambiar , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , Florian Fainelli , Ferenc Fejes , Xiaoliang Yang , Roger Quadros , Pranavi Somisetty , Harini Katakam , Giuseppe Cavallaro , Alexandre Torgue , Michael Sit Wei Hong , Mohammad Athari Bin Ismail , Jacob Keller , linux-kernel@vger.kernel.org Subject: [PATCH v3 net-next 12/13] net: mscc: ocelot: add support for preemptible traffic classes Date: Mon, 20 Feb 2023 14:23:42 +0200 Message-Id: <20230220122343.1156614-13-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220122343.1156614-1-vladimir.oltean@nxp.com> References: <20230220122343.1156614-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0183.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:8d::17) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PA4PR04MB7725:EE_ X-MS-Office365-Filtering-Correlation-Id: 206d8fd2-09a5-47ca-92fe-08db133d6700 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hVNfeLFXtvnYV47PG2wG9gfE5Yg9WTDAEw4OdveqSRyVjTrYvYlj+eB+oSx08BQGrsAxyZT7DBQNuTGqQ8JetUIObkONmy9IUSIkJ2RuhWexIi6rfOeprY9lwIblxs9FUOGo8DtjsPV6rLBnART6j3/VEYREZaXumIBnJpuJMhPT20X7uG6IXjRXE6T8F/EMUM+LSkZSPhl2LkNItHsQgGngXCG3806X5AALiF47AMGMbdG79Dze8+aNtPeswVY4V4N+WWKeeaWQ0T6DxNiRHo1ylUeOCjA2ldRD098oqfEYYmB+ULwGyE1kZ+a+PKTmQ1be8CgyrmJ5Y3oKfJDruNRZ0zXLU6nNbXri37dX7NjNSayJBylvl1Nros0792h+RAloEM0RUB0NYOQpWgZnnC4iXlAoU546VdIhVJVpnf90Ka9C5DA7UKXCr6ld3IiIUKkz3qR/INr5eM8Jh34RZPGVmZTDZBCjUiy4hi/AE3sUK1nR7CFYFgNizpjy+HYA45pzX+6YfcWHEjbGDCWORHW37nDEKCUjRYMVVgpXMZKDAaY/lincn+E6rNCX3YRKSSBY8hDX6VpKpM2zI4v0thzEOTmxVyrj/AGo0M14WHIGWXAJ5jdijDoLPn0JqO2K1lCaaJTyNKKwCBdwu0mnYhu2tYNINAdpQjg/MbNAcfsUDRzaZzkW70fwOMfJ0uiy82/lSQTls6kuy36ctA1S0Q== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(366004)(346002)(39860400002)(136003)(376002)(396003)(451199018)(8676002)(6916009)(4326008)(66556008)(316002)(6486002)(66476007)(54906003)(66946007)(7416002)(52116002)(8936002)(5660300002)(41300700001)(86362001)(36756003)(478600001)(38100700002)(1076003)(38350700002)(6506007)(26005)(186003)(6512007)(6666004)(2616005)(2906002)(44832011)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: n++sqc9eSpHzi5vg6agry+shjCjnjQGi+y5Xv3FP8UxklURwcUJ/PCh3k0kNK3mI9fjE4Yptv71RKbEDquUxtSULbLQ7jB1y7IZnrsaOhNZMCjzrF0fmFbIvz3PiDlfZQFpC7y+w5ptDyGuqnqD0NcJQT4QzmzcKaDoLPj44byyCPUGa+L+sFsWafmbVJ6adLeiHi6tfZJs2eMaIp8lTtiB6erMCcPmxXYKgrSNcm1nqtyYkw5kBlstP1W7IdDIvX6g7RBcRiwT2O8SoTkFJNZstYaChF0rPoi4/xeCW91n7rcGziwH81otexfqKBZBaiefWcyUAGgsi/tdYYf+34l3PV5CJZC3HiqNXDxoRmG5KG2PtnKoT7yISGWGGS4/4cdw5Tt0JiGyed4SXYQxQgfnEWfxbVB7h18jhE6vRewHwKFdA6Xk60arL1gHZFFOOjvNXXs4+2XFzaq+0fW7vmP6PiDYiodT/LvoUHethy9K+DQK7wAeQSvDXuL74XFCLtzd4go711zSR5kwj9OqpAZ+2BmT+XE0zHbKqWyx5Mpjv+wvwFTbjnZNvAD2/ibNecoJF1OEpERg8Igr602gdd8tgv7j8qy2ALmbryWq6deuIqrcer+Tagt9idrZkxukkxYHwr/fBArb9LKil6XiYMIW3dYXOcIyHq2Wo9OQO7oex6bYn6TZnGkv3RNQNjnxfiFDRMfS60MnQ+3i4kMgbGuuNzmr3c7ccseRMnwf0ZxAkYhBf8ij/Jgl44z757L0c6MN79eH8SDU9DKE1MJU7101hNLy2AczynTDmi7+n8QOcjo3PPtIGkJIrntqZqR9u0q+odKLc3Sof1ea7YSD90FGb7vnZBMrxLtkUadjx4mX0OnSDVqwvQhgrovZFZjOegBVN6C3rUlc/Ey7X2wdxKHytPpzQKrgOy7gN3If7J3S/ZB7kCeCNhJH8XDiRrPYX9dbCYm1ONeZRKNazW8grJdwnRQcdt95KMpaQckl8/BqF9pvHKQQEtY/kOvgvKbrDjNz94VpuDFmJn/xunbPxt+RvgZ5oXX1oO2Y5ODvhw7O3diJ9bSx7bRuOb6Mwk/PYuo0hRV0E0YYvimTM64FGDh8b0tG3qtqbT6yrvC/nUy+Zh81dFQhI4ZFtlSjEce/dsJuTbOXn+5VbndVQj05lFWndbO1Qj9RKVodcMTdXV7DbtH4sedzJpFqQuixox7gADrEaCa6VGWKeqyqA3RHwkG8UMw8ez1u7cmfMiXLvNnuG9+9Yup7O4tHnCOuPtgyXVfT0JkGlGzJCEvorynRnSd+QL2y8eiNEDaaDXn4UCucsv9BEUFueRRtAx3XrDZgeCMTT/tH4LPNBURa5YLJdsH+UkbHM08B4809Sjxk2jGJUUPk/QYkOgGU9AQwA+TeJ/cLzbwo1cM0tTPLy2rPBV5hEjUYiHYEwwofEIsIAj+VoTXwXhBDusL5kIiBXSyT7vFkjsnV5dImstQrn6wnoAzAJyCm0rraC9DBGDCzqlcvYIe1tmzORMFcq5U0pYMqStfrIUWAnh4mf1/KY7gUfpbJxJFkbLNHKr2gJ2yLUyfyNLqlsMCOK21IZb8kmVpYGCuF1ir6LBkdWyrkPRDdKEg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 206d8fd2-09a5-47ca-92fe-08db133d6700 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2023 12:24:24.7268 (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: QkY+hxGMGqKkQLbxkKhDn8WnPnc1RIz3JjW1qh8nNhs3V5LtymXPFZSiro3NbYaRx/zPWxBNO3tKnX/xUbFOWw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7725 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_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758353948411877938?= X-GMAIL-MSGID: =?utf-8?q?1758353948411877938?= In order to not transmit (preemptible) frames which will be received by the link partner as corrupted (because it doesn't support FP), the hardware requires the driver to program the QSYS_PREEMPTION_CFG_P_QUEUES register only after the MAC Merge layer becomes active (verification succeeds, or was disabled). There are some cases when FP is known (through experimentation) to be broken. Give priority to FP over cut-through switching, and disable FP for known broken link modes. Signed-off-by: Vladimir Oltean --- v2->v3: fix build error caused by "default" switch case with no code v1->v2: none drivers/net/dsa/ocelot/felix_vsc9959.c | 13 ++++++- drivers/net/ethernet/mscc/ocelot.c | 3 ++ drivers/net/ethernet/mscc/ocelot.h | 2 + drivers/net/ethernet/mscc/ocelot_mm.c | 52 ++++++++++++++++++++++++++ include/soc/mscc/ocelot.h | 2 + 5 files changed, 70 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c index 81fcdccacd8b..c6a5cf57dcc6 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -1343,6 +1343,7 @@ static void vsc9959_sched_speed_set(struct ocelot *ocelot, int port, u32 speed) { struct ocelot_port *ocelot_port = ocelot->ports[port]; + struct ocelot_mm_state *mm = &ocelot->mm[port]; u8 tas_speed; switch (speed) { @@ -1374,6 +1375,11 @@ static void vsc9959_sched_speed_set(struct ocelot *ocelot, int port, vsc9959_tas_guard_bands_update(ocelot, port); mutex_unlock(&ocelot->tas_lock); + + /* Workaround for hardware bug */ + mutex_lock(&mm->lock); + ocelot_port_update_preemptible_tcs(ocelot, port); + mutex_unlock(&mm->lock); } static void vsc9959_new_base_time(struct ocelot *ocelot, ktime_t base_time, @@ -2519,6 +2525,7 @@ static void vsc9959_cut_through_fwd(struct ocelot *ocelot) for (port = 0; port < ocelot->num_phys_ports; port++) { struct ocelot_port *ocelot_port = ocelot->ports[port]; + struct ocelot_mm_state *mm = &ocelot->mm[port]; int min_speed = ocelot_port->speed; unsigned long mask = 0; u32 tmp, val = 0; @@ -2559,10 +2566,12 @@ static void vsc9959_cut_through_fwd(struct ocelot *ocelot) /* Enable cut-through forwarding for all traffic classes that * don't have oversized dropping enabled, since this check is - * bypassed in cut-through mode. + * bypassed in cut-through mode. Also exclude preemptible + * traffic classes, since these would hang the port for some + * reason, if sent as cut-through. */ if (ocelot_port->speed == min_speed) { - val = GENMASK(7, 0); + val = GENMASK(7, 0) & ~mm->preemptible_tcs; for (tc = 0; tc < OCELOT_NUM_TC; tc++) if (vsc9959_port_qmaxsdu_get(ocelot, port, tc)) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 8227d2027c94..b53fbeb6bf4a 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -2608,6 +2608,7 @@ static void ocelot_port_reset_mqprio(struct ocelot *ocelot, int port) struct net_device *dev = ocelot->ops->port_to_netdev(ocelot, port); netdev_reset_tc(dev); + ocelot_port_update_fp(ocelot, port, 0); } int ocelot_port_mqprio(struct ocelot *ocelot, int port, @@ -2644,6 +2645,8 @@ int ocelot_port_mqprio(struct ocelot *ocelot, int port, if (err) goto err_reset_tc; + ocelot_port_update_fp(ocelot, port, mqprio->preemptible_tcs); + return 0; err_reset_tc: diff --git a/drivers/net/ethernet/mscc/ocelot.h b/drivers/net/ethernet/mscc/ocelot.h index e9a0179448bf..fa9b69ba198c 100644 --- a/drivers/net/ethernet/mscc/ocelot.h +++ b/drivers/net/ethernet/mscc/ocelot.h @@ -110,6 +110,8 @@ int ocelot_stats_init(struct ocelot *ocelot); void ocelot_stats_deinit(struct ocelot *ocelot); int ocelot_mm_init(struct ocelot *ocelot); +void ocelot_port_update_fp(struct ocelot *ocelot, int port, + unsigned long preemptible_tcs); extern struct notifier_block ocelot_netdevice_nb; extern struct notifier_block ocelot_switchdev_nb; diff --git a/drivers/net/ethernet/mscc/ocelot_mm.c b/drivers/net/ethernet/mscc/ocelot_mm.c index 0a8f21ae23f0..f7766927bdd2 100644 --- a/drivers/net/ethernet/mscc/ocelot_mm.c +++ b/drivers/net/ethernet/mscc/ocelot_mm.c @@ -49,6 +49,57 @@ static enum ethtool_mm_verify_status ocelot_mm_verify_status(u32 val) } } +void ocelot_port_update_preemptible_tcs(struct ocelot *ocelot, int port) +{ + struct ocelot_port *ocelot_port = ocelot->ports[port]; + struct ocelot_mm_state *mm = &ocelot->mm[port]; + u32 val = 0; + + lockdep_assert_held(&mm->lock); + + /* Only commit preemptible TCs when MAC Merge is active. + * On NXP LS1028A, when using QSGMII, the port hangs if transmitting + * preemptible frames at any other link speed than gigabit, so avoid + * preemption at lower speeds in this PHY mode. + */ + if ((ocelot_port->phy_mode != PHY_INTERFACE_MODE_QSGMII || + ocelot_port->speed == SPEED_1000) && + (mm->verify_status == ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED || + mm->verify_status == ETHTOOL_MM_VERIFY_STATUS_DISABLED)) + val = mm->preemptible_tcs; + + ocelot_rmw_rix(ocelot, QSYS_PREEMPTION_CFG_P_QUEUES(val), + QSYS_PREEMPTION_CFG_P_QUEUES_M, + QSYS_PREEMPTION_CFG, port); +} +EXPORT_SYMBOL_GPL(ocelot_port_update_preemptible_tcs); + +void ocelot_port_update_fp(struct ocelot *ocelot, int port, + unsigned long preemptible_tcs) +{ + struct ocelot_mm_state *mm = &ocelot->mm[port]; + + mutex_lock(&mm->lock); + + if (mm->preemptible_tcs == preemptible_tcs) + goto out_unlock; + + mm->preemptible_tcs = preemptible_tcs; + + /* Cut through switching doesn't work for preemptible priorities, + * so disable it. + */ + mutex_lock(&ocelot->fwd_domain_lock); + ocelot->ops->cut_through_fwd(ocelot); + mutex_unlock(&ocelot->fwd_domain_lock); + + ocelot_port_update_preemptible_tcs(ocelot, port); + +out_unlock: + mutex_unlock(&mm->lock); +} +EXPORT_SYMBOL_GPL(ocelot_port_update_fp); + void ocelot_port_mm_irq(struct ocelot *ocelot, int port) { struct ocelot_port *ocelot_port = ocelot->ports[port]; @@ -66,6 +117,7 @@ void ocelot_port_mm_irq(struct ocelot *ocelot, int port) "Port %d MAC Merge verification state %s\n", port, mm_verify_state_to_string(verify_status)); mm->verify_status = verify_status; + ocelot_port_update_preemptible_tcs(ocelot, port); } if (val & DEV_MM_STAT_MM_STATUS_PRMPT_ACTIVE_STICKY) { diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index 27ff770a6c53..7ee7a29e7c51 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -748,6 +748,7 @@ struct ocelot_mm_state { struct mutex lock; enum ethtool_mm_verify_status verify_status; bool tx_active; + u8 preemptible_tcs; }; struct ocelot_port; @@ -1149,6 +1150,7 @@ int ocelot_port_get_mm(struct ocelot *ocelot, int port, struct ethtool_mm_state *state); int ocelot_port_mqprio(struct ocelot *ocelot, int port, struct tc_mqprio_qopt_offload *mqprio); +void ocelot_port_update_preemptible_tcs(struct ocelot *ocelot, int port); #if IS_ENABLED(CONFIG_BRIDGE_MRP) int ocelot_mrp_add(struct ocelot *ocelot, int port, From patchwork Mon Feb 20 12:23:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 59417 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1283546wrn; Mon, 20 Feb 2023 04:40:20 -0800 (PST) X-Google-Smtp-Source: AK7set+Yf9wg484ShrlTsQ0nE0oF6mmaA2OqOSdeJFT9IvhHYOMY5rqFJDMvmPbf5s9zUJu6R6TE X-Received: by 2002:a17:903:187:b0:196:5d8d:2d6f with SMTP id z7-20020a170903018700b001965d8d2d6fmr3544386plg.13.1676896820636; Mon, 20 Feb 2023 04:40:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1676896820; cv=pass; d=google.com; s=arc-20160816; b=lBIUSGSpgdHooZdbDd5jWvmibS0+UzP3lrik3+wxnHRQ4Un7RObdlI9X5M5Dv2XB6B iYsx2cLjdbigq9PDdWxsOQX63ui/PtnClVIL/TtPcCq5Poh8VtNxFQNJT4qnkWhyjRFD dIUm+RBOOvTdffRCPl5fxGzwoTro6w6yd1oJYDnNhehfC30qFWCgc5OFNyU9OZHMh2z2 smiDYhWiHSzkyknsWBFHOUC8NLHRWV4ZjlPkQt8KtZ0f8zvd09SnwLYvkbH6BrDvWkm+ XOttOthbKNgOgeRtSXdy3E6bk3+F5ckKQHokbhh3uuBxjVaHFJeAbEs2A4WQAGQbGhyY sQ6w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+LAxh0ndzKgSmev7VvnyhN4M8QLpSBeUVLWwrsOu23I=; b=Sl9Z9aL8ZtTp47AQXyLXYCdYoKsCO7rm1y0wG77SHF9itDk8eszIPLOywm1TVkpcyh dzvS1oxAwMGBpLLfzNzKM+U7fFDBYNvrsFVqS2BbTrdM+ofdEltPWbzPOwyma58gO1mC dACh6+tWbILIk0BYkWCk8MQst1Gz2VmuTT5ublZwuZQ6nisd/5YarodxfqHgB2thb+Hw Ub1t2wNXPgHVtuPKzRkplzjTjdrXbuan1sXUfe0J5945GWMSo8sRzKJNwQj7vJQgr4Ef pzmI6CEQH9nmaj5tVlJz/1Agr5k9uWdOFvAeaA+FatH3UIPe01tPqvhgHXX822oENwNA ARqA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=k2dPio+f; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q16-20020a170902dad000b001991d6f3cadsi3912352plx.206.2023.02.20.04.40.07; Mon, 20 Feb 2023 04:40:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=k2dPio+f; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231925AbjBTM3R (ORCPT + 99 others); Mon, 20 Feb 2023 07:29:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231820AbjBTM3P (ORCPT ); Mon, 20 Feb 2023 07:29:15 -0500 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on062d.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe02::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C26C91C5AA; Mon, 20 Feb 2023 04:28:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iLceoOUCpdBOPdPXO6M/eZ0Tv/8enoosumyaNKu0PbkmcaSmedpfE3OABaZ3BhWOZ3gpu7SOQNaHEuADXPsiqnabx9R64GsmG2UA1H4Iu9sI12xsTioY08D51+Ydxi18cR3DfzShVYP550i9sA+19916SKLy4QR4pZ+brdy7Y4Vq/M0jRonSATyxozPMcPO2JIsVKa2w67nl8wvMEsXhg6nygbtVzYt4Tagkev+jw09gL0CVfnsphlCkICsfT3KP+xUViM7AXViJcKkK7SWs6ok9HjqzoTVlqbVPcsaAUOoK9S+j+KB15xcVQ6Jea3/j8yXg58Ag1fH26Pv9d0khnQ== 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=+LAxh0ndzKgSmev7VvnyhN4M8QLpSBeUVLWwrsOu23I=; b=bk7iGEVMGEiV1MBTMAblX/eM4O8R5YFdfuizOlk/aIb05VoB8b8YcGO0ckS+5GfTtfTxvnG4r8UgiiiPYRwkNKzBKjmux5OQPe2dkN2KSsoSXW5V6i4c93AiPka5vVRYpNFxarEe7xezCCyUn4MjX4JnL8m+SUfqoqhDG0DMCXaCyueo+E4PqGzuXrf0WQ/7J2h+xED8Bi9DjLkgsmzYV/XOJMTt4OxnZrHXG1OKXQkUtpTpzfSfcuBBeMylkrmDE9gLRvRBAa7lLHU/w3wPX3+wr3/uPm7NtateU1N8wfET4YROcvyVUIDF3WC4H5t2jbZ4eSZR79LbiYpjA1u0DA== 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=+LAxh0ndzKgSmev7VvnyhN4M8QLpSBeUVLWwrsOu23I=; b=k2dPio+fBlVt0nBS+361grm5XASV3CP2MuFK6icX3LdPEYpl3EdZrikXKmmv9YeOIHFfg3v3uaiqXwWMNIZR4KgeaN0qffVcpmwBMQ5uQSeyZ/o2hCBCwyNiaujEUF9OR3eRX5slLBuJIxBmV9vRj/avlv7rj5U6qmDPUE08UmM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by PA4PR04MB7725.eurprd04.prod.outlook.com (2603:10a6:102:f1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.19; Mon, 20 Feb 2023 12:24:27 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%7]) with mapi id 15.20.6111.019; Mon, 20 Feb 2023 12:24:27 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Vinicius Costa Gomes , Kurt Kanzenbach , Gerhard Engleder , Amritha Nambiar , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , Florian Fainelli , Ferenc Fejes , Xiaoliang Yang , Roger Quadros , Pranavi Somisetty , Harini Katakam , Giuseppe Cavallaro , Alexandre Torgue , Michael Sit Wei Hong , Mohammad Athari Bin Ismail , Jacob Keller , linux-kernel@vger.kernel.org, Ferenc Fejes Subject: [PATCH v3 net-next 13/13] net: enetc: add support for preemptible traffic classes Date: Mon, 20 Feb 2023 14:23:43 +0200 Message-Id: <20230220122343.1156614-14-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220122343.1156614-1-vladimir.oltean@nxp.com> References: <20230220122343.1156614-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: BE1P281CA0183.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:8d::17) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|PA4PR04MB7725:EE_ X-MS-Office365-Filtering-Correlation-Id: 860b3c1e-4069-41ce-f1e3-08db133d686a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jM40lqdUZzbpwjqKvGJd6km3stxo0O36/TgC02oEbt5hyRFK+sV/vPKaoI4zghCsHBwR7ApUD76/HrzbEoRpCzlLgcblzuVpNa6Hl5KAxqm+/D1XKCZOrFE9rReGCXAX/MPABrK/fPP2AU6IgzwYk8yGE3E++raLWrPDTZ1eDw7G1QJhe1uVQaDS0EIhZdArHKVGPB/saCd1aWdmktH3jTeHeSUCet5imA6XxVOjM3XoqS1PUkhqRjYQA1Z69xOnPlaKIcN+RciCBt83UdY7+9CMMK4hyVYi8sHf/0eqJTeeidCcxkwaztKTnuN4ITYgD7Ctl784TDiCEWBrC/Dqk7Yj5cbOTS8D3hrWZBSHzqaMOXU9Bzs7KddPY4ZwLspZtKVhpANsVH+wkWTENF4YXkYNkd+Wr9CKdRUuKqiNiqW556G2rH6aAQThCDIMDgyqdDb2d0S55g876bQ0zNNHFE0RZ3eZzlch14rRVLUbHsU57vbQfZOEMdpRjK2drXfYYR+f1BiyEXrtOAyQ06pKxFeublLzxPj6a7rMPDASDovTz5mupRZ+wM90Ifpbl98USilhubdytSUC8WnPkdgO6XoIt7dP4D1MD2PVZX2ulqQWgZ19AunlYORPpM+MYMPZlVQwRc16mibbIe3XFZ5Zni7EIIepJbzHWWYsGdCrKjW6s0OK27Es7k9ntIrWlBILoHUDYe9P7HijIt6uYKGRrQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(366004)(346002)(39860400002)(136003)(376002)(396003)(451199018)(8676002)(6916009)(4326008)(66556008)(316002)(6486002)(66476007)(54906003)(66946007)(7416002)(52116002)(8936002)(5660300002)(41300700001)(86362001)(36756003)(478600001)(38100700002)(1076003)(38350700002)(6506007)(26005)(186003)(6512007)(6666004)(2616005)(2906002)(44832011)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BBfB9GcWa1SmDP3Fd9ldT+TJfSArfQLJh+Rq1J9MVz6snzzsm8owDDMRqFMH9emU9xj9QKC0bKmXo+EPrd7NUaKGb5dk52hlWlOo7Rt1ebkK3vRahZnG/f+ZNTsRXOSY0yXebKNwNAdLi/7imedtwJYKHBanzwlIstX8n8UkOhnSaJpa7vZ1GvdlCuMipluvGVmkJXaDD+F7wH6WHej/naODXuSbjpaOicxa+F0J1BuRmO/GPfQqWt1badNoXadtIE0Ya5lDYgwLtt1vXzgphqqmMqsVeowfFKL2jgdybZTyaN4aesxTcTQxVRmq3EpeJ1GUAhLYqcBn0jUvUPmrE0EXsQw8NhO14wbDYC7pYcCGug0Mbz3dNggZQxZ8gAGBmEhxcf0EGglI4kspQ805N8y+UPAZUCVen6N0puPWkBrKwFo304RiMjPub4yhZ3yvX6kXNyoROeEF6CelagCRMqyTQWYxBojSrcZ9x6oMiyzC0TArDitFGMLMXWukW4MkPWRU5Bse9/WmKtwaRH915ubbEh2iWrwUa4+E7Za1w9u2FF/MuENBIlPRVhjLVlePHmLLxQUJzb+ZBtDWEG5Zl2VZtkkvhakdlRk8USnZ9gc7+MiqNhT79we9Rvq/6JmpyskPxiL/R29StFaJ/oNtOd2HxOf4ifoqO7JeMJ9d0gIqZihjb0TrX4lhVD4ABaxZTN71AYM/0kISRL+nBXiqaDkmQVdRcxzT3eCx8IQ9Cz3JCPn+ya1TKa9KZRwHcpRkUYfLYLCtztQVbJxG6HQvrbrdlfbtEPpteHjX8aPSaPi3ExmDjNG9SYN3OIsrpm1M3M+dm8sZQqRnMRlBvrM/lUKotUd/nGjoAPouQUSXFoC4FPThPieIp/f/aMRw06Y6A1lvctkyRz/yVvZ3bnAivvvzc86XqfRzgJPfWmJdOYpJ/fEzJM5+XIoIKvBLUTXiPPHkZwZUUzL0Bve0CH2jv5dqutyPRIVyfFtAdXqlkBH4QZVhIvz82sWC/oA+zrTbrtmOoeHCMvFia/hXVJk6iOALxkXiGPBj5ISjpEM+iU8gAZhDOfzKsz71+WXWIgPeZcHOIoAFcghgeOzHlEwsET1hMZhBkapvtC/LKLSQfodneSoo+inPrZLtYppAin7Uy2JYIP4jJUemyKuo5zacY0VthUUxcQEXUsD2IDdpyCfZwr9C4S1GUrCC0g18J9ksBZ8CW4tkbHi1d0e9CkKaxlJvNB4wWCFdftCDlq6nsNSf2huqfrXDSZxQCPxjysYFc3uXkT3d2Bb2/AcFL83oD3Rv/VPHwg5uFNCG+xhpe/GxAJRN6/ZiuGxocqy3zp2tho2d27KdqtTUH2lnPxT0rYkBxInLXZt9KxKX72BT83vP2QfWJd0UZLmtcdTXdFNRXxaED9reqSiwwuQCFba5sEPgsvMYNTwCW/S7JS/r0/tKjB8/Wiwav3TWNvgLHGVGrUBph8OzAEp91JLzAV4Z075bGU5PSFiQWB5krWFE1D3BHQsyXrYmZP9rHcLKnQkKL9h2U5owMLeAVZmw9qVHFsda4wWg6oKLAQ5VBE0iAQJ2/fBg7FJXgF/aOaEYg+UZbMqtbhEFtEG/XvVsknJeaA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 860b3c1e-4069-41ce-f1e3-08db133d686a X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2023 12:24:27.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: 65xC9put//WGBywqFocEX1nVy/uAu0SWVUkgMqju41d2Hk/sm70Jc60K7sUbPp9J9vr8Ffsi1F33D3kOR/PZIQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7725 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO,SPF_HELO_PASS, T_SPF_PERMERROR autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758353760391284888?= X-GMAIL-MSGID: =?utf-8?q?1758353760391284888?= PFs which support the MAC Merge layer also have a set of 8 registers called "Port traffic class N frame preemption register (PTC0FPR - PTC7FPR)". Through these, a traffic class (group of TX rings of same dequeue priority) can be mapped to the eMAC or to the pMAC. There's nothing particularly spectacular here. We should probably only commit the preemptible TCs to hardware once the MAC Merge layer became active, but unlike Felix, we don't have an IRQ that notifies us of that. We'd have to sleep for up to verifyTime (127 ms) to wait for a resolution coming from the verification state machine; not only from the ndo_setup_tc() code path, but also from enetc_mm_link_state_update(). Since it's relatively complicated and has a relatively small benefit, I'm not doing it. Signed-off-by: Vladimir Oltean Reviewed-by: Ferenc Fejes --- v1->v3: none drivers/net/ethernet/freescale/enetc/enetc.c | 22 +++++++++++++++++++ drivers/net/ethernet/freescale/enetc/enetc.h | 1 + .../net/ethernet/freescale/enetc/enetc_hw.h | 4 ++++ 3 files changed, 27 insertions(+) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index e0207b01ddd6..41c194c1672d 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -25,6 +25,24 @@ void enetc_port_mac_wr(struct enetc_si *si, u32 reg, u32 val) } EXPORT_SYMBOL_GPL(enetc_port_mac_wr); +void enetc_set_ptcfpr(struct enetc_hw *hw, unsigned long preemptible_tcs) +{ + u32 val; + int tc; + + for (tc = 0; tc < 8; tc++) { + val = enetc_port_rd(hw, ENETC_PTCFPR(tc)); + + if (preemptible_tcs & BIT(tc)) + val |= ENETC_PTCFPR_FPE; + else + val &= ~ENETC_PTCFPR_FPE; + + enetc_port_wr(hw, ENETC_PTCFPR(tc), val); + } +} +EXPORT_SYMBOL_GPL(enetc_set_ptcfpr); + static int enetc_num_stack_tx_queues(struct enetc_ndev_priv *priv) { int num_tx_rings = priv->num_tx_rings; @@ -2640,6 +2658,8 @@ static void enetc_reset_tc_mqprio(struct net_device *ndev) } enetc_debug_tx_ring_prios(priv); + + enetc_set_ptcfpr(hw, 0); } int enetc_setup_tc_mqprio(struct net_device *ndev, void *type_data) @@ -2694,6 +2714,8 @@ int enetc_setup_tc_mqprio(struct net_device *ndev, void *type_data) enetc_debug_tx_ring_prios(priv); + enetc_set_ptcfpr(hw, mqprio->preemptible_tcs); + return 0; err_reset_tc: diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h index 8010f31cd10d..143078a9ef16 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h @@ -486,6 +486,7 @@ static inline void enetc_cbd_free_data_mem(struct enetc_si *si, int size, void enetc_reset_ptcmsdur(struct enetc_hw *hw); void enetc_set_ptcmsdur(struct enetc_hw *hw, u32 *queue_max_sdu); +void enetc_set_ptcfpr(struct enetc_hw *hw, unsigned long preemptible_tcs); #ifdef CONFIG_FSL_ENETC_QOS int enetc_qos_query_caps(struct net_device *ndev, void *type_data); diff --git a/drivers/net/ethernet/freescale/enetc/enetc_hw.h b/drivers/net/ethernet/freescale/enetc/enetc_hw.h index de2e0ee8cdcb..36bb2d6d5658 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_hw.h +++ b/drivers/net/ethernet/freescale/enetc/enetc_hw.h @@ -965,6 +965,10 @@ static inline u32 enetc_usecs_to_cycles(u32 usecs) return (u32)div_u64(usecs * ENETC_CLK, 1000000ULL); } +/* Port traffic class frame preemption register */ +#define ENETC_PTCFPR(n) (0x1910 + (n) * 4) /* n = [0 ..7] */ +#define ENETC_PTCFPR_FPE BIT(31) + /* port time gating control register */ #define ENETC_PTGCR 0x11a00 #define ENETC_PTGCR_TGE BIT(31)