From mboxrd@z Thu Jan 1 00:00:00 1970 From: Florian Fainelli Subject: Re: [PATCH net-next 2/2] net: dsa: Set the master device's MTU to account for DSA overheads Date: Thu, 6 Dec 2018 12:21:31 -0800 Message-ID: <2cb7d5ba-5769-ad42-f4f1-e0828e2017f1@gmail.com> References: <1544092565-11311-1-git-send-email-andrew@lunn.ch> <1544092565-11311-3-git-send-email-andrew@lunn.ch> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: netdev , Vivien Didelot To: Andrew Lunn , David Miller Return-path: Received: from mail-yb1-f194.google.com ([209.85.219.194]:44979 "EHLO mail-yb1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725916AbeLFUVm (ORCPT ); Thu, 6 Dec 2018 15:21:42 -0500 Received: by mail-yb1-f194.google.com with SMTP id j145so1363565ybg.11 for ; Thu, 06 Dec 2018 12:21:41 -0800 (PST) In-Reply-To: <1544092565-11311-3-git-send-email-andrew@lunn.ch> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 12/6/18 2:36 AM, Andrew Lunn wrote: > DSA tagging of frames sent over the master interface to the switch > increases the size of the frame. Such frames can then be bigger than > the normal MTU of the master interface, and it may drop them. Use the > overhead information from the tagger to set the MTU of the master > device to include this overhead. > > Signed-off-by: Andrew Lunn > --- > net/dsa/master.c | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > > diff --git a/net/dsa/master.c b/net/dsa/master.c > index c90ee3227dea..42f525bc68e2 100644 > --- a/net/dsa/master.c > +++ b/net/dsa/master.c > @@ -158,8 +158,24 @@ static void dsa_master_ethtool_teardown(struct net_device *dev) > cpu_dp->orig_ethtool_ops = NULL; > } > > +void dsa_master_set_mtu(struct net_device *dev, struct dsa_port *cpu_dp) > +{ > + unsigned int mtu = ETH_DATA_LEN + cpu_dp->tag_ops->overhead; > + int err; > + > + rtnl_lock(); > + if (mtu <= dev->max_mtu) { > + err = dev_set_mtu(dev, mtu); > + if (err) > + netdev_dbg(dev, "Unable to set MTU to include for DSA overheads\n"); > + } Would it make sense to warn the user that there might be transmit/receive issues with the DSA tagging protocol if either dev_set_mtu() fails or mtu > dev->max_mtu? > + rtnl_unlock(); > +} > + > int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp) > { > + dsa_master_set_mtu(dev, cpu_dp); Not that I think it matters too much to people because unbinding the switch driver and expecting the CPU port to continue operating is wishful thinking, but we should probably unwind that operation in dsa_master_teardown(), right? > + > /* If we use a tagging format that doesn't have an ethertype > * field, make sure that all packets from this point on get > * sent to the tag format's receive function. > -- Florian