2014-01-17 16:18:12

by Zhao, Gang

[permalink] [raw]
Subject: [PATCH v4 1/2] b43: fix the wrong assignment of status.freq in b43_rx()

Use the right function to update frequency value.

If rx skb is probe response or beacon, the wrong frequency value can
cause problem that bss info can't be updated when it should be.

Cc: <[email protected]>
Fixes: 8318d78a44d4 ("cfg80211 API for channels/bitrates, mac80211
and driver conversion")
Signed-off-by: ZHAO Gang <[email protected]>
---
v4: change commit message
suggested by Johannes Berg

drivers/net/wireless/b43/xmit.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/b43/xmit.c b/drivers/net/wireless/b43/xmit.c
index 4ae63f4..50e5ddb 100644
--- a/drivers/net/wireless/b43/xmit.c
+++ b/drivers/net/wireless/b43/xmit.c
@@ -821,10 +821,10 @@ void b43_rx(struct b43_wldev *dev, struct sk_buff *skb, const void *_rxhdr)
* channel number in b43. */
if (chanstat & B43_RX_CHAN_5GHZ) {
status.band = IEEE80211_BAND_5GHZ;
- status.freq = b43_freq_to_channel_5ghz(chanid);
+ status.freq = b43_channel_to_freq_5ghz(chanid);
} else {
status.band = IEEE80211_BAND_2GHZ;
- status.freq = b43_freq_to_channel_2ghz(chanid);
+ status.freq = b43_channel_to_freq_2ghz(chanid);
}
break;
default:
--
1.8.4.2



2014-01-26 14:35:43

by Rafał Miłecki

[permalink] [raw]
Subject: Re: [PATCH v4 1/2] b43: fix the wrong assignment of status.freq in b43_rx()

2014/1/17 ZHAO Gang <[email protected]>:
> Use the right function to update frequency value.
>
> If rx skb is probe response or beacon, the wrong frequency value can
> cause problem that bss info can't be updated when it should be.

Zhao: this fix is great. My development machine was running some
ancient distro with kernel 2.6.22, so I couldn't test it earlier.

For a long time I got problem with finding AP on channel 13. I reported it in:
cfg80211: use DS or HT operation IEs to determine BSS channel"

I did 10 tests *without* your patch. wpa_supplicant had to scan 43,
33, 7, 2, 46, 12, 7, 32, 6, 6 times to find my AP on channel 13.
With your patch wpa_supplicant finds it in scanning results after the first try!

Thanks a lot for finding and fixing it!

[0] http://lists.infradead.org/pipermail/b43-dev/2013-March/003003.html

2014-01-17 16:18:21

by Zhao, Gang

[permalink] [raw]
Subject: [PATCH v4 2/2] b43: use kernel api to replace b43 specific helper function

Use ieee80211_channel_to_frequency() to replace b43_channel_to_freq_{2,5}ghz(),
and remove unused b43_freq_to_channel_{2,5}ghz().

Signed-off-by: ZHAO Gang <[email protected]>
---
v4: bump version to consistent with first patch.

drivers/net/wireless/b43/main.h | 35 -----------------------------------
drivers/net/wireless/b43/xmit.c | 12 ++++++------
2 files changed, 6 insertions(+), 41 deletions(-)

diff --git a/drivers/net/wireless/b43/main.h b/drivers/net/wireless/b43/main.h
index abac25e..f476fc3 100644
--- a/drivers/net/wireless/b43/main.h
+++ b/drivers/net/wireless/b43/main.h
@@ -58,41 +58,6 @@ enum b43_verbosity {
#endif
};

-
-/* Lightweight function to convert a frequency (in Mhz) to a channel number. */
-static inline u8 b43_freq_to_channel_5ghz(int freq)
-{
- return ((freq - 5000) / 5);
-}
-static inline u8 b43_freq_to_channel_2ghz(int freq)
-{
- u8 channel;
-
- if (freq == 2484)
- channel = 14;
- else
- channel = (freq - 2407) / 5;
-
- return channel;
-}
-
-/* Lightweight function to convert a channel number to a frequency (in Mhz). */
-static inline int b43_channel_to_freq_5ghz(u8 channel)
-{
- return (5000 + (5 * channel));
-}
-static inline int b43_channel_to_freq_2ghz(u8 channel)
-{
- int freq;
-
- if (channel == 14)
- freq = 2484;
- else
- freq = 2407 + (5 * channel);
-
- return freq;
-}
-
static inline int b43_is_cck_rate(int rate)
{
return (rate == B43_CCK_RATE_1MB ||
diff --git a/drivers/net/wireless/b43/xmit.c b/drivers/net/wireless/b43/xmit.c
index 50e5ddb..218a0f3 100644
--- a/drivers/net/wireless/b43/xmit.c
+++ b/drivers/net/wireless/b43/xmit.c
@@ -806,7 +806,8 @@ void b43_rx(struct b43_wldev *dev, struct sk_buff *skb, const void *_rxhdr)
B43_WARN_ON(1);
/* FIXME: We don't really know which value the "chanid" contains.
* So the following assignment might be wrong. */
- status.freq = b43_channel_to_freq_5ghz(chanid);
+ status.freq =
+ ieee80211_channel_to_frequency(chanid, status.band);
break;
case B43_PHYTYPE_G:
status.band = IEEE80211_BAND_2GHZ;
@@ -819,13 +820,12 @@ void b43_rx(struct b43_wldev *dev, struct sk_buff *skb, const void *_rxhdr)
case B43_PHYTYPE_HT:
/* chanid is the SHM channel cookie. Which is the plain
* channel number in b43. */
- if (chanstat & B43_RX_CHAN_5GHZ) {
+ if (chanstat & B43_RX_CHAN_5GHZ)
status.band = IEEE80211_BAND_5GHZ;
- status.freq = b43_channel_to_freq_5ghz(chanid);
- } else {
+ else
status.band = IEEE80211_BAND_2GHZ;
- status.freq = b43_channel_to_freq_2ghz(chanid);
- }
+ status.freq =
+ ieee80211_channel_to_frequency(chanid, status.band);
break;
default:
B43_WARN_ON(1);
--
1.8.4.2


2014-01-17 22:18:10

by Larry Finger

[permalink] [raw]
Subject: Re: [PATCH v4 1/2] b43: fix the wrong assignment of status.freq in b43_rx()

On 01/17/2014 10:17 AM, ZHAO Gang wrote:
> Use the right function to update frequency value.
>
> If rx skb is probe response or beacon, the wrong frequency value can
> cause problem that bss info can't be updated when it should be.
>
> Cc: <[email protected]>
> Fixes: 8318d78a44d4 ("cfg80211 API for channels/bitrates, mac80211
> and driver conversion")
> Signed-off-by: ZHAO Gang <[email protected]>
> ---

This patch seems to fix a problem that caused scanning under NetworkManager to
fail. The symptom was that no available networks were seen in the NM applet
after a connection was made. Now the available AP list remains populated.

Acked-by: Larry Finger <[email protected]>

Larry