Linux Audio

Check our new training course

Loading...
v3.15
  1/*
  2 * Copyright (c) 2012  Bjørn Mork <bjorn@mork.no>
  3 *
  4 * The probing code is heavily inspired by cdc_ether, which is:
  5 * Copyright (C) 2003-2005 by David Brownell
  6 * Copyright (C) 2006 by Ole Andre Vadla Ravnas (ActiveSync)
  7 *
  8 * This program is free software; you can redistribute it and/or
  9 * modify it under the terms of the GNU General Public License
 10 * version 2 as published by the Free Software Foundation.
 11 */
 12
 13#include <linux/module.h>
 14#include <linux/netdevice.h>
 15#include <linux/ethtool.h>
 16#include <linux/etherdevice.h>
 
 17#include <linux/mii.h>
 
 18#include <linux/usb.h>
 19#include <linux/usb/cdc.h>
 20#include <linux/usb/usbnet.h>
 21#include <linux/usb/cdc-wdm.h>
 22
 23/* This driver supports wwan (3G/LTE/?) devices using a vendor
 24 * specific management protocol called Qualcomm MSM Interface (QMI) -
 25 * in addition to the more common AT commands over serial interface
 26 * management
 27 *
 28 * QMI is wrapped in CDC, using CDC encapsulated commands on the
 29 * control ("master") interface of a two-interface CDC Union
 30 * resembling standard CDC ECM.  The devices do not use the control
 31 * interface for any other CDC messages.  Most likely because the
 32 * management protocol is used in place of the standard CDC
 33 * notifications NOTIFY_NETWORK_CONNECTION and NOTIFY_SPEED_CHANGE
 34 *
 35 * Alternatively, control and data functions can be combined in a
 36 * single USB interface.
 37 *
 38 * Handling a protocol like QMI is out of the scope for any driver.
 39 * It is exported as a character device using the cdc-wdm driver as
 40 * a subdriver, enabling userspace applications ("modem managers") to
 41 * handle it.
 42 *
 43 * These devices may alternatively/additionally be configured using AT
 44 * commands on a serial interface
 45 */
 46
 47/* driver specific data */
 48struct qmi_wwan_state {
 49	struct usb_driver *subdriver;
 50	atomic_t pmcount;
 51	unsigned long unused;
 52	struct usb_interface *control;
 53	struct usb_interface *data;
 54};
 55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 56/* default ethernet address used by the modem */
 57static const u8 default_modem_addr[ETH_ALEN] = {0x02, 0x50, 0xf3};
 58
 
 
 59/* Make up an ethernet header if the packet doesn't have one.
 60 *
 61 * A firmware bug common among several devices cause them to send raw
 62 * IP packets under some circumstances.  There is no way for the
 63 * driver/host to know when this will happen.  And even when the bug
 64 * hits, some packets will still arrive with an intact header.
 65 *
 66 * The supported devices are only capably of sending IPv4, IPv6 and
 67 * ARP packets on a point-to-point link. Any packet with an ethernet
 68 * header will have either our address or a broadcast/multicast
 69 * address as destination.  ARP packets will always have a header.
 70 *
 71 * This means that this function will reliably add the appropriate
 72 * header iff necessary, provided our hardware address does not start
 73 * with 4 or 6.
 74 *
 75 * Another common firmware bug results in all packets being addressed
 76 * to 00:a0:c6:00:00:00 despite the host address being different.
 77 * This function will also fixup such packets.
 78 */
 79static int qmi_wwan_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
 80{
 
 
 81	__be16 proto;
 82
 83	/* This check is no longer done by usbnet */
 84	if (skb->len < dev->net->hard_header_len)
 85		return 0;
 86
 87	switch (skb->data[0] & 0xf0) {
 88	case 0x40:
 89		proto = htons(ETH_P_IP);
 90		break;
 91	case 0x60:
 92		proto = htons(ETH_P_IPV6);
 93		break;
 94	case 0x00:
 
 
 95		if (is_multicast_ether_addr(skb->data))
 96			return 1;
 97		/* possibly bogus destination - rewrite just in case */
 98		skb_reset_mac_header(skb);
 99		goto fix_dest;
100	default:
 
 
101		/* pass along other packets without modifications */
102		return 1;
103	}
 
 
 
 
 
 
104	if (skb_headroom(skb) < ETH_HLEN)
105		return 0;
106	skb_push(skb, ETH_HLEN);
107	skb_reset_mac_header(skb);
108	eth_hdr(skb)->h_proto = proto;
109	memset(eth_hdr(skb)->h_source, 0, ETH_ALEN);
110fix_dest:
111	memcpy(eth_hdr(skb)->h_dest, dev->net->dev_addr, ETH_ALEN);
112	return 1;
113}
114
115/* very simplistic detection of IPv4 or IPv6 headers */
116static bool possibly_iphdr(const char *data)
117{
118	return (data[0] & 0xd0) == 0x40;
119}
120
121/* disallow addresses which may be confused with IP headers */
122static int qmi_wwan_mac_addr(struct net_device *dev, void *p)
123{
124	int ret;
125	struct sockaddr *addr = p;
126
127	ret = eth_prepare_mac_addr_change(dev, p);
128	if (ret < 0)
129		return ret;
130	if (possibly_iphdr(addr->sa_data))
131		return -EADDRNOTAVAIL;
132	eth_commit_mac_addr_change(dev, p);
133	return 0;
134}
135
136static const struct net_device_ops qmi_wwan_netdev_ops = {
137	.ndo_open		= usbnet_open,
138	.ndo_stop		= usbnet_stop,
139	.ndo_start_xmit		= usbnet_start_xmit,
140	.ndo_tx_timeout		= usbnet_tx_timeout,
141	.ndo_change_mtu		= usbnet_change_mtu,
142	.ndo_set_mac_address	= qmi_wwan_mac_addr,
143	.ndo_validate_addr	= eth_validate_addr,
144};
145
146/* using a counter to merge subdriver requests with our own into a
147 * combined state
148 */
149static int qmi_wwan_manage_power(struct usbnet *dev, int on)
150{
151	struct qmi_wwan_state *info = (void *)&dev->data;
152	int rv;
153
154	dev_dbg(&dev->intf->dev, "%s() pmcount=%d, on=%d\n", __func__,
155		atomic_read(&info->pmcount), on);
156
157	if ((on && atomic_add_return(1, &info->pmcount) == 1) ||
158	    (!on && atomic_dec_and_test(&info->pmcount))) {
159		/* need autopm_get/put here to ensure the usbcore sees
160		 * the new value
161		 */
162		rv = usb_autopm_get_interface(dev->intf);
163		dev->intf->needs_remote_wakeup = on;
164		if (!rv)
165			usb_autopm_put_interface(dev->intf);
166	}
167	return 0;
168}
169
170static int qmi_wwan_cdc_wdm_manage_power(struct usb_interface *intf, int on)
171{
172	struct usbnet *dev = usb_get_intfdata(intf);
173
174	/* can be called while disconnecting */
175	if (!dev)
176		return 0;
177	return qmi_wwan_manage_power(dev, on);
178}
179
180/* collect all three endpoints and register subdriver */
181static int qmi_wwan_register_subdriver(struct usbnet *dev)
182{
183	int rv;
184	struct usb_driver *subdriver = NULL;
185	struct qmi_wwan_state *info = (void *)&dev->data;
186
187	/* collect bulk endpoints */
188	rv = usbnet_get_endpoints(dev, info->data);
189	if (rv < 0)
190		goto err;
191
192	/* update status endpoint if separate control interface */
193	if (info->control != info->data)
194		dev->status = &info->control->cur_altsetting->endpoint[0];
195
196	/* require interrupt endpoint for subdriver */
197	if (!dev->status) {
198		rv = -EINVAL;
199		goto err;
200	}
201
202	/* for subdriver power management */
203	atomic_set(&info->pmcount, 0);
204
205	/* register subdriver */
206	subdriver = usb_cdc_wdm_register(info->control, &dev->status->desc,
207					 4096, &qmi_wwan_cdc_wdm_manage_power);
208	if (IS_ERR(subdriver)) {
209		dev_err(&info->control->dev, "subdriver registration failed\n");
210		rv = PTR_ERR(subdriver);
211		goto err;
212	}
213
214	/* prevent usbnet from using status endpoint */
215	dev->status = NULL;
216
217	/* save subdriver struct for suspend/resume wrappers */
218	info->subdriver = subdriver;
219
220err:
221	return rv;
222}
223
 
 
 
 
 
 
 
 
 
 
 
 
 
 
224static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf)
225{
226	int status = -1;
227	u8 *buf = intf->cur_altsetting->extra;
228	int len = intf->cur_altsetting->extralen;
229	struct usb_interface_descriptor *desc = &intf->cur_altsetting->desc;
230	struct usb_cdc_union_desc *cdc_union = NULL;
231	struct usb_cdc_ether_desc *cdc_ether = NULL;
232	u32 found = 0;
233	struct usb_driver *driver = driver_of(intf);
234	struct qmi_wwan_state *info = (void *)&dev->data;
 
235
236	BUILD_BUG_ON((sizeof(((struct usbnet *)0)->data) <
237		      sizeof(struct qmi_wwan_state)));
238
239	/* set up initial state */
240	info->control = intf;
241	info->data = intf;
242
243	/* and a number of CDC descriptors */
244	while (len > 3) {
245		struct usb_descriptor_header *h = (void *)buf;
246
247		/* ignore any misplaced descriptors */
248		if (h->bDescriptorType != USB_DT_CS_INTERFACE)
249			goto next_desc;
250
251		/* buf[2] is CDC descriptor subtype */
252		switch (buf[2]) {
253		case USB_CDC_HEADER_TYPE:
254			if (found & 1 << USB_CDC_HEADER_TYPE) {
255				dev_dbg(&intf->dev, "extra CDC header\n");
256				goto err;
257			}
258			if (h->bLength != sizeof(struct usb_cdc_header_desc)) {
259				dev_dbg(&intf->dev, "CDC header len %u\n",
260					h->bLength);
261				goto err;
262			}
263			break;
264		case USB_CDC_UNION_TYPE:
265			if (found & 1 << USB_CDC_UNION_TYPE) {
266				dev_dbg(&intf->dev, "extra CDC union\n");
267				goto err;
268			}
269			if (h->bLength != sizeof(struct usb_cdc_union_desc)) {
270				dev_dbg(&intf->dev, "CDC union len %u\n",
271					h->bLength);
272				goto err;
273			}
274			cdc_union = (struct usb_cdc_union_desc *)buf;
275			break;
276		case USB_CDC_ETHERNET_TYPE:
277			if (found & 1 << USB_CDC_ETHERNET_TYPE) {
278				dev_dbg(&intf->dev, "extra CDC ether\n");
279				goto err;
280			}
281			if (h->bLength != sizeof(struct usb_cdc_ether_desc)) {
282				dev_dbg(&intf->dev, "CDC ether len %u\n",
283					h->bLength);
284				goto err;
285			}
286			cdc_ether = (struct usb_cdc_ether_desc *)buf;
287			break;
288		}
289
290		/* Remember which CDC functional descriptors we've seen.  Works
291		 * for all types we care about, of which USB_CDC_ETHERNET_TYPE
292		 * (0x0f) is the highest numbered
293		 */
294		if (buf[2] < 32)
295			found |= 1 << buf[2];
296
297next_desc:
298		len -= h->bLength;
299		buf += h->bLength;
300	}
301
302	/* Use separate control and data interfaces if we found a CDC Union */
303	if (cdc_union) {
304		info->data = usb_ifnum_to_if(dev->udev,
305					     cdc_union->bSlaveInterface0);
306		if (desc->bInterfaceNumber != cdc_union->bMasterInterface0 ||
307		    !info->data) {
308			dev_err(&intf->dev,
309				"bogus CDC Union: master=%u, slave=%u\n",
310				cdc_union->bMasterInterface0,
311				cdc_union->bSlaveInterface0);
312			goto err;
 
 
 
313		}
314	}
315
316	/* errors aren't fatal - we can live with the dynamic address */
317	if (cdc_ether) {
318		dev->hard_mtu = le16_to_cpu(cdc_ether->wMaxSegmentSize);
319		usbnet_get_ethernet_addr(dev, cdc_ether->iMACAddress);
320	}
321
322	/* claim data interface and set it up */
323	if (info->control != info->data) {
324		status = usb_driver_claim_interface(driver, info->data, dev);
325		if (status < 0)
326			goto err;
327	}
328
329	status = qmi_wwan_register_subdriver(dev);
330	if (status < 0 && info->control != info->data) {
331		usb_set_intfdata(info->data, NULL);
332		usb_driver_release_interface(driver, info->data);
333	}
334
335	/* Never use the same address on both ends of the link, even
336	 * if the buggy firmware told us to.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
337	 */
338	if (ether_addr_equal(dev->net->dev_addr, default_modem_addr))
 
339		eth_hw_addr_random(dev->net);
340
341	/* make MAC addr easily distinguishable from an IP header */
342	if (possibly_iphdr(dev->net->dev_addr)) {
343		dev->net->dev_addr[0] |= 0x02;	/* set local assignment bit */
344		dev->net->dev_addr[0] &= 0xbf;	/* clear "IP" bit */
345	}
346	dev->net->netdev_ops = &qmi_wwan_netdev_ops;
 
347err:
348	return status;
349}
350
351static void qmi_wwan_unbind(struct usbnet *dev, struct usb_interface *intf)
352{
353	struct qmi_wwan_state *info = (void *)&dev->data;
354	struct usb_driver *driver = driver_of(intf);
355	struct usb_interface *other;
356
357	if (info->subdriver && info->subdriver->disconnect)
358		info->subdriver->disconnect(info->control);
359
 
 
 
 
 
 
360	/* allow user to unbind using either control or data */
361	if (intf == info->control)
362		other = info->data;
363	else
364		other = info->control;
365
366	/* only if not shared */
367	if (other && intf != other) {
368		usb_set_intfdata(other, NULL);
369		usb_driver_release_interface(driver, other);
370	}
371
372	info->subdriver = NULL;
373	info->data = NULL;
374	info->control = NULL;
375}
376
377/* suspend/resume wrappers calling both usbnet and the cdc-wdm
378 * subdriver if present.
379 *
380 * NOTE: cdc-wdm also supports pre/post_reset, but we cannot provide
381 * wrappers for those without adding usbnet reset support first.
382 */
383static int qmi_wwan_suspend(struct usb_interface *intf, pm_message_t message)
384{
385	struct usbnet *dev = usb_get_intfdata(intf);
386	struct qmi_wwan_state *info = (void *)&dev->data;
387	int ret;
388
389	/* Both usbnet_suspend() and subdriver->suspend() MUST return 0
390	 * in system sleep context, otherwise, the resume callback has
391	 * to recover device from previous suspend failure.
392	 */
393	ret = usbnet_suspend(intf, message);
394	if (ret < 0)
395		goto err;
396
397	if (intf == info->control && info->subdriver &&
398	    info->subdriver->suspend)
399		ret = info->subdriver->suspend(intf, message);
400	if (ret < 0)
401		usbnet_resume(intf);
402err:
403	return ret;
404}
405
406static int qmi_wwan_resume(struct usb_interface *intf)
407{
408	struct usbnet *dev = usb_get_intfdata(intf);
409	struct qmi_wwan_state *info = (void *)&dev->data;
410	int ret = 0;
411	bool callsub = (intf == info->control && info->subdriver &&
412			info->subdriver->resume);
413
414	if (callsub)
415		ret = info->subdriver->resume(intf);
416	if (ret < 0)
417		goto err;
418	ret = usbnet_resume(intf);
419	if (ret < 0 && callsub)
420		info->subdriver->suspend(intf, PMSG_SUSPEND);
421err:
422	return ret;
423}
424
425static const struct driver_info	qmi_wwan_info = {
426	.description	= "WWAN/QMI device",
427	.flags		= FLAG_WWAN,
428	.bind		= qmi_wwan_bind,
429	.unbind		= qmi_wwan_unbind,
430	.manage_power	= qmi_wwan_manage_power,
431	.rx_fixup       = qmi_wwan_rx_fixup,
432};
433
 
 
 
 
 
 
 
 
 
 
434#define HUAWEI_VENDOR_ID	0x12D1
435
436/* map QMI/wwan function by a fixed interface number */
437#define QMI_FIXED_INTF(vend, prod, num) \
438	USB_DEVICE_INTERFACE_NUMBER(vend, prod, num), \
439	.driver_info = (unsigned long)&qmi_wwan_info
440
 
 
 
 
 
441/* Gobi 1000 QMI/wwan interface number is 3 according to qcserial */
442#define QMI_GOBI1K_DEVICE(vend, prod) \
443	QMI_FIXED_INTF(vend, prod, 3)
444
445/* Gobi 2000/3000 QMI/wwan interface number is 0 according to qcserial */
446#define QMI_GOBI_DEVICE(vend, prod) \
447	QMI_FIXED_INTF(vend, prod, 0)
448
449static const struct usb_device_id products[] = {
450	/* 1. CDC ECM like devices match on the control interface */
451	{	/* Huawei E392, E398 and possibly others sharing both device id and more... */
452		USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 1, 9),
453		.driver_info        = (unsigned long)&qmi_wwan_info,
454	},
455	{	/* Vodafone/Huawei K5005 (12d1:14c8) and similar modems */
456		USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 1, 57),
457		.driver_info        = (unsigned long)&qmi_wwan_info,
458	},
459	{	/* HUAWEI_INTERFACE_NDIS_CONTROL_QUALCOMM */
460		USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 0x01, 0x69),
461		.driver_info        = (unsigned long)&qmi_wwan_info,
462	},
463
464	/* 2. Combined interface devices matching on class+protocol */
465	{	/* Huawei E367 and possibly others in "Windows mode" */
466		USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 1, 7),
467		.driver_info        = (unsigned long)&qmi_wwan_info,
468	},
469	{	/* Huawei E392, E398 and possibly others in "Windows mode" */
470		USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 1, 17),
471		.driver_info        = (unsigned long)&qmi_wwan_info,
472	},
473	{	/* HUAWEI_NDIS_SINGLE_INTERFACE_VDF */
474		USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 0x01, 0x37),
475		.driver_info        = (unsigned long)&qmi_wwan_info,
476	},
477	{	/* HUAWEI_INTERFACE_NDIS_HW_QUALCOMM */
478		USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 0x01, 0x67),
479		.driver_info        = (unsigned long)&qmi_wwan_info,
480	},
481	{	/* Pantech UML290, P4200 and more */
482		USB_VENDOR_AND_INTERFACE_INFO(0x106c, USB_CLASS_VENDOR_SPEC, 0xf0, 0xff),
483		.driver_info        = (unsigned long)&qmi_wwan_info,
484	},
485	{	/* Pantech UML290 - newer firmware */
486		USB_VENDOR_AND_INTERFACE_INFO(0x106c, USB_CLASS_VENDOR_SPEC, 0xf1, 0xff),
487		.driver_info        = (unsigned long)&qmi_wwan_info,
488	},
489	{	/* Novatel USB551L and MC551 */
490		USB_DEVICE_AND_INTERFACE_INFO(0x1410, 0xb001,
491		                              USB_CLASS_COMM,
492		                              USB_CDC_SUBCLASS_ETHERNET,
493		                              USB_CDC_PROTO_NONE),
494		.driver_info        = (unsigned long)&qmi_wwan_info,
495	},
496	{	/* Novatel E362 */
497		USB_DEVICE_AND_INTERFACE_INFO(0x1410, 0x9010,
498		                              USB_CLASS_COMM,
499		                              USB_CDC_SUBCLASS_ETHERNET,
500		                              USB_CDC_PROTO_NONE),
501		.driver_info        = (unsigned long)&qmi_wwan_info,
502	},
503	{	/* Novatel Expedite E371 */
504		USB_DEVICE_AND_INTERFACE_INFO(0x1410, 0x9011,
505		                              USB_CLASS_COMM,
506		                              USB_CDC_SUBCLASS_ETHERNET,
507		                              USB_CDC_PROTO_NONE),
508		.driver_info        = (unsigned long)&qmi_wwan_info,
509	},
510	{	/* Dell Wireless 5800 (Novatel E362) */
511		USB_DEVICE_AND_INTERFACE_INFO(0x413C, 0x8195,
512					      USB_CLASS_COMM,
513					      USB_CDC_SUBCLASS_ETHERNET,
514					      USB_CDC_PROTO_NONE),
515		.driver_info        = (unsigned long)&qmi_wwan_info,
516	},
517	{	/* Dell Wireless 5800 V2 (Novatel E362) */
518		USB_DEVICE_AND_INTERFACE_INFO(0x413C, 0x8196,
519					      USB_CLASS_COMM,
520					      USB_CDC_SUBCLASS_ETHERNET,
521					      USB_CDC_PROTO_NONE),
522		.driver_info        = (unsigned long)&qmi_wwan_info,
523	},
524	{	/* Dell Wireless 5804 (Novatel E371) */
525		USB_DEVICE_AND_INTERFACE_INFO(0x413C, 0x819b,
526					      USB_CLASS_COMM,
527					      USB_CDC_SUBCLASS_ETHERNET,
528					      USB_CDC_PROTO_NONE),
529		.driver_info        = (unsigned long)&qmi_wwan_info,
530	},
531	{	/* ADU960S */
532		USB_DEVICE_AND_INTERFACE_INFO(0x16d5, 0x650a,
533					      USB_CLASS_COMM,
534					      USB_CDC_SUBCLASS_ETHERNET,
535					      USB_CDC_PROTO_NONE),
536		.driver_info        = (unsigned long)&qmi_wwan_info,
537	},
 
 
 
 
 
 
 
 
 
 
 
538
539	/* 3. Combined interface devices matching on interface number */
540	{QMI_FIXED_INTF(0x0408, 0xea42, 4)},	/* Yota / Megafon M100-1 */
 
541	{QMI_FIXED_INTF(0x05c6, 0x7000, 0)},
542	{QMI_FIXED_INTF(0x05c6, 0x7001, 1)},
543	{QMI_FIXED_INTF(0x05c6, 0x7002, 1)},
544	{QMI_FIXED_INTF(0x05c6, 0x7101, 1)},
545	{QMI_FIXED_INTF(0x05c6, 0x7101, 2)},
546	{QMI_FIXED_INTF(0x05c6, 0x7101, 3)},
547	{QMI_FIXED_INTF(0x05c6, 0x7102, 1)},
548	{QMI_FIXED_INTF(0x05c6, 0x7102, 2)},
549	{QMI_FIXED_INTF(0x05c6, 0x7102, 3)},
550	{QMI_FIXED_INTF(0x05c6, 0x8000, 7)},
551	{QMI_FIXED_INTF(0x05c6, 0x8001, 6)},
552	{QMI_FIXED_INTF(0x05c6, 0x9000, 4)},
553	{QMI_FIXED_INTF(0x05c6, 0x9003, 4)},
554	{QMI_FIXED_INTF(0x05c6, 0x9005, 2)},
555	{QMI_FIXED_INTF(0x05c6, 0x900a, 4)},
556	{QMI_FIXED_INTF(0x05c6, 0x900b, 2)},
557	{QMI_FIXED_INTF(0x05c6, 0x900c, 4)},
558	{QMI_FIXED_INTF(0x05c6, 0x900c, 5)},
559	{QMI_FIXED_INTF(0x05c6, 0x900c, 6)},
560	{QMI_FIXED_INTF(0x05c6, 0x900d, 5)},
561	{QMI_FIXED_INTF(0x05c6, 0x900f, 3)},
562	{QMI_FIXED_INTF(0x05c6, 0x900f, 4)},
563	{QMI_FIXED_INTF(0x05c6, 0x900f, 5)},
564	{QMI_FIXED_INTF(0x05c6, 0x9010, 4)},
565	{QMI_FIXED_INTF(0x05c6, 0x9010, 5)},
566	{QMI_FIXED_INTF(0x05c6, 0x9011, 3)},
567	{QMI_FIXED_INTF(0x05c6, 0x9011, 4)},
568	{QMI_FIXED_INTF(0x05c6, 0x9021, 1)},
569	{QMI_FIXED_INTF(0x05c6, 0x9022, 2)},
570	{QMI_FIXED_INTF(0x05c6, 0x9025, 4)},	/* Alcatel-sbell ASB TL131 TDD LTE  (China Mobile) */
571	{QMI_FIXED_INTF(0x05c6, 0x9026, 3)},
572	{QMI_FIXED_INTF(0x05c6, 0x902e, 5)},
573	{QMI_FIXED_INTF(0x05c6, 0x9031, 5)},
574	{QMI_FIXED_INTF(0x05c6, 0x9032, 4)},
575	{QMI_FIXED_INTF(0x05c6, 0x9033, 3)},
576	{QMI_FIXED_INTF(0x05c6, 0x9033, 4)},
577	{QMI_FIXED_INTF(0x05c6, 0x9033, 5)},
578	{QMI_FIXED_INTF(0x05c6, 0x9033, 6)},
579	{QMI_FIXED_INTF(0x05c6, 0x9034, 3)},
580	{QMI_FIXED_INTF(0x05c6, 0x9034, 4)},
581	{QMI_FIXED_INTF(0x05c6, 0x9034, 5)},
582	{QMI_FIXED_INTF(0x05c6, 0x9034, 6)},
583	{QMI_FIXED_INTF(0x05c6, 0x9034, 7)},
584	{QMI_FIXED_INTF(0x05c6, 0x9035, 4)},
585	{QMI_FIXED_INTF(0x05c6, 0x9036, 3)},
586	{QMI_FIXED_INTF(0x05c6, 0x9037, 5)},
587	{QMI_FIXED_INTF(0x05c6, 0x9038, 4)},
588	{QMI_FIXED_INTF(0x05c6, 0x903b, 7)},
589	{QMI_FIXED_INTF(0x05c6, 0x903c, 6)},
590	{QMI_FIXED_INTF(0x05c6, 0x903d, 6)},
591	{QMI_FIXED_INTF(0x05c6, 0x903e, 5)},
592	{QMI_FIXED_INTF(0x05c6, 0x9043, 3)},
593	{QMI_FIXED_INTF(0x05c6, 0x9046, 3)},
594	{QMI_FIXED_INTF(0x05c6, 0x9046, 4)},
595	{QMI_FIXED_INTF(0x05c6, 0x9046, 5)},
596	{QMI_FIXED_INTF(0x05c6, 0x9047, 2)},
597	{QMI_FIXED_INTF(0x05c6, 0x9047, 3)},
598	{QMI_FIXED_INTF(0x05c6, 0x9047, 4)},
599	{QMI_FIXED_INTF(0x05c6, 0x9048, 4)},
600	{QMI_FIXED_INTF(0x05c6, 0x9048, 5)},
601	{QMI_FIXED_INTF(0x05c6, 0x9048, 6)},
602	{QMI_FIXED_INTF(0x05c6, 0x9048, 7)},
603	{QMI_FIXED_INTF(0x05c6, 0x9048, 8)},
604	{QMI_FIXED_INTF(0x05c6, 0x904c, 5)},
605	{QMI_FIXED_INTF(0x05c6, 0x904c, 6)},
606	{QMI_FIXED_INTF(0x05c6, 0x904c, 7)},
607	{QMI_FIXED_INTF(0x05c6, 0x904c, 8)},
608	{QMI_FIXED_INTF(0x05c6, 0x9050, 3)},
609	{QMI_FIXED_INTF(0x05c6, 0x9052, 4)},
610	{QMI_FIXED_INTF(0x05c6, 0x9053, 6)},
611	{QMI_FIXED_INTF(0x05c6, 0x9053, 7)},
612	{QMI_FIXED_INTF(0x05c6, 0x9054, 5)},
613	{QMI_FIXED_INTF(0x05c6, 0x9054, 6)},
614	{QMI_FIXED_INTF(0x05c6, 0x9055, 3)},
615	{QMI_FIXED_INTF(0x05c6, 0x9055, 4)},
616	{QMI_FIXED_INTF(0x05c6, 0x9055, 5)},
617	{QMI_FIXED_INTF(0x05c6, 0x9055, 6)},
618	{QMI_FIXED_INTF(0x05c6, 0x9055, 7)},
619	{QMI_FIXED_INTF(0x05c6, 0x9056, 3)},
620	{QMI_FIXED_INTF(0x05c6, 0x9062, 2)},
621	{QMI_FIXED_INTF(0x05c6, 0x9062, 3)},
622	{QMI_FIXED_INTF(0x05c6, 0x9062, 4)},
623	{QMI_FIXED_INTF(0x05c6, 0x9062, 5)},
624	{QMI_FIXED_INTF(0x05c6, 0x9062, 6)},
625	{QMI_FIXED_INTF(0x05c6, 0x9062, 7)},
626	{QMI_FIXED_INTF(0x05c6, 0x9062, 8)},
627	{QMI_FIXED_INTF(0x05c6, 0x9062, 9)},
628	{QMI_FIXED_INTF(0x05c6, 0x9064, 3)},
629	{QMI_FIXED_INTF(0x05c6, 0x9065, 6)},
630	{QMI_FIXED_INTF(0x05c6, 0x9065, 7)},
631	{QMI_FIXED_INTF(0x05c6, 0x9066, 5)},
632	{QMI_FIXED_INTF(0x05c6, 0x9066, 6)},
633	{QMI_FIXED_INTF(0x05c6, 0x9067, 1)},
634	{QMI_FIXED_INTF(0x05c6, 0x9068, 2)},
635	{QMI_FIXED_INTF(0x05c6, 0x9068, 3)},
636	{QMI_FIXED_INTF(0x05c6, 0x9068, 4)},
637	{QMI_FIXED_INTF(0x05c6, 0x9068, 5)},
638	{QMI_FIXED_INTF(0x05c6, 0x9068, 6)},
639	{QMI_FIXED_INTF(0x05c6, 0x9068, 7)},
640	{QMI_FIXED_INTF(0x05c6, 0x9069, 5)},
641	{QMI_FIXED_INTF(0x05c6, 0x9069, 6)},
642	{QMI_FIXED_INTF(0x05c6, 0x9069, 7)},
643	{QMI_FIXED_INTF(0x05c6, 0x9069, 8)},
644	{QMI_FIXED_INTF(0x05c6, 0x9070, 4)},
645	{QMI_FIXED_INTF(0x05c6, 0x9070, 5)},
646	{QMI_FIXED_INTF(0x05c6, 0x9075, 5)},
647	{QMI_FIXED_INTF(0x05c6, 0x9076, 4)},
648	{QMI_FIXED_INTF(0x05c6, 0x9076, 5)},
649	{QMI_FIXED_INTF(0x05c6, 0x9076, 6)},
650	{QMI_FIXED_INTF(0x05c6, 0x9076, 7)},
651	{QMI_FIXED_INTF(0x05c6, 0x9076, 8)},
652	{QMI_FIXED_INTF(0x05c6, 0x9077, 3)},
653	{QMI_FIXED_INTF(0x05c6, 0x9077, 4)},
654	{QMI_FIXED_INTF(0x05c6, 0x9077, 5)},
655	{QMI_FIXED_INTF(0x05c6, 0x9077, 6)},
656	{QMI_FIXED_INTF(0x05c6, 0x9078, 3)},
657	{QMI_FIXED_INTF(0x05c6, 0x9079, 4)},
658	{QMI_FIXED_INTF(0x05c6, 0x9079, 5)},
659	{QMI_FIXED_INTF(0x05c6, 0x9079, 6)},
660	{QMI_FIXED_INTF(0x05c6, 0x9079, 7)},
661	{QMI_FIXED_INTF(0x05c6, 0x9079, 8)},
662	{QMI_FIXED_INTF(0x05c6, 0x9080, 5)},
663	{QMI_FIXED_INTF(0x05c6, 0x9080, 6)},
664	{QMI_FIXED_INTF(0x05c6, 0x9080, 7)},
665	{QMI_FIXED_INTF(0x05c6, 0x9080, 8)},
666	{QMI_FIXED_INTF(0x05c6, 0x9083, 3)},
667	{QMI_FIXED_INTF(0x05c6, 0x9084, 4)},
668	{QMI_FIXED_INTF(0x05c6, 0x920d, 0)},
669	{QMI_FIXED_INTF(0x05c6, 0x920d, 5)},
 
670	{QMI_FIXED_INTF(0x12d1, 0x140c, 1)},	/* Huawei E173 */
671	{QMI_FIXED_INTF(0x12d1, 0x14ac, 1)},	/* Huawei E1820 */
672	{QMI_FIXED_INTF(0x16d8, 0x6003, 0)},	/* CMOTech 6003 */
673	{QMI_FIXED_INTF(0x16d8, 0x6007, 0)},	/* CMOTech CHE-628S */
674	{QMI_FIXED_INTF(0x16d8, 0x6008, 0)},	/* CMOTech CMU-301 */
675	{QMI_FIXED_INTF(0x16d8, 0x6280, 0)},	/* CMOTech CHU-628 */
676	{QMI_FIXED_INTF(0x16d8, 0x7001, 0)},	/* CMOTech CHU-720S */
677	{QMI_FIXED_INTF(0x16d8, 0x7002, 0)},	/* CMOTech 7002 */
678	{QMI_FIXED_INTF(0x16d8, 0x7003, 4)},	/* CMOTech CHU-629K */
679	{QMI_FIXED_INTF(0x16d8, 0x7004, 3)},	/* CMOTech 7004 */
680	{QMI_FIXED_INTF(0x16d8, 0x7006, 5)},	/* CMOTech CGU-629 */
681	{QMI_FIXED_INTF(0x16d8, 0x700a, 4)},	/* CMOTech CHU-629S */
682	{QMI_FIXED_INTF(0x16d8, 0x7211, 0)},	/* CMOTech CHU-720I */
683	{QMI_FIXED_INTF(0x16d8, 0x7212, 0)},	/* CMOTech 7212 */
684	{QMI_FIXED_INTF(0x16d8, 0x7213, 0)},	/* CMOTech 7213 */
685	{QMI_FIXED_INTF(0x16d8, 0x7251, 1)},	/* CMOTech 7251 */
686	{QMI_FIXED_INTF(0x16d8, 0x7252, 1)},	/* CMOTech 7252 */
687	{QMI_FIXED_INTF(0x16d8, 0x7253, 1)},	/* CMOTech 7253 */
688	{QMI_FIXED_INTF(0x19d2, 0x0002, 1)},
689	{QMI_FIXED_INTF(0x19d2, 0x0012, 1)},
690	{QMI_FIXED_INTF(0x19d2, 0x0017, 3)},
691	{QMI_FIXED_INTF(0x19d2, 0x0019, 3)},	/* ONDA MT689DC */
692	{QMI_FIXED_INTF(0x19d2, 0x0021, 4)},
693	{QMI_FIXED_INTF(0x19d2, 0x0025, 1)},
694	{QMI_FIXED_INTF(0x19d2, 0x0031, 4)},
695	{QMI_FIXED_INTF(0x19d2, 0x0042, 4)},
696	{QMI_FIXED_INTF(0x19d2, 0x0049, 5)},
697	{QMI_FIXED_INTF(0x19d2, 0x0052, 4)},
698	{QMI_FIXED_INTF(0x19d2, 0x0055, 1)},	/* ZTE (Vodafone) K3520-Z */
699	{QMI_FIXED_INTF(0x19d2, 0x0058, 4)},
700	{QMI_FIXED_INTF(0x19d2, 0x0063, 4)},	/* ZTE (Vodafone) K3565-Z */
701	{QMI_FIXED_INTF(0x19d2, 0x0104, 4)},	/* ZTE (Vodafone) K4505-Z */
702	{QMI_FIXED_INTF(0x19d2, 0x0113, 5)},
703	{QMI_FIXED_INTF(0x19d2, 0x0118, 5)},
704	{QMI_FIXED_INTF(0x19d2, 0x0121, 5)},
705	{QMI_FIXED_INTF(0x19d2, 0x0123, 4)},
706	{QMI_FIXED_INTF(0x19d2, 0x0124, 5)},
707	{QMI_FIXED_INTF(0x19d2, 0x0125, 6)},
708	{QMI_FIXED_INTF(0x19d2, 0x0126, 5)},
709	{QMI_FIXED_INTF(0x19d2, 0x0130, 1)},
710	{QMI_FIXED_INTF(0x19d2, 0x0133, 3)},
711	{QMI_FIXED_INTF(0x19d2, 0x0141, 5)},
712	{QMI_FIXED_INTF(0x19d2, 0x0157, 5)},	/* ZTE MF683 */
713	{QMI_FIXED_INTF(0x19d2, 0x0158, 3)},
714	{QMI_FIXED_INTF(0x19d2, 0x0167, 4)},	/* ZTE MF820D */
715	{QMI_FIXED_INTF(0x19d2, 0x0168, 4)},
716	{QMI_FIXED_INTF(0x19d2, 0x0176, 3)},
717	{QMI_FIXED_INTF(0x19d2, 0x0178, 3)},
718	{QMI_FIXED_INTF(0x19d2, 0x0191, 4)},	/* ZTE EuFi890 */
719	{QMI_FIXED_INTF(0x19d2, 0x0199, 1)},	/* ZTE MF820S */
720	{QMI_FIXED_INTF(0x19d2, 0x0200, 1)},
721	{QMI_FIXED_INTF(0x19d2, 0x0257, 3)},	/* ZTE MF821 */
722	{QMI_FIXED_INTF(0x19d2, 0x0265, 4)},	/* ONDA MT8205 4G LTE */
723	{QMI_FIXED_INTF(0x19d2, 0x0284, 4)},	/* ZTE MF880 */
724	{QMI_FIXED_INTF(0x19d2, 0x0326, 4)},	/* ZTE MF821D */
725	{QMI_FIXED_INTF(0x19d2, 0x0412, 4)},	/* Telewell TW-LTE 4G */
726	{QMI_FIXED_INTF(0x19d2, 0x1008, 4)},	/* ZTE (Vodafone) K3570-Z */
727	{QMI_FIXED_INTF(0x19d2, 0x1010, 4)},	/* ZTE (Vodafone) K3571-Z */
728	{QMI_FIXED_INTF(0x19d2, 0x1012, 4)},
729	{QMI_FIXED_INTF(0x19d2, 0x1018, 3)},	/* ZTE (Vodafone) K5006-Z */
730	{QMI_FIXED_INTF(0x19d2, 0x1021, 2)},
731	{QMI_FIXED_INTF(0x19d2, 0x1245, 4)},
732	{QMI_FIXED_INTF(0x19d2, 0x1247, 4)},
733	{QMI_FIXED_INTF(0x19d2, 0x1252, 4)},
734	{QMI_FIXED_INTF(0x19d2, 0x1254, 4)},
735	{QMI_FIXED_INTF(0x19d2, 0x1255, 3)},
736	{QMI_FIXED_INTF(0x19d2, 0x1255, 4)},
737	{QMI_FIXED_INTF(0x19d2, 0x1256, 4)},
738	{QMI_FIXED_INTF(0x19d2, 0x1270, 5)},	/* ZTE MF667 */
739	{QMI_FIXED_INTF(0x19d2, 0x1401, 2)},
740	{QMI_FIXED_INTF(0x19d2, 0x1402, 2)},	/* ZTE MF60 */
741	{QMI_FIXED_INTF(0x19d2, 0x1424, 2)},
742	{QMI_FIXED_INTF(0x19d2, 0x1425, 2)},
743	{QMI_FIXED_INTF(0x19d2, 0x1426, 2)},	/* ZTE MF91 */
 
744	{QMI_FIXED_INTF(0x19d2, 0x2002, 4)},	/* ZTE (Vodafone) K3765-Z */
 
745	{QMI_FIXED_INTF(0x0f3d, 0x68a2, 8)},    /* Sierra Wireless MC7700 */
746	{QMI_FIXED_INTF(0x114f, 0x68a2, 8)},    /* Sierra Wireless MC7750 */
747	{QMI_FIXED_INTF(0x1199, 0x68a2, 8)},	/* Sierra Wireless MC7710 in QMI mode */
748	{QMI_FIXED_INTF(0x1199, 0x68a2, 19)},	/* Sierra Wireless MC7710 in QMI mode */
749	{QMI_FIXED_INTF(0x1199, 0x68c0, 8)},	/* Sierra Wireless MC73xx */
750	{QMI_FIXED_INTF(0x1199, 0x68c0, 10)},	/* Sierra Wireless MC73xx */
751	{QMI_FIXED_INTF(0x1199, 0x901c, 8)},    /* Sierra Wireless EM7700 */
752	{QMI_FIXED_INTF(0x1199, 0x901f, 8)},    /* Sierra Wireless EM7355 */
753	{QMI_FIXED_INTF(0x1199, 0x9041, 8)},	/* Sierra Wireless MC7305/MC7355 */
 
754	{QMI_FIXED_INTF(0x1199, 0x9051, 8)},	/* Netgear AirCard 340U */
755	{QMI_FIXED_INTF(0x1199, 0x9053, 8)},	/* Sierra Wireless Modem */
756	{QMI_FIXED_INTF(0x1199, 0x9054, 8)},	/* Sierra Wireless Modem */
757	{QMI_FIXED_INTF(0x1199, 0x9055, 8)},	/* Netgear AirCard 341U */
758	{QMI_FIXED_INTF(0x1199, 0x9056, 8)},	/* Sierra Wireless Modem */
 
759	{QMI_FIXED_INTF(0x1199, 0x9061, 8)},	/* Sierra Wireless Modem */
 
 
 
 
760	{QMI_FIXED_INTF(0x1bbb, 0x011e, 4)},	/* Telekom Speedstick LTE II (Alcatel One Touch L100V LTE) */
761	{QMI_FIXED_INTF(0x1bbb, 0x0203, 2)},	/* Alcatel L800MA */
762	{QMI_FIXED_INTF(0x2357, 0x0201, 4)},	/* TP-LINK HSUPA Modem MA180 */
763	{QMI_FIXED_INTF(0x2357, 0x9000, 4)},	/* TP-LINK MA260 */
 
764	{QMI_FIXED_INTF(0x1bc7, 0x1200, 5)},	/* Telit LE920 */
765	{QMI_FIXED_INTF(0x1bc7, 0x1201, 2)},	/* Telit LE920 */
766	{QMI_FIXED_INTF(0x0b3c, 0xc005, 6)},    /* Olivetti Olicard 200 */
 
 
 
 
 
 
767	{QMI_FIXED_INTF(0x0b3c, 0xc00b, 4)},	/* Olivetti Olicard 500 */
768	{QMI_FIXED_INTF(0x1e2d, 0x0060, 4)},	/* Cinterion PLxx */
769	{QMI_FIXED_INTF(0x1e2d, 0x0053, 4)},	/* Cinterion PHxx,PXxx */
 
 
 
770	{QMI_FIXED_INTF(0x413c, 0x81a2, 8)},	/* Dell Wireless 5806 Gobi(TM) 4G LTE Mobile Broadband Card */
771	{QMI_FIXED_INTF(0x413c, 0x81a3, 8)},	/* Dell Wireless 5570 HSPA+ (42Mbps) Mobile Broadband Card */
772	{QMI_FIXED_INTF(0x413c, 0x81a4, 8)},	/* Dell Wireless 5570e HSPA+ (42Mbps) Mobile Broadband Card */
773	{QMI_FIXED_INTF(0x413c, 0x81a8, 8)},	/* Dell Wireless 5808 Gobi(TM) 4G LTE Mobile Broadband Card */
774	{QMI_FIXED_INTF(0x413c, 0x81a9, 8)},	/* Dell Wireless 5808e Gobi(TM) 4G LTE Mobile Broadband Card */
 
 
 
 
 
 
 
 
 
775
776	/* 4. Gobi 1000 devices */
777	{QMI_GOBI1K_DEVICE(0x05c6, 0x9212)},	/* Acer Gobi Modem Device */
778	{QMI_GOBI1K_DEVICE(0x03f0, 0x1f1d)},	/* HP un2400 Gobi Modem Device */
779	{QMI_GOBI1K_DEVICE(0x04da, 0x250d)},	/* Panasonic Gobi Modem device */
780	{QMI_GOBI1K_DEVICE(0x413c, 0x8172)},	/* Dell Gobi Modem device */
781	{QMI_GOBI1K_DEVICE(0x1410, 0xa001)},	/* Novatel/Verizon USB-1000 */
782	{QMI_GOBI1K_DEVICE(0x1410, 0xa002)},	/* Novatel Gobi Modem device */
783	{QMI_GOBI1K_DEVICE(0x1410, 0xa003)},	/* Novatel Gobi Modem device */
784	{QMI_GOBI1K_DEVICE(0x1410, 0xa004)},	/* Novatel Gobi Modem device */
785	{QMI_GOBI1K_DEVICE(0x1410, 0xa005)},	/* Novatel Gobi Modem device */
786	{QMI_GOBI1K_DEVICE(0x1410, 0xa006)},	/* Novatel Gobi Modem device */
787	{QMI_GOBI1K_DEVICE(0x1410, 0xa007)},	/* Novatel Gobi Modem device */
788	{QMI_GOBI1K_DEVICE(0x0b05, 0x1776)},	/* Asus Gobi Modem device */
789	{QMI_GOBI1K_DEVICE(0x19d2, 0xfff3)},	/* ONDA Gobi Modem device */
790	{QMI_GOBI1K_DEVICE(0x05c6, 0x9001)},	/* Generic Gobi Modem device */
791	{QMI_GOBI1K_DEVICE(0x05c6, 0x9002)},	/* Generic Gobi Modem device */
792	{QMI_GOBI1K_DEVICE(0x05c6, 0x9202)},	/* Generic Gobi Modem device */
793	{QMI_GOBI1K_DEVICE(0x05c6, 0x9203)},	/* Generic Gobi Modem device */
794	{QMI_GOBI1K_DEVICE(0x05c6, 0x9222)},	/* Generic Gobi Modem device */
795	{QMI_GOBI1K_DEVICE(0x05c6, 0x9009)},	/* Generic Gobi Modem device */
796
797	/* 5. Gobi 2000 and 3000 devices */
798	{QMI_GOBI_DEVICE(0x413c, 0x8186)},	/* Dell Gobi 2000 Modem device (N0218, VU936) */
799	{QMI_GOBI_DEVICE(0x413c, 0x8194)},	/* Dell Gobi 3000 Composite */
800	{QMI_GOBI_DEVICE(0x05c6, 0x920b)},	/* Generic Gobi 2000 Modem device */
801	{QMI_GOBI_DEVICE(0x05c6, 0x9225)},	/* Sony Gobi 2000 Modem device (N0279, VU730) */
802	{QMI_GOBI_DEVICE(0x05c6, 0x9245)},	/* Samsung Gobi 2000 Modem device (VL176) */
803	{QMI_GOBI_DEVICE(0x03f0, 0x251d)},	/* HP Gobi 2000 Modem device (VP412) */
804	{QMI_GOBI_DEVICE(0x05c6, 0x9215)},	/* Acer Gobi 2000 Modem device (VP413) */
 
805	{QMI_GOBI_DEVICE(0x05c6, 0x9265)},	/* Asus Gobi 2000 Modem device (VR305) */
806	{QMI_GOBI_DEVICE(0x05c6, 0x9235)},	/* Top Global Gobi 2000 Modem device (VR306) */
807	{QMI_GOBI_DEVICE(0x05c6, 0x9275)},	/* iRex Technologies Gobi 2000 Modem device (VR307) */
808	{QMI_GOBI_DEVICE(0x0af0, 0x8120)},	/* Option GTM681W */
809	{QMI_GOBI_DEVICE(0x1199, 0x68a5)},	/* Sierra Wireless Modem */
810	{QMI_GOBI_DEVICE(0x1199, 0x68a9)},	/* Sierra Wireless Modem */
811	{QMI_GOBI_DEVICE(0x1199, 0x9001)},	/* Sierra Wireless Gobi 2000 Modem device (VT773) */
812	{QMI_GOBI_DEVICE(0x1199, 0x9002)},	/* Sierra Wireless Gobi 2000 Modem device (VT773) */
813	{QMI_GOBI_DEVICE(0x1199, 0x9003)},	/* Sierra Wireless Gobi 2000 Modem device (VT773) */
814	{QMI_GOBI_DEVICE(0x1199, 0x9004)},	/* Sierra Wireless Gobi 2000 Modem device (VT773) */
815	{QMI_GOBI_DEVICE(0x1199, 0x9005)},	/* Sierra Wireless Gobi 2000 Modem device (VT773) */
816	{QMI_GOBI_DEVICE(0x1199, 0x9006)},	/* Sierra Wireless Gobi 2000 Modem device (VT773) */
817	{QMI_GOBI_DEVICE(0x1199, 0x9007)},	/* Sierra Wireless Gobi 2000 Modem device (VT773) */
818	{QMI_GOBI_DEVICE(0x1199, 0x9008)},	/* Sierra Wireless Gobi 2000 Modem device (VT773) */
819	{QMI_GOBI_DEVICE(0x1199, 0x9009)},	/* Sierra Wireless Gobi 2000 Modem device (VT773) */
820	{QMI_GOBI_DEVICE(0x1199, 0x900a)},	/* Sierra Wireless Gobi 2000 Modem device (VT773) */
821	{QMI_GOBI_DEVICE(0x1199, 0x9011)},	/* Sierra Wireless Gobi 2000 Modem device (MC8305) */
822	{QMI_GOBI_DEVICE(0x16d8, 0x8002)},	/* CMDTech Gobi 2000 Modem device (VU922) */
823	{QMI_GOBI_DEVICE(0x05c6, 0x9205)},	/* Gobi 2000 Modem device */
824	{QMI_GOBI_DEVICE(0x1199, 0x9013)},	/* Sierra Wireless Gobi 3000 Modem device (MC8355) */
825	{QMI_GOBI_DEVICE(0x03f0, 0x371d)},	/* HP un2430 Mobile Broadband Module */
826	{QMI_GOBI_DEVICE(0x1199, 0x9015)},	/* Sierra Wireless Gobi 3000 Modem device */
827	{QMI_GOBI_DEVICE(0x1199, 0x9019)},	/* Sierra Wireless Gobi 3000 Modem device */
828	{QMI_GOBI_DEVICE(0x1199, 0x901b)},	/* Sierra Wireless MC7770 */
829	{QMI_GOBI_DEVICE(0x12d1, 0x14f1)},	/* Sony Gobi 3000 Composite */
830	{QMI_GOBI_DEVICE(0x1410, 0xa021)},	/* Foxconn Gobi 3000 Modem device (Novatel E396) */
831
832	{ }					/* END */
833};
834MODULE_DEVICE_TABLE(usb, products);
835
 
 
 
 
 
 
 
 
 
 
 
 
 
836static int qmi_wwan_probe(struct usb_interface *intf,
837			  const struct usb_device_id *prod)
838{
839	struct usb_device_id *id = (struct usb_device_id *)prod;
 
840
841	/* Workaround to enable dynamic IDs.  This disables usbnet
842	 * blacklisting functionality.  Which, if required, can be
843	 * reimplemented here by using a magic "blacklist" value
844	 * instead of 0 in the static device id table
845	 */
846	if (!id->driver_info) {
847		dev_dbg(&intf->dev, "setting defaults for dynamic device id\n");
848		id->driver_info = (unsigned long)&qmi_wwan_info;
 
 
 
 
 
 
849	}
850
851	return usbnet_probe(intf, id);
852}
853
854static struct usb_driver qmi_wwan_driver = {
855	.name		      = "qmi_wwan",
856	.id_table	      = products,
857	.probe		      = qmi_wwan_probe,
858	.disconnect	      = usbnet_disconnect,
859	.suspend	      = qmi_wwan_suspend,
860	.resume		      =	qmi_wwan_resume,
861	.reset_resume         = qmi_wwan_resume,
862	.supports_autosuspend = 1,
863	.disable_hub_initiated_lpm = 1,
864};
865
866module_usb_driver(qmi_wwan_driver);
867
868MODULE_AUTHOR("Bjørn Mork <bjorn@mork.no>");
869MODULE_DESCRIPTION("Qualcomm MSM Interface (QMI) WWAN driver");
870MODULE_LICENSE("GPL");
v4.10.11
   1/*
   2 * Copyright (c) 2012  Bjørn Mork <bjorn@mork.no>
   3 *
   4 * The probing code is heavily inspired by cdc_ether, which is:
   5 * Copyright (C) 2003-2005 by David Brownell
   6 * Copyright (C) 2006 by Ole Andre Vadla Ravnas (ActiveSync)
   7 *
   8 * This program is free software; you can redistribute it and/or
   9 * modify it under the terms of the GNU General Public License
  10 * version 2 as published by the Free Software Foundation.
  11 */
  12
  13#include <linux/module.h>
  14#include <linux/netdevice.h>
  15#include <linux/ethtool.h>
  16#include <linux/etherdevice.h>
  17#include <linux/if_arp.h>
  18#include <linux/mii.h>
  19#include <linux/rtnetlink.h>
  20#include <linux/usb.h>
  21#include <linux/usb/cdc.h>
  22#include <linux/usb/usbnet.h>
  23#include <linux/usb/cdc-wdm.h>
  24
  25/* This driver supports wwan (3G/LTE/?) devices using a vendor
  26 * specific management protocol called Qualcomm MSM Interface (QMI) -
  27 * in addition to the more common AT commands over serial interface
  28 * management
  29 *
  30 * QMI is wrapped in CDC, using CDC encapsulated commands on the
  31 * control ("master") interface of a two-interface CDC Union
  32 * resembling standard CDC ECM.  The devices do not use the control
  33 * interface for any other CDC messages.  Most likely because the
  34 * management protocol is used in place of the standard CDC
  35 * notifications NOTIFY_NETWORK_CONNECTION and NOTIFY_SPEED_CHANGE
  36 *
  37 * Alternatively, control and data functions can be combined in a
  38 * single USB interface.
  39 *
  40 * Handling a protocol like QMI is out of the scope for any driver.
  41 * It is exported as a character device using the cdc-wdm driver as
  42 * a subdriver, enabling userspace applications ("modem managers") to
  43 * handle it.
  44 *
  45 * These devices may alternatively/additionally be configured using AT
  46 * commands on a serial interface
  47 */
  48
  49/* driver specific data */
  50struct qmi_wwan_state {
  51	struct usb_driver *subdriver;
  52	atomic_t pmcount;
  53	unsigned long flags;
  54	struct usb_interface *control;
  55	struct usb_interface *data;
  56};
  57
  58enum qmi_wwan_flags {
  59	QMI_WWAN_FLAG_RAWIP = 1 << 0,
  60};
  61
  62enum qmi_wwan_quirks {
  63	QMI_WWAN_QUIRK_DTR = 1 << 0,	/* needs "set DTR" request */
  64};
  65
  66static void qmi_wwan_netdev_setup(struct net_device *net)
  67{
  68	struct usbnet *dev = netdev_priv(net);
  69	struct qmi_wwan_state *info = (void *)&dev->data;
  70
  71	if (info->flags & QMI_WWAN_FLAG_RAWIP) {
  72		net->header_ops      = NULL;  /* No header */
  73		net->type            = ARPHRD_NONE;
  74		net->hard_header_len = 0;
  75		net->addr_len        = 0;
  76		net->flags           = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST;
  77		netdev_dbg(net, "mode: raw IP\n");
  78	} else if (!net->header_ops) { /* don't bother if already set */
  79		ether_setup(net);
  80		netdev_dbg(net, "mode: Ethernet\n");
  81	}
  82
  83	/* recalculate buffers after changing hard_header_len */
  84	usbnet_change_mtu(net, net->mtu);
  85}
  86
  87static ssize_t raw_ip_show(struct device *d, struct device_attribute *attr, char *buf)
  88{
  89	struct usbnet *dev = netdev_priv(to_net_dev(d));
  90	struct qmi_wwan_state *info = (void *)&dev->data;
  91
  92	return sprintf(buf, "%c\n", info->flags & QMI_WWAN_FLAG_RAWIP ? 'Y' : 'N');
  93}
  94
  95static ssize_t raw_ip_store(struct device *d,  struct device_attribute *attr, const char *buf, size_t len)
  96{
  97	struct usbnet *dev = netdev_priv(to_net_dev(d));
  98	struct qmi_wwan_state *info = (void *)&dev->data;
  99	bool enable;
 100	int ret;
 101
 102	if (strtobool(buf, &enable))
 103		return -EINVAL;
 104
 105	/* no change? */
 106	if (enable == (info->flags & QMI_WWAN_FLAG_RAWIP))
 107		return len;
 108
 109	if (!rtnl_trylock())
 110		return restart_syscall();
 111
 112	/* we don't want to modify a running netdev */
 113	if (netif_running(dev->net)) {
 114		netdev_err(dev->net, "Cannot change a running device\n");
 115		ret = -EBUSY;
 116		goto err;
 117	}
 118
 119	/* let other drivers deny the change */
 120	ret = call_netdevice_notifiers(NETDEV_PRE_TYPE_CHANGE, dev->net);
 121	ret = notifier_to_errno(ret);
 122	if (ret) {
 123		netdev_err(dev->net, "Type change was refused\n");
 124		goto err;
 125	}
 126
 127	if (enable)
 128		info->flags |= QMI_WWAN_FLAG_RAWIP;
 129	else
 130		info->flags &= ~QMI_WWAN_FLAG_RAWIP;
 131	qmi_wwan_netdev_setup(dev->net);
 132	call_netdevice_notifiers(NETDEV_POST_TYPE_CHANGE, dev->net);
 133	ret = len;
 134err:
 135	rtnl_unlock();
 136	return ret;
 137}
 138
 139static DEVICE_ATTR_RW(raw_ip);
 140
 141static struct attribute *qmi_wwan_sysfs_attrs[] = {
 142	&dev_attr_raw_ip.attr,
 143	NULL,
 144};
 145
 146static struct attribute_group qmi_wwan_sysfs_attr_group = {
 147	.name = "qmi",
 148	.attrs = qmi_wwan_sysfs_attrs,
 149};
 150
 151/* default ethernet address used by the modem */
 152static const u8 default_modem_addr[ETH_ALEN] = {0x02, 0x50, 0xf3};
 153
 154static const u8 buggy_fw_addr[ETH_ALEN] = {0x00, 0xa0, 0xc6, 0x00, 0x00, 0x00};
 155
 156/* Make up an ethernet header if the packet doesn't have one.
 157 *
 158 * A firmware bug common among several devices cause them to send raw
 159 * IP packets under some circumstances.  There is no way for the
 160 * driver/host to know when this will happen.  And even when the bug
 161 * hits, some packets will still arrive with an intact header.
 162 *
 163 * The supported devices are only capably of sending IPv4, IPv6 and
 164 * ARP packets on a point-to-point link. Any packet with an ethernet
 165 * header will have either our address or a broadcast/multicast
 166 * address as destination.  ARP packets will always have a header.
 167 *
 168 * This means that this function will reliably add the appropriate
 169 * header iff necessary, provided our hardware address does not start
 170 * with 4 or 6.
 171 *
 172 * Another common firmware bug results in all packets being addressed
 173 * to 00:a0:c6:00:00:00 despite the host address being different.
 174 * This function will also fixup such packets.
 175 */
 176static int qmi_wwan_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
 177{
 178	struct qmi_wwan_state *info = (void *)&dev->data;
 179	bool rawip = info->flags & QMI_WWAN_FLAG_RAWIP;
 180	__be16 proto;
 181
 182	/* This check is no longer done by usbnet */
 183	if (skb->len < dev->net->hard_header_len)
 184		return 0;
 185
 186	switch (skb->data[0] & 0xf0) {
 187	case 0x40:
 188		proto = htons(ETH_P_IP);
 189		break;
 190	case 0x60:
 191		proto = htons(ETH_P_IPV6);
 192		break;
 193	case 0x00:
 194		if (rawip)
 195			return 0;
 196		if (is_multicast_ether_addr(skb->data))
 197			return 1;
 198		/* possibly bogus destination - rewrite just in case */
 199		skb_reset_mac_header(skb);
 200		goto fix_dest;
 201	default:
 202		if (rawip)
 203			return 0;
 204		/* pass along other packets without modifications */
 205		return 1;
 206	}
 207	if (rawip) {
 208		skb->dev = dev->net; /* normally set by eth_type_trans */
 209		skb->protocol = proto;
 210		return 1;
 211	}
 212
 213	if (skb_headroom(skb) < ETH_HLEN)
 214		return 0;
 215	skb_push(skb, ETH_HLEN);
 216	skb_reset_mac_header(skb);
 217	eth_hdr(skb)->h_proto = proto;
 218	eth_zero_addr(eth_hdr(skb)->h_source);
 219fix_dest:
 220	memcpy(eth_hdr(skb)->h_dest, dev->net->dev_addr, ETH_ALEN);
 221	return 1;
 222}
 223
 224/* very simplistic detection of IPv4 or IPv6 headers */
 225static bool possibly_iphdr(const char *data)
 226{
 227	return (data[0] & 0xd0) == 0x40;
 228}
 229
 230/* disallow addresses which may be confused with IP headers */
 231static int qmi_wwan_mac_addr(struct net_device *dev, void *p)
 232{
 233	int ret;
 234	struct sockaddr *addr = p;
 235
 236	ret = eth_prepare_mac_addr_change(dev, p);
 237	if (ret < 0)
 238		return ret;
 239	if (possibly_iphdr(addr->sa_data))
 240		return -EADDRNOTAVAIL;
 241	eth_commit_mac_addr_change(dev, p);
 242	return 0;
 243}
 244
 245static const struct net_device_ops qmi_wwan_netdev_ops = {
 246	.ndo_open		= usbnet_open,
 247	.ndo_stop		= usbnet_stop,
 248	.ndo_start_xmit		= usbnet_start_xmit,
 249	.ndo_tx_timeout		= usbnet_tx_timeout,
 250	.ndo_change_mtu		= usbnet_change_mtu,
 251	.ndo_set_mac_address	= qmi_wwan_mac_addr,
 252	.ndo_validate_addr	= eth_validate_addr,
 253};
 254
 255/* using a counter to merge subdriver requests with our own into a
 256 * combined state
 257 */
 258static int qmi_wwan_manage_power(struct usbnet *dev, int on)
 259{
 260	struct qmi_wwan_state *info = (void *)&dev->data;
 261	int rv;
 262
 263	dev_dbg(&dev->intf->dev, "%s() pmcount=%d, on=%d\n", __func__,
 264		atomic_read(&info->pmcount), on);
 265
 266	if ((on && atomic_add_return(1, &info->pmcount) == 1) ||
 267	    (!on && atomic_dec_and_test(&info->pmcount))) {
 268		/* need autopm_get/put here to ensure the usbcore sees
 269		 * the new value
 270		 */
 271		rv = usb_autopm_get_interface(dev->intf);
 272		dev->intf->needs_remote_wakeup = on;
 273		if (!rv)
 274			usb_autopm_put_interface(dev->intf);
 275	}
 276	return 0;
 277}
 278
 279static int qmi_wwan_cdc_wdm_manage_power(struct usb_interface *intf, int on)
 280{
 281	struct usbnet *dev = usb_get_intfdata(intf);
 282
 283	/* can be called while disconnecting */
 284	if (!dev)
 285		return 0;
 286	return qmi_wwan_manage_power(dev, on);
 287}
 288
 289/* collect all three endpoints and register subdriver */
 290static int qmi_wwan_register_subdriver(struct usbnet *dev)
 291{
 292	int rv;
 293	struct usb_driver *subdriver = NULL;
 294	struct qmi_wwan_state *info = (void *)&dev->data;
 295
 296	/* collect bulk endpoints */
 297	rv = usbnet_get_endpoints(dev, info->data);
 298	if (rv < 0)
 299		goto err;
 300
 301	/* update status endpoint if separate control interface */
 302	if (info->control != info->data)
 303		dev->status = &info->control->cur_altsetting->endpoint[0];
 304
 305	/* require interrupt endpoint for subdriver */
 306	if (!dev->status) {
 307		rv = -EINVAL;
 308		goto err;
 309	}
 310
 311	/* for subdriver power management */
 312	atomic_set(&info->pmcount, 0);
 313
 314	/* register subdriver */
 315	subdriver = usb_cdc_wdm_register(info->control, &dev->status->desc,
 316					 4096, &qmi_wwan_cdc_wdm_manage_power);
 317	if (IS_ERR(subdriver)) {
 318		dev_err(&info->control->dev, "subdriver registration failed\n");
 319		rv = PTR_ERR(subdriver);
 320		goto err;
 321	}
 322
 323	/* prevent usbnet from using status endpoint */
 324	dev->status = NULL;
 325
 326	/* save subdriver struct for suspend/resume wrappers */
 327	info->subdriver = subdriver;
 328
 329err:
 330	return rv;
 331}
 332
 333/* Send CDC SetControlLineState request, setting or clearing the DTR.
 334 * "Required for Autoconnect and 9x30 to wake up" according to the
 335 * GobiNet driver. The requirement has been verified on an MDM9230
 336 * based Sierra Wireless MC7455
 337 */
 338static int qmi_wwan_change_dtr(struct usbnet *dev, bool on)
 339{
 340	u8 intf = dev->intf->cur_altsetting->desc.bInterfaceNumber;
 341
 342	return usbnet_write_cmd(dev, USB_CDC_REQ_SET_CONTROL_LINE_STATE,
 343				USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
 344				on ? 0x01 : 0x00, intf, NULL, 0);
 345}
 346
 347static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf)
 348{
 349	int status = -1;
 350	u8 *buf = intf->cur_altsetting->extra;
 351	int len = intf->cur_altsetting->extralen;
 352	struct usb_interface_descriptor *desc = &intf->cur_altsetting->desc;
 353	struct usb_cdc_union_desc *cdc_union;
 354	struct usb_cdc_ether_desc *cdc_ether;
 
 355	struct usb_driver *driver = driver_of(intf);
 356	struct qmi_wwan_state *info = (void *)&dev->data;
 357	struct usb_cdc_parsed_header hdr;
 358
 359	BUILD_BUG_ON((sizeof(((struct usbnet *)0)->data) <
 360		      sizeof(struct qmi_wwan_state)));
 361
 362	/* set up initial state */
 363	info->control = intf;
 364	info->data = intf;
 365
 366	/* and a number of CDC descriptors */
 367	cdc_parse_cdc_header(&hdr, intf, buf, len);
 368	cdc_union = hdr.usb_cdc_union_desc;
 369	cdc_ether = hdr.usb_cdc_ether_desc;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 370
 371	/* Use separate control and data interfaces if we found a CDC Union */
 372	if (cdc_union) {
 373		info->data = usb_ifnum_to_if(dev->udev,
 374					     cdc_union->bSlaveInterface0);
 375		if (desc->bInterfaceNumber != cdc_union->bMasterInterface0 ||
 376		    !info->data) {
 377			dev_err(&intf->dev,
 378				"bogus CDC Union: master=%u, slave=%u\n",
 379				cdc_union->bMasterInterface0,
 380				cdc_union->bSlaveInterface0);
 381
 382			/* ignore and continue... */
 383			cdc_union = NULL;
 384			info->data = intf;
 385		}
 386	}
 387
 388	/* errors aren't fatal - we can live with the dynamic address */
 389	if (cdc_ether) {
 390		dev->hard_mtu = le16_to_cpu(cdc_ether->wMaxSegmentSize);
 391		usbnet_get_ethernet_addr(dev, cdc_ether->iMACAddress);
 392	}
 393
 394	/* claim data interface and set it up */
 395	if (info->control != info->data) {
 396		status = usb_driver_claim_interface(driver, info->data, dev);
 397		if (status < 0)
 398			goto err;
 399	}
 400
 401	status = qmi_wwan_register_subdriver(dev);
 402	if (status < 0 && info->control != info->data) {
 403		usb_set_intfdata(info->data, NULL);
 404		usb_driver_release_interface(driver, info->data);
 405	}
 406
 407	/* disabling remote wakeup on MDM9x30 devices has the same
 408	 * effect as clearing DTR. The device will not respond to QMI
 409	 * requests until we set DTR again.  This is similar to a
 410	 * QMI_CTL SYNC request, clearing a lot of firmware state
 411	 * including the client ID allocations.
 412	 *
 413	 * Our usage model allows a session to span multiple
 414	 * open/close events, so we must prevent the firmware from
 415	 * clearing out state the clients might need.
 416	 *
 417	 * MDM9x30 is the first QMI chipset with USB3 support. Abuse
 418	 * this fact to enable the quirk for all USB3 devices.
 419	 *
 420	 * There are also chipsets with the same "set DTR" requirement
 421	 * but without USB3 support.  Devices based on these chips
 422	 * need a quirk flag in the device ID table.
 423	 */
 424	if (dev->driver_info->data & QMI_WWAN_QUIRK_DTR ||
 425	    le16_to_cpu(dev->udev->descriptor.bcdUSB) >= 0x0201) {
 426		qmi_wwan_manage_power(dev, 1);
 427		qmi_wwan_change_dtr(dev, true);
 428	}
 429
 430	/* Never use the same address on both ends of the link, even if the
 431	 * buggy firmware told us to. Or, if device is assigned the well-known
 432	 * buggy firmware MAC address, replace it with a random address,
 433	 */
 434	if (ether_addr_equal(dev->net->dev_addr, default_modem_addr) ||
 435	    ether_addr_equal(dev->net->dev_addr, buggy_fw_addr))
 436		eth_hw_addr_random(dev->net);
 437
 438	/* make MAC addr easily distinguishable from an IP header */
 439	if (possibly_iphdr(dev->net->dev_addr)) {
 440		dev->net->dev_addr[0] |= 0x02;	/* set local assignment bit */
 441		dev->net->dev_addr[0] &= 0xbf;	/* clear "IP" bit */
 442	}
 443	dev->net->netdev_ops = &qmi_wwan_netdev_ops;
 444	dev->net->sysfs_groups[0] = &qmi_wwan_sysfs_attr_group;
 445err:
 446	return status;
 447}
 448
 449static void qmi_wwan_unbind(struct usbnet *dev, struct usb_interface *intf)
 450{
 451	struct qmi_wwan_state *info = (void *)&dev->data;
 452	struct usb_driver *driver = driver_of(intf);
 453	struct usb_interface *other;
 454
 455	if (info->subdriver && info->subdriver->disconnect)
 456		info->subdriver->disconnect(info->control);
 457
 458	/* disable MDM9x30 quirk */
 459	if (le16_to_cpu(dev->udev->descriptor.bcdUSB) >= 0x0201) {
 460		qmi_wwan_change_dtr(dev, false);
 461		qmi_wwan_manage_power(dev, 0);
 462	}
 463
 464	/* allow user to unbind using either control or data */
 465	if (intf == info->control)
 466		other = info->data;
 467	else
 468		other = info->control;
 469
 470	/* only if not shared */
 471	if (other && intf != other) {
 472		usb_set_intfdata(other, NULL);
 473		usb_driver_release_interface(driver, other);
 474	}
 475
 476	info->subdriver = NULL;
 477	info->data = NULL;
 478	info->control = NULL;
 479}
 480
 481/* suspend/resume wrappers calling both usbnet and the cdc-wdm
 482 * subdriver if present.
 483 *
 484 * NOTE: cdc-wdm also supports pre/post_reset, but we cannot provide
 485 * wrappers for those without adding usbnet reset support first.
 486 */
 487static int qmi_wwan_suspend(struct usb_interface *intf, pm_message_t message)
 488{
 489	struct usbnet *dev = usb_get_intfdata(intf);
 490	struct qmi_wwan_state *info = (void *)&dev->data;
 491	int ret;
 492
 493	/* Both usbnet_suspend() and subdriver->suspend() MUST return 0
 494	 * in system sleep context, otherwise, the resume callback has
 495	 * to recover device from previous suspend failure.
 496	 */
 497	ret = usbnet_suspend(intf, message);
 498	if (ret < 0)
 499		goto err;
 500
 501	if (intf == info->control && info->subdriver &&
 502	    info->subdriver->suspend)
 503		ret = info->subdriver->suspend(intf, message);
 504	if (ret < 0)
 505		usbnet_resume(intf);
 506err:
 507	return ret;
 508}
 509
 510static int qmi_wwan_resume(struct usb_interface *intf)
 511{
 512	struct usbnet *dev = usb_get_intfdata(intf);
 513	struct qmi_wwan_state *info = (void *)&dev->data;
 514	int ret = 0;
 515	bool callsub = (intf == info->control && info->subdriver &&
 516			info->subdriver->resume);
 517
 518	if (callsub)
 519		ret = info->subdriver->resume(intf);
 520	if (ret < 0)
 521		goto err;
 522	ret = usbnet_resume(intf);
 523	if (ret < 0 && callsub)
 524		info->subdriver->suspend(intf, PMSG_SUSPEND);
 525err:
 526	return ret;
 527}
 528
 529static const struct driver_info	qmi_wwan_info = {
 530	.description	= "WWAN/QMI device",
 531	.flags		= FLAG_WWAN,
 532	.bind		= qmi_wwan_bind,
 533	.unbind		= qmi_wwan_unbind,
 534	.manage_power	= qmi_wwan_manage_power,
 535	.rx_fixup       = qmi_wwan_rx_fixup,
 536};
 537
 538static const struct driver_info	qmi_wwan_info_quirk_dtr = {
 539	.description	= "WWAN/QMI device",
 540	.flags		= FLAG_WWAN,
 541	.bind		= qmi_wwan_bind,
 542	.unbind		= qmi_wwan_unbind,
 543	.manage_power	= qmi_wwan_manage_power,
 544	.rx_fixup       = qmi_wwan_rx_fixup,
 545	.data           = QMI_WWAN_QUIRK_DTR,
 546};
 547
 548#define HUAWEI_VENDOR_ID	0x12D1
 549
 550/* map QMI/wwan function by a fixed interface number */
 551#define QMI_FIXED_INTF(vend, prod, num) \
 552	USB_DEVICE_INTERFACE_NUMBER(vend, prod, num), \
 553	.driver_info = (unsigned long)&qmi_wwan_info
 554
 555/* devices requiring "set DTR" quirk */
 556#define QMI_QUIRK_SET_DTR(vend, prod, num) \
 557	USB_DEVICE_INTERFACE_NUMBER(vend, prod, num), \
 558	.driver_info = (unsigned long)&qmi_wwan_info_quirk_dtr
 559
 560/* Gobi 1000 QMI/wwan interface number is 3 according to qcserial */
 561#define QMI_GOBI1K_DEVICE(vend, prod) \
 562	QMI_FIXED_INTF(vend, prod, 3)
 563
 564/* Gobi 2000/3000 QMI/wwan interface number is 0 according to qcserial */
 565#define QMI_GOBI_DEVICE(vend, prod) \
 566	QMI_FIXED_INTF(vend, prod, 0)
 567
 568static const struct usb_device_id products[] = {
 569	/* 1. CDC ECM like devices match on the control interface */
 570	{	/* Huawei E392, E398 and possibly others sharing both device id and more... */
 571		USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 1, 9),
 572		.driver_info        = (unsigned long)&qmi_wwan_info,
 573	},
 574	{	/* Vodafone/Huawei K5005 (12d1:14c8) and similar modems */
 575		USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 1, 57),
 576		.driver_info        = (unsigned long)&qmi_wwan_info,
 577	},
 578	{	/* HUAWEI_INTERFACE_NDIS_CONTROL_QUALCOMM */
 579		USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 0x01, 0x69),
 580		.driver_info        = (unsigned long)&qmi_wwan_info,
 581	},
 582
 583	/* 2. Combined interface devices matching on class+protocol */
 584	{	/* Huawei E367 and possibly others in "Windows mode" */
 585		USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 1, 7),
 586		.driver_info        = (unsigned long)&qmi_wwan_info,
 587	},
 588	{	/* Huawei E392, E398 and possibly others in "Windows mode" */
 589		USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 1, 17),
 590		.driver_info        = (unsigned long)&qmi_wwan_info,
 591	},
 592	{	/* HUAWEI_NDIS_SINGLE_INTERFACE_VDF */
 593		USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 0x01, 0x37),
 594		.driver_info        = (unsigned long)&qmi_wwan_info,
 595	},
 596	{	/* HUAWEI_INTERFACE_NDIS_HW_QUALCOMM */
 597		USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, USB_CLASS_VENDOR_SPEC, 0x01, 0x67),
 598		.driver_info        = (unsigned long)&qmi_wwan_info,
 599	},
 600	{	/* Pantech UML290, P4200 and more */
 601		USB_VENDOR_AND_INTERFACE_INFO(0x106c, USB_CLASS_VENDOR_SPEC, 0xf0, 0xff),
 602		.driver_info        = (unsigned long)&qmi_wwan_info,
 603	},
 604	{	/* Pantech UML290 - newer firmware */
 605		USB_VENDOR_AND_INTERFACE_INFO(0x106c, USB_CLASS_VENDOR_SPEC, 0xf1, 0xff),
 606		.driver_info        = (unsigned long)&qmi_wwan_info,
 607	},
 608	{	/* Novatel USB551L and MC551 */
 609		USB_DEVICE_AND_INTERFACE_INFO(0x1410, 0xb001,
 610		                              USB_CLASS_COMM,
 611		                              USB_CDC_SUBCLASS_ETHERNET,
 612		                              USB_CDC_PROTO_NONE),
 613		.driver_info        = (unsigned long)&qmi_wwan_info,
 614	},
 615	{	/* Novatel E362 */
 616		USB_DEVICE_AND_INTERFACE_INFO(0x1410, 0x9010,
 617		                              USB_CLASS_COMM,
 618		                              USB_CDC_SUBCLASS_ETHERNET,
 619		                              USB_CDC_PROTO_NONE),
 620		.driver_info        = (unsigned long)&qmi_wwan_info,
 621	},
 622	{	/* Novatel Expedite E371 */
 623		USB_DEVICE_AND_INTERFACE_INFO(0x1410, 0x9011,
 624		                              USB_CLASS_COMM,
 625		                              USB_CDC_SUBCLASS_ETHERNET,
 626		                              USB_CDC_PROTO_NONE),
 627		.driver_info        = (unsigned long)&qmi_wwan_info,
 628	},
 629	{	/* Dell Wireless 5800 (Novatel E362) */
 630		USB_DEVICE_AND_INTERFACE_INFO(0x413C, 0x8195,
 631					      USB_CLASS_COMM,
 632					      USB_CDC_SUBCLASS_ETHERNET,
 633					      USB_CDC_PROTO_NONE),
 634		.driver_info        = (unsigned long)&qmi_wwan_info,
 635	},
 636	{	/* Dell Wireless 5800 V2 (Novatel E362) */
 637		USB_DEVICE_AND_INTERFACE_INFO(0x413C, 0x8196,
 638					      USB_CLASS_COMM,
 639					      USB_CDC_SUBCLASS_ETHERNET,
 640					      USB_CDC_PROTO_NONE),
 641		.driver_info        = (unsigned long)&qmi_wwan_info,
 642	},
 643	{	/* Dell Wireless 5804 (Novatel E371) */
 644		USB_DEVICE_AND_INTERFACE_INFO(0x413C, 0x819b,
 645					      USB_CLASS_COMM,
 646					      USB_CDC_SUBCLASS_ETHERNET,
 647					      USB_CDC_PROTO_NONE),
 648		.driver_info        = (unsigned long)&qmi_wwan_info,
 649	},
 650	{	/* ADU960S */
 651		USB_DEVICE_AND_INTERFACE_INFO(0x16d5, 0x650a,
 652					      USB_CLASS_COMM,
 653					      USB_CDC_SUBCLASS_ETHERNET,
 654					      USB_CDC_PROTO_NONE),
 655		.driver_info        = (unsigned long)&qmi_wwan_info,
 656	},
 657	{	/* HP lt2523 (Novatel E371) */
 658		USB_DEVICE_AND_INTERFACE_INFO(0x03f0, 0x421d,
 659					      USB_CLASS_COMM,
 660					      USB_CDC_SUBCLASS_ETHERNET,
 661					      USB_CDC_PROTO_NONE),
 662		.driver_info        = (unsigned long)&qmi_wwan_info,
 663	},
 664	{	/* HP lt4112 LTE/HSPA+ Gobi 4G Module (Huawei me906e) */
 665		USB_DEVICE_AND_INTERFACE_INFO(0x03f0, 0x581d, USB_CLASS_VENDOR_SPEC, 1, 7),
 666		.driver_info = (unsigned long)&qmi_wwan_info,
 667	},
 668
 669	/* 3. Combined interface devices matching on interface number */
 670	{QMI_FIXED_INTF(0x0408, 0xea42, 4)},	/* Yota / Megafon M100-1 */
 671	{QMI_FIXED_INTF(0x05c6, 0x6001, 3)},	/* 4G LTE usb-modem U901 */
 672	{QMI_FIXED_INTF(0x05c6, 0x7000, 0)},
 673	{QMI_FIXED_INTF(0x05c6, 0x7001, 1)},
 674	{QMI_FIXED_INTF(0x05c6, 0x7002, 1)},
 675	{QMI_FIXED_INTF(0x05c6, 0x7101, 1)},
 676	{QMI_FIXED_INTF(0x05c6, 0x7101, 2)},
 677	{QMI_FIXED_INTF(0x05c6, 0x7101, 3)},
 678	{QMI_FIXED_INTF(0x05c6, 0x7102, 1)},
 679	{QMI_FIXED_INTF(0x05c6, 0x7102, 2)},
 680	{QMI_FIXED_INTF(0x05c6, 0x7102, 3)},
 681	{QMI_FIXED_INTF(0x05c6, 0x8000, 7)},
 682	{QMI_FIXED_INTF(0x05c6, 0x8001, 6)},
 683	{QMI_FIXED_INTF(0x05c6, 0x9000, 4)},
 684	{QMI_FIXED_INTF(0x05c6, 0x9003, 4)},
 685	{QMI_FIXED_INTF(0x05c6, 0x9005, 2)},
 686	{QMI_FIXED_INTF(0x05c6, 0x900a, 4)},
 687	{QMI_FIXED_INTF(0x05c6, 0x900b, 2)},
 688	{QMI_FIXED_INTF(0x05c6, 0x900c, 4)},
 689	{QMI_FIXED_INTF(0x05c6, 0x900c, 5)},
 690	{QMI_FIXED_INTF(0x05c6, 0x900c, 6)},
 691	{QMI_FIXED_INTF(0x05c6, 0x900d, 5)},
 692	{QMI_FIXED_INTF(0x05c6, 0x900f, 3)},
 693	{QMI_FIXED_INTF(0x05c6, 0x900f, 4)},
 694	{QMI_FIXED_INTF(0x05c6, 0x900f, 5)},
 695	{QMI_FIXED_INTF(0x05c6, 0x9010, 4)},
 696	{QMI_FIXED_INTF(0x05c6, 0x9010, 5)},
 697	{QMI_FIXED_INTF(0x05c6, 0x9011, 3)},
 698	{QMI_FIXED_INTF(0x05c6, 0x9011, 4)},
 699	{QMI_FIXED_INTF(0x05c6, 0x9021, 1)},
 700	{QMI_FIXED_INTF(0x05c6, 0x9022, 2)},
 701	{QMI_FIXED_INTF(0x05c6, 0x9025, 4)},	/* Alcatel-sbell ASB TL131 TDD LTE  (China Mobile) */
 702	{QMI_FIXED_INTF(0x05c6, 0x9026, 3)},
 703	{QMI_FIXED_INTF(0x05c6, 0x902e, 5)},
 704	{QMI_FIXED_INTF(0x05c6, 0x9031, 5)},
 705	{QMI_FIXED_INTF(0x05c6, 0x9032, 4)},
 706	{QMI_FIXED_INTF(0x05c6, 0x9033, 3)},
 707	{QMI_FIXED_INTF(0x05c6, 0x9033, 4)},
 708	{QMI_FIXED_INTF(0x05c6, 0x9033, 5)},
 709	{QMI_FIXED_INTF(0x05c6, 0x9033, 6)},
 710	{QMI_FIXED_INTF(0x05c6, 0x9034, 3)},
 711	{QMI_FIXED_INTF(0x05c6, 0x9034, 4)},
 712	{QMI_FIXED_INTF(0x05c6, 0x9034, 5)},
 713	{QMI_FIXED_INTF(0x05c6, 0x9034, 6)},
 714	{QMI_FIXED_INTF(0x05c6, 0x9034, 7)},
 715	{QMI_FIXED_INTF(0x05c6, 0x9035, 4)},
 716	{QMI_FIXED_INTF(0x05c6, 0x9036, 3)},
 717	{QMI_FIXED_INTF(0x05c6, 0x9037, 5)},
 718	{QMI_FIXED_INTF(0x05c6, 0x9038, 4)},
 719	{QMI_FIXED_INTF(0x05c6, 0x903b, 7)},
 720	{QMI_FIXED_INTF(0x05c6, 0x903c, 6)},
 721	{QMI_FIXED_INTF(0x05c6, 0x903d, 6)},
 722	{QMI_FIXED_INTF(0x05c6, 0x903e, 5)},
 723	{QMI_FIXED_INTF(0x05c6, 0x9043, 3)},
 724	{QMI_FIXED_INTF(0x05c6, 0x9046, 3)},
 725	{QMI_FIXED_INTF(0x05c6, 0x9046, 4)},
 726	{QMI_FIXED_INTF(0x05c6, 0x9046, 5)},
 727	{QMI_FIXED_INTF(0x05c6, 0x9047, 2)},
 728	{QMI_FIXED_INTF(0x05c6, 0x9047, 3)},
 729	{QMI_FIXED_INTF(0x05c6, 0x9047, 4)},
 730	{QMI_FIXED_INTF(0x05c6, 0x9048, 4)},
 731	{QMI_FIXED_INTF(0x05c6, 0x9048, 5)},
 732	{QMI_FIXED_INTF(0x05c6, 0x9048, 6)},
 733	{QMI_FIXED_INTF(0x05c6, 0x9048, 7)},
 734	{QMI_FIXED_INTF(0x05c6, 0x9048, 8)},
 735	{QMI_FIXED_INTF(0x05c6, 0x904c, 5)},
 736	{QMI_FIXED_INTF(0x05c6, 0x904c, 6)},
 737	{QMI_FIXED_INTF(0x05c6, 0x904c, 7)},
 738	{QMI_FIXED_INTF(0x05c6, 0x904c, 8)},
 739	{QMI_FIXED_INTF(0x05c6, 0x9050, 3)},
 740	{QMI_FIXED_INTF(0x05c6, 0x9052, 4)},
 741	{QMI_FIXED_INTF(0x05c6, 0x9053, 6)},
 742	{QMI_FIXED_INTF(0x05c6, 0x9053, 7)},
 743	{QMI_FIXED_INTF(0x05c6, 0x9054, 5)},
 744	{QMI_FIXED_INTF(0x05c6, 0x9054, 6)},
 745	{QMI_FIXED_INTF(0x05c6, 0x9055, 3)},
 746	{QMI_FIXED_INTF(0x05c6, 0x9055, 4)},
 747	{QMI_FIXED_INTF(0x05c6, 0x9055, 5)},
 748	{QMI_FIXED_INTF(0x05c6, 0x9055, 6)},
 749	{QMI_FIXED_INTF(0x05c6, 0x9055, 7)},
 750	{QMI_FIXED_INTF(0x05c6, 0x9056, 3)},
 751	{QMI_FIXED_INTF(0x05c6, 0x9062, 2)},
 752	{QMI_FIXED_INTF(0x05c6, 0x9062, 3)},
 753	{QMI_FIXED_INTF(0x05c6, 0x9062, 4)},
 754	{QMI_FIXED_INTF(0x05c6, 0x9062, 5)},
 755	{QMI_FIXED_INTF(0x05c6, 0x9062, 6)},
 756	{QMI_FIXED_INTF(0x05c6, 0x9062, 7)},
 757	{QMI_FIXED_INTF(0x05c6, 0x9062, 8)},
 758	{QMI_FIXED_INTF(0x05c6, 0x9062, 9)},
 759	{QMI_FIXED_INTF(0x05c6, 0x9064, 3)},
 760	{QMI_FIXED_INTF(0x05c6, 0x9065, 6)},
 761	{QMI_FIXED_INTF(0x05c6, 0x9065, 7)},
 762	{QMI_FIXED_INTF(0x05c6, 0x9066, 5)},
 763	{QMI_FIXED_INTF(0x05c6, 0x9066, 6)},
 764	{QMI_FIXED_INTF(0x05c6, 0x9067, 1)},
 765	{QMI_FIXED_INTF(0x05c6, 0x9068, 2)},
 766	{QMI_FIXED_INTF(0x05c6, 0x9068, 3)},
 767	{QMI_FIXED_INTF(0x05c6, 0x9068, 4)},
 768	{QMI_FIXED_INTF(0x05c6, 0x9068, 5)},
 769	{QMI_FIXED_INTF(0x05c6, 0x9068, 6)},
 770	{QMI_FIXED_INTF(0x05c6, 0x9068, 7)},
 771	{QMI_FIXED_INTF(0x05c6, 0x9069, 5)},
 772	{QMI_FIXED_INTF(0x05c6, 0x9069, 6)},
 773	{QMI_FIXED_INTF(0x05c6, 0x9069, 7)},
 774	{QMI_FIXED_INTF(0x05c6, 0x9069, 8)},
 775	{QMI_FIXED_INTF(0x05c6, 0x9070, 4)},
 776	{QMI_FIXED_INTF(0x05c6, 0x9070, 5)},
 777	{QMI_FIXED_INTF(0x05c6, 0x9075, 5)},
 778	{QMI_FIXED_INTF(0x05c6, 0x9076, 4)},
 779	{QMI_FIXED_INTF(0x05c6, 0x9076, 5)},
 780	{QMI_FIXED_INTF(0x05c6, 0x9076, 6)},
 781	{QMI_FIXED_INTF(0x05c6, 0x9076, 7)},
 782	{QMI_FIXED_INTF(0x05c6, 0x9076, 8)},
 783	{QMI_FIXED_INTF(0x05c6, 0x9077, 3)},
 784	{QMI_FIXED_INTF(0x05c6, 0x9077, 4)},
 785	{QMI_FIXED_INTF(0x05c6, 0x9077, 5)},
 786	{QMI_FIXED_INTF(0x05c6, 0x9077, 6)},
 787	{QMI_FIXED_INTF(0x05c6, 0x9078, 3)},
 788	{QMI_FIXED_INTF(0x05c6, 0x9079, 4)},
 789	{QMI_FIXED_INTF(0x05c6, 0x9079, 5)},
 790	{QMI_FIXED_INTF(0x05c6, 0x9079, 6)},
 791	{QMI_FIXED_INTF(0x05c6, 0x9079, 7)},
 792	{QMI_FIXED_INTF(0x05c6, 0x9079, 8)},
 793	{QMI_FIXED_INTF(0x05c6, 0x9080, 5)},
 794	{QMI_FIXED_INTF(0x05c6, 0x9080, 6)},
 795	{QMI_FIXED_INTF(0x05c6, 0x9080, 7)},
 796	{QMI_FIXED_INTF(0x05c6, 0x9080, 8)},
 797	{QMI_FIXED_INTF(0x05c6, 0x9083, 3)},
 798	{QMI_FIXED_INTF(0x05c6, 0x9084, 4)},
 799	{QMI_FIXED_INTF(0x05c6, 0x920d, 0)},
 800	{QMI_FIXED_INTF(0x05c6, 0x920d, 5)},
 801	{QMI_FIXED_INTF(0x0846, 0x68a2, 8)},
 802	{QMI_FIXED_INTF(0x12d1, 0x140c, 1)},	/* Huawei E173 */
 803	{QMI_FIXED_INTF(0x12d1, 0x14ac, 1)},	/* Huawei E1820 */
 804	{QMI_FIXED_INTF(0x16d8, 0x6003, 0)},	/* CMOTech 6003 */
 805	{QMI_FIXED_INTF(0x16d8, 0x6007, 0)},	/* CMOTech CHE-628S */
 806	{QMI_FIXED_INTF(0x16d8, 0x6008, 0)},	/* CMOTech CMU-301 */
 807	{QMI_FIXED_INTF(0x16d8, 0x6280, 0)},	/* CMOTech CHU-628 */
 808	{QMI_FIXED_INTF(0x16d8, 0x7001, 0)},	/* CMOTech CHU-720S */
 809	{QMI_FIXED_INTF(0x16d8, 0x7002, 0)},	/* CMOTech 7002 */
 810	{QMI_FIXED_INTF(0x16d8, 0x7003, 4)},	/* CMOTech CHU-629K */
 811	{QMI_FIXED_INTF(0x16d8, 0x7004, 3)},	/* CMOTech 7004 */
 812	{QMI_FIXED_INTF(0x16d8, 0x7006, 5)},	/* CMOTech CGU-629 */
 813	{QMI_FIXED_INTF(0x16d8, 0x700a, 4)},	/* CMOTech CHU-629S */
 814	{QMI_FIXED_INTF(0x16d8, 0x7211, 0)},	/* CMOTech CHU-720I */
 815	{QMI_FIXED_INTF(0x16d8, 0x7212, 0)},	/* CMOTech 7212 */
 816	{QMI_FIXED_INTF(0x16d8, 0x7213, 0)},	/* CMOTech 7213 */
 817	{QMI_FIXED_INTF(0x16d8, 0x7251, 1)},	/* CMOTech 7251 */
 818	{QMI_FIXED_INTF(0x16d8, 0x7252, 1)},	/* CMOTech 7252 */
 819	{QMI_FIXED_INTF(0x16d8, 0x7253, 1)},	/* CMOTech 7253 */
 820	{QMI_FIXED_INTF(0x19d2, 0x0002, 1)},
 821	{QMI_FIXED_INTF(0x19d2, 0x0012, 1)},
 822	{QMI_FIXED_INTF(0x19d2, 0x0017, 3)},
 823	{QMI_FIXED_INTF(0x19d2, 0x0019, 3)},	/* ONDA MT689DC */
 824	{QMI_FIXED_INTF(0x19d2, 0x0021, 4)},
 825	{QMI_FIXED_INTF(0x19d2, 0x0025, 1)},
 826	{QMI_FIXED_INTF(0x19d2, 0x0031, 4)},
 827	{QMI_FIXED_INTF(0x19d2, 0x0042, 4)},
 828	{QMI_FIXED_INTF(0x19d2, 0x0049, 5)},
 829	{QMI_FIXED_INTF(0x19d2, 0x0052, 4)},
 830	{QMI_FIXED_INTF(0x19d2, 0x0055, 1)},	/* ZTE (Vodafone) K3520-Z */
 831	{QMI_FIXED_INTF(0x19d2, 0x0058, 4)},
 832	{QMI_FIXED_INTF(0x19d2, 0x0063, 4)},	/* ZTE (Vodafone) K3565-Z */
 833	{QMI_FIXED_INTF(0x19d2, 0x0104, 4)},	/* ZTE (Vodafone) K4505-Z */
 834	{QMI_FIXED_INTF(0x19d2, 0x0113, 5)},
 835	{QMI_FIXED_INTF(0x19d2, 0x0118, 5)},
 836	{QMI_FIXED_INTF(0x19d2, 0x0121, 5)},
 837	{QMI_FIXED_INTF(0x19d2, 0x0123, 4)},
 838	{QMI_FIXED_INTF(0x19d2, 0x0124, 5)},
 839	{QMI_FIXED_INTF(0x19d2, 0x0125, 6)},
 840	{QMI_FIXED_INTF(0x19d2, 0x0126, 5)},
 841	{QMI_FIXED_INTF(0x19d2, 0x0130, 1)},
 842	{QMI_FIXED_INTF(0x19d2, 0x0133, 3)},
 843	{QMI_FIXED_INTF(0x19d2, 0x0141, 5)},
 844	{QMI_FIXED_INTF(0x19d2, 0x0157, 5)},	/* ZTE MF683 */
 845	{QMI_FIXED_INTF(0x19d2, 0x0158, 3)},
 846	{QMI_FIXED_INTF(0x19d2, 0x0167, 4)},	/* ZTE MF820D */
 847	{QMI_FIXED_INTF(0x19d2, 0x0168, 4)},
 848	{QMI_FIXED_INTF(0x19d2, 0x0176, 3)},
 849	{QMI_FIXED_INTF(0x19d2, 0x0178, 3)},
 850	{QMI_FIXED_INTF(0x19d2, 0x0191, 4)},	/* ZTE EuFi890 */
 851	{QMI_FIXED_INTF(0x19d2, 0x0199, 1)},	/* ZTE MF820S */
 852	{QMI_FIXED_INTF(0x19d2, 0x0200, 1)},
 853	{QMI_FIXED_INTF(0x19d2, 0x0257, 3)},	/* ZTE MF821 */
 854	{QMI_FIXED_INTF(0x19d2, 0x0265, 4)},	/* ONDA MT8205 4G LTE */
 855	{QMI_FIXED_INTF(0x19d2, 0x0284, 4)},	/* ZTE MF880 */
 856	{QMI_FIXED_INTF(0x19d2, 0x0326, 4)},	/* ZTE MF821D */
 857	{QMI_FIXED_INTF(0x19d2, 0x0412, 4)},	/* Telewell TW-LTE 4G */
 858	{QMI_FIXED_INTF(0x19d2, 0x1008, 4)},	/* ZTE (Vodafone) K3570-Z */
 859	{QMI_FIXED_INTF(0x19d2, 0x1010, 4)},	/* ZTE (Vodafone) K3571-Z */
 860	{QMI_FIXED_INTF(0x19d2, 0x1012, 4)},
 861	{QMI_FIXED_INTF(0x19d2, 0x1018, 3)},	/* ZTE (Vodafone) K5006-Z */
 862	{QMI_FIXED_INTF(0x19d2, 0x1021, 2)},
 863	{QMI_FIXED_INTF(0x19d2, 0x1245, 4)},
 864	{QMI_FIXED_INTF(0x19d2, 0x1247, 4)},
 865	{QMI_FIXED_INTF(0x19d2, 0x1252, 4)},
 866	{QMI_FIXED_INTF(0x19d2, 0x1254, 4)},
 867	{QMI_FIXED_INTF(0x19d2, 0x1255, 3)},
 868	{QMI_FIXED_INTF(0x19d2, 0x1255, 4)},
 869	{QMI_FIXED_INTF(0x19d2, 0x1256, 4)},
 870	{QMI_FIXED_INTF(0x19d2, 0x1270, 5)},	/* ZTE MF667 */
 871	{QMI_FIXED_INTF(0x19d2, 0x1401, 2)},
 872	{QMI_FIXED_INTF(0x19d2, 0x1402, 2)},	/* ZTE MF60 */
 873	{QMI_FIXED_INTF(0x19d2, 0x1424, 2)},
 874	{QMI_FIXED_INTF(0x19d2, 0x1425, 2)},
 875	{QMI_FIXED_INTF(0x19d2, 0x1426, 2)},	/* ZTE MF91 */
 876	{QMI_FIXED_INTF(0x19d2, 0x1428, 2)},	/* Telewell TW-LTE 4G v2 */
 877	{QMI_FIXED_INTF(0x19d2, 0x2002, 4)},	/* ZTE (Vodafone) K3765-Z */
 878	{QMI_FIXED_INTF(0x2001, 0x7e19, 4)},	/* D-Link DWM-221 B1 */
 879	{QMI_FIXED_INTF(0x0f3d, 0x68a2, 8)},    /* Sierra Wireless MC7700 */
 880	{QMI_FIXED_INTF(0x114f, 0x68a2, 8)},    /* Sierra Wireless MC7750 */
 881	{QMI_FIXED_INTF(0x1199, 0x68a2, 8)},	/* Sierra Wireless MC7710 in QMI mode */
 882	{QMI_FIXED_INTF(0x1199, 0x68a2, 19)},	/* Sierra Wireless MC7710 in QMI mode */
 883	{QMI_FIXED_INTF(0x1199, 0x68c0, 8)},	/* Sierra Wireless MC7304/MC7354 */
 884	{QMI_FIXED_INTF(0x1199, 0x68c0, 10)},	/* Sierra Wireless MC7304/MC7354 */
 885	{QMI_FIXED_INTF(0x1199, 0x901c, 8)},    /* Sierra Wireless EM7700 */
 886	{QMI_FIXED_INTF(0x1199, 0x901f, 8)},    /* Sierra Wireless EM7355 */
 887	{QMI_FIXED_INTF(0x1199, 0x9041, 8)},	/* Sierra Wireless MC7305/MC7355 */
 888	{QMI_FIXED_INTF(0x1199, 0x9041, 10)},	/* Sierra Wireless MC7305/MC7355 */
 889	{QMI_FIXED_INTF(0x1199, 0x9051, 8)},	/* Netgear AirCard 340U */
 890	{QMI_FIXED_INTF(0x1199, 0x9053, 8)},	/* Sierra Wireless Modem */
 891	{QMI_FIXED_INTF(0x1199, 0x9054, 8)},	/* Sierra Wireless Modem */
 892	{QMI_FIXED_INTF(0x1199, 0x9055, 8)},	/* Netgear AirCard 341U */
 893	{QMI_FIXED_INTF(0x1199, 0x9056, 8)},	/* Sierra Wireless Modem */
 894	{QMI_FIXED_INTF(0x1199, 0x9057, 8)},
 895	{QMI_FIXED_INTF(0x1199, 0x9061, 8)},	/* Sierra Wireless Modem */
 896	{QMI_FIXED_INTF(0x1199, 0x9071, 8)},	/* Sierra Wireless MC74xx */
 897	{QMI_FIXED_INTF(0x1199, 0x9071, 10)},	/* Sierra Wireless MC74xx */
 898	{QMI_FIXED_INTF(0x1199, 0x9079, 8)},	/* Sierra Wireless EM74xx */
 899	{QMI_FIXED_INTF(0x1199, 0x9079, 10)},	/* Sierra Wireless EM74xx */
 900	{QMI_FIXED_INTF(0x1bbb, 0x011e, 4)},	/* Telekom Speedstick LTE II (Alcatel One Touch L100V LTE) */
 901	{QMI_FIXED_INTF(0x1bbb, 0x0203, 2)},	/* Alcatel L800MA */
 902	{QMI_FIXED_INTF(0x2357, 0x0201, 4)},	/* TP-LINK HSUPA Modem MA180 */
 903	{QMI_FIXED_INTF(0x2357, 0x9000, 4)},	/* TP-LINK MA260 */
 904	{QMI_QUIRK_SET_DTR(0x1bc7, 0x1040, 2)},	/* Telit LE922A */
 905	{QMI_FIXED_INTF(0x1bc7, 0x1200, 5)},	/* Telit LE920 */
 906	{QMI_FIXED_INTF(0x1bc7, 0x1201, 2)},	/* Telit LE920 */
 907	{QMI_FIXED_INTF(0x1c9e, 0x9b01, 3)},	/* XS Stick W100-2 from 4G Systems */
 908	{QMI_FIXED_INTF(0x0b3c, 0xc000, 4)},	/* Olivetti Olicard 100 */
 909	{QMI_FIXED_INTF(0x0b3c, 0xc001, 4)},	/* Olivetti Olicard 120 */
 910	{QMI_FIXED_INTF(0x0b3c, 0xc002, 4)},	/* Olivetti Olicard 140 */
 911	{QMI_FIXED_INTF(0x0b3c, 0xc004, 6)},	/* Olivetti Olicard 155 */
 912	{QMI_FIXED_INTF(0x0b3c, 0xc005, 6)},	/* Olivetti Olicard 200 */
 913	{QMI_FIXED_INTF(0x0b3c, 0xc00a, 6)},	/* Olivetti Olicard 160 */
 914	{QMI_FIXED_INTF(0x0b3c, 0xc00b, 4)},	/* Olivetti Olicard 500 */
 915	{QMI_FIXED_INTF(0x1e2d, 0x0060, 4)},	/* Cinterion PLxx */
 916	{QMI_FIXED_INTF(0x1e2d, 0x0053, 4)},	/* Cinterion PHxx,PXxx */
 917	{QMI_FIXED_INTF(0x1e2d, 0x0082, 4)},	/* Cinterion PHxx,PXxx (2 RmNet) */
 918	{QMI_FIXED_INTF(0x1e2d, 0x0082, 5)},	/* Cinterion PHxx,PXxx (2 RmNet) */
 919	{QMI_FIXED_INTF(0x1e2d, 0x0083, 4)},	/* Cinterion PHxx,PXxx (1 RmNet + USB Audio)*/
 920	{QMI_FIXED_INTF(0x413c, 0x81a2, 8)},	/* Dell Wireless 5806 Gobi(TM) 4G LTE Mobile Broadband Card */
 921	{QMI_FIXED_INTF(0x413c, 0x81a3, 8)},	/* Dell Wireless 5570 HSPA+ (42Mbps) Mobile Broadband Card */
 922	{QMI_FIXED_INTF(0x413c, 0x81a4, 8)},	/* Dell Wireless 5570e HSPA+ (42Mbps) Mobile Broadband Card */
 923	{QMI_FIXED_INTF(0x413c, 0x81a8, 8)},	/* Dell Wireless 5808 Gobi(TM) 4G LTE Mobile Broadband Card */
 924	{QMI_FIXED_INTF(0x413c, 0x81a9, 8)},	/* Dell Wireless 5808e Gobi(TM) 4G LTE Mobile Broadband Card */
 925	{QMI_FIXED_INTF(0x413c, 0x81b1, 8)},	/* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card */
 926	{QMI_FIXED_INTF(0x413c, 0x81b3, 8)},	/* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card (rev3) */
 927	{QMI_FIXED_INTF(0x413c, 0x81b6, 8)},	/* Dell Wireless 5811e */
 928	{QMI_FIXED_INTF(0x413c, 0x81b6, 10)},	/* Dell Wireless 5811e */
 929	{QMI_FIXED_INTF(0x03f0, 0x4e1d, 8)},	/* HP lt4111 LTE/EV-DO/HSPA+ Gobi 4G Module */
 930	{QMI_FIXED_INTF(0x22de, 0x9061, 3)},	/* WeTelecom WPD-600N */
 931	{QMI_FIXED_INTF(0x1e0e, 0x9001, 5)},	/* SIMCom 7230E */
 932	{QMI_QUIRK_SET_DTR(0x2c7c, 0x0125, 4)},	/* Quectel EC25, EC20 R2.0  Mini PCIe */
 933	{QMI_QUIRK_SET_DTR(0x2c7c, 0x0121, 4)},	/* Quectel EC21 Mini PCIe */
 934
 935	/* 4. Gobi 1000 devices */
 936	{QMI_GOBI1K_DEVICE(0x05c6, 0x9212)},	/* Acer Gobi Modem Device */
 937	{QMI_GOBI1K_DEVICE(0x03f0, 0x1f1d)},	/* HP un2400 Gobi Modem Device */
 938	{QMI_GOBI1K_DEVICE(0x04da, 0x250d)},	/* Panasonic Gobi Modem device */
 939	{QMI_GOBI1K_DEVICE(0x413c, 0x8172)},	/* Dell Gobi Modem device */
 940	{QMI_GOBI1K_DEVICE(0x1410, 0xa001)},	/* Novatel/Verizon USB-1000 */
 941	{QMI_GOBI1K_DEVICE(0x1410, 0xa002)},	/* Novatel Gobi Modem device */
 942	{QMI_GOBI1K_DEVICE(0x1410, 0xa003)},	/* Novatel Gobi Modem device */
 943	{QMI_GOBI1K_DEVICE(0x1410, 0xa004)},	/* Novatel Gobi Modem device */
 944	{QMI_GOBI1K_DEVICE(0x1410, 0xa005)},	/* Novatel Gobi Modem device */
 945	{QMI_GOBI1K_DEVICE(0x1410, 0xa006)},	/* Novatel Gobi Modem device */
 946	{QMI_GOBI1K_DEVICE(0x1410, 0xa007)},	/* Novatel Gobi Modem device */
 947	{QMI_GOBI1K_DEVICE(0x0b05, 0x1776)},	/* Asus Gobi Modem device */
 948	{QMI_GOBI1K_DEVICE(0x19d2, 0xfff3)},	/* ONDA Gobi Modem device */
 949	{QMI_GOBI1K_DEVICE(0x05c6, 0x9001)},	/* Generic Gobi Modem device */
 950	{QMI_GOBI1K_DEVICE(0x05c6, 0x9002)},	/* Generic Gobi Modem device */
 951	{QMI_GOBI1K_DEVICE(0x05c6, 0x9202)},	/* Generic Gobi Modem device */
 952	{QMI_GOBI1K_DEVICE(0x05c6, 0x9203)},	/* Generic Gobi Modem device */
 953	{QMI_GOBI1K_DEVICE(0x05c6, 0x9222)},	/* Generic Gobi Modem device */
 954	{QMI_GOBI1K_DEVICE(0x05c6, 0x9009)},	/* Generic Gobi Modem device */
 955
 956	/* 5. Gobi 2000 and 3000 devices */
 957	{QMI_GOBI_DEVICE(0x413c, 0x8186)},	/* Dell Gobi 2000 Modem device (N0218, VU936) */
 958	{QMI_GOBI_DEVICE(0x413c, 0x8194)},	/* Dell Gobi 3000 Composite */
 959	{QMI_GOBI_DEVICE(0x05c6, 0x920b)},	/* Generic Gobi 2000 Modem device */
 960	{QMI_GOBI_DEVICE(0x05c6, 0x9225)},	/* Sony Gobi 2000 Modem device (N0279, VU730) */
 961	{QMI_GOBI_DEVICE(0x05c6, 0x9245)},	/* Samsung Gobi 2000 Modem device (VL176) */
 962	{QMI_GOBI_DEVICE(0x03f0, 0x251d)},	/* HP Gobi 2000 Modem device (VP412) */
 963	{QMI_GOBI_DEVICE(0x05c6, 0x9215)},	/* Acer Gobi 2000 Modem device (VP413) */
 964	{QMI_FIXED_INTF(0x05c6, 0x9215, 4)},	/* Quectel EC20 Mini PCIe */
 965	{QMI_GOBI_DEVICE(0x05c6, 0x9265)},	/* Asus Gobi 2000 Modem device (VR305) */
 966	{QMI_GOBI_DEVICE(0x05c6, 0x9235)},	/* Top Global Gobi 2000 Modem device (VR306) */
 967	{QMI_GOBI_DEVICE(0x05c6, 0x9275)},	/* iRex Technologies Gobi 2000 Modem device (VR307) */
 968	{QMI_GOBI_DEVICE(0x0af0, 0x8120)},	/* Option GTM681W */
 969	{QMI_GOBI_DEVICE(0x1199, 0x68a5)},	/* Sierra Wireless Modem */
 970	{QMI_GOBI_DEVICE(0x1199, 0x68a9)},	/* Sierra Wireless Modem */
 971	{QMI_GOBI_DEVICE(0x1199, 0x9001)},	/* Sierra Wireless Gobi 2000 Modem device (VT773) */
 972	{QMI_GOBI_DEVICE(0x1199, 0x9002)},	/* Sierra Wireless Gobi 2000 Modem device (VT773) */
 973	{QMI_GOBI_DEVICE(0x1199, 0x9003)},	/* Sierra Wireless Gobi 2000 Modem device (VT773) */
 974	{QMI_GOBI_DEVICE(0x1199, 0x9004)},	/* Sierra Wireless Gobi 2000 Modem device (VT773) */
 975	{QMI_GOBI_DEVICE(0x1199, 0x9005)},	/* Sierra Wireless Gobi 2000 Modem device (VT773) */
 976	{QMI_GOBI_DEVICE(0x1199, 0x9006)},	/* Sierra Wireless Gobi 2000 Modem device (VT773) */
 977	{QMI_GOBI_DEVICE(0x1199, 0x9007)},	/* Sierra Wireless Gobi 2000 Modem device (VT773) */
 978	{QMI_GOBI_DEVICE(0x1199, 0x9008)},	/* Sierra Wireless Gobi 2000 Modem device (VT773) */
 979	{QMI_GOBI_DEVICE(0x1199, 0x9009)},	/* Sierra Wireless Gobi 2000 Modem device (VT773) */
 980	{QMI_GOBI_DEVICE(0x1199, 0x900a)},	/* Sierra Wireless Gobi 2000 Modem device (VT773) */
 981	{QMI_GOBI_DEVICE(0x1199, 0x9011)},	/* Sierra Wireless Gobi 2000 Modem device (MC8305) */
 982	{QMI_GOBI_DEVICE(0x16d8, 0x8002)},	/* CMDTech Gobi 2000 Modem device (VU922) */
 983	{QMI_GOBI_DEVICE(0x05c6, 0x9205)},	/* Gobi 2000 Modem device */
 984	{QMI_GOBI_DEVICE(0x1199, 0x9013)},	/* Sierra Wireless Gobi 3000 Modem device (MC8355) */
 985	{QMI_GOBI_DEVICE(0x03f0, 0x371d)},	/* HP un2430 Mobile Broadband Module */
 986	{QMI_GOBI_DEVICE(0x1199, 0x9015)},	/* Sierra Wireless Gobi 3000 Modem device */
 987	{QMI_GOBI_DEVICE(0x1199, 0x9019)},	/* Sierra Wireless Gobi 3000 Modem device */
 988	{QMI_GOBI_DEVICE(0x1199, 0x901b)},	/* Sierra Wireless MC7770 */
 989	{QMI_GOBI_DEVICE(0x12d1, 0x14f1)},	/* Sony Gobi 3000 Composite */
 990	{QMI_GOBI_DEVICE(0x1410, 0xa021)},	/* Foxconn Gobi 3000 Modem device (Novatel E396) */
 991
 992	{ }					/* END */
 993};
 994MODULE_DEVICE_TABLE(usb, products);
 995
 996static bool quectel_ec20_detected(struct usb_interface *intf)
 997{
 998	struct usb_device *dev = interface_to_usbdev(intf);
 999
1000	if (dev->actconfig &&
1001	    le16_to_cpu(dev->descriptor.idVendor) == 0x05c6 &&
1002	    le16_to_cpu(dev->descriptor.idProduct) == 0x9215 &&
1003	    dev->actconfig->desc.bNumInterfaces == 5)
1004		return true;
1005
1006	return false;
1007}
1008
1009static int qmi_wwan_probe(struct usb_interface *intf,
1010			  const struct usb_device_id *prod)
1011{
1012	struct usb_device_id *id = (struct usb_device_id *)prod;
1013	struct usb_interface_descriptor *desc = &intf->cur_altsetting->desc;
1014
1015	/* Workaround to enable dynamic IDs.  This disables usbnet
1016	 * blacklisting functionality.  Which, if required, can be
1017	 * reimplemented here by using a magic "blacklist" value
1018	 * instead of 0 in the static device id table
1019	 */
1020	if (!id->driver_info) {
1021		dev_dbg(&intf->dev, "setting defaults for dynamic device id\n");
1022		id->driver_info = (unsigned long)&qmi_wwan_info;
1023	}
1024
1025	/* Quectel EC20 quirk where we've QMI on interface 4 instead of 0 */
1026	if (quectel_ec20_detected(intf) && desc->bInterfaceNumber == 0) {
1027		dev_dbg(&intf->dev, "Quectel EC20 quirk, skipping interface 0\n");
1028		return -ENODEV;
1029	}
1030
1031	return usbnet_probe(intf, id);
1032}
1033
1034static struct usb_driver qmi_wwan_driver = {
1035	.name		      = "qmi_wwan",
1036	.id_table	      = products,
1037	.probe		      = qmi_wwan_probe,
1038	.disconnect	      = usbnet_disconnect,
1039	.suspend	      = qmi_wwan_suspend,
1040	.resume		      =	qmi_wwan_resume,
1041	.reset_resume         = qmi_wwan_resume,
1042	.supports_autosuspend = 1,
1043	.disable_hub_initiated_lpm = 1,
1044};
1045
1046module_usb_driver(qmi_wwan_driver);
1047
1048MODULE_AUTHOR("Bjørn Mork <bjorn@mork.no>");
1049MODULE_DESCRIPTION("Qualcomm MSM Interface (QMI) WWAN driver");
1050MODULE_LICENSE("GPL");