Jeff Johnson | 2b0a7b8 | 2016-05-18 15:08:02 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved. |
| 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | |
| 22 | /* |
| 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
| 27 | |
| 28 | /** |
| 29 | * DOC: wlan_hdd_lpass.c |
| 30 | * |
| 31 | * WLAN Host Device Driver LPASS feature implementation |
| 32 | * |
| 33 | */ |
| 34 | |
| 35 | /* Include Files */ |
| 36 | #include "wlan_hdd_main.h" |
| 37 | #include "wlan_hdd_lpass.h" |
| 38 | #include <cds_utils.h> |
| 39 | #include "qwlan_version.h" |
| 40 | |
| 41 | static int wlan_hdd_gen_wlan_status_pack(struct wlan_status_data *data, |
| 42 | hdd_adapter_t *adapter, |
| 43 | hdd_station_ctx_t *pHddStaCtx, |
| 44 | uint8_t is_on, uint8_t is_connected) |
| 45 | { |
| 46 | hdd_context_t *hdd_ctx = NULL; |
| 47 | uint8_t buflen = WLAN_SVC_COUNTRY_CODE_LEN; |
| 48 | |
| 49 | if (!data) { |
| 50 | hddLog(LOGE, FL("invalid data pointer")); |
| 51 | return -EINVAL; |
| 52 | } |
| 53 | if (!adapter) { |
| 54 | if (is_on) { |
| 55 | /* no active interface */ |
| 56 | data->lpss_support = 0; |
| 57 | data->is_on = is_on; |
| 58 | return 0; |
| 59 | } |
| 60 | hddLog(LOGE, FL("invalid adapter pointer")); |
| 61 | return -EINVAL; |
| 62 | } |
| 63 | |
| 64 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 65 | if (hdd_ctx->lpss_support && hdd_ctx->config->enable_lpass_support) |
| 66 | data->lpss_support = 1; |
| 67 | else |
| 68 | data->lpss_support = 0; |
| 69 | data->numChannels = WLAN_SVC_MAX_NUM_CHAN; |
| 70 | sme_get_cfg_valid_channels(hdd_ctx->hHal, data->channel_list, |
| 71 | &data->numChannels); |
| 72 | sme_get_country_code(hdd_ctx->hHal, data->country_code, &buflen); |
| 73 | data->is_on = is_on; |
| 74 | data->vdev_id = adapter->sessionId; |
| 75 | data->vdev_mode = adapter->device_mode; |
| 76 | if (pHddStaCtx) { |
| 77 | data->is_connected = is_connected; |
| 78 | data->rssi = adapter->rssi; |
| 79 | data->freq = |
| 80 | cds_chan_to_freq(pHddStaCtx->conn_info.operationChannel); |
| 81 | if (WLAN_SVC_MAX_SSID_LEN >= |
| 82 | pHddStaCtx->conn_info.SSID.SSID.length) { |
| 83 | data->ssid_len = pHddStaCtx->conn_info.SSID.SSID.length; |
| 84 | memcpy(data->ssid, |
| 85 | pHddStaCtx->conn_info.SSID.SSID.ssId, |
| 86 | pHddStaCtx->conn_info.SSID.SSID.length); |
| 87 | } |
| 88 | if (QDF_MAC_ADDR_SIZE >= |
| 89 | sizeof(pHddStaCtx->conn_info.bssId)) |
| 90 | memcpy(data->bssid, pHddStaCtx->conn_info.bssId.bytes, |
| 91 | QDF_MAC_ADDR_SIZE); |
| 92 | } |
| 93 | return 0; |
| 94 | } |
| 95 | |
| 96 | static int wlan_hdd_gen_wlan_version_pack(struct wlan_version_data *data, |
| 97 | uint32_t fw_version, |
| 98 | uint32_t chip_id, |
| 99 | const char *chip_name) |
| 100 | { |
| 101 | if (!data) { |
| 102 | hddLog(LOGE, FL("invalid data pointer")); |
| 103 | return -EINVAL; |
| 104 | } |
| 105 | |
| 106 | data->chip_id = chip_id; |
| 107 | strlcpy(data->chip_name, chip_name, WLAN_SVC_MAX_STR_LEN); |
| 108 | if (strncmp(chip_name, "Unknown", 7)) |
| 109 | strlcpy(data->chip_from, "Qualcomm", WLAN_SVC_MAX_STR_LEN); |
| 110 | else |
| 111 | strlcpy(data->chip_from, "Unknown", WLAN_SVC_MAX_STR_LEN); |
| 112 | strlcpy(data->host_version, QWLAN_VERSIONSTR, WLAN_SVC_MAX_STR_LEN); |
| 113 | scnprintf(data->fw_version, WLAN_SVC_MAX_STR_LEN, "%d.%d.%d.%d", |
| 114 | (fw_version & 0xf0000000) >> 28, |
| 115 | (fw_version & 0xf000000) >> 24, |
| 116 | (fw_version & 0xf00000) >> 20, (fw_version & 0x7fff)); |
| 117 | return 0; |
| 118 | } |
| 119 | |
| 120 | void wlan_hdd_send_status_pkg(hdd_adapter_t *adapter, |
| 121 | hdd_station_ctx_t *pHddStaCtx, |
| 122 | uint8_t is_on, uint8_t is_connected) |
| 123 | { |
| 124 | int ret = 0; |
| 125 | struct wlan_status_data data; |
| 126 | |
| 127 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
| 128 | return; |
| 129 | |
| 130 | memset(&data, 0, sizeof(struct wlan_status_data)); |
| 131 | if (is_on) |
| 132 | ret = wlan_hdd_gen_wlan_status_pack(&data, adapter, pHddStaCtx, |
| 133 | is_on, is_connected); |
| 134 | if (!ret) |
| 135 | wlan_hdd_send_svc_nlink_msg(WLAN_SVC_WLAN_STATUS_IND, |
| 136 | &data, |
| 137 | sizeof(struct wlan_status_data)); |
| 138 | } |
| 139 | |
| 140 | void wlan_hdd_send_version_pkg(uint32_t fw_version, |
| 141 | uint32_t chip_id, const char *chip_name) |
| 142 | { |
| 143 | int ret = 0; |
| 144 | struct wlan_version_data data; |
| 145 | |
| 146 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
| 147 | return; |
| 148 | |
| 149 | memset(&data, 0, sizeof(struct wlan_version_data)); |
| 150 | ret = |
| 151 | wlan_hdd_gen_wlan_version_pack(&data, fw_version, chip_id, |
| 152 | chip_name); |
| 153 | if (!ret) |
| 154 | wlan_hdd_send_svc_nlink_msg(WLAN_SVC_WLAN_VERSION_IND, |
| 155 | &data, |
| 156 | sizeof(struct wlan_version_data)); |
| 157 | } |
| 158 | |
| 159 | void wlan_hdd_send_all_scan_intf_info(hdd_context_t *hdd_ctx) |
| 160 | { |
| 161 | hdd_adapter_t *pDataAdapter = NULL; |
| 162 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
| 163 | bool scan_intf_found = false; |
| 164 | QDF_STATUS status; |
| 165 | |
| 166 | if (!hdd_ctx) { |
| 167 | hddLog(QDF_TRACE_LEVEL_ERROR, |
| 168 | FL("NULL pointer for hdd_ctx")); |
| 169 | return; |
| 170 | } |
| 171 | |
| 172 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 173 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
| 174 | pDataAdapter = adapterNode->pAdapter; |
| 175 | if (pDataAdapter) { |
| 176 | if (pDataAdapter->device_mode == QDF_STA_MODE |
| 177 | || pDataAdapter->device_mode == QDF_P2P_CLIENT_MODE |
| 178 | || pDataAdapter->device_mode == |
| 179 | QDF_P2P_DEVICE_MODE) { |
| 180 | scan_intf_found = true; |
| 181 | wlan_hdd_send_status_pkg(pDataAdapter, NULL, 1, |
| 182 | 0); |
| 183 | } |
| 184 | } |
| 185 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 186 | adapterNode = pNext; |
| 187 | } |
| 188 | |
| 189 | if (!scan_intf_found) |
| 190 | wlan_hdd_send_status_pkg(pDataAdapter, NULL, 1, 0); |
| 191 | } |