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 continously 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;
187 u32 txctl0 = 0, txctl1 = 0, txctl2 = 0, txctl3 = 0;
189 tx_ctl = &desc->ud.ds_tx5212.tx_ctl;
193 * - Zero retries don't make sense.
194 * - A zero rate will put the HW into a mode where it continously sends
195 * noise on the channel, so it is important to avoid this.
197 if (unlikely(tx_tries0 == 0)) {
198 ATH5K_ERR(ah->ah_sc, "zero retries\n");
202 if (unlikely(tx_rate0 == 0)) {
203 ATH5K_ERR(ah->ah_sc, "zero rate\n");
208 tx_power += ah->ah_txpower.txp_offset;
209 if (tx_power > AR5K_TUNE_MAX_TXPOWER)
210 tx_power = AR5K_TUNE_MAX_TXPOWER;
212 /* Clear descriptor */
213 memset(&desc->ud.ds_tx5212.tx_stat, 0,
214 sizeof(desc->ud.ds_tx5212.tx_stat));
216 /* Setup control descriptor */
218 /* Verify and set frame length */
220 /* remove padding we might have added before */
221 frame_len = pkt_len - padsize + FCS_LEN;
223 if (frame_len & ~AR5K_4W_TX_DESC_CTL0_FRAME_LEN)
226 txctl0 = frame_len & AR5K_4W_TX_DESC_CTL0_FRAME_LEN;
228 /* Verify and set buffer length */
230 /* NB: beacon's BufLen must be a multiple of 4 bytes */
231 if (type == AR5K_PKT_TYPE_BEACON)
232 pkt_len = roundup(pkt_len, 4);
234 if (pkt_len & ~AR5K_4W_TX_DESC_CTL1_BUF_LEN)
237 txctl1 = pkt_len & AR5K_4W_TX_DESC_CTL1_BUF_LEN;
239 txctl0 |= AR5K_REG_SM(tx_power, AR5K_4W_TX_DESC_CTL0_XMIT_POWER) |
240 AR5K_REG_SM(antenna_mode, AR5K_4W_TX_DESC_CTL0_ANT_MODE_XMIT);
241 txctl1 |= AR5K_REG_SM(type, AR5K_4W_TX_DESC_CTL1_FRAME_TYPE);
242 txctl2 = AR5K_REG_SM(tx_tries0, AR5K_4W_TX_DESC_CTL2_XMIT_TRIES0);
243 txctl3 = tx_rate0 & AR5K_4W_TX_DESC_CTL3_XMIT_RATE0;
245 #define _TX_FLAGS(_c, _flag) \
246 if (flags & AR5K_TXDESC_##_flag) { \
247 txctl##_c |= AR5K_4W_TX_DESC_CTL##_c##_##_flag; \
250 _TX_FLAGS(0, CLRDMASK);
252 _TX_FLAGS(0, INTREQ);
253 _TX_FLAGS(0, RTSENA);
254 _TX_FLAGS(0, CTSENA);
262 if (key_index != AR5K_TXKEYIX_INVALID) {
263 txctl0 |= AR5K_4W_TX_DESC_CTL0_ENCRYPT_KEY_VALID;
264 txctl1 |= AR5K_REG_SM(key_index,
265 AR5K_4W_TX_DESC_CTL1_ENCRYPT_KEY_IDX);
271 if (flags & (AR5K_TXDESC_RTSENA | AR5K_TXDESC_CTSENA)) {
272 if ((flags & AR5K_TXDESC_RTSENA) &&
273 (flags & AR5K_TXDESC_CTSENA))
275 txctl2 |= rtscts_duration & AR5K_4W_TX_DESC_CTL2_RTS_DURATION;
276 txctl3 |= AR5K_REG_SM(rtscts_rate,
277 AR5K_4W_TX_DESC_CTL3_RTS_CTS_RATE);
280 tx_ctl->tx_control_0 = txctl0;
281 tx_ctl->tx_control_1 = txctl1;
282 tx_ctl->tx_control_2 = txctl2;
283 tx_ctl->tx_control_3 = txctl3;
289 * Initialize a 4-word multi rate retry tx control descriptor on 5212
292 ath5k_hw_setup_mrr_tx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc,
293 unsigned int tx_rate1, u_int tx_tries1, u_int tx_rate2,
294 u_int tx_tries2, unsigned int tx_rate3, u_int tx_tries3)
296 struct ath5k_hw_4w_tx_ctl *tx_ctl;
298 /* no mrr support for cards older than 5212 */
299 if (ah->ah_version < AR5K_AR5212)
303 * Rates can be 0 as long as the retry count is 0 too.
304 * A zero rate and nonzero retry count will put the HW into a mode where
305 * it continously sends noise on the channel, so it is important to
308 if (unlikely((tx_rate1 == 0 && tx_tries1 != 0) ||
309 (tx_rate2 == 0 && tx_tries2 != 0) ||
310 (tx_rate3 == 0 && tx_tries3 != 0))) {
311 ATH5K_ERR(ah->ah_sc, "zero rate\n");
316 if (ah->ah_version == AR5K_AR5212) {
317 tx_ctl = &desc->ud.ds_tx5212.tx_ctl;
319 #define _XTX_TRIES(_n) \
320 if (tx_tries##_n) { \
321 tx_ctl->tx_control_2 |= \
322 AR5K_REG_SM(tx_tries##_n, \
323 AR5K_4W_TX_DESC_CTL2_XMIT_TRIES##_n); \
324 tx_ctl->tx_control_3 |= \
325 AR5K_REG_SM(tx_rate##_n, \
326 AR5K_4W_TX_DESC_CTL3_XMIT_RATE##_n); \
342 /***********************\
343 * TX Status descriptors *
344 \***********************/
347 * Proccess the tx status descriptor on 5210/5211
349 static int ath5k_hw_proc_2word_tx_status(struct ath5k_hw *ah,
350 struct ath5k_desc *desc, struct ath5k_tx_status *ts)
352 struct ath5k_hw_2w_tx_ctl *tx_ctl;
353 struct ath5k_hw_tx_status *tx_status;
355 tx_ctl = &desc->ud.ds_tx5210.tx_ctl;
356 tx_status = &desc->ud.ds_tx5210.tx_stat;
358 /* No frame has been send or error */
359 if (unlikely((tx_status->tx_status_1 & AR5K_DESC_TX_STATUS1_DONE) == 0))
363 * Get descriptor status
365 ts->ts_tstamp = AR5K_REG_MS(tx_status->tx_status_0,
366 AR5K_DESC_TX_STATUS0_SEND_TIMESTAMP);
367 ts->ts_shortretry = AR5K_REG_MS(tx_status->tx_status_0,
368 AR5K_DESC_TX_STATUS0_SHORT_RETRY_COUNT);
369 ts->ts_longretry = AR5K_REG_MS(tx_status->tx_status_0,
370 AR5K_DESC_TX_STATUS0_LONG_RETRY_COUNT);
371 /*TODO: ts->ts_virtcol + test*/
372 ts->ts_seqnum = AR5K_REG_MS(tx_status->tx_status_1,
373 AR5K_DESC_TX_STATUS1_SEQ_NUM);
374 ts->ts_rssi = AR5K_REG_MS(tx_status->tx_status_1,
375 AR5K_DESC_TX_STATUS1_ACK_SIG_STRENGTH);
378 ts->ts_retry[0] = ts->ts_longretry;
379 ts->ts_final_idx = 0;
381 if (!(tx_status->tx_status_0 & AR5K_DESC_TX_STATUS0_FRAME_XMIT_OK)) {
382 if (tx_status->tx_status_0 &
383 AR5K_DESC_TX_STATUS0_EXCESSIVE_RETRIES)
384 ts->ts_status |= AR5K_TXERR_XRETRY;
386 if (tx_status->tx_status_0 & AR5K_DESC_TX_STATUS0_FIFO_UNDERRUN)
387 ts->ts_status |= AR5K_TXERR_FIFO;
389 if (tx_status->tx_status_0 & AR5K_DESC_TX_STATUS0_FILTERED)
390 ts->ts_status |= AR5K_TXERR_FILT;
397 * Proccess a tx status descriptor on 5212
399 static int ath5k_hw_proc_4word_tx_status(struct ath5k_hw *ah,
400 struct ath5k_desc *desc, struct ath5k_tx_status *ts)
402 struct ath5k_hw_4w_tx_ctl *tx_ctl;
403 struct ath5k_hw_tx_status *tx_status;
404 u32 txstat0, txstat1, txctl2;
406 tx_ctl = &desc->ud.ds_tx5212.tx_ctl;
407 tx_status = &desc->ud.ds_tx5212.tx_stat;
409 txstat1 = ACCESS_ONCE(tx_status->tx_status_1);
411 /* No frame has been send or error */
412 if (unlikely(!(txstat1 & AR5K_DESC_TX_STATUS1_DONE)))
415 txstat0 = ACCESS_ONCE(tx_status->tx_status_0);
416 txctl2 = ACCESS_ONCE(tx_ctl->tx_control_2);
419 * Get descriptor status
421 ts->ts_tstamp = AR5K_REG_MS(txstat0,
422 AR5K_DESC_TX_STATUS0_SEND_TIMESTAMP);
423 ts->ts_shortretry = AR5K_REG_MS(txstat0,
424 AR5K_DESC_TX_STATUS0_SHORT_RETRY_COUNT);
425 ts->ts_longretry = AR5K_REG_MS(txstat0,
426 AR5K_DESC_TX_STATUS0_LONG_RETRY_COUNT);
427 ts->ts_seqnum = AR5K_REG_MS(txstat1,
428 AR5K_DESC_TX_STATUS1_SEQ_NUM);
429 ts->ts_rssi = AR5K_REG_MS(txstat1,
430 AR5K_DESC_TX_STATUS1_ACK_SIG_STRENGTH);
431 ts->ts_antenna = (txstat1 &
432 AR5K_DESC_TX_STATUS1_XMIT_ANTENNA_5212) ? 2 : 1;
435 ts->ts_final_idx = AR5K_REG_MS(txstat1,
436 AR5K_DESC_TX_STATUS1_FINAL_TS_IX_5212);
438 /* The longretry counter has the number of un-acked retries
439 * for the final rate. To get the total number of retries
440 * we have to add the retry counters for the other rates
443 ts->ts_retry[ts->ts_final_idx] = ts->ts_longretry;
444 switch (ts->ts_final_idx) {
446 ts->ts_retry[2] = AR5K_REG_MS(txctl2,
447 AR5K_4W_TX_DESC_CTL2_XMIT_TRIES2);
448 ts->ts_longretry += ts->ts_retry[2];
451 ts->ts_retry[1] = AR5K_REG_MS(txctl2,
452 AR5K_4W_TX_DESC_CTL2_XMIT_TRIES1);
453 ts->ts_longretry += ts->ts_retry[1];
456 ts->ts_retry[0] = AR5K_REG_MS(txctl2,
457 AR5K_4W_TX_DESC_CTL2_XMIT_TRIES1);
458 ts->ts_longretry += ts->ts_retry[0];
465 if (!(txstat0 & AR5K_DESC_TX_STATUS0_FRAME_XMIT_OK)) {
466 if (txstat0 & AR5K_DESC_TX_STATUS0_EXCESSIVE_RETRIES)
467 ts->ts_status |= AR5K_TXERR_XRETRY;
469 if (txstat0 & AR5K_DESC_TX_STATUS0_FIFO_UNDERRUN)
470 ts->ts_status |= AR5K_TXERR_FIFO;
472 if (txstat0 & AR5K_DESC_TX_STATUS0_FILTERED)
473 ts->ts_status |= AR5K_TXERR_FILT;
485 * Initialize an rx control descriptor
487 int ath5k_hw_setup_rx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc,
488 u32 size, unsigned int flags)
490 struct ath5k_hw_rx_ctl *rx_ctl;
492 rx_ctl = &desc->ud.ds_rx.rx_ctl;
495 * Clear the descriptor
496 * If we don't clean the status descriptor,
497 * while scanning we get too many results,
498 * most of them virtual, after some secs
499 * of scanning system hangs. M.F.
501 memset(&desc->ud.ds_rx, 0, sizeof(struct ath5k_hw_all_rx_desc));
503 if (unlikely(size & ~AR5K_DESC_RX_CTL1_BUF_LEN))
506 /* Setup descriptor */
507 rx_ctl->rx_control_1 = size & AR5K_DESC_RX_CTL1_BUF_LEN;
509 if (flags & AR5K_RXDESC_INTREQ)
510 rx_ctl->rx_control_1 |= AR5K_DESC_RX_CTL1_INTREQ;
516 * Proccess the rx status descriptor on 5210/5211
518 static int ath5k_hw_proc_5210_rx_status(struct ath5k_hw *ah,
519 struct ath5k_desc *desc, struct ath5k_rx_status *rs)
521 struct ath5k_hw_rx_status *rx_status;
523 rx_status = &desc->ud.ds_rx.rx_stat;
525 /* No frame received / not ready */
526 if (unlikely(!(rx_status->rx_status_1 &
527 AR5K_5210_RX_DESC_STATUS1_DONE)))
530 memset(rs, 0, sizeof(struct ath5k_rx_status));
533 * Frame receive status
535 rs->rs_datalen = rx_status->rx_status_0 &
536 AR5K_5210_RX_DESC_STATUS0_DATA_LEN;
537 rs->rs_rssi = AR5K_REG_MS(rx_status->rx_status_0,
538 AR5K_5210_RX_DESC_STATUS0_RECEIVE_SIGNAL);
539 rs->rs_rate = AR5K_REG_MS(rx_status->rx_status_0,
540 AR5K_5210_RX_DESC_STATUS0_RECEIVE_RATE);
541 rs->rs_more = !!(rx_status->rx_status_0 &
542 AR5K_5210_RX_DESC_STATUS0_MORE);
543 /* TODO: this timestamp is 13 bit, later on we assume 15 bit!
544 * also the HAL code for 5210 says the timestamp is bits [10..22] of the
545 * TSF, and extends the timestamp here to 15 bit.
546 * we need to check on 5210...
548 rs->rs_tstamp = AR5K_REG_MS(rx_status->rx_status_1,
549 AR5K_5210_RX_DESC_STATUS1_RECEIVE_TIMESTAMP);
551 if (ah->ah_version == AR5K_AR5211)
552 rs->rs_antenna = AR5K_REG_MS(rx_status->rx_status_0,
553 AR5K_5210_RX_DESC_STATUS0_RECEIVE_ANT_5211);
555 rs->rs_antenna = (rx_status->rx_status_0 &
556 AR5K_5210_RX_DESC_STATUS0_RECEIVE_ANT_5210)
562 if (rx_status->rx_status_1 & AR5K_5210_RX_DESC_STATUS1_KEY_INDEX_VALID)
563 rs->rs_keyix = AR5K_REG_MS(rx_status->rx_status_1,
564 AR5K_5210_RX_DESC_STATUS1_KEY_INDEX);
566 rs->rs_keyix = AR5K_RXKEYIX_INVALID;
569 * Receive/descriptor errors
571 if (!(rx_status->rx_status_1 &
572 AR5K_5210_RX_DESC_STATUS1_FRAME_RECEIVE_OK)) {
573 if (rx_status->rx_status_1 &
574 AR5K_5210_RX_DESC_STATUS1_CRC_ERROR)
575 rs->rs_status |= AR5K_RXERR_CRC;
578 if ((ah->ah_version == AR5K_AR5210) &&
579 (rx_status->rx_status_1 &
580 AR5K_5210_RX_DESC_STATUS1_FIFO_OVERRUN_5210))
581 rs->rs_status |= AR5K_RXERR_FIFO;
583 if (rx_status->rx_status_1 &
584 AR5K_5210_RX_DESC_STATUS1_PHY_ERROR) {
585 rs->rs_status |= AR5K_RXERR_PHY;
586 rs->rs_phyerr = AR5K_REG_MS(rx_status->rx_status_1,
587 AR5K_5210_RX_DESC_STATUS1_PHY_ERROR);
590 if (rx_status->rx_status_1 &
591 AR5K_5210_RX_DESC_STATUS1_DECRYPT_CRC_ERROR)
592 rs->rs_status |= AR5K_RXERR_DECRYPT;
599 * Proccess the rx status descriptor on 5212
601 static int ath5k_hw_proc_5212_rx_status(struct ath5k_hw *ah,
602 struct ath5k_desc *desc,
603 struct ath5k_rx_status *rs)
605 struct ath5k_hw_rx_status *rx_status;
607 rx_status = &desc->ud.ds_rx.rx_stat;
609 /* No frame received / not ready */
610 if (unlikely(!(rx_status->rx_status_1 &
611 AR5K_5212_RX_DESC_STATUS1_DONE)))
614 memset(rs, 0, sizeof(struct ath5k_rx_status));
617 * Frame receive status
619 rs->rs_datalen = rx_status->rx_status_0 &
620 AR5K_5212_RX_DESC_STATUS0_DATA_LEN;
621 rs->rs_rssi = AR5K_REG_MS(rx_status->rx_status_0,
622 AR5K_5212_RX_DESC_STATUS0_RECEIVE_SIGNAL);
623 rs->rs_rate = AR5K_REG_MS(rx_status->rx_status_0,
624 AR5K_5212_RX_DESC_STATUS0_RECEIVE_RATE);
625 rs->rs_antenna = AR5K_REG_MS(rx_status->rx_status_0,
626 AR5K_5212_RX_DESC_STATUS0_RECEIVE_ANTENNA);
627 rs->rs_more = !!(rx_status->rx_status_0 &
628 AR5K_5212_RX_DESC_STATUS0_MORE);
629 rs->rs_tstamp = AR5K_REG_MS(rx_status->rx_status_1,
630 AR5K_5212_RX_DESC_STATUS1_RECEIVE_TIMESTAMP);
635 if (rx_status->rx_status_1 & AR5K_5212_RX_DESC_STATUS1_KEY_INDEX_VALID)
636 rs->rs_keyix = AR5K_REG_MS(rx_status->rx_status_1,
637 AR5K_5212_RX_DESC_STATUS1_KEY_INDEX);
639 rs->rs_keyix = AR5K_RXKEYIX_INVALID;
642 * Receive/descriptor errors
644 if (!(rx_status->rx_status_1 &
645 AR5K_5212_RX_DESC_STATUS1_FRAME_RECEIVE_OK)) {
646 if (rx_status->rx_status_1 &
647 AR5K_5212_RX_DESC_STATUS1_CRC_ERROR)
648 rs->rs_status |= AR5K_RXERR_CRC;
650 if (rx_status->rx_status_1 &
651 AR5K_5212_RX_DESC_STATUS1_PHY_ERROR) {
652 rs->rs_status |= AR5K_RXERR_PHY;
653 rs->rs_phyerr = AR5K_REG_MS(rx_status->rx_status_1,
654 AR5K_5212_RX_DESC_STATUS1_PHY_ERROR_CODE);
655 if (!ah->ah_capabilities.cap_has_phyerr_counters)
656 ath5k_ani_phy_error_report(ah, rs->rs_phyerr);
659 if (rx_status->rx_status_1 &
660 AR5K_5212_RX_DESC_STATUS1_DECRYPT_CRC_ERROR)
661 rs->rs_status |= AR5K_RXERR_DECRYPT;
663 if (rx_status->rx_status_1 &
664 AR5K_5212_RX_DESC_STATUS1_MIC_ERROR)
665 rs->rs_status |= AR5K_RXERR_MIC;
676 * Init function pointers inside ath5k_hw struct
678 int ath5k_hw_init_desc_functions(struct ath5k_hw *ah)
680 if (ah->ah_version == AR5K_AR5212) {
681 ah->ah_setup_tx_desc = ath5k_hw_setup_4word_tx_desc;
682 ah->ah_proc_tx_desc = ath5k_hw_proc_4word_tx_status;
683 ah->ah_proc_rx_desc = ath5k_hw_proc_5212_rx_status;
684 } else if (ah->ah_version <= AR5K_AR5211) {
685 ah->ah_setup_tx_desc = ath5k_hw_setup_2word_tx_desc;
686 ah->ah_proc_tx_desc = ath5k_hw_proc_2word_tx_status;
687 ah->ah_proc_rx_desc = ath5k_hw_proc_5210_rx_status;