11 #include "MBufRawPacket.h"
64 struct rte_eth_dev_tx_buffer;
73 #define DPDK_MAX_RX_QUEUES 16
74 #define DPDK_MAX_TX_QUEUES 16
75 #define PCPP_RSS_HASH_MAGIC_NUMBER 0x123456
474 return m_NumOfRxQueuesOpened;
482 return m_NumOfTxQueuesOpened;
490 return m_TotalAvailableRxQueues;
498 return m_TotalAvailableTxQueues;
563 bool useTxBuffer =
false);
589 uint16_t
sendPackets(
Packet** packetsArr, uint16_t arrLength, uint16_t txQueueId = 0,
bool useTxBuffer =
false);
799 uint16_t
flushTxBuffer(
bool flushOnlyIfTimeoutExpired =
false, uint16_t txQueueId = 0);
854 struct DpdkCoreConfiguration
865 DpdkCoreConfiguration() : RxQueueId(-1), IsCoreInUse(false)
869 DpdkDevice(
int port, uint32_t mBufPoolSize, uint16_t mMbufDataSize);
870 bool initMemPool(
struct rte_mempool*& memPool,
const char* mempoolName, uint32_t mBufPoolSize);
872 bool configurePort(uint8_t numOfRxQueues, uint8_t numOfTxQueues);
873 bool initQueues(uint8_t numOfRxQueuesToInit, uint8_t numOfTxQueuesToInit);
876 static int dpdkCaptureThreadMain(
void* ptr);
878 void clearCoreConfiguration();
879 bool initCoreConfigurationByCoreMask(CoreMask coreMask);
880 int getCoresInUseCount()
const;
882 void setDeviceInfo();
884 typedef rte_mbuf* (*PacketIterator)(
void* packetStorage,
int index);
885 uint16_t sendPacketsInner(uint16_t txQueueId,
void* packetStorage, PacketIterator iter,
int arrLength,
888 uint64_t convertRssHfToDpdkRssHf(uint64_t rssHF)
const;
889 uint64_t convertDpdkRssHfToRssHf(uint64_t dpdkRssHF)
const;
891 std::string m_DeviceName;
893 std::string m_PMDName;
894 std::string m_PciAddress;
896 DpdkDeviceConfiguration m_Config;
899 MacAddress m_MacAddress;
900 int16_t m_DeviceSocketId;
901 uint16_t m_DeviceMtu;
902 uint16_t m_MBufDataSize;
903 struct rte_mempool* m_MBufMempool;
904 struct rte_eth_dev_tx_buffer** m_TxBuffers;
905 uint64_t m_TxBufferDrainTsc;
906 uint64_t* m_TxBufferLastDrainTsc;
907 DpdkCoreConfiguration m_CoreConfiguration[MAX_NUM_OF_CORES];
908 uint16_t m_TotalAvailableRxQueues;
909 uint16_t m_TotalAvailableTxQueues;
910 uint16_t m_NumOfRxQueuesOpened;
911 uint16_t m_NumOfTxQueuesOpened;
913 void* m_OnPacketsArriveUserCookie;
919 static uint8_t m_RSSKey[40];
921 mutable DpdkDeviceStats m_PrevStats;
Definition: DpdkDevice.h:179
bool setFilter(std::string filterAsString)
bool startCaptureMultiThreads(OnDpdkPacketsArriveCallback onPacketsArrive, void *onPacketsArriveUserCookie, CoreMask coreMask)
uint16_t getTotalNumOfRxQueues() const
Definition: DpdkDevice.h:488
int getAmountOfMbufsInUse() const
uint16_t getMtu() const
Definition: DpdkDevice.h:439
bool sendPacket(RawPacket &rawPacket, uint16_t txQueueId=0, bool useTxBuffer=false)
int getDeviceId() const
Definition: DpdkDevice.h:390
uint16_t receivePackets(Packet **packetsArr, uint16_t packetsArrLength, uint16_t rxQueueId) const
bool open() override
Definition: DpdkDevice.h:843
bool sendPacket(MBufRawPacket &rawPacket, uint16_t txQueueId=0, bool useTxBuffer=false)
std::string getPciAddress() const
Definition: DpdkDevice.h:431
bool sendPacket(Packet &packet, uint16_t txQueueId=0, bool useTxBuffer=false)
uint64_t getConfiguredRssHashFunction() const
void getLinkStatus(LinkStatus &linkStatus) const
MacAddress getMacAddress() const
Definition: DpdkDevice.h:405
int getAmountOfFreeMbufs() const
uint16_t receivePackets(MBufRawPacket **rawPacketsArr, uint16_t rawPacketArrLength, uint16_t rxQueueId) const
uint16_t sendPackets(Packet **packetsArr, uint16_t arrLength, uint16_t txQueueId=0, bool useTxBuffer=false)
bool setFilter(GeneralFilter &filter)
uint16_t sendPackets(MBufRawPacketVector &rawPacketsVec, uint16_t txQueueId=0, bool useTxBuffer=false)
uint64_t getSupportedRssHashFunctions() const
std::string getPMDName() const
Definition: DpdkDevice.h:414
uint16_t sendPackets(RawPacketVector &rawPacketsVec, uint16_t txQueueId=0, bool useTxBuffer=false)
bool isDeviceSupportRssHashFunction(uint64_t rssHFMask) const
bool setMtu(uint16_t newMtu)
uint16_t getNumOfOpenedRxQueues() const
Definition: DpdkDevice.h:472
DpdkRssHashFunction
Definition: DpdkDevice.h:189
@ RSS_NVGRE
Definition: DpdkDevice.h:231
@ RSS_IPV4
Definition: DpdkDevice.h:193
@ RSS_ALL_SUPPORTED
Definition: DpdkDevice.h:233
@ RSS_NONE
Definition: DpdkDevice.h:191
@ RSS_PORT
Definition: DpdkDevice.h:225
@ RSS_IPV6_TCP_EX
Definition: DpdkDevice.h:221
@ RSS_GENEVE
Definition: DpdkDevice.h:229
@ RSS_NONFRAG_IPV4_OTHER
Definition: DpdkDevice.h:203
@ RSS_FRAG_IPV6
Definition: DpdkDevice.h:207
@ RSS_IPV6_EX
Definition: DpdkDevice.h:219
@ RSS_IPV6_UDP_EX
Definition: DpdkDevice.h:223
@ RSS_NONFRAG_IPV6_UDP
Definition: DpdkDevice.h:211
@ RSS_NONFRAG_IPV4_SCTP
Definition: DpdkDevice.h:201
@ RSS_NONFRAG_IPV4_UDP
Definition: DpdkDevice.h:199
@ RSS_NONFRAG_IPV6_OTHER
Definition: DpdkDevice.h:215
@ RSS_NONFRAG_IPV6_TCP
Definition: DpdkDevice.h:209
@ RSS_L2_PAYLOAD
Definition: DpdkDevice.h:217
@ RSS_FRAG_IPV4
Definition: DpdkDevice.h:195
@ RSS_DEFAULT
Definition: DpdkDevice.h:235
@ RSS_IPV6
Definition: DpdkDevice.h:205
@ RSS_NONFRAG_IPV6_SCTP
Definition: DpdkDevice.h:213
@ RSS_NONFRAG_IPV4_TCP
Definition: DpdkDevice.h:197
@ RSS_VXLAN
Definition: DpdkDevice.h:227
uint16_t flushTxBuffer(bool flushOnlyIfTimeoutExpired=false, uint16_t txQueueId=0)
uint16_t getNumOfOpenedTxQueues() const
Definition: DpdkDevice.h:480
uint16_t sendPackets(MBufRawPacket **rawPacketsArr, uint16_t arrLength, uint16_t txQueueId=0, bool useTxBuffer=false)
void getStatistics(DpdkDeviceStats &stats) const
uint16_t getTotalNumOfTxQueues() const
Definition: DpdkDevice.h:496
bool isDeviceSupportRssHashFunction(DpdkRssHashFunction rssHF) const
DpdkPMDType getPMDType() const
Definition: DpdkDevice.h:423
uint16_t receivePackets(MBufRawPacketVector &rawPacketsArr, uint16_t rxQueueId) const
uint32_t getCurrentCoreId() const
bool startCaptureSingleThread(OnDpdkPacketsArriveCallback onPacketsArrive, void *onPacketsArriveUserCookie)
std::vector< std::string > rssHashFunctionMaskToString(uint64_t rssHFMask) const
std::string getDeviceName() const
Definition: DpdkDevice.h:397
bool openMultiQueues(uint16_t numOfRxQueuesToOpen, uint16_t numOfTxQueuesToOpen, const DpdkDeviceConfiguration &config=DpdkDeviceConfiguration())
Definition: DpdkDeviceList.h:76
Definition: PcapFilter.h:160
Definition: MBufRawPacket.h:49
Definition: MacAddress.h:25
Definition: PointerVector.h:29
Definition: RawPacket.h:269
The main namespace for the PcapPlusPlus lib.
DpdkPMDType
Definition: DpdkDevice.h:85
@ PMD_IGB
Definition: DpdkDevice.h:94
@ PMD_MLX4
Definition: DpdkDevice.h:110
@ PMD_RING
Definition: DpdkDevice.h:116
@ PMD_IXGBEVF
Definition: DpdkDevice.h:108
@ PMD_BOND
Definition: DpdkDevice.h:90
@ PMD_AF_PACKET
Definition: DpdkDevice.h:124
@ PMD_I40EVF
Definition: DpdkDevice.h:104
@ PMD_UNKNOWN
Definition: DpdkDevice.h:87
@ PMD_I40E
Definition: DpdkDevice.h:102
@ PMD_E1000EM
Definition: DpdkDevice.h:92
@ PMD_PCAP
Definition: DpdkDevice.h:114
@ PMD_FM10K
Definition: DpdkDevice.h:100
@ PMD_XENVIRT
Definition: DpdkDevice.h:122
@ PMD_IXGBE
Definition: DpdkDevice.h:106
@ PMD_VMXNET3
Definition: DpdkDevice.h:120
@ PMD_ENIC
Definition: DpdkDevice.h:98
@ PMD_IGBVF
Definition: DpdkDevice.h:96
@ PMD_VIRTIO
Definition: DpdkDevice.h:118
@ PMD_NULL
Definition: DpdkDevice.h:112
void(* OnDpdkPacketsArriveCallback)(MBufRawPacket *packets, uint32_t numOfPackets, uint8_t threadId, DpdkDevice *device, void *userCookie)
Definition: DpdkDevice.h:137
Definition: DpdkDevice.h:244
uint16_t flushTxBufferTimeout
Definition: DpdkDevice.h:263
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:304
uint16_t transmitDescriptorsNumber
Definition: DpdkDevice.h:257
uint8_t * rssKey
Definition: DpdkDevice.h:272
uint8_t rssKeyLength
Definition: DpdkDevice.h:278
uint64_t rssHashFunction
Definition: DpdkDevice.h:286
uint16_t receiveDescriptorsNumber
Definition: DpdkDevice.h:250
Definition: DpdkDevice.h:363
uint64_t rxMbufAlocFailed
Definition: DpdkDevice.h:382
uint8_t devId
Definition: DpdkDevice.h:365
RxTxStats aggregatedRxStats
Definition: DpdkDevice.h:373
timespec timestamp
Definition: DpdkDevice.h:367
uint64_t rxPacketsDroppedByHW
Definition: DpdkDevice.h:378
RxTxStats txStats[16]
Definition: DpdkDevice.h:371
RxTxStats aggregatedTxStats
Definition: DpdkDevice.h:375
RxTxStats rxStats[16]
Definition: DpdkDevice.h:369
uint64_t rxErroneousPackets
Definition: DpdkDevice.h:380
Definition: DpdkDevice.h:324
int linkSpeedMbps
Definition: DpdkDevice.h:337
LinkDuplex linkDuplex
Definition: DpdkDevice.h:339
LinkDuplex
Definition: DpdkDevice.h:327
@ FULL_DUPLEX
Definition: DpdkDevice.h:329
@ HALF_DUPLEX
Definition: DpdkDevice.h:331
bool linkUp
Definition: DpdkDevice.h:335
Definition: DpdkDevice.h:347
uint64_t packetsPerSec
Definition: DpdkDevice.h:353
uint64_t bytesPerSec
Definition: DpdkDevice.h:355
uint64_t packets
Definition: DpdkDevice.h:349
uint64_t bytes
Definition: DpdkDevice.h:351