diff --git a/src/nvme/ioctl.h b/src/nvme/ioctl.h index 7d407a00..02b70335 100644 --- a/src/nvme/ioctl.h +++ b/src/nvme/ioctl.h @@ -1526,14 +1526,32 @@ static inline int nvme_get_log_device_self_test(int fd, } /** - * nvme_get_log_create_telemetry_host() - Create host telemetry log + * enum nvme_telemetry_da - Telemetry Log Data Area + * @NVME_TELEMETRY_DA_CTRL_DETERMINE: + * @NVME_TELEMETRY_DA_1: Data Area 1 + * @NVME_TELEMETRY_DA_2: Data Area 2 + * @NVME_TELEMETRY_DA_3: Data Area 3 + * @NVME_TELEMETRY_DA_4: Data Area 4 + */ +enum nvme_telemetry_da { + NVME_TELEMETRY_DA_CTRL_DETERMINE = 0, + NVME_TELEMETRY_DA_1 = 1, + NVME_TELEMETRY_DA_2 = 2, + NVME_TELEMETRY_DA_3 = 3, + NVME_TELEMETRY_DA_4 = 4, +}; + +/** + * nvme_get_log_create_telemetry_host_mcda() - Create host telemetry log * @fd: File descriptor of nvme device + * @mcda: Maximum Created Data Area * @log: Userspace address of the log payload * * Return: The nvme command status if a response was received (see * &enum nvme_status_field) or -1 with errno set otherwise. */ -static inline int nvme_get_log_create_telemetry_host(int fd, +static inline int nvme_get_log_create_telemetry_host_mcda(int fd, + enum nvme_telemetry_da mcda, struct nvme_telemetry_log *log) { struct nvme_get_log_args args = { @@ -1548,7 +1566,7 @@ static inline int nvme_get_log_create_telemetry_host(int fd, .nsid = NVME_NSID_NONE, .csi = NVME_CSI_NVM, .lsi = NVME_LOG_LSI_NONE, - .lsp = NVME_LOG_TELEM_HOST_LSP_CREATE, + .lsp = (__u8)((mcda << 1) | NVME_LOG_TELEM_HOST_LSP_CREATE), .uuidx = NVME_UUID_NONE, .rae = false, .ot = false, @@ -1556,6 +1574,20 @@ static inline int nvme_get_log_create_telemetry_host(int fd, return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args); } +/** + * nvme_get_log_create_telemetry_host() - Create host telemetry log + * @fd: File descriptor of nvme device + * @log: Userspace address of the log payload + * + * Return: The nvme command status if a response was received (see + * &enum nvme_status_field) or -1 with errno set otherwise. + */ +static inline int nvme_get_log_create_telemetry_host(int fd, + struct nvme_telemetry_log *log) +{ + return nvme_get_log_create_telemetry_host_mcda(fd, NVME_TELEMETRY_DA_CTRL_DETERMINE, log); +} + /** * nvme_get_log_telemetry_host() - Get Telemetry Host-Initiated log page * @fd: File descriptor of nvme device diff --git a/src/nvme/linux.c b/src/nvme/linux.c index a9ba58b3..4254a3eb 100644 --- a/src/nvme/linux.c +++ b/src/nvme/linux.c @@ -197,7 +197,7 @@ int nvme_get_telemetry_log(int fd, bool create, bool ctrl, bool rae, size_t max_ } else { lid = NVME_LOG_LID_TELEMETRY_HOST; if (create) - err = nvme_get_log_create_telemetry_host(fd, log); + err = nvme_get_log_create_telemetry_host_mcda(fd, da, log); else err = nvme_get_log_telemetry_host(fd, 0, xfer, log); } diff --git a/src/nvme/linux.h b/src/nvme/linux.h index 5dbc0926..c38c47a1 100644 --- a/src/nvme/linux.h +++ b/src/nvme/linux.h @@ -34,20 +34,6 @@ int nvme_fw_download_seq(int fd, __u32 size, __u32 xfer, __u32 offset, void *buf); -/** - * enum nvme_telemetry_da - Telemetry Log Data Area - * @NVME_TELEMETRY_DA_1: Data Area 1 - * @NVME_TELEMETRY_DA_2: Data Area 2 - * @NVME_TELEMETRY_DA_3: Data Area 3 - * @NVME_TELEMETRY_DA_4: Data Area 4 - */ -enum nvme_telemetry_da { - NVME_TELEMETRY_DA_1 = 1, - NVME_TELEMETRY_DA_2 = 2, - NVME_TELEMETRY_DA_3 = 3, - NVME_TELEMETRY_DA_4 = 4, -}; - /** * nvme_get_telemetry_max() - Get telemetry limits * @fd: File descriptor of nvme device diff --git a/src/nvme/types.h b/src/nvme/types.h index 82de8a98..baa748c0 100644 --- a/src/nvme/types.h +++ b/src/nvme/types.h @@ -3711,19 +3711,21 @@ enum nvme_cmd_get_log_telemetry_host_lsp { * @rsvd1: Reserved * @ieee: IEEE OUI Identifier is the Organization Unique Identifier (OUI) * for the controller vendor that is able to interpret the data. - * @dalb1: Telemetry Controller-Initiated Data Area 1 Last Block is + * @dalb1: Telemetry Host/Controller Initiated Data Area 1 Last Block is * the value of the last block in this area. - * @dalb2: Telemetry Controller-Initiated Data Area 1 Last Block is + * @dalb2: Telemetry Host/Controller Initiated Data Area 1 Last Block is * the value of the last block in this area. - * @dalb3: Telemetry Controller-Initiated Data Area 1 Last Block is + * @dalb3: Telemetry Host/ControllerInitiated Data Area 1 Last Block is * the value of the last block in this area. * @rsvd14: Reserved - * @dalb4: Telemetry Controller-Initiated Data Area 4 Last Block is + * @dalb4: Telemetry Host/Controller Initiated Data Area 4 Last Block is * the value of the last block in this area. * @rsvd20: Reserved + * @ths: Telemetry Host-Initiated Scope * @hostdgn: Telemetry Host-Initiated Data Generation Number is a * value that is incremented each time the host initiates a - * capture of its internal controller state in the controller . + * capture of its internal controller state in the controller. + * @tcs: Telemetry Controller-Initiated Scope * @ctrlavail: Telemetry Controller-Initiated Data Available, if cleared, * then the controller telemetry log does not contain saved * internal controller state. If this field is set to 1h, the @@ -3751,8 +3753,12 @@ struct nvme_telemetry_log { __le16 dalb3; __u8 rsvd14[2]; __le32 dalb4; - __u8 rsvd20[361]; - __u8 hostdgn; + __u8 rsvd20[360]; + __u8 ths; + union { // [381] + __u8 hostdgn; + __u8 tcs; + }; __u8 ctrlavail; __u8 ctrldgn; __u8 rsnident[128];