fcpio.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780
  1. /*
  2. * Copyright 2008 Cisco Systems, Inc. All rights reserved.
  3. * Copyright 2007 Nuova Systems, Inc. All rights reserved.
  4. *
  5. * This program is free software; you may redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; version 2 of the License.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  10. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  11. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  12. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  13. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  14. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  15. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  16. * SOFTWARE.
  17. */
  18. #ifndef _FCPIO_H_
  19. #define _FCPIO_H_
  20. #include <linux/if_ether.h>
  21. /*
  22. * This header file includes all of the data structures used for
  23. * communication by the host driver to the fcp firmware.
  24. */
  25. /*
  26. * Exchange and sequence id space allocated to the host driver
  27. */
  28. #define FCPIO_HOST_EXCH_RANGE_START 0x1000
  29. #define FCPIO_HOST_EXCH_RANGE_END 0x1fff
  30. #define FCPIO_HOST_SEQ_ID_RANGE_START 0x80
  31. #define FCPIO_HOST_SEQ_ID_RANGE_END 0xff
  32. /*
  33. * Command entry type
  34. */
  35. enum fcpio_type {
  36. /*
  37. * Initiator request types
  38. */
  39. FCPIO_ICMND_16 = 0x1,
  40. FCPIO_ICMND_32,
  41. FCPIO_ICMND_CMPL,
  42. FCPIO_ITMF,
  43. FCPIO_ITMF_CMPL,
  44. /*
  45. * Target request types
  46. */
  47. FCPIO_TCMND_16 = 0x11,
  48. FCPIO_TCMND_32,
  49. FCPIO_TDATA,
  50. FCPIO_TXRDY,
  51. FCPIO_TRSP,
  52. FCPIO_TDRSP_CMPL,
  53. FCPIO_TTMF,
  54. FCPIO_TTMF_ACK,
  55. FCPIO_TABORT,
  56. FCPIO_TABORT_CMPL,
  57. /*
  58. * Misc request types
  59. */
  60. FCPIO_ACK = 0x20,
  61. FCPIO_RESET,
  62. FCPIO_RESET_CMPL,
  63. FCPIO_FLOGI_REG,
  64. FCPIO_FLOGI_REG_CMPL,
  65. FCPIO_ECHO,
  66. FCPIO_ECHO_CMPL,
  67. FCPIO_LUNMAP_CHNG,
  68. FCPIO_LUNMAP_REQ,
  69. FCPIO_LUNMAP_REQ_CMPL,
  70. FCPIO_FLOGI_FIP_REG,
  71. FCPIO_FLOGI_FIP_REG_CMPL,
  72. };
  73. /*
  74. * Header status codes from the firmware
  75. */
  76. enum fcpio_status {
  77. FCPIO_SUCCESS = 0, /* request was successful */
  78. /*
  79. * If a request to the firmware is rejected, the original request
  80. * header will be returned with the status set to one of the following:
  81. */
  82. FCPIO_INVALID_HEADER, /* header contains invalid data */
  83. FCPIO_OUT_OF_RESOURCE, /* out of resources to complete request */
  84. FCPIO_INVALID_PARAM, /* some parameter in request is invalid */
  85. FCPIO_REQ_NOT_SUPPORTED, /* request type is not supported */
  86. FCPIO_IO_NOT_FOUND, /* requested I/O was not found */
  87. /*
  88. * Once a request is processed, the firmware will usually return
  89. * a cmpl message type. In cases where errors occurred,
  90. * the header status field would be filled in with one of the following:
  91. */
  92. FCPIO_ABORTED = 0x41, /* request was aborted */
  93. FCPIO_TIMEOUT, /* request was timed out */
  94. FCPIO_SGL_INVALID, /* request was aborted due to sgl error */
  95. FCPIO_MSS_INVALID, /* request was aborted due to mss error */
  96. FCPIO_DATA_CNT_MISMATCH, /* recv/sent more/less data than exp. */
  97. FCPIO_FW_ERR, /* request was terminated due to fw error */
  98. FCPIO_ITMF_REJECTED, /* itmf req was rejected by remote node */
  99. FCPIO_ITMF_FAILED, /* itmf req was failed by remote node */
  100. FCPIO_ITMF_INCORRECT_LUN, /* itmf req targeted incorrect LUN */
  101. FCPIO_CMND_REJECTED, /* request was invalid and rejected */
  102. FCPIO_NO_PATH_AVAIL, /* no paths to the lun was available */
  103. FCPIO_PATH_FAILED, /* i/o sent to current path failed */
  104. FCPIO_LUNMAP_CHNG_PEND, /* i/o rejected due to lunmap change */
  105. };
  106. /*
  107. * The header command tag. All host requests will use the "tag" field
  108. * to mark commands with a unique tag. When the firmware responds to
  109. * a host request, it will copy the tag field into the response.
  110. *
  111. * The only firmware requests that will use the rx_id/ox_id fields instead
  112. * of the tag field will be the target command and target task management
  113. * requests. These two requests do not have corresponding host requests
  114. * since they come directly from the FC initiator on the network.
  115. */
  116. struct fcpio_tag {
  117. union {
  118. u32 req_id;
  119. struct {
  120. u16 rx_id;
  121. u16 ox_id;
  122. } ex_id;
  123. } u;
  124. };
  125. static inline void
  126. fcpio_tag_id_enc(struct fcpio_tag *tag, u32 id)
  127. {
  128. tag->u.req_id = id;
  129. }
  130. static inline void
  131. fcpio_tag_id_dec(struct fcpio_tag *tag, u32 *id)
  132. {
  133. *id = tag->u.req_id;
  134. }
  135. static inline void
  136. fcpio_tag_exid_enc(struct fcpio_tag *tag, u16 ox_id, u16 rx_id)
  137. {
  138. tag->u.ex_id.rx_id = rx_id;
  139. tag->u.ex_id.ox_id = ox_id;
  140. }
  141. static inline void
  142. fcpio_tag_exid_dec(struct fcpio_tag *tag, u16 *ox_id, u16 *rx_id)
  143. {
  144. *rx_id = tag->u.ex_id.rx_id;
  145. *ox_id = tag->u.ex_id.ox_id;
  146. }
  147. /*
  148. * The header for an fcpio request, whether from the firmware or from the
  149. * host driver
  150. */
  151. struct fcpio_header {
  152. u8 type; /* enum fcpio_type */
  153. u8 status; /* header status entry */
  154. u16 _resvd; /* reserved */
  155. struct fcpio_tag tag; /* header tag */
  156. };
  157. static inline void
  158. fcpio_header_enc(struct fcpio_header *hdr,
  159. u8 type, u8 status,
  160. struct fcpio_tag tag)
  161. {
  162. hdr->type = type;
  163. hdr->status = status;
  164. hdr->_resvd = 0;
  165. hdr->tag = tag;
  166. }
  167. static inline void
  168. fcpio_header_dec(struct fcpio_header *hdr,
  169. u8 *type, u8 *status,
  170. struct fcpio_tag *tag)
  171. {
  172. *type = hdr->type;
  173. *status = hdr->status;
  174. *tag = hdr->tag;
  175. }
  176. #define CDB_16 16
  177. #define CDB_32 32
  178. #define LUN_ADDRESS 8
  179. /*
  180. * fcpio_icmnd_16: host -> firmware request
  181. *
  182. * used for sending out an initiator SCSI 16-byte command
  183. */
  184. struct fcpio_icmnd_16 {
  185. u32 lunmap_id; /* index into lunmap table */
  186. u8 special_req_flags; /* special exchange request flags */
  187. u8 _resvd0[3]; /* reserved */
  188. u32 sgl_cnt; /* scatter-gather list count */
  189. u32 sense_len; /* sense buffer length */
  190. u64 sgl_addr; /* scatter-gather list addr */
  191. u64 sense_addr; /* sense buffer address */
  192. u8 crn; /* SCSI Command Reference No. */
  193. u8 pri_ta; /* SCSI Priority and Task attribute */
  194. u8 _resvd1; /* reserved: should be 0 */
  195. u8 flags; /* command flags */
  196. u8 scsi_cdb[CDB_16]; /* SCSI Cmnd Descriptor Block */
  197. u32 data_len; /* length of data expected */
  198. u8 lun[LUN_ADDRESS]; /* FC vNIC only: LUN address */
  199. u8 _resvd2; /* reserved */
  200. u8 d_id[3]; /* FC vNIC only: Target D_ID */
  201. u16 mss; /* FC vNIC only: max burst */
  202. u16 _resvd3; /* reserved */
  203. u32 r_a_tov; /* FC vNIC only: Res. Alloc Timeout */
  204. u32 e_d_tov; /* FC vNIC only: Err Detect Timeout */
  205. };
  206. /*
  207. * Special request flags
  208. */
  209. #define FCPIO_ICMND_SRFLAG_RETRY 0x01 /* Enable Retry handling on exchange */
  210. /*
  211. * Priority/Task Attribute settings
  212. */
  213. #define FCPIO_ICMND_PTA_SIMPLE 0 /* simple task attribute */
  214. #define FCPIO_ICMND_PTA_HEADQ 1 /* head of queue task attribute */
  215. #define FCPIO_ICMND_PTA_ORDERED 2 /* ordered task attribute */
  216. #define FCPIO_ICMND_PTA_ACA 4 /* auto contingent allegiance */
  217. #define FCPIO_ICMND_PRI_SHIFT 3 /* priority field starts in bit 3 */
  218. /*
  219. * Command flags
  220. */
  221. #define FCPIO_ICMND_RDDATA 0x02 /* read data */
  222. #define FCPIO_ICMND_WRDATA 0x01 /* write data */
  223. /*
  224. * fcpio_icmnd_32: host -> firmware request
  225. *
  226. * used for sending out an initiator SCSI 32-byte command
  227. */
  228. struct fcpio_icmnd_32 {
  229. u32 lunmap_id; /* index into lunmap table */
  230. u8 special_req_flags; /* special exchange request flags */
  231. u8 _resvd0[3]; /* reserved */
  232. u32 sgl_cnt; /* scatter-gather list count */
  233. u32 sense_len; /* sense buffer length */
  234. u64 sgl_addr; /* scatter-gather list addr */
  235. u64 sense_addr; /* sense buffer address */
  236. u8 crn; /* SCSI Command Reference No. */
  237. u8 pri_ta; /* SCSI Priority and Task attribute */
  238. u8 _resvd1; /* reserved: should be 0 */
  239. u8 flags; /* command flags */
  240. u8 scsi_cdb[CDB_32]; /* SCSI Cmnd Descriptor Block */
  241. u32 data_len; /* length of data expected */
  242. u8 lun[LUN_ADDRESS]; /* FC vNIC only: LUN address */
  243. u8 _resvd2; /* reserved */
  244. u8 d_id[3]; /* FC vNIC only: Target D_ID */
  245. u16 mss; /* FC vNIC only: max burst */
  246. u16 _resvd3; /* reserved */
  247. u32 r_a_tov; /* FC vNIC only: Res. Alloc Timeout */
  248. u32 e_d_tov; /* FC vNIC only: Error Detect Timeout */
  249. };
  250. /*
  251. * fcpio_itmf: host -> firmware request
  252. *
  253. * used for requesting the firmware to abort a request and/or send out
  254. * a task management function
  255. *
  256. * The t_tag field is only needed when the request type is ABT_TASK.
  257. */
  258. struct fcpio_itmf {
  259. u32 lunmap_id; /* index into lunmap table */
  260. u32 tm_req; /* SCSI Task Management request */
  261. u32 t_tag; /* header tag of fcpio to be aborted */
  262. u32 _resvd; /* _reserved */
  263. u8 lun[LUN_ADDRESS]; /* FC vNIC only: LUN address */
  264. u8 _resvd1; /* reserved */
  265. u8 d_id[3]; /* FC vNIC only: Target D_ID */
  266. u32 r_a_tov; /* FC vNIC only: R_A_TOV in msec */
  267. u32 e_d_tov; /* FC vNIC only: E_D_TOV in msec */
  268. };
  269. /*
  270. * Task Management request
  271. */
  272. enum fcpio_itmf_tm_req_type {
  273. FCPIO_ITMF_ABT_TASK_TERM = 0x01, /* abort task and terminate */
  274. FCPIO_ITMF_ABT_TASK, /* abort task and issue abts */
  275. FCPIO_ITMF_ABT_TASK_SET, /* abort task set */
  276. FCPIO_ITMF_CLR_TASK_SET, /* clear task set */
  277. FCPIO_ITMF_LUN_RESET, /* logical unit reset task mgmt */
  278. FCPIO_ITMF_CLR_ACA, /* Clear ACA condition */
  279. };
  280. /*
  281. * fcpio_tdata: host -> firmware request
  282. *
  283. * used for requesting the firmware to send out a read data transfer for a
  284. * target command
  285. */
  286. struct fcpio_tdata {
  287. u16 rx_id; /* FC rx_id of target command */
  288. u16 flags; /* command flags */
  289. u32 rel_offset; /* data sequence relative offset */
  290. u32 sgl_cnt; /* scatter-gather list count */
  291. u32 data_len; /* length of data expected to send */
  292. u64 sgl_addr; /* scatter-gather list address */
  293. };
  294. /*
  295. * Command flags
  296. */
  297. #define FCPIO_TDATA_SCSI_RSP 0x01 /* send a scsi resp. after last frame */
  298. /*
  299. * fcpio_txrdy: host -> firmware request
  300. *
  301. * used for requesting the firmware to send out a write data transfer for a
  302. * target command
  303. */
  304. struct fcpio_txrdy {
  305. u16 rx_id; /* FC rx_id of target command */
  306. u16 _resvd0; /* reserved */
  307. u32 rel_offset; /* data sequence relative offset */
  308. u32 sgl_cnt; /* scatter-gather list count */
  309. u32 data_len; /* length of data expected to send */
  310. u64 sgl_addr; /* scatter-gather list address */
  311. };
  312. /*
  313. * fcpio_trsp: host -> firmware request
  314. *
  315. * used for requesting the firmware to send out a response for a target
  316. * command
  317. */
  318. struct fcpio_trsp {
  319. u16 rx_id; /* FC rx_id of target command */
  320. u16 _resvd0; /* reserved */
  321. u32 sense_len; /* sense data buffer length */
  322. u64 sense_addr; /* sense data buffer address */
  323. u16 _resvd1; /* reserved */
  324. u8 flags; /* response request flags */
  325. u8 scsi_status; /* SCSI status */
  326. u32 residual; /* SCSI data residual value of I/O */
  327. };
  328. /*
  329. * resposnse request flags
  330. */
  331. #define FCPIO_TRSP_RESID_UNDER 0x08 /* residual is valid and is underflow */
  332. #define FCPIO_TRSP_RESID_OVER 0x04 /* residual is valid and is overflow */
  333. /*
  334. * fcpio_ttmf_ack: host -> firmware response
  335. *
  336. * used by the host to indicate to the firmware it has received and processed
  337. * the target tmf request
  338. */
  339. struct fcpio_ttmf_ack {
  340. u16 rx_id; /* FC rx_id of target command */
  341. u16 _resvd0; /* reserved */
  342. u32 tmf_status; /* SCSI task management status */
  343. };
  344. /*
  345. * fcpio_tabort: host -> firmware request
  346. *
  347. * used by the host to request the firmware to abort a target request that was
  348. * received by the firmware
  349. */
  350. struct fcpio_tabort {
  351. u16 rx_id; /* rx_id of the target request */
  352. };
  353. /*
  354. * fcpio_reset: host -> firmware request
  355. *
  356. * used by the host to signal a reset of the driver to the firmware
  357. * and to request firmware to clean up all outstanding I/O
  358. */
  359. struct fcpio_reset {
  360. u32 _resvd;
  361. };
  362. enum fcpio_flogi_reg_format_type {
  363. FCPIO_FLOGI_REG_DEF_DEST = 0, /* Use the oui | s_id mac format */
  364. FCPIO_FLOGI_REG_GW_DEST, /* Use the fixed gateway mac */
  365. };
  366. /*
  367. * fcpio_flogi_reg: host -> firmware request
  368. *
  369. * fc vnic only
  370. * used by the host to notify the firmware of the lif's s_id
  371. * and destination mac address format
  372. */
  373. struct fcpio_flogi_reg {
  374. u8 format;
  375. u8 s_id[3]; /* FC vNIC only: Source S_ID */
  376. u8 gateway_mac[ETH_ALEN]; /* Destination gateway mac */
  377. u16 _resvd;
  378. u32 r_a_tov; /* R_A_TOV in msec */
  379. u32 e_d_tov; /* E_D_TOV in msec */
  380. };
  381. /*
  382. * fcpio_echo: host -> firmware request
  383. *
  384. * sends a heartbeat echo request to the firmware
  385. */
  386. struct fcpio_echo {
  387. u32 _resvd;
  388. };
  389. /*
  390. * fcpio_lunmap_req: host -> firmware request
  391. *
  392. * scsi vnic only
  393. * sends a request to retrieve the lunmap table for scsi vnics
  394. */
  395. struct fcpio_lunmap_req {
  396. u64 addr; /* address of the buffer */
  397. u32 len; /* len of the buffer */
  398. };
  399. /*
  400. * fcpio_flogi_fip_reg: host -> firmware request
  401. *
  402. * fc vnic only
  403. * used by the host to notify the firmware of the lif's s_id
  404. * and destination mac address format
  405. */
  406. struct fcpio_flogi_fip_reg {
  407. u8 _resvd0;
  408. u8 s_id[3]; /* FC vNIC only: Source S_ID */
  409. u8 fcf_mac[ETH_ALEN]; /* FCF Target destination mac */
  410. u16 _resvd1;
  411. u32 r_a_tov; /* R_A_TOV in msec */
  412. u32 e_d_tov; /* E_D_TOV in msec */
  413. u8 ha_mac[ETH_ALEN]; /* Host adapter source mac */
  414. u16 _resvd2;
  415. };
  416. /*
  417. * Basic structure for all fcpio structures that are sent from the host to the
  418. * firmware. They are 128 bytes per structure.
  419. */
  420. #define FCPIO_HOST_REQ_LEN 128 /* expected length of host requests */
  421. struct fcpio_host_req {
  422. struct fcpio_header hdr;
  423. union {
  424. /*
  425. * Defines space needed for request
  426. */
  427. u8 buf[FCPIO_HOST_REQ_LEN - sizeof(struct fcpio_header)];
  428. /*
  429. * Initiator host requests
  430. */
  431. struct fcpio_icmnd_16 icmnd_16;
  432. struct fcpio_icmnd_32 icmnd_32;
  433. struct fcpio_itmf itmf;
  434. /*
  435. * Target host requests
  436. */
  437. struct fcpio_tdata tdata;
  438. struct fcpio_txrdy txrdy;
  439. struct fcpio_trsp trsp;
  440. struct fcpio_ttmf_ack ttmf_ack;
  441. struct fcpio_tabort tabort;
  442. /*
  443. * Misc requests
  444. */
  445. struct fcpio_reset reset;
  446. struct fcpio_flogi_reg flogi_reg;
  447. struct fcpio_echo echo;
  448. struct fcpio_lunmap_req lunmap_req;
  449. struct fcpio_flogi_fip_reg flogi_fip_reg;
  450. } u;
  451. };
  452. /*
  453. * fcpio_icmnd_cmpl: firmware -> host response
  454. *
  455. * used for sending the host a response to an initiator command
  456. */
  457. struct fcpio_icmnd_cmpl {
  458. u8 _resvd0[6]; /* reserved */
  459. u8 flags; /* response flags */
  460. u8 scsi_status; /* SCSI status */
  461. u32 residual; /* SCSI data residual length */
  462. u32 sense_len; /* SCSI sense length */
  463. };
  464. /*
  465. * response flags
  466. */
  467. #define FCPIO_ICMND_CMPL_RESID_UNDER 0x08 /* resid under and valid */
  468. #define FCPIO_ICMND_CMPL_RESID_OVER 0x04 /* resid over and valid */
  469. /*
  470. * fcpio_itmf_cmpl: firmware -> host response
  471. *
  472. * used for sending the host a response for a itmf request
  473. */
  474. struct fcpio_itmf_cmpl {
  475. u32 _resvd; /* reserved */
  476. };
  477. /*
  478. * fcpio_tcmnd_16: firmware -> host request
  479. *
  480. * used by the firmware to notify the host of an incoming target SCSI 16-Byte
  481. * request
  482. */
  483. struct fcpio_tcmnd_16 {
  484. u8 lun[LUN_ADDRESS]; /* FC vNIC only: LUN address */
  485. u8 crn; /* SCSI Command Reference No. */
  486. u8 pri_ta; /* SCSI Priority and Task attribute */
  487. u8 _resvd2; /* reserved: should be 0 */
  488. u8 flags; /* command flags */
  489. u8 scsi_cdb[CDB_16]; /* SCSI Cmnd Descriptor Block */
  490. u32 data_len; /* length of data expected */
  491. u8 _resvd1; /* reserved */
  492. u8 s_id[3]; /* FC vNIC only: Source S_ID */
  493. };
  494. /*
  495. * Priority/Task Attribute settings
  496. */
  497. #define FCPIO_TCMND_PTA_SIMPLE 0 /* simple task attribute */
  498. #define FCPIO_TCMND_PTA_HEADQ 1 /* head of queue task attribute */
  499. #define FCPIO_TCMND_PTA_ORDERED 2 /* ordered task attribute */
  500. #define FCPIO_TCMND_PTA_ACA 4 /* auto contingent allegiance */
  501. #define FCPIO_TCMND_PRI_SHIFT 3 /* priority field starts in bit 3 */
  502. /*
  503. * Command flags
  504. */
  505. #define FCPIO_TCMND_RDDATA 0x02 /* read data */
  506. #define FCPIO_TCMND_WRDATA 0x01 /* write data */
  507. /*
  508. * fcpio_tcmnd_32: firmware -> host request
  509. *
  510. * used by the firmware to notify the host of an incoming target SCSI 32-Byte
  511. * request
  512. */
  513. struct fcpio_tcmnd_32 {
  514. u8 lun[LUN_ADDRESS]; /* FC vNIC only: LUN address */
  515. u8 crn; /* SCSI Command Reference No. */
  516. u8 pri_ta; /* SCSI Priority and Task attribute */
  517. u8 _resvd2; /* reserved: should be 0 */
  518. u8 flags; /* command flags */
  519. u8 scsi_cdb[CDB_32]; /* SCSI Cmnd Descriptor Block */
  520. u32 data_len; /* length of data expected */
  521. u8 _resvd0; /* reserved */
  522. u8 s_id[3]; /* FC vNIC only: Source S_ID */
  523. };
  524. /*
  525. * fcpio_tdrsp_cmpl: firmware -> host response
  526. *
  527. * used by the firmware to notify the host of a response to a host target
  528. * command
  529. */
  530. struct fcpio_tdrsp_cmpl {
  531. u16 rx_id; /* rx_id of the target request */
  532. u16 _resvd0; /* reserved */
  533. };
  534. /*
  535. * fcpio_ttmf: firmware -> host request
  536. *
  537. * used by the firmware to notify the host of an incoming task management
  538. * function request
  539. */
  540. struct fcpio_ttmf {
  541. u8 _resvd0; /* reserved */
  542. u8 s_id[3]; /* FC vNIC only: Source S_ID */
  543. u8 lun[LUN_ADDRESS]; /* FC vNIC only: LUN address */
  544. u8 crn; /* SCSI Command Reference No. */
  545. u8 _resvd2[3]; /* reserved */
  546. u32 tmf_type; /* task management request type */
  547. };
  548. /*
  549. * Task Management request
  550. */
  551. #define FCPIO_TTMF_CLR_ACA 0x40 /* Clear ACA condition */
  552. #define FCPIO_TTMF_LUN_RESET 0x10 /* logical unit reset task mgmt */
  553. #define FCPIO_TTMF_CLR_TASK_SET 0x04 /* clear task set */
  554. #define FCPIO_TTMF_ABT_TASK_SET 0x02 /* abort task set */
  555. #define FCPIO_TTMF_ABT_TASK 0x01 /* abort task */
  556. /*
  557. * fcpio_tabort_cmpl: firmware -> host response
  558. *
  559. * used by the firmware to respond to a host's tabort request
  560. */
  561. struct fcpio_tabort_cmpl {
  562. u16 rx_id; /* rx_id of the target request */
  563. u16 _resvd0; /* reserved */
  564. };
  565. /*
  566. * fcpio_ack: firmware -> host response
  567. *
  568. * used by firmware to notify the host of the last work request received
  569. */
  570. struct fcpio_ack {
  571. u16 request_out; /* last host entry received */
  572. u16 _resvd;
  573. };
  574. /*
  575. * fcpio_reset_cmpl: firmware -> host response
  576. *
  577. * use by firmware to respond to the host's reset request
  578. */
  579. struct fcpio_reset_cmpl {
  580. u16 vnic_id;
  581. };
  582. /*
  583. * fcpio_flogi_reg_cmpl: firmware -> host response
  584. *
  585. * fc vnic only
  586. * response to the fcpio_flogi_reg request
  587. */
  588. struct fcpio_flogi_reg_cmpl {
  589. u32 _resvd;
  590. };
  591. /*
  592. * fcpio_echo_cmpl: firmware -> host response
  593. *
  594. * response to the fcpio_echo request
  595. */
  596. struct fcpio_echo_cmpl {
  597. u32 _resvd;
  598. };
  599. /*
  600. * fcpio_lunmap_chng: firmware -> host notification
  601. *
  602. * scsi vnic only
  603. * notifies the host that the lunmap tables have changed
  604. */
  605. struct fcpio_lunmap_chng {
  606. u32 _resvd;
  607. };
  608. /*
  609. * fcpio_lunmap_req_cmpl: firmware -> host response
  610. *
  611. * scsi vnic only
  612. * response for lunmap table request from the host
  613. */
  614. struct fcpio_lunmap_req_cmpl {
  615. u32 _resvd;
  616. };
  617. /*
  618. * Basic structure for all fcpio structures that are sent from the firmware to
  619. * the host. They are 64 bytes per structure.
  620. */
  621. #define FCPIO_FW_REQ_LEN 64 /* expected length of fw requests */
  622. struct fcpio_fw_req {
  623. struct fcpio_header hdr;
  624. union {
  625. /*
  626. * Defines space needed for request
  627. */
  628. u8 buf[FCPIO_FW_REQ_LEN - sizeof(struct fcpio_header)];
  629. /*
  630. * Initiator firmware responses
  631. */
  632. struct fcpio_icmnd_cmpl icmnd_cmpl;
  633. struct fcpio_itmf_cmpl itmf_cmpl;
  634. /*
  635. * Target firmware new requests
  636. */
  637. struct fcpio_tcmnd_16 tcmnd_16;
  638. struct fcpio_tcmnd_32 tcmnd_32;
  639. /*
  640. * Target firmware responses
  641. */
  642. struct fcpio_tdrsp_cmpl tdrsp_cmpl;
  643. struct fcpio_ttmf ttmf;
  644. struct fcpio_tabort_cmpl tabort_cmpl;
  645. /*
  646. * Firmware response to work received
  647. */
  648. struct fcpio_ack ack;
  649. /*
  650. * Misc requests
  651. */
  652. struct fcpio_reset_cmpl reset_cmpl;
  653. struct fcpio_flogi_reg_cmpl flogi_reg_cmpl;
  654. struct fcpio_echo_cmpl echo_cmpl;
  655. struct fcpio_lunmap_chng lunmap_chng;
  656. struct fcpio_lunmap_req_cmpl lunmap_req_cmpl;
  657. } u;
  658. };
  659. /*
  660. * Access routines to encode and decode the color bit, which is the most
  661. * significant bit of the MSB of the structure
  662. */
  663. static inline void fcpio_color_enc(struct fcpio_fw_req *fw_req, u8 color)
  664. {
  665. u8 *c = ((u8 *) fw_req) + sizeof(struct fcpio_fw_req) - 1;
  666. if (color)
  667. *c |= 0x80;
  668. else
  669. *c &= ~0x80;
  670. }
  671. static inline void fcpio_color_dec(struct fcpio_fw_req *fw_req, u8 *color)
  672. {
  673. u8 *c = ((u8 *) fw_req) + sizeof(struct fcpio_fw_req) - 1;
  674. *color = *c >> 7;
  675. /*
  676. * Make sure color bit is read from desc *before* other fields
  677. * are read from desc. Hardware guarantees color bit is last
  678. * bit (byte) written. Adding the rmb() prevents the compiler
  679. * and/or CPU from reordering the reads which would potentially
  680. * result in reading stale values.
  681. */
  682. rmb();
  683. }
  684. /*
  685. * Lunmap table entry for scsi vnics
  686. */
  687. #define FCPIO_LUNMAP_TABLE_SIZE 256
  688. #define FCPIO_FLAGS_LUNMAP_VALID 0x80
  689. #define FCPIO_FLAGS_BOOT 0x01
  690. struct fcpio_lunmap_entry {
  691. u8 bus;
  692. u8 target;
  693. u8 lun;
  694. u8 path_cnt;
  695. u16 flags;
  696. u16 update_cnt;
  697. };
  698. struct fcpio_lunmap_tbl {
  699. u32 update_cnt;
  700. struct fcpio_lunmap_entry lunmaps[FCPIO_LUNMAP_TABLE_SIZE];
  701. };
  702. #endif /* _FCPIO_H_ */