1 Star 0 Fork 32

fantaotao1/gazelle

forked from src-openEuler/gazelle 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0101-conenct-support-multi-queues.patch 3.70 KB
一键复制 编辑 原始数据 按行查看 历史
吴昌盛 提交于 2022-10-08 22:27 . adapt ceph client
From e55108b4f3ef13556075da292d1dc17a3335fb04 Mon Sep 17 00:00:00 2001
From: wu-changsheng <wuchangsheng2@huawei.com>
Date: Sat, 8 Oct 2022 17:57:40 +0800
Subject: [PATCH 17/21] conenct support multi queues
---
src/lstack/core/lstack_dpdk.c | 38 ++++++++++++++++++++--
src/lstack/include/lstack_dpdk.h | 1 +
src/lstack/include/lstack_protocol_stack.h | 2 ++
3 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/src/lstack/core/lstack_dpdk.c b/src/lstack/core/lstack_dpdk.c
index 8d45838..39f8ecf 100644
--- a/src/lstack/core/lstack_dpdk.c
+++ b/src/lstack/core/lstack_dpdk.c
@@ -27,6 +27,7 @@
#include <rte_bus.h>
#include <rte_errno.h>
#include <rte_kni.h>
+#include <rte_thash.h>
#include <lwip/posix_api.h>
#include <lwipopts.h>
#include <lwip/pbuf.h>
@@ -55,6 +56,15 @@ struct eth_params {
struct rte_kni;
static struct rte_bus *g_pci_bus = NULL;
+#define RSS_HASH_KEY_LEN 40
+static uint8_t g_default_rss_key[] = {
+ 0x6d, 0x5a, 0x56, 0xda, 0x25, 0x5b, 0x0e, 0xc2,
+ 0x41, 0x67, 0x25, 0x3d, 0x43, 0xa3, 0x8f, 0xb0,
+ 0xd0, 0xca, 0x2b, 0xcb, 0xae, 0x7b, 0x30, 0xb4,
+ 0x77, 0xcb, 0x2d, 0xa3, 0x80, 0x30, 0xf2, 0x0c,
+ 0x6a, 0x42, 0xb7, 0x3b, 0xbe, 0xac, 0x01, 0xfa,
+};
+
int32_t thread_affinity_default(void)
{
static cpu_set_t cpuset;
@@ -327,8 +337,8 @@ static int eth_params_rss(struct rte_eth_conf *conf, struct rte_eth_dev_info *de
int rss_enable = 0;
uint64_t def_rss_hf = ETH_RSS_TCP | ETH_RSS_IP;
struct rte_eth_rss_conf rss_conf = {
- NULL,
- 40,
+ g_default_rss_key,
+ RSS_HASH_KEY_LEN,
def_rss_hf,
};
@@ -445,7 +455,9 @@ int32_t dpdk_ethdev_init(void)
if (rss_enable) {
rss_setup(port_id, nb_queues);
+ stack_group->reta_mask = dev_info.reta_size - 1;
}
+ stack_group->nb_queues = nb_queues;
return 0;
}
@@ -571,3 +583,25 @@ int32_t init_dpdk_ethdev(void)
sem_post(&stack_group->ethdev_init);
return 0;
}
+
+bool port_in_stack_queue(uint32_t src_ip, uint32_t dst_ip, uint16_t src_port, uint16_t dst_port)
+{
+ struct protocol_stack_group *stack_group = get_protocol_stack_group();
+ if (stack_group->reta_mask == 0 || stack_group->nb_queues <= 1) {
+ return true;
+ }
+
+ struct rte_ipv4_tuple tuple = {0};
+ tuple.src_addr = rte_be_to_cpu_32(src_ip);
+ tuple.dst_addr = rte_be_to_cpu_32(dst_ip);
+ tuple.sport = src_port;
+ tuple.dport = dst_port;
+
+ uint32_t hash = rte_softrss((uint32_t *)&tuple, RTE_THASH_V4_L4_LEN, g_default_rss_key);
+
+ uint32_t reta_index = hash & stack_group->reta_mask;
+
+ struct protocol_stack *stack = get_protocol_stack();
+ return (reta_index % stack_group->nb_queues) == stack->queue_id;
+}
+
diff --git a/src/lstack/include/lstack_dpdk.h b/src/lstack/include/lstack_dpdk.h
index e224f23..684d025 100644
--- a/src/lstack/include/lstack_dpdk.h
+++ b/src/lstack/include/lstack_dpdk.h
@@ -51,5 +51,6 @@ int dpdk_ethdev_start(void);
void dpdk_skip_nic_init(void);
int32_t dpdk_init_lstack_kni(void);
void dpdk_restore_pci(void);
+bool port_in_stack_queue(uint32_t src_ip, uint32_t dst_ip, uint16_t src_port, uint16_t dst_port);
#endif /* GAZELLE_DPDK_H */
diff --git a/src/lstack/include/lstack_protocol_stack.h b/src/lstack/include/lstack_protocol_stack.h
index 0a060b4..a791357 100644
--- a/src/lstack/include/lstack_protocol_stack.h
+++ b/src/lstack/include/lstack_protocol_stack.h
@@ -78,6 +78,8 @@ struct protocol_stack_group {
sem_t all_init;
uint64_t rx_offload;
uint64_t tx_offload;
+ uint32_t reta_mask;
+ uint16_t nb_queues;
struct rte_mempool *kni_pktmbuf_pool;
struct eth_params *eth_params;
struct protocol_stack *stacks[PROTOCOL_STACK_MAX];
--
2.23.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/fantaotao1/gazelle.git
git@gitee.com:fantaotao1/gazelle.git
fantaotao1
gazelle
gazelle
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385