From 79e79417cabd45fb03ad36190c7810367bc47738 Mon Sep 17 00:00:00 2001 From: jiangheng Date: Thu, 10 Oct 2024 14:27:25 +0800 Subject: [PATCH] sync xdp: skip checksum temporarily due to kernel cannot transfer offloads (cherry picked from commit 996cf5f41a819080acac54ec2426191592f5f5dd) --- ...m-temporarily-due-to-kernel-cannot-t.patch | 97 +++++++++++++++++++ gazelle.spec | 6 +- 2 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 0269-xdp-skip-checksum-temporarily-due-to-kernel-cannot-t.patch diff --git a/0269-xdp-skip-checksum-temporarily-due-to-kernel-cannot-t.patch b/0269-xdp-skip-checksum-temporarily-due-to-kernel-cannot-t.patch new file mode 100644 index 0000000..243d7be --- /dev/null +++ b/0269-xdp-skip-checksum-temporarily-due-to-kernel-cannot-t.patch @@ -0,0 +1,97 @@ +From 77f34bd4406093dd47ec1fd60332ac5fd0f685a3 Mon Sep 17 00:00:00 2001 +From: jiangheng +Date: Wed, 9 Oct 2024 21:05:34 +0800 +Subject: [PATCH] xdp: skip checksum temporarily due to kernel cannot transfer + offloads + +--- + src/lstack/core/lstack_dpdk.c | 10 ++++++++++ + src/lstack/include/lstack_dpdk.h | 2 ++ + src/lstack/netif/lstack_ethdev.c | 8 +++++++- + src/lstack/netif/lstack_vdev.c | 5 +++-- + 4 files changed, 22 insertions(+), 3 deletions(-) + +diff --git a/src/lstack/core/lstack_dpdk.c b/src/lstack/core/lstack_dpdk.c +index 530332b..33605b3 100644 +--- a/src/lstack/core/lstack_dpdk.c ++++ b/src/lstack/core/lstack_dpdk.c +@@ -50,6 +50,7 @@ + + struct eth_params { + uint16_t port_id; ++ bool is_xdp; + + uint16_t nb_queues; + uint16_t nb_rx_desc; +@@ -413,6 +414,12 @@ static int eth_params_rss(struct rte_eth_conf *conf, struct rte_eth_dev_info *de + return rss_enable; + } + ++bool dpdk_nic_is_xdp(void) ++{ ++ struct protocol_stack_group *stack_group = get_protocol_stack_group(); ++ return stack_group->eth_params->is_xdp; ++} ++ + static int eth_params_init(struct eth_params *eth_params, uint16_t port_id, uint16_t nb_queues, int *rss_enable) + { + struct rte_eth_dev_info dev_info; +@@ -442,6 +449,9 @@ static int eth_params_init(struct eth_params *eth_params, uint16_t port_id, uint + eth_params->conf.intr_conf.rxq = get_global_cfg_params()->stack_interrupt; + + eth_params_checksum(ð_params->conf, &dev_info); ++ if (strcmp(dev_info.driver_name, "net_af_xdp") == 0) { ++ eth_params->is_xdp = true; ++ } + + if (!get_global_cfg_params()->tuple_filter) { + *rss_enable = eth_params_rss(ð_params->conf, &dev_info); +diff --git a/src/lstack/include/lstack_dpdk.h b/src/lstack/include/lstack_dpdk.h +index 965a0cb..0210843 100644 +--- a/src/lstack/include/lstack_dpdk.h ++++ b/src/lstack/include/lstack_dpdk.h +@@ -65,4 +65,6 @@ int32_t dpdk_init_lstack_kni(void); + void dpdk_nic_xstats_get(struct gazelle_stack_dfx_data *dfx, uint16_t port_id); + void dpdk_nic_features_get(struct gazelle_stack_dfx_data *dfx, uint16_t port_id); + ++bool dpdk_nic_is_xdp(void); ++ + #endif /* GAZELLE_DPDK_H */ +diff --git a/src/lstack/netif/lstack_ethdev.c b/src/lstack/netif/lstack_ethdev.c +index 1a721f6..315cced 100644 +--- a/src/lstack/netif/lstack_ethdev.c ++++ b/src/lstack/netif/lstack_ethdev.c +@@ -364,7 +364,13 @@ static err_t eth_dev_init(struct netif *netif) + + netif->hwaddr_len = ETHER_ADDR_LEN; + +- netif_set_rxol_flags(netif, get_protocol_stack_group()->rx_offload); ++ if (dpdk_nic_is_xdp()) { ++ netif_set_rxol_flags(netif, RTE_ETH_RX_OFFLOAD_TCP_CKSUM | ++ RTE_ETH_RX_OFFLOAD_UDP_CKSUM | ++ RTE_ETH_RX_OFFLOAD_IPV4_CKSUM); ++ } else { ++ netif_set_rxol_flags(netif, get_protocol_stack_group()->rx_offload); ++ } + netif_set_txol_flags(netif, get_protocol_stack_group()->tx_offload); + if (get_global_cfg_params()->stack_mode_rtc) { + netif_set_rtc_mode(netif); +diff --git a/src/lstack/netif/lstack_vdev.c b/src/lstack/netif/lstack_vdev.c +index 290046e..b1d1a1b 100644 +--- a/src/lstack/netif/lstack_vdev.c ++++ b/src/lstack/netif/lstack_vdev.c +@@ -146,8 +146,9 @@ static uint32_t vdev_rx_poll(struct protocol_stack *stack, struct rte_mbuf **pkt + return pkt_num; + } + +- /* skip gro when tcp/ip cksum offloads disable */ +- if (get_protocol_stack_group()->rx_offload == 0 || (get_global_cfg_params()->vlan_mode >= 0 ++ if (get_protocol_stack_group()->rx_offload == 0 || /* skip gro when tcp/ip cksum offloads disable */ ++ dpdk_nic_is_xdp() || /* kernel has done GRO */ ++ (get_global_cfg_params()->vlan_mode >= 0 + && !(get_protocol_stack_group()->rx_offload & RTE_ETH_RX_OFFLOAD_VLAN_STRIP))) { + return pkt_num; + } +-- +2.33.0 + diff --git a/gazelle.spec b/gazelle.spec index 9e8c54f..c82218b 100644 --- a/gazelle.spec +++ b/gazelle.spec @@ -2,7 +2,7 @@ Name: gazelle Version: 1.0.2 -Release: 67 +Release: 68 Summary: gazelle is a high performance user-mode stack License: MulanPSL-2.0 URL: https://gitee.com/openeuler/gazelle @@ -285,6 +285,7 @@ Patch9265: 0265-fix-stack-null-when-register-interrupt.patch Patch9266: 0266-rtw-fix-send-length-exceeding-send_ring_size.patch Patch9267: 0267-rpc-fix-rpc_sync_call-spinlock-block-when-msg-be-rec.patch Patch9268: 0268-bugfix-fix-gazelle-init-failed-while-setup-by-non-ro.patch +Patch9269: 0269-xdp-skip-checksum-temporarily-due-to-kernel-cannot-t.patch %description %{name} is a high performance user-mode stack. @@ -326,6 +327,9 @@ install -Dpm 0640 %{_builddir}/%{name}-%{version}/src/ltran/ltran.conf %{b %config(noreplace) %{conf_path}/ltran.conf %changelog +* Thu Oct 10 2024 yinbin6 - 1.0.2-68 +- xdp: skip checksum temporarily due to kernel cannot transfer offloads + * Wed Oct 09 2024 yinbin6 - 1.0.2-67 - bugfix: fix gazelle init failed while setup by non-root user - rpc: fix rpc_sync_call spinlock block when msg be recalled