Adding upstream version 2.12.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
65508f0a28
commit
c0fbec1eb4
571 changed files with 10718 additions and 2738 deletions
|
@ -11,6 +11,7 @@
|
|||
#include "nvme-print.h"
|
||||
#include "ocp-hardware-component-log.h"
|
||||
#include "ocp-print.h"
|
||||
#include "ocp-utils.h"
|
||||
|
||||
//#define HWCOMP_DUMMY
|
||||
|
||||
|
@ -154,6 +155,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:
|
||||
|
@ -168,39 +171,59 @@ static int get_hwcomp_log_data(struct nvme_dev *dev, struct hwcomp_log *log)
|
|||
{
|
||||
int ret = 0;
|
||||
size_t desc_offset = offsetof(struct hwcomp_log, desc);
|
||||
long double log_bytes;
|
||||
nvme_uint128_t log_size;
|
||||
|
||||
struct nvme_get_log_args args = {
|
||||
.lpo = desc_offset,
|
||||
.args_size = sizeof(args),
|
||||
.fd = dev_fd(dev),
|
||||
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
|
||||
.lid = LID_HWCOMP,
|
||||
.lid = (enum nvme_cmd_get_log_lid)OCP_LID_HWCOMP,
|
||||
.nsid = NVME_NSID_ALL,
|
||||
.log = log,
|
||||
.len = desc_offset,
|
||||
};
|
||||
|
||||
ocp_get_uuid_index(dev, &args.uuidx);
|
||||
|
||||
#ifdef HWCOMP_DUMMY
|
||||
memcpy(log, hwcomp_dummy, desc_offset);
|
||||
#else /* HWCOMP_DUMMY */
|
||||
ret = nvme_get_log_simple(dev_fd(dev), LID_HWCOMP, desc_offset, log);
|
||||
ret = nvme_get_log_page(dev_fd(dev), NVME_LOG_PAGE_PDU_SIZE, &args);
|
||||
if (ret) {
|
||||
print_info_error("error: ocp: failed to get log simple (hwcomp: %02X, ret: %d)\n",
|
||||
LID_HWCOMP, ret);
|
||||
print_info_error("error: ocp: failed to get hwcomp log size (ret: %d)\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#endif /* HWCOMP_DUMMY */
|
||||
|
||||
print_info("id: %02Xh\n", LID_HWCOMP);
|
||||
log_size = le128_to_cpu(log->size);
|
||||
|
||||
print_info("id: %02Xh\n", OCP_LID_HWCOMP);
|
||||
print_info("version: %04Xh\n", log->ver);
|
||||
print_info_array("guid", log->guid, ARRAY_SIZE(log->guid));
|
||||
print_info("size: %s\n", uint128_t_to_string(le128_to_cpu(log->size)));
|
||||
print_info("size: %s\n", uint128_t_to_string(log_size));
|
||||
|
||||
log_bytes = uint128_t_to_double(log_size);
|
||||
if (log->ver == 1)
|
||||
log_bytes *= sizeof(__le32);
|
||||
|
||||
if (log_bytes <= desc_offset) {
|
||||
print_info_error("error: ocp: invalid hwcomp log size bytes: %.0Lf\n", log_bytes);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
args.len = log_bytes - desc_offset;
|
||||
|
||||
print_info("args.len: %u\n", args.len);
|
||||
|
||||
args.len = uint128_t_to_double(le128_to_cpu(log->size)) * sizeof(__le32);
|
||||
log->desc = calloc(1, args.len);
|
||||
if (!log->desc) {
|
||||
fprintf(stderr, "error: ocp: calloc: %s\n", strerror(errno));
|
||||
return -1;
|
||||
return -errno;
|
||||
}
|
||||
|
||||
args.log = log->desc,
|
||||
args.lpo = desc_offset,
|
||||
|
||||
#ifdef HWCOMP_DUMMY
|
||||
memcpy(log->desc, &hwcomp_dummy[desc_offset], args.len);
|
||||
|
@ -208,7 +231,8 @@ static int get_hwcomp_log_data(struct nvme_dev *dev, struct hwcomp_log *log)
|
|||
ret = nvme_get_log_page(dev_fd(dev), NVME_LOG_PAGE_PDU_SIZE, &args);
|
||||
if (ret) {
|
||||
print_info_error("error: ocp: failed to get log page (hwcomp: %02X, ret: %d)\n",
|
||||
LID_HWCOMP, ret);
|
||||
OCP_LID_HWCOMP, ret);
|
||||
free(log->desc);
|
||||
return ret;
|
||||
}
|
||||
#endif /* HWCOMP_DUMMY */
|
||||
|
@ -218,12 +242,10 @@ static int get_hwcomp_log_data(struct nvme_dev *dev, struct hwcomp_log *log)
|
|||
|
||||
static int get_hwcomp_log(struct nvme_dev *dev, __u32 id, bool list)
|
||||
{
|
||||
_cleanup_free_ __u8 *desc = NULL;
|
||||
|
||||
int ret;
|
||||
nvme_print_flags_t fmt;
|
||||
struct hwcomp_log log = {
|
||||
.desc = (struct hwcomp_desc *)desc,
|
||||
.desc = NULL,
|
||||
};
|
||||
|
||||
ret = validate_output_format(nvme_cfg.output_format, &fmt);
|
||||
|
@ -235,12 +257,14 @@ static int get_hwcomp_log(struct nvme_dev *dev, __u32 id, bool list)
|
|||
ret = get_hwcomp_log_data(dev, &log);
|
||||
if (ret) {
|
||||
print_info_error("error: ocp: failed get hwcomp log: %02X data, ret: %d\n",
|
||||
LID_HWCOMP, ret);
|
||||
OCP_LID_HWCOMP, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ocp_show_hwcomp_log(&log, id, list, fmt);
|
||||
|
||||
free(log.desc);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -268,6 +292,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()
|
||||
};
|
||||
|
@ -281,8 +306,8 @@ int ocp_hwcomp_log(int argc, char **argv, struct command *cmd, struct plugin *pl
|
|||
|
||||
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);
|
||||
fprintf(stderr, "error: ocp: failed to get hwcomp log: %02X, ret: %d\n",
|
||||
OCP_LID_HWCOMP, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue