]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - sys/ofed/include/linux/mlx4/qp.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / sys / ofed / include / linux / mlx4 / qp.h
1 /*
2  * Copyright (c) 2007 Cisco Systems, Inc.  All rights reserved.
3  *
4  * This software is available to you under a choice of one of two
5  * licenses.  You may choose to be licensed under the terms of the GNU
6  * General Public License (GPL) Version 2, available from the file
7  * COPYING in the main directory of this source tree, or the
8  * OpenIB.org BSD license below:
9  *
10  *     Redistribution and use in source and binary forms, with or
11  *     without modification, are permitted provided that the following
12  *     conditions are met:
13  *
14  *      - Redistributions of source code must retain the above
15  *        copyright notice, this list of conditions and the following
16  *        disclaimer.
17  *
18  *      - Redistributions in binary form must reproduce the above
19  *        copyright notice, this list of conditions and the following
20  *        disclaimer in the documentation and/or other materials
21  *        provided with the distribution.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30  * SOFTWARE.
31  */
32
33 #ifndef MLX4_QP_H
34 #define MLX4_QP_H
35
36 #include <linux/types.h>
37
38 #include <linux/mlx4/device.h>
39
40 #define MLX4_INVALID_LKEY       0x100
41
42 enum ib_m_qp_attr_mask {
43         IB_M_EXT_CLASS_1 = 1 << 28,
44         IB_M_EXT_CLASS_2 = 1 << 29,
45         IB_M_EXT_CLASS_3 = 1 << 30,
46
47         IB_M_QP_MOD_VEND_MASK = (IB_M_EXT_CLASS_1 | IB_M_EXT_CLASS_2 |
48                                  IB_M_EXT_CLASS_3)
49 };
50
51 enum mlx4_qp_optpar {
52         MLX4_QP_OPTPAR_ALT_ADDR_PATH            = 1 << 0,
53         MLX4_QP_OPTPAR_RRE                      = 1 << 1,
54         MLX4_QP_OPTPAR_RAE                      = 1 << 2,
55         MLX4_QP_OPTPAR_RWE                      = 1 << 3,
56         MLX4_QP_OPTPAR_PKEY_INDEX               = 1 << 4,
57         MLX4_QP_OPTPAR_Q_KEY                    = 1 << 5,
58         MLX4_QP_OPTPAR_RNR_TIMEOUT              = 1 << 6,
59         MLX4_QP_OPTPAR_PRIMARY_ADDR_PATH        = 1 << 7,
60         MLX4_QP_OPTPAR_SRA_MAX                  = 1 << 8,
61         MLX4_QP_OPTPAR_RRA_MAX                  = 1 << 9,
62         MLX4_QP_OPTPAR_PM_STATE                 = 1 << 10,
63         MLX4_QP_OPTPAR_RETRY_COUNT              = 1 << 12,
64         MLX4_QP_OPTPAR_RNR_RETRY                = 1 << 13,
65         MLX4_QP_OPTPAR_ACK_TIMEOUT              = 1 << 14,
66         MLX4_QP_OPTPAR_SCHED_QUEUE              = 1 << 16,
67         MLX4_QP_OPTPAR_COUNTER_INDEX            = 1 << 20
68 };
69
70 enum mlx4_qp_state {
71         MLX4_QP_STATE_RST                       = 0,
72         MLX4_QP_STATE_INIT                      = 1,
73         MLX4_QP_STATE_RTR                       = 2,
74         MLX4_QP_STATE_RTS                       = 3,
75         MLX4_QP_STATE_SQER                      = 4,
76         MLX4_QP_STATE_SQD                       = 5,
77         MLX4_QP_STATE_ERR                       = 6,
78         MLX4_QP_STATE_SQ_DRAINING               = 7,
79         MLX4_QP_NUM_STATE
80 };
81
82 enum {
83         MLX4_QP_ST_RC                           = 0x0,
84         MLX4_QP_ST_UC                           = 0x1,
85         MLX4_QP_ST_RD                           = 0x2,
86         MLX4_QP_ST_UD                           = 0x3,
87         MLX4_QP_ST_XRC                          = 0x6,
88         MLX4_QP_ST_MLX                          = 0x7
89 };
90
91 enum {
92         MLX4_QP_PM_MIGRATED                     = 0x3,
93         MLX4_QP_PM_ARMED                        = 0x0,
94         MLX4_QP_PM_REARM                        = 0x1
95 };
96
97 enum {
98         /* params1 */
99         MLX4_QP_BIT_SRE                         = 1 << 15,
100         MLX4_QP_BIT_SWE                         = 1 << 14,
101         MLX4_QP_BIT_SAE                         = 1 << 13,
102         /* params2 */
103         MLX4_QP_BIT_RRE                         = 1 << 15,
104         MLX4_QP_BIT_RWE                         = 1 << 14,
105         MLX4_QP_BIT_RAE                         = 1 << 13,
106         MLX4_QP_BIT_RIC                         = 1 <<  4,
107         MLX4_QP_BIT_COLL_SYNC_RQ                = 1 <<  2,
108         MLX4_QP_BIT_COLL_SYNC_SQ                = 1 <<  1,
109         MLX4_QP_BIT_COLL_MASTER                 = 1 <<  0
110 };
111
112 enum {
113         MLX4_RSS_HASH_XOR                       = 0,
114         MLX4_RSS_HASH_TOP                       = 1,
115
116         MLX4_RSS_UDP_IPV6                       = 1 << 0,
117         MLX4_RSS_UDP_IPV4                       = 1 << 1,
118         MLX4_RSS_TCP_IPV6                       = 1 << 2,
119         MLX4_RSS_IPV6                           = 1 << 3,
120         MLX4_RSS_TCP_IPV4                       = 1 << 4,
121         MLX4_RSS_IPV4                           = 1 << 5,
122
123         /* offset of mlx4_rss_context within mlx4_qp_context.pri_path */
124         MLX4_RSS_OFFSET_IN_QPC_PRI_PATH         = 0x24,
125         /* offset of being RSS indirection QP within mlx4_qp_context.flags */
126         MLX4_RSS_QPC_FLAG_OFFSET                = 13,
127 };
128
129 struct mlx4_rss_context {
130         __be32                  base_qpn;
131         __be32                  default_qpn;
132         u16                     reserved;
133         u8                      hash_fn;
134         u8                      flags;
135         __be32                  rss_key[10];
136         __be32                  base_qpn_udp;
137 };
138
139 struct mlx4_qp_path {
140         u8                      fl;
141         u8                      reserved1[1];
142         u8                      disable_pkey_check;
143         u8                      pkey_index;
144         u8                      counter_index;
145         u8                      grh_mylmc;
146         __be16                  rlid;
147         u8                      ackto;
148         u8                      mgid_index;
149         u8                      static_rate;
150         u8                      hop_limit;
151         __be32                  tclass_flowlabel;
152         u8                      rgid[16];
153         u8                      sched_queue;
154         u8                      vlan_index;
155         u8                      feup;
156         u8                      reserved3;
157         u8                      reserved4[2];
158         u8                      dmac[6];
159 };
160
161 struct mlx4_qp_context {
162         __be32                  flags;
163         __be32                  pd;
164         u8                      mtu_msgmax;
165         u8                      rq_size_stride;
166         u8                      sq_size_stride;
167         u8                      rlkey;
168         __be32                  usr_page;
169         __be32                  local_qpn;
170         __be32                  remote_qpn;
171         struct                  mlx4_qp_path pri_path;
172         struct                  mlx4_qp_path alt_path;
173         __be32                  params1;
174         u32                     reserved1;
175         __be32                  next_send_psn;
176         __be32                  cqn_send;
177         u32                     reserved2[2];
178         __be32                  last_acked_psn;
179         __be32                  ssn;
180         __be32                  params2;
181         __be32                  rnr_nextrecvpsn;
182         __be32                  xrcd;
183         __be32                  cqn_recv;
184         __be64                  db_rec_addr;
185         __be32                  qkey;
186         __be32                  srqn;
187         __be32                  msn;
188         __be16                  rq_wqe_counter;
189         __be16                  sq_wqe_counter;
190         u32                     reserved3[2];
191         __be32                  param3;
192         __be32                  nummmcpeers_basemkey;
193         u8                      log_page_size;
194         u8                      reserved4[2];
195         u8                      mtt_base_addr_h;
196         __be32                  mtt_base_addr_l;
197         u32                     reserved5[10];
198 };
199
200 /* Which firmware version adds support for NEC (NoErrorCompletion) bit */
201 #define MLX4_FW_VER_WQE_CTRL_NEC mlx4_fw_ver(2, 2, 232)
202
203 enum {
204         MLX4_WQE_CTRL_NEC               = 1 << 29,
205         MLX4_WQE_CTRL_FENCE             = 1 << 6,
206         MLX4_WQE_CTRL_CQ_UPDATE         = 3 << 2,
207         MLX4_WQE_CTRL_SOLICITED         = 1 << 1,
208         MLX4_WQE_CTRL_IP_CSUM           = 1 << 4,
209         MLX4_WQE_CTRL_TCP_UDP_CSUM      = 1 << 5,
210         MLX4_WQE_CTRL_INS_VLAN          = 1 << 6,
211         MLX4_WQE_CTRL_STRONG_ORDER      = 1 << 7,
212         MLX4_WQE_CTRL_FORCE_LOOPBACK    = 1 << 0,
213 };
214
215 struct mlx4_wqe_ctrl_seg {
216         __be32                  owner_opcode;
217         __be16                  vlan_tag;
218         u8                      ins_vlan;
219         u8                      fence_size;
220         /*
221          * High 24 bits are SRC remote buffer; low 8 bits are flags:
222          * [7]   SO (strong ordering)
223          * [5]   TCP/UDP checksum
224          * [4]   IP checksum
225          * [3:2] C (generate completion queue entry)
226          * [1]   SE (solicited event)
227          * [0]   FL (force loopback)
228          */
229         union {
230                 __be32                  srcrb_flags;
231                 __be16                  srcrb_flags16[2];
232         };
233         /*
234          * imm is immediate data for send/RDMA write w/ immediate;
235          * also invalidation key for send with invalidate; input
236          * modifier for WQEs on CCQs.
237          */
238         __be32                  imm;
239 };
240
241 enum {
242         MLX4_WQE_MLX_VL15       = 1 << 17,
243         MLX4_WQE_MLX_SLR        = 1 << 16
244 };
245
246 struct mlx4_wqe_mlx_seg {
247         u8                      owner;
248         u8                      reserved1[2];
249         u8                      opcode;
250         __be16                  sched_prio;
251         u8                      reserved2;
252         u8                      size;
253         /*
254          * [17]    VL15
255          * [16]    SLR
256          * [15:12] static rate
257          * [11:8]  SL
258          * [4]     ICRC
259          * [3:2]   C
260          * [0]     FL (force loopback)
261          */
262         __be32                  flags;
263         __be16                  rlid;
264         u16                     reserved3;
265 };
266
267 struct mlx4_wqe_datagram_seg {
268         __be32                  av[8];
269         __be32                  dqpn;
270         __be32                  qkey;
271         __be16                  vlan;
272         u8                      mac[6];
273 };
274
275 struct mlx4_wqe_lso_seg {
276         __be32                  mss_hdr_size;
277         __be32                  header[0];
278 };
279
280 struct mlx4_wqe_bind_seg {
281         __be32                  flags1;
282         __be32                  flags2;
283         __be32                  new_rkey;
284         __be32                  lkey;
285         __be64                  addr;
286         __be64                  length;
287 };
288
289 enum {
290         MLX4_WQE_FMR_PERM_LOCAL_READ    = 1 << 27,
291         MLX4_WQE_FMR_PERM_LOCAL_WRITE   = 1 << 28,
292         MLX4_WQE_FMR_PERM_REMOTE_READ   = 1 << 29,
293         MLX4_WQE_FMR_PERM_REMOTE_WRITE  = 1 << 30,
294         MLX4_WQE_FMR_PERM_ATOMIC        = 1 << 31
295 };
296
297 struct mlx4_wqe_fmr_seg {
298         __be32                  flags;
299         __be32                  mem_key;
300         __be64                  buf_list;
301         __be64                  start_addr;
302         __be64                  reg_len;
303         __be32                  offset;
304         __be32                  page_size;
305         u32                     reserved[2];
306 };
307
308 struct mlx4_wqe_fmr_ext_seg {
309         u8                      flags;
310         u8                      reserved;
311         __be16                  app_mask;
312         __be16                  wire_app_tag;
313         __be16                  mem_app_tag;
314         __be32                  wire_ref_tag_base;
315         __be32                  mem_ref_tag_base;
316 };
317
318 struct mlx4_wqe_local_inval_seg {
319         __be32                  flags;
320         u32                     reserved1;
321         __be32                  mem_key;
322         u32                     reserved2[2];
323         __be32                  guest_id;
324         __be64                  pa;
325 };
326
327 struct mlx4_wqe_raddr_seg {
328         __be64                  raddr;
329         __be32                  rkey;
330         u32                     reserved;
331 };
332
333 struct mlx4_wqe_atomic_seg {
334         __be64                  swap_add;
335         __be64                  compare;
336 };
337
338 struct mlx4_wqe_masked_atomic_seg {
339         __be64                  swap_add;
340         __be64                  compare;
341         __be64                  swap_add_mask;
342         __be64                  compare_mask;
343 };
344
345 struct mlx4_wqe_data_seg {
346         __be32                  byte_count;
347         __be32                  lkey;
348         __be64                  addr;
349 };
350
351 enum {
352         MLX4_INLINE_ALIGN       = 64,
353         MLX4_INLINE_SEG         = 1 << 31,
354 };
355
356 struct mlx4_wqe_inline_seg {
357         __be32                  byte_count;
358 };
359
360 int mlx4_qp_modify(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
361                    enum mlx4_qp_state cur_state, enum mlx4_qp_state new_state,
362                    struct mlx4_qp_context *context, enum mlx4_qp_optpar optpar,
363                    int sqd_event, struct mlx4_qp *qp);
364
365 int mlx4_qp_query(struct mlx4_dev *dev, struct mlx4_qp *qp,
366                   struct mlx4_qp_context *context);
367
368 int mlx4_qp_to_ready(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
369                      struct mlx4_qp_context *context,
370                      struct mlx4_qp *qp, enum mlx4_qp_state *qp_state);
371
372 static inline struct mlx4_qp *__mlx4_qp_lookup(struct mlx4_dev *dev, u32 qpn)
373 {
374         return radix_tree_lookup(&dev->qp_table_tree, qpn & (dev->caps.num_qps - 1));
375 }
376
377 void mlx4_qp_remove(struct mlx4_dev *dev, struct mlx4_qp *qp);
378
379 #endif /* MLX4_QP_H */