Skip to content

Commit

Permalink
ioctl,types: telemetry log update based NVMe v2.1
Browse files Browse the repository at this point in the history
MCDA added for Telemetry Host-Initiated Log creation

Log member variable added
Host-Initiated Log - THS
Controller-Initiated Log - TCS

Signed-off-by: Steven Seungcheol Lee <[email protected]>
  • Loading branch information
sc108-lee authored and igaw committed Dec 3, 2024
1 parent b50a076 commit 80775de
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 25 deletions.
38 changes: 35 additions & 3 deletions src/nvme/ioctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -1548,14 +1566,28 @@ 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,
};
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
Expand Down
2 changes: 1 addition & 1 deletion src/nvme/linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
14 changes: 0 additions & 14 deletions src/nvme/linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 13 additions & 7 deletions src/nvme/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit 80775de

Please sign in to comment.