Merge branch 'feature/run_esp32c3_code_on_esp32_and_esp32s2' into 'master'

Feature/run esp32c3 code on esp32 and esp32s2

See merge request espressif/esp-idf!10213
This commit is contained in:
Jiang Jiang Jian 2020-09-24 13:27:47 +08:00
commit e093eb064c
16 changed files with 585 additions and 558 deletions

View File

@ -217,11 +217,11 @@ extern int bredr_txpwr_get(int *min_power_level, int *max_power_level);
extern void bredr_sco_datapath_set(uint8_t data_path);
extern void btdm_controller_scan_duplicate_list_clear(void);
/* Coexistence */
extern int coex_bt_request_wrapper(uint32_t event, uint32_t latency, uint32_t duration);
extern int coex_bt_release_wrapper(uint32_t event);
extern int coex_register_bt_cb_wrapper(coex_func_cb_t cb);
extern uint32_t coex_bb_reset_lock_wrapper(void);
extern void coex_bb_reset_unlock_wrapper(uint32_t restore);
extern int coex_bt_request(uint32_t event, uint32_t latency, uint32_t duration);
extern int coex_bt_release(uint32_t event);
extern int coex_register_bt_cb(coex_func_cb_t cb);
extern uint32_t coex_bb_reset_lock(void);
extern void coex_bb_reset_unlock(uint32_t restore);
extern void coex_ble_adv_priority_high_set(bool high);
extern char _bss_start_btdm;
@ -288,6 +288,11 @@ static void IRAM_ATTR btdm_sleep_exit_phase1_wrapper(void);
static void btdm_sleep_exit_phase3_wrapper(void);
static bool coex_bt_wakeup_request(void);
static void coex_bt_wakeup_request_end(void);
static int coex_bt_request_wrapper(uint32_t event, uint32_t latency, uint32_t duration);
static int coex_bt_release_wrapper(uint32_t event);
static int coex_register_bt_cb_wrapper(coex_func_cb_t cb);
static uint32_t coex_bb_reset_lock_wrapper(void);
static void coex_bb_reset_unlock_wrapper(uint32_t restore);
/* Local variable definition
***************************************************************************
@ -850,14 +855,13 @@ static void btdm_sleep_enter_phase1_wrapper(uint32_t lpcycles)
static void btdm_sleep_enter_phase2_wrapper(void)
{
if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_ORIG) {
esp_modem_sleep_enter(MODEM_BLE_MODULE);
esp_modem_sleep_enter(MODEM_CLASSIC_BT_MODULE);
esp_phy_disable();
#ifdef CONFIG_PM_ENABLE
esp_pm_lock_release(s_pm_lock);
semphr_give_wrapper(s_pm_lock_sem);
#endif
} else if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_EVED) {
esp_modem_sleep_enter(MODEM_BLE_MODULE);
esp_phy_disable();
// pause bluetooth baseband
periph_module_disable(PERIPH_BT_BASEBAND_MODULE);
}
@ -875,8 +879,7 @@ static void IRAM_ATTR btdm_sleep_exit_phase1_wrapper(void)
static void btdm_sleep_exit_phase3_wrapper(void)
{
if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_ORIG) {
esp_modem_sleep_exit(MODEM_BLE_MODULE);
esp_modem_sleep_exit(MODEM_CLASSIC_BT_MODULE);
esp_phy_enable();
btdm_check_and_init_bb();
#ifdef CONFIG_PM_ENABLE
esp_timer_stop(s_btdm_slp_tmr);
@ -884,7 +887,7 @@ static void btdm_sleep_exit_phase3_wrapper(void)
} else if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_EVED) {
// resume bluetooth baseband
periph_module_enable(PERIPH_BT_BASEBAND_MODULE);
esp_modem_sleep_exit(MODEM_BLE_MODULE);
esp_phy_enable();
}
}
@ -963,6 +966,49 @@ static void coex_bt_wakeup_request_end(void)
return;
}
int IRAM_ATTR coex_bt_request_wrapper(uint32_t event, uint32_t latency, uint32_t duration)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_bt_request(event, latency, duration);
#else
return 0;
#endif
}
int IRAM_ATTR coex_bt_release_wrapper(uint32_t event)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_bt_release(event);
#else
return 0;
#endif
}
int coex_register_bt_cb_wrapper(coex_func_cb_t cb)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_register_bt_cb(cb);
#else
return 0;
#endif
}
uint32_t IRAM_ATTR coex_bb_reset_lock_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_bb_reset_lock();
#else
return 0;
#endif
}
void IRAM_ATTR coex_bb_reset_unlock_wrapper(uint32_t restore)
{
#if CONFIG_SW_COEXIST_ENABLE
coex_bb_reset_unlock(restore);
#endif
}
bool esp_vhci_host_check_send_available(void)
{
return API_vhci_host_check_send_available();
@ -1273,6 +1319,10 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
}
#endif
#if CONFIG_SW_COEXIST_ENABLE
coex_init();
#endif
btdm_cfg_mask = btdm_config_mask_load();
if (btdm_controller_init(btdm_cfg_mask, cfg) != 0) {
@ -1375,21 +1425,11 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
esp_pm_lock_acquire(s_pm_lock);
#endif
esp_phy_load_cal_and_init(PHY_BT_MODULE);
esp_phy_enable();
if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_NONE) {
//Just register to sleep module, make the modem sleep modules check BT sleep status when sleep enter.
//Thus, it will prevent WIFI from disabling RF when BT is not in sleep but is using RF.
esp_modem_sleep_register(MODEM_BLE_MODULE);
esp_modem_sleep_register(MODEM_CLASSIC_BT_MODULE);
esp_modem_sleep_exit(MODEM_BLE_MODULE);
esp_modem_sleep_exit(MODEM_CLASSIC_BT_MODULE);
} else if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_ORIG) {
esp_modem_sleep_register(MODEM_BLE_MODULE);
esp_modem_sleep_register(MODEM_CLASSIC_BT_MODULE);
} else if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_EVED) {
esp_modem_sleep_register(MODEM_BLE_MODULE);
}
#if CONFIG_SW_COEXIST_ENABLE
coex_enable();
#endif
if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_ORIG) {
btdm_controller_enable_sleep(true);
@ -1399,15 +1439,11 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
btdm_check_and_init_bb();
ret = btdm_controller_enable(mode);
if (ret) {
if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_NONE
|| btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_ORIG) {
esp_modem_sleep_deregister(MODEM_BLE_MODULE);
esp_modem_sleep_deregister(MODEM_CLASSIC_BT_MODULE);
} else if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_EVED) {
esp_modem_sleep_deregister(MODEM_BLE_MODULE);
}
esp_phy_rf_deinit(PHY_BT_MODULE);
if (ret != 0) {
#if CONFIG_SW_COEXIST_ENABLE
coex_disable();
#endif
esp_phy_disable();
#ifdef CONFIG_PM_ENABLE
if (!s_btdm_allow_light_sleep) {
esp_pm_lock_release(s_light_sleep_pm_lock);
@ -1441,14 +1477,11 @@ esp_err_t esp_bt_controller_disable(void)
btdm_controller_disable();
if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_NONE
|| btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_ORIG) {
esp_modem_sleep_deregister(MODEM_BLE_MODULE);
esp_modem_sleep_deregister(MODEM_CLASSIC_BT_MODULE);
} else if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_EVED) {
esp_modem_sleep_deregister(MODEM_BLE_MODULE);
}
esp_phy_rf_deinit(PHY_BT_MODULE);
#if CONFIG_SW_COEXIST_ENABLE
coex_disable();
#endif
esp_phy_disable();
btdm_controller_status = ESP_BT_CONTROLLER_STATUS_INITED;
#ifdef CONFIG_PM_ENABLE
@ -1515,13 +1548,8 @@ esp_err_t esp_bt_sleep_enable (void)
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_ENABLED) {
return ESP_ERR_INVALID_STATE;
}
if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_ORIG) {
esp_modem_sleep_register(MODEM_BLE_MODULE);
esp_modem_sleep_register(MODEM_CLASSIC_BT_MODULE);
btdm_controller_enable_sleep (true);
status = ESP_OK;
} else if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_EVED) {
esp_modem_sleep_register(MODEM_BLE_MODULE);
if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_ORIG ||
btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_EVED) {
btdm_controller_enable_sleep (true);
status = ESP_OK;
} else {
@ -1537,13 +1565,8 @@ esp_err_t esp_bt_sleep_disable (void)
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_ENABLED) {
return ESP_ERR_INVALID_STATE;
}
if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_ORIG) {
esp_modem_sleep_deregister(MODEM_BLE_MODULE);
esp_modem_sleep_deregister(MODEM_CLASSIC_BT_MODULE);
btdm_controller_enable_sleep (false);
status = ESP_OK;
} else if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_EVED) {
esp_modem_sleep_deregister(MODEM_BLE_MODULE);
if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_ORIG ||
btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_EVED) {
btdm_controller_enable_sleep (false);
status = ESP_OK;
} else {

@ -1 +1 @@
Subproject commit d2fd8129aaea47408a76590508443192d82fe2f1
Subproject commit 97375274e9446551835697c23357e23f3cf23146

View File

@ -399,12 +399,10 @@ esp_pm_config_esp32s2_t cfg = {
#endif
#endif
#if CONFIG_IDF_TARGET_ESP32
#if CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE
#if CONFIG_SW_COEXIST_ENABLE
esp_coex_adapter_register(&g_coex_adapter_funcs);
coex_pre_init();
#endif
#endif
#ifdef CONFIG_BOOTLOADER_EFUSE_SECURE_VERSION_EMULATE
const esp_partition_t *efuse_partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_EFUSE_EM, NULL);

View File

@ -51,6 +51,11 @@
#define TAG "esp_adapter"
#ifdef CONFIG_PM_ENABLE
extern void wifi_apb80m_request(void);
extern void wifi_apb80m_release(void);
#endif
static void IRAM_ATTR s_esp_dport_access_stall_other_cpu_start(void)
{
DPORT_STALL_OTHER_CPU_START();
@ -174,6 +179,25 @@ static void wifi_delete_queue_wrapper(void *queue)
wifi_delete_queue(queue);
}
static bool IRAM_ATTR env_is_chip_wrapper(void)
{
#ifdef CONFIG_IDF_ENV_FPGA
return false;
#else
return true;
#endif
}
static void set_intr_wrapper(int32_t cpu_no, uint32_t intr_source, uint32_t intr_num, int32_t intr_prio)
{
intr_matrix_set(cpu_no, intr_source, intr_num);
}
static void clear_intr_wrapper(uint32_t intr_source, uint32_t intr_num)
{
}
static void set_isr_wrapper(int32_t n, void *f, void *arg)
{
xt_set_interrupt_handler(n, (xt_handler)f, arg);
@ -213,7 +237,7 @@ static void IRAM_ATTR wifi_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp)
static bool IRAM_ATTR is_from_isr_wrapper(void)
{
return xPortInIsrContext();
return !xPortCanYield();
}
static void IRAM_ATTR task_yield_from_isr_wrapper(void)
@ -391,6 +415,20 @@ static int32_t esp_event_post_wrapper(const char* event_base, int32_t event_id,
}
}
static void IRAM_ATTR wifi_apb80m_request_wrapper(void)
{
#ifdef CONFIG_PM_ENABLE
wifi_apb80m_request();
#endif
}
static void IRAM_ATTR wifi_apb80m_release_wrapper(void)
{
#ifdef CONFIG_PM_ENABLE
wifi_apb80m_release();
#endif
}
static void IRAM_ATTR timer_arm_wrapper(void *timer, uint32_t tmout, bool repeat)
{
ets_timer_arm(timer, tmout, repeat);
@ -461,9 +499,41 @@ static void * IRAM_ATTR zalloc_internal_wrapper(size_t size)
return ptr;
}
static uint32_t coex_status_get_wrapper(void)
static int coex_init_wrapper(void)
{
#if CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE
#if CONFIG_SW_COEXIST_ENABLE
return coex_init();
#else
return 0;
#endif
}
static void coex_deinit_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
coex_deinit();
#endif
}
static int coex_enable_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_enable();
#else
return 0;
#endif
}
static void coex_disable_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
coex_disable();
#endif
}
static IRAM_ATTR uint32_t coex_status_get_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_status_get();
#else
return 0;
@ -479,65 +549,118 @@ static void coex_condition_set_wrapper(uint32_t type, bool dissatisfy)
static int coex_wifi_request_wrapper(uint32_t event, uint32_t latency, uint32_t duration)
{
#if CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE
#if CONFIG_SW_COEXIST_ENABLE
return coex_wifi_request(event, latency, duration);
#else
return 0;
#endif
}
static int coex_wifi_release_wrapper(uint32_t event)
static IRAM_ATTR int coex_wifi_release_wrapper(uint32_t event)
{
#if CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE
#if CONFIG_SW_COEXIST_ENABLE
return coex_wifi_release(event);
#else
return 0;
#endif
}
int IRAM_ATTR coex_bt_request_wrapper(uint32_t event, uint32_t latency, uint32_t duration)
static int coex_wifi_channel_set_wrapper(uint8_t primary, uint8_t secondary)
{
#if CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE
return coex_bt_request(event, latency, duration);
#if CONFIG_SW_COEXIST_ENABLE
return coex_wifi_channel_set(primary, secondary);
#else
return 0;
#endif
}
int IRAM_ATTR coex_bt_release_wrapper(uint32_t event)
static IRAM_ATTR int coex_event_duration_get_wrapper(uint32_t event, uint32_t *duration)
{
#if CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE
return coex_bt_release(event);
#if CONFIG_SW_COEXIST_ENABLE
return coex_event_duration_get(event, duration);
#else
return 0;
#endif
}
int coex_register_bt_cb_wrapper(coex_func_cb_t cb)
static int coex_pti_get_wrapper(uint32_t event, uint8_t *pti)
{
#if CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE
return coex_register_bt_cb(cb);
return 0;
}
static void coex_schm_status_bit_clear_wrapper(uint32_t type, uint32_t status)
{
#if CONFIG_SW_COEXIST_ENABLE
coex_schm_status_bit_clear(type, status);
#endif
}
static void coex_schm_status_bit_set_wrapper(uint32_t type, uint32_t status)
{
#if CONFIG_SW_COEXIST_ENABLE
coex_schm_status_bit_set(type, status);
#endif
}
static IRAM_ATTR int coex_schm_interval_set_wrapper(uint32_t interval)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_schm_interval_set(interval);
#else
return 0;
#endif
}
uint32_t IRAM_ATTR coex_bb_reset_lock_wrapper(void)
static uint32_t coex_schm_interval_get_wrapper(void)
{
#if CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE
return coex_bb_reset_lock();
#if CONFIG_SW_COEXIST_ENABLE
return coex_schm_interval_get();
#else
return 0;
#endif
}
void IRAM_ATTR coex_bb_reset_unlock_wrapper(uint32_t restore)
static uint8_t coex_schm_curr_period_get_wrapper(void)
{
#if CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE
coex_bb_reset_unlock(restore);
#if CONFIG_SW_COEXIST_ENABLE
return coex_schm_curr_period_get();
#else
return 0;
#endif
}
static void * coex_schm_curr_phase_get_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_schm_curr_phase_get();
#else
return NULL;
#endif
}
static int coex_schm_curr_phase_idx_set_wrapper(int idx)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_schm_curr_phase_idx_set(idx);
#else
return 0;
#endif
}
static int coex_schm_curr_phase_idx_get_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_schm_curr_phase_idx_get();
#else
return 0;
#endif
}
static void IRAM_ATTR esp_empty_wrapper(void)
{
}
int32_t IRAM_ATTR coex_is_in_isr_wrapper(void)
{
return !xPortCanYield();
@ -545,9 +668,13 @@ int32_t IRAM_ATTR coex_is_in_isr_wrapper(void)
wifi_osi_funcs_t g_wifi_osi_funcs = {
._version = ESP_WIFI_OS_ADAPTER_VERSION,
._env_is_chip = env_is_chip_wrapper,
._set_intr = set_intr_wrapper,
._clear_intr = clear_intr_wrapper,
._set_isr = set_isr_wrapper,
._ints_on = xt_ints_on,
._ints_off = xt_ints_off,
._is_from_isr = is_from_isr_wrapper,
._spin_lock_create = spin_lock_create_wrapper,
._spin_lock_delete = free,
._wifi_int_disable = wifi_int_disable_wrapper,
@ -590,8 +717,10 @@ wifi_osi_funcs_t g_wifi_osi_funcs = {
._rand = esp_random,
._dport_access_stall_other_cpu_start_wrap = s_esp_dport_access_stall_other_cpu_start,
._dport_access_stall_other_cpu_end_wrap = s_esp_dport_access_stall_other_cpu_end,
._phy_rf_deinit = esp_phy_rf_deinit,
._phy_load_cal_and_init = esp_phy_load_cal_and_init,
._wifi_apb80m_request = wifi_apb80m_request_wrapper,
._wifi_apb80m_release = wifi_apb80m_release_wrapper,
._phy_disable = esp_phy_disable,
._phy_enable = esp_phy_enable,
._phy_common_clock_enable = esp_phy_common_clock_enable,
._phy_common_clock_disable = esp_phy_common_clock_disable,
._phy_update_country_info = esp_phy_update_country_info,
@ -604,6 +733,8 @@ wifi_osi_funcs_t g_wifi_osi_funcs = {
._wifi_reset_mac = wifi_reset_mac_wrapper,
._wifi_clock_enable = wifi_clock_enable_wrapper,
._wifi_clock_disable = wifi_clock_disable_wrapper,
._wifi_rtc_enable_iso = esp_empty_wrapper,
._wifi_rtc_disable_iso = esp_empty_wrapper,
._esp_timer_get_time = esp_timer_get_time,
._nvs_set_i8 = nvs_set_i8,
._nvs_get_i8 = nvs_get_i8,
@ -633,15 +764,25 @@ wifi_osi_funcs_t g_wifi_osi_funcs = {
._wifi_zalloc = wifi_zalloc_wrapper,
._wifi_create_queue = wifi_create_queue_wrapper,
._wifi_delete_queue = wifi_delete_queue_wrapper,
._modem_sleep_enter = esp_modem_sleep_enter,
._modem_sleep_exit = esp_modem_sleep_exit,
._modem_sleep_register = esp_modem_sleep_register,
._modem_sleep_deregister = esp_modem_sleep_deregister,
._coex_init = coex_init_wrapper,
._coex_deinit = coex_deinit_wrapper,
._coex_enable = coex_enable_wrapper,
._coex_disable = coex_disable_wrapper,
._coex_status_get = coex_status_get_wrapper,
._coex_condition_set = coex_condition_set_wrapper,
._coex_wifi_request = coex_wifi_request_wrapper,
._coex_wifi_release = coex_wifi_release_wrapper,
._is_from_isr = is_from_isr_wrapper,
._coex_wifi_channel_set = coex_wifi_channel_set_wrapper,
._coex_event_duration_get = coex_event_duration_get_wrapper,
._coex_pti_get = coex_pti_get_wrapper,
._coex_schm_status_bit_clear = coex_schm_status_bit_clear_wrapper,
._coex_schm_status_bit_set = coex_schm_status_bit_set_wrapper,
._coex_schm_interval_set = coex_schm_interval_set_wrapper,
._coex_schm_interval_get = coex_schm_interval_get_wrapper,
._coex_schm_curr_period_get = coex_schm_curr_period_get_wrapper,
._coex_schm_curr_phase_get = coex_schm_curr_phase_get_wrapper,
._coex_schm_curr_phase_idx_set = coex_schm_curr_phase_idx_set_wrapper,
._coex_schm_curr_phase_idx_get = coex_schm_curr_phase_idx_get_wrapper,
._magic = ESP_WIFI_OS_ADAPTER_MAGIC,
};

View File

@ -46,11 +46,14 @@
#include "nvs.h"
#include "os.h"
#include "esp_smartconfig.h"
#include "esp_coexist_internal.h"
#include "esp_coexist_adapter.h"
#define TAG "esp_adapter"
#ifdef CONFIG_PM_ENABLE
extern void wifi_apb80m_request(void);
extern void wifi_apb80m_release(void);
#endif
/*
If CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP is enabled. Prefer to allocate a chunk of memory in SPIRAM firstly.
If failed, try to allocate it in internal memory then.
@ -164,6 +167,25 @@ static void wifi_delete_queue_wrapper(void *queue)
wifi_delete_queue(queue);
}
static bool IRAM_ATTR env_is_chip_wrapper(void)
{
#ifdef CONFIG_IDF_ENV_FPGA
return false;
#else
return true;
#endif
}
static void set_intr_wrapper(int32_t cpu_no, uint32_t intr_source, uint32_t intr_num, int32_t intr_prio)
{
intr_matrix_set(cpu_no, intr_source, intr_num);
}
static void clear_intr_wrapper(uint32_t intr_source, uint32_t intr_num)
{
}
static void set_isr_wrapper(int32_t n, void *f, void *arg)
{
xt_set_interrupt_handler(n, (xt_handler)f, arg);
@ -203,7 +225,7 @@ static void IRAM_ATTR wifi_int_restore_wrapper(void *wifi_int_mux, uint32_t tmp)
static bool IRAM_ATTR is_from_isr_wrapper(void)
{
return xPortInIsrContext();
return !xPortCanYield();
}
static void IRAM_ATTR task_yield_from_isr_wrapper(void)
@ -256,16 +278,6 @@ static void * wifi_thread_semphr_get_wrapper(void)
return (void*)sem;
}
static int32_t IRAM_ATTR semphr_take_from_isr_wrapper(void *semphr, void *hptw)
{
return (int32_t)xSemaphoreTakeFromISR(semphr, hptw);
}
static int32_t IRAM_ATTR semphr_give_from_isr_wrapper(void *semphr, void *hptw)
{
return (int32_t)xSemaphoreGiveFromISR(semphr, hptw);
}
static int32_t semphr_take_wrapper(void *semphr, uint32_t block_time_tick)
{
if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) {
@ -381,6 +393,20 @@ static int32_t esp_event_post_wrapper(const char* event_base, int32_t event_id,
}
}
static void IRAM_ATTR wifi_apb80m_request_wrapper(void)
{
#ifdef CONFIG_PM_ENABLE
wifi_apb80m_request();
#endif
}
static void IRAM_ATTR wifi_apb80m_release_wrapper(void)
{
#ifdef CONFIG_PM_ENABLE
wifi_apb80m_release();
#endif
}
static void IRAM_ATTR timer_arm_wrapper(void *timer, uint32_t tmout, bool repeat)
{
ets_timer_arm(timer, tmout, repeat);
@ -459,9 +485,41 @@ static void * IRAM_ATTR zalloc_internal_wrapper(size_t size)
return ptr;
}
static uint32_t coex_status_get_wrapper(void)
static int coex_init_wrapper(void)
{
#if CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE
#if CONFIG_SW_COEXIST_ENABLE
return coex_init();
#else
return 0;
#endif
}
static void coex_deinit_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
coex_deinit();
#endif
}
static int coex_enable_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_enable();
#else
return 0;
#endif
}
static void coex_disable_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
coex_disable();
#endif
}
static IRAM_ATTR uint32_t coex_status_get_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_status_get();
#else
return 0;
@ -477,7 +535,7 @@ static void coex_condition_set_wrapper(uint32_t type, bool dissatisfy)
static int coex_wifi_request_wrapper(uint32_t event, uint32_t latency, uint32_t duration)
{
#if CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE
#if CONFIG_SW_COEXIST_ENABLE
return coex_wifi_request(event, latency, duration);
#else
return 0;
@ -486,53 +544,101 @@ static int coex_wifi_request_wrapper(uint32_t event, uint32_t latency, uint32_t
static int coex_wifi_release_wrapper(uint32_t event)
{
#if CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE
#if CONFIG_SW_COEXIST_ENABLE
return coex_wifi_release(event);
#else
return 0;
#endif
}
int IRAM_ATTR coex_bt_request_wrapper(uint32_t event, uint32_t latency, uint32_t duration)
static int coex_wifi_channel_set_wrapper(uint8_t primary, uint8_t secondary)
{
#if CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE
return coex_bt_request(event, latency, duration);
#if CONFIG_SW_COEXIST_ENABLE
return coex_wifi_channel_set(primary, secondary);
#else
return 0;
#endif
}
int IRAM_ATTR coex_bt_release_wrapper(uint32_t event)
static IRAM_ATTR int coex_event_duration_get_wrapper(uint32_t event, uint32_t *duration)
{
#if CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE
return coex_bt_release(event);
#if CONFIG_SW_COEXIST_ENABLE
return coex_event_duration_get(event, duration);
#else
return 0;
#endif
}
int coex_register_bt_cb_wrapper(coex_func_cb_t cb)
static int coex_pti_get_wrapper(uint32_t event, uint8_t *pti)
{
#if CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE
return coex_register_bt_cb(cb);
return 0;
}
static void coex_schm_status_bit_clear_wrapper(uint32_t type, uint32_t status)
{
#if CONFIG_SW_COEXIST_ENABLE
coex_schm_status_bit_clear(type, status);
#endif
}
static void coex_schm_status_bit_set_wrapper(uint32_t type, uint32_t status)
{
#if CONFIG_SW_COEXIST_ENABLE
coex_schm_status_bit_set(type, status);
#endif
}
static IRAM_ATTR int coex_schm_interval_set_wrapper(uint32_t interval)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_schm_interval_set(interval);
#else
return 0;
#endif
}
uint32_t IRAM_ATTR coex_bb_reset_lock_wrapper(void)
static uint32_t coex_schm_interval_get_wrapper(void)
{
#if CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE
return coex_bb_reset_lock();
#if CONFIG_SW_COEXIST_ENABLE
return coex_schm_interval_get();
#else
return 0;
#endif
}
void IRAM_ATTR coex_bb_reset_unlock_wrapper(uint32_t restore)
static uint8_t coex_schm_curr_period_get_wrapper(void)
{
#if CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE
coex_bb_reset_unlock(restore);
#if CONFIG_SW_COEXIST_ENABLE
return coex_schm_curr_period_get();
#else
return 0;
#endif
}
static void * coex_schm_curr_phase_get_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_schm_curr_phase_get();
#else
return NULL;
#endif
}
static int coex_schm_curr_phase_idx_set_wrapper(int idx)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_schm_curr_phase_idx_set(idx);
#else
return 0;
#endif
}
static int coex_schm_curr_phase_idx_get_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_schm_curr_phase_idx_get();
#else
return 0;
#endif
}
@ -543,9 +649,13 @@ static void IRAM_ATTR esp_empty_wrapper(void)
wifi_osi_funcs_t g_wifi_osi_funcs = {
._version = ESP_WIFI_OS_ADAPTER_VERSION,
._env_is_chip = env_is_chip_wrapper,
._set_intr = set_intr_wrapper,
._clear_intr = clear_intr_wrapper,
._set_isr = set_isr_wrapper,
._ints_on = xt_ints_on,
._ints_off = xt_ints_off,
._is_from_isr = is_from_isr_wrapper,
._spin_lock_create = spin_lock_create_wrapper,
._spin_lock_delete = free,
._wifi_int_disable = wifi_int_disable_wrapper,
@ -588,8 +698,10 @@ wifi_osi_funcs_t g_wifi_osi_funcs = {
._rand = esp_random,
._dport_access_stall_other_cpu_start_wrap = esp_empty_wrapper,
._dport_access_stall_other_cpu_end_wrap = esp_empty_wrapper,
._phy_rf_deinit = esp_phy_rf_deinit,
._phy_load_cal_and_init = esp_phy_load_cal_and_init,
._wifi_apb80m_request = wifi_apb80m_request_wrapper,
._wifi_apb80m_release = wifi_apb80m_release_wrapper,
._phy_disable = esp_phy_disable,
._phy_enable = esp_phy_enable,
._phy_update_country_info = esp_phy_update_country_info,
._read_mac = esp_read_mac,
._timer_arm = timer_arm_wrapper,
@ -600,6 +712,8 @@ wifi_osi_funcs_t g_wifi_osi_funcs = {
._wifi_reset_mac = wifi_reset_mac_wrapper,
._wifi_clock_enable = wifi_clock_enable_wrapper,
._wifi_clock_disable = wifi_clock_disable_wrapper,
._wifi_rtc_enable_iso = esp_empty_wrapper,
._wifi_rtc_disable_iso = esp_empty_wrapper,
._esp_timer_get_time = esp_timer_get_time,
._nvs_set_i8 = nvs_set_i8,
._nvs_get_i8 = nvs_get_i8,
@ -616,9 +730,7 @@ wifi_osi_funcs_t g_wifi_osi_funcs = {
._get_random = os_get_random,
._get_time = get_time_wrapper,
._random = os_random,
#if CONFIG_IDF_TARGET_ESP32S2
._slowclk_cal_get = esp_clk_slowclk_cal_get_wrapper,
#endif
._log_write = esp_log_write,
._log_writev = esp_log_writev,
._log_timestamp = esp_log_timestamp,
@ -632,38 +744,24 @@ wifi_osi_funcs_t g_wifi_osi_funcs = {
._wifi_zalloc = wifi_zalloc_wrapper,
._wifi_create_queue = wifi_create_queue_wrapper,
._wifi_delete_queue = wifi_delete_queue_wrapper,
._modem_sleep_enter = esp_modem_sleep_enter,
._modem_sleep_exit = esp_modem_sleep_exit,
._modem_sleep_register = esp_modem_sleep_register,
._modem_sleep_deregister = esp_modem_sleep_deregister,
._coex_init = coex_init_wrapper,
._coex_deinit = coex_deinit_wrapper,
._coex_enable = coex_enable_wrapper,
._coex_disable = coex_disable_wrapper,
._coex_status_get = coex_status_get_wrapper,
._coex_condition_set = coex_condition_set_wrapper,
._coex_wifi_request = coex_wifi_request_wrapper,
._coex_wifi_release = coex_wifi_release_wrapper,
._is_from_isr = is_from_isr_wrapper,
._coex_wifi_channel_set = coex_wifi_channel_set_wrapper,
._coex_event_duration_get = coex_event_duration_get_wrapper,
._coex_pti_get = coex_pti_get_wrapper,
._coex_schm_status_bit_clear = coex_schm_status_bit_clear_wrapper,
._coex_schm_status_bit_set = coex_schm_status_bit_set_wrapper,
._coex_schm_interval_set = coex_schm_interval_set_wrapper,
._coex_schm_interval_get = coex_schm_interval_get_wrapper,
._coex_schm_curr_period_get = coex_schm_curr_period_get_wrapper,
._coex_schm_curr_phase_get = coex_schm_curr_phase_get_wrapper,
._coex_schm_curr_phase_idx_set = coex_schm_curr_phase_idx_set_wrapper,
._coex_schm_curr_phase_idx_get = coex_schm_curr_phase_idx_get_wrapper,
._magic = ESP_WIFI_OS_ADAPTER_MAGIC,
};
coex_adapter_funcs_t g_coex_adapter_funcs = {
._version = COEX_ADAPTER_VERSION,
._spin_lock_create = spin_lock_create_wrapper,
._spin_lock_delete = free,
._int_disable = wifi_int_disable_wrapper,
._int_enable = wifi_int_restore_wrapper,
._task_yield_from_isr = task_yield_from_isr_wrapper,
._semphr_create = semphr_create_wrapper,
._semphr_delete = semphr_delete_wrapper,
._semphr_take_from_isr = semphr_take_from_isr_wrapper,
._semphr_give_from_isr = semphr_give_from_isr_wrapper,
._semphr_take = semphr_take_wrapper,
._semphr_give = semphr_give_wrapper,
._is_in_isr = xPortInIsrContext,
._malloc_internal = malloc_internal_wrapper,
._free = free,
._timer_disarm = timer_disarm_wrapper,
._timer_done = timer_done_wrapper,
._timer_setfn = timer_setfn_wrapper,
._timer_arm_us = timer_arm_us_wrapper,
._esp_timer_get_time = esp_timer_get_time,
._magic = COEX_ADAPTER_MAGIC,
};

View File

@ -21,17 +21,19 @@
extern "C" {
#endif
#define COEX_ADAPTER_VERSION 0x00000001
#define COEX_ADAPTER_VERSION 0x00000002
#define COEX_ADAPTER_MAGIC 0xDEADBEAF
#define COEX_ADAPTER_FUNCS_TIME_BLOCKING 0xffffffff
typedef struct {
int32_t _version;
#if CONFIG_IDF_TARGET_ESP32
void *(* _spin_lock_create)(void);
void (* _spin_lock_delete)(void *lock);
uint32_t (*_int_disable)(void *mux);
void (*_int_enable)(void *mux, uint32_t tmp);
#endif
void (*_task_yield_from_isr)(void);
void *(*_semphr_create)(uint32_t max, uint32_t init);
void (*_semphr_delete)(void *semphr);
@ -42,10 +44,12 @@ typedef struct {
int32_t (* _is_in_isr)(void);
void * (* _malloc_internal)(size_t size);
void (* _free)(void *p);
#if CONFIG_IDF_TARGET_ESP32
void (* _timer_disarm)(void *timer);
void (* _timer_done)(void *ptimer);
void (* _timer_setfn)(void *ptimer, void *pfunction, void *parg);
void (* _timer_arm_us)(void *ptimer, uint32_t us, bool repeat);
#endif
int64_t (* _esp_timer_get_time)(void);
int32_t _magic;
} coex_adapter_funcs_t;

View File

@ -54,16 +54,18 @@ esp_err_t coex_init(void);
void coex_deinit(void);
/**
* @brief Pause software coexist
* @brief Enable software coexist
* extern function for internal use.
*
* @return Enable ok or failed.
*/
void coex_pause(void);
esp_err_t coex_enable(void);
/**
* @brief Resume software coexist
* @brief Disable software coexist
* extern function for internal use.
*/
void coex_resume(void);
void coex_disable(void);
/**
* @brief Get software coexist version string
@ -112,44 +114,82 @@ int coex_wifi_request(uint32_t event, uint32_t latency, uint32_t duration);
int coex_wifi_release(uint32_t event);
/**
* @brief Blue tooth requests coexistence.
* @brief Set WiFi channel to coexistence module.
*
* @param event : blue tooth event
* @param latency : blue tooth will request coexistence after latency
* @param duration : duration for blue tooth to request coexistence
* @param primary : WiFi primary channel
* @param secondary : WiFi secondary channel
* @return : 0 - success, other - failed
*/
int coex_bt_request(uint32_t event, uint32_t latency, uint32_t duration);
int coex_wifi_channel_set(uint8_t primary, uint8_t secondary);
/**
* @brief Blue tooth release coexistence.
* @brief Get coexistence event duration.
*
* @param event : blue tooth event
* @param event : Coexistence event
* @param duration: Coexistence event duration
* @return : 0 - success, other - failed
*/
int coex_bt_release(uint32_t event);
int coex_event_duration_get(uint32_t event, uint32_t *duration);
/**
* @brief Register callback function for blue tooth.
* @brief Clear coexistence status.
*
* @param cb : callback function
* @param type : Coexistence status type
* @param status: Coexistence status
*/
void coex_schm_status_bit_clear(uint32_t type, uint32_t status);
/**
* @brief Set coexistence status.
*
* @param type : Coexistence status type
* @param status: Coexistence status
*/
void coex_schm_status_bit_set(uint32_t type, uint32_t status);
/**
* @brief Set coexistence scheme interval.
*
* @param interval : Coexistence scheme interval
* @return : 0 - success, other - failed
*/
int coex_register_bt_cb(coex_func_cb_t cb);
int coex_schm_interval_set(uint32_t interval);
/**
* @brief Lock before reset base band.
* @brief Get coexistence scheme interval.
*
* @return : lock value
* @return : Coexistence scheme interval
*/
uint32_t coex_bb_reset_lock(void);
uint32_t coex_schm_interval_get(void);
/**
* @brief Unlock after reset base band.
* @brief Get current coexistence scheme period.
*
* @param restore : lock value
* @return : Coexistence scheme period
*/
void coex_bb_reset_unlock(uint32_t restore);
uint8_t coex_schm_curr_period_get(void);
/**
* @brief Get current coexistence scheme phase.
*
* @return : Coexistence scheme phase
*/
void * coex_schm_curr_phase_get(void);
/**
* @brief Set current coexistence scheme phase index.
*
* @param interval : Coexistence scheme phase index
* @return : 0 - success, other - failed
*/
int coex_schm_curr_phase_idx_set(int idx);
/**
* @brief Get current coexistence scheme phase index.
*
* @return : Coexistence scheme phase index
*/
int coex_schm_curr_phase_idx_get(void);
/**
* @brief Register coexistence adapter functions.

View File

@ -48,21 +48,6 @@ typedef enum {
PHY_RF_CAL_FULL = 0x00000002 /*!< Do full RF calibration. Produces best results, but also consumes a lot of time and current. Suggested to be used once. */
} esp_phy_calibration_mode_t;
/**
* @brief Modules for modem sleep
*/
typedef enum{
MODEM_BLE_MODULE, //!< BLE controller used
MODEM_CLASSIC_BT_MODULE, //!< Classic BT controller used
MODEM_WIFI_STATION_MODULE, //!< Wi-Fi Station used
MODEM_WIFI_SOFTAP_MODULE, //!< Wi-Fi SoftAP used
MODEM_WIFI_SNIFFER_MODULE, //!< Wi-Fi Sniffer used
MODEM_WIFI_NULL_MODULE, //!< Wi-Fi Null mode used
MODEM_USER_MODULE, //!< User used
MODEM_MODULE_COUNT //!< Number of items
}modem_sleep_module_t;
#if CONFIG_ESP32_SUPPORT_MULTIPLE_PHY_INIT_DATA_BIN
/**
* @brief PHY init data type
@ -87,30 +72,6 @@ typedef enum {
} phy_init_data_type_t;
#endif
/**
* @brief Module WIFI mask for medem sleep
*/
#define MODEM_BT_MASK ((1<<MODEM_BLE_MODULE) | \
(1<<MODEM_CLASSIC_BT_MODULE))
/**
* @brief Module WIFI mask for medem sleep
*/
#define MODEM_WIFI_MASK ((1<<MODEM_WIFI_STATION_MODULE) | \
(1<<MODEM_WIFI_SOFTAP_MODULE) | \
(1<<MODEM_WIFI_SNIFFER_MODULE) | \
(1<<MODEM_WIFI_NULL_MODULE))
/**
* @brief Modules needing to call phy_rf_init
*/
typedef enum{
PHY_BT_MODULE, //!< Bluetooth used
PHY_WIFI_MODULE, //!< Wi-Fi used
PHY_MODEM_MODULE, //!< Modem sleep used
PHY_MODULE_COUNT //!< Number of items
}phy_rf_module_t;
/**
* @brief Get PHY init data
*
@ -193,38 +154,29 @@ esp_err_t esp_phy_store_cal_data_to_nvs(const esp_phy_calibration_data_t* cal_da
esp_err_t esp_phy_erase_cal_data_in_nvs(void);
/**
* @brief Initialize PHY and RF module
* @brief Enable PHY and RF module
*
* PHY and RF module should be initialized in order to use WiFi or BT.
* Now PHY and RF initializing job is done automatically when start WiFi or BT. Users should not
* PHY and RF module should be enabled in order to use WiFi or BT.
* Now PHY and RF enabling job is done automatically when start WiFi or BT. Users should not
* call this API in their application.
*
* @param init_data PHY parameters. Default set of parameters can
* be obtained by calling esp_phy_get_default_init_data
* function.
* @param mode Calibration mode (Full, partial, or no calibration)
* @param[inout] calibration_data
* @return ESP_OK on success.
* @return ESP_FAIL on fail.
*/
esp_err_t esp_phy_rf_init(const esp_phy_init_data_t* init_data,esp_phy_calibration_mode_t mode,
esp_phy_calibration_data_t* calibration_data, phy_rf_module_t module);
void esp_phy_enable(void);
/**
* @brief De-initialize PHY and RF module
* @brief Disable PHY and RF module
*
* PHY module should be de-initialized in order to shutdown WiFi or BT.
* Now PHY and RF de-initializing job is done automatically when stop WiFi or BT. Users should not
* PHY module should be disabled in order to shutdown WiFi or BT.
* Now PHY and RF disabling job is done automatically when stop WiFi or BT. Users should not
* call this API in their application.
*
* @return ESP_OK on success.
*/
esp_err_t esp_phy_rf_deinit(phy_rf_module_t module);
void esp_phy_disable(void);
/**
* @brief Load calibration data from NVS and initialize PHY and RF module
*/
void esp_phy_load_cal_and_init(phy_rf_module_t module);
void esp_phy_load_cal_and_init(void);
/**
* @brief Enable WiFi/BT common clock
@ -238,30 +190,6 @@ void esp_phy_common_clock_enable(void);
*/
void esp_phy_common_clock_disable(void);
/**
* @brief Module requires to enter modem sleep
*/
esp_err_t esp_modem_sleep_enter(modem_sleep_module_t module);
/**
* @brief Module requires to exit modem sleep
*/
esp_err_t esp_modem_sleep_exit(modem_sleep_module_t module);
/**
* @brief Register module to make it be able to require to enter/exit modem sleep
* Although the module has no sleep function, as long as the module use RF,
* it must call esp_modem_sleep_regsiter. Otherwise, other modules with sleep
* function will disable RF without checking the module which doesn't call
* esp_modem_sleep_regsiter.
*/
esp_err_t esp_modem_sleep_register(modem_sleep_module_t module);
/**
* @brief De-register module from modem sleep list
*/
esp_err_t esp_modem_sleep_deregister(modem_sleep_module_t module);
/**
* @brief Get the time stamp when PHY/RF was switched on
* @return return 0 if PHY/RF is never switched on. Otherwise return time in

View File

@ -21,7 +21,7 @@
extern "C" {
#endif
#define ESP_WIFI_OS_ADAPTER_VERSION 0x00000007
#define ESP_WIFI_OS_ADAPTER_VERSION 0x00000008
#define ESP_WIFI_OS_ADAPTER_MAGIC 0xDEADBEAF
#define OSI_FUNCS_TIME_BLOCKING 0xffffffff
@ -32,9 +32,13 @@ extern "C" {
typedef struct {
int32_t _version;
bool (* _env_is_chip)(void);
void (*_set_intr)(int32_t cpu_no, uint32_t intr_source, uint32_t intr_num, int32_t intr_prio);
void (*_clear_intr)(uint32_t intr_source, uint32_t intr_num);
void (*_set_isr)(int32_t n, void *f, void *arg);
void (*_ints_on)(uint32_t mask);
void (*_ints_off)(uint32_t mask);
bool (* _is_from_isr)(void);
void *(* _spin_lock_create)(void);
void (* _spin_lock_delete)(void *lock);
uint32_t (*_wifi_int_disable)(void *wifi_int_mux);
@ -77,8 +81,10 @@ typedef struct {
uint32_t (* _rand)(void);
void (* _dport_access_stall_other_cpu_start_wrap)(void);
void (* _dport_access_stall_other_cpu_end_wrap)(void);
int32_t (* _phy_rf_deinit)(uint32_t module);
void (* _phy_load_cal_and_init)(uint32_t module);
void (* _wifi_apb80m_request)(void);
void (* _wifi_apb80m_release)(void);
void (* _phy_disable)(void);
void (* _phy_enable)(void);
#if CONFIG_IDF_TARGET_ESP32
void (* _phy_common_clock_enable)(void);
void (* _phy_common_clock_disable)(void);
@ -93,6 +99,8 @@ typedef struct {
void (* _wifi_reset_mac)(void);
void (* _wifi_clock_enable)(void);
void (* _wifi_clock_disable)(void);
void (* _wifi_rtc_enable_iso)(void);
void (* _wifi_rtc_disable_iso)(void);
int64_t (* _esp_timer_get_time)(void);
int32_t (* _nvs_set_i8)(uint32_t handle, const char* key, int8_t value);
int32_t (* _nvs_get_i8)(uint32_t handle, const char* key, int8_t* out_value);
@ -109,7 +117,7 @@ typedef struct {
int32_t (* _get_random)(uint8_t *buf, size_t len);
int32_t (* _get_time)(void *t);
unsigned long (* _random)(void);
#if CONFIG_IDF_TARGET_ESP32S2
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3
uint32_t (* _slowclk_cal_get)(void);
#endif
void (* _log_write)(uint32_t level, const char* tag, const char* format, ...);
@ -125,15 +133,25 @@ typedef struct {
void * (* _wifi_zalloc)(size_t size);
void * (* _wifi_create_queue)(int32_t queue_len, int32_t item_size);
void (* _wifi_delete_queue)(void * queue);
int32_t (* _modem_sleep_enter)(uint32_t module);
int32_t (* _modem_sleep_exit)(uint32_t module);
int32_t (* _modem_sleep_register)(uint32_t module);
int32_t (* _modem_sleep_deregister)(uint32_t module);
int (* _coex_init)(void);
void (* _coex_deinit)(void);
int (* _coex_enable)(void);
void (* _coex_disable)(void);
uint32_t (* _coex_status_get)(void);
void (* _coex_condition_set)(uint32_t type, bool dissatisfy);
int32_t (* _coex_wifi_request)(uint32_t event, uint32_t latency, uint32_t duration);
int32_t (* _coex_wifi_release)(uint32_t event);
bool (* _is_from_isr)(void);
int (* _coex_wifi_channel_set)(uint8_t primary, uint8_t secondary);
int (* _coex_event_duration_get)(uint32_t event, uint32_t *duration);
int (* _coex_pti_get)(uint32_t event, uint8_t *pti);
void (* _coex_schm_status_bit_clear)(uint32_t type, uint32_t status);
void (* _coex_schm_status_bit_set)(uint32_t type, uint32_t status);
int (* _coex_schm_interval_set)(uint32_t interval);
uint32_t (* _coex_schm_interval_get)(void);
uint8_t (* _coex_schm_curr_period_get)(void);
void * (* _coex_schm_curr_phase_get)(void);
int (* _coex_schm_curr_phase_idx_set)(int idx);
int (* _coex_schm_curr_phase_idx_get)(void);
int32_t _magic;
} wifi_osi_funcs_t;

View File

@ -329,7 +329,7 @@ typedef struct {
unsigned sgi:1; /**< Short Guide Interval(SGI). 0: Long GI; 1: Short GI */
#if CONFIG_IDF_TARGET_ESP32
signed noise_floor:8; /**< noise floor of Radio Frequency Module(RF). unit: 0.25dBm*/
#elif CONFIG_IDF_TARGET_ESP32S2
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3
unsigned :8; /**< reserved */
#endif
unsigned ampdu_cnt:8; /**< ampdu cnt */
@ -340,12 +340,20 @@ typedef struct {
unsigned :32; /**< reserved */
#if CONFIG_IDF_TARGET_ESP32S2
unsigned :32; /**< reserved */
#elif CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3
signed noise_floor:8; /**< noise floor of Radio Frequency Module(RF). unit: 0.25dBm*/
unsigned :24; /**< reserved */
unsigned :32; /**< reserved */
#endif
unsigned :31; /**< reserved */
unsigned ant:1; /**< antenna number from which this packet is received. 0: WiFi antenna 0; 1: WiFi antenna 1 */
#if CONFIG_IDF_TARGET_ESP32S2
signed noise_floor:8; /**< noise floor of Radio Frequency Module(RF). unit: 0.25dBm*/
unsigned :24; /**< reserved */
#elif CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3
unsigned :32; /**< reserved */
unsigned :32; /**< reserved */
unsigned :32; /**< reserved */
#endif
unsigned sig_len:12; /**< length of packet including Frame Check Sequence(FCS) */
unsigned :12; /**< reserved */
@ -531,6 +539,8 @@ typedef enum {
WIFI_EVENT_AP_STADISCONNECTED, /**< a station disconnected from ESP32 soft-AP */
WIFI_EVENT_AP_PROBEREQRECVED, /**< Receive probe request packet in soft-AP interface */
WIFI_EVENT_FTM_REPORT, /**< Receive report of FTM procedure */
WIFI_EVENT_MAX, /**< Invalid WiFi event ID */
} wifi_event_t;
@ -616,6 +626,7 @@ typedef struct {
#define WIFI_STATIS_RXTX (1<<1)
#define WIFI_STATIS_HW (1<<2)
#define WIFI_STATIS_DIAG (1<<3)
#define WIFI_STATIS_PS (1<<4)
#define WIFI_STATIS_ALL (-1)
#ifdef __cplusplus

@ -1 +1 @@
Subproject commit 12e949d5ab93a3c82972a8a57a813726f0f3737f
Subproject commit c02243cd78ee8d1f366e4853e75b9c7183523ecf

View File

@ -48,32 +48,20 @@ extern wifi_mac_time_update_cb_t s_wifi_mac_time_update_cb;
static const char* TAG = "phy_init";
static _lock_t s_phy_rf_init_lock;
static _lock_t s_phy_access_lock;
/* Bit mask of modules needing to call phy_rf_init */
static uint32_t s_module_phy_rf_init = 0;
/* Indicate PHY is calibrated or not */
static bool s_is_phy_calibrated = false;
/* Whether modem sleep is turned on */
static volatile bool s_is_phy_rf_en = false;
/* Bit mask of modules needing to enter modem sleep mode */
static uint32_t s_modem_sleep_module_enter = 0;
/* Bit mask of modules which might use RF, system can enter modem
* sleep mode only when all modules registered require to enter
* modem sleep*/
static uint32_t s_modem_sleep_module_register = 0;
/* Whether modern sleep is turned on */
static volatile bool s_is_modem_sleep_en = false;
static _lock_t s_modem_sleep_lock;
/* Reference count of enabling PHY */
static uint8_t s_phy_access_ref = 0;
#if CONFIG_IDF_TARGET_ESP32
/* time stamp updated when the PHY/RF is turned on */
static int64_t s_phy_rf_en_ts = 0;
#endif
/* PHY spinlock for libphy.a */
static DRAM_ATTR portMUX_TYPE s_phy_int_mux = portMUX_INITIALIZER_UNLOCKED;
#if CONFIG_ESP32_SUPPORT_MULTIPLE_PHY_INIT_DATA_BIN
@ -196,288 +184,60 @@ IRAM_ATTR void esp_phy_common_clock_disable(void)
wifi_bt_common_module_disable();
}
esp_err_t esp_phy_rf_init(const esp_phy_init_data_t* init_data, esp_phy_calibration_mode_t mode,
esp_phy_calibration_data_t* calibration_data, phy_rf_module_t module)
void esp_phy_enable(void)
{
/* 3 modules may call phy_init: Wi-Fi, BT, Modem Sleep */
if (module >= PHY_MODULE_COUNT){
ESP_LOGE(TAG, "%s, invalid module parameter(%d), should be smaller than \
module count(%d)", __func__, module, PHY_MODULE_COUNT);
return ESP_ERR_INVALID_ARG;
}
_lock_acquire(&s_phy_access_lock);
_lock_acquire(&s_phy_rf_init_lock);
uint32_t s_module_phy_rf_init_old = s_module_phy_rf_init;
bool is_wifi_or_bt_enabled = !!(s_module_phy_rf_init_old & (BIT(PHY_BT_MODULE) | BIT(PHY_WIFI_MODULE)));
esp_err_t status = ESP_OK;
s_module_phy_rf_init |= BIT(module);
if (s_phy_access_ref == 0) {
#if CONFIG_IDF_TARGET_ESP32
// Update time stamp
s_phy_rf_en_ts = esp_timer_get_time();
// Update WiFi MAC time before WiFi/BT common clock is enabled
phy_update_wifi_mac_time(false, s_phy_rf_en_ts);
#endif
esp_phy_common_clock_enable();
phy_set_wifi_mode_only(0);
if ((is_wifi_or_bt_enabled == false) && (module == PHY_MODEM_MODULE)){
status = ESP_FAIL;
}
else if (s_is_phy_rf_en == true) {
}
else {
/* If Wi-Fi, BT all disabled, modem sleep should not take effect;
* If either Wi-Fi or BT is enabled, should allow modem sleep requires
* to enter sleep;
* If Wi-Fi, BT co-exist, it is disallowed that only one module
* support modem sleep, E,g. BT support modem sleep but Wi-Fi not
* support modem sleep;
*/
if (is_wifi_or_bt_enabled == false){
if ((module == PHY_BT_MODULE) || (module == PHY_WIFI_MODULE)){
s_is_phy_rf_en = true;
}
if (s_is_phy_calibrated == false) {
esp_phy_load_cal_and_init();
s_is_phy_calibrated = true;
}
else {
if (module == PHY_MODEM_MODULE){
s_is_phy_rf_en = true;
}
else if ((module == PHY_BT_MODULE) || (module == PHY_WIFI_MODULE)){
/* New module (BT or Wi-Fi) can init RF according to modem_sleep_exit */
}
}
if (s_is_phy_rf_en == true){
#if CONFIG_IDF_TARGET_ESP32
// Update time stamp
s_phy_rf_en_ts = esp_timer_get_time();
// Update WiFi MAC time before WiFi/BT common clock is enabled
phy_update_wifi_mac_time(false, s_phy_rf_en_ts);
#endif
esp_phy_common_clock_enable();
phy_set_wifi_mode_only(0);
#if CONFIG_IDF_TARGET_ESP32S2
if (module == PHY_MODEM_MODULE) {
phy_wakeup_init();
}
else
phy_wakeup_init();
#elif CONFIG_IDF_TARGET_ESP32
register_chipv7_phy(NULL, NULL, PHY_RF_CAL_NONE);
#endif
if (ESP_CAL_DATA_CHECK_FAIL == register_chipv7_phy(init_data, calibration_data, mode)) {
ESP_LOGW(TAG, "saving new calibration data because of checksum failure, mode(%d)", mode);
#ifdef CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE
if (mode != PHY_RF_CAL_FULL) {
esp_phy_store_cal_data_to_nvs(calibration_data);
}
#endif
}
}
#if CONFIG_IDF_TARGET_ESP32
coex_bt_high_prio();
coex_bt_high_prio();
#endif
}
}
s_phy_access_ref++;
#if CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE
if ((module == PHY_BT_MODULE) || (module == PHY_WIFI_MODULE)){
uint32_t phy_bt_wifi_mask = BIT(PHY_BT_MODULE) | BIT(PHY_WIFI_MODULE);
if ((s_module_phy_rf_init & phy_bt_wifi_mask) == phy_bt_wifi_mask) { //both wifi & bt enabled
coex_init();
coex_resume();
}
}
#endif
_lock_release(&s_phy_rf_init_lock);
return status;
_lock_release(&s_phy_access_lock);
}
esp_err_t esp_phy_rf_deinit(phy_rf_module_t module)
void esp_phy_disable(void)
{
/* 3 modules may call phy_init: Wi-Fi, BT, Modem Sleep */
if (module >= PHY_MODULE_COUNT){
ESP_LOGE(TAG, "%s, invalid module parameter(%d), should be smaller than \
module count(%d)", __func__, module, PHY_MODULE_COUNT);
return ESP_ERR_INVALID_ARG;
}
_lock_acquire(&s_phy_access_lock);
_lock_acquire(&s_phy_rf_init_lock);
uint32_t s_module_phy_rf_init_old = s_module_phy_rf_init;
uint32_t phy_bt_wifi_mask = BIT(PHY_BT_MODULE) | BIT(PHY_WIFI_MODULE);
bool is_wifi_or_bt_enabled = !!(s_module_phy_rf_init_old & phy_bt_wifi_mask);
bool is_both_wifi_bt_enabled = ((s_module_phy_rf_init_old & phy_bt_wifi_mask) == phy_bt_wifi_mask);
s_module_phy_rf_init &= ~BIT(module);
esp_err_t status = ESP_OK;
#if CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE
if ((module == PHY_BT_MODULE) || (module == PHY_WIFI_MODULE)){
if (is_both_wifi_bt_enabled == true) {
coex_deinit();
}
}
#endif
if ((is_wifi_or_bt_enabled == false) && (module == PHY_MODEM_MODULE)){
/* Modem sleep should not take effect in this case */
status = ESP_FAIL;
}
else if (s_is_phy_rf_en == false) {
//do nothing
}
else {
if (is_wifi_or_bt_enabled == false){
if ((module == PHY_BT_MODULE) || (module == PHY_WIFI_MODULE)){
s_is_phy_rf_en = false;
ESP_LOGE(TAG, "%s, RF should not be in enabled state if both Wi-Fi and BT are disabled", __func__);
}
}
else {
if (module == PHY_MODEM_MODULE){
s_is_phy_rf_en = false;
}
else if ((module == PHY_BT_MODULE) || (module == PHY_WIFI_MODULE)){
s_is_phy_rf_en = is_both_wifi_bt_enabled ? true : false;
}
}
if (s_is_phy_rf_en == false) {
// Disable PHY and RF.
phy_close_rf();
s_phy_access_ref--;
if (s_phy_access_ref == 0) {
// Disable PHY and RF.
phy_close_rf();
#if CONFIG_IDF_TARGET_ESP32
// Update WiFi MAC time before disalbe WiFi/BT common peripheral clock
phy_update_wifi_mac_time(true, esp_timer_get_time());
// Update WiFi MAC time before disalbe WiFi/BT common peripheral clock
phy_update_wifi_mac_time(true, esp_timer_get_time());
#endif
// Disable WiFi/BT common peripheral clock. Do not disable clock for hardware RNG
esp_phy_common_clock_disable();
}
// Disable WiFi/BT common peripheral clock. Do not disable clock for hardware RNG
esp_phy_common_clock_disable();
}
_lock_release(&s_phy_rf_init_lock);
return status;
_lock_release(&s_phy_access_lock);
}
esp_err_t esp_modem_sleep_enter(modem_sleep_module_t module)
{
#if CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE
uint32_t phy_bt_wifi_mask = BIT(PHY_BT_MODULE) | BIT(PHY_WIFI_MODULE);
#endif
if (module >= MODEM_MODULE_COUNT){
ESP_LOGE(TAG, "%s, invalid module parameter(%d), should be smaller than \
module count(%d)", __func__, module, MODEM_MODULE_COUNT);
return ESP_ERR_INVALID_ARG;
}
else if (!(s_modem_sleep_module_register & BIT(module))){
ESP_LOGW(TAG, "%s, module (%d) has not been registered", __func__, module);
return ESP_ERR_INVALID_ARG;
}
else {
_lock_acquire(&s_modem_sleep_lock);
s_modem_sleep_module_enter |= BIT(module);
#if CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE
_lock_acquire(&s_phy_rf_init_lock);
if (((s_module_phy_rf_init & phy_bt_wifi_mask) == phy_bt_wifi_mask) //both wifi & bt enabled
&& (s_modem_sleep_module_enter & (MODEM_BT_MASK | MODEM_WIFI_MASK)) != 0){
coex_pause();
}
_lock_release(&s_phy_rf_init_lock);
#endif
if (!s_is_modem_sleep_en && (s_modem_sleep_module_enter == s_modem_sleep_module_register)){
esp_err_t status = esp_phy_rf_deinit(PHY_MODEM_MODULE);
if (status == ESP_OK){
s_is_modem_sleep_en = true;
}
}
_lock_release(&s_modem_sleep_lock);
return ESP_OK;
}
}
esp_err_t esp_modem_sleep_exit(modem_sleep_module_t module)
{
#if CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE
uint32_t phy_bt_wifi_mask = BIT(PHY_BT_MODULE) | BIT(PHY_WIFI_MODULE);
#endif
if (module >= MODEM_MODULE_COUNT){
ESP_LOGE(TAG, "%s, invalid module parameter(%d), should be smaller than \
module count(%d)", __func__, module, MODEM_MODULE_COUNT);
return ESP_ERR_INVALID_ARG;
}
else if (!(s_modem_sleep_module_register & BIT(module))){
ESP_LOGW(TAG, "%s, module (%d) has not been registered", __func__, module);
return ESP_ERR_INVALID_ARG;
}
else {
_lock_acquire(&s_modem_sleep_lock);
s_modem_sleep_module_enter &= ~BIT(module);
if (s_is_modem_sleep_en){
esp_err_t status = esp_phy_rf_init(NULL,PHY_RF_CAL_NONE,NULL, PHY_MODEM_MODULE);
if (status == ESP_OK){
s_is_modem_sleep_en = false;
}
}
#if CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE
_lock_acquire(&s_phy_rf_init_lock);
if (((s_module_phy_rf_init & phy_bt_wifi_mask) == phy_bt_wifi_mask) //both wifi & bt enabled
&& (s_modem_sleep_module_enter & (MODEM_BT_MASK | MODEM_WIFI_MASK)) == 0){
coex_resume();
}
_lock_release(&s_phy_rf_init_lock);
#endif
_lock_release(&s_modem_sleep_lock);
return ESP_OK;
}
return ESP_OK;
}
esp_err_t esp_modem_sleep_register(modem_sleep_module_t module)
{
if (module >= MODEM_MODULE_COUNT){
ESP_LOGE(TAG, "%s, invalid module parameter(%d), should be smaller than \
module count(%d)", __func__, module, MODEM_MODULE_COUNT);
return ESP_ERR_INVALID_ARG;
}
else if (s_modem_sleep_module_register & BIT(module)){
ESP_LOGI(TAG, "%s, multiple registration of module (%d)", __func__, module);
return ESP_OK;
}
else{
_lock_acquire(&s_modem_sleep_lock);
s_modem_sleep_module_register |= BIT(module);
/* The module is set to enter modem sleep by default, otherwise will prevent
* other modules from entering sleep mode if this module never call enter sleep function
* in the future */
s_modem_sleep_module_enter |= BIT(module);
_lock_release(&s_modem_sleep_lock);
return ESP_OK;
}
}
esp_err_t esp_modem_sleep_deregister(modem_sleep_module_t module)
{
if (module >= MODEM_MODULE_COUNT){
ESP_LOGE(TAG, "%s, invalid module parameter(%d), should be smaller than \
module count(%d)", __func__, module, MODEM_MODULE_COUNT);
return ESP_ERR_INVALID_ARG;
}
else if (!(s_modem_sleep_module_register & BIT(module))){
ESP_LOGI(TAG, "%s, module (%d) has not been registered", __func__, module);
return ESP_OK;
}
else{
_lock_acquire(&s_modem_sleep_lock);
s_modem_sleep_module_enter &= ~BIT(module);
s_modem_sleep_module_register &= ~BIT(module);
if (s_modem_sleep_module_register == 0){
s_modem_sleep_module_enter = 0;
/* Once all module are de-registered and current state
* is modem sleep mode, we need to turn off modem sleep
*/
if (s_is_modem_sleep_en == true){
s_is_modem_sleep_en = false;
esp_phy_rf_init(NULL,PHY_RF_CAL_NONE,NULL, PHY_MODEM_MODULE);
}
}
_lock_release(&s_modem_sleep_lock);
return ESP_OK;
}
}
// PHY init data handling functions
#if CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION
#include "esp_partition.h"
@ -709,7 +469,7 @@ static void __attribute((unused)) esp_phy_reduce_tx_power(esp_phy_init_data_t* i
}
#endif
void esp_phy_load_cal_and_init(phy_rf_module_t module)
void esp_phy_load_cal_and_init(void)
{
esp_phy_calibration_data_t* cal_data =
(esp_phy_calibration_data_t*) calloc(sizeof(esp_phy_calibration_data_t), 1);
@ -760,15 +520,19 @@ void esp_phy_load_cal_and_init(phy_rf_module_t module)
esp_efuse_mac_get_default(sta_mac);
memcpy(cal_data->mac, sta_mac, 6);
esp_phy_rf_init(init_data, calibration_mode, cal_data, module);
esp_err_t ret = register_chipv7_phy(init_data, cal_data, calibration_mode);
if (ret == ESP_CAL_DATA_CHECK_FAIL) {
ESP_LOGW(TAG, "saving new calibration data because of checksum failure, mode(%d)", calibration_mode);
}
if (calibration_mode != PHY_RF_CAL_NONE && err != ESP_OK) {
if ((calibration_mode != PHY_RF_CAL_NONE && err != ESP_OK) ||
(calibration_mode != PHY_RF_CAL_FULL && ret == ESP_CAL_DATA_CHECK_FAIL)) {
err = esp_phy_store_cal_data_to_nvs(cal_data);
} else {
err = ESP_OK;
}
#else
esp_phy_rf_init(init_data, PHY_RF_CAL_FULL, cal_data, module);
register_chipv7_phy(init_data, cal_data, PHY_RF_CAL_FULL);
#endif
#if CONFIG_ESP32_REDUCE_PHY_TX_POWER

View File

@ -24,6 +24,7 @@
#include "esp_netif.h"
#include "tcpip_adapter_compatible/tcpip_adapter_compat.h"
#include "driver/adc2_wifi_private.h"
#include "esp_coexist_internal.h"
#if (CONFIG_ESP32_WIFI_RX_BA_WIN > CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM)
#error "WiFi configuration check: WARNING, WIFI_RX_BA_WIN should not be larger than WIFI_DYNAMIC_RX_BUFFER_NUM!"
@ -199,6 +200,9 @@ esp_err_t esp_wifi_init(const wifi_init_config_t *config)
if (err != ESP_OK) {
ESP_LOGW(TAG, "Failed to set default Wi-Fi event handlers (0x%x)", err);
}
#endif
#if CONFIG_SW_COEXIST_ENABLE
coex_init();
#endif
esp_err_t result = esp_wifi_init_internal(config);
if (result == ESP_OK) {

View File

@ -45,10 +45,7 @@ static void test_phy_rtc_init(void)
}
TEST_ESP_OK(ret);
#ifdef SOC_BT_SUPPORTED
esp_phy_load_cal_and_init(PHY_BT_MODULE);
#endif
esp_phy_load_cal_and_init(PHY_WIFI_MODULE);
esp_phy_enable();
//must run here, not blocking in above code
TEST_ASSERT(1);
@ -100,4 +97,4 @@ TEST_CASE("Test PHY/RTC functions called when cache is disabled", "[phy_rtc][cac
vSemaphoreDelete(semphr_done);
}
#endif
#endif

View File

@ -40,7 +40,7 @@ enum {
WIFI_WPA_ALG_GCMP
};
enum {
typedef enum {
WIFI_APPIE_PROBEREQ = 0,
WIFI_APPIE_ASSOC_REQ,
WIFI_APPIE_ASSOC_RESP,
@ -53,7 +53,7 @@ enum {
WIFI_APPIE_ESP_MANUFACTOR,
WIFI_APPIE_COUNTRY,
WIFI_APPIE_MAX,
};
} wifi_appie_t;
enum {
NONE_AUTH = 0x01,
@ -195,6 +195,7 @@ void esp_wifi_deauthenticate_internal(u8 reason_code);
bool esp_wifi_sta_is_running_internal(void);
bool esp_wifi_auth_done_internal(void);
int esp_wifi_set_ap_key_internal(int alg, const u8 *addr, int idx, u8 *key, size_t key_len);
int esp_wifi_get_sta_hw_key_idx_internal(int key_idx);
int esp_wifi_set_sta_key_internal(int alg, u8 *addr, int key_idx, int set_tx,
u8 *seq, size_t seq_len, u8 *key, size_t key_len, int key_entry_valid);
int esp_wifi_get_sta_key_internal(uint8_t *ifx, int *alg, u8 *addr, int *key_idx,

View File

@ -672,7 +672,7 @@ int wpa_supplicant_install_ptk(struct wpa_sm *sm)
}
//now only use keyentry 0 for pairwise key
sm->key_entry_valid = 5;
sm->key_entry_valid = esp_wifi_get_sta_hw_key_idx_internal(0); //KEY_IDX_STA_PTK
if (wpa_sm_set_key(&(sm->install_ptk), alg, sm->bssid, 0, 1, (sm->install_ptk).seq, WPA_KEY_RSC_LEN,
(u8 *) sm->ptk.tk1, keylen,sm->key_entry_valid) < 0) {
@ -808,7 +808,7 @@ int wpa_supplicant_install_gtk(struct wpa_sm *sm,
_gtk = gtk_buf;
}
//now only use keycache entry1 for group key
sm->key_entry_valid = gd->keyidx;
sm->key_entry_valid = esp_wifi_get_sta_hw_key_idx_internal(gd->keyidx);
if (sm->pairwise_cipher == WPA_CIPHER_NONE) {
if (wpa_sm_set_key(&(sm->install_gtk), gd->alg,
sm->bssid, //(u8 *) "\xff\xff\xff\xff\xff\xff",