be_cmds.h 37 KB

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