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

@@ -78,11 +78,6 @@
#include <string.h>
#if ESP_LWIP
#include "esp_wifi_internal.h"
#include "esp_eth.h"
#endif
#define SIZEOF_STRUCT_PBUF LWIP_MEM_ALIGN_SIZE(sizeof(struct pbuf))
/* Since the pool is created in memp, PBUF_POOL_BUFSIZE will be automatically
aligned there. Therefore, PBUF_POOL_BUFSIZE_ALIGNED can be used here. */
@@ -350,10 +345,10 @@ pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
p->ref = 1;
/* set flags */
p->flags = 0;
#if ESP_LWIP
p->user_buf = NULL;
p->user_flag = PBUF_USER_FLAG_OWNER_NULL;
p->l2_owner = NULL;
p->l2_buf = NULL;
#endif
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_alloc(length=%"U16_F") == %p\n", length, (void *)p));
@@ -720,14 +715,13 @@ pbuf_free(struct pbuf *p)
memp_free(MEMP_PBUF_POOL, p);
/* is this a ROM or RAM referencing pbuf? */
} else if (type == PBUF_ROM || type == PBUF_REF) {
#if ESP_LWIP
if (type == PBUF_REF && p->user_flag == PBUF_USER_FLAG_OWNER_WIFI ) {
esp_wifi_internal_free_rx_buffer(p->user_buf);
}
if (type == PBUF_REF && p->user_flag == PBUF_USER_FLAG_OWNER_ETH ) {
esp_eth_free_rx_buf(p->user_buf);
}
if (p->l2_owner != NULL
&& p->l2_buf != NULL
&& p->l2_owner->l2_buffer_free_notify != NULL) {
p->l2_owner->l2_buffer_free_notify(p->l2_buf);
}
#endif
memp_free(MEMP_PBUF, p);
/* type == PBUF_RAM */