Skip to content

Commit dc0fe7d

Browse files
lunndavem330
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a5dd308 commit dc0fe7d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

net/dsa/master.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,24 @@ static void dsa_master_ethtool_teardown(struct net_device *dev)
158158
cpu_dp->orig_ethtool_ops = NULL;
159159
}
160160

161+
void dsa_master_set_mtu(struct net_device *dev, struct dsa_port *cpu_dp)
162+
{
163+
unsigned int mtu = ETH_DATA_LEN + cpu_dp->tag_ops->overhead;
164+
int err;
165+
166+
rtnl_lock();
167+
if (mtu <= dev->max_mtu) {
168+
err = dev_set_mtu(dev, mtu);
169+
if (err)
170+
netdev_dbg(dev, "Unable to set MTU to include for DSA overheads\n");
171+
}
172+
rtnl_unlock();
173+
}
174+
161175
int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp)
162176
{
177+
dsa_master_set_mtu(dev, cpu_dp);
178+
163179
/* If we use a tagging format that doesn't have an ethertype
164180
* field, make sure that all packets from this point on get
165181
* sent to the tag format's receive function.

0 commit comments

Comments
 (0)