1 #ifndef PCAPPP_DPDK_DEVICE 2 #define PCAPPP_DPDK_DEVICE 10 #include "MBufRawPacket.h" 60 struct rte_eth_dev_tx_buffer;
69 #define DPDK_MAX_RX_QUEUES 16 70 #define DPDK_MAX_TX_QUEUES 16 71 #define PCPP_RSS_HASH_MAGIC_NUMBER 0x123456 288 uint16_t transmitDescriptorsNumber = 512,
289 uint16_t flushTxBufferTimeout = 100,
291 uint8_t* rssKey = DpdkDevice::m_RSSKey,
292 uint8_t rssKeyLength = 40)
404 uint16_t
getMtu()
const {
return m_DeviceMtu; }
411 bool setMtu(uint16_t newMtu);
481 uint16_t
receivePackets(
Packet** packetsArr, uint16_t packetsArrLength, uint16_t rxQueueId)
const;
503 uint16_t
sendPackets(
MBufRawPacket** rawPacketsArr, uint16_t arrLength, uint16_t txQueueId = 0,
bool useTxBuffer =
false);
525 uint16_t
sendPackets(
Packet** packetsArr, uint16_t arrLength, uint16_t txQueueId = 0,
bool useTxBuffer =
false);
612 bool sendPacket(
Packet& packet, uint16_t txQueueId = 0,
bool useTxBuffer =
false);
626 bool setFilter(std::string filterAsString);
714 uint16_t
flushTxBuffer(
bool flushOnlyIfTimeoutExpired =
false, uint16_t txQueueId = 0);
765 struct DpdkCoreConfiguration
770 void clear() { RxQueueId = -1; IsCoreInUse =
false; }
772 DpdkCoreConfiguration() : RxQueueId(-1), IsCoreInUse(
false) {}
776 bool initMemPool(
struct rte_mempool*& memPool,
const char* mempoolName, uint32_t mBufPoolSize);
778 bool configurePort(uint8_t numOfRxQueues, uint8_t numOfTxQueues);
779 bool initQueues(uint8_t numOfRxQueuesToInit, uint8_t numOfTxQueuesToInit);
782 static int dpdkCaptureThreadMain(
void* ptr);
784 void clearCoreConfiguration();
785 bool initCoreConfigurationByCoreMask(CoreMask coreMask);
786 int getCoresInUseCount()
const;
788 void setDeviceInfo();
790 typedef rte_mbuf* (*PacketIterator)(
void* packetStorage,
int index);
791 uint16_t sendPacketsInner(uint16_t txQueueId,
void* packetStorage, PacketIterator iter,
int arrLength,
bool useTxBuffer);
793 uint64_t convertRssHfToDpdkRssHf(uint64_t rssHF)
const;
794 uint64_t convertDpdkRssHfToRssHf(uint64_t dpdkRssHF)
const;
796 std::string m_DeviceName;
798 std::string m_PMDName;
799 std::string m_PciAddress;
805 uint16_t m_DeviceMtu;
806 struct rte_mempool* m_MBufMempool;
807 struct rte_eth_dev_tx_buffer** m_TxBuffers;
808 uint64_t m_TxBufferDrainTsc;
809 uint64_t* m_TxBufferLastDrainTsc;
810 DpdkCoreConfiguration m_CoreConfiguration[MAX_NUM_OF_CORES];
811 uint16_t m_TotalAvailableRxQueues;
812 uint16_t m_TotalAvailableTxQueues;
813 uint16_t m_NumOfRxQueuesOpened;
814 uint16_t m_NumOfTxQueuesOpened;
816 void* m_OnPacketsArriveUserCookie;
822 static uint8_t m_RSSKey[40];
Definition: DpdkDevice.h:182
The main namespace for the PcapPlusPlus lib.
uint16_t transmitDescriptorsNumber
Definition: DpdkDevice.h:244
bool open()
Definition: DpdkDevice.h:756
Definition: DpdkDevice.h:307
Definition: DpdkDevice.h:200
int getAmountOfMbufsInUse() const
DpdkPMDType
Definition: DpdkDevice.h:79
RxTxStats aggregatedRxStats
Definition: DpdkDevice.h:357
uint16_t flushTxBuffer(bool flushOnlyIfTimeoutExpired=false, uint16_t txQueueId=0)
Definition: DpdkDevice.h:180
Definition: DpdkDevice.h:94
Definition: DpdkDevice.h:224
uint64_t getConfiguredRssHashFunction() const
int linkSpeedMbps
Definition: DpdkDevice.h:321
std::string getDeviceName() const
Definition: DpdkDevice.h:377
uint16_t flushTxBufferTimeout
Definition: DpdkDevice.h:250
uint64_t getSupportedRssHashFunctions() const
uint64_t rxErroneousPackets
Definition: DpdkDevice.h:363
Definition: DpdkDevice.h:86
Definition: DpdkDevice.h:114
bool startCaptureSingleThread(OnDpdkPacketsArriveCallback onPacketsArrive, void *onPacketsArriveUserCookie)
std::string getPciAddress() const
Definition: DpdkDevice.h:399
Definition: DpdkDevice.h:106
Definition: PointerVector.h:24
Definition: PcapFilter.h:136
bool setMtu(uint16_t newMtu)
bool openMultiQueues(uint16_t numOfRxQueuesToOpen, uint16_t numOfTxQueuesToOpen, const DpdkDeviceConfiguration &config=DpdkDeviceConfiguration())
Definition: DpdkDevice.h:82
Definition: RawPacket.h:252
Definition: DpdkDevice.h:210
Definition: DpdkDevice.h:98
uint64_t rxPacketsDroppedByHW
Definition: DpdkDevice.h:361
RxTxStats aggregatedTxStats
Definition: DpdkDevice.h:359
void getLinkStatus(LinkStatus &linkStatus) const
Definition: MBufRawPacket.h:43
Definition: DpdkDevice.h:204
Definition: DpdkDevice.h:192
LinkDuplex
Definition: DpdkDevice.h:310
Definition: DpdkDevice.h:110
Definition: DpdkDevice.h:84
Definition: DpdkDevice.h:186
Definition: DpdkDevice.h:202
Definition: DpdkDevice.h:330
Definition: DpdkDevice.h:212
DpdkDeviceConfiguration(uint16_t receiveDescriptorsNumber=128, uint16_t transmitDescriptorsNumber=512, uint16_t flushTxBufferTimeout=100, uint64_t rssHashFunction=RSS_DEFAULT, uint8_t *rssKey=DpdkDevice::m_RSSKey, uint8_t rssKeyLength=40)
Definition: DpdkDevice.h:287
Definition: DpdkDevice.h:194
Definition: DpdkDevice.h:112
bool sendPacket(RawPacket &rawPacket, uint16_t txQueueId=0, bool useTxBuffer=false)
timespec timestamp
Definition: DpdkDevice.h:351
bool setFilter(GeneralFilter &filter)
int getDeviceId() const
Definition: DpdkDevice.h:373
uint64_t packetsPerSec
Definition: DpdkDevice.h:337
Definition: DpdkDevice.h:313
uint64_t bytes
Definition: DpdkDevice.h:335
MacAddress getMacAddress() const
Definition: DpdkDevice.h:382
Definition: DpdkDevice.h:167
uint16_t receivePackets(MBufRawPacketVector &rawPacketsArr, uint16_t rxQueueId) const
Definition: DpdkDevice.h:190
uint8_t * rssKey
Definition: DpdkDevice.h:258
uint8_t devId
Definition: DpdkDevice.h:349
Definition: DpdkDevice.h:100
Definition: DpdkDevice.h:108
uint64_t packets
Definition: DpdkDevice.h:333
uint16_t getMtu() const
Definition: DpdkDevice.h:404
uint64_t rxMbufAlocFailed
Definition: DpdkDevice.h:365
bool isDeviceSupportRssHashFunction(DpdkRssHashFunction rssHF) const
Definition: DpdkDevice.h:102
Definition: DpdkDevice.h:184
Definition: DpdkDevice.h:216
Definition: DpdkDevice.h:104
DpdkPMDType getPMDType() const
Definition: DpdkDevice.h:394
Definition: DpdkDevice.h:220
void getStatistics(DpdkDeviceStats &stats) const
Definition: DpdkDevice.h:188
uint16_t receiveDescriptorsNumber
Definition: DpdkDevice.h:238
Definition: DpdkDevice.h:232
Definition: DpdkDevice.h:90
Definition: DpdkDevice.h:346
Definition: DpdkDevice.h:218
uint64_t bytesPerSec
Definition: DpdkDevice.h:339
Definition: DpdkDevice.h:88
uint16_t getNumOfOpenedTxQueues() const
Definition: DpdkDevice.h:437
uint16_t getTotalNumOfRxQueues() const
Definition: DpdkDevice.h:442
Definition: DpdkDevice.h:206
Definition: DpdkDevice.h:96
Definition: DpdkDevice.h:118
Definition: DpdkDevice.h:208
Definition: DpdkDeviceList.h:72
uint32_t getCurrentCoreId() const
bool startCaptureMultiThreads(OnDpdkPacketsArriveCallback onPacketsArrive, void *onPacketsArriveUserCookie, CoreMask coreMask)
bool linkUp
Definition: DpdkDevice.h:319
int getAmountOfFreeMbufs() const
uint16_t sendPackets(MBufRawPacket **rawPacketsArr, uint16_t arrLength, uint16_t txQueueId=0, bool useTxBuffer=false)
Definition: DpdkDevice.h:116
uint16_t getTotalNumOfTxQueues() const
Definition: DpdkDevice.h:447
std::vector< std::string > rssHashFunctionMaskToString(uint64_t rssHFMask) const
Definition: MacAddress.h:28
uint64_t rssHashFunction
Definition: DpdkDevice.h:271
uint8_t rssKeyLength
Definition: DpdkDevice.h:264
Definition: DpdkDevice.h:198
Definition: DpdkDevice.h:214
Definition: DpdkDevice.h:92
LinkDuplex linkDuplex
Definition: DpdkDevice.h:323
Definition: DpdkDevice.h:222
Definition: DpdkDevice.h:196
std::string getPMDName() const
Definition: DpdkDevice.h:388
void(* OnDpdkPacketsArriveCallback)(MBufRawPacket *packets, uint32_t numOfPackets, uint8_t threadId, DpdkDevice *device, void *userCookie)
Definition: DpdkDevice.h:130
uint16_t getNumOfOpenedRxQueues() const
Definition: DpdkDevice.h:432
DpdkRssHashFunction
Definition: DpdkDevice.h:177