39 #define THIS_NAME "TB"
41 #define TRACE_OFF 0x0000
42 #define TRACE_CAM 1 << 1
43 #define TRACE_IPRX 1 << 2
44 #define TRACE_IPTX 1 << 3
45 #define TRACE_MAIN 1 << 4
46 #define TRACE_RXMEM 1 << 5
47 #define TRACE_TAIF 1 << 6
48 #define TRACE_TAr 1 << 7
49 #define TRACE_TAs 1 << 8
50 #define TRACE_Tac 1 << 9
51 #define TRACE_Tae 1 << 10
52 #define TRACE_Tal 1 << 11
53 #define TRACE_TXMEM 1 << 12
54 #define TRACE_ALL 0xFFFF
55 #define DEBUG_LEVEL (TRACE_OFF)
108 while (!(ss.empty())) {
109 ss.read(currDropCount);
110 if (currDropCount != prevDropCount) {
111 printWarn(myName,
"Detected a drop event on stream '%s' (currDropCounter=%d). \n",
112 ssName.c_str(), currDropCount.to_ushort());
115 prevDropCount = currDropCount;
129 stream<CamSessionLookupRequest> &siTOE_SssLkpReq,
130 stream<CamSessionLookupReply> &soTOE_SssLkpRep,
131 stream<CamSessionUpdateRequest> &siTOE_SssUpdReq,
132 stream<CamSessionUpdateReply> &soTOE_SssUpdRep)
136 static map<FourTuple, ap_uint<14> > cam_lookupTable;
138 static enum FsmStates { CAM_WAIT_4_REQ=0,
139 CAM_LOOKUP_REP, CAM_UPDATE_REP } cam_fsmState=CAM_WAIT_4_REQ;
143 static int cam_updateIdleCnt = 0;
144 volatile static int cam_lookupIdleCnt = 0;
146 map<FourTuple, ap_uint<14> >::const_iterator findPos;
151 switch (cam_fsmState) {
153 if (!siTOE_SssLkpReq.empty()) {
154 siTOE_SssLkpReq.read(cam_request);
156 cam_fsmState = CAM_LOOKUP_REP;
158 printInfo(myName,
"Received a session lookup request from [%s] for socket pair: \n",
163 else if (!siTOE_SssUpdReq.empty()) {
164 siTOE_SssUpdReq.read(cam_update);
166 cam_fsmState = CAM_UPDATE_REP;
168 printInfo(myName,
"Received a session update request from [%s] for socket pair: \n",
176 if (cam_lookupIdleCnt > 0) {
180 findPos = cam_lookupTable.find(cam_request.
key);
181 if (findPos != cam_lookupTable.end()) {
184 printInfo(myName,
"Result of session lookup = HIT \n");
190 printInfo(myName,
"Result of session lookup = NO-HIT\n");
193 cam_fsmState = CAM_WAIT_4_REQ;
198 if (cam_updateIdleCnt > 0) {
205 cam_lookupTable[cam_update.
key] = cam_update.
value;
208 printInfo(myName,
"Successful insertion of session ID #%d for [%s].\n", cam_update.
value.to_int(),
213 cam_lookupTable.erase(cam_update.
key);
216 printInfo(myName,
"Successful deletion of session ID #%d for [%s].\n", cam_update.
value.to_int(),
220 cam_fsmState = CAM_WAIT_4_REQ;
241 stream<DmCmd> &siTOE_RxP_WrCmd,
242 stream<AxisApp> &siTOE_RxP_Data,
243 stream<DmSts> &soTOE_RxP_WrSts,
244 stream<DmCmd> &siTOE_RxP_RdCmd,
245 stream<AxisApp> &soTOE_RxP_Data)
250 static int rxmem_wrCounter = 0;
251 static int rxmem_rdCounter = 0;
252 static int rxmem_noBytesToWrite = 0;
253 static int rxmem_noBytesToRead = 0;
254 static int rxmem_rdIdleCnt = 0;
255 static int rxmem_wrIdleCnt = 0;
256 static DmCmd rxmem_dmCmd;
258 static enum WrStates { WAIT_4_WR_CMD, MWR_DATA, MWR_STS } rxmem_WrState;
259 static enum RdStates { WAIT_4_RD_CMD, MRD_DATA, MRD_STS } rxmem_RdState;
272 switch (rxmem_WrState) {
274 if (!siTOE_RxP_WrCmd.empty()) {
276 siTOE_RxP_WrCmd.read(rxmem_dmCmd);
278 printInfo(myName,
"Received memory write command from TOE: (addr=0x%llx, btt=%d).\n",
279 rxmem_dmCmd.
saddr.to_uint64(), rxmem_dmCmd.
btt.to_uint());
282 rxmem_noBytesToWrite = rxmem_dmCmd.
btt.to_int();
285 rxmem_WrState = MWR_DATA;
289 if (rxmem_wrIdleCnt > 0) {
293 else if (!siTOE_RxP_Data.empty()) {
295 siTOE_RxP_Data.read(tmpInChunk);
296 inChunk = tmpInChunk;
298 rxmem_wrCounter += inChunk.
getLen();
299 if (inChunk.
getTLast() or (rxmem_wrCounter == rxmem_noBytesToWrite)) {
301 rxmem_WrState = MWR_STS;
306 if (rxmem_wrIdleCnt > 0) {
310 else if (!soTOE_RxP_WrSts.full()) {
312 if (rxmem_noBytesToWrite != rxmem_wrCounter) {
313 printError(myName,
"The number of bytes received from TOE (%d) does not match the expected number specified by the command (%d)!\n",
314 rxmem_wrCounter, rxmem_noBytesToWrite);
321 soTOE_RxP_WrSts.write(dmSts);
324 printInfo(myName,
"Sending memory status back to TOE: (OK=%d).\n",
325 dmSts.
okay.to_int());
327 rxmem_WrState = WAIT_4_WR_CMD;
335 switch (rxmem_RdState) {
337 if (!siTOE_RxP_RdCmd.empty()) {
339 siTOE_RxP_RdCmd.read(rxmem_dmCmd);
341 printInfo(myName,
"Received memory read command from TOE: (addr=0x%llx, btt=%d).\n",
342 rxmem_dmCmd.
saddr.to_uint64(), rxmem_dmCmd.
btt.to_uint());
345 rxmem_noBytesToRead = rxmem_dmCmd.
btt.to_int();
348 rxmem_RdState = MRD_DATA;
352 if (rxmem_rdIdleCnt > 0) {
356 else if (!soTOE_RxP_Data.full()) {
359 outChunk = tmpOutChunk;
360 rxmem_rdCounter += outChunk.
getLen();
361 soTOE_RxP_Data.write(outChunk);
362 if ((outChunk.
getTLast()) or (rxmem_rdCounter == rxmem_noBytesToRead)) {
364 rxmem_RdState = MRD_STS;
369 if (rxmem_wrIdleCnt > 0) {
374 rxmem_RdState = WAIT_4_RD_CMD;
394 stream<DmCmd> &siTOE_TxP_WrCmd,
395 stream<AxisApp> &siTOE_TxP_Data,
396 stream<DmSts> &soTOE_TxP_WrSts,
397 stream<DmCmd> &siTOE_TxP_RdCmd,
398 stream<AxisApp> &soTOE_TxP_Data)
403 static int txmem_wrCounter = 0;
404 static int txmem_rdCounter = 0;
405 static int txmem_noBytesToWrite = 0;
406 static int txmem_noBytesToRead = 0;
407 static int txmem_wrIdleCnt = 0;
408 static int txmem_rdIdleCnt = 0;
409 static DmCmd txmem_dmCmd;
410 static enum WrStates { WAIT_4_WR_CMD, MWR_DATA, MWR_STS } txmem_WrState;
411 static enum RdStates { WAIT_4_RD_CMD, MRD_DATA, MRD_STS } txmem_RdState;
423 switch (txmem_WrState) {
425 if (!siTOE_TxP_WrCmd.empty()) {
427 siTOE_TxP_WrCmd.read(txmem_dmCmd);
429 printInfo(myName,
"Received memory write command from TOE: (addr=0x%llx, btt=%d).\n",
430 txmem_dmCmd.
saddr.to_uint64(), txmem_dmCmd.
btt.to_uint());
433 txmem_noBytesToWrite = txmem_dmCmd.
btt.to_int();
436 txmem_WrState = MWR_DATA;
440 if (txmem_wrIdleCnt > 0) {
444 else if (!siTOE_TxP_Data.empty()) {
446 siTOE_TxP_Data.read(tmpInChunk);
447 inChunk = tmpInChunk;
449 txmem_wrCounter += inChunk.
getLen();
450 if (inChunk.
getTLast() or (txmem_wrCounter == txmem_noBytesToWrite)) {
452 txmem_WrState = MWR_STS;
457 if (txmem_wrIdleCnt > 0) {
461 else if (!soTOE_TxP_WrSts.full()) {
463 if (txmem_noBytesToWrite != txmem_wrCounter) {
464 printError(myName,
"The number of bytes received from TOE (%d) does not match the expected number specified by the command (%d)!\n",
465 txmem_wrCounter, txmem_noBytesToWrite);
472 soTOE_TxP_WrSts.write(dmSts);
474 printInfo(myName,
"Sending memory status back to TOE: (OK=%d).\n",
475 dmSts.
okay.to_int());
477 txmem_WrState = WAIT_4_WR_CMD;
485 switch (txmem_RdState) {
487 if (!siTOE_TxP_RdCmd.empty()) {
489 siTOE_TxP_RdCmd.read(txmem_dmCmd);
491 printInfo(myName,
"Received memory read command from TOE: (addr=0x%llx, btt=%d).\n",
492 txmem_dmCmd.
saddr.to_uint64(), txmem_dmCmd.
btt.to_uint());
495 txmem_noBytesToRead = txmem_dmCmd.
btt.to_int();
498 txmem_RdState = MRD_DATA;
502 if (txmem_rdIdleCnt > 0) {
506 else if (!soTOE_TxP_Data.full()) {
509 outChunk = tmpOutChunk;
510 txmem_rdCounter += outChunk.
getLen();
511 soTOE_TxP_Data.write(outChunk);
512 if (outChunk.
getTLast() or (txmem_rdCounter == txmem_noBytesToRead)) {
514 txmem_RdState = MRD_STS;
520 if (txmem_rdIdleCnt > 0) {
525 txmem_RdState = WAIT_4_RD_CMD;
548 bool setGlobalParameters(
const char *callerName,
unsigned int startupDelay, ifstream &inputFile)
551 strcpy(myName, callerName);
552 strcat(myName,
"/setGlobalParameters");
554 string rxStringBuffer;
555 vector<string> stringVector;
559 getline(inputFile, rxStringBuffer);
562 if (stringVector[0] ==
"") {
565 else if (stringVector[0].length() == 1) {
567 if ((stringVector[0] ==
"G") and (stringVector[1] ==
"PARAM")) {
568 if (stringVector[2] ==
"SimCycles") {
570 int noSimCycles = atoi(stringVector[3].c_str());
571 noSimCycles += startupDelay;
579 else if (stringVector[2] ==
"FpgaIp4Addr") {
582 unsigned int ip4Addr;
586 ip4Addr = strtoul(stringVector[3].c_str(), &ptr, 16);
588 ip4Addr = strtoul(stringVector[3].c_str(), &ptr, 10);
590 printInfo(myName,
"Redefining the default FPGA IPv4 address to be: ");
593 else if (stringVector[2] ==
"FpgaLsnPort") {
596 unsigned int tcpPort;
598 tcpPort = strtoul(stringVector[3].c_str(), &ptr, 16);
600 tcpPort = strtoul(stringVector[3].c_str(), &ptr, 10);
602 printInfo(myName,
"Redefining the default FPGA listen port to be: ");
605 else if (stringVector[2] ==
"HostIp4Addr") {
608 unsigned int ip4Addr;
612 ip4Addr = strtoul(stringVector[3].c_str(), &ptr, 16);
614 ip4Addr = strtoul(stringVector[3].c_str(), &ptr, 10);
616 printInfo(myName,
"Redefining the default HOST IPv4 address to be: ");
619 else if (stringVector[2] ==
"HostLsnPort") {
622 unsigned int tcpPort;
624 tcpPort = strtoul(stringVector[3].c_str(), &ptr, 16);
626 tcpPort = strtoul(stringVector[3].c_str(), &ptr, 10);
628 printInfo(myName,
"Redefining the default HOST listen port to be: \n");
631 else if (stringVector[2] ==
"SortTaifGold") {
632 if (stringVector[3] ==
"true") {
634 printInfo(callerName,
"Requesting the 'soTAIF.gold' file to be sorted.\n");
638 printInfo(callerName,
"Disabling the sorting of the 'soTAIF.gold' file.\n");
641 else if (stringVector[2] ==
"FpgaServerSocket") {
642 printFatal(myName,
"The global parameter \'FpgaServerSockett\' is not supported anymore.\n\tPLEASE UPDATE YOUR TEST VECTOR FILE ACCORDINGLY.\n");
644 else if (stringVector[2] ==
"ForeignSocket") {
645 printFatal(myName,
"The global parameter \'ForeignSocket\' is not supported anymore.\n\tPLEASE UPDATE YOUR TEST VECTOR FILE ACCORDINGLY.\n");
648 else if (stringVector[2] ==
"LocalSocket") {
649 printFatal(myName,
"The global parameter \'LocalSocket\' is not supported anymore.\n\tPLEASE UPDATE YOUR TESTVECTOR FILE ACCORDINGLY.\n");
652 printError(myName,
"Unknown parameter \'%s\'.\n", stringVector[2].c_str());
659 }
while(!inputFile.eof());
662 printInfo(myName,
"Done with the parsing of the input test file.\n");
667 inputFile.seekg(0, ios::beg);
691 if (stringVector[2] ==
"HostIp4Addr") {
697 unsigned int ip4Addr;
701 ip4Addr = strtoul(stringVector[3].c_str(), &ptr, 16);
703 ip4Addr = strtoul(stringVector[3].c_str(), &ptr, 10);
705 printInfo(callerName,
"Setting the current HOST IPv4 address to be: \n");
708 else if (stringVector[2] ==
"HostLsnPort") {
714 unsigned int tcpPort;
716 tcpPort = strtoul(stringVector[3].c_str(), &ptr, 16);
718 tcpPort = strtoul(stringVector[3].c_str(), &ptr, 10);
720 printInfo(callerName,
"Setting the current HOST listen port to be: \n");
723 else if (stringVector[2] ==
"FpgaLsnPort") {
729 unsigned int tcpPort;
731 tcpPort = strtoul(stringVector[3].c_str(), &ptr, 16);
733 tcpPort = strtoul(stringVector[3].c_str(), &ptr, 10);
735 printInfo(callerName,
"Setting the current FPGA listen port to be: \n");
738 else if (stringVector[2] ==
"HostServerSocket") {
746 unsigned int ip4Addr;
750 ip4Addr = strtoul(stringVector[3].c_str(), &pEnd, 16);
752 ip4Addr = strtoul(stringVector[3].c_str(), &pEnd, 10);
755 unsigned int tcpPort;
757 tcpPort = strtoul(stringVector[4].c_str(), &pEnd, 16);
759 tcpPort = strtoul(stringVector[4].c_str(), &pEnd, 10);
762 printInfo(callerName,
"Setting current host server socket to be: \n");
789 if (stringVector[2] ==
"RcvdIp4Packet") {
790 if (stringVector[3] ==
"false") {
792 printWarn(callerName,
"Disabling receive IPv4 checker.\n");
796 printWarn(callerName,
"Enabling receive IPv4 checker.\n");
799 else if (stringVector[2] ==
"RcvdIp4TotLen") {
800 if (stringVector[3] ==
"false") {
802 printWarn(callerName,
"Disabling receive IPv4-Total-Length checker.\n");
806 printWarn(callerName,
"Enabling receive IPv4-Total_Length checker.\n");
809 else if (stringVector[2] ==
"RcvdIp4HdrCsum") {
810 if (stringVector[3] ==
"false") {
812 printWarn(callerName,
"Disabling receive IPv4-Header-Checksum checker.\n");
816 printWarn(callerName,
"Enabling receive IPv4-Header-Checksum checker.\n");
819 else if (stringVector[2] ==
"RcvdUdpLen") {
820 if (stringVector[3] ==
"false") {
822 printWarn(callerName,
"Disabling receive UDP-Length Checker.\n");
826 printWarn(callerName,
"Enabling receive IPv4-Header-Checksum checker.\n");
829 else if (stringVector[2] ==
"RcvdLy4Csum") {
830 if (stringVector[3] ==
"false") {
832 printWarn(callerName,
"Disabling receive TCP|UDP-Checksum checker.\n");
836 printWarn(callerName,
"Enabling receive TCP|UDP-Checksum checker.\n");
840 if (stringVector[2] ==
"SentIp4TotLen") {
841 if (stringVector[3] ==
"false") {
843 printWarn(callerName,
"Disabling send IPv4-Total-Length checker.\n");
847 printWarn(callerName,
"Enabling send IPv4-Total_Length checker.\n");
850 else if (stringVector[2] ==
"SentIp4HdrCsum") {
851 if (stringVector[3] ==
"false") {
853 printWarn(callerName,
"Disabling send IPv4-Header-Checksum checker.\n");
857 printWarn(callerName,
"Enabling send IPv4-Header-Checksum checker.\n");
860 else if (stringVector[2] ==
"SentUdpLen") {
861 if (stringVector[3] ==
"false") {
863 printWarn(callerName,
"Disabling send UDP-Length Checker.\n");
867 printWarn(callerName,
"Enabling send IPv4-Header-Checksum checker.\n");
870 else if (stringVector[2] ==
"SentLy4Csum") {
871 if (stringVector[3] ==
"false") {
873 printWarn(callerName,
"Disabling send TCP|UDP-Checksum checker.\n");
877 printWarn(callerName,
"Enabling send TCP|UDP-Checksum checker.\n");
895 map<SocketPair, TcpAckNum> &sessAckList)
905 if (ipRxPacket.
isSYN()) {
908 if (sessAckList.find(newSockPair) != sessAckList.end()) {
909 printWarn(myName,
"Trying to open an existing session !\n");
917 if (computedCsum != embeddedCsum) {
918 printError(myName,
"WRONG PSEUDO-HEADER CHECKSUM (0x%4.4X) - Expected 0x%4.4X \n",
919 embeddedCsum,
byteSwap16(computedCsum).to_uint());
924 sessAckList[newSockPair] = 0;
926 printInfo(myName,
"Successfully opened a new session for connection:\n");
933 else if (ipRxPacket.
isACK()) {
936 if (sessAckList.find(newSockPair) != sessAckList.end()) {
938 TcpAckNum newAckNum = sessAckList[newSockPair];
941 printInfo(myName,
"Setting the TCP Acknowledge of this segment to: %u (0x%8.8X) \n",
942 newAckNum.to_uint(),
byteSwap32(newAckNum).to_uint());
947 printInfo(myName,
"Updating the checksum of this packet from 0x%4.4X to 0x%4.4X\n",
953 printWarn(myName,
"Trying to send data to a non-existing session! \n");
977 deque<SimIp4Packet> &ipRxPacketizer,
979 stream<AxisIp4> &soTOE_Data,
980 map<SocketPair, TcpAckNum> &sessAckList)
984 if (ipRxPacketizer.size() != 0) {
990 ipRxPacketizer[0].printHdr(myName);
993 int noPackets= ipRxPacketizer.size();
994 for (
int p=0; p<noPackets; p++) {
999 if (not soTOE_Data.full()) {
1000 soTOE_Data.write(ip4Chunk);
1003 printFatal(myName,
"Cannot write \'soTOE_Data\'. Stream is full!\n");
1007 ipRxPacketizer.pop_front();
1040 ifstream &ifIPRX_Data,
1041 ofstream &ofTAIF_Gold,
1043 int &ipRxPktCounter,
1044 int &tcpBytCntr_IPRX_TOE,
1045 deque<SimIp4Packet> &ipRxPacketizer,
1046 map<SocketPair, TcpAckNum> &sessAckList,
1048 stream<AxisIp4> &soTOE_Data)
1053 static bool iprx_globParseDone =
false;
1054 static bool iprx_idlingReq =
false;
1055 static unsigned int iprx_idleCycReq = 0;
1056 static unsigned int iprx_idleCycCnt = 0;
1057 static unsigned int iprx_toeReadyDelay = 0;
1058 static int iprx_inpPackets = 0;
1061 string rxStringBuffer;
1062 vector<string> stringVector;
1067 if (piTOE_Ready == 0) {
1068 iprx_toeReadyDelay++;
1076 if (!iprx_globParseDone) {
1078 if (iprx_globParseDone ==
false) {
1079 printInfo(myName,
"Aborting testbench (check for previous error).\n");
1093 pIPRX_FeedTOE(ipRxPacketizer, ipRxPktCounter, soTOE_Data, sessAckList);
1098 if (iprx_idlingReq ==
true) {
1099 if (iprx_idleCycCnt >= iprx_idleCycReq) {
1100 iprx_idleCycCnt = 0;
1101 iprx_idlingReq =
false;
1112 if ((not testRxPath) || (ifIPRX_Data.eof()))
1128 getline(ifIPRX_Data, rxStringBuffer);
1130 if (stringVector[0] ==
"") {
1133 else if (stringVector[0].length() == 1) {
1139 if (stringVector[0] ==
"#") {
1142 for (
int t=0; t<stringVector.size(); t++) {
1143 printf(
"%s ", stringVector[t].c_str());
1149 else if (stringVector[0] ==
"G") {
1153 else if (stringVector[0] ==
">") {
1156 if (stringVector[1] ==
"IDLE") {
1158 iprx_idleCycReq = atoi(stringVector[2].c_str());
1159 iprx_idlingReq =
true;
1161 printInfo(myName,
"Request to idle for %d cycles. \n", iprx_idleCycReq);
1166 if (stringVector[1] ==
"SET") {
1170 if (stringVector[1] ==
"TEST") {
1175 printFatal(myName,
"Read unknown command \"> %s\".\n", stringVector[1].c_str());
1179 else if (ifIPRX_Data.fail() == 1 || rxStringBuffer.empty()) {
1185 bool firstChunkFlag =
true;
1188 if (firstChunkFlag ==
false) {
1189 getline(ifIPRX_Data, rxStringBuffer);
1192 if (stringVector[0] ==
"#") {
1195 for (
int t=0; t<stringVector.size(); t++) {
1196 printf(
"%s ", stringVector[t].c_str());
1202 firstChunkFlag =
false;
1208 }
while (not ipRxChunk.
getTLast());
1215 if (not wellFormed) {
1216 printFatal(myName,
"IP packet #%d is malformed!\n", iprx_inpPackets);
1226 ipRxPacketizer.push_back(ipRxPacket);
1227 pIPRX_FeedTOE(ipRxPacketizer, ipRxPktCounter, soTOE_Data, sessAckList);
1232 }
while(!ifIPRX_Data.eof());
1254 map<SocketPair, TcpAckNum> &sessAckList,
1255 deque<SimIp4Packet> &ipRxPacketizer)
1257 bool returnValue =
false;
1258 bool isFinAck =
false;
1259 bool isSynAck =
false;
1260 static int currAckNum = 0;
1268 if (ipTxPacket.
isSYN() and !ipTxPacket.
isACK()) {
1273 printInfo(myName,
"Got a SYN from TOE. Replying with a SYN+ACK.\n");
1276 synAckPacket.
clone(ipTxPacket);
1291 ipRxPacketizer.push_back(synAckPacket);
1293 else if (ipTxPacket.
isFIN() and !ipTxPacket.
isACK()) {
1306 printInfo(myName,
"Got a FIN from TOE. Closing the following connection:\n");
1310 sessAckList.erase(sockPair);
1312 else if (ipTxPacket.
isACK()) {
1330 if (ipTxPacket.
isFIN() and !ipTxPacket.
isSYN()) {
1334 printInfo(myName,
"Got a FIN+ACK from TOE.\n");
1336 else if (ipTxPacket.
isSYN() and !ipTxPacket.
isFIN()) {
1340 printInfo(myName,
"Got a SYN+ACK from TOE.\n");
1342 else if (ipTxPacket.
isFIN() and ipTxPacket.
isSYN()) {
1343 printError(myName,
"Got a SYN+FIN+ACK from TOE.\n");
1346 else if (ip4PktLen >= 40) {
1351 nextAckNum += ip4PktLen;
1355 sessAckList[sockPair] = nextAckNum;
1356 if (ipTxPacket.
isFIN()) {
1362 printInfo(myName,
"Got an ACK+FIN from TOE.\n");
1364 int itemsErased = sessAckList.erase(sockPair);
1365 if (itemsErased != 1) {
1366 printError(myName,
"Received a ACK+FIN segment for a non-existing session. \n");
1372 printInfo(myName,
"Connection was successfully closed.\n");
1377 if (ip4PktLen > 0 and !isFinAck) {
1393 ackPacket.setTcpSequenceNumber(currAckNum);
1394 ackPacket.setTcpAcknowledgeNumber(nextAckNum);
1396 ackPacket.setTcpControlAck(1);
1397 ackPacket.setTcpControlFin(0);
1399 ackPacket.setTcpWindow(7777);
1401 int newTcpCsum = ackPacket.tcpRecalculateChecksum();
1402 ackPacket.setTcpChecksum(newTcpCsum);
1404 ipRxPacketizer.push_back(ackPacket);
1405 currAckNum = nextAckNum;
1436 stream<AxisIp4> &siTOE_Data,
1437 ofstream &ofIPTX_Data1,
1438 ofstream &ofIPTX_Data2,
1439 map<SocketPair, TcpAckNum> &sessAckList,
1440 int &pktCounter_TOE_IPTX,
1441 int &tcpBytCntr_TOE_IPTX,
1442 deque<SimIp4Packet> &ipRxPacketizer)
1454 uint16_t ipTxChunkCounter = 0;
1459 if (piTOE_Ready == 0) {
1463 if (!siTOE_Data.empty()) {
1474 siTOE_Data.read(ipTxChunk);
1492 printFatal(myName,
"IP packet #%d is malformed!\n", pktCounter_TOE_IPTX);
1494 if (
pIPTX_Parse(iptx_ipPacket, sessAckList, ipRxPacketizer) ==
true) {
1496 pktCounter_TOE_IPTX++;
1498 if (tcpPayloadSize) {
1499 tcpBytCntr_TOE_IPTX += tcpPayloadSize;
1505 ipTxChunkCounter = 0;
1506 iptx_ipPacket.
clear();
1535 set<TcpPort> &openedPorts,
1536 stream<TcpAppLsnReq> &soTOE_LsnReq,
1537 stream<TcpAppLsnRep> &siTOE_LsnRep)
1542 static ap_uint<1> tal_fsmState = 0;
1544 static int tal_watchDogTimer = 100;
1549 switch (tal_fsmState) {
1551 tal_portNum = lsnPortNum;
1552 soTOE_LsnReq.write(tal_portNum);
1554 printInfo(myName,
"Request to listen on port %d (0x%4.4X).\n",
1555 tal_portNum.to_uint(), tal_portNum.to_uint());
1557 tal_watchDogTimer = 100;
1561 tal_watchDogTimer--;
1562 if (!siTOE_LsnRep.empty()) {
1563 siTOE_LsnRep.read(
rc);
1566 openedPorts.insert(tal_portNum);
1568 printInfo(myName,
"TOE is now listening on port %d (0x%4.4X).\n",
1569 tal_portNum.to_uint(), tal_portNum.to_uint());
1573 printWarn(myName,
"TOE denied listening on port %d (0x%4.4X).\n",
1574 tal_portNum.to_uint(), tal_portNum.to_uint());
1579 if (tal_watchDogTimer == 0) {
1580 printError(myName,
"Timeout: Failed to listen on port %d (0x%4.4X).\n",
1581 tal_portNum.to_uint(), tal_portNum.to_uint());
1609 map<SocketPair, SessionId> &openSessList,
1610 stream<SockAddr> &soTOE_OpnReq,
1611 stream<TcpAppOpnRep> &siTOE_OpnRep)
1619 static set<TcpPort> tac_dynamicPorts;
1620 static int tac_fsmState = 0;
1627 switch (tac_fsmState) {
1630 if (tac_dynamicPorts.empty()) {
1631 aSocketPair.
src.
port = tac_ephemeralPortCounter;
1632 tac_ephemeralPortCounter++;
1636 aSocketPair.
src.
port = tac_ephemeralPortCounter;
1637 tac_ephemeralPortCounter++;
1638 }
while(tac_dynamicPorts.find(aSocketPair.
src.
port) != tac_dynamicPorts.end());
1640 soTOE_OpnReq.write(hostServerSocket);
1642 printInfo(myName,
"The FPGA client is requesting to connect to the following HOST socket: \n");
1650 tac_watchDogTimer--;
1651 if (!siTOE_OpnRep.empty()) {
1655 openSessList[aSocketPair] = appOpenRep.
sessId;
1657 printInfo(myName,
"Successfully opened a new active session (%d) for connection:\n", appOpenRep.
sessId.to_int());
1661 tac_dynamicPorts.insert(aSocketPair.
src.
port);
1663 if (tac_ephemeralPortCounter-0x8000 > TOE_MAX_SESSIONS) {
1664 printError(myName,
"Trying to open too many FPGA client sessions. Max. is %d.\n", TOE_MAX_SESSIONS);
1670 printError(myName,
"Failed to open a new active session (%d).\n", appOpenRep.
sessId.to_uint());
1678 if (tac_watchDogTimer == 0) {
1679 printError(myName,
"Timeout: Failed to open the following FPGA client session:\n");
1710 ofstream &ofIPTX_Gold2,
1712 stream<TcpAppData> &soTOE_Data,
1713 stream<TcpAppSndReq> &soTOE_SndReq,
1714 stream<TcpAppSndRep> &siTOE_SndRep,
1715 stream<TcpAppData> &siTAr_Data,
1716 stream<TcpAppSndReq> &siTAr_SndReq)
1721 static enum FsmStates { IDLE=0, START_OF_SEGMENT,
1722 CONTINUATION_OF_SEGMENT } tae_fsmState = IDLE;
1723 static int tae_mssCounter = 0;
1729 switch (tae_fsmState) {
1731 if ( !siTAr_SndReq.empty() and !soTOE_SndReq.full()) {
1733 siTAr_SndReq.read(appSndReq);
1734 soTOE_SndReq.write(appSndReq);
1735 tae_fsmState = START_OF_SEGMENT;
1738 case START_OF_SEGMENT:
1739 if (!siTOE_SndRep.empty()) {
1742 switch (appSndRep.
error) {
1744 tae_fsmState = CONTINUATION_OF_SEGMENT;
1747 printError(
THIS_NAME,
"Not enough space for writing %d bytes in the Tx buffer of session #%d. Available space is %d bytes.\n",
1750 tae_fsmState = IDLE;
1755 tae_fsmState = IDLE;
1760 tae_fsmState = IDLE;
1765 case CONTINUATION_OF_SEGMENT:
1766 if ( !siTAr_Data.empty() and !soTOE_Data.full()) {
1768 siTAr_Data.read(appChunk);
1769 soTOE_Data.write(appChunk);
1772 tae_fsmState = IDLE;
1801 ofstream &ofTAIF_Data,
1804 stream<TcpAppLsnReq> &soTOE_LsnReq,
1805 stream<TcpAppLsnRep> &siTOE_LsnRep,
1806 stream<TcpAppNotif> &siTOE_Notif,
1807 stream<TcpAppRdReq> &soTOE_DReq,
1808 stream<TcpAppData> &siTOE_Data,
1809 stream<TcpAppMeta> &siTOE_Meta,
1810 stream<TcpAppData> &soTAs_Data,
1811 stream<TcpAppSndReq> &soTAs_SndReq)
1816 static bool tar_idlingReq =
false;
1817 static unsigned int tar_idleCycReq = 0;
1818 static unsigned int tar_idleCycCnt = 0;
1819 static int tar_startupDelay = 0;
1820 static bool tar_dualTest =
false;
1821 static int tar_appRspIdle = 0;
1822 static ap_uint<32> tar_mAmount = 0;
1823 static set<TcpPort> tar_listeningPorts;
1825 static vector<SessionId> tar_txSessIdVector;
1826 static enum FsmStates { WAIT_NOTIF=0, SEND_DREQ,
1827 WAIT_SEG, CONSUME } tar_fsmState = WAIT_NOTIF;
1830 string rxStringBuffer;
1831 vector<string> stringVector;
1839 if (piTOE_Ready == 0) {
1847 if (tar_listeningPorts.find(
gFpgaLsnPort) == tar_listeningPorts.end()) {
1853 if (listenStatus ==
false) {
1862 switch (tar_fsmState) {
1864 if (!siTOE_Notif.empty()) {
1865 siTOE_Notif.read(tar_notification);
1867 printInfo(myName,
"Received data notification from TOE: (sessId=%d, tcpDataLen=%d) and {IP_SA, TCP_DP} is:\n",
1872 tar_fsmState = SEND_DREQ;
1877 if (tar_appRspIdle > 0) {
1880 else if (!soTOE_DReq.full()) {
1884 tar_fsmState = WAIT_SEG;
1887 printWarn(myName,
"Received a data notification of length \'0\'. Please double check!!!\n");
1889 tar_fsmState = WAIT_NOTIF;
1896 if (!siTOE_Meta.empty()) {
1898 siTOE_Meta.read(tcpSessId);
1899 tar_fsmState = CONSUME;
1903 if (!siTOE_Meta.empty() and !soTAs_SndReq.full()) {
1904 siTOE_Meta.read(tcpSessId);
1906 tar_fsmState = CONSUME;
1910 printFatal(myName,
"Aborting testbench (The code should never end-up here).\n");
1917 if (!siTOE_Data.empty()) {
1918 siTOE_Data.read(currChunk);
1922 tar_fsmState = WAIT_NOTIF;
1926 if (!siTOE_Data.empty() and !soTAs_Data.full()) {
1927 siTOE_Data.read(currChunk);
1928 soTAs_Data.write(currChunk);
1932 tar_fsmState = WAIT_NOTIF;
1937 printFatal(myName,
"Aborting testbench (The code should never end-up here).\n");
1973 ifstream &ifTAIF_Data,
1974 ofstream &ofIPTX_Gold2,
1977 stream<TcpAppOpnReq> &soTOE_OpnReq,
1978 stream<TcpAppOpnRep> &siTOE_OpnRep,
1979 stream<TcpAppData> &soTOE_Data,
1980 stream<TcpAppSndReq> &soTOE_SndReq,
1981 stream<TcpAppSndRep> &siTOE_SndRep,
1982 stream<TcpAppClsReq> &soTOE_ClsReq,
1983 stream<TcpAppData> &siTAr_Data,
1984 stream<TcpAppSndReq> &siTAr_SndReq)
1989 static bool tas_globParseDone =
false;
1990 static bool tas_appTxIdlingReq =
false;
1991 static unsigned int tas_appTxIdleCycReq = 0;
1992 static unsigned int tas_appTxIdleCycCnt = 0;
1993 static unsigned int tas_toeReadyDelay = 0;
1994 static vector<SessionId> tas_txSessIdVector;
1995 static map<SocketPair, SessionId> tas_openSessList;
1996 static bool tas_clearToSend =
false;
2000 string rxStringBuffer;
2001 vector<string> stringVector;
2009 if (piTOE_Ready == 0) {
2010 tas_toeReadyDelay++;
2019 SocketPair currSocketPair(fpgaClientSocket, hostServerSocket);
2021 if (tas_openSessList.find(currSocketPair) == tas_openSessList.end()) {
2044 if (tas_appTxIdlingReq ==
true) {
2045 if (tas_appTxIdleCycCnt >= tas_appTxIdleCycReq) {
2046 tas_appTxIdleCycCnt = 0;
2047 tas_appTxIdlingReq =
false;
2049 printInfo(myName,
"End of APP Tx idling phase. \n");
2053 tas_appTxIdleCycCnt++;
2077 if (!siTOE_SndRep.empty()) {
2082 tas_clearToSend =
true;
2085 printFatal(myName,
"Attempt to write data for session %d which is not established.\n", appSndRep.
sessId.to_uint());
2089 printFatal(myName,
"There is not enough TxBuf memory space available for session %d.\n",
2090 appSndRep.
sessId.to_uint());
2094 printFatal(myName,
"Received unknown reply error (%d) from [TOE].\n",
rc);
2103 if (tas_simAppData.
size() and tas_clearToSend) {
2104 if (!soTOE_Data.full()) {
2109 soTOE_Data.write(appChunk);
2112 tas_clearToSend =
false;
2116 else if (tas_simAppData.
size() == 0) {
2120 while (!ifTAIF_Data.eof()) {
2122 getline(ifTAIF_Data, rxStringBuffer);
2125 if (stringVector[0] ==
"") {
2128 else if (stringVector[0].length() == 1) {
2134 if (stringVector[0] ==
"#") {
2138 else if (stringVector[0] ==
"G") {
2142 else if (stringVector[0] ==
">") {
2145 if (stringVector[1] ==
"IDLE") {
2147 tas_appTxIdleCycReq = strtol(stringVector[2].c_str(), &pEnd, 10);
2148 tas_appTxIdlingReq =
true;
2150 printInfo(myName,
"Request to idle for %d cycles. \n", tas_appTxIdleCycReq);
2155 if (stringVector[1] ==
"SET") {
2156 if (stringVector[2] ==
"HostIp4Addr") {
2160 unsigned int ip4Addr;
2164 ip4Addr = strtoul(stringVector[3].c_str(), &ptr, 16);
2166 ip4Addr = strtoul(stringVector[3].c_str(), &ptr, 10);
2168 printInfo(myName,
"Setting the current HOST IPv4 address to be: ");
2172 else if (stringVector[2] ==
"HostLsnPort") {
2176 unsigned int tcpPort;
2178 tcpPort = strtoul(stringVector[3].c_str(), &ptr, 16);
2180 tcpPort = strtoul(stringVector[3].c_str(), &ptr, 10);
2182 printInfo(myName,
"Setting the current HOST listen port to be: ");
2186 else if (stringVector[2] ==
"HostServerSocket") {
2192 unsigned int ip4Addr;
2196 ip4Addr = strtoul(stringVector[3].c_str(), &pEnd, 16);
2198 ip4Addr = strtoul(stringVector[3].c_str(), &pEnd, 10);
2201 unsigned int tcpPort;
2203 tcpPort = strtoul(stringVector[4].c_str(), &pEnd, 16);
2205 tcpPort = strtoul(stringVector[4].c_str(), &pEnd, 10);
2209 printInfo(myName,
"Setting current host server socket to be: \n");
2216 printFatal(myName,
"Read unknown command \"%s\" from TAIF.\n", stringVector[0].c_str());
2219 else if (ifTAIF_Data.fail() == 1 || rxStringBuffer.empty()) {
2222 else if (!tas_clearToSend) {
2225 bool firstChunkFlag =
true;
2226 int writtenBytes = 0;
2228 if (firstChunkFlag ==
false) {
2229 getline(ifTAIF_Data, rxStringBuffer);
2232 if (stringVector[0] ==
"#") {
2238 firstChunkFlag =
false;
2245 apRxBytCntr += writtenBytes;
2248 soTOE_SndReq.write(
TcpAppSndReq(tas_openSessList[currSocketPair], tas_simAppData.
length()));
2294 ifstream &ifTAIF_Data,
2295 ofstream &ofTAIF_Data,
2296 ofstream &ofIPTX_Gold2,
2301 stream<TcpAppLsnReq> &soTOE_LsnReq,
2302 stream<TcpAppLsnRep> &siTOE_LsnRep,
2303 stream<TcpAppNotif> &siTOE_Notif,
2304 stream<TcpAppRdReq> &soTOE_DReq,
2305 stream<TcpAppData> &siTOE_Data,
2306 stream<TcpAppMeta> &siTOE_Meta,
2308 stream<TcpAppOpnReq> &soTOE_OpnReq,
2309 stream<TcpAppOpnRep> &siTOE_OpnRep,
2310 stream<TcpAppData> &soTOE_Data,
2311 stream<TcpAppSndReq> &soTOE_SndReq,
2312 stream<TcpAppSndRep> &siTOE_SndRep,
2313 stream<TcpAppClsReq> &soTOE_ClsReq)
2319 static bool taif_globParseDone =
false;
2320 static unsigned int taif_toeReadyDelay = 0;
2325 static stream<TcpAppData> ssTArToTAs_Data (
"ssTArToTAs_Data");
2326 #pragma HLS STREAM variable=ssTArToTAs_Data depth=2048
2327 static stream<TcpAppSndReq> ssTArToTAs_SndReq (
"ssTArToTAs_SndReq");
2328 #pragma HLS STREAM variable=ssTArToTAs_SndReq depth=64
2333 if (piTOE_Ready == 0) {
2334 taif_toeReadyDelay++;
2342 if (!taif_globParseDone) {
2344 if (taif_globParseDone ==
false) {
2345 printFatal(myName,
"Aborting testbench (check for previous error).\n");
2385 #if HLS_VERSION != 2017
2440 stream<StsBit> &soMMIO_RxMemWrErr,
2441 stream<ap_uint<8> > &soMMIO_NotifDropCnt,
2442 stream<ap_uint<8> > &soMMIO_MetaDropCnt,
2443 stream<ap_uint<8> > &soMMIO_DataDropCnt,
2444 stream<ap_uint<8> > &soMMIO_CrcDropCnt,
2445 stream<ap_uint<8> > &soMMIO_SessDropCnt,
2446 stream<ap_uint<8> > &soMMIO_OooDropCnt,
2450 stream<AxisIp4> &siIPRX_Data,
2452 stream<AxisIp4> &soIPTX_Data,
2454 stream<TcpAppNotif> &soTAIF_Notif,
2455 stream<TcpAppRdReq> &siTAIF_DReq,
2456 stream<TcpAppData> &soTAIF_Data,
2457 stream<TcpAppMeta> &soTAIF_Meta,
2459 stream<TcpAppLsnReq> &siTAIF_LsnReq,
2460 stream<TcpAppLsnRep> &soTAIF_LsnRep,
2462 stream<TcpAppData> &siTAIF_Data,
2463 stream<TcpAppSndReq> &siTAIF_SndReq,
2464 stream<TcpAppSndRep> &soTAIF_SndRep,
2466 stream<TcpAppOpnReq> &siTAIF_OpnReq,
2467 stream<TcpAppOpnRep> &soTAIF_OpnRep,
2469 stream<TcpAppClsReq> &siTAIF_ClsReq,
2473 stream<DmCmd> &soMEM_RxP_RdCmd,
2474 stream<AxisApp> &siMEM_RxP_Data,
2475 stream<DmSts> &siMEM_RxP_WrSts,
2476 stream<DmCmd> &soMEM_RxP_WrCmd,
2477 stream<AxisApp> &soMEM_RxP_Data,
2480 stream<DmCmd> &soMEM_TxP_RdCmd,
2481 stream<AxisApp> &siMEM_TxP_Data,
2482 stream<DmSts> &siMEM_TxP_WrSts,
2483 stream<DmCmd> &soMEM_TxP_WrCmd,
2484 stream<AxisApp> &soMEM_TxP_Data,
2486 stream<CamSessionLookupRequest> &soCAM_SssLkpReq,
2487 stream<CamSessionLookupReply> &siCAM_SssLkpRep,
2488 stream<CamSessionUpdateRequest> &soCAM_SssUpdReq,
2489 stream<CamSessionUpdateReply> &siCAM_SssUpdRep,
2492 stream<ap_uint<16> > &soDBG_SssRelCnt,
2493 stream<ap_uint<16> > &soDBG_SssRegCnt,
2495 stream<RxBufPtr> &soDBG_RxFreeSpace,
2496 stream<ap_uint<32> > &soDBG_TcpIpRxByteCnt,
2497 stream<ap_uint< 8> > &soDBG_OooDebug
2500 ap_uint<32> &poSimCycCount
2505 static stream<AxisRaw> ssiIPRX_Data (
"ssiIPRX_Data");
2506 static stream<AxisRaw> ssoIPTX_Data (
"ssoIPTX_Data");
2516 soMMIO_NotifDropCnt,
2567 soDBG_TcpIpRxByteCnt,
2600 int main(
int argc,
char *argv[]) {
2616 stream<AxisIp4> ssIPRX_TOE_Data (
"ssIPRX_TOE_Data");
2618 stream<AxisIp4> ssTOE_IPTX_Data (
"ssTOE_IPTX_Data");
2620 stream<TcpAppData> ssTAIF_TOE_Data (
"ssTAIF_TOE_Data");
2621 stream<TcpAppSndReq> ssTAIF_TOE_SndReq (
"ssTAIF_TOE_SndReq");
2622 stream<TcpAppSndRep> ssTOE_TAIF_SndRep (
"ssTOE_TAIF_SndRep");
2624 stream<TcpAppRdReq> ssTAIF_TOE_DReq (
"ssTAIF_TOE_DReq");
2625 stream<TcpAppData> ssTOE_TAIF_Data (
"ssTOE_TAIF_Data");
2626 stream<TcpAppMeta> ssTOE_TAIF_Meta (
"ssTOE_TAIF_Meta");
2628 stream<TcpAppLsnReq> ssTAIF_TOE_LsnReq (
"ssTAIF_TOE_LsnReq");
2629 stream<TcpAppLsnRep> ssTOE_TAIF_LsnRep (
"ssTOE_TAIF_LsnRep");
2631 stream<TcpAppOpnReq> ssTAIF_TOE_OpnReq (
"ssTAIF_TOE_OpnReq");
2632 stream<TcpAppOpnRep> ssTOE_TAIF_OpnRep (
"ssTOE_TAIF_OpnRep");
2634 stream<TcpAppNotif> ssTOE_TAIF_Notif (
"ssTOE_TAIF_Notif");
2636 stream<TcpAppClsReq> ssTAIF_TOE_ClsReq (
"ssTAIF_TOE_ClsReq");
2638 stream<DmCmd> ssTOE_MEM_RxP_RdCmd (
"ssTOE_MEM_RxP_RdCmd");
2639 stream<AxisApp> ssMEM_TOE_RxP_Data (
"ssMEM_TOE_RxP_Data");
2640 stream<DmSts> ssMEM_TOE_RxP_WrSts (
"ssMEM_TOE_RxP_WrSts");
2641 stream<DmCmd> ssTOE_MEM_RxP_WrCmd (
"ssTOE_MEM_RxP_WrCmd");
2642 stream<AxisApp> ssTOE_MEM_RxP_Data (
"ssTOE_MEM_RxP_Data");
2644 stream<DmCmd> ssTOE_MEM_TxP_RdCmd (
"ssTOE_MEM_TxP_RdCmd");
2645 stream<AxisApp> ssMEM_TOE_TxP_Data (
"ssMEM_TOE_TxP_Data");
2646 stream<DmSts> ssMEM_TOE_TxP_WrSts (
"ssMEM_TOE_TxP_WrSts");
2647 stream<DmCmd> ssTOE_MEM_TxP_WrCmd (
"ssTOE_MEM_TxP_WrCmd");
2648 stream<AxisApp> ssTOE_MEM_TxP_Data (
"ssTOE_MEM_TxP_Data");
2650 stream<CamSessionLookupRequest> ssTOE_CAM_SssLkpReq (
"ssTOE_CAM_SssLkpReq");
2651 stream<CamSessionLookupReply> ssCAM_TOE_SssLkpRep (
"ssCAM_TOE_SssLkpRep");
2652 stream<CamSessionUpdateRequest> ssTOE_CAM_SssUpdReq (
"ssTOE_CAM_SssUpdReq");
2653 stream<CamSessionUpdateReply> ssCAM_TOE_SssUpdRep (
"ssCAM_TOE_SssUpdRep");
2655 stream<StsBit> ssTOE_MMIO_RxMemWrErr (
"ssTOE_MMIO_RxMemWrErr");
2656 stream<ap_uint<8> > ssTOE_MMIO_NotifDropCnt (
"ssTOE_MMIO_NotifDropCnt");
2657 stream<ap_uint<8> > ssTOE_MMIO_MetaDropCnt (
"ssTOE_MMIO_MetaDropCnt");
2658 stream<ap_uint<8> > ssTOE_MMIO_DataDropCnt (
"ssTOE_MMIO_DataDropCnt");
2659 stream<ap_uint<8> > ssTOE_MMIO_CrcDropCnt (
"ssTOE_MMIO_CrcDropCnt");
2660 stream<ap_uint<8> > ssTOE_MMIO_SessDropCnt (
"ssTOE_MMIO_SessDropCnt");
2661 stream<ap_uint<8> > ssTOE_MMIO_OooDropCnt (
"ssTOE_MMIO_OooDropCnt");
2663 stream<ap_uint<16> > ssTOE_OpnSessCount (
"ssTOE_OpnSessCount");
2664 stream<ap_uint<16> > ssTOE_ClsSessCount (
"ssTOE_ClsSessCount");
2665 stream<RxBufPtr> ssTOE_RxFreeSpace (
"ssTOE_RxFreeSpace");
2666 stream<ap_uint<32> > ssTOE_TcpIprxByteCnt (
"ssTOE_TcpIprxByteCnt");
2667 stream<ap_uint< 8> > ssTOE_OooDebugState (
"ssTOE_OooDebugState");
2676 #if TOE_FEATURE_USED_FOR_DEBUGGING
2677 ap_uint<32> sTOE_TB_SimCycCnt;
2683 ap_uint<16> nrOpenedSessions;
2684 ap_uint<16> nrClosedSessions;
2685 ap_uint<32> nrTcpIprxBytes;
2690 map<SocketPair, TcpAckNum> sessAckList;
2691 map<SocketPair, TcpSeqNum> sessSeqList;
2694 deque<SimIp4Packet> ipRxPacketizer;
2699 ifstream ifIPRX_Data;
2700 ifstream ifTAIF_Data;
2702 ofstream ofTAIF_Data;
2703 ofstream ofTAIF_Gold;
2704 ofstream ofIPTX_Data1;
2705 ofstream ofIPTX_Gold1;
2706 ofstream ofIPTX_Data2;
2707 ofstream ofIPTX_Gold2;
2709 const char *ofTAIF_DataName =
"../../../../test/simOutFiles/soTAIF.strm";
2710 const char *ofTAIF_GoldName =
"../../../../test/simOutFiles/soTAIF.gold";
2711 const char *ofIPTX_Data1Name =
"../../../../test/simOutFiles/soIPTX.dat";
2712 const char *ofIPTX_Gold1Name =
"../../../../test/simOutFiles/soIPTX.gold";
2713 const char *ofIPTX_Data2Name =
"../../../../test/simOutFiles/soIPTX_TcpData.strm";
2714 const char *ofIPTX_Gold2Name =
"../../../../test/simOutFiles/soIPTX_TcpData.gold";
2716 string dataString, keepString;
2720 int pktCounter_IPRX_TOE = 0;
2721 int tcpBytCntr_IPRX_TOE = 0;
2723 int pktCounter_TOE_IPTX = 0;
2724 int tcpBytCntr_TOE_IPTX = 0;
2726 int tcpBytCnt_APP_TOE = 0;
2727 int tcpBytCnt_TOE_APP = 0;
2729 bool testRxPath =
false;
2730 bool testTxPath =
false;
2734 char mode = *argv[1];
2735 char cCurrPath[FILENAME_MAX];
2740 remove(ofTAIF_DataName);
2741 ofTAIF_Data.open(ofTAIF_DataName);
2743 printError(
THIS_NAME,
"Cannot open the Application Tx file: \n\t %s \n", ofTAIF_DataName);
2746 remove(ofTAIF_GoldName);
2747 ofTAIF_Gold.open(ofTAIF_GoldName);
2749 printInfo(
THIS_NAME,
"Cannot open the Application Tx gold file: \n\t %s \n", ofTAIF_GoldName);
2752 remove(ofIPTX_Data1Name);
2753 ofIPTX_Data1.open(ofIPTX_Data1Name);
2754 if (!ofIPTX_Data1) {
2758 remove(ofIPTX_Data2Name);
2759 ofIPTX_Data2.open(ofIPTX_Data2Name);
2760 if (!ofIPTX_Data2) {
2764 remove(ofIPTX_Gold2Name);
2765 ofIPTX_Gold1.open(ofIPTX_Gold1Name);
2766 if (!ofIPTX_Gold1) {
2770 remove(ofIPTX_Gold2Name);
2771 ofIPTX_Gold2.open(ofIPTX_Gold2Name);
2772 if (!ofIPTX_Gold2) {
2777 printInfo(
THIS_NAME,
"############################################################################\n");
2779 printInfo(
THIS_NAME,
"############################################################################\n");
2780 printInfo(
THIS_NAME,
"This testbench will be executed with the following parameters: \n");
2781 for (
int i=1; i<argc; i++) {
2792 printError(
THIS_NAME,
"Expected a minimum of 2 or 3 parameters with one of the following synopsis:\n \t\t mode(0|3) siIPRX_<TestName>\n \t\t mode(1) siTAIF_<TestName>\n \t\t mode(2) siIPRX_<TestName> siTAIF_<TestName>\n");
2803 ifIPRX_Data.open(argv[2]);
2806 if (!getcwd(cCurrPath,
sizeof(cCurrPath))) {
2809 printInfo (
THIS_NAME,
"\t (FYI - The current working directory is: \n\t %s) \n", cCurrPath);
2822 ifTAIF_Data.open(argv[2]);
2825 if (!getcwd(cCurrPath,
sizeof(cCurrPath))) {
2828 printInfo (
THIS_NAME,
"\t (FYI - The current working directory is: \n\t %s) \n", cCurrPath);
2834 ifTAIF_Data.open(argv[3]);
2837 if (!getcwd(cCurrPath,
sizeof(cCurrPath))) {
2840 printf (
"\t (FYI - The current working directory is: \n\t %s) \n", cCurrPath);
2855 pIPRX(ifIPRX_Data, ofTAIF_Gold,
2856 testRxPath, pktCounter_IPRX_TOE, tcpBytCntr_IPRX_TOE,
2857 ipRxPacketizer, sessAckList,
2858 sTOE_ReadyDly, ssIPRX_TOE_Data);
2863 #if HLS_VERSION == 2017
2870 ssTOE_MMIO_RxMemWrErr,
2871 ssTOE_MMIO_NotifDropCnt,
2872 ssTOE_MMIO_MetaDropCnt,
2873 ssTOE_MMIO_DataDropCnt,
2874 ssTOE_MMIO_CrcDropCnt,
2875 ssTOE_MMIO_SessDropCnt,
2876 ssTOE_MMIO_OooDropCnt,
2901 ssTOE_MEM_RxP_RdCmd,
2903 ssMEM_TOE_RxP_WrSts,
2904 ssTOE_MEM_RxP_WrCmd,
2907 ssTOE_MEM_TxP_RdCmd,
2909 ssMEM_TOE_TxP_WrSts,
2910 ssTOE_MEM_TxP_WrCmd,
2913 ssTOE_CAM_SssLkpReq,
2914 ssCAM_TOE_SssLkpRep,
2915 ssTOE_CAM_SssUpdReq,
2916 ssCAM_TOE_SssUpdRep,
2921 ssTOE_TcpIprxByteCnt,
2932 if (!ssTOE_ClsSessCount.empty()) {
2933 nrClosedSessions = ssTOE_ClsSessCount.read();
2935 if (!ssTOE_OpnSessCount.empty()) {
2936 nrOpenedSessions = ssTOE_OpnSessCount.read();
2938 if (!ssTOE_RxFreeSpace.empty()) {
2939 nrOpenedSessions = ssTOE_RxFreeSpace.read();
2941 if (!ssTOE_TcpIprxByteCnt.empty()) {
2942 nrTcpIprxBytes = ssTOE_TcpIprxByteCnt.read();
2944 if (!ssTOE_OooDebugState.empty()) {
2945 ssTOE_OooDebugState.read();
2951 if (sTOE_Ready == 1) {
2952 if (startUpDelay > 0) {
2955 if (startUpDelay == 0) {
2961 sTOE_ReadyDly = sTOE_Ready;
2968 if (sTOE_ReadyDly) {
2971 ssTOE_MEM_RxP_WrCmd, ssTOE_MEM_RxP_Data, ssMEM_TOE_RxP_WrSts,
2972 ssTOE_MEM_RxP_RdCmd, ssMEM_TOE_RxP_Data);
2976 ssTOE_MEM_TxP_WrCmd, ssTOE_MEM_TxP_Data, ssMEM_TOE_TxP_WrSts,
2977 ssTOE_MEM_TxP_RdCmd, ssMEM_TOE_TxP_Data);
2980 ssTOE_CAM_SssLkpReq, ssCAM_TOE_SssLkpRep,
2981 ssTOE_CAM_SssUpdReq, ssCAM_TOE_SssUpdRep);
2997 pktCounter_TOE_IPTX,
2998 tcpBytCntr_TOE_IPTX,
3032 #if TOE_FEATURE_USED_FOR_DEBUGGING
3036 printf(
"-- [@%4.4d] -----------------------------\n",
gSimCycCnt);
3050 printInfo(
THIS_NAME,
"############################################################################\n");
3052 printInfo(
THIS_NAME,
"############################################################################\n");
3071 ifIPRX_Data.close();
3072 ofTAIF_Data.close();
3073 ofTAIF_Gold.close();
3078 ifTAIF_Data.close();
3079 ofIPTX_Data1 << endl; ofIPTX_Data1.close();
3080 ofIPTX_Data2 << endl; ofIPTX_Data2.close();
3081 ofIPTX_Gold2 << endl; ofIPTX_Gold2.close();
3087 printInfo(
THIS_NAME,
"Number of sessions opened by TOE : %6d \n", nrOpenedSessions.to_uint());
3088 printInfo(
THIS_NAME,
"Number of sessions closed by TOE : %6d \n", nrClosedSessions.to_uint());
3090 printInfo(
THIS_NAME,
"Number of IP Packets from IPRX-to-TOE : %6d \n", pktCounter_IPRX_TOE);
3091 printInfo(
THIS_NAME,
"Number of IP Packets from TOE-to-IPTX : %6d \n", pktCounter_TOE_IPTX);
3093 printInfo(
THIS_NAME,
"Number of TCP Bytes from IPRX-to-TOE : %6d \n", tcpBytCntr_IPRX_TOE);
3094 printInfo(
THIS_NAME,
"Number of TCP Bytes from TOE-to-APP : %6d \n", tcpBytCnt_TOE_APP);
3096 printInfo(
THIS_NAME,
"Number of TCP Bytes from APP-to-TOE : %6d \n", tcpBytCnt_APP_TOE);
3097 printInfo(
THIS_NAME,
"Number of TCP Bytes from TOE-to-IPTX : %6d \n", tcpBytCntr_TOE_IPTX);
3103 if (tcpBytCntr_IPRX_TOE != nrTcpIprxBytes.to_uint()) {
3104 printError(
THIS_NAME,
"The number of TCP bytes received by TOE on its IP interface (%d) does not match the internal TCP bytes counter of TOE (%d). \n", tcpBytCntr_IPRX_TOE, nrTcpIprxBytes.to_uint());
3113 printInfo(
THIS_NAME,
"This testbench was executed in mode \'%c\' with siIPRX file = %s.\n", mode, argv[2]);
3117 string sortedTAIF_GoldName = std::string(ofTAIF_GoldName) +
".sorted";
3118 int rc = system((
"sort " + std::string(ofTAIF_GoldName) +
" > " +
3119 std::string(sortedTAIF_GoldName)).c_str());
3123 string mergedTAIF_GoldName = std::string(sortedTAIF_GoldName) +
".merged";
3124 string mergedTAIF_StrmName = std::string(ofTAIF_DataName) +
".merged";
3125 int mergeCmd1 = system((
"paste -sd \"\" "+ std::string(sortedTAIF_GoldName) +
" > " + mergedTAIF_GoldName +
" ").c_str());
3126 int mergeCmd2 = system((
"paste -sd \"\" "+ std::string(ofTAIF_DataName) +
" > " + mergedTAIF_StrmName +
" ").c_str());
3127 int ipRx_TcpDataCompare = system((
"diff --brief -w " + mergedTAIF_GoldName +
" " + mergedTAIF_StrmName +
" ").c_str());
3128 if (ipRx_TcpDataCompare != 0) {
3129 if (nrOooDrops == 0) {
3130 printError(
THIS_NAME,
"File \"%s\" differs from file \"%s\" \n", mergedTAIF_StrmName.c_str(), mergedTAIF_GoldName.c_str());
3140 int appTxCompare = system((
"diff --brief -w " + std::string(ofTAIF_DataName) +
" "
3141 + std::string(ofTAIF_GoldName) +
" ").c_str());
3142 if (appTxCompare != 0) {
3143 if (nrOooDrops == 0) {
3144 printError(
THIS_NAME,
"File \"%s\" differs from file \"%s\" \n", ofTAIF_DataName, ofTAIF_GoldName);
3148 printWarn(
THIS_NAME,
"Skipping comparison between file \"%s\" and file \"%s\" \n", ofTAIF_DataName, ofTAIF_GoldName);
3150 if (tcpBytCntr_IPRX_TOE != tcpBytCnt_TOE_APP) {
3151 if (nrOooDrops == 0) {
3152 printError(
THIS_NAME,
"The number of TCP bytes received by TOE on its IP interface (%d) does not match the number TCP bytes forwarded by TOE to the application over its TAIF interface (%d). \n", tcpBytCntr_IPRX_TOE, tcpBytCnt_TOE_APP);
3161 if ((nrOpenedSessions == 0) and (pktCounter_IPRX_TOE > 0)) {
3162 printWarn(
THIS_NAME,
"No session was opened by the TOE during this run. Please double check!!!\n");
3169 printInfo(
THIS_NAME,
"This testbench was executed in mode \'%c\' with siTAIF file = %s.\n", mode, argv[2]);
3170 if (tcpBytCntr_TOE_IPTX != tcpBytCnt_APP_TOE) {
3171 printError(
THIS_NAME,
"The number of TCP bytes forwarded from TOE-to-IPTX (%d) does not match the number TCP bytes received from APP-to-TOE (%d). \n", tcpBytCntr_TOE_IPTX, tcpBytCnt_APP_TOE);
3174 string mergedIPTX_Data2Name = std::string(ofIPTX_Data2Name) +
".merged";
3175 string mergedIPTX_Gold2Name = std::string(ofIPTX_Gold2Name) +
".merged";
3176 int mergeCmd1 = system((
"paste -sd \"\" "+ std::string(ofIPTX_Data2Name) +
" > " + mergedIPTX_Data2Name +
" ").c_str());
3177 int mergeCmd2 = system((
"paste -sd \"\" "+ std::string(ofIPTX_Gold2Name) +
" > " + mergedIPTX_Gold2Name +
" ").c_str());
3178 int ipTx_TcpDataCompare = system((
"diff --brief -w " + mergedIPTX_Data2Name +
" " + mergedIPTX_Gold2Name +
" ").c_str());
3179 if (ipTx_TcpDataCompare != 0) {
3180 printError(
THIS_NAME,
"File \"%s\" differs from file \"%s\" \n", mergedIPTX_Data2Name.c_str(), mergedIPTX_Gold2Name.c_str());
3189 printInfo(
THIS_NAME,
"This testbench was executed with the following parameters: \n");
3191 for (
int i=2; i<argc; i++) {
3198 printError(
THIS_NAME,
"#### TEST BENCH FAILED : TOTAL NUMBER OF ERROR(S) = %2d ####\n", nrErr);
3201 printInfo(
THIS_NAME,
"FYI - You may want to check for \'ERROR\' and/or \'WARNING\' alarms in the LOG file...\n\n");
3204 printInfo(
THIS_NAME,
"#############################################################\n");
3206 printInfo(
THIS_NAME,
"#############################################################\n");
void setTLast(tLast last)
void pushChunk(AxisApp appChunk)
Class IPv4 Packet for simulation.
void writeTcpDataToDatFile(ofstream &outFile)
Dump the TCP payload of this IP packet into a file. Data is written as a string.
int sizeOfTcpData()
Return the size of the TCP data payload in octets.
TcpSeqNum getTcpSequenceNumber()
bool isACK()
Returns true if packet is an ACK.
void setTcpSequenceNumber(TcpSeqNum num)
int tcpRecalculateChecksum()
Recalculate the checksum of a TCP segment after it was modified.
void setIpSourceAddress(int addr)
bool isWellFormed(const char *callerName, bool checkIp4TotLen=true, bool checkIp4HdrCsum=true, bool checkUdpLen=true, bool checkLy4Csum=true)
Checks if the IP header and embedded protocol fields are properly set.
TcpAckNum getTcpAcknowledgeNumber()
Ip4Addr getIpSourceAddress()
int getTcpDestinationPort()
void pushChunk(AxisIp4 ip4Chunk)
void clone(SimIp4Packet &ipPkt)
Clone an IP packet.
bool isFIN()
Returns true if packet is a FIN.
void setTcpAcknowledgeNumber(TcpAckNum num)
void setTcpControlAck(int bit)
void setIpDestinationAddress(int addr)
Ip4Addr getIpDestinationAddress()
void printHdr(const char *callerName)
Print the header details of an IP packet.
void setTcpSourcePort(int port)
void printRaw(const char *callerName)
Raw print of an IP packet (.i.e, as AxisRaw chunks).
bool isSYN()
Returns true if packet is a SYN.
void setTcpChecksum(int csum)
void setTcpDestinationPort(int port)
void stepSim()
Increment the simulation counter.
#define CAM_LOOKUP_LATENCY
unsigned int gMaxSimCycles
#define CAM_UPDATE_LATENCY
void pEmulateCam(stream< RtlMacLookupRequest > &siARS_MacLkpReq, stream< RtlMacLookupReply > &soARS_MacLkpRep, stream< RtlMacUpdateRequest > &siARS_MacUpdReq, stream< RtlMacUpdateReply > &soARS_MacUpdRep)
Emulate the behavior of the Content Addressable Memory (CAM).
bool readAxisRawFromLine(AxisRaw &axisRaw, string stringBuffer)
Retrieve an AxisRaw chunk from a string.
vector< string > myTokenizer(string strBuff, char delimiter)
Brakes a string into tokens by using the 'delimiter' character.
bool writeAxisRawToFile(AxisRaw &axisRaw, ofstream &outFileStream)
Dump an Axis raw data chunk to a file.
bool isDottedDecimal(string ipStr)
Checks if a string contains an IP address represented in dot-decimal notation.
int writeAxisAppToFile(AxisApp &axisApp, ofstream &outFile)
Dump a TCP or UDP application data chunk into a file. The data are stored as a stream of bytes which ...
bool isHexString(string str)
Checks if a string contains a hexadecimal number.
ap_uint< 32 > myDottedDecimalIpToUint32(string ipStr)
Converts an IPv4 address represented with a dotted-decimal string into an UINT32.
bool pTcpAppConnect(int &nrError, SocketPair &aSocketPair, map< SocketPair, SessionId > &openSessList, stream< SockAddr > &soTOE_OpnReq, stream< TcpAppOpnRep > &siTOE_OpnRep)
TCP Application Connect (Tac). Requests TOE to open a new connection to a HOST socket.
void pIPRX_FeedTOE(deque< SimIp4Packet > &ipRxPacketizer, int &ipRxPktCounter, stream< AxisIp4 > &soTOE_Data, map< SocketPair, TcpAckNum > &sessAckList)
Feed TOE with an IP packet.
void pIPRX(ifstream &ifIPRX_Data, ofstream &ofTAIF_Gold, bool &testRxPath, int &ipRxPktCounter, int &tcpBytCntr_IPRX_TOE, deque< SimIp4Packet > &ipRxPacketizer, map< SocketPair, TcpAckNum > &sessAckList, StsBit &piTOE_Ready, stream< AxisIp4 > &soTOE_Data)
Emulate the behavior of the IP Rx Path (IPRX).
int pIPRX_InjectAckNumber(SimIp4Packet &ipRxPacket, map< SocketPair, TcpAckNum > &sessAckList)
Take the ACK number of a session and inject it into the sequence number field of the current packet.
bool setGlobalParameters(const char *callerName, unsigned int startupDelay, ifstream &inputFile)
Parse the input test file and set the global parameters of the TB.
#define MEM_RD_STS_LATENCY
void pTAIF(bool &testTxPath, char &testMode, int &nrError, Ip4Address &toeIpAddress, ifstream &ifTAIF_Data, ofstream &ofTAIF_Data, ofstream &ofIPTX_Gold2, int &appRxBytCntr, int &appTxBytCntr, StsBit &piTOE_Ready, stream< TcpAppLsnReq > &soTOE_LsnReq, stream< TcpAppLsnRep > &siTOE_LsnRep, stream< TcpAppNotif > &siTOE_Notif, stream< TcpAppRdReq > &soTOE_DReq, stream< TcpAppData > &siTOE_Data, stream< TcpAppMeta > &siTOE_Meta, stream< TcpAppOpnReq > &soTOE_OpnReq, stream< TcpAppOpnRep > &siTOE_OpnRep, stream< TcpAppData > &soTOE_Data, stream< TcpAppSndReq > &soTOE_SndReq, stream< TcpAppSndRep > &siTOE_SndRep, stream< TcpAppClsReq > &soTOE_ClsReq)
Emulates the behavior of the TCP application interface (TAIF).
void pIPTX(StsBit &piTOE_Ready, stream< AxisIp4 > &siTOE_Data, ofstream &ofIPTX_Data1, ofstream &ofIPTX_Data2, map< SocketPair, TcpAckNum > &sessAckList, int &pktCounter_TOE_IPTX, int &tcpBytCntr_TOE_IPTX, deque< SimIp4Packet > &ipRxPacketizer)
Emulate the behavior of the IP Tx Handler (IPTX).
void pTcpAppEcho(int &nrError, ofstream &ofIPTX_Gold2, int &apRxBytCntr, stream< TcpAppData > &soTOE_Data, stream< TcpAppSndReq > &soTOE_SndReq, stream< TcpAppSndRep > &siTOE_SndRep, stream< TcpAppData > &siTAr_Data, stream< TcpAppSndReq > &siTAr_SndReq)
TCP Application Echo (Tae). Performs an echo loopback between the receive and send parts of the TCP A...
#define MEM_RD_CMD_LATENCY
void pTAIF_Send(int &nrError, char &testMode, bool &testTxPath, Ip4Address &toeIpAddress, ifstream &ifTAIF_Data, ofstream &ofIPTX_Gold2, int &apRxBytCntr, StsBit &piTOE_Ready, stream< TcpAppOpnReq > &soTOE_OpnReq, stream< TcpAppOpnRep > &siTOE_OpnRep, stream< TcpAppData > &soTOE_Data, stream< TcpAppSndReq > &soTOE_SndReq, stream< TcpAppSndRep > &siTOE_SndRep, stream< TcpAppClsReq > &soTOE_ClsReq, stream< TcpAppData > &siTAr_Data, stream< TcpAppSndReq > &siTAr_SndReq)
TCP Application Send (TAs). Emulates the Tx process of the TAIF.
bool gTest_SentIp4HdrCsum
void cmdTestCommandParser(const char *callerName, vector< string > stringVector)
Parse and handle a 'COMMAND/TEST' request.
bool pIPTX_Parse(SimIp4Packet &ipTxPacket, map< SocketPair, TcpAckNum > &sessAckList, deque< SimIp4Packet > &ipRxPacketizer)
Parse the TCP/IP packets generated by the TOE.
void increaseSimTime(unsigned int cycles)
Increase the simulation time of the testbench.
bool pTcpAppListen(TcpPort lsnPortNum, set< TcpPort > &openedPorts, stream< TcpAppLsnReq > &soTOE_LsnReq, stream< TcpAppLsnRep > &siTOE_LsnRep)
TCP Application Listen (Tal). Requests TOE to listen on a new port.
#define MEM_WR_STS_LATENCY
bool gTest_RcvdIp4HdrCsum
const char * myCamAccessToString(int initiator)
Convert an access CAM initiator into a string.
void pEmulateRxBufMem(DummyMemory *memory, int &nrError, stream< DmCmd > &siTOE_RxP_WrCmd, stream< AxisApp > &siTOE_RxP_Data, stream< DmSts > &soTOE_RxP_WrSts, stream< DmCmd > &siTOE_RxP_RdCmd, stream< AxisApp > &soTOE_RxP_Data)
Emulate the behavior of the Receive DDR4 Buffer Memory (RXMEM).
void pEmulateTxBufMem(DummyMemory *memory, int &nrError, stream< DmCmd > &siTOE_TxP_WrCmd, stream< AxisApp > &siTOE_TxP_Data, stream< DmSts > &soTOE_TxP_WrSts, stream< DmCmd > &siTOE_TxP_RdCmd, stream< AxisApp > &soTOE_TxP_Data)
Emulate the behavior of the Transmit DDR4 Buffer Memory (TXMEM).
#define MEM_WR_CMD_LATENCY
void toe_top_wrap(Ip4Addr piMMIO_IpAddr, stream< StsBit > &soMMIO_RxMemWrErr, stream< ap_uint< 8 > > &soMMIO_NotifDropCnt, stream< ap_uint< 8 > > &soMMIO_MetaDropCnt, stream< ap_uint< 8 > > &soMMIO_DataDropCnt, stream< ap_uint< 8 > > &soMMIO_CrcDropCnt, stream< ap_uint< 8 > > &soMMIO_SessDropCnt, stream< ap_uint< 8 > > &soMMIO_OooDropCnt, StsBit &poNTS_Ready, stream< AxisIp4 > &siIPRX_Data, stream< AxisIp4 > &soIPTX_Data, stream< TcpAppNotif > &soTAIF_Notif, stream< TcpAppRdReq > &siTAIF_DReq, stream< TcpAppData > &soTAIF_Data, stream< TcpAppMeta > &soTAIF_Meta, stream< TcpAppLsnReq > &siTAIF_LsnReq, stream< TcpAppLsnRep > &soTAIF_LsnRep, stream< TcpAppData > &siTAIF_Data, stream< TcpAppSndReq > &siTAIF_SndReq, stream< TcpAppSndRep > &soTAIF_SndRep, stream< TcpAppOpnReq > &siTAIF_OpnReq, stream< TcpAppOpnRep > &soTAIF_OpnRep, stream< TcpAppClsReq > &siTAIF_ClsReq, stream< DmCmd > &soMEM_RxP_RdCmd, stream< AxisApp > &siMEM_RxP_Data, stream< DmSts > &siMEM_RxP_WrSts, stream< DmCmd > &soMEM_RxP_WrCmd, stream< AxisApp > &soMEM_RxP_Data, stream< DmCmd > &soMEM_TxP_RdCmd, stream< AxisApp > &siMEM_TxP_Data, stream< DmSts > &siMEM_TxP_WrSts, stream< DmCmd > &soMEM_TxP_WrCmd, stream< AxisApp > &soMEM_TxP_Data, stream< CamSessionLookupRequest > &soCAM_SssLkpReq, stream< CamSessionLookupReply > &siCAM_SssLkpRep, stream< CamSessionUpdateRequest > &soCAM_SssUpdReq, stream< CamSessionUpdateReply > &siCAM_SssUpdRep, stream< ap_uint< 16 > > &soDBG_SssRelCnt, stream< ap_uint< 16 > > &soDBG_SssRegCnt, stream< RxBufPtr > &soDBG_RxFreeSpace, stream< ap_uint< 32 > > &soDBG_TcpIpRxByteCnt, stream< ap_uint< 8 > > &soDBG_OooDebug)
A wrapper for the Toplevel of the TCP Offload Engine (TOE).
void cmdSetCommandParser(const char *callerName, vector< string > stringVector)
Parse and handle a 'COMMAND/SET' request.
const char * camAccessorStrings[]
void pTAIF_Recv(int &nrError, char &testMode, ofstream &ofTAIF_Data, int &appTxBytCntr, StsBit &piTOE_Ready, stream< TcpAppLsnReq > &soTOE_LsnReq, stream< TcpAppLsnRep > &siTOE_LsnRep, stream< TcpAppNotif > &siTOE_Notif, stream< TcpAppRdReq > &soTOE_DReq, stream< TcpAppData > &siTOE_Data, stream< TcpAppMeta > &siTOE_Meta, stream< TcpAppData > &soTAs_Data, stream< TcpAppSndReq > &soTAs_SndReq)
TCP Application Receive (TAr). Emulates the Rx process of the TAIF.
int drainMmioDropCounter(stream< T > &ss, string ssName)
Empty a DropCounter stream and throw it away.
#define FPGA_CLIENT_CONNECT_TIMEOUT
void setReadCmd(DmCmd cmd)
void printFourTuple(const char *callerName, int src, FourTuple fourTuple)
Print a socket pair association from an internal FourTuple encoding.
void setWriteCmd(DmCmd cmd)
void readChunk(AxisApp &chunk)
#define TOE_FEATURE_USED_FOR_DEBUGGING
void toe_top(Ip4Addr piMMIO_IpAddr, stream< StsBit > &soMMIO_RxMemWrErr, stream< ap_uint< 8 > > &soMMIO_NotifDropCnt, stream< ap_uint< 8 > > &soMMIO_MetaDropCnt, stream< ap_uint< 8 > > &soMMIO_DataDropCnt, stream< ap_uint< 8 > > &soMMIO_CrcDropCnt, stream< ap_uint< 8 > > &soMMIO_SessDropCnt, stream< ap_uint< 8 > > &soMMIO_OooDropCnt, StsBit &poNTS_Ready, stream< AxisRaw > &siIPRX_Data, stream< AxisRaw > &soIPTX_Data, stream< TcpAppNotif > &soTAIF_Notif, stream< TcpAppRdReq > &siTAIF_DReq, stream< TcpAppData > &soTAIF_Data, stream< TcpAppMeta > &soTAIF_Meta, stream< TcpAppLsnReq > &siTAIF_LsnReq, stream< TcpAppLsnRep > &soTAIF_LsnRep, stream< TcpAppData > &siTAIF_Data, stream< TcpAppSndReq > &siTAIF_SndReq, stream< TcpAppSndRep > &soTAIF_SndRep, stream< TcpAppOpnReq > &siTAIF_OpnReq, stream< TcpAppOpnRep > &soTAIF_OpnRep, stream< TcpAppClsReq > &siTAIF_ClsReq, stream< DmCmd > &soMEM_RxP_RdCmd, stream< AxisApp > &siMEM_RxP_Data, stream< DmSts > &siMEM_RxP_WrSts, stream< DmCmd > &soMEM_RxP_WrCmd, stream< AxisApp > &soMEM_RxP_Data, stream< DmCmd > &soMEM_TxP_RdCmd, stream< AxisApp > &siMEM_TxP_Data, stream< DmSts > &siMEM_TxP_WrSts, stream< DmCmd > &soMEM_TxP_WrCmd, stream< AxisApp > &soMEM_TxP_Data, stream< CamSessionLookupRequest > &soCAM_SssLkpReq, stream< CamSessionLookupReply > &siCAM_SssLkpRep, stream< CamSessionUpdateRequest > &soCAM_SssUpdReq, stream< CamSessionUpdateReply > &siCAM_SssUpdRep, stream< ap_uint< 16 > > &soDBG_SssRelCnt, stream< ap_uint< 16 > > &soDBG_SssRegCnt, stream< RxBufPtr > &soDBG_RxFreeSpace, stream< ap_uint< 32 > > &soDBG_TcpIpRxByteCnt, stream< ap_uint< 8 > > &soDBG_OooDebug)
Top of TCP Offload Engine (TOE)
#define TOE_FIRST_EPHEMERAL_PORT_NUM
void writeChunk(AxisApp &chunk)
#define printError(callerName, format,...)
A macro to print an error message.
void printAxisRaw(const char *callerName, AxisRaw chunk)
Prints an Axis raw data chunk (used for debugging).
void pAxisRawCast(hls::stream< TypeIn > &si, hls::stream< TypeOut > &so)
AxisRaw cast - Casts an AxisRaw stream to/from an AxisRaw derived class.
void printSockAddr(const char *callerName, SockAddr sockAddr)
Print a socket address.
const char * getTcpStateName(TcpState tcpState)
Returns the name of an enum-based TCP-State as a user friendly string.
#define printInfo(callerName, format,...)
A macro to print an information message.
void printIp4Addr(const char *callerName, const char *message, Ip4Addr ip4Addr)
Print an IPv4 address prepended with a message (used for debugging).
#define printWarn(callerName, format,...)
A macro to print a warning message.
#define concat3(firstCharConst, secondCharConst, thirdCharConst)
void printTcpPort(const char *callerName, TcpPort tcpPort)
Print a TCP port.
void printSockPair(const char *callerName, SocketPair sockPair)
Print a socket pair association.
#define printFatal(callerName, format,...)
A macro to print a fatal error message and exit.
ap_uint< 32 > byteSwap32(ap_uint< 32 > inputVector)
ap_uint< 16 > byteSwap16(ap_uint< 16 > inputVector)