代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/gazelle 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 9437f113443158cb3bd8aa31c69e40de5ff6c3dc Mon Sep 17 00:00:00 2001
From: jiangheng <jiangheng14@huawei.com>
Date: Mon, 5 Sep 2022 01:33:52 +0800
Subject: [PATCH] add tuple filter in conf to diff rss rule and tuple filter
rule
---
src/lstack/api/lstack_wrap.c | 2 +-
src/lstack/core/lstack_cfg.c | 13 +++++
src/lstack/core/lstack_dpdk.c | 70 ++++++++++++-------------
src/lstack/core/lstack_protocol_stack.c | 8 ++-
src/lstack/include/lstack_cfg.h | 1 +
src/lstack/include/lstack_ethdev.h | 1 -
src/lstack/include/lstack_vdev.h | 1 -
src/lstack/lstack.conf | 10 +++-
src/lstack/netif/lstack_ethdev.c | 6 +--
src/lstack/netif/lstack_vdev.c | 5 +-
10 files changed, 68 insertions(+), 49 deletions(-)
diff --git a/src/lstack/api/lstack_wrap.c b/src/lstack/api/lstack_wrap.c
index ecde391..1fba81c 100644
--- a/src/lstack/api/lstack_wrap.c
+++ b/src/lstack/api/lstack_wrap.c
@@ -303,7 +303,7 @@ static inline int32_t do_listen(int32_t s, int32_t backlog)
}
int32_t ret;
- if (use_ltran() && get_global_cfg_params()->listen_shadow == 0) {
+ if (get_global_cfg_params()->listen_shadow == 0) {
ret = stack_single_listen(s, backlog);
} else {
ret = stack_broadcast_listen(s, backlog);
diff --git a/src/lstack/core/lstack_cfg.c b/src/lstack/core/lstack_cfg.c
index 72a3292..88f69e1 100644
--- a/src/lstack/core/lstack_cfg.c
+++ b/src/lstack/core/lstack_cfg.c
@@ -69,6 +69,7 @@ static int32_t parse_num_process(void);
static int32_t parse_process_numa(void);
static int32_t parse_process_index(void);
static int32_t parse_seperate_sendrecv_args(void);
+static int32_t parse_tuple_filter(void);
static inline int32_t parse_int(void *arg, char * arg_string, int32_t default_val,
int32_t min_val, int32_t max_val)
@@ -120,6 +121,7 @@ static struct config_vector_t g_config_tbl[] = {
{ "num_process", parse_num_process },
{ "process_numa", parse_process_numa },
{ "process_idx", parse_process_index },
+ { "tuple_filter", parse_tuple_filter },
{ NULL, NULL }
};
@@ -1030,3 +1032,14 @@ static int parse_process_index(void)
return 0;
}
+static int parse_tuple_filter(void)
+{
+ parse_int(&g_config_params.tuple_filter, "tuple_filter", 0, 0, 1);
+ if (g_config_params.tuple_filter == 0) {
+ return 0;
+ }
+ if (g_config_params.use_ltran || g_config_params.listen_shadow) {
+ return -EINVAL;
+ }
+ return 0;
+}
diff --git a/src/lstack/core/lstack_dpdk.c b/src/lstack/core/lstack_dpdk.c
index 2463d3e..2ecfd1d 100644
--- a/src/lstack/core/lstack_dpdk.c
+++ b/src/lstack/core/lstack_dpdk.c
@@ -445,44 +445,44 @@ int32_t dpdk_ethdev_init(void)
nb_queues = get_global_cfg_params()->tot_queue_num;
}
- struct protocol_stack_group *stack_group = get_protocol_stack_group();
+ struct protocol_stack_group *stack_group = get_protocol_stack_group();
- int32_t port_id = ethdev_port_id(get_global_cfg_params()->mac_addr);
- if (port_id < 0) {
- return port_id;
- }
- get_global_cfg_params()->port_id = port_id;
+ int32_t port_id = ethdev_port_id(get_global_cfg_params()->mac_addr);
+ if (port_id < 0) {
+ return port_id;
+ }
+ get_global_cfg_params()->port_id = port_id;
- struct rte_eth_dev_info dev_info;
- int32_t ret = rte_eth_dev_info_get(port_id, &dev_info);
- if (ret != 0) {
- LSTACK_LOG(ERR, LSTACK, "get dev info ret=%d\n", ret);
- return ret;
- }
+ struct rte_eth_dev_info dev_info;
+ int32_t ret = rte_eth_dev_info_get(port_id, &dev_info);
+ if (ret != 0) {
+ LSTACK_LOG(ERR, LSTACK, "get dev info ret=%d\n", ret);
+ return ret;
+ }
- int32_t max_queues = LWIP_MIN(dev_info.max_rx_queues, dev_info.max_tx_queues);
- if (max_queues < nb_queues) {
- LSTACK_LOG(ERR, LSTACK, "port_id %d max_queues=%d\n", port_id, max_queues);
- return -EINVAL;
- }
+ int32_t max_queues = LWIP_MIN(dev_info.max_rx_queues, dev_info.max_tx_queues);
+ if (max_queues < nb_queues) {
+ LSTACK_LOG(ERR, LSTACK, "port_id %d max_queues=%d\n", port_id, max_queues);
+ return -EINVAL;
+ }
+
+ struct eth_params *eth_params = alloc_eth_params(port_id, nb_queues);
+ if (eth_params == NULL) {
+ return -ENOMEM;
+ }
+ eth_params_checksum(ð_params->conf, &dev_info);
+ int32_t rss_enable = 0;
+ if (!get_global_cfg_params()->tuple_filter) {
+ rss_enable = eth_params_rss(ð_params->conf, &dev_info);
+ }
+ stack_group->eth_params = eth_params;
+ stack_group->port_id = eth_params->port_id;
+ stack_group->rx_offload = eth_params->conf.rxmode.offloads;
+ stack_group->tx_offload = eth_params->conf.txmode.offloads;
+ /* used for tcp port alloc */
+ stack_group->reta_mask = dev_info.reta_size - 1;
+ stack_group->nb_queues = nb_queues;
- struct eth_params *eth_params = alloc_eth_params(port_id, nb_queues);
- if (eth_params == NULL) {
- return -ENOMEM;
- }
- eth_params_checksum(ð_params->conf, &dev_info);
- int32_t rss_enable = 0;
- if (use_ltran()) {
- rss_enable = eth_params_rss(ð_params->conf, &dev_info);
- }
- stack_group->eth_params = eth_params;
- stack_group->port_id = eth_params->port_id;
- stack_group->rx_offload = eth_params->conf.rxmode.offloads;
- stack_group->tx_offload = eth_params->conf.txmode.offloads;
- /* used for tcp port alloc */
- stack_group->reta_mask = dev_info.reta_size - 1;
- stack_group->nb_queues = nb_queues;
-
if (get_global_cfg_params()->is_primary) {
for (uint32_t i = 0; i < stack_group->stack_num; i++) {
struct protocol_stack *stack = stack_group->stacks[i];
@@ -512,7 +512,7 @@ int32_t dpdk_ethdev_init(void)
return ret;
}
- if (rss_enable && use_ltran()) {
+ if (rss_enable && !get_global_cfg_params()->tuple_filter) {
rss_setup(port_id, nb_queues);
stack_group->reta_mask = dev_info.reta_size - 1;
}
diff --git a/src/lstack/core/lstack_protocol_stack.c b/src/lstack/core/lstack_protocol_stack.c
index 5811b26..4be981a 100644
--- a/src/lstack/core/lstack_protocol_stack.c
+++ b/src/lstack/core/lstack_protocol_stack.c
@@ -132,10 +132,10 @@ struct protocol_stack *get_bind_protocol_stack(void)
int min_conn_num = GAZELLE_MAX_CLIENTS;
/* close listen shadow, per app communication thread select only one stack */
- if (use_ltran() && get_global_cfg_params()->listen_shadow == 0) {
+ if (get_global_cfg_params()->listen_shadow == 0) {
static _Atomic uint16_t stack_index = 0;
- index = atomic_fetch_add(&stack_index, 1);
- if (index >= stack_group->stack_num) {
+ index = atomic_fetch_add(&stack_index, 1);
+ if (index >= stack_group->stack_num) {
LSTACK_LOG(ERR, LSTACK, "thread =%hu larger than stack num = %hu\n", index, stack_group->stack_num);
return NULL;
}
@@ -645,8 +645,6 @@ int32_t init_protocol_stack(void)
struct sys_thread *thread = sys_thread_new(name, libnet_listen_thread, (void*)(&stack_group->sem_listen_thread), 0, 0);
free(thread);
sem_wait(&stack_group->sem_listen_thread);
-
- create_flow_rule_map();
}
if (get_init_fail()) {
diff --git a/src/lstack/include/lstack_cfg.h b/src/lstack/include/lstack_cfg.h
index 942c0b7..5f8e6b3 100644
--- a/src/lstack/include/lstack_cfg.h
+++ b/src/lstack/include/lstack_cfg.h
@@ -103,6 +103,7 @@ struct cfg_params {
char unix_socket_filename[NAME_MAX];
uint16_t send_ring_size;
bool expand_send_ring;
+ bool tuple_filter;
};
struct cfg_params *get_global_cfg_params(void);
diff --git a/src/lstack/include/lstack_ethdev.h b/src/lstack/include/lstack_ethdev.h
index 25f5b8e..39a972d 100644
--- a/src/lstack/include/lstack_ethdev.h
+++ b/src/lstack/include/lstack_ethdev.h
@@ -45,7 +45,6 @@ int32_t gazelle_eth_dev_poll(struct protocol_stack *stack, uint8_t use_ltran_fla
void eth_dev_recv(struct rte_mbuf *mbuf, struct protocol_stack *stack);
int recv_pkts_from_other_process(int process_index, void* arg);
-void create_flow_rule_map();
void kni_handle_rx(uint16_t port_id);
void delete_user_process_port(uint16_t dst_port, enum port_type type);
void add_user_process_port(uint16_t dst_port, uint8_t process_idx, enum port_type type);
diff --git a/src/lstack/include/lstack_vdev.h b/src/lstack/include/lstack_vdev.h
index 0995277..540a31a 100644
--- a/src/lstack/include/lstack_vdev.h
+++ b/src/lstack/include/lstack_vdev.h
@@ -22,7 +22,6 @@ void vdev_dev_ops_init(struct lstack_dev_ops *dev_ops);
int vdev_reg_xmit(enum reg_ring_type type, struct gazelle_quintuple *qtuple);
int recv_pkts_from_other_process(int process_index, void* arg);
-void create_flow_rule_map();
void transfer_delete_rule_info_to_process0(uint32_t dst_ip, uint16_t src_port, uint16_t dst_port);
void transfer_create_rule_info_to_process0(uint16_t queue_id, uint32_t src_ip, uint32_t dst_ip, uint16_t src_port, uint16_t dst_port);
void transfer_add_or_delete_listen_port_to_process0(uint16_t listen_port, uint8_t process_idx, uint8_t is_add);
diff --git a/src/lstack/lstack.conf b/src/lstack/lstack.conf
index 389a81c..64a2f42 100644
--- a/src/lstack/lstack.conf
+++ b/src/lstack/lstack.conf
@@ -50,6 +50,14 @@ mask_addr="255.255.255.0"
gateway_addr="192.168.1.1"
devices="aa:bb:cc:dd:ee:ff"
-num_process=2
+#0: use rss rule
+#1: use tcp tuple rule to specify packet to nic queue
+tuple_filter=0
+
+#tuple_filter=1, below cfg valid
+num_process=1
process_numa="0,1"
process_idx=0
+
+#tuple_filer=0, below cfg valid
+listen_shadow=0
diff --git a/src/lstack/netif/lstack_ethdev.c b/src/lstack/netif/lstack_ethdev.c
index 5032b5b..5ec211d 100644
--- a/src/lstack/netif/lstack_ethdev.c
+++ b/src/lstack/netif/lstack_ethdev.c
@@ -530,7 +530,6 @@ int recv_pkts_from_other_process(int process_index, void* arg){
parse_arp_and_transefer(buf);
}else if(n == TRANSFER_TCP_MUBF_LEN) {
/* tcp. lstack_mbuf_queue_id */
- printf("recv_pkts_from_other_process, process idx %d \n ", process_index);
parse_tcp_and_transefer(buf);
}else if (n == DELETE_FLOWS_PARAMS_LENGTH) {
/* delete rule */
@@ -645,7 +644,6 @@ void kni_handle_tx(struct rte_mbuf *mbuf)
ipv4_hdr->hdr_checksum = rte_ipv4_cksum(ipv4_hdr);
}
- // 发送到内核协议栈
if (!rte_kni_tx_burst(get_gazelle_kni(), &mbuf, 1)) {
rte_pktmbuf_free(mbuf);
}
@@ -680,8 +678,8 @@ int32_t gazelle_eth_dev_poll(struct protocol_stack *stack, uint8_t use_ltran_fla
transfer_arp_to_other_process(stack->pkts[i]);
transfer_type = TRANSFER_KERNEL;
}
- }else {
- if (!use_ltran_flag && stack->queue_id == 0) {
+ } else {
+ if (!use_ltran_flag && get_global_cfg_params()->tuple_filter && stack->queue_id == 0) {
transfer_type = distribute_pakages(stack->pkts[i]);
}
}
diff --git a/src/lstack/netif/lstack_vdev.c b/src/lstack/netif/lstack_vdev.c
index 1752853..2a4c6ac 100644
--- a/src/lstack/netif/lstack_vdev.c
+++ b/src/lstack/netif/lstack_vdev.c
@@ -151,7 +151,7 @@ int32_t vdev_reg_xmit(enum reg_ring_type type, struct gazelle_quintuple *qtuple)
return -1;
}
- if (!use_ltran()) {
+ if (!use_ltran() & get_global_cfg_params()->tuple_filter) {
if(type == REG_RING_TCP_LISTEN_CLOSE){
if (get_global_cfg_params()->is_primary) {
delete_user_process_port(qtuple->src_port, PORT_LISTEN);
@@ -190,6 +190,9 @@ int32_t vdev_reg_xmit(enum reg_ring_type type, struct gazelle_quintuple *qtuple)
}
return 0;
}
+ if (!use_ltran()) {
+ return 0;
+ }
int32_t ret;
--
2.23.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。