aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBruno Randolf <br1@einfach.org>2008-03-05 04:35:23 -0500
committerJohn W. Linville <linville@tuxdriver.com>2008-03-07 16:07:49 -0500
commit19fd6e5510f6991148e2210753b58f0eab95e0f6 (patch)
tree1a71054afbc01d0db5f99fdc50a747eef38d1b54 /drivers
parentb095d03a7d724db7379b73f64b6035f7be2e0a7c (diff)
ath5k: struct ath5k_desc cleanups
* make struct ath5k_desc clearer by directly including unions of structures, which correspond to the hardware descriptors of different HW versions (5210 and 5212). before they were casted at onto ath5k_desc at different points (e.g. ds_hw[2]). * rename some structures and variable names to make their use clearer, e.g. struct ath5k_hw_4w_tx_desc to ath5k_hw_4w_tx_ctl. * substitute "old" with "5210" and "new" with "5212" (eg. rename ath5k_hw_proc_new_rx_status() to ath5k_hw_proc_5212_rx_status()) because old and new are relative and we might have a newer structure at some point. * unify structs ath5k_hw_old_rx_status and ath5k_hw_new_rx_status into one ath5k_hw_rx_status, because they only differ in the flags and masks. drivers/net/wireless/ath5k/ath5k.h: Changes-licensed-under: ISC drivers/net/wireless/ath5k/debug.c: Changes-licensed-under: GPL drivers/net/wireless/ath5k/hw.c: Changes-licensed-under: ISC drivers/net/wireless/ath5k/hw.h: Changes-licensed-under: ISC Signed-off-by: Bruno Randolf <bruno@thinktube.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/ath5k/ath5k.h23
-rw-r--r--drivers/net/wireless/ath5k/debug.c12
-rw-r--r--drivers/net/wireless/ath5k/hw.c212
-rw-r--r--drivers/net/wireless/ath5k/hw.h150
4 files changed, 210 insertions, 187 deletions
diff --git a/drivers/net/wireless/ath5k/ath5k.h b/drivers/net/wireless/ath5k/ath5k.h
index 04efceef95a8..2af7982f6f0d 100644
--- a/drivers/net/wireless/ath5k/ath5k.h
+++ b/drivers/net/wireless/ath5k/ath5k.h
@@ -273,12 +273,13 @@ enum ath5k_driver_mode {
273#define SHPREAMBLE_FLAG(_ix) \ 273#define SHPREAMBLE_FLAG(_ix) \
274 (HAS_SHPREAMBLE(_ix) ? AR5K_SET_SHORT_PREAMBLE : 0) 274 (HAS_SHPREAMBLE(_ix) ? AR5K_SET_SHORT_PREAMBLE : 0)
275 275
276
276/****************\ 277/****************\
277 TX DEFINITIONS 278 TX DEFINITIONS
278\****************/ 279\****************/
279 280
280/* 281/*
281 * Tx Descriptor 282 * TX Status
282 */ 283 */
283struct ath5k_tx_status { 284struct ath5k_tx_status {
284 u16 ts_seqnum; 285 u16 ts_seqnum;
@@ -426,7 +427,7 @@ enum ath5k_dmasize {
426\****************/ 427\****************/
427 428
428/* 429/*
429 * Rx Descriptor 430 * RX Status
430 */ 431 */
431struct ath5k_rx_status { 432struct ath5k_rx_status {
432 u16 rs_datalen; 433 u16 rs_datalen;
@@ -457,8 +458,6 @@ struct ath5k_mib_stats {
457}; 458};
458 459
459 460
460
461
462/**************************\ 461/**************************\
463 BEACON TIMERS DEFINITIONS 462 BEACON TIMERS DEFINITIONS
464\**************************/ 463\**************************/
@@ -500,20 +499,22 @@ struct ath5k_beacon_state {
500#define TSF_TO_TU(_tsf) (u32)((_tsf) >> 10) 499#define TSF_TO_TU(_tsf) (u32)((_tsf) >> 10)
501 500
502 501
503
504/********************\ 502/********************\
505 COMMON DEFINITIONS 503 COMMON DEFINITIONS
506\********************/ 504\********************/
507 505
508/* 506/*
509 * Atheros descriptor 507 * Atheros hardware descriptor
510 */ 508 */
511struct ath5k_desc { 509struct ath5k_desc {
512 u32 ds_link; 510 u32 ds_link; /* physical address of the next descriptor */
513 u32 ds_data; 511 u32 ds_data; /* physical address of data buffer (skb) */
514 u32 ds_ctl0; 512
515 u32 ds_ctl1; 513 union {
516 u32 ds_hw[4]; 514 struct ath5k_hw_5210_tx_desc ds_tx5210;
515 struct ath5k_hw_5212_tx_desc ds_tx5212;
516 struct ath5k_hw_all_rx_desc ds_rx;
517 } ud;
517 518
518 union { 519 union {
519 struct ath5k_rx_status rx; 520 struct ath5k_rx_status rx;
diff --git a/drivers/net/wireless/ath5k/debug.c b/drivers/net/wireless/ath5k/debug.c
index 05bf4fb8f907..93014944f43f 100644
--- a/drivers/net/wireless/ath5k/debug.c
+++ b/drivers/net/wireless/ath5k/debug.c
@@ -500,11 +500,13 @@ static inline void
500ath5k_debug_printrxbuf(struct ath5k_buf *bf, int done) 500ath5k_debug_printrxbuf(struct ath5k_buf *bf, int done)
501{ 501{
502 struct ath5k_desc *ds = bf->desc; 502 struct ath5k_desc *ds = bf->desc;
503 struct ath5k_hw_all_rx_desc *rd = &ds->ud.ds_rx;
503 504
504 printk(KERN_DEBUG "R (%p %llx) %08x %08x %08x %08x %08x %08x %c\n", 505 printk(KERN_DEBUG "R (%p %llx) %08x %08x %08x %08x %08x %08x %c\n",
505 ds, (unsigned long long)bf->daddr, 506 ds, (unsigned long long)bf->daddr,
506 ds->ds_link, ds->ds_data, ds->ds_ctl0, ds->ds_ctl1, 507 ds->ds_link, ds->ds_data,
507 ds->ds_hw[0], ds->ds_hw[1], 508 rd->rx_ctl.rx_control_0, rd->rx_ctl.rx_control_1,
509 rd->u.rx_stat.rx_status_0, rd->u.rx_stat.rx_status_0,
508 !done ? ' ' : (ds->ds_rxstat.rs_status == 0) ? '*' : '!'); 510 !done ? ' ' : (ds->ds_rxstat.rs_status == 0) ? '*' : '!');
509} 511}
510 512
@@ -554,14 +556,16 @@ ath5k_debug_printtxbuf(struct ath5k_softc *sc,
554 struct ath5k_buf *bf, int done) 556 struct ath5k_buf *bf, int done)
555{ 557{
556 struct ath5k_desc *ds = bf->desc; 558 struct ath5k_desc *ds = bf->desc;
559 struct ath5k_hw_5212_tx_desc *td = &ds->ud.ds_tx5212;
557 560
558 if (likely(!(sc->debug.level & ATH5K_DEBUG_RESET))) 561 if (likely(!(sc->debug.level & ATH5K_DEBUG_RESET)))
559 return; 562 return;
560 563
561 printk(KERN_DEBUG "T (%p %llx) %08x %08x %08x %08x %08x %08x %08x " 564 printk(KERN_DEBUG "T (%p %llx) %08x %08x %08x %08x %08x %08x %08x "
562 "%08x %c\n", ds, (unsigned long long)bf->daddr, ds->ds_link, 565 "%08x %c\n", ds, (unsigned long long)bf->daddr, ds->ds_link,
563 ds->ds_data, ds->ds_ctl0, ds->ds_ctl1, 566 ds->ds_data, td->tx_ctl.tx_control_0, td->tx_ctl.tx_control_1,
564 ds->ds_hw[0], ds->ds_hw[1], ds->ds_hw[2], ds->ds_hw[3], 567 td->tx_ctl.tx_control_2, td->tx_ctl.tx_control_3,
568 td->tx_stat.tx_status_0, td->tx_stat.tx_status_1,
565 !done ? ' ' : (ds->ds_txstat.ts_status == 0) ? '*' : '!'); 569 !done ? ' ' : (ds->ds_txstat.ts_status == 0) ? '*' : '!');
566} 570}
567 571
diff --git a/drivers/net/wireless/ath5k/hw.c b/drivers/net/wireless/ath5k/hw.c
index 3c399604f30e..f88adf52a1b2 100644
--- a/drivers/net/wireless/ath5k/hw.c
+++ b/drivers/net/wireless/ath5k/hw.c
@@ -54,8 +54,8 @@ static int ath5k_hw_setup_2word_tx_desc(struct ath5k_hw *, struct ath5k_desc *,
54 unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, 54 unsigned int, unsigned int, unsigned int, unsigned int, unsigned int,
55 unsigned int, unsigned int); 55 unsigned int, unsigned int);
56static int ath5k_hw_proc_2word_tx_status(struct ath5k_hw *, struct ath5k_desc *); 56static int ath5k_hw_proc_2word_tx_status(struct ath5k_hw *, struct ath5k_desc *);
57static int ath5k_hw_proc_new_rx_status(struct ath5k_hw *, struct ath5k_desc *); 57static int ath5k_hw_proc_5212_rx_status(struct ath5k_hw *, struct ath5k_desc *);
58static int ath5k_hw_proc_old_rx_status(struct ath5k_hw *, struct ath5k_desc *); 58static int ath5k_hw_proc_5210_rx_status(struct ath5k_hw *, struct ath5k_desc *);
59static int ath5k_hw_get_capabilities(struct ath5k_hw *); 59static int ath5k_hw_get_capabilities(struct ath5k_hw *);
60 60
61static int ath5k_eeprom_init(struct ath5k_hw *); 61static int ath5k_eeprom_init(struct ath5k_hw *);
@@ -174,9 +174,9 @@ struct ath5k_hw *ath5k_hw_attach(struct ath5k_softc *sc, u8 mac_version)
174 } 174 }
175 175
176 if (ah->ah_version == AR5K_AR5212) 176 if (ah->ah_version == AR5K_AR5212)
177 ah->ah_proc_rx_desc = ath5k_hw_proc_new_rx_status; 177 ah->ah_proc_rx_desc = ath5k_hw_proc_5212_rx_status;
178 else if (ah->ah_version <= AR5K_AR5211) 178 else if (ah->ah_version <= AR5K_AR5211)
179 ah->ah_proc_rx_desc = ath5k_hw_proc_old_rx_status; 179 ah->ah_proc_rx_desc = ath5k_hw_proc_5210_rx_status;
180 180
181 /* Bring device out of sleep and reset it's units */ 181 /* Bring device out of sleep and reset it's units */
182 ret = ath5k_hw_nic_wakeup(ah, AR5K_INIT_MODE, true); 182 ret = ath5k_hw_nic_wakeup(ah, AR5K_INIT_MODE, true);
@@ -3522,10 +3522,10 @@ ath5k_hw_setup_2word_tx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc,
3522 unsigned int rtscts_rate, unsigned int rtscts_duration) 3522 unsigned int rtscts_rate, unsigned int rtscts_duration)
3523{ 3523{
3524 u32 frame_type; 3524 u32 frame_type;
3525 struct ath5k_hw_2w_tx_desc *tx_desc; 3525 struct ath5k_hw_2w_tx_ctl *tx_ctl;
3526 unsigned int frame_len; 3526 unsigned int frame_len;
3527 3527
3528 tx_desc = (struct ath5k_hw_2w_tx_desc *)&desc->ds_ctl0; 3528 tx_ctl = &desc->ud.ds_tx5210.tx_ctl;
3529 3529
3530 /* 3530 /*
3531 * Validate input 3531 * Validate input
@@ -3544,12 +3544,8 @@ ath5k_hw_setup_2word_tx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc,
3544 return -EINVAL; 3544 return -EINVAL;
3545 } 3545 }
3546 3546
3547 /* Clear status descriptor */ 3547 /* Clear descriptor */
3548 memset(desc->ds_hw, 0, sizeof(struct ath5k_hw_tx_status)); 3548 memset(&desc->ud.ds_tx5210, 0, sizeof(struct ath5k_hw_5210_tx_desc));
3549
3550 /* Initialize control descriptor */
3551 tx_desc->tx_control_0 = 0;
3552 tx_desc->tx_control_1 = 0;
3553 3549
3554 /* Setup control descriptor */ 3550 /* Setup control descriptor */
3555 3551
@@ -3561,7 +3557,7 @@ ath5k_hw_setup_2word_tx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc,
3561 if (frame_len & ~AR5K_2W_TX_DESC_CTL0_FRAME_LEN) 3557 if (frame_len & ~AR5K_2W_TX_DESC_CTL0_FRAME_LEN)
3562 return -EINVAL; 3558 return -EINVAL;
3563 3559
3564 tx_desc->tx_control_0 = frame_len & AR5K_2W_TX_DESC_CTL0_FRAME_LEN; 3560 tx_ctl->tx_control_0 = frame_len & AR5K_2W_TX_DESC_CTL0_FRAME_LEN;
3565 3561
3566 /* Verify and set buffer length */ 3562 /* Verify and set buffer length */
3567 3563
@@ -3572,7 +3568,7 @@ ath5k_hw_setup_2word_tx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc,
3572 if (pkt_len & ~AR5K_2W_TX_DESC_CTL1_BUF_LEN) 3568 if (pkt_len & ~AR5K_2W_TX_DESC_CTL1_BUF_LEN)
3573 return -EINVAL; 3569 return -EINVAL;
3574 3570
3575 tx_desc->tx_control_1 = pkt_len & AR5K_2W_TX_DESC_CTL1_BUF_LEN; 3571 tx_ctl->tx_control_1 = pkt_len & AR5K_2W_TX_DESC_CTL1_BUF_LEN;
3576 3572
3577 /* 3573 /*
3578 * Verify and set header length 3574 * Verify and set header length
@@ -3581,7 +3577,7 @@ ath5k_hw_setup_2word_tx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc,
3581 if (ah->ah_version == AR5K_AR5210) { 3577 if (ah->ah_version == AR5K_AR5210) {
3582 if (hdr_len & ~AR5K_2W_TX_DESC_CTL0_HEADER_LEN) 3578 if (hdr_len & ~AR5K_2W_TX_DESC_CTL0_HEADER_LEN)
3583 return -EINVAL; 3579 return -EINVAL;
3584 tx_desc->tx_control_0 |= 3580 tx_ctl->tx_control_0 |=
3585 AR5K_REG_SM(hdr_len, AR5K_2W_TX_DESC_CTL0_HEADER_LEN); 3581 AR5K_REG_SM(hdr_len, AR5K_2W_TX_DESC_CTL0_HEADER_LEN);
3586 } 3582 }
3587 3583
@@ -3597,19 +3593,19 @@ ath5k_hw_setup_2word_tx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc,
3597 frame_type = type /*<< 2 ?*/; 3593 frame_type = type /*<< 2 ?*/;
3598 } 3594 }
3599 3595
3600 tx_desc->tx_control_0 |= 3596 tx_ctl->tx_control_0 |=
3601 AR5K_REG_SM(frame_type, AR5K_2W_TX_DESC_CTL0_FRAME_TYPE) | 3597 AR5K_REG_SM(frame_type, AR5K_2W_TX_DESC_CTL0_FRAME_TYPE) |
3602 AR5K_REG_SM(tx_rate0, AR5K_2W_TX_DESC_CTL0_XMIT_RATE); 3598 AR5K_REG_SM(tx_rate0, AR5K_2W_TX_DESC_CTL0_XMIT_RATE);
3603 } else { 3599 } else {
3604 tx_desc->tx_control_0 |= 3600 tx_ctl->tx_control_0 |=
3605 AR5K_REG_SM(tx_rate0, AR5K_2W_TX_DESC_CTL0_XMIT_RATE) | 3601 AR5K_REG_SM(tx_rate0, AR5K_2W_TX_DESC_CTL0_XMIT_RATE) |
3606 AR5K_REG_SM(antenna_mode, AR5K_2W_TX_DESC_CTL0_ANT_MODE_XMIT); 3602 AR5K_REG_SM(antenna_mode, AR5K_2W_TX_DESC_CTL0_ANT_MODE_XMIT);
3607 tx_desc->tx_control_1 |= 3603 tx_ctl->tx_control_1 |=
3608 AR5K_REG_SM(type, AR5K_2W_TX_DESC_CTL1_FRAME_TYPE); 3604 AR5K_REG_SM(type, AR5K_2W_TX_DESC_CTL1_FRAME_TYPE);
3609 } 3605 }
3610#define _TX_FLAGS(_c, _flag) \ 3606#define _TX_FLAGS(_c, _flag) \
3611 if (flags & AR5K_TXDESC_##_flag) \ 3607 if (flags & AR5K_TXDESC_##_flag) \
3612 tx_desc->tx_control_##_c |= \ 3608 tx_ctl->tx_control_##_c |= \
3613 AR5K_2W_TX_DESC_CTL##_c##_##_flag 3609 AR5K_2W_TX_DESC_CTL##_c##_##_flag
3614 3610
3615 _TX_FLAGS(0, CLRDMASK); 3611 _TX_FLAGS(0, CLRDMASK);
@@ -3624,9 +3620,9 @@ ath5k_hw_setup_2word_tx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc,
3624 * WEP crap 3620 * WEP crap
3625 */ 3621 */
3626 if (key_index != AR5K_TXKEYIX_INVALID) { 3622 if (key_index != AR5K_TXKEYIX_INVALID) {
3627 tx_desc->tx_control_0 |= 3623 tx_ctl->tx_control_0 |=
3628 AR5K_2W_TX_DESC_CTL0_ENCRYPT_KEY_VALID; 3624 AR5K_2W_TX_DESC_CTL0_ENCRYPT_KEY_VALID;
3629 tx_desc->tx_control_1 |= 3625 tx_ctl->tx_control_1 |=
3630 AR5K_REG_SM(key_index, 3626 AR5K_REG_SM(key_index,
3631 AR5K_2W_TX_DESC_CTL1_ENCRYPT_KEY_INDEX); 3627 AR5K_2W_TX_DESC_CTL1_ENCRYPT_KEY_INDEX);
3632 } 3628 }
@@ -3636,7 +3632,7 @@ ath5k_hw_setup_2word_tx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc,
3636 */ 3632 */
3637 if ((ah->ah_version == AR5K_AR5210) && 3633 if ((ah->ah_version == AR5K_AR5210) &&
3638 (flags & (AR5K_TXDESC_RTSENA | AR5K_TXDESC_CTSENA))) 3634 (flags & (AR5K_TXDESC_RTSENA | AR5K_TXDESC_CTSENA)))
3639 tx_desc->tx_control_1 |= rtscts_duration & 3635 tx_ctl->tx_control_1 |= rtscts_duration &
3640 AR5K_2W_TX_DESC_CTL1_RTS_DURATION; 3636 AR5K_2W_TX_DESC_CTL1_RTS_DURATION;
3641 3637
3642 return 0; 3638 return 0;
@@ -3652,13 +3648,11 @@ static int ath5k_hw_setup_4word_tx_desc(struct ath5k_hw *ah,
3652 unsigned int antenna_mode, unsigned int flags, unsigned int rtscts_rate, 3648 unsigned int antenna_mode, unsigned int flags, unsigned int rtscts_rate,
3653 unsigned int rtscts_duration) 3649 unsigned int rtscts_duration)
3654{ 3650{
3655 struct ath5k_hw_4w_tx_desc *tx_desc; 3651 struct ath5k_hw_4w_tx_ctl *tx_ctl;
3656 struct ath5k_hw_tx_status *tx_status;
3657 unsigned int frame_len; 3652 unsigned int frame_len;
3658 3653
3659 ATH5K_TRACE(ah->ah_sc); 3654 ATH5K_TRACE(ah->ah_sc);
3660 tx_desc = (struct ath5k_hw_4w_tx_desc *)&desc->ds_ctl0; 3655 tx_ctl = &desc->ud.ds_tx5212.tx_ctl;
3661 tx_status = (struct ath5k_hw_tx_status *)&desc->ds_hw[2];
3662 3656
3663 /* 3657 /*
3664 * Validate input 3658 * Validate input
@@ -3677,14 +3671,8 @@ static int ath5k_hw_setup_4word_tx_desc(struct ath5k_hw *ah,
3677 return -EINVAL; 3671 return -EINVAL;
3678 } 3672 }
3679 3673
3680 /* Clear status descriptor */ 3674 /* Clear descriptor */
3681 memset(tx_status, 0, sizeof(struct ath5k_hw_tx_status)); 3675 memset(&desc->ud.ds_tx5212, 0, sizeof(struct ath5k_hw_5212_tx_desc));
3682
3683 /* Initialize control descriptor */
3684 tx_desc->tx_control_0 = 0;
3685 tx_desc->tx_control_1 = 0;
3686 tx_desc->tx_control_2 = 0;
3687 tx_desc->tx_control_3 = 0;
3688 3676
3689 /* Setup control descriptor */ 3677 /* Setup control descriptor */
3690 3678
@@ -3696,7 +3684,7 @@ static int ath5k_hw_setup_4word_tx_desc(struct ath5k_hw *ah,
3696 if (frame_len & ~AR5K_4W_TX_DESC_CTL0_FRAME_LEN) 3684 if (frame_len & ~AR5K_4W_TX_DESC_CTL0_FRAME_LEN)
3697 return -EINVAL; 3685 return -EINVAL;
3698 3686
3699 tx_desc->tx_control_0 = frame_len & AR5K_4W_TX_DESC_CTL0_FRAME_LEN; 3687 tx_ctl->tx_control_0 = frame_len & AR5K_4W_TX_DESC_CTL0_FRAME_LEN;
3700 3688
3701 /* Verify and set buffer length */ 3689 /* Verify and set buffer length */
3702 3690
@@ -3707,20 +3695,20 @@ static int ath5k_hw_setup_4word_tx_desc(struct ath5k_hw *ah,
3707 if (pkt_len & ~AR5K_4W_TX_DESC_CTL1_BUF_LEN) 3695 if (pkt_len & ~AR5K_4W_TX_DESC_CTL1_BUF_LEN)
3708 return -EINVAL; 3696 return -EINVAL;
3709 3697
3710 tx_desc->tx_control_1 = pkt_len & AR5K_4W_TX_DESC_CTL1_BUF_LEN; 3698 tx_ctl->tx_control_1 = pkt_len & AR5K_4W_TX_DESC_CTL1_BUF_LEN;
3711 3699
3712 tx_desc->tx_control_0 |= 3700 tx_ctl->tx_control_0 |=
3713 AR5K_REG_SM(tx_power, AR5K_4W_TX_DESC_CTL0_XMIT_POWER) | 3701 AR5K_REG_SM(tx_power, AR5K_4W_TX_DESC_CTL0_XMIT_POWER) |
3714 AR5K_REG_SM(antenna_mode, AR5K_4W_TX_DESC_CTL0_ANT_MODE_XMIT); 3702 AR5K_REG_SM(antenna_mode, AR5K_4W_TX_DESC_CTL0_ANT_MODE_XMIT);
3715 tx_desc->tx_control_1 |= AR5K_REG_SM(type, 3703 tx_ctl->tx_control_1 |= AR5K_REG_SM(type,
3716 AR5K_4W_TX_DESC_CTL1_FRAME_TYPE); 3704 AR5K_4W_TX_DESC_CTL1_FRAME_TYPE);
3717 tx_desc->tx_control_2 = AR5K_REG_SM(tx_tries0 + AR5K_TUNE_HWTXTRIES, 3705 tx_ctl->tx_control_2 = AR5K_REG_SM(tx_tries0 + AR5K_TUNE_HWTXTRIES,
3718 AR5K_4W_TX_DESC_CTL2_XMIT_TRIES0); 3706 AR5K_4W_TX_DESC_CTL2_XMIT_TRIES0);
3719 tx_desc->tx_control_3 = tx_rate0 & AR5K_4W_TX_DESC_CTL3_XMIT_RATE0; 3707 tx_ctl->tx_control_3 = tx_rate0 & AR5K_4W_TX_DESC_CTL3_XMIT_RATE0;
3720 3708
3721#define _TX_FLAGS(_c, _flag) \ 3709#define _TX_FLAGS(_c, _flag) \
3722 if (flags & AR5K_TXDESC_##_flag) \ 3710 if (flags & AR5K_TXDESC_##_flag) \
3723 tx_desc->tx_control_##_c |= \ 3711 tx_ctl->tx_control_##_c |= \
3724 AR5K_4W_TX_DESC_CTL##_c##_##_flag 3712 AR5K_4W_TX_DESC_CTL##_c##_##_flag
3725 3713
3726 _TX_FLAGS(0, CLRDMASK); 3714 _TX_FLAGS(0, CLRDMASK);
@@ -3736,8 +3724,8 @@ static int ath5k_hw_setup_4word_tx_desc(struct ath5k_hw *ah,
3736 * WEP crap 3724 * WEP crap
3737 */ 3725 */
3738 if (key_index != AR5K_TXKEYIX_INVALID) { 3726 if (key_index != AR5K_TXKEYIX_INVALID) {
3739 tx_desc->tx_control_0 |= AR5K_4W_TX_DESC_CTL0_ENCRYPT_KEY_VALID; 3727 tx_ctl->tx_control_0 |= AR5K_4W_TX_DESC_CTL0_ENCRYPT_KEY_VALID;
3740 tx_desc->tx_control_1 |= AR5K_REG_SM(key_index, 3728 tx_ctl->tx_control_1 |= AR5K_REG_SM(key_index,
3741 AR5K_4W_TX_DESC_CTL1_ENCRYPT_KEY_INDEX); 3729 AR5K_4W_TX_DESC_CTL1_ENCRYPT_KEY_INDEX);
3742 } 3730 }
3743 3731
@@ -3748,9 +3736,9 @@ static int ath5k_hw_setup_4word_tx_desc(struct ath5k_hw *ah,
3748 if ((flags & AR5K_TXDESC_RTSENA) && 3736 if ((flags & AR5K_TXDESC_RTSENA) &&
3749 (flags & AR5K_TXDESC_CTSENA)) 3737 (flags & AR5K_TXDESC_CTSENA))
3750 return -EINVAL; 3738 return -EINVAL;
3751 tx_desc->tx_control_2 |= rtscts_duration & 3739 tx_ctl->tx_control_2 |= rtscts_duration &
3752 AR5K_4W_TX_DESC_CTL2_RTS_DURATION; 3740 AR5K_4W_TX_DESC_CTL2_RTS_DURATION;
3753 tx_desc->tx_control_3 |= AR5K_REG_SM(rtscts_rate, 3741 tx_ctl->tx_control_3 |= AR5K_REG_SM(rtscts_rate,
3754 AR5K_4W_TX_DESC_CTL3_RTS_CTS_RATE); 3742 AR5K_4W_TX_DESC_CTL3_RTS_CTS_RATE);
3755 } 3743 }
3756 3744
@@ -3765,7 +3753,7 @@ ath5k_hw_setup_xr_tx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc,
3765 unsigned int tx_rate1, u_int tx_tries1, u_int tx_rate2, u_int tx_tries2, 3753 unsigned int tx_rate1, u_int tx_tries1, u_int tx_rate2, u_int tx_tries2,
3766 unsigned int tx_rate3, u_int tx_tries3) 3754 unsigned int tx_rate3, u_int tx_tries3)
3767{ 3755{
3768 struct ath5k_hw_4w_tx_desc *tx_desc; 3756 struct ath5k_hw_4w_tx_ctl *tx_ctl;
3769 3757
3770 /* 3758 /*
3771 * Rates can be 0 as long as the retry count is 0 too. 3759 * Rates can be 0 as long as the retry count is 0 too.
@@ -3782,14 +3770,14 @@ ath5k_hw_setup_xr_tx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc,
3782 } 3770 }
3783 3771
3784 if (ah->ah_version == AR5K_AR5212) { 3772 if (ah->ah_version == AR5K_AR5212) {
3785 tx_desc = (struct ath5k_hw_4w_tx_desc *)&desc->ds_ctl0; 3773 tx_ctl = &desc->ud.ds_tx5212.tx_ctl;
3786 3774
3787#define _XTX_TRIES(_n) \ 3775#define _XTX_TRIES(_n) \
3788 if (tx_tries##_n) { \ 3776 if (tx_tries##_n) { \
3789 tx_desc->tx_control_2 |= \ 3777 tx_ctl->tx_control_2 |= \
3790 AR5K_REG_SM(tx_tries##_n, \ 3778 AR5K_REG_SM(tx_tries##_n, \
3791 AR5K_4W_TX_DESC_CTL2_XMIT_TRIES##_n); \ 3779 AR5K_4W_TX_DESC_CTL2_XMIT_TRIES##_n); \
3792 tx_desc->tx_control_3 |= \ 3780 tx_ctl->tx_control_3 |= \
3793 AR5K_REG_SM(tx_rate##_n, \ 3781 AR5K_REG_SM(tx_rate##_n, \
3794 AR5K_4W_TX_DESC_CTL3_XMIT_RATE##_n); \ 3782 AR5K_4W_TX_DESC_CTL3_XMIT_RATE##_n); \
3795 } 3783 }
@@ -3812,11 +3800,13 @@ ath5k_hw_setup_xr_tx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc,
3812static int ath5k_hw_proc_2word_tx_status(struct ath5k_hw *ah, 3800static int ath5k_hw_proc_2word_tx_status(struct ath5k_hw *ah,
3813 struct ath5k_desc *desc) 3801 struct ath5k_desc *desc)
3814{ 3802{
3803 struct ath5k_hw_2w_tx_ctl *tx_ctl;
3815 struct ath5k_hw_tx_status *tx_status; 3804 struct ath5k_hw_tx_status *tx_status;
3816 struct ath5k_hw_2w_tx_desc *tx_desc;
3817 3805
3818 tx_desc = (struct ath5k_hw_2w_tx_desc *)&desc->ds_ctl0; 3806 ATH5K_TRACE(ah->ah_sc);
3819 tx_status = (struct ath5k_hw_tx_status *)&desc->ds_hw[0]; 3807
3808 tx_ctl = &desc->ud.ds_tx5210.tx_ctl;
3809 tx_status = &desc->ud.ds_tx5210.tx_stat;
3820 3810
3821 /* No frame has been send or error */ 3811 /* No frame has been send or error */
3822 if (unlikely((tx_status->tx_status_1 & AR5K_DESC_TX_STATUS1_DONE) == 0)) 3812 if (unlikely((tx_status->tx_status_1 & AR5K_DESC_TX_STATUS1_DONE) == 0))
@@ -3838,7 +3828,7 @@ static int ath5k_hw_proc_2word_tx_status(struct ath5k_hw *ah,
3838 AR5K_DESC_TX_STATUS1_ACK_SIG_STRENGTH); 3828 AR5K_DESC_TX_STATUS1_ACK_SIG_STRENGTH);
3839 desc->ds_us.tx.ts_antenna = 1; 3829 desc->ds_us.tx.ts_antenna = 1;
3840 desc->ds_us.tx.ts_status = 0; 3830 desc->ds_us.tx.ts_status = 0;
3841 desc->ds_us.tx.ts_rate = AR5K_REG_MS(tx_desc->tx_control_0, 3831 desc->ds_us.tx.ts_rate = AR5K_REG_MS(tx_ctl->tx_control_0,
3842 AR5K_2W_TX_DESC_CTL0_XMIT_RATE); 3832 AR5K_2W_TX_DESC_CTL0_XMIT_RATE);
3843 3833
3844 if ((tx_status->tx_status_0 & AR5K_DESC_TX_STATUS0_FRAME_XMIT_OK) == 0){ 3834 if ((tx_status->tx_status_0 & AR5K_DESC_TX_STATUS0_FRAME_XMIT_OK) == 0){
@@ -3862,12 +3852,13 @@ static int ath5k_hw_proc_2word_tx_status(struct ath5k_hw *ah,
3862static int ath5k_hw_proc_4word_tx_status(struct ath5k_hw *ah, 3852static int ath5k_hw_proc_4word_tx_status(struct ath5k_hw *ah,
3863 struct ath5k_desc *desc) 3853 struct ath5k_desc *desc)
3864{ 3854{
3855 struct ath5k_hw_4w_tx_ctl *tx_ctl;
3865 struct ath5k_hw_tx_status *tx_status; 3856 struct ath5k_hw_tx_status *tx_status;
3866 struct ath5k_hw_4w_tx_desc *tx_desc;
3867 3857
3868 ATH5K_TRACE(ah->ah_sc); 3858 ATH5K_TRACE(ah->ah_sc);
3869 tx_desc = (struct ath5k_hw_4w_tx_desc *)&desc->ds_ctl0; 3859
3870 tx_status = (struct ath5k_hw_tx_status *)&desc->ds_hw[2]; 3860 tx_ctl = &desc->ud.ds_tx5212.tx_ctl;
3861 tx_status = &desc->ud.ds_tx5212.tx_stat;
3871 3862
3872 /* No frame has been send or error */ 3863 /* No frame has been send or error */
3873 if (unlikely((tx_status->tx_status_1 & AR5K_DESC_TX_STATUS1_DONE) == 0)) 3864 if (unlikely((tx_status->tx_status_1 & AR5K_DESC_TX_STATUS1_DONE) == 0))
@@ -3893,25 +3884,25 @@ static int ath5k_hw_proc_4word_tx_status(struct ath5k_hw *ah,
3893 switch (AR5K_REG_MS(tx_status->tx_status_1, 3884 switch (AR5K_REG_MS(tx_status->tx_status_1,
3894 AR5K_DESC_TX_STATUS1_FINAL_TS_INDEX)) { 3885 AR5K_DESC_TX_STATUS1_FINAL_TS_INDEX)) {
3895 case 0: 3886 case 0:
3896 desc->ds_us.tx.ts_rate = tx_desc->tx_control_3 & 3887 desc->ds_us.tx.ts_rate = tx_ctl->tx_control_3 &
3897 AR5K_4W_TX_DESC_CTL3_XMIT_RATE0; 3888 AR5K_4W_TX_DESC_CTL3_XMIT_RATE0;
3898 break; 3889 break;
3899 case 1: 3890 case 1:
3900 desc->ds_us.tx.ts_rate = AR5K_REG_MS(tx_desc->tx_control_3, 3891 desc->ds_us.tx.ts_rate = AR5K_REG_MS(tx_ctl->tx_control_3,
3901 AR5K_4W_TX_DESC_CTL3_XMIT_RATE1); 3892 AR5K_4W_TX_DESC_CTL3_XMIT_RATE1);
3902 desc->ds_us.tx.ts_longretry +=AR5K_REG_MS(tx_desc->tx_control_2, 3893 desc->ds_us.tx.ts_longretry += AR5K_REG_MS(tx_ctl->tx_control_2,
3903 AR5K_4W_TX_DESC_CTL2_XMIT_TRIES1); 3894 AR5K_4W_TX_DESC_CTL2_XMIT_TRIES1);
3904 break; 3895 break;
3905 case 2: 3896 case 2:
3906 desc->ds_us.tx.ts_rate = AR5K_REG_MS(tx_desc->tx_control_3, 3897 desc->ds_us.tx.ts_rate = AR5K_REG_MS(tx_ctl->tx_control_3,
3907 AR5K_4W_TX_DESC_CTL3_XMIT_RATE2); 3898 AR5K_4W_TX_DESC_CTL3_XMIT_RATE2);
3908 desc->ds_us.tx.ts_longretry +=AR5K_REG_MS(tx_desc->tx_control_2, 3899 desc->ds_us.tx.ts_longretry += AR5K_REG_MS(tx_ctl->tx_control_2,
3909 AR5K_4W_TX_DESC_CTL2_XMIT_TRIES2); 3900 AR5K_4W_TX_DESC_CTL2_XMIT_TRIES2);
3910 break; 3901 break;
3911 case 3: 3902 case 3:
3912 desc->ds_us.tx.ts_rate = AR5K_REG_MS(tx_desc->tx_control_3, 3903 desc->ds_us.tx.ts_rate = AR5K_REG_MS(tx_ctl->tx_control_3,
3913 AR5K_4W_TX_DESC_CTL3_XMIT_RATE3); 3904 AR5K_4W_TX_DESC_CTL3_XMIT_RATE3);
3914 desc->ds_us.tx.ts_longretry +=AR5K_REG_MS(tx_desc->tx_control_2, 3905 desc->ds_us.tx.ts_longretry += AR5K_REG_MS(tx_ctl->tx_control_2,
3915 AR5K_4W_TX_DESC_CTL2_XMIT_TRIES3); 3906 AR5K_4W_TX_DESC_CTL2_XMIT_TRIES3);
3916 break; 3907 break;
3917 } 3908 }
@@ -3941,31 +3932,27 @@ static int ath5k_hw_proc_4word_tx_status(struct ath5k_hw *ah,
3941int ath5k_hw_setup_rx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc, 3932int ath5k_hw_setup_rx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc,
3942 u32 size, unsigned int flags) 3933 u32 size, unsigned int flags)
3943{ 3934{
3944 struct ath5k_rx_desc *rx_desc; 3935 struct ath5k_hw_rx_ctl *rx_ctl;
3945 3936
3946 ATH5K_TRACE(ah->ah_sc); 3937 ATH5K_TRACE(ah->ah_sc);
3947 rx_desc = (struct ath5k_rx_desc *)&desc->ds_ctl0; 3938 rx_ctl = &desc->ud.ds_rx.rx_ctl;
3948 3939
3949 /* 3940 /*
3950 *Clear ds_hw 3941 * Clear the descriptor
3951 * If we don't clean the status descriptor, 3942 * If we don't clean the status descriptor,
3952 * while scanning we get too many results, 3943 * while scanning we get too many results,
3953 * most of them virtual, after some secs 3944 * most of them virtual, after some secs
3954 * of scanning system hangs. M.F. 3945 * of scanning system hangs. M.F.
3955 */ 3946 */
3956 memset(desc->ds_hw, 0, sizeof(desc->ds_hw)); 3947 memset(&desc->ud.ds_rx, 0, sizeof(struct ath5k_hw_all_rx_desc));
3957
3958 /*Initialize rx descriptor*/
3959 rx_desc->rx_control_0 = 0;
3960 rx_desc->rx_control_1 = 0;
3961 3948
3962 /* Setup descriptor */ 3949 /* Setup descriptor */
3963 rx_desc->rx_control_1 = size & AR5K_DESC_RX_CTL1_BUF_LEN; 3950 rx_ctl->rx_control_1 = size & AR5K_DESC_RX_CTL1_BUF_LEN;
3964 if (unlikely(rx_desc->rx_control_1 != size)) 3951 if (unlikely(rx_ctl->rx_control_1 != size))
3965 return -EINVAL; 3952 return -EINVAL;
3966 3953
3967 if (flags & AR5K_RXDESC_INTREQ) 3954 if (flags & AR5K_RXDESC_INTREQ)
3968 rx_desc->rx_control_1 |= AR5K_DESC_RX_CTL1_INTREQ; 3955 rx_ctl->rx_control_1 |= AR5K_DESC_RX_CTL1_INTREQ;
3969 3956
3970 return 0; 3957 return 0;
3971} 3958}
@@ -3973,15 +3960,15 @@ int ath5k_hw_setup_rx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc,
3973/* 3960/*
3974 * Proccess the rx status descriptor on 5210/5211 3961 * Proccess the rx status descriptor on 5210/5211
3975 */ 3962 */
3976static int ath5k_hw_proc_old_rx_status(struct ath5k_hw *ah, 3963static int ath5k_hw_proc_5210_rx_status(struct ath5k_hw *ah,
3977 struct ath5k_desc *desc) 3964 struct ath5k_desc *desc)
3978{ 3965{
3979 struct ath5k_hw_old_rx_status *rx_status; 3966 struct ath5k_hw_rx_status *rx_status;
3980 3967
3981 rx_status = (struct ath5k_hw_old_rx_status *)&desc->ds_hw[0]; 3968 rx_status = &desc->ud.ds_rx.u.rx_stat;
3982 3969
3983 /* No frame received / not ready */ 3970 /* No frame received / not ready */
3984 if (unlikely((rx_status->rx_status_1 & AR5K_OLD_RX_DESC_STATUS1_DONE) 3971 if (unlikely((rx_status->rx_status_1 & AR5K_5210_RX_DESC_STATUS1_DONE)
3985 == 0)) 3972 == 0))
3986 return -EINPROGRESS; 3973 return -EINPROGRESS;
3987 3974
@@ -3989,50 +3976,51 @@ static int ath5k_hw_proc_old_rx_status(struct ath5k_hw *ah,
3989 * Frame receive status 3976 * Frame receive status
3990 */ 3977 */
3991 desc->ds_us.rx.rs_datalen = rx_status->rx_status_0 & 3978 desc->ds_us.rx.rs_datalen = rx_status->rx_status_0 &
3992 AR5K_OLD_RX_DESC_STATUS0_DATA_LEN; 3979 AR5K_5210_RX_DESC_STATUS0_DATA_LEN;
3993 desc->ds_us.rx.rs_rssi = AR5K_REG_MS(rx_status->rx_status_0, 3980 desc->ds_us.rx.rs_rssi = AR5K_REG_MS(rx_status->rx_status_0,
3994 AR5K_OLD_RX_DESC_STATUS0_RECEIVE_SIGNAL); 3981 AR5K_5210_RX_DESC_STATUS0_RECEIVE_SIGNAL);
3995 desc->ds_us.rx.rs_rate = AR5K_REG_MS(rx_status->rx_status_0, 3982 desc->ds_us.rx.rs_rate = AR5K_REG_MS(rx_status->rx_status_0,
3996 AR5K_OLD_RX_DESC_STATUS0_RECEIVE_RATE); 3983 AR5K_5210_RX_DESC_STATUS0_RECEIVE_RATE);
3997 desc->ds_us.rx.rs_antenna = rx_status->rx_status_0 & 3984 desc->ds_us.rx.rs_antenna = rx_status->rx_status_0 &
3998 AR5K_OLD_RX_DESC_STATUS0_RECEIVE_ANTENNA; 3985 AR5K_5210_RX_DESC_STATUS0_RECEIVE_ANTENNA;
3999 desc->ds_us.rx.rs_more = rx_status->rx_status_0 & 3986 desc->ds_us.rx.rs_more = rx_status->rx_status_0 &
4000 AR5K_OLD_RX_DESC_STATUS0_MORE; 3987 AR5K_5210_RX_DESC_STATUS0_MORE;
4001 desc->ds_us.rx.rs_tstamp = AR5K_REG_MS(rx_status->rx_status_1, 3988 desc->ds_us.rx.rs_tstamp = AR5K_REG_MS(rx_status->rx_status_1,
4002 AR5K_OLD_RX_DESC_STATUS1_RECEIVE_TIMESTAMP); 3989 AR5K_5210_RX_DESC_STATUS1_RECEIVE_TIMESTAMP);
4003 desc->ds_us.rx.rs_status = 0; 3990 desc->ds_us.rx.rs_status = 0;
4004 3991
4005 /* 3992 /*
4006 * Key table status 3993 * Key table status
4007 */ 3994 */
4008 if (rx_status->rx_status_1 & AR5K_OLD_RX_DESC_STATUS1_KEY_INDEX_VALID) 3995 if (rx_status->rx_status_1 & AR5K_5210_RX_DESC_STATUS1_KEY_INDEX_VALID)
4009 desc->ds_us.rx.rs_keyix = AR5K_REG_MS(rx_status->rx_status_1, 3996 desc->ds_us.rx.rs_keyix = AR5K_REG_MS(rx_status->rx_status_1,
4010 AR5K_OLD_RX_DESC_STATUS1_KEY_INDEX); 3997 AR5K_5210_RX_DESC_STATUS1_KEY_INDEX);
4011 else 3998 else
4012 desc->ds_us.rx.rs_keyix = AR5K_RXKEYIX_INVALID; 3999 desc->ds_us.rx.rs_keyix = AR5K_RXKEYIX_INVALID;
4013 4000
4014 /* 4001 /*
4015 * Receive/descriptor errors 4002 * Receive/descriptor errors
4016 */ 4003 */
4017 if ((rx_status->rx_status_1 & AR5K_OLD_RX_DESC_STATUS1_FRAME_RECEIVE_OK) 4004 if ((rx_status->rx_status_1 &
4018 == 0) { 4005 AR5K_5210_RX_DESC_STATUS1_FRAME_RECEIVE_OK) == 0) {
4019 if (rx_status->rx_status_1 & AR5K_OLD_RX_DESC_STATUS1_CRC_ERROR) 4006 if (rx_status->rx_status_1 &
4007 AR5K_5210_RX_DESC_STATUS1_CRC_ERROR)
4020 desc->ds_us.rx.rs_status |= AR5K_RXERR_CRC; 4008 desc->ds_us.rx.rs_status |= AR5K_RXERR_CRC;
4021 4009
4022 if (rx_status->rx_status_1 & 4010 if (rx_status->rx_status_1 &
4023 AR5K_OLD_RX_DESC_STATUS1_FIFO_OVERRUN) 4011 AR5K_5210_RX_DESC_STATUS1_FIFO_OVERRUN)
4024 desc->ds_us.rx.rs_status |= AR5K_RXERR_FIFO; 4012 desc->ds_us.rx.rs_status |= AR5K_RXERR_FIFO;
4025 4013
4026 if (rx_status->rx_status_1 & 4014 if (rx_status->rx_status_1 &
4027 AR5K_OLD_RX_DESC_STATUS1_PHY_ERROR) { 4015 AR5K_5210_RX_DESC_STATUS1_PHY_ERROR) {
4028 desc->ds_us.rx.rs_status |= AR5K_RXERR_PHY; 4016 desc->ds_us.rx.rs_status |= AR5K_RXERR_PHY;
4029 desc->ds_us.rx.rs_phyerr = 4017 desc->ds_us.rx.rs_phyerr =
4030 AR5K_REG_MS(rx_status->rx_status_1, 4018 AR5K_REG_MS(rx_status->rx_status_1,
4031 AR5K_OLD_RX_DESC_STATUS1_PHY_ERROR); 4019 AR5K_5210_RX_DESC_STATUS1_PHY_ERROR);
4032 } 4020 }
4033 4021
4034 if (rx_status->rx_status_1 & 4022 if (rx_status->rx_status_1 &
4035 AR5K_OLD_RX_DESC_STATUS1_DECRYPT_CRC_ERROR) 4023 AR5K_5210_RX_DESC_STATUS1_DECRYPT_CRC_ERROR)
4036 desc->ds_us.rx.rs_status |= AR5K_RXERR_DECRYPT; 4024 desc->ds_us.rx.rs_status |= AR5K_RXERR_DECRYPT;
4037 } 4025 }
4038 4026
@@ -4042,20 +4030,20 @@ static int ath5k_hw_proc_old_rx_status(struct ath5k_hw *ah,
4042/* 4030/*
4043 * Proccess the rx status descriptor on 5212 4031 * Proccess the rx status descriptor on 5212
4044 */ 4032 */
4045static int ath5k_hw_proc_new_rx_status(struct ath5k_hw *ah, 4033static int ath5k_hw_proc_5212_rx_status(struct ath5k_hw *ah,
4046 struct ath5k_desc *desc) 4034 struct ath5k_desc *desc)
4047{ 4035{
4048 struct ath5k_hw_new_rx_status *rx_status; 4036 struct ath5k_hw_rx_status *rx_status;
4049 struct ath5k_hw_rx_error *rx_err; 4037 struct ath5k_hw_rx_error *rx_err;
4050 4038
4051 ATH5K_TRACE(ah->ah_sc); 4039 ATH5K_TRACE(ah->ah_sc);
4052 rx_status = (struct ath5k_hw_new_rx_status *)&desc->ds_hw[0]; 4040 rx_status = &desc->ud.ds_rx.u.rx_stat;
4053 4041
4054 /* Overlay on error */ 4042 /* Overlay on error */
4055 rx_err = (struct ath5k_hw_rx_error *)&desc->ds_hw[0]; 4043 rx_err = &desc->ud.ds_rx.u.rx_err;
4056 4044
4057 /* No frame received / not ready */ 4045 /* No frame received / not ready */
4058 if (unlikely((rx_status->rx_status_1 & AR5K_NEW_RX_DESC_STATUS1_DONE) 4046 if (unlikely((rx_status->rx_status_1 & AR5K_5212_RX_DESC_STATUS1_DONE)
4059 == 0)) 4047 == 0))
4060 return -EINPROGRESS; 4048 return -EINPROGRESS;
4061 4049
@@ -4063,25 +4051,25 @@ static int ath5k_hw_proc_new_rx_status(struct ath5k_hw *ah,
4063 * Frame receive status 4051 * Frame receive status
4064 */ 4052 */
4065 desc->ds_us.rx.rs_datalen = rx_status->rx_status_0 & 4053 desc->ds_us.rx.rs_datalen = rx_status->rx_status_0 &
4066 AR5K_NEW_RX_DESC_STATUS0_DATA_LEN; 4054 AR5K_5212_RX_DESC_STATUS0_DATA_LEN;
4067 desc->ds_us.rx.rs_rssi = AR5K_REG_MS(rx_status->rx_status_0, 4055 desc->ds_us.rx.rs_rssi = AR5K_REG_MS(rx_status->rx_status_0,
4068 AR5K_NEW_RX_DESC_STATUS0_RECEIVE_SIGNAL); 4056 AR5K_5212_RX_DESC_STATUS0_RECEIVE_SIGNAL);
4069 desc->ds_us.rx.rs_rate = AR5K_REG_MS(rx_status->rx_status_0, 4057 desc->ds_us.rx.rs_rate = AR5K_REG_MS(rx_status->rx_status_0,
4070 AR5K_NEW_RX_DESC_STATUS0_RECEIVE_RATE); 4058 AR5K_5212_RX_DESC_STATUS0_RECEIVE_RATE);
4071 desc->ds_us.rx.rs_antenna = rx_status->rx_status_0 & 4059 desc->ds_us.rx.rs_antenna = rx_status->rx_status_0 &
4072 AR5K_NEW_RX_DESC_STATUS0_RECEIVE_ANTENNA; 4060 AR5K_5212_RX_DESC_STATUS0_RECEIVE_ANTENNA;
4073 desc->ds_us.rx.rs_more = rx_status->rx_status_0 & 4061 desc->ds_us.rx.rs_more = rx_status->rx_status_0 &
4074 AR5K_NEW_RX_DESC_STATUS0_MORE; 4062 AR5K_5212_RX_DESC_STATUS0_MORE;
4075 desc->ds_us.rx.rs_tstamp = AR5K_REG_MS(rx_status->rx_status_1, 4063 desc->ds_us.rx.rs_tstamp = AR5K_REG_MS(rx_status->rx_status_1,
4076 AR5K_NEW_RX_DESC_STATUS1_RECEIVE_TIMESTAMP); 4064 AR5K_5212_RX_DESC_STATUS1_RECEIVE_TIMESTAMP);
4077 desc->ds_us.rx.rs_status = 0; 4065 desc->ds_us.rx.rs_status = 0;
4078 4066
4079 /* 4067 /*
4080 * Key table status 4068 * Key table status
4081 */ 4069 */
4082 if (rx_status->rx_status_1 & AR5K_NEW_RX_DESC_STATUS1_KEY_INDEX_VALID) 4070 if (rx_status->rx_status_1 & AR5K_5212_RX_DESC_STATUS1_KEY_INDEX_VALID)
4083 desc->ds_us.rx.rs_keyix = AR5K_REG_MS(rx_status->rx_status_1, 4071 desc->ds_us.rx.rs_keyix = AR5K_REG_MS(rx_status->rx_status_1,
4084 AR5K_NEW_RX_DESC_STATUS1_KEY_INDEX); 4072 AR5K_5212_RX_DESC_STATUS1_KEY_INDEX);
4085 else 4073 else
4086 desc->ds_us.rx.rs_keyix = AR5K_RXKEYIX_INVALID; 4074 desc->ds_us.rx.rs_keyix = AR5K_RXKEYIX_INVALID;
4087 4075
@@ -4089,12 +4077,13 @@ static int ath5k_hw_proc_new_rx_status(struct ath5k_hw *ah,
4089 * Receive/descriptor errors 4077 * Receive/descriptor errors
4090 */ 4078 */
4091 if ((rx_status->rx_status_1 & 4079 if ((rx_status->rx_status_1 &
4092 AR5K_NEW_RX_DESC_STATUS1_FRAME_RECEIVE_OK) == 0) { 4080 AR5K_5212_RX_DESC_STATUS1_FRAME_RECEIVE_OK) == 0) {
4093 if (rx_status->rx_status_1 & AR5K_NEW_RX_DESC_STATUS1_CRC_ERROR) 4081 if (rx_status->rx_status_1 &
4082 AR5K_5212_RX_DESC_STATUS1_CRC_ERROR)
4094 desc->ds_us.rx.rs_status |= AR5K_RXERR_CRC; 4083 desc->ds_us.rx.rs_status |= AR5K_RXERR_CRC;
4095 4084
4096 if (rx_status->rx_status_1 & 4085 if (rx_status->rx_status_1 &
4097 AR5K_NEW_RX_DESC_STATUS1_PHY_ERROR) { 4086 AR5K_5212_RX_DESC_STATUS1_PHY_ERROR) {
4098 desc->ds_us.rx.rs_status |= AR5K_RXERR_PHY; 4087 desc->ds_us.rx.rs_status |= AR5K_RXERR_PHY;
4099 desc->ds_us.rx.rs_phyerr = 4088 desc->ds_us.rx.rs_phyerr =
4100 AR5K_REG_MS(rx_err->rx_error_1, 4089 AR5K_REG_MS(rx_err->rx_error_1,
@@ -4102,10 +4091,11 @@ static int ath5k_hw_proc_new_rx_status(struct ath5k_hw *ah,
4102 } 4091 }
4103 4092
4104 if (rx_status->rx_status_1 & 4093 if (rx_status->rx_status_1 &
4105 AR5K_NEW_RX_DESC_STATUS1_DECRYPT_CRC_ERROR) 4094 AR5K_5212_RX_DESC_STATUS1_DECRYPT_CRC_ERROR)
4106 desc->ds_us.rx.rs_status |= AR5K_RXERR_DECRYPT; 4095 desc->ds_us.rx.rs_status |= AR5K_RXERR_DECRYPT;
4107 4096
4108 if (rx_status->rx_status_1 & AR5K_NEW_RX_DESC_STATUS1_MIC_ERROR) 4097 if (rx_status->rx_status_1 &
4098 AR5K_5212_RX_DESC_STATUS1_MIC_ERROR)
4109 desc->ds_us.rx.rs_status |= AR5K_RXERR_MIC; 4099 desc->ds_us.rx.rs_status |= AR5K_RXERR_MIC;
4110 } 4100 }
4111 4101
diff --git a/drivers/net/wireless/ath5k/hw.h b/drivers/net/wireless/ath5k/hw.h
index d9a7c0973f53..64fca8dcb386 100644
--- a/drivers/net/wireless/ath5k/hw.h
+++ b/drivers/net/wireless/ath5k/hw.h
@@ -173,7 +173,10 @@ struct ath5k_eeprom_info {
173 * (rX: reserved fields possibily used by future versions of the ar5k chipset) 173 * (rX: reserved fields possibily used by future versions of the ar5k chipset)
174 */ 174 */
175 175
176struct ath5k_rx_desc { 176/*
177 * common hardware RX control descriptor
178 */
179struct ath5k_hw_rx_ctl {
177 u32 rx_control_0; /* RX control word 0 */ 180 u32 rx_control_0; /* RX control word 0 */
178 181
179#define AR5K_DESC_RX_CTL0 0x00000000 182#define AR5K_DESC_RX_CTL0 0x00000000
@@ -185,69 +188,63 @@ struct ath5k_rx_desc {
185} __packed; 188} __packed;
186 189
187/* 190/*
188 * 5210/5211 rx status descriptor 191 * common hardware RX status descriptor
192 * 5210/11 and 5212 differ only in the flags defined below
189 */ 193 */
190struct ath5k_hw_old_rx_status { 194struct ath5k_hw_rx_status {
191 u32 rx_status_0; /* RX status word 0 */ 195 u32 rx_status_0; /* RX status word 0 */
192
193#define AR5K_OLD_RX_DESC_STATUS0_DATA_LEN 0x00000fff
194#define AR5K_OLD_RX_DESC_STATUS0_MORE 0x00001000
195#define AR5K_OLD_RX_DESC_STATUS0_RECEIVE_RATE 0x00078000
196#define AR5K_OLD_RX_DESC_STATUS0_RECEIVE_RATE_S 15
197#define AR5K_OLD_RX_DESC_STATUS0_RECEIVE_SIGNAL 0x07f80000
198#define AR5K_OLD_RX_DESC_STATUS0_RECEIVE_SIGNAL_S 19
199#define AR5K_OLD_RX_DESC_STATUS0_RECEIVE_ANTENNA 0x38000000
200#define AR5K_OLD_RX_DESC_STATUS0_RECEIVE_ANTENNA_S 27
201
202 u32 rx_status_1; /* RX status word 1 */ 196 u32 rx_status_1; /* RX status word 1 */
203
204#define AR5K_OLD_RX_DESC_STATUS1_DONE 0x00000001
205#define AR5K_OLD_RX_DESC_STATUS1_FRAME_RECEIVE_OK 0x00000002
206#define AR5K_OLD_RX_DESC_STATUS1_CRC_ERROR 0x00000004
207#define AR5K_OLD_RX_DESC_STATUS1_FIFO_OVERRUN 0x00000008
208#define AR5K_OLD_RX_DESC_STATUS1_DECRYPT_CRC_ERROR 0x00000010
209#define AR5K_OLD_RX_DESC_STATUS1_PHY_ERROR 0x000000e0
210#define AR5K_OLD_RX_DESC_STATUS1_PHY_ERROR_S 5
211#define AR5K_OLD_RX_DESC_STATUS1_KEY_INDEX_VALID 0x00000100
212#define AR5K_OLD_RX_DESC_STATUS1_KEY_INDEX 0x00007e00
213#define AR5K_OLD_RX_DESC_STATUS1_KEY_INDEX_S 9
214#define AR5K_OLD_RX_DESC_STATUS1_RECEIVE_TIMESTAMP 0x0fff8000
215#define AR5K_OLD_RX_DESC_STATUS1_RECEIVE_TIMESTAMP_S 15
216#define AR5K_OLD_RX_DESC_STATUS1_KEY_CACHE_MISS 0x10000000
217} __packed; 197} __packed;
218 198
199/* 5210/5211 */
200#define AR5K_5210_RX_DESC_STATUS0_DATA_LEN 0x00000fff
201#define AR5K_5210_RX_DESC_STATUS0_MORE 0x00001000
202#define AR5K_5210_RX_DESC_STATUS0_RECEIVE_RATE 0x00078000
203#define AR5K_5210_RX_DESC_STATUS0_RECEIVE_RATE_S 15
204#define AR5K_5210_RX_DESC_STATUS0_RECEIVE_SIGNAL 0x07f80000
205#define AR5K_5210_RX_DESC_STATUS0_RECEIVE_SIGNAL_S 19
206#define AR5K_5210_RX_DESC_STATUS0_RECEIVE_ANTENNA 0x38000000
207#define AR5K_5210_RX_DESC_STATUS0_RECEIVE_ANTENNA_S 27
208#define AR5K_5210_RX_DESC_STATUS1_DONE 0x00000001
209#define AR5K_5210_RX_DESC_STATUS1_FRAME_RECEIVE_OK 0x00000002
210#define AR5K_5210_RX_DESC_STATUS1_CRC_ERROR 0x00000004
211#define AR5K_5210_RX_DESC_STATUS1_FIFO_OVERRUN 0x00000008
212#define AR5K_5210_RX_DESC_STATUS1_DECRYPT_CRC_ERROR 0x00000010
213#define AR5K_5210_RX_DESC_STATUS1_PHY_ERROR 0x000000e0
214#define AR5K_5210_RX_DESC_STATUS1_PHY_ERROR_S 5
215#define AR5K_5210_RX_DESC_STATUS1_KEY_INDEX_VALID 0x00000100
216#define AR5K_5210_RX_DESC_STATUS1_KEY_INDEX 0x00007e00
217#define AR5K_5210_RX_DESC_STATUS1_KEY_INDEX_S 9
218#define AR5K_5210_RX_DESC_STATUS1_RECEIVE_TIMESTAMP 0x0fff8000
219#define AR5K_5210_RX_DESC_STATUS1_RECEIVE_TIMESTAMP_S 15
220#define AR5K_5210_RX_DESC_STATUS1_KEY_CACHE_MISS 0x10000000
221
222/* 5212 */
223#define AR5K_5212_RX_DESC_STATUS0_DATA_LEN 0x00000fff
224#define AR5K_5212_RX_DESC_STATUS0_MORE 0x00001000
225#define AR5K_5212_RX_DESC_STATUS0_DECOMP_CRC_ERROR 0x00002000
226#define AR5K_5212_RX_DESC_STATUS0_RECEIVE_RATE 0x000f8000
227#define AR5K_5212_RX_DESC_STATUS0_RECEIVE_RATE_S 15
228#define AR5K_5212_RX_DESC_STATUS0_RECEIVE_SIGNAL 0x0ff00000
229#define AR5K_5212_RX_DESC_STATUS0_RECEIVE_SIGNAL_S 20
230#define AR5K_5212_RX_DESC_STATUS0_RECEIVE_ANTENNA 0xf0000000
231#define AR5K_5212_RX_DESC_STATUS0_RECEIVE_ANTENNA_S 28
232#define AR5K_5212_RX_DESC_STATUS1_DONE 0x00000001
233#define AR5K_5212_RX_DESC_STATUS1_FRAME_RECEIVE_OK 0x00000002
234#define AR5K_5212_RX_DESC_STATUS1_CRC_ERROR 0x00000004
235#define AR5K_5212_RX_DESC_STATUS1_DECRYPT_CRC_ERROR 0x00000008
236#define AR5K_5212_RX_DESC_STATUS1_PHY_ERROR 0x00000010
237#define AR5K_5212_RX_DESC_STATUS1_MIC_ERROR 0x00000020
238#define AR5K_5212_RX_DESC_STATUS1_KEY_INDEX_VALID 0x00000100
239#define AR5K_5212_RX_DESC_STATUS1_KEY_INDEX 0x0000fe00
240#define AR5K_5212_RX_DESC_STATUS1_KEY_INDEX_S 9
241#define AR5K_5212_RX_DESC_STATUS1_RECEIVE_TIMESTAMP 0x7fff0000
242#define AR5K_5212_RX_DESC_STATUS1_RECEIVE_TIMESTAMP_S 16
243#define AR5K_5212_RX_DESC_STATUS1_KEY_CACHE_MISS 0x80000000
244
219/* 245/*
220 * 5212 rx status descriptor 246 * common hardware RX error descriptor
221 */ 247 */
222struct ath5k_hw_new_rx_status {
223 u32 rx_status_0; /* RX status word 0 */
224
225#define AR5K_NEW_RX_DESC_STATUS0_DATA_LEN 0x00000fff
226#define AR5K_NEW_RX_DESC_STATUS0_MORE 0x00001000
227#define AR5K_NEW_RX_DESC_STATUS0_DECOMP_CRC_ERROR 0x00002000
228#define AR5K_NEW_RX_DESC_STATUS0_RECEIVE_RATE 0x000f8000
229#define AR5K_NEW_RX_DESC_STATUS0_RECEIVE_RATE_S 15
230#define AR5K_NEW_RX_DESC_STATUS0_RECEIVE_SIGNAL 0x0ff00000
231#define AR5K_NEW_RX_DESC_STATUS0_RECEIVE_SIGNAL_S 20
232#define AR5K_NEW_RX_DESC_STATUS0_RECEIVE_ANTENNA 0xf0000000
233#define AR5K_NEW_RX_DESC_STATUS0_RECEIVE_ANTENNA_S 28
234
235 u32 rx_status_1; /* RX status word 1 */
236
237#define AR5K_NEW_RX_DESC_STATUS1_DONE 0x00000001
238#define AR5K_NEW_RX_DESC_STATUS1_FRAME_RECEIVE_OK 0x00000002
239#define AR5K_NEW_RX_DESC_STATUS1_CRC_ERROR 0x00000004
240#define AR5K_NEW_RX_DESC_STATUS1_DECRYPT_CRC_ERROR 0x00000008
241#define AR5K_NEW_RX_DESC_STATUS1_PHY_ERROR 0x00000010
242#define AR5K_NEW_RX_DESC_STATUS1_MIC_ERROR 0x00000020
243#define AR5K_NEW_RX_DESC_STATUS1_KEY_INDEX_VALID 0x00000100
244#define AR5K_NEW_RX_DESC_STATUS1_KEY_INDEX 0x0000fe00
245#define AR5K_NEW_RX_DESC_STATUS1_KEY_INDEX_S 9
246#define AR5K_NEW_RX_DESC_STATUS1_RECEIVE_TIMESTAMP 0x7fff0000
247#define AR5K_NEW_RX_DESC_STATUS1_RECEIVE_TIMESTAMP_S 16
248#define AR5K_NEW_RX_DESC_STATUS1_KEY_CACHE_MISS 0x80000000
249} __packed;
250
251struct ath5k_hw_rx_error { 248struct ath5k_hw_rx_error {
252 u32 rx_error_0; /* RX error word 0 */ 249 u32 rx_error_0; /* RX error word 0 */
253 250
@@ -268,7 +265,10 @@ struct ath5k_hw_rx_error {
268#define AR5K_DESC_RX_PHY_ERROR_SERVICE 0xc0 265#define AR5K_DESC_RX_PHY_ERROR_SERVICE 0xc0
269#define AR5K_DESC_RX_PHY_ERROR_TRANSMITOVR 0xe0 266#define AR5K_DESC_RX_PHY_ERROR_TRANSMITOVR 0xe0
270 267
271struct ath5k_hw_2w_tx_desc { 268/*
269 * 5210/5211 hardware 2-word TX control descriptor
270 */
271struct ath5k_hw_2w_tx_ctl {
272 u32 tx_control_0; /* TX control word 0 */ 272 u32 tx_control_0; /* TX control word 0 */
273 273
274#define AR5K_2W_TX_DESC_CTL0_FRAME_LEN 0x00000fff 274#define AR5K_2W_TX_DESC_CTL0_FRAME_LEN 0x00000fff
@@ -314,9 +314,9 @@ struct ath5k_hw_2w_tx_desc {
314#define AR5K_AR5210_TX_DESC_FRAME_TYPE_PIFS 0x10 314#define AR5K_AR5210_TX_DESC_FRAME_TYPE_PIFS 0x10
315 315
316/* 316/*
317 * 5212 4-word tx control descriptor 317 * 5212 hardware 4-word TX control descriptor
318 */ 318 */
319struct ath5k_hw_4w_tx_desc { 319struct ath5k_hw_4w_tx_ctl {
320 u32 tx_control_0; /* TX control word 0 */ 320 u32 tx_control_0; /* TX control word 0 */
321 321
322#define AR5K_4W_TX_DESC_CTL0_FRAME_LEN 0x00000fff 322#define AR5K_4W_TX_DESC_CTL0_FRAME_LEN 0x00000fff
@@ -374,7 +374,7 @@ struct ath5k_hw_4w_tx_desc {
374} __packed; 374} __packed;
375 375
376/* 376/*
377 * Common tx status descriptor 377 * Common TX status descriptor
378 */ 378 */
379struct ath5k_hw_tx_status { 379struct ath5k_hw_tx_status {
380 u32 tx_status_0; /* TX status word 0 */ 380 u32 tx_status_0; /* TX status word 0 */
@@ -415,6 +415,34 @@ struct ath5k_hw_tx_status {
415 415
416 416
417/* 417/*
418 * 5210/5211 hardware TX descriptor
419 */
420struct ath5k_hw_5210_tx_desc {
421 struct ath5k_hw_2w_tx_ctl tx_ctl;
422 struct ath5k_hw_tx_status tx_stat;
423} __packed;
424
425/*
426 * 5212 hardware TX descriptor
427 */
428struct ath5k_hw_5212_tx_desc {
429 struct ath5k_hw_4w_tx_ctl tx_ctl;
430 struct ath5k_hw_tx_status tx_stat;
431} __packed;
432
433/*
434 * common hardware RX descriptor
435 */
436struct ath5k_hw_all_rx_desc {
437 struct ath5k_hw_rx_ctl rx_ctl;
438 union {
439 struct ath5k_hw_rx_status rx_stat;
440 struct ath5k_hw_rx_error rx_err;
441 } u;
442} __packed;
443
444
445/*
418 * AR5K REGISTER ACCESS 446 * AR5K REGISTER ACCESS
419 */ 447 */
420 448