nvme: unify Identify command helpers
Convert nvme_ctrlr_cmd_identify_controller() and nvme_ctrlr_cmd_identify_namespace() into a single function, nvme_ctrlr_cmd_identify(), with generic parameters that should be suitable for all current callers as well as future users. These functions were internal-only, so there is no public API change. Change-Id: I3dbb3e6b00308b67ba1f161f8a6b11b6333fca57 Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-on: https://review.gerrithub.io/404733 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
4f5bf64af1
commit
3d57e4a8f4
@ -765,8 +765,9 @@ nvme_ctrlr_identify(struct spdk_nvme_ctrlr *ctrlr)
|
||||
int rc;
|
||||
|
||||
status.done = false;
|
||||
rc = nvme_ctrlr_cmd_identify_controller(ctrlr, &ctrlr->cdata,
|
||||
nvme_completion_poll_cb, &status);
|
||||
rc = nvme_ctrlr_cmd_identify(ctrlr, SPDK_NVME_IDENTIFY_CTRLR, 0, 0,
|
||||
&ctrlr->cdata, sizeof(ctrlr->cdata),
|
||||
nvme_completion_poll_cb, &status);
|
||||
if (rc != 0) {
|
||||
return rc;
|
||||
}
|
||||
|
@ -102,14 +102,15 @@ spdk_nvme_ctrlr_cmd_admin_raw(struct spdk_nvme_ctrlr *ctrlr,
|
||||
}
|
||||
|
||||
int
|
||||
nvme_ctrlr_cmd_identify_controller(struct spdk_nvme_ctrlr *ctrlr, void *payload,
|
||||
spdk_nvme_cmd_cb cb_fn, void *cb_arg)
|
||||
nvme_ctrlr_cmd_identify(struct spdk_nvme_ctrlr *ctrlr, uint8_t cns, uint16_t cntid, uint32_t nsid,
|
||||
void *payload, size_t payload_size,
|
||||
spdk_nvme_cmd_cb cb_fn, void *cb_arg)
|
||||
{
|
||||
struct nvme_request *req;
|
||||
struct spdk_nvme_cmd *cmd;
|
||||
|
||||
req = nvme_allocate_request_user_copy(ctrlr->adminq,
|
||||
payload, sizeof(struct spdk_nvme_ctrlr_data),
|
||||
payload, payload_size,
|
||||
cb_fn, cb_arg, false);
|
||||
if (req == NULL) {
|
||||
return -ENOMEM;
|
||||
@ -117,37 +118,7 @@ nvme_ctrlr_cmd_identify_controller(struct spdk_nvme_ctrlr *ctrlr, void *payload,
|
||||
|
||||
cmd = &req->cmd;
|
||||
cmd->opc = SPDK_NVME_OPC_IDENTIFY;
|
||||
|
||||
/*
|
||||
* TODO: create an identify command data structure, which
|
||||
* includes this CNS bit in cdw10.
|
||||
*/
|
||||
cmd->cdw10 = SPDK_NVME_IDENTIFY_CTRLR;
|
||||
|
||||
return nvme_ctrlr_submit_admin_request(ctrlr, req);
|
||||
}
|
||||
|
||||
int
|
||||
nvme_ctrlr_cmd_identify_namespace(struct spdk_nvme_ctrlr *ctrlr, uint32_t nsid,
|
||||
void *payload, spdk_nvme_cmd_cb cb_fn, void *cb_arg)
|
||||
{
|
||||
struct nvme_request *req;
|
||||
struct spdk_nvme_cmd *cmd;
|
||||
|
||||
req = nvme_allocate_request_user_copy(ctrlr->adminq,
|
||||
payload, sizeof(struct spdk_nvme_ns_data),
|
||||
cb_fn, cb_arg, false);
|
||||
if (req == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
cmd = &req->cmd;
|
||||
cmd->opc = SPDK_NVME_OPC_IDENTIFY;
|
||||
|
||||
/*
|
||||
* TODO: create an identify command data structure
|
||||
*/
|
||||
cmd->cdw10 = SPDK_NVME_IDENTIFY_NS;
|
||||
cmd->cdw10 = cns | ((uint32_t)cntid << 16);
|
||||
cmd->nsid = nsid;
|
||||
|
||||
return nvme_ctrlr_submit_admin_request(ctrlr, req);
|
||||
|
@ -524,12 +524,10 @@ nvme_robust_mutex_unlock(pthread_mutex_t *mtx)
|
||||
}
|
||||
|
||||
/* Admin functions */
|
||||
int nvme_ctrlr_cmd_identify_controller(struct spdk_nvme_ctrlr *ctrlr,
|
||||
void *payload,
|
||||
spdk_nvme_cmd_cb cb_fn, void *cb_arg);
|
||||
int nvme_ctrlr_cmd_identify_namespace(struct spdk_nvme_ctrlr *ctrlr,
|
||||
uint32_t nsid, void *payload,
|
||||
spdk_nvme_cmd_cb cb_fn, void *cb_arg);
|
||||
int nvme_ctrlr_cmd_identify(struct spdk_nvme_ctrlr *ctrlr,
|
||||
uint8_t cns, uint16_t cntid, uint32_t nsid,
|
||||
void *payload, size_t payload_size,
|
||||
spdk_nvme_cmd_cb cb_fn, void *cb_arg);
|
||||
int nvme_ctrlr_cmd_set_num_queues(struct spdk_nvme_ctrlr *ctrlr,
|
||||
uint32_t num_queues, spdk_nvme_cmd_cb cb_fn,
|
||||
void *cb_arg);
|
||||
|
@ -48,8 +48,9 @@ int nvme_ns_identify_update(struct spdk_nvme_ns *ns)
|
||||
|
||||
nsdata = _nvme_ns_get_data(ns);
|
||||
status.done = false;
|
||||
rc = nvme_ctrlr_cmd_identify_namespace(ns->ctrlr, ns->id, nsdata,
|
||||
nvme_completion_poll_cb, &status);
|
||||
rc = nvme_ctrlr_cmd_identify(ns->ctrlr, SPDK_NVME_IDENTIFY_NS, 0, ns->id,
|
||||
nsdata, sizeof(*nsdata),
|
||||
nvme_completion_poll_cb, &status);
|
||||
if (rc != 0) {
|
||||
return rc;
|
||||
}
|
||||
|
@ -1244,8 +1244,9 @@ nvme_rdma_ctrlr_scan(const struct spdk_nvme_transport_id *discovery_trid,
|
||||
|
||||
/* get the cdata info */
|
||||
status.done = false;
|
||||
rc = nvme_ctrlr_cmd_identify_controller(discovery_ctrlr, &discovery_ctrlr->cdata,
|
||||
nvme_completion_poll_cb, &status);
|
||||
rc = nvme_ctrlr_cmd_identify(discovery_ctrlr, SPDK_NVME_IDENTIFY_CTRLR, 0, 0,
|
||||
&discovery_ctrlr->cdata, sizeof(discovery_ctrlr->cdata),
|
||||
nvme_completion_poll_cb, &status);
|
||||
if (rc != 0) {
|
||||
SPDK_ERRLOG("Failed to identify cdata\n");
|
||||
return rc;
|
||||
|
@ -272,8 +272,9 @@ nvme_ctrlr_cmd_set_async_event_config(struct spdk_nvme_ctrlr *ctrlr,
|
||||
}
|
||||
|
||||
int
|
||||
nvme_ctrlr_cmd_identify_controller(struct spdk_nvme_ctrlr *ctrlr, void *payload,
|
||||
spdk_nvme_cmd_cb cb_fn, void *cb_arg)
|
||||
nvme_ctrlr_cmd_identify(struct spdk_nvme_ctrlr *ctrlr, uint8_t cns, uint16_t cntid, uint32_t nsid,
|
||||
void *payload, size_t payload_size,
|
||||
spdk_nvme_cmd_cb cb_fn, void *cb_arg)
|
||||
{
|
||||
fake_cpl_success(cb_fn, cb_arg);
|
||||
return 0;
|
||||
|
@ -42,8 +42,9 @@
|
||||
SPDK_LOG_REGISTER_COMPONENT("nvme", SPDK_LOG_NVME)
|
||||
|
||||
int
|
||||
nvme_ctrlr_cmd_identify_namespace(struct spdk_nvme_ctrlr *ctrlr, uint32_t nsid, void *payload,
|
||||
spdk_nvme_cmd_cb cb_fn, void *cb_arg)
|
||||
nvme_ctrlr_cmd_identify(struct spdk_nvme_ctrlr *ctrlr, uint8_t cns, uint16_t cntid, uint32_t nsid,
|
||||
void *payload, size_t payload_size,
|
||||
spdk_nvme_cmd_cb cb_fn, void *cb_arg)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user