cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
tcp_shell_if

This module handles the control flow interface between the SHELL and the ROLE. More...

Collaboration diagram for tcp_shell_if:

Files

file  tcp_shell_if.cpp
 : TCP Shell Interface (TSIF)
 
file  tcp_shell_if.hpp
 : TCP Shell Interface (TSIF)
 
file  tcp_shell_if_top.cpp
 : Top level with I/O ports for TCP Shell Interface (TSIF)
 
file  tcp_shell_if_top.hpp
 : Top of TCP Shell Interface (TSIF)
 
file  simu_tcp_shell_if_env.cpp
 : Simulation environment for the TCP Shell Interface (TSIF).
 
file  simu_tcp_shell_if_env.hpp
 : Simulation environment for the TCP Shell Interface (TSIF).
 
file  test_tcp_shell_if.cpp
 : Testbench for the TCP Shell Interface (TSIF).
 
file  test_tcp_shell_if.hpp
 : Testbench for the TCP Shell Interface (TSIF).
 
file  test_tcp_shell_if_top.cpp
 : Testbench for the toplevel of the TCP Shell Interface (TSIF).
 
file  test_tcp_shell_if_top.hpp
 : Testbench for the toplevel of TCP Shell Interface (TSIF).
 

Classes

class  ForwardCmd
 
class  InterruptEntry
 
class  InterruptQuery
 

Macros

#define THIS_NAME   "TSIF"
 
#define TRACE_OFF   0x0000
 
#define TRACE_IRB   1 << 1
 
#define TRACE_RDP   1 << 2
 
#define TRACE_WRP   1 << 3
 
#define TRACE_LSN   1 << 4
 
#define TRACE_CON   1 << 5
 
#define TRACE_RNH   1 << 6
 
#define TRACE_RRH   1 << 7
 
#define TRACE_RRM   1 << 8
 
#define TRACE_ALL   0xFFFF
 
#define DEBUG_LEVEL   (TRACE_OFF)
 
#define RECV_MODE_LSN_PORT   8800
 
#define XMIT_MODE_LSN_PORT   8801
 
#define ECHO_MOD2_LSN_PORT   8802
 
#define ECHO_MODE_LSN_PORT   8803
 
#define IPERF_LSN_PORT   5001
 
#define IPREF3_LSN_PORT   5201
 
#define FIXME_DEFAULT_HOST_IP4_ADDR   0x0A0CC832
 
#define FIXME_DEFAULT_HOST_LSN_PORT   8803+0x8000
 
#define GEN_CHK0   0x48692066726f6d20
 
#define GEN_CHK1   0x464d4b553630210a
 
#define THIS_NAME   "SIM"
 
#define TRACE_OFF   0x0000
 
#define TRACE_TOE   1 << 1
 
#define TRACE_TOE_LSN   1 << 2
 
#define TRACE_TOE_OPN   1 << 3
 
#define TRACE_TOE_RXP   1 << 4
 
#define TRACE_TOE_TXP   1 << 5
 
#define TRACE_TAF   1 << 6
 
#define TRACE_MMIO   1 << 7
 
#define TRACE_DDSK   1 << 8
 
#define TRACE_DDSP   1 << 9
 
#define TRACE_ALL   0xFFFF
 
#define DEBUG_LEVEL   (TRACE_OFF)
 
#define DEFAULT_FPGA_IP4_ADDR   0x0A0CC801
 
#define DEFAULT_FPGA_LSN_PORT   0x0057
 
#define DEFAULT_HOST_IP4_ADDR   0x0A0CC832
 
#define DEFAULT_HOST_TCP_SRC_PORT   0x80
 
#define DEFAULT_SESSION_ID   0
 
#define DEFAULT_SESSION_LEN   32
 
#define THIS_NAME   "TB_TSIF"
 
#define TRACE_OFF   0x0000
 
#define TRACE_DDC   1 << 1
 
#define TRACE_ALL   0xFFFF
 
#define DEBUG_LEVEL   (TRACE_OFF | TRACE_DDC)
 
#define THIS_NAME   "TB_TSIF_TOP"
 
#define TRACE_OFF   0x0000
 
#define TRACE_DDC   1 << 1
 
#define TRACE_ALL   0xFFFF
 
#define DEBUG_LEVEL   (TRACE_OFF)
 

Enumerations

enum  DropCode { NOP =0 , GEN }
 
enum  QueryCmd { GET =0 , PUT , POST }
 

Functions

template<class Type >
void pStreamDataMover (stream< Type > &si, stream< Type > &so)
 Stream Data Mover - Moves data chunks from incoming stream to outgoing stream with blocking read and write access methods. More...
 
void pConnect (CmdBit *piSHL_Enable, stream< SockAddr > &siRDp_OpnSockReq, stream< Ly4Len > &siRDp_TxCountReq, stream< Ly4Len > &soWRp_TxBytesReq, stream< SessionId > &soWRp_TxSessId, stream< TcpAppOpnReq > &soSHL_OpnReq, stream< TcpAppOpnRep > &siSHL_OpnRep, stream< TcpAppClsReq > &soSHL_ClsReq)
 Connect (COn). More...
 
void pListen (CmdBit *piSHL_Enable, stream< TcpAppLsnReq > &soSHL_LsnReq, stream< TcpAppLsnRep > &siSHL_LsnRep)
 Listen(LSn) More...
 
void pInputReadBuffer (CmdBit *piSHL_Enable, stream< TcpAppData > &siSHL_Data, stream< TcpAppMeta > &siSHL_Meta, stream< TcpAppData > &soRDp_Data, stream< TcpAppMeta > &soRDp_Meta)
 Input Read Buffer (IRb) More...
 
void pReadNotificationHandler (CmdBit *piSHL_Enable, stream< TcpAppNotif > &siSHL_Notif, stream< TcpAppNotif > &soRRh_Notif)
 Read Notification Handler (RNh) More...
 
void pReadRequestHandler (CmdBit *piSHL_Enable, stream< TcpAppNotif > &siRNh_Notif, stream< SigBit > &siRDp_DequSig, stream< TcpAppRdReq > &soRRm_DReq, stream< ForwardCmd > &soRDp_FwdCmd, stream< ap_uint< 16 > > &soDBG_freeSpace)
 Read Request Handler (RRh) More...
 
void pReadRequestMover (CmdBit *piSHL_Enable, stream< TcpAppRdReq > &siRRh_DReq, stream< TcpAppRdReq > &soSHL_DReq)
 Read Request Mover (RRm) More...
 
void pReadPath (CmdBit *piSHL_Enable, stream< TcpAppData > &siSHL_Data, stream< TcpAppMeta > &siSHL_Meta, stream< ForwardCmd > &siRRh_FwdCmd, stream< SockAddr > &soCOn_OpnSockReq, stream< TcpDatLen > &soCOn_TxCountReq, stream< SigBit > &soRRh_DequSig, stream< TcpAppData > &soTAF_Data, stream< TcpSessId > &soTAF_SessId, stream< TcpDatLen > &soTAF_DatLen, stream< ap_uint< 32 > > &soDBG_SinkCount)
 Read Path (RDp) More...
 
void pWritePath (CmdBit *piSHL_Enable, stream< TcpAppData > &siTAF_Data, stream< TcpSessId > &siTAF_SessId, stream< TcpDatLen > &siTAF_DatLen, stream< TcpDatLen > &siCOn_TxBytesReq, stream< SessionId > &siCOn_TxSessId, stream< TcpAppData > &soSHL_Data, stream< TcpAppSndReq > &soSHL_SndReq, stream< TcpAppSndRep > &siSHL_SndRep)
 Write Path (WRp) More...
 
void tcp_shell_if (CmdBit *piSHL_Mmio_En, stream< TcpAppData > &siTAF_Data, stream< TcpSessId > &siTAF_SessId, stream< TcpDatLen > &siTAF_DatLen, stream< TcpAppData > &soTAF_Data, stream< TcpSessId > &soTAF_SessId, stream< TcpDatLen > &soTAF_DatLen, stream< TcpAppNotif > &siSHL_Notif, stream< TcpAppRdReq > &soSHL_DReq, stream< TcpAppData > &siSHL_Data, stream< TcpAppMeta > &siSHL_Meta, stream< TcpAppLsnReq > &soSHL_LsnReq, stream< TcpAppLsnRep > &siSHL_LsnRep, stream< TcpAppData > &soSHL_Data, stream< TcpAppSndReq > &soSHL_SndReq, stream< TcpAppSndRep > &siSHL_SndRep, stream< TcpAppOpnReq > &soSHL_OpnReq, stream< TcpAppOpnRep > &siSHL_OpnRep, stream< TcpAppClsReq > &soSHL_ClsReq, stream< ap_uint< 32 > > &soDBG_SinkCnt, stream< ap_uint< 16 > > &soDBG_InpBufSpace)
 TCP Shell Interface (TSIF) More...
 
void tcp_shell_if_top (CmdBit *piSHL_Mmio_En, stream< TcpAppData > &siTAF_Data, stream< TcpSessId > &siTAF_SessId, stream< TcpDatLen > &siTAF_DatLen, stream< TcpAppData > &soTAF_Data, stream< TcpSessId > &soTAF_SessId, stream< TcpDatLen > &soTAF_DatLen, stream< TcpAppNotif > &siSHL_Notif, stream< TcpAppRdReq > &soSHL_DReq, stream< TcpAppData > &siSHL_Data, stream< TcpAppMeta > &siSHL_Meta, stream< TcpAppLsnReq > &soSHL_LsnReq, stream< TcpAppLsnRep > &siSHL_LsnRep, stream< TcpAppData > &soSHL_Data, stream< TcpAppSndReq > &soSHL_SndReq, stream< TcpAppSndRep > &siSHL_SndRep, stream< TcpAppOpnReq > &soSHL_OpnReq, stream< TcpAppOpnRep > &siSHL_OpnRep, stream< TcpAppClsReq > &soSHL_ClsReq, stream< ap_uint< 32 > > &soDBG_SinkCnt, stream< ap_uint< 16 > > &soDBG_InpBufSpace)
 Top of TCP Shell Interface (TSIF) More...
 
void stepSim ()
 Increment the simulation counter. More...
 
void increaseSimTime (unsigned int cycles)
 Increase the simulation time of the testbench. More...
 
bool drainDebugSinkCounter (stream< ap_uint< 32 > > &ss, string ssName)
 Empty the DebugSinkCounter stream and throw it away. More...
 
bool drainDebugSpaceCounter (stream< ap_uint< 16 > > &ss, string ssName)
 Empty the DebugSpaceCounter stream and check its last value. More...
 
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). More...
 
void pMMIO (StsBit *piSHL_Ready, CmdBit *poTSIF_Enable)
 Emulate the behavior of the SHELL & MMIO. More...
 
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). More...
 
template<typename T >
bool drainDebugCounter (stream< T > &ss, string ssName)
 Empty a debug stream and throw it away. More...
 
int main (int argc, char *argv[])
 Main function for the test of the TCP Shell Interface (TSIF). More...
 

Variables

bool gTraceEvent
 
const int cDepth_IRbToRDp_Data = 256
 
const int cDepth_IRbToRDp_Meta = 256
 
const int cDepth_RNhToRRh_Notif = 64
 
const int cDepth_RRhToRDp_FwdCmd = 8
 
const int cDepth_RRhToRRm_DReq = cDepth_RRhToRDp_FwdCmd
 
const int cDepth_RDpToRRh_Dequeue = 4
 
const int cDepth_RDpToCOn_OpnSockReq = 2
 
const int cDepth_RDpToCOn_TxCountReq = cDepth_RDpToCOn_OpnSockReq
 
const int cDepth_COnToWRp_TxBytesReq = 2
 
const int cDepth_COnToWRp_TxSessId = cDepth_COnToWRp_TxBytesReq
 
const int cMaxSessions = TOE_MAX_SESSIONS
 
const int cIBuffBytes = cDepth_IRbToRDp_Data * (ARW/8)
 
const int cMinDataReqLen = 128
 
unsigned int gSimCycCnt
 
bool gTraceEvent
 
bool gFatalError
 
unsigned int gMaxSimCycles
 
const int cSimToeStartupDelay = 1000
 
const int cGraceTime = 2500
 
const int cNrSegToSend = 5
 
const int cNrSessToSend = 2
 
const int cMinWAIT = cMaxSessions
 
unsigned int gSimCycCnt
 
unsigned int gMaxSimCycles
 
unsigned int gSimCycCnt = 0
 
bool gTraceEvent = false
 
bool gFatalError = false
 
unsigned int gMaxSimCycles = cSimToeStartupDelay + cGraceTime
 
unsigned int gSimCycCnt
 
unsigned int gMaxSimCycles
 
unsigned int gSimCycCnt = 0
 
bool gTraceEvent = false
 
bool gFatalError = false
 
unsigned int gMaxSimCycles = cSimToeStartupDelay + cGraceTime
 

Detailed Description

This module handles the control flow interface between the SHELL and the ROLE.

Macro Definition Documentation

◆ DEBUG_LEVEL [1/4]

#define DEBUG_LEVEL   (TRACE_OFF)

Definition at line 81 of file tcp_shell_if.cpp.

◆ DEBUG_LEVEL [2/4]

#define DEBUG_LEVEL   (TRACE_OFF)

Definition at line 73 of file simu_tcp_shell_if_env.cpp.

◆ DEBUG_LEVEL [3/4]

#define DEBUG_LEVEL   (TRACE_OFF | TRACE_DDC)

Definition at line 61 of file test_tcp_shell_if.cpp.

◆ DEBUG_LEVEL [4/4]

#define DEBUG_LEVEL   (TRACE_OFF)

Definition at line 62 of file test_tcp_shell_if_top.cpp.

◆ DEFAULT_FPGA_IP4_ADDR

#define DEFAULT_FPGA_IP4_ADDR   0x0A0CC801

Definition at line 61 of file simu_tcp_shell_if_env.hpp.

◆ DEFAULT_FPGA_LSN_PORT

#define DEFAULT_FPGA_LSN_PORT   0x0057

Definition at line 62 of file simu_tcp_shell_if_env.hpp.

◆ DEFAULT_HOST_IP4_ADDR

#define DEFAULT_HOST_IP4_ADDR   0x0A0CC832

Definition at line 63 of file simu_tcp_shell_if_env.hpp.

◆ DEFAULT_HOST_TCP_SRC_PORT

#define DEFAULT_HOST_TCP_SRC_PORT   0x80

Definition at line 64 of file simu_tcp_shell_if_env.hpp.

◆ DEFAULT_SESSION_ID

#define DEFAULT_SESSION_ID   0

Definition at line 66 of file simu_tcp_shell_if_env.hpp.

◆ DEFAULT_SESSION_LEN

#define DEFAULT_SESSION_LEN   32

Definition at line 67 of file simu_tcp_shell_if_env.hpp.

◆ ECHO_MOD2_LSN_PORT

#define ECHO_MOD2_LSN_PORT   8802

Definition at line 87 of file tcp_shell_if.hpp.

◆ ECHO_MODE_LSN_PORT

#define ECHO_MODE_LSN_PORT   8803

Definition at line 88 of file tcp_shell_if.hpp.

◆ FIXME_DEFAULT_HOST_IP4_ADDR

#define FIXME_DEFAULT_HOST_IP4_ADDR   0x0A0CC832

Definition at line 92 of file tcp_shell_if.hpp.

◆ FIXME_DEFAULT_HOST_LSN_PORT

#define FIXME_DEFAULT_HOST_LSN_PORT   8803+0x8000

Definition at line 93 of file tcp_shell_if.hpp.

◆ GEN_CHK0

#define GEN_CHK0   0x48692066726f6d20

Definition at line 101 of file tcp_shell_if.hpp.

◆ GEN_CHK1

#define GEN_CHK1   0x464d4b553630210a

Definition at line 102 of file tcp_shell_if.hpp.

◆ IPERF_LSN_PORT

#define IPERF_LSN_PORT   5001

Definition at line 89 of file tcp_shell_if.hpp.

◆ IPREF3_LSN_PORT

#define IPREF3_LSN_PORT   5201

Definition at line 90 of file tcp_shell_if.hpp.

◆ RECV_MODE_LSN_PORT

#define RECV_MODE_LSN_PORT   8800

Definition at line 85 of file tcp_shell_if.hpp.

◆ THIS_NAME [1/4]

#define THIS_NAME   "TSIF"

Definition at line 69 of file tcp_shell_if.cpp.

◆ THIS_NAME [2/4]

#define THIS_NAME   "SIM"

Definition at line 60 of file simu_tcp_shell_if_env.cpp.

◆ THIS_NAME [3/4]

#define THIS_NAME   "TB_TSIF"

Definition at line 57 of file test_tcp_shell_if.cpp.

◆ THIS_NAME [4/4]

#define THIS_NAME   "TB_TSIF_TOP"

Definition at line 51 of file test_tcp_shell_if_top.cpp.

◆ TRACE_ALL [1/4]

#define TRACE_ALL   0xFFFF

Definition at line 80 of file tcp_shell_if.cpp.

◆ TRACE_ALL [2/4]

#define TRACE_ALL   0xFFFF

Definition at line 72 of file simu_tcp_shell_if_env.cpp.

◆ TRACE_ALL [3/4]

#define TRACE_ALL   0xFFFF

Definition at line 60 of file test_tcp_shell_if.cpp.

◆ TRACE_ALL [4/4]

#define TRACE_ALL   0xFFFF

Definition at line 60 of file test_tcp_shell_if_top.cpp.

◆ TRACE_CON

#define TRACE_CON   1 << 5

Definition at line 76 of file tcp_shell_if.cpp.

◆ TRACE_DDC [1/2]

#define TRACE_DDC   1 << 1

Definition at line 59 of file test_tcp_shell_if.cpp.

◆ TRACE_DDC [2/2]

#define TRACE_DDC   1 << 1

Definition at line 59 of file test_tcp_shell_if_top.cpp.

◆ TRACE_DDSK

#define TRACE_DDSK   1 << 8

Definition at line 70 of file simu_tcp_shell_if_env.cpp.

◆ TRACE_DDSP

#define TRACE_DDSP   1 << 9

Definition at line 71 of file simu_tcp_shell_if_env.cpp.

◆ TRACE_IRB

#define TRACE_IRB   1 << 1

Definition at line 72 of file tcp_shell_if.cpp.

◆ TRACE_LSN

#define TRACE_LSN   1 << 4

Definition at line 75 of file tcp_shell_if.cpp.

◆ TRACE_MMIO

#define TRACE_MMIO   1 << 7

Definition at line 69 of file simu_tcp_shell_if_env.cpp.

◆ TRACE_OFF [1/4]

#define TRACE_OFF   0x0000

Definition at line 71 of file tcp_shell_if.cpp.

◆ TRACE_OFF [2/4]

#define TRACE_OFF   0x0000

Definition at line 62 of file simu_tcp_shell_if_env.cpp.

◆ TRACE_OFF [3/4]

#define TRACE_OFF   0x0000

Definition at line 58 of file test_tcp_shell_if.cpp.

◆ TRACE_OFF [4/4]

#define TRACE_OFF   0x0000

Definition at line 58 of file test_tcp_shell_if_top.cpp.

◆ TRACE_RDP

#define TRACE_RDP   1 << 2

Definition at line 73 of file tcp_shell_if.cpp.

◆ TRACE_RNH

#define TRACE_RNH   1 << 6

Definition at line 77 of file tcp_shell_if.cpp.

◆ TRACE_RRH

#define TRACE_RRH   1 << 7

Definition at line 78 of file tcp_shell_if.cpp.

◆ TRACE_RRM

#define TRACE_RRM   1 << 8

Definition at line 79 of file tcp_shell_if.cpp.

◆ TRACE_TAF

#define TRACE_TAF   1 << 6

Definition at line 68 of file simu_tcp_shell_if_env.cpp.

◆ TRACE_TOE

#define TRACE_TOE   1 << 1

Definition at line 63 of file simu_tcp_shell_if_env.cpp.

◆ TRACE_TOE_LSN

#define TRACE_TOE_LSN   1 << 2

Definition at line 64 of file simu_tcp_shell_if_env.cpp.

◆ TRACE_TOE_OPN

#define TRACE_TOE_OPN   1 << 3

Definition at line 65 of file simu_tcp_shell_if_env.cpp.

◆ TRACE_TOE_RXP

#define TRACE_TOE_RXP   1 << 4

Definition at line 66 of file simu_tcp_shell_if_env.cpp.

◆ TRACE_TOE_TXP

#define TRACE_TOE_TXP   1 << 5

Definition at line 67 of file simu_tcp_shell_if_env.cpp.

◆ TRACE_WRP

#define TRACE_WRP   1 << 3

Definition at line 74 of file tcp_shell_if.cpp.

◆ XMIT_MODE_LSN_PORT

#define XMIT_MODE_LSN_PORT   8801

Definition at line 86 of file tcp_shell_if.hpp.

Enumeration Type Documentation

◆ DropCode

enum DropCode
Enumerator
NOP 
GEN 

Definition at line 104 of file tcp_shell_if.hpp.

104  {
105  NOP=0, // No Operation
106  GEN // Generate traffic towards producer
107 };
@ GEN
@ NOP

◆ QueryCmd

enum QueryCmd
Enumerator
GET 
PUT 
POST 

Definition at line 142 of file tcp_shell_if.hpp.

142  {
143  GET=0, // Retrieve a table entry
144  PUT, // Modify an entry of the table
145  POST, // Create a new entry in the table
146 };
@ GET
@ POST
@ PUT

Function Documentation

◆ drainDebugCounter()

template<typename T >
bool drainDebugCounter ( stream< T > &  ss,
string  ssName 
)

Empty a debug stream and throw it away.

Parameters
[in/out]ss A ref to the stream to drain.
[in]ssNameThe name of the stream to drain.
Returns
NTS_OK if successful, otherwise NTS_KO.

Definition at line 71 of file test_tcp_shell_if.cpp.

71  {
72  int nr=0;
73  const char *myName = concat3(THIS_NAME, "/", "DDC");
74  T currCount;
75  T prevCount=0;
76 
77  //-- READ FROM STREAM
78  while (!(ss.empty())) {
79  ss.read(currCount);
80  if (currCount != prevCount) {
81  if (DEBUG_LEVEL & TRACE_DDC) {
82  printInfo(myName, "Detected a change on stream '%s' (currCounter=%d). \n",
83  ssName.c_str(), currCount.to_uint());
84  }
85  }
86  prevCount = currCount;
87  }
88  return(NTS_OK);
89 }
#define NTS_OK
Definition: nts_types.hpp:55
#define printInfo(callerName, format,...)
A macro to print an information message.
Definition: nts_utils.hpp:169
#define concat3(firstCharConst, secondCharConst, thirdCharConst)
Definition: nts_utils.hpp:161
#define TRACE_DDC
#define THIS_NAME
#define DEBUG_LEVEL
Here is the caller graph for this function:

◆ drainDebugSinkCounter()

bool drainDebugSinkCounter ( stream< ap_uint< 32 > > &  ss,
string  ssName 
)

Empty the DebugSinkCounter stream and throw it away.

Parameters
[in/out]ss A ref to the stream to drain.
[in]ssNameThe name of the stream to drain.
Returns
NTS_OK if successful, otherwise NTS_KO.

Definition at line 107 of file simu_tcp_shell_if_env.cpp.

107  {
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 }
#define NTS_KO
Definition: nts_types.hpp:56
#define printWarn(callerName, format,...)
A macro to print a warning message.
Definition: nts_utils.hpp:182
Here is the caller graph for this function:

◆ drainDebugSpaceCounter()

bool drainDebugSpaceCounter ( stream< ap_uint< 16 > > &  ss,
string  ssName 
)

Empty the DebugSpaceCounter stream and check its last value.

Parameters
[in/out]ss A ref to the stream to drain.
[in]ssNameThe name of the stream to drain.
Returns
NTS_OK if successful, otherwise NTS_KO.

Definition at line 134 of file simu_tcp_shell_if_env.cpp.

134  {
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 }
#define printError(callerName, format,...)
A macro to print an error message.
Definition: nts_utils.hpp:195
#define TRACE_DDSP
const int cIBuffBytes

◆ increaseSimTime()

void increaseSimTime ( unsigned int  cycles)

Increase the simulation time of the testbench.

Parameters
[in]Thenumber of cycles to increase.

Definition at line 95 of file simu_tcp_shell_if_env.cpp.

95  {
96  gMaxSimCycles += cycles;
97 }
unsigned int gMaxSimCycles
Definition: test_arp.hpp:69

◆ main()

int main ( int  argc,
char *  argv[] 
)

Main function for the test of the TCP Shell Interface (TSIF).

Main function for the test of the TCP Shell Interface (TSIF) TOP.

This test take 0,1,2,3 or 4 parameters in the following order:

Parameters
[in]Thenumber of bytes to generate in 'Echo' or "Dump' mode [1:65535].
[in]TheIPv4 address to open (must be in the range [0x00000000:0xFFFFFFFF].
[in]TheTCP port number to open (must be in the range [0:65535].
[in]Thenumber of bytes to generate in 'Tx' test mode [1:65535] or '0' to simply open a port w/o triggering the Tx test mode.

Definition at line 102 of file test_tcp_shell_if.cpp.

102  {
103 
104  //------------------------------------------------------
105  //-- TESTBENCH GLOBAL VARIABLES
106  //------------------------------------------------------
107  gSimCycCnt = 0; // Simulation cycle counter as a global variable
108 
109  //------------------------------------------------------
110  //-- DUT SIGNAL INTERFACES
111  //------------------------------------------------------
112  //-- SHL / Mmio Interface
113  CmdBit sMMIO_TSIF_Enable;
114  //-- TOE / Ready Signal
115  StsBit sTOE_MMIO_Ready;
116  //-- TSIF / Session Connect Id Interface
117  SessionId sTSIF_TAF_SConId;
118 
119  //------------------------------------------------------
120  //-- DUT STREAM INTERFACES
121  //------------------------------------------------------
122  //-- TAF / Rx Data Interface
123  stream<TcpAppData> ssTAF_TSIF_Data ("ssTAF_TSIF_Data");
124  stream<TcpSessId> ssTAF_TSIF_SessId("ssTAF_TSIF_SessId");
125  stream<TcpDatLen> ssTAF_TSIF_DatLen("ssTAF_TSIF_DatLen");
126  //-- TSIF / Tx Data Interface
127  stream<TcpAppData> ssTSIF_TAF_Data ("ssTSIF_TAF_Data");
128  stream<TcpSessId> ssTSIF_TAF_SessId("ssTSIF_TAF_SessId");
129  stream<TcpDatLen> ssTSIF_TAF_DatLen("ssTSIF_TAF_DatLen");
130  //-- TOE / Rx Data Interfaces
131  stream<TcpAppNotif> ssTOE_TSIF_Notif ("ssTOE_TSIF_Notif");
132  stream<TcpAppData> ssTOE_TSIF_Data ("ssTOE_TSIF_Data");
133  stream<TcpAppMeta> ssTOE_TSIF_Meta ("ssTOE_TSIF_Meta");
134  //-- TSIF / Rx Data Interface
135  stream<TcpAppRdReq> ssTSIF_TOE_DReq ("ssTSIF_TOE_DReq");
136  //-- TOE / Listen Interface
137  stream<TcpAppLsnRep> ssTOE_TSIF_LsnRep("ssTOE_TSIF_LsnRep");
138  //-- TSIF / Listen Interface
139  stream<TcpAppLsnReq> ssTSIF_TOE_LsnReq("ssTSIF_TOE_LsnReq");
140  //-- TOE / Tx Data Interfaces
141  stream<TcpAppSndRep> ssTOE_TSIF_SndRep("ssTOE_TSIF_SndRep");
142  //-- TSIF / Tx Data Interfaces
143  stream<TcpAppData> ssTSIF_TOE_Data ("ssTSIF_TOE_Data");
144  stream<TcpAppSndReq> ssTSIF_TOE_SndReq("ssTSIF_TOE_SndReq");
145  //-- TOE / Connect Interfaces
146  stream<TcpAppOpnRep> ssTOE_TSIF_OpnRep("ssTOE_TSIF_OpnRep");
147  //-- TSIF / Connect Interfaces
148  stream<TcpAppOpnReq> ssTSIF_TOE_OpnReq("ssTSIF_TOE_OpnReq");
149  stream<TcpAppClsReq> ssTSIF_TOE_ClsReq("ssTSIF_TOE_ClsReq");
150  //-- DEBUG Interface
151  stream<ap_uint<32> > ssTSIF_DBG_SinkCnt("ssTSIF_DBG_SinkCnt");
152  stream<ap_uint<16> > ssTSIF_DBG_InpBufSpace("ssTSIF_DBG_InpBufSpace");
153 
154  //------------------------------------------------------
155  //-- TESTBENCH VARIABLES
156  //------------------------------------------------------
157  int nrErr = 0; // Total number of testbench errors
158  ofstream ofTAF_Data; // APP byte streams delivered to TAF
159  const char *ofTAF_DataName = "../../../../test/simOutFiles/soTAF.dat";
160  ofstream ofTAF_Gold; // Gold reference file for 'ofTAF_Data'
161  const char *ofTAF_GoldName = "../../../../test/simOutFiles/soTAF.gold";
162  ofstream ofTOE_Data; // Data streams delivered to TOE
163  const char *ofTOE_DataName = "../../../../test/simOutFiles/soTOE_Data.dat";
164  ofstream ofTOE_Gold; // Gold streams to compare with
165  const char *ofTOE_GoldName = "../../../../test/simOutFiles/soTOE_Gold.dat";
166 
167  const int defaultLenOfSegmentEcho = 42;
168  const int defaultDestHostIpv4Test = 0xC0A80096; // 192.168.0.150
169  const int defaultDestHostPortTest = 2718;
170  const int defaultLenOfSegmentTest = 43;
171 
172  int echoLenOfSegment = defaultLenOfSegmentEcho;
173  ap_uint<32> testDestHostIpv4 = defaultDestHostIpv4Test;
174  ap_uint<16> testDestHostPort = defaultDestHostIpv4Test;
175  int testLenOfSegment = defaultLenOfSegmentTest;
176 
177  //------------------------------------------------------
178  //-- PARSING THE TESBENCH ARGUMENTS
179  //------------------------------------------------------
180  if (argc >= 2) {
181  if ((atoi(argv[1]) < 1) or (atoi(argv[1]) > 0x4000)) {
183  "Argument 'len' is out of range [1:16384].\n");
184  return NTS_KO;
185  } else {
186  echoLenOfSegment = atoi(argv[1]);
187  }
188  }
189  if (argc >= 3) {
190  if (isDottedDecimal(argv[2])) {
191  testDestHostIpv4 = myDottedDecimalIpToUint32(argv[2]);
192  } else {
193  testDestHostIpv4 = atoi(argv[2]);
194  }
195  if ((testDestHostIpv4 < 0x00000000)
196  or (testDestHostIpv4 > 0xFFFFFFFF)) {
198  "Argument 'IPv4' is out of range [0x00000000:0xFFFFFFFF].\n");
199  return NTS_KO;
200  }
201  }
202  if (argc >= 4) {
203  testDestHostPort = atoi(argv[3]);
204  if ((testDestHostPort < 0x0000) or (testDestHostPort >= 0x10000)) {
206  "Argument 'port' is out of range [0:65535].\n");
207  return NTS_KO;
208  }
209  }
210  if (argc >= 5) {
211  testLenOfSegment = atoi(argv[4]);
212  if ((testLenOfSegment < 1) or (testLenOfSegment > 0x4000)) {
214  "Argument 'len' is out of range [1:16384].\n");
215  return NTS_KO;
216  }
217  }
218 
219  //------------------------------------------------------
220  //-- ASSESS THE TESTBENCH ARGUMENTS
221  //------------------------------------------------------
222  int totalRxBytes = (cNrSessToSend * (testLenOfSegment + 8 + 8 + 2*echoLenOfSegment));
223  if (totalRxBytes > cIBuffBytes) {
224  printFatal(THIS_NAME, "The total amount of Rx bytes (%d) exceeds the size of the input TSIF read buffer (%d).\n",
225  totalRxBytes, cIBuffBytes);
226  }
227  if (testLenOfSegment > cIBuffBytes) {
228  printFatal(THIS_NAME, "The length of the test segment (%d) exceeds the size of the input TSIF read buffer (%d).\n",
229  testLenOfSegment, cIBuffBytes);
230  }
231 
232  //------------------------------------------------------
233  //-- UPDATE THE LOCAL VARIABLES ACCORDINGLY
234  //------------------------------------------------------
235  SockAddr testSock(testDestHostIpv4, testDestHostPort);
237  * (((echoLenOfSegment * (cNrSegToSend / 2))
238  + (testLenOfSegment * (cNrSegToSend / 2))));
239 
240  //------------------------------------------------------
241  //-- REMOVE PREVIOUS OLD SIM FILES and OPEN NEW ONES
242  //------------------------------------------------------
243  remove(ofTAF_DataName);
244  ofTAF_Data.open(ofTAF_DataName);
245  if (!ofTAF_Data) {
247  "Cannot open the Application Tx file: \n\t %s \n",
248  ofTAF_DataName);
249  return -1;
250  }
251  remove(ofTAF_GoldName);
252  ofTAF_Gold.open(ofTAF_GoldName);
253  if (!ofTAF_Gold) {
255  "Cannot open the Application Tx gold file: \n\t %s \n",
256  ofTAF_GoldName);
257  return -1;
258  }
259  remove(ofTOE_DataName);
260  if (!ofTOE_Data.is_open()) {
261  ofTOE_Data.open(ofTOE_DataName, ofstream::out);
262  if (!ofTOE_Data) {
263  printError(THIS_NAME, "Cannot open the file: \'%s\'.\n",
264  ofTOE_DataName);
265  }
266  }
267  remove(ofTOE_GoldName);
268  if (!ofTOE_Gold.is_open()) {
269  ofTOE_Gold.open(ofTOE_GoldName, ofstream::out);
270  if (!ofTOE_Gold) {
271  printError(THIS_NAME, "Cannot open the file: \'%s\'.\n",
272  ofTOE_GoldName);
273  return (NTS_KO);
274  }
275  }
276 
278  "############################################################################\n");
280  "## TESTBENCH 'test_tcp_shell' STARTS HERE ##\n");
282  "############################################################################\n\n");
283  if (argc > 1) {
285  "This testbench will be executed with the following parameters: \n");
286  for (int i = 1; i < argc; i++) {
287  printInfo(THIS_NAME, "\t==> Param[%d] = %s\n", (i - 1), argv[i]);
288  }
289  }
290 
291  //-----------------------------------------------------
292  //-- MAIN LOOP
293  //-----------------------------------------------------
294  do {
295  //-------------------------------------------------
296  //-- EMULATE TOE
297  //-------------------------------------------------
298  pTOE(nrErr, ofTAF_Gold, ofTOE_Gold, ofTOE_Data, echoLenOfSegment,
299  testSock, testLenOfSegment,
300  //-- TOE / Ready Signal
301  &sTOE_MMIO_Ready,
302  //-- TOE / Tx Data Interfaces
303  ssTOE_TSIF_Notif, ssTSIF_TOE_DReq,
304  ssTOE_TSIF_Data, ssTOE_TSIF_Meta,
305  //-- TOE / Listen Interfaces
306  ssTSIF_TOE_LsnReq, ssTOE_TSIF_LsnRep,
307  //-- TOE / Tx Data Interfaces
308  ssTSIF_TOE_Data, ssTSIF_TOE_SndReq, ssTOE_TSIF_SndRep,
309  //-- TOE / Open Interfaces
310  ssTSIF_TOE_OpnReq, ssTOE_TSIF_OpnRep);
311 
312  //-------------------------------------------------
313  //-- EMULATE SHELL/MMIO
314  //-------------------------------------------------
315  pMMIO(
316  //-- TOE / Ready Signal
317  &sTOE_MMIO_Ready,
318  //-- MMIO / Enable Layer-7 (.i.e APP alias ROLE)
319  &sMMIO_TSIF_Enable);
320 
321  //-------------------------------------------------
322  //-- RUN DUT
323  //-------------------------------------------------
324  tcp_shell_if(
325  //-- SHELL / Mmio Interface
326  &sMMIO_TSIF_Enable,
327  //-- TAF / Rx & Tx Data Interfaces
328  ssTAF_TSIF_Data, ssTAF_TSIF_SessId, ssTAF_TSIF_DatLen,
329  ssTSIF_TAF_Data, ssTSIF_TAF_SessId, ssTSIF_TAF_DatLen,
330  //-- TOE / Rx Data Interfaces
331  ssTOE_TSIF_Notif, ssTSIF_TOE_DReq, ssTOE_TSIF_Data,
332  ssTOE_TSIF_Meta,
333  //-- TOE / Listen Interfaces
334  ssTSIF_TOE_LsnReq, ssTOE_TSIF_LsnRep,
335  //-- TOE / Tx Data Interfaces
336  ssTSIF_TOE_Data, ssTSIF_TOE_SndReq, ssTOE_TSIF_SndRep,
337  //-- TOE / Tx Open Interfaces
338  ssTSIF_TOE_OpnReq, ssTOE_TSIF_OpnRep,
339  //-- TOE / Close Interfaces
340  ssTSIF_TOE_ClsReq,
341  //-- DEBUG Probes
342  ssTSIF_DBG_SinkCnt,
343  ssTSIF_DBG_InpBufSpace);
344 
345  //-------------------------------------------------
346  //-- EMULATE ROLE/TcpApplicationFlash
347  //-------------------------------------------------
348  pTAF(ofTAF_Data,
349  //-- TSIF / Data Interface
350  ssTSIF_TAF_Data, ssTSIF_TAF_SessId, ssTSIF_TAF_DatLen,
351  //-- TAF / Data Interface
352  ssTAF_TSIF_Data, ssTAF_TSIF_SessId, ssTAF_TSIF_DatLen);
353 
354  //------------------------------------------------------
355  //-- INCREMENT SIMULATION COUNTER
356  //------------------------------------------------------
357  stepSim();
358 
359  } while ((gSimCycCnt < gMaxSimCycles) and (!gFatalError) and (nrErr < 10));
360 
362  "############################################################################\n");
364  "## TESTBENCH 'test_tcp_shell_if' ENDS HERE ##\n");
366  "############################################################################\n");
367  stepSim();
368 
369  //---------------------------------------------------------------
370  //-- DRAIN THE TSIF SINK and FREESPACE COUNTER STREAMS
371  //---------------------------------------------------------------
372  if (not drainDebugSinkCounter(ssTSIF_DBG_SinkCnt, "ssTSIF_DBG_SinkCnt")) {
373  printError(THIS_NAME, "Failed to drain debug sink counter from DUT. \n");
374  nrErr++;
375  }
376  if (not drainDebugCounter(ssTSIF_DBG_InpBufSpace, "ssTSIF_DBG_InpBufSpace")) {
377  printError(THIS_NAME, "Failed to drain debug counter from DUT. \n");
378  nrErr++;
379  }
380 
381  //---------------------------------------------------------------
382  //-- COMPARE RESULT DATA FILE WITH GOLDEN FILE
383  //---------------------------------------------------------------
384  if (ofTAF_Data.tellp() != 0) {
385  int res = system(
386  ("diff --brief -w " + std::string(ofTAF_DataName) + " "
387  + std::string(ofTAF_GoldName) + " ").c_str());
388  if (res != 0) {
389  printError(THIS_NAME, "File \"%s\" differs from file \"%s\" \n",
390  ofTAF_DataName, ofTAF_GoldName);
391  nrErr++;
392  }
393  } else {
394  printError(THIS_NAME, "File \"%s\" is empty.\n", ofTAF_DataName);
395  nrErr++;
396  }
397  if (ofTOE_Data.tellp() != 0) {
398  int res = system(
399  ("diff --brief -w " + std::string(ofTOE_DataName) + " "
400  + std::string(ofTOE_GoldName) + " ").c_str());
401  if (res != 0) {
402  printError(THIS_NAME, "File \"%s\" differs from file \"%s\" \n",
403  ofTOE_DataName, ofTOE_GoldName);
404  nrErr++;
405  }
406  } else {
407  printError(THIS_NAME, "File \"%s\" is empty.\n", ofTOE_DataName);
408  nrErr++;
409  }
410 
411  //---------------------------------------------------------------
412  //-- PRINT TESTBENCH STATUS
413  //---------------------------------------------------------------
414  printf("\n");
416  "This testbench was executed with the following parameters: \n");
417  for (int i = 1; i < argc; i++) {
418  printInfo(THIS_NAME, "\t==> Param[%d] = %s\n", (i - 1), argv[i]);
419  }
420  printf("\n");
421 
422  if (nrErr) {
424  "###########################################################\n");
426  "#### TEST BENCH FAILED : TOTAL NUMBER OF ERROR(S) = %2d ####\n",
427  nrErr);
429  "###########################################################\n");
430  } else {
432  "#############################################################\n");
434  "#### SUCCESSFUL END OF TEST ####\n");
436  "#############################################################\n");
437  }
438 
439  //---------------------------------
440  //-- CLOSING OPEN FILES
441  //---------------------------------
442  ofTAF_Data.close();
443  ofTAF_Gold.close();
444  ofTOE_Data.close();
445  ofTOE_Gold.close();
446 
447  return (nrErr);
448 }
void pTOE(int &nrErr, stream< TcpAppNotif > &soTRIF_Notif, stream< TcpAppRdReq > &siTRIF_DReq, stream< TcpAppData > &soTRIF_Data, stream< TcpAppMeta > &soTRIF_SessId, stream< TcpAppLsnReq > &siTRIF_LsnReq, stream< TcpAppLsnRep > &soTRIF_LsnAck, stream< TcpAppData > &siTRIF_Data, stream< TcpAppSndReq > &siTRIF_SndReq, stream< TcpAppSndRep > &soTRIF_SndRep, stream< TcpAppOpnReq > &siTRIF_OpnReq, stream< TcpAppOpnRep > &soTRIF_OpnRep)
Definition: tb_nal.cpp:840
bool gFatalError
Definition: tb_nal.cpp:152
void stepSim()
Increment the simulation counter.
Definition: test_arp.cpp:54
bool isDottedDecimal(string ipStr)
Checks if a string contains an IP address represented in dot-decimal notation.
Definition: SimNtsUtils.cpp:72
ap_uint< 32 > myDottedDecimalIpToUint32(string ipStr)
Converts an IPv4 address represented with a dotted-decimal string into an UINT32.
ap_uint< 16 > SessionId
Definition: nts_types.hpp:136
ap_uint< 1 > StsBit
Definition: nts_types.hpp:116
ap_uint< 1 > CmdBit
Definition: nts_types.hpp:108
#define printFatal(callerName, format,...)
A macro to print a fatal error message and exit.
Definition: nts_utils.hpp:208
void tcp_shell_if(CmdBit *piSHL_Mmio_En, stream< TcpAppData > &siTAF_Data, stream< TcpSessId > &siTAF_SessId, stream< TcpDatLen > &siTAF_DatLen, stream< TcpAppData > &soTAF_Data, stream< TcpSessId > &soTAF_SessId, stream< TcpDatLen > &soTAF_DatLen, stream< TcpAppNotif > &siSHL_Notif, stream< TcpAppRdReq > &soSHL_DReq, stream< TcpAppData > &siSHL_Data, stream< TcpAppMeta > &siSHL_Meta, stream< TcpAppLsnReq > &soSHL_LsnReq, stream< TcpAppLsnRep > &siSHL_LsnRep, stream< TcpAppData > &soSHL_Data, stream< TcpAppSndReq > &soSHL_SndReq, stream< TcpAppSndRep > &siSHL_SndRep, stream< TcpAppOpnReq > &soSHL_OpnReq, stream< TcpAppOpnRep > &siSHL_OpnRep, stream< TcpAppClsReq > &soSHL_ClsReq, stream< ap_uint< 32 > > &soDBG_SinkCnt, stream< ap_uint< 16 > > &soDBG_InpBufSpace)
TCP Shell Interface (TSIF)
void pMMIO(StsBit *piSHL_Ready, CmdBit *poTSIF_Enable)
Emulate the behavior of the SHELL & MMIO.
unsigned int gSimCycCnt
Definition: tb_nal.cpp:150
bool drainDebugSinkCounter(stream< ap_uint< 32 > > &ss, string ssName)
Empty the DebugSinkCounter stream and throw it away.
const int cNrSessToSend
const int cNrSegToSend
bool drainDebugCounter(stream< T > &ss, string ssName)
Empty a debug stream and throw it away.
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).
out
Definition: test.py:12
Here is the call graph for this function:

◆ pConnect()

void pConnect ( CmdBit piSHL_Enable,
stream< SockAddr > &  siRDp_OpnSockReq,
stream< Ly4Len > &  siRDp_TxCountReq,
stream< Ly4Len > &  soWRp_TxBytesReq,
stream< SessionId > &  soWRp_TxSessId,
stream< TcpAppOpnReq > &  soSHL_OpnReq,
stream< TcpAppOpnRep > &  siSHL_OpnRep,
stream< TcpAppClsReq > &  soSHL_ClsReq 
)

Connect (COn).

Parameters
[in]piSHL_EnableEnable signal from [SHELL].
[in]siRDp_OpnSockReqThe remote socket to connect from ReadPath(RDp).
[in]siRDp_TxCountReqThe #bytes to be transmitted after connection is opened.
[out]soWRp_TxBytesReqThe #bytes to be transmitted to WritePath (WRp).
[out]soWRp_TxSessIdThe session id of the active opened connection to [WRp].
[out]soSHL_OpnReqOpen connection request to [SHELL].
[in]siSHL_OpnRepOpen connection reply from [SHELL].
[out]soSHL_ClsReqClose connection request to [SHELL].

This process connects the FPGA in client mode to a remote server which socket address is specified by 'siRDp_OpnSockReq'. Alternatively, the process is also used to trigger the TxPath (TXp) to transmit a segment to the newly opened connection. The switch between opening a connection and sending traffic a remote host is defined by the value of the 'siRDp_TxCountReq' input: 1) If 'siRDp_TxCountReq' == 0, the process opens a new connection with the remote host specified by 'siRDp_OpnSockReq'. 2) If 'siRDp_TxCountReq' != 0, the process triggers the TxPath (TXp) to transmit a segment to the LAST opened connection. The number of bytes to transmit is specified by 'siRDp_TxCountReq'.

Definition at line 127 of file tcp_shell_if.cpp.

136 {
137  //-- DIRECTIVES FOR THIS PROCESS -------------------------------------------
138  #pragma HLS INLINE off
139  #pragma HLS PIPELINE II=1 enable_flush
140 
141  const char *myName = concat3(THIS_NAME, "/", "COn");
142 
143  //-- STATIC CONTROL VARIABLES (with RESET) --------------------------------
144  static enum FsmStates{ CON_IDLE, CON_RD_RDp, CON_WR_WRp, \
145  CON_OPN_REQ, CON_OPN_REP } \
146  con_fsmState=CON_IDLE;
147  #pragma HLS reset variable=con_fsmState
148  static SockAddr con_testSockAddr;
149  #pragma HLS reset variable=con_testSockAddr
150 
151  //-- STATIC DATAFLOW VARIABLES --------------------------------------------
152  static TcpAppOpnRep con_opnRep;
153  static Ly4Len con_txBytesReq;
154  static ap_uint< 12> con_watchDogTimer;
155 
156  switch (con_fsmState) {
157  case CON_IDLE:
158  if (*piSHL_Enable != 1) {
159  if (!siSHL_OpnRep.empty()) {
160  // Drain any potential status data
161  siSHL_OpnRep.read(con_opnRep);
162  printWarn(myName, "Draining unexpected residue from the \'OpnRep\' stream. As a result, request to close sessionId=%d.\n", con_opnRep.sessId.to_uint());
163  soSHL_ClsReq.write(con_opnRep.sessId);
164  }
165  }
166  else {
167  con_fsmState = CON_RD_RDp;
168  }
169  break;
170  case CON_RD_RDp:
171  if (!siRDp_OpnSockReq.empty() and !siRDp_TxCountReq.empty()) {
172  siRDp_TxCountReq.read(con_txBytesReq);
173  SockAddr currSockAddr = siRDp_OpnSockReq.read();
174  if (con_txBytesReq == 0) {
175  con_fsmState = CON_OPN_REQ;
176  con_testSockAddr = currSockAddr;
177  if (DEBUG_LEVEL & TRACE_CON) {
178  printInfo(myName, "Client is requesting to connect to new remote socket:\n");
179  printSockAddr(myName, con_testSockAddr);
180  }
181  }
182  else if (currSockAddr == con_testSockAddr) {
183  con_fsmState = CON_WR_WRp;
184  if (DEBUG_LEVEL & TRACE_CON) {
185  printInfo(myName, "Client is requesting the FPGA to send %d bytes to the last opened socket:\n", con_txBytesReq.to_uint());
186  printSockAddr(myName, currSockAddr);
187  }
188  }
189  else {
190  con_fsmState = CON_RD_RDp;
191  printInfo(myName, "Client is requesting the FPGA to send traffic to a none opened connection:\n");
192  printSockAddr(myName, currSockAddr);
193  printFatal(myName, "Error.\n");
194  }
195  }
196  break;
197  case CON_OPN_REQ:
198  if (!soSHL_OpnReq.full()) {
199  soSHL_OpnReq.write(con_testSockAddr);
200  #ifndef __SYNTHESIS__
201  con_watchDogTimer = 250;
202  #else
203  con_watchDogTimer = 10000;
204  #endif
205  con_fsmState = CON_OPN_REP;
206  }
207  break;
208  case CON_OPN_REP:
209  con_watchDogTimer--;
210  if (!siSHL_OpnRep.empty()) {
211  // Read the reply stream
212  siSHL_OpnRep.read(con_opnRep);
213  if (con_opnRep.tcpState == ESTABLISHED) {
214  if (DEBUG_LEVEL & TRACE_CON) {
215  printInfo(myName, "Client successfully established connection.\n");
216  }
217  }
218  else {
219  printError(myName, "Client failed to establish connection with remote socket (TCP state is '%s'):\n",
220  getTcpStateName(con_opnRep.tcpState));
221  }
222  con_fsmState = CON_IDLE;
223  }
224  else {
225  if (con_watchDogTimer == 0) {
226  if (DEBUG_LEVEL & TRACE_CON) {
227  printError(myName, "Timeout: Failed to establish connection.\n");
228  }
229  #ifndef __SYNTHESIS__
230  con_watchDogTimer = 250;
231  #else
232  con_watchDogTimer = 10000;
233  #endif
234  }
235  }
236  break;
237  case CON_WR_WRp:
238  if(!soWRp_TxBytesReq.full() and !soWRp_TxSessId.full()) {
239  //-- Request [WRp] to start the xmit test
240  soWRp_TxBytesReq.write(con_txBytesReq);
241  soWRp_TxSessId.write(con_opnRep.sessId);
242  con_fsmState = CON_IDLE;
243  }
244  break;
245  }
246 }
SessionId sessId
Definition: nts.hpp:167
TcpState tcpState
Definition: nts.hpp:168
ap_uint< 16 > Ly4Len
Definition: nts_types.hpp:202
void printSockAddr(const char *callerName, SockAddr sockAddr)
Print a socket address.
Definition: nts_utils.cpp:174
const char * getTcpStateName(TcpState tcpState)
Returns the name of an enum-based TCP-State as a user friendly string.
Definition: nts_utils.cpp:272
@ ESTABLISHED
Definition: nts_types.hpp:296
#define TRACE_CON
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pInputReadBuffer()

void pInputReadBuffer ( CmdBit piSHL_Enable,
stream< TcpAppData > &  siSHL_Data,
stream< TcpAppMeta > &  siSHL_Meta,
stream< TcpAppData > &  soRDp_Data,
stream< TcpAppMeta > &  soRDp_Meta 
)

Input Read Buffer (IRb)

Parameters
[in]piSHL_EnableEnable signal from [SHELL].
[in]siSHL_DataData stream from [SHELL].
[in]siSHL_MetaSession Id from [SHELL].
[out]soRDp_DataData stream to ReadPath (RDp).
[out]soRDp_MetaMetadata stream [RDp].

This process implements an input FIFO buffer as a stream. The goal is to provision a buffer to store all the bytes that were requested by the ReadRequestHandler (RRh) process. FYI, if this user process does not absorb the incoming data stream fast enough, the [TOE] will start dropping segments on his side to avoid any blocking situation.

Definition at line 1033 of file tcp_shell_if.cpp.

1039 {
1040  //-- DIRECTIVES FOR THIS PROCESS -------------------------------------------
1041  #pragma HLS INLINE off
1042  #pragma HLS PIPELINE II=1 enable_flush
1043 
1044  const char *myName = concat3(THIS_NAME, "/", "IRb");
1045 
1046  if (*piSHL_Enable != 1) {
1047  return;
1048  }
1049 
1050  if (!siSHL_Meta.empty() and !soRDp_Meta.full()) {
1051  soRDp_Meta.write(siSHL_Meta.read());
1052  }
1053  if (!siSHL_Data.empty() and !soRDp_Data.full()) {
1054  soRDp_Data.write(siSHL_Data.read());
1055  }
1056 
1057 }
Here is the caller graph for this function:

◆ pListen()

void pListen ( CmdBit piSHL_Enable,
stream< TcpAppLsnReq > &  soSHL_LsnReq,
stream< TcpAppLsnRep > &  siSHL_LsnRep 
)

Listen(LSn)

Parameters
[in]piSHL_EnableEnable signal from [SHELL].
[out]soSHL_LsnReqListen port request to [SHELL].
[in]siSHL_LsnRepListen port reply from [SHELL].
Warning
This process requests the SHELL/NTS/TOE to start listening for incoming connections on a specific port (.i.e, open connection in server mode). By default, the port numbers 5001, 5201, 8800 to 8803 will always be opened in listen mode at startup. Later on, we should be able to open more ports if we provide some configuration register for the user to specify new ones. FYI - The PortTable (PRt) of the SHELL/NTS/TOE supports two port ranges; one for static ports (0 to 32,767) which are used for listening ports, and one for dynamically assigned or ephemeral ports (32,768 to 65,535) which are used for active connections. Therefore, listening port numbers must always fall in the range 0 to 32,767.

Definition at line 267 of file tcp_shell_if.cpp.

271 {
272  //-- DIRECTIVES FOR THIS PROCESS -------------------------------------------
273  #pragma HLS INLINE off
274  #pragma HLS PIPELINE II=1 enable_flush
275 
276  const char *myName = concat3(THIS_NAME, "/", "LSn");
277 
278  //-- STATIC CONTROL VARIABLES (with RESET) ---------------------------------
279  static enum FsmStates { LSN_IDLE, LSN_SEND_REQ, LSN_WAIT_REP, LSN_DONE } \
280  lsn_fsmState=LSN_IDLE;
281  #pragma HLS reset variable=lsn_fsmState
282  static ap_uint<3> lsn_i = 0;
283  #pragma HLS reset variable=lsn_i
284 
285  //-- STATIC ARRAYS --------------------------------------------------------
286  static const TcpPort LSN_PORT_TABLE[6] = { RECV_MODE_LSN_PORT, XMIT_MODE_LSN_PORT,
289  #pragma HLS RESOURCE variable=LSN_PORT_TABLE core=ROM_1P
290 
291  //-- STATIC DATAFLOW VARIABLES ---------------------------------------------
292  static ap_uint<8> lsn_watchDogTimer;
293 
294  switch (lsn_fsmState) {
295  case LSN_IDLE:
296  if (*piSHL_Enable != 1) {
297  return;
298  }
299  else {
300  if (lsn_i == 0) {
301  lsn_fsmState = LSN_SEND_REQ;
302  }
303  else {
304  //-- Port are already opened
305  lsn_fsmState = LSN_DONE;
306  }
307  }
308  break;
309  case LSN_SEND_REQ:
310  if (!soSHL_LsnReq.full()) {
311  switch (lsn_i) {
312  case 0:
313  soSHL_LsnReq.write(RECV_MODE_LSN_PORT);
314  break;
315  case 1:
316  soSHL_LsnReq.write(XMIT_MODE_LSN_PORT);
317  break;
318  case 2:
319  soSHL_LsnReq.write(ECHO_MOD2_LSN_PORT);
320  break;
321  case 3:
322  soSHL_LsnReq.write(ECHO_MODE_LSN_PORT);
323  break;
324  case 4:
325  soSHL_LsnReq.write(IPERF_LSN_PORT);
326  break;
327  case 5:
328  soSHL_LsnReq.write(IPREF3_LSN_PORT);
329  break;
330  }
331  if (DEBUG_LEVEL & TRACE_LSN) {
332  printInfo(myName, "Server is requested to listen on port #%d (0x%4.4X).\n",
333  LSN_PORT_TABLE[lsn_i].to_uint(), LSN_PORT_TABLE[lsn_i].to_uint());
334  }
335  #ifndef __SYNTHESIS__
336  lsn_watchDogTimer = 10;
337  #else
338  lsn_watchDogTimer = 100;
339  #endif
340  lsn_fsmState = LSN_WAIT_REP;
341  }
342  else {
343  printWarn(myName, "Cannot send a listen port request to [TOE] because stream is full!\n");
344  }
345  break;
346  case LSN_WAIT_REP:
347  lsn_watchDogTimer--;
348  if (!siSHL_LsnRep.empty()) {
349  TcpAppLsnRep listenDone;
350  siSHL_LsnRep.read(listenDone);
351  if (listenDone) {
352  if (DEBUG_LEVEL & TRACE_LSN) {
353  printInfo(myName, "Received OK listen reply from [TOE] for port %d.\n", LSN_PORT_TABLE[lsn_i].to_uint());
354  }
355  if (lsn_i == sizeof(LSN_PORT_TABLE)/sizeof(LSN_PORT_TABLE[0])-1) {
356  lsn_fsmState = LSN_DONE;
357  }
358  else {
359  //-- Set next listen port number
360  lsn_i += 1;
361  lsn_fsmState = LSN_SEND_REQ;
362  }
363  }
364  else {
365  printWarn(myName, "TOE denied listening on port %d (0x%4.4X).\n",
366  LSN_PORT_TABLE[lsn_i].to_uint(), LSN_PORT_TABLE[lsn_i].to_uint());
367  lsn_fsmState = LSN_SEND_REQ;
368  }
369  }
370  else {
371  if (lsn_watchDogTimer == 0) {
372  printError(myName, "Timeout: Server failed to listen on port %d (0x%4.4X).\n",
373  LSN_PORT_TABLE[lsn_i].to_uint(), LSN_PORT_TABLE[lsn_i].to_uint());
374  lsn_fsmState = LSN_SEND_REQ;
375  }
376  }
377  break;
378  case LSN_DONE:
379  break;
380  } // End-of: switch()
381 } // End-of: pListen()
@ LSN_IDLE
Definition: nal.hpp:146
@ LSN_SEND_REQ
Definition: nal.hpp:146
@ LSN_DONE
Definition: nal.hpp:146
RepBool TcpAppLsnRep
Definition: nts.hpp:196
ap_uint< 16 > TcpPort
Definition: AxisTcp.hpp:105
#define RECV_MODE_LSN_PORT
#define XMIT_MODE_LSN_PORT
#define ECHO_MOD2_LSN_PORT
#define IPERF_LSN_PORT
#define IPREF3_LSN_PORT
#define ECHO_MODE_LSN_PORT
#define TRACE_LSN
Here is the caller graph for this function:

◆ pMMIO()

void pMMIO ( StsBit piSHL_Ready,
CmdBit poTSIF_Enable 
)

Emulate the behavior of the SHELL & MMIO.

Parameters
[in]piSHL_ReadyReady signal from [SHELL].
[out]poTSIF_EnableEnable signal to TSIF.

Definition at line 211 of file simu_tcp_shell_if_env.cpp.

213  {
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 }
Here is the caller graph for this function:

◆ pReadNotificationHandler()

void pReadNotificationHandler ( CmdBit piSHL_Enable,
stream< TcpAppNotif > &  siSHL_Notif,
stream< TcpAppNotif > &  soRRh_Notif 
)

Read Notification Handler (RNh)

Parameters
[in]piSHL_EnableEnable signal from [SHELL].
[in]siSHL_NotifA new Rx data notification from [SHELL].
[out]soRRh_NotifThe notification forwarded to ReadRequestHandler (RRh).

This process waits for a notification from [TOE] indicating the availability of new data for the TcpApplication Flash (TAF) process of the [ROLE]. If the TCP segment length of the notification message is greater than 0, the data segment is valid and the notification is accepted. The notification is then pushed into a FIFO for later processing by the [RRh]. This process runs with II=1 in order to never miss an incoming notification.

Definition at line 1074 of file tcp_shell_if.cpp.

1078 {
1079  //-- DIRECTIVES FOR THIS PROCESS -------------------------------------------
1080  #pragma HLS INLINE off
1081  #pragma HLS PIPELINE II=1 enable_flush
1082 
1083  const char *myName = concat3(THIS_NAME, "/", "RNh");
1084 
1085  if (*piSHL_Enable != 1) {
1086  return;
1087  }
1088 
1089  if (!siSHL_Notif.empty()) {
1090  TcpAppNotif notif;
1091  siSHL_Notif.read(notif);
1092  if (notif.tcpDatLen == 0) {
1093  printFatal(myName, "Received a notification for a TCP segment of length 'zero'. Don't know what to do with it!\n");
1094  }
1095  if (!soRRh_Notif.full()) {
1096  soRRh_Notif.write(notif);
1097  }
1098  else {
1099  printFatal(myName, "The Rx Notif FiFo is full. Consider increasing the depth of this FiFo.\n");
1100  }
1101  }
1102 }
TcpDatLen tcpDatLen
Definition: nts.hpp:90
Here is the caller graph for this function:

◆ pReadPath()

void pReadPath ( CmdBit piSHL_Enable,
stream< TcpAppData > &  siSHL_Data,
stream< TcpAppMeta > &  siSHL_Meta,
stream< ForwardCmd > &  siRRh_FwdCmd,
stream< SockAddr > &  soCOn_OpnSockReq,
stream< TcpDatLen > &  soCOn_TxCountReq,
stream< SigBit > &  soRRh_DequSig,
stream< TcpAppData > &  soTAF_Data,
stream< TcpSessId > &  soTAF_SessId,
stream< TcpDatLen > &  soTAF_DatLen,
stream< ap_uint< 32 > > &  soDBG_SinkCount 
)

Read Path (RDp)

Parameters
[in]piSHL_EnableEnable signal from [SHELL].
[in]siSHL_DataData stream from [SHELL].
[in]siSHL_MetaSession Id from [SHELL].
[in]siRRh_FwdCmdA command to keep/drop a stream from ReadRequestHandler (RRh).
[out]soCOn_OpnSockReqThe remote socket to open to Connect (COn).
[out]soCOn_TxCountReqThe #bytes to be transmitted once connection is opened by [COn].
[out]soRRh_DequSigSignals the dequeue of a chunk to ReadRequestHandler (RRh).
[out]soTAF_DataData stream to [TAF].
[out]soTAF_SessIdThe session-id to [TAF].
[out]soTAF_DatLenThe data-length to [TAF].
[out]soDBG_SinkCountCounts the number of sinked bytes (for debug).

This process waits for new data to read and either forwards them to the TcpApplicationFlash (TAF) process or drops them based on the 'action' field of the 'siRRh_FwdCmd' command.

  • If the action is 'CMD_KEEP', the stream is forwarded to the next layer. As such, [RDp] implements a pipe for the TCP traffic from [SHELL] to [TAF].
  • If the action is 'CMD_DROP' the field 'opCOde' becomes meaningful and may specify additional sub-options:
    • If the op-code is 'NOP', simply drop the stream and do nothing more.
    • If the op-code is 'GEN', extract the remote socket to connect to as well as the number of bytes to transmit out of the 64 first incoming bits of the data stream. Next, drop the rest of that stream and forward the extracted fields to the Connect (COn) process.

Definition at line 1347 of file tcp_shell_if.cpp.

1359 {
1360  //-- DIRECTIVES FOR THIS PROCESS -------------------------------------------
1361  #pragma HLS INLINE off
1362  #pragma HLS PIPELINE II=1 enable_flush
1363 
1364  const char *myName = concat3(THIS_NAME, "/", "RDp");
1365 
1366  //-- STATIC CONTROL VARIABLES (with RESET) ---------------------------------
1367  static enum FsmStates { RDP_IDLE=0, RDP_8801,
1368  RDP_FWD_META, RDP_FWD_STREAM,
1369  RDP_SINK_META, RDP_SINK_STREAM } \
1370  rdp_fsmState=RDP_IDLE;
1371  #pragma HLS reset variable=rdp_fsmState
1372  static ap_uint<32> rdp_sinkCnt=0;
1373  #pragma HLS reset variable=rdp_sinkCnt
1374 
1375  //-- STATIC VARIABLES ------------------------------------------------------
1376  static ForwardCmd rdp_fwdCmd;
1377  static TcpSessId rdp_sessId;
1378 
1379  //-- DYNAMIC VARIABLES -----------------------------------------------------
1380  TcpAppData appData;
1381 
1382  if (*piSHL_Enable != 1) {
1383  return;
1384  }
1385 
1386  switch (rdp_fsmState ) {
1387  case RDP_IDLE:
1388  if (!siRRh_FwdCmd.empty() and !siSHL_Meta.empty()) {
1389  siRRh_FwdCmd.read(rdp_fwdCmd);
1390  siSHL_Meta.read(rdp_sessId);
1391  if ((rdp_fwdCmd.action == CMD_KEEP) and (rdp_fwdCmd.sessId == rdp_sessId)) {
1392  rdp_fsmState = RDP_FWD_META;
1393  }
1394  else {
1395  rdp_fsmState = RDP_SINK_META;
1396  }
1397  }
1398  break;
1399  case RDP_FWD_META:
1400  if (!soTAF_SessId.full() and !soTAF_DatLen.full()) {
1401  soTAF_SessId.write(rdp_sessId);
1402  soTAF_DatLen.write(rdp_fwdCmd.datLen);
1403  if (DEBUG_LEVEL & TRACE_RDP) {
1404  printInfo(myName, "soTAF_SessId = %d \n", rdp_sessId.to_uint());
1405  printInfo(myName, "soTAF_DatLen = %d \n", rdp_fwdCmd.datLen.to_uint());
1406  }
1407  rdp_fsmState = RDP_FWD_STREAM;
1408  }
1409  break;
1410  case RDP_FWD_STREAM:
1411  if (!siSHL_Data.empty() and !soTAF_Data.full()) {
1412  siSHL_Data.read(appData);
1413  soRRh_DequSig.write(1);
1414  soTAF_Data.write(appData);
1415  if (DEBUG_LEVEL & TRACE_RDP) { printAxisRaw(myName, "soTAF_Data =", appData); }
1416  if (appData.getTLast()) {
1417  rdp_fsmState = RDP_IDLE;
1418  }
1419  }
1420  break;
1421  case RDP_SINK_META:
1422  if (rdp_fwdCmd.dropCode == GEN) {
1423  rdp_fsmState = RDP_8801;
1424  }
1425  else {
1426  rdp_fsmState = RDP_SINK_STREAM;
1427  }
1428  break;
1429  case RDP_SINK_STREAM:
1430  if (!siSHL_Data.empty()) {
1431  siSHL_Data.read(appData);
1432  soRRh_DequSig.write(1);
1433  if (DEBUG_LEVEL & TRACE_RDP) { printAxisRaw(myName, "Sink Data =", appData); }
1434  rdp_sinkCnt += appData.getLen();
1435  soDBG_SinkCount.write(rdp_sinkCnt);
1436  if (appData.getTLast()) {
1437  rdp_fsmState = RDP_IDLE;
1438  }
1439  }
1440  break;
1441  case RDP_8801:
1442  if (!siSHL_Data.empty() and !soCOn_OpnSockReq.full() and !soCOn_TxCountReq.full()) {
1443  // Extract the remote socket address and the requested #bytes to transmit
1444  siSHL_Data.read(appData);
1445  soRRh_DequSig.write(1);
1446  SockAddr sockToOpen(byteSwap32(appData.getLE_TData(31, 0)), // IP4 address
1447  byteSwap16(appData.getLE_TData(47, 32))); // TCP port
1448  TcpDatLen bytesToSend = byteSwap16(appData.getLE_TData(63, 48));
1449  soCOn_OpnSockReq.write(sockToOpen);
1450  soCOn_TxCountReq.write(bytesToSend);
1451  if (DEBUG_LEVEL & TRACE_RDP) {
1452  printInfo(myName, "Received request for Tx test mode to generate a segment of length=%d and to send it to socket:\n",
1453  bytesToSend.to_int());
1454  printSockAddr(myName, sockToOpen);
1455  }
1456  if (appData.getTLast()) {
1457  rdp_fsmState = RDP_IDLE;
1458  }
1459  else {
1460  rdp_fsmState = RDP_SINK_STREAM;
1461  }
1462  }
1463  }
1464 }
tLast getTLast() const
Definition: AxisRaw.hpp:219
LE_tData getLE_TData(int leHi=64 -1, int leLo=0) const
Definition: AxisRaw.hpp:260
int getLen() const
Definition: AxisRaw.hpp:411
SessionId sessId
DropCode dropCode
TcpDatLen datLen
void printAxisRaw(const char *callerName, AxisRaw chunk)
Prints an Axis raw data chunk (used for debugging).
Definition: nts_utils.cpp:46
ap_uint< 16 > TcpDatLen
Definition: AxisTcp.hpp:123
#define CMD_KEEP
Definition: nts_types.hpp:62
ap_uint< 16 > TcpSessId
Definition: nts_types.hpp:137
#define TRACE_RDP
ap_uint< 32 > byteSwap32(ap_uint< 32 > inputVector)
Definition: udp.cpp:78
ap_uint< 16 > byteSwap16(ap_uint< 16 > inputVector)
Definition: udp.cpp:82
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pReadRequestHandler()

void pReadRequestHandler ( CmdBit piSHL_Enable,
stream< TcpAppNotif > &  siRNh_Notif,
stream< SigBit > &  siRDp_DequSig,
stream< TcpAppRdReq > &  soRRm_DReq,
stream< ForwardCmd > &  soRDp_FwdCmd,
stream< ap_uint< 16 > > &  soDBG_freeSpace 
)

Read Request Handler (RRh)

Parameters
[in]piSHL_EnableEnable signal from [SHELL].
[in]siRNh_NotifA new Rx data notification from ReadNotifHandler (RNh).
[in]siRDp_DequSigSignals the dequeue of a chunk from ReadPath (RDp).
[out]soRRm_DReqA data read request to ReadRequestMover (RRm).
[out]soRDp_FwdCmdA command telling the ReadPath (RDp) to keep/drop a stream.

The [RRh] consists of 2 sub-processes: 1) pRxBufferManager (Rbm) keeps tracks of the free space in the Rx buffer. 2) pRxDataRequester (Rdr) dequeues the notifications from a FiFo, assesses the available space in the Rx buffer and requests one or multiple data read requests from the [SHELL] accordingly. The rule is as follows: #RequestedBytes = min(NotifDatLen, max(AvailableSpace, cMinDataReqLen).

For testing purposes, the TCP destination port is also evaluated here and one of the following actions is taken upon its value:

  • 8800 : The RxPath (RXp) process is requested to dump/sink this segment. This is an indirect way for a remote client to run iPerf on that FPGA port used here as a server.
  • 8801 : The TxPath (TXp) is expected to open an active connection and to send an certain amount of bytes to the producer of this request. It is the responsibility of the RxPath (RXp) to extract the TCP destination socket {IpAddr, PortNum} and the #bytes to transmit, out of the 64 first bits of the segment and to forward these data to the Connect (COn) process. The [COn] will then open an active connection before triggering the WritePath (WRp) to send the requested amount of bytes on the new connection.
  • 5001 : [TBD]
  • 5201 : [TBD]
  • Others: The RXp process is requested to forward these data and metadata streams to the TcpApplicationFlash (TAF).

Definition at line 1140 of file tcp_shell_if.cpp.

1147 {
1148  //-- DIRECTIVES FOR THIS PROCESS -------------------------------------------
1149  #pragma HLS INLINE off
1150 
1151  const char *myName = concat3(THIS_NAME, "/", "RRh");
1152 
1153  //-- LOCAL STATIC VARIABLES W/ RESET ---------------------------------------
1154  static enum FsmStates { RRH_IDLE, RRH_GEN_DLEN, RRH_SEND_DREQ} \
1155  rrh_fsmState=RRH_IDLE;
1156  #pragma HLS reset variable=rrh_fsmState
1157  static ap_uint<log2Ceil<cIBuffBytes>::val+1> rrh_freeSpace=cIBuffBytes;
1158  #pragma HLS reset variable=rrh_freeSpace
1159 
1160  //-- STATIC VARIABLES ------------------------------------------------------
1161  static TcpAppNotif rrh_notif;
1162  static TcpDatLen rrh_datLenReq;
1163 
1164  if (*piSHL_Enable != 1) {
1165  return;
1166  }
1167 
1168  //-- MAIN PROCESS ----------------------------------------------------------
1169  switch(rrh_fsmState) {
1170  case RRH_IDLE:
1171  //-- Always handle dequeue signal
1172  if (!siRDp_DequSig.empty()) {
1173  siRDp_DequSig.read();
1174  rrh_freeSpace += (ARW/8);
1175  if (DEBUG_LEVEL & TRACE_RRH) {
1176  printInfo(myName, "FreeSpace=%4d bytes\n", rrh_freeSpace.to_uint());
1177  }
1178  }
1179  if (!siRNh_Notif.empty()) {
1180  siRNh_Notif.read(rrh_notif);
1181  rrh_fsmState = RRH_GEN_DLEN;
1182  if (DEBUG_LEVEL & TRACE_RRH) {
1183  printInfo(myName, "Received a new notification (SessId=%2d | DatLen=%4d | TcpDstPort=%4d).\n",
1184  rrh_notif.sessionID.to_uint(), rrh_notif.tcpDatLen.to_uint(), rrh_notif.tcpDstPort.to_uint());
1185  }
1186  }
1187  break;
1188  case RRH_GEN_DLEN:
1189  if (rrh_freeSpace >= cMinDataReqLen) {
1190  //-- Issue a new SEND request = max(rdr_notif.byteCnt, rrh_freeSpace)
1191  if (rrh_freeSpace < rrh_notif.tcpDatLen) {
1192  //-- Requested bytes = rrh_freeSpace
1193  rrh_datLenReq = rrh_freeSpace;
1194  rrh_notif.tcpDatLen -= rrh_freeSpace;
1195  //-- Handle dequeue signal
1196  if (!siRDp_DequSig.empty()) {
1197  siRDp_DequSig.read();
1198  rrh_freeSpace += (ARW/8);
1199  }
1200  else {
1201  rrh_freeSpace = 0;
1202  }
1203  }
1204  else {
1205  //-- Requested bytes = rdr_notif.byteCnt
1206  rrh_datLenReq = rrh_notif.tcpDatLen;
1207  rrh_freeSpace -= (rrh_notif.tcpDatLen) & ~((TcpDatLen)(ARW/8-1));
1208  if (rrh_notif.tcpDatLen & (TcpDatLen)((ARW/8)-1)) {
1209  // The requested length is not aligned w/ the input buffer
1210  // width and this will consume another input buffer chunk.
1211  rrh_freeSpace -= (ARW/8);
1212  //-- Handle dequeue signal
1213  if (!siRDp_DequSig.empty()) {
1214  siRDp_DequSig.read();
1215  rrh_freeSpace += (ARW/8);
1216  }
1217  }
1218  rrh_notif.tcpDatLen = 0;
1219  }
1220  rrh_fsmState = RRH_SEND_DREQ;
1221  }
1222  else {
1223  if (DEBUG_LEVEL & TRACE_RRH) {
1224  printInfo(myName, "FreeSpace=%4d is too low. Waiting for buffer to drain. \n",
1225  rrh_freeSpace.to_uint());
1226  }
1227  //-- Handle dequeue signal
1228  if (!siRDp_DequSig.empty()) {
1229  siRDp_DequSig.read();
1230  rrh_freeSpace += (ARW/8);
1231  }
1232  }
1233  // Debug Trace
1234  if (DEBUG_LEVEL & TRACE_RRH) {
1235  printInfo(myName, "DataLenReq=%4d | FreeSpace=%4d | NotifBytes=%4d \n",
1236  rrh_datLenReq.to_uint(), rrh_freeSpace.to_uint(), rrh_notif.tcpDatLen.to_uint());
1237  }
1238  break;
1239  case RRH_SEND_DREQ:
1240  //-- Always handle dequeue signal
1241  if (!siRDp_DequSig.empty()) {
1242  siRDp_DequSig.read();
1243  rrh_freeSpace += (ARW/8);
1244  if (DEBUG_LEVEL & TRACE_RRH) {
1245  printInfo(myName, "FreeSpace=%4d bytes\n", rrh_freeSpace.to_uint());
1246  }
1247  }
1248  if (!soRRm_DReq.full() and !soRDp_FwdCmd.full()) {
1249  soRRm_DReq.write(TcpAppRdReq(rrh_notif.sessionID, rrh_datLenReq));
1250  switch (rrh_notif.tcpDstPort) {
1251  case RECV_MODE_LSN_PORT: // 8800
1252  soRDp_FwdCmd.write(ForwardCmd(rrh_notif.sessionID, rrh_datLenReq, CMD_DROP, NOP));
1253  break;
1254  case XMIT_MODE_LSN_PORT: // 8801
1255  soRDp_FwdCmd.write(ForwardCmd(rrh_notif.sessionID, rrh_datLenReq, CMD_DROP, GEN));
1256  break;
1257  default:
1258  soRDp_FwdCmd.write(ForwardCmd(rrh_notif.sessionID, rrh_datLenReq, CMD_KEEP, NOP));
1259  break;
1260  }
1261  if (rrh_notif.tcpDatLen == 0) {
1262  rrh_fsmState = RRH_IDLE;
1263  if (DEBUG_LEVEL & TRACE_RRH) {
1264  printInfo(myName, "Done with notification (SessId=%2d | DatLen=%4d | TcpDstPort=%4d).\n",
1265  rrh_notif.sessionID.to_uint(), rrh_notif.tcpDatLen.to_uint(), rrh_notif.tcpDstPort.to_uint());
1266  }
1267  }
1268  else {
1269  rrh_fsmState = RRH_GEN_DLEN;
1270  }
1271  if (DEBUG_LEVEL & TRACE_RRH) {
1272  printInfo(myName, "Sending DReq(SessId=%2d, DatLen=%4d) to SHELL (requested TcpDstPort was %4d).\n",
1273  rrh_notif.sessionID.to_uint(), rrh_datLenReq.to_uint(), rrh_notif.tcpDstPort.to_uint());
1274  }
1275  }
1276  break;
1277  }
1278 
1279  //-- ALWAYS -------------------------------------------
1280  if (!soDBG_freeSpace.full()) {
1281  soDBG_freeSpace.write(rrh_freeSpace);
1282  }
1283  else {
1284  printFatal(myName, "Cannot write soDBG_freeSpace stream...");
1285  }
1286 
1287 }
SessionId sessionID
Definition: nts.hpp:89
TcpPort tcpDstPort
Definition: nts.hpp:93
#define ARW
Definition: AxisRaw.hpp:114
#define CMD_DROP
Definition: nts_types.hpp:61
const int cMinDataReqLen
#define TRACE_RRH
Here is the caller graph for this function:

◆ pReadRequestMover()

void pReadRequestMover ( CmdBit piSHL_Enable,
stream< TcpAppRdReq > &  siRRh_DReq,
stream< TcpAppRdReq > &  soSHL_DReq 
)

Read Request Mover (RRm)

Parameters
[out]siRRh_DReqA data read request from ReadRequestHandler (RRh).
[out]soSHL_DReqThe TCP data request forwarded to [SHELL].

Dequeues the read requests form a FiFo and forwards them to the [SHELL] in blocking read and write access modes.

Definition at line 1299 of file tcp_shell_if.cpp.

1303 {
1304  //-- DIRECTIVES FOR THIS PROCESS -------------------------------------------
1305  #pragma HLS INLINE off
1306  #pragma HLS PIPELINE II=1 enable_flush
1307 
1308  if (*piSHL_Enable != 1) {
1309  return;
1310  }
1311  if (!siRRh_DReq.empty()) {
1312  pStreamDataMover(siRRh_DReq, soSHL_DReq);
1313  }
1314 }
void pStreamDataMover(stream< Type > &si, stream< Type > &so)
Stream Data Mover - Moves data chunks from incoming stream to outgoing stream with blocking read and ...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pStreamDataMover()

template<class Type >
void pStreamDataMover ( stream< Type > &  si,
stream< Type > &  so 
)

Stream Data Mover - Moves data chunks from incoming stream to outgoing stream with blocking read and write access methods.

Parameters
[in]siStream in.
[out]soStream out.

Definition at line 91 of file tcp_shell_if.cpp.

94 {
95  #pragma HLS INLINE
96  Type currChunk;
97  si.read(currChunk); // Blocking read
98  so.write(currChunk); // Blocking write
99  // [TODO] so.write(si.read());
100 }
Here is the caller graph for this function:

◆ pTAF()

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).

Parameters
[in]ofTAF_DataA ref to the output TxApp file to write to.
[in]siTSIF_DataData stream from TcpShellInterface (TSIF).
[in]siTSIF_SessIdSession-id from [TSIF].
[in]siTSIF_DatLenData-length from [TSIF].
[out]soTSIF_DataData stream to [TSIF].
[out]soTSIF_SessIdSession-id to [TSIF].
[out]soTSIF_DatLenData-length to [TSIF].

ALWAYS READ INCOMING DATA STREAM AND STORE IT TO FILE.

SIMULATION ENVIRONMENT FUNCTIONS

Definition at line 175 of file simu_tcp_shell_if_env.cpp.

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 }
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 TRACE_TAF
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pTOE()

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).

Parameters
[in]nrErrA ref to the error counter of main.
[in]ofTAF_GoldA ref to the TAF gold file to write.
[in]ofTOE_GoldA ref to the TOE gold file to write.
[in]ofTOE_DataA ref to the TOE data file to write.
[in]echoDatLenThe length of the echo data to generate.
[in]testSockThe destination socket to send traffic to.
[in]tcpDataLenThe length of the TCP payload to generate.
[out]poMMIO_ReadyReady signal to [MMIO].
[out]soTSIF_NotifNotification to TcpShellInterface (TSIF).
[in]siTSIF_DReqData read request from [TSIF].
[out]soTSIF_DataData to [TSIF].
[out]soTSIF_MetaSession Id to [TSIF].
[in]siTSIF_LsnReqListen port request from [TSIF].
[out]soTSIF_LsnRepListen port reply to [TSIF].

Definition at line 248 of file simu_tcp_shell_if_env.cpp.

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 }
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
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.
ap_uint< 16 > TcpSegLen
Definition: AxisTcp.hpp:121
ap_uint< 32 > Ip4Addr
Definition: AxisIp4.hpp:169
TcpPort TcpAppLsnReq
Definition: nts.hpp:190
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 TLAST
Definition: AxisRaw.hpp:116
@ NO_ERROR
Definition: nts_types.hpp:304
@ NO_CONNECTION
Definition: nts_types.hpp:304
@ NO_SPACE
Definition: nts_types.hpp:304
#define DONE
#define GEN_CHK0
#define TRACE_TOE_LSN
#define GEN_CHK1
const int cSimToeStartupDelay
#define TRACE_TOE_RXP
#define TRACE_TOE_TXP
#define TRACE_TOE_OPN
#define DEFAULT_HOST_TCP_SRC_PORT
#define TRACE_TOE
#define TRACE_ALL
Here is the call graph for this function:

◆ pWritePath()

void pWritePath ( CmdBit piSHL_Enable,
stream< TcpAppData > &  siTAF_Data,
stream< TcpSessId > &  siTAF_SessId,
stream< TcpDatLen > &  siTAF_DatLen,
stream< TcpDatLen > &  siCOn_TxBytesReq,
stream< SessionId > &  siCOn_TxSessId,
stream< TcpAppData > &  soSHL_Data,
stream< TcpAppSndReq > &  soSHL_SndReq,
stream< TcpAppSndRep > &  siSHL_SndRep 
)

Write Path (WRp)

Parameters
[in]piSHL_EnableEnable signal from [SHELL].
[in]siTAF_DataTx data stream from [ROLE/TAF].
[in]siTAF_SessIdThe session Id from [ROLE/TAF].
[in]siTAF_DatLenThe data length from [ROLE/TAF].
[in]siCOn_TxBytesReqThe #bytes to be transmitted on the active opened connection from Connect(COn).
[in]siCOn_SessIdThe session id of the active opened connection from [COn].
[out]soSHL_DataTx data to [SHELL].
[out]soSHL_SndReqRequest to send to [SHELL].
[in]siSHL_SndRepSend reply from [SHELL].

This process waits for new data to be forwarded from the TcpAppFlash (TAF) or for a transmit test command from Connect(COn). Upon reception of one of these two requests, the process issues a request to send message and waits for its reply. A request to send consists of a session-id and a data-length information. A send reply consists of a session-id, a data-length, the amount of space left in TCP Tx buffer and an error code. 1) If the return code is 'NO_ERROR', the process is allowed to send the amount of requested bytes. 2) If the return code is 'NO_SPACE', there is not enough space available in the TCP Tx buffer of the session. The process will retry its request after a short delay but may give up after a maximum number f trials. 3) If the return code is 'NO_CONNECTION', the process will abandon the transmission because there is no established connection for session-id.

Definition at line 1496 of file tcp_shell_if.cpp.

1506 {
1507  //-- DIRECTIVES FOR THIS PROCESS -------------------------------------------
1508  #pragma HLS INLINE off
1509  #pragma HLS PIPELINE II=1 enable_flush
1510 
1511  const char *myName = concat3(THIS_NAME, "/", "WRp");
1512 
1513  //-- STATIC CONTROL VARIABLES (with RESET) ---------------------------------
1514  static enum FsmStates { WRP_IDLE=0, WRP_RTS, WRP_RTS_REP,
1515  WRP_STREAM, WRP_TXGEN, WRP_DRAIN } \
1516  wrp_fsmState=WRP_IDLE;
1517  #pragma HLS reset variable=wrp_fsmState
1518  static enum GenChunks { CHK0=0, CHK1 } \
1519  wrp_genChunk=CHK0;
1520  #pragma HLS reset variable=wrp_genChunk
1521 
1522  //-- STATIC DATAFLOW VARIABLES ---------------------------------------------
1523  static TcpAppSndReq wrp_sendReq;
1524  static FlagBool wrp_testMode;
1525  static uint16_t wrp_retryCnt;
1526 
1527  //-- DYNAMIC VARIABLES -----------------------------------------------------
1528  TcpAppData appData;
1529 
1530  if (*piSHL_Enable != 1) {
1531  return;
1532  }
1533 
1534  switch (wrp_fsmState) {
1535  case WRP_IDLE:
1536  //-- Always give priority to the Tx test generator (for testing reasons)
1537  if (!siCOn_TxSessId.empty() and !siCOn_TxBytesReq.empty()) {
1538  siCOn_TxSessId.read(wrp_sendReq.sessId);
1539  siCOn_TxBytesReq.read(wrp_sendReq.length);
1540  if (DEBUG_LEVEL & TRACE_WRP) {
1541  printInfo(myName, "Received a Tx test request from [TSIF/COn] for sessId=%d and nrBytes=%d.\n",
1542  wrp_sendReq.sessId.to_uint(), wrp_sendReq.length.to_uint());
1543  }
1544  if (wrp_sendReq.length != 0) {
1545  wrp_testMode = true;
1546  wrp_retryCnt = 0x200;
1547  wrp_fsmState = WRP_RTS;
1548  }
1549  else {
1550  wrp_fsmState = WRP_IDLE;
1551  }
1552  }
1553  else if (!siTAF_SessId.empty() and !siTAF_DatLen.empty()) {
1554  siTAF_SessId.read(wrp_sendReq.sessId);
1555  siTAF_DatLen.read(wrp_sendReq.length);
1556  if (DEBUG_LEVEL & TRACE_WRP) {
1557  printInfo(myName, "Received a data forward request from [ROLE/TAF] for sessId=%d and nrBytes=%d.\n",
1558  wrp_sendReq.sessId.to_uint(), wrp_sendReq.length.to_uint());
1559  }
1560  if (wrp_sendReq.length != 0) {
1561  wrp_testMode = false;
1562  wrp_retryCnt = 0x200;
1563  wrp_fsmState = WRP_RTS;
1564  }
1565  }
1566  break;
1567  case WRP_RTS:
1568  if (!soSHL_SndReq.full()) {
1569  soSHL_SndReq.write(wrp_sendReq);
1570  wrp_fsmState = WRP_RTS_REP;
1571  }
1572  break;
1573  case WRP_RTS_REP:
1574  if (!siSHL_SndRep.empty()) {
1575  //-- Read the request-to-send reply and continue accordingly
1576  TcpAppSndRep appSndRep = siSHL_SndRep.read();
1577  switch (appSndRep.error) {
1578  case NO_ERROR:
1579  if (wrp_testMode) {
1580  wrp_genChunk = CHK0;
1581  wrp_fsmState = WRP_TXGEN;
1582  }
1583  else {
1584  wrp_fsmState = WRP_STREAM;
1585  }
1586  break;
1587  case NO_SPACE:
1588  printWarn(myName, "Not enough space for writing %d bytes in the Tx buffer of session #%d. Available space is %d bytes.\n",
1589  appSndRep.length.to_uint(), appSndRep.sessId.to_uint(), appSndRep.spaceLeft.to_uint());
1590  if (wrp_retryCnt) {
1591  wrp_retryCnt -= 1;
1592  wrp_fsmState = WRP_RTS;
1593  }
1594  else {
1595  if (wrp_testMode) {
1596  wrp_fsmState = WRP_IDLE;
1597  }
1598  else {
1599  wrp_fsmState = WRP_DRAIN;
1600  }
1601  }
1602  break;
1603  case NO_CONNECTION:
1604  printWarn(myName, "Attempt to write data for a session that is not established.\n");
1605  if (wrp_testMode) {
1606  wrp_fsmState = WRP_IDLE;
1607  }
1608  else {
1609  wrp_fsmState = WRP_DRAIN;
1610  }
1611  break;
1612  default:
1613  printFatal(myName, "Received unknown TCP request to send reply from [TOE].\n");
1614  wrp_fsmState = WRP_IDLE;
1615  break;
1616  }
1617  }
1618  break;
1619  case WRP_STREAM:
1620  if (!siTAF_Data.empty() and !soSHL_Data.full()) {
1621  siTAF_Data.read(appData);
1622  soSHL_Data.write(appData);
1623  if (DEBUG_LEVEL & TRACE_WRP) { printAxisRaw(myName, "soSHL_Data = ", appData); }
1624  if(appData.getTLast()) {
1625  wrp_fsmState = WRP_IDLE;
1626  }
1627  }
1628  break;
1629  case WRP_TXGEN:
1630  if (!soSHL_Data.full()) {
1631  TcpAppData currChunk(0,0,0);
1632  if (wrp_sendReq.length > 8) {
1633  currChunk.setLE_TKeep(0xFF);
1634  wrp_sendReq.length -= 8;
1635  }
1636  else {
1637  currChunk.setLE_TKeep(lenToLE_tKeep(wrp_sendReq.length));
1638  currChunk.setLE_TLast(TLAST);
1639  wrp_fsmState = WRP_IDLE;
1640  }
1641  switch (wrp_genChunk) {
1642  case CHK0: // Send 'Hi from '
1643  currChunk.setTData(GEN_CHK0);
1644  wrp_genChunk = CHK1;
1645  break;
1646  case CHK1: // Send 'FMKU60!\n'
1647  currChunk.setTData(GEN_CHK1);
1648  wrp_genChunk = CHK0;
1649  break;
1650  }
1651  currChunk.clearUnusedBytes();
1652  soSHL_Data.write(currChunk);
1653  if (DEBUG_LEVEL & TRACE_WRP) { printAxisRaw(myName, "soSHL_Data =", currChunk); }
1654  }
1655  break;
1656  case WRP_DRAIN:
1657  if (!siTAF_Data.empty()) {
1658  siTAF_Data.read(appData);
1659  if (DEBUG_LEVEL & TRACE_WRP) { printAxisRaw(myName, "Draining siTAF_Data =", appData); }
1660  if(appData.getTLast()) {
1661  wrp_fsmState = WRP_IDLE;
1662  }
1663  }
1664  break;
1665  } // End-of: switch
1666 
1667 }
TcpDatLen spaceLeft
Definition: nts.hpp:144
SessionId sessId
Definition: nts.hpp:142
TcpAppSndErr error
Definition: nts.hpp:145
TcpDatLen length
Definition: nts.hpp:143
LE_tKeep lenToLE_tKeep(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:307
bool FlagBool
Definition: nts_types.hpp:124
#define TRACE_WRP
Here is the call graph for this function:
Here is the caller graph for this function:

◆ stepSim()

void stepSim ( )

Increment the simulation counter.

SIMULATION UTILITY HELPERS

Definition at line 78 of file simu_tcp_shell_if_env.cpp.

78  {
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 }
bool gTraceEvent
Definition: tb_nal.cpp:151

◆ tcp_shell_if()

void tcp_shell_if ( CmdBit piSHL_Mmio_En,
stream< TcpAppData > &  siTAF_Data,
stream< TcpSessId > &  siTAF_SessId,
stream< TcpDatLen > &  siTAF_DatLen,
stream< TcpAppData > &  soTAF_Data,
stream< TcpSessId > &  soTAF_SessId,
stream< TcpDatLen > &  soTAF_DatLen,
stream< TcpAppNotif > &  siSHL_Notif,
stream< TcpAppRdReq > &  soSHL_DReq,
stream< TcpAppData > &  siSHL_Data,
stream< TcpAppMeta > &  siSHL_Meta,
stream< TcpAppLsnReq > &  soSHL_LsnReq,
stream< TcpAppLsnRep > &  siSHL_LsnRep,
stream< TcpAppData > &  soSHL_Data,
stream< TcpAppSndReq > &  soSHL_SndReq,
stream< TcpAppSndRep > &  siSHL_SndRep,
stream< TcpAppOpnReq > &  soSHL_OpnReq,
stream< TcpAppOpnRep > &  siSHL_OpnRep,
stream< TcpAppClsReq > &  soSHL_ClsReq,
stream< ap_uint< 32 > > &  soDBG_SinkCnt,
stream< ap_uint< 16 > > &  soDBG_InpBufSpace 
)

TCP Shell Interface (TSIF)

Parameters
[in]piSHL_Mmio_EnEnable signal from [SHELL/MMIO].
[in]siTAF_DataTCP data stream from TcpAppFlash (TAF).
[in]siTAF_SessIdTCP session Id from [TAF].
[out]soTAF_DataTCP data stream to [TAF].
[out]soTAF_SessIdTCP session Id to [TAF].
[in]siSHL_NotifTCP data notification from [SHELL].
[out]soSHL_DReqTCP data request to [SHELL].
[in]siSHL_DataTCP data stream from [SHELL].
[in]siSHL_MetaTCP metadata from [SHELL].
[out]soSHL_LsnReqTCP listen port request to [SHELL].
[in]siSHL_LsnRepTCP listen port acknowledge from [SHELL].
[out]soSHL_DataTCP data stream to [SHELL].
[out]soSHL_SndReqTCP send request to [SHELL].
[in]siSHL_SndRepTCP send reply from [SHELL].
[out]soSHL_OpnReqTCP open connection request to [SHELL].
[in]siSHL_OpnRepTCP open connection reply from [SHELL].
[out]soSHL_ClsReqTCP close connection request to [SHELL].
[out]soDBG_SinkCntCounts the number of sinked bytes (for debug).

ENTITY - TCP SHELL INTERFACE (TSIF)

Definition at line 1691 of file tcp_shell_if.cpp.

1749 {
1750  //-- DIRECTIVES FOR THIS PROCESS -------------------------------------------
1751  #pragma HLS DATAFLOW
1752  #pragma HLS INLINE
1753  #pragma HLS INTERFACE ap_ctrl_none port=return
1754 
1755  //--------------------------------------------------------------------------
1756  //-- LOCAL STREAMS (Sorted by the name of the modules which generate them)
1757  //--------------------------------------------------------------------------
1758 
1759  //-- Input Read Buffer (IRb)
1760  static stream<TcpAppData> ssIRbToRDp_Data ("ssIRbToRDp_Data");
1761  #pragma HLS stream variable=ssIRbToRDp_Data depth=cDepth_IRbToRDp_Data
1762  static stream<TcpAppMeta> ssIRbToRDp_Meta ("ssIRbToRDp_Meta");
1763  #pragma HLS stream variable=ssIRbToRDp_Meta depth=cDepth_IRbToRDp_Meta
1764 
1765  //-- Read Notification Handler (RNh)
1766  static stream <TcpAppNotif> ssRNhToRRh_Notif ("ssRNhToRRh_Notif");
1767  #pragma HLS stream variable=ssRNhToRRh_Notif depth=cDepth_RNhToRRh_Notif
1768 
1769  //-- Read Request Handler (RRh)
1770  static stream<ForwardCmd> ssRRhToRDp_FwdCmd ("ssRRhToRDp_FwdCmd");
1771  #pragma HLS stream variable=ssRRhToRDp_FwdCmd depth=cDepth_RRhToRDp_FwdCmd
1772  #pragma HLS DATA_PACK variable=ssRRhToRDp_FwdCmd
1773  static stream<TcpAppRdReq> ssRRhToRRm_DReq ("ssRRhToRRm_DReq");
1774  #pragma HLS stream variable=ssRRhToRRm_DReq depth=cDepth_RRhToRRm_DReq
1775 
1776  //-- Read Path (RDp)
1777  static stream<SigBit> ssRDpToRRh_Dequeue ("ssRDpToRRh_Dequeue");
1778  #pragma HLS stream variable=ssRDpToRRh_Dequeue depth=cDepth_RDpToRRh_Dequeue
1779  static stream<SockAddr> ssRDpToCOn_OpnSockReq ("ssRDpToCOn_OpnSockReq");
1780  #pragma HLS stream variable=ssRDpToCOn_OpnSockReq depth=cDepth_RDpToCOn_OpnSockReq
1781  static stream<TcpDatLen> ssRDpToCOn_TxCountReq ("ssRDpToCOn_TxCountReq");
1782  #pragma HLS stream variable=ssRDpToCOn_TxCountReq depth=cDepth_RDpToCOn_TxCountReq
1783 
1784  //-- Connect (COn)
1785  static stream<TcpDatLen> ssCOnToWRp_TxBytesReq ("ssCOnToWRp_TxBytesReq");
1786  #pragma HLS stream variable=ssCOnToWRp_TxBytesReq depth=cDepth_COnToWRp_TxBytesReq
1787  static stream<SessionId> ssCOnToWRp_TxSessId ("ssCOnToWRp_TxSessId");
1788  #pragma HLS stream variable=ssCOnToWRp_TxSessId depth=cDepth_COnToWRp_TxSessId
1789 
1790  //-- PROCESS FUNCTIONS -----------------------------------------------------
1791  pConnect(
1792  piSHL_Mmio_En,
1793  ssRDpToCOn_OpnSockReq,
1794  ssRDpToCOn_TxCountReq,
1795  ssCOnToWRp_TxBytesReq,
1796  ssCOnToWRp_TxSessId,
1797  soSHL_OpnReq,
1798  siSHL_OpnRep,
1799  soSHL_ClsReq);
1800 
1801  pListen(
1802  piSHL_Mmio_En,
1803  soSHL_LsnReq,
1804  siSHL_LsnRep);
1805 
1807  piSHL_Mmio_En,
1808  siSHL_Data,
1809  siSHL_Meta,
1810  ssIRbToRDp_Data,
1811  ssIRbToRDp_Meta);
1812 
1813  pReadPath(
1814  piSHL_Mmio_En,
1815  ssIRbToRDp_Data,
1816  ssIRbToRDp_Meta,
1817  ssRRhToRDp_FwdCmd,
1818  ssRDpToCOn_OpnSockReq,
1819  ssRDpToCOn_TxCountReq,
1820  ssRDpToRRh_Dequeue,
1821  soTAF_Data,
1822  soTAF_SessId,
1823  soTAF_DatLen,
1824  soDBG_SinkCnt);
1825 
1827  piSHL_Mmio_En,
1828  siSHL_Notif,
1829  ssRNhToRRh_Notif);
1830 
1831  #if defined USE_INTERRUPTS
1833  siSHL_Notif,
1834  ssIRbToRRh_Enqueue,
1835  ssRDpToRRh_Dequeue,
1836  soSHL_DReq,
1837  ssRRhToRDp_FwdCmd);
1838 
1839  #else
1841  piSHL_Mmio_En,
1842  ssRNhToRRh_Notif,
1843  ssRDpToRRh_Dequeue,
1844  ssRRhToRRm_DReq,
1845  ssRRhToRDp_FwdCmd,
1846  soDBG_InpBufSpace);
1847 
1849  piSHL_Mmio_En,
1850  ssRRhToRRm_DReq,
1851  soSHL_DReq);
1852 
1853  pWritePath(
1854  piSHL_Mmio_En,
1855  siTAF_Data,
1856  siTAF_SessId,
1857  siTAF_DatLen,
1858  ssCOnToWRp_TxBytesReq,
1859  ssCOnToWRp_TxSessId,
1860  soSHL_Data,
1861  soSHL_SndReq,
1862  siSHL_SndRep);
1863 
1864  #endif
1865 }
void pReadRequestMover(CmdBit *piSHL_Enable, stream< TcpAppRdReq > &siRRh_DReq, stream< TcpAppRdReq > &soSHL_DReq)
Read Request Mover (RRm)
void pReadRequestHandler(CmdBit *piSHL_Enable, stream< TcpAppNotif > &siRNh_Notif, stream< SigBit > &siRDp_DequSig, stream< TcpAppRdReq > &soRRm_DReq, stream< ForwardCmd > &soRDp_FwdCmd, stream< ap_uint< 16 > > &soDBG_freeSpace)
Read Request Handler (RRh)
void pConnect(CmdBit *piSHL_Enable, stream< SockAddr > &siRDp_OpnSockReq, stream< Ly4Len > &siRDp_TxCountReq, stream< Ly4Len > &soWRp_TxBytesReq, stream< SessionId > &soWRp_TxSessId, stream< TcpAppOpnReq > &soSHL_OpnReq, stream< TcpAppOpnRep > &siSHL_OpnRep, stream< TcpAppClsReq > &soSHL_ClsReq)
Connect (COn).
void pReadPath(CmdBit *piSHL_Enable, stream< TcpAppData > &siSHL_Data, stream< TcpAppMeta > &siSHL_Meta, stream< ForwardCmd > &siRRh_FwdCmd, stream< SockAddr > &soCOn_OpnSockReq, stream< TcpDatLen > &soCOn_TxCountReq, stream< SigBit > &soRRh_DequSig, stream< TcpAppData > &soTAF_Data, stream< TcpSessId > &soTAF_SessId, stream< TcpDatLen > &soTAF_DatLen, stream< ap_uint< 32 > > &soDBG_SinkCount)
Read Path (RDp)
void pWritePath(CmdBit *piSHL_Enable, stream< TcpAppData > &siTAF_Data, stream< TcpSessId > &siTAF_SessId, stream< TcpDatLen > &siTAF_DatLen, stream< TcpDatLen > &siCOn_TxBytesReq, stream< SessionId > &siCOn_TxSessId, stream< TcpAppData > &soSHL_Data, stream< TcpAppSndReq > &soSHL_SndReq, stream< TcpAppSndRep > &siSHL_SndRep)
Write Path (WRp)
void pReadNotificationHandler(CmdBit *piSHL_Enable, stream< TcpAppNotif > &siSHL_Notif, stream< TcpAppNotif > &soRRh_Notif)
Read Notification Handler (RNh)
void pInputReadBuffer(CmdBit *piSHL_Enable, stream< TcpAppData > &siSHL_Data, stream< TcpAppMeta > &siSHL_Meta, stream< TcpAppData > &soRDp_Data, stream< TcpAppMeta > &soRDp_Meta)
Input Read Buffer (IRb)
void pListen(CmdBit *piSHL_Enable, stream< TcpAppLsnReq > &soSHL_LsnReq, stream< TcpAppLsnRep > &siSHL_LsnRep)
Listen(LSn)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tcp_shell_if_top()

void tcp_shell_if_top ( CmdBit piSHL_Mmio_En,
stream< TcpAppData > &  siTAF_Data,
stream< TcpSessId > &  siTAF_SessId,
stream< TcpDatLen > &  siTAF_DatLen,
stream< TcpAppData > &  soTAF_Data,
stream< TcpSessId > &  soTAF_SessId,
stream< TcpDatLen > &  soTAF_DatLen,
stream< TcpAppNotif > &  siSHL_Notif,
stream< TcpAppRdReq > &  soSHL_DReq,
stream< TcpAppData > &  siSHL_Data,
stream< TcpAppMeta > &  siSHL_Meta,
stream< TcpAppLsnReq > &  soSHL_LsnReq,
stream< TcpAppLsnRep > &  siSHL_LsnRep,
stream< TcpAppData > &  soSHL_Data,
stream< TcpAppSndReq > &  soSHL_SndReq,
stream< TcpAppSndRep > &  siSHL_SndRep,
stream< TcpAppOpnReq > &  soSHL_OpnReq,
stream< TcpAppOpnRep > &  siSHL_OpnRep,
stream< TcpAppClsReq > &  soSHL_ClsReq,
stream< ap_uint< 32 > > &  soDBG_SinkCnt,
stream< ap_uint< 16 > > &  soDBG_InpBufSpace 
)

Top of TCP Shell Interface (TSIF)

Parameters
[in]piSHL_Mmio_EnEnable signal from [SHELL/MMIO].
[in]siTAF_DataTCP data stream from TcpAppFlash (TAF).
[in]siTAF_SessIdTCP session Id from [TAF].
[out]soTAF_DataTCP data stream to [TAF].
[out]soTAF_SessIdTCP session Id to [TAF].
[in]siSHL_NotifTCP data notification from [SHELL].
[out]soSHL_DReqTCP data request to [SHELL].
[in]siSHL_DataTCP data stream from [SHELL].
[in]siSHL_MetaTCP metadata from [SHELL].
[out]soSHL_LsnReqTCP listen port request to [SHELL].
[in]siSHL_LsnRepTCP listen port acknowledge from [SHELL].
[out]soSHL_DataTCP data stream to [SHELL].
[out]soSHL_SndReqTCP send request to [SHELL].
[in]siSHL_SndRepTCP send reply from [SHELL].
[out]soSHL_OpnReqTCP open connection request to [SHELL].
[in]siSHL_OpnRepTCP open connection reply from [SHELL].
[out]soSHL_ClsReqTCP close connection request to [SHELL].
[out]soDBG_SinkCntCounts the number of sinked bytes (for debug).

ENTITY - TOP of TCP SHELL INTERFACE (TSIF)

Definition at line 186 of file tcp_shell_if_top.cpp.

235 {
236  //-- DIRECTIVES FOR THE INTERFACES -----------------------------------------
237  #pragma HLS INTERFACE ap_ctrl_none port=return
238 
239  #pragma HLS INTERFACE ap_stable register port=piSHL_Mmio_En name=piSHL_Mmio_En
240 
241  #pragma HLS INTERFACE axis off port=siTAF_Data name=siTAF_Data
242  #pragma HLS INTERFACE axis off port=siTAF_SessId name=siTAF_SessId
243  #pragma HLS INTERFACE axis off port=siTAF_DatLen name=siTAF_DatLen
244 
245  #pragma HLS INTERFACE axis off port=soTAF_Data name=soTAF_Data
246  #pragma HLS INTERFACE axis off port=soTAF_SessId name=soTAF_SessId
247  #pragma HLS INTERFACE axis off port=soTAF_DatLen name=soTAF_DatLen
248 
249  #pragma HLS INTERFACE axis off port=siSHL_Notif name=siSHL_Notif
250  #pragma HLS DATA_PACK variable=siSHL_Notif
251  #pragma HLS INTERFACE axis off port=soSHL_DReq name=soSHL_DReq
252  #pragma HLS DATA_PACK variable=soSHL_DReq
253  #pragma HLS INTERFACE axis off port=siSHL_Data name=siSHL_Data
254  #pragma HLS INTERFACE axis off port=siSHL_Meta name=siSHL_Meta
255 
256  #pragma HLS INTERFACE axis off port=soSHL_LsnReq name=soSHL_LsnReq
257  #pragma HLS INTERFACE axis off port=siSHL_LsnRep name=siSHL_LsnRep
258 
259  #pragma HLS INTERFACE axis off port=soSHL_Data name=soSHL_Data
260  #pragma HLS INTERFACE axis off port=soSHL_SndReq name=soSHL_SndReq
261  #pragma HLS DATA_PACK variable=soSHL_SndReq
262  #pragma HLS INTERFACE axis off port=siSHL_SndRep name=siSHL_SndRep
263  #pragma HLS DATA_PACK variable=siSHL_SndRep
264 
265  #pragma HLS INTERFACE axis off port=soSHL_OpnReq name=soSHL_OpnReq
266  #pragma HLS DATA_PACK variable=soSHL_OpnReq
267  #pragma HLS INTERFACE axis off port=siSHL_OpnRep name=siSHL_OpnRep
268  #pragma HLS DATA_PACK variable=siSHL_OpnRep
269 
270  #pragma HLS INTERFACE axis off port=soSHL_ClsReq name=soSHL_ClsReq
271 
272  #pragma HLS INTERFACE axis register both port=soDBG_SinkCnt name=soDBG_SinkCnt
273  #pragma HLS INTERFACE axis register both port=soDBG_InpBufSpace name=soDBG_InpBufSpace
274 
275  //-- DIRECTIVES FOR THIS PROCESS -------------------------------------------
276  #if HLS_VERSION == 2017
277  #pragma HLS DATAFLOW
278  #else
279  #pragma HLS DATAFLOW disable_start_propagation
280  #endif
281 
282  //-- INSTANTIATE TOPLEVEL --------------------------------------------------
283  tcp_shell_if(
284  //-- SHELL / Mmio Interface
285  piSHL_Mmio_En,
286  //-- TAF / Rx & Tx Data Interfaces
287  siTAF_Data,
288  siTAF_SessId,
289  siTAF_DatLen,
290  soTAF_Data,
291  soTAF_SessId,
292  soTAF_DatLen,
293  //-- TOE / Rx Data Interfaces
294  siSHL_Notif,
295  soSHL_DReq,
296  siSHL_Data,
297  siSHL_Meta,
298  //-- TOE / Listen Interfaces
299  soSHL_LsnReq,
300  siSHL_LsnRep,
301  //-- TOE / Tx Data Interfaces
302  soSHL_Data,
303  soSHL_SndReq,
304  siSHL_SndRep,
305  //-- TOE / Tx Open Interfaces
306  soSHL_OpnReq,
307  siSHL_OpnRep,
308  //-- TOE / Close Interfaces
309  soSHL_ClsReq,
310  //-- DEBUG Interfaces
311  soDBG_SinkCnt,
312  soDBG_InpBufSpace);
313 }
Here is the call graph for this function:

Variable Documentation

◆ cDepth_COnToWRp_TxBytesReq

const int cDepth_COnToWRp_TxBytesReq = 2

Definition at line 53 of file tcp_shell_if.hpp.

◆ cDepth_COnToWRp_TxSessId

const int cDepth_COnToWRp_TxSessId = cDepth_COnToWRp_TxBytesReq

Definition at line 54 of file tcp_shell_if.hpp.

◆ cDepth_IRbToRDp_Data

const int cDepth_IRbToRDp_Data = 256

Definition at line 42 of file tcp_shell_if.hpp.

◆ cDepth_IRbToRDp_Meta

const int cDepth_IRbToRDp_Meta = 256

Definition at line 43 of file tcp_shell_if.hpp.

◆ cDepth_RDpToCOn_OpnSockReq

const int cDepth_RDpToCOn_OpnSockReq = 2

Definition at line 50 of file tcp_shell_if.hpp.

◆ cDepth_RDpToCOn_TxCountReq

const int cDepth_RDpToCOn_TxCountReq = cDepth_RDpToCOn_OpnSockReq

Definition at line 51 of file tcp_shell_if.hpp.

◆ cDepth_RDpToRRh_Dequeue

const int cDepth_RDpToRRh_Dequeue = 4

Definition at line 49 of file tcp_shell_if.hpp.

◆ cDepth_RNhToRRh_Notif

const int cDepth_RNhToRRh_Notif = 64

Definition at line 45 of file tcp_shell_if.hpp.

◆ cDepth_RRhToRDp_FwdCmd

const int cDepth_RRhToRDp_FwdCmd = 8

Definition at line 46 of file tcp_shell_if.hpp.

◆ cDepth_RRhToRRm_DReq

const int cDepth_RRhToRRm_DReq = cDepth_RRhToRDp_FwdCmd

Definition at line 47 of file tcp_shell_if.hpp.

◆ cGraceTime

const int cGraceTime = 2500

Definition at line 48 of file simu_tcp_shell_if_env.hpp.

◆ cIBuffBytes

const int cIBuffBytes = cDepth_IRbToRDp_Data * (ARW/8)

Definition at line 61 of file tcp_shell_if.hpp.

◆ cMaxSessions

const int cMaxSessions = TOE_MAX_SESSIONS

Definition at line 59 of file tcp_shell_if.hpp.

◆ cMinDataReqLen

const int cMinDataReqLen = 128

Definition at line 62 of file tcp_shell_if.hpp.

◆ cMinWAIT

const int cMinWAIT = cMaxSessions

Definition at line 53 of file simu_tcp_shell_if_env.hpp.

◆ cNrSegToSend

const int cNrSegToSend = 5

Definition at line 50 of file simu_tcp_shell_if_env.hpp.

◆ cNrSessToSend

const int cNrSessToSend = 2

Definition at line 51 of file simu_tcp_shell_if_env.hpp.

◆ cSimToeStartupDelay

const int cSimToeStartupDelay = 1000

Definition at line 47 of file simu_tcp_shell_if_env.hpp.

◆ gFatalError [1/3]

bool gFatalError
extern

Definition at line 152 of file tb_nal.cpp.

◆ gFatalError [2/3]

bool gFatalError = false

Definition at line 43 of file test_tcp_shell_if.hpp.

◆ gFatalError [3/3]

bool gFatalError = false

Definition at line 43 of file test_tcp_shell_if_top.hpp.

◆ gMaxSimCycles [1/5]

unsigned int gMaxSimCycles
extern

Definition at line 69 of file test_arp.hpp.

◆ gMaxSimCycles [2/5]

unsigned int gMaxSimCycles
extern

Definition at line 69 of file test_arp.hpp.

◆ gMaxSimCycles [3/5]

unsigned int gMaxSimCycles = cSimToeStartupDelay + cGraceTime

Definition at line 44 of file test_tcp_shell_if.hpp.

◆ gMaxSimCycles [4/5]

unsigned int gMaxSimCycles
extern

Definition at line 69 of file test_arp.hpp.

◆ gMaxSimCycles [5/5]

unsigned int gMaxSimCycles = cSimToeStartupDelay + cGraceTime

Definition at line 44 of file test_tcp_shell_if_top.hpp.

◆ gSimCycCnt [1/5]

unsigned int gSimCycCnt
extern

GLOBAL VARIABLES USED BY THE SIMULATION ENVIRONMENT

Definition at line 150 of file tb_nal.cpp.

◆ gSimCycCnt [2/5]

unsigned int gSimCycCnt
extern

GLOBAL VARIABLES USED BY THE SIMULATION ENVIRONMENT

Definition at line 150 of file tb_nal.cpp.

◆ gSimCycCnt [3/5]

unsigned int gSimCycCnt = 0

GLOBAL VARIABLES USED BY THE SIMULATION ENVIRONMENT

Definition at line 41 of file test_tcp_shell_if.hpp.

◆ gSimCycCnt [4/5]

unsigned int gSimCycCnt
extern

GLOBAL VARIABLES USED BY THE SIMULATION ENVIRONMENT

Definition at line 150 of file tb_nal.cpp.

◆ gSimCycCnt [5/5]

unsigned int gSimCycCnt = 0

GLOBAL VARIABLES USED BY THE SIMULATION ENVIRONMENT

Definition at line 41 of file test_tcp_shell_if_top.hpp.

◆ gTraceEvent [1/4]

bool gTraceEvent
extern

ARCHITECTURE DIRECTIVE The ReadRequestHandler (RRh) of TSIF can be implemented with an interrupt handler and scheduler approach by setting the following pre-processor directive. HELPERS FOR THE DEBUGGING TRACES .e.g: DEBUG_LEVEL = (MDL_TRACE | IPS_TRACE)

HELPERS FOR THE DEBUGGING TRACES .e.g: DEBUG_LEVEL = (MDL_TRACE | IPS_TRACE)

Definition at line 151 of file tb_nal.cpp.

◆ gTraceEvent [2/4]

bool gTraceEvent
extern

HELPERS FOR THE DEBUGGING TRACES .e.g: DEBUG_LEVEL = (MDL_TRACE | IPS_TRACE)

Definition at line 151 of file tb_nal.cpp.

◆ gTraceEvent [3/4]

bool gTraceEvent = false

HELPERS FOR THE DEBUGGING TRACES .e.g: DEBUG_LEVEL = (MDL_TRACE | IPS_TRACE)

Definition at line 42 of file test_tcp_shell_if.hpp.

◆ gTraceEvent [4/4]

bool gTraceEvent = false

HELPERS FOR THE DEBUGGING TRACES .e.g: DEBUG_LEVEL = (MDL_TRACE | IPS_TRACE)

Definition at line 42 of file test_tcp_shell_if_top.hpp.