/* SPDX-License-Identifier: (GPL-2.0 OR Linux-OpenIB) */1/*2* Copyright (c) 2017-2018 Mellanox Technologies. All rights reserved.3*/45#ifndef _RDMA_SIGNATURE_H_6#define _RDMA_SIGNATURE_H_78#include <linux/types.h>910enum ib_signature_prot_cap {11IB_PROT_T10DIF_TYPE_1 = 1,12IB_PROT_T10DIF_TYPE_2 = 1 << 1,13IB_PROT_T10DIF_TYPE_3 = 1 << 2,14};1516enum ib_signature_guard_cap {17IB_GUARD_T10DIF_CRC = 1,18IB_GUARD_T10DIF_CSUM = 1 << 1,19};2021/**22* enum ib_signature_type - Signature types23* @IB_SIG_TYPE_NONE: Unprotected.24* @IB_SIG_TYPE_T10_DIF: Type T10-DIF25*/26enum ib_signature_type {27IB_SIG_TYPE_NONE,28IB_SIG_TYPE_T10_DIF,29};3031/**32* enum ib_t10_dif_bg_type - Signature T10-DIF block-guard types33* @IB_T10DIF_CRC: Corresponds to T10-PI mandated CRC checksum rules.34* @IB_T10DIF_CSUM: Corresponds to IP checksum rules.35*/36enum ib_t10_dif_bg_type {37IB_T10DIF_CRC,38IB_T10DIF_CSUM,39};4041/**42* struct ib_t10_dif_domain - Parameters specific for T10-DIF43* domain.44* @bg_type: T10-DIF block guard type (CRC|CSUM)45* @pi_interval: protection information interval.46* @bg: seed of guard computation.47* @app_tag: application tag of guard block48* @ref_tag: initial guard block reference tag.49* @ref_remap: Indicate wethear the reftag increments each block50* @app_escape: Indicate to skip block check if apptag=0xffff51* @ref_escape: Indicate to skip block check if reftag=0xffffffff52* @apptag_check_mask: check bitmask of application tag.53*/54struct ib_t10_dif_domain {55enum ib_t10_dif_bg_type bg_type;56u16 pi_interval;57u16 bg;58u16 app_tag;59u32 ref_tag;60bool ref_remap;61bool app_escape;62bool ref_escape;63u16 apptag_check_mask;64};6566/**67* struct ib_sig_domain - Parameters for signature domain68* @sig_type: specific signauture type69* @sig: union of all signature domain attributes that may70* be used to set domain layout.71*/72struct ib_sig_domain {73enum ib_signature_type sig_type;74union {75struct ib_t10_dif_domain dif;76} sig;77};7879/**80* struct ib_sig_attrs - Parameters for signature handover operation81* @check_mask: bitmask for signature byte check (8 bytes)82* @mem: memory domain layout descriptor.83* @wire: wire domain layout descriptor.84* @meta_length: metadata length85*/86struct ib_sig_attrs {87u8 check_mask;88struct ib_sig_domain mem;89struct ib_sig_domain wire;90int meta_length;91};9293enum ib_sig_err_type {94IB_SIG_BAD_GUARD,95IB_SIG_BAD_REFTAG,96IB_SIG_BAD_APPTAG,97};9899/*100* Signature check masks (8 bytes in total) according to the T10-PI standard:101* -------- -------- ------------102* | GUARD | APPTAG | REFTAG |103* | 2B | 2B | 4B |104* -------- -------- ------------105*/106enum {107IB_SIG_CHECK_GUARD = 0xc0,108IB_SIG_CHECK_APPTAG = 0x30,109IB_SIG_CHECK_REFTAG = 0x0f,110};111112/*113* struct ib_sig_err - signature error descriptor114*/115struct ib_sig_err {116enum ib_sig_err_type err_type;117u32 expected;118u32 actual;119u64 sig_err_offset;120u32 key;121};122123#endif /* _RDMA_SIGNATURE_H_ */124125126