Skip to content

Commit

Permalink
ocp: move ocp telemetry log print function into ocp-print
Browse files Browse the repository at this point in the history
Still the ocp-telemetry-decode used by print functions combined json code.

Signed-off-by: Tokunori Ikegami <[email protected]>
  • Loading branch information
ikegami-t committed Oct 6, 2024
1 parent ec32aee commit 13da15f
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 10 deletions.
12 changes: 2 additions & 10 deletions plugins/ocp/ocp-nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "ocp-fw-activation-history.h"
#include "ocp-telemetry-decode.h"
#include "ocp-hardware-component-log.h"
#include "ocp-print.h"

#define CREATE_CMD
#include "ocp-nvme.h"
Expand Down Expand Up @@ -1722,16 +1723,7 @@ int parse_ocp_telemetry_log(struct ocp_telemetry_parse_options *options)
return status;
}

switch (fmt) {
case NORMAL:
print_ocp_telemetry_normal(options);
break;
case JSON:
print_ocp_telemetry_json(options);
break;
default:
break;
}
ocp_show_telemetry_log(options, fmt);

return 0;
}
Expand Down
7 changes: 7 additions & 0 deletions plugins/ocp/ocp-print-json.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "ocp-hardware-component-log.h"
#include "ocp-fw-activation-history.h"
#include "ocp-smart-extended-log.h"
#include "ocp-telemetry-decode.h"

static void print_hwcomp_desc_json(struct hwcomp_desc_entry *e, struct json_object *r)
{
Expand Down Expand Up @@ -244,10 +245,16 @@ static void json_smart_extended_log(void *data)
json_free_object(root);
}

static void json_telemetry_log(struct ocp_telemetry_parse_options *options)
{
print_ocp_telemetry_json(options);
}

static struct ocp_print_ops json_print_ops = {
.hwcomp_log = json_hwcomp_log,
.fw_act_history = json_fw_activation_history,
.smart_extended_log = json_smart_extended_log,
.telemetry_log = json_telemetry_log,
};

struct ocp_print_ops *ocp_get_json_print_ops(nvme_print_flags_t flags)
Expand Down
9 changes: 9 additions & 0 deletions plugins/ocp/ocp-print-stdout.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "ocp-hardware-component-log.h"
#include "ocp-fw-activation-history.h"
#include "ocp-smart-extended-log.h"
#include "ocp-telemetry-decode.h"

static void print_hwcomp_desc(struct hwcomp_desc_entry *e, bool list, int num)
{
Expand Down Expand Up @@ -192,10 +193,18 @@ static void stdout_smart_extended_log(void *data)
printf("\n");
}

static void stdout_telemetry_log(struct ocp_telemetry_parse_options *options)
{
#ifdef CONFIG_JSONC
print_ocp_telemetry_normal(options);
#endif /* CONFIG_JSONC */
}

static struct ocp_print_ops stdout_print_ops = {
.hwcomp_log = stdout_hwcomp_log,
.fw_act_history = stdout_fw_activation_history,
.smart_extended_log = stdout_smart_extended_log,
.telemetry_log = stdout_telemetry_log,
};

struct ocp_print_ops *ocp_get_stdout_print_ops(nvme_print_flags_t flags)
Expand Down
5 changes: 5 additions & 0 deletions plugins/ocp/ocp-print.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,8 @@ void ocp_smart_extended_log(void *data, nvme_print_flags_t flags)
{
ocp_print(smart_extended_log, flags, data);
}

void ocp_show_telemetry_log(struct ocp_telemetry_parse_options *options, nvme_print_flags_t flags)
{
ocp_print(telemetry_log, flags, options);
}
3 changes: 3 additions & 0 deletions plugins/ocp/ocp-print.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

#include "ocp-hardware-component-log.h"
#include "ocp-fw-activation-history.h"
#include "ocp-telemetry-decode.h"

struct ocp_print_ops {
void (*hwcomp_log)(struct hwcomp_log *log, __u32 id, bool list);
void (*fw_act_history)(const struct fw_activation_history *fw_history);
void (*smart_extended_log)(void *data);
void (*telemetry_log)(struct ocp_telemetry_parse_options *options);
nvme_print_flags_t flags;
};

Expand All @@ -27,4 +29,5 @@ static inline struct ocp_print_ops *ocp_get_json_print_ops(nvme_print_flags_t fl
void ocp_show_hwcomp_log(struct hwcomp_log *log, __u32 id, bool list, nvme_print_flags_t flags);
void ocp_fw_act_history(const struct fw_activation_history *fw_history, nvme_print_flags_t flags);
void ocp_smart_extended_log(void *data, nvme_print_flags_t flags);
void ocp_show_telemetry_log(struct ocp_telemetry_parse_options *options, nvme_print_flags_t flags);
#endif /* OCP_PRINT_H */
3 changes: 3 additions & 0 deletions plugins/ocp/ocp-telemetry-decode.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
*
* Authors: Jeff Lien <[email protected]>,
*/
#ifndef OCP_TELEMETRY_DECODE_H
#define OCP_TELEMETRY_DECODE_H

#include "nvme.h"
#include "nvme-print.h"
Expand Down Expand Up @@ -1226,3 +1228,4 @@ void parse_common_event(struct nvme_ocp_telemetry_event_descriptor *pevent_descr
void parse_media_wear_event(struct nvme_ocp_telemetry_event_descriptor *pevent_descriptor,
struct json_object *pevent_descriptor_obj, __u8 *pevent_specific_data,
struct json_object *pevent_fifos_object, FILE *fp);
#endif /* OCP_TELEMETRY_DECODE_H */

0 comments on commit 13da15f

Please sign in to comment.