Skip to content

Commit 8004dd2

Browse files
committed
dpdk: fix RSS configuration
Previously, RSS was set to RTE_ETH_RSS_IP, which is not supported by all NICs. This update allows configuring RSS to a subset of RTE_ETH_RSS_IP, ensuring better compatibility.
1 parent 10fea0b commit 8004dd2

File tree

2 files changed

+35
-14
lines changed

2 files changed

+35
-14
lines changed

input/dpdk/dpdkDevice.cpp

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,11 @@ void DpdkDevice::recognizeDriver()
9393
std::cerr << "\tflow type RSS offloads: " << rteDevInfo.flow_type_rss_offloads << std::endl;
9494

9595
/* Check if RSS hashing is supported in NIC */
96+
#if RTE_VERSION >= RTE_VERSION_NUM(21, 11, 0, 0)
9697
m_supportedRSS = (rteDevInfo.flow_type_rss_offloads & RTE_ETH_RSS_IP) != 0;
98+
#else
99+
m_supportedRSS = (rteDevInfo.flow_type_rss_offloads & ETH_RSS_IP) != 0;
100+
#endif
97101
std::cerr << "\tDetected RSS offload capability: " << (m_supportedRSS ? "yes" : "no")
98102
<< std::endl;
99103

@@ -219,25 +223,41 @@ void DpdkDevice::configureRSS()
219223
return;
220224
}
221225

222-
constexpr size_t RSS_KEY_LEN = 40;
223-
// biflow hash key
224-
static uint8_t rssKey[RSS_KEY_LEN]
225-
= {0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A,
226-
0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A,
227-
0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A};
226+
rte_eth_dev_info rteDevInfo;
227+
if (rte_eth_dev_info_get(m_portID, &rteDevInfo)) {
228+
throw PluginError("DpdkDevice::configureRSS() has failed. Unable to get rte dev info");
229+
}
230+
231+
const uint8_t rssHashKeySize = rteDevInfo.hash_key_size;
232+
233+
m_hashKey.resize(rssHashKeySize);
234+
std::generate(
235+
m_hashKey.begin(),
236+
m_hashKey.end(),
237+
[idx = static_cast<std::size_t>(0)]() mutable {
238+
static const std::array<uint8_t, 2> hashKey = {0x6D, 0x5A};
239+
return hashKey[idx++ % sizeof(hashKey)];
240+
});
228241

229-
struct rte_eth_rss_conf rssConfig
230-
= {.rss_key = rssKey,
231-
.rss_key_len = RSS_KEY_LEN,
232242
#if RTE_VERSION >= RTE_VERSION_NUM(21, 11, 0, 0)
233-
.rss_hf = RTE_ETH_RSS_IP,
243+
const uint64_t rssOffloads = rteDevInfo.flow_type_rss_offloads & RTE_ETH_RSS_IP;
244+
if (rssOffloads != RTE_ETH_RSS_IP) {
245+
std::cerr << "RTE_ETH_RSS_IP is not supported by the card. Used subset: " << rssOffloads << std::endl;
246+
}
234247
#else
235-
.rss_hf = ETH_RSS_IP,
248+
const uint64_t rssOffloads = rteDevInfo.flow_type_rss_offloads & ETH_RSS_IP;
249+
if (rssOffloads != ETH_RSS_IP) {
250+
std::cerr << "ETH_RSS_IP is not supported by the card. Used subset: " << rssOffloads << std::endl;
251+
}
236252
#endif
237-
};
253+
254+
struct rte_eth_rss_conf rssConfig = {};
255+
rssConfig.rss_key = m_hashKey.data();
256+
rssConfig.rss_key_len = rssHashKeySize;
257+
rssConfig.rss_hf = rssOffloads;
238258

239259
if (rte_eth_dev_rss_hash_update(m_portID, &rssConfig)) {
240-
std::cerr << "Setting RSS hash for port " << m_portID << "." << std::endl;
260+
std::cerr << "Setting RSS {" << rssOffloads << "} for port " << m_portID << "." << std::endl;
241261
}
242262
}
243263

input/dpdk/dpdkDevice.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ class DpdkDevice {
8484
void registerRxTimestamp();
8585

8686
std::vector<rte_mempool*> m_memPools;
87-
uint16_t m_portID;
87+
std::vector<uint8_t> m_hashKey;
88+
uint16_t m_portID;
8889
uint16_t m_rxQueueCount;
8990
uint16_t m_txQueueCount;
9091
uint16_t m_mBufsCount;

0 commit comments

Comments
 (0)