bdev/nvme: Add helper functions to decode T10 DIF parameters
Signed-off-by: Shuhei Matsumoto <smatsumoto@nvidia.com> Change-Id: If218cbc8ee0a5354e5c4e58eaae111660eb9c099 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11828 Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Community-CI: Mellanox Build Bot 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:
parent
d40292d05a
commit
df32eb112b
@ -181,8 +181,7 @@ struct rpc_bdev_nvme_attach_controller {
|
|||||||
char *hostnqn;
|
char *hostnqn;
|
||||||
char *hostaddr;
|
char *hostaddr;
|
||||||
char *hostsvcid;
|
char *hostsvcid;
|
||||||
bool prchk_reftag;
|
uint32_t prchk_flags;
|
||||||
bool prchk_guard;
|
|
||||||
char *multipath;
|
char *multipath;
|
||||||
int32_t ctrlr_loss_timeout_sec;
|
int32_t ctrlr_loss_timeout_sec;
|
||||||
uint32_t reconnect_delay_sec;
|
uint32_t reconnect_delay_sec;
|
||||||
@ -206,6 +205,36 @@ free_rpc_bdev_nvme_attach_controller(struct rpc_bdev_nvme_attach_controller *req
|
|||||||
free(req->multipath);
|
free(req->multipath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
bdev_nvme_decode_reftag(const struct spdk_json_val *val, void *out)
|
||||||
|
{
|
||||||
|
uint32_t *flag = out;
|
||||||
|
bool reftag;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
rc = spdk_json_decode_bool(val, &reftag);
|
||||||
|
if (rc == 0 && reftag == true) {
|
||||||
|
*flag |= SPDK_NVME_IO_FLAGS_PRCHK_REFTAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
bdev_nvme_decode_guard(const struct spdk_json_val *val, void *out)
|
||||||
|
{
|
||||||
|
uint32_t *flag = out;
|
||||||
|
bool guard;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
rc = spdk_json_decode_bool(val, &guard);
|
||||||
|
if (rc == 0 && guard == true) {
|
||||||
|
*flag |= SPDK_NVME_IO_FLAGS_PRCHK_GUARD;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
static const struct spdk_json_object_decoder rpc_bdev_nvme_attach_controller_decoders[] = {
|
static const struct spdk_json_object_decoder rpc_bdev_nvme_attach_controller_decoders[] = {
|
||||||
{"name", offsetof(struct rpc_bdev_nvme_attach_controller, name), spdk_json_decode_string},
|
{"name", offsetof(struct rpc_bdev_nvme_attach_controller, name), spdk_json_decode_string},
|
||||||
{"trtype", offsetof(struct rpc_bdev_nvme_attach_controller, trtype), spdk_json_decode_string},
|
{"trtype", offsetof(struct rpc_bdev_nvme_attach_controller, trtype), spdk_json_decode_string},
|
||||||
@ -219,8 +248,8 @@ static const struct spdk_json_object_decoder rpc_bdev_nvme_attach_controller_dec
|
|||||||
{"hostaddr", offsetof(struct rpc_bdev_nvme_attach_controller, hostaddr), spdk_json_decode_string, true},
|
{"hostaddr", offsetof(struct rpc_bdev_nvme_attach_controller, hostaddr), spdk_json_decode_string, true},
|
||||||
{"hostsvcid", offsetof(struct rpc_bdev_nvme_attach_controller, hostsvcid), spdk_json_decode_string, true},
|
{"hostsvcid", offsetof(struct rpc_bdev_nvme_attach_controller, hostsvcid), spdk_json_decode_string, true},
|
||||||
|
|
||||||
{"prchk_reftag", offsetof(struct rpc_bdev_nvme_attach_controller, prchk_reftag), spdk_json_decode_bool, true},
|
{"prchk_reftag", offsetof(struct rpc_bdev_nvme_attach_controller, prchk_flags), bdev_nvme_decode_reftag, true},
|
||||||
{"prchk_guard", offsetof(struct rpc_bdev_nvme_attach_controller, prchk_guard), spdk_json_decode_bool, true},
|
{"prchk_guard", offsetof(struct rpc_bdev_nvme_attach_controller, prchk_flags), bdev_nvme_decode_guard, true},
|
||||||
{"hdgst", offsetof(struct rpc_bdev_nvme_attach_controller, drv_opts.header_digest), spdk_json_decode_bool, true},
|
{"hdgst", offsetof(struct rpc_bdev_nvme_attach_controller, drv_opts.header_digest), spdk_json_decode_bool, true},
|
||||||
{"ddgst", offsetof(struct rpc_bdev_nvme_attach_controller, drv_opts.data_digest), spdk_json_decode_bool, true},
|
{"ddgst", offsetof(struct rpc_bdev_nvme_attach_controller, drv_opts.data_digest), spdk_json_decode_bool, true},
|
||||||
{"fabrics_connect_timeout_us", offsetof(struct rpc_bdev_nvme_attach_controller, drv_opts.fabrics_connect_timeout_us), spdk_json_decode_uint64, true},
|
{"fabrics_connect_timeout_us", offsetof(struct rpc_bdev_nvme_attach_controller, drv_opts.fabrics_connect_timeout_us), spdk_json_decode_uint64, true},
|
||||||
@ -286,7 +315,6 @@ rpc_bdev_nvme_attach_controller(struct spdk_jsonrpc_request *request,
|
|||||||
struct spdk_nvme_transport_id trid = {};
|
struct spdk_nvme_transport_id trid = {};
|
||||||
const struct spdk_nvme_ctrlr_opts *drv_opts;
|
const struct spdk_nvme_ctrlr_opts *drv_opts;
|
||||||
const struct spdk_nvme_transport_id *ctrlr_trid;
|
const struct spdk_nvme_transport_id *ctrlr_trid;
|
||||||
uint32_t prchk_flags = 0;
|
|
||||||
struct nvme_ctrlr *ctrlr = NULL;
|
struct nvme_ctrlr *ctrlr = NULL;
|
||||||
size_t len, maxlen;
|
size_t len, maxlen;
|
||||||
bool multipath = false;
|
bool multipath = false;
|
||||||
@ -467,7 +495,7 @@ rpc_bdev_nvme_attach_controller(struct spdk_jsonrpc_request *request,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->req.prchk_guard || ctx->req.prchk_reftag) {
|
if (ctx->req.prchk_flags) {
|
||||||
spdk_jsonrpc_send_error_response_fmt(request, -EINVAL,
|
spdk_jsonrpc_send_error_response_fmt(request, -EINVAL,
|
||||||
"A controller named %s already exists. To add a path, do not specify PI options.\n",
|
"A controller named %s already exists. To add a path, do not specify PI options.\n",
|
||||||
ctx->req.name);
|
ctx->req.name);
|
||||||
@ -475,14 +503,6 @@ rpc_bdev_nvme_attach_controller(struct spdk_jsonrpc_request *request,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->req.prchk_reftag) {
|
|
||||||
prchk_flags |= SPDK_NVME_IO_FLAGS_PRCHK_REFTAG;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ctx->req.prchk_guard) {
|
|
||||||
prchk_flags |= SPDK_NVME_IO_FLAGS_PRCHK_GUARD;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ctx->req.multipath != NULL && strcasecmp(ctx->req.multipath, "multipath") == 0) {
|
if (ctx->req.multipath != NULL && strcasecmp(ctx->req.multipath, "multipath") == 0) {
|
||||||
multipath = true;
|
multipath = true;
|
||||||
}
|
}
|
||||||
@ -496,7 +516,7 @@ rpc_bdev_nvme_attach_controller(struct spdk_jsonrpc_request *request,
|
|||||||
|
|
||||||
ctx->request = request;
|
ctx->request = request;
|
||||||
ctx->count = NVME_MAX_BDEVS_PER_RPC;
|
ctx->count = NVME_MAX_BDEVS_PER_RPC;
|
||||||
rc = bdev_nvme_create(&trid, ctx->req.name, ctx->names, ctx->count, prchk_flags,
|
rc = bdev_nvme_create(&trid, ctx->req.name, ctx->names, ctx->count, ctx->req.prchk_flags,
|
||||||
rpc_bdev_nvme_attach_controller_done, ctx, &ctx->req.drv_opts,
|
rpc_bdev_nvme_attach_controller_done, ctx, &ctx->req.drv_opts,
|
||||||
multipath, ctx->req.ctrlr_loss_timeout_sec,
|
multipath, ctx->req.ctrlr_loss_timeout_sec,
|
||||||
ctx->req.reconnect_delay_sec, ctx->req.fast_io_fail_timeout_sec);
|
ctx->req.reconnect_delay_sec, ctx->req.fast_io_fail_timeout_sec);
|
||||||
|
Loading…
Reference in New Issue
Block a user