blob: 554750d993ed75f7fc9a5f085398f2fa7003e4f9 [file] [log] [blame]
Wey-Yi Guyb305a082010-03-16 17:41:22 -07001/******************************************************************************
2 *
3 * GPL LICENSE SUMMARY
4 *
Wey-Yi Guy901069c2011-04-05 09:42:00 -07005 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
Wey-Yi Guyb305a082010-03-16 17:41:22 -07006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
19 * USA
20 *
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
23 *
24 * Contact Information:
25 * Intel Linux Wireless <ilw@linux.intel.com>
26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *
28 *****************************************************************************/
29
30#include <linux/kernel.h>
31#include <linux/module.h>
32#include <linux/init.h>
33#include <linux/sched.h>
34
35#include "iwl-dev.h"
36#include "iwl-core.h"
37#include "iwl-sta.h"
38#include "iwl-io.h"
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -070039#include "iwl-helpers.h"
Wey-Yi Guy19e6cda2010-03-16 17:41:23 -070040#include "iwl-agn-hw.h"
Wey-Yi Guy8d801082010-03-17 13:34:36 -070041#include "iwl-agn.h"
Emmanuel Grumbach47c1b492011-07-03 11:22:15 +030042#include "iwl-trans.h"
Wey-Yi Guyb305a082010-03-16 17:41:22 -070043
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -070044/*
45 * mac80211 queues, ACs, hardware queues, FIFOs.
46 *
47 * Cf. http://wireless.kernel.org/en/developers/Documentation/mac80211/queues
48 *
49 * Mac80211 uses the following numbers, which we get as from it
50 * by way of skb_get_queue_mapping(skb):
51 *
52 * VO 0
53 * VI 1
54 * BE 2
55 * BK 3
56 *
57 *
58 * Regular (not A-MPDU) frames are put into hardware queues corresponding
59 * to the FIFOs, see comments in iwl-prph.h. Aggregated frames get their
60 * own queue per aggregation session (RA/TID combination), such queues are
61 * set up to map into FIFOs too, for which we need an AC->FIFO mapping. In
62 * order to map frames to the right queue, we also need an AC->hw queue
63 * mapping. This is implemented here.
64 *
65 * Due to the way hw queues are set up (by the hw specific modules like
66 * iwl-4965.c, iwl-5000.c etc.), the AC->hw queue mapping is the identity
67 * mapping.
68 */
69
70static const u8 tid_to_ac[] = {
Johannes Berg0c4ac342010-11-17 11:33:27 -080071 IEEE80211_AC_BE,
72 IEEE80211_AC_BK,
73 IEEE80211_AC_BK,
74 IEEE80211_AC_BE,
75 IEEE80211_AC_VI,
76 IEEE80211_AC_VI,
77 IEEE80211_AC_VO,
78 IEEE80211_AC_VO
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -070079};
80
Shanyu Zhaoc2845d02010-04-14 15:35:14 -070081static inline int get_ac_from_tid(u16 tid)
82{
83 if (likely(tid < ARRAY_SIZE(tid_to_ac)))
84 return tid_to_ac[tid];
85
86 /* no support for TIDs 8-15 yet */
87 return -EINVAL;
88}
89
Johannes Berge72f3682010-08-23 10:46:51 +020090static inline int get_fifo_from_tid(struct iwl_rxon_context *ctx, u16 tid)
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -070091{
92 if (likely(tid < ARRAY_SIZE(tid_to_ac)))
Johannes Berge72f3682010-08-23 10:46:51 +020093 return ctx->ac_to_fifo[tid_to_ac[tid]];
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -070094
95 /* no support for TIDs 8-15 yet */
96 return -EINVAL;
97}
98
Wey-Yi Guyb305a082010-03-16 17:41:22 -070099/**
100 * iwlagn_txq_update_byte_cnt_tbl - Set up entry in Tx byte-count array
101 */
Emmanuel Grumbach47c1b492011-07-03 11:22:15 +0300102void iwlagn_txq_update_byte_cnt_tbl(struct iwl_priv *priv,
Johannes Berg94b00652011-04-28 07:27:09 -0700103 struct iwl_tx_queue *txq,
104 u16 byte_cnt)
Wey-Yi Guyb305a082010-03-16 17:41:22 -0700105{
Wey-Yi Guy19e6cda2010-03-16 17:41:23 -0700106 struct iwlagn_scd_bc_tbl *scd_bc_tbl = priv->scd_bc_tbls.addr;
Wey-Yi Guyb305a082010-03-16 17:41:22 -0700107 int write_ptr = txq->q.write_ptr;
108 int txq_id = txq->q.id;
109 u8 sec_ctl = 0;
110 u8 sta_id = 0;
111 u16 len = byte_cnt + IWL_TX_CRC_SIZE + IWL_TX_DELIMITER_SIZE;
112 __le16 bc_ent;
113
114 WARN_ON(len > 0xFFF || write_ptr >= TFD_QUEUE_SIZE_MAX);
115
Johannes Bergccb6c1c2011-04-28 07:27:08 -0700116 sta_id = txq->cmd[txq->q.write_ptr]->cmd.tx.sta_id;
117 sec_ctl = txq->cmd[txq->q.write_ptr]->cmd.tx.sec_ctl;
Wey-Yi Guyb305a082010-03-16 17:41:22 -0700118
Johannes Bergccb6c1c2011-04-28 07:27:08 -0700119 switch (sec_ctl & TX_CMD_SEC_MSK) {
120 case TX_CMD_SEC_CCM:
121 len += CCMP_MIC_LEN;
122 break;
123 case TX_CMD_SEC_TKIP:
124 len += TKIP_ICV_LEN;
125 break;
126 case TX_CMD_SEC_WEP:
127 len += WEP_IV_LEN + WEP_ICV_LEN;
128 break;
Wey-Yi Guyb305a082010-03-16 17:41:22 -0700129 }
130
131 bc_ent = cpu_to_le16((len & 0xFFF) | (sta_id << 12));
132
133 scd_bc_tbl[txq_id].tfd_offset[write_ptr] = bc_ent;
134
135 if (write_ptr < TFD_QUEUE_SIZE_BC_DUP)
136 scd_bc_tbl[txq_id].
137 tfd_offset[TFD_QUEUE_SIZE_MAX + write_ptr] = bc_ent;
138}
139
Johannes Berg94b00652011-04-28 07:27:09 -0700140static void iwlagn_txq_inval_byte_cnt_tbl(struct iwl_priv *priv,
141 struct iwl_tx_queue *txq)
Wey-Yi Guyb305a082010-03-16 17:41:22 -0700142{
Wey-Yi Guy19e6cda2010-03-16 17:41:23 -0700143 struct iwlagn_scd_bc_tbl *scd_bc_tbl = priv->scd_bc_tbls.addr;
Wey-Yi Guyb305a082010-03-16 17:41:22 -0700144 int txq_id = txq->q.id;
145 int read_ptr = txq->q.read_ptr;
146 u8 sta_id = 0;
147 __le16 bc_ent;
148
149 WARN_ON(read_ptr >= TFD_QUEUE_SIZE_MAX);
150
Johannes Berg13bb9482010-08-23 10:46:33 +0200151 if (txq_id != priv->cmd_queue)
Wey-Yi Guyb305a082010-03-16 17:41:22 -0700152 sta_id = txq->cmd[read_ptr]->cmd.tx.sta_id;
153
154 bc_ent = cpu_to_le16(1 | (sta_id << 12));
155 scd_bc_tbl[txq_id].tfd_offset[read_ptr] = bc_ent;
156
157 if (read_ptr < TFD_QUEUE_SIZE_BC_DUP)
158 scd_bc_tbl[txq_id].
159 tfd_offset[TFD_QUEUE_SIZE_MAX + read_ptr] = bc_ent;
160}
161
162static int iwlagn_tx_queue_set_q2ratid(struct iwl_priv *priv, u16 ra_tid,
163 u16 txq_id)
164{
165 u32 tbl_dw_addr;
166 u32 tbl_dw;
167 u16 scd_q2ratid;
168
169 scd_q2ratid = ra_tid & IWL_SCD_QUEUE_RA_TID_MAP_RATID_MSK;
170
171 tbl_dw_addr = priv->scd_base_addr +
Wey-Yi Guyf4388ad2010-04-12 18:32:11 -0700172 IWLAGN_SCD_TRANSLATE_TBL_OFFSET_QUEUE(txq_id);
Wey-Yi Guyb305a082010-03-16 17:41:22 -0700173
174 tbl_dw = iwl_read_targ_mem(priv, tbl_dw_addr);
175
176 if (txq_id & 0x1)
177 tbl_dw = (scd_q2ratid << 16) | (tbl_dw & 0x0000FFFF);
178 else
179 tbl_dw = scd_q2ratid | (tbl_dw & 0xFFFF0000);
180
181 iwl_write_targ_mem(priv, tbl_dw_addr, tbl_dw);
182
183 return 0;
184}
185
186static void iwlagn_tx_queue_stop_scheduler(struct iwl_priv *priv, u16 txq_id)
187{
188 /* Simply stop the queue, but don't change any configuration;
189 * the SCD_ACT_EN bit is the write-enable mask for the ACTIVE bit. */
190 iwl_write_prph(priv,
Wey-Yi Guyf4388ad2010-04-12 18:32:11 -0700191 IWLAGN_SCD_QUEUE_STATUS_BITS(txq_id),
192 (0 << IWLAGN_SCD_QUEUE_STTS_REG_POS_ACTIVE)|
193 (1 << IWLAGN_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN));
Wey-Yi Guyb305a082010-03-16 17:41:22 -0700194}
195
196void iwlagn_set_wr_ptrs(struct iwl_priv *priv,
197 int txq_id, u32 index)
198{
199 iwl_write_direct32(priv, HBUS_TARG_WRPTR,
200 (index & 0xff) | (txq_id << 8));
Wey-Yi Guyf4388ad2010-04-12 18:32:11 -0700201 iwl_write_prph(priv, IWLAGN_SCD_QUEUE_RDPTR(txq_id), index);
Wey-Yi Guyb305a082010-03-16 17:41:22 -0700202}
203
204void iwlagn_tx_queue_set_status(struct iwl_priv *priv,
205 struct iwl_tx_queue *txq,
206 int tx_fifo_id, int scd_retry)
207{
208 int txq_id = txq->q.id;
209 int active = test_bit(txq_id, &priv->txq_ctx_active_msk) ? 1 : 0;
210
Wey-Yi Guyf4388ad2010-04-12 18:32:11 -0700211 iwl_write_prph(priv, IWLAGN_SCD_QUEUE_STATUS_BITS(txq_id),
212 (active << IWLAGN_SCD_QUEUE_STTS_REG_POS_ACTIVE) |
213 (tx_fifo_id << IWLAGN_SCD_QUEUE_STTS_REG_POS_TXF) |
214 (1 << IWLAGN_SCD_QUEUE_STTS_REG_POS_WSL) |
215 IWLAGN_SCD_QUEUE_STTS_REG_MSK);
Wey-Yi Guyb305a082010-03-16 17:41:22 -0700216
217 txq->sched_retry = scd_retry;
218
219 IWL_DEBUG_INFO(priv, "%s %s Queue %d on FIFO %d\n",
220 active ? "Activate" : "Deactivate",
221 scd_retry ? "BA" : "AC/CMD", txq_id, tx_fifo_id);
222}
223
Johannes Bergc8823ec2011-03-15 11:33:03 -0700224static int iwlagn_txq_agg_enable(struct iwl_priv *priv, int txq_id, int sta_id, int tid)
Wey-Yi Guyb305a082010-03-16 17:41:22 -0700225{
Wey-Yi Guy19e6cda2010-03-16 17:41:23 -0700226 if ((IWLAGN_FIRST_AMPDU_QUEUE > txq_id) ||
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -0700227 (IWLAGN_FIRST_AMPDU_QUEUE +
228 priv->cfg->base_params->num_of_ampdu_queues <= txq_id)) {
Wey-Yi Guyb305a082010-03-16 17:41:22 -0700229 IWL_WARN(priv,
230 "queue number out of range: %d, must be %d to %d\n",
Wey-Yi Guy19e6cda2010-03-16 17:41:23 -0700231 txq_id, IWLAGN_FIRST_AMPDU_QUEUE,
232 IWLAGN_FIRST_AMPDU_QUEUE +
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -0700233 priv->cfg->base_params->num_of_ampdu_queues - 1);
Wey-Yi Guyb305a082010-03-16 17:41:22 -0700234 return -EINVAL;
235 }
236
Wey-Yi Guyb305a082010-03-16 17:41:22 -0700237 /* Modify device's station table to Tx this TID */
Johannes Bergc8823ec2011-03-15 11:33:03 -0700238 return iwl_sta_tx_modify_enable_tid(priv, sta_id, tid);
239}
240
241void iwlagn_txq_agg_queue_setup(struct iwl_priv *priv,
242 struct ieee80211_sta *sta,
243 int tid, int frame_limit)
244{
245 int sta_id, tx_fifo, txq_id, ssn_idx;
246 u16 ra_tid;
247 unsigned long flags;
248 struct iwl_tid_data *tid_data;
249
250 sta_id = iwl_sta_id(sta);
251 if (WARN_ON(sta_id == IWL_INVALID_STATION))
252 return;
253 if (WARN_ON(tid >= MAX_TID_COUNT))
254 return;
255
256 spin_lock_irqsave(&priv->sta_lock, flags);
257 tid_data = &priv->stations[sta_id].tid[tid];
258 ssn_idx = SEQ_TO_SN(tid_data->seq_number);
259 txq_id = tid_data->agg.txq_id;
260 tx_fifo = tid_data->agg.tx_fifo;
261 spin_unlock_irqrestore(&priv->sta_lock, flags);
262
263 ra_tid = BUILD_RAxTID(sta_id, tid);
Wey-Yi Guyb305a082010-03-16 17:41:22 -0700264
265 spin_lock_irqsave(&priv->lock, flags);
266
267 /* Stop this Tx queue before configuring it */
268 iwlagn_tx_queue_stop_scheduler(priv, txq_id);
269
270 /* Map receiver-address / traffic-ID to this queue */
271 iwlagn_tx_queue_set_q2ratid(priv, ra_tid, txq_id);
272
273 /* Set this queue as a chain-building queue */
Wey-Yi Guyf4388ad2010-04-12 18:32:11 -0700274 iwl_set_bits_prph(priv, IWLAGN_SCD_QUEUECHAIN_SEL, (1<<txq_id));
Wey-Yi Guyb305a082010-03-16 17:41:22 -0700275
276 /* enable aggregations for the queue */
Wey-Yi Guyf4388ad2010-04-12 18:32:11 -0700277 iwl_set_bits_prph(priv, IWLAGN_SCD_AGGR_SEL, (1<<txq_id));
Wey-Yi Guyb305a082010-03-16 17:41:22 -0700278
279 /* Place first TFD at index corresponding to start sequence number.
280 * Assumes that ssn_idx is valid (!= 0xFFF) */
281 priv->txq[txq_id].q.read_ptr = (ssn_idx & 0xff);
282 priv->txq[txq_id].q.write_ptr = (ssn_idx & 0xff);
283 iwlagn_set_wr_ptrs(priv, txq_id, ssn_idx);
284
285 /* Set up Tx window size and frame limit for this queue */
286 iwl_write_targ_mem(priv, priv->scd_base_addr +
Wey-Yi Guyf4388ad2010-04-12 18:32:11 -0700287 IWLAGN_SCD_CONTEXT_QUEUE_OFFSET(txq_id) +
Wey-Yi Guyb305a082010-03-16 17:41:22 -0700288 sizeof(u32),
Johannes Bergc8823ec2011-03-15 11:33:03 -0700289 ((frame_limit <<
Wey-Yi Guyf4388ad2010-04-12 18:32:11 -0700290 IWLAGN_SCD_QUEUE_CTX_REG2_WIN_SIZE_POS) &
291 IWLAGN_SCD_QUEUE_CTX_REG2_WIN_SIZE_MSK) |
Johannes Bergc8823ec2011-03-15 11:33:03 -0700292 ((frame_limit <<
Wey-Yi Guyf4388ad2010-04-12 18:32:11 -0700293 IWLAGN_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) &
294 IWLAGN_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK));
Wey-Yi Guyb305a082010-03-16 17:41:22 -0700295
Wey-Yi Guyf4388ad2010-04-12 18:32:11 -0700296 iwl_set_bits_prph(priv, IWLAGN_SCD_INTERRUPT_MASK, (1 << txq_id));
Wey-Yi Guyb305a082010-03-16 17:41:22 -0700297
298 /* Set up Status area in SRAM, map to Tx DMA/FIFO, activate the queue */
299 iwlagn_tx_queue_set_status(priv, &priv->txq[txq_id], tx_fifo, 1);
300
301 spin_unlock_irqrestore(&priv->lock, flags);
Wey-Yi Guyb305a082010-03-16 17:41:22 -0700302}
303
Johannes Berg7ffef132011-03-15 04:59:10 -0700304static int iwlagn_txq_agg_disable(struct iwl_priv *priv, u16 txq_id,
305 u16 ssn_idx, u8 tx_fifo)
Wey-Yi Guyb305a082010-03-16 17:41:22 -0700306{
Wey-Yi Guy19e6cda2010-03-16 17:41:23 -0700307 if ((IWLAGN_FIRST_AMPDU_QUEUE > txq_id) ||
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -0700308 (IWLAGN_FIRST_AMPDU_QUEUE +
309 priv->cfg->base_params->num_of_ampdu_queues <= txq_id)) {
Wey-Yi Guyb305a082010-03-16 17:41:22 -0700310 IWL_ERR(priv,
311 "queue number out of range: %d, must be %d to %d\n",
Wey-Yi Guy19e6cda2010-03-16 17:41:23 -0700312 txq_id, IWLAGN_FIRST_AMPDU_QUEUE,
313 IWLAGN_FIRST_AMPDU_QUEUE +
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -0700314 priv->cfg->base_params->num_of_ampdu_queues - 1);
Wey-Yi Guyb305a082010-03-16 17:41:22 -0700315 return -EINVAL;
316 }
317
318 iwlagn_tx_queue_stop_scheduler(priv, txq_id);
319
Wey-Yi Guyf4388ad2010-04-12 18:32:11 -0700320 iwl_clear_bits_prph(priv, IWLAGN_SCD_AGGR_SEL, (1 << txq_id));
Wey-Yi Guyb305a082010-03-16 17:41:22 -0700321
322 priv->txq[txq_id].q.read_ptr = (ssn_idx & 0xff);
323 priv->txq[txq_id].q.write_ptr = (ssn_idx & 0xff);
324 /* supposes that ssn_idx is valid (!= 0xFFF) */
325 iwlagn_set_wr_ptrs(priv, txq_id, ssn_idx);
326
Wey-Yi Guyf4388ad2010-04-12 18:32:11 -0700327 iwl_clear_bits_prph(priv, IWLAGN_SCD_INTERRUPT_MASK, (1 << txq_id));
Wey-Yi Guyb305a082010-03-16 17:41:22 -0700328 iwl_txq_ctx_deactivate(priv, txq_id);
329 iwlagn_tx_queue_set_status(priv, &priv->txq[txq_id], tx_fifo, 0);
330
331 return 0;
332}
333
334/*
335 * Activate/Deactivate Tx DMA/FIFO channels according tx fifos mask
336 * must be called under priv->lock and mac access
337 */
338void iwlagn_txq_set_sched(struct iwl_priv *priv, u32 mask)
339{
Wey-Yi Guyf4388ad2010-04-12 18:32:11 -0700340 iwl_write_prph(priv, IWLAGN_SCD_TXFACT, mask);
Wey-Yi Guyb305a082010-03-16 17:41:22 -0700341}
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700342
Don Fry5c3d29f2011-07-08 08:46:29 -0700343static void iwlagn_tx_cmd_protection(struct iwl_priv *priv,
344 struct ieee80211_tx_info *info,
345 __le16 fc, __le32 *tx_flags)
346{
347 if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS ||
348 info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT ||
349 info->flags & IEEE80211_TX_CTL_AMPDU)
350 *tx_flags |= TX_CMD_FLG_PROT_REQUIRE_MSK;
351}
352
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700353/*
354 * handle build REPLY_TX command notification.
355 */
356static void iwlagn_tx_cmd_build_basic(struct iwl_priv *priv,
Johannes Bergd44ae692010-08-23 07:56:56 -0700357 struct sk_buff *skb,
358 struct iwl_tx_cmd *tx_cmd,
359 struct ieee80211_tx_info *info,
360 struct ieee80211_hdr *hdr,
361 u8 std_id)
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700362{
363 __le16 fc = hdr->frame_control;
364 __le32 tx_flags = tx_cmd->tx_flags;
365
366 tx_cmd->stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE;
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700367
Johannes Berg2c2def12011-07-07 05:11:51 -0700368 if (!(info->flags & IEEE80211_TX_CTL_NO_ACK))
369 tx_flags |= TX_CMD_FLG_ACK_MSK;
370 else
371 tx_flags &= ~TX_CMD_FLG_ACK_MSK;
372
373 if (ieee80211_is_probe_resp(fc))
374 tx_flags |= TX_CMD_FLG_TSF_MSK;
375 else if (ieee80211_is_back_req(fc))
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700376 tx_flags |= TX_CMD_FLG_ACK_MSK | TX_CMD_FLG_IMM_BA_RSP_MASK;
Johannes Bergd44ae692010-08-23 07:56:56 -0700377 else if (info->band == IEEE80211_BAND_2GHZ &&
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -0700378 priv->cfg->bt_params &&
379 priv->cfg->bt_params->advanced_bt_coexist &&
Johannes Bergd44ae692010-08-23 07:56:56 -0700380 (ieee80211_is_auth(fc) || ieee80211_is_assoc_req(fc) ||
381 ieee80211_is_reassoc_req(fc) ||
382 skb->protocol == cpu_to_be16(ETH_P_PAE)))
383 tx_flags |= TX_CMD_FLG_IGNORE_BT;
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700384
385
386 tx_cmd->sta_id = std_id;
387 if (ieee80211_has_morefrags(fc))
388 tx_flags |= TX_CMD_FLG_MORE_FRAG_MSK;
389
390 if (ieee80211_is_data_qos(fc)) {
391 u8 *qc = ieee80211_get_qos_ctl(hdr);
392 tx_cmd->tid_tspec = qc[0] & 0xf;
393 tx_flags &= ~TX_CMD_FLG_SEQ_CTL_MSK;
394 } else {
395 tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK;
396 }
397
Don Fry5c3d29f2011-07-08 08:46:29 -0700398 iwlagn_tx_cmd_protection(priv, info, fc, &tx_flags);
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700399
400 tx_flags &= ~(TX_CMD_FLG_ANT_SEL_MSK);
401 if (ieee80211_is_mgmt(fc)) {
402 if (ieee80211_is_assoc_req(fc) || ieee80211_is_reassoc_req(fc))
403 tx_cmd->timeout.pm_frame_timeout = cpu_to_le16(3);
404 else
405 tx_cmd->timeout.pm_frame_timeout = cpu_to_le16(2);
406 } else {
407 tx_cmd->timeout.pm_frame_timeout = 0;
408 }
409
410 tx_cmd->driver_txop = 0;
411 tx_cmd->tx_flags = tx_flags;
412 tx_cmd->next_frame_len = 0;
413}
414
415#define RTS_DFAULT_RETRY_LIMIT 60
416
417static void iwlagn_tx_cmd_build_rate(struct iwl_priv *priv,
418 struct iwl_tx_cmd *tx_cmd,
419 struct ieee80211_tx_info *info,
420 __le16 fc)
421{
422 u32 rate_flags;
423 int rate_idx;
424 u8 rts_retry_limit;
425 u8 data_retry_limit;
426 u8 rate_plcp;
427
428 /* Set retry limit on DATA packets and Probe Responses*/
429 if (ieee80211_is_probe_resp(fc))
430 data_retry_limit = 3;
431 else
Wey-Yi Guyb744cb72010-03-23 11:37:59 -0700432 data_retry_limit = IWLAGN_DEFAULT_TX_RETRY;
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700433 tx_cmd->data_retry_limit = data_retry_limit;
434
435 /* Set retry limit on RTS packets */
436 rts_retry_limit = RTS_DFAULT_RETRY_LIMIT;
437 if (data_retry_limit < rts_retry_limit)
438 rts_retry_limit = data_retry_limit;
439 tx_cmd->rts_retry_limit = rts_retry_limit;
440
441 /* DATA packets will use the uCode station table for rate/antenna
442 * selection */
443 if (ieee80211_is_data(fc)) {
444 tx_cmd->initial_rate_index = 0;
445 tx_cmd->tx_flags |= TX_CMD_FLG_STA_RATE_MSK;
Wey-Yi Guy4e308112011-07-08 08:46:28 -0700446 if (priv->tm_fixed_rate) {
447 /*
448 * rate overwrite by testmode
449 * we not only send lq command to change rate
450 * we also re-enforce per data pkt base.
451 */
452 tx_cmd->tx_flags &= ~TX_CMD_FLG_STA_RATE_MSK;
453 memcpy(&tx_cmd->rate_n_flags, &priv->tm_fixed_rate,
454 sizeof(tx_cmd->rate_n_flags));
455 }
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700456 return;
457 }
458
459 /**
460 * If the current TX rate stored in mac80211 has the MCS bit set, it's
461 * not really a TX rate. Thus, we use the lowest supported rate for
462 * this band. Also use the lowest supported rate if the stored rate
463 * index is invalid.
464 */
465 rate_idx = info->control.rates[0].idx;
466 if (info->control.rates[0].flags & IEEE80211_TX_RC_MCS ||
467 (rate_idx < 0) || (rate_idx > IWL_RATE_COUNT_LEGACY))
468 rate_idx = rate_lowest_index(&priv->bands[info->band],
469 info->control.sta);
470 /* For 5 GHZ band, remap mac80211 rate indices into driver indices */
471 if (info->band == IEEE80211_BAND_5GHZ)
472 rate_idx += IWL_FIRST_OFDM_RATE;
473 /* Get PLCP rate for tx_cmd->rate_n_flags */
474 rate_plcp = iwl_rates[rate_idx].plcp;
475 /* Zero out flags for this packet */
476 rate_flags = 0;
477
478 /* Set CCK flag as needed */
479 if ((rate_idx >= IWL_FIRST_CCK_RATE) && (rate_idx <= IWL_LAST_CCK_RATE))
480 rate_flags |= RATE_MCS_CCK_MSK;
481
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700482 /* Set up antennas */
Wey-Yi Guy7cb1b082010-10-06 08:10:00 -0700483 if (priv->cfg->bt_params &&
484 priv->cfg->bt_params->advanced_bt_coexist &&
485 priv->bt_full_concurrent) {
Wey-Yi Guybee008b2010-08-23 07:57:04 -0700486 /* operated as 1x1 in full concurrency mode */
487 priv->mgmt_tx_ant = iwl_toggle_tx_ant(priv, priv->mgmt_tx_ant,
488 first_antenna(priv->hw_params.valid_tx_ant));
489 } else
490 priv->mgmt_tx_ant = iwl_toggle_tx_ant(priv, priv->mgmt_tx_ant,
Johannes Berg0e1654f2010-05-18 02:48:36 -0700491 priv->hw_params.valid_tx_ant);
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700492 rate_flags |= iwl_ant_idx_to_flags(priv->mgmt_tx_ant);
493
494 /* Set the rate in the TX cmd */
495 tx_cmd->rate_n_flags = iwl_hw_set_rate_n_flags(rate_plcp, rate_flags);
496}
497
498static void iwlagn_tx_cmd_build_hwcrypto(struct iwl_priv *priv,
499 struct ieee80211_tx_info *info,
500 struct iwl_tx_cmd *tx_cmd,
501 struct sk_buff *skb_frag,
502 int sta_id)
503{
504 struct ieee80211_key_conf *keyconf = info->control.hw_key;
505
Johannes Berg97359d12010-08-10 09:46:38 +0200506 switch (keyconf->cipher) {
507 case WLAN_CIPHER_SUITE_CCMP:
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700508 tx_cmd->sec_ctl = TX_CMD_SEC_CCM;
509 memcpy(tx_cmd->key, keyconf->key, keyconf->keylen);
510 if (info->flags & IEEE80211_TX_CTL_AMPDU)
511 tx_cmd->tx_flags |= TX_CMD_FLG_AGG_CCMP_MSK;
512 IWL_DEBUG_TX(priv, "tx_cmd with AES hwcrypto\n");
513 break;
514
Johannes Berg97359d12010-08-10 09:46:38 +0200515 case WLAN_CIPHER_SUITE_TKIP:
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700516 tx_cmd->sec_ctl = TX_CMD_SEC_TKIP;
Johannes Berg523b02e2011-07-07 22:28:01 +0200517 ieee80211_get_tkip_p2k(keyconf, skb_frag, tx_cmd->key);
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700518 IWL_DEBUG_TX(priv, "tx_cmd with tkip hwcrypto\n");
519 break;
520
Johannes Berg97359d12010-08-10 09:46:38 +0200521 case WLAN_CIPHER_SUITE_WEP104:
522 tx_cmd->sec_ctl |= TX_CMD_SEC_KEY128;
523 /* fall through */
524 case WLAN_CIPHER_SUITE_WEP40:
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700525 tx_cmd->sec_ctl |= (TX_CMD_SEC_WEP |
526 (keyconf->keyidx & TX_CMD_SEC_MSK) << TX_CMD_SEC_SHIFT);
527
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700528 memcpy(&tx_cmd->key[3], keyconf->key, keyconf->keylen);
529
530 IWL_DEBUG_TX(priv, "Configuring packet for WEP encryption "
531 "with key %d\n", keyconf->keyidx);
532 break;
533
534 default:
Johannes Berg97359d12010-08-10 09:46:38 +0200535 IWL_ERR(priv, "Unknown encode cipher %x\n", keyconf->cipher);
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700536 break;
537 }
538}
539
540/*
541 * start REPLY_TX command process
542 */
543int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
544{
545 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
546 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700547 struct iwl_station_priv *sta_priv = NULL;
Johannes Berga194e322010-08-27 08:53:46 -0700548 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
Emmanuel Grumbach47c1b492011-07-03 11:22:15 +0300549 struct iwl_tx_cmd *tx_cmd;
Johannes Berg8d563962010-11-10 18:25:42 -0800550 int txq_id;
Emmanuel Grumbach47c1b492011-07-03 11:22:15 +0300551
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700552 u16 seq_number = 0;
553 __le16 fc;
554 u8 hdr_len;
Emmanuel Grumbach47c1b492011-07-03 11:22:15 +0300555 u16 len;
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700556 u8 sta_id;
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700557 u8 tid = 0;
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700558 unsigned long flags;
Johannes Berg2e340342010-11-16 11:51:38 -0800559 bool is_agg = false;
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700560
Johannes Berg9b9190d2011-01-06 08:07:10 -0800561 /*
562 * If the frame needs to go out off-channel, then
563 * we'll have put the PAN context to that channel,
564 * so make the frame go out there.
565 */
566 if (info->flags & IEEE80211_TX_CTL_TX_OFFCHAN)
567 ctx = &priv->contexts[IWL_RXON_CTX_PAN];
568 else if (info->control.vif)
Johannes Berga194e322010-08-27 08:53:46 -0700569 ctx = iwl_rxon_ctx_from_vif(info->control.vif);
570
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700571 spin_lock_irqsave(&priv->lock, flags);
572 if (iwl_is_rfkill(priv)) {
573 IWL_DEBUG_DROP(priv, "Dropping - RF KILL\n");
Johannes Berg2c46f722011-04-28 07:27:10 -0700574 goto drop_unlock_priv;
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700575 }
576
577 fc = hdr->frame_control;
578
579#ifdef CONFIG_IWLWIFI_DEBUG
580 if (ieee80211_is_auth(fc))
581 IWL_DEBUG_TX(priv, "Sending AUTH frame\n");
582 else if (ieee80211_is_assoc_req(fc))
583 IWL_DEBUG_TX(priv, "Sending ASSOC frame\n");
584 else if (ieee80211_is_reassoc_req(fc))
585 IWL_DEBUG_TX(priv, "Sending REASSOC frame\n");
586#endif
587
588 hdr_len = ieee80211_hdrlen(fc);
589
Stanislaw Gruszkabfd36102011-04-29 17:51:06 +0200590 /* For management frames use broadcast id to do not break aggregation */
591 if (!ieee80211_is_data(fc))
592 sta_id = ctx->bcast_sta_id;
593 else {
594 /* Find index into station table for destination station */
595 sta_id = iwl_sta_id_or_broadcast(priv, ctx, info->control.sta);
596 if (sta_id == IWL_INVALID_STATION) {
597 IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n",
598 hdr->addr1);
John W. Linvillee00cf3b2011-05-16 14:55:42 -0400599 goto drop_unlock_priv;
Stanislaw Gruszkabfd36102011-04-29 17:51:06 +0200600 }
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700601 }
602
603 IWL_DEBUG_TX(priv, "station Id %d\n", sta_id);
604
Emmanuel Grumbach47c1b492011-07-03 11:22:15 +0300605 if (info->control.sta)
606 sta_priv = (void *)info->control.sta->drv_priv;
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700607
Johannes Berg67158b62010-11-16 11:51:04 -0800608 if (sta_priv && sta_priv->asleep &&
609 (info->flags & IEEE80211_TX_CTL_PSPOLL_RESPONSE)) {
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700610 /*
611 * This sends an asynchronous command to the device,
612 * but we can rely on it being processed before the
613 * next frame is processed -- and the next frame to
614 * this station is the one that will consume this
615 * counter.
616 * For now set the counter to just 1 since we do not
617 * support uAPSD yet.
618 */
619 iwl_sta_modify_sleep_tx_count(priv, sta_id, 1);
620 }
621
Johannes Berge72f3682010-08-23 10:46:51 +0200622 /*
623 * Send this frame after DTIM -- there's a special queue
624 * reserved for this for contexts that support AP mode.
625 */
626 if (info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM) {
627 txq_id = ctx->mcast_queue;
628 /*
629 * The microcode will clear the more data
630 * bit in the last frame it transmits.
631 */
632 hdr->frame_control |=
633 cpu_to_le16(IEEE80211_FCTL_MOREDATA);
634 } else
635 txq_id = ctx->ac_to_queue[skb_get_queue_mapping(skb)];
Reinette Chatre9c5ac092010-05-05 02:26:06 -0700636
637 /* irqs already disabled/saved above when locking priv->lock */
638 spin_lock(&priv->sta_lock);
639
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700640 if (ieee80211_is_data_qos(fc)) {
Emmanuel Grumbach47c1b492011-07-03 11:22:15 +0300641 u8 *qc = NULL;
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700642 qc = ieee80211_get_qos_ctl(hdr);
643 tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK;
Johannes Berg2c46f722011-04-28 07:27:10 -0700644
645 if (WARN_ON_ONCE(tid >= MAX_TID_COUNT))
646 goto drop_unlock_sta;
647
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700648 seq_number = priv->stations[sta_id].tid[tid].seq_number;
649 seq_number &= IEEE80211_SCTL_SEQ;
650 hdr->seq_ctrl = hdr->seq_ctrl &
651 cpu_to_le16(IEEE80211_SCTL_FRAG);
652 hdr->seq_ctrl |= cpu_to_le16(seq_number);
653 seq_number += 0x10;
654 /* aggregation is on for this <sta,tid> */
655 if (info->flags & IEEE80211_TX_CTL_AMPDU &&
656 priv->stations[sta_id].tid[tid].agg.state == IWL_AGG_ON) {
657 txq_id = priv->stations[sta_id].tid[tid].agg.txq_id;
Johannes Berg2e340342010-11-16 11:51:38 -0800658 is_agg = true;
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700659 }
660 }
661
Emmanuel Grumbach47c1b492011-07-03 11:22:15 +0300662 tx_cmd = trans_get_tx_cmd(priv, txq_id);
663 if (unlikely(!tx_cmd))
Johannes Berg2c46f722011-04-28 07:27:10 -0700664 goto drop_unlock_sta;
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700665
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700666 /* Copy MAC header from skb into command buffer */
667 memcpy(tx_cmd->hdr, hdr, hdr_len);
668
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700669 /* Total # bytes to be transmitted */
670 len = (u16)skb->len;
671 tx_cmd->len = cpu_to_le16(len);
672
673 if (info->control.hw_key)
674 iwlagn_tx_cmd_build_hwcrypto(priv, info, tx_cmd, skb, sta_id);
675
676 /* TODO need this for burst mode later on */
Johannes Bergd44ae692010-08-23 07:56:56 -0700677 iwlagn_tx_cmd_build_basic(priv, skb, tx_cmd, info, hdr, sta_id);
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700678 iwl_dbg_log_tx_data_frame(priv, len, hdr);
679
680 iwlagn_tx_cmd_build_rate(priv, tx_cmd, info, fc);
681
682 iwl_update_stats(priv, true, fc, len);
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700683
Emmanuel Grumbach47c1b492011-07-03 11:22:15 +0300684 if (trans_tx(priv, skb, tx_cmd, txq_id, fc, is_agg, ctx))
Johannes Berg2c46f722011-04-28 07:27:10 -0700685 goto drop_unlock_sta;
Johannes Berg2c46f722011-04-28 07:27:10 -0700686
687 if (ieee80211_is_data_qos(fc)) {
688 priv->stations[sta_id].tid[tid].tfds_in_queue++;
689 if (!ieee80211_has_morefrags(fc))
690 priv->stations[sta_id].tid[tid].seq_number = seq_number;
691 }
692
693 spin_unlock(&priv->sta_lock);
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700694 spin_unlock_irqrestore(&priv->lock, flags);
695
696 /*
Johannes Berg2e340342010-11-16 11:51:38 -0800697 * Avoid atomic ops if it isn't an associated client.
698 * Also, if this is a packet for aggregation, don't
699 * increase the counter because the ucode will stop
700 * aggregation queues when their respective station
701 * goes to sleep.
702 */
703 if (sta_priv && sta_priv->client && !is_agg)
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700704 atomic_inc(&sta_priv->pending_frames);
705
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700706 return 0;
707
Johannes Berg2c46f722011-04-28 07:27:10 -0700708drop_unlock_sta:
709 spin_unlock(&priv->sta_lock);
710drop_unlock_priv:
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700711 spin_unlock_irqrestore(&priv->lock, flags);
712 return -1;
713}
714
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700715/*
716 * Find first available (lowest unused) Tx Queue, mark it "active".
717 * Called only when finding queue for aggregation.
718 * Should never return anything < 7, because they should already
719 * be in use as EDCA AC (0-3), Command (4), reserved (5, 6)
720 */
721static int iwlagn_txq_ctx_activate_free(struct iwl_priv *priv)
722{
723 int txq_id;
724
725 for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++)
726 if (!test_and_set_bit(txq_id, &priv->txq_ctx_active_msk))
727 return txq_id;
728 return -1;
729}
730
Johannes Berg832f47e2010-04-29 04:43:07 -0700731int iwlagn_tx_agg_start(struct iwl_priv *priv, struct ieee80211_vif *vif,
Johannes Berg619753f2010-04-30 11:30:46 -0700732 struct ieee80211_sta *sta, u16 tid, u16 *ssn)
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700733{
734 int sta_id;
735 int tx_fifo;
736 int txq_id;
737 int ret;
738 unsigned long flags;
739 struct iwl_tid_data *tid_data;
740
Johannes Berge72f3682010-08-23 10:46:51 +0200741 tx_fifo = get_fifo_from_tid(iwl_rxon_ctx_from_vif(vif), tid);
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700742 if (unlikely(tx_fifo < 0))
743 return tx_fifo;
744
Wey-Yi Guy5bc98902011-05-27 08:40:32 -0700745 IWL_DEBUG_HT(priv, "TX AGG request on ra = %pM tid = %d\n",
746 sta->addr, tid);
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700747
Johannes Berg619753f2010-04-30 11:30:46 -0700748 sta_id = iwl_sta_id(sta);
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700749 if (sta_id == IWL_INVALID_STATION) {
750 IWL_ERR(priv, "Start AGG on invalid station\n");
751 return -ENXIO;
752 }
753 if (unlikely(tid >= MAX_TID_COUNT))
754 return -EINVAL;
755
756 if (priv->stations[sta_id].tid[tid].agg.state != IWL_AGG_OFF) {
757 IWL_ERR(priv, "Start AGG when state is not IWL_AGG_OFF !\n");
758 return -ENXIO;
759 }
760
761 txq_id = iwlagn_txq_ctx_activate_free(priv);
762 if (txq_id == -1) {
763 IWL_ERR(priv, "No free aggregation queue available\n");
764 return -ENXIO;
765 }
766
767 spin_lock_irqsave(&priv->sta_lock, flags);
768 tid_data = &priv->stations[sta_id].tid[tid];
769 *ssn = SEQ_TO_SN(tid_data->seq_number);
770 tid_data->agg.txq_id = txq_id;
Johannes Bergc8823ec2011-03-15 11:33:03 -0700771 tid_data->agg.tx_fifo = tx_fifo;
Johannes Bergea9b3072010-11-10 18:25:45 -0800772 iwl_set_swq_id(&priv->txq[txq_id], get_ac_from_tid(tid), txq_id);
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700773 spin_unlock_irqrestore(&priv->sta_lock, flags);
774
Johannes Bergc8823ec2011-03-15 11:33:03 -0700775 ret = iwlagn_txq_agg_enable(priv, txq_id, sta_id, tid);
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700776 if (ret)
777 return ret;
778
Reinette Chatre9c5ac092010-05-05 02:26:06 -0700779 spin_lock_irqsave(&priv->sta_lock, flags);
780 tid_data = &priv->stations[sta_id].tid[tid];
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700781 if (tid_data->tfds_in_queue == 0) {
782 IWL_DEBUG_HT(priv, "HW queue is empty\n");
783 tid_data->agg.state = IWL_AGG_ON;
Johannes Berg619753f2010-04-30 11:30:46 -0700784 ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid);
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700785 } else {
786 IWL_DEBUG_HT(priv, "HW queue is NOT empty: %d packets in HW queue\n",
787 tid_data->tfds_in_queue);
788 tid_data->agg.state = IWL_EMPTYING_HW_QUEUE_ADDBA;
789 }
Reinette Chatre9c5ac092010-05-05 02:26:06 -0700790 spin_unlock_irqrestore(&priv->sta_lock, flags);
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700791 return ret;
792}
793
Johannes Berg832f47e2010-04-29 04:43:07 -0700794int iwlagn_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif,
Johannes Berg619753f2010-04-30 11:30:46 -0700795 struct ieee80211_sta *sta, u16 tid)
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700796{
Johannes Berg18c121d2010-08-23 07:57:17 -0700797 int tx_fifo_id, txq_id, sta_id, ssn;
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700798 struct iwl_tid_data *tid_data;
799 int write_ptr, read_ptr;
800 unsigned long flags;
801
Johannes Berge72f3682010-08-23 10:46:51 +0200802 tx_fifo_id = get_fifo_from_tid(iwl_rxon_ctx_from_vif(vif), tid);
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700803 if (unlikely(tx_fifo_id < 0))
804 return tx_fifo_id;
805
Johannes Berg619753f2010-04-30 11:30:46 -0700806 sta_id = iwl_sta_id(sta);
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700807
808 if (sta_id == IWL_INVALID_STATION) {
809 IWL_ERR(priv, "Invalid station for AGG tid %d\n", tid);
810 return -ENXIO;
811 }
812
Reinette Chatre9c5ac092010-05-05 02:26:06 -0700813 spin_lock_irqsave(&priv->sta_lock, flags);
814
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700815 tid_data = &priv->stations[sta_id].tid[tid];
816 ssn = (tid_data->seq_number & IEEE80211_SCTL_SEQ) >> 4;
817 txq_id = tid_data->agg.txq_id;
Johannes Berg18c121d2010-08-23 07:57:17 -0700818
819 switch (priv->stations[sta_id].tid[tid].agg.state) {
820 case IWL_EMPTYING_HW_QUEUE_ADDBA:
821 /*
822 * This can happen if the peer stops aggregation
823 * again before we've had a chance to drain the
824 * queue we selected previously, i.e. before the
825 * session was really started completely.
826 */
827 IWL_DEBUG_HT(priv, "AGG stop before setup done\n");
828 goto turn_off;
829 case IWL_AGG_ON:
830 break;
831 default:
832 IWL_WARN(priv, "Stopping AGG while state not ON or starting\n");
833 }
834
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700835 write_ptr = priv->txq[txq_id].q.write_ptr;
836 read_ptr = priv->txq[txq_id].q.read_ptr;
837
838 /* The queue is not empty */
839 if (write_ptr != read_ptr) {
840 IWL_DEBUG_HT(priv, "Stopping a non empty AGG HW QUEUE\n");
841 priv->stations[sta_id].tid[tid].agg.state =
842 IWL_EMPTYING_HW_QUEUE_DELBA;
Reinette Chatre9c5ac092010-05-05 02:26:06 -0700843 spin_unlock_irqrestore(&priv->sta_lock, flags);
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700844 return 0;
845 }
846
847 IWL_DEBUG_HT(priv, "HW queue is empty\n");
Johannes Berg18c121d2010-08-23 07:57:17 -0700848 turn_off:
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700849 priv->stations[sta_id].tid[tid].agg.state = IWL_AGG_OFF;
850
Reinette Chatre9c5ac092010-05-05 02:26:06 -0700851 /* do not restore/save irqs */
852 spin_unlock(&priv->sta_lock);
853 spin_lock(&priv->lock);
854
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700855 /*
856 * the only reason this call can fail is queue number out of range,
857 * which can happen if uCode is reloaded and all the station
858 * information are lost. if it is outside the range, there is no need
859 * to deactivate the uCode queue, just return "success" to allow
860 * mac80211 to clean up it own data.
861 */
Johannes Berg7ffef132011-03-15 04:59:10 -0700862 iwlagn_txq_agg_disable(priv, txq_id, ssn, tx_fifo_id);
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700863 spin_unlock_irqrestore(&priv->lock, flags);
864
Johannes Berg619753f2010-04-30 11:30:46 -0700865 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700866
867 return 0;
868}
869
870int iwlagn_txq_check_empty(struct iwl_priv *priv,
871 int sta_id, u8 tid, int txq_id)
872{
873 struct iwl_queue *q = &priv->txq[txq_id].q;
874 u8 *addr = priv->stations[sta_id].sta.sta.addr;
875 struct iwl_tid_data *tid_data = &priv->stations[sta_id].tid[tid];
Johannes Berg8bd413e2010-08-23 10:46:40 +0200876 struct iwl_rxon_context *ctx;
877
878 ctx = &priv->contexts[priv->stations[sta_id].ctxid];
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700879
Johannes Berga24d52f2010-08-06 16:17:53 +0200880 lockdep_assert_held(&priv->sta_lock);
Reinette Chatre9c5ac092010-05-05 02:26:06 -0700881
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700882 switch (priv->stations[sta_id].tid[tid].agg.state) {
883 case IWL_EMPTYING_HW_QUEUE_DELBA:
884 /* We are reclaiming the last packet of the */
885 /* aggregated HW queue */
886 if ((txq_id == tid_data->agg.txq_id) &&
887 (q->read_ptr == q->write_ptr)) {
888 u16 ssn = SEQ_TO_SN(tid_data->seq_number);
Johannes Berge72f3682010-08-23 10:46:51 +0200889 int tx_fifo = get_fifo_from_tid(ctx, tid);
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700890 IWL_DEBUG_HT(priv, "HW queue empty: continue DELBA flow\n");
Johannes Berg7ffef132011-03-15 04:59:10 -0700891 iwlagn_txq_agg_disable(priv, txq_id, ssn, tx_fifo);
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700892 tid_data->agg.state = IWL_AGG_OFF;
Johannes Berg8bd413e2010-08-23 10:46:40 +0200893 ieee80211_stop_tx_ba_cb_irqsafe(ctx->vif, addr, tid);
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700894 }
895 break;
896 case IWL_EMPTYING_HW_QUEUE_ADDBA:
897 /* We are reclaiming the last packet of the queue */
898 if (tid_data->tfds_in_queue == 0) {
899 IWL_DEBUG_HT(priv, "HW queue empty: continue ADDBA flow\n");
900 tid_data->agg.state = IWL_AGG_ON;
Johannes Berg8bd413e2010-08-23 10:46:40 +0200901 ieee80211_start_tx_ba_cb_irqsafe(ctx->vif, addr, tid);
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700902 }
903 break;
904 }
Reinette Chatre9c5ac092010-05-05 02:26:06 -0700905
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700906 return 0;
907}
908
Johannes Berg2e340342010-11-16 11:51:38 -0800909static void iwlagn_non_agg_tx_status(struct iwl_priv *priv,
910 struct iwl_rxon_context *ctx,
911 const u8 *addr1)
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700912{
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700913 struct ieee80211_sta *sta;
914 struct iwl_station_priv *sta_priv;
915
Johannes Berg6db63402010-06-07 21:20:38 +0200916 rcu_read_lock();
Johannes Berg2e340342010-11-16 11:51:38 -0800917 sta = ieee80211_find_sta(ctx->vif, addr1);
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700918 if (sta) {
919 sta_priv = (void *)sta->drv_priv;
920 /* avoid atomic ops if this isn't a client */
921 if (sta_priv->client &&
922 atomic_dec_return(&sta_priv->pending_frames) == 0)
923 ieee80211_sta_block_awake(priv->hw, sta, false);
924 }
Johannes Berg6db63402010-06-07 21:20:38 +0200925 rcu_read_unlock();
Johannes Berg2e340342010-11-16 11:51:38 -0800926}
927
928static void iwlagn_tx_status(struct iwl_priv *priv, struct iwl_tx_info *tx_info,
929 bool is_agg)
930{
931 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx_info->skb->data;
932
933 if (!is_agg)
934 iwlagn_non_agg_tx_status(priv, tx_info->ctx, hdr->addr1);
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700935
Johannes Berg8bd413e2010-08-23 10:46:40 +0200936 ieee80211_tx_status_irqsafe(priv->hw, tx_info->skb);
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700937}
938
939int iwlagn_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index)
940{
941 struct iwl_tx_queue *txq = &priv->txq[txq_id];
942 struct iwl_queue *q = &txq->q;
943 struct iwl_tx_info *tx_info;
944 int nfreed = 0;
945 struct ieee80211_hdr *hdr;
946
947 if ((index >= q->n_bd) || (iwl_queue_used(q, index) == 0)) {
Daniel Halperin2e5d04d2011-05-27 08:40:28 -0700948 IWL_ERR(priv, "%s: Read index for DMA queue txq id (%d), "
949 "index %d is out of range [0-%d] %d %d.\n", __func__,
950 txq_id, index, q->n_bd, q->write_ptr, q->read_ptr);
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700951 return 0;
952 }
953
954 for (index = iwl_queue_inc_wrap(index, q->n_bd);
955 q->read_ptr != index;
956 q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) {
957
958 tx_info = &txq->txb[txq->q.read_ptr];
Stanislaw Gruszkab2502692011-04-20 15:57:14 +0200959
960 if (WARN_ON_ONCE(tx_info->skb == NULL))
961 continue;
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700962
Johannes Bergff0d91c2010-05-17 02:37:34 -0700963 hdr = (struct ieee80211_hdr *)tx_info->skb->data;
Stanislaw Gruszkab2502692011-04-20 15:57:14 +0200964 if (ieee80211_is_data_qos(hdr->frame_control))
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700965 nfreed++;
Stanislaw Gruszkab2502692011-04-20 15:57:14 +0200966
967 iwlagn_tx_status(priv, tx_info,
968 txq_id >= IWLAGN_FIRST_AMPDU_QUEUE);
Johannes Bergff0d91c2010-05-17 02:37:34 -0700969 tx_info->skb = NULL;
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700970
Johannes Berg94b00652011-04-28 07:27:09 -0700971 iwlagn_txq_inval_byte_cnt_tbl(priv, txq);
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700972
Emmanuel Grumbach1359ca42011-07-08 08:46:10 -0700973 iwlagn_txq_free_tfd(priv, txq, txq->q.read_ptr);
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700974 }
975 return nfreed;
976}
977
978/**
979 * iwlagn_tx_status_reply_compressed_ba - Update tx status from block-ack
980 *
981 * Go through block-ack's bitmap of ACK'd frames, update driver's record of
982 * ACK vs. not. This gets sent to mac80211, then to rate scaling algo.
983 */
984static int iwlagn_tx_status_reply_compressed_ba(struct iwl_priv *priv,
985 struct iwl_ht_agg *agg,
986 struct iwl_compressed_ba_resp *ba_resp)
987
988{
Daniel Halperind0eb6332011-03-16 17:17:36 -0700989 int sh;
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700990 u16 seq_ctl = le16_to_cpu(ba_resp->seq_ctl);
991 u16 scd_flow = le16_to_cpu(ba_resp->scd_flow);
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700992 struct ieee80211_tx_info *info;
Daniel Halperind0eb6332011-03-16 17:17:36 -0700993 u64 bitmap, sent_bitmap;
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700994
995 if (unlikely(!agg->wait_for_ba)) {
Don Fry822395b2010-10-23 09:02:50 -0700996 if (unlikely(ba_resp->bitmap))
997 IWL_ERR(priv, "Received BA when not expected\n");
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -0700998 return -EINVAL;
999 }
1000
1001 /* Mark that the expected block-ack response arrived */
1002 agg->wait_for_ba = 0;
1003 IWL_DEBUG_TX_REPLY(priv, "BA %d %d\n", agg->start_idx, ba_resp->seq_ctl);
1004
1005 /* Calculate shift to align block-ack bits with our Tx window bits */
1006 sh = agg->start_idx - SEQ_TO_INDEX(seq_ctl >> 4);
Daniel Halperind0eb6332011-03-16 17:17:36 -07001007 if (sh < 0)
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -07001008 sh += 0x100;
1009
Daniel Halperind0eb6332011-03-16 17:17:36 -07001010 /*
1011 * Check for success or failure according to the
1012 * transmitted bitmap and block-ack bitmap
1013 */
1014 bitmap = le64_to_cpu(ba_resp->bitmap) >> sh;
1015 sent_bitmap = bitmap & agg->bitmap;
1016
1017 /* Sanity check values reported by uCode */
1018 if (ba_resp->txed_2_done > ba_resp->txed) {
1019 IWL_DEBUG_TX_REPLY(priv,
1020 "bogus sent(%d) and ack(%d) count\n",
1021 ba_resp->txed, ba_resp->txed_2_done);
Wey-Yi Guy8829c9e2010-11-10 11:05:38 -08001022 /*
Daniel Halperind0eb6332011-03-16 17:17:36 -07001023 * set txed_2_done = txed,
1024 * so it won't impact rate scale
Wey-Yi Guy8829c9e2010-11-10 11:05:38 -08001025 */
Daniel Halperind0eb6332011-03-16 17:17:36 -07001026 ba_resp->txed = ba_resp->txed_2_done;
1027 }
1028 IWL_DEBUG_HT(priv, "agg frames sent:%d, acked:%d\n",
1029 ba_resp->txed, ba_resp->txed_2_done);
Johannes Berg9decde92010-11-30 13:24:36 -08001030
Daniel Halperind0eb6332011-03-16 17:17:36 -07001031 /* Find the first ACKed frame to store the TX status */
1032 while (sent_bitmap && !(sent_bitmap & 1)) {
1033 agg->start_idx = (agg->start_idx + 1) & 0xff;
1034 sent_bitmap >>= 1;
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -07001035 }
Johannes Berg9decde92010-11-30 13:24:36 -08001036
Johannes Bergff0d91c2010-05-17 02:37:34 -07001037 info = IEEE80211_SKB_CB(priv->txq[scd_flow].txb[agg->start_idx].skb);
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -07001038 memset(&info->status, 0, sizeof(info->status));
1039 info->flags |= IEEE80211_TX_STAT_ACK;
1040 info->flags |= IEEE80211_TX_STAT_AMPDU;
Daniel Halperind0eb6332011-03-16 17:17:36 -07001041 info->status.ampdu_ack_len = ba_resp->txed_2_done;
1042 info->status.ampdu_len = ba_resp->txed;
Wey-Yi Guy8d801082010-03-17 13:34:36 -07001043 iwlagn_hwrate_to_tx_control(priv, agg->rate_n_flags, info);
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -07001044
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -07001045 return 0;
1046}
1047
1048/**
Wey-Yi Guy8d801082010-03-17 13:34:36 -07001049 * translate ucode response to mac80211 tx status control values
1050 */
1051void iwlagn_hwrate_to_tx_control(struct iwl_priv *priv, u32 rate_n_flags,
1052 struct ieee80211_tx_info *info)
1053{
1054 struct ieee80211_tx_rate *r = &info->control.rates[0];
1055
1056 info->antenna_sel_tx =
1057 ((rate_n_flags & RATE_MCS_ANT_ABC_MSK) >> RATE_MCS_ANT_POS);
1058 if (rate_n_flags & RATE_MCS_HT_MSK)
1059 r->flags |= IEEE80211_TX_RC_MCS;
1060 if (rate_n_flags & RATE_MCS_GF_MSK)
1061 r->flags |= IEEE80211_TX_RC_GREEN_FIELD;
1062 if (rate_n_flags & RATE_MCS_HT40_MSK)
1063 r->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH;
1064 if (rate_n_flags & RATE_MCS_DUP_MSK)
1065 r->flags |= IEEE80211_TX_RC_DUP_DATA;
1066 if (rate_n_flags & RATE_MCS_SGI_MSK)
1067 r->flags |= IEEE80211_TX_RC_SHORT_GI;
1068 r->idx = iwlagn_hwrate_to_mac80211_idx(rate_n_flags, info->band);
1069}
1070
1071/**
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -07001072 * iwlagn_rx_reply_compressed_ba - Handler for REPLY_COMPRESSED_BA
1073 *
1074 * Handles block-acknowledge notification from device, which reports success
1075 * of frames sent via aggregation.
1076 */
1077void iwlagn_rx_reply_compressed_ba(struct iwl_priv *priv,
1078 struct iwl_rx_mem_buffer *rxb)
1079{
1080 struct iwl_rx_packet *pkt = rxb_addr(rxb);
1081 struct iwl_compressed_ba_resp *ba_resp = &pkt->u.compressed_ba;
1082 struct iwl_tx_queue *txq = NULL;
1083 struct iwl_ht_agg *agg;
1084 int index;
1085 int sta_id;
1086 int tid;
Reinette Chatre9c5ac092010-05-05 02:26:06 -07001087 unsigned long flags;
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -07001088
1089 /* "flow" corresponds to Tx queue */
1090 u16 scd_flow = le16_to_cpu(ba_resp->scd_flow);
1091
1092 /* "ssn" is start of block-ack Tx window, corresponds to index
1093 * (in Tx queue's circular buffer) of first TFD/frame in window */
1094 u16 ba_resp_scd_ssn = le16_to_cpu(ba_resp->scd_ssn);
1095
1096 if (scd_flow >= priv->hw_params.max_txq_num) {
1097 IWL_ERR(priv,
1098 "BUG_ON scd_flow is bigger than number of queues\n");
1099 return;
1100 }
1101
1102 txq = &priv->txq[scd_flow];
1103 sta_id = ba_resp->sta_id;
1104 tid = ba_resp->tid;
1105 agg = &priv->stations[sta_id].tid[tid].agg;
Shanyu Zhaob561e822010-06-01 17:13:58 -07001106 if (unlikely(agg->txq_id != scd_flow)) {
Wey-Yi Guy735df292010-07-31 08:34:11 -07001107 /*
1108 * FIXME: this is a uCode bug which need to be addressed,
1109 * log the information and return for now!
1110 * since it is possible happen very often and in order
1111 * not to fill the syslog, don't enable the logging by default
1112 */
1113 IWL_DEBUG_TX_REPLY(priv,
1114 "BA scd_flow %d does not match txq_id %d\n",
Shanyu Zhaob561e822010-06-01 17:13:58 -07001115 scd_flow, agg->txq_id);
1116 return;
1117 }
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -07001118
1119 /* Find index just before block-ack window */
1120 index = iwl_queue_dec_wrap(ba_resp_scd_ssn & 0xff, txq->q.n_bd);
1121
Reinette Chatre9c5ac092010-05-05 02:26:06 -07001122 spin_lock_irqsave(&priv->sta_lock, flags);
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -07001123
1124 IWL_DEBUG_TX_REPLY(priv, "REPLY_COMPRESSED_BA [%d] Received from %pM, "
1125 "sta_id = %d\n",
1126 agg->wait_for_ba,
1127 (u8 *) &ba_resp->sta_addr_lo32,
1128 ba_resp->sta_id);
1129 IWL_DEBUG_TX_REPLY(priv, "TID = %d, SeqCtl = %d, bitmap = 0x%llx, scd_flow = "
1130 "%d, scd_ssn = %d\n",
1131 ba_resp->tid,
1132 ba_resp->seq_ctl,
1133 (unsigned long long)le64_to_cpu(ba_resp->bitmap),
1134 ba_resp->scd_flow,
1135 ba_resp->scd_ssn);
Frans Pop91dd6c22010-03-24 14:19:58 -07001136 IWL_DEBUG_TX_REPLY(priv, "DAT start_idx = %d, bitmap = 0x%llx\n",
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -07001137 agg->start_idx,
1138 (unsigned long long)agg->bitmap);
1139
1140 /* Update driver's record of ACK vs. not for each frame in window */
1141 iwlagn_tx_status_reply_compressed_ba(priv, agg, ba_resp);
1142
1143 /* Release all TFDs before the SSN, i.e. all TFDs in front of
1144 * block-ack window (we assume that they've been successfully
1145 * transmitted ... if not, it's too late anyway). */
1146 if (txq->q.read_ptr != (ba_resp_scd_ssn & 0xff)) {
1147 /* calculate mac80211 ampdu sw queue to wake */
1148 int freed = iwlagn_tx_queue_reclaim(priv, scd_flow, index);
1149 iwl_free_tfds_in_queue(priv, sta_id, tid, freed);
1150
1151 if ((iwl_queue_space(&txq->q) > txq->q.low_mark) &&
1152 priv->mac80211_registered &&
1153 (agg->state != IWL_EMPTYING_HW_QUEUE_DELBA))
Johannes Berg549a04e2010-11-10 18:25:44 -08001154 iwl_wake_queue(priv, txq);
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -07001155
1156 iwlagn_txq_check_empty(priv, sta_id, tid, scd_flow);
1157 }
Reinette Chatre9c5ac092010-05-05 02:26:06 -07001158
1159 spin_unlock_irqrestore(&priv->sta_lock, flags);
Wey-Yi Guy74bcdb32010-03-17 13:34:34 -07001160}
Johannes Berg69fdb712010-09-22 18:02:02 +02001161
1162#ifdef CONFIG_IWLWIFI_DEBUG
1163const char *iwl_get_tx_fail_reason(u32 status)
1164{
1165#define TX_STATUS_FAIL(x) case TX_STATUS_FAIL_ ## x: return #x
1166#define TX_STATUS_POSTPONE(x) case TX_STATUS_POSTPONE_ ## x: return #x
1167
1168 switch (status & TX_STATUS_MSK) {
1169 case TX_STATUS_SUCCESS:
1170 return "SUCCESS";
1171 TX_STATUS_POSTPONE(DELAY);
1172 TX_STATUS_POSTPONE(FEW_BYTES);
1173 TX_STATUS_POSTPONE(BT_PRIO);
1174 TX_STATUS_POSTPONE(QUIET_PERIOD);
1175 TX_STATUS_POSTPONE(CALC_TTAK);
1176 TX_STATUS_FAIL(INTERNAL_CROSSED_RETRY);
1177 TX_STATUS_FAIL(SHORT_LIMIT);
1178 TX_STATUS_FAIL(LONG_LIMIT);
1179 TX_STATUS_FAIL(FIFO_UNDERRUN);
1180 TX_STATUS_FAIL(DRAIN_FLOW);
1181 TX_STATUS_FAIL(RFKILL_FLUSH);
1182 TX_STATUS_FAIL(LIFE_EXPIRE);
1183 TX_STATUS_FAIL(DEST_PS);
1184 TX_STATUS_FAIL(HOST_ABORTED);
1185 TX_STATUS_FAIL(BT_RETRY);
1186 TX_STATUS_FAIL(STA_INVALID);
1187 TX_STATUS_FAIL(FRAG_DROPPED);
1188 TX_STATUS_FAIL(TID_DISABLE);
1189 TX_STATUS_FAIL(FIFO_FLUSHED);
1190 TX_STATUS_FAIL(INSUFFICIENT_CF_POLL);
1191 TX_STATUS_FAIL(PASSIVE_NO_RX);
1192 TX_STATUS_FAIL(NO_BEACON_ON_RADAR);
1193 }
1194
1195 return "UNKNOWN";
1196
1197#undef TX_STATUS_FAIL
1198#undef TX_STATUS_POSTPONE
1199}
1200#endif /* CONFIG_IWLWIFI_DEBUG */