From patchwork Tue Jun 13 17:09:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 107472 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp710856vqr; Tue, 13 Jun 2023 10:22:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ429mqAcTMsgexfZDdKgBR3FZvoiLHKBPVeRDLigfeC6OCBDkgTRgASsSKF+S0w6X8mHK2e X-Received: by 2002:a17:907:36c3:b0:974:7713:293f with SMTP id bj3-20020a17090736c300b009747713293fmr15406719ejc.41.1686676970521; Tue, 13 Jun 2023 10:22:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1686676970; cv=pass; d=google.com; s=arc-20160816; b=vVlatYHzYUTHqO0ch81QQ+MGSWEwGj03FQuPSJOREGZ1iRY6J+2ZAR1izyyLDL0vRn AVZgl8p1piabhQizhz9fWVl/xDs15w0+p+VenD9QV5wO2RKuwHrEBDLOMGCRVTiH4BWP 1z71QfrdU+qehtpeSgnAjO2vinc8FzU0ESh64Jkr7d5nFt5Ggehbr4dNkTMKDKgMG+hA twM1y13RLay3P29F+onEHaM+isDmIrbx0QGKQElq6ZsSIAdAXe4KC/ytVBvblelEfdx+ ZX7QjEghHoyspEfHvEoHC8Pr1CbSOOthMSGObPWSpoRNR7/dT/KLunvLNcd8ltGFzoEo enXg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=Et2EL1rvz1tImEnOBsXTR28LSiAMYNdMQ7JSBIEhjzw=; b=aOqrDC83dJV28inu6UvjrNDyzISDtDMxFGvk5O48J9GVhhqog+lYBpByCgNuG3jt2e izs2li71WCfA7u4TV2VCVC76cAOIAR3gRpkWvJqMHeRxrJ8Si2z5+Cjxb8TSUMghSJI2 wu0tcHZt/7J8bspN6ORG3iHScJ+HT80MHr/eY1uHBP4Cbt9gLGPok5O1mtI+dciiCn0M /Oc/Y+2AsqgzthPpa7F41B0Cpk/jWPMwTO8wr8BoiMgU5l+NyZOXFRMyIuUOHbR6OYI/ ygSZ6fH60FJUgVCcslKVB5zeTQMLh3sOhlph1mRzvNK7KpdcvGzpaYsTDR964V7N1d3L n/DQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=qommHrb7; 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 d20-20020a170906641400b009781494aca8si6811115ejm.725.2023.06.13.10.22.25; Tue, 13 Jun 2023 10:22:50 -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=qommHrb7; 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 S235865AbjFMRJ0 (ORCPT + 99 others); Tue, 13 Jun 2023 13:09:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232484AbjFMRJY (ORCPT ); Tue, 13 Jun 2023 13:09:24 -0400 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2079.outbound.protection.outlook.com [40.107.105.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE3E41709; Tue, 13 Jun 2023 10:09:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c+/iqaCzkFChAwqpt9fQNuYAEbF72TS7JQUwT8BUwoS0PiD/7pAg7AjXjLoR90m5LojLYLSqSR6PjlmppmREj6aZSfFnQrd06ar/9ASQ+7wltM1Mh4t1ortaqERtDkJSe2Q88LKJ4kw+frB+zK0W4n9z6X+jLFC7Sr53kr2YQBln5ZPvaT9DZIn1OHyrpIwnWeCtQ/A4sUHvLJZm/fngaO0NVj/fxfxccRAiYbYLo+74F8MObZDmaFGylbN1C1QbqhKwlbObyWhVSli3xRP+psHlP0Cd1jWk7ZoJ594pGOIIYLQKG4m+nsZu76YsDeMIfLeFTusqXvQIXJAmLujBmw== 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=Et2EL1rvz1tImEnOBsXTR28LSiAMYNdMQ7JSBIEhjzw=; b=kFIA+4nPXopsP1hVAbrAOoXIrlbxXaEqGa+m0et0XCJ2ruK+RZn0R72E5TL567Yeq5Q7NsfmZxgsWdWHcFIFPQPCHRzgIfJOdPNb3p3yzR4ZNyDhMKJ5MG2u1M8IV3GWJGIIpm8LRs+byFQ0F3X/yZBXU5y6ZRyzeScWsRoDgo7tCu3aFyL4RjsNrFmhnrSxiNCUUBeKuyxcO2CqZTyAnV80/mrWVwsGtiP/1MNHuZSkQdcVSSarHQt5XYTc2xlYh5RFUUgqlYZyOooxIBhMnmQVmaJTwJ5qFbBe/JT4Wa3MJlaF2FVYuSn/oegnBTSriJXwG+gPyKBSBSB/8RS+mg== 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=Et2EL1rvz1tImEnOBsXTR28LSiAMYNdMQ7JSBIEhjzw=; b=qommHrb7Pln94uJBdDPc9li3X02TmmbKvv+qVwTiiNOYjJyoxJlayakVE6wQW512A5SR7GmmaeUrv6AmJwhX1J+TbPPKbrqPX+Wl80MX0w0GX2MVUICL7tZ/WUKFL5Nm1scWv67ULxe5D82Dha/SHltZQz+ItefbLjCsCK/9mLo= 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 DBBPR04MB7548.eurprd04.prod.outlook.com (2603:10a6:10:20c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.39; Tue, 13 Jun 2023 17:09:20 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::c40e:d76:fd88:f460]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::c40e:d76:fd88:f460%4]) with mapi id 15.20.6455.045; Tue, 13 Jun 2023 17:09:19 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Andrew Lunn , Florian Fainelli , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Xiaoliang Yang , linux-kernel@vger.kernel.org Subject: [PATCH net] net: dsa: felix: fix taprio guard band overflow at 10Mbps with jumbo frames Date: Tue, 13 Jun 2023 20:09:07 +0300 Message-Id: <20230613170907.2413559-1-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: AM0PR03CA0059.eurprd03.prod.outlook.com (2603:10a6:208::36) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|DBBPR04MB7548:EE_ X-MS-Office365-Filtering-Correlation-Id: 0d88fd25-618d-4e24-e5fc-08db6c30ed02 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mKklGwW6FCoV2jMYdu1S9ir1gA+ZnHdNEp6UlxaLHPAc+vrsdYLTmSWxhMSTPYuGt6SUpqwS/AyrxnJfbm8rYVds6/Jl55g05r2FKlq/d4xKdU3C4FlHPKGIRS2X4aALypNNBKToMJPt2undSBCOp/bvbZoeoMXcxKy/K9K86bmEvjo4yDHbv07eqsmd1XfzpgwZwjvOkuSvOcXuTttNnyLDbSIWO/sHPhiiu7ROVUX710OH9JSjyLRzr59/zwey595am3aOOyyxWrXQwbpobNfV0Zot/q4aOzP3HJ3l0l1NZ1CfR9wWF91zUJsanVXmz8ERUOKFtHbWVhYdLW8gXaKp4tZS9fDpRqyl4697l5Kdnm2bE4pyy0kgZgygFlHCS9TVqtFWS/8kQ9u7sPx8Ab9Cu/WrSEDEIz+Cw73O5a1CPczPzUxhVRJ0MiaVxxyZNYYOnLbSmVY5po5zkwUtCISF1/tOmgi/B52HmbgM5FOxmpOiyJcZO92WwvVdIv0AtW7OWlS5hmiMUbFR4l0egR4BGCzmkfrOs+oesIyHefQL1wnEs52IjLG54Bx0eNNss7Vg5jaYzlpUhR2vPndPUVirkZEuPob4TK6SQW+CfCR7WId1VUgDf70Ds7cpXCgF X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(136003)(39860400002)(346002)(376002)(396003)(451199021)(7416002)(83380400001)(36756003)(6666004)(54906003)(478600001)(38350700002)(8936002)(5660300002)(316002)(41300700001)(66556008)(66476007)(66946007)(86362001)(6916009)(4326008)(8676002)(38100700002)(6486002)(52116002)(2906002)(44832011)(1076003)(186003)(26005)(6506007)(6512007)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vuDA0wiVh3+AVIp6E4OIYTpK6bs01/CiwkUCpwmAn3bclDieEsTRCCK0Cp4Ts2tJl7CgGacHFkLrsY/5687OdXyHrd0H/xy2yjxKAtyeYlRor2ORUoXfdKb7USDIUaAMJu6cRtpfJ9PLT5ojEd3aJGtooVpUejHl3jJQw1d2aWZ/uLMDO2rI/P5nQ3P8rJHxBtYebzr66JUnwwpVu5TcC80Ynn1c1vDaz5MCkLL9untw4Hgxo+v/GE9xHFPLNzr9XHnV91w/V0lowoCHWkJrS4LVbKDIPHo7SRvqc+ahpDV3GUNxHLDSeLPjBJDW//SpksN0H4IRplHGYA2L3tV89T14Oz5XlVlyM7exJFH2f/RPJPO6wpkt0D1//Xvj6K5HC5r2pIafKt93jRmVpWHjstXUleMDH6gArY0boQomMyJlkctCBwjCz1JNlu3Uv0df87vPOf5jNzTYkiOoyv2Ifujmeas15Pxdf5XGl/tKFnuRYkdFCYx13hiVl2jc6tTgWQ+yVGGE/gDmS204wsRSkeHLEkk5RoCoWP5UJrEzK9YnfjlQUe8Kumv2nB26HU5BPRcN6QD3MgnBFwnqI4nFREw/gxHDw+BxB5OZ1uvIRFNsoQ45Q/AOYCjiq+4yxmGtvifHF9d4tvxt6M9VDJHZGoSDjtHXzeruz/KJA6IoH4ntUsvOP/65fX9sRRIZFavkwNZ7637MnBxyxEXNwqkGv8dRofs3T1UBh0rlPItEsrfrrSjumb1qRWCaakdn0GZjbqWs2fxIp0yVCjcPgcvcGj7k48Rk0w4UAeV7dsV130t3LxPQilpQTLZO7d3LMXhrzmimoW6QMWAO+Iucz022W+HPEPjnhwJE0qkYZyc7wT2RU6euPcAKo5V8oEMnCpxp2E19sQ0zjpEMSfctYQOw7P4q4OFLup5FLRWK4VfYbuDsoMk+jWfF1gaERN9IQUL9xjYGEgIeaDhOfQ1mynvOvL986kQm7dkM/6xZSjXlBhIiTChq4UCjnz+pYqCxxt4FSjRpb+/0mcfCPlyU2JwdO2aTb+2Y3yQANfP/GGMi6qyEHbP4WFs8PKshc9mRaQuYeHL/boBU/atDuOCFSG8uTWF/5EL1Q28hcCly1otuq6fU/PqnMyeJXmfi1MMTVb6PLrYLNZNHJyRwB8Lxeqf/uttFieAt5Sj273dhVjy7E+aOOZoJSoQmRcsyUH759bvJd410pjxYR5vQHU1bg2nqeWh7QmTmWFlxym61XezVXO/DH7qq0CSWpCG7dT44b6FarIx+D7jx3payC1jrghm4R+iCOQGBZ38zRXtzb6cdq/0ClVSKSMOUBz6VWBYtP/oUQD/rnStnDs+wrz2KF9WpHNJRzbXN3SUqjQRInxpMa90p+JrmCu/8x5UcKX8RjoaAiW+5zXPRDt1YW9r18eZx9waFIdozSVieDvXFXt6i3XFFmvemN6L+cUwiEe1s97R0YObm4cHwbNP4+f12Bjmyh/Q91UcGc2coCq0/gsjyNpQtx9j2h1ZLNc463+9u9kriQEvD+mXur07Zh9BT0Oz38eW9IeOaB0QO3Q37LX7e70UPJ3TdbGGzsxejLcDpIfT0PBaZgbYC68ht2/Z3Pb76SA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0d88fd25-618d-4e24-e5fc-08db6c30ed02 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2023 17:09:19.5660 (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: SxGuWj92NxWVmP0nC3IkXGgLoH30Vta6RNs5R26OY+RuinQLDeyBcfJDNt0BMTH0xYpsMvAPVF0OGQv5uwssnQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7548 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,T_SCC_BODY_TEXT_LINE, 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?1768608991433153193?= X-GMAIL-MSGID: =?utf-8?q?1768608991433153193?= The DEV_MAC_MAXLEN_CFG register contains a 16-bit value - up to 65535. Plus 2 * VLAN_HLEN (4), that is up to 65543. The picos_per_byte variable is the largest when "speed" is lowest - SPEED_10 = 10. In that case it is (1000000L * 8) / 10 = 800000. Their product - 52434400000 - exceeds 32 bits, which is a problem, because apparently, a multiplication between two 32-bit factors is evaluated as 32-bit before being assigned to a 64-bit variable. In fact it's a problem for any MTU value larger than 5368. Cast one of the factors of the multiplication to u64 to force the multiplication to take place on 64 bits. Issue found by Coverity. Fixes: 55a515b1f5a9 ("net: dsa: felix: drop oversized frames with tc-taprio instead of hanging the port") Signed-off-by: Vladimir Oltean Reviewed-by: Simon Horman --- drivers/net/dsa/ocelot/felix_vsc9959.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c index 903532ea9fa4..bb39fedd46c7 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -1251,7 +1251,7 @@ static void vsc9959_tas_guard_bands_update(struct ocelot *ocelot, int port) /* Consider the standard Ethernet overhead of 8 octets preamble+SFD, * 4 octets FCS, 12 octets IFG. */ - needed_bit_time_ps = (maxlen + 24) * picos_per_byte; + needed_bit_time_ps = (u64)(maxlen + 24) * picos_per_byte; dev_dbg(ocelot->dev, "port %d: max frame size %d needs %llu ps at speed %d\n",