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

nvmf_tgt: Add passthru support for NVMe-MI send/recv OPC



Add handler to passthru NVMe-MI send/recv OPC 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: Ia74b6fb20b3d9ac67242108820f25219a8b93f0e
Signed-off-by: default avatarPawel Baldysiak <pawel.baldysiak@dell.com>
Reviewed-on: https://review.spdk.io/c/spdk/spdk/+/26610


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 e39172e7
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -8593,6 +8593,7 @@ have been initialized.
 sanitize           | Optional   | bool   | If true, enables passthru sanitize OPC handlers for underlying NVMe drive
 security_send_recv | Optional   | bool   | If true, enables passthru security send/recieve OPC handlers for underlying NVMe drive
 fw_update          | Optional   | bool   | If true, enables passthru firmware download/commit OPC handlers for underlying NVMe drive
 nvme_mi            | Optional   | bool   | If true, enables passthru NVMe-MI send/recieve OPC handlers for 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
@@ -22,6 +22,7 @@ struct spdk_nvmf_admin_passthru_conf {
	bool sanitize;
	bool security_send_recv;
	bool fw_update;
	bool nvme_mi;
	bool vendor_specific;
};

+1 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ static const struct spdk_json_object_decoder admin_passthru_decoder[] = {
	{"sanitize", offsetof(struct spdk_nvmf_admin_passthru_conf, sanitize), spdk_json_decode_bool, true},
	{"security_send_recv", offsetof(struct spdk_nvmf_admin_passthru_conf, security_send_recv), spdk_json_decode_bool, true},
	{"fw_update", offsetof(struct spdk_nvmf_admin_passthru_conf, fw_update), spdk_json_decode_bool, true},
	{"nvme_mi", offsetof(struct spdk_nvmf_admin_passthru_conf, nvme_mi), spdk_json_decode_bool, true},
	{"vendor_specific", offsetof(struct spdk_nvmf_admin_passthru_conf, vendor_specific), spdk_json_decode_bool, true},
};

+14 −0
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ struct spdk_nvmf_tgt_conf g_spdk_nvmf_tgt_conf = {
	.admin_passthru.sanitize = false,
	.admin_passthru.security_send_recv = false,
	.admin_passthru.fw_update = false,
	.admin_passthru.nvme_mi = false,
	.admin_passthru.vendor_specific = false
};

@@ -433,6 +434,12 @@ fixup_get_cmds_and_effects_log_page(struct spdk_nvmf_request *req)
		nvmf_log_data.admin_cmds_supported[SPDK_NVME_OPC_FIRMWARE_IMAGE_DOWNLOAD] =
			nvme_log_data.admin_cmds_supported[SPDK_NVME_OPC_FIRMWARE_IMAGE_DOWNLOAD];
	}
	if (g_spdk_nvmf_tgt_conf.admin_passthru.nvme_mi) {
		nvmf_log_data.admin_cmds_supported[SPDK_NVME_OPC_NVME_MI_RECEIVE] =
			nvme_log_data.admin_cmds_supported[SPDK_NVME_OPC_NVME_MI_RECEIVE];
		nvmf_log_data.admin_cmds_supported[SPDK_NVME_OPC_NVME_MI_SEND] =
			nvme_log_data.admin_cmds_supported[SPDK_NVME_OPC_NVME_MI_SEND];
	}

	/* Copy the fixed SPDK struct to the request */
	spdk_nvmf_request_copy_from_buf(req, (uint8_t *) &nvmf_log_data + offset, datalen);
@@ -737,6 +744,11 @@ nvmf_tgt_advance_state(void)
				spdk_nvmf_set_custom_admin_cmd_hdlr(SPDK_NVME_OPC_FIRMWARE_IMAGE_DOWNLOAD,
								    nvmf_custom_admin_no_cb_hdlr);
			}
			if (g_spdk_nvmf_tgt_conf.admin_passthru.nvme_mi) {
				SPDK_NOTICELOG("Custom NVMe-MI send/recv commands handlers enabled\n");
				spdk_nvmf_set_custom_admin_cmd_hdlr(SPDK_NVME_OPC_NVME_MI_RECEIVE, nvmf_custom_admin_no_cb_hdlr);
				spdk_nvmf_set_custom_admin_cmd_hdlr(SPDK_NVME_OPC_NVME_MI_SEND, nvmf_custom_admin_no_cb_hdlr);
			}
			if (g_spdk_nvmf_tgt_conf.admin_passthru.vendor_specific) {
				int i;
				SPDK_NOTICELOG("Custom vendor specific commands handlers enabled\n");
@@ -867,6 +879,8 @@ nvmf_subsystem_write_config_json(struct spdk_json_write_ctx *w)
				   g_spdk_nvmf_tgt_conf.admin_passthru.security_send_recv);
	spdk_json_write_named_bool(w, "fw_update",
				   g_spdk_nvmf_tgt_conf.admin_passthru.fw_update);
	spdk_json_write_named_bool(w, "nvme_mi",
				   g_spdk_nvmf_tgt_conf.admin_passthru.nvme_mi);
	spdk_json_write_named_bool(w, "vendor_specific",
				   g_spdk_nvmf_tgt_conf.admin_passthru.vendor_specific);
	spdk_json_write_object_end(w);
+2 −2
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ def add_parser(subparsers):
                  file=sys.stderr)
            admin_cmd_passthru.append('identify_ctrlr')
        all_admin_cmd_passthru = ('identify_ctrlr', 'get_log_page', 'get_set_features', 'sanitize', 'security_send_recv', 'fw_update',
                                  'vendor_specific')
                                  'nvme_mi', 'vendor_specific')
        if 'all' in admin_cmd_passthru:
            admin_cmd_passthru = {cmd: True for cmd in all_admin_cmd_passthru}
        else:
@@ -44,7 +44,7 @@ def add_parser(subparsers):
    p.add_argument('-p', '--passthru-admin-cmds', help="""Comma-separated list of admin commands to be passthru
                   when the controller has a single namespace that is an NVMe bdev.
                   Available options are: all, identify_ctrlr, get_log_page, get_set_features, sanitize, security_send_recv,
                   fw_update, vendor_specific""",
                   fw_update, nvme_mi, vendor_specific""",
                   type=lambda d: d.split(','))
    p.add_argument('-m', '--poll-groups-mask', help='Set cpumask for NVMf poll groups (optional)', type=str)
    p.add_argument('-d', '--discovery-filter', help="""Set discovery filter (optional), possible values are: `match_any` (default) or