52 lines
2.1 KiB
Diff
52 lines
2.1 KiB
Diff
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
|
|
|