1*36b1e47fSMax Gurtovoy /* SPDX-License-Identifier: (GPL-2.0 OR Linux-OpenIB) */ 2*36b1e47fSMax Gurtovoy /* 3*36b1e47fSMax Gurtovoy * Copyright (c) 2017-2018 Mellanox Technologies. All rights reserved. 4*36b1e47fSMax Gurtovoy */ 5*36b1e47fSMax Gurtovoy 6*36b1e47fSMax Gurtovoy #ifndef _RDMA_SIGNATURE_H_ 7*36b1e47fSMax Gurtovoy #define _RDMA_SIGNATURE_H_ 8*36b1e47fSMax Gurtovoy 9*36b1e47fSMax Gurtovoy enum ib_signature_prot_cap { 10*36b1e47fSMax Gurtovoy IB_PROT_T10DIF_TYPE_1 = 1, 11*36b1e47fSMax Gurtovoy IB_PROT_T10DIF_TYPE_2 = 1 << 1, 12*36b1e47fSMax Gurtovoy IB_PROT_T10DIF_TYPE_3 = 1 << 2, 13*36b1e47fSMax Gurtovoy }; 14*36b1e47fSMax Gurtovoy 15*36b1e47fSMax Gurtovoy enum ib_signature_guard_cap { 16*36b1e47fSMax Gurtovoy IB_GUARD_T10DIF_CRC = 1, 17*36b1e47fSMax Gurtovoy IB_GUARD_T10DIF_CSUM = 1 << 1, 18*36b1e47fSMax Gurtovoy }; 19*36b1e47fSMax Gurtovoy 20*36b1e47fSMax Gurtovoy /** 21*36b1e47fSMax Gurtovoy * enum ib_signature_type - Signature types 22*36b1e47fSMax Gurtovoy * @IB_SIG_TYPE_NONE: Unprotected. 23*36b1e47fSMax Gurtovoy * @IB_SIG_TYPE_T10_DIF: Type T10-DIF 24*36b1e47fSMax Gurtovoy */ 25*36b1e47fSMax Gurtovoy enum ib_signature_type { 26*36b1e47fSMax Gurtovoy IB_SIG_TYPE_NONE, 27*36b1e47fSMax Gurtovoy IB_SIG_TYPE_T10_DIF, 28*36b1e47fSMax Gurtovoy }; 29*36b1e47fSMax Gurtovoy 30*36b1e47fSMax Gurtovoy /** 31*36b1e47fSMax Gurtovoy * enum ib_t10_dif_bg_type - Signature T10-DIF block-guard types 32*36b1e47fSMax Gurtovoy * @IB_T10DIF_CRC: Corresponds to T10-PI mandated CRC checksum rules. 33*36b1e47fSMax Gurtovoy * @IB_T10DIF_CSUM: Corresponds to IP checksum rules. 34*36b1e47fSMax Gurtovoy */ 35*36b1e47fSMax Gurtovoy enum ib_t10_dif_bg_type { 36*36b1e47fSMax Gurtovoy IB_T10DIF_CRC, 37*36b1e47fSMax Gurtovoy IB_T10DIF_CSUM, 38*36b1e47fSMax Gurtovoy }; 39*36b1e47fSMax Gurtovoy 40*36b1e47fSMax Gurtovoy /** 41*36b1e47fSMax Gurtovoy * struct ib_t10_dif_domain - Parameters specific for T10-DIF 42*36b1e47fSMax Gurtovoy * domain. 43*36b1e47fSMax Gurtovoy * @bg_type: T10-DIF block guard type (CRC|CSUM) 44*36b1e47fSMax Gurtovoy * @pi_interval: protection information interval. 45*36b1e47fSMax Gurtovoy * @bg: seed of guard computation. 46*36b1e47fSMax Gurtovoy * @app_tag: application tag of guard block 47*36b1e47fSMax Gurtovoy * @ref_tag: initial guard block reference tag. 48*36b1e47fSMax Gurtovoy * @ref_remap: Indicate wethear the reftag increments each block 49*36b1e47fSMax Gurtovoy * @app_escape: Indicate to skip block check if apptag=0xffff 50*36b1e47fSMax Gurtovoy * @ref_escape: Indicate to skip block check if reftag=0xffffffff 51*36b1e47fSMax Gurtovoy * @apptag_check_mask: check bitmask of application tag. 52*36b1e47fSMax Gurtovoy */ 53*36b1e47fSMax Gurtovoy struct ib_t10_dif_domain { 54*36b1e47fSMax Gurtovoy enum ib_t10_dif_bg_type bg_type; 55*36b1e47fSMax Gurtovoy u16 pi_interval; 56*36b1e47fSMax Gurtovoy u16 bg; 57*36b1e47fSMax Gurtovoy u16 app_tag; 58*36b1e47fSMax Gurtovoy u32 ref_tag; 59*36b1e47fSMax Gurtovoy bool ref_remap; 60*36b1e47fSMax Gurtovoy bool app_escape; 61*36b1e47fSMax Gurtovoy bool ref_escape; 62*36b1e47fSMax Gurtovoy u16 apptag_check_mask; 63*36b1e47fSMax Gurtovoy }; 64*36b1e47fSMax Gurtovoy 65*36b1e47fSMax Gurtovoy /** 66*36b1e47fSMax Gurtovoy * struct ib_sig_domain - Parameters for signature domain 67*36b1e47fSMax Gurtovoy * @sig_type: specific signauture type 68*36b1e47fSMax Gurtovoy * @sig: union of all signature domain attributes that may 69*36b1e47fSMax Gurtovoy * be used to set domain layout. 70*36b1e47fSMax Gurtovoy */ 71*36b1e47fSMax Gurtovoy struct ib_sig_domain { 72*36b1e47fSMax Gurtovoy enum ib_signature_type sig_type; 73*36b1e47fSMax Gurtovoy union { 74*36b1e47fSMax Gurtovoy struct ib_t10_dif_domain dif; 75*36b1e47fSMax Gurtovoy } sig; 76*36b1e47fSMax Gurtovoy }; 77*36b1e47fSMax Gurtovoy 78*36b1e47fSMax Gurtovoy /** 79*36b1e47fSMax Gurtovoy * struct ib_sig_attrs - Parameters for signature handover operation 80*36b1e47fSMax Gurtovoy * @check_mask: bitmask for signature byte check (8 bytes) 81*36b1e47fSMax Gurtovoy * @mem: memory domain layout descriptor. 82*36b1e47fSMax Gurtovoy * @wire: wire domain layout descriptor. 83*36b1e47fSMax Gurtovoy */ 84*36b1e47fSMax Gurtovoy struct ib_sig_attrs { 85*36b1e47fSMax Gurtovoy u8 check_mask; 86*36b1e47fSMax Gurtovoy struct ib_sig_domain mem; 87*36b1e47fSMax Gurtovoy struct ib_sig_domain wire; 88*36b1e47fSMax Gurtovoy }; 89*36b1e47fSMax Gurtovoy 90*36b1e47fSMax Gurtovoy enum ib_sig_err_type { 91*36b1e47fSMax Gurtovoy IB_SIG_BAD_GUARD, 92*36b1e47fSMax Gurtovoy IB_SIG_BAD_REFTAG, 93*36b1e47fSMax Gurtovoy IB_SIG_BAD_APPTAG, 94*36b1e47fSMax Gurtovoy }; 95*36b1e47fSMax Gurtovoy 96*36b1e47fSMax Gurtovoy /* 97*36b1e47fSMax Gurtovoy * Signature check masks (8 bytes in total) according to the T10-PI standard: 98*36b1e47fSMax Gurtovoy * -------- -------- ------------ 99*36b1e47fSMax Gurtovoy * | GUARD | APPTAG | REFTAG | 100*36b1e47fSMax Gurtovoy * | 2B | 2B | 4B | 101*36b1e47fSMax Gurtovoy * -------- -------- ------------ 102*36b1e47fSMax Gurtovoy */ 103*36b1e47fSMax Gurtovoy enum { 104*36b1e47fSMax Gurtovoy IB_SIG_CHECK_GUARD = 0xc0, 105*36b1e47fSMax Gurtovoy IB_SIG_CHECK_APPTAG = 0x30, 106*36b1e47fSMax Gurtovoy IB_SIG_CHECK_REFTAG = 0x0f, 107*36b1e47fSMax Gurtovoy }; 108*36b1e47fSMax Gurtovoy 109*36b1e47fSMax Gurtovoy /* 110*36b1e47fSMax Gurtovoy * struct ib_sig_err - signature error descriptor 111*36b1e47fSMax Gurtovoy */ 112*36b1e47fSMax Gurtovoy struct ib_sig_err { 113*36b1e47fSMax Gurtovoy enum ib_sig_err_type err_type; 114*36b1e47fSMax Gurtovoy u32 expected; 115*36b1e47fSMax Gurtovoy u32 actual; 116*36b1e47fSMax Gurtovoy u64 sig_err_offset; 117*36b1e47fSMax Gurtovoy u32 key; 118*36b1e47fSMax Gurtovoy }; 119*36b1e47fSMax Gurtovoy 120*36b1e47fSMax Gurtovoy #endif /* _RDMA_SIGNATURE_H_ */ 121