Merge branch 'feature/add_wifi_send_buffer_result_to_aio_ret' into 'master'

feat(lib): add wifi buffer send result to aio ret

See merge request sdk/ESP8266_RTOS_SDK!441
This commit is contained in:
Dong Heng
2018-09-07 15:46:08 +08:00
5 changed files with 139 additions and 71 deletions

View File

@ -372,6 +372,40 @@ typedef struct {
#define WIFI_EVENT_MASK_NONE (0) /**< mask none of the WiFi events */ #define WIFI_EVENT_MASK_NONE (0) /**< mask none of the WiFi events */
#define WIFI_EVENT_MASK_AP_PROBEREQRECVED (BIT(0)) /**< mask SYSTEM_EVENT_AP_PROBEREQRECVED event */ #define WIFI_EVENT_MASK_AP_PROBEREQRECVED (BIT(0)) /**< mask SYSTEM_EVENT_AP_PROBEREQRECVED event */
typedef enum {
TX_STATUS_SUCCESS = 1,
TX_STATUS_SRC_EXCEED,
TX_STATUS_LRC_EXCEED,
TX_STATUS_DISCARD,
} wifi_tx_result_t;
typedef enum {
PHY_RATE_1_LONG,
PHY_RATE_2_LONG,
PHY_RATE_5_LONG,
PHY_RATE_11_LONG,
PHY_RATE_RESERVED,
PHY_RATE_2_SHORT,
PHY_RATE_5_SHORT,
PHY_RATE_11_SHORT,
PHY_RATE_48,
PHY_RATE_24,
PHY_RATE_12,
PHY_RATE_6,
PHY_RATE_54,
PHY_RATE_36,
PHY_RATE_18,
PHY_RATE_9,
} wifi_tx_rate_t;
typedef struct {
unsigned wifi_tx_result: 8;
unsigned wifi_tx_src: 6;
unsigned wifi_tx_lrc: 6;
unsigned wifi_tx_rate: 8;
unsigned unused: 4;
} wifi_tx_status_t;
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -1,7 +1,7 @@
gwen: gwen:
core: b9f2d3e core: b9f2d3e
net80211: eca7811 net80211: eca7811
pp: eca7811 pp: 82269d9
smartconfig:eca7811 smartconfig:eca7811
wpa: eca7811 wpa: eca7811
phy: 1055_8 phy: 1055_8

Binary file not shown.

View File

@ -49,10 +49,12 @@ static int low_level_send_cb(esp_aio_t* aio);
static inline bool check_pbuf_to_insert(struct pbuf* p) static inline bool check_pbuf_to_insert(struct pbuf* p)
{ {
uint8_t* buf = (uint8_t*)p->payload; uint8_t* buf = (uint8_t*)p->payload;
/*Check if pbuf is tcp ip*/ /*Check if pbuf is tcp ip*/
if (buf[12] == 0x08 && buf[13] == 0x00 && buf[23] == 0x06) { if (buf[12] == 0x08 && buf[13] == 0x00 && buf[23] == 0x06) {
return true; return true;
} }
return false; return false;
} }
@ -70,19 +72,22 @@ static void insert_to_list(int fd, struct pbuf* p)
} }
LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("Insert %p,%d\n", p, pbuf_send_list_num)); LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("Insert %p,%d\n", p, pbuf_send_list_num));
if (pbuf_list_head == NULL) {
pbuf_list_head = (pbuf_send_list_t* )malloc(sizeof(pbuf_send_list_t));
pbuf_send_list_num++;
if (!pbuf_list_head) { if (pbuf_list_head == NULL) {
LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("no menory malloc pbuf list error\n")); tmp_pbuf_list1 = (pbuf_send_list_t*)malloc(sizeof(pbuf_send_list_t));
if (!tmp_pbuf_list1) {
LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("no memory malloc pbuf list error\n"));
return; return;
} }
pbuf_ref(p); pbuf_ref(p);
pbuf_list_head->aiofd = fd; tmp_pbuf_list1->aiofd = fd;
pbuf_list_head->p = p; tmp_pbuf_list1->p = p;
pbuf_list_head->next = NULL; tmp_pbuf_list1->next = NULL;
pbuf_list_head->err_cnt = 0; tmp_pbuf_list1->err_cnt = 0;
pbuf_list_head = tmp_pbuf_list1;
pbuf_send_list_num++;
return; return;
} }
@ -94,16 +99,15 @@ static void insert_to_list(int fd, struct pbuf* p)
tmp_pbuf_list1->err_cnt ++; tmp_pbuf_list1->err_cnt ++;
return; return;
} }
tmp_pbuf_list2 = tmp_pbuf_list1; tmp_pbuf_list2 = tmp_pbuf_list1;
tmp_pbuf_list1 = tmp_pbuf_list2->next; tmp_pbuf_list1 = tmp_pbuf_list2->next;
} }
tmp_pbuf_list2->next = (pbuf_send_list_t*)malloc(sizeof(pbuf_send_list_t)); tmp_pbuf_list1 = (pbuf_send_list_t*)malloc(sizeof(pbuf_send_list_t));
pbuf_send_list_num++;
tmp_pbuf_list1 = tmp_pbuf_list2->next;
if (!tmp_pbuf_list1) { if (!tmp_pbuf_list1) {
LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("no menory malloc pbuf list error\n")); LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("no memory malloc pbuf list error\n"));
return; return;
} }
@ -112,6 +116,8 @@ static void insert_to_list(int fd, struct pbuf* p)
tmp_pbuf_list1->p = p; tmp_pbuf_list1->p = p;
tmp_pbuf_list1->next = NULL; tmp_pbuf_list1->next = NULL;
tmp_pbuf_list1->err_cnt = 0; tmp_pbuf_list1->err_cnt = 0;
tmp_pbuf_list2->next = tmp_pbuf_list1;
pbuf_send_list_num++;
} }
void send_from_list() void send_from_list()
@ -141,6 +147,7 @@ void send_from_list()
if (err == ERR_MEM) { if (err == ERR_MEM) {
pbuf_list_head->err_cnt++; pbuf_list_head->err_cnt++;
if (pbuf_list_head->err_cnt >= 3) { if (pbuf_list_head->err_cnt >= 3) {
LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("Delete %p,%d\n", pbuf_list_head->p, pbuf_send_list_num)); LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("Delete %p,%d\n", pbuf_list_head->p, pbuf_send_list_num));
pbuf_free(pbuf_list_head->p); pbuf_free(pbuf_list_head->p);
@ -148,6 +155,7 @@ void send_from_list()
pbuf_send_list_num--; pbuf_send_list_num--;
pbuf_list_head = tmp_pbuf_list1; pbuf_list_head = tmp_pbuf_list1;
} }
return; return;
} else if (err == ERR_OK) { } else if (err == ERR_OK) {
LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("Delete %p,%d\n", pbuf_list_head->p, pbuf_send_list_num)); LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("Delete %p,%d\n", pbuf_list_head->p, pbuf_send_list_num));
@ -205,6 +213,28 @@ static void low_level_init(struct netif* netif)
static int low_level_send_cb(esp_aio_t* aio) static int low_level_send_cb(esp_aio_t* aio)
{ {
struct pbuf* pbuf = aio->arg; struct pbuf* pbuf = aio->arg;
wifi_tx_status_t* status = (wifi_tx_status_t*) & (aio->ret);
if ((TX_STATUS_SUCCESS != status->wifi_tx_result) && check_pbuf_to_insert(pbuf)) {
uint8_t* buf = (uint8_t*)pbuf->payload;
struct eth_hdr ethhdr;
if (*(buf - 17) & 0x01) { //From DS
memcpy(&ethhdr.dest, buf - 2, ETH_HWADDR_LEN);
memcpy(&ethhdr.src, buf - 2 - ETH_HWADDR_LEN, ETH_HWADDR_LEN);
} else if (*(buf - 17) & 0x02) { //To DS
memcpy(&ethhdr.dest, buf - 2 - ETH_HWADDR_LEN - ETH_HWADDR_LEN, ETH_HWADDR_LEN);
memcpy(&ethhdr.src, buf - 2, 6);
} else {
pbuf_free(pbuf);
return 0;
}
memcpy(buf, &ethhdr, (ETH_HWADDR_LEN + ETH_HWADDR_LEN));
LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("Send packet fail: result:%d, LRC:%d, SRC:%d, RATE:%d",
status->wifi_tx_result, status->wifi_tx_lrc, status->wifi_tx_src, status->wifi_tx_rate));
insert_to_list(aio->fd, aio->arg);
}
pbuf_free(pbuf); pbuf_free(pbuf);
@ -232,8 +262,10 @@ static inline struct pbuf *ethernetif_transform_pbuf(struct pbuf *pbuf)
} }
p = pbuf_alloc(PBUF_RAW, pbuf->len, PBUF_RAM); p = pbuf_alloc(PBUF_RAW, pbuf->len, PBUF_RAM);
if (!p)
if (!p) {
return NULL; return NULL;
}
if (IS_IRAM(p->payload)) { if (IS_IRAM(p->payload)) {
LWIP_DEBUGF(NETIF_DEBUG, ("low_level_output: data in IRAM\n")); LWIP_DEBUGF(NETIF_DEBUG, ("low_level_output: data in IRAM\n"));
@ -285,6 +317,7 @@ static int8_t low_level_output(struct netif* netif, struct pbuf* p)
#endif #endif
p = ethernetif_transform_pbuf(p); p = ethernetif_transform_pbuf(p);
if (!p) { if (!p) {
LWIP_DEBUGF(NETIF_DEBUG, ("low_level_output: lack memory\n")); LWIP_DEBUGF(NETIF_DEBUG, ("low_level_output: lack memory\n"));
return ERR_OK; return ERR_OK;
@ -305,6 +338,7 @@ static int8_t low_level_output(struct netif* netif, struct pbuf* p)
#if ESP_UDP #if ESP_UDP
udp_sync_set_ret(netif, err); udp_sync_set_ret(netif, err);
#endif #endif
if (err != ERR_OK) { if (err != ERR_OK) {
if (err == ERR_MEM) { if (err == ERR_MEM) {
insert_to_list(aio.fd, p); insert_to_list(aio.fd, p);

View File

@ -241,7 +241,7 @@ esp_err_t tcpip_adapter_start(tcpip_adapter_if_t tcpip_if, uint8_t *mac, tcpip_a
} }
if (esp_netif[tcpip_if] == NULL) { if (esp_netif[tcpip_if] == NULL) {
ESP_LOGE(TAG, "TCPIP adapter has no menory\n"); ESP_LOGE(TAG, "TCPIP adapter has no memory\n");
return ESP_ERR_NO_MEM; return ESP_ERR_NO_MEM;
} }
memcpy(esp_netif[tcpip_if]->hwaddr, mac, NETIF_MAX_HWADDR_LEN); memcpy(esp_netif[tcpip_if]->hwaddr, mac, NETIF_MAX_HWADDR_LEN);