Print this page
8368 remove warlock leftovers from usr/src/uts
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/io/ib/ibtl/ibtl_cm.c
+++ new/usr/src/uts/common/io/ib/ibtl/ibtl_cm.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 25
26 26 #include <sys/ib/ibtl/impl/ibtl.h>
27 27 #include <sys/ib/ibtl/impl/ibtl_cm.h>
28 28
29 29 /*
30 30 * ibtl_cm.c
31 31 * These routines tie the Communication Manager into IBTL.
32 32 */
33 33
34 34 /*
35 35 * Globals.
36 36 */
37 37 static char ibtf_cm[] = "ibtl_cm";
38 38 boolean_t ibtl_fast_gid_cache_valid = B_FALSE;
39 39
40 40 /*
41 41 * Function:
42 42 * ibtl_cm_set_chan_private
43 43 * Input:
44 44 * chan Channel Handle.
45 45 * cm_private CM private data.
46 46 * Output:
47 47 * none.
48 48 * Returns:
49 49 * none.
50 50 * Description:
51 51 * A helper function to store CM's Private data in the specified channel.
52 52 */
53 53 void
54 54 ibtl_cm_set_chan_private(ibt_channel_hdl_t chan, void *cm_private)
55 55 {
56 56 IBTF_DPRINTF_L3(ibtf_cm, "ibtl_cm_set_chan_private(%p, %p)",
57 57 chan, cm_private);
58 58
59 59 mutex_enter(&chan->ch_cm_mutex);
60 60 chan->ch_cm_private = cm_private;
61 61 if (cm_private == NULL)
62 62 cv_signal(&chan->ch_cm_cv);
63 63 mutex_exit(&chan->ch_cm_mutex);
64 64 }
65 65
66 66
67 67 /*
68 68 * Function:
69 69 * ibtl_cm_get_chan_private
70 70 * Input:
71 71 * chan Channel Handle.
72 72 * Output:
73 73 * cm_private_p The CM private data.
74 74 * Returns:
75 75 * CM private data.
76 76 * Description:
↓ open down ↓ |
76 lines elided |
↑ open up ↑ |
77 77 * A helper function to get CM's Private data for the specified channel.
78 78 */
79 79 void *
80 80 ibtl_cm_get_chan_private(ibt_channel_hdl_t chan)
81 81 {
82 82 void *cm_private;
83 83
84 84 IBTF_DPRINTF_L3(ibtf_cm, "ibtl_cm_get_chan_private(%p)", chan);
85 85 mutex_enter(&chan->ch_cm_mutex);
86 86 cm_private = chan->ch_cm_private;
87 -#ifndef __lock_lint
88 87 /* IBCM will call the release function if cm_private is non-NULL */
89 88 if (cm_private == NULL)
90 -#endif
91 89 mutex_exit(&chan->ch_cm_mutex);
92 90 return (cm_private);
93 91 }
94 92
95 93 void
96 94 ibtl_cm_release_chan_private(ibt_channel_hdl_t chan)
97 95 {
98 -#ifndef __lock_lint
99 96 mutex_exit(&chan->ch_cm_mutex);
100 -#endif
101 97 }
102 98
103 99 void
104 100 ibtl_cm_wait_chan_private(ibt_channel_hdl_t chan)
105 101 {
106 102 mutex_enter(&chan->ch_cm_mutex);
107 103 if (chan->ch_cm_private != NULL)
108 104 cv_wait(&chan->ch_cm_cv, &chan->ch_cm_mutex);
109 105 mutex_exit(&chan->ch_cm_mutex);
110 106 delay(drv_usectohz(50000));
111 107 }
112 108
113 109
114 110 /*
115 111 * Function:
116 112 * ibtl_cm_get_chan_type
117 113 * Input:
118 114 * chan Channel Handle.
119 115 * Output:
120 116 * none.
121 117 * Returns:
122 118 * Channel transport type.
123 119 * Description:
124 120 * A helper function to get channel transport type.
125 121 */
126 122 ibt_tran_srv_t
127 123 ibtl_cm_get_chan_type(ibt_channel_hdl_t chan)
128 124 {
129 125 IBTF_DPRINTF_L3(ibtf_cm, "ibtl_cm_get_chan_type(%p)", chan);
130 126
131 127 return (chan->ch_qp.qp_type);
132 128 }
133 129
134 130 /*
135 131 * Function:
136 132 * ibtl_cm_change_service_cnt
137 133 * Input:
138 134 * ibt_hdl Client's IBT Handle.
139 135 * delta_num_sids The change in the number of service ids
140 136 * (positive for ibt_register_service() and
141 137 * negative fo ibt_service_deregister()).
142 138 */
143 139 void
144 140 ibtl_cm_change_service_cnt(ibt_clnt_hdl_t ibt_hdl, int delta_num_sids)
145 141 {
146 142 IBTF_DPRINTF_L3(ibtf_cm, "ibtl_cm_change_service_cnt(%p. %d)",
147 143 ibt_hdl, delta_num_sids);
148 144
149 145 mutex_enter(&ibtl_clnt_list_mutex);
150 146 if ((delta_num_sids < 0) && (-delta_num_sids > ibt_hdl->clnt_srv_cnt)) {
151 147 IBTF_DPRINTF_L2(ibtf_cm, "ibtl_cm_change_service_cnt: "
152 148 "ERROR: service registration counter underflow\n"
153 149 "current count = %d, requested delta = %d",
154 150 ibt_hdl->clnt_srv_cnt, delta_num_sids);
155 151 }
156 152 ibt_hdl->clnt_srv_cnt += delta_num_sids;
157 153 mutex_exit(&ibtl_clnt_list_mutex);
158 154 }
159 155
160 156
161 157 /*
162 158 * Function:
163 159 * ibtl_cm_get_hca_port
164 160 * Input:
165 161 * gid Source GID.
166 162 * hca_guid Optional source HCA GUID on which SGID is available.
167 163 * Ignored if zero.
168 164 * Output:
169 165 * hca_port Pointer to ibtl_cm_hca_port_t struct.
170 166 * Returns:
171 167 * IBT_SUCCESS.
172 168 * Description:
173 169 * A helper function to get HCA node GUID, Base LID, SGID Index,
174 170 * port number, LMC and MTU for the specified SGID.
175 171 * Also filling default SGID, to be used in ibmf_sa_session_open.
176 172 */
177 173 ibt_status_t
178 174 ibtl_cm_get_hca_port(ib_gid_t gid, ib_guid_t hca_guid,
179 175 ibtl_cm_hca_port_t *hca_port)
180 176 {
181 177 ibtl_hca_devinfo_t *hca_devp; /* HCA Dev Info */
182 178 ibt_hca_portinfo_t *portinfop;
183 179 uint_t ports, port;
184 180 uint_t i;
185 181 ib_gid_t *sgid;
186 182 static ib_gid_t fast_gid; /* fast_gid_cache data */
187 183 static uint8_t fast_sgid_ix;
188 184 static ibt_hca_portinfo_t *fast_portinfop;
189 185 static ib_guid_t fast_node_guid;
190 186 static ib_guid_t fast_port_guid;
191 187
192 188 IBTF_DPRINTF_L3(ibtf_cm, "ibtl_cm_get_hca_port(%llX:%llX, %llX)",
193 189 gid.gid_prefix, gid.gid_guid, hca_guid);
194 190
195 191 if ((gid.gid_prefix == 0) || (gid.gid_guid == 0)) {
196 192 IBTF_DPRINTF_L2(ibtf_cm, "ibtl_cm_get_hca_port: "
197 193 "NULL SGID specified.");
198 194 return (IBT_INVALID_PARAM);
199 195 }
200 196
201 197 mutex_enter(&ibtl_clnt_list_mutex);
202 198
203 199 if ((ibtl_fast_gid_cache_valid == B_TRUE) &&
204 200 (gid.gid_guid == fast_gid.gid_guid) &&
205 201 (gid.gid_prefix == fast_gid.gid_prefix)) {
206 202
207 203 if ((hca_guid != 0) && (hca_guid != fast_node_guid)) {
208 204 IBTF_DPRINTF_L3(ibtf_cm, "ibtl_cm_get_hca_port: "
209 205 "Mis-match hca_guid v/s sgid combination.");
210 206 mutex_exit(&ibtl_clnt_list_mutex);
211 207 return (IBT_INVALID_PARAM);
212 208 }
213 209
214 210 portinfop = fast_portinfop;
215 211 hca_port->hp_base_lid = portinfop->p_base_lid;
216 212 hca_port->hp_port = portinfop->p_port_num;
217 213 hca_port->hp_sgid_ix = fast_sgid_ix;
218 214 hca_port->hp_lmc = portinfop->p_lmc;
219 215 hca_port->hp_mtu = portinfop->p_mtu;
220 216 hca_port->hp_hca_guid = fast_node_guid;
221 217 hca_port->hp_port_guid = fast_port_guid;
222 218
223 219 mutex_exit(&ibtl_clnt_list_mutex);
224 220
225 221 return (IBT_SUCCESS);
226 222 }
227 223
228 224 /* If HCA GUID is specified, then lookup in that device only. */
229 225 if (hca_guid) {
230 226 hca_devp = ibtl_get_hcadevinfo(hca_guid);
231 227 } else {
232 228 hca_devp = ibtl_hca_list;
233 229 }
234 230
235 231 while (hca_devp != NULL) {
236 232
237 233 ports = hca_devp->hd_hca_attr->hca_nports;
238 234 portinfop = hca_devp->hd_portinfop;
239 235
240 236 for (port = 0; port < ports; port++, portinfop++) {
241 237 if (portinfop->p_linkstate != IBT_PORT_ACTIVE)
242 238 continue;
243 239 sgid = &portinfop->p_sgid_tbl[0];
244 240 for (i = 0; i < portinfop->p_sgid_tbl_sz; i++, sgid++) {
245 241 if ((gid.gid_guid != sgid->gid_guid) ||
246 242 (gid.gid_prefix != sgid->gid_prefix))
247 243 continue;
248 244
249 245 /*
250 246 * Found the matching GID.
251 247 */
252 248 ibtl_fast_gid_cache_valid = B_TRUE;
253 249 fast_gid = gid;
254 250 fast_portinfop = portinfop;
255 251 fast_node_guid = hca_port->hp_hca_guid =
256 252 hca_devp->hd_hca_attr->hca_node_guid;
257 253 fast_sgid_ix = hca_port->hp_sgid_ix = i;
258 254 fast_port_guid =
259 255 portinfop->p_sgid_tbl[0].gid_guid;
260 256 hca_port->hp_port_guid = fast_port_guid;
261 257 hca_port->hp_base_lid = portinfop->p_base_lid;
262 258 hca_port->hp_port = portinfop->p_port_num;
263 259 hca_port->hp_lmc = portinfop->p_lmc;
264 260 hca_port->hp_mtu = portinfop->p_mtu;
265 261
266 262 mutex_exit(&ibtl_clnt_list_mutex);
267 263
268 264 return (IBT_SUCCESS);
269 265 }
270 266 }
271 267
272 268 /* Asked to look in the specified HCA device only?. */
273 269 if (hca_guid)
274 270 break;
275 271
276 272 /* Get next in the list */
277 273 hca_devp = hca_devp->hd_hca_dev_link;
278 274 }
279 275
280 276 mutex_exit(&ibtl_clnt_list_mutex);
281 277
282 278 /* If we are here, then we failed to get a match, so return error. */
283 279 return (IBT_INVALID_PARAM);
284 280 }
285 281
286 282
287 283 static ibt_status_t
288 284 ibtl_cm_get_cnt(ibt_path_attr_t *attr, ibt_path_flags_t flags,
289 285 ibtl_cm_port_list_t *plistp, uint_t *count)
290 286 {
291 287 ibtl_hca_devinfo_t *hdevp;
292 288 ibt_hca_portinfo_t *pinfop;
293 289 ib_guid_t hca_guid, tmp_hca_guid = 0;
294 290 ib_gid_t gid;
295 291 uint_t pcount = 0, tmp_pcount = 0;
296 292 uint_t cnt = *count;
297 293 ibt_status_t retval = IBT_SUCCESS;
298 294 uint_t i, j;
299 295
300 296 *count = 0;
301 297
302 298 /* If HCA GUID is specified, then lookup in that device only. */
303 299 if (attr->pa_hca_guid) {
304 300 hdevp = ibtl_get_hcadevinfo(attr->pa_hca_guid);
305 301 } else {
306 302 hdevp = ibtl_hca_list;
307 303 }
308 304
309 305 while (hdevp != NULL) {
310 306 hca_guid = hdevp->hd_hca_attr->hca_node_guid;
311 307
312 308 if ((flags & IBT_PATH_APM) &&
313 309 (!(hdevp->hd_hca_attr->hca_flags &
314 310 IBT_HCA_AUTO_PATH_MIG))) {
315 311
316 312 IBTF_DPRINTF_L2(ibtf_cm, "ibtl_cm_get_cnt: "
317 313 "HCA (%llX) - APM NOT SUPPORTED ", hca_guid);
318 314
319 315 retval = IBT_APM_NOT_SUPPORTED;
320 316
321 317 if (attr->pa_hca_guid)
322 318 break;
323 319 goto search_next;
324 320 }
325 321
326 322 for (i = 0; i < hdevp->hd_hca_attr->hca_nports; i++) {
327 323
328 324 if ((attr->pa_hca_port_num) &&
329 325 (attr->pa_hca_port_num != (i + 1))) {
330 326 IBTF_DPRINTF_L3(ibtf_cm, "ibtl_cm_get_cnt: "
331 327 "Asked only on Port# %d, so skip this "
332 328 "port(%d)", attr->pa_hca_port_num, (i + 1));
333 329 continue;
334 330 }
335 331 pinfop = hdevp->hd_portinfop + i;
336 332
337 333 if (pinfop->p_linkstate != IBT_PORT_ACTIVE) {
338 334 retval = IBT_HCA_PORT_NOT_ACTIVE;
339 335 continue;
340 336 }
341 337 if (attr->pa_mtu.r_mtu) {
342 338 if ((attr->pa_mtu.r_selector == IBT_GT) &&
343 339 (attr->pa_mtu.r_mtu >= pinfop->p_mtu))
344 340 continue;
345 341 else if ((attr->pa_mtu.r_selector == IBT_EQU) &&
346 342 (attr->pa_mtu.r_mtu > pinfop->p_mtu))
347 343 continue;
348 344 }
349 345
350 346 if ((flags & IBT_PATH_APM) && (!attr->pa_hca_guid) &&
351 347 attr->pa_sgid.gid_prefix &&
352 348 attr->pa_sgid.gid_guid) {
353 349 for (j = 0; j < pinfop->p_sgid_tbl_sz; j++) {
354 350 gid = pinfop->p_sgid_tbl[j];
355 351 if (gid.gid_prefix && gid.gid_guid) {
356 352 if ((attr->pa_sgid.gid_prefix !=
357 353 gid.gid_prefix) ||
358 354 (attr->pa_sgid.gid_guid !=
359 355 gid.gid_guid)) {
360 356 continue;
361 357 } else {
362 358 attr->pa_hca_guid =
363 359 hca_guid;
364 360 goto got_apm_hca_info;
365 361 }
366 362 }
367 363 }
368 364 continue;
369 365 }
370 366 got_apm_hca_info:
371 367 for (j = 0; j < pinfop->p_sgid_tbl_sz; j++) {
372 368 gid = pinfop->p_sgid_tbl[j];
373 369 if (gid.gid_prefix && gid.gid_guid) {
374 370 if (!(flags & IBT_PATH_APM) &&
375 371 attr->pa_sgid.gid_prefix &&
376 372 attr->pa_sgid.gid_guid) {
377 373 if ((attr->pa_sgid.gid_prefix !=
378 374 gid.gid_prefix) ||
379 375 (attr->pa_sgid.gid_guid !=
380 376 gid.gid_guid))
381 377 continue;
382 378 }
383 379 pcount++;
384 380 if (plistp) {
385 381 plistp->p_hca_guid = hca_guid;
386 382 plistp->p_mtu = pinfop->p_mtu;
387 383 plistp->p_base_lid =
388 384 pinfop->p_base_lid;
389 385 plistp->p_port_num =
390 386 pinfop->p_port_num;
391 387 plistp->p_sgid_ix = j;
392 388 plistp->p_sgid = gid;
393 389 plistp->p_count = cnt;
394 390 if (hdevp->hd_multism)
395 391 plistp->p_multi |=
396 392 IBTL_CM_MULTI_SM;
397 393
398 394 IBTF_DPRINTF_L3(ibtf_cm,
399 395 "ibtl_cm_get_cnt: HCA"
400 396 "(%llX,%d) SGID(%llX:%llX)",
401 397 plistp->p_hca_guid,
402 398 plistp->p_port_num,
403 399 plistp->p_sgid.gid_prefix,
404 400 plistp->p_sgid.gid_guid);
405 401
406 402 plistp++;
407 403 }
408 404 }
409 405 }
410 406 }
411 407 /* Asked to look in the specified HCA device only?. */
412 408 if (attr->pa_hca_guid)
413 409 break;
414 410
415 411 if (flags & IBT_PATH_APM) {
416 412 if (pcount == 2) {
417 413 attr->pa_hca_guid = hca_guid;
418 414 break;
419 415 } else if (pcount == 1) {
420 416 if (hdevp->hd_hca_dev_link) {
421 417 tmp_hca_guid = hca_guid;
422 418 tmp_pcount = pcount;
423 419 pcount = 0;
424 420 } else if (tmp_hca_guid) {
425 421 attr->pa_hca_guid = tmp_hca_guid;
426 422 } else {
427 423 attr->pa_hca_guid = hca_guid;
428 424 }
429 425 } else if ((pcount == 0) && (tmp_hca_guid)) {
430 426 attr->pa_hca_guid = tmp_hca_guid;
431 427 pcount = tmp_pcount;
432 428 }
433 429 }
434 430 search_next:
435 431 hdevp = hdevp->hd_hca_dev_link;
436 432 }
437 433
438 434 *count = pcount;
439 435
440 436 if (pcount) {
441 437 retval = IBT_SUCCESS;
442 438 } else {
443 439 IBTF_DPRINTF_L2(ibtf_cm, "ibtl_cm_get_cnt: "
444 440 "Appropriate Source Points NOT found");
445 441 if (retval == IBT_SUCCESS)
446 442 retval = IBT_NO_HCAS_AVAILABLE;
447 443 }
448 444
449 445 return (retval);
450 446 }
451 447
452 448
453 449 ibt_status_t
454 450 ibtl_cm_get_active_plist(ibt_path_attr_t *attr, ibt_path_flags_t flags,
455 451 ibtl_cm_port_list_t **port_list_p)
456 452 {
457 453 ibtl_cm_port_list_t *p_listp, tmp;
458 454 uint_t i, j;
459 455 uint_t count, rcount;
460 456 boolean_t multi_hca = B_FALSE;
461 457 ibt_status_t retval = IBT_SUCCESS;
462 458
463 459 IBTF_DPRINTF_L3(ibtf_cm, "ibtl_cm_get_active_plist(%p, %X)",
464 460 attr, flags);
465 461
466 462 get_plist_start:
467 463 *port_list_p = NULL;
468 464
469 465 /* Get "number of active src points" so that we can allocate memory. */
470 466 mutex_enter(&ibtl_clnt_list_mutex);
471 467 retval = ibtl_cm_get_cnt(attr, flags, NULL, &count);
472 468 mutex_exit(&ibtl_clnt_list_mutex);
473 469
474 470 IBTF_DPRINTF_L3(ibtf_cm, "ibtl_cm_get_active_plist: Found %d SrcPoint",
475 471 count);
476 472 if (retval != IBT_SUCCESS)
477 473 return (retval);
478 474
479 475 /* Allocate Memory to hold Src Point information. */
480 476 p_listp = kmem_zalloc(count * sizeof (ibtl_cm_port_list_t), KM_SLEEP);
481 477
482 478 /*
483 479 * Verify that the count we got previously is still valid, as we had
484 480 * dropped mutex to allocate memory. If not, restart the process.
485 481 */
486 482 mutex_enter(&ibtl_clnt_list_mutex);
487 483 retval = ibtl_cm_get_cnt(attr, flags, NULL, &rcount);
488 484 if (retval != IBT_SUCCESS) {
489 485 mutex_exit(&ibtl_clnt_list_mutex);
490 486 kmem_free(p_listp, count * sizeof (ibtl_cm_port_list_t));
491 487 return (retval);
492 488 } else if (rcount != count) {
493 489 mutex_exit(&ibtl_clnt_list_mutex);
494 490 kmem_free(p_listp, count * sizeof (ibtl_cm_port_list_t));
495 491 goto get_plist_start;
496 492 }
497 493
498 494 *port_list_p = p_listp;
499 495 /*
500 496 * Src count hasn't changed, still holding the lock fill-in the
501 497 * required source point information.
502 498 */
↓ open down ↓ |
392 lines elided |
↑ open up ↑ |
503 499 retval = ibtl_cm_get_cnt(attr, flags, p_listp, &rcount);
504 500 mutex_exit(&ibtl_clnt_list_mutex);
505 501 if (retval != IBT_SUCCESS) {
506 502 kmem_free(p_listp, count * sizeof (ibtl_cm_port_list_t));
507 503 *port_list_p = NULL;
508 504 return (retval);
509 505 }
510 506
511 507 p_listp = *port_list_p;
512 508
513 - _NOTE(NO_COMPETING_THREADS_NOW)
514 -
515 509 for (i = 0; i < count - 1; i++) {
516 510 for (j = 0; j < count - 1 - i; j++) {
517 511 if (p_listp[j].p_hca_guid != p_listp[j+1].p_hca_guid) {
518 512 multi_hca = B_TRUE;
519 513 break;
520 514 }
521 515 }
522 516 if (multi_hca == B_TRUE)
523 517 break;
524 518 }
525 519
526 520 if (multi_hca == B_TRUE)
527 521 for (i = 0; i < count; i++)
528 522 p_listp[i].p_multi |= IBTL_CM_MULTI_HCA;
529 523
530 524 /*
531 525 * Sort (bubble sort) the list based on MTU quality (higher on top).
532 526 * Sorting is only performed, if IBT_PATH_AVAIL is set.
533 527 */
534 528 if (((attr->pa_mtu.r_selector == IBT_GT) || (flags & IBT_PATH_AVAIL)) &&
535 529 (!(flags & IBT_PATH_APM))) {
536 530 for (i = 0; i < count - 1; i++) {
537 531 for (j = 0; j < count - 1 - i; j++) {
538 532 if (p_listp[j].p_mtu < p_listp[j+1].p_mtu) {
539 533 tmp = p_listp[j];
540 534 p_listp[j] = p_listp[j+1];
541 535 p_listp[j+1] = tmp;
542 536 }
543 537 }
544 538 }
545 539 }
546 540
547 541 if ((p_listp->p_multi & IBTL_CM_MULTI_HCA) &&
548 542 (flags & IBT_PATH_AVAIL) && (!(flags & IBT_PATH_APM))) {
549 543 /* Avoid having same HCA next to each other in the list. */
550 544 for (i = 0; i < count - 1; i++) {
551 545 for (j = 0; j < (count - 1 - i); j++) {
552 546 if ((p_listp[j].p_hca_guid ==
553 547 p_listp[j+1].p_hca_guid) &&
554 548 (j+2 < count)) {
555 549 tmp = p_listp[j+1];
556 550 p_listp[j+1] = p_listp[j+2];
557 551 p_listp[j+2] = tmp;
558 552 }
559 553 }
560 554 }
561 555 }
562 556
563 557 /*
564 558 * If SGID is specified, then make sure that SGID info is first
565 559 * in the array.
566 560 */
567 561 if (attr->pa_sgid.gid_guid && (p_listp->p_count > 1) &&
568 562 (p_listp[0].p_sgid.gid_guid != attr->pa_sgid.gid_guid)) {
↓ open down ↓ |
44 lines elided |
↑ open up ↑ |
569 563 for (i = 1; i < count; i++) {
570 564 if (p_listp[i].p_sgid.gid_guid ==
571 565 attr->pa_sgid.gid_guid) {
572 566 tmp = p_listp[i];
573 567 p_listp[i] = p_listp[0];
574 568 p_listp[0] = tmp;
575 569 }
576 570 }
577 571 }
578 572
579 -#ifndef lint
580 - _NOTE(COMPETING_THREADS_NOW)
581 -#endif
582 -
583 573 IBTF_DPRINTF_L3(ibtf_cm, "ibtl_cm_get_active_plist: "
584 574 "Returned <%d> entries @0x%p", count, *port_list_p);
585 575
586 576 return (retval);
587 577 }
588 578
589 579
590 580 void
591 581 ibtl_cm_free_active_plist(ibtl_cm_port_list_t *plist)
592 582 {
593 583 int count;
594 584
595 585 IBTF_DPRINTF_L3(ibtf_cm, "ibtl_cm_free_active_plist(%p)", plist);
596 586
597 587 if (plist != NULL) {
598 - _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*plist))
599 588 count = plist->p_count;
600 - _NOTE(NOW_VISIBLE_TO_OTHER_THREADS(*plist))
601 -
602 589 kmem_free(plist, count * sizeof (ibtl_cm_port_list_t));
603 590 }
604 591 }
605 592
606 593 /*
607 594 * Function:
608 595 * ibtl_cm_get_1st_full_pkey_ix
609 596 * Input:
610 597 * hca_guid HCA GUID.
611 598 * port Port Number.
612 599 * Output:
613 600 * None.
614 601 * Returns:
615 602 * P_Key Index of the first full member available from the P_Key table
616 603 * of the specified HCA<->Port.
617 604 * Description:
618 605 * A helper function to get P_Key Index of the first full member P_Key
619 606 * available on the specified HCA and Port combination.
620 607 */
621 608 uint16_t
622 609 ibtl_cm_get_1st_full_pkey_ix(ib_guid_t hca_guid, uint8_t port)
623 610 {
624 611 ibtl_hca_devinfo_t *hca_devp; /* HCA Dev Info */
625 612 uint16_t pkey_ix = 0;
626 613
627 614 IBTF_DPRINTF_L3(ibtf_cm, "ibtl_cm_get_1st_full_pkey_ix(%llX, %d)",
628 615 hca_guid, port);
629 616
630 617 mutex_enter(&ibtl_clnt_list_mutex);
631 618 hca_devp = ibtl_get_hcadevinfo(hca_guid);
632 619
633 620 if ((hca_devp != NULL) && (port <= hca_devp->hd_hca_attr->hca_nports) &&
634 621 (port != 0)) {
635 622 pkey_ix = hca_devp->hd_portinfop[port - 1].p_def_pkey_ix;
636 623 } else {
637 624 IBTF_DPRINTF_L2(ibtf_cm, "ibtl_cm_get_1st_full_pkey_ix: "
638 625 "Invalid HCA (%llX), Port (%d) specified.", hca_guid, port);
639 626 }
640 627 mutex_exit(&ibtl_clnt_list_mutex);
641 628
642 629 return (pkey_ix);
643 630 }
644 631
645 632
646 633 ibt_status_t
647 634 ibtl_cm_get_local_comp_gids(ib_guid_t hca_guid, ib_gid_t gid, ib_gid_t **gids_p,
648 635 uint_t *num_gids_p)
649 636 {
650 637 ibtl_hca_devinfo_t *hdevp; /* HCA Dev Info */
651 638 ibt_hca_portinfo_t *pinfop;
652 639 ib_gid_t sgid;
653 640 ib_gid_t *gidp = NULL;
654 641 int i, j, k;
655 642 int count = 0;
656 643 int gid_specified;
657 644
658 645 IBTF_DPRINTF_L3(ibtf_cm, "ibtl_cm_get_local_comp_gids(%llX, %llX:%llX)",
659 646 hca_guid, gid.gid_prefix, gid.gid_guid);
660 647
661 648 mutex_enter(&ibtl_clnt_list_mutex);
662 649 hdevp = ibtl_get_hcadevinfo(hca_guid);
663 650
664 651 if (hdevp == NULL) {
665 652 IBTF_DPRINTF_L3(ibtf_cm, "ibtl_cm_get_local_comp_gids: ",
666 653 "NO HCA (%llX) availble", hca_guid);
667 654 mutex_exit(&ibtl_clnt_list_mutex);
668 655 return (IBT_NO_HCAS_AVAILABLE);
669 656 }
670 657
671 658 if (gid.gid_prefix && gid.gid_guid)
672 659 gid_specified = 1;
673 660 else
674 661 gid_specified = 0;
675 662
676 663 for (i = 0; i < hdevp->hd_hca_attr->hca_nports; i++) {
677 664 pinfop = hdevp->hd_portinfop + i;
678 665
679 666 if (pinfop->p_linkstate != IBT_PORT_ACTIVE)
680 667 continue;
681 668
682 669 for (j = 0; j < pinfop->p_sgid_tbl_sz; j++) {
683 670 sgid = pinfop->p_sgid_tbl[j];
684 671 if (sgid.gid_prefix && sgid.gid_guid) {
685 672 if (gid_specified &&
686 673 ((gid.gid_prefix == sgid.gid_prefix) &&
687 674 (gid.gid_guid == sgid.gid_guid))) {
688 675 /*
689 676 * Don't return the input specified
690 677 * GID
691 678 */
692 679 continue;
693 680 }
694 681 count++;
695 682 }
696 683 }
697 684 }
698 685
699 686 if (count == 0) {
700 687 IBTF_DPRINTF_L2(ibtf_cm, "ibtl_cm_get_local_comp_gids: "
701 688 "Companion GIDs not available");
702 689 mutex_exit(&ibtl_clnt_list_mutex);
703 690 return (IBT_GIDS_NOT_FOUND);
704 691 }
705 692
706 693 gidp = kmem_zalloc(count * sizeof (ib_gid_t), KM_SLEEP);
707 694 *num_gids_p = count;
708 695 *gids_p = gidp;
709 696 k = 0;
710 697
711 698 for (i = 0; i < hdevp->hd_hca_attr->hca_nports; i++) {
712 699 pinfop = hdevp->hd_portinfop + i;
713 700
714 701 if (pinfop->p_linkstate != IBT_PORT_ACTIVE)
715 702 continue;
716 703
717 704 for (j = 0; j < pinfop->p_sgid_tbl_sz; j++) {
718 705 sgid = pinfop->p_sgid_tbl[j];
719 706 if (sgid.gid_prefix && sgid.gid_guid) {
720 707 if (gid_specified &&
721 708 ((gid.gid_prefix == sgid.gid_prefix) &&
722 709 (gid.gid_guid == sgid.gid_guid)))
723 710 continue;
724 711
725 712 gidp[k].gid_prefix = sgid.gid_prefix;
726 713 gidp[k].gid_guid = sgid.gid_guid;
727 714
728 715 IBTF_DPRINTF_L3(ibtf_cm,
729 716 "ibtl_cm_get_local_comp_gids: GID[%d]="
730 717 "%llX:%llX", k, gidp[k].gid_prefix,
731 718 gidp[k].gid_guid);
732 719 k++;
733 720 if (k == count)
734 721 break;
735 722 }
736 723 }
737 724 if (k == count)
738 725 break;
739 726 }
740 727 mutex_exit(&ibtl_clnt_list_mutex);
741 728
742 729 return (IBT_SUCCESS);
743 730 }
744 731
745 732
746 733 int
747 734 ibtl_cm_is_multi_sm(ib_guid_t hca_guid)
748 735 {
749 736 ibtl_hca_devinfo_t *hdevp; /* HCA Dev Info */
750 737 uint_t multi_sm;
751 738
752 739 mutex_enter(&ibtl_clnt_list_mutex);
753 740 hdevp = ibtl_get_hcadevinfo(hca_guid);
754 741 if (hdevp == NULL) {
755 742 IBTF_DPRINTF_L2(ibtf_cm, "ibtl_cm_is_multi_sm: NO HCA (%llX) "
756 743 "availble", hca_guid);
757 744 mutex_exit(&ibtl_clnt_list_mutex);
758 745 return (-1);
759 746 }
760 747 multi_sm = hdevp->hd_multism;
761 748 mutex_exit(&ibtl_clnt_list_mutex);
762 749
763 750 IBTF_DPRINTF_L3(ibtf_cm, "ibtl_cm_is_multi_sm(%llX): %d", hca_guid,
764 751 multi_sm);
765 752
766 753 return (multi_sm);
767 754 }
768 755
769 756 char *
770 757 ibtl_cm_get_clnt_name(ibt_clnt_hdl_t ibt_hdl)
771 758 {
772 759 if (ibt_hdl)
773 760 return (ibt_hdl->clnt_name);
774 761 else
775 762 return (NULL);
776 763 }
↓ open down ↓ |
165 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX