2018-11-27 05:23:38 +00:00
|
|
|
/*-
|
|
|
|
* BSD LICENSE
|
|
|
|
*
|
|
|
|
* Copyright (c) Intel Corporation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* * Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
* * Neither the name of Intel Corporation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SPDK_DIF_H
|
|
|
|
#define SPDK_DIF_H
|
|
|
|
|
|
|
|
#include "spdk/stdinc.h"
|
|
|
|
#include "spdk/assert.h"
|
|
|
|
|
2019-02-04 23:54:15 +00:00
|
|
|
#define SPDK_DIF_FLAGS_REFTAG_CHECK (1U << 26)
|
|
|
|
#define SPDK_DIF_FLAGS_APPTAG_CHECK (1U << 27)
|
|
|
|
#define SPDK_DIF_FLAGS_GUARD_CHECK (1U << 28)
|
2018-11-27 05:23:38 +00:00
|
|
|
|
2018-12-18 01:51:22 +00:00
|
|
|
#define SPDK_DIF_REFTAG_ERROR 0x1
|
|
|
|
#define SPDK_DIF_APPTAG_ERROR 0x2
|
|
|
|
#define SPDK_DIF_GUARD_ERROR 0x4
|
|
|
|
#define SPDK_DIF_DATA_ERROR 0x8
|
|
|
|
|
2018-11-27 05:23:38 +00:00
|
|
|
enum spdk_dif_type {
|
2018-12-27 22:57:26 +00:00
|
|
|
SPDK_DIF_DISABLE = 0,
|
2018-11-27 05:23:38 +00:00
|
|
|
SPDK_DIF_TYPE1 = 1,
|
2018-12-27 22:57:26 +00:00
|
|
|
SPDK_DIF_TYPE2 = 2,
|
|
|
|
SPDK_DIF_TYPE3 = 3,
|
2018-11-27 05:23:38 +00:00
|
|
|
};
|
|
|
|
|
2019-02-07 08:41:06 +00:00
|
|
|
enum spdk_dif_check_type {
|
|
|
|
SPDK_DIF_CHECK_TYPE_REFTAG = 1,
|
|
|
|
SPDK_DIF_CHECK_TYPE_APPTAG = 2,
|
|
|
|
SPDK_DIF_CHECK_TYPE_GUARD = 3,
|
|
|
|
};
|
|
|
|
|
2018-11-27 05:23:38 +00:00
|
|
|
struct spdk_dif {
|
|
|
|
uint16_t guard;
|
|
|
|
uint16_t app_tag;
|
|
|
|
uint32_t ref_tag;
|
|
|
|
};
|
|
|
|
SPDK_STATIC_ASSERT(sizeof(struct spdk_dif) == 8, "Incorrect size");
|
|
|
|
|
2019-01-07 00:20:35 +00:00
|
|
|
/** DIF context information */
|
|
|
|
struct spdk_dif_ctx {
|
|
|
|
/** Block size */
|
|
|
|
uint32_t block_size;
|
|
|
|
|
|
|
|
/** Metadata size */
|
|
|
|
uint32_t md_size;
|
|
|
|
|
2019-06-15 00:09:05 +00:00
|
|
|
/** Metadata location */
|
|
|
|
bool md_interleave;
|
|
|
|
|
2019-01-08 23:07:08 +00:00
|
|
|
/** Interval for guard computation for DIF */
|
2019-01-07 00:20:35 +00:00
|
|
|
uint32_t guard_interval;
|
|
|
|
|
|
|
|
/** DIF type */
|
|
|
|
enum spdk_dif_type dif_type;
|
|
|
|
|
|
|
|
/* Flags to specify the DIF action */
|
|
|
|
uint32_t dif_flags;
|
|
|
|
|
|
|
|
/* Initial reference tag */
|
|
|
|
uint32_t init_ref_tag;
|
|
|
|
|
|
|
|
/** Application tag */
|
|
|
|
uint16_t app_tag;
|
|
|
|
|
|
|
|
/* Application tag mask */
|
|
|
|
uint16_t apptag_mask;
|
2019-02-13 06:17:49 +00:00
|
|
|
|
2019-06-04 05:52:24 +00:00
|
|
|
/* Byte offset from the start of the whole data buffer. */
|
|
|
|
uint32_t data_offset;
|
|
|
|
|
|
|
|
/* Offset to initial reference tag */
|
|
|
|
uint32_t ref_tag_offset;
|
|
|
|
|
2019-06-13 00:48:58 +00:00
|
|
|
/** Guard value of the last data block.
|
|
|
|
*
|
|
|
|
* Interim guard value is set if the last data block is partial, or
|
|
|
|
* seed value is set otherwise.
|
|
|
|
*/
|
|
|
|
uint16_t last_guard;
|
|
|
|
|
2019-02-13 06:17:49 +00:00
|
|
|
/* Seed value for guard computation */
|
|
|
|
uint16_t guard_seed;
|
2019-07-08 06:45:21 +00:00
|
|
|
|
|
|
|
/* Remapped initial reference tag. */
|
|
|
|
uint32_t remapped_init_ref_tag;
|
2019-01-07 00:20:35 +00:00
|
|
|
};
|
|
|
|
|
2018-12-28 01:18:21 +00:00
|
|
|
/** DIF error information */
|
|
|
|
struct spdk_dif_error {
|
|
|
|
/** Error type */
|
|
|
|
uint8_t err_type;
|
|
|
|
|
|
|
|
/** Expected value */
|
|
|
|
uint32_t expected;
|
|
|
|
|
|
|
|
/** Actual value */
|
|
|
|
uint32_t actual;
|
|
|
|
|
|
|
|
/** Offset the error occurred at, block based */
|
|
|
|
uint32_t err_offset;
|
|
|
|
};
|
|
|
|
|
2018-11-27 05:23:38 +00:00
|
|
|
/**
|
2019-01-07 00:20:35 +00:00
|
|
|
* Initialize DIF context.
|
2018-11-27 05:23:38 +00:00
|
|
|
*
|
2019-01-07 00:20:35 +00:00
|
|
|
* \param ctx DIF context.
|
2018-11-27 05:23:38 +00:00
|
|
|
* \param block_size Block size in a block.
|
|
|
|
* \param md_size Metadata size in a block.
|
2019-01-08 23:07:08 +00:00
|
|
|
* \param md_interleave If true, metadata is interleaved with block data.
|
|
|
|
* If false, metadata is separated with block data.
|
2019-01-16 06:40:59 +00:00
|
|
|
* \param dif_loc DIF location. If true, DIF is set in the first 8 bytes of metadata.
|
|
|
|
* If false, DIF is in the last 8 bytes of metadata.
|
2018-11-27 05:23:38 +00:00
|
|
|
* \param dif_type Type of DIF.
|
|
|
|
* \param dif_flags Flag to specify the DIF action.
|
2019-01-07 00:20:35 +00:00
|
|
|
* \param init_ref_tag Initial reference tag. For type 1, this is the
|
2018-11-27 05:23:38 +00:00
|
|
|
* starting block address.
|
2019-01-07 00:20:35 +00:00
|
|
|
* \param apptag_mask Application tag mask.
|
|
|
|
* \param app_tag Application tag.
|
2019-06-04 05:52:24 +00:00
|
|
|
* \param data_offset Byte offset from the start of the whole data buffer.
|
2019-02-13 06:17:49 +00:00
|
|
|
* \param guard_seed Seed value for guard computation.
|
2018-11-27 05:23:38 +00:00
|
|
|
*
|
|
|
|
* \return 0 on success and negated errno otherwise.
|
|
|
|
*/
|
2019-01-07 00:20:35 +00:00
|
|
|
int spdk_dif_ctx_init(struct spdk_dif_ctx *ctx, uint32_t block_size, uint32_t md_size,
|
2019-01-08 23:07:08 +00:00
|
|
|
bool md_interleave, bool dif_loc, enum spdk_dif_type dif_type, uint32_t dif_flags,
|
2019-02-13 06:17:49 +00:00
|
|
|
uint32_t init_ref_tag, uint16_t apptag_mask, uint16_t app_tag,
|
2019-06-04 05:52:24 +00:00
|
|
|
uint32_t data_offset, uint16_t guard_seed);
|
2019-01-07 00:20:35 +00:00
|
|
|
|
2019-06-15 00:09:05 +00:00
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
|
2019-07-08 06:45:21 +00:00
|
|
|
/**
|
|
|
|
* Set remapped initial reference tag of DIF context.
|
|
|
|
*
|
|
|
|
* \param ctx DIF context.
|
|
|
|
* \param remapped_init_ref_tag Remapped initial reference tag. For type 1, this is the
|
|
|
|
* starting block address.
|
|
|
|
*/
|
|
|
|
void spdk_dif_ctx_set_remapped_init_ref_tag(struct spdk_dif_ctx *ctx,
|
|
|
|
uint32_t remapped_init_ref_tag);
|
|
|
|
|
2019-01-07 00:20:35 +00:00
|
|
|
/**
|
|
|
|
* Generate DIF for extended LBA payload.
|
|
|
|
*
|
|
|
|
* \param iovs iovec array describing the extended LBA payload.
|
|
|
|
* \param iovcnt Number of elements in the iovec array.
|
|
|
|
* \param num_blocks Number of blocks of the payload.
|
|
|
|
* \param ctx DIF context.
|
|
|
|
*
|
|
|
|
* \return 0 on success and negated errno otherwise.
|
|
|
|
*/
|
|
|
|
int spdk_dif_generate(struct iovec *iovs, int iovcnt, uint32_t num_blocks,
|
|
|
|
const struct spdk_dif_ctx *ctx);
|
2018-11-27 05:23:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Verify DIF for extended LBA payload.
|
|
|
|
*
|
|
|
|
* \param iovs iovec array describing the extended LBA payload.
|
|
|
|
* \param iovcnt Number of elements in the iovec array.
|
|
|
|
* \param num_blocks Number of blocks of the payload.
|
2019-01-07 00:20:35 +00:00
|
|
|
* \param ctx DIF context.
|
2018-12-28 01:18:21 +00:00
|
|
|
* \param err_blk Error information of the block in which DIF error is found.
|
2018-11-27 05:23:38 +00:00
|
|
|
*
|
|
|
|
* \return 0 on success and negated errno otherwise.
|
|
|
|
*/
|
2019-01-07 00:20:35 +00:00
|
|
|
int spdk_dif_verify(struct iovec *iovs, int iovcnt, uint32_t num_blocks,
|
2018-12-28 01:18:21 +00:00
|
|
|
const struct spdk_dif_ctx *ctx, struct spdk_dif_error *err_blk);
|
2018-12-18 01:51:22 +00:00
|
|
|
|
2019-05-29 07:01:39 +00:00
|
|
|
/**
|
|
|
|
* Calculate CRC-32C checksum for extended LBA payload.
|
|
|
|
*
|
|
|
|
* \param iovs iovec array describing the extended LBA payload.
|
|
|
|
* \param iovcnt Number of elements in the iovec array.
|
|
|
|
* \param num_blocks Number of blocks of the payload.
|
|
|
|
* \param crc32c Initial and updated CRC-32C value.
|
|
|
|
* \param ctx DIF context.
|
|
|
|
*
|
|
|
|
* \return 0 on success and negated errno otherwise.
|
|
|
|
*/
|
|
|
|
int spdk_dif_update_crc32c(struct iovec *iovs, int iovcnt, uint32_t num_blocks,
|
|
|
|
uint32_t *crc32c, const struct spdk_dif_ctx *ctx);
|
|
|
|
|
2018-12-28 01:25:02 +00:00
|
|
|
/**
|
|
|
|
* Copy data and generate DIF for extended LBA payload.
|
|
|
|
*
|
|
|
|
* \param iovs iovec array describing the LBA payload.
|
|
|
|
* \param iovcnt Number of elements in the iovec array.
|
|
|
|
* \param bounce_iov A contiguous buffer forming extended LBA payload.
|
|
|
|
* \param num_blocks Number of blocks of the LBA payload.
|
|
|
|
* \param ctx DIF context.
|
|
|
|
*
|
|
|
|
* \return 0 on success and negated errno otherwise.
|
|
|
|
*/
|
|
|
|
int spdk_dif_generate_copy(struct iovec *iovs, int iovcnt, struct iovec *bounce_iov,
|
|
|
|
uint32_t num_blocks, const struct spdk_dif_ctx *ctx);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Verify DIF and copy data for extended LBA payload.
|
|
|
|
*
|
|
|
|
* \param iovs iovec array describing the LBA payload.
|
|
|
|
* \param iovcnt Number of elements in the iovec array.
|
|
|
|
* \param bounce_iov A contiguous buffer forming extended LBA payload.
|
|
|
|
* \param num_blocks Number of blocks of the LBA payload.
|
|
|
|
* \param ctx DIF context.
|
2018-12-28 01:32:13 +00:00
|
|
|
* \param err_blk Error information of the block in which DIF error is found.
|
2018-12-28 01:25:02 +00:00
|
|
|
*
|
|
|
|
* \return 0 on success and negated errno otherwise.
|
|
|
|
*/
|
|
|
|
int spdk_dif_verify_copy(struct iovec *iovs, int iovcnt, struct iovec *bounce_iov,
|
2018-12-28 01:32:13 +00:00
|
|
|
uint32_t num_blocks, const struct spdk_dif_ctx *ctx,
|
|
|
|
struct spdk_dif_error *err_blk);
|
2018-12-28 01:25:02 +00:00
|
|
|
|
2018-12-18 01:51:22 +00:00
|
|
|
/**
|
|
|
|
* Inject bit flip error to extended LBA payload.
|
|
|
|
*
|
|
|
|
* \param iovs iovec array describing the extended LBA payload.
|
|
|
|
* \param iovcnt Number of elements in the iovec array.
|
|
|
|
* \param num_blocks Number of blocks of the payload.
|
2019-01-07 00:20:35 +00:00
|
|
|
* \param ctx DIF context.
|
2018-12-28 01:18:21 +00:00
|
|
|
* \param inject_flags Flags to specify the action of error injection.
|
|
|
|
* \param inject_offset Offset, in blocks, to which error is injected.
|
|
|
|
* If multiple error is injected, only the last injection is stored.
|
2018-12-18 01:51:22 +00:00
|
|
|
*
|
|
|
|
* \return 0 on success and negated errno otherwise including no metadata.
|
|
|
|
*/
|
2019-01-07 00:20:35 +00:00
|
|
|
int spdk_dif_inject_error(struct iovec *iovs, int iovcnt, uint32_t num_blocks,
|
2018-12-28 01:18:21 +00:00
|
|
|
const struct spdk_dif_ctx *ctx, uint32_t inject_flags,
|
|
|
|
uint32_t *inject_offset);
|
2019-01-08 23:07:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate DIF for separate metadata payload.
|
|
|
|
*
|
|
|
|
* \param iovs iovec array describing the LBA payload.
|
|
|
|
* \params iovcnt Number of elements in iovs.
|
|
|
|
* \param md_iov A contiguous buffer for metadata.
|
|
|
|
* \param num_blocks Number of blocks of the separate metadata payload.
|
|
|
|
* \param ctx DIF context.
|
|
|
|
*
|
|
|
|
* \return 0 on success and negated errno otherwise.
|
|
|
|
*/
|
|
|
|
int spdk_dix_generate(struct iovec *iovs, int iovcnt, struct iovec *md_iov,
|
|
|
|
uint32_t num_blocks, const struct spdk_dif_ctx *ctx);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Verify DIF for separate metadata payload.
|
|
|
|
*
|
|
|
|
* \param iovs iovec array describing the LBA payload.
|
|
|
|
* \params iovcnt Number of elements in iovs.
|
|
|
|
* \param md_iov A contiguous buffer for metadata.
|
|
|
|
* \param num_blocks Number of blocks of the separate metadata payload.
|
|
|
|
* \param ctx DIF context.
|
2019-01-08 09:08:08 +00:00
|
|
|
* \param err_blk Error information of the block in which DIF error is found.
|
2019-01-08 23:07:08 +00:00
|
|
|
*
|
|
|
|
* \return 0 on success and negated errno otherwise.
|
|
|
|
*/
|
|
|
|
int spdk_dix_verify(struct iovec *iovs, int iovcnt, struct iovec *md_iov,
|
2019-01-08 09:08:08 +00:00
|
|
|
uint32_t num_blocks, const struct spdk_dif_ctx *ctx,
|
|
|
|
struct spdk_dif_error *err_blk);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Inject bit flip error to separate metadata payload.
|
|
|
|
*
|
|
|
|
* \param iovs iovec array describing the extended LBA payload.
|
|
|
|
* \param iovcnt Number of elements in the iovec array.
|
|
|
|
* \param md_iov A contiguous buffer for metadata.
|
|
|
|
* \param num_blocks Number of blocks of the payload.
|
|
|
|
* \param ctx DIF context.
|
|
|
|
* \param inject_flags Flag to specify the action of error injection.
|
|
|
|
* \param inject_offset Offset, in blocks, to which error is injected.
|
|
|
|
* If multiple error is injected, only the last injection is stored.
|
|
|
|
*
|
|
|
|
* \return 0 on success and negated errno otherwise including no metadata.
|
|
|
|
*/
|
|
|
|
int spdk_dix_inject_error(struct iovec *iovs, int iovcnt, struct iovec *md_iov,
|
|
|
|
uint32_t num_blocks, const struct spdk_dif_ctx *ctx,
|
|
|
|
uint32_t inject_flags, uint32_t *inject_offset);
|
2019-02-26 06:14:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Setup iovec array to leave a space for metadata for each block.
|
|
|
|
*
|
|
|
|
* This function is used to leave a space for metadata for each block when
|
|
|
|
* the network socket reads data, or to make the network socket ignore a
|
|
|
|
* space for metadata for each block when the network socket writes data.
|
|
|
|
* This function removes the necessity of data copy in the SPDK application
|
|
|
|
* during DIF insertion and strip.
|
|
|
|
*
|
2019-06-12 08:26:08 +00:00
|
|
|
* When the extended LBA payload is splitted into multiple data segments,
|
|
|
|
* start of each data segment is passed through the DIF context. data_offset
|
|
|
|
* and data_len is within a data segment.
|
|
|
|
*
|
2019-02-26 06:14:53 +00:00
|
|
|
* \param iovs iovec array set by this function.
|
2019-05-15 07:27:17 +00:00
|
|
|
* \param iovcnt Number of elements in the iovec array.
|
2019-05-15 01:22:01 +00:00
|
|
|
* \param buf_iovs SGL for the buffer to create extended LBA payload.
|
|
|
|
* \param buf_iovcnt Size of the SGL for the buffer to create extended LBA payload.
|
2019-06-12 08:26:08 +00:00
|
|
|
* \param data_offset Offset to store the next incoming data in the current data segment.
|
|
|
|
* \param data_len Expected length of the newly read data in the current data segment of
|
|
|
|
* the extended LBA payload.
|
2019-02-26 06:14:53 +00:00
|
|
|
* \param mapped_len Output parameter that will contain data length mapped by
|
|
|
|
* the iovec array.
|
|
|
|
* \param ctx DIF context.
|
|
|
|
*
|
|
|
|
* \return Number of used elements in the iovec array on success or negated
|
|
|
|
* errno otherwise.
|
|
|
|
*/
|
2019-05-15 07:27:17 +00:00
|
|
|
int spdk_dif_set_md_interleave_iovs(struct iovec *iovs, int iovcnt,
|
2019-05-15 01:22:01 +00:00
|
|
|
struct iovec *buf_iovs, int buf_iovcnt,
|
2019-02-26 06:14:53 +00:00
|
|
|
uint32_t data_offset, uint32_t data_len,
|
|
|
|
uint32_t *mapped_len,
|
|
|
|
const struct spdk_dif_ctx *ctx);
|
2019-03-01 08:49:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate and insert DIF into metadata space for newly read data block.
|
|
|
|
*
|
2019-06-13 00:48:58 +00:00
|
|
|
* When the extended LBA payload is splitted into multiple data segments,
|
|
|
|
* start of each data segment is passed through the DIF context. data_offset
|
|
|
|
* and data_len is within a data segment.
|
|
|
|
*
|
2019-05-08 23:16:33 +00:00
|
|
|
* \param iovs iovec array describing the extended LBA payload.
|
|
|
|
* \param iovcnt Number of elements in the iovec array.
|
2019-06-13 00:48:58 +00:00
|
|
|
* \param data_offset Offset to the newly read data in the current data segment of
|
|
|
|
* the extended LBA payload.
|
|
|
|
* \param data_len Length of the newly read data in the current data segment of
|
|
|
|
* the extended LBA payload.
|
2019-03-01 08:49:23 +00:00
|
|
|
* \param ctx DIF context.
|
|
|
|
*
|
|
|
|
* \return 0 on success and negated errno otherwise.
|
|
|
|
*/
|
2019-05-08 23:16:33 +00:00
|
|
|
int spdk_dif_generate_stream(struct iovec *iovs, int iovcnt,
|
2019-05-30 01:18:11 +00:00
|
|
|
uint32_t data_offset, uint32_t data_len,
|
2019-06-13 00:48:58 +00:00
|
|
|
struct spdk_dif_ctx *ctx);
|
2019-06-17 08:45:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Verify DIF for the to-be-written block of the extended LBA payload.
|
|
|
|
*
|
|
|
|
* \param iovs iovec array describing the extended LBA payload.
|
|
|
|
* \param iovcnt Number of elements in the iovec array.
|
|
|
|
* \param data_offset Offset to the to-be-written data in the extended LBA payload.
|
|
|
|
* \param data_len Length of the to-be-written data in the extended LBA payload.
|
|
|
|
* \param ctx DIF context.
|
|
|
|
*
|
|
|
|
* \return 0 on success and negated errno otherwise.
|
|
|
|
*/
|
|
|
|
int spdk_dif_verify_stream(struct iovec *iovs, int iovcnt,
|
|
|
|
uint32_t data_offset, uint32_t data_len,
|
|
|
|
struct spdk_dif_ctx *ctx,
|
|
|
|
struct spdk_dif_error *err_blk);
|
2019-06-20 08:04:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculate CRC-32C checksum of the specified range in the extended LBA payload.
|
|
|
|
*
|
|
|
|
* \param iovs iovec array describing the extended LBA payload.
|
|
|
|
* \param iovcnt Number of elements in the iovec array.
|
|
|
|
* \param data_offset Offset to the range
|
|
|
|
* \param data_len Length of the range
|
|
|
|
* \param crc32c Initial and updated CRC-32C value.
|
|
|
|
* \param ctx DIF context.
|
|
|
|
*
|
|
|
|
* \return 0 on success and negated errno otherwise.
|
|
|
|
*/
|
|
|
|
int spdk_dif_update_crc32c_stream(struct iovec *iovs, int iovcnt,
|
|
|
|
uint32_t data_offset, uint32_t data_len,
|
|
|
|
uint32_t *crc32c, const struct spdk_dif_ctx *ctx);
|
2019-06-20 08:12:04 +00:00
|
|
|
/**
|
|
|
|
* Convert offset and size from LBA based to extended LBA based.
|
|
|
|
*
|
|
|
|
* \param data_offset Data offset
|
|
|
|
* \param data_len Data length
|
|
|
|
* \param buf_offset Buffer offset converted from data offset.
|
|
|
|
* \param buf_len Buffer length converted from data length
|
|
|
|
* \param ctx DIF context.
|
|
|
|
*/
|
|
|
|
void spdk_dif_get_range_with_md(uint32_t data_offset, uint32_t data_len,
|
|
|
|
uint32_t *buf_offset, uint32_t *buf_len,
|
|
|
|
const struct spdk_dif_ctx *ctx);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert length from LBA based to extended LBA based.
|
|
|
|
*
|
|
|
|
* \param data_len Data length
|
|
|
|
* \param ctx DIF context.
|
|
|
|
*
|
|
|
|
* \return Extended LBA based data length.
|
|
|
|
*/
|
|
|
|
uint32_t spdk_dif_get_length_with_md(uint32_t data_len, const struct spdk_dif_ctx *ctx);
|
2019-07-08 06:45:21 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Remap reference tag for extended LBA payload.
|
|
|
|
*
|
|
|
|
* When using stacked virtual bdev (e.g. split virtual bdev), block address space for I/O
|
|
|
|
* will be remapped during I/O processing and so reference tag will have to be remapped
|
|
|
|
* accordingly. This patch is for that case.
|
|
|
|
*
|
|
|
|
* \param iovs iovec array describing the extended LBA payload.
|
|
|
|
* \param iovcnt Number of elements in the iovec array.
|
|
|
|
* \param num_blocks Number of blocks of the payload.
|
|
|
|
* \param ctx DIF context.
|
|
|
|
* \param err_blk Error information of the block in which DIF error is found.
|
|
|
|
*
|
|
|
|
* \return 0 on success and negated errno otherwise.
|
|
|
|
*/
|
|
|
|
int spdk_dif_remap_ref_tag(struct iovec *iovs, int iovcnt, uint32_t num_blocks,
|
|
|
|
const struct spdk_dif_ctx *dif_ctx,
|
|
|
|
struct spdk_dif_error *err_blk);
|
2019-07-09 02:58:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Remap reference tag for separate metadata payload.
|
|
|
|
*
|
|
|
|
* When using stacked virtual bdev (e.g. split virtual bdev), block address space for I/O
|
|
|
|
* will be remapped during I/O processing and so reference tag will have to be remapped
|
|
|
|
* accordingly. This patch is for that case.
|
|
|
|
*
|
|
|
|
* \param md_iov A contiguous buffer for metadata.
|
|
|
|
* \param num_blocks Number of blocks of the payload.
|
|
|
|
* \param ctx DIF context.
|
|
|
|
* \param err_blk Error information of the block in which DIF error is found.
|
|
|
|
*
|
|
|
|
* \return 0 on success and negated errno otherwise.
|
|
|
|
*/
|
|
|
|
int spdk_dix_remap_ref_tag(struct iovec *md_iov, uint32_t num_blocks,
|
|
|
|
const struct spdk_dif_ctx *dif_ctx,
|
|
|
|
struct spdk_dif_error *err_blk);
|
2018-11-27 05:23:38 +00:00
|
|
|
#endif /* SPDK_DIF_H */
|