fix(wpa_supplicant): Remove the btm_rrm task from supplicant

This commit removes btm_rrm_t task and CONFIG_SUPPLICANT_TASK from
wpa_supplicant and make the functions work in wifi task's context.
This commit is contained in:
Aditi
2024-11-14 16:11:25 +05:30
committed by BOT
parent 041bc41ccf
commit 30264132b5
4 changed files with 7 additions and 155 deletions

View File

@ -288,13 +288,13 @@ if(CONFIG_ESP_WIFI_DPP_SUPPORT)
target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_DPP)
endif()
if(CONFIG_ESP_WIFI_11KV_SUPPORT)
target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_SUPPLICANT_TASK CONFIG_WNM CONFIG_RRM CONFIG_IEEE80211KV)
target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_WNM CONFIG_RRM CONFIG_IEEE80211KV)
endif()
if(CONFIG_ESP_WIFI_RRM_SUPPORT)
target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_SUPPLICANT_TASK CONFIG_RRM)
target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_RRM)
endif()
if(CONFIG_ESP_WIFI_WNM_SUPPORT)
target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_SUPPLICANT_TASK CONFIG_WNM)
target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_WNM)
endif()
if(CONFIG_ESP_WIFI_11R_SUPPORT)
target_compile_definitions(${COMPONENT_LIB} PRIVATE CONFIG_IEEE80211R)

View File

@ -26,6 +26,7 @@
#if CONFIG_ESP_WIFI_ENABLE_ROAMING_APP
#include "esp_roaming.h"
#endif
#include "eloop.h"
/* Utility Functions */
esp_err_t esp_supplicant_str_to_mac(const char *str, uint8_t dest[6])
@ -39,40 +40,7 @@ esp_err_t esp_supplicant_str_to_mac(const char *str, uint8_t dest[6])
struct wpa_supplicant g_wpa_supp;
#if defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R)
#ifdef CONFIG_SUPPLICANT_TASK
static void *s_supplicant_task_hdl = NULL;
static void *s_supplicant_evt_queue = NULL;
static void *s_supplicant_api_lock = NULL;
static bool s_supplicant_task_init_done;
#define SUPPLICANT_API_LOCK() os_mutex_lock(s_supplicant_api_lock)
#define SUPPLICANT_API_UNLOCK() os_mutex_unlock(s_supplicant_api_lock)
#define SUPPLICANT_TASK_STACK_SIZE (6144 + TASK_STACK_SIZE_ADD)
static int handle_action_frm(u8 *frame, size_t len,
u8 *sender, int8_t rssi, u8 channel)
{
struct ieee_mgmt_frame *frm = os_malloc(sizeof(struct ieee_mgmt_frame) + len);
if (!frm) {
wpa_printf(MSG_ERROR, "memory allocation failed");
return -1;
}
os_memcpy(frm->sender, sender, ETH_ALEN);
frm->len = len;
frm->channel = channel;
frm->rssi = rssi;
os_memcpy(frm->payload, frame, len);
if (esp_supplicant_post_evt(SIG_SUPPLICANT_RX_ACTION, (u32)frm) != 0) {
os_free(frm);
return -1;
}
return 0;
}
#endif /* CONFIG_SUPPLICANT_TASK */
static int mgmt_rx_action(u8 *frame, size_t len, u8 *sender, int8_t rssi, u8 channel);
#if defined(CONFIG_RRM)
static void handle_rrm_frame(struct wpa_supplicant *wpa_s, u8 *sender,
@ -120,53 +88,6 @@ static int mgmt_rx_action(u8 *frame, size_t len, u8 *sender, int8_t rssi, u8 cha
return 0;
}
#ifdef CONFIG_SUPPLICANT_TASK
static void btm_rrm_task(void *pvParameters)
{
supplicant_event_t evt;
bool task_del = false;
while (1) {
if (os_queue_recv(s_supplicant_evt_queue, &evt, OS_BLOCK) != TRUE) {
continue;
}
/* event validation failed */
if (evt.id >= SIG_SUPPLICANT_MAX) {
continue;
}
switch (evt.id) {
case SIG_SUPPLICANT_RX_ACTION: {
struct ieee_mgmt_frame *frm = (struct ieee_mgmt_frame *)evt.data;
mgmt_rx_action(frm->payload, frm->len, frm->sender, frm->rssi, frm->channel);
os_free(frm);
break;
}
case SIG_SUPPLICANT_SCAN_DONE:
esp_supplicant_handle_scan_done_evt();
break;
case SIG_SUPPLICANT_DEL_TASK:
task_del = true;
break;
default:
break;
}
if (task_del) {
break;
}
}
os_queue_delete(s_supplicant_evt_queue);
s_supplicant_evt_queue = NULL;
/* At this point, we completed */
os_task_delete(NULL);
}
#endif /* CONFIG_SUPPLICANT_TASK */
static void clear_bssid_flag_and_channel(struct wpa_supplicant *wpa_s)
{
wifi_config_t *config;
@ -304,11 +225,7 @@ static int ieee80211_handle_rx_frm(u8 type, u8 *frame, size_t len, u8 *sender,
break;
#if defined(CONFIG_IEEE80211KV)
case WLAN_FC_STYPE_ACTION:
#ifdef CONFIG_SUPPLICANT_TASK
ret = handle_action_frm(frame, len, sender, rssi, channel);
#else /* CONFIG_SUPPLICANT_TASK */
ret = mgmt_rx_action(frame, len, sender, rssi, channel);
#endif /* CONFIG_SUPPLICANT_TASK */
mgmt_rx_action(frame, len, sender, rssi, channel);
break;
#endif /* defined(CONFIG_IEEE80211KV) */
default:
@ -353,32 +270,6 @@ int esp_supplicant_common_init(struct wpa_funcs *wpa_cb)
int ret = 0;
#if defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R)
#ifdef CONFIG_SUPPLICANT_TASK
if (!s_supplicant_api_lock) {
s_supplicant_api_lock = os_recursive_mutex_create();
}
if (!s_supplicant_api_lock) {
wpa_printf(MSG_ERROR, "%s: failed to create Supplicant API lock", __func__);
ret = -1;
goto err;
}
s_supplicant_evt_queue = os_queue_create(3, sizeof(supplicant_event_t));
if (!s_supplicant_evt_queue) {
wpa_printf(MSG_ERROR, "%s: failed to create Supplicant event queue", __func__);
ret = -1;
goto err;
}
ret = os_task_create(btm_rrm_task, "btm_rrm_t", SUPPLICANT_TASK_STACK_SIZE, NULL, 2, &s_supplicant_task_hdl);
if (ret != TRUE) {
wpa_printf(MSG_ERROR, "btm: failed to create task");
ret = -1;
goto err;
}
s_supplicant_task_init_done = true;
#endif /* CONFIG_SUPPLICANT_TASK */
#if defined(CONFIG_RRM)
wpas_rrm_reset(wpa_s);
wpas_clear_beacon_rep_data(wpa_s);
@ -422,26 +313,6 @@ void esp_supplicant_common_deinit(void)
esp_wifi_register_mgmt_frame_internal(wpa_s->type, wpa_s->subtype);
}
#if defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R)
#ifdef CONFIG_SUPPLICANT_TASK
/* We have failed to create task, delete queue and exit */
if (!s_supplicant_task_hdl) {
if (s_supplicant_evt_queue) {
os_queue_delete(s_supplicant_evt_queue);
s_supplicant_evt_queue = NULL;
}
if (s_supplicant_api_lock) {
os_mutex_delete(s_supplicant_api_lock);
s_supplicant_api_lock = NULL;
}
} else if (esp_supplicant_post_evt(SIG_SUPPLICANT_DEL_TASK, 0) != 0) {
/* failed to post delete event, just delete event queue and exit */
if (s_supplicant_evt_queue) {
os_queue_delete(s_supplicant_evt_queue);
s_supplicant_evt_queue = NULL;
}
}
s_supplicant_task_init_done = false;
#endif /* CONFIG_SUPPLICANT_TASK */
#endif /* defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) */
}

View File

@ -21,20 +21,6 @@ struct ieee_mgmt_frame {
u8 payload[0];
};
int esp_supplicant_post_evt(uint32_t evt_id, uint32_t data);
typedef struct {
uint32_t id;
uint32_t data;
} supplicant_event_t;
enum SIG_SUPPLICANT {
SIG_SUPPLICANT_RX_ACTION,
SIG_SUPPLICANT_SCAN_DONE,
SIG_SUPPLICANT_DEL_TASK,
SIG_SUPPLICANT_MAX,
};
void esp_get_tx_power(uint8_t *tx_power);
#ifdef CONFIG_MBO
bool mbo_bss_profile_match(u8 *bssid);

View File

@ -22,6 +22,7 @@
#include "common/wnm_sta.h"
#include "esp_scan_i.h"
#include "esp_common_i.h"
#include "eloop.h"
extern struct wpa_supplicant g_wpa_supp;
@ -35,13 +36,7 @@ static void scan_done_event_handler(void *arg, ETS_STATUS status)
wpa_s->type &= ~(1 << WLAN_FC_STYPE_BEACON) & ~(1 << WLAN_FC_STYPE_PROBE_RESP);
esp_wifi_register_mgmt_frame_internal(wpa_s->type, wpa_s->subtype);
}
#ifdef CONFIG_SUPPLICANT_TASK
if (esp_supplicant_post_evt(SIG_SUPPLICANT_SCAN_DONE, 0) != 0) {
wpa_printf(MSG_ERROR, "Posting of scan done failed!");
}
#else
esp_supplicant_handle_scan_done_evt();
#endif /*CONFIG_SUPPLICANT_TASK*/
}
#if defined(CONFIG_WNM)