1 #ifndef PCAPPP_DPDK_DEVICE 2 #define PCAPPP_DPDK_DEVICE 9 #include "MBufRawPacket.h" 59 struct rte_eth_dev_tx_buffer;
68 #define DPDK_MAX_RX_QUEUES 16 69 #define DPDK_MAX_TX_QUEUES 16 278 uint16_t transmitDescriptorsNumber = 512,
279 uint16_t flushTxBufferTimeout = 100,
281 uint8_t* rssKey = DpdkDevice::m_RSSKey,
282 uint8_t rssKeyLength = 40)
394 uint16_t
getMtu()
const {
return m_DeviceMtu; }
401 bool setMtu(uint16_t newMtu);
471 uint16_t
receivePackets(
Packet** packetsArr, uint16_t packetsArrLength, uint16_t rxQueueId)
const;
493 uint16_t
sendPackets(
MBufRawPacket** rawPacketsArr, uint16_t arrLength, uint16_t txQueueId = 0,
bool useTxBuffer =
false);
515 uint16_t
sendPackets(
Packet** packetsArr, uint16_t arrLength, uint16_t txQueueId = 0,
bool useTxBuffer =
false);
602 bool sendPacket(
Packet& packet, uint16_t txQueueId = 0,
bool useTxBuffer =
false);
614 bool setFilter(std::string filterAsString);
702 uint16_t
flushTxBuffer(
bool flushOnlyIfTimeoutExpired =
false, uint16_t txQueueId = 0);
742 struct DpdkCoreConfiguration
747 void clear() { RxQueueId = -1; IsCoreInUse =
false; }
749 DpdkCoreConfiguration() : RxQueueId(-1), IsCoreInUse(
false) {}
753 bool initMemPool(
struct rte_mempool*& memPool,
const char* mempoolName, uint32_t mBufPoolSize);
755 bool configurePort(uint8_t numOfRxQueues, uint8_t numOfTxQueues);
756 bool initQueues(uint8_t numOfRxQueuesToInit, uint8_t numOfTxQueuesToInit);
759 static int dpdkCaptureThreadMain(
void* ptr);
761 void clearCoreConfiguration();
762 bool initCoreConfigurationByCoreMask(CoreMask coreMask);
763 int getCoresInUseCount()
const;
765 void setDeviceInfo();
767 typedef rte_mbuf* (*PacketIterator)(
void* packetStorage,
int index);
768 uint16_t sendPacketsInner(uint16_t txQueueId,
void* packetStorage, PacketIterator iter,
int arrLength,
bool useTxBuffer);
770 uint64_t convertRssHfToDpdkRssHf(uint64_t rssHF)
const;
771 uint64_t convertDpdkRssHfToRssHf(uint64_t dpdkRssHF)
const;
773 char m_DeviceName[30];
775 std::string m_PMDName;
776 std::string m_PciAddress;
782 uint16_t m_DeviceMtu;
783 struct rte_mempool* m_MBufMempool;
784 struct rte_eth_dev_tx_buffer** m_TxBuffers;
785 uint64_t m_TxBufferDrainTsc;
786 uint64_t* m_TxBufferLastDrainTsc;
787 DpdkCoreConfiguration m_CoreConfiguration[MAX_NUM_OF_CORES];
788 uint16_t m_TotalAvailableRxQueues;
789 uint16_t m_TotalAvailableTxQueues;
790 uint16_t m_NumOfRxQueuesOpened;
791 uint16_t m_NumOfTxQueuesOpened;
793 void* m_OnPacketsArriveUserCookie;
799 static uint8_t m_RSSKey[40];
Definition: DpdkDevice.h:177
The main namespace for the PcapPlusPlus lib.
uint16_t transmitDescriptorsNumber
Definition: DpdkDevice.h:235
bool open()
Definition: DpdkDevice.h:733
Definition: DpdkDevice.h:297
Definition: DpdkDevice.h:195
int getAmountOfMbufsInUse() const
DpdkPMDType
Definition: DpdkDevice.h:77
RxTxStats aggregatedRxStats
Definition: DpdkDevice.h:347
uint16_t flushTxBuffer(bool flushOnlyIfTimeoutExpired=false, uint16_t txQueueId=0)
Definition: DpdkDevice.h:91
int linkSpeedMbps
Definition: DpdkDevice.h:311
std::string getDeviceName() const
Definition: DpdkDevice.h:367
uint16_t flushTxBufferTimeout
Definition: DpdkDevice.h:241
uint64_t getSupportedRssHashFunctions() const
uint64_t rxErroneousPackets
Definition: DpdkDevice.h:353
Definition: DpdkDevice.h:83
Definition: DpdkDevice.h:111
bool startCaptureSingleThread(OnDpdkPacketsArriveCallback onPacketsArrive, void *onPacketsArriveUserCookie)
std::string getPciAddress() const
Definition: DpdkDevice.h:389
Definition: DpdkDevice.h:103
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:79
Definition: RawPacket.h:252
Definition: DpdkDevice.h:205
Definition: DpdkDevice.h:95
RxTxStats aggregatedTxStats
Definition: DpdkDevice.h:349
void getLinkStatus(LinkStatus &linkStatus) const
Definition: MBufRawPacket.h:43
Definition: DpdkDevice.h:199
Definition: DpdkDevice.h:187
LinkDuplex
Definition: DpdkDevice.h:300
Definition: DpdkDevice.h:107
Definition: DpdkDevice.h:81
Definition: DpdkDevice.h:181
Definition: DpdkDevice.h:197
Definition: DpdkDevice.h:320
Definition: DpdkDevice.h:207
Definition: DpdkDevice.h:189
Definition: DpdkDevice.h:109
bool sendPacket(RawPacket &rawPacket, uint16_t txQueueId=0, bool useTxBuffer=false)
timespec timestamp
Definition: DpdkDevice.h:341
bool setFilter(GeneralFilter &filter)
int getDeviceId() const
Definition: DpdkDevice.h:363
uint64_t packetsPerSec
Definition: DpdkDevice.h:327
Definition: DpdkDevice.h:303
DpdkDeviceConfiguration(uint16_t receiveDescriptorsNumber=128, uint16_t transmitDescriptorsNumber=512, uint16_t flushTxBufferTimeout=100, uint64_t rssHashFunction=RSS_IPV4|RSS_IPV6, uint8_t *rssKey=DpdkDevice::m_RSSKey, uint8_t rssKeyLength=40)
Definition: DpdkDevice.h:277
uint64_t bytes
Definition: DpdkDevice.h:325
MacAddress getMacAddress() const
Definition: DpdkDevice.h:372
Definition: DpdkDevice.h:164
uint16_t receivePackets(MBufRawPacketVector &rawPacketsArr, uint16_t rxQueueId) const
Definition: DpdkDevice.h:185
uint8_t * rssKey
Definition: DpdkDevice.h:249
uint8_t devId
Definition: DpdkDevice.h:339
Definition: DpdkDevice.h:97
Definition: DpdkDevice.h:105
uint64_t packets
Definition: DpdkDevice.h:323
uint16_t getMtu() const
Definition: DpdkDevice.h:394
uint64_t rxMbufAlocFailed
Definition: DpdkDevice.h:355
bool isDeviceSupportRssHashFunction(DpdkRssHashFunction rssHF) const
Definition: DpdkDevice.h:99
Definition: DpdkDevice.h:179
Definition: DpdkDevice.h:211
Definition: DpdkDevice.h:101
DpdkPMDType getPMDType() const
Definition: DpdkDevice.h:384
Definition: DpdkDevice.h:215
void getStatistics(DpdkDeviceStats &stats) const
Definition: DpdkDevice.h:183
uint16_t receiveDescriptorsNumber
Definition: DpdkDevice.h:229
Definition: DpdkDevice.h:223
Definition: DpdkDevice.h:87
Definition: DpdkDevice.h:336
Definition: DpdkDevice.h:213
uint64_t bytesPerSec
Definition: DpdkDevice.h:329
Definition: DpdkDevice.h:85
uint16_t getNumOfOpenedTxQueues() const
Definition: DpdkDevice.h:427
uint16_t getTotalNumOfRxQueues() const
Definition: DpdkDevice.h:432
Definition: DpdkDevice.h:201
Definition: DpdkDevice.h:93
Definition: DpdkDevice.h:115
Definition: DpdkDevice.h:203
Definition: DpdkDeviceList.h:71
uint32_t getCurrentCoreId() const
bool startCaptureMultiThreads(OnDpdkPacketsArriveCallback onPacketsArrive, void *onPacketsArriveUserCookie, CoreMask coreMask)
bool linkUp
Definition: DpdkDevice.h:309
int getAmountOfFreeMbufs() const
uint64_t rxPacketsDropeedByHW
Definition: DpdkDevice.h:351
uint16_t sendPackets(MBufRawPacket **rawPacketsArr, uint16_t arrLength, uint16_t txQueueId=0, bool useTxBuffer=false)
Definition: DpdkDevice.h:113
uint16_t getTotalNumOfTxQueues() const
Definition: DpdkDevice.h:437
Definition: MacAddress.h:27
uint64_t rssHashFunction
Definition: DpdkDevice.h:262
uint8_t rssKeyLength
Definition: DpdkDevice.h:255
Definition: DpdkDevice.h:193
Definition: DpdkDevice.h:209
Definition: DpdkDevice.h:89
LinkDuplex linkDuplex
Definition: DpdkDevice.h:313
Definition: DpdkDevice.h:191
std::string getPMDName() const
Definition: DpdkDevice.h:378
void(* OnDpdkPacketsArriveCallback)(MBufRawPacket *packets, uint32_t numOfPackets, uint8_t threadId, DpdkDevice *device, void *userCookie)
Definition: DpdkDevice.h:127
uint16_t getNumOfOpenedRxQueues() const
Definition: DpdkDevice.h:422
DpdkRssHashFunction
Definition: DpdkDevice.h:174