aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Looijmans <mike.looijmans@topic.nl>2015-11-30 06:18:23 -0500
committerFelipe Balbi <balbi@ti.com>2015-12-16 11:07:30 -0500
commitab738ff1991d183a67c37ce38b3fc39cd28798c6 (patch)
tree9d171dd69b0ddf90c9534f1dbac9f6e9c2625ceb
parentf310abb33bf1e2e93f2b8d788b47100f07f1cf09 (diff)
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 bba787a860fa ("usb: gadget: ether: Allow jumbo frames") Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl> Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r--drivers/usb/gadget/function/u_ether.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c
index 6554322af2c1..637809e3bd0d 100644
--- a/drivers/usb/gadget/function/u_ether.c
+++ b/drivers/usb/gadget/function/u_ether.c
@@ -143,21 +143,11 @@ static inline int qlen(struct usb_gadget *gadget, unsigned qmult)
143 143
144static int ueth_change_mtu(struct net_device *net, int new_mtu) 144static int ueth_change_mtu(struct net_device *net, int new_mtu)
145{ 145{
146 struct eth_dev *dev = netdev_priv(net); 146 if (new_mtu <= ETH_HLEN || new_mtu > GETHER_MAX_ETH_FRAME_LEN)
147 unsigned long flags; 147 return -ERANGE;
148 int status = 0; 148 net->mtu = new_mtu;
149 149
150 /* don't change MTU on "live" link (peer won't know) */ 150 return 0;
151 spin_lock_irqsave(&dev->lock, flags);
152 if (dev->port_usb)
153 status = -EBUSY;
154 else if (new_mtu <= ETH_HLEN || new_mtu > GETHER_MAX_ETH_FRAME_LEN)
155 status = -ERANGE;
156 else
157 net->mtu = new_mtu;
158 spin_unlock_irqrestore(&dev->lock, flags);
159
160 return status;
161} 151}
162 152
163static void eth_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *p) 153static void eth_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *p)