nvme/tcp: Unify array size and used count in SGL operation

Recently DIF library refined SGL create operation by unifying
size and used count into unused count. This patch applies the
good practice in DIF library to create SGL in NVMe/TCP.

The next patch refines names of related function and variables
to be consistent in NVMe/TCP.

Change-Id: I1e73310c0e3650ede53672d76071a6c37dba82c1
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/455473
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Shuhei Matsumoto 2019-05-21 14:36:24 +09:00 committed by Jim Harris
parent f089b07af4
commit 9315f02254
2 changed files with 13 additions and 14 deletions

View File

@ -75,9 +75,8 @@ typedef void (*nvme_tcp_qpair_xfer_complete_cb)(void *cb_arg);
struct _iov_ctx {
struct iovec *iov;
int num_iovs;
uint32_t iov_offset;
int iovcnt;
uint32_t iov_offset;
uint32_t mapped_len;
};
@ -192,13 +191,12 @@ nvme_tcp_pdu_calc_data_digest(struct nvme_tcp_pdu *pdu)
}
static inline void
_iov_ctx_init(struct _iov_ctx *ctx, struct iovec *iovs, int num_iovs,
_iov_ctx_init(struct _iov_ctx *ctx, struct iovec *iov, int iovcnt,
uint32_t iov_offset)
{
ctx->iov = iovs;
ctx->num_iovs = num_iovs;
ctx->iov = iov;
ctx->iovcnt = iovcnt;
ctx->iov_offset = iov_offset;
ctx->iovcnt = 0;
ctx->mapped_len = 0;
}
@ -208,13 +206,14 @@ _iov_ctx_set_iov(struct _iov_ctx *ctx, uint8_t *data, uint32_t data_len)
if (ctx->iov_offset >= data_len) {
ctx->iov_offset -= data_len;
} else {
assert(ctx->iovcnt > 0);
ctx->iov->iov_base = data + ctx->iov_offset;
ctx->iov->iov_len = data_len - ctx->iov_offset;
ctx->mapped_len += data_len - ctx->iov_offset;
ctx->iov_offset = 0;
ctx->iov++;
ctx->iovcnt++;
if (ctx->iovcnt == ctx->num_iovs) {
ctx->iovcnt--;
if (ctx->iovcnt == 0) {
return false;
}
}
@ -292,7 +291,7 @@ end:
assert(plen == pdu->hdr.common.plen);
}
return ctx->iovcnt;
return num_iovs - ctx->iovcnt;
}
static int
@ -324,7 +323,7 @@ end:
if (_mapped_length != NULL) {
*_mapped_length = ctx->mapped_len;
}
return ctx->iovcnt;
return num_iovs - ctx->iovcnt;
}
static int

View File

@ -635,7 +635,7 @@ nvme_tcp_pdu_set_data_buf(struct nvme_tcp_pdu *pdu,
}
assert(remain_len == 0);
pdu->data_iovcnt = ctx->iovcnt;
pdu->data_iovcnt = tcp_req->iovcnt - ctx->iovcnt;
pdu->data_len = data_len;
}
}