iPXE
ath5k_qcu.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2004-2008 Reyk Floeter <reyk@openbsd.org>
3 * Copyright (c) 2006-2008 Nick Kossifidis <mickflemm@gmail.com>
4 *
5 * Lightly modified for iPXE, July 2009, by Joshua Oreman <oremanj@rwcr.net>.
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 *
19 */
20
22FILE_SECBOOT ( FORBIDDEN );
23
24/********************************************\
25Queue Control Unit, DFS Control Unit Functions
26\********************************************/
27
28#include "ath5k.h"
29#include "reg.h"
30#include "base.h"
31
32/*
33 * Set properties for a transmit queue
34 */
36 const struct ath5k_txq_info *queue_info)
37{
38 if (ah->ah_txq.tqi_type == AR5K_TX_QUEUE_INACTIVE)
39 return -EIO;
40
41 memcpy(&ah->ah_txq, queue_info, sizeof(struct ath5k_txq_info));
42
43 /*XXX: Is this supported on 5210 ?*/
44 if ((queue_info->tqi_type == AR5K_TX_QUEUE_DATA &&
45 ((queue_info->tqi_subtype == AR5K_WME_AC_VI) ||
46 (queue_info->tqi_subtype == AR5K_WME_AC_VO))) ||
47 queue_info->tqi_type == AR5K_TX_QUEUE_UAPSD)
48 ah->ah_txq.tqi_flags |= AR5K_TXQ_FLAG_POST_FR_BKOFF_DIS;
49
50 return 0;
51}
52
53/*
54 * Initialize a transmit queue
55 */
57 struct ath5k_txq_info *queue_info)
58{
59 int ret;
60
61 /*
62 * Setup internal queue structure
63 */
64 memset(&ah->ah_txq, 0, sizeof(struct ath5k_txq_info));
65 ah->ah_txq.tqi_type = queue_type;
66
67 if (queue_info != NULL) {
68 queue_info->tqi_type = queue_type;
69 ret = ath5k_hw_set_tx_queueprops(ah, queue_info);
70 if (ret)
71 return ret;
72 }
73
74 /*
75 * We use ah_txq_status to hold a temp value for
76 * the Secondary interrupt mask registers on 5211+
77 * check out ath5k_hw_reset_tx_queue
78 */
79 AR5K_Q_ENABLE_BITS(ah->ah_txq_status, 0);
80
81 return 0;
82}
83
84/*
85 * Set a transmit queue inactive
86 */
88{
89 /* This queue will be skipped in further operations */
90 ah->ah_txq.tqi_type = AR5K_TX_QUEUE_INACTIVE;
91 /*For SIMR setup*/
92 AR5K_Q_DISABLE_BITS(ah->ah_txq_status, 0);
93}
94
95/*
96 * Set DFS properties for a transmit queue on DCU
97 */
99{
100 u32 cw_min, cw_max, retry_lg, retry_sh;
101 struct ath5k_txq_info *tq = &ah->ah_txq;
102 const int queue = 0;
103
104 tq = &ah->ah_txq;
105
107 return 0;
108
109 if (ah->ah_version == AR5K_AR5210) {
110 /* Only handle data queues, others will be ignored */
111 if (tq->tqi_type != AR5K_TX_QUEUE_DATA)
112 return 0;
113
114 /* Set Slot time */
115 ath5k_hw_reg_write(ah, ah->ah_turbo ?
118 /* Set ACK_CTS timeout */
119 ath5k_hw_reg_write(ah, ah->ah_turbo ?
122 /* Set Transmit Latency */
123 ath5k_hw_reg_write(ah, ah->ah_turbo ?
126
127 /* Set IFS0 */
128 if (ah->ah_turbo) {
130 (ah->ah_aifs + tq->tqi_aifs) *
133 AR5K_IFS0);
134 } else {
136 (ah->ah_aifs + tq->tqi_aifs) *
139 }
140
141 /* Set IFS1 */
142 ath5k_hw_reg_write(ah, ah->ah_turbo ?
145 /* Set AR5K_PHY_SETTLING */
146 ath5k_hw_reg_write(ah, ah->ah_turbo ?
148 | 0x38 :
150 | 0x1C,
152 /* Set Frame Control Register */
153 ath5k_hw_reg_write(ah, ah->ah_turbo ?
155 AR5K_PHY_TURBO_SHORT | 0x2020) :
156 (AR5K_PHY_FRAME_CTL_INI | 0x1020),
158 }
159
160 /*
161 * Calculate cwmin/max by channel mode
162 */
163 cw_min = ah->ah_cw_min = AR5K_TUNE_CWMIN;
164 cw_max = ah->ah_cw_max = AR5K_TUNE_CWMAX;
165 ah->ah_aifs = AR5K_TUNE_AIFS;
166 /*XR is only supported on 5212*/
167 if (IS_CHAN_XR(ah->ah_current_channel) &&
168 ah->ah_version == AR5K_AR5212) {
169 cw_min = ah->ah_cw_min = AR5K_TUNE_CWMIN_XR;
170 cw_max = ah->ah_cw_max = AR5K_TUNE_CWMAX_XR;
171 ah->ah_aifs = AR5K_TUNE_AIFS_XR;
172 /*B mode is not supported on 5210*/
173 } else if (IS_CHAN_B(ah->ah_current_channel) &&
174 ah->ah_version != AR5K_AR5210) {
175 cw_min = ah->ah_cw_min = AR5K_TUNE_CWMIN_11B;
176 cw_max = ah->ah_cw_max = AR5K_TUNE_CWMAX_11B;
177 ah->ah_aifs = AR5K_TUNE_AIFS_11B;
178 }
179
180 cw_min = 1;
181 while (cw_min < ah->ah_cw_min)
182 cw_min = (cw_min << 1) | 1;
183
184 cw_min = tq->tqi_cw_min < 0 ? (cw_min >> (-tq->tqi_cw_min)) :
185 ((cw_min << tq->tqi_cw_min) + (1 << tq->tqi_cw_min) - 1);
186 cw_max = tq->tqi_cw_max < 0 ? (cw_max >> (-tq->tqi_cw_max)) :
187 ((cw_max << tq->tqi_cw_max) + (1 << tq->tqi_cw_max) - 1);
188
189 /*
190 * Calculate and set retry limits
191 */
192 if (ah->ah_software_retry) {
193 /* XXX Need to test this */
194 retry_lg = ah->ah_limit_tx_retries;
195 retry_sh = retry_lg = retry_lg > AR5K_DCU_RETRY_LMT_SH_RETRY ?
197 } else {
198 retry_lg = AR5K_INIT_LG_RETRY;
199 retry_sh = AR5K_INIT_SH_RETRY;
200 }
201
202 /*No QCU/DCU [5210]*/
203 if (ah->ah_version == AR5K_AR5210) {
213 } else {
214 /*QCU/DCU [5211+]*/
223
224 /*===Rest is also for QCU/DCU only [5211+]===*/
225
226 /*
227 * Set initial content window (cw_min/cw_max)
228 * and arbitrated interframe space (aifs)...
229 */
233 AR5K_REG_SM(ah->ah_aifs + tq->tqi_aifs,
236
237 /*
238 * Set misc registers
239 */
240 /* Enable DCU early termination for this queue */
243
244 /* Enable DCU to wait for next fragment from QCU */
247
248 /* On Maui and Spirit use the global seqnum on DCU */
249 if (ah->ah_mac_version < AR5K_SREV_AR5211)
252
253 if (tq->tqi_cbr_period) {
265 }
266
267 if (tq->tqi_ready_time &&
273
274 if (tq->tqi_burst_time) {
279
280 if (tq->tqi_flags
285 }
286
290
294
295 /* TODO: Handle frame compression */
296
297 /*
298 * Enable interrupts for this tx queue
299 * in the secondary interrupt mask registers
300 */
302 AR5K_Q_ENABLE_BITS(ah->ah_txq_imr_txok, queue);
303
305 AR5K_Q_ENABLE_BITS(ah->ah_txq_imr_txerr, queue);
306
308 AR5K_Q_ENABLE_BITS(ah->ah_txq_imr_txurn, queue);
309
311 AR5K_Q_ENABLE_BITS(ah->ah_txq_imr_txdesc, queue);
312
314 AR5K_Q_ENABLE_BITS(ah->ah_txq_imr_txeol, queue);
315
317 AR5K_Q_ENABLE_BITS(ah->ah_txq_imr_cbrorn, queue);
318
320 AR5K_Q_ENABLE_BITS(ah->ah_txq_imr_cbrurn, queue);
321
323 AR5K_Q_ENABLE_BITS(ah->ah_txq_imr_qtrig, queue);
324
326 AR5K_Q_ENABLE_BITS(ah->ah_txq_imr_nofrm, queue);
327
328 /* Update secondary interrupt mask registers */
329
330 /* Filter out inactive queues */
331 ah->ah_txq_imr_txok &= ah->ah_txq_status;
332 ah->ah_txq_imr_txerr &= ah->ah_txq_status;
333 ah->ah_txq_imr_txurn &= ah->ah_txq_status;
334 ah->ah_txq_imr_txdesc &= ah->ah_txq_status;
335 ah->ah_txq_imr_txeol &= ah->ah_txq_status;
336 ah->ah_txq_imr_cbrorn &= ah->ah_txq_status;
337 ah->ah_txq_imr_cbrurn &= ah->ah_txq_status;
338 ah->ah_txq_imr_qtrig &= ah->ah_txq_status;
339 ah->ah_txq_imr_nofrm &= ah->ah_txq_status;
340
341 ath5k_hw_reg_write(ah, AR5K_REG_SM(ah->ah_txq_imr_txok,
343 AR5K_REG_SM(ah->ah_txq_imr_txdesc,
345 ath5k_hw_reg_write(ah, AR5K_REG_SM(ah->ah_txq_imr_txerr,
347 AR5K_REG_SM(ah->ah_txq_imr_txeol,
349 /* Update simr2 but don't overwrite rest simr2 settings */
352 AR5K_REG_SM(ah->ah_txq_imr_txurn,
354 ath5k_hw_reg_write(ah, AR5K_REG_SM(ah->ah_txq_imr_cbrorn,
356 AR5K_REG_SM(ah->ah_txq_imr_cbrurn,
358 ath5k_hw_reg_write(ah, AR5K_REG_SM(ah->ah_txq_imr_qtrig,
360 /* Set TXNOFRM_QCU for the queues with TXNOFRM enabled */
361 ath5k_hw_reg_write(ah, AR5K_REG_SM(ah->ah_txq_imr_nofrm,
363 /* No queue has TXNOFRM enabled, disable the interrupt
364 * by setting AR5K_TXNOFRM to zero */
365 if (ah->ah_txq_imr_nofrm == 0)
367
368 /* Set QCU mask for this DCU to save power */
370 }
371
372 return 0;
373}
374
375/*
376 * Set slot time on DCU
377 */
378int ath5k_hw_set_slot_time(struct ath5k_hw *ah, unsigned int slot_time)
379{
380 if (slot_time < AR5K_SLOT_TIME_9 || slot_time > AR5K_SLOT_TIME_MAX)
381 return -EINVAL;
382
383 if (ah->ah_version == AR5K_AR5210)
385 ah->ah_turbo), AR5K_SLOT_TIME);
386 else
388
389 return 0;
390}
391
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
#define AR5K_DCU_MISC_SEQNUM_CTL
Definition reg.h:746
#define AR5K_PHY_SETTLING
Definition reg.h:1970
#define AR5K_SIMR3_QCBRURN
Definition reg.h:447
#define AR5K_DCU_MISC_FRAG_WAIT
Definition reg.h:727
#define AR5K_PHY_FRAME_CTL_INI
Definition reg.h:2283
#define AR5K_SIMR1
Definition reg.h:424
#define AR5K_SIMR1_QCU_TXERR
Definition reg.h:425
#define AR5K_QCU_MISC_RDY_VEOL_POLICY
Definition reg.h:616
#define AR5K_PHY_TURBO_SHORT
Definition reg.h:1893
#define AR5K_NODCU_RETRY_LMT_SH_RETRY
Definition reg.h:1201
#define AR5K_QUEUE_DFS_CHANNEL_TIME(_q)
Definition reg.h:709
#define AR5K_SIMR0_QCU_TXOK
Definition reg.h:419
#define AR5K_TXNOFRM_QCU
Definition reg.h:239
#define AR5K_QUEUE_CBRCFG(_q)
Definition reg.h:578
#define AR5K_SIMR1_QCU_TXEOL
Definition reg.h:427
#define AR5K_SIMR0_QCU_TXDESC
Definition reg.h:421
#define AR5K_QCU_CBRCFG_ORN_THRES
Definition reg.h:576
#define AR5K_SIMR2_QCU_TXURN
Definition reg.h:431
#define AR5K_NODCU_RETRY_LMT_CW_MIN_S
Definition reg.h:1210
#define AR5K_QUEUE_MISC(_q)
Definition reg.h:620
#define AR5K_DCU_GBL_IFS_SLOT
Definition reg.h:765
#define AR5K_PHY_FRAME_CTL_5210
Definition reg.h:2266
#define AR5K_IFS0
Definition reg.h:1290
#define AR5K_IFS1
Definition reg.h:1299
#define AR5K_SLOT_TIME
Definition reg.h:1163
#define AR5K_QUEUE_DFS_MISC(_q)
Definition reg.h:747
#define AR5K_QUEUE_DFS_LOCAL_IFS(_q)
Definition reg.h:686
#define AR5K_NODCU_RETRY_LMT
Definition reg.h:1200
#define AR5K_TXNOFRM
Definition reg.h:237
#define AR5K_SIMR4
Definition reg.h:450
#define AR5K_QCU_RDYTIMECFG_ENABLE
Definition reg.h:586
#define AR5K_DCU_MISC_POST_FR_BKOFF_DIS
Definition reg.h:743
#define AR5K_NODCU_RETRY_LMT_SLG_RETRY
Definition reg.h:1207
#define AR5K_QCU_MISC_FRSHED_CBR
Definition reg.h:607
#define AR5K_SIMR3_QCBRORN
Definition reg.h:445
#define AR5K_QUEUE_DFS_RETRY_LIMIT(_q)
Definition reg.h:700
#define AR5K_NODCU_RETRY_LMT_SSH_RETRY
Definition reg.h:1205
#define AR5K_QCU_RDYTIMECFG_INTVAL
Definition reg.h:584
#define AR5K_DCU_RETRY_LMT_SLG_RETRY
Definition reg.h:698
#define AR5K_DCU_MISC_BACKOFF_FRAG
Definition reg.h:728
#define AR5K_DCU_LCL_IFS_AIFS
Definition reg.h:683
#define AR5K_SIMR0
Definition reg.h:418
#define AR5K_NODCU_RETRY_LMT_LG_RETRY
Definition reg.h:1203
#define AR5K_DCU_LCL_IFS_CW_MAX
Definition reg.h:681
#define AR5K_QCU_MISC_DCU_EARLY
Definition reg.h:618
#define AR5K_QUEUE_QCUMASK(_q)
Definition reg.h:673
#define AR5K_IFS0_DIFS_S
Definition reg.h:1294
#define AR5K_DCU_CHAN_TIME_DUR
Definition reg.h:706
#define AR5K_SIMR4_QTRIG
Definition reg.h:451
#define AR5K_DCU_RETRY_LMT_LG_RETRY
Definition reg.h:694
#define AR5K_SIMR2
Definition reg.h:430
#define AR5K_DCU_LCL_IFS_CW_MIN
Definition reg.h:679
#define AR5K_DCU_RETRY_LMT_SH_RETRY
Definition reg.h:692
#define AR5K_DCU_CHAN_TIME_ENABLE
Definition reg.h:708
#define AR5K_QUEUE_RDYTIMECFG(_q)
Definition reg.h:587
#define AR5K_DCU_RETRY_LMT_SSH_RETRY
Definition reg.h:696
#define AR5K_QCU_CBRCFG_INTVAL
Definition reg.h:574
#define AR5K_PHY_TURBO_MODE
Definition reg.h:1892
#define AR5K_USEC_5210
Definition reg.h:1215
#define AR5K_SIMR3
Definition reg.h:444
#define AR5K_QCU_MISC_CBR_THRES_ENABLE
Definition reg.h:615
#define AR5K_TXQ_FLAG_TXURNINT_ENABLE
Definition ath5k.h:494
#define AR5K_Q_ENABLE_BITS(_reg, _queue)
Definition ath5k.h:126
#define AR5K_INIT_SLOT_TIME_TURBO
Definition ath5k.h:217
#define AR5K_TXQ_FLAG_TXDESCINT_ENABLE
Definition ath5k.h:493
#define AR5K_TXQ_FLAG_QTRIGINT_ENABLE
Definition ath5k.h:497
#define AR5K_TXQ_FLAG_RDYTIME_EXP_POLICY_ENABLE
Definition ath5k.h:500
#define AR5K_TUNE_CWMAX
Definition ath5k.h:189
#define AR5K_TXQ_FLAG_CBRORNINT_ENABLE
Definition ath5k.h:495
#define AR5K_INIT_SSH_RETRY
Definition ath5k.h:228
#define AR5K_INIT_LG_RETRY
Definition ath5k.h:227
#define AR5K_TXQ_FLAG_TXNOFRMINT_ENABLE
Definition ath5k.h:498
@ AR5K_WME_AC_VO
Definition ath5k.h:466
@ AR5K_WME_AC_VI
Definition ath5k.h:465
#define AR5K_REG_SM(_val, _flags)
Definition ath5k.h:86
#define AR5K_REG_WRITE_Q(ah, _reg, _queue)
Definition ath5k.h:123
#define AR5K_Q_DISABLE_BITS(_reg, _queue)
Definition ath5k.h:130
#define AR5K_INIT_ACK_CTS_TIMEOUT
Definition ath5k.h:218
#define AR5K_TXQ_FLAG_TXEOLINT_ENABLE
Definition ath5k.h:492
#define AR5K_TXQ_FLAG_TXOKINT_ENABLE
Definition ath5k.h:490
#define AR5K_TUNE_AIFS_11B
Definition ath5k.h:184
#define AR5K_REG_ENABLE_BITS(ah, _reg, _flags)
Definition ath5k.h:106
#define AR5K_INIT_SIFS_TURBO
Definition ath5k.h:225
#define AR5K_INIT_TRANSMIT_LATENCY
Definition ath5k.h:232
#define AR5K_TUNE_CWMIN_11B
Definition ath5k.h:187
#define AR5K_TUNE_AIFS
Definition ath5k.h:183
#define AR5K_TUNE_CWMAX_11B
Definition ath5k.h:190
#define AR5K_TUNE_AIFS_XR
Definition ath5k.h:185
#define AR5K_TUNE_CWMAX_XR
Definition ath5k.h:191
#define AR5K_INIT_SIFS
Definition ath5k.h:224
#define AR5K_INIT_SLOT_TIME
Definition ath5k.h:216
static u32 ath5k_hw_reg_read(struct ath5k_hw *ah, u16 reg)
Definition ath5k.h:1216
#define AR5K_TXQ_FLAG_POST_FR_BKOFF_DIS
Definition ath5k.h:502
#define AR5K_INIT_PROTO_TIME_CNTRL_TURBO
Definition ath5k.h:244
#define AR5K_INIT_SLG_RETRY
Definition ath5k.h:229
#define AR5K_TXQ_FLAG_TXERRINT_ENABLE
Definition ath5k.h:491
#define AR5K_TXQ_FLAG_CBRURNINT_ENABLE
Definition ath5k.h:496
#define AR5K_TUNE_CWMIN_XR
Definition ath5k.h:188
#define AR5K_SLOT_TIME_MAX
Definition ath5k.h:627
#define AR5K_SREV_AR5211
Definition ath5k.h:294
ath5k_tx_queue
enum ath5k_tx_queue - Queue types used to classify tx queues.
Definition ath5k.h:446
@ AR5K_TX_QUEUE_CAB
Definition ath5k.h:451
@ AR5K_TX_QUEUE_INACTIVE
Definition ath5k.h:447
@ AR5K_TX_QUEUE_DATA
Definition ath5k.h:448
@ AR5K_TX_QUEUE_UAPSD
Definition ath5k.h:452
#define IS_CHAN_B(_c)
Definition ath5k.h:660
@ AR5K_AR5210
Definition ath5k.h:256
@ AR5K_AR5212
Definition ath5k.h:258
#define AR5K_INIT_SH_RETRY
Definition ath5k.h:226
#define AR5K_INIT_ACK_CTS_TIMEOUT_TURBO
Definition ath5k.h:219
static void ath5k_hw_reg_write(struct ath5k_hw *ah, u32 val, u16 reg)
Definition ath5k.h:1224
#define AR5K_REG_DISABLE_BITS(ah, _reg, _flags)
Definition ath5k.h:109
#define AR5K_INIT_PROTO_TIME_CNTRL
Definition ath5k.h:240
#define AR5K_TXQ_FLAG_BACKOFF_DISABLE
Definition ath5k.h:499
#define AR5K_TXQ_FLAG_FRAG_BURST_BACKOFF_ENABLE
Definition ath5k.h:501
#define IS_CHAN_XR(_c)
Definition ath5k.h:659
#define AR5K_INIT_TRANSMIT_LATENCY_TURBO
Definition ath5k.h:236
#define AR5K_TUNE_CWMIN
Definition ath5k.h:186
static unsigned int ath5k_hw_htoclock(unsigned int usec, int turbo)
Definition ath5k.h:1199
int ath5k_hw_reset_tx_queue(struct ath5k_hw *ah)
Definition ath5k_qcu.c:98
int ath5k_hw_set_slot_time(struct ath5k_hw *ah, unsigned int slot_time)
Definition ath5k_qcu.c:378
int ath5k_hw_set_tx_queueprops(struct ath5k_hw *ah, const struct ath5k_txq_info *queue_info)
Definition ath5k_qcu.c:35
void ath5k_hw_release_tx_queue(struct ath5k_hw *ah)
Definition ath5k_qcu.c:87
int ath5k_hw_setup_tx_queue(struct ath5k_hw *ah, enum ath5k_tx_queue queue_type, struct ath5k_txq_info *queue_info)
Definition ath5k_qcu.c:56
uint16_t queue
Queue ID.
Definition ena.h:11
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define EINVAL
Invalid argument.
Definition errno.h:429
#define EIO
Input/output error.
Definition errno.h:434
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
void * memcpy(void *dest, const void *src, size_t len) __nonnull
void * memset(void *dest, int character, size_t len) __nonnull
uint8_t ah
Definition registers.h:1
ath5k_hw_get_isr - Get interrupt status
Definition ath5k.h:955
u32 tqi_cbr_overflow_limit
Definition ath5k.h:516
u16 tqi_flags
Definition ath5k.h:511
u32 tqi_cbr_period
Definition ath5k.h:515
u32 tqi_ready_time
Definition ath5k.h:518
enum ath5k_tx_queue tqi_type
Definition ath5k.h:509
enum ath5k_tx_queue_subtype tqi_subtype
Definition ath5k.h:510
s32 tqi_cw_max
Definition ath5k.h:514
s32 tqi_cw_min
Definition ath5k.h:513
u32 tqi_burst_time
Definition ath5k.h:517
#define u32
Definition vga.h:21