Linux 4.16.11
[linux/fpc-iii.git] / drivers / scsi / qedf / qedf_hsi.h
blob503c1ae3ccd08a3aaa6036df9ffd478fba915714
1 /*
2 * QLogic FCoE Offload Driver
3 * Copyright (c) 2016-2017 Cavium Inc.
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__
12 * Add include to common target
14 #include <linux/qed/common_hsi.h>
17 * Add include to common storage target
19 #include <linux/qed/storage_common.h>
22 * Add include to common fcoe target for both eCore and protocol driver
24 #include <linux/qed/fcoe_common.h>
28 * FCoE CQ element ABTS information
30 struct 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 */;
40 * FCoE class type
42 enum fcoe_class_type {
43 FCOE_TASK_CLASS_TYPE_3,
44 FCOE_TASK_CLASS_TYPE_2,
45 MAX_FCOE_CLASS_TYPE
50 * FCoE CMDQ element control information
52 struct 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];
65 * FCoE control + payload CMDQ element
67 struct fcoe_cmdqe {
68 struct fcoe_cmdqe_control hdr;
69 u8 fc_header[24];
70 __le32 fcp_cmd_payload[8];
76 * FCP RSP flags
78 struct 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
95 * FCoE CQ element response information
97 struct 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 */;
115 * FCoE CQ element Target completion information
117 struct fcoe_cqe_target_info {
118 __le16 rx_id;
119 __le16 reserved0;
120 __le32 reserved1[5];
124 * FCoE error/warning reporting entry
126 struct 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;
139 * FCoE CQ element middle path information
141 struct fcoe_cqe_midpath_info {
142 __le32 data_placement_size;
143 __le16 rx_id;
144 __le16 reserved0;
145 __le32 reserved1[4];
149 * FCoE CQ element unsolicited information
151 struct 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];
160 * FCoE warning reporting entry
162 struct 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;
172 * FCoE CQ element information
174 union 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;
190 * FCoE CQ element
192 struct 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
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)
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;
212 * FCoE CQE type
214 enum 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
229 * FCoE fast path error codes
231 enum fcoe_fp_error_warning_code {
232 FCOE_ERROR_CODE_XFER_OOO_RO /* XFER error codes */,
233 FCOE_ERROR_CODE_XFER_RO_NOT_ALIGNED,
234 FCOE_ERROR_CODE_XFER_NULL_BURST_LEN,
235 FCOE_ERROR_CODE_XFER_RO_GREATER_THAN_DATA2TRNS,
236 FCOE_ERROR_CODE_XFER_INVALID_PAYLOAD_SIZE,
237 FCOE_ERROR_CODE_XFER_TASK_TYPE_NOT_WRITE,
238 FCOE_ERROR_CODE_XFER_PEND_XFER_SET,
239 FCOE_ERROR_CODE_XFER_OPENED_SEQ,
240 FCOE_ERROR_CODE_XFER_FCTL,
241 FCOE_ERROR_CODE_FCP_RSP_BIDI_FLAGS_SET /* FCP RSP error codes */,
242 FCOE_ERROR_CODE_FCP_RSP_INVALID_LENGTH_FIELD,
243 FCOE_ERROR_CODE_FCP_RSP_INVALID_SNS_FIELD,
244 FCOE_ERROR_CODE_FCP_RSP_INVALID_PAYLOAD_SIZE,
245 FCOE_ERROR_CODE_FCP_RSP_PEND_XFER_SET,
246 FCOE_ERROR_CODE_FCP_RSP_OPENED_SEQ,
247 FCOE_ERROR_CODE_FCP_RSP_FCTL,
248 FCOE_ERROR_CODE_FCP_RSP_LAST_SEQ_RESET,
249 FCOE_ERROR_CODE_FCP_RSP_CONF_REQ_NOT_SUPPORTED_YET,
250 FCOE_ERROR_CODE_DATA_OOO_RO /* FCP DATA error codes */,
251 FCOE_ERROR_CODE_DATA_EXCEEDS_DEFINED_MAX_FRAME_SIZE,
252 FCOE_ERROR_CODE_DATA_EXCEEDS_DATA2TRNS,
253 FCOE_ERROR_CODE_DATA_SOFI3_SEQ_ACTIVE_SET,
254 FCOE_ERROR_CODE_DATA_SOFN_SEQ_ACTIVE_RESET,
255 FCOE_ERROR_CODE_DATA_EOFN_END_SEQ_SET,
256 FCOE_ERROR_CODE_DATA_EOFT_END_SEQ_RESET,
257 FCOE_ERROR_CODE_DATA_TASK_TYPE_NOT_READ,
258 FCOE_ERROR_CODE_DATA_FCTL_INITIATIR,
259 FCOE_ERROR_CODE_MIDPATH_INVALID_TYPE /* Middle path error codes */,
260 FCOE_ERROR_CODE_MIDPATH_SOFI3_SEQ_ACTIVE_SET,
261 FCOE_ERROR_CODE_MIDPATH_SOFN_SEQ_ACTIVE_RESET,
262 FCOE_ERROR_CODE_MIDPATH_EOFN_END_SEQ_SET,
263 FCOE_ERROR_CODE_MIDPATH_EOFT_END_SEQ_RESET,
264 FCOE_ERROR_CODE_MIDPATH_REPLY_FCTL,
265 FCOE_ERROR_CODE_MIDPATH_INVALID_REPLY,
266 FCOE_ERROR_CODE_MIDPATH_ELS_REPLY_RCTL,
267 FCOE_ERROR_CODE_COMMON_MIDDLE_FRAME_WITH_PAD /* Common error codes */,
268 FCOE_ERROR_CODE_COMMON_SEQ_INIT_IN_TCE,
269 FCOE_ERROR_CODE_COMMON_FC_HDR_RX_ID_MISMATCH,
270 FCOE_ERROR_CODE_COMMON_INCORRECT_SEQ_CNT,
271 FCOE_ERROR_CODE_COMMON_DATA_FC_HDR_FCP_TYPE_MISMATCH,
272 FCOE_ERROR_CODE_COMMON_DATA_NO_MORE_SGES,
273 FCOE_ERROR_CODE_COMMON_OPTIONAL_FC_HDR,
274 FCOE_ERROR_CODE_COMMON_READ_TCE_OX_ID_TOO_BIG,
275 FCOE_ERROR_CODE_COMMON_DATA_WAS_NOT_TRANSMITTED,
276 FCOE_ERROR_CODE_COMMON_TASK_DDF_RCTL_INFO_FIELD,
277 FCOE_ERROR_CODE_COMMON_TASK_INVALID_RCTL,
278 FCOE_ERROR_CODE_COMMON_TASK_RCTL_GENERAL_MISMATCH,
279 FCOE_ERROR_CODE_E_D_TOV_TIMER_EXPIRATION /* Timer error codes */,
280 FCOE_WARNING_CODE_REC_TOV_TIMER_EXPIRATION /* Timer error codes */,
281 FCOE_ERROR_CODE_RR_TOV_TIMER_EXPIRATION /* Timer error codes */,
282 /* ABTSrsp pckt arrived unexpected */
283 FCOE_ERROR_CODE_ABTS_REPLY_UNEXPECTED,
284 FCOE_ERROR_CODE_TARGET_MODE_FCP_RSP,
285 FCOE_ERROR_CODE_TARGET_MODE_FCP_XFER,
286 FCOE_ERROR_CODE_TARGET_MODE_DATA_TASK_TYPE_NOT_WRITE,
287 FCOE_ERROR_CODE_DATA_FCTL_TARGET,
288 FCOE_ERROR_CODE_TARGET_DATA_SIZE_NO_MATCH_XFER,
289 FCOE_ERROR_CODE_TARGET_DIF_CRC_CHECKSUM_ERROR,
290 FCOE_ERROR_CODE_TARGET_DIF_REF_TAG_ERROR,
291 FCOE_ERROR_CODE_TARGET_DIF_APP_TAG_ERROR,
292 MAX_FCOE_FP_ERROR_WARNING_CODE
297 * FCoE RESPQ element
299 struct fcoe_respqe {
300 __le16 ox_id /* OX_ID that is located in the FCP_RSP FC header */;
301 __le16 rx_id /* RX_ID that is located in the FCP_RSP FC header */;
302 __le32 additional_info;
303 /* PARAM that is located in the FCP_RSP FC header */
304 #define FCOE_RESPQE_PARAM_MASK 0xFFFFFF
305 #define FCOE_RESPQE_PARAM_SHIFT 0
306 /* Indication whther its Target-auto-rsp mode or not */
307 #define FCOE_RESPQE_TARGET_AUTO_RSP_MASK 0xFF
308 #define FCOE_RESPQE_TARGET_AUTO_RSP_SHIFT 24
313 * FCoE slow path error codes
315 enum fcoe_sp_error_code {
316 /* Error codes for Error Reporting in slow path flows */
317 FCOE_ERROR_CODE_SLOW_PATH_TOO_MANY_FUNCS,
318 FCOE_ERROR_SLOW_PATH_CODE_NO_LICENSE,
319 MAX_FCOE_SP_ERROR_CODE
323 * FCoE task TX state
325 enum fcoe_task_tx_state {
326 /* Initiate state after driver has initialized the task */
327 FCOE_TASK_TX_STATE_NORMAL,
328 /* Updated by TX path after complete transmitting unsolicited packet */
329 FCOE_TASK_TX_STATE_UNSOLICITED_COMPLETED,
331 * Updated by TX path after start processing the task requesting the
332 * cleanup/abort operation
334 FCOE_TASK_TX_STATE_CLEAN_REQ,
335 FCOE_TASK_TX_STATE_ABTS /* Updated by TX path during abort procedure */,
336 /* Updated by TX path during exchange cleanup procedure */
337 FCOE_TASK_TX_STATE_EXCLEANUP,
339 * Updated by TX path during exchange cleanup continuation task
340 * procedure
342 FCOE_TASK_TX_STATE_EXCLEANUP_TARGET_WRITE_CONT,
343 /* Updated by TX path during exchange cleanup first xfer procedure */
344 FCOE_TASK_TX_STATE_EXCLEANUP_TARGET_WRITE,
345 /* Updated by TX path during exchange cleanup read task in Target */
346 FCOE_TASK_TX_STATE_EXCLEANUP_TARGET_READ_OR_RSP,
347 /* Updated by TX path during target exchange cleanup procedure */
348 FCOE_TASK_TX_STATE_EXCLEANUP_TARGET_WRITE_LAST_CYCLE,
349 /* Updated by TX path during sequence recovery procedure */
350 FCOE_TASK_TX_STATE_SEQRECOVERY,
351 MAX_FCOE_TASK_TX_STATE
354 #endif /* __QEDF_HSI__ */