cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
test_tx_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_TX_ENGINE_H_
31 #define _TEST_TX_ENGINE_H_
32 
33 #include <cstdio>
34 #include <iostream>
35 #include <fstream>
36 #include <map>
37 #include <set>
38 #include <string>
39 #include <unistd.h>
40 
41 #include "../../../../../NTS/nts_config.hpp"
42 #include "../../../../../NTS/nts_utils.hpp"
43 #include "../../../../../NTS/SimNtsUtils.hpp"
44 #include "../../../../../NTS/SimAppData.hpp"
45 #include "../../../../../NTS/SimIp4Packet.hpp"
46 #include "../../../../../NTS/toe/src/toe.hpp"
47 #include "../../../../../NTS/toe/src/toe_utils.hpp"
48 #include "../../../../../NTS/toe/test/dummy_memory/dummy_memory.hpp"
49 
50 //-- Emulate behavior of TOE with the following files
51 #include "../../../../toe/src/toe.hpp"
52 #include "../../../../toe/src/session_lookup_controller/session_lookup_controller.hpp"
53 #include "../../../../toe/src/state_table/state_table.hpp"
54 #include "../../../../toe/src/rx_sar_table/rx_sar_table.hpp"
55 #include "../../../../toe/src/tx_sar_table/tx_sar_table.hpp"
56 #include "../../../../toe/src/timers/timers.hpp"
57 #include "../../../../toe/src/event_engine/event_engine.hpp"
58 #include "../../../../toe/src/ack_delay/src/ack_delay.hpp"
59 #include "../../../../toe/src/port_table/port_table.hpp"
60 #include "../../../../toe/src/rx_engine/src/rx_engine.hpp"
61 #include "../../../../toe/src/tx_app_interface/tx_app_interface.hpp"
62 
63 //---------------------------------------------------------
64 //-- TESTBENCH GLOBAL DEFINES
65 // 'STARTUP_DELAY' is used to delay the start of the [TB] functions.
66 //---------------------------------------------------------
67 #define TB_STARTUP_DELAY (TOE_SIZEOF_LISTEN_PORT_TABLE)
68 #define TB_GRACE_TIME 2500 // Adds some cycles to drain the DUT before exiting
69 
70 //#define TB_MAX_SIM_CYCLES 2500000
71 //#define TB_MIN_SIM_CYCLES 1000
72 #define TB_STARTUP_TIME 25
73 
74 //---------------------------------------------------------
75 //-- DEFAULT LOCAL FPGA AND FOREIGN HOST SOCKETS
76 //-- By default, the following sockets will be used by the
77 //-- testbench, unless the user specifies new ones via the
78 //-- test vector files.
79 //---------------------------------------------------------
80 #define DEFAULT_FPGA_IP4_ADDR 0x0A0CC801 // TOE's local IP Address = 10.12.200.01
81 #define DEFAULT_FPGA_LSN_PORT 0x0057 // TOE listens on port = 87 (static ports must be 0..32767)
82 #define DEFAULT_FPGA_SND_PORT TOE_FIRST_EPHEMERAL_PORT_NUM // TOE's ephemeral port # = 32768
83 
84 #define DEFAULT_HOST_IP4_ADDR 0x0A0CC832 // TB's foreign IP Address = 10.12.200.50
85 #define DEFAULT_HOST_LSN_PORT 0x0058 // TB listens on port = 88
86 #define DEFAULT_HOST_SND_PORT 0x8058 // TB's ephemeral port # = 32856
87 
88 //---------------------------------------------------------
89 //-- TESTBENCH MODES OF OPERATION
90 //---------------------------------------------------------
91 enum TestingMode { RX_MODE='0', TX_MODE='1', BIDIR_MODE='2', ECHO_MODE='3' };
92 
93 //---------------------------------------------------------
94 //-- C/RTL LATENCIES AND INITIAL INTERVALS
95 //-- Use numbers >= to those of the 'CoSimulation Report'
96 //---------------------------------------------------------
97 #define APP_RSP_LATENCY 10 // [FIXME - "ipRx_TwentyPkt.dat" will fail if latency goes down to 5.
98 
99 #define MEM_RD_CMD_LATENCY 10
100 #define MEM_RD_DAT_LATENCY 10
101 #define MEM_RD_STS_LATENCY 10
102 
103 #define MEM_WR_CMD_LATENCY 10
104 #define MEM_WR_DAT_LATENCY 10
105 #define MEM_WR_STS_LATENCY 10
106 
107 #define CAM_LOOKUP_LATENCY 1
108 #define CAM_UPDATE_LATENCY 10
109 
110 #define RTT_LINK 25
111 
112 #define FPGA_CLIENT_CONNECT_TIMEOUT 250 // In clock cycles
113 
114 //---------------------------------------------------------
115 //-- TESTBENCH GLOBAL VARIABLES
116 //-- These variables might be updated/overwritten by the
117 //-- content of a test-vector file.
118 //---------------------------------------------------------
119 bool gTraceEvent = false;
120 bool gFatalError = false;
121 unsigned int gSimCycCnt = 0;
123 //unsigned int gMaxSimCycles = TB_MIN_SIM_CYCLES + TB_GRACE_TIME;
124 
125 Ip4Addr gFpgaIp4Addr = DEFAULT_FPGA_IP4_ADDR; // IPv4 address (in NETWORK BYTE ORDER)
128 Ip4Addr gHostIp4Addr = DEFAULT_HOST_IP4_ADDR; // IPv4 address (in NETWORK BYTE ORDER)
130 bool gSortTaifGold = false; // Do not sort soTAIF.gold file
131 
132 bool gTest_RcvdIp4Packet = true; // Check the received IPv4 packet
133 bool gTest_RcvdIp4TotLen = true; // Check the received IPv4-Total-Length field
134 bool gTest_RcvdIp4HdrCsum = true; // Check the received IPv4-Header-Checksum field
135 bool gTest_RcvdUdpLen = true; // Check the received UDP-Length field
136 bool gTest_RcvdLy4Csum = true; // Check the received TCP|UDP Layer-4-Checksum field
137 bool gTest_SentIp4TotLen = true; // Check the sent IPv4-Total-Length field
138 bool gTest_SentIp4HdrCsum = true; // Check the sent IPv4-Header-Checksum field
139 bool gTest_SentUdpLen = true; // Check the sent UDP-Length field
140 bool gTest_SentLy4Csum = true; // Check the sent TCP|UDP Layer-4-Checksum field
141 
142 #endif
143 
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