cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
fmc.hpp
Go to the documentation of this file.
1 
17 
30 #ifndef _FMC_H_
31 #define _FMC_H_
32 
33 #include "ap_int.h"
34 #include "http.hpp"
35 #include "../../../../../hls/cfdk.hpp"
36 #include "../../../../../hls/network.hpp"
37 #include "../../../../../hls/axi_utils.hpp"
38 #include "../../network_utils.hpp"
39 
40 
41 using namespace hls;
42 
43 
44 //Display1
45 #define WFV_V_SHIFT 8
46 #define DONE_SHIFT 1
47 #define WEMPTY_SHIFT 2
48 #define DECOUP_SHIFT 19
49 #define CMD_SHIFT 3
50 #define ASW1_SHIFT 20
51 #define TCP_OPERATION_SHIFT 18
52 
53 //Display2
54 #define ASW2_SHIFT 0
55 #define ASW3_SHIFT 8
56 #define ASW4_SHIFT 16
57 #define NOT_TO_SWAP_SHIFT 24
58 
59 //Display3
60 #define RCNT_SHIFT 24
61 #define MSG_SHIFT 0
62 
63 //Display4
64 #define ANSWER_LENGTH_SHIFT 0
65 #define HTTP_STATE_SHIFT 4
66 #define WRITE_ERROR_CNT_SHIFT 8
67 #define EMPTY_FIFO_CNT_SHIFT 16
68 #define GLOBAL_STATE_SHIFT 24
69 
70 //Display6
71 #define RANK_SHIFT 0
72 #define SIZE_SHIFT 8
73 #define LAST_PAGE_WRITE_CNT_SHIFT 16
74 #define PYRO_SEND_REQUEST_SHIFT 23
75 
76 //Display7
77 #define RX_SESS_STATE_SHIFT 0
78 #define RX_DATA_STATE_SHIFT 4
79 #define TX_SESS_STATE_SHIFT 8
80 #define TX_DATA_STATE_SHIFT 12
81 #define TCP_ITER_COUNT_SHIFT 16
82 #define DETECTED_HTTPNL_SHIFT 24
83 
84 //Display8
85 #define TCP_RX_CNT_SHIFT 0
86 
87 //Display9
88 #define BUFFER_IN_MAX_SHIFT 0
89 #define FULL_FIFO_CNT_SHIFT 16
90 #define ICAP_FSM_SHIFT 24
91 
92 
93 #define WS 4
94 #define SR_OFFSET (0x110/WS)
95 #define ISR_OFFSET (0x20/WS)
96 #define WFV_OFFSET (0x114/WS)
97 #define ASR_OFFSET (0x11C/WS)
98 #define CR_OFFSET (0x10C/WS)
99 #define RFO_OFFSET (0x118/WS)
100 #define WF_OFFSET (0x100/WS)
101 
102 //#define FMC_VERSION 0xA
103 //#define FMC_VERSION_SHIFT 8
104 
105 // MMIO TO FMC Register
106 #define DECOUP_CMD_SHIFT 0
107 #define RST_SHIFT 1
108 #define DSEL_SHIFT 28
109 //#define WCNT_SHIFT 8
110 #define START_SHIFT 12
111 #define SWAP_N_SHIFT 16
112 #define CHECK_PATTERN_SHIFT 13
113 #define PARSE_HTTP_SHIFT 14
114 #define SOFT_RST_SHIFT 2
115 #define PYRO_MODE_SHIFT 15
116 #define PYRO_READ_REQUEST_SHIFT 3
117 #define ENABLE_TCP_MODE_SHIFT 4
118 #define ENABLE_FAKE_HWICAP_SHIFT 5
119 #define LAST_PAGE_CNT_SHIFT 17 //until 23, including
120 
121 //XMEM
122 #define LINES_PER_PAGE 32
123 #define MAX_PAGES 16
124 #define XMEM_SIZE (LINES_PER_PAGE * MAX_PAGES)
125 #define BYTES_PER_PAGE (LINES_PER_PAGE*4)
126 #define PAYLOAD_BYTES_PER_PAGE (BYTES_PER_PAGE - 2)
127 
128 //should be smaller then 2^16, but much bigger than a usual HTTP Header (~ 200 Bytes)
129 //#define IN_BUFFER_SIZE 2048
130 //#define IN_BUFFER_SIZE 8192 //8K
131 #define IN_BUFFER_SIZE 4096 //4K, = HWICAP FIFO DEPTH (in Bytes)
132 //#define IN_BUFFER_SIZE 6144 //6K
133 #define OUT_BUFFER_SIZE 1024
134 #define XMEM_ANSWER_START (1*LINES_PER_PAGE) //Lines! not Bytes
135 
136 //HWICAP CR Commands
137 #define CR_ABORT 0x10
138 #define CR_SWRST 0x8
139 #define CR_FICLR 0x4
140 #define CR_READ 0x2
141 #define CR_WRITE 0x1
142 
143 #define HWICAP_FIFO_DEPTH 1023
144 #define MAX_HWICAP_DATA_CHUNK_BYTES ((4*HWICAP_FIFO_DEPTH) - 24)
145 #define HWICAP_FIFO_NEARLY_FULL_TRIGGER 4
146 
147 #include "../../NAL/src/nal.hpp"
148 //MAX CLUSTER/MAX RANK
149 //only one limit is enough, there is no rank > clusterSize...
150 //#define MAX_CLUSTER_SIZE 128
151 #define MAX_CLUSTER_SIZE (MAX_MRT_SIZE)
152 
153 
154 #define MIN_ROUTING_TABLE_LINE (1+1+4+1) //1: rank, 1: space, 4: IPv4-Address, 1: \n
155 
156 
157 //HTTP State
158 #define HTTP_IDLE 0
159 #define HTTP_PARSE_HEADER 1
160 #define HTTP_HEADER_PARSED 2
161 #define HTTP_READ_PAYLOAD 3
162 #define HTTP_REQUEST_COMPLETE 4
163 #define HTTP_SEND_RESPONSE 5
164 #define HTTP_INVALID_REQUEST 6
165 #define HTTP_DONE 7
166 #define HttpState uint8_t
167 
168 //Global Opperations
169 #define GLOBAL_IDLE 0
170 #define GLOBAL_XMEM_CHECK_PATTERN 1
171 #define GLOBAL_XMEM_TO_HWICAP 2
172 #define GLOBAL_XMEM_HTTP 3
173 #define GLOBAL_TCP_HTTP 4
174 #define GLOBAL_PYROLINK_RECV 5
175 #define GLOBAL_PYROLINK_TRANS 6
176 #define GLOBAL_MANUAL_DECOUPLING 7
177 //#define GLOBAL_TCP_TO_HWICAP 8
178 #define GlobalState uint8_t
179 
180 //Operations return values (one hot encoded)
181 #define OprvType uint8_t
182 #define OPRV_OK 0x1
183 #define OPRV_FAIL 0x2
184 #define OPRV_SKIPPED 0x4
185 #define OPRV_NOT_COMPLETE 0x8
186 #define OPRV_PARTIAL_COMPLETE 0x10
187 #define OPRV_DONE 0x20
188 #define OPRV_USER 0x40
189 #define MASK_ALWAYS 0xFF
190 
191 //TCP FSMs state
192 #define TCP_FSM_RESET 0
193 #define TCP_FSM_IDLE 1
194 #define TCP_FSM_W84_START 2
195 #define TCP_FSM_PROCESS_DATA 3
196 #define TCP_FSM_DONE 4
197 #define TCP_FSM_ERROR 5
198 //#define TCP_FSM_PROCESS_SECOND 7
199 #define TcpFsmState uint8_t
200 
201 //HWICAP FSM state
202 #define ICAP_FSM_RESET 0
203 #define ICAP_FSM_IDLE 1
204 #define ICAP_FSM_WRITE 2
205 #define ICAP_FSM_DONE 3
206 #define ICAP_FSM_ERROR 4
207 #define ICAP_FSM_DRAIN 5
208 #define IcapFsmState uint8_t
209 #define ICAP_FIFO_POISON_PILL 0x0a0b1c2d //isn't a valid JTAG?
210 #define ICAP_FIFO_POISON_PILL_REVERSE 0x2d1c0b0a
211 
212 
213 //FPGA state registers
214 #define NUMBER_FPGA_STATE_REGISTERS 8
215 #define FPGA_STATE_LAYER_4 0
216 #define FPGA_STATE_LAYER_6 1
217 #define FPGA_STATE_LAYER_7 2
218 #define FPGA_STATE_CONFIG_UPDATE 3
219 #define FPGA_STATE_MRT_UPDATE 4
220 #define FPGA_STATE_NTS_READY 5
221 
222 //ctrl link interval
223 #define CHECK_CTRL_LINK_INTERVAL_SECONDS 2
224 #define CHECK_HWICAP_INTERVAL_SECONDS 2
225 
226 #define LINKFSM_IDLE 0
227 #define LINKFSM_WAIT 1
228 #define LINKFSM_UPDATE_MRT 2
229 #define LINKFSM_UPDATE_CONFIG 3
230 #define LINKFSM_UPDATE_STATE 4
231 #define LINKFSM_UPDATE_SAVED_STATE 5
232 #define LinkFsmStateType uint8_t
233 
234 
235 
236 //Internal Opcodes
237 #define OpcodeType uint8_t
238 #define OP_NOP 0
239 #define OP_ENABLE_XMEM_CHECK_PATTERN 1
240 #define OP_XMEM_COPY_DATA 2
241 #define OP_FILL_BUFFER_TCP 3
242 #define OP_HANDLE_HTTP 4
243 #define OP_CHECK_HTTP_EOR 5
244 #define OP_CHECK_HTTP_EOP 6
245 #define OP_BUFFER_TO_HWICAP 7
246 #define OP_BUFFER_TO_PYROLINK 8
247 #define OP_BUFFER_TO_ROUTING 9
248 #define OP_SEND_BUFFER_TCP 10
249 #define OP_SEND_BUFFER_XMEM 11
250 #define OP_CLEAR_IN_BUFFER 12
251 #define OP_CLEAR_OUT_BUFFER 13
252 #define OP_DONE 14
253 #define OP_DISABLE_XMEM_CHECK_PATTERN 15
254 #define OP_ACTIVATE_DECOUP 16
255 #define OP_DEACTIVATE_DECOUP 17
256 #define OP_ABORT_HWICAP 18
257 #define OP_FAIL 19
258 #define OP_UPDATE_HTTP_STATE 20
259 #define OP_COPY_REQTYPE_TO_RETURN 21
260 #define OP_EXIT 22
261 #define OP_ENABLE_SILENT_SKIP 23
262 #define OP_DISABLE_SILENT_SKIP 24
263 #define OP_OK 25
264 #define OP_PYROLINK_TO_OUTBUFFER 26
265 #define OP_WAIT_FOR_TCP_SESS 27
266 #define OP_SEND_TCP_SESS 28
267 #define OP_SET_NOT_TO_SWAP 29
268 #define OP_UNSET_NOT_TO_SWAP 30
269 #define OP_ACTIVATE_CONT_TCP 31
270 #define OP_DEACTIVATE_CONT_TCP 32
271 #define OP_TCP_RX_STOP_ON_EOR 33
272 #define OP_TCP_RX_STOP_ON_EOP 34
273 #define OP_TCP_CNT_RESET 35
274 #define OP_FIFO_TO_HWICAP 36
275 #define OP_CLEAR_ROUTING_TABLE 37
276 
277 
278 #define MAX_PROGRAM_LENGTH 64
279 
280 
281 
282 #define GLOBAL_MAX_WAIT_COUNT (5 * 1024)
283 
284 extern uint8_t bufferIn[IN_BUFFER_SIZE];
285 extern uint8_t bufferOut[OUT_BUFFER_SIZE];
286 extern uint32_t bufferInPtrWrite;
287 extern uint32_t bufferInPtrNextRead;
288 extern uint16_t bufferOutPtrWrite;
289 extern uint16_t bufferOutContentLength;
290 
291 #ifndef __SYNTHESIS__
292 extern bool use_sequential_hwicap;
293 extern uint32_t sequential_hwicap_address;
294 #endif
295 
296 extern HttpState httpState;
297 //extern ap_uint<16> currentPayloadStart;
298 
299 void emptyInBuffer();
300 void emptyOutBuffer();
301 uint32_t writeDisplaysToOutBuffer();
302 
303 void setRank(ap_uint<32> newRank);
304 void setSize(ap_uint<32> newSize);
305 
306 void fmc(
307  //EMIF Registers
308  ap_uint<32> *MMIO_in, ap_uint<32> *MMIO_out,
309  //state of the FPGA
310  ap_uint<1> *layer_4_enabled,
311  ap_uint<1> *layer_6_enabled,
312  ap_uint<1> *layer_7_enabled,
313  ap_uint<1> *nts_ready,
314  //get FPGA time
315  ap_uint<32> *in_time_seconds,
316  ap_uint<32> *in_time_minutes,
317  ap_uint<32> *in_time_hours,
318  //get ROLE version
319  ap_uint<16> *role_mmio_in,
320  //get UOE drop count
321  ap_uint<16> *uoe_drop_cnt_in,
322  //get TOE drop counts
323  ap_uint<8> *toe_notif_drop_cnt_in,
324  ap_uint<8> *toe_meta_drop_cnt_in,
325  ap_uint<8> *toe_data_drop_cnt_in,
326  ap_uint<8> *toe_crc_drop_cnt_in,
327  ap_uint<8> *toe_sess_drop_cnt_in,
328  ap_uint<8> *toe_ooo_drop_cnt_in,
329  //HWICAP and DECOUPLING
330  ap_uint<32> *HWICAP, ap_uint<1> decoupStatus, ap_uint<1> *setDecoup,
331  // Soft Reset
332  ap_uint<1> *setSoftReset,
333  //XMEM
334  ap_uint<32> xmem[XMEM_SIZE],
335  //NRC
336  ap_uint<32> nalCtrl[NAL_CTRL_LINK_SIZE],
337  ap_uint<1> *disable_ctrl_link,
338  stream<TcpWord> &siNAL_Tcp_data,
339  stream<AppMeta> &siNAL_Tcp_SessId,
340  stream<TcpWord> &soNAL_Tcp_data,
341  stream<AppMeta> &soNAL_Tcp_SessId,
342 #ifdef INCLUDE_PYROLINK
343  //Pyrolink
344  stream<Axis<8> > &soPYROLINK,
345  stream<Axis<8> > &siPYROLINK,
346  ap_uint<1> *disable_pyro_link,
347 #endif
348  //TO ROLE
349  ap_uint<32> *role_rank, ap_uint<32> *cluster_size);
350 
351 
352 #endif
353 
354 
#define OUT_BUFFER_SIZE
Definition: fmc.hpp:133
ap_uint< 1 > nts_ready
Definition: tb_fmc.cpp:69
uint8_t bufferOut[1024]
Definition: fmc.cpp:59
uint16_t bufferOutContentLength
Definition: fmc.cpp:61
ap_uint< 1 > layer_7_enabled
Definition: tb_fmc.cpp:68
ap_uint< 1 > disable_pyro_link
Definition: tb_fmc.cpp:92
uint32_t bufferInPtrWrite
Definition: fmc.cpp:53
#define XMEM_SIZE
Definition: fmc.hpp:124
ap_uint< 1 > disable_ctrl_link
Definition: tb_fmc.cpp:91
void emptyInBuffer()
Definition: fmc.cpp:217
void setRank(ap_uint< 32 > newRank)
Definition: fmc.cpp:451
uint8_t httpState
Definition: fmc.cpp:72
ap_uint< 32 > xmem[(32 *16)]
Definition: tb_fmc.cpp:89
ap_uint< 1 > layer_4_enabled
Definition: tb_fmc.cpp:66
void fmc(ap_uint< 32 > *MMIO_in, ap_uint< 32 > *MMIO_out, ap_uint< 1 > *layer_4_enabled, ap_uint< 1 > *layer_6_enabled, ap_uint< 1 > *layer_7_enabled, ap_uint< 1 > *nts_ready, ap_uint< 32 > *in_time_seconds, ap_uint< 32 > *in_time_minutes, ap_uint< 32 > *in_time_hours, ap_uint< 16 > *role_mmio_in, ap_uint< 16 > *uoe_drop_cnt_in, ap_uint< 8 > *toe_notif_drop_cnt_in, ap_uint< 8 > *toe_meta_drop_cnt_in, ap_uint< 8 > *toe_data_drop_cnt_in, ap_uint< 8 > *toe_crc_drop_cnt_in, ap_uint< 8 > *toe_sess_drop_cnt_in, ap_uint< 8 > *toe_ooo_drop_cnt_in, ap_uint< 32 > *HWICAP, ap_uint< 1 > decoupStatus, ap_uint< 1 > *setDecoup, ap_uint< 1 > *setSoftReset, ap_uint< 32 > xmem[(32 *16)], ap_uint< 32 > nalCtrl[(0x3ff/4)], ap_uint< 1 > *disable_ctrl_link, stream< TcpWord > &siNAL_Tcp_data, stream< AppMeta > &siNAL_Tcp_SessId, stream< TcpWord > &soNAL_Tcp_data, stream< AppMeta > &soNAL_Tcp_SessId, ap_uint< 32 > *role_rank, ap_uint< 32 > *cluster_size)
Definition: fmc.cpp:564
uint32_t sequential_hwicap_address
Definition: fmc.cpp:68
#define IN_BUFFER_SIZE
Definition: fmc.hpp:131
ap_uint< 1 > layer_6_enabled
Definition: tb_fmc.cpp:67
uint16_t bufferOutPtrWrite
Definition: fmc.cpp:60
ap_uint< 1 > decoupStatus
Definition: tb_fmc.cpp:82
uint32_t writeDisplaysToOutBuffer()
Definition: fmc.cpp:270
ap_uint< 32 > MMIO_in
Definition: tb_fmc.cpp:63
uint32_t bufferInPtrNextRead
Definition: fmc.cpp:56
ap_uint< 32 > HWICAP[512]
Definition: tb_fmc.cpp:86
void setSize(ap_uint< 32 > newSize)
Definition: fmc.cpp:458
uint8_t bufferIn[4096]
Definition: fmc.cpp:52
void emptyOutBuffer()
Definition: fmc.cpp:255
#define HttpState
Definition: fmc.hpp:166
ap_uint< 32 > nalCtrl[(0x3ff/4)]
Definition: tb_fmc.cpp:90
bool use_sequential_hwicap
Definition: fmc.cpp:67
ap_uint< 32 > cluster_size
#define NAL_CTRL_LINK_SIZE
Definition: nal.hpp:82
: The HTTP parsing functions for the FMC.