Skip to content
227 changes: 227 additions & 0 deletions src/nvme/ioctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1370,6 +1370,30 @@ static inline int nvme_get_nsid_log(int fd, bool rae,
return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args);
}

static inline int nvme_get_endgid_log(int fd, bool rae, enum nvme_cmd_get_log_lid lid, __u16 endgid,
__u32 len, void *log)
{
struct nvme_get_log_args args = {
.lpo = 0,
.result = NULL,
.log = log,
.args_size = sizeof(args),
.fd = fd,
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
.lid = lid,
.len = len,
.nsid = NVME_NSID_NONE,
.csi = NVME_CSI_NVM,
.lsi = endgid,
.lsp = NVME_LOG_LSP_NONE,
.uuidx = NVME_LOG_LSP_NONE,
.rae = rae,
.ot = false,
};

return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args);
}

static inline int nvme_get_log_simple(int fd, enum nvme_cmd_get_log_lid lid,
__u32 len, void *log)
{
Expand Down Expand Up @@ -2095,6 +2119,55 @@ static inline int nvme_get_log_boot_partition(int fd, bool rae,
return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args);
}

/**
* nvme_get_log_rotational_media_info() - Retrieve Rotational Media Information Log
* @fd: File descriptor of nvme device
* @endgid: Endurance Group Identifier
* @len: The allocated length of the log page
* @log: User address to store the log page
*
* 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_rotational_media_info(int fd, __u16 endgid, __u32 len,
struct nvme_rotational_media_info_log *log)
{
return nvme_get_endgid_log(fd, false, NVME_LOG_LID_ROTATIONAL_MEDIA_INFO, endgid, len, log);
}

/**
* nvme_get_log_dispersed_ns_participating_nss() - Retrieve Dispersed Namespace Participating NVM
* Subsystems Log
* @fd: File descriptor of nvme device
* @nsid: Namespace Identifier
* @len: The allocated length of the log page
* @log: User address to store the log page
*
* 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_dispersed_ns_participating_nss(int fd, __u32 nsid, __u32 len,
struct nvme_dispersed_ns_participating_nss_log *log)
{
return nvme_get_nsid_log(fd, false, NVME_LOG_LID_DISPERSED_NS_PARTICIPATING_NSS, nsid, len,
log);
}

/**
* nvme_get_log_mgmt_addr_list() - Retrieve Management Address List Log
* @fd: File descriptor of nvme device
* @len: The allocated length of the log page
* @log: User address to store the log page
*
* 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_mgmt_addr_list(int fd, __u32 len,
struct nvme_mgmt_addr_list_log *log)
{
return nvme_get_log_simple(fd, NVME_LOG_LID_MGMT_ADDR_LIST, len, log);
}

/**
* nvme_get_log_phy_rx_eom() - Retrieve Physical Interface Receiver Eye Opening Measurement Log
* @fd: File descriptor of nvme device
Expand Down Expand Up @@ -2130,6 +2203,93 @@ static inline int nvme_get_log_phy_rx_eom(int fd, __u8 lsp, __u16 controller,
return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args);
}

/**
* nvme_get_log_reachability_groups() - Retrieve Reachability Groups Log
* @fd: File descriptor of nvme device
* @rgo: Return groups only
* @rae: Retain asynchronous events
* @len: The allocated length of the log page
* @log: User address to store the log page
*
* 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_reachability_groups(int fd, __u32 len, bool rgo, bool rae,
struct nvme_reachability_groups_log *log)
{
struct nvme_get_log_args args = {
.lpo = 0,
.result = NULL,
.log = log,
.args_size = sizeof(args),
.fd = fd,
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
.lid = NVME_LOG_LID_REACHABILITY_GROUPS,
.len = len,
.nsid = NVME_NSID_ALL,
.csi = NVME_CSI_NVM,
.lsi = NVME_LOG_LSI_NONE,
.lsp = rgo,
.uuidx = NVME_LOG_LSP_NONE,
.rae = rae,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Timeout missing?

.ot = false,
};

return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args);
}

/**
* nvme_get_log_reachability_associations() - Retrieve Reachability Associations Log
* @fd: File descriptor of nvme device
* @rao: Return associations only
* @rae: Retain asynchronous events
* @len: The allocated length of the log page
* @log: User address to store the log page
*
* 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_reachability_associations(int fd, bool rao, bool rae, __u32 len,
struct nvme_reachability_associations_log *log)
{
struct nvme_get_log_args args = {
.lpo = 0,
.result = NULL,
.log = log,
.args_size = sizeof(args),
.fd = fd,
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
.lid = NVME_LOG_LID_REACHABILITY_ASSOCIATIONS,
.len = len,
.nsid = NVME_NSID_ALL,
.csi = NVME_CSI_NVM,
.lsi = NVME_LOG_LSI_NONE,
.lsp = rao,
.uuidx = NVME_LOG_LSP_NONE,
.rae = rae,
.ot = false,
};

return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args);
}

/**
* nvme_get_log_changed_alloc_ns_list() - Retrieve Changed Allocated Namespace List Log
* @fd: File descriptor of nvme device
* @rae: Retain asynchronous events
* @len: The allocated length of the log page
* @log: User address to store the log page
*
* 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_changed_alloc_ns_list(int fd, bool rae, __u32 len,
struct nvme_ns_list *log)
{
return nvme_get_nsid_log(fd, rae, NVME_LOG_LID_CHANGED_ALLOC_NS_LIST, NVME_NSID_ALL, len,
log);
}

/**
* nvme_get_log_discovery() - Retrieve Discovery log page
* @fd: File descriptor of nvme device
Expand Down Expand Up @@ -2167,6 +2327,73 @@ static inline int nvme_get_log_discovery(int fd, bool rae,
return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args);
}

/**
* nvme_get_log_host_discover() - Retrieve Host Discovery Log
* @fd: File descriptor of nvme device
* @allhoste: All host entries
* @rae: Retain asynchronous events
* @len: The allocated length of the log page
* @log: User address to store the log page
*
* 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_host_discover(int fd, bool allhoste, bool rae, __u32 len,
struct nvme_host_discover_log *log)
{
struct nvme_get_log_args args = {
.lpo = 0,
.result = NULL,
.log = log,
.args_size = sizeof(args),
.fd = fd,
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
.lid = NVME_LOG_LID_HOST_DISCOVER,
.len = len,
.nsid = NVME_NSID_ALL,
.csi = NVME_CSI_NVM,
.lsi = NVME_LOG_LSI_NONE,
.lsp = allhoste,
.uuidx = NVME_LOG_LSP_NONE,
.rae = rae,
.ot = false,
};

return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args);
}

/**
* nvme_get_log_ave_discover() - Retrieve AVE Discovery Log
* @fd: File descriptor of nvme device
* @rae: Retain asynchronous events
* @len: The allocated length of the log page
* @log: User address to store the log page
*
* 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_ave_discover(int fd, bool rae, __u32 len,
struct nvme_ave_discover_log *log)
{
return nvme_get_nsid_log(fd, rae, NVME_LOG_LID_AVE_DISCOVER, NVME_NSID_ALL, len, log);
}

/**
* nvme_get_log_pull_model_ddc_req() - Retrieve Pull Model DDC Request Log
* @fd: File descriptor of nvme device
* @rae: Retain asynchronous events
* @len: The allocated length of the log page
* @log: User address to store the log page
*
* 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_pull_model_ddc_req(int fd, bool rae, __u32 len,
struct nvme_pull_model_ddc_req_log *log)
{
return nvme_get_nsid_log(fd, rae, NVME_LOG_LID_PULL_MODEL_DDC_REQ, NVME_NSID_ALL, len, log);
}

/**
* nvme_get_log_media_unit_stat() - Retrieve Media Unit Status
* @fd: File descriptor of nvme device
Expand Down
Loading
Loading