spdk: Move the declaration of set/get feature API to nvme.h.
Change-Id: Iad4863b51850920fbe15fce6638c7439a94b58fd Signed-off-by: Cunyin Chang <cunyin.chang@intel.com>
This commit is contained in:
parent
0021c23dfe
commit
d2806e6204
@ -252,6 +252,55 @@ int nvme_ctrlr_cmd_get_log_page(struct nvme_controller *ctrlr,
|
||||
void *payload, uint32_t payload_size,
|
||||
nvme_cb_fn_t cb_fn, void *cb_arg);
|
||||
|
||||
/**
|
||||
* \brief Set specific feature for the given NVMe controller.
|
||||
*
|
||||
* \param feature The feature identifier.
|
||||
* \param cdw11 as defined by the specification for this command.
|
||||
* \param cdw12 as defined by the specification for this command.
|
||||
* \param payload The pointer to the payload buffer.
|
||||
* \param payload_size The size of payload buffer.
|
||||
* \param cb_fn Callback function to invoke when the feature has been set.
|
||||
* \param cb_arg Argument to pass to the callback function.
|
||||
*
|
||||
* \return 0 if successfully submitted, ENOMEM if resources could not be allocated for this request
|
||||
*
|
||||
* This function is thread safe and can be called at any point after nvme_attach().
|
||||
*
|
||||
* Call \ref nvme_ctrlr_process_admin_completions() to poll for completion
|
||||
* of commands submitted through this function.
|
||||
*
|
||||
* \sa nvme_ctrlr_cmd_set_feature()
|
||||
*/
|
||||
int nvme_ctrlr_cmd_set_feature(struct nvme_controller *ctrlr,
|
||||
uint8_t feature, uint32_t cdw11, uint32_t cdw12,
|
||||
void *payload, uint32_t payload_size,
|
||||
nvme_cb_fn_t cb_fn, void *cb_arg);
|
||||
|
||||
/**
|
||||
* \brief Get specific feature from given NVMe controller.
|
||||
*
|
||||
* \param feature The feature identifier.
|
||||
* \param cdw11 as defined by the specification for this command.
|
||||
* \param payload The pointer to the payload buffer.
|
||||
* \param payload_size The size of payload buffer.
|
||||
* \param cb_fn Callback function to invoke when the feature has been retrieved.
|
||||
* \param cb_arg Argument to pass to the callback function.
|
||||
*
|
||||
* \return 0 if successfully submitted, ENOMEM if resources could not be allocated for this request
|
||||
*
|
||||
* This function is thread safe and can be called at any point after nvme_attach().
|
||||
*
|
||||
* Call \ref nvme_ctrlr_process_admin_completions() to poll for completion
|
||||
* of commands submitted through this function.
|
||||
*
|
||||
* \sa nvme_ctrlr_cmd_get_feature()
|
||||
*/
|
||||
int nvme_ctrlr_cmd_get_feature(struct nvme_controller *ctrlr,
|
||||
uint8_t feature, uint32_t cdw11,
|
||||
void *payload, uint32_t payload_size,
|
||||
nvme_cb_fn_t cb_fn, void *cb_arg);
|
||||
|
||||
/**
|
||||
* \brief Get the identify namespace data as defined by the NVMe specification.
|
||||
*
|
||||
|
@ -173,25 +173,34 @@ nvme_ctrlr_cmd_create_io_sq(struct nvme_controller *ctrlr,
|
||||
nvme_ctrlr_submit_admin_request(ctrlr, req);
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
nvme_ctrlr_cmd_set_feature(struct nvme_controller *ctrlr, uint8_t feature,
|
||||
uint32_t cdw11, void *payload, uint32_t payload_size,
|
||||
uint32_t cdw11, uint32_t cdw12, void *payload, uint32_t payload_size,
|
||||
nvme_cb_fn_t cb_fn, void *cb_arg)
|
||||
{
|
||||
struct nvme_request *req;
|
||||
struct nvme_command *cmd;
|
||||
|
||||
nvme_mutex_lock(&ctrlr->ctrlr_lock);
|
||||
req = nvme_allocate_request(NULL, 0, cb_fn, cb_arg);
|
||||
if (req == NULL) {
|
||||
nvme_mutex_unlock(&ctrlr->ctrlr_lock);
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
cmd = &req->cmd;
|
||||
cmd->opc = NVME_OPC_SET_FEATURES;
|
||||
cmd->cdw10 = feature;
|
||||
cmd->cdw11 = cdw11;
|
||||
cmd->cdw12 = cdw12;
|
||||
|
||||
nvme_ctrlr_submit_admin_request(ctrlr, req);
|
||||
nvme_mutex_unlock(&ctrlr->ctrlr_lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
nvme_ctrlr_cmd_get_feature(struct nvme_controller *ctrlr, uint8_t feature,
|
||||
uint32_t cdw11, void *payload, uint32_t payload_size,
|
||||
nvme_cb_fn_t cb_fn, void *cb_arg)
|
||||
@ -199,7 +208,12 @@ nvme_ctrlr_cmd_get_feature(struct nvme_controller *ctrlr, uint8_t feature,
|
||||
struct nvme_request *req;
|
||||
struct nvme_command *cmd;
|
||||
|
||||
nvme_mutex_lock(&ctrlr->ctrlr_lock);
|
||||
req = nvme_allocate_request(NULL, 0, cb_fn, cb_arg);
|
||||
if (req == NULL) {
|
||||
nvme_mutex_unlock(&ctrlr->ctrlr_lock);
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
cmd = &req->cmd;
|
||||
cmd->opc = NVME_OPC_GET_FEATURES;
|
||||
@ -207,6 +221,9 @@ nvme_ctrlr_cmd_get_feature(struct nvme_controller *ctrlr, uint8_t feature,
|
||||
cmd->cdw11 = cdw11;
|
||||
|
||||
nvme_ctrlr_submit_admin_request(ctrlr, req);
|
||||
nvme_mutex_unlock(&ctrlr->ctrlr_lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
@ -216,7 +233,7 @@ nvme_ctrlr_cmd_set_num_queues(struct nvme_controller *ctrlr,
|
||||
uint32_t cdw11;
|
||||
|
||||
cdw11 = ((num_queues - 1) << 16) | (num_queues - 1);
|
||||
nvme_ctrlr_cmd_set_feature(ctrlr, NVME_FEAT_NUMBER_OF_QUEUES, cdw11,
|
||||
nvme_ctrlr_cmd_set_feature(ctrlr, NVME_FEAT_NUMBER_OF_QUEUES, cdw11, 0,
|
||||
NULL, 0, cb_fn, cb_arg);
|
||||
}
|
||||
|
||||
@ -229,7 +246,7 @@ nvme_ctrlr_cmd_set_async_event_config(struct nvme_controller *ctrlr,
|
||||
|
||||
cdw11 = state.raw;
|
||||
nvme_ctrlr_cmd_set_feature(ctrlr,
|
||||
NVME_FEAT_ASYNC_EVENT_CONFIGURATION, cdw11, NULL, 0, cb_fn,
|
||||
NVME_FEAT_ASYNC_EVENT_CONFIGURATION, cdw11, 0, NULL, 0, cb_fn,
|
||||
cb_arg);
|
||||
}
|
||||
|
||||
|
@ -339,14 +339,6 @@ nvme_align32pow2(uint32_t x)
|
||||
}
|
||||
|
||||
/* Admin functions */
|
||||
void nvme_ctrlr_cmd_set_feature(struct nvme_controller *ctrlr,
|
||||
uint8_t feature, uint32_t cdw11,
|
||||
void *payload, uint32_t payload_size,
|
||||
nvme_cb_fn_t cb_fn, void *cb_arg);
|
||||
void nvme_ctrlr_cmd_get_feature(struct nvme_controller *ctrlr,
|
||||
uint8_t feature, uint32_t cdw11,
|
||||
void *payload, uint32_t payload_size,
|
||||
nvme_cb_fn_t cb_fn, void *cb_arg);
|
||||
void nvme_ctrlr_cmd_identify_controller(struct nvme_controller *ctrlr,
|
||||
void *payload,
|
||||
nvme_cb_fn_t cb_fn, void *cb_arg);
|
||||
|
@ -46,6 +46,7 @@ uint32_t error_num_entries;
|
||||
uint32_t health_log_nsid = 1;
|
||||
uint8_t feature = 1;
|
||||
uint32_t feature_cdw11 = 1;
|
||||
uint32_t feature_cdw12 = 1;
|
||||
uint8_t get_feature = 1;
|
||||
uint32_t get_feature_cdw11 = 1;
|
||||
uint16_t abort_cid = 1;
|
||||
@ -96,6 +97,7 @@ static void verify_set_feature_cmd(struct nvme_request *req)
|
||||
CU_ASSERT(req->cmd.opc == NVME_OPC_SET_FEATURES);
|
||||
CU_ASSERT(req->cmd.cdw10 == feature);
|
||||
CU_ASSERT(req->cmd.cdw11 == feature_cdw11);
|
||||
CU_ASSERT(req->cmd.cdw12 == feature_cdw12);
|
||||
}
|
||||
|
||||
static void verify_get_feature_cmd(struct nvme_request *req)
|
||||
@ -336,7 +338,7 @@ test_set_feature_cmd(void)
|
||||
|
||||
verify_fn = verify_set_feature_cmd;
|
||||
|
||||
nvme_ctrlr_cmd_set_feature(&ctrlr, feature, feature_cdw11, NULL, 0, NULL, NULL);
|
||||
nvme_ctrlr_cmd_set_feature(&ctrlr, feature, feature_cdw11, feature_cdw12, NULL, 0, NULL, NULL);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user