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

Address Resolution Protocol (ARS) server of the Network Transport Stack (NTS). More...

Collaboration diagram for ARP:

Modules

 ARP_TEST
 Testbench for the Address Resolution Protocol (ARS) server of the Network Transport Stack (NTS).
 

Files

file  test_arp.cpp
 : Testbench for the Address Resolution Protocol (ARP) server.
 
file  test_arp.cpp
 : Testbench for the Address Resolution Protocol (ARP) server.
 

Classes

class  ArpMeta
 
class  RtlMacUpdateRequest
 
class  RtlMacUpdateReply
 
class  RtlMacLookupRequest
 
class  RtlMacLookupReply
 

Macros

#define USE_DEPRECATED_DIRECTIVES
 
#define THIS_NAME   "ARP"
 
#define TRACE_OFF   0x0000
 
#define TRACE_APR   1 << 1
 
#define TRACE_APS   1 << 2
 
#define TRACE_ACC   1 << 3
 
#define TRACE_ALL   0xFFFF
 
#define DEBUG_LEVEL   (TRACE_OFF)
 

Typedefs

typedef ap_uint< 1 > ArpLkpOp
 

Enumerations

enum  ArpLkpOpCodes { ARP_INSERT =0 , ARP_DELETE =1 }
 

Functions

void pArpPacketReceiver (Ip4Addr piMMIO_IpAddress, stream< AxisEth > &siIPRX_Data, stream< ArpMeta > &soAPs_Meta, stream< ArpBindPair > &soACc_UpdateReq)
 
void pArpPacketSender (EthAddr piMMIO_MacAddress, Ip4Addr piMMIO_IpAddress, stream< ArpMeta > &siAPr_Meta, stream< Ip4Addr > &siACc_Meta, stream< AxisEth > &soETH_Data)
 
void pArpCamController (stream< ArpBindPair > &siAPr_UpdateReq, stream< Ip4Addr > &soAPs_Meta, stream< Ip4Addr > &siIPTX_MacLkpReq, stream< ArpLkpReply > &soIPTX_MacLkpRep, stream< RtlMacLookupRequest > &soCAM_MacLkpReq, stream< RtlMacLookupReply > &siCAM_MacLkpRep, stream< RtlMacUpdateRequest > &soCAM_MacUpdReq, stream< RtlMacUpdateReply > &siCAM_MacUpdRep)
 
void arp (EthAddr piMMIO_MacAddress, Ip4Addr piMMIO_Ip4Address, stream< AxisEth > &siIPRX_Data, stream< AxisEth > &soETH_Data, stream< Ip4Addr > &siIPTX_MacLkpReq, stream< ArpLkpReply > &soIPTX_MacLkpRep, stream< RtlMacLookupRequest > &soCAM_MacLkpReq, stream< RtlMacLookupReply > &siCAM_MacLkpRep, stream< RtlMacUpdateRequest > &soCAM_MacUpdReq, stream< RtlMacUpdateReply > &siCAM_MacUpdRep)
 Main process of the Address Resolution Protocol (ARP) Server. More...
 
void arp_top (EthAddr piMMIO_MacAddress, Ip4Addr piMMIO_Ip4Address, stream< AxisRaw > &siIPRX_Data, stream< AxisRaw > &soETH_Data, stream< Ip4Addr > &siIPTX_MacLkpReq, stream< ArpLkpReply > &soIPTX_MacLkpRep, stream< RtlMacLookupRequest > &soCAM_MacLkpReq, stream< RtlMacLookupReply > &siCAM_MacLkpRep, stream< RtlMacUpdateRequest > &soCAM_MacUpdReq, stream< RtlMacUpdateReply > &siCAM_MacUpdRep)
 Top of Address Resolution Protocol (ARP) Server. More...
 

Variables

bool gTraceEvent
 

Detailed Description

Address Resolution Protocol (ARS) server of the Network Transport Stack (NTS).

cFDK / ShellLib / FMC : Submodules cFDK / ShellLib / NAL: Submodules cFDK / ShellLib / NTS : Submodules

Macro Definition Documentation

◆ DEBUG_LEVEL

#define DEBUG_LEVEL   (TRACE_OFF)

Definition at line 77 of file arp.cpp.

◆ THIS_NAME

#define THIS_NAME   "ARP"

Definition at line 69 of file arp.cpp.

◆ TRACE_ACC

#define TRACE_ACC   1 << 3

Definition at line 74 of file arp.cpp.

◆ TRACE_ALL

#define TRACE_ALL   0xFFFF

Definition at line 75 of file arp.cpp.

◆ TRACE_APR

#define TRACE_APR   1 << 1

Definition at line 72 of file arp.cpp.

◆ TRACE_APS

#define TRACE_APS   1 << 2

Definition at line 73 of file arp.cpp.

◆ TRACE_OFF

#define TRACE_OFF   0x0000

Definition at line 71 of file arp.cpp.

◆ USE_DEPRECATED_DIRECTIVES

#define USE_DEPRECATED_DIRECTIVES

Definition at line 60 of file arp.cpp.

Typedef Documentation

◆ ArpLkpOp

typedef ap_uint<1> ArpLkpOp

CAM / Lookup OpCodes

Definition at line 86 of file arp.hpp.

Enumeration Type Documentation

◆ ArpLkpOpCodes

Enumerator
ARP_INSERT 
ARP_DELETE 

Definition at line 87 of file arp.hpp.

87 { ARP_INSERT=0, ARP_DELETE=1 };
@ ARP_INSERT
Definition: arp.hpp:87
@ ARP_DELETE
Definition: arp.hpp:87

Function Documentation

◆ arp()

void arp ( EthAddr  piMMIO_MacAddress,
Ip4Addr  piMMIO_Ip4Address,
stream< AxisEth > &  siIPRX_Data,
stream< AxisEth > &  soETH_Data,
stream< Ip4Addr > &  siIPTX_MacLkpReq,
stream< ArpLkpReply > &  soIPTX_MacLkpRep,
stream< RtlMacLookupRequest > &  soCAM_MacLkpReq,
stream< RtlMacLookupReply > &  siCAM_MacLkpRep,
stream< RtlMacUpdateRequest > &  soCAM_MacUpdReq,
stream< RtlMacUpdateReply > &  siCAM_MacUpdRep 
)

Main process of the Address Resolution Protocol (ARP) Server.

Parameters
[in]piMMIO_MacAddressThe MAC address from MMIO (in network order).
[in]piMMIO_Ip4AddressThe IPv4 address from MMIO (in network order).
[in]siIPRX_DataData stream from the IP Rx Handler (IPRX).
[out]soETH_DataData stream to Ethernet (ETH).
[in]siIPTX_MacLkpReqMAC lookup request from [IPTX].
[out]soIPTX_MacLkpRepMAC lookup reply to [IPTX].
[out]soCAM_MacLkpReqMAC lookup request to [CAM].
[in]siCAM_MacLkpRepMAC lookup reply from [CAM].
[out]soCAM_MacUpdReqMAC update request to [CAM].
[in]siCAM_MacUpdRepMAC update reply from [CAM].

This process maintains a Content Addressable Memory (CAM) which holds the association of a layer-2 MAC address with a layer-3 IP address. The content of the CAM is continuously updated with any new {MAC_SA, IP_SA} binding seen by the IP Rx packet handler (IPRX) at the receive side of the FPGA. When an IP packet is transmitted by the FPGA, the 'IP_DA' is used as key to lookup the CAM and retrieve the associated 'MAC_DA' value to be used for building the outgoing Ethernet frame. If there is not a known binding for a given 'IP_DA', this process will build a broadcast ARP-REQUEST message that will be sent to every node of the local network, and will wait for the corresponding ARP-RESPONSE message to come back before forwarding the IP packet that is currently waiting for its address to be resolved. Conversely, if a broadcast ARP-REQUEST message that matches the ARP binding of the current FPGA, this process is in charge of building the corresponding ARP-REPLY message that is to be sent back in response to the incoming ARP request.

Definition at line 495 of file arp.cpp.

526 {
527  //-- DIRECTIVES FOR THE INTERFACES -----------------------------------------
528  #pragma HLS DATAFLOW
529  #pragma HLS INLINE
530  #pragma HLS INTERFACE ap_ctrl_none port=return
531 
532  //--------------------------------------------------------------------------
533  //-- LOCAL STREAMS (Sorted by the name of the modules which generate them)
534  //--------------------------------------------------------------------------
535 
536  //-- ARP Packet Receiver (APr)
537  static stream<ArpMeta> ssAPrToAPs_Meta ("ssAPrToAPs_Meta");
538  #pragma HLS STREAM variable=ssAPrToAPs_Meta depth=4
539  #pragma HLS DATA_PACK variable=ssAPrToAPs_Meta
540  static stream<ArpBindPair> ssAPrToACc_UpdateReq ("ssAPrToACc_UpdateReq");
541  #pragma HLS STREAM variable=ssAPrToACc_UpdateReq depth=4
542  #pragma HLS DATA_PACK variable=ssAPrToACc_UpdateReq
543 
544  //-- ARP CAM Controller (ACc)
545  static stream<LE_Ip4Addr> ssACcToAPs_Meta ("ssACcToAPs_Meta");
546  #pragma HLS STREAM variable=ssACcToAPs_Meta depth=4
547 
549  piMMIO_Ip4Address,
550  siIPRX_Data,
551  ssAPrToAPs_Meta,
552  ssAPrToACc_UpdateReq);
553 
555  piMMIO_MacAddress,
556  piMMIO_Ip4Address,
557  ssAPrToAPs_Meta,
558  ssACcToAPs_Meta,
559  soETH_Data);
560 
562  ssAPrToACc_UpdateReq,
563  ssACcToAPs_Meta,
564  siIPTX_MacLkpReq,
565  soIPTX_MacLkpRep,
566  soCAM_MacLkpReq,
567  siCAM_MacLkpRep,
568  soCAM_MacUpdReq,
569  siCAM_MacUpdRep);
570 }
void pArpCamController(stream< ArpBindPair > &siAPr_UpdateReq, stream< Ip4Addr > &soAPs_Meta, stream< Ip4Addr > &siIPTX_MacLkpReq, stream< ArpLkpReply > &soIPTX_MacLkpRep, stream< RtlMacLookupRequest > &soCAM_MacLkpReq, stream< RtlMacLookupReply > &siCAM_MacLkpRep, stream< RtlMacUpdateRequest > &soCAM_MacUpdReq, stream< RtlMacUpdateReply > &siCAM_MacUpdRep)
Definition: arp.cpp:377
void pArpPacketReceiver(Ip4Addr piMMIO_IpAddress, stream< AxisEth > &siIPRX_Data, stream< ArpMeta > &soAPs_Meta, stream< ArpBindPair > &soACc_UpdateReq)
Definition: arp.cpp:116
void pArpPacketSender(EthAddr piMMIO_MacAddress, Ip4Addr piMMIO_IpAddress, stream< ArpMeta > &siAPr_Meta, stream< Ip4Addr > &siACc_Meta, stream< AxisEth > &soETH_Data)
Definition: arp.cpp:246
Here is the call graph for this function:
Here is the caller graph for this function:

◆ arp_top()

void arp_top ( EthAddr  piMMIO_MacAddress,
Ip4Addr  piMMIO_Ip4Address,
stream< AxisRaw > &  siIPRX_Data,
stream< AxisRaw > &  soETH_Data,
stream< Ip4Addr > &  siIPTX_MacLkpReq,
stream< ArpLkpReply > &  soIPTX_MacLkpRep,
stream< RtlMacLookupRequest > &  soCAM_MacLkpReq,
stream< RtlMacLookupReply > &  siCAM_MacLkpRep,
stream< RtlMacUpdateRequest > &  soCAM_MacUpdReq,
stream< RtlMacUpdateReply > &  siCAM_MacUpdRep 
)

Top of Address Resolution Protocol (ARP) Server.

Parameters
[in]piMMIO_MacAddressThe MAC address from MMIO (in network order).
[in]piMMIO_Ip4AddressThe IPv4 address from MMIO (in network order).
[in]siIPRX_DataData stream from the IP Rx Handler (IPRX).
[out]soETH_DataData stream to Ethernet (ETH).
[in]siIPTX_MacLkpReqMAC lookup request from [IPTX].
[out]soIPTX_MacLkpRepMAC lookup reply to [IPTX].
[out]soCAM_MacLkpReqMAC lookup request to [CAM].
[in]siCAM_MacLkpRepMAC lookup reply from [CAM].
[out]soCAM_MacUpdReqMAC update request to [CAM].
[in]siCAM_MacUpdRepMAC update reply from [CAM].

ENTITY - ADDRESS RESOLUTION PROTOCOL (ARP) SERVER

Definition at line 664 of file arp.cpp.

690 {
691  //-- DIRECTIVES FOR THE INTERFACES -----------------------------------------
692  #pragma HLS INTERFACE ap_ctrl_none port=return
693 
694  #pragma HLS INTERFACE ap_stable port=piMMIO_MacAddress
695  #pragma HLS INTERFACE ap_stable port=piMMIO_Ip4Address
696 
697  #pragma HLS INTERFACE axis off port=siIPRX_Data
698  #pragma HLS INTERFACE axis register both port=soETH_Data
699 
700  #pragma HLS INTERFACE axis off port=siIPTX_MacLkpReq
701  #pragma HLS INTERFACE axis off port=soIPTX_MacLkpRep
702  #pragma HLS DATA_PACK variable=soIPTX_MacLkpRep
703 
704  #pragma HLS INTERFACE axis register both port=soCAM_MacLkpReq
705  #pragma HLS DATA_PACK variable=soCAM_MacLkpReq
706  #pragma HLS INTERFACE axis off port=siCAM_MacLkpRep
707  #pragma HLS DATA_PACK variable=siCAM_MacLkpRep
708  #pragma HLS INTERFACE axis register both port=soCAM_MacUpdReq
709  #pragma HLS DATA_PACK variable=soCAM_MacUpdReq
710  #pragma HLS INTERFACE axis off port=siCAM_MacUpdRep
711  #pragma HLS DATA_PACK variable=siCAM_MacUpdRep
712 
713  //-- DIRECTIVES FOR THIS PROCESS -------------------------------------------
714  #pragma HLS DATAFLOW disable_start_propagation
715 
716  //-- LOCAL INPUT and OUTPUT STREAMS ----------------------------------------
717  static stream<AxisEth> ssiIPRX_Data;
718  static stream<AxisEth> ssoETH_Data;
719 
720  //-- INPUT STREAM CASTING --------------------------------------------------
721  pAxisRawCast(
722  siIPRX_Data,
723  ssiIPRX_Data);
724 
725  //-- MAIN ARP PROCESS ------------------------------------------------------
726  arp(
727  //-- MMIO Interfaces
728  piMMIO_MacAddress,
729  piMMIO_Ip4Address,
730  //-- IPRX Interface
731  ssiIPRX_Data,
732  //-- ETH Interface
733  ssoETH_Data,
734  //-- IPTX Interfaces
735  siIPTX_MacLkpReq,
736  soIPTX_MacLkpRep,
737  //-- CAM Interfaces
738  soCAM_MacLkpReq,
739  siCAM_MacLkpRep,
740  soCAM_MacUpdReq,
741  siCAM_MacUpdRep);
742 
743  //-- OUTPUT STREAM CASTING -------------------------------------------------
744  pAxisRawCast(
745  ssoETH_Data,
746  soETH_Data);
747 }
void arp(EthAddr piMMIO_MacAddress, Ip4Addr piMMIO_Ip4Address, stream< AxisEth > &siIPRX_Data, stream< AxisEth > &soETH_Data, stream< Ip4Addr > &siIPTX_MacLkpReq, stream< ArpLkpReply > &soIPTX_MacLkpRep, stream< RtlMacLookupRequest > &soCAM_MacLkpReq, stream< RtlMacLookupReply > &siCAM_MacLkpRep, stream< RtlMacUpdateRequest > &soCAM_MacUpdReq, stream< RtlMacUpdateReply > &siCAM_MacUpdRep)
Main process of the Address Resolution Protocol (ARP) Server.
Definition: arp.cpp:495
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:

◆ pArpCamController()

void pArpCamController ( stream< ArpBindPair > &  siAPr_UpdateReq,
stream< Ip4Addr > &  soAPs_Meta,
stream< Ip4Addr > &  siIPTX_MacLkpReq,
stream< ArpLkpReply > &  soIPTX_MacLkpRep,
stream< RtlMacLookupRequest > &  soCAM_MacLkpReq,
stream< RtlMacLookupReply > &  siCAM_MacLkpRep,
stream< RtlMacUpdateRequest > &  soCAM_MacUpdReq,
stream< RtlMacUpdateReply > &  siCAM_MacUpdRep 
)

ARP CAM Controller (ACc)

Parameters
[in]siAPr_UpdateReqNew {MAC,IP} update request from ArpPacketReceiver (APr).
[out]soAPs_MetaMeta stream to ArpPacketSender (APs).
[in]siIPTX_MacLkpReqMAC lookup request from [IPTX].
[out]soIPTX_MacLkpRepMAC lookup reply to [IPTX].
[out]soCAM_MacLkpReqMAC lookup request to [CAM].
[in]siCAM_MacLkpRepMAC lookup reply from [CAM].
[out]soCAM_MacUpdReqMAC update request to [CAM].
[in]siCAM_MacUpdRepMAC update reply from [CAM].

This is the front-end process of the RTL ContentAddressableMemory (CAM). It serves the MAC lookup requests from the IpTxHandler (IPTX) and MAC update requests from the ArpPacketReceiver (APr).

Definition at line 377 of file arp.cpp.

386 {
387  //-- DIRECTIVES FOR THIS PROCESS -------------------------------------------
388  #pragma HLS INLINE off
389  #pragma HLS PIPELINE II=1 enable_flush
390 
391  const char *myName = concat3(THIS_NAME, "/", "ACc");
392 
393  //-- STATIC CONTROL VARIABLES (with RESET) ---------------------------------
394  static enum FsmStates { ACC_IDLE, ACC_UPDATE, ACC_LOOKUP } acc_fsmState=ACC_IDLE;
395  #pragma HLS RESET variable=acc_fsmState
396 
397  //-- STATIC DATAFLOW VARIABLES ---------------------------------------------
398  static Ip4Addr acc_ipLkpKey;
399 
400  switch(acc_fsmState) {
401  case ACC_IDLE:
402  if (!siIPTX_MacLkpReq.empty()) {
403  acc_ipLkpKey = siIPTX_MacLkpReq.read();
404  if (acc_ipLkpKey == IP4_BROADCAST_ADDR) {
405  // Reply with Ethernet broadcast address and return immediately
406  soIPTX_MacLkpRep.write(ArpLkpReply(ETH_BROADCAST_ADDR, LKP_HIT));
407  acc_fsmState = ACC_IDLE;
408  }
409  else {
410  if (DEBUG_LEVEL & TRACE_ACC) {
411  printInfo(myName, "FSM=ACC_IDLE - Request CAM to lookup MAC address binded to:\n");
412  printIp4Addr(myName, acc_ipLkpKey);
413  }
414  soCAM_MacLkpReq.write(RtlMacLookupRequest(acc_ipLkpKey));
415  acc_fsmState = ACC_LOOKUP;
416  }
417  }
418  else if (!siAPr_UpdateReq.empty()) {
419  ArpBindPair arpBind = siAPr_UpdateReq.read();
420  if (DEBUG_LEVEL & TRACE_ACC) {
421  printInfo(myName, "FSM=ACC_IDLE - Request CAM to update:\n");
422  printArpBindPair(myName, ArpBindPair(arpBind.macAddr, arpBind.ip4Addr));
423  }
424  soCAM_MacUpdReq.write(RtlMacUpdateRequest(arpBind.ip4Addr, arpBind.macAddr, ARP_INSERT));
425  acc_fsmState = ACC_UPDATE;
426  }
427  break;
428  case ACC_UPDATE:
429  if(!siCAM_MacUpdRep.empty()) {
430  siCAM_MacUpdRep.read(); // Consume the reply without actually acting on it
431  if (DEBUG_LEVEL & TRACE_ACC) {
432  printInfo(myName, "FSM=ACC_UPDATE - Done with CAM update.\n");
433  }
434  acc_fsmState = ACC_IDLE;
435  }
436  break;
437  case ACC_LOOKUP:
438  if(!siCAM_MacLkpRep.empty()) {
439  RtlMacLookupReply macLkpReply = siCAM_MacLkpRep.read();
440  if (DEBUG_LEVEL & TRACE_ACC) {
441  printInfo(myName, "FSM=ACC_LOOKUP\n");
442  }
443  soIPTX_MacLkpRep.write(ArpLkpReply(macLkpReply.value, macLkpReply.hit));
444  if (!macLkpReply.hit) {
445  if (DEBUG_LEVEL & TRACE_ACC) {
446  printInfo(myName, "NO-HIT. Go and fire an ARP-REQUEST for:\n");
447  printIp4Addr(myName, acc_ipLkpKey);
448  }
449  soAPs_Meta.write(acc_ipLkpKey);
450  }
451  else {
452  if (DEBUG_LEVEL & TRACE_ACC) {
453  printInfo(myName, "HIT. Retrieved following address from CAM:\n");
454  printEthAddr(myName, macLkpReply.value);
455  }
456  }
457  acc_fsmState = ACC_IDLE;
458  }
459  break;
460  }
461 }
Ip4Addr ip4Addr
Definition: nts_types.hpp:335
EthAddr macAddr
Definition: nts_types.hpp:334
HitBool hit
Definition: arp.hpp:135
EthAddr value
Definition: arp.hpp:134
#define TRACE_ACC
Definition: arp.cpp:74
#define THIS_NAME
Definition: arp.cpp:69
#define DEBUG_LEVEL
Definition: arp.cpp:77
#define IP4_BROADCAST_ADDR
Definition: nts_types.hpp:181
void printArpBindPair(const char *callerName, ArpBindPair arpBind)
Print an ARP binding pair association.
Definition: nts_utils.cpp:80
ap_uint< 32 > Ip4Addr
Definition: AxisIp4.hpp:169
#define printInfo(callerName, format,...)
A macro to print an information message.
Definition: nts_utils.hpp:169
#define ETH_BROADCAST_ADDR
Definition: nts_types.hpp:152
void printIp4Addr(const char *callerName, const char *message, Ip4Addr ip4Addr)
Print an IPv4 address prepended with a message (used for debugging).
Definition: nts_utils.cpp:205
#define concat3(firstCharConst, secondCharConst, thirdCharConst)
Definition: nts_utils.hpp:161
#define LKP_HIT
Definition: nts_types.hpp:76
void printEthAddr(const char *callerName, const char *message, EthAddr ethAddr)
Print an ETHERNET MAC address prepended with a message (for debug).
Definition: nts_utils.cpp:237
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pArpPacketReceiver()

void pArpPacketReceiver ( Ip4Addr  piMMIO_IpAddress,
stream< AxisEth > &  siIPRX_Data,
stream< ArpMeta > &  soAPs_Meta,
stream< ArpBindPair > &  soACc_UpdateReq 
)

ARP Packet Receiver (APr)

Parameters
[in]piMMIO_IpAddressMy IPv4 address from [MMIO].
[in]siIPRX_DataData stream from the IP Rx Handler (IPRX).
[out]soAPs_MetaMeta stream to ARP Packet Sender (APs).
[out]soACc_UpdateReqNew {MAC,IP} update request to ArpCamController (ACc).

This process parses the incoming ARP packet and extracts the relevant ARP fields as a metadata structure. If the 'OPERation' field is an ARP-REQUEST, the extracted metadata structure is forwarded to the ArpPacketSender (APs) which will use that information to to build an ARP-REPLY packet in response to the incoming ARP-REQUEST. Next, the {MAC,IP} binding of the ARP-Sender is systematically forwarded to the ARP-CAM for insertion.

Warning
The format of the incoming ARP-over-ETHERNET is as follow: 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SA[1] | SA[0] | DA[5] | DA[4] | DA[3] | DA[2] | DA[1] | DA[0] | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | HTYPE=0x0001 | Length/Type | SA[5] | SA[4] | SA[3] | SA[2] | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SHA[1] | SHA[0] | OPER=0x0001 (or 0x0002) | PLEN=0x04 | HLEN=0x06 | PTYPE=0x0800 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SPA[3] | SPA[2] | SPA[1] | SPA[0] | SHA[5] | SHA[4] | SHA[3] | SHA[2] | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | TPA[1] | TPA[0] | THA[5] | THA[4] | THA[3] | THA[2] | THA[1] | THA[0] | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | | | | | | TPA[3] | TPA[2] | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Definition at line 116 of file arp.cpp.

121 {
122  //-- DIRECTIVES FOR THIS PROCESS -------------------------------------------
123  #pragma HLS INLINE off
124  #pragma HLS PIPELINE II=1 enable_flush
125 
126  const char *myName = concat3(THIS_NAME, "/", "APr");
127 
128  // An ETH frame w/ an ARP packet but w/o FCS is only 14+28 bytes.
129  // However, let's plan for an entire MTU frame.
130  const int cW = 8; // (int)(ceil(log2((1500+18)/8)))
131 
132  //-- STATIC CONTROL VARIABLES (with RESET) --------------------------------
133  static ap_uint<cW> apr_chunkCount=0;
134  #pragma HLS RESET variable=apr_chunkCount
135 
136  //-- STATIC DATAFLOW VARIABLES ---------------------------------------------
137  static ArpMeta apr_meta;
138  static ArpOper apr_opCode;
139  static ArpTargProtAddr arp_targProtAddr;
140 
141  //-- DYNAMIC VARIABLES -----------------------------------------------------
142  AxisEth currChunk(0, 0, 0);
143 
144  enum { CHUNK_0=0, CHUNK_1, CHUNK_2, CHUNK_3, CHUNK_4, CHUNK_5 };
145 
146  if (!siIPRX_Data.empty()) {
147  siIPRX_Data.read(currChunk);
148  switch(apr_chunkCount) {
149  case CHUNK_0:
150  // Extract MAC_SA[1:0]
151  apr_meta.remoteMacAddr(47,32) = currChunk.getEthSrcAddrHi();
152  break;
153  case CHUNK_1:
154  apr_meta.remoteMacAddr(31, 0) = currChunk.getEthSrcAddrLo();
155  apr_meta.etherType = currChunk.getEtherType();
156  apr_meta.arpHwType = currChunk.getArpHwType();
157  break;
158  case CHUNK_2:
159  apr_meta.arpProtType = currChunk.getArpProtType();
160  apr_meta.arpHwLen = currChunk.getArpHwLen();
161  apr_meta.arpProtLen = currChunk.getArpProtLen();
162  apr_opCode = currChunk.getArpOper();
163  apr_meta.arpSendHwAddr(47,32) = currChunk.getArpShaHi();
164  break;
165  case CHUNK_3:
166  apr_meta.arpSendHwAddr(31, 0) = currChunk.getArpShaLo();
167  apr_meta.arpSendProtAddr = currChunk.getArpSpa();
168  break;
169  case CHUNK_4:
170  arp_targProtAddr(31,16) = currChunk.getArpTpaHi();
171  break;
172  case CHUNK_5:
173  arp_targProtAddr(15, 0) = currChunk.getArpTpaLo();
174  if (DEBUG_LEVEL & TRACE_APR) {
175  printInfo(myName, "Received ARP packet from IPRX\n");
176  printInfo(myName, "\t srcMacAddr = 0x%12.12lX \n", apr_meta.remoteMacAddr.to_ulong());
177  printInfo(myName, "\t etherType = 0x%4.4X \n", apr_meta.etherType.to_ushort());
178  printInfo(myName, "\t HwType = 0x%4.4X \n", apr_meta.arpHwType.to_ushort());
179  printInfo(myName, "\t ProtType = 0x%4.4X \n", apr_meta.arpProtType.to_ushort());
180  printInfo(myName, "\t HwLen = 0x%2.2X \n", apr_meta.arpHwLen.to_uchar());
181  printInfo(myName, "\t ProtLen = 0x%2.2X \n", apr_meta.arpProtLen.to_uchar());
182  printInfo(myName, "\t Operation = 0x%4.4X \n", apr_opCode.to_ushort());
183  printInfo(myName, "\t SendHwAddr = 0x%12.12lX \n", apr_meta.arpSendHwAddr.to_ulong());
184  printInfo(myName, "\t SendProtAddr = 0x%8.8X \n", apr_meta.arpSendProtAddr.to_uint());
185  printInfo(myName, "\t TargProtAddr = 0x%8.8X \n", arp_targProtAddr.to_uint());
186  }
187  break;
188  default:
189  break;
190  } // End of: switch
191 
192  if (currChunk.getLE_TLast() == 1) {
193  if (apr_opCode == ARP_OPER_REQUEST) {
194  if (arp_targProtAddr == piMMIO_IpAddress) {
195  soAPs_Meta.write(apr_meta);
196  }
197  else if (DEBUG_LEVEL & TRACE_APR) {
198  printInfo(myName,"Skip ARP reply because requested TPA does not match our IP address.\n");
199  }
200  }
201  // Always ask the CAM to add the {MAC,IP} binding of the ARP-Sender
202  soACc_UpdateReq.write(ArpBindPair(apr_meta.arpSendHwAddr,
203  apr_meta.arpSendProtAddr));
204  apr_chunkCount = 0;
205  }
206  else {
207  apr_chunkCount++;
208  }
209  }
210 }
Definition: arp.hpp:70
EtherType etherType
Definition: arp.hpp:73
ArpProtLen arpProtLen
Definition: arp.hpp:77
ArpSendHwAddr arpSendHwAddr
Definition: arp.hpp:78
ArpHwLen arpHwLen
Definition: arp.hpp:76
EthAddr remoteMacAddr
Definition: arp.hpp:72
ArpHwType arpHwType
Definition: arp.hpp:74
ArpProtType arpProtType
Definition: arp.hpp:75
ArpSendProtAddr arpSendProtAddr
Definition: arp.hpp:79
#define TRACE_APR
Definition: arp.cpp:72
@ CHUNK_2
Definition: toe.hpp:244
@ CHUNK_1
Definition: toe.hpp:244
@ CHUNK_4
Definition: toe.hpp:244
@ CHUNK_5
Definition: toe.hpp:244
@ CHUNK_3
Definition: toe.hpp:244
@ CHUNK_0
Definition: toe.hpp:244
#define ARP_OPER_REQUEST
Definition: nts_types.hpp:165
ap_uint< 32 > ArpTargProtAddr
Definition: AxisArp.hpp:103
ap_uint< 16 > ArpOper
Definition: AxisArp.hpp:99
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pArpPacketSender()

void pArpPacketSender ( EthAddr  piMMIO_MacAddress,
Ip4Addr  piMMIO_IpAddress,
stream< ArpMeta > &  siAPr_Meta,
stream< Ip4Addr > &  siACc_Meta,
stream< AxisEth > &  soETH_Data 
)

ARP Packet Sender (APs)

Parameters
[in]piMMIO_MacAddressMy MAC address from MemoryMappedIOs (MMIO).
[in]piMMIO_IpAddressMy IPv4 address from [MMIO].
[in]siAPr_MetaMeta stream from ArpPacketReceiver (APr).
[in]siACc_MetaMeta stream from ArpCamController (ACc).
[out]soETH_DataData stream to Ethernet (ETH).

This process builds an ARP-REPLY packet upon request from the process ArpPacketReceiver (APr), or an ARP-REQUEST packet upon request from the process ArpCamController ACc). The generated ARP packet is then encapsulated into an Ethernet frame.

Warning
The format of the outgoing ARP-over-ETHERNET is as follow: 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SA[1] | SA[0] | DA[5] | DA[4] | DA[3] | DA[2] | DA[1] | DA[0] | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | HTYPE=0x0001 | Length/Type | SA[5] | SA[4] | SA[3] | SA[2] | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SHA[1] | SHA[0] | OPER=0x0001 (or 0x0002) | PLEN=0x04 | HLEN=0x06 | PTYPE=0x0800 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SPA[3] | SPA[2] | SPA[1] | SPA[0] | SHA[5] | SHA[4] | SHA[3] | SHA[2] | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | TPA[1] | TPA[0] | THA[5] | THA[4] | THA[3] | THA[2] | THA[1] | THA[0] | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | | | | | | TPA[3] | TPA[2] | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Definition at line 246 of file arp.cpp.

252 {
253  //-- DIRECTIVES FOR THIS PROCESS -------------------------------------------
254  #pragma HLS INLINE off
255  #pragma HLS PIPELINE II=1 enable_flush
256 
257  const char *myName = concat3(THIS_NAME, "/", "APr");
258 
259  //-- STATIC CONTROL VARIABLES (with RESET) --------------------------------
260  static enum FsmStates { APR_IDLE, APR_REPLY, APR_SENTRQ } aps_fsmState=APR_IDLE;
261  #pragma HLS RESET variable=aps_fsmState
262 
263  //-- STATIC DATAFLOW VARIABLES ---------------------------------------------
264  static ap_uint<8> aps_sendCount; // ETH+ARP is only 44 bytes (.i.e 6 quadwords).
265  static ArpMeta aps_aprMeta;
266  static Ip4Addr aps_tpaReq; // Target Protocol Address Request
267 
268  //-- DYNAMIC VARIABLES -----------------------------------------------------
269  AxisEth sendCunk(0, 0xFF, 0);
270 
271  switch (aps_fsmState) {
272  case APR_IDLE:
273  aps_sendCount = 0;
274  if (!siAPr_Meta.empty()) {
275  siAPr_Meta.read(aps_aprMeta);
276  aps_fsmState = APR_REPLY;
277  }
278  else if (!siACc_Meta.empty()) {
279  siACc_Meta.read(aps_tpaReq);
280  aps_fsmState = APR_SENTRQ;
281  }
282  break;
283  case APR_SENTRQ:
284  switch(aps_sendCount) {
285  case 0:
286  sendCunk.setEthDstAddr(ETH_BROADCAST_ADDR);
287  sendCunk.setEthSrcAddrHi(piMMIO_MacAddress);
288  break;
289  case 1:
290  sendCunk.setEthSrcAddrLo(piMMIO_MacAddress);
291  sendCunk.setEthertType(ETH_ETHERTYPE_ARP);
292  sendCunk.setArpHwType(ARP_HTYPE_ETHERNET);
293  break;
294  case 2:
295  sendCunk.setArpProtType(ARP_PTYPE_IPV4);
296  sendCunk.setArpHwLen(ARP_HLEN_ETHERNET);
297  sendCunk.setArpProtLen(ARP_PLEN_IPV4);
298  sendCunk.setArpOper(ARP_OPER_REQUEST);
299  sendCunk.setArpShaHi(piMMIO_MacAddress);
300  break;
301  case 3:
302  sendCunk.setArpShaLo(piMMIO_MacAddress);
303  sendCunk.setArpSpa(piMMIO_IpAddress);
304  break;
305  case 4:
306  // MEMO - The THA field is ignored in an ARP request
307  sendCunk.setArpTpaHi(aps_tpaReq);
308  break;
309  case 5:
310  sendCunk.setArpTpaLo(aps_tpaReq);
311  sendCunk.setLE_TKeep(0x03);
312  sendCunk.setLE_TLast(TLAST);
313  aps_fsmState = APR_IDLE;
314  break;
315  } // End-of: switch(aps_sendCount)
316  soETH_Data.write(sendCunk);
317  aps_sendCount++;
318  break;
319  case APR_REPLY:
320  switch(aps_sendCount) {
321  case 0:
322  sendCunk.setEthDstAddr(aps_aprMeta.remoteMacAddr);
323  sendCunk.setEthSrcAddrHi(piMMIO_MacAddress);
324  break;
325  case 1:
326  sendCunk.setEthSrcAddrLo(piMMIO_MacAddress);
327  sendCunk.setEthertType(aps_aprMeta.etherType);
328  sendCunk.setArpHwType(aps_aprMeta.arpHwType);
329  break;
330  case 2:
331  sendCunk.setArpProtType(aps_aprMeta.arpProtType);
332  sendCunk.setArpHwLen(aps_aprMeta.arpHwLen);
333  sendCunk.setArpProtLen(aps_aprMeta.arpProtLen);
334  sendCunk.setArpOper(ARP_OPER_REPLY);
335  sendCunk.setArpShaHi(piMMIO_MacAddress);
336  break;
337  case 3:
338  sendCunk.setArpShaLo(piMMIO_MacAddress);
339  sendCunk.setArpSpa(piMMIO_IpAddress);
340  break;
341  case 4:
342  sendCunk.setArpTha(aps_aprMeta.arpSendHwAddr);
343  sendCunk.setArpTpaHi(aps_aprMeta.arpSendProtAddr);
344  break;
345  case 5:
346  sendCunk.setArpTpaLo(aps_aprMeta.arpSendProtAddr);
347  sendCunk.setLE_TKeep(0x03);
348  sendCunk.setLE_TLast(TLAST);
349  aps_fsmState = APR_IDLE;
350  break;
351  } // End-of: switch(aps_sendCount)
352  soETH_Data.write(sendCunk);
353  aps_sendCount++;
354  break;
355 
356  } // End-of: switch (aps_fsmState)
357 }
#define ARP_PTYPE_IPV4
Definition: nts_types.hpp:162
#define ARP_HTYPE_ETHERNET
Definition: nts_types.hpp:161
#define ARP_PLEN_IPV4
Definition: nts_types.hpp:164
#define ETH_ETHERTYPE_ARP
Definition: nts_types.hpp:156
#define ARP_HLEN_ETHERNET
Definition: nts_types.hpp:163
#define ARP_OPER_REPLY
Definition: nts_types.hpp:166
#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_APR | TRACE_APS)

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

Definition at line 151 of file tb_nal.cpp.