Commit f331ae16 authored by Konrad Sztyber's avatar Konrad Sztyber Committed by Tomasz Zawadzki
Browse files

bdev/nvme: add RPC returning information about discovery service



The RPC returns a list of active discovery service connections.  Each
discovery service is described by a name, its trid, and a list of
discovery service trids it refers to.

Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Ifa4b9501dd353e7b4948ad830575a6c94dafd86b
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12380


Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
parent d71a91bb
Loading
Loading
Loading
Loading
+37 −0
Original line number Diff line number Diff line
@@ -3344,6 +3344,43 @@ Example response:
}
~~~

### bdev_nvme_get_discovery_info {#rpc_bdev_nvme_get_discovery_info}

Get information about the discovery service.

#### Example

Example request:
~~~json
{
  "jsonrpc": "2.0",
  "method": "bdev_nvme_get_discovery_info",
  "id": 1
}
~~~

Example response:

~~~json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": [
    {
      "name": "nvme-disc",
      "trid": {
        "trtype": "TCP",
        "adrfam": "IPv4",
        "traddr": "127.0.0.1",
        "trsvcid": "8009",
        "subnqn": "nqn.2014-08.org.nvmexpress.discovery"
      },
      "referrals": []
    }
  ]
}
~~~

### bdev_nvme_get_io_paths {#rpc_bdev_nvme_get_io_paths}

Display all or the specified NVMe bdev's active I/O paths.
+30 −0
Original line number Diff line number Diff line
@@ -6500,4 +6500,34 @@ nvme_io_path_info_json(struct spdk_json_write_ctx *w, struct nvme_io_path *io_pa
	spdk_json_write_object_end(w);
}

void
bdev_nvme_get_discovery_info(struct spdk_json_write_ctx *w)
{
	struct discovery_ctx *ctx;
	struct discovery_entry_ctx *entry_ctx;

	spdk_json_write_array_begin(w);
	TAILQ_FOREACH(ctx, &g_discovery_ctxs, tailq) {
		spdk_json_write_object_begin(w);
		spdk_json_write_named_string(w, "name", ctx->name);

		spdk_json_write_named_object_begin(w, "trid");
		nvme_bdev_dump_trid_json(&ctx->trid, w);
		spdk_json_write_object_end(w);

		spdk_json_write_named_array_begin(w, "referrals");
		TAILQ_FOREACH(entry_ctx, &ctx->discovery_entry_ctxs, tailq) {
			spdk_json_write_object_begin(w);
			spdk_json_write_named_object_begin(w, "trid");
			nvme_bdev_dump_trid_json(&entry_ctx->trid, w);
			spdk_json_write_object_end(w);
			spdk_json_write_object_end(w);
		}
		spdk_json_write_array_end(w);

		spdk_json_write_object_end(w);
	}
	spdk_json_write_array_end(w);
}

SPDK_LOG_REGISTER_COMPONENT(bdev_nvme)
+1 −0
Original line number Diff line number Diff line
@@ -300,6 +300,7 @@ int bdev_nvme_start_discovery(struct spdk_nvme_transport_id *trid, const char *b
			      spdk_bdev_nvme_start_discovery_fn cb_fn, void *cb_ctx);
int bdev_nvme_stop_discovery(const char *name, spdk_bdev_nvme_stop_discovery_fn cb_fn,
			     void *cb_ctx);
void bdev_nvme_get_discovery_info(struct spdk_json_write_ctx *w);

struct spdk_nvme_ctrlr *bdev_nvme_get_ctrlr(struct spdk_bdev *bdev);

+13 −0
Original line number Diff line number Diff line
@@ -1766,6 +1766,19 @@ cleanup:
SPDK_RPC_REGISTER("bdev_nvme_stop_discovery", rpc_bdev_nvme_stop_discovery,
		  SPDK_RPC_RUNTIME)

static void
rpc_bdev_nvme_get_discovery_info(struct spdk_jsonrpc_request *request,
				 const struct spdk_json_val *params)
{
	struct spdk_json_write_ctx *w;

	w = spdk_jsonrpc_begin_result(request);
	bdev_nvme_get_discovery_info(w);
	spdk_jsonrpc_end_result(request, w);
}
SPDK_RPC_REGISTER("bdev_nvme_get_discovery_info", rpc_bdev_nvme_get_discovery_info,
		  SPDK_RPC_RUNTIME)

enum error_injection_cmd_type {
	NVME_ADMIN_CMD = 1,
	NVME_IO_CMD,
+6 −0
Original line number Diff line number Diff line
@@ -811,6 +811,12 @@ def bdev_nvme_stop_discovery(client, name):
    return client.call('bdev_nvme_stop_discovery', params)


def bdev_nvme_get_discovery_info(client):
    """Get information about the automatic discovery
    """
    return client.call('bdev_nvme_get_discovery_info')


def bdev_nvme_get_io_paths(client, name):
    """Display all or the specified NVMe bdev's active I/O paths

Loading