All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sir_port_info.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cvmx.h>
4 #include <cvmx-pow.h>
5 #include <cvmx-version.h>
6 #include <common.h>
7 
8 
9 #define NROFPHYSICALPORTS 128 // Number of physical ports supported by this stack
10 #define MAXPHYSICALPORTNR 4096 // Highest physical port number supported by this stack
11 #define NROFARPENTRIES 128 // Max nr of Arp Entries in table
12 #define NROFIPADDRESSES 16 // Max nr of IP address entries per port
13 
14 
15 class CMACProxy; // Forward declaration of Mac Proxy
16 class ISirius; // Forward declaration of Sirius INterface class
18 {
19  public:
20  static CSiriusPorts* Instance(void);
21  bool Init(int iInstance, void *pCSiriusI);
22  bool AddPort(int iPhysPort, int iNrOfArpEntries, int iNrOfVlans, int iNrOfCacheEntries, int iNrOfInterfaceEntries,
23  int iNrOfRouterEntries, int iNrOfPrefixEntries, bool bSlaacEnabled);
24  bool AddVlan(int iPhysPort, uint16_t ui16Vlan);
25  bool AddIPV6Address(int iPhysPort, uint16_t ui16Vlan, TIPAddr tIp, uint8_t bMaskBits, TIPAddr tGw);
26  bool AddIPV4Address(int iPortNr, uint32_t ui32IP, uint32_t ui32Gateway, uint32_t Netmask, uint16_t ui16VLan);
27  bool RemoveIPV4Address(int iPortNr, uint32_t ui32IP, uint16_t ui16Vlan);
28  bool RemoveIPV6Address(int iPhysPort, TIPAddr tIp, uint16_t ui16Vlan);
29  int SearchForIPV4 (uint32_t ui32IP, int16_t i16Vlan);
30  bool SearchForIPV6 (const TIPAddr *ptIp, int *piPort, uint16_t *pui16Vlan);
31  bool SearchForBestMatchIPV6(const TIPAddr *ptDstIp, TIPAddr *ptIfip, int *piPort, uint16_t *pui16Vlan);
32  int SearchForBestMatchIPV4(uint32_t ui32IP, uint32_t *pui32BestMatchIP, uint16_t *pui16Vlan);
33  CMACProxy* GetMacProxyForPort(int iPhysPort);
34  CSiriusEth* GetEthernetForPort(int iPhysPort);
35  bool GetPortInfo(TIPAddr *ptIp, CSiriusEth **ppEth, CMACProxy **ppMac, uint16_t *pVlan, int *pPort);
36  bool HandlePortTiming();
37  static uint8_t MaskToBits(TIPAddr tMask);
38  void DiagnosticsIPv6(uint16_t ui16Par);
40  void PrintPortStatus(int iPortNr, CSystemInfo::prt_linkstatus_t* ptLinkStatus);
42  int PortToPortIndex(int iPhysPort);
43  bool DisplayArpStats(int iPortNr);
44  CARPProxy *GetARPReference(int iPortNr);
45  CARPProxy *GetArpReferenceByIndex(int iIndex);
46  int GetArpHashResources(int iPortNr);
47 
48  private:
49  struct TGlobalVar
50  {
51  CSystemInfo::prt_linkstatus_t tLinkStatus[NROFPHYSICALPORTS]; // Stores link status of port
52  cvmx_rwlock_wp_lock_t tRWLock[NROFPHYSICALPORTS];
53  cvmx_rwlock_wp_lock_t tGlobalLock;
54  int iActivePort;
55  };
56 
57  struct TLookup
58  {
59  bool bOccupied;
60  uint16_t ui16Index;
61  } m_tReversePortLookup[MAXPHYSICALPORTNR]; // Lookup from physical to sequence number
62 
63  TGlobalVar *m_ptGlobalVarStorage;
64 
65  int m_iInstance;
66  ISirius *m_pISirius; // Pointer to interface class
67 
68  CCoremask m_cCoreMask;
69 
70  int m_iIndexToPhysPort[NROFPHYSICALPORTS]; // Lookup from sequence number to physical port
71  int m_iNrOfPortsInConfiguration;
72  bool m_bOcteonEthernetActive;
73  bool m_bVsnTapDriverActive;
74  bool m_bPhactTapDriverActive;
75 
76 
80 
81  CVMX_SHARED static int m_iSharedTickCount;
82 
83 
84 
85  struct TPortCache
86  {
87  int iMacIdx;
88  int iInterfaceIdx;
89  };
90 
92 
93  CMACProxy* GetProxyReferenceByIndex(int iIndex);
94  CSiriusEth* GetEthernetReferenceByIndex(int iIndex);
95  static void ArpCallback(CARPProxy::TARPEvent *ptArpEvent, void *pArg);
96  bool PortCacheAdd(TIPAddr *ptIpAddr, TPortCache *pCache);
97  void PortCacheRemove(TIPAddr *ptIpAddr);
98  bool PortCacheSearch(TIPAddr *ptIpAddr, TPortCache *pCache);
99 };
100 
Sirius interface class.
Definition: sir_isocket.h:20
CSiriusEth * GetEthernetForPort(int iPhysPort)
#define MAXPHYSICALPORTNR
Definition: sir_port_info.h:10
CSystemInfo::prt_linkstatus_t UpdatePortStatus(int iPortIndex)
bool SearchForBestMatchIPV6(const TIPAddr *ptDstIp, TIPAddr *ptIfip, int *piPort, uint16_t *pui16Vlan)
#define NROFPHYSICALPORTS
Definition: sir_port_info.h:9
bool RemoveIPV6Address(int iPhysPort, TIPAddr tIp, uint16_t ui16Vlan)
void PrintPortStatus(int iPortNr, CSystemInfo::prt_linkstatus_t *ptLinkStatus)
Sirius ARP IPV4 class.
Definition: arp-proxy.h:21
int SearchForIPV4(uint32_t ui32IP, int16_t i16Vlan)
bool GetPortInfo(TIPAddr *ptIp, CSiriusEth **ppEth, CMACProxy **ppMac, uint16_t *pVlan, int *pPort)
bool AddVlan(int iPhysPort, uint16_t ui16Vlan)
CSystemInfo::prt_linkstatus_t GetLinkStatus(int iPortIndex)
bool HandlePortTiming()
bool RemoveIPV4Address(int iPortNr, uint32_t ui32IP, uint16_t ui16Vlan)
int PortToPortIndex(int iPhysPort)
static CSiriusPorts * Instance(void)
int SearchForBestMatchIPV4(uint32_t ui32IP, uint32_t *pui32BestMatchIP, uint16_t *pui16Vlan)
bool AddIPV4Address(int iPortNr, uint32_t ui32IP, uint32_t ui32Gateway, uint32_t Netmask, uint16_t ui16VLan)
CMACProxy * GetMacProxyForPort(int iPhysPort)
bool Init(int iInstance, void *pCSiriusI)
Struct contains an IPV4 or an IPV6 address.
Definition: packet-defines.h:7
bool AddPort(int iPhysPort, int iNrOfArpEntries, int iNrOfVlans, int iNrOfCacheEntries, int iNrOfInterfaceEntries, int iNrOfRouterEntries, int iNrOfPrefixEntries, bool bSlaacEnabled)
static uint8_t MaskToBits(TIPAddr tMask)
int GetArpHashResources(int iPortNr)
bool DisplayArpStats(int iPortNr)
Define the event events the ARP class generates when calling the ARP callback function void (*PTCallB...
Definition: arp-proxy.h:44
void DiagnosticsIPv6(uint16_t ui16Par)
CARPProxy * GetArpReferenceByIndex(int iIndex)
bool AddIPV6Address(int iPhysPort, uint16_t ui16Vlan, TIPAddr tIp, uint8_t bMaskBits, TIPAddr tGw)
bool SearchForIPV6(const TIPAddr *ptIp, int *piPort, uint16_t *pui16Vlan)
CARPProxy * GetARPReference(int iPortNr)