Skip to content

Commit

Permalink
ocp-nvme: Update ocp v2.6 Hardware Component
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
sc108-lee committed Nov 20, 2024
1 parent db32b0e commit b6c9481
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
10 changes: 9 additions & 1 deletion plugins/ocp/ocp-hardware-component-log.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ const char *hwcomp_id_to_string(__u32 id)
return "Country of Origin";
case HWCOMP_ID_HW_REV:
return "Global Device Hardware Revision";
case HWCOMP_ID_BORN_ON_DATE:
return "Born on Date";
case HWCOMP_ID_VENDOR ... HWCOMP_ID_MAX:
return "Vendor Unique Component";
case HWCOMP_ID_RSVD:
Expand Down Expand Up @@ -193,7 +195,12 @@ static int get_hwcomp_log_data(struct nvme_dev *dev, struct hwcomp_log *log)
print_info_array("guid", log->guid, ARRAY_SIZE(log->guid));
print_info("size: %s\n", uint128_t_to_string(le128_to_cpu(log->size)));

args.len = uint128_t_to_double(le128_to_cpu(log->size)) * sizeof(__le32) - desc_offset;
if (log->ver > 1)
args.len = uint128_t_to_double(le128_to_cpu(log->size)) - desc_offset;
else
args.len = uint128_t_to_double(le128_to_cpu(log->size)) * sizeof(__le32)
- desc_offset;

log->desc = calloc(1, args.len);
if (!log->desc) {
fprintf(stderr, "error: ocp: calloc: %s\n", strerror(errno));
Expand Down Expand Up @@ -268,6 +275,7 @@ int ocp_hwcomp_log(int argc, char **argv, struct command *cmd, struct plugin *pl
VAL_LONG("sn", HWCOMP_ID_SN),
VAL_LONG("country", HWCOMP_ID_COUNTRY),
VAL_LONG("hw-rev", HWCOMP_ID_HW_REV),
VAL_LONG("born-on-date", HWCOMP_ID_BORN_ON_DATE),
VAL_LONG("vendor", HWCOMP_ID_VENDOR),
VAL_END()
};
Expand Down
1 change: 1 addition & 0 deletions plugins/ocp/ocp-hardware-component-log.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ enum hwcomp_id {
HWCOMP_ID_SN,
HWCOMP_ID_COUNTRY,
HWCOMP_ID_HW_REV,
HWCOMP_ID_BORN_ON_DATE,
HWCOMP_ID_VENDOR = 0x8000,
HWCOMP_ID_MAX = 0xffff,
};
Expand Down
6 changes: 4 additions & 2 deletions plugins/ocp/ocp-print-binary.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@

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

d_raw((unsigned char *)log, offsetof(struct hwcomp_log, desc) + desc_len);
d_raw((unsigned char *)log, desc_len);
}

static void binary_c5_log(struct nvme_dev *dev, struct unsupported_requirement_log *log_data)
Expand Down
4 changes: 3 additions & 1 deletion plugins/ocp/ocp-print-json.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ static void json_hwcomp_log(struct hwcomp_log *log, __u32 id, bool list)
{
struct json_object *r = json_create_object();

long double log_size = uint128_t_to_double(le128_to_cpu(log->size)) * sizeof(__le32);
long double log_size = uint128_t_to_double(le128_to_cpu(log->size));
if (log->ver == 1)
log_size *= sizeof(__le32);

obj_add_uint_02x(r, "Log Identifier", LID_HWCOMP);
obj_add_uint_0x(r, "Log Page Version", le16_to_cpu(log->ver));
Expand Down
4 changes: 3 additions & 1 deletion plugins/ocp/ocp-print-stdout.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ static void stdout_hwcomp_log(struct hwcomp_log *log, __u32 id, bool list)
int num = 1;
struct hwcomp_desc_entry e = { log->desc };

long double log_size = uint128_t_to_double(le128_to_cpu(log->size)) * sizeof(__le32);
long double log_size = uint128_t_to_double(le128_to_cpu(log->size));
if (log->ver == 1)
log_size *= sizeof(__le32);

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

0 comments on commit b6c9481

Please sign in to comment.