xref: /titanic_41/usr/src/lib/libdtrace/common/fc.d (revision 29bd28862cfb8abbd3a0f0a4b17e08bbc3652836)
1 /*
2  * CDDL HEADER START
3  *
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.
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 /*
23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #pragma	D depends_on library net.d
28 #pragma	D depends_on library scsi.d
29 #pragma	D depends_on module genunix
30 #pragma	D depends_on module fct
31 
32 /*
33  * FC port information.
34  */
35 typedef struct fc_port_info {
36 	string fcp_node_wwn;		/* node WWN */
37 	string fcp_sym_node_name;	/* node symbolic name */
38 	string fcp_sym_port_name;	/* port symbolic name */
39 	uint32_t fcp_port_hard_address;	/* port hard address */
40 } fc_port_info_t;
41 
42 /*
43  * FC transfer info (somewhat analogous to iscsiinfo_t)
44  * Represents data transfer details.
45  */
46 typedef struct fc_xferinfo {
47 	uint32_t fcx_len;
48 	uint32_t fcx_offset;
49 	uint16_t fcx_flags;	/* db_flags as defined in sys/stmf.h */
50 } fc_xferinfo_t;
51 
52 /*
53  * conninfo translators
54  */
55 
56 /*
57  * Translator for conninfo, translating from the local port.
58  */
59 #pragma D binding "1.5" translator
60 translator conninfo_t < fct_local_port_t *P > {
61  	ci_local = P->port_pwwn_str[0] ?
62 	    P->port_pwwn_str : "<unknown>";
63  	ci_remote = "<unknown>";
64 	ci_protocol = "fc";
65 };
66 
67 /*
68  * Translator for conninfo, translating from the local port implementation.
69  */
70 #pragma D binding "1.5" translator
71 translator conninfo_t < fct_i_local_port_t *P > {
72  	ci_local = P->iport_port->port_pwwn_str[0] ?
73 		 P->iport_port->port_pwwn_str : "<unknown>";
74  	ci_remote = "<unknown>";
75 	ci_protocol = "fc";
76 };
77 
78 /*
79  * Translator for conninfo, translating from fct cmd struct.
80  */
81 #pragma D binding "1.5" translator
82 translator conninfo_t < fct_cmd_t *C > {
83  	ci_local = (C->cmd_port ?
84 		 (C->cmd_port->port_pwwn_str[0] ?
85 		  C->cmd_port->port_pwwn_str : "<unknown>") :
86 		 "<unknown>");
87 
88  	ci_remote = (C->cmd_rp ?
89 		 (C->cmd_rp->rp_pwwn_str[0] ?
90 		  C->cmd_rp->rp_pwwn_str : "<unknown>") :
91 		 "<unknown>");
92 
93 	ci_protocol = "fc";
94 };
95 
96 
97 /*
98  * fc_port_info_t translators.
99  */
100 
101 /*
102  * Translator for fc_port_info_t, translating from the local port.
103  */
104 #pragma D binding "1.5" translator
105 translator fc_port_info_t < fct_local_port_t *P > {
106         /* node WWN */
107 	fcp_node_wwn = P->port_nwwn_str[0] ?
108 		     P->port_nwwn_str : "<unknown>";
109 
110 	/* node symbolic name */
111 	fcp_sym_node_name = P->port_sym_node_name ?
112 		P->port_sym_node_name : `utsname.nodename;
113 
114 	/* port symbolic name */
115 	fcp_sym_port_name = P->port_sym_port_name ?
116 			P->port_sym_port_name : "<unknown>";
117 
118 	/* port hard address */
119 	fcp_port_hard_address = P->port_hard_address;
120 };
121 
122 
123 /*
124  * Translator for fc_port_info_t, translating from the local port impl.
125  */
126 #pragma D binding "1.5" translator
127 translator fc_port_info_t < fct_i_local_port_t *P > {
128         /* node WWN */
129 
130 	fcp_node_wwn = (P->iport_port ?
131 			   (P->iport_port->port_nwwn_str[0] ?
132 		               P->iport_port->port_nwwn_str :
133 			       "<unknown>") :
134 		           "<bad iport_port ptr>");
135 
136 	fcp_sym_node_name =
137 			 (P->iport_port ?
138 			   (P->iport_port->port_sym_node_name ?
139 		            P->iport_port->port_sym_node_name : "<unknown>") :
140 		           "<bad iport_port ptr>");
141 
142 	fcp_sym_port_name =
143 			 (P->iport_port ?
144 			   (P->iport_port->port_sym_port_name ?
145 		            P->iport_port->port_sym_port_name : "<unknown>") :
146 		           "<bad iport_port ptr>");
147 
148 	fcp_port_hard_address =
149 			 (P->iport_port ?
150 			   P->iport_port->port_hard_address : 0);
151 };
152 
153 /*
154  * Translator for fc_port_info, translating from the remote port impl
155  */
156 #pragma D binding "1.5" translator
157 translator fc_port_info_t < fct_i_remote_port_t *P > {
158 
159         /* node WWN */
160 	fcp_node_wwn = P->irp_rp ?
161 			   (P->irp_rp->rp_nwwn_str[0] ?
162 			     P->irp_rp->rp_nwwn_str : "<unknown>") :
163                            "<unknown>";
164 
165 	/* node symbolic name */
166 	fcp_sym_node_name = P->irp_snn ? P->irp_snn : "<unknown>";
167 
168 	/* port symbolic name */
169 	fcp_sym_port_name = P->irp_spn ? P->irp_spn : "<unknown>";
170 
171 	/* port hard address */
172 	fcp_port_hard_address = P->irp_rp ? P->irp_rp->rp_id : 0;
173 };
174 
175 /*
176  * Translator for fc_xferinfo, translating from stmf_data_buf_t.
177  */
178 #pragma D binding "1.5" translator
179 translator fc_xferinfo_t < stmf_data_buf_t *B > {
180 	   fcx_len = B->db_data_size;
181 	   fcx_offset = B->db_relative_offset;
182 	   fcx_flags = B->db_flags;
183 };
184