Projects
Eulaceura:Factory
lwip
_service:obs_scm:0146-cleancode-remove-perf.patch
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:obs_scm:0146-cleancode-remove-perf.patch of Package lwip
From caaae52ed2af00869270221f64e20deaaed6368c Mon Sep 17 00:00:00 2001 From: Lemmy Huang <huangliming5@huawei.com> Date: Mon, 8 Jul 2024 17:40:25 +0800 Subject: [PATCH 2/2] cleancode: remove perf Signed-off-by: Lemmy Huang <huangliming5@huawei.com> --- src/api/api_lib.c | 2 - src/api/api_msg.c | 4 - 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/tcp.c | 1 - src/core/tcp_in.c | 22 ----- src/core/tcp_out.c | 19 ----- src/core/udp.c | 22 +---- src/include/arch/perf.h | 155 ---------------------------------- src/include/lwipopts.h | 3 +- 12 files changed, 7 insertions(+), 429 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 1721d49..851c7cc --- a/src/api/api_lib.c +++ b/src/api/api_lib.c @@ -1075,9 +1075,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 0d33c67..60801c4 --- a/src/api/api_msg.c +++ b/src/api/api_msg.c @@ -1410,7 +1410,6 @@ lwip_netconn_do_connected(void *arg, struct tcp_pcb *pcb, err_t err) if (was_blocking) { sys_sem_signal(op_completed_sem); } - return ERR_OK; } #endif /* LWIP_TCP */ @@ -1445,7 +1444,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; @@ -1463,7 +1461,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 @@ -1477,7 +1474,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 <signal.h> - -#include <lwip/stats.h> - -#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 0bbeefc..9e27023 --- 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)) { @@ -386,9 +384,7 @@ ip4_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp) IP_STATS_INC(ip.xmit); #endif -#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) { @@ -485,8 +481,6 @@ ip4_input(struct pbuf *p, struct netif *inp) LWIP_ASSERT_CORE_LOCKED(); - PERF_START(PERF_LAYER_IP, PERF_POINT_IP_RECV); - #if GAZELLE_ENABLE IP_STATS_INC(ip.rx_in); #else @@ -762,19 +756,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 @@ -823,7 +811,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); #if GAZELLE_ENABLE IP_STATS_INC(ip.rx_out); #endif @@ -1124,6 +1111,7 @@ ip4_output(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest, struct netif *netif; LWIP_IP_CHECK_PBUF_REF_COUNT_FOR_TX(p); + if ((netif = ip4_route_src(src, dest)) == NULL) { LWIP_DEBUGF(IP_DEBUG, ("ip4_output: No route to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", ip4_addr1_16(dest), ip4_addr2_16(dest), ip4_addr3_16(dest), ip4_addr4_16(dest))); diff --git a/src/core/ipv6/ip6.c b/src/core/ipv6/ip6.c index 9017d87..4ee73f6 --- a/src/core/ipv6/ip6.c +++ b/src/core/ipv6/ip6.c @@ -526,8 +526,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 */ @@ -1075,18 +1073,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 @@ -1127,8 +1119,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/tcp.c b/src/core/tcp.c index 69f6953..cf6b76d --- a/src/core/tcp.c +++ b/src/core/tcp.c @@ -561,7 +561,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 6c960a6..08796b8 --- a/src/core/tcp_in.c +++ b/src/core/tcp_in.c @@ -658,19 +658,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); @@ -707,9 +695,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); @@ -780,7 +766,6 @@ tcp_listen_input(struct tcp_pcb_listen *pcb) tcp_rst_netif(ip_data.current_input_netif, 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) { @@ -865,19 +850,14 @@ 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) { LWIP_DEBUGF(GAZELLE_DEBUG_SERIOUS, ("tcp_listen_input: send SYN or ACK failed\n")); 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; } @@ -1024,7 +1004,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; @@ -1105,7 +1084,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 839e904..ed0c791 --- a/src/core/tcp_out.c +++ b/src/core/tcp_out.c @@ -1822,11 +1822,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 @@ -2025,8 +2020,6 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb, struct netif *netif #if !GAZELLE_ENABLE TCP_STATS_INC(tcp.xmit); #endif - PERF_PAUSE_RETURN_POINT(PERF_LAYER_TCP, tmpPoint); - PERF_START(PERF_LAYER_IP, PERF_POINT_IP_SEND); NETIF_SET_HINTS(netif, &(pcb->netif_hints)); @@ -2046,8 +2039,6 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb, struct netif *netif #if GAZELLE_ENABLE TCP_STATS_INC(tcp.tx_out); #endif - PERF_STOP_INCREASE_COUNT("ip_out", PERF_LAYER_IP); - PERF_RESUME(PERF_LAYER_TCP, tmpPoint); return err; } @@ -2563,10 +2554,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 @@ -2583,9 +2570,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 */ @@ -2610,9 +2594,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 6b11bf6..fd42bc2 --- a/src/core/udp.c +++ b/src/core/udp.c @@ -269,11 +269,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; #if !GAZELLE_ENABLE UDP_STATS_INC(udp.recv); @@ -526,12 +522,7 @@ udp_input(struct pbuf *p, struct netif *inp) UDP_STATS_INC(udp.rx_out); #endif 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: @@ -541,13 +532,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 */ } @@ -596,6 +581,7 @@ udp_send_chksum(struct udp_pcb *pcb, struct pbuf *p, { LWIP_ERROR("udp_send_chksum: invalid pcb", pcb != NULL, return ERR_ARG); LWIP_ERROR("udp_send_chksum: invalid pbuf", p != NULL, return ERR_ARG); + if (IP_IS_ANY_TYPE_VAL(pcb->remote_ip)) { return ERR_VAL; } 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 <time.h> - -#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 44dcddf..0b18629 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 GAZELLE_USE_DPDK_LOG 1 -- 2.33.0
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2