mac80211: simplify code in util.c
PATCH 1/1 mac80211: simplify code in util.c
--- net/mac80211/util.c | 11 ++++------- 1 files changed, 4 insertions(+), 7 deletions(-)
net/mac80211/util.c +4 -7
@@ -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 :/*
Signature · 1 line
1.5.5.144.g3e42
net/mac80211/util.c int ieee80211_get_hdrlen(u16 fc) · line 110
Quoted 4 lines · Harvey Harrison
net/mac80211/util.c +2
-2- 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
Quoted 9 lines · Zhu Yi
net/mac80211/util.c int ieee80211_get_hdrlen(u16 fc) · line 110
Quoted 4 lines · Harvey Harrison
net/mac80211/util.c +2
-2- 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 atWLAN_FC_IS_QOS_DATAmacro.
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
Johannes Berg
maintainerQuoted 7 lines · Harvey Harrison
Signed-off-by Harvey Harrison <[email protected]>net/mac80211/util.c +1
-1if ((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
net/mac80211/util.c int ieee80211_get_hdrlen(u16 fc) · line 110
Quoted 10 lines
net/mac80211/util.c +3
-6-* 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