fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / include / scsi / scsi_transport_fc.h
index 70ad163..798f7c7 100644 (file)
@@ -27,7 +27,9 @@
 #ifndef SCSI_TRANSPORT_FC_H
 #define SCSI_TRANSPORT_FC_H
 
-#include <linux/config.h>
+#include <linux/sched.h>
+#include <scsi/scsi.h>
+#include <scsi/scsi_netlink.h>
 
 struct scsi_transport_template;
 
@@ -77,6 +79,7 @@ enum fc_port_state {
        FC_PORTSTATE_LINKDOWN,
        FC_PORTSTATE_ERROR,
        FC_PORTSTATE_LOOPBACK,
+       FC_PORTSTATE_DELETED,
 };
 
 
@@ -103,8 +106,8 @@ enum fc_port_state {
                                             incapable of reporting */
 #define FC_PORTSPEED_1GBIT             1
 #define FC_PORTSPEED_2GBIT             2
-#define FC_PORTSPEED_10GBIT            4
-#define FC_PORTSPEED_4GBIT             8
+#define FC_PORTSPEED_4GBIT             4
+#define FC_PORTSPEED_10GBIT            8
 #define FC_PORTSPEED_NOT_NEGOTIATED    (1 << 15) /* Speed not established */
 
 /*
@@ -192,6 +195,7 @@ struct fc_rport {   /* aka fc_starget_attrs */
        u32 roles;
        enum fc_port_state port_state;  /* Will only be ONLINE or UNKNOWN */
        u32 scsi_target_id;
+       u32 fast_io_fail_tmo;
 
        /* exported data */
        void *dd_data;                  /* Used for driver-specific storage */
@@ -199,12 +203,20 @@ struct fc_rport { /* aka fc_starget_attrs */
        /* internal data */
        unsigned int channel;
        u32 number;
+       u8 flags;
        struct list_head peers;
        struct device dev;
-       struct work_struct dev_loss_work;
+       struct delayed_work dev_loss_work;
        struct work_struct scan_work;
+       struct delayed_work fail_io_work;
+       struct work_struct stgt_delete_work;
+       struct work_struct rport_delete_work;
 } __attribute__((aligned(sizeof(unsigned long))));
 
+/* bit field values for struct fc_rport "flags" field: */
+#define FC_RPORT_DEVLOSS_PENDING       0x01
+#define FC_RPORT_SCAN_PENDING          0x02
+
 #define        dev_to_rport(d)                         \
        container_of(d, struct fc_rport, dev)
 #define transport_class_to_rport(classdev)     \
@@ -274,6 +286,30 @@ struct fc_host_statistics {
 };
 
 
+/*
+ * FC Event Codes - Polled and Async, following FC HBAAPI v2.0 guidelines
+ */
+
+/*
+ * fc_host_event_code: If you alter this, you also need to alter
+ * scsi_transport_fc.c (for the ascii descriptions).
+ */
+enum fc_host_event_code  {
+       FCH_EVT_LIP                     = 0x1,
+       FCH_EVT_LINKUP                  = 0x2,
+       FCH_EVT_LINKDOWN                = 0x3,
+       FCH_EVT_LIPRESET                = 0x4,
+       FCH_EVT_RSCN                    = 0x5,
+       FCH_EVT_ADAPTER_CHANGE          = 0x103,
+       FCH_EVT_PORT_UNKNOWN            = 0x200,
+       FCH_EVT_PORT_OFFLINE            = 0x201,
+       FCH_EVT_PORT_ONLINE             = 0x202,
+       FCH_EVT_PORT_FABRIC             = 0x204,
+       FCH_EVT_LINK_UNKNOWN            = 0x500,
+       FCH_EVT_VENDOR_UNIQUE           = 0xffff,
+};
+
+
 /*
  * FC Local Port (Host) Attributes
  *
@@ -300,9 +336,9 @@ struct fc_host_attrs {
        /* Fixed Attributes */
        u64 node_name;
        u64 port_name;
+       u64 permanent_port_name;
        u32 supported_classes;
        u8  supported_fc4s[FC_FC4_LIST_SIZE];
-       char symbolic_name[FC_SYMBOLIC_NAME_SIZE];
        u32 supported_speeds;
        u32 maxframe_size;
        char serial_number[FC_SERIAL_NUMBER_SIZE];
@@ -314,6 +350,8 @@ struct fc_host_attrs {
        u8  active_fc4s[FC_FC4_LIST_SIZE];
        u32 speed;
        u64 fabric_name;
+       char symbolic_name[FC_SYMBOLIC_NAME_SIZE];
+       char system_hostname[FC_SYMBOLIC_NAME_SIZE];
 
        /* Private (Transport-managed) Attributes */
        enum fc_tgtid_binding_type  tgtid_bind_type;
@@ -323,18 +361,27 @@ struct fc_host_attrs {
        struct list_head rport_bindings;
        u32 next_rport_number;
        u32 next_target_id;
+
+       /* work queues for rport state manipulation */
+       char work_q_name[KOBJ_NAME_LEN];
+       struct workqueue_struct *work_q;
+       char devloss_work_q_name[KOBJ_NAME_LEN];
+       struct workqueue_struct *devloss_work_q;
 };
 
+#define shost_to_fc_host(x) \
+       ((struct fc_host_attrs *)(x)->shost_data)
+
 #define fc_host_node_name(x) \
        (((struct fc_host_attrs *)(x)->shost_data)->node_name)
 #define fc_host_port_name(x)   \
        (((struct fc_host_attrs *)(x)->shost_data)->port_name)
+#define fc_host_permanent_port_name(x) \
+       (((struct fc_host_attrs *)(x)->shost_data)->permanent_port_name)
 #define fc_host_supported_classes(x)   \
        (((struct fc_host_attrs *)(x)->shost_data)->supported_classes)
 #define fc_host_supported_fc4s(x)      \
        (((struct fc_host_attrs *)(x)->shost_data)->supported_fc4s)
-#define fc_host_symbolic_name(x)       \
-       (((struct fc_host_attrs *)(x)->shost_data)->symbolic_name)
 #define fc_host_supported_speeds(x)    \
        (((struct fc_host_attrs *)(x)->shost_data)->supported_speeds)
 #define fc_host_maxframe_size(x)       \
@@ -353,6 +400,10 @@ struct fc_host_attrs {
        (((struct fc_host_attrs *)(x)->shost_data)->speed)
 #define fc_host_fabric_name(x) \
        (((struct fc_host_attrs *)(x)->shost_data)->fabric_name)
+#define fc_host_symbolic_name(x)       \
+       (((struct fc_host_attrs *)(x)->shost_data)->symbolic_name)
+#define fc_host_system_hostname(x)     \
+       (((struct fc_host_attrs *)(x)->shost_data)->system_hostname)
 #define fc_host_tgtid_bind_type(x) \
        (((struct fc_host_attrs *)(x)->shost_data)->tgtid_bind_type)
 #define fc_host_rports(x) \
@@ -363,6 +414,14 @@ struct fc_host_attrs {
        (((struct fc_host_attrs *)(x)->shost_data)->next_rport_number)
 #define fc_host_next_target_id(x) \
        (((struct fc_host_attrs *)(x)->shost_data)->next_target_id)
+#define fc_host_work_q_name(x) \
+       (((struct fc_host_attrs *)(x)->shost_data)->work_q_name)
+#define fc_host_work_q(x) \
+       (((struct fc_host_attrs *)(x)->shost_data)->work_q)
+#define fc_host_devloss_work_q_name(x) \
+       (((struct fc_host_attrs *)(x)->shost_data)->devloss_work_q_name)
+#define fc_host_devloss_work_q(x) \
+       (((struct fc_host_attrs *)(x)->shost_data)->devloss_work_q)
 
 
 /* The functions by which the transport class and the driver communicate */
@@ -380,10 +439,17 @@ struct fc_function_template {
        void    (*get_host_active_fc4s)(struct Scsi_Host *);
        void    (*get_host_speed)(struct Scsi_Host *);
        void    (*get_host_fabric_name)(struct Scsi_Host *);
+       void    (*get_host_symbolic_name)(struct Scsi_Host *);
+       void    (*set_host_system_hostname)(struct Scsi_Host *);
 
        struct fc_host_statistics * (*get_fc_host_stats)(struct Scsi_Host *);
        void    (*reset_fc_host_stats)(struct Scsi_Host *);
 
+       int     (*issue_fc_host_lip)(struct Scsi_Host *);
+
+       void    (*dev_loss_tmo_callbk)(struct fc_rport *);
+       void    (*terminate_rport_io)(struct fc_rport *);
+
        /* allocation lengths for host-specific data */
        u32                             dd_fcrport_size;
 
@@ -411,9 +477,9 @@ struct fc_function_template {
        /* host fixed attributes */
        unsigned long   show_host_node_name:1;
        unsigned long   show_host_port_name:1;
+       unsigned long   show_host_permanent_port_name:1;
        unsigned long   show_host_supported_classes:1;
        unsigned long   show_host_supported_fc4s:1;
-       unsigned long   show_host_symbolic_name:1;
        unsigned long   show_host_supported_speeds:1;
        unsigned long   show_host_maxframe_size:1;
        unsigned long   show_host_serial_number:1;
@@ -424,9 +490,63 @@ struct fc_function_template {
        unsigned long   show_host_active_fc4s:1;
        unsigned long   show_host_speed:1;
        unsigned long   show_host_fabric_name:1;
+       unsigned long   show_host_symbolic_name:1;
+       unsigned long   show_host_system_hostname:1;
 };
 
 
+/**
+ * fc_remote_port_chkready - called to validate the remote port state
+ *   prior to initiating io to the port.
+ *
+ * Returns a scsi result code that can be returned by the LLDD.
+ *
+ * @rport:     remote port to be checked
+ **/
+static inline int
+fc_remote_port_chkready(struct fc_rport *rport)
+{
+       int result;
+
+       switch (rport->port_state) {
+       case FC_PORTSTATE_ONLINE:
+               if (rport->roles & FC_RPORT_ROLE_FCP_TARGET)
+                       result = 0;
+               else if (rport->flags & FC_RPORT_DEVLOSS_PENDING)
+                       result = DID_IMM_RETRY << 16;
+               else
+                       result = DID_NO_CONNECT << 16;
+               break;
+       case FC_PORTSTATE_BLOCKED:
+               result = DID_IMM_RETRY << 16;
+               break;
+       default:
+               result = DID_NO_CONNECT << 16;
+               break;
+       }
+       return result;
+}
+
+static inline u64 wwn_to_u64(u8 *wwn)
+{
+       return (u64)wwn[0] << 56 | (u64)wwn[1] << 48 |
+           (u64)wwn[2] << 40 | (u64)wwn[3] << 32 |
+           (u64)wwn[4] << 24 | (u64)wwn[5] << 16 |
+           (u64)wwn[6] <<  8 | (u64)wwn[7];
+}
+
+static inline void u64_to_wwn(u64 inm, u8 *wwn)
+{
+       wwn[0] = (inm >> 56) & 0xff;
+       wwn[1] = (inm >> 48) & 0xff;
+       wwn[2] = (inm >> 40) & 0xff;
+       wwn[3] = (inm >> 32) & 0xff;
+       wwn[4] = (inm >> 24) & 0xff;
+       wwn[5] = (inm >> 16) & 0xff;
+       wwn[6] = (inm >> 8) & 0xff;
+       wwn[7] = inm & 0xff;
+}
+
 struct scsi_transport_template *fc_attach_transport(
                        struct fc_function_template *);
 void fc_release_transport(struct scsi_transport_template *);
@@ -435,8 +555,15 @@ struct fc_rport *fc_remote_port_add(struct Scsi_Host *shost,
                        int channel, struct fc_rport_identifiers  *ids);
 void fc_remote_port_delete(struct fc_rport  *rport);
 void fc_remote_port_rolechg(struct fc_rport  *rport, u32 roles);
-int fc_remote_port_block(struct fc_rport *rport);
-void fc_remote_port_unblock(struct fc_rport *rport);
 int scsi_is_fc_rport(const struct device *);
+u32 fc_get_event_number(void);
+void fc_host_post_event(struct Scsi_Host *shost, u32 event_number,
+               enum fc_host_event_code event_code, u32 event_data);
+void fc_host_post_vendor_event(struct Scsi_Host *shost, u32 event_number,
+               u32 data_len, char * data_buf, u64 vendor_id);
+       /* Note: when specifying vendor_id to fc_host_post_vendor_event()
+        *   be sure to read the Vendor Type and ID formatting requirements
+        *   specified in scsi_netlink.h
+        */
 
 #endif /* SCSI_TRANSPORT_FC_H */