summaryrefslogtreecommitdiff
path: root/qcwcn/wifi_hal/wifi_hal.cpp
diff options
context:
space:
mode:
authorAhmed ElArabawy <arabawy@google.com>2018-03-02 14:26:10 -0800
committerAhmed ElArabawy <arabawy@google.com>2018-03-06 19:54:42 +0000
commitc96959f7cd9a29bb7f6eafc77c0b170ba8aa8536 (patch)
treeace6ff44c8c4b05909fd66d305d8e34886f229fe /qcwcn/wifi_hal/wifi_hal.cpp
parent6dce6cfcf80c98cd4dd7bd21e6b4fa0d466cbdb1 (diff)
downloadwlan-c96959f7cd9a29bb7f6eafc77c0b170ba8aa8536.tar.gz
WiFi: Vendor HAL function to wait for driver ready
This commit adds a vendor hal function to wait for the driver to be ready. This ensures the driver is ready for operatin before framework starts to use it Bug: 73482286 Test: Manual test (reboot and make sure wifi comes up consistently) Test: The reboot test has been performed more than 10 times in a row Test: Also, tested toggling wifi off/on then rebooted, wifi starts fine Change-Id: Ife5a15863b224d59cf04d6dc35b5b5fb85f9161c Signed-off-by: Ahmed ElArabawy <arabawy@google.com>
Diffstat (limited to 'qcwcn/wifi_hal/wifi_hal.cpp')
-rw-r--r--qcwcn/wifi_hal/wifi_hal.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/qcwcn/wifi_hal/wifi_hal.cpp b/qcwcn/wifi_hal/wifi_hal.cpp
index 01b8753..efeed77 100644
--- a/qcwcn/wifi_hal/wifi_hal.cpp
+++ b/qcwcn/wifi_hal/wifi_hal.cpp
@@ -66,6 +66,13 @@
#define WIFI_HAL_CMD_SOCK_PORT 644
#define WIFI_HAL_EVENT_SOCK_PORT 645
+/*
+ * Defines for wifi_wait_for_driver_ready()
+ * Specify durations between polls and max wait time
+ */
+#define POLL_DRIVER_DURATION_US (100000)
+#define POLL_DRIVER_MAX_TIME_MS (10000)
+
static void internal_event_handler(wifi_handle handle, int events,
struct nl_sock *sock);
static int internal_valid_message_handler(nl_msg *msg, void *arg);
@@ -326,6 +333,7 @@ wifi_error init_wifi_vendor_hal_func_table(wifi_hal_fn *fn) {
}
fn->wifi_initialize = wifi_initialize;
+ fn->wifi_wait_for_driver_ready = wifi_wait_for_driver_ready;
fn->wifi_cleanup = wifi_cleanup;
fn->wifi_event_loop = wifi_event_loop;
fn->wifi_get_supported_feature_set = wifi_get_supported_feature_set;
@@ -707,6 +715,25 @@ unload:
return ret;
}
+wifi_error wifi_wait_for_driver_ready(void)
+{
+ // This function will wait to make sure basic client netdev is created
+ // Function times out after 10 seconds
+ int count = (POLL_DRIVER_MAX_TIME_MS * 1000) / POLL_DRIVER_DURATION_US;
+ FILE *fd;
+
+ do {
+ if ((fd = fopen("/sys/class/net/wlan0", "r")) != NULL) {
+ fclose(fd);
+ return WIFI_SUCCESS;
+ }
+ usleep(POLL_DRIVER_DURATION_US);
+ } while(--count > 0);
+
+ ALOGE("Timed out wating on Driver ready ... ");
+ return WIFI_ERROR_TIMED_OUT;
+}
+
static int wifi_add_membership(wifi_handle handle, const char *group)
{
hal_info *info = getHalInfo(handle);