18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright (c) 2005 Cisco Systems. All rights reserved.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * This software is available to you under a choice of one of two
58c2ecf20Sopenharmony_ci * licenses.  You may choose to be licensed under the terms of the GNU
68c2ecf20Sopenharmony_ci * General Public License (GPL) Version 2, available from the file
78c2ecf20Sopenharmony_ci * COPYING in the main directory of this source tree, or the
88c2ecf20Sopenharmony_ci * OpenIB.org BSD license below:
98c2ecf20Sopenharmony_ci *
108c2ecf20Sopenharmony_ci *     Redistribution and use in source and binary forms, with or
118c2ecf20Sopenharmony_ci *     without modification, are permitted provided that the following
128c2ecf20Sopenharmony_ci *     conditions are met:
138c2ecf20Sopenharmony_ci *
148c2ecf20Sopenharmony_ci *      - Redistributions of source code must retain the above
158c2ecf20Sopenharmony_ci *        copyright notice, this list of conditions and the following
168c2ecf20Sopenharmony_ci *        disclaimer.
178c2ecf20Sopenharmony_ci *
188c2ecf20Sopenharmony_ci *      - Redistributions in binary form must reproduce the above
198c2ecf20Sopenharmony_ci *        copyright notice, this list of conditions and the following
208c2ecf20Sopenharmony_ci *        disclaimer in the documentation and/or other materials
218c2ecf20Sopenharmony_ci *        provided with the distribution.
228c2ecf20Sopenharmony_ci *
238c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
248c2ecf20Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
258c2ecf20Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
268c2ecf20Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
278c2ecf20Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
288c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
298c2ecf20Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
308c2ecf20Sopenharmony_ci * SOFTWARE.
318c2ecf20Sopenharmony_ci */
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci#ifndef MTHCA_WQE_H
348c2ecf20Sopenharmony_ci#define MTHCA_WQE_H
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci#include <linux/types.h>
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_cienum {
398c2ecf20Sopenharmony_ci	MTHCA_NEXT_DBD		= 1 << 7,
408c2ecf20Sopenharmony_ci	MTHCA_NEXT_FENCE	= 1 << 6,
418c2ecf20Sopenharmony_ci	MTHCA_NEXT_CQ_UPDATE	= 1 << 3,
428c2ecf20Sopenharmony_ci	MTHCA_NEXT_EVENT_GEN	= 1 << 2,
438c2ecf20Sopenharmony_ci	MTHCA_NEXT_SOLICIT	= 1 << 1,
448c2ecf20Sopenharmony_ci	MTHCA_NEXT_IP_CSUM	= 1 << 4,
458c2ecf20Sopenharmony_ci	MTHCA_NEXT_TCP_UDP_CSUM = 1 << 5,
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci	MTHCA_MLX_VL15		= 1 << 17,
488c2ecf20Sopenharmony_ci	MTHCA_MLX_SLR		= 1 << 16
498c2ecf20Sopenharmony_ci};
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_cienum {
528c2ecf20Sopenharmony_ci	MTHCA_INVAL_LKEY			= 0x100,
538c2ecf20Sopenharmony_ci	MTHCA_TAVOR_MAX_WQES_PER_RECV_DB	= 256,
548c2ecf20Sopenharmony_ci	MTHCA_ARBEL_MAX_WQES_PER_SEND_DB	= 255
558c2ecf20Sopenharmony_ci};
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_cistruct mthca_next_seg {
588c2ecf20Sopenharmony_ci	__be32 nda_op;		/* [31:6] next WQE [4:0] next opcode */
598c2ecf20Sopenharmony_ci	__be32 ee_nds;		/* [31:8] next EE  [7] DBD [6] F [5:0] next WQE size */
608c2ecf20Sopenharmony_ci	__be32 flags;		/* [3] CQ [2] Event [1] Solicit */
618c2ecf20Sopenharmony_ci	__be32 imm;		/* immediate data */
628c2ecf20Sopenharmony_ci};
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_cistruct mthca_tavor_ud_seg {
658c2ecf20Sopenharmony_ci	u32    reserved1;
668c2ecf20Sopenharmony_ci	__be32 lkey;
678c2ecf20Sopenharmony_ci	__be64 av_addr;
688c2ecf20Sopenharmony_ci	u32    reserved2[4];
698c2ecf20Sopenharmony_ci	__be32 dqpn;
708c2ecf20Sopenharmony_ci	__be32 qkey;
718c2ecf20Sopenharmony_ci	u32    reserved3[2];
728c2ecf20Sopenharmony_ci};
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_cistruct mthca_arbel_ud_seg {
758c2ecf20Sopenharmony_ci	__be32 av[8];
768c2ecf20Sopenharmony_ci	__be32 dqpn;
778c2ecf20Sopenharmony_ci	__be32 qkey;
788c2ecf20Sopenharmony_ci	u32    reserved[2];
798c2ecf20Sopenharmony_ci};
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_cistruct mthca_bind_seg {
828c2ecf20Sopenharmony_ci	__be32 flags;		/* [31] Atomic [30] rem write [29] rem read */
838c2ecf20Sopenharmony_ci	u32    reserved;
848c2ecf20Sopenharmony_ci	__be32 new_rkey;
858c2ecf20Sopenharmony_ci	__be32 lkey;
868c2ecf20Sopenharmony_ci	__be64 addr;
878c2ecf20Sopenharmony_ci	__be64 length;
888c2ecf20Sopenharmony_ci};
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_cistruct mthca_raddr_seg {
918c2ecf20Sopenharmony_ci	__be64 raddr;
928c2ecf20Sopenharmony_ci	__be32 rkey;
938c2ecf20Sopenharmony_ci	u32    reserved;
948c2ecf20Sopenharmony_ci};
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_cistruct mthca_atomic_seg {
978c2ecf20Sopenharmony_ci	__be64 swap_add;
988c2ecf20Sopenharmony_ci	__be64 compare;
998c2ecf20Sopenharmony_ci};
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_cistruct mthca_data_seg {
1028c2ecf20Sopenharmony_ci	__be32 byte_count;
1038c2ecf20Sopenharmony_ci	__be32 lkey;
1048c2ecf20Sopenharmony_ci	__be64 addr;
1058c2ecf20Sopenharmony_ci};
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_cistruct mthca_mlx_seg {
1088c2ecf20Sopenharmony_ci	__be32 nda_op;
1098c2ecf20Sopenharmony_ci	__be32 nds;
1108c2ecf20Sopenharmony_ci	__be32 flags;		/* [17] VL15 [16] SLR [14:12] static rate
1118c2ecf20Sopenharmony_ci				   [11:8] SL [3] C [2] E */
1128c2ecf20Sopenharmony_ci	__be16 rlid;
1138c2ecf20Sopenharmony_ci	__be16 vcrc;
1148c2ecf20Sopenharmony_ci};
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_cistatic __always_inline void mthca_set_data_seg(struct mthca_data_seg *dseg,
1178c2ecf20Sopenharmony_ci					       struct ib_sge *sg)
1188c2ecf20Sopenharmony_ci{
1198c2ecf20Sopenharmony_ci	dseg->byte_count = cpu_to_be32(sg->length);
1208c2ecf20Sopenharmony_ci	dseg->lkey       = cpu_to_be32(sg->lkey);
1218c2ecf20Sopenharmony_ci	dseg->addr       = cpu_to_be64(sg->addr);
1228c2ecf20Sopenharmony_ci}
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_cistatic __always_inline void mthca_set_data_seg_inval(struct mthca_data_seg *dseg)
1258c2ecf20Sopenharmony_ci{
1268c2ecf20Sopenharmony_ci	dseg->byte_count = 0;
1278c2ecf20Sopenharmony_ci	dseg->lkey       = cpu_to_be32(MTHCA_INVAL_LKEY);
1288c2ecf20Sopenharmony_ci	dseg->addr       = 0;
1298c2ecf20Sopenharmony_ci}
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ci#endif /* MTHCA_WQE_H */
132