69 #define THIS_NAME "TOE/RAi"
71 #define TRACE_OFF 0x0000
72 #define TRACE_LAI 1 << 1
73 #define TRACE_ASS 1 << 2
74 #define TRACE_NMX 1 << 3
75 #define TRACE_RAS 1 << 4
76 #define TRACE_MRD 1 << 5
77 #define TRACE_ALL 0xFFFF
79 #define DEBUG_LEVEL (TRACE_OFF)
104 stream<TcpAppNotif> &siRXe_Notif,
105 stream<TcpAppNotif> &siTIm_Notif,
106 stream<TcpAppNotif> &soTAIF_Notif,
107 stream<ap_uint<8> > &soMMIO_NotifDropCnt)
110 #pragma HLS PIPELINE II=1 enable_flush
111 #pragma HLS INLINE off
116 static ap_uint<8 > nmx_notifDropCounter=0;
117 #pragma HLS reset variable=nmx_notifDropCounter
121 if (!siRXe_Notif.empty()) {
122 currNotif = siRXe_Notif.read();
123 if (!soTAIF_Notif.full()) {
124 soTAIF_Notif.write(currNotif);
128 nmx_notifDropCounter++;
129 printFatal(myName,
"Cannot write 'soTAIF_Notif()'. Stream is full!");
132 else if (!siTIm_Notif.empty()) {
133 currNotif = siTIm_Notif.read();
134 if (!soTAIF_Notif.full()) {
135 soTAIF_Notif.write(currNotif);
139 printFatal(myName,
"Cannot write 'soTAIF_Notif()'. Stream is full!");
144 if (!soMMIO_NotifDropCnt.full()) {
145 soMMIO_NotifDropCnt.write(nmx_notifDropCounter);
148 printFatal(myName,
"Cannot write soMMIO_NotifDropCnt stream...");
179 stream<TcpAppRdReq> &siTAIF_DataReq,
180 stream<TcpAppMeta> &soTAIF_Meta,
181 stream<RAiRxSarQuery> &soRSt_RxSarQry,
182 stream<RAiRxSarReply> &siRSt_RxSarRep,
183 stream<DmCmd> &soMrd_MemRdCmd,
184 stream<ap_uint<8> > &soMMIO_MetaDropCnt)
187 #pragma HLS PIPELINE II=1 enable_flush
188 #pragma HLS INLINE off
193 static enum FsmStates { S0=0, S1 } \
195 #pragma HLS RESET variable=ras_fsmState
196 static ap_uint<8 > ras_metaDropCounter=0;
197 #pragma HLS reset variable=ras_metaDropCounter
202 switch (ras_fsmState) {
204 if (!siTAIF_DataReq.empty() and !soRSt_RxSarQry.full()) {
205 TcpAppRdReq appReadRequest = siTAIF_DataReq.read();
206 if (appReadRequest.
length != 0) {
209 ras_readLength = appReadRequest.
length;
214 if (!soTAIF_Meta.full()) {
215 soTAIF_Meta.write(appReadRequest.
sessionID);
219 ras_metaDropCounter++;
220 printFatal(myName,
"Cannot write 'soTAIF_Meta()'. Stream is full!");
226 if (!siRSt_RxSarRep.empty() and
227 !soMrd_MemRdCmd.full() and !soRSt_RxSarQry.full()) {
230 if (!soTAIF_Meta.full()) {
235 ras_metaDropCounter++;
236 printFatal(myName,
"Cannot write 'soTAIF_Meta()'. Stream is full!");
239 RxMemPtr memSegAddr = TOE_RX_MEMORY_BASE;
240 memSegAddr(29, 16) = rxSarRep.
sessionID(13, 0);
241 memSegAddr(15, 0) = rxSarRep.
appd;
242 soMrd_MemRdCmd.write(
DmCmd(memSegAddr, ras_readLength));
251 if (!soMMIO_MetaDropCnt.full()) {
252 soMMIO_MetaDropCnt.write(ras_metaDropCounter);
255 printFatal(myName,
"Cannot write soMMIO_MetaDropCnt stream...");
276 stream<DmCmd> &siRas_MemRdCmd,
277 stream<DmCmd> &soMEM_RxpRdCmd,
278 stream<FlagBool> &soAss_SplitSeg)
281 #pragma HLS PIPELINE II=1 enable_flush
282 #pragma HLS INLINE off
287 static enum FsmState { MRD_1ST_ACCESS=0, MRD_2ND_ACCESS } \
288 mrd_fsmState=MRD_1ST_ACCESS;
289 #pragma HLS RESET variable=mrd_fsmState
292 static DmCmd mrd_memRdCmd;
294 static uint16_t mrd_debugCounter=1;
296 switch (mrd_fsmState) {
298 if (!siRas_MemRdCmd.empty() and !soAss_SplitSeg.full() and !soMEM_RxpRdCmd.full() ) {
299 siRas_MemRdCmd.read(mrd_memRdCmd);
301 if ((mrd_memRdCmd.
saddr.range(TOE_WINDOW_BITS-1, 0) + mrd_memRdCmd.
btt) > TOE_RX_BUFFER_SIZE) {
303 mrd_firstAccLen = TOE_RX_BUFFER_SIZE - mrd_memRdCmd.
saddr;
304 mrd_fsmState = MRD_2ND_ACCESS;
306 soMEM_RxpRdCmd.write(
DmCmd(mrd_memRdCmd.
saddr, mrd_firstAccLen));
307 soAss_SplitSeg.write(
true);
310 printInfo(myName,
"TCP Rx memory buffer wraps around: This segment is broken in two memory accesses.\n");
311 printInfo(myName,
"Issuing 1st memory read command #%d - SADDR=0x%9.9lx - BTT=%d\n",
312 mrd_debugCounter, mrd_memRdCmd.
saddr.to_ulong(), mrd_firstAccLen.to_uint());
316 soMEM_RxpRdCmd.write(mrd_memRdCmd);
317 soAss_SplitSeg.write(
false);
320 printInfo(myName,
"Issuing memory read command #%d - SADDR=0x%9.9lx - BTT=%d\n",
321 mrd_debugCounter, mrd_memRdCmd.
saddr.to_ulong(), mrd_memRdCmd.
btt.to_uint());
328 if (!soMEM_RxpRdCmd.full()) {
330 mrd_memRdCmd.
saddr(TOE_WINDOW_BITS-1, 0) = 0;
331 soMEM_RxpRdCmd.write(
DmCmd(mrd_memRdCmd.
saddr, mrd_memRdCmd.
btt - mrd_firstAccLen));
333 mrd_fsmState = MRD_1ST_ACCESS;
336 printInfo(myName,
"Issuing 2nd memory read command #%d - SADDR=0x%9.9lx - BTT=%d\n",
337 mrd_debugCounter, mrd_memRdCmd.
saddr.to_ulong(),
338 (mrd_memRdCmd.
btt - mrd_firstAccLen).to_uint());
372 stream<AxisApp> &siMEM_RxP_Data,
373 stream<TcpAppData> &soTAIF_Data,
374 stream<FlagBool> &siMrd_SplitSegFlag,
375 stream<ap_uint<8> > &soMMIO_DataDropCnt)
378 #pragma HLS PIPELINE II=1 enable_flush
379 #pragma HLS INLINE off
384 static enum FsmState { ASS_IDLE,
385 ASS_FWD_1ST_BUF, ASS_FWD_2ND_BUF,
386 ASS_JOIN_2ND_BUF, ASS_RESIDUE } \
387 ass_fsmState=ASS_IDLE;
388 #pragma HLS RESET variable=ass_fsmState
389 static ap_uint<3> ass_psdHdrChunkCount = 0;
390 #pragma HLS RESET variable=ass_psdHdrChunkCount
391 static ap_uint<16> ass_dataDropCounter=0;
392 #pragma HLS reset variable=ass_dataDropCounter
396 static ap_uint<4> ass_memRdOffset;
399 switch(ass_fsmState) {
402 if (!siMEM_RxP_Data.empty() and !siMrd_SplitSegFlag.empty()) {
403 siMrd_SplitSegFlag.read(ass_mustJoin);
404 AxisApp currAppChunk = siMEM_RxP_Data.read();
407 if (ass_mustJoin ==
false) {
410 if (!soTAIF_Data.full()) {
411 soTAIF_Data.write(currAppChunk);
416 ass_dataDropCounter++;
417 printFatal(myName,
"Cannot write 'soTAIF_Data()'. Stream is full!");
419 ass_fsmState = ASS_IDLE;
423 ass_memRdOffset = currAppChunk.
getLen();
424 if (ass_memRdOffset != 8) {
428 ass_prevChunk = currAppChunk;
429 ass_fsmState = ASS_JOIN_2ND_BUF;
435 if (!soTAIF_Data.full()) {
436 soTAIF_Data.write(currAppChunk);
441 ass_dataDropCounter++;
442 printFatal(myName,
"Cannot write 'soTAIF_Data()'. Stream is full!");
444 ass_fsmState = ASS_FWD_2ND_BUF;
450 if (!soTAIF_Data.full()) {
451 soTAIF_Data.write(currAppChunk);
456 ass_dataDropCounter++;
457 printFatal(myName,
"Cannot write 'soTAIF_Data()'. Stream is full!");
459 ass_fsmState = ASS_FWD_1ST_BUF;
463 case ASS_FWD_1ST_BUF:
465 if (!siMEM_RxP_Data.empty()) {
466 AxisApp currAppChunk = siMEM_RxP_Data.read();
470 if (ass_mustJoin ==
false) {
473 if (!soTAIF_Data.full()) {
474 soTAIF_Data.write(currAppChunk);
479 printFatal(myName,
"Cannot write 'soTAIF_Data()'. Stream is full!");
481 ass_fsmState = ASS_IDLE;
485 ass_memRdOffset = currAppChunk.
getLen();
488 if (ass_memRdOffset != 8) {
492 ass_prevChunk = currAppChunk;
493 ass_fsmState = ASS_JOIN_2ND_BUF;
499 if (!soTAIF_Data.full()) {
500 soTAIF_Data.write(currAppChunk);
505 ass_dataDropCounter++;
506 printFatal(myName,
"Cannot write 'soTAIF_Data()'. Stream is full!");
508 ass_fsmState = ASS_FWD_2ND_BUF;
514 if (!soTAIF_Data.full()) {
515 soTAIF_Data.write(currAppChunk);
520 ass_dataDropCounter++;
521 printFatal(myName,
"Cannot write 'soTAIF_Data()'. Stream is full!");
526 case ASS_FWD_2ND_BUF:
528 if (!siMEM_RxP_Data.empty()) {
529 AxisApp currAppChunk = siMEM_RxP_Data.read();
530 if (!soTAIF_Data.full()) {
531 soTAIF_Data.write(currAppChunk);
536 ass_dataDropCounter++;
537 printFatal(myName,
"Cannot write 'soTAIF_Data()'. Stream is full!");
541 ass_fsmState = ASS_IDLE;
545 case ASS_JOIN_2ND_BUF:
551 if (!siMEM_RxP_Data.empty()) {
552 AxisApp currAppChunk = siMEM_RxP_Data.read();
557 ((
int)ass_memRdOffset*8)-1, 0);
559 (
int)ass_memRdOffset -1, 0);
562 ARW -1,((
int)ass_memRdOffset*8));
564 (
ARW/8)-1, (
int)ass_memRdOffset);
565 if (currAppChunk.
getLE_TKeep()[8-(
int)ass_memRdOffset] == 0) {
569 ass_fsmState = ASS_IDLE;
575 ass_fsmState = ASS_RESIDUE;
578 if (!soTAIF_Data.full()) {
579 soTAIF_Data.write(joinedChunk);
584 ass_dataDropCounter++;
585 printFatal(myName,
"Cannot write 'soTAIF_Data()'. Stream is full!");
590 ((
int)ass_memRdOffset*8)-1, 0);
592 (
int)ass_memRdOffset-1, 0);
599 ((
int)ass_memRdOffset*8)-1, 0);
601 (
int)ass_memRdOffset-1, 0);
603 if (!soTAIF_Data.full()) {
604 soTAIF_Data.write(lastChunk);
609 ass_dataDropCounter++;
610 printFatal(myName,
"Cannot write 'soTAIF_Data()'. Stream is full!");
612 ass_fsmState = ASS_IDLE;
617 if (!soMMIO_DataDropCnt.full()) {
618 soMMIO_DataDropCnt.write(ass_dataDropCounter);
621 printFatal(myName,
"Cannot write soMMIO_DataDropCnt stream...");
648 stream<TcpAppLsnReq> &siTAIF_LsnReq,
649 stream<TcpAppLsnRep> &soTAIF_LsnRep,
650 stream<TcpPort> &soPRt_LsnReq,
651 stream<RepBit> &siPRt_LsnRep)
656 #pragma HLS PIPELINE II=1 enable_flush
657 #pragma HLS INLINE off
662 static bool lai_waitForPRtRep=
false;
663 #pragma HLS reset variable=lai_waitForPRtRep
669 if (!siTAIF_LsnReq.empty() and !lai_waitForPRtRep) {
670 siTAIF_LsnReq.read(listenPort);
671 soPRt_LsnReq.write(listenPort);
672 lai_waitForPRtRep =
true;
674 else if (!siPRt_LsnRep.empty() and lai_waitForPRtRep) {
675 siPRt_LsnRep.read(listenRep);
676 if (!soTAIF_LsnRep.full()) {
677 soTAIF_LsnRep.write((
RepBool)listenRep);
681 printFatal(myName,
"Cannot write 'soTAIF_Meta()'. Stream is full!");
683 lai_waitForPRtRep =
false;
731 stream<TcpAppNotif> &soTAIF_Notif,
732 stream<TcpAppRdReq> &siTAIF_DataReq,
734 stream<TcpAppData> &soTAIF_Data,
735 stream<TcpAppMeta> &soTAIF_Meta,
737 stream<TcpAppLsnReq> &siTAIF_LsnReq,
738 stream<TcpAppLsnRep> &soTAIF_LsnRep,
740 stream<TcpPort> &soPRt_LsnReq,
741 stream<AckBit> &siPRt_LsnAck,
743 stream<TcpAppNotif> &siRXe_Notif,
745 stream<TcpAppNotif> &siTIm_Notif,
747 stream<RAiRxSarQuery> &soRSt_RxSarReq,
748 stream<RAiRxSarReply> &siRSt_RxSarRep,
750 stream<DmCmd> &soMEM_RxP_RdCmd,
751 stream<AxisApp> &siMEM_RxP_Data,
753 stream<ap_uint<8> > &soMMIO_NotifDropCnt,
754 stream<ap_uint<8> > &soMMIO_MetaDropCnt,
755 stream<ap_uint<8> > &soMMIO_DataDropCnt)
765 static stream<DmCmd> ssRasToMrd_MemRdCmd (
"ssRasToMrd_MemRdCmd");
766 #pragma HLS stream variable=ssRasToMrd_MemRdCmd depth=16
769 static stream<FlagBool> ssMrdToAss_SplitSeg (
"ssMrdToAss_SplitSeg");
770 #pragma HLS stream variable=ssMrdToAss_SplitSeg depth=16
783 ssMrdToAss_SplitSeg);
801 soMMIO_NotifDropCnt);
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
void pRxMemoryReader(stream< DmCmd > &siRas_MemRdCmd, stream< DmCmd > &soMEM_RxpRdCmd, stream< FlagBool > &soAss_SplitSeg)
Rx Memory Reader (Mrd)
void pNotificationMux(stream< TcpAppNotif > &siRXe_Notif, stream< TcpAppNotif > &siTIm_Notif, stream< TcpAppNotif > &soTAIF_Notif, stream< ap_uint< 8 > > &soMMIO_NotifDropCnt)
Rx Notification Multiplexer (Nmx)
void rx_app_interface(stream< TcpAppNotif > &soTAIF_Notif, stream< TcpAppRdReq > &siTAIF_DataReq, stream< TcpAppData > &soTAIF_Data, stream< TcpAppMeta > &soTAIF_Meta, stream< TcpAppLsnReq > &siTAIF_LsnReq, stream< TcpAppLsnRep > &soTAIF_LsnRep, stream< TcpPort > &soPRt_LsnReq, stream< AckBit > &siPRt_LsnAck, stream< TcpAppNotif > &siRXe_Notif, stream< TcpAppNotif > &siTIm_Notif, stream< RAiRxSarQuery > &soRSt_RxSarReq, stream< RAiRxSarReply > &siRSt_RxSarRep, stream< DmCmd > &soMEM_RxP_RdCmd, stream< AxisApp > &siMEM_RxP_Data, stream< ap_uint< 8 > > &soMMIO_NotifDropCnt, stream< ap_uint< 8 > > &soMMIO_MetaDropCnt, stream< ap_uint< 8 > > &soMMIO_DataDropCnt)
Rx Application Interface (RAi)
void pLsnAppInterface(stream< TcpAppLsnReq > &siTAIF_LsnReq, stream< TcpAppLsnRep > &soTAIF_LsnRep, stream< TcpPort > &soPRt_LsnReq, stream< RepBit > &siPRt_LsnRep)
Listen Application Interface (Lai)
void pRxAppStream(stream< TcpAppRdReq > &siTAIF_DataReq, stream< TcpAppMeta > &soTAIF_Meta, stream< RAiRxSarQuery > &soRSt_RxSarQry, stream< RAiRxSarReply > &siRSt_RxSarRep, stream< DmCmd > &soMrd_MemRdCmd, stream< ap_uint< 8 > > &soMMIO_MetaDropCnt)
Rx Application Stream (RAs)
void pAppSegmentStitcher(stream< AxisApp > &siMEM_RxP_Data, stream< TcpAppData > &soTAIF_Data, stream< FlagBool > &siMrd_SplitSegFlag, stream< ap_uint< 8 > > &soMMIO_DataDropCnt)
Application Segment Stitcher (Ass)
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.
#define concat3(firstCharConst, secondCharConst, thirdCharConst)
#define printFatal(callerName, format,...)
A macro to print a fatal error message and exit.
: Rx Application Interface (RAi) of the TCP Offload Engine (TOE)