be_cmds.h 37 KB

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