From cb8d274804ccc9d9c5bb434d1c2e60aaf14e8fd5 Mon Sep 17 00:00:00 2001
From: jiangheng <jiangheng14@huawei.com>
Date: Wed, 8 Nov 2023 20:53:22 +0800
Subject: [PATCH] cfg: nic queue size only support power of 2

---
 src/lstack/core/lstack_cfg.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/lstack/core/lstack_cfg.c b/src/lstack/core/lstack_cfg.c
index 8e83c0d..d2d0fc1 100644
--- a/src/lstack/core/lstack_cfg.c
+++ b/src/lstack/core/lstack_cfg.c
@@ -1191,6 +1191,10 @@ static int32_t parse_nic_rxqueue_size(void)
     int32_t ret;
     PARSE_ARG(g_config_params.nic.rxqueue_size, "nic_rxqueue_size", 4096,
               NIC_QUEUE_SIZE_MIN, NIC_QUEUE_SIZE_MAX, ret);
+    if (!rte_is_power_of_2(g_config_params.nic.rxqueue_size)) {
+        LSTACK_LOG(ERR, LSTACK, "nic queue size only support power of two\n");
+        return -1;
+    }
     return ret;
 }
 
@@ -1199,6 +1203,10 @@ static int32_t parse_nic_txqueue_size(void)
     int32_t ret;
     PARSE_ARG(g_config_params.nic.txqueue_size, "nic_txqueue_size", 2048,
               NIC_QUEUE_SIZE_MIN, NIC_QUEUE_SIZE_MAX, ret);
+    if (!rte_is_power_of_2(g_config_params.nic.txqueue_size)) {
+        LSTACK_LOG(ERR, LSTACK, "nic queue size only support power of two\n");
+        return -1;
+    }
     return ret;
 }
 
-- 
2.23.0

