diff options
| author | Christian Breunig <christian@breunig.cc> | 2026-05-21 08:18:08 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-21 08:18:08 +0200 |
| commit | a367f7adc56ac01cd6ef7db93564d53b48bb2610 (patch) | |
| tree | 28e03341c64c1c80aa47c12ba475b14eab824810 /src | |
| parent | d8aab03bc85d9a01289bd400dee256ca8647f032 (diff) | |
| parent | c66ac79a1308f1dc7dd8ecf7466ba2ad648176e9 (diff) | |
| download | vyos-1x-a367f7adc56ac01cd6ef7db93564d53b48bb2610.tar.gz vyos-1x-a367f7adc56ac01cd6ef7db93564d53b48bb2610.zip | |
Merge pull request #5135 from alainlamar/T8528
wireless: T8528: Add module config code for mt7916 based cards
Diffstat (limited to 'src')
| -rwxr-xr-x | src/conf_mode/interfaces_wireless.py | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/src/conf_mode/interfaces_wireless.py b/src/conf_mode/interfaces_wireless.py index e1a2b22bf..68aa71474 100755 --- a/src/conf_mode/interfaces_wireless.py +++ b/src/conf_mode/interfaces_wireless.py @@ -36,10 +36,14 @@ from vyos.ifconfig import WiFiIf from vyos.template import render from vyos.utils.dict import dict_search from vyos.utils.kernel import check_kmod +from vyos.utils.kernel import is_module_loaded +from vyos.utils.file import read_file +from vyos.utils.file import write_file from vyos.utils.process import call from vyos.utils.process import is_systemd_service_active from vyos.utils.process import is_systemd_service_running from vyos.utils.network import interface_exists +from vyos.base import Warning from vyos import ConfigError from vyos import airbag airbag.enable() @@ -50,6 +54,8 @@ hostapd_conf = '/run/hostapd/{ifname}.conf' hostapd_accept_station_conf = '/run/hostapd/{ifname}_station_accept.conf' hostapd_deny_station_conf = '/run/hostapd/{ifname}_station_deny.conf' +mt7915e_conf = f'/etc/modprobe.d/mt7915e.conf' + country_code_path = ['system', 'wireless', 'country-code'] def find_other_stations(conf, base, ifname): @@ -232,7 +238,9 @@ def verify(wifi): phy = wifi['physical_device'] if phy in wifi['station_interfaces']: if len(wifi['station_interfaces'][phy]) > 0: - raise ConfigError('Only one station per wireless physical interface possible!') + raise ConfigError( + 'Only one station per wireless physical interface possible!' + ) verify_address(wifi) verify_vrf(wifi) @@ -320,6 +328,54 @@ def apply(wifi): w = WiFiIf(**wifi) w.update(wifi) + # Set up the mt7915e module according to new wifi configuration. + # For this card, the decision is made for the 5GHz/6GHz-capable phy: + # 5GHz uses VHT (802.11ac) op_modes and 6GHz uses HE (802.11ax) + # op_modes. The card does not support WiFi-7 (802.11be). + # There is a race condition in the order the two phys on that card + # are configured. Sometimes, the 5/6GHz phy is configured first and + # the 2.4GHz phy is configured last, which would overwrite the module + # parameter definition. Only the Wi-Fi configuration for the 5/6GHz phy + # must write the file! + # + # Only if the mt7915e module is loaded (card present)... + if is_module_loaded('mt7915e'): + # op_modes as configured in interfaces_wireless.xml.in + five_ghz_op_modes_vht = ['0', '1', '2', '3'] + six_ghz_op_modes_he = ['131', '132', '133', '134', '135'] + # Make sure to act only when VHT or HE modes are used + module_options = '' + if 'capabilities' in wifi: + mt7915e_options_string = 'options mt7915e' + if 'he' in wifi['capabilities']: + if 'channel_set_width' in wifi['capabilities']['he']: + if wifi['capabilities']['he']['channel_set_width'] in six_ghz_op_modes_he: + # 6GHz band required (802.11ax, WiFi-6e) + module_options = f'{mt7915e_options_string} enable_6ghz=1' + if 'vht' in wifi['capabilities']: + if 'channel_set_width' in wifi['capabilities']['vht']: + if wifi['capabilities']['vht']['channel_set_width'] in five_ghz_op_modes_vht: + # 5GHz band required... + module_options = f'{mt7915e_options_string} enable_6ghz=0' + + tmp = None + if os.path.isfile(mt7915e_conf): + tmp = read_file(mt7915e_conf) + + # Write the module config, so that there always is a valid module + # config which is mandatory to load the mt7916 firmware. + write_file(mt7915e_conf, module_options, mode=0o644) + # Issue warning if module options have changed. Warning is necessary + # even if this is the first time this module is configured, + # firmware must be reloaded. + if tmp != module_options: + Warning('Change to firmware 5GHz/6GHz configuration detected. '\ + 'The system must be rebooted to correctly reload the ' \ + 'mt7916 firmware. The card will not work otherwise!') + # Instead of reboot - can we unload and re-load the driver? + elif os.path.isfile(mt7915e_conf): + os.remove(mt7915e_conf) + # Enable/Disable interface - interface is always placed in # administrative down state in WiFiIf class if 'disable' not in wifi: |
