kopia lustrzana https://github.com/espressif/esp-idf
Merge branch 'optimization/config_option_LWIP_TCPIP_CORE_LOCKING' into 'master'
optimization config option LWIP_TCPIP_CORE_LOCKING Closes IDF-2478 See merge request espressif/esp-idf!11809pull/7497/head
commit
cec0f5edfb
|
@ -101,11 +101,13 @@ extern sys_thread_t g_lwip_task;
|
|||
|
||||
static const char *TAG = "esp_netif_lwip";
|
||||
|
||||
static sys_sem_t api_sync_sem = NULL;
|
||||
static sys_sem_t api_lock_sem = NULL;
|
||||
static bool tcpip_initialized = false;
|
||||
static esp_netif_t *s_last_default_esp_netif = NULL;
|
||||
|
||||
#if !LWIP_TCPIP_CORE_LOCKING
|
||||
static sys_sem_t api_sync_sem = NULL;
|
||||
static sys_sem_t api_lock_sem = NULL;
|
||||
|
||||
/**
|
||||
* @brief Api callback from tcpip thread used to call esp-netif
|
||||
* function in lwip task context
|
||||
|
@ -124,6 +126,7 @@ static void esp_netif_api_cb(void *api_msg)
|
|||
sys_sem_signal(&api_sync_sem);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Initiates a tcpip remote call if called from another task
|
||||
|
@ -136,6 +139,7 @@ static inline esp_err_t esp_netif_lwip_ipc_call(esp_netif_api_fn fn, esp_netif_t
|
|||
.data = data,
|
||||
.api_fn = fn
|
||||
};
|
||||
#if !LWIP_TCPIP_CORE_LOCKING
|
||||
if (g_lwip_task != xTaskGetCurrentTaskHandle()) {
|
||||
ESP_LOGD(TAG, "check: remote, if=%p fn=%p\n", netif, fn);
|
||||
sys_arch_sem_wait(&api_lock_sem, 0);
|
||||
|
@ -143,6 +147,7 @@ static inline esp_err_t esp_netif_lwip_ipc_call(esp_netif_api_fn fn, esp_netif_t
|
|||
sys_sem_signal(&api_lock_sem);
|
||||
return msg.ret;
|
||||
}
|
||||
#endif /* !LWIP_TCPIP_CORE_LOCKING */
|
||||
ESP_LOGD(TAG, "check: local, if=%p fn=%p\n", netif, fn);
|
||||
return fn(&msg);
|
||||
}
|
||||
|
@ -324,6 +329,7 @@ esp_err_t esp_netif_init(void)
|
|||
ESP_LOGD(TAG, "LwIP stack has been initialized");
|
||||
}
|
||||
|
||||
#if !LWIP_TCPIP_CORE_LOCKING
|
||||
if (!api_sync_sem) {
|
||||
if (ERR_OK != sys_sem_new(&api_sync_sem, 0)) {
|
||||
ESP_LOGE(TAG, "esp netif api sync sem init fail");
|
||||
|
@ -337,6 +343,7 @@ esp_err_t esp_netif_init(void)
|
|||
return ESP_FAIL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
ESP_LOGD(TAG, "esp-netif has been successfully initialized");
|
||||
return ESP_OK;
|
||||
|
|
|
@ -52,7 +52,11 @@
|
|||
#define ESP_TASK_TIMER_PRIO (ESP_TASK_PRIO_MAX - 3)
|
||||
#define ESP_TASK_TIMER_STACK (CONFIG_ESP_TIMER_TASK_STACK_SIZE + TASK_EXTRA_STACK_SIZE)
|
||||
#define ESP_TASKD_EVENT_PRIO (ESP_TASK_PRIO_MAX - 5)
|
||||
#if CONFIG_LWIP_TCPIP_CORE_LOCKING
|
||||
#define ESP_TASKD_EVENT_STACK (CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE + TASK_EXTRA_STACK_SIZE + 2048)
|
||||
#else
|
||||
#define ESP_TASKD_EVENT_STACK (CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE + TASK_EXTRA_STACK_SIZE)
|
||||
#endif /* CONFIG_LWIP_TCPIP_CORE_LOCKING */
|
||||
#define ESP_TASK_TCPIP_PRIO (ESP_TASK_PRIO_MAX - 7)
|
||||
#define ESP_TASK_TCPIP_STACK (CONFIG_LWIP_TCPIP_TASK_STACK_SIZE + TASK_EXTRA_STACK_SIZE)
|
||||
#define ESP_TASK_MAIN_PRIO (ESP_TASK_PRIO_MIN + 1)
|
||||
|
|
|
@ -15,6 +15,16 @@ menu "LWIP"
|
|||
could be used to convert network interface index to name
|
||||
instead of IDF specific esp-netif APIs (such as esp_netif_get_netif_impl_name())
|
||||
|
||||
config LWIP_TCPIP_CORE_LOCKING
|
||||
bool "Enable tcpip core locking"
|
||||
default n
|
||||
help
|
||||
If Enable tcpip core locking,Creates a global mutex that is held
|
||||
during TCPIP thread operations.Can be locked by client code to perform
|
||||
lwIP operations without changing into TCPIP thread using callbacks.
|
||||
See LOCK_TCPIP_CORE() and UNLOCK_TCPIP_CORE().
|
||||
|
||||
If disable tcpip core locking,TCP IP will perform tasks through context switching.
|
||||
|
||||
config LWIP_DNS_SUPPORT_MDNS_QUERIES
|
||||
bool "Enable mDNS queries in resolving host name"
|
||||
|
|
|
@ -594,7 +594,7 @@
|
|||
* LWIP_TCPIP_CORE_LOCKING: (EXPERIMENTAL!)
|
||||
* Don't use it if you're not an active lwIP project member
|
||||
*/
|
||||
#define LWIP_TCPIP_CORE_LOCKING 0
|
||||
#define LWIP_TCPIP_CORE_LOCKING CONFIG_LWIP_TCPIP_CORE_LOCKING
|
||||
|
||||
/*
|
||||
------------------------------------
|
||||
|
@ -1052,7 +1052,11 @@
|
|||
#define CHECKSUM_CHECK_ICMP CONFIG_LWIP_CHECKSUM_CHECK_ICMP
|
||||
|
||||
#define LWIP_NETCONN_FULLDUPLEX 1
|
||||
#if LWIP_TCPIP_CORE_LOCKING
|
||||
#define LWIP_NETCONN_SEM_PER_THREAD 0
|
||||
#else
|
||||
#define LWIP_NETCONN_SEM_PER_THREAD 1
|
||||
#endif /* LWIP_TCPIP_CORE_LOCKING */
|
||||
|
||||
#define LWIP_DHCP_MAX_NTP_SERVERS CONFIG_LWIP_DHCP_MAX_NTP_SERVERS
|
||||
#define LWIP_TIMEVAL_PRIVATE 0
|
||||
|
|
Ładowanie…
Reference in New Issue