Skip to content

Conversation

@YUEyuan310
Copy link

The display of Hardware Component (Log Identifier C6h) failures to comply with protocol OCP2.5

Issue: #2566

Copy link
Contributor

@ikegami-t ikegami-t left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the json print code also as below for example.

diff --git a/plugins/ocp/ocp-print-json.c b/plugins/ocp/ocp-print-json.c
index 1e0a2dbb..d18957e5 100644
--- a/plugins/ocp/ocp-print-json.c
+++ b/plugins/ocp/ocp-print-json.c
@@ -73,7 +73,7 @@ static void json_hwcomp_log(struct hwcomp_log *log, __u32 id, bool list)
 	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_byte_array(r, "Reserved48", log->rsvd48, ARRAY_SIZE(log->rsvd48));
-	print_hwcomp_descs_json(log->desc, log_size, id, list,
+	print_hwcomp_descs_json(log->desc, log_size - offsetof(struct hwcomp_log, desc), id, list,
 				obj_create_array_obj(r, "Component Descriptions"));
 
 	json_print(r);

By the way looks the PR #2568 change is better to be refixed as below..

diff --git a/plugins/ocp/ocp-hardware-component-log.c b/plugins/ocp/ocp-hardware-component-log.c
index 90b478cb..cc36a180 100644
--- a/plugins/ocp/ocp-hardware-component-log.c
+++ b/plugins/ocp/ocp-hardware-component-log.c
@@ -193,8 +193,7 @@ 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) -
-		offsetof(struct __packed hwcomp_log, desc);
+	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));

print_array("Reserved48", log->rsvd48, ARRAY_SIZE(log->rsvd48));
printf("Component Descriptions\n");
while (log_size > 0) {
while (log_size - desc_offset > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems better to add to subtract the offset from the log size before the while loop as below for example.

diff --git a/plugins/ocp/ocp-print-stdout.c b/plugins/ocp/ocp-print-stdout.c
index 48e4dc89..cb66aa57 100644
--- a/plugins/ocp/ocp-print-stdout.c
+++ b/plugins/ocp/ocp-print-stdout.c
@@ -41,6 +41,7 @@ static void stdout_hwcomp_log(struct hwcomp_log *log, __u32 id, bool list)
 	printf("Hardware Component Log Size: 0x%"PRIx64"\n", (uint64_t)log_size);
 	print_array("Reserved48", log->rsvd48, ARRAY_SIZE(log->rsvd48));
 	printf("Component Descriptions\n");
+	log_size -= offsetof(struct hwcomp_log, desc);
 	while (log_size > 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;

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ikegami-t I have made the code changes based on your suggestions and updated the commit.

The display of Hardware Component (Log Identifier C6h) failures to
comply with protocol OCP2.5

Issue: linux-nvme#2566

Signed-off-by: liuzhen <[email protected]>
@YUEyuan310
Copy link
Author

YUEyuan310 commented Nov 14, 2024

ocp3
ocp2
ocp4
ocp5
This submission has been verified and passed with no redundant printing. @ikegami-t

@ikegami-t
Copy link
Contributor

@YUEyuan310 Thank you so much for your help!
@igaw Very sorry the PR #2568 change was not correct so please apply this PR changes again if you okay.

@igaw igaw merged commit bc3e7c6 into linux-nvme:master Nov 21, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants