be_cmds.h 38 KB

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