82 stream<NalConfigUpdate> &sToPortLogic,
83 stream<NalConfigUpdate> &sToUdpRx,
84 stream<NalConfigUpdate> &sToTcpRx,
85 stream<NalConfigUpdate> &sToStatusProc,
86 stream<NalMrtUpdate> &sMrtUpdate,
88 stream<uint32_t> &mrt_version_update_0,
89 stream<uint32_t> &mrt_version_update_1,
90 stream<NalStatusUpdate> &sStatusUpdate
94 #pragma HLS INLINE off
98 static uint16_t tableCopyVariable = 0;
102 static uint32_t processed_mrt_version = 0;
105 #pragma HLS reset variable=tableCopyVariable
106 #pragma HLS reset variable=tables_initialized
107 #pragma HLS reset variable=a4lFsm
108 #pragma HLS reset variable=cbFsm
109 #pragma HLS reset variable=processed_mrt_version
110 #pragma HLS reset variable=mbFsm
116 static ap_uint<16> configProp = 0x0;
118 static ap_uint<32> new_word;
131 uint32_t new_mrt_version;
132 ap_uint<32> new_ip4node;
177 if(!sStatusUpdate.empty())
182 printf(
"[A4l] got status update for address %d with value %d\n", (
int) su.
status_addr, (
int) su.
new_value);
192 new_word =
ctrlLink[tableCopyVariable];
193 if(new_word != config[tableCopyVariable])
204 tableCopyVariable = 0;
210 printf(
"[A4l] waiting CB broadcast\n");
213 config[tableCopyVariable] = new_word;
217 tableCopyVariable = 0;
227 if (new_ip4node != localMRT[tableCopyVariable])
230 sMrtUpdate.write(mu);
231 localMRT[tableCopyVariable] = new_ip4node;
232 printf(
"[A4l] update MRT at %d with %d\n", tableCopyVariable, (
int) new_ip4node);
234 sMrtUpdate.write(mrt_update);
239 tableCopyVariable = 0;
253 tableCopyVariable = 0;
256 if(new_mrt_version != processed_mrt_version)
258 printf(
"\t\t\t[A4L:CtrlLink:Info] Acknowledged MRT version %d.\n", (
int) new_mrt_version);
260 processed_mrt_version = new_mrt_version;
265 printf(
"[A4l] SubFSMs state mb: %d; cb: %d\n", (
int) mbFsm, (
int) cbFsm);
269 printf(
"[A4l] SubFSMs done...continue\n");
284 switch (configProp) {
297 printf(
"[A4l] Issued rank update: %d\n", (
int) cu.
update_value);
310 if(!sToPortLogic.full())
312 sToPortLogic.write(cu_toCB);
319 sToUdpRx.write(cu_toCB);
326 sToTcpRx.write(cu_toCB);
331 if(!sToStatusProc.full())
333 sToStatusProc.write(cu_toCB);
349 printf(
"[A4l] Issued Mrt update: %d\n", (
int) processed_mrt_version);
352 if(!mrt_version_update_0.full())
354 mrt_version_update_0.write(processed_mrt_version);
359 if(!mrt_version_update_1.full())
361 mrt_version_update_1.write(processed_mrt_version);
387 stream<NalMrtUpdate> &sMrtUpdate,
389 stream<NodeId> &sGetIpReq_UdpTx,
390 stream<Ip4Addr> &sGetIpRep_UdpTx,
391 stream<NodeId> &sGetIpReq_TcpTx,
392 stream<Ip4Addr> &sGetIpRep_TcpTx,
393 stream<Ip4Addr> &sGetNidReq_UdpRx,
394 stream<NodeId> &sGetNidRep_UdpRx,
395 stream<Ip4Addr> &sGetNidReq_TcpRx,
396 stream<NodeId> &sGetNidRep_TcpRx
402 #pragma HLS INLINE off
403 #pragma HLS pipeline II=1
426 #pragma HLS ARRAY_PARTITION variable=localMRT complete dim=1
440 if( !sMrtUpdate.empty() )
448 }
else if( !sGetIpReq_UdpTx.empty() && !sGetIpRep_UdpTx.full())
451 rank = sGetIpReq_UdpTx.read();
458 rep = localMRT[rank];
460 sGetIpRep_UdpTx.write(rep);
462 else if( !sGetIpReq_TcpTx.empty() && !sGetIpRep_TcpTx.full())
465 rank = sGetIpReq_TcpTx.read();
472 rep = localMRT[rank];
474 sGetIpRep_TcpTx.write(rep);
476 else if( !sGetNidReq_UdpRx.empty() && !sGetNidRep_UdpRx.full())
478 ap_uint<32> ipAddr = sGetNidReq_UdpRx.read();
479 printf(
"[HSS-INFO] Searching for Node ID of IP %d.\n", (
int) ipAddr);
483 #pragma HLS unroll factor=8
484 if(localMRT[i] == ipAddr)
490 printf(
"[HSS-INFO] found Node Id %d.\n", (
int) rep);
491 sGetNidRep_UdpRx.write(rep);
493 else if( !sGetNidReq_TcpRx.empty() && !sGetNidRep_TcpRx.full())
495 ap_uint<32> ipAddr = sGetNidReq_TcpRx.read();
496 printf(
"[HSS-INFO] Searching for Node ID of IP %d.\n", (
int) ipAddr);
500 #pragma HLS unroll factor=8
501 if(localMRT[i] == ipAddr)
507 printf(
"[HSS-INFO] found Node Id %d.\n", (
int) rep);
508 sGetNidRep_TcpRx.write(rep);
549 ap_uint<1> *piNTS_ready,
550 ap_uint<16> *piMMIO_FmcLsnPort,
551 ap_uint<32> *pi_udp_rx_ports,
552 ap_uint<32> *pi_tcp_rx_ports,
553 stream<NalConfigUpdate> &sConfigUpdate,
554 stream<UdpPort> &sUdpPortsToOpen,
555 stream<UdpPort> &sUdpPortsToClose,
556 stream<TcpPort> &sTcpPortsToOpen,
557 stream<bool> &sUdpPortsOpenFeedback,
558 stream<bool> &sTcpPortsOpenFeedback,
559 stream<bool> &sMarkToDel_unpriv,
560 stream<NalPortUpdate> &sPortUpdate,
561 stream<bool> &sStartTclCls
565 #pragma HLS INLINE off
566 #pragma HLS pipeline II=1
569 static ap_uint<16> processed_FMC_listen_port = 0;
570 static ap_uint<32> tcp_rx_ports_processed = 0;
571 static ap_uint<32> udp_rx_ports_processed = 0;
574 #ifndef __SYNTHESIS__
575 static ap_uint<16> mmio_stabilize_counter = 1;
581 #pragma HLS reset variable=mmio_stabilize_counter
582 #pragma HLS reset variable=processed_FMC_listen_port
583 #pragma HLS reset variable=udp_rx_ports_processed
584 #pragma HLS reset variable=tcp_rx_ports_processed
585 #pragma HLS reset variable=port_fsm
588 static ap_uint<16> new_relative_port_to_req_udp;
589 static ap_uint<16> new_relative_port_to_req_tcp;
590 static ap_uint<16> current_requested_port;
599 if(mmio_stabilize_counter > 0)
601 mmio_stabilize_counter--;
607 if(!sConfigUpdate.empty())
616 if(processed_FMC_listen_port == 0)
618 processed_FMC_listen_port = (ap_uint<16>) ca.
update_value;
622 if(udp_rx_ports_processed == 0)
628 if(tcp_rx_ports_processed == 0)
634 printf(
"[ERROR] invalid config update received!\n");
641 }
else if(processed_FMC_listen_port != *piMMIO_FmcLsnPort)
649 if(udp_rx_ports_processed != *pi_udp_rx_ports)
653 else if(tcp_rx_ports_processed != *pi_tcp_rx_ports)
660 if(!sPortUpdate.full()
661 && (processed_FMC_listen_port != 0 || udp_rx_ports_processed != 0 || tcp_rx_ports_processed !=0 )
664 if(processed_FMC_listen_port != 0)
667 processed_FMC_listen_port = 0;
669 else if(udp_rx_ports_processed != 0)
672 udp_rx_ports_processed = 0;
674 else if(tcp_rx_ports_processed != 0)
677 tcp_rx_ports_processed = 0;
684 processed_FMC_listen_port = 0x0;
685 udp_rx_ports_processed = 0x0;
686 tcp_rx_ports_processed = 0x0;
694 if(udp_rx_ports_processed > 0)
697 }
else if(tcp_rx_ports_processed > 0)
709 if(!sUdpPortsToClose.full())
713 ap_uint<16> newRelativePortToClose = 0;
714 ap_uint<16> newAbsolutePortToClose = 0;
715 if(udp_rx_ports_processed != 0)
719 sUdpPortsToClose.write(newAbsolutePortToClose);
720 ap_uint<32> one_cold_closed_port = ~(((ap_uint<32>) 1) << (newRelativePortToClose));
721 udp_rx_ports_processed &= one_cold_closed_port;
722 printf(
"new UDP port ports to close: %#04x\n",(
unsigned int) udp_rx_ports_processed);
724 if(udp_rx_ports_processed == 0)
736 if(!sMarkToDel_unpriv.full())
738 sMarkToDel_unpriv.write(
true);
754 if(!sStartTclCls.full())
756 sStartTclCls.write(
true);
757 tcp_rx_ports_processed = 0x0;
764 if(!sTcpPortsToOpen.full())
766 printf(
"Need FMC port request: %#02x\n",(
unsigned int) *piMMIO_FmcLsnPort);
767 sTcpPortsToOpen.write(*piMMIO_FmcLsnPort);
768 current_requested_port = *piMMIO_FmcLsnPort;
773 if(!sTcpPortsOpenFeedback.empty())
775 bool fed = sTcpPortsOpenFeedback.read();
778 processed_FMC_listen_port = current_requested_port;
779 printf(
"FMC Port opened: %#03x\n",(
int) processed_FMC_listen_port);
781 printf(
"[ERROR] FMC TCP port opening failed.\n");
789 if(!sUdpPortsToOpen.full())
791 ap_uint<32>
tmp = udp_rx_ports_processed | *pi_udp_rx_ports;
792 ap_uint<32> diff = udp_rx_ports_processed ^
tmp;
795 printf(
"UDP port diff: %#04x\n",(
unsigned int) diff);
800 sUdpPortsToOpen.write(new_port_to_open);
803 udp_rx_ports_processed = *pi_udp_rx_ports;
809 if(!sUdpPortsOpenFeedback.empty())
811 bool fed = sUdpPortsOpenFeedback.read();
814 udp_rx_ports_processed |= ((ap_uint<32>) 1) << (new_relative_port_to_req_udp);
815 printf(
"new udp_rx_ports_processed: %#03x\n",(
int) udp_rx_ports_processed);
817 printf(
"[ERROR] UDP port opening failed.\n");
826 if( !sTcpPortsToOpen.full() )
828 ap_uint<32>
tmp = tcp_rx_ports_processed | *pi_tcp_rx_ports;
829 ap_uint<32> diff = tcp_rx_ports_processed ^
tmp;
832 printf(
"TCP port diff: %#04x\n",(
unsigned int) diff);
837 sTcpPortsToOpen.write(new_port);
840 tcp_rx_ports_processed = *pi_tcp_rx_ports;
846 if(!sTcpPortsOpenFeedback.empty())
848 bool fed = sTcpPortsOpenFeedback.read();
851 tcp_rx_ports_processed |= ((ap_uint<32>) 1) << (new_relative_port_to_req_tcp);
852 printf(
"new tcp_rx_ports_processed: %#03x\n",(
int) tcp_rx_ports_processed);
854 printf(
"[ERROR] TCP port opening failed.\n");
863 if(!sPortUpdate.full())
865 sPortUpdate.write(current_port_update);
893 ap_uint<1> *piNTS_ready,
894 stream<uint32_t> &mrt_version_update,
895 stream<bool> &inval_del_sig,
896 stream<bool> &cache_inval_0,
897 stream<bool> &cache_inval_1,
898 stream<bool> &cache_inval_2,
899 stream<bool> &cache_inval_3
903 #pragma HLS INLINE off
904 #pragma HLS pipeline II=1
908 static uint32_t mrt_version_current = 0;
910 #pragma HLS RESET variable=cache_fsm
911 #pragma HLS RESET variable=mrt_version_current
914 static ap_uint<1> role_state;
939 printf(
"[pCacheInvalDetection] Detected cache invalidation condition!\n");
944 }
else if(!mrt_version_update.empty())
946 uint32_t
tmp = mrt_version_update.read();
947 if(
tmp != mrt_version_current)
949 mrt_version_current =
tmp;
952 }
else if(!inval_del_sig.empty())
954 bool sig = inval_del_sig.read();
965 if(!cache_inval_0.full())
967 cache_inval_0.write(
true);
973 if(!cache_inval_1.full())
975 cache_inval_1.write(
true);
981 if(!cache_inval_2.full())
983 cache_inval_2.write(
true);
989 if(!cache_inval_3.full())
991 cache_inval_3.write(
true);
1018 stream<SessionId> &sGetTripleFromSid_Req,
1019 stream<NalTriple> &sGetTripleFromSid_Rep,
1020 stream<NalTriple> &sGetSidFromTriple_Req,
1021 stream<SessionId> &sGetSidFromTriple_Rep,
1022 stream<NalNewTableEntry> &sAddNewTriple_TcpRrh,
1023 stream<NalNewTableEntry> &sAddNewTriple_TcpCon,
1024 stream<SessionId> &sDeleteEntryBySid,
1025 stream<bool> &inval_del_sig,
1026 stream<SessionId> &sMarkAsPriv,
1027 stream<bool> &sMarkToDel_unpriv,
1028 stream<bool> &sGetNextDelRow_Req,
1029 stream<SessionId> &sGetNextDelRow_Rep
1033 #pragma HLS INLINE off
1034 #pragma HLS pipeline II=1
1041 #pragma HLS RESET variable=tables_initialized
1049 #pragma HLS ARRAY_PARTITION variable=tripleList complete dim=1
1050 #pragma HLS ARRAY_PARTITION variable=sessionIdList complete dim=1
1051 #pragma HLS ARRAY_PARTITION variable=usedRows complete dim=1
1052 #pragma HLS ARRAY_PARTITION variable=rowsToDelete complete dim=1
1053 #pragma HLS ARRAY_PARTITION variable=privilegedRows complete dim=1
1060 printf(
"init tables...\n");
1064 sessionIdList[i] = 0;
1067 rowsToDelete[i] = 0;
1068 privilegedRows[i] = 0;
1076 if(!sGetTripleFromSid_Req.empty() && !sGetTripleFromSid_Rep.full())
1078 SessionId sessionID = sGetTripleFromSid_Req.read();
1079 printf(
"searching for session: %d\n", (
int) sessionID);
1082 bool found_smth =
false;
1086 if(sessionIdList[i] == sessionID && usedRows[i] == 1 && rowsToDelete[i] == 0)
1088 ret = tripleList[i];
1089 printf(
"found triple entry: %d | %d | %llu\n",(
int) i, (
int) sessionID, (
unsigned long long)
ret);
1097 printf(
"[TcpAgency:INFO] Unknown session requested\n");
1099 sGetTripleFromSid_Rep.write(
ret);
1100 }
else if(!sGetSidFromTriple_Req.empty() && !sGetSidFromTriple_Rep.full())
1102 NalTriple triple = sGetSidFromTriple_Req.read();
1103 printf(
"Searching for triple: %llu\n", (
unsigned long long) triple);
1106 bool found_smth =
false;
1110 if(tripleList[i] == triple && usedRows[i] == 1 && rowsToDelete[i] == 0)
1112 ret = sessionIdList[i];
1120 printf(
"[TcpAgency:INFO] Unknown triple requested\n");
1122 sGetSidFromTriple_Rep.write(
ret);
1127 if(!sAddNewTriple_TcpRrh.empty() || !sAddNewTriple_TcpCon.empty())
1130 if(!sAddNewTriple_TcpRrh.empty())
1132 ne_struct = sAddNewTriple_TcpRrh.read();
1134 ne_struct = sAddNewTriple_TcpCon.read();
1138 printf(
"new tripple entry: %d | %llu\n",(
int) sessionID, (
unsigned long long) new_entry);
1143 bool found_smth =
false;
1147 if(sessionIdList[i] == sessionID && usedRows[i] == 1 && rowsToDelete[i] == 0)
1149 ret = tripleList[i];
1150 printf(
"found triple entry: %d | %d | %llu\n",(
int) i, (
int) sessionID, (
unsigned long long)
ret);
1157 printf(
"session/triple already known, skipping. \n");
1160 bool stored =
false;
1165 if(usedRows[i] == 0)
1167 sessionIdList[i] = sessionID;
1168 tripleList[i] = new_entry;
1170 privilegedRows[i] = 0;
1171 printf(
"stored triple entry: %d | %d | %llu\n",(
int) i, (
int) sessionID, (
unsigned long long) new_entry);
1180 printf(
"[TcpAgency:ERROR] no free space left in table!\n");
1183 }
else if(!sDeleteEntryBySid.empty() && !inval_del_sig.full())
1185 SessionId sessionID = sDeleteEntryBySid.read();
1186 printf(
"try to delete session: %d\n", (
int) sessionID);
1190 if(sessionIdList[i] == sessionID && usedRows[i] == 1)
1193 privilegedRows[i] = 0;
1194 printf(
"found and deleting session: %d\n", (
int) sessionID);
1196 inval_del_sig.write(
true);
1201 }
else if(!sMarkAsPriv.empty())
1203 SessionId sessionID = sMarkAsPriv.read();
1204 printf(
"mark session as privileged: %d\n", (
int) sessionID);
1208 if(sessionIdList[i] == sessionID && usedRows[i] == 1)
1210 privilegedRows[i] = 1;
1211 rowsToDelete[i] = 0;
1216 }
else if(!sMarkToDel_unpriv.empty())
1218 if(sMarkToDel_unpriv.read())
1223 if(privilegedRows[i] == 1)
1227 rowsToDelete[i] = usedRows[i];
1231 }
else if(!sGetNextDelRow_Req.empty() && !sGetNextDelRow_Rep.full())
1233 if(sGetNextDelRow_Req.read())
1236 bool found_smth =
false;
1240 if(rowsToDelete[i] == 1)
1242 ret = sessionIdList[i];
1246 rowsToDelete[i] = 0;
1248 printf(
"Closing session %d at table row %d.\n",(
int)
ret, (
int) i);
1256 printf(
"TCP tables are empty\n");
1258 sGetNextDelRow_Rep.write(
ret);
ap_uint< 1 > layer_7_enabled
ap_uint< 1 > layer_4_enabled
#define UNUSED_SESSION_ENTRY_VALUE
#define NUMBER_CONFIG_WORDS
uint8_t selectConfigUpdatePropagation(uint16_t config_addr)
void axi4liteProcessing(ap_uint< 32 > ctrlLink[64+16+16], stream< NalConfigUpdate > &sToPortLogic, stream< NalConfigUpdate > &sToUdpRx, stream< NalConfigUpdate > &sToTcpRx, stream< NalConfigUpdate > &sToStatusProc, stream< NalMrtUpdate > &sMrtUpdate, stream< uint32_t > &mrt_version_update_0, stream< uint32_t > &mrt_version_update_1, stream< NalStatusUpdate > &sStatusUpdate)
Contains the Axi4 Lite secondary endpoint and reads the MRT and configuration values from it as well ...
#define NUMBER_STATUS_WORDS
#define NAL_CONFIG_SAVED_FMC_PORTS
void pCacheInvalDetection(ap_uint< 1 > *layer_4_enabled, ap_uint< 1 > *layer_7_enabled, ap_uint< 1 > *role_decoupled, ap_uint< 1 > *piNTS_ready, stream< uint32_t > &mrt_version_update, stream< bool > &inval_del_sig, stream< bool > &cache_inval_0, stream< bool > &cache_inval_1, stream< bool > &cache_inval_2, stream< bool > &cache_inval_3)
Detects if the caches of the USS and TSS have to be invalidated and signals this to the concerned pro...
#define UNUSED_TABLE_ENTRY_VALUE
#define NAL_CONFIG_SAVED_TCP_PORTS
void pTcpAgency(stream< SessionId > &sGetTripleFromSid_Req, stream< NalTriple > &sGetTripleFromSid_Rep, stream< NalTriple > &sGetSidFromTriple_Req, stream< SessionId > &sGetSidFromTriple_Rep, stream< NalNewTableEntry > &sAddNewTriple_TcpRrh, stream< NalNewTableEntry > &sAddNewTriple_TcpCon, stream< SessionId > &sDeleteEntryBySid, stream< bool > &inval_del_sig, stream< SessionId > &sMarkAsPriv, stream< bool > &sMarkToDel_unpriv, stream< bool > &sGetNextDelRow_Req, stream< SessionId > &sGetNextDelRow_Rep)
Contains the SessionId-Triple CAM for TCP sessions. It replies to stram requests.
#define NAL_MMIO_STABILIZE_TIME
#define NAL_CONFIG_SAVED_UDP_PORTS
ap_uint< 32 > getRightmostBitPos(ap_uint< 32 > num)
ap_uint< 1 > role_decoupled
#define NAL_CONFIG_MRT_VERSION
#define NAL_CONFIG_OWN_RANK
ap_uint< 32 > ctrlLink[64+16+16]
void pMrtAgency(stream< NalMrtUpdate > &sMrtUpdate, stream< NodeId > &sGetIpReq_UdpTx, stream< Ip4Addr > &sGetIpRep_UdpTx, stream< NodeId > &sGetIpReq_TcpTx, stream< Ip4Addr > &sGetIpRep_TcpTx, stream< Ip4Addr > &sGetNidReq_UdpRx, stream< NodeId > &sGetNidRep_UdpRx, stream< Ip4Addr > &sGetNidReq_TcpRx, stream< NodeId > &sGetNidRep_TcpRx)
Can access the BRAM that contains the MRT and replies to lookup requests.
void pPortLogic(ap_uint< 1 > *layer_4_enabled, ap_uint< 1 > *layer_7_enabled, ap_uint< 1 > *role_decoupled, ap_uint< 1 > *piNTS_ready, ap_uint< 16 > *piMMIO_FmcLsnPort, ap_uint< 32 > *pi_udp_rx_ports, ap_uint< 32 > *pi_tcp_rx_ports, stream< NalConfigUpdate > &sConfigUpdate, stream< UdpPort > &sUdpPortsToOpen, stream< UdpPort > &sUdpPortsToClose, stream< TcpPort > &sTcpPortsToOpen, stream< bool > &sUdpPortsOpenFeedback, stream< bool > &sTcpPortsOpenFeedback, stream< bool > &sMarkToDel_unpriv, stream< NalPortUpdate > &sPortUpdate, stream< bool > &sStartTclCls)
Translates the one-hot encoded open-port vectors from the Role (i.e. piUdpRxPorts and piTcpRxPorts) t...
#define INVALID_MRT_VALUE
: 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
ap_uint< 16 > status_addr
: The UDP Sub System (USS) of the NAL core.