All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SystemInfo.h
Go to the documentation of this file.
1 #pragma once
2 #include <cvmx.h>
3 #include <cvmx-version.h>
4 #include <cvmx-rwlock.h>
5 #include <cvmx-bootmem.h>
6 #include <cvmx-fpa.h>
7 #include <cvmx-pko.h>
8 #include <cvmx-helper-cfg.h>
9 
10 #include <string>
11 #ifdef __linux__
12 #include "ifaddrs.h"
13 #include "cvmx-helper.h"
14 #endif
15 
17 {
18 public:
19 
20  enum EGlobal
21  {
23  PHACTTAP_MAX_IF = 16, // maximunm support interfaces
24  VERSION = 2 // Update version when not compatible with previous anymore
25  };
26 
27 
28  // Struct contains link information
29  // -------------------------------
31  {
32  uint64_t u64;
33  struct {
34  uint64_t duplex:8;
35  uint64_t status:8;
36 #if OCTEON_SDK_VERSION_NUM < 301020000ull // SDK 3.1.2 build 000
37  uint64_t speed:16;
38  uint64_t reserved:32;
39 #else
40  uint64_t speed:18;
41  uint64_t reserved:30;
42 #endif
43  };
44  bool operator!=(const prt_linkstatus_t &T) const
45  {
46  return ((T.duplex != duplex) || (T.speed != speed) || (T.status != status)) ? true : false;
47  }
48  void operator=(const prt_linkstatus_t &T)
49  {
50  this->duplex = T.duplex;
51  this->speed = T.speed;
52  this->status = T.status;
53  }
54  };
55 
56 
57  // Info per port
58  // -------------
59  struct TPortInfo
60  {
61  bool bUsed;
63  };
64 
65 
66  // Link status of the board
67  // ------------------------
68  struct TLinkStatus
69  {
70  TPortInfo tPortInfo[PHACTTAP_MAX_PORTS]; // Stores link status per port
72  };
73 
74  // added to share pool info across different applications
75  struct TPoolInfo
76  {
77 #if OCTEON_SDK_VERSION_NUM < 301020000ull // SDK 3.1.2 build 000
78  cvmx_fpa_pool_info_t cvmx_fpa_pool_info[CVMX_FPA_NUM_POOLS];
79 #endif
80  };
81 
82  struct TSystemInfo
83  {
84  cvmx_rwlock_wp_lock_t tLock;
88 
89 #if OCTEON_SDK_VERSION_NUM >= 301020000ull // SDK 3.1.2 build 000
90  struct cvmx_cfg_pko_port_param tPko_Queue_Table[CVMX_HELPER_CFG_MAX_PKO_PORT];
91 #endif
92  };
93 
94  static CSystemInfo* Instance(bool bAsMaster = false);
95  prt_linkstatus_t GetStatus(int iCaviumPort);
96  bool SetStatus(int iCaviumPort, CSystemInfo::prt_linkstatus_t tLinkStatus);
97  bool VersionCompatible(void);
98  bool GetMAC(int iPort);
99  int GetBaseQueue(int iPort);
100  int GetNumQueues(int iPort);
101 
102 
103 #if OCTEON_SDK_VERSION_NUM < 301020000ull // SDK 3.1.2 build 000
104  cvmx_fpa_pool_info_t GetPoolInfo(int iPool);
105  bool SetPoolInfo(int iPool, cvmx_fpa_pool_info_t tPoolInfo);
106 #else
107 #endif
108 
110 
111 private:
112  typedef struct
113  {
114  std::string sDeviceName;
115  uint64_t ui64MAC;
116  int iOcteonPortNr;
117  } TNetDevInfo;
118 
119  CSystemInfo(bool bAsMaster);
120 
121  TSystemInfo *m_ptSystemInfo;
122  bool m_bAsMaster;
123  int m_iPortCounter;
124 
125 };
bool operator!=(const prt_linkstatus_t &T) const
Definition: SystemInfo.h:44
int GetBaseQueue(int iPort)
int GetNumQueues(int iPort)
static CSystemInfo * Instance(bool bAsMaster=false)
TLinkStatus tLinkStatus
Definition: SystemInfo.h:87
prt_linkstatus_t GetStatus(int iCaviumPort)
prt_linkstatus_t tLinkStat
Definition: SystemInfo.h:62
cvmx_fpa_pool_info_t cvmx_fpa_pool_info[CVMX_FPA_NUM_POOLS]
Definition: SystemInfo.h:78
cvmx_fpa_pool_info_t GetPoolInfo(int iPool)
bool GetMAC(int iPort)
uint64_t duplex
1 if link is full duplex
Definition: SystemInfo.h:34
static CSystemInfo * m_pInstance
Definition: SystemInfo.h:109
uint64_t status
1 if link is up
Definition: SystemInfo.h:35
bool SetStatus(int iCaviumPort, CSystemInfo::prt_linkstatus_t tLinkStatus)
TPortInfo tPortInfo[PHACTTAP_MAX_PORTS]
Definition: SystemInfo.h:70
bool SetPoolInfo(int iPool, cvmx_fpa_pool_info_t tPoolInfo)
cvmx_rwlock_wp_lock_t tLock
Definition: SystemInfo.h:84
void operator=(const prt_linkstatus_t &T)
Definition: SystemInfo.h:48
uint64_t reserved
Not used.
Definition: SystemInfo.h:38
bool VersionCompatible(void)
uint64_t speed
Speed link in Mbps.
Definition: SystemInfo.h:37