1 Star 0 Fork 32

fantaotao1/gazelle

forked from src-openEuler/gazelle 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0160-optimite-net-type.patch 2.90 KB
一键复制 编辑 原始数据 按行查看 历史
jinag12 提交于 2022-12-17 15:26 . stack thread params set dafault value
From bad6066508dcefeabac220df948d7505c3191b66 Mon Sep 17 00:00:00 2001
From: wuchangsheng <wuchangsheng2@huawei.com>
Date: Fri, 16 Dec 2022 20:13:57 +0800
Subject: [PATCH 2/2] optimite net type
---
src/lstack/core/lstack_lwip.c | 2 +-
src/lstack/netif/lstack_vdev.c | 28 +++++++++++++++++++++++-----
2 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/src/lstack/core/lstack_lwip.c b/src/lstack/core/lstack_lwip.c
index 0aaae30..d4e2d9c 100644
--- a/src/lstack/core/lstack_lwip.c
+++ b/src/lstack/core/lstack_lwip.c
@@ -935,7 +935,7 @@ void read_recv_list(struct protocol_stack *stack, uint32_t max_num)
list_for_each_safe(node, temp, list) {
sock = container_of(node, struct lwip_sock, recv_list);
- if (++read_num >= max_num) {
+ if (++read_num > max_num) {
/* list head move to next send */
list_del_node(&stack->recv_list);
list_add_node(&sock->recv_list, &stack->recv_list);
diff --git a/src/lstack/netif/lstack_vdev.c b/src/lstack/netif/lstack_vdev.c
index 5bdaf63..f6e7a1a 100644
--- a/src/lstack/netif/lstack_vdev.c
+++ b/src/lstack/netif/lstack_vdev.c
@@ -40,6 +40,11 @@
#define INUSE_TX_PKTS_WATERMARK (VDEV_TX_QUEUE_SZ >> 2)
#define USED_RX_PKTS_WATERMARK (FREE_RX_QUEUE_SZ >> 2)
+#define IPV4_MASK (0xf0)
+#define IPV4_VERION (0x40)
+
+#define TCP_HDR_LEN(tcp_hdr) ((tcp_hdr->data_off & 0xf0) >> 2)
+
static uint32_t ltran_rx_poll(struct protocol_stack *stack, struct rte_mbuf **pkts, uint32_t max_mbuf)
{
uint32_t rcvd_pkts;
@@ -78,11 +83,24 @@ static uint32_t vdev_rx_poll(struct protocol_stack *stack, struct rte_mbuf **pkt
}
for (uint32_t i = 0; i < pkt_num; i++) {
- struct rte_net_hdr_lens hdr_lens;
- pkts[i]->packet_type = rte_net_get_ptype(pkts[i], &hdr_lens, RTE_PTYPE_ALL_MASK);
- pkts[i]->l2_len = hdr_lens.l2_len;
- pkts[i]->l3_len = hdr_lens.l3_len;
- pkts[i]->l4_len = hdr_lens.l4_len;
+ struct rte_ether_hdr *ethh = rte_pktmbuf_mtod(pkts[i], struct rte_ether_hdr *);
+ if (unlikely(RTE_BE16(RTE_ETHER_TYPE_IPV4) != ethh->ether_type)) {
+ continue;
+ }
+ pkts[i]->l2_len = sizeof(struct rte_ether_hdr);
+
+ struct rte_ipv4_hdr *iph = rte_pktmbuf_mtod_offset(pkts[i], struct rte_ipv4_hdr *,
+ sizeof(struct rte_ether_hdr));
+ if (unlikely((iph->version_ihl & IPV4_MASK) != IPV4_VERION)) {
+ continue;
+ }
+ pkts[i]->l3_len = sizeof(struct rte_ipv4_hdr);
+
+ struct rte_tcp_hdr *tcp_hdr = rte_pktmbuf_mtod_offset(pkts[i], struct rte_tcp_hdr *,
+ sizeof(struct rte_ether_hdr) + sizeof(struct rte_ipv4_hdr));
+ pkts[i]->l4_len = TCP_HDR_LEN(tcp_hdr);
+
+ pkts[i]->packet_type = RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_TCP;
}
return rte_gro_reassemble_burst(pkts, pkt_num, &gro_param);
}
--
2.8.4.windows.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/fantaotao1/gazelle.git
git@gitee.com:fantaotao1/gazelle.git
fantaotao1
gazelle
gazelle
master

搜索帮助