mlx5_ifc_fpga.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  1. /*
  2. * Copyright (c) 2017, Mellanox Technologies, Ltd. All rights reserved.
  3. *
  4. * This software is available to you under a choice of one of two
  5. * licenses. You may choose to be licensed under the terms of the GNU
  6. * General Public License (GPL) Version 2, available from the file
  7. * COPYING in the main directory of this source tree, or the
  8. * OpenIB.org BSD license below:
  9. *
  10. * Redistribution and use in source and binary forms, with or
  11. * without modification, are permitted provided that the following
  12. * conditions are met:
  13. *
  14. * - Redistributions of source code must retain the above
  15. * copyright notice, this list of conditions and the following
  16. * disclaimer.
  17. *
  18. * - Redistributions in binary form must reproduce the above
  19. * copyright notice, this list of conditions and the following
  20. * disclaimer in the documentation and/or other materials
  21. * provided with the distribution.
  22. *
  23. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  27. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  28. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  29. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  30. * SOFTWARE.
  31. */
  32. #ifndef MLX5_IFC_FPGA_H
  33. #define MLX5_IFC_FPGA_H
  34. struct mlx5_ifc_ipv4_layout_bits {
  35. u8 reserved_at_0[0x60];
  36. u8 ipv4[0x20];
  37. };
  38. struct mlx5_ifc_ipv6_layout_bits {
  39. u8 ipv6[16][0x8];
  40. };
  41. union mlx5_ifc_ipv6_layout_ipv4_layout_auto_bits {
  42. struct mlx5_ifc_ipv6_layout_bits ipv6_layout;
  43. struct mlx5_ifc_ipv4_layout_bits ipv4_layout;
  44. u8 reserved_at_0[0x80];
  45. };
  46. enum {
  47. MLX5_FPGA_CAP_SANDBOX_VENDOR_ID_MLNX = 0x2c9,
  48. };
  49. enum {
  50. MLX5_FPGA_CAP_SANDBOX_PRODUCT_ID_IPSEC = 0x2,
  51. MLX5_FPGA_CAP_SANDBOX_PRODUCT_ID_TLS = 0x3,
  52. };
  53. struct mlx5_ifc_fpga_shell_caps_bits {
  54. u8 max_num_qps[0x10];
  55. u8 reserved_at_10[0x8];
  56. u8 total_rcv_credits[0x8];
  57. u8 reserved_at_20[0xe];
  58. u8 qp_type[0x2];
  59. u8 reserved_at_30[0x5];
  60. u8 rae[0x1];
  61. u8 rwe[0x1];
  62. u8 rre[0x1];
  63. u8 reserved_at_38[0x4];
  64. u8 dc[0x1];
  65. u8 ud[0x1];
  66. u8 uc[0x1];
  67. u8 rc[0x1];
  68. u8 reserved_at_40[0x1a];
  69. u8 log_ddr_size[0x6];
  70. u8 max_fpga_qp_msg_size[0x20];
  71. u8 reserved_at_80[0x180];
  72. };
  73. struct mlx5_ifc_fpga_cap_bits {
  74. u8 fpga_id[0x8];
  75. u8 fpga_device[0x18];
  76. u8 register_file_ver[0x20];
  77. u8 fpga_ctrl_modify[0x1];
  78. u8 reserved_at_41[0x5];
  79. u8 access_reg_query_mode[0x2];
  80. u8 reserved_at_48[0x6];
  81. u8 access_reg_modify_mode[0x2];
  82. u8 reserved_at_50[0x10];
  83. u8 reserved_at_60[0x20];
  84. u8 image_version[0x20];
  85. u8 image_date[0x20];
  86. u8 image_time[0x20];
  87. u8 shell_version[0x20];
  88. u8 reserved_at_100[0x80];
  89. struct mlx5_ifc_fpga_shell_caps_bits shell_caps;
  90. u8 reserved_at_380[0x8];
  91. u8 ieee_vendor_id[0x18];
  92. u8 sandbox_product_version[0x10];
  93. u8 sandbox_product_id[0x10];
  94. u8 sandbox_basic_caps[0x20];
  95. u8 reserved_at_3e0[0x10];
  96. u8 sandbox_extended_caps_len[0x10];
  97. u8 sandbox_extended_caps_addr[0x40];
  98. u8 fpga_ddr_start_addr[0x40];
  99. u8 fpga_cr_space_start_addr[0x40];
  100. u8 fpga_ddr_size[0x20];
  101. u8 fpga_cr_space_size[0x20];
  102. u8 reserved_at_500[0x300];
  103. };
  104. enum {
  105. MLX5_FPGA_CTRL_OPERATION_LOAD = 0x1,
  106. MLX5_FPGA_CTRL_OPERATION_RESET = 0x2,
  107. MLX5_FPGA_CTRL_OPERATION_FLASH_SELECT = 0x3,
  108. MLX5_FPGA_CTRL_OPERATION_SANDBOX_BYPASS_ON = 0x4,
  109. MLX5_FPGA_CTRL_OPERATION_SANDBOX_BYPASS_OFF = 0x5,
  110. MLX5_FPGA_CTRL_OPERATION_RESET_SANDBOX = 0x6,
  111. };
  112. struct mlx5_ifc_fpga_ctrl_bits {
  113. u8 reserved_at_0[0x8];
  114. u8 operation[0x8];
  115. u8 reserved_at_10[0x8];
  116. u8 status[0x8];
  117. u8 reserved_at_20[0x8];
  118. u8 flash_select_admin[0x8];
  119. u8 reserved_at_30[0x8];
  120. u8 flash_select_oper[0x8];
  121. u8 reserved_at_40[0x40];
  122. };
  123. enum {
  124. MLX5_FPGA_ERROR_EVENT_SYNDROME_CORRUPTED_DDR = 0x1,
  125. MLX5_FPGA_ERROR_EVENT_SYNDROME_FLASH_TIMEOUT = 0x2,
  126. MLX5_FPGA_ERROR_EVENT_SYNDROME_INTERNAL_LINK_ERROR = 0x3,
  127. MLX5_FPGA_ERROR_EVENT_SYNDROME_WATCHDOG_FAILURE = 0x4,
  128. MLX5_FPGA_ERROR_EVENT_SYNDROME_I2C_FAILURE = 0x5,
  129. MLX5_FPGA_ERROR_EVENT_SYNDROME_IMAGE_CHANGED = 0x6,
  130. MLX5_FPGA_ERROR_EVENT_SYNDROME_TEMPERATURE_CRITICAL = 0x7,
  131. };
  132. struct mlx5_ifc_fpga_error_event_bits {
  133. u8 reserved_at_0[0x40];
  134. u8 reserved_at_40[0x18];
  135. u8 syndrome[0x8];
  136. u8 reserved_at_60[0x80];
  137. };
  138. #define MLX5_FPGA_ACCESS_REG_SIZE_MAX 64
  139. struct mlx5_ifc_fpga_access_reg_bits {
  140. u8 reserved_at_0[0x20];
  141. u8 reserved_at_20[0x10];
  142. u8 size[0x10];
  143. u8 address[0x40];
  144. u8 data[0][0x8];
  145. };
  146. enum mlx5_ifc_fpga_qp_state {
  147. MLX5_FPGA_QPC_STATE_INIT = 0x0,
  148. MLX5_FPGA_QPC_STATE_ACTIVE = 0x1,
  149. MLX5_FPGA_QPC_STATE_ERROR = 0x2,
  150. };
  151. enum mlx5_ifc_fpga_qp_type {
  152. MLX5_FPGA_QPC_QP_TYPE_SHELL_QP = 0x0,
  153. MLX5_FPGA_QPC_QP_TYPE_SANDBOX_QP = 0x1,
  154. };
  155. enum mlx5_ifc_fpga_qp_service_type {
  156. MLX5_FPGA_QPC_ST_RC = 0x0,
  157. };
  158. struct mlx5_ifc_fpga_qpc_bits {
  159. u8 state[0x4];
  160. u8 reserved_at_4[0x1b];
  161. u8 qp_type[0x1];
  162. u8 reserved_at_20[0x4];
  163. u8 st[0x4];
  164. u8 reserved_at_28[0x10];
  165. u8 traffic_class[0x8];
  166. u8 ether_type[0x10];
  167. u8 prio[0x3];
  168. u8 dei[0x1];
  169. u8 vid[0xc];
  170. u8 reserved_at_60[0x20];
  171. u8 reserved_at_80[0x8];
  172. u8 next_rcv_psn[0x18];
  173. u8 reserved_at_a0[0x8];
  174. u8 next_send_psn[0x18];
  175. u8 reserved_at_c0[0x10];
  176. u8 pkey[0x10];
  177. u8 reserved_at_e0[0x8];
  178. u8 remote_qpn[0x18];
  179. u8 reserved_at_100[0x15];
  180. u8 rnr_retry[0x3];
  181. u8 reserved_at_118[0x5];
  182. u8 retry_count[0x3];
  183. u8 reserved_at_120[0x20];
  184. u8 reserved_at_140[0x10];
  185. u8 remote_mac_47_32[0x10];
  186. u8 remote_mac_31_0[0x20];
  187. u8 remote_ip[16][0x8];
  188. u8 reserved_at_200[0x40];
  189. u8 reserved_at_240[0x10];
  190. u8 fpga_mac_47_32[0x10];
  191. u8 fpga_mac_31_0[0x20];
  192. u8 fpga_ip[16][0x8];
  193. };
  194. struct mlx5_ifc_fpga_create_qp_in_bits {
  195. u8 opcode[0x10];
  196. u8 reserved_at_10[0x10];
  197. u8 reserved_at_20[0x10];
  198. u8 op_mod[0x10];
  199. u8 reserved_at_40[0x40];
  200. struct mlx5_ifc_fpga_qpc_bits fpga_qpc;
  201. };
  202. struct mlx5_ifc_fpga_create_qp_out_bits {
  203. u8 status[0x8];
  204. u8 reserved_at_8[0x18];
  205. u8 syndrome[0x20];
  206. u8 reserved_at_40[0x8];
  207. u8 fpga_qpn[0x18];
  208. u8 reserved_at_60[0x20];
  209. struct mlx5_ifc_fpga_qpc_bits fpga_qpc;
  210. };
  211. struct mlx5_ifc_fpga_modify_qp_in_bits {
  212. u8 opcode[0x10];
  213. u8 reserved_at_10[0x10];
  214. u8 reserved_at_20[0x10];
  215. u8 op_mod[0x10];
  216. u8 reserved_at_40[0x8];
  217. u8 fpga_qpn[0x18];
  218. u8 field_select[0x20];
  219. struct mlx5_ifc_fpga_qpc_bits fpga_qpc;
  220. };
  221. struct mlx5_ifc_fpga_modify_qp_out_bits {
  222. u8 status[0x8];
  223. u8 reserved_at_8[0x18];
  224. u8 syndrome[0x20];
  225. u8 reserved_at_40[0x40];
  226. };
  227. struct mlx5_ifc_fpga_query_qp_in_bits {
  228. u8 opcode[0x10];
  229. u8 reserved_at_10[0x10];
  230. u8 reserved_at_20[0x10];
  231. u8 op_mod[0x10];
  232. u8 reserved_at_40[0x8];
  233. u8 fpga_qpn[0x18];
  234. u8 reserved_at_60[0x20];
  235. };
  236. struct mlx5_ifc_fpga_query_qp_out_bits {
  237. u8 status[0x8];
  238. u8 reserved_at_8[0x18];
  239. u8 syndrome[0x20];
  240. u8 reserved_at_40[0x40];
  241. struct mlx5_ifc_fpga_qpc_bits fpga_qpc;
  242. };
  243. struct mlx5_ifc_fpga_query_qp_counters_in_bits {
  244. u8 opcode[0x10];
  245. u8 reserved_at_10[0x10];
  246. u8 reserved_at_20[0x10];
  247. u8 op_mod[0x10];
  248. u8 clear[0x1];
  249. u8 reserved_at_41[0x7];
  250. u8 fpga_qpn[0x18];
  251. u8 reserved_at_60[0x20];
  252. };
  253. struct mlx5_ifc_fpga_query_qp_counters_out_bits {
  254. u8 status[0x8];
  255. u8 reserved_at_8[0x18];
  256. u8 syndrome[0x20];
  257. u8 reserved_at_40[0x40];
  258. u8 rx_ack_packets[0x40];
  259. u8 rx_send_packets[0x40];
  260. u8 tx_ack_packets[0x40];
  261. u8 tx_send_packets[0x40];
  262. u8 rx_total_drop[0x40];
  263. u8 reserved_at_1c0[0x1c0];
  264. };
  265. struct mlx5_ifc_fpga_destroy_qp_in_bits {
  266. u8 opcode[0x10];
  267. u8 reserved_at_10[0x10];
  268. u8 reserved_at_20[0x10];
  269. u8 op_mod[0x10];
  270. u8 reserved_at_40[0x8];
  271. u8 fpga_qpn[0x18];
  272. u8 reserved_at_60[0x20];
  273. };
  274. struct mlx5_ifc_fpga_destroy_qp_out_bits {
  275. u8 status[0x8];
  276. u8 reserved_at_8[0x18];
  277. u8 syndrome[0x20];
  278. u8 reserved_at_40[0x40];
  279. };
  280. struct mlx5_ifc_tls_extended_cap_bits {
  281. u8 aes_gcm_128[0x1];
  282. u8 aes_gcm_256[0x1];
  283. u8 reserved_at_2[0x1e];
  284. u8 reserved_at_20[0x20];
  285. u8 context_capacity_total[0x20];
  286. u8 context_capacity_rx[0x20];
  287. u8 context_capacity_tx[0x20];
  288. u8 reserved_at_a0[0x10];
  289. u8 tls_counter_size[0x10];
  290. u8 tls_counters_addr_low[0x20];
  291. u8 tls_counters_addr_high[0x20];
  292. u8 rx[0x1];
  293. u8 tx[0x1];
  294. u8 tls_v12[0x1];
  295. u8 tls_v13[0x1];
  296. u8 lro[0x1];
  297. u8 ipv6[0x1];
  298. u8 reserved_at_106[0x1a];
  299. };
  300. struct mlx5_ifc_ipsec_extended_cap_bits {
  301. u8 encapsulation[0x20];
  302. u8 reserved_0[0x12];
  303. u8 v2_command[0x1];
  304. u8 udp_encap[0x1];
  305. u8 rx_no_trailer[0x1];
  306. u8 ipv4_fragment[0x1];
  307. u8 ipv6[0x1];
  308. u8 esn[0x1];
  309. u8 lso[0x1];
  310. u8 transport_and_tunnel_mode[0x1];
  311. u8 tunnel_mode[0x1];
  312. u8 transport_mode[0x1];
  313. u8 ah_esp[0x1];
  314. u8 esp[0x1];
  315. u8 ah[0x1];
  316. u8 ipv4_options[0x1];
  317. u8 auth_alg[0x20];
  318. u8 enc_alg[0x20];
  319. u8 sa_cap[0x20];
  320. u8 reserved_1[0x10];
  321. u8 number_of_ipsec_counters[0x10];
  322. u8 ipsec_counters_addr_low[0x20];
  323. u8 ipsec_counters_addr_high[0x20];
  324. };
  325. struct mlx5_ifc_ipsec_counters_bits {
  326. u8 dec_in_packets[0x40];
  327. u8 dec_out_packets[0x40];
  328. u8 dec_bypass_packets[0x40];
  329. u8 enc_in_packets[0x40];
  330. u8 enc_out_packets[0x40];
  331. u8 enc_bypass_packets[0x40];
  332. u8 drop_dec_packets[0x40];
  333. u8 failed_auth_dec_packets[0x40];
  334. u8 drop_enc_packets[0x40];
  335. u8 success_add_sa[0x40];
  336. u8 fail_add_sa[0x40];
  337. u8 success_delete_sa[0x40];
  338. u8 fail_delete_sa[0x40];
  339. u8 dropped_cmd[0x40];
  340. };
  341. enum {
  342. MLX5_FPGA_QP_ERROR_EVENT_SYNDROME_RETRY_COUNTER_EXPIRED = 0x1,
  343. MLX5_FPGA_QP_ERROR_EVENT_SYNDROME_RNR_EXPIRED = 0x2,
  344. };
  345. struct mlx5_ifc_fpga_qp_error_event_bits {
  346. u8 reserved_at_0[0x40];
  347. u8 reserved_at_40[0x18];
  348. u8 syndrome[0x8];
  349. u8 reserved_at_60[0x60];
  350. u8 reserved_at_c0[0x8];
  351. u8 fpga_qpn[0x18];
  352. };
  353. enum mlx5_ifc_fpga_ipsec_response_syndrome {
  354. MLX5_FPGA_IPSEC_RESPONSE_SUCCESS = 0,
  355. MLX5_FPGA_IPSEC_RESPONSE_ILLEGAL_REQUEST = 1,
  356. MLX5_FPGA_IPSEC_RESPONSE_SADB_ISSUE = 2,
  357. MLX5_FPGA_IPSEC_RESPONSE_WRITE_RESPONSE_ISSUE = 3,
  358. };
  359. struct mlx5_ifc_fpga_ipsec_cmd_resp {
  360. __be32 syndrome;
  361. union {
  362. __be32 sw_sa_handle;
  363. __be32 flags;
  364. };
  365. u8 reserved[24];
  366. } __packed;
  367. enum mlx5_ifc_fpga_ipsec_cmd_opcode {
  368. MLX5_FPGA_IPSEC_CMD_OP_ADD_SA = 0,
  369. MLX5_FPGA_IPSEC_CMD_OP_DEL_SA = 1,
  370. MLX5_FPGA_IPSEC_CMD_OP_ADD_SA_V2 = 2,
  371. MLX5_FPGA_IPSEC_CMD_OP_DEL_SA_V2 = 3,
  372. MLX5_FPGA_IPSEC_CMD_OP_MOD_SA_V2 = 4,
  373. MLX5_FPGA_IPSEC_CMD_OP_SET_CAP = 5,
  374. };
  375. enum mlx5_ifc_fpga_ipsec_cap {
  376. MLX5_FPGA_IPSEC_CAP_NO_TRAILER = BIT(0),
  377. };
  378. struct mlx5_ifc_fpga_ipsec_cmd_cap {
  379. __be32 cmd;
  380. __be32 flags;
  381. u8 reserved[24];
  382. } __packed;
  383. enum mlx5_ifc_fpga_ipsec_sa_flags {
  384. MLX5_FPGA_IPSEC_SA_ESN_EN = BIT(0),
  385. MLX5_FPGA_IPSEC_SA_ESN_OVERLAP = BIT(1),
  386. MLX5_FPGA_IPSEC_SA_IPV6 = BIT(2),
  387. MLX5_FPGA_IPSEC_SA_DIR_SX = BIT(3),
  388. MLX5_FPGA_IPSEC_SA_SPI_EN = BIT(4),
  389. MLX5_FPGA_IPSEC_SA_SA_VALID = BIT(5),
  390. MLX5_FPGA_IPSEC_SA_IP_ESP = BIT(6),
  391. MLX5_FPGA_IPSEC_SA_IP_AH = BIT(7),
  392. };
  393. enum mlx5_ifc_fpga_ipsec_sa_enc_mode {
  394. MLX5_FPGA_IPSEC_SA_ENC_MODE_NONE = 0,
  395. MLX5_FPGA_IPSEC_SA_ENC_MODE_AES_GCM_128_AUTH_128 = 1,
  396. MLX5_FPGA_IPSEC_SA_ENC_MODE_AES_GCM_256_AUTH_128 = 3,
  397. };
  398. struct mlx5_ifc_fpga_ipsec_sa_v1 {
  399. __be32 cmd;
  400. u8 key_enc[32];
  401. u8 key_auth[32];
  402. __be32 sip[4];
  403. __be32 dip[4];
  404. union {
  405. struct {
  406. __be32 reserved;
  407. u8 salt_iv[8];
  408. __be32 salt;
  409. } __packed gcm;
  410. struct {
  411. u8 salt[16];
  412. } __packed cbc;
  413. };
  414. __be32 spi;
  415. __be32 sw_sa_handle;
  416. __be16 tfclen;
  417. u8 enc_mode;
  418. u8 reserved1[2];
  419. u8 flags;
  420. u8 reserved2[2];
  421. };
  422. struct mlx5_ifc_fpga_ipsec_sa {
  423. struct mlx5_ifc_fpga_ipsec_sa_v1 ipsec_sa_v1;
  424. __be16 udp_sp;
  425. __be16 udp_dp;
  426. u8 reserved1[4];
  427. __be32 esn;
  428. __be16 vid; /* only 12 bits, rest is reserved */
  429. __be16 reserved2;
  430. } __packed;
  431. enum fpga_tls_cmds {
  432. CMD_SETUP_STREAM = 0x1001,
  433. CMD_TEARDOWN_STREAM = 0x1002,
  434. CMD_RESYNC_RX = 0x1003,
  435. };
  436. #define MLX5_TLS_1_2 (0)
  437. #define MLX5_TLS_ALG_AES_GCM_128 (0)
  438. #define MLX5_TLS_ALG_AES_GCM_256 (1)
  439. struct mlx5_ifc_tls_cmd_bits {
  440. u8 command_type[0x20];
  441. u8 ipv6[0x1];
  442. u8 direction_sx[0x1];
  443. u8 tls_version[0x2];
  444. u8 reserved[0x1c];
  445. u8 swid[0x20];
  446. u8 src_port[0x10];
  447. u8 dst_port[0x10];
  448. union mlx5_ifc_ipv6_layout_ipv4_layout_auto_bits src_ipv4_src_ipv6;
  449. union mlx5_ifc_ipv6_layout_ipv4_layout_auto_bits dst_ipv4_dst_ipv6;
  450. u8 tls_rcd_sn[0x40];
  451. u8 tcp_sn[0x20];
  452. u8 tls_implicit_iv[0x20];
  453. u8 tls_xor_iv[0x40];
  454. u8 encryption_key[0x100];
  455. u8 alg[4];
  456. u8 reserved2[0x1c];
  457. u8 reserved3[0x4a0];
  458. };
  459. struct mlx5_ifc_tls_resp_bits {
  460. u8 syndrome[0x20];
  461. u8 stream_id[0x20];
  462. u8 reserverd[0x40];
  463. };
  464. #define MLX5_TLS_COMMAND_SIZE (0x100)
  465. #endif /* MLX5_IFC_FPGA_H */