blob: 7faef80c5f7a4d9e9081bf1490f8e848c69ee16b [file] [log] [blame]
Dupuis, Chad61d86582017-02-15 06:28:23 -08001/*
2 * QLogic FCoE Offload Driver
Chad Dupuis12d0b122017-05-31 06:33:49 -07003 * Copyright (c) 2016-2017 Cavium Inc.
Dupuis, Chad61d86582017-02-15 06:28:23 -08004 *
5 * This software is available under the terms of the GNU General Public License
6 * (GPL) Version 2, available from the file COPYING in the main directory of
7 * this source tree.
8 */
9#ifndef __QEDF_HSI__
10#define __QEDF_HSI__
11/*
12 * Add include to common target
13 */
14#include <linux/qed/common_hsi.h>
15
16/*
17 * Add include to common storage target
18 */
19#include <linux/qed/storage_common.h>
20
21/*
22 * Add include to common fcoe target for both eCore and protocol driver
23 */
24#include <linux/qed/fcoe_common.h>
25
26
27/*
28 * FCoE CQ element ABTS information
29 */
30struct fcoe_abts_info {
31 u8 r_ctl /* R_CTL in the ABTS response frame */;
32 u8 reserved0;
33 __le16 rx_id;
34 __le32 reserved2[2];
35 __le32 fc_payload[3] /* ABTS FC payload response frame */;
36};
37
38
39/*
40 * FCoE class type
41 */
42enum fcoe_class_type {
43 FCOE_TASK_CLASS_TYPE_3,
44 FCOE_TASK_CLASS_TYPE_2,
45 MAX_FCOE_CLASS_TYPE
46};
47
48
49/*
50 * FCoE CMDQ element control information
51 */
52struct fcoe_cmdqe_control {
53 __le16 conn_id;
54 u8 num_additional_cmdqes;
55 u8 cmdType;
56 /* true for ABTS request cmdqe. used in Target mode */
57#define FCOE_CMDQE_CONTROL_ABTSREQCMD_MASK 0x1
58#define FCOE_CMDQE_CONTROL_ABTSREQCMD_SHIFT 0
59#define FCOE_CMDQE_CONTROL_RESERVED1_MASK 0x7F
60#define FCOE_CMDQE_CONTROL_RESERVED1_SHIFT 1
61 u8 reserved2[4];
62};
63
64/*
65 * FCoE control + payload CMDQ element
66 */
67struct fcoe_cmdqe {
68 struct fcoe_cmdqe_control hdr;
69 u8 fc_header[24];
70 __le32 fcp_cmd_payload[8];
71};
72
73
74
75/*
76 * FCP RSP flags
77 */
78struct fcoe_fcp_rsp_flags {
79 u8 flags;
80#define FCOE_FCP_RSP_FLAGS_FCP_RSP_LEN_VALID_MASK 0x1
81#define FCOE_FCP_RSP_FLAGS_FCP_RSP_LEN_VALID_SHIFT 0
82#define FCOE_FCP_RSP_FLAGS_FCP_SNS_LEN_VALID_MASK 0x1
83#define FCOE_FCP_RSP_FLAGS_FCP_SNS_LEN_VALID_SHIFT 1
84#define FCOE_FCP_RSP_FLAGS_FCP_RESID_OVER_MASK 0x1
85#define FCOE_FCP_RSP_FLAGS_FCP_RESID_OVER_SHIFT 2
86#define FCOE_FCP_RSP_FLAGS_FCP_RESID_UNDER_MASK 0x1
87#define FCOE_FCP_RSP_FLAGS_FCP_RESID_UNDER_SHIFT 3
88#define FCOE_FCP_RSP_FLAGS_FCP_CONF_REQ_MASK 0x1
89#define FCOE_FCP_RSP_FLAGS_FCP_CONF_REQ_SHIFT 4
90#define FCOE_FCP_RSP_FLAGS_FCP_BIDI_FLAGS_MASK 0x7
91#define FCOE_FCP_RSP_FLAGS_FCP_BIDI_FLAGS_SHIFT 5
92};
93
94/*
95 * FCoE CQ element response information
96 */
97struct fcoe_cqe_rsp_info {
98 struct fcoe_fcp_rsp_flags rsp_flags;
99 u8 scsi_status_code;
100 __le16 retry_delay_timer;
101 __le32 fcp_resid;
102 __le32 fcp_sns_len;
103 __le32 fcp_rsp_len;
104 __le16 rx_id;
105 u8 fw_error_flags;
106#define FCOE_CQE_RSP_INFO_FW_UNDERRUN_MASK 0x1 /* FW detected underrun */
107#define FCOE_CQE_RSP_INFO_FW_UNDERRUN_SHIFT 0
108#define FCOE_CQE_RSP_INFO_RESREVED_MASK 0x7F
109#define FCOE_CQE_RSP_INFO_RESREVED_SHIFT 1
110 u8 reserved;
111 __le32 fw_residual /* Residual bytes calculated by FW */;
112};
113
114/*
115 * FCoE CQ element Target completion information
116 */
117struct fcoe_cqe_target_info {
118 __le16 rx_id;
119 __le16 reserved0;
120 __le32 reserved1[5];
121};
122
123/*
124 * FCoE error/warning reporting entry
125 */
126struct fcoe_err_report_entry {
127 __le32 err_warn_bitmap_lo /* Error bitmap lower 32 bits */;
128 __le32 err_warn_bitmap_hi /* Error bitmap higher 32 bits */;
129 /* Buffer offset the beginning of the Sequence last transmitted */
130 __le32 tx_buf_off;
131 /* Buffer offset from the beginning of the Sequence last received */
132 __le32 rx_buf_off;
133 __le16 rx_id /* RX_ID of the associated task */;
134 __le16 reserved1;
135 __le32 reserved2;
136};
137
138/*
139 * FCoE CQ element middle path information
140 */
141struct fcoe_cqe_midpath_info {
142 __le32 data_placement_size;
143 __le16 rx_id;
144 __le16 reserved0;
145 __le32 reserved1[4];
146};
147
148/*
149 * FCoE CQ element unsolicited information
150 */
151struct fcoe_unsolic_info {
152 /* BD information: Physical address and opaque data */
153 struct scsi_bd bd_info;
154 __le16 conn_id /* Connection ID the frame is associated to */;
155 __le16 pkt_len /* Packet length */;
156 u8 reserved1[4];
157};
158
159/*
160 * FCoE warning reporting entry
161 */
162struct fcoe_warning_report_entry {
163 /* BD information: Physical address and opaque data */
164 struct scsi_bd bd_info;
165 /* Buffer offset the beginning of the Sequence last transmitted */
166 __le32 buf_off;
167 __le16 rx_id /* RX_ID of the associated task */;
168 __le16 reserved1;
169};
170
171/*
172 * FCoE CQ element information
173 */
174union fcoe_cqe_info {
175 struct fcoe_cqe_rsp_info rsp_info /* Response completion information */;
176 /* Target completion information */
177 struct fcoe_cqe_target_info target_info;
178 /* Error completion information */
179 struct fcoe_err_report_entry err_info;
180 struct fcoe_abts_info abts_info /* ABTS completion information */;
181 /* Middle path completion information */
182 struct fcoe_cqe_midpath_info midpath_info;
183 /* Unsolicited packet completion information */
184 struct fcoe_unsolic_info unsolic_info;
185 /* Warning completion information (Rec Tov expiration) */
186 struct fcoe_warning_report_entry warn_info;
187};
188
189/*
190 * FCoE CQ element
191 */
192struct fcoe_cqe {
193 __le32 cqe_data;
194 /* The task identifier (OX_ID) to be completed */
195#define FCOE_CQE_TASK_ID_MASK 0xFFFF
196#define FCOE_CQE_TASK_ID_SHIFT 0
197 /*
198 * The CQE type: 0x0 Indicating on a pending work request completion.
199 * 0x1 - Indicating on an unsolicited event notification. use enum
200 * fcoe_cqe_type (use enum fcoe_cqe_type)
201 */
202#define FCOE_CQE_CQE_TYPE_MASK 0xF
203#define FCOE_CQE_CQE_TYPE_SHIFT 16
204#define FCOE_CQE_RESERVED0_MASK 0xFFF
205#define FCOE_CQE_RESERVED0_SHIFT 20
206 __le16 reserved1;
207 __le16 fw_cq_prod;
208 union fcoe_cqe_info cqe_info;
209};
210
211/*
212 * FCoE CQE type
213 */
214enum fcoe_cqe_type {
215 /* solicited response on a R/W or middle-path SQE */
216 FCOE_GOOD_COMPLETION_CQE_TYPE,
217 FCOE_UNSOLIC_CQE_TYPE /* unsolicited packet, RQ consumed */,
218 FCOE_ERROR_DETECTION_CQE_TYPE /* timer expiration, validation error */,
219 FCOE_WARNING_CQE_TYPE /* rec_tov or rr_tov timer expiration */,
220 FCOE_EXCH_CLEANUP_CQE_TYPE /* task cleanup completed */,
221 FCOE_ABTS_CQE_TYPE /* ABTS received and task cleaned */,
222 FCOE_DUMMY_CQE_TYPE /* just increment SQ CONS */,
223 /* Task was completed wight after sending a pkt to the target */
224 FCOE_LOCAL_COMP_CQE_TYPE,
225 MAX_FCOE_CQE_TYPE
226};
227
228
229/*
230 * FCoE device type
231 */
232enum fcoe_device_type {
233 FCOE_TASK_DEV_TYPE_DISK,
234 FCOE_TASK_DEV_TYPE_TAPE,
235 MAX_FCOE_DEVICE_TYPE
236};
237
238
239
240
241/*
242 * FCoE fast path error codes
243 */
244enum fcoe_fp_error_warning_code {
245 FCOE_ERROR_CODE_XFER_OOO_RO /* XFER error codes */,
246 FCOE_ERROR_CODE_XFER_RO_NOT_ALIGNED,
247 FCOE_ERROR_CODE_XFER_NULL_BURST_LEN,
248 FCOE_ERROR_CODE_XFER_RO_GREATER_THAN_DATA2TRNS,
249 FCOE_ERROR_CODE_XFER_INVALID_PAYLOAD_SIZE,
250 FCOE_ERROR_CODE_XFER_TASK_TYPE_NOT_WRITE,
251 FCOE_ERROR_CODE_XFER_PEND_XFER_SET,
252 FCOE_ERROR_CODE_XFER_OPENED_SEQ,
253 FCOE_ERROR_CODE_XFER_FCTL,
254 FCOE_ERROR_CODE_FCP_RSP_BIDI_FLAGS_SET /* FCP RSP error codes */,
255 FCOE_ERROR_CODE_FCP_RSP_INVALID_LENGTH_FIELD,
256 FCOE_ERROR_CODE_FCP_RSP_INVALID_SNS_FIELD,
257 FCOE_ERROR_CODE_FCP_RSP_INVALID_PAYLOAD_SIZE,
258 FCOE_ERROR_CODE_FCP_RSP_PEND_XFER_SET,
259 FCOE_ERROR_CODE_FCP_RSP_OPENED_SEQ,
260 FCOE_ERROR_CODE_FCP_RSP_FCTL,
261 FCOE_ERROR_CODE_FCP_RSP_LAST_SEQ_RESET,
262 FCOE_ERROR_CODE_FCP_RSP_CONF_REQ_NOT_SUPPORTED_YET,
263 FCOE_ERROR_CODE_DATA_OOO_RO /* FCP DATA error codes */,
264 FCOE_ERROR_CODE_DATA_EXCEEDS_DEFINED_MAX_FRAME_SIZE,
265 FCOE_ERROR_CODE_DATA_EXCEEDS_DATA2TRNS,
266 FCOE_ERROR_CODE_DATA_SOFI3_SEQ_ACTIVE_SET,
267 FCOE_ERROR_CODE_DATA_SOFN_SEQ_ACTIVE_RESET,
268 FCOE_ERROR_CODE_DATA_EOFN_END_SEQ_SET,
269 FCOE_ERROR_CODE_DATA_EOFT_END_SEQ_RESET,
270 FCOE_ERROR_CODE_DATA_TASK_TYPE_NOT_READ,
271 FCOE_ERROR_CODE_DATA_FCTL_INITIATIR,
272 FCOE_ERROR_CODE_MIDPATH_INVALID_TYPE /* Middle path error codes */,
273 FCOE_ERROR_CODE_MIDPATH_SOFI3_SEQ_ACTIVE_SET,
274 FCOE_ERROR_CODE_MIDPATH_SOFN_SEQ_ACTIVE_RESET,
275 FCOE_ERROR_CODE_MIDPATH_EOFN_END_SEQ_SET,
276 FCOE_ERROR_CODE_MIDPATH_EOFT_END_SEQ_RESET,
277 FCOE_ERROR_CODE_MIDPATH_REPLY_FCTL,
278 FCOE_ERROR_CODE_MIDPATH_INVALID_REPLY,
279 FCOE_ERROR_CODE_MIDPATH_ELS_REPLY_RCTL,
280 FCOE_ERROR_CODE_COMMON_MIDDLE_FRAME_WITH_PAD /* Common error codes */,
281 FCOE_ERROR_CODE_COMMON_SEQ_INIT_IN_TCE,
282 FCOE_ERROR_CODE_COMMON_FC_HDR_RX_ID_MISMATCH,
283 FCOE_ERROR_CODE_COMMON_INCORRECT_SEQ_CNT,
284 FCOE_ERROR_CODE_COMMON_DATA_FC_HDR_FCP_TYPE_MISMATCH,
285 FCOE_ERROR_CODE_COMMON_DATA_NO_MORE_SGES,
286 FCOE_ERROR_CODE_COMMON_OPTIONAL_FC_HDR,
287 FCOE_ERROR_CODE_COMMON_READ_TCE_OX_ID_TOO_BIG,
288 FCOE_ERROR_CODE_COMMON_DATA_WAS_NOT_TRANSMITTED,
289 FCOE_ERROR_CODE_COMMON_TASK_DDF_RCTL_INFO_FIELD,
290 FCOE_ERROR_CODE_COMMON_TASK_INVALID_RCTL,
291 FCOE_ERROR_CODE_COMMON_TASK_RCTL_GENERAL_MISMATCH,
292 FCOE_ERROR_CODE_E_D_TOV_TIMER_EXPIRATION /* Timer error codes */,
293 FCOE_WARNING_CODE_REC_TOV_TIMER_EXPIRATION /* Timer error codes */,
294 FCOE_ERROR_CODE_RR_TOV_TIMER_EXPIRATION /* Timer error codes */,
295 /* ABTSrsp pckt arrived unexpected */
296 FCOE_ERROR_CODE_ABTS_REPLY_UNEXPECTED,
297 FCOE_ERROR_CODE_TARGET_MODE_FCP_RSP,
298 FCOE_ERROR_CODE_TARGET_MODE_FCP_XFER,
299 FCOE_ERROR_CODE_TARGET_MODE_DATA_TASK_TYPE_NOT_WRITE,
300 FCOE_ERROR_CODE_DATA_FCTL_TARGET,
301 FCOE_ERROR_CODE_TARGET_DATA_SIZE_NO_MATCH_XFER,
302 FCOE_ERROR_CODE_TARGET_DIF_CRC_CHECKSUM_ERROR,
303 FCOE_ERROR_CODE_TARGET_DIF_REF_TAG_ERROR,
304 FCOE_ERROR_CODE_TARGET_DIF_APP_TAG_ERROR,
305 MAX_FCOE_FP_ERROR_WARNING_CODE
306};
307
308
309/*
310 * FCoE RESPQ element
311 */
312struct fcoe_respqe {
313 __le16 ox_id /* OX_ID that is located in the FCP_RSP FC header */;
314 __le16 rx_id /* RX_ID that is located in the FCP_RSP FC header */;
315 __le32 additional_info;
316/* PARAM that is located in the FCP_RSP FC header */
317#define FCOE_RESPQE_PARAM_MASK 0xFFFFFF
318#define FCOE_RESPQE_PARAM_SHIFT 0
319/* Indication whther its Target-auto-rsp mode or not */
320#define FCOE_RESPQE_TARGET_AUTO_RSP_MASK 0xFF
321#define FCOE_RESPQE_TARGET_AUTO_RSP_SHIFT 24
322};
323
324
325/*
326 * FCoE slow path error codes
327 */
328enum fcoe_sp_error_code {
329 /* Error codes for Error Reporting in slow path flows */
330 FCOE_ERROR_CODE_SLOW_PATH_TOO_MANY_FUNCS,
331 FCOE_ERROR_SLOW_PATH_CODE_NO_LICENSE,
332 MAX_FCOE_SP_ERROR_CODE
333};
334
335
336/*
337 * FCoE SQE request type
338 */
339enum fcoe_sqe_request_type {
340 SEND_FCOE_CMD,
341 SEND_FCOE_MIDPATH,
342 SEND_FCOE_ABTS_REQUEST,
343 FCOE_EXCHANGE_CLEANUP,
344 FCOE_SEQUENCE_RECOVERY,
345 SEND_FCOE_XFER_RDY,
346 SEND_FCOE_RSP,
347 SEND_FCOE_RSP_WITH_SENSE_DATA,
348 SEND_FCOE_TARGET_DATA,
349 SEND_FCOE_INITIATOR_DATA,
350 /*
351 * Xfer Continuation (==1) ready to be sent. Previous XFERs data
352 * received successfully.
353 */
354 SEND_FCOE_XFER_CONTINUATION_RDY,
355 SEND_FCOE_TARGET_ABTS_RSP,
356 MAX_FCOE_SQE_REQUEST_TYPE
357};
358
359
360/*
361 * FCoE task TX state
362 */
363enum fcoe_task_tx_state {
364 /* Initiate state after driver has initialized the task */
365 FCOE_TASK_TX_STATE_NORMAL,
366 /* Updated by TX path after complete transmitting unsolicited packet */
367 FCOE_TASK_TX_STATE_UNSOLICITED_COMPLETED,
368 /*
369 * Updated by TX path after start processing the task requesting the
370 * cleanup/abort operation
371 */
372 FCOE_TASK_TX_STATE_CLEAN_REQ,
373 FCOE_TASK_TX_STATE_ABTS /* Updated by TX path during abort procedure */,
374 /* Updated by TX path during exchange cleanup procedure */
375 FCOE_TASK_TX_STATE_EXCLEANUP,
376 /*
377 * Updated by TX path during exchange cleanup continuation task
378 * procedure
379 */
380 FCOE_TASK_TX_STATE_EXCLEANUP_TARGET_WRITE_CONT,
381 /* Updated by TX path during exchange cleanup first xfer procedure */
382 FCOE_TASK_TX_STATE_EXCLEANUP_TARGET_WRITE,
383 /* Updated by TX path during exchange cleanup read task in Target */
384 FCOE_TASK_TX_STATE_EXCLEANUP_TARGET_READ_OR_RSP,
385 /* Updated by TX path during target exchange cleanup procedure */
386 FCOE_TASK_TX_STATE_EXCLEANUP_TARGET_WRITE_LAST_CYCLE,
387 /* Updated by TX path during sequence recovery procedure */
388 FCOE_TASK_TX_STATE_SEQRECOVERY,
389 MAX_FCOE_TASK_TX_STATE
390};
391
392
393/*
394 * FCoE task type
395 */
396enum fcoe_task_type {
397 FCOE_TASK_TYPE_WRITE_INITIATOR,
398 FCOE_TASK_TYPE_READ_INITIATOR,
399 FCOE_TASK_TYPE_MIDPATH,
400 FCOE_TASK_TYPE_UNSOLICITED,
401 FCOE_TASK_TYPE_ABTS,
402 FCOE_TASK_TYPE_EXCHANGE_CLEANUP,
403 FCOE_TASK_TYPE_SEQUENCE_CLEANUP,
404 FCOE_TASK_TYPE_WRITE_TARGET,
405 FCOE_TASK_TYPE_READ_TARGET,
406 FCOE_TASK_TYPE_RSP,
407 FCOE_TASK_TYPE_RSP_SENSE_DATA,
408 FCOE_TASK_TYPE_ABTS_TARGET,
409 FCOE_TASK_TYPE_ENUM_SIZE,
410 MAX_FCOE_TASK_TYPE
411};
412
413struct scsi_glbl_queue_entry {
414 /* Start physical address for the RQ (receive queue) PBL. */
415 struct regpair rq_pbl_addr;
416 /* Start physical address for the CQ (completion queue) PBL. */
417 struct regpair cq_pbl_addr;
418 /* Start physical address for the CMDQ (command queue) PBL. */
419 struct regpair cmdq_pbl_addr;
420};
421
422#endif /* __QEDF_HSI__ */