linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch 6/7] mac80211: michael.c use unaligned/byteorder helpers
@ 2008-04-18 20:59 akpm
  2008-04-19 18:24 ` Larry Finger
  2008-04-19 18:38 ` Larry Finger
  0 siblings, 2 replies; 5+ messages in thread
From: akpm @ 2008-04-18 20:59 UTC (permalink / raw)
  To: linville; +Cc: linux-wireless, akpm, harvey.harrison, jbenc

From: Harvey Harrison <harvey.harrison@gmail.com>

Rather than open-coding the get/put of little endian values, use
get/put_unaligned and the byteorder helpers.

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Cc: Jiri Benc <jbenc@suse.cz>
Cc: John W. Linville <linville@tuxdriver.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 net/mac80211/michael.c |   21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff -puN net/mac80211/michael.c~mac80211-michaelc-use-unaligned-byteorder-helpers net/mac80211/michael.c
--- a/net/mac80211/michael.c~mac80211-michaelc-use-unaligned-byteorder-helpers
+++ a/net/mac80211/michael.c
@@ -9,6 +9,8 @@
 
 #include <linux/types.h>
 #include <linux/bitops.h>
+#include <asm/byteorder.h>
+#include <asm/unaligned.h>
 
 #include "michael.h"
 
@@ -24,21 +26,20 @@ static void michael_block(u32 *l, u32 *r
 	*l += *r;
 }
 
-
-static inline u32 michael_get32(u8 *data)
+static u32 michael_get16(u8 *data)
 {
-	return data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24);
+	return le16_to_cpu(get_unaligned((__le16 *)data));
 }
 
-
-static inline void michael_put32(u32 val, u8 *data)
+static u32 michael_get32(u8 *data)
 {
-	data[0] = val & 0xff;
-	data[1] = (val >> 8) & 0xff;
-	data[2] = (val >> 16) & 0xff;
-	data[3] = (val >> 24) & 0xff;
+	return le32_to_cpu(get_unaligned((__le32 *)data));
 }
 
+static void michael_put32(u32 val, u8 *data)
+{
+	put_unaligned(cpu_to_le32(val), (__le32 *)data);
+}
 
 void michael_mic(u8 *key, u8 *da, u8 *sa, u8 priority,
 		 u8 *data, size_t data_len, u8 *mic)
@@ -53,7 +54,7 @@ void michael_mic(u8 *key, u8 *da, u8 *sa
 	 * calculation, but it is _not_ transmitted */
 	l ^= michael_get32(da);
 	michael_block(&l, &r);
-	l ^= da[4] | (da[5] << 8) | (sa[0] << 16) | (sa[1] << 24);
+	l ^= michael_get16(da) | (michael_get16(sa) << 16);
 	michael_block(&l, &r);
 	l ^= michael_get32(&sa[2]);
 	michael_block(&l, &r);
_

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

* Re: [patch 6/7] mac80211: michael.c use unaligned/byteorder helpers
  2008-04-18 20:59 [patch 6/7] mac80211: michael.c use unaligned/byteorder helpers akpm
@ 2008-04-19 18:24 ` Larry Finger
  2008-04-19 19:31   ` Harvey Harrison
  2008-04-19 18:38 ` Larry Finger
  1 sibling, 1 reply; 5+ messages in thread
From: Larry Finger @ 2008-04-19 18:24 UTC (permalink / raw)
  To: akpm; +Cc: linville, linux-wireless, harvey.harrison, jbenc

akpm@linux-foundation.org wrote:
> From: Harvey Harrison <harvey.harrison@gmail.com>
> 
> Rather than open-coding the get/put of little endian values, use
> get/put_unaligned and the byteorder helpers.
> 
> Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
> Cc: Jiri Benc <jbenc@suse.cz>
> Cc: John W. Linville <linville@tuxdriver.com>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---

The set of 7 patches break my system, which is x86_64 using WPA-PSK 
TKIP. If I back out #6 and 7, then all is OK.

Does this series have any prerequisites? I'm running the current 
wireless-testing git tree.

Larry

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

* Re: [patch 6/7] mac80211: michael.c use unaligned/byteorder helpers
  2008-04-18 20:59 [patch 6/7] mac80211: michael.c use unaligned/byteorder helpers akpm
  2008-04-19 18:24 ` Larry Finger
@ 2008-04-19 18:38 ` Larry Finger
  1 sibling, 0 replies; 5+ messages in thread
From: Larry Finger @ 2008-04-19 18:38 UTC (permalink / raw)
  To: akpm; +Cc: linville, linux-wireless, harvey.harrison, jbenc

akpm@linux-foundation.org wrote:
> From: Harvey Harrison <harvey.harrison@gmail.com>
> 
> Rather than open-coding the get/put of little endian values, use
> get/put_unaligned and the byteorder helpers.
> 
> Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
> Cc: Jiri Benc <jbenc@suse.cz>
> Cc: John W. Linville <linville@tuxdriver.com>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
> 
>  net/mac80211/michael.c |   21 +++++++++++----------
>  1 file changed, 11 insertions(+), 10 deletions(-)
> 
> diff -puN net/mac80211/michael.c~mac80211-michaelc-use-unaligned-byteorder-helpers net/mac80211/michael.c
> --- a/net/mac80211/michael.c~mac80211-michaelc-use-unaligned-byteorder-helpers
> +++ a/net/mac80211/michael.c
> @@ -9,6 +9,8 @@
>  
>  #include <linux/types.h>
>  #include <linux/bitops.h>
> +#include <asm/byteorder.h>
> +#include <asm/unaligned.h>
>  
>  #include "michael.h"
>  
> @@ -24,21 +26,20 @@ static void michael_block(u32 *l, u32 *r
>  	*l += *r;
>  }
>  
> -
> -static inline u32 michael_get32(u8 *data)
> +static u32 michael_get16(u8 *data)
>  {
> -	return data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24);
> +	return le16_to_cpu(get_unaligned((__le16 *)data));
>  }
>  
> -
> -static inline void michael_put32(u32 val, u8 *data)
> +static u32 michael_get32(u8 *data)
>  {
> -	data[0] = val & 0xff;
> -	data[1] = (val >> 8) & 0xff;
> -	data[2] = (val >> 16) & 0xff;
> -	data[3] = (val >> 24) & 0xff;
> +	return le32_to_cpu(get_unaligned((__le32 *)data));
>  }
>  
> +static void michael_put32(u32 val, u8 *data)
> +{
> +	put_unaligned(cpu_to_le32(val), (__le32 *)data);
> +}
>  
>  void michael_mic(u8 *key, u8 *da, u8 *sa, u8 priority,
>  		 u8 *data, size_t data_len, u8 *mic)
> @@ -53,7 +54,7 @@ void michael_mic(u8 *key, u8 *da, u8 *sa
>  	 * calculation, but it is _not_ transmitted */
>  	l ^= michael_get32(da);
>  	michael_block(&l, &r);
> -	l ^= da[4] | (da[5] << 8) | (sa[0] << 16) | (sa[1] << 24);
> +	l ^= michael_get16(da) | (michael_get16(sa) << 16);
___________________________^^

This should be da + 4! This change affects #7 of 7, and is needed 
there as well. With those changes, my stuff works with patches 1-6 and 
with 1-7.

Larry


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

* Re: [patch 6/7] mac80211: michael.c use unaligned/byteorder helpers
  2008-04-19 18:24 ` Larry Finger
@ 2008-04-19 19:31   ` Harvey Harrison
  2008-04-20  2:25     ` Larry Finger
  0 siblings, 1 reply; 5+ messages in thread
From: Harvey Harrison @ 2008-04-19 19:31 UTC (permalink / raw)
  To: Larry Finger; +Cc: akpm, linville, linux-wireless, jbenc

On Sat, 2008-04-19 at 13:24 -0500, Larry Finger wrote:
> akpm@linux-foundation.org wrote:
> > From: Harvey Harrison <harvey.harrison@gmail.com>
> > 
> > Rather than open-coding the get/put of little endian values, use
> > get/put_unaligned and the byteorder helpers.
> > 
> > Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
> > Cc: Jiri Benc <jbenc@suse.cz>
> > Cc: John W. Linville <linville@tuxdriver.com>
> > Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> > ---
> 
> The set of 7 patches break my system, which is x86_64 using WPA-PSK 
> TKIP. If I back out #6 and 7, then all is OK.
> 
> Does this series have any prerequisites? I'm running the current 
> wireless-testing git tree.
> 

Thanks for the testing, I posted an updated patchset on Thursday
last week and this set has been dropped from -mm.

The new patchset depends on the new unaligned helpers in -mm,
if you want I can send you a full set if you feel like testing
them.

Harvey



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

* Re: [patch 6/7] mac80211: michael.c use unaligned/byteorder helpers
  2008-04-19 19:31   ` Harvey Harrison
@ 2008-04-20  2:25     ` Larry Finger
  0 siblings, 0 replies; 5+ messages in thread
From: Larry Finger @ 2008-04-20  2:25 UTC (permalink / raw)
  To: Harvey Harrison; +Cc: akpm, linville, linux-wireless, jbenc

Harvey Harrison wrote:
> Thanks for the testing, I posted an updated patchset on Thursday
> last week and this set has been dropped from -mm.
> 
> The new patchset depends on the new unaligned helpers in -mm,
> if you want I can send you a full set if you feel like testing
> them.

I would be happy to test the full set.

Larry


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

end of thread, other threads:[~2008-04-20  2:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-18 20:59 [patch 6/7] mac80211: michael.c use unaligned/byteorder helpers akpm
2008-04-19 18:24 ` Larry Finger
2008-04-19 19:31   ` Harvey Harrison
2008-04-20  2:25     ` Larry Finger
2008-04-19 18:38 ` Larry Finger

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