Skip to content

Commit

Permalink
ocp: change hwcomp log size variable name to log_bytes
Browse files Browse the repository at this point in the history
Since the size value calculated to bytes from dwords for version 1.

Signed-off-by: Tokunori Ikegami <[email protected]>
  • Loading branch information
ikegami-t committed Dec 29, 2024
1 parent 8e0ee84 commit 996ab38
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
7 changes: 4 additions & 3 deletions plugins/ocp/ocp-print-binary.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@

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));
long double log_bytes = uint128_t_to_double(le128_to_cpu(log->size));

if (log->ver == 1)
desc_len *= sizeof(__le32);
log_bytes *= sizeof(__le32);

d_raw((unsigned char *)log, desc_len);
d_raw((unsigned char *)log, log_bytes);
}

static void binary_c5_log(struct nvme_dev *dev, struct unsupported_requirement_log *log_data)
Expand Down
8 changes: 4 additions & 4 deletions plugins/ocp/ocp-print-json.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,19 @@ static void print_hwcomp_descs_json(struct hwcomp_desc *desc, long double log_si

static void json_hwcomp_log(struct hwcomp_log *log, __u32 id, bool list)
{
long double log_bytes = uint128_t_to_double(le128_to_cpu(log->size));
struct json_object *r = json_create_object();

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

obj_add_uint_02x(r, "Log Identifier", OCP_LID_HWCOMP);
obj_add_uint_0x(r, "Log Page Version", le16_to_cpu(log->ver));
obj_add_byte_array(r, "Reserved2", log->rsvd2, ARRAY_SIZE(log->rsvd2));
obj_add_byte_array(r, "Log page GUID", log->guid, ARRAY_SIZE(log->guid));
obj_add_nprix64(r, "Hardware Component Log Size", (unsigned long long)log_size);
obj_add_nprix64(r, "Hardware Component Log Size", (unsigned long long)log_bytes);
obj_add_byte_array(r, "Reserved48", log->rsvd48, ARRAY_SIZE(log->rsvd48));
print_hwcomp_descs_json(log->desc, log_size - offsetof(struct hwcomp_log, desc), id, list,
print_hwcomp_descs_json(log->desc, log_bytes - offsetof(struct hwcomp_log, desc), id, list,
obj_create_array_obj(r, "Component Descriptions"));

json_print(r);
Expand Down
12 changes: 6 additions & 6 deletions plugins/ocp/ocp-print-stdout.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,21 @@ static void stdout_hwcomp_log(struct hwcomp_log *log, __u32 id, bool list)
{
size_t date_lot_code_offset = sizeof(struct hwcomp_desc);
int num = 1;
long double log_bytes = uint128_t_to_double(le128_to_cpu(log->size));
struct hwcomp_desc_entry e = { log->desc };

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

printf("Log Identifier: 0x%02xh\n", OCP_LID_HWCOMP);
printf("Log Page Version: 0x%x\n", le16_to_cpu(log->ver));
print_array("Reserved2", log->rsvd2, ARRAY_SIZE(log->rsvd2));
print_array("Log page GUID", log->guid, ARRAY_SIZE(log->guid));
printf("Hardware Component Log Size: 0x%"PRIx64"\n", (uint64_t)log_size);
printf("Hardware Component Log Size: 0x%"PRIx64"\n", (uint64_t)log_bytes);
print_array("Reserved48", log->rsvd48, ARRAY_SIZE(log->rsvd48));
printf("Component Descriptions\n");
log_size -= offsetof(struct hwcomp_log, desc);
while (log_size > 0) {
log_bytes -= offsetof(struct hwcomp_log, desc);
while (log_bytes > 0) {
e.date_lot_size = le64_to_cpu(e.desc->date_lot_size) * sizeof(__le32);
e.date_lot_code = e.date_lot_size ? (__u8 *)e.desc + date_lot_code_offset : NULL;
e.add_info_size = le64_to_cpu(e.desc->add_info_size) * sizeof(__le32);
Expand All @@ -54,7 +54,7 @@ static void stdout_hwcomp_log(struct hwcomp_log *log, __u32 id, bool list)
print_hwcomp_desc(&e, list, num++);
e.desc_size = date_lot_code_offset + e.date_lot_size + e.add_info_size;
e.desc = (struct hwcomp_desc *)((__u8 *)e.desc + e.desc_size);
log_size -= e.desc_size;
log_bytes -= e.desc_size;
}
}

Expand Down

0 comments on commit 996ab38

Please sign in to comment.