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.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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. /* NODNIC Port states
  34. * Bit 0 - port open/close
  35. * Bit 1 - port is [not] in disabling DMA
  36. * 0 - closed and not disabling DMA
  37. * 1 - opened and not disabling DMA
  38. * 3 - opened and disabling DMA
  39. */
  40. #define NODNIC_PORT_OPENED 0b00000001
  41. #define NODNIC_PORT_DISABLING_DMA 0b00000010
  42. typedef enum {
  43. ConnectX3 = 0,
  44. Connectx4
  45. }nodnic_hardware_format;
  46. typedef enum {
  47. NODNIC_QPT_SMI,
  48. NODNIC_QPT_GSI,
  49. NODNIC_QPT_UD,
  50. NODNIC_QPT_RC,
  51. NODNIC_QPT_ETH,
  52. }nodnic_queue_pair_type;
  53. typedef enum {
  54. NODNIC_PORT_TYPE_IB = 0,
  55. NODNIC_PORT_TYPE_ETH,
  56. NODNIC_PORT_TYPE_UNKNOWN,
  57. }nodnic_port_type;
  58. #define RECV_WQE_SIZE 16
  59. #define NODNIC_WQBB_SIZE 64
  60. /** A nodnic send wqbb */
  61. struct nodnic_send_wqbb {
  62. mlx_uint8 force_align[NODNIC_WQBB_SIZE];
  63. };
  64. struct nodnic_ring {
  65. mlx_uint32 offset;
  66. /** Work queue entries */
  67. /* TODO: add to memory entity */
  68. mlx_physical_address wqe_physical;
  69. mlx_void *map;
  70. /** Size of work queue */
  71. mlx_size wq_size;
  72. /** Next work queue entry index
  73. *
  74. * This is the index of the next entry to be filled (i.e. the
  75. * first empty entry). This value is not bounded by num_wqes;
  76. * users must logical-AND with (num_wqes-1) to generate an
  77. * array index.
  78. */
  79. mlx_uint32 num_wqes;
  80. mlx_uint32 qpn;
  81. mlx_uint32 next_idx;
  82. mlx_uint32 ring_pi;
  83. };
  84. struct nodnic_send_ring{
  85. struct nodnic_ring nodnic_ring;
  86. struct nodnic_send_wqbb *wqe_virt;
  87. };
  88. struct nodnic_recv_ring{
  89. struct nodnic_ring nodnic_ring;
  90. void *wqe_virt;
  91. };
  92. struct _nodnic_qp{
  93. nodnic_queue_pair_type type;
  94. struct nodnic_send_ring send;
  95. struct nodnic_recv_ring receive;
  96. };
  97. struct _nodnic_cq{
  98. /** cq entries */
  99. mlx_void *cq_virt;
  100. mlx_physical_address cq_physical;
  101. mlx_void *map;
  102. /** cq */
  103. mlx_size cq_size;
  104. };
  105. struct _nodnic_eq{
  106. mlx_void *eq_virt;
  107. mlx_physical_address eq_physical;
  108. mlx_void *map;
  109. mlx_size eq_size;
  110. };
  111. struct _nodnic_device_capabilites{
  112. mlx_boolean support_mac_filters;
  113. mlx_boolean support_promisc_filter;
  114. mlx_boolean support_promisc_multicast_filter;
  115. mlx_uint8 log_working_buffer_size;
  116. mlx_uint8 log_pkey_table_size;
  117. mlx_boolean num_ports; // 0 - single port, 1 - dual port
  118. mlx_uint8 log_max_ring_size;
  119. #ifdef DEVICE_CX3
  120. mlx_uint8 crspace_doorbells;
  121. #endif
  122. };
  123. #ifdef DEVICE_CX3
  124. /* This is the structure of the data in the scratchpad
  125. * Read/Write data from/to its field using PCI accesses only */
  126. typedef struct _nodnic_port_data_flow_gw nodnic_port_data_flow_gw;
  127. struct _nodnic_port_data_flow_gw {
  128. mlx_uint32 send_doorbell;
  129. mlx_uint32 recv_doorbell;
  130. mlx_uint32 reserved2[2];
  131. mlx_uint32 armcq_cq_ci_dword;
  132. mlx_uint32 dma_en;
  133. } __attribute__ ((packed));
  134. #endif
  135. struct _nodnic_device_priv{
  136. mlx_boolean is_initiailzied;
  137. mlx_utils *utils;
  138. //nodnic structure offset in init segment
  139. mlx_uint32 device_offset;
  140. nodnic_device_capabilites device_cap;
  141. mlx_uint8 nodnic_revision;
  142. nodnic_hardware_format hardware_format;
  143. mlx_uint32 pd;
  144. mlx_uint32 lkey;
  145. mlx_uint64 device_guid;
  146. nodnic_port_priv *ports;
  147. #ifdef DEVICE_CX3
  148. mlx_void *crspace_clear_int;
  149. #endif
  150. };
  151. struct _nodnic_port_priv{
  152. nodnic_device_priv *device;
  153. mlx_uint32 port_offset;
  154. mlx_uint8 port_state;
  155. mlx_boolean network_state;
  156. mlx_boolean dma_state;
  157. nodnic_port_type port_type;
  158. mlx_uint8 port_num;
  159. nodnic_eq eq;
  160. mlx_mac_address mac_filters[5];
  161. mlx_status (*send_doorbell)(
  162. IN nodnic_port_priv *port_priv,
  163. IN struct nodnic_ring *ring,
  164. IN mlx_uint16 index);
  165. mlx_status (*recv_doorbell)(
  166. IN nodnic_port_priv *port_priv,
  167. IN struct nodnic_ring *ring,
  168. IN mlx_uint16 index);
  169. mlx_status (*set_dma)(
  170. IN nodnic_port_priv *port_priv,
  171. IN mlx_boolean value);
  172. #ifdef DEVICE_CX3
  173. nodnic_port_data_flow_gw *data_flow_gw;
  174. #endif
  175. };
  176. #endif /* STUB_NODNIC_NODNICDATASTRUCTURES_H_ */