summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAjay <ajay.davanageri@broadcom.com>2021-03-26 16:28:21 +0530
committerchenpaul <chenpaul@google.com>2021-04-19 19:42:30 +0800
commitaa5a7a948926e19954f58199fdc515792e0173b7 (patch)
tree2a4e9136b5f7449f7e5e2e5b06776b18a20438e6
parent0068b27e70a2529d852f25b04424f6b44e776dc5 (diff)
downloadwlan-aa5a7a948926e19954f58199fdc515792e0173b7.tar.gz
New API in HAL to trigger SSR by framework for recovery.
API name: wifi_trigger_subsystem_restart Bug: 183483123 Test: Verified using halutil, value getting reflected. Change-Id: Ia63d2ac73c1d23dac546f8558f5e1358fc564ed3
-rwxr-xr-xbcmdhd/wifi_hal/common.h7
-rwxr-xr-xbcmdhd/wifi_hal/wifi_hal.cpp1
-rwxr-xr-xbcmdhd/wifi_hal/wifi_logger.cpp104
3 files changed, 112 insertions, 0 deletions
diff --git a/bcmdhd/wifi_hal/common.h b/bcmdhd/wifi_hal/common.h
index df653a3..d5bc971 100755
--- a/bcmdhd/wifi_hal/common.h
+++ b/bcmdhd/wifi_hal/common.h
@@ -135,6 +135,10 @@ typedef enum {
ANDROID_NL80211_SUBCMD_USABLE_CHANNEL_START = 0x2150,
ANDROID_NL80211_SUBCMD_USABLE_CHANNEL_END = 0x215F,
+ /* define all init/deinit related commands between 0x2160 and 0x216F */
+ ANDROID_NL80211_SUBCMD_INIT_DEINIT_RANGE_START = 0x2160,
+ ANDROID_NL80211_SUBCMD_INIT_DEINIT_RANGE_END = 0x216F,
+
/* This is reserved for future usage */
} ANDROID_VENDOR_SUB_COMMAND;
@@ -224,6 +228,7 @@ typedef enum {
WIFI_SUBCMD_GET_OTA_CURRUNT_INFO = ANDROID_NL80211_SUBCMD_OTA_DOWNLOAD_START,
WIFI_SUBCMD_OTA_UPDATE,
WIFI_SUBCMD_USABLE_CHANNEL = ANDROID_NL80211_SUBCMD_USABLE_CHANNEL_START,
+ WIFI_SUBCMD_TRIGGER_SSR = ANDROID_NL80211_SUBCMD_INIT_DEINIT_RANGE_START,
} WIFI_SUB_COMMAND;
@@ -323,6 +328,7 @@ typedef struct {
interface_info **interfaces; // array of interfaces
int num_interfaces; // number of interfaces
int max_num_interfaces; // max number of interfaces
+ wifi_subsystem_restart_handler restart_handler; // trigger sub system handler
// add other details
@@ -516,6 +522,7 @@ wifi_error twt_get_stats(wifi_interface_handle iface, u8 config_id, TwtStats* st
*/
wifi_error twt_clear_stats(wifi_interface_handle iface, u8 config_id);
+wifi_error wifi_trigger_subsystem_restart(wifi_handle handle);
// some common macros
#define min(x, y) ((x) < (y) ? (x) : (y))
diff --git a/bcmdhd/wifi_hal/wifi_hal.cpp b/bcmdhd/wifi_hal/wifi_hal.cpp
index abe89a5..0146258 100755
--- a/bcmdhd/wifi_hal/wifi_hal.cpp
+++ b/bcmdhd/wifi_hal/wifi_hal.cpp
@@ -329,6 +329,7 @@ wifi_error init_wifi_vendor_hal_func_table(wifi_hal_fn *fn)
fn->wifi_set_voip_mode = wifi_set_voip_mode;
fn->wifi_set_dtim_config = wifi_set_dtim_config;
fn->wifi_get_usable_channels = wifi_get_usable_channels;
+ fn->wifi_trigger_subsystem_restart = wifi_trigger_subsystem_restart;
return WIFI_SUCCESS;
}
diff --git a/bcmdhd/wifi_hal/wifi_logger.cpp b/bcmdhd/wifi_hal/wifi_logger.cpp
index b71b45e..2301290 100755
--- a/bcmdhd/wifi_hal/wifi_logger.cpp
+++ b/bcmdhd/wifi_hal/wifi_logger.cpp
@@ -26,6 +26,7 @@
#include <netpacket/packet.h>
#include <linux/filter.h>
#include <linux/errqueue.h>
+#include <errno.h>
#include <linux/pkt_sched.h>
#include <netlink/object-api.h>
@@ -47,6 +48,7 @@
#include "wifi_hal.h"
#include "common.h"
#include "cpp_bindings.h"
+#include <sys/stat.h>
#include "brcm_version.h"
#define WIFI_HAL_EVENT_SOCK_PORT 645
@@ -989,6 +991,54 @@ public:
};
///////////////////////////////////////////////////////////////////////////////
+class SubSystemRestart : public WifiCommand
+{
+ public:
+ SubSystemRestart(wifi_interface_handle iface)
+ : WifiCommand("SubSystemRestart", iface, 0)
+ { }
+
+ int createRequest(WifiRequest& request) {
+ int result = request.create(GOOGLE_OUI, WIFI_SUBCMD_TRIGGER_SSR);
+ if (result < 0) {
+ return result;
+ }
+
+ nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA);
+
+ request.attr_end(data);
+ return WIFI_SUCCESS;
+ }
+
+ int create() {
+ WifiRequest request(familyId(), ifaceId());
+
+ int result = createRequest(request);
+ if (result < 0) {
+ ALOGE("Failed to create ssr request result = %d\n", result);
+ return result;
+ }
+
+ result = requestResponse(request);
+ if (result != WIFI_SUCCESS) {
+ ALOGE("Failed to register ssr response; result = %d\n", result);
+ }
+ return result;
+ }
+
+ protected:
+ int handleResponse(WifiEvent& reply) {
+ /* Nothing to do on response! */
+ return NL_OK;
+ }
+
+ int handleEvent(WifiEvent& event) {
+ /* NO events to handle here! */
+ return NL_SKIP;
+ }
+
+};
+///////////////////////////////////////////////////////////////////////////////
class HalInit : public WifiCommand
{
int mErrCode;
@@ -1132,6 +1182,14 @@ wifi_error wifi_stop_hal(wifi_interface_handle iface)
wifi_error wifi_set_subsystem_restart_handler(wifi_handle handle,
wifi_subsystem_restart_handler handler)
{
+ hal_info *info = NULL;
+
+ info = (hal_info *)handle;
+ if (info == NULL) {
+ ALOGE("Could not find hal info\n");
+ return WIFI_ERROR_UNKNOWN;
+ }
+
SetRestartHandler *cmd = new SetRestartHandler(handle, HAL_RESTART_ID, handler);
NULL_CHECK_RETURN(cmd, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY);
wifi_error result = wifi_register_cmd(handle, HAL_RESTART_ID, cmd);
@@ -1139,15 +1197,61 @@ wifi_error wifi_set_subsystem_restart_handler(wifi_handle handle,
cmd->releaseRef();
return result;
}
+
result = (wifi_error)cmd->start();
if (result != WIFI_SUCCESS) {
wifi_unregister_cmd(handle, HAL_RESTART_ID);
cmd->releaseRef();
return result;
}
+
+ /* Cache the handler to use it for trigger subsystem restart */
+ info->restart_handler = handler;
return result;
}
+wifi_error wifi_trigger_subsystem_restart(wifi_handle handle)
+{
+ wifi_error result = WIFI_SUCCESS;
+ hal_info *info = NULL;
+ char error_str[20];
+ SubSystemRestart *cmd = NULL;
+ wifi_interface_handle *ifaceHandles = NULL;
+ wifi_interface_handle wlan0Handle;
+ int numIfaceHandles = 0;
+
+ info = (hal_info *)handle;
+ if (handle == NULL || info == NULL) {
+ ALOGE("Could not find hal info\n");
+ result = WIFI_ERROR_UNKNOWN;
+ goto exit;
+ }
+
+ ALOGI("Trigger subsystem restart\n");
+
+ wlan0Handle = wifi_get_wlan_interface((wifi_handle)handle, ifaceHandles, numIfaceHandles);
+
+ cmd = new SubSystemRestart(wlan0Handle);
+ NULL_CHECK_RETURN(cmd, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY);
+
+ result = (wifi_error)cmd->create();
+ if (result != WIFI_SUCCESS) {
+ cmd->releaseRef();
+ strncpy(error_str, "WIFI_ERROR_UNKNOWN", sizeof(error_str));
+ goto exit;
+ }
+
+ strncpy(error_str, "WIFI_SUCCESS", sizeof(error_str));
+
+exit:
+ if (info->restart_handler.on_subsystem_restart) {
+ (info->restart_handler.on_subsystem_restart)(error_str);
+ } else {
+ ALOGW("No trigger ssr handler registered");
+ }
+
+ return result;
+}
wifi_error wifi_set_alert_handler(wifi_request_id id, wifi_interface_handle iface,
wifi_alert_handler handler)