sync enable-UDP-CKSUM-in-gazelle

(cherry picked from commit a02db14a02a694717d7b73914667e7bfcb24f868)
This commit is contained in:
kircher 2023-06-25 15:15:16 +08:00 committed by openeuler-sync-bot
parent b1a311957b
commit e8e609cb74
5 changed files with 277 additions and 2 deletions

View File

@ -0,0 +1,45 @@
From 734f786e959fc536a41f304bbffe9fa9c269b874 Mon Sep 17 00:00:00 2001
From: jiangheng <jiangheng14@huawei.com>
Date: Mon, 19 Jun 2023 15:51:50 +0800
Subject: [PATCH] fix null pointer of sock in udp_recvfrom
---
src/lstack/api/lstack_wrap.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/src/lstack/api/lstack_wrap.c b/src/lstack/api/lstack_wrap.c
index 096fcf7..6ee0512 100644
--- a/src/lstack/api/lstack_wrap.c
+++ b/src/lstack/api/lstack_wrap.c
@@ -552,7 +552,7 @@ static inline ssize_t udp_recvfrom(struct lwip_sock *sock, int32_t sockfd, void
{
int32_t ret;
- do {
+ while (1) {
ret = read_stack_data(sockfd, buf, len, flags, addr, addrlen);
if (ret > 0) {
return ret;
@@ -561,9 +561,16 @@ static inline ssize_t udp_recvfrom(struct lwip_sock *sock, int32_t sockfd, void
return -1;
}
sock = sock->listen_next;
- sockfd = sock->conn->socket;
- } while (sock != NULL);
- GAZELLE_RETURN(EAGAIN);
+ if (sock != NULL && sock->conn != NULL) {
+ sockfd = sock->conn->socket;
+ } else {
+ if (sock == NULL) {
+ GAZELLE_RETURN(EAGAIN);
+ } else {
+ GAZELLE_RETURN(ENOTCONN);
+ }
+ }
+ }
}
static inline ssize_t tcp_recvfrom(struct lwip_sock *sock, int32_t sockfd, void *buf, size_t len, int32_t flags,
--
2.33.0

View File

@ -0,0 +1,28 @@
From 9f3faa569a3181585da5650dec66136f89591348 Mon Sep 17 00:00:00 2001
From: jiangheng <jiangheng14@huawei.com>
Date: Tue, 20 Jun 2023 09:20:43 +0800
Subject: [PATCH] skip gro when tcp/ip checksum offloads disable
---
src/lstack/netif/lstack_vdev.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/lstack/netif/lstack_vdev.c b/src/lstack/netif/lstack_vdev.c
index 5ea1f31..4307f24 100644
--- a/src/lstack/netif/lstack_vdev.c
+++ b/src/lstack/netif/lstack_vdev.c
@@ -82,6 +82,11 @@ 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) {
+ return pkt_num;
+ }
+
for (uint32_t i = 0; i < pkt_num; i++) {
struct rte_ether_hdr *ethh = rte_pktmbuf_mtod(pkts[i], struct rte_ether_hdr *);
if (unlikely(RTE_BE16(RTE_ETHER_TYPE_IPV4) != ethh->ether_type)) {
--
2.33.0

View File

@ -0,0 +1,128 @@
From 1c771f0af29dad27d29af371b13ab3013efc44c3 Mon Sep 17 00:00:00 2001
From: Lemmy Huang <huangliming5@huawei.com>
Date: Tue, 20 Jun 2023 17:30:34 +0800
Subject: [PATCH] lstack: cfg add app_exclude_cpus
Signed-off-by: Lemmy Huang <huangliming5@huawei.com>
---
src/lstack/core/lstack_cfg.c | 55 ++++++++++++++++---
src/lstack/include/lstack_cfg.h | 2 +
2 files changed, 49 insertions(+), 8 deletions(-)
diff --git a/src/lstack/core/lstack_cfg.c b/src/lstack/core/lstack_cfg.c
index daf49ea..8a627d5 100644
--- a/src/lstack/core/lstack_cfg.c
+++ b/src/lstack/core/lstack_cfg.c
@@ -47,6 +47,8 @@ static config_t g_config;
static int32_t parse_host_addr(void);
static int32_t parse_low_power_mode(void);
static int32_t parse_stack_cpu_number(void);
+static int32_t parse_app_bind_numa(void);
+static int32_t parse_app_exclude_cpus(void);
static int32_t parse_use_ltran(void);
static int32_t parse_mask_addr(void);
static int32_t parse_devices(void);
@@ -54,7 +56,6 @@ static int32_t parse_dpdk_args(void);
static int32_t parse_gateway_addr(void);
static int32_t parse_kni_switch(void);
static int32_t parse_listen_shadow(void);
-static int32_t parse_app_bind_numa(void);
static int32_t parse_main_thread_affinity(void);
static int32_t parse_unix_prefix(void);
static int32_t parse_read_connect_number(void);
@@ -111,6 +112,7 @@ static struct config_vector_t g_config_tbl[] = {
{ "kni_switch", parse_kni_switch },
{ "listen_shadow", parse_listen_shadow },
{ "app_bind_numa", parse_app_bind_numa },
+ { "app_exclude_cpus", parse_app_exclude_cpus },
{ "main_thread_affinity", parse_main_thread_affinity },
{ "unix_prefix", parse_unix_prefix },
{ "tcp_conn_count", parse_tcp_conn_count },
@@ -391,6 +393,46 @@ static int32_t parse_stack_cpu_number(void)
return 0;
}
+static int32_t parse_app_bind_numa(void)
+{
+ int32_t ret;
+ PARSE_ARG(g_config_params.app_bind_numa, "app_bind_numa", 1, 0, 1, ret);
+ return ret;
+}
+
+static int32_t parse_app_exclude_cpus(void)
+{
+ const config_setting_t *num_cpus = NULL;
+ const char *args = NULL;
+ char *tmp_arg;
+ int32_t cnt;
+
+ g_config_params.app_exclude_num_cpu = 0;
+ if (!g_config_params.app_bind_numa) {
+ return 0;
+ }
+
+ num_cpus = config_lookup(&g_config, "app_exclude_cpus");
+ if (num_cpus == NULL) {
+ return 0;
+ }
+
+ args = config_setting_get_string(num_cpus);
+ if (args == NULL) {
+ return -EINVAL;
+ }
+
+ tmp_arg = strdup(args);
+ cnt = separate_str_to_array(tmp_arg, g_config_params.app_exclude_cpus, CFG_MAX_CPUS, CFG_MAX_CPUS);
+ free(tmp_arg);
+ if (cnt <= 0 || cnt > CFG_MAX_CPUS) {
+ return -EINVAL;
+ }
+
+ g_config_params.app_exclude_num_cpu = cnt;
+ return 0;
+}
+
static int32_t numa_to_cpusnum(unsigned socket_id, uint32_t *cpulist, int32_t num)
{
char path[PATH_MAX] = {0};
@@ -458,6 +500,10 @@ int32_t init_stack_numa_cpuset(struct protocol_stack *stack)
}
}
+ for (int32_t idx = 0; idx < cfg->app_exclude_num_cpu; ++idx) {
+ CPU_SET(cfg->app_exclude_cpus[idx], &stack_cpuset);
+ }
+
ret = stack_idle_cpuset(stack, &stack_cpuset);
if (ret < 0) {
LSTACK_LOG(ERR, LSTACK, "thread_get_cpuset stack(%u) failed\n", stack->tid);
@@ -836,13 +882,6 @@ static int32_t parse_listen_shadow(void)
return ret;
}
-static int32_t parse_app_bind_numa(void)
-{
- int32_t ret;
- PARSE_ARG(g_config_params.app_bind_numa, "app_bind_numa", 1, 0, 1, ret);
- return ret;
-}
-
static int32_t parse_main_thread_affinity(void)
{
int32_t ret;
diff --git a/src/lstack/include/lstack_cfg.h b/src/lstack/include/lstack_cfg.h
index b000519..6da18cf 100644
--- a/src/lstack/include/lstack_cfg.h
+++ b/src/lstack/include/lstack_cfg.h
@@ -68,6 +68,8 @@ struct cfg_params {
uint32_t cpus[CFG_MAX_CPUS];
uint32_t send_cpus[CFG_MAX_CPUS];
uint32_t recv_cpus[CFG_MAX_CPUS];
+ uint16_t app_exclude_num_cpu;
+ uint32_t app_exclude_cpus[CFG_MAX_CPUS];
uint8_t num_ports;
uint16_t ports[CFG_MAX_PORTS];
char log_file[PATH_MAX];
--
2.33.0

View File

@ -0,0 +1,64 @@
From 266f148b8080e9896fba1bdbaebb5e2dbfd44f07 Mon Sep 17 00:00:00 2001
From: kircher <majun65@huawei.com>
Date: Wed, 21 Jun 2023 15:03:47 +0800
Subject: [PATCH] enable UDP CKSUM in gazelle
---
src/common/dpdk_common.c | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/src/common/dpdk_common.c b/src/common/dpdk_common.c
index 23c96d6..52a163f 100644
--- a/src/common/dpdk_common.c
+++ b/src/common/dpdk_common.c
@@ -92,11 +92,18 @@ void eth_params_checksum(struct rte_eth_conf *conf, struct rte_eth_dev_info *dev
COMMON_INFO("DEV_RX_OFFLOAD_IPV4_CKSUM\n");
}
+ // rx tcp
if (rx_ol_capa & DEV_RX_OFFLOAD_TCP_CKSUM) {
rx_ol |= DEV_RX_OFFLOAD_TCP_CKSUM;
COMMON_INFO("DEV_RX_OFFLOAD_TCP_CKSUM\n");
}
+ // rx udp
+ if (rx_ol_capa & DEV_RX_OFFLOAD_UDP_CKSUM) {
+ rx_ol |= DEV_RX_OFFLOAD_UDP_CKSUM;
+ COMMON_INFO("DEV_RX_OFFLOAD_UDP_CKSUM\n");
+ }
+
// tx ip
if (tx_ol_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) {
tx_ol |= DEV_TX_OFFLOAD_IPV4_CKSUM;
@@ -109,15 +116,26 @@ void eth_params_checksum(struct rte_eth_conf *conf, struct rte_eth_dev_info *dev
COMMON_INFO("DEV_TX_OFFLOAD_TCP_CKSUM\n");
}
+ // tx udp
+ if (tx_ol_capa & DEV_TX_OFFLOAD_UDP_CKSUM) {
+ tx_ol |= DEV_TX_OFFLOAD_UDP_CKSUM;
+ COMMON_INFO("DEV_TX_OFFLOAD_UDP_CKSUM\n");
+ }
+
+ // tx tso
if (tx_ol_capa & DEV_TX_OFFLOAD_TCP_TSO) {
tx_ol |= (DEV_TX_OFFLOAD_TCP_TSO | DEV_TX_OFFLOAD_MULTI_SEGS);
COMMON_INFO("DEV_TX_OFFLOAD_TCP_TSO\n");
}
- if (!(rx_ol & DEV_RX_OFFLOAD_TCP_CKSUM) || !(rx_ol & DEV_RX_OFFLOAD_IPV4_CKSUM)) {
+ if (!(rx_ol & DEV_RX_OFFLOAD_UDP_CKSUM) ||
+ !(rx_ol & DEV_RX_OFFLOAD_TCP_CKSUM) ||
+ !(rx_ol & DEV_RX_OFFLOAD_IPV4_CKSUM)) {
rx_ol = 0;
}
- if (!(tx_ol & DEV_TX_OFFLOAD_TCP_CKSUM) || !(tx_ol & DEV_TX_OFFLOAD_IPV4_CKSUM)) {
+ if (!(tx_ol & DEV_TX_OFFLOAD_UDP_CKSUM) ||
+ !(tx_ol & DEV_TX_OFFLOAD_TCP_CKSUM) ||
+ !(tx_ol & DEV_TX_OFFLOAD_IPV4_CKSUM)) {
tx_ol = 0;
}
--
2.33.0

View File

@ -2,7 +2,7 @@
Name: gazelle
Version: 1.0.1
Release: 66
Release: 67
Summary: gazelle is a high performance user-mode stack
License: MulanPSL-2.0
URL: https://gitee.com/openeuler/gazelle
@ -268,6 +268,10 @@ Patch9250: 0250-adapt-to-dpdk-19.11-and-dpdk-21.11.patch
Patch9251: 0251-change-send_ring_size-32-in-lstack-conf.patch
Patch9252: 0252-add-use_sockmap-in-cfg-to-distinguish-whether-to-use.patch
Patch9253: 0253-add-multicast-enable-in-dpdk_ethdev_init.patch
Patch9254: 0254-fix-null-pointer-of-sock-in-udp_recvfrom.patch
Patch9255: 0255-skip-gro-when-tcp-ip-checksum-offloads-disable.patch
Patch9256: 0256-lstack-cfg-add-app_exclude_cpus.patch
Patch9257: 0257-enable-UDP-CKSUM-in-gazelle.patch
%description
%{name} is a high performance user-mode stack.
@ -309,6 +313,12 @@ install -Dpm 0640 %{_builddir}/%{name}-%{version}/src/ltran/ltran.conf %{b
%config(noreplace) %{conf_path}/ltran.conf
%changelog
* Sun Jun 25 2023 kircher <majun65@huawei.com> - 1.0.1-67
- enable UDP CKSUM in gazelle
- lstack: cfg add app_exclude_cpus
- skip gro when tcp/ip checksum offloads disable
- fix null pointer of sock in udp_recvfrom
* Mon Jun 19 2023 jiangheng12 <jiangheng14@huawei.com> - 1.0.1-66
- add multicast enable in dpdk_ethdev_init
- add use_sockmap in cfg to distinguish whether to use dpdk ring communication between processes
@ -382,7 +392,7 @@ install -Dpm 0640 %{_builddir}/%{name}-%{version}/src/ltran/ltran.conf %{b
* Thu Apr 20 2023 sunsuwan <sunsuwan3@huawei.com> - 1.0.1-55
- sepeate_string_to array add error args handle
* Thu Apr 20 UTC wu-changsheng <wuchangsheng2@huawei.com> - 1.0.1-54
* Thu Apr 20 2023 wu-changsheng <wuchangsheng2@huawei.com> - 1.0.1-54
- waiting when primary process not start already
- gazelle send/recv thread bind numa