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
pull/103/merge
Liu Zhi Fu 2016-11-16 16:24:41 +08:00
rodzic 7dbf01b210
commit 69dbc36a1c
4 zmienionych plików z 37 dodań i 22 usunięć

Wyświetl plik

@ -1,5 +1,15 @@
menu "LWIP"
config L2_TO_L3_COPY
bool "Enable copy between Layer2 and Layer3 packets"
default 0
help
If this feature is enabled, then all traffic from layer2(WIFI Driver)
to layer3(LWIP stack) will make a copy, the layer2 buffer will be
freed and the copy will be sent to layer3. Please make sure you fully
understand this feature before you enable this feature.
config LWIP_MAX_SOCKETS
int "Max number of open sockets"
range 1 16

Wyświetl plik

@ -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 1
#endif
#ifndef ESP_THREAD_SAFE_DEBUG
#define ESP_THREAD_SAFE_DEBUG 0
#endif

Wyświetl plik

@ -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)

Wyświetl plik

@ -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"));