69 #define THIS_NAME "TSIF"
71 #define TRACE_OFF 0x0000
72 #define TRACE_IRB 1 << 1
73 #define TRACE_RDP 1 << 2
74 #define TRACE_WRP 1 << 3
75 #define TRACE_LSN 1 << 4
76 #define TRACE_CON 1 << 5
77 #define TRACE_RNH 1 << 6
78 #define TRACE_RRH 1 << 7
79 #define TRACE_RRM 1 << 8
80 #define TRACE_ALL 0xFFFF
81 #define DEBUG_LEVEL (TRACE_OFF)
129 stream<SockAddr> &siRDp_OpnSockReq,
130 stream<Ly4Len> &siRDp_TxCountReq,
131 stream<Ly4Len> &soWRp_TxBytesReq,
132 stream<SessionId> &soWRp_TxSessId,
133 stream<TcpAppOpnReq> &soSHL_OpnReq,
134 stream<TcpAppOpnRep> &siSHL_OpnRep,
135 stream<TcpAppClsReq> &soSHL_ClsReq)
138 #pragma HLS INLINE off
139 #pragma HLS PIPELINE II=1 enable_flush
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
149 #pragma HLS reset variable=con_testSockAddr
153 static Ly4Len con_txBytesReq;
154 static ap_uint< 12> con_watchDogTimer;
156 switch (con_fsmState) {
158 if (*piSHL_Enable != 1) {
159 if (!siSHL_OpnRep.empty()) {
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);
167 con_fsmState = 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;
178 printInfo(myName,
"Client is requesting to connect to new remote socket:\n");
182 else if (currSockAddr == con_testSockAddr) {
183 con_fsmState = CON_WR_WRp;
185 printInfo(myName,
"Client is requesting the FPGA to send %d bytes to the last opened socket:\n", con_txBytesReq.to_uint());
190 con_fsmState = CON_RD_RDp;
191 printInfo(myName,
"Client is requesting the FPGA to send traffic to a none opened connection:\n");
198 if (!soSHL_OpnReq.full()) {
199 soSHL_OpnReq.write(con_testSockAddr);
200 #ifndef __SYNTHESIS__
201 con_watchDogTimer = 250;
203 con_watchDogTimer = 10000;
205 con_fsmState = CON_OPN_REP;
210 if (!siSHL_OpnRep.empty()) {
212 siSHL_OpnRep.read(con_opnRep);
215 printInfo(myName,
"Client successfully established connection.\n");
219 printError(myName,
"Client failed to establish connection with remote socket (TCP state is '%s'):\n",
222 con_fsmState = CON_IDLE;
225 if (con_watchDogTimer == 0) {
227 printError(myName,
"Timeout: Failed to establish connection.\n");
229 #ifndef __SYNTHESIS__
230 con_watchDogTimer = 250;
232 con_watchDogTimer = 10000;
238 if(!soWRp_TxBytesReq.full() and !soWRp_TxSessId.full()) {
240 soWRp_TxBytesReq.write(con_txBytesReq);
241 soWRp_TxSessId.write(con_opnRep.
sessId);
242 con_fsmState = CON_IDLE;
269 stream<TcpAppLsnReq> &soSHL_LsnReq,
270 stream<TcpAppLsnRep> &siSHL_LsnRep)
273 #pragma HLS INLINE off
274 #pragma HLS PIPELINE II=1 enable_flush
281 #pragma HLS reset variable=lsn_fsmState
282 static ap_uint<3> lsn_i = 0;
283 #pragma HLS reset variable=lsn_i
289 #pragma HLS RESOURCE variable=LSN_PORT_TABLE core=ROM_1P
292 static ap_uint<8> lsn_watchDogTimer;
294 switch (lsn_fsmState) {
296 if (*piSHL_Enable != 1) {
310 if (!soSHL_LsnReq.full()) {
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());
335 #ifndef __SYNTHESIS__
336 lsn_watchDogTimer = 10;
338 lsn_watchDogTimer = 100;
340 lsn_fsmState = LSN_WAIT_REP;
343 printWarn(myName,
"Cannot send a listen port request to [TOE] because stream is full!\n");
348 if (!siSHL_LsnRep.empty()) {
350 siSHL_LsnRep.read(listenDone);
353 printInfo(myName,
"Received OK listen reply from [TOE] for port %d.\n", LSN_PORT_TABLE[lsn_i].to_uint());
355 if (lsn_i ==
sizeof(LSN_PORT_TABLE)/
sizeof(LSN_PORT_TABLE[0])-1) {
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());
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());
383 #if defined USE_INTERRUPTS
404 stream<TcpAppData> &siSHL_Data,
405 stream<TcpAppMeta> &siSHL_Meta,
406 stream<SigBit> &soRRh_EnquSig,
407 stream<TcpAppData> &soRDp_Data,
408 stream<TcpAppMeta> &soRDp_Meta)
411 #pragma HLS INLINE off
412 #pragma HLS PIPELINE II=1 enable_flush
417 static enum FsmStates { IRB_IDLE=0, IRB_STREAM } \
418 irb_fsmState=IRB_IDLE;
419 #pragma HLS reset variable=irb_fsmState
421 if (*piSHL_Enable != 1) {
425 switch (irb_fsmState ) {
427 if (!siSHL_Meta.empty() and !soRDp_Meta.full()) {
428 soRDp_Meta.write(siSHL_Meta.read());
429 irb_fsmState = IRB_STREAM;
433 if (!siSHL_Data.empty() and !soRDp_Data.full() and !soRRh_EnquSig.full()) {
435 soRDp_Data.write(currChunk);
436 soRRh_EnquSig.write(1);
438 irb_fsmState = IRB_IDLE;
453 void pRxBufferOccupancy(
454 stream<SigBit> &siEnqueueSig,
455 stream<SigBit> &siDequeueSig,
459 #pragma HLS INLINE off
460 #pragma HLS PIPELINE II=1 enable_flush
464 static ap_uint<log2Ceil<cIBuffBytes>::val+1> rrh_freeSpace=
cIBuffBytes;
465 #pragma HLS reset variable=rrh_freeSpace
467 bool traceInc =
false;
468 bool traceDec =
false;
470 if (!siEnqueueSig.empty() and siDequeueSig.empty()) {
472 rrh_freeSpace -= (
ARW/8);
474 }
else if (siEnqueueSig.empty() and !siDequeueSig.empty()) {
476 rrh_freeSpace += (
ARW/8);
478 }
else if (!siEnqueueSig.empty() and !siDequeueSig.empty()) {
485 soFreeSpace.write(rrh_freeSpace);
488 if (traceInc or traceDec) {
489 printInfo(myName,
"Input buffer occupancy = %d bytes (%c|%c)\n",
491 (traceInc ?
'+' :
' '), (traceDec ?
'-' :
' '));
516 void pRxPostNotification(
517 stream<TcpAppNotif> &siSHL_Notif,
518 stream<InterruptQuery> &soRit_InterruptQry,
519 stream<InterruptEntry> &siRit_InterruptRep,
520 stream<SessionId> &soRsr_SessId)
523 #pragma HLS INLINE off
524 #pragma HLS PIPELINE II=1 enable_flush
529 static enum PostFsmStates { RPN_IDLE, RPN_INC, RPN_POST } \
530 rpn_fsmState=RPN_IDLE;
531 #pragma HLS reset variable=rpn_fsmState
539 switch (rpn_fsmState) {
541 if (!siSHL_Notif.empty() and !soRit_InterruptQry.full()) {
542 rpn_notif = siSHL_Notif.read();
545 soRit_InterruptQry.write(getQuery);
546 rpn_fsmState = RPN_INC;
551 if (!siRit_InterruptRep.empty()) {
554 rpn_fsmState = RPN_POST;
558 if (!soRit_InterruptQry.full() and !soRsr_SessId.full()) {
561 soRit_InterruptQry.write(postQuery);
563 rpn_fsmState = RPN_IDLE;
587 void pRxInterruptTable(
588 stream<InterruptQuery> &siRpn_InterruptQry,
589 stream<InterruptEntry> &soRpn_InterruptRep,
590 stream<InterruptQuery> &siRsr_InterruptQry,
591 stream<InterruptEntry> &soRsr_InterruptRep)
594 #pragma HLS INLINE off
595 #pragma HLS PIPELINE II=1 enable_flush
601 #pragma HLS RESOURCE variable=INTERRUPT_TABLE core=RAM_2P
602 #pragma HLS DEPENDENCE variable=INTERRUPT_TABLE inter false
605 static bool rit_isInit=
false;
606 #pragma HLS reset variable=rit_isInit
607 static ap_uint<log2Ceil<cMaxSessions>::val> rit_initEntry=0;
608 #pragma HLS reset variable=rit_initEntry
610 static enum FsmStates { RIT_IDLE, RIT_NOTIF_REQ, RIT_NOTIF_REP, RIT_NOTIF_UPDATE, \
611 RIT_SCHED_REQ, RIT_SCHED_REP, RIT_SCHED_UPDATE } rit_fsmState=RIT_IDLE;
626 printInfo(myName,
"Done with initialization of INTERRUPT_TABLE.\n");
633 switch (rit_fsmState) {
635 if (!siRpn_InterruptQry.empty()) {
636 rit_notifQuery = siRpn_InterruptQry.read();
638 printFatal(myName,
"Expecting a query 'GET' request!\n");
640 rit_fsmState = RIT_NOTIF_REQ;
642 else if (!siRsr_InterruptQry.empty()) {
643 rit_schedQuery = siRsr_InterruptQry.read();
645 printFatal(myName,
"Expecting a query 'GET' request!\n");
647 rit_fsmState = RIT_SCHED_REQ;
651 rit_notifEntry = INTERRUPT_TABLE[rit_notifQuery.
sessId];
652 rit_fsmState = RIT_NOTIF_REP;
655 if (!soRpn_InterruptRep.full()) {
656 soRpn_InterruptRep.write(rit_notifEntry);
657 rit_fsmState = RIT_NOTIF_UPDATE;
661 rit_schedEntry = INTERRUPT_TABLE[rit_schedQuery.
sessId];
662 rit_fsmState = RIT_SCHED_REP;
665 if (!soRsr_InterruptRep.full()) {
666 soRsr_InterruptRep.write(rit_schedEntry);
667 rit_fsmState = RIT_SCHED_UPDATE;
670 case RIT_NOTIF_UPDATE:
671 if (!siRpn_InterruptQry.empty()) {
680 printFatal(myName,
"Expecting a query 'PUT' or 'PUSH' request!\n");
682 rit_fsmState = RIT_IDLE;
685 case RIT_SCHED_UPDATE:
686 if (!siRsr_InterruptQry.empty()) {
695 printFatal(myName,
"Expecting a query 'PUT' or 'PUSH' request!\n");
697 rit_fsmState = RIT_IDLE;
710 stream<SessionId> &siRpn_SessId,
711 stream<ReqBit> &siRxs_SessIdReq,
712 stream<SessionId> &soRxs_SessIdRep,
713 stream<SessionId> &siRxs_ClearInt)
716 #pragma HLS INLINE off
717 #pragma HLS PIPELINE II=1 enable_flush
722 static ap_uint<cMaxSessions> rsr_pendingInterrupts=0;
723 #pragma HLS reset variable=rsr_pendingInterrupts
725 #pragma HLS reset variable=rsr_currSess
728 ap_uint<log2Ceil<cMaxSessions>::val> nextSess=0;
729 ap_uint<cMaxSessions> setVec=0;
730 ap_uint<cMaxSessions> clrVec=0;
733 if (!siRpn_SessId.empty()) {
737 printInfo(myName,
"Set interrupt for session #%d.\n", sessId.to_uint());
741 if (!siRxs_ClearInt.empty()) {
742 SessionId sessId = siRxs_ClearInt.read();
745 printInfo(myName,
"Clear interrupt for session #%d.\n", sessId.to_uint());
749 rsr_pendingInterrupts = (rsr_pendingInterrupts xor clrVec) | setVec;
752 bool currSessValid =
false;
753 if (!siRxs_SessIdReq.empty() and !soRxs_SessIdRep.full()) {
757 nextSess = rsr_currSess + i + 1;
758 if (rsr_pendingInterrupts[nextSess] == 1) {
759 rsr_currSess = nextSess;
760 currSessValid =
true;
763 if (currSessValid ==
true) {
764 siRxs_SessIdReq.read();
765 soRxs_SessIdRep.write(nextSess);
767 printInfo(myName,
"RR-Arbiter has scheduled session #%d.\n", nextSess.to_uint());
796 stream<ReqBit> &soRxh_SessIdReq,
797 stream<SessionId> &siRxh_SessIdRep,
799 stream<InterruptQuery> &soRit_InterruptQry,
800 stream<InterruptEntry> &siRit_InterruptRep,
801 stream<SessionId> &soRxh_ClearReq,
802 stream<TcpAppRdReq> &soSHL_DReq,
803 stream<ForwardCmd> &soRDp_FwdCmd)
806 #pragma HLS INLINE off
807 #pragma HLS PIPELINE II=1 enable_flush
812 static enum FsmStates { RSR_SREQ, RSR_SREP, RSR_DEC, RSR_PUT, RSR_FWD } \
813 rsr_fsmState=RSR_SREQ;
814 #pragma HLS reset variable=rsr_fsmState
816 #pragma HLS reset variable=rsr_freeSpace
822 static ap_uint<cMaxSessions> rsr_pendingInterrupts;
826 if (!siRxb_FreeSpace.empty()) {
827 rsr_freeSpace = siRxb_FreeSpace.read();
830 switch(rsr_fsmState) {
832 if (!soRxh_SessIdReq.full()) {
833 soRxh_SessIdReq.write(1);
834 rsr_fsmState = RSR_SREP;
838 if (!siRxh_SessIdRep.empty() and !soRit_InterruptQry.full()) {
839 rsr_currSess = siRxh_SessIdRep.read();
840 soRit_InterruptQry.write(rsr_currSess);
842 printInfo(myName,
"Querying [Rit] for session #%d.\n", rsr_currSess.to_uint());
844 rsr_fsmState = RSR_DEC;
848 if (!siRit_InterruptRep.empty()) {
850 rsr_intEntry = siRit_InterruptRep.read();
852 rsr_datLenReq = (rsr_freeSpace < rsr_intEntry.
byteCnt) ? (rsr_freeSpace) : (rsr_intEntry.
byteCnt);
854 printInfo(myName,
"NotifBytes=%d - FreeSpace=%d \n",
855 rsr_intEntry.
byteCnt.to_uint(), rsr_freeSpace.to_uint());
857 rsr_fsmState = RSR_PUT;
861 if (!soRit_InterruptQry.full() and !soRxh_ClearReq.full()) {
862 newByteCnt = rsr_intEntry.
byteCnt - rsr_datLenReq;
863 soRit_InterruptQry.write(
InterruptQuery(rsr_currSess, newByteCnt));
864 if (newByteCnt == 0) {
865 soRxh_ClearReq.write(rsr_currSess);
867 printInfo(myName,
"Request to clear interrupt #%d.\n", rsr_currSess.to_uint());
870 rsr_fsmState = RSR_FWD;
874 if (!soSHL_DReq.full() and !soRDp_FwdCmd.full()) {
875 soSHL_DReq.write(
TcpAppRdReq(rsr_currSess, rsr_datLenReq));
876 switch (rsr_intEntry.
dstPort) {
888 printInfo(myName,
"Sending DReq(SessId=%2d, DatLen=%4d) to RDp (expected TcpDstPort=%4d).\n",
889 rsr_currSess.to_uint(), rsr_datLenReq.to_uint(), rsr_intEntry.
dstPort.to_uint());
892 rsr_fsmState = RSR_SREQ;
941 stream<TcpAppNotif> &siSHL_Notif,
942 stream<SigBit> &siIRb_EnquSig,
943 stream<SigBit> &siRDp_DequSig,
944 stream<TcpAppRdReq> &soSHL_DReq,
945 stream<ForwardCmd> &soRDp_FwdCmd)
949 #pragma HLS INTERFACE ap_ctrl_none port=return
950 #pragma HLS INLINE off
955 static stream<InterruptQuery> ssRpnToRit_InterruptQry (
"ssRpnToRit_InterruptQry");
956 #pragma HLS stream variable=ssRpnToRit_InterruptQry depth=2
957 static stream<SessionId> ssRpnToRxh_SessId (
"ssRpnToRxh_SessId");
958 #pragma HLS stream variable=ssRpnToRxh_SessId depth=4
960 static stream<InterruptEntry> ssRitToRsr_InterruptRep (
"ssRitToRsr_InterruptRep");
961 #pragma HLS stream variable=ssRitToRsr_InterruptRep depth=2
962 static stream<InterruptEntry> ssRitToRpn_InterruptRep (
"ssRitToRpn_InterruptRep");
963 #pragma HLS stream variable=ssRitToRpn_InterruptRep depth=2
965 static stream<InterruptQuery> ssRxsToRit_InterruptQry (
"ssRxsToRit_InterruptQry");
966 #pragma HLS stream variable=ssRxsToRit_InterruptQry depth=2
968 static stream<ReqBit> ssRxsToRxh_SessIdReq (
"ssRxsToRxh_SessIdReq");
969 #pragma HLS stream variable=ssRxsToRxh_SessIdReq depth=2
970 static stream<SessionId> ssRxsToRxh_ClearInt (
"ssRxsToRxh_ClearInt");
971 #pragma HLS stream variable=ssRxsToRxh_ClearInt depth=2
973 static stream<SessionId> ssRxhToRxs_SessIdRep (
"ssRxhToRxs_SessIdRep");
974 #pragma HLS stream variable=ssRxhToRxs_SessIdRep depth=2
976 static stream<ap_uint<log2Ceil<cIBuffBytes>::val+1> > ssRxbToRxs_FreeSpace (
"ssRxbToRxs_FreeSpace");
977 #pragma HLS stream variable=ssRxbToRxs_FreeSpace depth=4
983 ssRxbToRxs_FreeSpace);
987 ssRpnToRit_InterruptQry,
988 ssRitToRpn_InterruptRep,
993 ssRxsToRxh_SessIdReq,
994 ssRxhToRxs_SessIdRep,
995 ssRxsToRxh_ClearInt);
998 ssRxsToRxh_SessIdReq,
999 ssRxhToRxs_SessIdRep,
1000 ssRxbToRxs_FreeSpace,
1001 ssRxsToRit_InterruptQry,
1002 ssRitToRsr_InterruptRep,
1003 ssRxsToRxh_ClearInt,
1008 ssRpnToRit_InterruptQry,
1009 ssRitToRpn_InterruptRep,
1010 ssRxsToRit_InterruptQry,
1011 ssRitToRsr_InterruptRep);
1035 stream<TcpAppData> &siSHL_Data,
1036 stream<TcpAppMeta> &siSHL_Meta,
1037 stream<TcpAppData> &soRDp_Data,
1038 stream<TcpAppMeta> &soRDp_Meta)
1041 #pragma HLS INLINE off
1042 #pragma HLS PIPELINE II=1 enable_flush
1046 if (*piSHL_Enable != 1) {
1050 if (!siSHL_Meta.empty() and !soRDp_Meta.full()) {
1051 soRDp_Meta.write(siSHL_Meta.read());
1053 if (!siSHL_Data.empty() and !soRDp_Data.full()) {
1054 soRDp_Data.write(siSHL_Data.read());
1076 stream<TcpAppNotif> &siSHL_Notif,
1077 stream<TcpAppNotif> &soRRh_Notif)
1080 #pragma HLS INLINE off
1081 #pragma HLS PIPELINE II=1 enable_flush
1085 if (*piSHL_Enable != 1) {
1089 if (!siSHL_Notif.empty()) {
1091 siSHL_Notif.read(notif);
1093 printFatal(myName,
"Received a notification for a TCP segment of length 'zero'. Don't know what to do with it!\n");
1095 if (!soRRh_Notif.full()) {
1096 soRRh_Notif.write(notif);
1099 printFatal(myName,
"The Rx Notif FiFo is full. Consider increasing the depth of this FiFo.\n");
1142 stream<TcpAppNotif> &siRNh_Notif,
1143 stream<SigBit> &siRDp_DequSig,
1144 stream<TcpAppRdReq> &soRRm_DReq,
1145 stream<ForwardCmd> &soRDp_FwdCmd,
1146 stream<ap_uint<16> > &soDBG_freeSpace)
1149 #pragma HLS INLINE off
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
1164 if (*piSHL_Enable != 1) {
1169 switch(rrh_fsmState) {
1172 if (!siRDp_DequSig.empty()) {
1173 siRDp_DequSig.read();
1174 rrh_freeSpace += (
ARW/8);
1176 printInfo(myName,
"FreeSpace=%4d bytes\n", rrh_freeSpace.to_uint());
1179 if (!siRNh_Notif.empty()) {
1180 siRNh_Notif.read(rrh_notif);
1181 rrh_fsmState = RRH_GEN_DLEN;
1183 printInfo(myName,
"Received a new notification (SessId=%2d | DatLen=%4d | TcpDstPort=%4d).\n",
1191 if (rrh_freeSpace < rrh_notif.
tcpDatLen) {
1193 rrh_datLenReq = rrh_freeSpace;
1196 if (!siRDp_DequSig.empty()) {
1197 siRDp_DequSig.read();
1198 rrh_freeSpace += (
ARW/8);
1211 rrh_freeSpace -= (
ARW/8);
1213 if (!siRDp_DequSig.empty()) {
1214 siRDp_DequSig.read();
1215 rrh_freeSpace += (
ARW/8);
1220 rrh_fsmState = RRH_SEND_DREQ;
1224 printInfo(myName,
"FreeSpace=%4d is too low. Waiting for buffer to drain. \n",
1225 rrh_freeSpace.to_uint());
1228 if (!siRDp_DequSig.empty()) {
1229 siRDp_DequSig.read();
1230 rrh_freeSpace += (
ARW/8);
1235 printInfo(myName,
"DataLenReq=%4d | FreeSpace=%4d | NotifBytes=%4d \n",
1236 rrh_datLenReq.to_uint(), rrh_freeSpace.to_uint(), rrh_notif.
tcpDatLen.to_uint());
1241 if (!siRDp_DequSig.empty()) {
1242 siRDp_DequSig.read();
1243 rrh_freeSpace += (
ARW/8);
1245 printInfo(myName,
"FreeSpace=%4d bytes\n", rrh_freeSpace.to_uint());
1248 if (!soRRm_DReq.full() and !soRDp_FwdCmd.full()) {
1262 rrh_fsmState = RRH_IDLE;
1264 printInfo(myName,
"Done with notification (SessId=%2d | DatLen=%4d | TcpDstPort=%4d).\n",
1269 rrh_fsmState = RRH_GEN_DLEN;
1272 printInfo(myName,
"Sending DReq(SessId=%2d, DatLen=%4d) to SHELL (requested TcpDstPort was %4d).\n",
1280 if (!soDBG_freeSpace.full()) {
1281 soDBG_freeSpace.write(rrh_freeSpace);
1284 printFatal(myName,
"Cannot write soDBG_freeSpace stream...");
1301 stream<TcpAppRdReq> &siRRh_DReq,
1302 stream<TcpAppRdReq> &soSHL_DReq)
1305 #pragma HLS INLINE off
1306 #pragma HLS PIPELINE II=1 enable_flush
1308 if (*piSHL_Enable != 1) {
1311 if (!siRRh_DReq.empty()) {
1349 stream<TcpAppData> &siSHL_Data,
1350 stream<TcpAppMeta> &siSHL_Meta,
1351 stream<ForwardCmd> &siRRh_FwdCmd,
1352 stream<SockAddr> &soCOn_OpnSockReq,
1353 stream<TcpDatLen> &soCOn_TxCountReq,
1354 stream<SigBit> &soRRh_DequSig,
1355 stream<TcpAppData> &soTAF_Data,
1356 stream<TcpSessId> &soTAF_SessId,
1357 stream<TcpDatLen> &soTAF_DatLen,
1358 stream<ap_uint<32> > &soDBG_SinkCount)
1361 #pragma HLS INLINE off
1362 #pragma HLS PIPELINE II=1 enable_flush
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
1382 if (*piSHL_Enable != 1) {
1386 switch (rdp_fsmState ) {
1388 if (!siRRh_FwdCmd.empty() and !siSHL_Meta.empty()) {
1389 siRRh_FwdCmd.read(rdp_fwdCmd);
1390 siSHL_Meta.read(rdp_sessId);
1392 rdp_fsmState = RDP_FWD_META;
1395 rdp_fsmState = RDP_SINK_META;
1400 if (!soTAF_SessId.full() and !soTAF_DatLen.full()) {
1401 soTAF_SessId.write(rdp_sessId);
1402 soTAF_DatLen.write(rdp_fwdCmd.
datLen);
1404 printInfo(myName,
"soTAF_SessId = %d \n", rdp_sessId.to_uint());
1405 printInfo(myName,
"soTAF_DatLen = %d \n", rdp_fwdCmd.
datLen.to_uint());
1407 rdp_fsmState = RDP_FWD_STREAM;
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);
1417 rdp_fsmState = RDP_IDLE;
1423 rdp_fsmState = RDP_8801;
1426 rdp_fsmState = RDP_SINK_STREAM;
1429 case RDP_SINK_STREAM:
1430 if (!siSHL_Data.empty()) {
1431 siSHL_Data.read(appData);
1432 soRRh_DequSig.write(1);
1434 rdp_sinkCnt += appData.
getLen();
1435 soDBG_SinkCount.write(rdp_sinkCnt);
1437 rdp_fsmState = RDP_IDLE;
1442 if (!siSHL_Data.empty() and !soCOn_OpnSockReq.full() and !soCOn_TxCountReq.full()) {
1444 siSHL_Data.read(appData);
1445 soRRh_DequSig.write(1);
1449 soCOn_OpnSockReq.write(sockToOpen);
1452 printInfo(myName,
"Received request for Tx test mode to generate a segment of length=%d and to send it to socket:\n",
1457 rdp_fsmState = RDP_IDLE;
1460 rdp_fsmState = RDP_SINK_STREAM;
1498 stream<TcpAppData> &siTAF_Data,
1499 stream<TcpSessId> &siTAF_SessId,
1500 stream<TcpDatLen> &siTAF_DatLen,
1501 stream<TcpDatLen> &siCOn_TxBytesReq,
1502 stream<SessionId> &siCOn_TxSessId,
1503 stream<TcpAppData> &soSHL_Data,
1504 stream<TcpAppSndReq> &soSHL_SndReq,
1505 stream<TcpAppSndRep> &siSHL_SndRep)
1508 #pragma HLS INLINE off
1509 #pragma HLS PIPELINE II=1 enable_flush
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 } \
1520 #pragma HLS reset variable=wrp_genChunk
1525 static uint16_t wrp_retryCnt;
1530 if (*piSHL_Enable != 1) {
1534 switch (wrp_fsmState) {
1537 if (!siCOn_TxSessId.empty() and !siCOn_TxBytesReq.empty()) {
1538 siCOn_TxSessId.read(wrp_sendReq.
sessId);
1539 siCOn_TxBytesReq.read(wrp_sendReq.
length);
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());
1544 if (wrp_sendReq.
length != 0) {
1545 wrp_testMode =
true;
1546 wrp_retryCnt = 0x200;
1547 wrp_fsmState = WRP_RTS;
1550 wrp_fsmState = WRP_IDLE;
1553 else if (!siTAF_SessId.empty() and !siTAF_DatLen.empty()) {
1554 siTAF_SessId.read(wrp_sendReq.
sessId);
1555 siTAF_DatLen.read(wrp_sendReq.
length);
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());
1560 if (wrp_sendReq.
length != 0) {
1561 wrp_testMode =
false;
1562 wrp_retryCnt = 0x200;
1563 wrp_fsmState = WRP_RTS;
1568 if (!soSHL_SndReq.full()) {
1569 soSHL_SndReq.write(wrp_sendReq);
1570 wrp_fsmState = WRP_RTS_REP;
1574 if (!siSHL_SndRep.empty()) {
1577 switch (appSndRep.
error) {
1580 wrp_genChunk = CHK0;
1581 wrp_fsmState = WRP_TXGEN;
1584 wrp_fsmState = WRP_STREAM;
1588 printWarn(myName,
"Not enough space for writing %d bytes in the Tx buffer of session #%d. Available space is %d bytes.\n",
1592 wrp_fsmState = WRP_RTS;
1596 wrp_fsmState = WRP_IDLE;
1599 wrp_fsmState = WRP_DRAIN;
1604 printWarn(myName,
"Attempt to write data for a session that is not established.\n");
1606 wrp_fsmState = WRP_IDLE;
1609 wrp_fsmState = WRP_DRAIN;
1613 printFatal(myName,
"Received unknown TCP request to send reply from [TOE].\n");
1614 wrp_fsmState = WRP_IDLE;
1620 if (!siTAF_Data.empty() and !soSHL_Data.full()) {
1621 siTAF_Data.read(appData);
1622 soSHL_Data.write(appData);
1625 wrp_fsmState = WRP_IDLE;
1630 if (!soSHL_Data.full()) {
1632 if (wrp_sendReq.
length > 8) {
1639 wrp_fsmState = WRP_IDLE;
1641 switch (wrp_genChunk) {
1644 wrp_genChunk = CHK1;
1648 wrp_genChunk = CHK0;
1652 soSHL_Data.write(currChunk);
1657 if (!siTAF_Data.empty()) {
1658 siTAF_Data.read(appData);
1661 wrp_fsmState = WRP_IDLE;
1701 stream<TcpAppData> &siTAF_Data,
1702 stream<TcpSessId> &siTAF_SessId,
1703 stream<TcpDatLen> &siTAF_DatLen,
1708 stream<TcpAppData> &soTAF_Data,
1709 stream<TcpSessId> &soTAF_SessId,
1710 stream<TcpDatLen> &soTAF_DatLen,
1715 stream<TcpAppNotif> &siSHL_Notif,
1716 stream<TcpAppRdReq> &soSHL_DReq,
1717 stream<TcpAppData> &siSHL_Data,
1718 stream<TcpAppMeta> &siSHL_Meta,
1723 stream<TcpAppLsnReq> &soSHL_LsnReq,
1724 stream<TcpAppLsnRep> &siSHL_LsnRep,
1729 stream<TcpAppData> &soSHL_Data,
1730 stream<TcpAppSndReq> &soSHL_SndReq,
1731 stream<TcpAppSndRep> &siSHL_SndRep,
1736 stream<TcpAppOpnReq> &soSHL_OpnReq,
1737 stream<TcpAppOpnRep> &siSHL_OpnRep,
1742 stream<TcpAppClsReq> &soSHL_ClsReq,
1747 stream<ap_uint<32> > &soDBG_SinkCnt,
1748 stream<ap_uint<16> > &soDBG_InpBufSpace)
1751 #pragma HLS DATAFLOW
1753 #pragma HLS INTERFACE ap_ctrl_none port=return
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
1766 static stream <TcpAppNotif> ssRNhToRRh_Notif (
"ssRNhToRRh_Notif");
1767 #pragma HLS stream variable=ssRNhToRRh_Notif depth=cDepth_RNhToRRh_Notif
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
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
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
1793 ssRDpToCOn_OpnSockReq,
1794 ssRDpToCOn_TxCountReq,
1795 ssCOnToWRp_TxBytesReq,
1796 ssCOnToWRp_TxSessId,
1818 ssRDpToCOn_OpnSockReq,
1819 ssRDpToCOn_TxCountReq,
1831 #if defined USE_INTERRUPTS
1858 ssCOnToWRp_TxBytesReq,
1859 ssCOnToWRp_TxSessId,
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)
#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.
const char * getTcpStateName(TcpState tcpState)
Returns the name of an enum-based TCP-State as a user friendly string.
#define printInfo(callerName, format,...)
A macro to print an information message.
#define printWarn(callerName, format,...)
A macro to print a warning message.
#define concat3(firstCharConst, secondCharConst, thirdCharConst)
#define printFatal(callerName, format,...)
A macro to print a fatal error message and exit.
void pStreamDataMover(stream< Type > &si, stream< Type > &so)
Stream Data Mover - Moves data chunks from incoming stream to outgoing stream with blocking read and ...
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 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 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).
#define RECV_MODE_LSN_PORT
#define XMIT_MODE_LSN_PORT
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)
#define ECHO_MOD2_LSN_PORT
void pReadNotificationHandler(CmdBit *piSHL_Enable, stream< TcpAppNotif > &siSHL_Notif, stream< TcpAppNotif > &soRRh_Notif)
Read Notification Handler (RNh)
#define ECHO_MODE_LSN_PORT
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)
: TCP Shell Interface (TSIF)
ap_uint< 32 > byteSwap32(ap_uint< 32 > inputVector)
ap_uint< 16 > byteSwap16(ap_uint< 16 > inputVector)