From patchwork Wed Feb 15 22:46:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 57758 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp462918wrn; Wed, 15 Feb 2023 14:57:42 -0800 (PST) X-Google-Smtp-Source: AK7set85dQcWWHS1kpfx54PmYOIR7dxtO9CPJk/x2y+LPlBK9hZyQ4Q6ARz55owxOTtt+AHNGE9f X-Received: by 2002:a17:906:cec3:b0:8ae:30bb:a12c with SMTP id si3-20020a170906cec300b008ae30bba12cmr4031648ejb.28.1676501862790; Wed, 15 Feb 2023 14:57:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1676501862; cv=pass; d=google.com; s=arc-20160816; b=uSM2gRIwTLPeBgf8u9DpDM9Ug007jwVFsMPXf/rEgmo5Aoa2iCInp7Zx+TCKsJuspn 9E73i3JNxL1uvprkh/43g4rv8IiPGmF0rOlpnDTt68rWulR9bbmC9uM1x6y/ZM6igltl wHPbeuQTGovvnHOvLsG1ArfnuZqiNzV0828SFMURwacGTWc+dhflWsZ8rP8UtOoKUPPC xpMzjCk68ATQTbidwY5+UuVeDhkNbN+ozhh3mYnG+w9CiC6X7/zt8tChmvIQLnglQMyh A2eM9IhvEj6ckMjwaCoXKpwwbB1YIje1uufxzeJrXSFfp4sfEqx8UEFmO4b6FuwpdK4O N0Aw== 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=OcfqCb+n5sNTVWdr3UHmaLjGSkxj7vmXWvMcpPgUSrs=; b=y+GAN8mlS2JlzA6lmFaxJofantN36swqe+E4rwwCJmFKfv1bEaIzM2k24KQ7JT6+Cr APYQX7IlA5zeKJUbFbFzz1WF+aY9rHd+BbcLZYADImzxSJMhRPGcYnvdVFPfS4gSUlQR NDJHvYSnpfRaMAr5qb5BO5GT4N8+zWL74awlFTw8K1S1/a6Sn83oh3q0/Do6t+jz20XV HgsnISr4zWYM7bXPx2/GnYSsnM+tQMaQNgJi8xv4HboSFZ68Os/x0vkqXF6aPNJ5+imh C2HCoSsnbMD563AefQ3YivU7gfVTqjIlJbQ+5bBmvIBPdKMFKTPz0EU4n08JJcHL4bRB fskQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=DmDvYyxN; 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 mt31-20020a170907619f00b008b11939568dsi10582380ejc.365.2023.02.15.14.57.19; Wed, 15 Feb 2023 14:57:42 -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=DmDvYyxN; 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 S229815AbjBOWqy (ORCPT + 99 others); Wed, 15 Feb 2023 17:46:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229509AbjBOWqw (ORCPT ); Wed, 15 Feb 2023 17:46:52 -0500 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2055.outbound.protection.outlook.com [40.107.6.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73DD123850; Wed, 15 Feb 2023 14:46:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BmpVpZsk8L3hT/ieEaxXUbbcEmhjzmGtkkvo9lCBBeQz0g3cjFMIbcx5xMhHqjCxIXdjPNAojp2peBk0FVOGrhZ1TzlbvNGjHrdGIJez/86GgPp6Lz69jBVB3tlJdSA2Vv+PjA9nugbUgev7pp0ChPk2JtsAnEwcTNOtCEVvfJXLrRjEESg0qEJnoJjqP8ytrmIPwWOe/yuVzMMP7mbW5G6RnmHtU2BBZ41hL3ECTuCOdO5Pq8rZZYrhbTs8MzFHG5zpH2Dh4Q1IzArcCMo+DOE1t1URIhgYQXS29CAzDDgv/mdhOO9CjPyXZezus5Bl/xAUwWE+aZds+xLrWYaq8A== 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=OcfqCb+n5sNTVWdr3UHmaLjGSkxj7vmXWvMcpPgUSrs=; b=DpIqziKH14d64d96MM1FWRLY/eJkCtgHcB92/ISJr96Ju2QoLCXxxOoKzwlxK9v0YHE5xhzRXeAcZabp876kG4OGHPH3gdND4apoAJrqckKT31IpVBt1hxTSJQ/GFar4eohNU2/Wqq7Ejw6CW7M//7k/CShZEoR0QB4/PhecxLFZ/CAfiW33zQDAebkjs0AIY13ggkHTaU3oOxb6/CHObRxs6g6C5V3KNWW02qHAJlXvNlUII7dKrCmM4RKshfA+rHAtmKnA+Ur6/MRX9J8eHB28v8VfKaDYniaQ7mjwl3/vp152QKf4H20l2F2o1GwUup15tLhrBvJWDYZ87t4U/A== 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=OcfqCb+n5sNTVWdr3UHmaLjGSkxj7vmXWvMcpPgUSrs=; b=DmDvYyxNKG3dcyd9JOjJ2aVPVJgupDOc7mBnP9XzJ0nB8hhzyKzl2rp60cF2i0bBRb6xFruhBxZLv02y9W3pjJR8ugKgDuJUKVbskp1HDeZmfcSILgbpSl9LsWhSoyfFW9v452MLTrqZ4nbgD2KV4a5VNtOpPmG/TuG6iwo0wMA= 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 AM9PR04MB8748.eurprd04.prod.outlook.com (2603:10a6:20b:409::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.26; Wed, 15 Feb 2023 22:46:48 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%4]) with mapi id 15.20.6086.026; Wed, 15 Feb 2023 22:46:48 +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 , linux-kernel@vger.kernel.org Subject: [PATCH net-next 1/3] net/sched: taprio: fix calculation of maximum gate durations Date: Thu, 16 Feb 2023 00:46:30 +0200 Message-Id: <20230215224632.2532685-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230215224632.2532685-1-vladimir.oltean@nxp.com> References: <20230215224632.2532685-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM3PR04CA0138.eurprd04.prod.outlook.com (2603:10a6:207::22) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|AM9PR04MB8748:EE_ X-MS-Office365-Filtering-Correlation-Id: 429af7f4-87f4-4883-034f-08db0fa685c3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8CvxwKzVmIXjlT3NTI8VB4u62/EgOmLE4lVot9nbOs+bgB1aWlfvu0tjM/DYcmw+kVVTG+qDP8g9eSffh8tMu0VIci/9CWLw5cqmebOEqH+/mfUdw4ebVWSh1O1g7x4jQdyOYUJp8yLbsMAJKSDJO+IQMq2RP2cAtU8Lhc9nxny7e4EIIZ98GBD5waDDq7QZiRTdbw5YUzE16ZstR2w7LPxVW+Be4noAeFaObpodWu98d1feHKNTr/k3Pa21NTCmtkDKaQbLKBp/NhrjfTs9OcNZgqU9BmIUDxxlku3be33okZ6xR5K1BgF4KvMIhlUDEC6gmxp8SuPxy56hd4HInejDXGSwH5s7YlBXDOROHXxjbXyYUDtHXNWm6P4np0Xjhi0er+qKYphh7MeU+r2ENAlPC6lEYW7dRBPs70RPqWqp77/2HQQ9lpDC87ZWY1jFt/w6LwuyjeZw+f2dqdAQtqOwUhCkygS9ubWFfxsuDt/rmKjbtbXGI+3tx8ZtJa/KKL84r9Kijw9GnJv3JCObu0wher80lTs1lLTmovO4G/khzSdUR23qOMzQW+M9Z2i3CjGuqbBbnmminPqIvS+IXoEsijuNLubiOkE7qURlIhVBWOVhtT6cDGFnCjbtXYjpSZfG1Xai/SxHNTu77KBcwiB1V4MxBmwpKXZM1FMfUTw64N89JZaV/XHRvYNi9JWu 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)(136003)(39860400002)(366004)(396003)(376002)(346002)(451199018)(478600001)(6666004)(6512007)(26005)(966005)(38100700002)(1076003)(186003)(6506007)(54906003)(6486002)(83380400001)(38350700002)(52116002)(41300700001)(2616005)(2906002)(86362001)(36756003)(4326008)(8676002)(6916009)(66476007)(66946007)(66556008)(316002)(44832011)(5660300002)(8936002)(7416002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PKYFKPMhNBaybkRFSUZbGEN5R6uLKoA1HsnLEn1W1Em9mGHecAWeZ+jFJz2v+spdl7ZuTWqltFYha+w2iRleyG4F7FaLWoGb9GE7ZHBoWpjEbytj5lUNzLSHdyMz+y1cNYIb60jeDWCc5eVF5wf3HeyaTbUu07J8ZTddgKHqtRNcaI5PFPDGyhOW/+C9NfAeiN+pYkoHyW0IaF5hIqG7NPxWkS45I3RwvwSL01orNcheVuOuerdaSzbTHdT1x3kwh+p4keDtO15UYJG10DJS16JiVdA7WOql7fcZZP5YjIvLsdGcJIc/iBVvKxGFtF5UiVxCzj0VoU3FDBlRUm/2Szc7y6BTWRkLZde482nel8LdzxcTCSU1w0HFbdyS2oJN0LU+/WBctrsD58wJMMXnKKpJIKSCRBI1UWZ+6ekQgpeAFFjUaRD5G7AL2IHkL5KorCoRFaGjjsnXeIEj0cowClJxkmuN+0I6LuFSm1L5SR9e+yoESWGYqmV6txTC97kulk7nmPubPVaEpUMMLkYThdlegQlCt547HsAlyXmNMcF0uwM4GXyeNBtZi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ant-Network-Message-Id: 429af7f4-87f4-4883-034f-08db0fa685c3 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2023 22:46:48.8382 (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: x3f+6eotfawQy/x38LiU7m0vQiqtiFmSBput6NxttyHZp8VBnt70RLCCQG+pbUWAA+Dmf5ujL7i2yKCQQuHYmw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8748 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?1757939616946371639?= X-GMAIL-MSGID: =?utf-8?q?1757939616946371639?= taprio_calculate_gate_durations() depends on netdev_get_num_tc() and this returns 0. So it calculates the maximum gate durations for no traffic class. I had tested the blamed commit only with another patch in my tree, one which in the end I decided isn't valuable enough to submit ("net/sched: taprio: mask off bits in gate mask that exceed number of TCs"). The problem is that having this patch threw off my testing. By moving the netdev_set_num_tc() call earlier, we implicitly gave to taprio_calculate_gate_durations() the information it needed. Extract only the portion from the unsubmitted change which applies the mqprio configuration to the netdev earlier. Link: https://patchwork.kernel.org/project/netdevbpf/patch/20230130173145.475943-15-vladimir.oltean@nxp.com/ Fixes: a306a90c8ffe ("net/sched: taprio: calculate tc gate durations") Signed-off-by: Vladimir Oltean Reviewed-by: Kurt Kanzenbach --- net/sched/sch_taprio.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index 9781b47962bb..556e72ec0f38 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -1833,23 +1833,6 @@ static int taprio_change(struct Qdisc *sch, struct nlattr *opt, goto free_sched; } - err = parse_taprio_schedule(q, tb, new_admin, extack); - if (err < 0) - goto free_sched; - - if (new_admin->num_entries == 0) { - NL_SET_ERR_MSG(extack, "There should be at least one entry in the schedule"); - err = -EINVAL; - goto free_sched; - } - - err = taprio_parse_clockid(sch, tb, extack); - if (err < 0) - goto free_sched; - - taprio_set_picos_per_byte(dev, q); - taprio_update_queue_max_sdu(q, new_admin, stab); - if (mqprio) { err = netdev_set_num_tc(dev, mqprio->num_tc); if (err) @@ -1867,6 +1850,23 @@ static int taprio_change(struct Qdisc *sch, struct nlattr *opt, mqprio->prio_tc_map[i]); } + err = parse_taprio_schedule(q, tb, new_admin, extack); + if (err < 0) + goto free_sched; + + if (new_admin->num_entries == 0) { + NL_SET_ERR_MSG(extack, "There should be at least one entry in the schedule"); + err = -EINVAL; + goto free_sched; + } + + err = taprio_parse_clockid(sch, tb, extack); + if (err < 0) + goto free_sched; + + taprio_set_picos_per_byte(dev, q); + taprio_update_queue_max_sdu(q, new_admin, stab); + if (FULL_OFFLOAD_IS_ENABLED(q->flags)) err = taprio_enable_offload(dev, q, new_admin, extack); else