efa_com_cmd.h 8.0 KB

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