be_cmds.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134
  1. /**
  2. * Copyright (C) 2005 - 2011 Emulex
  3. * All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License version 2
  7. * as published by the Free Software Foundation. The full GNU General
  8. * Public License is included in this distribution in the file called COPYING.
  9. *
  10. * Contact Information:
  11. * linux-drivers@emulex.com
  12. *
  13. * Emulex
  14. * 3333 Susan Street
  15. * Costa Mesa, CA 92626
  16. */
  17. #ifndef BEISCSI_CMDS_H
  18. #define BEISCSI_CMDS_H
  19. /**
  20. * The driver sends configuration and managements command requests to the
  21. * firmware in the BE. These requests are communicated to the processor
  22. * using Work Request Blocks (WRBs) submitted to the MCC-WRB ring or via one
  23. * WRB inside a MAILBOX.
  24. * The commands are serviced by the ARM processor in the OneConnect's MPU.
  25. */
  26. struct be_sge {
  27. u32 pa_lo;
  28. u32 pa_hi;
  29. u32 len;
  30. };
  31. #define MCC_WRB_SGE_CNT_SHIFT 3 /* bits 3 - 7 of dword 0 */
  32. #define MCC_WRB_SGE_CNT_MASK 0x1F /* bits 3 - 7 of dword 0 */
  33. struct be_mcc_wrb {
  34. u32 embedded; /* dword 0 */
  35. u32 payload_length; /* dword 1 */
  36. u32 tag0; /* dword 2 */
  37. u32 tag1; /* dword 3 */
  38. u32 rsvd; /* dword 4 */
  39. union {
  40. u8 embedded_payload[236]; /* used by embedded cmds */
  41. struct be_sge sgl[19]; /* used by non-embedded cmds */
  42. } payload;
  43. };
  44. #define CQE_FLAGS_VALID_MASK (1 << 31)
  45. #define CQE_FLAGS_ASYNC_MASK (1 << 30)
  46. #define CQE_FLAGS_COMPLETED_MASK (1 << 28)
  47. #define CQE_FLAGS_CONSUMED_MASK (1 << 27)
  48. /* Completion Status */
  49. #define MCC_STATUS_SUCCESS 0x0
  50. #define CQE_STATUS_COMPL_MASK 0xFFFF
  51. #define CQE_STATUS_COMPL_SHIFT 0 /* bits 0 - 15 */
  52. #define CQE_STATUS_EXTD_MASK 0xFFFF
  53. #define CQE_STATUS_EXTD_SHIFT 16 /* bits 0 - 15 */
  54. struct be_mcc_compl {
  55. u32 status; /* dword 0 */
  56. u32 tag0; /* dword 1 */
  57. u32 tag1; /* dword 2 */
  58. u32 flags; /* dword 3 */
  59. };
  60. /********* Mailbox door bell *************/
  61. /**
  62. * Used for driver communication with the FW.
  63. * The software must write this register twice to post any command. First,
  64. * it writes the register with hi=1 and the upper bits of the physical address
  65. * for the MAILBOX structure. Software must poll the ready bit until this
  66. * is acknowledged. Then, sotware writes the register with hi=0 with the lower
  67. * bits in the address. It must poll the ready bit until the command is
  68. * complete. Upon completion, the MAILBOX will contain a valid completion
  69. * queue entry.
  70. */
  71. #define MPU_MAILBOX_DB_OFFSET 0x160
  72. #define MPU_MAILBOX_DB_RDY_MASK 0x1 /* bit 0 */
  73. #define MPU_MAILBOX_DB_HI_MASK 0x2 /* bit 1 */
  74. /********** MPU semphore ******************/
  75. #define MPU_EP_SEMAPHORE_OFFSET 0xac
  76. #define EP_SEMAPHORE_POST_STAGE_MASK 0x0000FFFF
  77. #define EP_SEMAPHORE_POST_ERR_MASK 0x1
  78. #define EP_SEMAPHORE_POST_ERR_SHIFT 31
  79. /********** MCC door bell ************/
  80. #define DB_MCCQ_OFFSET 0x140
  81. #define DB_MCCQ_RING_ID_MASK 0x7FF /* bits 0 - 10 */
  82. /* Number of entries posted */
  83. #define DB_MCCQ_NUM_POSTED_SHIFT 16 /* bits 16 - 29 */
  84. /* MPU semphore POST stage values */
  85. #define POST_STAGE_ARMFW_RDY 0xc000 /* FW is done with POST */
  86. /**
  87. * When the async bit of mcc_compl is set, the last 4 bytes of
  88. * mcc_compl is interpreted as follows:
  89. */
  90. #define ASYNC_TRAILER_EVENT_CODE_SHIFT 8 /* bits 8 - 15 */
  91. #define ASYNC_TRAILER_EVENT_CODE_MASK 0xFF
  92. #define ASYNC_EVENT_CODE_LINK_STATE 0x1
  93. struct be_async_event_trailer {
  94. u32 code;
  95. };
  96. enum {
  97. ASYNC_EVENT_LINK_DOWN = 0x0,
  98. ASYNC_EVENT_LINK_UP = 0x1
  99. };
  100. /**
  101. * When the event code of an async trailer is link-state, the mcc_compl
  102. * must be interpreted as follows
  103. */
  104. struct be_async_event_link_state {
  105. u8 physical_port;
  106. u8 port_link_status;
  107. u8 port_duplex;
  108. u8 port_speed;
  109. u8 port_fault;
  110. u8 rsvd0[7];
  111. struct be_async_event_trailer trailer;
  112. } __packed;
  113. struct be_mcc_mailbox {
  114. struct be_mcc_wrb wrb;
  115. struct be_mcc_compl compl;
  116. };
  117. /* Type of subsystems supported by FW */
  118. #define CMD_SUBSYSTEM_COMMON 0x1
  119. #define CMD_SUBSYSTEM_ISCSI 0x2
  120. #define CMD_SUBSYSTEM_ETH 0x3
  121. #define CMD_SUBSYSTEM_ISCSI_INI 0x6
  122. #define CMD_COMMON_TCP_UPLOAD 0x1
  123. /**
  124. * List of common opcodes subsystem CMD_SUBSYSTEM_COMMON
  125. * These opcodes are unique for each subsystem defined above
  126. */
  127. #define OPCODE_COMMON_CQ_CREATE 12
  128. #define OPCODE_COMMON_EQ_CREATE 13
  129. #define OPCODE_COMMON_MCC_CREATE 21
  130. #define OPCODE_COMMON_GET_CNTL_ATTRIBUTES 32
  131. #define OPCODE_COMMON_GET_FW_VERSION 35
  132. #define OPCODE_COMMON_MODIFY_EQ_DELAY 41
  133. #define OPCODE_COMMON_FIRMWARE_CONFIG 42
  134. #define OPCODE_COMMON_MCC_DESTROY 53
  135. #define OPCODE_COMMON_CQ_DESTROY 54
  136. #define OPCODE_COMMON_EQ_DESTROY 55
  137. #define OPCODE_COMMON_QUERY_FIRMWARE_CONFIG 58
  138. #define OPCODE_COMMON_FUNCTION_RESET 61
  139. /**
  140. * LIST of opcodes that are common between Initiator and Target
  141. * used by CMD_SUBSYSTEM_ISCSI
  142. * These opcodes are unique for each subsystem defined above
  143. */
  144. #define OPCODE_COMMON_ISCSI_CFG_POST_SGL_PAGES 2
  145. #define OPCODE_COMMON_ISCSI_CFG_REMOVE_SGL_PAGES 3
  146. #define OPCODE_COMMON_ISCSI_NTWK_GET_NIC_CONFIG 7
  147. #define OPCODE_COMMON_ISCSI_NTWK_SET_VLAN 14
  148. #define OPCODE_COMMON_ISCSI_NTWK_CONFIG_STATELESS_IP_ADDR 17
  149. #define OPCODE_COMMON_ISCSI_NTWK_REL_STATELESS_IP_ADDR 18
  150. #define OPCODE_COMMON_ISCSI_NTWK_MODIFY_IP_ADDR 21
  151. #define OPCODE_COMMON_ISCSI_NTWK_GET_DEFAULT_GATEWAY 22
  152. #define OPCODE_COMMON_ISCSI_NTWK_MODIFY_DEFAULT_GATEWAY 23
  153. #define OPCODE_COMMON_ISCSI_NTWK_GET_ALL_IF_ID 24
  154. #define OPCODE_COMMON_ISCSI_NTWK_GET_IF_INFO 25
  155. #define OPCODE_COMMON_ISCSI_SET_FRAGNUM_BITS_FOR_SGL_CRA 61
  156. #define OPCODE_COMMON_ISCSI_DEFQ_CREATE 64
  157. #define OPCODE_COMMON_ISCSI_DEFQ_DESTROY 65
  158. #define OPCODE_COMMON_ISCSI_WRBQ_CREATE 66
  159. #define OPCODE_COMMON_ISCSI_WRBQ_DESTROY 67
  160. struct be_cmd_req_hdr {
  161. u8 opcode; /* dword 0 */
  162. u8 subsystem; /* dword 0 */
  163. u8 port_number; /* dword 0 */
  164. u8 domain; /* dword 0 */
  165. u32 timeout; /* dword 1 */
  166. u32 request_length; /* dword 2 */
  167. u32 rsvd0; /* dword 3 */
  168. };
  169. struct be_cmd_resp_hdr {
  170. u32 info; /* dword 0 */
  171. u32 status; /* dword 1 */
  172. u32 response_length; /* dword 2 */
  173. u32 actual_resp_len; /* dword 3 */
  174. };
  175. struct phys_addr {
  176. u32 lo;
  177. u32 hi;
  178. };
  179. /**************************
  180. * BE Command definitions *
  181. **************************/
  182. /**
  183. * Pseudo amap definition in which each bit of the actual structure is defined
  184. * as a byte - used to calculate offset/shift/mask of each field
  185. */
  186. struct amap_eq_context {
  187. u8 cidx[13]; /* dword 0 */
  188. u8 rsvd0[3]; /* dword 0 */
  189. u8 epidx[13]; /* dword 0 */
  190. u8 valid; /* dword 0 */
  191. u8 rsvd1; /* dword 0 */
  192. u8 size; /* dword 0 */
  193. u8 pidx[13]; /* dword 1 */
  194. u8 rsvd2[3]; /* dword 1 */
  195. u8 pd[10]; /* dword 1 */
  196. u8 count[3]; /* dword 1 */
  197. u8 solevent; /* dword 1 */
  198. u8 stalled; /* dword 1 */
  199. u8 armed; /* dword 1 */
  200. u8 rsvd3[4]; /* dword 2 */
  201. u8 func[8]; /* dword 2 */
  202. u8 rsvd4; /* dword 2 */
  203. u8 delaymult[10]; /* dword 2 */
  204. u8 rsvd5[2]; /* dword 2 */
  205. u8 phase[2]; /* dword 2 */
  206. u8 nodelay; /* dword 2 */
  207. u8 rsvd6[4]; /* dword 2 */
  208. u8 rsvd7[32]; /* dword 3 */
  209. } __packed;
  210. struct be_cmd_req_eq_create {
  211. struct be_cmd_req_hdr hdr; /* dw[4] */
  212. u16 num_pages; /* sword */
  213. u16 rsvd0; /* sword */
  214. u8 context[sizeof(struct amap_eq_context) / 8]; /* dw[4] */
  215. struct phys_addr pages[8];
  216. } __packed;
  217. struct be_cmd_resp_eq_create {
  218. struct be_cmd_resp_hdr resp_hdr;
  219. u16 eq_id; /* sword */
  220. u16 rsvd0; /* sword */
  221. } __packed;
  222. struct mgmt_chap_format {
  223. u32 flags;
  224. u8 intr_chap_name[256];
  225. u8 intr_secret[16];
  226. u8 target_chap_name[256];
  227. u8 target_secret[16];
  228. u16 intr_chap_name_length;
  229. u16 intr_secret_length;
  230. u16 target_chap_name_length;
  231. u16 target_secret_length;
  232. } __packed;
  233. struct mgmt_auth_method_format {
  234. u8 auth_method_type;
  235. u8 padding[3];
  236. struct mgmt_chap_format chap;
  237. } __packed;
  238. struct mgmt_conn_login_options {
  239. u8 flags;
  240. u8 header_digest;
  241. u8 data_digest;
  242. u8 rsvd0;
  243. u32 max_recv_datasegment_len_ini;
  244. u32 max_recv_datasegment_len_tgt;
  245. u32 tcp_mss;
  246. u32 tcp_window_size;
  247. struct mgmt_auth_method_format auth_data;
  248. } __packed;
  249. struct ip_addr_format {
  250. u16 size_of_structure;
  251. u8 reserved;
  252. u8 ip_type;
  253. u8 addr[16];
  254. u32 rsvd0;
  255. } __packed;
  256. struct mgmt_conn_info {
  257. u32 connection_handle;
  258. u32 connection_status;
  259. u16 src_port;
  260. u16 dest_port;
  261. u16 dest_port_redirected;
  262. u16 cid;
  263. u32 estimated_throughput;
  264. struct ip_addr_format src_ipaddr;
  265. struct ip_addr_format dest_ipaddr;
  266. struct ip_addr_format dest_ipaddr_redirected;
  267. struct mgmt_conn_login_options negotiated_login_options;
  268. } __packed;
  269. struct mgmt_session_login_options {
  270. u8 flags;
  271. u8 error_recovery_level;
  272. u16 rsvd0;
  273. u32 first_burst_length;
  274. u32 max_burst_length;
  275. u16 max_connections;
  276. u16 max_outstanding_r2t;
  277. u16 default_time2wait;
  278. u16 default_time2retain;
  279. } __packed;
  280. struct mgmt_session_info {
  281. u32 session_handle;
  282. u32 status;
  283. u8 isid[6];
  284. u16 tsih;
  285. u32 session_flags;
  286. u16 conn_count;
  287. u16 pad;
  288. u8 target_name[224];
  289. u8 initiator_iscsiname[224];
  290. struct mgmt_session_login_options negotiated_login_options;
  291. struct mgmt_conn_info conn_list[1];
  292. } __packed;
  293. struct be_cmd_get_session_req {
  294. struct be_cmd_req_hdr hdr;
  295. u32 session_handle;
  296. } __packed;
  297. struct be_cmd_get_session_resp {
  298. struct be_cmd_resp_hdr hdr;
  299. struct mgmt_session_info session_info;
  300. } __packed;
  301. struct mac_addr {
  302. u16 size_of_structure;
  303. u8 addr[ETH_ALEN];
  304. } __packed;
  305. struct be_cmd_get_boot_target_req {
  306. struct be_cmd_req_hdr hdr;
  307. } __packed;
  308. struct be_cmd_get_boot_target_resp {
  309. struct be_cmd_resp_hdr hdr;
  310. u32 boot_session_count;
  311. int boot_session_handle;
  312. };
  313. struct be_cmd_mac_query_req {
  314. struct be_cmd_req_hdr hdr;
  315. u8 type;
  316. u8 permanent;
  317. u16 if_id;
  318. } __packed;
  319. struct be_cmd_get_mac_resp {
  320. struct be_cmd_resp_hdr hdr;
  321. struct mac_addr mac;
  322. };
  323. struct be_ip_addr_subnet_format {
  324. u16 size_of_structure;
  325. u8 ip_type;
  326. u8 ipv6_prefix_length;
  327. u8 addr[16];
  328. u8 subnet_mask[16];
  329. u32 rsvd0;
  330. } __packed;
  331. struct be_cmd_get_if_info_req {
  332. struct be_cmd_req_hdr hdr;
  333. u32 interface_hndl;
  334. u32 ip_type;
  335. } __packed;
  336. struct be_cmd_get_if_info_resp {
  337. struct be_cmd_req_hdr hdr;
  338. u32 interface_hndl;
  339. u32 vlan_priority;
  340. u32 ip_addr_count;
  341. u32 dhcp_state;
  342. struct be_ip_addr_subnet_format ip_addr;
  343. } __packed;
  344. struct be_ip_addr_record {
  345. u32 action;
  346. u32 interface_hndl;
  347. struct be_ip_addr_subnet_format ip_addr;
  348. u32 status;
  349. } __packed;
  350. struct be_ip_addr_record_params {
  351. u32 record_entry_count;
  352. struct be_ip_addr_record ip_record;
  353. } __packed;
  354. struct be_cmd_set_ip_addr_req {
  355. struct be_cmd_req_hdr hdr;
  356. struct be_ip_addr_record_params ip_params;
  357. } __packed;
  358. struct be_cmd_set_dhcp_req {
  359. struct be_cmd_req_hdr hdr;
  360. u32 interface_hndl;
  361. u32 ip_type;
  362. u32 flags;
  363. u32 retry_count;
  364. } __packed;
  365. struct be_cmd_rel_dhcp_req {
  366. struct be_cmd_req_hdr hdr;
  367. u32 interface_hndl;
  368. u32 ip_type;
  369. } __packed;
  370. struct be_cmd_set_def_gateway_req {
  371. struct be_cmd_req_hdr hdr;
  372. u32 action;
  373. struct ip_addr_format ip_addr;
  374. } __packed;
  375. struct be_cmd_get_def_gateway_req {
  376. struct be_cmd_req_hdr hdr;
  377. u32 ip_type;
  378. } __packed;
  379. struct be_cmd_get_def_gateway_resp {
  380. struct be_cmd_req_hdr hdr;
  381. struct ip_addr_format ip_addr;
  382. } __packed;
  383. /******************** Create CQ ***************************/
  384. /**
  385. * Pseudo amap definition in which each bit of the actual structure is defined
  386. * as a byte - used to calculate offset/shift/mask of each field
  387. */
  388. struct amap_cq_context {
  389. u8 cidx[11]; /* dword 0 */
  390. u8 rsvd0; /* dword 0 */
  391. u8 coalescwm[2]; /* dword 0 */
  392. u8 nodelay; /* dword 0 */
  393. u8 epidx[11]; /* dword 0 */
  394. u8 rsvd1; /* dword 0 */
  395. u8 count[2]; /* dword 0 */
  396. u8 valid; /* dword 0 */
  397. u8 solevent; /* dword 0 */
  398. u8 eventable; /* dword 0 */
  399. u8 pidx[11]; /* dword 1 */
  400. u8 rsvd2; /* dword 1 */
  401. u8 pd[10]; /* dword 1 */
  402. u8 eqid[8]; /* dword 1 */
  403. u8 stalled; /* dword 1 */
  404. u8 armed; /* dword 1 */
  405. u8 rsvd3[4]; /* dword 2 */
  406. u8 func[8]; /* dword 2 */
  407. u8 rsvd4[20]; /* dword 2 */
  408. u8 rsvd5[32]; /* dword 3 */
  409. } __packed;
  410. struct be_cmd_req_cq_create {
  411. struct be_cmd_req_hdr hdr;
  412. u16 num_pages;
  413. u16 rsvd0;
  414. u8 context[sizeof(struct amap_cq_context) / 8];
  415. struct phys_addr pages[4];
  416. } __packed;
  417. struct be_cmd_resp_cq_create {
  418. struct be_cmd_resp_hdr hdr;
  419. u16 cq_id;
  420. u16 rsvd0;
  421. } __packed;
  422. /******************** Create MCCQ ***************************/
  423. /**
  424. * Pseudo amap definition in which each bit of the actual structure is defined
  425. * as a byte - used to calculate offset/shift/mask of each field
  426. */
  427. struct amap_mcc_context {
  428. u8 con_index[14];
  429. u8 rsvd0[2];
  430. u8 ring_size[4];
  431. u8 fetch_wrb;
  432. u8 fetch_r2t;
  433. u8 cq_id[10];
  434. u8 prod_index[14];
  435. u8 fid[8];
  436. u8 pdid[9];
  437. u8 valid;
  438. u8 rsvd1[32];
  439. u8 rsvd2[32];
  440. } __packed;
  441. struct be_cmd_req_mcc_create {
  442. struct be_cmd_req_hdr hdr;
  443. u16 num_pages;
  444. u16 rsvd0;
  445. u8 context[sizeof(struct amap_mcc_context) / 8];
  446. struct phys_addr pages[8];
  447. } __packed;
  448. struct be_cmd_resp_mcc_create {
  449. struct be_cmd_resp_hdr hdr;
  450. u16 id;
  451. u16 rsvd0;
  452. } __packed;
  453. /******************** Q Destroy ***************************/
  454. /* Type of Queue to be destroyed */
  455. enum {
  456. QTYPE_EQ = 1,
  457. QTYPE_CQ,
  458. QTYPE_MCCQ,
  459. QTYPE_WRBQ,
  460. QTYPE_DPDUQ,
  461. QTYPE_SGL
  462. };
  463. struct be_cmd_req_q_destroy {
  464. struct be_cmd_req_hdr hdr;
  465. u16 id;
  466. u16 bypass_flush; /* valid only for rx q destroy */
  467. } __packed;
  468. struct macaddr {
  469. u8 byte[ETH_ALEN];
  470. };
  471. struct be_cmd_req_mcast_mac_config {
  472. struct be_cmd_req_hdr hdr;
  473. u16 num_mac;
  474. u8 promiscuous;
  475. u8 interface_id;
  476. struct macaddr mac[32];
  477. } __packed;
  478. static inline void *embedded_payload(struct be_mcc_wrb *wrb)
  479. {
  480. return wrb->payload.embedded_payload;
  481. }
  482. static inline struct be_sge *nonembedded_sgl(struct be_mcc_wrb *wrb)
  483. {
  484. return &wrb->payload.sgl[0];
  485. }
  486. /******************** Modify EQ Delay *******************/
  487. struct be_cmd_req_modify_eq_delay {
  488. struct be_cmd_req_hdr hdr;
  489. u32 num_eq;
  490. struct {
  491. u32 eq_id;
  492. u32 phase;
  493. u32 delay_multiplier;
  494. } delay[8];
  495. } __packed;
  496. /******************** Get MAC ADDR *******************/
  497. #define ETH_ALEN 6
  498. struct be_cmd_get_nic_conf_req {
  499. struct be_cmd_req_hdr hdr;
  500. u32 nic_port_count;
  501. u32 speed;
  502. u32 max_speed;
  503. u32 link_state;
  504. u32 max_frame_size;
  505. u16 size_of_structure;
  506. u8 mac_address[ETH_ALEN];
  507. u32 rsvd[23];
  508. };
  509. struct be_cmd_get_nic_conf_resp {
  510. struct be_cmd_resp_hdr hdr;
  511. u32 nic_port_count;
  512. u32 speed;
  513. u32 max_speed;
  514. u32 link_state;
  515. u32 max_frame_size;
  516. u16 size_of_structure;
  517. u8 mac_address[6];
  518. u32 rsvd[23];
  519. };
  520. #define BEISCSI_ALIAS_LEN 32
  521. struct be_cmd_hba_name {
  522. struct be_cmd_req_hdr hdr;
  523. u16 flags;
  524. u16 rsvd0;
  525. u8 initiator_name[ISCSI_NAME_LEN];
  526. u8 initiator_alias[BEISCSI_ALIAS_LEN];
  527. } __packed;
  528. struct be_cmd_ntwk_link_status_req {
  529. struct be_cmd_req_hdr hdr;
  530. u32 rsvd0;
  531. } __packed;
  532. /*** Port Speed Values ***/
  533. #define BE2ISCSI_LINK_SPEED_ZERO 0x00
  534. #define BE2ISCSI_LINK_SPEED_10MBPS 0x01
  535. #define BE2ISCSI_LINK_SPEED_100MBPS 0x02
  536. #define BE2ISCSI_LINK_SPEED_1GBPS 0x03
  537. #define BE2ISCSI_LINK_SPEED_10GBPS 0x04
  538. struct be_cmd_ntwk_link_status_resp {
  539. struct be_cmd_resp_hdr hdr;
  540. u8 phys_port;
  541. u8 mac_duplex;
  542. u8 mac_speed;
  543. u8 mac_fault;
  544. u8 mgmt_mac_duplex;
  545. u8 mgmt_mac_speed;
  546. u16 qos_link_speed;
  547. u32 logical_link_speed;
  548. } __packed;
  549. int beiscsi_cmd_eq_create(struct be_ctrl_info *ctrl,
  550. struct be_queue_info *eq, int eq_delay);
  551. int beiscsi_cmd_cq_create(struct be_ctrl_info *ctrl,
  552. struct be_queue_info *cq, struct be_queue_info *eq,
  553. bool sol_evts, bool no_delay,
  554. int num_cqe_dma_coalesce);
  555. int beiscsi_cmd_q_destroy(struct be_ctrl_info *ctrl, struct be_queue_info *q,
  556. int type);
  557. int beiscsi_cmd_mccq_create(struct beiscsi_hba *phba,
  558. struct be_queue_info *mccq,
  559. struct be_queue_info *cq);
  560. int be_poll_mcc(struct be_ctrl_info *ctrl);
  561. int mgmt_check_supported_fw(struct be_ctrl_info *ctrl,
  562. struct beiscsi_hba *phba);
  563. unsigned int be_cmd_get_initname(struct beiscsi_hba *phba);
  564. unsigned int be_cmd_get_port_speed(struct beiscsi_hba *phba);
  565. void free_mcc_tag(struct be_ctrl_info *ctrl, unsigned int tag);
  566. /*ISCSI Functuions */
  567. int be_cmd_fw_initialize(struct be_ctrl_info *ctrl);
  568. struct be_mcc_wrb *wrb_from_mbox(struct be_dma_mem *mbox_mem);
  569. struct be_mcc_wrb *wrb_from_mccq(struct beiscsi_hba *phba);
  570. int be_mcc_notify_wait(struct beiscsi_hba *phba);
  571. void be_mcc_notify(struct beiscsi_hba *phba);
  572. unsigned int alloc_mcc_tag(struct beiscsi_hba *phba);
  573. void beiscsi_async_link_state_process(struct beiscsi_hba *phba,
  574. struct be_async_event_link_state *evt);
  575. int be_mcc_compl_process_isr(struct be_ctrl_info *ctrl,
  576. struct be_mcc_compl *compl);
  577. int be_mbox_notify(struct be_ctrl_info *ctrl);
  578. int be_cmd_create_default_pdu_queue(struct be_ctrl_info *ctrl,
  579. struct be_queue_info *cq,
  580. struct be_queue_info *dq, int length,
  581. int entry_size);
  582. int be_cmd_iscsi_post_sgl_pages(struct be_ctrl_info *ctrl,
  583. struct be_dma_mem *q_mem, u32 page_offset,
  584. u32 num_pages);
  585. int beiscsi_cmd_reset_function(struct beiscsi_hba *phba);
  586. int be_cmd_wrbq_create(struct be_ctrl_info *ctrl, struct be_dma_mem *q_mem,
  587. struct be_queue_info *wrbq);
  588. bool is_link_state_evt(u32 trailer);
  589. struct be_default_pdu_context {
  590. u32 dw[4];
  591. } __packed;
  592. struct amap_be_default_pdu_context {
  593. u8 dbuf_cindex[13]; /* dword 0 */
  594. u8 rsvd0[3]; /* dword 0 */
  595. u8 ring_size[4]; /* dword 0 */
  596. u8 ring_state[4]; /* dword 0 */
  597. u8 rsvd1[8]; /* dword 0 */
  598. u8 dbuf_pindex[13]; /* dword 1 */
  599. u8 rsvd2; /* dword 1 */
  600. u8 pci_func_id[8]; /* dword 1 */
  601. u8 rx_pdid[9]; /* dword 1 */
  602. u8 rx_pdid_valid; /* dword 1 */
  603. u8 default_buffer_size[16]; /* dword 2 */
  604. u8 cq_id_recv[10]; /* dword 2 */
  605. u8 rx_pdid_not_valid; /* dword 2 */
  606. u8 rsvd3[5]; /* dword 2 */
  607. u8 rsvd4[32]; /* dword 3 */
  608. } __packed;
  609. struct be_defq_create_req {
  610. struct be_cmd_req_hdr hdr;
  611. u16 num_pages;
  612. u8 ulp_num;
  613. u8 rsvd0;
  614. struct be_default_pdu_context context;
  615. struct phys_addr pages[8];
  616. } __packed;
  617. struct be_defq_create_resp {
  618. struct be_cmd_req_hdr hdr;
  619. u16 id;
  620. u16 rsvd0;
  621. } __packed;
  622. struct be_post_sgl_pages_req {
  623. struct be_cmd_req_hdr hdr;
  624. u16 num_pages;
  625. u16 page_offset;
  626. u32 rsvd0;
  627. struct phys_addr pages[26];
  628. u32 rsvd1;
  629. } __packed;
  630. struct be_wrbq_create_req {
  631. struct be_cmd_req_hdr hdr;
  632. u16 num_pages;
  633. u8 ulp_num;
  634. u8 rsvd0;
  635. struct phys_addr pages[8];
  636. } __packed;
  637. struct be_wrbq_create_resp {
  638. struct be_cmd_resp_hdr resp_hdr;
  639. u16 cid;
  640. u16 rsvd0;
  641. } __packed;
  642. #define SOL_CID_MASK 0x0000FFC0
  643. #define SOL_CODE_MASK 0x0000003F
  644. #define SOL_WRB_INDEX_MASK 0x00FF0000
  645. #define SOL_CMD_WND_MASK 0xFF000000
  646. #define SOL_RES_CNT_MASK 0x7FFFFFFF
  647. #define SOL_EXP_CMD_SN_MASK 0xFFFFFFFF
  648. #define SOL_HW_STS_MASK 0x000000FF
  649. #define SOL_STS_MASK 0x0000FF00
  650. #define SOL_RESP_MASK 0x00FF0000
  651. #define SOL_FLAGS_MASK 0x7F000000
  652. #define SOL_S_MASK 0x80000000
  653. struct sol_cqe {
  654. u32 dw[4];
  655. };
  656. struct amap_sol_cqe {
  657. u8 hw_sts[8]; /* dword 0 */
  658. u8 i_sts[8]; /* dword 0 */
  659. u8 i_resp[8]; /* dword 0 */
  660. u8 i_flags[7]; /* dword 0 */
  661. u8 s; /* dword 0 */
  662. u8 i_exp_cmd_sn[32]; /* dword 1 */
  663. u8 code[6]; /* dword 2 */
  664. u8 cid[10]; /* dword 2 */
  665. u8 wrb_index[8]; /* dword 2 */
  666. u8 i_cmd_wnd[8]; /* dword 2 */
  667. u8 i_res_cnt[31]; /* dword 3 */
  668. u8 valid; /* dword 3 */
  669. } __packed;
  670. #define SOL_ICD_INDEX_MASK 0x0003FFC0
  671. struct amap_sol_cqe_ring {
  672. u8 hw_sts[8]; /* dword 0 */
  673. u8 i_sts[8]; /* dword 0 */
  674. u8 i_resp[8]; /* dword 0 */
  675. u8 i_flags[7]; /* dword 0 */
  676. u8 s; /* dword 0 */
  677. u8 i_exp_cmd_sn[32]; /* dword 1 */
  678. u8 code[6]; /* dword 2 */
  679. u8 icd_index[12]; /* dword 2 */
  680. u8 rsvd[6]; /* dword 2 */
  681. u8 i_cmd_wnd[8]; /* dword 2 */
  682. u8 i_res_cnt[31]; /* dword 3 */
  683. u8 valid; /* dword 3 */
  684. } __packed;
  685. /**
  686. * Post WRB Queue Doorbell Register used by the host Storage
  687. * stack to notify the
  688. * controller of a posted Work Request Block
  689. */
  690. #define DB_WRB_POST_CID_MASK 0x3FF /* bits 0 - 9 */
  691. #define DB_DEF_PDU_WRB_INDEX_MASK 0xFF /* bits 0 - 9 */
  692. #define DB_DEF_PDU_WRB_INDEX_SHIFT 16
  693. #define DB_DEF_PDU_NUM_POSTED_SHIFT 24
  694. struct fragnum_bits_for_sgl_cra_in {
  695. struct be_cmd_req_hdr hdr;
  696. u32 num_bits;
  697. } __packed;
  698. struct iscsi_cleanup_req {
  699. struct be_cmd_req_hdr hdr;
  700. u16 chute;
  701. u8 hdr_ring_id;
  702. u8 data_ring_id;
  703. } __packed;
  704. struct eq_delay {
  705. u32 eq_id;
  706. u32 phase;
  707. u32 delay_multiplier;
  708. } __packed;
  709. struct be_eq_delay_params_in {
  710. struct be_cmd_req_hdr hdr;
  711. u32 num_eq;
  712. struct eq_delay delay[8];
  713. } __packed;
  714. struct tcp_connect_and_offload_in {
  715. struct be_cmd_req_hdr hdr;
  716. struct ip_addr_format ip_address;
  717. u16 tcp_port;
  718. u16 cid;
  719. u16 cq_id;
  720. u16 defq_id;
  721. struct phys_addr dataout_template_pa;
  722. u16 hdr_ring_id;
  723. u16 data_ring_id;
  724. u8 do_offload;
  725. u8 rsvd0[3];
  726. } __packed;
  727. struct tcp_connect_and_offload_out {
  728. struct be_cmd_resp_hdr hdr;
  729. u32 connection_handle;
  730. u16 cid;
  731. u16 rsvd0;
  732. } __packed;
  733. struct be_mcc_wrb_context {
  734. struct MCC_WRB *wrb;
  735. int *users_final_status;
  736. } __packed;
  737. #define DB_DEF_PDU_RING_ID_MASK 0x3FF /* bits 0 - 9 */
  738. #define DB_DEF_PDU_CQPROC_MASK 0x3FFF /* bits 0 - 9 */
  739. #define DB_DEF_PDU_REARM_SHIFT 14
  740. #define DB_DEF_PDU_EVENT_SHIFT 15
  741. #define DB_DEF_PDU_CQPROC_SHIFT 16
  742. struct dmsg_cqe {
  743. u32 dw[4];
  744. } __packed;
  745. struct tcp_upload_params_in {
  746. struct be_cmd_req_hdr hdr;
  747. u16 id;
  748. u16 upload_type;
  749. u32 reset_seq;
  750. } __packed;
  751. struct tcp_upload_params_out {
  752. u32 dw[32];
  753. } __packed;
  754. union tcp_upload_params {
  755. struct tcp_upload_params_in request;
  756. struct tcp_upload_params_out response;
  757. } __packed;
  758. struct be_ulp_fw_cfg {
  759. u32 ulp_mode;
  760. u32 etx_base;
  761. u32 etx_count;
  762. u32 sq_base;
  763. u32 sq_count;
  764. u32 rq_base;
  765. u32 rq_count;
  766. u32 dq_base;
  767. u32 dq_count;
  768. u32 lro_base;
  769. u32 lro_count;
  770. u32 icd_base;
  771. u32 icd_count;
  772. };
  773. struct be_fw_cfg {
  774. struct be_cmd_req_hdr hdr;
  775. u32 be_config_number;
  776. u32 asic_revision;
  777. u32 phys_port;
  778. u32 function_mode;
  779. struct be_ulp_fw_cfg ulp[2];
  780. u32 function_caps;
  781. } __packed;
  782. struct be_cmd_get_all_if_id_req {
  783. struct be_cmd_req_hdr hdr;
  784. u32 if_count;
  785. u32 if_hndl_list[1];
  786. } __packed;
  787. #define ISCSI_OPCODE_SCSI_DATA_OUT 5
  788. #define OPCODE_COMMON_NTWK_LINK_STATUS_QUERY 5
  789. #define OPCODE_COMMON_MODIFY_EQ_DELAY 41
  790. #define OPCODE_COMMON_ISCSI_CLEANUP 59
  791. #define OPCODE_COMMON_TCP_UPLOAD 56
  792. #define OPCODE_COMMON_ISCSI_TCP_CONNECT_AND_OFFLOAD 70
  793. #define OPCODE_COMMON_ISCSI_ERROR_RECOVERY_INVALIDATE_COMMANDS 1
  794. #define OPCODE_ISCSI_INI_CFG_GET_HBA_NAME 6
  795. #define OPCODE_ISCSI_INI_CFG_SET_HBA_NAME 7
  796. #define OPCODE_ISCSI_INI_SESSION_GET_A_SESSION 14
  797. #define OPCODE_ISCSI_INI_DRIVER_OFFLOAD_SESSION 41
  798. #define OPCODE_ISCSI_INI_DRIVER_INVALIDATE_CONNECTION 42
  799. #define OPCODE_ISCSI_INI_BOOT_GET_BOOT_TARGET 52
  800. #define OPCODE_COMMON_WRITE_FLASH 96
  801. #define OPCODE_COMMON_READ_FLASH 97
  802. /* --- CMD_ISCSI_INVALIDATE_CONNECTION_TYPE --- */
  803. #define CMD_ISCSI_COMMAND_INVALIDATE 1
  804. #define CMD_ISCSI_CONNECTION_INVALIDATE 0x8001
  805. #define CMD_ISCSI_CONNECTION_ISSUE_TCP_RST 0x8002
  806. #define INI_WR_CMD 1 /* Initiator write command */
  807. #define INI_TMF_CMD 2 /* Initiator TMF command */
  808. #define INI_NOPOUT_CMD 3 /* Initiator; Send a NOP-OUT */
  809. #define INI_RD_CMD 5 /* Initiator requesting to send
  810. * a read command
  811. */
  812. #define TGT_CTX_UPDT_CMD 7 /* Target context update */
  813. #define TGT_STS_CMD 8 /* Target R2T and other BHS
  814. * where only the status number
  815. * need to be updated
  816. */
  817. #define TGT_DATAIN_CMD 9 /* Target Data-Ins in response
  818. * to read command
  819. */
  820. #define TGT_SOS_PDU 10 /* Target:standalone status
  821. * response
  822. */
  823. #define TGT_DM_CMD 11 /* Indicates that the bhs
  824. * preparedby
  825. * driver should not be touched
  826. */
  827. /* --- CMD_CHUTE_TYPE --- */
  828. #define CMD_CONNECTION_CHUTE_0 1
  829. #define CMD_CONNECTION_CHUTE_1 2
  830. #define CMD_CONNECTION_CHUTE_2 3
  831. #define EQ_MAJOR_CODE_COMPLETION 0
  832. #define CMD_ISCSI_SESSION_DEL_CFG_FROM_FLASH 0
  833. #define CMD_ISCSI_SESSION_SAVE_CFG_ON_FLASH 1
  834. /* --- CONNECTION_UPLOAD_PARAMS --- */
  835. /* These parameters are used to define the type of upload desired. */
  836. #define CONNECTION_UPLOAD_GRACEFUL 1 /* Graceful upload */
  837. #define CONNECTION_UPLOAD_ABORT_RESET 2 /* Abortive upload with
  838. * reset
  839. */
  840. #define CONNECTION_UPLOAD_ABORT 3 /* Abortive upload without
  841. * reset
  842. */
  843. #define CONNECTION_UPLOAD_ABORT_WITH_SEQ 4 /* Abortive upload with reset,
  844. * sequence number by driver */
  845. /* Returns byte size of given field with a structure. */
  846. /* Returns the number of items in the field array. */
  847. #define BE_NUMBER_OF_FIELD(_type_, _field_) \
  848. (FIELD_SIZEOF(_type_, _field_)/sizeof((((_type_ *)0)->_field_[0])))\
  849. /**
  850. * Different types of iSCSI completions to host driver for both initiator
  851. * and taget mode
  852. * of operation.
  853. */
  854. #define SOL_CMD_COMPLETE 1 /* Solicited command completed
  855. * normally
  856. */
  857. #define SOL_CMD_KILLED_DATA_DIGEST_ERR 2 /* Solicited command got
  858. * invalidated internally due
  859. * to Data Digest error
  860. */
  861. #define CXN_KILLED_PDU_SIZE_EXCEEDS_DSL 3 /* Connection got invalidated
  862. * internally
  863. * due to a received PDU
  864. * size > DSL
  865. */
  866. #define CXN_KILLED_BURST_LEN_MISMATCH 4 /* Connection got invalidated
  867. * internally due ti received
  868. * PDU sequence size >
  869. * FBL/MBL.
  870. */
  871. #define CXN_KILLED_AHS_RCVD 5 /* Connection got invalidated
  872. * internally due to a received
  873. * PDU Hdr that has
  874. * AHS */
  875. #define CXN_KILLED_HDR_DIGEST_ERR 6 /* Connection got invalidated
  876. * internally due to Hdr Digest
  877. * error
  878. */
  879. #define CXN_KILLED_UNKNOWN_HDR 7 /* Connection got invalidated
  880. * internally
  881. * due to a bad opcode in the
  882. * pdu hdr
  883. */
  884. #define CXN_KILLED_STALE_ITT_TTT_RCVD 8 /* Connection got invalidated
  885. * internally due to a received
  886. * ITT/TTT that does not belong
  887. * to this Connection
  888. */
  889. #define CXN_KILLED_INVALID_ITT_TTT_RCVD 9 /* Connection got invalidated
  890. * internally due to received
  891. * ITT/TTT value > Max
  892. * Supported ITTs/TTTs
  893. */
  894. #define CXN_KILLED_RST_RCVD 10 /* Connection got invalidated
  895. * internally due to an
  896. * incoming TCP RST
  897. */
  898. #define CXN_KILLED_TIMED_OUT 11 /* Connection got invalidated
  899. * internally due to timeout on
  900. * tcp segment 12 retransmit
  901. * attempts failed
  902. */
  903. #define CXN_KILLED_RST_SENT 12 /* Connection got invalidated
  904. * internally due to TCP RST
  905. * sent by the Tx side
  906. */
  907. #define CXN_KILLED_FIN_RCVD 13 /* Connection got invalidated
  908. * internally due to an
  909. * incoming TCP FIN.
  910. */
  911. #define CXN_KILLED_BAD_UNSOL_PDU_RCVD 14 /* Connection got invalidated
  912. * internally due to bad
  913. * unsolicited PDU Unsolicited
  914. * PDUs are PDUs with
  915. * ITT=0xffffffff
  916. */
  917. #define CXN_KILLED_BAD_WRB_INDEX_ERROR 15 /* Connection got invalidated
  918. * internally due to bad WRB
  919. * index.
  920. */
  921. #define CXN_KILLED_OVER_RUN_RESIDUAL 16 /* Command got invalidated
  922. * internally due to received
  923. * command has residual
  924. * over run bytes.
  925. */
  926. #define CXN_KILLED_UNDER_RUN_RESIDUAL 17 /* Command got invalidated
  927. * internally due to received
  928. * command has residual under
  929. * run bytes.
  930. */
  931. #define CMD_KILLED_INVALID_STATSN_RCVD 18 /* Command got invalidated
  932. * internally due to a received
  933. * PDU has an invalid StatusSN
  934. */
  935. #define CMD_KILLED_INVALID_R2T_RCVD 19 /* Command got invalidated
  936. * internally due to a received
  937. * an R2T with some invalid
  938. * fields in it
  939. */
  940. #define CMD_CXN_KILLED_LUN_INVALID 20 /* Command got invalidated
  941. * internally due to received
  942. * PDU has an invalid LUN.
  943. */
  944. #define CMD_CXN_KILLED_ICD_INVALID 21 /* Command got invalidated
  945. * internally due to the
  946. * corresponding ICD not in a
  947. * valid state
  948. */
  949. #define CMD_CXN_KILLED_ITT_INVALID 22 /* Command got invalidated due
  950. * to received PDU has an
  951. * invalid ITT.
  952. */
  953. #define CMD_CXN_KILLED_SEQ_OUTOFORDER 23 /* Command got invalidated due
  954. * to received sequence buffer
  955. * offset is out of order.
  956. */
  957. #define CMD_CXN_KILLED_INVALID_DATASN_RCVD 24 /* Command got invalidated
  958. * internally due to a
  959. * received PDU has an invalid
  960. * DataSN
  961. */
  962. #define CXN_INVALIDATE_NOTIFY 25 /* Connection invalidation
  963. * completion notify.
  964. */
  965. #define CXN_INVALIDATE_INDEX_NOTIFY 26 /* Connection invalidation
  966. * completion
  967. * with data PDU index.
  968. */
  969. #define CMD_INVALIDATED_NOTIFY 27 /* Command invalidation
  970. * completionnotifify.
  971. */
  972. #define UNSOL_HDR_NOTIFY 28 /* Unsolicited header notify.*/
  973. #define UNSOL_DATA_NOTIFY 29 /* Unsolicited data notify.*/
  974. #define UNSOL_DATA_DIGEST_ERROR_NOTIFY 30 /* Unsolicited data digest
  975. * error notify.
  976. */
  977. #define DRIVERMSG_NOTIFY 31 /* TCP acknowledge based
  978. * notification.
  979. */
  980. #define CXN_KILLED_CMND_DATA_NOT_ON_SAME_CONN 32 /* Connection got invalidated
  981. * internally due to command
  982. * and data are not on same
  983. * connection.
  984. */
  985. #define SOL_CMD_KILLED_DIF_ERR 33 /* Solicited command got
  986. * invalidated internally due
  987. * to DIF error
  988. */
  989. #define CXN_KILLED_SYN_RCVD 34 /* Connection got invalidated
  990. * internally due to incoming
  991. * TCP SYN
  992. */
  993. #define CXN_KILLED_IMM_DATA_RCVD 35 /* Connection got invalidated
  994. * internally due to an
  995. * incoming Unsolicited PDU
  996. * that has immediate data on
  997. * the cxn
  998. */
  999. int beiscsi_pci_soft_reset(struct beiscsi_hba *phba);
  1000. int be_chk_reset_complete(struct beiscsi_hba *phba);
  1001. void be_wrb_hdr_prepare(struct be_mcc_wrb *wrb, int payload_len,
  1002. bool embedded, u8 sge_cnt);
  1003. void be_cmd_hdr_prepare(struct be_cmd_req_hdr *req_hdr,
  1004. u8 subsystem, u8 opcode, int cmd_len);
  1005. #endif /* !BEISCSI_CMDS_H */