|
PcapPlusPlus
20.08
|
Go to the documentation of this file. 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
281 uint8_t*
rssKey = DpdkDevice::m_RSSKey,
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);
626 bool openMultiQueues(uint16_t numOfRxQueuesToOpen, uint16_t numOfTxQueuesToOpen,
const DpdkDeviceConfiguration& config = DpdkDeviceConfiguration());
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) {}
752 DpdkDevice(
int port, uint32_t mBufPoolSize);
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;
778 DpdkDeviceConfiguration m_Config;
781 MacAddress m_MacAddress;
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];
801 mutable DpdkDeviceStats m_PrevStats;
@ HALF_DUPLEX
Definition: DpdkDevice.h:305
bool linkUp
Definition: DpdkDevice.h:309
Definition: DpdkDevice.h:297
RxTxStats aggregatedRxStats
Definition: DpdkDevice.h:347
uint64_t rxPacketsDropeedByHW
Definition: DpdkDevice.h:351
uint16_t transmitDescriptorsNumber
Definition: DpdkDevice.h:235
int linkSpeedMbps
Definition: DpdkDevice.h:311
bool sendPacket(RawPacket &rawPacket, uint16_t txQueueId=0, bool useTxBuffer=false)
@ PMD_VMXNET3
Definition: DpdkDevice.h:111
Definition: DpdkDevice.h:164
DpdkRssHashFunction
Definition: DpdkDevice.h:174
@ RSS_NONFRAG_IPV4_TCP
Definition: DpdkDevice.h:181
@ PMD_FM10K
Definition: DpdkDevice.h:91
@ PMD_UNKNOWN
Definition: DpdkDevice.h:79
@ RSS_IPV6
Definition: DpdkDevice.h:189
uint16_t getTotalNumOfTxQueues() const
Definition: DpdkDevice.h:437
@ PMD_E1000EM
Definition: DpdkDevice.h:83
uint16_t flushTxBufferTimeout
Definition: DpdkDevice.h:241
bool setFilter(GeneralFilter &filter)
uint16_t flushTxBuffer(bool flushOnlyIfTimeoutExpired=false, uint16_t txQueueId=0)
@ PMD_NULL
Definition: DpdkDevice.h:103
LinkDuplex
Definition: DpdkDevice.h:300
uint16_t receiveDescriptorsNumber
Definition: DpdkDevice.h:229
@ PMD_I40EVF
Definition: DpdkDevice.h:95
Definition: DpdkDeviceList.h:71
bool open()
Definition: DpdkDevice.h:733
@ RSS_NONFRAG_IPV4_SCTP
Definition: DpdkDevice.h:185
@ PMD_RING
Definition: DpdkDevice.h:107
std::string getPciAddress() const
Definition: DpdkDevice.h:389
@ PMD_BOND
Definition: DpdkDevice.h:81
Definition: MacAddress.h:27
@ FULL_DUPLEX
Definition: DpdkDevice.h:303
RxTxStats txStats[16]
Definition: DpdkDevice.h:345
@ PMD_VIRTIO
Definition: DpdkDevice.h:109
uint64_t getSupportedRssHashFunctions() const
@ RSS_GENEVE
Definition: DpdkDevice.h:213
bool startCaptureMultiThreads(OnDpdkPacketsArriveCallback onPacketsArrive, void *onPacketsArriveUserCookie, CoreMask coreMask)
@ PMD_IXGBE
Definition: DpdkDevice.h:97
uint8_t * rssKey
Definition: DpdkDevice.h:249
@ PMD_IXGBEVF
Definition: DpdkDevice.h:99
@ RSS_NONFRAG_IPV4_OTHER
Definition: DpdkDevice.h:187
@ RSS_NONFRAG_IPV6_SCTP
Definition: DpdkDevice.h:197
uint8_t rssKeyLength
Definition: DpdkDevice.h:255
int getAmountOfMbufsInUse() const
uint16_t getTotalNumOfRxQueues() const
Definition: DpdkDevice.h:432
@ RSS_IPV6_UDP_EX
Definition: DpdkDevice.h:207
@ RSS_IPV6_TCP_EX
Definition: DpdkDevice.h:205
bool setMtu(uint16_t newMtu)
bool openMultiQueues(uint16_t numOfRxQueuesToOpen, uint16_t numOfTxQueuesToOpen, const DpdkDeviceConfiguration &config=DpdkDeviceConfiguration())
uint64_t packets
Definition: DpdkDevice.h:323
RxTxStats rxStats[16]
Definition: DpdkDevice.h:343
uint32_t getCurrentCoreId() const
@ RSS_IPV6_EX
Definition: DpdkDevice.h:203
@ PMD_PCAP
Definition: DpdkDevice.h:105
uint64_t rxErroneousPackets
Definition: DpdkDevice.h:353
Definition: DpdkDevice.h:320
@ RSS_NONFRAG_IPV6_OTHER
Definition: DpdkDevice.h:199
uint64_t rssHashFunction
Definition: DpdkDevice.h:262
int getAmountOfFreeMbufs() const
MacAddress getMacAddress() const
Definition: DpdkDevice.h:372
timespec timestamp
Definition: DpdkDevice.h:341
uint64_t bytes
Definition: DpdkDevice.h:325
@ RSS_L2_PAYLOAD
Definition: DpdkDevice.h:201
@ PMD_IGBVF
Definition: DpdkDevice.h:87
Definition: DpdkDevice.h:223
uint8_t devId
Definition: DpdkDevice.h:339
The main namespace for the PcapPlusPlus lib.
@ PMD_MLX4
Definition: DpdkDevice.h:101
uint64_t rxMbufAlocFailed
Definition: DpdkDevice.h:355
@ PMD_IGB
Definition: DpdkDevice.h:85
@ RSS_NONFRAG_IPV6_TCP
Definition: DpdkDevice.h:193
uint16_t getNumOfOpenedRxQueues() const
Definition: DpdkDevice.h:422
int getDeviceId() const
Definition: DpdkDevice.h:363
Definition: DpdkDevice.h:336
@ PMD_AF_PACKET
Definition: DpdkDevice.h:115
LinkDuplex linkDuplex
Definition: DpdkDevice.h:313
uint16_t sendPackets(MBufRawPacket **rawPacketsArr, uint16_t arrLength, uint16_t txQueueId=0, bool useTxBuffer=false)
@ RSS_VXLAN
Definition: DpdkDevice.h:211
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
uint16_t receivePackets(MBufRawPacketVector &rawPacketsArr, uint16_t rxQueueId) const
@ RSS_PORT
Definition: DpdkDevice.h:209
@ RSS_NONFRAG_IPV6_UDP
Definition: DpdkDevice.h:195
std::string getPMDName() const
Definition: DpdkDevice.h:378
@ PMD_I40E
Definition: DpdkDevice.h:93
@ RSS_FRAG_IPV6
Definition: DpdkDevice.h:191
std::string getDeviceName() const
Definition: DpdkDevice.h:367
uint64_t packetsPerSec
Definition: DpdkDevice.h:327
@ RSS_IPV4
Definition: DpdkDevice.h:177
@ RSS_FRAG_IPV4
Definition: DpdkDevice.h:179
uint64_t bytesPerSec
Definition: DpdkDevice.h:329
@ PMD_XENVIRT
Definition: DpdkDevice.h:113
RxTxStats aggregatedTxStats
Definition: DpdkDevice.h:349
void getLinkStatus(LinkStatus &linkStatus) const
uint16_t getMtu() const
Definition: DpdkDevice.h:394
bool isDeviceSupportRssHashFunction(DpdkRssHashFunction rssHF) const
Definition: PointerVector.h:24
@ PMD_ENIC
Definition: DpdkDevice.h:89
uint16_t getNumOfOpenedTxQueues() const
Definition: DpdkDevice.h:427
DpdkPMDType getPMDType() const
Definition: DpdkDevice.h:384
@ RSS_NVGRE
Definition: DpdkDevice.h:215
@ RSS_NONFRAG_IPV4_UDP
Definition: DpdkDevice.h:183
Definition: PcapFilter.h:79
bool startCaptureSingleThread(OnDpdkPacketsArriveCallback onPacketsArrive, void *onPacketsArriveUserCookie)
void getStatistics(DpdkDeviceStats &stats) const
Definition: MBufRawPacket.h:43
Definition: RawPacket.h:252
DpdkPMDType
Definition: DpdkDevice.h:77
void(* OnDpdkPacketsArriveCallback)(MBufRawPacket *packets, uint32_t numOfPackets, uint8_t threadId, DpdkDevice *device, void *userCookie)
Definition: DpdkDevice.h:127