PcapPlusPlus  20.08
DpdkDeviceList.h
Go to the documentation of this file.
1 #ifndef PCAPPP_DPDK_DEVICE_LIST
2 #define PCAPPP_DPDK_DEVICE_LIST
3 
4 #include "SystemUtils.h"
5 #include "DpdkDevice.h"
6 #include "Logger.h"
7 #include <vector>
8 
18 namespace pcpp
19 {
20 
32  {
33  public:
37  virtual ~DpdkWorkerThread() {}
38 
44  virtual bool run(uint32_t coreId) = 0;
45 
50  virtual void stop() = 0;
51 
57  virtual uint32_t getCoreId() const = 0;
58  };
59 
60  class KniDeviceList;
61 
72  {
73  friend class KniDeviceList;
74  private:
75  bool m_IsInitialized;
76  static bool m_IsDpdkInitialized;
77  static uint32_t m_MBufPoolSizePerDevice;
78  static CoreMask m_CoreMask;
79  std::vector<DpdkDevice*> m_DpdkDeviceList;
80  std::vector<DpdkWorkerThread*> m_WorkerThreads;
81 
83 
84  bool isInitialized() const { return (m_IsInitialized && m_IsDpdkInitialized); }
85  bool initDpdkDevices(uint32_t mBufPoolSizePerDevice);
86  static bool verifyHugePagesAndDpdkDriver();
87 
88  static int dpdkWorkerThreadStart(void* ptr);
89  public:
90 
91  ~DpdkDeviceList();
92 
99  {
100  static DpdkDeviceList instance;
101  if (!instance.isInitialized())
102  instance.initDpdkDevices(DpdkDeviceList::m_MBufPoolSizePerDevice);
103 
104  return instance;
105  }
106 
127  static bool initDpdk(CoreMask coreMask, uint32_t mBufPoolSizePerDevice, uint8_t masterCore = 0);
128 
134  DpdkDevice* getDeviceByPort(int portId) const;
135 
141  DpdkDevice* getDeviceByPciAddress(const std::string& pciAddr) const;
142 
146  const std::vector<DpdkDevice*>& getDpdkDeviceList() const { return m_DpdkDeviceList; }
147 
152 
157  void setDpdkLogLevel(LoggerPP::LogLevel logLevel);
158 
164 
170  bool writeDpdkLogToFile(FILE* logFile);
171 
190  bool startDpdkWorkerThreads(CoreMask coreMask, std::vector<DpdkWorkerThread*>& workerThreadsVec);
191 
196  void stopDpdkWorkerThreads();
197  };
198 
199 } // namespace pcpp
200 
201 #endif /* PCAPPP_DPDK_DEVICE_LIST */
pcpp::SystemCore
Definition: SystemUtils.h:32
pcpp::DpdkDeviceList::getDpdkLogLevel
LoggerPP::LogLevel getDpdkLogLevel() const
pcpp::DpdkDeviceList::stopDpdkWorkerThreads
void stopDpdkWorkerThreads()
pcpp::DpdkWorkerThread
Definition: DpdkDeviceList.h:31
pcpp::DpdkDevice
Definition: DpdkDevice.h:164
SystemUtils.h
pcpp::DpdkDeviceList::initDpdk
static bool initDpdk(CoreMask coreMask, uint32_t mBufPoolSizePerDevice, uint8_t masterCore=0)
pcpp::DpdkDeviceList::getDpdkDeviceList
const std::vector< DpdkDevice * > & getDpdkDeviceList() const
Definition: DpdkDeviceList.h:146
DpdkDevice.h
pcpp::DpdkDeviceList::getInstance
static DpdkDeviceList & getInstance()
Definition: DpdkDeviceList.h:98
pcpp::DpdkDeviceList
Definition: DpdkDeviceList.h:71
Logger.h
pcpp::DpdkDeviceList::startDpdkWorkerThreads
bool startDpdkWorkerThreads(CoreMask coreMask, std::vector< DpdkWorkerThread * > &workerThreadsVec)
pcpp::DpdkWorkerThread::stop
virtual void stop()=0
pcpp::KniDeviceList
Definition: KniDeviceList.h:22
pcpp::DpdkDeviceList::writeDpdkLogToFile
bool writeDpdkLogToFile(FILE *logFile)
pcpp::DpdkDeviceList::getDeviceByPciAddress
DpdkDevice * getDeviceByPciAddress(const std::string &pciAddr) const
pcpp
The main namespace for the PcapPlusPlus lib.
pcpp::DpdkDeviceList::setDpdkLogLevel
void setDpdkLogLevel(LoggerPP::LogLevel logLevel)
pcpp::LoggerPP::LogLevel
LogLevel
Definition: Logger.h:89
pcpp::DpdkDeviceList::getDeviceByPort
DpdkDevice * getDeviceByPort(int portId) const
pcpp::DpdkWorkerThread::~DpdkWorkerThread
virtual ~DpdkWorkerThread()
Definition: DpdkDeviceList.h:37
pcpp::DpdkDeviceList::getDpdkMasterCore
SystemCore getDpdkMasterCore() const
pcpp::DpdkWorkerThread::run
virtual bool run(uint32_t coreId)=0
pcpp::DpdkWorkerThread::getCoreId
virtual uint32_t getCoreId() const =0