162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * Copyright (c) 2005 Cisco Systems. All rights reserved.
362306a36Sopenharmony_ci *
462306a36Sopenharmony_ci * This software is available to you under a choice of one of two
562306a36Sopenharmony_ci * licenses.  You may choose to be licensed under the terms of the GNU
662306a36Sopenharmony_ci * General Public License (GPL) Version 2, available from the file
762306a36Sopenharmony_ci * COPYING in the main directory of this source tree, or the
862306a36Sopenharmony_ci * OpenIB.org BSD license below:
962306a36Sopenharmony_ci *
1062306a36Sopenharmony_ci *     Redistribution and use in source and binary forms, with or
1162306a36Sopenharmony_ci *     without modification, are permitted provided that the following
1262306a36Sopenharmony_ci *     conditions are met:
1362306a36Sopenharmony_ci *
1462306a36Sopenharmony_ci *      - Redistributions of source code must retain the above
1562306a36Sopenharmony_ci *        copyright notice, this list of conditions and the following
1662306a36Sopenharmony_ci *        disclaimer.
1762306a36Sopenharmony_ci *
1862306a36Sopenharmony_ci *      - Redistributions in binary form must reproduce the above
1962306a36Sopenharmony_ci *        copyright notice, this list of conditions and the following
2062306a36Sopenharmony_ci *        disclaimer in the documentation and/or other materials
2162306a36Sopenharmony_ci *        provided with the distribution.
2262306a36Sopenharmony_ci *
2362306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2462306a36Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2562306a36Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
2662306a36Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
2762306a36Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
2862306a36Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
2962306a36Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3062306a36Sopenharmony_ci * SOFTWARE.
3162306a36Sopenharmony_ci */
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci#ifndef MTHCA_WQE_H
3462306a36Sopenharmony_ci#define MTHCA_WQE_H
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ci#include <linux/types.h>
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_cienum {
3962306a36Sopenharmony_ci	MTHCA_NEXT_DBD		= 1 << 7,
4062306a36Sopenharmony_ci	MTHCA_NEXT_FENCE	= 1 << 6,
4162306a36Sopenharmony_ci	MTHCA_NEXT_CQ_UPDATE	= 1 << 3,
4262306a36Sopenharmony_ci	MTHCA_NEXT_EVENT_GEN	= 1 << 2,
4362306a36Sopenharmony_ci	MTHCA_NEXT_SOLICIT	= 1 << 1,
4462306a36Sopenharmony_ci	MTHCA_NEXT_IP_CSUM	= 1 << 4,
4562306a36Sopenharmony_ci	MTHCA_NEXT_TCP_UDP_CSUM = 1 << 5,
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_ci	MTHCA_MLX_VL15		= 1 << 17,
4862306a36Sopenharmony_ci	MTHCA_MLX_SLR		= 1 << 16
4962306a36Sopenharmony_ci};
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_cienum {
5262306a36Sopenharmony_ci	MTHCA_INVAL_LKEY			= 0x100,
5362306a36Sopenharmony_ci	MTHCA_TAVOR_MAX_WQES_PER_RECV_DB	= 256,
5462306a36Sopenharmony_ci	MTHCA_ARBEL_MAX_WQES_PER_SEND_DB	= 255
5562306a36Sopenharmony_ci};
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_cistruct mthca_next_seg {
5862306a36Sopenharmony_ci	__be32 nda_op;		/* [31:6] next WQE [4:0] next opcode */
5962306a36Sopenharmony_ci	__be32 ee_nds;		/* [31:8] next EE  [7] DBD [6] F [5:0] next WQE size */
6062306a36Sopenharmony_ci	__be32 flags;		/* [3] CQ [2] Event [1] Solicit */
6162306a36Sopenharmony_ci	__be32 imm;		/* immediate data */
6262306a36Sopenharmony_ci};
6362306a36Sopenharmony_ci
6462306a36Sopenharmony_cistruct mthca_tavor_ud_seg {
6562306a36Sopenharmony_ci	u32    reserved1;
6662306a36Sopenharmony_ci	__be32 lkey;
6762306a36Sopenharmony_ci	__be64 av_addr;
6862306a36Sopenharmony_ci	u32    reserved2[4];
6962306a36Sopenharmony_ci	__be32 dqpn;
7062306a36Sopenharmony_ci	__be32 qkey;
7162306a36Sopenharmony_ci	u32    reserved3[2];
7262306a36Sopenharmony_ci};
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_cistruct mthca_arbel_ud_seg {
7562306a36Sopenharmony_ci	__be32 av[8];
7662306a36Sopenharmony_ci	__be32 dqpn;
7762306a36Sopenharmony_ci	__be32 qkey;
7862306a36Sopenharmony_ci	u32    reserved[2];
7962306a36Sopenharmony_ci};
8062306a36Sopenharmony_ci
8162306a36Sopenharmony_cistruct mthca_bind_seg {
8262306a36Sopenharmony_ci	__be32 flags;		/* [31] Atomic [30] rem write [29] rem read */
8362306a36Sopenharmony_ci	u32    reserved;
8462306a36Sopenharmony_ci	__be32 new_rkey;
8562306a36Sopenharmony_ci	__be32 lkey;
8662306a36Sopenharmony_ci	__be64 addr;
8762306a36Sopenharmony_ci	__be64 length;
8862306a36Sopenharmony_ci};
8962306a36Sopenharmony_ci
9062306a36Sopenharmony_cistruct mthca_raddr_seg {
9162306a36Sopenharmony_ci	__be64 raddr;
9262306a36Sopenharmony_ci	__be32 rkey;
9362306a36Sopenharmony_ci	u32    reserved;
9462306a36Sopenharmony_ci};
9562306a36Sopenharmony_ci
9662306a36Sopenharmony_cistruct mthca_atomic_seg {
9762306a36Sopenharmony_ci	__be64 swap_add;
9862306a36Sopenharmony_ci	__be64 compare;
9962306a36Sopenharmony_ci};
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_cistruct mthca_data_seg {
10262306a36Sopenharmony_ci	__be32 byte_count;
10362306a36Sopenharmony_ci	__be32 lkey;
10462306a36Sopenharmony_ci	__be64 addr;
10562306a36Sopenharmony_ci};
10662306a36Sopenharmony_ci
10762306a36Sopenharmony_cistruct mthca_mlx_seg {
10862306a36Sopenharmony_ci	__be32 nda_op;
10962306a36Sopenharmony_ci	__be32 nds;
11062306a36Sopenharmony_ci	__be32 flags;		/* [17] VL15 [16] SLR [14:12] static rate
11162306a36Sopenharmony_ci				   [11:8] SL [3] C [2] E */
11262306a36Sopenharmony_ci	__be16 rlid;
11362306a36Sopenharmony_ci	__be16 vcrc;
11462306a36Sopenharmony_ci};
11562306a36Sopenharmony_ci
11662306a36Sopenharmony_cistatic __always_inline void mthca_set_data_seg(struct mthca_data_seg *dseg,
11762306a36Sopenharmony_ci					       struct ib_sge *sg)
11862306a36Sopenharmony_ci{
11962306a36Sopenharmony_ci	dseg->byte_count = cpu_to_be32(sg->length);
12062306a36Sopenharmony_ci	dseg->lkey       = cpu_to_be32(sg->lkey);
12162306a36Sopenharmony_ci	dseg->addr       = cpu_to_be64(sg->addr);
12262306a36Sopenharmony_ci}
12362306a36Sopenharmony_ci
12462306a36Sopenharmony_cistatic __always_inline void mthca_set_data_seg_inval(struct mthca_data_seg *dseg)
12562306a36Sopenharmony_ci{
12662306a36Sopenharmony_ci	dseg->byte_count = 0;
12762306a36Sopenharmony_ci	dseg->lkey       = cpu_to_be32(MTHCA_INVAL_LKEY);
12862306a36Sopenharmony_ci	dseg->addr       = 0;
12962306a36Sopenharmony_ci}
13062306a36Sopenharmony_ci
13162306a36Sopenharmony_ci#endif /* MTHCA_WQE_H */
132