1*9e39c5baSBill Taylor /*
2*9e39c5baSBill Taylor  * CDDL HEADER START
3*9e39c5baSBill Taylor  *
4*9e39c5baSBill Taylor  * The contents of this file are subject to the terms of the
5*9e39c5baSBill Taylor  * Common Development and Distribution License (the "License").
6*9e39c5baSBill Taylor  * You may not use this file except in compliance with the License.
7*9e39c5baSBill Taylor  *
8*9e39c5baSBill Taylor  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*9e39c5baSBill Taylor  * or http://www.opensolaris.org/os/licensing.
10*9e39c5baSBill Taylor  * See the License for the specific language governing permissions
11*9e39c5baSBill Taylor  * and limitations under the License.
12*9e39c5baSBill Taylor  *
13*9e39c5baSBill Taylor  * When distributing Covered Code, include this CDDL HEADER in each
14*9e39c5baSBill Taylor  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*9e39c5baSBill Taylor  * If applicable, add the following below this CDDL HEADER, with the
16*9e39c5baSBill Taylor  * fields enclosed by brackets "[]" replaced with your own identifying
17*9e39c5baSBill Taylor  * information: Portions Copyright [yyyy] [name of copyright owner]
18*9e39c5baSBill Taylor  *
19*9e39c5baSBill Taylor  * CDDL HEADER END
20*9e39c5baSBill Taylor  */
21*9e39c5baSBill Taylor 
22*9e39c5baSBill Taylor /*
23*9e39c5baSBill Taylor  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*9e39c5baSBill Taylor  * Use is subject to license terms.
25*9e39c5baSBill Taylor  */
26*9e39c5baSBill Taylor 
27*9e39c5baSBill Taylor #ifndef	_SYS_IB_ADAPTERS_TAVOR_WR_H
28*9e39c5baSBill Taylor #define	_SYS_IB_ADAPTERS_TAVOR_WR_H
29*9e39c5baSBill Taylor 
30*9e39c5baSBill Taylor /*
31*9e39c5baSBill Taylor  * tavor_wr.h
32*9e39c5baSBill Taylor  *    Contains all of the prototypes, #defines, and structures necessary
33*9e39c5baSBill Taylor  *    for the Tavor Work Request Processing Routines
34*9e39c5baSBill Taylor  *    Specifically it contains #defines, macros, and prototypes for each of
35*9e39c5baSBill Taylor  *    building each of the various types of WQE and for managing the WRID
36*9e39c5baSBill Taylor  *    tracking mechanisms.
37*9e39c5baSBill Taylor  */
38*9e39c5baSBill Taylor 
39*9e39c5baSBill Taylor #include <sys/types.h>
40*9e39c5baSBill Taylor #include <sys/conf.h>
41*9e39c5baSBill Taylor #include <sys/ddi.h>
42*9e39c5baSBill Taylor #include <sys/sunddi.h>
43*9e39c5baSBill Taylor 
44*9e39c5baSBill Taylor #ifdef __cplusplus
45*9e39c5baSBill Taylor extern "C" {
46*9e39c5baSBill Taylor #endif
47*9e39c5baSBill Taylor 
48*9e39c5baSBill Taylor /*
49*9e39c5baSBill Taylor  * The following macro is used to convert WQE address and size into the
50*9e39c5baSBill Taylor  * "wqeaddrsz" value needed in the tavor_wrid_entry_t (see below).
51*9e39c5baSBill Taylor  */
52*9e39c5baSBill Taylor #define	TAVOR_QP_WQEADDRSZ(addr, size)					\
53*9e39c5baSBill Taylor 	((((uintptr_t)(addr)) & ~TAVOR_WQE_NDS_MASK) |			\
54*9e39c5baSBill Taylor 	((size) & TAVOR_WQE_NDS_MASK))
55*9e39c5baSBill Taylor 
56*9e39c5baSBill Taylor /*
57*9e39c5baSBill Taylor  * The following macros are used to calculate pointers to the Send or Receive
58*9e39c5baSBill Taylor  * (or SRQ) WQEs on a given QP, respectively
59*9e39c5baSBill Taylor  */
60*9e39c5baSBill Taylor #define	TAVOR_QP_SQ_ENTRY(qp, tail)					\
61*9e39c5baSBill Taylor 	((uint64_t *)((uintptr_t)((qp)->qp_sq_buf) +			\
62*9e39c5baSBill Taylor 	((tail) << (qp)->qp_sq_log_wqesz)))
63*9e39c5baSBill Taylor #define	TAVOR_QP_RQ_ENTRY(qp, tail)					\
64*9e39c5baSBill Taylor 	((uint64_t *)((uintptr_t)((qp)->qp_rq_buf) +			\
65*9e39c5baSBill Taylor 	((tail) << (qp)->qp_rq_log_wqesz)))
66*9e39c5baSBill Taylor #define	TAVOR_SRQ_WQ_ENTRY(srq, tail)					\
67*9e39c5baSBill Taylor 	((uint64_t *)((uintptr_t)((srq)->srq_wq_buf) +			\
68*9e39c5baSBill Taylor 	((tail) << (srq)->srq_wq_log_wqesz)))
69*9e39c5baSBill Taylor 
70*9e39c5baSBill Taylor /*
71*9e39c5baSBill Taylor  * The following macro is used to calculate the 'wqe_index' field during SRQ
72*9e39c5baSBill Taylor  * operation.  This returns the index based on the WQE size, that can be used
73*9e39c5baSBill Taylor  * to reference WQEs in an SRQ.
74*9e39c5baSBill Taylor  */
75*9e39c5baSBill Taylor #define	TAVOR_SRQ_WQE_INDEX(srq_base_addr, wqe_addr, log_wqesz)		\
76*9e39c5baSBill Taylor 	(((uint32_t)(uintptr_t)wqe_addr -				\
77*9e39c5baSBill Taylor 	(uint32_t)(uintptr_t)srq_base_addr) >> log_wqesz)
78*9e39c5baSBill Taylor 
79*9e39c5baSBill Taylor #define	TAVOR_SRQ_WQE_ADDR(srq, wqe_index)				\
80*9e39c5baSBill Taylor 	((uint64_t *)((uintptr_t)srq->srq_wq_buf +			\
81*9e39c5baSBill Taylor 	(wqe_index << srq->srq_wq_log_wqesz)))
82*9e39c5baSBill Taylor 
83*9e39c5baSBill Taylor /*
84*9e39c5baSBill Taylor  * The following macros are used to access specific fields in Directed Route
85*9e39c5baSBill Taylor  * MAD packets.  We can extract the MgmtClass, "hop pointer", and "hop count".
86*9e39c5baSBill Taylor  * We can also update the "hop pointer" as appropriate.  Note:  Again, because
87*9e39c5baSBill Taylor  * of the limited amount of direct handling the Tavor hardware does on special
88*9e39c5baSBill Taylor  * QP request (specifically on Directed Route MADs), the driver needs to
89*9e39c5baSBill Taylor  * update (as necessary) the "hop pointer" value depending on whether a MAD
90*9e39c5baSBill Taylor  * is outbound or inbound (i.e. depending on the relationship between "hop
91*9e39c5baSBill Taylor  * pointer" and "hop count" in the given MAD)
92*9e39c5baSBill Taylor  */
93*9e39c5baSBill Taylor #define	TAVOR_SPECIAL_QP_DRMAD_GET_MGMTCLASS(mgmtclass, offset, va, len) \
94*9e39c5baSBill Taylor 	if (((mgmtclass) == NULL) && ((offset) + (len) > 1)) {		 \
95*9e39c5baSBill Taylor 	    (mgmtclass) = &((uint8_t *)(uintptr_t)(va))[1 - (offset)];	 \
96*9e39c5baSBill Taylor 	}
97*9e39c5baSBill Taylor #define	TAVOR_SPECIAL_QP_DRMAD_GET_HOPPOINTER(hp, offset, va, len)	\
98*9e39c5baSBill Taylor 	if (((hp) == NULL) &&					  	\
99*9e39c5baSBill Taylor 	    ((offset) + (len) > 6)) {					\
100*9e39c5baSBill Taylor 	    (hp) = &((uint8_t *)(uintptr_t)(va))[6 - (offset)];		\
101*9e39c5baSBill Taylor 	}
102*9e39c5baSBill Taylor #define	TAVOR_SPECIAL_QP_DRMAD_GET_HOPCOUNT(hc, offset, va, len)	\
103*9e39c5baSBill Taylor 	if (((hc) == NULL) &&						\
104*9e39c5baSBill Taylor 	    ((offset) + (len) > 7)) {					\
105*9e39c5baSBill Taylor 	    (hc) = &((uint8_t *)(uintptr_t)(va))[7 - (offset)];		\
106*9e39c5baSBill Taylor 	}
107*9e39c5baSBill Taylor #define	TAVOR_SPECIAL_QP_DRMAD_DO_HOPPOINTER_MODIFY(mgmtclass, hp, hc)	\
108*9e39c5baSBill Taylor 	if ((mgmtclass) == 0x81) {					\
109*9e39c5baSBill Taylor 		if ((hp) < (hc)) {					\
110*9e39c5baSBill Taylor 			(hp) = (hp) + 1;				\
111*9e39c5baSBill Taylor 		} else if ((hp) > (hc)) {				\
112*9e39c5baSBill Taylor 			(hp) = (hp) - 1;				\
113*9e39c5baSBill Taylor 		}							\
114*9e39c5baSBill Taylor 	}
115*9e39c5baSBill Taylor 
116*9e39c5baSBill Taylor 
117*9e39c5baSBill Taylor /*
118*9e39c5baSBill Taylor  * The tavor_wrid_entry_s structure is used internally by the Tavor
119*9e39c5baSBill Taylor  * driver to contain all the information necessary for tracking WRIDs.
120*9e39c5baSBill Taylor  * Specifically, this structure contains the 64-bit WRID, the 32-bit quantity
121*9e39c5baSBill Taylor  * called "wr_wqeaddrsz" (which can also be found in every CQE), and the
122*9e39c5baSBill Taylor  * "wr_signaled_dbd" information which indicates whether a given entry was
123*9e39c5baSBill Taylor  * signaled or not and whether a doorbell was subsequently rung for this
124*9e39c5baSBill Taylor  * particular work request.  Note: the latter piece of information is
125*9e39c5baSBill Taylor  * particularly useful during completion processing on errored CQEs.
126*9e39c5baSBill Taylor  */
127*9e39c5baSBill Taylor struct tavor_wrid_entry_s {
128*9e39c5baSBill Taylor 	uint64_t		wr_wrid;
129*9e39c5baSBill Taylor 	uint32_t		wr_wqeaddrsz;
130*9e39c5baSBill Taylor 	uint32_t		wr_signaled_dbd;
131*9e39c5baSBill Taylor };
132*9e39c5baSBill Taylor #define	TAVOR_WRID_ENTRY_SIGNALED	(1 << 0)
133*9e39c5baSBill Taylor #define	TAVOR_WRID_ENTRY_DOORBELLED	(1 << 1)
134*9e39c5baSBill Taylor 
135*9e39c5baSBill Taylor /*
136*9e39c5baSBill Taylor  * The tavor_sw_wqe_dbinfo_t structure is used internally by the Tavor
137*9e39c5baSBill Taylor  * driver to return information (from the tavor_wqe_mlx_build_nextctl() and
138*9e39c5baSBill Taylor  * tavor_wqe_send_build_nextctl() routines) regarding the type of Tavor
139*9e39c5baSBill Taylor  * doorbell necessary.
140*9e39c5baSBill Taylor  */
141*9e39c5baSBill Taylor typedef struct tavor_sw_wqe_dbinfo_s {
142*9e39c5baSBill Taylor 	uint_t	db_nopcode;
143*9e39c5baSBill Taylor 	uint_t	db_fence;
144*9e39c5baSBill Taylor } tavor_sw_wqe_dbinfo_t;
145*9e39c5baSBill Taylor 
146*9e39c5baSBill Taylor /*
147*9e39c5baSBill Taylor  * The Work Queue Lock (WQL) structure.  Each WQHDR (tavor_workq_hdr_t defined
148*9e39c5baSBill Taylor  * below) must lock access to the wridlist during any wridlist manipulation.
149*9e39c5baSBill Taylor  * Also, any Shared Receive Queue (SRQ) must also be able to lock the wridlist
150*9e39c5baSBill Taylor  * since it maintains wridlist's differently than normal QPs.  This
151*9e39c5baSBill Taylor  * 'tavor_wq_lock_t' structure is shared and accessible through the WQ or the
152*9e39c5baSBill Taylor  * SRQ, and refcnt is maintained.  The last entity to decrement use of the
153*9e39c5baSBill Taylor  * lock, also will free up the memory.
154*9e39c5baSBill Taylor  */
155*9e39c5baSBill Taylor struct tavor_wq_lock_s {
156*9e39c5baSBill Taylor 	kmutex_t	wql_lock;
157*9e39c5baSBill Taylor 	uint_t		wql_refcnt;
158*9e39c5baSBill Taylor };
159*9e39c5baSBill Taylor 
160*9e39c5baSBill Taylor /*
161*9e39c5baSBill Taylor  * The tavor_wrid_list_hdr_s structure is used internally by the Tavor driver
162*9e39c5baSBill Taylor  * to track all the information necessary to manage a queue of WRID entries
163*9e39c5baSBill Taylor  * (the tavor_wrid_entry_s struct above).
164*9e39c5baSBill Taylor  * It contains some information regarding the status of a given WRID list
165*9e39c5baSBill Taylor  * (e.g. head index, tail index, queue full condition, etc.).  Note:  Although
166*9e39c5baSBill Taylor  * some of this information is also kept by the tavor_workq_hdr_s below, what
167*9e39c5baSBill Taylor  * is kept here may, in fact, represent the state of an old WRID list.  It
168*9e39c5baSBill Taylor  * could be different from what is kept in the tavor_workq_hdr_s because this
169*9e39c5baSBill Taylor  * WRID list may no longer be the active WRID list.  If it is an active list,
170*9e39c5baSBill Taylor  * however, then both sets of information should be up-to-date and consistent.
171*9e39c5baSBill Taylor  * Several of these structures are chained together on each work queue header
172*9e39c5baSBill Taylor  * to form a linked list (using the "wl_next" and "wl_prev").  These structs,
173*9e39c5baSBill Taylor  * in turn, each have a pointer to a queue of WRID entries.  They also each
174*9e39c5baSBill Taylor  * have a pointer to the next "reapable" entry ("wl_reap_next") which is only
175*9e39c5baSBill Taylor  * used when a WRID list has been retired and is ready to be freed up.
176*9e39c5baSBill Taylor  * Lastly, it has a backpointer to the work queue header to which the WRID
177*9e39c5baSBill Taylor  * list belongs (this is for proper handling on removal).
178*9e39c5baSBill Taylor  */
179*9e39c5baSBill Taylor struct tavor_wrid_list_hdr_s {
180*9e39c5baSBill Taylor 	tavor_wrid_list_hdr_t	*wl_next;
181*9e39c5baSBill Taylor 	tavor_wrid_list_hdr_t	*wl_prev;
182*9e39c5baSBill Taylor 	tavor_wrid_list_hdr_t	*wl_reap_next;
183*9e39c5baSBill Taylor 	tavor_workq_hdr_t	*wl_wqhdr;
184*9e39c5baSBill Taylor 
185*9e39c5baSBill Taylor 	tavor_wrid_entry_t	*wl_wre;
186*9e39c5baSBill Taylor 	tavor_wrid_entry_t	*wl_wre_old_tail;
187*9e39c5baSBill Taylor 	uint32_t		wl_size;
188*9e39c5baSBill Taylor 	uint32_t		wl_full;
189*9e39c5baSBill Taylor 	uint32_t		wl_head;
190*9e39c5baSBill Taylor 	uint32_t		wl_tail;
191*9e39c5baSBill Taylor 
192*9e39c5baSBill Taylor 	/* For SRQ */
193*9e39c5baSBill Taylor 	uint_t			wl_srq_en;
194*9e39c5baSBill Taylor 	int			wl_free_list_indx;
195*9e39c5baSBill Taylor 	ddi_acc_handle_t	wl_acchdl;
196*9e39c5baSBill Taylor 	uint32_t		*wl_srq_wq_buf;
197*9e39c5baSBill Taylor 	uint32_t		wl_srq_wq_bufsz;
198*9e39c5baSBill Taylor 	uint64_t		wl_srq_desc_off;
199*9e39c5baSBill Taylor 	uint32_t		wl_srq_log_wqesz;
200*9e39c5baSBill Taylor };
201*9e39c5baSBill Taylor _NOTE(MUTEX_PROTECTS_DATA(tavor_sw_cq_s::cq_wrid_wqhdr_lock,
202*9e39c5baSBill Taylor     tavor_wrid_list_hdr_s::wl_next
203*9e39c5baSBill Taylor     tavor_wrid_list_hdr_s::wl_prev
204*9e39c5baSBill Taylor     tavor_wrid_list_hdr_s::wl_wqhdr))
205*9e39c5baSBill Taylor _NOTE(MUTEX_PROTECTS_DATA(tavor_wq_lock_s::wql_lock,
206*9e39c5baSBill Taylor     tavor_wrid_list_hdr_s::wl_wre
207*9e39c5baSBill Taylor     tavor_wrid_list_hdr_s::wl_wre_old_tail
208*9e39c5baSBill Taylor     tavor_wrid_list_hdr_s::wl_size
209*9e39c5baSBill Taylor     tavor_wrid_list_hdr_s::wl_full
210*9e39c5baSBill Taylor     tavor_wrid_list_hdr_s::wl_head
211*9e39c5baSBill Taylor     tavor_wrid_list_hdr_s::wl_tail
212*9e39c5baSBill Taylor     tavor_wrid_list_hdr_s::wl_srq_en
213*9e39c5baSBill Taylor     tavor_wrid_list_hdr_s::wl_free_list_indx
214*9e39c5baSBill Taylor     tavor_wrid_list_hdr_s::wl_acchdl
215*9e39c5baSBill Taylor     tavor_wrid_list_hdr_s::wl_srq_wq_buf
216*9e39c5baSBill Taylor     tavor_wrid_list_hdr_s::wl_srq_desc_off
217*9e39c5baSBill Taylor     tavor_wrid_list_hdr_s::wl_srq_log_wqesz))
218*9e39c5baSBill Taylor 
219*9e39c5baSBill Taylor /*
220*9e39c5baSBill Taylor  * The tavor_workq_hdr_s structure is used internally by the Tavor driver to
221*9e39c5baSBill Taylor  * track all the information necessary to manage the work queues associated
222*9e39c5baSBill Taylor  * with a given completion queue.  It contains much of the information
223*9e39c5baSBill Taylor  * regarding the status of a given work queue (e.g. head index, tail index,
224*9e39c5baSBill Taylor  * queue full condition, etc.).  Note:  This information is kept here (i.e.
225*9e39c5baSBill Taylor  * associated with a completion queue) rather than as part of the QP because
226*9e39c5baSBill Taylor  * the queue pair may potentially be destroyed while outstanding CQEs still
227*9e39c5baSBill Taylor  * remain on the CQ.
228*9e39c5baSBill Taylor  * Several of these structures are chained together on each CQ to form a
229*9e39c5baSBill Taylor  * linked list (using the "wq_next" and "wq_prev").  These headers, in turn,
230*9e39c5baSBill Taylor  * link to the containers for the individual WRID entries (managed with the
231*9e39c5baSBill Taylor  * tavor_wrid_list_hdr_s structs above).  Note: We keep a list of these
232*9e39c5baSBill Taylor  * tavor_wrid_list_hdr_s because a given QP may be used, destroyed (or
233*9e39c5baSBill Taylor  * transition to "Reset"), and then reused.  The list helps us track where
234*9e39c5baSBill Taylor  * to put new WRID entries and where to pull old entries from.
235*9e39c5baSBill Taylor  * The "wq_qpn" (QP number) and "wq_send_or_recv" (TAVOR_WR_SEND or
236*9e39c5baSBill Taylor  * TAVOR_WR_RECV) are used to uniquely identify the given work queue.
237*9e39c5baSBill Taylor  * Lookups into the work queue list (to find a given work queue) will use
238*9e39c5baSBill Taylor  * these two fields as identifiers.
239*9e39c5baSBill Taylor  */
240*9e39c5baSBill Taylor struct tavor_workq_hdr_s {
241*9e39c5baSBill Taylor 	avl_node_t		wq_avl_link;
242*9e39c5baSBill Taylor 	uint32_t		wq_qpn;
243*9e39c5baSBill Taylor 	uint32_t		wq_type;
244*9e39c5baSBill Taylor 
245*9e39c5baSBill Taylor 	tavor_wq_lock_t		*wq_wrid_wql;
246*9e39c5baSBill Taylor 
247*9e39c5baSBill Taylor 	uint32_t		wq_size;
248*9e39c5baSBill Taylor 	uint32_t		wq_head;
249*9e39c5baSBill Taylor 	uint32_t		wq_tail;
250*9e39c5baSBill Taylor 	uint32_t		wq_full;
251*9e39c5baSBill Taylor 	tavor_wrid_list_hdr_t	*wq_wrid_poll;
252*9e39c5baSBill Taylor 	tavor_wrid_list_hdr_t	*wq_wrid_post;
253*9e39c5baSBill Taylor };
254*9e39c5baSBill Taylor _NOTE(MUTEX_PROTECTS_DATA(tavor_sw_cq_s::cq_wrid_wqhdr_lock,
255*9e39c5baSBill Taylor     tavor_workq_hdr_s::wq_avl_link
256*9e39c5baSBill Taylor     tavor_workq_hdr_s::wq_qpn
257*9e39c5baSBill Taylor     tavor_workq_hdr_s::wq_type
258*9e39c5baSBill Taylor     tavor_sw_cq_s::cq_wrid_reap_head
259*9e39c5baSBill Taylor     tavor_sw_cq_s::cq_wrid_reap_tail))
260*9e39c5baSBill Taylor _NOTE(MUTEX_PROTECTS_DATA(tavor_wq_lock_s::wql_lock,
261*9e39c5baSBill Taylor     tavor_workq_hdr_s::wq_size
262*9e39c5baSBill Taylor     tavor_workq_hdr_s::wq_head
263*9e39c5baSBill Taylor     tavor_workq_hdr_s::wq_tail
264*9e39c5baSBill Taylor     tavor_workq_hdr_s::wq_full
265*9e39c5baSBill Taylor     tavor_workq_hdr_s::wq_wrid_poll
266*9e39c5baSBill Taylor     tavor_workq_hdr_s::wq_wrid_post
267*9e39c5baSBill Taylor     tavor_wrid_list_hdr_s::wl_wre
268*9e39c5baSBill Taylor     tavor_wrid_list_hdr_s::wl_wre_old_tail
269*9e39c5baSBill Taylor     tavor_wrid_list_hdr_s::wl_size
270*9e39c5baSBill Taylor     tavor_wrid_list_hdr_s::wl_full
271*9e39c5baSBill Taylor     tavor_wrid_list_hdr_s::wl_head
272*9e39c5baSBill Taylor     tavor_wrid_list_hdr_s::wl_tail))
273*9e39c5baSBill Taylor _NOTE(MUTEX_PROTECTS_DATA(tavor_sw_cq_s::cq_wrid_wqhdr_lock,
274*9e39c5baSBill Taylor     tavor_wrid_list_hdr_s::wl_reap_next))
275*9e39c5baSBill Taylor _NOTE(LOCK_ORDER(tavor_sw_cq_s::cq_lock
276*9e39c5baSBill Taylor     tavor_sw_cq_s::cq_wrid_wqhdr_lock
277*9e39c5baSBill Taylor     tavor_wq_lock_s::wql_lock))
278*9e39c5baSBill Taylor #define	TAVOR_WR_RECV			0x0
279*9e39c5baSBill Taylor #define	TAVOR_WR_SEND			0x1
280*9e39c5baSBill Taylor #define	TAVOR_WR_SRQ			0x2
281*9e39c5baSBill Taylor 
282*9e39c5baSBill Taylor extern int tavor_wrid_wqhdr_compare(const void *p1, const void *p2);
283*9e39c5baSBill Taylor typedef struct tavor_workq_compare_s {
284*9e39c5baSBill Taylor 	uint32_t cmp_type;
285*9e39c5baSBill Taylor 	uint32_t cmp_qpn;
286*9e39c5baSBill Taylor } tavor_workq_compare_t;
287*9e39c5baSBill Taylor 
288*9e39c5baSBill Taylor /* For Work Request posting */
289*9e39c5baSBill Taylor int tavor_post_send(tavor_state_t *state, tavor_qphdl_t qphdl,
290*9e39c5baSBill Taylor     ibt_send_wr_t *wr_p, uint_t num_wr, uint_t *num_posted);
291*9e39c5baSBill Taylor int tavor_post_recv(tavor_state_t *state, tavor_qphdl_t qphdl,
292*9e39c5baSBill Taylor     ibt_recv_wr_t *wr_p, uint_t num_wr, uint_t *num_posted);
293*9e39c5baSBill Taylor int tavor_post_srq(tavor_state_t *state, tavor_srqhdl_t srqhdl,
294*9e39c5baSBill Taylor     ibt_recv_wr_t *wr_p, uint_t num_wr, uint_t *num_posted);
295*9e39c5baSBill Taylor 
296*9e39c5baSBill Taylor /* For WRID handling */
297*9e39c5baSBill Taylor int tavor_wrid_from_reset_handling(tavor_state_t *state, tavor_qphdl_t qp);
298*9e39c5baSBill Taylor void tavor_wrid_to_reset_handling(tavor_state_t *state, tavor_qphdl_t qp);
299*9e39c5baSBill Taylor void tavor_wrid_add_entry(tavor_workq_hdr_t *wq, uint64_t wrid,
300*9e39c5baSBill Taylor     uint32_t wqeaddr_sz, uint_t signaled_dbd);
301*9e39c5baSBill Taylor void tavor_wrid_add_entry_srq(tavor_srqhdl_t srq, uint64_t wrid,
302*9e39c5baSBill Taylor     uint_t signaled_dbd);
303*9e39c5baSBill Taylor uint64_t tavor_wrid_get_entry(tavor_cqhdl_t cqhdl, tavor_hw_cqe_t *cqe,
304*9e39c5baSBill Taylor     tavor_wrid_entry_t *wre);
305*9e39c5baSBill Taylor tavor_wq_lock_t *tavor_wrid_wql_create(tavor_state_t *state);
306*9e39c5baSBill Taylor tavor_wrid_list_hdr_t *tavor_wrid_get_list(uint32_t size);
307*9e39c5baSBill Taylor void tavor_wrid_list_srq_init(tavor_wrid_list_hdr_t *r_wridlist,
308*9e39c5baSBill Taylor     tavor_srqhdl_t srq, uint_t wq_start);
309*9e39c5baSBill Taylor void tavor_wrid_cq_reap(tavor_cqhdl_t cq);
310*9e39c5baSBill Taylor void tavor_wrid_cq_force_reap(tavor_cqhdl_t cq);
311*9e39c5baSBill Taylor void tavor_wql_refcnt_dec(tavor_wq_lock_t *wq_lock);
312*9e39c5baSBill Taylor void tavor_wql_refcnt_inc(tavor_wq_lock_t *wq_lock);
313*9e39c5baSBill Taylor tavor_wrid_entry_t *tavor_wrid_find_match_srq(tavor_wrid_list_hdr_t *wq,
314*9e39c5baSBill Taylor     tavor_cqhdl_t cq, tavor_hw_cqe_t *cqe);
315*9e39c5baSBill Taylor 
316*9e39c5baSBill Taylor #ifdef __cplusplus
317*9e39c5baSBill Taylor }
318*9e39c5baSBill Taylor #endif
319*9e39c5baSBill Taylor 
320*9e39c5baSBill Taylor #endif	/* _SYS_IB_ADAPTERS_TAVOR_WR_H */
321