652 lines
22 KiB
Diff
652 lines
22 KiB
Diff
From 2b1e966ac4542bd78d3de05111d4539843cb2fa2 Mon Sep 17 00:00:00 2001
|
|
From: Lemmy Huang <huangliming5@huawei.com>
|
|
Date: Mon, 29 May 2023 15:51:22 +0800
|
|
Subject: [PATCH] cleancode: refactor sys_now and lwip_ioctl
|
|
|
|
Signed-off-by: Lemmy Huang <huangliming5@huawei.com>
|
|
---
|
|
src/common/dpdk_common.c | 11 +++++++
|
|
src/common/dpdk_common.h | 1 +
|
|
src/common/gazelle_dfx_msg.h | 8 ++++-
|
|
src/lstack/api/lstack_wrap.c | 37 +++++++++++-------------
|
|
src/lstack/core/lstack_cfg.c | 1 -
|
|
src/lstack/core/lstack_control_plane.c | 21 ++++++++------
|
|
src/lstack/core/lstack_dpdk.c | 9 +++---
|
|
src/lstack/core/lstack_init.c | 2 --
|
|
src/lstack/core/lstack_lwip.c | 14 ++++-----
|
|
src/lstack/core/lstack_protocol_stack.c | 14 ++++-----
|
|
src/lstack/core/lstack_stack_stat.c | 23 ++-------------
|
|
src/lstack/include/lstack_stack_stat.h | 1 -
|
|
src/lstack/include/lstack_thread_rpc.h | 1 -
|
|
src/lstack/include/posix/lstack_socket.h | 2 +-
|
|
src/lstack/netif/lstack_ethdev.c | 4 +--
|
|
src/ltran/ltran_forward.c | 10 +++----
|
|
src/ltran/ltran_stat.c | 2 +-
|
|
src/ltran/ltran_stat.h | 6 ----
|
|
src/ltran/ltran_timer.c | 17 -----------
|
|
src/ltran/ltran_timer.h | 2 --
|
|
test/unitest/stub.c | 2 +-
|
|
21 files changed, 75 insertions(+), 113 deletions(-)
|
|
|
|
diff --git a/src/common/dpdk_common.c b/src/common/dpdk_common.c
|
|
index 23c96d6..dcfe802 100644
|
|
--- a/src/common/dpdk_common.c
|
|
+++ b/src/common/dpdk_common.c
|
|
@@ -10,6 +10,7 @@
|
|
* See the Mulan PSL v2 for more details.
|
|
*/
|
|
|
|
+#include <rte_cycles.h>
|
|
#include <rte_kni.h>
|
|
#include <rte_bus_pci.h>
|
|
#include <rte_ethdev.h>
|
|
@@ -34,6 +35,16 @@
|
|
#define COMMON_INFO(fmt, ...) LSTACK_LOG(INFO, LSTACK, fmt, ##__VA_ARGS__)
|
|
#endif
|
|
|
|
+uint64_t get_now_us(void)
|
|
+{
|
|
+ static uint64_t g_cycles_per_us = 0;
|
|
+ if (unlikely(g_cycles_per_us == 0)) {
|
|
+ g_cycles_per_us = (rte_get_tsc_hz() + US_PER_S - 1) / US_PER_S;;
|
|
+ }
|
|
+
|
|
+ return (rte_rdtsc() / g_cycles_per_us);
|
|
+}
|
|
+
|
|
struct rte_kni *g_pkni = NULL;
|
|
static volatile bool g_kni_started = false;
|
|
|
|
diff --git a/src/common/dpdk_common.h b/src/common/dpdk_common.h
|
|
index 2f0e8d1..6ae0f7b 100644
|
|
--- a/src/common/dpdk_common.h
|
|
+++ b/src/common/dpdk_common.h
|
|
@@ -94,6 +94,7 @@ static __rte_always_inline void time_stamp_into_mbuf(uint32_t rx_count, struct r
|
|
}
|
|
}
|
|
|
|
+uint64_t get_now_us(void);
|
|
bool get_kni_started(void);
|
|
struct rte_kni* get_gazelle_kni(void);
|
|
int32_t dpdk_kni_init(uint16_t port, struct rte_mempool *pool);
|
|
diff --git a/src/common/gazelle_dfx_msg.h b/src/common/gazelle_dfx_msg.h
|
|
index a89b82c..69896a6 100644
|
|
--- a/src/common/gazelle_dfx_msg.h
|
|
+++ b/src/common/gazelle_dfx_msg.h
|
|
@@ -53,6 +53,12 @@ enum GAZELLE_LATENCY_TYPE {
|
|
GAZELLE_LATENCY_READ,
|
|
};
|
|
|
|
+enum GAZELLE_TCP_LIST_STATE {
|
|
+ GAZELLE_ACTIVE_LIST,
|
|
+ GAZELLE_LISTEN_LIST,
|
|
+ GAZELLE_TIME_WAIT_LIST,
|
|
+};
|
|
+
|
|
struct gazelle_stack_stat {
|
|
uint64_t wakeup_events;
|
|
uint64_t write_lwip_cnt;
|
|
@@ -146,7 +152,6 @@ struct gazelle_stat_lstack_snmp {
|
|
uint32_t icmp_out_echo_reps;
|
|
};
|
|
|
|
-/* same as define in lwip/tcp.h - struct tcp_pcb_dp */
|
|
struct gazelle_stat_lstack_conn_info {
|
|
uint32_t state;
|
|
uint32_t rip;
|
|
@@ -158,6 +163,7 @@ struct gazelle_stat_lstack_conn_info {
|
|
uint32_t send_ring_cnt;
|
|
uint32_t recv_ring_cnt;
|
|
uint32_t tcp_sub_state;
|
|
+
|
|
uint32_t cwn;
|
|
uint32_t rcv_wnd;
|
|
uint32_t snd_wnd;
|
|
diff --git a/src/lstack/api/lstack_wrap.c b/src/lstack/api/lstack_wrap.c
|
|
index e8a3b75..776646f 100644
|
|
--- a/src/lstack/api/lstack_wrap.c
|
|
+++ b/src/lstack/api/lstack_wrap.c
|
|
@@ -623,23 +623,20 @@ static int32_t do_sigaction(int32_t signum, const struct sigaction *act, struct
|
|
return lstack_sigaction(signum, act, oldact);
|
|
}
|
|
|
|
-#define WRAP_VA_PARAM(_fd, _cmd, _lwip_fcntl, _fcntl_fn) \
|
|
+#define POSIX_VA_PARAM(fd, cmd, type, lwip_fn, kernel_fn) \
|
|
do { \
|
|
- unsigned long val; \
|
|
- va_list ap; \
|
|
- va_start(ap, _cmd); \
|
|
- val = va_arg(ap, typeof(val)); \
|
|
- va_end(ap); \
|
|
- struct lwip_sock *sock = NULL; \
|
|
- if (select_path(_fd, &sock) == PATH_KERNEL) \
|
|
- return _fcntl_fn(_fd, _cmd, val); \
|
|
- int32_t ret = _fcntl_fn(_fd, _cmd, val); \
|
|
- if (ret == -1) \
|
|
- return ret; \
|
|
- return _lwip_fcntl(_fd, _cmd, val); \
|
|
+ unsigned long __val; \
|
|
+ va_list __ap; \
|
|
+ va_start(__ap, cmd); \
|
|
+ __val = va_arg(__ap, typeof(__val)); \
|
|
+ va_end(__ap); \
|
|
+ \
|
|
+ int __ret = kernel_fn(fd, cmd, __val); \
|
|
+ if (__ret == -1 || select_path(fd, NULL) == PATH_KERNEL) \
|
|
+ return __ret; \
|
|
+ return lwip_fn(fd, cmd, (type)__val); \
|
|
} while (0)
|
|
|
|
-
|
|
/* --------------------------------------------------------
|
|
* ------- LD_PRELOAD mode replacement interface --------
|
|
* --------------------------------------------------------
|
|
@@ -662,15 +659,15 @@ int32_t epoll_wait(int32_t epfd, struct epoll_event* events, int32_t maxevents,
|
|
}
|
|
int32_t fcntl64(int32_t s, int32_t cmd, ...)
|
|
{
|
|
- WRAP_VA_PARAM(s, cmd, lwip_fcntl, posix_api->fcntl64_fn);
|
|
+ POSIX_VA_PARAM(s, cmd, int, lwip_fcntl, posix_api->fcntl64_fn);
|
|
}
|
|
int32_t fcntl(int32_t s, int32_t cmd, ...)
|
|
{
|
|
- WRAP_VA_PARAM(s, cmd, lwip_fcntl, posix_api->fcntl_fn);
|
|
+ POSIX_VA_PARAM(s, cmd, int, lwip_fcntl, posix_api->fcntl_fn);
|
|
}
|
|
int32_t ioctl(int32_t s, int32_t cmd, ...)
|
|
{
|
|
- WRAP_VA_PARAM(s, cmd, lwip_ioctl, posix_api->ioctl_fn);
|
|
+ POSIX_VA_PARAM(s, cmd, void*, lwip_ioctl, posix_api->ioctl_fn);
|
|
}
|
|
int32_t accept(int32_t s, struct sockaddr *addr, socklen_t *addrlen)
|
|
{
|
|
@@ -806,15 +803,15 @@ int32_t __wrap_epoll_wait(int32_t epfd, struct epoll_event* events, int32_t maxe
|
|
}
|
|
int32_t __wrap_fcntl64(int32_t s, int32_t cmd, ...)
|
|
{
|
|
- WRAP_VA_PARAM(s, cmd, lwip_fcntl, posix_api->fcntl64_fn);
|
|
+ POSIX_VA_PARAM(s, cmd, int, lwip_fcntl, posix_api->fcntl64_fn);
|
|
}
|
|
int32_t __wrap_fcntl(int32_t s, int32_t cmd, ...)
|
|
{
|
|
- WRAP_VA_PARAM(s, cmd, lwip_fcntl, posix_api->fcntl_fn);
|
|
+ POSIX_VA_PARAM(s, cmd, int, lwip_fcntl, posix_api->fcntl_fn);
|
|
}
|
|
int32_t __wrap_ioctl(int32_t s, int32_t cmd, ...)
|
|
{
|
|
- WRAP_VA_PARAM(s, cmd, lwip_ioctl, posix_api->ioctl_fn);
|
|
+ POSIX_VA_PARAM(s, cmd, void*, lwip_ioctl, posix_api->ioctl_fn);
|
|
}
|
|
|
|
int32_t __wrap_accept(int32_t s, struct sockaddr *addr, socklen_t *addrlen)
|
|
diff --git a/src/lstack/core/lstack_cfg.c b/src/lstack/core/lstack_cfg.c
|
|
index fa014e8..09e1b09 100644
|
|
--- a/src/lstack/core/lstack_cfg.c
|
|
+++ b/src/lstack/core/lstack_cfg.c
|
|
@@ -24,7 +24,6 @@
|
|
#include <sched.h>
|
|
|
|
#include <lwip/lwipsock.h>
|
|
-#include <lwip/gazelle_posix_api.h>
|
|
#include <lwip/inet.h>
|
|
|
|
#include "common/gazelle_reg_msg.h"
|
|
diff --git a/src/lstack/core/lstack_control_plane.c b/src/lstack/core/lstack_control_plane.c
|
|
index a26420e..c903952 100644
|
|
--- a/src/lstack/core/lstack_control_plane.c
|
|
+++ b/src/lstack/core/lstack_control_plane.c
|
|
@@ -18,11 +18,14 @@
|
|
#include <sys/socket.h>
|
|
#include <securec.h>
|
|
|
|
-#include <lwip/tcp.h>
|
|
+#include <rte_cycles.h>
|
|
#include <rte_eal.h>
|
|
#include <rte_errno.h>
|
|
+
|
|
+#include <lwip/tcp.h>
|
|
#include <lwip/gazelle_posix_api.h>
|
|
#include <lwip/gazelle_tcp_reg.h>
|
|
+#include <lwip/arch/sys_arch.h>
|
|
|
|
#include "lstack_cfg.h"
|
|
#include "lstack_dpdk.h"
|
|
@@ -344,7 +347,7 @@ static int32_t client_reg_proc_attach(__attribute__((__unused__)) bool is_reconn
|
|
return 0;
|
|
}
|
|
|
|
-static int32_t reg_conn(enum tcp_list_state table_state, enum reg_ring_type reg_type,
|
|
+static int32_t reg_conn(enum GAZELLE_TCP_LIST_STATE table_state, enum reg_ring_type reg_type,
|
|
const struct gazelle_stat_lstack_conn *conn)
|
|
{
|
|
struct gazelle_quintuple qtuple;
|
|
@@ -362,7 +365,7 @@ static int32_t reg_conn(enum tcp_list_state table_state, enum reg_ring_type reg_
|
|
qtuple.dst_ip = conn->conn_list[i].rip;
|
|
qtuple.dst_port = lwip_htons(conn->conn_list[i].r_port);
|
|
|
|
- if ((table_state == LISTEN_LIST) &&
|
|
+ if ((table_state == GAZELLE_LISTEN_LIST) &&
|
|
(!match_host_addr(qtuple.src_ip))) {
|
|
continue;
|
|
}
|
|
@@ -391,16 +394,16 @@ void thread_register_phase1(struct rpc_msg *msg)
|
|
}
|
|
|
|
struct gazelle_stat_lstack_conn *conn = (struct gazelle_stat_lstack_conn *)msg->args[MSG_ARG_0].p;
|
|
- ret = reg_conn(ACTIVE_LIST, REG_RING_TCP_CONNECT, conn);
|
|
+ ret = reg_conn(GAZELLE_ACTIVE_LIST, REG_RING_TCP_CONNECT, conn);
|
|
if (ret != 0) {
|
|
- LSTACK_LOG(ERR, LSTACK, "ACTIVE_LIST rereg conn fail ret=%d\n", ret);
|
|
+ LSTACK_LOG(ERR, LSTACK, "GAZELLE_ACTIVE_LIST rereg conn fail ret=%d\n", ret);
|
|
msg->result = ret;
|
|
return;
|
|
}
|
|
|
|
- ret = reg_conn(TIME_WAIT_LIST, REG_RING_TCP_CONNECT, conn);
|
|
+ ret = reg_conn(GAZELLE_TIME_WAIT_LIST, REG_RING_TCP_CONNECT, conn);
|
|
if (ret != 0) {
|
|
- LSTACK_LOG(ERR, LSTACK, "TIME_WAIT_LIST rereg conn fail ret=%d\n", ret);
|
|
+ LSTACK_LOG(ERR, LSTACK, "GAZELLE_TIME_WAIT_LIST rereg conn fail ret=%d\n", ret);
|
|
}
|
|
msg->result = ret;
|
|
}
|
|
@@ -409,9 +412,9 @@ void thread_register_phase2(struct rpc_msg *msg)
|
|
{
|
|
struct gazelle_stat_lstack_conn *conn = (struct gazelle_stat_lstack_conn *)msg->args[MSG_ARG_0].p;
|
|
|
|
- int32_t ret = reg_conn(LISTEN_LIST, REG_RING_TCP_LISTEN, conn);
|
|
+ int32_t ret = reg_conn(GAZELLE_LISTEN_LIST, REG_RING_TCP_LISTEN, conn);
|
|
if (ret != 0) {
|
|
- LSTACK_LOG(ERR, LSTACK, "LISTEN_LIST rereg conn fail ret=%d\n", ret);
|
|
+ LSTACK_LOG(ERR, LSTACK, "GAZELLE_LISTEN_LIST rereg conn fail ret=%d\n", ret);
|
|
}
|
|
|
|
msg->result = ret;
|
|
diff --git a/src/lstack/core/lstack_dpdk.c b/src/lstack/core/lstack_dpdk.c
|
|
index d927b60..f7d10b7 100644
|
|
--- a/src/lstack/core/lstack_dpdk.c
|
|
+++ b/src/lstack/core/lstack_dpdk.c
|
|
@@ -29,15 +29,14 @@
|
|
#include <rte_kni.h>
|
|
#include <rte_pdump.h>
|
|
#include <rte_thash.h>
|
|
-#include <lwip/gazelle_posix_api.h>
|
|
-#include <lwipopts.h>
|
|
-#include <lwip/pbuf.h>
|
|
-#include <lwip/gazelle_tcp_reg.h>
|
|
-#include <lwip/priv/tcp_priv.h>
|
|
#include <rte_eth_bond_8023ad.h>
|
|
#include <rte_eth_bond.h>
|
|
#include <rte_ethdev.h>
|
|
|
|
+#include <lwip/pbuf.h>
|
|
+#include <lwip/gazelle_tcp_reg.h>
|
|
+#include <lwip/priv/tcp_priv.h>
|
|
+
|
|
#include "lstack_log.h"
|
|
#include "common/dpdk_common.h"
|
|
#include "lstack_lockless_queue.h"
|
|
diff --git a/src/lstack/core/lstack_init.c b/src/lstack/core/lstack_init.c
|
|
index 541480d..7f484f4 100644
|
|
--- a/src/lstack/core/lstack_init.c
|
|
+++ b/src/lstack/core/lstack_init.c
|
|
@@ -29,8 +29,6 @@
|
|
#include <lwip/def.h>
|
|
#include <lwip/init.h>
|
|
#include <lwip/lwipsock.h>
|
|
-#include <lwip/tcpip.h>
|
|
-#include <lwip/memp_def.h>
|
|
#include <lwip/lwipopts.h>
|
|
#include <lwip/gazelle_posix_api.h>
|
|
|
|
diff --git a/src/lstack/core/lstack_lwip.c b/src/lstack/core/lstack_lwip.c
|
|
index 08836da..805ac82 100644
|
|
--- a/src/lstack/core/lstack_lwip.c
|
|
+++ b/src/lstack/core/lstack_lwip.c
|
|
@@ -12,19 +12,19 @@
|
|
|
|
#include <sys/types.h>
|
|
#include <stdatomic.h>
|
|
+#include <securec.h>
|
|
+#include <rte_errno.h>
|
|
+#include <rte_malloc.h>
|
|
+
|
|
#include <lwip/sockets.h>
|
|
#include <lwip/tcp.h>
|
|
#include <lwip/udp.h>
|
|
#include <lwipsock.h>
|
|
-#include <arch/sys_arch.h>
|
|
#include <lwip/pbuf.h>
|
|
#include <lwip/priv/tcp_priv.h>
|
|
#include <lwip/gazelle_posix_api.h>
|
|
#include <lwip/api.h>
|
|
#include <lwip/tcp.h>
|
|
-#include <securec.h>
|
|
-#include <rte_errno.h>
|
|
-#include <rte_malloc.h>
|
|
|
|
#include "common/gazelle_base_func.h"
|
|
#include "lstack_ethdev.h"
|
|
@@ -1316,20 +1316,20 @@ void get_lwip_conntable(struct rpc_msg *msg)
|
|
}
|
|
|
|
for (pcb = tcp_active_pcbs; pcb != NULL && conn_num < max_num; pcb = pcb->next) {
|
|
- conn[conn_num].state = ACTIVE_LIST;
|
|
+ conn[conn_num].state = GAZELLE_ACTIVE_LIST;
|
|
copy_pcb_to_conn(conn + conn_num, pcb);
|
|
conn_num++;
|
|
}
|
|
|
|
for (pcb = tcp_tw_pcbs; pcb != NULL && conn_num < max_num; pcb = pcb->next) {
|
|
- conn[conn_num].state = TIME_WAIT_LIST;
|
|
+ conn[conn_num].state = GAZELLE_TIME_WAIT_LIST;
|
|
copy_pcb_to_conn(conn + conn_num, pcb);
|
|
conn_num++;
|
|
}
|
|
|
|
for (struct tcp_pcb_listen *pcbl = tcp_listen_pcbs.listen_pcbs; pcbl != NULL && conn_num < max_num;
|
|
pcbl = pcbl->next) {
|
|
- conn[conn_num].state = LISTEN_LIST;
|
|
+ conn[conn_num].state = GAZELLE_LISTEN_LIST;
|
|
conn[conn_num].lip = pcbl->local_ip.addr;
|
|
conn[conn_num].l_port = pcbl->local_port;
|
|
conn[conn_num].tcp_sub_state = pcbl->state;
|
|
diff --git a/src/lstack/core/lstack_protocol_stack.c b/src/lstack/core/lstack_protocol_stack.c
|
|
index c31e65b..eea0a47 100644
|
|
--- a/src/lstack/core/lstack_protocol_stack.c
|
|
+++ b/src/lstack/core/lstack_protocol_stack.c
|
|
@@ -12,17 +12,16 @@
|
|
|
|
#include <pthread.h>
|
|
#include <stdatomic.h>
|
|
-
|
|
+#include <securec.h>
|
|
+#include <numa.h>
|
|
#include <rte_kni.h>
|
|
|
|
#include <lwip/sockets.h>
|
|
-#include <lwip/tcpip.h>
|
|
+#include <lwip/init.h>
|
|
#include <lwip/tcp.h>
|
|
#include <lwip/memp_def.h>
|
|
#include <lwipsock.h>
|
|
#include <lwip/gazelle_posix_api.h>
|
|
-#include <securec.h>
|
|
-#include <numa.h>
|
|
|
|
#include "common/gazelle_base_func.h"
|
|
#include "lstack_thread_rpc.h"
|
|
@@ -292,9 +291,6 @@ static int32_t init_stack_value(struct protocol_stack *stack, void *arg)
|
|
list_init_head(&stack->same_node_recv_list);
|
|
list_init_head(&stack->wakeup_list);
|
|
|
|
- sys_calibrate_tsc();
|
|
- stack_stat_init();
|
|
-
|
|
stack_group->stacks[t_params->idx] = stack;
|
|
set_stack_idx(t_params->idx);
|
|
|
|
@@ -378,9 +374,9 @@ static struct protocol_stack *stack_thread_init(void *arg)
|
|
}
|
|
RTE_PER_LCORE(_lcore_id) = stack->cpu_id;
|
|
|
|
+ sys_timer_init();
|
|
hugepage_init();
|
|
-
|
|
- tcpip_init(NULL, NULL);
|
|
+ lwip_init();
|
|
|
|
if (use_ltran()) {
|
|
if (client_reg_thrd_ring() != 0) {
|
|
diff --git a/src/lstack/core/lstack_stack_stat.c b/src/lstack/core/lstack_stack_stat.c
|
|
index 9f2e93a..00679ab 100644
|
|
--- a/src/lstack/core/lstack_stack_stat.c
|
|
+++ b/src/lstack/core/lstack_stack_stat.c
|
|
@@ -29,25 +29,6 @@
|
|
#include "lstack_dpdk.h"
|
|
#include "lstack_stack_stat.h"
|
|
|
|
-#define US_PER_SEC 1000000
|
|
-
|
|
-static uint64_t g_cycles_per_us;
|
|
-
|
|
-void stack_stat_init(void)
|
|
-{
|
|
- uint64_t freq = rte_get_tsc_hz();
|
|
- g_cycles_per_us = (freq + US_PER_SEC - 1) / US_PER_SEC;
|
|
-}
|
|
-
|
|
-uint64_t get_current_time(void)
|
|
-{
|
|
- if (g_cycles_per_us == 0) {
|
|
- return 0;
|
|
- }
|
|
-
|
|
- return (rte_rdtsc() / g_cycles_per_us);
|
|
-}
|
|
-
|
|
void calculate_lstack_latency(struct gazelle_stack_latency *stack_latency, const struct pbuf *pbuf,
|
|
enum GAZELLE_LATENCY_TYPE type)
|
|
{
|
|
@@ -62,7 +43,7 @@ void calculate_lstack_latency(struct gazelle_stack_latency *stack_latency, const
|
|
if (lt->stamp != ~(lt->check) || lt->stamp < stack_latency->start_time) {
|
|
return;
|
|
}
|
|
- latency = get_current_time() - lt->stamp;
|
|
+ latency = get_now_us() - lt->stamp;
|
|
|
|
struct stack_latency *latency_stat = (type == GAZELLE_LATENCY_LWIP) ?
|
|
&stack_latency->lwip_latency : &stack_latency->read_latency;
|
|
@@ -117,7 +98,7 @@ static void set_latency_start_flag(bool start)
|
|
if (ret != 0) {
|
|
LSTACK_LOG(ERR, LSTACK, "memset_s faile\n");
|
|
}
|
|
- stack->latency.start_time = get_current_time();
|
|
+ stack->latency.start_time = get_now_us();
|
|
stack->latency.lwip_latency.latency_min = ~((uint64_t)0);
|
|
stack->latency.read_latency.latency_min = ~((uint64_t)0);
|
|
memset_s(&stack->aggregate_stats, sizeof(struct gazelle_stack_aggregate_stats),
|
|
diff --git a/src/lstack/include/lstack_stack_stat.h b/src/lstack/include/lstack_stack_stat.h
|
|
index 5737bae..c42c68c 100644
|
|
--- a/src/lstack/include/lstack_stack_stat.h
|
|
+++ b/src/lstack/include/lstack_stack_stat.h
|
|
@@ -25,7 +25,6 @@ void calculate_lstack_latency(struct gazelle_stack_latency *stack_latency, const
|
|
enum GAZELLE_LATENCY_TYPE type);
|
|
void stack_stat_init(void);
|
|
int32_t handle_stack_cmd(int fd, enum GAZELLE_STAT_MODE stat_mode);
|
|
-uint64_t get_current_time(void);
|
|
void lstack_get_low_power_info(struct gazelle_stat_low_power_info *low_power_info);
|
|
void unregister_wakeup(struct protocol_stack *stack, struct wakeup_poll *wakeup);
|
|
void lstack_calculate_aggregate(int type, uint32_t len);
|
|
diff --git a/src/lstack/include/lstack_thread_rpc.h b/src/lstack/include/lstack_thread_rpc.h
|
|
index 657ffa9..4384581 100644
|
|
--- a/src/lstack/include/lstack_thread_rpc.h
|
|
+++ b/src/lstack/include/lstack_thread_rpc.h
|
|
@@ -14,7 +14,6 @@
|
|
#define __GAZELLE_THREAD_RPC_H__
|
|
|
|
#include <pthread.h>
|
|
-#include <arch/sys_arch.h>
|
|
|
|
#include "lstack_lockless_queue.h"
|
|
|
|
diff --git a/src/lstack/include/posix/lstack_socket.h b/src/lstack/include/posix/lstack_socket.h
|
|
index a3ce1eb..45add74 100644
|
|
--- a/src/lstack/include/posix/lstack_socket.h
|
|
+++ b/src/lstack/include/posix/lstack_socket.h
|
|
@@ -37,7 +37,7 @@ ssize_t lwip_recvfrom(int s, void *mem, size_t len, int flags, void *from, void
|
|
ssize_t lwip_recv(int s, void *mem, size_t len, int flags);
|
|
|
|
int lwip_fcntl(int s, int cmd, int val);
|
|
-int lwip_ioctl(int s, int cmd, ...);
|
|
+int lwip_ioctl(int s, long cmd, void *argp);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
diff --git a/src/lstack/netif/lstack_ethdev.c b/src/lstack/netif/lstack_ethdev.c
|
|
index 3923b77..ccaea7d 100644
|
|
--- a/src/lstack/netif/lstack_ethdev.c
|
|
+++ b/src/lstack/netif/lstack_ethdev.c
|
|
@@ -134,7 +134,7 @@ int32_t eth_dev_poll(void)
|
|
}
|
|
|
|
if (!cfg->use_ltran && get_protocol_stack_group()->latency_start) {
|
|
- uint64_t time_stamp = get_current_time();
|
|
+ uint64_t time_stamp = get_now_us();
|
|
time_stamp_into_mbuf(nr_pkts, stack->pkts, time_stamp);
|
|
}
|
|
|
|
@@ -768,7 +768,7 @@ int32_t gazelle_eth_dev_poll(struct protocol_stack *stack, uint8_t use_ltran_fla
|
|
}
|
|
|
|
if (!use_ltran_flag && get_protocol_stack_group()->latency_start) {
|
|
- uint64_t time_stamp = get_current_time();
|
|
+ uint64_t time_stamp = get_now_us();
|
|
time_stamp_into_mbuf(nr_pkts, stack->pkts, time_stamp);
|
|
}
|
|
|
|
diff --git a/src/ltran/ltran_forward.c b/src/ltran/ltran_forward.c
|
|
index 55105f6..4e69f11 100644
|
|
--- a/src/ltran/ltran_forward.c
|
|
+++ b/src/ltran/ltran_forward.c
|
|
@@ -19,7 +19,6 @@
|
|
#include <rte_mempool.h>
|
|
#include <rte_memory.h>
|
|
#include <rte_prefetch.h>
|
|
-#include <rte_cycles.h>
|
|
#include <rte_ring.h>
|
|
#include <securec.h>
|
|
|
|
@@ -65,7 +64,7 @@ static void calculate_ltran_latency(struct gazelle_stack *stack, const struct rt
|
|
return;
|
|
}
|
|
|
|
- latency = get_current_time() - lt->stamp;
|
|
+ latency = get_now_us() - lt->stamp;
|
|
|
|
stack->stack_stats.latency_total += latency;
|
|
stack->stack_stats.latency_pkts++;
|
|
@@ -561,7 +560,7 @@ static __rte_always_inline void upstream_forward_loop(uint32_t port_id, uint32_t
|
|
struct rte_mbuf *buf[GAZELLE_PACKET_READ_SIZE] __rte_cache_aligned;
|
|
for (loop_cnt = 0; loop_cnt < UPSTREAM_LOOP_TIMES; loop_cnt++) {
|
|
if (get_start_latency_flag() == GAZELLE_ON) {
|
|
- time_stamp = get_current_time();
|
|
+ time_stamp = get_now_us();
|
|
}
|
|
|
|
rx_count = rte_eth_rx_burst(port_id, queue_id, buf, GAZELLE_PACKET_READ_SIZE);
|
|
@@ -623,9 +622,8 @@ void upstream_forward(const uint16_t *port)
|
|
uint32_t queue_num = get_ltran_config()->bond.rx_queue_num;
|
|
uint32_t port_id = get_bond_port()[g_port_index];
|
|
unsigned long now_time;
|
|
- unsigned long last_time = get_current_time();
|
|
+ unsigned long last_time = get_now_us();
|
|
unsigned long aging_conn_last_time = last_time;
|
|
- calibrate_time();
|
|
|
|
while (get_ltran_stop_flag() != GAZELLE_TRUE) {
|
|
for (queue_id = 0; queue_id < queue_num; queue_id++) {
|
|
@@ -637,7 +635,7 @@ void upstream_forward(const uint16_t *port)
|
|
rte_kni_handle_request(get_gazelle_kni());
|
|
}
|
|
|
|
- now_time = get_current_time();
|
|
+ now_time = get_now_us();
|
|
if (now_time - aging_conn_last_time > GAZELLE_CONN_INTERVAL) {
|
|
gazelle_delete_aging_conn(gazelle_get_tcp_conn_htable());
|
|
aging_conn_last_time = now_time;
|
|
diff --git a/src/ltran/ltran_stat.c b/src/ltran/ltran_stat.c
|
|
index 774b9cc..384a9a0 100644
|
|
--- a/src/ltran/ltran_stat.c
|
|
+++ b/src/ltran/ltran_stat.c
|
|
@@ -75,7 +75,7 @@ void set_start_latency_flag(int32_t flag)
|
|
}
|
|
|
|
g_start_latency = flag;
|
|
- g_start_time_stamp = get_current_time();
|
|
+ g_start_time_stamp = get_now_us();
|
|
}
|
|
|
|
int32_t get_start_latency_flag(void)
|
|
diff --git a/src/ltran/ltran_stat.h b/src/ltran/ltran_stat.h
|
|
index 75cb353..7945d67 100644
|
|
--- a/src/ltran/ltran_stat.h
|
|
+++ b/src/ltran/ltran_stat.h
|
|
@@ -36,12 +36,6 @@ enum GAZELLE_CLIENT_STATE {
|
|
GAZELLE_CLIENT_STATE_MAX
|
|
};
|
|
|
|
-enum GAZELLE_TCP_LIST_STATE {
|
|
- GAZELLE_ACTIVE_LIST,
|
|
- GAZELLE_LISTEN_LIST,
|
|
- GAZELLE_TIME_WAIT_LIST,
|
|
-};
|
|
-
|
|
enum GAZELLE_TCP_STATE {
|
|
GAZELLE_TCP_STATE_CLS,
|
|
GAZELLE_TCP_STATE_LSN,
|
|
diff --git a/src/ltran/ltran_timer.c b/src/ltran/ltran_timer.c
|
|
index af37679..2a068ea 100644
|
|
--- a/src/ltran/ltran_timer.c
|
|
+++ b/src/ltran/ltran_timer.c
|
|
@@ -15,7 +15,6 @@
|
|
|
|
#include <rte_malloc.h>
|
|
#include <rte_errno.h>
|
|
-#include <rte_cycles.h>
|
|
#include <lwip/gazelle_hlist.h>
|
|
|
|
#include "ltran_param.h"
|
|
@@ -25,22 +24,6 @@
|
|
#include "ltran_instance.h"
|
|
#include "ltran_timer.h"
|
|
|
|
-static uint64_t g_cycles_per_us = 0;
|
|
-
|
|
-uint64_t get_current_time(void)
|
|
-{
|
|
- if (g_cycles_per_us == 0) {
|
|
- return 0;
|
|
- }
|
|
-
|
|
- return (rte_rdtsc() / g_cycles_per_us);
|
|
-}
|
|
-
|
|
-void calibrate_time(void)
|
|
-{
|
|
- g_cycles_per_us = (rte_get_tsc_hz() + US_PER_S - 1) / US_PER_S;
|
|
-}
|
|
-
|
|
void gazelle_detect_sock_logout(struct gazelle_tcp_sock_htable *tcp_sock_htable)
|
|
{
|
|
uint32_t i;
|
|
diff --git a/src/ltran/ltran_timer.h b/src/ltran/ltran_timer.h
|
|
index abc08b9..59aa21b 100644
|
|
--- a/src/ltran/ltran_timer.h
|
|
+++ b/src/ltran/ltran_timer.h
|
|
@@ -16,8 +16,6 @@
|
|
struct gazelle_tcp_conn_htable;
|
|
struct gazelle_tcp_sock_htable;
|
|
|
|
-unsigned long get_current_time(void);
|
|
-void calibrate_time(void);
|
|
void gazelle_detect_conn_logout(struct gazelle_tcp_conn_htable *conn_htable);
|
|
void gazelle_detect_sock_logout(struct gazelle_tcp_sock_htable *tcp_sock_htable);
|
|
void gazelle_delete_aging_conn(struct gazelle_tcp_conn_htable *conn_htable);
|
|
diff --git a/test/unitest/stub.c b/test/unitest/stub.c
|
|
index 8f37c90..5e334ff 100644
|
|
--- a/test/unitest/stub.c
|
|
+++ b/test/unitest/stub.c
|
|
@@ -13,7 +13,7 @@
|
|
#include <stdint.h>
|
|
#include <stdlib.h>
|
|
|
|
-uint64_t get_current_time(void)
|
|
+uint64_t get_now_us(void)
|
|
{
|
|
return 0;
|
|
}
|
|
--
|
|
2.23.0
|
|
|