summaryrefslogtreecommitdiff
path: root/net/dsa/master.c
diff options
context:
space:
mode:
authorAndrew Lunn <andrew@lunn.ch>2018-12-06 13:36:05 +0300
committerDavid S. Miller <davem@davemloft.net>2018-12-06 23:18:17 +0300
commitdc0fe7d47f9f2256e3aa695bb754625f37291e17 (patch)
tree8f91a4fdb046fea0ec14589399758a2a766156d7 /net/dsa/master.c
parenta5dd308778a4e05e7b0b927cf18b89d1ebbff59c (diff)
downloadlinux-dc0fe7d47f9f2256e3aa695bb754625f37291e17.tar.xz
net: dsa: Set the master device's MTU to account for DSA overheads
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 <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa/master.c')
-rw-r--r--net/dsa/master.c16
1 files changed, 16 insertions, 0 deletions
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.