2511e0a9614b771b4aaaa8d41dc99e1389215c6f
[openwrt/staging/jogo.git] /
1 From a4abd7a80addb4a9547f7dfc7812566b60ec505c Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Bj=C3=B8rn=20Mork?= <bjorn@mork.no>
3 Date: Wed, 6 Dec 2017 20:21:24 +0100
4 Subject: [PATCH] usbnet: fix alignment for frames with no ethernet header
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 The qmi_wwan minidriver support a 'raw-ip' mode where frames are
10 received without any ethernet header. This causes alignment issues
11 because the skbs allocated by usbnet are "IP aligned".
12
13 Fix by allowing minidrivers to disable the additional alignment
14 offset. This is implemented using a per-device flag, since the same
15 minidriver also supports 'ethernet' mode.
16
17 Fixes: 32f7adf633b9 ("net: qmi_wwan: support "raw IP" mode")
18 Reported-and-tested-by: Jay Foster <jay@systech.com>
19 Signed-off-by: Bjørn Mork <bjorn@mork.no>
20 Signed-off-by: David S. Miller <davem@davemloft.net>
21 ---
22 drivers/net/usb/qmi_wwan.c | 2 ++
23 drivers/net/usb/usbnet.c | 5 ++++-
24 include/linux/usb/usbnet.h | 1 +
25 3 files changed, 7 insertions(+), 1 deletion(-)
26
27 diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
28 index c750cf7c042b..304ec6555cd8 100644
29 --- a/drivers/net/usb/qmi_wwan.c
30 +++ b/drivers/net/usb/qmi_wwan.c
31 @@ -261,9 +261,11 @@ static void qmi_wwan_netdev_setup(struct net_device *net)
32 net->hard_header_len = 0;
33 net->addr_len = 0;
34 net->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST;
35 + set_bit(EVENT_NO_IP_ALIGN, &dev->flags);
36 netdev_dbg(net, "mode: raw IP\n");
37 } else if (!net->header_ops) { /* don't bother if already set */
38 ether_setup(net);
39 + clear_bit(EVENT_NO_IP_ALIGN, &dev->flags);
40 netdev_dbg(net, "mode: Ethernet\n");
41 }
42
43 diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
44 index 80348b6a8646..d56fe32bf48d 100644
45 --- a/drivers/net/usb/usbnet.c
46 +++ b/drivers/net/usb/usbnet.c
47 @@ -484,7 +484,10 @@ static int rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags)
48 return -ENOLINK;
49 }
50
51 - skb = __netdev_alloc_skb_ip_align(dev->net, size, flags);
52 + if (test_bit(EVENT_NO_IP_ALIGN, &dev->flags))
53 + skb = __netdev_alloc_skb(dev->net, size, flags);
54 + else
55 + skb = __netdev_alloc_skb_ip_align(dev->net, size, flags);
56 if (!skb) {
57 netif_dbg(dev, rx_err, dev->net, "no rx skb\n");
58 usbnet_defer_kevent (dev, EVENT_RX_MEMORY);
59 diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
60 index a69877734c4e..e2ec3582e549 100644
61 --- a/include/linux/usb/usbnet.h
62 +++ b/include/linux/usb/usbnet.h
63 @@ -82,6 +82,7 @@ struct usbnet {
64 # define EVENT_RX_KILL 10
65 # define EVENT_LINK_CHANGE 11
66 # define EVENT_SET_RX_MODE 12
67 +# define EVENT_NO_IP_ALIGN 13
68 };
69
70 static inline struct usb_driver *driver_of(struct usb_interface *intf)
71 --
72 2.7.4
73