From: "Jouni Malinen" <jkm@devicescape.com>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: Jiri Benc <jbenc@suse.cz>,
linux-wireless <linux-wireless@vger.kernel.org>
Subject: Re: [PATCH] mac80211: optimise ieee80211_get_hdrlen
Date: Wed, 28 Mar 2007 12:11:16 -0700 [thread overview]
Message-ID: <20070328191116.GJ6036@devicescape.com> (raw)
In-Reply-To: <1175011305.9282.10.camel@johannes.berg>
On Tue, Mar 27, 2007 at 06:01:45PM +0200, Johannes Berg wrote:
> This patch optimises the ieee80211_get_hdrlen function by exploiting the
> bit masks directly.
> --- wireless-dev.orig/net/mac80211/ieee80211.c 2007-03-27 16:33:47.163155480 +0200
> +++ wireless-dev/net/mac80211/ieee80211.c 2007-03-27 16:33:48.473155480 +0200
> @@ -258,19 +258,24 @@ int ieee80211_get_hdrlen(u16 fc)
> case IEEE80211_FTYPE_DATA:
> if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
> hdrlen = 30; /* Addr4 */
> - if (fc & IEEE80211_STYPE_QOS_DATA)
> - hdrlen += 2; /* QoS Control Field */
> + /* QoS Control Field */
> + hdrlen += (fc & IEEE80211_STYPE_QOS_DATA)
> + >> (ilog2(IEEE80211_STYPE_QOS_DATA)-1);
> break;
Could you please add a comment explaining what exactly happens here and
more importantly, include an easy way of understanding that this adds 2
bytes.
> case IEEE80211_FTYPE_CTL:
> - switch (fc & IEEE80211_FCTL_STYPE) {
> - case IEEE80211_STYPE_CTS:
> - case IEEE80211_STYPE_ACK:
> + /*
> + * ACK and CTS are 10 bytes, all others 16. To see how
> + * to get this condition consider
> + * subtype mask: 0b0000000011110000 (0x00F0)
> + * ACK subtype: 0b0000000011010000 (0x00D0)
> + * CTS subtype: 0b0000000011000000 (0x00C0)
> + * bits that matter: ^^^ (0x00E0)
> + * value of those: 0b0000000011000000 (0x00C0)
> + */
> + if ((fc & 0xE0) == 0xC0)
> hdrlen = 10;
> - break;
> - default:
> + else
> hdrlen = 16;
> - break;
> - }
Is this case even used anywhere? Looks like unnecessary optimization at
the cost of making the source code more difficult to understand and
modify.
--
Jouni Malinen PGP id EFC895FA
next prev parent reply other threads:[~2007-03-28 19:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-27 16:01 [PATCH] mac80211: optimise ieee80211_get_hdrlen Johannes Berg
2007-03-28 19:11 ` Jouni Malinen [this message]
2007-03-29 11:07 ` Johannes Berg
2007-03-29 15:48 ` Jouni Malinen
2007-04-27 15:10 ` Johannes Berg
2007-04-28 13:40 ` Jiri Benc
2007-04-28 13:58 ` Johannes Berg
2007-04-28 14:35 ` Jiri Benc
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070328191116.GJ6036@devicescape.com \
--to=jkm@devicescape.com \
--cc=jbenc@suse.cz \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).