lwip: Refactor support for L2 pbuf free notification into each driver

Makes it easier to handle different drivers enabled at compile/link time.
This commit is contained in:
Angus Gratton
2017-02-24 14:45:17 +11:00
parent 36b3963efb
commit eb1fbaabce
5 changed files with 32 additions and 32 deletions

View File

@@ -82,7 +82,10 @@ ethernet_low_level_init(struct netif *netif)
netif->flags |= NETIF_FLAG_IGMP;
#endif
#endif
/* Do whatever else is needed to initialize interface. */
#ifndef CONFIG_EMAC_L2_TO_L3_RX_BUF_MODE
netif->l2_buffer_free_notify = esp_eth_free_rx_buf;
#endif
}
/**
@@ -152,11 +155,12 @@ ethernetif_input(struct netif *netif, void *buffer, uint16_t len)
if(buffer== NULL || netif == NULL)
goto _exit;
#if CONFIG_EMAC_L2_TO_L3_RX_BUF_MODE
#ifdef CONFIG_EMAC_L2_TO_L3_RX_BUF_MODE
p = pbuf_alloc(PBUF_RAW, len, PBUF_RAM);
if (p == NULL) {
return;
}
p->l2_owner = NULL;
memcpy(p->payload, buffer, len);
/* full packet send to tcpip_thread to process */
@@ -171,13 +175,13 @@ if (netif->input(p, netif) != ERR_OK) {
return;
}
p->payload = buffer;
p->user_flag = PBUF_USER_FLAG_OWNER_ETH;
p->user_buf = buffer;
p->l2_owner = netif;
p->l2_buf = buffer;
/* 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"));
p->user_flag = PBUF_USER_FLAG_OWNER_NULL;
p->l2_owner = NULL;
pbuf_free(p);
}
#endif

View File

@@ -84,7 +84,9 @@ low_level_init(struct netif *netif)
#endif
#endif
/* Do whatever else is needed to initialize interface. */
#if !ESP_L2_TO_L3_COPY
netif->l2_buffer_free_notify = esp_wifi_internal_free_rx_buffer;
#endif
}
/**
@@ -119,6 +121,7 @@ low_level_output(struct netif *netif, struct pbuf *p)
LWIP_DEBUGF(PBUF_DEBUG, ("low_level_output: pbuf is a list, application may has bug"));
q = pbuf_alloc(PBUF_RAW_TX, p->tot_len, PBUF_RAM);
if (q != NULL) {
q->l2_owner = NULL;
pbuf_copy(q, p);
} else {
return ERR_MEM;
@@ -154,6 +157,7 @@ wlanif_input(struct netif *netif, void *buffer, u16_t len, void* eb)
esp_wifi_internal_free_rx_buffer(eb);
return;
}
p->l2_owner = NULL;
memcpy(p->payload, buffer, len);
esp_wifi_internal_free_rx_buffer(eb);
#else
@@ -163,8 +167,8 @@ wlanif_input(struct netif *netif, void *buffer, u16_t len, void* eb)
return;
}
p->payload = buffer;
p->user_buf = eb;
p->user_flag = PBUF_USER_FLAG_OWNER_WIFI;
p->l2_owner = netif;
p->l2_buf = eb;
#endif
/* full packet send to tcpip_thread to process */