nvme/rdma: Simplify nvme_rdma_req_init

Cache payload type and in-capsule data transfer support

Change-Id: Id40a6e86d1f29235ca3e0189d7fbcf19baa30ffe
Signed-off-by: Alexey Marchuk <alexeymar@mellanox.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1461
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Alexey Marchuk 2020-03-25 12:12:07 +03:00 committed by Tomasz Zawadzki
parent d713b99c3a
commit d2510a56f3

View File

@ -1560,31 +1560,32 @@ nvme_rdma_req_init(struct nvme_rdma_qpair *rqpair, struct nvme_request *req,
struct spdk_nvme_rdma_req *rdma_req)
{
struct spdk_nvme_ctrlr *ctrlr = rqpair->qpair.ctrlr;
enum nvme_payload_type payload_type;
bool icd_supported;
int rc;
rdma_req->req = req;
req->cmd.cid = rdma_req->id;
if (req->payload_size == 0) {
rc = nvme_rdma_build_null_request(rdma_req);
} else if (nvme_payload_type(&req->payload) == NVME_PAYLOAD_TYPE_CONTIG) {
payload_type = nvme_payload_type(&req->payload);
/*
* Check if icdoff is non zero, to avoid interop conflicts with
* targets with non-zero icdoff. Both SPDK and the Linux kernel
* targets use icdoff = 0. For targets with non-zero icdoff, we
* will currently just not use inline data for now.
*/
if (spdk_nvme_opc_get_data_transfer(req->cmd.opc) ==
SPDK_NVME_DATA_HOST_TO_CONTROLLER &&
req->payload_size <= ctrlr->ioccsz_bytes && ctrlr->icdoff == 0) {
icd_supported = spdk_nvme_opc_get_data_transfer(req->cmd.opc) == SPDK_NVME_DATA_HOST_TO_CONTROLLER
&& req->payload_size <= ctrlr->ioccsz_bytes && ctrlr->icdoff == 0;
if (req->payload_size == 0) {
rc = nvme_rdma_build_null_request(rdma_req);
} else if (payload_type == NVME_PAYLOAD_TYPE_CONTIG) {
if (icd_supported) {
rc = nvme_rdma_build_contig_inline_request(rqpair, rdma_req);
} else {
rc = nvme_rdma_build_contig_request(rqpair, rdma_req);
}
} else if (nvme_payload_type(&req->payload) == NVME_PAYLOAD_TYPE_SGL) {
if (spdk_nvme_opc_get_data_transfer(req->cmd.opc) ==
SPDK_NVME_DATA_HOST_TO_CONTROLLER &&
req->payload_size <= ctrlr->ioccsz_bytes && ctrlr->icdoff == 0) {
} else if (payload_type == NVME_PAYLOAD_TYPE_SGL) {
if (icd_supported) {
rc = nvme_rdma_build_sgl_inline_request(rqpair, rdma_req);
} else {
rc = nvme_rdma_build_sgl_request(rqpair, rdma_req);