代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/gazelle 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 3ed8f430fb3070404d5b77da99964623877a01dd Mon Sep 17 00:00:00 2001
From: jiangheng <jiangheng14@huawei.com>
Date: Thu, 15 Dec 2022 16:35:46 +0800
Subject: [PATCH] ltran rxtx mbuf pool size config by conf
---
src/ltran/ltran.conf | 3 +++
src/ltran/ltran_ethdev.c | 18 ++++++++----------
src/ltran/ltran_param.c | 32 ++++++++++++++++++++++++++++++++
src/ltran/ltran_param.h | 2 ++
src/ltran/ltran_stat.h | 2 +-
5 files changed, 46 insertions(+), 11 deletions(-)
diff --git a/src/ltran/ltran.conf b/src/ltran/ltran.conf
index 3c1a2bc..4bfcbef 100644
--- a/src/ltran/ltran.conf
+++ b/src/ltran/ltran.conf
@@ -24,3 +24,6 @@ bond_macs="aa:bb:cc:dd:ee:ff"
bond_ports="0x1"
tcp_conn_scan_interval=10
+# number of mbuf for tx and rx. default tx is 30720, default rx is 307200.
+#rx_pool_mbuf_size = 307200
+#tx_pool_mbuf_size = 30720
diff --git a/src/ltran/ltran_ethdev.c b/src/ltran/ltran_ethdev.c
index 45bf2ef..62a662d 100644
--- a/src/ltran/ltran_ethdev.c
+++ b/src/ltran/ltran_ethdev.c
@@ -78,8 +78,8 @@ static int32_t ltran_log_init(void);
static int32_t ltran_eal_init(void);
static int32_t ltran_pdump_init(void);
static int32_t ltran_log_level_init(void);
-static struct rte_mempool *ltran_create_rx_mbuf_pool(uint32_t bond_port_index, uint32_t scale);
-static struct rte_mempool *ltran_create_tx_mbuf_pool(uint32_t bond_port_index, uint32_t scale);
+static struct rte_mempool *ltran_create_rx_mbuf_pool(uint32_t bond_port_index);
+static struct rte_mempool *ltran_create_tx_mbuf_pool(uint32_t bond_port_index);
static int32_t ltran_parse_port(void);
static int32_t ltran_mbuf_pool_init(void);
static int32_t ltran_single_slave_port_init(uint16_t port_num, struct rte_mempool *pktmbuf_rxpool);
@@ -133,9 +133,9 @@ static int32_t ltran_pdump_init(void)
return GAZELLE_OK;
}
-static struct rte_mempool *ltran_create_rx_mbuf_pool(uint32_t bond_port_index, uint32_t scale)
+static struct rte_mempool *ltran_create_rx_mbuf_pool(uint32_t bond_port_index)
{
- uint32_t num_mbufs = GAZELLE_MBUFS_RX_COUNT * scale;
+ uint32_t num_mbufs = get_ltran_config()->rx_mbuf_pool_size;
char mbuf_pool_name[GAZELLE_PKT_MBUF_POOL_NAME_LENGTH] = {0};
@@ -151,9 +151,9 @@ static struct rte_mempool *ltran_create_rx_mbuf_pool(uint32_t bond_port_index, u
RTE_MBUF_DEFAULT_BUF_SIZE, (int32_t)rte_socket_id());
}
-static struct rte_mempool *ltran_create_tx_mbuf_pool(uint32_t bond_port_index, uint32_t scale)
+static struct rte_mempool *ltran_create_tx_mbuf_pool(uint32_t bond_port_index)
{
- const uint32_t num_mbufs = GAZELLE_MBUFS_TX_COUNT * scale;
+ const uint32_t num_mbufs = get_ltran_config()->tx_mbuf_pool_size;
char mbuf_pool_name[GAZELLE_PKT_MBUF_POOL_NAME_LENGTH] = {0};
@@ -174,17 +174,15 @@ static int32_t ltran_mbuf_pool_init(void)
uint32_t bond_num = get_bond_num();
struct rte_mempool** rxpool = get_pktmbuf_rxpool();
struct rte_mempool** txpool = get_pktmbuf_txpool();
- struct ltran_config* ltran_config = get_ltran_config();
- struct port_info* port_info = get_port_info();
for (uint32_t i = 0; i < bond_num; i++) {
- rxpool[i] = ltran_create_rx_mbuf_pool(i, 1);
+ rxpool[i] = ltran_create_rx_mbuf_pool(i);
if (rxpool[i] == NULL) {
LTRAN_ERR("rxpool[%u] is NULL, pktmbuf_pool init failed. rte_errno: %d. \n", i, rte_errno);
return GAZELLE_ERR;
}
- txpool[i] = ltran_create_tx_mbuf_pool(i, port_info[i].num_ports * ltran_config->bond.tx_queue_num);
+ txpool[i] = ltran_create_tx_mbuf_pool(i);
if (txpool[i] == NULL) {
LTRAN_ERR("txpool[%u] is NULL, pktmbuf_pool init failed. rte_errno: %d. \n", i, rte_errno);
return GAZELLE_ERR;
diff --git a/src/ltran/ltran_param.c b/src/ltran/ltran_param.c
index 18854cf..1b9d82b 100644
--- a/src/ltran/ltran_param.c
+++ b/src/ltran/ltran_param.c
@@ -43,6 +43,8 @@
#define PARAM_BOND_MACS "bond_macs"
#define PARAM_TCP_CONN_SCAN_INTERVAL "tcp_conn_scan_interval"
#define PARAM_UNIX_PREFIX "unix_prefix"
+#define PARAM_RX_MBUF_POOL_SIZE "rx_mbuf_pool_size"
+#define PARAM_TX_MBUF_POOL_SIZE "tx_mbuf_pool_size"
static struct ltran_config g_ltran_config = {0};
struct ltran_config* get_ltran_config(void)
@@ -610,6 +612,34 @@ static int32_t parse_unix_prefix(const config_t *config, const char *key, struct
return GAZELLE_OK;
}
+static int32_t parse_rx_mbuf_pool_size(const config_t *config, const char *key, struct ltran_config *ltran_config)
+{
+ int32_t ret;
+ int32_t rx_mbuf_pool_size = 0;
+ ret = config_lookup_int(config, key, &rx_mbuf_pool_size);
+ if (ret == 0) {
+ ltran_config->rx_mbuf_pool_size = GAZELLE_MBUFS_RX_COUNT;
+ return GAZELLE_OK;
+ }
+
+ ltran_config->rx_mbuf_pool_size = rx_mbuf_pool_size;
+ return GAZELLE_OK;
+}
+
+static int32_t parse_tx_mbuf_pool_size(const config_t *config, const char *key, struct ltran_config *ltran_config)
+{
+ int32_t ret;
+ int32_t tx_mbuf_pool_size = 0;
+ ret = config_lookup_int(config, key, &tx_mbuf_pool_size);
+ if (ret == 0) {
+ ltran_config->tx_mbuf_pool_size = GAZELLE_MBUFS_TX_COUNT;
+ return GAZELLE_OK;
+ }
+
+ ltran_config->tx_mbuf_pool_size = tx_mbuf_pool_size;
+ return GAZELLE_OK;
+}
+
struct param_parser g_param_parse_tbl[] = {
{PARAM_FORWARD_KIT_ARGS, parse_forward_kit_args},
{PARAM_DISPATCH_MAX_CLIENT, parse_dispatch_max_client},
@@ -625,6 +655,8 @@ struct param_parser g_param_parse_tbl[] = {
{PARAM_TCP_CONN_SCAN_INTERVAL, parse_tcp_conn_scan_interval},
{PARAM_KNI_SWITCH, parse_kni_switch},
{PARAM_UNIX_PREFIX, parse_unix_prefix},
+ {PARAM_RX_MBUF_POOL_SIZE, parse_rx_mbuf_pool_size},
+ {PARAM_TX_MBUF_POOL_SIZE, parse_tx_mbuf_pool_size},
};
int32_t parse_config_file_args(const char *conf_file_path, struct ltran_config *ltran_config)
diff --git a/src/ltran/ltran_param.h b/src/ltran/ltran_param.h
index 6f013d5..40a92b1 100644
--- a/src/ltran/ltran_param.h
+++ b/src/ltran/ltran_param.h
@@ -58,6 +58,8 @@ struct ltran_config {
} log;
char unix_socket_filename[NAME_MAX];
char dfx_socket_filename[NAME_MAX];
+ uint32_t rx_mbuf_pool_size;
+ uint32_t tx_mbuf_pool_size;
};
int32_t parse_config_file_args(const char *conf_file_path, struct ltran_config *ltran_config);
diff --git a/src/ltran/ltran_stat.h b/src/ltran/ltran_stat.h
index f91b0c4..16d03a1 100644
--- a/src/ltran/ltran_stat.h
+++ b/src/ltran/ltran_stat.h
@@ -23,7 +23,7 @@
* When doing reads from the NIC or the client queues,
* use this batch size
*/
-#define BACKUP_SIZE_FACTOR (256)
+#define BACKUP_SIZE_FACTOR (1024)
#define RING_MAX_SIZE (512) /* determined by g_mbuf_ring.rx_ring in func create_shared_ring in file dpdk.c */
#define PACKET_READ_SIZE (32)
#define BACKUP_MBUF_SIZE (BACKUP_SIZE_FACTOR * PACKET_READ_SIZE)
--
2.33.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。