be_cmds.h 27 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040
  1. /**
  2. * Copyright (C) 2005 - 2011 Emulex
  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@emulex.com
  12. *
  13. * Emulex
  14. * 3333 Susan Street
  15. * Costa Mesa, CA 92626
  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 OneConnect'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_NTWK_SET_VLAN 14
  148. #define OPCODE_COMMON_ISCSI_NTWK_CONFIGURE_STATELESS_IP_ADDR 17
  149. #define OPCODE_COMMON_ISCSI_NTWK_MODIFY_IP_ADDR 21
  150. #define OPCODE_COMMON_ISCSI_NTWK_GET_DEFAULT_GATEWAY 22
  151. #define OPCODE_COMMON_ISCSI_NTWK_MODIFY_DEFAULT_GATEWAY 23
  152. #define OPCODE_COMMON_ISCSI_NTWK_GET_ALL_IF_ID 24
  153. #define OPCODE_COMMON_ISCSI_NTWK_GET_IF_INFO 25
  154. #define OPCODE_COMMON_ISCSI_SET_FRAGNUM_BITS_FOR_SGL_CRA 61
  155. #define OPCODE_COMMON_ISCSI_DEFQ_CREATE 64
  156. #define OPCODE_COMMON_ISCSI_DEFQ_DESTROY 65
  157. #define OPCODE_COMMON_ISCSI_WRBQ_CREATE 66
  158. #define OPCODE_COMMON_ISCSI_WRBQ_DESTROY 67
  159. struct be_cmd_req_hdr {
  160. u8 opcode; /* dword 0 */
  161. u8 subsystem; /* dword 0 */
  162. u8 port_number; /* dword 0 */
  163. u8 domain; /* dword 0 */
  164. u32 timeout; /* dword 1 */
  165. u32 request_length; /* dword 2 */
  166. u32 rsvd0; /* dword 3 */
  167. };
  168. struct be_cmd_resp_hdr {
  169. u32 info; /* dword 0 */
  170. u32 status; /* dword 1 */
  171. u32 response_length; /* dword 2 */
  172. u32 actual_resp_len; /* dword 3 */
  173. };
  174. struct phys_addr {
  175. u32 lo;
  176. u32 hi;
  177. };
  178. /**************************
  179. * BE Command definitions *
  180. **************************/
  181. /**
  182. * Pseudo amap definition in which each bit of the actual structure is defined
  183. * as a byte - used to calculate offset/shift/mask of each field
  184. */
  185. struct amap_eq_context {
  186. u8 cidx[13]; /* dword 0 */
  187. u8 rsvd0[3]; /* dword 0 */
  188. u8 epidx[13]; /* dword 0 */
  189. u8 valid; /* dword 0 */
  190. u8 rsvd1; /* dword 0 */
  191. u8 size; /* dword 0 */
  192. u8 pidx[13]; /* dword 1 */
  193. u8 rsvd2[3]; /* dword 1 */
  194. u8 pd[10]; /* dword 1 */
  195. u8 count[3]; /* dword 1 */
  196. u8 solevent; /* dword 1 */
  197. u8 stalled; /* dword 1 */
  198. u8 armed; /* dword 1 */
  199. u8 rsvd3[4]; /* dword 2 */
  200. u8 func[8]; /* dword 2 */
  201. u8 rsvd4; /* dword 2 */
  202. u8 delaymult[10]; /* dword 2 */
  203. u8 rsvd5[2]; /* dword 2 */
  204. u8 phase[2]; /* dword 2 */
  205. u8 nodelay; /* dword 2 */
  206. u8 rsvd6[4]; /* dword 2 */
  207. u8 rsvd7[32]; /* dword 3 */
  208. } __packed;
  209. struct be_cmd_req_eq_create {
  210. struct be_cmd_req_hdr hdr; /* dw[4] */
  211. u16 num_pages; /* sword */
  212. u16 rsvd0; /* sword */
  213. u8 context[sizeof(struct amap_eq_context) / 8]; /* dw[4] */
  214. struct phys_addr pages[8];
  215. } __packed;
  216. struct be_cmd_resp_eq_create {
  217. struct be_cmd_resp_hdr resp_hdr;
  218. u16 eq_id; /* sword */
  219. u16 rsvd0; /* sword */
  220. } __packed;
  221. struct mgmt_chap_format {
  222. u32 flags;
  223. u8 intr_chap_name[256];
  224. u8 intr_secret[16];
  225. u8 target_chap_name[256];
  226. u8 target_secret[16];
  227. u16 intr_chap_name_length;
  228. u16 intr_secret_length;
  229. u16 target_chap_name_length;
  230. u16 target_secret_length;
  231. } __packed;
  232. struct mgmt_auth_method_format {
  233. u8 auth_method_type;
  234. u8 padding[3];
  235. struct mgmt_chap_format chap;
  236. } __packed;
  237. struct mgmt_conn_login_options {
  238. u8 flags;
  239. u8 header_digest;
  240. u8 data_digest;
  241. u8 rsvd0;
  242. u32 max_recv_datasegment_len_ini;
  243. u32 max_recv_datasegment_len_tgt;
  244. u32 tcp_mss;
  245. u32 tcp_window_size;
  246. struct mgmt_auth_method_format auth_data;
  247. } __packed;
  248. struct ip_address_format {
  249. u16 size_of_structure;
  250. u8 reserved;
  251. u8 ip_type;
  252. u8 ip_address[16];
  253. u32 rsvd0;
  254. } __packed;
  255. struct mgmt_conn_info {
  256. u32 connection_handle;
  257. u32 connection_status;
  258. u16 src_port;
  259. u16 dest_port;
  260. u16 dest_port_redirected;
  261. u16 cid;
  262. u32 estimated_throughput;
  263. struct ip_address_format src_ipaddr;
  264. struct ip_address_format dest_ipaddr;
  265. struct ip_address_format dest_ipaddr_redirected;
  266. struct mgmt_conn_login_options negotiated_login_options;
  267. } __packed;
  268. struct mgmt_session_login_options {
  269. u8 flags;
  270. u8 error_recovery_level;
  271. u16 rsvd0;
  272. u32 first_burst_length;
  273. u32 max_burst_length;
  274. u16 max_connections;
  275. u16 max_outstanding_r2t;
  276. u16 default_time2wait;
  277. u16 default_time2retain;
  278. } __packed;
  279. struct mgmt_session_info {
  280. u32 session_handle;
  281. u32 status;
  282. u8 isid[6];
  283. u16 tsih;
  284. u32 session_flags;
  285. u16 conn_count;
  286. u16 pad;
  287. u8 target_name[224];
  288. u8 initiator_iscsiname[224];
  289. struct mgmt_session_login_options negotiated_login_options;
  290. struct mgmt_conn_info conn_list[1];
  291. } __packed;
  292. struct be_cmd_req_get_session {
  293. struct be_cmd_req_hdr hdr;
  294. u32 session_handle;
  295. } __packed;
  296. struct be_cmd_resp_get_session {
  297. struct be_cmd_resp_hdr hdr;
  298. struct mgmt_session_info session_info;
  299. } __packed;
  300. struct mac_addr {
  301. u16 size_of_struct;
  302. u8 addr[ETH_ALEN];
  303. } __packed;
  304. struct be_cmd_req_get_boot_target {
  305. struct be_cmd_req_hdr hdr;
  306. } __packed;
  307. struct be_cmd_resp_get_boot_target {
  308. struct be_cmd_resp_hdr hdr;
  309. u32 boot_session_count;
  310. int boot_session_handle;
  311. };
  312. struct be_cmd_req_mac_query {
  313. struct be_cmd_req_hdr hdr;
  314. u8 type;
  315. u8 permanent;
  316. u16 if_id;
  317. } __packed;
  318. struct be_cmd_resp_mac_query {
  319. struct be_cmd_resp_hdr hdr;
  320. struct mac_addr mac;
  321. };
  322. /******************** Create CQ ***************************/
  323. /**
  324. * Pseudo amap definition in which each bit of the actual structure is defined
  325. * as a byte - used to calculate offset/shift/mask of each field
  326. */
  327. struct amap_cq_context {
  328. u8 cidx[11]; /* dword 0 */
  329. u8 rsvd0; /* dword 0 */
  330. u8 coalescwm[2]; /* dword 0 */
  331. u8 nodelay; /* dword 0 */
  332. u8 epidx[11]; /* dword 0 */
  333. u8 rsvd1; /* dword 0 */
  334. u8 count[2]; /* dword 0 */
  335. u8 valid; /* dword 0 */
  336. u8 solevent; /* dword 0 */
  337. u8 eventable; /* dword 0 */
  338. u8 pidx[11]; /* dword 1 */
  339. u8 rsvd2; /* dword 1 */
  340. u8 pd[10]; /* dword 1 */
  341. u8 eqid[8]; /* dword 1 */
  342. u8 stalled; /* dword 1 */
  343. u8 armed; /* dword 1 */
  344. u8 rsvd3[4]; /* dword 2 */
  345. u8 func[8]; /* dword 2 */
  346. u8 rsvd4[20]; /* dword 2 */
  347. u8 rsvd5[32]; /* dword 3 */
  348. } __packed;
  349. struct be_cmd_req_cq_create {
  350. struct be_cmd_req_hdr hdr;
  351. u16 num_pages;
  352. u16 rsvd0;
  353. u8 context[sizeof(struct amap_cq_context) / 8];
  354. struct phys_addr pages[4];
  355. } __packed;
  356. struct be_cmd_resp_cq_create {
  357. struct be_cmd_resp_hdr hdr;
  358. u16 cq_id;
  359. u16 rsvd0;
  360. } __packed;
  361. /******************** Create MCCQ ***************************/
  362. /**
  363. * Pseudo amap definition in which each bit of the actual structure is defined
  364. * as a byte - used to calculate offset/shift/mask of each field
  365. */
  366. struct amap_mcc_context {
  367. u8 con_index[14];
  368. u8 rsvd0[2];
  369. u8 ring_size[4];
  370. u8 fetch_wrb;
  371. u8 fetch_r2t;
  372. u8 cq_id[10];
  373. u8 prod_index[14];
  374. u8 fid[8];
  375. u8 pdid[9];
  376. u8 valid;
  377. u8 rsvd1[32];
  378. u8 rsvd2[32];
  379. } __packed;
  380. struct be_cmd_req_mcc_create {
  381. struct be_cmd_req_hdr hdr;
  382. u16 num_pages;
  383. u16 rsvd0;
  384. u8 context[sizeof(struct amap_mcc_context) / 8];
  385. struct phys_addr pages[8];
  386. } __packed;
  387. struct be_cmd_resp_mcc_create {
  388. struct be_cmd_resp_hdr hdr;
  389. u16 id;
  390. u16 rsvd0;
  391. } __packed;
  392. /******************** Q Destroy ***************************/
  393. /* Type of Queue to be destroyed */
  394. enum {
  395. QTYPE_EQ = 1,
  396. QTYPE_CQ,
  397. QTYPE_MCCQ,
  398. QTYPE_WRBQ,
  399. QTYPE_DPDUQ,
  400. QTYPE_SGL
  401. };
  402. struct be_cmd_req_q_destroy {
  403. struct be_cmd_req_hdr hdr;
  404. u16 id;
  405. u16 bypass_flush; /* valid only for rx q destroy */
  406. } __packed;
  407. struct macaddr {
  408. u8 byte[ETH_ALEN];
  409. };
  410. struct be_cmd_req_mcast_mac_config {
  411. struct be_cmd_req_hdr hdr;
  412. u16 num_mac;
  413. u8 promiscuous;
  414. u8 interface_id;
  415. struct macaddr mac[32];
  416. } __packed;
  417. static inline void *embedded_payload(struct be_mcc_wrb *wrb)
  418. {
  419. return wrb->payload.embedded_payload;
  420. }
  421. static inline struct be_sge *nonembedded_sgl(struct be_mcc_wrb *wrb)
  422. {
  423. return &wrb->payload.sgl[0];
  424. }
  425. /******************** Modify EQ Delay *******************/
  426. struct be_cmd_req_modify_eq_delay {
  427. struct be_cmd_req_hdr hdr;
  428. u32 num_eq;
  429. struct {
  430. u32 eq_id;
  431. u32 phase;
  432. u32 delay_multiplier;
  433. } delay[8];
  434. } __packed;
  435. /******************** Get MAC ADDR *******************/
  436. #define ETH_ALEN 6
  437. struct be_cmd_req_get_mac_addr {
  438. struct be_cmd_req_hdr hdr;
  439. u32 nic_port_count;
  440. u32 speed;
  441. u32 max_speed;
  442. u32 link_state;
  443. u32 max_frame_size;
  444. u16 size_of_structure;
  445. u8 mac_address[ETH_ALEN];
  446. u32 rsvd[23];
  447. };
  448. struct be_cmd_resp_get_mac_addr {
  449. struct be_cmd_resp_hdr hdr;
  450. u32 nic_port_count;
  451. u32 speed;
  452. u32 max_speed;
  453. u32 link_state;
  454. u32 max_frame_size;
  455. u16 size_of_structure;
  456. u8 mac_address[6];
  457. u32 rsvd[23];
  458. };
  459. #define BEISCSI_ALIAS_LEN 32
  460. struct be_cmd_hba_name {
  461. struct be_cmd_req_hdr hdr;
  462. u16 flags;
  463. u16 rsvd0;
  464. u8 initiator_name[ISCSI_NAME_LEN];
  465. u8 initiator_alias[BEISCSI_ALIAS_LEN];
  466. } __packed;
  467. int beiscsi_cmd_eq_create(struct be_ctrl_info *ctrl,
  468. struct be_queue_info *eq, int eq_delay);
  469. int beiscsi_cmd_cq_create(struct be_ctrl_info *ctrl,
  470. struct be_queue_info *cq, struct be_queue_info *eq,
  471. bool sol_evts, bool no_delay,
  472. int num_cqe_dma_coalesce);
  473. int beiscsi_cmd_q_destroy(struct be_ctrl_info *ctrl, struct be_queue_info *q,
  474. int type);
  475. int beiscsi_cmd_mccq_create(struct beiscsi_hba *phba,
  476. struct be_queue_info *mccq,
  477. struct be_queue_info *cq);
  478. int be_poll_mcc(struct be_ctrl_info *ctrl);
  479. int mgmt_check_supported_fw(struct be_ctrl_info *ctrl,
  480. struct beiscsi_hba *phba);
  481. unsigned int be_cmd_get_mac_addr(struct beiscsi_hba *phba);
  482. unsigned int be_cmd_get_initname(struct beiscsi_hba *phba);
  483. unsigned int beiscsi_get_boot_target(struct beiscsi_hba *phba);
  484. unsigned int beiscsi_get_session_info(struct beiscsi_hba *phba,
  485. u32 boot_session_handle,
  486. struct be_dma_mem *nonemb_cmd);
  487. void free_mcc_tag(struct be_ctrl_info *ctrl, unsigned int tag);
  488. /*ISCSI Functuions */
  489. int be_cmd_fw_initialize(struct be_ctrl_info *ctrl);
  490. struct be_mcc_wrb *wrb_from_mbox(struct be_dma_mem *mbox_mem);
  491. struct be_mcc_wrb *wrb_from_mccq(struct beiscsi_hba *phba);
  492. int be_mcc_notify_wait(struct beiscsi_hba *phba);
  493. void be_mcc_notify(struct beiscsi_hba *phba);
  494. unsigned int alloc_mcc_tag(struct beiscsi_hba *phba);
  495. void beiscsi_async_link_state_process(struct beiscsi_hba *phba,
  496. struct be_async_event_link_state *evt);
  497. int be_mcc_compl_process_isr(struct be_ctrl_info *ctrl,
  498. struct be_mcc_compl *compl);
  499. int be_mbox_notify(struct be_ctrl_info *ctrl);
  500. int be_cmd_create_default_pdu_queue(struct be_ctrl_info *ctrl,
  501. struct be_queue_info *cq,
  502. struct be_queue_info *dq, int length,
  503. int entry_size);
  504. int be_cmd_iscsi_post_sgl_pages(struct be_ctrl_info *ctrl,
  505. struct be_dma_mem *q_mem, u32 page_offset,
  506. u32 num_pages);
  507. int beiscsi_cmd_reset_function(struct beiscsi_hba *phba);
  508. int be_cmd_wrbq_create(struct be_ctrl_info *ctrl, struct be_dma_mem *q_mem,
  509. struct be_queue_info *wrbq);
  510. bool is_link_state_evt(u32 trailer);
  511. struct be_default_pdu_context {
  512. u32 dw[4];
  513. } __packed;
  514. struct amap_be_default_pdu_context {
  515. u8 dbuf_cindex[13]; /* dword 0 */
  516. u8 rsvd0[3]; /* dword 0 */
  517. u8 ring_size[4]; /* dword 0 */
  518. u8 ring_state[4]; /* dword 0 */
  519. u8 rsvd1[8]; /* dword 0 */
  520. u8 dbuf_pindex[13]; /* dword 1 */
  521. u8 rsvd2; /* dword 1 */
  522. u8 pci_func_id[8]; /* dword 1 */
  523. u8 rx_pdid[9]; /* dword 1 */
  524. u8 rx_pdid_valid; /* dword 1 */
  525. u8 default_buffer_size[16]; /* dword 2 */
  526. u8 cq_id_recv[10]; /* dword 2 */
  527. u8 rx_pdid_not_valid; /* dword 2 */
  528. u8 rsvd3[5]; /* dword 2 */
  529. u8 rsvd4[32]; /* dword 3 */
  530. } __packed;
  531. struct be_defq_create_req {
  532. struct be_cmd_req_hdr hdr;
  533. u16 num_pages;
  534. u8 ulp_num;
  535. u8 rsvd0;
  536. struct be_default_pdu_context context;
  537. struct phys_addr pages[8];
  538. } __packed;
  539. struct be_defq_create_resp {
  540. struct be_cmd_req_hdr hdr;
  541. u16 id;
  542. u16 rsvd0;
  543. } __packed;
  544. struct be_post_sgl_pages_req {
  545. struct be_cmd_req_hdr hdr;
  546. u16 num_pages;
  547. u16 page_offset;
  548. u32 rsvd0;
  549. struct phys_addr pages[26];
  550. u32 rsvd1;
  551. } __packed;
  552. struct be_wrbq_create_req {
  553. struct be_cmd_req_hdr hdr;
  554. u16 num_pages;
  555. u8 ulp_num;
  556. u8 rsvd0;
  557. struct phys_addr pages[8];
  558. } __packed;
  559. struct be_wrbq_create_resp {
  560. struct be_cmd_resp_hdr resp_hdr;
  561. u16 cid;
  562. u16 rsvd0;
  563. } __packed;
  564. #define SOL_CID_MASK 0x0000FFC0
  565. #define SOL_CODE_MASK 0x0000003F
  566. #define SOL_WRB_INDEX_MASK 0x00FF0000
  567. #define SOL_CMD_WND_MASK 0xFF000000
  568. #define SOL_RES_CNT_MASK 0x7FFFFFFF
  569. #define SOL_EXP_CMD_SN_MASK 0xFFFFFFFF
  570. #define SOL_HW_STS_MASK 0x000000FF
  571. #define SOL_STS_MASK 0x0000FF00
  572. #define SOL_RESP_MASK 0x00FF0000
  573. #define SOL_FLAGS_MASK 0x7F000000
  574. #define SOL_S_MASK 0x80000000
  575. struct sol_cqe {
  576. u32 dw[4];
  577. };
  578. struct amap_sol_cqe {
  579. u8 hw_sts[8]; /* dword 0 */
  580. u8 i_sts[8]; /* dword 0 */
  581. u8 i_resp[8]; /* dword 0 */
  582. u8 i_flags[7]; /* dword 0 */
  583. u8 s; /* dword 0 */
  584. u8 i_exp_cmd_sn[32]; /* dword 1 */
  585. u8 code[6]; /* dword 2 */
  586. u8 cid[10]; /* dword 2 */
  587. u8 wrb_index[8]; /* dword 2 */
  588. u8 i_cmd_wnd[8]; /* dword 2 */
  589. u8 i_res_cnt[31]; /* dword 3 */
  590. u8 valid; /* dword 3 */
  591. } __packed;
  592. #define SOL_ICD_INDEX_MASK 0x0003FFC0
  593. struct amap_sol_cqe_ring {
  594. u8 hw_sts[8]; /* dword 0 */
  595. u8 i_sts[8]; /* dword 0 */
  596. u8 i_resp[8]; /* dword 0 */
  597. u8 i_flags[7]; /* dword 0 */
  598. u8 s; /* dword 0 */
  599. u8 i_exp_cmd_sn[32]; /* dword 1 */
  600. u8 code[6]; /* dword 2 */
  601. u8 icd_index[12]; /* dword 2 */
  602. u8 rsvd[6]; /* dword 2 */
  603. u8 i_cmd_wnd[8]; /* dword 2 */
  604. u8 i_res_cnt[31]; /* dword 3 */
  605. u8 valid; /* dword 3 */
  606. } __packed;
  607. /**
  608. * Post WRB Queue Doorbell Register used by the host Storage
  609. * stack to notify the
  610. * controller of a posted Work Request Block
  611. */
  612. #define DB_WRB_POST_CID_MASK 0x3FF /* bits 0 - 9 */
  613. #define DB_DEF_PDU_WRB_INDEX_MASK 0xFF /* bits 0 - 9 */
  614. #define DB_DEF_PDU_WRB_INDEX_SHIFT 16
  615. #define DB_DEF_PDU_NUM_POSTED_SHIFT 24
  616. struct fragnum_bits_for_sgl_cra_in {
  617. struct be_cmd_req_hdr hdr;
  618. u32 num_bits;
  619. } __packed;
  620. struct iscsi_cleanup_req {
  621. struct be_cmd_req_hdr hdr;
  622. u16 chute;
  623. u8 hdr_ring_id;
  624. u8 data_ring_id;
  625. } __packed;
  626. struct eq_delay {
  627. u32 eq_id;
  628. u32 phase;
  629. u32 delay_multiplier;
  630. } __packed;
  631. struct be_eq_delay_params_in {
  632. struct be_cmd_req_hdr hdr;
  633. u32 num_eq;
  634. struct eq_delay delay[8];
  635. } __packed;
  636. struct tcp_connect_and_offload_in {
  637. struct be_cmd_req_hdr hdr;
  638. struct ip_address_format ip_address;
  639. u16 tcp_port;
  640. u16 cid;
  641. u16 cq_id;
  642. u16 defq_id;
  643. struct phys_addr dataout_template_pa;
  644. u16 hdr_ring_id;
  645. u16 data_ring_id;
  646. u8 do_offload;
  647. u8 rsvd0[3];
  648. } __packed;
  649. struct tcp_connect_and_offload_out {
  650. struct be_cmd_resp_hdr hdr;
  651. u32 connection_handle;
  652. u16 cid;
  653. u16 rsvd0;
  654. } __packed;
  655. struct be_mcc_wrb_context {
  656. struct MCC_WRB *wrb;
  657. int *users_final_status;
  658. } __packed;
  659. #define DB_DEF_PDU_RING_ID_MASK 0x3FF /* bits 0 - 9 */
  660. #define DB_DEF_PDU_CQPROC_MASK 0x3FFF /* bits 0 - 9 */
  661. #define DB_DEF_PDU_REARM_SHIFT 14
  662. #define DB_DEF_PDU_EVENT_SHIFT 15
  663. #define DB_DEF_PDU_CQPROC_SHIFT 16
  664. struct dmsg_cqe {
  665. u32 dw[4];
  666. } __packed;
  667. struct tcp_upload_params_in {
  668. struct be_cmd_req_hdr hdr;
  669. u16 id;
  670. u16 upload_type;
  671. u32 reset_seq;
  672. } __packed;
  673. struct tcp_upload_params_out {
  674. u32 dw[32];
  675. } __packed;
  676. union tcp_upload_params {
  677. struct tcp_upload_params_in request;
  678. struct tcp_upload_params_out response;
  679. } __packed;
  680. struct be_ulp_fw_cfg {
  681. u32 ulp_mode;
  682. u32 etx_base;
  683. u32 etx_count;
  684. u32 sq_base;
  685. u32 sq_count;
  686. u32 rq_base;
  687. u32 rq_count;
  688. u32 dq_base;
  689. u32 dq_count;
  690. u32 lro_base;
  691. u32 lro_count;
  692. u32 icd_base;
  693. u32 icd_count;
  694. };
  695. struct be_fw_cfg {
  696. struct be_cmd_req_hdr hdr;
  697. u32 be_config_number;
  698. u32 asic_revision;
  699. u32 phys_port;
  700. u32 function_mode;
  701. struct be_ulp_fw_cfg ulp[2];
  702. u32 function_caps;
  703. } __packed;
  704. struct be_all_if_id {
  705. struct be_cmd_req_hdr hdr;
  706. u32 if_count;
  707. u32 if_hndl_list[1];
  708. } __packed;
  709. #define ISCSI_OPCODE_SCSI_DATA_OUT 5
  710. #define OPCODE_COMMON_MODIFY_EQ_DELAY 41
  711. #define OPCODE_COMMON_ISCSI_CLEANUP 59
  712. #define OPCODE_COMMON_TCP_UPLOAD 56
  713. #define OPCODE_COMMON_ISCSI_TCP_CONNECT_AND_OFFLOAD 70
  714. #define OPCODE_COMMON_ISCSI_ERROR_RECOVERY_INVALIDATE_COMMANDS 1
  715. #define OPCODE_ISCSI_INI_CFG_GET_HBA_NAME 6
  716. #define OPCODE_ISCSI_INI_CFG_SET_HBA_NAME 7
  717. #define OPCODE_ISCSI_INI_SESSION_GET_A_SESSION 14
  718. #define OPCODE_ISCSI_INI_DRIVER_OFFLOAD_SESSION 41
  719. #define OPCODE_ISCSI_INI_DRIVER_INVALIDATE_CONNECTION 42
  720. #define OPCODE_ISCSI_INI_BOOT_GET_BOOT_TARGET 52
  721. /* --- CMD_ISCSI_INVALIDATE_CONNECTION_TYPE --- */
  722. #define CMD_ISCSI_COMMAND_INVALIDATE 1
  723. #define CMD_ISCSI_CONNECTION_INVALIDATE 0x8001
  724. #define CMD_ISCSI_CONNECTION_ISSUE_TCP_RST 0x8002
  725. #define INI_WR_CMD 1 /* Initiator write command */
  726. #define INI_TMF_CMD 2 /* Initiator TMF command */
  727. #define INI_NOPOUT_CMD 3 /* Initiator; Send a NOP-OUT */
  728. #define INI_RD_CMD 5 /* Initiator requesting to send
  729. * a read command
  730. */
  731. #define TGT_CTX_UPDT_CMD 7 /* Target context update */
  732. #define TGT_STS_CMD 8 /* Target R2T and other BHS
  733. * where only the status number
  734. * need to be updated
  735. */
  736. #define TGT_DATAIN_CMD 9 /* Target Data-Ins in response
  737. * to read command
  738. */
  739. #define TGT_SOS_PDU 10 /* Target:standalone status
  740. * response
  741. */
  742. #define TGT_DM_CMD 11 /* Indicates that the bhs
  743. * preparedby
  744. * driver should not be touched
  745. */
  746. /* --- CMD_CHUTE_TYPE --- */
  747. #define CMD_CONNECTION_CHUTE_0 1
  748. #define CMD_CONNECTION_CHUTE_1 2
  749. #define CMD_CONNECTION_CHUTE_2 3
  750. #define EQ_MAJOR_CODE_COMPLETION 0
  751. #define CMD_ISCSI_SESSION_DEL_CFG_FROM_FLASH 0
  752. #define CMD_ISCSI_SESSION_SAVE_CFG_ON_FLASH 1
  753. /* --- CONNECTION_UPLOAD_PARAMS --- */
  754. /* These parameters are used to define the type of upload desired. */
  755. #define CONNECTION_UPLOAD_GRACEFUL 1 /* Graceful upload */
  756. #define CONNECTION_UPLOAD_ABORT_RESET 2 /* Abortive upload with
  757. * reset
  758. */
  759. #define CONNECTION_UPLOAD_ABORT 3 /* Abortive upload without
  760. * reset
  761. */
  762. #define CONNECTION_UPLOAD_ABORT_WITH_SEQ 4 /* Abortive upload with reset,
  763. * sequence number by driver */
  764. /* Returns byte size of given field with a structure. */
  765. /* Returns the number of items in the field array. */
  766. #define BE_NUMBER_OF_FIELD(_type_, _field_) \
  767. (FIELD_SIZEOF(_type_, _field_)/sizeof((((_type_ *)0)->_field_[0])))\
  768. /**
  769. * Different types of iSCSI completions to host driver for both initiator
  770. * and taget mode
  771. * of operation.
  772. */
  773. #define SOL_CMD_COMPLETE 1 /* Solicited command completed
  774. * normally
  775. */
  776. #define SOL_CMD_KILLED_DATA_DIGEST_ERR 2 /* Solicited command got
  777. * invalidated internally due
  778. * to Data Digest error
  779. */
  780. #define CXN_KILLED_PDU_SIZE_EXCEEDS_DSL 3 /* Connection got invalidated
  781. * internally
  782. * due to a received PDU
  783. * size > DSL
  784. */
  785. #define CXN_KILLED_BURST_LEN_MISMATCH 4 /* Connection got invalidated
  786. * internally due ti received
  787. * PDU sequence size >
  788. * FBL/MBL.
  789. */
  790. #define CXN_KILLED_AHS_RCVD 5 /* Connection got invalidated
  791. * internally due to a received
  792. * PDU Hdr that has
  793. * AHS */
  794. #define CXN_KILLED_HDR_DIGEST_ERR 6 /* Connection got invalidated
  795. * internally due to Hdr Digest
  796. * error
  797. */
  798. #define CXN_KILLED_UNKNOWN_HDR 7 /* Connection got invalidated
  799. * internally
  800. * due to a bad opcode in the
  801. * pdu hdr
  802. */
  803. #define CXN_KILLED_STALE_ITT_TTT_RCVD 8 /* Connection got invalidated
  804. * internally due to a received
  805. * ITT/TTT that does not belong
  806. * to this Connection
  807. */
  808. #define CXN_KILLED_INVALID_ITT_TTT_RCVD 9 /* Connection got invalidated
  809. * internally due to received
  810. * ITT/TTT value > Max
  811. * Supported ITTs/TTTs
  812. */
  813. #define CXN_KILLED_RST_RCVD 10 /* Connection got invalidated
  814. * internally due to an
  815. * incoming TCP RST
  816. */
  817. #define CXN_KILLED_TIMED_OUT 11 /* Connection got invalidated
  818. * internally due to timeout on
  819. * tcp segment 12 retransmit
  820. * attempts failed
  821. */
  822. #define CXN_KILLED_RST_SENT 12 /* Connection got invalidated
  823. * internally due to TCP RST
  824. * sent by the Tx side
  825. */
  826. #define CXN_KILLED_FIN_RCVD 13 /* Connection got invalidated
  827. * internally due to an
  828. * incoming TCP FIN.
  829. */
  830. #define CXN_KILLED_BAD_UNSOL_PDU_RCVD 14 /* Connection got invalidated
  831. * internally due to bad
  832. * unsolicited PDU Unsolicited
  833. * PDUs are PDUs with
  834. * ITT=0xffffffff
  835. */
  836. #define CXN_KILLED_BAD_WRB_INDEX_ERROR 15 /* Connection got invalidated
  837. * internally due to bad WRB
  838. * index.
  839. */
  840. #define CXN_KILLED_OVER_RUN_RESIDUAL 16 /* Command got invalidated
  841. * internally due to received
  842. * command has residual
  843. * over run bytes.
  844. */
  845. #define CXN_KILLED_UNDER_RUN_RESIDUAL 17 /* Command got invalidated
  846. * internally due to received
  847. * command has residual under
  848. * run bytes.
  849. */
  850. #define CMD_KILLED_INVALID_STATSN_RCVD 18 /* Command got invalidated
  851. * internally due to a received
  852. * PDU has an invalid StatusSN
  853. */
  854. #define CMD_KILLED_INVALID_R2T_RCVD 19 /* Command got invalidated
  855. * internally due to a received
  856. * an R2T with some invalid
  857. * fields in it
  858. */
  859. #define CMD_CXN_KILLED_LUN_INVALID 20 /* Command got invalidated
  860. * internally due to received
  861. * PDU has an invalid LUN.
  862. */
  863. #define CMD_CXN_KILLED_ICD_INVALID 21 /* Command got invalidated
  864. * internally due to the
  865. * corresponding ICD not in a
  866. * valid state
  867. */
  868. #define CMD_CXN_KILLED_ITT_INVALID 22 /* Command got invalidated due
  869. * to received PDU has an
  870. * invalid ITT.
  871. */
  872. #define CMD_CXN_KILLED_SEQ_OUTOFORDER 23 /* Command got invalidated due
  873. * to received sequence buffer
  874. * offset is out of order.
  875. */
  876. #define CMD_CXN_KILLED_INVALID_DATASN_RCVD 24 /* Command got invalidated
  877. * internally due to a
  878. * received PDU has an invalid
  879. * DataSN
  880. */
  881. #define CXN_INVALIDATE_NOTIFY 25 /* Connection invalidation
  882. * completion notify.
  883. */
  884. #define CXN_INVALIDATE_INDEX_NOTIFY 26 /* Connection invalidation
  885. * completion
  886. * with data PDU index.
  887. */
  888. #define CMD_INVALIDATED_NOTIFY 27 /* Command invalidation
  889. * completionnotifify.
  890. */
  891. #define UNSOL_HDR_NOTIFY 28 /* Unsolicited header notify.*/
  892. #define UNSOL_DATA_NOTIFY 29 /* Unsolicited data notify.*/
  893. #define UNSOL_DATA_DIGEST_ERROR_NOTIFY 30 /* Unsolicited data digest
  894. * error notify.
  895. */
  896. #define DRIVERMSG_NOTIFY 31 /* TCP acknowledge based
  897. * notification.
  898. */
  899. #define CXN_KILLED_CMND_DATA_NOT_ON_SAME_CONN 32 /* Connection got invalidated
  900. * internally due to command
  901. * and data are not on same
  902. * connection.
  903. */
  904. #define SOL_CMD_KILLED_DIF_ERR 33 /* Solicited command got
  905. * invalidated internally due
  906. * to DIF error
  907. */
  908. #define CXN_KILLED_SYN_RCVD 34 /* Connection got invalidated
  909. * internally due to incoming
  910. * TCP SYN
  911. */
  912. #define CXN_KILLED_IMM_DATA_RCVD 35 /* Connection got invalidated
  913. * internally due to an
  914. * incoming Unsolicited PDU
  915. * that has immediate data on
  916. * the cxn
  917. */
  918. int beiscsi_pci_soft_reset(struct beiscsi_hba *phba);
  919. int be_chk_reset_complete(struct beiscsi_hba *phba);
  920. void be_wrb_hdr_prepare(struct be_mcc_wrb *wrb, int payload_len,
  921. bool embedded, u8 sge_cnt);
  922. void be_cmd_hdr_prepare(struct be_cmd_req_hdr *req_hdr,
  923. u8 subsystem, u8 opcode, int cmd_len);
  924. #endif /* !BEISCSI_CMDS_H */