nvme: add helper function to get payload type
This will simplify upcoming patches that change the way nvme_payload stores its type. Change-Id: Idf0a5b8dfd7d66a10f89254d2c5c54fee2968a43 Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-on: https://review.gerrithub.io/413173 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
cf6ee25359
commit
5c2ccd0628
@ -203,7 +203,7 @@ nvme_user_copy_cmd_complete(void *arg, const struct spdk_nvme_cpl *cpl)
|
||||
|
||||
if (req->user_buffer && req->payload_size) {
|
||||
/* Copy back to the user buffer and free the contig buffer */
|
||||
assert(req->payload.type == NVME_PAYLOAD_TYPE_CONTIG);
|
||||
assert(nvme_payload_type(&req->payload) == NVME_PAYLOAD_TYPE_CONTIG);
|
||||
xfer = spdk_nvme_opc_get_data_transfer(req->cmd.opc);
|
||||
if (xfer == SPDK_NVME_DATA_CONTROLLER_TO_HOST ||
|
||||
xfer == SPDK_NVME_DATA_BIDIRECTIONAL) {
|
||||
|
@ -160,6 +160,11 @@ struct __attribute__((packed)) nvme_payload {
|
||||
uint8_t type;
|
||||
};
|
||||
|
||||
static inline enum nvme_payload_type
|
||||
nvme_payload_type(const struct nvme_payload *payload) {
|
||||
return payload->type;
|
||||
}
|
||||
|
||||
struct nvme_request {
|
||||
struct spdk_nvme_cmd cmd;
|
||||
|
||||
|
@ -482,7 +482,7 @@ _nvme_ns_cmd_rw(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair,
|
||||
cb_fn,
|
||||
cb_arg, opc,
|
||||
io_flags, req, sectors_per_max_io, 0, apptag_mask, apptag);
|
||||
} else if (req->payload.type == NVME_PAYLOAD_TYPE_SGL && check_sgl) {
|
||||
} else if (nvme_payload_type(&req->payload) == NVME_PAYLOAD_TYPE_SGL && check_sgl) {
|
||||
if (ns->ctrlr->flags & SPDK_NVME_CTRLR_SGL_SUPPORTED) {
|
||||
return _nvme_ns_cmd_split_request_sgl(ns, qpair, payload, payload_offset, md_offset,
|
||||
lba, lba_count, cb_fn, cb_arg, opc, io_flags,
|
||||
|
@ -1771,7 +1771,7 @@ nvme_pcie_qpair_build_hw_sgl_request(struct spdk_nvme_qpair *qpair, struct nvme_
|
||||
* Build scattered payloads.
|
||||
*/
|
||||
assert(req->payload_size != 0);
|
||||
assert(req->payload.type == NVME_PAYLOAD_TYPE_SGL);
|
||||
assert(nvme_payload_type(&req->payload) == NVME_PAYLOAD_TYPE_SGL);
|
||||
assert(req->payload.u.sgl.reset_sgl_fn != NULL);
|
||||
assert(req->payload.u.sgl.next_sge_fn != NULL);
|
||||
req->payload.u.sgl.reset_sgl_fn(req->payload.u.sgl.cb_arg, req->payload_offset);
|
||||
@ -1848,7 +1848,7 @@ nvme_pcie_qpair_build_prps_sgl_request(struct spdk_nvme_qpair *qpair, struct nvm
|
||||
/*
|
||||
* Build scattered payloads.
|
||||
*/
|
||||
assert(req->payload.type == NVME_PAYLOAD_TYPE_SGL);
|
||||
assert(nvme_payload_type(&req->payload) == NVME_PAYLOAD_TYPE_SGL);
|
||||
assert(req->payload.u.sgl.reset_sgl_fn != NULL);
|
||||
req->payload.u.sgl.reset_sgl_fn(req->payload.u.sgl.cb_arg, req->payload_offset);
|
||||
|
||||
@ -1945,9 +1945,9 @@ nvme_pcie_qpair_submit_request(struct spdk_nvme_qpair *qpair, struct nvme_reques
|
||||
if (req->payload_size == 0) {
|
||||
/* Null payload - leave PRP fields zeroed */
|
||||
rc = 0;
|
||||
} else if (req->payload.type == NVME_PAYLOAD_TYPE_CONTIG) {
|
||||
} else if (nvme_payload_type(&req->payload) == NVME_PAYLOAD_TYPE_CONTIG) {
|
||||
rc = nvme_pcie_qpair_build_contig_request(qpair, req, tr);
|
||||
} else if (req->payload.type == NVME_PAYLOAD_TYPE_SGL) {
|
||||
} else if (nvme_payload_type(&req->payload) == NVME_PAYLOAD_TYPE_SGL) {
|
||||
if (ctrlr->flags & SPDK_NVME_CTRLR_SGL_SUPPORTED) {
|
||||
rc = nvme_pcie_qpair_build_hw_sgl_request(qpair, req, tr);
|
||||
} else {
|
||||
|
@ -909,7 +909,7 @@ nvme_rdma_build_contig_request(struct nvme_rdma_qpair *rqpair, struct nvme_reque
|
||||
struct ibv_mr *mr;
|
||||
|
||||
assert(req->payload_size != 0);
|
||||
assert(req->payload.type == NVME_PAYLOAD_TYPE_CONTIG);
|
||||
assert(nvme_payload_type(&req->payload) == NVME_PAYLOAD_TYPE_CONTIG);
|
||||
|
||||
mr = (struct ibv_mr *)spdk_mem_map_translate(rqpair->mr_map->map, (uint64_t)payload);
|
||||
if (mr == NULL) {
|
||||
@ -938,7 +938,7 @@ nvme_rdma_build_sgl_request(struct nvme_rdma_qpair *rqpair, struct nvme_request
|
||||
uint32_t length;
|
||||
|
||||
assert(req->payload_size != 0);
|
||||
assert(req->payload.type == NVME_PAYLOAD_TYPE_SGL);
|
||||
assert(nvme_payload_type(&req->payload) == NVME_PAYLOAD_TYPE_SGL);
|
||||
assert(req->payload.u.sgl.reset_sgl_fn != NULL);
|
||||
assert(req->payload.u.sgl.next_sge_fn != NULL);
|
||||
req->payload.u.sgl.reset_sgl_fn(req->payload.u.sgl.cb_arg, req->payload_offset);
|
||||
@ -980,9 +980,9 @@ nvme_rdma_req_init(struct nvme_rdma_qpair *rqpair, struct nvme_request *req,
|
||||
|
||||
if (req->payload_size == 0) {
|
||||
rc = nvme_rdma_build_null_request(req);
|
||||
} else if (req->payload.type == NVME_PAYLOAD_TYPE_CONTIG) {
|
||||
} else if (nvme_payload_type(&req->payload) == NVME_PAYLOAD_TYPE_CONTIG) {
|
||||
rc = nvme_rdma_build_contig_request(rqpair, req);
|
||||
} else if (req->payload.type == NVME_PAYLOAD_TYPE_SGL) {
|
||||
} else if (nvme_payload_type(&req->payload) == NVME_PAYLOAD_TYPE_SGL) {
|
||||
rc = nvme_rdma_build_sgl_request(rqpair, req);
|
||||
} else {
|
||||
rc = -1;
|
||||
|
@ -606,7 +606,7 @@ test_nvme_allocate_request_null(void)
|
||||
CU_ASSERT(req->cb_fn == cb_fn);
|
||||
CU_ASSERT(req->cb_arg == cb_arg);
|
||||
CU_ASSERT(req->pid == getpid());
|
||||
CU_ASSERT(req->payload.type == NVME_PAYLOAD_TYPE_CONTIG);
|
||||
CU_ASSERT(nvme_payload_type(&req->payload) == NVME_PAYLOAD_TYPE_CONTIG);
|
||||
CU_ASSERT(req->payload.md == NULL);
|
||||
CU_ASSERT(req->payload.u.contig == NULL);
|
||||
}
|
||||
|
@ -654,7 +654,7 @@ test_nvme_ns_cmd_readv(void)
|
||||
SPDK_CU_ASSERT_FATAL(rc == 0);
|
||||
SPDK_CU_ASSERT_FATAL(g_request != NULL);
|
||||
CU_ASSERT(g_request->cmd.opc == SPDK_NVME_OPC_READ);
|
||||
CU_ASSERT(g_request->payload.type == NVME_PAYLOAD_TYPE_SGL);
|
||||
CU_ASSERT(nvme_payload_type(&g_request->payload) == NVME_PAYLOAD_TYPE_SGL);
|
||||
CU_ASSERT(g_request->payload.u.sgl.reset_sgl_fn == nvme_request_reset_sgl);
|
||||
CU_ASSERT(g_request->payload.u.sgl.next_sge_fn == nvme_request_next_sge);
|
||||
CU_ASSERT(g_request->payload.u.sgl.cb_arg == &sge_length);
|
||||
@ -689,7 +689,7 @@ test_nvme_ns_cmd_writev(void)
|
||||
SPDK_CU_ASSERT_FATAL(rc == 0);
|
||||
SPDK_CU_ASSERT_FATAL(g_request != NULL);
|
||||
CU_ASSERT(g_request->cmd.opc == SPDK_NVME_OPC_WRITE);
|
||||
CU_ASSERT(g_request->payload.type == NVME_PAYLOAD_TYPE_SGL);
|
||||
CU_ASSERT(nvme_payload_type(&g_request->payload) == NVME_PAYLOAD_TYPE_SGL);
|
||||
CU_ASSERT(g_request->payload.u.sgl.reset_sgl_fn == nvme_request_reset_sgl);
|
||||
CU_ASSERT(g_request->payload.u.sgl.next_sge_fn == nvme_request_next_sge);
|
||||
CU_ASSERT(g_request->payload.u.sgl.cb_arg == &sge_length);
|
||||
@ -724,7 +724,7 @@ test_nvme_ns_cmd_comparev(void)
|
||||
SPDK_CU_ASSERT_FATAL(rc == 0);
|
||||
SPDK_CU_ASSERT_FATAL(g_request != NULL);
|
||||
CU_ASSERT(g_request->cmd.opc == SPDK_NVME_OPC_COMPARE);
|
||||
CU_ASSERT(g_request->payload.type == NVME_PAYLOAD_TYPE_SGL);
|
||||
CU_ASSERT(nvme_payload_type(&g_request->payload) == NVME_PAYLOAD_TYPE_SGL);
|
||||
CU_ASSERT(g_request->payload.u.sgl.reset_sgl_fn == nvme_request_reset_sgl);
|
||||
CU_ASSERT(g_request->payload.u.sgl.next_sge_fn == nvme_request_next_sge);
|
||||
CU_ASSERT(g_request->payload.u.sgl.cb_arg == &sge_length);
|
||||
|
Loading…
x
Reference in New Issue
Block a user