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