1 Star 0 Fork 32

LemmyHuang/gazelle_1

forked from src-openEuler/gazelle 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0065-support-vlan-offload.patch 3.55 KB
一键复制 编辑 原始数据 按行查看 历史
yinbin6 提交于 2023-11-29 15:01 . sync support vlan offload
From a449111fed8c0c4cd7b8021ff20b3ea12f334479 Mon Sep 17 00:00:00 2001
From: zhengjiebing <zhengjiebing_yewu@cmss.chinamobile.com>
Date: Tue, 28 Nov 2023 14:14:15 +0800
Subject: [PATCH] support vlan offload
---
src/common/dpdk_common.c | 12 ++++++++++++
src/lstack/netif/lstack_ethdev.c | 13 +++++++------
src/lstack/netif/lstack_vdev.c | 3 ++-
3 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/src/common/dpdk_common.c b/src/common/dpdk_common.c
index 52a163f..50f0bf0 100644
--- a/src/common/dpdk_common.c
+++ b/src/common/dpdk_common.c
@@ -104,6 +104,12 @@ void eth_params_checksum(struct rte_eth_conf *conf, struct rte_eth_dev_info *dev
COMMON_INFO("DEV_RX_OFFLOAD_UDP_CKSUM\n");
}
+ // rx vlan
+ if (rx_ol_capa & DEV_RX_OFFLOAD_VLAN_STRIP) {
+ rx_ol |= DEV_RX_OFFLOAD_VLAN_STRIP;
+ COMMON_INFO("DEV_RX_OFFLOAD_VLAN_STRIP\n");
+ }
+
// tx ip
if (tx_ol_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) {
tx_ol |= DEV_TX_OFFLOAD_IPV4_CKSUM;
@@ -128,6 +134,12 @@ void eth_params_checksum(struct rte_eth_conf *conf, struct rte_eth_dev_info *dev
COMMON_INFO("DEV_TX_OFFLOAD_TCP_TSO\n");
}
+ // tx vlan
+ if (tx_ol_capa & DEV_TX_OFFLOAD_VLAN_INSERT) {
+ tx_ol |= DEV_TX_OFFLOAD_VLAN_INSERT;
+ COMMON_INFO("DEV_TX_OFFLOAD_VLAN_INSERT\n");
+ }
+
if (!(rx_ol & DEV_RX_OFFLOAD_UDP_CKSUM) ||
!(rx_ol & DEV_RX_OFFLOAD_TCP_CKSUM) ||
!(rx_ol & DEV_RX_OFFLOAD_IPV4_CKSUM)) {
diff --git a/src/lstack/netif/lstack_ethdev.c b/src/lstack/netif/lstack_ethdev.c
index cce2fcf..31856f2 100644
--- a/src/lstack/netif/lstack_ethdev.c
+++ b/src/lstack/netif/lstack_ethdev.c
@@ -815,12 +815,12 @@ int32_t gazelle_eth_dev_poll(struct protocol_stack *stack, uint8_t use_ltran_fla
/* copy arp into other stack */
if (!use_ltran_flag) {
struct rte_ether_hdr *ethh = rte_pktmbuf_mtod(stack->pkts[i], struct rte_ether_hdr *);
- u16_t type;
- type = ethh->ether_type;
- if (type == PP_HTONS(ETHTYPE_VLAN)) {
- struct eth_vlan_hdr *vlan = (struct eth_vlan_hdr *)(((char *)ethh) + SIZEOF_ETH_HDR);
- type = vlan->tpid;
- }
+ u16_t type;
+ type = ethh->ether_type;
+ if (type == PP_HTONS(ETHTYPE_VLAN)) {
+ struct eth_vlan_hdr *vlan = (struct eth_vlan_hdr *)(((char *)ethh) + SIZEOF_ETH_HDR);
+ type = vlan->tpid;
+ }
if (unlikely(RTE_BE16(RTE_ETHER_TYPE_ARP) == type)) {
stack_broadcast_arp(stack->pkts[i], stack);
/* copy arp into other process */
@@ -860,6 +860,7 @@ static err_t eth_dev_output(struct netif *netif, struct pbuf *pbuf)
mbuf->data_len = pbuf->len;
mbuf->pkt_len = pbuf->tot_len;
mbuf->ol_flags = pbuf->ol_flags;
+ mbuf->vlan_tci = pbuf->vlan_tci;
mbuf->next = NULL;
buf_addr = rte_pktmbuf_mtod(mbuf, void *);
diff --git a/src/lstack/netif/lstack_vdev.c b/src/lstack/netif/lstack_vdev.c
index 18322a6..e1438da 100644
--- a/src/lstack/netif/lstack_vdev.c
+++ b/src/lstack/netif/lstack_vdev.c
@@ -84,7 +84,8 @@ static uint32_t vdev_rx_poll(struct protocol_stack *stack, struct rte_mbuf **pkt
}
/* skip gro when tcp/ip cksum offloads disable */
- if (get_protocol_stack_group()->rx_offload == 0 || get_global_cfg_params()->nic.vlan_mode >= 0) {
+ if (get_protocol_stack_group()->rx_offload == 0 || (get_global_cfg_params()->nic.vlan_mode >= 0
+ && !(get_protocol_stack_group()->rx_offload & DEV_RX_OFFLOAD_VLAN_STRIP))) {
return pkt_num;
}
--
2.27.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/LemmyHuang/gazelle_1.git
git@gitee.com:LemmyHuang/gazelle_1.git
LemmyHuang
gazelle_1
gazelle_1
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385