diff --git a/lib/util/dif.c b/lib/util/dif.c index 239950006..5ea276a9f 100644 --- a/lib/util/dif.c +++ b/lib/util/dif.c @@ -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, - uint32_t data_offset, uint32_t data_len, - const struct spdk_dif_ctx *ctx) +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); - } -}