54 stream<TcpAppLsnReq> &soTOE_LsnReq,
55 stream<TcpAppLsnRep> &siTOE_LsnRep,
56 stream<TcpPort> &sTcpPortsToOpen,
57 stream<bool> &sTcpPortsOpenFeedback
61 #pragma HLS INLINE off
62 #pragma HLS pipeline II=1
69 static ap_uint<16> startupDelay = 0x8000;
71 static ap_uint<16> startupDelay = 5;
74 #pragma HLS RESET variable=lsnFsmState
75 #pragma HLS RESET variable=startupDelay
77 static ap_uint<8> watchDogTimer_plisten = 0;
78 ap_uint<16> new_absolute_port = 0;
81 switch (lsnFsmState) {
94 if (!soTOE_LsnReq.full() && !sTcpPortsToOpen.empty())
96 new_absolute_port = sTcpPortsToOpen.read();
98 soTOE_LsnReq.write(tcpListenPort);
100 printInfo(myName,
"Server is requested to listen on port #%d (0x%4.4X).\n",
101 (
int) new_absolute_port, (
int) new_absolute_port);
102 #ifndef __SYNTHESIS__
103 watchDogTimer_plisten = 10;
105 watchDogTimer_plisten = 100;
116 if (!siTOE_LsnRep.empty() && !sTcpPortsOpenFeedback.full())
119 siTOE_LsnRep.read(listenDone);
121 printInfo(myName,
"Received listen acknowledgment from [TOE].\n");
123 sTcpPortsOpenFeedback.write(
true);
126 printWarn(myName,
"TOE denied listening on port %d (0x%4.4X).\n",
127 (
int) new_absolute_port, (
int) new_absolute_port);
128 sTcpPortsOpenFeedback.write(
false);
131 }
else if (watchDogTimer_plisten == 0 && !sTcpPortsOpenFeedback.full() )
133 ap_uint<16> new_absolute_port = 0;
134 printError(myName,
"Timeout: Server failed to listen on port %d %d (0x%4.4X).\n",
135 (
int) new_absolute_port, (
int) new_absolute_port);
136 sTcpPortsOpenFeedback.write(
false);
139 watchDogTimer_plisten--;
154 ap_uint<1> *piNTS_ready,
155 stream<TcpAppNotif> &siTOE_Notif,
156 stream<TcpAppNotif> &sTcpNotif_buffer
160 #pragma HLS INLINE off
161 #pragma HLS pipeline II=1
164 #pragma HLS RESET variable=rrhEngFsm
178 else if(!siTOE_Notif.empty())
188 else if(!siTOE_Notif.empty() && !sTcpNotif_buffer.full())
191 sTcpNotif_buffer.write(new_notif);
221 ap_uint<1> *piNTS_ready,
222 ap_uint<32> *piMMIO_CfrmIp4Addr,
223 ap_uint<16> *piMMIO_FmcLsnPort,
224 stream<TcpAppNotif> &siTOE_Notif,
225 stream<TcpAppRdReq> &soTOE_DReq,
226 stream<NalNewTableEntry> &sAddNewTriple_TcpRrh,
227 stream<SessionId> &sMarkAsPriv,
228 stream<SessionId> &sDeleteEntryBySid,
229 stream<TcpAppRdReq> &sRDp_ReqNotif,
230 stream<PacketLen> &fmc_write_cnt_sig,
231 stream<PacketLen> &role_write_cnt_sig
235 #pragma HLS INLINE off
236 #pragma HLS pipeline II=1
243 #pragma HLS RESET variable=rrhFsmState
247 #ifndef __SYNTHESIS__
250 printf(
"\n\t\tERROR: pTcpRRh is currently configured to support only 8 parallel sessions! Abort.\n(Currently, the use of \'Cam8\' must be updated accordingly by hand.)\n");
255 static stream<NalWaitingData> waitingSessions (
"sTcpRRh_WaitingSessions");
256 static stream<NalWaitingData> session_reinsert (
"sTcpRRh_sessions_to_reinsert");
257 #pragma HLS STREAM variable=waitingSessions depth=8
258 #pragma HLS STREAM variable=session_reinsert depth=8
262 static bool already_waiting =
false;
264 static TcpDatLen length_update_value = 0;
266 static bool found_fmc_sess =
false;
267 static bool need_cam_update =
false;
268 static bool go_back_to_ack_wait_role =
false;
269 static bool go_back_to_ack_wait_fmc =
false;
280 sessionLength.
reset();
281 go_back_to_ack_wait_fmc =
false;
282 go_back_to_ack_wait_role =
false;
292 else if(!siTOE_Notif.empty() && !sDeleteEntryBySid.full()
295 siTOE_Notif.read(notif_pRrh);
299 already_waiting = sessionLength.
lookup(notif_pRrh.
sessionID, waiting_length);
307 sDeleteEntryBySid.write(notif_pRrh.
sessionID);
308 if(go_back_to_ack_wait_fmc)
312 else if(go_back_to_ack_wait_role)
319 else if(!session_reinsert.empty() && !waitingSessions.full()
320 && !go_back_to_ack_wait_fmc && !go_back_to_ack_wait_role
323 waitingSessions.write(session_reinsert.read());
326 else if(!waitingSessions.empty()
327 && !go_back_to_ack_wait_fmc && !go_back_to_ack_wait_role
334 if(!waitingSessions.full() && !sAddNewTriple_TcpRrh.full()
335 && !sMarkAsPriv.full()
341 printf(
"[TCP-RRH] adding %d to waiting sessions for session %d.\n",(
int) notif_pRrh.
tcpDatLen, (
int) notif_pRrh.
sessionID);
355 sAddNewTriple_TcpRrh.write(ne_struct);
363 waitingSessions.write(new_sess);
364 printf(
"[TCP-RRH] adding %d with %d bytes as new waiting session.\n", (
int) notif_pRrh.
sessionID, (
int) notif_pRrh.
tcpDatLen);
367 if(go_back_to_ack_wait_fmc)
371 else if(go_back_to_ack_wait_role)
380 if(!waitingSessions.empty() && !session_reinsert.full()
387 found_ID = new_data.
sessId;
389 found_fmc_sess = new_data.
fmc_con;
391 sessionLength.
lookup(found_ID, found_length);
402 if(found_length >= fmc_fifo_free_cnt)
404 need_cam_update =
true;
405 requested_length = fmc_fifo_free_cnt;
406 length_update_value = found_length - fmc_fifo_free_cnt;
408 need_cam_update =
false;
409 requested_length = found_length;
412 if(found_length >= role_fifo_free_cnt)
414 need_cam_update =
true;
415 requested_length = role_fifo_free_cnt;
416 length_update_value = found_length - role_fifo_free_cnt;
418 need_cam_update =
false;
419 requested_length = found_length;
436 else if(!soTOE_DReq.full() && !sRDp_ReqNotif.full()
437 && !session_reinsert.full()
442 sessionLength.
update(found_ID, length_update_value);
446 fmc_fifo_free_cnt = 0;
448 role_fifo_free_cnt = 0;
454 fmc_fifo_free_cnt -= requested_length;
456 role_fifo_free_cnt -= requested_length;
459 printf(
"[TCP-RRH] requesting data for #%d with length %d (FMC: %d)\n", (
int) found_ID, (
int) requested_length, (
int) found_fmc_sess);
461 soTOE_DReq.write(new_req);
462 sRDp_ReqNotif.write(new_req);
463 go_back_to_ack_wait_fmc =
false;
464 go_back_to_ack_wait_role =
false;
478 else if(!fmc_write_cnt_sig.empty())
480 PacketLen fmc_new_free = fmc_write_cnt_sig.read();
481 fmc_fifo_free_cnt += fmc_new_free;
487 printf(
"[TCP-RRH] FMC FIFO completed write of %d bytes; In total %d bytes are free in FMC FIFO.\n", (
int) fmc_new_free, (
int) fmc_fifo_free_cnt);
488 go_back_to_ack_wait_fmc =
false;
491 else if(!siTOE_Notif.empty())
494 go_back_to_ack_wait_fmc =
true;
502 else if(!role_write_cnt_sig.empty())
504 PacketLen role_new_free = role_write_cnt_sig.read();
505 role_fifo_free_cnt += role_new_free;
511 printf(
"[TCP-RRH] ROLE FIFO completed write of %d bytes; In total %d bytes are free in ROLE FIFO.\n", (
int) role_new_free, (
int) role_fifo_free_cnt);
512 go_back_to_ack_wait_role =
false;
515 else if(!siTOE_Notif.empty())
518 go_back_to_ack_wait_role =
true;
524 if(!siTOE_Notif.empty())
528 if(!waitingSessions.empty())
530 waitingSessions.read();
532 if(!session_reinsert.empty())
534 session_reinsert.read();
536 if(!fmc_write_cnt_sig.empty())
538 fmc_write_cnt_sig.read();
540 if(!role_write_cnt_sig.empty())
542 role_write_cnt_sig.read();
583 ap_uint<1> *piNTS_ready,
584 stream<TcpAppRdReq> &sRDp_ReqNotif,
585 stream<TcpAppData> &siTOE_Data,
586 stream<TcpAppMeta> &siTOE_SessId,
587 stream<NetworkWord> &soFMC_data,
588 stream<TcpSessId> &soFMC_SessId,
589 stream<NetworkWord> &soTcp_data,
590 stream<NetworkMetaStream> &soTcp_meta,
591 stream<NalConfigUpdate> &sConfigUpdate,
592 stream<Ip4Addr> &sGetNidReq_TcpRx,
593 stream<NodeId> &sGetNidRep_TcpRx,
594 stream<SessionId> &sGetTripleFromSid_Req,
595 stream<NalTriple> &sGetTripleFromSid_Rep,
596 ap_uint<32> *piMMIO_CfrmIp4Addr,
597 ap_uint<16> *piMMIO_FmcLsnPort,
600 stream<bool> &cache_inval_sig,
601 stream<NalEventNotif> &internal_event_fifo
605 #pragma HLS INLINE off
606 #pragma HLS pipeline II=1
617 static NodeId own_rank = 0;
619 static bool cache_init =
false;
620 static uint8_t evs_loop_i = 0;
623 #pragma HLS RESET variable=rdpFsmState
624 #pragma HLS RESET variable=cached_tcp_rx_triple
626 #pragma HLS RESET variable=cached_tcp_rx_session_id
627 #pragma HLS RESET variable=cached_src_id
628 #pragma HLS RESET variable=cache_init
629 #pragma HLS RESET variable=own_rank
630 #pragma HLS RESET variable=evs_loop_i
635 static bool first_word_written =
false;
642 static bool found_in_cache =
false;
645 static ap_uint<32> fmc_tcp_bytes_cnt = 0;
647 static stream<NalEventNotif> evsStreams[7];
663 fmc_tcp_bytes_cnt = 0;
667 if(!sRDp_ReqNotif.empty() )
669 sRDp_ReqNotif.read();
671 if(!siTOE_SessId.empty())
675 if(!siTOE_Data.empty())
686 else if(!cache_inval_sig.empty())
688 if(cache_inval_sig.read())
696 }
else if(!sConfigUpdate.empty())
706 else if (!sRDp_ReqNotif.empty()
707 && !sGetTripleFromSid_Req.full()
712 current_length = new_req.
length;
715 found_in_cache =
false;
716 if(cache_init && sessId == cached_tcp_rx_session_id)
718 printf(
"used TCP RX tripple and NID cache.\n");
719 triple_in = cached_tcp_rx_triple;
720 src_id = cached_src_id;
721 found_in_cache =
true;
724 sGetTripleFromSid_Req.write(sessId);
727 printf(
"[Tcp-RDP:INFO] Need to request session and node id.\n");
733 if(!sGetTripleFromSid_Rep.empty() && !sGetNidReq_TcpRx.full())
735 triple_in = sGetTripleFromSid_Rep.read();
738 if(dstPort != *piMMIO_FmcLsnPort)
740 sGetNidReq_TcpRx.write(remoteAddr);
741 printf(
"[TCP-RX:INFO] need to ask for Node ID.\n");
744 printf(
"[TCP-RX:INFO] found possible FMC connection, write to cache.\n");
747 cached_tcp_rx_session_id = sessId;
748 cached_tcp_rx_triple = triple_in;
755 if(!sGetNidRep_TcpRx.empty())
758 src_id = sGetNidRep_TcpRx.read();
760 cached_src_id = src_id;
761 cached_tcp_rx_session_id = sessId;
762 cached_tcp_rx_triple = triple_in;
772 else if(!siTOE_SessId.empty()
773 && !soTcp_meta.full() && !soFMC_SessId.full()
777 if(controll_id != sessId)
779 printf(
"[TCP-RDp:PANIC] We received data that we didn't expect...\n");
784 printf(
"NRC drops the packet...\n");
789 printf(
"tripple_in: %llu\n",(
unsigned long long) triple_in);
794 printf(
"remote Addr: %d; dstPort: %d; srcPort %d\n", (
int) remoteAddr, (
int) dstPort, (
int) srcPort);
796 if(dstPort == *piMMIO_FmcLsnPort)
798 if(remoteAddr == *piMMIO_CfrmIp4Addr)
800 printf(
"found valid FMC connection.\n");
801 session_toFMC = sessId;
802 soFMC_SessId.write(session_toFMC);
803 fmc_tcp_bytes_cnt = 0;
806 evsStreams[0].write_nb(new_ev_not);
816 evsStreams[1].write_nb(new_ev_not);
817 printf(
"unauthorized access to FMC!\n");
819 printf(
"NRC drops the packet...\n");
825 printf(
"TO ROLE: src_rank: %d\n", (
int) src_id);
832 evsStreams[2].write_nb(new_ev_not);
834 printf(
"NRC drops the packet...\n");
839 evsStreams[3].write_nb(new_ev_not);
841 evsStreams[4].write_nb(new_ev_not);
842 tmp_meta =
NetworkMeta(own_rank, dstPort, src_id, srcPort, current_length);
846 soTcp_meta.write(in_meta_tcp);
848 evsStreams[5].write_nb(new_ev_not);
857 else if (!siTOE_Data.empty() && !soTcp_data.full())
859 siTOE_Data.read(currWord);
861 soTcp_data.write(tcpWord);
874 else if (!siTOE_Data.empty()
875 && !soFMC_data.full()
878 siTOE_Data.read(currWord);
880 soFMC_data.write(tcpWord);
885 evsStreams[6].write_nb(new_ev_not);
896 else if( !siTOE_Data.empty() )
898 siTOE_Data.read(currWord);
909 if(!internal_event_fifo.full())
911 if(!evsStreams[evs_loop_i].empty())
913 internal_event_fifo.write(evsStreams[evs_loop_i].read());
932 stream<NetworkWord> &sRoleTcpDataRx_buffer,
933 stream<NetworkMetaStream> &sRoleTcpMetaRx_buffer,
934 stream<NetworkWord> &soTcp_data,
935 stream<NetworkMetaStream> &soTcp_meta,
936 stream<PacketLen> &role_write_cnt_sig
940 #pragma HLS INLINE off
941 #pragma HLS pipeline II=1
944 #pragma HLS RESET variable=deqFsmState
946 static PacketLen current_bytes_written = 0;
956 if(!role_write_cnt_sig.full())
958 role_write_cnt_sig.write(current_bytes_written);
959 current_bytes_written = 0;
964 if(!sRoleTcpDataRx_buffer.empty() && !sRoleTcpMetaRx_buffer.empty()
965 && ( (!soTcp_data.full() && !soTcp_meta.full()) ||
970 cur_word = sRoleTcpDataRx_buffer.read();
971 cur_meta = sRoleTcpMetaRx_buffer.read();
975 soTcp_data.write(cur_word);
976 soTcp_meta.write(cur_meta);
978 if(cur_word.
tlast == 0)
987 if(!sRoleTcpDataRx_buffer.empty()
988 && (!soTcp_data.full() || role_disabled)
991 cur_word = sRoleTcpDataRx_buffer.read();
995 soTcp_data.write(cur_word);
997 if(cur_word.
tlast == 1)
1013 stream<NetworkWord> &sFmcTcpDataRx_buffer,
1014 stream<TcpSessId> &sFmcTcpMetaRx_buffer,
1015 stream<NetworkWord> &soFmc_data,
1016 stream<TcpSessId> &soFmc_meta,
1017 stream<PacketLen> &fmc_write_cnt_sig
1021 #pragma HLS INLINE off
1022 #pragma HLS pipeline II=1
1025 #pragma HLS RESET variable=deqFsmState
1027 static PacketLen current_bytes_written = 0;
1036 if(!fmc_write_cnt_sig.full())
1038 fmc_write_cnt_sig.write(current_bytes_written);
1039 current_bytes_written = 0;
1044 if(!sFmcTcpDataRx_buffer.empty() && !sFmcTcpMetaRx_buffer.empty()
1045 && !soFmc_data.full() && !soFmc_meta.full()
1048 printf(
"[pFmcTcpRxDeq] Start processing FMC packet\n");
1049 cur_word = sFmcTcpDataRx_buffer.read();
1050 cur_meta = sFmcTcpMetaRx_buffer.read();
1052 soFmc_data.write(cur_word);
1053 soFmc_meta.write(cur_meta);
1054 if(cur_word.
tlast == 0)
1063 if(!sFmcTcpDataRx_buffer.empty()
1064 && !soFmc_data.full()
1067 cur_word = sFmcTcpDataRx_buffer.read();
1068 soFmc_data.write(cur_word);
1070 if(cur_word.
tlast == 1)
1106 ap_uint<1> *piNTS_ready,
1107 stream<NetworkWord> &siFMC_data,
1108 stream<TcpSessId> &siFMC_SessId,
1109 stream<NetworkWord> &siTcp_data,
1110 stream<NetworkMetaStream> &siTcp_meta,
1111 stream<TcpAppData> &soTOE_Data,
1112 stream<TcpAppMeta> &soTOE_SessId,
1113 stream<TcpDatLen> &soTOE_len,
1114 stream<NodeId> &sGetIpReq_TcpTx,
1115 stream<Ip4Addr> &sGetIpRep_TcpTx,
1116 stream<NalTriple> &sGetSidFromTriple_Req,
1117 stream<SessionId> &sGetSidFromTriple_Rep,
1118 stream<NalTriple> &sNewTcpCon_Req,
1119 stream<NalNewTcpConRep> &sNewTcpCon_Rep,
1120 stream<bool> &cache_inval_sig,
1121 stream<NalEventNotif> &internal_event_fifo
1125 #pragma HLS INLINE off
1126 #pragma HLS pipeline II=1
1137 static Ip4Addr cached_dst_ip_addr = 0x0;
1138 static bool cache_init =
false;
1140 static uint8_t evs_loop_i = 0;
1142 #pragma HLS RESET variable=wrpFsmState
1143 #pragma HLS RESET variable=cached_tcp_tx_session_id
1144 #pragma HLS RESET variable=cached_tcp_tx_triple
1145 #pragma HLS RESET variable=cached_dst_rank
1146 #pragma HLS RESET variable=cache_init
1147 #pragma HLS RESET variable=cached_dst_ip_addr
1148 #pragma HLS RESET variable=evs_loop_i
1156 static Ip4Addr dst_ip_addr = 0x0;
1157 static NrcPort src_port = 0x0;
1158 static NrcPort dst_port = 0x0;
1161 static bool streaming_mode =
false;
1163 static stream<NalEventNotif> evsStreams[10];
1171 switch (wrpFsmState)
1180 if(!siFMC_data.empty())
1184 if(!siFMC_SessId.empty())
1186 siFMC_SessId.read();
1188 if(!siTcp_data.empty())
1192 if(!siTcp_meta.empty())
1203 else if(!cache_inval_sig.empty())
1205 if(cache_inval_sig.read())
1210 cached_dst_ip_addr = 0x0;
1215 else if (!siFMC_SessId.empty()
1216 && !soTOE_SessId.full()
1220 tcpSessId = (
AppMeta) siFMC_SessId.read();
1221 soTOE_SessId.write(tcpSessId);
1222 streaming_mode =
true;
1223 tcpTX_current_packet_length = 0;
1230 printInfo(myName,
"Received new session ID #%d from [FMC].\n",
1231 tcpSessId.to_uint());
1236 else if (!siTcp_meta.empty()
1237 && !sGetIpReq_TcpTx.full()
1241 out_meta_tcp = siTcp_meta.read();
1242 tcpTX_packet_length = out_meta_tcp.
tdata.
len;
1243 tcpTX_current_packet_length = 0;
1249 evsStreams[0].write_nb(new_ev_not);
1252 printf(
"NRC drops the packet...\n");
1266 evsStreams[2].write_nb(new_ev_not);
1269 if(cache_init && dst_rank == cached_dst_rank)
1271 dst_ip_addr = cached_dst_ip_addr;
1275 sGetIpReq_TcpTx.write(dst_rank);
1284 if(!sGetIpRep_TcpTx.empty())
1286 dst_ip_addr = sGetIpRep_TcpTx.read();
1294 !sGetSidFromTriple_Req.full())
1298 if(dst_ip_addr == 0)
1301 evsStreams[1].write_nb(new_ev_not);
1304 printf(
"NRC drops the packet...\n");
1309 new_triple =
newTriple(dst_ip_addr, dst_port, src_port);
1310 printf(
"From ROLE: remote Addr: %d; dstPort: %d; srcPort %d; (rank: %d)\n", (
int) dst_ip_addr, (
int) dst_port, (
int) src_port, (
int) dst_rank);
1312 if(cache_init && new_triple == cached_tcp_tx_triple)
1314 printf(
"used TCP TX tripple chache.\n");
1315 sessId = cached_tcp_tx_session_id;
1319 sGetSidFromTriple_Req.write(new_triple);
1328 if(!sGetSidFromTriple_Rep.empty())
1330 sessId = sGetSidFromTriple_Rep.read();
1331 cached_tcp_tx_triple = new_triple;
1332 cached_tcp_tx_session_id = sessId;
1333 cached_dst_ip_addr = dst_ip_addr;
1334 cached_dst_rank = dst_rank;
1345 else if(!soTOE_SessId.full() && !sNewTcpCon_Req.full() && !soTOE_len.full() )
1349 printf(
"session id found: %d\n", (
int) sessId);
1352 sNewTcpCon_Req.write(new_triple);
1355 printf(
"requesting new connection.\n");
1359 evsStreams[3].write_nb(new_ev_not);
1361 evsStreams[4].write_nb(new_ev_not);
1363 evsStreams[5].write_nb(new_ev_not);
1365 soTOE_SessId.write(sessId);
1366 tcpTX_current_packet_length = 0;
1367 if(tcpTX_packet_length == 0)
1369 streaming_mode =
true;
1371 streaming_mode =
false;
1372 soTOE_len.write(tcpTX_packet_length);
1375 printInfo(myName,
"Received new session ID #%d from [ROLE] with length %d.\n",
1376 sessId.to_uint(), tcpTX_packet_length.to_uint());
1387 else if( !soTOE_SessId.full() && !sNewTcpCon_Rep.empty() && !soTOE_len.full() )
1393 evsStreams[6].write_nb(new_ev_not);
1397 printf(
"NRC drops the packet...\n");
1404 evsStreams[7].write_nb(new_ev_not);
1406 evsStreams[8].write_nb(new_ev_not);
1408 evsStreams[9].write_nb(new_ev_not);
1410 soTOE_SessId.write(sessId);
1411 tcpTX_current_packet_length = 0;
1412 if(tcpTX_packet_length == 0)
1414 streaming_mode =
true;
1416 streaming_mode =
false;
1417 soTOE_len.write(tcpTX_packet_length);
1420 printInfo(myName,
"Received new session ID #%d from [ROLE].\n",
1424 cached_tcp_tx_triple = new_triple;
1425 cached_tcp_tx_session_id = sessId;
1426 cached_dst_ip_addr = dst_ip_addr;
1427 cached_dst_rank = dst_rank;
1438 else if (!siFMC_data.empty() && !soTOE_Data.full() && !soTOE_len.full() )
1443 soTOE_Data.write(tcpWord);
1446 soTOE_len.write(tcpTX_current_packet_length);
1451 soTOE_len.write(tcpTX_current_packet_length);
1452 tcpTX_current_packet_length = 0;
1463 else if (!siTcp_data.empty() && !soTOE_Data.full() && !soTOE_len.full() )
1469 currWordIn.
tlast = 0;
1471 printf(
"streaming from ROLE to TOE: tcpTX_packet_length: %d, tcpTX_current_packet_length: %d \n", (
int) tcpTX_packet_length, (
int) tcpTX_current_packet_length);
1472 if(!streaming_mode && tcpTX_current_packet_length >= tcpTX_packet_length)
1474 currWordIn.
tlast = 1;
1476 if(currWordIn.
tlast == 1)
1481 soTOE_len.write(tcpTX_current_packet_length);
1484 else if (streaming_mode)
1488 soTOE_len.write(tcpTX_current_packet_length);
1489 tcpTX_current_packet_length = 0;
1490 currWordIn.
tlast = 1;
1494 soTOE_Data.write(currWordOutTmp);
1503 else if( !siTcp_data.empty())
1508 if( (tcpTX_packet_length > 0 && tcpTX_current_packet_length >= tcpTX_packet_length)
1509 || (currWordIn.
tlast == 1)
1519 if(!internal_event_fifo.full()
1522 if(!evsStreams[evs_loop_i].empty())
1524 internal_event_fifo.write(evsStreams[evs_loop_i].read());
1527 if(evs_loop_i >= 10)
1554 ap_uint<1> *piNTS_ready,
1555 stream<TcpAppData> &siWrp_Data,
1556 stream<TcpAppMeta> &siWrp_SessId,
1557 stream<TcpDatLen> &siWrp_len,
1558 stream<TcpAppData> &soTOE_Data,
1559 stream<TcpAppSndReq> &soTOE_SndReq,
1560 stream<TcpAppSndRep> &siTOE_SndRep
1564 #pragma HLS INLINE off
1565 #pragma HLS pipeline II=1
1571 static uint16_t dequeue_cnt = 0;
1574 #pragma HLS RESET variable=wbuState
1575 #pragma HLS RESET variable=dequeue_cnt
1580 static TcpDatLen current_requested_length = 0;
1581 static TcpDatLen current_approved_length = 0;
1582 static bool need_to_request_again =
false;
1597 else if(!siWrp_SessId.empty() && !siWrp_len.empty())
1600 current_sessId = siWrp_SessId.read();
1603 current_requested_length = new_len;
1613 else if(!soTOE_SndReq.full())
1615 toe_sendReq.
sessId = current_sessId;
1616 toe_sendReq.
length = current_requested_length;
1617 soTOE_SndReq.write(toe_sendReq);
1620 printInfo(myName,
"Received a data forward request from [NAL/WRP] for sessId=%d and nrBytes=%d (repeating request %d).\n",
1621 toe_sendReq.
sessId.to_uint(), toe_sendReq.
length.to_uint(), (
int) need_to_request_again);
1631 else if(!siTOE_SndRep.empty())
1635 switch (appSndRep.
error) {
1638 current_approved_length = current_requested_length;
1639 need_to_request_again =
false;
1643 printWarn(myName,
"Not enough space for writing %d bytes in the Tx buffer of session #%d. Available space is %d bytes.\n",
1647 current_approved_length = appSndRep.
spaceLeft - 7;
1648 need_to_request_again =
true;
1653 printWarn(myName,
"Attempt to write data for a session that is not established.\n");
1656 dequeue_cnt = current_requested_length;
1661 printWarn(myName,
"Received unknown TCP request to send reply from [TOE].\n");
1663 dequeue_cnt = current_requested_length;
1676 else if(!soTOE_Data.full() && !siWrp_Data.empty() )
1680 if(dequeue_cnt >= current_approved_length)
1683 if(need_to_request_again)
1685 current_requested_length -= dequeue_cnt;
1690 printInfo(myName,
"Done with packet (#%d, %d)\n",
1691 current_sessId.to_uint(), current_requested_length.to_uint());
1696 soTOE_Data.write(
tmp);
1701 if(!siWrp_Data.empty())
1704 if(
tmp.getTLast() == 1)
1710 if(dequeue_cnt == 0)
1721 if(!siWrp_Data.empty())
1725 if(!siWrp_SessId.empty())
1727 siWrp_SessId.read();
1729 if(!siWrp_len.empty())
1752 stream<TcpAppOpnReq> &soTOE_OpnReq,
1753 stream<TcpAppOpnRep> &siTOE_OpnRep,
1754 stream<NalNewTableEntry> &sAddNewTriple_TcpCon,
1755 stream<NalTriple> &sNewTcpCon_Req,
1756 stream<NalNewTcpConRep> &sNewTcpCon_Rep
1760 #pragma HLS INLINE off
1761 #pragma HLS pipeline II=1
1773 static ap_uint<16> startupDelay = 0x8000;
1775 static ap_uint<16> startupDelay = 30;
1778 #pragma HLS RESET variable=opnFsmState
1779 #pragma HLS RESET variable=startupDelay
1781 static ap_uint<32> watchDogTimer_pcon = 0;
1783 static NalTriple triple_for_new_connection = 0x0;
1789 switch (opnFsmState)
1793 if (startupDelay > 0)
1810 if (!sNewTcpCon_Req.empty() && !soTOE_OpnReq.full())
1812 triple_for_new_connection = sNewTcpCon_Req.read();
1816 SockAddr hostSockAddr(remoteIp, remotePort);
1817 HostSockAddr.
addr = hostSockAddr.
addr;
1818 HostSockAddr.
port = hostSockAddr.
port;
1819 soTOE_OpnReq.write(HostSockAddr);
1821 printInfo(myName,
"Client is requesting to connect to remote socket:\n");
1824 #ifndef __SYNTHESIS__
1825 watchDogTimer_pcon = 10;
1834 if(!sAddNewTriple_TcpCon.full() && !sNewTcpCon_Rep.full())
1836 watchDogTimer_pcon--;
1837 if (!siTOE_OpnRep.empty())
1840 siTOE_OpnRep.read(newConn);
1843 printInfo(myName,
"Client successfully connected to remote socket:\n");
1847 sAddNewTriple_TcpCon.write(ne_struct);
1850 sNewTcpCon_Rep.write(con_rep);
1853 printError(myName,
"Client failed to connect to remote socket:\n");
1857 sNewTcpCon_Rep.write(con_rep);
1861 if (watchDogTimer_pcon == 0) {
1863 printError(myName,
"Timeout: Failed to connect to the following remote socket:\n");
1869 sNewTcpCon_Rep.write(con_rep);
1893 stream<TcpAppClsReq> &soTOE_ClsReq,
1894 stream<bool> &sGetNextDelRow_Req,
1895 stream<SessionId> &sGetNextDelRow_Rep,
1896 stream<bool> &sStartTclCls
1900 #pragma HLS INLINE off
1901 #pragma HLS pipeline II=1
1910 #pragma HLS RESET variable=clsFsmState_Tcp
1914 switch (clsFsmState_Tcp) {
1918 if(!sStartTclCls.empty())
1920 if(sStartTclCls.read())
1927 if(!sGetNextDelRow_Req.full())
1929 sGetNextDelRow_Req.write(
true);
1934 if(!soTOE_ClsReq.full() && !sGetNextDelRow_Rep.empty())
1936 SessionId nextToDelete = sGetNextDelRow_Rep.read();
1939 soTOE_ClsReq.write(nextToDelete);
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
#define UNUSED_SESSION_ENTRY_VALUE
NalTriple newTriple(Ip4Addr ipRemoteAddres, TcpPort tcpRemotePort, TcpPort tcpLocalPort)
void pFmcTcpRxDeq(stream< NetworkWord > &sFmcTcpDataRx_buffer, stream< TcpSessId > &sFmcTcpMetaRx_buffer, stream< NetworkWord > &soFmc_data, stream< TcpSessId > &soFmc_meta, stream< PacketLen > &fmc_write_cnt_sig)
Terminates the internal TCP RX FIFOs and forwards packets to the FMC.
void pTcpLsn(stream< TcpAppLsnReq > &soTOE_LsnReq, stream< TcpAppLsnRep > &siTOE_LsnRep, stream< TcpPort > &sTcpPortsToOpen, stream< bool > &sTcpPortsOpenFeedback)
Request the TOE to start listening (LSn) for incoming connections on a specific port (....
void pTcpWRp(ap_uint< 1 > *layer_4_enabled, ap_uint< 1 > *piNTS_ready, stream< NetworkWord > &siFMC_data, stream< TcpSessId > &siFMC_SessId, stream< NetworkWord > &siTcp_data, stream< NetworkMetaStream > &siTcp_meta, stream< TcpAppData > &soTOE_Data, stream< TcpAppMeta > &soTOE_SessId, stream< TcpDatLen > &soTOE_len, stream< NodeId > &sGetIpReq_TcpTx, stream< Ip4Addr > &sGetIpRep_TcpTx, stream< NalTriple > &sGetSidFromTriple_Req, stream< SessionId > &sGetSidFromTriple_Rep, stream< NalTriple > &sNewTcpCon_Req, stream< NalNewTcpConRep > &sNewTcpCon_Rep, stream< bool > &cache_inval_sig, stream< NalEventNotif > &internal_event_fifo)
Write Path (WRp) - From ROLE or FMC to TOE. Process waits for a new data segment to write and forward...
void pTcpCOn(stream< TcpAppOpnReq > &soTOE_OpnReq, stream< TcpAppOpnRep > &siTOE_OpnRep, stream< NalNewTableEntry > &sAddNewTriple_TcpCon, stream< NalTriple > &sNewTcpCon_Req, stream< NalNewTcpConRep > &sNewTcpCon_Rep)
Client connection to remote HOST or FPGA socket (COn).
#define UNUSED_TABLE_ENTRY_VALUE
void pTcpRxNotifEnq(ap_uint< 1 > *layer_4_enabled, ap_uint< 1 > *piNTS_ready, stream< TcpAppNotif > &siTOE_Notif, stream< TcpAppNotif > &sTcpNotif_buffer)
Enqueus the incoming notificiations from TOE into the internal buffer.
uint8_t extractByteCnt(AxisRaw currWord)
TcpPort getLocalPortFromTriple(NalTriple triple)
void pTcpWBu(ap_uint< 1 > *layer_4_enabled, ap_uint< 1 > *piNTS_ready, stream< TcpAppData > &siWrp_Data, stream< TcpAppMeta > &siWrp_SessId, stream< TcpDatLen > &siWrp_len, stream< TcpAppData > &soTOE_Data, stream< TcpAppSndReq > &soTOE_SndReq, stream< TcpAppSndRep > &siTOE_SndRep)
Write Buffer (WBu) - From WRp to TOE. Process to synchronize with TOE's TX buffer (and it's available...
void pRoleTcpRxDeq(ap_uint< 1 > *layer_7_enabled, ap_uint< 1 > *role_decoupled, stream< NetworkWord > &sRoleTcpDataRx_buffer, stream< NetworkMetaStream > &sRoleTcpMetaRx_buffer, stream< NetworkWord > &soTcp_data, stream< NetworkMetaStream > &soTcp_meta, stream< PacketLen > &role_write_cnt_sig)
Terminates the internal TCP RX FIFOs and forwards packets to the Role.
Ip4Addr getRemoteIpAddrFromTriple(NalTriple triple)
void pTcpRRh(ap_uint< 1 > *layer_4_enabled, ap_uint< 1 > *piNTS_ready, ap_uint< 32 > *piMMIO_CfrmIp4Addr, ap_uint< 16 > *piMMIO_FmcLsnPort, stream< TcpAppNotif > &siTOE_Notif, stream< TcpAppRdReq > &soTOE_DReq, stream< NalNewTableEntry > &sAddNewTriple_TcpRrh, stream< SessionId > &sMarkAsPriv, stream< SessionId > &sDeleteEntryBySid, stream< TcpAppRdReq > &sRDp_ReqNotif, stream< PacketLen > &fmc_write_cnt_sig, stream< PacketLen > &role_write_cnt_sig)
ReadRequestHandler (RRh). Waits for a notification indicating the availability of new data for the RO...
void pTcpCls(stream< TcpAppClsReq > &soTOE_ClsReq, stream< bool > &sGetNextDelRow_Req, stream< SessionId > &sGetNextDelRow_Rep, stream< bool > &sStartTclCls)
Asks the TOE to close Tcp connections, based on the request from pPortLogic.
TcpPort getRemotePortFromTriple(NalTriple triple)
#define NAL_CONNECTION_TIMEOUT
ap_uint< 1 > role_decoupled
#define NAL_CONFIG_OWN_RANK
void pTcpRDp(ap_uint< 1 > *layer_4_enabled, ap_uint< 1 > *piNTS_ready, stream< TcpAppRdReq > &sRDp_ReqNotif, stream< TcpAppData > &siTOE_Data, stream< TcpAppMeta > &siTOE_SessId, stream< NetworkWord > &soFMC_data, stream< TcpSessId > &soFMC_SessId, stream< NetworkWord > &soTcp_data, stream< NetworkMetaStream > &soTcp_meta, stream< NalConfigUpdate > &sConfigUpdate, stream< Ip4Addr > &sGetNidReq_TcpRx, stream< NodeId > &sGetNidRep_TcpRx, stream< SessionId > &sGetTripleFromSid_Req, stream< NalTriple > &sGetTripleFromSid_Rep, ap_uint< 32 > *piMMIO_CfrmIp4Addr, ap_uint< 16 > *piMMIO_FmcLsnPort, ap_uint< 1 > *layer_7_enabled, ap_uint< 1 > *role_decoupled, stream< bool > &cache_inval_sig, stream< NalEventNotif > &internal_event_fifo)
Read Path (RDp) - From TOE to ROLE or FMC. Process waits for a new data segment to read and forwards ...
#define NAL_MAX_FIFO_DEPTHS_BYTES
#define NAL_STREAMING_SPLIT_TCP
#define INVALID_MRT_VALUE
#define printError(callerName, format,...)
A macro to print an error message.
void printSockAddr(const char *callerName, SockAddr sockAddr)
Print a socket address.
#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 > NetworkDataLength
bool update(K key, V value)
Search the CAM array for a key and updates the corresponding value.
bool lookup(K key, V &value)
Search the CAM array for a key.
bool deleteEntry(K key)
Remove a key-value pair from the CAM array.
bool insert(KeyValuePair< K, V > kVP)
Insert a new key-value pair in the CAM array.
void reset()
Invalidate all entries of the CAM array.
ap_uint< 16 > config_addr
ap_uint< 32 > update_value
: The TCP Sub System (TSS) of the NAL core.