rpc: Rename send_nvme_cmd to bdev_nvme_send_cmd

Change-Id: Ic441595cc2e5c3b3db1f998507660f6978759035
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466503
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Pawel Kaminski 2019-08-28 04:09:45 -04:00 committed by Jim Harris
parent b9063e4b70
commit b318d5f0cb
4 changed files with 63 additions and 59 deletions

View File

@ -5640,11 +5640,11 @@ Example response:
# Miscellaneous RPC commands # Miscellaneous RPC commands
## send_nvme_cmd {#rpc_send_nvme_cmd} ## bdev_nvme_send_cmd {#rpc_bdev_nvme_send_cmd}
Send NVMe command directly to NVMe controller or namespace. Parameters and responses encoded by base64 urlsafe need further processing. Send NVMe command directly to NVMe controller or namespace. Parameters and responses encoded by base64 urlsafe need further processing.
Notice: send_nvme_cmd requires user to guarentee the correctness of NVMe command itself, and also optional parameters. Illegal command contents or mismatching buffer size may result in unpredictable behavior. Notice: bdev_nvme_send_cmd requires user to guarentee the correctness of NVMe command itself, and also optional parameters. Illegal command contents or mismatching buffer size may result in unpredictable behavior.
### Parameters ### Parameters
@ -5675,7 +5675,7 @@ Example request:
~~~ ~~~
{ {
"jsonrpc": "2.0", "jsonrpc": "2.0",
"method": "send_nvme_cmd", "method": "bdev_nvme_send_cmd",
"id": 1, "id": 1,
"params": { "params": {
"name": "Nvme0", "name": "Nvme0",

View File

@ -47,7 +47,7 @@ enum spdk_nvme_rpc_type {
NVME_IO_CMD, NVME_IO_CMD,
}; };
struct rpc_send_nvme_cmd_req { struct rpc_bdev_nvme_send_cmd_req {
char *name; char *name;
int cmd_type; int cmd_type;
int data_direction; int data_direction;
@ -60,22 +60,22 @@ struct rpc_send_nvme_cmd_req {
char *md; char *md;
}; };
struct rpc_send_nvme_cmd_resp { struct rpc_bdev_nvme_send_cmd_resp {
char *cpl_text; char *cpl_text;
char *data_text; char *data_text;
char *md_text; char *md_text;
}; };
struct rpc_send_nvme_cmd_ctx { struct rpc_bdev_nvme_send_cmd_ctx {
struct spdk_jsonrpc_request *jsonrpc_request; struct spdk_jsonrpc_request *jsonrpc_request;
struct rpc_send_nvme_cmd_req req; struct rpc_bdev_nvme_send_cmd_req req;
struct rpc_send_nvme_cmd_resp resp; struct rpc_bdev_nvme_send_cmd_resp resp;
struct nvme_bdev_ctrlr *nvme_bdev_ctrlr; struct nvme_bdev_ctrlr *nvme_bdev_ctrlr;
struct spdk_io_channel *ctrlr_io_ch; struct spdk_io_channel *ctrlr_io_ch;
}; };
static void static void
free_rpc_send_nvme_cmd_ctx(struct rpc_send_nvme_cmd_ctx *ctx) free_rpc_bdev_nvme_send_cmd_ctx(struct rpc_bdev_nvme_send_cmd_ctx *ctx)
{ {
assert(ctx != NULL); assert(ctx != NULL);
@ -90,9 +90,9 @@ free_rpc_send_nvme_cmd_ctx(struct rpc_send_nvme_cmd_ctx *ctx)
} }
static int static int
rpc_send_nvme_cmd_resp_construct(struct rpc_send_nvme_cmd_resp *resp, rpc_bdev_nvme_send_cmd_resp_construct(struct rpc_bdev_nvme_send_cmd_resp *resp,
struct rpc_send_nvme_cmd_req *req, struct rpc_bdev_nvme_send_cmd_req *req,
const struct spdk_nvme_cpl *cpl) const struct spdk_nvme_cpl *cpl)
{ {
resp->cpl_text = malloc(spdk_base64_get_encoded_strlen(sizeof(*cpl)) + 1); resp->cpl_text = malloc(spdk_base64_get_encoded_strlen(sizeof(*cpl)) + 1);
if (!resp->cpl_text) { if (!resp->cpl_text) {
@ -121,13 +121,14 @@ rpc_send_nvme_cmd_resp_construct(struct rpc_send_nvme_cmd_resp *resp,
} }
static void static void
spdk_rpc_send_nvme_cmd_complete(struct rpc_send_nvme_cmd_ctx *ctx, const struct spdk_nvme_cpl *cpl) spdk_rpc_bdev_nvme_send_cmd_complete(struct rpc_bdev_nvme_send_cmd_ctx *ctx,
const struct spdk_nvme_cpl *cpl)
{ {
struct spdk_jsonrpc_request *request = ctx->jsonrpc_request; struct spdk_jsonrpc_request *request = ctx->jsonrpc_request;
struct spdk_json_write_ctx *w; struct spdk_json_write_ctx *w;
int ret; int ret;
ret = rpc_send_nvme_cmd_resp_construct(&ctx->resp, &ctx->req, cpl); ret = rpc_bdev_nvme_send_cmd_resp_construct(&ctx->resp, &ctx->req, cpl);
if (ret) { if (ret) {
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INTERNAL_ERROR, spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
spdk_strerror(-ret)); spdk_strerror(-ret));
@ -150,25 +151,25 @@ spdk_rpc_send_nvme_cmd_complete(struct rpc_send_nvme_cmd_ctx *ctx, const struct
spdk_jsonrpc_end_result(request, w); spdk_jsonrpc_end_result(request, w);
out: out:
free_rpc_send_nvme_cmd_ctx(ctx); free_rpc_bdev_nvme_send_cmd_ctx(ctx);
return; return;
} }
static void static void
nvme_rpc_bdev_nvme_cb(void *ref, const struct spdk_nvme_cpl *cpl) nvme_rpc_bdev_nvme_cb(void *ref, const struct spdk_nvme_cpl *cpl)
{ {
struct rpc_send_nvme_cmd_ctx *ctx = (struct rpc_send_nvme_cmd_ctx *)ref; struct rpc_bdev_nvme_send_cmd_ctx *ctx = (struct rpc_bdev_nvme_send_cmd_ctx *)ref;
if (ctx->ctrlr_io_ch) { if (ctx->ctrlr_io_ch) {
spdk_put_io_channel(ctx->ctrlr_io_ch); spdk_put_io_channel(ctx->ctrlr_io_ch);
ctx->ctrlr_io_ch = NULL; ctx->ctrlr_io_ch = NULL;
} }
spdk_rpc_send_nvme_cmd_complete(ctx, cpl); spdk_rpc_bdev_nvme_send_cmd_complete(ctx, cpl);
} }
static int static int
nvme_rpc_admin_cmd_bdev_nvme(struct rpc_send_nvme_cmd_ctx *ctx, struct spdk_nvme_cmd *cmd, nvme_rpc_admin_cmd_bdev_nvme(struct rpc_bdev_nvme_send_cmd_ctx *ctx, struct spdk_nvme_cmd *cmd,
void *buf, uint32_t nbytes, uint32_t timeout_ms) void *buf, uint32_t nbytes, uint32_t timeout_ms)
{ {
struct nvme_bdev_ctrlr *_nvme_ctrlr = ctx->nvme_bdev_ctrlr; struct nvme_bdev_ctrlr *_nvme_ctrlr = ctx->nvme_bdev_ctrlr;
@ -181,7 +182,7 @@ nvme_rpc_admin_cmd_bdev_nvme(struct rpc_send_nvme_cmd_ctx *ctx, struct spdk_nvme
} }
static int static int
nvme_rpc_io_cmd_bdev_nvme(struct rpc_send_nvme_cmd_ctx *ctx, struct spdk_nvme_cmd *cmd, nvme_rpc_io_cmd_bdev_nvme(struct rpc_bdev_nvme_send_cmd_ctx *ctx, struct spdk_nvme_cmd *cmd,
void *buf, uint32_t nbytes, void *md_buf, uint32_t md_len, void *buf, uint32_t nbytes, void *md_buf, uint32_t md_len,
uint32_t timeout_ms) uint32_t timeout_ms)
{ {
@ -203,9 +204,9 @@ nvme_rpc_io_cmd_bdev_nvme(struct rpc_send_nvme_cmd_ctx *ctx, struct spdk_nvme_cm
} }
static int static int
rpc_send_nvme_cmd_exec(struct rpc_send_nvme_cmd_ctx *ctx) rpc_bdev_nvme_send_cmd_exec(struct rpc_bdev_nvme_send_cmd_ctx *ctx)
{ {
struct rpc_send_nvme_cmd_req *req = &ctx->req; struct rpc_bdev_nvme_send_cmd_req *req = &ctx->req;
int ret = -EINVAL; int ret = -EINVAL;
switch (req->cmd_type) { switch (req->cmd_type) {
@ -296,7 +297,7 @@ out:
static int static int
rpc_decode_data(const struct spdk_json_val *val, void *out) rpc_decode_data(const struct spdk_json_val *val, void *out)
{ {
struct rpc_send_nvme_cmd_req *req = (struct rpc_send_nvme_cmd_req *)out; struct rpc_bdev_nvme_send_cmd_req *req = (struct rpc_bdev_nvme_send_cmd_req *)out;
char *text = NULL; char *text = NULL;
size_t text_strlen; size_t text_strlen;
int rc; int rc;
@ -333,7 +334,7 @@ out:
static int static int
rpc_decode_data_len(const struct spdk_json_val *val, void *out) rpc_decode_data_len(const struct spdk_json_val *val, void *out)
{ {
struct rpc_send_nvme_cmd_req *req = (struct rpc_send_nvme_cmd_req *)out; struct rpc_bdev_nvme_send_cmd_req *req = (struct rpc_bdev_nvme_send_cmd_req *)out;
uint32_t data_len; uint32_t data_len;
int rc; int rc;
@ -362,7 +363,7 @@ rpc_decode_data_len(const struct spdk_json_val *val, void *out)
static int static int
rpc_decode_metadata(const struct spdk_json_val *val, void *out) rpc_decode_metadata(const struct spdk_json_val *val, void *out)
{ {
struct rpc_send_nvme_cmd_req *req = (struct rpc_send_nvme_cmd_req *)out; struct rpc_bdev_nvme_send_cmd_req *req = (struct rpc_bdev_nvme_send_cmd_req *)out;
char *text = NULL; char *text = NULL;
size_t text_strlen; size_t text_strlen;
int rc; int rc;
@ -399,7 +400,7 @@ out:
static int static int
rpc_decode_metadata_len(const struct spdk_json_val *val, void *out) rpc_decode_metadata_len(const struct spdk_json_val *val, void *out)
{ {
struct rpc_send_nvme_cmd_req *req = (struct rpc_send_nvme_cmd_req *)out; struct rpc_bdev_nvme_send_cmd_req *req = (struct rpc_bdev_nvme_send_cmd_req *)out;
uint32_t md_len; uint32_t md_len;
int rc; int rc;
@ -425,12 +426,12 @@ rpc_decode_metadata_len(const struct spdk_json_val *val, void *out)
return rc; return rc;
} }
static const struct spdk_json_object_decoder rpc_send_nvme_cmd_req_decoders[] = { static const struct spdk_json_object_decoder rpc_bdev_nvme_send_cmd_req_decoders[] = {
{"name", offsetof(struct rpc_send_nvme_cmd_req, name), spdk_json_decode_string}, {"name", offsetof(struct rpc_bdev_nvme_send_cmd_req, name), spdk_json_decode_string},
{"cmd_type", offsetof(struct rpc_send_nvme_cmd_req, cmd_type), rpc_decode_cmd_type}, {"cmd_type", offsetof(struct rpc_bdev_nvme_send_cmd_req, cmd_type), rpc_decode_cmd_type},
{"data_direction", offsetof(struct rpc_send_nvme_cmd_req, data_direction), rpc_decode_data_direction}, {"data_direction", offsetof(struct rpc_bdev_nvme_send_cmd_req, data_direction), rpc_decode_data_direction},
{"cmdbuf", offsetof(struct rpc_send_nvme_cmd_req, cmdbuf), rpc_decode_cmdbuf}, {"cmdbuf", offsetof(struct rpc_bdev_nvme_send_cmd_req, cmdbuf), rpc_decode_cmdbuf},
{"timeout_ms", offsetof(struct rpc_send_nvme_cmd_req, timeout_ms), spdk_json_decode_uint32, true}, {"timeout_ms", offsetof(struct rpc_bdev_nvme_send_cmd_req, timeout_ms), spdk_json_decode_uint32, true},
{"data_len", 0, rpc_decode_data_len, true}, {"data_len", 0, rpc_decode_data_len, true},
{"metadata_len", 0, rpc_decode_metadata_len, true}, {"metadata_len", 0, rpc_decode_metadata_len, true},
{"data", 0, rpc_decode_data, true}, {"data", 0, rpc_decode_data, true},
@ -438,10 +439,10 @@ static const struct spdk_json_object_decoder rpc_send_nvme_cmd_req_decoders[] =
}; };
static void static void
spdk_rpc_send_nvme_cmd(struct spdk_jsonrpc_request *request, spdk_rpc_bdev_nvme_send_cmd(struct spdk_jsonrpc_request *request,
const struct spdk_json_val *params) const struct spdk_json_val *params)
{ {
struct rpc_send_nvme_cmd_ctx *ctx; struct rpc_bdev_nvme_send_cmd_ctx *ctx;
int ret, error_code; int ret, error_code;
ctx = calloc(1, sizeof(*ctx)); ctx = calloc(1, sizeof(*ctx));
@ -452,8 +453,8 @@ spdk_rpc_send_nvme_cmd(struct spdk_jsonrpc_request *request,
goto invalid; goto invalid;
} }
if (spdk_json_decode_object(params, rpc_send_nvme_cmd_req_decoders, if (spdk_json_decode_object(params, rpc_bdev_nvme_send_cmd_req_decoders,
SPDK_COUNTOF(rpc_send_nvme_cmd_req_decoders), SPDK_COUNTOF(rpc_bdev_nvme_send_cmd_req_decoders),
&ctx->req)) { &ctx->req)) {
SPDK_ERRLOG("spdk_json_decode_object failed\n"); SPDK_ERRLOG("spdk_json_decode_object failed\n");
error_code = SPDK_JSONRPC_ERROR_INVALID_PARAMS; error_code = SPDK_JSONRPC_ERROR_INVALID_PARAMS;
@ -471,9 +472,9 @@ spdk_rpc_send_nvme_cmd(struct spdk_jsonrpc_request *request,
ctx->jsonrpc_request = request; ctx->jsonrpc_request = request;
ret = rpc_send_nvme_cmd_exec(ctx); ret = rpc_bdev_nvme_send_cmd_exec(ctx);
if (ret < 0) { if (ret < 0) {
SPDK_NOTICELOG("Failed at rpc_send_nvme_cmd_exec\n"); SPDK_NOTICELOG("Failed at rpc_bdev_nvme_send_cmd_exec\n");
error_code = SPDK_JSONRPC_ERROR_INTERNAL_ERROR; error_code = SPDK_JSONRPC_ERROR_INTERNAL_ERROR;
goto invalid; goto invalid;
} }
@ -482,7 +483,8 @@ spdk_rpc_send_nvme_cmd(struct spdk_jsonrpc_request *request,
invalid: invalid:
spdk_jsonrpc_send_error_response(request, error_code, spdk_strerror(-ret)); spdk_jsonrpc_send_error_response(request, error_code, spdk_strerror(-ret));
free_rpc_send_nvme_cmd_ctx(ctx); free_rpc_bdev_nvme_send_cmd_ctx(ctx);
return; return;
} }
SPDK_RPC_REGISTER("send_nvme_cmd", spdk_rpc_send_nvme_cmd, SPDK_RPC_RUNTIME) SPDK_RPC_REGISTER("bdev_nvme_send_cmd", spdk_rpc_bdev_nvme_send_cmd, SPDK_RPC_RUNTIME)
SPDK_RPC_REGISTER_ALIAS_DEPRECATED(bdev_nvme_send_cmd, send_nvme_cmd)

View File

@ -1891,20 +1891,21 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
domain:bus:device.function format or domain.bus.device.function format""") domain:bus:device.function format or domain.bus.device.function format""")
p.set_defaults(func=scan_ioat_copy_engine) p.set_defaults(func=scan_ioat_copy_engine)
# send_nvme_cmd # bdev_nvme_send_cmd
def send_nvme_cmd(args): def bdev_nvme_send_cmd(args):
print_dict(rpc.nvme.send_nvme_cmd(args.client, print_dict(rpc.nvme.bdev_nvme_send_cmd(args.client,
name=args.nvme_name, name=args.nvme_name,
cmd_type=args.cmd_type, cmd_type=args.cmd_type,
data_direction=args.data_direction, data_direction=args.data_direction,
cmdbuf=args.cmdbuf, cmdbuf=args.cmdbuf,
data=args.data, data=args.data,
metadata=args.metadata, metadata=args.metadata,
data_len=args.data_length, data_len=args.data_length,
metadata_len=args.metadata_length, metadata_len=args.metadata_length,
timeout_ms=args.timeout_ms)) timeout_ms=args.timeout_ms))
p = subparsers.add_parser('send_nvme_cmd', help='NVMe passthrough cmd.') p = subparsers.add_parser('bdev_nvme_send_cmd', aliases=['send_nvme_cmd'],
help='NVMe passthrough cmd.')
p.add_argument('-n', '--nvme-name', help="""Name of the operating NVMe controller""") p.add_argument('-n', '--nvme-name', help="""Name of the operating NVMe controller""")
p.add_argument('-t', '--cmd-type', help="""Type of nvme cmd. Valid values are: admin, io""") p.add_argument('-t', '--cmd-type', help="""Type of nvme cmd. Valid values are: admin, io""")
p.add_argument('-r', '--data-direction', help="""Direction of data transfer. Valid values are: c2h, h2c""") p.add_argument('-r', '--data-direction', help="""Direction of data transfer. Valid values are: c2h, h2c""")
@ -1915,7 +1916,7 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse
p.add_argument('-M', '--metadata-length', help="""Metadata length required to transfer from controller to host""", type=int) p.add_argument('-M', '--metadata-length', help="""Metadata length required to transfer from controller to host""", type=int)
p.add_argument('-T', '--timeout-ms', p.add_argument('-T', '--timeout-ms',
help="""Command execution timeout value, in milliseconds, if 0, don't track timeout""", type=int, default=0) help="""Command execution timeout value, in milliseconds, if 0, don't track timeout""", type=int, default=0)
p.set_defaults(func=send_nvme_cmd) p.set_defaults(func=bdev_nvme_send_cmd)
# Notifications # Notifications
def get_notification_types(args): def get_notification_types(args):

View File

@ -1,10 +1,11 @@
from .helpers import deprecated_alias from .helpers import deprecated_alias
def send_nvme_cmd(client, name, cmd_type, data_direction, cmdbuf, @deprecated_alias('send_nvme_cmd')
data=None, metadata=None, def bdev_nvme_send_cmd(client, name, cmd_type, data_direction, cmdbuf,
data_len=None, metadata_len=None, data=None, metadata=None,
timeout_ms=None): data_len=None, metadata_len=None,
timeout_ms=None):
"""Send one NVMe command """Send one NVMe command
Args: Args:
@ -37,7 +38,7 @@ def send_nvme_cmd(client, name, cmd_type, data_direction, cmdbuf,
if timeout_ms: if timeout_ms:
params['timeout_ms'] = timeout_ms params['timeout_ms'] = timeout_ms
return client.call('send_nvme_cmd', params) return client.call('bdev_nvme_send_cmd', params)
@deprecated_alias('get_nvme_controllers') @deprecated_alias('get_nvme_controllers')