0001
0002
0003
0004
0005
0006
0007 #ifndef _QEDI_ISCSI_H_
0008 #define _QEDI_ISCSI_H_
0009
0010 #include <linux/socket.h>
0011 #include <linux/completion.h>
0012 #include "qedi.h"
0013
0014 #define ISCSI_MAX_SESS_PER_HBA 4096
0015
0016 #define DEF_KA_TIMEOUT 7200000
0017 #define DEF_KA_INTERVAL 10000
0018 #define DEF_KA_MAX_PROBE_COUNT 10
0019 #define DEF_TOS 0
0020 #define DEF_TTL 0xfe
0021 #define DEF_SND_SEQ_SCALE 0
0022 #define DEF_RCV_BUF 0xffff
0023 #define DEF_SND_BUF 0xffff
0024 #define DEF_SEED 0
0025 #define DEF_MAX_RT_TIME 8000
0026 #define DEF_MAX_DA_COUNT 2
0027 #define DEF_SWS_TIMER 1000
0028 #define DEF_MAX_CWND 2
0029 #define DEF_PATH_MTU 1500
0030 #define DEF_MSS 1460
0031 #define DEF_LL2_MTU 1560
0032 #define JUMBO_MTU 9000
0033
0034 #define MIN_MTU 576
0035 #define IPV4_HDR_LEN 20
0036 #define IPV6_HDR_LEN 40
0037 #define TCP_HDR_LEN 20
0038 #define TCP_OPTION_LEN 12
0039 #define VLAN_LEN 4
0040
0041 enum {
0042 EP_STATE_IDLE = 0x0,
0043 EP_STATE_ACQRCONN_START = 0x1,
0044 EP_STATE_ACQRCONN_COMPL = 0x2,
0045 EP_STATE_OFLDCONN_START = 0x4,
0046 EP_STATE_OFLDCONN_COMPL = 0x8,
0047 EP_STATE_DISCONN_START = 0x10,
0048 EP_STATE_DISCONN_COMPL = 0x20,
0049 EP_STATE_CLEANUP_START = 0x40,
0050 EP_STATE_CLEANUP_CMPL = 0x80,
0051 EP_STATE_TCP_FIN_RCVD = 0x100,
0052 EP_STATE_TCP_RST_RCVD = 0x200,
0053 EP_STATE_LOGOUT_SENT = 0x400,
0054 EP_STATE_LOGOUT_RESP_RCVD = 0x800,
0055 EP_STATE_CLEANUP_FAILED = 0x1000,
0056 EP_STATE_OFLDCONN_FAILED = 0x2000,
0057 EP_STATE_CONNECT_FAILED = 0x4000,
0058 EP_STATE_DISCONN_TIMEDOUT = 0x8000,
0059 EP_STATE_OFLDCONN_NONE = 0x10000,
0060 };
0061
0062 struct qedi_conn;
0063
0064 struct qedi_endpoint {
0065 struct qedi_ctx *qedi;
0066 u32 dst_addr[4];
0067 u32 src_addr[4];
0068 u16 src_port;
0069 u16 dst_port;
0070 u16 vlan_id;
0071 u16 pmtu;
0072 u8 src_mac[ETH_ALEN];
0073 u8 dst_mac[ETH_ALEN];
0074 u8 ip_type;
0075 int state;
0076 wait_queue_head_t ofld_wait;
0077 wait_queue_head_t tcp_ofld_wait;
0078 u32 iscsi_cid;
0079
0080 u32 handle;
0081 u32 fw_cid;
0082 void __iomem *p_doorbell;
0083 struct iscsi_db_data db_data;
0084
0085
0086 struct iscsi_wqe *sq;
0087 dma_addr_t sq_dma;
0088
0089 u16 sq_prod_idx;
0090 u16 fw_sq_prod_idx;
0091 u16 sq_con_idx;
0092 u32 sq_mem_size;
0093
0094 void *sq_pbl;
0095 dma_addr_t sq_pbl_dma;
0096 u32 sq_pbl_size;
0097 struct qedi_conn *conn;
0098 struct work_struct offload_work;
0099 };
0100
0101 #define QEDI_SQ_WQES_MIN 16
0102
0103 struct qedi_io_bdt {
0104 struct scsi_sge *sge_tbl;
0105 dma_addr_t sge_tbl_dma;
0106 u16 sge_valid;
0107 };
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133 struct generic_pdu_resc {
0134 char *req_buf;
0135 dma_addr_t req_dma_addr;
0136 u32 req_buf_size;
0137 char *req_wr_ptr;
0138 struct iscsi_hdr resp_hdr;
0139 char *resp_buf;
0140 dma_addr_t resp_dma_addr;
0141 u32 resp_buf_size;
0142 char *resp_wr_ptr;
0143 char *req_bd_tbl;
0144 dma_addr_t req_bd_dma;
0145 char *resp_bd_tbl;
0146 dma_addr_t resp_bd_dma;
0147 };
0148
0149 struct qedi_conn {
0150 struct iscsi_cls_conn *cls_conn;
0151 struct qedi_ctx *qedi;
0152 struct qedi_endpoint *ep;
0153 struct iscsi_endpoint *iscsi_ep;
0154 struct list_head active_cmd_list;
0155 spinlock_t list_lock;
0156 u32 active_cmd_count;
0157 u32 cmd_cleanup_req;
0158 atomic_t cmd_cleanup_cmpl;
0159
0160 u32 iscsi_conn_id;
0161 int itt;
0162 int abrt_conn;
0163 #define QEDI_CID_RESERVED 0x5AFF
0164 u32 fw_cid;
0165
0166
0167
0168 struct generic_pdu_resc gen_pdu;
0169
0170 struct list_head tmf_work_list;
0171 wait_queue_head_t wait_queue;
0172 spinlock_t tmf_work_lock;
0173 bool ep_disconnect_starting;
0174 int fw_cleanup_works;
0175 };
0176
0177 struct qedi_cmd {
0178 struct list_head io_cmd;
0179 bool io_cmd_in_list;
0180 struct iscsi_hdr hdr;
0181 struct qedi_conn *conn;
0182 struct scsi_cmnd *scsi_cmd;
0183 struct scatterlist *sg;
0184 struct qedi_io_bdt io_tbl;
0185 struct iscsi_task_context request;
0186 unsigned char *sense_buffer;
0187 dma_addr_t sense_buffer_dma;
0188 u16 task_id;
0189
0190
0191 struct iscsi_task *task;
0192 struct work_struct tmf_work;
0193 int state;
0194 #define CLEANUP_WAIT 1
0195 #define CLEANUP_RECV 2
0196 #define CLEANUP_WAIT_FAILED 3
0197 #define CLEANUP_NOT_REQUIRED 4
0198 #define LUN_RESET_RESPONSE_RECEIVED 5
0199 #define RESPONSE_RECEIVED 6
0200
0201 int type;
0202 #define TYPEIO 1
0203 #define TYPERESET 2
0204
0205 struct qedi_work_map *list_tmf_work;
0206
0207 bool use_slowpath;
0208
0209 struct iscsi_tm_rsp *tmf_resp_buf;
0210 struct qedi_work cqe_work;
0211 };
0212
0213 struct qedi_work_map {
0214 struct list_head list;
0215 struct qedi_cmd *qedi_cmd;
0216 struct iscsi_task *ctask;
0217 int rtid;
0218
0219 int state;
0220 #define QEDI_WORK_QUEUED 1
0221 #define QEDI_WORK_SCHEDULED 2
0222 #define QEDI_WORK_EXIT 3
0223
0224 struct work_struct *ptr_tmf_work;
0225 };
0226
0227 struct qedi_boot_target {
0228 char ip_addr[64];
0229 char iscsi_name[255];
0230 u32 ipv6_en;
0231 };
0232
0233 #define qedi_set_itt(task_id, itt) ((u32)(((task_id) & 0xffff) | ((itt) << 16)))
0234 #define qedi_get_itt(cqe) (cqe.iscsi_hdr.cmd.itt >> 16)
0235
0236 #define QEDI_OFLD_WAIT_STATE(q) ((q)->state == EP_STATE_OFLDCONN_FAILED || \
0237 (q)->state == EP_STATE_OFLDCONN_COMPL)
0238
0239 #endif