1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate /*
28*7c478bd9Sstevel@tonic-gate  * Should we maintain base lid for each port in ibmf_ci?
29*7c478bd9Sstevel@tonic-gate  */
30*7c478bd9Sstevel@tonic-gate 
31*7c478bd9Sstevel@tonic-gate /*
32*7c478bd9Sstevel@tonic-gate  * This file implements the UD destination resource management in IBMF.
33*7c478bd9Sstevel@tonic-gate  */
34*7c478bd9Sstevel@tonic-gate 
35*7c478bd9Sstevel@tonic-gate #include <sys/ib/mgt/ibmf/ibmf_impl.h>
36*7c478bd9Sstevel@tonic-gate 
37*7c478bd9Sstevel@tonic-gate extern int ibmf_trace_level;
38*7c478bd9Sstevel@tonic-gate extern ibmf_state_t *ibmf_statep;
39*7c478bd9Sstevel@tonic-gate static void ibmf_i_populate_ud_dest_list(ibmf_ci_t *cip, int kmflag);
40*7c478bd9Sstevel@tonic-gate 
41*7c478bd9Sstevel@tonic-gate /*
42*7c478bd9Sstevel@tonic-gate  * ibmf_i_init_ud_dest():
43*7c478bd9Sstevel@tonic-gate  * Initialize a cache of UD destination structure used to send UD traffic.
44*7c478bd9Sstevel@tonic-gate  * Also create a list of pre-allocated UD destination structures to
45*7c478bd9Sstevel@tonic-gate  * satisfy requests for a UD destination structure and its associated
46*7c478bd9Sstevel@tonic-gate  * address handle, from a thread in interrupt context. Threads in interrupt
47*7c478bd9Sstevel@tonic-gate  * context are not allowed to allocated their own address handles.
48*7c478bd9Sstevel@tonic-gate  */
49*7c478bd9Sstevel@tonic-gate void
ibmf_i_init_ud_dest(ibmf_ci_t * cip)50*7c478bd9Sstevel@tonic-gate ibmf_i_init_ud_dest(ibmf_ci_t *cip)
51*7c478bd9Sstevel@tonic-gate {
52*7c478bd9Sstevel@tonic-gate 	IBMF_TRACE_1(IBMF_TNF_DEBUG, DPRINT_L4, ibmf_i_init_ud_dest_start,
53*7c478bd9Sstevel@tonic-gate 	    IBMF_TNF_TRACE, "", "ibmf_i_init_ud_dest() enter, cip = %p\n",
54*7c478bd9Sstevel@tonic-gate 	    tnf_opaque, cip, cip);
55*7c478bd9Sstevel@tonic-gate 
56*7c478bd9Sstevel@tonic-gate 	/* initialize the UD dest list mutex */
57*7c478bd9Sstevel@tonic-gate 	mutex_init(&cip->ci_ud_dest_list_mutex, NULL, MUTEX_DRIVER, NULL);
58*7c478bd9Sstevel@tonic-gate 
59*7c478bd9Sstevel@tonic-gate 	/* populate the UD dest list if possible */
60*7c478bd9Sstevel@tonic-gate 	ibmf_i_pop_ud_dest_thread(cip);
61*7c478bd9Sstevel@tonic-gate 
62*7c478bd9Sstevel@tonic-gate 	IBMF_TRACE_0(IBMF_TNF_DEBUG, DPRINT_L4, ibmf_i_init_ud_dest_end,
63*7c478bd9Sstevel@tonic-gate 	    IBMF_TNF_TRACE, "", "ibmf_i_init_ud_dest() exit\n");
64*7c478bd9Sstevel@tonic-gate }
65*7c478bd9Sstevel@tonic-gate 
66*7c478bd9Sstevel@tonic-gate /*
67*7c478bd9Sstevel@tonic-gate  * ibmf_i_fini_ud_dest():
68*7c478bd9Sstevel@tonic-gate  * Free up the UD destination cache and the linked list.
69*7c478bd9Sstevel@tonic-gate  */
70*7c478bd9Sstevel@tonic-gate void
ibmf_i_fini_ud_dest(ibmf_ci_t * cip)71*7c478bd9Sstevel@tonic-gate ibmf_i_fini_ud_dest(ibmf_ci_t *cip)
72*7c478bd9Sstevel@tonic-gate {
73*7c478bd9Sstevel@tonic-gate 	IBMF_TRACE_1(IBMF_TNF_DEBUG, DPRINT_L4, ibmf_i_fini_ud_dest_start,
74*7c478bd9Sstevel@tonic-gate 	    IBMF_TNF_TRACE, "", "ibmf_i_fini_ud_dest() enter, cip = %p\n",
75*7c478bd9Sstevel@tonic-gate 	    tnf_opaque, cip, cip);
76*7c478bd9Sstevel@tonic-gate 
77*7c478bd9Sstevel@tonic-gate 	/* clean up the UD dest list */
78*7c478bd9Sstevel@tonic-gate 	ibmf_i_clean_ud_dest_list(cip, B_TRUE);
79*7c478bd9Sstevel@tonic-gate 
80*7c478bd9Sstevel@tonic-gate 	IBMF_TRACE_0(IBMF_TNF_DEBUG, DPRINT_L4, ibmf_i_fini_ud_dest_end,
81*7c478bd9Sstevel@tonic-gate 	    IBMF_TNF_TRACE, "", "ibmf_i_fini_ud_dest() exit\n");
82*7c478bd9Sstevel@tonic-gate }
83*7c478bd9Sstevel@tonic-gate 
84*7c478bd9Sstevel@tonic-gate /*
85*7c478bd9Sstevel@tonic-gate  * ibmf_i_get_ud_dest():
86*7c478bd9Sstevel@tonic-gate  *	Get a UD destination structure from the list
87*7c478bd9Sstevel@tonic-gate  */
88*7c478bd9Sstevel@tonic-gate ibmf_ud_dest_t *
ibmf_i_get_ud_dest(ibmf_ci_t * cip)89*7c478bd9Sstevel@tonic-gate ibmf_i_get_ud_dest(ibmf_ci_t *cip)
90*7c478bd9Sstevel@tonic-gate {
91*7c478bd9Sstevel@tonic-gate 	ibmf_ud_dest_t		*ibmf_ud_dest;
92*7c478bd9Sstevel@tonic-gate 
93*7c478bd9Sstevel@tonic-gate 	IBMF_TRACE_1(IBMF_TNF_DEBUG, DPRINT_L4, ibmf_i_get_ud_dest_start,
94*7c478bd9Sstevel@tonic-gate 	    IBMF_TNF_TRACE, "", "ibmf_i_get_ud_dest() enter, cip = %p\n",
95*7c478bd9Sstevel@tonic-gate 	    tnf_opaque, cip, cip);
96*7c478bd9Sstevel@tonic-gate 
97*7c478bd9Sstevel@tonic-gate 	mutex_enter(&cip->ci_ud_dest_list_mutex);
98*7c478bd9Sstevel@tonic-gate 	ibmf_ud_dest = cip->ci_ud_dest_list_head;
99*7c478bd9Sstevel@tonic-gate 	if (ibmf_ud_dest != NULL) {
100*7c478bd9Sstevel@tonic-gate 		cip->ci_ud_dest_list_head = ibmf_ud_dest->ud_next;
101*7c478bd9Sstevel@tonic-gate 		cip->ci_ud_dest_list_count--;
102*7c478bd9Sstevel@tonic-gate 	}
103*7c478bd9Sstevel@tonic-gate 	mutex_exit(&cip->ci_ud_dest_list_mutex);
104*7c478bd9Sstevel@tonic-gate 
105*7c478bd9Sstevel@tonic-gate 	IBMF_TRACE_0(IBMF_TNF_DEBUG, DPRINT_L4, ibmf_i_get_ud_dest_end,
106*7c478bd9Sstevel@tonic-gate 	    IBMF_TNF_TRACE, "", "ibmf_i_get_ud_dest() exit\n");
107*7c478bd9Sstevel@tonic-gate 	return (ibmf_ud_dest);
108*7c478bd9Sstevel@tonic-gate }
109*7c478bd9Sstevel@tonic-gate 
110*7c478bd9Sstevel@tonic-gate /*
111*7c478bd9Sstevel@tonic-gate  * ibmf_i_put_ud_dest():
112*7c478bd9Sstevel@tonic-gate  *	Add a UD destination structure to the list
113*7c478bd9Sstevel@tonic-gate  */
114*7c478bd9Sstevel@tonic-gate void
ibmf_i_put_ud_dest(ibmf_ci_t * cip,ibmf_ud_dest_t * ud_dest)115*7c478bd9Sstevel@tonic-gate ibmf_i_put_ud_dest(ibmf_ci_t *cip, ibmf_ud_dest_t *ud_dest)
116*7c478bd9Sstevel@tonic-gate {
117*7c478bd9Sstevel@tonic-gate 	IBMF_TRACE_2(IBMF_TNF_DEBUG, DPRINT_L4, ibmf_i_put_ud_dest_start,
118*7c478bd9Sstevel@tonic-gate 	    IBMF_TNF_TRACE, "", "ibmf_i_put_ud_dest() enter, cip = %p, "
119*7c478bd9Sstevel@tonic-gate 	    "ud_dest = %p\n", tnf_opaque, cip, cip,
120*7c478bd9Sstevel@tonic-gate 	    tnf_opaque, ud_dest, ud_dest);
121*7c478bd9Sstevel@tonic-gate 
122*7c478bd9Sstevel@tonic-gate 	mutex_enter(&cip->ci_ud_dest_list_mutex);
123*7c478bd9Sstevel@tonic-gate 	cip->ci_ud_dest_list_count++;
124*7c478bd9Sstevel@tonic-gate 	ud_dest->ud_next = cip->ci_ud_dest_list_head;
125*7c478bd9Sstevel@tonic-gate 	cip->ci_ud_dest_list_head = ud_dest;
126*7c478bd9Sstevel@tonic-gate 	mutex_exit(&cip->ci_ud_dest_list_mutex);
127*7c478bd9Sstevel@tonic-gate 
128*7c478bd9Sstevel@tonic-gate 	IBMF_TRACE_1(IBMF_TNF_DEBUG, DPRINT_L4, ibmf_i_put_ud_dest_end,
129*7c478bd9Sstevel@tonic-gate 	    IBMF_TNF_TRACE, "", "ibmf_i_put_ud_dest() exit, cip = %p\n",
130*7c478bd9Sstevel@tonic-gate 	    tnf_opaque, cip, cip);
131*7c478bd9Sstevel@tonic-gate }
132*7c478bd9Sstevel@tonic-gate 
133*7c478bd9Sstevel@tonic-gate /*
134*7c478bd9Sstevel@tonic-gate  * ibmf_i_populate_ud_dest_list():
135*7c478bd9Sstevel@tonic-gate  * Maintain a list of IBMF UD destination structures to
136*7c478bd9Sstevel@tonic-gate  * satisfy requests for a UD destination structure and its associated
137*7c478bd9Sstevel@tonic-gate  * address handle, from a thread in interrupt context. Threads in interrupt
138*7c478bd9Sstevel@tonic-gate  * context are not allowed to allocate their own address handles.
139*7c478bd9Sstevel@tonic-gate  * Add to this list only if the number of entries in the list falls below
140*7c478bd9Sstevel@tonic-gate  * IBMF_UD_DEST_LO_WATER_MARK. When adding to the list, add entries upto
141*7c478bd9Sstevel@tonic-gate  * IBMF_UD_DEST_HI_WATER_MARK.
142*7c478bd9Sstevel@tonic-gate  */
143*7c478bd9Sstevel@tonic-gate static void
ibmf_i_populate_ud_dest_list(ibmf_ci_t * cip,int kmflag)144*7c478bd9Sstevel@tonic-gate ibmf_i_populate_ud_dest_list(ibmf_ci_t *cip, int kmflag)
145*7c478bd9Sstevel@tonic-gate {
146*7c478bd9Sstevel@tonic-gate 	ibmf_ud_dest_t		*ibmf_ud_dest;
147*7c478bd9Sstevel@tonic-gate 	uint32_t		count;
148*7c478bd9Sstevel@tonic-gate 	ibt_status_t		status;
149*7c478bd9Sstevel@tonic-gate 	ibt_ud_dest_flags_t	ud_dest_flags = IBT_UD_DEST_NO_FLAGS;
150*7c478bd9Sstevel@tonic-gate 
151*7c478bd9Sstevel@tonic-gate 	IBMF_TRACE_2(IBMF_TNF_DEBUG, DPRINT_L4,
152*7c478bd9Sstevel@tonic-gate 	    ibmf_i_populate_ud_dest_list_start, IBMF_TNF_TRACE, "",
153*7c478bd9Sstevel@tonic-gate 	    "ibmf_i_populate_ud_dest_list() enter, cip = %p, kmflag = %d \n",
154*7c478bd9Sstevel@tonic-gate 	    tnf_opaque, cip, cip, tnf_int, kmflag, kmflag);
155*7c478bd9Sstevel@tonic-gate 
156*7c478bd9Sstevel@tonic-gate 	/* do not allow a population operation if non-blocking */
157*7c478bd9Sstevel@tonic-gate 	if (kmflag == KM_NOSLEEP) {
158*7c478bd9Sstevel@tonic-gate 		IBMF_TRACE_1(IBMF_TNF_DEBUG, DPRINT_L3,
159*7c478bd9Sstevel@tonic-gate 		    ibmf_i_populate_ud_dest, IBMF_TNF_TRACE, "",
160*7c478bd9Sstevel@tonic-gate 		    "ibmf_i_populate_ud_dest_list(): %s\n", tnf_string, msg,
161*7c478bd9Sstevel@tonic-gate 		    "Skipping, called with non-blocking flag\n");
162*7c478bd9Sstevel@tonic-gate 		IBMF_TRACE_0(IBMF_TNF_DEBUG, DPRINT_L4,
163*7c478bd9Sstevel@tonic-gate 		    ibmf_i_populate_ud_dest_end, IBMF_TNF_TRACE, "",
164*7c478bd9Sstevel@tonic-gate 		    "ibmf_i_populate_ud_dest_list() exit\n");
165*7c478bd9Sstevel@tonic-gate 		/*
166*7c478bd9Sstevel@tonic-gate 		 * Don't return a failure code here.
167*7c478bd9Sstevel@tonic-gate 		 * If ibmf_i_ud_dest_alloc() returns NULL, the
168*7c478bd9Sstevel@tonic-gate 		 * the resource allocation will fail
169*7c478bd9Sstevel@tonic-gate 		 */
170*7c478bd9Sstevel@tonic-gate 		return;
171*7c478bd9Sstevel@tonic-gate 	}
172*7c478bd9Sstevel@tonic-gate 
173*7c478bd9Sstevel@tonic-gate 	mutex_enter(&cip->ci_ud_dest_list_mutex);
174*7c478bd9Sstevel@tonic-gate 	count = cip->ci_ud_dest_list_count;
175*7c478bd9Sstevel@tonic-gate 
176*7c478bd9Sstevel@tonic-gate 	/* nothing to do if count is above the low water mark */
177*7c478bd9Sstevel@tonic-gate 	if (count > IBMF_UD_DEST_LO_WATER_MARK) {
178*7c478bd9Sstevel@tonic-gate 		mutex_exit(&cip->ci_ud_dest_list_mutex);
179*7c478bd9Sstevel@tonic-gate 		IBMF_TRACE_1(IBMF_TNF_DEBUG, DPRINT_L3,
180*7c478bd9Sstevel@tonic-gate 		    ibmf_i_populate_ud_dest, IBMF_TNF_TRACE, "",
181*7c478bd9Sstevel@tonic-gate 		    "ibmf_i_populate_ud_dest_list(): %s\n", tnf_string, msg,
182*7c478bd9Sstevel@tonic-gate 		    "Count not below low water mark\n");
183*7c478bd9Sstevel@tonic-gate 		IBMF_TRACE_0(IBMF_TNF_DEBUG, DPRINT_L4,
184*7c478bd9Sstevel@tonic-gate 		    ibmf_i_populate_ud_dest_end, IBMF_TNF_TRACE, "",
185*7c478bd9Sstevel@tonic-gate 		    "ibmf_i_populate_ud_dest_list() exit\n");
186*7c478bd9Sstevel@tonic-gate 		return;
187*7c478bd9Sstevel@tonic-gate 	}
188*7c478bd9Sstevel@tonic-gate 
189*7c478bd9Sstevel@tonic-gate 	/* populate the pool upto the high water mark */
190*7c478bd9Sstevel@tonic-gate 	while (count < IBMF_UD_DEST_HI_WATER_MARK) {
191*7c478bd9Sstevel@tonic-gate 		ibt_adds_vect_t adds_vect;
192*7c478bd9Sstevel@tonic-gate 
193*7c478bd9Sstevel@tonic-gate 		ibmf_ud_dest = kmem_zalloc(sizeof (ibmf_ud_dest_t), kmflag);
194*7c478bd9Sstevel@tonic-gate 		_NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*ibmf_ud_dest))
195*7c478bd9Sstevel@tonic-gate 
196*7c478bd9Sstevel@tonic-gate 		/* Call IBTF to allocate an address handle */
197*7c478bd9Sstevel@tonic-gate 		bzero(&adds_vect, sizeof (adds_vect));
198*7c478bd9Sstevel@tonic-gate 		adds_vect.av_port_num = 1;
199*7c478bd9Sstevel@tonic-gate 		adds_vect.av_srate = IBT_SRATE_1X;	/* assume the minimum */
200*7c478bd9Sstevel@tonic-gate 		mutex_exit(&cip->ci_ud_dest_list_mutex);
201*7c478bd9Sstevel@tonic-gate 
202*7c478bd9Sstevel@tonic-gate 		status = ibt_alloc_ah(cip->ci_ci_handle, ud_dest_flags,
203*7c478bd9Sstevel@tonic-gate 		    cip->ci_pd, &adds_vect, &ibmf_ud_dest->ud_dest.ud_ah);
204*7c478bd9Sstevel@tonic-gate 		if (status != IBT_SUCCESS) {
205*7c478bd9Sstevel@tonic-gate 			kmem_free(ibmf_ud_dest, sizeof (ibmf_ud_dest_t));
206*7c478bd9Sstevel@tonic-gate 			IBMF_TRACE_2(IBMF_TNF_NODEBUG, DPRINT_L1,
207*7c478bd9Sstevel@tonic-gate 			    ibmf_i_populate_ud_dest_err, IBMF_TNF_ERROR, "",
208*7c478bd9Sstevel@tonic-gate 			    "ibmf_i_populate_ud_dest_list(): %s, status = %d\n",
209*7c478bd9Sstevel@tonic-gate 			    tnf_string, msg, "ibt alloc ah failed",
210*7c478bd9Sstevel@tonic-gate 			    tnf_uint, ibt_status, status);
211*7c478bd9Sstevel@tonic-gate 			IBMF_TRACE_0(IBMF_TNF_DEBUG, DPRINT_L4,
212*7c478bd9Sstevel@tonic-gate 			    ibmf_i_populate_ud_dest_end, IBMF_TNF_TRACE, "",
213*7c478bd9Sstevel@tonic-gate 			    "ibmf_i_populate_ud_dest_list() exit\n");
214*7c478bd9Sstevel@tonic-gate 			return;
215*7c478bd9Sstevel@tonic-gate 		}
216*7c478bd9Sstevel@tonic-gate 
217*7c478bd9Sstevel@tonic-gate 		/* Add the ud_dest to the list */
218*7c478bd9Sstevel@tonic-gate 		mutex_enter(&cip->ci_ud_dest_list_mutex);
219*7c478bd9Sstevel@tonic-gate 
220*7c478bd9Sstevel@tonic-gate 		if (cip->ci_ud_dest_list_head != NULL)
221*7c478bd9Sstevel@tonic-gate 			ibmf_ud_dest->ud_next = cip->ci_ud_dest_list_head;
222*7c478bd9Sstevel@tonic-gate 		else
223*7c478bd9Sstevel@tonic-gate 			ibmf_ud_dest->ud_next = NULL;
224*7c478bd9Sstevel@tonic-gate 
225*7c478bd9Sstevel@tonic-gate 		cip->ci_ud_dest_list_head = ibmf_ud_dest;
226*7c478bd9Sstevel@tonic-gate 		cip->ci_ud_dest_list_count++;
227*7c478bd9Sstevel@tonic-gate 
228*7c478bd9Sstevel@tonic-gate 		/*
229*7c478bd9Sstevel@tonic-gate 		 * Get the latest count since other threads may have
230*7c478bd9Sstevel@tonic-gate 		 * added to the list as well.
231*7c478bd9Sstevel@tonic-gate 		 */
232*7c478bd9Sstevel@tonic-gate 		count = cip->ci_ud_dest_list_count;
233*7c478bd9Sstevel@tonic-gate 
234*7c478bd9Sstevel@tonic-gate 	}
235*7c478bd9Sstevel@tonic-gate 
236*7c478bd9Sstevel@tonic-gate 	mutex_exit(&cip->ci_ud_dest_list_mutex);
237*7c478bd9Sstevel@tonic-gate 
238*7c478bd9Sstevel@tonic-gate 	IBMF_TRACE_0(IBMF_TNF_DEBUG, DPRINT_L4, ibmf_i_populate_ud_dest_end,
239*7c478bd9Sstevel@tonic-gate 	    IBMF_TNF_TRACE, "", "ibmf_i_populate_ud_dest_list() exit\n");
240*7c478bd9Sstevel@tonic-gate }
241*7c478bd9Sstevel@tonic-gate 
242*7c478bd9Sstevel@tonic-gate /*
243*7c478bd9Sstevel@tonic-gate  * ibmf_i_clean_ud_dest_list():
244*7c478bd9Sstevel@tonic-gate  * Free up entries from the linked list of IBMF UD destination structures.
245*7c478bd9Sstevel@tonic-gate  * If the "all" argument is B_TRUE, free up all the entries in the list.
246*7c478bd9Sstevel@tonic-gate  * If the "all" argument is B_FALSE, free up entries to bring the total
247*7c478bd9Sstevel@tonic-gate  * down to IBMF_UD_DEST_HI_WATER_MARK.
248*7c478bd9Sstevel@tonic-gate  */
249*7c478bd9Sstevel@tonic-gate void
ibmf_i_clean_ud_dest_list(ibmf_ci_t * cip,boolean_t all)250*7c478bd9Sstevel@tonic-gate ibmf_i_clean_ud_dest_list(ibmf_ci_t *cip, boolean_t all)
251*7c478bd9Sstevel@tonic-gate {
252*7c478bd9Sstevel@tonic-gate 	ibmf_ud_dest_t		*ibmf_ud_dest;
253*7c478bd9Sstevel@tonic-gate 	ibt_ud_dest_t		*ud_dest;
254*7c478bd9Sstevel@tonic-gate 	uint32_t		count;
255*7c478bd9Sstevel@tonic-gate 	ibt_status_t		status;
256*7c478bd9Sstevel@tonic-gate 
257*7c478bd9Sstevel@tonic-gate 	IBMF_TRACE_2(IBMF_TNF_DEBUG, DPRINT_L4, ibmf_i_clean_ud_dest_start,
258*7c478bd9Sstevel@tonic-gate 	    IBMF_TNF_TRACE, "", "ibmf_i_clean_ud_dest_list() enter, "
259*7c478bd9Sstevel@tonic-gate 	    "cip = %p, all = %d\n", tnf_opaque, cip, cip,
260*7c478bd9Sstevel@tonic-gate 	    tnf_uint, all, all);
261*7c478bd9Sstevel@tonic-gate 
262*7c478bd9Sstevel@tonic-gate 	mutex_enter(&cip->ci_ud_dest_list_mutex);
263*7c478bd9Sstevel@tonic-gate 
264*7c478bd9Sstevel@tonic-gate 	/* Determine the number of UD destination resources to free */
265*7c478bd9Sstevel@tonic-gate 	if (all == B_TRUE) {
266*7c478bd9Sstevel@tonic-gate 		count = cip->ci_ud_dest_list_count;
267*7c478bd9Sstevel@tonic-gate 	} else if (cip->ci_ud_dest_list_count > IBMF_UD_DEST_HI_WATER_MARK) {
268*7c478bd9Sstevel@tonic-gate 		count = cip->ci_ud_dest_list_count -
269*7c478bd9Sstevel@tonic-gate 		    IBMF_UD_DEST_HI_WATER_MARK;
270*7c478bd9Sstevel@tonic-gate 	} else
271*7c478bd9Sstevel@tonic-gate 		count = 0;
272*7c478bd9Sstevel@tonic-gate 
273*7c478bd9Sstevel@tonic-gate 	while (count) {
274*7c478bd9Sstevel@tonic-gate 		ibmf_ud_dest = cip->ci_ud_dest_list_head;
275*7c478bd9Sstevel@tonic-gate 		ASSERT(ibmf_ud_dest != NULL);
276*7c478bd9Sstevel@tonic-gate 		if (ibmf_ud_dest != NULL) {
277*7c478bd9Sstevel@tonic-gate 			/* Remove ibmf_ud_dest from the list */
278*7c478bd9Sstevel@tonic-gate 			cip->ci_ud_dest_list_head = ibmf_ud_dest->ud_next;
279*7c478bd9Sstevel@tonic-gate 			cip->ci_ud_dest_list_count--;
280*7c478bd9Sstevel@tonic-gate 			mutex_exit(&cip->ci_ud_dest_list_mutex);
281*7c478bd9Sstevel@tonic-gate 
282*7c478bd9Sstevel@tonic-gate 			ud_dest = &ibmf_ud_dest->ud_dest;
283*7c478bd9Sstevel@tonic-gate 			status = ibt_free_ah(cip->ci_ci_handle, ud_dest->ud_ah);
284*7c478bd9Sstevel@tonic-gate 			if (status != IBT_SUCCESS) {
285*7c478bd9Sstevel@tonic-gate 				IBMF_TRACE_2(IBMF_TNF_NODEBUG, DPRINT_L1,
286*7c478bd9Sstevel@tonic-gate 				    ibmf_i_clean_ud_dest_err, IBMF_TNF_ERROR,
287*7c478bd9Sstevel@tonic-gate 				    "", "ibmf_i_clean_ud_dest_list(): %s, "
288*7c478bd9Sstevel@tonic-gate 				    "status = %d\n", tnf_string, msg,
289*7c478bd9Sstevel@tonic-gate 				    "ibt_free_ah failed", tnf_uint, ibt_status,
290*7c478bd9Sstevel@tonic-gate 				    status);
291*7c478bd9Sstevel@tonic-gate 				IBMF_TRACE_0(IBMF_TNF_DEBUG, DPRINT_L4,
292*7c478bd9Sstevel@tonic-gate 				    ibmf_i_clean_ud_dest_end, IBMF_TNF_TRACE,
293*7c478bd9Sstevel@tonic-gate 				    "", "ibmf_i_clean_ud_dest_list() exit\n");
294*7c478bd9Sstevel@tonic-gate 				return;
295*7c478bd9Sstevel@tonic-gate 			}
296*7c478bd9Sstevel@tonic-gate 
297*7c478bd9Sstevel@tonic-gate 			/* Free the ud_dest context */
298*7c478bd9Sstevel@tonic-gate 			kmem_free(ibmf_ud_dest, sizeof (ibmf_ud_dest_t));
299*7c478bd9Sstevel@tonic-gate 
300*7c478bd9Sstevel@tonic-gate 			mutex_enter(&cip->ci_ud_dest_list_mutex);
301*7c478bd9Sstevel@tonic-gate 		}
302*7c478bd9Sstevel@tonic-gate 		/* Determine the number of UD destination resources to free */
303*7c478bd9Sstevel@tonic-gate 		if (all == B_TRUE) {
304*7c478bd9Sstevel@tonic-gate 			count = cip->ci_ud_dest_list_count;
305*7c478bd9Sstevel@tonic-gate 		} else if (cip->ci_ud_dest_list_count >
306*7c478bd9Sstevel@tonic-gate 		    IBMF_UD_DEST_HI_WATER_MARK) {
307*7c478bd9Sstevel@tonic-gate 			count = cip->ci_ud_dest_list_count -
308*7c478bd9Sstevel@tonic-gate 			    IBMF_UD_DEST_HI_WATER_MARK;
309*7c478bd9Sstevel@tonic-gate 		} else
310*7c478bd9Sstevel@tonic-gate 			count = 0;
311*7c478bd9Sstevel@tonic-gate 	}
312*7c478bd9Sstevel@tonic-gate 
313*7c478bd9Sstevel@tonic-gate 	mutex_exit(&cip->ci_ud_dest_list_mutex);
314*7c478bd9Sstevel@tonic-gate 
315*7c478bd9Sstevel@tonic-gate 	IBMF_TRACE_0(IBMF_TNF_DEBUG, DPRINT_L4, ibmf_i_clean_ud_dest_end,
316*7c478bd9Sstevel@tonic-gate 	    IBMF_TNF_TRACE, "", "ibmf_i_clean_ud_dest_list() exit\n");
317*7c478bd9Sstevel@tonic-gate }
318*7c478bd9Sstevel@tonic-gate 
319*7c478bd9Sstevel@tonic-gate /*
320*7c478bd9Sstevel@tonic-gate  * ibmf_i_alloc_ud_dest():
321*7c478bd9Sstevel@tonic-gate  *	Allocate and set up a UD destination context
322*7c478bd9Sstevel@tonic-gate  */
323*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/
324*7c478bd9Sstevel@tonic-gate int
ibmf_i_alloc_ud_dest(ibmf_client_t * clientp,ibmf_msg_impl_t * msgimplp,ibt_ud_dest_hdl_t * ud_dest_p,boolean_t block)325*7c478bd9Sstevel@tonic-gate ibmf_i_alloc_ud_dest(ibmf_client_t *clientp, ibmf_msg_impl_t *msgimplp,
326*7c478bd9Sstevel@tonic-gate     ibt_ud_dest_hdl_t *ud_dest_p, boolean_t block)
327*7c478bd9Sstevel@tonic-gate {
328*7c478bd9Sstevel@tonic-gate 	ibmf_ci_t 		*cip;
329*7c478bd9Sstevel@tonic-gate 	ibmf_addr_info_t	*addrp;
330*7c478bd9Sstevel@tonic-gate 	ibt_status_t		status;
331*7c478bd9Sstevel@tonic-gate 	ibt_adds_vect_t		adds_vec;
332*7c478bd9Sstevel@tonic-gate 	ibt_ud_dest_t		*ud_dest;
333*7c478bd9Sstevel@tonic-gate 	int			ibmf_status, ret;
334*7c478bd9Sstevel@tonic-gate 
335*7c478bd9Sstevel@tonic-gate 	IBMF_TRACE_4(IBMF_TNF_DEBUG, DPRINT_L4, ibmf_i_alloc_ud_dest_start,
336*7c478bd9Sstevel@tonic-gate 	    IBMF_TNF_TRACE, "", "ibmf_i_alloc_ud_dest_list() enter, "
337*7c478bd9Sstevel@tonic-gate 	    "clientp = %p, msg = %p, ud_destp = %p, block = %d\n",
338*7c478bd9Sstevel@tonic-gate 	    tnf_opaque, clientp, clientp, tnf_opaque, msg, msgimplp,
339*7c478bd9Sstevel@tonic-gate 	    tnf_opaque, ud_dest_p, ud_dest_p, tnf_uint, block, block);
340*7c478bd9Sstevel@tonic-gate 
341*7c478bd9Sstevel@tonic-gate 	_NOTE(ASSUMING_PROTECTED(*ud_dest_p))
342*7c478bd9Sstevel@tonic-gate 	_NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*ud_dest))
343*7c478bd9Sstevel@tonic-gate 
344*7c478bd9Sstevel@tonic-gate 	addrp = &msgimplp->im_local_addr;
345*7c478bd9Sstevel@tonic-gate 	cip = clientp->ic_myci;
346*7c478bd9Sstevel@tonic-gate 
347*7c478bd9Sstevel@tonic-gate 	/*
348*7c478bd9Sstevel@tonic-gate 	 * Dispatch a taskq to replenish the UD destination handle cache.
349*7c478bd9Sstevel@tonic-gate 	 */
350*7c478bd9Sstevel@tonic-gate 	mutex_enter(&cip->ci_ud_dest_list_mutex);
351*7c478bd9Sstevel@tonic-gate 	if (cip->ci_ud_dest_list_count < IBMF_UD_DEST_LO_WATER_MARK) {
352*7c478bd9Sstevel@tonic-gate 		ret = ibmf_ud_dest_tq_disp(cip);
353*7c478bd9Sstevel@tonic-gate 		if (ret == 0) {
354*7c478bd9Sstevel@tonic-gate 			IBMF_TRACE_1(IBMF_TNF_NODEBUG, DPRINT_L3,
355*7c478bd9Sstevel@tonic-gate 			    ibmf_i_alloc_ud_dest_err, IBMF_TNF_ERROR, "",
356*7c478bd9Sstevel@tonic-gate 			    "ibmf_i_alloc_ud_dest(): %s\n", tnf_string, msg,
357*7c478bd9Sstevel@tonic-gate 			    "taskq dispatch of ud_dest population thread "
358*7c478bd9Sstevel@tonic-gate 			    "failed");
359*7c478bd9Sstevel@tonic-gate 		}
360*7c478bd9Sstevel@tonic-gate 	}
361*7c478bd9Sstevel@tonic-gate 	mutex_exit(&cip->ci_ud_dest_list_mutex);
362*7c478bd9Sstevel@tonic-gate 
363*7c478bd9Sstevel@tonic-gate 	/* initialize the address vector bases on global/local address */
364*7c478bd9Sstevel@tonic-gate 	if (msgimplp->im_msg_flags & IBMF_MSG_FLAGS_GLOBAL_ADDRESS) {
365*7c478bd9Sstevel@tonic-gate 		/* fill in the grh stuff as expected by ibt */
366*7c478bd9Sstevel@tonic-gate 		adds_vec.av_flow = msgimplp->im_global_addr.ig_flow_label;
367*7c478bd9Sstevel@tonic-gate 		adds_vec.av_send_grh = B_TRUE;
368*7c478bd9Sstevel@tonic-gate 		adds_vec.av_tclass = msgimplp->im_global_addr.ig_tclass;
369*7c478bd9Sstevel@tonic-gate 		adds_vec.av_hop = msgimplp->im_global_addr.ig_hop_limit;
370*7c478bd9Sstevel@tonic-gate 		if (msgimplp->im_unsolicited == B_TRUE) {
371*7c478bd9Sstevel@tonic-gate 			adds_vec.av_sgid =
372*7c478bd9Sstevel@tonic-gate 			    msgimplp->im_global_addr.ig_recver_gid;
373*7c478bd9Sstevel@tonic-gate 			adds_vec.av_dgid =
374*7c478bd9Sstevel@tonic-gate 			    msgimplp->im_global_addr.ig_sender_gid;
375*7c478bd9Sstevel@tonic-gate 		} else {
376*7c478bd9Sstevel@tonic-gate 			adds_vec.av_sgid =
377*7c478bd9Sstevel@tonic-gate 			    msgimplp->im_global_addr.ig_sender_gid;
378*7c478bd9Sstevel@tonic-gate 			adds_vec.av_dgid =
379*7c478bd9Sstevel@tonic-gate 			    msgimplp->im_global_addr.ig_recver_gid;
380*7c478bd9Sstevel@tonic-gate 		}
381*7c478bd9Sstevel@tonic-gate 	} else {
382*7c478bd9Sstevel@tonic-gate 		adds_vec.av_send_grh = B_FALSE;
383*7c478bd9Sstevel@tonic-gate 	}
384*7c478bd9Sstevel@tonic-gate 
385*7c478bd9Sstevel@tonic-gate 	/* common address vector initialization */
386*7c478bd9Sstevel@tonic-gate 	adds_vec.av_dlid = addrp->ia_remote_lid;
387*7c478bd9Sstevel@tonic-gate 	if ((clientp->ic_base_lid == 0) && (clientp->ic_qp->iq_qp_num != 0)) {
388*7c478bd9Sstevel@tonic-gate 		/* Get the port's base LID */
389*7c478bd9Sstevel@tonic-gate 		(void) ibt_get_port_state_byguid(
390*7c478bd9Sstevel@tonic-gate 		    clientp->ic_client_info.ci_guid,
391*7c478bd9Sstevel@tonic-gate 		    clientp->ic_client_info.port_num, NULL,
392*7c478bd9Sstevel@tonic-gate 		    &clientp->ic_base_lid);
393*7c478bd9Sstevel@tonic-gate 		if (clientp->ic_base_lid == 0) {
394*7c478bd9Sstevel@tonic-gate 			IBMF_TRACE_1(IBMF_TNF_NODEBUG, DPRINT_L1,
395*7c478bd9Sstevel@tonic-gate 			    ibmf_i_alloc_ud_dest_err, IBMF_TNF_ERROR, "",
396*7c478bd9Sstevel@tonic-gate 			    "ibmf_i_alloc_ud_dest(): %s\n", tnf_string, msg,
397*7c478bd9Sstevel@tonic-gate 			    "base_lid is not defined, i.e., port is down");
398*7c478bd9Sstevel@tonic-gate 			IBMF_TRACE_0(IBMF_TNF_DEBUG, DPRINT_L4,
399*7c478bd9Sstevel@tonic-gate 			    ibmf_i_alloc_ud_dest_end, IBMF_TNF_TRACE, "",
400*7c478bd9Sstevel@tonic-gate 			    "ibmf_i_alloc_ud_dest_list() exit\n");
401*7c478bd9Sstevel@tonic-gate 			return (IBMF_BAD_PORT_STATE);
402*7c478bd9Sstevel@tonic-gate 		}
403*7c478bd9Sstevel@tonic-gate 	}
404*7c478bd9Sstevel@tonic-gate 	adds_vec.av_src_path = addrp->ia_local_lid - clientp->ic_base_lid;
405*7c478bd9Sstevel@tonic-gate 	adds_vec.av_srvl = addrp->ia_service_level;
406*7c478bd9Sstevel@tonic-gate 	adds_vec.av_srate = IBT_SRATE_1X;
407*7c478bd9Sstevel@tonic-gate 	adds_vec.av_port_num = clientp->ic_client_info.port_num;
408*7c478bd9Sstevel@tonic-gate 
409*7c478bd9Sstevel@tonic-gate 	ud_dest = *ud_dest_p;
410*7c478bd9Sstevel@tonic-gate 
411*7c478bd9Sstevel@tonic-gate 	/* If an IBT UD destination structure has not been allocated, do so */
412*7c478bd9Sstevel@tonic-gate 	if (ud_dest == NULL) {
413*7c478bd9Sstevel@tonic-gate 
414*7c478bd9Sstevel@tonic-gate 		ibmf_ud_dest_t *ibmf_ud_dest;
415*7c478bd9Sstevel@tonic-gate 
416*7c478bd9Sstevel@tonic-gate 		/* Get a UD destination resource from the list */
417*7c478bd9Sstevel@tonic-gate 		ibmf_ud_dest = ibmf_i_get_ud_dest(cip);
418*7c478bd9Sstevel@tonic-gate 		if (ibmf_ud_dest == NULL) {
419*7c478bd9Sstevel@tonic-gate 			IBMF_TRACE_1(IBMF_TNF_NODEBUG, DPRINT_L1,
420*7c478bd9Sstevel@tonic-gate 			    ibmf_i_alloc_ud_dest_err, IBMF_TNF_ERROR, "",
421*7c478bd9Sstevel@tonic-gate 			    "ibmf_i_alloc_ud_dest(): %s\n",
422*7c478bd9Sstevel@tonic-gate 			    tnf_string, msg, "No ud_dest available");
423*7c478bd9Sstevel@tonic-gate 			IBMF_TRACE_0(IBMF_TNF_DEBUG, DPRINT_L4,
424*7c478bd9Sstevel@tonic-gate 			    ibmf_i_alloc_ud_dest_end, IBMF_TNF_TRACE, "",
425*7c478bd9Sstevel@tonic-gate 			    "ibmf_i_alloc_ud_dest_list() exit\n");
426*7c478bd9Sstevel@tonic-gate 			return (IBMF_NO_RESOURCES);
427*7c478bd9Sstevel@tonic-gate 		}
428*7c478bd9Sstevel@tonic-gate 		ud_dest = &ibmf_ud_dest->ud_dest;
429*7c478bd9Sstevel@tonic-gate 		msgimplp->im_ibmf_ud_dest = ibmf_ud_dest;
430*7c478bd9Sstevel@tonic-gate 		ud_dest->ud_qkey = msgimplp->im_local_addr.ia_q_key;
431*7c478bd9Sstevel@tonic-gate 		ud_dest->ud_dst_qpn = msgimplp->im_local_addr.ia_remote_qno;
432*7c478bd9Sstevel@tonic-gate 		*ud_dest_p = ud_dest;
433*7c478bd9Sstevel@tonic-gate 	} else {
434*7c478bd9Sstevel@tonic-gate 		ud_dest->ud_qkey = msgimplp->im_local_addr.ia_q_key;
435*7c478bd9Sstevel@tonic-gate 		ud_dest->ud_dst_qpn = msgimplp->im_local_addr.ia_remote_qno;
436*7c478bd9Sstevel@tonic-gate 	}
437*7c478bd9Sstevel@tonic-gate 
438*7c478bd9Sstevel@tonic-gate 	/* modify the address handle with the address vector information */
439*7c478bd9Sstevel@tonic-gate 	status = ibt_modify_ah(cip->ci_ci_handle, ud_dest->ud_ah, &adds_vec);
440*7c478bd9Sstevel@tonic-gate 	if (status != IBT_SUCCESS)
441*7c478bd9Sstevel@tonic-gate 		IBMF_TRACE_2(IBMF_TNF_NODEBUG, DPRINT_L1,
442*7c478bd9Sstevel@tonic-gate 		    ibmf_i_alloc_ud_dest_err, IBMF_TNF_ERROR, "",
443*7c478bd9Sstevel@tonic-gate 		    "ibmf_i_alloc_ud_dest(): %s, status = %d\n",
444*7c478bd9Sstevel@tonic-gate 		    tnf_string, msg, "ibt alloc ah failed", tnf_uint,
445*7c478bd9Sstevel@tonic-gate 		    ibt_status, status);
446*7c478bd9Sstevel@tonic-gate 
447*7c478bd9Sstevel@tonic-gate 	ibmf_status = ibmf_i_ibt_to_ibmf_status(status);
448*7c478bd9Sstevel@tonic-gate 	if (ibmf_status == IBMF_SUCCESS) {
449*7c478bd9Sstevel@tonic-gate 		mutex_enter(&clientp->ic_kstat_mutex);
450*7c478bd9Sstevel@tonic-gate 		IBMF_ADD32_KSTATS(clientp, ud_dests_alloced, 1);
451*7c478bd9Sstevel@tonic-gate 		mutex_exit(&clientp->ic_kstat_mutex);
452*7c478bd9Sstevel@tonic-gate 	}
453*7c478bd9Sstevel@tonic-gate 
454*7c478bd9Sstevel@tonic-gate 	IBMF_TRACE_0(IBMF_TNF_DEBUG, DPRINT_L4, ibmf_i_alloc_ud_dest_end,
455*7c478bd9Sstevel@tonic-gate 	    IBMF_TNF_TRACE, "", "ibmf_i_alloc_ud_dest() exit\n");
456*7c478bd9Sstevel@tonic-gate 
457*7c478bd9Sstevel@tonic-gate 	return (ibmf_status);
458*7c478bd9Sstevel@tonic-gate }
459*7c478bd9Sstevel@tonic-gate 
460*7c478bd9Sstevel@tonic-gate /*
461*7c478bd9Sstevel@tonic-gate  * ibmf_i_free_ud_dest():
462*7c478bd9Sstevel@tonic-gate  *	Free up the UD destination context
463*7c478bd9Sstevel@tonic-gate  */
464*7c478bd9Sstevel@tonic-gate void
ibmf_i_free_ud_dest(ibmf_client_t * clientp,ibmf_msg_impl_t * msgimplp)465*7c478bd9Sstevel@tonic-gate ibmf_i_free_ud_dest(ibmf_client_t *clientp, ibmf_msg_impl_t *msgimplp)
466*7c478bd9Sstevel@tonic-gate {
467*7c478bd9Sstevel@tonic-gate 	IBMF_TRACE_0(IBMF_TNF_DEBUG, DPRINT_L4, ibmf_i_free_ud_dest_start,
468*7c478bd9Sstevel@tonic-gate 	    IBMF_TNF_TRACE, "", "ibmf_i_free_ud_dest() enter\n");
469*7c478bd9Sstevel@tonic-gate 
470*7c478bd9Sstevel@tonic-gate 	ibmf_i_put_ud_dest(clientp->ic_myci, msgimplp->im_ibmf_ud_dest);
471*7c478bd9Sstevel@tonic-gate 
472*7c478bd9Sstevel@tonic-gate 	/* Clear the UD dest pointers so a new UD dest may be allocated */
473*7c478bd9Sstevel@tonic-gate 	mutex_enter(&msgimplp->im_mutex);
474*7c478bd9Sstevel@tonic-gate 	msgimplp->im_ibmf_ud_dest = NULL;
475*7c478bd9Sstevel@tonic-gate 	msgimplp->im_ud_dest = NULL;
476*7c478bd9Sstevel@tonic-gate 	mutex_exit(&msgimplp->im_mutex);
477*7c478bd9Sstevel@tonic-gate 
478*7c478bd9Sstevel@tonic-gate 	mutex_enter(&clientp->ic_kstat_mutex);
479*7c478bd9Sstevel@tonic-gate 	IBMF_SUB32_KSTATS(clientp, ud_dests_alloced, 1);
480*7c478bd9Sstevel@tonic-gate 	mutex_exit(&clientp->ic_kstat_mutex);
481*7c478bd9Sstevel@tonic-gate 
482*7c478bd9Sstevel@tonic-gate 	IBMF_TRACE_0(IBMF_TNF_DEBUG, DPRINT_L4, ibmf_i_free_ud_dest_end,
483*7c478bd9Sstevel@tonic-gate 	    IBMF_TNF_TRACE, "", "ibmf_i_free_ud_dest() exit\n");
484*7c478bd9Sstevel@tonic-gate 
485*7c478bd9Sstevel@tonic-gate }
486*7c478bd9Sstevel@tonic-gate 
487*7c478bd9Sstevel@tonic-gate /*
488*7c478bd9Sstevel@tonic-gate  * ibmf_i_pop_ud_dest_thread()
489*7c478bd9Sstevel@tonic-gate  *
490*7c478bd9Sstevel@tonic-gate  * Wrapper function to call ibmf_i_populate_ud_dest_list() with
491*7c478bd9Sstevel@tonic-gate  * the KM_SLEEP flag.
492*7c478bd9Sstevel@tonic-gate  */
493*7c478bd9Sstevel@tonic-gate void
ibmf_i_pop_ud_dest_thread(void * argp)494*7c478bd9Sstevel@tonic-gate ibmf_i_pop_ud_dest_thread(void *argp)
495*7c478bd9Sstevel@tonic-gate {
496*7c478bd9Sstevel@tonic-gate 	ibmf_ci_t *cip = (ibmf_ci_t *)argp;
497*7c478bd9Sstevel@tonic-gate 
498*7c478bd9Sstevel@tonic-gate 	ibmf_i_populate_ud_dest_list(cip, KM_SLEEP);
499*7c478bd9Sstevel@tonic-gate }
500*7c478bd9Sstevel@tonic-gate 
501*7c478bd9Sstevel@tonic-gate /*
502*7c478bd9Sstevel@tonic-gate  * ibmf_ud_dest_tq_disp()
503*7c478bd9Sstevel@tonic-gate  *
504*7c478bd9Sstevel@tonic-gate  * Wrapper for taskq dispatch of the function that populates
505*7c478bd9Sstevel@tonic-gate  * the UD destination handle cache.
506*7c478bd9Sstevel@tonic-gate  */
507*7c478bd9Sstevel@tonic-gate int
ibmf_ud_dest_tq_disp(ibmf_ci_t * cip)508*7c478bd9Sstevel@tonic-gate ibmf_ud_dest_tq_disp(ibmf_ci_t *cip)
509*7c478bd9Sstevel@tonic-gate {
510*7c478bd9Sstevel@tonic-gate 	return (taskq_dispatch(ibmf_statep->ibmf_taskq,
511*7c478bd9Sstevel@tonic-gate 	    ibmf_i_pop_ud_dest_thread, cip, TQ_NOSLEEP));
512*7c478bd9Sstevel@tonic-gate }
513