From patchwork Sun Oct 30 21:36:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Horatiu Vultur X-Patchwork-Id: 13063 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1978236wru; Sun, 30 Oct 2022 14:53:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6o8VpvpghGu2Is/h/fJyLcZdeiP9A4NNl7GafHR1EvEFVCNEeSfq8e7MmH5R0cAfY23POw X-Received: by 2002:a17:906:5dd8:b0:78d:efa7:f78d with SMTP id p24-20020a1709065dd800b0078defa7f78dmr10087609ejv.641.1667166787175; Sun, 30 Oct 2022 14:53:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667166787; cv=none; d=google.com; s=arc-20160816; b=tMQOvhMyKMXRCorGe9JAWzuWYYFGq7i1zqYPMjmuV8UoBHIVMLHgcAMslDdhu7Hiw7 xKAOpCyOJVmfhJevKR1X4B5mjwMyD0yO374N4aGxNXrEglwY+xY5cVh1uniG4a9vvey4 ZA8DdrQLSGpqTfqAM5Lut7gzu39g5LFi/dsUJwbcysCILSg1LxajIosBPVNI/46g9fd4 Q4jfR0JWVZPZndRQhihDIXoLl+OB+cbrMg0KWYLOFdE87p4JPqEXbzRkwKaNFv32M1fQ vgs/VXIguLNB9nf5IvEKeN4vOkVXe5NZzv3frPLLAmsgOt5L6A9bXyy+6BLcWhKlbKcx RJyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=t9rNZw5qlK+RstzrgBrevoxZ39AMr+X0kHYIa0KisXs=; b=dx/dW3G7bnb687aNx/akS05z8bO2BoZH4diPkmJEU5S4kEC+WGbOOFCqzqRaNMmSCO myl+mMbpViR58yXxaSi+QZ5Cfb7lq24hyNlGbGytVELxjgRQ2h2jmCFihnnCw7UM/xl+ l2/RFq8ZotSYajPzpadKiiwhSLMXgfWkpY6IJ5WzYKjVM4tA0Q9X5wyuSvIh7I88YY/t ihbtAD2xmaQ/j2QNQx0p3/s7YPT4npPptrHT8WP9gJpLrbvUkMcY817SZqwW5r6Y3dfo MxWVIYk+XVgYY/ubSGxzxqfboZo/tlnmzdA51eWTGtg8kv09qehb+8czuT3ez1PMM+JQ /frw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=NjOSvK7h; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c6-20020a50f606000000b00461b0b4f1afsi5581681edn.288.2022.10.30.14.52.37; Sun, 30 Oct 2022 14:53:07 -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=@microchip.com header.s=mchp header.b=NjOSvK7h; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229923AbiJ3VcS (ORCPT + 99 others); Sun, 30 Oct 2022 17:32:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229786AbiJ3VcB (ORCPT ); Sun, 30 Oct 2022 17:32:01 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 037BFBC14; Sun, 30 Oct 2022 14:32:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1667165519; x=1698701519; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zO5TaBiovTLxzRxBjR6lBYtEuGdhCJDREHzQQ8LjDVE=; b=NjOSvK7hzg5A5oAhCAx1w838B65j+a2JTFnrJ7T6AkyWOZ3dAeAWRru/ /mP0F5DoubZKvdeAk7ccTb1THV1n5lJ9t/W7Q96jW76AZYwKeVlNONicY XitKzp867eD6uKvkQLXKcy9ZuMynKRrqum4Gg9gjll7s4Y+U6V/1sa3qt p8+oceexqai4yGwU4sD5hxIA91PQoFU8xGVeqjTnWbuUYm9rTDqlamSjs JbZhfNO4ZX5iHiWCb0/oUhzd+wNFS7G/5hZ7aIxqPT3Ru2zjbz9TTUmiQ V2sl3sI16YVSRkAhEc5wdfCeQgpRz0RLdLQEXOhamNU87jnKmMOnq1F3w Q==; X-IronPort-AV: E=Sophos;i="5.95,226,1661842800"; d="scan'208";a="186969029" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 30 Oct 2022 14:31:59 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Sun, 30 Oct 2022 14:31:59 -0700 Received: from soft-dev3-1.microsemi.net (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Sun, 30 Oct 2022 14:31:57 -0700 From: Horatiu Vultur To: , CC: , , , , , Horatiu Vultur Subject: [PATCH net v2 1/3] net: lan966x: Fix the MTU calculation Date: Sun, 30 Oct 2022 22:36:34 +0100 Message-ID: <20221030213636.1031408-2-horatiu.vultur@microchip.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221030213636.1031408-1-horatiu.vultur@microchip.com> References: <20221030213636.1031408-1-horatiu.vultur@microchip.com> MIME-Version: 1.0 X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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?1748151080959768577?= X-GMAIL-MSGID: =?utf-8?q?1748151080959768577?= When the MTU was changed, the lan966x didn't take in consideration the L2 header and the FCS. So the HW was configured with a smaller value than what was desired. Therefore the correct value to configure the HW would be new_mtu + ETH_HLEN + ETH_FCS_LEN. The vlan tag is not considered here, because at the time when the blamed commit was added, there was no vlan filtering support. The vlan fix will be part of the next patch. Fixes: d28d6d2e37d1 ("net: lan966x: add port module support") Signed-off-by: Horatiu Vultur --- drivers/net/ethernet/microchip/lan966x/lan966x_main.c | 2 +- drivers/net/ethernet/microchip/lan966x/lan966x_main.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c index be2fd030cccbe..b3070c3fcad0a 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c @@ -386,7 +386,7 @@ static int lan966x_port_change_mtu(struct net_device *dev, int new_mtu) int old_mtu = dev->mtu; int err; - lan_wr(DEV_MAC_MAXLEN_CFG_MAX_LEN_SET(new_mtu), + lan_wr(DEV_MAC_MAXLEN_CFG_MAX_LEN_SET(LAN966X_HW_MTU(new_mtu)), lan966x, DEV_MAC_MAXLEN_CFG(port->chip_port)); dev->mtu = new_mtu; diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.h b/drivers/net/ethernet/microchip/lan966x/lan966x_main.h index 9656071b8289e..4ec33999e4df6 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.h +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.h @@ -26,6 +26,8 @@ #define LAN966X_BUFFER_MEMORY (160 * 1024) #define LAN966X_BUFFER_MIN_SZ 60 +#define LAN966X_HW_MTU(mtu) ((mtu) + ETH_HLEN + ETH_FCS_LEN) + #define PGID_AGGR 64 #define PGID_SRC 80 #define PGID_ENTRIES 89