fcpio.h 22 KB

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