cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
simu_tcp_shell_if_env.cpp
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 
44 
45 using namespace hls;
46 using namespace std;
47 
48 
51 extern unsigned int gSimCycCnt;
52 extern bool gTraceEvent;
53 extern bool gFatalError;
54 extern unsigned int gMaxSimCycles; // = cSimToeStartupDelay + cGraceTime;
55 
56 //---------------------------------------------------------
57 // HELPERS FOR THE DEBUGGING TRACES
58 // .e.g: DEBUG_LEVEL = (MDL_TRACE | IPS_TRACE)
59 //---------------------------------------------------------
60 #define THIS_NAME "SIM"
61 
62 #define TRACE_OFF 0x0000
63 #define TRACE_TOE 1 << 1
64 #define TRACE_TOE_LSN 1 << 2
65 #define TRACE_TOE_OPN 1 << 3
66 #define TRACE_TOE_RXP 1 << 4
67 #define TRACE_TOE_TXP 1 << 5
68 #define TRACE_TAF 1 << 6
69 #define TRACE_MMIO 1 << 7
70 #define TRACE_DDSK 1 << 8
71 #define TRACE_DDSP 1 << 9
72 #define TRACE_ALL 0xFFFF
73 #define DEBUG_LEVEL (TRACE_OFF)
74 
75 
78 void stepSim() {
79  gSimCycCnt++;
80  if (gTraceEvent || ((gSimCycCnt % 1000) == 0)) {
81  printInfo(THIS_NAME, "-- [@%4.4d] -----------------------------\n",
82  gSimCycCnt);
83  gTraceEvent = false;
84  } else if (0) {
85  printInfo(THIS_NAME, "------------------- [@%d] ------------\n",
86  gSimCycCnt);
87  }
88 }
89 
90 
95 void increaseSimTime(unsigned int cycles) {
96  gMaxSimCycles += cycles;
97 }
98 
99 
107 bool drainDebugSinkCounter(stream<ap_uint<32> > &ss, string ssName) {
108  int nr=0;
109  const char *myName = concat3(THIS_NAME, "/", "DUMTF");
110  ap_uint<32> currCount;
111  ap_uint<32> prevCount=0xFFFFFFFF;
112  bool rc=NTS_OK;
113 
114  //-- READ FROM STREAM
115  while (!(ss.empty())) {
116  ss.read(currCount);
117  if (currCount == prevCount) {
118  printWarn(myName, "Houston, we have a problem !\n\tcurrCount=%d|prevCount=%d\n", currCount.to_uint(), prevCount.to_uint());
119  rc=NTS_KO;
120  }
121  prevCount = currCount;
122  }
123  return(rc);
124 }
125 
126 
134 bool drainDebugSpaceCounter(stream<ap_uint<16> > &ss, string ssName) {
135  int nr=0;
136  const char *myName = concat3(THIS_NAME, "/", "DUMTF");
137  ap_uint<16> currCount;
138  ap_uint<16> prevCount=0xFFFFFFFF;
139  bool rc=NTS_OK;
140 
141  //-- READ FROM STREAM
142  while (!(ss.empty())) {
143  ss.read(currCount);
144  if (currCount != prevCount) {
145  if (DEBUG_LEVEL & TRACE_DDSP) {
146  printInfo(myName, "Detected a change on stream '%s' (currCounter=%d). \n",
147  ssName.c_str(), currCount.to_uint());
148  }
149  }
150  prevCount = currCount;
151  }
152  //-- ASSESS THE LAST COUNTER VALUE
153  if (currCount.to_uint() != cIBuffBytes) {
154  printError(myName, "The free input buffer space (%d) did not settle back to its initial value (%d)!\n",
155  currCount.to_uint(), cIBuffBytes);
156  rc = NTS_KO;
157  }
158  return(rc);
159 }
160 
161 
175 void pTAF(ofstream &ofTAF_Data,
176  stream<TcpAppData> &siTSIF_Data,
177  stream<TcpSessId> &siTSIF_SessId,
178  stream<TcpDatLen> &siTSIF_DatLen,
179  stream<TcpAppData> &soTSIF_Data,
180  stream<TcpSessId> &soTSIF_Meta,
181  stream<TcpSessId> &soTSIF_DLen)
182 {
183  const char *myName = concat3(THIS_NAME, "/", "TAF");
184 
185  TcpAppData appData;
186  TcpSessId sessId;
187  TcpDatLen datLen;
188 
189  if (!siTSIF_SessId.empty()) {
190  siTSIF_SessId.read(sessId);
191  }
192  if (!siTSIF_DatLen.empty()) {
193  siTSIF_DatLen.read(datLen);
194  }
195  if (!siTSIF_Data.empty()) {
196  siTSIF_Data.read(appData);
197  int bytes = writeAxisAppToFile(appData, ofTAF_Data);
198  if (DEBUG_LEVEL & TRACE_TAF) {
199  printAxisRaw(myName, "soTSIF_Data =", appData);
200  }
201  }
202 }
203 
204 
211 void pMMIO(
212  StsBit *piSHL_Ready,
213  CmdBit *poTSIF_Enable) {
214  const char *myName = concat3(THIS_NAME, "/", "MMIO");
215 
216  static bool mmio_printOnce = true;
217 
218  if (*piSHL_Ready) {
219  *poTSIF_Enable = 1;
220  if (mmio_printOnce) {
221  printInfo(myName,
222  "[SHELL/NTS/TOE] is ready -> Enabling operation of the TCP Shell Interface [TSIF].\n");
223  mmio_printOnce = false;
224  }
225  } else {
226  *poTSIF_Enable = 0;
227  }
228 }
229 
230 
248 void pTOE(
249  int &nrErr,
250  ofstream &ofTAF_Gold,
251  ofstream &ofTOE_Gold,
252  ofstream &ofTOE_Data,
253  TcpDatLen echoDatLen,
254  SockAddr testSock,
255  TcpDatLen testDatLen,
256  //-- MMIO / Ready Signal
257  StsBit *poMMIO_Ready,
258  //-- TSIF / Tx Data Interfaces
259  stream<TcpAppNotif> &soTSIF_Notif,
260  stream<TcpAppRdReq> &siTSIF_DReq,
261  stream<TcpAppData> &soTSIF_Data,
262  stream<TcpAppMeta> &soTSIF_Meta,
263  //-- TSIF / Listen Interfaces
264  stream<TcpAppLsnReq> &siTSIF_LsnReq,
265  stream<TcpAppLsnRep> &soTSIF_LsnRep,
266  //-- TSIF / Rx Data Interfaces
267  stream<TcpAppData> &siTSIF_Data,
268  stream<TcpAppSndReq> &siTSIF_SndReq,
269  stream<TcpAppSndRep> &soTSIF_SndRep,
270  //-- TSIF / Open Interfaces
271  stream<TcpAppOpnReq> &siTSIF_OpnReq,
272  stream<TcpAppOpnRep> &soTSIF_OpnRep)
273 {
274  static Ip4Addr toe_hostIp4Addr = DEFAULT_HOST_IP4_ADDR;
275  static TcpPort toe_hostTcpSrcPort = DEFAULT_HOST_TCP_SRC_PORT;
276  static TcpPort toe_hostTcpDstPort = ECHO_MODE_LSN_PORT;
277 
278  static map<SessionId, InterruptEntry> toe_openedSess; // A map to keep track of the opened sessions
279  static TcpAppSndReq toe_appSndReq;
280 
281  static enum FsmStates {
282  CREATE_SCENARIO,
283  SEND_NOTIFICATION,
284  SEND_METADATA,
285  SEND_DATA_SEGMENT,
286  SEND_8801_COMMAND,
287  NEXT_SEGMENT,
288  NEXT_ROUND,
289  DONE
290  } toe_fsmState = CREATE_SCENARIO;
291 
292  static int toe_startupDelay = cSimToeStartupDelay;
293  static bool toe_rxpIsReady = false;
294  static bool toe_txpIsReady = false;
295 
296  const char *myLsnName = concat3(THIS_NAME, "/", "TOE/Listen");
297  const char *myOpnName = concat3(THIS_NAME, "/", "TOE/OpnCon");
298  const char *myRxpName = concat3(THIS_NAME, "/", "TOE/RxPath");
299  const char *myTxpName = concat3(THIS_NAME, "/", "TOE/TxPath");
300 
301  //------------------------------------------------------
302  //-- FSM #0 - STARTUP DELAYS
303  //------------------------------------------------------
304  if (toe_startupDelay) {
305  toe_startupDelay--;
306  *poMMIO_Ready = 0;
307  }
308  else {
309  *poMMIO_Ready = 1;
310  }
311  toe_rxpIsReady = (toe_startupDelay <= 500) ? true : false;
312  toe_txpIsReady = (toe_startupDelay <= 500) ? true : false;
313 
314  //------------------------------------------------------
315  //-- REQUEST TO LISTEN ON A PORT
316  //------------------------------------------------------
317  TcpAppLsnReq appLsnPortReq;
318  if (true) {
319  if (!siTSIF_LsnReq.empty()) {
320  // A LISTENING REQUEST IS PENDING
321  siTSIF_LsnReq.read(appLsnPortReq);
322  if (DEBUG_LEVEL & TRACE_TOE_LSN) {
323  printInfo(myLsnName, "Received a listen port request #%d from [TSIF].\n",
324  appLsnPortReq.to_int());
325  }
326  // SEND REPLY BACK TO [TSIF]
327  if (!soTSIF_LsnRep.full()) {
328  soTSIF_LsnRep.write(TcpAppLsnRep(NTS_OK));
329  }
330  else {
331  printFatal(myLsnName, "Cannot send listen reply back to [TSIF] because stream is full.\n");
332  }
333  }
334  }
335 
336  //------------------------------------------------------
337  //-- REQUEST TO OPEN AN ACTIVE CONNECTIONS
338  //------------------------------------------------------
339  TcpAppOpnReq opnReq;
341  if (true) {
342  if (!siTSIF_OpnReq.empty()) {
343  siTSIF_OpnReq.read(opnReq);
344  if (DEBUG_LEVEL & TRACE_TOE_OPN) {
345  printInfo(myOpnName, "Received a request to open the following remote socket address:\n");
346  printSockAddr(myOpnName, SockAddr(opnReq.addr, opnReq.port));
347  }
348  if (!soTSIF_OpnRep.full()) {
349  soTSIF_OpnRep.write(opnReply);
350  // Create a new entry in the map
351  if (opnReq.port == XMIT_MODE_LSN_PORT) {
352  toe_openedSess[opnReply.sessId] = InterruptEntry(0, 0);
353  printInfo(myOpnName, "Session #%d is now established.\n", opnReply.sessId.to_uint());
354  }
355  }
356  else {
357  printFatal(myOpnName, "Cannot send open connection reply back to [TSIF] because stream is full.\n");
358  }
359  }
360  }
361 
362  //------------------------------------------------------
363  //-- RX DATA PATH / GENERATE TRAFFIC AND NOTIFICATIONS
364  //------------------------------------------------------
365  static SessionId toe_sessId;
366  static TcpSegLen toe_notifByteCnt;
367  static int toe_sessCnt = 0;
368  static int toe_segCnt = 0;
369  TcpAppData appData;
370  int bytesToSend;
371 
372  if (toe_rxpIsReady) {
373  switch (toe_fsmState) {
374  case CREATE_SCENARIO:
375  switch (toe_segCnt) {
376  case 0:
377  toe_hostTcpDstPort = RECV_MODE_LSN_PORT;
378  toe_notifByteCnt = echoDatLen;
379  toe_sessId = 0;
380  gMaxSimCycles += (echoDatLen / 8);
381  break;
382  case 1: //-- Request TSIF to open an active port
383  toe_hostTcpDstPort = XMIT_MODE_LSN_PORT;
384  toe_notifByteCnt = 8; // {IP_DA,TCP_DP, 0x0000}
385  toe_sessId = 1;
386  gMaxSimCycles += (8 / 8);
387  //-- Drain previous echo and send traffic
388  break;
389  case 2: //-- Set TSIF in transmit mode and execute test
390  toe_hostTcpDstPort = XMIT_MODE_LSN_PORT;
391  toe_notifByteCnt = 8; // {IP_DA,TCP_DP, testDatLen}
392  toe_sessId = 2;
393  gMaxSimCycles += (testDatLen / 8);
394  break;
395  case 3:
396  toe_hostTcpDstPort = ECHO_MODE_LSN_PORT;
397  toe_notifByteCnt = echoDatLen;
398  toe_sessId = 3;
399  gMaxSimCycles += (echoDatLen / 8);
400  break;
401  default:
402  toe_hostTcpDstPort = RECV_MODE_LSN_PORT;
403  toe_notifByteCnt = echoDatLen;
404  toe_sessId = 4;
405  gMaxSimCycles += (echoDatLen / 8);
406  break;
407  }
408  // Add new connection to the map
409  if (toe_openedSess.find(toe_sessId) == toe_openedSess.end()) {
410  toe_openedSess[toe_sessId] = InterruptEntry(0, 0);
411  }
412  toe_segCnt += 1;
413  toe_hostIp4Addr = DEFAULT_HOST_IP4_ADDR;
414  toe_hostTcpSrcPort = DEFAULT_HOST_TCP_SRC_PORT;
415  // Set the TCP destination port and byte count of the current session
416  toe_openedSess[toe_sessId].byteCnt += toe_notifByteCnt;
417  toe_openedSess[toe_sessId].dstPort = toe_hostTcpDstPort;
418  if (DEBUG_LEVEL & TRACE_ALL) {
419  printf("[+++] toe_openedSess[%d].byteCnt = %d\n", toe_sessId.to_int(),
420  toe_openedSess[toe_sessId].byteCnt.to_int());
421  }
422  toe_fsmState = SEND_NOTIFICATION;
423  break;
424  case SEND_NOTIFICATION:
425  if (soTSIF_Notif.full()) {
426  printFatal(myRxpName, "Cannot send notification to [TSIF] because stream is full.\n");
427  }
428  soTSIF_Notif.write(TcpAppNotif(toe_sessId, toe_notifByteCnt, toe_hostIp4Addr,
429  toe_hostTcpSrcPort, toe_hostTcpDstPort));
430  if (DEBUG_LEVEL & TRACE_TOE_RXP) {
431  printInfo(myRxpName, "Sending Notif to [TSIF] (sessId=%2d, datLen=%4d, dstPort=%4d).\n",
432  toe_sessId.to_int(), toe_notifByteCnt.to_int(), toe_hostTcpDstPort.to_uint());
433  }
434  toe_fsmState = SEND_METADATA;
435  break;
436  case SEND_METADATA:
437  if (soTSIF_Meta.full()) {
438  printFatal(myRxpName, "Cannot send metadata to [TSIF] because stream is full.\n");
439  }
440  soTSIF_Meta.write(toe_sessId);
441  if (toe_hostTcpDstPort == XMIT_MODE_LSN_PORT) {
442  toe_fsmState = SEND_8801_COMMAND;
443  } else {
444  toe_fsmState = SEND_DATA_SEGMENT;
445  }
446  break;
447  case SEND_DATA_SEGMENT:
448  bytesToSend = toe_notifByteCnt;
449  while (bytesToSend) {
450  if (soTSIF_Data.full()) {
451  printFatal(myRxpName, "Cannot send data to [TSIF] because stream is full.\n");
452  }
453  appData.setTData((random() << 32) | random());
454  if (bytesToSend > 8) {
455  appData.setTKeep(0xFF);
456  appData.setTLast(0);
457  bytesToSend -= 8;
458  }
459  else {
460  appData.setTKeep(lenTotKeep(bytesToSend));
461  appData.setTLast(TLAST);
462  bytesToSend = 0;
463  toe_fsmState = NEXT_SEGMENT;
464  }
465  soTSIF_Data.write(appData);
466  if (DEBUG_LEVEL & TRACE_TOE) {
467  printAxisRaw(myRxpName, "Sending data chunk to [TSIF]: ", appData);
468  }
469  if (toe_hostTcpDstPort == ECHO_MODE_LSN_PORT) {
470  int bytes = writeAxisAppToFile(appData, ofTAF_Gold);
471  }
472  }
473  toe_fsmState = NEXT_SEGMENT;
474  break;
475  case SEND_8801_COMMAND:
476  bytesToSend = testDatLen;
477  if (toe_sessId == 1) {
478  printInfo(myRxpName, "Requesting TSIF to connect to socket: \n");
479  printSockAddr(myRxpName, testSock);
480  appData.setTData(0);
481  appData.setLE_TData(byteSwap32(testSock.addr), 31, 0);
482  appData.setLE_TData(byteSwap16(testSock.port), 47, 32);
483  appData.setLE_TData(byteSwap16(0), 63, 48);
484  appData.setLE_TKeep(0xFF); // Always
485  appData.setLE_TLast(TLAST); // Always
486  if (soTSIF_Data.full()) {
487  printFatal(myRxpName, "Cannot send data to [TSIF] because stream is full.\n");
488  }
489  soTSIF_Data.write(appData);
490  }
491  else {
492  printInfo(myRxpName, "Requesting TSIF to generate a TCP payload of length=%d and to send it to socket: \n", bytesToSend);
493  printSockAddr(myRxpName, testSock);
494  appData.setTData(0);
495  appData.setLE_TData(byteSwap32(testSock.addr), 31, 0);
496  appData.setLE_TData(byteSwap16(testSock.port), 47, 32);
497  appData.setLE_TData(byteSwap16(bytesToSend), 63, 48);
498  appData.setLE_TKeep(0xFF); // Always
499  appData.setLE_TLast(TLAST); // Always
500  if (soTSIF_Data.full()) {
501  printFatal(myRxpName, "Cannot send data to [TSIF] because stream is full.\n");
502  }
503  soTSIF_Data.write(appData);
504  if (DEBUG_LEVEL & TRACE_TOE) {
505  printAxisRaw(myRxpName, "Sending Tx data length request to [TSIF]: ", appData);
506  }
507  //-- Generate content of the golden file
508  bool firstChunk = true;
509  while (bytesToSend) {
510  TcpAppData goldChunk(0, 0, 0);
511  if (firstChunk) {
512  for (int i = 0; i < 8; i++) {
513  if (bytesToSend) {
514  unsigned char byte = (GEN_CHK0 >> ((7 - i) * 8)) & 0xFF;
515  goldChunk.setLE_TData(byte, (i * 8) + 7, (i * 8) + 0);
516  goldChunk.setLE_TKeep(1, i, i);
517  (bytesToSend)--;
518  }
519  }
520  firstChunk = !firstChunk;
521  }
522  else { // Second Chunk
523  for (int i = 0; i < 8; i++) {
524  if (bytesToSend) {
525  unsigned char byte = (GEN_CHK1 >> ((7 - i) * 8)) & 0xFF;
526  goldChunk.setLE_TData(byte, (i * 8) + 7, (i * 8) + 0);
527  goldChunk.setLE_TKeep(1, i, i);
528  (bytesToSend)--;
529  }
530  }
531  firstChunk = !firstChunk;
532  }
533  if (bytesToSend == 0) {
534  goldChunk.setLE_TLast(TLAST);
535  }
536  int bytes = writeAxisRawToFile(goldChunk, ofTOE_Gold);
537  }
538  }
539  toe_fsmState = NEXT_SEGMENT;
540  break;
541  case NEXT_SEGMENT:
542  if (toe_segCnt == cNrSegToSend) {
543  toe_fsmState = NEXT_ROUND;
544  }
545  else {
546  toe_fsmState = CREATE_SCENARIO;
547  }
548  break;
549  case NEXT_ROUND:
550  toe_segCnt = 0;
551  toe_sessCnt += 1;
552  if (toe_sessCnt == cNrSessToSend) {
553  toe_fsmState = DONE;
554  printInfo(myRxpName, "DONE WITH TRAFFIC GENERATION.\n");
555  }
556  else {
557  toe_fsmState = CREATE_SCENARIO;
558  }
559  break;
560  case DONE:
561  // END OF TRAFFIC - ALL SEGMENTS HAVE BEEN NOTIFIED AND SENT
562  break;
563  } // End of: switch (toe_fsmState)
564  }
565 
566  //------------------------------------------------------
567  //-- RX DATA PATH / HANDLE INCOMING DATA REQUESTS
568  //------------------------------------------------------
569  static TcpAppRdReq toe_appRdReq;
570  if (toe_rxpIsReady) {
571  // WAIT FOR A DATA REQUEST FROM [TSIF]
572  if (!siTSIF_DReq.empty()) {
573  siTSIF_DReq.read(toe_appRdReq);
574  if (DEBUG_LEVEL & TRACE_TOE_RXP) {
575  printInfo(myRxpName, "Received a data read request from [TSIF] (sessId=%d, datLen=%d).\n",
576  toe_appRdReq.sessionID.to_int(), toe_appRdReq.length.to_int());
577  }
578  //-- Decrement the byte counter of the session
579  int sessByteCnt = toe_openedSess[toe_appRdReq.sessionID].byteCnt.to_int();
580  if (toe_appRdReq.length.to_int() > sessByteCnt) {
581  printInfo(myRxpName, "TOE is requesting more data (%d) than notified (%d) for session #%d !\n",
582  toe_appRdReq.length.to_int(), sessByteCnt, toe_appRdReq.sessionID.to_uint());
583  }
584  else {
585  toe_openedSess[toe_appRdReq.sessionID].byteCnt -= toe_appRdReq.length;
586  if (DEBUG_LEVEL & TRACE_ALL) {
587  printf("[---] toe_openedSess[%d].byteCnt = %d\n", toe_appRdReq.sessionID.to_int(),
588  toe_openedSess[toe_appRdReq.sessionID].byteCnt.to_int());
589  }
590  }
591  }
592  }
593 
594  //------------------------------------------------------
595  //-- TX DATA PATH / ALWAYS ACCEPT INCOMING [TSIF] DATA
596  //------------------------------------------------------
597  if (toe_txpIsReady) {
598  if (!siTSIF_SndReq.empty()) {
599  // Read the request to send
600  siTSIF_SndReq.read(toe_appSndReq);
601  if (soTSIF_SndRep.full()) {
602  printFatal(myRxpName, "Cannot send a send reply to [TSIF] because stream is full.\n");
603  }
604  // Check if session is established
605  if (toe_openedSess.find(toe_appSndReq.sessId) == toe_openedSess.end()) {
606  // Notify APP about the none-established connection
607  soTSIF_SndRep.write(TcpAppSndRep(toe_appSndReq.sessId,
608  toe_appSndReq.length, 0, NO_CONNECTION));
609  printError(myTxpName, "Session %d is not established.\n", toe_appSndReq.sessId.to_uint());
610  nrErr++;
611  }
612  else if (toe_appSndReq.length > 0x10000) { // [TODO-emulate 'maxWriteLength']
613  // Notify APP about the lack of space
614  soTSIF_SndRep.write(TcpAppSndRep(toe_appSndReq.sessId,
615  toe_appSndReq.length, 0x10000, NO_SPACE));
616  printError(myTxpName, "There is not enough TxBuf memory space available for session %d.\n",
617  toe_appSndReq.sessId.to_uint());
618  nrErr++;
619  }
620  else { //-- Session is ESTABLISHED and data-length <= maxWriteLength
621  // Notify APP about acceptance of the transmission
622  soTSIF_SndRep.write(TcpAppSndRep(toe_appSndReq.sessId,
623  toe_appSndReq.length, 0x10000, NO_ERROR));
624  }
625  }
626  if (!siTSIF_Data.empty()) {
627  TcpAppData appData;
628  siTSIF_Data.read(appData);
629  writeAxisRawToFile(appData, ofTOE_Data);
630  if (DEBUG_LEVEL & TRACE_TOE_TXP) {
631  printAxisRaw(myTxpName, "siTSIF_Data =", appData);
632  }
633  }
634  }
635 }
636 
void setTLast(tLast last)
Definition: AxisRaw.hpp:246
void setLE_TLast(LE_tLast last)
Definition: AxisRaw.hpp:280
void setLE_TData(LE_tData data, int leHi=64 -1, int leLo=0)
Definition: AxisRaw.hpp:272
void setTKeep(tKeep keep)
Definition: AxisRaw.hpp:239
void setTData(tData data)
Definition: AxisRaw.hpp:228
void setLE_TKeep(LE_tKeep keep, int leHi=64/8-1, int leLo=0)
Definition: AxisRaw.hpp:276
Ip4Addr addr
Definition: nts_types.hpp:209
Ly4Port port
Definition: nts_types.hpp:210
SessionId sessId
Definition: nts.hpp:167
TcpDatLen length
Definition: nts.hpp:117
SessionId sessionID
Definition: nts.hpp:116
TcpDatLen length
Definition: nts.hpp:130
SessionId sessId
Definition: nts.hpp:129
const char * myRxpName
Definition: tb_nal.cpp:837
#define DEFAULT_SESSION_ID
Definition: tb_nal.cpp:75
const char * myTxpName
Definition: tb_nal.cpp:838
const char * myOpnName
Definition: tb_nal.cpp:836
const char * myLsnName
Definition: tb_nal.cpp:835
#define DEFAULT_HOST_IP4_ADDR
Definition: tb_nal.cpp:72
bool writeAxisRawToFile(AxisRaw &axisRaw, ofstream &outFileStream)
Dump an Axis raw data chunk to a file.
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 ...
#define NTS_KO
Definition: nts_types.hpp:56
ap_uint< 16 > TcpSegLen
Definition: AxisTcp.hpp:121
ap_uint< 16 > SessionId
Definition: nts_types.hpp:136
#define printError(callerName, format,...)
A macro to print an error message.
Definition: nts_utils.hpp:195
ap_uint< 1 > StsBit
Definition: nts_types.hpp:116
void printAxisRaw(const char *callerName, AxisRaw chunk)
Prints an Axis raw data chunk (used for debugging).
Definition: nts_utils.cpp:46
ap_uint< 32 > Ip4Addr
Definition: AxisIp4.hpp:169
RepBool TcpAppLsnRep
Definition: nts.hpp:196
void printSockAddr(const char *callerName, SockAddr sockAddr)
Print a socket address.
Definition: nts_utils.cpp:174
TcpPort TcpAppLsnReq
Definition: nts.hpp:190
ap_uint< 16 > TcpPort
Definition: AxisTcp.hpp:105
ap_uint< 16 > TcpDatLen
Definition: AxisTcp.hpp:123
#define NTS_OK
Definition: nts_types.hpp:55
tKeep lenTotKeep(ap_uint< 4 > noValidBytes)
A function to set a number of '1' in an 8-bit field. It is used here to set the number of valid bytes...
Definition: nts_utils.cpp:328
#define printInfo(callerName, format,...)
A macro to print an information message.
Definition: nts_utils.hpp:169
ap_uint< 1 > CmdBit
Definition: nts_types.hpp:108
#define printWarn(callerName, format,...)
A macro to print a warning message.
Definition: nts_utils.hpp:182
#define concat3(firstCharConst, secondCharConst, thirdCharConst)
Definition: nts_utils.hpp:161
#define printFatal(callerName, format,...)
A macro to print a fatal error message and exit.
Definition: nts_utils.hpp:208
#define TLAST
Definition: AxisRaw.hpp:116
ap_uint< 16 > TcpSessId
Definition: nts_types.hpp:137
@ ESTABLISHED
Definition: nts_types.hpp:296
@ NO_ERROR
Definition: nts_types.hpp:304
@ NO_CONNECTION
Definition: nts_types.hpp:304
@ NO_SPACE
Definition: nts_types.hpp:304
#define DONE
bool drainDebugSpaceCounter(stream< ap_uint< 16 > > &ss, string ssName)
Empty the DebugSpaceCounter stream and check its last value.
#define GEN_CHK0
#define TRACE_TOE_LSN
#define TRACE_DDSP
#define GEN_CHK1
const int cSimToeStartupDelay
#define TRACE_TOE_RXP
void stepSim()
Increment the simulation counter.
void pTOE(int &nrErr, ofstream &ofTAF_Gold, ofstream &ofTOE_Gold, ofstream &ofTOE_Data, TcpDatLen echoDatLen, SockAddr testSock, TcpDatLen testDatLen, StsBit *poMMIO_Ready, stream< TcpAppNotif > &soTSIF_Notif, stream< TcpAppRdReq > &siTSIF_DReq, stream< TcpAppData > &soTSIF_Data, stream< TcpAppMeta > &soTSIF_Meta, stream< TcpAppLsnReq > &siTSIF_LsnReq, stream< TcpAppLsnRep > &soTSIF_LsnRep, stream< TcpAppData > &siTSIF_Data, stream< TcpAppSndReq > &siTSIF_SndReq, stream< TcpAppSndRep > &soTSIF_SndRep, stream< TcpAppOpnReq > &siTSIF_OpnReq, stream< TcpAppOpnRep > &soTSIF_OpnRep)
Emulate behavior of the SHELL/NTS/TCP Offload Engine (TOE).
#define RECV_MODE_LSN_PORT
#define XMIT_MODE_LSN_PORT
#define TRACE_TOE_TXP
void pMMIO(StsBit *piSHL_Ready, CmdBit *poTSIF_Enable)
Emulate the behavior of the SHELL & MMIO.
#define TRACE_TOE_OPN
unsigned int gMaxSimCycles
Definition: test_arp.hpp:69
unsigned int gSimCycCnt
Definition: tb_nal.cpp:150
bool gTraceEvent
Definition: tb_nal.cpp:151
#define THIS_NAME
void increaseSimTime(unsigned int cycles)
Increase the simulation time of the testbench.
bool drainDebugSinkCounter(stream< ap_uint< 32 > > &ss, string ssName)
Empty the DebugSinkCounter stream and throw it away.
const int cNrSessToSend
const int cIBuffBytes
#define DEFAULT_HOST_TCP_SRC_PORT
#define TRACE_TAF
const int cNrSegToSend
bool gFatalError
Definition: tb_nal.cpp:152
#define ECHO_MODE_LSN_PORT
#define DEBUG_LEVEL
void pTAF(ofstream &ofTAF_Data, stream< TcpAppData > &siTSIF_Data, stream< TcpSessId > &siTSIF_SessId, stream< TcpDatLen > &siTSIF_DatLen, stream< TcpAppData > &soTSIF_Data, stream< TcpSessId > &soTSIF_Meta, stream< TcpSessId > &soTSIF_DLen)
Emulate the behavior of the ROLE/TcpAppFlash (TAF).
#define TRACE_TOE
#define TRACE_ALL
: Simulation environment for the TCP Shell Interface (TSIF).
ap_uint< 32 > byteSwap32(ap_uint< 32 > inputVector)
Definition: udp.cpp:78
ap_uint< 16 > byteSwap16(ap_uint< 16 > inputVector)
Definition: udp.cpp:82