static int ioat_reset_hw(struct ioat_softc *ioat);
static void ioat_setup_sysctl(device_t device);
+#define ioat_log_message(v, ...) do { \
+ if ((v) <= g_ioat_debug_level) { \
+ device_printf(ioat->device, __VA_ARGS__); \
+ } \
+} while (0)
+
MALLOC_DEFINE(M_IOAT, "ioat", "ioat driver memory allocations");
SYSCTL_NODE(_hw, OID_AUTO, ioat, CTLFLAG_RD, 0, "ioat node");
SYSCTL_INT(_hw_ioat, OID_AUTO, force_legacy_interrupts, CTLFLAG_RDTUN,
&g_force_legacy_interrupts, 0, "Set to non-zero to force MSI-X disabled");
-static 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.");
{
struct ioat_softc *ioat;
- ioat_log_message(3, "%s\n", __func__);
ioat = to_ioat_softc(dmaengine);
+ ioat_log_message(3, "%s\n", __func__);
ioat_write_2(ioat, IOAT_DMACOUNT_OFFSET, (uint16_t)ioat->head);
mtx_unlock(&ioat->submit_lock);
}
"tail", CTLFLAG_RD, &ioat->tail,
0, "HW descriptor tail pointer index");
}
-
-void
-ioat_log_message(int verbosity, char *fmt, ...)
-{
- va_list argp;
- char buffer[512];
- struct timeval tv;
-
- if (verbosity > g_ioat_debug_level)
- return;
-
- va_start(argp, fmt);
- vsnprintf(buffer, sizeof(buffer) - 1, fmt, argp);
- va_end(argp);
- microuptime(&tv);
-
- printf("[%d:%06d] ioat: %s", (int)tv.tv_sec, (int)tv.tv_usec, buffer);
-}
#include <dev/pci/pcivar.h>
#include <machine/bus.h>
#include <machine/resource.h>
+#include <machine/stdarg.h>
#include <vm/vm.h>
#include <vm/pmap.h>
static int g_thread_index = 1;
static struct cdev *g_ioat_cdev = NULL;
+#define ioat_test_log(v, ...) _ioat_test_log((v), "ioat " __VA_ARGS__)
+static inline void _ioat_test_log(int verbosity, const char *fmt, ...);
+
static void
ioat_test_transaction_destroy(struct test_transaction *tx)
{
test = tx->test;
if (test->verify && !ioat_compare_ok(tx)) {
- ioat_log_message(0, "miscompare found\n");
+ ioat_test_log(0, "miscompare found\n");
atomic_add_32(&test->status[IOAT_TEST_MISCOMPARE], tx->depth);
} else if (!test->too_late)
atomic_add_32(&test->status[IOAT_TEST_OK], tx->depth);
tx = ioat_test_transaction_create(test->chain_depth * 2,
test->buffer_size);
if (tx == NULL) {
- ioat_log_message(0, "tx == NULL - memory exhausted\n");
+ ioat_test_log(0, "tx == NULL - memory exhausted\n");
test->status[IOAT_TEST_NO_MEMORY]++;
return (ENOMEM);
}
memset(__DEVOLATILE(void *, test->status), 0, sizeof(test->status));
if (test->buffer_size > 1024 * 1024) {
- ioat_log_message(0, "Buffer size too large >1MB\n");
+ ioat_test_log(0, "Buffer size too large >1MB\n");
test->status[IOAT_TEST_NO_MEMORY]++;
return;
}
if (test->chain_depth * 2 > IOAT_MAX_BUFS) {
- ioat_log_message(0, "Depth too large (> %u)\n",
+ ioat_test_log(0, "Depth too large (> %u)\n",
(unsigned)IOAT_MAX_BUFS / 2);
test->status[IOAT_TEST_NO_MEMORY]++;
return;
if (btoc((uint64_t)test->buffer_size * test->chain_depth *
test->transactions) > (physmem / 4)) {
- ioat_log_message(0, "Sanity check failed -- test would "
+ ioat_test_log(0, "Sanity check failed -- test would "
"use more than 1/4 of phys mem.\n");
test->status[IOAT_TEST_NO_MEMORY]++;
return;
}
if ((uint64_t)test->transactions * test->chain_depth > (1<<16)) {
- ioat_log_message(0, "Sanity check failed -- test would "
+ ioat_test_log(0, "Sanity check failed -- test would "
"use more than available IOAT ring space.\n");
test->status[IOAT_TEST_NO_MEMORY]++;
return;
dmaengine = ioat_get_dmaengine(test->channel_index);
if (dmaengine == NULL) {
- ioat_log_message(0, "Couldn't acquire dmaengine\n");
+ ioat_test_log(0, "Couldn't acquire dmaengine\n");
test->status[IOAT_TEST_NO_DMA_ENGINE]++;
return;
}
TAILQ_INIT(&test->pend_q);
if (test->duration == 0)
- ioat_log_message(1, "Thread %d: num_loops remaining: 0x%08x\n",
+ ioat_test_log(1, "Thread %d: num_loops remaining: 0x%08x\n",
index, test->transactions);
else
- ioat_log_message(1, "Thread %d: starting\n", index);
+ ioat_test_log(1, "Thread %d: starting\n", index);
rc = ioat_test_prealloc_memory(test, index);
if (rc != 0) {
- ioat_log_message(0, "prealloc_memory: %d\n", rc);
+ ioat_test_log(0, "prealloc_memory: %d\n", rc);
return;
}
wmb();
ioat_test_submit_1_tx(test, dmaengine);
}
- ioat_log_message(1, "Test Elapsed: %d ticks (overrun %d), %d sec.\n",
+ ioat_test_log(1, "Test Elapsed: %d ticks (overrun %d), %d sec.\n",
ticks - start, ticks - end, (ticks - start) / hz);
IT_LOCK();
msleep(&test->free_q, &ioat_test_lk, 0, "ioattestcompl", hz);
IT_UNLOCK();
- ioat_log_message(1, "Test Elapsed2: %d ticks (overrun %d), %d sec.\n",
+ ioat_test_log(1, "Test Elapsed2: %d ticks (overrun %d), %d sec.\n",
ticks - start, ticks - end, (ticks - start) / hz);
ioat_test_release_memory(test);
enable_ioat_test(false);
mtx_unlock(&Giant);
}
+
+static inline void
+_ioat_test_log(int verbosity, const char *fmt, ...)
+{
+ va_list argp;
+
+ if (verbosity > g_ioat_debug_level)
+ return;
+
+ va_start(argp, fmt);
+ vprintf(fmt, argp);
+ va_end(argp);
+}