Post by @rqm
On #OpenBSD when connected to the WiFi mesh at home (eero) and move from room to room the connection gets dropped. My workaround is to do a card reset (ifconfing up / down / netstart) and let it reassociate but is there a "proper" solution this? (card is `bwfm`) Same SSID broadcasted by many BSSID's, both 2.4 and 5ghz.
@rqm It looks like the device can send roaming events (BWFM_E_ROAM) but the driver ignores them and doesn't enable this feature.
@stsp@bsd.network I had a glance at the drivers in Linux and BSD and this is way beyond me. I see you worked on roaming stuff in qw{z,x} recently; would it be possible to lift into bwfm whatever you implemented? Or is the behaviour / code just too different?
@rqm it is entirely different because the broadcom devices run their own WiFi stack internally. The net80211 code is barely involved
@rqm What you probably need to do is go into bwfm_rx_event_cb() and add cases for BWFM_E_ROAM_PREP and BWFM_E_ROAM (see bwfmreg.h for where these macros come from).
I guess these events are letting the driver know which AP / channel the device has switched to. Linux updates its wifi-stack data structures in bcrmfmac/cfg80211.c:brcmf_bss_roaming_done() by reading info from the E_ROAM device event data structure.
Another piece of the puzzle is making sure that such events get generated. Linux seems to be doing this in brcmf_dongle_roam() (in the same file) by setting the "bcn_timeout" device parameter to a magic value named something_ROAM_ON in their code. In bwfm we don't set this parameter yet, at least I cannot find it with a simple grep.
Not sure if this is the complete picture. If you can get to the point where you see an event fire in a printf, you're basically done with the hardest part already.
@rqm There is also a "roam_off" parameter being set to "on" or "off" just a few lines below the "bcn_timeout" one.
@stsp@bsd.network Looking at the code I am wondering whether adding BWFM_E_ROAMING to the _E_DEAUTH/E_DISASSOC fallthrough might be a simple hack? Let it start scanning?
@rqm It would work as a proof of concept of processing the roaming event. Avoiding the scan loop is the end goal because that way the link stays up and connections don't die.
@rqm In case it helps, here is a port of the function which enables roaming on Linux which you can drop into bwfm.c as a starting point: https://liam.stsp.name/files/bwfm_dongle_roam.c
@stsp@bsd.network Thank you! Was just reading this actually. If you don't mind being a rubber ducky, this is what I think the code does and how it could be implemented:
- Card is told to set "roam_off" to "false" (because double negatives are so logical) to turn on roaming mode. on BSD this is done via
bwfm_fwvar_set_data()andbwfm_fwvar_set_int(). - Then specify a roaming trigger and delta -- these are signal strength values, looking at the other files in the linux kernel, set somewhere around -75 i think (Linux sources have these); these values could be defined in bwfmreg.h I guess.
Linux seems to do this as part of the setup process. ¹ It looks to me like the place to call this on OpenBSD would be in bwfm_newstate() around bwfm.c:2944 just bwfore the switch()? (If not, there, where?)
Then,
3) Handle the roaming event; I think this can be handled either like BWFM_E_ASSOC or BWFM_E_AUTH. Linux checks for the _E_AUTH message and for _E_STATUS_SUCCESS, then
4) calls bwfm_dongle_roaming_done(). Through this the connection details are updated and reported. Not sure how this is done on the BSD side?
Is this vaguely correct in your eyes?
@rqm Yes, vaguely correct indeed. Enabling roaming should be done when the interface comes up (bwfm_init or something like that, called from bwfm_ioctl when the interface flags change such that UP gets set). The newstate handler is too late for this because it handles run-time state changes while the interface is up.
Roaming should only be enabled in client mode (ic->ic_opmode == IEEE80211_M_STA) but you don't really need to worry about such details during the first step.
@stsp@bsd.network Here's where I got to. Kernel build fails tho because of something complaining in pipex.o. (I am fetching -current from cvs as I'm on -current).
@rqm Is it for sure the driver for that chip and not interference? Maybe try another channel, if it's not dynamic. Maybe getting knocked off just one freq knocks out the whole connection on both radios. Just a thought.
@gemlog@friendface.kalum.ca It seems it is a driver issue. The roaming event isn't handled by the driver.