加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0045-ethdev-mbuf-data-start-pointer-pbuf-payload.patch 2.21 KB
一键复制 编辑 原始数据 按行查看 历史
yinbin6 提交于 2023-11-18 17:35 . sync modif mem
From b902a2a2f392ab945bedf7d2d9eb22f6a0aa032c Mon Sep 17 00:00:00 2001
From: jiangheng <jiangheng14@huawei.com>
Date: Wed, 15 Nov 2023 19:15:13 +0800
Subject: [PATCH] ethdev: mbuf data start pointer pbuf->payload
---
src/lstack/netif/lstack_ethdev.c | 26 ++++++++++----------------
1 file changed, 10 insertions(+), 16 deletions(-)
diff --git a/src/lstack/netif/lstack_ethdev.c b/src/lstack/netif/lstack_ethdev.c
index da16e85..1d04684 100644
--- a/src/lstack/netif/lstack_ethdev.c
+++ b/src/lstack/netif/lstack_ethdev.c
@@ -809,10 +809,7 @@ static err_t eth_dev_output(struct netif *netif, struct pbuf *pbuf)
struct rte_mbuf *pre_mbuf = NULL;
struct rte_mbuf *first_mbuf = NULL;
struct pbuf *first_pbuf = pbuf;
- uint16_t header_len = 0;
- if (likely(first_pbuf != NULL)) {
- header_len = first_pbuf->l2_len + first_pbuf->l3_len + first_pbuf->l4_len;
- }
+ void *buf_addr;
while (likely(pbuf != NULL)) {
struct rte_mbuf *mbuf = pbuf_to_mbuf(pbuf);
@@ -821,26 +818,23 @@ static err_t eth_dev_output(struct netif *netif, struct pbuf *pbuf)
mbuf->pkt_len = pbuf->tot_len;
mbuf->ol_flags = pbuf->ol_flags;
mbuf->next = NULL;
+ buf_addr = rte_pktmbuf_mtod(mbuf, void *);
+
+ /*
+ * |rte_mbuf | mbuf_private | data_off | data |
+ * ^ ^
+ * buf_addr payload
+ * m->buf_addr pointer pbuf->payload
+ */
+ mbuf->data_off += (uint8_t *)pbuf->payload - (uint8_t *)buf_addr;
if (first_mbuf == NULL) {
first_mbuf = mbuf;
first_pbuf = pbuf;
first_mbuf->nb_segs = 1;
- if (pbuf->header_off > 0) {
- mbuf->data_off -= header_len;
- pbuf->header_off = 0;
- }
} else {
first_mbuf->nb_segs++;
pre_mbuf->next = mbuf;
- if (pbuf->header_off == 0) {
- mbuf->data_off += header_len;
- pbuf->header_off = header_len;
- }
- }
-
- if (first_pbuf->l4_len == 8) {
- mbuf->data_off += 12;
}
if (likely(first_mbuf->pkt_len > MBUF_MAX_LEN)) {
--
2.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化