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/netdevice.h>
43 #include <linux/ctype.h>
44 #include <linux/ethtool.h>
45 #include <linux/workqueue.h>
46 #include <linux/mii.h>
47 #include <linux/crc32.h>
48 #include <linux/usb.h>
49 #include <linux/hrtimer.h>
50 #include <linux/atomic.h>
51 #include <linux/usb/usbnet.h>
52 #include <linux/usb/cdc.h>
53 #include <linux/usb/cdc_ncm.h>
55 #if IS_ENABLED(CONFIG_USB_NET_CDC_MBIM)
56 static bool prefer_mbim = true;
58 static bool prefer_mbim;
60 module_param(prefer_mbim, bool, S_IRUGO | S_IWUSR);
61 MODULE_PARM_DESC(prefer_mbim, "Prefer MBIM setting on dual NCM/MBIM functions");
63 static void cdc_ncm_txpath_bh(unsigned long param);
64 static void cdc_ncm_tx_timeout_start(struct cdc_ncm_ctx *ctx);
65 static enum hrtimer_restart cdc_ncm_tx_timer_cb(struct hrtimer *hr_timer);
66 static struct usb_driver cdc_ncm_driver;
68 /* handle rx_max and tx_max changes */
69 static void cdc_ncm_update_rxtx_max(struct usbnet *dev, u32 new_rx, u32 new_tx)
71 struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
72 u8 iface_no = ctx->control->cur_altsetting->desc.bInterfaceNumber;
75 /* clamp new_rx to sane values */
76 min = USB_CDC_NCM_NTB_MIN_IN_SIZE;
77 max = min_t(u32, CDC_NCM_NTB_MAX_SIZE_RX, le32_to_cpu(ctx->ncm_parm.dwNtbInMaxSize));
79 /* dwNtbInMaxSize spec violation? Use MIN size for both limits */
81 dev_warn(&dev->intf->dev, "dwNtbInMaxSize=%u is too small. Using %u\n",
82 le32_to_cpu(ctx->ncm_parm.dwNtbInMaxSize), min);
86 val = clamp_t(u32, new_rx, min, max);
88 dev_dbg(&dev->intf->dev, "rx_max must be in the [%u, %u] range. Using %u\n",
92 /* usbnet use these values for sizing rx queues */
93 dev->rx_urb_size = val;
95 /* inform device about NTB input size changes */
96 if (val != ctx->rx_max) {
97 __le32 dwNtbInMaxSize = cpu_to_le32(val);
99 dev_info(&dev->intf->dev, "setting rx_max = %u\n", val);
101 /* need to unlink rx urbs before increasing buffer size */
102 if (netif_running(dev->net) && dev->rx_urb_size > ctx->rx_max)
103 usbnet_unlink_rx_urbs(dev);
105 /* tell device to use new size */
106 if (usbnet_write_cmd(dev, USB_CDC_SET_NTB_INPUT_SIZE,
107 USB_TYPE_CLASS | USB_DIR_OUT
108 | USB_RECIP_INTERFACE,
109 0, iface_no, &dwNtbInMaxSize, 4) < 0)
110 dev_dbg(&dev->intf->dev, "Setting NTB Input Size failed\n");
115 /* clamp new_tx to sane values */
116 min = CDC_NCM_MIN_HDR_SIZE + ctx->max_datagram_size;
117 max = min_t(u32, CDC_NCM_NTB_MAX_SIZE_TX, le32_to_cpu(ctx->ncm_parm.dwNtbOutMaxSize));
119 /* some devices set dwNtbOutMaxSize too low for the above default */
122 val = clamp_t(u32, new_tx, min, max);
124 dev_dbg(&dev->intf->dev, "tx_max must be in the [%u, %u] range. Using %u\n",
127 if (val != ctx->tx_max)
128 dev_info(&dev->intf->dev, "setting tx_max = %u\n", val);
130 /* Adding a pad byte here if necessary simplifies the handling
131 * in cdc_ncm_fill_tx_frame, making tx_max always represent
132 * the real skb max size.
134 * We cannot use dev->maxpacket here because this is called from
135 * .bind which is called before usbnet sets up dev->maxpacket
137 if (val != le32_to_cpu(ctx->ncm_parm.dwNtbOutMaxSize) &&
138 val % usb_maxpacket(dev->udev, dev->out, 1) == 0)
141 /* we might need to flush any pending tx buffers if running */
142 if (netif_running(dev->net) && val > ctx->tx_max) {
143 netif_tx_lock_bh(dev->net);
144 usbnet_start_xmit(NULL, dev->net);
146 netif_tx_unlock_bh(dev->net);
151 dev->hard_mtu = ctx->tx_max;
153 /* max qlen depend on hard_mtu and rx_urb_size */
154 usbnet_update_max_qlen(dev);
157 /* helpers for NCM and MBIM differences */
158 static u8 cdc_ncm_flags(struct usbnet *dev)
160 struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
162 if (cdc_ncm_comm_intf_is_mbim(dev->intf->cur_altsetting) && ctx->mbim_desc)
163 return ctx->mbim_desc->bmNetworkCapabilities;
165 return ctx->func_desc->bmNetworkCapabilities;
169 static int cdc_ncm_eth_hlen(struct usbnet *dev)
171 if (cdc_ncm_comm_intf_is_mbim(dev->intf->cur_altsetting))
176 static u32 cdc_ncm_min_dgram_size(struct usbnet *dev)
178 if (cdc_ncm_comm_intf_is_mbim(dev->intf->cur_altsetting))
179 return CDC_MBIM_MIN_DATAGRAM_SIZE;
180 return CDC_NCM_MIN_DATAGRAM_SIZE;
183 static u32 cdc_ncm_max_dgram_size(struct usbnet *dev)
185 struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
187 if (cdc_ncm_comm_intf_is_mbim(dev->intf->cur_altsetting) && ctx->mbim_desc)
188 return le16_to_cpu(ctx->mbim_desc->wMaxSegmentSize);
190 return le16_to_cpu(ctx->ether_desc->wMaxSegmentSize);
191 return CDC_NCM_MAX_DATAGRAM_SIZE;
194 /* initial one-time device setup. MUST be called with the data interface
197 static int cdc_ncm_init(struct usbnet *dev)
199 struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
200 u8 iface_no = ctx->control->cur_altsetting->desc.bInterfaceNumber;
203 err = usbnet_read_cmd(dev, USB_CDC_GET_NTB_PARAMETERS,
204 USB_TYPE_CLASS | USB_DIR_IN
205 |USB_RECIP_INTERFACE,
206 0, iface_no, &ctx->ncm_parm,
207 sizeof(ctx->ncm_parm));
209 dev_err(&dev->intf->dev, "failed GET_NTB_PARAMETERS\n");
210 return err; /* GET_NTB_PARAMETERS is required */
214 if (cdc_ncm_flags(dev) & USB_CDC_NCM_NCAP_CRC_MODE) {
215 dev_dbg(&dev->intf->dev, "Setting CRC mode off\n");
216 err = usbnet_write_cmd(dev, USB_CDC_SET_CRC_MODE,
217 USB_TYPE_CLASS | USB_DIR_OUT
218 | USB_RECIP_INTERFACE,
219 USB_CDC_NCM_CRC_NOT_APPENDED,
222 dev_err(&dev->intf->dev, "SET_CRC_MODE failed\n");
225 /* set NTB format, if both formats are supported.
227 * "The host shall only send this command while the NCM Data
228 * Interface is in alternate setting 0."
230 if (le16_to_cpu(ctx->ncm_parm.bmNtbFormatsSupported) & USB_CDC_NCM_NTH32_SIGN) {
231 dev_dbg(&dev->intf->dev, "Setting NTB format to 16-bit\n");
232 err = usbnet_write_cmd(dev, USB_CDC_SET_NTB_FORMAT,
233 USB_TYPE_CLASS | USB_DIR_OUT
234 | USB_RECIP_INTERFACE,
235 USB_CDC_NCM_NTB16_FORMAT,
238 dev_err(&dev->intf->dev, "SET_NTB_FORMAT failed\n");
241 /* set initial device values */
242 ctx->rx_max = le32_to_cpu(ctx->ncm_parm.dwNtbInMaxSize);
243 ctx->tx_max = le32_to_cpu(ctx->ncm_parm.dwNtbOutMaxSize);
244 ctx->tx_remainder = le16_to_cpu(ctx->ncm_parm.wNdpOutPayloadRemainder);
245 ctx->tx_modulus = le16_to_cpu(ctx->ncm_parm.wNdpOutDivisor);
246 ctx->tx_ndp_modulus = le16_to_cpu(ctx->ncm_parm.wNdpOutAlignment);
247 /* devices prior to NCM Errata shall set this field to zero */
248 ctx->tx_max_datagrams = le16_to_cpu(ctx->ncm_parm.wNtbOutMaxDatagrams);
250 dev_dbg(&dev->intf->dev,
251 "dwNtbInMaxSize=%u dwNtbOutMaxSize=%u wNdpOutPayloadRemainder=%u wNdpOutDivisor=%u wNdpOutAlignment=%u wNtbOutMaxDatagrams=%u flags=0x%x\n",
252 ctx->rx_max, ctx->tx_max, ctx->tx_remainder, ctx->tx_modulus,
253 ctx->tx_ndp_modulus, ctx->tx_max_datagrams, cdc_ncm_flags(dev));
255 /* max count of tx datagrams */
256 if ((ctx->tx_max_datagrams == 0) ||
257 (ctx->tx_max_datagrams > CDC_NCM_DPT_DATAGRAMS_MAX))
258 ctx->tx_max_datagrams = CDC_NCM_DPT_DATAGRAMS_MAX;
263 /* set a new max datagram size */
264 static void cdc_ncm_set_dgram_size(struct usbnet *dev, int new_size)
266 struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
267 u8 iface_no = ctx->control->cur_altsetting->desc.bInterfaceNumber;
268 __le16 max_datagram_size;
272 /* set default based on descriptors */
273 ctx->max_datagram_size = clamp_t(u32, new_size,
274 cdc_ncm_min_dgram_size(dev),
275 CDC_NCM_MAX_DATAGRAM_SIZE);
277 /* inform the device about the selected Max Datagram Size? */
278 if (!(cdc_ncm_flags(dev) & USB_CDC_NCM_NCAP_MAX_DATAGRAM_SIZE))
281 /* read current mtu value from device */
282 err = usbnet_read_cmd(dev, USB_CDC_GET_MAX_DATAGRAM_SIZE,
283 USB_TYPE_CLASS | USB_DIR_IN | USB_RECIP_INTERFACE,
284 0, iface_no, &max_datagram_size, 2);
286 dev_dbg(&dev->intf->dev, "GET_MAX_DATAGRAM_SIZE failed\n");
290 if (le16_to_cpu(max_datagram_size) == ctx->max_datagram_size)
293 max_datagram_size = cpu_to_le16(ctx->max_datagram_size);
294 err = usbnet_write_cmd(dev, USB_CDC_SET_MAX_DATAGRAM_SIZE,
295 USB_TYPE_CLASS | USB_DIR_OUT | USB_RECIP_INTERFACE,
296 0, iface_no, &max_datagram_size, 2);
298 dev_dbg(&dev->intf->dev, "SET_MAX_DATAGRAM_SIZE failed\n");
301 /* set MTU to max supported by the device if necessary */
302 dev->net->mtu = min_t(int, dev->net->mtu, ctx->max_datagram_size - cdc_ncm_eth_hlen(dev));
304 /* do not exceed operater preferred MTU */
305 if (ctx->mbim_extended_desc) {
306 mbim_mtu = le16_to_cpu(ctx->mbim_extended_desc->wMTU);
307 if (mbim_mtu != 0 && mbim_mtu < dev->net->mtu)
308 dev->net->mtu = mbim_mtu;
312 static void cdc_ncm_fix_modulus(struct usbnet *dev)
314 struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
318 * verify that the structure alignment is:
320 * - not greater than the maximum transmit length
321 * - not less than four bytes
323 val = ctx->tx_ndp_modulus;
325 if ((val < USB_CDC_NCM_NDP_ALIGN_MIN_SIZE) ||
326 (val != ((-val) & val)) || (val >= ctx->tx_max)) {
327 dev_dbg(&dev->intf->dev, "Using default alignment: 4 bytes\n");
328 ctx->tx_ndp_modulus = USB_CDC_NCM_NDP_ALIGN_MIN_SIZE;
332 * verify that the payload alignment is:
334 * - not greater than the maximum transmit length
335 * - not less than four bytes
337 val = ctx->tx_modulus;
339 if ((val < USB_CDC_NCM_NDP_ALIGN_MIN_SIZE) ||
340 (val != ((-val) & val)) || (val >= ctx->tx_max)) {
341 dev_dbg(&dev->intf->dev, "Using default transmit modulus: 4 bytes\n");
342 ctx->tx_modulus = USB_CDC_NCM_NDP_ALIGN_MIN_SIZE;
345 /* verify the payload remainder */
346 if (ctx->tx_remainder >= ctx->tx_modulus) {
347 dev_dbg(&dev->intf->dev, "Using default transmit remainder: 0 bytes\n");
348 ctx->tx_remainder = 0;
351 /* adjust TX-remainder according to NCM specification. */
352 ctx->tx_remainder = ((ctx->tx_remainder - cdc_ncm_eth_hlen(dev)) &
353 (ctx->tx_modulus - 1));
356 static int cdc_ncm_setup(struct usbnet *dev)
358 struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
360 /* clamp rx_max and tx_max and inform device */
361 cdc_ncm_update_rxtx_max(dev, le32_to_cpu(ctx->ncm_parm.dwNtbInMaxSize),
362 le32_to_cpu(ctx->ncm_parm.dwNtbOutMaxSize));
364 /* sanitize the modulus and remainder values */
365 cdc_ncm_fix_modulus(dev);
367 /* set max datagram size */
368 cdc_ncm_set_dgram_size(dev, cdc_ncm_max_dgram_size(dev));
373 cdc_ncm_find_endpoints(struct usbnet *dev, struct usb_interface *intf)
375 struct usb_host_endpoint *e, *in = NULL, *out = NULL;
378 for (ep = 0; ep < intf->cur_altsetting->desc.bNumEndpoints; ep++) {
380 e = intf->cur_altsetting->endpoint + ep;
381 switch (e->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) {
382 case USB_ENDPOINT_XFER_INT:
383 if (usb_endpoint_dir_in(&e->desc)) {
389 case USB_ENDPOINT_XFER_BULK:
390 if (usb_endpoint_dir_in(&e->desc)) {
404 dev->in = usb_rcvbulkpipe(dev->udev,
405 in->desc.bEndpointAddress &
406 USB_ENDPOINT_NUMBER_MASK);
407 if (out && !dev->out)
408 dev->out = usb_sndbulkpipe(dev->udev,
409 out->desc.bEndpointAddress &
410 USB_ENDPOINT_NUMBER_MASK);
413 static void cdc_ncm_free(struct cdc_ncm_ctx *ctx)
418 if (ctx->tx_rem_skb != NULL) {
419 dev_kfree_skb_any(ctx->tx_rem_skb);
420 ctx->tx_rem_skb = NULL;
423 if (ctx->tx_curr_skb != NULL) {
424 dev_kfree_skb_any(ctx->tx_curr_skb);
425 ctx->tx_curr_skb = NULL;
431 int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_altsetting)
433 const struct usb_cdc_union_desc *union_desc = NULL;
434 struct cdc_ncm_ctx *ctx;
435 struct usb_driver *driver;
441 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
445 hrtimer_init(&ctx->tx_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
446 ctx->tx_timer.function = &cdc_ncm_tx_timer_cb;
447 ctx->bh.data = (unsigned long)dev;
448 ctx->bh.func = cdc_ncm_txpath_bh;
449 atomic_set(&ctx->stop, 0);
450 spin_lock_init(&ctx->mtx);
452 /* store ctx pointer in device data field */
453 dev->data[0] = (unsigned long)ctx;
455 /* only the control interface can be successfully probed */
458 /* get some pointers */
459 driver = driver_of(intf);
460 buf = intf->cur_altsetting->extra;
461 len = intf->cur_altsetting->extralen;
463 /* parse through descriptors associated with control interface */
464 while ((len > 0) && (buf[0] > 2) && (buf[0] <= len)) {
466 if (buf[1] != USB_DT_CS_INTERFACE)
470 case USB_CDC_UNION_TYPE:
471 if (buf[0] < sizeof(*union_desc))
474 union_desc = (const struct usb_cdc_union_desc *)buf;
475 /* the master must be the interface we are probing */
476 if (intf->cur_altsetting->desc.bInterfaceNumber !=
477 union_desc->bMasterInterface0) {
478 dev_dbg(&intf->dev, "bogus CDC Union\n");
481 ctx->data = usb_ifnum_to_if(dev->udev,
482 union_desc->bSlaveInterface0);
485 case USB_CDC_ETHERNET_TYPE:
486 if (buf[0] < sizeof(*(ctx->ether_desc)))
490 (const struct usb_cdc_ether_desc *)buf;
493 case USB_CDC_NCM_TYPE:
494 if (buf[0] < sizeof(*(ctx->func_desc)))
497 ctx->func_desc = (const struct usb_cdc_ncm_desc *)buf;
500 case USB_CDC_MBIM_TYPE:
501 if (buf[0] < sizeof(*(ctx->mbim_desc)))
504 ctx->mbim_desc = (const struct usb_cdc_mbim_desc *)buf;
507 case USB_CDC_MBIM_EXTENDED_TYPE:
508 if (buf[0] < sizeof(*(ctx->mbim_extended_desc)))
511 ctx->mbim_extended_desc =
512 (const struct usb_cdc_mbim_extended_desc *)buf;
519 /* advance to next descriptor */
525 /* some buggy devices have an IAD but no CDC Union */
526 if (!union_desc && intf->intf_assoc && intf->intf_assoc->bInterfaceCount == 2) {
527 ctx->data = usb_ifnum_to_if(dev->udev, intf->cur_altsetting->desc.bInterfaceNumber + 1);
528 dev_dbg(&intf->dev, "CDC Union missing - got slave from IAD\n");
531 /* check if we got everything */
533 dev_dbg(&intf->dev, "CDC Union missing and no IAD found\n");
536 if (cdc_ncm_comm_intf_is_mbim(intf->cur_altsetting)) {
537 if (!ctx->mbim_desc) {
538 dev_dbg(&intf->dev, "MBIM functional descriptor missing\n");
542 if (!ctx->ether_desc || !ctx->func_desc) {
543 dev_dbg(&intf->dev, "NCM or ECM functional descriptors missing\n");
548 /* claim data interface, if different from control */
549 if (ctx->data != ctx->control) {
550 temp = usb_driver_claim_interface(driver, ctx->data, dev);
552 dev_dbg(&intf->dev, "failed to claim data intf\n");
557 iface_no = ctx->data->cur_altsetting->desc.bInterfaceNumber;
559 /* reset data interface */
560 temp = usb_set_interface(dev->udev, iface_no, 0);
562 dev_dbg(&intf->dev, "set interface failed\n");
566 /* initialize basic device settings */
567 if (cdc_ncm_init(dev))
570 /* configure data interface */
571 temp = usb_set_interface(dev->udev, iface_no, data_altsetting);
573 dev_dbg(&intf->dev, "set interface failed\n");
577 cdc_ncm_find_endpoints(dev, ctx->data);
578 cdc_ncm_find_endpoints(dev, ctx->control);
579 if (!dev->in || !dev->out || !dev->status) {
580 dev_dbg(&intf->dev, "failed to collect endpoints\n");
584 usb_set_intfdata(ctx->data, dev);
585 usb_set_intfdata(ctx->control, dev);
587 if (ctx->ether_desc) {
588 temp = usbnet_get_ethernet_addr(dev, ctx->ether_desc->iMACAddress);
590 dev_dbg(&intf->dev, "failed to get mac address\n");
593 dev_info(&intf->dev, "MAC-Address: %pM\n", dev->net->dev_addr);
596 /* finish setting up the device specific data */
602 usb_set_intfdata(ctx->control, NULL);
603 usb_set_intfdata(ctx->data, NULL);
604 if (ctx->data != ctx->control)
605 usb_driver_release_interface(driver, ctx->data);
607 cdc_ncm_free((struct cdc_ncm_ctx *)dev->data[0]);
609 dev_info(&intf->dev, "bind() failure\n");
612 EXPORT_SYMBOL_GPL(cdc_ncm_bind_common);
614 void cdc_ncm_unbind(struct usbnet *dev, struct usb_interface *intf)
616 struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
617 struct usb_driver *driver = driver_of(intf);
620 return; /* no setup */
622 atomic_set(&ctx->stop, 1);
624 if (hrtimer_active(&ctx->tx_timer))
625 hrtimer_cancel(&ctx->tx_timer);
627 tasklet_kill(&ctx->bh);
629 /* handle devices with combined control and data interface */
630 if (ctx->control == ctx->data)
633 /* disconnect master --> disconnect slave */
634 if (intf == ctx->control && ctx->data) {
635 usb_set_intfdata(ctx->data, NULL);
636 usb_driver_release_interface(driver, ctx->data);
639 } else if (intf == ctx->data && ctx->control) {
640 usb_set_intfdata(ctx->control, NULL);
641 usb_driver_release_interface(driver, ctx->control);
645 usb_set_intfdata(intf, NULL);
648 EXPORT_SYMBOL_GPL(cdc_ncm_unbind);
650 /* Return the number of the MBIM control interface altsetting iff it
651 * is preferred and available,
653 u8 cdc_ncm_select_altsetting(struct usb_interface *intf)
655 struct usb_host_interface *alt;
657 /* The MBIM spec defines a NCM compatible default altsetting,
658 * which we may have matched:
660 * "Functions that implement both NCM 1.0 and MBIM (an
661 * “NCM/MBIM function”) according to this recommendation
662 * shall provide two alternate settings for the
663 * Communication Interface. Alternate setting 0, and the
664 * associated class and endpoint descriptors, shall be
665 * constructed according to the rules given for the
666 * Communication Interface in section 5 of [USBNCM10].
667 * Alternate setting 1, and the associated class and
668 * endpoint descriptors, shall be constructed according to
669 * the rules given in section 6 (USB Device Model) of this
672 if (intf->num_altsetting < 2)
673 return intf->cur_altsetting->desc.bAlternateSetting;
676 alt = usb_altnum_to_altsetting(intf, CDC_NCM_COMM_ALTSETTING_MBIM);
677 if (alt && cdc_ncm_comm_intf_is_mbim(alt))
678 return CDC_NCM_COMM_ALTSETTING_MBIM;
680 return CDC_NCM_COMM_ALTSETTING_NCM;
682 EXPORT_SYMBOL_GPL(cdc_ncm_select_altsetting);
684 static int cdc_ncm_bind(struct usbnet *dev, struct usb_interface *intf)
688 /* MBIM backwards compatible function? */
689 if (cdc_ncm_select_altsetting(intf) != CDC_NCM_COMM_ALTSETTING_NCM)
692 /* The NCM data altsetting is fixed */
693 ret = cdc_ncm_bind_common(dev, intf, CDC_NCM_DATA_ALTSETTING_NCM);
696 * We should get an event when network connection is "connected" or
697 * "disconnected". Set network connection in "disconnected" state
698 * (carrier is OFF) during attach, so the IP network stack does not
699 * start IPv6 negotiation and more.
701 usbnet_link_change(dev, 0, 0);
705 static void cdc_ncm_align_tail(struct sk_buff *skb, size_t modulus, size_t remainder, size_t max)
707 size_t align = ALIGN(skb->len, modulus) - skb->len + remainder;
709 if (skb->len + align > max)
710 align = max - skb->len;
711 if (align && skb_tailroom(skb) >= align)
712 memset(skb_put(skb, align), 0, align);
715 /* return a pointer to a valid struct usb_cdc_ncm_ndp16 of type sign, possibly
716 * allocating a new one within skb
718 static struct usb_cdc_ncm_ndp16 *cdc_ncm_ndp(struct cdc_ncm_ctx *ctx, struct sk_buff *skb, __le32 sign, size_t reserve)
720 struct usb_cdc_ncm_ndp16 *ndp16 = NULL;
721 struct usb_cdc_ncm_nth16 *nth16 = (void *)skb->data;
722 size_t ndpoffset = le16_to_cpu(nth16->wNdpIndex);
724 /* follow the chain of NDPs, looking for a match */
726 ndp16 = (struct usb_cdc_ncm_ndp16 *)(skb->data + ndpoffset);
727 if (ndp16->dwSignature == sign)
729 ndpoffset = le16_to_cpu(ndp16->wNextNdpIndex);
733 cdc_ncm_align_tail(skb, ctx->tx_ndp_modulus, 0, ctx->tx_max);
735 /* verify that there is room for the NDP and the datagram (reserve) */
736 if ((ctx->tx_max - skb->len - reserve) < CDC_NCM_NDP_SIZE)
741 ndp16->wNextNdpIndex = cpu_to_le16(skb->len);
743 nth16->wNdpIndex = cpu_to_le16(skb->len);
745 /* push a new empty NDP */
746 ndp16 = (struct usb_cdc_ncm_ndp16 *)memset(skb_put(skb, CDC_NCM_NDP_SIZE), 0, CDC_NCM_NDP_SIZE);
747 ndp16->dwSignature = sign;
748 ndp16->wLength = cpu_to_le16(sizeof(struct usb_cdc_ncm_ndp16) + sizeof(struct usb_cdc_ncm_dpe16));
753 cdc_ncm_fill_tx_frame(struct usbnet *dev, struct sk_buff *skb, __le32 sign)
755 struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
756 struct usb_cdc_ncm_nth16 *nth16;
757 struct usb_cdc_ncm_ndp16 *ndp16;
758 struct sk_buff *skb_out;
759 u16 n = 0, index, ndplen;
762 /* if there is a remaining skb, it gets priority */
764 swap(skb, ctx->tx_rem_skb);
765 swap(sign, ctx->tx_rem_sign);
770 /* check if we are resuming an OUT skb */
771 skb_out = ctx->tx_curr_skb;
773 /* allocate a new OUT skb */
775 skb_out = alloc_skb(ctx->tx_max, GFP_ATOMIC);
776 if (skb_out == NULL) {
778 dev_kfree_skb_any(skb);
779 dev->net->stats.tx_dropped++;
783 /* fill out the initial 16-bit NTB header */
784 nth16 = (struct usb_cdc_ncm_nth16 *)memset(skb_put(skb_out, sizeof(struct usb_cdc_ncm_nth16)), 0, sizeof(struct usb_cdc_ncm_nth16));
785 nth16->dwSignature = cpu_to_le32(USB_CDC_NCM_NTH16_SIGN);
786 nth16->wHeaderLength = cpu_to_le16(sizeof(struct usb_cdc_ncm_nth16));
787 nth16->wSequence = cpu_to_le16(ctx->tx_seq++);
789 /* count total number of frames in this NTB */
790 ctx->tx_curr_frame_num = 0;
793 for (n = ctx->tx_curr_frame_num; n < ctx->tx_max_datagrams; n++) {
794 /* send any remaining skb first */
796 skb = ctx->tx_rem_skb;
797 sign = ctx->tx_rem_sign;
798 ctx->tx_rem_skb = NULL;
800 /* check for end of skb */
805 /* get the appropriate NDP for this skb */
806 ndp16 = cdc_ncm_ndp(ctx, skb_out, sign, skb->len + ctx->tx_modulus + ctx->tx_remainder);
808 /* align beginning of next frame */
809 cdc_ncm_align_tail(skb_out, ctx->tx_modulus, ctx->tx_remainder, ctx->tx_max);
811 /* check if we had enough room left for both NDP and frame */
812 if (!ndp16 || skb_out->len + skb->len > ctx->tx_max) {
814 /* won't fit, MTU problem? */
815 dev_kfree_skb_any(skb);
817 dev->net->stats.tx_dropped++;
819 /* no room for skb - store for later */
820 if (ctx->tx_rem_skb != NULL) {
821 dev_kfree_skb_any(ctx->tx_rem_skb);
822 dev->net->stats.tx_dropped++;
824 ctx->tx_rem_skb = skb;
825 ctx->tx_rem_sign = sign;
832 /* calculate frame number withing this NDP */
833 ndplen = le16_to_cpu(ndp16->wLength);
834 index = (ndplen - sizeof(struct usb_cdc_ncm_ndp16)) / sizeof(struct usb_cdc_ncm_dpe16) - 1;
836 /* OK, add this skb */
837 ndp16->dpe16[index].wDatagramLength = cpu_to_le16(skb->len);
838 ndp16->dpe16[index].wDatagramIndex = cpu_to_le16(skb_out->len);
839 ndp16->wLength = cpu_to_le16(ndplen + sizeof(struct usb_cdc_ncm_dpe16));
840 memcpy(skb_put(skb_out, skb->len), skb->data, skb->len);
841 dev_kfree_skb_any(skb);
844 /* send now if this NDP is full */
845 if (index >= CDC_NCM_DPT_DATAGRAMS_MAX) {
851 /* free up any dangling skb */
853 dev_kfree_skb_any(skb);
855 dev->net->stats.tx_dropped++;
858 ctx->tx_curr_frame_num = n;
861 /* wait for more frames */
863 ctx->tx_curr_skb = skb_out;
866 } else if ((n < ctx->tx_max_datagrams) && (ready2send == 0)) {
867 /* wait for more frames */
869 ctx->tx_curr_skb = skb_out;
870 /* set the pending count */
871 if (n < CDC_NCM_RESTART_TIMER_DATAGRAM_CNT)
872 ctx->tx_timer_pending = CDC_NCM_TIMER_PENDING_CNT;
877 /* variables will be reset at next call */
880 /* If collected data size is less or equal CDC_NCM_MIN_TX_PKT
881 * bytes, we send buffers as it is. If we get more data, it
882 * would be more efficient for USB HS mobile device with DMA
883 * engine to receive a full size NTB, than canceling DMA
884 * transfer and receiving a short packet.
886 * This optimization support is pointless if we end up sending
887 * a ZLP after full sized NTBs.
889 if (!(dev->driver_info->flags & FLAG_SEND_ZLP) &&
890 skb_out->len > CDC_NCM_MIN_TX_PKT)
891 memset(skb_put(skb_out, ctx->tx_max - skb_out->len), 0,
892 ctx->tx_max - skb_out->len);
893 else if (skb_out->len < ctx->tx_max && (skb_out->len % dev->maxpacket) == 0)
894 *skb_put(skb_out, 1) = 0; /* force short packet */
896 /* set final frame length */
897 nth16 = (struct usb_cdc_ncm_nth16 *)skb_out->data;
898 nth16->wBlockLength = cpu_to_le16(skb_out->len);
901 ctx->tx_curr_skb = NULL;
902 dev->net->stats.tx_packets += ctx->tx_curr_frame_num;
906 /* Start timer, if there is a remaining skb */
907 if (ctx->tx_curr_skb != NULL)
908 cdc_ncm_tx_timeout_start(ctx);
911 EXPORT_SYMBOL_GPL(cdc_ncm_fill_tx_frame);
913 static void cdc_ncm_tx_timeout_start(struct cdc_ncm_ctx *ctx)
915 /* start timer, if not already started */
916 if (!(hrtimer_active(&ctx->tx_timer) || atomic_read(&ctx->stop)))
917 hrtimer_start(&ctx->tx_timer,
918 ktime_set(0, CDC_NCM_TIMER_INTERVAL),
922 static enum hrtimer_restart cdc_ncm_tx_timer_cb(struct hrtimer *timer)
924 struct cdc_ncm_ctx *ctx =
925 container_of(timer, struct cdc_ncm_ctx, tx_timer);
927 if (!atomic_read(&ctx->stop))
928 tasklet_schedule(&ctx->bh);
929 return HRTIMER_NORESTART;
932 static void cdc_ncm_txpath_bh(unsigned long param)
934 struct usbnet *dev = (struct usbnet *)param;
935 struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
937 spin_lock_bh(&ctx->mtx);
938 if (ctx->tx_timer_pending != 0) {
939 ctx->tx_timer_pending--;
940 cdc_ncm_tx_timeout_start(ctx);
941 spin_unlock_bh(&ctx->mtx);
942 } else if (dev->net != NULL) {
943 spin_unlock_bh(&ctx->mtx);
944 netif_tx_lock_bh(dev->net);
945 usbnet_start_xmit(NULL, dev->net);
946 netif_tx_unlock_bh(dev->net);
948 spin_unlock_bh(&ctx->mtx);
953 cdc_ncm_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
955 struct sk_buff *skb_out;
956 struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
959 * The Ethernet API we are using does not support transmitting
960 * multiple Ethernet frames in a single call. This driver will
961 * accumulate multiple Ethernet frames and send out a larger
962 * USB frame when the USB buffer is full or when a single jiffies
968 spin_lock_bh(&ctx->mtx);
969 skb_out = cdc_ncm_fill_tx_frame(dev, skb, cpu_to_le32(USB_CDC_NCM_NDP16_NOCRC_SIGN));
970 spin_unlock_bh(&ctx->mtx);
975 dev_kfree_skb_any(skb);
979 EXPORT_SYMBOL_GPL(cdc_ncm_tx_fixup);
981 /* verify NTB header and return offset of first NDP, or negative error */
982 int cdc_ncm_rx_verify_nth16(struct cdc_ncm_ctx *ctx, struct sk_buff *skb_in)
984 struct usbnet *dev = netdev_priv(skb_in->dev);
985 struct usb_cdc_ncm_nth16 *nth16;
992 if (skb_in->len < (sizeof(struct usb_cdc_ncm_nth16) +
993 sizeof(struct usb_cdc_ncm_ndp16))) {
994 netif_dbg(dev, rx_err, dev->net, "frame too short\n");
998 nth16 = (struct usb_cdc_ncm_nth16 *)skb_in->data;
1000 if (nth16->dwSignature != cpu_to_le32(USB_CDC_NCM_NTH16_SIGN)) {
1001 netif_dbg(dev, rx_err, dev->net,
1002 "invalid NTH16 signature <%#010x>\n",
1003 le32_to_cpu(nth16->dwSignature));
1007 len = le16_to_cpu(nth16->wBlockLength);
1008 if (len > ctx->rx_max) {
1009 netif_dbg(dev, rx_err, dev->net,
1010 "unsupported NTB block length %u/%u\n", len,
1015 if ((ctx->rx_seq + 1) != le16_to_cpu(nth16->wSequence) &&
1016 (ctx->rx_seq || le16_to_cpu(nth16->wSequence)) &&
1017 !((ctx->rx_seq == 0xffff) && !le16_to_cpu(nth16->wSequence))) {
1018 netif_dbg(dev, rx_err, dev->net,
1019 "sequence number glitch prev=%d curr=%d\n",
1020 ctx->rx_seq, le16_to_cpu(nth16->wSequence));
1022 ctx->rx_seq = le16_to_cpu(nth16->wSequence);
1024 ret = le16_to_cpu(nth16->wNdpIndex);
1028 EXPORT_SYMBOL_GPL(cdc_ncm_rx_verify_nth16);
1030 /* verify NDP header and return number of datagrams, or negative error */
1031 int cdc_ncm_rx_verify_ndp16(struct sk_buff *skb_in, int ndpoffset)
1033 struct usbnet *dev = netdev_priv(skb_in->dev);
1034 struct usb_cdc_ncm_ndp16 *ndp16;
1037 if ((ndpoffset + sizeof(struct usb_cdc_ncm_ndp16)) > skb_in->len) {
1038 netif_dbg(dev, rx_err, dev->net, "invalid NDP offset <%u>\n",
1042 ndp16 = (struct usb_cdc_ncm_ndp16 *)(skb_in->data + ndpoffset);
1044 if (le16_to_cpu(ndp16->wLength) < USB_CDC_NCM_NDP16_LENGTH_MIN) {
1045 netif_dbg(dev, rx_err, dev->net, "invalid DPT16 length <%u>\n",
1046 le16_to_cpu(ndp16->wLength));
1050 ret = ((le16_to_cpu(ndp16->wLength) -
1051 sizeof(struct usb_cdc_ncm_ndp16)) /
1052 sizeof(struct usb_cdc_ncm_dpe16));
1053 ret--; /* we process NDP entries except for the last one */
1055 if ((sizeof(struct usb_cdc_ncm_ndp16) +
1056 ret * (sizeof(struct usb_cdc_ncm_dpe16))) > skb_in->len) {
1057 netif_dbg(dev, rx_err, dev->net, "Invalid nframes = %d\n", ret);
1064 EXPORT_SYMBOL_GPL(cdc_ncm_rx_verify_ndp16);
1066 int cdc_ncm_rx_fixup(struct usbnet *dev, struct sk_buff *skb_in)
1068 struct sk_buff *skb;
1069 struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
1074 struct usb_cdc_ncm_ndp16 *ndp16;
1075 struct usb_cdc_ncm_dpe16 *dpe16;
1077 int loopcount = 50; /* arbitrary max preventing infinite loop */
1079 ndpoffset = cdc_ncm_rx_verify_nth16(ctx, skb_in);
1084 nframes = cdc_ncm_rx_verify_ndp16(skb_in, ndpoffset);
1088 ndp16 = (struct usb_cdc_ncm_ndp16 *)(skb_in->data + ndpoffset);
1090 if (ndp16->dwSignature != cpu_to_le32(USB_CDC_NCM_NDP16_NOCRC_SIGN)) {
1091 netif_dbg(dev, rx_err, dev->net,
1092 "invalid DPT16 signature <%#010x>\n",
1093 le32_to_cpu(ndp16->dwSignature));
1096 dpe16 = ndp16->dpe16;
1098 for (x = 0; x < nframes; x++, dpe16++) {
1099 offset = le16_to_cpu(dpe16->wDatagramIndex);
1100 len = le16_to_cpu(dpe16->wDatagramLength);
1104 * All entries after first NULL entry are to be ignored
1106 if ((offset == 0) || (len == 0)) {
1108 goto err_ndp; /* empty NTB */
1112 /* sanity checking */
1113 if (((offset + len) > skb_in->len) ||
1114 (len > ctx->rx_max) || (len < ETH_HLEN)) {
1115 netif_dbg(dev, rx_err, dev->net,
1116 "invalid frame detected (ignored) offset[%u]=%u, length=%u, skb=%p\n",
1117 x, offset, len, skb_in);
1123 skb = skb_clone(skb_in, GFP_ATOMIC);
1127 skb->data = ((u8 *)skb_in->data) + offset;
1128 skb_set_tail_pointer(skb, len);
1129 usbnet_skb_return(dev, skb);
1133 /* are there more NDPs to process? */
1134 ndpoffset = le16_to_cpu(ndp16->wNextNdpIndex);
1135 if (ndpoffset && loopcount--)
1142 EXPORT_SYMBOL_GPL(cdc_ncm_rx_fixup);
1145 cdc_ncm_speed_change(struct usbnet *dev,
1146 struct usb_cdc_speed_change *data)
1148 uint32_t rx_speed = le32_to_cpu(data->DLBitRRate);
1149 uint32_t tx_speed = le32_to_cpu(data->ULBitRate);
1152 * Currently the USB-NET API does not support reporting the actual
1153 * device speed. Do print it instead.
1155 if ((tx_speed > 1000000) && (rx_speed > 1000000)) {
1156 netif_info(dev, link, dev->net,
1157 "%u mbit/s downlink %u mbit/s uplink\n",
1158 (unsigned int)(rx_speed / 1000000U),
1159 (unsigned int)(tx_speed / 1000000U));
1161 netif_info(dev, link, dev->net,
1162 "%u kbit/s downlink %u kbit/s uplink\n",
1163 (unsigned int)(rx_speed / 1000U),
1164 (unsigned int)(tx_speed / 1000U));
1168 static void cdc_ncm_status(struct usbnet *dev, struct urb *urb)
1170 struct cdc_ncm_ctx *ctx;
1171 struct usb_cdc_notification *event;
1173 ctx = (struct cdc_ncm_ctx *)dev->data[0];
1175 if (urb->actual_length < sizeof(*event))
1178 /* test for split data in 8-byte chunks */
1179 if (test_and_clear_bit(EVENT_STS_SPLIT, &dev->flags)) {
1180 cdc_ncm_speed_change(dev,
1181 (struct usb_cdc_speed_change *)urb->transfer_buffer);
1185 event = urb->transfer_buffer;
1187 switch (event->bNotificationType) {
1188 case USB_CDC_NOTIFY_NETWORK_CONNECTION:
1190 * According to the CDC NCM specification ch.7.1
1191 * USB_CDC_NOTIFY_NETWORK_CONNECTION notification shall be
1192 * sent by device after USB_CDC_NOTIFY_SPEED_CHANGE.
1194 ctx->connected = le16_to_cpu(event->wValue);
1195 netif_info(dev, link, dev->net,
1196 "network connection: %sconnected\n",
1197 ctx->connected ? "" : "dis");
1198 usbnet_link_change(dev, ctx->connected, 0);
1201 case USB_CDC_NOTIFY_SPEED_CHANGE:
1202 if (urb->actual_length < (sizeof(*event) +
1203 sizeof(struct usb_cdc_speed_change)))
1204 set_bit(EVENT_STS_SPLIT, &dev->flags);
1206 cdc_ncm_speed_change(dev,
1207 (struct usb_cdc_speed_change *)&event[1]);
1211 dev_dbg(&dev->udev->dev,
1212 "NCM: unexpected notification 0x%02x!\n",
1213 event->bNotificationType);
1218 static int cdc_ncm_check_connect(struct usbnet *dev)
1220 struct cdc_ncm_ctx *ctx;
1222 ctx = (struct cdc_ncm_ctx *)dev->data[0];
1224 return 1; /* disconnected */
1226 return !ctx->connected;
1229 static const struct driver_info cdc_ncm_info = {
1230 .description = "CDC NCM",
1231 .flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET,
1232 .bind = cdc_ncm_bind,
1233 .unbind = cdc_ncm_unbind,
1234 .check_connect = cdc_ncm_check_connect,
1235 .manage_power = usbnet_manage_power,
1236 .status = cdc_ncm_status,
1237 .rx_fixup = cdc_ncm_rx_fixup,
1238 .tx_fixup = cdc_ncm_tx_fixup,
1241 /* Same as cdc_ncm_info, but with FLAG_WWAN */
1242 static const struct driver_info wwan_info = {
1243 .description = "Mobile Broadband Network Device",
1244 .flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET
1246 .bind = cdc_ncm_bind,
1247 .unbind = cdc_ncm_unbind,
1248 .check_connect = cdc_ncm_check_connect,
1249 .manage_power = usbnet_manage_power,
1250 .status = cdc_ncm_status,
1251 .rx_fixup = cdc_ncm_rx_fixup,
1252 .tx_fixup = cdc_ncm_tx_fixup,
1255 /* Same as wwan_info, but with FLAG_NOARP */
1256 static const struct driver_info wwan_noarp_info = {
1257 .description = "Mobile Broadband Network Device (NO ARP)",
1258 .flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET
1259 | FLAG_WWAN | FLAG_NOARP,
1260 .bind = cdc_ncm_bind,
1261 .unbind = cdc_ncm_unbind,
1262 .check_connect = cdc_ncm_check_connect,
1263 .manage_power = usbnet_manage_power,
1264 .status = cdc_ncm_status,
1265 .rx_fixup = cdc_ncm_rx_fixup,
1266 .tx_fixup = cdc_ncm_tx_fixup,
1269 static const struct usb_device_id cdc_devs[] = {
1270 /* Ericsson MBM devices like F5521gw */
1271 { .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
1272 | USB_DEVICE_ID_MATCH_VENDOR,
1274 .bInterfaceClass = USB_CLASS_COMM,
1275 .bInterfaceSubClass = USB_CDC_SUBCLASS_NCM,
1276 .bInterfaceProtocol = USB_CDC_PROTO_NONE,
1277 .driver_info = (unsigned long) &wwan_info,
1280 /* Dell branded MBM devices like DW5550 */
1281 { .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
1282 | USB_DEVICE_ID_MATCH_VENDOR,
1284 .bInterfaceClass = USB_CLASS_COMM,
1285 .bInterfaceSubClass = USB_CDC_SUBCLASS_NCM,
1286 .bInterfaceProtocol = USB_CDC_PROTO_NONE,
1287 .driver_info = (unsigned long) &wwan_info,
1290 /* Toshiba branded MBM devices */
1291 { .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
1292 | USB_DEVICE_ID_MATCH_VENDOR,
1294 .bInterfaceClass = USB_CLASS_COMM,
1295 .bInterfaceSubClass = USB_CDC_SUBCLASS_NCM,
1296 .bInterfaceProtocol = USB_CDC_PROTO_NONE,
1297 .driver_info = (unsigned long) &wwan_info,
1300 /* tag Huawei devices as wwan */
1301 { USB_VENDOR_AND_INTERFACE_INFO(0x12d1,
1303 USB_CDC_SUBCLASS_NCM,
1304 USB_CDC_PROTO_NONE),
1305 .driver_info = (unsigned long)&wwan_info,
1308 /* Infineon(now Intel) HSPA Modem platform */
1309 { USB_DEVICE_AND_INTERFACE_INFO(0x1519, 0x0443,
1311 USB_CDC_SUBCLASS_NCM, USB_CDC_PROTO_NONE),
1312 .driver_info = (unsigned long)&wwan_noarp_info,
1315 /* Generic CDC-NCM devices */
1316 { USB_INTERFACE_INFO(USB_CLASS_COMM,
1317 USB_CDC_SUBCLASS_NCM, USB_CDC_PROTO_NONE),
1318 .driver_info = (unsigned long)&cdc_ncm_info,
1323 MODULE_DEVICE_TABLE(usb, cdc_devs);
1325 static struct usb_driver cdc_ncm_driver = {
1327 .id_table = cdc_devs,
1328 .probe = usbnet_probe,
1329 .disconnect = usbnet_disconnect,
1330 .suspend = usbnet_suspend,
1331 .resume = usbnet_resume,
1332 .reset_resume = usbnet_resume,
1333 .supports_autosuspend = 1,
1334 .disable_hub_initiated_lpm = 1,
1337 module_usb_driver(cdc_ncm_driver);
1339 MODULE_AUTHOR("Hans Petter Selasky");
1340 MODULE_DESCRIPTION("USB CDC NCM host driver");
1341 MODULE_LICENSE("Dual BSD/GPL");