Commit e865a524 authored by Lance Hartmann's avatar Lance Hartmann Committed by Ben Walker
Browse files

nvme: Eliminate identify errors to Discovery ctrlr



The nvme/identify cmd issued some cmds to a ctrlr irrespective
of its type, and when the target was a Discovery ctrlr which only
accepts a very limited cmd set, that would result in errors observable
both on the initiator side (from nvme/identify) and in the output on
the target (nvmf_tgt).  Introduce new API, spdk_nvme_ctrlr_is_discovery(),
and alter identify to make use of that in determining which commands
to send to the target.

Change-Id: I974a569843f1d2b9e1ece7bd3bf9ceee1bfae872
Signed-off-by: default avatarLance Hartmann <lance.hartmann@oracle.com>
Reviewed-on: https://review.gerrithub.io/436225


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
parent 37af0cc9
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -18,6 +18,9 @@ Add a new TCP/IP transport(located in lib/nvme/nvme_tcp.c) in nvme driver. With
this new transport, it can be used to connect the NVMe-oF target with the
same TCP/IP support.

Added API, spdk_nvme_ctrlr_is_discovery(), to indicate whether the ctrlr
arg refers to a Discovery Controller or not.

### NVMe-oF Target

The `spdk_nvmf_tgt_opts` struct has been deprecated in favor of `spdk_nvmf_transport_opts`.
+33 −16
Original line number Diff line number Diff line
@@ -405,9 +405,17 @@ get_log_pages(struct spdk_nvme_ctrlr *ctrlr)
{
	const struct spdk_nvme_ctrlr_data *cdata;
	outstanding_commands = 0;
	bool is_discovery = spdk_nvme_ctrlr_is_discovery(ctrlr);

	cdata = spdk_nvme_ctrlr_get_data(ctrlr);

	if (!is_discovery) {
		/*
		 * Only attempt to retrieve the following log pages
		 * when the NVM subsystem that's being targeted is
		 * NOT the Discovery Controller which only fields
		 * a Discovery Log Page.
		 */
		if (get_error_log_page(ctrlr) == 0) {
			outstanding_commands++;
		} else {
@@ -425,6 +433,7 @@ get_log_pages(struct spdk_nvme_ctrlr *ctrlr)
		} else {
			printf("Get Log Page (Firmware Slot Information) failed\n");
		}
	}

	if (cdata->lpa.celp) {
		if (get_cmd_effects_log_page(ctrlr) == 0) {
@@ -459,7 +468,7 @@ get_log_pages(struct spdk_nvme_ctrlr *ctrlr)

	}

	if (get_discovery_log_page(ctrlr) == 0) {
	if (is_discovery && (get_discovery_log_page(ctrlr) == 0)) {
		outstanding_commands++;
	}

@@ -867,7 +876,15 @@ print_controller(struct spdk_nvme_ctrlr *ctrlr, const struct spdk_nvme_transport
	cap = spdk_nvme_ctrlr_get_regs_cap(ctrlr);
	vs = spdk_nvme_ctrlr_get_regs_vs(ctrlr);

	if (!spdk_nvme_ctrlr_is_discovery(ctrlr)) {
		/*
		 * Discovery Controller only supports the
		 * IDENTIFY and GET_LOG_PAGE cmd set, so only
		 * attempt GET_FEATURES when NOT targeting a
		 * Discovery Controller.
		 */
		get_features(ctrlr);
	}
	get_log_pages(ctrlr);

	cdata = spdk_nvme_ctrlr_get_data(ctrlr);
+9 −0
Original line number Diff line number Diff line
@@ -183,6 +183,15 @@ struct spdk_nvme_ctrlr_opts {
	bool data_digest;
};

/**
 * Indicate whether a ctrlr handle is associated with a Discovery controller.
 *
 * \param ctrlr Opaque handle to NVMe controller.
 *
 * \return true if a discovery controller, else false.
 */
bool spdk_nvme_ctrlr_is_discovery(struct spdk_nvme_ctrlr *ctrlr);

/**
 * Get the default options for the creation of a specific NVMe controller.
 *
+9 −0
Original line number Diff line number Diff line
@@ -2733,3 +2733,12 @@ spdk_nvme_ctrlr_free_cmb_io_buffer(struct spdk_nvme_ctrlr *ctrlr, void *buf, siz
		nvme_robust_mutex_unlock(&ctrlr->ctrlr_lock);
	}
}

bool
spdk_nvme_ctrlr_is_discovery(struct spdk_nvme_ctrlr *ctrlr)
{
	assert(ctrlr);

	return !strncmp(ctrlr->trid.subnqn, SPDK_NVMF_DISCOVERY_NQN,
			strlen(SPDK_NVMF_DISCOVERY_NQN));
}