1 #ifndef PCAPPP_DPDK_DEVICE 2 #define PCAPPP_DPDK_DEVICE 12 #include "MBufRawPacket.h" 62 struct rte_eth_dev_tx_buffer;
71 #define DPDK_MAX_RX_QUEUES 16 72 #define DPDK_MAX_TX_QUEUES 16 73 #define PCPP_RSS_HASH_MAGIC_NUMBER 0x123456 290 uint16_t transmitDescriptorsNumber = 512,
291 uint16_t flushTxBufferTimeout = 100,
293 uint8_t* rssKey = DpdkDevice::m_RSSKey,
294 uint8_t rssKeyLength = 40)
406 uint16_t
getMtu()
const {
return m_DeviceMtu; }
413 bool setMtu(uint16_t newMtu);
483 uint16_t
receivePackets(
Packet** packetsArr, uint16_t packetsArrLength, uint16_t rxQueueId)
const;
505 uint16_t
sendPackets(
MBufRawPacket** rawPacketsArr, uint16_t arrLength, uint16_t txQueueId = 0,
bool useTxBuffer =
false);
527 uint16_t
sendPackets(
Packet** packetsArr, uint16_t arrLength, uint16_t txQueueId = 0,
bool useTxBuffer =
false);
614 bool sendPacket(
Packet& packet, uint16_t txQueueId = 0,
bool useTxBuffer =
false);
628 bool setFilter(std::string filterAsString);
716 uint16_t
flushTxBuffer(
bool flushOnlyIfTimeoutExpired =
false, uint16_t txQueueId = 0);
767 struct DpdkCoreConfiguration
772 void clear() { RxQueueId = -1; IsCoreInUse =
false; }
774 DpdkCoreConfiguration() : RxQueueId(-1), IsCoreInUse(
false) {}
778 bool initMemPool(
struct rte_mempool*& memPool,
const char* mempoolName, uint32_t mBufPoolSize);
780 bool configurePort(uint8_t numOfRxQueues, uint8_t numOfTxQueues);
781 bool initQueues(uint8_t numOfRxQueuesToInit, uint8_t numOfTxQueuesToInit);
784 static int dpdkCaptureThreadMain(
void* ptr);
786 void clearCoreConfiguration();
787 bool initCoreConfigurationByCoreMask(CoreMask coreMask);
788 int getCoresInUseCount()
const;
790 void setDeviceInfo();
792 typedef rte_mbuf* (*PacketIterator)(
void* packetStorage,
int index);
793 uint16_t sendPacketsInner(uint16_t txQueueId,
void* packetStorage, PacketIterator iter,
int arrLength,
bool useTxBuffer);
795 uint64_t convertRssHfToDpdkRssHf(uint64_t rssHF)
const;
796 uint64_t convertDpdkRssHfToRssHf(uint64_t dpdkRssHF)
const;
798 std::string m_DeviceName;
800 std::string m_PMDName;
801 std::string m_PciAddress;
807 uint16_t m_DeviceMtu;
808 struct rte_mempool* m_MBufMempool;
809 struct rte_eth_dev_tx_buffer** m_TxBuffers;
810 uint64_t m_TxBufferDrainTsc;
811 uint64_t* m_TxBufferLastDrainTsc;
812 DpdkCoreConfiguration m_CoreConfiguration[MAX_NUM_OF_CORES];
813 uint16_t m_TotalAvailableRxQueues;
814 uint16_t m_TotalAvailableTxQueues;
815 uint16_t m_NumOfRxQueuesOpened;
816 uint16_t m_NumOfTxQueuesOpened;
818 void* m_OnPacketsArriveUserCookie;
824 static uint8_t m_RSSKey[40];
Definition: DpdkDevice.h:184
The main namespace for the PcapPlusPlus lib.
uint16_t transmitDescriptorsNumber
Definition: DpdkDevice.h:246
bool open()
Definition: DpdkDevice.h:758
Definition: DpdkDevice.h:309
Definition: DpdkDevice.h:202
int getAmountOfMbufsInUse() const
DpdkPMDType
Definition: DpdkDevice.h:81
RxTxStats aggregatedRxStats
Definition: DpdkDevice.h:359
uint16_t flushTxBuffer(bool flushOnlyIfTimeoutExpired=false, uint16_t txQueueId=0)
Definition: DpdkDevice.h:182
Definition: DpdkDevice.h:96
Definition: DpdkDevice.h:226
uint64_t getConfiguredRssHashFunction() const
int linkSpeedMbps
Definition: DpdkDevice.h:323
std::string getDeviceName() const
Definition: DpdkDevice.h:379
uint16_t flushTxBufferTimeout
Definition: DpdkDevice.h:252
uint64_t getSupportedRssHashFunctions() const
uint64_t rxErroneousPackets
Definition: DpdkDevice.h:365
Definition: DpdkDevice.h:88
Definition: DpdkDevice.h:116
bool startCaptureSingleThread(OnDpdkPacketsArriveCallback onPacketsArrive, void *onPacketsArriveUserCookie)
std::string getPciAddress() const
Definition: DpdkDevice.h:401
Definition: DpdkDevice.h:108
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:84
Definition: RawPacket.h:254
Definition: DpdkDevice.h:212
Definition: DpdkDevice.h:100
uint64_t rxPacketsDroppedByHW
Definition: DpdkDevice.h:363
RxTxStats aggregatedTxStats
Definition: DpdkDevice.h:361
void getLinkStatus(LinkStatus &linkStatus) const
Definition: MBufRawPacket.h:45
Definition: DpdkDevice.h:206
Definition: DpdkDevice.h:194
LinkDuplex
Definition: DpdkDevice.h:312
Definition: DpdkDevice.h:112
Definition: DpdkDevice.h:86
Definition: DpdkDevice.h:188
Definition: DpdkDevice.h:204
Definition: DpdkDevice.h:332
Definition: DpdkDevice.h:214
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:289
Definition: DpdkDevice.h:196
Definition: DpdkDevice.h:114
bool sendPacket(RawPacket &rawPacket, uint16_t txQueueId=0, bool useTxBuffer=false)
timespec timestamp
Definition: DpdkDevice.h:353
bool setFilter(GeneralFilter &filter)
int getDeviceId() const
Definition: DpdkDevice.h:375
uint64_t packetsPerSec
Definition: DpdkDevice.h:339
Definition: DpdkDevice.h:315
uint64_t bytes
Definition: DpdkDevice.h:337
MacAddress getMacAddress() const
Definition: DpdkDevice.h:384
Definition: DpdkDevice.h:169
uint16_t receivePackets(MBufRawPacketVector &rawPacketsArr, uint16_t rxQueueId) const
Definition: DpdkDevice.h:192
uint8_t * rssKey
Definition: DpdkDevice.h:260
uint8_t devId
Definition: DpdkDevice.h:351
Definition: DpdkDevice.h:102
Definition: DpdkDevice.h:110
uint64_t packets
Definition: DpdkDevice.h:335
uint16_t getMtu() const
Definition: DpdkDevice.h:406
uint64_t rxMbufAlocFailed
Definition: DpdkDevice.h:367
bool isDeviceSupportRssHashFunction(DpdkRssHashFunction rssHF) const
Definition: DpdkDevice.h:104
Definition: DpdkDevice.h:186
Definition: DpdkDevice.h:218
Definition: DpdkDevice.h:106
DpdkPMDType getPMDType() const
Definition: DpdkDevice.h:396
Definition: DpdkDevice.h:222
void getStatistics(DpdkDeviceStats &stats) const
Definition: DpdkDevice.h:190
uint16_t receiveDescriptorsNumber
Definition: DpdkDevice.h:240
Definition: DpdkDevice.h:234
Definition: DpdkDevice.h:92
Definition: DpdkDevice.h:348
Definition: DpdkDevice.h:220
uint64_t bytesPerSec
Definition: DpdkDevice.h:341
Definition: DpdkDevice.h:90
uint16_t getNumOfOpenedTxQueues() const
Definition: DpdkDevice.h:439
uint16_t getTotalNumOfRxQueues() const
Definition: DpdkDevice.h:444
Definition: DpdkDevice.h:208
Definition: DpdkDevice.h:98
Definition: DpdkDevice.h:120
Definition: DpdkDevice.h:210
Definition: DpdkDeviceList.h:73
uint32_t getCurrentCoreId() const
bool startCaptureMultiThreads(OnDpdkPacketsArriveCallback onPacketsArrive, void *onPacketsArriveUserCookie, CoreMask coreMask)
bool linkUp
Definition: DpdkDevice.h:321
int getAmountOfFreeMbufs() const
uint16_t sendPackets(MBufRawPacket **rawPacketsArr, uint16_t arrLength, uint16_t txQueueId=0, bool useTxBuffer=false)
Definition: DpdkDevice.h:118
uint16_t getTotalNumOfTxQueues() const
Definition: DpdkDevice.h:449
std::vector< std::string > rssHashFunctionMaskToString(uint64_t rssHFMask) const
Definition: MacAddress.h:28
uint64_t rssHashFunction
Definition: DpdkDevice.h:273
uint8_t rssKeyLength
Definition: DpdkDevice.h:266
Definition: DpdkDevice.h:200
Definition: DpdkDevice.h:216
Definition: DpdkDevice.h:94
LinkDuplex linkDuplex
Definition: DpdkDevice.h:325
Definition: DpdkDevice.h:224
Definition: DpdkDevice.h:198
std::string getPMDName() const
Definition: DpdkDevice.h:390
void(* OnDpdkPacketsArriveCallback)(MBufRawPacket *packets, uint32_t numOfPackets, uint8_t threadId, DpdkDevice *device, void *userCookie)
Definition: DpdkDevice.h:132
uint16_t getNumOfOpenedRxQueues() const
Definition: DpdkDevice.h:434
DpdkRssHashFunction
Definition: DpdkDevice.h:179