<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>mafm's musings - planet-igalia</title><link href="https://blogs.igalia.com/mafm/" rel="alternate"></link><link href="https://blogs.igalia.com/mafm/feeds/planet-igalia.atom.xml" rel="self"></link><id>https://blogs.igalia.com/mafm/</id><updated>2024-05-15T11:21:46+02:00</updated><entry><title>WiFi back-ends in SteamOS 3.6</title><link href="https://blogs.igalia.com/mafm/wifi-back-ends-in-steamos-36.html" rel="alternate"></link><published>2024-05-15T11:21:46+02:00</published><updated>2024-05-15T11:21:46+02:00</updated><author><name>Manuel A. Fernandez Montecelo</name></author><id>tag:blogs.igalia.com,2024-05-15:/mafm/wifi-back-ends-in-steamos-36.html</id><summary type="html">&lt;p&gt;WiFi back-ends in SteamOS 3.6 as of 2024-05&lt;/p&gt;</summary><content type="html">&lt;!-- Slug: steamos-wifi-backend --&gt;

&lt;p&gt;As of &lt;code&gt;NetworkManager&lt;/code&gt; v1.46.0 (and a very long while before that, since
1.12 released in 2018), there are &lt;a href="https://www.networkmanager.dev/docs/api/1.46.0/NetworkManager.conf.html#wifi.backend"&gt;two wifi.backend's
supported&lt;/a&gt;:
&lt;code&gt;wpa_supplicant&lt;/code&gt; (default), and &lt;code&gt;iwd&lt;/code&gt; (experimental).&lt;/p&gt;
&lt;p&gt;&lt;code&gt;iwd&lt;/code&gt; is still considered experimental after these years, see the
&lt;a href="https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues?scope=all&amp;amp;utf8=%E2%9C%93&amp;amp;state=opened&amp;amp;search=iwd"&gt;list of issues with &lt;code&gt;iwd&lt;/code&gt;
backend&lt;/a&gt;,
and &lt;a href="https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1456"&gt;specially this
one&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In &lt;a href="https://en.wikipedia.org/wiki/SteamOS"&gt;SteamOS&lt;/a&gt;, however, the
default is &lt;code&gt;iwd&lt;/code&gt;.  It works relatively well in most scenarios; and the
main advantage is that, when waking up the device (think of Steam Deck
returning from sleep, "suspended to RAM" or &lt;code&gt;S3&lt;/code&gt; sleeping state), it
regains network connectivity much faster -- typically 1-2 seconds
vs. 5+ for &lt;code&gt;wpa_supplicant&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;However, if for some reason &lt;code&gt;iwd&lt;/code&gt; doesn't work properly in your case,
you can give &lt;code&gt;wpa_supplicant&lt;/code&gt; a try.&lt;/p&gt;
&lt;h3&gt;With &lt;code&gt;steamos-wifi-set-backend&lt;/code&gt; command&lt;/h3&gt;
&lt;p&gt;In 3.6, the back-end can be changed via command.&lt;/p&gt;
&lt;p&gt;3.6 has been available in &lt;code&gt;Main&lt;/code&gt; channel since late March and in
&lt;code&gt;Beta&lt;/code&gt;/&lt;code&gt;Preview&lt;/code&gt; for several days, for example &lt;code&gt;20240509.100&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If you haven't done this before, to be able to run it, one must be
able to either log in via SSH (not available out of the box), or to
switch to desktop-mode, open a terminal and be able to type commands.&lt;/p&gt;
&lt;p&gt;Assuming that one wants to change from the default &lt;code&gt;iwd&lt;/code&gt; to
&lt;code&gt;wpa_supplicant&lt;/code&gt;, the command is:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;steamos-wifi-set-backend wpa_supplicant
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The script tries to ensure than things are in place in terms of some
systemd units being stopped and others brought up as appropriate.
After a few seconds, if it's able to connect correctly to the WiFi
network, the device should get connectivity (e.g. ping works).  It is
not necessary to enter again the preferred networks and passwords,
&lt;code&gt;NetworkManager&lt;/code&gt; feeds the back-ends with the necessary config and
credentials.&lt;/p&gt;
&lt;p&gt;It is possible to switch back and forth between back-ends by using
alternatively &lt;code&gt;iwd&lt;/code&gt; and &lt;code&gt;wpa_supplicant&lt;/code&gt; as many times as desired, and
without restarting the system.&lt;/p&gt;
&lt;p&gt;The current back-end as per configuration can be obtained with:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;steamos-wifi-set-backend --check
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;And finally, this is the output of changing to &lt;code&gt;wpa_supplicant&lt;/code&gt; and
back to &lt;code&gt;iwd&lt;/code&gt; (i.e., the output that you should expect):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="gp gp-VirtualEnv"&gt;(deck@steamdeck ~)&lt;/span&gt;&lt;span class="gp"&gt;$ &lt;/span&gt;steamos-wifi-set-backend&lt;span class="w"&gt; &lt;/span&gt;--check
&lt;span class="go"&gt;iwd&lt;/span&gt;

&lt;span class="gp gp-VirtualEnv"&gt;(deck@steamdeck ~)&lt;/span&gt;&lt;span class="gp"&gt;$ &lt;/span&gt;steamos-wifi-set-backend&lt;span class="w"&gt; &lt;/span&gt;wpa_supplicant
&lt;span class="go"&gt;INFO: switching back-end to &amp;#39;wpa_supplicant&amp;#39;&lt;/span&gt;
&lt;span class="go"&gt;INFO: stopping old back-end service and restarting NetworkManager,&lt;/span&gt;
&lt;span class="go"&gt;      networking will be disrupted (hopefully only momentary blip, max 10 seconds)...&lt;/span&gt;
&lt;span class="go"&gt;INFO: restarting done&lt;/span&gt;
&lt;span class="go"&gt;INFO: checking status of services ...&lt;/span&gt;
&lt;span class="go"&gt;      (sleeping for 2 seconds to catch-up with state)&lt;/span&gt;
&lt;span class="go"&gt;INFO: status OK&lt;/span&gt;

&lt;span class="gp gp-VirtualEnv"&gt;(deck@steamdeck ~)&lt;/span&gt;&lt;span class="gp"&gt;$ &lt;/span&gt;steamos-wifi-set-backend&lt;span class="w"&gt; &lt;/span&gt;--check
&lt;span class="go"&gt;wpa_supplicant&lt;/span&gt;

&lt;span class="gp gp-VirtualEnv"&gt;(deck@steamdeck ~)&lt;/span&gt;&lt;span class="gp"&gt;$ &lt;/span&gt;ping&lt;span class="w"&gt; &lt;/span&gt;-c&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;.1.1.1
&lt;span class="go"&gt;PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.&lt;/span&gt;
&lt;span class="go"&gt;64 bytes from 1.1.1.1: icmp_seq=1 ttl=56 time=16.4 ms&lt;/span&gt;
&lt;span class="go"&gt;64 bytes from 1.1.1.1: icmp_seq=2 ttl=56 time=24.8 ms&lt;/span&gt;
&lt;span class="go"&gt;64 bytes from 1.1.1.1: icmp_seq=3 ttl=56 time=16.5 ms&lt;/span&gt;

&lt;span class="go"&gt;--- 1.1.1.1 ping statistics ---&lt;/span&gt;
&lt;span class="go"&gt;3 packets transmitted, 3 received, 0% packet loss, time 2001ms&lt;/span&gt;
&lt;span class="go"&gt;rtt min/avg/max/mdev = 16.370/19.195/24.755/3.931 ms&lt;/span&gt;

&lt;span class="gp gp-VirtualEnv"&gt;(deck@steamdeck ~)&lt;/span&gt;&lt;span class="gp"&gt;$ &lt;/span&gt;steamos-wifi-set-backend&lt;span class="w"&gt; &lt;/span&gt;iwd
&lt;span class="go"&gt;INFO: switching back-end to &amp;#39;iwd&amp;#39;&lt;/span&gt;
&lt;span class="go"&gt;INFO: stopping old back-end service and restarting NetworkManager,&lt;/span&gt;
&lt;span class="go"&gt;      networking will be disrupted (hopefully only momentary blip, max 10 seconds)...&lt;/span&gt;
&lt;span class="go"&gt;INFO: restarting done&lt;/span&gt;
&lt;span class="go"&gt;INFO: checking status of services ...&lt;/span&gt;
&lt;span class="go"&gt;      (sleeping for 2 seconds to catch-up with state)&lt;/span&gt;
&lt;span class="go"&gt;INFO: status OK&lt;/span&gt;

&lt;span class="gp gp-VirtualEnv"&gt;(deck@steamdeck ~)&lt;/span&gt;&lt;span class="gp"&gt;$ &lt;/span&gt;steamos-wifi-set-backend&lt;span class="w"&gt; &lt;/span&gt;--check
&lt;span class="go"&gt;iwd&lt;/span&gt;

&lt;span class="gp gp-VirtualEnv"&gt;(deck@steamdeck ~)&lt;/span&gt;&lt;span class="gp"&gt;$ &lt;/span&gt;ping&lt;span class="w"&gt; &lt;/span&gt;-c&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;.1.1.1
&lt;span class="go"&gt;PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.&lt;/span&gt;
&lt;span class="go"&gt;64 bytes from 1.1.1.1: icmp_seq=1 ttl=56 time=16.0 ms&lt;/span&gt;
&lt;span class="go"&gt;64 bytes from 1.1.1.1: icmp_seq=2 ttl=56 time=16.5 ms&lt;/span&gt;
&lt;span class="go"&gt;64 bytes from 1.1.1.1: icmp_seq=3 ttl=56 time=21.3 ms&lt;/span&gt;

&lt;span class="go"&gt;--- 1.1.1.1 ping statistics ---&lt;/span&gt;
&lt;span class="go"&gt;3 packets transmitted, 3 received, 0% packet loss, time 2003ms&lt;/span&gt;
&lt;span class="go"&gt;rtt min/avg/max/mdev = 15.991/17.940/21.295/2.382 ms&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;By hand&lt;/h3&gt;
&lt;p&gt;⚠️ IMPORTANT ⚠️ :
Please do this only if you know what you are doing,
   you don't fear minor breakage and you are confident that you can
   recover from the situation if something goes wrong.  If unsure,
   better wait until the channel that you run supports the commands to
   handle this automatically.&lt;/p&gt;
&lt;p&gt;If you are running a channel that still does not have this command,
e.g. &lt;code&gt;Stable&lt;/code&gt; at the time of writing this, you can achieve the same
effect by executing the instructions run by this script by hand.&lt;/p&gt;
&lt;p&gt;Note, however, that you might easily loose network connectivity if you
make some mistake or something goes wrong.  So be prepared to restore
things by hand by switching to desktop-mode and having a terminal
ready.&lt;/p&gt;
&lt;p&gt;Now, the actual instructions.  In
&lt;code&gt;/etc/NetworkManager/conf.d/wifi_backend.conf&lt;/code&gt;, change the string of
&lt;code&gt;wifi.backend&lt;/code&gt;, for example comment out the default one with &lt;code&gt;iwd&lt;/code&gt; and
add a line using &lt;code&gt;wpa_supplicant&lt;/code&gt; as value:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;[device]&lt;/span&gt;
&lt;span class="c1"&gt;#wifi.backend=iwd&lt;/span&gt;
&lt;span class="na"&gt;wifi.backend&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;wpa_supplicant&lt;/span&gt;
&lt;span class="na"&gt;wifi.iwd.autoconnect&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;yes&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;⚠️ IMPORTANT  ⚠️  :
Leave the other lines alone. If you don't have
   experience with the format you can easily cause the file to not be
   parseable, and then networking could stop working entirely.&lt;/p&gt;
&lt;p&gt;After that, things get more complicated depending on the hardware on
which the system runs.&lt;/p&gt;
&lt;p&gt;If the device is the SteamDeck, there is a difference between the
original LCD and the newer OLED model.  With the OLED model, when you
switch away from &lt;code&gt;iwd&lt;/code&gt;, typically the network device is destroyed, so
it's necessary to re-create it.  This happens automatically when
booting the system, so the easiest way if the network doesn't come up
after 15 seconds after the following instructions, is to just restart
the whole system.&lt;/p&gt;
&lt;p&gt;If you're running SteamOS on models of the SteamDeck that don't exist
at the time of writing this, or on other types of computers, the
situation can be similar to the OLED or even more complex, depending
on the WiFi hardware and drivers.  So, again, tread carefully.&lt;/p&gt;
&lt;p&gt;In the simplest scenario, LCD model, execute the following commands as
&lt;code&gt;root&lt;/code&gt; (or prepending &lt;code&gt;sudo&lt;/code&gt;), with &lt;code&gt;OLD_BACKEND&lt;/code&gt; being either &lt;code&gt;iwd&lt;/code&gt;
or &lt;code&gt;wpa_supplicant&lt;/code&gt;, the one that you want to migrate away from:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;systemctl&lt;span class="w"&gt; &lt;/span&gt;stop&lt;span class="w"&gt; &lt;/span&gt;NetworkManager
systemctl&lt;span class="w"&gt; &lt;/span&gt;disable&lt;span class="w"&gt; &lt;/span&gt;--now&lt;span class="w"&gt; &lt;/span&gt;OLD_BACKEND
systemctl&lt;span class="w"&gt; &lt;/span&gt;restart&lt;span class="w"&gt; &lt;/span&gt;NetworkManager
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;If you have the OLED model and switching from &lt;code&gt;wpa_supplicant&lt;/code&gt; to
&lt;code&gt;iwd&lt;/code&gt;, that should be enough as well.&lt;/p&gt;
&lt;p&gt;But if you have the OLED model and you changed from &lt;code&gt;iwd&lt;/code&gt; to
&lt;code&gt;wpa_supplicant&lt;/code&gt;, as explained above, your system will not be able to
connect to the network, and the easiest is to &lt;strong&gt;restart the system&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;However, if you want to try to solve the problem by hand without
restarting, then execute these commands as &lt;code&gt;root&lt;/code&gt;/&lt;code&gt;sudo&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;systemctl&lt;span class="w"&gt; &lt;/span&gt;stop&lt;span class="w"&gt; &lt;/span&gt;NetworkManager
systemctl&lt;span class="w"&gt; &lt;/span&gt;disable&lt;span class="w"&gt; &lt;/span&gt;--now&lt;span class="w"&gt; &lt;/span&gt;OLD_BACKEND

&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;!&lt;span class="w"&gt; &lt;/span&gt;iw&lt;span class="w"&gt; &lt;/span&gt;dev&lt;span class="w"&gt; &lt;/span&gt;wlan0&lt;span class="w"&gt; &lt;/span&gt;info&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;&amp;amp;&lt;/span&gt;&amp;gt;/dev/null&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;then&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;iw&lt;span class="w"&gt; &lt;/span&gt;phy&lt;span class="w"&gt; &lt;/span&gt;phy0&lt;span class="w"&gt; &lt;/span&gt;interface&lt;span class="w"&gt; &lt;/span&gt;add&lt;span class="w"&gt; &lt;/span&gt;wlan0&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;station&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;fi&lt;/span&gt;

systemctl&lt;span class="w"&gt; &lt;/span&gt;restart&lt;span class="w"&gt; &lt;/span&gt;NetworkManager
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;In any case, if after trying to change the back-end by hand and
rebooting it's still not being able to connect, perhaps the best thing
to do is to restore the previous configuration and restart the system
again, and wait until your channel is upgraded to include this
command.&lt;/p&gt;
&lt;h3&gt;Change back-ends via UI?&lt;/h3&gt;
&lt;p&gt;In the future, it is conceivable that the UI allows to change WiFi
backends with the help of this command or by other means, but this is
not possible at the moment.&lt;/p&gt;</content><category term="SteamOS"></category><category term="igalia"></category><category term="planet-igalia"></category><category term="steamos"></category></entry></feed>