You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mlx_nodnic_data_structures.h 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. #ifndef NODNIC_NODNICDATASTRUCTURES_H_
  2. #define NODNIC_NODNICDATASTRUCTURES_H_
  3. /*
  4. * Copyright (C) 2015 Mellanox Technologies Ltd.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation; either version 2 of the
  9. * License, or any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19. * 02110-1301, USA.
  20. */
  21. FILE_LICENCE ( GPL2_OR_LATER );
  22. #include "../../mlx_utils/include/public/mlx_utils.h"
  23. /* todo: fix coding convention */
  24. #define NODNIC_MEMORY_ALIGN 0x1000
  25. #define NODNIC_MAX_MAC_FILTERS 5
  26. #define NODNIC_MAX_MGID_FILTERS 4
  27. typedef struct _nodnic_device_priv nodnic_device_priv;
  28. typedef struct _nodnic_port_priv nodnic_port_priv;
  29. typedef struct _nodnic_device_capabilites nodnic_device_capabilites;
  30. typedef struct _nodnic_qp nodnic_qp;
  31. typedef struct _nodnic_cq nodnic_cq;
  32. typedef struct _nodnic_eq nodnic_eq;
  33. typedef struct _nodnic_qp_db nodnic_qp_db;
  34. typedef struct _nodnic_arm_cq_db nodnic_arm_cq_db;
  35. /* NODNIC Port states
  36. * Bit 0 - port open/close
  37. * Bit 1 - port is [not] in disabling DMA
  38. * 0 - closed and not disabling DMA
  39. * 1 - opened and not disabling DMA
  40. * 3 - opened and disabling DMA
  41. */
  42. #define NODNIC_PORT_OPENED 0b00000001
  43. #define NODNIC_PORT_DISABLING_DMA 0b00000010
  44. typedef enum {
  45. ConnectX3 = 0,
  46. Connectx4
  47. }nodnic_hardware_format;
  48. typedef enum {
  49. NODNIC_QPT_SMI,
  50. NODNIC_QPT_GSI,
  51. NODNIC_QPT_UD,
  52. NODNIC_QPT_RC,
  53. NODNIC_QPT_ETH,
  54. }nodnic_queue_pair_type;
  55. typedef enum {
  56. NODNIC_PORT_TYPE_IB = 0,
  57. NODNIC_PORT_TYPE_ETH,
  58. NODNIC_PORT_TYPE_UNKNOWN,
  59. }nodnic_port_type;
  60. #define RECV_WQE_SIZE 16
  61. #define NODNIC_WQBB_SIZE 64
  62. /** A nodnic send wqbb */
  63. struct nodnic_send_wqbb {
  64. mlx_uint8 force_align[NODNIC_WQBB_SIZE];
  65. };
  66. struct nodnic_doorbell {
  67. mlx_physical_address doorbell_physical;
  68. mlx_void *map;
  69. nodnic_qp_db *qp_doorbell_record;
  70. };
  71. struct nodnic_ring {
  72. mlx_uint32 offset;
  73. /** Work queue entries */
  74. /* TODO: add to memory entity */
  75. mlx_physical_address wqe_physical;
  76. mlx_void *map;
  77. /** Size of work queue */
  78. mlx_size wq_size;
  79. /** Next work queue entry index
  80. *
  81. * This is the index of the next entry to be filled (i.e. the
  82. * first empty entry). This value is not bounded by num_wqes;
  83. * users must logical-AND with (num_wqes-1) to generate an
  84. * array index.
  85. */
  86. mlx_uint32 num_wqes;
  87. mlx_uint32 qpn;
  88. mlx_uint32 next_idx;
  89. struct nodnic_doorbell recv_doorbell;
  90. struct nodnic_doorbell send_doorbell;
  91. };
  92. struct nodnic_send_ring{
  93. struct nodnic_ring nodnic_ring;
  94. struct nodnic_send_wqbb *wqe_virt;
  95. };
  96. struct nodnic_recv_ring{
  97. struct nodnic_ring nodnic_ring;
  98. void *wqe_virt;
  99. };
  100. struct _nodnic_qp{
  101. nodnic_queue_pair_type type;
  102. struct nodnic_send_ring send;
  103. struct nodnic_recv_ring receive;
  104. };
  105. struct _nodnic_cq{
  106. /** cq entries */
  107. mlx_void *cq_virt;
  108. mlx_physical_address cq_physical;
  109. mlx_void *map;
  110. /** cq */
  111. mlx_size cq_size;
  112. struct nodnic_doorbell arm_cq_doorbell;
  113. };
  114. struct _nodnic_eq{
  115. mlx_void *eq_virt;
  116. mlx_physical_address eq_physical;
  117. mlx_void *map;
  118. mlx_size eq_size;
  119. };
  120. struct _nodnic_device_capabilites{
  121. mlx_boolean support_mac_filters;
  122. mlx_boolean support_promisc_filter;
  123. mlx_boolean support_promisc_multicast_filter;
  124. mlx_uint8 log_working_buffer_size;
  125. mlx_uint8 log_pkey_table_size;
  126. mlx_boolean num_ports; // 0 - single port, 1 - dual port
  127. mlx_uint8 log_max_ring_size;
  128. #ifdef DEVICE_CX3
  129. mlx_uint8 crspace_doorbells;
  130. #endif
  131. mlx_uint8 support_rx_pi_dma;
  132. mlx_uint8 support_uar_tx_db;
  133. mlx_uint8 support_bar_cq_ctrl;
  134. mlx_uint8 log_uar_page_size;
  135. };
  136. #ifdef DEVICE_CX3
  137. /* This is the structure of the data in the scratchpad
  138. * Read/Write data from/to its field using PCI accesses only */
  139. typedef struct _nodnic_port_data_flow_gw nodnic_port_data_flow_gw;
  140. struct _nodnic_port_data_flow_gw {
  141. mlx_uint32 send_doorbell;
  142. mlx_uint32 recv_doorbell;
  143. mlx_uint32 reserved2[2];
  144. mlx_uint32 armcq_cq_ci_dword;
  145. mlx_uint32 dma_en;
  146. } __attribute__ ((packed));
  147. #endif
  148. typedef struct _nodnic_uar_priv{
  149. mlx_uint8 inited;
  150. mlx_uint64 offset;
  151. void *virt;
  152. unsigned long phys;
  153. } nodnic_uar;
  154. struct _nodnic_device_priv{
  155. mlx_boolean is_initiailzied;
  156. mlx_utils *utils;
  157. //nodnic structure offset in init segment
  158. mlx_uint32 device_offset;
  159. nodnic_device_capabilites device_cap;
  160. mlx_uint8 nodnic_revision;
  161. nodnic_hardware_format hardware_format;
  162. mlx_uint32 pd;
  163. mlx_uint32 lkey;
  164. mlx_uint64 device_guid;
  165. nodnic_port_priv *ports;
  166. #ifdef DEVICE_CX3
  167. mlx_void *crspace_clear_int;
  168. #endif
  169. nodnic_uar uar;
  170. };
  171. struct _nodnic_port_priv{
  172. nodnic_device_priv *device;
  173. mlx_uint32 port_offset;
  174. mlx_uint8 port_state;
  175. mlx_boolean network_state;
  176. mlx_boolean dma_state;
  177. nodnic_port_type port_type;
  178. mlx_uint8 port_num;
  179. nodnic_eq eq;
  180. mlx_mac_address mac_filters[5];
  181. nodnic_arm_cq_db *arm_cq_doorbell_record;
  182. mlx_status (*send_doorbell)(
  183. IN nodnic_port_priv *port_priv,
  184. IN struct nodnic_ring *ring,
  185. IN mlx_uint16 index);
  186. mlx_status (*recv_doorbell)(
  187. IN nodnic_port_priv *port_priv,
  188. IN struct nodnic_ring *ring,
  189. IN mlx_uint16 index);
  190. mlx_status (*set_dma)(
  191. IN nodnic_port_priv *port_priv,
  192. IN mlx_boolean value);
  193. #ifdef DEVICE_CX3
  194. nodnic_port_data_flow_gw *data_flow_gw;
  195. #endif
  196. };
  197. struct _nodnic_qp_db {
  198. mlx_uint32 recv_db;
  199. mlx_uint32 send_db;
  200. } __attribute ( ( packed ) );
  201. struct _nodnic_arm_cq_db {
  202. mlx_uint32 dword[2];
  203. } __attribute ( ( packed ) );
  204. #endif /* STUB_NODNIC_NODNICDATASTRUCTURES_H_ */