68 #define THIS_NAME "TOE/RXe"
70 #define TRACE_OFF 0x0000
71 #define TRACE_TLE 1 << 1
72 #define TRACE_IPH 1 << 2
73 #define TRACE_CSA 1 << 3
74 #define TRACE_MDH 1 << 4
75 #define TRACE_TID 1 << 5
76 #define TRACE_TSD 1 << 6
77 #define TRACE_EVM 1 << 7
78 #define TRACE_FSM 1 << 8
79 #define TRACE_MWR 1 << 9
80 #define TRACE_RAN 1 << 10
81 #define TRACE_ALL 0xFFFF
83 #define DEBUG_LEVEL (TRACE_OFF)
146 stream<AxisIp4> &siIPRX_Data,
147 stream<AxisRaw> &soIph_Data,
148 stream<TcpSegLen> &soIph_TcpSegLen)
151 #pragma HLS PIPELINE II=1 enable_flush
152 #pragma HLS INLINE off
157 static ap_uint<4> tle_chunkCount=0;
158 #pragma HLS RESET variable=tle_chunkCount
159 static bool tle_residue=
false;
160 #pragma HLS RESET variable=tle_residue
163 static bool tle_shift;
173 if (!siIPRX_Data.empty() and !soIph_Data.full() and !tle_residue) {
174 AxisIp4 currChunk = siIPRX_Data.read();
175 switch (tle_chunkCount) {
180 tle_ipDataLen = tle_ip4TotLen - (tle_ip4HdrLen * 4);
186 soIph_TcpSegLen.write(tle_ipDataLen);
198 soIph_Data.write(sendChunk);
204 switch (tle_ip4HdrLen) {
211 soIph_Data.write(sendChunk);
218 soIph_Data.write(sendChunk);
237 soIph_Data.write(sendChunk);
247 soIph_Data.write(sendChunk);
256 tle_prevChunk = currChunk;
258 else if (tle_residue) {
263 soIph_Data.write(sendChunk);
321 stream<AxisRaw> &siTle_Data,
322 stream<TcpSegLen> &siTle_TcpSegLen,
323 stream<AxisPsd4> &soCsa_PseudoPkt)
326 #pragma HLS PIPELINE II=1 enable_flush
327 #pragma HLS INLINE off
332 static bool iph_residue=
false;
333 #pragma HLS RESET variable=iph_residue
334 static ap_uint<2> iph_chunkCount=0;
335 #pragma HLS RESET variable=iph_chunkCount
352 soCsa_PseudoPkt.write(sendChunk);
356 else if(!siTle_Data.empty() and !soCsa_PseudoPkt.full()) {
357 switch (iph_chunkCount) {
360 siTle_Data.read(currChunk);
361 soCsa_PseudoPkt.write(currChunk);
367 if (!siTle_TcpSegLen.empty()) {
369 siTle_Data.read(currChunk);
378 soCsa_PseudoPkt.write(sendChunk);
384 siTle_Data.read(currChunk);
393 soCsa_PseudoPkt.write(sendChunk);
398 iph_prevChunk = currChunk;
445 stream<AxisPsd4> &siIph_PseudoPkt,
446 stream<AxisApp> &soTid_Data,
447 stream<ValBit> &soTid_DataVal,
448 stream<RXeMeta> &soMdh_Meta,
449 stream<SocketPair> &soMdh_SockPair,
450 stream<TcpPort> &soPRt_GetState)
453 #pragma HLS PIPELINE II=1 enable_flush
454 #pragma HLS INLINE off
459 static ap_uint<3> csa_chunkCount=0;
460 #pragma HLS RESET variable=csa_chunkCount
461 static bool csa_doCSumVerif=
false;
462 #pragma HLS RESET variable=csa_doCSumVerif
463 static bool csa_residue=
false;
464 #pragma HLS RESET variable=csa_residue
465 static ap_uint<3> csa_cc_state=0;
466 #pragma HLS RESET variable=csa_cc_state
467 static ap_uint<17> csa_tcp_sums[4]={0, 0, 0, 0};
468 #pragma HLS RESET variable=csa_tcp_sums
469 #pragma HLS ARRAY_PARTITION \
470 variable=csa_tcp_sums complete dim=1
474 static bool csa_doShift;
479 static ap_uint<32> csa_half_tdata;
480 static ap_uint<4> csa_half_tkeep;
486 if (!siIph_PseudoPkt.empty() and !soTid_Data.full() and !csa_doCSumVerif) {
487 currChunk = siIph_PseudoPkt.read();
489 switch (csa_chunkCount) {
518 csa_meta.
length -= (csa_dataOffset * 4);
534 if (csa_dataOffset >= 6) {
544 printInfo(myName,
"TCP segment includes 4 option bytes (OptKind=2, OptLen=4, MSS=%d)\n",
549 printWarn(myName,
"The TCP option %d is not yet supported and will be dropped.\n", optionKind.to_uchar());
551 if (csa_dataOffset == 6) {
564 sendChunk = currChunk;
565 soTid_Data.write(sendChunk);
573 soTid_Data.write(sendChunk);
583 for (
int i = 0; i < 4; i++) {
587 temp( 7, 0) = currChunk.
getLE_TData(i*16+15, i*16+8);
588 temp(15, 8) = currChunk.
getLE_TData(i*16+ 7, i*16);
589 csa_tcp_sums[i] += temp;
590 csa_tcp_sums[i] = (csa_tcp_sums[i] + (csa_tcp_sums[i] >> 16)) & 0xFFFF;
595 csa_tcp_sums[i] += temp;
596 csa_tcp_sums[i] = (csa_tcp_sums[i] + (csa_tcp_sums[i] >> 16)) & 0xFFFF;
603 csa_residue = !sendChunk.
getTLast();
604 csa_doCSumVerif =
true;
607 else if(csa_residue and !soTid_Data.full()) {
608 if (csa_meta.
length != 0) {
614 soTid_Data.write(sendChunk);
619 else if (csa_doCSumVerif) {
620 switch (csa_cc_state) {
622 csa_tcp_sums[0] = (csa_tcp_sums[0] + (csa_tcp_sums[0] >> 16)) & 0xFFFF;
623 csa_tcp_sums[1] = (csa_tcp_sums[1] + (csa_tcp_sums[1] >> 16)) & 0xFFFF;
624 csa_tcp_sums[2] = (csa_tcp_sums[2] + (csa_tcp_sums[2] >> 16)) & 0xFFFF;
625 csa_tcp_sums[3] = (csa_tcp_sums[3] + (csa_tcp_sums[3] >> 16)) & 0xFFFF;
629 csa_tcp_sums[0] += csa_tcp_sums[2];
630 csa_tcp_sums[1] += csa_tcp_sums[3];
631 csa_tcp_sums[0] = (csa_tcp_sums[0] + (csa_tcp_sums[0] >> 16)) & 0xFFFF;
632 csa_tcp_sums[1] = (csa_tcp_sums[1] + (csa_tcp_sums[1] >> 16)) & 0xFFFF;
636 csa_tcp_sums[0] += csa_tcp_sums[1];
637 csa_tcp_sums[0] = (csa_tcp_sums[0] + (csa_tcp_sums[0] >> 16)) & 0xFFFF;
641 csa_tcp_sums[0] = ~csa_tcp_sums[0];
645 if (csa_tcp_sums[0](15, 0) == 0) {
648 soMdh_Meta.write(csa_meta);
649 soMdh_SockPair.write(csa_socketPair);
650 if (csa_meta.
length != 0) {
652 soTid_DataVal.write(
OK);
654 printInfo(myName,
"Received end-of-packet. Checksum is correct.\n");
658 soPRt_GetState.write(csa_tcpDstPort);
661 printWarn(myName,
"RECEIVED BAD CHECKSUM (0x%4.4X - Delta= 0x%4.4X).\n",
662 csa_tcpCSum.to_uint(), (~csa_tcp_sums[0](15, 0).to_uint() & 0xFFFF));
663 if(csa_meta.
length != 0) {
665 soTid_DataVal.write(
KO);
671 csa_doCSumVerif =
false;
696 stream<AxisApp> &siCsa_Data,
697 stream<ValBit> &siCsa_DataVal,
698 stream<AxisApp> &soTsd_Data,
699 stream<ap_uint<8> > &soMMIO_CrcDropCnt)
702 #pragma HLS PIPELINE II=1 enable_flush
703 #pragma HLS INLINE off
708 static enum FsmStates { TSD_IDLE=0, TSD_FWD, TSD_DROP } \
709 tid_fsmState=TSD_IDLE;
710 #pragma HLS RESET variable=tid_fsmState
711 static ap_uint<8 > tid_crcDropCounter=0;
712 #pragma HLS reset variable=tid_crcDropCounter
719 switch (tid_fsmState) {
721 if (!siCsa_DataVal.empty()) {
722 siCsa_DataVal.read(validBit);
723 if (validBit ==
OK) {
724 tid_fsmState = TSD_FWD;
727 tid_fsmState = TSD_DROP;
728 tid_crcDropCounter++;
729 printWarn(myName,
"Bad checksum: Dropping payload for this packet!\n");
734 if(!siCsa_Data.empty() && !soTsd_Data.full()) {
735 siCsa_Data.read(currChunk);
736 soTsd_Data.write(currChunk);
738 tid_fsmState = TSD_IDLE;
744 if(!siCsa_Data.empty()) {
745 siCsa_Data.read(currChunk);
747 tid_fsmState = TSD_IDLE;
754 if (!soMMIO_CrcDropCnt.full()) {
755 soMMIO_CrcDropCnt.write(tid_crcDropCounter);
758 printFatal(myName,
"Cannot write soMMIO_CrcDropCnt stream...");
776 stream<AxisApp> &siTid_Data,
777 stream<CmdBit> &siMdh_DropCmd,
778 stream<CmdBit> &siFsm_DropCmd,
779 stream<AxisApp> &soMwr_Data)
782 #pragma HLS PIPELINE II=1 enable_flush
783 #pragma HLS INLINE off
788 static enum FsmStates { TSD_RD_DROP_CMD1=0, TSD_RD_DROP_CMD2, TSD_FWD, TSD_DROP } \
789 tsd_fsmState=TSD_RD_DROP_CMD1;
790 #pragma HLS RESET variable=tsd_fsmState
792 switch (tsd_fsmState) {
793 case TSD_RD_DROP_CMD1:
794 if (!siMdh_DropCmd.empty()) {
795 CmdBit dropCmd = siMdh_DropCmd.read();
797 tsd_fsmState = TSD_DROP;
798 printWarn(myName,
"[Mdh] is requesting to drop this packet.\n");
801 tsd_fsmState = TSD_RD_DROP_CMD2;
805 case TSD_RD_DROP_CMD2:
806 if (!siFsm_DropCmd.empty()) {
807 CmdBit dropCmd = siFsm_DropCmd.read();
809 tsd_fsmState = TSD_DROP;
810 printWarn(myName,
"[Fsm] is requesting to drop this packet.\n");
813 tsd_fsmState = TSD_FWD;
818 if(!siTid_Data.empty() && !soMwr_Data.full()) {
819 AxisApp currChunk = siTid_Data.read();
821 tsd_fsmState = TSD_RD_DROP_CMD1;
823 soMwr_Data.write(currChunk);
828 if(!siTid_Data.empty()) {
829 AxisApp currChunk = siTid_Data.read();
831 tsd_fsmState = TSD_RD_DROP_CMD1;
860 stream<AxisApp> &siTsd_Data,
861 stream<DmCmd> &siFsm_MemWrCmd,
862 stream<DmCmd> &soMEM_WrCmd,
863 stream<AxisApp> &soMEM_WrData,
864 stream<FlagBool> &soRan_SplitSeg)
867 #pragma HLS PIPELINE II=1 enable_flush
868 #pragma HLS INLINE off
873 static enum FsmStates { MWR_IDLE=0,
874 MWR_FWD_ALIGNED, MWR_SPLIT_1ST_CMD,
875 MWR_FWD_1ST_BUF, MWR_FWD_2ND_BUF, MWR_RESIDUE } \
876 mwr_fsmState=MWR_IDLE;
877 #pragma HLS RESET variable=mwr_fsmState
878 static ap_uint<3> mwr_residueLen=0;
879 #pragma HLS RESET variable=mwr_residueLen
880 static bool mwr_accessBreakdown=
false;
881 #pragma HLS RESET variable=mwr_accessBreakdown
884 static DmCmd mwr_memWrCmd;
888 static ap_uint<4> mwr_splitOffset;
889 static uint16_t mwr_debugCounter=3;
891 switch (mwr_fsmState) {
893 if (!siFsm_MemWrCmd.empty() and !soRan_SplitSeg.full() and !soMEM_WrCmd.full()) {
894 siFsm_MemWrCmd.read(mwr_memWrCmd);
895 if ((mwr_memWrCmd.
saddr.range(TOE_WINDOW_BITS-1, 0) + mwr_memWrCmd.
btt) > TOE_RX_BUFFER_SIZE) {
897 soRan_SplitSeg.write(
true);
900 printInfo(myName,
"TCP Rx memory buffer wraps around: This segment will be broken in two memory buffers.\n");
902 mwr_fsmState = MWR_SPLIT_1ST_CMD;
906 soRan_SplitSeg.write(
false);
907 soMEM_WrCmd.write(mwr_memWrCmd);
910 printInfo(myName,
"Issuing memory write command #%d - SADDR=0x%9.9x - BTT=%d\n",
911 mwr_debugCounter, mwr_memWrCmd.
saddr.to_uint(), mwr_memWrCmd.
btt.to_uint());
914 mwr_fsmState = MWR_FWD_ALIGNED;
918 case MWR_SPLIT_1ST_CMD:
919 if (!soMEM_WrCmd.full()) {
920 mwr_firstAccLen = TOE_RX_BUFFER_SIZE - mwr_memWrCmd.
saddr;
921 mwr_nrBytesToWr = mwr_firstAccLen;
922 soMEM_WrCmd.write(
DmCmd(mwr_memWrCmd.
saddr, mwr_firstAccLen));
925 printInfo(myName,
"Issuing 1st memory write command #%d - SADDR=0x%9.9x - BTT=%d\n",
926 mwr_debugCounter, mwr_memWrCmd.
saddr.to_uint(), mwr_firstAccLen.to_uint());
928 mwr_fsmState = MWR_FWD_1ST_BUF;
931 case MWR_FWD_ALIGNED:
932 if (!siTsd_Data.empty() and !soMEM_WrData.full()) {
935 AxisApp memChunk = siTsd_Data.read();
936 soMEM_WrData.write(memChunk);
938 mwr_fsmState = MWR_IDLE;
944 case MWR_FWD_1ST_BUF:
945 if (!siTsd_Data.empty() and !soMEM_WrData.full()) {
947 siTsd_Data.read(mwr_currChunk);
948 AxisApp memChunk = mwr_currChunk;
949 if (mwr_nrBytesToWr > (
ARW/8)) {
950 mwr_nrBytesToWr -= (
ARW/8);
952 else if (!soMEM_WrCmd.full()) {
953 if (mwr_nrBytesToWr == (
ARW/8)) {
958 mwr_memWrCmd.
saddr(TOE_WINDOW_BITS-1, 0) = 0;
959 mwr_memWrCmd.
btt -= mwr_firstAccLen;
960 soMEM_WrCmd.write(mwr_memWrCmd);
963 printInfo(myName,
"Issuing 2nd memory write command #%d - SADDR=0x%9.9x - BTT=%d\n",
964 mwr_debugCounter, mwr_memWrCmd.
saddr.to_uint(), mwr_memWrCmd.
btt.to_uint());
967 mwr_fsmState = MWR_FWD_ALIGNED;
973 #ifndef __SYNTHESIS__
978 mwr_memWrCmd.
saddr(TOE_WINDOW_BITS-1, 0) = 0;
979 mwr_memWrCmd.
btt -= mwr_firstAccLen;
980 soMEM_WrCmd.write(mwr_memWrCmd);
983 printInfo(myName,
"Issuing 2nd memory write command #%d - SADDR=0x%9.9x - BTT=%d\n",
984 mwr_debugCounter, mwr_memWrCmd.
saddr.to_uint(), mwr_memWrCmd.
btt.to_uint());
987 mwr_splitOffset = (
ARW/8) - mwr_nrBytesToWr;
989 mwr_fsmState = MWR_RESIDUE;
992 mwr_fsmState = MWR_FWD_2ND_BUF;
997 soMEM_WrData.write(memChunk);
1001 case MWR_FWD_2ND_BUF:
1002 if (!siTsd_Data.empty() && !soMEM_WrData.full()) {
1004 AxisApp prevChunk = mwr_currChunk;
1005 mwr_currChunk = siTsd_Data.read();
1010 ((
int)mwr_splitOffset*8)-1, 0);
1012 ((
int)mwr_splitOffset )-1, 0);
1015 (
ARW ) -1, ((
int)mwr_splitOffset*8));
1017 (
ARW/8) -1, ((
int)mwr_splitOffset ));
1019 if (mwr_currChunk.
getLen() > mwr_nrBytesToWr) {
1023 mwr_fsmState = MWR_RESIDUE;
1029 mwr_fsmState = MWR_IDLE;
1032 soMEM_WrData.write(joinedChunk);
1037 if (!soMEM_WrData.full()) {
1039 AxisApp prevChunk = mwr_currChunk;
1044 ((
int)mwr_splitOffset*8)-1, 0);
1046 ((
int)mwr_splitOffset )-1, 0);
1048 soMEM_WrData.write(lastChunk);
1051 mwr_fsmState = MWR_IDLE;
1076 stream<DmSts> &siMEM_WrSts,
1077 stream<TcpAppNotif> &siFsm_Notif,
1078 stream<TcpAppNotif> &soRAi_RxNotif,
1079 stream<FlagBool> &siMwr_SplitSeg,
1080 stream<StsBit> &soMMIO_MemWrErr)
1083 #pragma HLS PIPELINE II=1 enable_flush
1084 #pragma HLS INLINE off
1089 static stream<TcpAppNotif> ssRxNotifFifo(
"ssRxNotifFifo");
1090 #pragma HLS STREAM variable=ssRxNotifFifo depth=32
1091 #pragma HLS DATA_PACK variable=ssRxNotifFifo
1095 #pragma HLS RESET variable=ran_doubleAccessFlag
1097 #pragma HLS RESET variable=ran_dataMoverError
1100 static DmSts ran_dmStatus1;
1101 static DmSts ran_dmStatus2;
1104 if (ran_doubleAccessFlag ==
FLAG_ON) {
1106 if(!siMEM_WrSts.empty()) {
1107 siMEM_WrSts.read(ran_dmStatus2);
1108 if (ran_dmStatus1.
okay and ran_dmStatus2.
okay) {
1109 soRAi_RxNotif.write(ran_appNotification);
1111 printInfo(myName,
"Sending APP notification to [RAi]. This was a double access.\n");
1115 ran_dataMoverError = ran_dmStatus1.
slverr | ran_dmStatus1.
decerr | ran_dmStatus1.
interr | \
1116 ran_dmStatus2.slverr | ran_dmStatus2.
decerr | ran_dmStatus2.
interr;;
1118 printError(myName,
"The previous splitted mem-write command failed (OKAY=0).\n");
1126 if (!siMEM_WrSts.empty() and !siMwr_SplitSeg.empty() and !ssRxNotifFifo.empty()) {
1127 siMEM_WrSts.read(ran_dmStatus1);
1128 siMwr_SplitSeg.read(ran_doubleAccessFlag);
1129 ssRxNotifFifo.read(ran_appNotification);
1130 if (ran_doubleAccessFlag ==
FLAG_OFF) {
1132 if (ran_dmStatus1.
okay) {
1134 soRAi_RxNotif.write(ran_appNotification);
1136 printInfo(myName,
"Sending APP notification to [RAi].\n");
1140 ran_dataMoverError = ran_dmStatus1.
slverr | ran_dmStatus1.
decerr | ran_dmStatus1.
interr;
1142 printError(myName,
"The previous memory write command failed (OKAY=0).\n");
1148 printInfo(myName,
"The memory access was broken down in two parts.\n");
1152 else if (!siFsm_Notif.empty() and !ssRxNotifFifo.full()) {
1153 siFsm_Notif.read(ran_appNotification);
1154 if (ran_appNotification.
tcpDatLen != 0) {
1155 ssRxNotifFifo.write(ran_appNotification);
1159 printInfo(myName,
"Received an RxNotif with LENGTH=0.\n");
1165 if (!soMMIO_MemWrErr.full()) {
1166 soMMIO_MemWrErr.write(ran_dataMoverError);
1169 printFatal(myName,
"Cannot write soMMIO_MemWrerr stream...");
1198 stream<RXeMeta> &siCsa_Meta,
1199 stream<SocketPair> &siCsa_SockPair,
1200 stream<SessionLookupQuery> &soSLc_SessLkpReq,
1201 stream<SessionLookupReply> &siSLc_SessLkpRep,
1202 stream<StsBit> &siPRt_PortSts,
1203 stream<ExtendedEvent> &soEVe_Event,
1204 stream<CmdBit> &soTsd_DropCmd,
1205 stream<RXeFsmMeta> &soFsm_Meta,
1206 stream<ap_uint<8> > &soMMIO_SessDropCnt)
1209 #pragma HLS PIPELINE II=1 enable_flush
1210 #pragma HLS INLINE off
1215 static enum FsmStates { MDH_META=0, \
1216 MDH_LOOKUP } mdh_fsmState;
1217 #pragma HLS RESET variable=mdh_fsmState
1218 static ap_uint<8 > mdh_SessDropCounter=0;
1219 #pragma HLS reset variable=mdh_SessDropCounter
1225 static TcpPort mdh_tcpSrcPort;
1226 static TcpPort mdh_tcpDstPort;
1232 switch (mdh_fsmState) {
1235 if (!siPRt_PortSts.empty()) {
1237 if (!siCsa_Meta.empty() && !siCsa_SockPair.empty()) {
1238 siPRt_PortSts.read(dstPortStatus);
1239 siCsa_Meta.read(mdh_meta);
1240 siCsa_SockPair.read(socketPair);
1241 mdh_ip4SrcAddr = socketPair.
src.
addr;
1242 mdh_tcpSrcPort = socketPair.
src.
port;
1243 mdh_tcpDstPort = socketPair.
dst.
port;
1247 printWarn(myName,
"Port 0x%4.4X (%d) is not open.\n",
1248 mdh_tcpDstPort.to_uint(), mdh_tcpDstPort.to_uint());
1250 if (!mdh_meta.
rst) {
1257 if (mdh_meta.
syn || mdh_meta.
fin) {
1269 if (mdh_meta.
length != 0) {
1271 mdh_SessDropCounter++;
1277 printInfo(myName,
"Destination port 0x%4.4X (%d) is open.\n",
1278 mdh_tcpDstPort.to_uint(), mdh_tcpDstPort.to_uint());
1284 (mdh_meta.
syn && !mdh_meta.
rst && !mdh_meta.
fin)));
1286 printInfo(myName,
"Request the SLc to lookup the following session:\n");
1289 mdh_fsmState = MDH_LOOKUP;
1297 if (!siSLc_SessLkpRep.empty()) {
1298 siSLc_SessLkpRep.read(mdh_sessLookupReply);
1299 if (mdh_sessLookupReply.
hit) {
1302 mdh_ip4SrcAddr, mdh_tcpSrcPort,
1303 mdh_tcpDstPort, mdh_meta));
1305 printInfo(myName,
"Successful session lookup. \n");
1310 printWarn(myName,
"Session lookup failed! \n");
1312 if (mdh_meta.
length != 0) {
1313 soTsd_DropCmd.write(!mdh_sessLookupReply.
hit);
1314 if (!mdh_sessLookupReply.
hit) {
1315 mdh_SessDropCounter++;
1318 mdh_fsmState = MDH_META;
1324 if (!soMMIO_SessDropCnt.full()) {
1325 soMMIO_SessDropCnt.write(mdh_SessDropCounter);
1328 printFatal(myName,
"Cannot write soMMIO_SessDropCnt stream...");
1359 stream<RXeFsmMeta> &siMdh_FsmMeta,
1360 stream<StateQuery> &soSTt_StateQry,
1361 stream<TcpState> &siSTt_StateRep,
1362 stream<RXeRxSarQuery> &soRSt_RxSarQry,
1363 stream<RxSarReply> &siRSt_RxSarRep,
1364 stream<RXeTxSarQuery> &soTSt_TxSarQry,
1365 stream<RXeTxSarReply> &siTSt_TxSarRep,
1366 stream<RXeReTransTimerCmd> &soTIm_ReTxTimerCmd,
1367 stream<SessionId> &soTIm_ClearProbeTimer,
1368 stream<SessionId> &soTIm_CloseTimer,
1369 stream<SessState> &soTAi_SessOpnSts,
1370 stream<Event> &soEVe_Event,
1371 stream<CmdBit> &soTsd_DropCmd,
1372 stream<DmCmd> &soMwr_WrCmd,
1373 stream<TcpAppNotif> &soRan_RxNotif,
1374 stream<ap_uint<8> > &soMMIO_OooDropCnt,
1375 stream<RxBufPtr> &soDBG_RxFreeSpace,
1376 stream<ap_uint<32> > &soDBG_TcpIpRxByteCnt,
1377 stream<ap_uint<8> > &soDBG_OooDebug)
1380 #pragma HLS PIPELINE II=1 enable_flush
1381 #pragma HLS INLINE off
1386 static enum FsmStates { FSM_LOAD=0, FSM_TRANSITION } \
1387 fsm_fsmState=FSM_LOAD;
1388 #pragma HLS RESET variable=fsm_fsmState
1389 static bool fsm_txSarRequest=
false;
1390 #pragma HLS RESET variable=fsm_txSarRequest
1391 static ap_uint<8 > fsm_oooDropCounter=0;
1392 #pragma HLS RESET variable=fsm_oooDropCounter
1394 #pragma HLS RESET variable=fsm_freeSpace
1395 static ap_uint<32> fsm_rxByteCounter;
1396 #pragma HLS RESET variable=fsm_rxByteCounter
1397 static ap_uint<8 > fsm_oooDebugState=0;
1398 #pragma HLS RESET variable=fsm_oooDebugState
1404 ap_uint<4> control_bits;
1409 fsm_oooDebugState = 0;
1411 switch(fsm_fsmState) {
1413 if (!siMdh_FsmMeta.empty()) {
1414 siMdh_FsmMeta.read(fsm_Meta);
1422 fsm_txSarRequest =
true;
1424 fsm_fsmState = FSM_TRANSITION;
1425 fsm_oooDebugState = 1;
1428 case FSM_TRANSITION:
1430 if (!siSTt_StateRep.empty() and !siRSt_RxSarRep.empty() and
1431 !(fsm_txSarRequest and siTSt_TxSarRep.empty())) {
1432 fsm_fsmState = FSM_LOAD;
1433 fsm_txSarRequest =
false;
1435 control_bits[0] = fsm_Meta.
meta.
ack;
1436 control_bits[1] = fsm_Meta.
meta.
syn;
1437 control_bits[2] = fsm_Meta.
meta.
fin;
1438 control_bits[3] = fsm_Meta.
meta.
rst;
1439 switch (control_bits) {
1444 if (fsm_fsmState == FSM_LOAD) {
1445 siSTt_StateRep.read(tcpState);
1446 siRSt_RxSarRep.read(rxSar);
1447 siTSt_TxSarRep.read(txSar);
1450 fsm_freeSpace = ((rxSar.
appd - rxSar.
oooHead(TOE_WINDOW_BITS-1, 0)) - 1);
1451 soDBG_RxFreeSpace.write(fsm_freeSpace);
1454 printInfo(myName,
"Entering 'ACK' processing.\n \
1455 \t\t Meta.seqNum =0x%8.8x \n \
1456 \t\t RxSar.appd =0x%8.8x \n \
1457 \t\t RxSar.oooHead=0x%8.8x \n \
1458 \t\t RxSar.oooTail=0x%8.8x \n \
1459 \t\t FreeSpace = %8d\n",
1463 fsm_freeSpace.to_uint());
1487 soTIm_ClearProbeTimer.write(fsm_Meta.
sessionId);
1492 else if (txSar.
cong_window <= TOE_MAX_CONGESTION_WINDOW) {
1515 RxMemPtr memSegAddr = TOE_RX_MEMORY_BASE;
1516 memSegAddr(29, TOE_WINDOW_BITS) = fsm_Meta.
sessionId(13, 0);
1517 memSegAddr(TOE_WINDOW_BITS-1, 0) = fsm_Meta.
meta.
seqNumb.range(TOE_WINDOW_BITS-1, 0);
1543 fsm_oooDebugState = 2;
1562 fsm_oooDebugState = 3;
1580 fsm_oooDebugState = 4;
1585 if (
DEBUG_LEVEL &
TRACE_FSM) {
printInfo(myName,
"OOO-CONTINUE: Rx segment is in-order with respect to 'rcvd' but it does not fill the gap.\n"); }
1598 fsm_oooDebugState = 5;
1616 fsm_oooDebugState = 6;
1621 fsm_oooDropCounter++;
1622 fsm_oooDebugState = 10;
1624 printInfo(myName,
"OOO-Dropping Rx segment (Frame is a retransmission because of a lost or delayed ACK). \n");
1625 fsm_oooDebugState = 11;
1629 printInfo(myName,
"OOO-Dropping Rx segment (Not enough space left in the Rx ring buffer).\n");
1630 fsm_oooDebugState = 12;
1633 printInfo(myName,
"OOO-Dropping Rx segment (Segment is a duplicate).\n");
1634 fsm_oooDebugState = 13;
1637 printFatal(myName,
"OOO-Dropping Rx segment (Reason is unknown).\n");
1638 fsm_oooDebugState = 14;
1644 # if FAST_RETRANSMIT
1646 soEVe_Event.write(event(RT, fsm_Meta.
sessionId));
1648 else if (fsm_meta.meta.length != 0) {
1660 fsm_oooDebugState += 100;
1673 soTIm_CloseTimer.write(fsm_Meta.
sessionId);
1705 if (fsm_fsmState == FSM_LOAD) {
1706 siSTt_StateRep.read(tcpState);
1707 siRSt_RxSarRep.read(rxSar);
1726 ap_uint<3> rtCount = 1;
1750 if (fsm_fsmState == FSM_LOAD) {
1751 siSTt_StateRep.read(tcpState);
1752 siRSt_RxSarRep.read(rxSar);
1753 siTSt_TxSarRep.read(txSar);
1789 if (fsm_fsmState == FSM_LOAD) {
1790 siSTt_StateRep.read(tcpState);
1791 siRSt_RxSarRep.read(rxSar);
1792 siTSt_TxSarRep.read(txSar);
1805 soTIm_ClearProbeTimer.write(fsm_Meta.
sessionId);
1809 RxMemPtr memSegAddr = TOE_RX_MEMORY_BASE;
1810 memSegAddr(29, 16) = fsm_Meta.
sessionId(13, 0);
1812 #if !(RX_DDR_BYPASS)
1834 soTIm_CloseTimer.write(fsm_Meta.
sessionId);
1857 if (fsm_fsmState == FSM_LOAD) {
1858 siSTt_StateRep.read(tcpState);
1859 siRSt_RxSarRep.read(rxSar);
1860 siTSt_TxSarRep.read_nb(txSar);
1862 if (fsm_fsmState == FSM_LOAD) {
1904 printInfo(myName,
"Flags - [0x%X] \n", control_bits.to_uint());
1910 if (!soMMIO_OooDropCnt.full()) {
1911 soMMIO_OooDropCnt.write(fsm_oooDropCounter);
1914 printFatal(myName,
"Cannot write soMMIO_OooDropCnt stream...");
1916 if (!soDBG_TcpIpRxByteCnt.full()) {
1917 soDBG_TcpIpRxByteCnt.write(fsm_rxByteCounter);
1920 printFatal(myName,
"Cannot write soDBG_TcpIpRxByteCnt stream...");
1922 if (!soDBG_OooDebug.full()) {
1923 soDBG_OooDebug.write(fsm_oooDebugState);
1926 printFatal(myName,
"Cannot write soDBG_OooDebug stream...");
1944 stream<ExtendedEvent> &siMdh_Event,
1945 stream<Event> &siFsm_Event,
1946 stream<ExtendedEvent> &soEVe_Event)
1949 #pragma HLS PIPELINE II=1 enable_flush
1954 if (!siMdh_Event.empty()) {
1955 soEVe_Event.write(siMdh_Event.read());
1957 else if (!siFsm_Event.empty()) {
1958 soEVe_Event.write(siFsm_Event.read());
2002 stream<AxisIp4> &siIPRX_Data,
2004 stream<SessionLookupQuery> &soSLc_SessLkReq,
2005 stream<SessionLookupReply> &siSLc_SessLkRep,
2007 stream<StateQuery> &soSTt_StateQry,
2008 stream<TcpState> &siSTt_StateRep,
2010 stream<TcpPort> &soPRt_PortStateReq,
2011 stream<RepBit> &siPRt_PortStateRep,
2013 stream<RXeRxSarQuery> &soRSt_RxSarQry,
2014 stream<RxSarReply> &siRSt_RxSarRep,
2016 stream<RXeTxSarQuery> &soTSt_TxSarQry,
2017 stream<RXeTxSarReply> &siTSt_TxSarRep,
2019 stream<RXeReTransTimerCmd> &soTIm_ReTxTimerCmd,
2020 stream<SessionId> &soTIm_ClearProbeTimer,
2021 stream<SessionId> &soTIm_CloseTimer,
2023 stream<ExtendedEvent> &soEVe_SetEvent,
2025 stream<SessState> &soTAi_SessOpnSts,
2027 stream<TcpAppNotif> &soRAi_RxNotif,
2029 stream<DmCmd> &soMEM_WrCmd,
2030 stream<AxisApp> &soMEM_WrData,
2031 stream<DmSts> &siMEM_WrSts,
2033 stream<StsBit> &soMMIO_RxMemWrErr,
2034 stream<ap_uint<8> > &soMMIO_CrcDropCnt,
2035 stream<ap_uint<8> > &soMMIO_SessDropCnt,
2036 stream<ap_uint<8> > &soMMIO_OooDropCnt,
2038 stream<RxBufPtr> &soDBG_RxFreeSpace,
2039 stream<ap_uint<32> > &soDBG_TcpIpRxByteCnt,
2040 stream<ap_uint<8> > &soDBG_OooDebug)
2043 #pragma HLS DATAFLOW
2044 #pragma HLS INTERFACE ap_ctrl_none port=return
2051 static stream<AxisRaw> ssTleToIph_Data (
"ssTleToIph_Data");
2052 #pragma HLS stream variable=ssTleToIph_Data depth=8
2053 #pragma HLS DATA_PACK variable=ssTleToIph_Data
2055 static stream<TcpSegLen> ssTleToIph_TcpSegLen (
"ssTleToIph_TcpSegLen");
2056 #pragma HLS stream variable=ssTleToIph_TcpSegLen depth=2
2059 static stream<AxisPsd4> ssIphToCsa_PseudoPkt (
"ssIphToCsa_PseudoPkt");
2060 #pragma HLS stream variable=ssIphToCsa_PseudoPkt depth=8
2061 #pragma HLS DATA_PACK variable=ssIphToCsa_PseudoPkt
2064 static stream<AxisApp> ssCsaToTid_Data (
"ssCsaToTid_Data");
2065 #pragma HLS stream variable=ssCsaToTid_Data depth=256
2066 #pragma HLS DATA_PACK variable=ssCsaToTid_Data
2068 static stream<ValBit> ssCsaToTid_DataValid (
"ssCsaToTid_DataValid");
2069 #pragma HLS stream variable=ssCsaToTid_DataValid depth=2
2071 static stream<RXeMeta> ssCsaToMdh_Meta (
"ssCsaToMdh_Meta");
2072 #pragma HLS stream variable=ssCsaToMdh_Meta depth=2
2073 #pragma HLS DATA_PACK variable=ssCsaToMdh_Meta
2075 static stream<SocketPair> ssCsaToMdh_SockPair (
"ssCsaToMdh_SockPair");
2076 #pragma HLS stream variable=ssCsaToMdh_SockPair depth=2
2077 #pragma HLS DATA_PACK variable=ssCsaToMdh_SockPair
2080 static stream<AxisApp> ssTidToTsd_Data (
"ssTidToTsd_Data");
2081 #pragma HLS stream variable=ssTidToTsd_Data depth=8
2082 #pragma HLS DATA_PACK variable=ssTidToTsd_Data
2085 static stream<AxisApp> ssTsdToMwr_Data (
"ssTsdToMwr_Data");
2086 #pragma HLS stream variable=ssTsdToMwr_Data depth=16
2087 #pragma HLS DATA_PACK variable=ssTsdToMwr_Data
2090 static stream<ExtendedEvent> ssMdhToEvm_Event (
"ssMdhToEvm_Event");
2091 #pragma HLS stream variable=ssMdhToEvm_Event depth=cDepth_MdhToEvm_Event
2092 #pragma HLS DATA_PACK variable=ssMdhToEvm_Event
2094 static stream<CmdBit> ssMdhToTsd_DropCmd (
"ssMdhToTsd_DropCmd");
2095 #pragma HLS stream variable=ssMdhToTsd_DropCmd depth=cDepth_MdhToTsd_DropCmd
2097 static stream<RXeFsmMeta> ssMdhToFsm_Meta (
"ssMdhToFsm_Meta");
2098 #pragma HLS stream variable=ssMdhToFsm_Meta depth=2
2099 #pragma HLS DATA_PACK variable=ssMdhToFsm_Meta
2102 static stream<CmdBit> ssFsmToTsd_DropCmd (
"ssFsmToTsd_DropCmd");
2103 #pragma HLS stream variable=ssFsmToTsd_DropCmd depth=cDepth_FsmToTsd_DropCmd
2105 static stream<TcpAppNotif> ssFsmToRan_Notif (
"ssFsmToRan_Notif");
2106 #pragma HLS stream variable=ssFsmToRan_Notif depth=cDepth_FsmToRan_Notif
2107 #pragma HLS DATA_PACK variable=ssFsmToRan_Notif
2109 static stream<Event> ssFsmToEvm_Event (
"ssFsmToEvm_Event");
2110 #pragma HLS stream variable=ssFsmToEvm_Event depth=cDepth_FsmToEve_Event
2111 #pragma HLS DATA_PACK variable=ssFsmToEvm_Event
2113 static stream<DmCmd> ssFsmToMwr_WrCmd (
"ssFsmToMwr_WrCmd");
2114 #pragma HLS stream variable=ssFsmToMwr_WrCmd depth=cDepth_FsmToMwr_WrCmd
2115 #pragma HLS DATA_PACK variable=ssFsmToMwr_WrCmd
2118 static stream<FlagBool> ssMwrToRan_SplitSeg (
"ssMwrToRan_SplitSeg");
2119 #pragma HLS stream variable=ssMwrToRan_SplitSeg depth=cDepth_MwrToRan_SplitSeg
2128 ssTleToIph_TcpSegLen);
2133 ssTleToIph_TcpSegLen,
2134 ssIphToCsa_PseudoPkt);
2137 ssIphToCsa_PseudoPkt,
2139 ssCsaToTid_DataValid,
2141 ssCsaToMdh_SockPair,
2142 soPRt_PortStateReq);
2146 ssCsaToTid_DataValid,
2152 ssCsaToMdh_SockPair,
2159 soMMIO_SessDropCnt);
2170 soTIm_ClearProbeTimer,
2179 soDBG_TcpIpRxByteCnt,
2193 ssMwrToRan_SplitSeg);
2199 ssMwrToRan_SplitSeg,
Ip4TotalLen getIp4TotalLen()
void setTcpDstPort(TcpPort port)
void setPsd4Len(Ly4Len len)
void setTcpSrcPort(TcpPort port)
TcpCtrlBit getTcpCtrlAck()
TcpCtrlBit getTcpCtrlFin()
TcpDataOff getTcpDataOff()
void setPsd4ResBits(Psd4Res res)
TcpOptKind getTcpOptKind()
void setPsd4Prot(Ip4Prot prot)
TcpCtrlBit getTcpCtrlRst()
TcpChecksum getTcpChecksum()
TcpCtrlBit getTcpCtrlSyn()
void setTLast(tLast last)
LE_tKeep getLE_TKeep(int leHi=64/8-1, int leLo=0) const
LE_tData getLE_TData(int leHi=64 -1, int leLo=0) const
void setLE_TLast(LE_tLast last)
void setLE_TData(LE_tData data, int leHi=64 -1, int leLo=0)
void setLE_TKeep(LE_tKeep keep, int leHi=64/8-1, int leLo=0)
LE_tLast getLE_TLast() const
CmdBool fastRetransmitted
TcpWindow slowstart_threshold
const int cDepth_FsmToMwr_WrCmd
void rx_engine(stream< AxisIp4 > &siIPRX_Data, stream< SessionLookupQuery > &soSLc_SessLkReq, stream< SessionLookupReply > &siSLc_SessLkRep, stream< StateQuery > &soSTt_StateQry, stream< TcpState > &siSTt_StateRep, stream< TcpPort > &soPRt_PortStateReq, stream< RepBit > &siPRt_PortStateRep, stream< RXeRxSarQuery > &soRSt_RxSarQry, stream< RxSarReply > &siRSt_RxSarRep, stream< RXeTxSarQuery > &soTSt_TxSarQry, stream< RXeTxSarReply > &siTSt_TxSarRep, stream< RXeReTransTimerCmd > &soTIm_ReTxTimerCmd, stream< SessionId > &soTIm_ClearProbeTimer, stream< SessionId > &soTIm_CloseTimer, stream< ExtendedEvent > &soEVe_SetEvent, stream< SessState > &soTAi_SessOpnSts, stream< TcpAppNotif > &soRAi_RxNotif, stream< DmCmd > &soMEM_WrCmd, stream< AxisApp > &soMEM_WrData, stream< DmSts > &siMEM_WrSts, stream< StsBit > &soMMIO_RxMemWrErr, stream< ap_uint< 8 > > &soMMIO_CrcDropCnt, stream< ap_uint< 8 > > &soMMIO_SessDropCnt, stream< ap_uint< 8 > > &soMMIO_OooDropCnt, stream< RxBufPtr > &soDBG_RxFreeSpace, stream< ap_uint< 32 > > &soDBG_TcpIpRxByteCnt, stream< ap_uint< 8 > > &soDBG_OooDebug)
Receive Engine (RXe)
void pRxAppNotifier(stream< DmSts > &siMEM_WrSts, stream< TcpAppNotif > &siFsm_Notif, stream< TcpAppNotif > &soRAi_RxNotif, stream< FlagBool > &siMwr_SplitSeg, stream< StsBit > &soMMIO_MemWrErr)
Rx Application Notifier (Ran)
void pRxMemoryWriter(stream< AxisApp > &siTsd_Data, stream< DmCmd > &siFsm_MemWrCmd, stream< DmCmd > &soMEM_WrCmd, stream< AxisApp > &soMEM_WrData, stream< FlagBool > &soRan_SplitSeg)
Rx Memory Writer (Mwr)
void pTcpSegmentDropper(stream< AxisApp > &siTid_Data, stream< CmdBit > &siMdh_DropCmd, stream< CmdBit > &siFsm_DropCmd, stream< AxisApp > &soMwr_Data)
TCP Segment Dropper (Tsd)
void pTcpLengthExtractor(stream< AxisIp4 > &siIPRX_Data, stream< AxisRaw > &soIph_Data, stream< TcpSegLen > &soIph_TcpSegLen)
TCP Length Extraction (Tle)
void pTcpInvalidDropper(stream< AxisApp > &siCsa_Data, stream< ValBit > &siCsa_DataVal, stream< AxisApp > &soTsd_Data, stream< ap_uint< 8 > > &soMMIO_CrcDropCnt)
TCP Invalid checksum Dropper (Tid)
void pMetaDataHandler(stream< RXeMeta > &siCsa_Meta, stream< SocketPair > &siCsa_SockPair, stream< SessionLookupQuery > &soSLc_SessLkpReq, stream< SessionLookupReply > &siSLc_SessLkpRep, stream< StsBit > &siPRt_PortSts, stream< ExtendedEvent > &soEVe_Event, stream< CmdBit > &soTsd_DropCmd, stream< RXeFsmMeta > &soFsm_Meta, stream< ap_uint< 8 > > &soMMIO_SessDropCnt)
MetaData Handler (Mdh)
void pFiniteStateMachine(stream< RXeFsmMeta > &siMdh_FsmMeta, stream< StateQuery > &soSTt_StateQry, stream< TcpState > &siSTt_StateRep, stream< RXeRxSarQuery > &soRSt_RxSarQry, stream< RxSarReply > &siRSt_RxSarRep, stream< RXeTxSarQuery > &soTSt_TxSarQry, stream< RXeTxSarReply > &siTSt_TxSarRep, stream< RXeReTransTimerCmd > &soTIm_ReTxTimerCmd, stream< SessionId > &soTIm_ClearProbeTimer, stream< SessionId > &soTIm_CloseTimer, stream< SessState > &soTAi_SessOpnSts, stream< Event > &soEVe_Event, stream< CmdBit > &soTsd_DropCmd, stream< DmCmd > &soMwr_WrCmd, stream< TcpAppNotif > &soRan_RxNotif, stream< ap_uint< 8 > > &soMMIO_OooDropCnt, stream< RxBufPtr > &soDBG_RxFreeSpace, stream< ap_uint< 32 > > &soDBG_TcpIpRxByteCnt, stream< ap_uint< 8 > > &soDBG_OooDebug)
Finite State machine (Fsm)
void pInsertPseudoHeader(stream< AxisRaw > &siTle_Data, stream< TcpSegLen > &siTle_TcpSegLen, stream< AxisPsd4 > &soCsa_PseudoPkt)
Insert pseudo header (Iph)
void pCheckSumAccumulator(stream< AxisPsd4 > &siIph_PseudoPkt, stream< AxisApp > &soTid_Data, stream< ValBit > &soTid_DataVal, stream< RXeMeta > &soMdh_Meta, stream< SocketPair > &soMdh_SockPair, stream< TcpPort > &soPRt_GetState)
TCP checksum accumulator (Csa)
void pEventMultiplexer(stream< ExtendedEvent > &siMdh_Event, stream< Event > &siFsm_Event, stream< ExtendedEvent > &soEVe_Event)
Event Multiplexer (Evm)
#define assessSize(callerName, stream, streamName, depth)
A macro that checks if a stream is full.
#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...
#define QUERY_FAST_RETRANSMIT
void printAxisRaw(const char *callerName, AxisRaw chunk)
Prints an Axis raw data chunk (used for debugging).
#define printInfo(callerName, format,...)
A macro to print an information message.
ap_uint< 16 > Ip4TotalLen
#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 printFatal(callerName, format,...)
A macro to print a fatal error message and exit.
ap_uint< 16 > TcpChecksum
: Rx Engine (RXe) of the TCP Offload Engine (TOE)
ap_uint< 32 > byteSwap32(ap_uint< 32 > inputVector)
ap_uint< 16 > byteSwap16(ap_uint< 16 > inputVector)