Skip to content

Commit bf8c8e6

Browse files
committed
ocp: fix latency monitoring data structure entry endian
Fix the entry data to little endian format. Also delete to fill the data to 0 since already initialized by 0. Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
1 parent a4c5885 commit bf8c8e6

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

plugins/ocp/ocp-nvme.c

+20-20
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,17 @@ static __u8 lat_mon_guid[GUID_LEN] = {
5757
#define RESERVED 0
5858

5959
struct __packed feature_latency_monitor {
60-
__u16 active_bucket_timer_threshold;
61-
__u8 active_threshold_a;
62-
__u8 active_threshold_b;
63-
__u8 active_threshold_c;
64-
__u8 active_threshold_d;
65-
__u16 active_latency_config;
66-
__u8 active_latency_minimum_window;
67-
__u16 debug_log_trigger_enable;
68-
__u8 discard_debug_log;
69-
__u8 latency_monitor_feature_enable;
70-
__u8 reserved[4083];
60+
__le16 active_bucket_timer_threshold;
61+
__u8 active_threshold_a;
62+
__u8 active_threshold_b;
63+
__u8 active_threshold_c;
64+
__u8 active_threshold_d;
65+
__le16 active_latency_config;
66+
__u8 active_latency_minimum_window;
67+
__le16 debug_log_trigger_enable;
68+
__u8 discard_debug_log;
69+
__u8 latency_monitor_feature_enable;
70+
__u8 reserved[4083];
7171
};
7272

7373
struct erri_entry {
@@ -265,7 +265,7 @@ int ocp_set_latency_monitor_feature(int argc, char **argv, struct command *cmd,
265265
int err = -1;
266266
struct nvme_dev *dev;
267267
__u32 result;
268-
struct feature_latency_monitor buf = {0,};
268+
struct feature_latency_monitor buf = { 0 };
269269
__u32 nsid = NVME_NSID_ALL;
270270
struct stat nvme_stat;
271271
struct nvme_id_ctrl ctrl;
@@ -342,16 +342,14 @@ int ocp_set_latency_monitor_feature(int argc, char **argv, struct command *cmd,
342342
if (err)
343343
return err;
344344

345-
memset(&buf, 0, sizeof(struct feature_latency_monitor));
346-
347-
buf.active_bucket_timer_threshold = cfg.active_bucket_timer_threshold;
345+
buf.active_bucket_timer_threshold = cpu_to_le16(cfg.active_bucket_timer_threshold);
348346
buf.active_threshold_a = cfg.active_threshold_a;
349347
buf.active_threshold_b = cfg.active_threshold_b;
350348
buf.active_threshold_c = cfg.active_threshold_c;
351349
buf.active_threshold_d = cfg.active_threshold_d;
352-
buf.active_latency_config = cfg.active_latency_config;
350+
buf.active_latency_config = cpu_to_le16(cfg.active_latency_config);
353351
buf.active_latency_minimum_window = cfg.active_latency_minimum_window;
354-
buf.debug_log_trigger_enable = cfg.debug_log_trigger_enable;
352+
buf.debug_log_trigger_enable = cpu_to_le16(cfg.debug_log_trigger_enable);
355353
buf.discard_debug_log = cfg.discard_debug_log;
356354
buf.latency_monitor_feature_enable = cfg.latency_monitor_feature_enable;
357355

@@ -373,14 +371,16 @@ int ocp_set_latency_monitor_feature(int argc, char **argv, struct command *cmd,
373371
perror("set-feature");
374372
} else if (!err) {
375373
printf("NVME_FEAT_OCP_LATENCY_MONITOR: 0x%02x\n", NVME_FEAT_OCP_LATENCY_MONITOR);
376-
printf("active bucket timer threshold: 0x%x\n", buf.active_bucket_timer_threshold);
374+
printf("active bucket timer threshold: 0x%x\n",
375+
le16_to_cpu(buf.active_bucket_timer_threshold));
377376
printf("active threshold a: 0x%x\n", buf.active_threshold_a);
378377
printf("active threshold b: 0x%x\n", buf.active_threshold_b);
379378
printf("active threshold c: 0x%x\n", buf.active_threshold_c);
380379
printf("active threshold d: 0x%x\n", buf.active_threshold_d);
381-
printf("active latency config: 0x%x\n", buf.active_latency_config);
380+
printf("active latency config: 0x%x\n", le16_to_cpu(buf.active_latency_config));
382381
printf("active latency minimum window: 0x%x\n", buf.active_latency_minimum_window);
383-
printf("debug log trigger enable: 0x%x\n", buf.debug_log_trigger_enable);
382+
printf("debug log trigger enable: 0x%x\n",
383+
le16_to_cpu(buf.debug_log_trigger_enable));
384384
printf("discard debug log: 0x%x\n", buf.discard_debug_log);
385385
printf("latency monitor feature enable: 0x%x\n", buf.latency_monitor_feature_enable);
386386
} else if (err > 0) {

0 commit comments

Comments
 (0)