Commit d13d21e6 authored by Daniel Verkamp's avatar Daniel Verkamp
Browse files

nvmf: remove spdk_nvmf_qpair::type field



The type of a queue is purely a function of its queue ID.

Add a helper function, spdk_nvmf_qpair_is_admin_queue(), to make the
logic more obvious (akin to nvme_qpair_is_admin_queue() in the NVMe
library).

Change-Id: I7cf5a82d1e3dc50834cc2ff03f5f88c5719c6952
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/398663


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
parent dfa9aea4
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -240,8 +240,6 @@ spdk_nvmf_ctrlr_connect(struct spdk_nvmf_request *req)
	qpair->qid = cmd->qid;

	if (cmd->qid == 0) {
		qpair->type = QPAIR_TYPE_AQ;

		SPDK_DEBUGLOG(SPDK_LOG_NVMF, "Connect Admin Queue for controller ID 0x%x\n", data->cntlid);

		if (data->cntlid != 0xFFFF) {
@@ -259,7 +257,6 @@ spdk_nvmf_ctrlr_connect(struct spdk_nvmf_request *req)
			return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
		}
	} else {
		qpair->type = QPAIR_TYPE_IOQ;
		SPDK_DEBUGLOG(SPDK_LOG_NVMF, "Connect I/O Queue for controller id 0x%x\n", data->cntlid);

		ctrlr = spdk_nvmf_subsystem_get_ctrlr(subsystem, data->cntlid);
@@ -1169,7 +1166,7 @@ spdk_nvmf_ctrlr_process_fabrics_cmd(struct spdk_nvmf_request *req)
			req->rsp->nvme_cpl.status.sc = SPDK_NVME_SC_COMMAND_SEQUENCE_ERROR;
			return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
		}
	} else if (qpair->type == QPAIR_TYPE_AQ) {
	} else if (spdk_nvmf_qpair_is_admin_queue(qpair)) {
		/*
		 * Controller session is established, and this is an admin queue.
		 * Disallow Connect and allow other fabrics commands.
+6 −6
Original line number Diff line number Diff line
@@ -141,16 +141,10 @@ struct spdk_nvmf_ns {
	bool allocated;
};

enum spdk_nvmf_qpair_type {
	QPAIR_TYPE_AQ = 0,
	QPAIR_TYPE_IOQ = 1,
};

struct spdk_nvmf_qpair {
	struct spdk_nvmf_transport		*transport;
	struct spdk_nvmf_ctrlr			*ctrlr;
	struct spdk_nvmf_poll_group		*group;
	enum spdk_nvmf_qpair_type		type;

	uint16_t				qid;
	uint16_t				sq_head;
@@ -268,6 +262,12 @@ _spdk_nvmf_subsystem_get_ns(struct spdk_nvmf_subsystem *subsystem, uint32_t nsid
	return ns;
}

static inline bool
spdk_nvmf_qpair_is_admin_queue(struct spdk_nvmf_qpair *qpair)
{
	return qpair->qid == 0;
}

#define OBJECT_NVMF_IO				0x30

#define TRACE_GROUP_NVMF			0x3
+5 −5
Original line number Diff line number Diff line
@@ -67,7 +67,7 @@ spdk_nvmf_request_complete(struct spdk_nvmf_request *req)
}

static void
nvmf_trace_command(union nvmf_h2c_msg *h2c_msg, enum spdk_nvmf_qpair_type qpair_type)
nvmf_trace_command(union nvmf_h2c_msg *h2c_msg, bool is_admin_queue)
{
	struct spdk_nvmf_capsule_cmd *cap_hdr = &h2c_msg->nvmf_cmd;
	struct spdk_nvme_cmd *cmd = &h2c_msg->nvme_cmd;
@@ -77,12 +77,12 @@ nvmf_trace_command(union nvmf_h2c_msg *h2c_msg, enum spdk_nvmf_qpair_type qpair_
	if (cmd->opc == SPDK_NVME_OPC_FABRIC) {
		opc = cap_hdr->fctype;
		SPDK_DEBUGLOG(SPDK_LOG_NVMF, "%s Fabrics cmd: fctype 0x%02x cid %u\n",
			      qpair_type == QPAIR_TYPE_AQ ? "Admin" : "I/O",
			      is_admin_queue ? "Admin" : "I/O",
			      cap_hdr->fctype, cap_hdr->cid);
	} else {
		opc = cmd->opc;
		SPDK_DEBUGLOG(SPDK_LOG_NVMF, "%s cmd: opc 0x%02x fuse %u cid %u nsid %u cdw10 0x%08x\n",
			      qpair_type == QPAIR_TYPE_AQ ? "Admin" : "I/O",
			      is_admin_queue ? "Admin" : "I/O",
			      cmd->opc, cmd->fuse, cmd->cid, cmd->nsid, cmd->cdw10);
		if (cmd->mptr) {
			SPDK_DEBUGLOG(SPDK_LOG_NVMF, "mptr 0x%" PRIx64 "\n", cmd->mptr);
@@ -116,7 +116,7 @@ spdk_nvmf_request_exec(struct spdk_nvmf_request *req)
	struct spdk_nvmf_qpair *qpair = req->qpair;
	spdk_nvmf_request_exec_status status;

	nvmf_trace_command(req->cmd, qpair->type);
	nvmf_trace_command(req->cmd, spdk_nvmf_qpair_is_admin_queue(qpair));

	/* Check if the subsystem is paused (if there is a subsystem) */
	if (qpair->ctrlr) {
@@ -133,7 +133,7 @@ spdk_nvmf_request_exec(struct spdk_nvmf_request *req)

	if (spdk_unlikely(req->cmd->nvmf_cmd.opcode == SPDK_NVME_OPC_FABRIC)) {
		status = spdk_nvmf_ctrlr_process_fabrics_cmd(req);
	} else if (spdk_unlikely(qpair->type == QPAIR_TYPE_AQ)) {
	} else if (spdk_unlikely(spdk_nvmf_qpair_is_admin_queue(qpair))) {
		status = spdk_nvmf_ctrlr_process_admin_cmd(req);
	} else {
		status = spdk_nvmf_ctrlr_process_io_cmd(req);