diff mbox

brcmfmac: fix setting primary channel for 80 MHz width

Message ID 1453304764-11895-1-git-send-email-zajec5@gmail.com (mailing list archive)
State Accepted
Delegated to: Kalle Valo
Headers show

Commit Message

Rafał Miłecki Jan. 20, 2016, 3:46 p.m. UTC
First of all it changes the way we calculate primary channel offset. If
we use e.g. 80 MHz channel with primary frequency 5180 MHz (which means
center frequency is 5210 MHz) it makes sense to calculate primary offset
as -30 MHz.
Then it fixes values we compare primary_offset with. We were comparing
offset in MHz against -2 or 2 which was resulting in picking a wrong
primary channel.

Signed-off-by: Rafa? Mi?ecki <zajec5@gmail.com>
---
 .../broadcom/brcm80211/brcmfmac/cfg80211.c         | 23 ++++++++++------------
 1 file changed, 10 insertions(+), 13 deletions(-)

Comments

Arend van Spriel Jan. 25, 2016, 9:54 a.m. UTC | #1
On 20-1-2016 16:46, Rafa? Mi?ecki wrote:
> First of all it changes the way we calculate primary channel offset. If
> we use e.g. 80 MHz channel with primary frequency 5180 MHz (which means
> center frequency is 5210 MHz) it makes sense to calculate primary offset
> as -30 MHz.
> Then it fixes values we compare primary_offset with. We were comparing
> offset in MHz against -2 or 2 which was resulting in picking a wrong
> primary channel.

Not sure about comparing explicit values here, but it looks fine by me.

Acked-by: Arend van Spriel <arend@broadcom.com>
> Signed-off-by: Rafa? Mi?ecki <zajec5@gmail.com>
> ---
>  .../broadcom/brcm80211/brcmfmac/cfg80211.c         | 23 ++++++++++------------
>  1 file changed, 10 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
> index 8d9cff4..2b335de 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
> @@ -247,7 +247,7 @@ static u16 chandef_to_chanspec(struct brcmu_d11inf *d11inf,
>  	brcmf_dbg(TRACE, "chandef: control %d center %d width %d\n",
>  		  ch->chan->center_freq, ch->center_freq1, ch->width);
>  	ch_inf.chnum = ieee80211_frequency_to_channel(ch->center_freq1);
> -	primary_offset = ch->center_freq1 - ch->chan->center_freq;
> +	primary_offset = ch->chan->center_freq - ch->center_freq1;
>  	switch (ch->width) {
>  	case NL80211_CHAN_WIDTH_20:
>  	case NL80211_CHAN_WIDTH_20_NOHT:
> @@ -256,24 +256,21 @@ static u16 chandef_to_chanspec(struct brcmu_d11inf *d11inf,
>  		break;
>  	case NL80211_CHAN_WIDTH_40:
>  		ch_inf.bw = BRCMU_CHAN_BW_40;
> -		if (primary_offset < 0)
> +		if (primary_offset > 0)
>  			ch_inf.sb = BRCMU_CHAN_SB_U;
>  		else
>  			ch_inf.sb = BRCMU_CHAN_SB_L;
>  		break;
>  	case NL80211_CHAN_WIDTH_80:
>  		ch_inf.bw = BRCMU_CHAN_BW_80;
> -		if (primary_offset < 0) {
> -			if (primary_offset < -CH_10MHZ_APART)
> -				ch_inf.sb = BRCMU_CHAN_SB_UU;
> -			else
> -				ch_inf.sb = BRCMU_CHAN_SB_UL;
> -		} else {
> -			if (primary_offset > CH_10MHZ_APART)
> -				ch_inf.sb = BRCMU_CHAN_SB_LL;
> -			else
> -				ch_inf.sb = BRCMU_CHAN_SB_LU;
> -		}
> +		if (primary_offset == -30)
> +			ch_inf.sb = BRCMU_CHAN_SB_LL;
> +		else if (primary_offset == -10)
> +			ch_inf.sb = BRCMU_CHAN_SB_LU;
> +		else if (primary_offset == 10)
> +			ch_inf.sb = BRCMU_CHAN_SB_UL;
> +		else
> +			ch_inf.sb = BRCMU_CHAN_SB_UU;
>  		break;
>  	case NL80211_CHAN_WIDTH_80P80:
>  	case NL80211_CHAN_WIDTH_160:
> 
--
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
Kalle Valo Feb. 6, 2016, 11:43 a.m. UTC | #2
Rafa? Mi?ecki <zajec5@gmail.com> writes:

> First of all it changes the way we calculate primary channel offset. If
> we use e.g. 80 MHz channel with primary frequency 5180 MHz (which means
> center frequency is 5210 MHz) it makes sense to calculate primary offset
> as -30 MHz.
> Then it fixes values we compare primary_offset with. We were comparing
> offset in MHz against -2 or 2 which was resulting in picking a wrong
> primary channel.
>
> Signed-off-by: Rafa? Mi?ecki <zajec5@gmail.com>

Manually applied to wireless-drivers-next.git, thanks.
diff mbox

Patch

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index 8d9cff4..2b335de 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -247,7 +247,7 @@  static u16 chandef_to_chanspec(struct brcmu_d11inf *d11inf,
 	brcmf_dbg(TRACE, "chandef: control %d center %d width %d\n",
 		  ch->chan->center_freq, ch->center_freq1, ch->width);
 	ch_inf.chnum = ieee80211_frequency_to_channel(ch->center_freq1);
-	primary_offset = ch->center_freq1 - ch->chan->center_freq;
+	primary_offset = ch->chan->center_freq - ch->center_freq1;
 	switch (ch->width) {
 	case NL80211_CHAN_WIDTH_20:
 	case NL80211_CHAN_WIDTH_20_NOHT:
@@ -256,24 +256,21 @@  static u16 chandef_to_chanspec(struct brcmu_d11inf *d11inf,
 		break;
 	case NL80211_CHAN_WIDTH_40:
 		ch_inf.bw = BRCMU_CHAN_BW_40;
-		if (primary_offset < 0)
+		if (primary_offset > 0)
 			ch_inf.sb = BRCMU_CHAN_SB_U;
 		else
 			ch_inf.sb = BRCMU_CHAN_SB_L;
 		break;
 	case NL80211_CHAN_WIDTH_80:
 		ch_inf.bw = BRCMU_CHAN_BW_80;
-		if (primary_offset < 0) {
-			if (primary_offset < -CH_10MHZ_APART)
-				ch_inf.sb = BRCMU_CHAN_SB_UU;
-			else
-				ch_inf.sb = BRCMU_CHAN_SB_UL;
-		} else {
-			if (primary_offset > CH_10MHZ_APART)
-				ch_inf.sb = BRCMU_CHAN_SB_LL;
-			else
-				ch_inf.sb = BRCMU_CHAN_SB_LU;
-		}
+		if (primary_offset == -30)
+			ch_inf.sb = BRCMU_CHAN_SB_LL;
+		else if (primary_offset == -10)
+			ch_inf.sb = BRCMU_CHAN_SB_LU;
+		else if (primary_offset == 10)
+			ch_inf.sb = BRCMU_CHAN_SB_UL;
+		else
+			ch_inf.sb = BRCMU_CHAN_SB_UU;
 		break;
 	case NL80211_CHAN_WIDTH_80P80:
 	case NL80211_CHAN_WIDTH_160: