19e39c5baSBill Taylor /*
29e39c5baSBill Taylor  * CDDL HEADER START
39e39c5baSBill Taylor  *
49e39c5baSBill Taylor  * The contents of this file are subject to the terms of the
59e39c5baSBill Taylor  * Common Development and Distribution License (the "License").
69e39c5baSBill Taylor  * You may not use this file except in compliance with the License.
79e39c5baSBill Taylor  *
89e39c5baSBill Taylor  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
99e39c5baSBill Taylor  * or http://www.opensolaris.org/os/licensing.
109e39c5baSBill Taylor  * See the License for the specific language governing permissions
119e39c5baSBill Taylor  * and limitations under the License.
129e39c5baSBill Taylor  *
139e39c5baSBill Taylor  * When distributing Covered Code, include this CDDL HEADER in each
149e39c5baSBill Taylor  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
159e39c5baSBill Taylor  * If applicable, add the following below this CDDL HEADER, with the
169e39c5baSBill Taylor  * fields enclosed by brackets "[]" replaced with your own identifying
179e39c5baSBill Taylor  * information: Portions Copyright [yyyy] [name of copyright owner]
189e39c5baSBill Taylor  *
199e39c5baSBill Taylor  * CDDL HEADER END
209e39c5baSBill Taylor  */
219e39c5baSBill Taylor 
229e39c5baSBill Taylor /*
23*17a2b317SBill Taylor  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
249e39c5baSBill Taylor  */
259e39c5baSBill Taylor 
269e39c5baSBill Taylor #ifndef	_SYS_IB_ADAPTERS_HERMON_QP_H
279e39c5baSBill Taylor #define	_SYS_IB_ADAPTERS_HERMON_QP_H
289e39c5baSBill Taylor 
299e39c5baSBill Taylor /*
309e39c5baSBill Taylor  * hermon_qp.h
319e39c5baSBill Taylor  *    Contains all of the prototypes, #defines, and structures necessary
329e39c5baSBill Taylor  *    for all of the Queue Pair Processing routines.
339e39c5baSBill Taylor  *    Specifically it contains the various flags, structures used for managing
349e39c5baSBill Taylor  *    Hermon queue pairs, and prototypes for many of the functions consumed by
359e39c5baSBill Taylor  *    other parts of the Hermon driver (including those routines directly
369e39c5baSBill Taylor  *    exposed through the IBTF CI interface).
379e39c5baSBill Taylor  *
389e39c5baSBill Taylor  *    Most of the values defined below establish default values which,
399e39c5baSBill Taylor  *    where indicated, can be controlled via their related patchable values,
409e39c5baSBill Taylor  *    if 'hermon_alt_config_enable' is set.
419e39c5baSBill Taylor  */
429e39c5baSBill Taylor 
439e39c5baSBill Taylor #include <sys/types.h>
449e39c5baSBill Taylor #include <sys/conf.h>
459e39c5baSBill Taylor #include <sys/ddi.h>
469e39c5baSBill Taylor #include <sys/sunddi.h>
479e39c5baSBill Taylor 
489e39c5baSBill Taylor #ifdef __cplusplus
499e39c5baSBill Taylor extern "C" {
509e39c5baSBill Taylor #endif
519e39c5baSBill Taylor 
529e39c5baSBill Taylor /*
539e39c5baSBill Taylor  * The following defines the default number of Queue Pairs. This value is
549e39c5baSBill Taylor  * controlled via the "hermon_log_num_qp" configuration variables.
559e39c5baSBill Taylor  * We also have a define for the minimum size of a QP.  QPs allocated
569e39c5baSBill Taylor  * with size 0, 1, 2, or 3 will always get back a QP of size 4.
57*17a2b317SBill Taylor  *
58*17a2b317SBill Taylor  * Note: Increasing #QPs from 64K to 256K for reserved ranges for FCoIB.
599e39c5baSBill Taylor  */
60*17a2b317SBill Taylor #define	HERMON_NUM_QP_SHIFT		0x12
61*17a2b317SBill Taylor #define	HERMON_NUM_QPS			(1 << HERMON_NUM_QP_SHIFT) /* 256K */
629e39c5baSBill Taylor #define	HERMON_QP_MIN_SIZE		0xf
639e39c5baSBill Taylor 
649e39c5baSBill Taylor /*
659e39c5baSBill Taylor  * The following defines the default number of Hermon RDMA Remote read
669e39c5baSBill Taylor  * database (RDB) entries per QP.  This value is controllable through the
679e39c5baSBill Taylor  * "hermon_log_num_rdb_per_qp" configuration variable.
689e39c5baSBill Taylor  */
699e39c5baSBill Taylor #define	HERMON_LOG_NUM_RDB_PER_QP	0x4
709e39c5baSBill Taylor 
719e39c5baSBill Taylor /*
729e39c5baSBill Taylor  * This defines the maximum number of SGLs per WQE.  This value is
739e39c5baSBill Taylor  * controllable through the "hermon_wqe_max_sgl" configuration variable
749e39c5baSBill Taylor  * (but should not be set larger than this value).
759e39c5baSBill Taylor  */
769e39c5baSBill Taylor #define	HERMON_NUM_SGL_PER_WQE		0x10
779e39c5baSBill Taylor 
789e39c5baSBill Taylor /*
799e39c5baSBill Taylor  * Maximum QP number mask (QP number is 24 bits).
809e39c5baSBill Taylor  * We reserve the most significant bit to indicate an "XRC" QP
819e39c5baSBill Taylor  * as recommended by the PRM.  All XRC QPs will have this bit set.
829e39c5baSBill Taylor  */
839e39c5baSBill Taylor #define	HERMON_QP_MAXNUMBER_MSK		0x7FFFFF
84*17a2b317SBill Taylor #define	HERMON_QP_XRC_MSK		0x800000
859e39c5baSBill Taylor 
869e39c5baSBill Taylor /*
879e39c5baSBill Taylor  * This define and the following macro are used to find a schedule queue for
889e39c5baSBill Taylor  * a new QP based on its queue pair number.  Note:  This is a rather simple
899e39c5baSBill Taylor  * method that we use today.  We simply choose from the schedule queue based
909e39c5baSBill Taylor  * on the 4 least significant bits of the QP number.
919e39c5baSBill Taylor  */
929e39c5baSBill Taylor 
939e39c5baSBill Taylor /*
949e39c5baSBill Taylor  * The following defines are used to indicate whether a QP is special or
959e39c5baSBill Taylor  * not (and what type it is).  They are used in the "qp_is_special" field
969e39c5baSBill Taylor  * below in qp_state.  If "qp_is_special" == 0 then an ordinary data qp.
979e39c5baSBill Taylor  */
989e39c5baSBill Taylor 
999e39c5baSBill Taylor /*
1009e39c5baSBill Taylor  * The sl is selected based on the qpnum as it was for Tavor/Arbel, except for
1019e39c5baSBill Taylor  * QP0, which is defined as being 0xF
1029e39c5baSBill Taylor  */
1039e39c5baSBill Taylor 
1049e39c5baSBill Taylor #define	HERMON_QP_SMI			0x1
1059e39c5baSBill Taylor #define	HERMON_QP_GSI			0x2
1069e39c5baSBill Taylor 
1079e39c5baSBill Taylor #define	HERMON_DEF_SCHED_POLICY		0x03
1089e39c5baSBill Taylor #define	HERMON_DEF_SCHED_SELECTION	0x0F
1099e39c5baSBill Taylor 
1109e39c5baSBill Taylor #define	HERMON_QP_SCHEDQ_GET(port, sl, issmi)   \
1119e39c5baSBill Taylor 	(HERMON_DEF_SCHED_POLICY 		\
1129e39c5baSBill Taylor 	| (issmi == HERMON_QP_SMI ? (HERMON_DEF_SCHED_SELECTION << 2) : \
1139e39c5baSBill Taylor 	((issmi == HERMON_QP_GSI ? 0 : (sl & 0XF)) << 2)) \
1149e39c5baSBill Taylor 	| ((port & 0x01) << 6) \
1159e39c5baSBill Taylor 	| ((issmi == HERMON_QP_SMI ? 0 : 1) << 7))
1169e39c5baSBill Taylor 
1179e39c5baSBill Taylor 
1189e39c5baSBill Taylor /*
1199e39c5baSBill Taylor  * This define determines the frequency with which the AckReq bit will be
1209e39c5baSBill Taylor  * set in outgoing RC packets.  By default it is set to five (5) or 2^5 = 32.
1219e39c5baSBill Taylor  * So AckReq will be set once every 32 packets sent.  This value is
1229e39c5baSBill Taylor  * controllable through the "hermon_qp_ackreq_freq" configuration variable.
1239e39c5baSBill Taylor  */
1249e39c5baSBill Taylor #define	HERMON_QP_ACKREQ_FREQ		0x5
1259e39c5baSBill Taylor 
1269e39c5baSBill Taylor /*
1279e39c5baSBill Taylor  * Define the maximum message size (log 2).  Note: This value corresponds
1289e39c5baSBill Taylor  * to the maximum allowable message sized as defined by the IBA spec.
1299e39c5baSBill Taylor  */
1309e39c5baSBill Taylor #define	HERMON_QP_LOG_MAX_MSGSZ		0x1F
1319e39c5baSBill Taylor 
1329e39c5baSBill Taylor /*
1339e39c5baSBill Taylor  * This macro is used to determine if the hermon QP type (qp_serv) is the
1349e39c5baSBill Taylor  * same as the caller passed in IBT type (qp_trans).  This is used in QP modify
1359e39c5baSBill Taylor  * to ensure the types match.
1369e39c5baSBill Taylor  */
1379e39c5baSBill Taylor #define	HERMON_QP_TYPE_VALID(qp_trans, qp_serv)				\
138*17a2b317SBill Taylor 	((qp_trans == IBT_RC_SRV && qp_serv == HERMON_QP_RC) ||		\
139*17a2b317SBill Taylor 	(qp_trans == IBT_UD_SRV && (qp_serv == HERMON_QP_UD ||		\
140*17a2b317SBill Taylor 	qp_serv == HERMON_QP_RFCI || qp_serv == HERMON_QP_FCMND ||	\
141*17a2b317SBill Taylor 	qp_serv == HERMON_QP_FEXCH)) ||					\
1429e39c5baSBill Taylor 	(qp_trans == IBT_UC_SRV && qp_serv == HERMON_QP_UC))
1439e39c5baSBill Taylor 
1449e39c5baSBill Taylor /*
1459e39c5baSBill Taylor  * The following enumerated type is used to capture all the various types
1469e39c5baSBill Taylor  * of Hermon work queue types. It is specifically used as an argument to the
1479e39c5baSBill Taylor  * to the hermon_qp_sgl_to_logwqesz() routine to determine the amount of
1489e39c5baSBill Taylor  * overhead (in WQE header size) consumed by each of the types. This
1499e39c5baSBill Taylor  * information is used to round the WQE size to the next largest power-of-2
1509e39c5baSBill Taylor  * (and to determine the number of SGLs that are supported for the given WQE
1519e39c5baSBill Taylor  * type).  There is also a define below used to specify the minimum size for a
1529e39c5baSBill Taylor  * WQE.  The minimum size is set to 64 bytes (a single cacheline).
1539e39c5baSBill Taylor  */
1549e39c5baSBill Taylor 
1559e39c5baSBill Taylor typedef enum {
1569e39c5baSBill Taylor 	HERMON_QP_WQ_TYPE_SENDQ_UD,
1579e39c5baSBill Taylor 	HERMON_QP_WQ_TYPE_SENDQ_CONN,
1589e39c5baSBill Taylor 	HERMON_QP_WQ_TYPE_RECVQ,
1599e39c5baSBill Taylor 	HERMON_QP_WQ_TYPE_SENDMLX_QP0,
1609e39c5baSBill Taylor 	HERMON_QP_WQ_TYPE_SENDMLX_QP1
1619e39c5baSBill Taylor } hermon_qp_wq_type_t;
1629e39c5baSBill Taylor #define	HERMON_QP_WQE_MLX_SND_HDRS	0x40
1639e39c5baSBill Taylor #define	HERMON_QP_WQE_MLX_RCV_HDRS	0x00
1649e39c5baSBill Taylor #define	HERMON_QP_WQE_MLX_SRQ_HDRS	0x10
1659e39c5baSBill Taylor #define	HERMON_QP_WQE_MLX_QP0_HDRS	0x40
1669e39c5baSBill Taylor #define	HERMON_QP_WQE_MLX_QP1_HDRS	0x70
1679e39c5baSBill Taylor #define	HERMON_QP_WQE_LOG_MINIMUM	0x6
1689e39c5baSBill Taylor 
1699e39c5baSBill Taylor 
170*17a2b317SBill Taylor /*
171*17a2b317SBill Taylor  * The hermon_qp_range_t is used to manage a qp_range for RSS and FEXCH.
172*17a2b317SBill Taylor  * It has a reference count.  When the reference count goes to 0,
173*17a2b317SBill Taylor  * the qpc resource can be freed.
174*17a2b317SBill Taylor  */
175*17a2b317SBill Taylor typedef struct hermon_qp_range_s {
176*17a2b317SBill Taylor 	kmutex_t	hqpr_lock;
177*17a2b317SBill Taylor 	hermon_rsrc_t	*hqpr_qpcrsrc;
178*17a2b317SBill Taylor 	uint_t		hqpr_refcnt;
179*17a2b317SBill Taylor } hermon_qp_range_t;
180*17a2b317SBill Taylor 
1819e39c5baSBill Taylor /*
1829e39c5baSBill Taylor  * The hermon_qp_info_t structure is used internally by the Hermon driver to
1839e39c5baSBill Taylor  * pass information to and from the hermon_qp_alloc() and
1849e39c5baSBill Taylor  * hermon_special_qp_alloc() routines.  It contains placeholders for all of the
1859e39c5baSBill Taylor  * potential inputs and outputs that either routine can take.
1869e39c5baSBill Taylor  */
1879e39c5baSBill Taylor typedef struct hermon_qp_info_s {
1889e39c5baSBill Taylor 	ibt_qp_alloc_attr_t	*qpi_attrp;
1899e39c5baSBill Taylor 	uint_t			qpi_type;
1909e39c5baSBill Taylor 	uint_t			qpi_port;
1919e39c5baSBill Taylor 	ibtl_qp_hdl_t		qpi_ibt_qphdl;
1929e39c5baSBill Taylor 	ibt_chan_sizes_t	*qpi_queueszp;
1939e39c5baSBill Taylor 	ib_qpn_t		*qpi_qpn;
1949e39c5baSBill Taylor 	hermon_qphdl_t		qpi_qphdl;
1959e39c5baSBill Taylor } hermon_qp_info_t;
1969e39c5baSBill Taylor 
1979e39c5baSBill Taylor /*
1989e39c5baSBill Taylor  * The QPN entry which is stored in the AVL tree
1999e39c5baSBill Taylor  */
2009e39c5baSBill Taylor typedef struct hermon_qpn_entry_s {
2019e39c5baSBill Taylor 	avl_node_t		qpn_avlnode;
2029e39c5baSBill Taylor 	uint_t			qpn_refcnt;
2039e39c5baSBill Taylor 	uint_t			qpn_counter;
2049e39c5baSBill Taylor 	uint_t			qpn_indx;
2059e39c5baSBill Taylor 	hermon_rsrc_t		*qpn_qpc;
2069e39c5baSBill Taylor } hermon_qpn_entry_t;
2079e39c5baSBill Taylor #define	HERMON_QPN_NOFLAG		0x0
2089e39c5baSBill Taylor #define	HERMON_QPN_RELEASE		0x1
2099e39c5baSBill Taylor #define	HERMON_QPN_FREE_ONLY		0x2
2109e39c5baSBill Taylor 
2119e39c5baSBill Taylor #define	HERMON_QP_OH_SIZE		0x0800
2129e39c5baSBill Taylor /*
2139e39c5baSBill Taylor  * 2KB, fixed per Mnox PRM 0.35c & conversation w/Mnox technical Sep 5, 2007
2149e39c5baSBill Taylor  */
2159e39c5baSBill Taylor 
2169e39c5baSBill Taylor /*
2179e39c5baSBill Taylor  * The hermon_sw_qp_s structure is also referred to using the "hermon_qphdl_t"
2189e39c5baSBill Taylor  * typedef (see hermon_typedef.h).  It encodes all the information necessary
2199e39c5baSBill Taylor  * to track the various resources needed to allocate, query, modify, and
2209e39c5baSBill Taylor  * (later) free both normal QP and special QP.
2219e39c5baSBill Taylor  *
2229e39c5baSBill Taylor  * Specifically, it has a lock to ensure single threaded access to the QP.
2239e39c5baSBill Taylor  * It has QP state, type, and number, pointers to the PD, MR, and CQ handles
2249e39c5baSBill Taylor  * associated with the QP, and pointers to the buffer where the work queues
2259e39c5baSBill Taylor  * come from.
2269e39c5baSBill Taylor  *
2279e39c5baSBill Taylor  * It has two pointers (one per work queue) to the workQ headers for the WRID
2289e39c5baSBill Taylor  * list, as well as pointers to the last WQE on each chain (used when
2299e39c5baSBill Taylor  * connecting a new chain of WQEs to a previously executing chain - see
2309e39c5baSBill Taylor  * hermon_wr.c).  It's also got the real WQE size, real number of SGL per WQE,
2319e39c5baSBill Taylor  * and the size of each of the work queues (in number of WQEs).
2329e39c5baSBill Taylor  *
2339e39c5baSBill Taylor  * Additionally, it has pointers to the resources associated with the QP,
2349e39c5baSBill Taylor  * including the obligatory backpointer to the resource for the QP handle
2359e39c5baSBill Taylor  * itself.  But it also has some flags, like "qp_forward_sqd_event" and
2369e39c5baSBill Taylor  * "qp_sqd_still_draining" (which are used to indicate whether a Send Queue
2379e39c5baSBill Taylor  * Drained Event should be forwarded to the IBTF) or "qp_is_special",
2389e39c5baSBill Taylor  * "qp_portnum", and "qp_pkeyindx" (which are used by special QP to store
2399e39c5baSBill Taylor  * necessary information about the type of the QP, which port it's connected
2409e39c5baSBill Taylor  * to, and what its current PKey index is set to).
2419e39c5baSBill Taylor  */
2429e39c5baSBill Taylor struct hermon_sw_qp_s {
2439e39c5baSBill Taylor 	kmutex_t		qp_lock;
2449e39c5baSBill Taylor 	uint_t			qp_state;
2459e39c5baSBill Taylor 	uint32_t		qp_qpnum;
2469e39c5baSBill Taylor 	hermon_pdhdl_t		qp_pdhdl;
2479e39c5baSBill Taylor 	uint_t			qp_serv_type;
248*17a2b317SBill Taylor 	ibt_qp_type_t		qp_type;
2499e39c5baSBill Taylor 	uint_t			qp_sl;		/* service level */
2509e39c5baSBill Taylor 	hermon_mrhdl_t		qp_mrhdl;
2519e39c5baSBill Taylor 	uint_t			qp_sq_sigtype;
2529e39c5baSBill Taylor 	uint_t			qp_is_special;
253*17a2b317SBill Taylor 	ibt_qp_alloc_flags_t	qp_alloc_flags;
2549e39c5baSBill Taylor 	uint32_t		qp_uarpg;
2559e39c5baSBill Taylor 	devmap_cookie_t		qp_umap_dhp;
2569e39c5baSBill Taylor 	uint_t			qp_portnum;	/* port 0/1 for HCA */
2579e39c5baSBill Taylor 	uint_t			qp_portnum_alt;	/* port 0/1 for HCA */
2589e39c5baSBill Taylor 	uint_t			qp_pkeyindx;
2599e39c5baSBill Taylor 	uint_t			qp_no_prefetch;
2609e39c5baSBill Taylor 				/* prefetch == 0, none == 1, for headroom */
2619e39c5baSBill Taylor 	uint_t			qp_rlky;	/* using reserved lkey */
2629e39c5baSBill Taylor 
2639e39c5baSBill Taylor 	/* Send Work Queue */
2649e39c5baSBill Taylor 	kmutex_t		qp_sq_lock;
2659e39c5baSBill Taylor 	hermon_cqhdl_t		qp_sq_cqhdl;
2669e39c5baSBill Taylor 	hermon_workq_avl_t	qp_sq_wqavl;
2679e39c5baSBill Taylor 	hermon_workq_hdr_t	*qp_sq_wqhdr;
2689e39c5baSBill Taylor 	uint32_t		*qp_sq_buf;
2699e39c5baSBill Taylor 	uint32_t		qp_sq_bufsz;
2709e39c5baSBill Taylor 	uint32_t		qp_sq_logqsz;	/* used to check owner valid */
2719e39c5baSBill Taylor 	uint32_t		qp_sq_log_wqesz;
2729e39c5baSBill Taylor 	uint32_t		qp_sq_headroom; /* #bytes needed for headroom */
2739e39c5baSBill Taylor 	uint32_t		qp_sq_hdrmwqes;	/* # wqes needed for headroom */
2749e39c5baSBill Taylor 	uint32_t		qp_sq_baseaddr;
2759e39c5baSBill Taylor 	uint32_t		qp_sq_sgl;
2769e39c5baSBill Taylor 	uint_t			qp_uses_lso;
2779e39c5baSBill Taylor 	uint32_t		qp_ring;
278*17a2b317SBill Taylor 	uint_t			qp_state_for_post_send; /* copy of qp_state */
2799e39c5baSBill Taylor 
2809e39c5baSBill Taylor 	/* Receive Work Queue - not used when SRQ is used */
2819e39c5baSBill Taylor 	hermon_cqhdl_t		qp_rq_cqhdl;
2829e39c5baSBill Taylor 	hermon_workq_avl_t	qp_rq_wqavl;	/* needed for srq */
2839e39c5baSBill Taylor 	hermon_workq_hdr_t	*qp_rq_wqhdr;
2849e39c5baSBill Taylor 	uint32_t		*qp_rq_buf;
2859e39c5baSBill Taylor 	uint32_t		qp_rq_bufsz;
2869e39c5baSBill Taylor 	uint32_t		qp_rq_logqsz;	/* used to check owner valid */
2879e39c5baSBill Taylor 	uint32_t		qp_rq_log_wqesz;
2889e39c5baSBill Taylor 	uint32_t		qp_rq_wqecntr;
2899e39c5baSBill Taylor 	uint32_t		qp_rq_baseaddr;
2909e39c5baSBill Taylor 	uint32_t		qp_rq_sgl;
2919e39c5baSBill Taylor 
2929e39c5baSBill Taylor 	/* DoorBell Record information */
2939e39c5baSBill Taylor 	ddi_acc_handle_t	qp_rq_dbr_acchdl;
2949e39c5baSBill Taylor 	hermon_dbr_t		*qp_rq_vdbr;
2959e39c5baSBill Taylor 	uint64_t		qp_rq_pdbr;
2969e39c5baSBill Taylor 	uint64_t		qp_rdbr_mapoffset;	/* user mode access */
2979e39c5baSBill Taylor 
2989e39c5baSBill Taylor 	uint64_t		qp_desc_off;
2999e39c5baSBill Taylor 
3009e39c5baSBill Taylor 	hermon_rsrc_t		*qp_qpcrsrcp;
3019e39c5baSBill Taylor 	hermon_rsrc_t		*qp_rsrcp;
3029e39c5baSBill Taylor 	void			*qp_hdlrarg;
3039e39c5baSBill Taylor 	uint_t			qp_forward_sqd_event;
3049e39c5baSBill Taylor 	uint_t			qp_sqd_still_draining;
3059e39c5baSBill Taylor 
3069e39c5baSBill Taylor 	/* Shared Receive Queue */
3079e39c5baSBill Taylor 	hermon_srqhdl_t		qp_srqhdl;
3089e39c5baSBill Taylor 
3099e39c5baSBill Taylor 	/* Refcnt of QP belongs to an MCG */
3109e39c5baSBill Taylor 	uint_t			qp_mcg_refcnt;
3119e39c5baSBill Taylor 
3129e39c5baSBill Taylor 	/* save the mtu from init2rtr for future use */
3139e39c5baSBill Taylor 	uint_t			qp_save_mtu;
3149e39c5baSBill Taylor 	hermon_qpn_entry_t	*qp_qpn_hdl;
3159e39c5baSBill Taylor 
3169e39c5baSBill Taylor 	struct hermon_qalloc_info_s qp_wqinfo;
3179e39c5baSBill Taylor 
318*17a2b317SBill Taylor 	ibt_fc_attr_t		qp_fc_attr;
319*17a2b317SBill Taylor 
320*17a2b317SBill Taylor 	struct hermon_qp_range_s *qp_rangep;
321*17a2b317SBill Taylor 
322*17a2b317SBill Taylor 	/* Beware: 8-byte alignment needed here */
323*17a2b317SBill Taylor 
3249e39c5baSBill Taylor 	struct hermon_hw_qpc_s qpc;
3259e39c5baSBill Taylor };
3269e39c5baSBill Taylor _NOTE(READ_ONLY_DATA(hermon_sw_qp_s::qp_qpnum
3279e39c5baSBill Taylor     hermon_sw_qp_s::qp_sq_buf
3289e39c5baSBill Taylor     hermon_sw_qp_s::qp_sq_log_wqesz
3299e39c5baSBill Taylor     hermon_sw_qp_s::qp_sq_bufsz
3309e39c5baSBill Taylor     hermon_sw_qp_s::qp_sq_sgl
3319e39c5baSBill Taylor     hermon_sw_qp_s::qp_rq_buf
3329e39c5baSBill Taylor     hermon_sw_qp_s::qp_rq_log_wqesz
3339e39c5baSBill Taylor     hermon_sw_qp_s::qp_rq_bufsz
3349e39c5baSBill Taylor     hermon_sw_qp_s::qp_rq_sgl
3359e39c5baSBill Taylor     hermon_sw_qp_s::qp_desc_off
3369e39c5baSBill Taylor     hermon_sw_qp_s::qp_mrhdl
3379e39c5baSBill Taylor     hermon_sw_qp_s::qp_wqinfo
3389e39c5baSBill Taylor     hermon_sw_qp_s::qp_qpcrsrcp
3399e39c5baSBill Taylor     hermon_sw_qp_s::qp_rsrcp
3409e39c5baSBill Taylor     hermon_sw_qp_s::qp_hdlrarg
3419e39c5baSBill Taylor     hermon_sw_qp_s::qp_pdhdl
3429e39c5baSBill Taylor     hermon_sw_qp_s::qp_sq_cqhdl
3439e39c5baSBill Taylor     hermon_sw_qp_s::qp_rq_cqhdl
3449e39c5baSBill Taylor     hermon_sw_qp_s::qp_sq_sigtype
3459e39c5baSBill Taylor     hermon_sw_qp_s::qp_serv_type
3469e39c5baSBill Taylor     hermon_sw_qp_s::qp_is_special
347*17a2b317SBill Taylor     hermon_sw_qp_s::qp_alloc_flags
3489e39c5baSBill Taylor     hermon_sw_qp_s::qp_uarpg
3499e39c5baSBill Taylor     hermon_sw_qp_s::qp_sq_wqhdr
3509e39c5baSBill Taylor     hermon_sw_qp_s::qp_rq_wqhdr
3519e39c5baSBill Taylor     hermon_sw_qp_s::qp_qpn_hdl))
3529e39c5baSBill Taylor _NOTE(MUTEX_PROTECTS_DATA(hermon_sw_qp_s::qp_lock,
3539e39c5baSBill Taylor     hermon_sw_qp_s::qp_state
3549e39c5baSBill Taylor     hermon_sw_qp_s::qpc
3559e39c5baSBill Taylor     hermon_sw_qp_s::qp_forward_sqd_event
3569e39c5baSBill Taylor     hermon_sw_qp_s::qp_sqd_still_draining
3579e39c5baSBill Taylor     hermon_sw_qp_s::qp_mcg_refcnt
3589e39c5baSBill Taylor     hermon_sw_qp_s::qp_save_mtu
3599e39c5baSBill Taylor     hermon_sw_qp_s::qp_umap_dhp))
3609e39c5baSBill Taylor _NOTE(SCHEME_PROTECTS_DATA("safe sharing",
3619e39c5baSBill Taylor     hermon_sw_qp_s::qp_pkeyindx
3629e39c5baSBill Taylor     hermon_sw_qp_s::qp_portnum))
3639e39c5baSBill Taylor 
364*17a2b317SBill Taylor #define	HERMON_SET_QP_POST_SEND_STATE(qp, state)			\
365*17a2b317SBill Taylor 	mutex_enter(&qp->qp_sq_lock);					\
366*17a2b317SBill Taylor 	qp->qp_state_for_post_send = state;				\
367*17a2b317SBill Taylor 	mutex_exit(&qp->qp_sq_lock)
3689e39c5baSBill Taylor 
3699e39c5baSBill Taylor /* Defined in hermon_qp.c */
3709e39c5baSBill Taylor int hermon_qp_alloc(hermon_state_t *state, hermon_qp_info_t *qpinfo,
3719e39c5baSBill Taylor     uint_t sleepflag);
3729e39c5baSBill Taylor int hermon_special_qp_alloc(hermon_state_t *state, hermon_qp_info_t *qpinfo,
3739e39c5baSBill Taylor     uint_t sleepflag);
374*17a2b317SBill Taylor int hermon_qp_alloc_range(hermon_state_t *state, uint_t log2,
375*17a2b317SBill Taylor     hermon_qp_info_t *qpinfo, ibtl_qp_hdl_t *ibtl_qp_p, ibc_cq_hdl_t *send_cq_p,
376*17a2b317SBill Taylor     ibc_cq_hdl_t *recv_cq_p, hermon_qphdl_t *qp_p, uint_t sleepflag);
3779e39c5baSBill Taylor int hermon_qp_free(hermon_state_t *state, hermon_qphdl_t *qphdl,
3789e39c5baSBill Taylor     ibc_free_qp_flags_t free_qp_flags, ibc_qpn_hdl_t *qpnh, uint_t sleepflag);
3799e39c5baSBill Taylor int hermon_qp_query(hermon_state_t *state, hermon_qphdl_t qphdl,
3809e39c5baSBill Taylor     ibt_qp_query_attr_t *attr_p);
3819e39c5baSBill Taylor hermon_qphdl_t hermon_qphdl_from_qpnum(hermon_state_t *state, uint_t qpnum);
3829e39c5baSBill Taylor void hermon_qp_release_qpn(hermon_state_t *state, hermon_qpn_entry_t *entry,
3839e39c5baSBill Taylor     int flags);
3849e39c5baSBill Taylor void hermon_qpn_avl_init(hermon_state_t *state);
3859e39c5baSBill Taylor void hermon_qpn_avl_fini(hermon_state_t *state);
3869e39c5baSBill Taylor 
3879e39c5baSBill Taylor /* Defined in hermon_qpmod.c */
3889e39c5baSBill Taylor int hermon_qp_modify(hermon_state_t *state, hermon_qphdl_t qp,
3899e39c5baSBill Taylor     ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p,
3909e39c5baSBill Taylor     ibt_queue_sizes_t *actual_sz);
3919e39c5baSBill Taylor int hermon_qp_to_reset(hermon_state_t *state, hermon_qphdl_t qp);
3929e39c5baSBill Taylor 
3939e39c5baSBill Taylor #ifdef __cplusplus
3949e39c5baSBill Taylor }
3959e39c5baSBill Taylor #endif
3969e39c5baSBill Taylor 
3979e39c5baSBill Taylor #endif	/* _SYS_IB_ADAPTERS_HERMON_QP_H */
398