Merge remote-tracking branch 'origin/master' into feature/wdts

This commit is contained in:
Jeroen Domburg 2016-10-27 10:25:23 +08:00
commit fd887dbeea
23 changed files with 235 additions and 136 deletions

View File

@ -191,14 +191,14 @@ esp_err_t esp_wifi_disconnect(void);
esp_err_t esp_wifi_clear_fast_connect(void);
/**
* @brief Kick the all station or associated id equals to aid
* @brief deauthenticate all stations or associated id equals to aid
*
* @param uint16_t aid : when aid is 0, kick all stations, otherwise kick station whose associated id is aid
* @param uint16_t aid : when aid is 0, deauthenticate all stations, otherwise deauthenticate station whose associated id is aid
*
* @return ESP_OK : succeed
* @return others : fail
*/
esp_err_t esp_wifi_kick_station(uint16_t aid);
esp_err_t esp_wifi_deauth_sta(uint16_t aid);
/**
* @brief Scan all available APs.
@ -235,19 +235,19 @@ esp_err_t esp_wifi_scan_stop(void);
* @return ESP_OK : succeed
* @return others : fail
*/
esp_err_t esp_wifi_get_ap_num(uint16_t *number);
esp_err_t esp_wifi_scan_get_ap_num(uint16_t *number);
/**
* @brief Get AP list found in last scan
*
* @param uint16_t *number : as input param, it stores max AP number ap_list can hold, as output param, it store
* @param uint16_t *number : as input param, it stores max AP number ap_records can hold, as output param, it store
the actual AP number this API returns
* @param wifi_ap_list_t *ap_list : a list to hold the found APs
* @param wifi_ap_record_t *ap_records: an wifi_ap_record_t array to hold the found APs
*
* @return ESP_OK : succeed
* @return others : fail
*/
esp_err_t esp_wifi_get_ap_list(uint16_t *number, wifi_ap_list_t *ap_list);
esp_err_t esp_wifi_scan_get_ap_records(uint16_t *number, wifi_ap_record_t *ap_records);
/**
* @brief Set current power save type
@ -471,14 +471,13 @@ esp_err_t esp_wifi_get_config(wifi_interface_t ifx, wifi_config_t *conf);
*
* @attention SSC only API
*
* @param struct station_info **station : station list
* @param wifi_sta_list_t *sta: station list
*
* @return ESP_OK : succeed
* @return others : fail
*/
esp_err_t esp_wifi_get_station_list(struct station_info **station);
esp_err_t esp_wifi_ap_get_sta_list(wifi_sta_list_t *sta);
esp_err_t esp_wifi_free_station_list(void);
/**
* @brief Set the WiFi API configuration storage type

View File

@ -0,0 +1,80 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* All the APIs declared here are internal only APIs, it can only be used by
* espressif internal modules, such as SSC, LWIP, TCPIP adapter etc, espressif
* customers are not recommended to use them.
*
* If someone really want to use specified APIs declared in here, please contact
* espressif AE/developer to make sure you know the limitations or risk of
* the API, otherwise you may get unexpected behavior!!!
*
*/
#ifndef __ESP_WIFI_INTERNAL_H__
#define __ESP_WIFI_INTERNAL_H__
#include <stdint.h>
#include <stdbool.h>
#include "freertos/FreeRTOS.h"
#include "freertos/queue.h"
#include "rom/queue.h"
#include "esp_err.h"
#include "esp_wifi_types.h"
#include "esp_event.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief get whether the wifi driver is allowed to transmit data or not
*
* @param none
*
* @return true : upper layer should stop to transmit data to wifi driver
* @return false : upper layer can transmit data to wifi driver
*/
bool esp_wifi_internal_tx_is_stop(void);
/**
* @brief free the rx buffer which allocated by wifi driver
*
* @param void* buffer: rx buffer pointer
*
* @return nonoe
*/
void esp_wifi_internal_free_rx_buffer(void* buffer);
/**
* @brief transmit the buffer via wifi driver
*
* @attention1 TODO should modify the return type from bool to int
*
* @param wifi_interface_t wifi_if : wifi interface id
* @param void *buffer : the buffer to be tansmit
* @param u16_t len : the length of buffer
*
* @return True : success transmit the buffer to wifi driver
* False : failed to transmit the buffer to wifi driver
*/
bool esp_wifi_internal_tx(wifi_interface_t wifi_if, void *buffer, u16_t len);
#ifdef __cplusplus
}
#endif
#endif /* __ESP_WIFI_H__ */

View File

@ -109,7 +109,7 @@ typedef struct {
wifi_second_chan_t second; /**< second channel of AP */
int8_t rssi; /**< signal strength of AP */
wifi_auth_mode_t authmode; /**< authmode of AP */
} wifi_ap_list_t;
} wifi_ap_record_t;
typedef enum {
WIFI_PS_NONE, /**< No power save */
@ -150,10 +150,15 @@ typedef union {
wifi_sta_config_t sta; /**< configuration of STA */
} wifi_config_t;
struct station_info {
STAILQ_ENTRY(station_info) next;
uint8_t bssid[6];
};
typedef struct {
uint8_t mac[6]; /**< mac address of sta that associated with ESP32 soft-AP */
}wifi_sta_info_t;
#define ESP_WIFI_MAX_CONN_NUM (8+2) /**< max number of sta the eSP32 soft-AP can connect */
typedef struct {
wifi_sta_info_t sta[ESP_WIFI_MAX_CONN_NUM]; /**< station list */
uint8_t num; /**< number of station that associated with ESP32 soft-AP */
}wifi_sta_list_t;
typedef enum {
WIFI_STORAGE_FLASH, /**< all configuration will strore in both memory and flash */

@ -1 +1 @@
Subproject commit a1e5f8b953c7934677ba7a6ed0a6dd2da0e6bd0f
Subproject commit b9561aa5db15443d11f8bb5aefdfc5da540d8f2d

View File

@ -192,7 +192,7 @@ void vPortEndScheduler( void ) PRIVILEGED_FUNCTION;
#endif
/* Multi-core: get current core ID */
inline uint32_t xPortGetCoreID() {
static inline uint32_t xPortGetCoreID() {
int id;
asm volatile(
"rsr.prid %0\n"

View File

@ -234,7 +234,7 @@ static inline unsigned portENTER_CRITICAL_NESTED() { unsigned state = XTOS_SET_I
* *bitwise inverse* of the old mem if the mem wasn't written. This doesn't seem to happen on the
* ESP32, though. (Would show up directly if it did because the magic wouldn't match.)
*/
inline void uxPortCompareSet(volatile uint32_t *addr, uint32_t compare, uint32_t *set) {
static inline void uxPortCompareSet(volatile uint32_t *addr, uint32_t compare, uint32_t *set) {
__asm__ __volatile__(
"WSR %2,SCOMPARE1 \n"
"ISYNC \n"

View File

@ -314,8 +314,8 @@ poll_tcp(void *arg, struct tcp_pcb *pcb)
if (conn->flags & NETCONN_FLAG_CHECK_WRITESPACE) {
/* If the queued byte- or pbuf-count drops below the configured low-water limit,
let select mark this pcb as writable again. */
if ((conn->pcb.tcp != NULL) && (tcp_sndbuf(conn->pcb.tcp) > TCP_SNDLOWAT) &&
(tcp_sndqueuelen(conn->pcb.tcp) < TCP_SNDQUEUELOWAT)) {
if ((conn->pcb.tcp != NULL) && (tcp_sndbuf(conn->pcb.tcp) > TCP_SNDLOWAT(conn->pcb.tcp)) &&
(tcp_sndqueuelen(conn->pcb.tcp) < TCP_SNDQUEUELOWAT(conn->pcb.tcp))) {
conn->flags &= ~NETCONN_FLAG_CHECK_WRITESPACE;
API_EVENT(conn, NETCONN_EVT_SENDPLUS, 0);
}
@ -348,8 +348,8 @@ sent_tcp(void *arg, struct tcp_pcb *pcb, u16_t len)
/* If the queued byte- or pbuf-count drops below the configured low-water limit,
let select mark this pcb as writable again. */
if ((conn->pcb.tcp != NULL) && (tcp_sndbuf(conn->pcb.tcp) > TCP_SNDLOWAT) &&
(tcp_sndqueuelen(conn->pcb.tcp) < TCP_SNDQUEUELOWAT)) {
if ((conn->pcb.tcp != NULL) && (tcp_sndbuf(conn->pcb.tcp) > TCP_SNDLOWAT(conn->pcb.tcp) &&
(tcp_sndqueuelen(conn->pcb.tcp) < TCP_SNDQUEUELOWAT(conn->pcb.tcp)))) {
conn->flags &= ~NETCONN_FLAG_CHECK_WRITESPACE;
API_EVENT(conn, NETCONN_EVT_SENDPLUS, len);
}
@ -1540,8 +1540,8 @@ err_mem:
and let poll_tcp check writable space to mark the pcb writable again */
API_EVENT(conn, NETCONN_EVT_SENDMINUS, len);
conn->flags |= NETCONN_FLAG_CHECK_WRITESPACE;
} else if ((tcp_sndbuf(conn->pcb.tcp) <= TCP_SNDLOWAT) ||
(tcp_sndqueuelen(conn->pcb.tcp) >= TCP_SNDQUEUELOWAT)) {
} else if ((tcp_sndbuf(conn->pcb.tcp) <= TCP_SNDLOWAT(conn->pcb.tcp)) ||
(tcp_sndqueuelen(conn->pcb.tcp) >= TCP_SNDQUEUELOWAT(conn->pcb.tcp))) {
/* The queued byte- or pbuf-count exceeds the configured low-water limit,
let select mark this pcb as non-writable. */
API_EVENT(conn, NETCONN_EVT_SENDMINUS, len);

View File

@ -48,6 +48,9 @@ static void dbg_lwip_tcp_pcb_one_show(struct tcp_pcb* pcb)
printf("rttest=%d rtseq=%d sa=%d sv=%d\n", pcb->rttest, pcb->rtseq, pcb->sa, pcb->sv);
printf("rto=%d nrtx=%d\n", pcb->rto, pcb->nrtx);
printf("dupacks=%d lastack=%d\n", pcb->dupacks, pcb->lastack);
#if ESP_PER_SOC_TCP_WND
printf("per_soc_window=%d per_soc_snd_buf=%d\n", pcb->per_soc_tcp_wnd, pcb->per_soc_tcp_snd_buf);
#endif
printf("cwnd=%d ssthreash=%d\n", pcb->cwnd, pcb->ssthresh);
printf("snd_next=%d snd_wl1=%d snd_wl2=%d\n", pcb->snd_nxt, pcb->snd_wl1, pcb->snd_wl2);
printf("snd_lbb=%d snd_wnd=%d snd_wnd_max=%d\n", pcb->snd_lbb, pcb->snd_wnd, pcb->snd_wnd_max);

View File

@ -388,10 +388,8 @@ static void lwip_socket_drop_registered_memberships(int s);
#endif /* LWIP_IGMP */
#ifdef LWIP_ESP8266
/* Since esp_wifi_tx_is_stop/system_get_free_heap_size are not an public wifi API, so extern them here*/
extern size_t system_get_free_heap_size(void);
extern bool esp_wifi_tx_is_stop(void);
#include "esp_wifi_internal.h"
#include "esp_system.h"
/* Please be notified that this flow control is just a workaround for fixing wifi Q full issue.
* Under UDP/TCP pressure test, we found that the sockets may cause wifi tx queue full if the socket
@ -402,9 +400,9 @@ extern bool esp_wifi_tx_is_stop(void);
*/
static inline void esp32_tx_flow_ctrl(void)
{
uint8_t _wait_delay = 0;
uint8_t _wait_delay = 1;
while ((system_get_free_heap_size() < HEAP_HIGHWAT) || esp_wifi_tx_is_stop()){
while ((system_get_free_heap_size() < HEAP_HIGHWAT) || esp_wifi_internal_tx_is_stop()){
vTaskDelay(_wait_delay/portTICK_RATE_MS);
if (_wait_delay < 64) _wait_delay *= 2;
}
@ -2395,6 +2393,16 @@ lwip_getsockopt_impl(int s, int level, int optname, void *optval, socklen_t *opt
s, *(int *)optval));
break;
#endif /* LWIP_TCP_KEEPALIVE */
#if ESP_PER_SOC_TCP_WND
case TCP_WINDOW:
*(int*)optval = (int)sock->conn->pcb.tcp->per_soc_tcp_wnd;
break;
case TCP_SNDBUF:
*(int*)optval = (int)sock->conn->pcb.tcp->per_soc_tcp_snd_buf;
break;
#endif
default:
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_TCP, UNIMPL: optname=0x%x, ..)\n",
s, optname));
@ -2792,6 +2800,16 @@ lwip_setsockopt_impl(int s, int level, int optname, const void *optval, socklen_
s, sock->conn->pcb.tcp->keep_cnt));
break;
#endif /* LWIP_TCP_KEEPALIVE */
#if ESP_PER_SOC_TCP_WND
case TCP_WINDOW:
sock->conn->pcb.tcp->per_soc_tcp_wnd = ((u32_t)(*(const int*)optval)) * TCP_MSS;
break;
case TCP_SNDBUF:
sock->conn->pcb.tcp->per_soc_tcp_snd_buf = ((u32_t)(*(const int*)optval)) * TCP_MSS;
break;
#endif
default:
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_TCP, UNIMPL: optname=0x%x, ..)\n",
s, optname));

View File

@ -135,13 +135,15 @@
//#endif
#else /* LWIP_WND_SCALE */
#ifndef LWIP_ESP8266
#if (ESP_PER_SOC_TCP_WND == 0)
#if (LWIP_TCP && (TCP_WND > 0xffff))
#error "If you want to use TCP, TCP_WND must fit in an u16_t, so, you have to reduce it in your lwipopts.h (or enable window scaling)"
#endif
#endif
#endif /* LWIP_WND_SCALE */
#if (ESP_PER_SOC_TCP_WND == 0)
#if (LWIP_TCP && (TCP_SND_QUEUELEN > 0xffff))
#error "If you want to use TCP, TCP_SND_QUEUELEN must fit in an u16_t, so, you have to reduce it in your lwipopts.h"
#endif
@ -149,7 +151,6 @@
#error "TCP_SND_QUEUELEN must be at least 2 for no-copy TCP writes to work"
#endif
#ifndef LWIP_ESP8266
#if (LWIP_TCP && ((TCP_MAXRTX > 12) || (TCP_SYNMAXRTX > 12)))
#error "If you want to use TCP, TCP_MAXRTX and TCP_SYNMAXRTX must less or equal to 12 (due to tcp_backoff table), so, you have to reduce them in your lwipopts.h"
#endif
@ -289,6 +290,8 @@
#if !MEMP_MEM_MALLOC && (MEMP_NUM_TCP_SEG < TCP_SND_QUEUELEN)
#error "lwip_sanity_check: WARNING: MEMP_NUM_TCP_SEG should be at least as big as TCP_SND_QUEUELEN. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error."
#endif
#if (ESP_PER_SOC_TCP_WND == 0)
#if TCP_SND_BUF < (2 * TCP_MSS)
#error "lwip_sanity_check: WARNING: TCP_SND_BUF must be at least as much as (2 * TCP_MSS) for things to work smoothly. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error."
#endif
@ -304,6 +307,8 @@
#if TCP_SNDQUEUELOWAT >= TCP_SND_QUEUELEN
#error "lwip_sanity_check: WARNING: TCP_SNDQUEUELOWAT must be less than TCP_SND_QUEUELEN. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error."
#endif
#endif
#if !MEMP_MEM_MALLOC && (PBUF_POOL_BUFSIZE <= (PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN))
#error "lwip_sanity_check: WARNING: PBUF_POOL_BUFSIZE does not provide enough space for protocol headers. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error."
#endif
@ -328,13 +333,6 @@
void
lwip_init(void)
{
#ifdef LWIP_ESP8266
// MEMP_NUM_TCP_PCB = 5;
// TCP_WND = (4 * TCP_MSS);
// TCP_MAXRTX = 12;
// TCP_SYNMAXRTX = 6;
#endif
/* Modules initialization */
stats_init();
#if !NO_SYS

View File

@ -83,6 +83,7 @@ static const char mem_debug_file[] ICACHE_RODATA_ATTR STORE_ATTR = __FILE__;
#endif
#ifdef LWIP_ESP8266
#include "esp_wifi_internal.h"
#define EP_OFFSET 0
#endif
@ -764,8 +765,7 @@ pbuf_free(struct pbuf *p)
} else if (type == PBUF_ROM || type == PBUF_REF) {
#ifdef LWIP_ESP8266
extern void system_pp_recycle_rx_pkt(void*);
if (type == PBUF_REF && p->eb != NULL ) system_pp_recycle_rx_pkt(p->eb);
if (type == PBUF_REF && p->eb != NULL ) esp_wifi_internal_free_rx_buffer(p->eb);
#endif
memp_free(MEMP_PBUF, p);

View File

@ -638,7 +638,7 @@ u32_t tcp_update_rcv_ann_wnd(struct tcp_pcb *pcb)
{
u32_t new_right_edge = pcb->rcv_nxt + pcb->rcv_wnd;
if (TCP_SEQ_GEQ(new_right_edge, pcb->rcv_ann_right_edge + LWIP_MIN((TCP_WND / 2), pcb->mss))) {
if (TCP_SEQ_GEQ(new_right_edge, pcb->rcv_ann_right_edge + LWIP_MIN((TCP_WND(pcb) / 2), pcb->mss))) {
/* we can advertise more window */
pcb->rcv_ann_wnd = pcb->rcv_wnd;
return new_right_edge - pcb->rcv_ann_right_edge;
@ -694,10 +694,10 @@ tcp_recved(struct tcp_pcb *pcb, u16_t len)
wnd_inflation = tcp_update_rcv_ann_wnd(pcb);
/* If the change in the right edge of window is significant (default
* watermark is TCP_WND/4), then send an explicit update now.
* watermark is TCP_WND(pcb)/4), then send an explicit update now.
* Otherwise wait for a packet to be sent in the normal course of
* events (or more window to be available later) */
if (wnd_inflation >= TCP_WND_UPDATE_THRESHOLD) {
if (wnd_inflation >= TCP_WND_UPDATE_THRESHOLD(pcb)) {
tcp_ack_now(pcb);
tcp_output(pcb);
}
@ -827,9 +827,9 @@ tcp_connect(struct tcp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port,
pcb->snd_lbb = iss - 1;
/* Start with a window that does not need scaling. When window scaling is
enabled and used, the window is enlarged when both sides agree on scaling. */
pcb->rcv_wnd = pcb->rcv_ann_wnd = TCPWND_MIN16(TCP_WND);
pcb->rcv_wnd = pcb->rcv_ann_wnd = TCPWND_MIN16(TCP_WND(pcb));
pcb->rcv_ann_right_edge = pcb->rcv_nxt;
pcb->snd_wnd = TCP_WND;
pcb->snd_wnd = TCP_WND(pcb);
/* As initial send MSS, we use TCP_MSS but limit it to 536.
The send MSS is updated when an MSS option is received. */
pcb->mss = (TCP_MSS > 536) ? 536 : TCP_MSS;
@ -837,7 +837,7 @@ tcp_connect(struct tcp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port,
pcb->mss = tcp_eff_send_mss(pcb->mss, &pcb->local_ip, &pcb->remote_ip);
#endif /* TCP_CALCULATE_EFF_SEND_MSS */
pcb->cwnd = 1;
pcb->ssthresh = TCP_WND;
pcb->ssthresh = TCP_WND(pcb);
#if LWIP_CALLBACK_API
pcb->connected = connected;
#else /* LWIP_CALLBACK_API */
@ -1581,11 +1581,11 @@ tcp_alloc(u8_t prio)
if (pcb != NULL) {
memset(pcb, 0, sizeof(struct tcp_pcb));
pcb->prio = prio;
pcb->snd_buf = TCP_SND_BUF;
pcb->snd_buf = TCP_SND_BUF_DEFAULT;
pcb->snd_queuelen = 0;
/* Start with a window that does not need scaling. When window scaling is
enabled and used, the window is enlarged when both sides agree on scaling. */
pcb->rcv_wnd = pcb->rcv_ann_wnd = TCPWND_MIN16(TCP_WND);
pcb->rcv_wnd = pcb->rcv_ann_wnd = TCPWND_MIN16(TCP_WND(pcb));
#if LWIP_WND_SCALE
/* snd_scale and rcv_scale are zero unless both sides agree to use scaling */
pcb->snd_scale = 0;
@ -1608,7 +1608,6 @@ tcp_alloc(u8_t prio)
pcb->snd_lbb = iss;
pcb->tmr = tcp_ticks;
pcb->last_timer = tcp_timer_ctr;
pcb->polltmr = 0;
#if LWIP_CALLBACK_API
@ -1624,7 +1623,13 @@ tcp_alloc(u8_t prio)
#endif /* LWIP_TCP_KEEPALIVE */
pcb->keep_cnt_sent = 0;
#if ESP_PER_SOC_TCP_WND
pcb->per_soc_tcp_wnd = TCP_WND_DEFAULT;
pcb->per_soc_tcp_snd_buf = TCP_SND_BUF_DEFAULT;
#endif
}
return pcb;
}

View File

@ -1745,9 +1745,9 @@ tcp_parseopt(struct tcp_pcb *pcb)
pcb->rcv_scale = TCP_RCV_SCALE;
pcb->flags |= TF_WND_SCALE;
/* window scaling is enabled, we can use the full receive window */
LWIP_ASSERT("window not at default value", pcb->rcv_wnd == TCPWND_MIN16(TCP_WND));
LWIP_ASSERT("window not at default value", pcb->rcv_ann_wnd == TCPWND_MIN16(TCP_WND));
pcb->rcv_wnd = pcb->rcv_ann_wnd = TCP_WND;
LWIP_ASSERT("window not at default value", pcb->rcv_wnd == TCPWND_MIN16(TCP_WND(pcb)));
LWIP_ASSERT("window not at default value", pcb->rcv_ann_wnd == TCPWND_MIN16(TCP_WND(pcb)));
pcb->rcv_wnd = pcb->rcv_ann_wnd = TCP_WND(pcb);
}
break;
#endif

View File

@ -336,9 +336,9 @@ tcp_write_checks(struct tcp_pcb *pcb, u16_t len)
/* If total number of pbufs on the unsent/unacked queues exceeds the
* configured maximum, return an error */
/* check for configured max queuelen and possible overflow */
if ((pcb->snd_queuelen >= TCP_SND_QUEUELEN) || (pcb->snd_queuelen > TCP_SNDQUEUELEN_OVERFLOW)) {
if ((pcb->snd_queuelen >= TCP_SND_QUEUELEN(pcb)) || (pcb->snd_queuelen > TCP_SNDQUEUELEN_OVERFLOW)) {
LWIP_DEBUGF(TCP_OUTPUT_DEBUG | LWIP_DBG_LEVEL_SEVERE, ("tcp_write: too long queue %"U16_F" (max %"U16_F")\n",
pcb->snd_queuelen, TCP_SND_QUEUELEN));
pcb->snd_queuelen, TCP_SND_QUEUELEN(pcb)));
TCP_STATS_INC(tcp.memerr);
pcb->flags |= TF_NAGLEMEMERR;
return ERR_MEM;
@ -606,9 +606,9 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags)
/* Now that there are more segments queued, we check again if the
* length of the queue exceeds the configured maximum or
* overflows. */
if ((queuelen > TCP_SND_QUEUELEN) || (queuelen > TCP_SNDQUEUELEN_OVERFLOW)) {
if ((queuelen > TCP_SND_QUEUELEN(pcb)) || (queuelen > TCP_SNDQUEUELEN_OVERFLOW)) {
LWIP_DEBUGF(TCP_OUTPUT_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("tcp_write: queue too long %"U16_F" (%d)\n",
queuelen, (int)TCP_SND_QUEUELEN));
queuelen, (int)TCP_SND_QUEUELEN(pcb)));
pbuf_free(p);
goto memerr;
}
@ -766,10 +766,10 @@ tcp_enqueue_flags(struct tcp_pcb *pcb, u8_t flags)
(flags & (TCP_SYN | TCP_FIN)) != 0);
/* check for configured max queuelen and possible overflow (FIN flag should always come through!) */
if (((pcb->snd_queuelen >= TCP_SND_QUEUELEN) || (pcb->snd_queuelen > TCP_SNDQUEUELEN_OVERFLOW)) &&
if (((pcb->snd_queuelen >= TCP_SND_QUEUELEN(pcb)) || (pcb->snd_queuelen > TCP_SNDQUEUELEN_OVERFLOW)) &&
((flags & TCP_FIN) == 0)) {
LWIP_DEBUGF(TCP_OUTPUT_DEBUG | LWIP_DBG_LEVEL_SEVERE, ("tcp_enqueue_flags: too long queue %"U16_F" (max %"U16_F")\n",
pcb->snd_queuelen, TCP_SND_QUEUELEN));
pcb->snd_queuelen, TCP_SND_QUEUELEN(pcb)));
TCP_STATS_INC(tcp.memerr);
pcb->flags |= TF_NAGLEMEMERR;
return ERR_MEM;
@ -1301,6 +1301,7 @@ tcp_rst(u32_t seqno, u32_t ackno,
struct pbuf *p;
struct tcp_hdr *tcphdr;
struct netif *netif;
p = pbuf_alloc(PBUF_IP, TCP_HLEN, PBUF_RAM);
if (p == NULL) {
LWIP_DEBUGF(TCP_DEBUG, ("tcp_rst: could not allocate memory for pbuf\n"));
@ -1315,10 +1316,18 @@ tcp_rst(u32_t seqno, u32_t ackno,
tcphdr->seqno = htonl(seqno);
tcphdr->ackno = htonl(ackno);
TCPH_HDRLEN_FLAGS_SET(tcphdr, TCP_HLEN/4, TCP_RST | TCP_ACK);
#if ESP_PER_SOC_TCP_WND
#if LWIP_WND_SCALE
tcphdr->wnd = PP_HTONS(((TCP_WND_DEFAULT >> TCP_RCV_SCALE) & 0xFFFF));
#else
tcphdr->wnd = PP_HTONS(TCP_WND_DEFAULT);
#endif
#else
#if LWIP_WND_SCALE
tcphdr->wnd = PP_HTONS(((TCP_WND >> TCP_RCV_SCALE) & 0xFFFF));
#else
tcphdr->wnd = PP_HTONS(TCP_WND);
#endif
#endif
tcphdr->chksum = 0;
tcphdr->urgp = 0;

View File

@ -986,7 +986,7 @@
* (2 * TCP_MSS) for things to work well
*/
#ifndef TCP_WND
#define TCP_WND (4 * TCP_MSS)
#define TCP_WND(pcb) (4 * TCP_MSS)
#endif
/**
@ -1040,7 +1040,7 @@
* To achieve good performance, this should be at least 2 * TCP_MSS.
*/
#ifndef TCP_SND_BUF
#define TCP_SND_BUF (2 * TCP_MSS)
#define TCP_SND_BUF(pcb) (2 * TCP_MSS)
#endif
/**
@ -1048,7 +1048,7 @@
* as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work.
*/
#ifndef TCP_SND_QUEUELEN
#define TCP_SND_QUEUELEN ((4 * (TCP_SND_BUF) + (TCP_MSS - 1))/(TCP_MSS))
#define TCP_SND_QUEUELEN(pcb) ((4 * (TCP_SND_BUF((pcb))) + (TCP_MSS - 1))/(TCP_MSS))
#endif
/**
@ -1057,7 +1057,7 @@
* TCP snd_buf for select to return writable (combined with TCP_SNDQUEUELOWAT).
*/
#ifndef TCP_SNDLOWAT
#define TCP_SNDLOWAT LWIP_MIN(LWIP_MAX(((TCP_SND_BUF)/2), (2 * TCP_MSS) + 1), (TCP_SND_BUF) - 1)
#define TCP_SNDLOWAT(pcb) LWIP_MIN(LWIP_MAX(((TCP_SND_BUF((pcb)))/2), (2 * TCP_MSS) + 1), (TCP_SND_BUF((pcb))) - 1)
#endif
/**
@ -1066,7 +1066,7 @@
* this number, select returns writable (combined with TCP_SNDLOWAT).
*/
#ifndef TCP_SNDQUEUELOWAT
#define TCP_SNDQUEUELOWAT LWIP_MAX(((TCP_SND_QUEUELEN)/2), 5)
#define TCP_SNDQUEUELOWAT(pcb) LWIP_MAX(((TCP_SND_QUEUELEN((pcb)))/2), 5)
#endif
/**
@ -1134,7 +1134,7 @@
* explicit window update
*/
#ifndef TCP_WND_UPDATE_THRESHOLD
#define TCP_WND_UPDATE_THRESHOLD LWIP_MIN((TCP_WND / 4), (TCP_MSS * 4))
#define TCP_WND_UPDATE_THRESHOLD(pcb) LWIP_MIN((TCP_WND((pcb)) / 4), (TCP_MSS * 4))
#endif
/**

View File

@ -92,7 +92,7 @@ err_t tcp_process_refused_data(struct tcp_pcb *pcb);
((tpcb)->flags & (TF_NODELAY | TF_INFR)) || \
(((tpcb)->unsent != NULL) && (((tpcb)->unsent->next != NULL) || \
((tpcb)->unsent->len >= (tpcb)->mss))) || \
((tcp_sndbuf(tpcb) == 0) || (tcp_sndqueuelen(tpcb) >= TCP_SND_QUEUELEN)) \
((tcp_sndbuf(tpcb) == 0) || (tcp_sndqueuelen(tpcb) >= TCP_SND_QUEUELEN(tpcb))) \
) ? 1 : 0)
#define tcp_output_nagle(tpcb) (tcp_do_output_nagle(tpcb) ? tcp_output(tpcb) : ERR_OK)

View File

@ -190,7 +190,6 @@ struct msghdr {
#define SO_CONTIMEO 0x1009 /* Unimplemented: connect timeout */
#define SO_NO_CHECK 0x100a /* don't create UDP checksum */
/*
* Structure used for manipulating linger option.
*/
@ -250,6 +249,11 @@ struct linger {
#define TCP_KEEPIDLE 0x03 /* set pcb->keep_idle - Same as TCP_KEEPALIVE, but use seconds for get/setsockopt */
#define TCP_KEEPINTVL 0x04 /* set pcb->keep_intvl - Use seconds for get/setsockopt */
#define TCP_KEEPCNT 0x05 /* set pcb->keep_cnt - Use number of probes sent for get/setsockopt */
#if ESP_PER_SOC_TCP_WND
#define TCP_WINDOW 0x06 /* set pcb->per_soc_tcp_wnd */
#define TCP_SNDBUF 0x07 /* set pcb->per_soc_tcp_snd_buf */
#endif
#endif /* LWIP_TCP */
#if LWIP_IPV6

View File

@ -129,14 +129,14 @@ typedef err_t (*tcp_connected_fn)(void *arg, struct tcp_pcb *tpcb, err_t err);
#define RCV_WND_SCALE(pcb, wnd) (((wnd) >> (pcb)->rcv_scale))
#define SND_WND_SCALE(pcb, wnd) (((wnd) << (pcb)->snd_scale))
#define TCPWND16(x) ((u16_t)LWIP_MIN((x), 0xFFFF))
#define TCP_WND_MAX(pcb) ((tcpwnd_size_t)(((pcb)->flags & TF_WND_SCALE) ? TCP_WND : TCPWND16(TCP_WND)))
#define TCP_WND_MAX(pcb) ((tcpwnd_size_t)(((pcb)->flags & TF_WND_SCALE) ? TCP_WND(pcb) : TCPWND16(TCP_WND(pcb))))
typedef u32_t tcpwnd_size_t;
typedef u16_t tcpflags_t;
#else
#define RCV_WND_SCALE(pcb, wnd) (wnd)
#define SND_WND_SCALE(pcb, wnd) (wnd)
#define TCPWND16(x) (x)
#define TCP_WND_MAX(pcb) TCP_WND
#define TCP_WND_MAX(pcb) TCP_WND(pcb)
typedef u16_t tcpwnd_size_t;
typedef u8_t tcpflags_t;
#endif
@ -236,6 +236,11 @@ struct tcp_pcb {
u8_t dupacks;
u32_t lastack; /* Highest acknowledged seqno. */
#if ESP_PER_SOC_TCP_WND
tcpwnd_size_t per_soc_tcp_wnd; /* per tcp socket tcp window size */
tcpwnd_size_t per_soc_tcp_snd_buf; /* per tcp socket tcp send buffer size */
#endif
/* congestion avoidance/control variables */
tcpwnd_size_t cwnd;
tcpwnd_size_t ssthresh;
@ -402,6 +407,10 @@ const char* tcp_debug_state_str(enum tcp_state s);
/* for compatibility with older implementation */
#define tcp_new_ip6() tcp_new_ip_type(IPADDR_TYPE_V6)
#if ESP_PER_SOC_TCP_WND
#define PER_SOC_WND(pcb) (pcb->per_soc_wnd)
#endif
#ifdef __cplusplus
}
#endif

View File

@ -225,18 +225,21 @@ extern unsigned long os_random(void);
* TCP_WND: The size of a TCP window. This must be at least
* (2 * TCP_MSS) for things to work well
*/
#define PERF 1
#define ESP_PER_SOC_TCP_WND 1
#if ESP_PER_SOC_TCP_WND
#define TCP_WND_DEFAULT (4*TCP_MSS)
#define TCP_SND_BUF_DEFAULT (2*TCP_MSS)
#define TCP_WND(pcb) (pcb->per_soc_tcp_wnd)
#define TCP_SND_BUF(pcb) (pcb->per_soc_tcp_snd_buf)
#else
#ifdef PERF
extern unsigned char misc_prof_get_tcpw(void);
extern unsigned char misc_prof_get_tcp_snd_buf(void);
#define TCP_WND (misc_prof_get_tcpw()*TCP_MSS)
#define TCP_SND_BUF (misc_prof_get_tcp_snd_buf()*TCP_MSS)
#else
#define TCP_WND (4 * TCP_MSS)
#define TCP_SND_BUF (2 * TCP_MSS)
#define TCP_WND(pcb) (misc_prof_get_tcpw()*TCP_MSS)
#define TCP_SND_BUF(pcb) (misc_prof_get_tcp_snd_buf()*TCP_MSS)
#endif
#endif

View File

@ -8,6 +8,8 @@
#include "esp_wifi.h"
#include "esp_wifi_internal.h"
#include "lwip/err.h"
#ifdef __cplusplus
@ -18,8 +20,6 @@ err_t wlanif_init(struct netif *netif);
void wlanif_input(struct netif *netif, void *buffer, u16_t len, void* eb);
bool ieee80211_output(wifi_interface_t wifi_if, void *buffer, u16_t len);
wifi_interface_t wifi_get_interface(void *dev);
void netif_reg_addr_change_cb(void* cb);

View File

@ -150,12 +150,12 @@ low_level_output(struct netif *netif, struct pbuf *p)
}
}
ieee80211_output(wifi_if, q->payload, pbuf_x_len);
esp_wifi_internal_tx(wifi_if, q->payload, pbuf_x_len);
return ERR_OK;
#else
for(q = p; q != NULL; q = q->next) {
ieee80211_output(wifi_if, q->payload, q->len);
esp_wifi_internal_tx(wifi_if, q->payload, q->len);
}
#endif

View File

@ -67,11 +67,15 @@ typedef struct {
typedef dhcps_lease_t tcpip_adapter_dhcps_lease_t;
#if CONFIG_DHCP_STA_LIST
struct station_list {
STAILQ_ENTRY(station_list) next;
typedef struct {
uint8_t mac[6];
ip4_addr_t ip;
};
}tcpip_adapter_sta_info_t;
typedef struct {
tcpip_adapter_sta_info_t sta[ESP_WIFI_MAX_CONN_NUM+2];
uint8_t num;
}tcpip_adapter_sta_list_t;
#endif
#endif
@ -359,26 +363,14 @@ wifi_interface_t tcpip_adapter_get_wifi_if(void *dev);
/**
* @brief Get the station information list
*
* @note This function should be called in AP mode and dhcp server started, and the list should
* be by using tcpip_adapter_free_sta_list.
*
* @param[in] sta_info: station information
* @param[out] sta_list: station information list
* @param[in] wifi_sta_list_t *wifi_sta_list: station list info
* @param[out] tcpip_adapter_sta_list_t *tcpip_sta_list: station list info
*
* @return ESP_OK
* ESP_ERR_TCPIP_ADAPTER_NO_MEM
* ESP_ERR_TCPIP_ADAPTER_INVALID_PARAMS
*/
esp_err_t tcpip_adapter_get_sta_list(struct station_info *sta_info, struct station_list **sta_list);
/**
* @brief Free the station information list's memory
*
* @param sta_list: station information list
*
* @return ESP_OK
*/
esp_err_t tcpip_adapter_free_sta_list(struct station_list *sta_list);
esp_err_t tcpip_adapter_get_sta_list(wifi_sta_list_t *wifi_sta_list, tcpip_adapter_sta_list_t *tcpip_sta_list);
#ifdef __cplusplus
}

View File

@ -103,7 +103,9 @@ esp_err_t tcpip_adapter_stop(tcpip_adapter_if_t tcpip_if)
if (tcpip_if == TCPIP_ADAPTER_IF_AP) {
dhcps_stop(esp_netif[tcpip_if]); // TODO: dhcps checks status by its self
dhcps_status = TCPIP_ADAPTER_DHCP_INIT;
if (TCPIP_ADAPTER_DHCP_STOPPED != dhcps_status){
dhcps_status = TCPIP_ADAPTER_DHCP_INIT;
}
} else if (tcpip_if == TCPIP_ADAPTER_IF_STA) {
dhcp_release(esp_netif[tcpip_if]);
dhcp_stop(esp_netif[tcpip_if]);
@ -588,45 +590,17 @@ wifi_interface_t tcpip_adapter_get_wifi_if(void *dev)
return WIFI_IF_MAX;
}
esp_err_t tcpip_adapter_get_sta_list(struct station_info *sta_info, struct station_list **sta_list)
esp_err_t tcpip_adapter_get_sta_list(wifi_sta_list_t *wifi_sta_list, tcpip_adapter_sta_list_t *tcpip_sta_list)
{
struct station_info *info = sta_info;
struct station_list *list;
STAILQ_HEAD(, station_list) list_head;
int i;
if (sta_list == NULL)
if ((wifi_sta_list == NULL) || (tcpip_sta_list == NULL))
return ESP_ERR_TCPIP_ADAPTER_INVALID_PARAMS;
STAILQ_INIT(&list_head);
while (info != NULL) {
list = (struct station_list *)malloc(sizeof(struct station_list));
memset(list, 0, sizeof (struct station_list));
if (list == NULL) {
return ESP_ERR_TCPIP_ADAPTER_NO_MEM;
}
memcpy(list->mac, info->bssid, 6);
dhcp_search_ip_on_mac(list->mac, &list->ip);
STAILQ_INSERT_TAIL(&list_head, list, next);
info = STAILQ_NEXT(info, next);
}
*sta_list = STAILQ_FIRST(&list_head);
return ESP_OK;
}
esp_err_t tcpip_adapter_free_sta_list(struct station_list *sta_list)
{
struct station_list *list = sta_list;
while (sta_list != NULL) {
list = sta_list;
sta_list = STAILQ_NEXT(sta_list, next);
free(list);
memset(tcpip_sta_list, 0, sizeof(tcpip_adapter_sta_list_t));
for (i=0; i<wifi_sta_list->num; i++){
memcpy(tcpip_sta_list->sta[i].mac, wifi_sta_list->sta[i].mac, 6);
dhcp_search_ip_on_mac(tcpip_sta_list->sta[i].mac, &tcpip_sta_list->sta[i].ip);
}
return ESP_OK;