dif: Merge single and multiple iovec cases of spdk_dif_generate_stream
As same as spdk_dif_set_md_interleave_iovs, no noticeable performance difference was observed even if dif_generate_stream and dif_generate_stream_split are merged into the latter. spdk_dif_generate_stream will be updated in subsequent patches anyway. Hence merge them into dif_generate_stream_split. Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Change-Id: I77b588527bc7533dc38a36e450972758ce57d6bb Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/457760 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
This commit is contained in:
parent
759a700f2a
commit
df2164f6f4
@ -1438,49 +1438,18 @@ end:
|
||||
return iovcnt - dif_sgl.iovcnt;
|
||||
}
|
||||
|
||||
static int
|
||||
dif_generate_stream(uint8_t *buf, uint32_t buf_len,
|
||||
uint32_t data_offset, uint32_t data_len,
|
||||
const struct spdk_dif_ctx *ctx)
|
||||
{
|
||||
uint32_t data_block_size, offset_blocks, num_blocks, i;
|
||||
uint16_t guard = 0;
|
||||
|
||||
data_block_size = ctx->block_size - ctx->md_size;
|
||||
|
||||
offset_blocks = data_offset / data_block_size;
|
||||
data_len += data_offset % data_block_size;
|
||||
|
||||
data_offset = offset_blocks * ctx->block_size;
|
||||
num_blocks = data_len / data_block_size;
|
||||
|
||||
if (data_offset + num_blocks * ctx->block_size > buf_len) {
|
||||
return -ERANGE;
|
||||
}
|
||||
|
||||
buf += data_offset;
|
||||
|
||||
for (i = 0; i < num_blocks; i++) {
|
||||
if (ctx->dif_flags & SPDK_DIF_FLAGS_GUARD_CHECK) {
|
||||
guard = spdk_crc16_t10dif(ctx->guard_seed, buf, ctx->guard_interval);
|
||||
}
|
||||
|
||||
_dif_generate(buf + ctx->guard_interval, guard, offset_blocks + i, ctx);
|
||||
|
||||
buf += ctx->block_size;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
dif_generate_stream_split(struct iovec *iovs, int iovcnt,
|
||||
int
|
||||
spdk_dif_generate_stream(struct iovec *iovs, int iovcnt,
|
||||
uint32_t data_offset, uint32_t data_len,
|
||||
const struct spdk_dif_ctx *ctx)
|
||||
{
|
||||
uint32_t data_block_size, offset_blocks, num_blocks, i;
|
||||
struct _dif_sgl sgl;
|
||||
|
||||
if (iovs == NULL || iovcnt == 0) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
data_block_size = ctx->block_size - ctx->md_size;
|
||||
|
||||
offset_blocks = data_offset / data_block_size;
|
||||
@ -1503,20 +1472,3 @@ dif_generate_stream_split(struct iovec *iovs, int iovcnt,
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
spdk_dif_generate_stream(struct iovec *iovs, int iovcnt,
|
||||
uint32_t data_offset, uint32_t data_len,
|
||||
const struct spdk_dif_ctx *ctx)
|
||||
{
|
||||
if (iovs == NULL || iovcnt == 0) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (iovcnt == 1) {
|
||||
return dif_generate_stream(iovs[0].iov_base, iovs[0].iov_len,
|
||||
data_offset, data_len, ctx);
|
||||
} else {
|
||||
return dif_generate_stream_split(iovs, iovcnt, data_offset, data_len, ctx);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user