2008-04-21 02:36:16

by Harvey Harrison

[permalink] [raw]
Subject: [PATCH] mac80211: simplify code in util.c

Signed-off-by: Harvey Harrison <[email protected]>
---
net/mac80211/util.c | 11 ++++-------
1 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index cc9f715..9960372 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -101,16 +101,13 @@ int ieee80211_get_hdrlen(u16 fc)
switch (fc & IEEE80211_FCTL_FTYPE) {
case IEEE80211_FTYPE_DATA:
if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
- hdrlen = 30; /* Addr4 */
+ hdrlen += ETH_ALEN; /* Addr4 */
/*
* The QoS Control field is two bytes and its presence is
- * indicated by the IEEE80211_STYPE_QOS_DATA bit. Add 2 to
- * hdrlen if that bit is set.
- * This works by masking out the bit and shifting it to
- * bit position 1 so the result has the value 0 or 2.
+ * indicated by the IEEE80211_STYPE_QOS_DATA bit.
*/
- hdrlen += (fc & IEEE80211_STYPE_QOS_DATA)
- >> (ilog2(IEEE80211_STYPE_QOS_DATA)-1);
+ if (fc & IEEE80211_STYPE_QOS_DATA)
+ hdrlen += 2;
break;
case IEEE80211_FTYPE_CTL:
/*
--
1.5.5.144.g3e42





2008-04-21 05:25:31

by Zhu Yi

[permalink] [raw]
Subject: Re: [PATCH] mac80211: simplify code in util.c

On Sun, 2008-04-20 at 19:36 -0700, Harvey Harrison wrote:
> - hdrlen += (fc & IEEE80211_STYPE_QOS_DATA)
> - >> (ilog2(IEEE80211_STYPE_QOS_DATA)-1);
> + if (fc & IEEE80211_STYPE_QOS_DATA)
> + hdrlen += 2;

You need also take other QoS types (i.e QOS_NULLFUNC) into
consideration. Please take a look at WLAN_FC_IS_QOS_DATA macro.

Thanks,
-yi


2008-04-21 05:50:39

by Harvey Harrison

[permalink] [raw]
Subject: Re: [PATCH] mac80211: simplify code in util.c

On Mon, 2008-04-21 at 13:24 +0800, Zhu Yi wrote:
> On Sun, 2008-04-20 at 19:36 -0700, Harvey Harrison wrote:
> > - hdrlen += (fc & IEEE80211_STYPE_QOS_DATA)
> > - >> (ilog2(IEEE80211_STYPE_QOS_DATA)-1);
> > + if (fc & IEEE80211_STYPE_QOS_DATA)
> > + hdrlen += 2;
>
> You need also take other QoS types (i.e QOS_NULLFUNC) into
> consideration. Please take a look at WLAN_FC_IS_QOS_DATA macro.
>

Well, that would be a change from what's there now, I've just got a
few pure cleanup patches I've done while making some changes in wpa.c
I'm going to submit the cleanup patches on their own first, then
patches with more substance.

Cheers,

Harvey


2008-04-21 08:19:47

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH] mac80211: simplify code in util.c

On Sun, 2008-04-20 at 19:36 -0700, Harvey Harrison wrote:
> Signed-off-by: Harvey Harrison <[email protected]>

> if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
> - hdrlen = 30; /* Addr4 */
> + hdrlen += ETH_ALEN; /* Addr4 */
> /*
> * The QoS Control field is two bytes and its presence is
> - * indicated by the IEEE80211_STYPE_QOS_DATA bit. Add 2 to
> - * hdrlen if that bit is set.
> - * This works by masking out the bit and shifting it to
> - * bit position 1 so the result has the value 0 or 2.
> + * indicated by the IEEE80211_STYPE_QOS_DATA bit.
> */
> - hdrlen += (fc & IEEE80211_STYPE_QOS_DATA)
> - >> (ilog2(IEEE80211_STYPE_QOS_DATA)-1);
> + if (fc & IEEE80211_STYPE_QOS_DATA)
> + hdrlen += 2;

Have you checked the generated code? Last time I checked it was better
with what we had there.

johannes


Attachments:
signature.asc (828.00 B)
This is a digitally signed message part