1 Star 0 Fork 32

fantaotao1/gazelle

forked from src-openEuler/gazelle 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0252-add-use_sockmap-in-cfg-to-distinguish-whether-to-use.patch 4.18 KB
一键复制 编辑 原始数据 按行查看 历史
From f0f6c7eb303b772d27e0720662485eb36e9c7d34 Mon Sep 17 00:00:00 2001
From: jiangheng <jiangheng14@huawei.com>
Date: Fri, 16 Jun 2023 10:00:33 +0800
Subject: [PATCH] add use_sockmap in cfg to distinguish whether to use dpdk
ring communication between processes
---
src/lstack/core/lstack_cfg.c | 8 ++++++++
src/lstack/core/lstack_lwip.c | 5 +++++
src/lstack/core/lstack_protocol_stack.c | 10 +++++++---
src/lstack/include/lstack_cfg.h | 1 +
src/lstack/netif/lstack_ethdev.c | 1 -
5 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/src/lstack/core/lstack_cfg.c b/src/lstack/core/lstack_cfg.c
index a21992e..daf49ea 100644
--- a/src/lstack/core/lstack_cfg.c
+++ b/src/lstack/core/lstack_cfg.c
@@ -71,6 +71,7 @@ static int32_t parse_seperate_sendrecv_args(void);
static int32_t parse_tuple_filter(void);
static int32_t parse_use_bond4(void);
static int32_t parse_bond4_slave_mac(void);
+static int32_t parse_use_sockmap(void);
#define PARSE_ARG(_arg, _arg_string, _default_val, _min_val, _max_val, _ret) \
do { \
@@ -125,6 +126,7 @@ static struct config_vector_t g_config_tbl[] = {
{ "tuple_filter", parse_tuple_filter },
{ "use_bond4", parse_use_bond4 },
{ "bond4_slave_mac", parse_bond4_slave_mac },
+ { "use_sockmap", parse_use_sockmap },
{ NULL, NULL }
};
@@ -1106,3 +1108,9 @@ static int32_t parse_bond4_slave_mac(void)
return ret;
}
+static int32_t parse_use_sockmap(void)
+{
+ int32_t ret;
+ PARSE_ARG(g_config_params.use_sockmap, "use_sockmap", 0, 0, 1, ret);
+ return ret;
+}
diff --git a/src/lstack/core/lstack_lwip.c b/src/lstack/core/lstack_lwip.c
index 34b4aa7..d53591d 100644
--- a/src/lstack/core/lstack_lwip.c
+++ b/src/lstack/core/lstack_lwip.c
@@ -1545,6 +1545,11 @@ err_t same_node_memzone_create(const struct rte_memzone **zone, int size, int po
err_t same_node_ring_create(struct rte_ring **ring, int size, int port, char *name, char *rx)
{
+ if (!get_global_cfg_params()->use_sockmap) {
+ *ring = NULL;
+ return -1;
+ }
+
unsigned flags;
char ring_name[RING_NAME_LEN] = {0};
if (strcmp(name, "listen") == 0) {
diff --git a/src/lstack/core/lstack_protocol_stack.c b/src/lstack/core/lstack_protocol_stack.c
index a8c5e14..e13f039 100644
--- a/src/lstack/core/lstack_protocol_stack.c
+++ b/src/lstack/core/lstack_protocol_stack.c
@@ -443,6 +443,7 @@ static void* gazelle_stack_thread(void *arg)
struct cfg_params *cfg = get_global_cfg_params();
uint8_t use_ltran_flag = cfg->use_ltran;
bool kni_switch = cfg->kni_switch;
+ bool use_sockmap = cfg->use_sockmap;
uint32_t read_connect_number = cfg->read_connect_number;
uint32_t rpc_number = cfg->rpc_number;
uint32_t nic_read_number = cfg->nic_read_number;
@@ -471,9 +472,12 @@ static void* gazelle_stack_thread(void *arg)
gazelle_eth_dev_poll(stack, use_ltran_flag, nic_read_number);
- /* reduce traversal times */
- if ((wakeup_tick & 0xff) == 0) {
- read_same_node_recv_list(stack);
+ if (use_sockmap) {
+ netif_poll(&stack->netif);
+ /* reduce traversal times */
+ if ((wakeup_tick & 0xff) == 0) {
+ read_same_node_recv_list(stack);
+ }
}
read_recv_list(stack, read_connect_number);
diff --git a/src/lstack/include/lstack_cfg.h b/src/lstack/include/lstack_cfg.h
index 4d0f611..b000519 100644
--- a/src/lstack/include/lstack_cfg.h
+++ b/src/lstack/include/lstack_cfg.h
@@ -106,6 +106,7 @@ struct cfg_params {
bool use_bond4;
uint8_t bond4_slave1_mac_addr[ETHER_ADDR_LEN];
uint8_t bond4_slave2_mac_addr[ETHER_ADDR_LEN];
+ bool use_sockmap;
};
struct cfg_params *get_global_cfg_params(void);
diff --git a/src/lstack/netif/lstack_ethdev.c b/src/lstack/netif/lstack_ethdev.c
index 2052240..3ea8e52 100644
--- a/src/lstack/netif/lstack_ethdev.c
+++ b/src/lstack/netif/lstack_ethdev.c
@@ -761,7 +761,6 @@ int32_t gazelle_eth_dev_poll(struct protocol_stack *stack, uint8_t use_ltran_fla
{
uint32_t nr_pkts;
- netif_poll(&stack->netif);
nr_pkts = stack->dev_ops.rx_poll(stack, stack->pkts, nic_read_number);
if (nr_pkts == 0) {
return 0;
--
2.27.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/fantaotao1/gazelle.git
git@gitee.com:fantaotao1/gazelle.git
fantaotao1
gazelle
gazelle
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385