iwl-tx.c 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2003 - 2008 Intel Corporation. All rights reserved.
  4. *
  5. * Portions of this file are derived from the ipw3945 project, as well
  6. * as portions of the ieee80211 subsystem header files.
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of version 2 of the GNU General Public License as
  10. * published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful, but WITHOUT
  13. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  15. * more details.
  16. *
  17. * You should have received a copy of the GNU General Public License along with
  18. * this program; if not, write to the Free Software Foundation, Inc.,
  19. * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  20. *
  21. * The full GNU General Public License is included in this distribution in the
  22. * file called LICENSE.
  23. *
  24. * Contact Information:
  25. * James P. Ketrenos <ipw2100-admin@linux.intel.com>
  26. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  27. *
  28. *****************************************************************************/
  29. #include <linux/etherdevice.h>
  30. #include <net/mac80211.h>
  31. #include "iwl-eeprom.h"
  32. #include "iwl-dev.h"
  33. #include "iwl-core.h"
  34. #include "iwl-sta.h"
  35. #include "iwl-io.h"
  36. #include "iwl-helpers.h"
  37. static const u16 default_tid_to_tx_fifo[] = {
  38. IWL_TX_FIFO_AC1,
  39. IWL_TX_FIFO_AC0,
  40. IWL_TX_FIFO_AC0,
  41. IWL_TX_FIFO_AC1,
  42. IWL_TX_FIFO_AC2,
  43. IWL_TX_FIFO_AC2,
  44. IWL_TX_FIFO_AC3,
  45. IWL_TX_FIFO_AC3,
  46. IWL_TX_FIFO_NONE,
  47. IWL_TX_FIFO_NONE,
  48. IWL_TX_FIFO_NONE,
  49. IWL_TX_FIFO_NONE,
  50. IWL_TX_FIFO_NONE,
  51. IWL_TX_FIFO_NONE,
  52. IWL_TX_FIFO_NONE,
  53. IWL_TX_FIFO_NONE,
  54. IWL_TX_FIFO_AC3
  55. };
  56. static inline dma_addr_t iwl_tfd_tb_get_addr(struct iwl_tfd *tfd, u8 idx)
  57. {
  58. struct iwl_tfd_tb *tb = &tfd->tbs[idx];
  59. dma_addr_t addr = get_unaligned_le32(&tb->lo);
  60. if (sizeof(dma_addr_t) > sizeof(u32))
  61. addr |=
  62. ((dma_addr_t)(le16_to_cpu(tb->hi_n_len) & 0xF) << 16) << 16;
  63. return addr;
  64. }
  65. static inline u16 iwl_tfd_tb_get_len(struct iwl_tfd *tfd, u8 idx)
  66. {
  67. struct iwl_tfd_tb *tb = &tfd->tbs[idx];
  68. return le16_to_cpu(tb->hi_n_len) >> 4;
  69. }
  70. static inline void iwl_tfd_set_tb(struct iwl_tfd *tfd, u8 idx,
  71. dma_addr_t addr, u16 len)
  72. {
  73. struct iwl_tfd_tb *tb = &tfd->tbs[idx];
  74. u16 hi_n_len = len << 4;
  75. put_unaligned_le32(addr, &tb->lo);
  76. if (sizeof(dma_addr_t) > sizeof(u32))
  77. hi_n_len |= ((addr >> 16) >> 16) & 0xF;
  78. tb->hi_n_len = cpu_to_le16(hi_n_len);
  79. tfd->num_tbs = idx + 1;
  80. }
  81. static inline u8 iwl_tfd_get_num_tbs(struct iwl_tfd *tfd)
  82. {
  83. return tfd->num_tbs & 0x1f;
  84. }
  85. /**
  86. * iwl_hw_txq_free_tfd - Free all chunks referenced by TFD [txq->q.read_ptr]
  87. * @priv - driver private data
  88. * @txq - tx queue
  89. *
  90. * Does NOT advance any TFD circular buffer read/write indexes
  91. * Does NOT free the TFD itself (which is within circular buffer)
  92. */
  93. static void iwl_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq)
  94. {
  95. struct iwl_tfd *tfd_tmp = (struct iwl_tfd *)&txq->tfds[0];
  96. struct iwl_tfd *tfd;
  97. struct pci_dev *dev = priv->pci_dev;
  98. int index = txq->q.read_ptr;
  99. int i;
  100. int num_tbs;
  101. tfd = &tfd_tmp[index];
  102. /* Sanity check on number of chunks */
  103. num_tbs = iwl_tfd_get_num_tbs(tfd);
  104. if (num_tbs >= IWL_NUM_OF_TBS) {
  105. IWL_ERROR("Too many chunks: %i\n", num_tbs);
  106. /* @todo issue fatal error, it is quite serious situation */
  107. return;
  108. }
  109. /* Unmap tx_cmd */
  110. if (num_tbs)
  111. pci_unmap_single(dev,
  112. pci_unmap_addr(&txq->cmd[index]->meta, mapping),
  113. pci_unmap_len(&txq->cmd[index]->meta, len),
  114. PCI_DMA_TODEVICE);
  115. /* Unmap chunks, if any. */
  116. for (i = 1; i < num_tbs; i++) {
  117. pci_unmap_single(dev, iwl_tfd_tb_get_addr(tfd, i),
  118. iwl_tfd_tb_get_len(tfd, i), PCI_DMA_TODEVICE);
  119. if (txq->txb) {
  120. dev_kfree_skb(txq->txb[txq->q.read_ptr].skb[i - 1]);
  121. txq->txb[txq->q.read_ptr].skb[i - 1] = NULL;
  122. }
  123. }
  124. }
  125. static int iwl_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv,
  126. struct iwl_tfd *tfd,
  127. dma_addr_t addr, u16 len)
  128. {
  129. u32 num_tbs = iwl_tfd_get_num_tbs(tfd);
  130. /* Each TFD can point to a maximum 20 Tx buffers */
  131. if (num_tbs >= IWL_NUM_OF_TBS) {
  132. IWL_ERROR("Error can not send more than %d chunks\n",
  133. IWL_NUM_OF_TBS);
  134. return -EINVAL;
  135. }
  136. BUG_ON(addr & ~DMA_BIT_MASK(36));
  137. if (unlikely(addr & ~IWL_TX_DMA_MASK))
  138. IWL_ERROR("Unaligned address = %llx\n",
  139. (unsigned long long)addr);
  140. iwl_tfd_set_tb(tfd, num_tbs, addr, len);
  141. return 0;
  142. }
  143. /**
  144. * iwl_txq_update_write_ptr - Send new write index to hardware
  145. */
  146. int iwl_txq_update_write_ptr(struct iwl_priv *priv, struct iwl_tx_queue *txq)
  147. {
  148. u32 reg = 0;
  149. int ret = 0;
  150. int txq_id = txq->q.id;
  151. if (txq->need_update == 0)
  152. return ret;
  153. /* if we're trying to save power */
  154. if (test_bit(STATUS_POWER_PMI, &priv->status)) {
  155. /* wake up nic if it's powered down ...
  156. * uCode will wake up, and interrupt us again, so next
  157. * time we'll skip this part. */
  158. reg = iwl_read32(priv, CSR_UCODE_DRV_GP1);
  159. if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) {
  160. IWL_DEBUG_INFO("Requesting wakeup, GP1 = 0x%x\n", reg);
  161. iwl_set_bit(priv, CSR_GP_CNTRL,
  162. CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
  163. return ret;
  164. }
  165. /* restore this queue's parameters in nic hardware. */
  166. ret = iwl_grab_nic_access(priv);
  167. if (ret)
  168. return ret;
  169. iwl_write_direct32(priv, HBUS_TARG_WRPTR,
  170. txq->q.write_ptr | (txq_id << 8));
  171. iwl_release_nic_access(priv);
  172. /* else not in power-save mode, uCode will never sleep when we're
  173. * trying to tx (during RFKILL, we're not trying to tx). */
  174. } else
  175. iwl_write32(priv, HBUS_TARG_WRPTR,
  176. txq->q.write_ptr | (txq_id << 8));
  177. txq->need_update = 0;
  178. return ret;
  179. }
  180. EXPORT_SYMBOL(iwl_txq_update_write_ptr);
  181. /**
  182. * iwl_tx_queue_free - Deallocate DMA queue.
  183. * @txq: Transmit queue to deallocate.
  184. *
  185. * Empty queue by removing and destroying all BD's.
  186. * Free all buffers.
  187. * 0-fill, but do not free "txq" descriptor structure.
  188. */
  189. static void iwl_tx_queue_free(struct iwl_priv *priv, int txq_id)
  190. {
  191. struct iwl_tx_queue *txq = &priv->txq[txq_id];
  192. struct iwl_queue *q = &txq->q;
  193. struct pci_dev *dev = priv->pci_dev;
  194. int i, len;
  195. if (q->n_bd == 0)
  196. return;
  197. /* first, empty all BD's */
  198. for (; q->write_ptr != q->read_ptr;
  199. q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd))
  200. iwl_hw_txq_free_tfd(priv, txq);
  201. len = sizeof(struct iwl_cmd) * q->n_window;
  202. /* De-alloc array of command/tx buffers */
  203. for (i = 0; i < TFD_TX_CMD_SLOTS; i++)
  204. kfree(txq->cmd[i]);
  205. /* De-alloc circular buffer of TFDs */
  206. if (txq->q.n_bd)
  207. pci_free_consistent(dev, sizeof(struct iwl_tfd) *
  208. txq->q.n_bd, txq->tfds, txq->q.dma_addr);
  209. /* De-alloc array of per-TFD driver data */
  210. kfree(txq->txb);
  211. txq->txb = NULL;
  212. /* 0-fill queue descriptor structure */
  213. memset(txq, 0, sizeof(*txq));
  214. }
  215. /**
  216. * iwl_cmd_queue_free - Deallocate DMA queue.
  217. * @txq: Transmit queue to deallocate.
  218. *
  219. * Empty queue by removing and destroying all BD's.
  220. * Free all buffers.
  221. * 0-fill, but do not free "txq" descriptor structure.
  222. */
  223. static void iwl_cmd_queue_free(struct iwl_priv *priv)
  224. {
  225. struct iwl_tx_queue *txq = &priv->txq[IWL_CMD_QUEUE_NUM];
  226. struct iwl_queue *q = &txq->q;
  227. struct pci_dev *dev = priv->pci_dev;
  228. int i, len;
  229. if (q->n_bd == 0)
  230. return;
  231. len = sizeof(struct iwl_cmd) * q->n_window;
  232. len += IWL_MAX_SCAN_SIZE;
  233. /* De-alloc array of command/tx buffers */
  234. for (i = 0; i <= TFD_CMD_SLOTS; i++)
  235. kfree(txq->cmd[i]);
  236. /* De-alloc circular buffer of TFDs */
  237. if (txq->q.n_bd)
  238. pci_free_consistent(dev, sizeof(struct iwl_tfd) *
  239. txq->q.n_bd, txq->tfds, txq->q.dma_addr);
  240. /* 0-fill queue descriptor structure */
  241. memset(txq, 0, sizeof(*txq));
  242. }
  243. /*************** DMA-QUEUE-GENERAL-FUNCTIONS *****
  244. * DMA services
  245. *
  246. * Theory of operation
  247. *
  248. * A Tx or Rx queue resides in host DRAM, and is comprised of a circular buffer
  249. * of buffer descriptors, each of which points to one or more data buffers for
  250. * the device to read from or fill. Driver and device exchange status of each
  251. * queue via "read" and "write" pointers. Driver keeps minimum of 2 empty
  252. * entries in each circular buffer, to protect against confusing empty and full
  253. * queue states.
  254. *
  255. * The device reads or writes the data in the queues via the device's several
  256. * DMA/FIFO channels. Each queue is mapped to a single DMA channel.
  257. *
  258. * For Tx queue, there are low mark and high mark limits. If, after queuing
  259. * the packet for Tx, free space become < low mark, Tx queue stopped. When
  260. * reclaiming packets (on 'tx done IRQ), if free space become > high mark,
  261. * Tx queue resumed.
  262. *
  263. * See more detailed info in iwl-4965-hw.h.
  264. ***************************************************/
  265. int iwl_queue_space(const struct iwl_queue *q)
  266. {
  267. int s = q->read_ptr - q->write_ptr;
  268. if (q->read_ptr > q->write_ptr)
  269. s -= q->n_bd;
  270. if (s <= 0)
  271. s += q->n_window;
  272. /* keep some reserve to not confuse empty and full situations */
  273. s -= 2;
  274. if (s < 0)
  275. s = 0;
  276. return s;
  277. }
  278. EXPORT_SYMBOL(iwl_queue_space);
  279. /**
  280. * iwl_queue_init - Initialize queue's high/low-water and read/write indexes
  281. */
  282. static int iwl_queue_init(struct iwl_priv *priv, struct iwl_queue *q,
  283. int count, int slots_num, u32 id)
  284. {
  285. q->n_bd = count;
  286. q->n_window = slots_num;
  287. q->id = id;
  288. /* count must be power-of-two size, otherwise iwl_queue_inc_wrap
  289. * and iwl_queue_dec_wrap are broken. */
  290. BUG_ON(!is_power_of_2(count));
  291. /* slots_num must be power-of-two size, otherwise
  292. * get_cmd_index is broken. */
  293. BUG_ON(!is_power_of_2(slots_num));
  294. q->low_mark = q->n_window / 4;
  295. if (q->low_mark < 4)
  296. q->low_mark = 4;
  297. q->high_mark = q->n_window / 8;
  298. if (q->high_mark < 2)
  299. q->high_mark = 2;
  300. q->write_ptr = q->read_ptr = 0;
  301. return 0;
  302. }
  303. /**
  304. * iwl_tx_queue_alloc - Alloc driver data and TFD CB for one Tx/cmd queue
  305. */
  306. static int iwl_tx_queue_alloc(struct iwl_priv *priv,
  307. struct iwl_tx_queue *txq, u32 id)
  308. {
  309. struct pci_dev *dev = priv->pci_dev;
  310. /* Driver private data, only for Tx (not command) queues,
  311. * not shared with device. */
  312. if (id != IWL_CMD_QUEUE_NUM) {
  313. txq->txb = kmalloc(sizeof(txq->txb[0]) *
  314. TFD_QUEUE_SIZE_MAX, GFP_KERNEL);
  315. if (!txq->txb) {
  316. IWL_ERROR("kmalloc for auxiliary BD "
  317. "structures failed\n");
  318. goto error;
  319. }
  320. } else
  321. txq->txb = NULL;
  322. /* Circular buffer of transmit frame descriptors (TFDs),
  323. * shared with device */
  324. txq->tfds = pci_alloc_consistent(dev,
  325. sizeof(txq->tfds[0]) * TFD_QUEUE_SIZE_MAX,
  326. &txq->q.dma_addr);
  327. if (!txq->tfds) {
  328. IWL_ERROR("pci_alloc_consistent(%zd) failed\n",
  329. sizeof(txq->tfds[0]) * TFD_QUEUE_SIZE_MAX);
  330. goto error;
  331. }
  332. txq->q.id = id;
  333. return 0;
  334. error:
  335. kfree(txq->txb);
  336. txq->txb = NULL;
  337. return -ENOMEM;
  338. }
  339. /*
  340. * Tell nic where to find circular buffer of Tx Frame Descriptors for
  341. * given Tx queue, and enable the DMA channel used for that queue.
  342. *
  343. * 4965 supports up to 16 Tx queues in DRAM, mapped to up to 8 Tx DMA
  344. * channels supported in hardware.
  345. */
  346. static int iwl_hw_tx_queue_init(struct iwl_priv *priv,
  347. struct iwl_tx_queue *txq)
  348. {
  349. int ret;
  350. unsigned long flags;
  351. int txq_id = txq->q.id;
  352. spin_lock_irqsave(&priv->lock, flags);
  353. ret = iwl_grab_nic_access(priv);
  354. if (ret) {
  355. spin_unlock_irqrestore(&priv->lock, flags);
  356. return ret;
  357. }
  358. /* Circular buffer (TFD queue in DRAM) physical base address */
  359. iwl_write_direct32(priv, FH_MEM_CBBC_QUEUE(txq_id),
  360. txq->q.dma_addr >> 8);
  361. /* Enable DMA channel, using same id as for TFD queue */
  362. iwl_write_direct32(priv, FH_TCSR_CHNL_TX_CONFIG_REG(txq_id),
  363. FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE |
  364. FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL);
  365. iwl_release_nic_access(priv);
  366. spin_unlock_irqrestore(&priv->lock, flags);
  367. return 0;
  368. }
  369. /**
  370. * iwl_tx_queue_init - Allocate and initialize one tx/cmd queue
  371. */
  372. static int iwl_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq,
  373. int slots_num, u32 txq_id)
  374. {
  375. int i, len;
  376. int ret;
  377. /*
  378. * Alloc buffer array for commands (Tx or other types of commands).
  379. * For the command queue (#4), allocate command space + one big
  380. * command for scan, since scan command is very huge; the system will
  381. * not have two scans at the same time, so only one is needed.
  382. * For normal Tx queues (all other queues), no super-size command
  383. * space is needed.
  384. */
  385. len = sizeof(struct iwl_cmd);
  386. for (i = 0; i <= slots_num; i++) {
  387. if (i == slots_num) {
  388. if (txq_id == IWL_CMD_QUEUE_NUM)
  389. len += IWL_MAX_SCAN_SIZE;
  390. else
  391. continue;
  392. }
  393. txq->cmd[i] = kmalloc(len, GFP_KERNEL);
  394. if (!txq->cmd[i])
  395. goto err;
  396. }
  397. /* Alloc driver data array and TFD circular buffer */
  398. ret = iwl_tx_queue_alloc(priv, txq, txq_id);
  399. if (ret)
  400. goto err;
  401. txq->need_update = 0;
  402. /* TFD_QUEUE_SIZE_MAX must be power-of-two size, otherwise
  403. * iwl_queue_inc_wrap and iwl_queue_dec_wrap are broken. */
  404. BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1));
  405. /* Initialize queue's high/low-water marks, and head/tail indexes */
  406. iwl_queue_init(priv, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id);
  407. /* Tell device where to find queue */
  408. iwl_hw_tx_queue_init(priv, txq);
  409. return 0;
  410. err:
  411. for (i = 0; i < slots_num; i++) {
  412. kfree(txq->cmd[i]);
  413. txq->cmd[i] = NULL;
  414. }
  415. if (txq_id == IWL_CMD_QUEUE_NUM) {
  416. kfree(txq->cmd[slots_num]);
  417. txq->cmd[slots_num] = NULL;
  418. }
  419. return -ENOMEM;
  420. }
  421. /**
  422. * iwl_hw_txq_ctx_free - Free TXQ Context
  423. *
  424. * Destroy all TX DMA queues and structures
  425. */
  426. void iwl_hw_txq_ctx_free(struct iwl_priv *priv)
  427. {
  428. int txq_id;
  429. /* Tx queues */
  430. for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++)
  431. if (txq_id == IWL_CMD_QUEUE_NUM)
  432. iwl_cmd_queue_free(priv);
  433. else
  434. iwl_tx_queue_free(priv, txq_id);
  435. /* Keep-warm buffer */
  436. iwl_kw_free(priv);
  437. }
  438. EXPORT_SYMBOL(iwl_hw_txq_ctx_free);
  439. /**
  440. * iwl_txq_ctx_reset - Reset TX queue context
  441. * Destroys all DMA structures and initialise them again
  442. *
  443. * @param priv
  444. * @return error code
  445. */
  446. int iwl_txq_ctx_reset(struct iwl_priv *priv)
  447. {
  448. int ret = 0;
  449. int txq_id, slots_num;
  450. unsigned long flags;
  451. iwl_kw_free(priv);
  452. /* Free all tx/cmd queues and keep-warm buffer */
  453. iwl_hw_txq_ctx_free(priv);
  454. /* Alloc keep-warm buffer */
  455. ret = iwl_kw_alloc(priv);
  456. if (ret) {
  457. IWL_ERROR("Keep Warm allocation failed\n");
  458. goto error_kw;
  459. }
  460. spin_lock_irqsave(&priv->lock, flags);
  461. ret = iwl_grab_nic_access(priv);
  462. if (unlikely(ret)) {
  463. spin_unlock_irqrestore(&priv->lock, flags);
  464. goto error_reset;
  465. }
  466. /* Turn off all Tx DMA fifos */
  467. priv->cfg->ops->lib->txq_set_sched(priv, 0);
  468. iwl_release_nic_access(priv);
  469. spin_unlock_irqrestore(&priv->lock, flags);
  470. /* Tell nic where to find the keep-warm buffer */
  471. ret = iwl_kw_init(priv);
  472. if (ret) {
  473. IWL_ERROR("kw_init failed\n");
  474. goto error_reset;
  475. }
  476. /* Alloc and init all Tx queues, including the command queue (#4) */
  477. for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) {
  478. slots_num = (txq_id == IWL_CMD_QUEUE_NUM) ?
  479. TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS;
  480. ret = iwl_tx_queue_init(priv, &priv->txq[txq_id], slots_num,
  481. txq_id);
  482. if (ret) {
  483. IWL_ERROR("Tx %d queue init failed\n", txq_id);
  484. goto error;
  485. }
  486. }
  487. return ret;
  488. error:
  489. iwl_hw_txq_ctx_free(priv);
  490. error_reset:
  491. iwl_kw_free(priv);
  492. error_kw:
  493. return ret;
  494. }
  495. /**
  496. * iwl_txq_ctx_stop - Stop all Tx DMA channels, free Tx queue memory
  497. */
  498. void iwl_txq_ctx_stop(struct iwl_priv *priv)
  499. {
  500. int txq_id;
  501. unsigned long flags;
  502. /* Turn off all Tx DMA fifos */
  503. spin_lock_irqsave(&priv->lock, flags);
  504. if (iwl_grab_nic_access(priv)) {
  505. spin_unlock_irqrestore(&priv->lock, flags);
  506. return;
  507. }
  508. priv->cfg->ops->lib->txq_set_sched(priv, 0);
  509. /* Stop each Tx DMA channel, and wait for it to be idle */
  510. for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) {
  511. iwl_write_direct32(priv,
  512. FH_TCSR_CHNL_TX_CONFIG_REG(txq_id), 0x0);
  513. iwl_poll_direct_bit(priv, FH_TSSR_TX_STATUS_REG,
  514. FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE
  515. (txq_id), 200);
  516. }
  517. iwl_release_nic_access(priv);
  518. spin_unlock_irqrestore(&priv->lock, flags);
  519. /* Deallocate memory for all Tx queues */
  520. iwl_hw_txq_ctx_free(priv);
  521. }
  522. EXPORT_SYMBOL(iwl_txq_ctx_stop);
  523. /*
  524. * handle build REPLY_TX command notification.
  525. */
  526. static void iwl_tx_cmd_build_basic(struct iwl_priv *priv,
  527. struct iwl_tx_cmd *tx_cmd,
  528. struct ieee80211_tx_info *info,
  529. struct ieee80211_hdr *hdr,
  530. int is_unicast, u8 std_id)
  531. {
  532. __le16 fc = hdr->frame_control;
  533. __le32 tx_flags = tx_cmd->tx_flags;
  534. tx_cmd->stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE;
  535. if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) {
  536. tx_flags |= TX_CMD_FLG_ACK_MSK;
  537. if (ieee80211_is_mgmt(fc))
  538. tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK;
  539. if (ieee80211_is_probe_resp(fc) &&
  540. !(le16_to_cpu(hdr->seq_ctrl) & 0xf))
  541. tx_flags |= TX_CMD_FLG_TSF_MSK;
  542. } else {
  543. tx_flags &= (~TX_CMD_FLG_ACK_MSK);
  544. tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK;
  545. }
  546. if (ieee80211_is_back_req(fc))
  547. tx_flags |= TX_CMD_FLG_ACK_MSK | TX_CMD_FLG_IMM_BA_RSP_MASK;
  548. tx_cmd->sta_id = std_id;
  549. if (ieee80211_has_morefrags(fc))
  550. tx_flags |= TX_CMD_FLG_MORE_FRAG_MSK;
  551. if (ieee80211_is_data_qos(fc)) {
  552. u8 *qc = ieee80211_get_qos_ctl(hdr);
  553. tx_cmd->tid_tspec = qc[0] & 0xf;
  554. tx_flags &= ~TX_CMD_FLG_SEQ_CTL_MSK;
  555. } else {
  556. tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK;
  557. }
  558. priv->cfg->ops->utils->rts_tx_cmd_flag(info, &tx_flags);
  559. if ((tx_flags & TX_CMD_FLG_RTS_MSK) || (tx_flags & TX_CMD_FLG_CTS_MSK))
  560. tx_flags |= TX_CMD_FLG_FULL_TXOP_PROT_MSK;
  561. tx_flags &= ~(TX_CMD_FLG_ANT_SEL_MSK);
  562. if (ieee80211_is_mgmt(fc)) {
  563. if (ieee80211_is_assoc_req(fc) || ieee80211_is_reassoc_req(fc))
  564. tx_cmd->timeout.pm_frame_timeout = cpu_to_le16(3);
  565. else
  566. tx_cmd->timeout.pm_frame_timeout = cpu_to_le16(2);
  567. } else {
  568. tx_cmd->timeout.pm_frame_timeout = 0;
  569. }
  570. tx_cmd->driver_txop = 0;
  571. tx_cmd->tx_flags = tx_flags;
  572. tx_cmd->next_frame_len = 0;
  573. }
  574. #define RTS_HCCA_RETRY_LIMIT 3
  575. #define RTS_DFAULT_RETRY_LIMIT 60
  576. static void iwl_tx_cmd_build_rate(struct iwl_priv *priv,
  577. struct iwl_tx_cmd *tx_cmd,
  578. struct ieee80211_tx_info *info,
  579. __le16 fc, int sta_id,
  580. int is_hcca)
  581. {
  582. u32 rate_flags = 0;
  583. int rate_idx;
  584. u8 rts_retry_limit = 0;
  585. u8 data_retry_limit = 0;
  586. u8 rate_plcp;
  587. rate_idx = min(ieee80211_get_tx_rate(priv->hw, info)->hw_value & 0xffff,
  588. IWL_RATE_COUNT - 1);
  589. rate_plcp = iwl_rates[rate_idx].plcp;
  590. rts_retry_limit = (is_hcca) ?
  591. RTS_HCCA_RETRY_LIMIT : RTS_DFAULT_RETRY_LIMIT;
  592. if ((rate_idx >= IWL_FIRST_CCK_RATE) && (rate_idx <= IWL_LAST_CCK_RATE))
  593. rate_flags |= RATE_MCS_CCK_MSK;
  594. if (ieee80211_is_probe_resp(fc)) {
  595. data_retry_limit = 3;
  596. if (data_retry_limit < rts_retry_limit)
  597. rts_retry_limit = data_retry_limit;
  598. } else
  599. data_retry_limit = IWL_DEFAULT_TX_RETRY;
  600. if (priv->data_retry_limit != -1)
  601. data_retry_limit = priv->data_retry_limit;
  602. if (ieee80211_is_data(fc)) {
  603. tx_cmd->initial_rate_index = 0;
  604. tx_cmd->tx_flags |= TX_CMD_FLG_STA_RATE_MSK;
  605. } else {
  606. switch (fc & cpu_to_le16(IEEE80211_FCTL_STYPE)) {
  607. case cpu_to_le16(IEEE80211_STYPE_AUTH):
  608. case cpu_to_le16(IEEE80211_STYPE_DEAUTH):
  609. case cpu_to_le16(IEEE80211_STYPE_ASSOC_REQ):
  610. case cpu_to_le16(IEEE80211_STYPE_REASSOC_REQ):
  611. if (tx_cmd->tx_flags & TX_CMD_FLG_RTS_MSK) {
  612. tx_cmd->tx_flags &= ~TX_CMD_FLG_RTS_MSK;
  613. tx_cmd->tx_flags |= TX_CMD_FLG_CTS_MSK;
  614. }
  615. break;
  616. default:
  617. break;
  618. }
  619. priv->mgmt_tx_ant = iwl_toggle_tx_ant(priv, priv->mgmt_tx_ant);
  620. rate_flags |= iwl_ant_idx_to_flags(priv->mgmt_tx_ant);
  621. }
  622. tx_cmd->rts_retry_limit = rts_retry_limit;
  623. tx_cmd->data_retry_limit = data_retry_limit;
  624. tx_cmd->rate_n_flags = iwl_hw_set_rate_n_flags(rate_plcp, rate_flags);
  625. }
  626. static void iwl_tx_cmd_build_hwcrypto(struct iwl_priv *priv,
  627. struct ieee80211_tx_info *info,
  628. struct iwl_tx_cmd *tx_cmd,
  629. struct sk_buff *skb_frag,
  630. int sta_id)
  631. {
  632. struct ieee80211_key_conf *keyconf = info->control.hw_key;
  633. switch (keyconf->alg) {
  634. case ALG_CCMP:
  635. tx_cmd->sec_ctl = TX_CMD_SEC_CCM;
  636. memcpy(tx_cmd->key, keyconf->key, keyconf->keylen);
  637. if (info->flags & IEEE80211_TX_CTL_AMPDU)
  638. tx_cmd->tx_flags |= TX_CMD_FLG_AGG_CCMP_MSK;
  639. IWL_DEBUG_TX("tx_cmd with aes hwcrypto\n");
  640. break;
  641. case ALG_TKIP:
  642. tx_cmd->sec_ctl = TX_CMD_SEC_TKIP;
  643. ieee80211_get_tkip_key(keyconf, skb_frag,
  644. IEEE80211_TKIP_P2_KEY, tx_cmd->key);
  645. IWL_DEBUG_TX("tx_cmd with tkip hwcrypto\n");
  646. break;
  647. case ALG_WEP:
  648. tx_cmd->sec_ctl |= (TX_CMD_SEC_WEP |
  649. (keyconf->keyidx & TX_CMD_SEC_MSK) << TX_CMD_SEC_SHIFT);
  650. if (keyconf->keylen == WEP_KEY_LEN_128)
  651. tx_cmd->sec_ctl |= TX_CMD_SEC_KEY128;
  652. memcpy(&tx_cmd->key[3], keyconf->key, keyconf->keylen);
  653. IWL_DEBUG_TX("Configuring packet for WEP encryption "
  654. "with key %d\n", keyconf->keyidx);
  655. break;
  656. default:
  657. printk(KERN_ERR "Unknown encode alg %d\n", keyconf->alg);
  658. break;
  659. }
  660. }
  661. static void iwl_update_tx_stats(struct iwl_priv *priv, u16 fc, u16 len)
  662. {
  663. /* 0 - mgmt, 1 - cnt, 2 - data */
  664. int idx = (fc & IEEE80211_FCTL_FTYPE) >> 2;
  665. priv->tx_stats[idx].cnt++;
  666. priv->tx_stats[idx].bytes += len;
  667. }
  668. /*
  669. * start REPLY_TX command process
  670. */
  671. int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
  672. {
  673. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
  674. struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  675. struct iwl_tfd *tfd;
  676. struct iwl_tx_queue *txq;
  677. struct iwl_queue *q;
  678. struct iwl_cmd *out_cmd;
  679. struct iwl_tx_cmd *tx_cmd;
  680. int swq_id, txq_id;
  681. dma_addr_t phys_addr;
  682. dma_addr_t txcmd_phys;
  683. dma_addr_t scratch_phys;
  684. u16 len, len_org;
  685. u16 seq_number = 0;
  686. __le16 fc;
  687. u8 hdr_len, unicast;
  688. u8 sta_id;
  689. u8 wait_write_ptr = 0;
  690. u8 tid = 0;
  691. u8 *qc = NULL;
  692. unsigned long flags;
  693. int ret;
  694. spin_lock_irqsave(&priv->lock, flags);
  695. if (iwl_is_rfkill(priv)) {
  696. IWL_DEBUG_DROP("Dropping - RF KILL\n");
  697. goto drop_unlock;
  698. }
  699. if ((ieee80211_get_tx_rate(priv->hw, info)->hw_value & 0xFF) ==
  700. IWL_INVALID_RATE) {
  701. IWL_ERROR("ERROR: No TX rate available.\n");
  702. goto drop_unlock;
  703. }
  704. unicast = !is_multicast_ether_addr(hdr->addr1);
  705. fc = hdr->frame_control;
  706. #ifdef CONFIG_IWLWIFI_DEBUG
  707. if (ieee80211_is_auth(fc))
  708. IWL_DEBUG_TX("Sending AUTH frame\n");
  709. else if (ieee80211_is_assoc_req(fc))
  710. IWL_DEBUG_TX("Sending ASSOC frame\n");
  711. else if (ieee80211_is_reassoc_req(fc))
  712. IWL_DEBUG_TX("Sending REASSOC frame\n");
  713. #endif
  714. /* drop all data frame if we are not associated */
  715. if (ieee80211_is_data(fc) &&
  716. (priv->iw_mode != NL80211_IFTYPE_MONITOR ||
  717. !(info->flags & IEEE80211_TX_CTL_INJECTED)) && /* packet injection */
  718. (!iwl_is_associated(priv) ||
  719. ((priv->iw_mode == NL80211_IFTYPE_STATION) && !priv->assoc_id) ||
  720. !priv->assoc_station_added)) {
  721. IWL_DEBUG_DROP("Dropping - !iwl_is_associated\n");
  722. goto drop_unlock;
  723. }
  724. spin_unlock_irqrestore(&priv->lock, flags);
  725. hdr_len = ieee80211_hdrlen(fc);
  726. /* Find (or create) index into station table for destination station */
  727. sta_id = iwl_get_sta_id(priv, hdr);
  728. if (sta_id == IWL_INVALID_STATION) {
  729. IWL_DEBUG_DROP("Dropping - INVALID STATION: %pM\n",
  730. hdr->addr1);
  731. goto drop;
  732. }
  733. IWL_DEBUG_TX("station Id %d\n", sta_id);
  734. swq_id = skb_get_queue_mapping(skb);
  735. txq_id = swq_id;
  736. if (ieee80211_is_data_qos(fc)) {
  737. qc = ieee80211_get_qos_ctl(hdr);
  738. tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK;
  739. seq_number = priv->stations[sta_id].tid[tid].seq_number;
  740. seq_number &= IEEE80211_SCTL_SEQ;
  741. hdr->seq_ctrl = hdr->seq_ctrl &
  742. __constant_cpu_to_le16(IEEE80211_SCTL_FRAG);
  743. hdr->seq_ctrl |= cpu_to_le16(seq_number);
  744. seq_number += 0x10;
  745. /* aggregation is on for this <sta,tid> */
  746. if (info->flags & IEEE80211_TX_CTL_AMPDU)
  747. txq_id = priv->stations[sta_id].tid[tid].agg.txq_id;
  748. priv->stations[sta_id].tid[tid].tfds_in_queue++;
  749. }
  750. /* Descriptor for chosen Tx queue */
  751. txq = &priv->txq[txq_id];
  752. q = &txq->q;
  753. spin_lock_irqsave(&priv->lock, flags);
  754. /* Set up first empty TFD within this queue's circular TFD buffer */
  755. tfd = &txq->tfds[q->write_ptr];
  756. memset(tfd, 0, sizeof(*tfd));
  757. /* Set up driver data for this TFD */
  758. memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct iwl_tx_info));
  759. txq->txb[q->write_ptr].skb[0] = skb;
  760. /* Set up first empty entry in queue's array of Tx/cmd buffers */
  761. out_cmd = txq->cmd[q->write_ptr];
  762. tx_cmd = &out_cmd->cmd.tx;
  763. memset(&out_cmd->hdr, 0, sizeof(out_cmd->hdr));
  764. memset(tx_cmd, 0, sizeof(struct iwl_tx_cmd));
  765. /*
  766. * Set up the Tx-command (not MAC!) header.
  767. * Store the chosen Tx queue and TFD index within the sequence field;
  768. * after Tx, uCode's Tx response will return this value so driver can
  769. * locate the frame within the tx queue and do post-tx processing.
  770. */
  771. out_cmd->hdr.cmd = REPLY_TX;
  772. out_cmd->hdr.sequence = cpu_to_le16((u16)(QUEUE_TO_SEQ(txq_id) |
  773. INDEX_TO_SEQ(q->write_ptr)));
  774. /* Copy MAC header from skb into command buffer */
  775. memcpy(tx_cmd->hdr, hdr, hdr_len);
  776. /*
  777. * Use the first empty entry in this queue's command buffer array
  778. * to contain the Tx command and MAC header concatenated together
  779. * (payload data will be in another buffer).
  780. * Size of this varies, due to varying MAC header length.
  781. * If end is not dword aligned, we'll have 2 extra bytes at the end
  782. * of the MAC header (device reads on dword boundaries).
  783. * We'll tell device about this padding later.
  784. */
  785. len = sizeof(struct iwl_tx_cmd) +
  786. sizeof(struct iwl_cmd_header) + hdr_len;
  787. len_org = len;
  788. len = (len + 3) & ~3;
  789. if (len_org != len)
  790. len_org = 1;
  791. else
  792. len_org = 0;
  793. /* Physical address of this Tx command's header (not MAC header!),
  794. * within command buffer array. */
  795. txcmd_phys = pci_map_single(priv->pci_dev,
  796. out_cmd, sizeof(struct iwl_cmd),
  797. PCI_DMA_TODEVICE);
  798. pci_unmap_addr_set(&out_cmd->meta, mapping, txcmd_phys);
  799. pci_unmap_len_set(&out_cmd->meta, len, sizeof(struct iwl_cmd));
  800. /* Add buffer containing Tx command and MAC(!) header to TFD's
  801. * first entry */
  802. txcmd_phys += offsetof(struct iwl_cmd, hdr);
  803. iwl_hw_txq_attach_buf_to_tfd(priv, tfd, txcmd_phys, len);
  804. if (info->control.hw_key)
  805. iwl_tx_cmd_build_hwcrypto(priv, info, tx_cmd, skb, sta_id);
  806. /* Set up TFD's 2nd entry to point directly to remainder of skb,
  807. * if any (802.11 null frames have no payload). */
  808. len = skb->len - hdr_len;
  809. if (len) {
  810. phys_addr = pci_map_single(priv->pci_dev, skb->data + hdr_len,
  811. len, PCI_DMA_TODEVICE);
  812. iwl_hw_txq_attach_buf_to_tfd(priv, tfd, phys_addr, len);
  813. }
  814. /* Tell NIC about any 2-byte padding after MAC header */
  815. if (len_org)
  816. tx_cmd->tx_flags |= TX_CMD_FLG_MH_PAD_MSK;
  817. /* Total # bytes to be transmitted */
  818. len = (u16)skb->len;
  819. tx_cmd->len = cpu_to_le16(len);
  820. /* TODO need this for burst mode later on */
  821. iwl_tx_cmd_build_basic(priv, tx_cmd, info, hdr, unicast, sta_id);
  822. /* set is_hcca to 0; it probably will never be implemented */
  823. iwl_tx_cmd_build_rate(priv, tx_cmd, info, fc, sta_id, 0);
  824. iwl_update_tx_stats(priv, le16_to_cpu(fc), len);
  825. scratch_phys = txcmd_phys + sizeof(struct iwl_cmd_header) +
  826. offsetof(struct iwl_tx_cmd, scratch);
  827. tx_cmd->dram_lsb_ptr = cpu_to_le32(scratch_phys);
  828. tx_cmd->dram_msb_ptr = iwl_get_dma_hi_addr(scratch_phys);
  829. if (!ieee80211_has_morefrags(hdr->frame_control)) {
  830. txq->need_update = 1;
  831. if (qc)
  832. priv->stations[sta_id].tid[tid].seq_number = seq_number;
  833. } else {
  834. wait_write_ptr = 1;
  835. txq->need_update = 0;
  836. }
  837. iwl_print_hex_dump(priv, IWL_DL_TX, (u8 *)tx_cmd, sizeof(*tx_cmd));
  838. iwl_print_hex_dump(priv, IWL_DL_TX, (u8 *)tx_cmd->hdr, hdr_len);
  839. /* Set up entry for this TFD in Tx byte-count array */
  840. priv->cfg->ops->lib->txq_update_byte_cnt_tbl(priv, txq, len);
  841. /* Tell device the write index *just past* this latest filled TFD */
  842. q->write_ptr = iwl_queue_inc_wrap(q->write_ptr, q->n_bd);
  843. ret = iwl_txq_update_write_ptr(priv, txq);
  844. spin_unlock_irqrestore(&priv->lock, flags);
  845. if (ret)
  846. return ret;
  847. if ((iwl_queue_space(q) < q->high_mark) && priv->mac80211_registered) {
  848. if (wait_write_ptr) {
  849. spin_lock_irqsave(&priv->lock, flags);
  850. txq->need_update = 1;
  851. iwl_txq_update_write_ptr(priv, txq);
  852. spin_unlock_irqrestore(&priv->lock, flags);
  853. } else {
  854. ieee80211_stop_queue(priv->hw, swq_id);
  855. }
  856. }
  857. return 0;
  858. drop_unlock:
  859. spin_unlock_irqrestore(&priv->lock, flags);
  860. drop:
  861. return -1;
  862. }
  863. EXPORT_SYMBOL(iwl_tx_skb);
  864. /*************** HOST COMMAND QUEUE FUNCTIONS *****/
  865. /**
  866. * iwl_enqueue_hcmd - enqueue a uCode command
  867. * @priv: device private data point
  868. * @cmd: a point to the ucode command structure
  869. *
  870. * The function returns < 0 values to indicate the operation is
  871. * failed. On success, it turns the index (> 0) of command in the
  872. * command queue.
  873. */
  874. int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
  875. {
  876. struct iwl_tx_queue *txq = &priv->txq[IWL_CMD_QUEUE_NUM];
  877. struct iwl_queue *q = &txq->q;
  878. struct iwl_tfd *tfd;
  879. struct iwl_cmd *out_cmd;
  880. dma_addr_t phys_addr;
  881. unsigned long flags;
  882. int len, ret;
  883. u32 idx;
  884. u16 fix_size;
  885. cmd->len = priv->cfg->ops->utils->get_hcmd_size(cmd->id, cmd->len);
  886. fix_size = (u16)(cmd->len + sizeof(out_cmd->hdr));
  887. /* If any of the command structures end up being larger than
  888. * the TFD_MAX_PAYLOAD_SIZE, and it sent as a 'small' command then
  889. * we will need to increase the size of the TFD entries */
  890. BUG_ON((fix_size > TFD_MAX_PAYLOAD_SIZE) &&
  891. !(cmd->meta.flags & CMD_SIZE_HUGE));
  892. if (iwl_is_rfkill(priv)) {
  893. IWL_DEBUG_INFO("Not sending command - RF KILL");
  894. return -EIO;
  895. }
  896. if (iwl_queue_space(q) < ((cmd->meta.flags & CMD_ASYNC) ? 2 : 1)) {
  897. IWL_ERROR("No space for Tx\n");
  898. return -ENOSPC;
  899. }
  900. spin_lock_irqsave(&priv->hcmd_lock, flags);
  901. tfd = &txq->tfds[q->write_ptr];
  902. memset(tfd, 0, sizeof(*tfd));
  903. idx = get_cmd_index(q, q->write_ptr, cmd->meta.flags & CMD_SIZE_HUGE);
  904. out_cmd = txq->cmd[idx];
  905. out_cmd->hdr.cmd = cmd->id;
  906. memcpy(&out_cmd->meta, &cmd->meta, sizeof(cmd->meta));
  907. memcpy(&out_cmd->cmd.payload, cmd->data, cmd->len);
  908. /* At this point, the out_cmd now has all of the incoming cmd
  909. * information */
  910. out_cmd->hdr.flags = 0;
  911. out_cmd->hdr.sequence = cpu_to_le16(QUEUE_TO_SEQ(IWL_CMD_QUEUE_NUM) |
  912. INDEX_TO_SEQ(q->write_ptr));
  913. if (out_cmd->meta.flags & CMD_SIZE_HUGE)
  914. out_cmd->hdr.sequence |= SEQ_HUGE_FRAME;
  915. len = (idx == TFD_CMD_SLOTS) ?
  916. IWL_MAX_SCAN_SIZE : sizeof(struct iwl_cmd);
  917. phys_addr = pci_map_single(priv->pci_dev, out_cmd,
  918. len, PCI_DMA_TODEVICE);
  919. pci_unmap_addr_set(&out_cmd->meta, mapping, phys_addr);
  920. pci_unmap_len_set(&out_cmd->meta, len, len);
  921. phys_addr += offsetof(struct iwl_cmd, hdr);
  922. iwl_hw_txq_attach_buf_to_tfd(priv, tfd, phys_addr, fix_size);
  923. #ifdef CONFIG_IWLWIFI_DEBUG
  924. switch (out_cmd->hdr.cmd) {
  925. case REPLY_TX_LINK_QUALITY_CMD:
  926. case SENSITIVITY_CMD:
  927. IWL_DEBUG_HC_DUMP("Sending command %s (#%x), seq: 0x%04X, "
  928. "%d bytes at %d[%d]:%d\n",
  929. get_cmd_string(out_cmd->hdr.cmd),
  930. out_cmd->hdr.cmd,
  931. le16_to_cpu(out_cmd->hdr.sequence), fix_size,
  932. q->write_ptr, idx, IWL_CMD_QUEUE_NUM);
  933. break;
  934. default:
  935. IWL_DEBUG_HC("Sending command %s (#%x), seq: 0x%04X, "
  936. "%d bytes at %d[%d]:%d\n",
  937. get_cmd_string(out_cmd->hdr.cmd),
  938. out_cmd->hdr.cmd,
  939. le16_to_cpu(out_cmd->hdr.sequence), fix_size,
  940. q->write_ptr, idx, IWL_CMD_QUEUE_NUM);
  941. }
  942. #endif
  943. txq->need_update = 1;
  944. /* Set up entry in queue's byte count circular buffer */
  945. priv->cfg->ops->lib->txq_update_byte_cnt_tbl(priv, txq, 0);
  946. /* Increment and update queue's write index */
  947. q->write_ptr = iwl_queue_inc_wrap(q->write_ptr, q->n_bd);
  948. ret = iwl_txq_update_write_ptr(priv, txq);
  949. spin_unlock_irqrestore(&priv->hcmd_lock, flags);
  950. return ret ? ret : idx;
  951. }
  952. int iwl_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index)
  953. {
  954. struct iwl_tx_queue *txq = &priv->txq[txq_id];
  955. struct iwl_queue *q = &txq->q;
  956. struct iwl_tx_info *tx_info;
  957. int nfreed = 0;
  958. if ((index >= q->n_bd) || (iwl_queue_used(q, index) == 0)) {
  959. IWL_ERROR("Read index for DMA queue txq id (%d), index %d, "
  960. "is out of range [0-%d] %d %d.\n", txq_id,
  961. index, q->n_bd, q->write_ptr, q->read_ptr);
  962. return 0;
  963. }
  964. for (index = iwl_queue_inc_wrap(index, q->n_bd);
  965. q->read_ptr != index;
  966. q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) {
  967. tx_info = &txq->txb[txq->q.read_ptr];
  968. ieee80211_tx_status_irqsafe(priv->hw, tx_info->skb[0]);
  969. tx_info->skb[0] = NULL;
  970. if (priv->cfg->ops->lib->txq_inval_byte_cnt_tbl)
  971. priv->cfg->ops->lib->txq_inval_byte_cnt_tbl(priv, txq);
  972. iwl_hw_txq_free_tfd(priv, txq);
  973. nfreed++;
  974. }
  975. return nfreed;
  976. }
  977. EXPORT_SYMBOL(iwl_tx_queue_reclaim);
  978. /**
  979. * iwl_hcmd_queue_reclaim - Reclaim TX command queue entries already Tx'd
  980. *
  981. * When FW advances 'R' index, all entries between old and new 'R' index
  982. * need to be reclaimed. As result, some free space forms. If there is
  983. * enough free space (> low mark), wake the stack that feeds us.
  984. */
  985. static void iwl_hcmd_queue_reclaim(struct iwl_priv *priv, int txq_id,
  986. int idx, int cmd_idx)
  987. {
  988. struct iwl_tx_queue *txq = &priv->txq[txq_id];
  989. struct iwl_queue *q = &txq->q;
  990. int nfreed = 0;
  991. if ((idx >= q->n_bd) || (iwl_queue_used(q, idx) == 0)) {
  992. IWL_ERROR("Read index for DMA queue txq id (%d), index %d, "
  993. "is out of range [0-%d] %d %d.\n", txq_id,
  994. idx, q->n_bd, q->write_ptr, q->read_ptr);
  995. return;
  996. }
  997. pci_unmap_single(priv->pci_dev,
  998. pci_unmap_addr(&txq->cmd[cmd_idx]->meta, mapping),
  999. pci_unmap_len(&txq->cmd[cmd_idx]->meta, len),
  1000. PCI_DMA_TODEVICE);
  1001. for (idx = iwl_queue_inc_wrap(idx, q->n_bd); q->read_ptr != idx;
  1002. q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) {
  1003. if (nfreed++ > 0) {
  1004. IWL_ERROR("HCMD skipped: index (%d) %d %d\n", idx,
  1005. q->write_ptr, q->read_ptr);
  1006. queue_work(priv->workqueue, &priv->restart);
  1007. }
  1008. }
  1009. }
  1010. /**
  1011. * iwl_tx_cmd_complete - Pull unused buffers off the queue and reclaim them
  1012. * @rxb: Rx buffer to reclaim
  1013. *
  1014. * If an Rx buffer has an async callback associated with it the callback
  1015. * will be executed. The attached skb (if present) will only be freed
  1016. * if the callback returns 1
  1017. */
  1018. void iwl_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb)
  1019. {
  1020. struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data;
  1021. u16 sequence = le16_to_cpu(pkt->hdr.sequence);
  1022. int txq_id = SEQ_TO_QUEUE(sequence);
  1023. int index = SEQ_TO_INDEX(sequence);
  1024. int cmd_index;
  1025. bool huge = !!(pkt->hdr.sequence & SEQ_HUGE_FRAME);
  1026. struct iwl_cmd *cmd;
  1027. /* If a Tx command is being handled and it isn't in the actual
  1028. * command queue then there a command routing bug has been introduced
  1029. * in the queue management code. */
  1030. if (WARN(txq_id != IWL_CMD_QUEUE_NUM,
  1031. "wrong command queue %d, command id 0x%X\n", txq_id, pkt->hdr.cmd))
  1032. return;
  1033. cmd_index = get_cmd_index(&priv->txq[IWL_CMD_QUEUE_NUM].q, index, huge);
  1034. cmd = priv->txq[IWL_CMD_QUEUE_NUM].cmd[cmd_index];
  1035. /* Input error checking is done when commands are added to queue. */
  1036. if (cmd->meta.flags & CMD_WANT_SKB) {
  1037. cmd->meta.source->u.skb = rxb->skb;
  1038. rxb->skb = NULL;
  1039. } else if (cmd->meta.u.callback &&
  1040. !cmd->meta.u.callback(priv, cmd, rxb->skb))
  1041. rxb->skb = NULL;
  1042. iwl_hcmd_queue_reclaim(priv, txq_id, index, cmd_index);
  1043. if (!(cmd->meta.flags & CMD_ASYNC)) {
  1044. clear_bit(STATUS_HCMD_ACTIVE, &priv->status);
  1045. wake_up_interruptible(&priv->wait_command_queue);
  1046. }
  1047. }
  1048. EXPORT_SYMBOL(iwl_tx_cmd_complete);
  1049. /*
  1050. * Find first available (lowest unused) Tx Queue, mark it "active".
  1051. * Called only when finding queue for aggregation.
  1052. * Should never return anything < 7, because they should already
  1053. * be in use as EDCA AC (0-3), Command (4), HCCA (5, 6).
  1054. */
  1055. static int iwl_txq_ctx_activate_free(struct iwl_priv *priv)
  1056. {
  1057. int txq_id;
  1058. for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++)
  1059. if (!test_and_set_bit(txq_id, &priv->txq_ctx_active_msk))
  1060. return txq_id;
  1061. return -1;
  1062. }
  1063. int iwl_tx_agg_start(struct iwl_priv *priv, const u8 *ra, u16 tid, u16 *ssn)
  1064. {
  1065. int sta_id;
  1066. int tx_fifo;
  1067. int txq_id;
  1068. int ret;
  1069. unsigned long flags;
  1070. struct iwl_tid_data *tid_data;
  1071. if (likely(tid < ARRAY_SIZE(default_tid_to_tx_fifo)))
  1072. tx_fifo = default_tid_to_tx_fifo[tid];
  1073. else
  1074. return -EINVAL;
  1075. IWL_WARNING("%s on ra = %pM tid = %d\n",
  1076. __func__, ra, tid);
  1077. sta_id = iwl_find_station(priv, ra);
  1078. if (sta_id == IWL_INVALID_STATION)
  1079. return -ENXIO;
  1080. if (priv->stations[sta_id].tid[tid].agg.state != IWL_AGG_OFF) {
  1081. IWL_ERROR("Start AGG when state is not IWL_AGG_OFF !\n");
  1082. return -ENXIO;
  1083. }
  1084. txq_id = iwl_txq_ctx_activate_free(priv);
  1085. if (txq_id == -1)
  1086. return -ENXIO;
  1087. spin_lock_irqsave(&priv->sta_lock, flags);
  1088. tid_data = &priv->stations[sta_id].tid[tid];
  1089. *ssn = SEQ_TO_SN(tid_data->seq_number);
  1090. tid_data->agg.txq_id = txq_id;
  1091. spin_unlock_irqrestore(&priv->sta_lock, flags);
  1092. ret = priv->cfg->ops->lib->txq_agg_enable(priv, txq_id, tx_fifo,
  1093. sta_id, tid, *ssn);
  1094. if (ret)
  1095. return ret;
  1096. if (tid_data->tfds_in_queue == 0) {
  1097. printk(KERN_ERR "HW queue is empty\n");
  1098. tid_data->agg.state = IWL_AGG_ON;
  1099. ieee80211_start_tx_ba_cb_irqsafe(priv->hw, ra, tid);
  1100. } else {
  1101. IWL_DEBUG_HT("HW queue is NOT empty: %d packets in HW queue\n",
  1102. tid_data->tfds_in_queue);
  1103. tid_data->agg.state = IWL_EMPTYING_HW_QUEUE_ADDBA;
  1104. }
  1105. return ret;
  1106. }
  1107. EXPORT_SYMBOL(iwl_tx_agg_start);
  1108. int iwl_tx_agg_stop(struct iwl_priv *priv , const u8 *ra, u16 tid)
  1109. {
  1110. int tx_fifo_id, txq_id, sta_id, ssn = -1;
  1111. struct iwl_tid_data *tid_data;
  1112. int ret, write_ptr, read_ptr;
  1113. unsigned long flags;
  1114. if (!ra) {
  1115. IWL_ERROR("ra = NULL\n");
  1116. return -EINVAL;
  1117. }
  1118. if (likely(tid < ARRAY_SIZE(default_tid_to_tx_fifo)))
  1119. tx_fifo_id = default_tid_to_tx_fifo[tid];
  1120. else
  1121. return -EINVAL;
  1122. sta_id = iwl_find_station(priv, ra);
  1123. if (sta_id == IWL_INVALID_STATION)
  1124. return -ENXIO;
  1125. if (priv->stations[sta_id].tid[tid].agg.state != IWL_AGG_ON)
  1126. IWL_WARNING("Stopping AGG while state not IWL_AGG_ON\n");
  1127. tid_data = &priv->stations[sta_id].tid[tid];
  1128. ssn = (tid_data->seq_number & IEEE80211_SCTL_SEQ) >> 4;
  1129. txq_id = tid_data->agg.txq_id;
  1130. write_ptr = priv->txq[txq_id].q.write_ptr;
  1131. read_ptr = priv->txq[txq_id].q.read_ptr;
  1132. /* The queue is not empty */
  1133. if (write_ptr != read_ptr) {
  1134. IWL_DEBUG_HT("Stopping a non empty AGG HW QUEUE\n");
  1135. priv->stations[sta_id].tid[tid].agg.state =
  1136. IWL_EMPTYING_HW_QUEUE_DELBA;
  1137. return 0;
  1138. }
  1139. IWL_DEBUG_HT("HW queue is empty\n");
  1140. priv->stations[sta_id].tid[tid].agg.state = IWL_AGG_OFF;
  1141. spin_lock_irqsave(&priv->lock, flags);
  1142. ret = priv->cfg->ops->lib->txq_agg_disable(priv, txq_id, ssn,
  1143. tx_fifo_id);
  1144. spin_unlock_irqrestore(&priv->lock, flags);
  1145. if (ret)
  1146. return ret;
  1147. ieee80211_stop_tx_ba_cb_irqsafe(priv->hw, ra, tid);
  1148. return 0;
  1149. }
  1150. EXPORT_SYMBOL(iwl_tx_agg_stop);
  1151. int iwl_txq_check_empty(struct iwl_priv *priv, int sta_id, u8 tid, int txq_id)
  1152. {
  1153. struct iwl_queue *q = &priv->txq[txq_id].q;
  1154. u8 *addr = priv->stations[sta_id].sta.sta.addr;
  1155. struct iwl_tid_data *tid_data = &priv->stations[sta_id].tid[tid];
  1156. switch (priv->stations[sta_id].tid[tid].agg.state) {
  1157. case IWL_EMPTYING_HW_QUEUE_DELBA:
  1158. /* We are reclaiming the last packet of the */
  1159. /* aggregated HW queue */
  1160. if (txq_id == tid_data->agg.txq_id &&
  1161. q->read_ptr == q->write_ptr) {
  1162. u16 ssn = SEQ_TO_SN(tid_data->seq_number);
  1163. int tx_fifo = default_tid_to_tx_fifo[tid];
  1164. IWL_DEBUG_HT("HW queue empty: continue DELBA flow\n");
  1165. priv->cfg->ops->lib->txq_agg_disable(priv, txq_id,
  1166. ssn, tx_fifo);
  1167. tid_data->agg.state = IWL_AGG_OFF;
  1168. ieee80211_stop_tx_ba_cb_irqsafe(priv->hw, addr, tid);
  1169. }
  1170. break;
  1171. case IWL_EMPTYING_HW_QUEUE_ADDBA:
  1172. /* We are reclaiming the last packet of the queue */
  1173. if (tid_data->tfds_in_queue == 0) {
  1174. IWL_DEBUG_HT("HW queue empty: continue ADDBA flow\n");
  1175. tid_data->agg.state = IWL_AGG_ON;
  1176. ieee80211_start_tx_ba_cb_irqsafe(priv->hw, addr, tid);
  1177. }
  1178. break;
  1179. }
  1180. return 0;
  1181. }
  1182. EXPORT_SYMBOL(iwl_txq_check_empty);
  1183. /**
  1184. * iwl_tx_status_reply_compressed_ba - Update tx status from block-ack
  1185. *
  1186. * Go through block-ack's bitmap of ACK'd frames, update driver's record of
  1187. * ACK vs. not. This gets sent to mac80211, then to rate scaling algo.
  1188. */
  1189. static int iwl_tx_status_reply_compressed_ba(struct iwl_priv *priv,
  1190. struct iwl_ht_agg *agg,
  1191. struct iwl_compressed_ba_resp *ba_resp)
  1192. {
  1193. int i, sh, ack;
  1194. u16 seq_ctl = le16_to_cpu(ba_resp->seq_ctl);
  1195. u16 scd_flow = le16_to_cpu(ba_resp->scd_flow);
  1196. u64 bitmap;
  1197. int successes = 0;
  1198. struct ieee80211_tx_info *info;
  1199. if (unlikely(!agg->wait_for_ba)) {
  1200. IWL_ERROR("Received BA when not expected\n");
  1201. return -EINVAL;
  1202. }
  1203. /* Mark that the expected block-ack response arrived */
  1204. agg->wait_for_ba = 0;
  1205. IWL_DEBUG_TX_REPLY("BA %d %d\n", agg->start_idx, ba_resp->seq_ctl);
  1206. /* Calculate shift to align block-ack bits with our Tx window bits */
  1207. sh = agg->start_idx - SEQ_TO_INDEX(seq_ctl>>4);
  1208. if (sh < 0) /* tbw something is wrong with indices */
  1209. sh += 0x100;
  1210. /* don't use 64-bit values for now */
  1211. bitmap = le64_to_cpu(ba_resp->bitmap) >> sh;
  1212. if (agg->frame_count > (64 - sh)) {
  1213. IWL_DEBUG_TX_REPLY("more frames than bitmap size");
  1214. return -1;
  1215. }
  1216. /* check for success or failure according to the
  1217. * transmitted bitmap and block-ack bitmap */
  1218. bitmap &= agg->bitmap;
  1219. /* For each frame attempted in aggregation,
  1220. * update driver's record of tx frame's status. */
  1221. for (i = 0; i < agg->frame_count ; i++) {
  1222. ack = bitmap & (1ULL << i);
  1223. successes += !!ack;
  1224. IWL_DEBUG_TX_REPLY("%s ON i=%d idx=%d raw=%d\n",
  1225. ack? "ACK":"NACK", i, (agg->start_idx + i) & 0xff,
  1226. agg->start_idx + i);
  1227. }
  1228. info = IEEE80211_SKB_CB(priv->txq[scd_flow].txb[agg->start_idx].skb[0]);
  1229. memset(&info->status, 0, sizeof(info->status));
  1230. info->flags = IEEE80211_TX_STAT_ACK;
  1231. info->flags |= IEEE80211_TX_STAT_AMPDU;
  1232. info->status.ampdu_ack_map = successes;
  1233. info->status.ampdu_ack_len = agg->frame_count;
  1234. iwl_hwrate_to_tx_control(priv, agg->rate_n_flags, info);
  1235. IWL_DEBUG_TX_REPLY("Bitmap %llx\n", (unsigned long long)bitmap);
  1236. return 0;
  1237. }
  1238. /**
  1239. * iwl_rx_reply_compressed_ba - Handler for REPLY_COMPRESSED_BA
  1240. *
  1241. * Handles block-acknowledge notification from device, which reports success
  1242. * of frames sent via aggregation.
  1243. */
  1244. void iwl_rx_reply_compressed_ba(struct iwl_priv *priv,
  1245. struct iwl_rx_mem_buffer *rxb)
  1246. {
  1247. struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data;
  1248. struct iwl_compressed_ba_resp *ba_resp = &pkt->u.compressed_ba;
  1249. int index;
  1250. struct iwl_tx_queue *txq = NULL;
  1251. struct iwl_ht_agg *agg;
  1252. /* "flow" corresponds to Tx queue */
  1253. u16 scd_flow = le16_to_cpu(ba_resp->scd_flow);
  1254. /* "ssn" is start of block-ack Tx window, corresponds to index
  1255. * (in Tx queue's circular buffer) of first TFD/frame in window */
  1256. u16 ba_resp_scd_ssn = le16_to_cpu(ba_resp->scd_ssn);
  1257. if (scd_flow >= priv->hw_params.max_txq_num) {
  1258. IWL_ERROR("BUG_ON scd_flow is bigger than number of queues\n");
  1259. return;
  1260. }
  1261. txq = &priv->txq[scd_flow];
  1262. agg = &priv->stations[ba_resp->sta_id].tid[ba_resp->tid].agg;
  1263. /* Find index just before block-ack window */
  1264. index = iwl_queue_dec_wrap(ba_resp_scd_ssn & 0xff, txq->q.n_bd);
  1265. /* TODO: Need to get this copy more safely - now good for debug */
  1266. IWL_DEBUG_TX_REPLY("REPLY_COMPRESSED_BA [%d]Received from %pM, "
  1267. "sta_id = %d\n",
  1268. agg->wait_for_ba,
  1269. (u8 *) &ba_resp->sta_addr_lo32,
  1270. ba_resp->sta_id);
  1271. IWL_DEBUG_TX_REPLY("TID = %d, SeqCtl = %d, bitmap = 0x%llx, scd_flow = "
  1272. "%d, scd_ssn = %d\n",
  1273. ba_resp->tid,
  1274. ba_resp->seq_ctl,
  1275. (unsigned long long)le64_to_cpu(ba_resp->bitmap),
  1276. ba_resp->scd_flow,
  1277. ba_resp->scd_ssn);
  1278. IWL_DEBUG_TX_REPLY("DAT start_idx = %d, bitmap = 0x%llx \n",
  1279. agg->start_idx,
  1280. (unsigned long long)agg->bitmap);
  1281. /* Update driver's record of ACK vs. not for each frame in window */
  1282. iwl_tx_status_reply_compressed_ba(priv, agg, ba_resp);
  1283. /* Release all TFDs before the SSN, i.e. all TFDs in front of
  1284. * block-ack window (we assume that they've been successfully
  1285. * transmitted ... if not, it's too late anyway). */
  1286. if (txq->q.read_ptr != (ba_resp_scd_ssn & 0xff)) {
  1287. /* calculate mac80211 ampdu sw queue to wake */
  1288. int ampdu_q =
  1289. scd_flow - priv->hw_params.first_ampdu_q + priv->hw->queues;
  1290. int freed = iwl_tx_queue_reclaim(priv, scd_flow, index);
  1291. priv->stations[ba_resp->sta_id].
  1292. tid[ba_resp->tid].tfds_in_queue -= freed;
  1293. if (iwl_queue_space(&txq->q) > txq->q.low_mark &&
  1294. priv->mac80211_registered &&
  1295. agg->state != IWL_EMPTYING_HW_QUEUE_DELBA)
  1296. ieee80211_wake_queue(priv->hw, ampdu_q);
  1297. iwl_txq_check_empty(priv, ba_resp->sta_id,
  1298. ba_resp->tid, scd_flow);
  1299. }
  1300. }
  1301. EXPORT_SYMBOL(iwl_rx_reply_compressed_ba);
  1302. #ifdef CONFIG_IWLWIFI_DEBUG
  1303. #define TX_STATUS_ENTRY(x) case TX_STATUS_FAIL_ ## x: return #x
  1304. const char *iwl_get_tx_fail_reason(u32 status)
  1305. {
  1306. switch (status & TX_STATUS_MSK) {
  1307. case TX_STATUS_SUCCESS:
  1308. return "SUCCESS";
  1309. TX_STATUS_ENTRY(SHORT_LIMIT);
  1310. TX_STATUS_ENTRY(LONG_LIMIT);
  1311. TX_STATUS_ENTRY(FIFO_UNDERRUN);
  1312. TX_STATUS_ENTRY(MGMNT_ABORT);
  1313. TX_STATUS_ENTRY(NEXT_FRAG);
  1314. TX_STATUS_ENTRY(LIFE_EXPIRE);
  1315. TX_STATUS_ENTRY(DEST_PS);
  1316. TX_STATUS_ENTRY(ABORTED);
  1317. TX_STATUS_ENTRY(BT_RETRY);
  1318. TX_STATUS_ENTRY(STA_INVALID);
  1319. TX_STATUS_ENTRY(FRAG_DROPPED);
  1320. TX_STATUS_ENTRY(TID_DISABLE);
  1321. TX_STATUS_ENTRY(FRAME_FLUSHED);
  1322. TX_STATUS_ENTRY(INSUFFICIENT_CF_POLL);
  1323. TX_STATUS_ENTRY(TX_LOCKED);
  1324. TX_STATUS_ENTRY(NO_BEACON_ON_RADAR);
  1325. }
  1326. return "UNKNOWN";
  1327. }
  1328. EXPORT_SYMBOL(iwl_get_tx_fail_reason);
  1329. #endif /* CONFIG_IWLWIFI_DEBUG */