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