cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
test_rx_engine.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2016 -- 2021 IBM Corporation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 
30 #ifndef _TEST_RX_ENGINE_H_
31 #define _TEST_RX_ENGINE_H_
32 
33 #include <ap_shift_reg.h>
34 #include <cstdio>
35 #include <iostream>
36 #include <fstream>
37 #include <map>
38 #include <set>
39 #include <string>
40 #include <unistd.h>
41 
42 #include "../../../../../NTS/nts_config.hpp"
43 #include "../../../../../NTS/nts_utils.hpp"
44 #include "../../../../../NTS/SimNtsUtils.hpp"
45 #include "../../../../../NTS/SimAppData.hpp"
46 #include "../../../../../NTS/SimIp4Packet.hpp"
47 #include "../../../../../NTS/toe/src/toe.hpp"
48 #include "../../../../../NTS/toe/src/toe_utils.hpp"
49 #include "../../../../../NTS/toe/test/dummy_memory/dummy_memory.hpp"
50 
51 //-- Emulate behavior of TOE with the following files
52 #include "../../../../toe/src/toe.hpp"
53 #include "../../../../toe/src/session_lookup_controller/session_lookup_controller.hpp"
54 #include "../../../../toe/src/state_table/state_table.hpp"
55 #include "../../../../toe/src/rx_sar_table/rx_sar_table.hpp"
56 #include "../../../../toe/src/tx_sar_table/tx_sar_table.hpp"
57 #include "../../../../toe/src/timers/timers.hpp"
58 #include "../../../../toe/src/event_engine/event_engine.hpp"
59 #include "../../../../toe/src/ack_delay/src/ack_delay.hpp"
60 #include "../../../../toe/src/port_table/port_table.hpp"
61 #include "../../../../toe/src/tx_engine/src/tx_engine.hpp"
62 #include "../../../../toe/src/tx_app_interface/tx_app_interface.hpp"
63 
64 //---------------------------------------------------------
65 //-- TESTBENCH GLOBAL DEFINES
66 // 'STARTUP_DELAY' is used to delay the start of the [TB] functions.
67 //---------------------------------------------------------
68 #define TB_STARTUP_DELAY (TOE_SIZEOF_LISTEN_PORT_TABLE)
69 #define TB_GRACE_TIME 2500 // Adds some cycles to drain the DUT before exiting
70 
71 //#define TB_MAX_SIM_CYCLES 2500000
72 //#define TB_MIN_SIM_CYCLES 1000
73 #define TB_STARTUP_TIME 25
74 
75 //---------------------------------------------------------
76 //-- DEFAULT LOCAL FPGA AND FOREIGN HOST SOCKETS
77 //-- By default, the following sockets will be used by the
78 //-- testbench, unless the user specifies new ones via the
79 //-- test vector files.
80 //---------------------------------------------------------
81 #define DEFAULT_FPGA_IP4_ADDR 0x0A0CC801 // TOE's local IP Address = 10.12.200.01
82 #define DEFAULT_FPGA_LSN_PORT 0x0057 // TOE listens on port = 87 (static ports must be 0..32767)
83 #define DEFAULT_FPGA_SND_PORT TOE_FIRST_EPHEMERAL_PORT_NUM // TOE's ephemeral port # = 32768
84 
85 #define DEFAULT_HOST_IP4_ADDR 0x0A0CC832 // TB's foreign IP Address = 10.12.200.50
86 #define DEFAULT_HOST_LSN_PORT 0x0058 // TB listens on port = 88
87 #define DEFAULT_HOST_SND_PORT 0x8058 // TB's ephemeral port # = 32856
88 
89 //---------------------------------------------------------
90 //-- TESTBENCH MODES OF OPERATION
91 //---------------------------------------------------------
92 enum TestingMode { RX_MODE='0', TX_MODE='1', BIDIR_MODE='2', ECHO_MODE='3' };
93 
94 //---------------------------------------------------------
95 //-- C/RTL LATENCIES AND INITIAL INTERVALS
96 //-- Use numbers >= to those of the 'CoSimulation Report'
97 //---------------------------------------------------------
98 #define APP_RSP_LATENCY 10 // [FIXME - "ipRx_TwentyPkt.dat" will fail if latency goes down to 5.
99 
100 #define MEM_RD_CMD_LATENCY 10
101 #define MEM_RD_DAT_LATENCY 10
102 #define MEM_RD_STS_LATENCY 10
103 
104 #define MEM_WR_CMD_LATENCY 10
105 #define MEM_WR_DAT_LATENCY 10
106 #define MEM_WR_STS_LATENCY 10
107 
108 #define CAM_LOOKUP_LATENCY 1
109 #define CAM_UPDATE_LATENCY 10
110 
111 #define RTT_LINK 25
112 
113 #define FPGA_CLIENT_CONNECT_TIMEOUT 250 // In clock cycles
114 
115 //---------------------------------------------------------
116 //-- TESTBENCH GLOBAL VARIABLES
117 //-- These variables might be updated/overwritten by the
118 //-- content of a test-vector file.
119 //---------------------------------------------------------
120 bool gTraceEvent = false;
121 bool gFatalError = false;
122 unsigned int gSimCycCnt = 0;
124 //unsigned int gMaxSimCycles = TB_MIN_SIM_CYCLES + TB_GRACE_TIME;
125 
126 Ip4Addr gFpgaIp4Addr = DEFAULT_FPGA_IP4_ADDR; // IPv4 address (in NETWORK BYTE ORDER)
129 Ip4Addr gHostIp4Addr = DEFAULT_HOST_IP4_ADDR; // IPv4 address (in NETWORK BYTE ORDER)
131 bool gSortTaifGold = false; // Do not sort soTAIF.gold file
132 
133 bool gTest_RcvdIp4Packet = true; // Check the received IPv4 packet
134 bool gTest_RcvdIp4TotLen = true; // Check the received IPv4-Total-Length field
135 bool gTest_RcvdIp4HdrCsum = true; // Check the received IPv4-Header-Checksum field
136 bool gTest_RcvdUdpLen = true; // Check the received UDP-Length field
137 bool gTest_RcvdLy4Csum = true; // Check the received TCP|UDP Layer-4-Checksum field
138 bool gTest_SentIp4TotLen = true; // Check the sent IPv4-Total-Length field
139 bool gTest_SentIp4HdrCsum = true; // Check the sent IPv4-Header-Checksum field
140 bool gTest_SentUdpLen = true; // Check the sent UDP-Length field
141 bool gTest_SentLy4Csum = true; // Check the sent TCP|UDP Layer-4-Checksum field
142 
143 #endif
144 
bool gTest_RcvdIp4Packet
TestingMode
#define DEFAULT_FPGA_LSN_PORT
#define TB_STARTUP_DELAY
#define DEFAULT_HOST_LSN_PORT
Ip4Addr gHostIp4Addr
#define TB_GRACE_TIME
TcpPort gFpgaLsnPort
bool gTest_RcvdLy4Csum
TcpPort gFpgaSndPort
bool gTest_SentIp4TotLen
bool gTest_SentIp4HdrCsum
unsigned int gMaxSimCycles
unsigned int gSimCycCnt
bool gTraceEvent
Ip4Addr gFpgaIp4Addr
bool gTest_SentLy4Csum
bool gFatalError
#define DEFAULT_HOST_IP4_ADDR
bool gTest_RcvdIp4HdrCsum
bool gTest_RcvdIp4TotLen
bool gSortTaifGold
#define DEFAULT_FPGA_IP4_ADDR
bool gTest_RcvdUdpLen
TcpPort gHostLsnPort
bool gTest_SentUdpLen
@ TX_MODE
@ BIDIR_MODE
@ ECHO_MODE
@ RX_MODE
#define TOE_FIRST_EPHEMERAL_PORT_NUM
Definition: toe.hpp:101
ap_uint< 32 > Ip4Addr
Definition: AxisIp4.hpp:169
ap_uint< 16 > TcpPort
Definition: AxisTcp.hpp:105