summaryrefslogtreecommitdiffstats
path: root/plugins/ocp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 11:11:05 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 11:11:05 +0000
commit81d6a5ded50a26338e1b36462b3e0a6e45beb9a6 (patch)
tree364371981040c3dc6e97bb289bda0d33933ebfac /plugins/ocp
parentAdding upstream version 2.8. (diff)
downloadnvme-cli-a434c25fd5f7213d0872842d2de6f10043f79818.tar.xz
nvme-cli-a434c25fd5f7213d0872842d2de6f10043f79818.zip
Adding upstream version 2.9.1.upstream/2.9.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--plugins/ocp/ocp-clear-features.c2
-rw-r--r--plugins/ocp/ocp-fw-activation-history.c6
-rw-r--r--plugins/ocp/ocp-nvme.c1526
-rw-r--r--plugins/ocp/ocp-nvme.h3
-rw-r--r--plugins/ocp/ocp-utils.c27
-rw-r--r--plugins/ocp/ocp-utils.h22
6 files changed, 914 insertions, 672 deletions
diff --git a/plugins/ocp/ocp-clear-features.c b/plugins/ocp/ocp-clear-features.c
index 0f49584..731dfea 100644
--- a/plugins/ocp/ocp-clear-features.c
+++ b/plugins/ocp/ocp-clear-features.c
@@ -18,7 +18,7 @@ static int ocp_clear_feature(int argc, char **argv, const char *desc, const __u8
__u32 result = 0;
__u32 clear = 1 << 31;
struct nvme_dev *dev;
- int uuid_index = 0;
+ __u8 uuid_index = 0;
bool uuid = true;
int err;
diff --git a/plugins/ocp/ocp-fw-activation-history.c b/plugins/ocp/ocp-fw-activation-history.c
index ad96c6b..16598a0 100644
--- a/plugins/ocp/ocp-fw-activation-history.c
+++ b/plugins/ocp/ocp-fw-activation-history.c
@@ -66,7 +66,7 @@ static void ocp_fw_activation_history_normal(const struct fw_activation_history
printf(" %-22s%d\n", "activation count:",
le16_to_cpu(entry->activation_count));
printf(" %-22s%"PRIu64"\n", "timestamp:",
- le64_to_cpu(entry->timestamp));
+ (0x0000FFFFFFFFFFFF & le64_to_cpu(entry->timestamp)));
printf(" %-22s%"PRIu64"\n", "power cycle count:",
le64_to_cpu(entry->power_cycle_count));
printf(" %-22s%.*s\n", "previous firmware:", (int)sizeof(entry->previous_fw),
@@ -106,7 +106,7 @@ static void ocp_fw_activation_history_json(const struct fw_activation_history *f
json_object_add_value_uint(entry_obj, "activation count",
le16_to_cpu(entry->activation_count));
json_object_add_value_uint64(entry_obj, "timestamp",
- le64_to_cpu(entry->timestamp));
+ (0x0000FFFFFFFFFFFF & le64_to_cpu(entry->timestamp)));
json_object_add_value_uint(entry_obj, "power cycle count",
le64_to_cpu(entry->power_cycle_count));
@@ -162,7 +162,7 @@ int ocp_fw_activation_history_log(int argc, char **argv, struct command *cmd,
if (err)
return err;
- int uuid_index = 0;
+ __u8 uuid_index = 0;
/*
* Best effort attempt at uuid. Otherwise, assume no index (i.e. 0)
diff --git a/plugins/ocp/ocp-nvme.c b/plugins/ocp/ocp-nvme.c
index 53ae0f4..6eaa773 100644
--- a/plugins/ocp/ocp-nvme.c
+++ b/plugins/ocp/ocp-nvme.c
@@ -705,7 +705,7 @@ static int eol_plp_failure_mode_set(struct nvme_dev *dev, const __u32 nsid,
{
__u32 result;
int err;
- int uuid_index = 0;
+ __u8 uuid_index = 0;
if (uuid) {
/* OCP 2.0 requires UUID index support */
@@ -2060,6 +2060,90 @@ static int ocp_device_capabilities_log(int argc, char **argv, struct command *cm
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
+/// Set Telemetry Profile (Feature Identifier C8h) Set Feature
+
+static int ocp_set_telemetry_profile(struct nvme_dev *dev, __u8 tps)
+{
+ __u32 result;
+ int err;
+ __u8 uuid_index = 0;
+
+ /* OCP 2.0 requires UUID index support */
+ err = ocp_get_uuid_index(dev, &uuid_index);
+ if (err || !uuid_index) {
+ nvme_show_error("ERROR: No OCP UUID index found");
+ return err;
+ }
+
+ struct nvme_set_features_args args = {
+ .args_size = sizeof(args),
+ .fd = dev_fd(dev),
+ .fid = 0xC8,
+ .nsid = 0xFFFFFFFF,
+ .cdw11 = tps,
+ .cdw12 = 0,
+ .save = true,
+ .uuidx = uuid_index,
+ .cdw15 = 0,
+ .data_len = 0,
+ .data = NULL,
+ .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
+ .result = &result,
+ };
+
+ err = nvme_set_features(&args);
+ if (err > 0) {
+ nvme_show_status(err);
+ } else if (err < 0) {
+ nvme_show_perror("Set Telemetry Profile");
+ fprintf(stderr, "Command failed while parsing.\n");
+ } else {
+ printf("Successfully Set Telemetry Profile (feature: 0xC8) to below values\n");
+ printf("Telemetry Profile Select: 0x%x\n", tps);
+ }
+
+ return err;
+}
+
+static int ocp_set_telemetry_profile_feature(int argc, char **argv, struct command *cmd,
+ struct plugin *plugin)
+{
+ const char *desc = "Set Telemetry Profile (Feature Identifier C8h) Set Feature.";
+ const char *tps = "Telemetry Profile Select for device debug data collection";
+ struct nvme_dev *dev;
+ int err;
+
+ struct config {
+ __u8 tps;
+ };
+
+ struct config cfg = {
+ .tps = 0,
+ };
+
+ OPT_ARGS(opts) = {
+ OPT_BYTE("telemetry-profile-select", 't', &cfg.tps, tps),
+ OPT_END()
+ };
+
+ err = parse_and_open(&dev, argc, argv, desc, opts);
+ if (err)
+ return err;
+
+ if (argconfig_parse_seen(opts, "telemetry-profile-select"))
+ err = ocp_set_telemetry_profile(dev, cfg.tps);
+ else
+ nvme_show_error("Telemetry Profile Select is a required argument");
+
+ dev_close(dev);
+
+ return err;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
/// DSSD Power State (Feature Identifier C7h) Set Feature
static int set_dssd_power_state(struct nvme_dev *dev, const __u32 nsid,
@@ -2068,7 +2152,7 @@ static int set_dssd_power_state(struct nvme_dev *dev, const __u32 nsid,
{
__u32 result;
int err;
- int uuid_index = 0;
+ __u8 uuid_index = 0;
if (uuid) {
/* OCP 2.0 requires UUID index support */
@@ -2143,7 +2227,7 @@ static int set_dssd_power_state_feature(int argc, char **argv, struct command *c
if (err)
return err;
- if (argconfig_parse_seen(opts, "power state"))
+ if (argconfig_parse_seen(opts, "power-state"))
err = set_dssd_power_state(dev, nsid, fid, cfg.power_state,
cfg.save,
!argconfig_parse_seen(opts, "no-uuid"));
@@ -2160,137 +2244,271 @@ static int set_dssd_power_state_feature(int argc, char **argv, struct command *c
/// plp_health_check_interval
static int set_plp_health_check_interval(int argc, char **argv, struct command *cmd,
- struct plugin *plugin)
+ struct plugin *plugin)
{
- const char *desc = "Define Issue Set Feature command (FID : 0xC6) PLP Health Check Interval";
- const char *plp_health_interval = "[31:16]:PLP Health Check Interval";
- const char *save = "Specifies that the controller shall save the attribute";
- const __u32 nsid = 0;
- const __u8 fid = 0xc6;
- struct nvme_dev *dev;
- int err;
- __u32 result;
- int uuid_index = 0;
-
- struct config {
- __le16 plp_health_interval;
- bool save;
- };
-
- struct config cfg = {
- .plp_health_interval = 0,
- .save = false,
- };
-
- OPT_ARGS(opts) = {
- OPT_BYTE("plp_health_interval", 'p', &cfg.plp_health_interval, plp_health_interval),
- OPT_FLAG("save", 's', &cfg.save, save),
- OPT_FLAG("no-uuid", 'n', NULL,
- "Skip UUID index search (UUID index not required for OCP 1.0)"),
- OPT_END()
- };
-
- err = parse_and_open(&dev, argc, argv, desc, opts);
- if (err)
- return err;
-
-
- if (!argconfig_parse_seen(opts, "no-uuid")) {
- /* OCP 2.0 requires UUID index support */
- err = ocp_get_uuid_index(dev, &uuid_index);
- if (err || !uuid_index) {
- printf("ERROR: No OCP UUID index found");
- return err;
- }
- }
-
-
- struct nvme_set_features_args args = {
- .args_size = sizeof(args),
- .fd = dev_fd(dev),
- .fid = fid,
- .nsid = nsid,
- .cdw11 = cfg.plp_health_interval << 16,
- .cdw12 = 0,
- .save = cfg.save,
- .uuidx = uuid_index,
- .cdw15 = 0,
- .data_len = 0,
- .data = NULL,
- .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
- .result = &result,
- };
-
- err = nvme_set_features(&args);
- if (err > 0) {
- nvme_show_status(err);
- } else if (err < 0) {
- nvme_show_perror("Define PLP Health Check Interval");
- fprintf(stderr, "Command failed while parsing.\n");
- } else {
- printf("Successfully set the PLP Health Check Interval");
- printf("PLP Health Check Interval: 0x%x\n", cfg.plp_health_interval);
- printf("Save bit Value: 0x%x\n", cfg.save);
- }
- return err;
+ const char *desc = "Define Issue Set Feature command (FID : 0xC6) PLP Health Check Interval";
+ const char *plp_health_interval = "[31:16]:PLP Health Check Interval";
+ const char *save = "Specifies that the controller shall save the attribute";
+ const __u32 nsid = 0;
+ const __u8 fid = 0xc6;
+ struct nvme_dev *dev;
+ int err;
+ __u32 result;
+ __u8 uuid_index = 0;
+
+ struct config {
+ __le16 plp_health_interval;
+ bool save;
+ };
+
+ struct config cfg = {
+ .plp_health_interval = 0,
+ .save = false,
+ };
+
+ OPT_ARGS(opts) = {
+ OPT_BYTE("plp_health_interval", 'p', &cfg.plp_health_interval, plp_health_interval),
+ OPT_FLAG("save", 's', &cfg.save, save),
+ OPT_FLAG("no-uuid", 'n', NULL,
+ "Skip UUID index search (UUID index not required for OCP 1.0)"),
+ OPT_END()
+ };
+
+ err = parse_and_open(&dev, argc, argv, desc, opts);
+ if (err)
+ return err;
+
+
+ if (!argconfig_parse_seen(opts, "no-uuid")) {
+ /* OCP 2.0 requires UUID index support */
+ err = ocp_get_uuid_index(dev, &uuid_index);
+ if (err || !uuid_index) {
+ printf("ERROR: No OCP UUID index found");
+ return err;
+ }
+ }
+
+
+ struct nvme_set_features_args args = {
+ .args_size = sizeof(args),
+ .fd = dev_fd(dev),
+ .fid = fid,
+ .nsid = nsid,
+ .cdw11 = cfg.plp_health_interval << 16,
+ .cdw12 = 0,
+ .save = cfg.save,
+ .uuidx = uuid_index,
+ .cdw15 = 0,
+ .data_len = 0,
+ .data = NULL,
+ .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
+ .result = &result,
+ };
+
+ err = nvme_set_features(&args);
+ if (err > 0) {
+ nvme_show_status(err);
+ } else if (err < 0) {
+ nvme_show_perror("Define PLP Health Check Interval");
+ fprintf(stderr, "Command failed while parsing.\n");
+ } else {
+ printf("Successfully set the PLP Health Check Interval");
+ printf("PLP Health Check Interval: 0x%x\n", cfg.plp_health_interval);
+ printf("Save bit Value: 0x%x\n", cfg.save);
+ }
+ return err;
}
static int get_plp_health_check_interval(int argc, char **argv, struct command *cmd,
- struct plugin *plugin)
+ struct plugin *plugin)
{
- const char *desc = "Define Issue Get Feature command (FID : 0xC6) PLP Health Check Interval";
- const char *sel = "[0-3,8]: current/default/saved/supported/changed";
- const __u32 nsid = 0;
- const __u8 fid = 0xc6;
- struct nvme_dev *dev;
- __u32 result;
- int err;
-
- struct config {
- __u8 sel;
- };
-
- struct config cfg = {
- .sel = 0,
- };
-
- OPT_ARGS(opts) = {
- OPT_BYTE("sel", 'S', &cfg.sel, sel),
- OPT_END()
- };
-
- err = parse_and_open(&dev, argc, argv, desc, opts);
- if (err)
- return err;
-
-
- struct nvme_get_features_args args = {
- .args_size = sizeof(args),
- .fd = dev_fd(dev),
- .fid = fid,
- .nsid = nsid,
- .sel = cfg.sel,
- .cdw11 = 0,
- .uuidx = 0,
- .data_len = 0,
- .data = NULL,
- .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
- .result = &result,
- };
-
- err = nvme_get_features(&args);
- if (!err) {
- printf("get-feature:0xC6 %s value: %#08x\n", nvme_select_to_string(cfg.sel), result);
-
- if (cfg.sel == NVME_GET_FEATURES_SEL_SUPPORTED)
- nvme_show_select_result(fid, result);
- } else {
- nvme_show_error("Could not get feature: 0xC6");
- }
-
- return err;
+ const char *desc = "Define Issue Get Feature command (FID : 0xC6) PLP Health Check Interval";
+ const char *sel = "[0-3,8]: current/default/saved/supported/changed";
+ const __u32 nsid = 0;
+ const __u8 fid = 0xc6;
+ struct nvme_dev *dev;
+ __u32 result;
+ int err;
+
+ struct config {
+ __u8 sel;
+ };
+
+ struct config cfg = {
+ .sel = 0,
+ };
+
+ OPT_ARGS(opts) = {
+ OPT_BYTE("sel", 'S', &cfg.sel, sel),
+ OPT_END()
+ };
+
+ err = parse_and_open(&dev, argc, argv, desc, opts);
+ if (err)
+ return err;
+
+
+ struct nvme_get_features_args args = {
+ .args_size = sizeof(args),
+ .fd = dev_fd(dev),
+ .fid = fid,
+ .nsid = nsid,
+ .sel = cfg.sel,
+ .cdw11 = 0,
+ .uuidx = 0,
+ .data_len = 0,
+ .data = NULL,
+ .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
+ .result = &result,
+ };
+
+ err = nvme_get_features(&args);
+ if (!err) {
+ printf("get-feature:0xC6 %s value: %#08x\n", nvme_select_to_string(cfg.sel), result);
+
+ if (cfg.sel == NVME_GET_FEATURES_SEL_SUPPORTED)
+ nvme_show_select_result(fid, result);
+ } else {
+ nvme_show_error("Could not get feature: 0xC6");
+ }
+
+ return err;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+/// dssd_async_event_config
+
+static int set_dssd_async_event_config(int argc, char **argv, struct command *cmd,
+ struct plugin *plugin)
+{
+
+ const char *desc = "Issue Set Feature command (FID : 0xC9) DSSD Async Event Config";
+ const char *epn = "[0]:Enable Panic Notices";
+ const char *save = "Specifies that the controller shall save the attribute";
+ const __u32 nsid = 0;
+ const __u8 fid = 0xc9;
+ struct nvme_dev *dev;
+ int err;
+ __u32 result;
+ __u8 uuid_index = 0;
+
+ struct config {
+ bool epn;
+ bool save;
+ };
+
+ struct config cfg = {
+ .epn = false,
+ .save = false,
+ };
+
+ OPT_ARGS(opts) = {
+ OPT_FLAG("enable-panic-notices", 'e', &cfg.epn, epn),
+ OPT_FLAG("save", 's', &cfg.save, save),
+ OPT_END()
+ };
+
+ err = parse_and_open(&dev, argc, argv, desc, opts);
+ if (err)
+ return err;
+
+ /* OCP 2.0 requires UUID index support */
+ err = ocp_get_uuid_index(dev, &uuid_index);
+ if (err || !uuid_index) {
+ printf("ERROR: No OCP UUID index found\n");
+ return err;
+ }
+
+ struct nvme_set_features_args args = {
+ .args_size = sizeof(args),
+ .fd = dev_fd(dev),
+ .fid = fid,
+ .nsid = nsid,
+ .cdw11 = cfg.epn ? 1 : 0,
+ .cdw12 = 0,
+ .save = cfg.save,
+ .uuidx = uuid_index,
+ .cdw15 = 0,
+ .data_len = 0,
+ .data = NULL,
+ .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
+ .result = &result,
+ };
+
+ err = nvme_set_features(&args);
+ if (err > 0) {
+ nvme_show_status(err);
+ } else if (err < 0) {
+ nvme_show_perror("Set DSSD Asynchronous Event Configuration\n");
+ fprintf(stderr, "Command failed while parsing.\n");
+ } else {
+ printf("Successfully set the DSSD Asynchronous Event Configuration\n");
+ printf("Enable Panic Notices bit Value: 0x%x\n", cfg.epn);
+ printf("Save bit Value: 0x%x\n", cfg.save);
+ }
+ return err;
+}
+
+static int get_dssd_async_event_config(int argc, char **argv, struct command *cmd,
+ struct plugin *plugin)
+{
+
+ const char *desc = "Issue Get Feature command (FID : 0xC9) DSSD Async Event Config";
+ const char *sel = "[0-3]: current/default/saved/supported";
+ const __u32 nsid = 0;
+ const __u8 fid = 0xc9;
+ struct nvme_dev *dev;
+ __u32 result;
+ int err;
+
+ struct config {
+ __u8 sel;
+ };
+
+ struct config cfg = {
+ .sel = 0,
+ };
+
+ OPT_ARGS(opts) = {
+ OPT_BYTE("sel", 'S', &cfg.sel, sel),
+ OPT_END()
+ };
+
+ err = parse_and_open(&dev, argc, argv, desc, opts);
+ if (err)
+ return err;
+
+
+ struct nvme_get_features_args args = {
+ .args_size = sizeof(args),
+ .fd = dev_fd(dev),
+ .fid = fid,
+ .nsid = nsid,
+ .sel = cfg.sel,
+ .cdw11 = 0,
+ .uuidx = 0,
+ .data_len = 0,
+ .data = NULL,
+ .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
+ .result = &result,
+ };
+
+ err = nvme_get_features(&args);
+ if (!err) {
+ printf("get-feature:0xC9 %s value: %#08x\n", nvme_select_to_string(cfg.sel), result);
+
+ if (cfg.sel == NVME_GET_FEATURES_SEL_SUPPORTED)
+ nvme_show_select_result(fid, result);
+ } else {
+ nvme_show_error("Could not get feature: 0xC9\n");
+ }
+
+ return err;
}
///////////////////////////////////////////////////////////////////////////////
@@ -2342,36 +2560,36 @@ static int get_plp_health_check_interval(int argc, char **argv, struct command *
* @reserved3: reserved
*/
struct __attribute__((__packed__)) telemetry_str_log_format {
- __u8 log_page_version;
- __u8 reserved1[15];
- __u8 log_page_guid[C9_GUID_LENGTH];
- __le64 sls;
- __u8 reserved2[24];
- __le64 sits;
- __le64 sitsz;
- __le64 ests;
- __le64 estsz;
- __le64 vu_eve_sts;
- __le64 vu_eve_st_sz;
- __le64 ascts;
- __le64 asctsz;
- __u8 fifo1[16];
- __u8 fifo2[16];
- __u8 fifo3[16];
- __u8 fifo4[16];
- __u8 fifo5[16];
- __u8 fifo6[16];
- __u8 fifo7[16];
- __u8 fifo8[16];
- __u8 fifo9[16];
- __u8 fifo10[16];
- __u8 fifo11[16];
- __u8 fifo12[16];
- __u8 fifo13[16];
- __u8 fifo14[16];
- __u8 fifo15[16];
- __u8 fifo16[16];
- __u8 reserved3[48];
+ __u8 log_page_version;
+ __u8 reserved1[15];
+ __u8 log_page_guid[C9_GUID_LENGTH];
+ __le64 sls;
+ __u8 reserved2[24];
+ __le64 sits;
+ __le64 sitsz;
+ __le64 ests;
+ __le64 estsz;
+ __le64 vu_eve_sts;
+ __le64 vu_eve_st_sz;
+ __le64 ascts;
+ __le64 asctsz;
+ __u8 fifo1[16];
+ __u8 fifo2[16];
+ __u8 fifo3[16];
+ __u8 fifo4[16];
+ __u8 fifo5[16];
+ __u8 fifo6[16];
+ __u8 fifo7[16];
+ __u8 fifo8[16];
+ __u8 fifo9[16];
+ __u8 fifo10[16];
+ __u8 fifo11[16];
+ __u8 fifo12[16];
+ __u8 fifo13[16];
+ __u8 fifo14[16];
+ __u8 fifo15[16];
+ __u8 fifo16[16];
+ __u8 reserved3[48];
};
/*
@@ -2385,11 +2603,11 @@ struct __attribute__((__packed__)) telemetry_str_log_format {
* @reserved2 reserved
*/
struct __attribute__((__packed__)) statistics_id_str_table_entry {
- __le16 vs_si;
- __u8 reserved1;
- __u8 ascii_id_len;
- __le64 ascii_id_ofst;
- __le32 reserved2;
+ __le16 vs_si;
+ __u8 reserved1;
+ __u8 ascii_id_len;
+ __le64 ascii_id_ofst;
+ __le32 reserved2;
};
/*
@@ -2402,11 +2620,11 @@ struct __attribute__((__packed__)) statistics_id_str_table_entry {
* @reserved2 reserved
*/
struct __attribute__((__packed__)) event_id_str_table_entry {
- __u8 deb_eve_class;
- __le16 ei;
- __u8 ascii_id_len;
- __le64 ascii_id_ofst;
- __le32 reserved2;
+ __u8 deb_eve_class;
+ __le16 ei;
+ __u8 ascii_id_len;
+ __le64 ascii_id_ofst;
+ __le32 reserved2;
};
/*
@@ -2419,525 +2637,525 @@ struct __attribute__((__packed__)) event_id_str_table_entry {
* @reserved reserved
*/
struct __attribute__((__packed__)) vu_event_id_str_table_entry {
- __u8 deb_eve_class;
- __le16 vu_ei;
- __u8 ascii_id_len;
- __le64 ascii_id_ofst;
- __le32 reserved;
+ __u8 deb_eve_class;
+ __le16 vu_ei;
+ __u8 ascii_id_len;
+ __le64 ascii_id_ofst;
+ __le32 reserved;
};
/* Function declaration for Telemetry String Log Format (LID:C9h) */
static int ocp_telemetry_str_log_format(int argc, char **argv, struct command *cmd,
- struct plugin *plugin);
+ struct plugin *plugin);
static int ocp_print_C9_log_normal(struct telemetry_str_log_format *log_data,__u8 *log_data_buf)
{
- //calculating the index value for array
- __le64 stat_id_index = (log_data->sitsz * 4) / 16;
- __le64 eve_id_index = (log_data->estsz * 4) / 16;
- __le64 vu_eve_index = (log_data->vu_eve_st_sz * 4) / 16;
- __le64 ascii_table_index = (log_data->asctsz * 4);
- //Calculating the offset for dynamic fields.
- __le64 stat_id_str_table_ofst = C9_TELEMETRY_STR_LOG_SIST_OFST + (log_data->sitsz * 4);
- __le64 event_str_table_ofst = stat_id_str_table_ofst + (log_data->estsz * 4);
- __le64 vu_event_str_table_ofst = event_str_table_ofst + (log_data->vu_eve_st_sz * 4);
- __le64 ascii_table_ofst = vu_event_str_table_ofst + (log_data->asctsz * 4);
- struct statistics_id_str_table_entry stat_id_str_table_arr[stat_id_index];
- struct event_id_str_table_entry event_id_str_table_arr[eve_id_index];
- struct vu_event_id_str_table_entry vu_event_id_str_table_arr[vu_eve_index];
- __u8 ascii_table_info_arr[ascii_table_index];
- int j;
-
- printf(" Log Page Version : 0x%x\n", log_data->log_page_version);
-
- printf(" Reserved : ");
- for (j = 0; j < 15; j++)
- printf("%d", log_data->reserved1[j]);
- printf("\n");
-
- printf(" Log page GUID : 0x");
- for (j = C9_GUID_LENGTH - 1; j >= 0; j--)
- printf("%x", log_data->log_page_guid[j]);
- printf("\n");
-
- printf(" Telemetry String Log Size : 0x%lx\n", le64_to_cpu(log_data->sls));
-
- printf(" Reserved : ");
- for (j = 0; j < 24; j++)
- printf("%d", log_data->reserved2[j]);
- printf("\n");
-
- printf(" Statistics Identifier String Table Start : 0x%lx\n", le64_to_cpu(log_data->sits));
- printf(" Statistics Identifier String Table Size : 0x%lx\n", le64_to_cpu(log_data->sitsz));
- printf(" Event String Table Start : 0x%lx\n", le64_to_cpu(log_data->ests));
- printf(" Event String Table Size : 0x%lx\n", le64_to_cpu(log_data->estsz));
- printf(" VU Event String Table Start : 0x%lx\n", le64_to_cpu(log_data->vu_eve_sts));
- printf(" VU Event String Table Size : 0x%lx\n", le64_to_cpu(log_data->vu_eve_st_sz));
- printf(" ASCII Table Start : 0x%lx\n", le64_to_cpu(log_data->ascts));
- printf(" ASCII Table Size : 0x%lx\n", le64_to_cpu(log_data->asctsz));
-
- printf(" FIFO 1 ASCII String\n");
- printf(" index value ascii_val\n");
- for (j = 0; j < 16; j++){
- printf(" %d %d %c \n", j, log_data->fifo1[j], log_data->fifo1[j]);
- }
-
- printf(" FIFO 2 ASCII String\n");
- printf(" index value ascii_val\n");
- for (j = 0; j < 16; j++){
- printf(" %d %d %c \n", j, log_data->fifo2[j], log_data->fifo2[j]);
- }
-
- printf(" FIFO 3 ASCII String\n");
- printf(" index value ascii_val\n");
- for (j = 0; j < 16; j++){
- printf(" %d %d %c \n", j, log_data->fifo3[j], log_data->fifo3[j]);
- }
-
- printf(" FIFO 4 ASCII String\n");
- printf(" index value ascii_val\n");
- for (j = 0; j < 16; j++){
-
- printf(" %d %d %c \n", j, log_data->fifo4[j], log_data->fifo4[j]);
- }
-
- printf(" FIFO 5 ASCII String\n");
- printf(" index value ascii_val\n");
- for (j = 0; j < 16; j++){
- printf(" %d %d %c \n", j, log_data->fifo5[j], log_data->fifo5[j]);
- }
-
- printf(" FIFO 6 ASCII String\n");
- printf(" index value ascii_val\n");
- for (j = 0; j < 16; j++){
- printf(" %d %d %c \n", j, log_data->fifo6[j], log_data->fifo6[j]);
- }
-
- printf(" FIFO 7 ASCII String\n");
- printf(" index value ascii_val\n");
- for (j = 0; j < 16; j++){
- printf(" %d %d %c \n", j, log_data->fifo7[j], log_data->fifo7[j]);
- }
-
- printf(" FIFO 8 ASCII String\n");
- printf(" index value ascii_val\n");
- for (j = 0; j < 16; j++){
- printf("index value ascii_val");
- printf(" %d %d %c \n", j, log_data->fifo8[j], log_data->fifo8[j]);
- }
-
- printf(" FIFO 9 ASCII String\n");
- printf(" index value ascii_val\n");
- for (j = 0; j < 16; j++){
- printf(" %d %d %c \n", j, log_data->fifo9[j], log_data->fifo9[j]);
- }
-
- printf(" FIFO 10 ASCII String\n");
- printf(" index value ascii_val\n");
- for (j = 0; j < 16; j++){
- printf(" %d %d %c \n", j, log_data->fifo10[j], log_data->fifo10[j]);
- }
-
- printf(" FIFO 11 ASCII String\n");
- printf(" index value ascii_val\n");
- for (j = 0; j < 16; j++){
- printf(" %d %d %c \n", j, log_data->fifo11[j], log_data->fifo11[j]);
- }
-
- printf(" FIFO 12 ASCII String\n");
- printf(" index value ascii_val\n");
- for (j = 0; j < 16; j++){
- printf(" %d %d %c \n", j, log_data->fifo12[j], log_data->fifo12[j]);
- }
-
- printf(" FIFO 13 ASCII String\n");
- printf(" index value ascii_val\n");
- for (j = 0; j < 16; j++){
- printf(" %d %d %c \n", j, log_data->fifo13[j], log_data->fifo13[j]);
- }
-
- printf(" FIFO 14 ASCII String\n");
- printf(" index value ascii_val\n");
- for (j = 0; j < 16; j++){
- printf(" %d %d %c \n", j, log_data->fifo14[j], log_data->fifo14[j]);
- }
-
- printf(" FIFO 15 ASCII String\n");
- printf(" index value ascii_val\n");
- for (j = 0; j < 16; j++){
- printf(" %d %d %c \n", j, log_data->fifo15[j], log_data->fifo16[j]);
- }
-
- printf(" FIFO 16 ASCII String\n");
- printf(" index value ascii_val\n");
- for (j = 0; j < 16; j++){
- printf(" %d %d %c \n", j, log_data->fifo16[j], log_data->fifo16[j]);
- }
-
- printf(" Reserved : ");
- for (j = 0; j < 48; j++)
- printf("%d", log_data->reserved3[j]);
- printf("\n");
-
- memcpy(stat_id_str_table_arr, (__u8*)log_data_buf + stat_id_str_table_ofst, (log_data->sitsz * 4));
- memcpy(event_id_str_table_arr, (__u8*)log_data_buf + event_str_table_ofst, (log_data->estsz * 4));
- memcpy(vu_event_id_str_table_arr, (__u8*)log_data_buf + vu_event_str_table_ofst, (log_data->vu_eve_st_sz * 4));
- memcpy(ascii_table_info_arr, (__u8*)log_data_buf + ascii_table_ofst, (log_data->asctsz * 4));
-
- printf(" Statistics Identifier String Table\n");
- for (j = 0; j < stat_id_index; j++){
- printf(" Vendor Specific Statistic Identifier : 0x%x\n",le16_to_cpu(stat_id_str_table_arr[j].vs_si));
- printf(" Reserved : 0x%d",stat_id_str_table_arr[j].reserved1);
- printf(" ASCII ID Length : 0x%x\n",stat_id_str_table_arr[j].ascii_id_len);
- printf(" ASCII ID offset : 0x%lx\n",le64_to_cpu(stat_id_str_table_arr[j].ascii_id_ofst));
- printf(" Reserved : 0x%d\n",stat_id_str_table_arr[j].reserved2);
- }
-
- printf(" Event Identifier String Table Entry\n");
- for (j = 0; j < eve_id_index; j++){
- printf(" Debug Event Class : 0x%x\n",event_id_str_table_arr[j].deb_eve_class);
- printf(" Event Identifier : 0x%x\n",le16_to_cpu(event_id_str_table_arr[j].ei));
- printf(" ASCII ID Length : 0x%x\n",event_id_str_table_arr[j].ascii_id_len);
- printf(" ASCII ID offset : 0x%lx\n",le64_to_cpu(event_id_str_table_arr[j].ascii_id_ofst));
- printf(" Reserved : 0x%d\n",event_id_str_table_arr[j].reserved2);
-
- }
-
- printf(" VU Event Identifier String Table Entry\n");
- for (j = 0; j < vu_eve_index; j++){
- printf(" Debug Event Class : 0x%x\n",vu_event_id_str_table_arr[j].deb_eve_class);
- printf(" VU Event Identifier : 0x%x\n",le16_to_cpu(vu_event_id_str_table_arr[j].vu_ei));
- printf(" ASCII ID Length : 0x%x\n",vu_event_id_str_table_arr[j].ascii_id_len);
- printf(" ASCII ID offset : 0x%lx\n",le64_to_cpu(vu_event_id_str_table_arr[j].ascii_id_ofst));
- printf(" Reserved : 0x%d\n",vu_event_id_str_table_arr[j].reserved);
-
- }
-
- printf(" ASCII Table\n");
- printf(" Byte Data_Byte ASCII_Character\n");
- for (j = 0; j < ascii_table_index; j++){
- printf(" %lld 0x%x %c \n",ascii_table_ofst+j,ascii_table_info_arr[j],ascii_table_info_arr[j]);
- }
- return 0;
+ //calculating the index value for array
+ __le64 stat_id_index = (log_data->sitsz * 4) / 16;
+ __le64 eve_id_index = (log_data->estsz * 4) / 16;
+ __le64 vu_eve_index = (log_data->vu_eve_st_sz * 4) / 16;
+ __le64 ascii_table_index = (log_data->asctsz * 4);
+ //Calculating the offset for dynamic fields.
+ __le64 stat_id_str_table_ofst = C9_TELEMETRY_STR_LOG_SIST_OFST + (log_data->sitsz * 4);
+ __le64 event_str_table_ofst = stat_id_str_table_ofst + (log_data->estsz * 4);
+ __le64 vu_event_str_table_ofst = event_str_table_ofst + (log_data->vu_eve_st_sz * 4);
+ __le64 ascii_table_ofst = vu_event_str_table_ofst + (log_data->asctsz * 4);
+ struct statistics_id_str_table_entry stat_id_str_table_arr[stat_id_index];
+ struct event_id_str_table_entry event_id_str_table_arr[eve_id_index];
+ struct vu_event_id_str_table_entry vu_event_id_str_table_arr[vu_eve_index];
+ __u8 ascii_table_info_arr[ascii_table_index];
+ int j;
+
+ printf(" Log Page Version : 0x%x\n", log_data->log_page_version);
+
+ printf(" Reserved : ");
+ for (j = 0; j < 15; j++)
+ printf("%d", log_data->reserved1[j]);
+ printf("\n");
+
+ printf(" Log page GUID : 0x");
+ for (j = C9_GUID_LENGTH - 1; j >= 0; j--)
+ printf("%x", log_data->log_page_guid[j]);
+ printf("\n");
+
+ printf(" Telemetry String Log Size : 0x%lx\n", le64_to_cpu(log_data->sls));
+
+ printf(" Reserved : ");
+ for (j = 0; j < 24; j++)
+ printf("%d", log_data->reserved2[j]);
+ printf("\n");
+
+ printf(" Statistics Identifier String Table Start : 0x%lx\n", le64_to_cpu(log_data->sits));
+ printf(" Statistics Identifier String Table Size : 0x%lx\n", le64_to_cpu(log_data->sitsz));
+ printf(" Event String Table Start : 0x%lx\n", le64_to_cpu(log_data->ests));
+ printf(" Event String Table Size : 0x%lx\n", le64_to_cpu(log_data->estsz));
+ printf(" VU Event String Table Start : 0x%lx\n", le64_to_cpu(log_data->vu_eve_sts));
+ printf(" VU Event String Table Size : 0x%lx\n", le64_to_cpu(log_data->vu_eve_st_sz));
+ printf(" ASCII Table Start : 0x%lx\n", le64_to_cpu(log_data->ascts));
+ printf(" ASCII Table Size : 0x%lx\n", le64_to_cpu(log_data->asctsz));
+
+ printf(" FIFO 1 ASCII String\n");
+ printf(" index value ascii_val\n");
+ for (j = 0; j < 16; j++){
+ printf(" %d %d %c \n", j, log_data->fifo1[j], log_data->fifo1[j]);
+ }
+
+ printf(" FIFO 2 ASCII String\n");
+ printf(" index value ascii_val\n");
+ for (j = 0; j < 16; j++){
+ printf(" %d %d %c \n", j, log_data->fifo2[j], log_data->fifo2[j]);
+ }
+
+ printf(" FIFO 3 ASCII String\n");
+ printf(" index value ascii_val\n");
+ for (j = 0; j < 16; j++){
+ printf(" %d %d %c \n", j, log_data->fifo3[j], log_data->fifo3[j]);
+ }
+
+ printf(" FIFO 4 ASCII String\n");
+ printf(" index value ascii_val\n");
+ for (j = 0; j < 16; j++){
+
+ printf(" %d %d %c \n", j, log_data->fifo4[j], log_data->fifo4[j]);
+ }
+
+ printf(" FIFO 5 ASCII String\n");
+ printf(" index value ascii_val\n");
+ for (j = 0; j < 16; j++){
+ printf(" %d %d %c \n", j, log_data->fifo5[j], log_data->fifo5[j]);
+ }
+
+ printf(" FIFO 6 ASCII String\n");
+ printf(" index value ascii_val\n");
+ for (j = 0; j < 16; j++){
+ printf(" %d %d %c \n", j, log_data->fifo6[j], log_data->fifo6[j]);
+ }
+
+ printf(" FIFO 7 ASCII String\n");
+ printf(" index value ascii_val\n");
+ for (j = 0; j < 16; j++){
+ printf(" %d %d %c \n", j, log_data->fifo7[j], log_data->fifo7[j]);
+ }
+
+ printf(" FIFO 8 ASCII String\n");
+ printf(" index value ascii_val\n");
+ for (j = 0; j < 16; j++){
+ printf("index value ascii_val");
+ printf(" %d %d %c \n", j, log_data->fifo8[j], log_data->fifo8[j]);
+ }
+
+ printf(" FIFO 9 ASCII String\n");
+ printf(" index value ascii_val\n");
+ for (j = 0; j < 16; j++){
+ printf(" %d %d %c \n", j, log_data->fifo9[j], log_data->fifo9[j]);
+ }
+
+ printf(" FIFO 10 ASCII String\n");
+ printf(" index value ascii_val\n");
+ for (j = 0; j < 16; j++){
+ printf(" %d %d %c \n", j, log_data->fifo10[j], log_data->fifo10[j]);
+ }
+
+ printf(" FIFO 11 ASCII String\n");
+ printf(" index value ascii_val\n");
+ for (j = 0; j < 16; j++){
+ printf(" %d %d %c \n", j, log_data->fifo11[j], log_data->fifo11[j]);
+ }
+
+ printf(" FIFO 12 ASCII String\n");
+ printf(" index value ascii_val\n");
+ for (j = 0; j < 16; j++){
+ printf(" %d %d %c \n", j, log_data->fifo12[j], log_data->fifo12[j]);
+ }
+
+ printf(" FIFO 13 ASCII String\n");
+ printf(" index value ascii_val\n");
+ for (j = 0; j < 16; j++){
+ printf(" %d %d %c \n", j, log_data->fifo13[j], log_data->fifo13[j]);
+ }
+
+ printf(" FIFO 14 ASCII String\n");
+ printf(" index value ascii_val\n");
+ for (j = 0; j < 16; j++){
+ printf(" %d %d %c \n", j, log_data->fifo14[j], log_data->fifo14[j]);
+ }
+
+ printf(" FIFO 15 ASCII String\n");
+ printf(" index value ascii_val\n");
+ for (j = 0; j < 16; j++){
+ printf(" %d %d %c \n", j, log_data->fifo15[j], log_data->fifo16[j]);
+ }
+
+ printf(" FIFO 16 ASCII String\n");
+ printf(" index value ascii_val\n");
+ for (j = 0; j < 16; j++){
+ printf(" %d %d %c \n", j, log_data->fifo16[j], log_data->fifo16[j]);
+ }
+
+ printf(" Reserved : ");
+ for (j = 0; j < 48; j++)
+ printf("%d", log_data->reserved3[j]);
+ printf("\n");
+
+ memcpy(stat_id_str_table_arr, (__u8*)log_data_buf + stat_id_str_table_ofst, (log_data->sitsz * 4));
+ memcpy(event_id_str_table_arr, (__u8*)log_data_buf + event_str_table_ofst, (log_data->estsz * 4));
+ memcpy(vu_event_id_str_table_arr, (__u8*)log_data_buf + vu_event_str_table_ofst, (log_data->vu_eve_st_sz * 4));
+ memcpy(ascii_table_info_arr, (__u8*)log_data_buf + ascii_table_ofst, (log_data->asctsz * 4));
+
+ printf(" Statistics Identifier String Table\n");
+ for (j = 0; j < stat_id_index; j++){
+ printf(" Vendor Specific Statistic Identifier : 0x%x\n",le16_to_cpu(stat_id_str_table_arr[j].vs_si));
+ printf(" Reserved : 0x%d",stat_id_str_table_arr[j].reserved1);
+ printf(" ASCII ID Length : 0x%x\n",stat_id_str_table_arr[j].ascii_id_len);
+ printf(" ASCII ID offset : 0x%lx\n",le64_to_cpu(stat_id_str_table_arr[j].ascii_id_ofst));
+ printf(" Reserved : 0x%d\n",stat_id_str_table_arr[j].reserved2);
+ }
+
+ printf(" Event Identifier String Table Entry\n");
+ for (j = 0; j < eve_id_index; j++){
+ printf(" Debug Event Class : 0x%x\n",event_id_str_table_arr[j].deb_eve_class);
+ printf(" Event Identifier : 0x%x\n",le16_to_cpu(event_id_str_table_arr[j].ei));
+ printf(" ASCII ID Length : 0x%x\n",event_id_str_table_arr[j].ascii_id_len);
+ printf(" ASCII ID offset : 0x%lx\n",le64_to_cpu(event_id_str_table_arr[j].ascii_id_ofst));
+ printf(" Reserved : 0x%d\n",event_id_str_table_arr[j].reserved2);
+
+ }
+
+ printf(" VU Event Identifier String Table Entry\n");
+ for (j = 0; j < vu_eve_index; j++){
+ printf(" Debug Event Class : 0x%x\n",vu_event_id_str_table_arr[j].deb_eve_class);
+ printf(" VU Event Identifier : 0x%x\n",le16_to_cpu(vu_event_id_str_table_arr[j].vu_ei));
+ printf(" ASCII ID Length : 0x%x\n",vu_event_id_str_table_arr[j].ascii_id_len);
+ printf(" ASCII ID offset : 0x%lx\n",le64_to_cpu(vu_event_id_str_table_arr[j].ascii_id_ofst));
+ printf(" Reserved : 0x%d\n",vu_event_id_str_table_arr[j].reserved);
+
+ }
+
+ printf(" ASCII Table\n");
+ printf(" Byte Data_Byte ASCII_Character\n");
+ for (j = 0; j < ascii_table_index; j++){
+ printf(" %lld 0x%x %c \n",ascii_table_ofst+j,ascii_table_info_arr[j],ascii_table_info_arr[j]);
+ }
+ return 0;
}
static int ocp_print_C9_log_json(struct telemetry_str_log_format *log_data,__u8 *log_data_buf)
{
- struct json_object *root = json_create_object();
- struct json_object *stat_table = json_create_object();
- struct json_object *eve_table = json_create_object();
- struct json_object *vu_eve_table = json_create_object();
- struct json_object *entry = json_create_object();
- char res_arr[48];
- char *res = res_arr;
- char guid_buf[C9_GUID_LENGTH];
- char *guid = guid_buf;
- char fifo_arr[16];
- char *fifo = fifo_arr;
- //calculating the index value for array
- __le64 stat_id_index = (log_data->sitsz * 4) / 16;
- __le64 eve_id_index = (log_data->estsz * 4) / 16;
- __le64 vu_eve_index = (log_data->vu_eve_st_sz * 4) / 16;
- __le64 ascii_table_index = (log_data->asctsz * 4);
- //Calculating the offset for dynamic fields.
- __le64 stat_id_str_table_ofst = C9_TELEMETRY_STR_LOG_SIST_OFST + (log_data->sitsz * 4);
- __le64 event_str_table_ofst = stat_id_str_table_ofst + (log_data->estsz * 4);
- __le64 vu_event_str_table_ofst = event_str_table_ofst + (log_data->vu_eve_st_sz * 4);
- __le64 ascii_table_ofst = vu_event_str_table_ofst + (log_data->asctsz * 4);
- struct statistics_id_str_table_entry stat_id_str_table_arr[stat_id_index];
- struct event_id_str_table_entry event_id_str_table_arr[eve_id_index];
- struct vu_event_id_str_table_entry vu_event_id_str_table_arr[vu_eve_index];
- __u8 ascii_table_info_arr[ascii_table_index];
- char ascii_buf[ascii_table_index];
- char *ascii = ascii_buf;
- int j;
-
- json_object_add_value_int(root, "Log Page Version", le16_to_cpu(log_data->log_page_version));
-
- memset((__u8 *)res, 0, 15);
- for (j = 0; j < 15; j++)
- res += sprintf(res, "%d", log_data->reserved1[j]);
- json_object_add_value_string(root, "Reserved", res_arr);
-
- memset((void *)guid, 0, C9_GUID_LENGTH);
- for (j = C9_GUID_LENGTH - 1; j >= 0; j--)
- guid += sprintf(guid, "%02x", log_data->log_page_guid[j]);
- json_object_add_value_string(root, "Log page GUID", guid_buf);
-
- json_object_add_value_int(root, "Telemetry String Log Size", le64_to_cpu(log_data->sls));
-
- memset((__u8 *)res, 0, 24);
- for (j = 0; j < 24; j++)
- res += sprintf(res, "%d", log_data->reserved2[j]);
- json_object_add_value_string(root, "Reserved", res_arr);
-
- json_object_add_value_int(root, "Statistics Identifier String Table Start", le64_to_cpu(log_data->sits));
- json_object_add_value_int(root, "Event String Table Start", le64_to_cpu(log_data->ests));
- json_object_add_value_int(root, "Event String Table Size", le64_to_cpu(log_data->estsz));
- json_object_add_value_int(root, "VU Event String Table Start", le64_to_cpu(log_data->vu_eve_sts));
- json_object_add_value_int(root, "VU Event String Table Size", le64_to_cpu(log_data->vu_eve_st_sz));
- json_object_add_value_int(root, "ASCII Table Start", le64_to_cpu(log_data->ascts));
- json_object_add_value_int(root, "ASCII Table Size", le64_to_cpu(log_data->asctsz));
-
- memset((void *)fifo, 0, 16);
- for (j = 0; j < 16; j++)
- fifo += sprintf(fifo, "%c", log_data->fifo1[j]);
- json_object_add_value_string(root, "FIFO 1 ASCII String", fifo_arr);
-
- memset((void *)fifo, 0, 16);
- for (j = 0; j < 16; j++)
- fifo += sprintf(fifo, "%c", log_data->fifo2[j]);
- json_object_add_value_string(root, "FIFO 2 ASCII String", fifo_arr);
-
- memset((void *)fifo, 0, 16);
- for (j = 0; j < 16; j++)
- fifo += sprintf(fifo, "%c", log_data->fifo3[j]);
- json_object_add_value_string(root, "FIFO 3 ASCII String", fifo_arr);
-
- memset((void *)fifo, 0, 16);
- for (j = 0; j < 16; j++)
- fifo += sprintf(fifo, "%c", log_data->fifo4[j]);
- json_object_add_value_string(root, "FIFO 4 ASCII String", fifo_arr);
-
- memset((void *)fifo, 0, 16);
- for (j = 0; j < 16; j++)
- fifo += sprintf(fifo, "%c", log_data->fifo5[j]);
- json_object_add_value_string(root, "FIFO 5 ASCII String", fifo_arr);
-
- memset((void *)fifo, 0, 16);
- for (j = 0; j < 16; j++)
- fifo += sprintf(fifo, "%c", log_data->fifo6[j]);
- json_object_add_value_string(root, "FIFO 6 ASCII String", fifo_arr);
-
- memset((void *)fifo, 0, 16);
- for (j = 0; j < 16; j++)
- fifo += sprintf(fifo, "%c", log_data->fifo7[j]);
- json_object_add_value_string(root, "FIFO 7 ASCII String", fifo_arr);
-
- memset((void *)fifo, 0, 16);
- for (j = 0; j < 16; j++)
- fifo += sprintf(fifo, "%c", log_data->fifo8[j]);
- json_object_add_value_string(root, "FIFO 8 ASCII String", fifo_arr);
-
- memset((void *)fifo, 0, 16);
- for (j = 0; j < 16; j++)
- fifo += sprintf(fifo, "%c", log_data->fifo9[j]);
- json_object_add_value_string(root, "FIFO 9 ASCII String", fifo_arr);
-
- memset((void *)fifo, 0, 16);
- for (j = 0; j < 16; j++)
- fifo += sprintf(fifo, "%c", log_data->fifo10[j]);
- json_object_add_value_string(root, "FIFO 10 ASCII String", fifo_arr);
-
- memset((void *)fifo, 0, 16);
- for (j = 0; j < 16; j++)
- fifo += sprintf(fifo, "%c", log_data->fifo11[j]);
- json_object_add_value_string(root, "FIFO 11 ASCII String", fifo_arr);
-
- memset((void *)fifo, 0, 16);
- for (j = 0; j < 16; j++)
- fifo += sprintf(fifo, "%c", log_data->fifo12[j]);
- json_object_add_value_string(root, "FIFO 12 ASCII String", fifo_arr);
-
- memset((void *)fifo, 0, 16);
- for (j = 0; j < 16; j++)
- fifo += sprintf(fifo, "%c", log_data->fifo13[j]);
- json_object_add_value_string(root, "FIFO 13 ASCII String", fifo_arr);
-
- memset((void *)fifo, 0, 16);
- for (j = 0; j < 16; j++)
- fifo += sprintf(fifo, "%c", log_data->fifo14[j]);
- json_object_add_value_string(root, "FIFO 14 ASCII String", fifo_arr);
-
- memset((void *)fifo, 0, 16);
- for (j = 0; j < 16; j++)
- fifo += sprintf(fifo, "%c", log_data->fifo15[j]);
- json_object_add_value_string(root, "FIFO 15 ASCII String", fifo_arr);
-
- memset((void *)fifo, 0, 16);
- for (j = 0; j < 16; j++)
- fifo += sprintf(fifo, "%c", log_data->fifo16[j]);
- json_object_add_value_string(root, "FIFO 16 ASCII String", fifo_arr);
-
- memset((__u8 *)res, 0, 48);
- for (j = 0; j < 48; j++)
- res += sprintf(res, "%d", log_data->reserved3[j]);
- json_object_add_value_string(root, "Reserved", res_arr);
-
- memcpy(stat_id_str_table_arr, (__u8*)log_data_buf + stat_id_str_table_ofst, (log_data->sitsz * 4));
- memcpy(event_id_str_table_arr, (__u8*)log_data_buf + event_str_table_ofst, (log_data->estsz * 4));
- memcpy(vu_event_id_str_table_arr, (__u8*)log_data_buf + vu_event_str_table_ofst, (log_data->vu_eve_st_sz * 4));
- memcpy(ascii_table_info_arr, (__u8*)log_data_buf + ascii_table_ofst, (log_data->asctsz * 4));
-
- for (j = 0; j < stat_id_index; j++){
- json_object_add_value_int(entry, "Vendor Specific Statistic Identifier", le16_to_cpu(stat_id_str_table_arr[j].vs_si));
- json_object_add_value_int(entry, "Reserved", le64_to_cpu(stat_id_str_table_arr[j].reserved1));
- json_object_add_value_int(entry, "ASCII ID Length", le64_to_cpu(stat_id_str_table_arr[j].ascii_id_len));
- json_object_add_value_int(entry, "ASCII ID offset", le64_to_cpu(stat_id_str_table_arr[j].ascii_id_ofst));
- json_object_add_value_int(entry, "Reserved", le64_to_cpu(stat_id_str_table_arr[j].reserved2));
- json_array_add_value_object(stat_table, entry);
- }
- json_object_add_value_array(root, "Statistics Identifier String Table", stat_table);
-
- for (j = 0; j < eve_id_index; j++){
- json_object_add_value_int(entry, "Debug Event Class", le16_to_cpu(event_id_str_table_arr[j].deb_eve_class));
- json_object_add_value_int(entry, "Event Identifier", le16_to_cpu(event_id_str_table_arr[j].ei));
- json_object_add_value_int(entry, "ASCII ID Length", le64_to_cpu(event_id_str_table_arr[j].ascii_id_len));
- json_object_add_value_int(entry, "ASCII ID offset", le64_to_cpu(event_id_str_table_arr[j].ascii_id_ofst));
- json_object_add_value_int(entry, "Reserved", le64_to_cpu(event_id_str_table_arr[j].reserved2));
- json_array_add_value_object(eve_table, entry);
- }
- json_object_add_value_array(root, "Event Identifier String Table Entry", eve_table);
-
- for (j = 0; j < vu_eve_index; j++){
- json_object_add_value_int(entry, "Debug Event Class", le16_to_cpu(vu_event_id_str_table_arr[j].deb_eve_class));
- json_object_add_value_int(entry, "VU Event Identifier", le16_to_cpu(vu_event_id_str_table_arr[j].vu_ei));
- json_object_add_value_int(entry, "ASCII ID Length", le64_to_cpu(vu_event_id_str_table_arr[j].ascii_id_len));
- json_object_add_value_int(entry, "ASCII ID offset", le64_to_cpu(vu_event_id_str_table_arr[j].ascii_id_ofst));
- json_object_add_value_int(entry, "Reserved", le64_to_cpu(vu_event_id_str_table_arr[j].reserved));
- json_array_add_value_object(vu_eve_table, entry);
- }
- json_object_add_value_array(root, "VU Event Identifier String Table Entry", vu_eve_table);
-
- memset((void *)ascii, 0, ascii_table_index);
- for (j = 0; j < ascii_table_index; j++)
- ascii += sprintf(ascii, "%c", ascii_table_info_arr[j]);
- json_object_add_value_string(root, "ASCII Table", ascii_buf);
-
- json_print_object(root, NULL);
- printf("\n");
- json_free_object(root);
- json_free_object(stat_table);
- json_free_object(eve_table);
- json_free_object(vu_eve_table);
-
- return 0;
+ struct json_object *root = json_create_object();
+ struct json_object *stat_table = json_create_object();
+ struct json_object *eve_table = json_create_object();
+ struct json_object *vu_eve_table = json_create_object();
+ struct json_object *entry = json_create_object();
+ char res_arr[48];
+ char *res = res_arr;
+ char guid_buf[C9_GUID_LENGTH];
+ char *guid = guid_buf;
+ char fifo_arr[16];
+ char *fifo = fifo_arr;
+ //calculating the index value for array
+ __le64 stat_id_index = (log_data->sitsz * 4) / 16;
+ __le64 eve_id_index = (log_data->estsz * 4) / 16;
+ __le64 vu_eve_index = (log_data->vu_eve_st_sz * 4) / 16;
+ __le64 ascii_table_index = (log_data->asctsz * 4);
+ //Calculating the offset for dynamic fields.
+ __le64 stat_id_str_table_ofst = C9_TELEMETRY_STR_LOG_SIST_OFST + (log_data->sitsz * 4);
+ __le64 event_str_table_ofst = stat_id_str_table_ofst + (log_data->estsz * 4);
+ __le64 vu_event_str_table_ofst = event_str_table_ofst + (log_data->vu_eve_st_sz * 4);
+ __le64 ascii_table_ofst = vu_event_str_table_ofst + (log_data->asctsz * 4);
+ struct statistics_id_str_table_entry stat_id_str_table_arr[stat_id_index];
+ struct event_id_str_table_entry event_id_str_table_arr[eve_id_index];
+ struct vu_event_id_str_table_entry vu_event_id_str_table_arr[vu_eve_index];
+ __u8 ascii_table_info_arr[ascii_table_index];
+ char ascii_buf[ascii_table_index];
+ char *ascii = ascii_buf;
+ int j;
+
+ json_object_add_value_int(root, "Log Page Version", le16_to_cpu(log_data->log_page_version));
+
+ memset((__u8 *)res, 0, 15);
+ for (j = 0; j < 15; j++)
+ res += sprintf(res, "%d", log_data->reserved1[j]);
+ json_object_add_value_string(root, "Reserved", res_arr);
+
+ memset((void *)guid, 0, C9_GUID_LENGTH);
+ for (j = C9_GUID_LENGTH - 1; j >= 0; j--)
+ guid += sprintf(guid, "%02x", log_data->log_page_guid[j]);
+ json_object_add_value_string(root, "Log page GUID", guid_buf);
+
+ json_object_add_value_int(root, "Telemetry String Log Size", le64_to_cpu(log_data->sls));
+
+ memset((__u8 *)res, 0, 24);
+ for (j = 0; j < 24; j++)
+ res += sprintf(res, "%d", log_data->reserved2[j]);
+ json_object_add_value_string(root, "Reserved", res_arr);
+
+ json_object_add_value_int(root, "Statistics Identifier String Table Start", le64_to_cpu(log_data->sits));
+ json_object_add_value_int(root, "Event String Table Start", le64_to_cpu(log_data->ests));
+ json_object_add_value_int(root, "Event String Table Size", le64_to_cpu(log_data->estsz));
+ json_object_add_value_int(root, "VU Event String Table Start", le64_to_cpu(log_data->vu_eve_sts));
+ json_object_add_value_int(root, "VU Event String Table Size", le64_to_cpu(log_data->vu_eve_st_sz));
+ json_object_add_value_int(root, "ASCII Table Start", le64_to_cpu(log_data->ascts));
+ json_object_add_value_int(root, "ASCII Table Size", le64_to_cpu(log_data->asctsz));
+
+ memset((void *)fifo, 0, 16);
+ for (j = 0; j < 16; j++)
+ fifo += sprintf(fifo, "%c", log_data->fifo1[j]);
+ json_object_add_value_string(root, "FIFO 1 ASCII String", fifo_arr);
+
+ memset((void *)fifo, 0, 16);
+ for (j = 0; j < 16; j++)
+ fifo += sprintf(fifo, "%c", log_data->fifo2[j]);
+ json_object_add_value_string(root, "FIFO 2 ASCII String", fifo_arr);
+
+ memset((void *)fifo, 0, 16);
+ for (j = 0; j < 16; j++)
+ fifo += sprintf(fifo, "%c", log_data->fifo3[j]);
+ json_object_add_value_string(root, "FIFO 3 ASCII String", fifo_arr);
+
+ memset((void *)fifo, 0, 16);
+ for (j = 0; j < 16; j++)
+ fifo += sprintf(fifo, "%c", log_data->fifo4[j]);
+ json_object_add_value_string(root, "FIFO 4 ASCII String", fifo_arr);
+
+ memset((void *)fifo, 0, 16);
+ for (j = 0; j < 16; j++)
+ fifo += sprintf(fifo, "%c", log_data->fifo5[j]);
+ json_object_add_value_string(root, "FIFO 5 ASCII String", fifo_arr);
+
+ memset((void *)fifo, 0, 16);
+ for (j = 0; j < 16; j++)
+ fifo += sprintf(fifo, "%c", log_data->fifo6[j]);
+ json_object_add_value_string(root, "FIFO 6 ASCII String", fifo_arr);
+
+ memset((void *)fifo, 0, 16);
+ for (j = 0; j < 16; j++)
+ fifo += sprintf(fifo, "%c", log_data->fifo7[j]);
+ json_object_add_value_string(root, "FIFO 7 ASCII String", fifo_arr);
+
+ memset((void *)fifo, 0, 16);
+ for (j = 0; j < 16; j++)
+ fifo += sprintf(fifo, "%c", log_data->fifo8[j]);
+ json_object_add_value_string(root, "FIFO 8 ASCII String", fifo_arr);
+
+ memset((void *)fifo, 0, 16);
+ for (j = 0; j < 16; j++)
+ fifo += sprintf(fifo, "%c", log_data->fifo9[j]);
+ json_object_add_value_string(root, "FIFO 9 ASCII String", fifo_arr);
+
+ memset((void *)fifo, 0, 16);
+ for (j = 0; j < 16; j++)
+ fifo += sprintf(fifo, "%c", log_data->fifo10[j]);
+ json_object_add_value_string(root, "FIFO 10 ASCII String", fifo_arr);
+
+ memset((void *)fifo, 0, 16);
+ for (j = 0; j < 16; j++)
+ fifo += sprintf(fifo, "%c", log_data->fifo11[j]);
+ json_object_add_value_string(root, "FIFO 11 ASCII String", fifo_arr);
+
+ memset((void *)fifo, 0, 16);
+ for (j = 0; j < 16; j++)
+ fifo += sprintf(fifo, "%c", log_data->fifo12[j]);
+ json_object_add_value_string(root, "FIFO 12 ASCII String", fifo_arr);
+
+ memset((void *)fifo, 0, 16);
+ for (j = 0; j < 16; j++)
+ fifo += sprintf(fifo, "%c", log_data->fifo13[j]);
+ json_object_add_value_string(root, "FIFO 13 ASCII String", fifo_arr);
+
+ memset((void *)fifo, 0, 16);
+ for (j = 0; j < 16; j++)
+ fifo += sprintf(fifo, "%c", log_data->fifo14[j]);
+ json_object_add_value_string(root, "FIFO 14 ASCII String", fifo_arr);
+
+ memset((void *)fifo, 0, 16);
+ for (j = 0; j < 16; j++)
+ fifo += sprintf(fifo, "%c", log_data->fifo15[j]);
+ json_object_add_value_string(root, "FIFO 15 ASCII String", fifo_arr);
+
+ memset((void *)fifo, 0, 16);
+ for (j = 0; j < 16; j++)
+ fifo += sprintf(fifo, "%c", log_data->fifo16[j]);
+ json_object_add_value_string(root, "FIFO 16 ASCII String", fifo_arr);
+
+ memset((__u8 *)res, 0, 48);
+ for (j = 0; j < 48; j++)
+ res += sprintf(res, "%d", log_data->reserved3[j]);
+ json_object_add_value_string(root, "Reserved", res_arr);
+
+ memcpy(stat_id_str_table_arr, (__u8*)log_data_buf + stat_id_str_table_ofst, (log_data->sitsz * 4));
+ memcpy(event_id_str_table_arr, (__u8*)log_data_buf + event_str_table_ofst, (log_data->estsz * 4));
+ memcpy(vu_event_id_str_table_arr, (__u8*)log_data_buf + vu_event_str_table_ofst, (log_data->vu_eve_st_sz * 4));
+ memcpy(ascii_table_info_arr, (__u8*)log_data_buf + ascii_table_ofst, (log_data->asctsz * 4));
+
+ for (j = 0; j < stat_id_index; j++){
+ json_object_add_value_int(entry, "Vendor Specific Statistic Identifier", le16_to_cpu(stat_id_str_table_arr[j].vs_si));
+ json_object_add_value_int(entry, "Reserved", le64_to_cpu(stat_id_str_table_arr[j].reserved1));
+ json_object_add_value_int(entry, "ASCII ID Length", le64_to_cpu(stat_id_str_table_arr[j].ascii_id_len));
+ json_object_add_value_int(entry, "ASCII ID offset", le64_to_cpu(stat_id_str_table_arr[j].ascii_id_ofst));
+ json_object_add_value_int(entry, "Reserved", le64_to_cpu(stat_id_str_table_arr[j].reserved2));
+ json_array_add_value_object(stat_table, entry);
+ }
+ json_object_add_value_array(root, "Statistics Identifier String Table", stat_table);
+
+ for (j = 0; j < eve_id_index; j++){
+ json_object_add_value_int(entry, "Debug Event Class", le16_to_cpu(event_id_str_table_arr[j].deb_eve_class));
+ json_object_add_value_int(entry, "Event Identifier", le16_to_cpu(event_id_str_table_arr[j].ei));
+ json_object_add_value_int(entry, "ASCII ID Length", le64_to_cpu(event_id_str_table_arr[j].ascii_id_len));
+ json_object_add_value_int(entry, "ASCII ID offset", le64_to_cpu(event_id_str_table_arr[j].ascii_id_ofst));
+ json_object_add_value_int(entry, "Reserved", le64_to_cpu(event_id_str_table_arr[j].reserved2));
+ json_array_add_value_object(eve_table, entry);
+ }
+ json_object_add_value_array(root, "Event Identifier String Table Entry", eve_table);
+
+ for (j = 0; j < vu_eve_index; j++){
+ json_object_add_value_int(entry, "Debug Event Class", le16_to_cpu(vu_event_id_str_table_arr[j].deb_eve_class));
+ json_object_add_value_int(entry, "VU Event Identifier", le16_to_cpu(vu_event_id_str_table_arr[j].vu_ei));
+ json_object_add_value_int(entry, "ASCII ID Length", le64_to_cpu(vu_event_id_str_table_arr[j].ascii_id_len));
+ json_object_add_value_int(entry, "ASCII ID offset", le64_to_cpu(vu_event_id_str_table_arr[j].ascii_id_ofst));
+ json_object_add_value_int(entry, "Reserved", le64_to_cpu(vu_event_id_str_table_arr[j].reserved));
+ json_array_add_value_object(vu_eve_table, entry);
+ }
+ json_object_add_value_array(root, "VU Event Identifier String Table Entry", vu_eve_table);
+
+ memset((void *)ascii, 0, ascii_table_index);
+ for (j = 0; j < ascii_table_index; j++)
+ ascii += sprintf(ascii, "%c", ascii_table_info_arr[j]);
+ json_object_add_value_string(root, "ASCII Table", ascii_buf);
+
+ json_print_object(root, NULL);
+ printf("\n");
+ json_free_object(root);
+ json_free_object(stat_table);
+ json_free_object(eve_table);
+ json_free_object(vu_eve_table);
+
+ return 0;
}
static void ocp_print_c9_log_binary(__u8 *log_data_buf,int total_log_page_size)
{
- return d_raw((unsigned char *)log_data_buf, total_log_page_size);
+ return d_raw((unsigned char *)log_data_buf, total_log_page_size);
}
static int get_c9_log_page(struct nvme_dev *dev, char *format)
{
- int ret = 0;
- __u8 *header_data;
- struct telemetry_str_log_format *log_data;
+ int ret = 0;
+ __u8 *header_data;
+ struct telemetry_str_log_format *log_data;
enum nvme_print_flags fmt;
- __u8 *full_log_buf_data = NULL;
- __le64 stat_id_str_table_ofst = 0;
- __le64 event_str_table_ofst = 0;
- __le64 vu_event_str_table_ofst = 0;
- __le64 ascii_table_ofst = 0;
- __le64 total_log_page_sz = 0;
-
- ret = validate_output_format(format, &fmt);
- if (ret < 0) {
- fprintf(stderr, "ERROR : OCP : invalid output format\n");
- return ret;
- }
-
- header_data = (__u8 *)malloc(sizeof(__u8) * C9_TELEMETRY_STR_LOG_LEN);
- if (!header_data) {
- fprintf(stderr, "ERROR : OCP : malloc : %s\n", strerror(errno));
- return -1;
- }
- memset(header_data, 0, sizeof(__u8) * C9_TELEMETRY_STR_LOG_LEN);
-
- ret = nvme_get_log_simple(dev_fd(dev), C9_TELEMETRY_STRING_LOG_ENABLE_OPCODE,
- C9_TELEMETRY_STR_LOG_LEN, header_data);
-
- if (!ret) {
- log_data = (struct telemetry_str_log_format *)header_data;
- printf("Statistics Identifier String Table Size = %lld\n",log_data->sitsz);
- printf("Event String Table Size = %lld\n",log_data->estsz);
- printf("VU Event String Table Size = %lld\n",log_data->vu_eve_st_sz);
- printf("ASCII Table Size = %lld\n",log_data->asctsz);
-
- //Calculating the offset for dynamic fields.
- stat_id_str_table_ofst = C9_TELEMETRY_STR_LOG_SIST_OFST + (log_data->sitsz * 4);
- event_str_table_ofst = stat_id_str_table_ofst + (log_data->estsz * 4);
- vu_event_str_table_ofst = event_str_table_ofst + (log_data->vu_eve_st_sz * 4);
- ascii_table_ofst = vu_event_str_table_ofst + (log_data->asctsz * 4);
- total_log_page_sz = stat_id_str_table_ofst + event_str_table_ofst + vu_event_str_table_ofst + ascii_table_ofst;
-
- printf("stat_id_str_table_ofst = %lld\n",stat_id_str_table_ofst);
- printf("event_str_table_ofst = %lld\n",event_str_table_ofst);
- printf("vu_event_str_table_ofst = %lld\n",vu_event_str_table_ofst);
- printf("ascii_table_ofst = %lld\n",ascii_table_ofst);
- printf("total_log_page_sz = %lld\n",total_log_page_sz);
-
- full_log_buf_data = (__u8 *)malloc(sizeof(__u8) * total_log_page_sz);
- if (!full_log_buf_data) {
- fprintf(stderr, "ERROR : OCP : malloc : %s\n", strerror(errno));
- return -1;
- }
- memset(full_log_buf_data, 0, sizeof(__u8) * total_log_page_sz);
-
- ret = nvme_get_log_simple(dev_fd(dev), C9_TELEMETRY_STRING_LOG_ENABLE_OPCODE,
- total_log_page_sz, full_log_buf_data);
-
- if (!ret) {
- switch (fmt) {
- case NORMAL:
- ocp_print_C9_log_normal(log_data,full_log_buf_data);
- break;
- case JSON:
- ocp_print_C9_log_json(log_data,full_log_buf_data);
- break;
- case BINARY:
- ocp_print_c9_log_binary(full_log_buf_data,total_log_page_sz);
- break;
- default:
- fprintf(stderr, "unhandled output format\n");
- break;
- }
- } else{
- fprintf(stderr, "ERROR : OCP : Unable to read C9 data from buffer\n");
- }
- } else {
- fprintf(stderr, "ERROR : OCP : Unable to read C9 data from buffer\n");
- }
-
- free(header_data);
- free(full_log_buf_data);
-
- return ret;
+ __u8 *full_log_buf_data = NULL;
+ __le64 stat_id_str_table_ofst = 0;
+ __le64 event_str_table_ofst = 0;
+ __le64 vu_event_str_table_ofst = 0;
+ __le64 ascii_table_ofst = 0;
+ __le64 total_log_page_sz = 0;
+
+ ret = validate_output_format(format, &fmt);
+ if (ret < 0) {
+ fprintf(stderr, "ERROR : OCP : invalid output format\n");
+ return ret;
+ }
+
+ header_data = (__u8 *)malloc(sizeof(__u8) * C9_TELEMETRY_STR_LOG_LEN);
+ if (!header_data) {
+ fprintf(stderr, "ERROR : OCP : malloc : %s\n", strerror(errno));
+ return -1;
+ }
+ memset(header_data, 0, sizeof(__u8) * C9_TELEMETRY_STR_LOG_LEN);
+
+ ret = nvme_get_log_simple(dev_fd(dev), C9_TELEMETRY_STRING_LOG_ENABLE_OPCODE,
+ C9_TELEMETRY_STR_LOG_LEN, header_data);
+
+ if (!ret) {
+ log_data = (struct telemetry_str_log_format *)header_data;
+ printf("Statistics Identifier String Table Size = %lld\n",log_data->sitsz);
+ printf("Event String Table Size = %lld\n",log_data->estsz);
+ printf("VU Event String Table Size = %lld\n",log_data->vu_eve_st_sz);
+ printf("ASCII Table Size = %lld\n",log_data->asctsz);
+
+ //Calculating the offset for dynamic fields.
+ stat_id_str_table_ofst = C9_TELEMETRY_STR_LOG_SIST_OFST + (log_data->sitsz * 4);
+ event_str_table_ofst = stat_id_str_table_ofst + (log_data->estsz * 4);
+ vu_event_str_table_ofst = event_str_table_ofst + (log_data->vu_eve_st_sz * 4);
+ ascii_table_ofst = vu_event_str_table_ofst + (log_data->asctsz * 4);
+ total_log_page_sz = stat_id_str_table_ofst + event_str_table_ofst + vu_event_str_table_ofst + ascii_table_ofst;
+
+ printf("stat_id_str_table_ofst = %lld\n",stat_id_str_table_ofst);
+ printf("event_str_table_ofst = %lld\n",event_str_table_ofst);
+ printf("vu_event_str_table_ofst = %lld\n",vu_event_str_table_ofst);
+ printf("ascii_table_ofst = %lld\n",ascii_table_ofst);
+ printf("total_log_page_sz = %lld\n",total_log_page_sz);
+
+ full_log_buf_data = (__u8 *)malloc(sizeof(__u8) * total_log_page_sz);
+ if (!full_log_buf_data) {
+ fprintf(stderr, "ERROR : OCP : malloc : %s\n", strerror(errno));
+ return -1;
+ }
+ memset(full_log_buf_data, 0, sizeof(__u8) * total_log_page_sz);
+
+ ret = nvme_get_log_simple(dev_fd(dev), C9_TELEMETRY_STRING_LOG_ENABLE_OPCODE,
+ total_log_page_sz, full_log_buf_data);
+
+ if (!ret) {
+ switch (fmt) {
+ case NORMAL:
+ ocp_print_C9_log_normal(log_data,full_log_buf_data);
+ break;
+ case JSON:
+ ocp_print_C9_log_json(log_data,full_log_buf_data);
+ break;
+ case BINARY:
+ ocp_print_c9_log_binary(full_log_buf_data,total_log_page_sz);
+ break;
+ default:
+ fprintf(stderr, "unhandled output format\n");
+ break;
+ }
+ } else{
+ fprintf(stderr, "ERROR : OCP : Unable to read C9 data from buffer\n");
+ }
+ } else {
+ fprintf(stderr, "ERROR : OCP : Unable to read C9 data from buffer\n");
+ }
+
+ free(header_data);
+ free(full_log_buf_data);
+
+ return ret;
}
static int ocp_telemetry_str_log_format(int argc, char **argv, struct command *cmd,
- struct plugin *plugin)
+ struct plugin *plugin)
{
- struct nvme_dev *dev;
- int ret = 0;
- const char *desc = "Retrieve telemetry string log format";
+ struct nvme_dev *dev;
+ int ret = 0;
+ const char *desc = "Retrieve telemetry string log format";
- struct config {
- char *output_format;
- };
+ struct config {
+ char *output_format;
+ };
- struct config cfg = {
- .output_format = "normal",
- };
+ struct config cfg = {
+ .output_format = "normal",
+ };
- OPT_ARGS(opts) = {
- OPT_FMT("output-format", 'o', &cfg.output_format, "output Format: normal|json"),
- OPT_END()
- };
+ OPT_ARGS(opts) = {
+ OPT_FMT("output-format", 'o', &cfg.output_format, "output Format: normal|json"),
+ OPT_END()
+ };
- ret = parse_and_open(&dev, argc, argv, desc, opts);
- if (ret)
- return ret;
+ ret = parse_and_open(&dev, argc, argv, desc, opts);
+ if (ret)
+ return ret;
- ret = get_c9_log_page(dev, cfg.output_format);
- if (ret)
- fprintf(stderr, "ERROR : OCP : Failure reading the C9 Log Page, ret = %d\n", ret);
+ ret = get_c9_log_page(dev, cfg.output_format);
+ if (ret)
+ fprintf(stderr, "ERROR : OCP : Failure reading the C9 Log Page, ret = %d\n", ret);
- dev_close(dev);
+ dev_close(dev);
- return ret;
+ return ret;
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/ocp/ocp-nvme.h b/plugins/ocp/ocp-nvme.h
index 95539b0..0317ea7 100644
--- a/plugins/ocp/ocp-nvme.h
+++ b/plugins/ocp/ocp-nvme.h
@@ -30,6 +30,9 @@ PLUGIN(NAME("ocp", "OCP cloud SSD extensions", NVME_VERSION),
ENTRY("set-plp-health-check-interval", "Set PLP Health Check Interval", set_plp_health_check_interval)
ENTRY("get-plp-health-check-interval", "Get PLP Health Check Interval", get_plp_health_check_interval)
ENTRY("telemetry-string-log", "Retrieve Telemetry string Log Page", ocp_telemetry_str_log_format)
+ ENTRY("set-telemetry-profile", "Set Telemetry Profile Feature", ocp_set_telemetry_profile_feature)
+ ENTRY("set-dssd-async-event-config", "Set DSSD Async Event Config", set_dssd_async_event_config)
+ ENTRY("get-dssd-async-event-config", "Get DSSD Async Event Config", get_dssd_async_event_config)
)
);
diff --git a/plugins/ocp/ocp-utils.c b/plugins/ocp/ocp-utils.c
index 1257b30..8a1462e 100644
--- a/plugins/ocp/ocp-utils.c
+++ b/plugins/ocp/ocp-utils.c
@@ -1,19 +1,32 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
- * Copyright (c) 2022 Solidigm.
+ * Copyright (c) 2022-2024 Solidigm.
*
* Author: leonardo.da.cunha@solidigm.com
*/
#include <unistd.h>
+#include <errno.h>
#include "ocp-utils.h"
-#include "nvme-print.h"
const unsigned char ocp_uuid[NVME_UUID_LEN] = {
0xc1, 0x94, 0xd5, 0x5b, 0xe0, 0x94, 0x47, 0x94, 0xa2, 0x1d,
0x29, 0x99, 0x8f, 0x56, 0xbe, 0x6f };
-int ocp_get_uuid_index(struct nvme_dev *dev, int *index)
+int ocp_find_uuid_index(struct nvme_id_uuid_list *uuid_list, __u8 *index)
+{
+ int i = nvme_uuid_find(uuid_list, ocp_uuid);
+
+ *index = 0;
+ if (i > 0)
+ *index = i;
+ else
+ return -errno;
+
+ return 0;
+}
+
+int ocp_get_uuid_index(struct nvme_dev *dev, __u8 *index)
{
struct nvme_id_uuid_list uuid_list;
int err = nvme_identify_uuid(dev_fd(dev), &uuid_list);
@@ -22,11 +35,5 @@ int ocp_get_uuid_index(struct nvme_dev *dev, int *index)
if (err)
return err;
- for (int i = 0; i < NVME_ID_UUID_LIST_MAX; i++) {
- if (memcmp(ocp_uuid, &uuid_list.entry[i].uuid, NVME_UUID_LEN) == 0) {
- *index = i + 1;
- break;
- }
- }
- return err;
+ return ocp_find_uuid_index(&uuid_list, index);
}
diff --git a/plugins/ocp/ocp-utils.h b/plugins/ocp/ocp-utils.h
index d02bea9..1512db8 100644
--- a/plugins/ocp/ocp-utils.h
+++ b/plugins/ocp/ocp-utils.h
@@ -1,18 +1,32 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
- * Copyright (c) 2022 Solidigm.
+ * Copyright (c) 2022-2024 Solidigm.
*
* Author: leonardo.da.cunha@solidigm.com
*/
#include "nvme.h"
+/*
+ * UUID assigned for OCP.
+ */
+extern const unsigned char ocp_uuid[NVME_UUID_LEN];
+
/**
* ocp_get_uuid_index() - Get OCP UUID index
* @dev: nvme device
* @index: integer pointer to here to save the index
- * @result: The command completion result from CQE dword0
*
- * Return: Zero if nvme device has UUID list log page, or result of get uuid list otherwise.
+ * Return: Zero if nvme device has UUID list identify page, or positive result of get uuid list
+ * or negative POSIX error code otherwise.
+ */
+int ocp_get_uuid_index(struct nvme_dev *dev, __u8 *index);
+
+/**
+ * ocp_find_uuid_index() - Find OCP UUID index in UUID list
+ * @uuid_list: uuid_list retrieved from Identify UUID List (CNS 0x17)
+ * @index: integer pointer to here to save the index
+ *
+ * Return: Zero if nvme device has UUID list log page, Negative POSIX error code otherwise.
*/
-int ocp_get_uuid_index(struct nvme_dev *dev, int *index);
+int ocp_find_uuid_index(struct nvme_id_uuid_list *uuid_list, __u8 *index);