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

nvmf_tgt: Add passthru handlers for vendor specific admin cmds



Vendor specific admin commands are OPCs 0xC0-0xFF.
Add handler to passthru those 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.

Since admin_cmd_passthru in nvmf_set_config has now
multiple params - make them optional, disabled by default.

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


Tested-by: default avatarSPDK Automated Test System <spdkbot@gmail.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarTomasz Zawadzki <tomasz@tzawadzki.com>
Reviewed-by: default avatarKonrad Sztyber <ksztyber@nvidia.com>
parent 3e2e0e8b
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -9380,7 +9380,8 @@ have been initialized.

 Name           | Optional   | Type   | Description
--------------- | ---------- | ------ | --------------------------------------------------------------------------------------------------------------
 identify_ctrlr | Required   | bool   | If true, enables custom identify handler that reports some identify attributes from the underlying NVMe drive
 identify_ctrlr | Optional   | bool   | If true, enables custom identify handler that reports some identify attributes from the underlying NVMe drive
 vendor_specific| Optional   | bool   | If true, enables passthru command handlers for underlying NVMe drive for vendor specific cmds (OPCs: 0xC0-0xFF)

#### Example

+1 −0
Original line number Diff line number Diff line
@@ -1715,6 +1715,7 @@ enum spdk_nvme_admin_opcode {
	SPDK_NVME_OPC_SANITIZE				= 0x84,

	SPDK_NVME_OPC_GET_LBA_STATUS			= 0x86,
	SPDK_NVME_OPC_VENDOR_SPECIFIC_START		= 0xC0,
};

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

struct spdk_nvmf_admin_passthru_conf {
	bool identify_ctrlr;
	bool vendor_specific;
};

struct spdk_nvmf_tgt_conf {
+2 −1
Original line number Diff line number Diff line
@@ -45,7 +45,8 @@ SPDK_RPC_REGISTER("nvmf_set_max_subsystems", rpc_nvmf_set_max_subsystems,
		  SPDK_RPC_STARTUP)

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}
	{"identify_ctrlr", offsetof(struct spdk_nvmf_admin_passthru_conf, identify_ctrlr), spdk_json_decode_bool, true},
	{"vendor_specific", offsetof(struct spdk_nvmf_admin_passthru_conf, vendor_specific), spdk_json_decode_bool, true}
};

static int
+17 −1
Original line number Diff line number Diff line
@@ -55,7 +55,8 @@ struct spdk_nvmf_tgt_conf g_spdk_nvmf_tgt_conf = {
		.dhchap_digests = NVMF_TGT_DEFAULT_DIGESTS,
		.dhchap_dhgroups = NVMF_TGT_DEFAULT_DHGROUPS,
	},
	.admin_passthru.identify_ctrlr = false
	.admin_passthru.identify_ctrlr = false,
	.admin_passthru.vendor_specific = false
};

struct spdk_cpuset *g_poll_groups_mask = NULL;
@@ -445,6 +446,12 @@ nvmf_custom_identify_hdlr(struct spdk_nvmf_request *req)
	return nvmf_admin_passthru_generic_hdlr(req, fixup_identify_ctrlr);
}

static int
nvmf_custom_admin_no_cb_hdlr(struct spdk_nvmf_request *req)
{
	return nvmf_admin_passthru_generic_hdlr(req, NULL);
}

static void
nvmf_tgt_advance_state(void)
{
@@ -470,6 +477,13 @@ nvmf_tgt_advance_state(void)
				SPDK_NOTICELOG("Custom identify ctrlr 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.vendor_specific) {
				int i;
				SPDK_NOTICELOG("Custom vendor specific commands handlers enabled\n");
				for (i = SPDK_NVME_OPC_VENDOR_SPECIFIC_START; i <= SPDK_NVME_MAX_OPC; i++) {
					spdk_nvmf_set_custom_admin_cmd_hdlr(i, nvmf_custom_admin_no_cb_hdlr);
				}
			}
			/* Create poll group threads, and send a message to each thread
			 * and create a poll group.
			 */
@@ -583,6 +597,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, "vendor_specific",
				   g_spdk_nvmf_tgt_conf.admin_passthru.vendor_specific);
	spdk_json_write_object_end(w);
	if (g_poll_groups_mask) {
		spdk_json_write_named_string(w, "poll_groups_mask", spdk_cpuset_fmt(g_poll_groups_mask));
Loading