136b1e47fSMax Gurtovoy /* SPDX-License-Identifier: (GPL-2.0 OR Linux-OpenIB) */ 236b1e47fSMax Gurtovoy /* 336b1e47fSMax Gurtovoy * Copyright (c) 2017-2018 Mellanox Technologies. All rights reserved. 436b1e47fSMax Gurtovoy */ 536b1e47fSMax Gurtovoy 636b1e47fSMax Gurtovoy #ifndef _RDMA_SIGNATURE_H_ 736b1e47fSMax Gurtovoy #define _RDMA_SIGNATURE_H_ 836b1e47fSMax Gurtovoy 936b1e47fSMax Gurtovoy enum ib_signature_prot_cap { 1036b1e47fSMax Gurtovoy IB_PROT_T10DIF_TYPE_1 = 1, 1136b1e47fSMax Gurtovoy IB_PROT_T10DIF_TYPE_2 = 1 << 1, 1236b1e47fSMax Gurtovoy IB_PROT_T10DIF_TYPE_3 = 1 << 2, 1336b1e47fSMax Gurtovoy }; 1436b1e47fSMax Gurtovoy 1536b1e47fSMax Gurtovoy enum ib_signature_guard_cap { 1636b1e47fSMax Gurtovoy IB_GUARD_T10DIF_CRC = 1, 1736b1e47fSMax Gurtovoy IB_GUARD_T10DIF_CSUM = 1 << 1, 1836b1e47fSMax Gurtovoy }; 1936b1e47fSMax Gurtovoy 2036b1e47fSMax Gurtovoy /** 2136b1e47fSMax Gurtovoy * enum ib_signature_type - Signature types 2236b1e47fSMax Gurtovoy * @IB_SIG_TYPE_NONE: Unprotected. 2336b1e47fSMax Gurtovoy * @IB_SIG_TYPE_T10_DIF: Type T10-DIF 2436b1e47fSMax Gurtovoy */ 2536b1e47fSMax Gurtovoy enum ib_signature_type { 2636b1e47fSMax Gurtovoy IB_SIG_TYPE_NONE, 2736b1e47fSMax Gurtovoy IB_SIG_TYPE_T10_DIF, 2836b1e47fSMax Gurtovoy }; 2936b1e47fSMax Gurtovoy 3036b1e47fSMax Gurtovoy /** 3136b1e47fSMax Gurtovoy * enum ib_t10_dif_bg_type - Signature T10-DIF block-guard types 3236b1e47fSMax Gurtovoy * @IB_T10DIF_CRC: Corresponds to T10-PI mandated CRC checksum rules. 3336b1e47fSMax Gurtovoy * @IB_T10DIF_CSUM: Corresponds to IP checksum rules. 3436b1e47fSMax Gurtovoy */ 3536b1e47fSMax Gurtovoy enum ib_t10_dif_bg_type { 3636b1e47fSMax Gurtovoy IB_T10DIF_CRC, 3736b1e47fSMax Gurtovoy IB_T10DIF_CSUM, 3836b1e47fSMax Gurtovoy }; 3936b1e47fSMax Gurtovoy 4036b1e47fSMax Gurtovoy /** 4136b1e47fSMax Gurtovoy * struct ib_t10_dif_domain - Parameters specific for T10-DIF 4236b1e47fSMax Gurtovoy * domain. 4336b1e47fSMax Gurtovoy * @bg_type: T10-DIF block guard type (CRC|CSUM) 4436b1e47fSMax Gurtovoy * @pi_interval: protection information interval. 4536b1e47fSMax Gurtovoy * @bg: seed of guard computation. 4636b1e47fSMax Gurtovoy * @app_tag: application tag of guard block 4736b1e47fSMax Gurtovoy * @ref_tag: initial guard block reference tag. 4836b1e47fSMax Gurtovoy * @ref_remap: Indicate wethear the reftag increments each block 4936b1e47fSMax Gurtovoy * @app_escape: Indicate to skip block check if apptag=0xffff 5036b1e47fSMax Gurtovoy * @ref_escape: Indicate to skip block check if reftag=0xffffffff 5136b1e47fSMax Gurtovoy * @apptag_check_mask: check bitmask of application tag. 5236b1e47fSMax Gurtovoy */ 5336b1e47fSMax Gurtovoy struct ib_t10_dif_domain { 5436b1e47fSMax Gurtovoy enum ib_t10_dif_bg_type bg_type; 5536b1e47fSMax Gurtovoy u16 pi_interval; 5636b1e47fSMax Gurtovoy u16 bg; 5736b1e47fSMax Gurtovoy u16 app_tag; 5836b1e47fSMax Gurtovoy u32 ref_tag; 5936b1e47fSMax Gurtovoy bool ref_remap; 6036b1e47fSMax Gurtovoy bool app_escape; 6136b1e47fSMax Gurtovoy bool ref_escape; 6236b1e47fSMax Gurtovoy u16 apptag_check_mask; 6336b1e47fSMax Gurtovoy }; 6436b1e47fSMax Gurtovoy 6536b1e47fSMax Gurtovoy /** 6636b1e47fSMax Gurtovoy * struct ib_sig_domain - Parameters for signature domain 6736b1e47fSMax Gurtovoy * @sig_type: specific signauture type 6836b1e47fSMax Gurtovoy * @sig: union of all signature domain attributes that may 6936b1e47fSMax Gurtovoy * be used to set domain layout. 7036b1e47fSMax Gurtovoy */ 7136b1e47fSMax Gurtovoy struct ib_sig_domain { 7236b1e47fSMax Gurtovoy enum ib_signature_type sig_type; 7336b1e47fSMax Gurtovoy union { 7436b1e47fSMax Gurtovoy struct ib_t10_dif_domain dif; 7536b1e47fSMax Gurtovoy } sig; 7636b1e47fSMax Gurtovoy }; 7736b1e47fSMax Gurtovoy 7836b1e47fSMax Gurtovoy /** 7936b1e47fSMax Gurtovoy * struct ib_sig_attrs - Parameters for signature handover operation 8036b1e47fSMax Gurtovoy * @check_mask: bitmask for signature byte check (8 bytes) 8136b1e47fSMax Gurtovoy * @mem: memory domain layout descriptor. 8236b1e47fSMax Gurtovoy * @wire: wire domain layout descriptor. 83*7c717d3aSMax Gurtovoy * @meta_length: metadata length 8436b1e47fSMax Gurtovoy */ 8536b1e47fSMax Gurtovoy struct ib_sig_attrs { 8636b1e47fSMax Gurtovoy u8 check_mask; 8736b1e47fSMax Gurtovoy struct ib_sig_domain mem; 8836b1e47fSMax Gurtovoy struct ib_sig_domain wire; 89*7c717d3aSMax Gurtovoy int meta_length; 9036b1e47fSMax Gurtovoy }; 9136b1e47fSMax Gurtovoy 9236b1e47fSMax Gurtovoy enum ib_sig_err_type { 9336b1e47fSMax Gurtovoy IB_SIG_BAD_GUARD, 9436b1e47fSMax Gurtovoy IB_SIG_BAD_REFTAG, 9536b1e47fSMax Gurtovoy IB_SIG_BAD_APPTAG, 9636b1e47fSMax Gurtovoy }; 9736b1e47fSMax Gurtovoy 9836b1e47fSMax Gurtovoy /* 9936b1e47fSMax Gurtovoy * Signature check masks (8 bytes in total) according to the T10-PI standard: 10036b1e47fSMax Gurtovoy * -------- -------- ------------ 10136b1e47fSMax Gurtovoy * | GUARD | APPTAG | REFTAG | 10236b1e47fSMax Gurtovoy * | 2B | 2B | 4B | 10336b1e47fSMax Gurtovoy * -------- -------- ------------ 10436b1e47fSMax Gurtovoy */ 10536b1e47fSMax Gurtovoy enum { 10636b1e47fSMax Gurtovoy IB_SIG_CHECK_GUARD = 0xc0, 10736b1e47fSMax Gurtovoy IB_SIG_CHECK_APPTAG = 0x30, 10836b1e47fSMax Gurtovoy IB_SIG_CHECK_REFTAG = 0x0f, 10936b1e47fSMax Gurtovoy }; 11036b1e47fSMax Gurtovoy 11136b1e47fSMax Gurtovoy /* 11236b1e47fSMax Gurtovoy * struct ib_sig_err - signature error descriptor 11336b1e47fSMax Gurtovoy */ 11436b1e47fSMax Gurtovoy struct ib_sig_err { 11536b1e47fSMax Gurtovoy enum ib_sig_err_type err_type; 11636b1e47fSMax Gurtovoy u32 expected; 11736b1e47fSMax Gurtovoy u32 actual; 11836b1e47fSMax Gurtovoy u64 sig_err_offset; 11936b1e47fSMax Gurtovoy u32 key; 12036b1e47fSMax Gurtovoy }; 12136b1e47fSMax Gurtovoy 12236b1e47fSMax Gurtovoy #endif /* _RDMA_SIGNATURE_H_ */ 123