From patchwork Thu Dec 6 10:36:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 1008682 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=lunn.ch Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=lunn.ch header.i=@lunn.ch header.b="xDYwlEm5"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 439X8f0PVTz9s3C for ; Thu, 6 Dec 2018 21:36:50 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729459AbeLFKgt (ORCPT ); Thu, 6 Dec 2018 05:36:49 -0500 Received: from vps0.lunn.ch ([185.16.172.187]:35763 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727806AbeLFKgs (ORCPT ); Thu, 6 Dec 2018 05:36:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=kfjf9LQFidMQppPzRYFfVOwBNeV+wrwTfX13tZotemY=; b=xDYwlEm5y30ak241UBdx88kLBxG5A147rdwQQECGtJ6RXUkPwnvbd9a9O8qR96Op1GzFaaLsHfZAD3wPQLhWimTtlKTBTYaJqoVQ+6dKjl31zY+tdPSWmIq3ZTAa67NhEw6skaKJ0tsAuDb2eB0HntZbvhxUdcDmfZJRA0n7oCE=; Received: from andrew by vps0.lunn.ch with local (Exim 4.84_2) (envelope-from ) id 1gUr0v-0002xA-Pv; Thu, 06 Dec 2018 11:36:13 +0100 From: Andrew Lunn To: David Miller Cc: netdev , Florian Fainelli , Vivien Didelot , Andrew Lunn Subject: [PATCH net-next 2/2] net: dsa: Set the master device's MTU to account for DSA overheads Date: Thu, 6 Dec 2018 11:36:05 +0100 Message-Id: <1544092565-11311-3-git-send-email-andrew@lunn.ch> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1544092565-11311-1-git-send-email-andrew@lunn.ch> References: <1544092565-11311-1-git-send-email-andrew@lunn.ch> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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"); + } + rtnl_unlock(); +} + int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp) { + dsa_master_set_mtu(dev, cpu_dp); + /* 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.