rt2x00: Synchronize WCID initialization with legacy driver
authorIvo van Doorn <IvDoorn@gmail.com>
Mon, 14 Jun 2010 20:14:19 +0000 (22:14 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Tue, 15 Jun 2010 20:02:21 +0000 (16:02 -0400)
Legacy rt2870 driver handles WCID differently then we expected,
the BSSID and Cipher value are 3 bit values, while the 4th bit
should be set elsewhere in an extended field.

After this, rt2800usb reports frames have been decrypted
successfully, indicating that the Hardware decryption now is
working correctly.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/rt2x00/rt2800.h
drivers/net/wireless/rt2x00/rt2800lib.c

index b3084211f1ba1c90090765dc615c7bb7d87e44f8..3ed87badc2d3e04f95db8a53bf6b7f1f8f699637 100644 (file)
@@ -1436,6 +1436,10 @@ struct mac_iveiv_entry {
 #define MAC_WCID_ATTRIBUTE_CIPHER      FIELD32(0x0000000e)
 #define MAC_WCID_ATTRIBUTE_BSS_IDX     FIELD32(0x00000070)
 #define MAC_WCID_ATTRIBUTE_RX_WIUDF    FIELD32(0x00000380)
+#define MAC_WCID_ATTRIBUTE_CIPHER_EXT  FIELD32(0x00000400)
+#define MAC_WCID_ATTRIBUTE_BSS_IDX_EXT FIELD32(0x00000800)
+#define MAC_WCID_ATTRIBUTE_WAPI_MCBC   FIELD32(0x00008000)
+#define MAC_WCID_ATTRIBUTE_WAPI_KEY_IDX        FIELD32(0xff000000)
 
 /*
  * SHARED_KEY_MODE:
index 84ce169882f3229ae41c22bf6cf2606d045f2735..14c361ae87be5e15f0abef94b2b58723cd54c7bf 100644 (file)
@@ -554,15 +554,28 @@ static void rt2800_config_wcid_attr(struct rt2x00_dev *rt2x00dev,
 
        offset = MAC_WCID_ATTR_ENTRY(key->hw_key_idx);
 
-       rt2800_register_read(rt2x00dev, offset, &reg);
-       rt2x00_set_field32(&reg, MAC_WCID_ATTRIBUTE_KEYTAB,
-                          !!(key->flags & IEEE80211_KEY_FLAG_PAIRWISE));
-       rt2x00_set_field32(&reg, MAC_WCID_ATTRIBUTE_CIPHER,
-                          (crypto->cmd == SET_KEY) * crypto->cipher);
-       rt2x00_set_field32(&reg, MAC_WCID_ATTRIBUTE_BSS_IDX,
-                          (crypto->cmd == SET_KEY) * crypto->bssidx);
-       rt2x00_set_field32(&reg, MAC_WCID_ATTRIBUTE_RX_WIUDF, crypto->cipher);
-       rt2800_register_write(rt2x00dev, offset, reg);
+       if (crypto->cmd == SET_KEY) {
+               rt2800_register_read(rt2x00dev, offset, &reg);
+               rt2x00_set_field32(&reg, MAC_WCID_ATTRIBUTE_KEYTAB,
+                                  !!(key->flags & IEEE80211_KEY_FLAG_PAIRWISE));
+               /*
+                * Both the cipher as the BSS Idx numbers are split in a main
+                * value of 3 bits, and a extended field for adding one additional
+                * bit to the value.
+                */
+               rt2x00_set_field32(&reg, MAC_WCID_ATTRIBUTE_CIPHER,
+                                  (crypto->cipher & 0x7));
+               rt2x00_set_field32(&reg, MAC_WCID_ATTRIBUTE_CIPHER_EXT,
+                                  (crypto->cipher & 0x8) >> 3);
+               rt2x00_set_field32(&reg, MAC_WCID_ATTRIBUTE_BSS_IDX,
+                                  (crypto->bssidx & 0x7));
+               rt2x00_set_field32(&reg, MAC_WCID_ATTRIBUTE_BSS_IDX_EXT,
+                                  (crypto->bssidx & 0x8) >> 3);
+               rt2x00_set_field32(&reg, MAC_WCID_ATTRIBUTE_RX_WIUDF, crypto->cipher);
+               rt2800_register_write(rt2x00dev, offset, reg);
+       } else {
+               rt2800_register_write(rt2x00dev, offset, 0);
+       }
 
        offset = MAC_IVEIV_ENTRY(key->hw_key_idx);