Skip to content

Commit e48be80

Browse files
authored
DpdkDevice - allow RX queue num which is not power of 2 for non-virtual devices seladb#1340 - (seladb#1343)
1 parent 5d217ff commit e48be80

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

Pcap++/src/DpdkDevice.cpp

+14-4
Original file line numberDiff line numberDiff line change
@@ -289,14 +289,24 @@ bool DpdkDevice::configurePort(uint8_t numOfRxQueues, uint8_t numOfTxQueues)
289289
return false;
290290
}
291291

292-
// verify num of RX queues is power of 2
293-
bool isRxQueuePowerOfTwo = !(numOfRxQueues == 0) && !(numOfRxQueues & (numOfRxQueues - 1));
294-
if (!isRxQueuePowerOfTwo)
292+
// verify num of RX queues is nonzero
293+
if (numOfRxQueues == 0)
295294
{
296-
PCPP_LOG_ERROR("Num of RX queues must be power of 2 (because of DPDK limitation). Attempted to open device with " << numOfRxQueues << " RX queues");
295+
PCPP_LOG_ERROR("Num of RX queues must be nonzero.");
297296
return false;
298297
}
299298

299+
// verify num of RX queues is power of 2 for virtual devices
300+
if (isVirtual())
301+
{
302+
bool isRxQueuePowerOfTwo = !(numOfRxQueues & (numOfRxQueues - 1));
303+
if (!isRxQueuePowerOfTwo)
304+
{
305+
PCPP_LOG_ERROR("Num of RX queues must be power of 2 when device is virtual (because of DPDK limitation). Attempted to open device with " << numOfRxQueues << " RX queues");
306+
return false;
307+
}
308+
}
309+
300310
struct rte_eth_conf portConf;
301311
memset(&portConf,0,sizeof(rte_eth_conf));
302312
#if (RTE_VER_YEAR < 22) || (RTE_VER_YEAR == 22 && RTE_VER_MONTH < 11)

0 commit comments

Comments
 (0)