diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/scsi/scsi_transport_fc.h |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'include/scsi/scsi_transport_fc.h')
-rw-r--r-- | include/scsi/scsi_transport_fc.h | 442 |
1 files changed, 442 insertions, 0 deletions
diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h new file mode 100644 index 000000000000..70ad16315a16 --- /dev/null +++ b/include/scsi/scsi_transport_fc.h | |||
@@ -0,0 +1,442 @@ | |||
1 | /* | ||
2 | * FiberChannel transport specific attributes exported to sysfs. | ||
3 | * | ||
4 | * Copyright (c) 2003 Silicon Graphics, Inc. All rights reserved. | ||
5 | * | ||
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. | ||
10 | * | ||
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. | ||
15 | * | ||
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 | ||
19 | * | ||
20 | * ======== | ||
21 | * | ||
22 | * Copyright (C) 2004-2005 James Smart, Emulex Corporation | ||
23 | * Rewrite for host, target, device, and remote port attributes, | ||
24 | * statistics, and service functions... | ||
25 | * | ||
26 | */ | ||
27 | #ifndef SCSI_TRANSPORT_FC_H | ||
28 | #define SCSI_TRANSPORT_FC_H | ||
29 | |||
30 | #include <linux/config.h> | ||
31 | |||
32 | struct scsi_transport_template; | ||
33 | |||
34 | |||
35 | /* | ||
36 | * FC Port definitions - Following FC HBAAPI guidelines | ||
37 | * | ||
38 | * Note: Not all binary values for the different fields match HBAAPI. | ||
39 | * Instead, we use densely packed ordinal values or enums. | ||
40 | * We get away with this as we never present the actual binary values | ||
41 | * externally. For sysfs, we always present the string that describes | ||
42 | * the value. Thus, an admin doesn't need a magic HBAAPI decoder ring | ||
43 | * to understand the values. The HBAAPI user-space library is free to | ||
44 | * convert the strings into the HBAAPI-specified binary values. | ||
45 | * | ||
46 | * Note: Not all HBAAPI-defined values are contained in the definitions | ||
47 | * below. Those not appropriate to an fc_host (e.g. FCP initiator) have | ||
48 | * been removed. | ||
49 | */ | ||
50 | |||
51 | /* | ||
52 | * fc_port_type: If you alter this, you also need to alter scsi_transport_fc.c | ||
53 | * (for the ascii descriptions). | ||
54 | */ | ||
55 | enum fc_port_type { | ||
56 | FC_PORTTYPE_UNKNOWN, | ||
57 | FC_PORTTYPE_OTHER, | ||
58 | FC_PORTTYPE_NOTPRESENT, | ||
59 | FC_PORTTYPE_NPORT, /* Attached to FPort */ | ||
60 | FC_PORTTYPE_NLPORT, /* (Public) Loop w/ FLPort */ | ||
61 | FC_PORTTYPE_LPORT, /* (Private) Loop w/o FLPort */ | ||
62 | FC_PORTTYPE_PTP, /* Point to Point w/ another NPort */ | ||
63 | }; | ||
64 | |||
65 | /* | ||
66 | * fc_port_state: If you alter this, you also need to alter scsi_transport_fc.c | ||
67 | * (for the ascii descriptions). | ||
68 | */ | ||
69 | enum fc_port_state { | ||
70 | FC_PORTSTATE_UNKNOWN, | ||
71 | FC_PORTSTATE_NOTPRESENT, | ||
72 | FC_PORTSTATE_ONLINE, | ||
73 | FC_PORTSTATE_OFFLINE, /* User has taken Port Offline */ | ||
74 | FC_PORTSTATE_BLOCKED, | ||
75 | FC_PORTSTATE_BYPASSED, | ||
76 | FC_PORTSTATE_DIAGNOSTICS, | ||
77 | FC_PORTSTATE_LINKDOWN, | ||
78 | FC_PORTSTATE_ERROR, | ||
79 | FC_PORTSTATE_LOOPBACK, | ||
80 | }; | ||
81 | |||
82 | |||
83 | /* | ||
84 | * FC Classes of Service | ||
85 | * Note: values are not enumerated, as they can be "or'd" together | ||
86 | * for reporting (e.g. report supported_classes). If you alter this list, | ||
87 | * you also need to alter scsi_transport_fc.c (for the ascii descriptions). | ||
88 | */ | ||
89 | #define FC_COS_UNSPECIFIED 0 | ||
90 | #define FC_COS_CLASS1 2 | ||
91 | #define FC_COS_CLASS2 4 | ||
92 | #define FC_COS_CLASS3 8 | ||
93 | #define FC_COS_CLASS4 0x10 | ||
94 | #define FC_COS_CLASS6 0x40 | ||
95 | |||
96 | /* | ||
97 | * FC Port Speeds | ||
98 | * Note: values are not enumerated, as they can be "or'd" together | ||
99 | * for reporting (e.g. report supported_speeds). If you alter this list, | ||
100 | * you also need to alter scsi_transport_fc.c (for the ascii descriptions). | ||
101 | */ | ||
102 | #define FC_PORTSPEED_UNKNOWN 0 /* Unknown - transceiver | ||
103 | incapable of reporting */ | ||
104 | #define FC_PORTSPEED_1GBIT 1 | ||
105 | #define FC_PORTSPEED_2GBIT 2 | ||
106 | #define FC_PORTSPEED_10GBIT 4 | ||
107 | #define FC_PORTSPEED_4GBIT 8 | ||
108 | #define FC_PORTSPEED_NOT_NEGOTIATED (1 << 15) /* Speed not established */ | ||
109 | |||
110 | /* | ||
111 | * fc_tgtid_binding_type: If you alter this, you also need to alter | ||
112 | * scsi_transport_fc.c (for the ascii descriptions). | ||
113 | */ | ||
114 | enum fc_tgtid_binding_type { | ||
115 | FC_TGTID_BIND_NONE, | ||
116 | FC_TGTID_BIND_BY_WWPN, | ||
117 | FC_TGTID_BIND_BY_WWNN, | ||
118 | FC_TGTID_BIND_BY_ID, | ||
119 | }; | ||
120 | |||
121 | /* | ||
122 | * FC Remote Port Roles | ||
123 | * Note: values are not enumerated, as they can be "or'd" together | ||
124 | * for reporting (e.g. report roles). If you alter this list, | ||
125 | * you also need to alter scsi_transport_fc.c (for the ascii descriptions). | ||
126 | */ | ||
127 | #define FC_RPORT_ROLE_UNKNOWN 0x00 | ||
128 | #define FC_RPORT_ROLE_FCP_TARGET 0x01 | ||
129 | #define FC_RPORT_ROLE_FCP_INITIATOR 0x02 | ||
130 | #define FC_RPORT_ROLE_IP_PORT 0x04 | ||
131 | |||
132 | |||
133 | /* | ||
134 | * fc_rport_identifiers: This set of data contains all elements | ||
135 | * to uniquely identify a remote FC port. The driver uses this data | ||
136 | * to report the existence of a remote FC port in the topology. Internally, | ||
137 | * the transport uses this data for attributes and to manage consistent | ||
138 | * target id bindings. | ||
139 | */ | ||
140 | struct fc_rport_identifiers { | ||
141 | u64 node_name; | ||
142 | u64 port_name; | ||
143 | u32 port_id; | ||
144 | u32 roles; | ||
145 | }; | ||
146 | |||
147 | /* Macro for use in defining Remote Port attributes */ | ||
148 | #define FC_RPORT_ATTR(_name,_mode,_show,_store) \ | ||
149 | struct class_device_attribute class_device_attr_rport_##_name = \ | ||
150 | __ATTR(_name,_mode,_show,_store) | ||
151 | |||
152 | |||
153 | /* | ||
154 | * FC Remote Port Attributes | ||
155 | * | ||
156 | * This structure exists for each remote FC port that a LLDD notifies | ||
157 | * the subsystem of. A remote FC port may or may not be a SCSI Target, | ||
158 | * also be a SCSI initiator, IP endpoint, etc. As such, the remote | ||
159 | * port is considered a separate entity, independent of "role" (such | ||
160 | * as scsi target). | ||
161 | * | ||
162 | * -- | ||
163 | * | ||
164 | * Attributes are based on HBAAPI V2.0 definitions. Only those | ||
165 | * attributes that are determinable by the local port (aka Host) | ||
166 | * are contained. | ||
167 | * | ||
168 | * Fixed attributes are not expected to change. The driver is | ||
169 | * expected to set these values after successfully calling | ||
170 | * fc_remote_port_add(). The transport fully manages all get functions | ||
171 | * w/o driver interaction. | ||
172 | * | ||
173 | * Dynamic attributes are expected to change. The driver participates | ||
174 | * in all get/set operations via functions provided by the driver. | ||
175 | * | ||
176 | * Private attributes are transport-managed values. They are fully | ||
177 | * managed by the transport w/o driver interaction. | ||
178 | */ | ||
179 | |||
180 | struct fc_rport { /* aka fc_starget_attrs */ | ||
181 | /* Fixed Attributes */ | ||
182 | u32 maxframe_size; | ||
183 | u32 supported_classes; | ||
184 | |||
185 | /* Dynamic Attributes */ | ||
186 | u32 dev_loss_tmo; /* Remote Port loss timeout in seconds. */ | ||
187 | |||
188 | /* Private (Transport-managed) Attributes */ | ||
189 | u64 node_name; | ||
190 | u64 port_name; | ||
191 | u32 port_id; | ||
192 | u32 roles; | ||
193 | enum fc_port_state port_state; /* Will only be ONLINE or UNKNOWN */ | ||
194 | u32 scsi_target_id; | ||
195 | |||
196 | /* exported data */ | ||
197 | void *dd_data; /* Used for driver-specific storage */ | ||
198 | |||
199 | /* internal data */ | ||
200 | unsigned int channel; | ||
201 | u32 number; | ||
202 | struct list_head peers; | ||
203 | struct device dev; | ||
204 | struct work_struct dev_loss_work; | ||
205 | struct work_struct scan_work; | ||
206 | } __attribute__((aligned(sizeof(unsigned long)))); | ||
207 | |||
208 | #define dev_to_rport(d) \ | ||
209 | container_of(d, struct fc_rport, dev) | ||
210 | #define transport_class_to_rport(classdev) \ | ||
211 | dev_to_rport(classdev->dev) | ||
212 | #define rport_to_shost(r) \ | ||
213 | dev_to_shost(r->dev.parent) | ||
214 | |||
215 | /* | ||
216 | * FC SCSI Target Attributes | ||
217 | * | ||
218 | * The SCSI Target is considered an extention of a remote port (as | ||
219 | * a remote port can be more than a SCSI Target). Within the scsi | ||
220 | * subsystem, we leave the Target as a separate entity. Doing so | ||
221 | * provides backward compatibility with prior FC transport api's, | ||
222 | * and lets remote ports be handled entirely within the FC transport | ||
223 | * and independently from the scsi subsystem. The drawback is that | ||
224 | * some data will be duplicated. | ||
225 | */ | ||
226 | |||
227 | struct fc_starget_attrs { /* aka fc_target_attrs */ | ||
228 | /* Dynamic Attributes */ | ||
229 | u64 node_name; | ||
230 | u64 port_name; | ||
231 | u32 port_id; | ||
232 | }; | ||
233 | |||
234 | #define fc_starget_node_name(x) \ | ||
235 | (((struct fc_starget_attrs *)&(x)->starget_data)->node_name) | ||
236 | #define fc_starget_port_name(x) \ | ||
237 | (((struct fc_starget_attrs *)&(x)->starget_data)->port_name) | ||
238 | #define fc_starget_port_id(x) \ | ||
239 | (((struct fc_starget_attrs *)&(x)->starget_data)->port_id) | ||
240 | |||
241 | #define starget_to_rport(s) \ | ||
242 | scsi_is_fc_rport(s->dev.parent) ? dev_to_rport(s->dev.parent) : NULL | ||
243 | |||
244 | |||
245 | /* | ||
246 | * FC Local Port (Host) Statistics | ||
247 | */ | ||
248 | |||
249 | /* FC Statistics - Following FC HBAAPI v2.0 guidelines */ | ||
250 | struct fc_host_statistics { | ||
251 | /* port statistics */ | ||
252 | u64 seconds_since_last_reset; | ||
253 | u64 tx_frames; | ||
254 | u64 tx_words; | ||
255 | u64 rx_frames; | ||
256 | u64 rx_words; | ||
257 | u64 lip_count; | ||
258 | u64 nos_count; | ||
259 | u64 error_frames; | ||
260 | u64 dumped_frames; | ||
261 | u64 link_failure_count; | ||
262 | u64 loss_of_sync_count; | ||
263 | u64 loss_of_signal_count; | ||
264 | u64 prim_seq_protocol_err_count; | ||
265 | u64 invalid_tx_word_count; | ||
266 | u64 invalid_crc_count; | ||
267 | |||
268 | /* fc4 statistics (only FCP supported currently) */ | ||
269 | u64 fcp_input_requests; | ||
270 | u64 fcp_output_requests; | ||
271 | u64 fcp_control_requests; | ||
272 | u64 fcp_input_megabytes; | ||
273 | u64 fcp_output_megabytes; | ||
274 | }; | ||
275 | |||
276 | |||
277 | /* | ||
278 | * FC Local Port (Host) Attributes | ||
279 | * | ||
280 | * Attributes are based on HBAAPI V2.0 definitions. | ||
281 | * Note: OSDeviceName is determined by user-space library | ||
282 | * | ||
283 | * Fixed attributes are not expected to change. The driver is | ||
284 | * expected to set these values after successfully calling scsi_add_host(). | ||
285 | * The transport fully manages all get functions w/o driver interaction. | ||
286 | * | ||
287 | * Dynamic attributes are expected to change. The driver participates | ||
288 | * in all get/set operations via functions provided by the driver. | ||
289 | * | ||
290 | * Private attributes are transport-managed values. They are fully | ||
291 | * managed by the transport w/o driver interaction. | ||
292 | */ | ||
293 | |||
294 | #define FC_FC4_LIST_SIZE 32 | ||
295 | #define FC_SYMBOLIC_NAME_SIZE 256 | ||
296 | #define FC_VERSION_STRING_SIZE 64 | ||
297 | #define FC_SERIAL_NUMBER_SIZE 80 | ||
298 | |||
299 | struct fc_host_attrs { | ||
300 | /* Fixed Attributes */ | ||
301 | u64 node_name; | ||
302 | u64 port_name; | ||
303 | u32 supported_classes; | ||
304 | u8 supported_fc4s[FC_FC4_LIST_SIZE]; | ||
305 | char symbolic_name[FC_SYMBOLIC_NAME_SIZE]; | ||
306 | u32 supported_speeds; | ||
307 | u32 maxframe_size; | ||
308 | char serial_number[FC_SERIAL_NUMBER_SIZE]; | ||
309 | |||
310 | /* Dynamic Attributes */ | ||
311 | u32 port_id; | ||
312 | enum fc_port_type port_type; | ||
313 | enum fc_port_state port_state; | ||
314 | u8 active_fc4s[FC_FC4_LIST_SIZE]; | ||
315 | u32 speed; | ||
316 | u64 fabric_name; | ||
317 | |||
318 | /* Private (Transport-managed) Attributes */ | ||
319 | enum fc_tgtid_binding_type tgtid_bind_type; | ||
320 | |||
321 | /* internal data */ | ||
322 | struct list_head rports; | ||
323 | struct list_head rport_bindings; | ||
324 | u32 next_rport_number; | ||
325 | u32 next_target_id; | ||
326 | }; | ||
327 | |||
328 | #define fc_host_node_name(x) \ | ||
329 | (((struct fc_host_attrs *)(x)->shost_data)->node_name) | ||
330 | #define fc_host_port_name(x) \ | ||
331 | (((struct fc_host_attrs *)(x)->shost_data)->port_name) | ||
332 | #define fc_host_supported_classes(x) \ | ||
333 | (((struct fc_host_attrs *)(x)->shost_data)->supported_classes) | ||
334 | #define fc_host_supported_fc4s(x) \ | ||
335 | (((struct fc_host_attrs *)(x)->shost_data)->supported_fc4s) | ||
336 | #define fc_host_symbolic_name(x) \ | ||
337 | (((struct fc_host_attrs *)(x)->shost_data)->symbolic_name) | ||
338 | #define fc_host_supported_speeds(x) \ | ||
339 | (((struct fc_host_attrs *)(x)->shost_data)->supported_speeds) | ||
340 | #define fc_host_maxframe_size(x) \ | ||
341 | (((struct fc_host_attrs *)(x)->shost_data)->maxframe_size) | ||
342 | #define fc_host_serial_number(x) \ | ||
343 | (((struct fc_host_attrs *)(x)->shost_data)->serial_number) | ||
344 | #define fc_host_port_id(x) \ | ||
345 | (((struct fc_host_attrs *)(x)->shost_data)->port_id) | ||
346 | #define fc_host_port_type(x) \ | ||
347 | (((struct fc_host_attrs *)(x)->shost_data)->port_type) | ||
348 | #define fc_host_port_state(x) \ | ||
349 | (((struct fc_host_attrs *)(x)->shost_data)->port_state) | ||
350 | #define fc_host_active_fc4s(x) \ | ||
351 | (((struct fc_host_attrs *)(x)->shost_data)->active_fc4s) | ||
352 | #define fc_host_speed(x) \ | ||
353 | (((struct fc_host_attrs *)(x)->shost_data)->speed) | ||
354 | #define fc_host_fabric_name(x) \ | ||
355 | (((struct fc_host_attrs *)(x)->shost_data)->fabric_name) | ||
356 | #define fc_host_tgtid_bind_type(x) \ | ||
357 | (((struct fc_host_attrs *)(x)->shost_data)->tgtid_bind_type) | ||
358 | #define fc_host_rports(x) \ | ||
359 | (((struct fc_host_attrs *)(x)->shost_data)->rports) | ||
360 | #define fc_host_rport_bindings(x) \ | ||
361 | (((struct fc_host_attrs *)(x)->shost_data)->rport_bindings) | ||
362 | #define fc_host_next_rport_number(x) \ | ||
363 | (((struct fc_host_attrs *)(x)->shost_data)->next_rport_number) | ||
364 | #define fc_host_next_target_id(x) \ | ||
365 | (((struct fc_host_attrs *)(x)->shost_data)->next_target_id) | ||
366 | |||
367 | |||
368 | /* The functions by which the transport class and the driver communicate */ | ||
369 | struct fc_function_template { | ||
370 | void (*get_rport_dev_loss_tmo)(struct fc_rport *); | ||
371 | void (*set_rport_dev_loss_tmo)(struct fc_rport *, u32); | ||
372 | |||
373 | void (*get_starget_node_name)(struct scsi_target *); | ||
374 | void (*get_starget_port_name)(struct scsi_target *); | ||
375 | void (*get_starget_port_id)(struct scsi_target *); | ||
376 | |||
377 | void (*get_host_port_id)(struct Scsi_Host *); | ||
378 | void (*get_host_port_type)(struct Scsi_Host *); | ||
379 | void (*get_host_port_state)(struct Scsi_Host *); | ||
380 | void (*get_host_active_fc4s)(struct Scsi_Host *); | ||
381 | void (*get_host_speed)(struct Scsi_Host *); | ||
382 | void (*get_host_fabric_name)(struct Scsi_Host *); | ||
383 | |||
384 | struct fc_host_statistics * (*get_fc_host_stats)(struct Scsi_Host *); | ||
385 | void (*reset_fc_host_stats)(struct Scsi_Host *); | ||
386 | |||
387 | /* allocation lengths for host-specific data */ | ||
388 | u32 dd_fcrport_size; | ||
389 | |||
390 | /* | ||
391 | * The driver sets these to tell the transport class it | ||
392 | * wants the attributes displayed in sysfs. If the show_ flag | ||
393 | * is not set, the attribute will be private to the transport | ||
394 | * class | ||
395 | */ | ||
396 | |||
397 | /* remote port fixed attributes */ | ||
398 | unsigned long show_rport_maxframe_size:1; | ||
399 | unsigned long show_rport_supported_classes:1; | ||
400 | unsigned long show_rport_dev_loss_tmo:1; | ||
401 | |||
402 | /* | ||
403 | * target dynamic attributes | ||
404 | * These should all be "1" if the driver uses the remote port | ||
405 | * add/delete functions (so attributes reflect rport values). | ||
406 | */ | ||
407 | unsigned long show_starget_node_name:1; | ||
408 | unsigned long show_starget_port_name:1; | ||
409 | unsigned long show_starget_port_id:1; | ||
410 | |||
411 | /* host fixed attributes */ | ||
412 | unsigned long show_host_node_name:1; | ||
413 | unsigned long show_host_port_name:1; | ||
414 | unsigned long show_host_supported_classes:1; | ||
415 | unsigned long show_host_supported_fc4s:1; | ||
416 | unsigned long show_host_symbolic_name:1; | ||
417 | unsigned long show_host_supported_speeds:1; | ||
418 | unsigned long show_host_maxframe_size:1; | ||
419 | unsigned long show_host_serial_number:1; | ||
420 | /* host dynamic attributes */ | ||
421 | unsigned long show_host_port_id:1; | ||
422 | unsigned long show_host_port_type:1; | ||
423 | unsigned long show_host_port_state:1; | ||
424 | unsigned long show_host_active_fc4s:1; | ||
425 | unsigned long show_host_speed:1; | ||
426 | unsigned long show_host_fabric_name:1; | ||
427 | }; | ||
428 | |||
429 | |||
430 | struct scsi_transport_template *fc_attach_transport( | ||
431 | struct fc_function_template *); | ||
432 | void fc_release_transport(struct scsi_transport_template *); | ||
433 | void fc_remove_host(struct Scsi_Host *); | ||
434 | struct fc_rport *fc_remote_port_add(struct Scsi_Host *shost, | ||
435 | int channel, struct fc_rport_identifiers *ids); | ||
436 | void fc_remote_port_delete(struct fc_rport *rport); | ||
437 | void fc_remote_port_rolechg(struct fc_rport *rport, u32 roles); | ||
438 | int fc_remote_port_block(struct fc_rport *rport); | ||
439 | void fc_remote_port_unblock(struct fc_rport *rport); | ||
440 | int scsi_is_fc_rport(const struct device *); | ||
441 | |||
442 | #endif /* SCSI_TRANSPORT_FC_H */ | ||