Page MenuHomeFreeBSD

Add log() style versions of device_printf() and if_printf()
ClosedPublic

Authored by adrian on Mar 18 2021, 6:46 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Apr 25, 7:17 PM
Unknown Object (File)
Thu, Apr 25, 6:49 PM
Unknown Object (File)
Tue, Apr 23, 9:06 PM
Unknown Object (File)
Feb 7 2024, 8:49 PM
Unknown Object (File)
Dec 23 2023, 12:02 AM
Unknown Object (File)
Sep 16 2023, 2:31 AM
Unknown Object (File)
Aug 1 2023, 6:59 PM
Unknown Object (File)
Aug 1 2023, 6:58 PM

Details

Summary

This is intended to be used by devices and network devices
to log things to the kernel syslog rather than hand-rolling
log() stuff (like what happens in other places in net/if.c)
or being very spammy with device_printf()/printf() (like, well,
a lot of things.)

I've used this in my local tree to convert net80211 and ath_hal
logging over to log at INFO/DEBUG where appropriate and it
works quite well. On devices with serial consoles (ie, all the
weird things I use in my wifi test bed here) writing debug
information to the serial console causes quite bad behaviour.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 37910
Build 34799: arc lint + arc unit

Event Timeline

Seems good to me, but you'll want to make sure others sign off on it too.

sys/kern/subr_bus.c
2457

128 is kinda small, but on the other hand it's also kinda big for the stack :(, but I guess it's no different than device_printf.

This revision is now accepted and ready to land.Mar 18 2021, 4:06 PM
jhb added a subscriber: jhb.
jhb added inline comments.
sys/kern/subr_bus.c
2457

If you wanted to support longer lines you could add a drain routine that wrote to log(). Truncating is probably fine though.

That's a nice addition we should long have.
Please see some minor comments inside.

sys/kern/subr_bus.c
2462

Nit: should it be something like "unknown_device:" ?

sys/net/if.c
3955

Nit: maybe if_buf?