Skip to content

Commit f260a8d

Browse files
ikegami-tigaw
authored andcommitted
ocp: combine to use GUID length definitions
This reduces the duplicated GUID length 16 bytes definitions. Signed-off-by: Tokunori Ikegami <[email protected]>
1 parent 2dd2870 commit f260a8d

File tree

9 files changed

+39
-46
lines changed

9 files changed

+39
-46
lines changed

plugins/ocp/ocp-fw-activation-history.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include "ocp-utils.h"
1717
#include "ocp-print.h"
1818

19-
static const unsigned char ocp_fw_activation_history_guid[16] = {
19+
static const unsigned char ocp_fw_activation_history_guid[GUID_LEN] = {
2020
0x6D, 0x79, 0x9a, 0x76,
2121
0xb4, 0xda, 0xf6, 0xa3,
2222
0xe2, 0x4d, 0xb2, 0x8a,

plugins/ocp/ocp-hardware-component-log.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
*/
55
#include "cmd.h"
66
#include "common.h"
7+
#include "ocp-nvme.h"
78

89
#ifndef OCP_HARDWARE_COMPONENT_LOG_H
910
#define OCP_HARDWARE_COMPONENT_LOG_H
1011

1112
#define LID_HWCOMP 0xc6
1213
#define HWCOMP_RSVD2_LEN 14
13-
#define GUID_LEN 16
1414
#define HWCOMP_SIZE_LEN 16
1515
#define HWCOMP_RSVD48_LEN 16
1616

plugins/ocp/ocp-nvme.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
#define C3_LATENCY_MON_OPCODE 0xC3
4848
#define NVME_FEAT_OCP_LATENCY_MONITOR 0xC5
4949

50-
static __u8 lat_mon_guid[C3_GUID_LENGTH] = {
50+
static __u8 lat_mon_guid[GUID_LEN] = {
5151
0x92, 0x7a, 0xc0, 0x8c,
5252
0xd0, 0x84, 0x6c, 0x9c,
5353
0x70, 0x43, 0xe6, 0xd4,
@@ -1587,7 +1587,7 @@ static int ocp_telemetry_log(int argc, char **argv, struct command *cmd, struct
15871587
#define C5_UNSUPPORTED_REQS_LEN 4096
15881588
#define C5_UNSUPPORTED_REQS_OPCODE 0xC5
15891589

1590-
static __u8 unsupported_req_guid[C5_GUID_LENGTH] = {
1590+
static __u8 unsupported_req_guid[GUID_LEN] = {
15911591
0x2F, 0x72, 0x9C, 0x0E,
15921592
0x99, 0x23, 0x2C, 0xBB,
15931593
0x63, 0x48, 0x32, 0xD0,
@@ -1695,7 +1695,7 @@ static int ocp_unsupported_requirements_log(int argc, char **argv, struct comman
16951695
#define C1_ERROR_RECOVERY_LOG_BUF_LEN 0x200
16961696
#define C1_ERROR_RECOVERY_OPCODE 0xC1
16971697

1698-
static __u8 error_recovery_guid[C1_GUID_LENGTH] = {
1698+
static __u8 error_recovery_guid[GUID_LEN] = {
16991699
0x44, 0xd9, 0x31, 0x21,
17001700
0xfe, 0x30, 0x34, 0xae,
17011701
0xab, 0x4d, 0xfd, 0x3d,
@@ -1798,7 +1798,7 @@ static int ocp_error_recovery_log(int argc, char **argv, struct command *cmd, st
17981798

17991799
#define C4_DEV_CAP_REQ_LEN 0x1000
18001800
#define C4_DEV_CAP_REQ_OPCODE 0xC4
1801-
static __u8 dev_cap_req_guid[C4_GUID_LENGTH] = {
1801+
static __u8 dev_cap_req_guid[GUID_LEN] = {
18021802
0x97, 0x42, 0x05, 0x0d,
18031803
0xd1, 0xe1, 0xc9, 0x98,
18041804
0x5d, 0x49, 0x58, 0x4b,
@@ -2523,7 +2523,7 @@ static int ocp_telemetry_str_log_format(int argc, char **argv, struct command *c
25232523
#define C7_TCG_CONFIGURATION_LEN 512
25242524
#define C7_TCG_CONFIGURATION_OPCODE 0xC7
25252525

2526-
static __u8 tcg_configuration_guid[C7_GUID_LENGTH] = {
2526+
static __u8 tcg_configuration_guid[GUID_LEN] = {
25272527
0x06, 0x40, 0x24, 0xBD,
25282528
0x7E, 0xE0, 0xE6, 0x83,
25292529
0xC0, 0x47, 0x54, 0xFA,

plugins/ocp/ocp-nvme.h

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ struct __packed ssd_latency_monitor_log {
8787
__u8 log_page_guid[0x10]; /* 0x1F0 */
8888
};
8989

90-
#define C3_GUID_LENGTH 16
90+
#define GUID_LEN 16
9191

9292
#define C3_ACTIVE_BUCKET_TIMER_INCREMENT 5
9393
#define C3_ACTIVE_THRESHOLD_INCREMENT 5
@@ -98,7 +98,6 @@ struct __packed ssd_latency_monitor_log {
9898
#define WRITE 2
9999
#define TRIM 1
100100

101-
#define C5_GUID_LENGTH 16
102101
#define C5_NUM_UNSUPPORTED_REQ_ENTRIES 253
103102

104103
/*
@@ -117,10 +116,9 @@ struct __packed unsupported_requirement_log {
117116
__u8 unsupported_req_list[C5_NUM_UNSUPPORTED_REQ_ENTRIES][16];
118117
__u8 rsvd2[14];
119118
__le16 log_page_version;
120-
__u8 log_page_guid[C5_GUID_LENGTH];
119+
__u8 log_page_guid[GUID_LEN];
121120
};
122121

123-
#define C1_GUID_LENGTH 16
124122
#define C1_PREV_PANIC_IDS_LENGTH 4
125123

126124
/**
@@ -160,11 +158,9 @@ struct __packed ocp_error_recovery_log_page {
160158
__le64 prev_panic_id[C1_PREV_PANIC_IDS_LENGTH]; /* 32 bytes - 0x20 - 0x3F */
161159
__u8 reserved2[0x1ae]; /* 430 bytes - 0x40 - 0x1ED */
162160
__le16 log_page_version; /* 2 bytes - 0x1EE - 0x1EF */
163-
__u8 log_page_guid[0x10]; /* 16 bytes - 0x1F0 - 0x1FF */
161+
__u8 log_page_guid[GUID_LEN]; /* 16 bytes - 0x1F0 - 0x1FF */
164162
};
165163

166-
#define C4_GUID_LENGTH 16
167-
168164
/**
169165
* struct ocp_device_capabilities_log_page - Device Capability Log page
170166
* @pcie_exp_port: PCI Express Ports
@@ -193,11 +189,9 @@ struct __packed ocp_device_capabilities_log_page {
193189
__u8 dssd_pwr_state_desc[128];
194190
__u8 reserved[3934];
195191
__le16 log_page_version;
196-
__u8 log_page_guid[16];
192+
__u8 log_page_guid[GUID_LEN];
197193
};
198194

199-
#define C7_GUID_LENGTH 16
200-
201195
/*
202196
* struct tcg_configuration_log - TCG Configuration Log Page Structure
203197
* @state: state
@@ -244,7 +238,7 @@ struct __packed tcg_configuration_log {
244238
__u32 tcg_ec;
245239
__u8 rsvd3[458];
246240
__le16 log_page_version;
247-
__u8 log_page_guid[C7_GUID_LENGTH];
241+
__u8 log_page_guid[GUID_LEN];
248242

249243
};
250244
#endif /* OCP_NVME_H */

plugins/ocp/ocp-print-json.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -393,10 +393,10 @@ static void json_c3_log(struct nvme_dev *dev, struct ssd_latency_monitor_log *lo
393393
json_object_add_value_uint(root, "Log Page Version",
394394
le16_to_cpu(log_data->log_page_version));
395395

396-
char guid[(C3_GUID_LENGTH * 2) + 1];
396+
char guid[(GUID_LEN * 2) + 1];
397397
char *ptr = &guid[0];
398398

399-
for (i = C3_GUID_LENGTH - 1; i >= 0; i--)
399+
for (i = GUID_LEN - 1; i >= 0; i--)
400400
ptr += sprintf(ptr, "%02X", log_data->log_page_guid[i]);
401401

402402
json_object_add_value_string(root, "Log Page GUID", guid);
@@ -412,7 +412,7 @@ static void json_c5_log(struct nvme_dev *dev, struct unsupported_requirement_log
412412
int j;
413413
struct json_object *root;
414414
char unsup_req_list_str[40];
415-
char guid_buf[C5_GUID_LENGTH];
415+
char guid_buf[GUID_LEN];
416416
char *guid = guid_buf;
417417

418418
root = json_create_object();
@@ -430,8 +430,8 @@ static void json_c5_log(struct nvme_dev *dev, struct unsupported_requirement_log
430430
json_object_add_value_int(root, "Log Page Version",
431431
le16_to_cpu(log_data->log_page_version));
432432

433-
memset((void *)guid, 0, C5_GUID_LENGTH);
434-
for (j = C5_GUID_LENGTH - 1; j >= 0; j--)
433+
memset((void *)guid, 0, GUID_LEN);
434+
for (j = GUID_LEN - 1; j >= 0; j--)
435435
guid += sprintf(guid, "%02x", log_data->log_page_guid[j]);
436436
json_object_add_value_string(root, "Log page GUID", guid_buf);
437437

@@ -526,7 +526,7 @@ static void json_c9_log(struct telemetry_str_log_format *log_data, __u8 *log_dat
526526
struct json_object *root = json_create_object();
527527
char res_arr[48];
528528
char *res = res_arr;
529-
char guid_buf[C9_GUID_LENGTH];
529+
char guid_buf[GUID_LEN];
530530
char *guid = guid_buf;
531531
char fifo_arr[16];
532532
char *fifo = fifo_arr;
@@ -557,8 +557,8 @@ static void json_c9_log(struct telemetry_str_log_format *log_data, __u8 *log_dat
557557
res += sprintf(res, "%d", log_data->reserved1[j]);
558558
json_object_add_value_string(root, "Reserved", res_arr);
559559

560-
memset((void *)guid, 0, C9_GUID_LENGTH);
561-
for (j = C9_GUID_LENGTH - 1; j >= 0; j--)
560+
memset((void *)guid, 0, GUID_LEN);
561+
for (j = GUID_LEN - 1; j >= 0; j--)
562562
guid += sprintf(guid, "%02x", log_data->log_page_guid[j]);
563563
json_object_add_value_string(root, "Log page GUID", guid_buf);
564564

@@ -768,7 +768,7 @@ static void json_c7_log(struct nvme_dev *dev, struct tcg_configuration_log *log_
768768
{
769769
int j;
770770
struct json_object *root;
771-
char guid_buf[C7_GUID_LENGTH];
771+
char guid_buf[GUID_LEN];
772772
char *guid = guid_buf;
773773
char res_arr[458];
774774
char *res = res_arr;
@@ -820,8 +820,8 @@ static void json_c7_log(struct nvme_dev *dev, struct tcg_configuration_log *log_
820820
json_object_add_value_int(root, "Log Page Version",
821821
le16_to_cpu(log_data->log_page_version));
822822

823-
memset((void *)guid, 0, C7_GUID_LENGTH);
824-
for (j = C7_GUID_LENGTH - 1; j >= 0; j--)
823+
memset((void *)guid, 0, GUID_LEN);
824+
for (j = GUID_LEN - 1; j >= 0; j--)
825825
guid += sprintf(guid, "%02x", log_data->log_page_guid[j]);
826826
json_object_add_value_string(root, "Log page GUID", guid_buf);
827827

plugins/ocp/ocp-print-stdout.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,10 @@ static void stdout_c3_log(struct nvme_dev *dev, struct ssd_latency_monitor_log *
256256
printf(" Log Page Version %d\n",
257257
le16_to_cpu(log_data->log_page_version));
258258

259-
char guid[(C3_GUID_LENGTH * 2) + 1];
259+
char guid[(GUID_LEN * 2) + 1];
260260
char *ptr = &guid[0];
261261

262-
for (i = C3_GUID_LENGTH - 1; i >= 0; i--)
262+
for (i = GUID_LEN - 1; i >= 0; i--)
263263
ptr += sprintf(ptr, "%02X", log_data->log_page_guid[i]);
264264

265265
printf(" Log Page GUID %s\n", guid);
@@ -344,7 +344,7 @@ static void stdout_c5_log(struct nvme_dev *dev, struct unsupported_requirement_l
344344
printf(" Log Page Version : 0x%x\n",
345345
le16_to_cpu(log_data->log_page_version));
346346
printf(" Log page GUID : 0x");
347-
for (j = C5_GUID_LENGTH - 1; j >= 0; j--)
347+
for (j = GUID_LEN - 1; j >= 0; j--)
348348
printf("%02x", log_data->log_page_guid[j]);
349349
printf("\n");
350350
}
@@ -381,7 +381,7 @@ static void stdout_c1_log(struct ocp_error_recovery_log_page *log_data)
381381
printf(" Log Page Version : 0x%x\n",
382382
le16_to_cpu(log_data->log_page_version));
383383
printf(" Log page GUID : 0x");
384-
for (i = C1_GUID_LENGTH - 1; i >= 0; i--)
384+
for (i = GUID_LEN - 1; i >= 0; i--)
385385
printf("%02x", log_data->log_page_guid[i]);
386386
printf("\n");
387387
}
@@ -414,7 +414,7 @@ static void stdout_c4_log(struct ocp_device_capabilities_log_page *log_data)
414414
printf(" Log Page Version : 0x%x\n",
415415
le16_to_cpu(log_data->log_page_version));
416416
printf(" Log page GUID : 0x");
417-
for (i = C4_GUID_LENGTH - 1; i >= 0; i--)
417+
for (i = GUID_LEN - 1; i >= 0; i--)
418418
printf("%02x", log_data->log_page_guid[i]);
419419
printf("\n");
420420
}
@@ -446,7 +446,7 @@ static void stdout_c9_log(struct telemetry_str_log_format *log_data, __u8 *log_d
446446
printf("\n");
447447

448448
printf(" Log page GUID : 0x");
449-
for (j = C9_GUID_LENGTH - 1; j >= 0; j--)
449+
for (j = GUID_LEN - 1; j >= 0; j--)
450450
printf("%02x", log_data->log_page_guid[j]);
451451
printf("\n");
452452

@@ -685,7 +685,7 @@ static void stdout_c7_log(struct nvme_dev *dev, struct tcg_configuration_log *lo
685685
printf(" Log Page Version : 0x%x\n",
686686
le16_to_cpu(log_data->log_page_version));
687687
printf(" Log page GUID : 0x");
688-
for (j = C7_GUID_LENGTH - 1; j >= 0; j--)
688+
for (j = GUID_LEN - 1; j >= 0; j--)
689689
printf("%02x", log_data->log_page_guid[j]);
690690
printf("\n");
691691
}

plugins/ocp/ocp-smart-extended-log.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@
1818
/* C0 SCAO Log Page */
1919
#define C0_SMART_CLOUD_ATTR_LEN 0x200
2020
#define C0_SMART_CLOUD_ATTR_OPCODE 0xC0
21-
#define C0_GUID_LENGTH 16
2221

23-
static __u8 scao_guid[C0_GUID_LENGTH] = {
22+
static __u8 scao_guid[GUID_LEN] = {
2423
0xC5, 0xAF, 0x10, 0x28,
2524
0xEA, 0xBF, 0xF2, 0xA4,
2625
0x9C, 0x4F, 0x6F, 0x7C,

plugins/ocp/ocp-telemetry-decode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ struct request_data ocp_header_in_da1[] = {
280280
{ "Minor Version", 2 },
281281
{ "Reserved1", 4 },
282282
{ "Timestamp", 8 },
283-
{ "Log page GUID", 16 },
283+
{ "Log page GUID", GUID_LEN },
284284
{ "Number Telemetry Profiles Supported", 1 },
285285
{ "Telemetry Profile Selected", 1 },
286286
{ "Reserved2", 6 },
@@ -419,7 +419,7 @@ struct request_data smart_extended[] = {
419419
{ "Lowest Permitted Firmware Revision", 8 },
420420
{ "Reserved4", 278 },
421421
{ "Log Page Version", 2 },
422-
{ "Log page GUID", 16 }
422+
{ "Log page GUID", GUID_LEN }
423423
};
424424

425425
#ifdef CONFIG_JSONC

plugins/ocp/ocp-telemetry-decode.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "nvme-print.h"
1111
#include "util/utils.h"
1212
#include "common.h"
13+
#include "ocp-nvme.h"
1314

1415
extern __u8 *ptelemetry_buffer;
1516
extern __u8 *pstring_buffer;
@@ -401,7 +402,7 @@ struct telemetry_data_area_1 {
401402
__le16 minor_version;
402403
__u8 reserved1[4];
403404
__le64 timestamp;
404-
__u8 log_page_guid[16];
405+
__u8 log_page_guid[GUID_LEN];
405406
__u8 no_of_tps_supp;
406407
__u8 tps;
407408
__u8 reserved2[6];
@@ -437,7 +438,6 @@ struct telemetry_data_area_1 {
437438
#define DEFAULT_OUTPUT_FORMAT_JSON "json"
438439

439440
/* C9 Telemetry String Log Format Log Page */
440-
#define C9_GUID_LENGTH 16
441441
#define C9_TELEMETRY_STRING_LOG_ENABLE_OPCODE 0xC9
442442
#define C9_TELEMETRY_STR_LOG_LEN 432
443443
#define C9_TELEMETRY_STR_LOG_SIST_OFST 431
@@ -569,7 +569,7 @@ enum ocp_telemetry_debug_event_class_types {
569569
struct __packed telemetry_str_log_format {
570570
__u8 log_page_version;
571571
__u8 reserved1[15];
572-
__u8 log_page_guid[C9_GUID_LENGTH];
572+
__u8 log_page_guid[GUID_LEN];
573573
__le64 sls;
574574
__u8 reserved2[24];
575575
__le64 sits;
@@ -781,7 +781,7 @@ struct __packed nvme_ocp_telemetry_smart_extended
781781
__le64 lowest_permitted_firmware_revision; // Bytes 215:208
782782
__u8 reserved4[278]; // Bytes 493:216
783783
__le16 log_page_version; // Bytes 495:494
784-
__u8 log_page_guid[16]; // Bytes 511:496
784+
__u8 log_page_guid[GUID_LEN]; // Bytes 511:496
785785
};
786786

787787
struct __packed nvme_ocp_event_fifo_data
@@ -818,7 +818,7 @@ struct __packed nvme_ocp_header_in_da1
818818
__le16 minor_version; // Bytes 3:2
819819
__le32 reserved1; // Bytes 7:4
820820
__le64 time_stamp; // Bytes 15:8
821-
__u8 log_page_guid[16]; // Bytes 31:16
821+
__u8 log_page_guid[GUID_LEN]; // Bytes 31:16
822822
__u8 num_telemetry_profiles_supported; // Byte 32
823823
__u8 telemetry_profile_selected; // Byte 33
824824
__u8 reserved2[6]; // Bytes 39:34
@@ -919,7 +919,7 @@ struct __packed nvme_ocp_telemetry_string_header
919919
{
920920
__u8 version; //0:0
921921
__u8 reserved1[15]; //15:1
922-
__u8 guid[16]; //32:16
922+
__u8 guid[GUID_LEN]; //32:16
923923
__le64 string_log_size; //39:32
924924
__u8 reserved2[24]; //63:40
925925
__le64 sits; //71:64 Statistics Identifier String Table Start(SITS)

0 commit comments

Comments
 (0)