symbols.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. #pragma once
  2. #define USE_DYNAMIC_OPEN
  3. #include <infiniband/mlx5dv.h>
  4. #include <infiniband/verbs.h>
  5. #include <rdma/rdma_cma.h>
  6. #undef ibv_reg_mr
  7. #undef ibv_query_port
  8. #ifdef __cplusplus
  9. template <class T>
  10. struct TId {
  11. typedef T R;
  12. };
  13. #define DOSTRUCT(name, type) TId<type>::R* name;
  14. #else
  15. #define DOSTRUCT(name, type) typeof(name)* name;
  16. #endif
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. // verbs
  21. #define DOVERBS(M) \
  22. M(ibv_modify_qp, int (struct ibv_qp *qp, struct ibv_qp_attr *attr, int attr_mask)) \
  23. M(ibv_create_ah, struct ibv_ah *(struct ibv_pd *pd, struct ibv_ah_attr *attr)) \
  24. M(ibv_create_cq, struct ibv_cq *(struct ibv_context *context, int cqe, void *cq_context, struct ibv_comp_channel *channel, int comp_vector)) \
  25. M(ibv_destroy_ah, int (struct ibv_ah *ah)) \
  26. M(ibv_create_qp, struct ibv_qp *(struct ibv_pd *pd, struct ibv_qp_init_attr *qp_init_attr)) \
  27. M(ibv_fork_init, int (void)) \
  28. M(ibv_open_device, struct ibv_context *(struct ibv_device *device)) \
  29. M(ibv_close_device, int (struct ibv_context *context)) \
  30. M(ibv_alloc_pd, struct ibv_pd *(struct ibv_context *context)) \
  31. M(ibv_dealloc_pd, int (struct ibv_pd *pd)) \
  32. M(ibv_free_device_list, void (struct ibv_device **list)) \
  33. M(ibv_query_device, int (struct ibv_context *context, struct ibv_device_attr *device_attr)) \
  34. M(ibv_get_device_list, struct ibv_device **(int *num_devices)) \
  35. M(ibv_destroy_qp, int (struct ibv_qp *qp)) \
  36. M(ibv_create_srq, struct ibv_srq *(struct ibv_pd *pd, struct ibv_srq_init_attr *srq_init_attr)) \
  37. M(ibv_destroy_srq, int (struct ibv_srq *srq)) \
  38. M(ibv_init_ah_from_wc, int (struct ibv_context *context, uint8_t port_num, struct ibv_wc *wc, struct ibv_grh *grh, struct ibv_ah_attr *ah_attr)) \
  39. M(ibv_reg_mr, struct ibv_mr *(struct ibv_pd *pd, void *addr, size_t length, int access)) \
  40. M(ibv_reg_mr_iova2, struct ibv_mr *(struct ibv_pd *pd, void *addr, size_t length, uint64_t iova, unsigned int access)) \
  41. M(ibv_dereg_mr, int (struct ibv_mr *mr)) \
  42. M(ibv_query_pkey, int (struct ibv_context *context, uint8_t port_num, int index, __be16 *pkey)) \
  43. M(ibv_node_type_str, const char *(enum ibv_node_type node_type)) \
  44. M(ibv_destroy_cq, int (struct ibv_cq *cq)) \
  45. M(ibv_query_gid, int (struct ibv_context *context, uint8_t port_num, int index, union ibv_gid *gid)) \
  46. M(ibv_query_port, int (struct ibv_context *context, uint8_t port_num, struct _compat_ibv_port_attr *port_attr)) \
  47. M(ibv_wc_status_str, const char *(enum ibv_wc_status status)) \
  48. M(ibv_get_device_name, const char *(struct ibv_device *device)) \
  49. M(ibv_get_async_event, int (struct ibv_context *context, struct ibv_async_event *event)) \
  50. M(ibv_event_type_str, const char *(enum ibv_event_type event)) \
  51. M(ibv_query_qp, int (struct ibv_qp *qp, struct ibv_qp_attr *attr, int attr_mask, struct ibv_qp_init_attr *init_attr)) \
  52. M(ibv_resize_cq, int (struct ibv_cq *cq, int cqe)) \
  53. M(ibv_ack_async_event, void (struct ibv_async_event *event)) \
  54. M(ibv_create_comp_channel, struct ibv_comp_channel *(struct ibv_context *context)) \
  55. M(ibv_destroy_comp_channel, int (struct ibv_comp_channel *channel)) \
  56. M(ibv_get_cq_event, int (struct ibv_comp_channel *channel, struct ibv_cq **cq, void **cq_context)) \
  57. M(ibv_ack_cq_events, void (struct ibv_cq *cq, unsigned int nevents)) \
  58. M(ibv_port_state_str, const char *(enum ibv_port_state port_state)) \
  59. // DOVERBS
  60. struct TInfinibandSymbols {
  61. DOVERBS(DOSTRUCT)
  62. };
  63. const struct TInfinibandSymbols* IBSym();
  64. // rdma
  65. #define DORDMA(M) \
  66. M(rdma_ack_cm_event, int (struct rdma_cm_event *event)) \
  67. M(rdma_get_cm_event, int (struct rdma_event_channel *channel, struct rdma_cm_event **event)) \
  68. M(rdma_create_qp, int (struct rdma_cm_id *id, struct ibv_pd *pd, struct ibv_qp_init_attr *qp_init_attr)) \
  69. M(rdma_create_event_channel, struct rdma_event_channel * (void)) \
  70. M(rdma_create_id, int (struct rdma_event_channel *channel, struct rdma_cm_id **id, void *context, enum rdma_port_space ps)) \
  71. M(rdma_resolve_addr, int (struct rdma_cm_id *id, struct sockaddr *src_addr, struct sockaddr *dst_addr, int timeout_ms)) \
  72. M(rdma_resolve_route, int (struct rdma_cm_id *id, int timeout_ms)) \
  73. M(rdma_bind_addr, int (struct rdma_cm_id *id, struct sockaddr *addr)) \
  74. M(rdma_listen, int (struct rdma_cm_id *id, int backlog)) \
  75. M(rdma_accept, int (struct rdma_cm_id *id, struct rdma_conn_param *conn_param)) \
  76. M(rdma_connect, int (struct rdma_cm_id *id, struct rdma_conn_param *conn_param)) \
  77. M(rdma_disconnect, int (struct rdma_cm_id *id)) \
  78. M(rdma_set_option, int (struct rdma_cm_id *id, int level, int optname, void *optval, size_t optlen)) \
  79. M(rdma_destroy_id, int (struct rdma_cm_id *id)) \
  80. M(rdma_destroy_qp, void (struct rdma_cm_id *id)) \
  81. M(rdma_get_devices, struct ibv_context **(int *num_devices)) \
  82. M(rdma_free_devices, void (struct ibv_context **list)) \
  83. M(rdma_destroy_event_channel, void (struct rdma_event_channel *channel)) \
  84. M(rdma_reject, int (struct rdma_cm_id *id, const void *private_data, uint8_t private_data_len)) \
  85. M(rdma_get_dst_port, uint16_t (struct rdma_cm_id *id)) \
  86. M(rdma_get_src_port, uint16_t (struct rdma_cm_id *id)) \
  87. M(rdma_getaddrinfo, int (const char *node, const char *service, const struct rdma_addrinfo *hints, struct rdma_addrinfo **res)) \
  88. M(rdma_freeaddrinfo, void (struct rdma_addrinfo *res)) \
  89. // DORDMA
  90. struct TRdmaSymbols {
  91. DORDMA(DOSTRUCT)
  92. };
  93. const struct TRdmaSymbols* RDSym();
  94. // mlx5
  95. #define DOMLX5(M) \
  96. M(mlx5dv_alloc_var, struct mlx5dv_var *(struct ibv_context *context, uint32_t flags)) \
  97. M(mlx5dv_create_cq, struct ibv_cq_ex *(struct ibv_context *context, struct ibv_cq_init_attr_ex *cq_attr, struct mlx5dv_cq_init_attr *mlx5_cq_attr)) \
  98. M(mlx5dv_create_flow, struct ibv_flow *(struct mlx5dv_flow_matcher *matcher, struct mlx5dv_flow_match_parameters *match_value, size_t num_actions, struct mlx5dv_flow_action_attr actions_attr[])) \
  99. M(mlx5dv_create_flow_matcher, struct mlx5dv_flow_matcher *(struct ibv_context *context, struct mlx5dv_flow_matcher_attr *matcher_attr)) \
  100. M(mlx5dv_create_qp, struct ibv_qp *(struct ibv_context *context, struct ibv_qp_init_attr_ex *qp_attr, struct mlx5dv_qp_init_attr *mlx5_qp_attr)) \
  101. M(mlx5dv_create_wq, struct ibv_wq *(struct ibv_context *context, struct ibv_wq_init_attr *wq_init_attr, struct mlx5dv_wq_init_attr *mlx5_wq_attr)) \
  102. M(mlx5dv_destroy_flow_matcher, int (struct mlx5dv_flow_matcher *matcher)) \
  103. M(mlx5dv_devx_alloc_uar, struct mlx5dv_devx_uar *(struct ibv_context *context, uint32_t flags)) \
  104. M(mlx5dv_devx_create_cmd_comp, struct mlx5dv_devx_cmd_comp *(struct ibv_context *context)) \
  105. M(mlx5dv_devx_create_event_channel, struct mlx5dv_devx_event_channel *(struct ibv_context *context, enum mlx5dv_devx_create_event_channel_flags flags)) \
  106. M(mlx5dv_devx_destroy_cmd_comp, void (struct mlx5dv_devx_cmd_comp *cmd_comp)) \
  107. M(mlx5dv_devx_destroy_event_channel, void (struct mlx5dv_devx_event_channel *event_channel)) \
  108. M(mlx5dv_devx_free_uar, void (struct mlx5dv_devx_uar *devx_uar)) \
  109. M(mlx5dv_devx_general_cmd, int (struct ibv_context *context, const void *in, size_t inlen, void *out, size_t outlen)) \
  110. M(mlx5dv_devx_get_async_cmd_comp, int (struct mlx5dv_devx_cmd_comp *cmd_comp, struct mlx5dv_devx_async_cmd_hdr *cmd_resp, size_t cmd_resp_len)) \
  111. M(mlx5dv_devx_get_event, ssize_t (struct mlx5dv_devx_event_channel *event_channel, struct mlx5dv_devx_async_event_hdr *event_data, size_t event_resp_len)) \
  112. M(mlx5dv_devx_obj_create, struct mlx5dv_devx_obj *(struct ibv_context *context, const void *in, size_t inlen, void *out, size_t outlen)) \
  113. M(mlx5dv_devx_obj_destroy, int (struct mlx5dv_devx_obj *obj)) \
  114. M(mlx5dv_devx_obj_modify, int (struct mlx5dv_devx_obj *obj, const void *in, size_t inlen, void *out, size_t outlen)) \
  115. M(mlx5dv_devx_obj_query, int (struct mlx5dv_devx_obj *obj, const void *in, size_t inlen, void *out, size_t outlen)) \
  116. M(mlx5dv_devx_obj_query_async, int (struct mlx5dv_devx_obj *obj, const void *in, size_t inlen, size_t outlen, uint64_t wr_id, struct mlx5dv_devx_cmd_comp *cmd_comp)) \
  117. M(mlx5dv_devx_qp_query, int (struct ibv_qp *qp, const void *in, size_t inlen, void *out, size_t outlen)) \
  118. M(mlx5dv_devx_query_eqn, int (struct ibv_context *context, uint32_t vector, uint32_t *eqn)) \
  119. M(mlx5dv_devx_subscribe_devx_event, int (struct mlx5dv_devx_event_channel *event_channel, struct mlx5dv_devx_obj *obj, uint16_t events_sz, uint16_t events_num[], uint64_t cookie)) \
  120. M(mlx5dv_devx_subscribe_devx_event_fd, int (struct mlx5dv_devx_event_channel *event_channel, int fd, struct mlx5dv_devx_obj *obj, uint16_t event_num)) \
  121. M(mlx5dv_devx_umem_dereg, int (struct mlx5dv_devx_umem *umem)) \
  122. M(mlx5dv_devx_umem_reg, struct mlx5dv_devx_umem *(struct ibv_context *ctx, void *addr, size_t size, uint32_t access)) \
  123. M(mlx5dv_dr_action_create_aso, struct mlx5dv_dr_action *(struct mlx5dv_dr_domain *domain, struct mlx5dv_devx_obj *devx_obj, uint32_t offset, uint32_t flags, uint8_t return_reg_c)) \
  124. M(mlx5dv_dr_action_create_default_miss, struct mlx5dv_dr_action *(void)) \
  125. M(mlx5dv_dr_action_create_dest_array, struct mlx5dv_dr_action *(struct mlx5dv_dr_domain *domain, size_t num_dest, struct mlx5dv_dr_action_dest_attr *dests[])) \
  126. M(mlx5dv_dr_action_create_dest_devx_tir, struct mlx5dv_dr_action *(struct mlx5dv_devx_obj *devx_obj)) \
  127. M(mlx5dv_dr_action_create_dest_ib_port, struct mlx5dv_dr_action *(struct mlx5dv_dr_domain *domain, uint32_t ib_port)) \
  128. M(mlx5dv_dr_action_create_dest_ibv_qp, struct mlx5dv_dr_action *(struct ibv_qp *ibqp)) \
  129. M(mlx5dv_dr_action_create_dest_table, struct mlx5dv_dr_action *(struct mlx5dv_dr_table *table)) \
  130. M(mlx5dv_dr_action_create_dest_vport, struct mlx5dv_dr_action *(struct mlx5dv_dr_domain *domain, uint32_t vport)) \
  131. M(mlx5dv_dr_action_create_drop, struct mlx5dv_dr_action *(void)) \
  132. M(mlx5dv_dr_action_create_flow_counter, struct mlx5dv_dr_action *(struct mlx5dv_devx_obj *devx_obj, uint32_t offset)) \
  133. M(mlx5dv_dr_action_create_flow_meter, struct mlx5dv_dr_action *(struct mlx5dv_dr_flow_meter_attr *attr)) \
  134. M(mlx5dv_dr_action_create_flow_sampler, struct mlx5dv_dr_action *(struct mlx5dv_dr_flow_sampler_attr *attr)) \
  135. M(mlx5dv_dr_action_create_modify_header, struct mlx5dv_dr_action *(struct mlx5dv_dr_domain *domain, uint32_t flags, size_t actions_sz, __be64 actions[])) \
  136. M(mlx5dv_dr_action_create_packet_reformat, struct mlx5dv_dr_action *(struct mlx5dv_dr_domain *domain, uint32_t flags, enum mlx5dv_flow_action_packet_reformat_type reformat_type, size_t data_sz, void *data)) \
  137. M(mlx5dv_dr_action_create_pop_vlan, struct mlx5dv_dr_action *(void)) \
  138. M(mlx5dv_dr_action_create_push_vlan, struct mlx5dv_dr_action *(struct mlx5dv_dr_domain *domain, __be32 vlan_hdr)) \
  139. M(mlx5dv_dr_action_create_tag, struct mlx5dv_dr_action *(uint32_t tag_value)) \
  140. M(mlx5dv_dr_action_destroy, int (struct mlx5dv_dr_action *action)) \
  141. M(mlx5dv_dr_action_modify_flow_meter, int (struct mlx5dv_dr_action *action, struct mlx5dv_dr_flow_meter_attr *attr, __be64 modify_field_select)) \
  142. M(mlx5dv_dr_domain_create, struct mlx5dv_dr_domain *(struct ibv_context *ctx, enum mlx5dv_dr_domain_type type)) \
  143. M(mlx5dv_dr_domain_destroy, int (struct mlx5dv_dr_domain *domain)) \
  144. M(mlx5dv_dr_domain_set_reclaim_device_memory, void (struct mlx5dv_dr_domain *dmn, bool enable)) \
  145. M(mlx5dv_dr_domain_sync, int (struct mlx5dv_dr_domain *domain, uint32_t flags)) \
  146. M(mlx5dv_dr_matcher_create, struct mlx5dv_dr_matcher *(struct mlx5dv_dr_table *table, uint16_t priority, uint8_t match_criteria_enable, struct mlx5dv_flow_match_parameters *mask)) \
  147. M(mlx5dv_dr_matcher_destroy, int (struct mlx5dv_dr_matcher *matcher)) \
  148. M(mlx5dv_dr_rule_create, struct mlx5dv_dr_rule *(struct mlx5dv_dr_matcher *matcher, struct mlx5dv_flow_match_parameters *value, size_t num_actions, struct mlx5dv_dr_action *actions[])) \
  149. M(mlx5dv_dr_rule_destroy, int (struct mlx5dv_dr_rule *rule)) \
  150. M(mlx5dv_dr_table_create, struct mlx5dv_dr_table *(struct mlx5dv_dr_domain *domain, uint32_t level)) \
  151. M(mlx5dv_dr_table_destroy, int (struct mlx5dv_dr_table *table)) \
  152. M(mlx5dv_dump_dr_domain, int (FILE *fout, struct mlx5dv_dr_domain *domain)) \
  153. M(mlx5dv_free_var, void (struct mlx5dv_var *dv_var)) \
  154. M(mlx5dv_init_obj, int (struct mlx5dv_obj *obj, uint64_t obj_type)) \
  155. M(mlx5dv_open_device, struct ibv_context *(struct ibv_device *device, struct mlx5dv_context_attr *attr)) \
  156. M(mlx5dv_pp_alloc, struct mlx5dv_pp *(struct ibv_context *context, size_t pp_context_sz, const void *pp_context, uint32_t flags)) \
  157. M(mlx5dv_pp_free, void (struct mlx5dv_pp *pp)) \
  158. M(mlx5dv_query_device, int (struct ibv_context *ctx_in, struct mlx5dv_context *attrs_out)) \
  159. M(mlx5dv_query_devx_port, int (struct ibv_context *ctx, uint32_t port_num, struct mlx5dv_devx_port *mlx5_devx_port)) \
  160. M(mlx5dv_set_context_attr, int (struct ibv_context *context, enum mlx5dv_set_ctx_attr_type type, void *attr)) \
  161. // DOMLX5
  162. struct TMlx5Symbols {
  163. DOMLX5(DOSTRUCT)
  164. };
  165. const struct TMlx5Symbols* M5Sym();
  166. #undef DOSTRUCT
  167. #ifdef __cplusplus
  168. }
  169. #endif