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 279 uint16_t transmitDescriptorsNumber = 512,
280 uint16_t flushTxBufferTimeout = 100,
282 uint8_t* rssKey = DpdkDevice::m_RSSKey,
283 uint8_t rssKeyLength = 40)
395 uint16_t
getMtu()
const {
return m_DeviceMtu; }
402 bool setMtu(uint16_t newMtu);
472 uint16_t
receivePackets(
Packet** packetsArr, uint16_t packetsArrLength, uint16_t rxQueueId)
const;
494 uint16_t
sendPackets(
MBufRawPacket** rawPacketsArr, uint16_t arrLength, uint16_t txQueueId = 0,
bool useTxBuffer =
false);
516 uint16_t
sendPackets(
Packet** packetsArr, uint16_t arrLength, uint16_t txQueueId = 0,
bool useTxBuffer =
false);
603 bool sendPacket(
Packet& packet, uint16_t txQueueId = 0,
bool useTxBuffer =
false);
617 bool setFilter(std::string filterAsString);
705 uint16_t
flushTxBuffer(
bool flushOnlyIfTimeoutExpired =
false, uint16_t txQueueId = 0);
745 struct DpdkCoreConfiguration
750 void clear() { RxQueueId = -1; IsCoreInUse =
false; }
752 DpdkCoreConfiguration() : RxQueueId(-1), IsCoreInUse(
false) {}
756 bool initMemPool(
struct rte_mempool*& memPool,
const char* mempoolName, uint32_t mBufPoolSize);
758 bool configurePort(uint8_t numOfRxQueues, uint8_t numOfTxQueues);
759 bool initQueues(uint8_t numOfRxQueuesToInit, uint8_t numOfTxQueuesToInit);
762 static int dpdkCaptureThreadMain(
void* ptr);
764 void clearCoreConfiguration();
765 bool initCoreConfigurationByCoreMask(CoreMask coreMask);
766 int getCoresInUseCount()
const;
768 void setDeviceInfo();
770 typedef rte_mbuf* (*PacketIterator)(
void* packetStorage,
int index);
771 uint16_t sendPacketsInner(uint16_t txQueueId,
void* packetStorage, PacketIterator iter,
int arrLength,
bool useTxBuffer);
773 uint64_t convertRssHfToDpdkRssHf(uint64_t rssHF)
const;
774 uint64_t convertDpdkRssHfToRssHf(uint64_t dpdkRssHF)
const;
776 std::string m_DeviceName;
778 std::string m_PMDName;
779 std::string m_PciAddress;
785 uint16_t m_DeviceMtu;
786 struct rte_mempool* m_MBufMempool;
787 struct rte_eth_dev_tx_buffer** m_TxBuffers;
788 uint64_t m_TxBufferDrainTsc;
789 uint64_t* m_TxBufferLastDrainTsc;
790 DpdkCoreConfiguration m_CoreConfiguration[MAX_NUM_OF_CORES];
791 uint16_t m_TotalAvailableRxQueues;
792 uint16_t m_TotalAvailableTxQueues;
793 uint16_t m_NumOfRxQueuesOpened;
794 uint16_t m_NumOfTxQueuesOpened;
796 void* m_OnPacketsArriveUserCookie;
802 static uint8_t m_RSSKey[40];
Definition: DpdkDevice.h:178
The main namespace for the PcapPlusPlus lib.
uint16_t transmitDescriptorsNumber
Definition: DpdkDevice.h:236
bool open()
Definition: DpdkDevice.h:736
Definition: DpdkDevice.h:298
Definition: DpdkDevice.h:196
int getAmountOfMbufsInUse() const
DpdkPMDType
Definition: DpdkDevice.h:77
RxTxStats aggregatedRxStats
Definition: DpdkDevice.h:348
uint16_t flushTxBuffer(bool flushOnlyIfTimeoutExpired=false, uint16_t txQueueId=0)
Definition: DpdkDevice.h:92
int linkSpeedMbps
Definition: DpdkDevice.h:312
std::string getDeviceName() const
Definition: DpdkDevice.h:368
uint16_t flushTxBufferTimeout
Definition: DpdkDevice.h:242
uint64_t getSupportedRssHashFunctions() const
uint64_t rxErroneousPackets
Definition: DpdkDevice.h:354
Definition: DpdkDevice.h:84
Definition: DpdkDevice.h:112
bool startCaptureSingleThread(OnDpdkPacketsArriveCallback onPacketsArrive, void *onPacketsArriveUserCookie)
std::string getPciAddress() const
Definition: DpdkDevice.h:390
Definition: DpdkDevice.h:104
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:80
Definition: RawPacket.h:252
Definition: DpdkDevice.h:206
Definition: DpdkDevice.h:96
RxTxStats aggregatedTxStats
Definition: DpdkDevice.h:350
void getLinkStatus(LinkStatus &linkStatus) const
Definition: MBufRawPacket.h:43
Definition: DpdkDevice.h:200
Definition: DpdkDevice.h:188
LinkDuplex
Definition: DpdkDevice.h:301
Definition: DpdkDevice.h:108
Definition: DpdkDevice.h:82
Definition: DpdkDevice.h:182
Definition: DpdkDevice.h:198
Definition: DpdkDevice.h:321
Definition: DpdkDevice.h:208
Definition: DpdkDevice.h:190
Definition: DpdkDevice.h:110
bool sendPacket(RawPacket &rawPacket, uint16_t txQueueId=0, bool useTxBuffer=false)
timespec timestamp
Definition: DpdkDevice.h:342
bool setFilter(GeneralFilter &filter)
int getDeviceId() const
Definition: DpdkDevice.h:364
uint64_t packetsPerSec
Definition: DpdkDevice.h:328
Definition: DpdkDevice.h:304
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:278
uint64_t bytes
Definition: DpdkDevice.h:326
MacAddress getMacAddress() const
Definition: DpdkDevice.h:373
Definition: DpdkDevice.h:165
uint16_t receivePackets(MBufRawPacketVector &rawPacketsArr, uint16_t rxQueueId) const
Definition: DpdkDevice.h:186
uint8_t * rssKey
Definition: DpdkDevice.h:250
uint8_t devId
Definition: DpdkDevice.h:340
Definition: DpdkDevice.h:98
Definition: DpdkDevice.h:106
uint64_t packets
Definition: DpdkDevice.h:324
uint16_t getMtu() const
Definition: DpdkDevice.h:395
uint64_t rxMbufAlocFailed
Definition: DpdkDevice.h:356
bool isDeviceSupportRssHashFunction(DpdkRssHashFunction rssHF) const
Definition: DpdkDevice.h:100
Definition: DpdkDevice.h:180
Definition: DpdkDevice.h:212
Definition: DpdkDevice.h:102
DpdkPMDType getPMDType() const
Definition: DpdkDevice.h:385
Definition: DpdkDevice.h:216
void getStatistics(DpdkDeviceStats &stats) const
Definition: DpdkDevice.h:184
uint16_t receiveDescriptorsNumber
Definition: DpdkDevice.h:230
Definition: DpdkDevice.h:224
Definition: DpdkDevice.h:88
Definition: DpdkDevice.h:337
Definition: DpdkDevice.h:214
uint64_t bytesPerSec
Definition: DpdkDevice.h:330
Definition: DpdkDevice.h:86
uint16_t getNumOfOpenedTxQueues() const
Definition: DpdkDevice.h:428
uint16_t getTotalNumOfRxQueues() const
Definition: DpdkDevice.h:433
Definition: DpdkDevice.h:202
Definition: DpdkDevice.h:94
Definition: DpdkDevice.h:116
Definition: DpdkDevice.h:204
Definition: DpdkDeviceList.h:72
uint32_t getCurrentCoreId() const
bool startCaptureMultiThreads(OnDpdkPacketsArriveCallback onPacketsArrive, void *onPacketsArriveUserCookie, CoreMask coreMask)
bool linkUp
Definition: DpdkDevice.h:310
int getAmountOfFreeMbufs() const
uint64_t rxPacketsDropeedByHW
Definition: DpdkDevice.h:352
uint16_t sendPackets(MBufRawPacket **rawPacketsArr, uint16_t arrLength, uint16_t txQueueId=0, bool useTxBuffer=false)
Definition: DpdkDevice.h:114
uint16_t getTotalNumOfTxQueues() const
Definition: DpdkDevice.h:438
Definition: MacAddress.h:28
uint64_t rssHashFunction
Definition: DpdkDevice.h:263
uint8_t rssKeyLength
Definition: DpdkDevice.h:256
Definition: DpdkDevice.h:194
Definition: DpdkDevice.h:210
Definition: DpdkDevice.h:90
LinkDuplex linkDuplex
Definition: DpdkDevice.h:314
Definition: DpdkDevice.h:192
std::string getPMDName() const
Definition: DpdkDevice.h:379
void(* OnDpdkPacketsArriveCallback)(MBufRawPacket *packets, uint32_t numOfPackets, uint8_t threadId, DpdkDevice *device, void *userCookie)
Definition: DpdkDevice.h:128
uint16_t getNumOfOpenedRxQueues() const
Definition: DpdkDevice.h:423
DpdkRssHashFunction
Definition: DpdkDevice.h:175