qmi_wwan.c 47 KB

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