61 #define THIS_NAME "USIF"
63 #define TRACE_OFF 0x0000
64 #define TRACE_RDP 1 << 1
65 #define TRACE_WRP 1 << 2
66 #define TRACE_SAM 1 << 3
67 #define TRACE_LSN 1 << 4
68 #define TRACE_CLS 1 << 5
69 #define TRACE_ALL 0xFFFF
70 #define DEBUG_LEVEL (TRACE_OFF)
81 #define DEFAULT_FPGA_LSN_PORT 0x2263
106 stream<UdpPort> &soSHL_LsnReq,
107 stream<StsBool> &siSHL_LsnRep)
110 #pragma HLS INLINE off
111 #pragma HLS PIPELINE II=1 enable_flush
118 #pragma HLS reset variable=lsn_fsmState
119 static ap_uint<3> lsn_i = 0;
120 #pragma HLS reset variable=lsn_i
126 #pragma HLS RESOURCE variable=LSN_PORT_TABLE core=ROM_1P
129 static ap_uint<8> lsn_watchDogTimer;
131 switch (lsn_fsmState) {
133 if (*piSHL_Enable != 1) {
147 if (!soSHL_LsnReq.full()) {
169 printInfo(myName,
"Server is requested to listen on port #%d (0x%4.4X).\n",
170 LSN_PORT_TABLE[lsn_i].to_uint(), LSN_PORT_TABLE[lsn_i].to_uint());
172 #ifndef __SYNTHESIS__
173 lsn_watchDogTimer = 10;
175 lsn_watchDogTimer = 100;
177 lsn_fsmState = LSN_WAIT_REP;
180 printWarn(myName,
"Cannot send a listen port request to [UOE] because stream is full!\n");
185 if (!siSHL_LsnRep.empty()) {
187 siSHL_LsnRep.read(listenDone);
189 printInfo(myName,
"Received OK listen reply from [UOE] for port %d.\n", LSN_PORT_TABLE[lsn_i].to_uint());
190 if (lsn_i ==
sizeof(LSN_PORT_TABLE)/
sizeof(LSN_PORT_TABLE[0])-1) {
200 printWarn(myName,
"UOE denied listening on port %d (0x%4.4X).\n",
201 LSN_PORT_TABLE[lsn_i].to_uint(), LSN_PORT_TABLE[lsn_i].to_uint());
206 if (lsn_watchDogTimer == 0) {
207 printError(myName,
"Timeout: Server failed to listen on port %d %d (0x%4.4X).\n",
208 LSN_PORT_TABLE[lsn_i].to_uint(), LSN_PORT_TABLE[lsn_i].to_uint());
229 stream<UdpPort> &soSHL_ClsReq,
230 stream<StsBool> &siSHL_ClsRep)
233 #pragma HLS INLINE off
234 #pragma HLS PIPELINE II=1 enable_flush
239 static enum FsmStates {
CLS_IDLE, CLS_SEND_REQ, CLS_WAIT_REP, CLS_DONE } \
241 #pragma HLS reset variable=cls_fsmState
245 switch (cls_fsmState) {
247 if (*piSHL_Enable != 1) {
248 if (!siSHL_ClsRep.empty()) {
251 printWarn(myName,
"Draining unexpected residue from the \'ClsRep\' stream.\n");
256 cls_fsmState = CLS_SEND_REQ;
260 if (!soSHL_ClsReq.full()) {
264 soSHL_ClsReq.write(udpClosePort);
266 printInfo(myName,
"SHELL/NTS/USIF is requesting to close port #%d (0x%4.4X).\n",
267 udpClosePort.to_int(), udpClosePort.to_int());
269 cls_fsmState = CLS_WAIT_REP;
272 printWarn(myName,
"Cannot send a listen port request to [UOE] because stream is full!\n");
276 if (!siSHL_ClsRep.empty()) {
278 siSHL_ClsRep.read(isOpened);
280 printInfo(myName,
"Received close acknowledgment from [UOE].\n");
281 cls_fsmState = CLS_DONE;
284 printWarn(myName,
"UOE denied closing the port %d (0x%4.4X) which is still opened.\n",
286 cls_fsmState = CLS_SEND_REQ;
323 stream<UdpAppData> &siSHL_Data,
324 stream<UdpAppMeta> &siSHL_Meta,
325 stream<UdpAppDLen> &siSHL_DLen,
326 stream<UdpAppData> &soUAF_Data,
327 stream<UdpAppMeta> &soUAF_Meta,
328 stream<UdpAppDLen> &soUAF_DLen,
329 stream<SocketPair> &soWRp_SockPair,
330 stream<UdpAppDLen> &soWRp_DReq)
333 #pragma HLS INLINE off
334 #pragma HLS PIPELINE II=1 enable_flush
339 static enum FsmStates { RDP_IDLE=0, RDP_FWD_META, RDP_FWD_STREAM, RDP_SINK_STREAM, RDP_8801 } \
340 rdp_fsmState = RDP_IDLE;
341 #pragma HLS reset variable=rdp_fsmState
350 if (*piSHL_Enable != 1) {
354 switch (rdp_fsmState ) {
356 if (!siSHL_Meta.empty() and !siSHL_DLen.empty()) {
357 siSHL_Meta.read(rdp_appMeta);
358 siSHL_DLen.read(rdp_appDLen);
363 rdp_fsmState = RDP_SINK_STREAM;
368 rdp_fsmState = RDP_8801;
372 rdp_fsmState = RDP_FWD_META;
378 if (!soUAF_Meta.full() and !soUAF_DLen.full()) {
379 soUAF_Meta.write(rdp_appMeta);
380 soUAF_DLen.write(rdp_appDLen);
381 rdp_fsmState = RDP_FWD_STREAM;
385 if (!siSHL_Data.empty() and !soUAF_Data.full()) {
386 siSHL_Data.read(appData);
387 soUAF_Data.write(appData);
389 rdp_fsmState = RDP_IDLE;
394 case RDP_SINK_STREAM:
395 if (!siSHL_Data.empty()) {
396 siSHL_Data.read(appData);
398 rdp_fsmState = RDP_IDLE;
404 if (!siSHL_Data.empty() and !soWRp_SockPair.full() and !soWRp_DReq.full()) {
406 siSHL_Data.read(appData);
412 soWRp_SockPair.write(
SocketPair(srcSockAddr, dstSockAddr));
416 printInfo(myName,
"Received request for Tx test mode to generate a segment of length=%d and to send it to socket:\n",
421 rdp_fsmState = RDP_IDLE;
424 rdp_fsmState = RDP_SINK_STREAM;
453 stream<UdpAppData> &siUAF_Data,
454 stream<UdpAppMeta> &siUAF_Meta,
455 stream<UdpAppDLen> &siUAF_DLen,
456 stream<SocketPair> &siRDp_SockPair,
457 stream<UdpAppDLen> &siRDp_DReq,
458 stream<UdpAppData> &soSHL_Data,
459 stream<UdpAppMeta> &soSHL_Meta,
460 stream<UdpAppDLen> &soSHL_DLen)
463 #pragma HLS INLINE off
464 #pragma HLS PIPELINE II=1 enable_flush
469 static enum FsmStates { WRP_IDLE=0, WRP_STREAM, WRP_8801 } \
470 wrp_fsmState=WRP_IDLE;
471 #pragma HLS reset variable=wrp_fsmState
472 static enum GenChunks { CHK0=0, CHK1, } \
474 #pragma HLS reset variable=wrp_genChunk
485 if (*piSHL_Enable != 1) {
489 switch (wrp_fsmState) {
492 if (!siRDp_SockPair.empty() and !siRDp_DReq.empty() and
493 !soSHL_Meta.full() and !soSHL_DLen.full()) {
494 siRDp_SockPair.read(tstSockPair);
495 siRDp_DReq.read(wrp_appDReq);
496 soSHL_Meta.write(tstSockPair);
497 soSHL_DLen.write(wrp_appDReq);
499 printInfo(myName,
"Received a Tx test request of length %d from RDp.\n", wrp_appDReq.to_uint());
502 if (wrp_appDReq != 0) {
503 wrp_fsmState = WRP_8801;
507 wrp_fsmState = WRP_IDLE;
510 else if (!siUAF_Meta.empty() and !siUAF_DLen.empty() and
511 !soSHL_Meta.full() and !soSHL_DLen.full()) {
513 siUAF_Meta.read(appMeta);
514 siUAF_DLen.read(appDLen);
515 soSHL_Meta.write(appMeta);
516 soSHL_DLen.write(appDLen);
518 printInfo(myName,
"Received a datagram of length %d from ROLE.\n", appDLen.to_uint());
522 wrp_fsmState = WRP_STREAM;
527 if (!siUAF_Data.empty() and !soSHL_Data.full()) {
528 siUAF_Data.read(appData);
529 soSHL_Data.write(appData);
532 wrp_fsmState = WRP_IDLE;
536 if (!soSHL_Data.full()) {
538 if (wrp_appDReq > 8) {
545 wrp_fsmState = WRP_IDLE;
547 switch (wrp_genChunk) {
558 soSHL_Data.write(currChunk);
604 stream<UdpPort> &soSHL_LsnReq,
605 stream<StsBool> &siSHL_LsnRep,
606 stream<UdpPort> &soSHL_ClsReq,
607 stream<StsBool> &siSHL_ClsRep,
612 stream<UdpAppData> &siSHL_Data,
613 stream<UdpAppMeta> &siSHL_Meta,
614 stream<UdpAppDLen> &siSHL_DLen,
619 stream<UdpAppData> &soSHL_Data,
620 stream<UdpAppMeta> &soSHL_Meta,
621 stream<UdpAppDLen> &soSHL_DLen,
626 stream<UdpAppData> &siUAF_Data,
627 stream<UdpAppMeta> &siUAF_Meta,
628 stream<UdpAppDLen> &siUAF_DLen,
633 stream<UdpAppData> &soUAF_Data,
634 stream<UdpAppMeta> &soUAF_Meta,
635 stream<UdpAppDLen> &soUAF_DLen)
640 #pragma HLS INTERFACE ap_ctrl_none port=return
647 static stream<SocketPair> ssRDpToWRp_SockPair (
"ssRDpToWRp_SockPair");
648 #pragma HLS STREAM variable=ssRDpToWRp_SockPair depth=2
649 static stream<UdpAppDLen> ssRDpToWRp_DReq (
"ssRDpToWRp_DReq");
650 #pragma HLS STREAM variable=ssRDpToWRp_DReq depth=2
LE_tData getLE_TData(int leHi=64 -1, int leLo=0) const
void setLE_TLast(LE_tLast last)
void setTData(tData data)
void setLE_TKeep(LE_tKeep keep, int leHi=64/8-1, int leLo=0)
LE_tLast getLE_TLast() const
#define printError(callerName, format,...)
A macro to print an error message.
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...
void printAxisRaw(const char *callerName, AxisRaw chunk)
Prints an Axis raw data chunk (used for debugging).
void printSockAddr(const char *callerName, SockAddr sockAddr)
Print a socket address.
#define printInfo(callerName, format,...)
A macro to print an information message.
#define printWarn(callerName, format,...)
A macro to print a warning message.
#define concat3(firstCharConst, secondCharConst, thirdCharConst)
void printSockPair(const char *callerName, SocketPair sockPair)
Print a socket pair association.
#define RECV_MODE_LSN_PORT
#define XMIT_MODE_LSN_PORT
#define ECHO_MOD2_LSN_PORT
#define ECHO_MODE_LSN_PORT
#define DEFAULT_FPGA_LSN_PORT
void pWritePath(CmdBit *piSHL_Enable, stream< UdpAppData > &siUAF_Data, stream< UdpAppMeta > &siUAF_Meta, stream< UdpAppDLen > &siUAF_DLen, stream< SocketPair > &siRDp_SockPair, stream< UdpAppDLen > &siRDp_DReq, stream< UdpAppData > &soSHL_Data, stream< UdpAppMeta > &soSHL_Meta, stream< UdpAppDLen > &soSHL_DLen)
Write Path (WRp) - From ROLE/UAF to SHELL/NTS/UOE.
void udp_shell_if(CmdBit *piSHL_Mmio_En, stream< UdpPort > &soSHL_LsnReq, stream< StsBool > &siSHL_LsnRep, stream< UdpPort > &soSHL_ClsReq, stream< StsBool > &siSHL_ClsRep, stream< UdpAppData > &siSHL_Data, stream< UdpAppMeta > &siSHL_Meta, stream< UdpAppDLen > &siSHL_DLen, stream< UdpAppData > &soSHL_Data, stream< UdpAppMeta > &soSHL_Meta, stream< UdpAppDLen > &soSHL_DLen, stream< UdpAppData > &siUAF_Data, stream< UdpAppMeta > &siUAF_Meta, stream< UdpAppDLen > &siUAF_DLen, stream< UdpAppData > &soUAF_Data, stream< UdpAppMeta > &soUAF_Meta, stream< UdpAppDLen > &soUAF_DLen)
Main process of the UDP Shell Interface (USIF).
void pReadPath(CmdBit *piSHL_Enable, stream< UdpAppData > &siSHL_Data, stream< UdpAppMeta > &siSHL_Meta, stream< UdpAppDLen > &siSHL_DLen, stream< UdpAppData > &soUAF_Data, stream< UdpAppMeta > &soUAF_Meta, stream< UdpAppDLen > &soUAF_DLen, stream< SocketPair > &soWRp_SockPair, stream< UdpAppDLen > &soWRp_DReq)
Read Path (RDp) - From SHELL/UOE to ROLE/UAF.
void pClose(CmdBit *piSHL_Enable, stream< UdpPort > &soSHL_ClsReq, stream< StsBool > &siSHL_ClsRep)
Request the SHELL/NTS/UOE to close a previously opened port.
void pListen(CmdBit *piSHL_Enable, stream< UdpPort > &soSHL_LsnReq, stream< StsBool > &siSHL_LsnRep)
Listen(LSn)
ap_uint< 32 > byteSwap32(ap_uint< 32 > inputVector)
ap_uint< 16 > byteSwap16(ap_uint< 16 > inputVector)
: UDP Shell Interface (USIF).