usb: gadget: ether: Allow changing the MTU
PATCH 1/1 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".
--- drivers/usb/gadget/function/u_ether.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)
drivers/usb/gadget/function/u_ether.c +4 -12
@@ -144,20 +144,12 @@ static inline int qlen(struct usb_gadget *gadget, unsigned qmult)static int ueth_change_mtu (struct net_device *net,int new_mtu) {struct eth_dev *dev =netdev_priv (net); -unsigned long flags; -int status =0 ; -/* don't change MTU on "live" link (peer won't know) */ -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); +if (new_mtu <=ETH_HLEN || new_mtu >GETHER_MAX_ETH_FRAME_LEN ) +return -ERANGE ; + net->mtu = new_mtu; -return status; +return 0 ; }static void eth_get_drvinfo (struct net_device *net,struct ethtool_drvinfo *p)
Signature · 1 line
1.9.1
kbuild test robot
build botreproduce:
Hi Mike,
[auto build test WARNING on: balbi-usb/next] [also build test WARNING on: v4.4-rc3 next-20151127]
url: https://github.com/0day-ci/linux/commits/Mike-Looijmans/usb-gadget-ether-Allow-changing-the-MTU/20151130-162847 base: https://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git next config: i386-randconfig-s1-201548 (attached as .config) reproduce: # save the attached .config to linux build tree make ARCH=i386
All warnings (new ones prefixed by >>):
drivers/usb/gadget/function/u_ether.c: In function 'ueth_change_mtu':
>> drivers/usb/gadget/function/u_ether.c:146:18: warning: unused variable 'dev' [-Wunused-variable]
struct eth_dev *dev = netdev_priv(net);
^vim +/dev +146 drivers/usb/gadget/function/u_ether.c
2b3d942c drivers/usb/gadget/u_ether.c David Brownell 2008-06-19 130 #else
2b3d942c drivers/usb/gadget/u_ether.c David Brownell 2008-06-19 131 #define VDBG(dev, fmt, args...) \
2b3d942c drivers/usb/gadget/u_ether.c David Brownell 2008-06-19 132 do { } while (0)
2b3d942c drivers/usb/gadget/u_ether.c David Brownell 2008-06-19 133 #endif /* DEBUG */
2b3d942c drivers/usb/gadget/u_ether.c David Brownell 2008-06-19 134
2b3d942c drivers/usb/gadget/u_ether.c David Brownell 2008-06-19 135 #define ERROR(dev, fmt, args...) \
2b3d942c drivers/usb/gadget/u_ether.c David Brownell 2008-06-19 136 xprintk(dev , KERN_ERR , fmt , ## args)
2b3d942c drivers/usb/gadget/u_ether.c David Brownell 2008-06-19 137 #define INFO(dev, fmt, args...) \
2b3d942c drivers/usb/gadget/u_ether.c David Brownell 2008-06-19 138 xprintk(dev , KERN_INFO , fmt , ## args)
2b3d942c drivers/usb/gadget/u_ether.c David Brownell 2008-06-19 139
2b3d942c drivers/usb/gadget/u_ether.c David Brownell 2008-06-19 140 /*-------------------------------------------------------------------------*/
2b3d942c drivers/usb/gadget/u_ether.c David Brownell 2008-06-19 141
2b3d942c drivers/usb/gadget/u_ether.c David Brownell 2008-06-19 142 /* NETWORK DRIVER HOOKUP (to the layer above this driver) */
2b3d942c drivers/usb/gadget/u_ether.c David Brownell 2008-06-19 143
ccad637b drivers/usb/gadget/u_ether.c Stephen Hemminger 2008-11-19 144 static int ueth_change_mtu(struct net_device *net, int new_mtu)
2b3d942c drivers/usb/gadget/u_ether.c David Brownell 2008-06-19 145 {
2b3d942c drivers/usb/gadget/u_ether.c David Brownell 2008-06-19 @146 struct eth_dev *dev = netdev_priv(net);
1616c4ef drivers/usb/gadget/function/u_ether.c Mike Looijmans 2015-11-30 147
1616c4ef drivers/usb/gadget/function/u_ether.c Mike Looijmans 2015-11-30 148 if (new_mtu <= ETH_HLEN || new_mtu > GETHER_MAX_ETH_FRAME_LEN)
1616c4ef drivers/usb/gadget/function/u_ether.c Mike Looijmans 2015-11-30 149 return -ERANGE;
2b3d942c drivers/usb/gadget/u_ether.c David Brownell 2008-06-19 150 net->mtu = new_mtu;
2b3d942c drivers/usb/gadget/u_ether.c David Brownell 2008-06-19 151
1616c4ef drivers/usb/gadget/function/u_ether.c Mike Looijmans 2015-11-30 152 return 0;
2b3d942c drivers/usb/gadget/u_ether.c David Brownell 2008-06-19 153 }
2b3d942c drivers/usb/gadget/u_ether.c David Brownell 2008-06-19 154 :::::: The code at line 146 was first introduced by commit
:::::: 2b3d942c4878084a37991a65e66512c02b8fa2ad usb ethernet gadget: split out network core
:::::: TO: David Brownell <[email protected]> :::::: CC: Greg Kroah-Hartman <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation