rt2x00: Fix RFKILL polling
PATCH 1/7 rt2x00: Fix RFKILL polling
The rfkill_poll callback function in the drivers check a bit to see if the RFKILL key has been pressed. However when the bit is set it means the radio is active and the device can be used.
The wiphy_rfkill_set_hw_state() function expects the inversed, so '1' must be send when the radio must be disabled.
--- drivers/net/wireless/rt2x00/rt2x00mac.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/rt2x00/rt2x00mac.c +2 -2
@@ -704,8 +704,8 @@ EXPORT_SYMBOL_GPL(rt2x00mac_conf_tx);void rt2x00mac_rfkill_poll (struct ieee80211_hw *hw) {struct rt2x00_dev *rt2x00dev = hw->priv; -bool blocked = !!rt2x00dev->ops->lib->rfkill_poll (rt2x00dev); +bool active = !!rt2x00dev->ops->lib->rfkill_poll (rt2x00dev); -wiphy_rfkill_set_hw_state (hw->wiphy, blocked); +wiphy_rfkill_set_hw_state (hw->wiphy, !active); }EXPORT_SYMBOL_GPL (rt2x00mac_rfkill_poll);
Signature · 1 line
1.6.4
PATCH 2/7 rt2x00: Fix for rt2800usb for SHARED_KEY_TABLE initializations
Fixed comments about SHARED_KEY_TABLE_BASE and SHARED_KEY_MODE_BASE. Fixed initialization loop for SHARED_KEY_MODE_ENTRY.
Based on a patch for rt2800pci from Benoit.
--- drivers/net/wireless/rt2x00/rt2800usb.c | 8 ++++---- drivers/net/wireless/rt2x00/rt2800usb.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/wireless/rt2x00/rt2800usb.c +4 -4
@@ -1463,6 +1463,10 @@ static int rt2800usb_init_registers(struct rt2x00_dev *rt2x00dev)/* * ASIC will keep garbage value after boot, clear encryption keys. */ +for (i =0 ; i <4 ; i++) +rt2x00usb_register_write (rt2x00dev, +SHARED_KEY_MODE_ENTRY (i),0 ); +for (i =0 ; i <256 ; i++) {u32 wcid[2 ] = {0xffffffff ,0x00ffffff }; rt2x00usb_register_multiwrite(rt2x00dev, MAC_WCID_ENTRY(i),
@@ -1472,10 +1476,6 @@ static int rt2800usb_init_registers(struct rt2x00_dev *rt2x00dev)rt2x00usb_register_write (rt2x00dev,MAC_IVEIV_ENTRY (i),0 ); } -for (i =0 ; i <16 ; i++) -rt2x00usb_register_write (rt2x00dev, -SHARED_KEY_MODE_ENTRY (i),0 ); -/* * Clear all beacons * For the Beacon base registers we only need to clear
drivers/net/wireless/rt2x00/rt2800usb.h +2 -2
@@ -1300,8 +1300,8 @@* PAIRWISE_KEY_TABLE_BASE: 32-byte * 256 entry * MAC_IVEIV_TABLE_BASE: 8-byte * 256-entry * MAC_WCID_ATTRIBUTE_BASE: 4-byte * 256-entry -* SHARED_KEY_TABLE_BASE: 32-byte * 16-entry -* SHARED_KEY_MODE_BASE: 4-byte * 16-entry +* SHARED_KEY_TABLE_BASE: 32 bytes * 32-entry +* SHARED_KEY_MODE_BASE: 4 bits * 32-entry */ #define MAC_WCID_BASE 0x1800#define PAIRWISE_KEY_TABLE_BASE 0x4000
Signature · 1 line
1.6.4
PATCH 4/7 rt2x00: Set SKBDESC_L2_PADDED in RX path
In reply to a message not in the archiveWhen the RX descriptor indicates the frame was L2 padded, the SKBDESC_L2_PADDED flag should be set to make sure the L2 padding is removed before it is send to mac80211.
--- drivers/net/wireless/rt2x00/rt2800usb.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/net/wireless/rt2x00/rt2800usb.c +3 -1
@@ -2163,8 +2163,10 @@ static void rt2800usb_fill_rxdone(struct queue_entry *entry,if (rt2x00_get_field32 (rxd0,RXD_W0_MY_BSS )) rxdesc->dev_flags |=RXDONE_MY_BSS ; -if (rt2x00_get_field32 (rxd0,RXD_W0_L2PAD )) +if (rt2x00_get_field32 (rxd0,RXD_W0_L2PAD )) { rxdesc->dev_flags |=RXDONE_L2PAD ; + skbdesc->flags |=SKBDESC_L2_PADDED ; + }if (rt2x00_get_field32 (rxwi1,RXWI_W1_SHORT_GI )) rxdesc->flags |=RX_FLAG_SHORT_GI ;
Signature · 1 line
1.6.4
PATCH 3/7 rt2x00: Add new RF chip defines
In reply to Ivo van DoornAdd new defines for RF chipsets which can be found by the driver. We don't have to check for these chips specifically yet, but it is better to have the defines in now.
--- drivers/net/wireless/rt2x00/rt2800usb.h | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
drivers/net/wireless/rt2x00/rt2800usb.h +6 -0
@@ -36,6 +36,9 @@* RF2750 2.4G/5G 1T2R * RF3020 2.4G 1T1R * RF2020 2.4G B/G +* RF3021 2.4G 1T2R +* RF3022 2.4G 2T2R +* RF3052 2.4G 2T2R */ #define RF2820 0x0001#define RF2850 0x0002
@@ -43,6 +46,9 @@#define RF2750 0x0004#define RF3020 0x0005#define RF2020 0x0006 +#define RF3021 0x0007 +#define RF3022 0x0008 +#define RF3052 0x0009/* * RT2870 version
Signature · 1 line
1.6.4
PATCH 7/7 rt2x00: Add support for retry rates
In reply to Ivo van DoornFrom: Benoit PAPILLAULT <[email protected]>
rt2800pci can handle different retry rates,
it will always step 1 rate down after a failed
transmission so creating the retry rate list
for mac80211 is quite simple.
--- drivers/net/wireless/rt2x00/rt2x00dev.c | 22 +++++++++++++++++----- drivers/net/wireless/rt2x00/rt2x00queue.h | 2 ++ 2 files changed, 19 insertions(+), 5 deletions(-)
drivers/net/wireless/rt2x00/rt2x00dev.c +17 -5
@@ -220,7 +220,8 @@ void rt2x00lib_txdone(struct queue_entry *entry,struct skb_frame_desc *skbdesc =get_skb_frame_desc (entry->skb);enum data_queue_qid qid =skb_get_queue_mapping (entry->skb);unsigned int header_length =ieee80211_get_hdrlen_from_skb (entry->skb); -u8 rate_idx, rate_flags; +u8 rate_idx, rate_flags, retry_rates; +unsigned int i;/* * Unmap the skb.
@@ -259,16 +260,27 @@ void rt2x00lib_txdone(struct queue_entry *entry, rate_idx = skbdesc->tx_rate_idx; rate_flags = skbdesc->tx_rate_flags; + retry_rates =test_bit (TXDONE_FALLBACK , &txdesc->flags) ? + (txdesc->retry +1 ) :1 ;/* * Initialize TX status */ memset (&tx_info->status,0 ,sizeof (tx_info->status)); tx_info->status.ack_signal =0 ; - tx_info->status.rates[0 ].idx = rate_idx; - tx_info->status.rates[0 ].flags = rate_flags; - tx_info->status.rates[0 ].count = txdesc->retry +1 ; - tx_info->status.rates[1 ].idx =-1 ;/* terminate */ + +/* +* Frame was send with retries, hardware tried +* different rates to send out the frame, at each +* retry it lowered the rate 1 step. +*/ +for (i =0 ; i < retry_rates && i <IEEE80211_TX_MAX_RATES ; i++) { + tx_info->status.rates[i].idx = rate_idx - i; + tx_info->status.rates[i].flags = rate_flags; + tx_info->status.rates[i].count =1 ; + } +if (i < (IEEE80211_TX_MAX_RATES -1 )) + tx_info->status.rates[i].idx =-1 ;/* terminate */ if (!(tx_info->flags &IEEE80211_TX_CTL_NO_ACK )) { if (test_bit(TXDONE_SUCCESS, &txdesc->flags) ||
drivers/net/wireless/rt2x00/rt2x00queue.h +2 -0
@@ -214,6 +214,7 @@ struct rxdone_entry_desc {* * @TXDONE_UNKNOWN: Hardware could not determine success of transmission. * @TXDONE_SUCCESS: Frame was successfully send +* @TXDONE_FALLBACK: Frame was successfully send using a fallback rate. * @TXDONE_FAILURE: Frame was not successfully send * @TXDONE_EXCESSIVE_RETRY: In addition to &TXDONE_FAILURE, the * frame transmission failed due to excessive retries.
@@ -221,6 +222,7 @@ struct rxdone_entry_desc {enum txdone_entry_desc_flags {TXDONE_UNKNOWN ,TXDONE_SUCCESS , +TXDONE_FALLBACK ,TXDONE_FAILURE ,TXDONE_EXCESSIVE_RETRY , };
Signature · 1 line
1.6.4
PATCH 5/7 rt2x00: wireless CLI ID and packet ID must not be 0
In reply to Ivo van DoornIn the TX descriptor the Packet ID must not be 0, so add 1 to the ID. The wireless CLI ID is not allowed to be 0 either, but also must be initialized with the wcid value rather then keyid.
Based on a patch for rt2800pci from Benoit
--- drivers/net/wireless/rt2x00/rt2800usb.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/rt2x00/rt2800usb.c +2 -2
@@ -1995,11 +1995,11 @@ static void rt2800usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,rt2x00_set_field32 (&word,TXWI_W1_BW_WIN_SIZE , txdesc->ba_size);rt2x00_set_field32 (&word,TXWI_W1_WIRELESS_CLI_ID ,test_bit (ENTRY_TXD_ENCRYPT , &txdesc->flags) ? - txdesc->key_idx :0xff ); + (skbdesc->entry->entry_idx +1 ) :0xff );rt2x00_set_field32 (&word,TXWI_W1_MPDU_TOTAL_BYTE_COUNT , skb->len - txdesc->l2pad);rt2x00_set_field32 (&word,TXWI_W1_PACKETID , - skbdesc->entry->entry_idx); + skbdesc->entry->queue->qid +1 );rt2x00_desc_write (txwi,1 , word);/*
Signature · 1 line
1.6.4
PATCH 6/7 rt2x00: Fix MCS register intialization
According to the original Ralink driver, LG_FBK_CFG0_OFDMMCS2FBK should be initialized to 9 rather then 3.
Based on a patch for rt2800pci from Benoit
--- drivers/net/wireless/rt2x00/rt2800usb.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/wireless/rt2x00/rt2800usb.c +1 -1
@@ -1520,7 +1520,7 @@ static int rt2800usb_init_registers(struct rt2x00_dev *rt2x00dev)rt2x00usb_register_read (rt2x00dev,LG_FBK_CFG0 , ®);rt2x00_set_field32 (®,LG_FBK_CFG0_OFDMMCS0FBK ,8 );rt2x00_set_field32 (®,LG_FBK_CFG0_OFDMMCS1FBK ,8 ); -rt2x00_set_field32 (®,LG_FBK_CFG0_OFDMMCS2FBK ,3 ); +rt2x00_set_field32 (®,LG_FBK_CFG0_OFDMMCS2FBK ,9 );rt2x00_set_field32 (®,LG_FBK_CFG0_OFDMMCS3FBK ,10 );rt2x00_set_field32 (®,LG_FBK_CFG0_OFDMMCS4FBK ,11 );rt2x00_set_field32 (®,LG_FBK_CFG0_OFDMMCS5FBK ,12 );
Signature · 1 line
1.6.4
Re: [rt2x00-users] [PATCH 4/7] rt2x00: Set SKBDESC_L2_PADDED in RX path
In reply to Ivo van Doorn-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Review
Quoted 10 lines · Ivo van Doorn
When the RX descriptor indicates the frame was L2 padded, the
SKBDESC_L2_PADDEDflag should be set to make sure the L2 padding is removed before it is send to mac80211.Signed-off-by Ivo van Doorn <[email protected]>--- drivers/net/wireless/rt2x00/rt2800usb.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)(quoted diff) +0
-0
b/drivers/net/wireless/rt2x00/rt2800usb.c
drivers/net/wireless/rt2x00/rt2800usb.c static void rt2800usb_fill_rxdone(struct
Quoted 4 lines
index c82474e..6de2eda 100644
drivers/net/wireless/rt2x00/rt2800usb.c +0
-0@@ -2163,8 +2163,10 @@ static void rt2800usb_fill_rxdone(struct
queue_entry *entry,
drivers/net/wireless/rt2x00/rt2800usb.c static void rt2800usb_fill_rxdone(struct queue_entry *entry, · line 2172
Quoted 11 lines
drivers/net/wireless/rt2x00/rt2800usb.c +3
-1if (rt2x00_get_field32 (rxd0,RXD_W0_MY_BSS )) rxdesc->dev_flags |=RXDONE_MY_BSS ; -if (rt2x00_get_field32 (rxd0,RXD_W0_L2PAD )) +if (rt2x00_get_field32 (rxd0,RXD_W0_L2PAD )) { rxdesc->dev_flags |=RXDONE_L2PAD ; + skbdesc->flags |=SKBDESC_L2_PADDED ; + }if (rt2x00_get_field32 (rxwi1,RXWI_W1_SHORT_GI )) rxdesc->flags |=RX_FLAG_SHORT_GI ;
I have tested this patch as well and it looks correct. However, during my test, the hardware does not set L2PAD flag, even if padding is present (for some frames). I did the same test with the rt2870sta driver from Ralink and the L2PAD was indeed set.
Ivo : what happens during your tests?
Regards,
Benoit
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkqJwZkACgkQOR6EySwP7oLcEACcDDUaE5oeOhF8CsC1hdg6cKQ6 7K4An2DKy76bVP2CpfhOJePGNrSWDI2v
=3ymH
-----END PGP SIGNATURE-----
Re: [rt2x00-users] [PATCH 4/7] rt2x00: Set SKBDESC_L2_PADDED in RX path
Quoted 26 lines · Benoit PAPILLAULT
Review
Quoted 10 lines · Ivo van Doorn
When the RX descriptor indicates the frame was L2 padded, the
SKBDESC_L2_PADDEDflag should be set to make sure the L2 padding is removed before it is send to mac80211.Signed-off-by Ivo van Doorn <[email protected]>--- drivers/net/wireless/rt2x00/rt2800usb.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)(quoted diff) +0
-0
b/drivers/net/wireless/rt2x00/rt2800usb.cdrivers/net/wireless/rt2x00/rt2800usb.c static void rt2800usb_fill_rxdone(struct
Quoted 4 lines
index c82474e..6de2eda 100644
drivers/net/wireless/rt2x00/rt2800usb.c +0
-0@@ -2163,8 +2163,10 @@ static void rt2800usb_fill_rxdone(struct
queue_entry*entry,Quoted 9 lines
drivers/net/wireless/rt2x00/rt2800usb.c +3
-1if (rt2x00_get_field32 (rxd0,RXD_W0_MY_BSS )) rxdesc->dev_flags |=RXDONE_MY_BSS ; -if (rt2x00_get_field32 (rxd0,RXD_W0_L2PAD )) +if (rt2x00_get_field32 (rxd0,RXD_W0_L2PAD )) { rxdesc->dev_flags |=RXDONE_L2PAD ; + skbdesc->flags |=SKBDESC_L2_PADDED ; + }
Quoted 6 lines
drivers/net/wireless/rt2x00/rt2800usb.c static void rt2800usb_fill_rxdone(struct queue_entry *entry, · line 2172
Quoted 2 lines
drivers/net/wireless/rt2x00/rt2800usb.c +0
-0if (rt2x00_get_field32 (rxwi1,RXWI_W1_SHORT_GI )) rxdesc->flags |=RX_FLAG_SHORT_GI ;I have tested this patch as well and it looks correct. However, during my test, the hardware does not set L2PAD flag, even if padding is present (for some frames). I did the same test with the rt2870sta driver from Ralink and the L2PAD was indeed set.
But when the flag is set, it is being set correctly? Perhaps we can just set the flag at all times, because rt2x00lib checks how much padding is required anyway. Unless of course the device doesn't always add L2 padding when it actually should have.
Quoted 1 line
Ivo : what happens during your tests?
Tests?
I don't really have time to perform any testing, so all patches are only checked by me for 'code correctness'.