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:
parent
f089b07af4
commit
9315f02254
@ -74,11 +74,10 @@
|
|||||||
typedef void (*nvme_tcp_qpair_xfer_complete_cb)(void *cb_arg);
|
typedef void (*nvme_tcp_qpair_xfer_complete_cb)(void *cb_arg);
|
||||||
|
|
||||||
struct _iov_ctx {
|
struct _iov_ctx {
|
||||||
struct iovec *iov;
|
struct iovec *iov;
|
||||||
int num_iovs;
|
int iovcnt;
|
||||||
uint32_t iov_offset;
|
uint32_t iov_offset;
|
||||||
int iovcnt;
|
uint32_t mapped_len;
|
||||||
uint32_t mapped_len;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct nvme_tcp_pdu {
|
struct nvme_tcp_pdu {
|
||||||
@ -192,13 +191,12 @@ nvme_tcp_pdu_calc_data_digest(struct nvme_tcp_pdu *pdu)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
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)
|
uint32_t iov_offset)
|
||||||
{
|
{
|
||||||
ctx->iov = iovs;
|
ctx->iov = iov;
|
||||||
ctx->num_iovs = num_iovs;
|
ctx->iovcnt = iovcnt;
|
||||||
ctx->iov_offset = iov_offset;
|
ctx->iov_offset = iov_offset;
|
||||||
ctx->iovcnt = 0;
|
|
||||||
ctx->mapped_len = 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) {
|
if (ctx->iov_offset >= data_len) {
|
||||||
ctx->iov_offset -= data_len;
|
ctx->iov_offset -= data_len;
|
||||||
} else {
|
} else {
|
||||||
|
assert(ctx->iovcnt > 0);
|
||||||
ctx->iov->iov_base = data + ctx->iov_offset;
|
ctx->iov->iov_base = data + ctx->iov_offset;
|
||||||
ctx->iov->iov_len = data_len - ctx->iov_offset;
|
ctx->iov->iov_len = data_len - ctx->iov_offset;
|
||||||
ctx->mapped_len += data_len - ctx->iov_offset;
|
ctx->mapped_len += data_len - ctx->iov_offset;
|
||||||
ctx->iov_offset = 0;
|
ctx->iov_offset = 0;
|
||||||
ctx->iov++;
|
ctx->iov++;
|
||||||
ctx->iovcnt++;
|
ctx->iovcnt--;
|
||||||
if (ctx->iovcnt == ctx->num_iovs) {
|
if (ctx->iovcnt == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -292,7 +291,7 @@ end:
|
|||||||
assert(plen == pdu->hdr.common.plen);
|
assert(plen == pdu->hdr.common.plen);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ctx->iovcnt;
|
return num_iovs - ctx->iovcnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -324,7 +323,7 @@ end:
|
|||||||
if (_mapped_length != NULL) {
|
if (_mapped_length != NULL) {
|
||||||
*_mapped_length = ctx->mapped_len;
|
*_mapped_length = ctx->mapped_len;
|
||||||
}
|
}
|
||||||
return ctx->iovcnt;
|
return num_iovs - ctx->iovcnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -635,7 +635,7 @@ nvme_tcp_pdu_set_data_buf(struct nvme_tcp_pdu *pdu,
|
|||||||
}
|
}
|
||||||
|
|
||||||
assert(remain_len == 0);
|
assert(remain_len == 0);
|
||||||
pdu->data_iovcnt = ctx->iovcnt;
|
pdu->data_iovcnt = tcp_req->iovcnt - ctx->iovcnt;
|
||||||
pdu->data_len = data_len;
|
pdu->data_len = data_len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user