2 * Copyright (c) 2004-2008 Reyk Floeter <reyk@openbsd.org>
3 * Copyright (c) 2006-2008 Nick Kossifidis <mickflemm@gmail.com>
4 * Copyright (c) 2007-2008 Pavel Roskin <proski@gnu.org>
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 /******************************\
21 Hardware Descriptor Functions
22 \******************************/
30 /************************\
31 * TX Control descriptors *
32 \************************/
35 * Initialize the 2-word tx control descriptor on 5210/5211
38 ath5k_hw_setup_2word_tx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc,
39 unsigned int pkt_len, unsigned int hdr_len, int padsize,
40 enum ath5k_pkt_type type,
41 unsigned int tx_power, unsigned int tx_rate0, unsigned int tx_tries0,
42 unsigned int key_index, unsigned int antenna_mode, unsigned int flags,
43 unsigned int rtscts_rate, unsigned int rtscts_duration)
46 struct ath5k_hw_2w_tx_ctl *tx_ctl;
47 unsigned int frame_len;
49 tx_ctl = &desc->ud.ds_tx5210.tx_ctl;
53 * - Zero retries don't make sense.
54 * - A zero rate will put the HW into a mode where it continuously sends
55 * noise on the channel, so it is important to avoid this.
57 if (unlikely(tx_tries0 == 0)) {
58 ATH5K_ERR(ah->ah_sc, "zero retries\n");
62 if (unlikely(tx_rate0 == 0)) {
63 ATH5K_ERR(ah->ah_sc, "zero rate\n");
68 /* Clear descriptor */
69 memset(&desc->ud.ds_tx5210, 0, sizeof(struct ath5k_hw_5210_tx_desc));
71 /* Setup control descriptor */
73 /* Verify and set frame length */
75 /* remove padding we might have added before */
76 frame_len = pkt_len - padsize + FCS_LEN;
78 if (frame_len & ~AR5K_2W_TX_DESC_CTL0_FRAME_LEN)
81 tx_ctl->tx_control_0 = frame_len & AR5K_2W_TX_DESC_CTL0_FRAME_LEN;
83 /* Verify and set buffer length */
85 /* NB: beacon's BufLen must be a multiple of 4 bytes */
86 if (type == AR5K_PKT_TYPE_BEACON)
87 pkt_len = roundup(pkt_len, 4);
89 if (pkt_len & ~AR5K_2W_TX_DESC_CTL1_BUF_LEN)
92 tx_ctl->tx_control_1 = pkt_len & AR5K_2W_TX_DESC_CTL1_BUF_LEN;
95 * Verify and set header length (only 5210)
97 if (ah->ah_version == AR5K_AR5210) {
98 if (hdr_len & ~AR5K_2W_TX_DESC_CTL0_HEADER_LEN_5210)
100 tx_ctl->tx_control_0 |=
101 AR5K_REG_SM(hdr_len, AR5K_2W_TX_DESC_CTL0_HEADER_LEN_5210);
104 /*Differences between 5210-5211*/
105 if (ah->ah_version == AR5K_AR5210) {
107 case AR5K_PKT_TYPE_BEACON:
108 case AR5K_PKT_TYPE_PROBE_RESP:
109 frame_type = AR5K_AR5210_TX_DESC_FRAME_TYPE_NO_DELAY;
110 case AR5K_PKT_TYPE_PIFS:
111 frame_type = AR5K_AR5210_TX_DESC_FRAME_TYPE_PIFS;
116 tx_ctl->tx_control_0 |=
117 AR5K_REG_SM(frame_type, AR5K_2W_TX_DESC_CTL0_FRAME_TYPE_5210) |
118 AR5K_REG_SM(tx_rate0, AR5K_2W_TX_DESC_CTL0_XMIT_RATE);
121 tx_ctl->tx_control_0 |=
122 AR5K_REG_SM(tx_rate0, AR5K_2W_TX_DESC_CTL0_XMIT_RATE) |
123 AR5K_REG_SM(antenna_mode,
124 AR5K_2W_TX_DESC_CTL0_ANT_MODE_XMIT);
125 tx_ctl->tx_control_1 |=
126 AR5K_REG_SM(type, AR5K_2W_TX_DESC_CTL1_FRAME_TYPE_5211);
129 #define _TX_FLAGS(_c, _flag) \
130 if (flags & AR5K_TXDESC_##_flag) { \
131 tx_ctl->tx_control_##_c |= \
132 AR5K_2W_TX_DESC_CTL##_c##_##_flag; \
134 #define _TX_FLAGS_5211(_c, _flag) \
135 if (flags & AR5K_TXDESC_##_flag) { \
136 tx_ctl->tx_control_##_c |= \
137 AR5K_2W_TX_DESC_CTL##_c##_##_flag##_5211; \
139 _TX_FLAGS(0, CLRDMASK);
140 _TX_FLAGS(0, INTREQ);
141 _TX_FLAGS(0, RTSENA);
143 if (ah->ah_version == AR5K_AR5211) {
144 _TX_FLAGS_5211(0, VEOL);
145 _TX_FLAGS_5211(1, NOACK);
149 #undef _TX_FLAGS_5211
154 if (key_index != AR5K_TXKEYIX_INVALID) {
155 tx_ctl->tx_control_0 |=
156 AR5K_2W_TX_DESC_CTL0_ENCRYPT_KEY_VALID;
157 tx_ctl->tx_control_1 |=
158 AR5K_REG_SM(key_index,
159 AR5K_2W_TX_DESC_CTL1_ENC_KEY_IDX);
163 * RTS/CTS Duration [5210 ?]
165 if ((ah->ah_version == AR5K_AR5210) &&
166 (flags & (AR5K_TXDESC_RTSENA | AR5K_TXDESC_CTSENA)))
167 tx_ctl->tx_control_1 |= rtscts_duration &
168 AR5K_2W_TX_DESC_CTL1_RTS_DURATION_5210;
174 * Initialize the 4-word tx control descriptor on 5212
176 static int ath5k_hw_setup_4word_tx_desc(struct ath5k_hw *ah,
177 struct ath5k_desc *desc, unsigned int pkt_len, unsigned int hdr_len,
179 enum ath5k_pkt_type type, unsigned int tx_power, unsigned int tx_rate0,
180 unsigned int tx_tries0, unsigned int key_index,
181 unsigned int antenna_mode, unsigned int flags,
182 unsigned int rtscts_rate,
183 unsigned int rtscts_duration)
185 struct ath5k_hw_4w_tx_ctl *tx_ctl;
186 unsigned int frame_len;
189 * Use local variables for these to reduce load/store access on
192 u32 txctl0 = 0, txctl1 = 0, txctl2 = 0, txctl3 = 0;
194 tx_ctl = &desc->ud.ds_tx5212.tx_ctl;
198 * - Zero retries don't make sense.
199 * - A zero rate will put the HW into a mode where it continuously sends
200 * noise on the channel, so it is important to avoid this.
202 if (unlikely(tx_tries0 == 0)) {
203 ATH5K_ERR(ah->ah_sc, "zero retries\n");
207 if (unlikely(tx_rate0 == 0)) {
208 ATH5K_ERR(ah->ah_sc, "zero rate\n");
213 tx_power += ah->ah_txpower.txp_offset;
214 if (tx_power > AR5K_TUNE_MAX_TXPOWER)
215 tx_power = AR5K_TUNE_MAX_TXPOWER;
217 /* Clear descriptor status area */
218 memset(&desc->ud.ds_tx5212.tx_stat, 0,
219 sizeof(desc->ud.ds_tx5212.tx_stat));
221 /* Setup control descriptor */
223 /* Verify and set frame length */
225 /* remove padding we might have added before */
226 frame_len = pkt_len - padsize + FCS_LEN;
228 if (frame_len & ~AR5K_4W_TX_DESC_CTL0_FRAME_LEN)
231 txctl0 = frame_len & AR5K_4W_TX_DESC_CTL0_FRAME_LEN;
233 /* Verify and set buffer length */
235 /* NB: beacon's BufLen must be a multiple of 4 bytes */
236 if (type == AR5K_PKT_TYPE_BEACON)
237 pkt_len = roundup(pkt_len, 4);
239 if (pkt_len & ~AR5K_4W_TX_DESC_CTL1_BUF_LEN)
242 txctl1 = pkt_len & AR5K_4W_TX_DESC_CTL1_BUF_LEN;
244 txctl0 |= AR5K_REG_SM(tx_power, AR5K_4W_TX_DESC_CTL0_XMIT_POWER) |
245 AR5K_REG_SM(antenna_mode, AR5K_4W_TX_DESC_CTL0_ANT_MODE_XMIT);
246 txctl1 |= AR5K_REG_SM(type, AR5K_4W_TX_DESC_CTL1_FRAME_TYPE);
247 txctl2 = AR5K_REG_SM(tx_tries0, AR5K_4W_TX_DESC_CTL2_XMIT_TRIES0);
248 txctl3 = tx_rate0 & AR5K_4W_TX_DESC_CTL3_XMIT_RATE0;
250 #define _TX_FLAGS(_c, _flag) \
251 if (flags & AR5K_TXDESC_##_flag) { \
252 txctl##_c |= AR5K_4W_TX_DESC_CTL##_c##_##_flag; \
255 _TX_FLAGS(0, CLRDMASK);
257 _TX_FLAGS(0, INTREQ);
258 _TX_FLAGS(0, RTSENA);
259 _TX_FLAGS(0, CTSENA);
267 if (key_index != AR5K_TXKEYIX_INVALID) {
268 txctl0 |= AR5K_4W_TX_DESC_CTL0_ENCRYPT_KEY_VALID;
269 txctl1 |= AR5K_REG_SM(key_index,
270 AR5K_4W_TX_DESC_CTL1_ENCRYPT_KEY_IDX);
276 if (flags & (AR5K_TXDESC_RTSENA | AR5K_TXDESC_CTSENA)) {
277 if ((flags & AR5K_TXDESC_RTSENA) &&
278 (flags & AR5K_TXDESC_CTSENA))
280 txctl2 |= rtscts_duration & AR5K_4W_TX_DESC_CTL2_RTS_DURATION;
281 txctl3 |= AR5K_REG_SM(rtscts_rate,
282 AR5K_4W_TX_DESC_CTL3_RTS_CTS_RATE);
285 tx_ctl->tx_control_0 = txctl0;
286 tx_ctl->tx_control_1 = txctl1;
287 tx_ctl->tx_control_2 = txctl2;
288 tx_ctl->tx_control_3 = txctl3;
294 * Initialize a 4-word multi rate retry tx control descriptor on 5212
297 ath5k_hw_setup_mrr_tx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc,
298 unsigned int tx_rate1, u_int tx_tries1, u_int tx_rate2,
299 u_int tx_tries2, unsigned int tx_rate3, u_int tx_tries3)
301 struct ath5k_hw_4w_tx_ctl *tx_ctl;
303 /* no mrr support for cards older than 5212 */
304 if (ah->ah_version < AR5K_AR5212)
308 * Rates can be 0 as long as the retry count is 0 too.
309 * A zero rate and nonzero retry count will put the HW into a mode where
310 * it continuously sends noise on the channel, so it is important to
313 if (unlikely((tx_rate1 == 0 && tx_tries1 != 0) ||
314 (tx_rate2 == 0 && tx_tries2 != 0) ||
315 (tx_rate3 == 0 && tx_tries3 != 0))) {
316 ATH5K_ERR(ah->ah_sc, "zero rate\n");
321 if (ah->ah_version == AR5K_AR5212) {
322 tx_ctl = &desc->ud.ds_tx5212.tx_ctl;
324 #define _XTX_TRIES(_n) \
325 if (tx_tries##_n) { \
326 tx_ctl->tx_control_2 |= \
327 AR5K_REG_SM(tx_tries##_n, \
328 AR5K_4W_TX_DESC_CTL2_XMIT_TRIES##_n); \
329 tx_ctl->tx_control_3 |= \
330 AR5K_REG_SM(tx_rate##_n, \
331 AR5K_4W_TX_DESC_CTL3_XMIT_RATE##_n); \
347 /***********************\
348 * TX Status descriptors *
349 \***********************/
352 * Process the tx status descriptor on 5210/5211
354 static int ath5k_hw_proc_2word_tx_status(struct ath5k_hw *ah,
355 struct ath5k_desc *desc, struct ath5k_tx_status *ts)
357 struct ath5k_hw_2w_tx_ctl *tx_ctl;
358 struct ath5k_hw_tx_status *tx_status;
360 tx_ctl = &desc->ud.ds_tx5210.tx_ctl;
361 tx_status = &desc->ud.ds_tx5210.tx_stat;
363 /* No frame has been send or error */
364 if (unlikely((tx_status->tx_status_1 & AR5K_DESC_TX_STATUS1_DONE) == 0))
368 * Get descriptor status
370 ts->ts_tstamp = AR5K_REG_MS(tx_status->tx_status_0,
371 AR5K_DESC_TX_STATUS0_SEND_TIMESTAMP);
372 ts->ts_shortretry = AR5K_REG_MS(tx_status->tx_status_0,
373 AR5K_DESC_TX_STATUS0_SHORT_RETRY_COUNT);
374 ts->ts_final_retry = AR5K_REG_MS(tx_status->tx_status_0,
375 AR5K_DESC_TX_STATUS0_LONG_RETRY_COUNT);
376 /*TODO: ts->ts_virtcol + test*/
377 ts->ts_seqnum = AR5K_REG_MS(tx_status->tx_status_1,
378 AR5K_DESC_TX_STATUS1_SEQ_NUM);
379 ts->ts_rssi = AR5K_REG_MS(tx_status->tx_status_1,
380 AR5K_DESC_TX_STATUS1_ACK_SIG_STRENGTH);
383 ts->ts_final_idx = 0;
385 if (!(tx_status->tx_status_0 & AR5K_DESC_TX_STATUS0_FRAME_XMIT_OK)) {
386 if (tx_status->tx_status_0 &
387 AR5K_DESC_TX_STATUS0_EXCESSIVE_RETRIES)
388 ts->ts_status |= AR5K_TXERR_XRETRY;
390 if (tx_status->tx_status_0 & AR5K_DESC_TX_STATUS0_FIFO_UNDERRUN)
391 ts->ts_status |= AR5K_TXERR_FIFO;
393 if (tx_status->tx_status_0 & AR5K_DESC_TX_STATUS0_FILTERED)
394 ts->ts_status |= AR5K_TXERR_FILT;
401 * Process a tx status descriptor on 5212
403 static int ath5k_hw_proc_4word_tx_status(struct ath5k_hw *ah,
404 struct ath5k_desc *desc, struct ath5k_tx_status *ts)
406 struct ath5k_hw_4w_tx_ctl *tx_ctl;
407 struct ath5k_hw_tx_status *tx_status;
408 u32 txstat0, txstat1;
410 tx_ctl = &desc->ud.ds_tx5212.tx_ctl;
411 tx_status = &desc->ud.ds_tx5212.tx_stat;
413 txstat1 = ACCESS_ONCE(tx_status->tx_status_1);
415 /* No frame has been send or error */
416 if (unlikely(!(txstat1 & AR5K_DESC_TX_STATUS1_DONE)))
419 txstat0 = ACCESS_ONCE(tx_status->tx_status_0);
422 * Get descriptor status
424 ts->ts_tstamp = AR5K_REG_MS(txstat0,
425 AR5K_DESC_TX_STATUS0_SEND_TIMESTAMP);
426 ts->ts_shortretry = AR5K_REG_MS(txstat0,
427 AR5K_DESC_TX_STATUS0_SHORT_RETRY_COUNT);
428 ts->ts_final_retry = AR5K_REG_MS(txstat0,
429 AR5K_DESC_TX_STATUS0_LONG_RETRY_COUNT);
430 ts->ts_seqnum = AR5K_REG_MS(txstat1,
431 AR5K_DESC_TX_STATUS1_SEQ_NUM);
432 ts->ts_rssi = AR5K_REG_MS(txstat1,
433 AR5K_DESC_TX_STATUS1_ACK_SIG_STRENGTH);
434 ts->ts_antenna = (txstat1 &
435 AR5K_DESC_TX_STATUS1_XMIT_ANTENNA_5212) ? 2 : 1;
438 ts->ts_final_idx = AR5K_REG_MS(txstat1,
439 AR5K_DESC_TX_STATUS1_FINAL_TS_IX_5212);
442 if (!(txstat0 & AR5K_DESC_TX_STATUS0_FRAME_XMIT_OK)) {
443 if (txstat0 & AR5K_DESC_TX_STATUS0_EXCESSIVE_RETRIES)
444 ts->ts_status |= AR5K_TXERR_XRETRY;
446 if (txstat0 & AR5K_DESC_TX_STATUS0_FIFO_UNDERRUN)
447 ts->ts_status |= AR5K_TXERR_FIFO;
449 if (txstat0 & AR5K_DESC_TX_STATUS0_FILTERED)
450 ts->ts_status |= AR5K_TXERR_FILT;
462 * Initialize an rx control descriptor
464 int ath5k_hw_setup_rx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc,
465 u32 size, unsigned int flags)
467 struct ath5k_hw_rx_ctl *rx_ctl;
469 rx_ctl = &desc->ud.ds_rx.rx_ctl;
472 * Clear the descriptor
473 * If we don't clean the status descriptor,
474 * while scanning we get too many results,
475 * most of them virtual, after some secs
476 * of scanning system hangs. M.F.
478 memset(&desc->ud.ds_rx, 0, sizeof(struct ath5k_hw_all_rx_desc));
480 if (unlikely(size & ~AR5K_DESC_RX_CTL1_BUF_LEN))
483 /* Setup descriptor */
484 rx_ctl->rx_control_1 = size & AR5K_DESC_RX_CTL1_BUF_LEN;
486 if (flags & AR5K_RXDESC_INTREQ)
487 rx_ctl->rx_control_1 |= AR5K_DESC_RX_CTL1_INTREQ;
493 * Process the rx status descriptor on 5210/5211
495 static int ath5k_hw_proc_5210_rx_status(struct ath5k_hw *ah,
496 struct ath5k_desc *desc, struct ath5k_rx_status *rs)
498 struct ath5k_hw_rx_status *rx_status;
500 rx_status = &desc->ud.ds_rx.rx_stat;
502 /* No frame received / not ready */
503 if (unlikely(!(rx_status->rx_status_1 &
504 AR5K_5210_RX_DESC_STATUS1_DONE)))
507 memset(rs, 0, sizeof(struct ath5k_rx_status));
510 * Frame receive status
512 rs->rs_datalen = rx_status->rx_status_0 &
513 AR5K_5210_RX_DESC_STATUS0_DATA_LEN;
514 rs->rs_rssi = AR5K_REG_MS(rx_status->rx_status_0,
515 AR5K_5210_RX_DESC_STATUS0_RECEIVE_SIGNAL);
516 rs->rs_rate = AR5K_REG_MS(rx_status->rx_status_0,
517 AR5K_5210_RX_DESC_STATUS0_RECEIVE_RATE);
518 rs->rs_more = !!(rx_status->rx_status_0 &
519 AR5K_5210_RX_DESC_STATUS0_MORE);
520 /* TODO: this timestamp is 13 bit, later on we assume 15 bit!
521 * also the HAL code for 5210 says the timestamp is bits [10..22] of the
522 * TSF, and extends the timestamp here to 15 bit.
523 * we need to check on 5210...
525 rs->rs_tstamp = AR5K_REG_MS(rx_status->rx_status_1,
526 AR5K_5210_RX_DESC_STATUS1_RECEIVE_TIMESTAMP);
528 if (ah->ah_version == AR5K_AR5211)
529 rs->rs_antenna = AR5K_REG_MS(rx_status->rx_status_0,
530 AR5K_5210_RX_DESC_STATUS0_RECEIVE_ANT_5211);
532 rs->rs_antenna = (rx_status->rx_status_0 &
533 AR5K_5210_RX_DESC_STATUS0_RECEIVE_ANT_5210)
539 if (rx_status->rx_status_1 & AR5K_5210_RX_DESC_STATUS1_KEY_INDEX_VALID)
540 rs->rs_keyix = AR5K_REG_MS(rx_status->rx_status_1,
541 AR5K_5210_RX_DESC_STATUS1_KEY_INDEX);
543 rs->rs_keyix = AR5K_RXKEYIX_INVALID;
546 * Receive/descriptor errors
548 if (!(rx_status->rx_status_1 &
549 AR5K_5210_RX_DESC_STATUS1_FRAME_RECEIVE_OK)) {
550 if (rx_status->rx_status_1 &
551 AR5K_5210_RX_DESC_STATUS1_CRC_ERROR)
552 rs->rs_status |= AR5K_RXERR_CRC;
555 if ((ah->ah_version == AR5K_AR5210) &&
556 (rx_status->rx_status_1 &
557 AR5K_5210_RX_DESC_STATUS1_FIFO_OVERRUN_5210))
558 rs->rs_status |= AR5K_RXERR_FIFO;
560 if (rx_status->rx_status_1 &
561 AR5K_5210_RX_DESC_STATUS1_PHY_ERROR) {
562 rs->rs_status |= AR5K_RXERR_PHY;
563 rs->rs_phyerr = AR5K_REG_MS(rx_status->rx_status_1,
564 AR5K_5210_RX_DESC_STATUS1_PHY_ERROR);
567 if (rx_status->rx_status_1 &
568 AR5K_5210_RX_DESC_STATUS1_DECRYPT_CRC_ERROR)
569 rs->rs_status |= AR5K_RXERR_DECRYPT;
576 * Process the rx status descriptor on 5212
578 static int ath5k_hw_proc_5212_rx_status(struct ath5k_hw *ah,
579 struct ath5k_desc *desc,
580 struct ath5k_rx_status *rs)
582 struct ath5k_hw_rx_status *rx_status;
583 u32 rxstat0, rxstat1;
585 rx_status = &desc->ud.ds_rx.rx_stat;
586 rxstat1 = ACCESS_ONCE(rx_status->rx_status_1);
588 /* No frame received / not ready */
589 if (unlikely(!(rxstat1 & AR5K_5212_RX_DESC_STATUS1_DONE)))
592 memset(rs, 0, sizeof(struct ath5k_rx_status));
593 rxstat0 = ACCESS_ONCE(rx_status->rx_status_0);
596 * Frame receive status
598 rs->rs_datalen = rxstat0 & AR5K_5212_RX_DESC_STATUS0_DATA_LEN;
599 rs->rs_rssi = AR5K_REG_MS(rxstat0,
600 AR5K_5212_RX_DESC_STATUS0_RECEIVE_SIGNAL);
601 rs->rs_rate = AR5K_REG_MS(rxstat0,
602 AR5K_5212_RX_DESC_STATUS0_RECEIVE_RATE);
603 rs->rs_antenna = AR5K_REG_MS(rxstat0,
604 AR5K_5212_RX_DESC_STATUS0_RECEIVE_ANTENNA);
605 rs->rs_more = !!(rxstat0 & AR5K_5212_RX_DESC_STATUS0_MORE);
606 rs->rs_tstamp = AR5K_REG_MS(rxstat1,
607 AR5K_5212_RX_DESC_STATUS1_RECEIVE_TIMESTAMP);
612 if (rxstat1 & AR5K_5212_RX_DESC_STATUS1_KEY_INDEX_VALID)
613 rs->rs_keyix = AR5K_REG_MS(rxstat1,
614 AR5K_5212_RX_DESC_STATUS1_KEY_INDEX);
616 rs->rs_keyix = AR5K_RXKEYIX_INVALID;
619 * Receive/descriptor errors
621 if (!(rxstat1 & AR5K_5212_RX_DESC_STATUS1_FRAME_RECEIVE_OK)) {
622 if (rxstat1 & AR5K_5212_RX_DESC_STATUS1_CRC_ERROR)
623 rs->rs_status |= AR5K_RXERR_CRC;
625 if (rxstat1 & AR5K_5212_RX_DESC_STATUS1_PHY_ERROR) {
626 rs->rs_status |= AR5K_RXERR_PHY;
627 rs->rs_phyerr = AR5K_REG_MS(rxstat1,
628 AR5K_5212_RX_DESC_STATUS1_PHY_ERROR_CODE);
629 if (!ah->ah_capabilities.cap_has_phyerr_counters)
630 ath5k_ani_phy_error_report(ah, rs->rs_phyerr);
633 if (rxstat1 & AR5K_5212_RX_DESC_STATUS1_DECRYPT_CRC_ERROR)
634 rs->rs_status |= AR5K_RXERR_DECRYPT;
636 if (rxstat1 & AR5K_5212_RX_DESC_STATUS1_MIC_ERROR)
637 rs->rs_status |= AR5K_RXERR_MIC;
648 * Init function pointers inside ath5k_hw struct
650 int ath5k_hw_init_desc_functions(struct ath5k_hw *ah)
652 if (ah->ah_version == AR5K_AR5212) {
653 ah->ah_setup_tx_desc = ath5k_hw_setup_4word_tx_desc;
654 ah->ah_proc_tx_desc = ath5k_hw_proc_4word_tx_status;
655 ah->ah_proc_rx_desc = ath5k_hw_proc_5212_rx_status;
656 } else if (ah->ah_version <= AR5K_AR5211) {
657 ah->ah_setup_tx_desc = ath5k_hw_setup_2word_tx_desc;
658 ah->ah_proc_tx_desc = ath5k_hw_proc_2word_tx_status;
659 ah->ah_proc_rx_desc = ath5k_hw_proc_5210_rx_status;