return "Reserved";
}
-static void print_hwcomp_log_normal(struct hwcomp_log *log, __u32 id)
+static void print_hwcomp_desc(struct hwcomp_desc *desc, __u64 date_lot_size, __u8 *date_lot_code,
+ __u64 add_info_size, __u8 *add_info, bool list)
+{
+ printf(" Component: %s\n", hwcomp_id_to_string(le32_to_cpu(desc->id)));
+
+ if (list)
+ return;
+
+ printf(" Date/Lot Size: 0x%llx\n", date_lot_size);
+ printf(" Additional Information Size: 0x%llx\n", add_info_size);
+ printf(" Identifier: 0x%08x\n", le32_to_cpu(desc->id));
+ printf(" Manufacture: 0x%016lx\n", le64_to_cpu(desc->mfg));
+ printf(" Revision: 0x%016lx\n", le64_to_cpu(desc->rev));
+ printf(" Manufacture Code: 0x%016lx\n", le64_to_cpu(desc->mfg_code));
+ print_array(" Date/Lot Code", date_lot_code, date_lot_size);
+ print_array(" Additional Information", add_info, add_info_size);
+}
+
+static void print_hwcomp_log_normal(struct hwcomp_log *log, __u32 id, bool list)
{
size_t date_lot_code_offset = sizeof(struct hwcomp_desc);
struct hwcomp_desc *desc;
add_info_size = le64_to_cpu(desc->add_info_size) * sizeof(__le32);
add_info = add_info_size ? date_lot_code ? date_lot_code + date_lot_size :
(__u8 *)desc + date_lot_code_offset : NULL;
-
- if (!id || id == le32_to_cpu(desc->id)) {
- printf(" Component: %s\n", hwcomp_id_to_string(le32_to_cpu(desc->id)));
- printf(" Date/Lot Size: 0x%llx\n", date_lot_size);
- printf(" Additional Information Size: 0x%llx\n", add_info_size);
- printf(" Identifier: 0x%08x\n", le32_to_cpu(desc->id));
- printf(" Manufacture: 0x%016lx\n", le64_to_cpu(desc->mfg));
- printf(" Revision: 0x%016lx\n", le64_to_cpu(desc->rev));
- printf(" Manufacture Code: 0x%016lx\n", le64_to_cpu(desc->mfg_code));
- print_array(" Date/Lot Code", date_lot_code, date_lot_size);
- print_array(" Additional Information", add_info, add_info_size);
- }
-
+ if (!id || id == le32_to_cpu(desc->id))
+ print_hwcomp_desc(desc, date_lot_size, date_lot_code, add_info_size,
+ add_info, list);
desc_size = date_lot_code_offset + date_lot_size + add_info_size;
desc = (struct hwcomp_desc *)((__u8 *)desc + desc_size);
log_size -= desc_size;
return ret;
}
-static int get_hwcomp_log(struct nvme_dev *dev, __u32 id)
+static int get_hwcomp_log(struct nvme_dev *dev, __u32 id, bool list)
{
_cleanup_free_ __u8 *desc = NULL;
switch (fmt) {
case NORMAL:
- print_hwcomp_log_normal(&log, id);
+ print_hwcomp_log_normal(&log, id, list);
break;
case BINARY:
print_hwcomp_log_binary(&log);
const char *desc = "retrieve hardware component log";
struct config {
__u32 id;
+ bool list;
} cfg = { 0 };
const char *id_desc = "component identifier";
+ const char *list_desc = "list component descriptions";
OPT_VALS(id) = {
VAL_LONG("asic", HWCOMP_ID_ASIC),
VAL_END()
};
- NVME_ARGS(opts, OPT_LONG("comp-id", 'i', &cfg.id, id_desc, id));
+ NVME_ARGS(opts, OPT_LONG("comp-id", 'i', &cfg.id, id_desc, id),
+ OPT_FLAG("list", 'l', &cfg.list, list_desc));
ret = parse_and_open(&dev, argc, argv, desc, opts);
if (ret)
return ret;
- ret = get_hwcomp_log(dev, cfg.id);
+ ret = get_hwcomp_log(dev, cfg.id, cfg.list);
if (ret)
fprintf(stderr, "error: ocp: failed to get hwcomp log: %02X, ret: %d\n", LID_HWCOMP,
ret);