bfi_fcpim.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. /*
  2. * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
  3. * All rights reserved
  4. * www.brocade.com
  5. *
  6. * Linux driver for Brocade Fibre Channel Host Bus Adapter.
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License (GPL) Version 2 as
  10. * published by the Free Software Foundation
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. */
  17. #ifndef __BFI_FCPIM_H__
  18. #define __BFI_FCPIM_H__
  19. #include "bfi.h"
  20. #include <protocol/fcp.h>
  21. #pragma pack(1)
  22. /*
  23. * Initiator mode I-T nexus interface defines.
  24. */
  25. enum bfi_itnim_h2i {
  26. BFI_ITNIM_H2I_CREATE_REQ = 1, /* i-t nexus creation */
  27. BFI_ITNIM_H2I_DELETE_REQ = 2, /* i-t nexus deletion */
  28. };
  29. enum bfi_itnim_i2h {
  30. BFI_ITNIM_I2H_CREATE_RSP = BFA_I2HM(1),
  31. BFI_ITNIM_I2H_DELETE_RSP = BFA_I2HM(2),
  32. BFI_ITNIM_I2H_SLER_EVENT = BFA_I2HM(3),
  33. };
  34. struct bfi_itnim_create_req_s {
  35. struct bfi_mhdr_s mh; /* common msg header */
  36. u16 fw_handle; /* f/w handle for itnim */
  37. u8 class; /* FC class for IO */
  38. u8 seq_rec; /* sequence recovery support */
  39. u8 msg_no; /* seq id of the msg */
  40. };
  41. struct bfi_itnim_create_rsp_s {
  42. struct bfi_mhdr_s mh; /* common msg header */
  43. u16 bfa_handle; /* bfa handle for itnim */
  44. u8 status; /* fcp request status */
  45. u8 seq_id; /* seq id of the msg */
  46. };
  47. struct bfi_itnim_delete_req_s {
  48. struct bfi_mhdr_s mh; /* common msg header */
  49. u16 fw_handle; /* f/w itnim handle */
  50. u8 seq_id; /* seq id of the msg */
  51. u8 rsvd;
  52. };
  53. struct bfi_itnim_delete_rsp_s {
  54. struct bfi_mhdr_s mh; /* common msg header */
  55. u16 bfa_handle; /* bfa handle for itnim */
  56. u8 status; /* fcp request status */
  57. u8 seq_id; /* seq id of the msg */
  58. };
  59. struct bfi_itnim_sler_event_s {
  60. struct bfi_mhdr_s mh; /* common msg header */
  61. u16 bfa_handle; /* bfa handle for itnim */
  62. u16 rsvd;
  63. };
  64. union bfi_itnim_h2i_msg_u {
  65. struct bfi_itnim_create_req_s *create_req;
  66. struct bfi_itnim_delete_req_s *delete_req;
  67. struct bfi_msg_s *msg;
  68. };
  69. union bfi_itnim_i2h_msg_u {
  70. struct bfi_itnim_create_rsp_s *create_rsp;
  71. struct bfi_itnim_delete_rsp_s *delete_rsp;
  72. struct bfi_itnim_sler_event_s *sler_event;
  73. struct bfi_msg_s *msg;
  74. };
  75. /*
  76. * Initiator mode IO interface defines.
  77. */
  78. enum bfi_ioim_h2i {
  79. BFI_IOIM_H2I_IOABORT_REQ = 1, /* IO abort request */
  80. BFI_IOIM_H2I_IOCLEANUP_REQ = 2, /* IO cleanup request */
  81. };
  82. enum bfi_ioim_i2h {
  83. BFI_IOIM_I2H_IO_RSP = BFA_I2HM(1), /* non-fp IO response */
  84. BFI_IOIM_I2H_IOABORT_RSP = BFA_I2HM(2),/* ABORT rsp */
  85. };
  86. /**
  87. * IO command DIF info
  88. */
  89. struct bfi_ioim_dif_s {
  90. u32 dif_info[4];
  91. };
  92. /**
  93. * FCP IO messages overview
  94. *
  95. * @note
  96. * - Max CDB length supported is 64 bytes.
  97. * - SCSI Linked commands and SCSI bi-directional Commands not
  98. * supported.
  99. *
  100. */
  101. struct bfi_ioim_req_s {
  102. struct bfi_mhdr_s mh; /* Common msg header */
  103. u16 io_tag; /* I/O tag */
  104. u16 rport_hdl; /* itnim/rport firmware handle */
  105. struct fcp_cmnd_s cmnd; /* IO request info */
  106. /**
  107. * SG elements array within the IO request must be double word
  108. * aligned. This aligment is required to optimize SGM setup for the IO.
  109. */
  110. struct bfi_sge_s sges[BFI_SGE_INLINE_MAX];
  111. u8 io_timeout;
  112. u8 dif_en;
  113. u8 rsvd_a[2];
  114. struct bfi_ioim_dif_s dif;
  115. };
  116. /**
  117. * This table shows various IO status codes from firmware and their
  118. * meaning. Host driver can use these status codes to further process
  119. * IO completions.
  120. *
  121. * BFI_IOIM_STS_OK : IO completed with error free SCSI &
  122. * transport status.
  123. * - io-tag can be reused.
  124. *
  125. * BFA_IOIM_STS_SCSI_ERR : IO completed with scsi error.
  126. * - io-tag can be reused.
  127. *
  128. * BFI_IOIM_STS_HOST_ABORTED : IO was aborted successfully due to
  129. * host request.
  130. * - io-tag cannot be reused yet.
  131. *
  132. * BFI_IOIM_STS_ABORTED : IO was aborted successfully
  133. * internally by f/w.
  134. * - io-tag cannot be reused yet.
  135. *
  136. * BFI_IOIM_STS_TIMEDOUT : IO timedout and ABTS/RRQ is happening
  137. * in the firmware and
  138. * - io-tag cannot be reused yet.
  139. *
  140. * BFI_IOIM_STS_SQER_NEEDED : Firmware could not recover the IO
  141. * with sequence level error
  142. * logic and hence host needs to retry
  143. * this IO with a different IO tag
  144. * - io-tag cannot be used yet.
  145. *
  146. * BFI_IOIM_STS_NEXUS_ABORT : Second Level Error Recovery from host
  147. * is required because 2 consecutive ABTS
  148. * timedout and host needs logout and
  149. * re-login with the target
  150. * - io-tag cannot be used yet.
  151. *
  152. * BFI_IOIM_STS_UNDERRUN : IO completed with SCSI status good,
  153. * but the data tranferred is less than
  154. * the fcp data length in the command.
  155. * ex. SCSI INQUIRY where transferred
  156. * data length and residue count in FCP
  157. * response accounts for total fcp-dl
  158. * - io-tag can be reused.
  159. *
  160. * BFI_IOIM_STS_OVERRUN : IO completed with SCSI status good,
  161. * but the data transerred is more than
  162. * fcp data length in the command. ex.
  163. * TAPE IOs where blocks can of unequal
  164. * lengths.
  165. * - io-tag can be reused.
  166. *
  167. * BFI_IOIM_STS_RES_FREE : Firmware has completed using io-tag
  168. * during abort process
  169. * - io-tag can be reused.
  170. *
  171. * BFI_IOIM_STS_PROTO_ERR : Firmware detected a protocol error.
  172. * ex target sent more data than
  173. * requested, or there was data frame
  174. * loss and other reasons
  175. * - io-tag cannot be used yet.
  176. *
  177. * BFI_IOIM_STS_DIF_ERR : Firwmare detected DIF error. ex: DIF
  178. * CRC err or Ref Tag err or App tag err.
  179. * - io-tag can be reused.
  180. *
  181. * BFA_IOIM_STS_TSK_MGT_ABORT : IO was aborted because of Task
  182. * Management command from the host
  183. * - io-tag can be reused.
  184. *
  185. * BFI_IOIM_STS_UTAG : Firmware does not know about this
  186. * io_tag.
  187. * - io-tag can be reused.
  188. */
  189. enum bfi_ioim_status {
  190. BFI_IOIM_STS_OK = 0,
  191. BFI_IOIM_STS_HOST_ABORTED = 1,
  192. BFI_IOIM_STS_ABORTED = 2,
  193. BFI_IOIM_STS_TIMEDOUT = 3,
  194. BFI_IOIM_STS_RES_FREE = 4,
  195. BFI_IOIM_STS_SQER_NEEDED = 5,
  196. BFI_IOIM_STS_PROTO_ERR = 6,
  197. BFI_IOIM_STS_UTAG = 7,
  198. BFI_IOIM_STS_PATHTOV = 8,
  199. };
  200. #define BFI_IOIM_SNSLEN (256)
  201. /**
  202. * I/O response message
  203. */
  204. struct bfi_ioim_rsp_s {
  205. struct bfi_mhdr_s mh; /* common msg header */
  206. u16 io_tag; /* completed IO tag */
  207. u16 bfa_rport_hndl; /* releated rport handle */
  208. u8 io_status; /* IO completion status */
  209. u8 reuse_io_tag; /* IO tag can be reused */
  210. u16 abort_tag; /* host abort request tag */
  211. u8 scsi_status; /* scsi status from target */
  212. u8 sns_len; /* scsi sense length */
  213. u8 resid_flags; /* IO residue flags */
  214. u8 rsvd_a;
  215. u32 residue; /* IO residual length in bytes */
  216. u32 rsvd_b[3];
  217. };
  218. struct bfi_ioim_abort_req_s {
  219. struct bfi_mhdr_s mh; /* Common msg header */
  220. u16 io_tag; /* I/O tag */
  221. u16 abort_tag; /* unique request tag */
  222. };
  223. /*
  224. * Initiator mode task management command interface defines.
  225. */
  226. enum bfi_tskim_h2i {
  227. BFI_TSKIM_H2I_TM_REQ = 1, /* task-mgmt command */
  228. BFI_TSKIM_H2I_ABORT_REQ = 2, /* task-mgmt command */
  229. };
  230. enum bfi_tskim_i2h {
  231. BFI_TSKIM_I2H_TM_RSP = BFA_I2HM(1),
  232. };
  233. struct bfi_tskim_req_s {
  234. struct bfi_mhdr_s mh; /* Common msg header */
  235. u16 tsk_tag; /* task management tag */
  236. u16 itn_fhdl; /* itn firmware handle */
  237. lun_t lun; /* LU number */
  238. u8 tm_flags; /* see fcp_tm_cmnd_t */
  239. u8 t_secs; /* Timeout value in seconds */
  240. u8 rsvd[2];
  241. };
  242. struct bfi_tskim_abortreq_s {
  243. struct bfi_mhdr_s mh; /* Common msg header */
  244. u16 tsk_tag; /* task management tag */
  245. u16 rsvd;
  246. };
  247. enum bfi_tskim_status {
  248. /*
  249. * Following are FCP-4 spec defined status codes,
  250. * **DO NOT CHANGE THEM **
  251. */
  252. BFI_TSKIM_STS_OK = 0,
  253. BFI_TSKIM_STS_NOT_SUPP = 4,
  254. BFI_TSKIM_STS_FAILED = 5,
  255. /**
  256. * Defined by BFA
  257. */
  258. BFI_TSKIM_STS_TIMEOUT = 10, /* TM request timedout */
  259. BFI_TSKIM_STS_ABORTED = 11, /* Aborted on host request */
  260. };
  261. struct bfi_tskim_rsp_s {
  262. struct bfi_mhdr_s mh; /* Common msg header */
  263. u16 tsk_tag; /* task mgmt cmnd tag */
  264. u8 tsk_status; /* @ref bfi_tskim_status */
  265. u8 rsvd;
  266. };
  267. #pragma pack()
  268. #endif /* __BFI_FCPIM_H__ */