60 #define THIS_NAME "UAF"
62 #define TRACE_OFF 0x0000
63 #define TRACE_ESF 1 << 1
64 #define TRACE_RXP 1 << 2
65 #define TRACE_TXP 1 << 3
66 #define TRACE_ALL 0xFFFF
67 #define DEBUG_LEVEL (TRACE_OFF)
89 stream<UdpAppData> &siRXp_Data,
90 stream<UdpAppMeta> &siRXp_Meta,
91 stream<UdpAppDLen> &siRXp_DLen,
92 stream<UdpAppData> &soTXp_Data,
93 stream<UdpAppMeta> &soTXp_Meta,
94 stream<UdpAppDLen> &soTXp_DLen)
97 #pragma HLS INLINE off
98 #pragma HLS PIPELINE II=1 enable_flush
103 static enum FsmStates { ESF_META=0, ESF_STREAM } \
104 esf_fsmState = ESF_META;
105 #pragma HLS reset variable=esf_fsmState
107 #pragma HLS reset variable=esf_byteCnt
109 if (*piSHL_Enable != 1) {
116 if ( !siRXp_Data.empty() and !soTXp_Data.full() ) {
118 soTXp_Data.write(appData);
119 esf_byteCnt += appData.
getLen();
128 if ( !siRXp_Meta.empty() and !soTXp_Meta.full() and
129 !siRXp_DLen.empty() and !soTXp_DLen.full() ) {
132 soTXp_Meta.write(appMeta);
133 soTXp_DLen.write(appDLen);
169 CmdBit *piSHL_Mmio_Enable,
171 stream<UdpAppData> &siEPt_Data,
172 stream<UdpAppMeta> &siEPt_Meta,
173 stream<UdpAppDLen> &siEPt_DLen,
174 stream<UdpAppData> &siESf_Data,
175 stream<UdpAppMeta> &siESf_Meta,
176 stream<UdpAppDLen> &siESf_DLen,
177 stream<UdpAppData> &soUSIF_Data,
178 stream<UdpAppMeta> &soUSIF_Meta,
179 stream<UdpAppDLen> &soUSIF_DLen)
182 #pragma HLS INLINE off
183 #pragma HLS PIPELINE II=1 enable_flush
188 static enum FsmStates { TXP_IDLE=0, TXP_META,
189 TXP_DATA_EPT, TXP_DATA_ESF, TXP_DRAIN_INPUT_FIFOS } \
190 txp_fsmState = TXP_IDLE;
191 #pragma HLS reset variable=txp_fsmState
192 static enum DgmMode { STRM_MODE=0, DGRM_MODE } \
193 txp_fwdMode = DGRM_MODE;
194 #pragma HLS reset variable=txp_fwdMode
197 static ap_int<17> txp_lenCnt;
200 static enum EchoMode { EPT_MODE=0, ESF_MODE } \
201 txp_echoMode = EPT_MODE;
206 switch (txp_fsmState) {
209 txp_fsmState = TXP_DRAIN_INPUT_FIFOS;
211 else if (!siEPt_Meta.empty() and !siEPt_DLen.empty()) {
212 txp_appMeta = siEPt_Meta.read();
213 txp_appDLen = siEPt_DLen.read();
214 txp_echoMode = EPT_MODE;
215 txp_fsmState = TXP_META;
217 else if (!siESf_Meta.empty() and !siESf_DLen.empty()) {
218 txp_appMeta = siESf_Meta.read();
219 txp_appDLen = siESf_DLen.read();
220 txp_echoMode = ESF_MODE;
221 txp_fsmState = TXP_META;
223 if (txp_appDLen == 0) {
224 txp_fwdMode = STRM_MODE;
228 txp_fwdMode = DGRM_MODE;
229 txp_lenCnt = txp_appDLen;
233 if (!soUSIF_Meta.full() and !soUSIF_DLen.full()) {
237 soUSIF_Meta.write(udpMeta);
238 soUSIF_DLen.write(txp_appDLen);
239 if (txp_echoMode == EPT_MODE) {
240 txp_fsmState = TXP_DATA_EPT;
243 txp_fsmState = TXP_DATA_ESF;
248 if (!siEPt_Data.empty() and !soUSIF_Data.full()) {
249 appData = siEPt_Data.read();
250 if (txp_fwdMode == STRM_MODE) {
251 txp_lenCnt = txp_lenCnt + appData.
getLen();
253 txp_fsmState = TXP_IDLE;
255 printInfo(myName,
"ECHO_PATH_THRU + STREAM MODE - Finished forwarding %d bytes.\n", txp_lenCnt.to_uint());
260 txp_lenCnt = txp_lenCnt - appData.
getLen();
261 if ((txp_lenCnt <= 0) or (appData.
getTLast())) {
262 txp_fsmState = TXP_IDLE;
264 printInfo(myName,
"ECHO_PATH_THRU + DATAGRAM MODE - Finished datagram forwarding.\n");
271 soUSIF_Data.write(appData);
275 if (!siESf_Data.empty() and !soUSIF_Data.full()) {
276 appData = siESf_Data.read();
277 if (txp_fwdMode == STRM_MODE) {
278 txp_lenCnt = txp_lenCnt + appData.
getLen();
280 txp_fsmState = TXP_IDLE;
282 printInfo(myName,
"ECHO_STORE_FWD + STREAM MODE - Finished forwarding %d bytes.\n", txp_lenCnt.to_uint());
287 txp_lenCnt = txp_lenCnt - appData.
getLen();
288 if ((txp_lenCnt <= 0) or (appData.
getTLast())) {
289 txp_fsmState = TXP_IDLE;
291 printInfo(myName,
"ECHO_STORE_FWD + DATAGRAM MODE - Finished datagram forwarding.\n");
298 soUSIF_Data.write(appData);
301 case TXP_DRAIN_INPUT_FIFOS:
303 if(!siEPt_Data.empty()) {
306 else if(!siEPt_Meta.empty()) {
309 else if(!siEPt_DLen.empty()) {
312 else if(!siESf_Data.empty()) {
315 else if(!siESf_Meta.empty()) {
318 else if(!siESf_DLen.empty()) {
322 txp_fsmState = TXP_IDLE;
352 CmdBit *piSHL_Mmio_Enable,
354 stream<UdpAppData> &siUSIF_Data,
355 stream<UdpAppMeta> &siUSIF_Meta,
356 stream<UdpAppDLen> &siUSIF_DLen,
357 stream<UdpAppData> &soEPt_Data,
358 stream<UdpAppMeta> &soEPt_Meta,
359 stream<UdpAppDLen> &soEPt_DLen,
360 stream<UdpAppData> &soESf_Data,
361 stream<UdpAppMeta> &soESf_Meta,
362 stream<UdpAppDLen> &soESf_DLen)
365 #pragma HLS INLINE off
366 #pragma HLS PIPELINE II=1 enable_flush
371 static enum FsmStates { RXP_IDLE=0, RXP_META_EPT, RXP_META_ESF,
372 RXP_DATA_EPT, RXP_DATA_ESF,
373 RXP_DLEN_EPT, RXP_DLEN_ESF,
374 RXP_DRAIN_INPUT_FIFOS } \
375 rxp_fsmState = RXP_IDLE;
376 #pragma HLS reset variable=rxp_fsmState
386 switch (rxp_fsmState) {
389 rxp_fsmState = RXP_DRAIN_INPUT_FIFOS;
391 else if (!siUSIF_Meta.empty() and !siUSIF_DLen.empty()) {
392 siUSIF_Meta.read(rxp_appMeta);
393 siUSIF_DLen.read(rxp_appDLen);
399 rxp_fsmState = RXP_META_EPT;
404 rxp_fsmState = RXP_META_ESF;
409 case RXP_DRAIN_INPUT_FIFOS:
411 if(!siUSIF_Data.empty()) {
414 else if(!siUSIF_Meta.empty()) {
417 else if(!siUSIF_DLen.empty()) {
421 rxp_fsmState = RXP_IDLE;
425 if (!soEPt_Meta.full()) {
427 soEPt_Meta.write(rxp_appMeta);
428 rxp_fsmState = RXP_DATA_EPT;
432 if (!soESf_Meta.full()) {
434 soESf_Meta.write(rxp_appMeta);
435 rxp_fsmState = RXP_DATA_ESF;
439 if (!siUSIF_Data.empty() and !soEPt_Data.full()) {
441 siUSIF_Data.read(appData);
442 soEPt_Data.write(appData);
443 rxp_byteCnt = rxp_byteCnt + appData.
getLen();
445 rxp_fsmState = RXP_DLEN_EPT;
450 if (!siUSIF_Data.empty() and !soESf_Data.full()) {
452 siUSIF_Data.read(appData);
453 soESf_Data.write(appData);
454 rxp_byteCnt = rxp_byteCnt + appData.
getLen();
456 rxp_fsmState = RXP_DLEN_ESF;
461 if (!soEPt_DLen.full()) {
463 if (rxp_byteCnt != rxp_appDLen) {
464 printFatal(myName,
"Received number of bytes (%d) differs from the advertised data length (%d)\n", rxp_byteCnt.to_uint(), rxp_appDLen.to_uint());
466 soEPt_DLen.write(rxp_byteCnt);
467 rxp_fsmState = RXP_IDLE;
471 if (!soESf_DLen.full()) {
473 if (rxp_byteCnt != rxp_appDLen) {
474 printFatal(myName,
"Received number of bytes (%d) differs from the advertised data length (%d)\n", rxp_byteCnt.to_uint(), rxp_appDLen.to_uint());
476 soESf_DLen.write(rxp_byteCnt);
477 rxp_fsmState = RXP_IDLE;
519 stream<UdpAppData> &siUSIF_Data,
520 stream<UdpAppMeta> &siUSIF_Meta,
521 stream<UdpAppDLen> &siUSIF_DLen,
526 stream<UdpAppData> &soUSIF_Data,
527 stream<UdpAppMeta> &soUSIF_Meta,
528 stream<UdpAppDLen> &soUSIF_DLen)
532 #pragma HLS INLINE off
539 static stream<UdpAppData> ssRXpToTXp_Data (
"ssRXpToTXp_Data");
540 #pragma HLS STREAM variable=ssRXpToTXp_Data depth=2048
541 static stream<UdpAppMeta> ssRXpToTXp_Meta (
"ssRXpToTXp_Meta");
542 #pragma HLS STREAM variable=ssRXpToTXp_Meta depth=64
543 static stream<UdpAppDLen> ssRXpToTXp_DLen (
"ssRXpToTXp_DLen");
544 #pragma HLS STREAM variable=ssRXpToTXp_DLen depth=64
546 static stream<UdpAppData> ssRXpToESf_Data (
"ssRXpToESf_Data");
547 #pragma HLS STREAM variable=ssRXpToESf_Data depth=1024
548 static stream<UdpAppMeta> ssRXpToESf_Meta (
"ssRXpToESf_Meta");
549 #pragma HLS STREAM variable=ssRXpToESf_Meta depth=32
550 static stream<UdpAppDLen> ssRXpToESf_DLen (
"ssRXpToESf_DLen");
551 #pragma HLS STREAM variable=ssRXpToESf_DLen depth=32
554 static stream<UdpAppData> ssESfToTXp_Data (
"ssESfToTXp_Data");
555 #pragma HLS STREAM variable=ssESfToTXp_Data depth=1024
556 static stream<UdpAppMeta> ssESfToTXp_Meta (
"ssESfToTXp_Meta");
557 #pragma HLS STREAM variable=ssESfToTXp_Meta depth=32
558 static stream<UdpAppDLen> ssESfToTXp_DLen (
"ssESfToTXp_DLen");
559 #pragma HLS STREAM variable=ssESfToTXp_DLen depth=32
void setTLast(tLast last)
#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.
#define ECHO_PATH_THRU_PORT
void pUdpTxPath(CmdBit *piSHL_Mmio_Enable, stream< UdpAppData > &siEPt_Data, stream< UdpAppMeta > &siEPt_Meta, stream< UdpAppDLen > &siEPt_DLen, stream< UdpAppData > &siESf_Data, stream< UdpAppMeta > &siESf_Meta, stream< UdpAppDLen > &siESf_DLen, stream< UdpAppData > &soUSIF_Data, stream< UdpAppMeta > &soUSIF_Meta, stream< UdpAppDLen > &soUSIF_DLen)
Transmit Path - From THIS to USIF.
void pUdpRxPath(CmdBit *piSHL_Mmio_Enable, stream< UdpAppData > &siUSIF_Data, stream< UdpAppMeta > &siUSIF_Meta, stream< UdpAppDLen > &siUSIF_DLen, stream< UdpAppData > &soEPt_Data, stream< UdpAppMeta > &soEPt_Meta, stream< UdpAppDLen > &soEPt_DLen, stream< UdpAppData > &soESf_Data, stream< UdpAppMeta > &soESf_Meta, stream< UdpAppDLen > &soESf_DLen)
UDP Receive Path (RXp) - From SHELL->ROLE/USIF to THIS.
void udp_app_flash(CmdBit *piSHL_Mmio_En, stream< UdpAppData > &siUSIF_Data, stream< UdpAppMeta > &siUSIF_Meta, stream< UdpAppDLen > &siUSIF_DLen, stream< UdpAppData > &soUSIF_Data, stream< UdpAppMeta > &soUSIF_Meta, stream< UdpAppDLen > &soUSIF_DLen)
Main process of the UDP Application Flash (UAF)
void pUdpEchoStoreAndForward(CmdBit *piSHL_Enable, stream< UdpAppData > &siRXp_Data, stream< UdpAppMeta > &siRXp_Meta, stream< UdpAppDLen > &siRXp_DLen, stream< UdpAppData > &soTXp_Data, stream< UdpAppMeta > &soTXp_Meta, stream< UdpAppDLen > &soTXp_DLen)
Echo loopback between the Rx and Tx ports of the UDP connection.
: UDP Application Flash (UAF)