From bc082ccc24d6a46ff9eadf3bc0e8d068a34b3654 Mon Sep 17 00:00:00 2001 From: Lemmy Huang Date: Tue, 23 May 2023 16:14:41 +0800 Subject: [PATCH] cleancode: remove perf cleancode: rename gazelle files in lwip Signed-off-by: Lemmy Huang --- 0063-cleancode-remove-perf.patch | 780 ++++++++++++++++++ ...eancode-rename-gazelle-files-in-lwip.patch | 476 +++++++++++ lwip.spec | 10 +- 3 files changed, 1265 insertions(+), 1 deletion(-) create mode 100644 0063-cleancode-remove-perf.patch create mode 100644 0064-cleancode-rename-gazelle-files-in-lwip.patch diff --git a/0063-cleancode-remove-perf.patch b/0063-cleancode-remove-perf.patch new file mode 100644 index 0000000..84343c3 --- /dev/null +++ b/0063-cleancode-remove-perf.patch @@ -0,0 +1,780 @@ +From 55cc351cc1b0e1fa021b410913e8876024a66c4b Mon Sep 17 00:00:00 2001 +From: Lemmy Huang +Date: Fri, 19 May 2023 08:59:43 +0800 +Subject: [PATCH 1/3] cleancode: remove perf + +Signed-off-by: Lemmy Huang +--- + src/api/api_lib.c | 2 - + src/api/api_msg.c | 3 - + src/api/gazelle_dir.mk | 2 +- + src/api/perf.c | 182 ---------------------------------------- + src/core/ipv4/ip4.c | 14 ---- + src/core/ipv6/ip6.c | 10 --- + src/core/pbuf.c | 4 - + src/core/tcp.c | 1 - + src/core/tcp_in.c | 24 ------ + src/core/tcp_out.c | 21 ----- + src/core/udp.c | 21 +---- + src/include/arch/perf.h | 155 ---------------------------------- + src/include/lwipopts.h | 3 +- + 13 files changed, 5 insertions(+), 437 deletions(-) + delete mode 100644 src/api/perf.c + delete mode 100644 src/include/arch/perf.h + +diff --git a/src/api/api_lib.c b/src/api/api_lib.c +index ba9f3c5..ffa14d6 100644 +--- a/src/api/api_lib.c ++++ b/src/api/api_lib.c +@@ -1061,9 +1061,7 @@ netconn_write_vectors_partly(struct netconn *conn, struct netvector *vectors, u1 + /* For locking the core: this _can_ be delayed on low memory/low send buffer, + but if it is, this is done inside api_msg.c:do_write(), so we can use the + non-blocking version here. */ +- PERF_START(PERF_LAYER_TCP, PERF_POINT_TCP_DATA_SEND); + err = netconn_apimsg(lwip_netconn_do_write, &API_MSG_VAR_REF(msg)); +- PERF_STOP_INCREASE_COUNT("lwip_netconn_do_write", PERF_LAYER_TCP); + if (err == ERR_OK) { + if (bytes_written != NULL) { + *bytes_written = API_MSG_VAR_REF(msg).msg.w.offset; +diff --git a/src/api/api_msg.c b/src/api/api_msg.c +index 0287c06..f0572af 100644 +--- a/src/api/api_msg.c ++++ b/src/api/api_msg.c +@@ -1400,7 +1400,6 @@ lwip_netconn_do_connect(void *m) + #endif /* LWIP_UDP */ + #if LWIP_TCP + case NETCONN_TCP: +- PERF_START(PERF_LAYER_TCP, PERF_POINT_TCP_SYN_SEND); + /* Prevent connect while doing any other action. */ + if (msg->conn->state == NETCONN_CONNECT) { + err = ERR_ALREADY; +@@ -1418,7 +1417,6 @@ lwip_netconn_do_connect(void *m) + err = ERR_INPROGRESS; + } else { + msg->conn->current_msg = msg; +- PERF_STOP_INCREASE_COUNT("lwip_netconn_do_connect", PERF_LAYER_TCP); + /* sys_sem_signal() is called from lwip_netconn_do_connected (or err_tcp()), + when the connection is established! */ + #if LWIP_TCPIP_CORE_LOCKING +@@ -1432,7 +1430,6 @@ lwip_netconn_do_connect(void *m) + } + } + } +- PERF_STOP_INCREASE_COUNT("lwip_netconn_do_connect", PERF_LAYER_TCP); + break; + #endif /* LWIP_TCP */ + default: +diff --git a/src/api/gazelle_dir.mk b/src/api/gazelle_dir.mk +index afbf863..c069a29 100644 +--- a/src/api/gazelle_dir.mk ++++ b/src/api/gazelle_dir.mk +@@ -1,3 +1,3 @@ +-SRC = api_lib.c api_msg.c err.c netbuf.c netdb.c netifapi.c sockets.c tcpip.c perf.c posix_api.c sys_arch.c ++SRC = api_lib.c api_msg.c err.c netbuf.c netdb.c netifapi.c sockets.c tcpip.c posix_api.c sys_arch.c + + $(eval $(call register_dir, api, $(SRC))) +diff --git a/src/api/perf.c b/src/api/perf.c +deleted file mode 100644 +index 1c2a273..0000000 +--- a/src/api/perf.c ++++ /dev/null +@@ -1,182 +0,0 @@ +-/* +- * Copyright (c) 2001-2004 Swedish Institute of Computer Science. +- * All rights reserved. +- * +- * Redistribution and use in source and binary forms, with or without modification, +- * are permitted provided that the following conditions are met: +- * +- * 1. Redistributions of source code must retain the above copyright notice, +- * this list of conditions and the following disclaimer. +- * 2. Redistributions in binary form must reproduce the above copyright notice, +- * this list of conditions and the following disclaimer in the documentation +- * and/or other materials provided with the distribution. +- * 3. The name of the author may not be used to endorse or promote products +- * derived from this software without specific prior written permission. +- * +- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT +- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY +- * OF SUCH DAMAGE. +- * +- * This file is part of the lwIP TCP/IP stack. +- * +- * Author: Huawei Technologies +- * +- */ +- +-#include "arch/perf.h" +- +-#include +- +-#include +- +-#if LWIP_RECORD_PERF +- +-#define SIG_FUNC_NUM 3 +- +-#define SIG_STATS_DISPLAY 38 +-#define SIG_PERF_BEGIN 39 +-#define SIG_PERF_END 40 +- +-typedef void (*pSignalFunc) (int); +-static void signal_stats_display(int s); +-static void signal_perf_begin(int s); +-static void signal_perf_end(int s); +- +-uint32_t g_record_perf; +-__thread uint64_t g_timeTaken[PERF_POINT_END]; +-__thread int g_perfPoint[PERF_LAYER_END]; +-__thread struct timespec tvStart[PERF_LAYER_END]; +-volatile uint64_t g_perfMaxtime[PERF_POINT_END]; +-volatile uint64_t g_astPacketCnt[PERF_POINT_END]; +-volatile uint64_t g_astPacketProcTime[PERF_POINT_END]; +- +-char *g_ppLayerName[PERF_POINT_END] = { +- "IP_RECV", +- "TCP_DATA_RECV", +- "UDP_PARTIAL", +- "TCP_SYN_RECV", +- "TCP_SYN_ACK_SEND", +- "TCP_ACK_RECV", +- "TCP_SYN_SEND", +- "TCP_SYN_ACK_RECV", +- "TCP_ACK_SEND", +- "TCP_DATA_SEND", +- "IP_SEND" +-}; +- +-static int gsig_arr[SIG_FUNC_NUM] = { +- SIG_STATS_DISPLAY, +- SIG_PERF_BEGIN, +- SIG_PERF_END +-}; +- +-static pSignalFunc g_Funcs[SIG_FUNC_NUM] = { +- signal_stats_display, +- signal_perf_begin, +- signal_perf_end, +-}; +- +-static void print_perf_data_and_reset() +-{ +- int i; +- printf("\n********* PERF DATA START*************\n"); +- for (i = 0; i < PERF_POINT_END; i++) { +- printf("%-20s Total: PacketProcTime: %-15"PRIu64", Maxtime: %-15"PRIu64", packetCnt: %-15"PRIu64"\n", +- g_ppLayerName[i], __sync_fetch_and_or(&g_astPacketProcTime[i], 0), +- __sync_fetch_and_or(&g_perfMaxtime[i], 0), +- __sync_fetch_and_or(&g_astPacketCnt[i], 0)); +- +- if (__sync_fetch_and_or(&g_astPacketProcTime[i], 0) && __sync_fetch_and_or(&g_astPacketCnt[i], 0)) { +- printf("%-20s Average: PacketProcTime: %-15lf, MaxTime: %-15"PRIu64"\n", g_ppLayerName[i], +- (double)__sync_fetch_and_or(&g_astPacketProcTime[i], 0) / (double)__sync_fetch_and_or(&g_astPacketCnt[i], 0), +- __sync_or_and_fetch(&g_perfMaxtime[i], 0)); +- } +- +- __sync_fetch_and_and (&g_astPacketProcTime[i], 0); +- __sync_fetch_and_and (&g_astPacketCnt[i], 0); +- __sync_fetch_and_and (&g_perfMaxtime[i], 0); +- } +- printf("\n********* PERF DATA END*************\n"); +-} +- +-static void signal_stats_display(int s) +-{ +- struct sigaction s_test; +- printf("Received signal %d, stats display.\n", s); +- stats_display(); +- s_test.sa_handler = (void *) signal_stats_display; +- if (sigemptyset(&s_test.sa_mask) != 0) { +- printf("sigemptyset failed.\n"); +- } +- s_test.sa_flags = SA_RESETHAND; +- if (sigaction(s, &s_test, NULL) != 0) { +- printf("Could not register %d signal handler.\n", s); +- } +-} +- +-static void signal_perf_begin(int s) +-{ +- struct sigaction s_test; +- printf("Received signal %d, perf_begin.\n", s); +- g_record_perf = 1; +- s_test.sa_handler = (void *) signal_perf_begin; +- if (sigemptyset(&s_test.sa_mask) != 0) { +- printf("sigemptyset failed.\n"); +- } +- s_test.sa_flags = SA_RESETHAND; +- if (sigaction(s, &s_test, NULL) != 0) { +- printf("Could not register %d signal handler.\n", s); +- } +-} +- +-static void signal_perf_end(int s) +-{ +- struct sigaction s_test; +- printf("Received signal %d, perf_end\n", s); +- g_record_perf = 0; +- print_perf_data_and_reset(); +- s_test.sa_handler = (void *) signal_perf_end; +- if (sigemptyset(&s_test.sa_mask) != 0) { +- printf("sigemptyset failed.\n"); +- } +- s_test.sa_flags = SA_RESETHAND; +- if (sigaction(s, &s_test, NULL) != 0) { +- printf("Could not register %d signal handler.\n", s); +- } +-} +- +-int check_layer_point(int layer, int point) +-{ +- if (point == g_perfPoint[layer]) { +- return 1; +- } +- return 0; +-} +- +-int perf_init(void) +-{ +- int i; +- struct sigaction s_test; +- for (i = 0; i < SIG_FUNC_NUM; i++) { +- s_test.sa_handler = (void *) g_Funcs[i]; +- if (sigemptyset(&s_test.sa_mask) != 0) { +- printf("sigemptyset failed.\n"); +- return 1; +- } +- +- s_test.sa_flags = SA_RESETHAND; +- if (sigaction(gsig_arr[i], &s_test, NULL) != 0) { +- printf("Could not register %d signal handler.\n", gsig_arr[i]); +- return 1; +- } +- } +- return 0; +-} +-#endif +diff --git a/src/core/ipv4/ip4.c b/src/core/ipv4/ip4.c +index 1b70bb5..1496289 100644 +--- a/src/core/ipv4/ip4.c ++++ b/src/core/ipv4/ip4.c +@@ -286,9 +286,7 @@ ip4_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp) + { + struct netif *netif; + +-#ifndef LWIP_PERF + PERF_START; +-#endif + LWIP_UNUSED_ARG(inp); + + if (!ip4_canforward(p)) { +@@ -350,9 +348,7 @@ ip4_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp) + MIB2_STATS_INC(mib2.ipforwdatagrams); + IP_STATS_INC(ip.xmit); + +-#ifndef LWIP_PERF + PERF_STOP("ip4_forward"); +-#endif + /* don't fragment if interface has mtu set to 0 [loopif] */ + if (netif->mtu && (p->tot_len > netif->mtu)) { + if ((IPH_OFFSET(iphdr) & PP_NTOHS(IP_DF)) == 0) { +@@ -446,8 +442,6 @@ ip4_input(struct pbuf *p, struct netif *inp) + + LWIP_ASSERT_CORE_LOCKED(); + +- PERF_START(PERF_LAYER_IP, PERF_POINT_IP_RECV); +- + IP_STATS_INC(ip.recv); + MIB2_STATS_INC(mib2.ipinreceives); + +@@ -719,19 +713,13 @@ ip4_input(struct pbuf *p, struct netif *inp) + case IP_PROTO_UDPLITE: + #endif /* LWIP_UDPLITE */ + MIB2_STATS_INC(mib2.ipindelivers); +- PERF_PAUSE(PERF_LAYER_IP); + udp_input(p, inp); +- PERF_RESUME(PERF_LAYER_IP, PERF_POINT_IP_RECV); + break; + #endif /* LWIP_UDP */ + #if LWIP_TCP + case IP_PROTO_TCP: + MIB2_STATS_INC(mib2.ipindelivers); +- PERF_PAUSE(PERF_LAYER_IP); +- PERF_START(PERF_LAYER_TCP, PERF_POINT_TCP_RECV); + tcp_input(p, inp); +- PERF_STOP_INCREASE_COUNT("tcp_input", PERF_LAYER_TCP); +- PERF_RESUME(PERF_LAYER_IP, PERF_POINT_IP_RECV); + break; + #endif /* LWIP_TCP */ + #if LWIP_ICMP +@@ -780,8 +768,6 @@ ip4_input(struct pbuf *p, struct netif *inp) + ip4_addr_set_any(ip4_current_src_addr()); + ip4_addr_set_any(ip4_current_dest_addr()); + +- PERF_STOP_INCREASE_COUNT("ip4_input", PERF_LAYER_IP); +- + return ERR_OK; + } + +diff --git a/src/core/ipv6/ip6.c b/src/core/ipv6/ip6.c +index 9d904ec..060d5f3 100644 +--- a/src/core/ipv6/ip6.c ++++ b/src/core/ipv6/ip6.c +@@ -522,8 +522,6 @@ ip6_input(struct pbuf *p, struct netif *inp) + + LWIP_ASSERT_CORE_LOCKED(); + +- PERF_START(PERF_LAYER_IP, PERF_POINT_IP_RECV); +- + IP6_STATS_INC(ip6.recv); + + /* identify the IP header */ +@@ -1071,18 +1069,12 @@ options_done: + #if LWIP_UDPLITE + case IP6_NEXTH_UDPLITE: + #endif /* LWIP_UDPLITE */ +- PERF_PAUSE(PERF_LAYER_IP); + udp_input(p, inp); +- PERF_RESUME(PERF_LAYER_IP, PERF_POINT_IP_RECV); + break; + #endif /* LWIP_UDP */ + #if LWIP_TCP + case IP6_NEXTH_TCP: +- PERF_PAUSE(PERF_LAYER_IP); +- PERF_START(PERF_LAYER_TCP, PERF_POINT_TCP_RECV); + tcp_input(p, inp); +- PERF_STOP_INCREASE_COUNT("tcp_input", PERF_LAYER_TCP); +- PERF_RESUME(PERF_LAYER_IP, PERF_POINT_IP_RECV); + break; + #endif /* LWIP_TCP */ + #if LWIP_ICMP6 +@@ -1123,8 +1115,6 @@ ip6_input_cleanup: + ip6_addr_set_zero(ip6_current_src_addr()); + ip6_addr_set_zero(ip6_current_dest_addr()); + +- PERF_STOP_INCREASE_COUNT("ip6_input", PERF_LAYER_IP); +- + return ERR_OK; + } + +diff --git a/src/core/pbuf.c b/src/core/pbuf.c +index 2385e57..aae6008 100644 +--- a/src/core/pbuf.c ++++ b/src/core/pbuf.c +@@ -747,9 +747,7 @@ pbuf_free(struct pbuf *p) + } + LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_free(%p)\n", (void *)p)); + +-#ifndef LWIP_PERF + PERF_START; +-#endif + + count = 0; + /* de-allocate all consecutive pbufs from the head of the chain that +@@ -814,9 +812,7 @@ pbuf_free(struct pbuf *p) + p = NULL; + } + } +-#ifndef LWIP_PERF + PERF_STOP("pbuf_free"); +-#endif + /* return number of de-allocated pbufs */ + return count; + } +diff --git a/src/core/tcp.c b/src/core/tcp.c +index 538a664..3abf63b 100644 +--- a/src/core/tcp.c ++++ b/src/core/tcp.c +@@ -558,7 +558,6 @@ tcp_close(struct tcp_pcb *pcb) + /* Set a flag not to receive any more data... */ + tcp_set_flags(pcb, TF_RXCLOSED); + } +- + /* ... and close */ + return tcp_close_shutdown(pcb, 1); + } +diff --git a/src/core/tcp_in.c b/src/core/tcp_in.c +index 7e7d70a..3e635aa 100644 +--- a/src/core/tcp_in.c ++++ b/src/core/tcp_in.c +@@ -146,9 +146,7 @@ tcp_input(struct pbuf *p, struct netif *inp) + LWIP_ASSERT_CORE_LOCKED(); + LWIP_ASSERT("tcp_input: invalid pbuf", p != NULL); + +-#ifndef LWIP_PERF + PERF_START; +-#endif + + TCP_STATS_INC(tcp.recv); + MIB2_STATS_INC(mib2.tcpinsegs); +@@ -637,19 +635,7 @@ tcp_input(struct pbuf *p, struct netif *inp) + goto aborted; + } + /* Try to send something out. */ +-#if LWIP_RECORD_PERF +- if (check_layer_point(PERF_LAYER_TCP, PERF_POINT_TCP_SYN_ACK_RECV)) { +- PERF_PAUSE(PERF_LAYER_TCP); +- PERF_START(PERF_LAYER_TCP, PERF_POINT_TCP_ACK_SEND); +- } +-#endif + tcp_output(pcb); +-#if LWIP_RECORD_PERF +- if (check_layer_point(PERF_LAYER_TCP, PERF_POINT_TCP_ACK_SEND)) { +- PERF_STOP_INCREASE_COUNT("tcp_in", PERF_LAYER_TCP); +- PERF_RESUME(PERF_LAYER_TCP, PERF_POINT_TCP_SYN_ACK_RECV); +- } +-#endif + #if TCP_INPUT_DEBUG + #if TCP_DEBUG + tcp_debug_print_state(pcb->state); +@@ -682,9 +668,7 @@ aborted: + } + + LWIP_ASSERT("tcp_input: tcp_pcbs_sane()", tcp_pcbs_sane()); +-#ifndef LWIP_PERF + PERF_STOP("tcp_input"); +-#endif + return; + dropped: + TCP_STATS_INC(tcp.drop); +@@ -753,7 +737,6 @@ tcp_listen_input(struct tcp_pcb_listen *pcb) + tcp_rst((const struct tcp_pcb *)pcb, ackno, seqno + tcplen, ip_current_dest_addr(), + ip_current_src_addr(), tcphdr->dest, tcphdr->src); + } else if (flags & TCP_SYN) { +- PERF_UPDATE_POINT(PERF_LAYER_TCP, PERF_POINT_TCP_SYN_RECV); + LWIP_DEBUGF(TCP_DEBUG, ("TCP connection request %"U16_F" -> %"U16_F".\n", tcphdr->src, tcphdr->dest)); + #if TCP_LISTEN_BACKLOG + if (pcb->accepts_pending >= pcb->backlog) { +@@ -832,18 +815,13 @@ tcp_listen_input(struct tcp_pcb_listen *pcb) + } + #endif + +- PERF_PAUSE(PERF_LAYER_TCP); +- PERF_START(PERF_LAYER_TCP, PERF_POINT_TCP_SYN_ACK_SEND); + /* Send a SYN|ACK together with the MSS option. */ + rc = tcp_enqueue_flags(npcb, TCP_SYN | TCP_ACK); + if (rc != ERR_OK) { + tcp_abandon(npcb, 0); +- PERF_RESUME(PERF_LAYER_TCP, PERF_POINT_TCP_SYN_RECV); + return; + } + tcp_output(npcb); +- PERF_STOP_INCREASE_COUNT("tcp_output", PERF_LAYER_TCP); +- PERF_RESUME(PERF_LAYER_TCP, PERF_POINT_TCP_SYN_RECV); + } + return; + } +@@ -987,7 +965,6 @@ tcp_process(struct tcp_pcb *pcb) + /* received SYN ACK with expected sequence number? */ + if ((flags & TCP_ACK) && (flags & TCP_SYN) + && (ackno == pcb->lastack + 1)) { +- PERF_UPDATE_POINT(PERF_LAYER_TCP, PERF_POINT_TCP_SYN_ACK_RECV); + pcb->rcv_nxt = seqno + 1; + pcb->rcv_ann_right_edge = pcb->rcv_nxt; + pcb->lastack = ackno; +@@ -1066,7 +1043,6 @@ tcp_process(struct tcp_pcb *pcb) + /* expected ACK number? */ + if (TCP_SEQ_BETWEEN(ackno, pcb->lastack + 1, pcb->snd_nxt)) { + pcb->state = ESTABLISHED; +- PERF_UPDATE_POINT(PERF_LAYER_TCP, PERF_POINT_TCP_ACK_RECV); + LWIP_DEBUGF(TCP_DEBUG, ("TCP connection established %"U16_F" -> %"U16_F".\n", inseg.tcphdr->src, inseg.tcphdr->dest)); + #if LWIP_CALLBACK_API || TCP_LISTEN_BACKLOG + if (pcb->listener == NULL) { +diff --git a/src/core/tcp_out.c b/src/core/tcp_out.c +index 6250e6b..ebbc417 100644 +--- a/src/core/tcp_out.c ++++ b/src/core/tcp_out.c +@@ -1708,11 +1708,6 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb, struct netif *netif + err_t err; + u16_t len; + u32_t *opts; +- +-#if LWIP_RECORD_PERF +- int tmpPoint; +-#endif +- + #if TCP_CHECKSUM_ON_COPY + int seg_chksum_was_swapped = 0; + #endif +@@ -1911,9 +1906,6 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb, struct netif *netif + #endif /* CHECKSUM_GEN_TCP */ + TCP_STATS_INC(tcp.xmit); + +- PERF_PAUSE_RETURN_POINT(PERF_LAYER_TCP, tmpPoint); +- PERF_START(PERF_LAYER_IP, PERF_POINT_IP_SEND); +- + NETIF_SET_HINTS(netif, &(pcb->netif_hints)); + + seg->p->pcb = pcb; +@@ -1930,9 +1922,6 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb, struct netif *netif + } + #endif + +- PERF_STOP_INCREASE_COUNT("ip_out", PERF_LAYER_IP); +- PERF_RESUME(PERF_LAYER_TCP, tmpPoint); +- + return err; + } + +@@ -2371,10 +2360,6 @@ tcp_send_empty_ack(struct tcp_pcb *pcb) + u8_t optlen, optflags = 0; + u8_t num_sacks = 0; + +-#if LWIP_RECORD_PERF +- int tmpPoint; +-#endif +- + LWIP_ASSERT("tcp_send_empty_ack: invalid pcb", pcb != NULL); + + #if LWIP_TCP_TIMESTAMPS +@@ -2391,9 +2376,6 @@ tcp_send_empty_ack(struct tcp_pcb *pcb) + } + #endif + +- PERF_PAUSE_RETURN_POINT(PERF_LAYER_TCP, tmpPoint); +- PERF_START(PERF_LAYER_IP, PERF_POINT_IP_SEND); +- + p = tcp_output_alloc_header(pcb, optlen, 0, lwip_htonl(pcb->snd_nxt)); + if (p == NULL) { + /* let tcp_fasttmr retry sending this ACK */ +@@ -2418,9 +2400,6 @@ tcp_send_empty_ack(struct tcp_pcb *pcb) + tcp_clear_flags(pcb, TF_ACK_DELAY | TF_ACK_NOW); + } + +- PERF_STOP_INCREASE_COUNT("ip_out", PERF_LAYER_IP); +- PERF_RESUME(PERF_LAYER_TCP, tmpPoint); +- + return err; + } + +diff --git a/src/core/udp.c b/src/core/udp.c +index 9c3cdaa..d632de8 100644 +--- a/src/core/udp.c ++++ b/src/core/udp.c +@@ -213,11 +213,7 @@ udp_input(struct pbuf *p, struct netif *inp) + LWIP_ASSERT("udp_input: invalid pbuf", p != NULL); + LWIP_ASSERT("udp_input: invalid netif", inp != NULL); + +-#if LWIP_RECORD_PERF +- PERF_START(PERF_LAYER_UDP, PERF_POINT_UDP); +-#else +- //PERF_START; +-#endif ++ PERF_START; + + UDP_STATS_INC(udp.recv); + +@@ -438,12 +434,7 @@ udp_input(struct pbuf *p, struct netif *inp) + pbuf_free(p); + } + end: +-#if LWIP_RECORD_PERF +- PERF_STOP_INCREASE_COUNT("udp_input", PERF_LAYER_UDP); +-#else +- //PERF_STOP("udp_input"); +-#endif +- ++ PERF_STOP("udp_input"); + return; + #if CHECKSUM_CHECK_UDP + chkerr: +@@ -453,13 +444,7 @@ chkerr: + UDP_STATS_INC(udp.drop); + MIB2_STATS_INC(mib2.udpinerrors); + pbuf_free(p); +- +-#if LWIP_RECORD_PERF +- PERF_STOP_INCREASE_COUNT("udp_input", PERF_LAYER_UDP); +-#else +- //PERF_STOP("udp_input"); +-#endif +- ++ PERF_STOP("udp_input"); + #endif /* CHECKSUM_CHECK_UDP */ + } + +diff --git a/src/include/arch/perf.h b/src/include/arch/perf.h +deleted file mode 100644 +index e505da7..0000000 +--- a/src/include/arch/perf.h ++++ /dev/null +@@ -1,155 +0,0 @@ +-/* +- * Copyright (c) 2001-2004 Swedish Institute of Computer Science. +- * All rights reserved. +- * +- * Redistribution and use in source and binary forms, with or without modification, +- * are permitted provided that the following conditions are met: +- * +- * 1. Redistributions of source code must retain the above copyright notice, +- * this list of conditions and the following disclaimer. +- * 2. Redistributions in binary form must reproduce the above copyright notice, +- * this list of conditions and the following disclaimer in the documentation +- * and/or other materials provided with the distribution. +- * 3. The name of the author may not be used to endorse or promote products +- * derived from this software without specific prior written permission. +- * +- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT +- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY +- * OF SUCH DAMAGE. +- * +- * This file is part of the lwIP TCP/IP stack. +- * +- * Author: Huawei Technologies +- * +- */ +- +-#ifndef LWIP_ARCH_PERF_H +-#define LWIP_ARCH_PERF_H +- +-#include +- +-#include "lwip/debug.h" +- +-#if LWIP_RECORD_PERF +-enum PERF_POINT { +- PERF_POINT_IP_RECV, +- PERF_POINT_TCP_RECV, +- PERF_POINT_UDP, +- PERF_POINT_TCP_SYN_RECV, +- PERF_POINT_TCP_SYN_ACK_SEND, +- PERF_POINT_TCP_ACK_RECV, +- PERF_POINT_TCP_SYN_SEND, +- PERF_POINT_TCP_SYN_ACK_RECV, +- PERF_POINT_TCP_ACK_SEND, +- PERF_POINT_TCP_DATA_SEND, +- PERF_POINT_IP_SEND, +- PERF_POINT_END +-}; +- +-enum PERF_LAYER { +- PERF_LAYER_IP, +- PERF_LAYER_TCP, +- PERF_LAYER_UDP, +- PERF_LAYER_END +-}; +- +-extern uint32_t g_record_perf; +- +-extern __thread uint64_t g_timeTaken[PERF_POINT_END]; +-extern __thread int g_perfPoint[PERF_LAYER_END]; +-extern __thread struct timespec tvStart[PERF_LAYER_END]; +- +-extern char *g_ppLayerName[PERF_POINT_END]; +-extern volatile uint64_t g_perfMaxtime[PERF_POINT_END]; +-extern volatile uint64_t g_astPacketCnt[PERF_POINT_END]; +-extern volatile uint64_t g_astPacketProcTime[PERF_POINT_END]; +- +-#define PERF_START(layer, point) do {\ +- g_perfPoint[(layer)] = (point);\ +- LWIP_DEBUGF(PERF_OUTPUT_DEBUG, ("set point %d:%s\n", layer, g_ppLayerName[g_perfPoint[(layer)]]));\ +- clock_gettime(CLOCK_MONOTONIC, &tvStart[(layer)]);\ +- g_timeTaken[(point)] = 0;\ +-} while (0) +- +-#define PERF_UPDATE_POINT(layer, point) do {\ +- LWIP_DEBUGF(PERF_OUTPUT_DEBUG, ("old point %d:%s\n", layer, g_ppLayerName[g_perfPoint[(layer)]]));\ +- g_timeTaken[(point)] = g_timeTaken[g_perfPoint[(layer)]];\ +- g_timeTaken[g_perfPoint[(layer)]] = 0;\ +- g_perfPoint[(layer)] = (point);\ +- LWIP_DEBUGF(PERF_OUTPUT_DEBUG, ("new point %d:%s\n", layer, g_ppLayerName[g_perfPoint[(layer)]]));\ +-} while (0) +- +-#define PERF_PAUSE(layer) do {\ +- struct timespec tvEnd;\ +- clock_gettime(CLOCK_MONOTONIC, &tvEnd);\ +- LWIP_DEBUGF(PERF_OUTPUT_DEBUG, ("perf pause layer%d\n", layer));\ +- g_timeTaken[g_perfPoint[(layer)]] += ((tvEnd.tv_sec - tvStart[(layer)].tv_sec) \ +- * (1000000000UL) + (tvEnd.tv_nsec - tvStart[(layer)].tv_nsec));\ +-} while (0) +- +-#define PERF_PAUSE_RETURN_POINT(layer, pause_point) do {\ +- struct timespec tvEnd;\ +- clock_gettime(CLOCK_MONOTONIC, &tvEnd);\ +- g_timeTaken[g_perfPoint[(layer)]] += ((tvEnd.tv_sec - tvStart[(layer)].tv_sec) \ +- * (1000000000UL) + (tvEnd.tv_nsec - tvStart[(layer)].tv_nsec));\ +- LWIP_DEBUGF(PERF_OUTPUT_DEBUG, ("perf pause point %d:%s\n", layer, g_ppLayerName[g_perfPoint[(layer)]]));\ +- (pause_point) = g_perfPoint[(layer)];\ +-} while (0) +- +- +-#define PERF_RESUME(layer, point) do {\ +- LWIP_DEBUGF(PERF_OUTPUT_DEBUG, ("perf resule point %d:%s\n", layer, g_ppLayerName[point]));\ +- clock_gettime(CLOCK_MONOTONIC, &tvStart[(layer)]);\ +- g_perfPoint[(layer)] = (point);\ +-} while (0) +- +- +-/* x is a prompt */ +-#define PERF_STOP_INCREASE_COUNT(x, layer) do {\ +- if (g_record_perf)\ +- {\ +- struct timespec tvEnd;\ +- int i = 2;\ +- uint32_t oldValue = 0;\ +- clock_gettime(CLOCK_MONOTONIC, &tvEnd);\ +- g_timeTaken[g_perfPoint[(layer)]] += ((tvEnd.tv_sec - tvStart[(layer)].tv_sec) \ +- * (1000000000UL) + (tvEnd.tv_nsec - tvStart[(layer)].tv_nsec));\ +- while (i && !oldValue)\ +- {\ +- oldValue = __sync_or_and_fetch(&g_perfMaxtime[g_perfPoint[(layer)]], 0);\ +- if (oldValue >= g_timeTaken[g_perfPoint[(layer)]])\ +- {\ +- break;\ +- }\ +- oldValue = __sync_val_compare_and_swap(&g_perfMaxtime[g_perfPoint[(layer)]],\ +- oldValue, g_timeTaken[g_perfPoint[(layer)]]);\ +- i--;\ +- }\ +- __sync_fetch_and_add(&g_astPacketCnt[g_perfPoint[(layer)]], 1);\ +- __sync_fetch_and_add(&g_astPacketProcTime[g_perfPoint[(layer)]], g_timeTaken[g_perfPoint[(layer)]]);\ +- LWIP_DEBUGF(PERF_OUTPUT_DEBUG, ("Time for %s is: %ld\n",\ +- g_ppLayerName[g_perfPoint[(layer)]], g_timeTaken[g_perfPoint[(layer)]]));\ +- }\ +-} while (0) +- +- +-int check_layer_point(int layer, int point); +-int perf_init(); +- +-#else +-#define PERF_START(layer, point) do { } while (0) +-#define PERF_UPDATE_POINT(layer, point) do { } while (0) +-#define PERF_PAUSE(layer) do { } while (0) +-#define PERF_PAUSE_RETURN_POINT(layer, pause_point) do { } while (0) +-#define PERF_RESUME(layer, point) do { } while (0) +-#define PERF_STOP_INCREASE_COUNT(x, layer) do { } while (0) +-#endif +- +-#endif /* LWIP_ARCH_PERF_H */ +diff --git a/src/include/lwipopts.h b/src/include/lwipopts.h +index bcb0879..828a2d1 100644 +--- a/src/include/lwipopts.h ++++ b/src/include/lwipopts.h +@@ -38,8 +38,7 @@ + ---------- gazelle options ---------- + ------------------------------------- + */ +-#define LWIP_PERF 1 +-#define LWIP_RECORD_PERF 0 ++#define LWIP_PERF 0 + + //#define LWIP_DEBUG 1 + #define GAZELLE_USE_DPDK_LOG 1 +-- +2.22.0.windows.1 + diff --git a/0064-cleancode-rename-gazelle-files-in-lwip.patch b/0064-cleancode-rename-gazelle-files-in-lwip.patch new file mode 100644 index 0000000..e2c8ea7 --- /dev/null +++ b/0064-cleancode-rename-gazelle-files-in-lwip.patch @@ -0,0 +1,476 @@ +From d41efd0c2f8f899daed9acfac86ac57738994bf1 Mon Sep 17 00:00:00 2001 +From: Lemmy Huang +Date: Fri, 19 May 2023 09:39:16 +0800 +Subject: [PATCH 2/3] cleancode: rename gazelle files in lwip + +Signed-off-by: Lemmy Huang +--- + src/api/api_msg.c | 2 +- + src/api/gazelle_dir.mk | 2 +- + src/api/{posix_api.c => gazelle_posix_api.c} | 2 +- + src/api/sockets.c | 2 +- + src/core/ipv4/icmp.c | 2 +- + src/core/ipv4/ip4.c | 2 +- + src/core/ipv4/ip4_frag.c | 2 +- + src/core/tcp_in.c | 2 +- + src/core/tcp_out.c | 2 +- + src/core/udp.c | 2 +- + src/include/arch/cc.h | 6 +++--- + src/include/arch/sys_arch.h | 6 +++--- + src/include/{dpdk_cksum.h => gazelle_dpdk_offload.h} | 6 +++--- + src/include/{eventpoll.h => gazelle_event.h} | 8 ++++---- + src/include/{hlist.h => gazelle_hlist.h} | 8 ++++---- + src/include/{list.h => gazelle_list.h} | 6 +++--- + src/include/{posix_api.h => gazelle_posix_api.h} | 6 +++--- + src/include/{reg_sock.h => gazelle_tcp_reg.h} | 6 +++--- + src/include/lwip/priv/tcp_priv.h | 2 +- + src/include/lwip/tcp.h | 2 +- + src/include/lwiplog.h | 6 +++--- + src/include/lwipopts.h | 6 +++--- + src/include/lwipsock.h | 8 ++++---- + src/netif/ethernet.c | 2 +- + 24 files changed, 49 insertions(+), 49 deletions(-) + rename src/api/{posix_api.c => gazelle_posix_api.c} (99%) + rename src/include/{dpdk_cksum.h => gazelle_dpdk_offload.h} (97%) + rename src/include/{eventpoll.h => gazelle_event.h} (95%) + rename src/include/{hlist.h => gazelle_hlist.h} (98%) + rename src/include/{list.h => gazelle_list.h} (97%) + rename src/include/{posix_api.h => gazelle_posix_api.h} (97%) + rename src/include/{reg_sock.h => gazelle_tcp_reg.h} (96%) + +diff --git a/src/api/api_msg.c b/src/api/api_msg.c +index f0572af..18f33ef 100644 +--- a/src/api/api_msg.c ++++ b/src/api/api_msg.c +@@ -57,7 +57,7 @@ + #if GAZELLE_ENABLE + #include "lwip/sockets.h" + #include "lwipsock.h" +-#include "posix_api.h" ++#include "gazelle_posix_api.h" + #endif + + #include +diff --git a/src/api/gazelle_dir.mk b/src/api/gazelle_dir.mk +index c069a29..d51ad43 100644 +--- a/src/api/gazelle_dir.mk ++++ b/src/api/gazelle_dir.mk +@@ -1,3 +1,3 @@ +-SRC = api_lib.c api_msg.c err.c netbuf.c netdb.c netifapi.c sockets.c tcpip.c posix_api.c sys_arch.c ++SRC = api_lib.c api_msg.c err.c netbuf.c netdb.c netifapi.c sockets.c tcpip.c sys_arch.c gazelle_posix_api.c + + $(eval $(call register_dir, api, $(SRC))) +diff --git a/src/api/posix_api.c b/src/api/gazelle_posix_api.c +similarity index 99% +rename from src/api/posix_api.c +rename to src/api/gazelle_posix_api.c +index d9b983c..8bd4ce0 100644 +--- a/src/api/posix_api.c ++++ b/src/api/gazelle_posix_api.c +@@ -41,7 +41,7 @@ + + #include "lwip/err.h" + #include "lwipsock.h" +-#include "posix_api.h" ++#include "gazelle_posix_api.h" + + posix_api_t *posix_api; + posix_api_t posix_api_val; +diff --git a/src/api/sockets.c b/src/api/sockets.c +index a0f9d50..f402db8 100644 +--- a/src/api/sockets.c ++++ b/src/api/sockets.c +@@ -66,7 +66,7 @@ + #if GAZELLE_ENABLE + #include + #include "lwipsock.h" +-#include "posix_api.h" ++#include "gazelle_posix_api.h" + #endif + + #include +diff --git a/src/core/ipv4/icmp.c b/src/core/ipv4/icmp.c +index 402ba69..2b15ed4 100644 +--- a/src/core/ipv4/icmp.c ++++ b/src/core/ipv4/icmp.c +@@ -52,7 +52,7 @@ + #include + + #if GAZELLE_ENABLE && CHECKSUM_GEN_IP_HW +-#include "dpdk_cksum.h" ++#include "gazelle_dpdk_offload.h" + #endif + + #ifdef LWIP_HOOK_FILENAME +diff --git a/src/core/ipv4/ip4.c b/src/core/ipv4/ip4.c +index 1496289..079716d 100644 +--- a/src/core/ipv4/ip4.c ++++ b/src/core/ipv4/ip4.c +@@ -60,7 +60,7 @@ + #include + + #if GAZELLE_ENABLE && (CHECKSUM_CHECK_IP_HW || CHECKSUM_GEN_IP_HW) +-#include "dpdk_cksum.h" ++#include "gazelle_dpdk_offload.h" + #endif + + #ifdef LWIP_HOOK_FILENAME +diff --git a/src/core/ipv4/ip4_frag.c b/src/core/ipv4/ip4_frag.c +index e01ea51..4d697c8 100644 +--- a/src/core/ipv4/ip4_frag.c ++++ b/src/core/ipv4/ip4_frag.c +@@ -52,7 +52,7 @@ + #include + + #if GAZELLE_ENABLE && CHECKSUM_GEN_IP_HW +-#include "dpdk_cksum.h" ++#include "gazelle_dpdk_offload.h" + #endif + + #if IP_REASSEMBLY +diff --git a/src/core/tcp_in.c b/src/core/tcp_in.c +index 3e635aa..9585965 100644 +--- a/src/core/tcp_in.c ++++ b/src/core/tcp_in.c +@@ -66,7 +66,7 @@ + #include + + #if GAZELLE_ENABLE && CHECKSUM_CHECK_TCP_HW +-#include ++#include + #endif /* CHECKSUM_CHECK_TCP_HW */ + + #ifdef LWIP_HOOK_FILENAME +diff --git a/src/core/tcp_out.c b/src/core/tcp_out.c +index ebbc417..fde3b8f 100644 +--- a/src/core/tcp_out.c ++++ b/src/core/tcp_out.c +@@ -84,7 +84,7 @@ + #include "lwipsock.h" + #include + #if CHECKSUM_GEN_TCP_HW +-#include "dpdk_cksum.h" ++#include "gazelle_dpdk_offload.h" + #endif + #endif + +diff --git a/src/core/udp.c b/src/core/udp.c +index d632de8..fc86ac5 100644 +--- a/src/core/udp.c ++++ b/src/core/udp.c +@@ -68,7 +68,7 @@ + #if GAZELLE_ENABLE + #include "lwipsock.h" + #include +-#include "dpdk_cksum.h" ++#include "gazelle_dpdk_offload.h" + #endif + + #ifndef UDP_LOCAL_PORT_RANGE_START +diff --git a/src/include/arch/cc.h b/src/include/arch/cc.h +index 10d667b..0b454bb 100644 +--- a/src/include/arch/cc.h ++++ b/src/include/arch/cc.h +@@ -30,8 +30,8 @@ + * + */ + +-#ifndef LWIP_ARCH_CC_H +-#define LWIP_ARCH_CC_H ++#ifndef _LWIP_ARCH_CC_H_ ++#define _LWIP_ARCH_CC_H_ + + #include + #include +@@ -78,4 +78,4 @@ void alloc_memory_##variable_name(void) \ + sys_hugepage_malloc(mpname, LWIP_MEM_ALIGN_BUFFER(size)); \ + } + +-#endif /* LWIP_ARCH_CC_H */ ++#endif /* _LWIP_ARCH_CC_H_ */ +diff --git a/src/include/arch/sys_arch.h b/src/include/arch/sys_arch.h +index 04e3192..907c116 100644 +--- a/src/include/arch/sys_arch.h ++++ b/src/include/arch/sys_arch.h +@@ -30,8 +30,8 @@ + * + */ + +-#ifndef LWIP_ARCH_SYS_ARCH_H +-#define LWIP_ARCH_SYS_ARCH_H ++#ifndef _LWIP_ARCH_SYS_ARCH_H_ ++#define _LWIP_ARCH_SYS_ARCH_H_ + + #include + #include +@@ -136,4 +136,4 @@ __attribute__((always_inline)) inline int update_timeout(int timeout, uint32_t p + } + } + +-#endif /* LWIP_ARCH_SYS_ARCH_H */ ++#endif /* _LWIP_ARCH_SYS_ARCH_H_ */ +diff --git a/src/include/dpdk_cksum.h b/src/include/gazelle_dpdk_offload.h +similarity index 97% +rename from src/include/dpdk_cksum.h +rename to src/include/gazelle_dpdk_offload.h +index e41644b..0548258 100644 +--- a/src/include/dpdk_cksum.h ++++ b/src/include/gazelle_dpdk_offload.h +@@ -30,8 +30,8 @@ + * + */ + +-#ifndef __DPDK_CKSUM_H__ +-#define __DPDK_CKSUM_H__ ++#ifndef _GAZELLE_DPDK_OFFLOAD_H_ ++#define _GAZELLE_DPDK_OFFLOAD_H_ + + #include "lwipopts.h" + #if GAZELLE_ENABLE +@@ -108,4 +108,4 @@ static inline u16_t ip_chksum_pseudo_offload(u8_t proto, u16_t proto_len, + #endif /* CHECKSUM_GEN_TCP_HW */ + + #endif /* GAZELLE_ENABLE */ +-#endif /* __DPDK_CKSUM_H__ */ ++#endif /* _GAZELLE_DPDK_OFFLOAD_H_ */ +diff --git a/src/include/eventpoll.h b/src/include/gazelle_event.h +similarity index 95% +rename from src/include/eventpoll.h +rename to src/include/gazelle_event.h +index a10c84b..e31ec4b 100644 +--- a/src/include/eventpoll.h ++++ b/src/include/gazelle_event.h +@@ -30,13 +30,13 @@ + * + */ + +-#ifndef __EVENTPOLL_H__ +-#define __EVENTPOLL_H__ ++#ifndef _GAZELLE_EVENT_H_ ++#define _GAZELLE_EVENT_H_ + + #include + + #include "lwip/api.h" +-#include "list.h" ++#include "gazelle_list.h" + + #define MAX_EPOLLFDS 32 + +@@ -67,4 +67,4 @@ struct lwip_sock; + extern void add_sock_event(struct lwip_sock *sock, uint32_t event); + extern int32_t lstack_epoll_close(int32_t); + +-#endif /* __EVENTPOLL_H__ */ ++#endif /* _GAZELLE_EVENT_H_ */ +diff --git a/src/include/hlist.h b/src/include/gazelle_hlist.h +similarity index 98% +rename from src/include/hlist.h +rename to src/include/gazelle_hlist.h +index 988b017..86b5c6d 100644 +--- a/src/include/hlist.h ++++ b/src/include/gazelle_hlist.h +@@ -30,10 +30,10 @@ + * + */ + +-#ifndef __HLIST_H__ +-#define __HLIST_H__ ++#ifndef _GAZELLE_HLIST_H_ ++#define _GAZELLE_HLIST_H_ + +-#include "list.h" ++#include "gazelle_list.h" + + //#if GAZELLE_TCP_PCB_HASH + struct hlist_node { +@@ -230,4 +230,4 @@ static inline void hlist_ctl_add_after(struct hlist_node *n, struct hlist_node * + } + //#endif /* GAZELLE_TCP_PCB_HASH */ + +-#endif /* __HLIST_H__ */ ++#endif /* _GAZELLE_HLIST_H_ */ +diff --git a/src/include/list.h b/src/include/gazelle_list.h +similarity index 97% +rename from src/include/list.h +rename to src/include/gazelle_list.h +index 11f94c2..a40c17f 100644 +--- a/src/include/list.h ++++ b/src/include/gazelle_list.h +@@ -30,8 +30,8 @@ + * + */ + +-#ifndef __LIST_H__ +-#define __LIST_H__ ++#ifndef _GAZELLE_LIST_H_ ++#define _GAZELLE_LIST_H_ + + #ifndef NULL + #ifdef __cplusplus +@@ -107,4 +107,4 @@ static inline int list_is_empty(const struct list_node *h) + (type *)((char *)__mptr - offsetof(type,member));}) + #endif /* container_of */ + +-#endif /* __LIST_H__ */ ++#endif /* _GAZELLE_LIST_H_ */ +diff --git a/src/include/posix_api.h b/src/include/gazelle_posix_api.h +similarity index 97% +rename from src/include/posix_api.h +rename to src/include/gazelle_posix_api.h +index a73e2ec..0bed1de 100644 +--- a/src/include/posix_api.h ++++ b/src/include/gazelle_posix_api.h +@@ -30,8 +30,8 @@ + * + */ + +-#ifndef __POSIX_API_H__ +-#define __POSIX_API_H__ ++#ifndef _GAZELLE_POSIX_API_H_ ++#define _GAZELLE_POSIX_API_H_ + + #include + #include +@@ -88,4 +88,4 @@ int posix_api_init(void); + void posix_api_free(void); + void posix_api_fork(void); + +-#endif /* __POSIX_API_H__ */ ++#endif /* _GAZELLE_POSIX_API_H_ */ +diff --git a/src/include/reg_sock.h b/src/include/gazelle_tcp_reg.h +similarity index 96% +rename from src/include/reg_sock.h +rename to src/include/gazelle_tcp_reg.h +index e349e85..6a9f5f9 100644 +--- a/src/include/reg_sock.h ++++ b/src/include/gazelle_tcp_reg.h +@@ -30,8 +30,8 @@ + * + */ + +-#ifndef __REG_SOCK_H__ +-#define __REG_SOCK_H__ ++#ifndef _GAZELLE_TCP_REG_ ++#define _GAZELLE_TCP_REG_ + + enum reg_ring_type { + REG_RING_TCP_LISTEN = 0, +@@ -60,4 +60,4 @@ struct reg_ring_msg { + extern int vdev_reg_xmit(enum reg_ring_type type, struct gazelle_quintuple *qtuple); + extern bool port_in_stack_queue(uint32_t src_ip, uint32_t dst_ip, uint16_t src_port, uint16_t dst_port); + +-#endif /* __REG_SOCK_H__ */ ++#endif /* _GAZELLE_TCP_REG_ */ +diff --git a/src/include/lwip/priv/tcp_priv.h b/src/include/lwip/priv/tcp_priv.h +index ddae3fd..44200ff 100644 +--- a/src/include/lwip/priv/tcp_priv.h ++++ b/src/include/lwip/priv/tcp_priv.h +@@ -341,7 +341,7 @@ extern PER_THREAD struct tcp_pcb *tcp_tw_pcbs; /* List of all TCP PCBs in T + extern PER_THREAD struct tcp_pcb ** tcp_pcb_lists[NUM_TCP_PCB_LISTS]; + + #if GAZELLE_ENABLE +-#include "reg_sock.h" ++#include "gazelle_tcp_reg.h" + static inline int vdev_reg_done(enum reg_ring_type reg_type, const struct tcp_pcb *pcb) + { + LWIP_ASSERT("Invalid parameter", pcb != NULL); +diff --git a/src/include/lwip/tcp.h b/src/include/lwip/tcp.h +index e13099c..11ddd25 100644 +--- a/src/include/lwip/tcp.h ++++ b/src/include/lwip/tcp.h +@@ -53,7 +53,7 @@ + + #if GAZELLE_TCP_PCB_HASH + #include "lwip/sys.h" +-#include "hlist.h" ++#include "gazelle_hlist.h" + #endif + + #ifdef __cplusplus +diff --git a/src/include/lwiplog.h b/src/include/lwiplog.h +index f278ff4..2cf68f9 100644 +--- a/src/include/lwiplog.h ++++ b/src/include/lwiplog.h +@@ -30,8 +30,8 @@ + * + */ + +-#ifndef __LWIPLOG_H__ +-#define __LWIPLOG_H__ ++#ifndef _LWIPLOG_H_ ++#define _LWIPLOG_H_ + + #include + #include +@@ -77,4 +77,4 @@ do { LWIP_PLATFORM_LOG(LWIP_LOG_FATAL, "Assertion \"%s\" failed at line %d in %s + + #endif /* GAZELLE_USE_DPDK_LOG */ + +-#endif /* __LWIPLOG_H__ */ ++#endif /* _LWIPLOG_H_ */ +diff --git a/src/include/lwipopts.h b/src/include/lwipopts.h +index 828a2d1..bc85eae 100644 +--- a/src/include/lwipopts.h ++++ b/src/include/lwipopts.h +@@ -30,8 +30,8 @@ + * + */ + +-#ifndef __LWIPOPTS_H__ +-#define __LWIPOPTS_H__ ++#ifndef _LWIPOPTS_H_ ++#define _LWIPOPTS_H_ + + /* + ------------------------------------- +@@ -241,4 +241,4 @@ + */ + #define LWIP_NETIF_LOOPBACK 1 + +-#endif /* __LWIPOPTS_H__ */ ++#endif /* _LWIPOPTS_H_ */ +diff --git a/src/include/lwipsock.h b/src/include/lwipsock.h +index f8480c5..1814f76 100644 +--- a/src/include/lwipsock.h ++++ b/src/include/lwipsock.h +@@ -30,14 +30,14 @@ + * + */ + +-#ifndef __LWIPSOCK_H__ +-#define __LWIPSOCK_H__ ++#ifndef _LWIPSOCK_H_ ++#define _LWIPSOCK_H_ + + #include + #include "lwip/opt.h" + #include "lwip/api.h" + +-#include "eventpoll.h" ++#include "gazelle_event.h" + + /* move some definitions to the lwipsock.h for libnet to use, and + * at the same time avoid conflict between lwip/sockets.h and sys/socket.h +@@ -187,4 +187,4 @@ struct lwip_sock *get_socket_by_fd(int s); + void lwip_sock_init(void); + void lwip_exit(void); + +-#endif /* __LWIPSOCK_H__ */ ++#endif /* _LWIPSOCK_H_ */ +diff --git a/src/netif/ethernet.c b/src/netif/ethernet.c +index fd13f00..deddf3f 100644 +--- a/src/netif/ethernet.c ++++ b/src/netif/ethernet.c +@@ -57,7 +57,7 @@ + #endif /* PPPOE_SUPPORT */ + + #if GAZELLE_ENABLE && (CHECKSUM_GEN_TCP_HW || CHECKSUM_GEN_IP_HW) +-#include "dpdk_cksum.h" ++#include "gazelle_dpdk_offload.h" + #endif + + #ifdef LWIP_HOOK_FILENAME +-- +2.22.0.windows.1 + diff --git a/lwip.spec b/lwip.spec index bdc7aeb..b964e58 100644 --- a/lwip.spec +++ b/lwip.spec @@ -4,7 +4,7 @@ Summary: lwip is a small independent implementation of the TCP/IP protocol suite Name: lwip Version: 2.1.3 -Release: 53 +Release: 54 License: BSD URL: http://savannah.nongnu.org/projects/lwip/ Source0: http://download.savannah.nongnu.org/releases/lwip/%{name}-%{version}.zip @@ -74,6 +74,8 @@ Patch9058: 0059-fix-last_unsent-last_unacked.patch Patch9059: 0060-lwip-add-udp-multicast.patch Patch9060: 0061-fix-pbuf-leak-in-udp-connection.patch Patch9061: 0062-cleancode-improving-makefile-readability.patch +Patch9062: 0063-cleancode-remove-perf.patch +Patch9063: 0064-cleancode-rename-gazelle-files-in-lwip.patch BuildRequires: gcc-c++ dos2unix dpdk-devel @@ -152,6 +154,8 @@ find %{_builddir}/%{name}-%{version} -type f -exec dos2unix -q {} \; %patch9059 -p1 %patch9060 -p1 %patch9061 -p1 +%patch9062 -p1 +%patch9063 -p1 %build cd %{_builddir}/%{name}-%{version}/src @@ -167,6 +171,10 @@ cd %{_builddir}/%{name}-%{version}/src %{_libdir}/liblwip.a %changelog +* Tue May 23 2023 Lemmy Huang - 2.1.3-54 +- cleancode: remove perf +- cleancode: rename gazelle files in lwip + * Tue May 23 2023 Lemmy Huang - 2.1.3-53 - cleancode: improving makefile readability