nvme: nvme_ctrlr_cmd_sanitize
Add support for NVMe Sanitize command. Signed-off-by: James Bergsten <jamesx.bergsten@intel.com> Change-Id: I679a4199822733345a3dae29002a81be44b53a53 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/452919 Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
740b2f5622
commit
fb7dbc1c27
@ -1808,6 +1808,9 @@ enum spdk_nvme_log_page {
|
||||
/** Reservation notification (optional) */
|
||||
SPDK_NVME_LOG_RESERVATION_NOTIFICATION = 0x80,
|
||||
|
||||
/** Sanitize status (optional) */
|
||||
SPDK_NVME_LOG_SANITIZE_STATUS = 0x81,
|
||||
|
||||
/* 0x81-0xBF - I/O command set specific */
|
||||
|
||||
/* 0xC0-0xFF - vendor specific */
|
||||
@ -1948,6 +1951,46 @@ struct spdk_nvme_telemetry_log_page_hdr {
|
||||
};
|
||||
SPDK_STATIC_ASSERT(sizeof(struct spdk_nvme_telemetry_log_page_hdr) == 512, "Incorrect size");
|
||||
|
||||
/**
|
||||
* Sanitize Status Type
|
||||
*/
|
||||
enum spdk_nvme_sanitize_status_type {
|
||||
SPDK_NVME_NEVER_BEEN_SANITIZED = 0x0,
|
||||
SPDK_NVME_RECENT_SANITIZE_SUCCESSFUL = 0x1,
|
||||
SPDK_NVME_SANITIZE_IN_PROGRESS = 0x2,
|
||||
SPDK_NVME_SANITIZE_FAILED = 0x3,
|
||||
};
|
||||
|
||||
/**
|
||||
* Sanitize status sstat field
|
||||
*/
|
||||
struct spdk_nvme_sanitize_status_sstat {
|
||||
uint16_t status : 3;
|
||||
uint16_t complete_pass : 5;
|
||||
uint16_t global_data_erase : 1;
|
||||
uint16_t reserved : 7;
|
||||
};
|
||||
|
||||
/**
|
||||
* Sanitize log page
|
||||
*/
|
||||
struct spdk_nvme_sanitize_status_log_page {
|
||||
/* Sanitize progress */
|
||||
uint16_t sprog;
|
||||
/* Sanitize status */
|
||||
struct spdk_nvme_sanitize_status_sstat sstat;
|
||||
/* CDW10 of sanitize command */
|
||||
uint32_t scdw10;
|
||||
/* Estimated overwrite time in seconds */
|
||||
uint32_t et_overwrite;
|
||||
/* Estimated block erase time in seconds */
|
||||
uint32_t et_block_erase;
|
||||
/* Estimated crypto erase time in seconds */
|
||||
uint32_t et_crypto_erase;
|
||||
uint8_t reserved[492];
|
||||
};
|
||||
SPDK_STATIC_ASSERT(sizeof(struct spdk_nvme_sanitize_status_log_page) == 512, "Incorrect size");
|
||||
|
||||
/**
|
||||
* Asynchronous Event Type
|
||||
*/
|
||||
@ -2455,6 +2498,36 @@ struct spdk_nvme_protection_info {
|
||||
};
|
||||
SPDK_STATIC_ASSERT(sizeof(struct spdk_nvme_protection_info) == 8, "Incorrect size");
|
||||
|
||||
/* Data structures for sanitize command */
|
||||
/* Sanitize - Command Dword 10 */
|
||||
struct spdk_nvme_sanitize {
|
||||
/* Sanitize Action (SANACT) */
|
||||
uint32_t sanact : 3;
|
||||
/* Allow Unrestricted Sanitize Exit (AUSE) */
|
||||
uint32_t ause : 1;
|
||||
/* Overwrite Pass Count (OWPASS) */
|
||||
uint32_t owpass : 4;
|
||||
/* Overwrite Invert Pattern Between Passes */
|
||||
uint32_t oipbp : 1;
|
||||
/* No Deallocate after sanitize (NDAS) */
|
||||
uint32_t ndas : 1;
|
||||
/* reserved */
|
||||
uint32_t reserved : 22;
|
||||
};
|
||||
SPDK_STATIC_ASSERT(sizeof(struct spdk_nvme_format) == 4, "Incorrect size");
|
||||
|
||||
/* Sanitize Action */
|
||||
enum spdk_sanitize_action {
|
||||
/* Exit Failure Mode */
|
||||
SPDK_NVME_SANITIZE_EXIT_FAILURE_MODE = 0x1,
|
||||
/* Start a Block Erase sanitize operation */
|
||||
SPDK_NVME_SANITIZE_BLOCK_ERASE = 0x2,
|
||||
/* Start an Overwrite sanitize operation */
|
||||
SPDK_NVME_SANITIZE_OVERWRITE = 0x3,
|
||||
/* Start a Crypto Erase sanitize operation */
|
||||
SPDK_NVME_SANITIZE_CRYPTO_ERASE = 0x4,
|
||||
};
|
||||
|
||||
/** Parameters for SPDK_NVME_OPC_FIRMWARE_COMMIT cdw10: commit action */
|
||||
enum spdk_nvme_fw_commit_action {
|
||||
/**
|
||||
|
@ -717,3 +717,31 @@ nvme_ctrlr_cmd_security_send(struct spdk_nvme_ctrlr *ctrlr, uint8_t secp,
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int
|
||||
nvme_ctrlr_cmd_sanitize(struct spdk_nvme_ctrlr *ctrlr, uint32_t nsid,
|
||||
struct spdk_nvme_sanitize *sanitize, uint32_t cdw11,
|
||||
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_null(ctrlr->adminq, cb_fn, cb_arg);
|
||||
if (req == NULL) {
|
||||
nvme_robust_mutex_unlock(&ctrlr->ctrlr_lock);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
cmd = &req->cmd;
|
||||
cmd->opc = SPDK_NVME_OPC_SANITIZE;
|
||||
cmd->nsid = nsid;
|
||||
cmd->cdw11 = cdw11;
|
||||
memcpy(&cmd->cdw10, sanitize, sizeof(cmd->cdw10));
|
||||
|
||||
rc = nvme_ctrlr_submit_admin_request(ctrlr, req);
|
||||
nvme_robust_mutex_unlock(&ctrlr->ctrlr_lock);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
@ -791,6 +791,9 @@ int nvme_ctrlr_cmd_security_receive(struct spdk_nvme_ctrlr *ctrlr, uint8_t secp,
|
||||
int 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);
|
||||
int nvme_ctrlr_cmd_sanitize(struct spdk_nvme_ctrlr *ctrlr, uint32_t nsid,
|
||||
struct spdk_nvme_sanitize *sanitize, uint32_t cdw11,
|
||||
spdk_nvme_cmd_cb cb_fn, void *cb_arg);
|
||||
void nvme_completion_poll_cb(void *arg, const struct spdk_nvme_cpl *cpl);
|
||||
int spdk_nvme_wait_for_completion(struct spdk_nvme_qpair *qpair,
|
||||
struct nvme_completion_poll_status *status);
|
||||
|
Loading…
Reference in New Issue
Block a user