Commit c9874b91 authored by Michael Haeuptle's avatar Michael Haeuptle Committed by Tomasz Zawadzki
Browse files

lib/nvmf: custom admin handler config



This commit disables the custom identify handler by default.
The user has to explictly enable this handler via the set_nvmf_config
RPC or conf file.

Change-Id: I767816ba7639ebe78683993408ce6db02c7620fe
Signed-off-by: default avatarMichael Haeuptle <michael.haeuptle@hpe.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/479603


Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent e93902a0
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -33,9 +33,8 @@ in `spdk_internal/nvmf.h` expose this functionality. There is an example custom
for the NVMe IDENTIFY CTRLR in `lib/nvmf/custom_cmd_hdlr.c`. This handler gets the SN, MN, FR, IEEE, FGUID
attributes from the first NVMe drive in the NVMF subsystem and returns it to the NVMF initiator (sn and mn attributes
specified during NVMF subsystem creation RPC will be overwritten).

This handler is enabled by default and can be disabled by adding
`spdk_nvmf_set_custom_admin_cmd_hdlr(SPDK_NVME_OPC_IDENTIFY, NULL);` to a target application.
This handler can be enabled via the `nvmf_set_config` RPC.
Note: In a future version of SPDK, this handler will be enabled by default.

### sock

+7 −0
Original line number Diff line number Diff line
@@ -4313,6 +4313,13 @@ have been initialized.
Name                    | Optional | Type        | Description
----------------------- | -------- | ----------- | -----------
acceptor_poll_rate      | Optional | number      | Polling interval of the acceptor for incoming connections (microseconds)
admin_cmd_passthru      | Optional | object      | Admin command passthru configuration

### admin_cmd_passthru {#spdk_nvmf_admin_passthru_conf}

Name                    | Optional | Type        | Description
----------------------- | -------- | ----------- | -----------
identify_ctrlr          | Required | bool        | If true, enables custom identify handler that reports some identify attributes from the underlying NVMe drive

### Example

+4 −0
Original line number Diff line number Diff line
@@ -136,6 +136,9 @@ spdk_nvmf_read_config_file_tgt_conf(struct spdk_conf_section *sp,
			       "we will use RoundRobin as the default scheduler\n");
	}

	conf->admin_passthru.identify_ctrlr = spdk_conf_section_get_boolval(sp,
					      "AdminCmdPassthruIdentifyCtrlr", false);

	return rc;
}

@@ -168,6 +171,7 @@ spdk_nvmf_parse_tgt_conf(void)

	conf->acceptor_poll_rate = ACCEPT_TIMEOUT_US;
	conf->conn_sched = DEFAULT_CONN_SCHED;
	conf->admin_passthru.identify_ctrlr = false;

	sp = spdk_conf_find_section(NULL, "Nvmf");
	if (sp != NULL) {
+5 −0
Original line number Diff line number Diff line
@@ -51,9 +51,14 @@ enum spdk_nvmf_connect_sched {
	CONNECT_SCHED_TRANSPORT_OPTIMAL_GROUP,
};

struct spdk_nvmf_admin_passthru_conf {
	bool identify_ctrlr;
};

struct spdk_nvmf_tgt_conf {
	uint32_t acceptor_poll_rate;
	enum spdk_nvmf_connect_sched conn_sched;
	struct spdk_nvmf_admin_passthru_conf admin_passthru;
};

extern struct spdk_nvmf_tgt_conf *g_spdk_nvmf_tgt_conf;
+20 −0
Original line number Diff line number Diff line
@@ -92,9 +92,28 @@ static int decode_conn_sched(const struct spdk_json_val *val, void *out)
	return 0;
}

static const struct spdk_json_object_decoder admin_passthru_decoder[] = {
	{"identify_ctrlr", offsetof(struct spdk_nvmf_admin_passthru_conf, identify_ctrlr), spdk_json_decode_bool}
};

static int decode_admin_passthru(const struct spdk_json_val *val, void *out)
{
	struct spdk_nvmf_admin_passthru_conf *req = (struct spdk_nvmf_admin_passthru_conf *)out;

	if (spdk_json_decode_object(val, admin_passthru_decoder,
				    SPDK_COUNTOF(admin_passthru_decoder),
				    req)) {
		SPDK_ERRLOG("spdk_json_decode_object failed\n");
		return -1;
	}

	return 0;
}

static const struct spdk_json_object_decoder nvmf_rpc_subsystem_tgt_conf_decoder[] = {
	{"acceptor_poll_rate", offsetof(struct spdk_nvmf_tgt_conf, acceptor_poll_rate), spdk_json_decode_uint32, true},
	{"conn_sched", offsetof(struct spdk_nvmf_tgt_conf, conn_sched), decode_conn_sched, true},
	{"admin_cmd_passthru", offsetof(struct spdk_nvmf_tgt_conf, admin_passthru), decode_admin_passthru, true}
};

static void
@@ -121,6 +140,7 @@ spdk_rpc_nvmf_set_config(struct spdk_jsonrpc_request *request,

	conf->acceptor_poll_rate = ACCEPT_TIMEOUT_US;
	conf->conn_sched = DEFAULT_CONN_SCHED;
	conf->admin_passthru.identify_ctrlr = false;

	if (params != NULL) {
		if (spdk_json_decode_object(params, nvmf_rpc_subsystem_tgt_conf_decoder,
Loading