Merge branch 'feature/tw8743_menuconfig_add_L2toL3_copy_option' into 'master'
lwip: add option to memcopy packet from L2 to L3 Menuconfig add an option to copy the packet from layer2 (WIFI driver) to layer3 (LWIP), default not copy See merge request !211
This commit is contained in:
commit
b0f3b730aa
4 changed files with 43 additions and 22 deletions
|
@ -1,5 +1,21 @@
|
|||
menu "LWIP"
|
||||
|
||||
config L2_TO_L3_COPY
|
||||
bool "Enable copy between Layer2 and Layer3 packets"
|
||||
default 0
|
||||
help
|
||||
If this feature is enabled, all traffic from layer2(WIFI Driver) will be
|
||||
copied to a new buffer before sending it to layer3(LWIP stack), freeing
|
||||
the layer2 buffer.
|
||||
Please be notified that the total layer2 receiving buffer is fixed and
|
||||
ESP32 currently supports 25 layer2 receiving buffer, when layer2 buffer
|
||||
runs out of memory, then the incoming packets will be dropped in hardware.
|
||||
The layer3 buffer is allocated from the heap, so the total layer3 receiving
|
||||
buffer depends on the available heap size, when heap runs out of memory,
|
||||
no copy will be sent to layer3 and packet will be dropped in layer2.
|
||||
Please make sure you fully understand the impact of this feature before
|
||||
enabling it.
|
||||
|
||||
config LWIP_MAX_SOCKETS
|
||||
int "Max number of open sockets"
|
||||
range 1 16
|
||||
|
|
|
@ -3008,6 +3008,13 @@
|
|||
#define LWIP_PERF 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* ESP_L2_TO_L3_COPY: enable memcpy when receiving packet from L2
|
||||
*/
|
||||
#ifndef ESP_L2_TO_L3_COPY
|
||||
#define ESP_L2_TO_L3_COPY 0
|
||||
#endif
|
||||
|
||||
#ifndef ESP_THREAD_SAFE_DEBUG
|
||||
#define ESP_THREAD_SAFE_DEBUG 0
|
||||
#endif
|
||||
|
|
|
@ -525,6 +525,7 @@ extern unsigned long os_random(void);
|
|||
#define ESP_RANDOM_TCP_PORT 1
|
||||
#define ESP_IP4_ATON 1
|
||||
#define ESP_LIGHT_SLEEP 1
|
||||
#define ESP_L2_TO_L3_COPY CONFIG_L2_TO_L3_COPY
|
||||
|
||||
#define TCP_WND_DEFAULT (4*TCP_MSS)
|
||||
#define TCP_SND_BUF_DEFAULT (2*TCP_MSS)
|
||||
|
|
|
@ -161,40 +161,37 @@ low_level_output(struct netif *netif, struct pbuf *p)
|
|||
* @param netif the lwip network interface structure for this ethernetif
|
||||
*/
|
||||
void
|
||||
#if ESP_LWIP
|
||||
wlanif_input(struct netif *netif, void *buffer, u16_t len, void* eb)
|
||||
#else
|
||||
wlanif_input(struct netif *netif, void *buffer, uint16 len)
|
||||
#endif
|
||||
{
|
||||
struct pbuf *p;
|
||||
|
||||
#if ESP_LWIP
|
||||
if(buffer== NULL)
|
||||
if(!buffer || !netif)
|
||||
goto _exit;
|
||||
if(netif == NULL)
|
||||
goto _exit;
|
||||
#endif
|
||||
|
||||
#if ESP_LWIP
|
||||
p = pbuf_alloc(PBUF_RAW, len, PBUF_REF);
|
||||
if (p == NULL){
|
||||
#if ESP_PERF
|
||||
g_rx_alloc_pbuf_fail_cnt++;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
p->payload = buffer;
|
||||
p->eb = eb;
|
||||
#else
|
||||
p = pbuf_alloc(PBUF_IP, len, PBUF_POOL);
|
||||
#if (ESP_L2_TO_L3_COPY == 1)
|
||||
//p = pbuf_alloc(PBUF_IP, len, PBUF_POOL);
|
||||
p = pbuf_alloc(PBUF_RAW, len, PBUF_RAM);
|
||||
if (p == NULL) {
|
||||
#if ESP_PERF
|
||||
g_rx_alloc_pbuf_fail_cnt++;
|
||||
#endif
|
||||
esp_wifi_internal_free_rx_buffer(eb);
|
||||
return;
|
||||
}
|
||||
memcpy(p->payload, buffer, len);
|
||||
esp_wifi_internal_free_rx_buffer(eb);
|
||||
#else
|
||||
p = pbuf_alloc(PBUF_RAW, len, PBUF_REF);
|
||||
if (p == NULL){
|
||||
#if ESP_PERF
|
||||
g_rx_alloc_pbuf_fail_cnt++;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
p->payload = buffer;
|
||||
p->eb = eb;
|
||||
#endif
|
||||
|
||||
|
||||
/* full packet send to tcpip_thread to process */
|
||||
if (netif->input(p, netif) != ERR_OK) {
|
||||
LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n"));
|
||||
|
|
Loading…
Reference in a new issue