NVMe: Add support for security send/receive command
Change-Id: I61f6a8fac4938d6af3ac6c84bcf11f99036ed856 Signed-off-by: Chunyang Hui <chunyang.hui@intel.com> Reviewed-on: https://review.gerrithub.io/426657 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
parent
6fa7e38667
commit
99ca58e082
@ -4,6 +4,10 @@
|
||||
|
||||
### nvme
|
||||
|
||||
spdk_nvme_ctrlr_cmd_security_send() and spdk_nvme_ctrlr_cmd_security_receive()
|
||||
were added to support sending or receiving security protocol data to or from
|
||||
nvme controller.
|
||||
|
||||
spdk_nvme_ns_get_extended_sector_size() was added. This function includes
|
||||
the metadata size per sector (if any). spdk_nvme_ns_get_sector_size() still
|
||||
returns only the data size per sector, not including metadata.
|
||||
|
@ -1095,6 +1095,56 @@ int spdk_nvme_ctrlr_cmd_set_feature_ns(struct spdk_nvme_ctrlr *ctrlr, uint8_t fe
|
||||
uint32_t payload_size, spdk_nvme_cmd_cb cb_fn,
|
||||
void *cb_arg, uint32_t ns_id);
|
||||
|
||||
/**
|
||||
* Receive security protocol data from controller.
|
||||
*
|
||||
* This function is thread safe and can be called at any point after spdk_nvme_probe().
|
||||
*
|
||||
* Call spdk_nvme_ctrlr_process_admin_completions() to poll for completion of
|
||||
* commands submitted through this function.
|
||||
*
|
||||
* \param ctrlr NVMe controller to use for security receive command submission.
|
||||
* \param secp Security Protocol that is used.
|
||||
* \param spsp Security Protocol Specific field.
|
||||
* \param nssf NVMe Security Specific field. Indicate RPMB target when using Security
|
||||
* Protocol EAh.
|
||||
* \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 security receive has completed.
|
||||
* \param cb_arg Argument to pass to the callback function.
|
||||
*
|
||||
* \return 0 if successfully submitted, negated errno if resources could not be allocated
|
||||
* for this request.
|
||||
*/
|
||||
int spdk_nvme_ctrlr_cmd_security_receive(struct spdk_nvme_ctrlr *ctrlr, uint8_t secp, uint16_t spsp,
|
||||
uint8_t nssf, void *payload, uint32_t payload_size,
|
||||
spdk_nvme_cmd_cb cb_fn, void *cb_arg);
|
||||
|
||||
/**
|
||||
* Send security protocol data to controller.
|
||||
*
|
||||
* This function is thread safe and can be called at any point after spdk_nvme_probe().
|
||||
*
|
||||
* Call spdk_nvme_ctrlr_process_admin_completions() to poll for completion of
|
||||
* commands submitted through this function.
|
||||
*
|
||||
* \param ctrlr NVMe controller to use for security send command submission.
|
||||
* \param secp Security Protocol that is used.
|
||||
* \param spsp Security Protocol Specific field.
|
||||
* \param nssf NVMe Security Specific field. Indicate RPMB target when using Security
|
||||
* Protocol EAh.
|
||||
* \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 security send has completed.
|
||||
* \param cb_arg Argument to pass to the callback function.
|
||||
*
|
||||
* \return 0 if successfully submitted, negated errno if resources could not be allocated
|
||||
* for this request.
|
||||
*/
|
||||
int spdk_nvme_ctrlr_cmd_security_send(struct spdk_nvme_ctrlr *ctrlr, uint8_t secp, uint16_t spsp,
|
||||
uint8_t nssf, void *payload, uint32_t payload_size,
|
||||
spdk_nvme_cmd_cb cb_fn, void *cb_arg);
|
||||
|
||||
/**
|
||||
* Attach the specified namespace to controllers.
|
||||
*
|
||||
|
@ -636,3 +636,59 @@ nvme_ctrlr_cmd_fw_image_download(struct spdk_nvme_ctrlr *ctrlr,
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int
|
||||
spdk_nvme_ctrlr_cmd_security_receive(struct spdk_nvme_ctrlr *ctrlr, uint8_t secp,
|
||||
uint16_t spsp, uint8_t nssf, void *payload,
|
||||
uint32_t payload_size, spdk_nvme_cmd_cb cb_fn, void *cb_arg)
|
||||
{
|
||||
struct nvme_request *req;
|
||||
struct spdk_nvme_cmd *cmd;
|
||||
int rc;
|
||||
|
||||
nvme_robust_mutex_lock(&ctrlr->ctrlr_lock);
|
||||
req = nvme_allocate_request_user_copy(ctrlr->adminq, payload, payload_size,
|
||||
cb_fn, cb_arg, false);
|
||||
if (req == NULL) {
|
||||
nvme_robust_mutex_unlock(&ctrlr->ctrlr_lock);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
cmd = &req->cmd;
|
||||
cmd->opc = SPDK_NVME_OPC_SECURITY_RECEIVE;
|
||||
cmd->cdw10 = ((uint32_t)secp << 24) | ((uint32_t)spsp << 8) | ((uint32_t)nssf);
|
||||
cmd->cdw11 = payload_size;
|
||||
|
||||
rc = nvme_ctrlr_submit_admin_request(ctrlr, req);
|
||||
nvme_robust_mutex_unlock(&ctrlr->ctrlr_lock);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int
|
||||
spdk_nvme_ctrlr_cmd_security_send(struct spdk_nvme_ctrlr *ctrlr, uint8_t secp,
|
||||
uint16_t spsp, uint8_t nssf, void *payload,
|
||||
uint32_t payload_size, spdk_nvme_cmd_cb cb_fn, void *cb_arg)
|
||||
{
|
||||
struct nvme_request *req;
|
||||
struct spdk_nvme_cmd *cmd;
|
||||
int rc;
|
||||
|
||||
nvme_robust_mutex_lock(&ctrlr->ctrlr_lock);
|
||||
req = nvme_allocate_request_user_copy(ctrlr->adminq, payload, payload_size,
|
||||
cb_fn, cb_arg, true);
|
||||
if (req == NULL) {
|
||||
nvme_robust_mutex_unlock(&ctrlr->ctrlr_lock);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
cmd = &req->cmd;
|
||||
cmd->opc = SPDK_NVME_OPC_SECURITY_SEND;
|
||||
cmd->cdw10 = ((uint32_t)secp << 24) | ((uint32_t)spsp << 8) | ((uint32_t)nssf);
|
||||
cmd->cdw11 = payload_size;
|
||||
|
||||
rc = nvme_ctrlr_submit_admin_request(ctrlr, req);
|
||||
nvme_robust_mutex_unlock(&ctrlr->ctrlr_lock);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user