1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * QLogic iSCSI Offload Driver
4 * Copyright (c) 2016 Cavium Inc.
10 #include <linux/socket.h>
11 #include <linux/completion.h>
14 #define ISCSI_MAX_SESS_PER_HBA 4096
16 #define DEF_KA_TIMEOUT 7200000
17 #define DEF_KA_INTERVAL 10000
18 #define DEF_KA_MAX_PROBE_COUNT 10
21 #define DEF_SND_SEQ_SCALE 0
22 #define DEF_RCV_BUF 0xffff
23 #define DEF_SND_BUF 0xffff
25 #define DEF_MAX_RT_TIME 8000
26 #define DEF_MAX_DA_COUNT 2
27 #define DEF_SWS_TIMER 1000
28 #define DEF_MAX_CWND 2
29 #define DEF_PATH_MTU 1500
31 #define DEF_LL2_MTU 1560
32 #define JUMBO_MTU 9000
34 #define MIN_MTU 576 /* rfc 793 */
35 #define IPV4_HDR_LEN 20
36 #define IPV6_HDR_LEN 40
37 #define TCP_HDR_LEN 20
38 #define TCP_OPTION_LEN 12
43 EP_STATE_ACQRCONN_START
= 0x1,
44 EP_STATE_ACQRCONN_COMPL
= 0x2,
45 EP_STATE_OFLDCONN_START
= 0x4,
46 EP_STATE_OFLDCONN_COMPL
= 0x8,
47 EP_STATE_DISCONN_START
= 0x10,
48 EP_STATE_DISCONN_COMPL
= 0x20,
49 EP_STATE_CLEANUP_START
= 0x40,
50 EP_STATE_CLEANUP_CMPL
= 0x80,
51 EP_STATE_TCP_FIN_RCVD
= 0x100,
52 EP_STATE_TCP_RST_RCVD
= 0x200,
53 EP_STATE_LOGOUT_SENT
= 0x400,
54 EP_STATE_LOGOUT_RESP_RCVD
= 0x800,
55 EP_STATE_CLEANUP_FAILED
= 0x1000,
56 EP_STATE_OFLDCONN_FAILED
= 0x2000,
57 EP_STATE_CONNECT_FAILED
= 0x4000,
58 EP_STATE_DISCONN_TIMEDOUT
= 0x8000,
59 EP_STATE_OFLDCONN_NONE
= 0x10000,
64 struct qedi_endpoint
{
65 struct qedi_ctx
*qedi
;
76 wait_queue_head_t ofld_wait
;
77 wait_queue_head_t tcp_ofld_wait
;
79 /* identifier of the connection from qed */
82 void __iomem
*p_doorbell
;
83 struct iscsi_db_data db_data
;
85 /* Send queue management */
95 dma_addr_t sq_pbl_dma
;
97 struct qedi_conn
*conn
;
98 struct work_struct offload_work
;
101 #define QEDI_SQ_WQES_MIN 16
104 struct scsi_sge
*sge_tbl
;
105 dma_addr_t sge_tbl_dma
;
110 * struct generic_pdu_resc - login pdu resource structure
112 * @req_buf: driver buffer used to stage payload associated with
114 * @req_dma_addr: dma address for iscsi login request payload buffer
115 * @req_buf_size: actual login request payload length
116 * @req_wr_ptr: pointer into login request buffer when next data is
118 * @resp_hdr: iscsi header where iscsi login response header is to
120 * @resp_buf: buffer to stage login response payload
121 * @resp_dma_addr: login response payload buffer dma address
122 * @resp_buf_size: login response paylod length
123 * @resp_wr_ptr: pointer into login response buffer when next data is
125 * @req_bd_tbl: iscsi login request payload BD table
126 * @req_bd_dma: login request BD table dma address
127 * @resp_bd_tbl: iscsi login response payload BD table
128 * @resp_bd_dma: login request BD table dma address
130 * following structure defines buffer info for generic pdus such as iSCSI Login,
133 struct generic_pdu_resc
{
135 dma_addr_t req_dma_addr
;
138 struct iscsi_hdr resp_hdr
;
140 dma_addr_t resp_dma_addr
;
144 dma_addr_t req_bd_dma
;
146 dma_addr_t resp_bd_dma
;
150 struct iscsi_cls_conn
*cls_conn
;
151 struct qedi_ctx
*qedi
;
152 struct qedi_endpoint
*ep
;
153 struct iscsi_endpoint
*iscsi_ep
;
154 struct list_head active_cmd_list
;
155 spinlock_t list_lock
; /* internal conn lock */
156 u32 active_cmd_count
;
158 atomic_t cmd_cleanup_cmpl
;
163 #define QEDI_CID_RESERVED 0x5AFF
166 * Buffer for login negotiation process
168 struct generic_pdu_resc gen_pdu
;
170 struct list_head tmf_work_list
;
171 wait_queue_head_t wait_queue
;
172 spinlock_t tmf_work_lock
; /* tmf work lock */
173 bool ep_disconnect_starting
;
174 int fw_cleanup_works
;
178 struct list_head io_cmd
;
180 struct iscsi_hdr hdr
;
181 struct qedi_conn
*conn
;
182 struct scsi_cmnd
*scsi_cmd
;
183 struct scatterlist
*sg
;
184 struct qedi_io_bdt io_tbl
;
185 struct iscsi_task_context request
;
186 unsigned char *sense_buffer
;
187 dma_addr_t sense_buffer_dma
;
190 /* field populated for tmf work queue */
191 struct iscsi_task
*task
;
192 struct work_struct tmf_work
;
194 #define CLEANUP_WAIT 1
195 #define CLEANUP_RECV 2
196 #define CLEANUP_WAIT_FAILED 3
197 #define CLEANUP_NOT_REQUIRED 4
198 #define LUN_RESET_RESPONSE_RECEIVED 5
199 #define RESPONSE_RECEIVED 6
205 struct qedi_work_map
*list_tmf_work
;
206 /* slowpath management */
209 struct iscsi_tm_rsp
*tmf_resp_buf
;
210 struct qedi_work cqe_work
;
213 struct qedi_work_map
{
214 struct list_head list
;
215 struct qedi_cmd
*qedi_cmd
;
216 struct iscsi_task
*ctask
;
220 #define QEDI_WORK_QUEUED 1
221 #define QEDI_WORK_SCHEDULED 2
222 #define QEDI_WORK_EXIT 3
224 struct work_struct
*ptr_tmf_work
;
227 struct qedi_boot_target
{
229 char iscsi_name
[255];
233 #define qedi_set_itt(task_id, itt) ((u32)(((task_id) & 0xffff) | ((itt) << 16)))
234 #define qedi_get_itt(cqe) (cqe.iscsi_hdr.cmd.itt >> 16)
236 #define QEDI_OFLD_WAIT_STATE(q) ((q)->state == EP_STATE_OFLDCONN_FAILED || \
237 (q)->state == EP_STATE_OFLDCONN_COMPL)
239 #endif /* _QEDI_ISCSI_H_ */