David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 1 | /* |
| 2 | * CDC Ethernet based networking peripherals |
| 3 | * Copyright (C) 2003-2005 by David Brownell |
Ole Andre Vadla Ravnas | ad55d71 | 2006-12-14 16:01:28 -0800 | [diff] [blame] | 4 | * Copyright (C) 2006 by Ole Andre Vadla Ravnas (ActiveSync) |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | */ |
| 20 | |
| 21 | // #define DEBUG // error path messages, extra info |
| 22 | // #define VERBOSE // more; success messages |
| 23 | |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 24 | #include <linux/module.h> |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 25 | #include <linux/init.h> |
| 26 | #include <linux/netdevice.h> |
| 27 | #include <linux/etherdevice.h> |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 28 | #include <linux/ethtool.h> |
| 29 | #include <linux/workqueue.h> |
| 30 | #include <linux/mii.h> |
| 31 | #include <linux/usb.h> |
David Brownell | a8c28f2 | 2006-06-13 09:57:47 -0700 | [diff] [blame] | 32 | #include <linux/usb/cdc.h> |
Jussi Kivilinna | 3692e94 | 2008-01-26 00:51:45 +0200 | [diff] [blame] | 33 | #include <linux/usb/usbnet.h> |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 34 | |
| 35 | |
Fabio Porcedda | 8857ec2 | 2013-09-16 11:47:51 +0200 | [diff] [blame^] | 36 | #if IS_ENABLED(CONFIG_USB_NET_RNDIS_HOST) |
Ole Andre Vadla Ravnas | ad55d71 | 2006-12-14 16:01:28 -0800 | [diff] [blame] | 37 | |
| 38 | static int is_rndis(struct usb_interface_descriptor *desc) |
| 39 | { |
Joe Perches | 8e95a20 | 2009-12-03 07:58:21 +0000 | [diff] [blame] | 40 | return (desc->bInterfaceClass == USB_CLASS_COMM && |
| 41 | desc->bInterfaceSubClass == 2 && |
| 42 | desc->bInterfaceProtocol == 0xff); |
Ole Andre Vadla Ravnas | ad55d71 | 2006-12-14 16:01:28 -0800 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | static int is_activesync(struct usb_interface_descriptor *desc) |
| 46 | { |
Joe Perches | 8e95a20 | 2009-12-03 07:58:21 +0000 | [diff] [blame] | 47 | return (desc->bInterfaceClass == USB_CLASS_MISC && |
| 48 | desc->bInterfaceSubClass == 1 && |
| 49 | desc->bInterfaceProtocol == 1); |
Ole Andre Vadla Ravnas | ad55d71 | 2006-12-14 16:01:28 -0800 | [diff] [blame] | 50 | } |
| 51 | |
Thomas Backlund | 7e99eed | 2008-07-22 13:55:58 -0700 | [diff] [blame] | 52 | static int is_wireless_rndis(struct usb_interface_descriptor *desc) |
| 53 | { |
Joe Perches | 8e95a20 | 2009-12-03 07:58:21 +0000 | [diff] [blame] | 54 | return (desc->bInterfaceClass == USB_CLASS_WIRELESS_CONTROLLER && |
| 55 | desc->bInterfaceSubClass == 1 && |
| 56 | desc->bInterfaceProtocol == 3); |
Thomas Backlund | 7e99eed | 2008-07-22 13:55:58 -0700 | [diff] [blame] | 57 | } |
| 58 | |
Ole Andre Vadla Ravnas | ad55d71 | 2006-12-14 16:01:28 -0800 | [diff] [blame] | 59 | #else |
| 60 | |
| 61 | #define is_rndis(desc) 0 |
| 62 | #define is_activesync(desc) 0 |
Thomas Backlund | 7e99eed | 2008-07-22 13:55:58 -0700 | [diff] [blame] | 63 | #define is_wireless_rndis(desc) 0 |
Ole Andre Vadla Ravnas | ad55d71 | 2006-12-14 16:01:28 -0800 | [diff] [blame] | 64 | |
| 65 | #endif |
| 66 | |
Jonas Sjöquist | 2185126 | 2010-04-23 01:07:45 +0000 | [diff] [blame] | 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, |
| 70 | }; |
| 71 | |
Fabio Porcedda | 8857ec2 | 2013-09-16 11:47:51 +0200 | [diff] [blame^] | 72 | /* probes control interface, claims data interface, collects the bulk |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 73 | * endpoints, activates data interface (if needed), maybe sets MTU. |
| 74 | * all pure cdc, except for certain firmware workarounds, and knowing |
| 75 | * that rndis uses one different rule. |
| 76 | */ |
| 77 | int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf) |
| 78 | { |
| 79 | u8 *buf = intf->cur_altsetting->extra; |
| 80 | int len = intf->cur_altsetting->extralen; |
| 81 | struct usb_interface_descriptor *d; |
| 82 | struct cdc_state *info = (void *) &dev->data; |
| 83 | int status; |
| 84 | int rndis; |
Bjørn Mork | 6eddcb4 | 2012-04-26 02:35:10 +0000 | [diff] [blame] | 85 | bool android_rndis_quirk = false; |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 86 | struct usb_driver *driver = driver_of(intf); |
Jonas Sjöquist | 2185126 | 2010-04-23 01:07:45 +0000 | [diff] [blame] | 87 | struct usb_cdc_mdlm_desc *desc = NULL; |
| 88 | struct usb_cdc_mdlm_detail_desc *detail = NULL; |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 89 | |
Fabio Porcedda | 8857ec2 | 2013-09-16 11:47:51 +0200 | [diff] [blame^] | 90 | if (sizeof(dev->data) < sizeof(*info)) |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 91 | return -EDOM; |
| 92 | |
| 93 | /* expect strict spec conformance for the descriptors, but |
| 94 | * cope with firmware which stores them in the wrong place |
| 95 | */ |
| 96 | if (len == 0 && dev->udev->actconfig->extralen) { |
| 97 | /* Motorola SB4100 (and others: Brad Hards says it's |
| 98 | * from a Broadcom design) put CDC descriptors here |
| 99 | */ |
| 100 | buf = dev->udev->actconfig->extra; |
| 101 | len = dev->udev->actconfig->extralen; |
Dan Carpenter | f5260f0 | 2010-12-25 12:23:42 +0000 | [diff] [blame] | 102 | dev_dbg(&intf->dev, "CDC descriptors on config\n"); |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 103 | } |
| 104 | |
David Brownell | 4149b72 | 2007-04-29 10:09:47 -0700 | [diff] [blame] | 105 | /* Maybe CDC descriptors are after the endpoint? This bug has |
| 106 | * been seen on some 2Wire Inc RNDIS-ish products. |
| 107 | */ |
| 108 | if (len == 0) { |
| 109 | struct usb_host_endpoint *hep; |
| 110 | |
| 111 | hep = intf->cur_altsetting->endpoint; |
| 112 | if (hep) { |
| 113 | buf = hep->extra; |
| 114 | len = hep->extralen; |
| 115 | } |
| 116 | if (len) |
| 117 | dev_dbg(&intf->dev, |
| 118 | "CDC descriptors on endpoint\n"); |
| 119 | } |
| 120 | |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 121 | /* this assumes that if there's a non-RNDIS vendor variant |
| 122 | * of cdc-acm, it'll fail RNDIS requests cleanly. |
| 123 | */ |
Joe Perches | 8e95a20 | 2009-12-03 07:58:21 +0000 | [diff] [blame] | 124 | rndis = (is_rndis(&intf->cur_altsetting->desc) || |
| 125 | is_activesync(&intf->cur_altsetting->desc) || |
| 126 | is_wireless_rndis(&intf->cur_altsetting->desc)); |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 127 | |
Fabio Porcedda | 8857ec2 | 2013-09-16 11:47:51 +0200 | [diff] [blame^] | 128 | memset(info, 0, sizeof(*info)); |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 129 | info->control = intf; |
| 130 | while (len > 3) { |
Fabio Porcedda | 8857ec2 | 2013-09-16 11:47:51 +0200 | [diff] [blame^] | 131 | if (buf[1] != USB_DT_CS_INTERFACE) |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 132 | goto next_desc; |
| 133 | |
| 134 | /* use bDescriptorSubType to identify the CDC descriptors. |
| 135 | * We expect devices with CDC header and union descriptors. |
| 136 | * For CDC Ethernet we need the ethernet descriptor. |
| 137 | * For RNDIS, ignore two (pointless) CDC modem descriptors |
| 138 | * in favor of a complicated OID-based RPC scheme doing what |
| 139 | * CDC Ethernet achieves with a simple descriptor. |
| 140 | */ |
Fabio Porcedda | 8857ec2 | 2013-09-16 11:47:51 +0200 | [diff] [blame^] | 141 | switch (buf[2]) { |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 142 | case USB_CDC_HEADER_TYPE: |
| 143 | if (info->header) { |
| 144 | dev_dbg(&intf->dev, "extra CDC header\n"); |
| 145 | goto bad_desc; |
| 146 | } |
| 147 | info->header = (void *) buf; |
Fabio Porcedda | 8857ec2 | 2013-09-16 11:47:51 +0200 | [diff] [blame^] | 148 | if (info->header->bLength != sizeof(*info->header)) { |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 149 | dev_dbg(&intf->dev, "CDC header len %u\n", |
| 150 | info->header->bLength); |
| 151 | goto bad_desc; |
| 152 | } |
| 153 | break; |
Ole Andre Vadla Ravnas | ad55d71 | 2006-12-14 16:01:28 -0800 | [diff] [blame] | 154 | case USB_CDC_ACM_TYPE: |
| 155 | /* paranoia: disambiguate a "real" vendor-specific |
| 156 | * modem interface from an RNDIS non-modem. |
| 157 | */ |
| 158 | if (rndis) { |
David Brownell | afaee82 | 2007-07-01 11:47:59 -0700 | [diff] [blame] | 159 | struct usb_cdc_acm_descriptor *acm; |
Ole Andre Vadla Ravnas | ad55d71 | 2006-12-14 16:01:28 -0800 | [diff] [blame] | 160 | |
David Brownell | afaee82 | 2007-07-01 11:47:59 -0700 | [diff] [blame] | 161 | acm = (void *) buf; |
| 162 | if (acm->bmCapabilities) { |
Ole Andre Vadla Ravnas | ad55d71 | 2006-12-14 16:01:28 -0800 | [diff] [blame] | 163 | dev_dbg(&intf->dev, |
| 164 | "ACM capabilities %02x, " |
| 165 | "not really RNDIS?\n", |
David Brownell | afaee82 | 2007-07-01 11:47:59 -0700 | [diff] [blame] | 166 | acm->bmCapabilities); |
Ole Andre Vadla Ravnas | ad55d71 | 2006-12-14 16:01:28 -0800 | [diff] [blame] | 167 | goto bad_desc; |
| 168 | } |
| 169 | } |
| 170 | break; |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 171 | case USB_CDC_UNION_TYPE: |
| 172 | if (info->u) { |
| 173 | dev_dbg(&intf->dev, "extra CDC union\n"); |
| 174 | goto bad_desc; |
| 175 | } |
| 176 | info->u = (void *) buf; |
Fabio Porcedda | 8857ec2 | 2013-09-16 11:47:51 +0200 | [diff] [blame^] | 177 | if (info->u->bLength != sizeof(*info->u)) { |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 178 | dev_dbg(&intf->dev, "CDC union len %u\n", |
| 179 | info->u->bLength); |
| 180 | goto bad_desc; |
| 181 | } |
| 182 | |
| 183 | /* we need a master/control interface (what we're |
| 184 | * probed with) and a slave/data interface; union |
| 185 | * descriptors sort this all out. |
| 186 | */ |
| 187 | info->control = usb_ifnum_to_if(dev->udev, |
| 188 | info->u->bMasterInterface0); |
| 189 | info->data = usb_ifnum_to_if(dev->udev, |
| 190 | info->u->bSlaveInterface0); |
| 191 | if (!info->control || !info->data) { |
| 192 | dev_dbg(&intf->dev, |
| 193 | "master #%u/%p slave #%u/%p\n", |
| 194 | info->u->bMasterInterface0, |
| 195 | info->control, |
| 196 | info->u->bSlaveInterface0, |
| 197 | info->data); |
Bjørn Mork | 6eddcb4 | 2012-04-26 02:35:10 +0000 | [diff] [blame] | 198 | /* fall back to hard-wiring for RNDIS */ |
| 199 | if (rndis) { |
| 200 | android_rndis_quirk = true; |
| 201 | goto next_desc; |
| 202 | } |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 203 | goto bad_desc; |
| 204 | } |
| 205 | if (info->control != intf) { |
| 206 | dev_dbg(&intf->dev, "bogus CDC Union\n"); |
| 207 | /* Ambit USB Cable Modem (and maybe others) |
| 208 | * interchanges master and slave interface. |
| 209 | */ |
| 210 | if (info->data == intf) { |
| 211 | info->data = info->control; |
| 212 | info->control = intf; |
| 213 | } else |
| 214 | goto bad_desc; |
| 215 | } |
| 216 | |
Bjørn Mork | 1fc4c84 | 2013-06-29 12:03:06 +0200 | [diff] [blame] | 217 | /* some devices merge these - skip class check */ |
| 218 | if (info->control == info->data) |
| 219 | goto next_desc; |
| 220 | |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 221 | /* a data interface altsetting does the real i/o */ |
| 222 | d = &info->data->cur_altsetting->desc; |
| 223 | if (d->bInterfaceClass != USB_CLASS_CDC_DATA) { |
| 224 | dev_dbg(&intf->dev, "slave class %u\n", |
| 225 | d->bInterfaceClass); |
| 226 | goto bad_desc; |
| 227 | } |
| 228 | break; |
| 229 | case USB_CDC_ETHERNET_TYPE: |
| 230 | if (info->ether) { |
| 231 | dev_dbg(&intf->dev, "extra CDC ether\n"); |
| 232 | goto bad_desc; |
| 233 | } |
| 234 | info->ether = (void *) buf; |
Fabio Porcedda | 8857ec2 | 2013-09-16 11:47:51 +0200 | [diff] [blame^] | 235 | if (info->ether->bLength != sizeof(*info->ether)) { |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 236 | dev_dbg(&intf->dev, "CDC ether len %u\n", |
| 237 | info->ether->bLength); |
| 238 | goto bad_desc; |
| 239 | } |
| 240 | dev->hard_mtu = le16_to_cpu( |
| 241 | info->ether->wMaxSegmentSize); |
| 242 | /* because of Zaurus, we may be ignoring the host |
| 243 | * side link address we were given. |
| 244 | */ |
| 245 | break; |
Jonas Sjöquist | 2185126 | 2010-04-23 01:07:45 +0000 | [diff] [blame] | 246 | case USB_CDC_MDLM_TYPE: |
| 247 | if (desc) { |
| 248 | dev_dbg(&intf->dev, "extra MDLM descriptor\n"); |
| 249 | goto bad_desc; |
| 250 | } |
| 251 | |
| 252 | desc = (void *)buf; |
| 253 | |
| 254 | if (desc->bLength != sizeof(*desc)) |
| 255 | goto bad_desc; |
| 256 | |
| 257 | if (memcmp(&desc->bGUID, mbm_guid, 16)) |
| 258 | goto bad_desc; |
| 259 | break; |
| 260 | case USB_CDC_MDLM_DETAIL_TYPE: |
| 261 | if (detail) { |
| 262 | dev_dbg(&intf->dev, "extra MDLM detail descriptor\n"); |
| 263 | goto bad_desc; |
| 264 | } |
| 265 | |
| 266 | detail = (void *)buf; |
| 267 | |
| 268 | if (detail->bGuidDescriptorType == 0) { |
| 269 | if (detail->bLength < (sizeof(*detail) + 1)) |
| 270 | goto bad_desc; |
| 271 | } else |
| 272 | goto bad_desc; |
| 273 | break; |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 274 | } |
| 275 | next_desc: |
Fabio Porcedda | 8857ec2 | 2013-09-16 11:47:51 +0200 | [diff] [blame^] | 276 | len -= buf[0]; /* bLength */ |
| 277 | buf += buf[0]; |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 278 | } |
| 279 | |
Bjorge Dijkstra | 786e3df | 2008-01-26 00:50:44 +0200 | [diff] [blame] | 280 | /* Microsoft ActiveSync based and some regular RNDIS devices lack the |
| 281 | * CDC descriptors, so we'll hard-wire the interfaces and not check |
| 282 | * for descriptors. |
Bjørn Mork | 6eddcb4 | 2012-04-26 02:35:10 +0000 | [diff] [blame] | 283 | * |
| 284 | * Some Android RNDIS devices have a CDC Union descriptor pointing |
| 285 | * to non-existing interfaces. Ignore that and attempt the same |
| 286 | * hard-wired 0 and 1 interfaces. |
Ole Andre Vadla Ravnas | ad55d71 | 2006-12-14 16:01:28 -0800 | [diff] [blame] | 287 | */ |
Bjørn Mork | 6eddcb4 | 2012-04-26 02:35:10 +0000 | [diff] [blame] | 288 | if (rndis && (!info->u || android_rndis_quirk)) { |
Ole Andre Vadla Ravnas | ad55d71 | 2006-12-14 16:01:28 -0800 | [diff] [blame] | 289 | info->control = usb_ifnum_to_if(dev->udev, 0); |
| 290 | info->data = usb_ifnum_to_if(dev->udev, 1); |
Bjørn Mork | 6eddcb4 | 2012-04-26 02:35:10 +0000 | [diff] [blame] | 291 | if (!info->control || !info->data || info->control != intf) { |
Ole Andre Vadla Ravnas | ad55d71 | 2006-12-14 16:01:28 -0800 | [diff] [blame] | 292 | dev_dbg(&intf->dev, |
Bjorge Dijkstra | 786e3df | 2008-01-26 00:50:44 +0200 | [diff] [blame] | 293 | "rndis: master #0/%p slave #1/%p\n", |
Ole Andre Vadla Ravnas | ad55d71 | 2006-12-14 16:01:28 -0800 | [diff] [blame] | 294 | info->control, |
| 295 | info->data); |
| 296 | goto bad_desc; |
| 297 | } |
| 298 | |
| 299 | } else if (!info->header || !info->u || (!rndis && !info->ether)) { |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 300 | dev_dbg(&intf->dev, "missing cdc %s%s%sdescriptor\n", |
| 301 | info->header ? "" : "header ", |
| 302 | info->u ? "" : "union ", |
| 303 | info->ether ? "" : "ether "); |
| 304 | goto bad_desc; |
| 305 | } |
| 306 | |
| 307 | /* claim data interface and set it up ... with side effects. |
| 308 | * network traffic can't flow until an altsetting is enabled. |
| 309 | */ |
Bjørn Mork | 1fc4c84 | 2013-06-29 12:03:06 +0200 | [diff] [blame] | 310 | if (info->data != info->control) { |
| 311 | status = usb_driver_claim_interface(driver, info->data, dev); |
| 312 | if (status < 0) |
| 313 | return status; |
| 314 | } |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 315 | status = usbnet_get_endpoints(dev, info->data); |
| 316 | if (status < 0) { |
| 317 | /* ensure immediate exit from usbnet_disconnect */ |
| 318 | usb_set_intfdata(info->data, NULL); |
Bjørn Mork | 1fc4c84 | 2013-06-29 12:03:06 +0200 | [diff] [blame] | 319 | if (info->data != info->control) |
| 320 | usb_driver_release_interface(driver, info->data); |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 321 | return status; |
| 322 | } |
| 323 | |
| 324 | /* status endpoint: optional for CDC Ethernet, not RNDIS (or ACM) */ |
Bjørn Mork | 1fc4c84 | 2013-06-29 12:03:06 +0200 | [diff] [blame] | 325 | if (info->data != info->control) |
| 326 | dev->status = NULL; |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 327 | if (info->control->cur_altsetting->desc.bNumEndpoints == 1) { |
| 328 | struct usb_endpoint_descriptor *desc; |
| 329 | |
| 330 | dev->status = &info->control->cur_altsetting->endpoint [0]; |
| 331 | desc = &dev->status->desc; |
Joe Perches | 8e95a20 | 2009-12-03 07:58:21 +0000 | [diff] [blame] | 332 | if (!usb_endpoint_is_int_in(desc) || |
| 333 | (le16_to_cpu(desc->wMaxPacketSize) |
| 334 | < sizeof(struct usb_cdc_notification)) || |
| 335 | !desc->bInterval) { |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 336 | dev_dbg(&intf->dev, "bad notification endpoint\n"); |
| 337 | dev->status = NULL; |
| 338 | } |
| 339 | } |
| 340 | if (rndis && !dev->status) { |
| 341 | dev_dbg(&intf->dev, "missing RNDIS status endpoint\n"); |
| 342 | usb_set_intfdata(info->data, NULL); |
| 343 | usb_driver_release_interface(driver, info->data); |
| 344 | return -ENODEV; |
| 345 | } |
| 346 | return 0; |
| 347 | |
| 348 | bad_desc: |
| 349 | dev_info(&dev->udev->dev, "bad CDC descriptors\n"); |
| 350 | return -ENODEV; |
| 351 | } |
| 352 | EXPORT_SYMBOL_GPL(usbnet_generic_cdc_bind); |
| 353 | |
| 354 | void usbnet_cdc_unbind(struct usbnet *dev, struct usb_interface *intf) |
| 355 | { |
| 356 | struct cdc_state *info = (void *) &dev->data; |
| 357 | struct usb_driver *driver = driver_of(intf); |
| 358 | |
Bjørn Mork | 1fc4c84 | 2013-06-29 12:03:06 +0200 | [diff] [blame] | 359 | /* combined interface - nothing to do */ |
| 360 | if (info->data == info->control) |
| 361 | return; |
| 362 | |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 363 | /* disconnect master --> disconnect slave */ |
| 364 | if (intf == info->control && info->data) { |
| 365 | /* ensure immediate exit from usbnet_disconnect */ |
| 366 | usb_set_intfdata(info->data, NULL); |
| 367 | usb_driver_release_interface(driver, info->data); |
| 368 | info->data = NULL; |
| 369 | } |
| 370 | |
| 371 | /* and vice versa (just in case) */ |
| 372 | else if (intf == info->data && info->control) { |
| 373 | /* ensure immediate exit from usbnet_disconnect */ |
| 374 | usb_set_intfdata(info->control, NULL); |
| 375 | usb_driver_release_interface(driver, info->control); |
| 376 | info->control = NULL; |
| 377 | } |
| 378 | } |
| 379 | EXPORT_SYMBOL_GPL(usbnet_cdc_unbind); |
| 380 | |
Fabio Porcedda | 8857ec2 | 2013-09-16 11:47:51 +0200 | [diff] [blame^] | 381 | /* Communications Device Class, Ethernet Control model |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 382 | * |
| 383 | * Takes two interfaces. The DATA interface is inactive till an altsetting |
| 384 | * is selected. Configuration data includes class descriptors. There's |
| 385 | * an optional status endpoint on the control interface. |
| 386 | * |
| 387 | * This should interop with whatever the 2.4 "CDCEther.c" driver |
| 388 | * (by Brad Hards) talked with, with more functionality. |
Fabio Porcedda | 8857ec2 | 2013-09-16 11:47:51 +0200 | [diff] [blame^] | 389 | */ |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 390 | |
| 391 | static void dumpspeed(struct usbnet *dev, __le32 *speeds) |
| 392 | { |
Joe Perches | a475f60 | 2010-02-17 10:30:24 +0000 | [diff] [blame] | 393 | netif_info(dev, timer, dev->net, |
| 394 | "link speeds: %u kbps up, %u kbps down\n", |
| 395 | __le32_to_cpu(speeds[0]) / 1000, |
| 396 | __le32_to_cpu(speeds[1]) / 1000); |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 397 | } |
| 398 | |
Andrzej Zaborowski | 7a635ea | 2011-03-28 12:56:33 +0000 | [diff] [blame] | 399 | void usbnet_cdc_status(struct usbnet *dev, struct urb *urb) |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 400 | { |
| 401 | struct usb_cdc_notification *event; |
| 402 | |
Fabio Porcedda | 8857ec2 | 2013-09-16 11:47:51 +0200 | [diff] [blame^] | 403 | if (urb->actual_length < sizeof(*event)) |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 404 | return; |
| 405 | |
| 406 | /* SPEED_CHANGE can get split into two 8-byte packets */ |
| 407 | if (test_and_clear_bit(EVENT_STS_SPLIT, &dev->flags)) { |
| 408 | dumpspeed(dev, (__le32 *) urb->transfer_buffer); |
| 409 | return; |
| 410 | } |
| 411 | |
| 412 | event = urb->transfer_buffer; |
| 413 | switch (event->bNotificationType) { |
| 414 | case USB_CDC_NOTIFY_NETWORK_CONNECTION: |
Joe Perches | a475f60 | 2010-02-17 10:30:24 +0000 | [diff] [blame] | 415 | netif_dbg(dev, timer, dev->net, "CDC: carrier %s\n", |
| 416 | event->wValue ? "on" : "off"); |
Bjørn Mork | a6bda45 | 2013-04-16 22:12:13 +0000 | [diff] [blame] | 417 | usbnet_link_change(dev, !!event->wValue, 0); |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 418 | break; |
| 419 | case USB_CDC_NOTIFY_SPEED_CHANGE: /* tx/rx rates */ |
Joe Perches | a475f60 | 2010-02-17 10:30:24 +0000 | [diff] [blame] | 420 | netif_dbg(dev, timer, dev->net, "CDC: speed change (len %d)\n", |
| 421 | urb->actual_length); |
Fabio Porcedda | 8857ec2 | 2013-09-16 11:47:51 +0200 | [diff] [blame^] | 422 | if (urb->actual_length != (sizeof(*event) + 8)) |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 423 | set_bit(EVENT_STS_SPLIT, &dev->flags); |
| 424 | else |
| 425 | dumpspeed(dev, (__le32 *) &event[1]); |
| 426 | break; |
| 427 | /* USB_CDC_NOTIFY_RESPONSE_AVAILABLE can happen too (e.g. RNDIS), |
| 428 | * but there are no standard formats for the response data. |
| 429 | */ |
| 430 | default: |
Joe Perches | 60b8675 | 2010-02-17 10:30:23 +0000 | [diff] [blame] | 431 | netdev_err(dev->net, "CDC: unexpected notification %02x!\n", |
| 432 | event->bNotificationType); |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 433 | break; |
| 434 | } |
| 435 | } |
Andrzej Zaborowski | 7a635ea | 2011-03-28 12:56:33 +0000 | [diff] [blame] | 436 | EXPORT_SYMBOL_GPL(usbnet_cdc_status); |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 437 | |
Andrzej Zaborowski | 7a635ea | 2011-03-28 12:56:33 +0000 | [diff] [blame] | 438 | int usbnet_cdc_bind(struct usbnet *dev, struct usb_interface *intf) |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 439 | { |
| 440 | int status; |
| 441 | struct cdc_state *info = (void *) &dev->data; |
| 442 | |
Greg Kroah-Hartman | d632eb1 | 2011-11-18 09:44:20 -0800 | [diff] [blame] | 443 | BUILD_BUG_ON((sizeof(((struct usbnet *)0)->data) |
| 444 | < sizeof(struct cdc_state))); |
| 445 | |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 446 | status = usbnet_generic_cdc_bind(dev, intf); |
| 447 | if (status < 0) |
| 448 | return status; |
| 449 | |
Peter Holik | 03ad032 | 2009-04-18 07:24:17 +0000 | [diff] [blame] | 450 | status = usbnet_get_ethernet_addr(dev, info->ether->iMACAddress); |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 451 | if (status < 0) { |
| 452 | usb_set_intfdata(info->data, NULL); |
| 453 | usb_driver_release_interface(driver_of(intf), info->data); |
| 454 | return status; |
| 455 | } |
| 456 | |
| 457 | /* FIXME cdc-ether has some multicast code too, though it complains |
| 458 | * in routine cases. info->ether describes the multicast support. |
| 459 | * Implement that here, manipulating the cdc filter as needed. |
| 460 | */ |
| 461 | return 0; |
| 462 | } |
Andrzej Zaborowski | 7a635ea | 2011-03-28 12:56:33 +0000 | [diff] [blame] | 463 | EXPORT_SYMBOL_GPL(usbnet_cdc_bind); |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 464 | |
| 465 | static const struct driver_info cdc_info = { |
| 466 | .description = "CDC Ethernet Device", |
Arnd Bergmann | c261344 | 2011-04-01 20:12:02 -0700 | [diff] [blame] | 467 | .flags = FLAG_ETHER | FLAG_POINTTOPOINT, |
Andrzej Zaborowski | 7a635ea | 2011-03-28 12:56:33 +0000 | [diff] [blame] | 468 | .bind = usbnet_cdc_bind, |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 469 | .unbind = usbnet_cdc_unbind, |
Andrzej Zaborowski | 7a635ea | 2011-03-28 12:56:33 +0000 | [diff] [blame] | 470 | .status = usbnet_cdc_status, |
Oliver Neukum | a5e4070 | 2012-12-18 04:46:12 +0000 | [diff] [blame] | 471 | .manage_power = usbnet_manage_power, |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 472 | }; |
| 473 | |
Dan Williams | b3c914a | 2011-04-27 09:54:28 +0000 | [diff] [blame] | 474 | static const struct driver_info wwan_info = { |
Marcel Holtmann | e1e499e | 2009-10-02 05:15:25 +0000 | [diff] [blame] | 475 | .description = "Mobile Broadband Network Device", |
| 476 | .flags = FLAG_WWAN, |
Andrzej Zaborowski | 7a635ea | 2011-03-28 12:56:33 +0000 | [diff] [blame] | 477 | .bind = usbnet_cdc_bind, |
Marcel Holtmann | e1e499e | 2009-10-02 05:15:25 +0000 | [diff] [blame] | 478 | .unbind = usbnet_cdc_unbind, |
Andrzej Zaborowski | 7a635ea | 2011-03-28 12:56:33 +0000 | [diff] [blame] | 479 | .status = usbnet_cdc_status, |
Oliver Neukum | a5e4070 | 2012-12-18 04:46:12 +0000 | [diff] [blame] | 480 | .manage_power = usbnet_manage_power, |
Marcel Holtmann | e1e499e | 2009-10-02 05:15:25 +0000 | [diff] [blame] | 481 | }; |
| 482 | |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 483 | /*-------------------------------------------------------------------------*/ |
| 484 | |
Dan Williams | b3c914a | 2011-04-27 09:54:28 +0000 | [diff] [blame] | 485 | #define HUAWEI_VENDOR_ID 0x12D1 |
Dan Williams | 4e6304b | 2012-05-07 04:24:51 +0000 | [diff] [blame] | 486 | #define NOVATEL_VENDOR_ID 0x1410 |
Andrew Bird (Sphere Systems) | 68d8318 | 2012-05-19 03:56:07 +0000 | [diff] [blame] | 487 | #define ZTE_VENDOR_ID 0x19D2 |
Dan Williams | 0370acd | 2012-12-17 08:17:41 +0000 | [diff] [blame] | 488 | #define DELL_VENDOR_ID 0x413C |
hayeswang | ac718b6 | 2013-05-02 16:01:25 +0000 | [diff] [blame] | 489 | #define REALTEK_VENDOR_ID 0x0bda |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 490 | |
Fabio Porcedda | 8857ec2 | 2013-09-16 11:47:51 +0200 | [diff] [blame^] | 491 | static const struct usb_device_id products[] = { |
| 492 | /* BLACKLIST !! |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 493 | * |
| 494 | * First blacklist any products that are egregiously nonconformant |
| 495 | * with the CDC Ethernet specs. Minor braindamage we cope with; when |
| 496 | * they're not even trying, needing a separate driver is only the first |
| 497 | * of the differences to show up. |
| 498 | */ |
| 499 | |
| 500 | #define ZAURUS_MASTER_INTERFACE \ |
| 501 | .bInterfaceClass = USB_CLASS_COMM, \ |
| 502 | .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, \ |
| 503 | .bInterfaceProtocol = USB_CDC_PROTO_NONE |
| 504 | |
| 505 | /* SA-1100 based Sharp Zaurus ("collie"), or compatible; |
| 506 | * wire-incompatible with true CDC Ethernet implementations. |
| 507 | * (And, it seems, needlessly so...) |
| 508 | */ |
| 509 | { |
| 510 | .match_flags = USB_DEVICE_ID_MATCH_INT_INFO |
| 511 | | USB_DEVICE_ID_MATCH_DEVICE, |
| 512 | .idVendor = 0x04DD, |
| 513 | .idProduct = 0x8004, |
| 514 | ZAURUS_MASTER_INTERFACE, |
| 515 | .driver_info = 0, |
| 516 | }, |
| 517 | |
| 518 | /* PXA-25x based Sharp Zaurii. Note that it seems some of these |
| 519 | * (later models especially) may have shipped only with firmware |
| 520 | * advertising false "CDC MDLM" compatibility ... but we're not |
| 521 | * clear which models did that, so for now let's assume the worst. |
| 522 | */ |
| 523 | { |
| 524 | .match_flags = USB_DEVICE_ID_MATCH_INT_INFO |
| 525 | | USB_DEVICE_ID_MATCH_DEVICE, |
| 526 | .idVendor = 0x04DD, |
| 527 | .idProduct = 0x8005, /* A-300 */ |
| 528 | ZAURUS_MASTER_INTERFACE, |
| 529 | .driver_info = 0, |
| 530 | }, { |
| 531 | .match_flags = USB_DEVICE_ID_MATCH_INT_INFO |
| 532 | | USB_DEVICE_ID_MATCH_DEVICE, |
| 533 | .idVendor = 0x04DD, |
| 534 | .idProduct = 0x8006, /* B-500/SL-5600 */ |
| 535 | ZAURUS_MASTER_INTERFACE, |
| 536 | .driver_info = 0, |
| 537 | }, { |
| 538 | .match_flags = USB_DEVICE_ID_MATCH_INT_INFO |
Fabio Porcedda | 8857ec2 | 2013-09-16 11:47:51 +0200 | [diff] [blame^] | 539 | | USB_DEVICE_ID_MATCH_DEVICE, |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 540 | .idVendor = 0x04DD, |
| 541 | .idProduct = 0x8007, /* C-700 */ |
| 542 | ZAURUS_MASTER_INTERFACE, |
| 543 | .driver_info = 0, |
| 544 | }, { |
| 545 | .match_flags = USB_DEVICE_ID_MATCH_INT_INFO |
| 546 | | USB_DEVICE_ID_MATCH_DEVICE, |
| 547 | .idVendor = 0x04DD, |
| 548 | .idProduct = 0x9031, /* C-750 C-760 */ |
| 549 | ZAURUS_MASTER_INTERFACE, |
| 550 | .driver_info = 0, |
| 551 | }, { |
| 552 | .match_flags = USB_DEVICE_ID_MATCH_INT_INFO |
| 553 | | USB_DEVICE_ID_MATCH_DEVICE, |
| 554 | .idVendor = 0x04DD, |
| 555 | .idProduct = 0x9032, /* SL-6000 */ |
| 556 | ZAURUS_MASTER_INTERFACE, |
| 557 | .driver_info = 0, |
| 558 | }, { |
| 559 | .match_flags = USB_DEVICE_ID_MATCH_INT_INFO |
| 560 | | USB_DEVICE_ID_MATCH_DEVICE, |
| 561 | .idVendor = 0x04DD, |
| 562 | /* reported with some C860 units */ |
| 563 | .idProduct = 0x9050, /* C-860 */ |
| 564 | ZAURUS_MASTER_INTERFACE, |
| 565 | .driver_info = 0, |
| 566 | }, |
| 567 | |
David Brownell | efcaa20 | 2006-05-30 20:49:29 -0700 | [diff] [blame] | 568 | /* Olympus has some models with a Zaurus-compatible option. |
| 569 | * R-1000 uses a FreeScale i.MXL cpu (ARMv4T) |
| 570 | */ |
| 571 | { |
| 572 | .match_flags = USB_DEVICE_ID_MATCH_INT_INFO |
| 573 | | USB_DEVICE_ID_MATCH_DEVICE, |
| 574 | .idVendor = 0x07B4, |
| 575 | .idProduct = 0x0F02, /* R-1000 */ |
| 576 | ZAURUS_MASTER_INTERFACE, |
| 577 | .driver_info = 0, |
| 578 | }, |
| 579 | |
Andrzej Zaborowski | 7a635ea | 2011-03-28 12:56:33 +0000 | [diff] [blame] | 580 | /* LG Electronics VL600 wants additional headers on every frame */ |
| 581 | { |
| 582 | USB_DEVICE_AND_INTERFACE_INFO(0x1004, 0x61aa, USB_CLASS_COMM, |
| 583 | USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), |
Mark Kamichoff | 6d74eb9 | 2011-11-09 11:48:10 +0000 | [diff] [blame] | 584 | .driver_info = 0, |
Andrzej Zaborowski | 7a635ea | 2011-03-28 12:56:33 +0000 | [diff] [blame] | 585 | }, |
| 586 | |
Scott Talbert | ee932bf | 2012-02-21 13:06:00 +0000 | [diff] [blame] | 587 | /* Logitech Harmony 900 - uses the pseudo-MDLM (BLAN) driver */ |
| 588 | { |
| 589 | USB_DEVICE_AND_INTERFACE_INFO(0x046d, 0xc11f, USB_CLASS_COMM, |
| 590 | USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE), |
| 591 | .driver_info = 0, |
| 592 | }, |
| 593 | |
Dan Williams | f8295ec | 2012-10-24 12:10:34 +0000 | [diff] [blame] | 594 | /* Novatel USB551L and MC551 - handled by qmi_wwan */ |
| 595 | { |
Dan Williams | c39ba1c | 2012-12-17 08:19:46 +0000 | [diff] [blame] | 596 | USB_DEVICE_AND_INTERFACE_INFO(NOVATEL_VENDOR_ID, 0xB001, USB_CLASS_COMM, |
| 597 | USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), |
Dan Williams | f8295ec | 2012-10-24 12:10:34 +0000 | [diff] [blame] | 598 | .driver_info = 0, |
| 599 | }, |
| 600 | |
| 601 | /* Novatel E362 - handled by qmi_wwan */ |
| 602 | { |
Dan Williams | c39ba1c | 2012-12-17 08:19:46 +0000 | [diff] [blame] | 603 | USB_DEVICE_AND_INTERFACE_INFO(NOVATEL_VENDOR_ID, 0x9010, USB_CLASS_COMM, |
| 604 | USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), |
Dan Williams | f8295ec | 2012-10-24 12:10:34 +0000 | [diff] [blame] | 605 | .driver_info = 0, |
| 606 | }, |
| 607 | |
Dan Williams | 0370acd | 2012-12-17 08:17:41 +0000 | [diff] [blame] | 608 | /* Dell Wireless 5800 (Novatel E362) - handled by qmi_wwan */ |
| 609 | { |
| 610 | USB_DEVICE_AND_INTERFACE_INFO(DELL_VENDOR_ID, 0x8195, USB_CLASS_COMM, |
| 611 | USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), |
| 612 | .driver_info = 0, |
| 613 | }, |
| 614 | |
| 615 | /* Dell Wireless 5800 (Novatel E362) - handled by qmi_wwan */ |
| 616 | { |
| 617 | USB_DEVICE_AND_INTERFACE_INFO(DELL_VENDOR_ID, 0x8196, USB_CLASS_COMM, |
| 618 | USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), |
| 619 | .driver_info = 0, |
| 620 | }, |
| 621 | |
Dan Williams | 7fdb784 | 2013-05-06 11:17:37 +0000 | [diff] [blame] | 622 | /* Dell Wireless 5804 (Novatel E371) - handled by qmi_wwan */ |
| 623 | { |
| 624 | USB_DEVICE_AND_INTERFACE_INFO(DELL_VENDOR_ID, 0x819b, USB_CLASS_COMM, |
| 625 | USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), |
| 626 | .driver_info = 0, |
| 627 | }, |
| 628 | |
Dan Williams | 45d213f | 2013-02-18 17:25:09 +0000 | [diff] [blame] | 629 | /* AnyDATA ADU960S - handled by qmi_wwan */ |
| 630 | { |
| 631 | USB_DEVICE_AND_INTERFACE_INFO(0x16d5, 0x650a, USB_CLASS_COMM, |
| 632 | USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), |
| 633 | .driver_info = 0, |
| 634 | }, |
| 635 | |
Bjørn Mork | c2020be | 2013-06-06 12:57:02 +0200 | [diff] [blame] | 636 | /* Huawei E1820 - handled by qmi_wwan */ |
| 637 | { |
| 638 | USB_DEVICE_INTERFACE_NUMBER(HUAWEI_VENDOR_ID, 0x14ac, 1), |
| 639 | .driver_info = 0, |
| 640 | }, |
| 641 | |
hayeswang | ac718b6 | 2013-05-02 16:01:25 +0000 | [diff] [blame] | 642 | /* Realtek RTL8152 Based USB 2.0 Ethernet Adapters */ |
hayeswang | ac718b6 | 2013-05-02 16:01:25 +0000 | [diff] [blame] | 643 | { |
| 644 | USB_DEVICE_AND_INTERFACE_INFO(REALTEK_VENDOR_ID, 0x8152, USB_CLASS_COMM, |
| 645 | USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), |
| 646 | .driver_info = 0, |
| 647 | }, |
hayeswang | c073f66 | 2013-07-08 10:41:21 +0800 | [diff] [blame] | 648 | |
| 649 | /* Realtek RTL8153 Based USB 3.0 Ethernet Adapters */ |
| 650 | { |
| 651 | USB_DEVICE_AND_INTERFACE_INFO(REALTEK_VENDOR_ID, 0x8153, USB_CLASS_COMM, |
| 652 | USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), |
| 653 | .driver_info = 0, |
| 654 | }, |
hayeswang | ac718b6 | 2013-05-02 16:01:25 +0000 | [diff] [blame] | 655 | |
Fabio Porcedda | 8857ec2 | 2013-09-16 11:47:51 +0200 | [diff] [blame^] | 656 | /* WHITELIST!!! |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 657 | * |
| 658 | * CDC Ether uses two interfaces, not necessarily consecutive. |
| 659 | * We match the main interface, ignoring the optional device |
| 660 | * class so we could handle devices that aren't exclusively |
| 661 | * CDC ether. |
| 662 | * |
| 663 | * NOTE: this match must come AFTER entries blacklisting devices |
| 664 | * because of bugs/quirks in a given product (like Zaurus, above). |
| 665 | */ |
| 666 | { |
Andrew Bird (Sphere Systems) | 68d8318 | 2012-05-19 03:56:07 +0000 | [diff] [blame] | 667 | /* ZTE (Vodafone) K3805-Z */ |
| 668 | .match_flags = USB_DEVICE_ID_MATCH_VENDOR |
| 669 | | USB_DEVICE_ID_MATCH_PRODUCT |
| 670 | | USB_DEVICE_ID_MATCH_INT_INFO, |
| 671 | .idVendor = ZTE_VENDOR_ID, |
| 672 | .idProduct = 0x1003, |
| 673 | .bInterfaceClass = USB_CLASS_COMM, |
| 674 | .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, |
| 675 | .bInterfaceProtocol = USB_CDC_PROTO_NONE, |
| 676 | .driver_info = (unsigned long)&wwan_info, |
| 677 | }, { |
| 678 | /* ZTE (Vodafone) K3806-Z */ |
| 679 | .match_flags = USB_DEVICE_ID_MATCH_VENDOR |
| 680 | | USB_DEVICE_ID_MATCH_PRODUCT |
| 681 | | USB_DEVICE_ID_MATCH_INT_INFO, |
| 682 | .idVendor = ZTE_VENDOR_ID, |
| 683 | .idProduct = 0x1015, |
| 684 | .bInterfaceClass = USB_CLASS_COMM, |
| 685 | .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, |
| 686 | .bInterfaceProtocol = USB_CDC_PROTO_NONE, |
| 687 | .driver_info = (unsigned long)&wwan_info, |
| 688 | }, { |
| 689 | /* ZTE (Vodafone) K4510-Z */ |
| 690 | .match_flags = USB_DEVICE_ID_MATCH_VENDOR |
| 691 | | USB_DEVICE_ID_MATCH_PRODUCT |
| 692 | | USB_DEVICE_ID_MATCH_INT_INFO, |
| 693 | .idVendor = ZTE_VENDOR_ID, |
| 694 | .idProduct = 0x1173, |
| 695 | .bInterfaceClass = USB_CLASS_COMM, |
| 696 | .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, |
| 697 | .bInterfaceProtocol = USB_CDC_PROTO_NONE, |
| 698 | .driver_info = (unsigned long)&wwan_info, |
| 699 | }, { |
| 700 | /* ZTE (Vodafone) K3770-Z */ |
| 701 | .match_flags = USB_DEVICE_ID_MATCH_VENDOR |
| 702 | | USB_DEVICE_ID_MATCH_PRODUCT |
| 703 | | USB_DEVICE_ID_MATCH_INT_INFO, |
| 704 | .idVendor = ZTE_VENDOR_ID, |
| 705 | .idProduct = 0x1177, |
| 706 | .bInterfaceClass = USB_CLASS_COMM, |
| 707 | .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, |
| 708 | .bInterfaceProtocol = USB_CDC_PROTO_NONE, |
| 709 | .driver_info = (unsigned long)&wwan_info, |
| 710 | }, { |
| 711 | /* ZTE (Vodafone) K3772-Z */ |
| 712 | .match_flags = USB_DEVICE_ID_MATCH_VENDOR |
| 713 | | USB_DEVICE_ID_MATCH_PRODUCT |
| 714 | | USB_DEVICE_ID_MATCH_INT_INFO, |
| 715 | .idVendor = ZTE_VENDOR_ID, |
| 716 | .idProduct = 0x1181, |
| 717 | .bInterfaceClass = USB_CLASS_COMM, |
| 718 | .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, |
| 719 | .bInterfaceProtocol = USB_CDC_PROTO_NONE, |
| 720 | .driver_info = (unsigned long)&wwan_info, |
| 721 | }, { |
Fabio Porcedda | 0092820 | 2013-09-16 11:47:50 +0200 | [diff] [blame] | 722 | /* Telit modules */ |
| 723 | USB_VENDOR_AND_INTERFACE_INFO(0x1bc7, USB_CLASS_COMM, |
| 724 | USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), |
| 725 | .driver_info = (kernel_ulong_t) &wwan_info, |
| 726 | }, { |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 727 | USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ETHERNET, |
| 728 | USB_CDC_PROTO_NONE), |
| 729 | .driver_info = (unsigned long) &cdc_info, |
Bjørn Mork | cac477e | 2009-02-25 04:33:58 +0000 | [diff] [blame] | 730 | }, { |
Jonas Sjöquist | 2185126 | 2010-04-23 01:07:45 +0000 | [diff] [blame] | 731 | USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_MDLM, |
| 732 | USB_CDC_PROTO_NONE), |
Dan Williams | b3c914a | 2011-04-27 09:54:28 +0000 | [diff] [blame] | 733 | .driver_info = (unsigned long)&wwan_info, |
Jonas Sjöquist | 2185126 | 2010-04-23 01:07:45 +0000 | [diff] [blame] | 734 | |
Dan Williams | b3c914a | 2011-04-27 09:54:28 +0000 | [diff] [blame] | 735 | }, { |
| 736 | /* Various Huawei modems with a network port like the UMG1831 */ |
| 737 | .match_flags = USB_DEVICE_ID_MATCH_VENDOR |
| 738 | | USB_DEVICE_ID_MATCH_INT_INFO, |
| 739 | .idVendor = HUAWEI_VENDOR_ID, |
| 740 | .bInterfaceClass = USB_CLASS_COMM, |
| 741 | .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, |
| 742 | .bInterfaceProtocol = 255, |
| 743 | .driver_info = (unsigned long)&wwan_info, |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 744 | }, |
Fabio Porcedda | 8857ec2 | 2013-09-16 11:47:51 +0200 | [diff] [blame^] | 745 | { }, /* END */ |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 746 | }; |
| 747 | MODULE_DEVICE_TABLE(usb, products); |
| 748 | |
| 749 | static struct usb_driver cdc_driver = { |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 750 | .name = "cdc_ether", |
| 751 | .id_table = products, |
| 752 | .probe = usbnet_probe, |
| 753 | .disconnect = usbnet_disconnect, |
| 754 | .suspend = usbnet_suspend, |
| 755 | .resume = usbnet_resume, |
Oliver Neukum | 7f51579 | 2009-12-03 11:41:07 +0000 | [diff] [blame] | 756 | .reset_resume = usbnet_resume, |
Oliver Neukum | 69ee472f | 2009-12-03 15:31:18 -0800 | [diff] [blame] | 757 | .supports_autosuspend = 1, |
Sarah Sharp | e1f12eb | 2012-04-23 10:08:51 -0700 | [diff] [blame] | 758 | .disable_hub_initiated_lpm = 1, |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 759 | }; |
| 760 | |
Greg Kroah-Hartman | d632eb1 | 2011-11-18 09:44:20 -0800 | [diff] [blame] | 761 | module_usb_driver(cdc_driver); |
David Brownell | 4324fd4 | 2005-08-31 09:54:20 -0700 | [diff] [blame] | 762 | |
| 763 | MODULE_AUTHOR("David Brownell"); |
| 764 | MODULE_DESCRIPTION("USB CDC Ethernet devices"); |
| 765 | MODULE_LICENSE("GPL"); |