* [PATCH] usb: gadget: ether: Allow changing the MTU
@ 2015-11-30 8:25 Mike Looijmans
2015-11-30 9:14 ` kbuild test robot
0 siblings, 1 reply; 2+ messages in thread
From: Mike Looijmans @ 2015-11-30 8:25 UTC (permalink / raw)
To: linux-usb; +Cc: balbi, gregkh, linux-kernel, Mike Looijmans
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>
---
drivers/usb/gadget/function/u_ether.c | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c
index 6554322..9c60e57 100644
--- a/drivers/usb/gadget/function/u_ether.c
+++ b/drivers/usb/gadget/function/u_ether.c
@@ -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)
--
1.9.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] usb: gadget: ether: Allow changing the MTU
2015-11-30 8:25 [PATCH] usb: gadget: ether: Allow changing the MTU Mike Looijmans
@ 2015-11-30 9:14 ` kbuild test robot
0 siblings, 0 replies; 2+ messages in thread
From: kbuild test robot @ 2015-11-30 9:14 UTC (permalink / raw)
To: Mike Looijmans
Cc: kbuild-all, linux-usb, balbi, gregkh, linux-kernel, Mike Looijmans
[-- Attachment #1: Type: text/plain, Size: 3858 bytes --]
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 <dbrownell@users.sourceforge.net>
:::::: CC: Greg Kroah-Hartman <gregkh@suse.de>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 23955 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-11-30 9:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-30 8:25 [PATCH] usb: gadget: ether: Allow changing the MTU Mike Looijmans
2015-11-30 9:14 ` kbuild test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®