dif: Add an API to update data offset of DIF context
To process unaligned data segment properly when a whole data buffer is splitted into multiple data segments and each data segment has any alignment, we have to update only data offset of DIF context according to the progress. Hence this patch adds an new API spdk_dif_ctx_set_data_offset(). The API will be used in the next patch. Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Change-Id: I346ab583518b80792ea40d34cf0c8536ecc3d904 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/458141 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
5ef24d5256
commit
2819718176
@ -74,6 +74,9 @@ struct spdk_dif_ctx {
|
||||
/** Metadata size */
|
||||
uint32_t md_size;
|
||||
|
||||
/** Metadata location */
|
||||
bool md_interleave;
|
||||
|
||||
/** Interval for guard computation for DIF */
|
||||
uint32_t guard_interval;
|
||||
|
||||
@ -150,6 +153,14 @@ int spdk_dif_ctx_init(struct spdk_dif_ctx *ctx, uint32_t block_size, uint32_t md
|
||||
uint32_t init_ref_tag, uint16_t apptag_mask, uint16_t app_tag,
|
||||
uint32_t data_offset, uint16_t guard_seed);
|
||||
|
||||
/**
|
||||
* Update date offset of DIF context.
|
||||
*
|
||||
* \param ctx DIF context.
|
||||
* \param data_offset Byte offset from the start of the whole data buffer.
|
||||
*/
|
||||
void spdk_dif_ctx_set_data_offset(struct spdk_dif_ctx *ctx, uint32_t data_offset);
|
||||
|
||||
/**
|
||||
* Generate DIF for extended LBA payload.
|
||||
*
|
||||
|
@ -250,6 +250,7 @@ spdk_dif_ctx_init(struct spdk_dif_ctx *ctx, uint32_t block_size, uint32_t md_siz
|
||||
|
||||
ctx->block_size = block_size;
|
||||
ctx->md_size = md_size;
|
||||
ctx->md_interleave = md_interleave;
|
||||
ctx->guard_interval = _get_guard_interval(block_size, md_size, dif_loc, md_interleave);
|
||||
ctx->dif_type = dif_type;
|
||||
ctx->dif_flags = dif_flags;
|
||||
@ -264,6 +265,21 @@ spdk_dif_ctx_init(struct spdk_dif_ctx *ctx, uint32_t block_size, uint32_t md_siz
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
spdk_dif_ctx_set_data_offset(struct spdk_dif_ctx *ctx, uint32_t data_offset)
|
||||
{
|
||||
uint32_t data_block_size;
|
||||
|
||||
if (ctx->md_interleave) {
|
||||
data_block_size = ctx->block_size - ctx->md_size;
|
||||
} else {
|
||||
data_block_size = ctx->block_size;
|
||||
}
|
||||
|
||||
ctx->data_offset = data_offset;
|
||||
ctx->ref_tag_offset = data_offset / data_block_size;
|
||||
}
|
||||
|
||||
static void
|
||||
_dif_generate(void *_dif, uint16_t guard, uint32_t offset_blocks,
|
||||
const struct spdk_dif_ctx *ctx)
|
||||
|
Loading…
Reference in New Issue
Block a user