be_cmds.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913
  1. /**
  2. * Copyright (C) 2005 - 2010 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 16 /* 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. int mgmt_check_supported_fw(struct be_ctrl_info *ctrl,
  378. struct beiscsi_hba *phba);
  379. unsigned int be_cmd_get_mac_addr(struct beiscsi_hba *phba);
  380. void free_mcc_tag(struct be_ctrl_info *ctrl, unsigned int tag);
  381. /*ISCSI Functuions */
  382. int be_cmd_fw_initialize(struct be_ctrl_info *ctrl);
  383. struct be_mcc_wrb *wrb_from_mbox(struct be_dma_mem *mbox_mem);
  384. struct be_mcc_wrb *wrb_from_mccq(struct beiscsi_hba *phba);
  385. int be_mcc_notify_wait(struct beiscsi_hba *phba);
  386. void be_mcc_notify(struct beiscsi_hba *phba);
  387. unsigned int alloc_mcc_tag(struct beiscsi_hba *phba);
  388. void beiscsi_async_link_state_process(struct beiscsi_hba *phba,
  389. struct be_async_event_link_state *evt);
  390. int be_mcc_compl_process_isr(struct be_ctrl_info *ctrl,
  391. struct be_mcc_compl *compl);
  392. int be_mbox_notify(struct be_ctrl_info *ctrl);
  393. int be_cmd_create_default_pdu_queue(struct be_ctrl_info *ctrl,
  394. struct be_queue_info *cq,
  395. struct be_queue_info *dq, int length,
  396. int entry_size);
  397. int be_cmd_iscsi_post_sgl_pages(struct be_ctrl_info *ctrl,
  398. struct be_dma_mem *q_mem, u32 page_offset,
  399. u32 num_pages);
  400. int be_cmd_wrbq_create(struct be_ctrl_info *ctrl, struct be_dma_mem *q_mem,
  401. struct be_queue_info *wrbq);
  402. bool is_link_state_evt(u32 trailer);
  403. struct be_default_pdu_context {
  404. u32 dw[4];
  405. } __packed;
  406. struct amap_be_default_pdu_context {
  407. u8 dbuf_cindex[13]; /* dword 0 */
  408. u8 rsvd0[3]; /* dword 0 */
  409. u8 ring_size[4]; /* dword 0 */
  410. u8 ring_state[4]; /* dword 0 */
  411. u8 rsvd1[8]; /* dword 0 */
  412. u8 dbuf_pindex[13]; /* dword 1 */
  413. u8 rsvd2; /* dword 1 */
  414. u8 pci_func_id[8]; /* dword 1 */
  415. u8 rx_pdid[9]; /* dword 1 */
  416. u8 rx_pdid_valid; /* dword 1 */
  417. u8 default_buffer_size[16]; /* dword 2 */
  418. u8 cq_id_recv[10]; /* dword 2 */
  419. u8 rx_pdid_not_valid; /* dword 2 */
  420. u8 rsvd3[5]; /* dword 2 */
  421. u8 rsvd4[32]; /* dword 3 */
  422. } __packed;
  423. struct be_defq_create_req {
  424. struct be_cmd_req_hdr hdr;
  425. u16 num_pages;
  426. u8 ulp_num;
  427. u8 rsvd0;
  428. struct be_default_pdu_context context;
  429. struct phys_addr pages[8];
  430. } __packed;
  431. struct be_defq_create_resp {
  432. struct be_cmd_req_hdr hdr;
  433. u16 id;
  434. u16 rsvd0;
  435. } __packed;
  436. struct be_post_sgl_pages_req {
  437. struct be_cmd_req_hdr hdr;
  438. u16 num_pages;
  439. u16 page_offset;
  440. u32 rsvd0;
  441. struct phys_addr pages[26];
  442. u32 rsvd1;
  443. } __packed;
  444. struct be_wrbq_create_req {
  445. struct be_cmd_req_hdr hdr;
  446. u16 num_pages;
  447. u8 ulp_num;
  448. u8 rsvd0;
  449. struct phys_addr pages[8];
  450. } __packed;
  451. struct be_wrbq_create_resp {
  452. struct be_cmd_resp_hdr resp_hdr;
  453. u16 cid;
  454. u16 rsvd0;
  455. } __packed;
  456. #define SOL_CID_MASK 0x0000FFC0
  457. #define SOL_CODE_MASK 0x0000003F
  458. #define SOL_WRB_INDEX_MASK 0x00FF0000
  459. #define SOL_CMD_WND_MASK 0xFF000000
  460. #define SOL_RES_CNT_MASK 0x7FFFFFFF
  461. #define SOL_EXP_CMD_SN_MASK 0xFFFFFFFF
  462. #define SOL_HW_STS_MASK 0x000000FF
  463. #define SOL_STS_MASK 0x0000FF00
  464. #define SOL_RESP_MASK 0x00FF0000
  465. #define SOL_FLAGS_MASK 0x7F000000
  466. #define SOL_S_MASK 0x80000000
  467. struct sol_cqe {
  468. u32 dw[4];
  469. };
  470. struct amap_sol_cqe {
  471. u8 hw_sts[8]; /* dword 0 */
  472. u8 i_sts[8]; /* dword 0 */
  473. u8 i_resp[8]; /* dword 0 */
  474. u8 i_flags[7]; /* dword 0 */
  475. u8 s; /* dword 0 */
  476. u8 i_exp_cmd_sn[32]; /* dword 1 */
  477. u8 code[6]; /* dword 2 */
  478. u8 cid[10]; /* dword 2 */
  479. u8 wrb_index[8]; /* dword 2 */
  480. u8 i_cmd_wnd[8]; /* dword 2 */
  481. u8 i_res_cnt[31]; /* dword 3 */
  482. u8 valid; /* dword 3 */
  483. } __packed;
  484. #define SOL_ICD_INDEX_MASK 0x0003FFC0
  485. struct amap_sol_cqe_ring {
  486. u8 hw_sts[8]; /* dword 0 */
  487. u8 i_sts[8]; /* dword 0 */
  488. u8 i_resp[8]; /* dword 0 */
  489. u8 i_flags[7]; /* dword 0 */
  490. u8 s; /* dword 0 */
  491. u8 i_exp_cmd_sn[32]; /* dword 1 */
  492. u8 code[6]; /* dword 2 */
  493. u8 icd_index[12]; /* dword 2 */
  494. u8 rsvd[6]; /* dword 2 */
  495. u8 i_cmd_wnd[8]; /* dword 2 */
  496. u8 i_res_cnt[31]; /* dword 3 */
  497. u8 valid; /* dword 3 */
  498. } __packed;
  499. /**
  500. * Post WRB Queue Doorbell Register used by the host Storage
  501. * stack to notify the
  502. * controller of a posted Work Request Block
  503. */
  504. #define DB_WRB_POST_CID_MASK 0x3FF /* bits 0 - 9 */
  505. #define DB_DEF_PDU_WRB_INDEX_MASK 0xFF /* bits 0 - 9 */
  506. #define DB_DEF_PDU_WRB_INDEX_SHIFT 16
  507. #define DB_DEF_PDU_NUM_POSTED_SHIFT 24
  508. struct fragnum_bits_for_sgl_cra_in {
  509. struct be_cmd_req_hdr hdr;
  510. u32 num_bits;
  511. } __packed;
  512. struct iscsi_cleanup_req {
  513. struct be_cmd_req_hdr hdr;
  514. u16 chute;
  515. u8 hdr_ring_id;
  516. u8 data_ring_id;
  517. } __packed;
  518. struct eq_delay {
  519. u32 eq_id;
  520. u32 phase;
  521. u32 delay_multiplier;
  522. } __packed;
  523. struct be_eq_delay_params_in {
  524. struct be_cmd_req_hdr hdr;
  525. u32 num_eq;
  526. struct eq_delay delay[8];
  527. } __packed;
  528. struct ip_address_format {
  529. u16 size_of_structure;
  530. u8 reserved;
  531. u8 ip_type;
  532. u8 ip_address[16];
  533. u32 rsvd0;
  534. } __packed;
  535. struct tcp_connect_and_offload_in {
  536. struct be_cmd_req_hdr hdr;
  537. struct ip_address_format ip_address;
  538. u16 tcp_port;
  539. u16 cid;
  540. u16 cq_id;
  541. u16 defq_id;
  542. struct phys_addr dataout_template_pa;
  543. u16 hdr_ring_id;
  544. u16 data_ring_id;
  545. u8 do_offload;
  546. u8 rsvd0[3];
  547. } __packed;
  548. struct tcp_connect_and_offload_out {
  549. struct be_cmd_resp_hdr hdr;
  550. u32 connection_handle;
  551. u16 cid;
  552. u16 rsvd0;
  553. } __packed;
  554. struct be_mcc_wrb_context {
  555. struct MCC_WRB *wrb;
  556. int *users_final_status;
  557. } __packed;
  558. #define DB_DEF_PDU_RING_ID_MASK 0x3FF /* bits 0 - 9 */
  559. #define DB_DEF_PDU_CQPROC_MASK 0x3FFF /* bits 0 - 9 */
  560. #define DB_DEF_PDU_REARM_SHIFT 14
  561. #define DB_DEF_PDU_EVENT_SHIFT 15
  562. #define DB_DEF_PDU_CQPROC_SHIFT 16
  563. struct dmsg_cqe {
  564. u32 dw[4];
  565. } __packed;
  566. struct tcp_upload_params_in {
  567. struct be_cmd_req_hdr hdr;
  568. u16 id;
  569. u16 upload_type;
  570. u32 reset_seq;
  571. } __packed;
  572. struct tcp_upload_params_out {
  573. u32 dw[32];
  574. } __packed;
  575. union tcp_upload_params {
  576. struct tcp_upload_params_in request;
  577. struct tcp_upload_params_out response;
  578. } __packed;
  579. struct be_ulp_fw_cfg {
  580. u32 ulp_mode;
  581. u32 etx_base;
  582. u32 etx_count;
  583. u32 sq_base;
  584. u32 sq_count;
  585. u32 rq_base;
  586. u32 rq_count;
  587. u32 dq_base;
  588. u32 dq_count;
  589. u32 lro_base;
  590. u32 lro_count;
  591. u32 icd_base;
  592. u32 icd_count;
  593. };
  594. struct be_fw_cfg {
  595. struct be_cmd_req_hdr hdr;
  596. u32 be_config_number;
  597. u32 asic_revision;
  598. u32 phys_port;
  599. u32 function_mode;
  600. struct be_ulp_fw_cfg ulp[2];
  601. u32 function_caps;
  602. } __packed;
  603. #define CMD_ISCSI_COMMAND_INVALIDATE 1
  604. #define ISCSI_OPCODE_SCSI_DATA_OUT 5
  605. #define OPCODE_COMMON_ISCSI_TCP_CONNECT_AND_OFFLOAD 70
  606. #define OPCODE_ISCSI_INI_DRIVER_OFFLOAD_SESSION 41
  607. #define OPCODE_COMMON_MODIFY_EQ_DELAY 41
  608. #define OPCODE_COMMON_ISCSI_CLEANUP 59
  609. #define OPCODE_COMMON_TCP_UPLOAD 56
  610. #define OPCODE_COMMON_ISCSI_ERROR_RECOVERY_INVALIDATE_COMMANDS 1
  611. /* --- CMD_ISCSI_INVALIDATE_CONNECTION_TYPE --- */
  612. #define CMD_ISCSI_CONNECTION_INVALIDATE 0x8001
  613. #define CMD_ISCSI_CONNECTION_ISSUE_TCP_RST 0x8002
  614. #define OPCODE_ISCSI_INI_DRIVER_INVALIDATE_CONNECTION 42
  615. #define INI_WR_CMD 1 /* Initiator write command */
  616. #define INI_TMF_CMD 2 /* Initiator TMF command */
  617. #define INI_NOPOUT_CMD 3 /* Initiator; Send a NOP-OUT */
  618. #define INI_RD_CMD 5 /* Initiator requesting to send
  619. * a read command
  620. */
  621. #define TGT_CTX_UPDT_CMD 7 /* Target context update */
  622. #define TGT_STS_CMD 8 /* Target R2T and other BHS
  623. * where only the status number
  624. * need to be updated
  625. */
  626. #define TGT_DATAIN_CMD 9 /* Target Data-Ins in response
  627. * to read command
  628. */
  629. #define TGT_SOS_PDU 10 /* Target:standalone status
  630. * response
  631. */
  632. #define TGT_DM_CMD 11 /* Indicates that the bhs
  633. * preparedby
  634. * driver should not be touched
  635. */
  636. /* --- CMD_CHUTE_TYPE --- */
  637. #define CMD_CONNECTION_CHUTE_0 1
  638. #define CMD_CONNECTION_CHUTE_1 2
  639. #define CMD_CONNECTION_CHUTE_2 3
  640. #define EQ_MAJOR_CODE_COMPLETION 0
  641. #define CMD_ISCSI_SESSION_DEL_CFG_FROM_FLASH 0
  642. #define CMD_ISCSI_SESSION_SAVE_CFG_ON_FLASH 1
  643. /* --- CONNECTION_UPLOAD_PARAMS --- */
  644. /* These parameters are used to define the type of upload desired. */
  645. #define CONNECTION_UPLOAD_GRACEFUL 1 /* Graceful upload */
  646. #define CONNECTION_UPLOAD_ABORT_RESET 2 /* Abortive upload with
  647. * reset
  648. */
  649. #define CONNECTION_UPLOAD_ABORT 3 /* Abortive upload without
  650. * reset
  651. */
  652. #define CONNECTION_UPLOAD_ABORT_WITH_SEQ 4 /* Abortive upload with reset,
  653. * sequence number by driver */
  654. /* Returns byte size of given field with a structure. */
  655. /* Returns the number of items in the field array. */
  656. #define BE_NUMBER_OF_FIELD(_type_, _field_) \
  657. (FIELD_SIZEOF(_type_, _field_)/sizeof((((_type_ *)0)->_field_[0])))\
  658. /**
  659. * Different types of iSCSI completions to host driver for both initiator
  660. * and taget mode
  661. * of operation.
  662. */
  663. #define SOL_CMD_COMPLETE 1 /* Solicited command completed
  664. * normally
  665. */
  666. #define SOL_CMD_KILLED_DATA_DIGEST_ERR 2 /* Solicited command got
  667. * invalidated internally due
  668. * to Data Digest error
  669. */
  670. #define CXN_KILLED_PDU_SIZE_EXCEEDS_DSL 3 /* Connection got invalidated
  671. * internally
  672. * due to a recieved PDU
  673. * size > DSL
  674. */
  675. #define CXN_KILLED_BURST_LEN_MISMATCH 4 /* Connection got invalidated
  676. * internally due ti received
  677. * PDU sequence size >
  678. * FBL/MBL.
  679. */
  680. #define CXN_KILLED_AHS_RCVD 5 /* Connection got invalidated
  681. * internally due to a recieved
  682. * PDU Hdr that has
  683. * AHS */
  684. #define CXN_KILLED_HDR_DIGEST_ERR 6 /* Connection got invalidated
  685. * internally due to Hdr Digest
  686. * error
  687. */
  688. #define CXN_KILLED_UNKNOWN_HDR 7 /* Connection got invalidated
  689. * internally
  690. * due to a bad opcode in the
  691. * pdu hdr
  692. */
  693. #define CXN_KILLED_STALE_ITT_TTT_RCVD 8 /* Connection got invalidated
  694. * internally due to a recieved
  695. * ITT/TTT that does not belong
  696. * to this Connection
  697. */
  698. #define CXN_KILLED_INVALID_ITT_TTT_RCVD 9 /* Connection got invalidated
  699. * internally due to recieved
  700. * ITT/TTT value > Max
  701. * Supported ITTs/TTTs
  702. */
  703. #define CXN_KILLED_RST_RCVD 10 /* Connection got invalidated
  704. * internally due to an
  705. * incoming TCP RST
  706. */
  707. #define CXN_KILLED_TIMED_OUT 11 /* Connection got invalidated
  708. * internally due to timeout on
  709. * tcp segment 12 retransmit
  710. * attempts failed
  711. */
  712. #define CXN_KILLED_RST_SENT 12 /* Connection got invalidated
  713. * internally due to TCP RST
  714. * sent by the Tx side
  715. */
  716. #define CXN_KILLED_FIN_RCVD 13 /* Connection got invalidated
  717. * internally due to an
  718. * incoming TCP FIN.
  719. */
  720. #define CXN_KILLED_BAD_UNSOL_PDU_RCVD 14 /* Connection got invalidated
  721. * internally due to bad
  722. * unsolicited PDU Unsolicited
  723. * PDUs are PDUs with
  724. * ITT=0xffffffff
  725. */
  726. #define CXN_KILLED_BAD_WRB_INDEX_ERROR 15 /* Connection got invalidated
  727. * internally due to bad WRB
  728. * index.
  729. */
  730. #define CXN_KILLED_OVER_RUN_RESIDUAL 16 /* Command got invalidated
  731. * internally due to recived
  732. * command has residual
  733. * over run bytes.
  734. */
  735. #define CXN_KILLED_UNDER_RUN_RESIDUAL 17 /* Command got invalidated
  736. * internally due to recived
  737. * command has residual under
  738. * run bytes.
  739. */
  740. #define CMD_KILLED_INVALID_STATSN_RCVD 18 /* Command got invalidated
  741. * internally due to a recieved
  742. * PDU has an invalid StatusSN
  743. */
  744. #define CMD_KILLED_INVALID_R2T_RCVD 19 /* Command got invalidated
  745. * internally due to a recieved
  746. * an R2T with some invalid
  747. * fields in it
  748. */
  749. #define CMD_CXN_KILLED_LUN_INVALID 20 /* Command got invalidated
  750. * internally due to received
  751. * PDU has an invalid LUN.
  752. */
  753. #define CMD_CXN_KILLED_ICD_INVALID 21 /* Command got invalidated
  754. * internally due to the
  755. * corresponding ICD not in a
  756. * valid state
  757. */
  758. #define CMD_CXN_KILLED_ITT_INVALID 22 /* Command got invalidated due
  759. * to received PDU has an
  760. * invalid ITT.
  761. */
  762. #define CMD_CXN_KILLED_SEQ_OUTOFORDER 23 /* Command got invalidated due
  763. * to received sequence buffer
  764. * offset is out of order.
  765. */
  766. #define CMD_CXN_KILLED_INVALID_DATASN_RCVD 24 /* Command got invalidated
  767. * internally due to a
  768. * recieved PDU has an invalid
  769. * DataSN
  770. */
  771. #define CXN_INVALIDATE_NOTIFY 25 /* Connection invalidation
  772. * completion notify.
  773. */
  774. #define CXN_INVALIDATE_INDEX_NOTIFY 26 /* Connection invalidation
  775. * completion
  776. * with data PDU index.
  777. */
  778. #define CMD_INVALIDATED_NOTIFY 27 /* Command invalidation
  779. * completionnotifify.
  780. */
  781. #define UNSOL_HDR_NOTIFY 28 /* Unsolicited header notify.*/
  782. #define UNSOL_DATA_NOTIFY 29 /* Unsolicited data notify.*/
  783. #define UNSOL_DATA_DIGEST_ERROR_NOTIFY 30 /* Unsolicited data digest
  784. * error notify.
  785. */
  786. #define DRIVERMSG_NOTIFY 31 /* TCP acknowledge based
  787. * notification.
  788. */
  789. #define CXN_KILLED_CMND_DATA_NOT_ON_SAME_CONN 32 /* Connection got invalidated
  790. * internally due to command
  791. * and data are not on same
  792. * connection.
  793. */
  794. #define SOL_CMD_KILLED_DIF_ERR 33 /* Solicited command got
  795. * invalidated internally due
  796. * to DIF error
  797. */
  798. #define CXN_KILLED_SYN_RCVD 34 /* Connection got invalidated
  799. * internally due to incoming
  800. * TCP SYN
  801. */
  802. #define CXN_KILLED_IMM_DATA_RCVD 35 /* Connection got invalidated
  803. * internally due to an
  804. * incoming Unsolicited PDU
  805. * that has immediate data on
  806. * the cxn
  807. */
  808. int beiscsi_pci_soft_reset(struct beiscsi_hba *phba);
  809. int be_chk_reset_complete(struct beiscsi_hba *phba);
  810. void be_wrb_hdr_prepare(struct be_mcc_wrb *wrb, int payload_len,
  811. bool embedded, u8 sge_cnt);
  812. void be_cmd_hdr_prepare(struct be_cmd_req_hdr *req_hdr,
  813. u8 subsystem, u8 opcode, int cmd_len);
  814. #endif /* !BEISCSI_CMDS_H */