1329222Shselasky/*
2329222Shselasky * Copyright (c) 2005 Cisco Systems. All rights reserved.
3329222Shselasky *
4329222Shselasky * This software is available to you under a choice of one of two
5329222Shselasky * licenses.  You may choose to be licensed under the terms of the GNU
6329222Shselasky * General Public License (GPL) Version 2, available from the file
7329222Shselasky * COPYING in the main directory of this source tree, or the
8329222Shselasky * OpenIB.org BSD license below:
9329222Shselasky *
10329222Shselasky *     Redistribution and use in source and binary forms, with or
11329222Shselasky *     without modification, are permitted provided that the following
12329222Shselasky *     conditions are met:
13329222Shselasky *
14329222Shselasky *      - Redistributions of source code must retain the above
15329222Shselasky *        copyright notice, this list of conditions and the following
16329222Shselasky *        disclaimer.
17329222Shselasky *
18329222Shselasky *      - Redistributions in binary form must reproduce the above
19329222Shselasky *        copyright notice, this list of conditions and the following
20329222Shselasky *        disclaimer in the documentation and/or other materials
21329222Shselasky *        provided with the distribution.
22329222Shselasky *
23329222Shselasky * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24329222Shselasky * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25329222Shselasky * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26329222Shselasky * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27329222Shselasky * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28329222Shselasky * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29329222Shselasky * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30329222Shselasky * SOFTWARE.
31329222Shselasky */
32329222Shselasky
33329222Shselasky#ifndef MTHCA_WQE_H
34329222Shselasky#define MTHCA_WQE_H
35329222Shselasky
36329222Shselasky#include <linux/types.h>
37329222Shselasky
38329222Shselaskyenum {
39329222Shselasky	MTHCA_NEXT_DBD		= 1 << 7,
40329222Shselasky	MTHCA_NEXT_FENCE	= 1 << 6,
41329222Shselasky	MTHCA_NEXT_CQ_UPDATE	= 1 << 3,
42329222Shselasky	MTHCA_NEXT_EVENT_GEN	= 1 << 2,
43329222Shselasky	MTHCA_NEXT_SOLICIT	= 1 << 1,
44329222Shselasky	MTHCA_NEXT_IP_CSUM	= 1 << 4,
45329222Shselasky	MTHCA_NEXT_TCP_UDP_CSUM = 1 << 5,
46329222Shselasky
47329222Shselasky	MTHCA_MLX_VL15		= 1 << 17,
48329222Shselasky	MTHCA_MLX_SLR		= 1 << 16
49329222Shselasky};
50329222Shselasky
51329222Shselaskyenum {
52329222Shselasky	MTHCA_INVAL_LKEY			= 0x100,
53329222Shselasky	MTHCA_TAVOR_MAX_WQES_PER_RECV_DB	= 256,
54329222Shselasky	MTHCA_ARBEL_MAX_WQES_PER_SEND_DB	= 255
55329222Shselasky};
56329222Shselasky
57329222Shselaskystruct mthca_next_seg {
58329222Shselasky	__be32 nda_op;		/* [31:6] next WQE [4:0] next opcode */
59329222Shselasky	__be32 ee_nds;		/* [31:8] next EE  [7] DBD [6] F [5:0] next WQE size */
60329222Shselasky	__be32 flags;		/* [3] CQ [2] Event [1] Solicit */
61329222Shselasky	__be32 imm;		/* immediate data */
62329222Shselasky};
63329222Shselasky
64329222Shselaskystruct mthca_tavor_ud_seg {
65329222Shselasky	u32    reserved1;
66329222Shselasky	__be32 lkey;
67329222Shselasky	__be64 av_addr;
68329222Shselasky	u32    reserved2[4];
69329222Shselasky	__be32 dqpn;
70329222Shselasky	__be32 qkey;
71329222Shselasky	u32    reserved3[2];
72329222Shselasky};
73329222Shselasky
74329222Shselaskystruct mthca_arbel_ud_seg {
75329222Shselasky	__be32 av[8];
76329222Shselasky	__be32 dqpn;
77329222Shselasky	__be32 qkey;
78329222Shselasky	u32    reserved[2];
79329222Shselasky};
80329222Shselasky
81329222Shselaskystruct mthca_bind_seg {
82329222Shselasky	__be32 flags;		/* [31] Atomic [30] rem write [29] rem read */
83329222Shselasky	u32    reserved;
84329222Shselasky	__be32 new_rkey;
85329222Shselasky	__be32 lkey;
86329222Shselasky	__be64 addr;
87329222Shselasky	__be64 length;
88329222Shselasky};
89329222Shselasky
90329222Shselaskystruct mthca_raddr_seg {
91329222Shselasky	__be64 raddr;
92329222Shselasky	__be32 rkey;
93329222Shselasky	u32    reserved;
94329222Shselasky};
95329222Shselasky
96329222Shselaskystruct mthca_atomic_seg {
97329222Shselasky	__be64 swap_add;
98329222Shselasky	__be64 compare;
99329222Shselasky};
100329222Shselasky
101329222Shselaskystruct mthca_data_seg {
102329222Shselasky	__be32 byte_count;
103329222Shselasky	__be32 lkey;
104329222Shselasky	__be64 addr;
105329222Shselasky};
106329222Shselasky
107329222Shselaskystruct mthca_mlx_seg {
108329222Shselasky	__be32 nda_op;
109329222Shselasky	__be32 nds;
110329222Shselasky	__be32 flags;		/* [17] VL15 [16] SLR [14:12] static rate
111329222Shselasky				   [11:8] SL [3] C [2] E */
112329222Shselasky	__be16 rlid;
113329222Shselasky	__be16 vcrc;
114329222Shselasky};
115329222Shselasky
116329222Shselaskystatic __always_inline void mthca_set_data_seg(struct mthca_data_seg *dseg,
117329222Shselasky					       struct ib_sge *sg)
118329222Shselasky{
119329222Shselasky	dseg->byte_count = cpu_to_be32(sg->length);
120329222Shselasky	dseg->lkey       = cpu_to_be32(sg->lkey);
121329222Shselasky	dseg->addr       = cpu_to_be64(sg->addr);
122329222Shselasky}
123329222Shselasky
124329222Shselaskystatic __always_inline void mthca_set_data_seg_inval(struct mthca_data_seg *dseg)
125329222Shselasky{
126329222Shselasky	dseg->byte_count = 0;
127329222Shselasky	dseg->lkey       = cpu_to_be32(MTHCA_INVAL_LKEY);
128329222Shselasky	dseg->addr       = 0;
129329222Shselasky}
130329222Shselasky
131329222Shselasky#endif /* MTHCA_WQE_H */
132