1 Star 0 Fork 32

jinag12/gazelle_1

forked from src-openEuler/gazelle 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0144-support-udp-pkglen-mtu.patch 3.04 KB
一键复制 编辑 原始数据 按行查看 历史
jinag12 提交于 2024-03-14 16:57 . sync fix rpc_pool create failed coredump
From 5ba19529acaf76a681313245a9a278356b615687 Mon Sep 17 00:00:00 2001
From: yangchen <yangchen145@huawei.com>
Date: Mon, 4 Mar 2024 14:10:43 +0800
Subject: [PATCH] support udp pkglen > mtu
---
src/lstack/core/lstack_lwip.c | 20 ++++++++++++++++++--
src/lstack/include/lstack_dpdk.h | 2 +-
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/src/lstack/core/lstack_lwip.c b/src/lstack/core/lstack_lwip.c
index 7715cf3..f4199f8 100644
--- a/src/lstack/core/lstack_lwip.c
+++ b/src/lstack/core/lstack_lwip.c
@@ -252,6 +252,13 @@ struct pbuf *do_lwip_get_from_sendring(struct lwip_sock *sock, uint16_t remain_s
return NULL;
}
+ /* udp send a pbuf chain, dequeue all pbufs except head pbuf */
+ if (NETCONN_IS_UDP(sock) && remain_size > MBUF_MAX_DATA_LEN) {
+ int size = (remain_size + MBUF_MAX_DATA_LEN - 1) / MBUF_MAX_DATA_LEN - 1;
+ struct pbuf *pbuf_used[size];
+ gazelle_ring_sc_dequeue(sock->send_ring, (void **)&pbuf_used, size);
+ }
+
if (get_protocol_stack_group()->latency_start) {
calculate_lstack_latency(&sock->stack->latency, pbuf, GAZELLE_LATENCY_WRITE_LWIP);
}
@@ -285,7 +292,7 @@ void do_lwip_get_from_sendring_over(struct lwip_sock *sock)
sock->stack->stats.write_lwip_cnt++;
}
-static ssize_t do_app_write(struct pbuf *pbufs[], void *buf, size_t len, uint32_t write_num)
+static ssize_t do_app_write(struct lwip_sock *sock, struct pbuf *pbufs[], void *buf, size_t len, uint32_t write_num)
{
ssize_t send_len = 0;
uint32_t i = 0;
@@ -297,6 +304,11 @@ static ssize_t do_app_write(struct pbuf *pbufs[], void *buf, size_t len, uint32_
rte_memcpy((char *)pbufs[i]->payload, (char *)buf + send_len, MBUF_MAX_DATA_LEN);
pbufs[i]->tot_len = pbufs[i]->len = MBUF_MAX_DATA_LEN;
send_len += MBUF_MAX_DATA_LEN;
+
+ /* if udp pkg len > mtu, use pbuf chain to send it */
+ if (NETCONN_IS_UDP(sock) && i > 0) {
+ pbuf_cat(pbufs[0], pbufs[i]);
+ }
}
/* reduce the branch in loop */
@@ -305,6 +317,10 @@ static ssize_t do_app_write(struct pbuf *pbufs[], void *buf, size_t len, uint32_
pbufs[i]->tot_len = pbufs[i]->len = copy_len;
send_len += copy_len;
+ if (NETCONN_IS_UDP(sock) && i > 0) {
+ pbuf_cat(pbufs[0], pbufs[i]);
+ }
+
return send_len;
}
@@ -320,7 +336,7 @@ static inline ssize_t app_buff_write(struct lwip_sock *sock, void *buf, size_t l
time_stamp_into_pbuf(write_num, pbufs, time_stamp);
}
- ssize_t send_len = do_app_write(pbufs, buf, len, write_num);
+ ssize_t send_len = do_app_write(sock, pbufs, buf, len, write_num);
if (addr) {
if (addr->sa_family == AF_INET) {
diff --git a/src/lstack/include/lstack_dpdk.h b/src/lstack/include/lstack_dpdk.h
index c40f3c0..c7cfbdf 100644
--- a/src/lstack/include/lstack_dpdk.h
+++ b/src/lstack/include/lstack_dpdk.h
@@ -21,7 +21,7 @@
#define KNI_NB_MBUF (DEFAULT_RING_SIZE << 4)
-#define MAX_PACKET_SZ 1530
+#define MAX_PACKET_SZ 1538
#define RING_SIZE(x) ((x) - 1)
--
2.27.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/jiangheng12/gazelle_1.git
git@gitee.com:jiangheng12/gazelle_1.git
jiangheng12
gazelle_1
gazelle_1
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385