be_cmds.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902
  1. /**
  2. * Copyright (C) 2005 - 2009 ServerEngines
  3. * All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License version 2
  7. * as published by the Free Software Foundation. The full GNU General
  8. * Public License is included in this distribution in the file called COPYING.
  9. *
  10. * Contact Information:
  11. * linux-drivers@serverengines.com
  12. *
  13. * ServerEngines
  14. * 209 N. Fair Oaks Ave
  15. * Sunnyvale, CA 94085
  16. */
  17. #ifndef BEISCSI_CMDS_H
  18. #define BEISCSI_CMDS_H
  19. /**
  20. * The driver sends configuration and managements command requests to the
  21. * firmware in the BE. These requests are communicated to the processor
  22. * using Work Request Blocks (WRBs) submitted to the MCC-WRB ring or via one
  23. * WRB inside a MAILBOX.
  24. * The commands are serviced by the ARM processor in the BladeEngine's MPU.
  25. */
  26. struct be_sge {
  27. u32 pa_lo;
  28. u32 pa_hi;
  29. u32 len;
  30. };
  31. #define MCC_WRB_SGE_CNT_SHIFT 3 /* bits 3 - 7 of dword 0 */
  32. #define MCC_WRB_SGE_CNT_MASK 0x1F /* bits 3 - 7 of dword 0 */
  33. struct be_mcc_wrb {
  34. u32 embedded; /* dword 0 */
  35. u32 payload_length; /* dword 1 */
  36. u32 tag0; /* dword 2 */
  37. u32 tag1; /* dword 3 */
  38. u32 rsvd; /* dword 4 */
  39. union {
  40. u8 embedded_payload[236]; /* used by embedded cmds */
  41. struct be_sge sgl[19]; /* used by non-embedded cmds */
  42. } payload;
  43. };
  44. #define CQE_FLAGS_VALID_MASK (1 << 31)
  45. #define CQE_FLAGS_ASYNC_MASK (1 << 30)
  46. #define CQE_FLAGS_COMPLETED_MASK (1 << 28)
  47. #define CQE_FLAGS_CONSUMED_MASK (1 << 27)
  48. /* Completion Status */
  49. #define MCC_STATUS_SUCCESS 0x0
  50. #define CQE_STATUS_COMPL_MASK 0xFFFF
  51. #define CQE_STATUS_COMPL_SHIFT 0 /* bits 0 - 15 */
  52. #define CQE_STATUS_EXTD_MASK 0xFFFF
  53. #define CQE_STATUS_EXTD_SHIFT 0 /* bits 0 - 15 */
  54. struct be_mcc_compl {
  55. u32 status; /* dword 0 */
  56. u32 tag0; /* dword 1 */
  57. u32 tag1; /* dword 2 */
  58. u32 flags; /* dword 3 */
  59. };
  60. /********* Mailbox door bell *************/
  61. /**
  62. * Used for driver communication with the FW.
  63. * The software must write this register twice to post any command. First,
  64. * it writes the register with hi=1 and the upper bits of the physical address
  65. * for the MAILBOX structure. Software must poll the ready bit until this
  66. * is acknowledged. Then, sotware writes the register with hi=0 with the lower
  67. * bits in the address. It must poll the ready bit until the command is
  68. * complete. Upon completion, the MAILBOX will contain a valid completion
  69. * queue entry.
  70. */
  71. #define MPU_MAILBOX_DB_OFFSET 0x160
  72. #define MPU_MAILBOX_DB_RDY_MASK 0x1 /* bit 0 */
  73. #define MPU_MAILBOX_DB_HI_MASK 0x2 /* bit 1 */
  74. /********** MPU semphore ******************/
  75. #define MPU_EP_SEMAPHORE_OFFSET 0xac
  76. #define EP_SEMAPHORE_POST_STAGE_MASK 0x0000FFFF
  77. #define EP_SEMAPHORE_POST_ERR_MASK 0x1
  78. #define EP_SEMAPHORE_POST_ERR_SHIFT 31
  79. /********** MCC door bell ************/
  80. #define DB_MCCQ_OFFSET 0x140
  81. #define DB_MCCQ_RING_ID_MASK 0x7FF /* bits 0 - 10 */
  82. /* Number of entries posted */
  83. #define DB_MCCQ_NUM_POSTED_SHIFT 16 /* bits 16 - 29 */
  84. /* MPU semphore POST stage values */
  85. #define POST_STAGE_ARMFW_RDY 0xc000 /* FW is done with POST */
  86. /**
  87. * When the async bit of mcc_compl is set, the last 4 bytes of
  88. * mcc_compl is interpreted as follows:
  89. */
  90. #define ASYNC_TRAILER_EVENT_CODE_SHIFT 8 /* bits 8 - 15 */
  91. #define ASYNC_TRAILER_EVENT_CODE_MASK 0xFF
  92. #define ASYNC_EVENT_CODE_LINK_STATE 0x1
  93. struct be_async_event_trailer {
  94. u32 code;
  95. };
  96. enum {
  97. ASYNC_EVENT_LINK_DOWN = 0x0,
  98. ASYNC_EVENT_LINK_UP = 0x1
  99. };
  100. /**
  101. * When the event code of an async trailer is link-state, the mcc_compl
  102. * must be interpreted as follows
  103. */
  104. struct be_async_event_link_state {
  105. u8 physical_port;
  106. u8 port_link_status;
  107. u8 port_duplex;
  108. u8 port_speed;
  109. u8 port_fault;
  110. u8 rsvd0[7];
  111. struct be_async_event_trailer trailer;
  112. } __packed;
  113. struct be_mcc_mailbox {
  114. struct be_mcc_wrb wrb;
  115. struct be_mcc_compl compl;
  116. };
  117. /* Type of subsystems supported by FW */
  118. #define CMD_SUBSYSTEM_COMMON 0x1
  119. #define CMD_SUBSYSTEM_ISCSI 0x2
  120. #define CMD_SUBSYSTEM_ETH 0x3
  121. #define CMD_SUBSYSTEM_ISCSI_INI 0x6
  122. #define CMD_COMMON_TCP_UPLOAD 0x1
  123. /**
  124. * List of common opcodes subsystem CMD_SUBSYSTEM_COMMON
  125. * These opcodes are unique for each subsystem defined above
  126. */
  127. #define OPCODE_COMMON_CQ_CREATE 12
  128. #define OPCODE_COMMON_EQ_CREATE 13
  129. #define OPCODE_COMMON_MCC_CREATE 21
  130. #define OPCODE_COMMON_GET_CNTL_ATTRIBUTES 32
  131. #define OPCODE_COMMON_GET_FW_VERSION 35
  132. #define OPCODE_COMMON_MODIFY_EQ_DELAY 41
  133. #define OPCODE_COMMON_FIRMWARE_CONFIG 42
  134. #define OPCODE_COMMON_MCC_DESTROY 53
  135. #define OPCODE_COMMON_CQ_DESTROY 54
  136. #define OPCODE_COMMON_EQ_DESTROY 55
  137. #define OPCODE_COMMON_QUERY_FIRMWARE_CONFIG 58
  138. #define OPCODE_COMMON_FUNCTION_RESET 61
  139. /**
  140. * LIST of opcodes that are common between Initiator and Target
  141. * used by CMD_SUBSYSTEM_ISCSI
  142. * These opcodes are unique for each subsystem defined above
  143. */
  144. #define OPCODE_COMMON_ISCSI_CFG_POST_SGL_PAGES 2
  145. #define OPCODE_COMMON_ISCSI_CFG_REMOVE_SGL_PAGES 3
  146. #define OPCODE_COMMON_ISCSI_NTWK_GET_NIC_CONFIG 7
  147. #define OPCODE_COMMON_ISCSI_SET_FRAGNUM_BITS_FOR_SGL_CRA 61
  148. #define OPCODE_COMMON_ISCSI_DEFQ_CREATE 64
  149. #define OPCODE_COMMON_ISCSI_DEFQ_DESTROY 65
  150. #define OPCODE_COMMON_ISCSI_WRBQ_CREATE 66
  151. #define OPCODE_COMMON_ISCSI_WRBQ_DESTROY 67
  152. struct be_cmd_req_hdr {
  153. u8 opcode; /* dword 0 */
  154. u8 subsystem; /* dword 0 */
  155. u8 port_number; /* dword 0 */
  156. u8 domain; /* dword 0 */
  157. u32 timeout; /* dword 1 */
  158. u32 request_length; /* dword 2 */
  159. u32 rsvd0; /* dword 3 */
  160. };
  161. struct be_cmd_resp_hdr {
  162. u32 info; /* dword 0 */
  163. u32 status; /* dword 1 */
  164. u32 response_length; /* dword 2 */
  165. u32 actual_resp_len; /* dword 3 */
  166. };
  167. struct phys_addr {
  168. u32 lo;
  169. u32 hi;
  170. };
  171. /**************************
  172. * BE Command definitions *
  173. **************************/
  174. /**
  175. * Pseudo amap definition in which each bit of the actual structure is defined
  176. * as a byte - used to calculate offset/shift/mask of each field
  177. */
  178. struct amap_eq_context {
  179. u8 cidx[13]; /* dword 0 */
  180. u8 rsvd0[3]; /* dword 0 */
  181. u8 epidx[13]; /* dword 0 */
  182. u8 valid; /* dword 0 */
  183. u8 rsvd1; /* dword 0 */
  184. u8 size; /* dword 0 */
  185. u8 pidx[13]; /* dword 1 */
  186. u8 rsvd2[3]; /* dword 1 */
  187. u8 pd[10]; /* dword 1 */
  188. u8 count[3]; /* dword 1 */
  189. u8 solevent; /* dword 1 */
  190. u8 stalled; /* dword 1 */
  191. u8 armed; /* dword 1 */
  192. u8 rsvd3[4]; /* dword 2 */
  193. u8 func[8]; /* dword 2 */
  194. u8 rsvd4; /* dword 2 */
  195. u8 delaymult[10]; /* dword 2 */
  196. u8 rsvd5[2]; /* dword 2 */
  197. u8 phase[2]; /* dword 2 */
  198. u8 nodelay; /* dword 2 */
  199. u8 rsvd6[4]; /* dword 2 */
  200. u8 rsvd7[32]; /* dword 3 */
  201. } __packed;
  202. struct be_cmd_req_eq_create {
  203. struct be_cmd_req_hdr hdr; /* dw[4] */
  204. u16 num_pages; /* sword */
  205. u16 rsvd0; /* sword */
  206. u8 context[sizeof(struct amap_eq_context) / 8]; /* dw[4] */
  207. struct phys_addr pages[8];
  208. } __packed;
  209. struct be_cmd_resp_eq_create {
  210. struct be_cmd_resp_hdr resp_hdr;
  211. u16 eq_id; /* sword */
  212. u16 rsvd0; /* sword */
  213. } __packed;
  214. struct mac_addr {
  215. u16 size_of_struct;
  216. u8 addr[ETH_ALEN];
  217. } __packed;
  218. struct be_cmd_req_mac_query {
  219. struct be_cmd_req_hdr hdr;
  220. u8 type;
  221. u8 permanent;
  222. u16 if_id;
  223. } __packed;
  224. struct be_cmd_resp_mac_query {
  225. struct be_cmd_resp_hdr hdr;
  226. struct mac_addr mac;
  227. };
  228. /******************** Create CQ ***************************/
  229. /**
  230. * Pseudo amap definition in which each bit of the actual structure is defined
  231. * as a byte - used to calculate offset/shift/mask of each field
  232. */
  233. struct amap_cq_context {
  234. u8 cidx[11]; /* dword 0 */
  235. u8 rsvd0; /* dword 0 */
  236. u8 coalescwm[2]; /* dword 0 */
  237. u8 nodelay; /* dword 0 */
  238. u8 epidx[11]; /* dword 0 */
  239. u8 rsvd1; /* dword 0 */
  240. u8 count[2]; /* dword 0 */
  241. u8 valid; /* dword 0 */
  242. u8 solevent; /* dword 0 */
  243. u8 eventable; /* dword 0 */
  244. u8 pidx[11]; /* dword 1 */
  245. u8 rsvd2; /* dword 1 */
  246. u8 pd[10]; /* dword 1 */
  247. u8 eqid[8]; /* dword 1 */
  248. u8 stalled; /* dword 1 */
  249. u8 armed; /* dword 1 */
  250. u8 rsvd3[4]; /* dword 2 */
  251. u8 func[8]; /* dword 2 */
  252. u8 rsvd4[20]; /* dword 2 */
  253. u8 rsvd5[32]; /* dword 3 */
  254. } __packed;
  255. struct be_cmd_req_cq_create {
  256. struct be_cmd_req_hdr hdr;
  257. u16 num_pages;
  258. u16 rsvd0;
  259. u8 context[sizeof(struct amap_cq_context) / 8];
  260. struct phys_addr pages[4];
  261. } __packed;
  262. struct be_cmd_resp_cq_create {
  263. struct be_cmd_resp_hdr hdr;
  264. u16 cq_id;
  265. u16 rsvd0;
  266. } __packed;
  267. /******************** Create MCCQ ***************************/
  268. /**
  269. * Pseudo amap definition in which each bit of the actual structure is defined
  270. * as a byte - used to calculate offset/shift/mask of each field
  271. */
  272. struct amap_mcc_context {
  273. u8 con_index[14];
  274. u8 rsvd0[2];
  275. u8 ring_size[4];
  276. u8 fetch_wrb;
  277. u8 fetch_r2t;
  278. u8 cq_id[10];
  279. u8 prod_index[14];
  280. u8 fid[8];
  281. u8 pdid[9];
  282. u8 valid;
  283. u8 rsvd1[32];
  284. u8 rsvd2[32];
  285. } __packed;
  286. struct be_cmd_req_mcc_create {
  287. struct be_cmd_req_hdr hdr;
  288. u16 num_pages;
  289. u16 rsvd0;
  290. u8 context[sizeof(struct amap_mcc_context) / 8];
  291. struct phys_addr pages[8];
  292. } __packed;
  293. struct be_cmd_resp_mcc_create {
  294. struct be_cmd_resp_hdr hdr;
  295. u16 id;
  296. u16 rsvd0;
  297. } __packed;
  298. /******************** Q Destroy ***************************/
  299. /* Type of Queue to be destroyed */
  300. enum {
  301. QTYPE_EQ = 1,
  302. QTYPE_CQ,
  303. QTYPE_MCCQ,
  304. QTYPE_WRBQ,
  305. QTYPE_DPDUQ,
  306. QTYPE_SGL
  307. };
  308. struct be_cmd_req_q_destroy {
  309. struct be_cmd_req_hdr hdr;
  310. u16 id;
  311. u16 bypass_flush; /* valid only for rx q destroy */
  312. } __packed;
  313. struct macaddr {
  314. u8 byte[ETH_ALEN];
  315. };
  316. struct be_cmd_req_mcast_mac_config {
  317. struct be_cmd_req_hdr hdr;
  318. u16 num_mac;
  319. u8 promiscuous;
  320. u8 interface_id;
  321. struct macaddr mac[32];
  322. } __packed;
  323. static inline void *embedded_payload(struct be_mcc_wrb *wrb)
  324. {
  325. return wrb->payload.embedded_payload;
  326. }
  327. static inline struct be_sge *nonembedded_sgl(struct be_mcc_wrb *wrb)
  328. {
  329. return &wrb->payload.sgl[0];
  330. }
  331. /******************** Modify EQ Delay *******************/
  332. struct be_cmd_req_modify_eq_delay {
  333. struct be_cmd_req_hdr hdr;
  334. u32 num_eq;
  335. struct {
  336. u32 eq_id;
  337. u32 phase;
  338. u32 delay_multiplier;
  339. } delay[8];
  340. } __packed;
  341. /******************** Get MAC ADDR *******************/
  342. #define ETH_ALEN 6
  343. struct be_cmd_req_get_mac_addr {
  344. struct be_cmd_req_hdr hdr;
  345. u32 nic_port_count;
  346. u32 speed;
  347. u32 max_speed;
  348. u32 link_state;
  349. u32 max_frame_size;
  350. u16 size_of_structure;
  351. u8 mac_address[ETH_ALEN];
  352. u32 rsvd[23];
  353. };
  354. struct be_cmd_resp_get_mac_addr {
  355. struct be_cmd_resp_hdr hdr;
  356. u32 nic_port_count;
  357. u32 speed;
  358. u32 max_speed;
  359. u32 link_state;
  360. u32 max_frame_size;
  361. u16 size_of_structure;
  362. u8 mac_address[6];
  363. u32 rsvd[23];
  364. };
  365. int beiscsi_cmd_eq_create(struct be_ctrl_info *ctrl,
  366. struct be_queue_info *eq, int eq_delay);
  367. int beiscsi_cmd_cq_create(struct be_ctrl_info *ctrl,
  368. struct be_queue_info *cq, struct be_queue_info *eq,
  369. bool sol_evts, bool no_delay,
  370. int num_cqe_dma_coalesce);
  371. int beiscsi_cmd_q_destroy(struct be_ctrl_info *ctrl, struct be_queue_info *q,
  372. int type);
  373. int beiscsi_cmd_mccq_create(struct beiscsi_hba *phba,
  374. struct be_queue_info *mccq,
  375. struct be_queue_info *cq);
  376. int be_poll_mcc(struct be_ctrl_info *ctrl);
  377. unsigned char mgmt_check_supported_fw(struct be_ctrl_info *ctrl,
  378. struct beiscsi_hba *phba);
  379. int be_cmd_get_mac_addr(struct beiscsi_hba *phba, u8 *mac_addr);
  380. /*ISCSI Functuions */
  381. int be_cmd_fw_initialize(struct be_ctrl_info *ctrl);
  382. struct be_mcc_wrb *wrb_from_mbox(struct be_dma_mem *mbox_mem);
  383. struct be_mcc_wrb *wrb_from_mccq(struct beiscsi_hba *phba);
  384. int be_mcc_notify_wait(struct beiscsi_hba *phba);
  385. int be_mbox_notify(struct be_ctrl_info *ctrl);
  386. int be_cmd_create_default_pdu_queue(struct be_ctrl_info *ctrl,
  387. struct be_queue_info *cq,
  388. struct be_queue_info *dq, int length,
  389. int entry_size);
  390. int be_cmd_iscsi_post_sgl_pages(struct be_ctrl_info *ctrl,
  391. struct be_dma_mem *q_mem, u32 page_offset,
  392. u32 num_pages);
  393. int be_cmd_wrbq_create(struct be_ctrl_info *ctrl, struct be_dma_mem *q_mem,
  394. struct be_queue_info *wrbq);
  395. struct be_default_pdu_context {
  396. u32 dw[4];
  397. } __packed;
  398. struct amap_be_default_pdu_context {
  399. u8 dbuf_cindex[13]; /* dword 0 */
  400. u8 rsvd0[3]; /* dword 0 */
  401. u8 ring_size[4]; /* dword 0 */
  402. u8 ring_state[4]; /* dword 0 */
  403. u8 rsvd1[8]; /* dword 0 */
  404. u8 dbuf_pindex[13]; /* dword 1 */
  405. u8 rsvd2; /* dword 1 */
  406. u8 pci_func_id[8]; /* dword 1 */
  407. u8 rx_pdid[9]; /* dword 1 */
  408. u8 rx_pdid_valid; /* dword 1 */
  409. u8 default_buffer_size[16]; /* dword 2 */
  410. u8 cq_id_recv[10]; /* dword 2 */
  411. u8 rx_pdid_not_valid; /* dword 2 */
  412. u8 rsvd3[5]; /* dword 2 */
  413. u8 rsvd4[32]; /* dword 3 */
  414. } __packed;
  415. struct be_defq_create_req {
  416. struct be_cmd_req_hdr hdr;
  417. u16 num_pages;
  418. u8 ulp_num;
  419. u8 rsvd0;
  420. struct be_default_pdu_context context;
  421. struct phys_addr pages[8];
  422. } __packed;
  423. struct be_defq_create_resp {
  424. struct be_cmd_req_hdr hdr;
  425. u16 id;
  426. u16 rsvd0;
  427. } __packed;
  428. struct be_post_sgl_pages_req {
  429. struct be_cmd_req_hdr hdr;
  430. u16 num_pages;
  431. u16 page_offset;
  432. u32 rsvd0;
  433. struct phys_addr pages[26];
  434. u32 rsvd1;
  435. } __packed;
  436. struct be_wrbq_create_req {
  437. struct be_cmd_req_hdr hdr;
  438. u16 num_pages;
  439. u8 ulp_num;
  440. u8 rsvd0;
  441. struct phys_addr pages[8];
  442. } __packed;
  443. struct be_wrbq_create_resp {
  444. struct be_cmd_resp_hdr resp_hdr;
  445. u16 cid;
  446. u16 rsvd0;
  447. } __packed;
  448. #define SOL_CID_MASK 0x0000FFC0
  449. #define SOL_CODE_MASK 0x0000003F
  450. #define SOL_WRB_INDEX_MASK 0x00FF0000
  451. #define SOL_CMD_WND_MASK 0xFF000000
  452. #define SOL_RES_CNT_MASK 0x7FFFFFFF
  453. #define SOL_EXP_CMD_SN_MASK 0xFFFFFFFF
  454. #define SOL_HW_STS_MASK 0x000000FF
  455. #define SOL_STS_MASK 0x0000FF00
  456. #define SOL_RESP_MASK 0x00FF0000
  457. #define SOL_FLAGS_MASK 0x7F000000
  458. #define SOL_S_MASK 0x80000000
  459. struct sol_cqe {
  460. u32 dw[4];
  461. };
  462. struct amap_sol_cqe {
  463. u8 hw_sts[8]; /* dword 0 */
  464. u8 i_sts[8]; /* dword 0 */
  465. u8 i_resp[8]; /* dword 0 */
  466. u8 i_flags[7]; /* dword 0 */
  467. u8 s; /* dword 0 */
  468. u8 i_exp_cmd_sn[32]; /* dword 1 */
  469. u8 code[6]; /* dword 2 */
  470. u8 cid[10]; /* dword 2 */
  471. u8 wrb_index[8]; /* dword 2 */
  472. u8 i_cmd_wnd[8]; /* dword 2 */
  473. u8 i_res_cnt[31]; /* dword 3 */
  474. u8 valid; /* dword 3 */
  475. } __packed;
  476. #define SOL_ICD_INDEX_MASK 0x0003FFC0
  477. struct amap_sol_cqe_ring {
  478. u8 hw_sts[8]; /* dword 0 */
  479. u8 i_sts[8]; /* dword 0 */
  480. u8 i_resp[8]; /* dword 0 */
  481. u8 i_flags[7]; /* dword 0 */
  482. u8 s; /* dword 0 */
  483. u8 i_exp_cmd_sn[32]; /* dword 1 */
  484. u8 code[6]; /* dword 2 */
  485. u8 icd_index[12]; /* dword 2 */
  486. u8 rsvd[6]; /* dword 2 */
  487. u8 i_cmd_wnd[8]; /* dword 2 */
  488. u8 i_res_cnt[31]; /* dword 3 */
  489. u8 valid; /* dword 3 */
  490. } __packed;
  491. /**
  492. * Post WRB Queue Doorbell Register used by the host Storage
  493. * stack to notify the
  494. * controller of a posted Work Request Block
  495. */
  496. #define DB_WRB_POST_CID_MASK 0x3FF /* bits 0 - 9 */
  497. #define DB_DEF_PDU_WRB_INDEX_MASK 0xFF /* bits 0 - 9 */
  498. #define DB_DEF_PDU_WRB_INDEX_SHIFT 16
  499. #define DB_DEF_PDU_NUM_POSTED_SHIFT 24
  500. struct fragnum_bits_for_sgl_cra_in {
  501. struct be_cmd_req_hdr hdr;
  502. u32 num_bits;
  503. } __packed;
  504. struct iscsi_cleanup_req {
  505. struct be_cmd_req_hdr hdr;
  506. u16 chute;
  507. u8 hdr_ring_id;
  508. u8 data_ring_id;
  509. } __packed;
  510. struct eq_delay {
  511. u32 eq_id;
  512. u32 phase;
  513. u32 delay_multiplier;
  514. } __packed;
  515. struct be_eq_delay_params_in {
  516. struct be_cmd_req_hdr hdr;
  517. u32 num_eq;
  518. struct eq_delay delay[8];
  519. } __packed;
  520. struct ip_address_format {
  521. u16 size_of_structure;
  522. u8 reserved;
  523. u8 ip_type;
  524. u8 ip_address[16];
  525. u32 rsvd0;
  526. } __packed;
  527. struct tcp_connect_and_offload_in {
  528. struct be_cmd_req_hdr hdr;
  529. struct ip_address_format ip_address;
  530. u16 tcp_port;
  531. u16 cid;
  532. u16 cq_id;
  533. u16 defq_id;
  534. struct phys_addr dataout_template_pa;
  535. u16 hdr_ring_id;
  536. u16 data_ring_id;
  537. u8 do_offload;
  538. u8 rsvd0[3];
  539. } __packed;
  540. struct tcp_connect_and_offload_out {
  541. struct be_cmd_resp_hdr hdr;
  542. u32 connection_handle;
  543. u16 cid;
  544. u16 rsvd0;
  545. } __packed;
  546. struct be_mcc_wrb_context {
  547. struct MCC_WRB *wrb;
  548. int *users_final_status;
  549. } __packed;
  550. #define DB_DEF_PDU_RING_ID_MASK 0x3FF /* bits 0 - 9 */
  551. #define DB_DEF_PDU_CQPROC_MASK 0x3FFF /* bits 0 - 9 */
  552. #define DB_DEF_PDU_REARM_SHIFT 14
  553. #define DB_DEF_PDU_EVENT_SHIFT 15
  554. #define DB_DEF_PDU_CQPROC_SHIFT 16
  555. struct dmsg_cqe {
  556. u32 dw[4];
  557. } __packed;
  558. struct tcp_upload_params_in {
  559. struct be_cmd_req_hdr hdr;
  560. u16 id;
  561. u16 upload_type;
  562. u32 reset_seq;
  563. } __packed;
  564. struct tcp_upload_params_out {
  565. u32 dw[32];
  566. } __packed;
  567. union tcp_upload_params {
  568. struct tcp_upload_params_in request;
  569. struct tcp_upload_params_out response;
  570. } __packed;
  571. struct be_ulp_fw_cfg {
  572. u32 ulp_mode;
  573. u32 etx_base;
  574. u32 etx_count;
  575. u32 sq_base;
  576. u32 sq_count;
  577. u32 rq_base;
  578. u32 rq_count;
  579. u32 dq_base;
  580. u32 dq_count;
  581. u32 lro_base;
  582. u32 lro_count;
  583. u32 icd_base;
  584. u32 icd_count;
  585. };
  586. struct be_fw_cfg {
  587. struct be_cmd_req_hdr hdr;
  588. u32 be_config_number;
  589. u32 asic_revision;
  590. u32 phys_port;
  591. u32 function_mode;
  592. struct be_ulp_fw_cfg ulp[2];
  593. u32 function_caps;
  594. } __packed;
  595. #define CMD_ISCSI_COMMAND_INVALIDATE 1
  596. #define ISCSI_OPCODE_SCSI_DATA_OUT 5
  597. #define OPCODE_COMMON_ISCSI_TCP_CONNECT_AND_OFFLOAD 70
  598. #define OPCODE_ISCSI_INI_DRIVER_OFFLOAD_SESSION 41
  599. #define OPCODE_COMMON_MODIFY_EQ_DELAY 41
  600. #define OPCODE_COMMON_ISCSI_CLEANUP 59
  601. #define OPCODE_COMMON_TCP_UPLOAD 56
  602. #define OPCODE_COMMON_ISCSI_ERROR_RECOVERY_INVALIDATE_COMMANDS 1
  603. /* --- CMD_ISCSI_INVALIDATE_CONNECTION_TYPE --- */
  604. #define CMD_ISCSI_CONNECTION_INVALIDATE 0x8001
  605. #define CMD_ISCSI_CONNECTION_ISSUE_TCP_RST 0x8002
  606. #define OPCODE_ISCSI_INI_DRIVER_INVALIDATE_CONNECTION 42
  607. #define INI_WR_CMD 1 /* Initiator write command */
  608. #define INI_TMF_CMD 2 /* Initiator TMF command */
  609. #define INI_NOPOUT_CMD 3 /* Initiator; Send a NOP-OUT */
  610. #define INI_RD_CMD 5 /* Initiator requesting to send
  611. * a read command
  612. */
  613. #define TGT_CTX_UPDT_CMD 7 /* Target context update */
  614. #define TGT_STS_CMD 8 /* Target R2T and other BHS
  615. * where only the status number
  616. * need to be updated
  617. */
  618. #define TGT_DATAIN_CMD 9 /* Target Data-Ins in response
  619. * to read command
  620. */
  621. #define TGT_SOS_PDU 10 /* Target:standalone status
  622. * response
  623. */
  624. #define TGT_DM_CMD 11 /* Indicates that the bhs
  625. * preparedby
  626. * driver should not be touched
  627. */
  628. /* --- CMD_CHUTE_TYPE --- */
  629. #define CMD_CONNECTION_CHUTE_0 1
  630. #define CMD_CONNECTION_CHUTE_1 2
  631. #define CMD_CONNECTION_CHUTE_2 3
  632. #define EQ_MAJOR_CODE_COMPLETION 0
  633. #define CMD_ISCSI_SESSION_DEL_CFG_FROM_FLASH 0
  634. #define CMD_ISCSI_SESSION_SAVE_CFG_ON_FLASH 1
  635. /* --- CONNECTION_UPLOAD_PARAMS --- */
  636. /* These parameters are used to define the type of upload desired. */
  637. #define CONNECTION_UPLOAD_GRACEFUL 1 /* Graceful upload */
  638. #define CONNECTION_UPLOAD_ABORT_RESET 2 /* Abortive upload with
  639. * reset
  640. */
  641. #define CONNECTION_UPLOAD_ABORT 3 /* Abortive upload without
  642. * reset
  643. */
  644. #define CONNECTION_UPLOAD_ABORT_WITH_SEQ 4 /* Abortive upload with reset,
  645. * sequence number by driver */
  646. /* Returns byte size of given field with a structure. */
  647. /* Returns the number of items in the field array. */
  648. #define BE_NUMBER_OF_FIELD(_type_, _field_) \
  649. (FIELD_SIZEOF(_type_, _field_)/sizeof((((_type_ *)0)->_field_[0])))\
  650. /**
  651. * Different types of iSCSI completions to host driver for both initiator
  652. * and taget mode
  653. * of operation.
  654. */
  655. #define SOL_CMD_COMPLETE 1 /* Solicited command completed
  656. * normally
  657. */
  658. #define SOL_CMD_KILLED_DATA_DIGEST_ERR 2 /* Solicited command got
  659. * invalidated internally due
  660. * to Data Digest error
  661. */
  662. #define CXN_KILLED_PDU_SIZE_EXCEEDS_DSL 3 /* Connection got invalidated
  663. * internally
  664. * due to a recieved PDU
  665. * size > DSL
  666. */
  667. #define CXN_KILLED_BURST_LEN_MISMATCH 4 /* Connection got invalidated
  668. * internally due ti received
  669. * PDU sequence size >
  670. * FBL/MBL.
  671. */
  672. #define CXN_KILLED_AHS_RCVD 5 /* Connection got invalidated
  673. * internally due to a recieved
  674. * PDU Hdr that has
  675. * AHS */
  676. #define CXN_KILLED_HDR_DIGEST_ERR 6 /* Connection got invalidated
  677. * internally due to Hdr Digest
  678. * error
  679. */
  680. #define CXN_KILLED_UNKNOWN_HDR 7 /* Connection got invalidated
  681. * internally
  682. * due to a bad opcode in the
  683. * pdu hdr
  684. */
  685. #define CXN_KILLED_STALE_ITT_TTT_RCVD 8 /* Connection got invalidated
  686. * internally due to a recieved
  687. * ITT/TTT that does not belong
  688. * to this Connection
  689. */
  690. #define CXN_KILLED_INVALID_ITT_TTT_RCVD 9 /* Connection got invalidated
  691. * internally due to recieved
  692. * ITT/TTT value > Max
  693. * Supported ITTs/TTTs
  694. */
  695. #define CXN_KILLED_RST_RCVD 10 /* Connection got invalidated
  696. * internally due to an
  697. * incoming TCP RST
  698. */
  699. #define CXN_KILLED_TIMED_OUT 11 /* Connection got invalidated
  700. * internally due to timeout on
  701. * tcp segment 12 retransmit
  702. * attempts failed
  703. */
  704. #define CXN_KILLED_RST_SENT 12 /* Connection got invalidated
  705. * internally due to TCP RST
  706. * sent by the Tx side
  707. */
  708. #define CXN_KILLED_FIN_RCVD 13 /* Connection got invalidated
  709. * internally due to an
  710. * incoming TCP FIN.
  711. */
  712. #define CXN_KILLED_BAD_UNSOL_PDU_RCVD 14 /* Connection got invalidated
  713. * internally due to bad
  714. * unsolicited PDU Unsolicited
  715. * PDUs are PDUs with
  716. * ITT=0xffffffff
  717. */
  718. #define CXN_KILLED_BAD_WRB_INDEX_ERROR 15 /* Connection got invalidated
  719. * internally due to bad WRB
  720. * index.
  721. */
  722. #define CXN_KILLED_OVER_RUN_RESIDUAL 16 /* Command got invalidated
  723. * internally due to recived
  724. * command has residual
  725. * over run bytes.
  726. */
  727. #define CXN_KILLED_UNDER_RUN_RESIDUAL 17 /* Command got invalidated
  728. * internally due to recived
  729. * command has residual under
  730. * run bytes.
  731. */
  732. #define CMD_KILLED_INVALID_STATSN_RCVD 18 /* Command got invalidated
  733. * internally due to a recieved
  734. * PDU has an invalid StatusSN
  735. */
  736. #define CMD_KILLED_INVALID_R2T_RCVD 19 /* Command got invalidated
  737. * internally due to a recieved
  738. * an R2T with some invalid
  739. * fields in it
  740. */
  741. #define CMD_CXN_KILLED_LUN_INVALID 20 /* Command got invalidated
  742. * internally due to received
  743. * PDU has an invalid LUN.
  744. */
  745. #define CMD_CXN_KILLED_ICD_INVALID 21 /* Command got invalidated
  746. * internally due to the
  747. * corresponding ICD not in a
  748. * valid state
  749. */
  750. #define CMD_CXN_KILLED_ITT_INVALID 22 /* Command got invalidated due
  751. * to received PDU has an
  752. * invalid ITT.
  753. */
  754. #define CMD_CXN_KILLED_SEQ_OUTOFORDER 23 /* Command got invalidated due
  755. * to received sequence buffer
  756. * offset is out of order.
  757. */
  758. #define CMD_CXN_KILLED_INVALID_DATASN_RCVD 24 /* Command got invalidated
  759. * internally due to a
  760. * recieved PDU has an invalid
  761. * DataSN
  762. */
  763. #define CXN_INVALIDATE_NOTIFY 25 /* Connection invalidation
  764. * completion notify.
  765. */
  766. #define CXN_INVALIDATE_INDEX_NOTIFY 26 /* Connection invalidation
  767. * completion
  768. * with data PDU index.
  769. */
  770. #define CMD_INVALIDATED_NOTIFY 27 /* Command invalidation
  771. * completionnotifify.
  772. */
  773. #define UNSOL_HDR_NOTIFY 28 /* Unsolicited header notify.*/
  774. #define UNSOL_DATA_NOTIFY 29 /* Unsolicited data notify.*/
  775. #define UNSOL_DATA_DIGEST_ERROR_NOTIFY 30 /* Unsolicited data digest
  776. * error notify.
  777. */
  778. #define DRIVERMSG_NOTIFY 31 /* TCP acknowledge based
  779. * notification.
  780. */
  781. #define CXN_KILLED_CMND_DATA_NOT_ON_SAME_CONN 32 /* Connection got invalidated
  782. * internally due to command
  783. * and data are not on same
  784. * connection.
  785. */
  786. #define SOL_CMD_KILLED_DIF_ERR 33 /* Solicited command got
  787. * invalidated internally due
  788. * to DIF error
  789. */
  790. #define CXN_KILLED_SYN_RCVD 34 /* Connection got invalidated
  791. * internally due to incoming
  792. * TCP SYN
  793. */
  794. #define CXN_KILLED_IMM_DATA_RCVD 35 /* Connection got invalidated
  795. * internally due to an
  796. * incoming Unsolicited PDU
  797. * that has immediate data on
  798. * the cxn
  799. */
  800. void be_wrb_hdr_prepare(struct be_mcc_wrb *wrb, int payload_len,
  801. bool embedded, u8 sge_cnt);
  802. void be_cmd_hdr_prepare(struct be_cmd_req_hdr *req_hdr,
  803. u8 subsystem, u8 opcode, int cmd_len);
  804. #endif /* !BEISCSI_CMDS_H */