Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3119359rwb; Fri, 16 Dec 2022 10:17:45 -0800 (PST) X-Google-Smtp-Source: AA0mqf4j7ehcjKnDzq3dVkWvP8AB+chWx9eyCs6uDgkNp2BW58m9kxSNWzWuJGbvUPG/b7vcRN5L X-Received: by 2002:a17:906:2288:b0:7c1:1001:600a with SMTP id p8-20020a170906228800b007c11001600amr40107684eja.77.1671214664862; Fri, 16 Dec 2022 10:17:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671214664; cv=none; d=google.com; s=arc-20160816; b=BkhpxHmLzkaUjEdzaP2CuYHLzA3Yxgzg2X/1qM5hZZp7KyuLBkjrsDf8lQcljVIZfe rBGnidn2NsoMOcI3RK/HvEVrPtnEkGiDQUCT+ou5lT+tGdexcorf7wva7+X08SoRoV8S ywWPHP952i939UxWukZwtwCPkS5hI/ne0thzOmWSlNGsaPMxny+B2ksyzxWe+JldP9GM vnjjoFC4YR4TFuZCMfUiPxoSfTfFDYpI7uzRUn99oFtRSpNjs1MGE81HQUK8TNfeaOvf wyews25EOmTVIrr3gJTElGOAmwBQRZrxN29H6AFVTnafRUwGwu4MEbgz2zNXU0sMDAMJ ibyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=dIv2+6FrFvBFHioHuEmEwHJpKVRq8KjJBhuXE7RUxYg=; b=qwoba9nkgURuPCce56VqFzLHPsQBoGFBZc17loa1h68hr+USIq4kYkTuTlVyfBHBi9 aV1ipF6RNj/AM3fhWY0du80vlQe5Mi2ES9Jjo6/UOjWOQ1CL3Yw3xF1GM+dMqYUmjyaO Nd7Z4WLa+UjYkHgp5MyU7gBoHh3hgixG1Gg5HhfAA00tbWF9CqPJLY82LoMV1QkUb0Jd GR+Rjo22kj89t4LpKPDjeKVpzX97aHAJbVif+BfLWFe6amJKwGOryIghmfn3hltdWNr1 8rzNCY6Ug7lMImYRL1M3Z+hkfoWA7/h1bkGCQv04T7n5+tcwnKrpBkH8RMIto0bG5+wO ApzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=d23NYspA; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sd34-20020a1709076e2200b007824b85978asi3493975ejc.81.2022.12.16.10.17.29; Fri, 16 Dec 2022 10:17:44 -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=@gmail.com header.s=20210112 header.b=d23NYspA; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231792AbiLPRYx (ORCPT + 68 others); Fri, 16 Dec 2022 12:24:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230157AbiLPRYs (ORCPT ); Fri, 16 Dec 2022 12:24:48 -0500 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75DF446678; Fri, 16 Dec 2022 09:24:47 -0800 (PST) Received: by mail-pg1-x535.google.com with SMTP id h33so2206190pgm.9; Fri, 16 Dec 2022 09:24:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=dIv2+6FrFvBFHioHuEmEwHJpKVRq8KjJBhuXE7RUxYg=; b=d23NYspAyVCmJO/zLT5jUZkbABjOrhjDGEzpNwHN1Y2X2M09aMzthCbgw60KJU8JYr mDeOETQwEcv8QNPHZ3DNdBTzIR2uU5LS8H2SxytYrOPyNDTYFdOOnrIpNVzZrlFFfsfj OaTKbOYW6n+g9wdS+++mbG42F9yXnVmrmq5Ku1B8WFLJ0iLUW8I5nS27k+WDeHaMLdZN a9SkLT4irKpsOD7zwS/co/tM2fN3erGuRPalXhhs2mtLuaXjp45gkpcvVHYXpF7BuSGm BYwBNltViQ6EwYgq2eyB+De3v6eDqLBqvJLU+sBbxHiL+vVVC5W4M1Ud08KMiLkhWxP3 5ALA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=dIv2+6FrFvBFHioHuEmEwHJpKVRq8KjJBhuXE7RUxYg=; b=H11ZNUJb8f8tJmaMMAAgjv/KVxaMPJ4FGGceETWN4uh/RLsTLy77ANfb8ltcffk0Qi 9NzHnwa06mCPNrc+sa9OnIf1vJqlZ1O2ILfMqbv8kw8lkQCvRBxGToGbaQOA7hse8KOY fUYfhRAElI1HwRF8b4JXwP9RqNvlZvkdb3zqyRp/Y2JjSCrkoWVPcIEAeijf5XKa5rac oA05Fb14a+ECDSYdFW4Q6ag136wuMvDlRcTDOT//46VXFWIdCuEK5ebGLoySMdU04GNV th13BKjd3nEc2ZtoepPuQs63svKsqu/h8YKtFAPgzI8EmOQ0jq72hiAGmOd4HDJyjHNP UDGw== X-Gm-Message-State: ANoB5pkXcuRC2BoJXBjm6HLu99bRcwkBhhEtXjFq7tpqNV/I4p6CwSL6 eWW/YcYxfFiYZl9gzd+V+LLBpyw0Qp/14pDGnCg= X-Received: by 2002:a63:f241:0:b0:46f:da0:f093 with SMTP id d1-20020a63f241000000b0046f0da0f093mr70601384pgk.441.1671211486851; Fri, 16 Dec 2022 09:24:46 -0800 (PST) MIME-Version: 1.0 References: <20221215144536.3810578-1-lukma@denx.de> <4d16ffd327d193f8c1f7c40f968fda90a267348e.camel@gmail.com> <20221216140526.799bd82f@wsk> In-Reply-To: <20221216140526.799bd82f@wsk> From: Alexander Duyck Date: Fri, 16 Dec 2022 09:24:35 -0800 Message-ID: Subject: Re: [PATCH v2 1/3] dsa: marvell: Provide per device information about max frame size To: Lukasz Majewski Cc: Andrew Lunn , Vladimir Oltean , Vivien Didelot , Florian Fainelli , "David S. Miller" , Jakub Kicinski , Russell King , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,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 Fri, Dec 16, 2022 at 5:05 AM Lukasz Majewski wrote: > > Hi Alexander, > > > On Thu, 2022-12-15 at 15:45 +0100, Lukasz Majewski wrote: > > > Different Marvell DSA switches support different size of max frame > > > bytes to be sent. > > > > > > For example mv88e6185 supports max 1632 bytes, which is now > > > in-driver standard value. On the other hand - mv88e6250 supports > > > 2048 bytes. > > > > > > As this value is internal and may be different for each switch IC, > > > new entry in struct mv88e6xxx_info has been added to store it. > > > > > > Signed-off-by: Lukasz Majewski > > > --- > > > Changes for v2: > > > - Define max_frame_size with default value of 1632 bytes, > > > - Set proper value for the mv88e6250 switch SoC (linkstreet) family > > > --- > > > drivers/net/dsa/mv88e6xxx/chip.c | 13 ++++++++++++- > > > drivers/net/dsa/mv88e6xxx/chip.h | 1 + > > > 2 files changed, 13 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/net/dsa/mv88e6xxx/chip.c > > > b/drivers/net/dsa/mv88e6xxx/chip.c index 2ca3cbba5764..7ae4c389ce50 > > > 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c > > > +++ b/drivers/net/dsa/mv88e6xxx/chip.c > > > @@ -3093,7 +3093,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 (chip->info->max_frame_size - VLAN_ETH_HLEN > > > + - EDSA_HLEN - ETH_FCS_LEN); > > > + > > > return 1522 - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN; > > > } > > > > > > > > > > Is there any specific reason for triggering this based on the > > existance of the function call? > > This was the original code in this driver. > > This value (1632 or 2048 bytes) is SoC (family) specific. > > By checking which device defines set_max_frame_size callback, I could > fill the chip->info->max_frame_size with 1632 value. > > > Why not just replace: > > else if (chip->info->ops->set_max_frame_size) > > with: > > else if (chip->info->max_frame_size) > > > > I think that the callback check is a bit "defensive" approach -> 1522B > is the default value and 1632 (or 10240 - jumbo) can be set only when > proper callback is defined. > > > Otherwise my concern is one gets defined without the other leading to > > a future issue as 0 - extra headers will likely wrap and while the > > return value may be a signed int, it is usually stored in an unsigned > > int so it would effectively uncap the MTU. > > Please correct me if I misunderstood something: > > The problem is with new mv88eXXXX devices, which will not provide > max_frame_size information to their chip->info struct? > > Or is there any other issue? That was mostly my concern. I was adding a bit of my own defensive programming in the event that somebody forgot to fill out the chip->info. If nothing else it might make sense to add a check to verify that the max_frame_size is populated before blindly using it. So perhaps you could do something similar to the max_t approach I had called out earlier but instead of applying it on the last case you could apply it for the "set_max_frame_size" case with 1632 being the minimum and being overwritten by 2048 if it is set in max_frame_size.