main.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  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 u64 lbtf_op_prepare_multicast(struct ieee80211_hw *hw,
  320. int mc_count, struct dev_addr_list *mclist)
  321. {
  322. struct lbtf_private *priv = hw->priv;
  323. int i;
  324. if (!mc_count || mc_count > MRVDRV_MAX_MULTICAST_LIST_SIZE)
  325. return mc_count;
  326. priv->nr_of_multicastmacaddr = mc_count;
  327. for (i = 0; i < mc_count; i++) {
  328. if (!mclist)
  329. break;
  330. memcpy(&priv->multicastlist[i], mclist->da_addr,
  331. ETH_ALEN);
  332. mclist = mclist->next;
  333. }
  334. return mc_count;
  335. }
  336. #define SUPPORTED_FIF_FLAGS (FIF_PROMISC_IN_BSS | FIF_ALLMULTI)
  337. static void lbtf_op_configure_filter(struct ieee80211_hw *hw,
  338. unsigned int changed_flags,
  339. unsigned int *new_flags,
  340. u64 multicast)
  341. {
  342. struct lbtf_private *priv = hw->priv;
  343. int old_mac_control = priv->mac_control;
  344. changed_flags &= SUPPORTED_FIF_FLAGS;
  345. *new_flags &= SUPPORTED_FIF_FLAGS;
  346. if (!changed_flags)
  347. return;
  348. if (*new_flags & (FIF_PROMISC_IN_BSS))
  349. priv->mac_control |= CMD_ACT_MAC_PROMISCUOUS_ENABLE;
  350. else
  351. priv->mac_control &= ~CMD_ACT_MAC_PROMISCUOUS_ENABLE;
  352. if (*new_flags & (FIF_ALLMULTI) ||
  353. multicast > MRVDRV_MAX_MULTICAST_LIST_SIZE) {
  354. priv->mac_control |= CMD_ACT_MAC_ALL_MULTICAST_ENABLE;
  355. priv->mac_control &= ~CMD_ACT_MAC_MULTICAST_ENABLE;
  356. } else if (multicast) {
  357. priv->mac_control |= CMD_ACT_MAC_MULTICAST_ENABLE;
  358. priv->mac_control &= ~CMD_ACT_MAC_ALL_MULTICAST_ENABLE;
  359. lbtf_cmd_set_mac_multicast_addr(priv);
  360. } else {
  361. priv->mac_control &= ~(CMD_ACT_MAC_MULTICAST_ENABLE |
  362. CMD_ACT_MAC_ALL_MULTICAST_ENABLE);
  363. if (priv->nr_of_multicastmacaddr) {
  364. priv->nr_of_multicastmacaddr = 0;
  365. lbtf_cmd_set_mac_multicast_addr(priv);
  366. }
  367. }
  368. if (priv->mac_control != old_mac_control)
  369. lbtf_set_mac_control(priv);
  370. }
  371. static void lbtf_op_bss_info_changed(struct ieee80211_hw *hw,
  372. struct ieee80211_vif *vif,
  373. struct ieee80211_bss_conf *bss_conf,
  374. u32 changes)
  375. {
  376. struct lbtf_private *priv = hw->priv;
  377. struct sk_buff *beacon;
  378. if (changes & (BSS_CHANGED_BEACON | BSS_CHANGED_BEACON_INT)) {
  379. switch (priv->vif->type) {
  380. case NL80211_IFTYPE_AP:
  381. case NL80211_IFTYPE_MESH_POINT:
  382. beacon = ieee80211_beacon_get(hw, vif);
  383. if (beacon) {
  384. lbtf_beacon_set(priv, beacon);
  385. kfree_skb(beacon);
  386. lbtf_beacon_ctrl(priv, 1,
  387. bss_conf->beacon_int);
  388. }
  389. break;
  390. default:
  391. break;
  392. }
  393. }
  394. if (changes & BSS_CHANGED_BSSID) {
  395. bool activate = !is_zero_ether_addr(bss_conf->bssid);
  396. lbtf_set_bssid(priv, activate, bss_conf->bssid);
  397. }
  398. if (changes & BSS_CHANGED_ERP_PREAMBLE) {
  399. if (bss_conf->use_short_preamble)
  400. priv->preamble = CMD_TYPE_SHORT_PREAMBLE;
  401. else
  402. priv->preamble = CMD_TYPE_LONG_PREAMBLE;
  403. lbtf_set_radio_control(priv);
  404. }
  405. }
  406. static const struct ieee80211_ops lbtf_ops = {
  407. .tx = lbtf_op_tx,
  408. .start = lbtf_op_start,
  409. .stop = lbtf_op_stop,
  410. .add_interface = lbtf_op_add_interface,
  411. .remove_interface = lbtf_op_remove_interface,
  412. .config = lbtf_op_config,
  413. .prepare_multicast = lbtf_op_prepare_multicast,
  414. .configure_filter = lbtf_op_configure_filter,
  415. .bss_info_changed = lbtf_op_bss_info_changed,
  416. };
  417. int lbtf_rx(struct lbtf_private *priv, struct sk_buff *skb)
  418. {
  419. struct ieee80211_rx_status stats;
  420. struct rxpd *prxpd;
  421. int need_padding;
  422. unsigned int flags;
  423. struct ieee80211_hdr *hdr;
  424. prxpd = (struct rxpd *) skb->data;
  425. stats.flag = 0;
  426. if (!(prxpd->status & cpu_to_le16(MRVDRV_RXPD_STATUS_OK)))
  427. stats.flag |= RX_FLAG_FAILED_FCS_CRC;
  428. stats.freq = priv->cur_freq;
  429. stats.band = IEEE80211_BAND_2GHZ;
  430. stats.signal = prxpd->snr;
  431. stats.noise = prxpd->nf;
  432. stats.qual = prxpd->snr - 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. skb_queue_head_init(&priv->bc_ps_buf);
  485. SET_IEEE80211_DEV(hw, dmdev);
  486. INIT_WORK(&priv->cmd_work, lbtf_cmd_work);
  487. INIT_WORK(&priv->tx_work, lbtf_tx_work);
  488. if (ieee80211_register_hw(hw))
  489. goto err_init_adapter;
  490. goto done;
  491. err_init_adapter:
  492. lbtf_free_adapter(priv);
  493. ieee80211_free_hw(hw);
  494. priv = NULL;
  495. done:
  496. return priv;
  497. }
  498. EXPORT_SYMBOL_GPL(lbtf_add_card);
  499. int lbtf_remove_card(struct lbtf_private *priv)
  500. {
  501. struct ieee80211_hw *hw = priv->hw;
  502. priv->surpriseremoved = 1;
  503. del_timer(&priv->command_timer);
  504. lbtf_free_adapter(priv);
  505. priv->hw = NULL;
  506. ieee80211_unregister_hw(hw);
  507. ieee80211_free_hw(hw);
  508. return 0;
  509. }
  510. EXPORT_SYMBOL_GPL(lbtf_remove_card);
  511. void lbtf_send_tx_feedback(struct lbtf_private *priv, u8 retrycnt, u8 fail)
  512. {
  513. struct ieee80211_tx_info *info = IEEE80211_SKB_CB(priv->tx_skb);
  514. ieee80211_tx_info_clear_status(info);
  515. /*
  516. * Commented out, otherwise we never go beyond 1Mbit/s using mac80211
  517. * default pid rc algorithm.
  518. *
  519. * info->status.retry_count = MRVL_DEFAULT_RETRIES - retrycnt;
  520. */
  521. if (!(info->flags & IEEE80211_TX_CTL_NO_ACK) && !fail)
  522. info->flags |= IEEE80211_TX_STAT_ACK;
  523. skb_pull(priv->tx_skb, sizeof(struct txpd));
  524. ieee80211_tx_status_irqsafe(priv->hw, priv->tx_skb);
  525. priv->tx_skb = NULL;
  526. if (!priv->skb_to_tx && skb_queue_empty(&priv->bc_ps_buf))
  527. ieee80211_wake_queues(priv->hw);
  528. else
  529. queue_work(lbtf_wq, &priv->tx_work);
  530. }
  531. EXPORT_SYMBOL_GPL(lbtf_send_tx_feedback);
  532. void lbtf_bcn_sent(struct lbtf_private *priv)
  533. {
  534. struct sk_buff *skb = NULL;
  535. if (priv->vif->type != NL80211_IFTYPE_AP)
  536. return;
  537. if (skb_queue_empty(&priv->bc_ps_buf)) {
  538. bool tx_buff_bc = 0;
  539. while ((skb = ieee80211_get_buffered_bc(priv->hw, priv->vif))) {
  540. skb_queue_tail(&priv->bc_ps_buf, skb);
  541. tx_buff_bc = 1;
  542. }
  543. if (tx_buff_bc) {
  544. ieee80211_stop_queues(priv->hw);
  545. queue_work(lbtf_wq, &priv->tx_work);
  546. }
  547. }
  548. skb = ieee80211_beacon_get(priv->hw, priv->vif);
  549. if (skb) {
  550. lbtf_beacon_set(priv, skb);
  551. kfree_skb(skb);
  552. }
  553. }
  554. EXPORT_SYMBOL_GPL(lbtf_bcn_sent);
  555. static int __init lbtf_init_module(void)
  556. {
  557. lbtf_wq = create_workqueue("libertastf");
  558. if (lbtf_wq == NULL) {
  559. printk(KERN_ERR "libertastf: couldn't create workqueue\n");
  560. return -ENOMEM;
  561. }
  562. return 0;
  563. }
  564. static void __exit lbtf_exit_module(void)
  565. {
  566. destroy_workqueue(lbtf_wq);
  567. }
  568. module_init(lbtf_init_module);
  569. module_exit(lbtf_exit_module);
  570. MODULE_DESCRIPTION("Libertas WLAN Thinfirm Driver Library");
  571. MODULE_AUTHOR("Cozybit Inc.");
  572. MODULE_LICENSE("GPL");