Commit 03aead39 authored by Daniel Verkamp's avatar Daniel Verkamp
Browse files

nvme: add qpair operations to transport



Change-Id: Id354ba13515d54bb54a8293569ee83ea72111183
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent 706bace3
Loading
Loading
Loading
Loading
+2 −11
Original line number Diff line number Diff line
@@ -335,7 +335,6 @@ nvme_ctrlr_construct_admin_qpair(struct spdk_nvme_ctrlr *ctrlr)
	return nvme_qpair_construct(&ctrlr->adminq,
				    0, /* qpair ID */
				    NVME_ADMIN_ENTRIES,
				    NVME_ADMIN_TRACKERS,
				    ctrlr);
}

@@ -344,7 +343,7 @@ nvme_ctrlr_construct_io_qpairs(struct spdk_nvme_ctrlr *ctrlr)
{
	struct spdk_nvme_qpair		*qpair;
	union spdk_nvme_cap_register	cap;
	uint32_t			i, num_entries, num_trackers;
	uint32_t			i, num_entries;
	int				rc;
	uint64_t			phys_addr = 0;

@@ -370,13 +369,6 @@ nvme_ctrlr_construct_io_qpairs(struct spdk_nvme_ctrlr *ctrlr)
	 */
	num_entries = nvme_min(NVME_IO_ENTRIES, cap.bits.mqes + 1);

	/*
	 * No need to have more trackers than entries in the submit queue.
	 *  Note also that for a queue size of N, we can only have (N-1)
	 *  commands outstanding, hence the "-1" here.
	 */
	num_trackers = nvme_min(NVME_IO_TRACKERS, (num_entries - 1));

	ctrlr->ioq = spdk_zmalloc(ctrlr->opts.num_io_queues * sizeof(struct spdk_nvme_qpair),
				  64, &phys_addr);

@@ -393,7 +385,6 @@ nvme_ctrlr_construct_io_qpairs(struct spdk_nvme_ctrlr *ctrlr)
		rc = nvme_qpair_construct(qpair,
					  i + 1, /* qpair ID */
					  num_entries,
					  num_trackers,
					  ctrlr);
		if (rc)
			return -1;
@@ -969,7 +960,7 @@ nvme_ctrlr_process_init(struct spdk_nvme_ctrlr *ctrlr)
int
nvme_ctrlr_start(struct spdk_nvme_ctrlr *ctrlr)
{
	nvme_qpair_reset(&ctrlr->adminq);
	ctrlr->transport->qpair_reset(&ctrlr->adminq);

	nvme_qpair_enable(&ctrlr->adminq);

+28 −2
Original line number Diff line number Diff line
@@ -259,6 +259,18 @@ struct spdk_nvme_transport {

	int (*ctrlr_create_io_qpair)(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_qpair *qpair);
	int (*ctrlr_delete_io_qpair)(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_qpair *qpair);

	int (*qpair_construct)(struct spdk_nvme_qpair *qpair);
	void (*qpair_destroy)(struct spdk_nvme_qpair *qpair);

	void (*qpair_enable)(struct spdk_nvme_qpair *qpair);
	void (*qpair_disable)(struct spdk_nvme_qpair *qpair);

	void (*qpair_reset)(struct spdk_nvme_qpair *qpair);
	void (*qpair_fail)(struct spdk_nvme_qpair *qpair);

	int (*qpair_submit_request)(struct spdk_nvme_qpair *qpair, struct nvme_request *req);
	int32_t (*qpair_process_completions)(struct spdk_nvme_qpair *qpair, uint32_t max_completions);
};

struct nvme_completion_poll_status {
@@ -521,6 +533,18 @@ nvme_align32pow2(uint32_t x)
	return 1u << (1 + nvme_u32log2(x - 1));
}

static inline bool
nvme_qpair_is_admin_queue(struct spdk_nvme_qpair *qpair)
{
	return qpair->id == 0;
}

static inline bool
nvme_qpair_is_io_queue(struct spdk_nvme_qpair *qpair)
{
	return qpair->id != 0;
}

/* Admin functions */
int	nvme_ctrlr_cmd_identify_controller(struct spdk_nvme_ctrlr *ctrlr,
		void *payload,
@@ -575,14 +599,12 @@ int nvme_ctrlr_alloc_cmb(struct spdk_nvme_ctrlr *ctrlr, uint64_t length, uint64_
			     uint64_t *offset);
int	nvme_qpair_construct(struct spdk_nvme_qpair *qpair, uint16_t id,
			     uint16_t num_entries,
			     uint16_t num_trackers,
			     struct spdk_nvme_ctrlr *ctrlr);
void	nvme_qpair_destroy(struct spdk_nvme_qpair *qpair);
void	nvme_qpair_enable(struct spdk_nvme_qpair *qpair);
void	nvme_qpair_disable(struct spdk_nvme_qpair *qpair);
int	nvme_qpair_submit_request(struct spdk_nvme_qpair *qpair,
				  struct nvme_request *req);
void	nvme_qpair_reset(struct spdk_nvme_qpair *qpair);
void	nvme_qpair_fail(struct spdk_nvme_qpair *qpair);

int	nvme_ns_construct(struct spdk_nvme_ns *ns, uint16_t id,
@@ -604,4 +626,8 @@ void spdk_nvme_ctrlr_opts_set_defaults(struct spdk_nvme_ctrlr_opts *opts);

int	nvme_mutex_init_shared(pthread_mutex_t *mtx);

bool	nvme_completion_is_retry(const struct spdk_nvme_cpl *cpl);
void	nvme_qpair_print_command(struct spdk_nvme_qpair *qpair, struct spdk_nvme_cmd *cmd);
void	nvme_qpair_print_completion(struct spdk_nvme_qpair *qpair, struct spdk_nvme_cpl *cpl);

#endif /* __NVME_INTERNAL_H__ */
+715 −1

File changed.

Preview size limit exceeded, changes collapsed.

+17 −659

File changed.

Preview size limit exceeded, changes collapsed.

+8 −6
Original line number Diff line number Diff line
@@ -152,6 +152,11 @@ ut_ctrlr_delete_io_qpair(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_qpair *
	return 0;
}

static void
ut_qpair_reset(struct spdk_nvme_qpair *qpair)
{
}

static const struct spdk_nvme_transport nvme_ctrlr_ut_transport = {
	.ctrlr_get_pci_id = ut_ctrlr_get_pci_id,

@@ -163,6 +168,8 @@ static const struct spdk_nvme_transport nvme_ctrlr_ut_transport = {

	.ctrlr_create_io_qpair = ut_ctrlr_create_io_qpair,
	.ctrlr_delete_io_qpair = ut_ctrlr_delete_io_qpair,

	.qpair_reset = ut_qpair_reset,
};

uint16_t
@@ -196,7 +203,7 @@ spdk_pci_device_compare_addr(struct spdk_pci_device *dev, struct spdk_pci_addr *
}

int nvme_qpair_construct(struct spdk_nvme_qpair *qpair, uint16_t id,
			 uint16_t num_entries, uint16_t num_trackers,
			 uint16_t num_entries,
			 struct spdk_nvme_ctrlr *ctrlr)
{
	qpair->id = id;
@@ -265,11 +272,6 @@ nvme_qpair_enable(struct spdk_nvme_qpair *qpair)
{
}

void
nvme_qpair_reset(struct spdk_nvme_qpair *qpair)
{
}

void
nvme_completion_poll_cb(void *arg, const struct spdk_nvme_cpl *cpl)
{
Loading