blob: 0b11eff989e04d54dc29f98ac2f40cde5edc6fe1 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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
Tim Schmielau4e57b682005-10-30 15:03:48 -080030#include <linux/sched.h>
James.Smart@Emulex.Com19a7b4a2005-10-18 12:03:35 -040031#include <scsi/scsi.h>
James Smart84314fd2006-08-18 17:30:09 -040032#include <scsi/scsi_netlink.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070033
34struct scsi_transport_template;
35
36
37/*
38 * FC Port definitions - Following FC HBAAPI guidelines
39 *
40 * Note: Not all binary values for the different fields match HBAAPI.
41 * Instead, we use densely packed ordinal values or enums.
42 * We get away with this as we never present the actual binary values
43 * externally. For sysfs, we always present the string that describes
44 * the value. Thus, an admin doesn't need a magic HBAAPI decoder ring
45 * to understand the values. The HBAAPI user-space library is free to
46 * convert the strings into the HBAAPI-specified binary values.
47 *
48 * Note: Not all HBAAPI-defined values are contained in the definitions
49 * below. Those not appropriate to an fc_host (e.g. FCP initiator) have
50 * been removed.
51 */
52
53/*
54 * fc_port_type: If you alter this, you also need to alter scsi_transport_fc.c
55 * (for the ascii descriptions).
56 */
57enum fc_port_type {
58 FC_PORTTYPE_UNKNOWN,
59 FC_PORTTYPE_OTHER,
60 FC_PORTTYPE_NOTPRESENT,
61 FC_PORTTYPE_NPORT, /* Attached to FPort */
62 FC_PORTTYPE_NLPORT, /* (Public) Loop w/ FLPort */
63 FC_PORTTYPE_LPORT, /* (Private) Loop w/o FLPort */
64 FC_PORTTYPE_PTP, /* Point to Point w/ another NPort */
65};
66
67/*
68 * fc_port_state: If you alter this, you also need to alter scsi_transport_fc.c
69 * (for the ascii descriptions).
70 */
71enum fc_port_state {
72 FC_PORTSTATE_UNKNOWN,
73 FC_PORTSTATE_NOTPRESENT,
74 FC_PORTSTATE_ONLINE,
75 FC_PORTSTATE_OFFLINE, /* User has taken Port Offline */
76 FC_PORTSTATE_BLOCKED,
77 FC_PORTSTATE_BYPASSED,
78 FC_PORTSTATE_DIAGNOSTICS,
79 FC_PORTSTATE_LINKDOWN,
80 FC_PORTSTATE_ERROR,
81 FC_PORTSTATE_LOOPBACK,
James.Smart@Emulex.Com42e33142005-12-15 09:56:22 -050082 FC_PORTSTATE_DELETED,
Linus Torvalds1da177e2005-04-16 15:20:36 -070083};
84
85
86/*
87 * FC Classes of Service
88 * Note: values are not enumerated, as they can be "or'd" together
89 * for reporting (e.g. report supported_classes). If you alter this list,
90 * you also need to alter scsi_transport_fc.c (for the ascii descriptions).
91 */
92#define FC_COS_UNSPECIFIED 0
93#define FC_COS_CLASS1 2
94#define FC_COS_CLASS2 4
95#define FC_COS_CLASS3 8
96#define FC_COS_CLASS4 0x10
97#define FC_COS_CLASS6 0x40
98
99/*
100 * FC Port Speeds
101 * Note: values are not enumerated, as they can be "or'd" together
102 * for reporting (e.g. report supported_speeds). If you alter this list,
103 * you also need to alter scsi_transport_fc.c (for the ascii descriptions).
104 */
105#define FC_PORTSPEED_UNKNOWN 0 /* Unknown - transceiver
106 incapable of reporting */
107#define FC_PORTSPEED_1GBIT 1
108#define FC_PORTSPEED_2GBIT 2
Andreas Herrmann1832a582005-09-16 11:01:14 +0200109#define FC_PORTSPEED_4GBIT 4
110#define FC_PORTSPEED_10GBIT 8
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111#define FC_PORTSPEED_NOT_NEGOTIATED (1 << 15) /* Speed not established */
112
113/*
114 * fc_tgtid_binding_type: If you alter this, you also need to alter
115 * scsi_transport_fc.c (for the ascii descriptions).
116 */
117enum fc_tgtid_binding_type {
118 FC_TGTID_BIND_NONE,
119 FC_TGTID_BIND_BY_WWPN,
120 FC_TGTID_BIND_BY_WWNN,
121 FC_TGTID_BIND_BY_ID,
122};
123
124/*
125 * FC Remote Port Roles
126 * Note: values are not enumerated, as they can be "or'd" together
127 * for reporting (e.g. report roles). If you alter this list,
128 * you also need to alter scsi_transport_fc.c (for the ascii descriptions).
129 */
130#define FC_RPORT_ROLE_UNKNOWN 0x00
131#define FC_RPORT_ROLE_FCP_TARGET 0x01
132#define FC_RPORT_ROLE_FCP_INITIATOR 0x02
133#define FC_RPORT_ROLE_IP_PORT 0x04
134
135
136/*
137 * fc_rport_identifiers: This set of data contains all elements
138 * to uniquely identify a remote FC port. The driver uses this data
139 * to report the existence of a remote FC port in the topology. Internally,
140 * the transport uses this data for attributes and to manage consistent
141 * target id bindings.
142 */
143struct fc_rport_identifiers {
144 u64 node_name;
145 u64 port_name;
146 u32 port_id;
147 u32 roles;
148};
149
150/* Macro for use in defining Remote Port attributes */
151#define FC_RPORT_ATTR(_name,_mode,_show,_store) \
152struct class_device_attribute class_device_attr_rport_##_name = \
153 __ATTR(_name,_mode,_show,_store)
154
155
156/*
157 * FC Remote Port Attributes
158 *
159 * This structure exists for each remote FC port that a LLDD notifies
160 * the subsystem of. A remote FC port may or may not be a SCSI Target,
161 * also be a SCSI initiator, IP endpoint, etc. As such, the remote
162 * port is considered a separate entity, independent of "role" (such
163 * as scsi target).
164 *
165 * --
166 *
167 * Attributes are based on HBAAPI V2.0 definitions. Only those
168 * attributes that are determinable by the local port (aka Host)
169 * are contained.
170 *
171 * Fixed attributes are not expected to change. The driver is
172 * expected to set these values after successfully calling
173 * fc_remote_port_add(). The transport fully manages all get functions
174 * w/o driver interaction.
175 *
176 * Dynamic attributes are expected to change. The driver participates
177 * in all get/set operations via functions provided by the driver.
178 *
179 * Private attributes are transport-managed values. They are fully
180 * managed by the transport w/o driver interaction.
181 */
182
183struct fc_rport { /* aka fc_starget_attrs */
184 /* Fixed Attributes */
185 u32 maxframe_size;
186 u32 supported_classes;
187
188 /* Dynamic Attributes */
189 u32 dev_loss_tmo; /* Remote Port loss timeout in seconds. */
190
191 /* Private (Transport-managed) Attributes */
192 u64 node_name;
193 u64 port_name;
194 u32 port_id;
195 u32 roles;
196 enum fc_port_state port_state; /* Will only be ONLINE or UNKNOWN */
197 u32 scsi_target_id;
198
199 /* exported data */
200 void *dd_data; /* Used for driver-specific storage */
201
202 /* internal data */
203 unsigned int channel;
204 u32 number;
James Smartaedf3492006-04-10 10:14:05 -0400205 u8 flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206 struct list_head peers;
207 struct device dev;
208 struct work_struct dev_loss_work;
209 struct work_struct scan_work;
James Smartaedf3492006-04-10 10:14:05 -0400210 struct work_struct stgt_delete_work;
211 struct work_struct rport_delete_work;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212} __attribute__((aligned(sizeof(unsigned long))));
213
James Smartaedf3492006-04-10 10:14:05 -0400214/* bit field values for struct fc_rport "flags" field: */
215#define FC_RPORT_DEVLOSS_PENDING 0x01
216#define FC_RPORT_SCAN_PENDING 0x02
217
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218#define dev_to_rport(d) \
219 container_of(d, struct fc_rport, dev)
220#define transport_class_to_rport(classdev) \
221 dev_to_rport(classdev->dev)
222#define rport_to_shost(r) \
223 dev_to_shost(r->dev.parent)
224
225/*
226 * FC SCSI Target Attributes
227 *
228 * The SCSI Target is considered an extention of a remote port (as
229 * a remote port can be more than a SCSI Target). Within the scsi
230 * subsystem, we leave the Target as a separate entity. Doing so
231 * provides backward compatibility with prior FC transport api's,
232 * and lets remote ports be handled entirely within the FC transport
233 * and independently from the scsi subsystem. The drawback is that
234 * some data will be duplicated.
235 */
236
237struct fc_starget_attrs { /* aka fc_target_attrs */
238 /* Dynamic Attributes */
239 u64 node_name;
240 u64 port_name;
241 u32 port_id;
242};
243
244#define fc_starget_node_name(x) \
245 (((struct fc_starget_attrs *)&(x)->starget_data)->node_name)
246#define fc_starget_port_name(x) \
247 (((struct fc_starget_attrs *)&(x)->starget_data)->port_name)
248#define fc_starget_port_id(x) \
249 (((struct fc_starget_attrs *)&(x)->starget_data)->port_id)
250
251#define starget_to_rport(s) \
252 scsi_is_fc_rport(s->dev.parent) ? dev_to_rport(s->dev.parent) : NULL
253
254
255/*
256 * FC Local Port (Host) Statistics
257 */
258
259/* FC Statistics - Following FC HBAAPI v2.0 guidelines */
260struct fc_host_statistics {
261 /* port statistics */
262 u64 seconds_since_last_reset;
263 u64 tx_frames;
264 u64 tx_words;
265 u64 rx_frames;
266 u64 rx_words;
267 u64 lip_count;
268 u64 nos_count;
269 u64 error_frames;
270 u64 dumped_frames;
271 u64 link_failure_count;
272 u64 loss_of_sync_count;
273 u64 loss_of_signal_count;
274 u64 prim_seq_protocol_err_count;
275 u64 invalid_tx_word_count;
276 u64 invalid_crc_count;
277
278 /* fc4 statistics (only FCP supported currently) */
279 u64 fcp_input_requests;
280 u64 fcp_output_requests;
281 u64 fcp_control_requests;
282 u64 fcp_input_megabytes;
283 u64 fcp_output_megabytes;
284};
285
286
287/*
James Smart84314fd2006-08-18 17:30:09 -0400288 * FC Event Codes - Polled and Async, following FC HBAAPI v2.0 guidelines
289 */
290
291/*
292 * fc_host_event_code: If you alter this, you also need to alter
293 * scsi_transport_fc.c (for the ascii descriptions).
294 */
295enum fc_host_event_code {
296 FCH_EVT_LIP = 0x1,
297 FCH_EVT_LINKUP = 0x2,
298 FCH_EVT_LINKDOWN = 0x3,
299 FCH_EVT_LIPRESET = 0x4,
300 FCH_EVT_RSCN = 0x5,
301 FCH_EVT_ADAPTER_CHANGE = 0x103,
302 FCH_EVT_PORT_UNKNOWN = 0x200,
303 FCH_EVT_PORT_OFFLINE = 0x201,
304 FCH_EVT_PORT_ONLINE = 0x202,
305 FCH_EVT_PORT_FABRIC = 0x204,
306 FCH_EVT_LINK_UNKNOWN = 0x500,
307 FCH_EVT_VENDOR_UNIQUE = 0xffff,
308};
309
310
311/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312 * FC Local Port (Host) Attributes
313 *
314 * Attributes are based on HBAAPI V2.0 definitions.
315 * Note: OSDeviceName is determined by user-space library
316 *
317 * Fixed attributes are not expected to change. The driver is
318 * expected to set these values after successfully calling scsi_add_host().
319 * The transport fully manages all get functions w/o driver interaction.
320 *
321 * Dynamic attributes are expected to change. The driver participates
322 * in all get/set operations via functions provided by the driver.
323 *
324 * Private attributes are transport-managed values. They are fully
325 * managed by the transport w/o driver interaction.
326 */
327
328#define FC_FC4_LIST_SIZE 32
329#define FC_SYMBOLIC_NAME_SIZE 256
330#define FC_VERSION_STRING_SIZE 64
331#define FC_SERIAL_NUMBER_SIZE 80
332
333struct fc_host_attrs {
334 /* Fixed Attributes */
335 u64 node_name;
336 u64 port_name;
Andreas Herrmann6b7281d2006-01-13 02:16:54 +0100337 u64 permanent_port_name;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338 u32 supported_classes;
339 u8 supported_fc4s[FC_FC4_LIST_SIZE];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340 u32 supported_speeds;
341 u32 maxframe_size;
342 char serial_number[FC_SERIAL_NUMBER_SIZE];
343
344 /* Dynamic Attributes */
345 u32 port_id;
346 enum fc_port_type port_type;
347 enum fc_port_state port_state;
348 u8 active_fc4s[FC_FC4_LIST_SIZE];
349 u32 speed;
350 u64 fabric_name;
James Smartb8d08212006-08-17 08:00:43 -0400351 char symbolic_name[FC_SYMBOLIC_NAME_SIZE];
352 char system_hostname[FC_SYMBOLIC_NAME_SIZE];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353
354 /* Private (Transport-managed) Attributes */
355 enum fc_tgtid_binding_type tgtid_bind_type;
356
357 /* internal data */
358 struct list_head rports;
359 struct list_head rport_bindings;
360 u32 next_rport_number;
361 u32 next_target_id;
James Smartaedf3492006-04-10 10:14:05 -0400362
363 /* work queues for rport state manipulation */
364 char work_q_name[KOBJ_NAME_LEN];
365 struct workqueue_struct *work_q;
366 char devloss_work_q_name[KOBJ_NAME_LEN];
367 struct workqueue_struct *devloss_work_q;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368};
369
James Smartaedf3492006-04-10 10:14:05 -0400370#define shost_to_fc_host(x) \
371 ((struct fc_host_attrs *)(x)->shost_data)
James.Smart@Emulex.Com42e33142005-12-15 09:56:22 -0500372
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373#define fc_host_node_name(x) \
374 (((struct fc_host_attrs *)(x)->shost_data)->node_name)
375#define fc_host_port_name(x) \
376 (((struct fc_host_attrs *)(x)->shost_data)->port_name)
Andreas Herrmann6b7281d2006-01-13 02:16:54 +0100377#define fc_host_permanent_port_name(x) \
378 (((struct fc_host_attrs *)(x)->shost_data)->permanent_port_name)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379#define fc_host_supported_classes(x) \
380 (((struct fc_host_attrs *)(x)->shost_data)->supported_classes)
381#define fc_host_supported_fc4s(x) \
382 (((struct fc_host_attrs *)(x)->shost_data)->supported_fc4s)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383#define fc_host_supported_speeds(x) \
384 (((struct fc_host_attrs *)(x)->shost_data)->supported_speeds)
385#define fc_host_maxframe_size(x) \
386 (((struct fc_host_attrs *)(x)->shost_data)->maxframe_size)
387#define fc_host_serial_number(x) \
388 (((struct fc_host_attrs *)(x)->shost_data)->serial_number)
389#define fc_host_port_id(x) \
390 (((struct fc_host_attrs *)(x)->shost_data)->port_id)
391#define fc_host_port_type(x) \
392 (((struct fc_host_attrs *)(x)->shost_data)->port_type)
393#define fc_host_port_state(x) \
394 (((struct fc_host_attrs *)(x)->shost_data)->port_state)
395#define fc_host_active_fc4s(x) \
396 (((struct fc_host_attrs *)(x)->shost_data)->active_fc4s)
397#define fc_host_speed(x) \
398 (((struct fc_host_attrs *)(x)->shost_data)->speed)
399#define fc_host_fabric_name(x) \
400 (((struct fc_host_attrs *)(x)->shost_data)->fabric_name)
James Smartb8d08212006-08-17 08:00:43 -0400401#define fc_host_symbolic_name(x) \
402 (((struct fc_host_attrs *)(x)->shost_data)->symbolic_name)
403#define fc_host_system_hostname(x) \
404 (((struct fc_host_attrs *)(x)->shost_data)->system_hostname)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405#define fc_host_tgtid_bind_type(x) \
406 (((struct fc_host_attrs *)(x)->shost_data)->tgtid_bind_type)
407#define fc_host_rports(x) \
408 (((struct fc_host_attrs *)(x)->shost_data)->rports)
409#define fc_host_rport_bindings(x) \
410 (((struct fc_host_attrs *)(x)->shost_data)->rport_bindings)
411#define fc_host_next_rport_number(x) \
412 (((struct fc_host_attrs *)(x)->shost_data)->next_rport_number)
413#define fc_host_next_target_id(x) \
414 (((struct fc_host_attrs *)(x)->shost_data)->next_target_id)
James Smartaedf3492006-04-10 10:14:05 -0400415#define fc_host_work_q_name(x) \
416 (((struct fc_host_attrs *)(x)->shost_data)->work_q_name)
417#define fc_host_work_q(x) \
418 (((struct fc_host_attrs *)(x)->shost_data)->work_q)
419#define fc_host_devloss_work_q_name(x) \
420 (((struct fc_host_attrs *)(x)->shost_data)->devloss_work_q_name)
421#define fc_host_devloss_work_q(x) \
422 (((struct fc_host_attrs *)(x)->shost_data)->devloss_work_q)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423
424
425/* The functions by which the transport class and the driver communicate */
426struct fc_function_template {
427 void (*get_rport_dev_loss_tmo)(struct fc_rport *);
428 void (*set_rport_dev_loss_tmo)(struct fc_rport *, u32);
429
430 void (*get_starget_node_name)(struct scsi_target *);
431 void (*get_starget_port_name)(struct scsi_target *);
432 void (*get_starget_port_id)(struct scsi_target *);
433
434 void (*get_host_port_id)(struct Scsi_Host *);
435 void (*get_host_port_type)(struct Scsi_Host *);
436 void (*get_host_port_state)(struct Scsi_Host *);
437 void (*get_host_active_fc4s)(struct Scsi_Host *);
438 void (*get_host_speed)(struct Scsi_Host *);
439 void (*get_host_fabric_name)(struct Scsi_Host *);
James Smart016131b2006-08-14 08:20:25 -0400440 void (*get_host_symbolic_name)(struct Scsi_Host *);
James Smartb8d08212006-08-17 08:00:43 -0400441 void (*set_host_system_hostname)(struct Scsi_Host *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442
443 struct fc_host_statistics * (*get_fc_host_stats)(struct Scsi_Host *);
444 void (*reset_fc_host_stats)(struct Scsi_Host *);
445
Andrew Vasquez91ca7b02005-10-27 16:03:37 -0700446 int (*issue_fc_host_lip)(struct Scsi_Host *);
447
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448 /* allocation lengths for host-specific data */
449 u32 dd_fcrport_size;
450
451 /*
452 * The driver sets these to tell the transport class it
453 * wants the attributes displayed in sysfs. If the show_ flag
454 * is not set, the attribute will be private to the transport
455 * class
456 */
457
458 /* remote port fixed attributes */
459 unsigned long show_rport_maxframe_size:1;
460 unsigned long show_rport_supported_classes:1;
461 unsigned long show_rport_dev_loss_tmo:1;
462
463 /*
464 * target dynamic attributes
465 * These should all be "1" if the driver uses the remote port
466 * add/delete functions (so attributes reflect rport values).
467 */
468 unsigned long show_starget_node_name:1;
469 unsigned long show_starget_port_name:1;
470 unsigned long show_starget_port_id:1;
471
472 /* host fixed attributes */
473 unsigned long show_host_node_name:1;
474 unsigned long show_host_port_name:1;
Andreas Herrmann6b7281d2006-01-13 02:16:54 +0100475 unsigned long show_host_permanent_port_name:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476 unsigned long show_host_supported_classes:1;
477 unsigned long show_host_supported_fc4s:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478 unsigned long show_host_supported_speeds:1;
479 unsigned long show_host_maxframe_size:1;
480 unsigned long show_host_serial_number:1;
481 /* host dynamic attributes */
482 unsigned long show_host_port_id:1;
483 unsigned long show_host_port_type:1;
484 unsigned long show_host_port_state:1;
485 unsigned long show_host_active_fc4s:1;
486 unsigned long show_host_speed:1;
487 unsigned long show_host_fabric_name:1;
James Smart016131b2006-08-14 08:20:25 -0400488 unsigned long show_host_symbolic_name:1;
James Smartb8d08212006-08-17 08:00:43 -0400489 unsigned long show_host_system_hostname:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490};
491
492
James.Smart@Emulex.Com19a7b4a2005-10-18 12:03:35 -0400493/**
494 * fc_remote_port_chkready - called to validate the remote port state
495 * prior to initiating io to the port.
496 *
497 * Returns a scsi result code that can be returned by the LLDD.
498 *
499 * @rport: remote port to be checked
500 **/
501static inline int
502fc_remote_port_chkready(struct fc_rport *rport)
503{
504 int result;
505
506 switch (rport->port_state) {
507 case FC_PORTSTATE_ONLINE:
James Smartaedf3492006-04-10 10:14:05 -0400508 if (rport->roles & FC_RPORT_ROLE_FCP_TARGET)
509 result = 0;
510 else if (rport->flags & FC_RPORT_DEVLOSS_PENDING)
511 result = DID_IMM_RETRY << 16;
512 else
513 result = DID_NO_CONNECT << 16;
James.Smart@Emulex.Com19a7b4a2005-10-18 12:03:35 -0400514 break;
515 case FC_PORTSTATE_BLOCKED:
James Smartaedf3492006-04-10 10:14:05 -0400516 result = DID_IMM_RETRY << 16;
James.Smart@Emulex.Com19a7b4a2005-10-18 12:03:35 -0400517 break;
518 default:
519 result = DID_NO_CONNECT << 16;
520 break;
521 }
522 return result;
523}
524
James Smartb8d08212006-08-17 08:00:43 -0400525static inline u64 wwn_to_u64(u8 *wwn)
526{
527 return (u64)wwn[0] << 56 | (u64)wwn[1] << 48 |
528 (u64)wwn[2] << 40 | (u64)wwn[3] << 32 |
529 (u64)wwn[4] << 24 | (u64)wwn[5] << 16 |
530 (u64)wwn[6] << 8 | (u64)wwn[7];
531}
532
533static inline void u64_to_wwn(u64 inm, u8 *wwn)
534{
535 wwn[0] = (inm >> 56) & 0xff;
536 wwn[1] = (inm >> 48) & 0xff;
537 wwn[2] = (inm >> 40) & 0xff;
538 wwn[3] = (inm >> 32) & 0xff;
539 wwn[4] = (inm >> 24) & 0xff;
540 wwn[5] = (inm >> 16) & 0xff;
541 wwn[6] = (inm >> 8) & 0xff;
542 wwn[7] = inm & 0xff;
543}
James.Smart@Emulex.Com19a7b4a2005-10-18 12:03:35 -0400544
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545struct scsi_transport_template *fc_attach_transport(
546 struct fc_function_template *);
547void fc_release_transport(struct scsi_transport_template *);
548void fc_remove_host(struct Scsi_Host *);
549struct fc_rport *fc_remote_port_add(struct Scsi_Host *shost,
550 int channel, struct fc_rport_identifiers *ids);
551void fc_remote_port_delete(struct fc_rport *rport);
552void fc_remote_port_rolechg(struct fc_rport *rport, u32 roles);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700553int scsi_is_fc_rport(const struct device *);
James Smart84314fd2006-08-18 17:30:09 -0400554u32 fc_get_event_number(void);
555void fc_host_post_event(struct Scsi_Host *shost, u32 event_number,
556 enum fc_host_event_code event_code, u32 event_data);
557void fc_host_post_vendor_event(struct Scsi_Host *shost, u32 event_number,
James Smartf14e2e22006-08-22 09:55:23 -0400558 u32 data_len, char * data_buf, u64 vendor_id);
James Smart84314fd2006-08-18 17:30:09 -0400559 /* Note: when specifying vendor_id to fc_host_post_vendor_event()
560 * be sure to read the Vendor Type and ID formatting requirements
561 * specified in scsi_netlink.h
562 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563
Linus Torvalds1da177e2005-04-16 15:20:36 -0700564#endif /* SCSI_TRANSPORT_FC_H */