14 Star 5 Fork 32

src-openEuler/gazelle

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0235-virtio_user-add-vlan-info-for-kernerl-packets-when-v.patch 2.12 KB
一键复制 编辑 原始数据 按行查看 历史
yinbin6 提交于 2024-08-09 16:37 . sync refector fill udp sendring
From a547e495321969074b72331c0ae6b65a39975f6a Mon Sep 17 00:00:00 2001
From: hkk <hankangkang5@huawei.com>
Date: Mon, 5 Aug 2024 21:58:46 +0800
Subject: [PATCH] virtio_user: add vlan info for kernerl packets when vlan
switch is on
---
src/lstack/core/lstack_virtio.c | 14 ++++++++++++++
src/lstack/netif/lstack_vdev.c | 1 +
2 files changed, 15 insertions(+)
diff --git a/src/lstack/core/lstack_virtio.c b/src/lstack/core/lstack_virtio.c
index 70b025c..f95b289 100644
--- a/src/lstack/core/lstack_virtio.c
+++ b/src/lstack/core/lstack_virtio.c
@@ -179,6 +179,20 @@ void virtio_tap_process_rx(uint16_t port, uint32_t queue_id)
uint32_t pkg_num;
pkg_num = rte_eth_rx_burst(g_virtio_instance.virtio_port_id, queue_id, pkts_burst, VIRTIO_TX_RX_RING_SIZE);
+ /*
+ * For VLAN, the tap device defaults to tx-vlan-ofload as enabled and will not be modified by default,
+ * so the judgment is skipped.
+ * For checksum, tap devices are turned off by default, and it is assumed that they will not be modified,
+ * so no action will be taken.
+ * For TSO, tap devices do not support it, so no action will be taken.
+ */
+ if (get_global_cfg_params()->nic.vlan_mode != -1) {
+ for (int i = 0; i< pkg_num; i++) {
+ pkts_burst[i]->ol_flags |= RTE_MBUF_F_TX_VLAN;
+ pkts_burst[i]->vlan_tci = (u16_t)get_global_cfg_params()->nic.vlan_mode;
+ }
+ }
+
if (pkg_num > 0) {
g_virtio_instance.rx_pkg[queue_id] += pkg_num;
uint16_t nb_rx = rte_eth_tx_burst(lstack_net_port, queue_id, pkts_burst, pkg_num);
diff --git a/src/lstack/netif/lstack_vdev.c b/src/lstack/netif/lstack_vdev.c
index a590b30..9ca77ba 100644
--- a/src/lstack/netif/lstack_vdev.c
+++ b/src/lstack/netif/lstack_vdev.c
@@ -87,6 +87,7 @@ static inline void vdev_pkts_parse(struct rte_mbuf **pkts, int pkt_num)
pkts[i]->l2_len = sizeof(struct rte_ether_hdr);
}
+ pkts[i]->packet_type = 0;
if (type == RTE_BE16(RTE_ETHER_TYPE_IPV4)) {
struct rte_ipv4_hdr *iph = rte_pktmbuf_mtod_offset(pkts[i], struct rte_ipv4_hdr *,
pkts[i]->l2_len);
--
2.33.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/gazelle.git
git@gitee.com:src-openeuler/gazelle.git
src-openeuler
gazelle
gazelle
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385