cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
uss.cpp
Go to the documentation of this file.
1 
17 
30 #include "uss.hpp"
31 #include "nal.hpp"
32 
33 using namespace hls;
34 
35 
36 
51 void pUdpTX(
52  stream<NetworkWord> &siUdp_data,
53  stream<NetworkMetaStream> &siUdp_meta,
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
62  )
63 {
64  //-- DIRECTIVES FOR THIS PROCESS ------------------------------------------
65 #pragma HLS INLINE off
66 #pragma HLS pipeline II=1
67 
68  char *myName = concat3(THIS_NAME, "/", "Udp_TX");
69 
70  //-- STATIC CONTROL VARIABLES (with RESET) --------------------------------
71  static FsmStateUdp fsmStateTX_Udp = FSM_RESET;
72  static NodeId cached_nodeid_udp_tx = UNUSED_SESSION_ENTRY_VALUE;
73  static Ip4Addr cached_ip4addr_udp_tx = 0;
74  static bool cache_init = false;
75  static uint8_t evs_loop_i = 0;
76 
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
82 
83  //-- STATIC DATAFLOW VARIABLES --------------------------------------------
84  static UdpAppDLen udpTX_packet_length = 0;
85  static UdpAppDLen udpTX_current_packet_length = 0;
86  static ap_uint<32> dst_ip_addr = 0;
87  static NetworkMetaStream udp_meta_in;
88  static NodeId dst_rank = 0;
89  static UdpAppMeta txMeta;
90  static NrcPort src_port;
91  static NrcPort dst_port;
92 
93  static stream<NalEventNotif> evsStreams[6];
94 
95  //-- LOCAL DATAFLOW VARIABLES ---------------------------------------------
96  NalEventNotif new_ev_not;
97 
98  switch(fsmStateTX_Udp) {
99 
100  default:
101  case FSM_RESET:
102  fsmStateTX_Udp = FSM_W8FORMETA;
103  udpTX_packet_length = 0;
104  udpTX_current_packet_length = 0;
105  cache_init = false;
106  break;
107 
108  case FSM_W8FORMETA:
109  if( !cache_inval_sig.empty() )
110  {
111  if(cache_inval_sig.read())
112  {
113  cache_init = false;
114  cached_nodeid_udp_tx = UNUSED_SESSION_ENTRY_VALUE;
115  cached_ip4addr_udp_tx = 0;
116  }
117  break;
118  }
119  else if ( !siUdp_meta.empty() &&
120  !sGetIpReq_UdpTx.full() )
121  {
122  udp_meta_in = siUdp_meta.read();
123  udpTX_packet_length = udp_meta_in.tdata.len;
124  udpTX_current_packet_length = 0;
125 
126  // Send out the first data together with the metadata and payload length information
127 
128  dst_rank = udp_meta_in.tdata.dst_rank;
129  if(dst_rank > MAX_CF_NODE_ID)
130  {
131  new_ev_not = NalEventNotif(NID_MISS_TX, 1);
132  evsStreams[0].write_nb(new_ev_not);
133  //SINK packet
134  fsmStateTX_Udp = FSM_DROP_PACKET;
135  break;
136  }
137 
138  src_port = udp_meta_in.tdata.src_port;
139  if (src_port == 0)
140  {
141  src_port = DEFAULT_RX_PORT;
142  }
143  dst_port = udp_meta_in.tdata.dst_port;
144  if (dst_port == 0)
145  {
146  dst_port = DEFAULT_RX_PORT;
147  new_ev_not = NalEventNotif(PCOR_TX, 1);
148  evsStreams[3].write_nb(new_ev_not);
149  }
150 
151  //to create here due to timing...
152  //dst addres as 0 for now
153  txMeta = UdpAppMeta(*ipAddrBE, src_port, 0, dst_port);
154 
155  //request ip if necessary
156  if(cache_init && cached_nodeid_udp_tx == dst_rank)
157  {
158  dst_ip_addr = cached_ip4addr_udp_tx;
159  fsmStateTX_Udp = FSM_FIRST_ACC;
160  printf("used UDP TX id cache\n");
161  } else {
162 
163  sGetIpReq_UdpTx.write(dst_rank);
164  fsmStateTX_Udp = FSM_W8FORREQS;
165  //break;
166  }
167  }
168  break;
169 
170  case FSM_W8FORREQS:
171  if(!sGetIpRep_UdpTx.empty())
172  {
173  dst_ip_addr = sGetIpRep_UdpTx.read();
174  //TODO: need new FSM states
175  cached_nodeid_udp_tx = dst_rank;
176  cached_ip4addr_udp_tx = dst_ip_addr;
177  cache_init = true;
178  fsmStateTX_Udp = FSM_FIRST_ACC;
179  }
180  break;
181 
182  case FSM_FIRST_ACC:
183  if ( !soUOE_Meta.full()
184  && !soUOE_DLen.full() )
185  {
186  if(dst_ip_addr == 0)
187  {
188  new_ev_not = NalEventNotif(NID_MISS_TX, 1);
189  evsStreams[1].write_nb(new_ev_not);
190  //SINK packet
191  fsmStateTX_Udp = FSM_DROP_PACKET;
192  break;
193  }
194  new_ev_not = NalEventNotif(LAST_TX_NID, dst_rank);
195  evsStreams[2].write_nb(new_ev_not);
196  new_ev_not = NalEventNotif(LAST_TX_PORT, dst_port);
197  evsStreams[4].write_nb(new_ev_not);
198  //UdpMeta txMeta = {{src_port, ipAddrBE}, {dst_port, dst_ip_addr}};
199  //txMeta = SocketPair(SockAddr(*ipAddrBE, src_port), SockAddr(dst_ip_addr, dst_port));
200  txMeta.ip4DstAddr = dst_ip_addr;
201 
202  // Forward data chunk, metadata and payload length
203  soUOE_Meta.write(txMeta);
204 
205  //we can forward the length, even if 0
206  //the UOE handles this as streaming mode
207  soUOE_DLen.write(udpTX_packet_length);
208  new_ev_not = NalEventNotif(PACKET_TX, 1);
209  evsStreams[5].write_nb(new_ev_not);
210 
211  fsmStateTX_Udp = FSM_ACC;
212  }
213  break;
214 
215  case FSM_ACC:
216  // Default stream handling
217  if ( !siUdp_data.empty() && !soUOE_Data.full() )
218  {
219  // Forward data chunk
220  //UdpAppData aWord = siUdp_data.read();
221  NetworkWord tmpWord = siUdp_data.read();
222  UdpAppData aWord = UdpAppData(tmpWord.tdata, tmpWord.tkeep, tmpWord.tlast);
223  udpTX_current_packet_length += extractByteCnt(aWord);
224  if(udpTX_packet_length > 0 && udpTX_current_packet_length >= udpTX_packet_length)
225  {//we need to set tlast manually
226  aWord.setTLast(1);
227  }
228 
229  soUOE_Data.write(aWord);
230  // Until LAST bit is set
231  if (aWord.getTLast() == 1)
232  {
233  fsmStateTX_Udp = FSM_W8FORMETA;
234  }
235  }
236  break;
237 
238  case FSM_DROP_PACKET:
239  if ( !siUdp_data.empty() )
240  {
241  //UdpAppData aWord = siUdp_data.read();
242  NetworkWord tmpWord = siUdp_data.read();
243  UdpAppData aWord = UdpAppData(tmpWord.tdata, tmpWord.tkeep, tmpWord.tlast);
244  udpTX_current_packet_length += extractByteCnt(aWord);
245 
246  if( (udpTX_packet_length > 0 && udpTX_current_packet_length >= udpTX_packet_length)
247  || aWord.getTLast() == 1 )
248  {
249  fsmStateTX_Udp = FSM_W8FORMETA;
250  }
251  }
252  break;
253  } //switch
254 
255  //-- ALWAYS -----------------------
256  if(!internal_event_fifo.full())
257  {
258  if(!evsStreams[evs_loop_i].empty())
259  {
260  internal_event_fifo.write(evsStreams[evs_loop_i].read());
261  }
262  evs_loop_i++;
263  if(evs_loop_i >= 6)
264  {
265  evs_loop_i = 0;
266  }
267  }
268 
269 }
270 
271 
272 
273 
278  ap_uint<1> *layer_4_enabled,
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
286  )
287 {
288  //-- DIRECTIVES FOR THIS PROCESS ------------------------------------------
289 #pragma HLS INLINE off
290 #pragma HLS pipeline II=1
291  //-- STATIC CONTROL VARIABLES (with RESET) --------------------------------
292  static DeqFsmStates deqFsmState = DEQ_WAIT_META;
293 #pragma HLS RESET variable=deqFsmState
294  //-- STATIC DATAFLOW VARIABLES --------------------------------------------
295  //-- LOCAL DATAFLOW VARIABLES ---------------------------------------------
296  UdpAppData cur_word;
297  UdpAppMeta cur_meta;
298  UdpAppDLen cur_dlen;
299  bool uoe_disabled = (*layer_4_enabled == 0 || *piNTS_ready == 0);
300 
301  switch(deqFsmState)
302  {
303  default:
304  case DEQ_WAIT_META:
305  if(!sUoeTxBuffer_Data.empty() && !sUoeTxBuffer_Meta.empty() && !sUoeTxBuffer_DLen.empty()
306  && ( (!soUOE_Data.full() && !soUOE_Meta.full() && !soUOE_DLen.full() ) || //UOE can read
307  (uoe_disabled) //UOE is disabled -> drain FIFOs
308  )
309  )
310  {
311  cur_word = sUoeTxBuffer_Data.read();
312  cur_meta = sUoeTxBuffer_Meta.read();
313  cur_dlen = sUoeTxBuffer_DLen.read();
314  if(!uoe_disabled)
315  {
316  soUOE_Data.write(cur_word);
317  soUOE_Meta.write(cur_meta);
318  soUOE_DLen.write(cur_dlen);
319  }
320  if(cur_word.getTLast() == 0)
321  {
322  deqFsmState = DEQ_STREAM_DATA;
323  }
324  }
325  break;
326  case DEQ_STREAM_DATA:
327  if(!sUoeTxBuffer_Data.empty()
328  && (!soUOE_Data.full() || uoe_disabled)
329  )
330  {
331  cur_word = sUoeTxBuffer_Data.read();
332  if(!uoe_disabled)
333  {
334  soUOE_Data.write(cur_word);
335  }
336  if(cur_word.getTLast() == 1)
337  {
338  deqFsmState = DEQ_WAIT_META;
339  }
340  }
341  break;
342  }
343 
344 }
345 
346 
347 
348 
358 void pUdpLsn(
359  stream<UdpPort> &soUOE_LsnReq,
360  stream<StsBool> &siUOE_LsnRep,
361  stream<UdpPort> &sUdpPortsToOpen,
362  stream<bool> &sUdpPortsOpenFeedback
363  )
364 {
365  //-- DIRECTIVES FOR THIS PROCESS ------------------------------------------
366 #pragma HLS INLINE off
367 #pragma HLS pipeline II=1
368 
369  char* myName = concat3(THIS_NAME, "/", "Udp_LSn");
370 
371  //-- STATIC CONTROL VARIABLES (with RESET) --------------------------------
372  static LsnFsmStates lsnFsmState = LSN_IDLE;
373 #ifdef __SYNTHESIS_
374  static ap_uint<16> startupDelay = 0x8000;
375 #else
376  static ap_uint<16> startupDelay = 10;
377 #endif
378 
379 #pragma HLS RESET variable=lsnFsmState
380 #pragma HLS RESET variable=startupDelay
381  //-- STATIC DATAFLOW VARIABLES --------------------------------------------
382  static ap_uint<8> watchDogTimer_plisten = 0;
383  static UdpPort new_absolute_port = 0;
384 
385  switch (lsnFsmState) {
386 
387  default:
388  case LSN_IDLE:
389  if (startupDelay > 0)
390  {
391  startupDelay--;
392  } else {
393  lsnFsmState = LSN_SEND_REQ;
394  }
395  break;
396 
397  case LSN_SEND_REQ:
398  if ( !soUOE_LsnReq.full() && !sUdpPortsToOpen.empty())
399  {
400  new_absolute_port = sUdpPortsToOpen.read();
401  soUOE_LsnReq.write(new_absolute_port);
402  if (DEBUG_LEVEL & TRACE_LSN) {
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;
407 #else
408  watchDogTimer_plisten = 100;
409 #endif
410  lsnFsmState = LSN_WAIT_ACK;
411  }
412  }
413  //else {
414  // printWarn(myName, "Cannot send a listen port request to [UOE] because stream is full!\n");
415  //}
416  break;
417 
418  case LSN_WAIT_ACK:
419  if (!siUOE_LsnRep.empty() && !sUdpPortsOpenFeedback.full())
420  {
421  bool listenDone;
422  siUOE_LsnRep.read(listenDone);
423  if (listenDone) {
424  printInfo(myName, "Received listen acknowledgment from [UOE].\n");
425  lsnFsmState = LSN_SEND_REQ;
426  sUdpPortsOpenFeedback.write(true);
427  }
428  else {
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);
432  lsnFsmState = LSN_SEND_REQ;
433  }
434  } else if (watchDogTimer_plisten == 0 && !sUdpPortsOpenFeedback.full() )
435  {
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);
439  lsnFsmState = LSN_SEND_REQ;
440  } else {
441  watchDogTimer_plisten--;
442  }
443  break;
444 
445  }
446 }
447 
448 
449 
450 
467 void pUdpRx(
468  ap_uint<1> *layer_7_enabled,
469  ap_uint<1> *role_decoupled,
470  stream<NetworkWord> &soUdp_data,
471  stream<NetworkMetaStream> &soUdp_meta,
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
480  )
481 {
482  //-- DIRECTIVES FOR THIS PROCESS ------------------------------------------
483 #pragma HLS INLINE off
484 #pragma HLS pipeline II=1
485 
486  char *myName = concat3(THIS_NAME, "/", "Udp_RX");
487 
488  //-- STATIC CONTROL VARIABLES (with RESET) --------------------------------
489  static FsmStateUdp fsmStateRX_Udp = FSM_W8FORMETA;
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;
495 
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
502 
503  //-- STATIC DATAFLOW VARIABLES --------------------------------------------
504  static UdpAppMeta udpRxMeta;
505  static UdpAppDLen udpRxLen;
506  static NodeId src_id = INVALID_MRT_VALUE;
507  static NetworkMeta in_meta;
508 
509  static stream<NalEventNotif> evsStreams[4];
510 
511  //-- LOCAL DATAFLOW VARIABLES ---------------------------------------------
512  NalEventNotif new_ev_not;
513  NetworkMetaStream in_meta_udp_stream;
514  bool role_disabled = (*layer_7_enabled == 0 || *role_decoupled == 1);
515 
516 
517  switch(fsmStateRX_Udp) {
518 
519  default:
520  //case FSM_RESET:
521  //fsmStateRX_Udp = FSM_W8FORMETA;
522  //NO break;
523  case FSM_W8FORMETA:
524  if( !cache_inval_sig.empty() )
525  {
526  if(cache_inval_sig.read())
527  {
528  cached_udp_rx_id = 0;
529  cached_udp_rx_ipaddr = 0;
530  cache_init = false;
531  }
532  break;
533  } else if(!sConfigUpdate.empty())
534  {
535  NalConfigUpdate ca = sConfigUpdate.read();
537  {
538  own_rank = (NodeId) ca.update_value;
539  cache_init = false;
540  cached_udp_rx_id = 0;
541  cached_udp_rx_ipaddr = 0;
542  }
543  break;
544  } else if ( !siUOE_Meta.empty()
545  && !siUOE_DLen.empty()
546  && !sGetNidReq_UdpRx.full())
547  {
548  //extract src ip address
549  siUOE_Meta.read(udpRxMeta);
550  siUOE_DLen.read(udpRxLen);
551  src_id = (NodeId) INVALID_MRT_VALUE;
552 
553  if(role_disabled)
554  {
555  fsmStateRX_Udp = FSM_DROP_PACKET;
556  //no notifications necessary, UOE counts?
557  cache_init = false;
558  break;
559  }
560 
561  //to create here due to timing...
562  in_meta = NetworkMeta(own_rank, udpRxMeta.udpDstPort, 0, udpRxMeta.udpSrcPort, udpRxLen);
563 
564  //ask cache
565  if(cache_init && cached_udp_rx_ipaddr == udpRxMeta.ip4SrcAddr)
566  {
567  printf("used UDP RX id cache\n");
568  src_id = cached_udp_rx_id;
569  fsmStateRX_Udp = FSM_FIRST_ACC;
570  } else {
571  sGetNidReq_UdpRx.write(udpRxMeta.ip4SrcAddr);
572  fsmStateRX_Udp = FSM_W8FORREQS;
573  //break;
574  }
575  }
576  break;
577 
578  case FSM_W8FORREQS:
579  if(!sGetNidRep_UdpRx.empty())
580  {
581  src_id = sGetNidRep_UdpRx.read();
582  cached_udp_rx_ipaddr = udpRxMeta.ip4SrcAddr;
583  cached_udp_rx_id = src_id;
584  cache_init = true;
585  fsmStateRX_Udp = FSM_FIRST_ACC;
586  }
587  break;
588 
589  case FSM_FIRST_ACC:
590  if( !soUdp_meta.full() )
591  {
592  if(src_id == ((NodeId) INVALID_MRT_VALUE))
593  {
594  //SINK packet
595  new_ev_not = NalEventNotif(NID_MISS_RX, 1);
596  evsStreams[0].write_nb(new_ev_not);
597  printf("[UDP-RX:ERROR]invalid src_id, packet will be dropped.\n");
598  fsmStateRX_Udp = FSM_DROP_PACKET;
599  cache_init = false;
600  break;
601  }
602  //status
603  new_ev_not = NalEventNotif(LAST_RX_NID, src_id);
604  evsStreams[1].write_nb(new_ev_not);
605  new_ev_not = NalEventNotif(LAST_RX_PORT, udpRxMeta.udpDstPort);
606  evsStreams[2].write_nb(new_ev_not);
607  in_meta.src_rank = src_id;
608 
609  //write metadata
610  in_meta_udp_stream = NetworkMetaStream(in_meta);
611  soUdp_meta.write(in_meta_udp_stream);
612  //soUdp_meta.write(in_meta_udp);
613  new_ev_not = NalEventNotif(PACKET_RX, 1);
614  evsStreams[3].write_nb(new_ev_not);
615  // Forward data chunk to ROLE
616  fsmStateRX_Udp = FSM_ACC;
617  }
618  break;
619 
620  case FSM_ACC:
621  // Default stream handling
622  if ( !siUOE_Data.empty() && !soUdp_data.full() )
623  {
624  // Forward data chunk to ROLE
625  //NetworkWord udpWord = siUOE_Data.read();
626  UdpAppData udpWordtmp = siUOE_Data.read();
627  NetworkWord udpWord = NetworkWord(udpWordtmp.getLE_TData(), udpWordtmp.getLE_TKeep(), udpWordtmp.getLE_TLast());
628  soUdp_data.write(udpWord);
629  //TODO: should we verify the length of udpRxLen?
630 
631  // Until LAST bit is set
632  if (udpWord.tlast == 1)
633  {
634  fsmStateRX_Udp = FSM_W8FORMETA;
635  }
636  }
637  break;
638 
639  case FSM_DROP_PACKET:
640  if( !siUOE_Data.empty() )
641  {
642  UdpAppData udpWord = siUOE_Data.read();
643  // Until LAST bit is set
644  if (udpWord.getTLast() == 1)
645  {
646  fsmStateRX_Udp = FSM_W8FORMETA;
647  }
648  }
649  break;
650  } //switch
651 
652  //-- ALWAYS -----------------------
653  if(!internal_event_fifo.full())
654  {
655  if(!evsStreams[evs_loop_i].empty())
656  {
657  internal_event_fifo.write(evsStreams[evs_loop_i].read());
658  }
659  evs_loop_i++;
660  if(evs_loop_i >= 4)
661  {
662  evs_loop_i = 0;
663  }
664  }
665 
666 }
667 
668 
669 
674  ap_uint<1> *layer_7_enabled,
675  ap_uint<1> *role_decoupled,
676  stream<NetworkWord> &sRoleUdpDataRx_buffer,
677  stream<NetworkMetaStream> &sRoleUdpMetaRx_buffer,
678  stream<NetworkWord> &soUdp_data,
679  stream<NetworkMetaStream> &soUdp_meta
680  )
681 {
682  //-- DIRECTIVES FOR THIS PROCESS ------------------------------------------
683 #pragma HLS INLINE off
684 #pragma HLS pipeline II=1
685  //-- STATIC CONTROL VARIABLES (with RESET) --------------------------------
686  static DeqFsmStates deqFsmState = DEQ_WAIT_META;
687 #pragma HLS RESET variable=deqFsmState
688  //-- STATIC DATAFLOW VARIABLES --------------------------------------------
689  //-- LOCAL DATAFLOW VARIABLES ---------------------------------------------
690  NetworkWord cur_word = NetworkWord();
692  bool role_disabled = (*layer_7_enabled == 0 || *role_decoupled == 1);
693 
694  switch(deqFsmState)
695  {
696  default:
697  case DEQ_WAIT_META:
698  if(!sRoleUdpDataRx_buffer.empty() && !sRoleUdpMetaRx_buffer.empty()
699  && ( (!soUdp_data.full() && !soUdp_meta.full()) || //user can read
700  (role_disabled) //role is disabled -> drain FIFOs
701  )
702  )
703  {
704  cur_word = sRoleUdpDataRx_buffer.read();
705  cur_meta = sRoleUdpMetaRx_buffer.read();
706  if(!role_disabled)
707  {
708  soUdp_data.write(cur_word);
709  soUdp_meta.write(cur_meta);
710  }
711  if(cur_word.tlast == 0)
712  {
713  deqFsmState = DEQ_STREAM_DATA;
714  }
715  }
716  break;
717  case DEQ_STREAM_DATA:
718  if(!sRoleUdpDataRx_buffer.empty()
719  && (!soUdp_data.full() || role_disabled)
720  )
721  {
722  cur_word = sRoleUdpDataRx_buffer.read();
723  if(!role_disabled)
724  {
725  soUdp_data.write(cur_word);
726  }
727  if(cur_word.tlast == 1)
728  {
729  deqFsmState = DEQ_WAIT_META;
730  }
731  }
732  break;
733  }
734 
735 }
736 
737 
738 
739 
747 void pUdpCls(
748  stream<UdpPort> &soUOE_ClsReq,
749  stream<StsBool> &siUOE_ClsRep,
750  stream<UdpPort> &sUdpPortsToClose
751  )
752 {
753  //-- DIRECTIVES FOR THIS PROCESS ------------------------------------------
754 #pragma HLS INLINE off
755 #pragma HLS pipeline II=1
756 
757  char *myName = concat3(THIS_NAME, "/", "Udp_Cls");
758 
759  //-- STATIC CONTROL VARIABLES (with RESET) --------------------------------
760  static ClsFsmStates clsFsmState_Udp = CLS_IDLE;
761 
762 #pragma HLS RESET variable=clsFsmState_Udp
763  //-- STATIC DATAFLOW VARIABLES --------------------------------------------
764  //static ap_uint<16> newRelativePortToClose = 0;
765  static ap_uint<16> newAbsolutePortToClose = 0;
766 
767 
768  switch (clsFsmState_Udp)
769  {
770  default:
771  case CLS_IDLE:
772  clsFsmState_Udp = CLS_NEXT;
773  case CLS_NEXT:
774  if(!sUdpPortsToClose.empty() && !soUOE_ClsReq.full() )
775  {
776  //we have to close opened ports, one after another
777  newAbsolutePortToClose = sUdpPortsToClose.read();
778  soUOE_ClsReq.write(newAbsolutePortToClose);
779  clsFsmState_Udp = CLS_WAIT4RESP;
780  }
781  break;
782  case CLS_WAIT4RESP:
783  if(!siUOE_ClsRep.empty())
784  {
785  StsBool isOpened;
786  siUOE_ClsRep.read(isOpened);
787  if (not isOpened)
788  {
789  printInfo(myName, "Received close acknowledgment from [UOE].\n");
790  }
791  else {
792  printWarn(myName, "UOE denied closing the port %d (0x%4.4X) which is still opened.\n",
793  (int) newAbsolutePortToClose, (int) newAbsolutePortToClose);
794  }
795  //in all cases
796  clsFsmState_Udp = CLS_NEXT;
797  }
798  break;
799  }
800 }
801 
802 
void setTLast(tLast last)
Definition: AxisRaw.hpp:246
tLast getTLast() const
Definition: AxisRaw.hpp:219
LE_tKeep getLE_TKeep(int leHi=64/8-1, int leLo=0) const
Definition: AxisRaw.hpp:264
LE_tData getLE_TData(int leHi=64 -1, int leLo=0) const
Definition: AxisRaw.hpp:260
LE_tLast getLE_TLast() const
Definition: AxisRaw.hpp:268
Ly4Port udpDstPort
Definition: nts.hpp:229
Ly4Port udpSrcPort
Definition: nts.hpp:227
Ip4Addr ip4SrcAddr
Definition: nts.hpp:226
Ip4Addr ip4DstAddr
Definition: nts.hpp:228
ap_uint< 1 > layer_7_enabled
Definition: tb_fmc.cpp:68
ap_uint< 1 > layer_4_enabled
Definition: tb_fmc.cpp:66
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.
Definition: uss.cpp:747
#define UNUSED_SESSION_ENTRY_VALUE
Definition: nal.hpp:202
UdpLen UdpAppDLen
Definition: nal.hpp:255
LsnFsmStates
Definition: nal.hpp:146
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).
Definition: uss.cpp:51
DeqFsmStates
Definition: nal.hpp:164
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.
Definition: uss.cpp:673
stream< NetworkMetaStream > soUdp_meta("soUdp_meta")
#define DEFAULT_RX_PORT
Definition: nal.hpp:139
bool StsBool
Definition: nal.hpp:246
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.
Definition: uss.cpp:358
ClsFsmStates
Definition: nal.hpp:162
uint8_t extractByteCnt(AxisRaw currWord)
Definition: nal.cpp:94
FsmStateUdp
Definition: nal.hpp:141
#define THIS_NAME
Definition: nal.hpp:113
ap_uint< 1 > role_decoupled
Definition: tb_nal.cpp:134
#define DEBUG_LEVEL
Definition: nal.hpp:123
stream< NetworkMetaStream > siUdp_meta("siUdp_meta")
#define NAL_CONFIG_OWN_RANK
Definition: nal.hpp:215
ap_uint< 16 > UdpPort
Definition: nal.hpp:249
#define TRACE_LSN
Definition: nal.hpp:119
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 ).
Definition: uss.cpp:467
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.
Definition: uss.cpp:277
#define INVALID_MRT_VALUE
Definition: nal.hpp:203
@ LSN_IDLE
Definition: nal.hpp:146
@ LSN_SEND_REQ
Definition: nal.hpp:146
@ LSN_WAIT_ACK
Definition: nal.hpp:146
@ DEQ_WAIT_META
Definition: nal.hpp:164
@ DEQ_STREAM_DATA
Definition: nal.hpp:164
@ CLS_WAIT4RESP
Definition: nal.hpp:162
@ CLS_IDLE
Definition: nal.hpp:162
@ CLS_NEXT
Definition: nal.hpp:162
@ FSM_RESET
Definition: nal.hpp:141
@ FSM_W8FORREQS
Definition: nal.hpp:141
@ FSM_W8FORMETA
Definition: nal.hpp:141
@ FSM_FIRST_ACC
Definition: nal.hpp:141
@ FSM_DROP_PACKET
Definition: nal.hpp:142
@ FSM_ACC
Definition: nal.hpp:141
@ LAST_TX_PORT
Definition: nal.hpp:182
@ NID_MISS_RX
Definition: nal.hpp:181
@ PCOR_TX
Definition: nal.hpp:181
@ PACKET_TX
Definition: nal.hpp:182
@ LAST_TX_NID
Definition: nal.hpp:182
@ PACKET_RX
Definition: nal.hpp:182
@ NID_MISS_TX
Definition: nal.hpp:181
@ LAST_RX_PORT
Definition: nal.hpp:181
@ LAST_RX_NID
Definition: nal.hpp:182
#define printError(callerName, format,...)
A macro to print an error message.
Definition: nts_utils.hpp:195
ap_uint< 32 > Ip4Addr
Definition: AxisIp4.hpp:169
#define printInfo(callerName, format,...)
A macro to print an information message.
Definition: nts_utils.hpp:169
#define printWarn(callerName, format,...)
A macro to print a warning message.
Definition: nts_utils.hpp:182
#define concat3(firstCharConst, secondCharConst, thirdCharConst)
Definition: nts_utils.hpp:161
AxisRaw UdpAppData
Definition: nts.hpp:214
: The cloudFPGA Network Abstraction Layer (NAL) between NTS and ROlE. The NAL core manages the NTS St...
ap_uint< 8 > NodeId
Definition: network.hpp:82
ap_uint< 16 > NrcPort
Definition: network.hpp:81
#define MAX_CF_NODE_ID
Definition: network.hpp:85
ap_uint< 16 > config_addr
Definition: nal.hpp:291
ap_uint< 32 > update_value
Definition: nal.hpp:292
NetworkMeta tdata
Definition: network.hpp:109
NetworkDataLength len
Definition: network.hpp:99
NodeId dst_rank
Definition: network.hpp:95
NodeId src_rank
Definition: network.hpp:97
NrcPort src_port
Definition: network.hpp:98
NrcPort dst_port
Definition: network.hpp:96
ap_uint< 64 > tdata
Definition: network.hpp:49
ap_uint< 8 > tkeep
Definition: network.hpp:50
ap_uint< 1 > tlast
Definition: network.hpp:51
: The UDP Sub System (USS) of the NAL core.