Skip to content

Commit 1e842b6

Browse files
sc108-leeigaw
authored andcommitted
ocp-nvme: Update ocp v2.6 Hardware Component
Log Identifier C6h Hardware Component Log Size (bytes) Component Identifier added 0x000C Born on Date. The date on which the device was manufactured. ASCII string format is MMDDYYYY. Signed-off-by: Steven Seungcheol Lee <[email protected]>
1 parent 1823ab6 commit 1e842b6

File tree

5 files changed

+20
-5
lines changed

5 files changed

+20
-5
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ const char *hwcomp_id_to_string(__u32 id)
154154
return "Country of Origin";
155155
case HWCOMP_ID_HW_REV:
156156
return "Global Device Hardware Revision";
157+
case HWCOMP_ID_BORN_ON_DATE:
158+
return "Born on Date";
157159
case HWCOMP_ID_VENDOR ... HWCOMP_ID_MAX:
158160
return "Vendor Unique Component";
159161
case HWCOMP_ID_RSVD:
@@ -193,7 +195,12 @@ static int get_hwcomp_log_data(struct nvme_dev *dev, struct hwcomp_log *log)
193195
print_info_array("guid", log->guid, ARRAY_SIZE(log->guid));
194196
print_info("size: %s\n", uint128_t_to_string(le128_to_cpu(log->size)));
195197

196-
args.len = uint128_t_to_double(le128_to_cpu(log->size)) * sizeof(__le32) - desc_offset;
198+
if (log->ver > 1)
199+
args.len = uint128_t_to_double(le128_to_cpu(log->size)) - desc_offset;
200+
else
201+
args.len = uint128_t_to_double(le128_to_cpu(log->size)) * sizeof(__le32)
202+
- desc_offset;
203+
197204
log->desc = calloc(1, args.len);
198205
if (!log->desc) {
199206
fprintf(stderr, "error: ocp: calloc: %s\n", strerror(errno));
@@ -268,6 +275,7 @@ int ocp_hwcomp_log(int argc, char **argv, struct command *cmd, struct plugin *pl
268275
VAL_LONG("sn", HWCOMP_ID_SN),
269276
VAL_LONG("country", HWCOMP_ID_COUNTRY),
270277
VAL_LONG("hw-rev", HWCOMP_ID_HW_REV),
278+
VAL_LONG("born-on-date", HWCOMP_ID_BORN_ON_DATE),
271279
VAL_LONG("vendor", HWCOMP_ID_VENDOR),
272280
VAL_END()
273281
};

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ enum hwcomp_id {
5454
HWCOMP_ID_SN,
5555
HWCOMP_ID_COUNTRY,
5656
HWCOMP_ID_HW_REV,
57+
HWCOMP_ID_BORN_ON_DATE,
5758
HWCOMP_ID_VENDOR = 0x8000,
5859
HWCOMP_ID_MAX = 0xffff,
5960
};

plugins/ocp/ocp-print-binary.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77

88
static void binary_hwcomp_log(struct hwcomp_log *log, __u32 id, bool list)
99
{
10-
long double desc_len = uint128_t_to_double(le128_to_cpu(log->size)) * sizeof(__le32);
10+
long double desc_len = uint128_t_to_double(le128_to_cpu(log->size));
11+
if (log->ver == 1)
12+
desc_len *= sizeof(__le32);
1113

12-
d_raw((unsigned char *)log, offsetof(struct hwcomp_log, desc) + desc_len);
14+
d_raw((unsigned char *)log, desc_len);
1315
}
1416

1517
static void binary_c5_log(struct nvme_dev *dev, struct unsupported_requirement_log *log_data)

plugins/ocp/ocp-print-json.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ static void json_hwcomp_log(struct hwcomp_log *log, __u32 id, bool list)
6565
{
6666
struct json_object *r = json_create_object();
6767

68-
long double log_size = uint128_t_to_double(le128_to_cpu(log->size)) * sizeof(__le32);
68+
long double log_size = uint128_t_to_double(le128_to_cpu(log->size));
69+
if (log->ver == 1)
70+
log_size *= sizeof(__le32);
6971

7072
obj_add_uint_02x(r, "Log Identifier", LID_HWCOMP);
7173
obj_add_uint_0x(r, "Log Page Version", le16_to_cpu(log->ver));

plugins/ocp/ocp-print-stdout.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ static void stdout_hwcomp_log(struct hwcomp_log *log, __u32 id, bool list)
3232
int num = 1;
3333
struct hwcomp_desc_entry e = { log->desc };
3434

35-
long double log_size = uint128_t_to_double(le128_to_cpu(log->size)) * sizeof(__le32);
35+
long double log_size = uint128_t_to_double(le128_to_cpu(log->size));
36+
if (log->ver == 1)
37+
log_size *= sizeof(__le32);
3638

3739
printf("Log Identifier: 0x%02xh\n", LID_HWCOMP);
3840
printf("Log Page Version: 0x%x\n", le16_to_cpu(log->ver));

0 commit comments

Comments
 (0)