2 * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
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:
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
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.
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
36 #include <linux/types.h>
38 #include <linux/mlx4/device.h>
40 #define MLX4_INVALID_LKEY 0x100
43 MLX4_QP_OPTPAR_ALT_ADDR_PATH = 1 << 0,
44 MLX4_QP_OPTPAR_RRE = 1 << 1,
45 MLX4_QP_OPTPAR_RAE = 1 << 2,
46 MLX4_QP_OPTPAR_RWE = 1 << 3,
47 MLX4_QP_OPTPAR_PKEY_INDEX = 1 << 4,
48 MLX4_QP_OPTPAR_Q_KEY = 1 << 5,
49 MLX4_QP_OPTPAR_RNR_TIMEOUT = 1 << 6,
50 MLX4_QP_OPTPAR_PRIMARY_ADDR_PATH = 1 << 7,
51 MLX4_QP_OPTPAR_SRA_MAX = 1 << 8,
52 MLX4_QP_OPTPAR_RRA_MAX = 1 << 9,
53 MLX4_QP_OPTPAR_PM_STATE = 1 << 10,
54 MLX4_QP_OPTPAR_RETRY_COUNT = 1 << 12,
55 MLX4_QP_OPTPAR_RNR_RETRY = 1 << 13,
56 MLX4_QP_OPTPAR_ACK_TIMEOUT = 1 << 14,
57 MLX4_QP_OPTPAR_SCHED_QUEUE = 1 << 16,
58 MLX4_QP_OPTPAR_COUNTER_INDEX = 1 << 20
62 MLX4_QP_STATE_RST = 0,
63 MLX4_QP_STATE_INIT = 1,
64 MLX4_QP_STATE_RTR = 2,
65 MLX4_QP_STATE_RTS = 3,
66 MLX4_QP_STATE_SQER = 4,
67 MLX4_QP_STATE_SQD = 5,
68 MLX4_QP_STATE_ERR = 6,
69 MLX4_QP_STATE_SQ_DRAINING = 7,
83 MLX4_QP_PM_MIGRATED = 0x3,
84 MLX4_QP_PM_ARMED = 0x0,
85 MLX4_QP_PM_REARM = 0x1
90 MLX4_QP_BIT_SRE = 1 << 15,
91 MLX4_QP_BIT_SWE = 1 << 14,
92 MLX4_QP_BIT_SAE = 1 << 13,
94 MLX4_QP_BIT_RRE = 1 << 15,
95 MLX4_QP_BIT_RWE = 1 << 14,
96 MLX4_QP_BIT_RAE = 1 << 13,
97 MLX4_QP_BIT_RIC = 1 << 4,
101 MLX4_RSS_HASH_XOR = 0,
102 MLX4_RSS_HASH_TOP = 1,
104 MLX4_RSS_UDP_IPV6 = 1 << 0,
105 MLX4_RSS_UDP_IPV4 = 1 << 1,
106 MLX4_RSS_TCP_IPV6 = 1 << 2,
107 MLX4_RSS_IPV6 = 1 << 3,
108 MLX4_RSS_TCP_IPV4 = 1 << 4,
109 MLX4_RSS_IPV4 = 1 << 5,
111 /* offset of mlx4_rss_context within mlx4_qp_context.pri_path */
112 MLX4_RSS_OFFSET_IN_QPC_PRI_PATH = 0x24,
113 /* offset of being RSS indirection QP within mlx4_qp_context.flags */
114 MLX4_RSS_QPC_FLAG_OFFSET = 13,
117 struct mlx4_rss_context {
127 struct mlx4_qp_path {
130 u8 disable_pkey_check;
139 __be32 tclass_flowlabel;
151 MLX4_FL_ETH_HIDE_CQE_VLAN = 1 << 2
153 enum { /* vlan_control */
154 MLX4_VLAN_CTRL_ETH_TX_BLOCK_TAGGED = 1 << 6,
155 MLX4_VLAN_CTRL_ETH_RX_BLOCK_TAGGED = 1 << 2,
156 MLX4_VLAN_CTRL_ETH_RX_BLOCK_PRIO_TAGGED = 1 << 1, /* 802.1p priority tag */
157 MLX4_VLAN_CTRL_ETH_RX_BLOCK_UNTAGGED = 1 << 0
161 MLX4_FEUP_FORCE_ETH_UP = 1 << 6, /* force Eth UP */
162 MLX4_FSM_FORCE_ETH_SRC_MAC = 1 << 5, /* force Source MAC */
163 MLX4_FVL_FORCE_ETH_VLAN = 1 << 3 /* force Eth vlan */
167 MLX4_FVL_RX_FORCE_ETH_VLAN = 1 << 0 /* enforce Eth rx vlan */
170 struct mlx4_qp_context {
180 struct mlx4_qp_path pri_path;
181 struct mlx4_qp_path alt_path;
184 __be32 next_send_psn;
187 __be32 last_acked_psn;
190 __be32 rnr_nextrecvpsn;
197 __be16 rq_wqe_counter;
198 __be16 sq_wqe_counter;
201 __be32 nummmcpeers_basemkey;
205 __be32 mtt_base_addr_l;
210 MLX4_STRIP_VLAN = 1 << 30
213 /* Which firmware version adds support for NEC (NoErrorCompletion) bit */
214 #define MLX4_FW_VER_WQE_CTRL_NEC mlx4_fw_ver(2, 2, 232)
217 MLX4_WQE_CTRL_NEC = 1 << 29,
218 MLX4_WQE_CTRL_FENCE = 1 << 6,
219 MLX4_WQE_CTRL_CQ_UPDATE = 3 << 2,
220 MLX4_WQE_CTRL_SOLICITED = 1 << 1,
221 MLX4_WQE_CTRL_IP_CSUM = 1 << 4,
222 MLX4_WQE_CTRL_TCP_UDP_CSUM = 1 << 5,
223 MLX4_WQE_CTRL_INS_VLAN = 1 << 6,
224 MLX4_WQE_CTRL_STRONG_ORDER = 1 << 7,
225 MLX4_WQE_CTRL_FORCE_LOOPBACK = 1 << 0,
228 struct mlx4_wqe_ctrl_seg {
234 * High 24 bits are SRC remote buffer; low 8 bits are flags:
235 * [7] SO (strong ordering)
236 * [5] TCP/UDP checksum
238 * [3:2] C (generate completion queue entry)
239 * [1] SE (solicited event)
240 * [0] FL (force loopback)
244 __be16 srcrb_flags16[2];
247 * imm is immediate data for send/RDMA write w/ immediate;
248 * also invalidation key for send with invalidate; input
249 * modifier for WQEs on CCQs.
255 MLX4_WQE_MLX_VL15 = 1 << 17,
256 MLX4_WQE_MLX_SLR = 1 << 16
259 struct mlx4_wqe_mlx_seg {
269 * [15:12] static rate
273 * [0] FL (force loopback)
280 struct mlx4_wqe_datagram_seg {
288 struct mlx4_wqe_lso_seg {
293 enum mlx4_wqe_bind_seg_flags2 {
294 MLX4_WQE_BIND_ZERO_BASED = (1 << 30),
295 MLX4_WQE_BIND_TYPE_2 = (1 << 31),
298 struct mlx4_wqe_bind_seg {
308 MLX4_WQE_FMR_PERM_LOCAL_READ = 1 << 27,
309 MLX4_WQE_FMR_PERM_LOCAL_WRITE = 1 << 28,
310 MLX4_WQE_FMR_AND_BIND_PERM_REMOTE_READ = 1 << 29,
311 MLX4_WQE_FMR_AND_BIND_PERM_REMOTE_WRITE = 1 << 30,
312 MLX4_WQE_FMR_AND_BIND_PERM_ATOMIC = 1 << 31
315 struct mlx4_wqe_fmr_seg {
326 struct mlx4_wqe_fmr_ext_seg {
332 __be32 wire_ref_tag_base;
333 __be32 mem_ref_tag_base;
336 struct mlx4_wqe_local_inval_seg {
343 struct mlx4_wqe_raddr_seg {
349 struct mlx4_wqe_atomic_seg {
354 struct mlx4_wqe_masked_atomic_seg {
357 __be64 swap_add_mask;
361 struct mlx4_wqe_data_seg {
368 MLX4_INLINE_ALIGN = 64,
369 MLX4_INLINE_SEG = 1 << 31,
372 struct mlx4_wqe_inline_seg {
376 int mlx4_qp_modify(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
377 enum mlx4_qp_state cur_state, enum mlx4_qp_state new_state,
378 struct mlx4_qp_context *context, enum mlx4_qp_optpar optpar,
379 int sqd_event, struct mlx4_qp *qp);
381 int mlx4_qp_query(struct mlx4_dev *dev, struct mlx4_qp *qp,
382 struct mlx4_qp_context *context);
384 int mlx4_qp_to_ready(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
385 struct mlx4_qp_context *context,
386 struct mlx4_qp *qp, enum mlx4_qp_state *qp_state);
388 static inline struct mlx4_qp *__mlx4_qp_lookup(struct mlx4_dev *dev, u32 qpn)
390 return radix_tree_lookup(&dev->qp_table_tree, qpn & (dev->caps.num_qps - 1));
393 void mlx4_qp_remove(struct mlx4_dev *dev, struct mlx4_qp *qp);
395 #endif /* MLX4_QP_H */