Commit f54df840 authored by Pawel Kaminski's avatar Pawel Kaminski Committed by Jim Harris
Browse files

rpc: Rename construct_nvme_bdev to bdev_nvme_attach_controller



Change-Id: I1831eb39d3d357594968271b2ee69bb48502a59c
Signed-off-by: default avatarPawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466138


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarPaul Luse <paul.e.luse@intel.com>
parent 714a5646
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -393,15 +393,15 @@ To delete a null bdev use the bdev_null_delete command.

There are two ways to create block device based on NVMe device in SPDK. First
way is to connect local PCIe drive and second one is to connect NVMe-oF device.
In both cases user should use `construct_nvme_bdev` RPC command to achieve that.
In both cases user should use `bdev_nvme_attach_controller` RPC command to achieve that.

Example commands

`rpc.py construct_nvme_bdev -b NVMe1 -t PCIe -a 0000:01:00.0`
`rpc.py bdev_nvme_attach_controller -b NVMe1 -t PCIe -a 0000:01:00.0`

This command will create NVMe bdev of physical device in the system.

`rpc.py construct_nvme_bdev -b Nvme0 -t RDMA -a 192.168.100.1 -f IPv4 -s 4420 -n nqn.2016-06.io.spdk:cnode1`
`rpc.py bdev_nvme_attach_controller -b Nvme0 -t RDMA -a 192.168.100.1 -f IPv4 -s 4420 -n nqn.2016-06.io.spdk:cnode1`

This command will create NVMe bdev of NVMe-oF resource.

+5 −5
Original line number Diff line number Diff line
@@ -293,7 +293,7 @@ Example response:
    "construct_passthru_bdev",
    "bdev_nvme_apply_firmware",
    "delete_nvme_controller",
    "construct_nvme_bdev",
    "bdev_nvme_attach_controller",
    "bdev_null_create",
    "bdev_malloc_delete",
    "bdev_malloc_create",
@@ -452,7 +452,7 @@ Example response:
        "name": "Nvme1",
        "traddr": "0000:01:00.0"
      },
      "method": "construct_nvme_bdev"
      "method": "bdev_nvme_attach_controller"
    },
    {
      "params": {
@@ -460,7 +460,7 @@ Example response:
        "name": "Nvme2",
        "traddr": "0000:03:00.0"
      },
      "method": "construct_nvme_bdev"
      "method": "bdev_nvme_attach_controller"
    },
    {
      "params": {
@@ -1479,7 +1479,7 @@ Example response:
}
~~~

## construct_nvme_bdev {#rpc_construct_nvme_bdev}
## bdev_nvme_attach_controller {#rpc_bdev_nvme_attach_controller}

Construct @ref bdev_config_nvme

@@ -1515,7 +1515,7 @@ Example request:
    "traddr": "0000:0a:00.0"
  },
  "jsonrpc": "2.0",
  "method": "construct_nvme_bdev",
  "method": "bdev_nvme_attach_controller",
  "id": 1
}
~~~
+1 −1
Original line number Diff line number Diff line
@@ -260,7 +260,7 @@ reactor.c: 424:_spdk_reactor_run: *NOTICE*: Reactor started on core 0 on socket
~~~

~~~{.sh}
host:~# ./scripts/rpc.py construct_nvme_bdev -b Nvme0 -t pcie -a 0000:01:00.0
host:~# ./scripts/rpc.py bdev_nvme_attach_controller -b Nvme0 -t pcie -a 0000:01:00.0
EAL: PCI device 0000:01:00.0 on NUMA socket 0
EAL:   probe driver: 8086:953 spdk_nvme
EAL:   using IOMMU type 1 (Type 1)
+1 −1
Original line number Diff line number Diff line
@@ -2121,7 +2121,7 @@ bdev_nvme_config_json(struct spdk_json_write_ctx *w)

		spdk_json_write_object_begin(w);

		spdk_json_write_named_string(w, "method", "construct_nvme_bdev");
		spdk_json_write_named_string(w, "method", "bdev_nvme_attach_controller");

		spdk_json_write_named_object_begin(w, "params");
		spdk_json_write_named_string(w, "name", nvme_bdev_ctrlr->name);
+29 −27
Original line number Diff line number Diff line
@@ -158,7 +158,7 @@ invalid:
SPDK_RPC_REGISTER("bdev_nvme_set_hotplug", spdk_rpc_bdev_nvme_set_hotplug, SPDK_RPC_RUNTIME)
SPDK_RPC_REGISTER_ALIAS_DEPRECATED(bdev_nvme_set_hotplug, set_bdev_nvme_hotplug)

struct rpc_construct_nvme {
struct rpc_bdev_nvme_attach_controller {
	char *name;
	char *trtype;
	char *adrfam;
@@ -173,7 +173,7 @@ struct rpc_construct_nvme {
};

static void
free_rpc_construct_nvme(struct rpc_construct_nvme *req)
free_rpc_bdev_nvme_attach_controller(struct rpc_bdev_nvme_attach_controller *req)
{
	free(req->name);
	free(req->trtype);
@@ -186,35 +186,35 @@ free_rpc_construct_nvme(struct rpc_construct_nvme *req)
	free(req->hostsvcid);
}

static const struct spdk_json_object_decoder rpc_construct_nvme_decoders[] = {
	{"name", offsetof(struct rpc_construct_nvme, name), spdk_json_decode_string},
	{"trtype", offsetof(struct rpc_construct_nvme, trtype), spdk_json_decode_string},
	{"traddr", offsetof(struct rpc_construct_nvme, traddr), spdk_json_decode_string},
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},
	{"trtype", offsetof(struct rpc_bdev_nvme_attach_controller, trtype), spdk_json_decode_string},
	{"traddr", offsetof(struct rpc_bdev_nvme_attach_controller, traddr), spdk_json_decode_string},

	{"adrfam", offsetof(struct rpc_construct_nvme, adrfam), spdk_json_decode_string, true},
	{"trsvcid", offsetof(struct rpc_construct_nvme, trsvcid), spdk_json_decode_string, true},
	{"subnqn", offsetof(struct rpc_construct_nvme, subnqn), spdk_json_decode_string, true},
	{"hostnqn", offsetof(struct rpc_construct_nvme, hostnqn), spdk_json_decode_string, true},
	{"hostaddr", offsetof(struct rpc_construct_nvme, hostaddr), spdk_json_decode_string, true},
	{"hostsvcid", offsetof(struct rpc_construct_nvme, hostsvcid), spdk_json_decode_string, true},
	{"adrfam", offsetof(struct rpc_bdev_nvme_attach_controller, adrfam), spdk_json_decode_string, true},
	{"trsvcid", offsetof(struct rpc_bdev_nvme_attach_controller, trsvcid), spdk_json_decode_string, true},
	{"subnqn", offsetof(struct rpc_bdev_nvme_attach_controller, subnqn), spdk_json_decode_string, true},
	{"hostnqn", offsetof(struct rpc_bdev_nvme_attach_controller, hostnqn), 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},

	{"prchk_reftag", offsetof(struct rpc_construct_nvme, prchk_reftag), spdk_json_decode_bool, true},
	{"prchk_guard", offsetof(struct rpc_construct_nvme, prchk_guard), spdk_json_decode_bool, true}
	{"prchk_reftag", offsetof(struct rpc_bdev_nvme_attach_controller, prchk_reftag), spdk_json_decode_bool, true},
	{"prchk_guard", offsetof(struct rpc_bdev_nvme_attach_controller, prchk_guard), spdk_json_decode_bool, true}
};

#define NVME_MAX_BDEVS_PER_RPC 128

struct rpc_create_nvme_bdev_ctx {
	struct rpc_construct_nvme req;
struct rpc_bdev_nvme_attach_controller_ctx {
	struct rpc_bdev_nvme_attach_controller req;
	size_t count;
	const char *names[NVME_MAX_BDEVS_PER_RPC];
	struct spdk_jsonrpc_request *request;
};

static void
spdk_rpc_construct_nvme_bdev_done(void *cb_ctx, int rc)
spdk_rpc_bdev_nvme_attach_controller_done(void *cb_ctx, int rc)
{
	struct rpc_create_nvme_bdev_ctx *ctx = cb_ctx;
	struct rpc_bdev_nvme_attach_controller_ctx *ctx = cb_ctx;
	struct spdk_jsonrpc_request *request = ctx->request;
	struct spdk_json_write_ctx *w;
	size_t i;
@@ -233,15 +233,15 @@ spdk_rpc_construct_nvme_bdev_done(void *cb_ctx, int rc)
	spdk_jsonrpc_end_result(request, w);

exit:
	free_rpc_construct_nvme(&ctx->req);
	free_rpc_bdev_nvme_attach_controller(&ctx->req);
	free(ctx);
}

static void
spdk_rpc_construct_nvme_bdev(struct spdk_jsonrpc_request *request,
spdk_rpc_bdev_nvme_attach_controller(struct spdk_jsonrpc_request *request,
				     const struct spdk_json_val *params)
{
	struct rpc_create_nvme_bdev_ctx *ctx;
	struct rpc_bdev_nvme_attach_controller_ctx *ctx;
	struct spdk_nvme_transport_id trid = {};
	struct spdk_nvme_host_id hostid = {};
	uint32_t prchk_flags = 0;
@@ -253,8 +253,8 @@ spdk_rpc_construct_nvme_bdev(struct spdk_jsonrpc_request *request,
		return;
	}

	if (spdk_json_decode_object(params, rpc_construct_nvme_decoders,
				    SPDK_COUNTOF(rpc_construct_nvme_decoders),
	if (spdk_json_decode_object(params, rpc_bdev_nvme_attach_controller_decoders,
				    SPDK_COUNTOF(rpc_bdev_nvme_attach_controller_decoders),
				    &ctx->req)) {
		SPDK_ERRLOG("spdk_json_decode_object failed\n");
		spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
@@ -314,7 +314,7 @@ spdk_rpc_construct_nvme_bdev(struct spdk_jsonrpc_request *request,
	ctx->request = request;
	ctx->count = NVME_MAX_BDEVS_PER_RPC;
	rc = spdk_bdev_nvme_create(&trid, &hostid, ctx->req.name, ctx->names, &ctx->count, ctx->req.hostnqn,
				   prchk_flags, spdk_rpc_construct_nvme_bdev_done, ctx);
				   prchk_flags, spdk_rpc_bdev_nvme_attach_controller_done, ctx);
	if (rc) {
		spdk_jsonrpc_send_error_response(request, rc, spdk_strerror(-rc));
		goto cleanup;
@@ -323,10 +323,12 @@ spdk_rpc_construct_nvme_bdev(struct spdk_jsonrpc_request *request,
	return;

cleanup:
	free_rpc_construct_nvme(&ctx->req);
	free_rpc_bdev_nvme_attach_controller(&ctx->req);
	free(ctx);
}
SPDK_RPC_REGISTER("construct_nvme_bdev", spdk_rpc_construct_nvme_bdev, SPDK_RPC_RUNTIME)
SPDK_RPC_REGISTER("bdev_nvme_attach_controller", spdk_rpc_bdev_nvme_attach_controller,
		  SPDK_RPC_RUNTIME)
SPDK_RPC_REGISTER_ALIAS_DEPRECATED(bdev_nvme_attach_controller, construct_nvme_bdev)

static void
spdk_rpc_dump_nvme_controller_info(struct spdk_json_write_ctx *w,
Loading