ip4: Add on-demand timer config for IP4 reassembly timer

2.1.3-esp: ce1a7099 optimization lwip ip4 reassembly timer
This commit is contained in:
xueyunfei
2024-09-11 08:04:53 +02:00
committed by David Cermak
parent 3d8cbaa9ce
commit 2dcdc98eb4
4 changed files with 45 additions and 1 deletions
+1
View File
@@ -329,6 +329,7 @@ void lwip_example_app_platform_assert(const char *msg, int line, const char *fil
#define ESP_LWIP_MLD6_TIMERS_ONDEMAND ESP_LWIP
#define ESP_LWIP_DHCP_FINE_TIMERS_ONDEMAND ESP_LWIP
#define ESP_LWIP_DNS_TIMERS_ONDEMAND ESP_LWIP
#define ESP_LWIP_IP4_REASSEMBLY_TIMERS_ONDEMAND ESP_LWIP
#define ESP_DNS ESP_LWIP
#define ESP_LWIP_ARP ESP_LWIP
+38
View File
@@ -52,6 +52,13 @@
#include <string.h>
#if IP_REASSEMBLY
#if ESP_LWIP_IP4_REASSEMBLY_TIMERS_ONDEMAND
#include "lwip/timeouts.h"
#include "stdbool.h"
static bool s_is_tmr_start = false;
#endif /* ESP_LWIP_IP4_REASSEMBLY_TIMERS_ONDEMAND */
/**
* The IP reassembly code currently has the following limitations:
* - IP header options are not supported
@@ -118,6 +125,17 @@ static u16_t ip_reass_pbufcount;
static void ip_reass_dequeue_datagram(struct ip_reassdata *ipr, struct ip_reassdata *prev);
static int ip_reass_free_complete_datagram(struct ip_reassdata *ipr, struct ip_reassdata *prev);
#if ESP_LWIP_IP4_REASSEMBLY_TIMERS_ONDEMAND
/**
* Wrapper function with matching prototype which calls the actual callback
*/
static void ip_reass_timeout_cb(void *arg)
{
LWIP_UNUSED_ARG(arg);
ip_reass_tmr();
}
#endif
/**
* Reassembly timer base function
* for both NO_SYS == 0 and 1 (!).
@@ -128,6 +146,9 @@ void
ip_reass_tmr(void)
{
struct ip_reassdata *r, *prev = NULL;
#if ESP_LWIP_IP4_REASSEMBLY_TIMERS_ONDEMAND
bool tmr_restart = false;
#endif /* ESP_LWIP_IP4_REASSEMBLY_TIMERS_ONDEMAND */
r = reassdatagrams;
while (r != NULL) {
@@ -138,6 +159,9 @@ ip_reass_tmr(void)
LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_reass_tmr: timer dec %"U16_F"\n", (u16_t)r->timer));
prev = r;
r = r->next;
#if ESP_LWIP_IP4_REASSEMBLY_TIMERS_ONDEMAND
tmr_restart = true;
#endif /* ESP_LWIP_IP4_REASSEMBLY_TIMERS_ONDEMAND */
} else {
/* reassembly timed out */
struct ip_reassdata *tmp;
@@ -149,6 +173,14 @@ ip_reass_tmr(void)
ip_reass_free_complete_datagram(tmp, prev);
}
}
#if ESP_LWIP_IP4_REASSEMBLY_TIMERS_ONDEMAND
if (tmr_restart) {
sys_timeout(IP_TMR_INTERVAL, ip_reass_timeout_cb, NULL);
} else {
sys_untimeout(ip_reass_timeout_cb, NULL);
s_is_tmr_start = false;
}
#endif/* ESP_LWIP_IP4_REASSEMBLY_TIMERS_ONDEMAND */
}
/**
@@ -672,6 +704,12 @@ ip4_reass(struct pbuf *p)
/* Return the pbuf chain */
return p;
}
#if ESP_LWIP_IP4_REASSEMBLY_TIMERS_ONDEMAND
if (!s_is_tmr_start) {
sys_timeout(IP_TMR_INTERVAL, ip_reass_timeout_cb, NULL);
s_is_tmr_start = true;
}
#endif /* ESP_LWIP_IP4_REASSEMBLY_TIMERS_ONDEMAND */
/* the datagram is not (yet?) reassembled completely */
LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_reass_pbufcount: %d out\n", ip_reass_pbufcount));
return NULL;
+1 -1
View File
@@ -81,7 +81,7 @@ const struct lwip_cyclic_timer lwip_cyclic_timers[] = {
{TCP_TMR_INTERVAL, HANDLER(tcp_tmr)},
#endif /* LWIP_TCP */
#if LWIP_IPV4
#if IP_REASSEMBLY
#if IP_REASSEMBLY && !ESP_LWIP_IP4_REASSEMBLY_TIMERS_ONDEMAND
{IP_TMR_INTERVAL, HANDLER(ip_reass_tmr)},
#endif /* IP_REASSEMBLY */
#if LWIP_ARP
+5
View File
@@ -165,6 +165,7 @@ u32_t esp_random(void);
#define DNS_FALLBACK_SERVER_INDEX (DNS_MAX_SERVERS - 1)
#define ESP_LWIP_DHCP_FINE_TIMERS_ONDEMAND 1
#define ESP_LWIP_DNS_TIMERS_ONDEMAND 1
#define ESP_LWIP_IP4_REASSEMBLY_TIMERS_ONDEMAND 1
#else
#define ESP_LWIP 0
@@ -180,6 +181,10 @@ u32_t esp_random(void);
#define ESP_LWIP_DNS_TIMERS_ONDEMAND 0
#endif
#ifndef ESP_LWIP_IP4_REASSEMBLY_TIMERS_ONDEMAND
#define ESP_LWIP_IP4_REASSEMBLY_TIMERS_ONDEMAND 0
#endif /* ESP_LWIP_IP4_REASSEMBLY_TIMERS_ONDEMAND */
#endif /* ESP_LWIP */
#endif /* LWIP_HDR_LWIPOPTS_H */