main.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  1. /*
  2. * Copyright (C) 2008, cozybit Inc.
  3. * Copyright (C) 2003-2006, Marvell International Ltd.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or (at
  8. * your option) any later version.
  9. */
  10. #include <linux/slab.h>
  11. #include "libertas_tf.h"
  12. #include "linux/etherdevice.h"
  13. #define DRIVER_RELEASE_VERSION "004.p0"
  14. /* thinfirm version: 5.132.X.pX */
  15. #define LBTF_FW_VER_MIN 0x05840300
  16. #define LBTF_FW_VER_MAX 0x0584ffff
  17. #define QOS_CONTROL_LEN 2
  18. static const char lbtf_driver_version[] = "THINFIRM-USB8388-" DRIVER_RELEASE_VERSION;
  19. struct workqueue_struct *lbtf_wq;
  20. static const struct ieee80211_channel lbtf_channels[] = {
  21. { .center_freq = 2412, .hw_value = 1 },
  22. { .center_freq = 2417, .hw_value = 2 },
  23. { .center_freq = 2422, .hw_value = 3 },
  24. { .center_freq = 2427, .hw_value = 4 },
  25. { .center_freq = 2432, .hw_value = 5 },
  26. { .center_freq = 2437, .hw_value = 6 },
  27. { .center_freq = 2442, .hw_value = 7 },
  28. { .center_freq = 2447, .hw_value = 8 },
  29. { .center_freq = 2452, .hw_value = 9 },
  30. { .center_freq = 2457, .hw_value = 10 },
  31. { .center_freq = 2462, .hw_value = 11 },
  32. { .center_freq = 2467, .hw_value = 12 },
  33. { .center_freq = 2472, .hw_value = 13 },
  34. { .center_freq = 2484, .hw_value = 14 },
  35. };
  36. /* This table contains the hardware specific values for the modulation rates. */
  37. static const struct ieee80211_rate lbtf_rates[] = {
  38. { .bitrate = 10,
  39. .hw_value = 0, },
  40. { .bitrate = 20,
  41. .hw_value = 1,
  42. .flags = IEEE80211_RATE_SHORT_PREAMBLE },
  43. { .bitrate = 55,
  44. .hw_value = 2,
  45. .flags = IEEE80211_RATE_SHORT_PREAMBLE },
  46. { .bitrate = 110,
  47. .hw_value = 3,
  48. .flags = IEEE80211_RATE_SHORT_PREAMBLE },
  49. { .bitrate = 60,
  50. .hw_value = 5,
  51. .flags = 0 },
  52. { .bitrate = 90,
  53. .hw_value = 6,
  54. .flags = 0 },
  55. { .bitrate = 120,
  56. .hw_value = 7,
  57. .flags = 0 },
  58. { .bitrate = 180,
  59. .hw_value = 8,
  60. .flags = 0 },
  61. { .bitrate = 240,
  62. .hw_value = 9,
  63. .flags = 0 },
  64. { .bitrate = 360,
  65. .hw_value = 10,
  66. .flags = 0 },
  67. { .bitrate = 480,
  68. .hw_value = 11,
  69. .flags = 0 },
  70. { .bitrate = 540,
  71. .hw_value = 12,
  72. .flags = 0 },
  73. };
  74. static void lbtf_cmd_work(struct work_struct *work)
  75. {
  76. struct lbtf_private *priv = container_of(work, struct lbtf_private,
  77. cmd_work);
  78. spin_lock_irq(&priv->driver_lock);
  79. /* command response? */
  80. if (priv->cmd_response_rxed) {
  81. priv->cmd_response_rxed = 0;
  82. spin_unlock_irq(&priv->driver_lock);
  83. lbtf_process_rx_command(priv);
  84. spin_lock_irq(&priv->driver_lock);
  85. }
  86. if (priv->cmd_timed_out && priv->cur_cmd) {
  87. struct cmd_ctrl_node *cmdnode = priv->cur_cmd;
  88. if (++priv->nr_retries > 10) {
  89. lbtf_complete_command(priv, cmdnode,
  90. -ETIMEDOUT);
  91. priv->nr_retries = 0;
  92. } else {
  93. priv->cur_cmd = NULL;
  94. /* Stick it back at the _top_ of the pending
  95. * queue for immediate resubmission */
  96. list_add(&cmdnode->list, &priv->cmdpendingq);
  97. }
  98. }
  99. priv->cmd_timed_out = 0;
  100. spin_unlock_irq(&priv->driver_lock);
  101. if (!priv->fw_ready)
  102. return;
  103. /* Execute the next command */
  104. if (!priv->cur_cmd)
  105. lbtf_execute_next_command(priv);
  106. }
  107. /**
  108. * lbtf_setup_firmware: initialize firmware.
  109. *
  110. * @priv A pointer to struct lbtf_private structure
  111. *
  112. * Returns: 0 on success.
  113. */
  114. static int lbtf_setup_firmware(struct lbtf_private *priv)
  115. {
  116. int ret = -1;
  117. /*
  118. * Read priv address from HW
  119. */
  120. memset(priv->current_addr, 0xff, ETH_ALEN);
  121. ret = lbtf_update_hw_spec(priv);
  122. if (ret) {
  123. ret = -1;
  124. goto done;
  125. }
  126. lbtf_set_mac_control(priv);
  127. lbtf_set_radio_control(priv);
  128. ret = 0;
  129. done:
  130. return ret;
  131. }
  132. /**
  133. * This function handles the timeout of command sending.
  134. * It will re-send the same command again.
  135. */
  136. static void command_timer_fn(unsigned long data)
  137. {
  138. struct lbtf_private *priv = (struct lbtf_private *)data;
  139. unsigned long flags;
  140. spin_lock_irqsave(&priv->driver_lock, flags);
  141. if (!priv->cur_cmd) {
  142. printk(KERN_DEBUG "libertastf: command timer expired; "
  143. "no pending command\n");
  144. goto out;
  145. }
  146. printk(KERN_DEBUG "libertas: command %x timed out\n",
  147. le16_to_cpu(priv->cur_cmd->cmdbuf->command));
  148. priv->cmd_timed_out = 1;
  149. queue_work(lbtf_wq, &priv->cmd_work);
  150. out:
  151. spin_unlock_irqrestore(&priv->driver_lock, flags);
  152. }
  153. static int lbtf_init_adapter(struct lbtf_private *priv)
  154. {
  155. memset(priv->current_addr, 0xff, ETH_ALEN);
  156. mutex_init(&priv->lock);
  157. priv->vif = NULL;
  158. setup_timer(&priv->command_timer, command_timer_fn,
  159. (unsigned long)priv);
  160. INIT_LIST_HEAD(&priv->cmdfreeq);
  161. INIT_LIST_HEAD(&priv->cmdpendingq);
  162. spin_lock_init(&priv->driver_lock);
  163. /* Allocate the command buffers */
  164. if (lbtf_allocate_cmd_buffer(priv))
  165. return -1;
  166. return 0;
  167. }
  168. static void lbtf_free_adapter(struct lbtf_private *priv)
  169. {
  170. lbtf_free_cmd_buffer(priv);
  171. del_timer(&priv->command_timer);
  172. }
  173. static int lbtf_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
  174. {
  175. struct lbtf_private *priv = hw->priv;
  176. priv->skb_to_tx = skb;
  177. queue_work(lbtf_wq, &priv->tx_work);
  178. /*
  179. * queue will be restarted when we receive transmission feedback if
  180. * there are no buffered multicast frames to send
  181. */
  182. ieee80211_stop_queues(priv->hw);
  183. return NETDEV_TX_OK;
  184. }
  185. static void lbtf_tx_work(struct work_struct *work)
  186. {
  187. struct lbtf_private *priv = container_of(work, struct lbtf_private,
  188. tx_work);
  189. unsigned int len;
  190. struct ieee80211_tx_info *info;
  191. struct txpd *txpd;
  192. struct sk_buff *skb = NULL;
  193. int err;
  194. if ((priv->vif->type == NL80211_IFTYPE_AP) &&
  195. (!skb_queue_empty(&priv->bc_ps_buf)))
  196. skb = skb_dequeue(&priv->bc_ps_buf);
  197. else if (priv->skb_to_tx) {
  198. skb = priv->skb_to_tx;
  199. priv->skb_to_tx = NULL;
  200. } else
  201. return;
  202. len = skb->len;
  203. info = IEEE80211_SKB_CB(skb);
  204. txpd = (struct txpd *) skb_push(skb, sizeof(struct txpd));
  205. if (priv->surpriseremoved) {
  206. dev_kfree_skb_any(skb);
  207. return;
  208. }
  209. memset(txpd, 0, sizeof(struct txpd));
  210. /* Activate per-packet rate selection */
  211. txpd->tx_control |= cpu_to_le32(MRVL_PER_PACKET_RATE |
  212. ieee80211_get_tx_rate(priv->hw, info)->hw_value);
  213. /* copy destination address from 802.11 header */
  214. memcpy(txpd->tx_dest_addr_high, skb->data + sizeof(struct txpd) + 4,
  215. ETH_ALEN);
  216. txpd->tx_packet_length = cpu_to_le16(len);
  217. txpd->tx_packet_location = cpu_to_le32(sizeof(struct txpd));
  218. BUG_ON(priv->tx_skb);
  219. spin_lock_irq(&priv->driver_lock);
  220. priv->tx_skb = skb;
  221. err = priv->hw_host_to_card(priv, MVMS_DAT, skb->data, skb->len);
  222. spin_unlock_irq(&priv->driver_lock);
  223. if (err) {
  224. dev_kfree_skb_any(skb);
  225. priv->tx_skb = NULL;
  226. }
  227. }
  228. static int lbtf_op_start(struct ieee80211_hw *hw)
  229. {
  230. struct lbtf_private *priv = hw->priv;
  231. void *card = priv->card;
  232. int ret = -1;
  233. if (!priv->fw_ready)
  234. /* Upload firmware */
  235. if (priv->hw_prog_firmware(card))
  236. goto err_prog_firmware;
  237. /* poke the firmware */
  238. priv->capability = WLAN_CAPABILITY_SHORT_PREAMBLE;
  239. priv->radioon = RADIO_ON;
  240. priv->mac_control = CMD_ACT_MAC_RX_ON | CMD_ACT_MAC_TX_ON;
  241. ret = lbtf_setup_firmware(priv);
  242. if (ret)
  243. goto err_prog_firmware;
  244. if ((priv->fwrelease < LBTF_FW_VER_MIN) ||
  245. (priv->fwrelease > LBTF_FW_VER_MAX)) {
  246. ret = -1;
  247. goto err_prog_firmware;
  248. }
  249. printk(KERN_INFO "libertastf: Marvell WLAN 802.11 thinfirm adapter\n");
  250. return 0;
  251. err_prog_firmware:
  252. priv->hw_reset_device(card);
  253. return ret;
  254. }
  255. static void lbtf_op_stop(struct ieee80211_hw *hw)
  256. {
  257. struct lbtf_private *priv = hw->priv;
  258. unsigned long flags;
  259. struct sk_buff *skb;
  260. struct cmd_ctrl_node *cmdnode;
  261. /* Flush pending command nodes */
  262. spin_lock_irqsave(&priv->driver_lock, flags);
  263. list_for_each_entry(cmdnode, &priv->cmdpendingq, list) {
  264. cmdnode->result = -ENOENT;
  265. cmdnode->cmdwaitqwoken = 1;
  266. wake_up_interruptible(&cmdnode->cmdwait_q);
  267. }
  268. spin_unlock_irqrestore(&priv->driver_lock, flags);
  269. cancel_work_sync(&priv->cmd_work);
  270. cancel_work_sync(&priv->tx_work);
  271. while ((skb = skb_dequeue(&priv->bc_ps_buf)))
  272. dev_kfree_skb_any(skb);
  273. priv->radioon = RADIO_OFF;
  274. lbtf_set_radio_control(priv);
  275. return;
  276. }
  277. static int lbtf_op_add_interface(struct ieee80211_hw *hw,
  278. struct ieee80211_vif *vif)
  279. {
  280. struct lbtf_private *priv = hw->priv;
  281. if (priv->vif != NULL)
  282. return -EOPNOTSUPP;
  283. priv->vif = vif;
  284. switch (vif->type) {
  285. case NL80211_IFTYPE_MESH_POINT:
  286. case NL80211_IFTYPE_AP:
  287. lbtf_set_mode(priv, LBTF_AP_MODE);
  288. break;
  289. case NL80211_IFTYPE_STATION:
  290. lbtf_set_mode(priv, LBTF_STA_MODE);
  291. break;
  292. default:
  293. priv->vif = NULL;
  294. return -EOPNOTSUPP;
  295. }
  296. lbtf_set_mac_address(priv, (u8 *) vif->addr);
  297. return 0;
  298. }
  299. static void lbtf_op_remove_interface(struct ieee80211_hw *hw,
  300. struct ieee80211_vif *vif)
  301. {
  302. struct lbtf_private *priv = hw->priv;
  303. if (priv->vif->type == NL80211_IFTYPE_AP ||
  304. priv->vif->type == NL80211_IFTYPE_MESH_POINT)
  305. lbtf_beacon_ctrl(priv, 0, 0);
  306. lbtf_set_mode(priv, LBTF_PASSIVE_MODE);
  307. lbtf_set_bssid(priv, 0, NULL);
  308. priv->vif = NULL;
  309. }
  310. static int lbtf_op_config(struct ieee80211_hw *hw, u32 changed)
  311. {
  312. struct lbtf_private *priv = hw->priv;
  313. struct ieee80211_conf *conf = &hw->conf;
  314. if (conf->channel->center_freq != priv->cur_freq) {
  315. priv->cur_freq = conf->channel->center_freq;
  316. lbtf_set_channel(priv, conf->channel->hw_value);
  317. }
  318. return 0;
  319. }
  320. static u64 lbtf_op_prepare_multicast(struct ieee80211_hw *hw,
  321. int mc_count, struct dev_addr_list *mclist)
  322. {
  323. struct lbtf_private *priv = hw->priv;
  324. int i;
  325. if (!mc_count || mc_count > MRVDRV_MAX_MULTICAST_LIST_SIZE)
  326. return mc_count;
  327. priv->nr_of_multicastmacaddr = mc_count;
  328. for (i = 0; i < mc_count; i++) {
  329. if (!mclist)
  330. break;
  331. memcpy(&priv->multicastlist[i], mclist->da_addr,
  332. ETH_ALEN);
  333. mclist = mclist->next;
  334. }
  335. return mc_count;
  336. }
  337. #define SUPPORTED_FIF_FLAGS (FIF_PROMISC_IN_BSS | FIF_ALLMULTI)
  338. static void lbtf_op_configure_filter(struct ieee80211_hw *hw,
  339. unsigned int changed_flags,
  340. unsigned int *new_flags,
  341. u64 multicast)
  342. {
  343. struct lbtf_private *priv = hw->priv;
  344. int old_mac_control = priv->mac_control;
  345. changed_flags &= SUPPORTED_FIF_FLAGS;
  346. *new_flags &= SUPPORTED_FIF_FLAGS;
  347. if (!changed_flags)
  348. return;
  349. if (*new_flags & (FIF_PROMISC_IN_BSS))
  350. priv->mac_control |= CMD_ACT_MAC_PROMISCUOUS_ENABLE;
  351. else
  352. priv->mac_control &= ~CMD_ACT_MAC_PROMISCUOUS_ENABLE;
  353. if (*new_flags & (FIF_ALLMULTI) ||
  354. multicast > MRVDRV_MAX_MULTICAST_LIST_SIZE) {
  355. priv->mac_control |= CMD_ACT_MAC_ALL_MULTICAST_ENABLE;
  356. priv->mac_control &= ~CMD_ACT_MAC_MULTICAST_ENABLE;
  357. } else if (multicast) {
  358. priv->mac_control |= CMD_ACT_MAC_MULTICAST_ENABLE;
  359. priv->mac_control &= ~CMD_ACT_MAC_ALL_MULTICAST_ENABLE;
  360. lbtf_cmd_set_mac_multicast_addr(priv);
  361. } else {
  362. priv->mac_control &= ~(CMD_ACT_MAC_MULTICAST_ENABLE |
  363. CMD_ACT_MAC_ALL_MULTICAST_ENABLE);
  364. if (priv->nr_of_multicastmacaddr) {
  365. priv->nr_of_multicastmacaddr = 0;
  366. lbtf_cmd_set_mac_multicast_addr(priv);
  367. }
  368. }
  369. if (priv->mac_control != old_mac_control)
  370. lbtf_set_mac_control(priv);
  371. }
  372. static void lbtf_op_bss_info_changed(struct ieee80211_hw *hw,
  373. struct ieee80211_vif *vif,
  374. struct ieee80211_bss_conf *bss_conf,
  375. u32 changes)
  376. {
  377. struct lbtf_private *priv = hw->priv;
  378. struct sk_buff *beacon;
  379. if (changes & (BSS_CHANGED_BEACON | BSS_CHANGED_BEACON_INT)) {
  380. switch (priv->vif->type) {
  381. case NL80211_IFTYPE_AP:
  382. case NL80211_IFTYPE_MESH_POINT:
  383. beacon = ieee80211_beacon_get(hw, vif);
  384. if (beacon) {
  385. lbtf_beacon_set(priv, beacon);
  386. kfree_skb(beacon);
  387. lbtf_beacon_ctrl(priv, 1,
  388. bss_conf->beacon_int);
  389. }
  390. break;
  391. default:
  392. break;
  393. }
  394. }
  395. if (changes & BSS_CHANGED_BSSID) {
  396. bool activate = !is_zero_ether_addr(bss_conf->bssid);
  397. lbtf_set_bssid(priv, activate, bss_conf->bssid);
  398. }
  399. if (changes & BSS_CHANGED_ERP_PREAMBLE) {
  400. if (bss_conf->use_short_preamble)
  401. priv->preamble = CMD_TYPE_SHORT_PREAMBLE;
  402. else
  403. priv->preamble = CMD_TYPE_LONG_PREAMBLE;
  404. lbtf_set_radio_control(priv);
  405. }
  406. }
  407. static const struct ieee80211_ops lbtf_ops = {
  408. .tx = lbtf_op_tx,
  409. .start = lbtf_op_start,
  410. .stop = lbtf_op_stop,
  411. .add_interface = lbtf_op_add_interface,
  412. .remove_interface = lbtf_op_remove_interface,
  413. .config = lbtf_op_config,
  414. .prepare_multicast = lbtf_op_prepare_multicast,
  415. .configure_filter = lbtf_op_configure_filter,
  416. .bss_info_changed = lbtf_op_bss_info_changed,
  417. };
  418. int lbtf_rx(struct lbtf_private *priv, struct sk_buff *skb)
  419. {
  420. struct ieee80211_rx_status stats;
  421. struct rxpd *prxpd;
  422. int need_padding;
  423. unsigned int flags;
  424. struct ieee80211_hdr *hdr;
  425. prxpd = (struct rxpd *) skb->data;
  426. stats.flag = 0;
  427. if (!(prxpd->status & cpu_to_le16(MRVDRV_RXPD_STATUS_OK)))
  428. stats.flag |= RX_FLAG_FAILED_FCS_CRC;
  429. stats.freq = priv->cur_freq;
  430. stats.band = IEEE80211_BAND_2GHZ;
  431. stats.signal = prxpd->snr;
  432. stats.noise = prxpd->nf;
  433. /* Marvell rate index has a hole at value 4 */
  434. if (prxpd->rx_rate > 4)
  435. --prxpd->rx_rate;
  436. stats.rate_idx = prxpd->rx_rate;
  437. skb_pull(skb, sizeof(struct rxpd));
  438. hdr = (struct ieee80211_hdr *)skb->data;
  439. flags = le32_to_cpu(*(__le32 *)(skb->data + 4));
  440. need_padding = ieee80211_is_data_qos(hdr->frame_control);
  441. need_padding ^= ieee80211_has_a4(hdr->frame_control);
  442. need_padding ^= ieee80211_is_data_qos(hdr->frame_control) &&
  443. (*ieee80211_get_qos_ctl(hdr) &
  444. IEEE80211_QOS_CONTROL_A_MSDU_PRESENT);
  445. if (need_padding) {
  446. memmove(skb->data + 2, skb->data, skb->len);
  447. skb_reserve(skb, 2);
  448. }
  449. memcpy(IEEE80211_SKB_RXCB(skb), &stats, sizeof(stats));
  450. ieee80211_rx_irqsafe(priv->hw, skb);
  451. return 0;
  452. }
  453. EXPORT_SYMBOL_GPL(lbtf_rx);
  454. /**
  455. * lbtf_add_card: Add and initialize the card, no fw upload yet.
  456. *
  457. * @card A pointer to card
  458. *
  459. * Returns: pointer to struct lbtf_priv.
  460. */
  461. struct lbtf_private *lbtf_add_card(void *card, struct device *dmdev)
  462. {
  463. struct ieee80211_hw *hw;
  464. struct lbtf_private *priv = NULL;
  465. hw = ieee80211_alloc_hw(sizeof(struct lbtf_private), &lbtf_ops);
  466. if (!hw)
  467. goto done;
  468. priv = hw->priv;
  469. if (lbtf_init_adapter(priv))
  470. goto err_init_adapter;
  471. priv->hw = hw;
  472. priv->card = card;
  473. priv->tx_skb = NULL;
  474. hw->queues = 1;
  475. hw->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING;
  476. hw->extra_tx_headroom = sizeof(struct txpd);
  477. memcpy(priv->channels, lbtf_channels, sizeof(lbtf_channels));
  478. memcpy(priv->rates, lbtf_rates, sizeof(lbtf_rates));
  479. priv->band.n_bitrates = ARRAY_SIZE(lbtf_rates);
  480. priv->band.bitrates = priv->rates;
  481. priv->band.n_channels = ARRAY_SIZE(lbtf_channels);
  482. priv->band.channels = priv->channels;
  483. hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &priv->band;
  484. hw->wiphy->interface_modes =
  485. BIT(NL80211_IFTYPE_STATION) |
  486. BIT(NL80211_IFTYPE_ADHOC);
  487. skb_queue_head_init(&priv->bc_ps_buf);
  488. SET_IEEE80211_DEV(hw, dmdev);
  489. INIT_WORK(&priv->cmd_work, lbtf_cmd_work);
  490. INIT_WORK(&priv->tx_work, lbtf_tx_work);
  491. if (ieee80211_register_hw(hw))
  492. goto err_init_adapter;
  493. goto done;
  494. err_init_adapter:
  495. lbtf_free_adapter(priv);
  496. ieee80211_free_hw(hw);
  497. priv = NULL;
  498. done:
  499. return priv;
  500. }
  501. EXPORT_SYMBOL_GPL(lbtf_add_card);
  502. int lbtf_remove_card(struct lbtf_private *priv)
  503. {
  504. struct ieee80211_hw *hw = priv->hw;
  505. priv->surpriseremoved = 1;
  506. del_timer(&priv->command_timer);
  507. lbtf_free_adapter(priv);
  508. priv->hw = NULL;
  509. ieee80211_unregister_hw(hw);
  510. ieee80211_free_hw(hw);
  511. return 0;
  512. }
  513. EXPORT_SYMBOL_GPL(lbtf_remove_card);
  514. void lbtf_send_tx_feedback(struct lbtf_private *priv, u8 retrycnt, u8 fail)
  515. {
  516. struct ieee80211_tx_info *info = IEEE80211_SKB_CB(priv->tx_skb);
  517. ieee80211_tx_info_clear_status(info);
  518. /*
  519. * Commented out, otherwise we never go beyond 1Mbit/s using mac80211
  520. * default pid rc algorithm.
  521. *
  522. * info->status.retry_count = MRVL_DEFAULT_RETRIES - retrycnt;
  523. */
  524. if (!(info->flags & IEEE80211_TX_CTL_NO_ACK) && !fail)
  525. info->flags |= IEEE80211_TX_STAT_ACK;
  526. skb_pull(priv->tx_skb, sizeof(struct txpd));
  527. ieee80211_tx_status_irqsafe(priv->hw, priv->tx_skb);
  528. priv->tx_skb = NULL;
  529. if (!priv->skb_to_tx && skb_queue_empty(&priv->bc_ps_buf))
  530. ieee80211_wake_queues(priv->hw);
  531. else
  532. queue_work(lbtf_wq, &priv->tx_work);
  533. }
  534. EXPORT_SYMBOL_GPL(lbtf_send_tx_feedback);
  535. void lbtf_bcn_sent(struct lbtf_private *priv)
  536. {
  537. struct sk_buff *skb = NULL;
  538. if (priv->vif->type != NL80211_IFTYPE_AP)
  539. return;
  540. if (skb_queue_empty(&priv->bc_ps_buf)) {
  541. bool tx_buff_bc = 0;
  542. while ((skb = ieee80211_get_buffered_bc(priv->hw, priv->vif))) {
  543. skb_queue_tail(&priv->bc_ps_buf, skb);
  544. tx_buff_bc = 1;
  545. }
  546. if (tx_buff_bc) {
  547. ieee80211_stop_queues(priv->hw);
  548. queue_work(lbtf_wq, &priv->tx_work);
  549. }
  550. }
  551. skb = ieee80211_beacon_get(priv->hw, priv->vif);
  552. if (skb) {
  553. lbtf_beacon_set(priv, skb);
  554. kfree_skb(skb);
  555. }
  556. }
  557. EXPORT_SYMBOL_GPL(lbtf_bcn_sent);
  558. static int __init lbtf_init_module(void)
  559. {
  560. lbtf_wq = create_workqueue("libertastf");
  561. if (lbtf_wq == NULL) {
  562. printk(KERN_ERR "libertastf: couldn't create workqueue\n");
  563. return -ENOMEM;
  564. }
  565. return 0;
  566. }
  567. static void __exit lbtf_exit_module(void)
  568. {
  569. destroy_workqueue(lbtf_wq);
  570. }
  571. module_init(lbtf_init_module);
  572. module_exit(lbtf_exit_module);
  573. MODULE_DESCRIPTION("Libertas WLAN Thinfirm Driver Library");
  574. MODULE_AUTHOR("Cozybit Inc.");
  575. MODULE_LICENSE("GPL");