nvme/tcp: Factor out operation to append multiple SGL entries
Such small refactoring will be helpful to add DIF insert/strip feature, and is done in this patch. Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Change-Id: I4b16a041d176acef948d2af1a5a1811380287738 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/458527 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
This commit is contained in:
parent
b2982b7d44
commit
ade7d070f2
@ -247,12 +247,26 @@ _nvme_tcp_sgl_append(struct _nvme_tcp_sgl *s, uint8_t *data, uint32_t data_len)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool
|
||||||
|
_nvme_tcp_sgl_append_multi(struct _nvme_tcp_sgl *s, struct iovec *iov, int iovcnt)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < iovcnt; i++) {
|
||||||
|
if (!_nvme_tcp_sgl_append(s, iov[i].iov_base, iov[i].iov_len)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
nvme_tcp_build_iovs(struct iovec *iov, int iovcnt, struct nvme_tcp_pdu *pdu,
|
nvme_tcp_build_iovs(struct iovec *iov, int iovcnt, struct nvme_tcp_pdu *pdu,
|
||||||
bool hdgst_enable, bool ddgst_enable, uint32_t *_mapped_length)
|
bool hdgst_enable, bool ddgst_enable, uint32_t *_mapped_length)
|
||||||
{
|
{
|
||||||
int enable_digest;
|
int enable_digest;
|
||||||
uint32_t hlen, plen, i;
|
uint32_t hlen, plen;
|
||||||
struct _nvme_tcp_sgl *sgl;
|
struct _nvme_tcp_sgl *sgl;
|
||||||
|
|
||||||
if (iovcnt == 0) {
|
if (iovcnt == 0) {
|
||||||
@ -295,10 +309,8 @@ nvme_tcp_build_iovs(struct iovec *iov, int iovcnt, struct nvme_tcp_pdu *pdu,
|
|||||||
|
|
||||||
/* Data Segment */
|
/* Data Segment */
|
||||||
plen += pdu->data_len;
|
plen += pdu->data_len;
|
||||||
for (i = 0; i < pdu->data_iovcnt; i++) {
|
if (!_nvme_tcp_sgl_append_multi(sgl, pdu->data_iov, pdu->data_iovcnt)) {
|
||||||
if (!_nvme_tcp_sgl_append(sgl, pdu->data_iov[i].iov_base, pdu->data_iov[i].iov_len)) {
|
goto end;
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Data Digest */
|
/* Data Digest */
|
||||||
@ -325,7 +337,6 @@ nvme_tcp_build_payload_iovs(struct iovec *iov, int iovcnt, struct nvme_tcp_pdu *
|
|||||||
bool ddgst_enable, uint32_t *_mapped_length)
|
bool ddgst_enable, uint32_t *_mapped_length)
|
||||||
{
|
{
|
||||||
struct _nvme_tcp_sgl *sgl;
|
struct _nvme_tcp_sgl *sgl;
|
||||||
uint32_t i;
|
|
||||||
|
|
||||||
if (iovcnt == 0) {
|
if (iovcnt == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -334,10 +345,8 @@ nvme_tcp_build_payload_iovs(struct iovec *iov, int iovcnt, struct nvme_tcp_pdu *
|
|||||||
sgl = &pdu->sgl;
|
sgl = &pdu->sgl;
|
||||||
_nvme_tcp_sgl_init(sgl, iov, iovcnt, pdu->readv_offset);
|
_nvme_tcp_sgl_init(sgl, iov, iovcnt, pdu->readv_offset);
|
||||||
|
|
||||||
for (i = 0; i < pdu->data_iovcnt; i++) {
|
if (!_nvme_tcp_sgl_append_multi(sgl, pdu->data_iov, pdu->data_iovcnt)) {
|
||||||
if (!_nvme_tcp_sgl_append(sgl, pdu->data_iov[i].iov_base, pdu->data_iov[i].iov_len)) {
|
goto end;
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Data Digest */
|
/* Data Digest */
|
||||||
|
Loading…
Reference in New Issue
Block a user