From be61372364b4ffb743fff0f26d200c84b432f4ce Mon Sep 17 00:00:00 2001 From: pomsi <72771413+pomsi@users.noreply.github.com> Date: Fri, 9 May 2025 23:46:13 +0200 Subject: [PATCH 01/21] Create README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..a9d436e --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +Changed Files: +- ip4.hpp: ipv4Meta struct, ipv4Header class From f760d6356fa86abd22e5b58427ad892cc600e6ba Mon Sep 17 00:00:00 2001 From: Cyril Pomsar Date: Sat, 10 May 2025 00:32:43 +0200 Subject: [PATCH 02/21] ECN markings forwarded up the stack until infiniband --- hls/ipv4/ipv4.cpp | 3 ++- hls/ipv4/ipv4.hpp | 17 +++++++++++++++-- hls/udp/udp.cpp | 3 ++- hls/udp/udp.hpp | 8 +++++++- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/hls/ipv4/ipv4.cpp b/hls/ipv4/ipv4.cpp index b7cf4ac..553db6a 100644 --- a/hls/ipv4/ipv4.cpp +++ b/hls/ipv4/ipv4.cpp @@ -27,6 +27,7 @@ #include "ipv4_config.hpp" #include "ipv4.hpp" +//MT added ECN marking to the ipv4Meta struct written to MetaOut template void process_ipv4( stream >& dataIn, stream >& process2dropLengthFifo, @@ -54,7 +55,7 @@ void process_ipv4( stream >& dataIn, { std::cout << "IP HEADER: src address: " << header.getSrcAddr() << ", length: " << header.getLength() << std::endl; process2dropLengthFifo.write(header.getHeaderLength() - headerWordsDropped); - MetaOut.write(ipv4Meta(header.getSrcAddr(), header.getLength())); + MetaOut.write(ipv4Meta(header.getSrcAddr(), header.getLength(), header.getECN())); metaWritten = true; } } diff --git a/hls/ipv4/ipv4.hpp b/hls/ipv4/ipv4.hpp index efabe99..241c29e 100644 --- a/hls/ipv4/ipv4.hpp +++ b/hls/ipv4/ipv4.hpp @@ -31,17 +31,23 @@ const uint32_t IPV4_HEADER_SIZE = 160; + +//MT changed this struct to also include 2 bit for the ecn marking struct ipv4Meta { ap_uint<32> their_address; ap_uint<16> length; + ap_uint<2> ecn; + //TODO what aobut my address?? ipv4Meta() {} ipv4Meta(ap_uint<32> addr, ap_uint<16> len) - :their_address(addr), length(len) {} + :their_address(addr), length(len), ecn(0) {} + ipv4Meta(ap_uint<32> addr, ap_uint<16> len, ap_uint<2> e) + :their_address(addr), length(len), ecn(e) {} //for IPv6 TODO fix this in the future ipv4Meta(ap_uint<128> addr, ap_uint<16> len) - :their_address(addr(127,96)), length(len) {} + :their_address(addr(127,96)), length(len), ecn(0) {} }; template @@ -650,6 +656,13 @@ class ipv4Header : public packetHeader { header[9] = ECN; } + //MT added function to return the 2-bit ecn field + ap_uint<2> getECN() + { + return reverse((ap_uint<2>)header(9,8)); + } + + void setProtocol(const ap_uint<8>& protocol) { header(79, 72) = protocol; diff --git a/hls/udp/udp.cpp b/hls/udp/udp.cpp index 3dd8a2c..ca65828 100644 --- a/hls/udp/udp.cpp +++ b/hls/udp/udp.cpp @@ -174,6 +174,7 @@ void split_tx_meta( stream& metaIn, } } +//MT added ECN marking from ipMeta to also be merged and written to MetaOut void merge_rx_meta( stream& ipMetaIn, stream& udpMetaIn, stream& metaOut) @@ -190,7 +191,7 @@ void merge_rx_meta( stream& ipMetaIn, udpMetaIn.read(meta1); if (meta1.valid) { - metaOut.write(ipUdpMeta(meta0.their_address, meta1.their_port, meta1.my_port, meta1.length)); + metaOut.write(ipUdpMeta(meta0.their_address, meta1.their_port, meta1.my_port, meta1.length, meta0.ecn)); } } } diff --git a/hls/udp/udp.hpp b/hls/udp/udp.hpp index 8fe12e8..cda3b3e 100644 --- a/hls/udp/udp.hpp +++ b/hls/udp/udp.hpp @@ -43,15 +43,21 @@ typedef ipv4Meta ipMeta; const uint32_t UDP_HEADER_SIZE = 64; const uint16_t UDP_PROTOCOL = 0x11; +//MT changed this struct to also include 2 bit for the ecn marking struct ipUdpMeta { ap_uint<128> their_address; ap_uint<16> their_port; ap_uint<16> my_port; ap_uint<16> length; + ap_uint<2> ecn; ipUdpMeta() {} ipUdpMeta(ap_uint<128> addr, ap_uint<16> tport, ap_uint<16> mport, ap_uint<16> len) - :their_address(addr), their_port(tport), my_port(mport), length(len) {} + :their_address(addr), their_port(tport), my_port(mport), length(len), ecn(0) {} + ipUdpMeta(ap_uint<128> addr, ap_uint<16> tport, ap_uint<16> mport, ap_uint<16> len, ap_uint<2> e) + :their_address(addr), their_port(tport), my_port(mport), length(len), ecn(e) {} + + }; struct udpMeta From 584d2f37a3dcc390d678524383a9208e136b7f55 Mon Sep 17 00:00:00 2001 From: pomsi <72771413+pomsi@users.noreply.github.com> Date: Sat, 10 May 2025 00:33:55 +0200 Subject: [PATCH 03/21] Update README.md --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a9d436e..7a52b98 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,10 @@ Changed Files: -- ip4.hpp: ipv4Meta struct, ipv4Header class +- ipv4.hpp: ipv4Meta struct, ipv4Header class +- ipv4.cpp: process_ipv4 function +- udp.hpp: ipUdpMeta struct, +- udp.cpp: merge_rx_meta function + + + +Notes: +add same changes to ipv6 From 66b2b7a3ac36cf29de6fffad7040608fe3e027ba Mon Sep 17 00:00:00 2001 From: pomsi <72771413+pomsi@users.noreply.github.com> Date: Wed, 14 May 2025 11:14:08 +0200 Subject: [PATCH 04/21] Update README.md --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7a52b98..350aa09 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,12 @@ Changed Files: - ipv4.cpp: process_ipv4 function - udp.hpp: ipUdpMeta struct, - udp.cpp: merge_rx_meta function +- ib_transport_protocol.hpp: ackMeta struct +- ib_transport_protocol.cpp: rx_exh_fsm function (signal definition, DMA_META Case, DATA Case (2 ackmeta calls)), ipUdpMetaHandler function, signal definitions Notes: -add same changes to ipv6 +- add same changes to ipv6 +- decouple tx and rx meta interfaces + From c785302e18e84e897c8ed35d7a2be41e01ee40b7 Mon Sep 17 00:00:00 2001 From: Cyril Pomsar Date: Wed, 14 May 2025 11:15:11 +0200 Subject: [PATCH 05/21] finished adding ecn to stack --- .../ib_transport_protocol.cpp | 35 +++++++++++++++---- .../ib_transport_protocol.hpp | 6 +++- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/hls/ib_transport_protocol/ib_transport_protocol.cpp b/hls/ib_transport_protocol/ib_transport_protocol.cpp index 81bfcb5..1aeddbb 100644 --- a/hls/ib_transport_protocol/ib_transport_protocol.cpp +++ b/hls/ib_transport_protocol/ib_transport_protocol.cpp @@ -480,6 +480,7 @@ void rx_ibh_fsm( * RDMA READ RESPONSE LAST: AETH, PayLd * ACK: AETH */ +//MT added ipEcnFifo input template void rx_exh_fsm( #ifdef DBG_IBV @@ -487,6 +488,7 @@ void rx_exh_fsm( #endif stream& metaIn, stream >& udpLengthFifo, + stream >& ipEcnFifo stream& msnTable2rxExh_rsp, #ifdef RETRANS_EN //stream& readReqTable_upd_req, @@ -515,6 +517,9 @@ void rx_exh_fsm( static ExHeader exHeader; static dmaState dmaMeta; static ap_uint<16> udpLength; + //MT added + static ap_uint<2> ecn; + ap_uint<32> payLoadLength; static bool consumeReadInit; //static rxReadReqRsp readReqMeta; @@ -546,12 +551,14 @@ void rx_exh_fsm( pe_fsmState = DMA_META; } break; + //MT added ecn case DMA_META: - if (!msnTable2rxExh_rsp.empty() && !udpLengthFifo.empty() && (!consumeReadInit || !retrans2rx_init.empty())) + if (!msnTable2rxExh_rsp.empty() && !udpLengthFifo.empty() && !ipEcnFifo.empty() && (!consumeReadInit || !retrans2rx_init.empty())) { msnTable2rxExh_rsp.read(dmaMeta); udpLengthFifo.read(udpLength); + ipEcnFifo.read(ecn); #ifdef RETRANS_EN /*if (meta.op_code == RC_ACK) { @@ -691,9 +698,10 @@ void rx_exh_fsm( AckExHeader ackHeader = exHeader.getAckHeader(); if(meta.op_code == RC_RDMA_READ_RESP_ONLY || meta.op_code == RC_RDMA_READ_RESP_LAST) { + //MT added ecn m_axis_rx_ack_meta.write(ackMeta(meta.op_code, meta.dest_qp(15,0), readReqInit.host, readReqInit.host ? readReqInit.laddr(51,48) : 0, readReqInit.host ? readReqInit.laddr(53,52) : 0, - readReqInit.lst)); + readReqInit.lst, ecn)); } if (ackHeader.isNAK()) @@ -750,10 +758,10 @@ void rx_exh_fsm( { // [BTH][AETH] AckExHeader ackHeader = exHeader.getAckHeader(); - + //MT added ecn m_axis_rx_ack_meta.write(ackMeta(meta.op_code, meta.dest_qp(19,0), readReqInit.host, readReqInit.host ? readReqInit.laddr(51,48) : 0, readReqInit.host ? readReqInit.laddr(53,52) : 0, - readReqInit.lst)); + readReqInit.lst, ecn)); std::cout << "[RX EXH FSM " << INSTID << "]: syndrome: " << std::hex << ackHeader.getSyndrome() << std::endl; #ifdef RETRANS_EN @@ -2016,6 +2024,7 @@ void prepend_ibh_header( */ //TODO maybe all ACKS should be triggered by ibhFSM?? what is the guarantee we should/have to give //TODO this should become a BRAM, storage type of thing +//MT added ecn output fifo template void ipUdpMetaHandler( stream& input, @@ -2024,7 +2033,9 @@ void ipUdpMetaHandler( //stream& output, //stream >& remcrc_lengthFifo, stream >& exh_lengthFifo, - stream >& exHeaderOutput + stream >& exHeaderOutput, + + stream>& ecn_Fifo ) { #pragma HLS inline off #pragma HLS pipeline II=1 @@ -2047,6 +2058,8 @@ void ipUdpMetaHandler( exh_lengthFifo.write(meta.length); exHeaderOutput.write(header); + ecn_FiFo.write(meta.ecn); + } //output.write(dstTuple(meta.their_address, meta.their_port)); } @@ -2388,10 +2401,16 @@ void ib_transport_protocol( #endif static stream > exh_lengthFifo("exh_lengthFifo"); + //MT added ecn + static stream> ecn_Fifo("ecn_Fifo"); + static stream rx_readRequestFifo("rx_readRequestFifo"); static stream rx_readEvenFifo("rx_readEvenFifo"); static stream rx_ackEventFifo("rx_ackEventFifo"); #pragma HLS STREAM depth=4 variable=exh_lengthFifo + //MT added ecn + #pragma HLS STREAM depth=4 variable=ecn_Fifo + #pragma HLS STREAM depth=8 variable=rx_readRequestFifo #pragma HLS STREAM depth=512 variable=rx_readEvenFifo #pragma HLS STREAM depth=32 variable=rx_ackEventFifo @@ -2545,15 +2564,19 @@ void ib_transport_protocol( rx_exh2dropFifo, rx_ibhDropFifo, rx_ibhDrop2exhFifo); //some hack TODO, make this nicer.. not sure what this is still for - ipUdpMetaHandler(s_axis_rx_meta, rx_exh2drop_MetaFifo, rx_ibhDropMetaFifo, exh_lengthFifo, rx_drop2exhFsm_MetaFifo); + //MT added ecn output signal + ipUdpMetaHandler(s_axis_rx_meta, rx_exh2drop_MetaFifo, rx_ibhDropMetaFifo, exh_lengthFifo, rx_drop2exhFsm_MetaFifo, ecn_Fifo); + //MT added ecn input rx_exh_fsm( #ifdef DBG_IBV m_axis_dbg_2, #endif rx_fsm2exh_MetaFifo, exh_lengthFifo, + ecn_Fifo, msnTable2rxExh_rsp, + #ifdef RETRANS_EN //rx_readReqTable_upd_req, //rx_readReqTable_upd_rsp, diff --git a/hls/ib_transport_protocol/ib_transport_protocol.hpp b/hls/ib_transport_protocol/ib_transport_protocol.hpp index ca8bc08..7edb3b0 100644 --- a/hls/ib_transport_protocol/ib_transport_protocol.hpp +++ b/hls/ib_transport_protocol/ib_transport_protocol.hpp @@ -236,6 +236,7 @@ struct txMeta }; /* ACK meta */ +//MT changed this struct to also include 2 bit for the ecn marking struct ackMeta { ibOpCode op_code; // 32 @@ -244,10 +245,13 @@ struct ackMeta ap_uint<4> dst; ap_uint<2> strm; ap_uint<1> lst; + ap_uint<2> ecn; ackMeta() {} ackMeta(ibOpCode op_code, ap_uint<16> qpn, ap_uint<1> host, ap_uint<4> dst, ap_uint<2> strm, ap_uint<1> lst) - : op_code(op_code), qpn(qpn), host(host), dst(dst), strm(strm), lst(lst) {} + : op_code(op_code), qpn(qpn), host(host), dst(dst), strm(strm), lst(lst), ecn(0) {} + ackMeta(ibOpCode op_code, ap_uint<16> qpn, ap_uint<1> host, ap_uint<4> dst, ap_uint<2> strm, ap_uint<1> lst, ap_uint<2> e) + : op_code(op_code), qpn(qpn), host(host), dst(dst), strm(strm), lst(lst), ecn(e) {} }; /* Event */ From 11ea45770aeb2104c0821e23e96555b7fe3a5cd3 Mon Sep 17 00:00:00 2001 From: Cyril Pomsar Date: Tue, 24 Jun 2025 10:08:39 +0200 Subject: [PATCH 06/21] pls work --- .../ib_transport_protocol.cpp | 2 +- hls/ipv4/ipv4.cpp | 21 +++++++++++++++++-- hls/ipv4/ipv4.hpp | 19 ++++++++++------- hls/rocev2/CMakeLists.txt | 2 +- hls/udp/udp.hpp | 9 +++++--- 5 files changed, 38 insertions(+), 15 deletions(-) diff --git a/hls/ib_transport_protocol/ib_transport_protocol.cpp b/hls/ib_transport_protocol/ib_transport_protocol.cpp index 1aeddbb..ee6b5ec 100644 --- a/hls/ib_transport_protocol/ib_transport_protocol.cpp +++ b/hls/ib_transport_protocol/ib_transport_protocol.cpp @@ -2024,7 +2024,7 @@ void prepend_ibh_header( */ //TODO maybe all ACKS should be triggered by ibhFSM?? what is the guarantee we should/have to give //TODO this should become a BRAM, storage type of thing -//MT added ecn output fifo +//MT_pomsarc added ecn output fifo template void ipUdpMetaHandler( stream& input, diff --git a/hls/ipv4/ipv4.cpp b/hls/ipv4/ipv4.cpp index 553db6a..a9d90a2 100644 --- a/hls/ipv4/ipv4.cpp +++ b/hls/ipv4/ipv4.cpp @@ -84,6 +84,9 @@ void generate_ipv4( stream& txEng_ipMetaDataFifoIn, static fsmStateType gi_state=META; static ipv4Header header; + //MT added + static bool ecn_alternator = true; + ipv4Meta meta; net_axis currWord; ap_uint<16> length; @@ -103,7 +106,15 @@ void generate_ipv4( stream& txEng_ipMetaDataFifoIn, header.setProtocol(protocol); // Set ECN and flags accordingly - header.setECN(2); + //MT added (if statement around set ECN) + if(ecn_alternator) + { + header.setECN(2); + } + else + { + header.setECN(3); + } header.setFlags(2); if (IPV4_HEADER_SIZE >= WIDTH) @@ -193,7 +204,13 @@ void ipv4_generate_ipv4( stream& txEng_ipMetaDataFifoIn, header.setProtocol(protocol); // Set ECN and flags accordingly - header.setECN(1); + //MT_pomsarc changed outgoing ecn if its ack + if(meta.is_marked_ack){ + //header.setECN(meta.ecn) + header.setECN(2); + }else{ + header.setECN(1); + } header.setFlags(1); if (IPV4_HEADER_SIZE >= WIDTH) diff --git a/hls/ipv4/ipv4.hpp b/hls/ipv4/ipv4.hpp index 241c29e..1b1a06d 100644 --- a/hls/ipv4/ipv4.hpp +++ b/hls/ipv4/ipv4.hpp @@ -32,22 +32,25 @@ const uint32_t IPV4_HEADER_SIZE = 160; -//MT changed this struct to also include 2 bit for the ecn marking +//MT changed this struct to also include 2 bit for the ecn marking + is_outgoing... struct ipv4Meta { ap_uint<32> their_address; ap_uint<16> length; - ap_uint<2> ecn; + ap_uint<2> ecn; + ap_uint<1> is_marked_ack; //TODO what aobut my address?? ipv4Meta() {} ipv4Meta(ap_uint<32> addr, ap_uint<16> len) - :their_address(addr), length(len), ecn(0) {} + :their_address(addr), length(len), ecn(3), is_marked_ack(0) {} ipv4Meta(ap_uint<32> addr, ap_uint<16> len, ap_uint<2> e) - :their_address(addr), length(len), ecn(e) {} + :their_address(addr), length(len), ecn(e), is_marked_ack(0) {} + ipv4Meta(ap_uint<32> addr, ap_uint<16> len, ap_uint<2> e, ap_uint<1> is_ack) + :their_address(addr), length(len), ecn(e), is_marked_ack(is_ack) {} //for IPv6 TODO fix this in the future ipv4Meta(ap_uint<128> addr, ap_uint<16> len) - :their_address(addr(127,96)), length(len), ecn(0) {} + :their_address(addr(127,96)), length(len), ecn(3), is_marked_ack(0) {} }; template @@ -651,15 +654,15 @@ class ipv4Header : public packetHeader { } // New function to set ECN - void setECN(const ap_uint<1> ECN) + void setECN(const ap_uint<2> ECN) { - header[9] = ECN; + header(15,14) = reverse(ECN); } //MT added function to return the 2-bit ecn field ap_uint<2> getECN() { - return reverse((ap_uint<2>)header(9,8)); + return reverse((ap_uint<2>)header(15,14)); } diff --git a/hls/rocev2/CMakeLists.txt b/hls/rocev2/CMakeLists.txt index 1828c8b..2df53e7 100644 --- a/hls/rocev2/CMakeLists.txt +++ b/hls/rocev2/CMakeLists.txt @@ -27,7 +27,7 @@ set(DATA_WIDTH 64 CACHE STRING "Width of data path in bytes") set(PMTU_BYTES 4096 CACHE STRING "PMTU size.") set(CLOCK_PERIOD 6.4 CACHE STRING "Target clock period in nanoseconds") # RoCE parameters -set(ROCE_STACK_MAX_QPS 500 CACHE STRING "Maximum number of queue pairs the RoCE stack can support") +set(ROCE_STACK_MAX_QPS 16 CACHE STRING "Maximum number of queue pairs the RoCE stack can support") find_package(VitisHLS REQUIRED) if (NOT VITIS_HLS_FOUND) diff --git a/hls/udp/udp.hpp b/hls/udp/udp.hpp index cda3b3e..3b93753 100644 --- a/hls/udp/udp.hpp +++ b/hls/udp/udp.hpp @@ -43,7 +43,7 @@ typedef ipv4Meta ipMeta; const uint32_t UDP_HEADER_SIZE = 64; const uint16_t UDP_PROTOCOL = 0x11; -//MT changed this struct to also include 2 bit for the ecn marking +//MT_pomsarc changed this struct to also include 2 bit for the ecn marking struct ipUdpMeta { ap_uint<128> their_address; @@ -51,11 +51,14 @@ struct ipUdpMeta ap_uint<16> my_port; ap_uint<16> length; ap_uint<2> ecn; + ap_uint<1> is_outgoing_ack; ipUdpMeta() {} ipUdpMeta(ap_uint<128> addr, ap_uint<16> tport, ap_uint<16> mport, ap_uint<16> len) - :their_address(addr), their_port(tport), my_port(mport), length(len), ecn(0) {} + :their_address(addr), their_port(tport), my_port(mport), length(len), ecn(3), is_outgoing_ack(0) {} ipUdpMeta(ap_uint<128> addr, ap_uint<16> tport, ap_uint<16> mport, ap_uint<16> len, ap_uint<2> e) - :their_address(addr), their_port(tport), my_port(mport), length(len), ecn(e) {} + :their_address(addr), their_port(tport), my_port(mport), length(len), ecn(e), is_outgoing_ack(0) {} + ipUdpMeta(ap_uint<128> addr, ap_uint<16> tport, ap_uint<16> mport, ap_uint<16> len, ap_uint<2> e, ap_uint<1> is_ack) + :their_address(addr), their_port(tport), my_port(mport), length(len), ecn(e), is_outgoing_ack(is_ack) {} }; From a1693f37abf1c4cf54abf912e6b8b3a4cfe0f0a6 Mon Sep 17 00:00:00 2001 From: Cyril Pomsar Date: Wed, 25 Jun 2025 04:14:52 +0200 Subject: [PATCH 07/21] deliberately not working to test if submodules connect correctly --- hls/ipv4/ipv4.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hls/ipv4/ipv4.cpp b/hls/ipv4/ipv4.cpp index a9d90a2..2975721 100644 --- a/hls/ipv4/ipv4.cpp +++ b/hls/ipv4/ipv4.cpp @@ -69,6 +69,7 @@ void process_ipv4( stream >& dataIn, } } } +deliberate mistake template void generate_ipv4( stream& txEng_ipMetaDataFifoIn, @@ -396,7 +397,7 @@ void ipv4( hls::stream >& s_axis_rx_data, generate_ipv4(s_axis_tx_meta, tx_shift2ipv4Fifo, m_axis_tx_data, local_ipv4_address, protocol); } -void ipv4_top( hls::stream >& s_axis_rx_data, +void ipv4_top( hls::stream >& s_axis_rx_data, hls::stream& m_axis_rx_meta, hls::stream >& m_axis_rx_data, hls::stream& s_axis_tx_meta, From 920d14eb64a025512f845ab686edbd93f16468c4 Mon Sep 17 00:00:00 2001 From: Cyril Pomsar Date: Fri, 27 Jun 2025 11:47:04 +0200 Subject: [PATCH 08/21] :( --- hls/ipv4/ipv4.cpp | 6 ++++-- hls/ipv4/ipv4.hpp | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/hls/ipv4/ipv4.cpp b/hls/ipv4/ipv4.cpp index 2975721..d7d8d16 100644 --- a/hls/ipv4/ipv4.cpp +++ b/hls/ipv4/ipv4.cpp @@ -55,7 +55,9 @@ void process_ipv4( stream >& dataIn, { std::cout << "IP HEADER: src address: " << header.getSrcAddr() << ", length: " << header.getLength() << std::endl; process2dropLengthFifo.write(header.getHeaderLength() - headerWordsDropped); - MetaOut.write(ipv4Meta(header.getSrcAddr(), header.getLength(), header.getECN())); + //cHANGE THIS BACK + //MetaOut.write(ipv4Meta(header.getSrcAddr(), header.getLength(), header.getECN())); + MetaOut.write(ipv4Meta(header.getSrcAddr(), header.getLength(), 3)); metaWritten = true; } } @@ -69,7 +71,7 @@ void process_ipv4( stream >& dataIn, } } } -deliberate mistake + template void generate_ipv4( stream& txEng_ipMetaDataFifoIn, diff --git a/hls/ipv4/ipv4.hpp b/hls/ipv4/ipv4.hpp index 1b1a06d..e37d38d 100644 --- a/hls/ipv4/ipv4.hpp +++ b/hls/ipv4/ipv4.hpp @@ -656,13 +656,13 @@ class ipv4Header : public packetHeader { // New function to set ECN void setECN(const ap_uint<2> ECN) { - header(15,14) = reverse(ECN); + header(9,8) = reverse(ECN); } //MT added function to return the 2-bit ecn field ap_uint<2> getECN() { - return reverse((ap_uint<2>)header(15,14)); + return reverse((ap_uint<2>)header(9,8)); } From 0032c5545507f15005386200759c7d4c10f94635 Mon Sep 17 00:00:00 2001 From: Cyril Pomsar Date: Mon, 30 Jun 2025 01:52:19 +0200 Subject: [PATCH 09/21] ib_protocol forward 3 ecn --- .../ib_transport_protocol.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/hls/ib_transport_protocol/ib_transport_protocol.cpp b/hls/ib_transport_protocol/ib_transport_protocol.cpp index ee6b5ec..1e19138 100644 --- a/hls/ib_transport_protocol/ib_transport_protocol.cpp +++ b/hls/ib_transport_protocol/ib_transport_protocol.cpp @@ -698,10 +698,14 @@ void rx_exh_fsm( AckExHeader ackHeader = exHeader.getAckHeader(); if(meta.op_code == RC_RDMA_READ_RESP_ONLY || meta.op_code == RC_RDMA_READ_RESP_LAST) { - //MT added ecn + //MT added ecn [TO_CHANGE_BACK] m_axis_rx_ack_meta.write(ackMeta(meta.op_code, meta.dest_qp(15,0), readReqInit.host, readReqInit.host ? readReqInit.laddr(51,48) : 0, readReqInit.host ? readReqInit.laddr(53,52) : 0, - readReqInit.lst, ecn)); + readReqInit.lst, 3)); + + /*m_axis_rx_ack_meta.write(ackMeta(meta.op_code, meta.dest_qp(15,0), readReqInit.host, + readReqInit.host ? readReqInit.laddr(51,48) : 0, readReqInit.host ? readReqInit.laddr(53,52) : 0, + readReqInit.lst, ecn));*/ } if (ackHeader.isNAK()) @@ -2204,9 +2208,7 @@ void ib_transport_protocol( // RDMA stream& m_axis_mem_write_cmd, - stream& m_axis_mem_read_cmd, - stream >& m_axis_mem_write_data, - stream >& s_axis_mem_read_data, + stream& m_axis_mem_read_cmd,ecn_FiFo // QP stream& s_axis_qp_interface, @@ -2277,7 +2279,7 @@ void ib_transport_protocol( #pragma HLS DATA_PACK variable=rx_exhEventMetaFifo #pragma HLS DATA_PACK variable=rx_remoteMemCmd #endif - +ecn_FiFo static stream tx_ibhMetaFifo("tx_ibhMetaFifo"); static stream tx_appMetaFifo("tx_appMetaFifo"); //static stream tx_localMetaFifo("tx_localMetaFifo"); From 681c35efe48c570cdc340fc28087e3bfc7c14058 Mon Sep 17 00:00:00 2001 From: pomsarc Date: Wed, 3 Sep 2025 16:47:57 +0200 Subject: [PATCH 10/21] typo fix --- hls/ib_transport_protocol/ib_transport_protocol.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/hls/ib_transport_protocol/ib_transport_protocol.cpp b/hls/ib_transport_protocol/ib_transport_protocol.cpp index 1e19138..bffd60b 100644 --- a/hls/ib_transport_protocol/ib_transport_protocol.cpp +++ b/hls/ib_transport_protocol/ib_transport_protocol.cpp @@ -488,7 +488,7 @@ void rx_exh_fsm( #endif stream& metaIn, stream >& udpLengthFifo, - stream >& ipEcnFifo + stream >& ipEcnFifo, stream& msnTable2rxExh_rsp, #ifdef RETRANS_EN //stream& readReqTable_upd_req, @@ -698,14 +698,10 @@ void rx_exh_fsm( AckExHeader ackHeader = exHeader.getAckHeader(); if(meta.op_code == RC_RDMA_READ_RESP_ONLY || meta.op_code == RC_RDMA_READ_RESP_LAST) { - //MT added ecn [TO_CHANGE_BACK] + //MT added ecn m_axis_rx_ack_meta.write(ackMeta(meta.op_code, meta.dest_qp(15,0), readReqInit.host, readReqInit.host ? readReqInit.laddr(51,48) : 0, readReqInit.host ? readReqInit.laddr(53,52) : 0, - readReqInit.lst, 3)); - - /*m_axis_rx_ack_meta.write(ackMeta(meta.op_code, meta.dest_qp(15,0), readReqInit.host, - readReqInit.host ? readReqInit.laddr(51,48) : 0, readReqInit.host ? readReqInit.laddr(53,52) : 0, - readReqInit.lst, ecn));*/ + readReqInit.lst, ecn)); } if (ackHeader.isNAK()) From 762b30c6ac5a6a4c93744fc08de39bd9eaa0c1af Mon Sep 17 00:00:00 2001 From: pomsarc Date: Wed, 3 Sep 2025 18:19:21 +0200 Subject: [PATCH 11/21] ... --- hls/ib_transport_protocol/ib_transport_protocol.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hls/ib_transport_protocol/ib_transport_protocol.cpp b/hls/ib_transport_protocol/ib_transport_protocol.cpp index bffd60b..fd4a9b1 100644 --- a/hls/ib_transport_protocol/ib_transport_protocol.cpp +++ b/hls/ib_transport_protocol/ib_transport_protocol.cpp @@ -2058,7 +2058,7 @@ void ipUdpMetaHandler( exh_lengthFifo.write(meta.length); exHeaderOutput.write(header); - ecn_FiFo.write(meta.ecn); + ecn_Fifo.write(meta.ecn); } //output.write(dstTuple(meta.their_address, meta.their_port)); @@ -2204,7 +2204,8 @@ void ib_transport_protocol( // RDMA stream& m_axis_mem_write_cmd, - stream& m_axis_mem_read_cmd,ecn_FiFo + stream& m_axis_mem_read_cmd, + //ecn_Fifo // QP stream& s_axis_qp_interface, From 08013656409f3c539aead664b4ced25ba9715a82 Mon Sep 17 00:00:00 2001 From: pomsarc Date: Wed, 3 Sep 2025 18:21:26 +0200 Subject: [PATCH 12/21] ... --- hls/ib_transport_protocol/ib_transport_protocol.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hls/ib_transport_protocol/ib_transport_protocol.cpp b/hls/ib_transport_protocol/ib_transport_protocol.cpp index fd4a9b1..c6135e3 100644 --- a/hls/ib_transport_protocol/ib_transport_protocol.cpp +++ b/hls/ib_transport_protocol/ib_transport_protocol.cpp @@ -2276,7 +2276,8 @@ void ib_transport_protocol( #pragma HLS DATA_PACK variable=rx_exhEventMetaFifo #pragma HLS DATA_PACK variable=rx_remoteMemCmd #endif -ecn_FiFo + //remove + //ecn_FiFo static stream tx_ibhMetaFifo("tx_ibhMetaFifo"); static stream tx_appMetaFifo("tx_appMetaFifo"); //static stream tx_localMetaFifo("tx_localMetaFifo"); From 5086556009f946ddf0601062a7c0520fd78e4280 Mon Sep 17 00:00:00 2001 From: pomsarc Date: Wed, 3 Sep 2025 18:36:11 +0200 Subject: [PATCH 13/21] ... --- hls/ib_transport_protocol/ib_transport_protocol.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hls/ib_transport_protocol/ib_transport_protocol.cpp b/hls/ib_transport_protocol/ib_transport_protocol.cpp index c6135e3..838e855 100644 --- a/hls/ib_transport_protocol/ib_transport_protocol.cpp +++ b/hls/ib_transport_protocol/ib_transport_protocol.cpp @@ -2205,7 +2205,9 @@ void ib_transport_protocol( // RDMA stream& m_axis_mem_write_cmd, stream& m_axis_mem_read_cmd, - //ecn_Fifo + stream >& m_axis_mem_write_data, + stream >& s_axis_mem_read_data, + // QP stream& s_axis_qp_interface, From 23f96c5c706f02f1ef7ccd6d1f3bdb40a0c754db Mon Sep 17 00:00:00 2001 From: pomsarc Date: Thu, 4 Sep 2025 20:33:15 +0200 Subject: [PATCH 14/21] :( --- .../ib_transport_protocol.cpp | 9 ++++---- hls/ipv4/ipv4.cpp | 21 +++++++++---------- hls/udp/udp.cpp | 3 ++- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/hls/ib_transport_protocol/ib_transport_protocol.cpp b/hls/ib_transport_protocol/ib_transport_protocol.cpp index 838e855..73982d1 100644 --- a/hls/ib_transport_protocol/ib_transport_protocol.cpp +++ b/hls/ib_transport_protocol/ib_transport_protocol.cpp @@ -555,7 +555,6 @@ void rx_exh_fsm( case DMA_META: if (!msnTable2rxExh_rsp.empty() && !udpLengthFifo.empty() && !ipEcnFifo.empty() && (!consumeReadInit || !retrans2rx_init.empty())) { - msnTable2rxExh_rsp.read(dmaMeta); udpLengthFifo.read(udpLength); ipEcnFifo.read(ecn); @@ -698,7 +697,7 @@ void rx_exh_fsm( AckExHeader ackHeader = exHeader.getAckHeader(); if(meta.op_code == RC_RDMA_READ_RESP_ONLY || meta.op_code == RC_RDMA_READ_RESP_LAST) { - //MT added ecn + //MT_pomsarc added ecn m_axis_rx_ack_meta.write(ackMeta(meta.op_code, meta.dest_qp(15,0), readReqInit.host, readReqInit.host ? readReqInit.laddr(51,48) : 0, readReqInit.host ? readReqInit.laddr(53,52) : 0, readReqInit.lst, ecn)); @@ -758,7 +757,7 @@ void rx_exh_fsm( { // [BTH][AETH] AckExHeader ackHeader = exHeader.getAckHeader(); - //MT added ecn + //MT_pomsarc added ecn m_axis_rx_ack_meta.write(ackMeta(meta.op_code, meta.dest_qp(19,0), readReqInit.host, readReqInit.host ? readReqInit.laddr(51,48) : 0, readReqInit.host ? readReqInit.laddr(53,52) : 0, readReqInit.lst, ecn)); @@ -2403,14 +2402,14 @@ void ib_transport_protocol( #endif static stream > exh_lengthFifo("exh_lengthFifo"); - //MT added ecn + //MT_pomsarc added ecn static stream> ecn_Fifo("ecn_Fifo"); static stream rx_readRequestFifo("rx_readRequestFifo"); static stream rx_readEvenFifo("rx_readEvenFifo"); static stream rx_ackEventFifo("rx_ackEventFifo"); #pragma HLS STREAM depth=4 variable=exh_lengthFifo - //MT added ecn + //MT_pomsarc added ecn #pragma HLS STREAM depth=4 variable=ecn_Fifo #pragma HLS STREAM depth=8 variable=rx_readRequestFifo diff --git a/hls/ipv4/ipv4.cpp b/hls/ipv4/ipv4.cpp index d7d8d16..744b725 100644 --- a/hls/ipv4/ipv4.cpp +++ b/hls/ipv4/ipv4.cpp @@ -87,9 +87,6 @@ void generate_ipv4( stream& txEng_ipMetaDataFifoIn, static fsmStateType gi_state=META; static ipv4Header header; - //MT added - static bool ecn_alternator = true; - ipv4Meta meta; net_axis currWord; ap_uint<16> length; @@ -109,15 +106,17 @@ void generate_ipv4( stream& txEng_ipMetaDataFifoIn, header.setProtocol(protocol); // Set ECN and flags accordingly - //MT added (if statement around set ECN) - if(ecn_alternator) - { - header.setECN(2); - } - else - { + + //MT_pomsarc changed outgoing ecn if its ack + if(meta.is_marked_ack){ + //header.setECN(meta.ecn) header.setECN(3); + }else{ + header.setECN(2); } + + + header.setFlags(2); if (IPV4_HEADER_SIZE >= WIDTH) @@ -210,7 +209,7 @@ void ipv4_generate_ipv4( stream& txEng_ipMetaDataFifoIn, //MT_pomsarc changed outgoing ecn if its ack if(meta.is_marked_ack){ //header.setECN(meta.ecn) - header.setECN(2); + header.setECN(3); }else{ header.setECN(1); } diff --git a/hls/udp/udp.cpp b/hls/udp/udp.cpp index ca65828..0f4ebab 100644 --- a/hls/udp/udp.cpp +++ b/hls/udp/udp.cpp @@ -169,7 +169,8 @@ void split_tx_meta( stream& metaIn, metaIn.read(meta); //Add 8 bytes for UDP header ap_uint<16> tempLen = meta.length+8; - metaOut0.write(ipMeta(meta.their_address, tempLen)); + //MT_pomsarc added ecn and ack mark to be handed down the stack too + metaOut0.write(ipMeta(meta.their_address, tempLen, meta.ecn, meta.is_outgoing_ack)); metaOut1.write(udpMeta(meta.their_port, meta.my_port, tempLen)); } } From ef47e1f81e6a7fbe8177103add8866edc7f0405c Mon Sep 17 00:00:00 2001 From: Cyril Pomsar Date: Thu, 4 Sep 2025 23:15:27 +0200 Subject: [PATCH 15/21] hopefully fixed incoming ecn -> mark outgoing ecn path --- .../ib_transport_protocol.cpp | 70 +++++++++++++++++-- .../ib_transport_protocol.hpp | 28 +++++--- hls/ipv4/ipv4.cpp | 4 +- 3 files changed, 83 insertions(+), 19 deletions(-) diff --git a/hls/ib_transport_protocol/ib_transport_protocol.cpp b/hls/ib_transport_protocol/ib_transport_protocol.cpp index 73982d1..9f47e64 100644 --- a/hls/ib_transport_protocol/ib_transport_protocol.cpp +++ b/hls/ib_transport_protocol/ib_transport_protocol.cpp @@ -589,7 +589,12 @@ void rx_exh_fsm( // Update state rxExh2msnTable_upd_req.write(rxMsnReq(meta.dest_qp, dmaMeta.msn+1)); // Trigger ACK - rx_exhEventMetaFifo.write(ackEvent(meta.dest_qp, meta.psn, false)); + //MT_pomsarc + if(ecn ==3){ + rx_exhEventMetaFifo.write(ackEvent(meta.dest_qp, meta.psn, false, true)); + } else{ + rx_exhEventMetaFifo.write(ackEvent(meta.dest_qp, meta.psn, false)); + } rx_pkgSplitTypeFifo.write(pkgSplit(meta.op_code)); rx_pkgShiftTypeFifo.write(pkgShift(SHIFT_NONE, meta.dest_qp)); @@ -607,7 +612,12 @@ void rx_exh_fsm( // Update state rxExh2msnTable_upd_req.write(rxMsnReq(meta.dest_qp, dmaMeta.msn+1)); // Trigger ACK - rx_exhEventMetaFifo.write(ackEvent(meta.dest_qp, meta.psn, false)); + //MT_pomsarc + if(ecn ==3){ + rx_exhEventMetaFifo.write(ackEvent(meta.dest_qp, meta.psn, false, true)); + } else{ + rx_exhEventMetaFifo.write(ackEvent(meta.dest_qp, meta.psn, false)); + } rx_pkgSplitTypeFifo.write(pkgSplit(meta.op_code)); rx_pkgShiftTypeFifo.write(pkgShift(SHIFT_NONE, meta.dest_qp)); @@ -642,7 +652,12 @@ void rx_exh_fsm( //TODO msn, only for ONLY?? rxExh2msnTable_upd_req.write(rxMsnReq(meta.dest_qp, dmaMeta.msn+1, rdmaHeader.getVirtualAddress()+payLoadLength, remainingLength, 1)); // Trigger ACK - rx_exhEventMetaFifo.write(ackEvent(meta.dest_qp, meta.psn, false)); + //MT_pomsarc + if(ecn ==3){ + rx_exhEventMetaFifo.write(ackEvent(meta.dest_qp, meta.psn, false, true)); + } else{ + rx_exhEventMetaFifo.write(ackEvent(meta.dest_qp, meta.psn, false)); + } rx_pkgSplitTypeFifo.write(pkgSplit(meta.op_code)); rx_pkgShiftTypeFifo.write(pkgShift(SHIFT_RETH, meta.dest_qp)); pe_fsmState = META; @@ -670,7 +685,12 @@ void rx_exh_fsm( //TODO msn only on LAST?? rxExh2msnTable_upd_req.write(rxMsnReq(meta.dest_qp, dmaMeta.msn+1, dmaMeta.vaddr+payLoadLength, remainingLength, 1)); // Trigger ACK - rx_exhEventMetaFifo.write(ackEvent(meta.dest_qp, meta.psn, false)); + //MT_pomsarc + if(ecn ==3){ + rx_exhEventMetaFifo.write(ackEvent(meta.dest_qp, meta.psn, false, true)); + } else{ + rx_exhEventMetaFifo.write(ackEvent(meta.dest_qp, meta.psn, false)); + } rx_pkgSplitTypeFifo.write(pkgSplit(meta.op_code)); rx_pkgShiftTypeFifo.write(pkgShift(SHIFT_NONE, meta.dest_qp)); pe_fsmState = META; @@ -1352,6 +1372,7 @@ void meta_merger( rx_ackEventFifo.read(aev); tx_connTable_req.write(aev.qpn(15, 0)); + // PSN used for read response tx_ibhMetaFifo.write(ibhMeta(RC_ACK, key, aev.qpn, aev.psn, aev.validPsn)); tx_exhMetaFifo.write(event(aev)); @@ -1509,6 +1530,8 @@ void generate_exh( stream >& txExh2msnTable_req, //stream& tx_readReqTable_upd, stream >& lengthFifo, + //MT_pomsarc + stream >& isMarkedAckFifo, stream& packetInfoFifo, #ifdef RETRANS_EN stream >& txSetTimer_req, @@ -1610,6 +1633,8 @@ void generate_exh( } udpLen = 12+16+payloadLen+4; //TODO dma_len can be much larger, for multiple packets we need to split this into multiple packets lengthFifo.write(udpLen); + //MT_pomsarc + isMarkedAckFifo.write(0); //Store meta for retransmit metaWritten = true; } @@ -1629,6 +1654,8 @@ void generate_exh( //BTH: 12, PayLd: x, ICRC: 4 udpLen = 12+meta.length+4; lengthFifo.write(udpLen); + //MT_pomsarc + isMarkedAckFifo.write(0); //Store meta for retransmit ge_state = META; break; @@ -1657,6 +1684,9 @@ void generate_exh( //BTH: 12, RETH: 16, PayLd: x, ICRC: 4 udpLen = 12+16+0+4; //TODO dma_len can be much larger, for multiple packets we need to split this into multiple packets lengthFifo.write(udpLen); + //MT_pomsarc + isMarkedAckFifo.write(0); + //Update Read Req max FWD header, TODO it is not exacly clear if meta.psn or meta.psn+numPkgs should be used //TODO i think psn is only used here!! //tx_readReqTable_upd.write(txReadReqUpdate(meta.qpn, meta.psn)); @@ -1695,6 +1725,8 @@ void generate_exh( //BTH: 12, AETH: 4, PayLd: x, ICRC: 4 udpLen = 12+4+meta.length+4; lengthFifo.write(udpLen); + //MT_pomsarc + isMarkedAckFifo.write(0); } break; } @@ -1707,6 +1739,8 @@ void generate_exh( //BTH: 12, PayLd: x, ICRC: 4 udpLen = 12+meta.length+4; lengthFifo.write(udpLen); + //MT_pomsarc + isMarkedAckFifo.write(0); ge_state = META; break; case RC_ACK: @@ -1742,6 +1776,12 @@ void generate_exh( output.write(sendWord); //BTH: 12, AETH: 4, ICRC: 4 lengthFifo.write(12+4+4); + //MT_pomsarc + if(meta.is_marked_ack_ecn){ + isMarkedAckFifo.write(1); + } else{ + isMarkedAckFifo.write(0); + } } break; } @@ -2072,6 +2112,8 @@ template void tx_ipUdpMetaMerger( stream& tx_connTable2ibh_rsp, stream >& tx_lengthFifo, + //MT_pomsarc + stream >& tx_isMarkedAckFifo, stream& m_axis_tx_meta, stream >& tx_dstQpFifo ) { @@ -2080,13 +2122,15 @@ void tx_ipUdpMetaMerger( connTableEntry connMeta; ap_uint<16> len; + ap_uint<1> is_ecn_marked; - if (!tx_connTable2ibh_rsp.empty() && !tx_lengthFifo.empty()) + if (!tx_connTable2ibh_rsp.empty() && !tx_lengthFifo.empty() && !tx_isMarkedAckFifo.empty()) { tx_connTable2ibh_rsp.read(connMeta); tx_lengthFifo.read(len); + tx_isMarkedAckFifo.read(is_ecn_marked); std::cout << "[TX IP UDP META MERGER " << INSTID << "]: port " << connMeta.remote_udp_port << std::endl; - m_axis_tx_meta.write(ipUdpMeta(connMeta.remote_ip_address, RDMA_DEFAULT_PORT, connMeta.remote_udp_port, len)); + m_axis_tx_meta.write(ipUdpMeta(connMeta.remote_ip_address, RDMA_DEFAULT_PORT, connMeta.remote_udp_port, len, 0, is_ecn_marked)); tx_dstQpFifo.write(connMeta.remote_qpn); } } @@ -2318,8 +2362,17 @@ void ib_transport_protocol( static stream tx_packetInfoFifo("tx_packetInfoFifo"); static stream > tx_lengthFifo("tx_lengthFifo"); + + //MT_pomsarc + static stream > tx_isMarkedAckFifo("tx_isMarkedAckFifo"); + + #pragma HLS STREAM depth=2 variable=tx_packetInfoFifo #pragma HLS STREAM depth=4 variable=tx_lengthFifo + + //MT_pomsarc + #pragma HLS STREAM depth=4 variable=tx_isMarkedAckFifo + #if defined( __VITIS_HLS__) #pragma HLS aggregate variable=tx_packetInfoFifo compact=bit #else @@ -2685,6 +2738,8 @@ void ib_transport_protocol( txExh2msnTable_req, //tx_readReqTable_upd, tx_lengthFifo, + //Mt_pomsarc + tx_isMarkedAckFifo, tx_packetInfoFifo, #ifdef RETRANS_EN txSetTimer_req, @@ -2712,7 +2767,8 @@ void ib_transport_protocol( prepend_ibh_header(tx_ibhHeaderFifo, tx_shift2ibhFifo, m_axis_tx_data, regIbvCountTx); //Get Meta data for UDP & IP layer - tx_ipUdpMetaMerger(tx_connTable2ibh_rsp, tx_lengthFifo, m_axis_tx_meta, tx_dstQpFifo); + //MT_pomsarc added tx_isMarkedAckFifo + tx_ipUdpMetaMerger(tx_connTable2ibh_rsp, tx_lengthFifo, tx_isMarkedAckFifo, m_axis_tx_meta, tx_dstQpFifo); //merge read requests mem_cmd_merger(rx_remoteMemCmd, tx_localMemCmdFifo, m_axis_mem_read_cmd, tx_pkgInfoFifo); diff --git a/hls/ib_transport_protocol/ib_transport_protocol.hpp b/hls/ib_transport_protocol/ib_transport_protocol.hpp index 7edb3b0..746fe85 100644 --- a/hls/ib_transport_protocol/ib_transport_protocol.hpp +++ b/hls/ib_transport_protocol/ib_transport_protocol.hpp @@ -255,23 +255,29 @@ struct ackMeta }; /* Event */ +//MT_pomsarc added ecn struct ackEvent { ap_uint<24> qpn; ap_uint<24> psn; bool validPsn; bool isNak; + bool is_marked_ecn; + ackEvent() {} ackEvent(ap_uint<24> qpn) - :qpn(qpn), psn(0), validPsn(false), isNak(false) {} + :qpn(qpn), psn(0), validPsn(false), isNak(false), is_marked_ecn(false) {} ackEvent(ap_uint<24> qpn, bool nak) - :qpn(qpn), psn(0), validPsn(false), isNak(nak) {} + :qpn(qpn), psn(0), validPsn(false), isNak(nak), is_marked_ecn(false) {} ackEvent(ap_uint<24> qp, ap_uint<24> psn, bool nak) - :qpn(qp), psn(psn), validPsn(true), isNak(nak) {} + :qpn(qp), psn(psn), validPsn(true), isNak(nak), is_marked_ecn(false) {} + ackEvent(ap_uint<24> qp, ap_uint<24> psn, bool nak, bool ecn_mark) + :qpn(qp), psn(psn), validPsn(true), isNak(nak), is_marked_ecn(ecn_mark) {} }; //TODO create readEvent //TODO event for writes addr + len, no psn + struct event { ibOpCode op_code; @@ -281,22 +287,24 @@ struct event ap_uint<24> psn; bool validPsn; bool isNak; + bool is_marked_ack_ecn; + event() - :op_code(RC_ACK), validPsn(false), isNak(false) {} + :op_code(RC_ACK), validPsn(false), isNak(false), is_marked_ack_ecn(false) {} event(ibOpCode op, ap_uint<24> qp) - :op_code(op), qpn(qp), validPsn(false), isNak(false) {} + :op_code(op), qpn(qp), validPsn(false), isNak(false), is_marked_ack_ecn(false) {} event(ackEvent& aev) - :op_code(RC_ACK), qpn(aev.qpn), psn(aev.psn), validPsn(aev.validPsn), isNak(aev.isNak) {} + :op_code(RC_ACK), qpn(aev.qpn), psn(aev.psn), validPsn(aev.validPsn), isNak(aev.isNak), is_marked_ack_ecn(aev.is_marked_ecn) {} /*event(ibOpCode op, ap_uint<24> qp, ap_uint<24> psn, bool nak) :op_code(op), qpn(qp), psn(psn), validPsn(true), isNak(nak) {}*/ event(ibOpCode op, ap_uint<24> qp, ap_uint<32> len) - :op_code(op), qpn(qp), addr(0), length(len), psn(0), validPsn(false), isNak(false) {} + :op_code(op), qpn(qp), addr(0), length(len), psn(0), validPsn(false), isNak(false), is_marked_ack_ecn(false) {} event(ibOpCode op, ap_uint<24> qp, ap_uint<64> addr, ap_uint<32> len) - :op_code(op), qpn(qp), addr(addr), length(len), psn(0), validPsn(false), isNak(false) {} + :op_code(op), qpn(qp), addr(addr), length(len), psn(0), validPsn(false), isNak(false), is_marked_ack_ecn(false) {} event(ibOpCode op, ap_uint<24> qp, ap_uint<32> len, ap_uint<24> psn) - :op_code(op), qpn(qp), addr(0), length(len), psn(psn), validPsn(true), isNak(false) {} + :op_code(op), qpn(qp), addr(0), length(len), psn(psn), validPsn(true), isNak(false), is_marked_ack_ecn(false) {} event(ibOpCode op, ap_uint<24> qp, ap_uint<64> addr, ap_uint<32> len, ap_uint<24> psn) - :op_code(op), qpn(qp), addr(addr), length(len), psn(psn), validPsn(true), isNak(false) {} + :op_code(op), qpn(qp), addr(addr), length(len), psn(psn), validPsn(true), isNak(false), is_marked_ack_ecn(false) {} }; /* Pakage info */ diff --git a/hls/ipv4/ipv4.cpp b/hls/ipv4/ipv4.cpp index 744b725..7b79259 100644 --- a/hls/ipv4/ipv4.cpp +++ b/hls/ipv4/ipv4.cpp @@ -108,7 +108,7 @@ void generate_ipv4( stream& txEng_ipMetaDataFifoIn, // Set ECN and flags accordingly //MT_pomsarc changed outgoing ecn if its ack - if(meta.is_marked_ack){ + if(meta.is_marked_ack == 1){ //header.setECN(meta.ecn) header.setECN(3); }else{ @@ -207,7 +207,7 @@ void ipv4_generate_ipv4( stream& txEng_ipMetaDataFifoIn, // Set ECN and flags accordingly //MT_pomsarc changed outgoing ecn if its ack - if(meta.is_marked_ack){ + if(meta.is_marked_ack == 1){ //header.setECN(meta.ecn) header.setECN(3); }else{ From 86b0a8604a332439bf975f06d02731a61511aba4 Mon Sep 17 00:00:00 2001 From: Cyril Pomsar Date: Mon, 8 Sep 2025 10:35:40 +0200 Subject: [PATCH 16/21] ... --- hls/ipv4/ipv4.cpp | 10 ++++++---- hls/ipv4/ipv4.hpp | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/hls/ipv4/ipv4.cpp b/hls/ipv4/ipv4.cpp index 7b79259..8de2395 100644 --- a/hls/ipv4/ipv4.cpp +++ b/hls/ipv4/ipv4.cpp @@ -108,12 +108,13 @@ void generate_ipv4( stream& txEng_ipMetaDataFifoIn, // Set ECN and flags accordingly //MT_pomsarc changed outgoing ecn if its ack - if(meta.is_marked_ack == 1){ + header.setECN(3); + /*if(meta.is_marked_ack == 1){ //header.setECN(meta.ecn) header.setECN(3); }else{ header.setECN(2); - } + }*/ @@ -207,12 +208,13 @@ void ipv4_generate_ipv4( stream& txEng_ipMetaDataFifoIn, // Set ECN and flags accordingly //MT_pomsarc changed outgoing ecn if its ack - if(meta.is_marked_ack == 1){ + header.setECN(3); + /*if(meta.is_marked_ack == 1){ //header.setECN(meta.ecn) header.setECN(3); }else{ header.setECN(1); - } + }*/ header.setFlags(1); if (IPV4_HEADER_SIZE >= WIDTH) diff --git a/hls/ipv4/ipv4.hpp b/hls/ipv4/ipv4.hpp index e37d38d..8fc4b9e 100644 --- a/hls/ipv4/ipv4.hpp +++ b/hls/ipv4/ipv4.hpp @@ -619,7 +619,7 @@ class ipv4Header : public packetHeader { ipv4Header() { header(7, 0) = 0x45; // version & IHL - header(71, 64) = 0x64; // TTL + header(71, 64) = 0x32; // TTL } void setSrcAddr(const ap_uint<32>& addr) From c1f85bbf483bbdad6e103946886a55963722fe3c Mon Sep 17 00:00:00 2001 From: Cyril Pomsar Date: Tue, 9 Sep 2025 00:37:18 +0200 Subject: [PATCH 17/21] ECN now correctly marked on TX path --- hls/ipv4/ipv4.cpp | 12 +++++++----- hls/ipv4/ipv4.hpp | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/hls/ipv4/ipv4.cpp b/hls/ipv4/ipv4.cpp index 8de2395..3ae2326 100644 --- a/hls/ipv4/ipv4.cpp +++ b/hls/ipv4/ipv4.cpp @@ -191,6 +191,7 @@ void ipv4_generate_ipv4( stream& txEng_ipMetaDataFifoIn, ipv4Meta meta; net_axis currWord; ap_uint<16> length; + ap_uint<2> ecn; switch (gi_state) { @@ -208,13 +209,14 @@ void ipv4_generate_ipv4( stream& txEng_ipMetaDataFifoIn, // Set ECN and flags accordingly //MT_pomsarc changed outgoing ecn if its ack - header.setECN(3); - /*if(meta.is_marked_ack == 1){ + if(meta.is_marked_ack == 1){ //header.setECN(meta.ecn) - header.setECN(3); + ecn = 3; }else{ - header.setECN(1); - }*/ + ecn = 1; + } + + header.setECN(ecn); header.setFlags(1); if (IPV4_HEADER_SIZE >= WIDTH) diff --git a/hls/ipv4/ipv4.hpp b/hls/ipv4/ipv4.hpp index 8fc4b9e..bef9942 100644 --- a/hls/ipv4/ipv4.hpp +++ b/hls/ipv4/ipv4.hpp @@ -656,13 +656,13 @@ class ipv4Header : public packetHeader { // New function to set ECN void setECN(const ap_uint<2> ECN) { - header(9,8) = reverse(ECN); + header(9,8) = ECN; } //MT added function to return the 2-bit ecn field ap_uint<2> getECN() { - return reverse((ap_uint<2>)header(9,8)); + return (ap_uint<2>)header(9,8); } From ffd8b038b2b7145c266fed2dd9d706f24b8e7869 Mon Sep 17 00:00:00 2001 From: Cyril Pomsar Date: Fri, 12 Sep 2025 07:49:13 +0200 Subject: [PATCH 18/21] slight fix --- hls/ipv4/ipv4.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/hls/ipv4/ipv4.cpp b/hls/ipv4/ipv4.cpp index 3ae2326..a16f69b 100644 --- a/hls/ipv4/ipv4.cpp +++ b/hls/ipv4/ipv4.cpp @@ -90,6 +90,7 @@ void generate_ipv4( stream& txEng_ipMetaDataFifoIn, ipv4Meta meta; net_axis currWord; ap_uint<16> length; + ap_uint<2> ecn; switch (gi_state) { @@ -108,7 +109,7 @@ void generate_ipv4( stream& txEng_ipMetaDataFifoIn, // Set ECN and flags accordingly //MT_pomsarc changed outgoing ecn if its ack - header.setECN(3); + //header.setECN(3); /*if(meta.is_marked_ack == 1){ //header.setECN(meta.ecn) header.setECN(3); @@ -116,6 +117,15 @@ void generate_ipv4( stream& txEng_ipMetaDataFifoIn, header.setECN(2); }*/ + if(meta.is_marked_ack == 1){ + //header.setECN(meta.ecn) + ecn = 3; + }else{ + ecn = 2; + } + + header.setECN(ecn); + header.setFlags(2); From 4214e4c8652bfb8a63a38e52d37c00018fc9646c Mon Sep 17 00:00:00 2001 From: Cyril Pomsar Date: Fri, 31 Oct 2025 16:29:13 +0100 Subject: [PATCH 19/21] ... --- hls/ipv4/ipv4.cpp | 16 +++------------- hls/ipv4/ipv4.hpp | 2 +- hls/udp/udp.hpp | 2 +- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/hls/ipv4/ipv4.cpp b/hls/ipv4/ipv4.cpp index a16f69b..7fb0314 100644 --- a/hls/ipv4/ipv4.cpp +++ b/hls/ipv4/ipv4.cpp @@ -55,9 +55,9 @@ void process_ipv4( stream >& dataIn, { std::cout << "IP HEADER: src address: " << header.getSrcAddr() << ", length: " << header.getLength() << std::endl; process2dropLengthFifo.write(header.getHeaderLength() - headerWordsDropped); - //cHANGE THIS BACK - //MetaOut.write(ipv4Meta(header.getSrcAddr(), header.getLength(), header.getECN())); - MetaOut.write(ipv4Meta(header.getSrcAddr(), header.getLength(), 3)); + + MetaOut.write(ipv4Meta(header.getSrcAddr(), header.getLength(), header.getECN())); + //MetaOut.write(ipv4Meta(header.getSrcAddr(), header.getLength(), 3)); metaWritten = true; } } @@ -108,17 +108,7 @@ void generate_ipv4( stream& txEng_ipMetaDataFifoIn, // Set ECN and flags accordingly - //MT_pomsarc changed outgoing ecn if its ack - //header.setECN(3); - /*if(meta.is_marked_ack == 1){ - //header.setECN(meta.ecn) - header.setECN(3); - }else{ - header.setECN(2); - }*/ - if(meta.is_marked_ack == 1){ - //header.setECN(meta.ecn) ecn = 3; }else{ ecn = 2; diff --git a/hls/ipv4/ipv4.hpp b/hls/ipv4/ipv4.hpp index bef9942..19f4912 100644 --- a/hls/ipv4/ipv4.hpp +++ b/hls/ipv4/ipv4.hpp @@ -50,7 +50,7 @@ struct ipv4Meta :their_address(addr), length(len), ecn(e), is_marked_ack(is_ack) {} //for IPv6 TODO fix this in the future ipv4Meta(ap_uint<128> addr, ap_uint<16> len) - :their_address(addr(127,96)), length(len), ecn(3), is_marked_ack(0) {} + :their_address(addr(127,96)), length(len), ecn(0), is_marked_ack(0) {} }; template diff --git a/hls/udp/udp.hpp b/hls/udp/udp.hpp index 3b93753..07c370d 100644 --- a/hls/udp/udp.hpp +++ b/hls/udp/udp.hpp @@ -54,7 +54,7 @@ struct ipUdpMeta ap_uint<1> is_outgoing_ack; ipUdpMeta() {} ipUdpMeta(ap_uint<128> addr, ap_uint<16> tport, ap_uint<16> mport, ap_uint<16> len) - :their_address(addr), their_port(tport), my_port(mport), length(len), ecn(3), is_outgoing_ack(0) {} + :their_address(addr), their_port(tport), my_port(mport), length(len), ecn(0), is_outgoing_ack(0) {} ipUdpMeta(ap_uint<128> addr, ap_uint<16> tport, ap_uint<16> mport, ap_uint<16> len, ap_uint<2> e) :their_address(addr), their_port(tport), my_port(mport), length(len), ecn(e), is_outgoing_ack(0) {} ipUdpMeta(ap_uint<128> addr, ap_uint<16> tport, ap_uint<16> mport, ap_uint<16> len, ap_uint<2> e, ap_uint<1> is_ack) From e5c958140dcb5562d92e064447b8ffa4dd344fa6 Mon Sep 17 00:00:00 2001 From: pomsi <72771413+pomsi@users.noreply.github.com> Date: Mon, 17 Nov 2025 20:27:07 +0100 Subject: [PATCH 20/21] Update README.md --- README.md | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/README.md b/README.md index 350aa09..ea80f15 100644 --- a/README.md +++ b/README.md @@ -1,14 +1 @@ -Changed Files: -- ipv4.hpp: ipv4Meta struct, ipv4Header class -- ipv4.cpp: process_ipv4 function -- udp.hpp: ipUdpMeta struct, -- udp.cpp: merge_rx_meta function -- ib_transport_protocol.hpp: ackMeta struct -- ib_transport_protocol.cpp: rx_exh_fsm function (signal definition, DMA_META Case, DATA Case (2 ackmeta calls)), ipUdpMetaHandler function, signal definitions - - - -Notes: -- add same changes to ipv6 -- decouple tx and rx meta interfaces - +Readme at: https://github.com/pomsi/Coyote/tree/tutorial From 11c406bd72e44ac2355a11fc14e22c1215815f43 Mon Sep 17 00:00:00 2001 From: pomsi <72771413+pomsi@users.noreply.github.com> Date: Mon, 17 Nov 2025 20:28:04 +0100 Subject: [PATCH 21/21] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ea80f15..e86f167 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -Readme at: https://github.com/pomsi/Coyote/tree/tutorial +Readme at: https://github.com/pomsi/Coyote/tree/tutorial/examples/Congestion_Control_Test