All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sir_ipv6.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include <cvmx.h>
5 #include <cvmx-version.h>
6 #include <cvmx-atomic.h>
7 #include <cvmx-rwlock.h>
8 #include <cvmx-tim.h>
9 #include <cvmx-access.h>
10 
11 #define DEFAULTMTUSIZE_V6 1280 // Set the default MTU size
12 #define MAXDATAGRAMSIZE 65536 // Max IP datagram size
13 #define IPREASSTIMEOUT 15000 // IP reassembly timeout is 15 secs
14 
15 // IP Header file
16 #define SIR_IP_IPPROTO_TCP 6
17 #define SIR_IP_IPPROTO_UDP 17
18 
19 #define CVMX_FPA_IPREASS_POOL CVMX_FPA_PACKET_POOL
20 #define CVMX_FPA_IPREASS_POOL_SIZE CVMX_FPA_PACKET_POOL_SIZE
21 
22 // IP error codes
23 #define SIR_IP_OK 0
24 #define SIR_IP_NOHEADERSPACE 1 // No space for IP header in buffer
25 #define SIR_IP_MAXSIZEEXCEEDED 2 // Max datagram size exceeded
26 #define SIR_IP_ETHERROR 3 // Ip layer received error from ethernet layer
27 #define SIR_IP_NOPAYLOADMEMORY 4 // No payload memory available
28 #define SIR_IP_MEMTOOSMALL 5 // Allocated memory too small for efficient use
29 #define SIR_IP_NULLPOINTER 6 // No allocated memory
30 #define SIR_IP_NOARP 7 // No ARP entry available for this IP address
31 
33 {
34  uint64_t ui64DstAddrHigh;
35  uint64_t ui64DstAddrLow;
36  uint64_t ui64SrcAddrHigh;
37  uint64_t ui64SrcAddrLow;
39 
40  bool operator==(const TReAssCompare& tReAssCompare) const
41  {
42  return ((tReAssCompare.ui64DstAddrHigh == ui64DstAddrHigh) && (tReAssCompare.ui64DstAddrLow == ui64DstAddrLow) &&
43  (tReAssCompare.ui64SrcAddrHigh == ui64SrcAddrHigh) && (tReAssCompare.ui64SrcAddrLow == ui64SrcAddrLow) &&
44  (tReAssCompare.ui32Ident == ui32Ident)) ? true : false;
45  }
46  bool operator!=(const TReAssCompare& tReAssCompare) const
47  {
48  return ((tReAssCompare.ui64DstAddrHigh != ui64DstAddrHigh) || (tReAssCompare.ui64DstAddrLow != ui64DstAddrLow) ||
49  (tReAssCompare.ui64SrcAddrHigh != ui64SrcAddrHigh) || (tReAssCompare.ui64SrcAddrLow != ui64SrcAddrLow) ||
50  (tReAssCompare.ui32Ident != ui32Ident)) ? true : false;
51  }
52 };
53 
54 
55 // structure for IP re-assembly timeout timer packet
57 {
58  uint64_t ui64Ticks;
61 };
62 
64 {
65 public:
66 
67  static CSiriusIPV6* Instance(void); // Singleton
68  bool Init(int iInstance);
69  CSiriusMemList* HandlePacket(cvmx_wqe_t *pWQE, uint16_t ui16Offset, uint16_t ui16Vlan, bool *pbPacketDigested);
70  void TimerTick();
71  uint16_t GetMTUSize();
72  void SetMTUSize(uint16_t ui16MTUSize);
73  int Send(TIPAddr *ptDestIP, TIPAddr *ptSrcIP, TIPAddr *ptAdapterSrcIp, char* pBuffer,uint32_t ui32PayloadSize, uint8_t ui8Protocol, int iPortNr);
74  int Send(TIPAddr *ptDestIP, TIPAddr *ptSrcIP, TIPAddr *ptAdapterSrcIp, CSiriusMemList *pMemList, uint32_t ui32PayloadSize, uint8_t ui8Protocol, volatile void *pAddr, int iPortNr);
75  void Diagnostics(uint16_t Selection, uint16_t *pOffset, uint8_t *pBytes, int iLength);
76  bool DeleteFragmentedList(CSiriusMemList *ptMemList);
77  bool TransferFragmentedList(CSiriusMemList *ptDestMemList, CSiriusMemList *ptSrcMemList);
78  int IPGetAndAddNrOfResourcesInUse(int iIncrement);
79  static int IPV6HeaderSize();
80 
82 private:
83 
84  static bool HandleUnusedStatic(cvmx_wqe_t *pWQE, void *pThis);
85  bool HandleUnused(cvmx_wqe_t *pWQE);
86  bool DeleteMemList(CSiriusMemList *ptMemList);
87  bool ClearScope(TIPAddr *ptAddr);
88  EHeaderOptions HandleIpv6ExtensionHeader(TIPv6Header *pHeader, uint64_t *pui64NexLayer);
89  bool ProcessSingleHeader(uint64_t ui64Header, uint64_t ui64NextHeader, EHeaderOptions eOption);
90  bool ProcessHBHandDSTOptions(uint64_t ui64Header, uint64_t ui64NextHeader);
91  CSiriusMemList* ProcessPacket(cvmx_wqe_t *pWQE, EHeaderOptions eOption, TIPv6Header *pIpHeader, uint64_t u64StartOfPacket, uint64_t ui64NextLayer, uint64_t ui64EndOfPacket);
92  CSiriusMemList* ProcessFragmentedPacket(cvmx_wqe_t *pWQE, EHeaderOptions eOption, TIPv6Header *pIpHeader,CSiriusMemList *ptMemList);
93  CSiriusMemList* ProcessFragmented(cvmx_wqe_t *pWQE, TIPv6Header *pIPHeader, CMACProxy *pProxy, uint16_t ui16Vlan, uint64_t ui64StartOfPacket, uint64_t ui64NextLayer, uint64_t ui64EndOfPacket, bool *pbDigested);
94  EHeaderOptions HandleIpv6FragmentedExtensionHeader(CSiriusMemList *ptMemList, EHeaderOptions eOption);
95  EHeaderOptions ProcessSingleFragmentedHeader(CSiriusMemList *ptMemList, EHeaderOptions eOption);
96  void ProcessFragmentedICMP(CSiriusMemList *ptMemList, CMACProxy *pProxy, TIPv6Header *pIpHeader, uint64_t vlan);
97  uint16_t GetNextIdentification();
98  int CreateIPHeader(char *pBuffer, uint32_t ui32Payloadsize, TIPAddr *ptDestIP, TIPAddr *ptSrcIP, uint8_t ui8Protocol);
99  int CreateFragmentHeader(char *pBuffer, uint32_t ui32Id, uint8_t ui8Flags, uint16_t ui16FragmentOffset, uint8_t ui8Protocol);
100 
101 
102  struct TGlobalVar
103  {
104  cvmx_rwlock_wp_lock_t tRW_ListenSockLock; // RW lock
105  int32_t i32Identification; // Counter for Identification generation in case of fragmentation
106  uint32_t ui32MtuSize; // MTU size for this system
107  bool bAlreadyInited;
108  };
109 
110  TGlobalVar *m_ptGlobalVarStorage;
111  uint32_t m_ui32IpOffset;
112  uint8_t m_ui8Unused; // Unused value for reassembly timout timer
113  int m_iInstance;
114  CCoremask m_cCoremask;
115  CTashTable<TReAssCompare, sizeof (CSiriusMemList)> m_cIPV6ReAssHash; // Bookkeeping for IP reassembly
116 
117  uint16_t m_ui16UsedReassemblyPool; // Reassembly pool used
118 
119  CVMX_SHARED static int32_t m_iNrOfIPV6ReasstPoolInUse; // Nr of IPReassembly pools in use by this class
120  CVMX_SHARED static int m_iDiagStart; // shared between all cores
121  CVMX_SHARED static int m_iDiagStop;
122 };
123 
void TimerTick()
int IPGetAndAddNrOfResourcesInUse(int iIncrement)
CSiriusMemList * HandlePacket(cvmx_wqe_t *pWQE, uint16_t ui16Offset, uint16_t ui16Vlan, bool *pbPacketDigested)
uint64_t ui64Ticks
Definition: sir_ipv6.h:58
uint64_t ui64SrcAddrHigh
Definition: sir_ipv6.h:36
bool TransferFragmentedList(CSiriusMemList *ptDestMemList, CSiriusMemList *ptSrcMemList)
bool DeleteFragmentedList(CSiriusMemList *ptMemList)
uint32_t ui32Ident
Definition: sir_ipv6.h:38
TReAssCompare tReAssCompare
Definition: sir_ipv6.h:60
void Diagnostics(uint16_t Selection, uint16_t *pOffset, uint8_t *pBytes, int iLength)
uint16_t GetMTUSize()
static int IPV6HeaderSize()
Struct contains an IPV4 or an IPV6 address.
Definition: packet-defines.h:7
sir_timer_t tEndTime
Definition: sir_ipv6.h:59
void * pMemList
Definition: sir_cmemlist.h:16
uint64_t ui64SrcAddrLow
Definition: sir_ipv6.h:37
bool Init(int iInstance)
uint64_t ui64DstAddrHigh
Definition: sir_ipv6.h:34
bool operator!=(const TReAssCompare &tReAssCompare) const
Definition: sir_ipv6.h:46
uint64_t ui64DstAddrLow
Definition: sir_ipv6.h:35
void SetMTUSize(uint16_t ui16MTUSize)
uint64_t sir_timer_t
int Send(TIPAddr *ptDestIP, TIPAddr *ptSrcIP, TIPAddr *ptAdapterSrcIp, char *pBuffer, uint32_t ui32PayloadSize, uint8_t ui8Protocol, int iPortNr)
Most important class of Sirius. Used to maintain and process all kinds of queues. ...
Definition: sir_memlist.h:51
EHeaderOptions
static CSiriusIPV6 * Instance(void)
bool operator==(const TReAssCompare &tReAssCompare) const
Definition: sir_ipv6.h:40
bool m_bAcceptFarAddresses
Definition: sir_ipv6.h:81