Commit 13eb8f2f authored by Ziye Yang's avatar Ziye Yang Committed by Tomasz Zawadzki
Browse files

idxd: Replace the read_8 function pointer with another one



Just remove this function pointer and add a new one,i.e.,
dump_sw_error.

Because this function pointer is only used to
read a sw err info. We can hide it in the detailed
idxd implemenation.

Signed-off-by: default avatarZiye Yang <ziye.yang@intel.com>
Change-Id: I42fe2220dae85df307b5af64e37acfd7f748915b
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8707


Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
parent 2f5abdb7
Loading
Loading
Loading
Loading
+6 −22
Original line number Diff line number Diff line
@@ -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) {
+1 −1
Original line number Diff line number Diff line
@@ -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);
+20 −7
Original line number Diff line number Diff line
@@ -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,
};