Skip to content

Commit

Permalink
intel: enable intel-nvme.c build without json-c dependencies checking
Browse files Browse the repository at this point in the history
Only build json print codes with CONFIG_JSONC build option instead.

Signed-off-by: Tokunori Ikegami <[email protected]>
  • Loading branch information
ikegami-t authored and igaw committed Dec 20, 2024
1 parent 16ed7c5 commit 3c07029
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
24 changes: 24 additions & 0 deletions plugins/intel/intel-nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ struct nvme_vu_id_ctrl_field { /* CDR MR5 */
__u8 mic_fw[4];
};

#ifdef CONFIG_JSONC
static void json_intel_id_ctrl(struct nvme_vu_id_ctrl_field *id,
char *health, char *bl, char *ww, char *mic_bl, char *mic_fw,
struct json_object *root)
Expand All @@ -89,6 +90,9 @@ static void json_intel_id_ctrl(struct nvme_vu_id_ctrl_field *id,
json_object_add_value_string(root, "mic_bl", mic_bl);
json_object_add_value_string(root, "mic_fw", mic_fw);
}
#else /* CONFIG_JSONC */
#define json_intel_id_ctrl(id, health, bl, ww, mic_bl, mic_fw, root)
#endif /* CONFIG_JSONC */

static void intel_id_ctrl(__u8 *vs, struct json_object *root)
{
Expand Down Expand Up @@ -134,6 +138,7 @@ static int id_ctrl(int argc, char **argv, struct command *cmd, struct plugin *pl
return __id_ctrl(argc, argv, cmd, plugin, intel_id_ctrl);
}

#ifdef CONFIG_JSONC
static void show_intel_smart_log_jsn(struct nvme_additional_smart_log *smart,
unsigned int nsid, const char *devname)
{
Expand Down Expand Up @@ -256,6 +261,9 @@ static void show_intel_smart_log_jsn(struct nvme_additional_smart_log *smart,
json_print_object(root, NULL);
json_free_object(root);
}
#else /* CONFIG_JSONC */
#define show_intel_smart_log_jsn(smart, nsid, devname)
#endif /* CONFIG_JSONC */

static char *id_to_key(__u8 id)
{
Expand Down Expand Up @@ -336,7 +344,9 @@ static int get_additional_smart_log(int argc, char **argv, struct command *cmd,
"Get Intel vendor specific additional smart log (optionally, for the specified namespace), and show it.";
const char *namespace = "(optional) desired namespace";
const char *raw = "Dump output in binary format";
#ifdef CONFIG_JSONC
const char *json = "Dump output in json format";
#endif /* CONFIG_JSONC */

struct nvme_additional_smart_log smart_log;
struct nvme_dev *dev;
Expand All @@ -355,7 +365,9 @@ static int get_additional_smart_log(int argc, char **argv, struct command *cmd,
OPT_ARGS(opts) = {
OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace),
OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),
#ifdef CONFIG_JSONC
OPT_FLAG("json", 'j', &cfg.json, json),
#endif /* CONFIG_JSONC */
OPT_END()
};

Expand Down Expand Up @@ -683,6 +695,7 @@ static int lat_stats_log_scale(int i)
* "type" : "write" or "read",
* "values" : {
*/
#ifdef CONFIG_JSONC
static void lat_stats_make_json_root(
struct json_object *root, struct json_object *bucket_list,
int write)
Expand Down Expand Up @@ -814,6 +827,7 @@ static void json_lat_stats_4_0(struct intel_lat_stats *stats,
json_print_object(root, NULL);
json_free_object(root);
}
#endif /* CONFIG_JSONC */

static void show_lat_stats_3_0(struct intel_lat_stats *stats)
{
Expand Down Expand Up @@ -844,6 +858,7 @@ static void show_lat_stats_4_0(struct intel_lat_stats *stats)
}
}

#ifdef CONFIG_JSONC
static void json_lat_stats_v1000_0(struct optane_lat_stats *stats, int write)
{
int i;
Expand Down Expand Up @@ -892,6 +907,7 @@ static void json_lat_stats_v1000_0(struct optane_lat_stats *stats, int write)
json_free_object(root);

}
#endif /* CONFIG_JSONC */

static void show_lat_stats_v1000_0(struct optane_lat_stats *stats, int write)
{
Expand Down Expand Up @@ -925,6 +941,7 @@ static void show_lat_stats_v1000_0(struct optane_lat_stats *stats, int write)

}

#ifdef CONFIG_JSONC
static void json_lat_stats(int write)
{
switch (media_version[MEDIA_MAJOR_IDX]) {
Expand Down Expand Up @@ -965,6 +982,9 @@ static void json_lat_stats(int write)
}
printf("\n");
}
#else /* CONFIG_JSONC */
#define json_lat_stats(write)
#endif /* CONFIG_JSONC */

static void print_dash_separator(int count)
{
Expand Down Expand Up @@ -1032,7 +1052,9 @@ static int get_lat_stats_log(int argc, char **argv, struct command *cmd, struct

const char *desc = "Get Intel Latency Statistics log and show it.";
const char *raw = "Dump output in binary format";
#ifdef CONFIG_JSONC
const char *json = "Dump output in json format";
#endif /* CONFIG_JSONC */
const char *write = "Get write statistics (read default)";

struct config {
Expand All @@ -1047,7 +1069,9 @@ static int get_lat_stats_log(int argc, char **argv, struct command *cmd, struct
OPT_ARGS(opts) = {
OPT_FLAG("write", 'w', &cfg.write, write),
OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),
#ifdef CONFIG_JSONC
OPT_FLAG("json", 'j', &cfg.json, json),
#endif /* CONFIG_JSONC */
OPT_END()
};

Expand Down
2 changes: 1 addition & 1 deletion plugins/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

if json_c_dep.found()
sources += [
'plugins/intel/intel-nvme.c',
'plugins/micron/micron-nvme.c',
'plugins/nbft/nbft-plugin.c',
'plugins/netapp/netapp-nvme.c',
Expand All @@ -26,6 +25,7 @@ sources += [
'plugins/huawei/huawei-nvme.c',
'plugins/innogrit/innogrit-nvme.c',
'plugins/inspur/inspur-nvme.c',
'plugins/intel/intel-nvme.c',
'plugins/memblaze/memblaze-nvme.c',
'plugins/shannon/shannon-nvme.c',
'plugins/toshiba/toshiba-nvme.c',
Expand Down

0 comments on commit 3c07029

Please sign in to comment.