52 stream<NetworkWord> &siUdp_data,
54 stream<UdpAppData> &soUOE_Data,
55 stream<UdpAppMeta> &soUOE_Meta,
56 stream<UdpAppDLen> &soUOE_DLen,
57 stream<NodeId> &sGetIpReq_UdpTx,
58 stream<Ip4Addr> &sGetIpRep_UdpTx,
59 const ap_uint<32> *ipAddrBE,
60 stream<bool> &cache_inval_sig,
61 stream<NalEventNotif> &internal_event_fifo
65 #pragma HLS INLINE off
66 #pragma HLS pipeline II=1
73 static Ip4Addr cached_ip4addr_udp_tx = 0;
74 static bool cache_init =
false;
75 static uint8_t evs_loop_i = 0;
77 #pragma HLS RESET variable=fsmStateTX_Udp
78 #pragma HLS RESET variable=cached_nodeid_udp_tx
79 #pragma HLS RESET variable=cached_ip4addr_udp_tx
80 #pragma HLS RESET variable=cache_init
81 #pragma HLS RESET variable=evs_loop_i
85 static UdpAppDLen udpTX_current_packet_length = 0;
86 static ap_uint<32> dst_ip_addr = 0;
88 static NodeId dst_rank = 0;
93 static stream<NalEventNotif> evsStreams[6];
98 switch(fsmStateTX_Udp) {
103 udpTX_packet_length = 0;
104 udpTX_current_packet_length = 0;
109 if( !cache_inval_sig.empty() )
111 if(cache_inval_sig.read())
115 cached_ip4addr_udp_tx = 0;
120 !sGetIpReq_UdpTx.full() )
123 udpTX_packet_length = udp_meta_in.
tdata.
len;
124 udpTX_current_packet_length = 0;
132 evsStreams[0].write_nb(new_ev_not);
148 evsStreams[3].write_nb(new_ev_not);
153 txMeta =
UdpAppMeta(*ipAddrBE, src_port, 0, dst_port);
156 if(cache_init && cached_nodeid_udp_tx == dst_rank)
158 dst_ip_addr = cached_ip4addr_udp_tx;
160 printf(
"used UDP TX id cache\n");
163 sGetIpReq_UdpTx.write(dst_rank);
171 if(!sGetIpRep_UdpTx.empty())
173 dst_ip_addr = sGetIpRep_UdpTx.read();
175 cached_nodeid_udp_tx = dst_rank;
176 cached_ip4addr_udp_tx = dst_ip_addr;
183 if ( !soUOE_Meta.full()
184 && !soUOE_DLen.full() )
189 evsStreams[1].write_nb(new_ev_not);
195 evsStreams[2].write_nb(new_ev_not);
197 evsStreams[4].write_nb(new_ev_not);
203 soUOE_Meta.write(txMeta);
207 soUOE_DLen.write(udpTX_packet_length);
209 evsStreams[5].write_nb(new_ev_not);
217 if ( !siUdp_data.empty() && !soUOE_Data.full() )
224 if(udpTX_packet_length > 0 && udpTX_current_packet_length >= udpTX_packet_length)
229 soUOE_Data.write(aWord);
239 if ( !siUdp_data.empty() )
246 if( (udpTX_packet_length > 0 && udpTX_current_packet_length >= udpTX_packet_length)
256 if(!internal_event_fifo.full())
258 if(!evsStreams[evs_loop_i].empty())
260 internal_event_fifo.write(evsStreams[evs_loop_i].read());
279 ap_uint<1> *piNTS_ready,
280 stream<UdpAppData> &sUoeTxBuffer_Data,
281 stream<UdpAppMeta> &sUoeTxBuffer_Meta,
282 stream<UdpAppDLen> &sUoeTxBuffer_DLen,
283 stream<UdpAppData> &soUOE_Data,
284 stream<UdpAppMeta> &soUOE_Meta,
285 stream<UdpAppDLen> &soUOE_DLen
289 #pragma HLS INLINE off
290 #pragma HLS pipeline II=1
293 #pragma HLS RESET variable=deqFsmState
305 if(!sUoeTxBuffer_Data.empty() && !sUoeTxBuffer_Meta.empty() && !sUoeTxBuffer_DLen.empty()
306 && ( (!soUOE_Data.full() && !soUOE_Meta.full() && !soUOE_DLen.full() ) ||
311 cur_word = sUoeTxBuffer_Data.read();
312 cur_meta = sUoeTxBuffer_Meta.read();
313 cur_dlen = sUoeTxBuffer_DLen.read();
316 soUOE_Data.write(cur_word);
317 soUOE_Meta.write(cur_meta);
318 soUOE_DLen.write(cur_dlen);
327 if(!sUoeTxBuffer_Data.empty()
328 && (!soUOE_Data.full() || uoe_disabled)
331 cur_word = sUoeTxBuffer_Data.read();
334 soUOE_Data.write(cur_word);
359 stream<UdpPort> &soUOE_LsnReq,
360 stream<StsBool> &siUOE_LsnRep,
361 stream<UdpPort> &sUdpPortsToOpen,
362 stream<bool> &sUdpPortsOpenFeedback
366 #pragma HLS INLINE off
367 #pragma HLS pipeline II=1
374 static ap_uint<16> startupDelay = 0x8000;
376 static ap_uint<16> startupDelay = 10;
379 #pragma HLS RESET variable=lsnFsmState
380 #pragma HLS RESET variable=startupDelay
382 static ap_uint<8> watchDogTimer_plisten = 0;
383 static UdpPort new_absolute_port = 0;
385 switch (lsnFsmState) {
389 if (startupDelay > 0)
398 if ( !soUOE_LsnReq.full() && !sUdpPortsToOpen.empty())
400 new_absolute_port = sUdpPortsToOpen.read();
401 soUOE_LsnReq.write(new_absolute_port);
403 printInfo(myName,
"Requesting to listen on port #%d (0x%4.4X).\n",
404 (
int) new_absolute_port, (
int) new_absolute_port);
405 #ifndef __SYNTHESIS__
406 watchDogTimer_plisten = 10;
408 watchDogTimer_plisten = 100;
419 if (!siUOE_LsnRep.empty() && !sUdpPortsOpenFeedback.full())
422 siUOE_LsnRep.read(listenDone);
424 printInfo(myName,
"Received listen acknowledgment from [UOE].\n");
426 sUdpPortsOpenFeedback.write(
true);
429 printWarn(myName,
"UOE denied listening on port %d (0x%4.4X).\n",
430 (
int) new_absolute_port, (
int) new_absolute_port);
431 sUdpPortsOpenFeedback.write(
false);
434 }
else if (watchDogTimer_plisten == 0 && !sUdpPortsOpenFeedback.full() )
436 printError(myName,
"Timeout: Server failed to listen on port %d %d (0x%4.4X).\n",
437 (
int) new_absolute_port, (
int) new_absolute_port);
438 sUdpPortsOpenFeedback.write(
false);
441 watchDogTimer_plisten--;
470 stream<NetworkWord> &soUdp_data,
472 stream<UdpAppData> &siUOE_Data,
473 stream<UdpAppMeta> &siUOE_Meta,
474 stream<UdpAppDLen> &siUOE_DLen,
475 stream<NalConfigUpdate> &sConfigUpdate,
476 stream<Ip4Addr> &sGetNidReq_UdpRx,
477 stream<NodeId> &sGetNidRep_UdpRx,
478 stream<bool> &cache_inval_sig,
479 stream<NalEventNotif> &internal_event_fifo
483 #pragma HLS INLINE off
484 #pragma HLS pipeline II=1
490 static NodeId cached_udp_rx_id = 0;
491 static Ip4Addr cached_udp_rx_ipaddr = 0;
492 static NodeId own_rank = 0;
493 static bool cache_init =
false;
494 static uint8_t evs_loop_i = 0;
496 #pragma HLS RESET variable=fsmStateRX_Udp
497 #pragma HLS RESET variable=cached_udp_rx_id
498 #pragma HLS RESET variable=cached_udp_rx_ipaddr
499 #pragma HLS RESET variable=own_rank
500 #pragma HLS RESET variable=cache_init
501 #pragma HLS RESET variable=evs_loop_i
509 static stream<NalEventNotif> evsStreams[4];
517 switch(fsmStateRX_Udp) {
524 if( !cache_inval_sig.empty() )
526 if(cache_inval_sig.read())
528 cached_udp_rx_id = 0;
529 cached_udp_rx_ipaddr = 0;
533 }
else if(!sConfigUpdate.empty())
540 cached_udp_rx_id = 0;
541 cached_udp_rx_ipaddr = 0;
544 }
else if ( !siUOE_Meta.empty()
545 && !siUOE_DLen.empty()
546 && !sGetNidReq_UdpRx.full())
549 siUOE_Meta.read(udpRxMeta);
550 siUOE_DLen.read(udpRxLen);
565 if(cache_init && cached_udp_rx_ipaddr == udpRxMeta.
ip4SrcAddr)
567 printf(
"used UDP RX id cache\n");
568 src_id = cached_udp_rx_id;
579 if(!sGetNidRep_UdpRx.empty())
581 src_id = sGetNidRep_UdpRx.read();
583 cached_udp_rx_id = src_id;
596 evsStreams[0].write_nb(new_ev_not);
597 printf(
"[UDP-RX:ERROR]invalid src_id, packet will be dropped.\n");
604 evsStreams[1].write_nb(new_ev_not);
606 evsStreams[2].write_nb(new_ev_not);
614 evsStreams[3].write_nb(new_ev_not);
622 if ( !siUOE_Data.empty() && !soUdp_data.full() )
628 soUdp_data.write(udpWord);
632 if (udpWord.
tlast == 1)
640 if( !siUOE_Data.empty() )
653 if(!internal_event_fifo.full())
655 if(!evsStreams[evs_loop_i].empty())
657 internal_event_fifo.write(evsStreams[evs_loop_i].read());
676 stream<NetworkWord> &sRoleUdpDataRx_buffer,
677 stream<NetworkMetaStream> &sRoleUdpMetaRx_buffer,
678 stream<NetworkWord> &soUdp_data,
683 #pragma HLS INLINE off
684 #pragma HLS pipeline II=1
687 #pragma HLS RESET variable=deqFsmState
698 if(!sRoleUdpDataRx_buffer.empty() && !sRoleUdpMetaRx_buffer.empty()
699 && ( (!soUdp_data.full() && !
soUdp_meta.full()) ||
704 cur_word = sRoleUdpDataRx_buffer.read();
705 cur_meta = sRoleUdpMetaRx_buffer.read();
708 soUdp_data.write(cur_word);
711 if(cur_word.
tlast == 0)
718 if(!sRoleUdpDataRx_buffer.empty()
719 && (!soUdp_data.full() || role_disabled)
722 cur_word = sRoleUdpDataRx_buffer.read();
725 soUdp_data.write(cur_word);
727 if(cur_word.
tlast == 1)
748 stream<UdpPort> &soUOE_ClsReq,
749 stream<StsBool> &siUOE_ClsRep,
750 stream<UdpPort> &sUdpPortsToClose
754 #pragma HLS INLINE off
755 #pragma HLS pipeline II=1
762 #pragma HLS RESET variable=clsFsmState_Udp
765 static ap_uint<16> newAbsolutePortToClose = 0;
768 switch (clsFsmState_Udp)
774 if(!sUdpPortsToClose.empty() && !soUOE_ClsReq.full() )
777 newAbsolutePortToClose = sUdpPortsToClose.read();
778 soUOE_ClsReq.write(newAbsolutePortToClose);
783 if(!siUOE_ClsRep.empty())
786 siUOE_ClsRep.read(isOpened);
789 printInfo(myName,
"Received close acknowledgment from [UOE].\n");
792 printWarn(myName,
"UOE denied closing the port %d (0x%4.4X) which is still opened.\n",
793 (
int) newAbsolutePortToClose, (
int) newAbsolutePortToClose);
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
LE_tLast getLE_TLast() const
ap_uint< 1 > layer_7_enabled
ap_uint< 1 > layer_4_enabled
void pUdpCls(stream< UdpPort > &soUOE_ClsReq, stream< StsBool > &siUOE_ClsRep, stream< UdpPort > &sUdpPortsToClose)
Asks the UOE to close UDP ports, based on the request from pPortLogic.
#define UNUSED_SESSION_ENTRY_VALUE
void pUdpTX(stream< NetworkWord > &siUdp_data, stream< NetworkMetaStream > &siUdp_meta, stream< UdpAppData > &soUOE_Data, stream< UdpAppMeta > &soUOE_Meta, stream< UdpAppDLen > &soUOE_DLen, stream< NodeId > &sGetIpReq_UdpTx, stream< Ip4Addr > &sGetIpRep_UdpTx, const ap_uint< 32 > *ipAddrBE, stream< bool > &cache_inval_sig, stream< NalEventNotif > &internal_event_fifo)
Processes the outgoing UDP packets (i.e. ROLE -> Network).
void pRoleUdpRxDeq(ap_uint< 1 > *layer_7_enabled, ap_uint< 1 > *role_decoupled, stream< NetworkWord > &sRoleUdpDataRx_buffer, stream< NetworkMetaStream > &sRoleUdpMetaRx_buffer, stream< NetworkWord > &soUdp_data, stream< NetworkMetaStream > &soUdp_meta)
Terminates the internal UDP RX FIFOs and forwards packets to the Role.
stream< NetworkMetaStream > soUdp_meta("soUdp_meta")
void pUdpLsn(stream< UdpPort > &soUOE_LsnReq, stream< StsBool > &siUOE_LsnRep, stream< UdpPort > &sUdpPortsToOpen, stream< bool > &sUdpPortsOpenFeedback)
Asks the UOE to open new UDP ports for listening, based on the request from pPortLogic.
uint8_t extractByteCnt(AxisRaw currWord)
ap_uint< 1 > role_decoupled
stream< NetworkMetaStream > siUdp_meta("siUdp_meta")
#define NAL_CONFIG_OWN_RANK
void pUdpRx(ap_uint< 1 > *layer_7_enabled, ap_uint< 1 > *role_decoupled, stream< NetworkWord > &soUdp_data, stream< NetworkMetaStream > &soUdp_meta, stream< UdpAppData > &siUOE_Data, stream< UdpAppMeta > &siUOE_Meta, stream< UdpAppDLen > &siUOE_DLen, stream< NalConfigUpdate > &sConfigUpdate, stream< Ip4Addr > &sGetNidReq_UdpRx, stream< NodeId > &sGetNidRep_UdpRx, stream< bool > &cache_inval_sig, stream< NalEventNotif > &internal_event_fifo)
Processes the incoming UDP packets (i.e. Network -> ROLE ).
void pUoeUdpTxDeq(ap_uint< 1 > *layer_4_enabled, ap_uint< 1 > *piNTS_ready, stream< UdpAppData > &sUoeTxBuffer_Data, stream< UdpAppMeta > &sUoeTxBuffer_Meta, stream< UdpAppDLen > &sUoeTxBuffer_DLen, stream< UdpAppData > &soUOE_Data, stream< UdpAppMeta > &soUOE_Meta, stream< UdpAppDLen > &soUOE_DLen)
Terminates the internal UDP TX FIFOs and forwards packets to the UOE.
#define INVALID_MRT_VALUE
#define printError(callerName, format,...)
A macro to print an error message.
#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)
: The cloudFPGA Network Abstraction Layer (NAL) between NTS and ROlE. The NAL core manages the NTS St...
ap_uint< 16 > config_addr
ap_uint< 32 > update_value
: The UDP Sub System (USS) of the NAL core.