aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/ehca/ehca_qes.h
blob: 8707d297ce4c60a1747424068599e220d194b10d (plain) (blame)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
/*
 *  IBM eServer eHCA Infiniband device driver for Linux on POWER
 *
 *  Hardware request structures
 *
 *  Authors: Waleri Fomin <fomin@de.ibm.com>
 *           Reinhard Ernst <rernst@de.ibm.com>
 *           Christoph Raisch <raisch@de.ibm.com>
 *
 *  Copyright (c) 2005 IBM Corporation
 *
 *  All rights reserved.
 *
 *  This source code is distributed under a dual license of GPL v2.0 and OpenIB
 *  BSD.
 *
 * OpenIB BSD License
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimer.
 *
 * Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials
 * provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */


#ifndef _EHCA_QES_H_
#define _EHCA_QES_H_

#include "ehca_tools.h"

/* virtual scatter gather entry to specify remote adresses with length */
struct ehca_vsgentry {
	u64 vaddr;
	u32 lkey;
	u32 length;
};

#define GRH_FLAG_MASK        EHCA_BMASK_IBM(7,7)
#define GRH_IPVERSION_MASK   EHCA_BMASK_IBM(0,3)
#define GRH_TCLASS_MASK      EHCA_BMASK_IBM(4,12)
#define GRH_FLOWLABEL_MASK   EHCA_BMASK_IBM(13,31)
#define GRH_PAYLEN_MASK      EHCA_BMASK_IBM(32,47)
#define GRH_NEXTHEADER_MASK  EHCA_BMASK_IBM(48,55)
#define GRH_HOPLIMIT_MASK    EHCA_BMASK_IBM(56,63)

/*
 * Unreliable Datagram Address Vector Format
 * see IBTA Vol1 chapter 8.3 Global Routing Header
 */
struct ehca_ud_av {
	u8 sl;
	u8 lnh;
	u16 dlid;
	u8 reserved1;
	u8 reserved2;
	u8 reserved3;
	u8 slid_path_bits;
	u8 reserved4;
	u8 ipd;
	u8 reserved5;
	u8 pmtu;
	u32 reserved6;
	u64 reserved7;
	union {
		struct {
			u64 word_0; /* always set to 6  */
			/*should be 0x1B for IB transport */
			u64 word_1;
			u64 word_2;
			u64 word_3;
			u64 word_4;
		} grh;
		struct {
			u32 wd_0;
			u32 wd_1;
			/* DWord_1 --> SGID */

			u32 sgid_wd3;
			u32 sgid_wd2;

			u32 sgid_wd1;
			u32 sgid_wd0;
			/* DWord_3 --> DGID */

			u32 dgid_wd3;
			u32 dgid_wd2;

			u32 dgid_wd1;
			u32 dgid_wd0;
		} grh_l;
	};
};

/* maximum number of sg entries allowed in a WQE */
#define MAX_WQE_SG_ENTRIES 252

#define WQE_OPTYPE_SEND             0x80
#define WQE_OPTYPE_RDMAREAD         0x40
#define WQE_OPTYPE_RDMAWRITE        0x20
#define WQE_OPTYPE_CMPSWAP          0x10
#define WQE_OPTYPE_FETCHADD         0x08
#define WQE_OPTYPE_BIND             0x04

#define WQE_WRFLAG_REQ_SIGNAL_COM   0x80
#define WQE_WRFLAG_FENCE            0x40
#define WQE_WRFLAG_IMM_DATA_PRESENT 0x20
#define WQE_WRFLAG_SOLIC_EVENT      0x10

#define WQEF_CACHE_HINT             0x80
#define WQEF_CACHE_HINT_RD_WR       0x40
#define WQEF_TIMED_WQE              0x20
#define WQEF_PURGE                  0x08
#define WQEF_HIGH_NIBBLE            0xF0

#define MW_BIND_ACCESSCTRL_R_WRITE   0x40
#define MW_BIND_ACCESSCTRL_R_READ    0x20
#define MW_BIND_ACCESSCTRL_R_ATOMIC  0x10

struct ehca_wqe {
	u64 work_request_id;
	u8 optype;
	u8 wr_flag;
	u16 pkeyi;
	u8 wqef;
	u8 nr_of_data_seg;
	u16 wqe_provided_slid;
	u32 destination_qp_number;
	u32 resync_psn_sqp;
	u32 local_ee_context_qkey;
	u32 immediate_data;
	union {
		struct {
			u64 remote_virtual_adress;
			u32 rkey;
			u32 reserved;
			u64 atomic_1st_op_dma_len;
			u64 atomic_2nd_op;
			struct ehca_vsgentry sg_list[MAX_WQE_SG_ENTRIES];

		} nud;
		struct {
			u64 ehca_ud_av_ptr;
			u64 reserved1;
			u64 reserved2;
			u64 reserved3;
			struct ehca_vsgentry sg_list[MAX_WQE_SG_ENTRIES];
		} ud_avp;
		struct {
			struct ehca_ud_av ud_av;
			struct ehca_vsgentry sg_list[MAX_WQE_SG_ENTRIES -
						     2];
		} ud_av;
		struct {
			u64 reserved0;
			u64 reserved1;
			u64 reserved2;
			u64 reserved3;
			struct ehca_vsgentry sg_list[MAX_WQE_SG_ENTRIES];
		} all_rcv;

		struct {
			u64 reserved;
			u32 rkey;
			u32 old_rkey;
			u64 reserved1;
			u64 reserved2;
			u64 virtual_address;
			u32 reserved3;
			u32 length;
			u32 reserved4;
			u16 reserved5;
			u8 reserved6;
			u8 lr_ctl;
			u32 lkey;
			u32 reserved7;
			u64 reserved8;
			u64 reserved9;
			u64 reserved10;
			u64 reserved11;
		} bind;
		struct {
			u64 reserved12;
			u64 reserved13;
			u32 size;
			u32 start;
		} inline_data;
	} u;

};

#define WC_SEND_RECEIVE EHCA_BMASK_IBM(0,0)
#define WC_IMM_DATA     EHCA_BMASK_IBM(1,1)
#define WC_GRH_PRESENT  EHCA_BMASK_IBM(2,2)
#define WC_SE_BIT       EHCA_BMASK_IBM(3,3)
#define WC_STATUS_ERROR_BIT 0x80000000
#define WC_STATUS_REMOTE_ERROR_FLAGS 0x0000F800
#define WC_STATUS_PURGE_BIT 0x10

struct ehca_cqe {
	u64 work_request_id;
	u8 optype;
	u8 w_completion_flags;
	u16 reserved1;
	u32 nr_bytes_transferred;
	u32 immediate_data;
	u32 local_qp_number;
	u8 freed_resource_count;
	u8 service_level;
	u16 wqe_count;
	u32 qp_token;
	u32 qkey_ee_token;
	u32 remote_qp_number;
	u16 dlid;
	u16 rlid;
	u16 reserved2;
	u16 pkey_index;
	u32 cqe_timestamp;
	u32 wqe_timestamp;
	u8 wqe_timestamp_valid;
	u8 reserved3;
	u8 reserved4;
	u8 cqe_flags;
	u32 status;
};

struct ehca_eqe {
	u64 entry;
};

struct ehca_mrte {
	u64 starting_va;
	u64 length; /* length of memory region in bytes*/
	u32 pd;
	u8 key_instance;
	u8 pagesize;
	u8 mr_control;
	u8 local_remote_access_ctrl;
	u8 reserved[0x20 - 0x18];
	u64 at_pointer[4];
};
#endif /*_EHCA_QES_H_*/