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