24 #include <linux/module.h>
26 #include <linux/netdevice.h>
28 #include <linux/ethtool.h>
30 #include <linux/mii.h>
36 #if defined(CONFIG_USB_NET_RNDIS_HOST) || defined(CONFIG_USB_NET_RNDIS_HOST_MODULE)
61 #define is_rndis(desc) 0
62 #define is_activesync(desc) 0
63 #define is_wireless_rndis(desc) 0
67 static const u8 mbm_guid[16] = {
68 0xa3, 0x17, 0xa8, 0x8b, 0x04, 0x5e, 0x4f, 0x01,
69 0xa6, 0x07, 0xc0, 0xff, 0xcb, 0x7e, 0x39, 0x2a,
80 u8 *
buf = intf->cur_altsetting->extra;
81 int len = intf->cur_altsetting->extralen;
86 bool android_rndis_quirk =
false;
87 struct usb_driver *
driver = driver_of(intf);
91 if (
sizeof dev->
data <
sizeof *info)
97 if (len == 0 && dev->
udev->actconfig->extralen) {
101 buf = dev->
udev->actconfig->extra;
102 len = dev->
udev->actconfig->extralen;
103 dev_dbg(&intf->dev,
"CDC descriptors on config\n");
110 struct usb_host_endpoint *
hep;
112 hep = intf->cur_altsetting->endpoint;
119 "CDC descriptors on endpoint\n");
125 rndis = (
is_rndis(&intf->cur_altsetting->desc) ||
129 memset(info, 0,
sizeof *info);
145 dev_dbg(&intf->dev,
"extra CDC header\n");
148 info->
header = (
void *) buf;
150 dev_dbg(&intf->dev,
"CDC header len %u\n",
165 "ACM capabilities %02x, "
166 "not really RNDIS?\n",
174 dev_dbg(&intf->dev,
"extra CDC union\n");
177 info->
u = (
void *) buf;
178 if (info->
u->bLength !=
sizeof *info->
u) {
179 dev_dbg(&intf->dev,
"CDC union len %u\n",
189 info->
u->bMasterInterface0);
191 info->
u->bSlaveInterface0);
194 "master #%u/%p slave #%u/%p\n",
195 info->
u->bMasterInterface0,
197 info->
u->bSlaveInterface0,
201 android_rndis_quirk =
true;
207 dev_dbg(&intf->dev,
"bogus CDC Union\n");
211 if (info->
data == intf) {
219 d = &info->
data->cur_altsetting->desc;
221 dev_dbg(&intf->dev,
"slave class %u\n",
228 dev_dbg(&intf->dev,
"extra CDC ether\n");
231 info->
ether = (
void *) buf;
232 if (info->
ether->bLength !=
sizeof *info->
ether) {
233 dev_dbg(&intf->dev,
"CDC ether len %u\n",
234 info->
ether->bLength);
238 info->
ether->wMaxSegmentSize);
245 dev_dbg(&intf->dev,
"extra MDLM descriptor\n");
251 if (desc->
bLength !=
sizeof(*desc))
259 dev_dbg(&intf->dev,
"extra MDLM detail descriptor\n");
263 detail = (
void *)buf;
266 if (detail->
bLength < (
sizeof(*detail) + 1))
285 if (rndis && (!info->
u || android_rndis_quirk)) {
290 "rndis: master #0/%p slave #1/%p\n",
296 }
else if (!info->
header || !info->
u || (!rndis && !info->
ether)) {
297 dev_dbg(&intf->dev,
"missing cdc %s%s%sdescriptor\n",
298 info->
header ?
"" :
"header ",
299 info->
u ?
"" :
"union ",
300 info->
ether ?
"" :
"ether ");
320 if (info->
control->cur_altsetting->desc.bNumEndpoints == 1) {
324 desc = &dev->
status->desc;
325 if (!usb_endpoint_is_int_in(desc) ||
329 dev_dbg(&intf->dev,
"bad notification endpoint\n");
333 if (rndis && !dev->
status) {
334 dev_dbg(&intf->dev,
"missing RNDIS status endpoint\n");
350 struct usb_driver *
driver = driver_of(intf);
386 "link speeds: %u kbps up, %u kbps down\n",
395 if (urb->actual_length <
sizeof *event)
400 dumpspeed(dev, (
__le32 *) urb->transfer_buffer);
404 event = urb->transfer_buffer;
408 event->
wValue ?
"on" :
"off");
417 if (urb->actual_length != (
sizeof *event + 8))
420 dumpspeed(dev, (
__le32 *) &event[1]);
426 netdev_err(dev->
net,
"CDC: unexpected notification %02x!\n",
460 static int cdc_manage_power(
struct usbnet *dev,
int on)
462 dev->
intf->needs_remote_wakeup = on;
467 .description =
"CDC Ethernet Device",
473 .manage_power = cdc_manage_power,
477 .description =
"Mobile Broadband Network Device",
482 .manage_power = cdc_manage_power,
487 #define HUAWEI_VENDOR_ID 0x12D1
488 #define NOVATEL_VENDOR_ID 0x1410
489 #define ZTE_VENDOR_ID 0x19D2
501 #define ZAURUS_MASTER_INTERFACE \
502 .bInterfaceClass = USB_CLASS_COMM, \
503 .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, \
504 .bInterfaceProtocol = USB_CDC_PROTO_NONE
511 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
512 | USB_DEVICE_ID_MATCH_DEVICE,
525 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
526 | USB_DEVICE_ID_MATCH_DEVICE,
532 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
533 | USB_DEVICE_ID_MATCH_DEVICE,
539 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
540 | USB_DEVICE_ID_MATCH_DEVICE,
546 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
547 | USB_DEVICE_ID_MATCH_DEVICE,
553 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
554 | USB_DEVICE_ID_MATCH_DEVICE,
560 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
561 | USB_DEVICE_ID_MATCH_DEVICE,
573 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
574 | USB_DEVICE_ID_MATCH_DEVICE,
599 | USB_DEVICE_ID_MATCH_INT_INFO,
612 | USB_DEVICE_ID_MATCH_INT_INFO,
636 | USB_DEVICE_ID_MATCH_INT_INFO,
642 .driver_info = (
unsigned long)&wwan_info,
647 | USB_DEVICE_ID_MATCH_INT_INFO,
653 .driver_info = (
unsigned long)&wwan_info,
658 | USB_DEVICE_ID_MATCH_INT_INFO,
664 .driver_info = (
unsigned long)&wwan_info,
669 | USB_DEVICE_ID_MATCH_INT_INFO,
675 .driver_info = (
unsigned long)&wwan_info,
680 | USB_DEVICE_ID_MATCH_INT_INFO,
686 .driver_info = (
unsigned long)&wwan_info,
690 .driver_info = (
unsigned long) &cdc_info,
694 .driver_info = (
unsigned long)&wwan_info,
699 | USB_DEVICE_ID_MATCH_INT_INFO,
703 .bInterfaceProtocol = 255,
704 .driver_info = (
unsigned long)&wwan_info,
710 static struct usb_driver cdc_driver = {
712 .id_table = products,
718 .supports_autosuspend = 1,
719 .disable_hub_initiated_lpm = 1,