4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
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.
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]
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
29 #include <sys/mdb_modapi.h>
30 #include <sys/mutex.h>
31 #include <sys/modctl.h>
32 #include <sys/ethernet.h>
33 #include <sys/fibre-channel/fc.h>
34 #include <sys/fibre-channel/impl/fc_ulpif.h>
35 #include <sys/fibre-channel/impl/fctl_private.h>
36 #include <sys/fibre-channel/ulp/fcip.h>
39 * Leadville fcip walker/dcmd code
43 fcip_walk_i(mdb_walk_state_t
*wsp
)
45 if (wsp
->walk_addr
== NULL
&&
46 mdb_readvar(&wsp
->walk_addr
, "fcip_port_head") == -1) {
47 mdb_warn("failed to read 'fcip_port_head'");
51 wsp
->walk_data
= mdb_alloc(sizeof (fcip_port_info_t
), UM_SLEEP
);
56 fcip_walk_s(mdb_walk_state_t
*wsp
)
60 if (wsp
->walk_addr
== NULL
)
63 if (mdb_vread(wsp
->walk_data
, sizeof (fcip_port_info_t
),
64 wsp
->walk_addr
) == -1) {
65 mdb_warn("failed to read fcip_port_info at %p", wsp
->walk_addr
);
69 status
= wsp
->walk_callback(wsp
->walk_addr
, wsp
->walk_data
,
73 (uintptr_t)(((fcip_port_info_t
*)wsp
->walk_data
)->fcipp_next
);
79 * The walker's fini function is invoked at the end of each walk. Since we
80 * dynamically allocated a fc_fca_port_t in port_walk_i, we must free it now.
83 fcip_walk_f(mdb_walk_state_t
*wsp
)
85 mdb_free(wsp
->walk_data
, sizeof (fc_fca_port_t
));
90 fcip(uintptr_t addr
, uint_t flags
, int argc
, const mdb_arg_t
*argv
)
92 fcip_port_info_t pinfo
;
98 if (!(flags
& DCMD_ADDRSPEC
)) {
99 if (mdb_walk_dcmd("fcip", "fcip",
101 mdb_warn("failed to walk 'fcip_port_head'");
107 if (DCMD_HDRSPEC(flags
))
108 mdb_printf("%12s %12s %12s %16s %16s\n",
109 "FCIP Struct", "Handle", "DIP", "Port WWN", "Node WWN");
112 * For each port, we just need to read the fc_fca_port_t struct, read
115 if (mdb_vread(&pinfo
, sizeof (fcip_port_info_t
), addr
) ==
116 sizeof (fcip_port_info_t
)) {
117 mdb_printf("%12p %12p %12p %02x%02x%02x%02x%02x%02x%02x%02x "
118 "%02x%02x%02x%02x%02x%02x%02x%02x\n",
119 pinfo
.fcipp_fcip
, pinfo
.fcipp_handle
, pinfo
.fcipp_dip
,
120 pinfo
.fcipp_pwwn
.raw_wwn
[0], pinfo
.fcipp_pwwn
.raw_wwn
[1],
121 pinfo
.fcipp_pwwn
.raw_wwn
[2], pinfo
.fcipp_pwwn
.raw_wwn
[3],
122 pinfo
.fcipp_pwwn
.raw_wwn
[4], pinfo
.fcipp_pwwn
.raw_wwn
[5],
123 pinfo
.fcipp_pwwn
.raw_wwn
[6], pinfo
.fcipp_pwwn
.raw_wwn
[7],
124 pinfo
.fcipp_nwwn
.raw_wwn
[0], pinfo
.fcipp_nwwn
.raw_wwn
[1],
125 pinfo
.fcipp_nwwn
.raw_wwn
[2], pinfo
.fcipp_nwwn
.raw_wwn
[3],
126 pinfo
.fcipp_nwwn
.raw_wwn
[4], pinfo
.fcipp_nwwn
.raw_wwn
[5],
127 pinfo
.fcipp_nwwn
.raw_wwn
[6], pinfo
.fcipp_nwwn
.raw_wwn
[7]);
130 mdb_warn("failed to read port info at %p", addr
);
137 * MDB module linkage information:
139 * We declare a list of structures describing our dcmds, a list of structures
140 * describing our walkers, and a function named _mdb_init to return a pointer
141 * to our module information.
144 static const mdb_dcmd_t dcmds
[] = {
145 { "fcip", NULL
, "Leadville fcip instances", fcip
},
149 static const mdb_walker_t walkers
[] = {
150 { "fcip", "walk list of Leadville fcip instances",
151 fcip_walk_i
, fcip_walk_s
, fcip_walk_f
},
155 static const mdb_modinfo_t modinfo
= {
156 MDB_API_VERSION
, dcmds
, walkers
159 const mdb_modinfo_t
*