Commit 99c8c6d8 authored by Ben Walker's avatar Ben Walker Committed by Daniel Verkamp
Browse files

nvme: Allow users to request which I/O command set they'd like to use



As of NVMe 1.3b, there is only one command set. But pipe
this through the driver per-spec anyway.

Change-Id: I4faf8596f5ce638e5e2a500b424e00ceb6e89edc
Signed-off-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/412102


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
parent 35efde74
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -823,7 +823,7 @@ print_controller(struct spdk_nvme_ctrlr *ctrlr, const struct spdk_nvme_transport
	       cap.bits.nssrs ? "Supported" : "Not Supported");
	printf("Command Sets Supported\n");
	printf("  NVM Command Set:                     %s\n",
	       cap.bits.css_nvm ? "Supported" : "Not Supported");
	       cap.bits.css & SPDK_NVME_CAP_CSS_NVM ? "Supported" : "Not Supported");
	printf("Boot Partition:                        %s\n",
	       cap.bits.bps ? "Supported" : "Not Supported");
	printf("Memory Page Size Minimum:              %" PRIu64 " bytes\n",
+9 −0
Original line number Diff line number Diff line
@@ -144,6 +144,15 @@ struct spdk_nvme_ctrlr_opts {
	 * Set to all zeroes to specify that no host ID should be provided to the controller.
	 */
	uint8_t extended_host_id[16];

	/**
	 * The I/O command set to select.
	 *
	 * If the requested command set is not supported, the controller
	 * initialization process will not proceed. By default, the NVM
	 * command set is used.
	 */
	enum spdk_nvme_cc_css command_set;
};

/**
+12 −3
Original line number Diff line number Diff line
@@ -96,9 +96,7 @@ union spdk_nvme_cap_register {
		uint32_t nssrs		: 1;

		/** command sets supported */
		uint32_t css_nvm	: 1;

		uint32_t css_reserved	: 7;
		uint32_t css		: 8;

		/** boot partition support */
		uint32_t bps		: 1;
@@ -116,6 +114,17 @@ union spdk_nvme_cap_register {
};
SPDK_STATIC_ASSERT(sizeof(union spdk_nvme_cap_register) == 8, "Incorrect size");

/**
 * I/O Command Set Selected
 *
 * Only a single command set is defined as of NVMe 1.3 (NVM).
 */
enum spdk_nvme_cc_css {
	SPDK_NVME_CC_CSS_NVM		= 0x0,	/**< NVM command set */
};

#define SPDK_NVME_CAP_CSS_NVM (1u << SPDK_NVME_CC_CSS_NVM) /**< NVM command set supported */

union spdk_nvme_cc_register {
	uint32_t	raw;
	struct {
+18 −0
Original line number Diff line number Diff line
@@ -134,6 +134,10 @@ spdk_nvme_ctrlr_get_default_ctrlr_opts(struct spdk_nvme_ctrlr_opts *opts, size_t
	if (FIELD_OK(src_svcid)) {
		memset(opts->src_svcid, 0, sizeof(opts->src_svcid));
	}

	if (FIELD_OK(command_set)) {
		opts->command_set = SPDK_NVME_CC_CSS_NVM;
	}
#undef FIELD_OK
}

@@ -553,6 +557,20 @@ nvme_ctrlr_enable(struct spdk_nvme_ctrlr *ctrlr)
	/* Page size is 2 ^ (12 + mps). */
	cc.bits.mps = spdk_u32log2(ctrlr->page_size) - 12;

	if (ctrlr->cap.bits.css == 0) {
		SPDK_INFOLOG(SPDK_LOG_NVME,
			     "Drive reports no command sets supported. Assuming NVM is supported.\n");
		ctrlr->cap.bits.css = SPDK_NVME_CAP_CSS_NVM;
	}

	if (!(ctrlr->cap.bits.css & (1u << ctrlr->opts.command_set))) {
		SPDK_DEBUGLOG(SPDK_LOG_NVME, "Requested I/O command set %u but supported mask is 0x%x\n",
			      ctrlr->opts.command_set, ctrlr->cap.bits.css);
		return -EINVAL;
	}

	cc.bits.css = ctrlr->opts.command_set;

	switch (ctrlr->opts.arb_mechanism) {
	case SPDK_NVME_CC_AMS_RR:
		break;
+1 −1
Original line number Diff line number Diff line
@@ -166,7 +166,7 @@ spdk_nvmf_ctrlr_create(struct spdk_nvmf_subsystem *subsystem,
	ctrlr->vcprop.cap.bits.ams = 0; /* optional arb mechanisms */
	ctrlr->vcprop.cap.bits.to = 1; /* ready timeout - 500 msec units */
	ctrlr->vcprop.cap.bits.dstrd = 0; /* fixed to 0 for NVMe-oF */
	ctrlr->vcprop.cap.bits.css_nvm = 1; /* NVM command set */
	ctrlr->vcprop.cap.bits.css = SPDK_NVME_CAP_CSS_NVM; /* NVM command set */
	ctrlr->vcprop.cap.bits.mpsmin = 0; /* 2 ^ (12 + mpsmin) == 4k */
	ctrlr->vcprop.cap.bits.mpsmax = 0; /* 2 ^ (12 + mpsmax) == 4k */

Loading