qedf_hsi.h 11 KB

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