cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
IPTX

IP Transmitter packet handler (IPTX) of the Network Transport Stack (NTS). More...

Collaboration diagram for IPTX:

Modules

 IPTX_TEST
 Testbench for the IP Transmitter packet handler (IPTX) of the Network Transport Stack (NTS).
 

Files

file  test_iptx.cpp
 : Testbench for the IP Transmit frame handler (IPTX).
 
file  test_iptx.hpp
 : Testbench for the IP Transmitter packet handler (IPTX).
 

Macros

#define THIS_NAME   "IPTX"
 
#define TRACE_OFF   0x0000
 
#define TRACE_ICA   1 << 1
 
#define TRACE_ICI   1 << 2
 
#define TRACE_IAE   1 << 3
 
#define TRACE_MAI   1 << 4
 
#define TRACE_ALL   0xFFFF
 
#define DEBUG_LEVEL   (TRACE_OFF)
 

Functions

void pHeaderChecksumAccumulator (stream< AxisIp4 > &siL3MUX_Data, stream< AxisIp4 > &soICi_Data, stream< Ip4HdrCsum > &soICi_Csum)
 
void pIpChecksumInsert (stream< AxisIp4 > &siHCa_Data, stream< Ip4HdrCsum > &siHCa_Csum, stream< AxisIp4 > &soIAe_Data)
 
void pIp4AddressExtractor (Ip4Addr piMMIO_SubNetMask, Ip4Addr piMMIO_GatewayAddr, stream< AxisIp4 > &siICi_Data, stream< AxisIp4 > &soMAi_Data, stream< Ip4Addr > &soARP_LookupReq)
 
void pMacAddressInserter (EthAddr piMMIO_MacAddress, stream< AxisIp4 > &siIAe_Data, stream< ArpLkpReply > &siARP_LookupRsp, stream< AxisEth > &soL2MUX_Data)
 
void iptx (EthAddr piMMIO_MacAddress, Ip4Addr piMMIO_SubNetMask, Ip4Addr piMMIO_GatewayAddr, stream< AxisIp4 > &siL3MUX_Data, stream< AxisEth > &soL2MUX_Data, stream< Ip4Addr > &soARP_LookupReq, stream< ArpLkpReply > &siARP_LookupRep)
 Main process of the IP Transmitter Handler (IPTX). More...
 
void iptx_top (EthAddr piMMIO_MacAddress, Ip4Addr piMMIO_SubNetMask, Ip4Addr piMMIO_GatewayAddr, stream< AxisRaw > &siL3MUX_Data, stream< AxisRaw > &soL2MUX_Data, stream< Ip4Addr > &soARP_LookupReq, stream< ArpLkpReply > &siARP_LookupRep)
 Top of IP Transmitter Handler (IPTX) More...
 

Variables

bool gTraceEvent
 

Detailed Description

IP Transmitter packet handler (IPTX) of the Network Transport Stack (NTS).

Macro Definition Documentation

◆ DEBUG_LEVEL

#define DEBUG_LEVEL   (TRACE_OFF)

Definition at line 77 of file iptx.cpp.

◆ THIS_NAME

#define THIS_NAME   "IPTX"

Definition at line 68 of file iptx.cpp.

◆ TRACE_ALL

#define TRACE_ALL   0xFFFF

Definition at line 75 of file iptx.cpp.

◆ TRACE_IAE

#define TRACE_IAE   1 << 3

Definition at line 73 of file iptx.cpp.

◆ TRACE_ICA

#define TRACE_ICA   1 << 1

Definition at line 71 of file iptx.cpp.

◆ TRACE_ICI

#define TRACE_ICI   1 << 2

Definition at line 72 of file iptx.cpp.

◆ TRACE_MAI

#define TRACE_MAI   1 << 4

Definition at line 74 of file iptx.cpp.

◆ TRACE_OFF

#define TRACE_OFF   0x0000

Definition at line 70 of file iptx.cpp.

Function Documentation

◆ iptx()

void iptx ( EthAddr  piMMIO_MacAddress,
Ip4Addr  piMMIO_SubNetMask,
Ip4Addr  piMMIO_GatewayAddr,
stream< AxisIp4 > &  siL3MUX_Data,
stream< AxisEth > &  soL2MUX_Data,
stream< Ip4Addr > &  soARP_LookupReq,
stream< ArpLkpReply > &  siARP_LookupRep 
)

Main process of the IP Transmitter Handler (IPTX).

Parameters
[in]piMMIO_MacAddressThe MAC address from MMIO (in network order).
[in]piMMIO_SubNetMaskThe sub-network-mask from [MMIO].
[in]piMMIO_GatewayAddrThe default gateway address from [MMIO].
[in]siL3MUX_DataThe IP4 data stream from the L3 Multiplexer (L3MUX).
[out]soL2MUX_DataThe ETH data stream to the L2 Multiplexer (L2MUX).
[out]soARP_LookupReqThe IP4 address lookup request to AddressResolutionProtocol (ARP).
[in]siARP_LookupRepThe MAC address looked-up from [ARP].

: This process receives IP packets from the TCP-offload-engine (TOE), the Internet Control Message Protocol (ICMP) engine or the UDP Offload Engine (UOE). It first computes the IP header checksum and inserts it into the IP packet. Next, it extracts the IP_DA from the incoming data stream and forwards it to the Address Resolution Protocol server (ARP) in order to look up the corresponding MAC address. Final, an Ethernet header is created and is prepended to the outgoing IPv4 packet.

Definition at line 530 of file iptx.cpp.

550 {
551  //-- DIRECTIVES FOR THE INTERFACES -----------------------------------------
552  #pragma HLS DATAFLOW
553  #pragma HLS INLINE
554  #pragma HLS INTERFACE ap_ctrl_none port=return
555 
556  //--------------------------------------------------------------------------
557  //-- LOCAL STREAMS (Sorted by the name of the modules which generate them)
558  //--------------------------------------------------------------------------
559 
560  //-- Header Checksum Accumulator (HCa)
561  static stream<AxisIp4> ssHCaToICi_Data ("ssHCaToICi_Data");
562  #pragma HLS STREAM variable=ssHCaToICi_Data depth=1024 // Must hold one IP header for checksum computation
563  #pragma HLS DATA_PACK variable=ssHCaToICi_Data // [FIXME -We only need to store 20 to 24+ bytes]
564 
565  static stream<Ip4HdrCsum> ssHCaToICi_Csum ("ssHCaToICi_Csum");
566  #pragma HLS STREAM variable=ssHCaToICi_Csum depth=16
567 
568  //-- IP Checksum Inserter (ICi)
569  static stream<AxisIp4> ssICiToIAe_Data ("ssICiToIAe_Data");
570  #pragma HLS STREAM variable=ssICiToIAe_Data depth=16
571  #pragma HLS DATA_PACK variable=ssICiToIAe_Data
572 
573  //-- IP Address Extractor (IAe)
574  static stream<AxisIp4> ssIAeToMAi_Data ("ssIAeToMAi_Data");
575  #pragma HLS STREAM variable=ssIAeToMAi_Data depth=16
576  #pragma HLS DATA_PACK variable=ssIAeToMAi_Data
577 
578  //-- PROCESS FUNCTIONS -----------------------------------------------------
579 
581  siL3MUX_Data,
582  ssHCaToICi_Data,
583  ssHCaToICi_Csum);
584 
586  ssHCaToICi_Data,
587  ssHCaToICi_Csum,
588  ssICiToIAe_Data);
589 
591  piMMIO_SubNetMask,
592  piMMIO_GatewayAddr,
593  ssICiToIAe_Data,
594  ssIAeToMAi_Data,
595  soARP_LookupReq);
596 
598  piMMIO_MacAddress,
599  ssIAeToMAi_Data,
600  siARP_LookupRep,
601  soL2MUX_Data);
602 }
void pHeaderChecksumAccumulator(stream< AxisIp4 > &siL3MUX_Data, stream< AxisIp4 > &soICi_Data, stream< Ip4HdrCsum > &soICi_Csum)
Definition: iptx.cpp:107
void pIpChecksumInsert(stream< AxisIp4 > &siHCa_Data, stream< Ip4HdrCsum > &siHCa_Csum, stream< AxisIp4 > &soIAe_Data)
Definition: iptx.cpp:255
void pIp4AddressExtractor(Ip4Addr piMMIO_SubNetMask, Ip4Addr piMMIO_GatewayAddr, stream< AxisIp4 > &siICi_Data, stream< AxisIp4 > &soMAi_Data, stream< Ip4Addr > &soARP_LookupReq)
Definition: iptx.cpp:320
void pMacAddressInserter(EthAddr piMMIO_MacAddress, stream< AxisIp4 > &siIAe_Data, stream< ArpLkpReply > &siARP_LookupRsp, stream< AxisEth > &soL2MUX_Data)
Definition: iptx.cpp:379
Here is the call graph for this function:
Here is the caller graph for this function:

◆ iptx_top()

void iptx_top ( EthAddr  piMMIO_MacAddress,
Ip4Addr  piMMIO_SubNetMask,
Ip4Addr  piMMIO_GatewayAddr,
stream< AxisRaw > &  siL3MUX_Data,
stream< AxisRaw > &  soL2MUX_Data,
stream< Ip4Addr > &  soARP_LookupReq,
stream< ArpLkpReply > &  siARP_LookupRep 
)

Top of IP Transmitter Handler (IPTX)

Parameters
[in]piMMIO_MacAddressThe MAC address from MMIO (in network order).
[in]piMMIO_SubNetMaskThe sub-network-mask from [MMIO].
[in]piMMIO_GatewayAddrThe default gateway address from [MMIO].
[in]siL3MUX_DataThe IP4 data stream from the L3 Multiplexer (L3MUX).
[out]soL2MUX_DataThe ETH data stream to the L2 Multiplexer (L2MUX).
[out]soARP_LookupReqThe IP4 address lookup request to AddressResolutionProtocol (ARP).
[in]siARP_LookupRepThe MAC address looked-up from [ARP].

ENTITY - IP TX HANDLER (IPTX)

Definition at line 676 of file iptx.cpp.

696 {
697  //-- DIRECTIVES FOR THE INTERFACES -----------------------------------------
698  #pragma HLS INTERFACE ap_ctrl_none port=return
699 
700  #pragma HLS INTERFACE ap_stable port=piMMIO_MacAddress
701  #pragma HLS INTERFACE ap_stable port=piMMIO_SubNetMask
702  #pragma HLS INTERFACE ap_stable port=piMMIO_GatewayAddr
703 
704  #pragma HLS INTERFACE axis off port=siL3MUX_Data
705  #pragma HLS INTERFACE axis register both port=soL2MUX_Data
706 
707  #pragma HLS INTERFACE axis off port=soARP_LookupReq
708  #pragma HLS INTERFACE axis off port=siARP_LookupRep
709  #pragma HLS DATA_PACK variable=siARP_LookupRep
710 
711  //-- DIRECTIVES FOR THIS PROCESS -------------------------------------------
712  #pragma HLS DATAFLOW disable_start_propagation
713 
714  //-- LOCAL INPUT and OUTPUT STREAMS ----------------------------------------
715  static stream<AxisIp4> ssiL3MUX_Data ("ssiL3MUX_Data");
716  #pragma HLS STREAM variable=ssiL3MUX_Data depth=8
717  static stream<AxisEth> ssoL2MUX_Data ("ssoL2MUX_Data");
718 
719  //-- INPUT STREAM CASTING --------------------------------------------------
720  pAxisRawCast(siL3MUX_Data, ssiL3MUX_Data);
721 
722  //-- MAIN IPTX PROCESS -----------------------------------------------------
723  iptx(
724  //-- MMIO Interfaces
725  piMMIO_MacAddress,
726  piMMIO_SubNetMask,
727  piMMIO_GatewayAddr,
728  //-- L3MUX Interface
729  ssiL3MUX_Data,
730  //-- L2MUX Interface
731  ssoL2MUX_Data,
732  //-- ARP Interface
733  soARP_LookupReq,
734  siARP_LookupRep);
735 
736  //-- OUTPUT STREAM CASTING -------------------------------------------------
737  pAxisRawCast(ssoL2MUX_Data, soL2MUX_Data);
738 
739 }
void iptx(EthAddr piMMIO_MacAddress, Ip4Addr piMMIO_SubNetMask, Ip4Addr piMMIO_GatewayAddr, stream< AxisIp4 > &siL3MUX_Data, stream< AxisEth > &soL2MUX_Data, stream< Ip4Addr > &soARP_LookupReq, stream< ArpLkpReply > &siARP_LookupRep)
Main process of the IP Transmitter Handler (IPTX).
Definition: iptx.cpp:530
void pAxisRawCast(hls::stream< TypeIn > &si, hls::stream< TypeOut > &so)
AxisRaw cast - Casts an AxisRaw stream to/from an AxisRaw derived class.
Definition: AxisRaw.hpp:148
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pHeaderChecksumAccumulator()

void pHeaderChecksumAccumulator ( stream< AxisIp4 > &  siL3MUX_Data,
stream< AxisIp4 > &  soICi_Data,
stream< Ip4HdrCsum > &  soICi_Csum 
)

IPv4 Header Checksum Accumulator (HCa)

Parameters
[in]siL3MUX_DataData stream from the L3 Multiplexer (L3MUX).
[out]soICi_DataData stream to the IpChecksumInserter (ICi).
[out]soICi_CsumIP header checksum.

This process computes the IPv4 header checksum and forwards it to the next process which will insert it into the header of the incoming packet.

@Warning The IP header is formatted for transmission over a 64-bits interface which is logically divided into 8 lanes, with lane[0]=bits(7:0) and lane[7]=bits(63:56). The format of the incoming IPv4 header is then:

   6                   5                   4                   3                   2                   1                   0

3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Frag Ofst (L) |Flags| FO(H) | Ident (L) | Ident (H) | Total Len (L) | Total Len (H) |Type of Service|Version| IHL | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SA (LL) | SA (L) | SA (H) | SA (HH) | Hd Chksum (L) | Hd Chksum (H) | Protocol | Time to Live | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Options | DA (LL) | DA (L) | DA (H) | DA (HH) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Definition at line 107 of file iptx.cpp.

111 {
112  //-- DIRECTIVES FOR THIS PROCESS ------------------------------------------
113  #pragma HLS INLINE off
114  #pragma HLS PIPELINE II=1 enable_flush
115 
116  const char *myName = concat3(THIS_NAME, "/", "HCa");
117 
118  //-- STATIC CONTROL VARIABLES (with RESET) --------------------------------
119  static bool hca_csumWritten=true;
120  #pragma HLS RESET variable=hca_csumWritten
121  static enum FsmState {S0=0, S1, S2, S3} hca_fsmState=S0;
122  #pragma HLS RESET variable=hca_fsmState
123  static ap_uint<17> hca_ipHdrCsum[4]={0, 0, 0, 0};
124  #pragma HLS RESET variable=hca_ipHdrCsum
125  #pragma HLS ARRAY_PARTITION variable=hca_ipHdrCsum complete dim=1
126  static ap_uint<3> hca_chunkCount=0;
127  #pragma HLS RESET variable=hca_chunkCount
128 
129  //-- STATIC DATAFLOW VARIABLES --------------------------------------------
130  static ap_uint<4> hca_ipHdrLen;
131 
132  //-- DYNAMIC VARIABLES ----------------------------------------------------
133  AxisIp4 currChunk;
134  Ip4HdrCsum tempHdrCsum;
135 
136  currChunk.setLE_TLast(0);
137  if(!hca_csumWritten) {
138  switch (hca_fsmState) {
139  case S0:
140  hca_ipHdrCsum[0] += hca_ipHdrCsum[2];
141  hca_ipHdrCsum[1] += hca_ipHdrCsum[3];
142  hca_ipHdrCsum[0] = (hca_ipHdrCsum[0] + (hca_ipHdrCsum[0] >> 16)) & 0xFFFF;
143  hca_ipHdrCsum[1] = (hca_ipHdrCsum[1] + (hca_ipHdrCsum[1] >> 16)) & 0xFFFF;
144  hca_fsmState = S1;
145  break;
146  case S1:
147  hca_ipHdrCsum[0] += hca_ipHdrCsum[1];
148  hca_ipHdrCsum[0] = (hca_ipHdrCsum[0] + (hca_ipHdrCsum[0] >> 16)) & 0xFFFF;
149  hca_fsmState = S2;
150  break;
151  case S2:
152  hca_ipHdrCsum[0] = ~hca_ipHdrCsum[0];
153  soICi_Csum.write(hca_ipHdrCsum[0](15, 0));
154  hca_fsmState = S3;
155  break;
156  case S3:
157  hca_ipHdrCsum[0] = 0;
158  hca_ipHdrCsum[1] = 0;
159  hca_ipHdrCsum[2] = 0;
160  hca_ipHdrCsum[3] = 0;
161  hca_csumWritten = true;
162  hca_fsmState = S0;
163  break;
164  }
165  }
166  else if (!siL3MUX_Data.empty() and !soICi_Data.full() and hca_csumWritten) {
167  siL3MUX_Data.read(currChunk);
168  // Process the IPv4 header.
169  // Remember that the Internet Header Length (IHL) field contains the
170  // size of the IPv4 header specified in number of 32-bit words, and
171  // its default minimum value is 5.
172  switch (hca_chunkCount) {
173  case 0:
174  hca_ipHdrLen = currChunk.getIp4HdrLen();
175  //-- Accumulate 1st IPv4 header qword [Frag|Ident|TotLen|ToS|IHL]
176  for (int i=0; i<4; i++) {
177  #pragma HLS UNROLL
178  tempHdrCsum( 7, 0) = currChunk.getLE_TData().range(i*16+15, i*16+8);
179  tempHdrCsum(15, 8) = currChunk.getLE_TData().range(i*16+7, i*16);
180  hca_ipHdrCsum[i] += tempHdrCsum;
181  hca_ipHdrCsum[i] = (hca_ipHdrCsum[i] + (hca_ipHdrCsum[i] >> 16)) & 0xFFFF;
182  }
183  hca_chunkCount++;
184  hca_ipHdrLen -= 2;
185  break;
186  case 1:
187  //-- Accumulate 2nd IPv4 header qword [SA|HdCsum|Prot|TTL]
188  for (int i=0; i<4; i++) {
189  #pragma HLS UNROLL
190  if (i != 1) {
191  // Skip 3rd and 4th bytes. They contain the IP header checksum.
192  tempHdrCsum( 7, 0) = currChunk.getLE_TData().range(i*16+15, i*16+8);
193  tempHdrCsum(15, 8) = currChunk.getLE_TData().range(i*16+7, i*16);
194  hca_ipHdrCsum[i] += tempHdrCsum;
195  hca_ipHdrCsum[i] = (hca_ipHdrCsum[i] + (hca_ipHdrCsum[i] >> 16)) & 0xFFFF;
196  }
197  }
198  hca_chunkCount++;
199  hca_ipHdrLen -= 2;
200  break;
201  default:
202  switch (hca_ipHdrLen) {
203  case 0:
204  //-- We are done with the checksum header processing
205  break;
206  case 1:
207  //-- Accumulate half of the 3rd IPv4 header qword [DA] or
208  //-- Accumulate the last IPv4 option dword
209  for (int i = 0; i < 2; i++) {
210  #pragma HLS UNROLL
211  tempHdrCsum( 7, 0) = currChunk.getLE_TData().range(i*16+15, i*16+8);
212  tempHdrCsum(15, 8) = currChunk.getLE_TData().range(i*16+7, i*16);
213  hca_ipHdrCsum[i] += tempHdrCsum;
214  hca_ipHdrCsum[i] = (hca_ipHdrCsum[i] + (hca_ipHdrCsum[i] >> 16)) & 0xFFFF;
215  }
216  hca_ipHdrLen = 0;
217  hca_csumWritten = false;
218  break;
219  default:
220  // Sum up everything
221  for (int i = 0; i < 4; i++) {
222  #pragma HLS UNROLL
223  tempHdrCsum( 7, 0) = currChunk.getLE_TData().range(i*16+15, i*16+8);
224  tempHdrCsum(15, 8) = currChunk.getLE_TData().range(i*16+7, i*16);
225  hca_ipHdrCsum[i] += tempHdrCsum;
226  hca_ipHdrCsum[i] = (hca_ipHdrCsum[i] + (hca_ipHdrCsum[i] >> 16)) & 0xFFFF;
227  }
228  hca_ipHdrLen -= 2;
229  if (hca_ipHdrLen == 0) {
230  hca_csumWritten = false;
231  }
232  break;
233  } // End-of: switch ipHeaderLen
234  break;
235  } // End-of: switch(hca_chunkCount)
236  soICi_Data.write(currChunk);
237  if (currChunk.getLE_TLast()) {
238  hca_chunkCount = 0;
239  }
240  }
241 }
Ip4HdrLen getIp4HdrLen()
Definition: AxisIp4.hpp:199
LE_tData getLE_TData(int leHi=64 -1, int leLo=0) const
Definition: AxisRaw.hpp:260
void setLE_TLast(LE_tLast last)
Definition: AxisRaw.hpp:280
LE_tLast getLE_TLast() const
Definition: AxisRaw.hpp:268
#define THIS_NAME
Definition: iptx.cpp:68
ap_uint< 16 > Ip4HdrCsum
Definition: AxisIp4.hpp:165
#define concat3(firstCharConst, secondCharConst, thirdCharConst)
Definition: nts_utils.hpp:161
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pIp4AddressExtractor()

void pIp4AddressExtractor ( Ip4Addr  piMMIO_SubNetMask,
Ip4Addr  piMMIO_GatewayAddr,
stream< AxisIp4 > &  siICi_Data,
stream< AxisIp4 > &  soMAi_Data,
stream< Ip4Addr > &  soARP_LookupReq 
)

IPv4 Address Extractor (IAe)

Parameters
[in]piMMIO_SubNetMaskThe sub-network-mask from [MMIO].
[in]piMMIO_GatewayAddrThedefault gateway address from [MMIO].
[in]siICi_DataThe data stream from IpChecksumInserter ICi).
[out]soMAi_DataThe data stream to MacAddressInserter (MAi).
[out]soARP_LookupReqIPv4 address lookup request to [ARP].

This process extracts the IP destination address from the incoming stream and forwards it to the Address Resolution Protocol server (ARP) in order to look up the corresponding MAC address.

Definition at line 320 of file iptx.cpp.

326 {
327  //-- DIRECTIVES FOR THIS PROCESS -------------------------------------------
328  #pragma HLS INLINE off
329  #pragma HLS PIPELINE II=1 enable_flush
330 
331  const char *myName = concat3(THIS_NAME, "/", "IAe");
332 
333  //-- STATIC CONTROL VARIABLES (with RESET) ---------------------------------
334  static ap_uint<2> iae_chunkCount=0;
335  #pragma HLS RESET variable=iae_chunkCount
336 
337  //-- DYNAMIC VARIABLES -----------------------------------------------------
338  Ip4Addr ipDestAddr;
339 
340  if (!siICi_Data.empty() and !soMAi_Data.full()) {
341  AxisIp4 currChunk = siICi_Data.read();
342  switch (iae_chunkCount) {
343  case 2: // Extract destination IP address
344  ipDestAddr = currChunk.getIp4DstAddr();
345  if ((ipDestAddr & piMMIO_SubNetMask) == (piMMIO_GatewayAddr & piMMIO_SubNetMask)
346  || (ipDestAddr == 0xFFFFFFFF)) {
347  soARP_LookupReq.write(ipDestAddr);
348  }
349  else {
350  soARP_LookupReq.write(piMMIO_GatewayAddr);
351  }
352  iae_chunkCount++;
353  break;
354  default:
355  if (currChunk.getLE_TLast()) {
356  iae_chunkCount = 0;
357  }
358  else if (iae_chunkCount < 3) {
359  iae_chunkCount++;
360  }
361  break;
362  } // End-of: switch()
363  soMAi_Data.write(currChunk);
364  }
365 }
Ip4Addr getIp4DstAddr()
Definition: AxisIp4.hpp:230
ap_uint< 32 > Ip4Addr
Definition: AxisIp4.hpp:169
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pIpChecksumInsert()

void pIpChecksumInsert ( stream< AxisIp4 > &  siHCa_Data,
stream< Ip4HdrCsum > &  siHCa_Csum,
stream< AxisIp4 > &  soIAe_Data 
)

IP Checksum Inserter (ICi)

Parameters
[in]siHCa_DataThe data stream from HeaderChecksumAccumulator (HCa).
[in]siHCa_CsumThe computed IP header checksum from [HCa].
[out]soIAe_DataThe data stream to IpAddressExtratcor (IAe).

This process inserts the computed IP header checksum in the IPv4 packet being streamed on the data interface.

Definition at line 255 of file iptx.cpp.

259 {
260  //-- DIRECTIVES FOR THIS PROCESS -------------------------------------------
261  #pragma HLS INLINE off
262  #pragma HLS PIPELINE II=1 enable_flush
263 
264  const char *myName = concat3(THIS_NAME, "/", "ICi");
265 
266  //-- STATIC CONTROL VARIABLES (with RESET) ---------------------------------
267  static enum FsmStates { S0=0, S1, S2 } ici_fsmState=S0;
268  #pragma HLS RESET variable=ici_fsmState
269 
270  //-- DYNAMIC VARIABLES -----------------------------------------------------
271  AxisIp4 currChunk;
272  Ip4HdrCsum ipHdrChecksum;
273 
274  currChunk.setLE_TLast(0);
275  switch (ici_fsmState) {
276  case S0:
277  if (!siHCa_Data.empty() and !soIAe_Data.full()) {
278  siHCa_Data.read(currChunk);
279  soIAe_Data.write(currChunk);
280  ici_fsmState = S1;
281  }
282  break;
283  case S1:
284  if (!siHCa_Data.empty() and !siHCa_Csum.empty() and !soIAe_Data.full()) {
285  siHCa_Data.read(currChunk);
286  siHCa_Csum.read(ipHdrChecksum);
287  // Insert the computed ipHeaderChecksum in the incoming stream
288  currChunk.setIp4HdrCsum(ipHdrChecksum);
289  soIAe_Data.write(currChunk);
290  ici_fsmState = S2;
291  }
292  break;
293  default:
294  if (!siHCa_Data.empty() and !soIAe_Data.full()) {
295  siHCa_Data.read(currChunk);
296  soIAe_Data.write(currChunk);
297  }
298  break;
299  } // End-of: switch()
300 
301  if (currChunk.getLE_TLast()) {
302  ici_fsmState = S0;
303  }
304 }
void setIp4HdrCsum(Ip4HdrCsum csum)
Definition: AxisIp4.hpp:223
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pMacAddressInserter()

void pMacAddressInserter ( EthAddr  piMMIO_MacAddress,
stream< AxisIp4 > &  siIAe_Data,
stream< ArpLkpReply > &  siARP_LookupRsp,
stream< AxisEth > &  soL2MUX_Data 
)

MAC Address Inserter (MAi)

Parameters
[in]piMMIO_MacAddressMy Ethernet MAC address from [MMIO].
[in]siIAe_DataThe data stream from IpAddressExtractor (IAe).
[out]siARP_LookupRspMAC address looked-up from [ARP].
[in]soL2MUX_DataThe data stream to [L2MUX].

This process prepends the appropriate Ethernet header to the outgoing IPv4 packet.

Definition at line 379 of file iptx.cpp.

384 {
385  //-- DIRECTIVES FOR THIS PROCESS -------------------------------------------
386  #pragma HLS INLINE off
387  #pragma HLS PIPELINE II=1 enable_flush
388 
389  const char *myName = concat3(THIS_NAME, "/", "MAi");
390 
391  //-- STATIC CONTROL VARIABLES (with RESET) ---------------------------------
392  static enum FsmStates {FSM_MAI_WAIT_LOOKUP=0, FSM_MAI_DROP, FSM_MAI_WRITE,
393  FSM_MAI_WRITE_FIRST, FSM_MAI_WRITE_LAST} \
394  mai_fsmState=FSM_MAI_WAIT_LOOKUP;
395  #pragma HLS RESET variable=mai_fsmState
396 
397  //-- STATIC DATAFLOW VARIABLES ---------------------------------------------
398  static AxisIp4 mai_prevChunk;
399 
400  //-- DYNAMIC VARIABLES -----------------------------------------------------
401  AxisEth sendChunk;
402  AxisIp4 currChunk;
403  ArpLkpReply arpResponse;
404  EthAddr macDstAddr;
405 
406  currChunk.setLE_TLast(0);
407  switch (mai_fsmState) {
408  case FSM_MAI_WAIT_LOOKUP:
409  if (!siARP_LookupRsp.empty() and !soL2MUX_Data.full()) {
410  siARP_LookupRsp.read(arpResponse);
411  macDstAddr = arpResponse.macAddress;
412  if (arpResponse.hit) {
413  sendChunk.setEthDstAddr(macDstAddr);
414  sendChunk.setEthSrcAddrHi(piMMIO_MacAddress);
415  sendChunk.setLE_TKeep(0xff);
416  sendChunk.setLE_TLast(0);
417  soL2MUX_Data.write(sendChunk);
418  mai_fsmState = FSM_MAI_WRITE_FIRST;
419  if (DEBUG_LEVEL & TRACE_MAI) {
420  printInfo(myName, "FSM_MAI_WAIT_LOOKUP - Lookup=HIT - Received MAC = 0x%12.12lX\n",
421  arpResponse.macAddress.to_ulong());
422  printAxisRaw(myName, "Forwarding AxisChunk to [L2MUX]: ", sendChunk);
423  }
424  }
425  else { // Drop it all, wait for RT
426  mai_fsmState = FSM_MAI_DROP;
427  if (DEBUG_LEVEL & TRACE_MAI) {
428  printInfo(myName, "FSM_MAI_WAIT_LOOKUP - Lookup=NO-HIT. \n");
429  }
430  }
431  }
432  break;
433  case FSM_MAI_WRITE_FIRST:
434  if (DEBUG_LEVEL & TRACE_MAI) { printInfo(myName, "FSM_MAI_WRITE_FIRST - \n"); }
435  if (!siIAe_Data.empty() and !soL2MUX_Data.full()) {
436  siIAe_Data.read(currChunk);
437  sendChunk.setEthSrcAddrLo(piMMIO_MacAddress);
438  sendChunk.setEthTypeLen(0x0800);
439  sendChunk.setIp4HdrLen(currChunk.getIp4HdrLen());
440  sendChunk.setIp4Version(currChunk.getIp4Version());
441  sendChunk.setIp4ToS(currChunk.getIp4ToS());
442  sendChunk.setLE_TKeep(0xff);
443  sendChunk.setLE_TLast(0);
444  soL2MUX_Data.write(sendChunk);
445  mai_prevChunk = currChunk;
446  mai_fsmState = FSM_MAI_WRITE;
447  }
448  break;
449  case FSM_MAI_WRITE:
450  if (DEBUG_LEVEL & TRACE_MAI) { printInfo(myName, "FSM_MAI_WRITE - \n"); }
451  if (!siIAe_Data.empty() and !soL2MUX_Data.full()) {
452  siIAe_Data.read(currChunk);
453  sendChunk.setLE_TData(mai_prevChunk.getLE_TData(63, 16), 47, 0);
454  sendChunk.setLE_TData( currChunk.getLE_TData(15, 0), 63, 48);
455  sendChunk.setLE_TKeep(mai_prevChunk.getLE_TKeep( 7, 2), 5, 0);
456  sendChunk.setLE_TKeep( currChunk.getLE_TKeep( 1, 0), 7, 6);
457  if (currChunk.getLE_TKeep()[2] == 0) {
458  sendChunk.setLE_TLast(TLAST);
459  }
460  else {
461  sendChunk.setLE_TLast(0);
462  }
463  soL2MUX_Data.write(sendChunk);
464  if (DEBUG_LEVEL & TRACE_MAI) {
465  printAxisRaw(myName, "Forwarding AxisChunk to [L2MUX]: ", sendChunk);
466  }
467  mai_prevChunk = currChunk;
468  if (currChunk.getLE_TLast()) {
469  if (currChunk.getLE_TKeep()[2] == 0) {
470  mai_fsmState = FSM_MAI_WAIT_LOOKUP;
471  }
472  else {
473  mai_fsmState = FSM_MAI_WRITE_LAST;
474  }
475  }
476  else {
477  mai_fsmState = FSM_MAI_WRITE;
478  }
479  }
480  break;
481  case FSM_MAI_WRITE_LAST:
482  if (DEBUG_LEVEL & TRACE_MAI) { printInfo(myName, "FSM_MAI_WRITE_LAST - \n"); }
483  if (!soL2MUX_Data.full()) {
484  sendChunk.setLE_TData(mai_prevChunk.getLE_TData(63, 16), 47, 0);
485  sendChunk.setLE_TData( 0, 63, 48);
486  sendChunk.setLE_TKeep(mai_prevChunk.getLE_TKeep( 7, 2), 5, 0);
487  sendChunk.setLE_TKeep( 0, 7, 6);
488  sendChunk.setLE_TLast(TLAST);
489  soL2MUX_Data.write(sendChunk);
490  if (DEBUG_LEVEL & TRACE_MAI) {
491  printAxisRaw(myName, "Forwarding AxisChunk to [L2MUX]: ", sendChunk);
492  }
493  mai_fsmState = FSM_MAI_WAIT_LOOKUP;
494  }
495  break;
496  case FSM_MAI_DROP:
497  if (DEBUG_LEVEL & TRACE_MAI) { printInfo(myName, "FSM_MAI_DROP - \n"); }
498  if (!siIAe_Data.empty() and !soL2MUX_Data.full()) {
499  siIAe_Data.read(currChunk);
500  if (currChunk.getLE_TLast()) {
501  mai_fsmState = FSM_MAI_WAIT_LOOKUP;
502  }
503  }
504  break;
505 
506  } // End-of: switch()
507 
508 } // End-of: pMacAddressInserter
EthAddr macAddress
Definition: nts_types.hpp:351
HitBool hit
Definition: nts_types.hpp:352
void setEthDstAddr(EthAddr addr)
Definition: AxisEth.hpp:159
void setIp4Version(Ip4Version ver)
Definition: AxisEth.hpp:233
void setEthSrcAddrHi(EthAddr addr)
Definition: AxisEth.hpp:163
void setEthSrcAddrLo(EthAddr addr)
Definition: AxisEth.hpp:166
void setEthTypeLen(EthTypeLen eTyLe)
Definition: AxisEth.hpp:169
void setIp4ToS(Ip4ToS tos)
Definition: AxisEth.hpp:239
void setIp4HdrLen(Ip4HdrLen ihl)
Definition: AxisEth.hpp:236
Ip4Version getIp4Version()
Definition: AxisIp4.hpp:196
Ip4ToS getIp4ToS()
Definition: AxisIp4.hpp:202
LE_tKeep getLE_TKeep(int leHi=64/8-1, int leLo=0) const
Definition: AxisRaw.hpp:264
void setLE_TData(LE_tData data, int leHi=64 -1, int leLo=0)
Definition: AxisRaw.hpp:272
void setLE_TKeep(LE_tKeep keep, int leHi=64/8-1, int leLo=0)
Definition: AxisRaw.hpp:276
#define TRACE_MAI
Definition: iptx.cpp:74
#define DEBUG_LEVEL
Definition: iptx.cpp:77
ap_uint< 48 > EthAddr
Definition: AxisEth.hpp:120
void printAxisRaw(const char *callerName, AxisRaw chunk)
Prints an Axis raw data chunk (used for debugging).
Definition: nts_utils.cpp:46
#define printInfo(callerName, format,...)
A macro to print an information message.
Definition: nts_utils.hpp:169
#define TLAST
Definition: AxisRaw.hpp:116
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ gTraceEvent

bool gTraceEvent
extern

HELPERS FOR THE DEBUGGING TRACES .e.g: DEBUG_LEVEL = (TRACE_MAI | TRACE_ICA)

HELPERS FOR THE DEBUGGING TRACES .e.g: DEBUG_LEVEL = (MDL_TRACE | IPS_TRACE)

Definition at line 151 of file tb_nal.cpp.