qmi_wwan.c 55 KB

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