mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-08-06 07:00:05 +08:00
feat(lwip): Add lwip TCP Tx/Rx debug log
This commit is contained in:
@ -47,6 +47,97 @@ static int pbuf_send_list_num = 0;
|
||||
#endif
|
||||
static int low_level_send_cb(esp_aio_t* aio);
|
||||
|
||||
#if ESP_TCP_TXRX_PBUF_DEBUG
|
||||
void tcp_print_status(int status, void* buf, uint32_t tmp1, uint32_t tmp2, uint32_t tmp3)
|
||||
{
|
||||
struct pbuf* p = (struct pbuf*)buf;
|
||||
if (p->tot_len < 50) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t i;
|
||||
|
||||
i = *((unsigned char*)p->payload + 12);
|
||||
|
||||
if (i == 0x08) { /*ipv4*/
|
||||
i = *((unsigned char*)p->payload + 13);
|
||||
|
||||
if (i == 0) {
|
||||
i = *((unsigned char*)p->payload + 23);
|
||||
|
||||
if (i == 0x06) { /*tcp*/
|
||||
i = *((unsigned char*)p->payload + 16);
|
||||
i <<= 8;
|
||||
i += *((unsigned char*)p->payload + 17);
|
||||
|
||||
if (i >= 40) { /*tcp data*/
|
||||
uint32_t len, seq, ack, srcport, destport, flags;
|
||||
wifi_tx_status_t *tx_result = (wifi_tx_status_t *)(&tmp1);
|
||||
len = i;
|
||||
i = *((unsigned char*)p->payload + 38);
|
||||
i <<= 8;
|
||||
i += *((unsigned char*)p->payload + 39);
|
||||
i <<= 8;
|
||||
i += *((unsigned char*)p->payload + 40);
|
||||
i <<= 8;
|
||||
i += *((unsigned char*)p->payload + 41);
|
||||
seq = i;
|
||||
i = *((unsigned char*)p->payload + 42);
|
||||
i <<= 8;
|
||||
i += *((unsigned char*)p->payload + 43);
|
||||
i <<= 8;
|
||||
i += *((unsigned char*)p->payload + 44);
|
||||
i <<= 8;
|
||||
i += *((unsigned char*)p->payload + 45);
|
||||
ack = i;
|
||||
i = *((unsigned char*)p->payload + 34);
|
||||
i <<= 8;
|
||||
i += *((unsigned char*)p->payload + 35);
|
||||
srcport = i;
|
||||
i = *((unsigned char*)p->payload + 36);
|
||||
i <<= 8;
|
||||
i += *((unsigned char*)p->payload + 37);
|
||||
destport = i;
|
||||
flags = *((unsigned char *)p->payload+47);
|
||||
|
||||
switch (status) {
|
||||
case LWIP_SEND_DATA_TO_WIFI:
|
||||
LWIP_DEBUGF(ESP_TCP_TXRX_PBUF_DEBUG, ("@@ Tx - L:%u, S:%u, A:%u, SP:%u, DP:%u, F:%x\n", len, seq, ack, srcport, destport, flags));
|
||||
break;
|
||||
|
||||
case LWIP_RESEND_DATA_TO_WIFI_WHEN_WIFI_SEND_FAILED:
|
||||
LWIP_DEBUGF(ESP_TCP_TXRX_PBUF_DEBUG, ("@@ Cache Tx - L:%u, S:%u, A:%u, SP:%u, DP:%u, F:%x\n", len, seq, ack, srcport, destport, flags));
|
||||
break;
|
||||
|
||||
case LWIP_RECV_DATA_FROM_WIFI:
|
||||
LWIP_DEBUGF(ESP_TCP_TXRX_PBUF_DEBUG, ("@@ WiFi Rx - L:%u, S:%u, A:%u, SP:%u, DP:%u, F:%x\n", len, seq, ack, srcport, destport, flags));
|
||||
break;
|
||||
|
||||
case LWIP_RETRY_DATA_WHEN_RECV_ACK_TIMEOUT:
|
||||
LWIP_DEBUGF(ESP_TCP_TXRX_PBUF_DEBUG, ("@@ TCP RTY - rtime:%d, rto:%d, L:%u, S:%u, A:%u, SP:%u, DP:%u, F:%x\n", tmp1, tmp2, len, seq, ack, srcport, destport, flags));
|
||||
return;
|
||||
|
||||
case LWIP_FETCH_DATA_AT_TCPIP_THREAD:
|
||||
LWIP_DEBUGF(ESP_TCP_TXRX_PBUF_DEBUG, ("@@ eth Rx - L:%u, S:%u, A:%u, SP:%u, DP:%u, F:%x\n", len, seq, ack, srcport, destport, flags));
|
||||
break;
|
||||
|
||||
case WIFI_SEND_DATA_FAILED:
|
||||
LWIP_DEBUGF(ESP_TCP_TXRX_PBUF_DEBUG, ("@@ WiFi Tx Fail - result:%d, src:%d, lrc:%d, rate:%d, L:%u, S:%u, A:%u, SP:%u, DP:%u, F:%x\n",\
|
||||
tx_result->wifi_tx_result, tx_result->wifi_tx_src, tx_result->wifi_tx_lrc, tx_result->wifi_tx_rate, len, seq, ack, srcport, destport, flags));
|
||||
break;
|
||||
|
||||
default:
|
||||
LWIP_DEBUGF(ESP_TCP_TXRX_PBUF_DEBUG, ("@@ status:%d, L:%u, S:%u, A:%u, SP:%u, DP:%u, F:%x, tmp1:%d, tmp2:%d, tmp3:%d\n",\
|
||||
status, len, seq, ack, srcport, destport, flags, tmp1, tmp2, tmp3));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ESP_TCP
|
||||
static inline bool check_pbuf_to_insert(struct pbuf* p)
|
||||
{
|
||||
@ -145,6 +236,10 @@ void send_from_list()
|
||||
aio.ret = 0;
|
||||
|
||||
err = ieee80211_output_pbuf(aio);
|
||||
|
||||
#if ESP_TCP_TXRX_PBUF_DEBUG
|
||||
tcp_print_status(LWIP_RESEND_DATA_TO_WIFI_WHEN_WIFI_SEND_FAILED, (void*)pbuf_list_head->p, 0 ,0, 0);
|
||||
#endif
|
||||
tmp_pbuf_list1 = pbuf_list_head->next;
|
||||
|
||||
if (err == ERR_MEM) {
|
||||
@ -217,6 +312,18 @@ static int low_level_send_cb(esp_aio_t* aio)
|
||||
{
|
||||
struct pbuf* pbuf = aio->arg;
|
||||
|
||||
#if ESP_TCP_TXRX_PBUF_DEBUG
|
||||
wifi_tx_status_t* status = (wifi_tx_status_t*) & (aio->ret);
|
||||
if (TX_STATUS_SUCCESS != status->wifi_tx_result) {
|
||||
uint8_t* buf = (uint8_t*)pbuf->payload;
|
||||
|
||||
/*Check if pbuf is tcp ip*/
|
||||
if (buf[12] == 0x08 && buf[13] == 0x00 && buf[23] == 0x06) {
|
||||
tcp_print_status(WIFI_SEND_DATA_FAILED, (void*)pbuf, aio->ret ,0, 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ESP_TCP
|
||||
wifi_tx_status_t* status = (wifi_tx_status_t*) & (aio->ret);
|
||||
|
||||
@ -345,6 +452,10 @@ static int8_t low_level_output(struct netif* netif, struct pbuf* p)
|
||||
aio.arg = p;
|
||||
aio.ret = 0;
|
||||
|
||||
#if ESP_TCP_TXRX_PBUF_DEBUG
|
||||
tcp_print_status(LWIP_SEND_DATA_TO_WIFI, (void*)p, 0 ,0, 0);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* we use "SOCK_RAW" to create socket, so all input/output datas include full ethernet
|
||||
* header, meaning we should not pass target low-level address here.
|
||||
|
Reference in New Issue
Block a user