1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48#ifndef IB_HDRS_H
49#define IB_HDRS_H
50
51#include <linux/types.h>
52#include <asm/unaligned.h>
53#include <rdma/ib_verbs.h>
54
55#define IB_SEQ_NAK (3 << 29)
56
57
58#define IB_RNR_NAK 0x20
59#define IB_NAK_PSN_ERROR 0x60
60#define IB_NAK_INVALID_REQUEST 0x61
61#define IB_NAK_REMOTE_ACCESS_ERROR 0x62
62#define IB_NAK_REMOTE_OPERATIONAL_ERROR 0x63
63#define IB_NAK_INVALID_RD_REQUEST 0x64
64
65#define IB_BTH_REQ_ACK BIT(31)
66#define IB_BTH_SOLICITED BIT(23)
67#define IB_BTH_MIG_REQ BIT(22)
68
69#define IB_GRH_VERSION 6
70#define IB_GRH_VERSION_MASK 0xF
71#define IB_GRH_VERSION_SHIFT 28
72#define IB_GRH_TCLASS_MASK 0xFF
73#define IB_GRH_TCLASS_SHIFT 20
74#define IB_GRH_FLOW_MASK 0xFFFFF
75#define IB_GRH_FLOW_SHIFT 0
76#define IB_GRH_NEXT_HDR 0x1B
77
78#define IB_AETH_CREDIT_SHIFT 24
79#define IB_AETH_CREDIT_MASK 0x1F
80#define IB_AETH_CREDIT_INVAL 0x1F
81#define IB_AETH_NAK_SHIFT 29
82#define IB_MSN_MASK 0xFFFFFF
83
84struct ib_reth {
85 __be64 vaddr;
86 __be32 rkey;
87 __be32 length;
88} __packed;
89
90struct ib_atomic_eth {
91 __be64 vaddr;
92 __be32 rkey;
93 __be64 swap_data;
94 __be64 compare_data;
95} __packed;
96
97union ib_ehdrs {
98 struct {
99 __be32 deth[2];
100 __be32 imm_data;
101 } ud;
102 struct {
103 struct ib_reth reth;
104 __be32 imm_data;
105 } rc;
106 struct {
107 __be32 aeth;
108 __be64 atomic_ack_eth;
109 } __packed at;
110 __be32 imm_data;
111 __be32 aeth;
112 __be32 ieth;
113 struct ib_atomic_eth atomic_eth;
114} __packed;
115
116struct ib_other_headers {
117 __be32 bth[3];
118 union ib_ehdrs u;
119} __packed;
120
121struct ib_header {
122 __be16 lrh[4];
123 union {
124 struct {
125 struct ib_grh grh;
126 struct ib_other_headers oth;
127 } l;
128 struct ib_other_headers oth;
129 } u;
130} __packed;
131
132
133
134static inline u64 ib_u64_get(__be64 *p)
135{
136 return get_unaligned_be64(p);
137}
138
139static inline void ib_u64_put(u64 val, __be64 *p)
140{
141 put_unaligned_be64(val, p);
142}
143
144static inline u64 get_ib_reth_vaddr(struct ib_reth *reth)
145{
146 return ib_u64_get(&reth->vaddr);
147}
148
149static inline void put_ib_reth_vaddr(u64 val, struct ib_reth *reth)
150{
151 ib_u64_put(val, &reth->vaddr);
152}
153
154static inline u64 get_ib_ateth_vaddr(struct ib_atomic_eth *ateth)
155{
156 return ib_u64_get(&ateth->vaddr);
157}
158
159static inline void put_ib_ateth_vaddr(u64 val, struct ib_atomic_eth *ateth)
160{
161 ib_u64_put(val, &ateth->vaddr);
162}
163
164static inline u64 get_ib_ateth_swap(struct ib_atomic_eth *ateth)
165{
166 return ib_u64_get(&ateth->swap_data);
167}
168
169static inline void put_ib_ateth_swap(u64 val, struct ib_atomic_eth *ateth)
170{
171 ib_u64_put(val, &ateth->swap_data);
172}
173
174static inline u64 get_ib_ateth_compare(struct ib_atomic_eth *ateth)
175{
176 return ib_u64_get(&ateth->compare_data);
177}
178
179static inline void put_ib_ateth_compare(u64 val, struct ib_atomic_eth *ateth)
180{
181 ib_u64_put(val, &ateth->compare_data);
182}
183
184#endif
185