Skip to content

Commit dd3cd88

Browse files
committed
dpdk - configure MTU size in dpdkDevice
1 parent 1a55ab3 commit dd3cd88

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

input/dpdk.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,13 @@ void DpdkCore::configure(const char* params)
155155
uint16_t mempoolSize = parser.pkt_mempool_size();
156156
uint16_t rxQueueCount = parser.rx_queues();
157157
m_mBufsCount = parser.pkt_buffer_size();
158+
uint16_t mtuSize = parser.mtu_size();
158159

159160
configureEal(parser.eal_params());
160161

161162
m_dpdkDevices.reserve(parser.port_numbers().size());
162163
for (auto portID : parser.port_numbers()) {
163-
m_dpdkDevices.emplace_back(portID, rxQueueCount, mempoolSize, m_mBufsCount);
164+
m_dpdkDevices.emplace_back(portID, rxQueueCount, mempoolSize, m_mBufsCount, mtuSize);
164165
}
165166

166167
isConfigured = true;

input/dpdk/dpdkDevice.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,16 @@ DpdkDevice::DpdkDevice(
3939
uint16_t portID,
4040
uint16_t rxQueueCount,
4141
uint16_t memPoolSize,
42-
uint16_t mbufsCount)
42+
uint16_t mbufsCount,
43+
uint16_t mtuSize)
4344
: m_portID(portID)
4445
, m_rxQueueCount(rxQueueCount)
4546
, m_txQueueCount(0)
4647
, m_mBufsCount(mbufsCount)
4748
, m_isNfbDpdkDriver(false)
4849
, m_supportedRSS(false)
4950
, m_supportedHWTimestamp(false)
51+
, m_mtuSize(mtuSize)
5052
{
5153
validatePort();
5254
recognizeDriver();
@@ -137,9 +139,9 @@ rte_eth_conf DpdkDevice::createPortConfig()
137139
}
138140

139141
#if RTE_VERSION >= RTE_VERSION_NUM(21, 11, 0, 0)
140-
rte_eth_conf portConfig {.rxmode = {.mtu = RTE_ETHER_MAX_LEN}};
142+
rte_eth_conf portConfig {.rxmode = {.mtu = m_mtuSize}};
141143
#else
142-
rte_eth_conf portConfig {.rxmode = {.max_rx_pkt_len = RTE_ETHER_MAX_LEN}};
144+
rte_eth_conf portConfig {.rxmode = {.max_rx_pkt_len = m_mtuSize}};
143145
#endif
144146

145147
if (m_supportedRSS) {
@@ -172,7 +174,7 @@ void DpdkDevice::initMemPools(uint16_t memPoolSize)
172174
memPoolSize,
173175
MEMPOOL_CACHE_SIZE,
174176
0,
175-
RTE_MBUF_DEFAULT_BUF_SIZE,
177+
std::max(m_mtuSize, (uint16_t)RTE_MBUF_DEFAULT_DATAROOM) + RTE_PKTMBUF_HEADROOM,
176178
rte_eth_dev_socket_id(m_portID));
177179
if (!memPool) {
178180
throw PluginError(

input/dpdk/dpdkDevice.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ class DpdkDevice {
4545
* @param rxQueueCount The number of receive queues to be configured.
4646
* @param memPoolSize The size of the memory pool for packet buffers.
4747
* @param mbufsCount The number of mbufs (packet buffers) to be allocated.
48+
* @param mtuSize Maximum transmission unit of input interface.
4849
*/
49-
DpdkDevice(uint16_t portID, uint16_t rxQueueCount, uint16_t memPoolSize, uint16_t mbufsCount);
50+
DpdkDevice(uint16_t portID, uint16_t rxQueueCount, uint16_t memPoolSize, uint16_t mbufsCount, uint16_t mtuSize);
5051

5152
/**
5253
* @brief Receives packets from the specified receive queue of the DPDK device.
@@ -92,6 +93,7 @@ class DpdkDevice {
9293
bool m_supportedHWTimestamp;
9394
int m_rxTimestampOffset;
9495
int m_rxTimestampDynflag;
96+
uint16_t m_mtuSize;
9597

9698
};
9799

0 commit comments

Comments
 (0)