diff --git a/lib/idxd/idxd.c b/lib/idxd/idxd.c index 45304eb02..0ee77a7ad 100644 --- a/lib/idxd/idxd.c +++ b/lib/idxd/idxd.c @@ -81,12 +81,6 @@ struct device_config g_dev_cfg1 = { .total_engines = 4, }; -static uint64_t -idxd_read_8(struct spdk_idxd_device *idxd, void *portal, uint32_t offset) -{ - return idxd->impl->read_8(idxd, portal, offset); -} - struct spdk_idxd_io_channel * spdk_idxd_get_channel(struct spdk_idxd_device *idxd) { @@ -1020,23 +1014,13 @@ spdk_idxd_batch_prep_compare(struct spdk_idxd_io_channel *chan, struct idxd_batc return 0; } -static void -_dump_error_reg(struct spdk_idxd_io_channel *chan) +static inline void +_dump_sw_error_reg(struct spdk_idxd_io_channel *chan) { - uint64_t sw_error_0; - uint16_t i; + struct spdk_idxd_device *idxd = chan->idxd; - sw_error_0 = idxd_read_8(chan->idxd, chan->portal, IDXD_SWERR_OFFSET); - - SPDK_NOTICELOG("SW Error bits set:"); - for (i = 0; i < CHAR_BIT; i++) { - if ((1ULL << i) & sw_error_0) { - SPDK_NOTICELOG(" %d\n", i); - } - } - SPDK_NOTICELOG("SW Error error code: %#x\n", (uint8_t)(sw_error_0 >> 8)); - SPDK_NOTICELOG("SW Error WQ index: %u\n", (uint8_t)(sw_error_0 >> 16)); - SPDK_NOTICELOG("SW Error Operation: %u\n", (uint8_t)(sw_error_0 >> 32)); + assert(idxd != NULL); + idxd->impl->dump_sw_error(idxd, chan->portal); } /* TODO: there are multiple ways of getting completions but we can't really pick the best one without @@ -1070,7 +1054,7 @@ spdk_idxd_process_events(struct spdk_idxd_io_channel *chan) if (spdk_unlikely(IDXD_FAILURE(comp_ctx->hw.status))) { status = -EINVAL; - _dump_error_reg(chan); + _dump_sw_error_reg(chan); } switch (comp_ctx->desc->opcode) { diff --git a/lib/idxd/idxd.h b/lib/idxd/idxd.h index c3d472f62..3bf18c5b2 100644 --- a/lib/idxd/idxd.h +++ b/lib/idxd/idxd.h @@ -177,7 +177,7 @@ struct spdk_idxd_impl { void (*set_config)(struct device_config *g_dev_cfg, uint32_t config_num); int (*probe)(void *cb_ctx, spdk_idxd_attach_cb attach_cb); void (*destruct)(struct spdk_idxd_device *idxd); - uint64_t (*read_8)(struct spdk_idxd_device *idxd, void *portal, uint32_t offset); + void (*dump_sw_error)(struct spdk_idxd_device *idxd, void *portal); char *(*portal_get_addr)(struct spdk_idxd_device *idxd); /* It is a workround for simulator */ bool (*nop_check)(struct spdk_idxd_device *idxd); diff --git a/lib/idxd/idxd_user.c b/lib/idxd/idxd_user.c index 3f89db5f8..29f7a6f6c 100644 --- a/lib/idxd/idxd_user.c +++ b/lib/idxd/idxd_user.c @@ -90,12 +90,6 @@ _idxd_read_8(struct spdk_idxd_device *idxd, uint32_t offset) return spdk_mmio_read_8((uint64_t *)(user_idxd->reg_base + offset)); } -static uint64_t -idxd_read_8(struct spdk_idxd_device *idxd, void *portal, uint32_t offset) -{ - return _idxd_read_8(idxd, offset); -} - static void _idxd_write_8(struct spdk_idxd_device *idxd, uint32_t offset, uint64_t value) { @@ -503,6 +497,25 @@ user_idxd_probe(void *cb_ctx, spdk_idxd_attach_cb attach_cb) return rc; } +static void +user_idxd_dump_sw_err(struct spdk_idxd_device *idxd, void *portal) +{ + uint64_t sw_error_0; + uint16_t i; + + sw_error_0 = _idxd_read_8(idxd, IDXD_SWERR_OFFSET); + + SPDK_NOTICELOG("SW Error bits set:"); + for (i = 0; i < CHAR_BIT; i++) { + if ((1ULL << i) & sw_error_0) { + SPDK_NOTICELOG(" %d\n", i); + } + } + SPDK_NOTICELOG("SW Error error code: %#x\n", (uint8_t)(sw_error_0 >> 8)); + SPDK_NOTICELOG("SW Error WQ index: %u\n", (uint8_t)(sw_error_0 >> 16)); + SPDK_NOTICELOG("SW Error Operation: %u\n", (uint8_t)(sw_error_0 >> 32)); +} + static char * user_idxd_portal_get_addr(struct spdk_idxd_device *idxd) { @@ -527,7 +540,7 @@ static struct spdk_idxd_impl g_user_idxd_impl = { .set_config = user_idxd_set_config, .probe = user_idxd_probe, .destruct = user_idxd_device_destruct, - .read_8 = idxd_read_8, + .dump_sw_error = user_idxd_dump_sw_err, .portal_get_addr = user_idxd_portal_get_addr, .nop_check = user_idxd_nop_check, };