4 * Copyright (C) ST-Ericsson 2010-2012
5 * Contact: Alexey Orishko <alexey.orishko@stericsson.com>
6 * Original author: Hans Petter Selasky <hans.petter.selasky@stericsson.com>
8 * USB Host Driver for Network Control Model (NCM)
9 * http://www.usb.org/developers/devclass_docs/NCM10.zip
11 * The NCM encoding, decoding and initialization logic
12 * derives from FreeBSD 8.x. if_cdce.c and if_cdcereg.h
14 * This software is available to you under a choice of one of two
15 * licenses. You may choose this file to be licensed under the terms
16 * of the GNU General Public License (GPL) Version 2 or the 2-clause
17 * BSD license listed below:
19 * Redistribution and use in source and binary forms, with or without
20 * modification, are permitted provided that the following conditions
22 * 1. Redistributions of source code must retain the above copyright
23 * notice, this list of conditions and the following disclaimer.
24 * 2. Redistributions in binary form must reproduce the above copyright
25 * notice, this list of conditions and the following disclaimer in the
26 * documentation and/or other materials provided with the distribution.
28 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
29 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
32 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
41 #include <linux/module.h>
42 #include <linux/init.h>
43 #include <linux/netdevice.h>
44 #include <linux/ctype.h>
45 #include <linux/ethtool.h>
46 #include <linux/workqueue.h>
47 #include <linux/mii.h>
48 #include <linux/crc32.h>
49 #include <linux/usb.h>
50 #include <linux/hrtimer.h>
51 #include <linux/atomic.h>
52 #include <linux/usb/usbnet.h>
53 #include <linux/usb/cdc.h>
54 #include <linux/usb/cdc_ncm.h>
56 #if IS_ENABLED(CONFIG_USB_NET_CDC_MBIM)
57 static bool prefer_mbim
= true;
59 static bool prefer_mbim
;
61 module_param(prefer_mbim
, bool, S_IRUGO
| S_IWUSR
);
62 MODULE_PARM_DESC(prefer_mbim
, "Prefer MBIM setting on dual NCM/MBIM functions");
64 static void cdc_ncm_txpath_bh(unsigned long param
);
65 static void cdc_ncm_tx_timeout_start(struct cdc_ncm_ctx
*ctx
);
66 static enum hrtimer_restart
cdc_ncm_tx_timer_cb(struct hrtimer
*hr_timer
);
67 static struct usb_driver cdc_ncm_driver
;
69 static u8
cdc_ncm_setup(struct usbnet
*dev
)
71 struct cdc_ncm_ctx
*ctx
= (struct cdc_ncm_ctx
*)dev
->data
[0];
72 struct usb_cdc_ncm_ntb_parameters ncm_parm
;
78 u16 ntb_fmt_supported
;
82 iface_no
= ctx
->control
->cur_altsetting
->desc
.bInterfaceNumber
;
84 err
= usbnet_read_cmd(dev
, USB_CDC_GET_NTB_PARAMETERS
,
85 USB_TYPE_CLASS
| USB_DIR_IN
87 0, iface_no
, &ncm_parm
,
90 dev_dbg(&dev
->intf
->dev
, "failed GET_NTB_PARAMETERS\n");
94 /* read correct set of parameters according to device mode */
95 ctx
->rx_max
= le32_to_cpu(ncm_parm
.dwNtbInMaxSize
);
96 ctx
->tx_max
= le32_to_cpu(ncm_parm
.dwNtbOutMaxSize
);
97 ctx
->tx_remainder
= le16_to_cpu(ncm_parm
.wNdpOutPayloadRemainder
);
98 ctx
->tx_modulus
= le16_to_cpu(ncm_parm
.wNdpOutDivisor
);
99 ctx
->tx_ndp_modulus
= le16_to_cpu(ncm_parm
.wNdpOutAlignment
);
100 /* devices prior to NCM Errata shall set this field to zero */
101 ctx
->tx_max_datagrams
= le16_to_cpu(ncm_parm
.wNtbOutMaxDatagrams
);
102 ntb_fmt_supported
= le16_to_cpu(ncm_parm
.bmNtbFormatsSupported
);
105 min_dgram_size
= CDC_NCM_MIN_DATAGRAM_SIZE
;
106 min_hdr_size
= CDC_NCM_MIN_HDR_SIZE
;
107 if (ctx
->mbim_desc
!= NULL
) {
108 flags
= ctx
->mbim_desc
->bmNetworkCapabilities
;
110 min_dgram_size
= CDC_MBIM_MIN_DATAGRAM_SIZE
;
112 } else if (ctx
->func_desc
!= NULL
) {
113 flags
= ctx
->func_desc
->bmNetworkCapabilities
;
118 dev_dbg(&dev
->intf
->dev
,
119 "dwNtbInMaxSize=%u dwNtbOutMaxSize=%u wNdpOutPayloadRemainder=%u wNdpOutDivisor=%u wNdpOutAlignment=%u wNtbOutMaxDatagrams=%u flags=0x%x\n",
120 ctx
->rx_max
, ctx
->tx_max
, ctx
->tx_remainder
, ctx
->tx_modulus
,
121 ctx
->tx_ndp_modulus
, ctx
->tx_max_datagrams
, flags
);
123 /* max count of tx datagrams */
124 if ((ctx
->tx_max_datagrams
== 0) ||
125 (ctx
->tx_max_datagrams
> CDC_NCM_DPT_DATAGRAMS_MAX
))
126 ctx
->tx_max_datagrams
= CDC_NCM_DPT_DATAGRAMS_MAX
;
128 /* verify maximum size of received NTB in bytes */
129 if (ctx
->rx_max
< USB_CDC_NCM_NTB_MIN_IN_SIZE
) {
130 dev_dbg(&dev
->intf
->dev
, "Using min receive length=%d\n",
131 USB_CDC_NCM_NTB_MIN_IN_SIZE
);
132 ctx
->rx_max
= USB_CDC_NCM_NTB_MIN_IN_SIZE
;
135 if (ctx
->rx_max
> CDC_NCM_NTB_MAX_SIZE_RX
) {
136 dev_dbg(&dev
->intf
->dev
, "Using default maximum receive length=%d\n",
137 CDC_NCM_NTB_MAX_SIZE_RX
);
138 ctx
->rx_max
= CDC_NCM_NTB_MAX_SIZE_RX
;
141 /* inform device about NTB input size changes */
142 if (ctx
->rx_max
!= le32_to_cpu(ncm_parm
.dwNtbInMaxSize
)) {
143 __le32 dwNtbInMaxSize
= cpu_to_le32(ctx
->rx_max
);
145 err
= usbnet_write_cmd(dev
, USB_CDC_SET_NTB_INPUT_SIZE
,
146 USB_TYPE_CLASS
| USB_DIR_OUT
147 | USB_RECIP_INTERFACE
,
148 0, iface_no
, &dwNtbInMaxSize
, 4);
150 dev_dbg(&dev
->intf
->dev
, "Setting NTB Input Size failed\n");
153 /* verify maximum size of transmitted NTB in bytes */
155 (min_hdr_size
+ min_dgram_size
)) ||
156 (ctx
->tx_max
> CDC_NCM_NTB_MAX_SIZE_TX
)) {
157 dev_dbg(&dev
->intf
->dev
, "Using default maximum transmit length=%d\n",
158 CDC_NCM_NTB_MAX_SIZE_TX
);
159 ctx
->tx_max
= CDC_NCM_NTB_MAX_SIZE_TX
;
161 /* Adding a pad byte here simplifies the handling in
162 * cdc_ncm_fill_tx_frame, by making tx_max always
163 * represent the real skb max size.
165 if (ctx
->tx_max
% usb_maxpacket(dev
->udev
, dev
->out
, 1) == 0)
171 * verify that the structure alignment is:
173 * - not greater than the maximum transmit length
174 * - not less than four bytes
176 val
= ctx
->tx_ndp_modulus
;
178 if ((val
< USB_CDC_NCM_NDP_ALIGN_MIN_SIZE
) ||
179 (val
!= ((-val
) & val
)) || (val
>= ctx
->tx_max
)) {
180 dev_dbg(&dev
->intf
->dev
, "Using default alignment: 4 bytes\n");
181 ctx
->tx_ndp_modulus
= USB_CDC_NCM_NDP_ALIGN_MIN_SIZE
;
185 * verify that the payload alignment is:
187 * - not greater than the maximum transmit length
188 * - not less than four bytes
190 val
= ctx
->tx_modulus
;
192 if ((val
< USB_CDC_NCM_NDP_ALIGN_MIN_SIZE
) ||
193 (val
!= ((-val
) & val
)) || (val
>= ctx
->tx_max
)) {
194 dev_dbg(&dev
->intf
->dev
, "Using default transmit modulus: 4 bytes\n");
195 ctx
->tx_modulus
= USB_CDC_NCM_NDP_ALIGN_MIN_SIZE
;
198 /* verify the payload remainder */
199 if (ctx
->tx_remainder
>= ctx
->tx_modulus
) {
200 dev_dbg(&dev
->intf
->dev
, "Using default transmit remainder: 0 bytes\n");
201 ctx
->tx_remainder
= 0;
204 /* adjust TX-remainder according to NCM specification. */
205 ctx
->tx_remainder
= ((ctx
->tx_remainder
- eth_hlen
) &
206 (ctx
->tx_modulus
- 1));
208 /* additional configuration */
211 if (flags
& USB_CDC_NCM_NCAP_CRC_MODE
) {
212 err
= usbnet_write_cmd(dev
, USB_CDC_SET_CRC_MODE
,
213 USB_TYPE_CLASS
| USB_DIR_OUT
214 | USB_RECIP_INTERFACE
,
215 USB_CDC_NCM_CRC_NOT_APPENDED
,
218 dev_dbg(&dev
->intf
->dev
, "Setting CRC mode off failed\n");
221 /* set NTB format, if both formats are supported */
222 if (ntb_fmt_supported
& USB_CDC_NCM_NTH32_SIGN
) {
223 err
= usbnet_write_cmd(dev
, USB_CDC_SET_NTB_FORMAT
,
224 USB_TYPE_CLASS
| USB_DIR_OUT
225 | USB_RECIP_INTERFACE
,
226 USB_CDC_NCM_NTB16_FORMAT
,
229 dev_dbg(&dev
->intf
->dev
, "Setting NTB format to 16-bit failed\n");
232 ctx
->max_datagram_size
= min_dgram_size
;
234 /* set Max Datagram Size (MTU) */
235 if (flags
& USB_CDC_NCM_NCAP_MAX_DATAGRAM_SIZE
) {
236 __le16 max_datagram_size
;
238 if (ctx
->ether_desc
!= NULL
)
239 eth_max_sz
= le16_to_cpu(ctx
->ether_desc
->wMaxSegmentSize
);
240 else if (ctx
->mbim_desc
!= NULL
)
241 eth_max_sz
= le16_to_cpu(ctx
->mbim_desc
->wMaxSegmentSize
);
245 err
= usbnet_read_cmd(dev
, USB_CDC_GET_MAX_DATAGRAM_SIZE
,
246 USB_TYPE_CLASS
| USB_DIR_IN
247 | USB_RECIP_INTERFACE
,
248 0, iface_no
, &max_datagram_size
, 2);
250 dev_dbg(&dev
->intf
->dev
, "GET_MAX_DATAGRAM_SIZE failed, use size=%u\n",
253 ctx
->max_datagram_size
=
254 le16_to_cpu(max_datagram_size
);
255 /* Check Eth descriptor value */
256 if (ctx
->max_datagram_size
> eth_max_sz
)
257 ctx
->max_datagram_size
= eth_max_sz
;
259 if (ctx
->max_datagram_size
> CDC_NCM_MAX_DATAGRAM_SIZE
)
260 ctx
->max_datagram_size
= CDC_NCM_MAX_DATAGRAM_SIZE
;
262 if (ctx
->max_datagram_size
< min_dgram_size
)
263 ctx
->max_datagram_size
= min_dgram_size
;
265 /* if value changed, update device */
266 if (ctx
->max_datagram_size
!=
267 le16_to_cpu(max_datagram_size
)) {
268 max_datagram_size
= cpu_to_le16(ctx
->max_datagram_size
);
269 err
= usbnet_write_cmd(dev
,
270 USB_CDC_SET_MAX_DATAGRAM_SIZE
,
271 USB_TYPE_CLASS
| USB_DIR_OUT
272 | USB_RECIP_INTERFACE
,
274 iface_no
, &max_datagram_size
,
277 dev_dbg(&dev
->intf
->dev
, "SET_MAX_DGRAM_SIZE failed\n");
283 if (dev
->net
->mtu
!= (ctx
->max_datagram_size
- eth_hlen
))
284 dev
->net
->mtu
= ctx
->max_datagram_size
- eth_hlen
;
290 cdc_ncm_find_endpoints(struct usbnet
*dev
, struct usb_interface
*intf
)
292 struct usb_host_endpoint
*e
, *in
= NULL
, *out
= NULL
;
295 for (ep
= 0; ep
< intf
->cur_altsetting
->desc
.bNumEndpoints
; ep
++) {
297 e
= intf
->cur_altsetting
->endpoint
+ ep
;
298 switch (e
->desc
.bmAttributes
& USB_ENDPOINT_XFERTYPE_MASK
) {
299 case USB_ENDPOINT_XFER_INT
:
300 if (usb_endpoint_dir_in(&e
->desc
)) {
306 case USB_ENDPOINT_XFER_BULK
:
307 if (usb_endpoint_dir_in(&e
->desc
)) {
321 dev
->in
= usb_rcvbulkpipe(dev
->udev
,
322 in
->desc
.bEndpointAddress
&
323 USB_ENDPOINT_NUMBER_MASK
);
324 if (out
&& !dev
->out
)
325 dev
->out
= usb_sndbulkpipe(dev
->udev
,
326 out
->desc
.bEndpointAddress
&
327 USB_ENDPOINT_NUMBER_MASK
);
330 static void cdc_ncm_free(struct cdc_ncm_ctx
*ctx
)
335 if (ctx
->tx_rem_skb
!= NULL
) {
336 dev_kfree_skb_any(ctx
->tx_rem_skb
);
337 ctx
->tx_rem_skb
= NULL
;
340 if (ctx
->tx_curr_skb
!= NULL
) {
341 dev_kfree_skb_any(ctx
->tx_curr_skb
);
342 ctx
->tx_curr_skb
= NULL
;
348 int cdc_ncm_bind_common(struct usbnet
*dev
, struct usb_interface
*intf
, u8 data_altsetting
)
350 const struct usb_cdc_union_desc
*union_desc
= NULL
;
351 struct cdc_ncm_ctx
*ctx
;
352 struct usb_driver
*driver
;
358 ctx
= kzalloc(sizeof(*ctx
), GFP_KERNEL
);
362 hrtimer_init(&ctx
->tx_timer
, CLOCK_MONOTONIC
, HRTIMER_MODE_REL
);
363 ctx
->tx_timer
.function
= &cdc_ncm_tx_timer_cb
;
364 ctx
->bh
.data
= (unsigned long)dev
;
365 ctx
->bh
.func
= cdc_ncm_txpath_bh
;
366 atomic_set(&ctx
->stop
, 0);
367 spin_lock_init(&ctx
->mtx
);
369 /* store ctx pointer in device data field */
370 dev
->data
[0] = (unsigned long)ctx
;
372 /* only the control interface can be successfully probed */
375 /* get some pointers */
376 driver
= driver_of(intf
);
377 buf
= intf
->cur_altsetting
->extra
;
378 len
= intf
->cur_altsetting
->extralen
;
380 /* parse through descriptors associated with control interface */
381 while ((len
> 0) && (buf
[0] > 2) && (buf
[0] <= len
)) {
383 if (buf
[1] != USB_DT_CS_INTERFACE
)
387 case USB_CDC_UNION_TYPE
:
388 if (buf
[0] < sizeof(*union_desc
))
391 union_desc
= (const struct usb_cdc_union_desc
*)buf
;
392 /* the master must be the interface we are probing */
393 if (intf
->cur_altsetting
->desc
.bInterfaceNumber
!=
394 union_desc
->bMasterInterface0
)
396 ctx
->data
= usb_ifnum_to_if(dev
->udev
,
397 union_desc
->bSlaveInterface0
);
400 case USB_CDC_ETHERNET_TYPE
:
401 if (buf
[0] < sizeof(*(ctx
->ether_desc
)))
405 (const struct usb_cdc_ether_desc
*)buf
;
408 case USB_CDC_NCM_TYPE
:
409 if (buf
[0] < sizeof(*(ctx
->func_desc
)))
412 ctx
->func_desc
= (const struct usb_cdc_ncm_desc
*)buf
;
415 case USB_CDC_MBIM_TYPE
:
416 if (buf
[0] < sizeof(*(ctx
->mbim_desc
)))
419 ctx
->mbim_desc
= (const struct usb_cdc_mbim_desc
*)buf
;
426 /* advance to next descriptor */
432 /* some buggy devices have an IAD but no CDC Union */
433 if (!union_desc
&& intf
->intf_assoc
&& intf
->intf_assoc
->bInterfaceCount
== 2) {
434 ctx
->data
= usb_ifnum_to_if(dev
->udev
, intf
->cur_altsetting
->desc
.bInterfaceNumber
+ 1);
435 dev_dbg(&intf
->dev
, "CDC Union missing - got slave from IAD\n");
438 /* check if we got everything */
439 if (!ctx
->data
|| (!ctx
->mbim_desc
&& !ctx
->ether_desc
))
442 /* claim data interface, if different from control */
443 if (ctx
->data
!= ctx
->control
) {
444 temp
= usb_driver_claim_interface(driver
, ctx
->data
, dev
);
449 iface_no
= ctx
->data
->cur_altsetting
->desc
.bInterfaceNumber
;
451 /* reset data interface */
452 temp
= usb_set_interface(dev
->udev
, iface_no
, 0);
456 /* configure data interface */
457 temp
= usb_set_interface(dev
->udev
, iface_no
, data_altsetting
);
461 cdc_ncm_find_endpoints(dev
, ctx
->data
);
462 cdc_ncm_find_endpoints(dev
, ctx
->control
);
463 if (!dev
->in
|| !dev
->out
|| !dev
->status
)
466 /* initialize data interface */
467 if (cdc_ncm_setup(dev
))
470 usb_set_intfdata(ctx
->data
, dev
);
471 usb_set_intfdata(ctx
->control
, dev
);
473 if (ctx
->ether_desc
) {
474 temp
= usbnet_get_ethernet_addr(dev
, ctx
->ether_desc
->iMACAddress
);
477 dev_info(&dev
->udev
->dev
, "MAC-Address: %pM\n", dev
->net
->dev_addr
);
480 /* usbnet use these values for sizing tx/rx queues */
481 dev
->hard_mtu
= ctx
->tx_max
;
482 dev
->rx_urb_size
= ctx
->rx_max
;
487 usb_set_intfdata(ctx
->control
, NULL
);
488 usb_set_intfdata(ctx
->data
, NULL
);
489 if (ctx
->data
!= ctx
->control
)
490 usb_driver_release_interface(driver
, ctx
->data
);
492 cdc_ncm_free((struct cdc_ncm_ctx
*)dev
->data
[0]);
494 dev_info(&dev
->udev
->dev
, "bind() failure\n");
497 EXPORT_SYMBOL_GPL(cdc_ncm_bind_common
);
499 void cdc_ncm_unbind(struct usbnet
*dev
, struct usb_interface
*intf
)
501 struct cdc_ncm_ctx
*ctx
= (struct cdc_ncm_ctx
*)dev
->data
[0];
502 struct usb_driver
*driver
= driver_of(intf
);
505 return; /* no setup */
507 atomic_set(&ctx
->stop
, 1);
509 if (hrtimer_active(&ctx
->tx_timer
))
510 hrtimer_cancel(&ctx
->tx_timer
);
512 tasklet_kill(&ctx
->bh
);
514 /* handle devices with combined control and data interface */
515 if (ctx
->control
== ctx
->data
)
518 /* disconnect master --> disconnect slave */
519 if (intf
== ctx
->control
&& ctx
->data
) {
520 usb_set_intfdata(ctx
->data
, NULL
);
521 usb_driver_release_interface(driver
, ctx
->data
);
524 } else if (intf
== ctx
->data
&& ctx
->control
) {
525 usb_set_intfdata(ctx
->control
, NULL
);
526 usb_driver_release_interface(driver
, ctx
->control
);
530 usb_set_intfdata(intf
, NULL
);
533 EXPORT_SYMBOL_GPL(cdc_ncm_unbind
);
535 /* Select the MBIM altsetting iff it is preferred and available,
536 * returning the number of the corresponding data interface altsetting
538 u8
cdc_ncm_select_altsetting(struct usbnet
*dev
, struct usb_interface
*intf
)
540 struct usb_host_interface
*alt
;
542 /* The MBIM spec defines a NCM compatible default altsetting,
543 * which we may have matched:
545 * "Functions that implement both NCM 1.0 and MBIM (an
546 * “NCM/MBIM function”) according to this recommendation
547 * shall provide two alternate settings for the
548 * Communication Interface. Alternate setting 0, and the
549 * associated class and endpoint descriptors, shall be
550 * constructed according to the rules given for the
551 * Communication Interface in section 5 of [USBNCM10].
552 * Alternate setting 1, and the associated class and
553 * endpoint descriptors, shall be constructed according to
554 * the rules given in section 6 (USB Device Model) of this
557 if (prefer_mbim
&& intf
->num_altsetting
== 2) {
558 alt
= usb_altnum_to_altsetting(intf
, CDC_NCM_COMM_ALTSETTING_MBIM
);
559 if (alt
&& cdc_ncm_comm_intf_is_mbim(alt
) &&
560 !usb_set_interface(dev
->udev
,
561 intf
->cur_altsetting
->desc
.bInterfaceNumber
,
562 CDC_NCM_COMM_ALTSETTING_MBIM
))
563 return CDC_NCM_DATA_ALTSETTING_MBIM
;
565 return CDC_NCM_DATA_ALTSETTING_NCM
;
567 EXPORT_SYMBOL_GPL(cdc_ncm_select_altsetting
);
569 static int cdc_ncm_bind(struct usbnet
*dev
, struct usb_interface
*intf
)
573 /* MBIM backwards compatible function? */
574 cdc_ncm_select_altsetting(dev
, intf
);
575 if (cdc_ncm_comm_intf_is_mbim(intf
->cur_altsetting
))
578 /* NCM data altsetting is always 1 */
579 ret
= cdc_ncm_bind_common(dev
, intf
, 1);
582 * We should get an event when network connection is "connected" or
583 * "disconnected". Set network connection in "disconnected" state
584 * (carrier is OFF) during attach, so the IP network stack does not
585 * start IPv6 negotiation and more.
587 usbnet_link_change(dev
, 0, 0);
591 static void cdc_ncm_align_tail(struct sk_buff
*skb
, size_t modulus
, size_t remainder
, size_t max
)
593 size_t align
= ALIGN(skb
->len
, modulus
) - skb
->len
+ remainder
;
595 if (skb
->len
+ align
> max
)
596 align
= max
- skb
->len
;
597 if (align
&& skb_tailroom(skb
) >= align
)
598 memset(skb_put(skb
, align
), 0, align
);
601 /* return a pointer to a valid struct usb_cdc_ncm_ndp16 of type sign, possibly
602 * allocating a new one within skb
604 static struct usb_cdc_ncm_ndp16
*cdc_ncm_ndp(struct cdc_ncm_ctx
*ctx
, struct sk_buff
*skb
, __le32 sign
, size_t reserve
)
606 struct usb_cdc_ncm_ndp16
*ndp16
= NULL
;
607 struct usb_cdc_ncm_nth16
*nth16
= (void *)skb
->data
;
608 size_t ndpoffset
= le16_to_cpu(nth16
->wNdpIndex
);
610 /* follow the chain of NDPs, looking for a match */
612 ndp16
= (struct usb_cdc_ncm_ndp16
*)(skb
->data
+ ndpoffset
);
613 if (ndp16
->dwSignature
== sign
)
615 ndpoffset
= le16_to_cpu(ndp16
->wNextNdpIndex
);
619 cdc_ncm_align_tail(skb
, ctx
->tx_ndp_modulus
, 0, ctx
->tx_max
);
621 /* verify that there is room for the NDP and the datagram (reserve) */
622 if ((ctx
->tx_max
- skb
->len
- reserve
) < CDC_NCM_NDP_SIZE
)
627 ndp16
->wNextNdpIndex
= cpu_to_le16(skb
->len
);
629 nth16
->wNdpIndex
= cpu_to_le16(skb
->len
);
631 /* push a new empty NDP */
632 ndp16
= (struct usb_cdc_ncm_ndp16
*)memset(skb_put(skb
, CDC_NCM_NDP_SIZE
), 0, CDC_NCM_NDP_SIZE
);
633 ndp16
->dwSignature
= sign
;
634 ndp16
->wLength
= cpu_to_le16(sizeof(struct usb_cdc_ncm_ndp16
) + sizeof(struct usb_cdc_ncm_dpe16
));
639 cdc_ncm_fill_tx_frame(struct usbnet
*dev
, struct sk_buff
*skb
, __le32 sign
)
641 struct cdc_ncm_ctx
*ctx
= (struct cdc_ncm_ctx
*)dev
->data
[0];
642 struct usb_cdc_ncm_nth16
*nth16
;
643 struct usb_cdc_ncm_ndp16
*ndp16
;
644 struct sk_buff
*skb_out
;
645 u16 n
= 0, index
, ndplen
;
648 /* if there is a remaining skb, it gets priority */
650 swap(skb
, ctx
->tx_rem_skb
);
651 swap(sign
, ctx
->tx_rem_sign
);
656 /* check if we are resuming an OUT skb */
657 skb_out
= ctx
->tx_curr_skb
;
659 /* allocate a new OUT skb */
661 skb_out
= alloc_skb(ctx
->tx_max
, GFP_ATOMIC
);
662 if (skb_out
== NULL
) {
664 dev_kfree_skb_any(skb
);
665 dev
->net
->stats
.tx_dropped
++;
669 /* fill out the initial 16-bit NTB header */
670 nth16
= (struct usb_cdc_ncm_nth16
*)memset(skb_put(skb_out
, sizeof(struct usb_cdc_ncm_nth16
)), 0, sizeof(struct usb_cdc_ncm_nth16
));
671 nth16
->dwSignature
= cpu_to_le32(USB_CDC_NCM_NTH16_SIGN
);
672 nth16
->wHeaderLength
= cpu_to_le16(sizeof(struct usb_cdc_ncm_nth16
));
673 nth16
->wSequence
= cpu_to_le16(ctx
->tx_seq
++);
675 /* count total number of frames in this NTB */
676 ctx
->tx_curr_frame_num
= 0;
679 for (n
= ctx
->tx_curr_frame_num
; n
< ctx
->tx_max_datagrams
; n
++) {
680 /* send any remaining skb first */
682 skb
= ctx
->tx_rem_skb
;
683 sign
= ctx
->tx_rem_sign
;
684 ctx
->tx_rem_skb
= NULL
;
686 /* check for end of skb */
691 /* get the appropriate NDP for this skb */
692 ndp16
= cdc_ncm_ndp(ctx
, skb_out
, sign
, skb
->len
+ ctx
->tx_modulus
+ ctx
->tx_remainder
);
694 /* align beginning of next frame */
695 cdc_ncm_align_tail(skb_out
, ctx
->tx_modulus
, ctx
->tx_remainder
, ctx
->tx_max
);
697 /* check if we had enough room left for both NDP and frame */
698 if (!ndp16
|| skb_out
->len
+ skb
->len
> ctx
->tx_max
) {
700 /* won't fit, MTU problem? */
701 dev_kfree_skb_any(skb
);
703 dev
->net
->stats
.tx_dropped
++;
705 /* no room for skb - store for later */
706 if (ctx
->tx_rem_skb
!= NULL
) {
707 dev_kfree_skb_any(ctx
->tx_rem_skb
);
708 dev
->net
->stats
.tx_dropped
++;
710 ctx
->tx_rem_skb
= skb
;
711 ctx
->tx_rem_sign
= sign
;
718 /* calculate frame number withing this NDP */
719 ndplen
= le16_to_cpu(ndp16
->wLength
);
720 index
= (ndplen
- sizeof(struct usb_cdc_ncm_ndp16
)) / sizeof(struct usb_cdc_ncm_dpe16
) - 1;
722 /* OK, add this skb */
723 ndp16
->dpe16
[index
].wDatagramLength
= cpu_to_le16(skb
->len
);
724 ndp16
->dpe16
[index
].wDatagramIndex
= cpu_to_le16(skb_out
->len
);
725 ndp16
->wLength
= cpu_to_le16(ndplen
+ sizeof(struct usb_cdc_ncm_dpe16
));
726 memcpy(skb_put(skb_out
, skb
->len
), skb
->data
, skb
->len
);
727 dev_kfree_skb_any(skb
);
730 /* send now if this NDP is full */
731 if (index
>= CDC_NCM_DPT_DATAGRAMS_MAX
) {
737 /* free up any dangling skb */
739 dev_kfree_skb_any(skb
);
741 dev
->net
->stats
.tx_dropped
++;
744 ctx
->tx_curr_frame_num
= n
;
747 /* wait for more frames */
749 ctx
->tx_curr_skb
= skb_out
;
752 } else if ((n
< ctx
->tx_max_datagrams
) && (ready2send
== 0)) {
753 /* wait for more frames */
755 ctx
->tx_curr_skb
= skb_out
;
756 /* set the pending count */
757 if (n
< CDC_NCM_RESTART_TIMER_DATAGRAM_CNT
)
758 ctx
->tx_timer_pending
= CDC_NCM_TIMER_PENDING_CNT
;
763 /* variables will be reset at next call */
766 /* If collected data size is less or equal CDC_NCM_MIN_TX_PKT
767 * bytes, we send buffers as it is. If we get more data, it
768 * would be more efficient for USB HS mobile device with DMA
769 * engine to receive a full size NTB, than canceling DMA
770 * transfer and receiving a short packet.
772 * This optimization support is pointless if we end up sending
773 * a ZLP after full sized NTBs.
775 if (!(dev
->driver_info
->flags
& FLAG_SEND_ZLP
) &&
776 skb_out
->len
> CDC_NCM_MIN_TX_PKT
)
777 memset(skb_put(skb_out
, ctx
->tx_max
- skb_out
->len
), 0,
778 ctx
->tx_max
- skb_out
->len
);
779 else if ((skb_out
->len
% dev
->maxpacket
) == 0)
780 *skb_put(skb_out
, 1) = 0; /* force short packet */
782 /* set final frame length */
783 nth16
= (struct usb_cdc_ncm_nth16
*)skb_out
->data
;
784 nth16
->wBlockLength
= cpu_to_le16(skb_out
->len
);
787 ctx
->tx_curr_skb
= NULL
;
788 dev
->net
->stats
.tx_packets
+= ctx
->tx_curr_frame_num
;
792 /* Start timer, if there is a remaining skb */
793 if (ctx
->tx_curr_skb
!= NULL
)
794 cdc_ncm_tx_timeout_start(ctx
);
797 EXPORT_SYMBOL_GPL(cdc_ncm_fill_tx_frame
);
799 static void cdc_ncm_tx_timeout_start(struct cdc_ncm_ctx
*ctx
)
801 /* start timer, if not already started */
802 if (!(hrtimer_active(&ctx
->tx_timer
) || atomic_read(&ctx
->stop
)))
803 hrtimer_start(&ctx
->tx_timer
,
804 ktime_set(0, CDC_NCM_TIMER_INTERVAL
),
808 static enum hrtimer_restart
cdc_ncm_tx_timer_cb(struct hrtimer
*timer
)
810 struct cdc_ncm_ctx
*ctx
=
811 container_of(timer
, struct cdc_ncm_ctx
, tx_timer
);
813 if (!atomic_read(&ctx
->stop
))
814 tasklet_schedule(&ctx
->bh
);
815 return HRTIMER_NORESTART
;
818 static void cdc_ncm_txpath_bh(unsigned long param
)
820 struct usbnet
*dev
= (struct usbnet
*)param
;
821 struct cdc_ncm_ctx
*ctx
= (struct cdc_ncm_ctx
*)dev
->data
[0];
823 spin_lock_bh(&ctx
->mtx
);
824 if (ctx
->tx_timer_pending
!= 0) {
825 ctx
->tx_timer_pending
--;
826 cdc_ncm_tx_timeout_start(ctx
);
827 spin_unlock_bh(&ctx
->mtx
);
828 } else if (dev
->net
!= NULL
) {
829 spin_unlock_bh(&ctx
->mtx
);
830 netif_tx_lock_bh(dev
->net
);
831 usbnet_start_xmit(NULL
, dev
->net
);
832 netif_tx_unlock_bh(dev
->net
);
834 spin_unlock_bh(&ctx
->mtx
);
838 static struct sk_buff
*
839 cdc_ncm_tx_fixup(struct usbnet
*dev
, struct sk_buff
*skb
, gfp_t flags
)
841 struct sk_buff
*skb_out
;
842 struct cdc_ncm_ctx
*ctx
= (struct cdc_ncm_ctx
*)dev
->data
[0];
845 * The Ethernet API we are using does not support transmitting
846 * multiple Ethernet frames in a single call. This driver will
847 * accumulate multiple Ethernet frames and send out a larger
848 * USB frame when the USB buffer is full or when a single jiffies
854 spin_lock_bh(&ctx
->mtx
);
855 skb_out
= cdc_ncm_fill_tx_frame(dev
, skb
, cpu_to_le32(USB_CDC_NCM_NDP16_NOCRC_SIGN
));
856 spin_unlock_bh(&ctx
->mtx
);
861 dev_kfree_skb_any(skb
);
866 /* verify NTB header and return offset of first NDP, or negative error */
867 int cdc_ncm_rx_verify_nth16(struct cdc_ncm_ctx
*ctx
, struct sk_buff
*skb_in
)
869 struct usbnet
*dev
= netdev_priv(skb_in
->dev
);
870 struct usb_cdc_ncm_nth16
*nth16
;
877 if (skb_in
->len
< (sizeof(struct usb_cdc_ncm_nth16
) +
878 sizeof(struct usb_cdc_ncm_ndp16
))) {
879 netif_dbg(dev
, rx_err
, dev
->net
, "frame too short\n");
883 nth16
= (struct usb_cdc_ncm_nth16
*)skb_in
->data
;
885 if (nth16
->dwSignature
!= cpu_to_le32(USB_CDC_NCM_NTH16_SIGN
)) {
886 netif_dbg(dev
, rx_err
, dev
->net
,
887 "invalid NTH16 signature <%#010x>\n",
888 le32_to_cpu(nth16
->dwSignature
));
892 len
= le16_to_cpu(nth16
->wBlockLength
);
893 if (len
> ctx
->rx_max
) {
894 netif_dbg(dev
, rx_err
, dev
->net
,
895 "unsupported NTB block length %u/%u\n", len
,
900 if ((ctx
->rx_seq
+ 1) != le16_to_cpu(nth16
->wSequence
) &&
901 (ctx
->rx_seq
|| le16_to_cpu(nth16
->wSequence
)) &&
902 !((ctx
->rx_seq
== 0xffff) && !le16_to_cpu(nth16
->wSequence
))) {
903 netif_dbg(dev
, rx_err
, dev
->net
,
904 "sequence number glitch prev=%d curr=%d\n",
905 ctx
->rx_seq
, le16_to_cpu(nth16
->wSequence
));
907 ctx
->rx_seq
= le16_to_cpu(nth16
->wSequence
);
909 ret
= le16_to_cpu(nth16
->wNdpIndex
);
913 EXPORT_SYMBOL_GPL(cdc_ncm_rx_verify_nth16
);
915 /* verify NDP header and return number of datagrams, or negative error */
916 int cdc_ncm_rx_verify_ndp16(struct sk_buff
*skb_in
, int ndpoffset
)
918 struct usbnet
*dev
= netdev_priv(skb_in
->dev
);
919 struct usb_cdc_ncm_ndp16
*ndp16
;
922 if ((ndpoffset
+ sizeof(struct usb_cdc_ncm_ndp16
)) > skb_in
->len
) {
923 netif_dbg(dev
, rx_err
, dev
->net
, "invalid NDP offset <%u>\n",
927 ndp16
= (struct usb_cdc_ncm_ndp16
*)(skb_in
->data
+ ndpoffset
);
929 if (le16_to_cpu(ndp16
->wLength
) < USB_CDC_NCM_NDP16_LENGTH_MIN
) {
930 netif_dbg(dev
, rx_err
, dev
->net
, "invalid DPT16 length <%u>\n",
931 le16_to_cpu(ndp16
->wLength
));
935 ret
= ((le16_to_cpu(ndp16
->wLength
) -
936 sizeof(struct usb_cdc_ncm_ndp16
)) /
937 sizeof(struct usb_cdc_ncm_dpe16
));
938 ret
--; /* we process NDP entries except for the last one */
940 if ((sizeof(struct usb_cdc_ncm_ndp16
) +
941 ret
* (sizeof(struct usb_cdc_ncm_dpe16
))) > skb_in
->len
) {
942 netif_dbg(dev
, rx_err
, dev
->net
, "Invalid nframes = %d\n", ret
);
949 EXPORT_SYMBOL_GPL(cdc_ncm_rx_verify_ndp16
);
951 static int cdc_ncm_rx_fixup(struct usbnet
*dev
, struct sk_buff
*skb_in
)
954 struct cdc_ncm_ctx
*ctx
= (struct cdc_ncm_ctx
*)dev
->data
[0];
959 struct usb_cdc_ncm_ndp16
*ndp16
;
960 struct usb_cdc_ncm_dpe16
*dpe16
;
962 int loopcount
= 50; /* arbitrary max preventing infinite loop */
964 ndpoffset
= cdc_ncm_rx_verify_nth16(ctx
, skb_in
);
969 nframes
= cdc_ncm_rx_verify_ndp16(skb_in
, ndpoffset
);
973 ndp16
= (struct usb_cdc_ncm_ndp16
*)(skb_in
->data
+ ndpoffset
);
975 if (ndp16
->dwSignature
!= cpu_to_le32(USB_CDC_NCM_NDP16_NOCRC_SIGN
)) {
976 netif_dbg(dev
, rx_err
, dev
->net
,
977 "invalid DPT16 signature <%#010x>\n",
978 le32_to_cpu(ndp16
->dwSignature
));
981 dpe16
= ndp16
->dpe16
;
983 for (x
= 0; x
< nframes
; x
++, dpe16
++) {
984 offset
= le16_to_cpu(dpe16
->wDatagramIndex
);
985 len
= le16_to_cpu(dpe16
->wDatagramLength
);
989 * All entries after first NULL entry are to be ignored
991 if ((offset
== 0) || (len
== 0)) {
993 goto err_ndp
; /* empty NTB */
997 /* sanity checking */
998 if (((offset
+ len
) > skb_in
->len
) ||
999 (len
> ctx
->rx_max
) || (len
< ETH_HLEN
)) {
1000 netif_dbg(dev
, rx_err
, dev
->net
,
1001 "invalid frame detected (ignored) offset[%u]=%u, length=%u, skb=%p\n",
1002 x
, offset
, len
, skb_in
);
1008 skb
= skb_clone(skb_in
, GFP_ATOMIC
);
1012 skb
->data
= ((u8
*)skb_in
->data
) + offset
;
1013 skb_set_tail_pointer(skb
, len
);
1014 usbnet_skb_return(dev
, skb
);
1018 /* are there more NDPs to process? */
1019 ndpoffset
= le16_to_cpu(ndp16
->wNextNdpIndex
);
1020 if (ndpoffset
&& loopcount
--)
1029 cdc_ncm_speed_change(struct usbnet
*dev
,
1030 struct usb_cdc_speed_change
*data
)
1032 uint32_t rx_speed
= le32_to_cpu(data
->DLBitRRate
);
1033 uint32_t tx_speed
= le32_to_cpu(data
->ULBitRate
);
1036 * Currently the USB-NET API does not support reporting the actual
1037 * device speed. Do print it instead.
1039 if ((tx_speed
> 1000000) && (rx_speed
> 1000000)) {
1040 netif_info(dev
, link
, dev
->net
,
1041 "%u mbit/s downlink %u mbit/s uplink\n",
1042 (unsigned int)(rx_speed
/ 1000000U),
1043 (unsigned int)(tx_speed
/ 1000000U));
1045 netif_info(dev
, link
, dev
->net
,
1046 "%u kbit/s downlink %u kbit/s uplink\n",
1047 (unsigned int)(rx_speed
/ 1000U),
1048 (unsigned int)(tx_speed
/ 1000U));
1052 static void cdc_ncm_status(struct usbnet
*dev
, struct urb
*urb
)
1054 struct cdc_ncm_ctx
*ctx
;
1055 struct usb_cdc_notification
*event
;
1057 ctx
= (struct cdc_ncm_ctx
*)dev
->data
[0];
1059 if (urb
->actual_length
< sizeof(*event
))
1062 /* test for split data in 8-byte chunks */
1063 if (test_and_clear_bit(EVENT_STS_SPLIT
, &dev
->flags
)) {
1064 cdc_ncm_speed_change(dev
,
1065 (struct usb_cdc_speed_change
*)urb
->transfer_buffer
);
1069 event
= urb
->transfer_buffer
;
1071 switch (event
->bNotificationType
) {
1072 case USB_CDC_NOTIFY_NETWORK_CONNECTION
:
1074 * According to the CDC NCM specification ch.7.1
1075 * USB_CDC_NOTIFY_NETWORK_CONNECTION notification shall be
1076 * sent by device after USB_CDC_NOTIFY_SPEED_CHANGE.
1078 ctx
->connected
= le16_to_cpu(event
->wValue
);
1079 netif_info(dev
, link
, dev
->net
,
1080 "network connection: %sconnected\n",
1081 ctx
->connected
? "" : "dis");
1082 usbnet_link_change(dev
, ctx
->connected
, 0);
1085 case USB_CDC_NOTIFY_SPEED_CHANGE
:
1086 if (urb
->actual_length
< (sizeof(*event
) +
1087 sizeof(struct usb_cdc_speed_change
)))
1088 set_bit(EVENT_STS_SPLIT
, &dev
->flags
);
1090 cdc_ncm_speed_change(dev
,
1091 (struct usb_cdc_speed_change
*)&event
[1]);
1095 dev_dbg(&dev
->udev
->dev
,
1096 "NCM: unexpected notification 0x%02x!\n",
1097 event
->bNotificationType
);
1102 static int cdc_ncm_check_connect(struct usbnet
*dev
)
1104 struct cdc_ncm_ctx
*ctx
;
1106 ctx
= (struct cdc_ncm_ctx
*)dev
->data
[0];
1108 return 1; /* disconnected */
1110 return !ctx
->connected
;
1113 static const struct driver_info cdc_ncm_info
= {
1114 .description
= "CDC NCM",
1115 .flags
= FLAG_POINTTOPOINT
| FLAG_NO_SETINT
| FLAG_MULTI_PACKET
,
1116 .bind
= cdc_ncm_bind
,
1117 .unbind
= cdc_ncm_unbind
,
1118 .check_connect
= cdc_ncm_check_connect
,
1119 .manage_power
= usbnet_manage_power
,
1120 .status
= cdc_ncm_status
,
1121 .rx_fixup
= cdc_ncm_rx_fixup
,
1122 .tx_fixup
= cdc_ncm_tx_fixup
,
1125 /* Same as cdc_ncm_info, but with FLAG_WWAN */
1126 static const struct driver_info wwan_info
= {
1127 .description
= "Mobile Broadband Network Device",
1128 .flags
= FLAG_POINTTOPOINT
| FLAG_NO_SETINT
| FLAG_MULTI_PACKET
1130 .bind
= cdc_ncm_bind
,
1131 .unbind
= cdc_ncm_unbind
,
1132 .check_connect
= cdc_ncm_check_connect
,
1133 .manage_power
= usbnet_manage_power
,
1134 .status
= cdc_ncm_status
,
1135 .rx_fixup
= cdc_ncm_rx_fixup
,
1136 .tx_fixup
= cdc_ncm_tx_fixup
,
1139 /* Same as wwan_info, but with FLAG_NOARP */
1140 static const struct driver_info wwan_noarp_info
= {
1141 .description
= "Mobile Broadband Network Device (NO ARP)",
1142 .flags
= FLAG_POINTTOPOINT
| FLAG_NO_SETINT
| FLAG_MULTI_PACKET
1143 | FLAG_WWAN
| FLAG_NOARP
,
1144 .bind
= cdc_ncm_bind
,
1145 .unbind
= cdc_ncm_unbind
,
1146 .check_connect
= cdc_ncm_check_connect
,
1147 .manage_power
= usbnet_manage_power
,
1148 .status
= cdc_ncm_status
,
1149 .rx_fixup
= cdc_ncm_rx_fixup
,
1150 .tx_fixup
= cdc_ncm_tx_fixup
,
1153 static const struct usb_device_id cdc_devs
[] = {
1154 /* Ericsson MBM devices like F5521gw */
1155 { .match_flags
= USB_DEVICE_ID_MATCH_INT_INFO
1156 | USB_DEVICE_ID_MATCH_VENDOR
,
1158 .bInterfaceClass
= USB_CLASS_COMM
,
1159 .bInterfaceSubClass
= USB_CDC_SUBCLASS_NCM
,
1160 .bInterfaceProtocol
= USB_CDC_PROTO_NONE
,
1161 .driver_info
= (unsigned long) &wwan_info
,
1164 /* Dell branded MBM devices like DW5550 */
1165 { .match_flags
= USB_DEVICE_ID_MATCH_INT_INFO
1166 | USB_DEVICE_ID_MATCH_VENDOR
,
1168 .bInterfaceClass
= USB_CLASS_COMM
,
1169 .bInterfaceSubClass
= USB_CDC_SUBCLASS_NCM
,
1170 .bInterfaceProtocol
= USB_CDC_PROTO_NONE
,
1171 .driver_info
= (unsigned long) &wwan_info
,
1174 /* Toshiba branded MBM devices */
1175 { .match_flags
= USB_DEVICE_ID_MATCH_INT_INFO
1176 | USB_DEVICE_ID_MATCH_VENDOR
,
1178 .bInterfaceClass
= USB_CLASS_COMM
,
1179 .bInterfaceSubClass
= USB_CDC_SUBCLASS_NCM
,
1180 .bInterfaceProtocol
= USB_CDC_PROTO_NONE
,
1181 .driver_info
= (unsigned long) &wwan_info
,
1184 /* tag Huawei devices as wwan */
1185 { USB_VENDOR_AND_INTERFACE_INFO(0x12d1,
1187 USB_CDC_SUBCLASS_NCM
,
1188 USB_CDC_PROTO_NONE
),
1189 .driver_info
= (unsigned long)&wwan_info
,
1192 /* Huawei NCM devices disguised as vendor specific */
1193 { USB_VENDOR_AND_INTERFACE_INFO(0x12d1, 0xff, 0x02, 0x16),
1194 .driver_info
= (unsigned long)&wwan_info
,
1196 { USB_VENDOR_AND_INTERFACE_INFO(0x12d1, 0xff, 0x02, 0x46),
1197 .driver_info
= (unsigned long)&wwan_info
,
1199 { USB_VENDOR_AND_INTERFACE_INFO(0x12d1, 0xff, 0x02, 0x76),
1200 .driver_info
= (unsigned long)&wwan_info
,
1203 /* Infineon(now Intel) HSPA Modem platform */
1204 { USB_DEVICE_AND_INTERFACE_INFO(0x1519, 0x0443,
1206 USB_CDC_SUBCLASS_NCM
, USB_CDC_PROTO_NONE
),
1207 .driver_info
= (unsigned long)&wwan_noarp_info
,
1210 /* Generic CDC-NCM devices */
1211 { USB_INTERFACE_INFO(USB_CLASS_COMM
,
1212 USB_CDC_SUBCLASS_NCM
, USB_CDC_PROTO_NONE
),
1213 .driver_info
= (unsigned long)&cdc_ncm_info
,
1218 MODULE_DEVICE_TABLE(usb
, cdc_devs
);
1220 static struct usb_driver cdc_ncm_driver
= {
1222 .id_table
= cdc_devs
,
1223 .probe
= usbnet_probe
,
1224 .disconnect
= usbnet_disconnect
,
1225 .suspend
= usbnet_suspend
,
1226 .resume
= usbnet_resume
,
1227 .reset_resume
= usbnet_resume
,
1228 .supports_autosuspend
= 1,
1229 .disable_hub_initiated_lpm
= 1,
1232 module_usb_driver(cdc_ncm_driver
);
1234 MODULE_AUTHOR("Hans Petter Selasky");
1235 MODULE_DESCRIPTION("USB CDC NCM host driver");
1236 MODULE_LICENSE("Dual BSD/GPL");