qmi_wwan.c 48 KB

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