linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RESEND] [PATCH] b43 : remove old kidx API
@ 2009-07-27 20:43 gregor kowski
  2009-08-20 14:52 ` John W. Linville
  0 siblings, 1 reply; 3+ messages in thread
From: gregor kowski @ 2009-07-27 20:43 UTC (permalink / raw)
  To: bcm43xx-dev; +Cc: Michael Buesch, linux-wireless

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-07-25
10:58:31.000000000 +0000
+++ linux-2.6/drivers/net/wireless/b43/main.c	2009-07-27
20:40:14.000000000 +0000
@@ -776,13 +776,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);
@@ -796,10 +794,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.
@@ -846,10 +841,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);
@@ -872,7 +864,6 @@
 			 struct ieee80211_key_conf *keyconf)
 {
 	int i;
-	int sta_keys_start;

 	if (key_len > B43_SEC_KEYSIZE)
 		return -EINVAL;
@@ -881,12 +872,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;
@@ -901,11 +889,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;

@@ -918,10 +901,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;
@@ -2972,7 +2951,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.
@@ -2981,7 +2961,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-07-25
10:58:31.000000000 +0000
+++ linux-2.6/drivers/net/wireless/b43/xmit.c	2009-07-27
20:40:14.000000000 +0000
@@ -252,7 +252,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) &
@@ -577,7 +576,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-07-25
10:58:30.000000000 +0000
+++ linux-2.6/drivers/net/wireless/b43/xmit.h	2009-07-27
20:40:14.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] 3+ messages in thread

* Re: [RESEND] [PATCH] b43 : remove old kidx API
  2009-07-27 20:43 [RESEND] [PATCH] b43 : remove old kidx API gregor kowski
@ 2009-08-20 14:52 ` John W. Linville
  2009-08-20 17:15   ` Michael Buesch
  0 siblings, 1 reply; 3+ messages in thread
From: John W. Linville @ 2009-08-20 14:52 UTC (permalink / raw)
  To: gregor kowski; +Cc: bcm43xx-dev, Michael Buesch, linux-wireless

On Mon, Jul 27, 2009 at 10:43:36PM +0200, gregor kowski wrote:
> Remove old kidx API.
> This simplify the code, and fix a potential key overflow.
> 
> Signed-off-by: Gregor Kowski <gregor.kowski@gmail.com>

Is this patch still relevant?  If so, could you repost a version that
isn't whitespace damaged and that actually applies?

John
-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

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

* Re: [RESEND] [PATCH] b43 : remove old kidx API
  2009-08-20 14:52 ` John W. Linville
@ 2009-08-20 17:15   ` Michael Buesch
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Buesch @ 2009-08-20 17:15 UTC (permalink / raw)
  To: John W. Linville; +Cc: gregor kowski, bcm43xx-dev, linux-wireless

On Thursday 20 August 2009 16:52:13 John W. Linville wrote:
> On Mon, Jul 27, 2009 at 10:43:36PM +0200, gregor kowski wrote:
> > Remove old kidx API.
> > This simplify the code, and fix a potential key overflow.
> > 
> > Signed-off-by: Gregor Kowski <gregor.kowski@gmail.com>
> 
> Is this patch still relevant?

no 

-- 
Greetings, Michael.

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

end of thread, other threads:[~2009-08-20 17:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-27 20:43 [RESEND] [PATCH] b43 : remove old kidx API gregor kowski
2009-08-20 14:52 ` John W. Linville
2009-08-20 17:15   ` Michael Buesch

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).