1
2
3
4
5
6
7
8
9
10#ifndef _QEDI_ISCSI_H_
11#define _QEDI_ISCSI_H_
12
13#include <linux/socket.h>
14#include <linux/completion.h>
15#include "qedi.h"
16
17#define ISCSI_MAX_SESS_PER_HBA 4096
18
19#define DEF_KA_TIMEOUT 7200000
20#define DEF_KA_INTERVAL 10000
21#define DEF_KA_MAX_PROBE_COUNT 10
22#define DEF_TOS 0
23#define DEF_TTL 0xfe
24#define DEF_SND_SEQ_SCALE 0
25#define DEF_RCV_BUF 0xffff
26#define DEF_SND_BUF 0xffff
27#define DEF_SEED 0
28#define DEF_MAX_RT_TIME 8000
29#define DEF_MAX_DA_COUNT 2
30#define DEF_SWS_TIMER 1000
31#define DEF_MAX_CWND 2
32#define DEF_PATH_MTU 1500
33#define DEF_MSS 1460
34#define DEF_LL2_MTU 1560
35#define JUMBO_MTU 9000
36
37#define MIN_MTU 576
38#define IPV4_HDR_LEN 20
39#define IPV6_HDR_LEN 40
40#define TCP_HDR_LEN 20
41#define TCP_OPTION_LEN 12
42#define VLAN_LEN 4
43
44enum {
45 EP_STATE_IDLE = 0x0,
46 EP_STATE_ACQRCONN_START = 0x1,
47 EP_STATE_ACQRCONN_COMPL = 0x2,
48 EP_STATE_OFLDCONN_START = 0x4,
49 EP_STATE_OFLDCONN_COMPL = 0x8,
50 EP_STATE_DISCONN_START = 0x10,
51 EP_STATE_DISCONN_COMPL = 0x20,
52 EP_STATE_CLEANUP_START = 0x40,
53 EP_STATE_CLEANUP_CMPL = 0x80,
54 EP_STATE_TCP_FIN_RCVD = 0x100,
55 EP_STATE_TCP_RST_RCVD = 0x200,
56 EP_STATE_LOGOUT_SENT = 0x400,
57 EP_STATE_LOGOUT_RESP_RCVD = 0x800,
58 EP_STATE_CLEANUP_FAILED = 0x1000,
59 EP_STATE_OFLDCONN_FAILED = 0x2000,
60 EP_STATE_CONNECT_FAILED = 0x4000,
61 EP_STATE_DISCONN_TIMEDOUT = 0x8000,
62 EP_STATE_OFLDCONN_NONE = 0x10000,
63};
64
65struct qedi_conn;
66
67struct qedi_endpoint {
68 struct qedi_ctx *qedi;
69 u32 dst_addr[4];
70 u32 src_addr[4];
71 u16 src_port;
72 u16 dst_port;
73 u16 vlan_id;
74 u16 pmtu;
75 u8 src_mac[ETH_ALEN];
76 u8 dst_mac[ETH_ALEN];
77 u8 ip_type;
78 int state;
79 wait_queue_head_t ofld_wait;
80 wait_queue_head_t tcp_ofld_wait;
81 u32 iscsi_cid;
82
83 u32 handle;
84 u32 fw_cid;
85 void __iomem *p_doorbell;
86
87
88 struct iscsi_wqe *sq;
89 dma_addr_t sq_dma;
90
91 u16 sq_prod_idx;
92 u16 fw_sq_prod_idx;
93 u16 sq_con_idx;
94 u32 sq_mem_size;
95
96 void *sq_pbl;
97 dma_addr_t sq_pbl_dma;
98 u32 sq_pbl_size;
99 struct qedi_conn *conn;
100 struct work_struct offload_work;
101};
102
103#define QEDI_SQ_WQES_MIN 16
104
105struct qedi_io_bdt {
106 struct scsi_sge *sge_tbl;
107 dma_addr_t sge_tbl_dma;
108 u16 sge_valid;
109};
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135struct generic_pdu_resc {
136 char *req_buf;
137 dma_addr_t req_dma_addr;
138 u32 req_buf_size;
139 char *req_wr_ptr;
140 struct iscsi_hdr resp_hdr;
141 char *resp_buf;
142 dma_addr_t resp_dma_addr;
143 u32 resp_buf_size;
144 char *resp_wr_ptr;
145 char *req_bd_tbl;
146 dma_addr_t req_bd_dma;
147 char *resp_bd_tbl;
148 dma_addr_t resp_bd_dma;
149};
150
151struct qedi_conn {
152 struct iscsi_cls_conn *cls_conn;
153 struct qedi_ctx *qedi;
154 struct qedi_endpoint *ep;
155 struct iscsi_endpoint *iscsi_ep;
156 struct list_head active_cmd_list;
157 spinlock_t list_lock;
158 u32 active_cmd_count;
159 u32 cmd_cleanup_req;
160 u32 cmd_cleanup_cmpl;
161
162 u32 iscsi_conn_id;
163 int itt;
164 int abrt_conn;
165#define QEDI_CID_RESERVED 0x5AFF
166 u32 fw_cid;
167
168
169
170 struct generic_pdu_resc gen_pdu;
171
172 struct list_head tmf_work_list;
173 wait_queue_head_t wait_queue;
174 spinlock_t tmf_work_lock;
175 unsigned long flags;
176#define QEDI_CONN_FW_CLEANUP 1
177};
178
179struct qedi_cmd {
180 struct list_head io_cmd;
181 bool io_cmd_in_list;
182 struct iscsi_hdr hdr;
183 struct qedi_conn *conn;
184 struct scsi_cmnd *scsi_cmd;
185 struct scatterlist *sg;
186 struct qedi_io_bdt io_tbl;
187 struct e4_iscsi_task_context request;
188 unsigned char *sense_buffer;
189 dma_addr_t sense_buffer_dma;
190 u16 task_id;
191
192
193 struct iscsi_task *task;
194 struct work_struct tmf_work;
195 int state;
196#define CLEANUP_WAIT 1
197#define CLEANUP_RECV 2
198#define CLEANUP_WAIT_FAILED 3
199#define CLEANUP_NOT_REQUIRED 4
200#define LUN_RESET_RESPONSE_RECEIVED 5
201#define RESPONSE_RECEIVED 6
202
203 int type;
204#define TYPEIO 1
205#define TYPERESET 2
206
207 struct qedi_work_map *list_tmf_work;
208
209 bool use_slowpath;
210
211 struct iscsi_tm_rsp *tmf_resp_buf;
212 struct qedi_work cqe_work;
213};
214
215struct qedi_work_map {
216 struct list_head list;
217 struct qedi_cmd *qedi_cmd;
218 int rtid;
219
220 int state;
221#define QEDI_WORK_QUEUED 1
222#define QEDI_WORK_SCHEDULED 2
223#define QEDI_WORK_EXIT 3
224
225 struct work_struct *ptr_tmf_work;
226};
227
228struct qedi_boot_target {
229 char ip_addr[64];
230 char iscsi_name[255];
231 u32 ipv6_en;
232};
233
234#define qedi_set_itt(task_id, itt) ((u32)(((task_id) & 0xffff) | ((itt) << 16)))
235#define qedi_get_itt(cqe) (cqe.iscsi_hdr.cmd.itt >> 16)
236
237#define QEDI_OFLD_WAIT_STATE(q) ((q)->state == EP_STATE_OFLDCONN_FAILED || \
238 (q)->state == EP_STATE_OFLDCONN_COMPL)
239
240#endif
241