Commit c9ae71ff authored by Amit Engel's avatar Amit Engel Committed by Tomasz Zawadzki
Browse files

rpc: add controller type (cntrltype) to nvmf_subsystem_get_controllers



Add cntrltype field to struct spdk_nvmf_ctrlr_data
and set it during controller initialization.
This allows the nvmf_subsystem_get_controllers RPC to report
whether a controller is an IO or Discovery controller.

Change-Id: If65e8f94c62dc672ed5ab563c730c795ba1f9e07
Signed-off-by: default avatarAmit Engel <amit.engel@dell.com>
Reviewed-on: https://review.spdk.io/c/spdk/spdk/+/26438


Reviewed-by: default avatarTomasz Zawadzki <tomasz@tzawadzki.com>
Reviewed-by: default avatarDor Deri <dor.deri@dell.com>
Reviewed-by: default avatarKrzysztof Goreczny <krzysztof.goreczny@dell.com>
Reviewed-by: default avatarJim Harris <jim.harris@nvidia.com>
Tested-by: default avatarSPDK Automated Test System <spdkbot@gmail.com>
Community-CI: Mellanox Build Bot
parent 82ff8572
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -8901,6 +8901,7 @@ Example response:
  "result": [
    {
      "cntlid": 1,
      "cntrltype: "io",
      "hostnqn": "nqn.2016-06.io.spdk:host1",
      "hostid": "27dad528-6368-41c3-82d3-0b956b49025d",
      "num_io_qpairs": 5
+1 −0
Original line number Diff line number Diff line
@@ -251,6 +251,7 @@ struct spdk_nvmf_ctrlr_data {
	uint16_t ssvid;
	/** ieee oui identifier */
	uint8_t ieee[3];
	uint8_t cntrltype;
	struct spdk_nvme_cdata_oacs oacs;
	struct spdk_nvme_cdata_oncs oncs;
	struct spdk_nvme_cdata_fuses fuses;
+2 −0
Original line number Diff line number Diff line
@@ -385,6 +385,8 @@ nvmf_ctrlr_cdata_init(struct spdk_nvmf_transport *transport, struct spdk_nvmf_su
	cdata->sgls.supported = 1;
	cdata->sgls.keyed_sgl = 1;
	cdata->sgls.sgl_offset = 1;
	cdata->cntrltype = spdk_nvmf_subsystem_is_discovery(subsystem) ?
			   SPDK_NVME_CTRLR_DISCOVERY : SPDK_NVME_CTRLR_IO;
	cdata->nvmf_specific.ioccsz = sizeof(struct spdk_nvme_cmd) / 16;
	cdata->nvmf_specific.ioccsz += transport->opts.in_capsule_data_size / 16;
	cdata->nvmf_specific.iorcsz = sizeof(struct spdk_nvme_cpl) / 16;
+16 −0
Original line number Diff line number Diff line
@@ -2834,6 +2834,21 @@ rpc_nvmf_get_stats(struct spdk_jsonrpc_request *request,

SPDK_RPC_REGISTER("nvmf_get_stats", rpc_nvmf_get_stats, SPDK_RPC_RUNTIME)

static const char *
nvmf_cntrltype_str(enum spdk_nvme_ctrlr_type type)
{
	switch (type) {
	case SPDK_NVME_CTRLR_IO:
		return "io";
	case SPDK_NVME_CTRLR_DISCOVERY:
		return "discovery";
	case SPDK_NVME_CTRLR_ADMINISTRATIVE:
		return "administrative";
	default:
		return "unknown";
	}
}

static void
dump_nvmf_ctrlr(struct spdk_json_write_ctx *w, struct spdk_nvmf_ctrlr *ctrlr)
{
@@ -2842,6 +2857,7 @@ dump_nvmf_ctrlr(struct spdk_json_write_ctx *w, struct spdk_nvmf_ctrlr *ctrlr)
	spdk_json_write_object_begin(w);

	spdk_json_write_named_uint32(w, "cntlid", ctrlr->cntlid);
	spdk_json_write_named_string(w, "cntrltype", nvmf_cntrltype_str(ctrlr->cdata.cntrltype));
	spdk_json_write_named_string(w, "hostnqn", ctrlr->hostnqn);
	spdk_json_write_named_uuid(w, "hostid", &ctrlr->hostid);