From patchwork Tue Mar 14 18:24:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 69756 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1917974wrd; Tue, 14 Mar 2023 11:31:27 -0700 (PDT) X-Google-Smtp-Source: AK7set8bgiX4AoaTF7tYBHqlwe4owWimlChROjOKYEBTbO5flUw4lwl211lv+mK2p3OKGkU6HT7e X-Received: by 2002:a05:6a20:3d06:b0:d5:58df:fb7a with SMTP id y6-20020a056a203d0600b000d558dffb7amr3959626pzi.3.1678818686798; Tue, 14 Mar 2023 11:31:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1678818686; cv=pass; d=google.com; s=arc-20160816; b=pcO4+srR8i+7rUDUVswfZo+UgPxk6v5Y5pWMu0QHnFXBBHelZx7uBowFJc+WrvdPfR X09J99kIOyK6t9O3LsMtXaHo2JUNy3KMPt01AcjrTQzAbYjVBpaUSgBdRg8edfcRizgp p+bKt5XArA7LdTDXxjrjiqmQhn9IqXJY99lAugstZvZyMYsMXppfKHXaYpwIan1YLptV ekeBX9NXAo130au8QdouIy+v4e5Wck+qCFrpt/2wRJW7ILBTfUEV1Q7l4rbUcuEcEAPF BEefmW2JnJNjyjqqSMtiJjwJVmGe6BAGI1efWW9ALSWvJXjO1l6oC8UqfbqjOFUE7RtJ Xt4w== 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=eR7QpYWXBw/qReJPhtbzYNdvR3ntTr0TG5tipWAGQSo=; b=DgzyodSu3uj4SnHHNnOyTAkaLywvX3tNEddUrKWtkv+R7BPwonIQvtgb3cF8DhLk1w xyCEdcbDqb6RVN5Zt23ecj7ASacu/SIjpwjWLqZVpW19qLzau0KRy1dsx5UDqhMMip/S Svy/dB7kypXULW2FOMK+AMYUPSvqVGyOEK8ZITe1k31KD0UH/L4lcoQhZ+FcKvId4CP+ 1dBJzCJ3hBkcRXcZD7F5uPJlb89h94vg+duthxyAeBoEZ6KkiHxeWdb+eNidtuNoCfR4 0QFUKlG6GIfiLvS0o64LslBKvuBHrtsqNQJtyoYzvJAMC/bDzMcPKJKrGcXljCY+BEV1 Y90w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=g3xHNudT; 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 j1-20020a625501000000b005a8cdb17b9bsi2705667pfb.102.2023.03.14.11.31.11; Tue, 14 Mar 2023 11:31:26 -0700 (PDT) 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=g3xHNudT; 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 S230160AbjCNSYg (ORCPT + 99 others); Tue, 14 Mar 2023 14:24:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229454AbjCNSY0 (ORCPT ); Tue, 14 Mar 2023 14:24:26 -0400 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2043.outbound.protection.outlook.com [40.107.105.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 723DC233C6; Tue, 14 Mar 2023 11:24:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OfKvcCfm/fUJhVU4LMZGz/tTXmwUztHahE1e13YpJGz2OdXQ5+ItZgx4kC1q4ymsCC1FLG+drBQcA3/oVSyBN4d9EGtjR1Nt7enPYfPehxRYkzN9FfvDTTI35LSTL3IQ1/i6tkr4/vqEM2ORtrImaAQlvq0d/dAwm89sjWewy4t6SLk7jUdb/wbgSRMOFZzZsytuGFENd/PIbYQd91YR4q8kuLDupWfL8CT8CpKtuLa2dgrMSaZd9XT46Zq0hbeXhwq7D1bjZ6GZ5Mv9k44Cp1Q+W26Ny4CaQ3H6t+MZa1bOHRbNe5pAlySvjMgh9Gi4ATd8Zu5LuQavIVMJ0D3aeQ== 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=eR7QpYWXBw/qReJPhtbzYNdvR3ntTr0TG5tipWAGQSo=; b=Q4vitrl1pbVf2L28R2zDV7EDW/4Fj3k3hhIlgdIZ+KJeTpEMv/ylUUfhJTf3XIucQefjcGZcq2uj+F6uDl14IU2pTCXHew3A/Ob3Dy2h6lRYKgv1kG3FQQNaBlJP5dL8U6GKeZUX0+K0b0qFi5rSJoitk/O+dIuQBmU9jAYQfhdOKdJqkK1ZLX3rXFqgs+0mTaEdIj57ubZmH5o4eQEY0bH4FuKrz20FOtrEHUCCB8vsOkx+eMrrROBE77XHeVRZjY8nqPe1izrOAmJGAgJjRvQm9DbMZ11hNQlqKriZKGamIVPVHgGjwy0HY+AhwQZzGCeo5/7Mk+WtfSThXF9ksA== 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=eR7QpYWXBw/qReJPhtbzYNdvR3ntTr0TG5tipWAGQSo=; b=g3xHNudTDe5820bYynP3ncygBwSyDQRm8+C2r/WB+JtwoJoTOsUY5PdwypkTM5Q2MRhmtSQrXCP6wvkIctCwEGhC0CVUlp2uYiu+A1oUq9NCbdXIi5YXdShBWTBQSCPpmymd2kc6GAvs9HM98E62wxC5Ez64LgjBhETEsnhRFwo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by PAXPR04MB8253.eurprd04.prod.outlook.com (2603:10a6:102:1bf::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.26; Tue, 14 Mar 2023 18:24:20 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::29a3:120c:7d42:3ca8]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::29a3:120c:7d42:3ca8%7]) with mapi id 15.20.6178.026; Tue, 14 Mar 2023 18:24:20 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Andrew Lunn , Florian Fainelli , Murali Krishna Policharla , Lukasz Majewski , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org Subject: [PATCH net 1/2] net: dsa: don't error out when drivers return ETH_DATA_LEN in .port_max_mtu() Date: Tue, 14 Mar 2023 20:24:04 +0200 Message-Id: <20230314182405.2449898-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230314182405.2449898-1-vladimir.oltean@nxp.com> References: <20230314182405.2449898-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM4PR05CA0032.eurprd05.prod.outlook.com (2603:10a6:205::45) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|PAXPR04MB8253:EE_ X-MS-Office365-Filtering-Correlation-Id: b737293a-4791-4465-ac9f-08db24b95403 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1Wb3l3GovjT3EYb+13QrfX3QiRpRugvlIQ91yvTq9vvKoRY5QPa7pLuVxZquFCnN5wPMNUUdIsSmj3et9kQ0k9hWkl8Yeqt9LyQvMStll7Ht+vMlun/80A2O7whFcf3n3X6dMxTkRjQSIyPBDWcvQ9j/25Ic7sN5mhnG6npgxF4tdbL+FwN3MdWwLMVfQ4Z8jQTgEx7UiAZSWE4ZyESmbNwF0kTV9KWUoOjJv4ZRUSIE+ZaHjsGIpZ7Maz8eWK51YsfbvORwqKWm1KVO8XGH5E8OaWpx3JOWKtxnFUIgleZeVmNNU4hgcVJ1AcA9iRSmIfNJd60vatN1fuugtd3YbjHSD+hJhsaemlQkZ3ZzypIB5YnJyPYF1A5Ei7SPIeAqIkT2zLbQgTvJubLO3ZAg34t0UX5tOq+LOKS0yeoD4VqK3jma9HyDE8C5ZAqZKVTZeIfz45x5CNLW7QM2Xg9h34Osi+tZpLivQkqNfVF01ElXLeYlYFjzNrw99mfENP2sUK2kMVR4YKsCOpa8mYZVG8rhXW7gI+I/4ZR0kREpTINIKAa/6JEQmm0Af0+4qE6kuPFrek4BF9BK573s5Bfc9uuEwN/qQnulacgKAiqofkig+xoyM4pVTVTYdr8wwfwVO/V89BB32ub8jKTbm0ZXkRJexKLKdvEnKkZ8GJZJszFCZAVODgswkYtw6p8TNumhvvuHvnVpmGrcaWgCO5+g6GxQgb6BaVVF3VwFjKPDgRs= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(376002)(366004)(396003)(136003)(39860400002)(346002)(451199018)(38350700002)(66476007)(66556008)(66946007)(4326008)(6916009)(38100700002)(41300700001)(8936002)(316002)(54906003)(83380400001)(8676002)(478600001)(5660300002)(86362001)(7416002)(44832011)(6666004)(6486002)(36756003)(2616005)(6506007)(6512007)(186003)(2906002)(52116002)(26005)(1076003)(142923001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LjD+HUzTuT8tCi2b/8XSpLEiS729O82dRu4bVbAQnGeb2y7GtyGI28ZW7YjLeYXZZGopC8c8Z7R+5seKEpzywtCenPKKwBWD7eROUzPeDmVpeWXcdSLnVD3skQYm00rXZFuD+tJgvftKQkm/v3pgeglAb7mgZyrEgsonNmjSAdG2Z4N9p2KQrZ2uInAcqXBB8FOovAufnzRSGuR8xx/4GSRxjZ8HLODDwoqXi0zVCvJQigLca1AA8Z4xwjEUum+hcbIf8YA8J8/darf+a6QctuawzMe9fnCBmRTMmJOwfSMQ1dsQ1pdZBcNtA8PeyySvNB3Fw3d7rFEE6PGrNpyVWUpbrlCdmoB/cGomUkcpMwtxLWNHHimIedRRheJJ8i5yrAH4Mpa5Cl14jS25xOyoGUq/oi2fI6KQBkqp+VltJqHnyGXrrjngkF5iaqZgNbW9U6PPPRNpUiOSYo8NM+JRC72REE2gXsgKVpIbFqQfmbIPGK9Xea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TVEh4xHr0pi/2K3FH5bVNP7Fg65Xu67U60Mnn2maGX4XJymZ02A== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b737293a-4791-4465-ac9f-08db24b95403 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Mar 2023 18:24:20.1852 (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: 2obLCxAF6xUzA3GJinQeGY6sZgY8anl4+OV17u2LqouSXBlvkvgmkygnQ8TkIeRvJkezr4J0R/ADoyZResHYHA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8253 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,URIBL_BLOCKED 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?1760368983213603097?= X-GMAIL-MSGID: =?utf-8?q?1760368983213603097?= Currently, when dsa_slave_change_mtu() is called on a user port where dev->max_mtu is 1500 (as returned by ds->ops->port_max_mtu()), the code will stumble upon this check: if (new_master_mtu > mtu_limit) return -ERANGE; because new_master_mtu is adjusted for the tagger overhead but mtu_limit is not. But it would be good if the logic went through, for example if the DSA master really depends on an MTU adjustment to accept DSA-tagged frames. To make the code pass through the check, we need to adjust mtu_limit for the overhead as well, if the minimum restriction was caused by the DSA user port's MTU (dev->max_mtu). A DSA user port MTU and a DSA master MTU are always offset by the protocol overhead. Currently no drivers return 1500 .port_max_mtu(), but this is only temporary and a bug in itself - mv88e6xxx should have done that, but since commit b9c587fed61c ("dsa: mv88e6xxx: Include tagger overhead when setting MTU for DSA and CPU ports") it no longer does. This is a preparation for fixing that. Fixes: bfcb813203e6 ("net: dsa: configure the MTU for switch ports") Signed-off-by: Vladimir Oltean Reviewed-by: Simon Horman Reviewed-by: Florian Fainelli --- net/dsa/slave.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 6957971c2db2..cac17183589f 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -1933,6 +1933,7 @@ int dsa_slave_change_mtu(struct net_device *dev, int new_mtu) int new_master_mtu; int old_master_mtu; int mtu_limit; + int overhead; int cpu_mtu; int err; @@ -1961,9 +1962,10 @@ int dsa_slave_change_mtu(struct net_device *dev, int new_mtu) largest_mtu = slave_mtu; } - mtu_limit = min_t(int, master->max_mtu, dev->max_mtu); + overhead = dsa_tag_protocol_overhead(cpu_dp->tag_ops); + mtu_limit = min_t(int, master->max_mtu, dev->max_mtu + overhead); old_master_mtu = master->mtu; - new_master_mtu = largest_mtu + dsa_tag_protocol_overhead(cpu_dp->tag_ops); + new_master_mtu = largest_mtu + overhead; if (new_master_mtu > mtu_limit) return -ERANGE; @@ -1998,8 +2000,7 @@ int dsa_slave_change_mtu(struct net_device *dev, int new_mtu) out_port_failed: if (new_master_mtu != old_master_mtu) - dsa_port_mtu_change(cpu_dp, old_master_mtu - - dsa_tag_protocol_overhead(cpu_dp->tag_ops)); + dsa_port_mtu_change(cpu_dp, old_master_mtu - overhead); out_cpu_failed: if (new_master_mtu != old_master_mtu) dev_set_mtu(master, old_master_mtu);