2022-11-30 21:25:04

by Bruno Dantas

[permalink] [raw]
Subject: every other wireless scan shows bogus (too low) signal strengths

I have an X230 ThinkPad with coreboot and Intel Dual Band Wireless-AC 7265 card, which uses the iwlwifi kernel module. Module's wifi power saving is off (the default setting).

When I scan for wifi hotspots at the command line, every other scan gives me bogus (too low) signal strengths and every other scan gives me expected signal strengths:

bruno@x230:~$ sudo iw dev wlan0 scan flush | grep -e 'signal:' -e 'SSID:' | head -10
signal: -69.00 dBm
SSID: donkey_2.4GHz
signal: -81.00 dBm
SSID: donkey_5GHz
signal: -79.00 dBm
SSID: Spencer
signal: -80.00 dBm
SSID: wattslolahome
signal: -82.00 dBm
SSID: wattslolahome-guest
bruno@x230:~$ sudo iw dev wlan0 scan flush | grep -e 'signal:' -e 'SSID:' | head -10
signal: -42.00 dBm
SSID: donkey_2.4GHz
signal: -64.00 dBm
SSID: donkey_5GHz
signal: -80.00 dBm
SSID: Spencer
signal: -80.00 dBm
SSID: wattslolahome
signal: -84.00 dBm
SSID: wattslolahome-guest
bruno@x230:~$ sudo iw dev wlan0 scan flush | grep -e 'signal:' -e 'SSID:' | head -10
signal: -69.00 dBm
SSID: donkey_2.4GHz
signal: -78.00 dBm
SSID: donkey_5GHz
signal: -80.00 dBm
SSID: Spencer
signal: -80.00 dBm
SSID: wattslolahome
signal: -84.00 dBm
SSID: wattslolahome-guest
bruno@x230:~$ sudo iw dev wlan0 scan flush | grep -e 'signal:' -e 'SSID:' | head -10
signal: -43.00 dBm
SSID: donkey_2.4GHz
signal: -61.00 dBm
SSID: donkey_5GHz
signal: -79.00 dBm
SSID: Spencer
signal: -80.00 dBm
SSID: wattslolahome
signal: -82.00 dBm
SSID: wattslolahome-guest
etc.

The problem is distro-agnostic (I use Devuan x86_64 and Tiny Core Linux x86_64 and both are affected). Problem is not specific to iw (if I scan with iwlist I see a similar pattern). The pattern is always the same: First scan after a fresh boot is always bad, second one is good, etc.

Does anyone know why this happens and how to fix it so that every scan shows the expected signal strengths?


2022-12-01 08:00:33

by Johannes Berg

[permalink] [raw]
Subject: Re: every other wireless scan shows bogus (too low) signal strengths

On Wed, 2022-11-30 at 16:19 -0500, Bruno Dantas wrote:
> I have an X230 ThinkPad with coreboot and Intel Dual Band Wireless-AC
> 7265 card, which uses the iwlwifi kernel module. Module's wifi power
> saving is off (the default setting).
>
> When I scan for wifi hotspots at the command line, every other scan
> gives me bogus (too low) signal strengths and every other scan gives
> me expected signal strengths:

> [...]

> Does anyone know why this happens and how to fix it so that every scan shows the expected signal strengths?
>

I think this NIC might be switching antennas for scan every time.

If you're able to open it, it might be a good idea to check if they're
both connected well, almost seems like one might not be connected quite
correctly?

Not sure I have any better idea.

You could record debug data with trace-cmd [1] and then at least we
could confirm this is the case.

johannes

[1]
https://wireless.wiki.kernel.org/en/users/drivers/iwlwifi/debugging#tracing

2022-12-01 20:07:26

by Bruno Dantas

[permalink] [raw]
Subject: Re: every other wireless scan shows bogus (too low) signal strengths

Hi, Johannes. Thank you for your help.

To exclude a bad network card, I replaced my laptop's card with a different one (with the same Intel AC 7265 chipset). The replacement card fared no better. Therefore, I put the original card back and ensured that the two antenna wires are securely connected. There is no doubt now that the wires are secure, but the problem persists.

Unfortunately I cannot seem to make trace-cmd work:

bruno@x230:~$ sudo trace-cmd record -e iwlwifi
trace-cmd: No such file or directory
No events enabled with iwlwifi
bruno@x230:~$ sudo trace-cmd record -e iwlwifi -e mac80211 -e cfg80211 -e iwlwifi_msg
trace-cmd: No such file or directory
No events enabled with iwlwifi

Perhaps the iwlwifi kernel module was not configured to allow this operation? I found this line in my kernel's configuration:

$ cat /boot/config-5.10.0-9-amd64
---snip---
# CONFIG_IWLWIFI_DEVICE_TRACING is not set
---snip---

Oh, well. This is proving to be a tough nut to crack. My workaround for the time being is to discard every other wifi hotspot scan. Since my minimalistic laptop only performs wifi scans in one shell script, this is easy to achieve:

iw dev wlan0 scan flush >/dev/null
iw dev wlan0 scan flush >/tmp/scan_results.txt

It's a kludge alright, but it will tide me over until I figure out what the real problem is (if ever).

-Bruno

2022-12-02 07:39:05

by Julian Calaby

[permalink] [raw]
Subject: Re: every other wireless scan shows bogus (too low) signal strengths

Hi Bruno,

On Fri, Dec 2, 2022 at 7:08 AM Bruno Dantas <[email protected]> wrote:
>
> Hi, Johannes. Thank you for your help.
>
> To exclude a bad network card, I replaced my laptop's card with a different one (with the same Intel AC 7265 chipset). The replacement card fared no better. Therefore, I put the original card back and ensured that the two antenna wires are securely connected. There is no doubt now that the wires are secure, but the problem persists.

Stupid question, is there any chance that one of the antennas is damaged?

You might get slightly different behaviour if you swap them - if your
X230 is anything like my X200, there should be enough slack do that.

If it turns out that one of them is bad, you might be able to find
replacements on eBay or Aliexpress, or in the worst case scenario just
install a generic antenna.

Hardware Maintenance Manual is here:
https://support.lenovo.com/us/en/manuals/um014928-hardware-maintenance-manual
and the steps to replace the antennas don't look too onerous.

Thanks,

--
Julian Calaby

Email: [email protected]
Profile: http://www.google.com/profiles/julian.calaby/

2022-12-02 15:27:23

by Bruno Dantas

[permalink] [raw]
Subject: Re: every other wireless scan shows bogus (too low) signal strengths

Hi, Julian.

> Stupid question, is there any chance that one of the antennas is damaged?
As best as I can tell, both antennas (black and gray wires) are intact.

> You might get slightly different behaviour if you swap them - if your
> X230 is anything like my X200, there should be enough slack do that.
Good idea, so I gave it a shot. Alas, behavior is the same when I swap the black and gray antennas.

I have a stash of these Intel AC 7265 half-height mini PCIe WiFi adapters, so thought I'd try yet another one. Interestingly, with the third adapter the behavior is worse: Every scan gives me the spuriously low signal strengths. I put my original adapter back in, of course.

Maybe doing a wifi network scan requires more power than just authenticating with an AP and using the network? And maybe my after-market 802.11ac adapter requires a bit more power than the 802.11n adapters that were around when this laptop was made? If so, maybe it takes this old laptop's PCI bus two attempts before the 802.11ac adapter has enough power to do an accurate network scan? That's a lot of maybes, but it's my best guess given the behavior I'm observing.

I'm ready to give up on troubleshooting this (for now, anyway). I can live with my workaround of discarding every other network scan result.

Thank you guys for your help.

2023-01-19 19:34:30

by Johannes Berg

[permalink] [raw]
Subject: Re: every other wireless scan shows bogus (too low) signal strengths

On Fri, 2022-12-02 at 10:21 -0500, Bruno Dantas wrote:
>
> Maybe doing a wifi network scan requires more power than just
> authenticating with an AP and using the network? And maybe my after-
> market 802.11ac adapter requires a bit more power than the 802.11n
> adapters that were around when this laptop was made? If so, maybe it
> takes this old laptop's PCI bus two attempts before the 802.11ac
> adapter has enough power to do an accurate network scan? That's a lot
> of maybes, but it's my best guess given the behavior I'm observing.
>

FWIW - and sorry I didn't get around to answering here earlier - that
doesn't really make a lot of sense - we're talking about the report of
"received signal strength", which is pretty much unrelated to the power
you need to actually receive.

But as to what's actually going on I still have no clue either, sorry.

johannes

2023-01-19 20:29:38

by Bruno Dantas

[permalink] [raw]
Subject: Re: every other wireless scan shows bogus (too low) signal strengths

Thank you for getting back to me, Johannes. My hypothesis was a wild guess based on almost no evidence, so I'm not surprised that it was totally wrong :)

Despite remaining unexplained, the behavior is perfectly consistent. Plus, my system is very minimalistic (e.g., there is no network manager, all network scans are explicitly initiated by me, I only use iw for scans). Because of this, I wrote a wrapper script around iw. If action is anything other than scan, the script bails out and passes all arguments to the iw executable. If action is scan, script does a disposable scan then passes all arguments to the iw executable. It's ugly as heck but I can live with it.

Happy hacking,
Bruno