Skip to content

Commit

Permalink
ioctl: add libnvme-mi NVMe 2.1 log page APIs
Browse files Browse the repository at this point in the history
Since added the NVMe 2.1 log page.

Signed-off-by: Tokunori Ikegami <[email protected]>
  • Loading branch information
ikegami-t committed Feb 2, 2025
1 parent e7479f8 commit 68c0aef
Showing 1 changed file with 229 additions and 0 deletions.
229 changes: 229 additions & 0 deletions src/nvme/mi.h
Original file line number Diff line number Diff line change
Expand Up @@ -1605,6 +1605,47 @@ static inline int nvme_mi_admin_get_nsid_log(nvme_mi_ctrl_t ctrl, bool rae,
return nvme_mi_admin_get_log(ctrl, &args);
}

/**
* nvme_mi_admin_get_endgid_log() - Helper for Get Endurance Group ID Log Page functions
* @ctrl: Controller to query
* @rae: Retain Asynchronous Events
* @lid: Log identifier
* @endgid: Endurance Group ID
* @len: length of log buffer
* @log: pointer for resulting log data
*
* Performs a Get Log Page Admin command for a specific log ID @lid and
* endurance group ID @endgid. Log data is expected to be @len bytes, and is stored
* in @log on success. The @rae flag is passed as-is to the Get Log Page
* command, and is specific to the Log Page requested.
*
* 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_mi_admin_get_endgid_log(nvme_mi_ctrl_t ctrl, 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),
.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_mi_admin_get_log(ctrl, &args);
}

/**
* nvme_mi_admin_get_log_simple() - Helper for Get Log Page functions with no
* NSID or RAE requirements
Expand Down Expand Up @@ -2241,6 +2282,41 @@ static inline int nvme_mi_admin_get_log_boot_partition(nvme_mi_ctrl_t ctrl,
return nvme_mi_admin_get_log(ctrl, &args);
}

/**
* nvme_mi_admin_get_log_rotational_media_info() - Retrieve Rotational Media Information Log
* @ctrl: Controller to query
* @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_mi_admin_get_log_rotational_media_info(nvme_mi_ctrl_t ctrl, __u16 endgid,
__u32 len, struct nvme_rotational_media_info_log *log)
{
return nvme_mi_admin_get_endgid_log(ctrl, false, NVME_LOG_LID_ROTATIONAL_MEDIA_INFO, endgid,
len, log);
}

/**
* nvme_mi_admin_get_log_dispersed_ns_participating_nss() - Retrieve Dispersed Namespace
* Participating NVM Subsystems Log
* @ctrl: Controller to query
* @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_mi_admin_get_log_dispersed_ns_participating_nss(nvme_mi_ctrl_t ctrl,
__u32 nsid, __u32 len, struct nvme_dispersed_ns_participating_nss_log *log)
{
return nvme_mi_admin_get_nsid_log(ctrl, false, NVME_LOG_LID_DISPERSED_NS_PARTICIPATING_NSS,
nsid, len, log);
}

/**
* nvme_mi_admin_get_log_mgmt_addr_list() - Retrieve Management Address List Log
* @ctrl: Controller to query
Expand Down Expand Up @@ -2291,6 +2367,91 @@ static inline int nvme_mi_admin_get_log_phy_rx_eom(nvme_mi_ctrl_t ctrl,
return nvme_mi_admin_get_log(ctrl, &args);
}

/**
* nvme_mi_admin_get_log_reachability_groups() - Retrieve Reachability Groups Log
* @ctrl: Controller to query
* @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_mi_admin_get_log_reachability_groups(nvme_mi_ctrl_t ctrl, __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),
.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,
.ot = false,
};

return nvme_mi_admin_get_log_page(ctrl, NVME_LOG_PAGE_PDU_SIZE, &args);
}

/**
* nvme_mi_admin_get_log_reachability_associations() - Retrieve Reachability Associations Log
* @ctrl: Controller to query
* @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_mi_admin_get_log_reachability_associations(nvme_mi_ctrl_t ctrl, 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),
.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_mi_admin_get_log_page(ctrl, NVME_LOG_PAGE_PDU_SIZE, &args);
}

/**
* nvme_mi_admin_get_log_changed_alloc_ns_list() - Retrieve Changed Allocated Namespace List Log
* @ctrl: Controller to query
* @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_mi_admin_get_log_changed_alloc_ns_list(nvme_mi_ctrl_t ctrl, bool rae,
__u32 len, struct nvme_ns_list *log)
{
return nvme_mi_admin_get_nsid_log(ctrl, rae, NVME_LOG_LID_CHANGED_ALLOC_NS_LIST,
NVME_NSID_ALL, len, log);
}

/**
* nvme_mi_admin_get_log_discovery() - Retrieve Discovery log page
* @ctrl: Controller to query
Expand Down Expand Up @@ -2327,6 +2488,74 @@ static inline int nvme_mi_admin_get_log_discovery(nvme_mi_ctrl_t ctrl, bool rae,
return nvme_mi_admin_get_log(ctrl, &args);
}

/**
* nvme_mi_admin_get_log_host_discover() - Retrieve Host Discovery Log
* @ctrl: Controller to query
* @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_mi_admin_get_log_host_discover(nvme_mi_ctrl_t ctrl, 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),
.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_mi_admin_get_log_page(ctrl, NVME_LOG_PAGE_PDU_SIZE, &args);
}

/**
* nvme_mi_admin_get_log_ave_discover() - Retrieve AVE Discovery Log
* @ctrl: Controller to query
* @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_mi_admin_get_log_ave_discover(nvme_mi_ctrl_t ctrl, bool rae, __u32 len,
struct nvme_ave_discover_log *log)
{
return nvme_mi_admin_get_nsid_log(ctrl, rae, NVME_LOG_LID_AVE_DISCOVER, NVME_NSID_ALL, len,
log);
}

/**
* nvme_mi_admin_get_log_pull_model_ddc_req() - Retrieve Pull Model DDC Request Log
* @ctrl: Controller to query
* @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_mi_admin_get_log_pull_model_ddc_req(nvme_mi_ctrl_t ctrl, bool rae, __u32 len,
struct nvme_pull_model_ddc_req_log *log)
{
return nvme_mi_admin_get_nsid_log(ctrl, rae, NVME_LOG_LID_PULL_MODEL_DDC_REQ, NVME_NSID_ALL,
len, log);
}

/**
* nvme_mi_admin_get_log_media_unit_stat() - Retrieve Media Unit Status
* @ctrl: Controller to query
Expand Down

0 comments on commit 68c0aef

Please sign in to comment.