]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blame - include/rdma/signature.h
RDMA/core: Introduce new header file for signature operations
[mirror_ubuntu-hirsute-kernel.git] / include / rdma / signature.h
CommitLineData
36b1e47f
MG
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
9enum 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
15enum 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 */
25enum 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 */
35enum 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 */
53struct 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 */
71struct 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 */
84struct ib_sig_attrs {
85 u8 check_mask;
86 struct ib_sig_domain mem;
87 struct ib_sig_domain wire;
88};
89
90enum ib_sig_err_type {
91 IB_SIG_BAD_GUARD,
92 IB_SIG_BAD_REFTAG,
93 IB_SIG_BAD_APPTAG,
94};
95
96/*
97 * Signature check masks (8 bytes in total) according to the T10-PI standard:
98 * -------- -------- ------------
99 * | GUARD | APPTAG | REFTAG |
100 * | 2B | 2B | 4B |
101 * -------- -------- ------------
102 */
103enum {
104 IB_SIG_CHECK_GUARD = 0xc0,
105 IB_SIG_CHECK_APPTAG = 0x30,
106 IB_SIG_CHECK_REFTAG = 0x0f,
107};
108
109/*
110 * struct ib_sig_err - signature error descriptor
111 */
112struct ib_sig_err {
113 enum ib_sig_err_type err_type;
114 u32 expected;
115 u32 actual;
116 u64 sig_err_offset;
117 u32 key;
118};
119
120#endif /* _RDMA_SIGNATURE_H_ */