Linux wireless drivers development
 help / color / mirror / Atom feed
From: Simon Wunderlich <simon.wunderlich@s2003.tu-chemnitz.de>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: Simon Wunderlich <simon.wunderlich@s2003.tu-chemnitz.de>,
	linux-wireless@vger.kernel.org, linville@tuxdriver.com,
	Simon Wunderlich <siwu@hrz.tu-chemnitz.de>,
	Mathias Kretschmer <mathias.kretschmer@fokus.fraunhofer.de>
Subject: Re: [PATCHv2 2/2] mac80211: add support for mcs masks
Date: Tue, 10 Jan 2012 18:28:32 +0100	[thread overview]
Message-ID: <20120110172832.GA19790@pandem0nium> (raw)
In-Reply-To: <1326114294.3451.25.camel@jlt3.sipsolutions.net>

[-- Attachment #1: Type: text/plain, Size: 1979 bytes --]

Hello Johannes,

On Mon, Jan 09, 2012 at 02:04:54PM +0100, Johannes Berg wrote:
> On Thu, 2012-01-05 at 20:58 +0100, Simon Wunderlich wrote:
> 
> > +static bool rate_idx_match_mcs_mask(struct ieee80211_tx_rate *rate,
> > +				    u8 mcs_mask[IEEE80211_HT_MCS_MASK_LEN])
> > +{
> > +	int i, j;
> > +	int ridx, rbit;
> > +
> > +	ridx = rate->idx / 8;
> > +	rbit = rate->idx % 8;
> > +
> > +	/* sanity check */
> > +	if (ridx < 0 || ridx > IEEE80211_HT_MCS_MASK_LEN)
> > +		return false;
> > +
> > +	/* See whether the selected rate or anything below it is allowed. */
> > +	for (i = ridx; i >= 0; i--) {
> > +		for (j = rbit; j >= 0; j--)
> > +			if (mcs_mask[i] & BIT(j)) {
> > +				rate->idx = i * 8 + j;
> > +				return true;
> > +			}
> > +		rbit = 7;
> > +	}
> > +
> > +	/* Try to find a higher rate that would be allowed */
> > +	ridx = (rate->idx + 1) / 8;
> > +	rbit = (rate->idx + 1) % 8;
> > +
> > +	for (i = ridx; i < IEEE80211_HT_MCS_MASK_LEN; i++) {
> > +		for (j = rbit; j < 8; j++)
> > +			if (mcs_mask[i] & BIT(j)) {
> > +				rate->idx = i * 8 + j;
> > +				return true;
> > +			}
> > +		rbit = 0;
> > +	}
> > +	return false;
> 
> All this logic is pretty complex, maybe we could translate the bitmap to
> an array of unsigned longs and use test_bit() instead of open-coding it
> for 8-bit words?

Mhm, I would rather not add further copies into this fast path function, and
simply casting will result in bad behaviour (alignment, endianess). Generally
changing the mcs_mask to u32 is possible, but then we have inconsistent mcs
fields (rx_mask and others are u8 arrays too) - do we want this? Or am I missing
something obvious right now? :)

Maybe we can simplify it to something like this:

for (i = rate->idx + 1; i < IEEE80211_HT_MCS_MASK_LEN * 8; i++) {
	ridx = i / 8;
	rbit = i % 8;
	if (mcs_mask[ridx] & BIT(rbit))) {
		rate->idx = i;
		return true;
	}
}

What do you think?

Cheers,
	Simon

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

  reply	other threads:[~2012-01-10 17:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-05 19:58 [PATCHv2 0/2] add support for mcs masks Simon Wunderlich
2012-01-05 19:58 ` [PATCHv2 1/2] nl80211: " Simon Wunderlich
2012-01-09 13:01   ` Johannes Berg
2012-01-05 19:58 ` [PATCHv2 2/2] mac80211: " Simon Wunderlich
2012-01-09 13:04   ` Johannes Berg
2012-01-10 17:28     ` Simon Wunderlich [this message]
2012-01-10 17:35       ` Johannes Berg
2012-01-10 18:42         ` Simon Wunderlich
2012-01-05 19:58 ` [PATCH 1/2] iw: add nl80211 bitrates Simon Wunderlich
2012-01-05 19:58 ` [PATCH 2/2] iw: remove ifdefs for mcs mask Simon Wunderlich
2012-01-09 13:05   ` Johannes Berg
2012-01-10 18:29     ` Simon Wunderlich

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=20120110172832.GA19790@pandem0nium \
    --to=simon.wunderlich@s2003.tu-chemnitz.de \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=mathias.kretschmer@fokus.fraunhofer.de \
    --cc=siwu@hrz.tu-chemnitz.de \
    /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