|
PcapPlusPlus
19.12
|
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;
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)
Definition: DpdkDevice.h:111
Definition: DpdkDevice.h:164
DpdkRssHashFunction
Definition: DpdkDevice.h:174
Definition: DpdkDevice.h:181
Definition: DpdkDevice.h:91
Definition: DpdkDevice.h:79
Definition: DpdkDevice.h:189
uint16_t getTotalNumOfTxQueues() const
Definition: DpdkDevice.h:437
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)
Definition: DpdkDevice.h:103
LinkDuplex
Definition: DpdkDevice.h:300
uint16_t receiveDescriptorsNumber
Definition: DpdkDevice.h:229
Definition: DpdkDevice.h:95
Definition: DpdkDeviceList.h:71
bool open()
Definition: DpdkDevice.h:733
Definition: DpdkDevice.h:185
Definition: DpdkDevice.h:107
std::string getPciAddress() const
Definition: DpdkDevice.h:389
Definition: DpdkDevice.h:81
Definition: MacAddress.h:27
Definition: DpdkDevice.h:303
RxTxStats txStats[16]
Definition: DpdkDevice.h:345
Definition: DpdkDevice.h:109
uint64_t getSupportedRssHashFunctions() const
Definition: DpdkDevice.h:213
bool startCaptureMultiThreads(OnDpdkPacketsArriveCallback onPacketsArrive, void *onPacketsArriveUserCookie, CoreMask coreMask)
Definition: DpdkDevice.h:97
uint8_t * rssKey
Definition: DpdkDevice.h:249
Definition: DpdkDevice.h:99
Definition: DpdkDevice.h:187
Definition: DpdkDevice.h:197
uint8_t rssKeyLength
Definition: DpdkDevice.h:255
int getAmountOfMbufsInUse() const
uint16_t getTotalNumOfRxQueues() const
Definition: DpdkDevice.h:432
Definition: DpdkDevice.h:207
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
Definition: DpdkDevice.h:203
Definition: DpdkDevice.h:105
uint64_t rxErroneousPackets
Definition: DpdkDevice.h:353
Definition: DpdkDevice.h:320
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
Definition: DpdkDevice.h:201
Definition: DpdkDevice.h:87
Definition: DpdkDevice.h:223
uint8_t devId
Definition: DpdkDevice.h:339
The main namespace for the PcapPlusPlus lib.
Definition: DpdkDevice.h:101
uint64_t rxMbufAlocFailed
Definition: DpdkDevice.h:355
Definition: DpdkDevice.h:85
Definition: DpdkDevice.h:193
uint16_t getNumOfOpenedRxQueues() const
Definition: DpdkDevice.h:422
int getDeviceId() const
Definition: DpdkDevice.h:363
Definition: DpdkDevice.h:336
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)
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
Definition: DpdkDevice.h:209
Definition: DpdkDevice.h:195
std::string getPMDName() const
Definition: DpdkDevice.h:378
Definition: DpdkDevice.h:93
Definition: DpdkDevice.h:191
std::string getDeviceName() const
Definition: DpdkDevice.h:367
uint64_t packetsPerSec
Definition: DpdkDevice.h:327
Definition: DpdkDevice.h:177
Definition: DpdkDevice.h:179
uint64_t bytesPerSec
Definition: DpdkDevice.h:329
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
Definition: DpdkDevice.h:89
uint16_t getNumOfOpenedTxQueues() const
Definition: DpdkDevice.h:427
DpdkPMDType getPMDType() const
Definition: DpdkDevice.h:384
Definition: DpdkDevice.h:215
Definition: DpdkDevice.h:183
Definition: PcapFilter.h:78
bool startCaptureSingleThread(OnDpdkPacketsArriveCallback onPacketsArrive, void *onPacketsArriveUserCookie)
void getStatistics(DpdkDeviceStats &stats) const
Definition: MBufRawPacket.h:43
Definition: RawPacket.h:219
DpdkPMDType
Definition: DpdkDevice.h:77
void(* OnDpdkPacketsArriveCallback)(MBufRawPacket *packets, uint32_t numOfPackets, uint8_t threadId, DpdkDevice *device, void *userCookie)
Definition: DpdkDevice.h:127