efa_com_cmd.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. /* SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause */
  2. /*
  3. * Copyright 2018-2025 Amazon.com, Inc. or its affiliates. All rights reserved.
  4. */
  5. #ifndef _EFA_COM_CMD_H_
  6. #define _EFA_COM_CMD_H_
  7. #include "efa_com.h"
  8. #define EFA_GID_SIZE 16
  9. struct efa_com_create_qp_params {
  10. u64 rq_base_addr;
  11. u32 send_cq_idx;
  12. u32 recv_cq_idx;
  13. /*
  14. * Send descriptor ring size in bytes,
  15. * sufficient for user-provided number of WQEs and SGL size
  16. */
  17. u32 sq_ring_size_in_bytes;
  18. /* Max number of WQEs that will be posted on send queue */
  19. u32 sq_depth;
  20. /* Recv descriptor ring size in bytes */
  21. u32 rq_ring_size_in_bytes;
  22. u32 rq_depth;
  23. u16 pd;
  24. u16 uarn;
  25. u8 qp_type;
  26. u8 sl;
  27. u8 unsolicited_write_recv : 1;
  28. };
  29. struct efa_com_create_qp_result {
  30. u32 qp_handle;
  31. u32 qp_num;
  32. u32 sq_db_offset;
  33. u32 rq_db_offset;
  34. u32 llq_descriptors_offset;
  35. u16 send_sub_cq_idx;
  36. u16 recv_sub_cq_idx;
  37. };
  38. struct efa_com_modify_qp_params {
  39. u32 modify_mask;
  40. u32 qp_handle;
  41. u32 qp_state;
  42. u32 cur_qp_state;
  43. u32 qkey;
  44. u32 sq_psn;
  45. u8 sq_drained_async_notify;
  46. u8 rnr_retry;
  47. };
  48. struct efa_com_query_qp_params {
  49. u32 qp_handle;
  50. };
  51. struct efa_com_query_qp_result {
  52. u32 qp_state;
  53. u32 qkey;
  54. u32 sq_draining;
  55. u32 sq_psn;
  56. u8 rnr_retry;
  57. };
  58. struct efa_com_destroy_qp_params {
  59. u32 qp_handle;
  60. };
  61. struct efa_com_create_cq_params {
  62. /* cq physical base address in OS memory */
  63. dma_addr_t dma_addr;
  64. /* completion queue depth in # of entries */
  65. u16 sub_cq_depth;
  66. u16 num_sub_cqs;
  67. u16 uarn;
  68. u16 eqn;
  69. u8 entry_size_in_bytes;
  70. u8 interrupt_mode_enabled : 1;
  71. u8 set_src_addr : 1;
  72. };
  73. struct efa_com_create_cq_result {
  74. /* cq identifier */
  75. u16 cq_idx;
  76. /* actual cq depth in # of entries */
  77. u16 actual_depth;
  78. u32 db_off;
  79. bool db_valid;
  80. };
  81. struct efa_com_destroy_cq_params {
  82. u16 cq_idx;
  83. };
  84. struct efa_com_create_ah_params {
  85. u16 pdn;
  86. /* Destination address in network byte order */
  87. u8 dest_addr[EFA_GID_SIZE];
  88. };
  89. struct efa_com_create_ah_result {
  90. u16 ah;
  91. };
  92. struct efa_com_destroy_ah_params {
  93. u16 ah;
  94. u16 pdn;
  95. };
  96. struct efa_com_get_device_attr_result {
  97. u8 addr[EFA_GID_SIZE];
  98. u64 page_size_cap;
  99. u64 max_mr_pages;
  100. u64 guid;
  101. u32 mtu;
  102. u32 fw_version;
  103. u32 admin_api_version;
  104. u32 device_version;
  105. u32 supported_features;
  106. u32 phys_addr_width;
  107. u32 virt_addr_width;
  108. u32 max_qp;
  109. u32 max_sq_depth; /* wqes */
  110. u32 max_rq_depth; /* wqes */
  111. u32 max_cq;
  112. u32 max_cq_depth; /* cqes */
  113. u32 inline_buf_size;
  114. u32 max_mr;
  115. u32 max_pd;
  116. u32 max_ah;
  117. u32 max_llq_size;
  118. u32 max_rdma_size;
  119. u32 device_caps;
  120. u32 max_eq;
  121. u32 max_eq_depth;
  122. u32 event_bitmask; /* EQ events bitmask */
  123. u16 sub_cqs_per_cq;
  124. u16 max_sq_sge;
  125. u16 max_rq_sge;
  126. u16 max_wr_rdma_sge;
  127. u16 max_tx_batch;
  128. u16 min_sq_depth;
  129. u16 max_link_speed_gbps;
  130. u8 db_bar;
  131. };
  132. struct efa_com_get_hw_hints_result {
  133. u16 mmio_read_timeout;
  134. u16 driver_watchdog_timeout;
  135. u16 admin_completion_timeout;
  136. u16 poll_interval;
  137. u32 reserved[4];
  138. };
  139. struct efa_com_mem_addr {
  140. u32 mem_addr_low;
  141. u32 mem_addr_high;
  142. };
  143. /* Used at indirect mode page list chunks for chaining */
  144. struct efa_com_ctrl_buff_info {
  145. /* indicates length of the buffer pointed by control_buffer_address. */
  146. u32 length;
  147. /* points to control buffer (direct or indirect) */
  148. struct efa_com_mem_addr address;
  149. };
  150. struct efa_com_reg_mr_params {
  151. /* Memory region length, in bytes. */
  152. u64 mr_length_in_bytes;
  153. /* IO Virtual Address associated with this MR. */
  154. u64 iova;
  155. /* words 8:15: Physical Buffer List, each element is page-aligned. */
  156. union {
  157. /*
  158. * Inline array of physical addresses of app pages
  159. * (optimization for short region reservations)
  160. */
  161. u64 inline_pbl_array[4];
  162. /*
  163. * Describes the next physically contiguous chunk of indirect
  164. * page list. A page list contains physical addresses of command
  165. * data pages. Data pages are 4KB; page list chunks are
  166. * variable-sized.
  167. */
  168. struct efa_com_ctrl_buff_info pbl;
  169. } pbl;
  170. /* number of pages in PBL (redundant, could be calculated) */
  171. u32 page_num;
  172. /* Protection Domain */
  173. u16 pd;
  174. /*
  175. * phys_page_size_shift - page size is (1 << phys_page_size_shift)
  176. * Page size is used for building the Virtual to Physical
  177. * address mapping
  178. */
  179. u8 page_shift;
  180. /* see permissions field of struct efa_admin_reg_mr_cmd */
  181. u8 permissions;
  182. u8 inline_pbl;
  183. u8 indirect;
  184. };
  185. struct efa_com_mr_interconnect_info {
  186. u16 recv_ic_id;
  187. u16 rdma_read_ic_id;
  188. u16 rdma_recv_ic_id;
  189. u8 recv_ic_id_valid : 1;
  190. u8 rdma_read_ic_id_valid : 1;
  191. u8 rdma_recv_ic_id_valid : 1;
  192. };
  193. struct efa_com_reg_mr_result {
  194. /*
  195. * To be used in conjunction with local buffers references in SQ and
  196. * RQ WQE
  197. */
  198. u32 l_key;
  199. /*
  200. * To be used in incoming RDMA semantics messages to refer to remotely
  201. * accessed memory region
  202. */
  203. u32 r_key;
  204. struct efa_com_mr_interconnect_info ic_info;
  205. };
  206. struct efa_com_dereg_mr_params {
  207. u32 l_key;
  208. };
  209. struct efa_com_alloc_pd_result {
  210. u16 pdn;
  211. };
  212. struct efa_com_dealloc_pd_params {
  213. u16 pdn;
  214. };
  215. struct efa_com_alloc_uar_result {
  216. u16 uarn;
  217. };
  218. struct efa_com_dealloc_uar_params {
  219. u16 uarn;
  220. };
  221. struct efa_com_get_stats_params {
  222. /* see enum efa_admin_get_stats_type */
  223. u8 type;
  224. /* see enum efa_admin_get_stats_scope */
  225. u8 scope;
  226. u16 scope_modifier;
  227. };
  228. struct efa_com_basic_stats {
  229. u64 tx_bytes;
  230. u64 tx_pkts;
  231. u64 rx_bytes;
  232. u64 rx_pkts;
  233. u64 rx_drops;
  234. };
  235. struct efa_com_messages_stats {
  236. u64 send_bytes;
  237. u64 send_wrs;
  238. u64 recv_bytes;
  239. u64 recv_wrs;
  240. };
  241. struct efa_com_rdma_read_stats {
  242. u64 read_wrs;
  243. u64 read_bytes;
  244. u64 read_wr_err;
  245. u64 read_resp_bytes;
  246. };
  247. struct efa_com_rdma_write_stats {
  248. u64 write_wrs;
  249. u64 write_bytes;
  250. u64 write_wr_err;
  251. u64 write_recv_bytes;
  252. };
  253. struct efa_com_network_stats {
  254. u64 retrans_bytes;
  255. u64 retrans_pkts;
  256. u64 retrans_timeout_events;
  257. u64 unresponsive_remote_events;
  258. u64 impaired_remote_conn_events;
  259. };
  260. union efa_com_get_stats_result {
  261. struct efa_com_basic_stats basic_stats;
  262. struct efa_com_messages_stats messages_stats;
  263. struct efa_com_rdma_read_stats rdma_read_stats;
  264. struct efa_com_rdma_write_stats rdma_write_stats;
  265. struct efa_com_network_stats network_stats;
  266. };
  267. int efa_com_create_qp(struct efa_com_dev *edev,
  268. struct efa_com_create_qp_params *params,
  269. struct efa_com_create_qp_result *res);
  270. int efa_com_modify_qp(struct efa_com_dev *edev,
  271. struct efa_com_modify_qp_params *params);
  272. int efa_com_query_qp(struct efa_com_dev *edev,
  273. struct efa_com_query_qp_params *params,
  274. struct efa_com_query_qp_result *result);
  275. int efa_com_destroy_qp(struct efa_com_dev *edev,
  276. struct efa_com_destroy_qp_params *params);
  277. int efa_com_create_cq(struct efa_com_dev *edev,
  278. struct efa_com_create_cq_params *params,
  279. struct efa_com_create_cq_result *result);
  280. int efa_com_destroy_cq(struct efa_com_dev *edev,
  281. struct efa_com_destroy_cq_params *params);
  282. int efa_com_register_mr(struct efa_com_dev *edev,
  283. struct efa_com_reg_mr_params *params,
  284. struct efa_com_reg_mr_result *result);
  285. int efa_com_dereg_mr(struct efa_com_dev *edev,
  286. struct efa_com_dereg_mr_params *params);
  287. int efa_com_create_ah(struct efa_com_dev *edev,
  288. struct efa_com_create_ah_params *params,
  289. struct efa_com_create_ah_result *result);
  290. int efa_com_destroy_ah(struct efa_com_dev *edev,
  291. struct efa_com_destroy_ah_params *params);
  292. int efa_com_get_device_attr(struct efa_com_dev *edev,
  293. struct efa_com_get_device_attr_result *result);
  294. int efa_com_get_hw_hints(struct efa_com_dev *edev,
  295. struct efa_com_get_hw_hints_result *result);
  296. bool
  297. efa_com_check_supported_feature_id(struct efa_com_dev *edev,
  298. enum efa_admin_aq_feature_id feature_id);
  299. int efa_com_set_feature_ex(struct efa_com_dev *edev,
  300. struct efa_admin_set_feature_resp *set_resp,
  301. struct efa_admin_set_feature_cmd *set_cmd,
  302. enum efa_admin_aq_feature_id feature_id,
  303. dma_addr_t control_buf_dma_addr,
  304. u32 control_buff_size);
  305. int efa_com_set_aenq_config(struct efa_com_dev *edev, u32 groups);
  306. int efa_com_alloc_pd(struct efa_com_dev *edev,
  307. struct efa_com_alloc_pd_result *result);
  308. int efa_com_dealloc_pd(struct efa_com_dev *edev,
  309. struct efa_com_dealloc_pd_params *params);
  310. int efa_com_alloc_uar(struct efa_com_dev *edev,
  311. struct efa_com_alloc_uar_result *result);
  312. int efa_com_dealloc_uar(struct efa_com_dev *edev,
  313. struct efa_com_dealloc_uar_params *params);
  314. int efa_com_get_stats(struct efa_com_dev *edev,
  315. struct efa_com_get_stats_params *params,
  316. union efa_com_get_stats_result *result);
  317. #endif /* _EFA_COM_CMD_H_ */