1 From e63585e28192e854707c549547645c669e6daa2a Mon Sep 17 00:00:00 2001
2 From: Ivo van Doorn <IvDoorn@gmail.com>
3 Date: Wed, 4 Mar 2009 20:25:43 +0100
4 Subject: [PATCH] rt2x00: Fix HW crypto offset calculation (rt2800pci)
6 Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
8 drivers/net/wireless/rt2x00/rt2800pci.c | 8 +++++---
9 1 files changed, 5 insertions(+), 3 deletions(-)
11 --- a/drivers/net/wireless/rt2x00/rt2800pci.c
12 +++ b/drivers/net/wireless/rt2x00/rt2800pci.c
13 @@ -336,7 +336,8 @@ static void rt2800pci_config_wcid_attr(s
14 rt2x00pci_register_read(rt2x00dev, offset, ®);
15 rt2x00_set_field32(®, MAC_WCID_ATTRIBUTE_KEYTAB,
16 !!(key->flags & IEEE80211_KEY_FLAG_PAIRWISE));
17 - rt2x00_set_field32(®, MAC_WCID_ATTRIBUTE_CIPHER, crypto->cipher);
18 + rt2x00_set_field32(®, MAC_WCID_ATTRIBUTE_CIPHER,
19 + (crypto->cmd == SET_KEY) * crypto->cipher);
20 rt2x00_set_field32(®, MAC_WCID_ATTRIBUTE_BSS_IDX,
21 (crypto->cmd == SET_KEY) * crypto->bssidx);
22 rt2x00_set_field32(®, MAC_WCID_ATTRIBUTE_RX_WIUDF, crypto->cipher);
23 @@ -393,10 +394,11 @@ static int rt2800pci_config_shared_key(s
24 * Using the correct defines correctly will cause overhead,
25 * so just calculate the correct offset.
27 - field.bit_offset = (4 * key->keyidx) + (16 * (crypto->bssidx & 1));
28 + field.bit_offset = 4 * (key->hw_key_idx % 8);
29 field.bit_mask = 0x7 << field.bit_offset;
31 - offset = SHARED_KEY_MODE_ENTRY(key->hw_key_idx / 2);
32 + offset = SHARED_KEY_MODE_ENTRY(key->hw_key_idx / 8);
34 rt2x00pci_register_read(rt2x00dev, offset, ®);
35 rt2x00_set_field32(®, field,
36 (crypto->cmd == SET_KEY) * crypto->cipher);