Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp11813035rwl; Tue, 3 Jan 2023 05:13:43 -0800 (PST) X-Google-Smtp-Source: AMrXdXsGWLhUn1/zqwuhbMzJe5vdebNiAOiFGoOaYScTFRpBytuutEW+8ED0anmXcR15VsB3Zk/a X-Received: by 2002:a05:6a20:c78e:b0:aa:15b6:6322 with SMTP id hk14-20020a056a20c78e00b000aa15b66322mr49054782pzb.42.1672751622931; Tue, 03 Jan 2023 05:13:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672751622; cv=none; d=google.com; s=arc-20160816; b=zHpffr1cE4pmJ3a0V2C6eeovOtChaZYuZWA8Bf3O4hd3BmKmnAlN5AC3qCyzOEwjkJ rsx2spvYVupJPnrq+6V2HP2oiXOtcnHxsikzbjKYV/zBdrL8+jfLf1J5Ru/INZWaxhNx EONF3Rrymgx4+XCWiX5AYYvfCmDa+vQRtHHBmuPGLW5I47OnyC5eL0nOUQGHx+q9iUt8 feqGaLCkyzFNING3ZP1KD2KDsu+3NLVtA09t+cXzFw3br0J4tl+GSuJuwgTGpNto09/A OmbJFfVQSXab+qllEdH+r891xHX6rTnSpHayDG5lFkFs06zB6f+3xhVWxXthpaFakhZd aCYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=i1X/dAEXknkd6JuUKqxl20xIM3iRsOafx1BzQIXRdfQ=; b=DJzBR6lSEBOgmiockENVeaB6S43vms3VtzNJq1Wg/XWk72RGyMQL/Sfw89lJ6O1uJt Z8NmY38PoKrekC17xLntbvWDmek7qV4YkKg854mrDHQ7q+cu0CKnoFQVsZjmuNO/Rw6n 8sGW8THdQW1N7UXg2OPGV7n7tSDijJumQWnaa+kNoYLvvQY9uWhGpMmNJT4cw3YXELPc HQsJimEq5qkEsxL1OvDwXp0dgk4RFNLnnFG+hUUolyu+pj9UElAmmq444JQz3tYOt2Ms QXC6IX5iOY2dPzepCSemr1qQ7VBQcWCNmuLRalbSYMRjpRyZnBCFJZ9Lxm/A91oqOrgq vJxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=pkKDhS9B; 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=lunn.ch Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p32-20020a635b20000000b0047767ded526si30802889pgb.100.2023.01.03.05.13.32; Tue, 03 Jan 2023 05:13: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=@lunn.ch header.s=20171124 header.b=pkKDhS9B; 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=lunn.ch Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231190AbjACMzF (ORCPT + 60 others); Tue, 3 Jan 2023 07:55:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233342AbjACMzB (ORCPT ); Tue, 3 Jan 2023 07:55:01 -0500 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 814BA10FC5; Tue, 3 Jan 2023 04:54:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=i1X/dAEXknkd6JuUKqxl20xIM3iRsOafx1BzQIXRdfQ=; b=pkKDhS9BfegC050glpTLF/VgFZ 64KHrxghxA3JyMW9N+4qDbgOpcv/pqhdA6B7QvIgVxnK6Tktho0SWIFOEPyFxuemdqGce9ScVqKwX MvBfheyXtL1780eKIHjSwy6jCNXZ9cXNiQtyBWihbANQrXtdZ++pWkR/caL1voAgnERM=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1pCgoW-0012mB-7w; Tue, 03 Jan 2023 13:54:44 +0100 Date: Tue, 3 Jan 2023 13:54:44 +0100 From: Andrew Lunn To: Lukasz Majewski Cc: Alexander Duyck , Vladimir Oltean , Eric Dumazet , Florian Fainelli , "David S. Miller" , Jakub Kicinski , Russell King , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 1/3] dsa: marvell: Provide per device information about max frame size Message-ID: References: <20230102150209.985419-1-lukma@denx.de> <20230103100251.08a5db46@wsk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230103100251.08a5db46@wsk> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 On Tue, Jan 03, 2023 at 10:02:51AM +0100, Lukasz Majewski wrote: > Hi Andrew, > > > > @@ -3548,7 +3548,9 @@ static int mv88e6xxx_get_max_mtu(struct > > > dsa_switch *ds, int port) if (chip->info->ops->port_set_jumbo_size) > > > return 10240 - VLAN_ETH_HLEN - EDSA_HLEN - > > > ETH_FCS_LEN; else if (chip->info->ops->set_max_frame_size) > > > - return 1632 - VLAN_ETH_HLEN - EDSA_HLEN - > > > ETH_FCS_LEN; > > > + return (max_t(int, chip->info->max_frame_size, > > > 1632) > > > + - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN); > > > + > > > return 1522 - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN; > > > > I would also prefer if all this if/else logic is removed, and the code > > simply returned chip->info->max_frame_size - VLAN_ETH_HLEN - > > EDSA_HLEN - ETH_FCS_LEN; > > > > So then the mv88e6xxx_get_max_mtu shall look like: > > WARN_ON_ONCE(!chip->info->max_frame_size) > > if (chip->info->ops->port_set_jumbo_size) > ... > else > return chip->info->max_frame_size - VLAN_ETH_HLEN - > EDSA_HLEN - ETH_FCS_LEN; I think it should go even further: { WARN_ON_ONCE(!chip->info->max_frame_size) return chip->info->max_frame_size - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN; } If we are going to use info->max_frame_size, we should always use info->max_frame_size. Andrew