Commit 8b95dbab authored by Changpeng Liu's avatar Changpeng Liu Committed by Jim Harris
Browse files

nvme: broken up nvme_ctrlr_set_num_qpairs() into set/get functions



Change-Id: If5744389ae36f9af0964040d30f81afca3fc4962
Signed-off-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/425063


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 5a028860
Loading
Loading
Loading
Loading
+22 −6
Original line number Diff line number Diff line
@@ -622,8 +622,10 @@ nvme_ctrlr_state_string(enum nvme_ctrlr_state state)
		return "identify controller";
	case NVME_CTRLR_STATE_WAIT_FOR_IDENTIFY:
		return "wait for identify controller";
	case NVME_CTRLR_STATE_SET_NUM_QPAIRS:
	case NVME_CTRLR_STATE_SET_NUM_QUEUES:
		return "set number of queues";
	case NVME_CTRLR_STATE_GET_NUM_QUEUES:
		return "get number of queues";
	case NVME_CTRLR_STATE_CONSTRUCT_NS:
		return "construct namespaces";
	case NVME_CTRLR_STATE_CONFIGURE_AER:
@@ -856,7 +858,7 @@ nvme_ctrlr_identify_done(void *arg, const struct spdk_nvme_cpl *cpl)
		ctrlr->max_sges = nvme_transport_ctrlr_get_max_sges(ctrlr);
	}

	nvme_ctrlr_set_state(ctrlr, NVME_CTRLR_STATE_SET_NUM_QPAIRS, NVME_TIMEOUT_INFINITE);
	nvme_ctrlr_set_state(ctrlr, NVME_CTRLR_STATE_SET_NUM_QUEUES, NVME_TIMEOUT_INFINITE);
}

static int
@@ -949,10 +951,9 @@ fail:
}

static int
nvme_ctrlr_set_num_qpairs(struct spdk_nvme_ctrlr *ctrlr)
nvme_ctrlr_set_num_queues(struct spdk_nvme_ctrlr *ctrlr)
{
	struct nvme_completion_poll_status	status;
	uint32_t cq_allocated, sq_allocated, min_allocated, i;
	int rc;

	if (ctrlr->opts.num_io_queues > SPDK_NVME_MAX_IO_QUEUES) {
@@ -974,6 +975,16 @@ nvme_ctrlr_set_num_qpairs(struct spdk_nvme_ctrlr *ctrlr)
		SPDK_ERRLOG("Set Features - Number of Queues failed!\n");
	}

	return 0;
}

static int
nvme_ctrlr_get_num_queues(struct spdk_nvme_ctrlr *ctrlr)
{
	struct nvme_completion_poll_status	status;
	uint32_t cq_allocated, sq_allocated, min_allocated, i;
	int rc;

	/* Obtain the number of queues allocated using Get Features. */
	rc = nvme_ctrlr_cmd_get_num_queues(ctrlr, nvme_completion_poll_cb, &status);
	if (rc != 0) {
@@ -1778,8 +1789,13 @@ nvme_ctrlr_process_init(struct spdk_nvme_ctrlr *ctrlr)
		spdk_nvme_qpair_process_completions(ctrlr->adminq, 0);
		break;

	case NVME_CTRLR_STATE_SET_NUM_QPAIRS:
		rc = nvme_ctrlr_set_num_qpairs(ctrlr);
	case NVME_CTRLR_STATE_SET_NUM_QUEUES:
		rc = nvme_ctrlr_set_num_queues(ctrlr);
		nvme_ctrlr_set_state(ctrlr, NVME_CTRLR_STATE_GET_NUM_QUEUES, NVME_TIMEOUT_INFINITE);
		break;

	case NVME_CTRLR_STATE_GET_NUM_QUEUES:
		rc = nvme_ctrlr_get_num_queues(ctrlr);
		nvme_ctrlr_set_state(ctrlr, NVME_CTRLR_STATE_CONSTRUCT_NS, NVME_TIMEOUT_INFINITE);
		break;

+7 −2
Original line number Diff line number Diff line
@@ -428,9 +428,14 @@ enum nvme_ctrlr_state {
	NVME_CTRLR_STATE_WAIT_FOR_IDENTIFY,

	/**
	 * Setup Number of Queues of the controller.
	 * Set Number of Queues of the controller.
	 */
	NVME_CTRLR_STATE_SET_NUM_QPAIRS,
	NVME_CTRLR_STATE_SET_NUM_QUEUES,

	/**
	 * Get Number of Queues of the controller.
	 */
	NVME_CTRLR_STATE_GET_NUM_QUEUES,

	/**
	 * Construct Namespaces of the controller.