summaryrefslogtreecommitdiff
path: root/qcwcn/wifi_hal/wifi_hal.cpp
diff options
context:
space:
mode:
authorSrinivas Dasari <dasaris@codeaurora.org>2017-02-17 17:00:09 +0530
committerEcco Park <eccopark@google.com>2017-03-09 17:23:32 +0000
commitf58c12182ec6ff0a64c3ee7e2f8d3e6256751f16 (patch)
treed9bc63a5d66275a4a7e1b49e4042015c39cfa24c /qcwcn/wifi_hal/wifi_hal.cpp
parentcb5c6d1cb7df43666f916f837b5e4e3ef6ccca01 (diff)
downloadwlan-f58c12182ec6ff0a64c3ee7e2f8d3e6256751f16.tar.gz
WiFi-HAL: changes to support cld80211 family
wifihal debug infrastructure recieves host logs, firmware logs and other debug stats from driver on NETLINK_USERSOCK. Use cld80211 library APIs to receive the same inorder to migrate from NETLINK_USERSOCK to NETLINK_GENERIC. Change-Id: I3eca2ff02ababd3255e3876b2e247eb0d3071e67
Diffstat (limited to 'qcwcn/wifi_hal/wifi_hal.cpp')
-rw-r--r--qcwcn/wifi_hal/wifi_hal.cpp96
1 files changed, 90 insertions, 6 deletions
diff --git a/qcwcn/wifi_hal/wifi_hal.cpp b/qcwcn/wifi_hal/wifi_hal.cpp
index 59ef8b5..822d6bc 100644
--- a/qcwcn/wifi_hal/wifi_hal.cpp
+++ b/qcwcn/wifi_hal/wifi_hal.cpp
@@ -38,6 +38,7 @@
#include <dirent.h>
#include <net/if.h>
#include <netinet/in.h>
+#include <cld80211_lib.h>
#include "sync.h"
@@ -294,6 +295,27 @@ static wifi_error wifi_init_user_sock(hal_info *info)
return WIFI_SUCCESS;
}
+static wifi_error wifi_init_cld80211_sock_cb(hal_info *info)
+{
+ struct nl_cb *cb = nl_socket_get_cb(info->cldctx->sock);
+ if (cb == NULL) {
+ ALOGE("Could not get cb");
+ return WIFI_ERROR_UNKNOWN;
+ }
+
+ info->user_sock_arg = 1;
+ nl_cb_set(cb, NL_CB_SEQ_CHECK, NL_CB_CUSTOM, no_seq_check, NULL);
+ nl_cb_err(cb, NL_CB_CUSTOM, error_handler, &info->user_sock_arg);
+ nl_cb_set(cb, NL_CB_FINISH, NL_CB_CUSTOM, finish_handler, &info->user_sock_arg);
+ nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM, ack_handler, &info->user_sock_arg);
+
+ nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, user_sock_message_handler, info);
+ nl_cb_put(cb);
+
+ return WIFI_SUCCESS;
+}
+
+
/*initialize function pointer table with Qualcomm HAL API*/
wifi_error init_wifi_vendor_hal_func_table(wifi_hal_fn *fn) {
if (fn == NULL) {
@@ -390,6 +412,20 @@ wifi_error init_wifi_vendor_hal_func_table(wifi_hal_fn *fn) {
return WIFI_SUCCESS;
}
+static void cld80211lib_cleanup(hal_info *info)
+{
+ if (!info->cldctx)
+ return;
+ cld80211_remove_mcast_group(info->cldctx, "host_logs");
+ cld80211_remove_mcast_group(info->cldctx, "fw_logs");
+ cld80211_remove_mcast_group(info->cldctx, "per_pkt_stats");
+ cld80211_remove_mcast_group(info->cldctx, "diag_events");
+ cld80211_remove_mcast_group(info->cldctx, "fatal_events");
+ exit_cld80211_recv(info->cldctx);
+ cld80211_deinit(info->cldctx);
+ info->cldctx = NULL;
+}
+
wifi_error wifi_initialize(wifi_handle *handle)
{
int err = 0;
@@ -398,6 +434,7 @@ wifi_error wifi_initialize(wifi_handle *handle)
struct nl_sock *cmd_sock = NULL;
struct nl_sock *event_sock = NULL;
struct nl_cb *cb = NULL;
+ int status = 0;
ALOGI("Initializing wifi");
hal_info *info = (hal_info *)malloc(sizeof(hal_info));
@@ -495,10 +532,46 @@ wifi_error wifi_initialize(wifi_handle *handle)
wifi_add_membership(*handle, "regulatory");
wifi_add_membership(*handle, "vendor");
- ret = wifi_init_user_sock(info);
- if (ret != WIFI_SUCCESS) {
- ALOGE("Failed to alloc user socket");
- goto unload;
+ info->cldctx = cld80211_init();
+ if (info->cldctx != NULL) {
+ info->user_sock = info->cldctx->sock;
+ ret = wifi_init_cld80211_sock_cb(info);
+ if (ret != WIFI_SUCCESS) {
+ ALOGE("Could not set cb for CLD80211 family");
+ goto cld80211_cleanup;
+ }
+
+ status = cld80211_add_mcast_group(info->cldctx, "host_logs");
+ if (status) {
+ ALOGE("Failed to add mcast group host_logs :%d", status);
+ goto cld80211_cleanup;
+ }
+ status = cld80211_add_mcast_group(info->cldctx, "fw_logs");
+ if (status) {
+ ALOGE("Failed to add mcast group fw_logs :%d", status);
+ goto cld80211_cleanup;
+ }
+ status = cld80211_add_mcast_group(info->cldctx, "per_pkt_stats");
+ if (status) {
+ ALOGE("Failed to add mcast group per_pkt_stats :%d", status);
+ goto cld80211_cleanup;
+ }
+ status = cld80211_add_mcast_group(info->cldctx, "diag_events");
+ if (status) {
+ ALOGE("Failed to add mcast group diag_events :%d", status);
+ goto cld80211_cleanup;
+ }
+ status = cld80211_add_mcast_group(info->cldctx, "fatal_events");
+ if (status) {
+ ALOGE("Failed to add mcast group fatal_events :%d", status);
+ goto cld80211_cleanup;
+ }
+ } else {
+ ret = wifi_init_user_sock(info);
+ if (ret != WIFI_SUCCESS) {
+ ALOGE("Failed to alloc user socket");
+ goto unload;
+ }
}
ret = wifi_init_interfaces(*handle);
@@ -598,6 +671,11 @@ wifi_error wifi_initialize(wifi_handle *handle)
ALOGV("Initialized Wifi HAL Successfully; vendor cmd = %d Supported"
" features : %x", NL80211_CMD_VENDOR, info->supported_feature_set);
+cld80211_cleanup:
+ if (status != 0 || ret != WIFI_SUCCESS) {
+ ret = WIFI_ERROR_UNKNOWN;
+ cld80211lib_cleanup(info);
+ }
unload:
if (ret != WIFI_SUCCESS) {
if (cmd_sock)
@@ -607,7 +685,11 @@ unload:
if (info) {
if (info->cmd) free(info->cmd);
if (info->event_cb) free(info->event_cb);
- if (info->user_sock) nl_socket_free(info->user_sock);
+ if (info->cldctx) {
+ cld80211lib_cleanup(info);
+ } else if (info->user_sock) {
+ nl_socket_free(info->user_sock);
+ }
if (info->pkt_stats) free(info->pkt_stats);
if (info->rx_aggr_pkts) free(info->rx_aggr_pkts);
cleanupGscanHandlers(info);
@@ -649,7 +731,9 @@ static void internal_cleaned_up_handler(wifi_handle handle)
info->event_sock = NULL;
}
- if (info->user_sock != 0) {
+ if (info->cldctx != NULL) {
+ cld80211lib_cleanup(info);
+ } else if (info->user_sock != 0) {
nl_socket_free(info->user_sock);
info->user_sock = NULL;
}