From 68d1fb64d52132a52bcad3450d6783939d8d9726 Mon Sep 17 00:00:00 2001 From: Vinit Deshpande Date: Mon, 4 Aug 2014 19:23:28 -0700 Subject: Workaround for RTT driver bugs Sometimes there are no results in an RTT event; when this happens there is no HAL callback ever, and no new requests can be generated. To avoid this, we just treat this as no RTT data event. Also, there is no clean up code here; so events are returned for the first command, working around that by adding cleanup code. Renamed all incorrect instances of GSCAN event handlers with RTT event handlers. Also fixed some log entries - as they incorrectly say 'scan started'. Bug: 16637086 Change-Id: I7da27d12b0d8e82f5fcba16fa14e3c444ac1b5ae --- bcmdhd/wifi_hal/common.cpp | 19 ++++++++++--------- bcmdhd/wifi_hal/rtt.cpp | 18 ++++++++++-------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/bcmdhd/wifi_hal/common.cpp b/bcmdhd/wifi_hal/common.cpp index 7d517d7..5739d4b 100644 --- a/bcmdhd/wifi_hal/common.cpp +++ b/bcmdhd/wifi_hal/common.cpp @@ -52,8 +52,9 @@ wifi_error wifi_register_handler(wifi_handle handle, int cmd, nl_recvmsg_msg_cb_ info->event_cb[info->num_event_cb].vendor_subcmd = 0; info->event_cb[info->num_event_cb].cb_func = func; info->event_cb[info->num_event_cb].cb_arg = arg; + ALOGI("Successfully added event handler %p:%p for command %d at %d", + arg, func, cmd, info->num_event_cb); info->num_event_cb++; - ALOGI("Successfully added event handler %p:%p for command %d", arg, func, cmd); result = WIFI_SUCCESS; } @@ -77,9 +78,9 @@ wifi_error wifi_register_vendor_handler(wifi_handle handle, info->event_cb[info->num_event_cb].vendor_subcmd = subcmd; info->event_cb[info->num_event_cb].cb_func = func; info->event_cb[info->num_event_cb].cb_arg = arg; + ALOGI("Added event handler %p:%p for vendor 0x%0x and subcmd 0x%0x at %d", + arg, func, id, subcmd, info->num_event_cb); info->num_event_cb++; - ALOGI("Added event handler %p:%p for vendor 0x%0x and subcmd 0x%0x", - arg, func, id, subcmd); result = WIFI_SUCCESS; } @@ -100,8 +101,8 @@ void wifi_unregister_handler(wifi_handle handle, int cmd) for (int i = 0; i < info->num_event_cb; i++) { if (info->event_cb[i].nl_cmd == cmd) { - ALOGI("Successfully removed event handler %p:%p for cmd = 0x%0x", - info->event_cb[i].cb_arg, info->event_cb[i].cb_func, cmd); + ALOGI("Successfully removed event handler %p:%p for cmd = 0x%0x from %d", + info->event_cb[i].cb_arg, info->event_cb[i].cb_func, cmd, i); memmove(&info->event_cb[i], &info->event_cb[i+1], (info->num_event_cb - i) * sizeof(cb_info)); @@ -124,8 +125,8 @@ void wifi_unregister_vendor_handler(wifi_handle handle, uint32_t id, int subcmd) if (info->event_cb[i].nl_cmd == NL80211_CMD_VENDOR && info->event_cb[i].vendor_id == id && info->event_cb[i].vendor_subcmd == subcmd) { - ALOGI("Successfully removed event handler %p:%p for vendor 0x%0x, subcmd = 0x%0x", - info->event_cb[i].cb_arg, info->event_cb[i].cb_func, id, subcmd); + ALOGI("Successfully removed event handler %p:%p for vendor 0x%0x, subcmd 0x%0x from %d", + info->event_cb[i].cb_arg, info->event_cb[i].cb_func, id, subcmd, i); memmove(&info->event_cb[i], &info->event_cb[i+1], (info->num_event_cb - i) * sizeof(cb_info)); info->num_event_cb--; @@ -148,8 +149,8 @@ wifi_error wifi_register_cmd(wifi_handle handle, int id, WifiCommand *cmd) if (info->num_cmd < info->alloc_cmd) { info->cmd[info->num_cmd].id = id; info->cmd[info->num_cmd].cmd = cmd; + ALOGI("Successfully added command %d: %p at %d", id, cmd, info->num_cmd); info->num_cmd++; - ALOGI("Successfully added command %d: %p", id, cmd); result = WIFI_SUCCESS; } @@ -169,7 +170,7 @@ WifiCommand *wifi_unregister_cmd(wifi_handle handle, int id) cmd = info->cmd[i].cmd; memmove(&info->cmd[i], &info->cmd[i+1], (info->num_cmd - i) * sizeof(cmd_info)); info->num_cmd--; - ALOGI("Successfully removed command %d: %p", id, cmd); + ALOGI("Successfully removed command %d: %p from %d", id, cmd, i); break; } } diff --git a/bcmdhd/wifi_hal/rtt.cpp b/bcmdhd/wifi_hal/rtt.cpp index 1673aca..da3e920 100644 --- a/bcmdhd/wifi_hal/rtt.cpp +++ b/bcmdhd/wifi_hal/rtt.cpp @@ -195,7 +195,7 @@ public: return result; } int start() { - ALOGD("Setting configuration"); + ALOGD("Setting RTT configuration"); WifiRequest request(familyId(), ifaceId()); int result = createSetupRequest(request); if (result != WIFI_SUCCESS) { @@ -205,17 +205,17 @@ public: result = requestResponse(request); if (result != WIFI_SUCCESS) { - ALOGE("failed to configure setup; result = %d", result); + ALOGE("failed to configure RTT setup; result = %d", result); return result; } registerVendorHandler(GOOGLE_OUI, RTT_EVENT_COMPLETE); - ALOGI("successfully restarted the scan"); + ALOGI("Successfully started RTT operation"); return result; } virtual int cancel() { - ALOGD("Stopping scan"); + ALOGD("Stopping RTT"); WifiRequest request(familyId(), ifaceId()); int result = createTeardownRequest(request, 0, NULL); @@ -228,7 +228,7 @@ public: } } - unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_SCAN_RESULTS_AVAILABLE); + unregisterVendorHandler(GOOGLE_OUI, RTT_EVENT_COMPLETE); return WIFI_SUCCESS; } @@ -242,11 +242,11 @@ public: } else { result = requestResponse(request); if (result != WIFI_SUCCESS) { - ALOGE("failed to stop scan; result = %d", result); + ALOGE("failed to stop RTT; result = %d", result); } } - unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_SCAN_RESULTS_AVAILABLE); + unregisterVendorHandler(GOOGLE_OUI, RTT_EVENT_COMPLETE); return WIFI_SUCCESS; } @@ -265,9 +265,11 @@ public: if (vendor_data == NULL || len == 0) { ALOGI("No rtt results found"); - return NL_SKIP; } + unregisterVendorHandler(GOOGLE_OUI, RTT_EVENT_COMPLETE); + wifi_unregister_cmd(wifiHandle(), id()); + memset(rttResults, 0, sizeof(wifi_rtt_result) * MAX_RESULTS); int num = len / sizeof(wifi_rtt_result); -- cgit v1.2.3