Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/ioat/ioat_logger.c
Show All 23 Lines | |||||
* SUCH DAMAGE. | * SUCH DAMAGE. | ||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/sysctl.h> | |||||
#include <sys/time.h> | #include <sys/time.h> | ||||
#include <machine/stdarg.h> | #include <machine/stdarg.h> | ||||
#include "ioat_logger.h" | #include "ioat_logger.h" | ||||
#include "ioat_sysctl.h" | |||||
int g_ioat_debug_level = 0; | int g_ioat_debug_level = 0; | ||||
SYSCTL_INT(_hw_ioat, OID_AUTO, debug_level, CTLFLAG_RWTUN, &g_ioat_debug_level, | |||||
0, "Set log level (0-3) for ioat(4). Higher is more verbose."); | |||||
#ifdef IOAT_LOGGING | |||||
void | void | ||||
ioat_log_message(int verbosity, char *log_message, ...) | ioat_log_message(int verbosity, char *fmt, ...) | ||||
{ | { | ||||
va_list argp; | va_list argp; | ||||
char buffer[512]; | char buffer[512]; | ||||
struct timeval tv; | struct timeval tv; | ||||
if (verbosity > g_ioat_debug_level) | if (verbosity > g_ioat_debug_level) | ||||
return; | return; | ||||
va_start (argp, log_message); | va_start(argp, fmt); | ||||
vsnprintf(buffer, sizeof(buffer)-1, log_message, argp); | vsnprintf(buffer, sizeof(buffer) - 1, fmt, argp); | ||||
va_end(argp); | va_end(argp); | ||||
microuptime(&tv); | microuptime(&tv); | ||||
printf("[%d:%06d] ioat: %s", (int)tv.tv_sec, (int)tv.tv_usec, buffer); | printf("[%d:%06d] ioat: %s", (int)tv.tv_sec, (int)tv.tv_usec, buffer); | ||||
} | } | ||||
#endif |