98 lines
3.8 KiB
Diff
98 lines
3.8 KiB
Diff
From 77f34bd4406093dd47ec1fd60332ac5fd0f685a3 Mon Sep 17 00:00:00 2001
|
|
From: jiangheng <jiangheng14@huawei.com>
|
|
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
|
|
|