diff mbox

[2/2] mac80211: fix the check for mcs rates masking

Message ID 1361966434-28343-2-git-send-email-karl.beldan@gmail.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Karl Beldan Feb. 27, 2013, noon UTC
From: Karl Beldan <karl.beldan@rivierawaves.com>

Currently the mcs bitrates mask rate_idx_mcs_mask is only applied when
the pre-ht bitrates mask rate_idx_mask of the same band differs from the
default mask.
Fix it by comparing the rate_idx_mcs_mask with the ht_cap.mcs.rx_mask, the
copy of the rate_idx_mcs_mask is now done if the check succeeds.
This results, when no pre-ht bitrates is disabled && an mcs idx is, to
one more memcmp, otherwise the cost remains identical.

Signed-off-by: Karl Beldan <karl.beldan@rivierawaves.com>
---
 net/mac80211/rate.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Karl Beldan Feb. 27, 2013, 1:38 p.m. UTC | #1
On Wed, Feb 27, 2013 at 01:00:34PM +0100, Karl Beldan wrote:
> From: Karl Beldan <karl.beldan@rivierawaves.com>
> 
> Currently the mcs bitrates mask rate_idx_mcs_mask is only applied when
> the pre-ht bitrates mask rate_idx_mask of the same band differs from the
> default mask.
> Fix it by comparing the rate_idx_mcs_mask with the ht_cap.mcs.rx_mask, the
> copy of the rate_idx_mcs_mask is now done if the check succeeds.
> This results, when no pre-ht bitrates is disabled && an mcs idx is, to
> one more memcmp, otherwise the cost remains identical.
> 
> Signed-off-by: Karl Beldan <karl.beldan@rivierawaves.com>
> ---
>  net/mac80211/rate.c |    7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
> index cfbd7d5..4c0a14d 100644
> --- a/net/mac80211/rate.c
> +++ b/net/mac80211/rate.c
> @@ -460,8 +460,11 @@ void rate_control_get_rate(struct ieee80211_sub_if_data *sdata,
>  	 * the common case.
>  	 */
>  	mask = txrc->rate_idx_mask;
> -	memcpy(mcs_mask, txrc->rate_idx_mcs_mask, sizeof(mcs_mask));
> -	if (mask != (1 << txrc->sband->n_bitrates) - 1) {
> +	if (mask != (1 << txrc->sband->n_bitrates) - 1 ||
> +		memcmp(txrc->sband->ht_cap.mcs.rx_mask, txrc->rate_idx_mcs_mask,
> +		       sizeof(txrc->rate_idx_mcs_mask))) {
> +		memcpy(mcs_mask, txrc->rate_idx_mcs_mask, sizeof(mcs_mask));
> +
>  		if (sta) {
> 

I don't know why I refrained myself from getting rid of the copies of
the masks altogether.
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Johannes Berg March 4, 2013, 3:50 p.m. UTC | #2
On Wed, 2013-02-27 at 14:38 +0100, Karl Beldan wrote:

> >  	mask = txrc->rate_idx_mask;
> > -	memcpy(mcs_mask, txrc->rate_idx_mcs_mask, sizeof(mcs_mask));
> > -	if (mask != (1 << txrc->sband->n_bitrates) - 1) {
> > +	if (mask != (1 << txrc->sband->n_bitrates) - 1 ||
> > +		memcmp(txrc->sband->ht_cap.mcs.rx_mask, txrc->rate_idx_mcs_mask,
> > +		       sizeof(txrc->rate_idx_mcs_mask))) {
> > +		memcpy(mcs_mask, txrc->rate_idx_mcs_mask, sizeof(mcs_mask));
> > +
> >  		if (sta) {
> > 
> 
> I don't know why I refrained myself from getting rid of the copies of
> the masks altogether.

Are you going to resend?

johannes

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Karl Beldan March 4, 2013, 6:28 p.m. UTC | #3
On Mon, Mar 04, 2013 at 04:50:28PM +0100, Johannes Berg wrote:
> On Wed, 2013-02-27 at 14:38 +0100, Karl Beldan wrote:
> 
> > >  	mask = txrc->rate_idx_mask;
> > > -	memcpy(mcs_mask, txrc->rate_idx_mcs_mask, sizeof(mcs_mask));
> > > -	if (mask != (1 << txrc->sband->n_bitrates) - 1) {
> > > +	if (mask != (1 << txrc->sband->n_bitrates) - 1 ||
> > > +		memcmp(txrc->sband->ht_cap.mcs.rx_mask, txrc->rate_idx_mcs_mask,
> > > +		       sizeof(txrc->rate_idx_mcs_mask))) {
> > > +		memcpy(mcs_mask, txrc->rate_idx_mcs_mask, sizeof(mcs_mask));
> > > +
> > >  		if (sta) {
> > > 
> > 
> > I don't know why I refrained myself from getting rid of the copies of
> > the masks altogether.
> 
> Are you going to resend?
> 
Just did.

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
index cfbd7d5..4c0a14d 100644
--- a/net/mac80211/rate.c
+++ b/net/mac80211/rate.c
@@ -460,8 +460,11 @@  void rate_control_get_rate(struct ieee80211_sub_if_data *sdata,
 	 * the common case.
 	 */
 	mask = txrc->rate_idx_mask;
-	memcpy(mcs_mask, txrc->rate_idx_mcs_mask, sizeof(mcs_mask));
-	if (mask != (1 << txrc->sband->n_bitrates) - 1) {
+	if (mask != (1 << txrc->sband->n_bitrates) - 1 ||
+		memcmp(txrc->sband->ht_cap.mcs.rx_mask, txrc->rate_idx_mcs_mask,
+		       sizeof(txrc->rate_idx_mcs_mask))) {
+		memcpy(mcs_mask, txrc->rate_idx_mcs_mask, sizeof(mcs_mask));
+
 		if (sta) {
 			/* Filter out rates that the STA does not support */
 			mask &= sta->sta.supp_rates[info->band];