60 #define USE_DEPRECATED_DIRECTIVES
69 #define THIS_NAME "ARP"
71 #define TRACE_OFF 0x0000
72 #define TRACE_APR 1 << 1
73 #define TRACE_APS 1 << 2
74 #define TRACE_ACC 1 << 3
75 #define TRACE_ALL 0xFFFF
77 #define DEBUG_LEVEL (TRACE_OFF)
118 stream<AxisEth> &siIPRX_Data,
119 stream<ArpMeta> &soAPs_Meta,
120 stream<ArpBindPair> &soACc_UpdateReq)
123 #pragma HLS INLINE off
124 #pragma HLS PIPELINE II=1 enable_flush
133 static ap_uint<cW> apr_chunkCount=0;
134 #pragma HLS RESET variable=apr_chunkCount
146 if (!siIPRX_Data.empty()) {
147 siIPRX_Data.read(currChunk);
148 switch(apr_chunkCount) {
175 printInfo(myName,
"Received ARP packet from IPRX\n");
182 printInfo(myName,
"\t Operation = 0x%4.4X \n", apr_opCode.to_ushort());
185 printInfo(myName,
"\t TargProtAddr = 0x%8.8X \n", arp_targProtAddr.to_uint());
194 if (arp_targProtAddr == piMMIO_IpAddress) {
195 soAPs_Meta.write(apr_meta);
198 printInfo(myName,
"Skip ARP reply because requested TPA does not match our IP address.\n");
249 stream<ArpMeta> &siAPr_Meta,
250 stream<Ip4Addr> &siACc_Meta,
251 stream<AxisEth> &soETH_Data)
254 #pragma HLS INLINE off
255 #pragma HLS PIPELINE II=1 enable_flush
260 static enum FsmStates { APR_IDLE, APR_REPLY, APR_SENTRQ } aps_fsmState=APR_IDLE;
261 #pragma HLS RESET variable=aps_fsmState
264 static ap_uint<8> aps_sendCount;
271 switch (aps_fsmState) {
274 if (!siAPr_Meta.empty()) {
275 siAPr_Meta.read(aps_aprMeta);
276 aps_fsmState = APR_REPLY;
278 else if (!siACc_Meta.empty()) {
279 siACc_Meta.read(aps_tpaReq);
280 aps_fsmState = APR_SENTRQ;
284 switch(aps_sendCount) {
313 aps_fsmState = APR_IDLE;
316 soETH_Data.write(sendCunk);
320 switch(aps_sendCount) {
349 aps_fsmState = APR_IDLE;
352 soETH_Data.write(sendCunk);
378 stream<ArpBindPair> &siAPr_UpdateReq,
379 stream<Ip4Addr> &soAPs_Meta,
380 stream<Ip4Addr> &siIPTX_MacLkpReq,
381 stream<ArpLkpReply> &soIPTX_MacLkpRep,
382 stream<RtlMacLookupRequest> &soCAM_MacLkpReq,
383 stream<RtlMacLookupReply> &siCAM_MacLkpRep,
384 stream<RtlMacUpdateRequest> &soCAM_MacUpdReq,
385 stream<RtlMacUpdateReply> &siCAM_MacUpdRep)
388 #pragma HLS INLINE off
389 #pragma HLS PIPELINE II=1 enable_flush
394 static enum FsmStates { ACC_IDLE, ACC_UPDATE, ACC_LOOKUP } acc_fsmState=ACC_IDLE;
395 #pragma HLS RESET variable=acc_fsmState
400 switch(acc_fsmState) {
402 if (!siIPTX_MacLkpReq.empty()) {
403 acc_ipLkpKey = siIPTX_MacLkpReq.read();
407 acc_fsmState = ACC_IDLE;
411 printInfo(myName,
"FSM=ACC_IDLE - Request CAM to lookup MAC address binded to:\n");
415 acc_fsmState = ACC_LOOKUP;
418 else if (!siAPr_UpdateReq.empty()) {
421 printInfo(myName,
"FSM=ACC_IDLE - Request CAM to update:\n");
425 acc_fsmState = ACC_UPDATE;
429 if(!siCAM_MacUpdRep.empty()) {
430 siCAM_MacUpdRep.read();
432 printInfo(myName,
"FSM=ACC_UPDATE - Done with CAM update.\n");
434 acc_fsmState = ACC_IDLE;
438 if(!siCAM_MacLkpRep.empty()) {
444 if (!macLkpReply.
hit) {
446 printInfo(myName,
"NO-HIT. Go and fire an ARP-REQUEST for:\n");
449 soAPs_Meta.write(acc_ipLkpKey);
453 printInfo(myName,
"HIT. Retrieved following address from CAM:\n");
457 acc_fsmState = ACC_IDLE;
506 stream<AxisEth> &siIPRX_Data,
511 stream<AxisEth> &soETH_Data,
516 stream<Ip4Addr> &siIPTX_MacLkpReq,
517 stream<ArpLkpReply> &soIPTX_MacLkpRep,
522 stream<RtlMacLookupRequest> &soCAM_MacLkpReq,
523 stream<RtlMacLookupReply> &siCAM_MacLkpRep,
524 stream<RtlMacUpdateRequest> &soCAM_MacUpdReq,
525 stream<RtlMacUpdateReply> &siCAM_MacUpdRep)
530 #pragma HLS INTERFACE ap_ctrl_none port=return
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
545 static stream<LE_Ip4Addr> ssACcToAPs_Meta (
"ssACcToAPs_Meta");
546 #pragma HLS STREAM variable=ssACcToAPs_Meta depth=4
552 ssAPrToACc_UpdateReq);
562 ssAPrToACc_UpdateReq,
587 #if HLS_VERSION == 2017
597 stream<AxisEth> &siIPRX_Data,
601 stream<AxisEth> &soETH_Data,
605 stream<Ip4Addr> &siIPTX_MacLkpReq,
606 stream<ArpLkpReply> &soIPTX_MacLkpRep,
610 stream<RtlMacLookupRequest> &soCAM_MacLkpReq,
611 stream<RtlMacLookupReply> &siCAM_MacLkpRep,
612 stream<RtlMacUpdateRequest> &soCAM_MacUpdReq,
613 stream<RtlMacUpdateReply> &siCAM_MacUpdRep)
616 #pragma HLS INTERFACE ap_ctrl_none port=return
623 #pragma HLS INTERFACE ap_stable port=piMMIO_MacAddress
624 #pragma HLS INTERFACE ap_stable port=piMMIO_Ip4Address
626 #pragma HLS RESOURCE core=AXI4Stream variable=siIPRX_Data metadata="-bus_bundle siIPRX_Data"
627 #pragma HLS RESOURCE core=AXI4Stream variable=soETH_Data metadata="-bus_bundle soETH_Data"
629 #pragma HLS RESOURCE core=AXI4Stream variable=siIPTX_MacLkpReq metadata="-bus_bundle siIPTX_MacLkpReq"
630 #pragma HLS RESOURCE core=AXI4Stream variable=soIPTX_MacLkpRep metadata="-bus_bundle soIPTX_MacLkpRep"
631 #pragma HLS DATA_PACK variable=soIPTX_MacLkpRep
633 #pragma HLS RESOURCE core=AXI4Stream variable=soCAM_MacLkpReq metadata="-bus_bundle soCAM_MacLkpReq"
634 #pragma HLS DATA_PACK variable=soCAM_MacLkpReq
635 #pragma HLS RESOURCE core=AXI4Stream variable=siCAM_MacLkpRep metadata="-bus_bundle siCAM_MacLkpRep"
636 #pragma HLS DATA_PACK variable=siCAM_MacLkpRep
637 #pragma HLS RESOURCE core=AXI4Stream variable=soCAM_MacUpdReq metadata="-bus_bundle soCAM_MacUpdReq"
638 #pragma HLS DATA_PACK variable=soCAM_MacUpdReq
639 #pragma HLS RESOURCE core=AXI4Stream variable=siCAM_MacUpdRep metadata="-bus_bundle siCAM_MacUpdRep"
640 #pragma HLS DATA_PACK variable=siCAM_MacUpdRep
673 stream<AxisRaw> &siIPRX_Data,
677 stream<AxisRaw> &soETH_Data,
681 stream<Ip4Addr> &siIPTX_MacLkpReq,
682 stream<ArpLkpReply> &soIPTX_MacLkpRep,
686 stream<RtlMacLookupRequest> &soCAM_MacLkpReq,
687 stream<RtlMacLookupReply> &siCAM_MacLkpRep,
688 stream<RtlMacUpdateRequest> &soCAM_MacUpdReq,
689 stream<RtlMacUpdateReply> &siCAM_MacUpdRep)
692 #pragma HLS INTERFACE ap_ctrl_none port=return
694 #pragma HLS INTERFACE ap_stable port=piMMIO_MacAddress
695 #pragma HLS INTERFACE ap_stable port=piMMIO_Ip4Address
697 #pragma HLS INTERFACE axis off port=siIPRX_Data
698 #pragma HLS INTERFACE axis register both port=soETH_Data
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
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
714 #pragma HLS DATAFLOW disable_start_propagation
717 static stream<AxisEth> ssiIPRX_Data;
718 static stream<AxisEth> ssoETH_Data;
: Address Resolution Protocol (ARP) Server
ap_uint< 16 > getEthSrcAddrHi()
void setEthDstAddr(EthAddr addr)
void setArpTpaHi(ArpTargProtAddr tpa)
ap_uint< 32 > getEthSrcAddrLo()
void setArpProtLen(ArpProtLen plen)
void setEthertType(EtherType eType)
void setArpSpa(ArpSendProtAddr spa)
ArpProtLen getArpProtLen()
void setArpProtType(ArpProtType ptype)
void setArpOper(ArpOper oper)
void setArpShaLo(ArpSendHwAddr sha)
void setArpTpaLo(ArpTargProtAddr tpa)
void setEthSrcAddrHi(EthAddr addr)
void setEthSrcAddrLo(EthAddr addr)
void setArpShaHi(ArpSendHwAddr sha)
void setArpHwLen(ArpHwLen hlen)
void setArpHwType(ArpHwType htype)
void setArpTha(ArpTargHwAddr tha)
ArpSendProtAddr getArpSpa()
ArpProtType getArpProtType()
void setLE_TLast(LE_tLast last)
void setLE_TKeep(LE_tKeep keep, int leHi=64/8-1, int leLo=0)
LE_tLast getLE_TLast() const
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 pArpPacketReceiver(Ip4Addr piMMIO_IpAddress, stream< AxisEth > &siIPRX_Data, stream< ArpMeta > &soAPs_Meta, stream< ArpBindPair > &soACc_UpdateReq)
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.
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.
void pArpPacketSender(EthAddr piMMIO_MacAddress, Ip4Addr piMMIO_IpAddress, stream< ArpMeta > &siAPr_Meta, stream< Ip4Addr > &siACc_Meta, stream< AxisEth > &soETH_Data)
#define ARP_HTYPE_ETHERNET
#define IP4_BROADCAST_ADDR
void printArpBindPair(const char *callerName, ArpBindPair arpBind)
Print an ARP binding pair association.
ap_uint< 32 > ArpTargProtAddr
void pAxisRawCast(hls::stream< TypeIn > &si, hls::stream< TypeOut > &so)
AxisRaw cast - Casts an AxisRaw stream to/from an AxisRaw derived class.
#define ETH_ETHERTYPE_ARP
#define ARP_HLEN_ETHERNET
#define printInfo(callerName, format,...)
A macro to print an information message.
#define ETH_BROADCAST_ADDR
void printIp4Addr(const char *callerName, const char *message, Ip4Addr ip4Addr)
Print an IPv4 address prepended with a message (used for debugging).
#define concat3(firstCharConst, secondCharConst, thirdCharConst)
void printEthAddr(const char *callerName, const char *message, EthAddr ethAddr)
Print an ETHERNET MAC address prepended with a message (for debug).