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)
Fri, Nov 22, 8:05 PM
Unknown Object (File)
Tue, Nov 12, 1:58 AM
Unknown Object (File)
Tue, Nov 12, 1:56 AM
Unknown Object (File)
Tue, Nov 12, 1:31 AM
Unknown Object (File)
Oct 23 2024, 5:25 PM
Unknown Object (File)
Oct 13 2024, 3:07 AM
Unknown Object (File)
Oct 13 2024, 3:07 AM
Unknown Object (File)
Oct 13 2024, 3:07 AM

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?