1 Star 0 Fork 32

吴昌盛/gazelle-tar

forked from src-openEuler/gazelle 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0199-remove-rxtx-driver-cache.patch 6.51 KB
一键复制 编辑 原始数据 按行查看 历史
From dea4fbb8a7a21877c21ec50573427dd202309973 Mon Sep 17 00:00:00 2001
From: jiangheng12 <jiangheng14@huawei.com>
Date: Fri, 10 Mar 2023 10:05:40 +0800
Subject: [PATCH] remove rxtx driver cache
---
src/lstack/core/lstack_lwip.c | 8 +---
src/lstack/core/lstack_protocol_stack.c | 44 ----------------------
src/lstack/include/lstack_protocol_stack.h | 14 -------
src/lstack/netif/lstack_ethdev.c | 23 ++++-------
src/lstack/netif/lstack_vdev.c | 9 ++++-
5 files changed, 16 insertions(+), 82 deletions(-)
diff --git a/src/lstack/core/lstack_lwip.c b/src/lstack/core/lstack_lwip.c
index f23419d..51cc9d1 100644
--- a/src/lstack/core/lstack_lwip.c
+++ b/src/lstack/core/lstack_lwip.c
@@ -215,14 +215,8 @@ void gazelle_free_pbuf(struct pbuf *pbuf)
}
struct rte_mbuf *mbuf = pbuf_to_mbuf(pbuf);
- struct protocol_stack *stack = get_protocol_stack();
- if (STACK_FREE_INDEX(stack->free_end + 1) != STACK_FREE_INDEX(stack->free_start)) {
- stack->free_pkts[STACK_FREE_INDEX(stack->free_end)] = mbuf;
- stack->free_end++;
- } else {
- rte_pktmbuf_free_seg(mbuf);
- }
+ rte_pktmbuf_free_seg(mbuf);
}
int32_t gazelle_alloc_pktmbuf(struct rte_mempool *pool, struct rte_mbuf **mbufs, uint32_t num)
diff --git a/src/lstack/core/lstack_protocol_stack.c b/src/lstack/core/lstack_protocol_stack.c
index 93204d1..e13034f 100644
--- a/src/lstack/core/lstack_protocol_stack.c
+++ b/src/lstack/core/lstack_protocol_stack.c
@@ -411,46 +411,6 @@ static void wakeup_kernel_event(struct protocol_stack *stack)
stack->kernel_event_num = 0;
}
-void stack_send_pkts(struct protocol_stack *stack)
-{
- uint32_t send_num = stack->send_end - stack->send_start;
-
- if (send_num == 0) {
- return;
- }
-
- uint32_t start = stack->send_start & STACK_SEND_MASK;
- uint32_t end = stack->send_end & STACK_SEND_MASK;
- uint32_t sent_pkts = 0;
-
- if (start < end) {
- sent_pkts = stack->dev_ops.tx_xmit(stack, &stack->send_pkts[start], send_num);
- } else {
- send_num = STACK_SEND_MAX - start;
- sent_pkts = stack->dev_ops.tx_xmit(stack, &stack->send_pkts[start], send_num);
- if (sent_pkts == send_num) {
- sent_pkts += stack->dev_ops.tx_xmit(stack, stack->send_pkts, end);
- }
- }
-
- stack->send_start += sent_pkts;
- stack->stats.tx += sent_pkts;
-}
-
-void stack_free_recv_pkts(struct protocol_stack *stack, uint32_t free_num)
-{
- if (stack->free_end == stack->free_start) {
- return;
- }
-
- uint32_t num = 0;
- for (uint32_t i = stack->free_start; num < free_num && i < stack->free_end; i++) {
- rte_pktmbuf_free_seg(stack->free_pkts[STACK_FREE_INDEX(i)]);
- num++;
- }
- stack->free_start += num;
-}
-
static void* gazelle_stack_thread(void *arg)
{
uint16_t queue_id = *(uint16_t *)arg;
@@ -483,10 +443,6 @@ static void* gazelle_stack_thread(void *arg)
send_stack_list(stack, send_connect_number);
- stack_send_pkts(stack);
-
- stack_free_recv_pkts(stack, nic_read_number);
-
gazelle_eth_dev_poll(stack, use_ltran_flag, nic_read_number);
read_recv_list(stack, read_connect_number);
diff --git a/src/lstack/include/lstack_protocol_stack.h b/src/lstack/include/lstack_protocol_stack.h
index b093362..1fac220 100644
--- a/src/lstack/include/lstack_protocol_stack.h
+++ b/src/lstack/include/lstack_protocol_stack.h
@@ -31,14 +31,6 @@
#define SOCK_SEND_REPLENISH_THRES (16)
#define WAKEUP_MAX_NUM (32)
-#define STACK_SEND_MAX 2048
-#define STACK_SEND_MASK (STACK_SEND_MAX - 1)
-#define STACK_SEND_INDEX(index) ((index) & STACK_SEND_MASK)
-
-#define STACK_FREE_MAX 4096
-#define STACK_FREE_MASK (STACK_FREE_MAX - 1)
-#define STACK_FREE_INDEX(index) ((index) & STACK_FREE_MASK)
-
struct rte_mempool;
struct rte_ring;
struct rte_mbuf;
@@ -74,12 +66,6 @@ struct protocol_stack {
uint32_t rx_ring_used;
uint32_t tx_ring_used;
- uint32_t free_start;
- uint32_t free_end;
- struct rte_mbuf *free_pkts[STACK_FREE_MAX];
- uint32_t send_start;
- uint32_t send_end;
- struct rte_mbuf *send_pkts[STACK_SEND_MAX];
struct rte_mbuf *pkts[RTE_TEST_RX_DESC_DEFAULT];
struct list_node recv_list;
struct list_node send_list;
diff --git a/src/lstack/netif/lstack_ethdev.c b/src/lstack/netif/lstack_ethdev.c
index db353f9..1441f64 100644
--- a/src/lstack/netif/lstack_ethdev.c
+++ b/src/lstack/netif/lstack_ethdev.c
@@ -147,21 +147,6 @@ int32_t gazelle_eth_dev_poll(struct protocol_stack *stack, bool use_ltran_flag,
return nr_pkts;
}
-static void add_send_pkt(struct protocol_stack *stack, struct rte_mbuf *mbuf)
-{
- do {
- if (STACK_SEND_INDEX(stack->send_end + 1) != STACK_SEND_INDEX(stack->send_start)) {
- stack->send_pkts[STACK_SEND_INDEX(stack->send_end)] = mbuf;
- stack->send_end++;
- return;
- }
-
- stack_send_pkts(stack);
-
- stack->stats.send_pkts_fail++;
- } while (1);
-}
-
static err_t eth_dev_output(struct netif *netif, struct pbuf *pbuf)
{
struct protocol_stack *stack = get_protocol_stack();
@@ -212,7 +197,13 @@ static err_t eth_dev_output(struct netif *netif, struct pbuf *pbuf)
pbuf = pbuf->next;
}
- add_send_pkt(stack, first_mbuf);
+ uint32_t sent_pkts = stack->dev_ops.tx_xmit(stack, &first_mbuf, 1);
+ stack->stats.tx += sent_pkts;
+ if (sent_pkts < 1) {
+ stack->stats.tx_drop++;
+ rte_pktmbuf_free(first_mbuf);
+ return ERR_MEM;
+ }
return ERR_OK;
}
diff --git a/src/lstack/netif/lstack_vdev.c b/src/lstack/netif/lstack_vdev.c
index 801edf8..3d1204e 100644
--- a/src/lstack/netif/lstack_vdev.c
+++ b/src/lstack/netif/lstack_vdev.c
@@ -129,11 +129,18 @@ static uint32_t ltran_tx_xmit(struct protocol_stack *stack, struct rte_mbuf **pk
static uint32_t vdev_tx_xmit(struct protocol_stack *stack, struct rte_mbuf **pkts, uint32_t nr_pkts)
{
+ uint32_t sent_pkts = 0;
+
if (rte_eth_tx_prepare(stack->port_id, stack->queue_id, pkts, nr_pkts) != nr_pkts) {
stack->stats.tx_prepare_fail++;
+ LSTACK_LOG(INFO, LSTACK, "rte_eth_tx_prepare failed\n");
}
- return rte_eth_tx_burst(stack->port_id, stack->queue_id, pkts, nr_pkts);
+ do {
+ sent_pkts += rte_eth_tx_burst(stack->port_id, stack->queue_id, &pkts[sent_pkts], nr_pkts - sent_pkts);
+ } while (sent_pkts < nr_pkts);
+
+ return sent_pkts;
}
int32_t vdev_reg_xmit(enum reg_ring_type type, struct gazelle_quintuple *qtuple)
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wu-changsheng/gazelle-tar.git
git@gitee.com:wu-changsheng/gazelle-tar.git
wu-changsheng
gazelle-tar
gazelle-tar
master

搜索帮助