linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] b43 : remove old kidx API
@ 2009-06-12 20:26 gregor kowski
  2009-06-19 19:17 ` gregor kowski
  0 siblings, 1 reply; 4+ messages in thread
From: gregor kowski @ 2009-06-12 20:26 UTC (permalink / raw)
  To: linux-wireless

[-- Attachment #1: Type: text/plain, Size: 79 bytes --]

Remove old kidx API.
This simplify the code, and fix a potential key overflow.

[-- Attachment #2: b43_remove_old_kidx_api.diff --]
[-- Type: text/x-diff, Size: 5768 bytes --]

Remove old kidx API.
This simplify the code, and fix a potential key overflow.

Signed-off-by: Gregor Kowski <gregor.kowski@gmail.com>
Index: linux-2.6/drivers/net/wireless/b43/main.c
===================================================================
--- linux-2.6.orig/drivers/net/wireless/b43/main.c	2009-06-12 19:15:41.000000000 +0000
+++ linux-2.6/drivers/net/wireless/b43/main.c	2009-06-12 19:26:42.000000000 +0000
@@ -795,13 +795,11 @@
 	unsigned int i;
 	u32 offset;
 	u16 value;
-	u16 kidx;
 
 	/* Key index/algo block */
-	kidx = b43_kidx_to_fw(dev, index);
-	value = ((kidx << 4) | algorithm);
+	value = ((index << 4) | algorithm);
 	b43_shm_write16(dev, B43_SHM_SHARED,
-			B43_SHM_SH_KEYIDXBLOCK + (kidx * 2), value);
+			B43_SHM_SH_KEYIDXBLOCK + (index * 2), value);
 
 	/* Write the key to the Key Table Pointer offset */
 	offset = dev->ktp + (index * B43_SEC_KEYSIZE);
@@ -815,10 +813,7 @@
 static void keymac_write(struct b43_wldev *dev, u8 index, const u8 *addr)
 {
 	u32 addrtmp[2] = { 0, 0, };
-	u8 per_sta_keys_start = 8;
-
-	if (b43_new_kidx_api(dev))
-		per_sta_keys_start = 4;
+	const u8 per_sta_keys_start = 4;
 
 	B43_WARN_ON(index < per_sta_keys_start);
 	/* We have two default TX keys and possibly two default RX keys.
@@ -865,10 +860,7 @@
 			 const u8 *key, size_t key_len, const u8 *mac_addr)
 {
 	u8 buf[B43_SEC_KEYSIZE] = { 0, };
-	u8 per_sta_keys_start = 8;
-
-	if (b43_new_kidx_api(dev))
-		per_sta_keys_start = 4;
+	const u8 per_sta_keys_start = 4;
 
 	B43_WARN_ON(index >= dev->max_nr_keys);
 	B43_WARN_ON(key_len > B43_SEC_KEYSIZE);
@@ -891,7 +883,6 @@
 			 struct ieee80211_key_conf *keyconf)
 {
 	int i;
-	int sta_keys_start;
 
 	if (key_len > B43_SEC_KEYSIZE)
 		return -EINVAL;
@@ -900,12 +891,9 @@
 		B43_WARN_ON(dev->key[i].keyconf == keyconf);
 	}
 	if (index < 0) {
+		const int per_sta_keys_start = 4;
 		/* Pairwise key. Get an empty slot for the key. */
-		if (b43_new_kidx_api(dev))
-			sta_keys_start = 4;
-		else
-			sta_keys_start = 8;
-		for (i = sta_keys_start; i < dev->max_nr_keys; i++) {
+		for (i = per_sta_keys_start; i < dev->max_nr_keys; i++) {
 			if (!dev->key[i].keyconf) {
 				/* found empty */
 				index = i;
@@ -920,11 +908,6 @@
 		B43_WARN_ON(index > 3);
 
 	do_key_write(dev, index, algorithm, key, key_len, mac_addr);
-	if ((index <= 3) && !b43_new_kidx_api(dev)) {
-		/* Default RX key */
-		B43_WARN_ON(mac_addr);
-		do_key_write(dev, index + 4, algorithm, key, key_len, NULL);
-	}
 	keyconf->hw_key_idx = index;
 	dev->key[index].keyconf = keyconf;
 
@@ -937,10 +920,6 @@
 		return -EINVAL;
 	do_key_write(dev, index, B43_SEC_ALGO_NONE,
 		     NULL, B43_SEC_KEYSIZE, NULL);
-	if ((index <= 3) && !b43_new_kidx_api(dev)) {
-		do_key_write(dev, index + 4, B43_SEC_ALGO_NONE,
-			     NULL, B43_SEC_KEYSIZE, NULL);
-	}
 	dev->key[index].keyconf = NULL;
 
 	return 0;
@@ -2966,7 +2945,8 @@
 
 static void b43_security_init(struct b43_wldev *dev)
 {
-	dev->max_nr_keys = (dev->dev->id.revision >= 5) ? 58 : 20;
+	dev->max_nr_keys = (dev->dev->id.revision >= 5) ? 54 : 20;
+	B43_WARN_ON(dev->fw.rev < 351);
 	B43_WARN_ON(dev->max_nr_keys > ARRAY_SIZE(dev->key));
 	dev->ktp = b43_shm_read16(dev, B43_SHM_SHARED, B43_SHM_SH_KTP);
 	/* KTP is a word address, but we address SHM bytewise.
@@ -2975,7 +2955,7 @@
 	dev->ktp *= 2;
 	if (dev->dev->id.revision >= 5) {
 		/* Number of RCMTA address slots */
-		b43_write16(dev, B43_MMIO_RCMTA_COUNT, dev->max_nr_keys - 8);
+		b43_write16(dev, B43_MMIO_RCMTA_COUNT, dev->max_nr_keys - 4);
 	}
 	b43_clear_keys(dev);
 }
Index: linux-2.6/drivers/net/wireless/b43/xmit.c
===================================================================
--- linux-2.6.orig/drivers/net/wireless/b43/xmit.c	2009-06-12 19:15:41.000000000 +0000
+++ linux-2.6/drivers/net/wireless/b43/xmit.c	2009-06-12 19:26:42.000000000 +0000
@@ -253,7 +253,6 @@
 		/* Hardware appends ICV. */
 		plcp_fragment_len += info->control.hw_key->icv_len;
 
-		key_idx = b43_kidx_to_fw(dev, key_idx);
 		mac_ctl |= (key_idx << B43_TXH_MAC_KEYIDX_SHIFT) &
 			   B43_TXH_MAC_KEYIDX;
 		mac_ctl |= (key->algorithm << B43_TXH_MAC_KEYALG_SHIFT) &
@@ -578,7 +577,6 @@
 		/* We must adjust the key index here. We want the "physical"
 		 * key index, but the ucode passed it slightly different.
 		 */
-		keyidx = b43_kidx_to_raw(dev, keyidx);
 		B43_WARN_ON(keyidx >= dev->max_nr_keys);
 
 		if (dev->key[keyidx].algorithm != B43_SEC_ALGO_NONE) {
Index: linux-2.6/drivers/net/wireless/b43/xmit.h
===================================================================
--- linux-2.6.orig/drivers/net/wireless/b43/xmit.h	2009-06-12 19:15:41.000000000 +0000
+++ linux-2.6/drivers/net/wireless/b43/xmit.h	2009-06-12 19:26:42.000000000 +0000
@@ -301,36 +301,4 @@
 void b43_tx_suspend(struct b43_wldev *dev);
 void b43_tx_resume(struct b43_wldev *dev);
 
-
-/* Helper functions for converting the key-table index from "firmware-format"
- * to "raw-format" and back. The firmware API changed for this at some revision.
- * We need to account for that here. */
-static inline int b43_new_kidx_api(struct b43_wldev *dev)
-{
-	/* FIXME: Not sure the change was at rev 351 */
-	return (dev->fw.rev >= 351);
-}
-static inline u8 b43_kidx_to_fw(struct b43_wldev *dev, u8 raw_kidx)
-{
-	u8 firmware_kidx;
-	if (b43_new_kidx_api(dev)) {
-		firmware_kidx = raw_kidx;
-	} else {
-		if (raw_kidx >= 4)	/* Is per STA key? */
-			firmware_kidx = raw_kidx - 4;
-		else
-			firmware_kidx = raw_kidx;	/* TX default key */
-	}
-	return firmware_kidx;
-}
-static inline u8 b43_kidx_to_raw(struct b43_wldev *dev, u8 firmware_kidx)
-{
-	u8 raw_kidx;
-	if (b43_new_kidx_api(dev))
-		raw_kidx = firmware_kidx;
-	else
-		raw_kidx = firmware_kidx + 4;	/* RX default keys or per STA keys */
-	return raw_kidx;
-}
-
 #endif /* B43_XMIT_H_ */

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] b43 : remove old kidx API
  2009-06-12 20:26 [PATCH] b43 : remove old kidx API gregor kowski
@ 2009-06-19 19:17 ` gregor kowski
  2009-06-19 19:29   ` Michael Buesch
  0 siblings, 1 reply; 4+ messages in thread
From: gregor kowski @ 2009-06-19 19:17 UTC (permalink / raw)
  To: linux-wireless; +Cc: Michael Buesch

On 6/12/09, gregor kowski <gregor.kowski@gmail.com> wrote:
> Remove old kidx API.
> This simplify the code, and fix a potential key overflow.
>
Michael,

any comment on this ?
I wait your ack to resubmit tkip hardware support.

Regards

Gregor.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] b43 : remove old kidx API
  2009-06-19 19:17 ` gregor kowski
@ 2009-06-19 19:29   ` Michael Buesch
  2009-06-19 22:18     ` Gábor Stefanik
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Buesch @ 2009-06-19 19:29 UTC (permalink / raw)
  To: gregor kowski; +Cc: linux-wireless

On Friday 19 June 2009 21:17:04 gregor kowski wrote:
> On 6/12/09, gregor kowski <gregor.kowski@gmail.com> wrote:
> > Remove old kidx API.
> > This simplify the code, and fix a potential key overflow.
> >
> Michael,
> 
> any comment on this ?
> I wait your ack to resubmit tkip hardware support.

If you want my ack, you should probably CC me. I basically don't read the list.

-- 
Greetings, Michael.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] b43 : remove old kidx API
  2009-06-19 19:29   ` Michael Buesch
@ 2009-06-19 22:18     ` Gábor Stefanik
  0 siblings, 0 replies; 4+ messages in thread
From: Gábor Stefanik @ 2009-06-19 22:18 UTC (permalink / raw)
  To: Michael Buesch; +Cc: gregor kowski, linux-wireless, Broadcom Wireless

On Fri, Jun 19, 2009 at 9:29 PM, Michael Buesch<mb@bu3sch.de> wrote:
> On Friday 19 June 2009 21:17:04 gregor kowski wrote:
>> On 6/12/09, gregor kowski <gregor.kowski@gmail.com> wrote:
>> > Remove old kidx API.
>> > This simplify the code, and fix a potential key overflow.
>> >
>> Michael,
>>
>> any comment on this ?
>> I wait your ack to resubmit tkip hardware support.
>
> If you want my ack, you should probably CC me. I basically don't read the list.
>

Also, given that this is a b43-related issue, CC bcm43xx-dev@lists.berlios.de.

-- 
Vista: [V]iruses, [I]ntruders, [S]pyware, [T]rojans and [A]dware. :-)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-06-19 22:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-12 20:26 [PATCH] b43 : remove old kidx API gregor kowski
2009-06-19 19:17 ` gregor kowski
2009-06-19 19:29   ` Michael Buesch
2009-06-19 22:18     ` Gábor Stefanik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).