bdev: add NVMe I/O passthru command
Change-Id: I4d281be99553629563026cc4f9ab890d0a97986c Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-on: https://review.gerrithub.io/364115 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
bac4c02bc4
commit
eba5c996c8
@ -84,6 +84,7 @@ enum spdk_bdev_io_type {
|
|||||||
SPDK_BDEV_IO_TYPE_FLUSH,
|
SPDK_BDEV_IO_TYPE_FLUSH,
|
||||||
SPDK_BDEV_IO_TYPE_RESET,
|
SPDK_BDEV_IO_TYPE_RESET,
|
||||||
SPDK_BDEV_IO_TYPE_NVME_ADMIN,
|
SPDK_BDEV_IO_TYPE_NVME_ADMIN,
|
||||||
|
SPDK_BDEV_IO_TYPE_NVME_IO,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -230,6 +231,11 @@ struct spdk_bdev_io *spdk_bdev_nvme_admin_passthru(struct spdk_bdev *bdev,
|
|||||||
const struct spdk_nvme_cmd *cmd,
|
const struct spdk_nvme_cmd *cmd,
|
||||||
void *buf, size_t nbytes,
|
void *buf, size_t nbytes,
|
||||||
spdk_bdev_io_completion_cb cb, void *cb_arg);
|
spdk_bdev_io_completion_cb cb, void *cb_arg);
|
||||||
|
struct spdk_bdev_io *spdk_bdev_nvme_io_passthru(struct spdk_bdev *bdev,
|
||||||
|
struct spdk_io_channel *ch,
|
||||||
|
const struct spdk_nvme_cmd *cmd,
|
||||||
|
void *buf, size_t nbytes,
|
||||||
|
spdk_bdev_io_completion_cb cb, void *cb_arg);
|
||||||
int spdk_bdev_free_io(struct spdk_bdev_io *bdev_io);
|
int spdk_bdev_free_io(struct spdk_bdev_io *bdev_io);
|
||||||
int spdk_bdev_reset(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
|
int spdk_bdev_reset(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
|
||||||
spdk_bdev_io_completion_cb cb, void *cb_arg);
|
spdk_bdev_io_completion_cb cb, void *cb_arg);
|
||||||
|
@ -996,6 +996,39 @@ spdk_bdev_nvme_admin_passthru(struct spdk_bdev *bdev, struct spdk_io_channel *ch
|
|||||||
return bdev_io;
|
return bdev_io;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct spdk_bdev_io *
|
||||||
|
spdk_bdev_nvme_io_passthru(struct spdk_bdev *bdev, struct spdk_io_channel *ch,
|
||||||
|
const struct spdk_nvme_cmd *cmd, void *buf, size_t nbytes,
|
||||||
|
spdk_bdev_io_completion_cb cb, void *cb_arg)
|
||||||
|
{
|
||||||
|
struct spdk_bdev_io *bdev_io;
|
||||||
|
struct spdk_bdev_channel *channel = spdk_io_channel_get_ctx(ch);
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
bdev_io = spdk_bdev_get_io();
|
||||||
|
if (!bdev_io) {
|
||||||
|
SPDK_ERRLOG("bdev_io memory allocation failed during nvme_admin_passthru\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bdev_io->ch = channel;
|
||||||
|
bdev_io->type = SPDK_BDEV_IO_TYPE_NVME_IO;
|
||||||
|
bdev_io->u.nvme_passthru.cmd = *cmd;
|
||||||
|
bdev_io->u.nvme_passthru.buf = buf;
|
||||||
|
bdev_io->u.nvme_passthru.nbytes = nbytes;
|
||||||
|
|
||||||
|
spdk_bdev_io_init(bdev_io, bdev, cb_arg, cb);
|
||||||
|
|
||||||
|
rc = spdk_bdev_io_submit(bdev_io);
|
||||||
|
if (rc < 0) {
|
||||||
|
spdk_bdev_put_io(bdev_io);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bdev_io;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
spdk_bdev_free_io(struct spdk_bdev_io *bdev_io)
|
spdk_bdev_free_io(struct spdk_bdev_io *bdev_io)
|
||||||
{
|
{
|
||||||
|
@ -139,6 +139,9 @@ static int bdev_nvme_queue_cmd(struct nvme_bdev *bdev, struct spdk_nvme_qpair *q
|
|||||||
uint64_t offset);
|
uint64_t offset);
|
||||||
static int bdev_nvme_admin_passthru(struct nvme_bdev *nbdev, struct nvme_bdev_io *bio,
|
static int bdev_nvme_admin_passthru(struct nvme_bdev *nbdev, struct nvme_bdev_io *bio,
|
||||||
struct spdk_nvme_cmd *cmd, void *buf, size_t nbytes);
|
struct spdk_nvme_cmd *cmd, void *buf, size_t nbytes);
|
||||||
|
static int bdev_nvme_io_passthru(struct nvme_bdev *nbdev, struct spdk_io_channel *ch,
|
||||||
|
struct nvme_bdev_io *bio,
|
||||||
|
struct spdk_nvme_cmd *cmd, void *buf, size_t nbytes);
|
||||||
|
|
||||||
static int
|
static int
|
||||||
bdev_nvme_get_ctx_size(void)
|
bdev_nvme_get_ctx_size(void)
|
||||||
@ -313,6 +316,14 @@ _bdev_nvme_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_
|
|||||||
bdev_io->u.nvme_passthru.buf,
|
bdev_io->u.nvme_passthru.buf,
|
||||||
bdev_io->u.nvme_passthru.nbytes);
|
bdev_io->u.nvme_passthru.nbytes);
|
||||||
|
|
||||||
|
case SPDK_BDEV_IO_TYPE_NVME_IO:
|
||||||
|
return bdev_nvme_io_passthru((struct nvme_bdev *)bdev_io->bdev->ctxt,
|
||||||
|
ch,
|
||||||
|
(struct nvme_bdev_io *)bdev_io->driver_ctx,
|
||||||
|
&bdev_io->u.nvme_passthru.cmd,
|
||||||
|
bdev_io->u.nvme_passthru.buf,
|
||||||
|
bdev_io->u.nvme_passthru.nbytes);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
@ -339,6 +350,7 @@ bdev_nvme_io_type_supported(void *ctx, enum spdk_bdev_io_type io_type)
|
|||||||
case SPDK_BDEV_IO_TYPE_RESET:
|
case SPDK_BDEV_IO_TYPE_RESET:
|
||||||
case SPDK_BDEV_IO_TYPE_FLUSH:
|
case SPDK_BDEV_IO_TYPE_FLUSH:
|
||||||
case SPDK_BDEV_IO_TYPE_NVME_ADMIN:
|
case SPDK_BDEV_IO_TYPE_NVME_ADMIN:
|
||||||
|
case SPDK_BDEV_IO_TYPE_NVME_IO:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case SPDK_BDEV_IO_TYPE_UNMAP:
|
case SPDK_BDEV_IO_TYPE_UNMAP:
|
||||||
@ -1138,6 +1150,28 @@ bdev_nvme_admin_passthru(struct nvme_bdev *nbdev, struct nvme_bdev_io *bio,
|
|||||||
(uint32_t)nbytes, bdev_nvme_admin_passthru_done, bio);
|
(uint32_t)nbytes, bdev_nvme_admin_passthru_done, bio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
bdev_nvme_io_passthru(struct nvme_bdev *nbdev, struct spdk_io_channel *ch,
|
||||||
|
struct nvme_bdev_io *bio,
|
||||||
|
struct spdk_nvme_cmd *cmd, void *buf, size_t nbytes)
|
||||||
|
{
|
||||||
|
struct nvme_io_channel *nvme_ch = spdk_io_channel_get_ctx(ch);
|
||||||
|
|
||||||
|
if (nbytes > UINT32_MAX) {
|
||||||
|
SPDK_ERRLOG("nbytes is greater than UINT32_MAX.\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Each NVMe bdev is a specific namespace, and all NVMe I/O commands require a nsid,
|
||||||
|
* so fill it out automatically.
|
||||||
|
*/
|
||||||
|
cmd->nsid = spdk_nvme_ns_get_id(nbdev->ns);
|
||||||
|
|
||||||
|
return spdk_nvme_ctrlr_cmd_io_raw(nbdev->nvme_ctrlr->ctrlr, nvme_ch->qpair, cmd, buf,
|
||||||
|
(uint32_t)nbytes, bdev_nvme_queued_done, bio);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
bdev_nvme_get_spdk_running_config(FILE *fp)
|
bdev_nvme_get_spdk_running_config(FILE *fp)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user