2 * FiberChannel transport specific attributes exported to sysfs.
4 * Copyright (c) 2003 Silicon Graphics, Inc. All rights reserved.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #ifndef SCSI_TRANSPORT_FC_H
21 #define SCSI_TRANSPORT_FC_H
23 #include <linux/config.h>
25 struct scsi_transport_template;
29 * FC Port definitions - Following FC HBAAPI guidelines
31 * Note: Not all binary values for the different fields match HBAAPI.
32 * Instead, we use densely packed ordinal values or enums.
33 * We get away with this as we never present the actual binary values
34 * externally. For sysfs, we always present the string that describes
35 * the value. Thus, an admin doesn't need a magic HBAAPI decoder ring
36 * to understand the values. The HBAAPI user-space library is free to
37 * convert the strings into the HBAAPI-specified binary values.
39 * Note: Not all HBAAPI-defined values are contained in the definitions
40 * below. Those not appropriate to an fc_host (e.g. FCP initiator) have
45 * fc_port_type: If you alter this, you also need to alter scsi_transport_fc.c
46 * (for the ascii descriptions).
51 FC_PORTTYPE_NOTPRESENT,
52 FC_PORTTYPE_NPORT, /* Attached to FPort */
53 FC_PORTTYPE_NLPORT, /* (Public) Loop w/ FLPort */
54 FC_PORTTYPE_LPORT, /* (Private) Loop w/o FLPort */
55 FC_PORTTYPE_PTP, /* Point to Point w/ another NPort */
59 * fc_port_state: If you alter this, you also need to alter scsi_transport_fc.c
60 * (for the ascii descriptions).
65 FC_PORTSTATE_OFFLINE, /* User has taken Port Offline */
66 FC_PORTSTATE_BYPASSED,
67 FC_PORTSTATE_DIAGNOSTICS,
68 FC_PORTSTATE_LINKDOWN,
70 FC_PORTSTATE_LOOPBACK,
75 * FC Classes of Service
76 * Note: values are not enumerated, as they can be "or'd" together
77 * for reporting (e.g. report supported_classes). If you alter this list,
78 * you also need to alter scsi_transport_fc.c (for the ascii descriptions).
80 #define FC_COS_UNSPECIFIED 0
81 #define FC_COS_CLASS1 2
82 #define FC_COS_CLASS2 4
83 #define FC_COS_CLASS3 8
84 #define FC_COS_CLASS4 0x10
85 #define FC_COS_CLASS6 0x40
89 * Note: values are not enumerated, as they can be "or'd" together
90 * for reporting (e.g. report supported_speeds). If you alter this list,
91 * you also need to alter scsi_transport_fc.c (for the ascii descriptions).
93 #define FC_PORTSPEED_UNKNOWN 0 /* Unknown - transceiver
94 incapable of reporting */
95 #define FC_PORTSPEED_1GBIT 1
96 #define FC_PORTSPEED_2GBIT 2
97 #define FC_PORTSPEED_10GBIT 4
98 #define FC_PORTSPEED_4GBIT 8
99 #define FC_PORTSPEED_NOT_NEGOTIATED (1 << 15) /* Speed not established */
102 * fc_tgtid_binding_type: If you alter this, you also need to alter
103 * scsi_transport_fc.c (for the ascii descriptions).
105 enum fc_tgtid_binding_type {
106 FC_TGTID_BIND_BY_WWPN,
107 FC_TGTID_BIND_BY_WWNN,
114 * FC Remote Port (Target) Attributes
117 struct fc_starget_attrs { /* aka fc_target_attrs */
121 u32 dev_loss_tmo; /* Remote Port loss timeout in seconds. */
122 struct work_struct dev_loss_work;
125 #define fc_starget_port_id(x) \
126 (((struct fc_starget_attrs *)&(x)->starget_data)->port_id)
127 #define fc_starget_node_name(x) \
128 (((struct fc_starget_attrs *)&(x)->starget_data)->node_name)
129 #define fc_starget_port_name(x) \
130 (((struct fc_starget_attrs *)&(x)->starget_data)->port_name)
131 #define fc_starget_dev_loss_tmo(x) \
132 (((struct fc_starget_attrs *)&(x)->starget_data)->dev_loss_tmo)
133 #define fc_starget_dev_loss_work(x) \
134 (((struct fc_starget_attrs *)&(x)->starget_data)->dev_loss_work)
138 * FC Local Port (Host) Statistics
141 /* FC Statistics - Following FC HBAAPI v2.0 guidelines */
142 struct fc_host_statistics {
143 /* port statistics */
144 u64 seconds_since_last_reset;
153 u64 link_failure_count;
154 u64 loss_of_sync_count;
155 u64 loss_of_signal_count;
156 u64 prim_seq_protocol_err_count;
157 u64 invalid_tx_word_count;
158 u64 invalid_crc_count;
160 /* fc4 statistics (only FCP supported currently) */
161 u64 fcp_input_requests;
162 u64 fcp_output_requests;
163 u64 fcp_control_requests;
164 u64 fcp_input_megabytes;
165 u64 fcp_output_megabytes;
170 * FC Local Port (Host) Attributes
172 * Attributes are based on HBAAPI V2.0 definitions.
173 * Note: OSDeviceName is determined by user-space library
175 * Fixed attributes are not expected to change. The driver is
176 * expected to set these values after successfully calling scsi_add_host().
177 * The transport fully manages all get functions w/o driver interaction.
179 * Dynamic attributes are expected to change. The driver participates
180 * in all get/set operations via functions provided by the driver.
182 * Private attributes are transport-managed values. They are fully
183 * managed by the transport w/o driver interaction.
186 #define FC_FC4_LIST_SIZE 32
187 #define FC_SYMBOLIC_NAME_SIZE 256
188 #define FC_VERSION_STRING_SIZE 64
189 #define FC_SERIAL_NUMBER_SIZE 80
191 struct fc_host_attrs {
192 /* Fixed Attributes */
195 u32 supported_classes;
196 u8 supported_fc4s[FC_FC4_LIST_SIZE];
197 char symbolic_name[FC_SYMBOLIC_NAME_SIZE];
198 u32 supported_speeds;
200 char hardware_version[FC_VERSION_STRING_SIZE];
201 char firmware_version[FC_VERSION_STRING_SIZE];
202 char serial_number[FC_SERIAL_NUMBER_SIZE];
203 char opt_rom_version[FC_VERSION_STRING_SIZE];
204 char driver_version[FC_VERSION_STRING_SIZE];
206 /* Dynamic Attributes */
208 enum fc_port_type port_type;
209 enum fc_port_state port_state;
210 u8 active_fc4s[FC_FC4_LIST_SIZE];
213 u32 link_down_tmo; /* Link Down timeout in seconds. */
215 /* Private (Transport-managed) Attributes */
216 enum fc_tgtid_binding_type tgtid_bind_type;
219 struct work_struct link_down_work;
222 #define fc_host_node_name(x) \
223 (((struct fc_host_attrs *)(x)->shost_data)->node_name)
224 #define fc_host_port_name(x) \
225 (((struct fc_host_attrs *)(x)->shost_data)->port_name)
226 #define fc_host_supported_classes(x) \
227 (((struct fc_host_attrs *)(x)->shost_data)->supported_classes)
228 #define fc_host_supported_fc4s(x) \
229 (((struct fc_host_attrs *)(x)->shost_data)->supported_fc4s)
230 #define fc_host_symbolic_name(x) \
231 (((struct fc_host_attrs *)(x)->shost_data)->symbolic_name)
232 #define fc_host_supported_speeds(x) \
233 (((struct fc_host_attrs *)(x)->shost_data)->supported_speeds)
234 #define fc_host_maxframe_size(x) \
235 (((struct fc_host_attrs *)(x)->shost_data)->maxframe_size)
236 #define fc_host_hardware_version(x) \
237 (((struct fc_host_attrs *)(x)->shost_data)->hardware_version)
238 #define fc_host_firmware_version(x) \
239 (((struct fc_host_attrs *)(x)->shost_data)->firmware_version)
240 #define fc_host_serial_number(x) \
241 (((struct fc_host_attrs *)(x)->shost_data)->serial_number)
242 #define fc_host_opt_rom_version(x) \
243 (((struct fc_host_attrs *)(x)->shost_data)->opt_rom_version)
244 #define fc_host_driver_version(x) \
245 (((struct fc_host_attrs *)(x)->shost_data)->driver_version)
246 #define fc_host_port_id(x) \
247 (((struct fc_host_attrs *)(x)->shost_data)->port_id)
248 #define fc_host_port_type(x) \
249 (((struct fc_host_attrs *)(x)->shost_data)->port_type)
250 #define fc_host_port_state(x) \
251 (((struct fc_host_attrs *)(x)->shost_data)->port_state)
252 #define fc_host_active_fc4s(x) \
253 (((struct fc_host_attrs *)(x)->shost_data)->active_fc4s)
254 #define fc_host_speed(x) \
255 (((struct fc_host_attrs *)(x)->shost_data)->speed)
256 #define fc_host_fabric_name(x) \
257 (((struct fc_host_attrs *)(x)->shost_data)->fabric_name)
258 #define fc_host_link_down_tmo(x) \
259 (((struct fc_host_attrs *)(x)->shost_data)->link_down_tmo)
260 #define fc_host_tgtid_bind_type(x) \
261 (((struct fc_host_attrs *)(x)->shost_data)->tgtid_bind_type)
262 #define fc_host_link_down_work(x) \
263 (((struct fc_host_attrs *)(x)->shost_data)->link_down_work)
266 /* The functions by which the transport class and the driver communicate */
267 struct fc_function_template {
268 void (*get_starget_port_id)(struct scsi_target *);
269 void (*get_starget_node_name)(struct scsi_target *);
270 void (*get_starget_port_name)(struct scsi_target *);
271 void (*get_starget_dev_loss_tmo)(struct scsi_target *);
272 void (*set_starget_dev_loss_tmo)(struct scsi_target *, u32);
274 void (*get_host_port_id)(struct Scsi_Host *);
275 void (*get_host_port_type)(struct Scsi_Host *);
276 void (*get_host_port_state)(struct Scsi_Host *);
277 void (*get_host_active_fc4s)(struct Scsi_Host *);
278 void (*get_host_speed)(struct Scsi_Host *);
279 void (*get_host_fabric_name)(struct Scsi_Host *);
280 void (*get_host_link_down_tmo)(struct Scsi_Host *);
281 void (*set_host_link_down_tmo)(struct Scsi_Host *, u32);
283 struct fc_host_statistics * (*get_fc_host_stats)(struct Scsi_Host *);
284 void (*reset_fc_host_stats)(struct Scsi_Host *);
287 * The driver sets these to tell the transport class it
288 * wants the attributes displayed in sysfs. If the show_ flag
289 * is not set, the attribute will be private to the transport
292 unsigned long show_starget_port_id:1;
293 unsigned long show_starget_node_name:1;
294 unsigned long show_starget_port_name:1;
295 unsigned long show_starget_dev_loss_tmo:1;
297 /* host fixed attributes */
298 unsigned long show_host_node_name:1;
299 unsigned long show_host_port_name:1;
300 unsigned long show_host_supported_classes:1;
301 unsigned long show_host_supported_fc4s:1;
302 unsigned long show_host_symbolic_name:1;
303 unsigned long show_host_supported_speeds:1;
304 unsigned long show_host_maxframe_size:1;
305 unsigned long show_host_hardware_version:1;
306 unsigned long show_host_firmware_version:1;
307 unsigned long show_host_serial_number:1;
308 unsigned long show_host_opt_rom_version:1;
309 unsigned long show_host_driver_version:1;
310 /* host dynamic attributes */
311 unsigned long show_host_port_id:1;
312 unsigned long show_host_port_type:1;
313 unsigned long show_host_port_state:1;
314 unsigned long show_host_active_fc4s:1;
315 unsigned long show_host_speed:1;
316 unsigned long show_host_fabric_name:1;
317 unsigned long show_host_link_down_tmo:1;
321 struct scsi_transport_template *fc_attach_transport(struct fc_function_template *);
322 void fc_release_transport(struct scsi_transport_template *);
323 int fc_target_block(struct scsi_target *starget);
324 void fc_target_unblock(struct scsi_target *starget);
325 int fc_host_block(struct Scsi_Host *shost);
326 void fc_host_unblock(struct Scsi_Host *shost);
328 #endif /* SCSI_TRANSPORT_FC_H */