Skip to content

Commit b483bbd

Browse files
jinliangwdwsuse
authored andcommitted
mi: Add Identify helper for ns-descs and primary-ctrl-caps
This change adds two helpers for the Identify command, retrieving the namespace identification descriptior list and primary controller capabilities data structure. Signed-off-by: Jinliang Wang <[email protected]>
1 parent 2ddaa19 commit b483bbd

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

src/nvme/mi.h

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,6 +1055,27 @@ static inline int nvme_mi_admin_identify_ns(nvme_mi_ctrl_t ctrl, __u32 nsid,
10551055
nsid, ns);
10561056
}
10571057

1058+
/**
1059+
* nvme_mi_admin_identify_ns_descs() - Perform an Admin identify Namespace
1060+
* Identification Descriptor list command for a namespace
1061+
* @ctrl: Controller to process identify command
1062+
* @nsid: Namespace ID
1063+
* @descs: Namespace Identification Descriptor list to populate
1064+
*
1065+
* Perform an Identify namespace identification description list command,
1066+
* setting the namespace identification description list in @descs
1067+
*
1068+
* Return: The nvme command status if a response was received (see
1069+
* &enum nvme_status_field) or -1 with errno set otherwise.
1070+
*/
1071+
static inline int nvme_mi_admin_identify_ns_descs(nvme_mi_ctrl_t ctrl,
1072+
__u32 nsid,
1073+
struct nvme_ns_id_desc *descs)
1074+
{
1075+
return nvme_mi_admin_identify_cns_nsid(ctrl, NVME_IDENTIFY_CNS_NS_DESC_LIST,
1076+
nsid, descs);
1077+
}
1078+
10581079
/**
10591080
* nvme_mi_admin_identify_allocated_ns() - Perform an Admin identify command
10601081
* for an allocated namespace
@@ -1254,6 +1275,43 @@ static inline int nvme_mi_admin_identify_active_ns_list(nvme_mi_ctrl_t ctrl,
12541275
return nvme_mi_admin_identify(ctrl, &args);
12551276
}
12561277

1278+
/**
1279+
* nvme_mi_admin_identify_primary_ctrl() - Perform an Admin identify for
1280+
* primary controller capabilities data structure.
1281+
* @ctrl: Controller to process identify command
1282+
* @cntid: Controller ID to specify
1283+
* @cap: Primary Controller Capabilities data structure to populate
1284+
*
1285+
* Perform an Identify command to get the Primary Controller Capabilities data
1286+
* for the controller specified by @cntid
1287+
*
1288+
* Will return an error if the length of the response data (from the
1289+
* controller) is not a full &NVME_IDENTIFY_DATA_SIZE, so @cap will be
1290+
* be fully populated on success.
1291+
*
1292+
* Return: 0 on success, non-zero on failure
1293+
*
1294+
* See: &struct nvme_primary_ctrl_cap
1295+
*/
1296+
static inline int nvme_mi_admin_identify_primary_ctrl(nvme_mi_ctrl_t ctrl,
1297+
__u16 cntid,
1298+
struct nvme_primary_ctrl_cap *cap)
1299+
{
1300+
struct nvme_identify_args args = {
1301+
.result = NULL,
1302+
.data = cap,
1303+
.args_size = sizeof(args),
1304+
.cns = NVME_IDENTIFY_CNS_PRIMARY_CTRL_CAP,
1305+
.csi = NVME_CSI_NVM,
1306+
.nsid = NVME_NSID_NONE,
1307+
.cntid = cntid,
1308+
.cns_specific_id = NVME_CNSSPECID_NONE,
1309+
.uuidx = NVME_UUID_NONE,
1310+
};
1311+
1312+
return nvme_mi_admin_identify(ctrl, &args);
1313+
}
1314+
12571315
/**
12581316
* nvme_mi_admin_identify_secondary_ctrl_list() - Perform an Admin identify for
12591317
* a secondary controller list.

0 commit comments

Comments
 (0)