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