Commit 7966e4a7 authored by Pawel Baldysiak's avatar Pawel Baldysiak Committed by Tomasz Zawadzki
Browse files

nvmf_tgt: Add passthru support for UUID_LIST CNS of identify



Add handler to passthru identify UUID_LIST cns cmds to underlying dev.
It is disabled by default, can be enabled by RPC.
It uses already existing generic passthru handler,
which makes sure that ctrlr-scope admin cmds are passthru
only for subsystem with single namespace.

Change-Id: Ibb862fb501d211bc049d6c2408c5f5b0becad75c
Signed-off-by: default avatarPawel Baldysiak <pawel.baldysiak@dell.com>
Reviewed-on: https://review.spdk.io/c/spdk/spdk/+/26611


Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK Automated Test System <spdkbot@gmail.com>
Reviewed-by: default avatarJim Harris <jim.harris@nvidia.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
parent cb55872e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -8588,6 +8588,7 @@ have been initialized.
 Name               | Optional   | Type   | Description
------------------- | ---------- | ------ | --------------------------------------------------------------------------------------------------------------
 identify_ctrlr     | Optional   | bool   | If true, enables custom identify handler that reports some identify attributes from the underlying NVMe drive
 identify_uuid_list | Optional   | bool   | If true, enables passthru identify UUID list (0x17 CNS) admin cmds for underlying NVMe device
 get_log_page       | Optional   | bool   | If true, enables passthru get log page command handlers for underlying NVMe drive (for non-fabrics related log pages)
 get_set_features   | Optional   | bool   | If true, enables passthru get/set_feature OPC handlers for underlying NVMe drive
 sanitize           | Optional   | bool   | If true, enables passthru sanitize OPC handlers for underlying NVMe drive
+3 −0
Original line number Diff line number Diff line
@@ -2045,6 +2045,9 @@ enum spdk_nvme_identify_cns {
	/** Get secondary controller list */
	SPDK_NVME_IDENTIFY_SECONDARY_CTRLR_LIST		= 0x15,

	/** Get UUID List */
	SPDK_NVME_IDENTIFY_UUID_LIST			= 0x17,

	/** List allocated NSIDs greater than CDW1.NSID, specific to CDW11.CSI */
	SPDK_NVME_IDENTIFY_ALLOCATED_NS_LIST_IOCS	= 0x1a,

+1 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@

struct spdk_nvmf_admin_passthru_conf {
	bool identify_ctrlr;
	bool identify_uuid_list;
	bool get_log_page;
	bool get_set_features;
	bool sanitize;
+1 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ SPDK_RPC_REGISTER("nvmf_set_max_subsystems", rpc_nvmf_set_max_subsystems,

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, true},
	{"identify_uuid_list", offsetof(struct spdk_nvmf_admin_passthru_conf, identify_uuid_list), spdk_json_decode_bool, true},
	{"get_log_page", offsetof(struct spdk_nvmf_admin_passthru_conf, get_log_page), spdk_json_decode_bool, true},
	{"get_set_features", offsetof(struct spdk_nvmf_admin_passthru_conf, get_set_features), spdk_json_decode_bool, true},
	{"sanitize", offsetof(struct spdk_nvmf_admin_passthru_conf, sanitize), spdk_json_decode_bool, true},
+18 −5
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ struct spdk_nvmf_tgt_conf g_spdk_nvmf_tgt_conf = {
		.dhchap_dhgroups = NVMF_TGT_DEFAULT_DHGROUPS,
	},
	.admin_passthru.identify_ctrlr = false,
	.admin_passthru.identify_uuid_list = false,
	.admin_passthru.get_log_page = false,
	.admin_passthru.get_set_features = false,
	.admin_passthru.sanitize = false,
@@ -580,6 +581,9 @@ fixup_identify_ctrlr(struct spdk_nvmf_request *req)
		nvmf_cdata.fwug = nvme_cdata.fwug;
		nvmf_cdata.mtfa = nvme_cdata.mtfa;
	}
	if (g_spdk_nvmf_tgt_conf.admin_passthru.identify_uuid_list) {
		nvmf_cdata.ctratt.bits.uuid_list = nvme_cdata.ctratt.bits.uuid_list;
	}

	/* Copy the fixed up data back to the response */
	spdk_nvmf_request_copy_from_buf(req, &nvmf_cdata, datalen);
@@ -624,11 +628,17 @@ nvmf_custom_identify_hdlr(struct spdk_nvmf_request *req)
{
	struct spdk_nvme_cmd *cmd = spdk_nvmf_request_get_cmd(req);

	if (cmd->cdw10_bits.identify.cns != SPDK_NVME_IDENTIFY_CTRLR) {
		return -1; /* Only support Identify Controller */
	if (cmd->cdw10_bits.identify.cns == SPDK_NVME_IDENTIFY_CTRLR &&
	    g_spdk_nvmf_tgt_conf.admin_passthru.identify_ctrlr) {
		return nvmf_admin_passthru_generic_hdlr(req, fixup_identify_ctrlr);
	}

	return nvmf_admin_passthru_generic_hdlr(req, fixup_identify_ctrlr);
	if (cmd->cdw10_bits.identify.cns == SPDK_NVME_IDENTIFY_UUID_LIST &&
	    g_spdk_nvmf_tgt_conf.admin_passthru.identify_uuid_list) {
		return nvmf_admin_passthru_generic_hdlr(req, NULL);
	}

	return -1;
}

static int
@@ -715,8 +725,9 @@ nvmf_tgt_advance_state(void)
			g_tgt_state = (ret == 0) ? NVMF_TGT_INIT_CREATE_POLL_GROUPS : NVMF_TGT_ERROR;
			break;
		case NVMF_TGT_INIT_CREATE_POLL_GROUPS:
			if (g_spdk_nvmf_tgt_conf.admin_passthru.identify_ctrlr) {
				SPDK_NOTICELOG("Custom identify ctrlr handler enabled\n");
			if (g_spdk_nvmf_tgt_conf.admin_passthru.identify_ctrlr ||
			    g_spdk_nvmf_tgt_conf.admin_passthru.identify_uuid_list) {
				SPDK_NOTICELOG("Custom identify OPC handler enabled\n");
				spdk_nvmf_set_custom_admin_cmd_hdlr(SPDK_NVME_OPC_IDENTIFY, nvmf_custom_identify_hdlr);
			}
			if (g_spdk_nvmf_tgt_conf.admin_passthru.get_log_page) {
@@ -869,6 +880,8 @@ nvmf_subsystem_write_config_json(struct spdk_json_write_ctx *w)
	spdk_json_write_named_object_begin(w, "admin_cmd_passthru");
	spdk_json_write_named_bool(w, "identify_ctrlr",
				   g_spdk_nvmf_tgt_conf.admin_passthru.identify_ctrlr);
	spdk_json_write_named_bool(w, "identify_uuid_list",
				   g_spdk_nvmf_tgt_conf.admin_passthru.identify_uuid_list);
	spdk_json_write_named_bool(w, "get_log_page",
				   g_spdk_nvmf_tgt_conf.admin_passthru.get_log_page);
	spdk_json_write_named_bool(w, "get_set_features",
Loading