be_cmds.h 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454
  1. /**
  2. * Copyright (C) 2005 - 2016 Broadcom
  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@broadcom.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. __le32 pa_lo;
  28. __le32 pa_hi;
  29. __le32 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. #define EMBED_MBX_MAX_PAYLOAD_SIZE 220
  41. u8 embedded_payload[236]; /* used by embedded cmds */
  42. struct be_sge sgl[19]; /* used by non-embedded cmds */
  43. } payload;
  44. };
  45. #define CQE_FLAGS_VALID_MASK (1 << 31)
  46. #define CQE_FLAGS_ASYNC_MASK (1 << 30)
  47. #define CQE_FLAGS_COMPLETED_MASK (1 << 28)
  48. #define CQE_FLAGS_CONSUMED_MASK (1 << 27)
  49. /* Completion Status */
  50. #define MCC_STATUS_SUCCESS 0x0
  51. #define MCC_STATUS_FAILED 0x1
  52. #define MCC_STATUS_ILLEGAL_REQUEST 0x2
  53. #define MCC_STATUS_ILLEGAL_FIELD 0x3
  54. #define MCC_STATUS_INSUFFICIENT_BUFFER 0x4
  55. #define MCC_STATUS_INVALID_LENGTH 0x74
  56. #define CQE_STATUS_COMPL_MASK 0xFFFF
  57. #define CQE_STATUS_COMPL_SHIFT 0 /* bits 0 - 15 */
  58. #define CQE_STATUS_EXTD_MASK 0xFFFF
  59. #define CQE_STATUS_EXTD_SHIFT 16 /* bits 31 - 16 */
  60. #define CQE_STATUS_ADDL_MASK 0xFF00
  61. #define CQE_STATUS_ADDL_SHIFT 8
  62. #define CQE_STATUS_MASK 0xFF
  63. #define CQE_STATUS_WRB_MASK 0xFF0000
  64. #define CQE_STATUS_WRB_SHIFT 16
  65. #define BEISCSI_HOST_MBX_TIMEOUT (110 * 1000)
  66. #define BEISCSI_FW_MBX_TIMEOUT 100
  67. /* MBOX Command VER */
  68. #define MBX_CMD_VER1 0x01
  69. #define MBX_CMD_VER2 0x02
  70. struct be_mcc_compl {
  71. u32 status; /* dword 0 */
  72. u32 tag0; /* dword 1 */
  73. u32 tag1; /* dword 2 */
  74. u32 flags; /* dword 3 */
  75. };
  76. /********* Mailbox door bell *************/
  77. /**
  78. * Used for driver communication with the FW.
  79. * The software must write this register twice to post any command. First,
  80. * it writes the register with hi=1 and the upper bits of the physical address
  81. * for the MAILBOX structure. Software must poll the ready bit until this
  82. * is acknowledged. Then, sotware writes the register with hi=0 with the lower
  83. * bits in the address. It must poll the ready bit until the command is
  84. * complete. Upon completion, the MAILBOX will contain a valid completion
  85. * queue entry.
  86. */
  87. #define MPU_MAILBOX_DB_OFFSET 0x160
  88. #define MPU_MAILBOX_DB_RDY_MASK 0x1 /* bit 0 */
  89. #define MPU_MAILBOX_DB_HI_MASK 0x2 /* bit 1 */
  90. /********** MPU semphore: used for SH & BE ******************/
  91. #define SLIPORT_SOFTRESET_OFFSET 0x5c /* CSR BAR offset */
  92. #define SLIPORT_SEMAPHORE_OFFSET_BEx 0xac /* CSR BAR offset */
  93. #define SLIPORT_SEMAPHORE_OFFSET_SH 0x94 /* PCI-CFG offset */
  94. #define POST_STAGE_MASK 0x0000FFFF
  95. #define POST_ERROR_BIT 0x80000000
  96. #define POST_ERR_RECOVERY_CODE_MASK 0xF000
  97. /* Soft Reset register masks */
  98. #define SLIPORT_SOFTRESET_SR_MASK 0x00000080 /* SR bit */
  99. /* MPU semphore POST stage values */
  100. #define POST_STAGE_AWAITING_HOST_RDY 0x1 /* FW awaiting goahead from host */
  101. #define POST_STAGE_HOST_RDY 0x2 /* Host has given go-ahed to FW */
  102. #define POST_STAGE_BE_RESET 0x3 /* Host wants to reset chip */
  103. #define POST_STAGE_ARMFW_RDY 0xC000 /* FW is done with POST */
  104. #define POST_STAGE_RECOVERABLE_ERR 0xE000 /* Recoverable err detected */
  105. /********** MCC door bell ************/
  106. #define DB_MCCQ_OFFSET 0x140
  107. #define DB_MCCQ_RING_ID_MASK 0xFFFF /* bits 0 - 15 */
  108. /* Number of entries posted */
  109. #define DB_MCCQ_NUM_POSTED_SHIFT 16 /* bits 16 - 29 */
  110. /**
  111. * When the async bit of mcc_compl is set, the last 4 bytes of
  112. * mcc_compl is interpreted as follows:
  113. */
  114. #define ASYNC_TRAILER_EVENT_CODE_SHIFT 8 /* bits 8 - 15 */
  115. #define ASYNC_TRAILER_EVENT_CODE_MASK 0xFF
  116. #define ASYNC_EVENT_CODE_LINK_STATE 0x1
  117. #define ASYNC_EVENT_CODE_ISCSI 0x4
  118. #define ASYNC_EVENT_CODE_SLI 0x11
  119. #define ASYNC_TRAILER_EVENT_TYPE_SHIFT 16 /* bits 16 - 23 */
  120. #define ASYNC_TRAILER_EVENT_TYPE_MASK 0xFF
  121. /* iSCSI events */
  122. #define ASYNC_EVENT_NEW_ISCSI_TGT_DISC 0x4
  123. #define ASYNC_EVENT_NEW_ISCSI_CONN 0x5
  124. #define ASYNC_EVENT_NEW_TCP_CONN 0x7
  125. /* SLI events */
  126. #define ASYNC_SLI_EVENT_TYPE_MISCONFIGURED 0x9
  127. #define ASYNC_SLI_LINK_EFFECT_VALID(le) (le & 0x80)
  128. #define ASYNC_SLI_LINK_EFFECT_SEV(le) ((le >> 1) & 0x03)
  129. #define ASYNC_SLI_LINK_EFFECT_STATE(le) (le & 0x01)
  130. struct be_async_event_trailer {
  131. u32 code;
  132. };
  133. enum {
  134. ASYNC_EVENT_LINK_DOWN = 0x0,
  135. ASYNC_EVENT_LINK_UP = 0x1,
  136. };
  137. /**
  138. * When the event code of an async trailer is link-state, the mcc_compl
  139. * must be interpreted as follows
  140. */
  141. struct be_async_event_link_state {
  142. u8 physical_port;
  143. u8 port_link_status;
  144. /**
  145. * ASYNC_EVENT_LINK_DOWN 0x0
  146. * ASYNC_EVENT_LINK_UP 0x1
  147. * ASYNC_EVENT_LINK_LOGICAL_DOWN 0x2
  148. * ASYNC_EVENT_LINK_LOGICAL_UP 0x3
  149. */
  150. #define BE_ASYNC_LINK_UP_MASK 0x01
  151. u8 port_duplex;
  152. u8 port_speed;
  153. /* BE2ISCSI_LINK_SPEED_ZERO 0x00 - no link */
  154. #define BE2ISCSI_LINK_SPEED_10MBPS 0x01
  155. #define BE2ISCSI_LINK_SPEED_100MBPS 0x02
  156. #define BE2ISCSI_LINK_SPEED_1GBPS 0x03
  157. #define BE2ISCSI_LINK_SPEED_10GBPS 0x04
  158. #define BE2ISCSI_LINK_SPEED_25GBPS 0x06
  159. #define BE2ISCSI_LINK_SPEED_40GBPS 0x07
  160. u8 port_fault;
  161. u8 event_reason;
  162. u16 qos_link_speed;
  163. u32 event_tag;
  164. struct be_async_event_trailer trailer;
  165. } __packed;
  166. /**
  167. * When async-trailer is SLI event, mcc_compl is interpreted as
  168. */
  169. struct be_async_event_sli {
  170. u32 event_data1;
  171. u32 event_data2;
  172. u32 reserved;
  173. u32 trailer;
  174. } __packed;
  175. struct be_mcc_mailbox {
  176. struct be_mcc_wrb wrb;
  177. struct be_mcc_compl compl;
  178. };
  179. /* Type of subsystems supported by FW */
  180. #define CMD_SUBSYSTEM_COMMON 0x1
  181. #define CMD_SUBSYSTEM_ISCSI 0x2
  182. #define CMD_SUBSYSTEM_ETH 0x3
  183. #define CMD_SUBSYSTEM_ISCSI_INI 0x6
  184. #define CMD_COMMON_TCP_UPLOAD 0x1
  185. /**
  186. * List of common opcodes subsystem CMD_SUBSYSTEM_COMMON
  187. * These opcodes are unique for each subsystem defined above
  188. */
  189. #define OPCODE_COMMON_CQ_CREATE 12
  190. #define OPCODE_COMMON_EQ_CREATE 13
  191. #define OPCODE_COMMON_MCC_CREATE 21
  192. #define OPCODE_COMMON_MCC_CREATE_EXT 90
  193. #define OPCODE_COMMON_ADD_TEMPLATE_HEADER_BUFFERS 24
  194. #define OPCODE_COMMON_REMOVE_TEMPLATE_HEADER_BUFFERS 25
  195. #define OPCODE_COMMON_GET_CNTL_ATTRIBUTES 32
  196. #define OPCODE_COMMON_GET_FW_VERSION 35
  197. #define OPCODE_COMMON_MODIFY_EQ_DELAY 41
  198. #define OPCODE_COMMON_FIRMWARE_CONFIG 42
  199. #define OPCODE_COMMON_MCC_DESTROY 53
  200. #define OPCODE_COMMON_CQ_DESTROY 54
  201. #define OPCODE_COMMON_EQ_DESTROY 55
  202. #define OPCODE_COMMON_QUERY_FIRMWARE_CONFIG 58
  203. #define OPCODE_COMMON_FUNCTION_RESET 61
  204. #define OPCODE_COMMON_GET_PORT_NAME 77
  205. #define OPCODE_COMMON_SET_FEATURES 191
  206. /**
  207. * LIST of opcodes that are common between Initiator and Target
  208. * used by CMD_SUBSYSTEM_ISCSI
  209. * These opcodes are unique for each subsystem defined above
  210. */
  211. #define OPCODE_COMMON_ISCSI_CFG_POST_SGL_PAGES 2
  212. #define OPCODE_COMMON_ISCSI_CFG_REMOVE_SGL_PAGES 3
  213. #define OPCODE_COMMON_ISCSI_NTWK_GET_NIC_CONFIG 7
  214. #define OPCODE_COMMON_ISCSI_NTWK_SET_VLAN 14
  215. #define OPCODE_COMMON_ISCSI_NTWK_CONFIG_STATELESS_IP_ADDR 17
  216. #define OPCODE_COMMON_ISCSI_NTWK_REL_STATELESS_IP_ADDR 18
  217. #define OPCODE_COMMON_ISCSI_NTWK_MODIFY_IP_ADDR 21
  218. #define OPCODE_COMMON_ISCSI_NTWK_GET_DEFAULT_GATEWAY 22
  219. #define OPCODE_COMMON_ISCSI_NTWK_MODIFY_DEFAULT_GATEWAY 23
  220. #define OPCODE_COMMON_ISCSI_NTWK_GET_ALL_IF_ID 24
  221. #define OPCODE_COMMON_ISCSI_NTWK_GET_IF_INFO 25
  222. #define OPCODE_COMMON_ISCSI_SET_FRAGNUM_BITS_FOR_SGL_CRA 61
  223. #define OPCODE_COMMON_ISCSI_DEFQ_CREATE 64
  224. #define OPCODE_COMMON_ISCSI_DEFQ_DESTROY 65
  225. #define OPCODE_COMMON_ISCSI_WRBQ_CREATE 66
  226. #define OPCODE_COMMON_ISCSI_WRBQ_DESTROY 67
  227. struct be_cmd_req_hdr {
  228. u8 opcode; /* dword 0 */
  229. u8 subsystem; /* dword 0 */
  230. u8 port_number; /* dword 0 */
  231. u8 domain; /* dword 0 */
  232. u32 timeout; /* dword 1 */
  233. u32 request_length; /* dword 2 */
  234. u8 version; /* dword 3 */
  235. u8 rsvd0[3]; /* dword 3 */
  236. };
  237. struct be_cmd_resp_hdr {
  238. u32 info; /* dword 0 */
  239. u32 status; /* dword 1 */
  240. u32 response_length; /* dword 2 */
  241. u32 actual_resp_len; /* dword 3 */
  242. };
  243. struct phys_addr {
  244. u32 lo;
  245. u32 hi;
  246. };
  247. struct virt_addr {
  248. u32 lo;
  249. u32 hi;
  250. };
  251. /**************************
  252. * BE Command definitions *
  253. **************************/
  254. /**
  255. * Pseudo amap definition in which each bit of the actual structure is defined
  256. * as a byte - used to calculate offset/shift/mask of each field
  257. */
  258. struct amap_eq_context {
  259. u8 cidx[13]; /* dword 0 */
  260. u8 rsvd0[3]; /* dword 0 */
  261. u8 epidx[13]; /* dword 0 */
  262. u8 valid; /* dword 0 */
  263. u8 rsvd1; /* dword 0 */
  264. u8 size; /* dword 0 */
  265. u8 pidx[13]; /* dword 1 */
  266. u8 rsvd2[3]; /* dword 1 */
  267. u8 pd[10]; /* dword 1 */
  268. u8 count[3]; /* dword 1 */
  269. u8 solevent; /* dword 1 */
  270. u8 stalled; /* dword 1 */
  271. u8 armed; /* dword 1 */
  272. u8 rsvd3[4]; /* dword 2 */
  273. u8 func[8]; /* dword 2 */
  274. u8 rsvd4; /* dword 2 */
  275. u8 delaymult[10]; /* dword 2 */
  276. u8 rsvd5[2]; /* dword 2 */
  277. u8 phase[2]; /* dword 2 */
  278. u8 nodelay; /* dword 2 */
  279. u8 rsvd6[4]; /* dword 2 */
  280. u8 rsvd7[32]; /* dword 3 */
  281. } __packed;
  282. struct be_cmd_req_eq_create {
  283. struct be_cmd_req_hdr hdr; /* dw[4] */
  284. u16 num_pages; /* sword */
  285. u16 rsvd0; /* sword */
  286. u8 context[sizeof(struct amap_eq_context) / 8]; /* dw[4] */
  287. struct phys_addr pages[8];
  288. } __packed;
  289. struct be_cmd_resp_eq_create {
  290. struct be_cmd_resp_hdr resp_hdr;
  291. u16 eq_id; /* sword */
  292. u16 rsvd0; /* sword */
  293. } __packed;
  294. struct be_set_eqd {
  295. u32 eq_id;
  296. u32 phase;
  297. u32 delay_multiplier;
  298. } __packed;
  299. struct mgmt_chap_format {
  300. u32 flags;
  301. u8 intr_chap_name[256];
  302. u8 intr_secret[16];
  303. u8 target_chap_name[256];
  304. u8 target_secret[16];
  305. u16 intr_chap_name_length;
  306. u16 intr_secret_length;
  307. u16 target_chap_name_length;
  308. u16 target_secret_length;
  309. } __packed;
  310. struct mgmt_auth_method_format {
  311. u8 auth_method_type;
  312. u8 padding[3];
  313. struct mgmt_chap_format chap;
  314. } __packed;
  315. struct be_cmd_req_logout_fw_sess {
  316. struct be_cmd_req_hdr hdr; /* dw[4] */
  317. uint32_t session_handle;
  318. } __packed;
  319. struct be_cmd_resp_logout_fw_sess {
  320. struct be_cmd_resp_hdr hdr; /* dw[4] */
  321. uint32_t session_status;
  322. #define BE_SESS_STATUS_CLOSE 0x20
  323. } __packed;
  324. struct mgmt_conn_login_options {
  325. u8 flags;
  326. u8 header_digest;
  327. u8 data_digest;
  328. u8 rsvd0;
  329. u32 max_recv_datasegment_len_ini;
  330. u32 max_recv_datasegment_len_tgt;
  331. u32 tcp_mss;
  332. u32 tcp_window_size;
  333. struct mgmt_auth_method_format auth_data;
  334. } __packed;
  335. struct ip_addr_format {
  336. u16 size_of_structure;
  337. u8 reserved;
  338. u8 ip_type;
  339. #define BEISCSI_IP_TYPE_V4 0x1
  340. #define BEISCSI_IP_TYPE_STATIC_V4 0x3
  341. #define BEISCSI_IP_TYPE_DHCP_V4 0x5
  342. /* type v4 values < type v6 values */
  343. #define BEISCSI_IP_TYPE_V6 0x10
  344. #define BEISCSI_IP_TYPE_ROUTABLE_V6 0x30
  345. #define BEISCSI_IP_TYPE_LINK_LOCAL_V6 0x50
  346. #define BEISCSI_IP_TYPE_AUTO_V6 0x90
  347. u8 addr[16];
  348. u32 rsvd0;
  349. } __packed;
  350. struct mgmt_conn_info {
  351. u32 connection_handle;
  352. u32 connection_status;
  353. u16 src_port;
  354. u16 dest_port;
  355. u16 dest_port_redirected;
  356. u16 cid;
  357. u32 estimated_throughput;
  358. struct ip_addr_format src_ipaddr;
  359. struct ip_addr_format dest_ipaddr;
  360. struct ip_addr_format dest_ipaddr_redirected;
  361. struct mgmt_conn_login_options negotiated_login_options;
  362. } __packed;
  363. struct mgmt_session_login_options {
  364. u8 flags;
  365. u8 error_recovery_level;
  366. u16 rsvd0;
  367. u32 first_burst_length;
  368. u32 max_burst_length;
  369. u16 max_connections;
  370. u16 max_outstanding_r2t;
  371. u16 default_time2wait;
  372. u16 default_time2retain;
  373. } __packed;
  374. struct mgmt_session_info {
  375. u32 session_handle;
  376. u32 status;
  377. u8 isid[6];
  378. u16 tsih;
  379. u32 session_flags;
  380. u16 conn_count;
  381. u16 pad;
  382. u8 target_name[224];
  383. u8 initiator_iscsiname[224];
  384. struct mgmt_session_login_options negotiated_login_options;
  385. struct mgmt_conn_info conn_list[1];
  386. } __packed;
  387. struct be_cmd_get_session_req {
  388. struct be_cmd_req_hdr hdr;
  389. u32 session_handle;
  390. } __packed;
  391. struct be_cmd_get_session_resp {
  392. struct be_cmd_resp_hdr hdr;
  393. struct mgmt_session_info session_info;
  394. } __packed;
  395. struct mac_addr {
  396. u16 size_of_structure;
  397. u8 addr[ETH_ALEN];
  398. } __packed;
  399. struct be_cmd_get_boot_target_req {
  400. struct be_cmd_req_hdr hdr;
  401. } __packed;
  402. struct be_cmd_get_boot_target_resp {
  403. struct be_cmd_resp_hdr hdr;
  404. u32 boot_session_count;
  405. u32 boot_session_handle;
  406. /**
  407. * FW returns 0xffffffff if it couldn't establish connection with
  408. * configured boot target.
  409. */
  410. #define BE_BOOT_INVALID_SHANDLE 0xffffffff
  411. };
  412. struct be_cmd_reopen_session_req {
  413. struct be_cmd_req_hdr hdr;
  414. #define BE_REOPEN_ALL_SESSIONS 0x00
  415. #define BE_REOPEN_BOOT_SESSIONS 0x01
  416. #define BE_REOPEN_A_SESSION 0x02
  417. u16 reopen_type;
  418. u16 rsvd;
  419. u32 session_handle;
  420. } __packed;
  421. struct be_cmd_reopen_session_resp {
  422. struct be_cmd_resp_hdr hdr;
  423. u32 rsvd;
  424. u32 session_handle;
  425. } __packed;
  426. struct be_cmd_mac_query_req {
  427. struct be_cmd_req_hdr hdr;
  428. u8 type;
  429. u8 permanent;
  430. u16 if_id;
  431. } __packed;
  432. struct be_cmd_get_mac_resp {
  433. struct be_cmd_resp_hdr hdr;
  434. struct mac_addr mac;
  435. };
  436. struct be_ip_addr_subnet_format {
  437. u16 size_of_structure;
  438. u8 ip_type;
  439. u8 ipv6_prefix_length;
  440. u8 addr[16];
  441. u8 subnet_mask[16];
  442. u32 rsvd0;
  443. } __packed;
  444. struct be_cmd_get_if_info_req {
  445. struct be_cmd_req_hdr hdr;
  446. u32 interface_hndl;
  447. u32 ip_type;
  448. } __packed;
  449. struct be_cmd_get_if_info_resp {
  450. struct be_cmd_req_hdr hdr;
  451. u32 interface_hndl;
  452. u32 vlan_priority;
  453. u32 ip_addr_count;
  454. u32 dhcp_state;
  455. struct be_ip_addr_subnet_format ip_addr;
  456. } __packed;
  457. struct be_ip_addr_record {
  458. u32 action;
  459. u32 interface_hndl;
  460. struct be_ip_addr_subnet_format ip_addr;
  461. u32 status;
  462. } __packed;
  463. struct be_ip_addr_record_params {
  464. u32 record_entry_count;
  465. struct be_ip_addr_record ip_record;
  466. } __packed;
  467. struct be_cmd_set_ip_addr_req {
  468. struct be_cmd_req_hdr hdr;
  469. struct be_ip_addr_record_params ip_params;
  470. } __packed;
  471. struct be_cmd_set_dhcp_req {
  472. struct be_cmd_req_hdr hdr;
  473. u32 interface_hndl;
  474. u32 ip_type;
  475. u32 flags;
  476. u32 retry_count;
  477. } __packed;
  478. struct be_cmd_rel_dhcp_req {
  479. struct be_cmd_req_hdr hdr;
  480. u32 interface_hndl;
  481. u32 ip_type;
  482. } __packed;
  483. struct be_cmd_set_def_gateway_req {
  484. struct be_cmd_req_hdr hdr;
  485. u32 action;
  486. struct ip_addr_format ip_addr;
  487. } __packed;
  488. struct be_cmd_get_def_gateway_req {
  489. struct be_cmd_req_hdr hdr;
  490. u32 ip_type;
  491. } __packed;
  492. struct be_cmd_get_def_gateway_resp {
  493. struct be_cmd_req_hdr hdr;
  494. struct ip_addr_format ip_addr;
  495. } __packed;
  496. #define BEISCSI_VLAN_DISABLE 0xFFFF
  497. struct be_cmd_set_vlan_req {
  498. struct be_cmd_req_hdr hdr;
  499. u32 interface_hndl;
  500. u32 vlan_priority;
  501. } __packed;
  502. /******************** Create CQ ***************************/
  503. /**
  504. * Pseudo amap definition in which each bit of the actual structure is defined
  505. * as a byte - used to calculate offset/shift/mask of each field
  506. */
  507. struct amap_cq_context {
  508. u8 cidx[11]; /* dword 0 */
  509. u8 rsvd0; /* dword 0 */
  510. u8 coalescwm[2]; /* dword 0 */
  511. u8 nodelay; /* dword 0 */
  512. u8 epidx[11]; /* dword 0 */
  513. u8 rsvd1; /* dword 0 */
  514. u8 count[2]; /* dword 0 */
  515. u8 valid; /* dword 0 */
  516. u8 solevent; /* dword 0 */
  517. u8 eventable; /* dword 0 */
  518. u8 pidx[11]; /* dword 1 */
  519. u8 rsvd2; /* dword 1 */
  520. u8 pd[10]; /* dword 1 */
  521. u8 eqid[8]; /* dword 1 */
  522. u8 stalled; /* dword 1 */
  523. u8 armed; /* dword 1 */
  524. u8 rsvd3[4]; /* dword 2 */
  525. u8 func[8]; /* dword 2 */
  526. u8 rsvd4[20]; /* dword 2 */
  527. u8 rsvd5[32]; /* dword 3 */
  528. } __packed;
  529. struct amap_cq_context_v2 {
  530. u8 rsvd0[12]; /* dword 0 */
  531. u8 coalescwm[2]; /* dword 0 */
  532. u8 nodelay; /* dword 0 */
  533. u8 rsvd1[12]; /* dword 0 */
  534. u8 count[2]; /* dword 0 */
  535. u8 valid; /* dword 0 */
  536. u8 rsvd2; /* dword 0 */
  537. u8 eventable; /* dword 0 */
  538. u8 eqid[16]; /* dword 1 */
  539. u8 rsvd3[15]; /* dword 1 */
  540. u8 armed; /* dword 1 */
  541. u8 cqecount[16];/* dword 2 */
  542. u8 rsvd4[16]; /* dword 2 */
  543. u8 rsvd5[32]; /* dword 3 */
  544. };
  545. struct be_cmd_req_cq_create {
  546. struct be_cmd_req_hdr hdr;
  547. u16 num_pages;
  548. u8 page_size;
  549. u8 rsvd0;
  550. u8 context[sizeof(struct amap_cq_context) / 8];
  551. struct phys_addr pages[4];
  552. } __packed;
  553. struct be_cmd_resp_cq_create {
  554. struct be_cmd_resp_hdr hdr;
  555. u16 cq_id;
  556. u16 rsvd0;
  557. } __packed;
  558. /******************** Create MCCQ ***************************/
  559. /**
  560. * Pseudo amap definition in which each bit of the actual structure is defined
  561. * as a byte - used to calculate offset/shift/mask of each field
  562. */
  563. struct amap_mcc_context {
  564. u8 con_index[14];
  565. u8 rsvd0[2];
  566. u8 ring_size[4];
  567. u8 fetch_wrb;
  568. u8 fetch_r2t;
  569. u8 cq_id[10];
  570. u8 prod_index[14];
  571. u8 fid[8];
  572. u8 pdid[9];
  573. u8 valid;
  574. u8 rsvd1[32];
  575. u8 rsvd2[32];
  576. } __packed;
  577. struct be_cmd_req_mcc_create_ext {
  578. struct be_cmd_req_hdr hdr;
  579. u16 num_pages;
  580. u16 rsvd0;
  581. u32 async_evt_bitmap;
  582. u8 context[sizeof(struct amap_mcc_context) / 8];
  583. struct phys_addr pages[8];
  584. } __packed;
  585. struct be_cmd_resp_mcc_create {
  586. struct be_cmd_resp_hdr hdr;
  587. u16 id;
  588. u16 rsvd0;
  589. } __packed;
  590. /******************** Q Destroy ***************************/
  591. /* Type of Queue to be destroyed */
  592. enum {
  593. QTYPE_EQ = 1,
  594. QTYPE_CQ,
  595. QTYPE_MCCQ,
  596. QTYPE_WRBQ,
  597. QTYPE_DPDUQ,
  598. QTYPE_SGL
  599. };
  600. struct be_cmd_req_q_destroy {
  601. struct be_cmd_req_hdr hdr;
  602. u16 id;
  603. u16 bypass_flush; /* valid only for rx q destroy */
  604. } __packed;
  605. struct macaddr {
  606. u8 byte[ETH_ALEN];
  607. };
  608. struct be_cmd_req_mcast_mac_config {
  609. struct be_cmd_req_hdr hdr;
  610. u16 num_mac;
  611. u8 promiscuous;
  612. u8 interface_id;
  613. struct macaddr mac[32];
  614. } __packed;
  615. static inline void *embedded_payload(struct be_mcc_wrb *wrb)
  616. {
  617. return wrb->payload.embedded_payload;
  618. }
  619. static inline struct be_sge *nonembedded_sgl(struct be_mcc_wrb *wrb)
  620. {
  621. return &wrb->payload.sgl[0];
  622. }
  623. /******************** Modify EQ Delay *******************/
  624. struct be_cmd_req_modify_eq_delay {
  625. struct be_cmd_req_hdr hdr;
  626. __le32 num_eq;
  627. struct {
  628. __le32 eq_id;
  629. __le32 phase;
  630. __le32 delay_multiplier;
  631. } delay[MAX_CPUS];
  632. } __packed;
  633. /******************** Get MAC ADDR *******************/
  634. struct be_cmd_get_nic_conf_resp {
  635. struct be_cmd_resp_hdr hdr;
  636. u32 nic_port_count;
  637. u32 speed;
  638. u32 max_speed;
  639. u32 link_state;
  640. u32 max_frame_size;
  641. u16 size_of_structure;
  642. u8 mac_address[ETH_ALEN];
  643. } __packed;
  644. /******************** Get HBA NAME *******************/
  645. struct be_cmd_hba_name {
  646. struct be_cmd_req_hdr hdr;
  647. u16 flags;
  648. u16 rsvd0;
  649. u8 initiator_name[ISCSI_NAME_LEN];
  650. #define BE_INI_ALIAS_LEN 32
  651. u8 initiator_alias[BE_INI_ALIAS_LEN];
  652. } __packed;
  653. /******************** COMMON SET Features *******************/
  654. #define BE_CMD_SET_FEATURE_UER 0x10
  655. #define BE_CMD_UER_SUPP_BIT 0x1
  656. struct be_uer_req {
  657. u32 uer;
  658. u32 rsvd;
  659. };
  660. struct be_uer_resp {
  661. u32 uer;
  662. u16 ue2rp;
  663. u16 ue2sr;
  664. };
  665. struct be_cmd_set_features {
  666. union {
  667. struct be_cmd_req_hdr req_hdr;
  668. struct be_cmd_resp_hdr resp_hdr;
  669. } h;
  670. u32 feature;
  671. u32 param_len;
  672. union {
  673. struct be_uer_req req;
  674. struct be_uer_resp resp;
  675. u32 rsvd[2];
  676. } param;
  677. } __packed;
  678. int beiscsi_cmd_function_reset(struct beiscsi_hba *phba);
  679. int beiscsi_cmd_special_wrb(struct be_ctrl_info *ctrl, u32 load);
  680. int beiscsi_check_fw_rdy(struct beiscsi_hba *phba);
  681. int beiscsi_init_sliport(struct beiscsi_hba *phba);
  682. int beiscsi_cmd_iscsi_cleanup(struct beiscsi_hba *phba, unsigned short ulp_num);
  683. int beiscsi_detect_ue(struct beiscsi_hba *phba);
  684. int beiscsi_detect_tpe(struct beiscsi_hba *phba);
  685. int beiscsi_cmd_eq_create(struct be_ctrl_info *ctrl,
  686. struct be_queue_info *eq, int eq_delay);
  687. int beiscsi_cmd_cq_create(struct be_ctrl_info *ctrl,
  688. struct be_queue_info *cq, struct be_queue_info *eq,
  689. bool sol_evts, bool no_delay,
  690. int num_cqe_dma_coalesce);
  691. int beiscsi_cmd_q_destroy(struct be_ctrl_info *ctrl, struct be_queue_info *q,
  692. int type);
  693. int beiscsi_cmd_mccq_create(struct beiscsi_hba *phba,
  694. struct be_queue_info *mccq,
  695. struct be_queue_info *cq);
  696. unsigned int be_cmd_get_initname(struct beiscsi_hba *phba);
  697. void free_mcc_wrb(struct be_ctrl_info *ctrl, unsigned int tag);
  698. int beiscsi_modify_eq_delay(struct beiscsi_hba *phba, struct be_set_eqd *,
  699. int num);
  700. int beiscsi_mccq_compl_wait(struct beiscsi_hba *phba,
  701. unsigned int tag,
  702. struct be_mcc_wrb **wrb,
  703. struct be_dma_mem *mbx_cmd_mem);
  704. int __beiscsi_mcc_compl_status(struct beiscsi_hba *phba,
  705. unsigned int tag,
  706. struct be_mcc_wrb **wrb,
  707. struct be_dma_mem *mbx_cmd_mem);
  708. struct be_mcc_wrb *wrb_from_mbox(struct be_dma_mem *mbox_mem);
  709. void be_mcc_notify(struct beiscsi_hba *phba, unsigned int tag);
  710. struct be_mcc_wrb *alloc_mcc_wrb(struct beiscsi_hba *phba,
  711. unsigned int *ref_tag);
  712. void beiscsi_process_async_event(struct beiscsi_hba *phba,
  713. struct be_mcc_compl *compl);
  714. int beiscsi_process_mcc_compl(struct be_ctrl_info *ctrl,
  715. struct be_mcc_compl *compl);
  716. int be_cmd_create_default_pdu_queue(struct be_ctrl_info *ctrl,
  717. struct be_queue_info *cq,
  718. struct be_queue_info *dq, int length,
  719. int entry_size, uint8_t is_header,
  720. uint8_t ulp_num);
  721. int be_cmd_iscsi_post_template_hdr(struct be_ctrl_info *ctrl,
  722. struct be_dma_mem *q_mem);
  723. int be_cmd_iscsi_remove_template_hdr(struct be_ctrl_info *ctrl);
  724. int be_cmd_iscsi_post_sgl_pages(struct be_ctrl_info *ctrl,
  725. struct be_dma_mem *q_mem, u32 page_offset,
  726. u32 num_pages);
  727. int be_cmd_wrbq_create(struct be_ctrl_info *ctrl, struct be_dma_mem *q_mem,
  728. struct be_queue_info *wrbq,
  729. struct hwi_wrb_context *pwrb_context,
  730. uint8_t ulp_num);
  731. /* Configuration Functions */
  732. int be_cmd_set_vlan(struct beiscsi_hba *phba, uint16_t vlan_tag);
  733. int beiscsi_check_supported_fw(struct be_ctrl_info *ctrl,
  734. struct beiscsi_hba *phba);
  735. int beiscsi_get_fw_config(struct be_ctrl_info *ctrl, struct beiscsi_hba *phba);
  736. int beiscsi_get_port_name(struct be_ctrl_info *ctrl, struct beiscsi_hba *phba);
  737. int beiscsi_set_uer_feature(struct beiscsi_hba *phba);
  738. struct be_default_pdu_context {
  739. u32 dw[4];
  740. } __packed;
  741. struct amap_be_default_pdu_context {
  742. u8 dbuf_cindex[13]; /* dword 0 */
  743. u8 rsvd0[3]; /* dword 0 */
  744. u8 ring_size[4]; /* dword 0 */
  745. u8 ring_state[4]; /* dword 0 */
  746. u8 rsvd1[8]; /* dword 0 */
  747. u8 dbuf_pindex[13]; /* dword 1 */
  748. u8 rsvd2; /* dword 1 */
  749. u8 pci_func_id[8]; /* dword 1 */
  750. u8 rx_pdid[9]; /* dword 1 */
  751. u8 rx_pdid_valid; /* dword 1 */
  752. u8 default_buffer_size[16]; /* dword 2 */
  753. u8 cq_id_recv[10]; /* dword 2 */
  754. u8 rx_pdid_not_valid; /* dword 2 */
  755. u8 rsvd3[5]; /* dword 2 */
  756. u8 rsvd4[32]; /* dword 3 */
  757. } __packed;
  758. struct amap_default_pdu_context_ext {
  759. u8 rsvd0[16]; /* dword 0 */
  760. u8 ring_size[4]; /* dword 0 */
  761. u8 rsvd1[12]; /* dword 0 */
  762. u8 rsvd2[22]; /* dword 1 */
  763. u8 rx_pdid[9]; /* dword 1 */
  764. u8 rx_pdid_valid; /* dword 1 */
  765. u8 default_buffer_size[16]; /* dword 2 */
  766. u8 cq_id_recv[16]; /* dword 2 */
  767. u8 rsvd3[32]; /* dword 3 */
  768. } __packed;
  769. struct be_defq_create_req {
  770. struct be_cmd_req_hdr hdr;
  771. u16 num_pages;
  772. u8 ulp_num;
  773. #define BEISCSI_DUAL_ULP_AWARE_BIT 0 /* Byte 3 - Bit 0 */
  774. #define BEISCSI_BIND_Q_TO_ULP_BIT 1 /* Byte 3 - Bit 1 */
  775. u8 dua_feature;
  776. struct be_default_pdu_context context;
  777. struct phys_addr pages[8];
  778. } __packed;
  779. struct be_defq_create_resp {
  780. struct be_cmd_req_hdr hdr;
  781. u16 id;
  782. u8 rsvd0;
  783. u8 ulp_num;
  784. u32 doorbell_offset;
  785. u16 register_set;
  786. u16 doorbell_format;
  787. } __packed;
  788. struct be_post_template_pages_req {
  789. struct be_cmd_req_hdr hdr;
  790. u16 num_pages;
  791. #define BEISCSI_TEMPLATE_HDR_TYPE_ISCSI 0x1
  792. u16 type;
  793. struct phys_addr scratch_pa;
  794. struct virt_addr scratch_va;
  795. struct virt_addr pages_va;
  796. struct phys_addr pages[16];
  797. } __packed;
  798. struct be_remove_template_pages_req {
  799. struct be_cmd_req_hdr hdr;
  800. u16 type;
  801. u16 rsvd0;
  802. } __packed;
  803. struct be_post_sgl_pages_req {
  804. struct be_cmd_req_hdr hdr;
  805. u16 num_pages;
  806. u16 page_offset;
  807. u32 rsvd0;
  808. struct phys_addr pages[26];
  809. u32 rsvd1;
  810. } __packed;
  811. struct be_wrbq_create_req {
  812. struct be_cmd_req_hdr hdr;
  813. u16 num_pages;
  814. u8 ulp_num;
  815. u8 dua_feature;
  816. struct phys_addr pages[8];
  817. } __packed;
  818. struct be_wrbq_create_resp {
  819. struct be_cmd_resp_hdr resp_hdr;
  820. u16 cid;
  821. u8 rsvd0;
  822. u8 ulp_num;
  823. u32 doorbell_offset;
  824. u16 register_set;
  825. u16 doorbell_format;
  826. } __packed;
  827. #define SOL_CID_MASK 0x0000FFC0
  828. #define SOL_CODE_MASK 0x0000003F
  829. #define SOL_WRB_INDEX_MASK 0x00FF0000
  830. #define SOL_CMD_WND_MASK 0xFF000000
  831. #define SOL_RES_CNT_MASK 0x7FFFFFFF
  832. #define SOL_EXP_CMD_SN_MASK 0xFFFFFFFF
  833. #define SOL_HW_STS_MASK 0x000000FF
  834. #define SOL_STS_MASK 0x0000FF00
  835. #define SOL_RESP_MASK 0x00FF0000
  836. #define SOL_FLAGS_MASK 0x7F000000
  837. #define SOL_S_MASK 0x80000000
  838. struct sol_cqe {
  839. u32 dw[4];
  840. };
  841. struct amap_sol_cqe {
  842. u8 hw_sts[8]; /* dword 0 */
  843. u8 i_sts[8]; /* dword 0 */
  844. u8 i_resp[8]; /* dword 0 */
  845. u8 i_flags[7]; /* dword 0 */
  846. u8 s; /* dword 0 */
  847. u8 i_exp_cmd_sn[32]; /* dword 1 */
  848. u8 code[6]; /* dword 2 */
  849. u8 cid[10]; /* dword 2 */
  850. u8 wrb_index[8]; /* dword 2 */
  851. u8 i_cmd_wnd[8]; /* dword 2 */
  852. u8 i_res_cnt[31]; /* dword 3 */
  853. u8 valid; /* dword 3 */
  854. } __packed;
  855. #define SOL_ICD_INDEX_MASK 0x0003FFC0
  856. struct amap_sol_cqe_ring {
  857. u8 hw_sts[8]; /* dword 0 */
  858. u8 i_sts[8]; /* dword 0 */
  859. u8 i_resp[8]; /* dword 0 */
  860. u8 i_flags[7]; /* dword 0 */
  861. u8 s; /* dword 0 */
  862. u8 i_exp_cmd_sn[32]; /* dword 1 */
  863. u8 code[6]; /* dword 2 */
  864. u8 icd_index[12]; /* dword 2 */
  865. u8 rsvd[6]; /* dword 2 */
  866. u8 i_cmd_wnd[8]; /* dword 2 */
  867. u8 i_res_cnt[31]; /* dword 3 */
  868. u8 valid; /* dword 3 */
  869. } __packed;
  870. struct amap_sol_cqe_v2 {
  871. u8 hw_sts[8]; /* dword 0 */
  872. u8 i_sts[8]; /* dword 0 */
  873. u8 wrb_index[16]; /* dword 0 */
  874. u8 i_exp_cmd_sn[32]; /* dword 1 */
  875. u8 code[6]; /* dword 2 */
  876. u8 cmd_cmpl; /* dword 2 */
  877. u8 rsvd0; /* dword 2 */
  878. u8 i_cmd_wnd[8]; /* dword 2 */
  879. u8 cid[13]; /* dword 2 */
  880. u8 u; /* dword 2 */
  881. u8 o; /* dword 2 */
  882. u8 s; /* dword 2 */
  883. u8 i_res_cnt[31]; /* dword 3 */
  884. u8 valid; /* dword 3 */
  885. } __packed;
  886. struct common_sol_cqe {
  887. u32 exp_cmdsn;
  888. u32 res_cnt;
  889. u16 wrb_index;
  890. u16 cid;
  891. u8 hw_sts;
  892. u8 cmd_wnd;
  893. u8 res_flag; /* the s feild of structure */
  894. u8 i_resp; /* for skh if cmd_complete is set then i_sts is response */
  895. u8 i_flags; /* for skh or the u and o feilds */
  896. u8 i_sts; /* for skh if cmd_complete is not-set then i_sts is status */
  897. };
  898. /*** iSCSI ack/driver message completions ***/
  899. struct amap_it_dmsg_cqe {
  900. u8 ack_num[32]; /* DWORD 0 */
  901. u8 pdu_bytes_rcvd[32]; /* DWORD 1 */
  902. u8 code[6]; /* DWORD 2 */
  903. u8 cid[10]; /* DWORD 2 */
  904. u8 wrb_idx[8]; /* DWORD 2 */
  905. u8 rsvd0[8]; /* DWORD 2*/
  906. u8 rsvd1[31]; /* DWORD 3*/
  907. u8 valid; /* DWORD 3 */
  908. } __packed;
  909. struct amap_it_dmsg_cqe_v2 {
  910. u8 ack_num[32]; /* DWORD 0 */
  911. u8 pdu_bytes_rcvd[32]; /* DWORD 1 */
  912. u8 code[6]; /* DWORD 2 */
  913. u8 rsvd0[10]; /* DWORD 2 */
  914. u8 wrb_idx[16]; /* DWORD 2 */
  915. u8 rsvd1[16]; /* DWORD 3 */
  916. u8 cid[13]; /* DWORD 3 */
  917. u8 rsvd2[2]; /* DWORD 3 */
  918. u8 valid; /* DWORD 3 */
  919. } __packed;
  920. /**
  921. * Post WRB Queue Doorbell Register used by the host Storage
  922. * stack to notify the
  923. * controller of a posted Work Request Block
  924. */
  925. #define DB_WRB_POST_CID_MASK 0xFFFF /* bits 0 - 16 */
  926. #define DB_DEF_PDU_WRB_INDEX_MASK 0xFF /* bits 0 - 9 */
  927. #define DB_DEF_PDU_WRB_INDEX_SHIFT 16
  928. #define DB_DEF_PDU_NUM_POSTED_SHIFT 24
  929. struct fragnum_bits_for_sgl_cra_in {
  930. struct be_cmd_req_hdr hdr;
  931. u32 num_bits;
  932. } __packed;
  933. struct iscsi_cleanup_req {
  934. struct be_cmd_req_hdr hdr;
  935. u16 chute;
  936. u8 hdr_ring_id;
  937. u8 data_ring_id;
  938. } __packed;
  939. struct iscsi_cleanup_req_v1 {
  940. struct be_cmd_req_hdr hdr;
  941. u16 chute;
  942. u16 rsvd1;
  943. u16 hdr_ring_id;
  944. u16 rsvd2;
  945. u16 data_ring_id;
  946. u16 rsvd3;
  947. } __packed;
  948. struct eq_delay {
  949. u32 eq_id;
  950. u32 phase;
  951. u32 delay_multiplier;
  952. } __packed;
  953. struct be_eq_delay_params_in {
  954. struct be_cmd_req_hdr hdr;
  955. u32 num_eq;
  956. struct eq_delay delay[8];
  957. } __packed;
  958. struct tcp_connect_and_offload_in {
  959. struct be_cmd_req_hdr hdr;
  960. struct ip_addr_format ip_address;
  961. u16 tcp_port;
  962. u16 cid;
  963. u16 cq_id;
  964. u16 defq_id;
  965. struct phys_addr dataout_template_pa;
  966. u16 hdr_ring_id;
  967. u16 data_ring_id;
  968. u8 do_offload;
  969. u8 rsvd0[3];
  970. } __packed;
  971. struct tcp_connect_and_offload_in_v1 {
  972. struct be_cmd_req_hdr hdr;
  973. struct ip_addr_format ip_address;
  974. u16 tcp_port;
  975. u16 cid;
  976. u16 cq_id;
  977. u16 defq_id;
  978. struct phys_addr dataout_template_pa;
  979. u16 hdr_ring_id;
  980. u16 data_ring_id;
  981. u8 do_offload;
  982. u8 ifd_state;
  983. u8 rsvd0[2];
  984. u16 tcp_window_size;
  985. u8 tcp_window_scale_count;
  986. u8 rsvd1;
  987. u32 tcp_mss:24;
  988. u8 rsvd2;
  989. } __packed;
  990. struct tcp_connect_and_offload_out {
  991. struct be_cmd_resp_hdr hdr;
  992. u32 connection_handle;
  993. u16 cid;
  994. u16 rsvd0;
  995. } __packed;
  996. struct be_mcc_wrb_context {
  997. struct MCC_WRB *wrb;
  998. int *users_final_status;
  999. } __packed;
  1000. #define DB_DEF_PDU_RING_ID_MASK 0x3FFF /* bits 0 - 13 */
  1001. #define DB_DEF_PDU_CQPROC_MASK 0x3FFF /* bits 16 - 29 */
  1002. #define DB_DEF_PDU_REARM_SHIFT 14
  1003. #define DB_DEF_PDU_EVENT_SHIFT 15
  1004. #define DB_DEF_PDU_CQPROC_SHIFT 16
  1005. struct dmsg_cqe {
  1006. u32 dw[4];
  1007. } __packed;
  1008. struct tcp_upload_params_in {
  1009. struct be_cmd_req_hdr hdr;
  1010. u16 id;
  1011. u16 upload_type;
  1012. u32 reset_seq;
  1013. } __packed;
  1014. struct tcp_upload_params_out {
  1015. u32 dw[32];
  1016. } __packed;
  1017. union tcp_upload_params {
  1018. struct tcp_upload_params_in request;
  1019. struct tcp_upload_params_out response;
  1020. } __packed;
  1021. struct be_ulp_fw_cfg {
  1022. #define BEISCSI_ULP_ISCSI_INI_MODE 0x10
  1023. u32 ulp_mode;
  1024. u32 etx_base;
  1025. u32 etx_count;
  1026. u32 sq_base;
  1027. u32 sq_count;
  1028. u32 rq_base;
  1029. u32 rq_count;
  1030. u32 dq_base;
  1031. u32 dq_count;
  1032. u32 lro_base;
  1033. u32 lro_count;
  1034. u32 icd_base;
  1035. u32 icd_count;
  1036. };
  1037. struct be_ulp_chain_icd {
  1038. u32 chain_base;
  1039. u32 chain_count;
  1040. };
  1041. struct be_fw_cfg {
  1042. struct be_cmd_req_hdr hdr;
  1043. u32 be_config_number;
  1044. u32 asic_revision;
  1045. u32 phys_port;
  1046. #define BEISCSI_FUNC_ISCSI_INI_MODE 0x10
  1047. #define BEISCSI_FUNC_DUA_MODE 0x800
  1048. u32 function_mode;
  1049. struct be_ulp_fw_cfg ulp[2];
  1050. u32 function_caps;
  1051. u32 cqid_base;
  1052. u32 cqid_count;
  1053. u32 eqid_base;
  1054. u32 eqid_count;
  1055. struct be_ulp_chain_icd chain_icd[2];
  1056. } __packed;
  1057. struct be_cmd_get_all_if_id_req {
  1058. struct be_cmd_req_hdr hdr;
  1059. u32 if_count;
  1060. u32 if_hndl_list[1];
  1061. } __packed;
  1062. struct be_cmd_get_port_name {
  1063. union {
  1064. struct be_cmd_req_hdr req_hdr;
  1065. struct be_cmd_resp_hdr resp_hdr;
  1066. } h;
  1067. union {
  1068. struct {
  1069. u32 reserved;
  1070. } req;
  1071. struct {
  1072. u32 port_names;
  1073. } resp;
  1074. } p;
  1075. } __packed;
  1076. #define ISCSI_OPCODE_SCSI_DATA_OUT 5
  1077. #define OPCODE_COMMON_NTWK_LINK_STATUS_QUERY 5
  1078. #define OPCODE_COMMON_MODIFY_EQ_DELAY 41
  1079. #define OPCODE_COMMON_ISCSI_CLEANUP 59
  1080. #define OPCODE_COMMON_TCP_UPLOAD 56
  1081. #define OPCODE_COMMON_ISCSI_TCP_CONNECT_AND_OFFLOAD 70
  1082. #define OPCODE_COMMON_ISCSI_ERROR_RECOVERY_INVALIDATE_COMMANDS 1
  1083. #define OPCODE_ISCSI_INI_CFG_GET_HBA_NAME 6
  1084. #define OPCODE_ISCSI_INI_CFG_SET_HBA_NAME 7
  1085. #define OPCODE_ISCSI_INI_SESSION_GET_A_SESSION 14
  1086. #define OPCODE_ISCSI_INI_SESSION_LOGOUT_TARGET 24
  1087. #define OPCODE_ISCSI_INI_DRIVER_REOPEN_ALL_SESSIONS 36
  1088. #define OPCODE_ISCSI_INI_DRIVER_OFFLOAD_SESSION 41
  1089. #define OPCODE_ISCSI_INI_DRIVER_INVALIDATE_CONNECTION 42
  1090. #define OPCODE_ISCSI_INI_BOOT_GET_BOOT_TARGET 52
  1091. #define OPCODE_COMMON_WRITE_FLASH 96
  1092. #define OPCODE_COMMON_READ_FLASH 97
  1093. /* --- CMD_ISCSI_INVALIDATE_CONNECTION_TYPE --- */
  1094. #define CMD_ISCSI_COMMAND_INVALIDATE 1
  1095. #define CMD_ISCSI_CONNECTION_INVALIDATE 0x8001
  1096. #define CMD_ISCSI_CONNECTION_ISSUE_TCP_RST 0x8002
  1097. #define INI_WR_CMD 1 /* Initiator write command */
  1098. #define INI_TMF_CMD 2 /* Initiator TMF command */
  1099. #define INI_NOPOUT_CMD 3 /* Initiator; Send a NOP-OUT */
  1100. #define INI_RD_CMD 5 /* Initiator requesting to send
  1101. * a read command
  1102. */
  1103. #define TGT_CTX_UPDT_CMD 7 /* Target context update */
  1104. #define TGT_STS_CMD 8 /* Target R2T and other BHS
  1105. * where only the status number
  1106. * need to be updated
  1107. */
  1108. #define TGT_DATAIN_CMD 9 /* Target Data-Ins in response
  1109. * to read command
  1110. */
  1111. #define TGT_SOS_PDU 10 /* Target:standalone status
  1112. * response
  1113. */
  1114. #define TGT_DM_CMD 11 /* Indicates that the bhs
  1115. * preparedby
  1116. * driver should not be touched
  1117. */
  1118. /* --- CMD_CHUTE_TYPE --- */
  1119. #define CMD_CONNECTION_CHUTE_0 1
  1120. #define CMD_CONNECTION_CHUTE_1 2
  1121. #define CMD_CONNECTION_CHUTE_2 3
  1122. #define EQ_MAJOR_CODE_COMPLETION 0
  1123. #define CMD_ISCSI_SESSION_DEL_CFG_FROM_FLASH 0
  1124. #define CMD_ISCSI_SESSION_SAVE_CFG_ON_FLASH 1
  1125. /* --- CONNECTION_UPLOAD_PARAMS --- */
  1126. /* These parameters are used to define the type of upload desired. */
  1127. #define CONNECTION_UPLOAD_GRACEFUL 1 /* Graceful upload */
  1128. #define CONNECTION_UPLOAD_ABORT_RESET 2 /* Abortive upload with
  1129. * reset
  1130. */
  1131. #define CONNECTION_UPLOAD_ABORT 3 /* Abortive upload without
  1132. * reset
  1133. */
  1134. #define CONNECTION_UPLOAD_ABORT_WITH_SEQ 4 /* Abortive upload with reset,
  1135. * sequence number by driver */
  1136. /* Returns the number of items in the field array. */
  1137. #define BE_NUMBER_OF_FIELD(_type_, _field_) \
  1138. (FIELD_SIZEOF(_type_, _field_)/sizeof((((_type_ *)0)->_field_[0])))\
  1139. /**
  1140. * Different types of iSCSI completions to host driver for both initiator
  1141. * and taget mode
  1142. * of operation.
  1143. */
  1144. #define SOL_CMD_COMPLETE 1 /* Solicited command completed
  1145. * normally
  1146. */
  1147. #define SOL_CMD_KILLED_DATA_DIGEST_ERR 2 /* Solicited command got
  1148. * invalidated internally due
  1149. * to Data Digest error
  1150. */
  1151. #define CXN_KILLED_PDU_SIZE_EXCEEDS_DSL 3 /* Connection got invalidated
  1152. * internally
  1153. * due to a received PDU
  1154. * size > DSL
  1155. */
  1156. #define CXN_KILLED_BURST_LEN_MISMATCH 4 /* Connection got invalidated
  1157. * internally due ti received
  1158. * PDU sequence size >
  1159. * FBL/MBL.
  1160. */
  1161. #define CXN_KILLED_AHS_RCVD 5 /* Connection got invalidated
  1162. * internally due to a received
  1163. * PDU Hdr that has
  1164. * AHS */
  1165. #define CXN_KILLED_HDR_DIGEST_ERR 6 /* Connection got invalidated
  1166. * internally due to Hdr Digest
  1167. * error
  1168. */
  1169. #define CXN_KILLED_UNKNOWN_HDR 7 /* Connection got invalidated
  1170. * internally
  1171. * due to a bad opcode in the
  1172. * pdu hdr
  1173. */
  1174. #define CXN_KILLED_STALE_ITT_TTT_RCVD 8 /* Connection got invalidated
  1175. * internally due to a received
  1176. * ITT/TTT that does not belong
  1177. * to this Connection
  1178. */
  1179. #define CXN_KILLED_INVALID_ITT_TTT_RCVD 9 /* Connection got invalidated
  1180. * internally due to received
  1181. * ITT/TTT value > Max
  1182. * Supported ITTs/TTTs
  1183. */
  1184. #define CXN_KILLED_RST_RCVD 10 /* Connection got invalidated
  1185. * internally due to an
  1186. * incoming TCP RST
  1187. */
  1188. #define CXN_KILLED_TIMED_OUT 11 /* Connection got invalidated
  1189. * internally due to timeout on
  1190. * tcp segment 12 retransmit
  1191. * attempts failed
  1192. */
  1193. #define CXN_KILLED_RST_SENT 12 /* Connection got invalidated
  1194. * internally due to TCP RST
  1195. * sent by the Tx side
  1196. */
  1197. #define CXN_KILLED_FIN_RCVD 13 /* Connection got invalidated
  1198. * internally due to an
  1199. * incoming TCP FIN.
  1200. */
  1201. #define CXN_KILLED_BAD_UNSOL_PDU_RCVD 14 /* Connection got invalidated
  1202. * internally due to bad
  1203. * unsolicited PDU Unsolicited
  1204. * PDUs are PDUs with
  1205. * ITT=0xffffffff
  1206. */
  1207. #define CXN_KILLED_BAD_WRB_INDEX_ERROR 15 /* Connection got invalidated
  1208. * internally due to bad WRB
  1209. * index.
  1210. */
  1211. #define CXN_KILLED_OVER_RUN_RESIDUAL 16 /* Command got invalidated
  1212. * internally due to received
  1213. * command has residual
  1214. * over run bytes.
  1215. */
  1216. #define CXN_KILLED_UNDER_RUN_RESIDUAL 17 /* Command got invalidated
  1217. * internally due to received
  1218. * command has residual under
  1219. * run bytes.
  1220. */
  1221. #define CMD_KILLED_INVALID_STATSN_RCVD 18 /* Command got invalidated
  1222. * internally due to a received
  1223. * PDU has an invalid StatusSN
  1224. */
  1225. #define CMD_KILLED_INVALID_R2T_RCVD 19 /* Command got invalidated
  1226. * internally due to a received
  1227. * an R2T with some invalid
  1228. * fields in it
  1229. */
  1230. #define CMD_CXN_KILLED_LUN_INVALID 20 /* Command got invalidated
  1231. * internally due to received
  1232. * PDU has an invalid LUN.
  1233. */
  1234. #define CMD_CXN_KILLED_ICD_INVALID 21 /* Command got invalidated
  1235. * internally due to the
  1236. * corresponding ICD not in a
  1237. * valid state
  1238. */
  1239. #define CMD_CXN_KILLED_ITT_INVALID 22 /* Command got invalidated due
  1240. * to received PDU has an
  1241. * invalid ITT.
  1242. */
  1243. #define CMD_CXN_KILLED_SEQ_OUTOFORDER 23 /* Command got invalidated due
  1244. * to received sequence buffer
  1245. * offset is out of order.
  1246. */
  1247. #define CMD_CXN_KILLED_INVALID_DATASN_RCVD 24 /* Command got invalidated
  1248. * internally due to a
  1249. * received PDU has an invalid
  1250. * DataSN
  1251. */
  1252. #define CXN_INVALIDATE_NOTIFY 25 /* Connection invalidation
  1253. * completion notify.
  1254. */
  1255. #define CXN_INVALIDATE_INDEX_NOTIFY 26 /* Connection invalidation
  1256. * completion
  1257. * with data PDU index.
  1258. */
  1259. #define CMD_INVALIDATED_NOTIFY 27 /* Command invalidation
  1260. * completionnotifify.
  1261. */
  1262. #define UNSOL_HDR_NOTIFY 28 /* Unsolicited header notify.*/
  1263. #define UNSOL_DATA_NOTIFY 29 /* Unsolicited data notify.*/
  1264. #define UNSOL_DATA_DIGEST_ERROR_NOTIFY 30 /* Unsolicited data digest
  1265. * error notify.
  1266. */
  1267. #define DRIVERMSG_NOTIFY 31 /* TCP acknowledge based
  1268. * notification.
  1269. */
  1270. #define CXN_KILLED_CMND_DATA_NOT_ON_SAME_CONN 32 /* Connection got invalidated
  1271. * internally due to command
  1272. * and data are not on same
  1273. * connection.
  1274. */
  1275. #define SOL_CMD_KILLED_DIF_ERR 33 /* Solicited command got
  1276. * invalidated internally due
  1277. * to DIF error
  1278. */
  1279. #define CXN_KILLED_SYN_RCVD 34 /* Connection got invalidated
  1280. * internally due to incoming
  1281. * TCP SYN
  1282. */
  1283. #define CXN_KILLED_IMM_DATA_RCVD 35 /* Connection got invalidated
  1284. * internally due to an
  1285. * incoming Unsolicited PDU
  1286. * that has immediate data on
  1287. * the cxn
  1288. */
  1289. void be_wrb_hdr_prepare(struct be_mcc_wrb *wrb, int payload_len,
  1290. bool embedded, u8 sge_cnt);
  1291. void be_cmd_hdr_prepare(struct be_cmd_req_hdr *req_hdr,
  1292. u8 subsystem, u8 opcode, int cmd_len);
  1293. #endif /* !BEISCSI_CMDS_H */