Commit 55d6cc0e authored by Konrad Sztyber's avatar Konrad Sztyber
Browse files

accel: add method for getting per-channel opcode stats



Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Ic3cc0ddc5907e113b6d9d752c9bff0f526458a11
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17625


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
parent d7b29fb9
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -691,6 +691,26 @@ int spdk_accel_set_opts(const struct spdk_accel_opts *opts);
 */
void spdk_accel_get_opts(struct spdk_accel_opts *opts);

struct spdk_accel_opcode_stats {
	/** Number of executed operations */
	uint64_t	executed;
	/** Number of failed operations */
	uint64_t	failed;
	/** Number of processed bytes */
	uint64_t	num_bytes;
} __attribute__((packed));

/**
 * Retrieve opcode statistics for a given IO channel.
 *
 * \param ch I/O channel.
 * \param opcode Operation to retrieve statistics.
 * \param stats Per-channel statistics.
 * \param size Size of the `stats` structure.
 */
void spdk_accel_get_opcode_stats(struct spdk_io_channel *ch, enum accel_opcode opcode,
				 struct spdk_accel_opcode_stats *stats, size_t size);

#ifdef __cplusplus
}
#endif
+22 −0
Original line number Diff line number Diff line
@@ -2715,4 +2715,26 @@ accel_get_stats(accel_get_stats_cb cb_fn, void *cb_arg)
	return 0;
}

void
spdk_accel_get_opcode_stats(struct spdk_io_channel *ch, enum accel_opcode opcode,
			    struct spdk_accel_opcode_stats *stats, size_t size)
{
	struct accel_io_channel *accel_ch = spdk_io_channel_get_ctx(ch);

#define FIELD_OK(field) \
	offsetof(struct spdk_accel_opcode_stats, field) + sizeof(stats->field) <= size

#define SET_FIELD(field, value) \
	if (FIELD_OK(field)) { \
		stats->field = value; \
	}

	SET_FIELD(executed, accel_ch->stats.operations[opcode].executed);
	SET_FIELD(failed, accel_ch->stats.operations[opcode].failed);
	SET_FIELD(num_bytes, accel_ch->stats.operations[opcode].num_bytes);

#undef FIELD_OK
#undef SET_FIELD
}

SPDK_LOG_REGISTER_COMPONENT(accel)
+1 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@
	spdk_accel_get_memory_domain;
	spdk_accel_set_opts;
	spdk_accel_get_opts;
	spdk_accel_get_opcode_stats;

	# functions needed by modules
	spdk_accel_module_list_add;