xref: /onnv-gate/usr/src/uts/common/sys/ib/adapters/hermon/hermon_qp.h (revision 12965:b65a8427f8fe)
19517SBill.Taylor@Sun.COM /*
29517SBill.Taylor@Sun.COM  * CDDL HEADER START
39517SBill.Taylor@Sun.COM  *
49517SBill.Taylor@Sun.COM  * The contents of this file are subject to the terms of the
59517SBill.Taylor@Sun.COM  * Common Development and Distribution License (the "License").
69517SBill.Taylor@Sun.COM  * You may not use this file except in compliance with the License.
79517SBill.Taylor@Sun.COM  *
89517SBill.Taylor@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
99517SBill.Taylor@Sun.COM  * or http://www.opensolaris.org/os/licensing.
109517SBill.Taylor@Sun.COM  * See the License for the specific language governing permissions
119517SBill.Taylor@Sun.COM  * and limitations under the License.
129517SBill.Taylor@Sun.COM  *
139517SBill.Taylor@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
149517SBill.Taylor@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
159517SBill.Taylor@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
169517SBill.Taylor@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
179517SBill.Taylor@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
189517SBill.Taylor@Sun.COM  *
199517SBill.Taylor@Sun.COM  * CDDL HEADER END
209517SBill.Taylor@Sun.COM  */
219517SBill.Taylor@Sun.COM 
229517SBill.Taylor@Sun.COM /*
23*12965SWilliam.Taylor@Oracle.COM  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
249517SBill.Taylor@Sun.COM  */
259517SBill.Taylor@Sun.COM 
269517SBill.Taylor@Sun.COM #ifndef	_SYS_IB_ADAPTERS_HERMON_QP_H
279517SBill.Taylor@Sun.COM #define	_SYS_IB_ADAPTERS_HERMON_QP_H
289517SBill.Taylor@Sun.COM 
299517SBill.Taylor@Sun.COM /*
309517SBill.Taylor@Sun.COM  * hermon_qp.h
319517SBill.Taylor@Sun.COM  *    Contains all of the prototypes, #defines, and structures necessary
329517SBill.Taylor@Sun.COM  *    for all of the Queue Pair Processing routines.
339517SBill.Taylor@Sun.COM  *    Specifically it contains the various flags, structures used for managing
349517SBill.Taylor@Sun.COM  *    Hermon queue pairs, and prototypes for many of the functions consumed by
359517SBill.Taylor@Sun.COM  *    other parts of the Hermon driver (including those routines directly
369517SBill.Taylor@Sun.COM  *    exposed through the IBTF CI interface).
379517SBill.Taylor@Sun.COM  *
389517SBill.Taylor@Sun.COM  *    Most of the values defined below establish default values which,
399517SBill.Taylor@Sun.COM  *    where indicated, can be controlled via their related patchable values,
409517SBill.Taylor@Sun.COM  *    if 'hermon_alt_config_enable' is set.
419517SBill.Taylor@Sun.COM  */
429517SBill.Taylor@Sun.COM 
439517SBill.Taylor@Sun.COM #include <sys/types.h>
449517SBill.Taylor@Sun.COM #include <sys/conf.h>
459517SBill.Taylor@Sun.COM #include <sys/ddi.h>
469517SBill.Taylor@Sun.COM #include <sys/sunddi.h>
479517SBill.Taylor@Sun.COM 
489517SBill.Taylor@Sun.COM #ifdef __cplusplus
499517SBill.Taylor@Sun.COM extern "C" {
509517SBill.Taylor@Sun.COM #endif
519517SBill.Taylor@Sun.COM 
529517SBill.Taylor@Sun.COM /*
539517SBill.Taylor@Sun.COM  * The following defines the default number of Queue Pairs. This value is
549517SBill.Taylor@Sun.COM  * controlled via the "hermon_log_num_qp" configuration variables.
559517SBill.Taylor@Sun.COM  * We also have a define for the minimum size of a QP.  QPs allocated
569517SBill.Taylor@Sun.COM  * with size 0, 1, 2, or 3 will always get back a QP of size 4.
57*12965SWilliam.Taylor@Oracle.COM  *
58*12965SWilliam.Taylor@Oracle.COM  * Note: Increasing #QPs from 64K to 256K for reserved ranges for FCoIB.
599517SBill.Taylor@Sun.COM  */
60*12965SWilliam.Taylor@Oracle.COM #define	HERMON_NUM_QP_SHIFT		0x12
61*12965SWilliam.Taylor@Oracle.COM #define	HERMON_NUM_QPS			(1 << HERMON_NUM_QP_SHIFT) /* 256K */
629517SBill.Taylor@Sun.COM #define	HERMON_QP_MIN_SIZE		0xf
639517SBill.Taylor@Sun.COM 
649517SBill.Taylor@Sun.COM /*
659517SBill.Taylor@Sun.COM  * The following defines the default number of Hermon RDMA Remote read
669517SBill.Taylor@Sun.COM  * database (RDB) entries per QP.  This value is controllable through the
679517SBill.Taylor@Sun.COM  * "hermon_log_num_rdb_per_qp" configuration variable.
689517SBill.Taylor@Sun.COM  */
699517SBill.Taylor@Sun.COM #define	HERMON_LOG_NUM_RDB_PER_QP	0x4
709517SBill.Taylor@Sun.COM 
719517SBill.Taylor@Sun.COM /*
729517SBill.Taylor@Sun.COM  * This defines the maximum number of SGLs per WQE.  This value is
739517SBill.Taylor@Sun.COM  * controllable through the "hermon_wqe_max_sgl" configuration variable
749517SBill.Taylor@Sun.COM  * (but should not be set larger than this value).
759517SBill.Taylor@Sun.COM  */
769517SBill.Taylor@Sun.COM #define	HERMON_NUM_SGL_PER_WQE		0x10
779517SBill.Taylor@Sun.COM 
789517SBill.Taylor@Sun.COM /*
799517SBill.Taylor@Sun.COM  * Maximum QP number mask (QP number is 24 bits).
809517SBill.Taylor@Sun.COM  * We reserve the most significant bit to indicate an "XRC" QP
819517SBill.Taylor@Sun.COM  * as recommended by the PRM.  All XRC QPs will have this bit set.
829517SBill.Taylor@Sun.COM  */
839517SBill.Taylor@Sun.COM #define	HERMON_QP_MAXNUMBER_MSK		0x7FFFFF
84*12965SWilliam.Taylor@Oracle.COM #define	HERMON_QP_XRC_MSK		0x800000
859517SBill.Taylor@Sun.COM 
869517SBill.Taylor@Sun.COM /*
879517SBill.Taylor@Sun.COM  * This define and the following macro are used to find a schedule queue for
889517SBill.Taylor@Sun.COM  * a new QP based on its queue pair number.  Note:  This is a rather simple
899517SBill.Taylor@Sun.COM  * method that we use today.  We simply choose from the schedule queue based
909517SBill.Taylor@Sun.COM  * on the 4 least significant bits of the QP number.
919517SBill.Taylor@Sun.COM  */
929517SBill.Taylor@Sun.COM 
939517SBill.Taylor@Sun.COM /*
949517SBill.Taylor@Sun.COM  * The following defines are used to indicate whether a QP is special or
959517SBill.Taylor@Sun.COM  * not (and what type it is).  They are used in the "qp_is_special" field
969517SBill.Taylor@Sun.COM  * below in qp_state.  If "qp_is_special" == 0 then an ordinary data qp.
979517SBill.Taylor@Sun.COM  */
989517SBill.Taylor@Sun.COM 
999517SBill.Taylor@Sun.COM /*
1009517SBill.Taylor@Sun.COM  * The sl is selected based on the qpnum as it was for Tavor/Arbel, except for
1019517SBill.Taylor@Sun.COM  * QP0, which is defined as being 0xF
1029517SBill.Taylor@Sun.COM  */
1039517SBill.Taylor@Sun.COM 
1049517SBill.Taylor@Sun.COM #define	HERMON_QP_SMI			0x1
1059517SBill.Taylor@Sun.COM #define	HERMON_QP_GSI			0x2
1069517SBill.Taylor@Sun.COM 
1079517SBill.Taylor@Sun.COM #define	HERMON_DEF_SCHED_POLICY		0x03
1089517SBill.Taylor@Sun.COM #define	HERMON_DEF_SCHED_SELECTION	0x0F
1099517SBill.Taylor@Sun.COM 
1109517SBill.Taylor@Sun.COM #define	HERMON_QP_SCHEDQ_GET(port, sl, issmi)   \
1119517SBill.Taylor@Sun.COM 	(HERMON_DEF_SCHED_POLICY 		\
1129517SBill.Taylor@Sun.COM 	| (issmi == HERMON_QP_SMI ? (HERMON_DEF_SCHED_SELECTION << 2) : \
1139517SBill.Taylor@Sun.COM 	((issmi == HERMON_QP_GSI ? 0 : (sl & 0XF)) << 2)) \
1149517SBill.Taylor@Sun.COM 	| ((port & 0x01) << 6) \
1159517SBill.Taylor@Sun.COM 	| ((issmi == HERMON_QP_SMI ? 0 : 1) << 7))
1169517SBill.Taylor@Sun.COM 
1179517SBill.Taylor@Sun.COM 
1189517SBill.Taylor@Sun.COM /*
1199517SBill.Taylor@Sun.COM  * This define determines the frequency with which the AckReq bit will be
1209517SBill.Taylor@Sun.COM  * set in outgoing RC packets.  By default it is set to five (5) or 2^5 = 32.
1219517SBill.Taylor@Sun.COM  * So AckReq will be set once every 32 packets sent.  This value is
1229517SBill.Taylor@Sun.COM  * controllable through the "hermon_qp_ackreq_freq" configuration variable.
1239517SBill.Taylor@Sun.COM  */
1249517SBill.Taylor@Sun.COM #define	HERMON_QP_ACKREQ_FREQ		0x5
1259517SBill.Taylor@Sun.COM 
1269517SBill.Taylor@Sun.COM /*
1279517SBill.Taylor@Sun.COM  * Define the maximum message size (log 2).  Note: This value corresponds
1289517SBill.Taylor@Sun.COM  * to the maximum allowable message sized as defined by the IBA spec.
1299517SBill.Taylor@Sun.COM  */
1309517SBill.Taylor@Sun.COM #define	HERMON_QP_LOG_MAX_MSGSZ		0x1F
1319517SBill.Taylor@Sun.COM 
1329517SBill.Taylor@Sun.COM /*
1339517SBill.Taylor@Sun.COM  * This macro is used to determine if the hermon QP type (qp_serv) is the
1349517SBill.Taylor@Sun.COM  * same as the caller passed in IBT type (qp_trans).  This is used in QP modify
1359517SBill.Taylor@Sun.COM  * to ensure the types match.
1369517SBill.Taylor@Sun.COM  */
1379517SBill.Taylor@Sun.COM #define	HERMON_QP_TYPE_VALID(qp_trans, qp_serv)				\
138*12965SWilliam.Taylor@Oracle.COM 	((qp_trans == IBT_RC_SRV && qp_serv == HERMON_QP_RC) ||		\
139*12965SWilliam.Taylor@Oracle.COM 	(qp_trans == IBT_UD_SRV && (qp_serv == HERMON_QP_UD ||		\
140*12965SWilliam.Taylor@Oracle.COM 	qp_serv == HERMON_QP_RFCI || qp_serv == HERMON_QP_FCMND ||	\
141*12965SWilliam.Taylor@Oracle.COM 	qp_serv == HERMON_QP_FEXCH)) ||					\
1429517SBill.Taylor@Sun.COM 	(qp_trans == IBT_UC_SRV && qp_serv == HERMON_QP_UC))
1439517SBill.Taylor@Sun.COM 
1449517SBill.Taylor@Sun.COM /*
1459517SBill.Taylor@Sun.COM  * The following enumerated type is used to capture all the various types
1469517SBill.Taylor@Sun.COM  * of Hermon work queue types. It is specifically used as an argument to the
1479517SBill.Taylor@Sun.COM  * to the hermon_qp_sgl_to_logwqesz() routine to determine the amount of
1489517SBill.Taylor@Sun.COM  * overhead (in WQE header size) consumed by each of the types. This
1499517SBill.Taylor@Sun.COM  * information is used to round the WQE size to the next largest power-of-2
1509517SBill.Taylor@Sun.COM  * (and to determine the number of SGLs that are supported for the given WQE
1519517SBill.Taylor@Sun.COM  * type).  There is also a define below used to specify the minimum size for a
1529517SBill.Taylor@Sun.COM  * WQE.  The minimum size is set to 64 bytes (a single cacheline).
1539517SBill.Taylor@Sun.COM  */
1549517SBill.Taylor@Sun.COM 
1559517SBill.Taylor@Sun.COM typedef enum {
1569517SBill.Taylor@Sun.COM 	HERMON_QP_WQ_TYPE_SENDQ_UD,
1579517SBill.Taylor@Sun.COM 	HERMON_QP_WQ_TYPE_SENDQ_CONN,
1589517SBill.Taylor@Sun.COM 	HERMON_QP_WQ_TYPE_RECVQ,
1599517SBill.Taylor@Sun.COM 	HERMON_QP_WQ_TYPE_SENDMLX_QP0,
1609517SBill.Taylor@Sun.COM 	HERMON_QP_WQ_TYPE_SENDMLX_QP1
1619517SBill.Taylor@Sun.COM } hermon_qp_wq_type_t;
1629517SBill.Taylor@Sun.COM #define	HERMON_QP_WQE_MLX_SND_HDRS	0x40
1639517SBill.Taylor@Sun.COM #define	HERMON_QP_WQE_MLX_RCV_HDRS	0x00
1649517SBill.Taylor@Sun.COM #define	HERMON_QP_WQE_MLX_SRQ_HDRS	0x10
1659517SBill.Taylor@Sun.COM #define	HERMON_QP_WQE_MLX_QP0_HDRS	0x40
1669517SBill.Taylor@Sun.COM #define	HERMON_QP_WQE_MLX_QP1_HDRS	0x70
1679517SBill.Taylor@Sun.COM #define	HERMON_QP_WQE_LOG_MINIMUM	0x6
1689517SBill.Taylor@Sun.COM 
1699517SBill.Taylor@Sun.COM 
1709517SBill.Taylor@Sun.COM /*
171*12965SWilliam.Taylor@Oracle.COM  * The hermon_qp_range_t is used to manage a qp_range for RSS and FEXCH.
172*12965SWilliam.Taylor@Oracle.COM  * It has a reference count.  When the reference count goes to 0,
173*12965SWilliam.Taylor@Oracle.COM  * the qpc resource can be freed.
174*12965SWilliam.Taylor@Oracle.COM  */
175*12965SWilliam.Taylor@Oracle.COM typedef struct hermon_qp_range_s {
176*12965SWilliam.Taylor@Oracle.COM 	kmutex_t	hqpr_lock;
177*12965SWilliam.Taylor@Oracle.COM 	hermon_rsrc_t	*hqpr_qpcrsrc;
178*12965SWilliam.Taylor@Oracle.COM 	uint_t		hqpr_refcnt;
179*12965SWilliam.Taylor@Oracle.COM } hermon_qp_range_t;
180*12965SWilliam.Taylor@Oracle.COM 
181*12965SWilliam.Taylor@Oracle.COM /*
1829517SBill.Taylor@Sun.COM  * The hermon_qp_info_t structure is used internally by the Hermon driver to
1839517SBill.Taylor@Sun.COM  * pass information to and from the hermon_qp_alloc() and
1849517SBill.Taylor@Sun.COM  * hermon_special_qp_alloc() routines.  It contains placeholders for all of the
1859517SBill.Taylor@Sun.COM  * potential inputs and outputs that either routine can take.
1869517SBill.Taylor@Sun.COM  */
1879517SBill.Taylor@Sun.COM typedef struct hermon_qp_info_s {
1889517SBill.Taylor@Sun.COM 	ibt_qp_alloc_attr_t	*qpi_attrp;
1899517SBill.Taylor@Sun.COM 	uint_t			qpi_type;
1909517SBill.Taylor@Sun.COM 	uint_t			qpi_port;
1919517SBill.Taylor@Sun.COM 	ibtl_qp_hdl_t		qpi_ibt_qphdl;
1929517SBill.Taylor@Sun.COM 	ibt_chan_sizes_t	*qpi_queueszp;
1939517SBill.Taylor@Sun.COM 	ib_qpn_t		*qpi_qpn;
1949517SBill.Taylor@Sun.COM 	hermon_qphdl_t		qpi_qphdl;
1959517SBill.Taylor@Sun.COM } hermon_qp_info_t;
1969517SBill.Taylor@Sun.COM 
1979517SBill.Taylor@Sun.COM /*
1989517SBill.Taylor@Sun.COM  * The QPN entry which is stored in the AVL tree
1999517SBill.Taylor@Sun.COM  */
2009517SBill.Taylor@Sun.COM typedef struct hermon_qpn_entry_s {
2019517SBill.Taylor@Sun.COM 	avl_node_t		qpn_avlnode;
2029517SBill.Taylor@Sun.COM 	uint_t			qpn_refcnt;
2039517SBill.Taylor@Sun.COM 	uint_t			qpn_counter;
2049517SBill.Taylor@Sun.COM 	uint_t			qpn_indx;
2059517SBill.Taylor@Sun.COM 	hermon_rsrc_t		*qpn_qpc;
2069517SBill.Taylor@Sun.COM } hermon_qpn_entry_t;
2079517SBill.Taylor@Sun.COM #define	HERMON_QPN_NOFLAG		0x0
2089517SBill.Taylor@Sun.COM #define	HERMON_QPN_RELEASE		0x1
2099517SBill.Taylor@Sun.COM #define	HERMON_QPN_FREE_ONLY		0x2
2109517SBill.Taylor@Sun.COM 
2119517SBill.Taylor@Sun.COM #define	HERMON_QP_OH_SIZE		0x0800
2129517SBill.Taylor@Sun.COM /*
2139517SBill.Taylor@Sun.COM  * 2KB, fixed per Mnox PRM 0.35c & conversation w/Mnox technical Sep 5, 2007
2149517SBill.Taylor@Sun.COM  */
2159517SBill.Taylor@Sun.COM 
2169517SBill.Taylor@Sun.COM /*
2179517SBill.Taylor@Sun.COM  * The hermon_sw_qp_s structure is also referred to using the "hermon_qphdl_t"
2189517SBill.Taylor@Sun.COM  * typedef (see hermon_typedef.h).  It encodes all the information necessary
2199517SBill.Taylor@Sun.COM  * to track the various resources needed to allocate, query, modify, and
2209517SBill.Taylor@Sun.COM  * (later) free both normal QP and special QP.
2219517SBill.Taylor@Sun.COM  *
2229517SBill.Taylor@Sun.COM  * Specifically, it has a lock to ensure single threaded access to the QP.
2239517SBill.Taylor@Sun.COM  * It has QP state, type, and number, pointers to the PD, MR, and CQ handles
2249517SBill.Taylor@Sun.COM  * associated with the QP, and pointers to the buffer where the work queues
2259517SBill.Taylor@Sun.COM  * come from.
2269517SBill.Taylor@Sun.COM  *
2279517SBill.Taylor@Sun.COM  * It has two pointers (one per work queue) to the workQ headers for the WRID
2289517SBill.Taylor@Sun.COM  * list, as well as pointers to the last WQE on each chain (used when
2299517SBill.Taylor@Sun.COM  * connecting a new chain of WQEs to a previously executing chain - see
2309517SBill.Taylor@Sun.COM  * hermon_wr.c).  It's also got the real WQE size, real number of SGL per WQE,
2319517SBill.Taylor@Sun.COM  * and the size of each of the work queues (in number of WQEs).
2329517SBill.Taylor@Sun.COM  *
2339517SBill.Taylor@Sun.COM  * Additionally, it has pointers to the resources associated with the QP,
2349517SBill.Taylor@Sun.COM  * including the obligatory backpointer to the resource for the QP handle
2359517SBill.Taylor@Sun.COM  * itself.  But it also has some flags, like "qp_forward_sqd_event" and
2369517SBill.Taylor@Sun.COM  * "qp_sqd_still_draining" (which are used to indicate whether a Send Queue
2379517SBill.Taylor@Sun.COM  * Drained Event should be forwarded to the IBTF) or "qp_is_special",
2389517SBill.Taylor@Sun.COM  * "qp_portnum", and "qp_pkeyindx" (which are used by special QP to store
2399517SBill.Taylor@Sun.COM  * necessary information about the type of the QP, which port it's connected
2409517SBill.Taylor@Sun.COM  * to, and what its current PKey index is set to).
2419517SBill.Taylor@Sun.COM  */
2429517SBill.Taylor@Sun.COM struct hermon_sw_qp_s {
2439517SBill.Taylor@Sun.COM 	kmutex_t		qp_lock;
2449517SBill.Taylor@Sun.COM 	uint_t			qp_state;
2459517SBill.Taylor@Sun.COM 	uint32_t		qp_qpnum;
2469517SBill.Taylor@Sun.COM 	hermon_pdhdl_t		qp_pdhdl;
2479517SBill.Taylor@Sun.COM 	uint_t			qp_serv_type;
248*12965SWilliam.Taylor@Oracle.COM 	ibt_qp_type_t		qp_type;
2499517SBill.Taylor@Sun.COM 	uint_t			qp_sl;		/* service level */
2509517SBill.Taylor@Sun.COM 	hermon_mrhdl_t		qp_mrhdl;
2519517SBill.Taylor@Sun.COM 	uint_t			qp_sq_sigtype;
2529517SBill.Taylor@Sun.COM 	uint_t			qp_is_special;
253*12965SWilliam.Taylor@Oracle.COM 	ibt_qp_alloc_flags_t	qp_alloc_flags;
2549517SBill.Taylor@Sun.COM 	uint32_t		qp_uarpg;
2559517SBill.Taylor@Sun.COM 	devmap_cookie_t		qp_umap_dhp;
2569517SBill.Taylor@Sun.COM 	uint_t			qp_portnum;	/* port 0/1 for HCA */
2579517SBill.Taylor@Sun.COM 	uint_t			qp_portnum_alt;	/* port 0/1 for HCA */
2589517SBill.Taylor@Sun.COM 	uint_t			qp_pkeyindx;
2599517SBill.Taylor@Sun.COM 	uint_t			qp_no_prefetch;
2609517SBill.Taylor@Sun.COM 				/* prefetch == 0, none == 1, for headroom */
2619517SBill.Taylor@Sun.COM 	uint_t			qp_rlky;	/* using reserved lkey */
2629517SBill.Taylor@Sun.COM 
2639517SBill.Taylor@Sun.COM 	/* Send Work Queue */
2649517SBill.Taylor@Sun.COM 	kmutex_t		qp_sq_lock;
2659517SBill.Taylor@Sun.COM 	hermon_cqhdl_t		qp_sq_cqhdl;
2669517SBill.Taylor@Sun.COM 	hermon_workq_avl_t	qp_sq_wqavl;
2679517SBill.Taylor@Sun.COM 	hermon_workq_hdr_t	*qp_sq_wqhdr;
2689517SBill.Taylor@Sun.COM 	uint32_t		*qp_sq_buf;
2699517SBill.Taylor@Sun.COM 	uint32_t		qp_sq_bufsz;
2709517SBill.Taylor@Sun.COM 	uint32_t		qp_sq_logqsz;	/* used to check owner valid */
2719517SBill.Taylor@Sun.COM 	uint32_t		qp_sq_log_wqesz;
2729517SBill.Taylor@Sun.COM 	uint32_t		qp_sq_headroom; /* #bytes needed for headroom */
2739517SBill.Taylor@Sun.COM 	uint32_t		qp_sq_hdrmwqes;	/* # wqes needed for headroom */
2749517SBill.Taylor@Sun.COM 	uint32_t		qp_sq_baseaddr;
2759517SBill.Taylor@Sun.COM 	uint32_t		qp_sq_sgl;
2769517SBill.Taylor@Sun.COM 	uint_t			qp_uses_lso;
2779517SBill.Taylor@Sun.COM 	uint32_t		qp_ring;
278*12965SWilliam.Taylor@Oracle.COM 	uint_t			qp_state_for_post_send; /* copy of qp_state */
2799517SBill.Taylor@Sun.COM 
2809517SBill.Taylor@Sun.COM 	/* Receive Work Queue - not used when SRQ is used */
2819517SBill.Taylor@Sun.COM 	hermon_cqhdl_t		qp_rq_cqhdl;
2829517SBill.Taylor@Sun.COM 	hermon_workq_avl_t	qp_rq_wqavl;	/* needed for srq */
2839517SBill.Taylor@Sun.COM 	hermon_workq_hdr_t	*qp_rq_wqhdr;
2849517SBill.Taylor@Sun.COM 	uint32_t		*qp_rq_buf;
2859517SBill.Taylor@Sun.COM 	uint32_t		qp_rq_bufsz;
2869517SBill.Taylor@Sun.COM 	uint32_t		qp_rq_logqsz;	/* used to check owner valid */
2879517SBill.Taylor@Sun.COM 	uint32_t		qp_rq_log_wqesz;
2889517SBill.Taylor@Sun.COM 	uint32_t		qp_rq_wqecntr;
2899517SBill.Taylor@Sun.COM 	uint32_t		qp_rq_baseaddr;
2909517SBill.Taylor@Sun.COM 	uint32_t		qp_rq_sgl;
2919517SBill.Taylor@Sun.COM 
2929517SBill.Taylor@Sun.COM 	/* DoorBell Record information */
2939517SBill.Taylor@Sun.COM 	ddi_acc_handle_t	qp_rq_dbr_acchdl;
2949517SBill.Taylor@Sun.COM 	hermon_dbr_t		*qp_rq_vdbr;
2959517SBill.Taylor@Sun.COM 	uint64_t		qp_rq_pdbr;
2969517SBill.Taylor@Sun.COM 	uint64_t		qp_rdbr_mapoffset;	/* user mode access */
2979517SBill.Taylor@Sun.COM 
2989517SBill.Taylor@Sun.COM 	uint64_t		qp_desc_off;
2999517SBill.Taylor@Sun.COM 
3009517SBill.Taylor@Sun.COM 	hermon_rsrc_t		*qp_qpcrsrcp;
3019517SBill.Taylor@Sun.COM 	hermon_rsrc_t		*qp_rsrcp;
3029517SBill.Taylor@Sun.COM 	void			*qp_hdlrarg;
3039517SBill.Taylor@Sun.COM 	uint_t			qp_forward_sqd_event;
3049517SBill.Taylor@Sun.COM 	uint_t			qp_sqd_still_draining;
3059517SBill.Taylor@Sun.COM 
3069517SBill.Taylor@Sun.COM 	/* Shared Receive Queue */
3079517SBill.Taylor@Sun.COM 	hermon_srqhdl_t		qp_srqhdl;
3089517SBill.Taylor@Sun.COM 
3099517SBill.Taylor@Sun.COM 	/* Refcnt of QP belongs to an MCG */
3109517SBill.Taylor@Sun.COM 	uint_t			qp_mcg_refcnt;
3119517SBill.Taylor@Sun.COM 
3129517SBill.Taylor@Sun.COM 	/* save the mtu from init2rtr for future use */
3139517SBill.Taylor@Sun.COM 	uint_t			qp_save_mtu;
3149517SBill.Taylor@Sun.COM 	hermon_qpn_entry_t	*qp_qpn_hdl;
3159517SBill.Taylor@Sun.COM 
3169517SBill.Taylor@Sun.COM 	struct hermon_qalloc_info_s qp_wqinfo;
3179517SBill.Taylor@Sun.COM 
318*12965SWilliam.Taylor@Oracle.COM 	ibt_fc_attr_t		qp_fc_attr;
319*12965SWilliam.Taylor@Oracle.COM 
320*12965SWilliam.Taylor@Oracle.COM 	struct hermon_qp_range_s *qp_rangep;
321*12965SWilliam.Taylor@Oracle.COM 
322*12965SWilliam.Taylor@Oracle.COM 	/* Beware: 8-byte alignment needed here */
323*12965SWilliam.Taylor@Oracle.COM 
3249517SBill.Taylor@Sun.COM 	struct hermon_hw_qpc_s qpc;
3259517SBill.Taylor@Sun.COM };
3269517SBill.Taylor@Sun.COM _NOTE(READ_ONLY_DATA(hermon_sw_qp_s::qp_qpnum
3279517SBill.Taylor@Sun.COM     hermon_sw_qp_s::qp_sq_buf
3289517SBill.Taylor@Sun.COM     hermon_sw_qp_s::qp_sq_log_wqesz
3299517SBill.Taylor@Sun.COM     hermon_sw_qp_s::qp_sq_bufsz
3309517SBill.Taylor@Sun.COM     hermon_sw_qp_s::qp_sq_sgl
3319517SBill.Taylor@Sun.COM     hermon_sw_qp_s::qp_rq_buf
3329517SBill.Taylor@Sun.COM     hermon_sw_qp_s::qp_rq_log_wqesz
3339517SBill.Taylor@Sun.COM     hermon_sw_qp_s::qp_rq_bufsz
3349517SBill.Taylor@Sun.COM     hermon_sw_qp_s::qp_rq_sgl
3359517SBill.Taylor@Sun.COM     hermon_sw_qp_s::qp_desc_off
3369517SBill.Taylor@Sun.COM     hermon_sw_qp_s::qp_mrhdl
3379517SBill.Taylor@Sun.COM     hermon_sw_qp_s::qp_wqinfo
3389517SBill.Taylor@Sun.COM     hermon_sw_qp_s::qp_qpcrsrcp
3399517SBill.Taylor@Sun.COM     hermon_sw_qp_s::qp_rsrcp
3409517SBill.Taylor@Sun.COM     hermon_sw_qp_s::qp_hdlrarg
3419517SBill.Taylor@Sun.COM     hermon_sw_qp_s::qp_pdhdl
3429517SBill.Taylor@Sun.COM     hermon_sw_qp_s::qp_sq_cqhdl
3439517SBill.Taylor@Sun.COM     hermon_sw_qp_s::qp_rq_cqhdl
3449517SBill.Taylor@Sun.COM     hermon_sw_qp_s::qp_sq_sigtype
3459517SBill.Taylor@Sun.COM     hermon_sw_qp_s::qp_serv_type
3469517SBill.Taylor@Sun.COM     hermon_sw_qp_s::qp_is_special
347*12965SWilliam.Taylor@Oracle.COM     hermon_sw_qp_s::qp_alloc_flags
3489517SBill.Taylor@Sun.COM     hermon_sw_qp_s::qp_uarpg
3499517SBill.Taylor@Sun.COM     hermon_sw_qp_s::qp_sq_wqhdr
3509517SBill.Taylor@Sun.COM     hermon_sw_qp_s::qp_rq_wqhdr
3519517SBill.Taylor@Sun.COM     hermon_sw_qp_s::qp_qpn_hdl))
3529517SBill.Taylor@Sun.COM _NOTE(MUTEX_PROTECTS_DATA(hermon_sw_qp_s::qp_lock,
3539517SBill.Taylor@Sun.COM     hermon_sw_qp_s::qp_state
3549517SBill.Taylor@Sun.COM     hermon_sw_qp_s::qpc
3559517SBill.Taylor@Sun.COM     hermon_sw_qp_s::qp_forward_sqd_event
3569517SBill.Taylor@Sun.COM     hermon_sw_qp_s::qp_sqd_still_draining
3579517SBill.Taylor@Sun.COM     hermon_sw_qp_s::qp_mcg_refcnt
3589517SBill.Taylor@Sun.COM     hermon_sw_qp_s::qp_save_mtu
3599517SBill.Taylor@Sun.COM     hermon_sw_qp_s::qp_umap_dhp))
3609517SBill.Taylor@Sun.COM _NOTE(SCHEME_PROTECTS_DATA("safe sharing",
3619517SBill.Taylor@Sun.COM     hermon_sw_qp_s::qp_pkeyindx
3629517SBill.Taylor@Sun.COM     hermon_sw_qp_s::qp_portnum))
3639517SBill.Taylor@Sun.COM 
364*12965SWilliam.Taylor@Oracle.COM #define	HERMON_SET_QP_POST_SEND_STATE(qp, state)			\
365*12965SWilliam.Taylor@Oracle.COM 	mutex_enter(&qp->qp_sq_lock);					\
366*12965SWilliam.Taylor@Oracle.COM 	qp->qp_state_for_post_send = state;				\
367*12965SWilliam.Taylor@Oracle.COM 	mutex_exit(&qp->qp_sq_lock)
3689517SBill.Taylor@Sun.COM 
3699517SBill.Taylor@Sun.COM /* Defined in hermon_qp.c */
3709517SBill.Taylor@Sun.COM int hermon_qp_alloc(hermon_state_t *state, hermon_qp_info_t *qpinfo,
3719517SBill.Taylor@Sun.COM     uint_t sleepflag);
3729517SBill.Taylor@Sun.COM int hermon_special_qp_alloc(hermon_state_t *state, hermon_qp_info_t *qpinfo,
3739517SBill.Taylor@Sun.COM     uint_t sleepflag);
374*12965SWilliam.Taylor@Oracle.COM int hermon_qp_alloc_range(hermon_state_t *state, uint_t log2,
375*12965SWilliam.Taylor@Oracle.COM     hermon_qp_info_t *qpinfo, ibtl_qp_hdl_t *ibtl_qp_p, ibc_cq_hdl_t *send_cq_p,
376*12965SWilliam.Taylor@Oracle.COM     ibc_cq_hdl_t *recv_cq_p, hermon_qphdl_t *qp_p, uint_t sleepflag);
3779517SBill.Taylor@Sun.COM int hermon_qp_free(hermon_state_t *state, hermon_qphdl_t *qphdl,
3789517SBill.Taylor@Sun.COM     ibc_free_qp_flags_t free_qp_flags, ibc_qpn_hdl_t *qpnh, uint_t sleepflag);
3799517SBill.Taylor@Sun.COM int hermon_qp_query(hermon_state_t *state, hermon_qphdl_t qphdl,
3809517SBill.Taylor@Sun.COM     ibt_qp_query_attr_t *attr_p);
3819517SBill.Taylor@Sun.COM hermon_qphdl_t hermon_qphdl_from_qpnum(hermon_state_t *state, uint_t qpnum);
3829517SBill.Taylor@Sun.COM void hermon_qp_release_qpn(hermon_state_t *state, hermon_qpn_entry_t *entry,
3839517SBill.Taylor@Sun.COM     int flags);
3849517SBill.Taylor@Sun.COM void hermon_qpn_avl_init(hermon_state_t *state);
3859517SBill.Taylor@Sun.COM void hermon_qpn_avl_fini(hermon_state_t *state);
3869517SBill.Taylor@Sun.COM 
3879517SBill.Taylor@Sun.COM /* Defined in hermon_qpmod.c */
3889517SBill.Taylor@Sun.COM int hermon_qp_modify(hermon_state_t *state, hermon_qphdl_t qp,
3899517SBill.Taylor@Sun.COM     ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p,
3909517SBill.Taylor@Sun.COM     ibt_queue_sizes_t *actual_sz);
3919517SBill.Taylor@Sun.COM int hermon_qp_to_reset(hermon_state_t *state, hermon_qphdl_t qp);
3929517SBill.Taylor@Sun.COM 
3939517SBill.Taylor@Sun.COM #ifdef __cplusplus
3949517SBill.Taylor@Sun.COM }
3959517SBill.Taylor@Sun.COM #endif
3969517SBill.Taylor@Sun.COM 
3979517SBill.Taylor@Sun.COM #endif	/* _SYS_IB_ADAPTERS_HERMON_QP_H */
398