xref: /onnv-gate/usr/src/uts/common/sys/ib/adapters/hermon/hermon_srq.h (revision 9517:b4839b0aa7a4)
1*9517SBill.Taylor@Sun.COM /*
2*9517SBill.Taylor@Sun.COM  * CDDL HEADER START
3*9517SBill.Taylor@Sun.COM  *
4*9517SBill.Taylor@Sun.COM  * The contents of this file are subject to the terms of the
5*9517SBill.Taylor@Sun.COM  * Common Development and Distribution License (the "License").
6*9517SBill.Taylor@Sun.COM  * You may not use this file except in compliance with the License.
7*9517SBill.Taylor@Sun.COM  *
8*9517SBill.Taylor@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*9517SBill.Taylor@Sun.COM  * or http://www.opensolaris.org/os/licensing.
10*9517SBill.Taylor@Sun.COM  * See the License for the specific language governing permissions
11*9517SBill.Taylor@Sun.COM  * and limitations under the License.
12*9517SBill.Taylor@Sun.COM  *
13*9517SBill.Taylor@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
14*9517SBill.Taylor@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*9517SBill.Taylor@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
16*9517SBill.Taylor@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
17*9517SBill.Taylor@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
18*9517SBill.Taylor@Sun.COM  *
19*9517SBill.Taylor@Sun.COM  * CDDL HEADER END
20*9517SBill.Taylor@Sun.COM  */
21*9517SBill.Taylor@Sun.COM 
22*9517SBill.Taylor@Sun.COM /*
23*9517SBill.Taylor@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24*9517SBill.Taylor@Sun.COM  * Use is subject to license terms.
25*9517SBill.Taylor@Sun.COM  */
26*9517SBill.Taylor@Sun.COM 
27*9517SBill.Taylor@Sun.COM #ifndef	_SYS_IB_ADAPTERS_HERMON_SRQ_H
28*9517SBill.Taylor@Sun.COM #define	_SYS_IB_ADAPTERS_HERMON_SRQ_H
29*9517SBill.Taylor@Sun.COM 
30*9517SBill.Taylor@Sun.COM /*
31*9517SBill.Taylor@Sun.COM  * hermon_srq.h
32*9517SBill.Taylor@Sun.COM  *    Contains all of the prototypes, #defines, and structures necessary
33*9517SBill.Taylor@Sun.COM  *    for the Shared Receive Queue Processing routines.
34*9517SBill.Taylor@Sun.COM  *
35*9517SBill.Taylor@Sun.COM  *    (including those routines directly exposed through the IBTF CI
36*9517SBill.Taylor@Sun.COM  *    interface).
37*9517SBill.Taylor@Sun.COM  */
38*9517SBill.Taylor@Sun.COM 
39*9517SBill.Taylor@Sun.COM #include <sys/types.h>
40*9517SBill.Taylor@Sun.COM #include <sys/conf.h>
41*9517SBill.Taylor@Sun.COM #include <sys/ddi.h>
42*9517SBill.Taylor@Sun.COM #include <sys/sunddi.h>
43*9517SBill.Taylor@Sun.COM 
44*9517SBill.Taylor@Sun.COM #ifdef __cplusplus
45*9517SBill.Taylor@Sun.COM extern "C" {
46*9517SBill.Taylor@Sun.COM #endif
47*9517SBill.Taylor@Sun.COM 
48*9517SBill.Taylor@Sun.COM /*
49*9517SBill.Taylor@Sun.COM  * The following defines the default number of Shared Receive Queues (SRQ).
50*9517SBill.Taylor@Sun.COM  * This value is controllable via the "hermon_log_num_srq" configuration
51*9517SBill.Taylor@Sun.COM  * variable.
52*9517SBill.Taylor@Sun.COM  * We also have a define for the minimum size of a SRQ.  SRQs allocated with
53*9517SBill.Taylor@Sun.COM  * size 0, 1, 2, or 3 will always get back a SRQ of size 4.
54*9517SBill.Taylor@Sun.COM  */
55*9517SBill.Taylor@Sun.COM #define	HERMON_NUM_SRQ_SHIFT		0x10
56*9517SBill.Taylor@Sun.COM #define	HERMON_SRQ_MIN_SIZE		0x4
57*9517SBill.Taylor@Sun.COM 
58*9517SBill.Taylor@Sun.COM /*
59*9517SBill.Taylor@Sun.COM  * The hermon firmware currently limits an SRQ to maximum of 31 SGL
60*9517SBill.Taylor@Sun.COM  * per WQE (WQE size is 512 bytes or less).  With a WQE size of 256
61*9517SBill.Taylor@Sun.COM  * (SGL 15 or less) no problems are seen.  We set SRQ_MAX_SGL size here, for
62*9517SBill.Taylor@Sun.COM  * use in the config profile to be 0xF.
63*9517SBill.Taylor@Sun.COM  */
64*9517SBill.Taylor@Sun.COM #define	HERMON_SRQ_MAX_SGL		0xF
65*9517SBill.Taylor@Sun.COM 
66*9517SBill.Taylor@Sun.COM /*
67*9517SBill.Taylor@Sun.COM  * SRQ States as defined by Hermon.
68*9517SBill.Taylor@Sun.COM  */
69*9517SBill.Taylor@Sun.COM #define	HERMON_SRQ_STATE_SW_OWNER	0xF
70*9517SBill.Taylor@Sun.COM #define	HERMON_SRQ_STATE_HW_OWNER	0x0
71*9517SBill.Taylor@Sun.COM #define	HERMON_SRQ_STATE_ERROR		0x1
72*9517SBill.Taylor@Sun.COM 
73*9517SBill.Taylor@Sun.COM /*
74*9517SBill.Taylor@Sun.COM  * The hermon_sw_srq_s structure is also referred to using the "hermon_srqhdl_t"
75*9517SBill.Taylor@Sun.COM  * typedef (see hermon_typedef.h).  It encodes all the information necessary
76*9517SBill.Taylor@Sun.COM  * to track the various resources needed to allocate, initialize, query, modify,
77*9517SBill.Taylor@Sun.COM  * post, and (later) free a shared receive queue (SRQ).
78*9517SBill.Taylor@Sun.COM  */
79*9517SBill.Taylor@Sun.COM struct hermon_sw_srq_s {
80*9517SBill.Taylor@Sun.COM 	kmutex_t		srq_lock;
81*9517SBill.Taylor@Sun.COM 	uint_t			srq_state;
82*9517SBill.Taylor@Sun.COM 	uint_t			srq_srqnum;
83*9517SBill.Taylor@Sun.COM 	hermon_pdhdl_t		srq_pdhdl;
84*9517SBill.Taylor@Sun.COM 	hermon_mrhdl_t		srq_mrhdl;
85*9517SBill.Taylor@Sun.COM 	uint_t			srq_is_umap;
86*9517SBill.Taylor@Sun.COM 	uint32_t		srq_uarpg;
87*9517SBill.Taylor@Sun.COM 	devmap_cookie_t		srq_umap_dhp;
88*9517SBill.Taylor@Sun.COM 
89*9517SBill.Taylor@Sun.COM 	ibt_srq_sizes_t		srq_real_sizes;
90*9517SBill.Taylor@Sun.COM 	hermon_rsrc_t		*srq_srqcrsrcp;
91*9517SBill.Taylor@Sun.COM 	hermon_rsrc_t		*srq_rsrcp;
92*9517SBill.Taylor@Sun.COM 	void			*srq_hdlrarg;
93*9517SBill.Taylor@Sun.COM 	uint_t			srq_refcnt;
94*9517SBill.Taylor@Sun.COM 
95*9517SBill.Taylor@Sun.COM 	/* Work Queue */
96*9517SBill.Taylor@Sun.COM 	hermon_workq_hdr_t	*srq_wq_wqhdr;
97*9517SBill.Taylor@Sun.COM 	uint32_t		*srq_wq_buf;
98*9517SBill.Taylor@Sun.COM 	uint32_t		srq_wq_bufsz;
99*9517SBill.Taylor@Sun.COM 	uint32_t		srq_wq_log_wqesz;
100*9517SBill.Taylor@Sun.COM 	uint32_t		srq_wq_sgl;
101*9517SBill.Taylor@Sun.COM 	uint32_t		srq_wq_wqecntr;
102*9517SBill.Taylor@Sun.COM 
103*9517SBill.Taylor@Sun.COM 	/* DoorBell Record information */
104*9517SBill.Taylor@Sun.COM 	ddi_acc_handle_t	srq_wq_dbr_acchdl;
105*9517SBill.Taylor@Sun.COM 	hermon_dbr_t		*srq_wq_vdbr;
106*9517SBill.Taylor@Sun.COM 	uint64_t		srq_wq_pdbr;
107*9517SBill.Taylor@Sun.COM 	uint64_t		srq_rdbr_mapoffset;	/* user mode access */
108*9517SBill.Taylor@Sun.COM 
109*9517SBill.Taylor@Sun.COM 	/* For zero-based */
110*9517SBill.Taylor@Sun.COM 	uint64_t		srq_desc_off;
111*9517SBill.Taylor@Sun.COM 
112*9517SBill.Taylor@Sun.COM 	/* Queue Memory for SRQ */
113*9517SBill.Taylor@Sun.COM 	struct hermon_qalloc_info_s	srq_wqinfo;
114*9517SBill.Taylor@Sun.COM };
115*9517SBill.Taylor@Sun.COM _NOTE(READ_ONLY_DATA(hermon_sw_srq_s::srq_pdhdl
116*9517SBill.Taylor@Sun.COM     hermon_sw_srq_s::srq_mrhdl
117*9517SBill.Taylor@Sun.COM     hermon_sw_srq_s::srq_srqnum
118*9517SBill.Taylor@Sun.COM     hermon_sw_srq_s::srq_wq_sgl
119*9517SBill.Taylor@Sun.COM     hermon_sw_srq_s::srq_srqcrsrcp
120*9517SBill.Taylor@Sun.COM     hermon_sw_srq_s::srq_rsrcp
121*9517SBill.Taylor@Sun.COM     hermon_sw_srq_s::srq_hdlrarg
122*9517SBill.Taylor@Sun.COM     hermon_sw_srq_s::srq_is_umap
123*9517SBill.Taylor@Sun.COM     hermon_sw_srq_s::srq_uarpg))
124*9517SBill.Taylor@Sun.COM _NOTE(DATA_READABLE_WITHOUT_LOCK(hermon_sw_srq_s::srq_wq_bufsz
125*9517SBill.Taylor@Sun.COM     hermon_sw_srq_s::srq_wqinfo
126*9517SBill.Taylor@Sun.COM     hermon_sw_srq_s::srq_wq_buf
127*9517SBill.Taylor@Sun.COM     hermon_sw_srq_s::srq_wq_wqhdr
128*9517SBill.Taylor@Sun.COM     hermon_sw_srq_s::srq_desc_off))
129*9517SBill.Taylor@Sun.COM _NOTE(MUTEX_PROTECTS_DATA(hermon_sw_srq_s::srq_lock,
130*9517SBill.Taylor@Sun.COM     hermon_sw_srq_s::srq_real_sizes
131*9517SBill.Taylor@Sun.COM     hermon_sw_srq_s::srq_umap_dhp))
132*9517SBill.Taylor@Sun.COM 
133*9517SBill.Taylor@Sun.COM /*
134*9517SBill.Taylor@Sun.COM  * The hermon_srq_info_t structure is used internally by the Hermon driver to
135*9517SBill.Taylor@Sun.COM  * pass information to and from the hermon_srq_alloc() routine.  It contains
136*9517SBill.Taylor@Sun.COM  * placeholders for all of the potential inputs and outputs that this routine
137*9517SBill.Taylor@Sun.COM  * can take.
138*9517SBill.Taylor@Sun.COM  */
139*9517SBill.Taylor@Sun.COM typedef struct hermon_srq_info_s {
140*9517SBill.Taylor@Sun.COM 	hermon_pdhdl_t		srqi_pd;
141*9517SBill.Taylor@Sun.COM 	ibt_srq_hdl_t		srqi_ibt_srqhdl;
142*9517SBill.Taylor@Sun.COM 	ibt_srq_sizes_t		*srqi_sizes;
143*9517SBill.Taylor@Sun.COM 	ibt_srq_sizes_t		*srqi_real_sizes;
144*9517SBill.Taylor@Sun.COM 	hermon_srqhdl_t		*srqi_srqhdl;
145*9517SBill.Taylor@Sun.COM 	uint_t			srqi_flags;
146*9517SBill.Taylor@Sun.COM } hermon_srq_info_t;
147*9517SBill.Taylor@Sun.COM 
148*9517SBill.Taylor@Sun.COM /*
149*9517SBill.Taylor@Sun.COM  * The hermon_srq_options_t structure is used in the Hermon SRQ allocation
150*9517SBill.Taylor@Sun.COM  * routines to provide additional option functionality.  When a NULL pointer
151*9517SBill.Taylor@Sun.COM  * is passed in place of a pointer to this struct, it is a way of specifying
152*9517SBill.Taylor@Sun.COM  * the "default" behavior.  Using this structure, however, is a way of
153*9517SBill.Taylor@Sun.COM  * controlling any extended behavior.
154*9517SBill.Taylor@Sun.COM  */
155*9517SBill.Taylor@Sun.COM typedef struct hermon_srq_options_s {
156*9517SBill.Taylor@Sun.COM 	uint_t			srqo_wq_loc;
157*9517SBill.Taylor@Sun.COM } hermon_srq_options_t;
158*9517SBill.Taylor@Sun.COM 
159*9517SBill.Taylor@Sun.COM /*
160*9517SBill.Taylor@Sun.COM  * old call
161*9517SBill.Taylor@Sun.COM  * int hermon_srq_alloc(hermon_state_t *state, hermon_srq_info_t *srqinfo,
162*9517SBill.Taylor@Sun.COM  *  uint_t sleepflag, hermon_srq_options_t *op);
163*9517SBill.Taylor@Sun.COM  */
164*9517SBill.Taylor@Sun.COM 
165*9517SBill.Taylor@Sun.COM int hermon_srq_alloc(hermon_state_t *state, hermon_srq_info_t *srqinfo,
166*9517SBill.Taylor@Sun.COM     uint_t sleepflag);
167*9517SBill.Taylor@Sun.COM int hermon_srq_free(hermon_state_t *state, hermon_srqhdl_t *srqhdl,
168*9517SBill.Taylor@Sun.COM     uint_t sleepflag);
169*9517SBill.Taylor@Sun.COM int hermon_srq_modify(hermon_state_t *state, hermon_srqhdl_t srq,
170*9517SBill.Taylor@Sun.COM     uint_t size, uint_t *real_size, uint_t sleepflag);
171*9517SBill.Taylor@Sun.COM int hermon_srq_post(hermon_state_t *state, hermon_srqhdl_t srq,
172*9517SBill.Taylor@Sun.COM     ibt_recv_wr_t *wr_p, uint_t num_wr, uint_t *num_posted);
173*9517SBill.Taylor@Sun.COM void hermon_srq_refcnt_inc(hermon_srqhdl_t srq);
174*9517SBill.Taylor@Sun.COM void hermon_srq_refcnt_dec(hermon_srqhdl_t srq);
175*9517SBill.Taylor@Sun.COM hermon_srqhdl_t hermon_srqhdl_from_srqnum(hermon_state_t *state, uint_t srqnum);
176*9517SBill.Taylor@Sun.COM 
177*9517SBill.Taylor@Sun.COM #ifdef __cplusplus
178*9517SBill.Taylor@Sun.COM }
179*9517SBill.Taylor@Sun.COM #endif
180*9517SBill.Taylor@Sun.COM 
181*9517SBill.Taylor@Sun.COM #endif	/* _SYS_IB_ADAPTERS_HERMON_SRQ_H */
182