nvme: support meta data on vendor specific commands

spdk_nvme_ctrlr_cmd_io_raw_with_md() will be verified
on Cosmos+ OpenSSD as soon as it will support meta data.

Change-Id: Ib5f3f1f1eba66d0147a566804395bfa5ec959c2f
Signed-off-by: Young Tack Jin <youngtack.jin@circuitblvd.com>
Reviewed-on: https://review.gerrithub.io/377428
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Young Tack Jin 2017-09-06 14:25:37 -07:00 committed by Jim Harris
parent 06988b1f2b
commit ef1437b313
3 changed files with 62 additions and 0 deletions

View File

@ -567,6 +567,25 @@ int spdk_nvme_ctrlr_cmd_io_raw(struct spdk_nvme_ctrlr *ctrlr,
void *buf, uint32_t len,
spdk_nvme_cmd_cb cb_fn, void *cb_arg);
/**
* \brief Send the given NVM I/O command with metadata to the NVMe controller.
*
* This is a low level interface for submitting I/O commands directly. Prefer
* the spdk_nvme_ns_cmd_* functions instead. The validity of the command will
* not be checked!
*
* When constructing the nvme_command it is not necessary to fill out the PRP
* list/SGL or the CID. The driver will handle both of those for you.
*
* The command is submitted to a qpair allocated by spdk_nvme_ctrlr_alloc_io_qpair().
* The user must ensure that only one thread submits I/O on a given qpair at any given time.
*/
int spdk_nvme_ctrlr_cmd_io_raw_with_md(struct spdk_nvme_ctrlr *ctrlr,
struct spdk_nvme_qpair *qpair,
struct spdk_nvme_cmd *cmd,
void *buf, uint32_t len, void *md_buf,
spdk_nvme_cmd_cb cb_fn, void *cb_arg);
/**
* \brief Process any outstanding completions for I/O submitted on a queue pair.
*

View File

@ -53,6 +53,29 @@ spdk_nvme_ctrlr_cmd_io_raw(struct spdk_nvme_ctrlr *ctrlr,
return nvme_qpair_submit_request(qpair, req);
}
int
spdk_nvme_ctrlr_cmd_io_raw_with_md(struct spdk_nvme_ctrlr *ctrlr,
struct spdk_nvme_qpair *qpair,
struct spdk_nvme_cmd *cmd,
void *buf, uint32_t len, void *md_buf,
spdk_nvme_cmd_cb cb_fn, void *cb_arg)
{
struct nvme_request *req;
struct nvme_payload payload;
payload.type = NVME_PAYLOAD_TYPE_CONTIG;
payload.u.contig = buf;
payload.md = md_buf;
req = nvme_allocate_request(qpair, &payload, len, cb_fn, cb_arg);
if (req == NULL)
return -ENOMEM;
memcpy(&req->cmd, cmd, sizeof(req->cmd));
return nvme_qpair_submit_request(qpair, req);
}
int
spdk_nvme_ctrlr_cmd_admin_raw(struct spdk_nvme_ctrlr *ctrlr,
struct spdk_nvme_cmd *cmd,

View File

@ -121,6 +121,13 @@ static void verify_io_raw_cmd(struct nvme_request *req)
CU_ASSERT(memcmp(&req->cmd, &command, sizeof(req->cmd)) == 0);
}
static void verify_io_raw_cmd_with_md(struct nvme_request *req)
{
struct spdk_nvme_cmd command = {};
CU_ASSERT(memcmp(&req->cmd, &command, sizeof(req->cmd)) == 0);
}
static void verify_intel_smart_log_page(struct nvme_request *req)
{
uint32_t temp_cdw10;
@ -488,6 +495,18 @@ test_io_raw_cmd(void)
spdk_nvme_ctrlr_cmd_io_raw(&ctrlr, &qpair, &cmd, NULL, 1, NULL, NULL);
}
static void
test_io_raw_cmd_with_md(void)
{
struct spdk_nvme_ctrlr ctrlr = {};
struct spdk_nvme_qpair qpair = {};
struct spdk_nvme_cmd cmd = {};
verify_fn = verify_io_raw_cmd_with_md;
spdk_nvme_ctrlr_cmd_io_raw_with_md(&ctrlr, &qpair, &cmd, NULL, 1, NULL, NULL, NULL);
}
static void
test_get_log_pages(void)
{
@ -593,6 +612,7 @@ int main(int argc, char **argv)
|| CU_add_test(suite, "test ctrlr cmd get_feature", test_get_feature_cmd) == NULL
|| CU_add_test(suite, "test ctrlr cmd abort_cmd", test_abort_cmd) == NULL
|| CU_add_test(suite, "test ctrlr cmd io_raw_cmd", test_io_raw_cmd) == NULL
|| CU_add_test(suite, "test ctrlr cmd io_raw_cmd_with_md", test_io_raw_cmd_with_md) == NULL
|| CU_add_test(suite, "test ctrlr cmd namespace_attach", test_namespace_attach) == NULL
|| CU_add_test(suite, "test ctrlr cmd namespace_detach", test_namespace_detach) == NULL
|| CU_add_test(suite, "test ctrlr cmd namespace_create", test_namespace_create) == NULL