dapl_tavor_ibtf.h revision 9517:b4839b0aa7a4
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22/*
23 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24 * Use is subject to license terms.
25 */
26
27#ifndef _DAPL_TAVOR_IBTI_H
28#define	_DAPL_TAVOR_IBTI_H
29
30/*
31 * This header file defines various IB types that is used by the
32 * generic reference implementation. These IB types are mapped to
33 * IBTF types.
34 */
35
36#ifdef __cplusplus
37extern "C" {
38#endif
39
40#include <sys/ib/ibtl/ibti.h>
41#include <daplt_if.h>
42#include <sys/ib/adapters/mlnx_umap.h>
43
44#define	DAPLIB_NEEDS_INIT(ep)  ((ep)->qp_state == IBT_STATE_ERROR)
45#define	DAPL_MAX_IOV		8
46
47/*
48 * The InfiniBand Specification, Section 9.7.7, states that the
49 * upper bound on the maximum message size for an RC connection
50 * is 2^31 bytes. Implementations are free to support a smaller
51 * value. see dapli_ep_default_attrs
52 */
53#define	DAPL_IB_MAX_MESSAGE_SIZE	0x80000000
54#define	DAPL_MAX_ADDRESS		0xfffffffffffffff0ULL
55
56
57#define	true				B_TRUE
58#define	false				B_FALSE
59#define	IB_INVALID_HANDLE		NULL
60
61#define	DAPL_CQE_INVALID_PRMEVENT	0x1015
62#define	DAPL_CQE_VALID_PRMEVENT		0x1215
63
64#define	DAPL_GET_CQE_WRID(cqe_p)	\
65			((ib_work_completion_t *)(cqe_p))->wc_id
66#define	DAPL_GET_CQE_OPTYPE(cqe_p)	\
67			((ib_work_completion_t *)(cqe_p))->wc_type
68#define	DAPL_GET_CQE_BYTESNUM(cqe_p)	\
69			((ib_work_completion_t *)(cqe_p))->wc_bytes_xfer
70#define	DAPL_GET_CQE_STATUS(cqe_p)	\
71			((ib_work_completion_t *)(cqe_p))->wc_status
72#define	DAPL_GET_CQE_QPN(cqe_p)	\
73			((ib_work_completion_t *)(cqe_p))->wc_qpn
74#define	DAPL_CQE_IS_VALID(cqe_p)	\
75			(((ib_work_completion_t *)(cqe_p))->wc_res_hash == \
76			DAPL_CQE_VALID_PRMEVENT)
77#define	DAPL_SET_CQE_INVALID(cqe_p)	\
78			(((ib_work_completion_t *)(cqe_p))->wc_res_hash = \
79			DAPL_CQE_INVALID_PRMEVENT)
80#define	DAPL_SET_CQE_VALID(cqe_p)	\
81			(((ib_work_completion_t *)(cqe_p))->wc_res_hash = \
82			DAPL_CQE_VALID_PRMEVENT)
83
84/*
85 * Map private data constants to IBTF constants
86 */
87#define	IB_MAX_REQ_PDATA_SIZE		IBT_REQ_PRIV_DATA_SZ
88#define	IB_MAX_REP_PDATA_SIZE		IBT_REP_PRIV_DATA_SZ
89#define	IB_MAX_REJ_PDATA_SIZE		IBT_REJ_PRIV_DATA_SZ
90#define	IB_MAX_DREQ_PDATA_SIZE		IBT_DREQ_PRIV_DATA_SZ
91#define	IB_MAX_DREP_PDATA_SIZE		IBT_DREP_PRIV_DATA_SZ
92
93/*
94 * Definitions to map DTO OPs to IBTF definitions
95 */
96#define	OP_RDMA_READ			IBT_WRC_RDMAR
97#define	OP_RDMA_WRITE			IBT_WRC_RDMAW
98#define	OP_SEND				IBT_WRC_SEND
99#define	OP_RECEIVE			IBT_WRC_RECV
100#define	OP_COMP_AND_SWAP		IBT_WRC_CSWAP
101#define	OP_FETCH_AND_ADD		IBT_WRC_FADD
102#define	OP_BIND_MW			IBT_WRC_BIND
103
104/*
105 * Definitions to map Memory OPs
106 */
107#define	IB_ACCESS_LOCAL_WRITE	IBT_MR_ENABLE_LOCAL_WRITE
108#define	IB_ACCESS_REMOTE_READ	IBT_MR_ENABLE_REMOTE_READ
109#define	IB_ACCESS_REMOTE_WRITE	IBT_MR_ENABLE_REMOTE_WRITE
110
111/*
112 * Definitions to map WR_BIND request flags -
113 * IBTF uses diff set of flags for the ibt_bind_flags_t
114 */
115#define	IB_BIND_ACCESS_REMOTE_READ	IBT_WR_BIND_READ
116#define	IB_BIND_ACCESS_REMOTE_WRITE	IBT_WR_BIND_WRITE
117
118/*
119 * MAP CQE status to IBT_WC_*
120 */
121#define	IB_COMP_ST_SUCCESS		IBT_WC_SUCCESS
122#define	IB_COMP_ST_LOCAL_LEN_ERR	IBT_WC_LOCAL_LEN_ERR
123#define	IB_COMP_ST_LOCAL_OP_ERR		IBT_WC_LOCAL_CHAN_OP_ERR
124#define	IB_COMP_ST_LOCAL_PROTECT_ERR	IBT_WC_LOCAL_PROTECT_ERR
125#define	IB_COMP_ST_WR_FLUSHED_ERR	IBT_WC_WR_FLUSHED_ERR
126#define	IB_COMP_ST_MW_BIND_ERR		IBT_WC_MEM_WIN_BIND_ERR
127#define	IB_COMP_ST_REM_REQ_ERR		IBT_WC_REMOTE_INVALID_REQ_ERR
128#define	IB_COMP_ST_REM_ACC_ERR		IBT_WC_REMOTE_ACCESS_ERR
129#define	IB_COMP_ST_REM_OP_ERR		IBT_WC_REMOTE_OP_ERR
130#define	IB_COMP_ST_TRANSP_COUNTER	IBT_WC_TRANS_TIMEOUT_ERR
131#define	IB_COMP_ST_RNR_COUNTER		IBT_WC_RNR_NAK_TIMEOUT_ERR
132#define	IB_COMP_ST_BAD_RESPONSE_ERR	IBT_WC_BAD_RESPONSE_ERR
133
134/*
135 * CQ NOTIFICATION TYPE
136 */
137#define	IB_NOTIFY_ON_NEXT_COMP		1
138#define	IB_NOTIFY_ON_NEXT_SOLICITED	2
139#define	IB_NOTIFY_ON_NEXT_NCOMP		3
140
141/*
142 * Connection Manager Defs
143 */
144#define	IB_CME_CONNECTED			DAPL_IB_CME_CONNECTED
145#define	IB_CME_DISCONNECTED			DAPL_IB_CME_DISCONNECTED
146#define	IB_CME_CONNECTION_REQUEST_PENDING	\
147	DAPL_IB_CME_CONNECTION_REQUEST_PENDING
148#define	IB_CME_CONNECTION_REQUEST_PENDING_PRIVATE_DATA	\
149	DAPL_IB_CME_CONNECTION_REQUEST_PENDING_PRIVATE_DATA
150#define	IB_CME_DESTINATION_REJECT		DAPL_IB_CME_DESTINATION_REJECT
151#define	IB_CME_DESTINATION_REJECT_PRIVATE_DATA	\
152	DAPL_IB_CME_DESTINATION_REJECT_PRIVATE_DATA
153#define	IB_CME_DESTINATION_UNREACHABLE		\
154	DAPL_IB_CME_DESTINATION_UNREACHABLE
155#define	IB_CME_TOO_MANY_CONNECTION_REQUESTS	\
156	DAPL_IB_CME_TOO_MANY_CONNECTION_REQUESTS
157#define	IB_CME_LOCAL_FAILURE			DAPL_IB_CME_LOCAL_FAILURE
158#define	IB_CME_TIMED_OUT			DAPL_IB_CME_TIMED_OUT
159#define	IB_CME_DISCONNECTED_ON_LINK_DOWN	\
160	DAPL_IB_CME_DISCONNECTED_ON_LINK_DOWN
161#define	IB_CM_REJ_REASON_CONSUMER_REJ		\
162	DAPL_IB_CM_REJ_REASON_CONSUMER_REJ
163
164/*
165 * Typedefs to map generic 'ib' types to service provider implementation
166 */
167typedef	dapl_ib_cm_event_type_t		ib_cm_events_t;
168typedef uint64_t			ib_cm_handle_t;
169typedef	uint32_t			ib_cqd_handle_t;
170typedef	uint64_t			ib_cno_handle_t;
171
172typedef struct dapls_ib_cm_srvc_handle	*ib_cm_srvc_handle_t;
173typedef	struct dapls_ib_hca_handle	*ib_hca_handle_t;
174typedef	struct dapls_ib_cq_handle	*ib_cq_handle_t;
175typedef	struct dapls_ib_qp_handle	*ib_qp_handle_t;
176typedef	struct dapls_ib_pd_handle	*ib_pd_handle_t;
177typedef	struct dapls_ib_mr_handle	*ib_mr_handle_t;
178typedef	struct dapls_ib_mw_handle	*ib_mw_handle_t;
179typedef	struct dapls_ib_srq_handle	*ib_srq_handle_t;
180typedef	dapl_ib_async_event_t		ib_error_record_t;
181
182typedef char				*IB_HCA_NAME;
183typedef	char				ib_hca_name_t[256];
184typedef	uint8_t				ib_hca_port_t;
185typedef uint32_t			ib_uint32_t;
186typedef	boolean_t			ib_bool_t;
187
188typedef	ibt_cep_state_t			ib_qp_state_t;
189typedef	ibt_wrc_opcode_t		ib_send_op_type_t;
190typedef	ibt_cq_notify_flags_t		ib_notification_type_t;
191typedef	ibt_async_handler_t		ib_async_handler_t;
192typedef	ibt_cq_hdl_t			ib_comp_handle_t;
193typedef	ibt_wr_ds_t			ib_data_segment_t;
194typedef ibt_wc_t			ib_work_completion_t;
195
196struct	tavor_hw_uar_s;
197typedef	struct tavor_hw_uar_s		*dapls_hw_uar_t;
198
199struct	tavor_hw_cqe_s;
200typedef	struct tavor_hw_cqe_s		*dapls_hw_cqe_t;
201
202/* Function prototypes */
203extern	DAT_RETURN dapls_convert_error(int errnum, int retval);
204
205#ifdef __cplusplus
206}
207#endif
208
209#endif /* _DAPL_TAVOR_IBTI_H */
210