Page MenuHomeFreeBSD

rtwn: add support for register IO debugging
ClosedPublic

Authored by adrian on Dec 14 2024, 7:39 PM.
Referenced Files
Unknown Object (File)
Thu, Mar 6, 6:42 AM
Unknown Object (File)
Sun, Mar 2, 8:10 PM
Unknown Object (File)
Thu, Feb 27, 2:08 PM
Unknown Object (File)
Thu, Feb 27, 1:39 PM
Unknown Object (File)
Wed, Feb 19, 5:21 PM
Unknown Object (File)
Jan 22 2025, 5:22 PM
Unknown Object (File)
Jan 1 2025, 12:36 AM
Unknown Object (File)
Dec 25 2024, 10:17 AM
Subscribers

Details

Summary

Add support to read/write the MAC/PHY registers.

Hide it behind RTWN_DEBUG_REGIO as I'm sure it's a security issue
being able to read things like the TX/RX packet buffer FIFO.

This doesn't cover the RF registers as they require a different
IO path, but I haven't yet debugged the RF paths.

Locally tested:

  • RTL8192CU, STA
  • RTL8188EU, STA

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

bz requested changes to this revision.Dec 18 2024, 1:23 PM
bz added a subscriber: bz.
bz added inline comments.
sys/dev/rtwn/if_rtwn.c
324

I would argue to make this a source code flag but not a kernel option if RTWN_DEBUG is not enough
(sysctl still require root to write, right? and if you are root you can do a lot more unless other safeguards are in place)

356

There is no sanity check on the register addr. That will easily go kaboom with a simple typo?

This revision now requires changes to proceed.Dec 18 2024, 1:23 PM
sys/dev/rtwn/if_rtwn.c
324

The challenge (!) is that RTWN_DEBUG is enabled by default in the rtwn module builds, rather than the module pulling in opt_rtwn.h from the build environment / kernel configuration directory. That's why I made it a different option.

For ath(4) it's behind ATH_DIAGAPI.

356

I sometimes forget that not everything is being enforced by iommu / newbus accessor range checking. Lemme cap it at 64k for now

add a bounds check, suggested by bz

sys/dev/rtwn/if_rtwn.c
324

The add a /* #define RTWN_DEBUG_REGIO */ at the top of the file and he (you) who needs can change it there and enable it; it doesn't have to be exposed to the build environment.
Like is done for so many DPRINTF cases (and similar) in lots of drivers in sys/dev/

sys/dev/rtwn/if_rtwn.c
324

It's easy to make the module pull it in from the kernel as well as having a stand alone default. It's what we do normally for other modules. Should i delve so i can make a detsiled suggestion?

sys/dev/rtwn/if_rtwn.c
324

It's easy to make the module pull it in from the kernel as well as having a stand alone default. It's what we do normally for other modules. Should i delve so i can make a detsiled suggestion?

Yeah, we should really fix it to do the right thing.

For now i'll stick this under RTWN_DEBUG; we can add the other option later when we've cleaned up the module opt_rtwn.h generation and such.

hide behind RTWN_DEBUG for now, feedback from bz/imp

ok, I've changed this to sit behind RTWN_DEBUG now.

I am generally fine with this I think.

This revision is now accepted and ready to land.Dec 31 2024, 6:34 AM
This revision was automatically updated to reflect the committed changes.