[SCSI] iser: fix handling of scsi cmnds during recovery.
[deliverable/linux.git] / include / scsi / libiscsi.h
index 889f51fabab9edae977c660de18e563a9f5c0982..f54aeb1e8ae359fba219c5c5c86f5ee81dc9ab24 100644 (file)
@@ -24,6 +24,7 @@
 #define LIBISCSI_H
 
 #include <linux/types.h>
+#include <linux/wait.h>
 #include <linux/mutex.h>
 #include <linux/timer.h>
 #include <linux/workqueue.h>
@@ -31,6 +32,7 @@
 #include <scsi/iscsi_if.h>
 
 struct scsi_transport_template;
+struct scsi_host_template;
 struct scsi_device;
 struct Scsi_Host;
 struct scsi_cmnd;
@@ -40,6 +42,7 @@ struct iscsi_cls_session;
 struct iscsi_cls_conn;
 struct iscsi_session;
 struct iscsi_nopin;
+struct device;
 
 /* #define DEBUG_SCSI */
 #ifdef DEBUG_SCSI
@@ -70,8 +73,6 @@ enum {
 #define ISCSI_SUSPEND_BIT              1
 
 #define ISCSI_ITT_MASK                 (0xfff)
-#define ISCSI_CID_SHIFT                        12
-#define ISCSI_CID_MASK                 (0xffff << ISCSI_CID_SHIFT)
 #define ISCSI_AGE_SHIFT                        28
 #define ISCSI_AGE_MASK                 (0xf << ISCSI_AGE_SHIFT)
 
@@ -135,6 +136,14 @@ static inline void* iscsi_next_hdr(struct iscsi_cmd_task *ctask)
        return (void*)ctask->hdr + ctask->hdr_len;
 }
 
+/* Connection's states */
+enum {
+       ISCSI_CONN_INITIAL_STAGE,
+       ISCSI_CONN_STARTED,
+       ISCSI_CONN_STOPPED,
+       ISCSI_CONN_CLEANUP_WAIT,
+};
+
 struct iscsi_conn {
        struct iscsi_cls_conn   *cls_conn;      /* ptr to class connection */
        void                    *dd_data;       /* iscsi_transport data */
@@ -202,9 +211,6 @@ struct iscsi_conn {
        /* remote portal currently connected to */
        int                     portal_port;
        char                    portal_address[ISCSI_ADDRESS_BUF_LEN];
-       /* local address */
-       int                     local_port;
-       char                    local_address[ISCSI_ADDRESS_BUF_LEN];
 
        /* MIB-statistics */
        uint64_t                txdata_octets;
@@ -219,6 +225,7 @@ struct iscsi_conn {
 
        /* custom statistics */
        uint32_t                eh_abort_cnt;
+       uint32_t                fmr_unalign_cnt;
 };
 
 struct iscsi_pool {
@@ -227,7 +234,19 @@ struct iscsi_pool {
        int                     max;            /* Max number of elements */
 };
 
+/* Session's states */
+enum {
+       ISCSI_STATE_FREE = 1,
+       ISCSI_STATE_LOGGED_IN,
+       ISCSI_STATE_FAILED,
+       ISCSI_STATE_TERMINATE,
+       ISCSI_STATE_IN_RECOVERY,
+       ISCSI_STATE_RECOVERY_FAILED,
+       ISCSI_STATE_LOGGING_OUT,
+};
+
 struct iscsi_session {
+       struct iscsi_cls_session *cls_session;
        /*
         * Syncs up the scsi eh thread with the iscsi eh thread when sending
         * task management functions. This must be taken before the session
@@ -263,10 +282,6 @@ struct iscsi_session {
        char                    *password;
        char                    *password_in;
        char                    *targetname;
-       char                    *initiatorname;
-       /* hw address or netdev iscsi connection is bound to */
-       char                    *hwaddress;
-       char                    *netdev;
        /* control data */
        struct iscsi_transport  *tt;
        struct Scsi_Host        *host;
@@ -288,6 +303,16 @@ struct iscsi_session {
        struct iscsi_pool       mgmtpool;       /* Mgmt PDU's pool */
 };
 
+struct iscsi_host {
+       char                    *initiatorname;
+       /* hw address or netdev iscsi connection is bound to */
+       char                    *hwaddress;
+       char                    *netdev;
+       /* local address */
+       int                     local_port;
+       char                    local_address[ISCSI_ADDRESS_BUF_LEN];
+};
+
 /*
  * scsi host template
  */
@@ -298,38 +323,44 @@ extern int iscsi_eh_device_reset(struct scsi_cmnd *sc);
 extern int iscsi_queuecommand(struct scsi_cmnd *sc,
                              void (*done)(struct scsi_cmnd *));
 
-
 /*
  * iSCSI host helpers.
  */
+#define iscsi_host_priv(_shost) \
+       (shost_priv(_shost) + sizeof(struct iscsi_host))
+
 extern int iscsi_host_set_param(struct Scsi_Host *shost,
                                enum iscsi_host_param param, char *buf,
                                int buflen);
 extern int iscsi_host_get_param(struct Scsi_Host *shost,
                                enum iscsi_host_param param, char *buf);
+extern int iscsi_host_add(struct Scsi_Host *shost, struct device *pdev);
+extern struct Scsi_Host *iscsi_host_alloc(struct scsi_host_template *sht,
+                                         int dd_data_size, uint16_t qdepth);
+extern void iscsi_host_remove(struct Scsi_Host *shost);
+extern void iscsi_host_free(struct Scsi_Host *shost);
 
 /*
  * session management
  */
 extern struct iscsi_cls_session *
-iscsi_session_setup(struct iscsi_transport *, struct scsi_transport_template *,
-                   uint16_t, uint16_t, int, int, uint32_t, uint32_t *);
+iscsi_session_setup(struct iscsi_transport *, struct Scsi_Host *shost,
+                   uint16_t, int, int, uint32_t);
 extern void iscsi_session_teardown(struct iscsi_cls_session *);
-extern struct iscsi_session *class_to_transport_session(struct iscsi_cls_session *);
 extern void iscsi_session_recovery_timedout(struct iscsi_cls_session *);
 extern int iscsi_set_param(struct iscsi_cls_conn *cls_conn,
                           enum iscsi_param param, char *buf, int buflen);
 extern int iscsi_session_get_param(struct iscsi_cls_session *cls_session,
                                   enum iscsi_param param, char *buf);
 
-#define session_to_cls(_sess) \
-       hostdata_session(_sess->host->hostdata)
+#define iscsi_session_printk(prefix, _sess, fmt, a...) \
+       iscsi_cls_session_printk(prefix, _sess->cls_session, fmt, ##a)
 
 /*
  * connection management
  */
 extern struct iscsi_cls_conn *iscsi_conn_setup(struct iscsi_cls_session *,
-                                              uint32_t);
+                                              int, uint32_t);
 extern void iscsi_conn_teardown(struct iscsi_cls_conn *);
 extern int iscsi_conn_start(struct iscsi_cls_conn *);
 extern void iscsi_conn_stop(struct iscsi_cls_conn *, int);
@@ -338,6 +369,11 @@ extern int iscsi_conn_bind(struct iscsi_cls_session *, struct iscsi_cls_conn *,
 extern void iscsi_conn_failure(struct iscsi_conn *conn, enum iscsi_err err);
 extern int iscsi_conn_get_param(struct iscsi_cls_conn *cls_conn,
                                enum iscsi_param param, char *buf);
+extern void iscsi_suspend_tx(struct iscsi_conn *conn);
+
+#define iscsi_conn_printk(prefix, _c, fmt, a...) \
+       iscsi_cls_conn_printk(prefix, ((struct iscsi_conn *)_c)->cls_conn, \
+                             fmt, ##a)
 
 /*
  * pdu and task processing
@@ -349,8 +385,6 @@ extern int iscsi_conn_send_pdu(struct iscsi_cls_conn *, struct iscsi_hdr *,
                                char *, uint32_t);
 extern int iscsi_complete_pdu(struct iscsi_conn *, struct iscsi_hdr *,
                              char *, int);
-extern int __iscsi_complete_pdu(struct iscsi_conn *, struct iscsi_hdr *,
-                               char *, int);
 extern int iscsi_verify_itt(struct iscsi_conn *, struct iscsi_hdr *,
                            uint32_t *);
 extern void iscsi_requeue_ctask(struct iscsi_cmd_task *ctask);
This page took 0.02778 seconds and 5 git commands to generate.