usb: gadget: ether: Allow changing the MTU

The gadget ethernet driver supports changing the MTU, but only allows this
when the USB cable is removed. The comment indicates that this is because
the "peer won't know". Even if the network link is still down and only the
USB link is established, the driver won't allow the change.

Other network interfaces allow changing the MTU any time, and don't force
the link to be disabled. This makes perfect sense, because in order to be
able to negotiate the MTU, the link needs to be up.

Remove the restriction so that it is now actually possible to change the
MTU (e.g. using "ifconfig usb0 mtu 15000") without having to manually pull
the plug or change the driver's default setting.

This is especially important after commit bba787a860
("usb: gadget: ether: Allow jumbo frames")

Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl>
Signed-off-by: Felipe Balbi <balbi@ti.com>
This commit is contained in:
Mike Looijmans 2015-11-30 12:18:23 +01:00 committed by Felipe Balbi
parent f310abb33b
commit ab738ff199
1 changed files with 4 additions and 14 deletions

View File

@ -143,21 +143,11 @@ static inline int qlen(struct usb_gadget *gadget, unsigned qmult)
static int ueth_change_mtu(struct net_device *net, int new_mtu) static int ueth_change_mtu(struct net_device *net, int new_mtu)
{ {
struct eth_dev *dev = netdev_priv(net); if (new_mtu <= ETH_HLEN || new_mtu > GETHER_MAX_ETH_FRAME_LEN)
unsigned long flags; return -ERANGE;
int status = 0; net->mtu = new_mtu;
/* don't change MTU on "live" link (peer won't know) */ return 0;
spin_lock_irqsave(&dev->lock, flags);
if (dev->port_usb)
status = -EBUSY;
else if (new_mtu <= ETH_HLEN || new_mtu > GETHER_MAX_ETH_FRAME_LEN)
status = -ERANGE;
else
net->mtu = new_mtu;
spin_unlock_irqrestore(&dev->lock, flags);
return status;
} }
static void eth_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *p) static void eth_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *p)