serial: add ADDI-DATA GmbH Communication cardsin8250_pci.c and pci_ids.h
[safe/jmp/linux-2.6] / include / scsi / libiscsi.h
index 61e0692..889f51f 100644 (file)
@@ -48,9 +48,8 @@ struct iscsi_nopin;
 #define debug_scsi(fmt...)
 #endif
 
-#define ISCSI_XMIT_CMDS_MAX    128     /* must be power of 2 */
-#define ISCSI_MGMT_CMDS_MAX    32      /* must be power of 2 */
-#define ISCSI_CONN_MAX                 1
+#define ISCSI_DEF_XMIT_CMDS_MAX        128     /* must be power of 2 */
+#define ISCSI_MGMT_CMDS_MAX    16      /* must be power of 2 */
 
 #define ISCSI_MGMT_ITT_OFFSET  0xa00
 
@@ -58,11 +57,14 @@ struct iscsi_nopin;
 #define ISCSI_MAX_CMD_PER_LUN          128
 
 /* Task Mgmt states */
-#define TMABORT_INITIAL                        0x0
-#define TMABORT_SUCCESS                        0x1
-#define TMABORT_FAILED                 0x2
-#define TMABORT_TIMEDOUT               0x3
-#define TMABORT_NOT_FOUND              0x4
+enum {
+       TMF_INITIAL,
+       TMF_QUEUED,
+       TMF_SUCCESS,
+       TMF_FAILED,
+       TMF_TIMEDOUT,
+       TMF_NOT_FOUND,
+};
 
 /* Connection suspend "bit" */
 #define ISCSI_SUSPEND_BIT              1
@@ -73,6 +75,15 @@ struct iscsi_nopin;
 #define ISCSI_AGE_SHIFT                        28
 #define ISCSI_AGE_MASK                 (0xf << ISCSI_AGE_SHIFT)
 
+#define ISCSI_ADDRESS_BUF_LEN          64
+
+enum {
+       /* this is the maximum possible storage for AHSs */
+       ISCSI_MAX_AHS_SIZE = sizeof(struct iscsi_ecdb_ahdr) +
+                               sizeof(struct iscsi_rlength_ahdr),
+       ISCSI_DIGEST_SIZE = sizeof(__u32),
+};
+
 struct iscsi_mgmt_task {
        /*
         * Becuae LLDs allocate their hdr differently, this is a pointer to
@@ -80,7 +91,7 @@ struct iscsi_mgmt_task {
         */
        struct iscsi_hdr        *hdr;
        char                    *data;          /* mgmt payload */
-       int                     data_count;     /* counts data to be sent */
+       unsigned                data_count;     /* counts data to be sent */
        uint32_t                itt;            /* this ITT */
        void                    *dd_data;       /* driver/transport data */
        struct list_head        running;
@@ -94,22 +105,23 @@ enum {
 
 struct iscsi_cmd_task {
        /*
-        * Becuae LLDs allocate their hdr differently, this is a pointer to
-        * that storage. It must be setup at session creation time.
+        * Because LLDs allocate their hdr differently, this is a pointer
+        * and length to that storage. It must be setup at session
+        * creation time.
         */
        struct iscsi_cmd        *hdr;
+       unsigned short          hdr_max;
+       unsigned short          hdr_len;        /* accumulated size of hdr used */
        int                     itt;            /* this ITT */
 
        uint32_t                unsol_datasn;
-       int                     imm_count;      /* imm-data (bytes)   */
-       int                     unsol_count;    /* unsolicited (bytes)*/
+       unsigned                imm_count;      /* imm-data (bytes)   */
+       unsigned                unsol_count;    /* unsolicited (bytes)*/
        /* offset in unsolicited stream (bytes); */
-       int                     unsol_offset;
-       int                     data_count;     /* remaining Data-Out */
+       unsigned                unsol_offset;
+       unsigned                data_count;     /* remaining Data-Out */
        struct scsi_cmnd        *sc;            /* associated SCSI cmd*/
-       int                     total_length;
        struct iscsi_conn       *conn;          /* used connection    */
-       struct iscsi_mgmt_task  *mtask;         /* tmf mtask in progr */
 
        /* state set/tested under session->lock */
        int                     state;
@@ -118,6 +130,11 @@ struct iscsi_cmd_task {
        void                    *dd_data;       /* driver/transport data */
 };
 
+static inline void* iscsi_next_hdr(struct iscsi_cmd_task *ctask)
+{
+       return (void*)ctask->hdr + ctask->hdr_len;
+}
+
 struct iscsi_conn {
        struct iscsi_cls_conn   *cls_conn;      /* ptr to class connection */
        void                    *dd_data;       /* iscsi_transport data */
@@ -131,6 +148,12 @@ struct iscsi_conn {
         * conn_stop() flag: stop to recover, stop to terminate
         */
         int                    stop_stage;
+       struct timer_list       transport_timer;
+       unsigned long           last_recv;
+       unsigned long           last_ping;
+       int                     ping_timeout;
+       int                     recv_timeout;
+       struct iscsi_mgmt_task  *ping_mtask;
 
        /* iSCSI connection-wide sequencing */
        uint32_t                exp_statsn;
@@ -151,30 +174,24 @@ struct iscsi_conn {
        struct iscsi_cmd_task   *ctask;         /* xmit ctask in progress */
 
        /* xmit */
-       struct kfifo            *immqueue;      /* immediate xmit queue */
-       struct kfifo            *mgmtqueue;     /* mgmt (control) xmit queue */
+       struct list_head        mgmtqueue;      /* mgmt (control) xmit queue */
        struct list_head        mgmt_run_list;  /* list of control tasks */
        struct list_head        xmitqueue;      /* data-path cmd queue */
        struct list_head        run_list;       /* list of cmds in progress */
+       struct list_head        requeue;        /* tasks needing another run */
        struct work_struct      xmitwork;       /* per-conn. xmit workqueue */
-       /*
-        * serializes connection xmit, access to kfifos:
-        * xmitqueue, immqueue, mgmtqueue
-        */
-       struct mutex            xmitmutex;
-
        unsigned long           suspend_tx;     /* suspend Tx */
        unsigned long           suspend_rx;     /* suspend Rx */
 
        /* abort */
        wait_queue_head_t       ehwait;         /* used in eh_abort() */
        struct iscsi_tm         tmhdr;
-       struct timer_list       tmabort_timer;
-       int                     tmabort_state;  /* see TMABORT_INITIAL, etc.*/
+       struct timer_list       tmf_timer;
+       int                     tmf_state;      /* see TMF_INITIAL, etc.*/
 
        /* negotiated params */
-       int                     max_recv_dlength; /* initiator_max_recv_dsl*/
-       int                     max_xmit_dlength; /* target_max_recv_dsl */
+       unsigned                max_recv_dlength; /* initiator_max_recv_dsl*/
+       unsigned                max_xmit_dlength; /* target_max_recv_dsl */
        int                     hdrdgst_en;
        int                     datadgst_en;
        int                     ifmarker_en;
@@ -182,6 +199,12 @@ struct iscsi_conn {
        /* values userspace uses to id a conn */
        int                     persistent_port;
        char                    *persistent_address;
+       /* 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;
@@ -198,34 +221,52 @@ struct iscsi_conn {
        uint32_t                eh_abort_cnt;
 };
 
-struct iscsi_queue {
+struct iscsi_pool {
        struct kfifo            *queue;         /* FIFO Queue */
        void                    **pool;         /* Pool of elements */
        int                     max;            /* Max number of elements */
 };
 
 struct iscsi_session {
+       /*
+        * Syncs up the scsi eh thread with the iscsi eh thread when sending
+        * task management functions. This must be taken before the session
+        * and recv lock.
+        */
+       struct mutex            eh_mutex;
+
        /* iSCSI session-wide sequencing */
        uint32_t                cmdsn;
        uint32_t                exp_cmdsn;
        uint32_t                max_cmdsn;
 
+       /* This tracks the reqs queued into the initiator */
+       uint32_t                queued_cmdsn;
+
        /* configuration */
+       int                     abort_timeout;
+       int                     lu_reset_timeout;
        int                     initial_r2t_en;
-       int                     max_r2t;
+       unsigned                max_r2t;
        int                     imm_data_en;
-       int                     first_burst;
-       int                     max_burst;
+       unsigned                first_burst;
+       unsigned                max_burst;
        int                     time2wait;
        int                     time2retain;
        int                     pdu_inorder_en;
        int                     dataseq_inorder_en;
        int                     erl;
+       int                     fast_abort;
        int                     tpgt;
+       char                    *username;
+       char                    *username_in;
+       char                    *password;
+       char                    *password_in;
        char                    *targetname;
        char                    *initiatorname;
-       /* hw address being used for iscsi connection */
+       /* hw address or netdev iscsi connection is bound to */
        char                    *hwaddress;
+       char                    *netdev;
        /* control data */
        struct iscsi_transport  *tt;
        struct Scsi_Host        *host;
@@ -241,10 +282,10 @@ struct iscsi_session {
 
        int                     cmds_max;       /* size of cmds array */
        struct iscsi_cmd_task   **cmds;         /* Original Cmds arr */
-       struct iscsi_queue      cmdpool;        /* PDU's pool */
+       struct iscsi_pool       cmdpool;        /* PDU's pool */
        int                     mgmtpool_max;   /* size of mgmt array */
        struct iscsi_mgmt_task  **mgmt_cmds;    /* Original mgmt arr */
-       struct iscsi_queue      mgmtpool;       /* Mgmt PDU's pool */
+       struct iscsi_pool       mgmtpool;       /* Mgmt PDU's pool */
 };
 
 /*
@@ -253,6 +294,7 @@ struct iscsi_session {
 extern int iscsi_change_queue_depth(struct scsi_device *sdev, int depth);
 extern int iscsi_eh_abort(struct scsi_cmnd *sc);
 extern int iscsi_eh_host_reset(struct scsi_cmnd *sc);
+extern int iscsi_eh_device_reset(struct scsi_cmnd *sc);
 extern int iscsi_queuecommand(struct scsi_cmnd *sc,
                              void (*done)(struct scsi_cmnd *));
 
@@ -271,7 +313,7 @@ extern int iscsi_host_get_param(struct Scsi_Host *shost,
  */
 extern struct iscsi_cls_session *
 iscsi_session_setup(struct iscsi_transport *, struct scsi_transport_template *,
-                   int, int, uint32_t, uint32_t *);
+                   uint16_t, uint16_t, int, int, uint32_t, 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 *);
@@ -300,8 +342,7 @@ extern int iscsi_conn_get_param(struct iscsi_cls_conn *cls_conn,
 /*
  * pdu and task processing
  */
-extern int iscsi_check_assign_cmdsn(struct iscsi_session *,
-                                   struct iscsi_nopin *);
+extern void iscsi_update_cmdsn(struct iscsi_session *, struct iscsi_nopin *);
 extern void iscsi_prep_unsolicit_data_pdu(struct iscsi_cmd_task *,
                                        struct iscsi_data *hdr);
 extern int iscsi_conn_send_pdu(struct iscsi_cls_conn *, struct iscsi_hdr *,
@@ -312,11 +353,32 @@ 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);
+extern void iscsi_free_mgmt_task(struct iscsi_conn *conn,
+                                struct iscsi_mgmt_task *mtask);
 
 /*
  * generic helpers
  */
-extern void iscsi_pool_free(struct iscsi_queue *, void **);
-extern int iscsi_pool_init(struct iscsi_queue *, int, void ***, int);
+extern void iscsi_pool_free(struct iscsi_pool *);
+extern int iscsi_pool_init(struct iscsi_pool *, int, void ***, int);
+
+/*
+ * inline functions to deal with padding.
+ */
+static inline unsigned int
+iscsi_padded(unsigned int len)
+{
+       return (len + ISCSI_PAD_LEN - 1) & ~(ISCSI_PAD_LEN - 1);
+}
+
+static inline unsigned int
+iscsi_padding(unsigned int len)
+{
+       len &= (ISCSI_PAD_LEN - 1);
+       if (len)
+               len = ISCSI_PAD_LEN - len;
+       return len;
+}
 
 #endif