Skip to content

Commit

Permalink
dpdk: fix RSS configuration
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
SiskaPavel committed Dec 27, 2024
1 parent 10fea0b commit 8004dd2
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 14 deletions.
46 changes: 33 additions & 13 deletions input/dpdk/dpdkDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ void DpdkDevice::recognizeDriver()
std::cerr << "\tflow type RSS offloads: " << rteDevInfo.flow_type_rss_offloads << std::endl;

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

Expand Down Expand Up @@ -219,25 +223,41 @@ void DpdkDevice::configureRSS()
return;
}

constexpr size_t RSS_KEY_LEN = 40;
// biflow hash key
static uint8_t rssKey[RSS_KEY_LEN]
= {0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A,
0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A,
0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A, 0x6D, 0x5A};
rte_eth_dev_info rteDevInfo;
if (rte_eth_dev_info_get(m_portID, &rteDevInfo)) {
throw PluginError("DpdkDevice::configureRSS() has failed. Unable to get rte dev info");
}

const uint8_t rssHashKeySize = rteDevInfo.hash_key_size;

m_hashKey.resize(rssHashKeySize);
std::generate(
m_hashKey.begin(),
m_hashKey.end(),
[idx = static_cast<std::size_t>(0)]() mutable {
static const std::array<uint8_t, 2> hashKey = {0x6D, 0x5A};
return hashKey[idx++ % sizeof(hashKey)];
});

struct rte_eth_rss_conf rssConfig
= {.rss_key = rssKey,
.rss_key_len = RSS_KEY_LEN,
#if RTE_VERSION >= RTE_VERSION_NUM(21, 11, 0, 0)
.rss_hf = RTE_ETH_RSS_IP,
const uint64_t rssOffloads = rteDevInfo.flow_type_rss_offloads & RTE_ETH_RSS_IP;
if (rssOffloads != RTE_ETH_RSS_IP) {
std::cerr << "RTE_ETH_RSS_IP is not supported by the card. Used subset: " << rssOffloads << std::endl;
}
#else
.rss_hf = ETH_RSS_IP,
const uint64_t rssOffloads = rteDevInfo.flow_type_rss_offloads & ETH_RSS_IP;
if (rssOffloads != ETH_RSS_IP) {
std::cerr << "ETH_RSS_IP is not supported by the card. Used subset: " << rssOffloads << std::endl;
}
#endif
};

struct rte_eth_rss_conf rssConfig = {};
rssConfig.rss_key = m_hashKey.data();
rssConfig.rss_key_len = rssHashKeySize;
rssConfig.rss_hf = rssOffloads;

if (rte_eth_dev_rss_hash_update(m_portID, &rssConfig)) {
std::cerr << "Setting RSS hash for port " << m_portID << "." << std::endl;
std::cerr << "Setting RSS {" << rssOffloads << "} for port " << m_portID << "." << std::endl;
}
}

Expand Down
3 changes: 2 additions & 1 deletion input/dpdk/dpdkDevice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ class DpdkDevice {
void registerRxTimestamp();

std::vector<rte_mempool*> m_memPools;
uint16_t m_portID;
std::vector<uint8_t> m_hashKey;
uint16_t m_portID;
uint16_t m_rxQueueCount;
uint16_t m_txQueueCount;
uint16_t m_mBufsCount;
Expand Down

0 comments on commit 8004dd2

Please sign in to comment.