7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25 /*
26 * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
27 */
28 /*
29 * Fibre channel Transport Library (fctl)
30 *
31 * Function naming conventions:
32 * Functions called from ULPs begin with fc_ulp_
33 * Functions called from FCAs begin with fc_fca_
34 * Internal functions begin with fctl_
35 *
36 * Fibre channel packet layout:
37 * +---------------------+<--------+
38 * | | |
39 * | ULP Packet private | |
40 * | | |
41 * +---------------------+ |
42 * | |---------+
43 * | struct fc_packet |---------+
44 * | | |
45 * +---------------------+<--------+
46 * | |
5483 */
5484 int
5485 fc_ulp_get_adapter_paths(char *pathList, int count)
5486 {
5487 fc_fca_port_t *fca_port;
5488 int in = 0, out = 0, check, skip, maxPorts = 0;
5489 fc_local_port_t **portList;
5490 fc_local_port_t *new_port, *stored_port;
5491 fca_hba_fru_details_t *new_fru, *stored_fru;
5492
5493 ASSERT(pathList != NULL);
5494
5495 /* First figure out how many ports we have */
5496 mutex_enter(&fctl_port_lock);
5497
5498 for (fca_port = fctl_fca_portlist; fca_port != NULL;
5499 fca_port = fca_port->port_next) {
5500 maxPorts ++;
5501 }
5502
5503 /* Now allocate a buffer to store all the pointers for comparisons */
5504 portList = kmem_zalloc(sizeof (fc_local_port_t *) * maxPorts, KM_SLEEP);
5505
5506 for (fca_port = fctl_fca_portlist; fca_port != NULL;
5507 fca_port = fca_port->port_next) {
5508 skip = 0;
5509
5510 /* Lock the new port for subsequent comparisons */
5511 new_port = fca_port->port_handle;
5512 mutex_enter(&new_port->fp_mutex);
5513 new_fru = &new_port->fp_hba_port_attrs.hba_fru_details;
5514
5515 /* Filter out secondary ports from the list */
5516 for (check = 0; check < out; check++) {
5517 if (portList[check] == NULL) {
5518 continue;
5519 }
5520 /* Guard against duplicates (should never happen) */
5521 if (portList[check] == fca_port->port_handle) {
5522 /* Same port */
|
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25 /*
26 * Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
27 * Copyright (c) 2015 Joyent, Inc. All rights reserved.
28 */
29 /*
30 * Fibre channel Transport Library (fctl)
31 *
32 * Function naming conventions:
33 * Functions called from ULPs begin with fc_ulp_
34 * Functions called from FCAs begin with fc_fca_
35 * Internal functions begin with fctl_
36 *
37 * Fibre channel packet layout:
38 * +---------------------+<--------+
39 * | | |
40 * | ULP Packet private | |
41 * | | |
42 * +---------------------+ |
43 * | |---------+
44 * | struct fc_packet |---------+
45 * | | |
46 * +---------------------+<--------+
47 * | |
5484 */
5485 int
5486 fc_ulp_get_adapter_paths(char *pathList, int count)
5487 {
5488 fc_fca_port_t *fca_port;
5489 int in = 0, out = 0, check, skip, maxPorts = 0;
5490 fc_local_port_t **portList;
5491 fc_local_port_t *new_port, *stored_port;
5492 fca_hba_fru_details_t *new_fru, *stored_fru;
5493
5494 ASSERT(pathList != NULL);
5495
5496 /* First figure out how many ports we have */
5497 mutex_enter(&fctl_port_lock);
5498
5499 for (fca_port = fctl_fca_portlist; fca_port != NULL;
5500 fca_port = fca_port->port_next) {
5501 maxPorts ++;
5502 }
5503
5504 if (maxPorts == 0) {
5505 mutex_exit(&fctl_port_lock);
5506 return (0);
5507 }
5508
5509 /* Now allocate a buffer to store all the pointers for comparisons */
5510 portList = kmem_zalloc(sizeof (fc_local_port_t *) * maxPorts, KM_SLEEP);
5511
5512 for (fca_port = fctl_fca_portlist; fca_port != NULL;
5513 fca_port = fca_port->port_next) {
5514 skip = 0;
5515
5516 /* Lock the new port for subsequent comparisons */
5517 new_port = fca_port->port_handle;
5518 mutex_enter(&new_port->fp_mutex);
5519 new_fru = &new_port->fp_hba_port_attrs.hba_fru_details;
5520
5521 /* Filter out secondary ports from the list */
5522 for (check = 0; check < out; check++) {
5523 if (portList[check] == NULL) {
5524 continue;
5525 }
5526 /* Guard against duplicates (should never happen) */
5527 if (portList[check] == fca_port->port_handle) {
5528 /* Same port */
|