1c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier/*
2c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier * Copyright (c) 2005 Cisco Systems. All rights reserved.
3c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier *
4c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier * This software is available to you under a choice of one of two
5c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier * licenses.  You may choose to be licensed under the terms of the GNU
6c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier * General Public License (GPL) Version 2, available from the file
7c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier * COPYING in the main directory of this source tree, or the
8c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier * OpenIB.org BSD license below:
9c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier *
10c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier *     Redistribution and use in source and binary forms, with or
11c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier *     without modification, are permitted provided that the following
12c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier *     conditions are met:
13c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier *
14c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier *      - Redistributions of source code must retain the above
15c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier *        copyright notice, this list of conditions and the following
16c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier *        disclaimer.
17c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier *
18c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier *      - Redistributions in binary form must reproduce the above
19c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier *        copyright notice, this list of conditions and the following
20c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier *        disclaimer in the documentation and/or other materials
21c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier *        provided with the distribution.
22c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier *
23c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier * SOFTWARE.
31c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier */
32c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier
33c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier#ifndef MTHCA_WQE_H
34c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier#define MTHCA_WQE_H
35c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier
36c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier#include <linux/types.h>
37c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier
38c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreierenum {
39680b575f6d1ae8aa39c4d7ee7e40b749d277fa9fEli Cohen	MTHCA_NEXT_DBD		= 1 << 7,
40680b575f6d1ae8aa39c4d7ee7e40b749d277fa9fEli Cohen	MTHCA_NEXT_FENCE	= 1 << 6,
41680b575f6d1ae8aa39c4d7ee7e40b749d277fa9fEli Cohen	MTHCA_NEXT_CQ_UPDATE	= 1 << 3,
42680b575f6d1ae8aa39c4d7ee7e40b749d277fa9fEli Cohen	MTHCA_NEXT_EVENT_GEN	= 1 << 2,
43680b575f6d1ae8aa39c4d7ee7e40b749d277fa9fEli Cohen	MTHCA_NEXT_SOLICIT	= 1 << 1,
44680b575f6d1ae8aa39c4d7ee7e40b749d277fa9fEli Cohen	MTHCA_NEXT_IP_CSUM	= 1 << 4,
45680b575f6d1ae8aa39c4d7ee7e40b749d277fa9fEli Cohen	MTHCA_NEXT_TCP_UDP_CSUM = 1 << 5,
46c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier
47680b575f6d1ae8aa39c4d7ee7e40b749d277fa9fEli Cohen	MTHCA_MLX_VL15		= 1 << 17,
48680b575f6d1ae8aa39c4d7ee7e40b749d277fa9fEli Cohen	MTHCA_MLX_SLR		= 1 << 16
49c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier};
50c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier
51c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreierenum {
52ae57e24a4006fd46b73d842ee99db9580ef74a02Michael S. Tsirkin	MTHCA_INVAL_LKEY			= 0x100,
53e0ae9ecf469fdd3c1ad999efbf4fe6b782f49900Michael S. Tsirkin	MTHCA_TAVOR_MAX_WQES_PER_RECV_DB	= 256,
54e0ae9ecf469fdd3c1ad999efbf4fe6b782f49900Michael S. Tsirkin	MTHCA_ARBEL_MAX_WQES_PER_SEND_DB	= 255
55c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier};
56c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier
57c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreierstruct mthca_next_seg {
58c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier	__be32 nda_op;		/* [31:6] next WQE [4:0] next opcode */
59c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier	__be32 ee_nds;		/* [31:8] next EE  [7] DBD [6] F [5:0] next WQE size */
60c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier	__be32 flags;		/* [3] CQ [2] Event [1] Solicit */
61c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier	__be32 imm;		/* immediate data */
62c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier};
63c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier
64c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreierstruct mthca_tavor_ud_seg {
65c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier	u32    reserved1;
66c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier	__be32 lkey;
67c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier	__be64 av_addr;
68c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier	u32    reserved2[4];
69c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier	__be32 dqpn;
70c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier	__be32 qkey;
71c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier	u32    reserved3[2];
72c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier};
73c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier
74c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreierstruct mthca_arbel_ud_seg {
75c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier	__be32 av[8];
76c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier	__be32 dqpn;
77c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier	__be32 qkey;
78c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier	u32    reserved[2];
79c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier};
80c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier
81c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreierstruct mthca_bind_seg {
82c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier	__be32 flags;		/* [31] Atomic [30] rem write [29] rem read */
83c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier	u32    reserved;
84c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier	__be32 new_rkey;
85c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier	__be32 lkey;
86c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier	__be64 addr;
87c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier	__be64 length;
88c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier};
89c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier
90c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreierstruct mthca_raddr_seg {
91c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier	__be64 raddr;
92c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier	__be32 rkey;
93c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier	u32    reserved;
94c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier};
95c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier
96c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreierstruct mthca_atomic_seg {
97c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier	__be64 swap_add;
98c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier	__be64 compare;
99c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier};
100c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier
101c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreierstruct mthca_data_seg {
102c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier	__be32 byte_count;
103c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier	__be32 lkey;
104c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier	__be64 addr;
105c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier};
106c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier
107c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreierstruct mthca_mlx_seg {
108c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier	__be32 nda_op;
109c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier	__be32 nds;
110c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier	__be32 flags;		/* [17] VL15 [16] SLR [14:12] static rate
111c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier				   [11:8] SL [3] C [2] E */
112c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier	__be16 rlid;
113c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier	__be16 vcrc;
114c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier};
115c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier
11680885456e844552044c8c5f1f9bf0f6773b187eaRoland Dreierstatic __always_inline void mthca_set_data_seg(struct mthca_data_seg *dseg,
11780885456e844552044c8c5f1f9bf0f6773b187eaRoland Dreier					       struct ib_sge *sg)
11880885456e844552044c8c5f1f9bf0f6773b187eaRoland Dreier{
11980885456e844552044c8c5f1f9bf0f6773b187eaRoland Dreier	dseg->byte_count = cpu_to_be32(sg->length);
12080885456e844552044c8c5f1f9bf0f6773b187eaRoland Dreier	dseg->lkey       = cpu_to_be32(sg->lkey);
12180885456e844552044c8c5f1f9bf0f6773b187eaRoland Dreier	dseg->addr       = cpu_to_be64(sg->addr);
12280885456e844552044c8c5f1f9bf0f6773b187eaRoland Dreier}
12380885456e844552044c8c5f1f9bf0f6773b187eaRoland Dreier
12480885456e844552044c8c5f1f9bf0f6773b187eaRoland Dreierstatic __always_inline void mthca_set_data_seg_inval(struct mthca_data_seg *dseg)
12580885456e844552044c8c5f1f9bf0f6773b187eaRoland Dreier{
12680885456e844552044c8c5f1f9bf0f6773b187eaRoland Dreier	dseg->byte_count = 0;
12780885456e844552044c8c5f1f9bf0f6773b187eaRoland Dreier	dseg->lkey       = cpu_to_be32(MTHCA_INVAL_LKEY);
12880885456e844552044c8c5f1f9bf0f6773b187eaRoland Dreier	dseg->addr       = 0;
12980885456e844552044c8c5f1f9bf0f6773b187eaRoland Dreier}
13080885456e844552044c8c5f1f9bf0f6773b187eaRoland Dreier
131c04bc3d1f417a8a90eef9ab46523dfd44858b28dRoland Dreier#endif /* MTHCA_WQE_H */
132