Commit 2d64c287 authored by Krishna Kanth Reddy's avatar Krishna Kanth Reddy Committed by Tomasz Zawadzki
Browse files

module/scheduler: Added dump_info_json function pointer



Implemented a function dump_info_json to
output governor-specific information to a JSON stream.

Change-Id: Ifbd4c9e7a0d6dea0e6aa0c565eb088a07a0e2826
Signed-off-by: default avatarKrishna Kanth Reddy <krish.reddy@samsung.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/23639


Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent fefbeadb
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -102,6 +102,14 @@ struct spdk_governor {
	 */
	int (*get_core_capabilities)(uint32_t lcore_id, struct spdk_governor_capabilities *capabilities);

	/**
	 * Output governor-specific information to a JSON stream.
	 *
	 * The JSON write context will be initialized with an open object, so the governor
	 * should write a name followed by a JSON value (most likely another nested object).
	 */
	int (*dump_info_json)(struct spdk_json_write_ctx *w);

	/**
	 * Initialize a governor.
	 *
+1 −1
Original line number Diff line number Diff line
@@ -122,7 +122,7 @@ DEPDIRS-sock_uring := log sock util trace
# module/scheduler
DEPDIRS-scheduler_dynamic := event log thread util json
ifeq (y,$(DPDK_POWER))
DEPDIRS-scheduler_dpdk_governor := event log
DEPDIRS-scheduler_dpdk_governor := event json log
DEPDIRS-scheduler_gscheduler := event log
endif

+26 −0
Original line number Diff line number Diff line
@@ -91,6 +91,31 @@ _get_core_capabilities(uint32_t lcore_id, struct spdk_governor_capabilities *cap
	return 0;
}

static int
_dump_info_json(struct spdk_json_write_ctx *w)
{
	enum power_management_env env;

	env = rte_power_get_env();

	if (env == PM_ENV_ACPI_CPUFREQ) {
		spdk_json_write_named_string(w, "env", "acpi-cpufreq");
	} else if (env == PM_ENV_KVM_VM) {
		spdk_json_write_named_string(w, "env", "kvm");
	} else if (env == PM_ENV_PSTATE_CPUFREQ) {
		spdk_json_write_named_string(w, "env", "intel-pstate");
	} else if (env == PM_ENV_CPPC_CPUFREQ) {
		spdk_json_write_named_string(w, "env", "cppc-cpufreq");
	} else if (env == PM_ENV_AMD_PSTATE_CPUFREQ) {
		spdk_json_write_named_string(w, "env", "amd-pstate");
	} else {
		spdk_json_write_named_string(w, "env", "unknown");
		return -EINVAL;
	}

	return 0;
}

static int
_init_core(uint32_t lcore_id)
{
@@ -171,6 +196,7 @@ static struct spdk_governor dpdk_governor = {
	.set_core_freq_max = _set_core_freq_max,
	.set_core_freq_min = _set_core_freq_min,
	.get_core_capabilities = _get_core_capabilities,
	.dump_info_json = _dump_info_json,
	.init = _init,
	.deinit = _deinit,
};