main.c 16 KB

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