1 Star 0 Fork 32

修一/gazelle_1

forked from src-openEuler/gazelle 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0029-fix-code-check.patch 8.25 KB
一键复制 编辑 原始数据 按行查看 历史
jinag12 提交于 2022-03-16 22:23 . fix gazelle test issue
From ce1cdc5e656596b1b70171481a8ce5d523c0b20f Mon Sep 17 00:00:00 2001
From: jiangheng <jiangheng12@huawei.com>
Date: Wed, 16 Mar 2022 17:30:25 +0800
Subject: [PATCH 29/34] fix code check
---
src/common/dpdk_common.h | 1 -
src/lstack/core/lstack_cfg.c | 30 ++++++------------------------
src/lstack/core/lstack_dpdk.c | 5 +++--
src/lstack/core/lstack_lwip.c | 3 +--
src/lstack/core/lstack_protocol_stack.c | 4 ++--
src/lstack/netif/lstack_ethdev.c | 4 ++--
src/lstack/netif/lstack_vdev.c | 2 +-
src/ltran/ltran_dfx.c | 4 ++--
src/ltran/ltran_forward.c | 1 +
9 files changed, 18 insertions(+), 36 deletions(-)
diff --git a/src/common/dpdk_common.h b/src/common/dpdk_common.h
index 6137bcb..595e85f 100644
--- a/src/common/dpdk_common.h
+++ b/src/common/dpdk_common.h
@@ -40,7 +40,6 @@ static __rte_always_inline void copy_mbuf(struct rte_mbuf *dst, struct rte_mbuf
uint8_t *dst_data = rte_pktmbuf_mtod(dst, void*);
uint8_t *src_data = rte_pktmbuf_mtod(src, void*);
-
rte_memcpy(dst_data, src_data, data_len);
// copy private date.
diff --git a/src/lstack/core/lstack_cfg.c b/src/lstack/core/lstack_cfg.c
index ca25b58..53712a8 100644
--- a/src/lstack/core/lstack_cfg.c
+++ b/src/lstack/core/lstack_cfg.c
@@ -269,25 +269,7 @@ static int32_t numa_to_cpusnum(unsigned socket_id, uint32_t *cpulist, int32_t nu
return -1;
}
- int32_t count = 0;
- char *elem = strtok(strbuf, "-");
- while (elem && count < num) {
- while (elem && isspace(*elem)) {
- elem++;
- }
- if (elem == NULL) {
- LSTACK_LOG(ERR, LSTACK, "parse %s failed\n", path);
- return -1;
- }
- cpulist[count++] = (uint32_t)strtol(elem, NULL, 10); // 10 : decimal
-
- if (count % 2 == 0) { // 2 : even
- elem = strtok(NULL, "-");
- } else {
- elem = strtok(NULL, ",");
- }
- }
-
+ int32_t count = separate_str_to_array(strbuf, cpulist, num);
return count;
}
@@ -644,8 +626,6 @@ static int32_t parse_weakup_cpu_number(void)
const config_setting_t *cfg_args = NULL;
const char *args = NULL;
- int32_t ret;
-
g_config_params.num_wakeup = 0;
cfg_args = config_lookup(&g_config, "num_wakeup");
@@ -658,11 +638,13 @@ static int32_t parse_weakup_cpu_number(void)
return 0;
}
- ret = turn_str_to_array((char *)args, g_config_params.weakup, CFG_MAX_CPUS);
- if (ret <= 0) {
+ char *tmp_arg = strdup(args);
+ int32_t cnt = separate_str_to_array(tmp_arg, g_config_params.weakup, CFG_MAX_CPUS);
+ free(tmp_arg);
+ if (cnt <= 0 || cnt > CFG_MAX_CPUS) {
return -EINVAL;
}
- g_config_params.num_wakeup = (uint16_t)ret;
+ g_config_params.num_wakeup = cnt;
return 0;
}
diff --git a/src/lstack/core/lstack_dpdk.c b/src/lstack/core/lstack_dpdk.c
index fb0e988..430c6e5 100644
--- a/src/lstack/core/lstack_dpdk.c
+++ b/src/lstack/core/lstack_dpdk.c
@@ -223,6 +223,7 @@ int32_t create_shared_ring(struct protocol_stack *stack)
if (stack->send_idle_ring == NULL) {
return -1;
}
+ stack->in_replenish = 0;
if (use_ltran()) {
stack->rx_ring = create_ring("RING_RX", VDEV_RX_QUEUE_SZ, RING_F_SP_ENQ | RING_F_SC_DEQ, stack->queue_id);
@@ -255,7 +256,7 @@ int32_t fill_mbuf_to_ring(struct rte_mempool *mempool, struct rte_ring *ring, ui
while (remain > 0) {
batch = LWIP_MIN(remain, FREE_RX_QUEUE_SZ);
- ret = gazelle_alloc_pktmbuf(mempool, free_buf, batch);
+ ret = gazelle_alloc_pktmbuf(mempool, free_buf, batch);
if (ret != 0) {
LSTACK_LOG(ERR, LSTACK, "cannot alloc mbuf for ring, count: %d ret=%d\n", (int32_t)batch, ret);
return -1;
@@ -339,7 +340,7 @@ static int eth_params_checksum(struct rte_eth_conf *conf, struct rte_eth_dev_inf
if (rx_ol_capa & DEV_RX_OFFLOAD_IPV4_CKSUM) {
#if CHECKSUM_CHECK_IP_HW
rx_ol |= DEV_RX_OFFLOAD_IPV4_CKSUM;
- LSTACK_LOG(INFO, LSTACK, "DEV_RX_OFFLOAD_IPV4_CKSUM\n");
+ LSTACK_LOG(INFO, LSTACK, "DEV_RX_OFFLOAD_IPV4_CKSUM\n");
#endif
}
diff --git a/src/lstack/core/lstack_lwip.c b/src/lstack/core/lstack_lwip.c
index d35a217..636840f 100644
--- a/src/lstack/core/lstack_lwip.c
+++ b/src/lstack/core/lstack_lwip.c
@@ -184,7 +184,6 @@ int32_t gazelle_alloc_pktmbuf(struct rte_mempool *pool, struct rte_mbuf **mbufs,
return ret;
}
-
for (uint32_t i = 0; i < num; i++) {
pbuf_custom = mbuf_to_pbuf(mbufs[i]);
pbuf_custom->custom_free_function = gazelle_free_pbuf;
@@ -216,7 +215,7 @@ void stack_replenish_send_idlembuf(struct protocol_stack *stack)
uint32_t replenish_cnt = rte_ring_free_count(stack->send_idle_ring);
for (uint32_t i = 0; i < replenish_cnt; i++) {
- struct pbuf *pbuf = lwip_alloc_pbuf(PBUF_TRANSPORT, MAX_PACKET_SZ - PBUF_TRANSPORT, PBUF_RAM);
+ struct pbuf *pbuf = lwip_alloc_pbuf(PBUF_TRANSPORT, MAX_PACKET_SZ - PBUF_TRANSPORT, PBUF_RAM);
if (pbuf == NULL) {
break;
}
diff --git a/src/lstack/core/lstack_protocol_stack.c b/src/lstack/core/lstack_protocol_stack.c
index 4ba851a..e297f7e 100644
--- a/src/lstack/core/lstack_protocol_stack.c
+++ b/src/lstack/core/lstack_protocol_stack.c
@@ -686,8 +686,8 @@ void stack_broadcast_arp(struct rte_mbuf *mbuf, struct protocol_stack *cur_stack
if (cur_stack == stack) {
continue;
}
-
- ret = gazelle_alloc_pktmbuf(stack->rx_pktmbuf_pool, &mbuf_copy, 1);
+
+ ret = gazelle_alloc_pktmbuf(stack->rx_pktmbuf_pool, &mbuf_copy, 1);
if (ret != 0) {
return;
}
diff --git a/src/lstack/netif/lstack_ethdev.c b/src/lstack/netif/lstack_ethdev.c
index c428bca..9cb9cb0 100644
--- a/src/lstack/netif/lstack_ethdev.c
+++ b/src/lstack/netif/lstack_ethdev.c
@@ -45,7 +45,7 @@ void eth_dev_recv(struct rte_mbuf *mbuf)
len = (uint16_t)rte_pktmbuf_pkt_len(m);
payload = rte_pktmbuf_mtod(m, void *);
pc = mbuf_to_pbuf(m);
- pc->custom_free_function = gazelle_free_pbuf;
+ pc->custom_free_function = gazelle_free_pbuf;
next = pbuf_alloced_custom(PBUF_RAW, (uint16_t)len, PBUF_RAM, pc, payload, (uint16_t)len);
if (next == NULL) {
stack->stats.rx_allocmbuf_fail++;
@@ -139,7 +139,7 @@ static err_t eth_dev_output(struct netif *netif, struct pbuf *pbuf)
stack->stats.tx += sent_pkts;
if (sent_pkts < 1) {
stack->stats.tx_drop++;
- rte_pktmbuf_free(mbuf);
+ rte_pktmbuf_free(mbuf);
return ERR_MEM;
}
diff --git a/src/lstack/netif/lstack_vdev.c b/src/lstack/netif/lstack_vdev.c
index a2f89fa..57d3bce 100644
--- a/src/lstack/netif/lstack_vdev.c
+++ b/src/lstack/netif/lstack_vdev.c
@@ -47,7 +47,7 @@ static uint32_t ltran_rx_poll(struct protocol_stack *stack, struct rte_mbuf **pk
stack->rx_ring_used += rcvd_pkts;
if (unlikely(stack->rx_ring_used >= USED_RX_PKTS_WATERMARK)) {
uint32_t free_cnt = LWIP_MIN(stack->rx_ring_used, DPDK_PKT_BURST_SIZE);
- int32_t ret = gazelle_alloc_pktmbuf(stack->rx_pktmbuf_pool, (struct rte_mbuf **)free_buf, free_cnt);
+ int32_t ret = gazelle_alloc_pktmbuf(stack->rx_pktmbuf_pool, (struct rte_mbuf **)free_buf, free_cnt);
if (likely(ret == 0)) {
nr_pkts = rte_ring_en_enqueue_bulk(stack->rx_ring, (void **)free_buf, free_cnt);
stack->rx_ring_used -= nr_pkts;
diff --git a/src/ltran/ltran_dfx.c b/src/ltran/ltran_dfx.c
index 3baa017..8db5791 100644
--- a/src/ltran/ltran_dfx.c
+++ b/src/ltran/ltran_dfx.c
@@ -111,8 +111,8 @@ static pid_t ltran_process_exist(void)
char line[LINE];
FILE *cmd = popen("pidof ltran", "r");
- if(fgets(line, LINE, cmd) == NULL) {
- return 0;
+ if (fgets(line, LINE, cmd) == NULL) {
+ return 0;
}
pid_t pid = strtoul(line, NULL, BASE_DEC_SCALE);
diff --git a/src/ltran/ltran_forward.c b/src/ltran/ltran_forward.c
index 9d1188e..b264ad3 100644
--- a/src/ltran/ltran_forward.c
+++ b/src/ltran/ltran_forward.c
@@ -82,6 +82,7 @@ static __rte_always_inline void flush_rx_mbuf(struct gazelle_stack *stack, struc
calculate_ltran_latency(stack, src);
}
rte_pktmbuf_free(src);
+ src = NULL;
}
static __rte_always_inline void backup_bufs_enque_rx_ring(struct gazelle_stack *stack)
--
1.8.3.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/slxiu/gazelle_1.git
git@gitee.com:slxiu/gazelle_1.git
slxiu
gazelle_1
gazelle_1
master

搜索帮助