5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
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 (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
23 */
24
25 #include <sys/conf.h>
26 #include <sys/file.h>
27 #include <sys/ddi.h>
28 #include <sys/sunddi.h>
29 #include <sys/modctl.h>
30 #include <sys/scsi/scsi.h>
31 #include <sys/scsi/impl/scsi_reset_notify.h>
32 #include <sys/disp.h>
33 #include <sys/byteorder.h>
34 #include <sys/varargs.h>
35 #include <sys/atomic.h>
36 #include <sys/sdt.h>
37
38 #include <sys/stmf.h>
39 #include <sys/stmf_ioctl.h>
40 #include <sys/portif.h>
41 #include <sys/fct.h>
42 #include <sys/fctio.h>
43
44 #include "fct_impl.h"
202
203 atomic_and_32(&iport->iport_flags, ~IPORT_WORKER_RUNNING);
204 mutex_exit(&iport->iport_worker_lock);
205 }
206
207 static char *topologies[] = { "Unknown", "Direct Pt-to-Pt", "Private Loop",
208 "Unknown", "Unknown", "Fabric Pt-to-Pt",
209 "Public Loop" };
210
211 void
212 fct_li_to_txt(fct_link_info_t *li, char *topology, char *speed)
213 {
214 uint8_t s = li->port_speed;
215
216 if (li->port_topology > PORT_TOPOLOGY_PUBLIC_LOOP) {
217 (void) sprintf(topology, "Invalid %02x", li->port_topology);
218 } else {
219 (void) strcpy(topology, topologies[li->port_topology]);
220 }
221
222 if ((s == 0) || ((s & 0xf00) != 0) || ((s & (s - 1)) != 0)) {
223 speed[0] = '?';
224 } else if (s == PORT_SPEED_10G) {
225 speed[0] = '1';
226 speed[1] = '0';
227 speed[2] = 'G';
228 speed[3] = 0;
229 } else {
230 speed[0] = '0' + li->port_speed;
231 speed[1] = 'G';
232 speed[2] = 0;
233 }
234 }
235
236 /*
237 * discovery lock held.
238 * XXX: Implement command cleanup upon Link down.
239 * XXX: Implement a clean start and FC-GS registrations upon Link up.
240 *
241 * ================ Local Port State Machine ============
242 * <hba fatal> <Link up>---|
|
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
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 (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
23 */
24
25 #include <sys/sysmacros.h>
26 #include <sys/conf.h>
27 #include <sys/file.h>
28 #include <sys/ddi.h>
29 #include <sys/sunddi.h>
30 #include <sys/modctl.h>
31 #include <sys/scsi/scsi.h>
32 #include <sys/scsi/impl/scsi_reset_notify.h>
33 #include <sys/disp.h>
34 #include <sys/byteorder.h>
35 #include <sys/varargs.h>
36 #include <sys/atomic.h>
37 #include <sys/sdt.h>
38
39 #include <sys/stmf.h>
40 #include <sys/stmf_ioctl.h>
41 #include <sys/portif.h>
42 #include <sys/fct.h>
43 #include <sys/fctio.h>
44
45 #include "fct_impl.h"
203
204 atomic_and_32(&iport->iport_flags, ~IPORT_WORKER_RUNNING);
205 mutex_exit(&iport->iport_worker_lock);
206 }
207
208 static char *topologies[] = { "Unknown", "Direct Pt-to-Pt", "Private Loop",
209 "Unknown", "Unknown", "Fabric Pt-to-Pt",
210 "Public Loop" };
211
212 void
213 fct_li_to_txt(fct_link_info_t *li, char *topology, char *speed)
214 {
215 uint8_t s = li->port_speed;
216
217 if (li->port_topology > PORT_TOPOLOGY_PUBLIC_LOOP) {
218 (void) sprintf(topology, "Invalid %02x", li->port_topology);
219 } else {
220 (void) strcpy(topology, topologies[li->port_topology]);
221 }
222
223 if ((s == 0) || ((s & 0xf00) != 0) || !ISP2(s)) {
224 speed[0] = '?';
225 } else if (s == PORT_SPEED_10G) {
226 speed[0] = '1';
227 speed[1] = '0';
228 speed[2] = 'G';
229 speed[3] = 0;
230 } else {
231 speed[0] = '0' + li->port_speed;
232 speed[1] = 'G';
233 speed[2] = 0;
234 }
235 }
236
237 /*
238 * discovery lock held.
239 * XXX: Implement command cleanup upon Link down.
240 * XXX: Implement a clean start and FC-GS registrations upon Link up.
241 *
242 * ================ Local Port State Machine ============
243 * <hba fatal> <Link up>---|
|