]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
ocp-nvme: Update ocp v2.6 Hardware Component
authorSteven Seungcheol Lee <sc108.lee@samsung.com>
Tue, 19 Nov 2024 03:58:46 +0000 (12:58 +0900)
committerDaniel Wagner <wagi@monom.org>
Fri, 22 Nov 2024 06:55:52 +0000 (07:55 +0100)
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 <sc108.lee@samsung.com>
plugins/ocp/ocp-hardware-component-log.c
plugins/ocp/ocp-hardware-component-log.h
plugins/ocp/ocp-print-binary.c
plugins/ocp/ocp-print-json.c
plugins/ocp/ocp-print-stdout.c

index cc36a18071f02863f484ebf60f91e34594255668..5e039dd85338f592a9c9920eb4f3508900b4f4a1 100644 (file)
@@ -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:
@@ -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));
@@ -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()
        };
index f5e5162eb7e534c623f781085f446bc311b7ed4e..f0e5c1f9cc47ffea89899d6128dfa7f589cab34e 100644 (file)
@@ -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,
 };
index 64e1246bc2ddd411e584f037983bd89bf7b79b05..b9cd31567b269dd1234b1766747937559ada118b 100644 (file)
@@ -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)
index d18957e519ec4d246b5cd9a8929d4f31791d427a..d32ed991809c5078d190c67972cce418da79fdf9 100644 (file)
@@ -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));
index cb66aa571eabdd4386da396cbff9e8ea70372e85..1de237d7415dc630c0de09bd975dff3bb00bb32e 100644 (file)
@@ -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));