main.c 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279
  1. /*
  2. * This file contains the major functions in WLAN
  3. * driver. It includes init, exit, open, close and main
  4. * thread etc..
  5. */
  6. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  7. #include <linux/moduleparam.h>
  8. #include <linux/delay.h>
  9. #include <linux/etherdevice.h>
  10. #include <linux/hardirq.h>
  11. #include <linux/netdevice.h>
  12. #include <linux/if_arp.h>
  13. #include <linux/kthread.h>
  14. #include <linux/kfifo.h>
  15. #include <linux/slab.h>
  16. #include <net/cfg80211.h>
  17. #include "host.h"
  18. #include "decl.h"
  19. #include "dev.h"
  20. #include "cfg.h"
  21. #include "debugfs.h"
  22. #include "cmd.h"
  23. #include "mesh.h"
  24. #define DRIVER_RELEASE_VERSION "323.p0"
  25. const char lbs_driver_version[] = "COMM-USB8388-" DRIVER_RELEASE_VERSION
  26. #ifdef DEBUG
  27. "-dbg"
  28. #endif
  29. "";
  30. /* Module parameters */
  31. unsigned int lbs_debug;
  32. EXPORT_SYMBOL_GPL(lbs_debug);
  33. module_param_named(libertas_debug, lbs_debug, int, 0644);
  34. unsigned int lbs_disablemesh;
  35. EXPORT_SYMBOL_GPL(lbs_disablemesh);
  36. module_param_named(libertas_disablemesh, lbs_disablemesh, int, 0644);
  37. /*
  38. * This global structure is used to send the confirm_sleep command as
  39. * fast as possible down to the firmware.
  40. */
  41. struct cmd_confirm_sleep confirm_sleep;
  42. /*
  43. * the table to keep region code
  44. */
  45. u16 lbs_region_code_to_index[MRVDRV_MAX_REGION_CODE] =
  46. { 0x10, 0x20, 0x30, 0x31, 0x32, 0x40 };
  47. /*
  48. * FW rate table. FW refers to rates by their index in this table, not by the
  49. * rate value itself. Values of 0x00 are
  50. * reserved positions.
  51. */
  52. static u8 fw_data_rates[MAX_RATES] =
  53. { 0x02, 0x04, 0x0B, 0x16, 0x00, 0x0C, 0x12,
  54. 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x00
  55. };
  56. /**
  57. * lbs_fw_index_to_data_rate - use index to get the data rate
  58. *
  59. * @idx: The index of data rate
  60. * returns: data rate or 0
  61. */
  62. u32 lbs_fw_index_to_data_rate(u8 idx)
  63. {
  64. if (idx >= sizeof(fw_data_rates))
  65. idx = 0;
  66. return fw_data_rates[idx];
  67. }
  68. /**
  69. * lbs_data_rate_to_fw_index - use rate to get the index
  70. *
  71. * @rate: data rate
  72. * returns: index or 0
  73. */
  74. u8 lbs_data_rate_to_fw_index(u32 rate)
  75. {
  76. u8 i;
  77. if (!rate)
  78. return 0;
  79. for (i = 0; i < sizeof(fw_data_rates); i++) {
  80. if (rate == fw_data_rates[i])
  81. return i;
  82. }
  83. return 0;
  84. }
  85. int lbs_start_iface(struct lbs_private *priv)
  86. {
  87. struct cmd_ds_802_11_mac_address cmd;
  88. int ret;
  89. if (priv->power_restore) {
  90. ret = priv->power_restore(priv);
  91. if (ret)
  92. return ret;
  93. }
  94. cmd.hdr.size = cpu_to_le16(sizeof(cmd));
  95. cmd.action = cpu_to_le16(CMD_ACT_SET);
  96. memcpy(cmd.macadd, priv->current_addr, ETH_ALEN);
  97. ret = lbs_cmd_with_response(priv, CMD_802_11_MAC_ADDRESS, &cmd);
  98. if (ret) {
  99. lbs_deb_net("set MAC address failed\n");
  100. goto err;
  101. }
  102. lbs_update_channel(priv);
  103. priv->iface_running = true;
  104. return 0;
  105. err:
  106. if (priv->power_save)
  107. priv->power_save(priv);
  108. return ret;
  109. }
  110. /**
  111. * lbs_dev_open - open the ethX interface
  112. *
  113. * @dev: A pointer to &net_device structure
  114. * returns: 0 or -EBUSY if monitor mode active
  115. */
  116. static int lbs_dev_open(struct net_device *dev)
  117. {
  118. struct lbs_private *priv = dev->ml_priv;
  119. int ret = 0;
  120. lbs_deb_enter(LBS_DEB_NET);
  121. if (!priv->iface_running) {
  122. ret = lbs_start_iface(priv);
  123. if (ret)
  124. goto out;
  125. }
  126. spin_lock_irq(&priv->driver_lock);
  127. netif_carrier_off(dev);
  128. if (!priv->tx_pending_len)
  129. netif_wake_queue(dev);
  130. spin_unlock_irq(&priv->driver_lock);
  131. out:
  132. lbs_deb_leave_args(LBS_DEB_NET, "ret %d", ret);
  133. return ret;
  134. }
  135. static bool lbs_command_queue_empty(struct lbs_private *priv)
  136. {
  137. unsigned long flags;
  138. bool ret;
  139. spin_lock_irqsave(&priv->driver_lock, flags);
  140. ret = priv->cur_cmd == NULL && list_empty(&priv->cmdpendingq);
  141. spin_unlock_irqrestore(&priv->driver_lock, flags);
  142. return ret;
  143. }
  144. int lbs_stop_iface(struct lbs_private *priv)
  145. {
  146. unsigned long flags;
  147. int ret = 0;
  148. lbs_deb_enter(LBS_DEB_MAIN);
  149. spin_lock_irqsave(&priv->driver_lock, flags);
  150. priv->iface_running = false;
  151. kfree_skb(priv->currenttxskb);
  152. priv->currenttxskb = NULL;
  153. priv->tx_pending_len = 0;
  154. spin_unlock_irqrestore(&priv->driver_lock, flags);
  155. cancel_work_sync(&priv->mcast_work);
  156. del_timer_sync(&priv->tx_lockup_timer);
  157. /* Disable command processing, and wait for all commands to complete */
  158. lbs_deb_main("waiting for commands to complete\n");
  159. wait_event(priv->waitq, lbs_command_queue_empty(priv));
  160. lbs_deb_main("all commands completed\n");
  161. if (priv->power_save)
  162. ret = priv->power_save(priv);
  163. lbs_deb_leave(LBS_DEB_MAIN);
  164. return ret;
  165. }
  166. /**
  167. * lbs_eth_stop - close the ethX interface
  168. *
  169. * @dev: A pointer to &net_device structure
  170. * returns: 0
  171. */
  172. static int lbs_eth_stop(struct net_device *dev)
  173. {
  174. struct lbs_private *priv = dev->ml_priv;
  175. lbs_deb_enter(LBS_DEB_NET);
  176. if (priv->connect_status == LBS_CONNECTED)
  177. lbs_disconnect(priv, WLAN_REASON_DEAUTH_LEAVING);
  178. spin_lock_irq(&priv->driver_lock);
  179. netif_stop_queue(dev);
  180. spin_unlock_irq(&priv->driver_lock);
  181. lbs_update_mcast(priv);
  182. cancel_delayed_work_sync(&priv->scan_work);
  183. if (priv->scan_req) {
  184. cfg80211_scan_done(priv->scan_req, false);
  185. priv->scan_req = NULL;
  186. }
  187. netif_carrier_off(priv->dev);
  188. if (!lbs_iface_active(priv))
  189. lbs_stop_iface(priv);
  190. lbs_deb_leave(LBS_DEB_NET);
  191. return 0;
  192. }
  193. void lbs_host_to_card_done(struct lbs_private *priv)
  194. {
  195. unsigned long flags;
  196. lbs_deb_enter(LBS_DEB_THREAD);
  197. spin_lock_irqsave(&priv->driver_lock, flags);
  198. del_timer(&priv->tx_lockup_timer);
  199. priv->dnld_sent = DNLD_RES_RECEIVED;
  200. /* Wake main thread if commands are pending */
  201. if (!priv->cur_cmd || priv->tx_pending_len > 0) {
  202. if (!priv->wakeup_dev_required)
  203. wake_up(&priv->waitq);
  204. }
  205. spin_unlock_irqrestore(&priv->driver_lock, flags);
  206. lbs_deb_leave(LBS_DEB_THREAD);
  207. }
  208. EXPORT_SYMBOL_GPL(lbs_host_to_card_done);
  209. int lbs_set_mac_address(struct net_device *dev, void *addr)
  210. {
  211. int ret = 0;
  212. struct lbs_private *priv = dev->ml_priv;
  213. struct sockaddr *phwaddr = addr;
  214. lbs_deb_enter(LBS_DEB_NET);
  215. /*
  216. * Can only set MAC address when all interfaces are down, to be written
  217. * to the hardware when one of them is brought up.
  218. */
  219. if (lbs_iface_active(priv))
  220. return -EBUSY;
  221. /* In case it was called from the mesh device */
  222. dev = priv->dev;
  223. memcpy(priv->current_addr, phwaddr->sa_data, ETH_ALEN);
  224. memcpy(dev->dev_addr, phwaddr->sa_data, ETH_ALEN);
  225. if (priv->mesh_dev)
  226. memcpy(priv->mesh_dev->dev_addr, phwaddr->sa_data, ETH_ALEN);
  227. lbs_deb_leave_args(LBS_DEB_NET, "ret %d", ret);
  228. return ret;
  229. }
  230. static inline int mac_in_list(unsigned char *list, int list_len,
  231. unsigned char *mac)
  232. {
  233. while (list_len) {
  234. if (!memcmp(list, mac, ETH_ALEN))
  235. return 1;
  236. list += ETH_ALEN;
  237. list_len--;
  238. }
  239. return 0;
  240. }
  241. static int lbs_add_mcast_addrs(struct cmd_ds_mac_multicast_adr *cmd,
  242. struct net_device *dev, int nr_addrs)
  243. {
  244. int i = nr_addrs;
  245. struct netdev_hw_addr *ha;
  246. int cnt;
  247. if ((dev->flags & (IFF_UP|IFF_MULTICAST)) != (IFF_UP|IFF_MULTICAST))
  248. return nr_addrs;
  249. netif_addr_lock_bh(dev);
  250. cnt = netdev_mc_count(dev);
  251. netdev_for_each_mc_addr(ha, dev) {
  252. if (mac_in_list(cmd->maclist, nr_addrs, ha->addr)) {
  253. lbs_deb_net("mcast address %s:%pM skipped\n", dev->name,
  254. ha->addr);
  255. cnt--;
  256. continue;
  257. }
  258. if (i == MRVDRV_MAX_MULTICAST_LIST_SIZE)
  259. break;
  260. memcpy(&cmd->maclist[6*i], ha->addr, ETH_ALEN);
  261. lbs_deb_net("mcast address %s:%pM added to filter\n", dev->name,
  262. ha->addr);
  263. i++;
  264. cnt--;
  265. }
  266. netif_addr_unlock_bh(dev);
  267. if (cnt)
  268. return -EOVERFLOW;
  269. return i;
  270. }
  271. void lbs_update_mcast(struct lbs_private *priv)
  272. {
  273. struct cmd_ds_mac_multicast_adr mcast_cmd;
  274. int dev_flags = 0;
  275. int nr_addrs;
  276. int old_mac_control = priv->mac_control;
  277. lbs_deb_enter(LBS_DEB_NET);
  278. if (netif_running(priv->dev))
  279. dev_flags |= priv->dev->flags;
  280. if (priv->mesh_dev && netif_running(priv->mesh_dev))
  281. dev_flags |= priv->mesh_dev->flags;
  282. if (dev_flags & IFF_PROMISC) {
  283. priv->mac_control |= CMD_ACT_MAC_PROMISCUOUS_ENABLE;
  284. priv->mac_control &= ~(CMD_ACT_MAC_ALL_MULTICAST_ENABLE |
  285. CMD_ACT_MAC_MULTICAST_ENABLE);
  286. goto out_set_mac_control;
  287. } else if (dev_flags & IFF_ALLMULTI) {
  288. do_allmulti:
  289. priv->mac_control |= CMD_ACT_MAC_ALL_MULTICAST_ENABLE;
  290. priv->mac_control &= ~(CMD_ACT_MAC_PROMISCUOUS_ENABLE |
  291. CMD_ACT_MAC_MULTICAST_ENABLE);
  292. goto out_set_mac_control;
  293. }
  294. /* Once for priv->dev, again for priv->mesh_dev if it exists */
  295. nr_addrs = lbs_add_mcast_addrs(&mcast_cmd, priv->dev, 0);
  296. if (nr_addrs >= 0 && priv->mesh_dev)
  297. nr_addrs = lbs_add_mcast_addrs(&mcast_cmd, priv->mesh_dev, nr_addrs);
  298. if (nr_addrs < 0)
  299. goto do_allmulti;
  300. if (nr_addrs) {
  301. int size = offsetof(struct cmd_ds_mac_multicast_adr,
  302. maclist[6*nr_addrs]);
  303. mcast_cmd.action = cpu_to_le16(CMD_ACT_SET);
  304. mcast_cmd.hdr.size = cpu_to_le16(size);
  305. mcast_cmd.nr_of_adrs = cpu_to_le16(nr_addrs);
  306. lbs_cmd_async(priv, CMD_MAC_MULTICAST_ADR, &mcast_cmd.hdr, size);
  307. priv->mac_control |= CMD_ACT_MAC_MULTICAST_ENABLE;
  308. } else
  309. priv->mac_control &= ~CMD_ACT_MAC_MULTICAST_ENABLE;
  310. priv->mac_control &= ~(CMD_ACT_MAC_PROMISCUOUS_ENABLE |
  311. CMD_ACT_MAC_ALL_MULTICAST_ENABLE);
  312. out_set_mac_control:
  313. if (priv->mac_control != old_mac_control)
  314. lbs_set_mac_control(priv);
  315. lbs_deb_leave(LBS_DEB_NET);
  316. }
  317. static void lbs_set_mcast_worker(struct work_struct *work)
  318. {
  319. struct lbs_private *priv = container_of(work, struct lbs_private, mcast_work);
  320. lbs_update_mcast(priv);
  321. }
  322. void lbs_set_multicast_list(struct net_device *dev)
  323. {
  324. struct lbs_private *priv = dev->ml_priv;
  325. schedule_work(&priv->mcast_work);
  326. }
  327. /**
  328. * lbs_thread - handles the major jobs in the LBS driver.
  329. * It handles all events generated by firmware, RX data received
  330. * from firmware and TX data sent from kernel.
  331. *
  332. * @data: A pointer to &lbs_thread structure
  333. * returns: 0
  334. */
  335. static int lbs_thread(void *data)
  336. {
  337. struct net_device *dev = data;
  338. struct lbs_private *priv = dev->ml_priv;
  339. wait_queue_t wait;
  340. lbs_deb_enter(LBS_DEB_THREAD);
  341. init_waitqueue_entry(&wait, current);
  342. for (;;) {
  343. int shouldsleep;
  344. u8 resp_idx;
  345. lbs_deb_thread("1: currenttxskb %p, dnld_sent %d\n",
  346. priv->currenttxskb, priv->dnld_sent);
  347. add_wait_queue(&priv->waitq, &wait);
  348. set_current_state(TASK_INTERRUPTIBLE);
  349. spin_lock_irq(&priv->driver_lock);
  350. if (kthread_should_stop())
  351. shouldsleep = 0; /* Bye */
  352. else if (priv->surpriseremoved)
  353. shouldsleep = 1; /* We need to wait until we're _told_ to die */
  354. else if (priv->psstate == PS_STATE_SLEEP)
  355. shouldsleep = 1; /* Sleep mode. Nothing we can do till it wakes */
  356. else if (priv->cmd_timed_out)
  357. shouldsleep = 0; /* Command timed out. Recover */
  358. else if (!priv->fw_ready)
  359. shouldsleep = 1; /* Firmware not ready. We're waiting for it */
  360. else if (priv->dnld_sent)
  361. shouldsleep = 1; /* Something is en route to the device already */
  362. else if (priv->tx_pending_len > 0)
  363. shouldsleep = 0; /* We've a packet to send */
  364. else if (priv->resp_len[priv->resp_idx])
  365. shouldsleep = 0; /* We have a command response */
  366. else if (priv->cur_cmd)
  367. shouldsleep = 1; /* Can't send a command; one already running */
  368. else if (!list_empty(&priv->cmdpendingq) &&
  369. !(priv->wakeup_dev_required))
  370. shouldsleep = 0; /* We have a command to send */
  371. else if (kfifo_len(&priv->event_fifo))
  372. shouldsleep = 0; /* We have an event to process */
  373. else
  374. shouldsleep = 1; /* No command */
  375. if (shouldsleep) {
  376. lbs_deb_thread("sleeping, connect_status %d, "
  377. "psmode %d, psstate %d\n",
  378. priv->connect_status,
  379. priv->psmode, priv->psstate);
  380. spin_unlock_irq(&priv->driver_lock);
  381. schedule();
  382. } else
  383. spin_unlock_irq(&priv->driver_lock);
  384. lbs_deb_thread("2: currenttxskb %p, dnld_send %d\n",
  385. priv->currenttxskb, priv->dnld_sent);
  386. set_current_state(TASK_RUNNING);
  387. remove_wait_queue(&priv->waitq, &wait);
  388. lbs_deb_thread("3: currenttxskb %p, dnld_sent %d\n",
  389. priv->currenttxskb, priv->dnld_sent);
  390. if (kthread_should_stop()) {
  391. lbs_deb_thread("break from main thread\n");
  392. break;
  393. }
  394. if (priv->surpriseremoved) {
  395. lbs_deb_thread("adapter removed; waiting to die...\n");
  396. continue;
  397. }
  398. lbs_deb_thread("4: currenttxskb %p, dnld_sent %d\n",
  399. priv->currenttxskb, priv->dnld_sent);
  400. /* Process any pending command response */
  401. spin_lock_irq(&priv->driver_lock);
  402. resp_idx = priv->resp_idx;
  403. if (priv->resp_len[resp_idx]) {
  404. spin_unlock_irq(&priv->driver_lock);
  405. lbs_process_command_response(priv,
  406. priv->resp_buf[resp_idx],
  407. priv->resp_len[resp_idx]);
  408. spin_lock_irq(&priv->driver_lock);
  409. priv->resp_len[resp_idx] = 0;
  410. }
  411. spin_unlock_irq(&priv->driver_lock);
  412. /* Process hardware events, e.g. card removed, link lost */
  413. spin_lock_irq(&priv->driver_lock);
  414. while (kfifo_len(&priv->event_fifo)) {
  415. u32 event;
  416. if (kfifo_out(&priv->event_fifo,
  417. (unsigned char *) &event, sizeof(event)) !=
  418. sizeof(event))
  419. break;
  420. spin_unlock_irq(&priv->driver_lock);
  421. lbs_process_event(priv, event);
  422. spin_lock_irq(&priv->driver_lock);
  423. }
  424. spin_unlock_irq(&priv->driver_lock);
  425. if (priv->wakeup_dev_required) {
  426. lbs_deb_thread("Waking up device...\n");
  427. /* Wake up device */
  428. if (priv->exit_deep_sleep(priv))
  429. lbs_deb_thread("Wakeup device failed\n");
  430. continue;
  431. }
  432. /* command timeout stuff */
  433. if (priv->cmd_timed_out && priv->cur_cmd) {
  434. struct cmd_ctrl_node *cmdnode = priv->cur_cmd;
  435. netdev_info(dev, "Timeout submitting command 0x%04x\n",
  436. le16_to_cpu(cmdnode->cmdbuf->command));
  437. lbs_complete_command(priv, cmdnode, -ETIMEDOUT);
  438. if (priv->reset_card)
  439. priv->reset_card(priv);
  440. }
  441. priv->cmd_timed_out = 0;
  442. if (!priv->fw_ready)
  443. continue;
  444. /* Check if we need to confirm Sleep Request received previously */
  445. if (priv->psstate == PS_STATE_PRE_SLEEP &&
  446. !priv->dnld_sent && !priv->cur_cmd) {
  447. if (priv->connect_status == LBS_CONNECTED) {
  448. lbs_deb_thread("pre-sleep, currenttxskb %p, "
  449. "dnld_sent %d, cur_cmd %p\n",
  450. priv->currenttxskb, priv->dnld_sent,
  451. priv->cur_cmd);
  452. lbs_ps_confirm_sleep(priv);
  453. } else {
  454. /* workaround for firmware sending
  455. * deauth/linkloss event immediately
  456. * after sleep request; remove this
  457. * after firmware fixes it
  458. */
  459. priv->psstate = PS_STATE_AWAKE;
  460. netdev_alert(dev,
  461. "ignore PS_SleepConfirm in non-connected state\n");
  462. }
  463. }
  464. /* The PS state is changed during processing of Sleep Request
  465. * event above
  466. */
  467. if ((priv->psstate == PS_STATE_SLEEP) ||
  468. (priv->psstate == PS_STATE_PRE_SLEEP))
  469. continue;
  470. if (priv->is_deep_sleep)
  471. continue;
  472. /* Execute the next command */
  473. if (!priv->dnld_sent && !priv->cur_cmd)
  474. lbs_execute_next_command(priv);
  475. spin_lock_irq(&priv->driver_lock);
  476. if (!priv->dnld_sent && priv->tx_pending_len > 0) {
  477. int ret = priv->hw_host_to_card(priv, MVMS_DAT,
  478. priv->tx_pending_buf,
  479. priv->tx_pending_len);
  480. if (ret) {
  481. lbs_deb_tx("host_to_card failed %d\n", ret);
  482. priv->dnld_sent = DNLD_RES_RECEIVED;
  483. } else {
  484. mod_timer(&priv->tx_lockup_timer,
  485. jiffies + (HZ * 5));
  486. }
  487. priv->tx_pending_len = 0;
  488. if (!priv->currenttxskb) {
  489. /* We can wake the queues immediately if we aren't
  490. waiting for TX feedback */
  491. if (priv->connect_status == LBS_CONNECTED)
  492. netif_wake_queue(priv->dev);
  493. if (priv->mesh_dev &&
  494. netif_running(priv->mesh_dev))
  495. netif_wake_queue(priv->mesh_dev);
  496. }
  497. }
  498. spin_unlock_irq(&priv->driver_lock);
  499. }
  500. del_timer(&priv->command_timer);
  501. del_timer(&priv->tx_lockup_timer);
  502. del_timer(&priv->auto_deepsleep_timer);
  503. lbs_deb_leave(LBS_DEB_THREAD);
  504. return 0;
  505. }
  506. /**
  507. * lbs_setup_firmware - gets the HW spec from the firmware and sets
  508. * some basic parameters
  509. *
  510. * @priv: A pointer to &struct lbs_private structure
  511. * returns: 0 or -1
  512. */
  513. static int lbs_setup_firmware(struct lbs_private *priv)
  514. {
  515. int ret = -1;
  516. s16 curlevel = 0, minlevel = 0, maxlevel = 0;
  517. lbs_deb_enter(LBS_DEB_FW);
  518. /* Read MAC address from firmware */
  519. memset(priv->current_addr, 0xff, ETH_ALEN);
  520. ret = lbs_update_hw_spec(priv);
  521. if (ret)
  522. goto done;
  523. /* Read power levels if available */
  524. ret = lbs_get_tx_power(priv, &curlevel, &minlevel, &maxlevel);
  525. if (ret == 0) {
  526. priv->txpower_cur = curlevel;
  527. priv->txpower_min = minlevel;
  528. priv->txpower_max = maxlevel;
  529. }
  530. /* Send cmd to FW to enable 11D function */
  531. ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_11D_ENABLE, 1);
  532. lbs_set_mac_control(priv);
  533. done:
  534. lbs_deb_leave_args(LBS_DEB_FW, "ret %d", ret);
  535. return ret;
  536. }
  537. int lbs_suspend(struct lbs_private *priv)
  538. {
  539. int ret;
  540. lbs_deb_enter(LBS_DEB_FW);
  541. if (priv->is_deep_sleep) {
  542. ret = lbs_set_deep_sleep(priv, 0);
  543. if (ret) {
  544. netdev_err(priv->dev,
  545. "deep sleep cancellation failed: %d\n", ret);
  546. return ret;
  547. }
  548. priv->deep_sleep_required = 1;
  549. }
  550. ret = lbs_set_host_sleep(priv, 1);
  551. netif_device_detach(priv->dev);
  552. if (priv->mesh_dev)
  553. netif_device_detach(priv->mesh_dev);
  554. lbs_deb_leave_args(LBS_DEB_FW, "ret %d", ret);
  555. return ret;
  556. }
  557. EXPORT_SYMBOL_GPL(lbs_suspend);
  558. int lbs_resume(struct lbs_private *priv)
  559. {
  560. int ret;
  561. lbs_deb_enter(LBS_DEB_FW);
  562. ret = lbs_set_host_sleep(priv, 0);
  563. netif_device_attach(priv->dev);
  564. if (priv->mesh_dev)
  565. netif_device_attach(priv->mesh_dev);
  566. if (priv->deep_sleep_required) {
  567. priv->deep_sleep_required = 0;
  568. ret = lbs_set_deep_sleep(priv, 1);
  569. if (ret)
  570. netdev_err(priv->dev,
  571. "deep sleep activation failed: %d\n", ret);
  572. }
  573. if (priv->setup_fw_on_resume)
  574. ret = lbs_setup_firmware(priv);
  575. lbs_deb_leave_args(LBS_DEB_FW, "ret %d", ret);
  576. return ret;
  577. }
  578. EXPORT_SYMBOL_GPL(lbs_resume);
  579. /**
  580. * lbs_cmd_timeout_handler - handles the timeout of command sending.
  581. * It will re-send the same command again.
  582. *
  583. * @data: &struct lbs_private pointer
  584. */
  585. static void lbs_cmd_timeout_handler(unsigned long data)
  586. {
  587. struct lbs_private *priv = (struct lbs_private *)data;
  588. unsigned long flags;
  589. lbs_deb_enter(LBS_DEB_CMD);
  590. spin_lock_irqsave(&priv->driver_lock, flags);
  591. if (!priv->cur_cmd)
  592. goto out;
  593. netdev_info(priv->dev, "command 0x%04x timed out\n",
  594. le16_to_cpu(priv->cur_cmd->cmdbuf->command));
  595. priv->cmd_timed_out = 1;
  596. /*
  597. * If the device didn't even acknowledge the command, reset the state
  598. * so that we don't block all future commands due to this one timeout.
  599. */
  600. if (priv->dnld_sent == DNLD_CMD_SENT)
  601. priv->dnld_sent = DNLD_RES_RECEIVED;
  602. wake_up(&priv->waitq);
  603. out:
  604. spin_unlock_irqrestore(&priv->driver_lock, flags);
  605. lbs_deb_leave(LBS_DEB_CMD);
  606. }
  607. /**
  608. * lbs_tx_lockup_handler - handles the timeout of the passing of TX frames
  609. * to the hardware. This is known to frequently happen with SD8686 when
  610. * waking up after a Wake-on-WLAN-triggered resume.
  611. *
  612. * @data: &struct lbs_private pointer
  613. */
  614. static void lbs_tx_lockup_handler(unsigned long data)
  615. {
  616. struct lbs_private *priv = (struct lbs_private *)data;
  617. unsigned long flags;
  618. lbs_deb_enter(LBS_DEB_TX);
  619. spin_lock_irqsave(&priv->driver_lock, flags);
  620. netdev_info(priv->dev, "TX lockup detected\n");
  621. if (priv->reset_card)
  622. priv->reset_card(priv);
  623. priv->dnld_sent = DNLD_RES_RECEIVED;
  624. wake_up_interruptible(&priv->waitq);
  625. spin_unlock_irqrestore(&priv->driver_lock, flags);
  626. lbs_deb_leave(LBS_DEB_TX);
  627. }
  628. /**
  629. * auto_deepsleep_timer_fn - put the device back to deep sleep mode when
  630. * timer expires and no activity (command, event, data etc.) is detected.
  631. * @data: &struct lbs_private pointer
  632. * returns: N/A
  633. */
  634. static void auto_deepsleep_timer_fn(unsigned long data)
  635. {
  636. struct lbs_private *priv = (struct lbs_private *)data;
  637. lbs_deb_enter(LBS_DEB_CMD);
  638. if (priv->is_activity_detected) {
  639. priv->is_activity_detected = 0;
  640. } else {
  641. if (priv->is_auto_deep_sleep_enabled &&
  642. (!priv->wakeup_dev_required) &&
  643. (priv->connect_status != LBS_CONNECTED)) {
  644. struct cmd_header cmd;
  645. lbs_deb_main("Entering auto deep sleep mode...\n");
  646. memset(&cmd, 0, sizeof(cmd));
  647. cmd.size = cpu_to_le16(sizeof(cmd));
  648. lbs_cmd_async(priv, CMD_802_11_DEEP_SLEEP, &cmd,
  649. sizeof(cmd));
  650. }
  651. }
  652. mod_timer(&priv->auto_deepsleep_timer , jiffies +
  653. (priv->auto_deep_sleep_timeout * HZ)/1000);
  654. lbs_deb_leave(LBS_DEB_CMD);
  655. }
  656. int lbs_enter_auto_deep_sleep(struct lbs_private *priv)
  657. {
  658. lbs_deb_enter(LBS_DEB_SDIO);
  659. priv->is_auto_deep_sleep_enabled = 1;
  660. if (priv->is_deep_sleep)
  661. priv->wakeup_dev_required = 1;
  662. mod_timer(&priv->auto_deepsleep_timer ,
  663. jiffies + (priv->auto_deep_sleep_timeout * HZ)/1000);
  664. lbs_deb_leave(LBS_DEB_SDIO);
  665. return 0;
  666. }
  667. int lbs_exit_auto_deep_sleep(struct lbs_private *priv)
  668. {
  669. lbs_deb_enter(LBS_DEB_SDIO);
  670. priv->is_auto_deep_sleep_enabled = 0;
  671. priv->auto_deep_sleep_timeout = 0;
  672. del_timer(&priv->auto_deepsleep_timer);
  673. lbs_deb_leave(LBS_DEB_SDIO);
  674. return 0;
  675. }
  676. static int lbs_init_adapter(struct lbs_private *priv)
  677. {
  678. int ret;
  679. lbs_deb_enter(LBS_DEB_MAIN);
  680. memset(priv->current_addr, 0xff, ETH_ALEN);
  681. priv->connect_status = LBS_DISCONNECTED;
  682. priv->channel = DEFAULT_AD_HOC_CHANNEL;
  683. priv->mac_control = CMD_ACT_MAC_RX_ON | CMD_ACT_MAC_TX_ON;
  684. priv->radio_on = 1;
  685. priv->psmode = LBS802_11POWERMODECAM;
  686. priv->psstate = PS_STATE_FULL_POWER;
  687. priv->is_deep_sleep = 0;
  688. priv->is_auto_deep_sleep_enabled = 0;
  689. priv->deep_sleep_required = 0;
  690. priv->wakeup_dev_required = 0;
  691. init_waitqueue_head(&priv->ds_awake_q);
  692. init_waitqueue_head(&priv->scan_q);
  693. priv->authtype_auto = 1;
  694. priv->is_host_sleep_configured = 0;
  695. priv->is_host_sleep_activated = 0;
  696. init_waitqueue_head(&priv->host_sleep_q);
  697. mutex_init(&priv->lock);
  698. setup_timer(&priv->command_timer, lbs_cmd_timeout_handler,
  699. (unsigned long)priv);
  700. setup_timer(&priv->tx_lockup_timer, lbs_tx_lockup_handler,
  701. (unsigned long)priv);
  702. setup_timer(&priv->auto_deepsleep_timer, auto_deepsleep_timer_fn,
  703. (unsigned long)priv);
  704. INIT_LIST_HEAD(&priv->cmdfreeq);
  705. INIT_LIST_HEAD(&priv->cmdpendingq);
  706. spin_lock_init(&priv->driver_lock);
  707. /* Allocate the command buffers */
  708. if (lbs_allocate_cmd_buffer(priv)) {
  709. pr_err("Out of memory allocating command buffers\n");
  710. ret = -ENOMEM;
  711. goto out;
  712. }
  713. priv->resp_idx = 0;
  714. priv->resp_len[0] = priv->resp_len[1] = 0;
  715. /* Create the event FIFO */
  716. ret = kfifo_alloc(&priv->event_fifo, sizeof(u32) * 16, GFP_KERNEL);
  717. if (ret) {
  718. pr_err("Out of memory allocating event FIFO buffer\n");
  719. goto out;
  720. }
  721. out:
  722. lbs_deb_leave_args(LBS_DEB_MAIN, "ret %d", ret);
  723. return ret;
  724. }
  725. static void lbs_free_adapter(struct lbs_private *priv)
  726. {
  727. lbs_deb_enter(LBS_DEB_MAIN);
  728. lbs_free_cmd_buffer(priv);
  729. kfifo_free(&priv->event_fifo);
  730. del_timer(&priv->command_timer);
  731. del_timer(&priv->tx_lockup_timer);
  732. del_timer(&priv->auto_deepsleep_timer);
  733. lbs_deb_leave(LBS_DEB_MAIN);
  734. }
  735. static const struct net_device_ops lbs_netdev_ops = {
  736. .ndo_open = lbs_dev_open,
  737. .ndo_stop = lbs_eth_stop,
  738. .ndo_start_xmit = lbs_hard_start_xmit,
  739. .ndo_set_mac_address = lbs_set_mac_address,
  740. .ndo_set_multicast_list = lbs_set_multicast_list,
  741. .ndo_change_mtu = eth_change_mtu,
  742. .ndo_validate_addr = eth_validate_addr,
  743. };
  744. /**
  745. * lbs_add_card - adds the card. It will probe the
  746. * card, allocate the lbs_priv and initialize the device.
  747. *
  748. * @card: A pointer to card
  749. * @dmdev: A pointer to &struct device
  750. * returns: A pointer to &struct lbs_private structure
  751. */
  752. struct lbs_private *lbs_add_card(void *card, struct device *dmdev)
  753. {
  754. struct net_device *dev;
  755. struct wireless_dev *wdev;
  756. struct lbs_private *priv = NULL;
  757. lbs_deb_enter(LBS_DEB_MAIN);
  758. /* Allocate an Ethernet device and register it */
  759. wdev = lbs_cfg_alloc(dmdev);
  760. if (IS_ERR(wdev)) {
  761. pr_err("cfg80211 init failed\n");
  762. goto done;
  763. }
  764. wdev->iftype = NL80211_IFTYPE_STATION;
  765. priv = wdev_priv(wdev);
  766. priv->wdev = wdev;
  767. if (lbs_init_adapter(priv)) {
  768. pr_err("failed to initialize adapter structure\n");
  769. goto err_wdev;
  770. }
  771. dev = alloc_netdev(0, "wlan%d", ether_setup);
  772. if (!dev) {
  773. dev_err(dmdev, "no memory for network device instance\n");
  774. goto err_adapter;
  775. }
  776. dev->ieee80211_ptr = wdev;
  777. dev->ml_priv = priv;
  778. SET_NETDEV_DEV(dev, dmdev);
  779. wdev->netdev = dev;
  780. priv->dev = dev;
  781. dev->netdev_ops = &lbs_netdev_ops;
  782. dev->watchdog_timeo = 5 * HZ;
  783. dev->ethtool_ops = &lbs_ethtool_ops;
  784. dev->flags |= IFF_BROADCAST | IFF_MULTICAST;
  785. priv->card = card;
  786. strcpy(dev->name, "wlan%d");
  787. lbs_deb_thread("Starting main thread...\n");
  788. init_waitqueue_head(&priv->waitq);
  789. priv->main_thread = kthread_run(lbs_thread, dev, "lbs_main");
  790. if (IS_ERR(priv->main_thread)) {
  791. lbs_deb_thread("Error creating main thread.\n");
  792. goto err_ndev;
  793. }
  794. priv->work_thread = create_singlethread_workqueue("lbs_worker");
  795. INIT_WORK(&priv->mcast_work, lbs_set_mcast_worker);
  796. priv->wol_criteria = EHS_REMOVE_WAKEUP;
  797. priv->wol_gpio = 0xff;
  798. priv->wol_gap = 20;
  799. priv->ehs_remove_supported = true;
  800. goto done;
  801. err_ndev:
  802. free_netdev(dev);
  803. err_adapter:
  804. lbs_free_adapter(priv);
  805. err_wdev:
  806. lbs_cfg_free(priv);
  807. priv = NULL;
  808. done:
  809. lbs_deb_leave_args(LBS_DEB_MAIN, "priv %p", priv);
  810. return priv;
  811. }
  812. EXPORT_SYMBOL_GPL(lbs_add_card);
  813. void lbs_remove_card(struct lbs_private *priv)
  814. {
  815. struct net_device *dev = priv->dev;
  816. lbs_deb_enter(LBS_DEB_MAIN);
  817. lbs_remove_mesh(priv);
  818. lbs_scan_deinit(priv);
  819. /* worker thread destruction blocks on the in-flight command which
  820. * should have been cleared already in lbs_stop_card().
  821. */
  822. lbs_deb_main("destroying worker thread\n");
  823. destroy_workqueue(priv->work_thread);
  824. lbs_deb_main("done destroying worker thread\n");
  825. if (priv->psmode == LBS802_11POWERMODEMAX_PSP) {
  826. priv->psmode = LBS802_11POWERMODECAM;
  827. lbs_set_ps_mode(priv, PS_MODE_ACTION_EXIT_PS, true);
  828. }
  829. if (priv->is_deep_sleep) {
  830. priv->is_deep_sleep = 0;
  831. wake_up_interruptible(&priv->ds_awake_q);
  832. }
  833. priv->is_host_sleep_configured = 0;
  834. priv->is_host_sleep_activated = 0;
  835. wake_up_interruptible(&priv->host_sleep_q);
  836. /* Stop the thread servicing the interrupts */
  837. priv->surpriseremoved = 1;
  838. kthread_stop(priv->main_thread);
  839. lbs_free_adapter(priv);
  840. lbs_cfg_free(priv);
  841. free_netdev(dev);
  842. lbs_deb_leave(LBS_DEB_MAIN);
  843. }
  844. EXPORT_SYMBOL_GPL(lbs_remove_card);
  845. int lbs_rtap_supported(struct lbs_private *priv)
  846. {
  847. if (MRVL_FW_MAJOR_REV(priv->fwrelease) == MRVL_FW_V5)
  848. return 1;
  849. /* newer firmware use a capability mask */
  850. return ((MRVL_FW_MAJOR_REV(priv->fwrelease) >= MRVL_FW_V10) &&
  851. (priv->fwcapinfo & MESH_CAPINFO_ENABLE_MASK));
  852. }
  853. int lbs_start_card(struct lbs_private *priv)
  854. {
  855. struct net_device *dev = priv->dev;
  856. int ret = -1;
  857. lbs_deb_enter(LBS_DEB_MAIN);
  858. /* poke the firmware */
  859. ret = lbs_setup_firmware(priv);
  860. if (ret)
  861. goto done;
  862. if (!lbs_disablemesh)
  863. lbs_init_mesh(priv);
  864. else
  865. pr_info("%s: mesh disabled\n", dev->name);
  866. if (lbs_cfg_register(priv)) {
  867. pr_err("cannot register device\n");
  868. goto done;
  869. }
  870. if (lbs_mesh_activated(priv))
  871. lbs_start_mesh(priv);
  872. lbs_debugfs_init_one(priv, dev);
  873. netdev_info(dev, "Marvell WLAN 802.11 adapter\n");
  874. ret = 0;
  875. done:
  876. lbs_deb_leave_args(LBS_DEB_MAIN, "ret %d", ret);
  877. return ret;
  878. }
  879. EXPORT_SYMBOL_GPL(lbs_start_card);
  880. void lbs_stop_card(struct lbs_private *priv)
  881. {
  882. struct net_device *dev;
  883. lbs_deb_enter(LBS_DEB_MAIN);
  884. if (!priv)
  885. goto out;
  886. dev = priv->dev;
  887. netif_stop_queue(dev);
  888. netif_carrier_off(dev);
  889. lbs_debugfs_remove_one(priv);
  890. lbs_deinit_mesh(priv);
  891. unregister_netdev(dev);
  892. out:
  893. lbs_deb_leave(LBS_DEB_MAIN);
  894. }
  895. EXPORT_SYMBOL_GPL(lbs_stop_card);
  896. void lbs_queue_event(struct lbs_private *priv, u32 event)
  897. {
  898. unsigned long flags;
  899. lbs_deb_enter(LBS_DEB_THREAD);
  900. spin_lock_irqsave(&priv->driver_lock, flags);
  901. if (priv->psstate == PS_STATE_SLEEP)
  902. priv->psstate = PS_STATE_AWAKE;
  903. kfifo_in(&priv->event_fifo, (unsigned char *) &event, sizeof(u32));
  904. wake_up(&priv->waitq);
  905. spin_unlock_irqrestore(&priv->driver_lock, flags);
  906. lbs_deb_leave(LBS_DEB_THREAD);
  907. }
  908. EXPORT_SYMBOL_GPL(lbs_queue_event);
  909. void lbs_notify_command_response(struct lbs_private *priv, u8 resp_idx)
  910. {
  911. lbs_deb_enter(LBS_DEB_THREAD);
  912. if (priv->psstate == PS_STATE_SLEEP)
  913. priv->psstate = PS_STATE_AWAKE;
  914. /* Swap buffers by flipping the response index */
  915. BUG_ON(resp_idx > 1);
  916. priv->resp_idx = resp_idx;
  917. wake_up(&priv->waitq);
  918. lbs_deb_leave(LBS_DEB_THREAD);
  919. }
  920. EXPORT_SYMBOL_GPL(lbs_notify_command_response);
  921. /**
  922. * lbs_get_firmware - Retrieves two-stage firmware
  923. *
  924. * @dev: A pointer to &device structure
  925. * @user_helper: User-defined helper firmware file
  926. * @user_mainfw: User-defined main firmware file
  927. * @card_model: Bus-specific card model ID used to filter firmware table
  928. * elements
  929. * @fw_table: Table of firmware file names and device model numbers
  930. * terminated by an entry with a NULL helper name
  931. * @helper: On success, the helper firmware; caller must free
  932. * @mainfw: On success, the main firmware; caller must free
  933. *
  934. * returns: 0 on success, non-zero on failure
  935. */
  936. int lbs_get_firmware(struct device *dev, const char *user_helper,
  937. const char *user_mainfw, u32 card_model,
  938. const struct lbs_fw_table *fw_table,
  939. const struct firmware **helper,
  940. const struct firmware **mainfw)
  941. {
  942. const struct lbs_fw_table *iter;
  943. int ret;
  944. BUG_ON(helper == NULL);
  945. BUG_ON(mainfw == NULL);
  946. /* Try user-specified firmware first */
  947. if (user_helper) {
  948. ret = request_firmware(helper, user_helper, dev);
  949. if (ret) {
  950. dev_err(dev, "couldn't find helper firmware %s\n",
  951. user_helper);
  952. goto fail;
  953. }
  954. }
  955. if (user_mainfw) {
  956. ret = request_firmware(mainfw, user_mainfw, dev);
  957. if (ret) {
  958. dev_err(dev, "couldn't find main firmware %s\n",
  959. user_mainfw);
  960. goto fail;
  961. }
  962. }
  963. if (*helper && *mainfw)
  964. return 0;
  965. /* Otherwise search for firmware to use. If neither the helper or
  966. * the main firmware were specified by the user, then we need to
  967. * make sure that found helper & main are from the same entry in
  968. * fw_table.
  969. */
  970. iter = fw_table;
  971. while (iter && iter->helper) {
  972. if (iter->model != card_model)
  973. goto next;
  974. if (*helper == NULL) {
  975. ret = request_firmware(helper, iter->helper, dev);
  976. if (ret)
  977. goto next;
  978. /* If the device has one-stage firmware (ie cf8305) and
  979. * we've got it then we don't need to bother with the
  980. * main firmware.
  981. */
  982. if (iter->fwname == NULL)
  983. return 0;
  984. }
  985. if (*mainfw == NULL) {
  986. ret = request_firmware(mainfw, iter->fwname, dev);
  987. if (ret && !user_helper) {
  988. /* Clear the helper if it wasn't user-specified
  989. * and the main firmware load failed, to ensure
  990. * we don't have mismatched firmware pairs.
  991. */
  992. release_firmware(*helper);
  993. *helper = NULL;
  994. }
  995. }
  996. if (*helper && *mainfw)
  997. return 0;
  998. next:
  999. iter++;
  1000. }
  1001. fail:
  1002. /* Failed */
  1003. if (*helper) {
  1004. release_firmware(*helper);
  1005. *helper = NULL;
  1006. }
  1007. if (*mainfw) {
  1008. release_firmware(*mainfw);
  1009. *mainfw = NULL;
  1010. }
  1011. return -ENOENT;
  1012. }
  1013. EXPORT_SYMBOL_GPL(lbs_get_firmware);
  1014. static int __init lbs_init_module(void)
  1015. {
  1016. lbs_deb_enter(LBS_DEB_MAIN);
  1017. memset(&confirm_sleep, 0, sizeof(confirm_sleep));
  1018. confirm_sleep.hdr.command = cpu_to_le16(CMD_802_11_PS_MODE);
  1019. confirm_sleep.hdr.size = cpu_to_le16(sizeof(confirm_sleep));
  1020. confirm_sleep.action = cpu_to_le16(PS_MODE_ACTION_SLEEP_CONFIRMED);
  1021. lbs_debugfs_init();
  1022. lbs_deb_leave(LBS_DEB_MAIN);
  1023. return 0;
  1024. }
  1025. static void __exit lbs_exit_module(void)
  1026. {
  1027. lbs_deb_enter(LBS_DEB_MAIN);
  1028. lbs_debugfs_remove();
  1029. lbs_deb_leave(LBS_DEB_MAIN);
  1030. }
  1031. module_init(lbs_init_module);
  1032. module_exit(lbs_exit_module);
  1033. MODULE_DESCRIPTION("Libertas WLAN Driver Library");
  1034. MODULE_AUTHOR("Marvell International Ltd.");
  1035. MODULE_LICENSE("GPL");