Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gluon-core: fixes wifi on mediatek-mt7622 through a fallback of renamed wireless phys #3430

Closed
wants to merge 1 commit into from

Conversation

maurerle
Copy link
Member

@maurerle maurerle commented Jan 22, 2025

tested on a Netgear WAX206

though I think that backporting the commit which fixes renaming of phy devices might fix this as well:
openwrt/openwrt@ed34e33
(No, the files do not exist on openwrt-24.10)

@RolandoMagico can you test my PR on your device as well?

Maybe there is a better way to do this, but this is just a quick fix to get things working again.

iwinfo.nl80211.phyname(config['.name']:gsub("radio", "phy")) returns phy0 again.

On my device iwinfo phy0 htmodelist shows correct values, while

root@ffac-000c43266078:~# uci show wireless
wireless.radio0=wifi-device
wireless.radio0.type='mac80211'
wireless.radio0.phy='wl0'
wireless.radio0.band='2g'
wireless.radio0.channel='11'
wireless.radio0.htmode='HT20'
wireless.radio0.country='DE'
wireless.radio0.legacy_rates='0'
wireless.radio1=wifi-device
wireless.radio1.type='mac80211'
wireless.radio1.phy='wl1'
wireless.radio1.band='5g'
wireless.radio1.channel='44'
wireless.radio1.htmode='HE20'
wireless.radio1.country='DE'

@github-actions github-actions bot added the 3. topic: package Topic: Gluon Packages label Jan 22, 2025
@maurerle maurerle changed the title gluon-core: this fixes the mediatek-mt7622 issue with renaming wireless phys gluon-core: fixes the mediatek-mt7622 issue with renaming wireless phys Jan 22, 2025
@maurerle maurerle changed the title gluon-core: fixes the mediatek-mt7622 issue with renaming wireless phys gluon-core: fixes wifi on mediatek-mt7622 through a fallback of renamed wireless phys Jan 22, 2025
@rotanid rotanid added 3. topic: hardware Topic: Hardware Support 0. type: bugfix This changeset fixes abug labels Jan 23, 2025
@maurerle
Copy link
Member Author

@neocturne could you take a look at this, please?

A fix like this is required for #3431 and #3332

@RolandoMagico
Copy link
Contributor

@maurerle: Thanks for the PR. Wifi setttings are now available in config mode and Wifi also works in normal mode on my R32

return iwinfo.nl80211.phyname(config['.name'])
local phyname = iwinfo.nl80211.phyname(config['.name'])
if not phyname then
phyname = iwinfo.nl80211.phyname(config['.name']:gsub("radio", "phy"))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same as:
phyname = config['.name']:gsub("radio", "phy")

Though such a fallback was not necessary on openwrt

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHY and radio numbering should be considered unrelated, there is no guarantee that PHY numbers don't change (on upgrades or possibly reboots).

I believe that this must be fixed in iwinfo itself.

Copy link
Member Author

@maurerle maurerle Jan 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, that something goes wrong here:
https://github.com/openwrt/openwrt/blob/1e9966a63ae430a5c48039fd9752bf1c465325f3/package/network/config/wifi-scripts/files/lib/netifd/wireless/mac80211.sh#L619

As I think I saw the Could not find PHY for device .. message in logread or something similar, which is issued by find_phy

Though this fix is something to get things going, which might help in finding a proper fix

Copy link
Member Author

@maurerle maurerle Jan 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is this is the logread at boot:

Thu Jan 23 04:39:30 2025 daemon.notice netifd: radio1 (2778): Command failed: Not found
Thu Jan 23 04:39:30 2025 daemon.notice hostapd: Set new config for phy wl0:
Thu Jan 23 04:39:30 2025 daemon.notice netifd: radio0 (2774): Command failed: Not found
Thu Jan 23 04:39:31 2025 daemon.notice hostapd: Set new config for phy wl0: /var/run/hostapd-wl0.conf
Thu Jan 23 04:39:31 2025 daemon.notice hostapd: Restart interface for phy wl0
Thu Jan 23 04:39:31 2025 daemon.notice hostapd: Configuration file: data: driver=nl80211 logger_syslog=127 logger_syslog_level=2 logger_stdout=127 logger_stdout_level=2 country_code=DE ieee80211d=1 hw_mode=g supported_rates=60 90 120 180 240 360 480 540 basic_rates=60 120 240 beacon_int=100 stationary_ap=1 chanlist=11 noscan=1 #num_global_macaddr=1 #macaddr_base= ieee80211n=1 ht_coex=0 ht_capab=[LDPC][SHORT-GI-20][SHORT-GI-40][TX-STBC][RX-STBC1] channel=11  interface=client0 bssid=72:90:4e:18:f7:30 ctrl_interface=/var/run/hostapd ap_isolate=1 bss_load_update_period=60 chan_util_avg_period=600 disassoc_low_ack=1 skip_inactivity_poll=0 preamble=1 wmm_enabled=1 ignore_broadcast_ssid=0 uapsd_advertisement_enabled=1 utf8_ssid=1 multi_ap=0 auth_algs=1 wpa=0 ssid=Freifunk bridge=br-client wds_bridge= snoop_iface=br-client qos_map_set=0,0,2,16,1,1,255,255,18,22,24,38,40,40,44,46,48,56 nas_identifier=72904e18f730  (phy wl0) --> new PHY
Thu Jan 23 04:39:31 2025 daemon.notice hostapd: Set new config for phy wl1: /var/run/hostapd-wl1.conf
Thu Jan 23 04:39:31 2025 daemon.notice hostapd: Restart interface for phy wl1

Does this help somehow @neocturne ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The iface_update_supplicant_macaddr call on reload was added in
openwrt/openwrt@20c667c

I think that this is what causes the "Not found" error and probably is the root cause of this issue, why reloading fails.

Eventually this is a different error, as I do not really see, how this impacts that the renaming fails

@maurerle
Copy link
Member Author

maurerle commented Jan 26, 2025

Alternatively to this PR, one can run:

. /lib/netifd/wireless/mac80211.sh 
phy=wl0
find_phy
phy=wl1
find_phy
gluon-reconfigure

in config-mode.
This manually triggers the renaming, after which everything works as expected

I don't know why this is skipped in gluon, while it runs in openwrt.
find_phy should be running in drv_mac80211_setup

EDIT: I did run service wpad start before in configmode, though I do not know if this is required (or maybe is the reason why this was not run before..?)

@neocturne
Copy link
Member

Alternatively, one can run:

. /lib/netifd/wireless/mac80211.sh 
phy=wl0
find_phy
phy=wl1
find_phy
gluon-reconfigure

in config-mode. This manually triggers the renaming, after which everything works as expected

Interesting. We'll have to check if it makes sense to duplicate more code from the shell script in Gluon, or what a good place to run the shell script is.

@maurerle
Copy link
Member Author

Normally, the find_phy funciton is called in drv_mac80211_setup in mac80211.sh - I did not find any occurance, where this is called.
Do you know how this works @neocturne ? How does this work for gluon in contrast?

@maurerle
Copy link
Member Author

The board.json of the Netgear WAX 206 is given here:

{
	"model": {
		"id": "netgear,wax206",
		"name": "Netgear WAX206"
	},
	"led": {
		"wan": {
			"name": "WAN",
			"sysfs": "inet:blue",
			"type": "netdev",
			"device": "wan",
			"mode": "link tx rx"
		}
	},
	"network": {
		"lan": {
			"ports": [
				"lan1",
				"lan2",
				"lan3",
				"lan4"
			],
			"protocol": "static"
		},
		"wan": {
			"device": "wan",
			"protocol": "dhcp"
		}
	},
	"wlan": {
		"wl0": {
			"path": "platform/18000000.wmac",
			"info": {
				"antenna_rx": 15,
				"antenna_tx": 15,
				"bands": {
					"2G": {
						"ht": true,
						"max_width": 40,
						"modes": [
							"NOHT",
							"HT20",
							"HT40"
						],
						"default_channel": 1
					}
				},
				"radios": [
				]
			}
		},
		"wl1": {
			"path": "1a143000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0",
			"info": {
				"antenna_rx": 15,
				"antenna_tx": 15,
				"bands": {
					"5G": {
						"ht": true,
						"vht": true,
						"he": true,
						"max_width": 160,
						"modes": [
							"NOHT",
							"HT20",
							"VHT20",
							"HE20",
							"HT40",
							"VHT40",
							"HE40",
							"VHT80",
							"HE80",
							"HE160"
						],
						"default_channel": 36
					}
				},
				"radios": [
				]
			}
		},
		"wl2": {
			"path": "1a145000.pcie/pci0001:00/0001:00:01.0/0001:01:00.0"
		}
	}
}

@rotanid
Copy link
Member

rotanid commented Feb 3, 2025

will be fixed with openwrt/openwrt#17821 probably

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0. type: bugfix This changeset fixes abug 3. topic: hardware Topic: Hardware Support 3. topic: package Topic: Gluon Packages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants