cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
arp.cpp
Go to the documentation of this file.
1 
17 
43 
56 #include "arp.hpp"
57 
58 using namespace hls;
59 
60 #define USE_DEPRECATED_DIRECTIVES
61 
62 
66 #ifndef __SYNTHESIS__
67  extern bool gTraceEvent;
68 #endif
69 #define THIS_NAME "ARP"
70 
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
76 
77 #define DEBUG_LEVEL (TRACE_OFF)
78 
79 
80 
117  Ip4Addr piMMIO_IpAddress,
118  stream<AxisEth> &siIPRX_Data,
119  stream<ArpMeta> &soAPs_Meta,
120  stream<ArpBindPair> &soACc_UpdateReq)
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 }
211 
212 
247  EthAddr piMMIO_MacAddress,
248  Ip4Addr piMMIO_IpAddress,
249  stream<ArpMeta> &siAPr_Meta,
250  stream<Ip4Addr> &siACc_Meta,
251  stream<AxisEth> &soETH_Data)
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:
287  sendCunk.setEthSrcAddrHi(piMMIO_MacAddress);
288  break;
289  case 1:
290  sendCunk.setEthSrcAddrLo(piMMIO_MacAddress);
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 }
358 
359 
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)
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 }
462 
463 
495 void arp(
496 
497  //------------------------------------------------------
498  //-- MMIO Interfaces
499  //------------------------------------------------------
500  EthAddr piMMIO_MacAddress,
501  Ip4Addr piMMIO_Ip4Address,
502 
503  //------------------------------------------------------
504  //-- IPRX Interface
505  //------------------------------------------------------
506  stream<AxisEth> &siIPRX_Data,
507 
508  //------------------------------------------------------
509  //-- ETH Interface
510  //------------------------------------------------------
511  stream<AxisEth> &soETH_Data,
512 
513  //------------------------------------------------------
514  //-- IPTX Interfaces
515  //------------------------------------------------------
516  stream<Ip4Addr> &siIPTX_MacLkpReq,
517  stream<ArpLkpReply> &soIPTX_MacLkpRep,
518 
519  //------------------------------------------------------
520  //-- CAM Interfaces
521  //------------------------------------------------------
522  stream<RtlMacLookupRequest> &soCAM_MacLkpReq,
523  stream<RtlMacLookupReply> &siCAM_MacLkpRep,
524  stream<RtlMacUpdateRequest> &soCAM_MacUpdReq,
525  stream<RtlMacUpdateReply> &siCAM_MacUpdRep)
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 }
571 
572 
587 #if HLS_VERSION == 2017
588  void arp_top(
589  //------------------------------------------------------
590  //-- MMIO Interfaces
591  //------------------------------------------------------
592  EthAddr piMMIO_MacAddress,
593  Ip4Addr piMMIO_Ip4Address,
594  //------------------------------------------------------
595  //-- IPRX Interface
596  //------------------------------------------------------
597  stream<AxisEth> &siIPRX_Data,
598  //------------------------------------------------------
599  //-- ETH Interface
600  //------------------------------------------------------
601  stream<AxisEth> &soETH_Data,
602  //------------------------------------------------------
603  //-- IPTX Interfaces
604  //------------------------------------------------------
605  stream<Ip4Addr> &siIPTX_MacLkpReq,
606  stream<ArpLkpReply> &soIPTX_MacLkpRep,
607  //------------------------------------------------------
608  //-- CAM Interfaces
609  //------------------------------------------------------
610  stream<RtlMacLookupRequest> &soCAM_MacLkpReq,
611  stream<RtlMacLookupReply> &siCAM_MacLkpRep,
612  stream<RtlMacUpdateRequest> &soCAM_MacUpdReq,
613  stream<RtlMacUpdateReply> &siCAM_MacUpdRep)
614 {
615  //-- DIRECTIVES FOR THE INTERFACES -----------------------------------------
616  #pragma HLS INTERFACE ap_ctrl_none port=return
617 
618 
619 
620 
621 
623  #pragma HLS INTERFACE ap_stable port=piMMIO_MacAddress
624  #pragma HLS INTERFACE ap_stable port=piMMIO_Ip4Address
625 
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"
628 
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
632 
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
641 
642  //-- DIRECTIVES FOR THIS PROCESS -------------------------------------------
643  #pragma HLS DATAFLOW
644 
645  //-- MAIN ARP PROCESS ------------------------------------------------------
646  arp(
647  //-- MMIO Interfaces
648  piMMIO_MacAddress,
649  piMMIO_Ip4Address,
650  //-- IPRX Interface
651  siIPRX_Data,
652  //-- ETH Interface
653  soETH_Data,
654  //-- IPTX Interfaces
655  siIPTX_MacLkpReq,
656  soIPTX_MacLkpRep,
657  //-- CAM Interfaces
658  soCAM_MacLkpReq,
659  siCAM_MacLkpRep,
660  soCAM_MacUpdReq,
661  siCAM_MacUpdRep);
662 }
663 #else
664  void arp_top(
665  //------------------------------------------------------
666  //-- MMIO Interfaces
667  //------------------------------------------------------
668  EthAddr piMMIO_MacAddress,
669  Ip4Addr piMMIO_Ip4Address,
670  //------------------------------------------------------
671  //-- IPRX Interface
672  //------------------------------------------------------
673  stream<AxisRaw> &siIPRX_Data,
674  //------------------------------------------------------
675  //-- ETH Interface
676  //------------------------------------------------------
677  stream<AxisRaw> &soETH_Data,
678  //------------------------------------------------------
679  //-- IPTX Interfaces
680  //------------------------------------------------------
681  stream<Ip4Addr> &siIPTX_MacLkpReq,
682  stream<ArpLkpReply> &soIPTX_MacLkpRep,
683  //------------------------------------------------------
684  //-- CAM Interfaces
685  //------------------------------------------------------
686  stream<RtlMacLookupRequest> &soCAM_MacLkpReq,
687  stream<RtlMacLookupReply> &siCAM_MacLkpRep,
688  stream<RtlMacUpdateRequest> &soCAM_MacUpdReq,
689  stream<RtlMacUpdateReply> &siCAM_MacUpdRep)
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 }
748 
749 #endif
750 
: Address Resolution Protocol (ARP) Server
Ip4Addr ip4Addr
Definition: nts_types.hpp:335
EthAddr macAddr
Definition: nts_types.hpp:334
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
ap_uint< 16 > getEthSrcAddrHi()
Definition: AxisEth.hpp:164
void setEthDstAddr(EthAddr addr)
Definition: AxisEth.hpp:159
void setArpTpaHi(ArpTargProtAddr tpa)
Definition: AxisEth.hpp:212
ap_uint< 32 > getEthSrcAddrLo()
Definition: AxisEth.hpp:167
ArpShaHi getArpShaHi()
Definition: AxisEth.hpp:201
EtherType getEtherType()
Definition: AxisEth.hpp:172
void setArpProtLen(ArpProtLen plen)
Definition: AxisEth.hpp:194
void setEthertType(EtherType eType)
Definition: AxisEth.hpp:171
void setArpSpa(ArpSendProtAddr spa)
Definition: AxisEth.hpp:206
ArpHwLen getArpHwLen()
Definition: AxisEth.hpp:192
ArpProtLen getArpProtLen()
Definition: AxisEth.hpp:195
void setArpProtType(ArpProtType ptype)
Definition: AxisEth.hpp:188
void setArpOper(ArpOper oper)
Definition: AxisEth.hpp:197
ArpShaLo getArpShaLo()
Definition: AxisEth.hpp:204
void setArpShaLo(ArpSendHwAddr sha)
Definition: AxisEth.hpp:203
ArpTpaHi getArpTpaHi()
Definition: AxisEth.hpp:213
void setArpTpaLo(ArpTargProtAddr tpa)
Definition: AxisEth.hpp:215
void setEthSrcAddrHi(EthAddr addr)
Definition: AxisEth.hpp:163
void setEthSrcAddrLo(EthAddr addr)
Definition: AxisEth.hpp:166
void setArpShaHi(ArpSendHwAddr sha)
Definition: AxisEth.hpp:200
void setArpHwLen(ArpHwLen hlen)
Definition: AxisEth.hpp:191
ArpTpaLo getArpTpaLo()
Definition: AxisEth.hpp:216
ArpHwType getArpHwType()
Definition: AxisEth.hpp:186
void setArpHwType(ArpHwType htype)
Definition: AxisEth.hpp:185
void setArpTha(ArpTargHwAddr tha)
Definition: AxisEth.hpp:209
ArpSendProtAddr getArpSpa()
Definition: AxisEth.hpp:207
ArpOper getArpOper()
Definition: AxisEth.hpp:198
ArpProtType getArpProtType()
Definition: AxisEth.hpp:189
void setLE_TLast(LE_tLast last)
Definition: AxisRaw.hpp:280
void setLE_TKeep(LE_tKeep keep, int leHi=64/8-1, int leLo=0)
Definition: AxisRaw.hpp:276
LE_tLast getLE_TLast() const
Definition: AxisRaw.hpp:268
HitBool hit
Definition: arp.hpp:135
EthAddr value
Definition: arp.hpp:134
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
#define TRACE_ACC
Definition: arp.cpp:74
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.
Definition: arp.cpp:664
#define TRACE_APR
Definition: arp.cpp:72
bool gTraceEvent
Definition: tb_nal.cpp:151
#define THIS_NAME
Definition: arp.cpp:69
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
#define DEBUG_LEVEL
Definition: arp.cpp:77
void pArpPacketSender(EthAddr piMMIO_MacAddress, Ip4Addr piMMIO_IpAddress, stream< ArpMeta > &siAPr_Meta, stream< Ip4Addr > &siACc_Meta, stream< AxisEth > &soETH_Data)
Definition: arp.cpp:246
@ ARP_INSERT
Definition: arp.hpp:87
@ 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_PTYPE_IPV4
Definition: nts_types.hpp:162
ap_uint< 48 > EthAddr
Definition: AxisEth.hpp:120
#define ARP_HTYPE_ETHERNET
Definition: nts_types.hpp:161
#define IP4_BROADCAST_ADDR
Definition: nts_types.hpp:181
#define ARP_OPER_REQUEST
Definition: nts_types.hpp:165
void printArpBindPair(const char *callerName, ArpBindPair arpBind)
Print an ARP binding pair association.
Definition: nts_utils.cpp:80
ap_uint< 32 > ArpTargProtAddr
Definition: AxisArp.hpp:103
#define ARP_PLEN_IPV4
Definition: nts_types.hpp:164
ap_uint< 32 > Ip4Addr
Definition: AxisIp4.hpp:169
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
#define ETH_ETHERTYPE_ARP
Definition: nts_types.hpp:156
ap_uint< 16 > ArpOper
Definition: AxisArp.hpp:99
#define ARP_HLEN_ETHERNET
Definition: nts_types.hpp:163
#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
#define ARP_OPER_REPLY
Definition: nts_types.hpp:166
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
#define TLAST
Definition: AxisRaw.hpp:116