Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Jeff Johnson | 86bef3e | 2018-12-26 19:57:01 -0800 | [diff] [blame] | 2 | * Copyright (c) 2012-2019 The Linux Foundation. All rights reserved. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4 | * Permission to use, copy, modify, and/or distribute this software for |
| 5 | * any purpose with or without fee is hereby granted, provided that the |
| 6 | * above copyright notice and this permission notice appear in all |
| 7 | * copies. |
| 8 | * |
| 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 10 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 11 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 12 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 13 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 14 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 15 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 16 | * PERFORMANCE OF THIS SOFTWARE. |
| 17 | */ |
| 18 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19 | /* Include Files */ |
| 20 | |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 21 | #include "osif_sync.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 22 | #include <wlan_hdd_includes.h> |
| 23 | #include <wlan_hdd_wowl.h> |
Jeff Johnson | 5fe539b | 2018-03-23 13:53:30 -0700 | [diff] [blame] | 24 | #include <wlan_hdd_stats.h> |
Pragaspathi Thilagaraj | 3cf0f65 | 2018-10-29 16:40:35 +0530 | [diff] [blame] | 25 | #include "cfg_ucfg_api.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 26 | #include "wlan_hdd_trace.h" |
| 27 | #include "wlan_hdd_ioctl.h" |
| 28 | #include "wlan_hdd_power.h" |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 29 | #include "wlan_hdd_regulatory.h" |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 30 | #include "wlan_osif_request_manager.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 31 | #include "wlan_hdd_driver_ops.h" |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 32 | #include "wlan_policy_mgr_api.h" |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 33 | #include "wlan_hdd_hostapd.h" |
Rajeev Kumar | ea95edd | 2017-01-11 20:49:36 -0800 | [diff] [blame] | 34 | #include "scheduler_api.h" |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 35 | #include "wlan_reg_ucfg_api.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 36 | #include "wlan_hdd_p2p.h" |
| 37 | #include <linux/ctype.h> |
| 38 | #include "wma.h" |
| 39 | #include "wlan_hdd_napi.h" |
Wu Gao | 9381621 | 2018-08-31 16:49:54 +0800 | [diff] [blame] | 40 | #include "wlan_mlme_ucfg_api.h" |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 41 | #ifdef FEATURE_WLAN_ESE |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 42 | #include <sme_api.h> |
| 43 | #include <sir_api.h> |
| 44 | #endif |
| 45 | #include "hif.h" |
Harprit Chhabada | 4691a47 | 2018-12-07 11:22:48 -0800 | [diff] [blame] | 46 | #include "wlan_scan_ucfg_api.h" |
Harprit Chhabada | 5dff30e | 2019-03-12 17:56:45 -0700 | [diff] [blame] | 47 | #include "wlan_reg_ucfg_api.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 48 | |
| 49 | #if defined(LINUX_QCMBR) |
| 50 | #define SIOCIOCTLTX99 (SIOCDEVPRIVATE+13) |
| 51 | #endif |
| 52 | |
| 53 | /* |
| 54 | * Size of Driver command strings from upper layer |
| 55 | */ |
| 56 | #define SIZE_OF_SETROAMMODE 11 /* size of SETROAMMODE */ |
| 57 | #define SIZE_OF_GETROAMMODE 11 /* size of GETROAMMODE */ |
Pragaspathi Thilagaraj | aa8320e | 2019-04-16 02:47:50 +0530 | [diff] [blame] | 58 | #define SIZE_OF_SETSUSPENDMODE 14 |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 59 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 60 | /* |
Rajeev Kumar Sirasanagandla | 32ae804 | 2019-03-25 16:37:02 +0530 | [diff] [blame] | 61 | * Size of GETCOUNTRYREV output = (sizeof("GETCOUNTRYREV") = 14) + one (space) + |
| 62 | * (sizeof("country_code") = 3) + |
| 63 | * one (NULL terminating character) |
| 64 | */ |
| 65 | #define SIZE_OF_GETCOUNTRYREV_OUTPUT 20 |
| 66 | |
| 67 | /* |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 68 | * Ibss prop IE from command will be of size: |
| 69 | * size = sizeof(oui) + sizeof(oui_data) + 1(Element ID) + 1(EID Length) |
| 70 | * OUI_DATA should be at least 3 bytes long |
| 71 | */ |
| 72 | #define WLAN_HDD_IBSS_MIN_OUI_DATA_LENGTH (3) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 73 | |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 74 | #ifdef FEATURE_WLAN_ESE |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 75 | #define TID_MIN_VALUE 0 |
| 76 | #define TID_MAX_VALUE 15 |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 77 | #endif /* FEATURE_WLAN_ESE */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 78 | |
| 79 | /* |
| 80 | * Maximum buffer size used for returning the data back to user space |
| 81 | */ |
| 82 | #define WLAN_MAX_BUF_SIZE 1024 |
| 83 | #define WLAN_PRIV_DATA_MAX_LEN 8192 |
| 84 | |
| 85 | /* |
| 86 | * Driver miracast parameters 0-Disabled |
| 87 | * 1-Source, 2-Sink |
| 88 | */ |
| 89 | #define WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL 0 |
| 90 | #define WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL 2 |
| 91 | |
| 92 | /* |
| 93 | * When ever we need to print IBSSPEERINFOALL for more than 16 STA |
| 94 | * we will split the printing. |
| 95 | */ |
| 96 | #define NUM_OF_STA_DATA_TO_PRINT 16 |
| 97 | |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 98 | #ifdef WLAN_FEATURE_EXTWOW_SUPPORT |
| 99 | /** |
| 100 | * struct enable_ext_wow_priv - Private data structure for ext wow |
| 101 | * @ext_wow_should_suspend: Suspend status of ext wow |
| 102 | */ |
| 103 | struct enable_ext_wow_priv { |
| 104 | bool ext_wow_should_suspend; |
| 105 | }; |
| 106 | #endif |
| 107 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 108 | /* |
| 109 | * Android DRIVER command structures |
| 110 | */ |
| 111 | struct android_wifi_reassoc_params { |
| 112 | unsigned char bssid[18]; |
| 113 | int channel; |
| 114 | }; |
| 115 | |
| 116 | #define ANDROID_WIFI_ACTION_FRAME_SIZE 1040 |
| 117 | struct android_wifi_af_params { |
| 118 | unsigned char bssid[18]; |
| 119 | int channel; |
| 120 | int dwell_time; |
| 121 | int len; |
| 122 | unsigned char data[ANDROID_WIFI_ACTION_FRAME_SIZE]; |
| 123 | }; |
| 124 | |
| 125 | /* |
| 126 | * Define HDD driver command handling entry, each contains a command |
| 127 | * string and the handler. |
| 128 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 129 | typedef int (*hdd_drv_cmd_handler_t)(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 130 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 131 | uint8_t *cmd, |
| 132 | uint8_t cmd_name_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 133 | struct hdd_priv_data *priv_data); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 134 | |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 135 | /** |
| 136 | * struct hdd_drv_cmd - Structure to store ioctl command handling info |
| 137 | * @cmd: Name of the command |
| 138 | * @handler: Command handler to be invoked |
| 139 | * @args: Set to true if command expects input parameters |
| 140 | */ |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 141 | struct hdd_drv_cmd { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 142 | const char *cmd; |
| 143 | hdd_drv_cmd_handler_t handler; |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 144 | bool args; |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 145 | }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 146 | |
| 147 | #ifdef WLAN_FEATURE_EXTWOW_SUPPORT |
| 148 | #define WLAN_WAIT_TIME_READY_TO_EXTWOW 2000 |
| 149 | #define WLAN_HDD_MAX_TCP_PORT 65535 |
| 150 | #endif |
| 151 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 152 | static uint16_t cesium_pid; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 153 | |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 154 | /** |
| 155 | * drv_cmd_validate() - Validates for space in hdd driver command |
| 156 | * @command: pointer to input data (its a NULL terminated string) |
| 157 | * @len: length of command name |
| 158 | * |
| 159 | * This function checks for space after command name and if no space |
| 160 | * is found returns error. |
| 161 | * |
| 162 | * Return: 0 for success non-zero for failure |
| 163 | */ |
| 164 | static int drv_cmd_validate(uint8_t *command, int len) |
| 165 | { |
| 166 | if (command[len] != ' ') |
| 167 | return -EINVAL; |
| 168 | |
| 169 | return 0; |
| 170 | } |
| 171 | |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 172 | #ifdef FEATURE_WLAN_ESE |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 173 | struct tsm_priv { |
| 174 | tAniTrafStrmMetrics tsm_metrics; |
| 175 | }; |
| 176 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 177 | static void hdd_get_tsm_stats_cb(tAniTrafStrmMetrics tsm_metrics, |
Sourav Mohapatra | dcd8f8d | 2019-07-03 15:43:15 +0530 | [diff] [blame] | 178 | void *context) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 179 | { |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 180 | struct osif_request *request; |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 181 | struct tsm_priv *priv; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 182 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 183 | request = osif_request_get(context); |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 184 | if (!request) { |
| 185 | hdd_err("Obsolete request"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 186 | return; |
| 187 | } |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 188 | priv = osif_request_priv(request); |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 189 | priv->tsm_metrics = tsm_metrics; |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 190 | osif_request_complete(request); |
| 191 | osif_request_put(request); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 192 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 193 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 194 | } |
| 195 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 196 | static int hdd_get_tsm_stats(struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 197 | const uint8_t tid, |
| 198 | tAniTrafStrmMetrics *tsm_metrics) |
| 199 | { |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 200 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 201 | struct hdd_station_ctx *hdd_sta_ctx; |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 202 | QDF_STATUS status; |
| 203 | int ret; |
| 204 | void *cookie; |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 205 | struct osif_request *request; |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 206 | struct tsm_priv *priv; |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 207 | static const struct osif_request_params params = { |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 208 | .priv_size = sizeof(*priv), |
| 209 | .timeout_ms = WLAN_WAIT_TIME_STATS, |
| 210 | }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 211 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 212 | if (!adapter) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 213 | hdd_err("adapter is NULL"); |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 214 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 215 | } |
| 216 | |
| 217 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 218 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 219 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 220 | request = osif_request_alloc(¶ms); |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 221 | if (!request) { |
| 222 | hdd_err("Request allocation failure"); |
| 223 | return -ENOMEM; |
| 224 | } |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 225 | cookie = osif_request_cookie(request); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 226 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 227 | status = sme_get_tsm_stats(hdd_ctx->mac_handle, hdd_get_tsm_stats_cb, |
Jeff Johnson | e04b699 | 2019-02-27 14:06:55 -0800 | [diff] [blame] | 228 | hdd_sta_ctx->conn_info.bssid, |
Jeff Johnson | 30f8455 | 2017-09-13 14:55:25 -0700 | [diff] [blame] | 229 | cookie, tid); |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 230 | if (QDF_STATUS_SUCCESS != status) { |
| 231 | hdd_err("Unable to retrieve tsm statistics"); |
| 232 | ret = qdf_status_to_os_return(status); |
| 233 | goto cleanup; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 234 | } |
| 235 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 236 | ret = osif_request_wait_for_response(request); |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 237 | if (ret) { |
| 238 | hdd_err("SME timed out while retrieving tsm statistics"); |
| 239 | goto cleanup; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 240 | } |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 241 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 242 | priv = osif_request_priv(request); |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 243 | *tsm_metrics = priv->tsm_metrics; |
| 244 | |
| 245 | cleanup: |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 246 | osif_request_put(request); |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 247 | |
| 248 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 249 | } |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 250 | #endif /*FEATURE_WLAN_ESE */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 251 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 252 | /** |
Rajeev Kumar | 94c9b45 | 2016-03-24 12:58:47 -0700 | [diff] [blame] | 253 | * hdd_get_ibss_peer_info_cb() - IBSS peer Info request callback |
Jeff Johnson | afa022c | 2019-02-26 09:24:17 -0800 | [diff] [blame] | 254 | * @context: callback context (adapter supplied by caller) |
Jeff Johnson | 52f19d5 | 2019-02-26 08:35:38 -0800 | [diff] [blame] | 255 | * @peer_info: Peer info response |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 256 | * |
| 257 | * This is an asynchronous callback function from SME when the peer info |
| 258 | * is received |
| 259 | * |
| 260 | * Return: 0 for success non-zero for failure |
| 261 | */ |
Rajeev Kumar | 94c9b45 | 2016-03-24 12:58:47 -0700 | [diff] [blame] | 262 | void |
Jeff Johnson | afa022c | 2019-02-26 09:24:17 -0800 | [diff] [blame] | 263 | hdd_get_ibss_peer_info_cb(void *context, |
Jeff Johnson | 52f19d5 | 2019-02-26 08:35:38 -0800 | [diff] [blame] | 264 | tSirPeerInfoRspParams *peer_info) |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 265 | { |
Jeff Johnson | afa022c | 2019-02-26 09:24:17 -0800 | [diff] [blame] | 266 | struct hdd_adapter *adapter = context; |
Jeff Johnson | 93107ad | 2019-02-26 08:14:46 -0800 | [diff] [blame] | 267 | struct hdd_station_ctx *sta_ctx; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 268 | uint8_t i; |
| 269 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 270 | if ((!adapter) || |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 271 | (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 272 | hdd_err("invalid adapter or adapter has invalid magic"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 273 | return; |
| 274 | } |
| 275 | |
Jeff Johnson | 93107ad | 2019-02-26 08:14:46 -0800 | [diff] [blame] | 276 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 277 | if (peer_info && QDF_STATUS_SUCCESS == peer_info->status) { |
Rajeev Kumar | 94c9b45 | 2016-03-24 12:58:47 -0700 | [diff] [blame] | 278 | /* validate number of peers */ |
Jeff Johnson | 52f19d5 | 2019-02-26 08:35:38 -0800 | [diff] [blame] | 279 | if (peer_info->numPeers > SIR_MAX_NUM_STA_IN_IBSS) { |
Sriram Madhvapathi | 58f0e27 | 2016-10-03 11:47:51 +0530 | [diff] [blame] | 280 | hdd_warn("Limiting num_peers %u to %u", |
Jeff Johnson | 52f19d5 | 2019-02-26 08:35:38 -0800 | [diff] [blame] | 281 | peer_info->numPeers, SIR_MAX_NUM_STA_IN_IBSS); |
| 282 | peer_info->numPeers = SIR_MAX_NUM_STA_IN_IBSS; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 283 | } |
Jeff Johnson | 52f19d5 | 2019-02-26 08:35:38 -0800 | [diff] [blame] | 284 | sta_ctx->ibss_peer_info.status = peer_info->status; |
| 285 | sta_ctx->ibss_peer_info.numPeers = peer_info->numPeers; |
Sriram Madhvapathi | 58f0e27 | 2016-10-03 11:47:51 +0530 | [diff] [blame] | 286 | |
Jeff Johnson | 52f19d5 | 2019-02-26 08:35:38 -0800 | [diff] [blame] | 287 | for (i = 0; i < peer_info->numPeers; i++) |
Jeff Johnson | 93107ad | 2019-02-26 08:14:46 -0800 | [diff] [blame] | 288 | sta_ctx->ibss_peer_info.peerInfoParams[i] = |
Jeff Johnson | 52f19d5 | 2019-02-26 08:35:38 -0800 | [diff] [blame] | 289 | peer_info->peerInfoParams[i]; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 290 | } else { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 291 | hdd_debug("peerInfo %s: status %u, numPeers %u", |
Jeff Johnson | 52f19d5 | 2019-02-26 08:35:38 -0800 | [diff] [blame] | 292 | peer_info ? "valid" : "null", |
| 293 | peer_info ? peer_info->status : QDF_STATUS_E_FAILURE, |
| 294 | peer_info ? peer_info->numPeers : 0); |
Jeff Johnson | 93107ad | 2019-02-26 08:14:46 -0800 | [diff] [blame] | 295 | sta_ctx->ibss_peer_info.numPeers = 0; |
| 296 | sta_ctx->ibss_peer_info.status = QDF_STATUS_E_FAILURE; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | complete(&adapter->ibss_peer_info_comp); |
| 300 | } |
| 301 | |
| 302 | /** |
| 303 | * hdd_cfg80211_get_ibss_peer_info_all() - get ibss peers' info |
| 304 | * @adapter: Adapter context |
| 305 | * |
| 306 | * Request function to get IBSS peer info from lower layers |
| 307 | * |
| 308 | * Return: 0 for success non-zero for failure |
| 309 | */ |
| 310 | static |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 311 | QDF_STATUS hdd_cfg80211_get_ibss_peer_info_all(struct hdd_adapter *adapter) |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 312 | { |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 313 | QDF_STATUS status; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 314 | unsigned long rc; |
| 315 | |
| 316 | INIT_COMPLETION(adapter->ibss_peer_info_comp); |
| 317 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 318 | status = sme_request_ibss_peer_info(adapter->hdd_ctx->mac_handle, |
| 319 | adapter, |
| 320 | hdd_get_ibss_peer_info_cb, |
| 321 | true, 0xFF); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 322 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 323 | if (QDF_STATUS_SUCCESS == status) { |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 324 | rc = wait_for_completion_timeout |
| 325 | (&adapter->ibss_peer_info_comp, |
| 326 | msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT)); |
| 327 | |
| 328 | /* status will be 0 if timed out */ |
| 329 | if (!rc) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 330 | hdd_warn("Warning: IBSS_PEER_INFO_TIMEOUT"); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 331 | status = QDF_STATUS_E_FAILURE; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 332 | } |
| 333 | } else { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 334 | hdd_warn("Warning: sme_request_ibss_peer_info Request failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 335 | } |
| 336 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 337 | return status; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 338 | } |
| 339 | |
| 340 | /** |
| 341 | * hdd_cfg80211_get_ibss_peer_info() - get ibss peer info |
| 342 | * @adapter: Adapter context |
Jeff Johnson | 0a082d9 | 2019-03-04 12:25:49 -0800 | [diff] [blame] | 343 | * @sta_id: Sta index for which the peer info is requested |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 344 | * |
| 345 | * Request function to get IBSS peer info from lower layers |
| 346 | * |
| 347 | * Return: 0 for success non-zero for failure |
| 348 | */ |
| 349 | static QDF_STATUS |
Jeff Johnson | 0a082d9 | 2019-03-04 12:25:49 -0800 | [diff] [blame] | 350 | hdd_cfg80211_get_ibss_peer_info(struct hdd_adapter *adapter, uint8_t sta_id) |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 351 | { |
| 352 | unsigned long rc; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 353 | QDF_STATUS status; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 354 | |
| 355 | INIT_COMPLETION(adapter->ibss_peer_info_comp); |
| 356 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 357 | status = sme_request_ibss_peer_info(adapter->hdd_ctx->mac_handle, |
| 358 | adapter, |
| 359 | hdd_get_ibss_peer_info_cb, |
Jeff Johnson | 0a082d9 | 2019-03-04 12:25:49 -0800 | [diff] [blame] | 360 | false, sta_id); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 361 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 362 | if (QDF_STATUS_SUCCESS == status) { |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 363 | rc = wait_for_completion_timeout( |
| 364 | &adapter->ibss_peer_info_comp, |
| 365 | msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT)); |
| 366 | |
| 367 | /* status = 0 on timeout */ |
| 368 | if (!rc) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 369 | hdd_warn("Warning: IBSS_PEER_INFO_TIMEOUT"); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 370 | status = QDF_STATUS_E_FAILURE; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 371 | } |
| 372 | } else { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 373 | hdd_warn("Warning: sme_request_ibss_peer_info Request failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 374 | } |
| 375 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 376 | return status; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 377 | } |
| 378 | |
| 379 | /* Function header is left blank intentionally */ |
Jeff Johnson | f731b30 | 2016-10-05 16:00:55 -0700 | [diff] [blame] | 380 | static QDF_STATUS |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 381 | hdd_parse_get_ibss_peer_info(uint8_t *command, |
Jeff Johnson | 64ba9af | 2019-02-26 12:57:35 -0800 | [diff] [blame] | 382 | struct qdf_mac_addr *peer_macaddr) |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 383 | { |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 384 | uint8_t *in_ptr = command; |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 385 | size_t in_ptr_len = strlen(command); |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 386 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 387 | in_ptr = strnchr(command, in_ptr_len, SPACE_ASCII_VALUE); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 388 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 389 | if (!in_ptr) |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 390 | return QDF_STATUS_E_FAILURE; |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 391 | else if (SPACE_ASCII_VALUE != *in_ptr) |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 392 | return QDF_STATUS_E_FAILURE; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 393 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 394 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 395 | in_ptr++; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 396 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 397 | if ('\0' == *in_ptr) |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 398 | return QDF_STATUS_E_FAILURE; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 399 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 400 | in_ptr_len -= (in_ptr - command); |
Min Liu | 5359ab1 | 2018-03-29 14:30:24 +0800 | [diff] [blame] | 401 | if (in_ptr_len < 17) |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 402 | return QDF_STATUS_E_FAILURE; |
Min Liu | 5359ab1 | 2018-03-29 14:30:24 +0800 | [diff] [blame] | 403 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 404 | if (in_ptr[2] != ':' || in_ptr[5] != ':' || in_ptr[8] != ':' || |
| 405 | in_ptr[11] != ':' || in_ptr[14] != ':') |
Min Liu | 5359ab1 | 2018-03-29 14:30:24 +0800 | [diff] [blame] | 406 | return QDF_STATUS_E_FAILURE; |
| 407 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 408 | sscanf(in_ptr, "%2x:%2x:%2x:%2x:%2x:%2x", |
Jeff Johnson | 64ba9af | 2019-02-26 12:57:35 -0800 | [diff] [blame] | 409 | (unsigned int *)&peer_macaddr->bytes[0], |
| 410 | (unsigned int *)&peer_macaddr->bytes[1], |
| 411 | (unsigned int *)&peer_macaddr->bytes[2], |
| 412 | (unsigned int *)&peer_macaddr->bytes[3], |
| 413 | (unsigned int *)&peer_macaddr->bytes[4], |
| 414 | (unsigned int *)&peer_macaddr->bytes[5]); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 415 | |
| 416 | return QDF_STATUS_SUCCESS; |
| 417 | } |
| 418 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 419 | static void hdd_get_band_helper(struct hdd_context *hdd_ctx, int *ui_band) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 420 | { |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 421 | enum band_info band = -1; |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 422 | |
Harprit Chhabada | 5dff30e | 2019-03-12 17:56:45 -0700 | [diff] [blame] | 423 | ucfg_reg_get_band(hdd_ctx->pdev, &band); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 424 | switch (band) { |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 425 | case BAND_ALL: |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 426 | *ui_band = WLAN_HDD_UI_BAND_AUTO; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 427 | break; |
| 428 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 429 | case BAND_2G: |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 430 | *ui_band = WLAN_HDD_UI_BAND_2_4_GHZ; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 431 | break; |
| 432 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 433 | case BAND_5G: |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 434 | *ui_band = WLAN_HDD_UI_BAND_5_GHZ; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 435 | break; |
| 436 | |
| 437 | default: |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 438 | hdd_warn("Invalid Band %d", band); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 439 | *ui_band = -1; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 440 | break; |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | /** |
| 445 | * _hdd_parse_bssid_and_chan() - helper function to parse bssid and channel |
| 446 | * @data: input data |
| 447 | * @target_ap_bssid: pointer to bssid (output parameter) |
| 448 | * @channel: pointer to channel (output parameter) |
| 449 | * |
| 450 | * Return: 0 if parsing is successful; -EINVAL otherwise |
| 451 | */ |
| 452 | static int _hdd_parse_bssid_and_chan(const uint8_t **data, |
| 453 | uint8_t *bssid, |
| 454 | uint8_t *channel) |
| 455 | { |
| 456 | const uint8_t *in_ptr; |
| 457 | int v = 0; |
| 458 | int temp_int; |
| 459 | uint8_t temp_buf[32]; |
| 460 | |
| 461 | /* 12 hexa decimal digits, 5 ':' and '\0' */ |
| 462 | uint8_t mac_addr[18]; |
| 463 | |
| 464 | if (!data || !*data) |
| 465 | return -EINVAL; |
| 466 | |
| 467 | in_ptr = *data; |
| 468 | |
| 469 | in_ptr = strnchr(in_ptr, strlen(in_ptr), SPACE_ASCII_VALUE); |
| 470 | /* no argument after the command */ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 471 | if (!in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 472 | goto error; |
| 473 | /* no space after the command */ |
| 474 | else if (SPACE_ASCII_VALUE != *in_ptr) |
| 475 | goto error; |
| 476 | |
| 477 | /* remove empty spaces */ |
| 478 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 479 | in_ptr++; |
| 480 | |
| 481 | /* no argument followed by spaces */ |
| 482 | if ('\0' == *in_ptr) |
| 483 | goto error; |
| 484 | |
| 485 | v = sscanf(in_ptr, "%17s", mac_addr); |
| 486 | if (!((1 == v) && hdd_is_valid_mac_address(mac_addr))) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 487 | hdd_err("Invalid MAC address or All hex inputs are not read (%d)", |
| 488 | v); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 489 | goto error; |
| 490 | } |
| 491 | |
| 492 | bssid[0] = hex_to_bin(mac_addr[0]) << 4 | |
| 493 | hex_to_bin(mac_addr[1]); |
| 494 | bssid[1] = hex_to_bin(mac_addr[3]) << 4 | |
| 495 | hex_to_bin(mac_addr[4]); |
| 496 | bssid[2] = hex_to_bin(mac_addr[6]) << 4 | |
| 497 | hex_to_bin(mac_addr[7]); |
| 498 | bssid[3] = hex_to_bin(mac_addr[9]) << 4 | |
| 499 | hex_to_bin(mac_addr[10]); |
| 500 | bssid[4] = hex_to_bin(mac_addr[12]) << 4 | |
| 501 | hex_to_bin(mac_addr[13]); |
| 502 | bssid[5] = hex_to_bin(mac_addr[15]) << 4 | |
| 503 | hex_to_bin(mac_addr[16]); |
| 504 | |
| 505 | /* point to the next argument */ |
| 506 | in_ptr = strnchr(in_ptr, strlen(in_ptr), SPACE_ASCII_VALUE); |
| 507 | /* no argument after the command */ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 508 | if (!in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 509 | goto error; |
| 510 | |
| 511 | /* remove empty spaces */ |
| 512 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 513 | in_ptr++; |
| 514 | |
| 515 | /* no argument followed by spaces */ |
| 516 | if ('\0' == *in_ptr) |
| 517 | goto error; |
| 518 | |
| 519 | /* get the next argument ie the channel number */ |
| 520 | v = sscanf(in_ptr, "%31s ", temp_buf); |
| 521 | if (1 != v) |
| 522 | goto error; |
| 523 | |
| 524 | v = kstrtos32(temp_buf, 10, &temp_int); |
| 525 | if ((v < 0) || (temp_int < 0) || |
| 526 | (temp_int > WNI_CFG_CURRENT_CHANNEL_STAMAX)) |
| 527 | return -EINVAL; |
| 528 | |
| 529 | *channel = temp_int; |
| 530 | *data = in_ptr; |
| 531 | return 0; |
| 532 | error: |
| 533 | *data = in_ptr; |
| 534 | return -EINVAL; |
| 535 | } |
| 536 | |
| 537 | /** |
| 538 | * hdd_parse_send_action_frame_data() - HDD Parse send action frame data |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 539 | * @command: Pointer to input data |
Jeff Johnson | b7d5279 | 2019-02-26 12:42:08 -0800 | [diff] [blame] | 540 | * @bssid: Pointer to target Ap bssid |
Jeff Johnson | d727cdc | 2019-02-26 12:47:05 -0800 | [diff] [blame] | 541 | * @channel: Pointer to the Target AP channel |
Jeff Johnson | 80d220a | 2019-02-26 12:27:24 -0800 | [diff] [blame] | 542 | * @dwell_time: Pointer to the time to stay off-channel |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 543 | * after transmitting action frame |
Jeff Johnson | 5f3a612 | 2019-02-26 17:20:59 -0800 | [diff] [blame] | 544 | * @buf: Pointer to data |
Jeff Johnson | 103f67a | 2019-02-26 17:11:01 -0800 | [diff] [blame] | 545 | * @buf_len: Pointer to data length |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 546 | * |
| 547 | * This function parses the send action frame data passed in the format |
| 548 | * SENDACTIONFRAME<space><bssid><space><channel><space><dwelltime><space><data> |
| 549 | * |
| 550 | * Return: 0 for success non-zero for failure |
| 551 | */ |
| 552 | static int |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 553 | hdd_parse_send_action_frame_v1_data(const uint8_t *command, |
Jeff Johnson | b7d5279 | 2019-02-26 12:42:08 -0800 | [diff] [blame] | 554 | uint8_t *bssid, |
Jeff Johnson | d727cdc | 2019-02-26 12:47:05 -0800 | [diff] [blame] | 555 | uint8_t *channel, uint8_t *dwell_time, |
Jeff Johnson | 5f3a612 | 2019-02-26 17:20:59 -0800 | [diff] [blame] | 556 | uint8_t **buf, uint8_t *buf_len) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 557 | { |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 558 | const uint8_t *in_ptr = command; |
Jeff Johnson | aae00ae | 2019-02-26 17:25:11 -0800 | [diff] [blame] | 559 | const uint8_t *end_ptr; |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 560 | int temp_int; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 561 | int j = 0; |
| 562 | int i = 0; |
| 563 | int v = 0; |
Jeff Johnson | 72f498b | 2019-02-26 18:37:25 -0800 | [diff] [blame] | 564 | uint8_t temp_buf[32]; |
| 565 | uint8_t temp_u8 = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 566 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 567 | if (_hdd_parse_bssid_and_chan(&in_ptr, bssid, channel)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 568 | return -EINVAL; |
| 569 | |
| 570 | /* point to the next argument */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 571 | in_ptr = strnchr(in_ptr, strlen(in_ptr), SPACE_ASCII_VALUE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 572 | /* no argument after the command */ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 573 | if (!in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 574 | return -EINVAL; |
| 575 | /* removing empty spaces */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 576 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 577 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 578 | |
| 579 | /* no argument followed by spaces */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 580 | if ('\0' == *in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 581 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 582 | |
| 583 | /* getting the next argument ie the dwell time */ |
Jeff Johnson | 72f498b | 2019-02-26 18:37:25 -0800 | [diff] [blame] | 584 | v = sscanf(in_ptr, "%31s ", temp_buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 585 | if (1 != v) |
| 586 | return -EINVAL; |
| 587 | |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 588 | v = kstrtos32(temp_buf, 10, &temp_int); |
| 589 | if (v < 0 || temp_int < 0) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 590 | return -EINVAL; |
| 591 | |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 592 | *dwell_time = temp_int; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 593 | |
| 594 | /* point to the next argument */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 595 | in_ptr = strnchr(in_ptr, strlen(in_ptr), SPACE_ASCII_VALUE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 596 | /* no argument after the command */ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 597 | if (!in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 598 | return -EINVAL; |
| 599 | /* removing empty spaces */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 600 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 601 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 602 | |
| 603 | /* no argument followed by spaces */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 604 | if ('\0' == *in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 605 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 606 | |
| 607 | /* find the length of data */ |
Jeff Johnson | aae00ae | 2019-02-26 17:25:11 -0800 | [diff] [blame] | 608 | end_ptr = in_ptr; |
| 609 | while (('\0' != *end_ptr)) |
| 610 | end_ptr++; |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 611 | |
Jeff Johnson | aae00ae | 2019-02-26 17:25:11 -0800 | [diff] [blame] | 612 | *buf_len = end_ptr - in_ptr; |
Jeff Johnson | 103f67a | 2019-02-26 17:11:01 -0800 | [diff] [blame] | 613 | if (*buf_len <= 0) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 614 | return -EINVAL; |
| 615 | |
| 616 | /* |
| 617 | * Allocate the number of bytes based on the number of input characters |
| 618 | * whether it is even or odd. |
| 619 | * if the number of input characters are even, then we need N/2 byte. |
| 620 | * if the number of input characters are odd, then we need do (N+1)/2 |
| 621 | * to compensate rounding off. |
| 622 | * For example, if N = 18, then (18 + 1)/2 = 9 bytes are enough. |
| 623 | * If N = 19, then we need 10 bytes, hence (19 + 1)/2 = 10 bytes |
| 624 | */ |
Jeff Johnson | 5f3a612 | 2019-02-26 17:20:59 -0800 | [diff] [blame] | 625 | *buf = qdf_mem_malloc((*buf_len + 1) / 2); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 626 | if (!*buf) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 627 | hdd_err("qdf_mem_malloc failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 628 | return -ENOMEM; |
| 629 | } |
| 630 | |
| 631 | /* the buffer received from the upper layer is character buffer, |
| 632 | * we need to prepare the buffer taking 2 characters in to a U8 hex |
| 633 | * decimal number for example 7f0000f0...form a buffer to contain 7f |
| 634 | * in 0th location, 00 in 1st and f0 in 3rd location |
| 635 | */ |
Jeff Johnson | 103f67a | 2019-02-26 17:11:01 -0800 | [diff] [blame] | 636 | for (i = 0, j = 0; j < *buf_len; j += 2) { |
| 637 | if (j + 1 == *buf_len) { |
Jeff Johnson | 72f498b | 2019-02-26 18:37:25 -0800 | [diff] [blame] | 638 | temp_u8 = hex_to_bin(in_ptr[j]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 639 | } else { |
Jeff Johnson | 72f498b | 2019-02-26 18:37:25 -0800 | [diff] [blame] | 640 | temp_u8 = |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 641 | (hex_to_bin(in_ptr[j]) << 4) | |
| 642 | (hex_to_bin(in_ptr[j + 1])); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 643 | } |
Jeff Johnson | 72f498b | 2019-02-26 18:37:25 -0800 | [diff] [blame] | 644 | (*buf)[i++] = temp_u8; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 645 | } |
Jeff Johnson | 103f67a | 2019-02-26 17:11:01 -0800 | [diff] [blame] | 646 | *buf_len = i; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 647 | return 0; |
| 648 | } |
| 649 | |
| 650 | /** |
| 651 | * hdd_parse_reassoc_command_data() - HDD Parse reassoc command data |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 652 | * @command: Pointer to input data (its a NULL terminated string) |
Jeff Johnson | b7d5279 | 2019-02-26 12:42:08 -0800 | [diff] [blame] | 653 | * @bssid: Pointer to target Ap bssid |
Jeff Johnson | d727cdc | 2019-02-26 12:47:05 -0800 | [diff] [blame] | 654 | * @channel: Pointer to the Target AP channel |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 655 | * |
| 656 | * This function parses the reasoc command data passed in the format |
| 657 | * REASSOC<space><bssid><space><channel> |
| 658 | * |
| 659 | * Return: 0 for success non-zero for failure |
| 660 | */ |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 661 | static int hdd_parse_reassoc_command_v1_data(const uint8_t *command, |
Jeff Johnson | b7d5279 | 2019-02-26 12:42:08 -0800 | [diff] [blame] | 662 | uint8_t *bssid, |
Jeff Johnson | d727cdc | 2019-02-26 12:47:05 -0800 | [diff] [blame] | 663 | uint8_t *channel) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 664 | { |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 665 | const uint8_t *in_ptr = command; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 666 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 667 | if (_hdd_parse_bssid_and_chan(&in_ptr, bssid, channel)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 668 | return -EINVAL; |
| 669 | |
| 670 | return 0; |
| 671 | } |
| 672 | |
Naveen Rawat | 05376ee | 2016-07-18 16:43:32 -0700 | [diff] [blame] | 673 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
Abhinav Kumar | eab2593 | 2018-07-13 11:48:43 +0530 | [diff] [blame] | 674 | QDF_STATUS hdd_wma_send_fastreassoc_cmd(struct hdd_adapter *adapter, |
| 675 | const tSirMacAddr bssid, |
| 676 | int channel) |
Naveen Rawat | 05376ee | 2016-07-18 16:43:32 -0700 | [diff] [blame] | 677 | { |
Krunal Soni | 332f4af | 2017-06-01 14:36:17 -0700 | [diff] [blame] | 678 | struct hdd_station_ctx *hdd_sta_ctx = |
| 679 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | 8313b9d | 2018-03-14 15:09:28 -0700 | [diff] [blame] | 680 | struct csr_roam_profile *roam_profile; |
Krunal Soni | 332f4af | 2017-06-01 14:36:17 -0700 | [diff] [blame] | 681 | tSirMacAddr connected_bssid; |
Naveen Rawat | 05376ee | 2016-07-18 16:43:32 -0700 | [diff] [blame] | 682 | |
Jeff Johnson | 8313b9d | 2018-03-14 15:09:28 -0700 | [diff] [blame] | 683 | roam_profile = hdd_roam_profile(adapter); |
Jeff Johnson | e04b699 | 2019-02-27 14:06:55 -0800 | [diff] [blame] | 684 | qdf_mem_copy(connected_bssid, hdd_sta_ctx->conn_info.bssid.bytes, |
Krunal Soni | 332f4af | 2017-06-01 14:36:17 -0700 | [diff] [blame] | 685 | ETH_ALEN); |
Abhinav Kumar | eab2593 | 2018-07-13 11:48:43 +0530 | [diff] [blame] | 686 | return sme_fast_reassoc(adapter->hdd_ctx->mac_handle, |
| 687 | roam_profile, bssid, channel, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 688 | adapter->vdev_id, connected_bssid); |
Naveen Rawat | 05376ee | 2016-07-18 16:43:32 -0700 | [diff] [blame] | 689 | } |
Naveen Rawat | 05376ee | 2016-07-18 16:43:32 -0700 | [diff] [blame] | 690 | #endif |
| 691 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 692 | /** |
| 693 | * hdd_reassoc() - perform a userspace-directed reassoc |
Deepak Dhamdhere | 5a36a4a | 2016-11-12 15:08:22 -0800 | [diff] [blame] | 694 | * @adapter: Adapter upon which the command was received |
| 695 | * @bssid: BSSID with which to reassociate |
| 696 | * @channel: channel upon which to reassociate |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 697 | * @src: The source for the trigger of this action |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 698 | * |
| 699 | * This function performs a userspace-directed reassoc operation |
| 700 | * |
| 701 | * Return: 0 for success non-zero for failure |
| 702 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 703 | int hdd_reassoc(struct hdd_adapter *adapter, const uint8_t *bssid, |
Deepak Dhamdhere | 5a36a4a | 2016-11-12 15:08:22 -0800 | [diff] [blame] | 704 | uint8_t channel, const handoff_src src) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 705 | { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 706 | struct hdd_station_ctx *sta_ctx; |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 707 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 708 | int ret = 0; |
Abhinav Kumar | eab2593 | 2018-07-13 11:48:43 +0530 | [diff] [blame] | 709 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 710 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 711 | if (!hdd_ctx) { |
Naveen Rawat | 05376ee | 2016-07-18 16:43:32 -0700 | [diff] [blame] | 712 | hdd_err("Invalid hdd ctx"); |
| 713 | return -EINVAL; |
| 714 | } |
| 715 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 716 | if (QDF_STA_MODE != adapter->device_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 717 | hdd_warn("Unsupported in mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 718 | qdf_opmode_str(adapter->device_mode), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 719 | adapter->device_mode); |
| 720 | return -EINVAL; |
| 721 | } |
| 722 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 723 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 724 | |
Vignesh Viswanathan | 7c43a7a | 2018-09-24 15:52:47 +0530 | [diff] [blame] | 725 | /* |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 726 | * pHddStaCtx->conn_info.conn_state is set to disconnected only |
Vignesh Viswanathan | 7c43a7a | 2018-09-24 15:52:47 +0530 | [diff] [blame] | 727 | * after the disconnect done indication from SME. If the SME is |
| 728 | * in the process of disconnecting, the SME Connection state is |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 729 | * set to disconnected and the pHddStaCtx->conn_info.conn_state |
Vignesh Viswanathan | 7c43a7a | 2018-09-24 15:52:47 +0530 | [diff] [blame] | 730 | * will still be associated till the disconnect is done. |
| 731 | * So check both the HDD state and SME state here. |
| 732 | * If not associated, no need to proceed with reassoc |
| 733 | */ |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 734 | if ((eConnectionState_Associated != sta_ctx->conn_info.conn_state) || |
Vignesh Viswanathan | 7c43a7a | 2018-09-24 15:52:47 +0530 | [diff] [blame] | 735 | (!sme_is_conn_state_connected(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 736 | adapter->vdev_id))) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 737 | hdd_warn("Not associated"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 738 | ret = -EINVAL; |
| 739 | goto exit; |
| 740 | } |
| 741 | |
| 742 | /* |
| 743 | * if the target bssid is same as currently associated AP, |
Deepak Dhamdhere | 5a36a4a | 2016-11-12 15:08:22 -0800 | [diff] [blame] | 744 | * use the current connections's channel. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 745 | */ |
Jeff Johnson | e04b699 | 2019-02-27 14:06:55 -0800 | [diff] [blame] | 746 | if (!memcmp(bssid, sta_ctx->conn_info.bssid.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 747 | QDF_MAC_ADDR_SIZE)) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 748 | hdd_warn("Reassoc BSSID is same as currently associated AP bssid"); |
Jingxiang Ge | ce7c547 | 2019-07-23 16:19:23 +0800 | [diff] [blame] | 749 | channel = wlan_reg_freq_to_chan(hdd_ctx->pdev, |
Jingxiang Ge | ae80dc6 | 2019-08-13 17:32:22 +0800 | [diff] [blame^] | 750 | sta_ctx->conn_info.chan_freq); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 751 | } |
| 752 | |
| 753 | /* Check channel number is a valid channel number */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 754 | if (QDF_STATUS_SUCCESS != |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 755 | wlan_hdd_validate_operation_channel(adapter, channel)) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 756 | hdd_err("Invalid Channel: %d", channel); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 757 | ret = -EINVAL; |
| 758 | goto exit; |
| 759 | } |
| 760 | |
| 761 | /* Proceed with reassoc */ |
Naveen Rawat | 05376ee | 2016-07-18 16:43:32 -0700 | [diff] [blame] | 762 | if (roaming_offload_enabled(hdd_ctx)) { |
Abhinav Kumar | eab2593 | 2018-07-13 11:48:43 +0530 | [diff] [blame] | 763 | status = hdd_wma_send_fastreassoc_cmd(adapter, |
| 764 | bssid, (int)channel); |
| 765 | if (status != QDF_STATUS_SUCCESS) { |
| 766 | hdd_err("Failed to send fast reassoc cmd"); |
| 767 | ret = -EINVAL; |
| 768 | } |
Naveen Rawat | 05376ee | 2016-07-18 16:43:32 -0700 | [diff] [blame] | 769 | } else { |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 770 | tCsrHandoffRequest handoff; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 771 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 772 | handoff.channel = channel; |
| 773 | handoff.src = src; |
| 774 | qdf_mem_copy(handoff.bssid.bytes, bssid, QDF_MAC_ADDR_SIZE); |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 775 | sme_handoff_request(hdd_ctx->mac_handle, adapter->vdev_id, |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 776 | &handoff); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 777 | } |
| 778 | exit: |
| 779 | return ret; |
| 780 | } |
| 781 | |
| 782 | /** |
| 783 | * hdd_parse_reassoc_v1() - parse version 1 of the REASSOC command |
| 784 | * @adapter: Adapter upon which the command was received |
| 785 | * @command: ASCII text command that was received |
| 786 | * |
| 787 | * This function parses the v1 REASSOC command with the format |
| 788 | * |
| 789 | * REASSOC xx:xx:xx:xx:xx:xx CH |
| 790 | * |
| 791 | * Where "xx:xx:xx:xx:xx:xx" is the Hex-ASCII representation of the |
| 792 | * BSSID and CH is the ASCII representation of the channel. For |
| 793 | * example |
| 794 | * |
| 795 | * REASSOC 00:0a:0b:11:22:33 48 |
| 796 | * |
| 797 | * Return: 0 for success non-zero for failure |
| 798 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 799 | static int hdd_parse_reassoc_v1(struct hdd_adapter *adapter, const char *command) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 800 | { |
| 801 | uint8_t channel = 0; |
| 802 | tSirMacAddr bssid; |
| 803 | int ret; |
| 804 | |
| 805 | ret = hdd_parse_reassoc_command_v1_data(command, bssid, &channel); |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 806 | if (ret) |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 807 | hdd_err("Failed to parse reassoc command data"); |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 808 | else |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 809 | ret = hdd_reassoc(adapter, bssid, channel, REASSOC); |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 810 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 811 | return ret; |
| 812 | } |
| 813 | |
| 814 | /** |
| 815 | * hdd_parse_reassoc_v2() - parse version 2 of the REASSOC command |
| 816 | * @adapter: Adapter upon which the command was received |
| 817 | * @command: Command that was received, ASCII command |
Jeff Johnson | 560dc56 | 2017-03-17 15:19:31 -0700 | [diff] [blame] | 818 | * followed by binary data |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 819 | * @total_len: Total length of the command received |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 820 | * |
| 821 | * This function parses the v2 REASSOC command with the format |
| 822 | * |
| 823 | * REASSOC <android_wifi_reassoc_params> |
| 824 | * |
| 825 | * Return: 0 for success non-zero for failure |
| 826 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 827 | static int hdd_parse_reassoc_v2(struct hdd_adapter *adapter, |
| 828 | const char *command, |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 829 | int total_len) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 830 | { |
| 831 | struct android_wifi_reassoc_params params; |
| 832 | tSirMacAddr bssid; |
| 833 | int ret; |
| 834 | |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 835 | if (total_len < sizeof(params) + 8) { |
| 836 | hdd_err("Invalid command length"); |
| 837 | return -EINVAL; |
| 838 | } |
| 839 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 840 | /* The params are located after "REASSOC " */ |
| 841 | memcpy(¶ms, command + 8, sizeof(params)); |
| 842 | |
| 843 | if (!mac_pton(params.bssid, (u8 *) &bssid)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 844 | hdd_err("MAC address parsing failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 845 | ret = -EINVAL; |
| 846 | } else { |
Varun Reddy Yeturu | 3e91dad | 2016-07-18 15:58:47 -0700 | [diff] [blame] | 847 | ret = hdd_reassoc(adapter, bssid, params.channel, REASSOC); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 848 | } |
| 849 | return ret; |
| 850 | } |
| 851 | |
| 852 | /** |
| 853 | * hdd_parse_reassoc() - parse the REASSOC command |
| 854 | * @adapter: Adapter upon which the command was received |
| 855 | * @command: Command that was received |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 856 | * @total_len: Total length of the command received |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 857 | * |
| 858 | * There are two different versions of the REASSOC command. Version 1 |
| 859 | * of the command contains a parameter list that is ASCII characters |
| 860 | * whereas version 2 contains a combination of ASCII and binary |
| 861 | * payload. Determine if a version 1 or a version 2 command is being |
| 862 | * parsed by examining the parameters, and then dispatch the parser |
| 863 | * that is appropriate for the command. |
| 864 | * |
| 865 | * Return: 0 for success non-zero for failure |
| 866 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 867 | static int hdd_parse_reassoc(struct hdd_adapter *adapter, const char *command, |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 868 | int total_len) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 869 | { |
| 870 | int ret; |
| 871 | |
| 872 | /* both versions start with "REASSOC " |
| 873 | * v1 has a bssid and channel # as an ASCII string |
| 874 | * REASSOC xx:xx:xx:xx:xx:xx CH |
| 875 | * v2 has a C struct |
| 876 | * REASSOC <binary c struct> |
| 877 | * |
| 878 | * The first field in the v2 struct is also the bssid in ASCII. |
| 879 | * But in the case of a v2 message the BSSID is NUL-terminated. |
| 880 | * Hence we can peek at that offset to see if this is V1 or V2 |
| 881 | * REASSOC xx:xx:xx:xx:xx:xx* |
| 882 | * 1111111111222222 |
| 883 | * 01234567890123456789012345 |
| 884 | */ |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 885 | |
| 886 | if (total_len < 26) { |
| 887 | hdd_err("Invalid command, total_len = %d", total_len); |
| 888 | return -EINVAL; |
| 889 | } |
| 890 | |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 891 | if (command[25]) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 892 | ret = hdd_parse_reassoc_v1(adapter, command); |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 893 | else |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 894 | ret = hdd_parse_reassoc_v2(adapter, command, total_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 895 | |
| 896 | return ret; |
| 897 | } |
| 898 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 899 | /** |
| 900 | * hdd_sendactionframe() - send a userspace-supplied action frame |
| 901 | * @adapter: Adapter upon which the command was received |
| 902 | * @bssid: BSSID target of the action frame |
| 903 | * @channel: Channel upon which to send the frame |
| 904 | * @dwell_time: Amount of time to dwell when the frame is sent |
| 905 | * @payload_len:Length of the payload |
| 906 | * @payload: Payload of the frame |
| 907 | * |
| 908 | * This function sends a userspace-supplied action frame |
| 909 | * |
| 910 | * Return: 0 for success non-zero for failure |
| 911 | */ |
| 912 | static int |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 913 | hdd_sendactionframe(struct hdd_adapter *adapter, const uint8_t *bssid, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 914 | const uint8_t channel, const uint8_t dwell_time, |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 915 | const int payload_len, const uint8_t *payload) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 916 | { |
| 917 | struct ieee80211_channel chan; |
Jingxiang Ge | ce7c547 | 2019-07-23 16:19:23 +0800 | [diff] [blame] | 918 | uint8_t conn_info_channel; |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 919 | int frame_len, ret = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 920 | uint8_t *frame; |
| 921 | struct ieee80211_hdr_3addr *hdr; |
| 922 | u64 cookie; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 923 | struct hdd_station_ctx *sta_ctx; |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 924 | struct hdd_context *hdd_ctx; |
Jeff Johnson | ecdf83b | 2019-02-26 18:33:56 -0800 | [diff] [blame] | 925 | tpSirMacVendorSpecificFrameHdr vendor = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 926 | (tpSirMacVendorSpecificFrameHdr) payload; |
| 927 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) |
| 928 | struct cfg80211_mgmt_tx_params params; |
| 929 | #endif |
| 930 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 931 | if (QDF_STA_MODE != adapter->device_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 932 | hdd_warn("Unsupported in mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 933 | qdf_opmode_str(adapter->device_mode), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 934 | adapter->device_mode); |
| 935 | return -EINVAL; |
| 936 | } |
| 937 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 938 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 939 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 940 | |
| 941 | /* if not associated, no need to send action frame */ |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 942 | if (eConnectionState_Associated != sta_ctx->conn_info.conn_state) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 943 | hdd_warn("Not associated"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 944 | ret = -EINVAL; |
| 945 | goto exit; |
| 946 | } |
| 947 | |
| 948 | /* |
| 949 | * if the target bssid is different from currently associated AP, |
| 950 | * then no need to send action frame |
| 951 | */ |
Jeff Johnson | e04b699 | 2019-02-27 14:06:55 -0800 | [diff] [blame] | 952 | if (memcmp(bssid, sta_ctx->conn_info.bssid.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 953 | QDF_MAC_ADDR_SIZE)) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 954 | hdd_warn("STA is not associated to this AP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 955 | ret = -EINVAL; |
| 956 | goto exit; |
| 957 | } |
| 958 | |
| 959 | chan.center_freq = sme_chn_to_freq(channel); |
| 960 | /* Check if it is specific action frame */ |
Jeff Johnson | ecdf83b | 2019-02-26 18:33:56 -0800 | [diff] [blame] | 961 | if (vendor->category == |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 962 | SIR_MAC_ACTION_VENDOR_SPECIFIC_CATEGORY) { |
Jeff Johnson | 2971e3a | 2019-02-26 18:31:54 -0800 | [diff] [blame] | 963 | static const uint8_t oui[] = { 0x00, 0x00, 0xf0 }; |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 964 | |
Jeff Johnson | ecdf83b | 2019-02-26 18:33:56 -0800 | [diff] [blame] | 965 | if (!qdf_mem_cmp(vendor->Oui, oui, 3)) { |
Jingxiang Ge | ce7c547 | 2019-07-23 16:19:23 +0800 | [diff] [blame] | 966 | conn_info_channel = wlan_reg_freq_to_chan( |
| 967 | hdd_ctx->pdev, |
Jingxiang Ge | ae80dc6 | 2019-08-13 17:32:22 +0800 | [diff] [blame^] | 968 | sta_ctx->conn_info.chan_freq); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 969 | /* |
| 970 | * if the channel number is different from operating |
| 971 | * channel then no need to send action frame |
| 972 | */ |
| 973 | if (channel != 0) { |
Jingxiang Ge | ce7c547 | 2019-07-23 16:19:23 +0800 | [diff] [blame] | 974 | if (channel != conn_info_channel) { |
| 975 | hdd_warn("channel(%u) is different from operating channel(%u)", |
| 976 | channel, |
| 977 | conn_info_channel); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 978 | ret = -EINVAL; |
| 979 | goto exit; |
| 980 | } |
| 981 | /* |
| 982 | * If channel number is specified and same |
| 983 | * as home channel, ensure that action frame |
| 984 | * is sent immediately by cancelling |
| 985 | * roaming scans. Otherwise large dwell times |
| 986 | * may cause long delays in sending action |
| 987 | * frames. |
| 988 | */ |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 989 | sme_abort_roam_scan(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 990 | adapter->vdev_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 991 | } else { |
| 992 | /* |
| 993 | * 0 is accepted as current home channel, |
| 994 | * delayed transmission of action frame is ok. |
| 995 | */ |
Jingxiang Ge | ae80dc6 | 2019-08-13 17:32:22 +0800 | [diff] [blame^] | 996 | chan.center_freq = sta_ctx->conn_info.chan_freq; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 997 | } |
| 998 | } |
| 999 | } |
| 1000 | if (chan.center_freq == 0) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 1001 | hdd_err("Invalid channel number: %d", channel); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1002 | ret = -EINVAL; |
| 1003 | goto exit; |
| 1004 | } |
| 1005 | |
| 1006 | frame_len = payload_len + 24; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1007 | frame = qdf_mem_malloc(frame_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1008 | if (!frame) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1009 | hdd_err("memory allocation failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1010 | ret = -ENOMEM; |
| 1011 | goto exit; |
| 1012 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1013 | |
| 1014 | hdr = (struct ieee80211_hdr_3addr *)frame; |
| 1015 | hdr->frame_control = |
| 1016 | cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ACTION); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1017 | qdf_mem_copy(hdr->addr1, bssid, QDF_MAC_ADDR_SIZE); |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 1018 | qdf_mem_copy(hdr->addr2, adapter->mac_addr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1019 | QDF_MAC_ADDR_SIZE); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1020 | qdf_mem_copy(hdr->addr3, bssid, QDF_MAC_ADDR_SIZE); |
| 1021 | qdf_mem_copy(hdr + 1, payload, payload_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1022 | |
| 1023 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) |
| 1024 | params.chan = &chan; |
| 1025 | params.offchan = 0; |
| 1026 | params.wait = dwell_time; |
| 1027 | params.buf = frame; |
| 1028 | params.len = frame_len; |
| 1029 | params.no_cck = 1; |
| 1030 | params.dont_wait_for_ack = 1; |
| 1031 | ret = wlan_hdd_mgmt_tx(NULL, &adapter->wdev, ¶ms, &cookie); |
| 1032 | #else |
| 1033 | ret = wlan_hdd_mgmt_tx(NULL, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1034 | &(adapter->wdev), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1035 | &chan, 0, |
Amar Singhal | 01098f7 | 2015-10-08 11:55:32 -0700 | [diff] [blame] | 1036 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1037 | dwell_time, frame, frame_len, 1, 1, &cookie); |
| 1038 | #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0) */ |
| 1039 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1040 | qdf_mem_free(frame); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1041 | exit: |
| 1042 | return ret; |
| 1043 | } |
| 1044 | |
| 1045 | /** |
| 1046 | * hdd_parse_sendactionframe_v1() - parse version 1 of the |
| 1047 | * SENDACTIONFRAME command |
| 1048 | * @adapter: Adapter upon which the command was received |
| 1049 | * @command: ASCII text command that was received |
| 1050 | * |
| 1051 | * This function parses the v1 SENDACTIONFRAME command with the format |
| 1052 | * |
| 1053 | * SENDACTIONFRAME xx:xx:xx:xx:xx:xx CH DW xxxxxx |
| 1054 | * |
| 1055 | * Where "xx:xx:xx:xx:xx:xx" is the Hex-ASCII representation of the |
| 1056 | * BSSID, CH is the ASCII representation of the channel, DW is the |
| 1057 | * ASCII representation of the dwell time, and xxxxxx is the Hex-ASCII |
| 1058 | * payload. For example |
| 1059 | * |
| 1060 | * SENDACTIONFRAME 00:0a:0b:11:22:33 48 40 aabbccddee |
| 1061 | * |
| 1062 | * Return: 0 for success non-zero for failure |
| 1063 | */ |
| 1064 | static int |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 1065 | hdd_parse_sendactionframe_v1(struct hdd_adapter *adapter, const char *command) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1066 | { |
| 1067 | uint8_t channel = 0; |
| 1068 | uint8_t dwell_time = 0; |
| 1069 | uint8_t payload_len = 0; |
| 1070 | uint8_t *payload = NULL; |
| 1071 | tSirMacAddr bssid; |
| 1072 | int ret; |
| 1073 | |
| 1074 | ret = hdd_parse_send_action_frame_v1_data(command, bssid, &channel, |
| 1075 | &dwell_time, &payload, |
| 1076 | &payload_len); |
| 1077 | if (ret) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1078 | hdd_err("Failed to parse send action frame data"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1079 | } else { |
| 1080 | ret = hdd_sendactionframe(adapter, bssid, channel, |
| 1081 | dwell_time, payload_len, payload); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1082 | qdf_mem_free(payload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1083 | } |
| 1084 | |
| 1085 | return ret; |
| 1086 | } |
| 1087 | |
| 1088 | /** |
| 1089 | * hdd_parse_sendactionframe_v2() - parse version 2 of the |
| 1090 | * SENDACTIONFRAME command |
| 1091 | * @adapter: Adapter upon which the command was received |
| 1092 | * @command: Command that was received, ASCII command |
Jeff Johnson | 560dc56 | 2017-03-17 15:19:31 -0700 | [diff] [blame] | 1093 | * followed by binary data |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1094 | * |
| 1095 | * This function parses the v2 SENDACTIONFRAME command with the format |
| 1096 | * |
| 1097 | * SENDACTIONFRAME <android_wifi_af_params> |
| 1098 | * |
| 1099 | * Return: 0 for success non-zero for failure |
| 1100 | */ |
| 1101 | static int |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 1102 | hdd_parse_sendactionframe_v2(struct hdd_adapter *adapter, |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 1103 | const char *command, int total_len) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1104 | { |
| 1105 | struct android_wifi_af_params *params; |
| 1106 | tSirMacAddr bssid; |
| 1107 | int ret; |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 1108 | int len_wo_payload = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1109 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1110 | /* The params are located after "SENDACTIONFRAME " */ |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 1111 | total_len -= 16; |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 1112 | len_wo_payload = sizeof(*params) - ANDROID_WIFI_ACTION_FRAME_SIZE; |
| 1113 | if (total_len <= len_wo_payload) { |
| 1114 | hdd_err("Invalid command len"); |
| 1115 | return -EINVAL; |
| 1116 | } |
| 1117 | |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 1118 | params = (struct android_wifi_af_params *)(command + 16); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1119 | |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 1120 | if (params->len <= 0 || params->len > ANDROID_WIFI_ACTION_FRAME_SIZE || |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 1121 | (params->len > (total_len - len_wo_payload))) { |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 1122 | hdd_err("Invalid payload length: %d", params->len); |
| 1123 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1124 | } |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 1125 | |
| 1126 | if (!mac_pton(params->bssid, (u8 *)&bssid)) { |
| 1127 | hdd_err("MAC address parsing failed"); |
| 1128 | return -EINVAL; |
| 1129 | } |
| 1130 | |
| 1131 | if (params->channel < 0 || |
| 1132 | params->channel > WNI_CFG_CURRENT_CHANNEL_STAMAX) { |
| 1133 | hdd_err("Invalid channel: %d", params->channel); |
| 1134 | return -EINVAL; |
| 1135 | } |
| 1136 | |
| 1137 | if (params->dwell_time < 0) { |
| 1138 | hdd_err("Invalid dwell_time: %d", params->dwell_time); |
| 1139 | return -EINVAL; |
| 1140 | } |
| 1141 | |
| 1142 | ret = hdd_sendactionframe(adapter, bssid, params->channel, |
| 1143 | params->dwell_time, params->len, params->data); |
| 1144 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1145 | return ret; |
| 1146 | } |
| 1147 | |
| 1148 | /** |
| 1149 | * hdd_parse_sendactionframe() - parse the SENDACTIONFRAME command |
| 1150 | * @adapter: Adapter upon which the command was received |
| 1151 | * @command: Command that was received |
| 1152 | * |
| 1153 | * There are two different versions of the SENDACTIONFRAME command. |
| 1154 | * Version 1 of the command contains a parameter list that is ASCII |
| 1155 | * characters whereas version 2 contains a combination of ASCII and |
| 1156 | * binary payload. Determine if a version 1 or a version 2 command is |
| 1157 | * being parsed by examining the parameters, and then dispatch the |
| 1158 | * parser that is appropriate for the version of the command. |
| 1159 | * |
| 1160 | * Return: 0 for success non-zero for failure |
| 1161 | */ |
| 1162 | static int |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 1163 | hdd_parse_sendactionframe(struct hdd_adapter *adapter, const char *command, |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 1164 | int total_len) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1165 | { |
| 1166 | int ret; |
| 1167 | |
| 1168 | /* |
| 1169 | * both versions start with "SENDACTIONFRAME " |
| 1170 | * v1 has a bssid and other parameters as an ASCII string |
| 1171 | * SENDACTIONFRAME xx:xx:xx:xx:xx:xx CH DWELL LEN FRAME |
| 1172 | * v2 has a C struct |
| 1173 | * SENDACTIONFRAME <binary c struct> |
| 1174 | * |
| 1175 | * The first field in the v2 struct is also the bssid in ASCII. |
| 1176 | * But in the case of a v2 message the BSSID is NUL-terminated. |
| 1177 | * Hence we can peek at that offset to see if this is V1 or V2 |
| 1178 | * SENDACTIONFRAME xx:xx:xx:xx:xx:xx* |
| 1179 | * 111111111122222222223333 |
| 1180 | * 0123456789012345678901234567890123 |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 1181 | * For both the commands, a valid command must have atleast |
| 1182 | * first 34 length of data. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1183 | */ |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 1184 | if (total_len < 34) { |
| 1185 | hdd_err("Invalid command (total_len=%d)", total_len); |
| 1186 | return -EINVAL; |
| 1187 | } |
| 1188 | |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 1189 | if (command[33]) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1190 | ret = hdd_parse_sendactionframe_v1(adapter, command); |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 1191 | else |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 1192 | ret = hdd_parse_sendactionframe_v2(adapter, command, total_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1193 | |
| 1194 | return ret; |
| 1195 | } |
| 1196 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1197 | /** |
| 1198 | * hdd_parse_channellist() - HDD Parse channel list |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 1199 | * @command: Pointer to input channel list |
Jeff Johnson | 091cbb7 | 2019-02-26 12:49:38 -0800 | [diff] [blame] | 1200 | * @channel_list: Pointer to local output array to record |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 1201 | * channel list |
Jeff Johnson | c3eac6c | 2019-02-26 18:09:53 -0800 | [diff] [blame] | 1202 | * @num_channels: Pointer to number of roam scan channels |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1203 | * |
| 1204 | * This function parses the channel list passed in the format |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 1205 | * SETROAMSCANCHANNELS<space><Number of channels><space>Channel 1<space> |
| 1206 | * Channel 2<space>Channel N |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1207 | * if the Number of channels (N) does not match with the actual number |
| 1208 | * of channels passed then take the minimum of N and count of |
| 1209 | * (Ch1, Ch2, ...Ch M). For example, if SETROAMSCANCHANNELS 3 36 40 44 48, |
| 1210 | * only 36, 40 and 44 shall be taken. If SETROAMSCANCHANNELS 5 36 40 44 48, |
| 1211 | * ignore 5 and take 36, 40, 44 and 48. This function does not take care of |
| 1212 | * removing duplicate channels from the list |
| 1213 | * |
| 1214 | * Return: 0 for success non-zero for failure |
| 1215 | */ |
| 1216 | static int |
Jeff Johnson | 091cbb7 | 2019-02-26 12:49:38 -0800 | [diff] [blame] | 1217 | hdd_parse_channellist(const uint8_t *command, uint8_t *channel_list, |
Jeff Johnson | c3eac6c | 2019-02-26 18:09:53 -0800 | [diff] [blame] | 1218 | uint8_t *num_channels) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1219 | { |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1220 | const uint8_t *in_ptr = command; |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 1221 | int temp_int; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1222 | int j = 0; |
| 1223 | int v = 0; |
| 1224 | char buf[32]; |
| 1225 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1226 | in_ptr = strnchr(command, strlen(command), SPACE_ASCII_VALUE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1227 | /* no argument after the command */ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 1228 | if (!in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1229 | return -EINVAL; |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1230 | else if (SPACE_ASCII_VALUE != *in_ptr) /* no space after the command */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1231 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1232 | |
| 1233 | /* remove empty spaces */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1234 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 1235 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1236 | |
| 1237 | /* no argument followed by spaces */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1238 | if ('\0' == *in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1239 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1240 | |
| 1241 | /* get the first argument ie the number of channels */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1242 | v = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1243 | if (1 != v) |
| 1244 | return -EINVAL; |
| 1245 | |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 1246 | v = kstrtos32(buf, 10, &temp_int); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1247 | if ((v < 0) || |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 1248 | (temp_int <= 0) || (temp_int > CFG_VALID_CHANNEL_LIST_LEN)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1249 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1250 | |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 1251 | *num_channels = temp_int; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1252 | |
Jeff Johnson | c3eac6c | 2019-02-26 18:09:53 -0800 | [diff] [blame] | 1253 | hdd_debug("Number of channels are: %d", *num_channels); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1254 | |
Jeff Johnson | c3eac6c | 2019-02-26 18:09:53 -0800 | [diff] [blame] | 1255 | for (j = 0; j < (*num_channels); j++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1256 | /* |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1257 | * in_ptr pointing to the beginning of first space after number |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1258 | * of channels |
| 1259 | */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1260 | in_ptr = strpbrk(in_ptr, " "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1261 | /* no channel list after the number of channels argument */ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 1262 | if (!in_ptr) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1263 | if (0 != j) { |
Jeff Johnson | c3eac6c | 2019-02-26 18:09:53 -0800 | [diff] [blame] | 1264 | *num_channels = j; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1265 | return 0; |
| 1266 | } else { |
| 1267 | return -EINVAL; |
| 1268 | } |
| 1269 | } |
| 1270 | |
| 1271 | /* remove empty space */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1272 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 1273 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1274 | |
| 1275 | /* |
| 1276 | * no channel list after the number of channels |
| 1277 | * argument and spaces |
| 1278 | */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1279 | if ('\0' == *in_ptr) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1280 | if (0 != j) { |
Jeff Johnson | c3eac6c | 2019-02-26 18:09:53 -0800 | [diff] [blame] | 1281 | *num_channels = j; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1282 | return 0; |
| 1283 | } else { |
| 1284 | return -EINVAL; |
| 1285 | } |
| 1286 | } |
| 1287 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1288 | v = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1289 | if (1 != v) |
| 1290 | return -EINVAL; |
| 1291 | |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 1292 | v = kstrtos32(buf, 10, &temp_int); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1293 | if ((v < 0) || |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 1294 | (temp_int <= 0) || |
| 1295 | (temp_int > WNI_CFG_CURRENT_CHANNEL_STAMAX)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1296 | return -EINVAL; |
| 1297 | } |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 1298 | channel_list[j] = temp_int; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1299 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 1300 | hdd_debug("Channel %d added to preferred channel list", |
Jeff Johnson | 091cbb7 | 2019-02-26 12:49:38 -0800 | [diff] [blame] | 1301 | channel_list[j]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1302 | } |
| 1303 | |
| 1304 | return 0; |
| 1305 | } |
| 1306 | |
| 1307 | /** |
| 1308 | * hdd_parse_set_roam_scan_channels_v1() - parse version 1 of the |
| 1309 | * SETROAMSCANCHANNELS command |
| 1310 | * @adapter: Adapter upon which the command was received |
| 1311 | * @command: ASCII text command that was received |
| 1312 | * |
| 1313 | * This function parses the v1 SETROAMSCANCHANNELS command with the format |
| 1314 | * |
| 1315 | * SETROAMSCANCHANNELS N C1 C2 ... Cn |
| 1316 | * |
| 1317 | * Where "N" is the ASCII representation of the number of channels and |
| 1318 | * C1 thru Cn is the ASCII representation of the channels. For example |
| 1319 | * |
| 1320 | * SETROAMSCANCHANNELS 4 36 40 44 48 |
| 1321 | * |
| 1322 | * Return: 0 for success non-zero for failure |
| 1323 | */ |
| 1324 | static int |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 1325 | hdd_parse_set_roam_scan_channels_v1(struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1326 | const char *command) |
| 1327 | { |
Wu Gao | 0821b0d | 2019-01-11 17:31:11 +0800 | [diff] [blame] | 1328 | uint8_t channel_list[CFG_VALID_CHANNEL_LIST_LEN] = { 0 }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1329 | uint8_t num_chan = 0; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1330 | QDF_STATUS status; |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 1331 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1332 | int ret; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1333 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1334 | |
| 1335 | ret = hdd_parse_channellist(command, channel_list, &num_chan); |
| 1336 | if (ret) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1337 | hdd_err("Failed to parse channel list information"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1338 | goto exit; |
| 1339 | } |
| 1340 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 1341 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 1342 | TRACE_CODE_HDD_SETROAMSCANCHANNELS_IOCTL, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 1343 | adapter->vdev_id, num_chan); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1344 | |
Wu Gao | 0821b0d | 2019-01-11 17:31:11 +0800 | [diff] [blame] | 1345 | if (num_chan > CFG_VALID_CHANNEL_LIST_LEN) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1346 | hdd_err("number of channels (%d) supported exceeded max (%d)", |
Wu Gao | 0821b0d | 2019-01-11 17:31:11 +0800 | [diff] [blame] | 1347 | num_chan, CFG_VALID_CHANNEL_LIST_LEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1348 | ret = -EINVAL; |
| 1349 | goto exit; |
| 1350 | } |
| 1351 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1352 | mac_handle = hdd_ctx->mac_handle; |
| 1353 | if (!sme_validate_channel_list(mac_handle, channel_list, num_chan)) { |
Vignesh Viswanathan | a2f5ce58 | 2018-05-09 20:38:39 +0530 | [diff] [blame] | 1354 | hdd_err("List contains invalid channel(s)"); |
| 1355 | ret = -EINVAL; |
| 1356 | goto exit; |
| 1357 | } |
| 1358 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1359 | status = sme_change_roam_scan_channel_list(mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 1360 | adapter->vdev_id, |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1361 | channel_list, num_chan); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1362 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1363 | hdd_err("Failed to update channel list information"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1364 | ret = -EINVAL; |
| 1365 | goto exit; |
| 1366 | } |
| 1367 | exit: |
| 1368 | return ret; |
| 1369 | } |
| 1370 | |
| 1371 | /** |
| 1372 | * hdd_parse_set_roam_scan_channels_v2() - parse version 2 of the |
| 1373 | * SETROAMSCANCHANNELS command |
| 1374 | * @adapter: Adapter upon which the command was received |
| 1375 | * @command: Command that was received, ASCII command |
Jeff Johnson | 560dc56 | 2017-03-17 15:19:31 -0700 | [diff] [blame] | 1376 | * followed by binary data |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1377 | * |
| 1378 | * This function parses the v2 SETROAMSCANCHANNELS command with the format |
| 1379 | * |
| 1380 | * SETROAMSCANCHANNELS [N][C1][C2][Cn] |
| 1381 | * |
| 1382 | * The command begins with SETROAMSCANCHANNELS followed by a space, but |
| 1383 | * what follows the space is an array of u08 parameters. For example |
| 1384 | * |
| 1385 | * SETROAMSCANCHANNELS [0x04 0x24 0x28 0x2c 0x30] |
| 1386 | * |
| 1387 | * Return: 0 for success non-zero for failure |
| 1388 | */ |
| 1389 | static int |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 1390 | hdd_parse_set_roam_scan_channels_v2(struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1391 | const char *command) |
| 1392 | { |
| 1393 | const uint8_t *value; |
Wu Gao | 0821b0d | 2019-01-11 17:31:11 +0800 | [diff] [blame] | 1394 | uint8_t channel_list[CFG_VALID_CHANNEL_LIST_LEN] = { 0 }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1395 | uint8_t channel; |
| 1396 | uint8_t num_chan; |
| 1397 | int i; |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 1398 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1399 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1400 | int ret = 0; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1401 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1402 | |
| 1403 | /* array of values begins after "SETROAMSCANCHANNELS " */ |
| 1404 | value = command + 20; |
| 1405 | |
| 1406 | num_chan = *value++; |
Wu Gao | 0821b0d | 2019-01-11 17:31:11 +0800 | [diff] [blame] | 1407 | if (num_chan > CFG_VALID_CHANNEL_LIST_LEN) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1408 | hdd_err("number of channels (%d) supported exceeded max (%d)", |
Wu Gao | 0821b0d | 2019-01-11 17:31:11 +0800 | [diff] [blame] | 1409 | num_chan, CFG_VALID_CHANNEL_LIST_LEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1410 | ret = -EINVAL; |
| 1411 | goto exit; |
| 1412 | } |
| 1413 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 1414 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 1415 | TRACE_CODE_HDD_SETROAMSCANCHANNELS_IOCTL, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 1416 | adapter->vdev_id, num_chan); |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 1417 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1418 | |
| 1419 | for (i = 0; i < num_chan; i++) { |
| 1420 | channel = *value++; |
Nachiket Kukade | caa2e84 | 2018-05-09 17:56:12 +0530 | [diff] [blame] | 1421 | if (!channel) { |
| 1422 | hdd_err("Channels end at index %d, expected %d", |
| 1423 | i, num_chan); |
| 1424 | ret = -EINVAL; |
| 1425 | goto exit; |
| 1426 | } |
| 1427 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1428 | if (channel > WNI_CFG_CURRENT_CHANNEL_STAMAX) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1429 | hdd_err("index %d invalid channel %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1430 | i, channel); |
| 1431 | ret = -EINVAL; |
| 1432 | goto exit; |
| 1433 | } |
| 1434 | channel_list[i] = channel; |
| 1435 | } |
Vignesh Viswanathan | a2f5ce58 | 2018-05-09 20:38:39 +0530 | [diff] [blame] | 1436 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1437 | mac_handle = hdd_ctx->mac_handle; |
| 1438 | if (!sme_validate_channel_list(mac_handle, channel_list, num_chan)) { |
Vignesh Viswanathan | a2f5ce58 | 2018-05-09 20:38:39 +0530 | [diff] [blame] | 1439 | hdd_err("List contains invalid channel(s)"); |
| 1440 | ret = -EINVAL; |
| 1441 | goto exit; |
| 1442 | } |
| 1443 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1444 | status = sme_change_roam_scan_channel_list(mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 1445 | adapter->vdev_id, |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1446 | channel_list, num_chan); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1447 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1448 | hdd_err("Failed to update channel list information"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1449 | ret = -EINVAL; |
| 1450 | goto exit; |
| 1451 | } |
| 1452 | exit: |
| 1453 | return ret; |
| 1454 | } |
| 1455 | |
| 1456 | /** |
| 1457 | * hdd_parse_set_roam_scan_channels() - parse the |
| 1458 | * SETROAMSCANCHANNELS command |
| 1459 | * @adapter: Adapter upon which the command was received |
| 1460 | * @command: Command that was received |
| 1461 | * |
| 1462 | * There are two different versions of the SETROAMSCANCHANNELS command. |
| 1463 | * Version 1 of the command contains a parameter list that is ASCII |
| 1464 | * characters whereas version 2 contains a binary payload. Determine |
| 1465 | * if a version 1 or a version 2 command is being parsed by examining |
| 1466 | * the parameters, and then dispatch the parser that is appropriate for |
| 1467 | * the command. |
| 1468 | * |
| 1469 | * Return: 0 for success non-zero for failure |
| 1470 | */ |
| 1471 | static int |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 1472 | hdd_parse_set_roam_scan_channels(struct hdd_adapter *adapter, const char *command) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1473 | { |
| 1474 | const char *cursor; |
| 1475 | char ch; |
| 1476 | bool v1; |
| 1477 | int ret; |
| 1478 | |
| 1479 | /* start after "SETROAMSCANCHANNELS " */ |
| 1480 | cursor = command + 20; |
| 1481 | |
| 1482 | /* assume we have a version 1 command until proven otherwise */ |
| 1483 | v1 = true; |
| 1484 | |
| 1485 | /* v1 params will only contain ASCII digits and space */ |
| 1486 | while ((ch = *cursor++) && v1) { |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 1487 | if (!(isdigit(ch) || isspace(ch))) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1488 | v1 = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1489 | } |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 1490 | |
| 1491 | if (v1) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1492 | ret = hdd_parse_set_roam_scan_channels_v1(adapter, command); |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 1493 | else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1494 | ret = hdd_parse_set_roam_scan_channels_v2(adapter, command); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1495 | |
| 1496 | return ret; |
| 1497 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1498 | |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 1499 | #ifdef FEATURE_WLAN_ESE |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1500 | /** |
| 1501 | * hdd_parse_plm_cmd() - HDD Parse Plm command |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 1502 | * @command: Pointer to input data |
Jeff Johnson | a0b6c3c | 2019-02-26 11:04:52 -0800 | [diff] [blame] | 1503 | * @req: Pointer to output struct plm_req |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1504 | * |
| 1505 | * This function parses the plm command passed in the format |
| 1506 | * CCXPLMREQ<space><enable><space><dialog_token><space> |
| 1507 | * <meas_token><space><num_of_bursts><space><burst_int><space> |
| 1508 | * <measu duration><space><burst_len><space><desired_tx_pwr> |
| 1509 | * <space><multcast_addr><space><number_of_channels> |
| 1510 | * <space><channel_numbers> |
| 1511 | * |
| 1512 | * Return: 0 for success non-zero for failure |
| 1513 | */ |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 1514 | static QDF_STATUS hdd_parse_plm_cmd(uint8_t *command, |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 1515 | struct plm_req_params *req) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1516 | { |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 1517 | uint8_t *in_ptr = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1518 | int count, content = 0, ret = 0; |
| 1519 | char buf[32]; |
| 1520 | |
| 1521 | /* move to argument list */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 1522 | in_ptr = strnchr(command, strlen(command), SPACE_ASCII_VALUE); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 1523 | if (!in_ptr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1524 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1525 | |
| 1526 | /* no space after the command */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 1527 | if (SPACE_ASCII_VALUE != *in_ptr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1528 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1529 | |
| 1530 | /* remove empty spaces */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 1531 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 1532 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1533 | |
| 1534 | /* START/STOP PLM req */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 1535 | ret = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1536 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1537 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1538 | |
| 1539 | ret = kstrtos32(buf, 10, &content); |
| 1540 | if (ret < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1541 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1542 | |
Jeff Johnson | a0b6c3c | 2019-02-26 11:04:52 -0800 | [diff] [blame] | 1543 | req->enable = content; |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 1544 | in_ptr = strpbrk(in_ptr, " "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1545 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 1546 | if (!in_ptr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1547 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1548 | |
| 1549 | /* remove empty spaces */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 1550 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 1551 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1552 | |
| 1553 | /* Dialog token of radio meas req containing meas reqIE */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 1554 | ret = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1555 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1556 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1557 | |
| 1558 | ret = kstrtos32(buf, 10, &content); |
| 1559 | if (ret < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1560 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1561 | |
Jeff Johnson | a0b6c3c | 2019-02-26 11:04:52 -0800 | [diff] [blame] | 1562 | req->diag_token = content; |
| 1563 | hdd_debug("diag token %d", req->diag_token); |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 1564 | in_ptr = strpbrk(in_ptr, " "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1565 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 1566 | if (!in_ptr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1567 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1568 | |
| 1569 | /* remove empty spaces */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 1570 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 1571 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1572 | |
| 1573 | /* measurement token of meas req IE */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 1574 | ret = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1575 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1576 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1577 | |
| 1578 | ret = kstrtos32(buf, 10, &content); |
| 1579 | if (ret < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1580 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1581 | |
Jeff Johnson | a0b6c3c | 2019-02-26 11:04:52 -0800 | [diff] [blame] | 1582 | req->meas_token = content; |
| 1583 | hdd_debug("meas token %d", req->meas_token); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1584 | |
Jeff Johnson | a0b6c3c | 2019-02-26 11:04:52 -0800 | [diff] [blame] | 1585 | hdd_debug("PLM req %s", req->enable ? "START" : "STOP"); |
| 1586 | if (req->enable) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1587 | |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 1588 | in_ptr = strpbrk(in_ptr, " "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1589 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 1590 | if (!in_ptr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1591 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1592 | |
| 1593 | /* remove empty spaces */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 1594 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 1595 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1596 | |
| 1597 | /* total number of bursts after which STA stops sending */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 1598 | ret = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1599 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1600 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1601 | |
| 1602 | ret = kstrtos32(buf, 10, &content); |
| 1603 | if (ret < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1604 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1605 | |
| 1606 | if (content < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1607 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1608 | |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 1609 | req->num_bursts = content; |
| 1610 | hdd_debug("num bursts %d", req->num_bursts); |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 1611 | in_ptr = strpbrk(in_ptr, " "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1612 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 1613 | if (!in_ptr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1614 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1615 | |
| 1616 | /* remove empty spaces */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 1617 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 1618 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1619 | |
| 1620 | /* burst interval in seconds */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 1621 | ret = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1622 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1623 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1624 | |
| 1625 | ret = kstrtos32(buf, 10, &content); |
| 1626 | if (ret < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1627 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1628 | |
| 1629 | if (content <= 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1630 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1631 | |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 1632 | req->burst_int = content; |
| 1633 | hdd_debug("burst int %d", req->burst_int); |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 1634 | in_ptr = strpbrk(in_ptr, " "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1635 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 1636 | if (!in_ptr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1637 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1638 | |
| 1639 | /* remove empty spaces */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 1640 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 1641 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1642 | |
| 1643 | /* Meas dur in TU's,STA goes off-ch and transmit PLM bursts */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 1644 | ret = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1645 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1646 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1647 | |
| 1648 | ret = kstrtos32(buf, 10, &content); |
| 1649 | if (ret < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1650 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1651 | |
| 1652 | if (content <= 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1653 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1654 | |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 1655 | req->meas_duration = content; |
| 1656 | hdd_debug("meas duration %d", req->meas_duration); |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 1657 | in_ptr = strpbrk(in_ptr, " "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1658 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 1659 | if (!in_ptr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1660 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1661 | |
| 1662 | /* remove empty spaces */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 1663 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 1664 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1665 | |
| 1666 | /* burst length of PLM bursts */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 1667 | ret = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1668 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1669 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1670 | |
| 1671 | ret = kstrtos32(buf, 10, &content); |
| 1672 | if (ret < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1673 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1674 | |
| 1675 | if (content <= 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1676 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1677 | |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 1678 | req->burst_len = content; |
| 1679 | hdd_debug("burst len %d", req->burst_len); |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 1680 | in_ptr = strpbrk(in_ptr, " "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1681 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 1682 | if (!in_ptr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1683 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1684 | |
| 1685 | /* remove empty spaces */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 1686 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 1687 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1688 | |
| 1689 | /* desired tx power for transmission of PLM bursts */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 1690 | ret = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1691 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1692 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1693 | |
| 1694 | ret = kstrtos32(buf, 10, &content); |
| 1695 | if (ret < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1696 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1697 | |
| 1698 | if (content <= 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1699 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1700 | |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 1701 | req->desired_tx_pwr = content; |
| 1702 | hdd_debug("desired tx pwr %d", req->desired_tx_pwr); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1703 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1704 | for (count = 0; count < QDF_MAC_ADDR_SIZE; count++) { |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 1705 | in_ptr = strpbrk(in_ptr, " "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1706 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 1707 | if (!in_ptr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1708 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1709 | |
| 1710 | /* remove empty spaces */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 1711 | while ((SPACE_ASCII_VALUE == *in_ptr) |
| 1712 | && ('\0' != *in_ptr)) |
| 1713 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1714 | |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 1715 | ret = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1716 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1717 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1718 | |
| 1719 | ret = kstrtos32(buf, 16, &content); |
| 1720 | if (ret < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1721 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1722 | |
Jeff Johnson | a0b6c3c | 2019-02-26 11:04:52 -0800 | [diff] [blame] | 1723 | req->mac_addr.bytes[count] = content; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1724 | } |
| 1725 | |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 1726 | hdd_debug("MAC addr " QDF_MAC_ADDR_STR, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 1727 | QDF_MAC_ADDR_ARRAY(req->mac_addr.bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1728 | |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 1729 | in_ptr = strpbrk(in_ptr, " "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1730 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 1731 | if (!in_ptr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1732 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1733 | |
| 1734 | /* remove empty spaces */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 1735 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 1736 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1737 | |
| 1738 | /* number of channels */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 1739 | ret = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1740 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1741 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1742 | |
| 1743 | ret = kstrtos32(buf, 10, &content); |
| 1744 | if (ret < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1745 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1746 | |
| 1747 | if (content < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1748 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1749 | |
Wu Gao | 0821b0d | 2019-01-11 17:31:11 +0800 | [diff] [blame] | 1750 | content = QDF_MIN(content, CFG_VALID_CHANNEL_LIST_LEN); |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 1751 | req->plm_num_ch = content; |
| 1752 | hdd_debug("num ch: %d", req->plm_num_ch); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1753 | |
| 1754 | /* Channel numbers */ |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 1755 | for (count = 0; count < req->plm_num_ch; count++) { |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 1756 | in_ptr = strpbrk(in_ptr, " "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1757 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 1758 | if (!in_ptr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1759 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1760 | |
| 1761 | /* remove empty spaces */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 1762 | while ((SPACE_ASCII_VALUE == *in_ptr) |
| 1763 | && ('\0' != *in_ptr)) |
| 1764 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1765 | |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 1766 | ret = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1767 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1768 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1769 | |
| 1770 | ret = kstrtos32(buf, 10, &content); |
Srinivas Girigowda | 0fb6cc4 | 2016-08-26 14:53:59 -0700 | [diff] [blame] | 1771 | if (ret < 0 || content <= 0 || |
| 1772 | content > WNI_CFG_CURRENT_CHANNEL_STAMAX) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1773 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1774 | |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 1775 | req->plm_ch_list[count] = content; |
| 1776 | hdd_debug(" ch- %d", req->plm_ch_list[count]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1777 | } |
| 1778 | } |
| 1779 | /* If PLM START */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1780 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1781 | } |
| 1782 | #endif |
| 1783 | |
| 1784 | #ifdef WLAN_FEATURE_EXTWOW_SUPPORT |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 1785 | /** |
| 1786 | * wlan_hdd_ready_to_extwow() - Callback function for enable ext wow |
| 1787 | * @cookie: callback context |
| 1788 | * @is_success: suspend status of ext wow |
| 1789 | * |
| 1790 | * Return: none |
| 1791 | */ |
| 1792 | static void wlan_hdd_ready_to_extwow(void *cookie, bool is_success) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1793 | { |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 1794 | struct osif_request *request = NULL; |
| 1795 | struct enable_ext_wow_priv *priv = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1796 | |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 1797 | request = osif_request_get(cookie); |
| 1798 | if (!request) { |
| 1799 | hdd_err("Obselete request"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1800 | return; |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 1801 | } |
| 1802 | priv = osif_request_priv(request); |
| 1803 | priv->ext_wow_should_suspend = is_success; |
| 1804 | |
| 1805 | osif_request_complete(request); |
| 1806 | osif_request_put(request); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1807 | } |
| 1808 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 1809 | static int hdd_enable_ext_wow(struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1810 | tpSirExtWoWParams arg_params) |
| 1811 | { |
| 1812 | tSirExtWoWParams params; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1813 | QDF_STATUS status; |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 1814 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1815 | int rc; |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 1816 | struct enable_ext_wow_priv *priv = NULL; |
| 1817 | struct osif_request *request = NULL; |
| 1818 | void *cookie = NULL; |
| 1819 | struct osif_request_params hdd_params = { |
| 1820 | .priv_size = sizeof(*priv), |
| 1821 | .timeout_ms = WLAN_WAIT_TIME_READY_TO_EXTWOW, |
| 1822 | }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1823 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1824 | qdf_mem_copy(¶ms, arg_params, sizeof(params)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1825 | |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 1826 | request = osif_request_alloc(&hdd_params); |
| 1827 | if (!request) { |
| 1828 | hdd_err("Request Allocation Failure"); |
| 1829 | return -ENOMEM; |
| 1830 | } |
| 1831 | cookie = osif_request_cookie(request); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1832 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1833 | status = sme_configure_ext_wow(hdd_ctx->mac_handle, ¶ms, |
| 1834 | &wlan_hdd_ready_to_extwow, |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 1835 | cookie); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1836 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1837 | hdd_err("sme_configure_ext_wow returned failure %d", |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1838 | status); |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 1839 | rc = -EPERM; |
| 1840 | goto exit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1841 | } |
| 1842 | |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 1843 | rc = osif_request_wait_for_response(request); |
| 1844 | if (rc) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1845 | hdd_err("Failed to get ready to extwow"); |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 1846 | rc = -EPERM; |
| 1847 | goto exit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1848 | } |
| 1849 | |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 1850 | priv = osif_request_priv(request); |
| 1851 | if (!priv->ext_wow_should_suspend) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1852 | hdd_err("Received ready to ExtWoW failure"); |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 1853 | rc = -EPERM; |
| 1854 | goto exit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1855 | } |
| 1856 | |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 1857 | if (ucfg_pmo_extwow_is_goto_suspend_enabled(hdd_ctx->psoc)) { |
Jeff Johnson | 17d6267 | 2017-03-27 08:00:11 -0700 | [diff] [blame] | 1858 | hdd_info("Received ready to ExtWoW. Going to suspend"); |
| 1859 | |
| 1860 | rc = wlan_hdd_cfg80211_suspend_wlan(hdd_ctx->wiphy, NULL); |
| 1861 | if (rc < 0) { |
| 1862 | hdd_err("wlan_hdd_cfg80211_suspend_wlan failed, error = %d", |
| 1863 | rc); |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 1864 | goto exit; |
Jeff Johnson | 17d6267 | 2017-03-27 08:00:11 -0700 | [diff] [blame] | 1865 | } |
| 1866 | rc = wlan_hdd_bus_suspend(); |
| 1867 | if (rc) { |
| 1868 | hdd_err("wlan_hdd_bus_suspend failed, status = %d", |
| 1869 | rc); |
| 1870 | wlan_hdd_cfg80211_resume_wlan(hdd_ctx->wiphy); |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 1871 | goto exit; |
Jeff Johnson | 17d6267 | 2017-03-27 08:00:11 -0700 | [diff] [blame] | 1872 | } |
| 1873 | } |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 1874 | |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 1875 | exit: |
| 1876 | osif_request_put(request); |
| 1877 | return rc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1878 | } |
| 1879 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 1880 | static int hdd_enable_ext_wow_parser(struct hdd_adapter *adapter, int vdev_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1881 | int value) |
| 1882 | { |
| 1883 | tSirExtWoWParams params; |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 1884 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1885 | int rc; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 1886 | uint8_t pin1, pin2; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1887 | |
| 1888 | rc = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 1889 | if (rc) |
| 1890 | return rc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1891 | |
| 1892 | if (value < EXT_WOW_TYPE_APP_TYPE1 || |
| 1893 | value > EXT_WOW_TYPE_APP_TYPE1_2) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 1894 | hdd_err("Invalid type: %d", value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1895 | return -EINVAL; |
| 1896 | } |
| 1897 | |
| 1898 | if (value == EXT_WOW_TYPE_APP_TYPE1 && |
| 1899 | hdd_ctx->is_extwow_app_type1_param_set) |
| 1900 | params.type = value; |
| 1901 | else if (value == EXT_WOW_TYPE_APP_TYPE2 && |
| 1902 | hdd_ctx->is_extwow_app_type2_param_set) |
| 1903 | params.type = value; |
| 1904 | else if (value == EXT_WOW_TYPE_APP_TYPE1_2 && |
| 1905 | hdd_ctx->is_extwow_app_type1_param_set && |
| 1906 | hdd_ctx->is_extwow_app_type2_param_set) |
| 1907 | params.type = value; |
| 1908 | else { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1909 | hdd_err("Set app params before enable it value %d", |
| 1910 | value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1911 | return -EINVAL; |
| 1912 | } |
| 1913 | |
| 1914 | params.vdev_id = vdev_id; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 1915 | pin1 = ucfg_pmo_extwow_app1_wakeup_pin_num(hdd_ctx->psoc); |
| 1916 | pin2 = ucfg_pmo_extwow_app2_wakeup_pin_num(hdd_ctx->psoc); |
| 1917 | params.wakeup_pin_num = pin1 | (pin2 << 8); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1918 | |
| 1919 | return hdd_enable_ext_wow(adapter, ¶ms); |
| 1920 | } |
| 1921 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1922 | static int hdd_set_app_type1_params(mac_handle_t mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1923 | tpSirAppType1Params arg_params) |
| 1924 | { |
| 1925 | tSirAppType1Params params; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1926 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1927 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1928 | qdf_mem_copy(¶ms, arg_params, sizeof(params)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1929 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1930 | status = sme_configure_app_type1_params(mac_handle, ¶ms); |
| 1931 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1932 | hdd_err("sme_configure_app_type1_params returned failure %d", |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1933 | status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1934 | return -EPERM; |
| 1935 | } |
| 1936 | |
| 1937 | return 0; |
| 1938 | } |
| 1939 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 1940 | static int hdd_set_app_type1_parser(struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1941 | char *arg, int len) |
| 1942 | { |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 1943 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1944 | char id[20], password[20]; |
| 1945 | tSirAppType1Params params; |
Srinivas Girigowda | 0420991 | 2015-11-24 12:11:13 -0800 | [diff] [blame] | 1946 | int rc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1947 | |
| 1948 | rc = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 1949 | if (rc) |
| 1950 | return rc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1951 | |
| 1952 | if (2 != sscanf(arg, "%8s %16s", id, password)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1953 | hdd_err("Invalid Number of arguments"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1954 | return -EINVAL; |
| 1955 | } |
| 1956 | |
| 1957 | memset(¶ms, 0, sizeof(tSirAppType1Params)); |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 1958 | params.vdev_id = adapter->vdev_id; |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 1959 | qdf_copy_macaddr(¶ms.wakee_mac_addr, &adapter->mac_addr); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1960 | |
| 1961 | params.id_length = strlen(id); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1962 | qdf_mem_copy(params.identification_id, id, params.id_length); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1963 | params.pass_length = strlen(password); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1964 | qdf_mem_copy(params.password, password, params.pass_length); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1965 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 1966 | hdd_debug("%d %pM %.8s %u %.16s %u", |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1967 | params.vdev_id, params.wakee_mac_addr.bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1968 | params.identification_id, params.id_length, |
| 1969 | params.password, params.pass_length); |
| 1970 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1971 | return hdd_set_app_type1_params(hdd_ctx->mac_handle, ¶ms); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1972 | } |
| 1973 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1974 | static int hdd_set_app_type2_params(mac_handle_t mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1975 | tpSirAppType2Params arg_params) |
| 1976 | { |
| 1977 | tSirAppType2Params params; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1978 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1979 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1980 | qdf_mem_copy(¶ms, arg_params, sizeof(params)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1981 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1982 | status = sme_configure_app_type2_params(mac_handle, ¶ms); |
| 1983 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1984 | hdd_err("sme_configure_app_type2_params returned failure %d", |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1985 | status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1986 | return -EPERM; |
| 1987 | } |
| 1988 | |
| 1989 | return 0; |
| 1990 | } |
| 1991 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 1992 | static int hdd_set_app_type2_parser(struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1993 | char *arg, int len) |
| 1994 | { |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 1995 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1996 | char mac_addr[20], rc4_key[20]; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1997 | unsigned int gateway_mac[QDF_MAC_ADDR_SIZE]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1998 | tSirAppType2Params params; |
| 1999 | int ret; |
| 2000 | |
| 2001 | ret = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 2002 | if (ret) |
| 2003 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2004 | |
| 2005 | memset(¶ms, 0, sizeof(tSirAppType2Params)); |
| 2006 | |
Bhargav Shah | f4fd97d | 2015-07-08 10:21:37 +0530 | [diff] [blame] | 2007 | ret = sscanf(arg, "%17s %16s %x %x %x %u %u %hu %hu %u %u %u %u %u %u", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2008 | mac_addr, rc4_key, (unsigned int *)¶ms.ip_id, |
| 2009 | (unsigned int *)¶ms.ip_device_ip, |
| 2010 | (unsigned int *)¶ms.ip_server_ip, |
| 2011 | (unsigned int *)¶ms.tcp_seq, |
| 2012 | (unsigned int *)¶ms.tcp_ack_seq, |
Bhargav Shah | f4fd97d | 2015-07-08 10:21:37 +0530 | [diff] [blame] | 2013 | (uint16_t *)¶ms.tcp_src_port, |
| 2014 | (uint16_t *)¶ms.tcp_dst_port, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2015 | (unsigned int *)¶ms.keepalive_init, |
| 2016 | (unsigned int *)¶ms.keepalive_min, |
| 2017 | (unsigned int *)¶ms.keepalive_max, |
| 2018 | (unsigned int *)¶ms.keepalive_inc, |
| 2019 | (unsigned int *)¶ms.tcp_tx_timeout_val, |
| 2020 | (unsigned int *)¶ms.tcp_rx_timeout_val); |
| 2021 | |
| 2022 | if (ret != 15 && ret != 7) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2023 | hdd_err("Invalid Number of arguments"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2024 | return -EINVAL; |
| 2025 | } |
| 2026 | |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 2027 | if (6 != sscanf(mac_addr, QDF_MAC_ADDR_STR, |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 2028 | &gateway_mac[0], &gateway_mac[1], &gateway_mac[2], |
| 2029 | &gateway_mac[3], &gateway_mac[4], &gateway_mac[5])) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2030 | hdd_err("Invalid MacAddress Input %s", mac_addr); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2031 | return -EINVAL; |
| 2032 | } |
| 2033 | |
| 2034 | if (params.tcp_src_port > WLAN_HDD_MAX_TCP_PORT || |
| 2035 | params.tcp_dst_port > WLAN_HDD_MAX_TCP_PORT) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2036 | hdd_err("Invalid TCP Port Number"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2037 | return -EINVAL; |
| 2038 | } |
| 2039 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2040 | qdf_mem_copy(¶ms.gateway_mac.bytes, (uint8_t *) &gateway_mac, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2041 | QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2042 | |
| 2043 | params.rc4_key_len = strlen(rc4_key); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2044 | qdf_mem_copy(params.rc4_key, rc4_key, params.rc4_key_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2045 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 2046 | params.vdev_id = adapter->vdev_id; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 2047 | |
| 2048 | if (!params.tcp_src_port) |
| 2049 | params.tcp_src_port = |
| 2050 | ucfg_pmo_extwow_app2_tcp_src_port(hdd_ctx->psoc); |
| 2051 | |
| 2052 | if (!params.tcp_dst_port) |
| 2053 | params.tcp_dst_port = |
| 2054 | ucfg_pmo_extwow_app2_tcp_dst_port(hdd_ctx->psoc); |
| 2055 | |
| 2056 | if (!params.keepalive_init) |
| 2057 | params.keepalive_init = |
| 2058 | ucfg_pmo_extwow_app2_init_ping_interval(hdd_ctx->psoc); |
| 2059 | |
| 2060 | if (!params.keepalive_min) |
| 2061 | params.keepalive_min = |
| 2062 | ucfg_pmo_extwow_app2_min_ping_interval(hdd_ctx->psoc); |
| 2063 | |
| 2064 | if (!params.keepalive_max) |
| 2065 | params.keepalive_max = |
| 2066 | ucfg_pmo_extwow_app2_max_ping_interval(hdd_ctx->psoc); |
| 2067 | |
| 2068 | if (!params.keepalive_inc) |
| 2069 | params.keepalive_inc = |
| 2070 | ucfg_pmo_extwow_app2_inc_ping_interval(hdd_ctx->psoc); |
| 2071 | |
| 2072 | if (!params.tcp_tx_timeout_val) |
| 2073 | params.tcp_tx_timeout_val = |
| 2074 | ucfg_pmo_extwow_app2_tcp_tx_timeout(hdd_ctx->psoc); |
| 2075 | |
| 2076 | if (!params.tcp_rx_timeout_val) |
| 2077 | params.tcp_rx_timeout_val = |
| 2078 | ucfg_pmo_extwow_app2_tcp_rx_timeout(hdd_ctx->psoc); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2079 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 2080 | hdd_debug("%pM %.16s %u %u %u %u %u %u %u %u %u %u %u %u %u", |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2081 | gateway_mac, rc4_key, params.ip_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2082 | params.ip_device_ip, params.ip_server_ip, params.tcp_seq, |
| 2083 | params.tcp_ack_seq, params.tcp_src_port, params.tcp_dst_port, |
| 2084 | params.keepalive_init, params.keepalive_min, |
| 2085 | params.keepalive_max, params.keepalive_inc, |
| 2086 | params.tcp_tx_timeout_val, params.tcp_rx_timeout_val); |
| 2087 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2088 | return hdd_set_app_type2_params(hdd_ctx->mac_handle, ¶ms); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2089 | } |
| 2090 | #endif /* WLAN_FEATURE_EXTWOW_SUPPORT */ |
| 2091 | |
| 2092 | /** |
| 2093 | * hdd_parse_setmaxtxpower_command() - HDD Parse MAXTXPOWER command |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 2094 | * @command: Pointer to MAXTXPOWER command |
Jeff Johnson | 93f47cf | 2019-02-26 13:08:48 -0800 | [diff] [blame] | 2095 | * @tx_power: Pointer to tx power |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2096 | * |
| 2097 | * This function parses the MAXTXPOWER command passed in the format |
| 2098 | * MAXTXPOWER<space>X(Tx power in dbm) |
| 2099 | * |
| 2100 | * For example input commands: |
| 2101 | * 1) MAXTXPOWER -8 -> This is translated into set max TX power to -8 dbm |
| 2102 | * 2) MAXTXPOWER -23 -> This is translated into set max TX power to -23 dbm |
| 2103 | * |
| 2104 | * Return: 0 for success non-zero for failure |
| 2105 | */ |
Jeff Johnson | 93f47cf | 2019-02-26 13:08:48 -0800 | [diff] [blame] | 2106 | static int hdd_parse_setmaxtxpower_command(uint8_t *command, int *tx_power) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2107 | { |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 2108 | uint8_t *in_ptr = command; |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 2109 | int temp_int; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2110 | int v = 0; |
Jeff Johnson | 93f47cf | 2019-02-26 13:08:48 -0800 | [diff] [blame] | 2111 | *tx_power = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2112 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 2113 | in_ptr = strnchr(command, strlen(command), SPACE_ASCII_VALUE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2114 | /* no argument after the command */ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2115 | if (!in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2116 | return -EINVAL; |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 2117 | else if (SPACE_ASCII_VALUE != *in_ptr) /* no space after the command */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2118 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2119 | |
| 2120 | /* remove empty spaces */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 2121 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 2122 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2123 | |
| 2124 | /* no argument followed by spaces */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 2125 | if ('\0' == *in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2126 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2127 | |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 2128 | v = kstrtos32(in_ptr, 10, &temp_int); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2129 | |
| 2130 | /* Range checking for passed parameter */ |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 2131 | if ((temp_int < HDD_MIN_TX_POWER) || (temp_int > HDD_MAX_TX_POWER)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2132 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2133 | |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 2134 | *tx_power = temp_int; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2135 | |
Jeff Johnson | 93f47cf | 2019-02-26 13:08:48 -0800 | [diff] [blame] | 2136 | hdd_debug("SETMAXTXPOWER: %d", *tx_power); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2137 | |
| 2138 | return 0; |
| 2139 | } /* End of hdd_parse_setmaxtxpower_command */ |
| 2140 | |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2141 | static int hdd_get_dwell_time(struct wlan_objmgr_psoc *psoc, uint8_t *command, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2142 | char *extra, uint8_t n, uint8_t *len) |
| 2143 | { |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2144 | uint32_t val = 0; |
| 2145 | |
| 2146 | if (!psoc || !command || !extra || !len) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2147 | hdd_err("argument passed for GETDWELLTIME is incorrect"); |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 2148 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2149 | } |
| 2150 | |
| 2151 | if (strncmp(command, "GETDWELLTIME ACTIVE MAX", 23) == 0) { |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2152 | ucfg_scan_cfg_get_active_dwelltime(psoc, &val); |
| 2153 | *len = scnprintf(extra, n, "GETDWELLTIME ACTIVE MAX %u\n", val); |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 2154 | return 0; |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 2155 | } |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 2156 | if (strncmp(command, "GETDWELLTIME PASSIVE MAX", 24) == 0) { |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2157 | ucfg_scan_cfg_get_passive_dwelltime(psoc, &val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2158 | *len = scnprintf(extra, n, "GETDWELLTIME PASSIVE MAX %u\n", |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2159 | val); |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 2160 | return 0; |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 2161 | } |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 2162 | if (strncmp(command, "GETDWELLTIME", 12) == 0) { |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2163 | ucfg_scan_cfg_get_active_dwelltime(psoc, &val); |
| 2164 | *len = scnprintf(extra, n, "GETDWELLTIME %u\n", val); |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 2165 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2166 | } |
| 2167 | |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 2168 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2169 | } |
| 2170 | |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2171 | static int hdd_set_dwell_time(struct wlan_objmgr_psoc *psoc, uint8_t *command) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2172 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2173 | uint8_t *value = command; |
Srinivas Girigowda | a9ce5e6 | 2019-03-28 13:44:31 -0700 | [diff] [blame] | 2174 | int retval = 0, temp = 0; |
| 2175 | uint32_t val = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2176 | |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2177 | if (!psoc) { |
| 2178 | hdd_err("psoc is null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2179 | return -EINVAL; |
| 2180 | } |
| 2181 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2182 | if (strncmp(command, "SETDWELLTIME ACTIVE MAX", 23) == 0) { |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 2183 | if (drv_cmd_validate(command, 23)) |
| 2184 | return -EINVAL; |
| 2185 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2186 | value = value + 24; |
| 2187 | temp = kstrtou32(value, 10, &val); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2188 | if (temp || !cfg_in_range(CFG_ACTIVE_MAX_CHANNEL_TIME, val)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2189 | hdd_err("argument passed for SETDWELLTIME ACTIVE MAX is incorrect"); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2190 | return -EFAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2191 | } |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2192 | ucfg_scan_cfg_set_active_dwelltime(psoc, val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2193 | } else if (strncmp(command, "SETDWELLTIME PASSIVE MAX", 24) == 0) { |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 2194 | if (drv_cmd_validate(command, 24)) |
| 2195 | return -EINVAL; |
| 2196 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2197 | value = value + 25; |
| 2198 | temp = kstrtou32(value, 10, &val); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2199 | if (temp || !cfg_in_range(CFG_PASSIVE_MAX_CHANNEL_TIME, val)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2200 | hdd_err("argument passed for SETDWELLTIME PASSIVE MAX is incorrect"); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2201 | return -EFAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2202 | } |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2203 | ucfg_scan_cfg_set_passive_dwelltime(psoc, val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2204 | } else if (strncmp(command, "SETDWELLTIME", 12) == 0) { |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 2205 | if (drv_cmd_validate(command, 12)) |
| 2206 | return -EINVAL; |
| 2207 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2208 | value = value + 13; |
| 2209 | temp = kstrtou32(value, 10, &val); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2210 | if (temp || !cfg_in_range(CFG_ACTIVE_MAX_CHANNEL_TIME, val)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2211 | hdd_err("argument passed for SETDWELLTIME is incorrect"); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2212 | return -EFAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2213 | } |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2214 | ucfg_scan_cfg_set_active_dwelltime(psoc, val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2215 | } else { |
Sridhar Selvaraj | 48c4709 | 2017-07-31 18:18:14 +0530 | [diff] [blame] | 2216 | retval = -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2217 | } |
| 2218 | |
Sridhar Selvaraj | 48c4709 | 2017-07-31 18:18:14 +0530 | [diff] [blame] | 2219 | return retval; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2220 | } |
| 2221 | |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 2222 | struct link_status_priv { |
| 2223 | uint8_t link_status; |
| 2224 | }; |
| 2225 | |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2226 | /** |
| 2227 | * hdd_conc_set_dwell_time() - Set Concurrent dwell time parameters |
| 2228 | * @adapter: Adapter upon which the command was received |
| 2229 | * @command: ASCII text command that is received |
| 2230 | * |
| 2231 | * Driver commands: |
| 2232 | * wpa_cli DRIVER CONCSETDWELLTIME ACTIVE MAX <value> |
| 2233 | * wpa_cli DRIVER CONCSETDWELLTIME ACTIVE MIN <value> |
| 2234 | * wpa_cli DRIVER CONCSETDWELLTIME PASSIVE MAX <value> |
| 2235 | * wpa_cli DRIVER CONCSETDWELLTIME PASSIVE MIN <value> |
| 2236 | * |
| 2237 | * Return: 0 for success non-zero for failure |
| 2238 | */ |
Ashish Kumar Dhanotiya | 652c233 | 2018-12-11 17:33:17 +0530 | [diff] [blame] | 2239 | static int hdd_conc_set_dwell_time(struct hdd_adapter *adapter, |
| 2240 | uint8_t *command) |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2241 | { |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2242 | u8 *value = command; |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2243 | int val = 0, temp = 0; |
| 2244 | int retval = 0; |
| 2245 | |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2246 | if (strncmp(command, "CONCSETDWELLTIME ACTIVE MAX", 27) == 0) { |
| 2247 | if (drv_cmd_validate(command, 27)) { |
| 2248 | hdd_err("Invalid driver command"); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2249 | return -EINVAL; |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2250 | } |
| 2251 | |
| 2252 | value = value + 28; |
| 2253 | temp = kstrtou32(value, 10, &val); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2254 | if (temp || |
| 2255 | !cfg_in_range(CFG_ACTIVE_MAX_CHANNEL_TIME_CONC, val)) { |
Harprit Chhabada | 4691a47 | 2018-12-07 11:22:48 -0800 | [diff] [blame] | 2256 | hdd_err("CONC ACTIVE MAX value %d incorrect", val); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2257 | return -EFAULT; |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2258 | } |
Ashish Kumar Dhanotiya | 652c233 | 2018-12-11 17:33:17 +0530 | [diff] [blame] | 2259 | ucfg_scan_cfg_set_conc_active_dwelltime( |
| 2260 | (WLAN_HDD_GET_CTX(adapter))->psoc, val); |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2261 | } else if (strncmp(command, "CONCSETDWELLTIME PASSIVE MAX", 28) == 0) { |
| 2262 | if (drv_cmd_validate(command, 28)) { |
| 2263 | hdd_err("Invalid driver command"); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2264 | return -EINVAL; |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2265 | } |
| 2266 | |
| 2267 | value = value + 29; |
| 2268 | temp = kstrtou32(value, 10, &val); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2269 | if (temp || |
| 2270 | !cfg_in_range(CFG_PASSIVE_MAX_CHANNEL_TIME_CONC, val)) { |
Harprit Chhabada | 4691a47 | 2018-12-07 11:22:48 -0800 | [diff] [blame] | 2271 | hdd_err("CONC PASSIVE MAX val %d incorrect", val); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2272 | return -EFAULT; |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2273 | } |
Ashish Kumar Dhanotiya | 652c233 | 2018-12-11 17:33:17 +0530 | [diff] [blame] | 2274 | ucfg_scan_cfg_set_conc_passive_dwelltime( |
| 2275 | (WLAN_HDD_GET_CTX(adapter))->psoc, val); |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2276 | } else { |
| 2277 | retval = -EINVAL; |
| 2278 | } |
| 2279 | |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2280 | return retval; |
| 2281 | } |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2282 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2283 | static void hdd_get_link_status_cb(uint8_t status, void *context) |
| 2284 | { |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 2285 | struct osif_request *request; |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 2286 | struct link_status_priv *priv; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2287 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 2288 | request = osif_request_get(context); |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 2289 | if (!request) { |
| 2290 | hdd_err("Obsolete request"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2291 | return; |
| 2292 | } |
| 2293 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 2294 | priv = osif_request_priv(request); |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 2295 | priv->link_status = status; |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 2296 | osif_request_complete(request); |
| 2297 | osif_request_put(request); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2298 | } |
| 2299 | |
| 2300 | /** |
| 2301 | * wlan_hdd_get_link_status() - get link status |
Jeff Johnson | 25c7734 | 2017-10-02 13:28:03 -0700 | [diff] [blame] | 2302 | * @adapter: pointer to the adapter |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2303 | * |
| 2304 | * This function sends a request to query the link status and waits |
| 2305 | * on a timer to invoke the callback. if the callback is invoked then |
| 2306 | * latest link status shall be returned or otherwise cached value |
| 2307 | * will be returned. |
| 2308 | * |
| 2309 | * Return: On success, link status shall be returned. |
| 2310 | * On error or not associated, link status 0 will be returned. |
| 2311 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 2312 | static int wlan_hdd_get_link_status(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2313 | { |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2314 | struct hdd_station_ctx *sta_ctx; |
| 2315 | QDF_STATUS status; |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 2316 | int ret; |
| 2317 | void *cookie; |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 2318 | struct osif_request *request; |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 2319 | struct link_status_priv *priv; |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 2320 | static const struct osif_request_params params = { |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 2321 | .priv_size = sizeof(*priv), |
| 2322 | .timeout_ms = WLAN_WAIT_TIME_LINK_STATUS, |
| 2323 | }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2324 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 2325 | if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) { |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 2326 | hdd_warn("Recovery in Progress. State: 0x%x Ignore!!!", |
| 2327 | cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2328 | return 0; |
| 2329 | } |
| 2330 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 2331 | if ((QDF_STA_MODE != adapter->device_mode) && |
| 2332 | (QDF_P2P_CLIENT_MODE != adapter->device_mode)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2333 | hdd_warn("Unsupported in mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 2334 | qdf_opmode_str(adapter->device_mode), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2335 | adapter->device_mode); |
| 2336 | return 0; |
| 2337 | } |
| 2338 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 2339 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 2340 | if (eConnectionState_Associated != sta_ctx->conn_info.conn_state) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2341 | /* If not associated, then expected link status return |
| 2342 | * value is 0 |
| 2343 | */ |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 2344 | hdd_warn("Not associated!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2345 | return 0; |
| 2346 | } |
| 2347 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 2348 | request = osif_request_alloc(¶ms); |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 2349 | if (!request) { |
| 2350 | hdd_err("Request allocation failure"); |
| 2351 | return 0; |
| 2352 | } |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 2353 | cookie = osif_request_cookie(request); |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 2354 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2355 | status = sme_get_link_status(adapter->hdd_ctx->mac_handle, |
| 2356 | hdd_get_link_status_cb, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 2357 | cookie, adapter->vdev_id); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2358 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2359 | hdd_err("Unable to retrieve link status"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2360 | /* return a cached value */ |
| 2361 | } else { |
| 2362 | /* request is sent -- wait for the response */ |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 2363 | ret = osif_request_wait_for_response(request); |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 2364 | if (ret) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2365 | hdd_err("SME timed out while retrieving link status"); |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 2366 | /* return a cached value */ |
| 2367 | } else { |
| 2368 | /* update the adapter with the fresh results */ |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 2369 | priv = osif_request_priv(request); |
Jeff Johnson | bd4c4f0 | 2017-10-30 20:33:01 -0700 | [diff] [blame] | 2370 | adapter->link_status = priv->link_status; |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 2371 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2372 | } |
| 2373 | |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 2374 | /* |
| 2375 | * either we never sent a request, we sent a request and |
| 2376 | * received a response or we sent a request and timed out. |
| 2377 | * regardless we are done with the request. |
| 2378 | */ |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 2379 | osif_request_put(request); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2380 | |
| 2381 | /* either callback updated adapter stats or it has cached data */ |
Jeff Johnson | bd4c4f0 | 2017-10-30 20:33:01 -0700 | [diff] [blame] | 2382 | return adapter->link_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2383 | } |
| 2384 | |
Jeff Johnson | 8f2016e | 2019-02-26 20:21:08 -0800 | [diff] [blame] | 2385 | static void hdd_tx_fail_ind_callback(uint8_t *macaddr, uint8_t seq_no) |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2386 | { |
| 2387 | int payload_len; |
| 2388 | struct sk_buff *skb; |
| 2389 | struct nlmsghdr *nlh; |
| 2390 | uint8_t *data; |
| 2391 | |
| 2392 | payload_len = ETH_ALEN; |
| 2393 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2394 | if (0 == cesium_pid || !cesium_nl_srv_sock) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2395 | hdd_err("cesium process not registered"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2396 | return; |
| 2397 | } |
| 2398 | |
| 2399 | skb = nlmsg_new(payload_len, GFP_ATOMIC); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2400 | if (!skb) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2401 | hdd_err("nlmsg_new() failed for msg size[%d]", |
| 2402 | NLMSG_SPACE(payload_len)); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2403 | return; |
| 2404 | } |
| 2405 | |
Jeff Johnson | d8a3546 | 2019-02-26 20:18:51 -0800 | [diff] [blame] | 2406 | nlh = nlmsg_put(skb, cesium_pid, seq_no, 0, payload_len, NLM_F_REQUEST); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2407 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2408 | if (!nlh) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2409 | hdd_err("nlmsg_put() failed for msg size[%d]", |
| 2410 | NLMSG_SPACE(payload_len)); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2411 | |
| 2412 | kfree_skb(skb); |
| 2413 | return; |
| 2414 | } |
| 2415 | |
| 2416 | data = nlmsg_data(nlh); |
Jeff Johnson | 8f2016e | 2019-02-26 20:21:08 -0800 | [diff] [blame] | 2417 | memcpy(data, macaddr, ETH_ALEN); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2418 | |
| 2419 | if (nlmsg_unicast(cesium_nl_srv_sock, skb, cesium_pid) < 0) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2420 | hdd_err("nlmsg_unicast() failed for msg size[%d]", |
| 2421 | NLMSG_SPACE(payload_len)); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2422 | } |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2423 | } |
| 2424 | |
| 2425 | |
| 2426 | /** |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 2427 | * hdd_parse_user_params() - return a pointer to the next argument |
| 2428 | * @command: Input argument string |
Jeff Johnson | 76e335b | 2019-02-26 17:41:17 -0800 | [diff] [blame] | 2429 | * @arg: Output pointer to the next argument |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2430 | * |
| 2431 | * This function parses argument stream and finds the pointer |
| 2432 | * to the next argument |
| 2433 | * |
| 2434 | * Return: 0 if the next argument found; -EINVAL otherwise |
| 2435 | */ |
Jeff Johnson | 76e335b | 2019-02-26 17:41:17 -0800 | [diff] [blame] | 2436 | static int hdd_parse_user_params(uint8_t *command, uint8_t **arg) |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2437 | { |
Jeff Johnson | 76e335b | 2019-02-26 17:41:17 -0800 | [diff] [blame] | 2438 | uint8_t *cursor; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2439 | |
Jeff Johnson | 76e335b | 2019-02-26 17:41:17 -0800 | [diff] [blame] | 2440 | cursor = strnchr(command, strlen(command), SPACE_ASCII_VALUE); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2441 | |
Jeff Johnson | 76e335b | 2019-02-26 17:41:17 -0800 | [diff] [blame] | 2442 | /* no argument remains ? */ |
| 2443 | if (!cursor) |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2444 | return -EINVAL; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2445 | |
Jeff Johnson | 76e335b | 2019-02-26 17:41:17 -0800 | [diff] [blame] | 2446 | /* no space after the current arg ? */ |
| 2447 | if (SPACE_ASCII_VALUE != *cursor) |
| 2448 | return -EINVAL; |
| 2449 | |
| 2450 | cursor++; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2451 | |
| 2452 | /* remove empty spaces */ |
Jeff Johnson | 76e335b | 2019-02-26 17:41:17 -0800 | [diff] [blame] | 2453 | while (SPACE_ASCII_VALUE == *cursor) |
| 2454 | cursor++; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2455 | |
Jeff Johnson | 76e335b | 2019-02-26 17:41:17 -0800 | [diff] [blame] | 2456 | /* no argument after the spaces ? */ |
| 2457 | if ('\0' == *cursor) |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2458 | return -EINVAL; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2459 | |
Jeff Johnson | 76e335b | 2019-02-26 17:41:17 -0800 | [diff] [blame] | 2460 | *arg = cursor; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2461 | |
| 2462 | return 0; |
| 2463 | } |
| 2464 | |
| 2465 | /** |
| 2466 | * hdd_parse_ibsstx_fail_event_params - Parse params |
| 2467 | * for SETIBSSTXFAILEVENT |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 2468 | * @command: Input ibss tx fail event argument |
| 2469 | * @tx_fail_count: (Output parameter) Tx fail counter |
| 2470 | * @pid: (Output parameter) PID |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2471 | * |
| 2472 | * Return: 0 if the parsing succeeds; -EINVAL otherwise |
| 2473 | */ |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 2474 | static int hdd_parse_ibsstx_fail_event_params(uint8_t *command, |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2475 | uint8_t *tx_fail_count, |
| 2476 | uint16_t *pid) |
| 2477 | { |
| 2478 | uint8_t *param = NULL; |
| 2479 | int ret; |
| 2480 | |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 2481 | ret = hdd_parse_user_params(command, ¶m); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2482 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2483 | if (0 == ret && param) { |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2484 | if (1 != sscanf(param, "%hhu", tx_fail_count)) { |
| 2485 | ret = -EINVAL; |
| 2486 | goto done; |
| 2487 | } |
| 2488 | } else { |
| 2489 | goto done; |
| 2490 | } |
| 2491 | |
| 2492 | if (0 == *tx_fail_count) { |
| 2493 | *pid = 0; |
| 2494 | goto done; |
| 2495 | } |
| 2496 | |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 2497 | command = param; |
| 2498 | command++; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2499 | |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 2500 | ret = hdd_parse_user_params(command, ¶m); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2501 | |
| 2502 | if (0 == ret) { |
| 2503 | if (1 != sscanf(param, "%hu", pid)) { |
| 2504 | ret = -EINVAL; |
| 2505 | goto done; |
| 2506 | } |
| 2507 | } else { |
| 2508 | goto done; |
| 2509 | } |
| 2510 | |
| 2511 | done: |
| 2512 | return ret; |
| 2513 | } |
| 2514 | |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 2515 | #ifdef FEATURE_WLAN_ESE |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2516 | /** |
| 2517 | * hdd_parse_ese_beacon_req() - Parse ese beacon request |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 2518 | * @command: Pointer to data |
Jeff Johnson | b2c3d04 | 2019-02-26 12:23:26 -0800 | [diff] [blame] | 2519 | * @req: Output pointer to store parsed ie information |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2520 | * |
| 2521 | * This function parses the ese beacon request passed in the format |
| 2522 | * CCXBEACONREQ<space><Number of fields><space><Measurement token> |
| 2523 | * <space>Channel 1<space>Scan Mode <space>Meas Duration<space>Channel N |
| 2524 | * <space>Scan Mode N<space>Meas Duration N |
| 2525 | * |
| 2526 | * If the Number of bcn req fields (N) does not match with the |
| 2527 | * actual number of fields passed then take N. |
| 2528 | * <Meas Token><Channel><Scan Mode> and <Meas Duration> are treated |
| 2529 | * as one pair. For example, CCXBEACONREQ 2 1 1 1 30 2 44 0 40. |
| 2530 | * This function does not take care of removing duplicate channels from the |
| 2531 | * list |
| 2532 | * |
| 2533 | * Return: 0 for success non-zero for failure |
| 2534 | */ |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 2535 | static int hdd_parse_ese_beacon_req(uint8_t *command, |
Jeff Johnson | b2c3d04 | 2019-02-26 12:23:26 -0800 | [diff] [blame] | 2536 | tCsrEseBeaconReq *req) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2537 | { |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 2538 | uint8_t *in_ptr = command; |
Srinivas Girigowda | 67e2da6 | 2016-07-19 16:33:01 -0700 | [diff] [blame] | 2539 | uint8_t input = 0; |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 2540 | uint32_t temp_int = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2541 | int j = 0, i = 0, v = 0; |
| 2542 | char buf[32]; |
| 2543 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 2544 | in_ptr = strnchr(command, strlen(command), SPACE_ASCII_VALUE); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2545 | if (!in_ptr) /* no argument after the command */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2546 | return -EINVAL; |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 2547 | else if (SPACE_ASCII_VALUE != *in_ptr) /* no space after the command */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2548 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2549 | |
| 2550 | /* remove empty spaces */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 2551 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 2552 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2553 | |
| 2554 | /* no argument followed by spaces */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 2555 | if ('\0' == *in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2556 | return -EINVAL; |
| 2557 | |
Srinivas Girigowda | 476deeb | 2016-07-19 16:21:29 -0700 | [diff] [blame] | 2558 | /* Getting the first argument ie Number of IE fields */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 2559 | v = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2560 | if (1 != v) |
| 2561 | return -EINVAL; |
| 2562 | |
Srinivas Girigowda | 67e2da6 | 2016-07-19 16:33:01 -0700 | [diff] [blame] | 2563 | v = kstrtou8(buf, 10, &input); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2564 | if (v < 0) |
| 2565 | return -EINVAL; |
| 2566 | |
Srinivas Girigowda | 67e2da6 | 2016-07-19 16:33:01 -0700 | [diff] [blame] | 2567 | input = QDF_MIN(input, SIR_ESE_MAX_MEAS_IE_REQS); |
Jeff Johnson | b2c3d04 | 2019-02-26 12:23:26 -0800 | [diff] [blame] | 2568 | req->numBcnReqIe = input; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2569 | |
Jeff Johnson | b2c3d04 | 2019-02-26 12:23:26 -0800 | [diff] [blame] | 2570 | hdd_debug("Number of Bcn Req Ie fields: %d", req->numBcnReqIe); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2571 | |
Jeff Johnson | b2c3d04 | 2019-02-26 12:23:26 -0800 | [diff] [blame] | 2572 | for (j = 0; j < (req->numBcnReqIe); j++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2573 | for (i = 0; i < 4; i++) { |
| 2574 | /* |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 2575 | * in_ptr pointing to the beginning of 1st space |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2576 | * after number of ie fields |
| 2577 | */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 2578 | in_ptr = strpbrk(in_ptr, " "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2579 | /* no ie data after the number of ie fields argument */ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2580 | if (!in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2581 | return -EINVAL; |
| 2582 | |
| 2583 | /* remove empty space */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 2584 | while ((SPACE_ASCII_VALUE == *in_ptr) |
| 2585 | && ('\0' != *in_ptr)) |
| 2586 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2587 | |
| 2588 | /* |
| 2589 | * no ie data after the number of ie fields |
| 2590 | * argument and spaces |
| 2591 | */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 2592 | if ('\0' == *in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2593 | return -EINVAL; |
| 2594 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 2595 | v = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2596 | if (1 != v) |
| 2597 | return -EINVAL; |
| 2598 | |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 2599 | v = kstrtou32(buf, 10, &temp_int); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2600 | if (v < 0) |
| 2601 | return -EINVAL; |
| 2602 | |
| 2603 | switch (i) { |
| 2604 | case 0: /* Measurement token */ |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 2605 | if (!temp_int) { |
Srinivas Girigowda | 67e2da6 | 2016-07-19 16:33:01 -0700 | [diff] [blame] | 2606 | hdd_err("Invalid Measurement Token: %u", |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 2607 | temp_int); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2608 | return -EINVAL; |
| 2609 | } |
Jeff Johnson | b2c3d04 | 2019-02-26 12:23:26 -0800 | [diff] [blame] | 2610 | req->bcnReq[j].measurementToken = |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 2611 | temp_int; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2612 | break; |
| 2613 | |
| 2614 | case 1: /* Channel number */ |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 2615 | if (!temp_int || |
| 2616 | (temp_int > |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2617 | WNI_CFG_CURRENT_CHANNEL_STAMAX)) { |
Srinivas Girigowda | 67e2da6 | 2016-07-19 16:33:01 -0700 | [diff] [blame] | 2618 | hdd_err("Invalid Channel Number: %u", |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 2619 | temp_int); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2620 | return -EINVAL; |
| 2621 | } |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 2622 | req->bcnReq[j].channel = temp_int; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2623 | break; |
| 2624 | |
| 2625 | case 2: /* Scan mode */ |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 2626 | if ((temp_int < eSIR_PASSIVE_SCAN) |
| 2627 | || (temp_int > eSIR_BEACON_TABLE)) { |
Srinivas Girigowda | 67e2da6 | 2016-07-19 16:33:01 -0700 | [diff] [blame] | 2628 | hdd_err("Invalid Scan Mode: %u Expected{0|1|2}", |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 2629 | temp_int); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2630 | return -EINVAL; |
| 2631 | } |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 2632 | req->bcnReq[j].scanMode = temp_int; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2633 | break; |
| 2634 | |
| 2635 | case 3: /* Measurement duration */ |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 2636 | if ((!temp_int |
Jeff Johnson | b2c3d04 | 2019-02-26 12:23:26 -0800 | [diff] [blame] | 2637 | && (req->bcnReq[j].scanMode != |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2638 | eSIR_BEACON_TABLE)) || |
Jeff Johnson | b2c3d04 | 2019-02-26 12:23:26 -0800 | [diff] [blame] | 2639 | (req->bcnReq[j].scanMode == |
Srinivas Girigowda | 67e2da6 | 2016-07-19 16:33:01 -0700 | [diff] [blame] | 2640 | eSIR_BEACON_TABLE)) { |
| 2641 | hdd_err("Invalid Measurement Duration: %u", |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 2642 | temp_int); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2643 | return -EINVAL; |
| 2644 | } |
Jeff Johnson | b2c3d04 | 2019-02-26 12:23:26 -0800 | [diff] [blame] | 2645 | req->bcnReq[j].measurementDuration = |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 2646 | temp_int; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2647 | break; |
| 2648 | } |
| 2649 | } |
| 2650 | } |
| 2651 | |
Jeff Johnson | b2c3d04 | 2019-02-26 12:23:26 -0800 | [diff] [blame] | 2652 | for (j = 0; j < req->numBcnReqIe; j++) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 2653 | hdd_debug("Index: %d Measurement Token: %u Channel: %u Scan Mode: %u Measurement Duration: %u", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2654 | j, |
Jeff Johnson | b2c3d04 | 2019-02-26 12:23:26 -0800 | [diff] [blame] | 2655 | req->bcnReq[j].measurementToken, |
| 2656 | req->bcnReq[j].channel, |
| 2657 | req->bcnReq[j].scanMode, |
| 2658 | req->bcnReq[j].measurementDuration); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2659 | } |
| 2660 | |
| 2661 | return 0; |
| 2662 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2663 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2664 | /** |
| 2665 | * hdd_parse_get_cckm_ie() - HDD Parse and fetch the CCKM IE |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 2666 | * @command: Pointer to input data |
Jeff Johnson | 64c01b1 | 2019-02-26 13:12:50 -0800 | [diff] [blame] | 2667 | * @cckm_ie: Pointer to output cckm Ie |
Jeff Johnson | ecbb79f | 2019-02-26 13:10:24 -0800 | [diff] [blame] | 2668 | * @cckm_ie_len: Pointer to output cckm ie length |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2669 | * |
| 2670 | * This function parses the SETCCKM IE command |
| 2671 | * SETCCKMIE<space><ie data> |
| 2672 | * |
| 2673 | * Return: 0 for success non-zero for failure |
| 2674 | */ |
Jeff Johnson | 64c01b1 | 2019-02-26 13:12:50 -0800 | [diff] [blame] | 2675 | static int hdd_parse_get_cckm_ie(uint8_t *command, uint8_t **cckm_ie, |
Jeff Johnson | ecbb79f | 2019-02-26 13:10:24 -0800 | [diff] [blame] | 2676 | uint8_t *cckm_ie_len) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2677 | { |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 2678 | uint8_t *in_ptr = command; |
Jeff Johnson | aae00ae | 2019-02-26 17:25:11 -0800 | [diff] [blame] | 2679 | uint8_t *end_ptr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2680 | int j = 0; |
| 2681 | int i = 0; |
Jeff Johnson | 72f498b | 2019-02-26 18:37:25 -0800 | [diff] [blame] | 2682 | uint8_t temp_u8 = 0; |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 2683 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 2684 | in_ptr = strnchr(command, strlen(command), SPACE_ASCII_VALUE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2685 | /* no argument after the command */ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2686 | if (!in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2687 | return -EINVAL; |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 2688 | else if (SPACE_ASCII_VALUE != *in_ptr) /* no space after the command */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2689 | return -EINVAL; |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 2690 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2691 | /* remove empty spaces */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 2692 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 2693 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2694 | /* no argument followed by spaces */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 2695 | if ('\0' == *in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2696 | return -EINVAL; |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 2697 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2698 | /* find the length of data */ |
Jeff Johnson | aae00ae | 2019-02-26 17:25:11 -0800 | [diff] [blame] | 2699 | end_ptr = in_ptr; |
| 2700 | while (('\0' != *end_ptr)) { |
| 2701 | end_ptr++; |
Jeff Johnson | ecbb79f | 2019-02-26 13:10:24 -0800 | [diff] [blame] | 2702 | ++(*cckm_ie_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2703 | } |
Jeff Johnson | ecbb79f | 2019-02-26 13:10:24 -0800 | [diff] [blame] | 2704 | if (*cckm_ie_len <= 0) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2705 | return -EINVAL; |
| 2706 | /* |
| 2707 | * Allocate the number of bytes based on the number of input characters |
| 2708 | * whether it is even or odd. |
| 2709 | * if the number of input characters are even, then we need N / 2 byte. |
| 2710 | * if the number of input characters are odd, then we need do |
| 2711 | * (N + 1) / 2 to compensate rounding off. |
| 2712 | * For example, if N = 18, then (18 + 1) / 2 = 9 bytes are enough. |
| 2713 | * If N = 19, then we need 10 bytes, hence (19 + 1) / 2 = 10 bytes |
| 2714 | */ |
Jeff Johnson | 64c01b1 | 2019-02-26 13:12:50 -0800 | [diff] [blame] | 2715 | *cckm_ie = qdf_mem_malloc((*cckm_ie_len + 1) / 2); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2716 | if (!*cckm_ie) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2717 | hdd_err("qdf_mem_malloc failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2718 | return -ENOMEM; |
| 2719 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2720 | /* |
| 2721 | * the buffer received from the upper layer is character buffer, |
| 2722 | * we need to prepare the buffer taking 2 characters in to a U8 hex |
| 2723 | * decimal number for example 7f0000f0...form a buffer to contain |
| 2724 | * 7f in 0th location, 00 in 1st and f0 in 3rd location |
| 2725 | */ |
Jeff Johnson | ecbb79f | 2019-02-26 13:10:24 -0800 | [diff] [blame] | 2726 | for (i = 0, j = 0; j < *cckm_ie_len; j += 2) { |
Jeff Johnson | 72f498b | 2019-02-26 18:37:25 -0800 | [diff] [blame] | 2727 | temp_u8 = (hex_to_bin(in_ptr[j]) << 4) | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 2728 | (hex_to_bin(in_ptr[j + 1])); |
Jeff Johnson | 72f498b | 2019-02-26 18:37:25 -0800 | [diff] [blame] | 2729 | (*cckm_ie)[i++] = temp_u8; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2730 | } |
Jeff Johnson | ecbb79f | 2019-02-26 13:10:24 -0800 | [diff] [blame] | 2731 | *cckm_ie_len = i; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2732 | return 0; |
| 2733 | } |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 2734 | #endif /* FEATURE_WLAN_ESE */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2735 | |
Jeff Johnson | b3f8043 | 2019-02-26 20:25:38 -0800 | [diff] [blame] | 2736 | int wlan_hdd_set_mc_rate(struct hdd_adapter *adapter, int target_rate) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2737 | { |
Jeff Johnson | 1a0c72b | 2019-02-26 20:29:43 -0800 | [diff] [blame] | 2738 | tSirRateUpdateInd rate_update = {0}; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2739 | QDF_STATUS status; |
Jeff Johnson | 25c7734 | 2017-10-02 13:28:03 -0700 | [diff] [blame] | 2740 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 2741 | bool bval = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2742 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2743 | if (!hdd_ctx) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2744 | hdd_err("HDD context is null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2745 | return -EINVAL; |
| 2746 | } |
Jeff Johnson | 25c7734 | 2017-10-02 13:28:03 -0700 | [diff] [blame] | 2747 | if ((QDF_IBSS_MODE != adapter->device_mode) && |
| 2748 | (QDF_SAP_MODE != adapter->device_mode) && |
| 2749 | (QDF_STA_MODE != adapter->device_mode)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2750 | hdd_err("Received SETMCRATE cmd in invalid mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 2751 | qdf_opmode_str(adapter->device_mode), |
| 2752 | adapter->device_mode); |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2753 | hdd_err("SETMCRATE cmd is allowed only in STA, IBSS or SOFTAP mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2754 | return -EINVAL; |
| 2755 | } |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 2756 | |
| 2757 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 2758 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 2759 | hdd_err("unable to get vht_enable2x2"); |
| 2760 | return -EINVAL; |
| 2761 | } |
Jeff Johnson | 1a0c72b | 2019-02-26 20:29:43 -0800 | [diff] [blame] | 2762 | rate_update.nss = (bval == 0) ? 0 : 1; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 2763 | |
Jeff Johnson | 1a0c72b | 2019-02-26 20:29:43 -0800 | [diff] [blame] | 2764 | rate_update.dev_mode = adapter->device_mode; |
| 2765 | rate_update.mcastDataRate24GHz = target_rate; |
| 2766 | rate_update.mcastDataRate24GHzTxFlag = 1; |
| 2767 | rate_update.mcastDataRate5GHz = target_rate; |
| 2768 | rate_update.bcastDataRate = -1; |
| 2769 | qdf_copy_macaddr(&rate_update.bssid, &adapter->mac_addr); |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 2770 | hdd_debug("MC Target rate %d, mac = %pM, dev_mode %s(%d)", |
Jeff Johnson | 1a0c72b | 2019-02-26 20:29:43 -0800 | [diff] [blame] | 2771 | rate_update.mcastDataRate24GHz, rate_update.bssid.bytes, |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 2772 | qdf_opmode_str(adapter->device_mode), adapter->device_mode); |
Jeff Johnson | 1a0c72b | 2019-02-26 20:29:43 -0800 | [diff] [blame] | 2773 | status = sme_send_rate_update_ind(hdd_ctx->mac_handle, &rate_update); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2774 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2775 | hdd_err("SETMCRATE failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2776 | return -EFAULT; |
| 2777 | } |
| 2778 | return 0; |
| 2779 | } |
| 2780 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 2781 | static int drv_cmd_p2p_dev_addr(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 2782 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2783 | uint8_t *command, |
| 2784 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 2785 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2786 | { |
Dustin Brown | ee22071 | 2018-04-19 16:24:23 -0700 | [diff] [blame] | 2787 | struct qdf_mac_addr *addr = &hdd_ctx->p2p_device_address; |
| 2788 | size_t user_size = qdf_min(sizeof(addr->bytes), |
| 2789 | (size_t)priv_data->total_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2790 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 2791 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 2792 | TRACE_CODE_HDD_P2P_DEV_ADDR_IOCTL, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 2793 | adapter->vdev_id, |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 2794 | (unsigned int)(*(addr->bytes + 2) << 24 | |
Dustin Brown | ee22071 | 2018-04-19 16:24:23 -0700 | [diff] [blame] | 2795 | *(addr->bytes + 3) << 16 | |
| 2796 | *(addr->bytes + 4) << 8 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 2797 | *(addr->bytes + 5))); |
| 2798 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2799 | |
Dustin Brown | ee22071 | 2018-04-19 16:24:23 -0700 | [diff] [blame] | 2800 | if (copy_to_user(priv_data->buf, addr->bytes, user_size)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2801 | hdd_err("failed to copy data to user buffer"); |
Dustin Brown | ee22071 | 2018-04-19 16:24:23 -0700 | [diff] [blame] | 2802 | return -EFAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2803 | } |
| 2804 | |
Dustin Brown | ee22071 | 2018-04-19 16:24:23 -0700 | [diff] [blame] | 2805 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2806 | } |
| 2807 | |
| 2808 | /** |
| 2809 | * drv_cmd_p2p_set_noa() - Handler for P2P_SET_NOA driver command |
| 2810 | * @adapter: Adapter on which the command was received |
| 2811 | * @hdd_ctx: HDD global context |
| 2812 | * @command: Entire driver command received from userspace |
| 2813 | * @command_len: Length of @command |
| 2814 | * @priv_data: Pointer to ioctl private data structure |
| 2815 | * |
Jeff Johnson | 78073fa | 2018-05-06 16:08:58 -0700 | [diff] [blame] | 2816 | * This is a trivial command handler function which simply forwards the |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2817 | * command to the actual command processor within the P2P module. |
| 2818 | * |
| 2819 | * Return: 0 on success, non-zero on failure |
| 2820 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 2821 | static int drv_cmd_p2p_set_noa(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 2822 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2823 | uint8_t *command, |
| 2824 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 2825 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2826 | { |
| 2827 | return hdd_set_p2p_noa(adapter->dev, command); |
| 2828 | } |
| 2829 | |
| 2830 | /** |
| 2831 | * drv_cmd_p2p_set_ps() - Handler for P2P_SET_PS driver command |
| 2832 | * @adapter: Adapter on which the command was received |
| 2833 | * @hdd_ctx: HDD global context |
| 2834 | * @command: Entire driver command received from userspace |
| 2835 | * @command_len: Length of @command |
| 2836 | * @priv_data: Pointer to ioctl private data structure |
| 2837 | * |
Jeff Johnson | 78073fa | 2018-05-06 16:08:58 -0700 | [diff] [blame] | 2838 | * This is a trivial command handler function which simply forwards the |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2839 | * command to the actual command processor within the P2P module. |
| 2840 | * |
| 2841 | * Return: 0 on success, non-zero on failure |
| 2842 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 2843 | static int drv_cmd_p2p_set_ps(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 2844 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2845 | uint8_t *command, |
| 2846 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 2847 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2848 | { |
| 2849 | return hdd_set_p2p_opps(adapter->dev, command); |
| 2850 | } |
| 2851 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 2852 | static int drv_cmd_set_band(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 2853 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2854 | uint8_t *command, |
| 2855 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 2856 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2857 | { |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 2858 | int err; |
| 2859 | uint8_t band; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2860 | |
| 2861 | /* |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 2862 | * Parse the band value passed from userspace. The first 8 bytes |
| 2863 | * should be "SETBAND " and the 9th byte should be a UI band value |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2864 | */ |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 2865 | err = kstrtou8(command + command_len + 1, 10, &band); |
| 2866 | if (err) { |
| 2867 | hdd_err("error %d parsing userspace band parameter", err); |
| 2868 | return err; |
| 2869 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2870 | |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 2871 | return hdd_reg_set_band(adapter->dev, band); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2872 | } |
| 2873 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 2874 | static int drv_cmd_set_wmmps(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 2875 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2876 | uint8_t *command, |
| 2877 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 2878 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2879 | { |
| 2880 | return hdd_wmmps_helper(adapter, command); |
| 2881 | } |
| 2882 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 2883 | static inline int drv_cmd_country(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 2884 | struct hdd_context *hdd_ctx, |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 2885 | uint8_t *command, |
| 2886 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 2887 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2888 | { |
Sourav Mohapatra | a30c457 | 2018-05-22 11:18:39 +0530 | [diff] [blame] | 2889 | char *country_code; |
| 2890 | |
| 2891 | country_code = strnchr(command, strlen(command), ' '); |
| 2892 | /* no argument after the command */ |
| 2893 | if (!country_code) |
| 2894 | return -EINVAL; |
| 2895 | |
| 2896 | /* no space after the command */ |
| 2897 | if (*country_code != SPACE_ASCII_VALUE) |
| 2898 | return -EINVAL; |
| 2899 | |
| 2900 | country_code++; |
| 2901 | |
| 2902 | /* removing empty spaces */ |
| 2903 | while ((*country_code == SPACE_ASCII_VALUE) && |
| 2904 | (*country_code != '\0')) |
| 2905 | country_code++; |
| 2906 | |
| 2907 | /* no or less than 2 arguments followed by spaces */ |
| 2908 | if (*country_code == '\0' || *(country_code + 1) == '\0') |
| 2909 | return -EINVAL; |
| 2910 | |
| 2911 | return hdd_reg_set_country(hdd_ctx, country_code); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2912 | } |
| 2913 | |
Rajeev Kumar Sirasanagandla | 32ae804 | 2019-03-25 16:37:02 +0530 | [diff] [blame] | 2914 | /** |
| 2915 | * drv_cmd_get_country() - Helper function to get current county code |
| 2916 | * @adapter: pointer to adapter on which request is received |
| 2917 | * @hdd_ctx: pointer to hdd context |
| 2918 | * @command: command name |
| 2919 | * @command_len: command buffer length |
| 2920 | * @priv_data: output pointer to hold current country code |
| 2921 | * |
| 2922 | * Return: On success 0, negative value on error. |
| 2923 | */ |
| 2924 | static int drv_cmd_get_country(struct hdd_adapter *adapter, |
| 2925 | struct hdd_context *hdd_ctx, |
| 2926 | uint8_t *command, uint8_t command_len, |
| 2927 | struct hdd_priv_data *priv_data) |
| 2928 | { |
| 2929 | uint8_t buf[SIZE_OF_GETCOUNTRYREV_OUTPUT] = {0}; |
| 2930 | uint8_t cc[REG_ALPHA2_LEN + 1]; |
| 2931 | int ret = 0, len; |
| 2932 | |
| 2933 | qdf_mem_copy(cc, hdd_ctx->reg.alpha2, REG_ALPHA2_LEN); |
| 2934 | cc[REG_ALPHA2_LEN] = '\0'; |
| 2935 | |
| 2936 | len = scnprintf(buf, sizeof(buf), "%s %s", |
| 2937 | "GETCOUNTRYREV", cc); |
| 2938 | hdd_debug("buf = %s", buf); |
| 2939 | len = QDF_MIN(priv_data->total_len, len + 1); |
| 2940 | if (copy_to_user(priv_data->buf, buf, len)) { |
| 2941 | hdd_err("failed to copy data to user buffer"); |
| 2942 | ret = -EFAULT; |
| 2943 | } |
| 2944 | |
| 2945 | return ret; |
| 2946 | } |
| 2947 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 2948 | static int drv_cmd_set_roam_trigger(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 2949 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2950 | uint8_t *command, |
| 2951 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 2952 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2953 | { |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2954 | int ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2955 | uint8_t *value = command; |
| 2956 | int8_t rssi = 0; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 2957 | uint8_t lookup_threshold = cfg_default( |
| 2958 | CFG_LFR_NEIGHBOR_LOOKUP_RSSI_THRESHOLD); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2959 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2960 | |
| 2961 | /* Move pointer to ahead of SETROAMTRIGGER<delimiter> */ |
| 2962 | value = value + command_len + 1; |
| 2963 | |
| 2964 | /* Convert the value from ascii to integer */ |
| 2965 | ret = kstrtos8(value, 10, &rssi); |
| 2966 | if (ret < 0) { |
| 2967 | /* |
| 2968 | * If the input value is greater than max value of datatype, |
| 2969 | * then also kstrtou8 fails |
| 2970 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2971 | hdd_err("kstrtou8 failed Input value may be out of range[%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 2972 | cfg_min(CFG_LFR_NEIGHBOR_LOOKUP_RSSI_THRESHOLD), |
| 2973 | cfg_max(CFG_LFR_NEIGHBOR_LOOKUP_RSSI_THRESHOLD)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2974 | ret = -EINVAL; |
| 2975 | goto exit; |
| 2976 | } |
| 2977 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 2978 | lookup_threshold = abs(rssi); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2979 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 2980 | if (!cfg_in_range(CFG_LFR_NEIGHBOR_LOOKUP_RSSI_THRESHOLD, |
| 2981 | lookup_threshold)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2982 | hdd_err("Neighbor lookup threshold value %d is out of range (Min: %d Max: %d)", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 2983 | lookup_threshold, |
| 2984 | cfg_min(CFG_LFR_NEIGHBOR_LOOKUP_RSSI_THRESHOLD), |
| 2985 | cfg_max(CFG_LFR_NEIGHBOR_LOOKUP_RSSI_THRESHOLD)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2986 | ret = -EINVAL; |
| 2987 | goto exit; |
| 2988 | } |
| 2989 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 2990 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 2991 | TRACE_CODE_HDD_SETROAMTRIGGER_IOCTL, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 2992 | adapter->vdev_id, lookup_threshold); |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 2993 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 2994 | hdd_debug("Received Command to Set Roam trigger (Neighbor lookup threshold) = %d", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 2995 | lookup_threshold); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2996 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2997 | status = sme_set_neighbor_lookup_rssi_threshold(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 2998 | adapter->vdev_id, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 2999 | lookup_threshold); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3000 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3001 | hdd_err("Failed to set roam trigger, try again"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3002 | ret = -EPERM; |
| 3003 | goto exit; |
| 3004 | } |
| 3005 | |
| 3006 | exit: |
| 3007 | return ret; |
| 3008 | } |
| 3009 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3010 | static int drv_cmd_get_roam_trigger(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3011 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3012 | uint8_t *command, |
| 3013 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3014 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3015 | { |
| 3016 | int ret = 0; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3017 | uint8_t lookup_threshold = |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3018 | sme_get_neighbor_lookup_rssi_threshold(hdd_ctx->mac_handle); |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3019 | int rssi = (-1) * lookup_threshold; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3020 | char extra[32]; |
| 3021 | uint8_t len = 0; |
| 3022 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3023 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 3024 | TRACE_CODE_HDD_GETROAMTRIGGER_IOCTL, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3025 | adapter->vdev_id, lookup_threshold); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3026 | |
| 3027 | len = scnprintf(extra, sizeof(extra), "%s %d", command, rssi); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3028 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3029 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3030 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3031 | ret = -EFAULT; |
| 3032 | } |
| 3033 | |
| 3034 | return ret; |
| 3035 | } |
| 3036 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3037 | static int drv_cmd_set_roam_scan_period(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3038 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3039 | uint8_t *command, |
| 3040 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3041 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3042 | { |
| 3043 | int ret = 0; |
| 3044 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3045 | uint8_t roam_scan_period = 0; |
| 3046 | uint16_t empty_scan_refresh_period = |
| 3047 | cfg_default(CFG_LFR_EMPTY_SCAN_REFRESH_PERIOD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3048 | |
| 3049 | /* input refresh period is in terms of seconds */ |
| 3050 | |
| 3051 | /* Move pointer to ahead of SETROAMSCANPERIOD<delimiter> */ |
| 3052 | value = value + command_len + 1; |
| 3053 | |
| 3054 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3055 | ret = kstrtou8(value, 10, &roam_scan_period); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3056 | if (ret < 0) { |
| 3057 | /* |
| 3058 | * If the input value is greater than max value of datatype, |
| 3059 | * then also kstrtou8 fails |
| 3060 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3061 | hdd_err("kstrtou8 failed Input value may be out of range[%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3062 | (cfg_min(CFG_LFR_EMPTY_SCAN_REFRESH_PERIOD) / 1000), |
| 3063 | (cfg_max(CFG_LFR_EMPTY_SCAN_REFRESH_PERIOD) / 1000)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3064 | ret = -EINVAL; |
| 3065 | goto exit; |
| 3066 | } |
| 3067 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3068 | if (!cfg_in_range(CFG_LFR_EMPTY_SCAN_REFRESH_PERIOD, |
| 3069 | roam_scan_period)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3070 | hdd_err("Roam scan period value %d is out of range (Min: %d Max: %d)", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3071 | roam_scan_period, |
| 3072 | (cfg_min(CFG_LFR_EMPTY_SCAN_REFRESH_PERIOD) / 1000), |
| 3073 | (cfg_max(CFG_LFR_EMPTY_SCAN_REFRESH_PERIOD) / 1000)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3074 | ret = -EINVAL; |
| 3075 | goto exit; |
| 3076 | } |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3077 | |
| 3078 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 3079 | TRACE_CODE_HDD_SETROAMSCANPERIOD_IOCTL, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3080 | adapter->vdev_id, roam_scan_period); |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3081 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3082 | empty_scan_refresh_period = roam_scan_period * 1000; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3083 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 3084 | hdd_debug("Received Command to Set roam scan period (Empty Scan refresh period) = %d", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3085 | roam_scan_period); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3086 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3087 | sme_update_empty_scan_refresh_period(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3088 | adapter->vdev_id, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3089 | empty_scan_refresh_period); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3090 | |
| 3091 | exit: |
| 3092 | return ret; |
| 3093 | } |
| 3094 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3095 | static int drv_cmd_get_roam_scan_period(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3096 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3097 | uint8_t *command, |
| 3098 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3099 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3100 | { |
| 3101 | int ret = 0; |
Jeff Johnson | 9625945 | 2019-02-26 20:38:17 -0800 | [diff] [blame] | 3102 | uint16_t empty_scan_refresh_period = |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3103 | sme_get_empty_scan_refresh_period(hdd_ctx->mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3104 | char extra[32]; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3105 | uint8_t len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3106 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3107 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 3108 | TRACE_CODE_HDD_GETROAMSCANPERIOD_IOCTL, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3109 | adapter->vdev_id, |
Jeff Johnson | 9625945 | 2019-02-26 20:38:17 -0800 | [diff] [blame] | 3110 | empty_scan_refresh_period); |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3111 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3112 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3113 | "GETROAMSCANPERIOD", |
Jeff Johnson | 9625945 | 2019-02-26 20:38:17 -0800 | [diff] [blame] | 3114 | (empty_scan_refresh_period / 1000)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3115 | /* Returned value is in units of seconds */ |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3116 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3117 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3118 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3119 | ret = -EFAULT; |
| 3120 | } |
| 3121 | |
| 3122 | return ret; |
| 3123 | } |
| 3124 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3125 | static int drv_cmd_set_roam_scan_refresh_period(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3126 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3127 | uint8_t *command, |
| 3128 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3129 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3130 | { |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3131 | int ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3132 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3133 | uint8_t roam_scan_refresh_period = 0; |
| 3134 | uint16_t neighbor_scan_refresh_period = |
| 3135 | cfg_default(CFG_LFR_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3136 | |
| 3137 | /* input refresh period is in terms of seconds */ |
| 3138 | /* Move pointer to ahead of SETROAMSCANREFRESHPERIOD<delimiter> */ |
| 3139 | value = value + command_len + 1; |
| 3140 | |
| 3141 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3142 | ret = kstrtou8(value, 10, &roam_scan_refresh_period); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3143 | if (ret < 0) { |
| 3144 | /* |
| 3145 | * If the input value is greater than max value of datatype, |
| 3146 | * then also kstrtou8 fails |
| 3147 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3148 | hdd_err("kstrtou8 failed Input value may be out of range[%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3149 | (cfg_min(CFG_LFR_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD) |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3150 | / 1000), |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3151 | (cfg_max(CFG_LFR_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD) |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3152 | / 1000)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3153 | ret = -EINVAL; |
| 3154 | goto exit; |
| 3155 | } |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3156 | |
| 3157 | if (!cfg_in_range(CFG_LFR_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD, |
| 3158 | roam_scan_refresh_period)) { |
| 3159 | hdd_err("Neighbor scan results refresh period value %d is out of range (Min: %d Max: %d)", |
| 3160 | roam_scan_refresh_period, |
| 3161 | (cfg_min(CFG_LFR_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD) |
| 3162 | / 1000), |
| 3163 | (cfg_max(CFG_LFR_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD) |
| 3164 | / 1000)); |
| 3165 | ret = -EINVAL; |
| 3166 | goto exit; |
| 3167 | } |
| 3168 | neighbor_scan_refresh_period = roam_scan_refresh_period * 1000; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3169 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 3170 | hdd_debug("Received Command to Set roam scan refresh period (Scan refresh period) = %d", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3171 | neighbor_scan_refresh_period); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3172 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3173 | sme_set_neighbor_scan_refresh_period(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3174 | adapter->vdev_id, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3175 | neighbor_scan_refresh_period); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3176 | |
| 3177 | exit: |
| 3178 | return ret; |
| 3179 | } |
| 3180 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3181 | static int drv_cmd_get_roam_scan_refresh_period(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3182 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3183 | uint8_t *command, |
| 3184 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3185 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3186 | { |
| 3187 | int ret = 0; |
| 3188 | uint16_t value = |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3189 | sme_get_neighbor_scan_refresh_period(hdd_ctx->mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3190 | char extra[32]; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3191 | uint8_t len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3192 | |
| 3193 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3194 | "GETROAMSCANREFRESHPERIOD", |
| 3195 | (value / 1000)); |
| 3196 | /* Returned value is in units of seconds */ |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3197 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3198 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3199 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3200 | ret = -EFAULT; |
| 3201 | } |
| 3202 | |
| 3203 | return ret; |
| 3204 | } |
| 3205 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3206 | static int drv_cmd_set_roam_mode(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3207 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3208 | uint8_t *command, |
| 3209 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3210 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3211 | { |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3212 | mac_handle_t mac_handle; |
| 3213 | int ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3214 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3215 | uint8_t roam_mode = cfg_default(CFG_LFR_FEATURE_ENABLED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3216 | |
| 3217 | /* Move pointer to ahead of SETROAMMODE<delimiter> */ |
| 3218 | value = value + SIZE_OF_SETROAMMODE + 1; |
| 3219 | |
| 3220 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3221 | ret = kstrtou8(value, 10, &roam_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3222 | if (ret < 0) { |
| 3223 | /* |
| 3224 | * If the input value is greater than max value of datatype, |
| 3225 | * then also kstrtou8 fails |
| 3226 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3227 | hdd_err("kstrtou8 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3228 | cfg_min(CFG_LFR_FEATURE_ENABLED), |
| 3229 | cfg_max(CFG_LFR_FEATURE_ENABLED)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3230 | ret = -EINVAL; |
| 3231 | goto exit; |
| 3232 | } |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3233 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3234 | hdd_debug("Received Command to Set Roam Mode = %d", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3235 | roam_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3236 | /* |
| 3237 | * Note that |
| 3238 | * SETROAMMODE 0 is to enable LFR while |
| 3239 | * SETROAMMODE 1 is to disable LFR, but |
| 3240 | * notify_is_fast_roam_ini_feature_enabled 0/1 is to |
| 3241 | * enable/disable. So, we have to invert the value |
| 3242 | * to call sme_update_is_fast_roam_ini_feature_enabled. |
| 3243 | */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3244 | if (roam_mode) { |
| 3245 | /* Roam enable */ |
| 3246 | roam_mode = cfg_min(CFG_LFR_FEATURE_ENABLED); |
| 3247 | } else { |
| 3248 | /* Roam disable */ |
| 3249 | roam_mode = cfg_max(CFG_LFR_FEATURE_ENABLED); |
| 3250 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3251 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3252 | ucfg_mlme_set_lfr_enabled(hdd_ctx->psoc, (bool)roam_mode); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3253 | mac_handle = hdd_ctx->mac_handle; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3254 | if (roam_mode) { |
| 3255 | ucfg_mlme_set_roam_scan_offload_enabled(hdd_ctx->psoc, |
| 3256 | (bool)roam_mode); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3257 | sme_update_is_fast_roam_ini_feature_enabled(mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3258 | adapter->vdev_id, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3259 | roam_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3260 | } else { |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3261 | sme_update_is_fast_roam_ini_feature_enabled(mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3262 | adapter->vdev_id, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3263 | roam_mode); |
| 3264 | ucfg_mlme_set_roam_scan_offload_enabled(hdd_ctx->psoc, |
| 3265 | roam_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3266 | } |
| 3267 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3268 | exit: |
| 3269 | return ret; |
| 3270 | } |
| 3271 | |
Pragaspathi Thilagaraj | aa8320e | 2019-04-16 02:47:50 +0530 | [diff] [blame] | 3272 | static int drv_cmd_set_suspend_mode(struct hdd_adapter *adapter, |
| 3273 | struct hdd_context *hdd_ctx, |
| 3274 | uint8_t *command, |
| 3275 | uint8_t command_len, |
| 3276 | struct hdd_priv_data *priv_data) |
| 3277 | { |
| 3278 | int errno; |
| 3279 | uint8_t *value = command; |
| 3280 | QDF_STATUS status; |
| 3281 | uint8_t idle_monitor; |
| 3282 | |
| 3283 | if (QDF_STA_MODE != adapter->device_mode) { |
| 3284 | hdd_debug("Non-STA interface"); |
| 3285 | return 0; |
| 3286 | } |
| 3287 | |
| 3288 | /* Move pointer to ahead of SETSUSPENDMODE<delimiter> */ |
| 3289 | value = value + SIZE_OF_SETSUSPENDMODE + 1; |
| 3290 | |
| 3291 | /* Convert the value from ascii to integer */ |
| 3292 | errno = kstrtou8(value, 10, &idle_monitor); |
| 3293 | if (errno < 0) { |
| 3294 | /* |
| 3295 | * If the input value is greater than max value of datatype, |
| 3296 | * then also kstrtou8 fails |
| 3297 | */ |
| 3298 | hdd_err("Range validation failed"); |
| 3299 | return -EINVAL; |
| 3300 | } |
| 3301 | |
| 3302 | hdd_debug("idle_monitor:%d", idle_monitor); |
| 3303 | status = ucfg_pmo_tgt_psoc_send_idle_roam_suspend_mode(hdd_ctx->psoc, |
| 3304 | idle_monitor); |
| 3305 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3306 | hdd_debug("Send suspend mode to fw failed"); |
| 3307 | return -EINVAL; |
| 3308 | } |
| 3309 | return 0; |
| 3310 | } |
| 3311 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3312 | static int drv_cmd_get_roam_mode(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3313 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3314 | uint8_t *command, |
| 3315 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3316 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3317 | { |
| 3318 | int ret = 0; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3319 | bool roam_mode = sme_get_is_lfr_feature_enabled(hdd_ctx->mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3320 | char extra[32]; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3321 | uint8_t len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3322 | |
| 3323 | /* |
| 3324 | * roamMode value shall be inverted because the sementics is different. |
| 3325 | */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3326 | if (roam_mode) |
| 3327 | roam_mode = cfg_min(CFG_LFR_FEATURE_ENABLED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3328 | else |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3329 | roam_mode = cfg_max(CFG_LFR_FEATURE_ENABLED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3330 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3331 | len = scnprintf(extra, sizeof(extra), "%s %d", command, roam_mode); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3332 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3333 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3334 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3335 | ret = -EFAULT; |
| 3336 | } |
| 3337 | |
| 3338 | return ret; |
| 3339 | } |
| 3340 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3341 | static int drv_cmd_set_roam_delta(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3342 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3343 | uint8_t *command, |
| 3344 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3345 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3346 | { |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3347 | int ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3348 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3349 | uint8_t roam_rssi_diff = cfg_default(CFG_LFR_ROAM_RSSI_DIFF); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3350 | |
| 3351 | /* Move pointer to ahead of SETROAMDELTA<delimiter> */ |
| 3352 | value = value + command_len + 1; |
| 3353 | |
| 3354 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3355 | ret = kstrtou8(value, 10, &roam_rssi_diff); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3356 | if (ret < 0) { |
| 3357 | /* |
| 3358 | * If the input value is greater than max value of datatype, |
| 3359 | * then also kstrtou8 fails |
| 3360 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3361 | hdd_err("kstrtou8 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3362 | cfg_min(CFG_LFR_ROAM_RSSI_DIFF), |
| 3363 | cfg_max(CFG_LFR_ROAM_RSSI_DIFF)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3364 | ret = -EINVAL; |
| 3365 | goto exit; |
| 3366 | } |
| 3367 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3368 | if (!cfg_in_range(CFG_LFR_ROAM_RSSI_DIFF, roam_rssi_diff)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3369 | hdd_err("Roam rssi diff value %d is out of range (Min: %d Max: %d)", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3370 | roam_rssi_diff, |
| 3371 | cfg_min(CFG_LFR_ROAM_RSSI_DIFF), |
| 3372 | cfg_max(CFG_LFR_ROAM_RSSI_DIFF)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3373 | ret = -EINVAL; |
| 3374 | goto exit; |
| 3375 | } |
| 3376 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 3377 | hdd_debug("Received Command to Set roam rssi diff = %d", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3378 | roam_rssi_diff); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3379 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3380 | sme_update_roam_rssi_diff(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3381 | adapter->vdev_id, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3382 | roam_rssi_diff); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3383 | |
| 3384 | exit: |
| 3385 | return ret; |
| 3386 | } |
| 3387 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3388 | static int drv_cmd_get_roam_delta(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3389 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3390 | uint8_t *command, |
| 3391 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3392 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3393 | { |
| 3394 | int ret = 0; |
Jeff Johnson | 6500380 | 2019-02-26 20:50:49 -0800 | [diff] [blame] | 3395 | uint8_t rssi_diff = |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3396 | sme_get_roam_rssi_diff(hdd_ctx->mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3397 | char extra[32]; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3398 | uint8_t len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3399 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3400 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 3401 | TRACE_CODE_HDD_GETROAMDELTA_IOCTL, |
Jeff Johnson | 6500380 | 2019-02-26 20:50:49 -0800 | [diff] [blame] | 3402 | adapter->vdev_id, rssi_diff); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3403 | |
| 3404 | len = scnprintf(extra, sizeof(extra), "%s %d", |
Jeff Johnson | 6500380 | 2019-02-26 20:50:49 -0800 | [diff] [blame] | 3405 | command, rssi_diff); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3406 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3407 | |
| 3408 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3409 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3410 | ret = -EFAULT; |
| 3411 | } |
| 3412 | |
| 3413 | return ret; |
| 3414 | } |
| 3415 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3416 | static int drv_cmd_get_band(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3417 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3418 | uint8_t *command, |
| 3419 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3420 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3421 | { |
| 3422 | int ret = 0; |
| 3423 | int band = -1; |
| 3424 | char extra[32]; |
| 3425 | uint8_t len = 0; |
| 3426 | |
| 3427 | hdd_get_band_helper(hdd_ctx, &band); |
| 3428 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3429 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 3430 | TRACE_CODE_HDD_GETBAND_IOCTL, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3431 | adapter->vdev_id, band); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3432 | |
| 3433 | len = scnprintf(extra, sizeof(extra), "%s %d", command, band); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3434 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3435 | |
| 3436 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3437 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3438 | ret = -EFAULT; |
| 3439 | } |
| 3440 | |
| 3441 | return ret; |
| 3442 | } |
| 3443 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3444 | static int drv_cmd_set_roam_scan_channels(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3445 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3446 | uint8_t *command, |
| 3447 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3448 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3449 | { |
| 3450 | return hdd_parse_set_roam_scan_channels(adapter, command); |
| 3451 | } |
| 3452 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3453 | static int drv_cmd_get_roam_scan_channels(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3454 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3455 | uint8_t *command, |
| 3456 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3457 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3458 | { |
| 3459 | int ret = 0; |
Jeff Johnson | 8a2e1da | 2019-02-26 17:56:24 -0800 | [diff] [blame] | 3460 | uint8_t channel_list[CFG_VALID_CHANNEL_LIST_LEN] = { 0 }; |
| 3461 | uint8_t num_channels = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3462 | uint8_t j = 0; |
| 3463 | char extra[128] = { 0 }; |
| 3464 | int len; |
| 3465 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3466 | if (QDF_STATUS_SUCCESS != |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3467 | sme_get_roam_scan_channel_list(hdd_ctx->mac_handle, |
Jeff Johnson | 8a2e1da | 2019-02-26 17:56:24 -0800 | [diff] [blame] | 3468 | channel_list, |
| 3469 | &num_channels, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3470 | adapter->vdev_id)) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 3471 | hdd_err("failed to get roam scan channel list"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3472 | ret = -EFAULT; |
| 3473 | goto exit; |
| 3474 | } |
| 3475 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3476 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 3477 | TRACE_CODE_HDD_GETROAMSCANCHANNELS_IOCTL, |
Jeff Johnson | 8a2e1da | 2019-02-26 17:56:24 -0800 | [diff] [blame] | 3478 | adapter->vdev_id, num_channels); |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3479 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3480 | /* |
| 3481 | * output channel list is of the format |
| 3482 | * [Number of roam scan channels][Channel1][Channel2]... |
| 3483 | * copy the number of channels in the 0th index |
| 3484 | */ |
| 3485 | len = scnprintf(extra, sizeof(extra), "%s %d", command, |
Jeff Johnson | 8a2e1da | 2019-02-26 17:56:24 -0800 | [diff] [blame] | 3486 | num_channels); |
| 3487 | for (j = 0; (j < num_channels) && len <= sizeof(extra); j++) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3488 | len += scnprintf(extra + len, sizeof(extra) - len, |
Jeff Johnson | 8a2e1da | 2019-02-26 17:56:24 -0800 | [diff] [blame] | 3489 | " %d", channel_list[j]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3490 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3491 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3492 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3493 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3494 | ret = -EFAULT; |
| 3495 | goto exit; |
| 3496 | } |
| 3497 | |
| 3498 | exit: |
| 3499 | return ret; |
| 3500 | } |
| 3501 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3502 | static int drv_cmd_get_ccx_mode(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3503 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3504 | uint8_t *command, |
| 3505 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3506 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3507 | { |
| 3508 | int ret = 0; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3509 | mac_handle_t mac_handle = hdd_ctx->mac_handle; |
Jeff Johnson | 22345e1 | 2019-02-26 21:33:02 -0800 | [diff] [blame] | 3510 | bool ese_mode = sme_get_is_ese_feature_enabled(mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3511 | char extra[32]; |
| 3512 | uint8_t len = 0; |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 3513 | struct pmkid_mode_bits pmkid_modes; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3514 | |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 3515 | hdd_get_pmkid_modes(hdd_ctx, &pmkid_modes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3516 | /* |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 3517 | * Check if the features PMKID/ESE/11R are supported simultaneously, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3518 | * then this operation is not permitted (return FAILURE) |
| 3519 | */ |
Jeff Johnson | 22345e1 | 2019-02-26 21:33:02 -0800 | [diff] [blame] | 3520 | if (ese_mode && |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 3521 | (pmkid_modes.fw_okc || pmkid_modes.fw_pmksa_cache) && |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3522 | sme_get_is_ft_feature_enabled(mac_handle)) { |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 3523 | hdd_warn("PMKID/ESE/11R are supported simultaneously hence this operation is not permitted!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3524 | ret = -EPERM; |
| 3525 | goto exit; |
| 3526 | } |
| 3527 | |
| 3528 | len = scnprintf(extra, sizeof(extra), "%s %d", |
Jeff Johnson | 22345e1 | 2019-02-26 21:33:02 -0800 | [diff] [blame] | 3529 | "GETCCXMODE", ese_mode); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3530 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3531 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3532 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3533 | ret = -EFAULT; |
| 3534 | goto exit; |
| 3535 | } |
| 3536 | |
| 3537 | exit: |
| 3538 | return ret; |
| 3539 | } |
| 3540 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3541 | static int drv_cmd_get_okc_mode(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3542 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3543 | uint8_t *command, |
| 3544 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3545 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3546 | { |
| 3547 | int ret = 0; |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 3548 | struct pmkid_mode_bits pmkid_modes; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3549 | char extra[32]; |
| 3550 | uint8_t len = 0; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3551 | mac_handle_t mac_handle = hdd_ctx->mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3552 | |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 3553 | hdd_get_pmkid_modes(hdd_ctx, &pmkid_modes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3554 | /* |
| 3555 | * Check if the features OKC/ESE/11R are supported simultaneously, |
| 3556 | * then this operation is not permitted (return FAILURE) |
| 3557 | */ |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 3558 | if (pmkid_modes.fw_okc && |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3559 | sme_get_is_ese_feature_enabled(mac_handle) && |
| 3560 | sme_get_is_ft_feature_enabled(mac_handle)) { |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 3561 | hdd_warn("PMKID/ESE/11R are supported simultaneously hence this operation is not permitted!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3562 | ret = -EPERM; |
| 3563 | goto exit; |
| 3564 | } |
| 3565 | |
| 3566 | len = scnprintf(extra, sizeof(extra), "%s %d", |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 3567 | "GETOKCMODE", pmkid_modes.fw_okc); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3568 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3569 | |
| 3570 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3571 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3572 | ret = -EFAULT; |
| 3573 | goto exit; |
| 3574 | } |
| 3575 | |
| 3576 | exit: |
| 3577 | return ret; |
| 3578 | } |
| 3579 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3580 | static int drv_cmd_get_fast_roam(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3581 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3582 | uint8_t *command, |
| 3583 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3584 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3585 | { |
| 3586 | int ret = 0; |
Jeff Johnson | 22345e1 | 2019-02-26 21:33:02 -0800 | [diff] [blame] | 3587 | bool lfr_mode = sme_get_is_lfr_feature_enabled(hdd_ctx->mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3588 | char extra[32]; |
| 3589 | uint8_t len = 0; |
| 3590 | |
| 3591 | len = scnprintf(extra, sizeof(extra), "%s %d", |
Jeff Johnson | 22345e1 | 2019-02-26 21:33:02 -0800 | [diff] [blame] | 3592 | "GETFASTROAM", lfr_mode); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3593 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3594 | |
| 3595 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3596 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3597 | ret = -EFAULT; |
| 3598 | } |
| 3599 | |
| 3600 | return ret; |
| 3601 | } |
| 3602 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3603 | static int drv_cmd_get_fast_transition(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3604 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3605 | uint8_t *command, |
| 3606 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3607 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3608 | { |
| 3609 | int ret = 0; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3610 | bool ft = sme_get_is_ft_feature_enabled(hdd_ctx->mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3611 | char extra[32]; |
| 3612 | uint8_t len = 0; |
| 3613 | |
| 3614 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3615 | "GETFASTTRANSITION", ft); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3616 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3617 | |
| 3618 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3619 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3620 | ret = -EFAULT; |
| 3621 | } |
| 3622 | |
| 3623 | return ret; |
| 3624 | } |
| 3625 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3626 | static int drv_cmd_set_roam_scan_channel_min_time(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3627 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3628 | uint8_t *command, |
| 3629 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3630 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3631 | { |
| 3632 | int ret = 0; |
| 3633 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3634 | uint8_t min_time = cfg_default(CFG_LFR_NEIGHBOR_SCAN_MIN_CHAN_TIME); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3635 | |
| 3636 | /* Move pointer to ahead of SETROAMSCANCHANNELMINTIME<delimiter> */ |
| 3637 | value = value + command_len + 1; |
| 3638 | |
| 3639 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3640 | ret = kstrtou8(value, 10, &min_time); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3641 | if (ret < 0) { |
| 3642 | /* |
| 3643 | * If the input value is greater than max value of datatype, |
| 3644 | * then also kstrtou8 fails |
| 3645 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3646 | hdd_err("kstrtou8 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3647 | cfg_min(CFG_LFR_NEIGHBOR_SCAN_MIN_CHAN_TIME), |
| 3648 | cfg_max(CFG_LFR_NEIGHBOR_SCAN_MIN_CHAN_TIME)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3649 | ret = -EINVAL; |
| 3650 | goto exit; |
| 3651 | } |
| 3652 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3653 | if (!cfg_in_range(CFG_LFR_NEIGHBOR_SCAN_MIN_CHAN_TIME, min_time)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3654 | hdd_err("scan min channel time value %d is out of range (Min: %d Max: %d)", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3655 | min_time, |
| 3656 | cfg_min(CFG_LFR_NEIGHBOR_SCAN_MIN_CHAN_TIME), |
| 3657 | cfg_max(CFG_LFR_NEIGHBOR_SCAN_MIN_CHAN_TIME)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3658 | ret = -EINVAL; |
| 3659 | goto exit; |
| 3660 | } |
| 3661 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3662 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 3663 | TRACE_CODE_HDD_SETROAMSCANCHANNELMINTIME_IOCTL, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3664 | adapter->vdev_id, min_time); |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3665 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 3666 | hdd_debug("Received Command to change channel min time = %d", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3667 | min_time); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3668 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3669 | sme_set_neighbor_scan_min_chan_time(hdd_ctx->mac_handle, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3670 | min_time, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3671 | adapter->vdev_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3672 | |
| 3673 | exit: |
| 3674 | return ret; |
| 3675 | } |
| 3676 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3677 | static int drv_cmd_send_action_frame(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3678 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3679 | uint8_t *command, |
| 3680 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3681 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3682 | { |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 3683 | return hdd_parse_sendactionframe(adapter, command, |
| 3684 | priv_data->total_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3685 | } |
| 3686 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3687 | static int drv_cmd_get_roam_scan_channel_min_time(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3688 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3689 | uint8_t *command, |
| 3690 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3691 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3692 | { |
| 3693 | int ret = 0; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3694 | uint16_t val = sme_get_neighbor_scan_min_chan_time(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3695 | adapter->vdev_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3696 | char extra[32]; |
| 3697 | uint8_t len = 0; |
| 3698 | |
| 3699 | /* value is interms of msec */ |
| 3700 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3701 | "GETROAMSCANCHANNELMINTIME", val); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3702 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3703 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3704 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 3705 | TRACE_CODE_HDD_GETROAMSCANCHANNELMINTIME_IOCTL, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3706 | adapter->vdev_id, val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3707 | |
| 3708 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3709 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3710 | ret = -EFAULT; |
| 3711 | } |
| 3712 | |
| 3713 | return ret; |
| 3714 | } |
| 3715 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3716 | static int drv_cmd_set_scan_channel_time(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3717 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3718 | uint8_t *command, |
| 3719 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3720 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3721 | { |
| 3722 | int ret = 0; |
| 3723 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3724 | uint16_t max_time = cfg_default(CFG_LFR_NEIGHBOR_SCAN_MAX_CHAN_TIME); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3725 | |
| 3726 | /* Move pointer to ahead of SETSCANCHANNELTIME<delimiter> */ |
| 3727 | value = value + command_len + 1; |
| 3728 | |
| 3729 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3730 | ret = kstrtou16(value, 10, &max_time); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3731 | if (ret < 0) { |
| 3732 | /* |
| 3733 | * If the input value is greater than max value of datatype, |
| 3734 | * then also kstrtou8 fails |
| 3735 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3736 | hdd_err("kstrtou16 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3737 | cfg_min(CFG_LFR_NEIGHBOR_SCAN_MAX_CHAN_TIME), |
| 3738 | cfg_max(CFG_LFR_NEIGHBOR_SCAN_MAX_CHAN_TIME)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3739 | ret = -EINVAL; |
| 3740 | goto exit; |
| 3741 | } |
| 3742 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3743 | if (!cfg_in_range(CFG_LFR_NEIGHBOR_SCAN_MAX_CHAN_TIME, max_time)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3744 | hdd_err("lfr mode value %d is out of range (Min: %d Max: %d)", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3745 | max_time, |
| 3746 | cfg_min(CFG_LFR_NEIGHBOR_SCAN_MAX_CHAN_TIME), |
| 3747 | cfg_max(CFG_LFR_NEIGHBOR_SCAN_MAX_CHAN_TIME)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3748 | ret = -EINVAL; |
| 3749 | goto exit; |
| 3750 | } |
| 3751 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 3752 | hdd_debug("Received Command to change channel max time = %d", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3753 | max_time); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3754 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3755 | sme_set_neighbor_scan_max_chan_time(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3756 | adapter->vdev_id, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3757 | max_time); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3758 | |
| 3759 | exit: |
| 3760 | return ret; |
| 3761 | } |
| 3762 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3763 | static int drv_cmd_get_scan_channel_time(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3764 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3765 | uint8_t *command, |
| 3766 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3767 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3768 | { |
| 3769 | int ret = 0; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3770 | uint16_t val = sme_get_neighbor_scan_max_chan_time(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3771 | adapter->vdev_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3772 | char extra[32]; |
| 3773 | uint8_t len = 0; |
| 3774 | |
| 3775 | /* value is interms of msec */ |
| 3776 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3777 | "GETSCANCHANNELTIME", val); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3778 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3779 | |
| 3780 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3781 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3782 | ret = -EFAULT; |
| 3783 | } |
| 3784 | |
| 3785 | return ret; |
| 3786 | } |
| 3787 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3788 | static int drv_cmd_set_scan_home_time(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3789 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3790 | uint8_t *command, |
| 3791 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3792 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3793 | { |
| 3794 | int ret = 0; |
| 3795 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3796 | uint16_t val = cfg_default(CFG_LFR_NEIGHBOR_SCAN_TIMER_PERIOD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3797 | |
| 3798 | /* Move pointer to ahead of SETSCANHOMETIME<delimiter> */ |
| 3799 | value = value + command_len + 1; |
| 3800 | |
| 3801 | /* Convert the value from ascii to integer */ |
| 3802 | ret = kstrtou16(value, 10, &val); |
| 3803 | if (ret < 0) { |
| 3804 | /* |
| 3805 | * If the input value is greater than max value of datatype, |
| 3806 | * then also kstrtou8 fails |
| 3807 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3808 | hdd_err("kstrtou16 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3809 | cfg_min(CFG_LFR_NEIGHBOR_SCAN_TIMER_PERIOD), |
| 3810 | cfg_max(CFG_LFR_NEIGHBOR_SCAN_TIMER_PERIOD)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3811 | ret = -EINVAL; |
| 3812 | goto exit; |
| 3813 | } |
| 3814 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3815 | if (!cfg_in_range(CFG_LFR_NEIGHBOR_SCAN_TIMER_PERIOD, val)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3816 | hdd_err("scan home time value %d is out of range (Min: %d Max: %d)", |
| 3817 | val, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3818 | cfg_min(CFG_LFR_NEIGHBOR_SCAN_TIMER_PERIOD), |
| 3819 | cfg_max(CFG_LFR_NEIGHBOR_SCAN_TIMER_PERIOD)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3820 | ret = -EINVAL; |
| 3821 | goto exit; |
| 3822 | } |
| 3823 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 3824 | hdd_debug("Received Command to change scan home time = %d", |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3825 | val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3826 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3827 | sme_set_neighbor_scan_period(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3828 | adapter->vdev_id, val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3829 | |
| 3830 | exit: |
| 3831 | return ret; |
| 3832 | } |
| 3833 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3834 | static int drv_cmd_get_scan_home_time(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3835 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3836 | uint8_t *command, |
| 3837 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3838 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3839 | { |
| 3840 | int ret = 0; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3841 | uint16_t val = sme_get_neighbor_scan_period(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3842 | adapter->vdev_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3843 | char extra[32]; |
| 3844 | uint8_t len = 0; |
| 3845 | |
| 3846 | /* value is interms of msec */ |
| 3847 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3848 | "GETSCANHOMETIME", val); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3849 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3850 | |
| 3851 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3852 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3853 | ret = -EFAULT; |
| 3854 | } |
| 3855 | |
| 3856 | return ret; |
| 3857 | } |
| 3858 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3859 | static int drv_cmd_set_roam_intra_band(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3860 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3861 | uint8_t *command, |
| 3862 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3863 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3864 | { |
| 3865 | int ret = 0; |
| 3866 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3867 | uint8_t val = cfg_default(CFG_LFR_ROAM_INTRA_BAND); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3868 | |
| 3869 | /* Move pointer to ahead of SETROAMINTRABAND<delimiter> */ |
| 3870 | value = value + command_len + 1; |
| 3871 | |
| 3872 | /* Convert the value from ascii to integer */ |
| 3873 | ret = kstrtou8(value, 10, &val); |
| 3874 | if (ret < 0) { |
| 3875 | /* |
| 3876 | * If the input value is greater than max value of datatype, |
| 3877 | * then also kstrtou8 fails |
| 3878 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3879 | hdd_err("kstrtou8 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3880 | cfg_min(CFG_LFR_ROAM_INTRA_BAND), |
| 3881 | cfg_max(CFG_LFR_ROAM_INTRA_BAND)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3882 | ret = -EINVAL; |
| 3883 | goto exit; |
| 3884 | } |
| 3885 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 3886 | hdd_debug("Received Command to change intra band = %d", |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3887 | val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3888 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3889 | ucfg_mlme_set_roam_intra_band(hdd_ctx->psoc, (bool)val); |
Jianmin Zhu | 0b505a6 | 2019-04-30 16:22:49 +0800 | [diff] [blame] | 3890 | policy_mgr_set_pcl_for_existing_combo( |
| 3891 | hdd_ctx->psoc, |
| 3892 | PM_STA_MODE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3893 | |
| 3894 | exit: |
| 3895 | return ret; |
| 3896 | } |
| 3897 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3898 | static int drv_cmd_get_roam_intra_band(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3899 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3900 | uint8_t *command, |
| 3901 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3902 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3903 | { |
| 3904 | int ret = 0; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3905 | uint16_t val = sme_get_roam_intra_band(hdd_ctx->mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3906 | char extra[32]; |
| 3907 | uint8_t len = 0; |
| 3908 | |
| 3909 | /* value is interms of msec */ |
| 3910 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3911 | "GETROAMINTRABAND", val); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3912 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3913 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3914 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3915 | ret = -EFAULT; |
| 3916 | } |
| 3917 | |
| 3918 | return ret; |
| 3919 | } |
| 3920 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3921 | static int drv_cmd_set_scan_n_probes(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3922 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3923 | uint8_t *command, |
| 3924 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3925 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3926 | { |
| 3927 | int ret = 0; |
| 3928 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3929 | uint8_t nprobes = cfg_default(CFG_LFR_ROAM_SCAN_N_PROBES); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3930 | |
| 3931 | /* Move pointer to ahead of SETSCANNPROBES<delimiter> */ |
| 3932 | value = value + command_len + 1; |
| 3933 | |
| 3934 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3935 | ret = kstrtou8(value, 10, &nprobes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3936 | if (ret < 0) { |
| 3937 | /* |
| 3938 | * If the input value is greater than max value of datatype, |
| 3939 | * then also kstrtou8 fails |
| 3940 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3941 | hdd_err("kstrtou8 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3942 | cfg_min(CFG_LFR_ROAM_SCAN_N_PROBES), |
| 3943 | cfg_max(CFG_LFR_ROAM_SCAN_N_PROBES)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3944 | ret = -EINVAL; |
| 3945 | goto exit; |
| 3946 | } |
| 3947 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3948 | if (!cfg_in_range(CFG_LFR_ROAM_SCAN_N_PROBES, nprobes)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3949 | hdd_err("NProbes value %d is out of range (Min: %d Max: %d)", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3950 | nprobes, |
| 3951 | cfg_min(CFG_LFR_ROAM_SCAN_N_PROBES), |
| 3952 | cfg_max(CFG_LFR_ROAM_SCAN_N_PROBES)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3953 | ret = -EINVAL; |
| 3954 | goto exit; |
| 3955 | } |
| 3956 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 3957 | hdd_debug("Received Command to Set nProbes = %d", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3958 | nprobes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3959 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3960 | sme_update_roam_scan_n_probes(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3961 | adapter->vdev_id, nprobes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3962 | |
| 3963 | exit: |
| 3964 | return ret; |
| 3965 | } |
| 3966 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3967 | static int drv_cmd_get_scan_n_probes(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3968 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3969 | uint8_t *command, |
| 3970 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3971 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3972 | { |
| 3973 | int ret = 0; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3974 | uint8_t val = sme_get_roam_scan_n_probes(hdd_ctx->mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3975 | char extra[32]; |
| 3976 | uint8_t len = 0; |
| 3977 | |
| 3978 | len = scnprintf(extra, sizeof(extra), "%s %d", command, val); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3979 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3980 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3981 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3982 | ret = -EFAULT; |
| 3983 | } |
| 3984 | |
| 3985 | return ret; |
| 3986 | } |
| 3987 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3988 | static int drv_cmd_set_scan_home_away_time(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3989 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3990 | uint8_t *command, |
| 3991 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3992 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3993 | { |
| 3994 | int ret = 0; |
| 3995 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3996 | uint16_t home_away_time = cfg_default(CFG_LFR_ROAM_SCAN_HOME_AWAY_TIME); |
| 3997 | uint16_t current_home_away_time; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3998 | |
| 3999 | /* input value is in units of msec */ |
| 4000 | |
| 4001 | /* Move pointer to ahead of SETSCANHOMEAWAYTIME<delimiter> */ |
| 4002 | value = value + command_len + 1; |
| 4003 | |
| 4004 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4005 | ret = kstrtou16(value, 10, &home_away_time); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4006 | if (ret < 0) { |
| 4007 | /* |
| 4008 | * If the input value is greater than max value of datatype, |
| 4009 | * then also kstrtou8 fails |
| 4010 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4011 | hdd_err("kstrtou8 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4012 | cfg_min(CFG_LFR_ROAM_SCAN_HOME_AWAY_TIME), |
| 4013 | cfg_max(CFG_LFR_ROAM_SCAN_HOME_AWAY_TIME)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4014 | ret = -EINVAL; |
| 4015 | goto exit; |
| 4016 | } |
| 4017 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4018 | if (!cfg_in_range(CFG_LFR_ROAM_SCAN_HOME_AWAY_TIME, home_away_time)) { |
| 4019 | hdd_err("home_away_time value %d is out of range (min: %d max: %d)", |
| 4020 | home_away_time, |
| 4021 | cfg_min(CFG_LFR_ROAM_SCAN_HOME_AWAY_TIME), |
| 4022 | cfg_max(CFG_LFR_ROAM_SCAN_HOME_AWAY_TIME)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4023 | ret = -EINVAL; |
| 4024 | goto exit; |
| 4025 | } |
| 4026 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4027 | hdd_debug("Received Command to Set scan away time = %d", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4028 | home_away_time); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4029 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4030 | ucfg_mlme_get_home_away_time(hdd_ctx->psoc, ¤t_home_away_time); |
| 4031 | if (current_home_away_time != home_away_time) { |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4032 | sme_update_roam_scan_home_away_time(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4033 | adapter->vdev_id, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4034 | home_away_time, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4035 | true); |
| 4036 | } |
| 4037 | |
| 4038 | exit: |
| 4039 | return ret; |
| 4040 | } |
| 4041 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4042 | static int drv_cmd_get_scan_home_away_time(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4043 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4044 | uint8_t *command, |
| 4045 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4046 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4047 | { |
| 4048 | int ret = 0; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4049 | uint16_t val = sme_get_roam_scan_home_away_time(hdd_ctx->mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4050 | char extra[32]; |
| 4051 | uint8_t len = 0; |
| 4052 | |
| 4053 | len = scnprintf(extra, sizeof(extra), "%s %d", command, val); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4054 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4055 | |
| 4056 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4057 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4058 | ret = -EFAULT; |
| 4059 | } |
| 4060 | |
| 4061 | return ret; |
| 4062 | } |
| 4063 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4064 | static int drv_cmd_reassoc(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4065 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4066 | uint8_t *command, |
| 4067 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4068 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4069 | { |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 4070 | return hdd_parse_reassoc(adapter, command, priv_data->total_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4071 | } |
| 4072 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4073 | static int drv_cmd_set_wes_mode(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4074 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4075 | uint8_t *command, |
| 4076 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4077 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4078 | { |
| 4079 | int ret = 0; |
| 4080 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4081 | uint8_t wes_mode = cfg_default(CFG_LFR_ENABLE_WES_MODE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4082 | |
| 4083 | /* Move pointer to ahead of SETWESMODE<delimiter> */ |
| 4084 | value = value + command_len + 1; |
| 4085 | |
| 4086 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4087 | ret = kstrtou8(value, 10, &wes_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4088 | if (ret < 0) { |
| 4089 | /* |
| 4090 | * If the input value is greater than max value of datatype, |
| 4091 | * then also kstrtou8 fails |
| 4092 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4093 | hdd_err("kstrtou8 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4094 | cfg_min(CFG_LFR_ENABLE_WES_MODE), |
| 4095 | cfg_max(CFG_LFR_ENABLE_WES_MODE)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4096 | ret = -EINVAL; |
| 4097 | goto exit; |
| 4098 | } |
| 4099 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4100 | hdd_debug("Received Command to Set WES Mode rssi diff = %d", wes_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4101 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4102 | sme_update_wes_mode(hdd_ctx->mac_handle, wes_mode, adapter->vdev_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4103 | |
| 4104 | exit: |
| 4105 | return ret; |
| 4106 | } |
| 4107 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4108 | static int drv_cmd_get_wes_mode(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4109 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4110 | uint8_t *command, |
| 4111 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4112 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4113 | { |
| 4114 | int ret = 0; |
Jeff Johnson | 22345e1 | 2019-02-26 21:33:02 -0800 | [diff] [blame] | 4115 | bool wes_mode = sme_get_wes_mode(hdd_ctx->mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4116 | char extra[32]; |
| 4117 | uint8_t len = 0; |
| 4118 | |
Jeff Johnson | 22345e1 | 2019-02-26 21:33:02 -0800 | [diff] [blame] | 4119 | len = scnprintf(extra, sizeof(extra), "%s %d", command, wes_mode); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4120 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4121 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4122 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4123 | ret = -EFAULT; |
| 4124 | } |
| 4125 | |
| 4126 | return ret; |
| 4127 | } |
| 4128 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4129 | static int drv_cmd_set_opportunistic_rssi_diff(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4130 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4131 | uint8_t *command, |
| 4132 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4133 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4134 | { |
| 4135 | int ret = 0; |
| 4136 | uint8_t *value = command; |
Jeff Johnson | 8e3ca4c | 2019-02-26 20:42:24 -0800 | [diff] [blame] | 4137 | uint8_t diff = |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4138 | cfg_default(CFG_LFR_OPPORTUNISTIC_SCAN_THRESHOLD_DIFF); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4139 | |
| 4140 | /* Move pointer to ahead of SETOPPORTUNISTICRSSIDIFF<delimiter> */ |
| 4141 | value = value + command_len + 1; |
| 4142 | |
| 4143 | /* Convert the value from ascii to integer */ |
Jeff Johnson | 8e3ca4c | 2019-02-26 20:42:24 -0800 | [diff] [blame] | 4144 | ret = kstrtou8(value, 10, &diff); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4145 | if (ret < 0) { |
| 4146 | /* |
| 4147 | * If the input value is greater than max value of datatype, |
| 4148 | * then also kstrtou8 fails |
| 4149 | */ |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4150 | hdd_err("kstrtou8 failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4151 | ret = -EINVAL; |
| 4152 | goto exit; |
| 4153 | } |
| 4154 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4155 | hdd_debug("Received Command to Set Opportunistic Threshold diff = %d", |
Jeff Johnson | 8e3ca4c | 2019-02-26 20:42:24 -0800 | [diff] [blame] | 4156 | diff); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4157 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4158 | sme_set_roam_opportunistic_scan_threshold_diff(hdd_ctx->mac_handle, |
Jeff Johnson | 8e3ca4c | 2019-02-26 20:42:24 -0800 | [diff] [blame] | 4159 | adapter->vdev_id, |
| 4160 | diff); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4161 | |
| 4162 | exit: |
| 4163 | return ret; |
| 4164 | } |
| 4165 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4166 | static int drv_cmd_get_opportunistic_rssi_diff(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4167 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4168 | uint8_t *command, |
| 4169 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4170 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4171 | { |
| 4172 | int ret = 0; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4173 | mac_handle_t mac_handle = hdd_ctx->mac_handle; |
| 4174 | int8_t val = sme_get_roam_opportunistic_scan_threshold_diff(mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4175 | char extra[32]; |
| 4176 | uint8_t len = 0; |
| 4177 | |
| 4178 | len = scnprintf(extra, sizeof(extra), "%s %d", command, val); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4179 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4180 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4181 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4182 | ret = -EFAULT; |
| 4183 | } |
| 4184 | |
| 4185 | return ret; |
| 4186 | } |
| 4187 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4188 | static int drv_cmd_set_roam_rescan_rssi_diff(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4189 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4190 | uint8_t *command, |
| 4191 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4192 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4193 | { |
| 4194 | int ret = 0; |
| 4195 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4196 | uint8_t rescan_rssi_diff = cfg_default(CFG_LFR_ROAM_RESCAN_RSSI_DIFF); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4197 | |
| 4198 | /* Move pointer to ahead of SETROAMRESCANRSSIDIFF<delimiter> */ |
| 4199 | value = value + command_len + 1; |
| 4200 | |
| 4201 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4202 | ret = kstrtou8(value, 10, &rescan_rssi_diff); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4203 | if (ret < 0) { |
| 4204 | /* |
| 4205 | * If the input value is greater than max value of datatype, |
| 4206 | * then also kstrtou8 fails |
| 4207 | */ |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4208 | hdd_err("kstrtou8 failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4209 | ret = -EINVAL; |
| 4210 | goto exit; |
| 4211 | } |
| 4212 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4213 | hdd_debug("Received Command to Set Roam Rescan RSSI Diff = %d", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4214 | rescan_rssi_diff); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4215 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4216 | sme_set_roam_rescan_rssi_diff(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4217 | adapter->vdev_id, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4218 | rescan_rssi_diff); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4219 | |
| 4220 | exit: |
| 4221 | return ret; |
| 4222 | } |
| 4223 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4224 | static int drv_cmd_get_roam_rescan_rssi_diff(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4225 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4226 | uint8_t *command, |
| 4227 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4228 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4229 | { |
| 4230 | int ret = 0; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4231 | uint8_t val = sme_get_roam_rescan_rssi_diff(hdd_ctx->mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4232 | char extra[32]; |
| 4233 | uint8_t len = 0; |
| 4234 | |
| 4235 | len = scnprintf(extra, sizeof(extra), "%s %d", command, val); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4236 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4237 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4238 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4239 | ret = -EFAULT; |
| 4240 | } |
| 4241 | |
| 4242 | return ret; |
| 4243 | } |
| 4244 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4245 | static int drv_cmd_set_fast_roam(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4246 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4247 | uint8_t *command, |
| 4248 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4249 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4250 | { |
| 4251 | int ret = 0; |
| 4252 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4253 | uint8_t lfr_mode = cfg_default(CFG_LFR_FEATURE_ENABLED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4254 | |
| 4255 | /* Move pointer to ahead of SETFASTROAM<delimiter> */ |
| 4256 | value = value + command_len + 1; |
| 4257 | |
| 4258 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4259 | ret = kstrtou8(value, 10, &lfr_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4260 | if (ret < 0) { |
| 4261 | /* |
| 4262 | * If the input value is greater than max value of datatype, |
| 4263 | * then also kstrtou8 fails |
| 4264 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4265 | hdd_err("kstrtou8 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4266 | cfg_min(CFG_LFR_FEATURE_ENABLED), |
| 4267 | cfg_max(CFG_LFR_FEATURE_ENABLED)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4268 | ret = -EINVAL; |
| 4269 | goto exit; |
| 4270 | } |
| 4271 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4272 | hdd_debug("Received Command to change lfr mode = %d", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4273 | lfr_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4274 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4275 | ucfg_mlme_set_lfr_enabled(hdd_ctx->psoc, (bool)lfr_mode); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4276 | sme_update_is_fast_roam_ini_feature_enabled(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4277 | adapter->vdev_id, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4278 | lfr_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4279 | |
| 4280 | exit: |
| 4281 | return ret; |
| 4282 | } |
| 4283 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4284 | static int drv_cmd_set_fast_transition(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4285 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4286 | uint8_t *command, |
| 4287 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4288 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4289 | { |
| 4290 | int ret = 0; |
| 4291 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4292 | uint8_t ft = cfg_default(CFG_LFR_FAST_TRANSITION_ENABLED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4293 | |
| 4294 | /* Move pointer to ahead of SETFASTROAM<delimiter> */ |
| 4295 | value = value + command_len + 1; |
| 4296 | |
| 4297 | /* Convert the value from ascii to integer */ |
| 4298 | ret = kstrtou8(value, 10, &ft); |
| 4299 | if (ret < 0) { |
| 4300 | /* |
| 4301 | * If the input value is greater than max value of datatype, |
| 4302 | * then also kstrtou8 fails |
| 4303 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4304 | hdd_err("kstrtou8 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4305 | cfg_min(CFG_LFR_FAST_TRANSITION_ENABLED), |
| 4306 | cfg_max(CFG_LFR_FAST_TRANSITION_ENABLED)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4307 | ret = -EINVAL; |
| 4308 | goto exit; |
| 4309 | } |
| 4310 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4311 | hdd_debug("Received Command to change ft mode = %d", ft); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4312 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4313 | ucfg_mlme_set_fast_transition_enabled(hdd_ctx->psoc, (bool)ft); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4314 | |
| 4315 | exit: |
| 4316 | return ret; |
| 4317 | } |
| 4318 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4319 | static int drv_cmd_fast_reassoc(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4320 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4321 | uint8_t *command, |
| 4322 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4323 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4324 | { |
| 4325 | int ret = 0; |
| 4326 | uint8_t *value = command; |
| 4327 | uint8_t channel = 0; |
Jeff Johnson | 8ff3ffe | 2019-02-26 13:21:07 -0800 | [diff] [blame] | 4328 | tSirMacAddr bssid; |
Jeff Johnson | 29c7867 | 2019-02-26 21:05:53 -0800 | [diff] [blame] | 4329 | uint32_t roam_id = INVALID_ROAM_ID; |
Jeff Johnson | 9ff1695 | 2019-02-26 20:58:44 -0800 | [diff] [blame] | 4330 | tCsrRoamModifyProfileFields mod_fields; |
Jeff Johnson | dcaa8fc | 2019-02-26 21:26:31 -0800 | [diff] [blame] | 4331 | tCsrHandoffRequest req; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4332 | struct hdd_station_ctx *sta_ctx; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4333 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4334 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 4335 | if (QDF_STA_MODE != adapter->device_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4336 | hdd_warn("Unsupported in mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 4337 | qdf_opmode_str(adapter->device_mode), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4338 | adapter->device_mode); |
| 4339 | return -EINVAL; |
| 4340 | } |
| 4341 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4342 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jingxiang Ge | ce7c547 | 2019-07-23 16:19:23 +0800 | [diff] [blame] | 4343 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4344 | |
| 4345 | /* if not associated, no need to proceed with reassoc */ |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 4346 | if (eConnectionState_Associated != sta_ctx->conn_info.conn_state) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4347 | hdd_warn("Not associated!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4348 | ret = -EINVAL; |
| 4349 | goto exit; |
| 4350 | } |
| 4351 | |
Jeff Johnson | 8ff3ffe | 2019-02-26 13:21:07 -0800 | [diff] [blame] | 4352 | ret = hdd_parse_reassoc_command_v1_data(value, bssid, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4353 | &channel); |
| 4354 | if (ret) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4355 | hdd_err("Failed to parse reassoc command data"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4356 | goto exit; |
| 4357 | } |
| 4358 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4359 | mac_handle = hdd_ctx->mac_handle; |
| 4360 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4361 | /* |
| 4362 | * if the target bssid is same as currently associated AP, |
| 4363 | * issue reassoc to same AP |
| 4364 | */ |
Jeff Johnson | e04b699 | 2019-02-27 14:06:55 -0800 | [diff] [blame] | 4365 | if (!qdf_mem_cmp(bssid, sta_ctx->conn_info.bssid.bytes, |
Jeff Johnson | 8ff3ffe | 2019-02-26 13:21:07 -0800 | [diff] [blame] | 4366 | QDF_MAC_ADDR_SIZE)) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4367 | hdd_warn("Reassoc BSSID is same as currently associated AP bssid"); |
Deepak Dhamdhere | 5fda0e4 | 2016-06-24 18:30:02 +0530 | [diff] [blame] | 4368 | if (roaming_offload_enabled(hdd_ctx)) { |
Jingxiang Ge | ce7c547 | 2019-07-23 16:19:23 +0800 | [diff] [blame] | 4369 | channel = wlan_reg_freq_to_chan( |
| 4370 | hdd_ctx->pdev, |
Jingxiang Ge | ae80dc6 | 2019-08-13 17:32:22 +0800 | [diff] [blame^] | 4371 | sta_ctx->conn_info.chan_freq); |
Jeff Johnson | 8ff3ffe | 2019-02-26 13:21:07 -0800 | [diff] [blame] | 4372 | hdd_wma_send_fastreassoc_cmd(adapter, bssid, |
| 4373 | channel); |
Deepak Dhamdhere | 5fda0e4 | 2016-06-24 18:30:02 +0530 | [diff] [blame] | 4374 | } else { |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4375 | sme_get_modify_profile_fields(mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4376 | adapter->vdev_id, |
Jeff Johnson | 9ff1695 | 2019-02-26 20:58:44 -0800 | [diff] [blame] | 4377 | &mod_fields); |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4378 | sme_roam_reassoc(mac_handle, adapter->vdev_id, |
Jeff Johnson | 29c7867 | 2019-02-26 21:05:53 -0800 | [diff] [blame] | 4379 | NULL, mod_fields, &roam_id, 1); |
Deepak Dhamdhere | 5fda0e4 | 2016-06-24 18:30:02 +0530 | [diff] [blame] | 4380 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4381 | return 0; |
| 4382 | } |
| 4383 | |
Padma, Santhosh Kumar | af9f08c | 2016-10-21 21:26:29 +0530 | [diff] [blame] | 4384 | /* Check channel number is a valid channel number */ |
Selvaraj, Sridhar | 64b0a9c | 2017-05-11 16:50:15 +0530 | [diff] [blame] | 4385 | if (channel && (QDF_STATUS_SUCCESS != |
| 4386 | wlan_hdd_validate_operation_channel(adapter, channel))) { |
Padma, Santhosh Kumar | af9f08c | 2016-10-21 21:26:29 +0530 | [diff] [blame] | 4387 | hdd_err("Invalid Channel [%d]", channel); |
| 4388 | return -EINVAL; |
| 4389 | } |
| 4390 | |
Varun Reddy Yeturu | d351a6c | 2016-03-16 14:01:00 -0700 | [diff] [blame] | 4391 | if (roaming_offload_enabled(hdd_ctx)) { |
Jeff Johnson | 8ff3ffe | 2019-02-26 13:21:07 -0800 | [diff] [blame] | 4392 | hdd_wma_send_fastreassoc_cmd(adapter, bssid, (int)channel); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4393 | goto exit; |
| 4394 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4395 | /* Proceed with reassoc */ |
Jeff Johnson | dcaa8fc | 2019-02-26 21:26:31 -0800 | [diff] [blame] | 4396 | req.channel = channel; |
| 4397 | req.src = FASTREASSOC; |
| 4398 | qdf_mem_copy(req.bssid.bytes, bssid, sizeof(tSirMacAddr)); |
| 4399 | sme_handoff_request(mac_handle, adapter->vdev_id, &req); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4400 | exit: |
| 4401 | return ret; |
| 4402 | } |
| 4403 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4404 | static int drv_cmd_set_roam_scan_control(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4405 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4406 | uint8_t *command, |
| 4407 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4408 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4409 | { |
| 4410 | int ret = 0; |
| 4411 | uint8_t *value = command; |
Jeff Johnson | d7ee476 | 2019-02-26 21:01:00 -0800 | [diff] [blame] | 4412 | uint8_t roam_scan_control = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4413 | |
| 4414 | /* Move pointer to ahead of SETROAMSCANCONTROL<delimiter> */ |
| 4415 | value = value + command_len + 1; |
| 4416 | |
| 4417 | /* Convert the value from ascii to integer */ |
Jeff Johnson | d7ee476 | 2019-02-26 21:01:00 -0800 | [diff] [blame] | 4418 | ret = kstrtou8(value, 10, &roam_scan_control); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4419 | if (ret < 0) { |
| 4420 | /* |
| 4421 | * If the input value is greater than max value of datatype, |
| 4422 | * then also kstrtou8 fails |
| 4423 | */ |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4424 | hdd_err("kstrtou8 failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4425 | ret = -EINVAL; |
| 4426 | goto exit; |
| 4427 | } |
| 4428 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4429 | hdd_debug("Received Command to Set roam scan control = %d", |
Jeff Johnson | d7ee476 | 2019-02-26 21:01:00 -0800 | [diff] [blame] | 4430 | roam_scan_control); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4431 | |
Jeff Johnson | d7ee476 | 2019-02-26 21:01:00 -0800 | [diff] [blame] | 4432 | if (0 != roam_scan_control) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4433 | ret = 0; /* return success but ignore param value "true" */ |
| 4434 | goto exit; |
| 4435 | } |
| 4436 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4437 | sme_set_roam_scan_control(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4438 | adapter->vdev_id, |
Jeff Johnson | d7ee476 | 2019-02-26 21:01:00 -0800 | [diff] [blame] | 4439 | roam_scan_control); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4440 | |
| 4441 | exit: |
| 4442 | return ret; |
| 4443 | } |
| 4444 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4445 | static int drv_cmd_set_okc_mode(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4446 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4447 | uint8_t *command, |
| 4448 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4449 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4450 | { |
| 4451 | int ret = 0; |
| 4452 | uint8_t *value = command; |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 4453 | uint32_t okc_mode; |
| 4454 | struct pmkid_mode_bits pmkid_modes; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4455 | mac_handle_t mac_handle; |
Wu Gao | 9381621 | 2018-08-31 16:49:54 +0800 | [diff] [blame] | 4456 | uint32_t cur_pmkid_modes; |
| 4457 | QDF_STATUS status; |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 4458 | |
| 4459 | hdd_get_pmkid_modes(hdd_ctx, &pmkid_modes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4460 | |
| 4461 | /* |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 4462 | * Check if the features PMKID/ESE/11R are supported simultaneously, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4463 | * then this operation is not permitted (return FAILURE) |
| 4464 | */ |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4465 | mac_handle = hdd_ctx->mac_handle; |
| 4466 | if (sme_get_is_ese_feature_enabled(mac_handle) && |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 4467 | pmkid_modes.fw_okc && |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4468 | sme_get_is_ft_feature_enabled(mac_handle)) { |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 4469 | hdd_warn("PMKID/ESE/11R are supported simultaneously hence this operation is not permitted!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4470 | ret = -EPERM; |
| 4471 | goto exit; |
| 4472 | } |
| 4473 | |
| 4474 | /* Move pointer to ahead of SETOKCMODE<delimiter> */ |
| 4475 | value = value + command_len + 1; |
| 4476 | |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 4477 | /* get the current configured value */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 4478 | status = ucfg_mlme_get_pmkid_modes(hdd_ctx->psoc, |
Wu Gao | 9381621 | 2018-08-31 16:49:54 +0800 | [diff] [blame] | 4479 | &cur_pmkid_modes); |
| 4480 | if (status != QDF_STATUS_SUCCESS) |
| 4481 | hdd_err("get pmkid modes failed"); |
| 4482 | |
| 4483 | okc_mode = cur_pmkid_modes & CFG_PMKID_MODES_OKC; |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 4484 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4485 | /* Convert the value from ascii to integer */ |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 4486 | ret = kstrtou32(value, 10, &okc_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4487 | if (ret < 0) { |
| 4488 | /* |
| 4489 | * If the input value is greater than max value of datatype, |
| 4490 | * then also kstrtou8 fails |
| 4491 | */ |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 4492 | hdd_err("value out of range [0 - 1]"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4493 | ret = -EINVAL; |
| 4494 | goto exit; |
| 4495 | } |
| 4496 | |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 4497 | if ((okc_mode < 0) || |
| 4498 | (okc_mode > 1)) { |
| 4499 | hdd_err("Okc mode value %d is out of range (Min: 0 Max: 1)", |
| 4500 | okc_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4501 | ret = -EINVAL; |
| 4502 | goto exit; |
| 4503 | } |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4504 | hdd_debug("Received Command to change okc mode = %d", |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 4505 | okc_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4506 | |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 4507 | if (okc_mode) |
Wu Gao | 9381621 | 2018-08-31 16:49:54 +0800 | [diff] [blame] | 4508 | cur_pmkid_modes |= CFG_PMKID_MODES_OKC; |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 4509 | else |
Wu Gao | 9381621 | 2018-08-31 16:49:54 +0800 | [diff] [blame] | 4510 | cur_pmkid_modes &= ~CFG_PMKID_MODES_OKC; |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 4511 | status = ucfg_mlme_set_pmkid_modes(hdd_ctx->psoc, |
Wu Gao | 9381621 | 2018-08-31 16:49:54 +0800 | [diff] [blame] | 4512 | cur_pmkid_modes); |
| 4513 | if (status != QDF_STATUS_SUCCESS) { |
| 4514 | ret = -EPERM; |
| 4515 | hdd_err("set pmkid modes failed"); |
| 4516 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4517 | exit: |
| 4518 | return ret; |
| 4519 | } |
| 4520 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4521 | static int drv_cmd_get_roam_scan_control(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4522 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4523 | uint8_t *command, |
| 4524 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4525 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4526 | { |
| 4527 | int ret = 0; |
Jeff Johnson | d7ee476 | 2019-02-26 21:01:00 -0800 | [diff] [blame] | 4528 | bool roam_scan_control = sme_get_roam_scan_control(hdd_ctx->mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4529 | char extra[32]; |
| 4530 | uint8_t len = 0; |
| 4531 | |
| 4532 | len = scnprintf(extra, sizeof(extra), "%s %d", |
Jeff Johnson | d7ee476 | 2019-02-26 21:01:00 -0800 | [diff] [blame] | 4533 | command, roam_scan_control); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4534 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4535 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4536 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4537 | ret = -EFAULT; |
| 4538 | } |
| 4539 | |
| 4540 | return ret; |
| 4541 | } |
| 4542 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4543 | static int drv_cmd_bt_coex_mode(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4544 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4545 | uint8_t *command, |
| 4546 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4547 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4548 | { |
| 4549 | int ret = 0; |
Jeff Johnson | 3019241 | 2019-02-26 20:32:52 -0800 | [diff] [blame] | 4550 | char *coex_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4551 | |
Jeff Johnson | 3019241 | 2019-02-26 20:32:52 -0800 | [diff] [blame] | 4552 | coex_mode = command + 11; |
| 4553 | if ('1' == *coex_mode) { |
| 4554 | hdd_debug("BTCOEXMODE %d", *coex_mode); |
Jeff Johnson | 59b1931 | 2017-11-02 21:14:33 -0700 | [diff] [blame] | 4555 | hdd_ctx->bt_coex_mode_set = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4556 | ret = wlan_hdd_scan_abort(adapter); |
| 4557 | if (ret < 0) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4558 | hdd_err("Failed to abort existing scan status: %d", |
| 4559 | ret); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4560 | } |
Jeff Johnson | 3019241 | 2019-02-26 20:32:52 -0800 | [diff] [blame] | 4561 | } else if ('2' == *coex_mode) { |
| 4562 | hdd_debug("BTCOEXMODE %d", *coex_mode); |
Jeff Johnson | 59b1931 | 2017-11-02 21:14:33 -0700 | [diff] [blame] | 4563 | hdd_ctx->bt_coex_mode_set = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4564 | } |
| 4565 | |
| 4566 | return ret; |
| 4567 | } |
| 4568 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4569 | static int drv_cmd_scan_active(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4570 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4571 | uint8_t *command, |
| 4572 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4573 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4574 | { |
| 4575 | hdd_ctx->ioctl_scan_mode = eSIR_ACTIVE_SCAN; |
| 4576 | return 0; |
| 4577 | } |
| 4578 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4579 | static int drv_cmd_scan_passive(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4580 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4581 | uint8_t *command, |
| 4582 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4583 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4584 | { |
| 4585 | hdd_ctx->ioctl_scan_mode = eSIR_PASSIVE_SCAN; |
| 4586 | return 0; |
| 4587 | } |
| 4588 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4589 | static int drv_cmd_get_dwell_time(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4590 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4591 | uint8_t *command, |
| 4592 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4593 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4594 | { |
| 4595 | int ret = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4596 | char extra[32]; |
| 4597 | uint8_t len = 0; |
| 4598 | |
| 4599 | memset(extra, 0, sizeof(extra)); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 4600 | ret = hdd_get_dwell_time(hdd_ctx->psoc, command, extra, |
| 4601 | sizeof(extra), &len); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4602 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4603 | if (ret != 0 || copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4604 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4605 | ret = -EFAULT; |
| 4606 | goto exit; |
| 4607 | } |
| 4608 | ret = len; |
| 4609 | exit: |
| 4610 | return ret; |
| 4611 | } |
| 4612 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4613 | static int drv_cmd_set_dwell_time(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4614 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4615 | uint8_t *command, |
| 4616 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4617 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4618 | { |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 4619 | return hdd_set_dwell_time(hdd_ctx->psoc, command); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4620 | } |
| 4621 | |
Ashish Kumar Dhanotiya | 652c233 | 2018-12-11 17:33:17 +0530 | [diff] [blame] | 4622 | static int drv_cmd_conc_set_dwell_time(struct hdd_adapter *adapter, |
| 4623 | struct hdd_context *hdd_ctx, |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 4624 | u8 *command, |
| 4625 | u8 command_len, |
Ashish Kumar Dhanotiya | 652c233 | 2018-12-11 17:33:17 +0530 | [diff] [blame] | 4626 | struct hdd_priv_data *priv_data) |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 4627 | { |
Ashish Kumar Dhanotiya | 652c233 | 2018-12-11 17:33:17 +0530 | [diff] [blame] | 4628 | return hdd_conc_set_dwell_time(adapter, command); |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 4629 | } |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 4630 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4631 | static int drv_cmd_miracast(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4632 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4633 | uint8_t *command, |
| 4634 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4635 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4636 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4637 | QDF_STATUS ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4638 | int ret = 0; |
Jeff Johnson | 3dd8a54 | 2019-02-26 21:38:14 -0800 | [diff] [blame] | 4639 | uint8_t filter_type = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4640 | uint8_t *value; |
| 4641 | |
Jeff Johnson | 6da2db1 | 2017-09-03 09:18:52 -0700 | [diff] [blame] | 4642 | if (wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4643 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4644 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4645 | value = command + 9; |
| 4646 | |
| 4647 | /* Convert the value from ascii to integer */ |
Jeff Johnson | 3dd8a54 | 2019-02-26 21:38:14 -0800 | [diff] [blame] | 4648 | ret = kstrtou8(value, 10, &filter_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4649 | if (ret < 0) { |
| 4650 | /* |
| 4651 | * If the input value is greater than max value of datatype, |
| 4652 | * then also kstrtou8 fails |
| 4653 | */ |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4654 | hdd_err("kstrtou8 failed range"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4655 | ret = -EINVAL; |
| 4656 | goto exit; |
| 4657 | } |
Jeff Johnson | 3dd8a54 | 2019-02-26 21:38:14 -0800 | [diff] [blame] | 4658 | if ((filter_type < WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL) || |
| 4659 | (filter_type > WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL)) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4660 | hdd_err("Accepted Values are 0 to 2. 0-Disabled, 1-Source, 2-Sink"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4661 | ret = -EINVAL; |
| 4662 | goto exit; |
| 4663 | } |
| 4664 | /* Filtertype value should be either 0-Disabled, 1-Source, 2-sink */ |
Jeff Johnson | 3dd8a54 | 2019-02-26 21:38:14 -0800 | [diff] [blame] | 4665 | hdd_ctx->miracast_value = filter_type; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4666 | |
Jeff Johnson | 3dd8a54 | 2019-02-26 21:38:14 -0800 | [diff] [blame] | 4667 | ret_status = sme_set_miracast(hdd_ctx->mac_handle, filter_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4668 | if (QDF_STATUS_SUCCESS != ret_status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4669 | hdd_err("Failed to set miracast"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4670 | return -EBUSY; |
| 4671 | } |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 4672 | ret_status = ucfg_scan_set_miracast(hdd_ctx->psoc, |
Jeff Johnson | 3dd8a54 | 2019-02-26 21:38:14 -0800 | [diff] [blame] | 4673 | filter_type ? true : false); |
Abhishek Singh | c87bb04 | 2018-01-30 17:10:42 +0530 | [diff] [blame] | 4674 | if (QDF_IS_STATUS_ERROR(ret_status)) { |
| 4675 | hdd_err("Failed to set miracastn scan"); |
| 4676 | return -EBUSY; |
| 4677 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4678 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 4679 | if (policy_mgr_is_mcc_in_24G(hdd_ctx->psoc)) |
Jeff Johnson | 3dd8a54 | 2019-02-26 21:38:14 -0800 | [diff] [blame] | 4680 | return wlan_hdd_set_mas(adapter, filter_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4681 | |
| 4682 | exit: |
| 4683 | return ret; |
| 4684 | } |
| 4685 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4686 | /* Function header is left blank intentionally */ |
| 4687 | static int hdd_parse_set_ibss_oui_data_command(uint8_t *command, uint8_t *ie, |
| 4688 | int32_t *oui_length, int32_t limit) |
| 4689 | { |
| 4690 | uint8_t len; |
| 4691 | uint8_t data; |
| 4692 | |
| 4693 | while ((SPACE_ASCII_VALUE == *command) && ('\0' != *command)) { |
| 4694 | command++; |
| 4695 | limit--; |
| 4696 | } |
| 4697 | |
| 4698 | len = 2; |
| 4699 | |
| 4700 | while ((SPACE_ASCII_VALUE != *command) && ('\0' != *command) && |
| 4701 | (limit > 1)) { |
| 4702 | sscanf(command, "%02x", (unsigned int *)&data); |
| 4703 | ie[len++] = data; |
| 4704 | command += 2; |
| 4705 | limit -= 2; |
| 4706 | } |
| 4707 | |
| 4708 | *oui_length = len - 2; |
| 4709 | |
| 4710 | while ((SPACE_ASCII_VALUE == *command) && ('\0' != *command)) { |
| 4711 | command++; |
| 4712 | limit--; |
| 4713 | } |
| 4714 | |
| 4715 | while ((SPACE_ASCII_VALUE != *command) && ('\0' != *command) && |
| 4716 | (limit > 1)) { |
| 4717 | sscanf(command, "%02x", (unsigned int *)&data); |
| 4718 | ie[len++] = data; |
| 4719 | command += 2; |
| 4720 | limit -= 2; |
| 4721 | } |
| 4722 | |
Srinivas Girigowda | 8e7ecab | 2019-05-16 11:31:19 -0700 | [diff] [blame] | 4723 | ie[0] = WLAN_ELEMID_VENDOR; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4724 | ie[1] = len - 2; |
| 4725 | |
| 4726 | return len; |
| 4727 | } |
| 4728 | |
| 4729 | /** |
| 4730 | * drv_cmd_set_ibss_beacon_oui_data() - set ibss oui data command |
| 4731 | * @adapter: Pointer to adapter |
| 4732 | * @hdd_ctx: Pointer to HDD context |
| 4733 | * @command: Pointer to command string |
| 4734 | * @command_len : Command length |
| 4735 | * @priv_data : Pointer to priv data |
| 4736 | * |
| 4737 | * Return: |
| 4738 | * int status code |
| 4739 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4740 | static int drv_cmd_set_ibss_beacon_oui_data(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4741 | struct hdd_context *hdd_ctx, |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4742 | uint8_t *command, |
| 4743 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4744 | struct hdd_priv_data *priv_data) |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4745 | { |
| 4746 | int i = 0; |
| 4747 | int status; |
| 4748 | int ret = 0; |
| 4749 | uint8_t *ibss_ie; |
| 4750 | int32_t oui_length = 0; |
| 4751 | uint32_t ibss_ie_length; |
| 4752 | uint8_t *value = command; |
Jeff Johnson | 7964a11 | 2019-02-26 18:24:12 -0800 | [diff] [blame] | 4753 | tSirModifyIE modify_ie; |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 4754 | struct csr_roam_profile *roam_profile; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4755 | mac_handle_t mac_handle; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4756 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 4757 | if (QDF_IBSS_MODE != adapter->device_mode) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4758 | hdd_debug("Device_mode %s(%d) not IBSS", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 4759 | qdf_opmode_str(adapter->device_mode), |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4760 | adapter->device_mode); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4761 | return ret; |
| 4762 | } |
| 4763 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4764 | hdd_debug("received command %s", ((char *)value)); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4765 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4766 | /* validate argument of command */ |
| 4767 | if (strlen(value) <= command_len) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4768 | hdd_err("No arguments in command length %zu", |
| 4769 | strlen(value)); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4770 | ret = -EFAULT; |
| 4771 | goto exit; |
| 4772 | } |
| 4773 | |
| 4774 | /* moving to arguments of commands */ |
| 4775 | value = value + command_len; |
| 4776 | command_len = strlen(value); |
| 4777 | |
| 4778 | /* oui_data can't be less than 3 bytes */ |
| 4779 | if (command_len < (2 * WLAN_HDD_IBSS_MIN_OUI_DATA_LENGTH)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4780 | hdd_err("Invalid SETIBSSBEACONOUIDATA command length %d", |
| 4781 | command_len); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4782 | ret = -EFAULT; |
| 4783 | goto exit; |
| 4784 | } |
| 4785 | |
| 4786 | ibss_ie = qdf_mem_malloc(command_len); |
| 4787 | if (!ibss_ie) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4788 | hdd_err("Could not allocate memory for command length %d", |
| 4789 | command_len); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4790 | ret = -ENOMEM; |
| 4791 | goto exit; |
| 4792 | } |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4793 | |
| 4794 | ibss_ie_length = hdd_parse_set_ibss_oui_data_command(value, ibss_ie, |
| 4795 | &oui_length, |
| 4796 | command_len); |
| 4797 | if (ibss_ie_length <= (2 * WLAN_HDD_IBSS_MIN_OUI_DATA_LENGTH)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4798 | hdd_err("Could not parse command %s return length %d", |
| 4799 | value, ibss_ie_length); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4800 | ret = -EFAULT; |
| 4801 | qdf_mem_free(ibss_ie); |
| 4802 | goto exit; |
| 4803 | } |
| 4804 | |
Jeff Johnson | 8313b9d | 2018-03-14 15:09:28 -0700 | [diff] [blame] | 4805 | roam_profile = hdd_roam_profile(adapter); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4806 | |
Jeff Johnson | 7964a11 | 2019-02-26 18:24:12 -0800 | [diff] [blame] | 4807 | qdf_copy_macaddr(&modify_ie.bssid, |
Jeff Johnson | 5b34fce | 2017-10-13 13:24:51 -0700 | [diff] [blame] | 4808 | roam_profile->BSSIDs.bssid); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4809 | |
Jeff Johnson | 7964a11 | 2019-02-26 18:24:12 -0800 | [diff] [blame] | 4810 | modify_ie.smeSessionId = adapter->vdev_id; |
| 4811 | modify_ie.notify = true; |
Srinivas Girigowda | 8e7ecab | 2019-05-16 11:31:19 -0700 | [diff] [blame] | 4812 | modify_ie.ieID = WLAN_ELEMID_VENDOR; |
Jeff Johnson | 7964a11 | 2019-02-26 18:24:12 -0800 | [diff] [blame] | 4813 | modify_ie.ieIDLen = ibss_ie_length; |
| 4814 | modify_ie.ieBufferlength = ibss_ie_length; |
| 4815 | modify_ie.pIEBuffer = ibss_ie; |
| 4816 | modify_ie.oui_length = oui_length; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4817 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4818 | hdd_warn("ibss_ie length %d oui_length %d ibss_ie:", |
| 4819 | ibss_ie_length, oui_length); |
Jeff Johnson | 7964a11 | 2019-02-26 18:24:12 -0800 | [diff] [blame] | 4820 | while (i < modify_ie.ieBufferlength) |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4821 | hdd_warn("0x%x", ibss_ie[i++]); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4822 | |
| 4823 | /* Probe Bcn modification */ |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4824 | mac_handle = hdd_ctx->mac_handle; |
Jeff Johnson | 7964a11 | 2019-02-26 18:24:12 -0800 | [diff] [blame] | 4825 | sme_modify_add_ie(mac_handle, &modify_ie, eUPDATE_IE_PROBE_BCN); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4826 | |
| 4827 | /* Populating probe resp frame */ |
Jeff Johnson | 7964a11 | 2019-02-26 18:24:12 -0800 | [diff] [blame] | 4828 | sme_modify_add_ie(mac_handle, &modify_ie, eUPDATE_IE_PROBE_RESP); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4829 | |
| 4830 | qdf_mem_free(ibss_ie); |
| 4831 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4832 | status = sme_send_cesium_enable_ind(mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4833 | adapter->vdev_id); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4834 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4835 | hdd_err("Could not send cesium enable indication %d", |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4836 | status); |
| 4837 | ret = -EINVAL; |
| 4838 | goto exit; |
| 4839 | } |
| 4840 | |
| 4841 | exit: |
| 4842 | return ret; |
| 4843 | } |
| 4844 | |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4845 | #ifdef FEATURE_WLAN_RMC |
| 4846 | /* Function header is left blank intentionally */ |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 4847 | static int hdd_parse_setrmcenable_command(uint8_t *command, |
Jeff Johnson | 259f3e9 | 2019-02-26 13:36:01 -0800 | [diff] [blame] | 4848 | uint8_t *rmc_enable) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4849 | { |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 4850 | uint8_t *in_ptr = command; |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 4851 | int temp_int; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4852 | int v = 0; |
| 4853 | char buf[32]; |
Jeff Johnson | 259f3e9 | 2019-02-26 13:36:01 -0800 | [diff] [blame] | 4854 | *rmc_enable = 0; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4855 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 4856 | in_ptr = strnchr(command, strlen(command), SPACE_ASCII_VALUE); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4857 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 4858 | if (!in_ptr) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4859 | return 0; |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 4860 | else if (SPACE_ASCII_VALUE != *in_ptr) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4861 | return 0; |
| 4862 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 4863 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 4864 | in_ptr++; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4865 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 4866 | if ('\0' == *in_ptr) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4867 | return 0; |
| 4868 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 4869 | v = sscanf(in_ptr, "%31s ", buf); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4870 | if (1 != v) |
| 4871 | return -EINVAL; |
| 4872 | |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 4873 | v = kstrtos32(buf, 10, &temp_int); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4874 | if (v < 0) |
| 4875 | return -EINVAL; |
| 4876 | |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 4877 | *rmc_enable = temp_int; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4878 | |
Jeff Johnson | f8a0b8f | 2019-02-26 19:26:31 -0800 | [diff] [blame] | 4879 | hdd_debug("rmc_enable: %d", *rmc_enable); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4880 | |
| 4881 | return 0; |
| 4882 | } |
| 4883 | |
| 4884 | /* Function header is left blank intentionally */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4885 | static int hdd_parse_setrmcactionperiod_command(uint8_t *pvalue, |
| 4886 | uint32_t *paction_period) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4887 | { |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4888 | uint8_t *inptr = pvalue; |
| 4889 | int temp_int; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4890 | int v = 0; |
| 4891 | char buf[32]; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4892 | *paction_period = 0; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4893 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4894 | inptr = strnchr(pvalue, strlen(pvalue), SPACE_ASCII_VALUE); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4895 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 4896 | if (!inptr) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4897 | return -EINVAL; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4898 | else if (SPACE_ASCII_VALUE != *inptr) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4899 | return -EINVAL; |
| 4900 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4901 | while ((SPACE_ASCII_VALUE == *inptr) && ('\0' != *inptr)) |
| 4902 | inptr++; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4903 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4904 | if ('\0' == *inptr) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4905 | return 0; |
| 4906 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4907 | v = sscanf(inptr, "%31s ", buf); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4908 | if (1 != v) |
| 4909 | return -EINVAL; |
| 4910 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4911 | v = kstrtos32(buf, 10, &temp_int); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4912 | if (v < 0) |
| 4913 | return -EINVAL; |
| 4914 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4915 | if (!cfg_in_range(CFG_RMC_ACTION_PERIOD_FREQUENCY, temp_int)) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4916 | return -EINVAL; |
| 4917 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4918 | *paction_period = temp_int; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4919 | |
Jeff Johnson | 3972e0d | 2019-02-26 19:42:35 -0800 | [diff] [blame] | 4920 | hdd_debug("action_period: %d", *paction_period); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4921 | |
| 4922 | return 0; |
| 4923 | } |
| 4924 | |
| 4925 | /* Function header is left blank intentionally */ |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 4926 | static int hdd_parse_setrmcrate_command(uint8_t *command, |
Jeff Johnson | b9f9b28 | 2019-02-26 13:40:32 -0800 | [diff] [blame] | 4927 | uint32_t *rate, |
Jeff Johnson | 269d7fb | 2019-02-26 10:47:33 -0800 | [diff] [blame] | 4928 | enum tx_rate_info *tx_flags) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4929 | { |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 4930 | uint8_t *in_ptr = command; |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 4931 | int temp_int; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4932 | int v = 0; |
| 4933 | char buf[32]; |
Jeff Johnson | b9f9b28 | 2019-02-26 13:40:32 -0800 | [diff] [blame] | 4934 | *rate = 0; |
Jeff Johnson | 269d7fb | 2019-02-26 10:47:33 -0800 | [diff] [blame] | 4935 | *tx_flags = 0; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4936 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 4937 | in_ptr = strnchr(command, strlen(command), SPACE_ASCII_VALUE); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4938 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 4939 | if (!in_ptr) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4940 | return -EINVAL; |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 4941 | else if (SPACE_ASCII_VALUE != *in_ptr) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4942 | return -EINVAL; |
| 4943 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 4944 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 4945 | in_ptr++; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4946 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 4947 | if ('\0' == *in_ptr) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4948 | return 0; |
| 4949 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 4950 | v = sscanf(in_ptr, "%31s ", buf); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4951 | if (1 != v) |
| 4952 | return -EINVAL; |
| 4953 | |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 4954 | v = kstrtos32(buf, 10, &temp_int); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4955 | if (v < 0) |
| 4956 | return -EINVAL; |
| 4957 | |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 4958 | switch (temp_int) { |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4959 | default: |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 4960 | hdd_warn("Unsupported rate: %d", temp_int); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4961 | return -EINVAL; |
| 4962 | case 0: |
| 4963 | case 6: |
| 4964 | case 9: |
| 4965 | case 12: |
| 4966 | case 18: |
| 4967 | case 24: |
| 4968 | case 36: |
| 4969 | case 48: |
| 4970 | case 54: |
Jeff Johnson | 269d7fb | 2019-02-26 10:47:33 -0800 | [diff] [blame] | 4971 | *tx_flags = TX_RATE_LEGACY; |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 4972 | *rate = temp_int * 10; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4973 | break; |
| 4974 | case 65: |
Jeff Johnson | 269d7fb | 2019-02-26 10:47:33 -0800 | [diff] [blame] | 4975 | *tx_flags = TX_RATE_HT20; |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 4976 | *rate = temp_int * 10; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4977 | break; |
| 4978 | case 72: |
Jeff Johnson | 269d7fb | 2019-02-26 10:47:33 -0800 | [diff] [blame] | 4979 | *tx_flags = TX_RATE_HT20 | TX_RATE_SGI; |
Jeff Johnson | b9f9b28 | 2019-02-26 13:40:32 -0800 | [diff] [blame] | 4980 | *rate = 722; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4981 | break; |
| 4982 | } |
| 4983 | |
Jeff Johnson | b9f9b28 | 2019-02-26 13:40:32 -0800 | [diff] [blame] | 4984 | hdd_debug("Rate: %d", *rate); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 4985 | |
| 4986 | return 0; |
| 4987 | } |
| 4988 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4989 | static int drv_cmd_set_rmc_enable(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4990 | struct hdd_context *hdd_ctx, |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4991 | uint8_t *command, |
| 4992 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4993 | struct hdd_priv_data *priv_data) |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4994 | { |
| 4995 | int ret = 0; |
| 4996 | uint8_t *value = command; |
Jeff Johnson | f8a0b8f | 2019-02-26 19:26:31 -0800 | [diff] [blame] | 4997 | uint8_t rmc_enable = 0; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 4998 | int status; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4999 | mac_handle_t mac_handle; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5000 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 5001 | if ((QDF_IBSS_MODE != adapter->device_mode) && |
| 5002 | (QDF_SAP_MODE != adapter->device_mode)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5003 | hdd_err("Received SETRMCENABLE cmd in invalid mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 5004 | qdf_opmode_str(adapter->device_mode), |
| 5005 | adapter->device_mode); |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5006 | hdd_err("SETRMCENABLE cmd is allowed only in IBSS/SOFTAP mode"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5007 | ret = -EINVAL; |
| 5008 | goto exit; |
| 5009 | } |
| 5010 | |
Jeff Johnson | f8a0b8f | 2019-02-26 19:26:31 -0800 | [diff] [blame] | 5011 | status = hdd_parse_setrmcenable_command(value, &rmc_enable); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5012 | if (status) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5013 | hdd_err("Invalid SETRMCENABLE command"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5014 | ret = -EINVAL; |
| 5015 | goto exit; |
| 5016 | } |
| 5017 | |
Jeff Johnson | f8a0b8f | 2019-02-26 19:26:31 -0800 | [diff] [blame] | 5018 | hdd_debug("rmc_enable %d", rmc_enable); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5019 | mac_handle = hdd_ctx->mac_handle; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5020 | |
Jeff Johnson | f8a0b8f | 2019-02-26 19:26:31 -0800 | [diff] [blame] | 5021 | if (true == rmc_enable) { |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5022 | status = sme_enable_rmc(mac_handle, adapter->vdev_id); |
Jeff Johnson | f8a0b8f | 2019-02-26 19:26:31 -0800 | [diff] [blame] | 5023 | } else if (false == rmc_enable) { |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5024 | status = sme_disable_rmc(mac_handle, adapter->vdev_id); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5025 | } else { |
Jeff Johnson | f8a0b8f | 2019-02-26 19:26:31 -0800 | [diff] [blame] | 5026 | hdd_err("Invalid SETRMCENABLE command %d", rmc_enable); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5027 | ret = -EINVAL; |
| 5028 | goto exit; |
| 5029 | } |
| 5030 | |
| 5031 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | f8a0b8f | 2019-02-26 19:26:31 -0800 | [diff] [blame] | 5032 | hdd_err("SETRMC %d failed status %d", rmc_enable, status); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5033 | ret = -EINVAL; |
| 5034 | goto exit; |
| 5035 | } |
| 5036 | |
| 5037 | exit: |
| 5038 | return ret; |
| 5039 | } |
| 5040 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5041 | static int drv_cmd_set_rmc_action_period(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5042 | struct hdd_context *hdd_ctx, |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5043 | uint8_t *command, |
| 5044 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5045 | struct hdd_priv_data *priv_data) |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5046 | { |
| 5047 | int ret = 0; |
| 5048 | uint8_t *value = command; |
Jeff Johnson | 3972e0d | 2019-02-26 19:42:35 -0800 | [diff] [blame] | 5049 | uint32_t action_period = 0; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5050 | int status; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5051 | mac_handle_t mac_handle; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5052 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 5053 | if ((QDF_IBSS_MODE != adapter->device_mode) && |
| 5054 | (QDF_SAP_MODE != adapter->device_mode)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5055 | hdd_err("Received SETRMC cmd in invalid mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 5056 | qdf_opmode_str(adapter->device_mode), |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5057 | adapter->device_mode); |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5058 | hdd_err("SETRMC cmd is allowed only in IBSS/SOFTAP mode"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5059 | ret = -EINVAL; |
| 5060 | goto exit; |
| 5061 | } |
| 5062 | |
Jeff Johnson | 3972e0d | 2019-02-26 19:42:35 -0800 | [diff] [blame] | 5063 | status = hdd_parse_setrmcactionperiod_command(value, &action_period); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5064 | if (status) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5065 | hdd_err("Invalid SETRMCACTIONPERIOD command"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5066 | ret = -EINVAL; |
| 5067 | goto exit; |
| 5068 | } |
| 5069 | |
Jeff Johnson | 3972e0d | 2019-02-26 19:42:35 -0800 | [diff] [blame] | 5070 | hdd_debug("action_period %d", action_period); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5071 | mac_handle = hdd_ctx->mac_handle; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5072 | |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 5073 | if (ucfg_mlme_set_rmc_action_period_freq(hdd_ctx->psoc, |
Jeff Johnson | 3972e0d | 2019-02-26 19:42:35 -0800 | [diff] [blame] | 5074 | action_period) != |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 5075 | QDF_STATUS_SUCCESS) { |
Jeff Johnson | 3972e0d | 2019-02-26 19:42:35 -0800 | [diff] [blame] | 5076 | hdd_err("Could not set SETRMCACTIONPERIOD %d", action_period); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5077 | ret = -EINVAL; |
| 5078 | goto exit; |
| 5079 | } |
| 5080 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5081 | status = sme_send_rmc_action_period(mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5082 | adapter->vdev_id); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5083 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5084 | hdd_err("Could not send cesium enable indication %d", |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5085 | status); |
| 5086 | ret = -EINVAL; |
| 5087 | goto exit; |
| 5088 | } |
| 5089 | |
| 5090 | exit: |
| 5091 | return ret; |
| 5092 | } |
| 5093 | |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5094 | static int drv_cmd_set_rmc_tx_rate(struct hdd_adapter *adapter, |
| 5095 | struct hdd_context *hdd_ctx, |
| 5096 | uint8_t *command, |
| 5097 | uint8_t command_len, |
| 5098 | struct hdd_priv_data *priv_data) |
| 5099 | { |
| 5100 | int ret = 0; |
| 5101 | uint8_t *value = command; |
Jeff Johnson | af5283f | 2019-02-26 19:31:48 -0800 | [diff] [blame] | 5102 | uint32_t rate = 0; |
Jeff Johnson | 269d7fb | 2019-02-26 10:47:33 -0800 | [diff] [blame] | 5103 | enum tx_rate_info tx_flags = 0; |
Jeff Johnson | 2370b85 | 2019-02-26 17:03:12 -0800 | [diff] [blame] | 5104 | tSirRateUpdateInd params = {0}; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5105 | int status; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 5106 | bool bval = false; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5107 | |
| 5108 | if ((QDF_IBSS_MODE != adapter->device_mode) && |
| 5109 | (QDF_SAP_MODE != adapter->device_mode)) { |
| 5110 | hdd_err("Received SETRMCTXRATE cmd in invalid mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 5111 | qdf_opmode_str(adapter->device_mode), |
| 5112 | adapter->device_mode); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5113 | hdd_err("SETRMCTXRATE cmd is allowed only in IBSS/SOFTAP mode"); |
| 5114 | ret = -EINVAL; |
| 5115 | goto exit; |
| 5116 | } |
| 5117 | |
Jeff Johnson | af5283f | 2019-02-26 19:31:48 -0800 | [diff] [blame] | 5118 | status = hdd_parse_setrmcrate_command(value, &rate, &tx_flags); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5119 | if (status) { |
| 5120 | hdd_err("Invalid SETRMCTXRATE command"); |
| 5121 | ret = -EINVAL; |
| 5122 | goto exit; |
| 5123 | } |
Jeff Johnson | af5283f | 2019-02-26 19:31:48 -0800 | [diff] [blame] | 5124 | hdd_debug("rate %d", rate); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5125 | |
| 5126 | /* |
| 5127 | * Fill the user specifieed RMC rate param |
| 5128 | * and the derived tx flags. |
| 5129 | */ |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 5130 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 5131 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 5132 | hdd_err("unable to get vht_enable2x2"); |
| 5133 | ret = -EINVAL; |
| 5134 | goto exit; |
| 5135 | } |
Jeff Johnson | 2370b85 | 2019-02-26 17:03:12 -0800 | [diff] [blame] | 5136 | params.nss = (bval == 0) ? 0 : 1; |
Jeff Johnson | af5283f | 2019-02-26 19:31:48 -0800 | [diff] [blame] | 5137 | params.reliableMcastDataRate = rate; |
Jeff Johnson | 2370b85 | 2019-02-26 17:03:12 -0800 | [diff] [blame] | 5138 | params.reliableMcastDataRateTxFlag = tx_flags; |
| 5139 | params.dev_mode = adapter->device_mode; |
| 5140 | params.bcastDataRate = -1; |
| 5141 | memcpy(params.bssid.bytes, |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5142 | adapter->mac_addr.bytes, |
Jeff Johnson | 2370b85 | 2019-02-26 17:03:12 -0800 | [diff] [blame] | 5143 | sizeof(params.bssid)); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5144 | status = sme_send_rate_update_ind(hdd_ctx->mac_handle, |
Jeff Johnson | 2370b85 | 2019-02-26 17:03:12 -0800 | [diff] [blame] | 5145 | ¶ms); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5146 | |
| 5147 | exit: |
| 5148 | return ret; |
| 5149 | } |
| 5150 | #endif /* FEATURE_WLAN_RMC */ |
| 5151 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5152 | static int drv_cmd_get_ibss_peer_info_all(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5153 | struct hdd_context *hdd_ctx, |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5154 | uint8_t *command, |
| 5155 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5156 | struct hdd_priv_data *priv_data) |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5157 | { |
| 5158 | int ret = 0; |
| 5159 | int status = QDF_STATUS_SUCCESS; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5160 | struct hdd_station_ctx *sta_ctx = NULL; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5161 | char *extra = NULL; |
| 5162 | int idx = 0; |
| 5163 | int length = 0; |
Rajeev Kumar | 94c9b45 | 2016-03-24 12:58:47 -0700 | [diff] [blame] | 5164 | uint8_t mac_addr[QDF_MAC_ADDR_SIZE]; |
Jeff Johnson | 0e5369e | 2019-02-26 21:54:26 -0800 | [diff] [blame] | 5165 | uint32_t print_break_index = 0; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5166 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 5167 | if (QDF_IBSS_MODE != adapter->device_mode) { |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5168 | hdd_warn("Unsupported in mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 5169 | qdf_opmode_str(adapter->device_mode), |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5170 | adapter->device_mode); |
| 5171 | return -EINVAL; |
| 5172 | } |
| 5173 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5174 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5175 | hdd_debug("Received GETIBSSPEERINFOALL Command"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5176 | |
| 5177 | /* Handle the command */ |
| 5178 | status = hdd_cfg80211_get_ibss_peer_info_all(adapter); |
| 5179 | if (QDF_STATUS_SUCCESS == status) { |
Dustin Brown | c8e96f1 | 2018-04-19 09:27:42 -0700 | [diff] [blame] | 5180 | size_t user_size = qdf_min(WLAN_MAX_BUF_SIZE, |
| 5181 | priv_data->total_len); |
| 5182 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5183 | /* |
| 5184 | * The variable extra needed to be allocated on the heap since |
| 5185 | * amount of memory required to copy the data for 32 devices |
| 5186 | * exceeds the size of 1024 bytes of default stack size. On |
| 5187 | * 64 bit devices, the default max stack size of 2048 bytes |
| 5188 | */ |
Dustin Brown | c8e96f1 | 2018-04-19 09:27:42 -0700 | [diff] [blame] | 5189 | extra = qdf_mem_malloc(user_size); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5190 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 5191 | if (!extra) { |
Mahesh Kumar Kalikot Veetil | 9c65618 | 2016-11-02 10:28:03 -0700 | [diff] [blame] | 5192 | hdd_err("memory allocation failed"); |
| 5193 | ret = -ENOMEM; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5194 | goto exit; |
| 5195 | } |
| 5196 | |
| 5197 | /* Copy number of stations */ |
Dustin Brown | c8e96f1 | 2018-04-19 09:27:42 -0700 | [diff] [blame] | 5198 | length = scnprintf(extra, user_size, "%d ", |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5199 | sta_ctx->ibss_peer_info.numPeers); |
Jeff Johnson | 0e5369e | 2019-02-26 21:54:26 -0800 | [diff] [blame] | 5200 | print_break_index = length; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5201 | for (idx = 0; idx < sta_ctx->ibss_peer_info.numPeers; |
Rajeev Kumar | 94c9b45 | 2016-03-24 12:58:47 -0700 | [diff] [blame] | 5202 | idx++) { |
| 5203 | int8_t rssi; |
| 5204 | uint32_t tx_rate; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5205 | |
Rajeev Kumar | 94c9b45 | 2016-03-24 12:58:47 -0700 | [diff] [blame] | 5206 | qdf_mem_copy(mac_addr, |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5207 | sta_ctx->ibss_peer_info.peerInfoParams[idx]. |
Rajeev Kumar | 94c9b45 | 2016-03-24 12:58:47 -0700 | [diff] [blame] | 5208 | mac_addr, sizeof(mac_addr)); |
| 5209 | |
| 5210 | tx_rate = |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5211 | sta_ctx->ibss_peer_info.peerInfoParams[idx]. |
Rajeev Kumar | 94c9b45 | 2016-03-24 12:58:47 -0700 | [diff] [blame] | 5212 | txRate; |
Sriram Madhvapathi | 85df7c7 | 2016-09-30 11:35:28 +0530 | [diff] [blame] | 5213 | /* |
| 5214 | * Only lower 3 bytes are rate info. Mask of the MSByte |
| 5215 | */ |
| 5216 | tx_rate &= 0x00FFFFFF; |
| 5217 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5218 | rssi = sta_ctx->ibss_peer_info.peerInfoParams[idx]. |
Rajeev Kumar | 94c9b45 | 2016-03-24 12:58:47 -0700 | [diff] [blame] | 5219 | rssi; |
| 5220 | |
Dustin Brown | c8e96f1 | 2018-04-19 09:27:42 -0700 | [diff] [blame] | 5221 | length += scnprintf(extra + length, |
| 5222 | user_size - length, |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 5223 | QDF_MAC_ADDR_STR" %d %d ", |
| 5224 | QDF_MAC_ADDR_ARRAY(mac_addr), |
Rajeev Kumar | 94c9b45 | 2016-03-24 12:58:47 -0700 | [diff] [blame] | 5225 | tx_rate, rssi); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5226 | /* |
Rajeev Kumar | 94c9b45 | 2016-03-24 12:58:47 -0700 | [diff] [blame] | 5227 | * cdf_trace_msg has limitation of 512 bytes for the |
| 5228 | * print buffer. Hence printing the data in two chunks. |
| 5229 | * The first chunk will have the data for 16 devices |
| 5230 | * and the second chunk will have the rest. |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5231 | */ |
| 5232 | if (idx < NUM_OF_STA_DATA_TO_PRINT) |
Jeff Johnson | 0e5369e | 2019-02-26 21:54:26 -0800 | [diff] [blame] | 5233 | print_break_index = length; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5234 | } |
| 5235 | |
| 5236 | /* |
| 5237 | * Copy the data back into buffer, if the data to copy is |
| 5238 | * more than 512 bytes than we will split the data and do |
| 5239 | * it in two shots |
| 5240 | */ |
Jeff Johnson | 0e5369e | 2019-02-26 21:54:26 -0800 | [diff] [blame] | 5241 | if (copy_to_user(priv_data->buf, extra, print_break_index)) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5242 | hdd_err("Copy into user data buffer failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5243 | ret = -EFAULT; |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 5244 | goto mem_free; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5245 | } |
| 5246 | |
Srinivas Girigowda | 051a9b4 | 2017-03-21 15:44:29 -0700 | [diff] [blame] | 5247 | /* This overwrites the last space, which we already copied */ |
Jeff Johnson | 0e5369e | 2019-02-26 21:54:26 -0800 | [diff] [blame] | 5248 | extra[print_break_index - 1] = '\0'; |
Srinivas Girigowda | 051a9b4 | 2017-03-21 15:44:29 -0700 | [diff] [blame] | 5249 | hdd_debug("%s", extra); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5250 | |
Jeff Johnson | 0e5369e | 2019-02-26 21:54:26 -0800 | [diff] [blame] | 5251 | if (length > print_break_index) { |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5252 | if (copy_to_user |
Jeff Johnson | 0e5369e | 2019-02-26 21:54:26 -0800 | [diff] [blame] | 5253 | (priv_data->buf + print_break_index, |
| 5254 | extra + print_break_index, |
| 5255 | length - print_break_index + 1)) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5256 | hdd_err("Copy into user data buffer failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5257 | ret = -EFAULT; |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 5258 | goto mem_free; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5259 | } |
Jeff Johnson | 0e5369e | 2019-02-26 21:54:26 -0800 | [diff] [blame] | 5260 | hdd_debug("%s", &extra[print_break_index]); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5261 | } |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5262 | } else { |
| 5263 | /* Command failed, log error */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5264 | hdd_err("GETIBSSPEERINFOALL command failed with status code %d", |
| 5265 | status); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5266 | ret = -EINVAL; |
| 5267 | goto exit; |
| 5268 | } |
| 5269 | ret = 0; |
| 5270 | |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 5271 | mem_free: |
| 5272 | qdf_mem_free(extra); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5273 | exit: |
| 5274 | return ret; |
| 5275 | } |
| 5276 | |
| 5277 | /* Peer Info <Peer Addr> command */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5278 | static int drv_cmd_get_ibss_peer_info(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5279 | struct hdd_context *hdd_ctx, |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5280 | uint8_t *command, |
| 5281 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5282 | struct hdd_priv_data *priv_data) |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5283 | { |
| 5284 | int ret = 0; |
| 5285 | uint8_t *value = command; |
| 5286 | QDF_STATUS status; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5287 | struct hdd_station_ctx *sta_ctx = NULL; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5288 | char extra[128] = { 0 }; |
| 5289 | uint32_t length = 0; |
Jeff Johnson | 0a082d9 | 2019-03-04 12:25:49 -0800 | [diff] [blame] | 5290 | uint8_t sta_id = 0; |
Jeff Johnson | 2d04461 | 2019-02-26 20:08:43 -0800 | [diff] [blame] | 5291 | struct qdf_mac_addr peer_macaddr; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5292 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 5293 | if (QDF_IBSS_MODE != adapter->device_mode) { |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5294 | hdd_warn("Unsupported in mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 5295 | qdf_opmode_str(adapter->device_mode), |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5296 | adapter->device_mode); |
| 5297 | return -EINVAL; |
| 5298 | } |
| 5299 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5300 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5301 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5302 | hdd_debug("Received GETIBSSPEERINFO Command"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5303 | |
| 5304 | /* if there are no peers, no need to continue with the command */ |
| 5305 | if (eConnectionState_IbssConnected != |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 5306 | sta_ctx->conn_info.conn_state) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5307 | hdd_err("No IBSS Peers coalesced"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5308 | ret = -EINVAL; |
| 5309 | goto exit; |
| 5310 | } |
| 5311 | |
| 5312 | /* Parse the incoming command buffer */ |
Jeff Johnson | 2d04461 | 2019-02-26 20:08:43 -0800 | [diff] [blame] | 5313 | status = hdd_parse_get_ibss_peer_info(value, &peer_macaddr); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5314 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5315 | hdd_err("Invalid GETIBSSPEERINFO command"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5316 | ret = -EINVAL; |
| 5317 | goto exit; |
| 5318 | } |
| 5319 | |
Rajeev Kumar | 94c9b45 | 2016-03-24 12:58:47 -0700 | [diff] [blame] | 5320 | /* Get station index for the peer mac address and sanitize it */ |
Jeff Johnson | 0a082d9 | 2019-03-04 12:25:49 -0800 | [diff] [blame] | 5321 | hdd_get_peer_sta_id(sta_ctx, &peer_macaddr, &sta_id); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5322 | |
Jeff Johnson | 0a082d9 | 2019-03-04 12:25:49 -0800 | [diff] [blame] | 5323 | if (sta_id > MAX_PEERS) { |
| 5324 | hdd_err("Invalid StaIdx %d returned", sta_id); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5325 | ret = -EINVAL; |
| 5326 | goto exit; |
| 5327 | } |
| 5328 | |
| 5329 | /* Handle the command */ |
Jeff Johnson | 0a082d9 | 2019-03-04 12:25:49 -0800 | [diff] [blame] | 5330 | status = hdd_cfg80211_get_ibss_peer_info(adapter, sta_id); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5331 | if (QDF_STATUS_SUCCESS == status) { |
Jeff Johnson | a464bf2 | 2019-02-26 21:41:48 -0800 | [diff] [blame] | 5332 | uint32_t tx_rate = |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5333 | sta_ctx->ibss_peer_info.peerInfoParams[0].txRate; |
Sriram Madhvapathi | 85df7c7 | 2016-09-30 11:35:28 +0530 | [diff] [blame] | 5334 | /* Only lower 3 bytes are rate info. Mask of the MSByte */ |
Jeff Johnson | a464bf2 | 2019-02-26 21:41:48 -0800 | [diff] [blame] | 5335 | tx_rate &= 0x00FFFFFF; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5336 | |
| 5337 | length = scnprintf(extra, sizeof(extra), "%d %d", |
Jeff Johnson | a464bf2 | 2019-02-26 21:41:48 -0800 | [diff] [blame] | 5338 | (int)tx_rate, |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5339 | (int)sta_ctx->ibss_peer_info. |
Rajeev Kumar | 94c9b45 | 2016-03-24 12:58:47 -0700 | [diff] [blame] | 5340 | peerInfoParams[0].rssi); |
Jingxiang Ge | 03e2b59 | 2019-01-23 17:15:53 +0800 | [diff] [blame] | 5341 | length = QDF_MIN(priv_data->total_len, length + 1); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5342 | |
| 5343 | /* Copy the data back into buffer */ |
Jingxiang Ge | 03e2b59 | 2019-01-23 17:15:53 +0800 | [diff] [blame] | 5344 | if (copy_to_user(priv_data->buf, &extra, length)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5345 | hdd_err("copy data to user buffer failed GETIBSSPEERINFO command"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5346 | ret = -EFAULT; |
| 5347 | goto exit; |
| 5348 | } |
| 5349 | } else { |
| 5350 | /* Command failed, log error */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5351 | hdd_err("GETIBSSPEERINFO command failed with status code %d", |
| 5352 | status); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5353 | ret = -EINVAL; |
| 5354 | goto exit; |
| 5355 | } |
| 5356 | |
| 5357 | /* Success ! */ |
Rajeev Kumar Sirasanagandla | 92ec9d9 | 2018-04-24 21:33:06 +0530 | [diff] [blame] | 5358 | hdd_debug("%s", extra); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5359 | ret = 0; |
| 5360 | |
| 5361 | exit: |
| 5362 | return ret; |
| 5363 | } |
| 5364 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5365 | static int drv_cmd_set_ibss_tx_fail_event(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5366 | struct hdd_context *hdd_ctx, |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5367 | uint8_t *command, |
| 5368 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5369 | struct hdd_priv_data *priv_data) |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5370 | { |
| 5371 | int ret = 0; |
| 5372 | char *value; |
| 5373 | uint8_t tx_fail_count = 0; |
| 5374 | uint16_t pid = 0; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5375 | mac_handle_t mac_handle; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5376 | |
| 5377 | value = command; |
| 5378 | |
| 5379 | ret = hdd_parse_ibsstx_fail_event_params(value, &tx_fail_count, &pid); |
| 5380 | |
| 5381 | if (0 != ret) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5382 | hdd_err("Failed to parse SETIBSSTXFAILEVENT arguments"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5383 | goto exit; |
| 5384 | } |
| 5385 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5386 | hdd_debug("tx_fail_cnt=%hhu, pid=%hu", tx_fail_count, pid); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5387 | mac_handle = hdd_ctx->mac_handle; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5388 | |
| 5389 | if (0 == tx_fail_count) { |
| 5390 | /* Disable TX Fail Indication */ |
| 5391 | if (QDF_STATUS_SUCCESS == |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5392 | sme_tx_fail_monitor_start_stop_ind(mac_handle, |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5393 | tx_fail_count, |
| 5394 | NULL)) { |
| 5395 | cesium_pid = 0; |
| 5396 | } else { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5397 | hdd_err("failed to disable TX Fail Event"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5398 | ret = -EINVAL; |
| 5399 | } |
| 5400 | } else { |
| 5401 | if (QDF_STATUS_SUCCESS == |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5402 | sme_tx_fail_monitor_start_stop_ind(mac_handle, |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5403 | tx_fail_count, |
| 5404 | (void *)hdd_tx_fail_ind_callback)) { |
| 5405 | cesium_pid = pid; |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5406 | hdd_debug("Registered Cesium pid %u", |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5407 | cesium_pid); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5408 | } else { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5409 | hdd_err("Failed to enable TX Fail Monitoring"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5410 | ret = -EINVAL; |
| 5411 | } |
| 5412 | } |
| 5413 | |
| 5414 | exit: |
| 5415 | return ret; |
| 5416 | } |
| 5417 | |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 5418 | #ifdef FEATURE_WLAN_ESE |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5419 | static int drv_cmd_set_ccx_roam_scan_channels(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5420 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5421 | uint8_t *command, |
| 5422 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5423 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5424 | { |
| 5425 | int ret = 0; |
| 5426 | uint8_t *value = command; |
Jeff Johnson | 8a2e1da | 2019-02-26 17:56:24 -0800 | [diff] [blame] | 5427 | uint8_t channel_list[CFG_VALID_CHANNEL_LIST_LEN] = { 0 }; |
| 5428 | uint8_t num_channels = 0; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5429 | QDF_STATUS status; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5430 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5431 | |
Jeff Johnson | 8a2e1da | 2019-02-26 17:56:24 -0800 | [diff] [blame] | 5432 | ret = hdd_parse_channellist(value, channel_list, &num_channels); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5433 | if (ret) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5434 | hdd_err("Failed to parse channel list information"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5435 | goto exit; |
| 5436 | } |
Jeff Johnson | 8a2e1da | 2019-02-26 17:56:24 -0800 | [diff] [blame] | 5437 | if (num_channels > CFG_VALID_CHANNEL_LIST_LEN) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5438 | hdd_err("number of channels (%d) supported exceeded max (%d)", |
Jeff Johnson | 8a2e1da | 2019-02-26 17:56:24 -0800 | [diff] [blame] | 5439 | num_channels, |
| 5440 | CFG_VALID_CHANNEL_LIST_LEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5441 | ret = -EINVAL; |
| 5442 | goto exit; |
| 5443 | } |
Vignesh Viswanathan | a2f5ce58 | 2018-05-09 20:38:39 +0530 | [diff] [blame] | 5444 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5445 | mac_handle = hdd_ctx->mac_handle; |
Jeff Johnson | 8a2e1da | 2019-02-26 17:56:24 -0800 | [diff] [blame] | 5446 | if (!sme_validate_channel_list(mac_handle, channel_list, |
| 5447 | num_channels)) { |
Vignesh Viswanathan | a2f5ce58 | 2018-05-09 20:38:39 +0530 | [diff] [blame] | 5448 | hdd_err("List contains invalid channel(s)"); |
| 5449 | ret = -EINVAL; |
| 5450 | goto exit; |
| 5451 | } |
| 5452 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5453 | status = sme_set_ese_roam_scan_channel_list(mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5454 | adapter->vdev_id, |
Jeff Johnson | 8a2e1da | 2019-02-26 17:56:24 -0800 | [diff] [blame] | 5455 | channel_list, |
| 5456 | num_channels); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5457 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5458 | hdd_err("Failed to update channel list information"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5459 | ret = -EINVAL; |
| 5460 | goto exit; |
| 5461 | } |
| 5462 | |
| 5463 | exit: |
| 5464 | return ret; |
| 5465 | } |
| 5466 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5467 | static int drv_cmd_get_tsm_stats(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5468 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5469 | uint8_t *command, |
| 5470 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5471 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5472 | { |
| 5473 | int ret = 0; |
| 5474 | uint8_t *value = command; |
| 5475 | char extra[128] = { 0 }; |
| 5476 | int len = 0; |
| 5477 | uint8_t tid = 0; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5478 | struct hdd_station_ctx *sta_ctx; |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 5479 | tAniTrafStrmMetrics tsm_metrics = {0}; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5480 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 5481 | if ((QDF_STA_MODE != adapter->device_mode) && |
| 5482 | (QDF_P2P_CLIENT_MODE != adapter->device_mode)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5483 | hdd_warn("Unsupported in mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 5484 | qdf_opmode_str(adapter->device_mode), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5485 | adapter->device_mode); |
| 5486 | return -EINVAL; |
| 5487 | } |
| 5488 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5489 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5490 | |
| 5491 | /* if not associated, return error */ |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 5492 | if (eConnectionState_Associated != sta_ctx->conn_info.conn_state) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5493 | hdd_err("Not associated!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5494 | ret = -EINVAL; |
| 5495 | goto exit; |
| 5496 | } |
| 5497 | |
| 5498 | /* Move pointer to ahead of GETTSMSTATS<delimiter> */ |
| 5499 | value = value + command_len + 1; |
| 5500 | |
| 5501 | /* Convert the value from ascii to integer */ |
| 5502 | ret = kstrtou8(value, 10, &tid); |
| 5503 | if (ret < 0) { |
| 5504 | /* |
| 5505 | * If the input value is greater than max value of datatype, |
| 5506 | * then also kstrtou8 fails |
| 5507 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5508 | hdd_err("kstrtou8 failed range [%d - %d]", |
| 5509 | TID_MIN_VALUE, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5510 | TID_MAX_VALUE); |
| 5511 | ret = -EINVAL; |
| 5512 | goto exit; |
| 5513 | } |
| 5514 | if ((tid < TID_MIN_VALUE) || (tid > TID_MAX_VALUE)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5515 | hdd_err("tid value %d is out of range (Min: %d Max: %d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5516 | tid, TID_MIN_VALUE, TID_MAX_VALUE); |
| 5517 | ret = -EINVAL; |
| 5518 | goto exit; |
| 5519 | } |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5520 | hdd_debug("Received Command to get tsm stats tid = %d", |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5521 | tid); |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 5522 | ret = hdd_get_tsm_stats(adapter, tid, &tsm_metrics); |
| 5523 | if (ret) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5524 | hdd_err("failed to get tsm stats"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5525 | goto exit; |
| 5526 | } |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5527 | hdd_debug( |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5528 | "UplinkPktQueueDly(%d) UplinkPktQueueDlyHist[0](%d) UplinkPktQueueDlyHist[1](%d) UplinkPktQueueDlyHist[2](%d) UplinkPktQueueDlyHist[3](%d) UplinkPktTxDly(%u) UplinkPktLoss(%d) UplinkPktCount(%d) RoamingCount(%d) RoamingDly(%d)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5529 | tsm_metrics.UplinkPktQueueDly, |
| 5530 | tsm_metrics.UplinkPktQueueDlyHist[0], |
| 5531 | tsm_metrics.UplinkPktQueueDlyHist[1], |
| 5532 | tsm_metrics.UplinkPktQueueDlyHist[2], |
| 5533 | tsm_metrics.UplinkPktQueueDlyHist[3], |
| 5534 | tsm_metrics.UplinkPktTxDly, |
| 5535 | tsm_metrics.UplinkPktLoss, |
| 5536 | tsm_metrics.UplinkPktCount, |
| 5537 | tsm_metrics.RoamingCount, |
| 5538 | tsm_metrics.RoamingDly); |
| 5539 | /* |
| 5540 | * Output TSM stats is of the format |
| 5541 | * GETTSMSTATS [PktQueueDly] |
| 5542 | * [PktQueueDlyHist[0]]:[PktQueueDlyHist[1]] ...[RoamingDly] |
| 5543 | * eg., GETTSMSTATS 10 1:0:0:161 20 1 17 8 39800 |
| 5544 | */ |
| 5545 | len = scnprintf(extra, |
| 5546 | sizeof(extra), |
| 5547 | "%s %d %d:%d:%d:%d %u %d %d %d %d", |
| 5548 | command, |
| 5549 | tsm_metrics.UplinkPktQueueDly, |
| 5550 | tsm_metrics.UplinkPktQueueDlyHist[0], |
| 5551 | tsm_metrics.UplinkPktQueueDlyHist[1], |
| 5552 | tsm_metrics.UplinkPktQueueDlyHist[2], |
| 5553 | tsm_metrics.UplinkPktQueueDlyHist[3], |
| 5554 | tsm_metrics.UplinkPktTxDly, |
| 5555 | tsm_metrics.UplinkPktLoss, |
| 5556 | tsm_metrics.UplinkPktCount, |
| 5557 | tsm_metrics.RoamingCount, |
| 5558 | tsm_metrics.RoamingDly); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5559 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5560 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5561 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5562 | ret = -EFAULT; |
| 5563 | goto exit; |
| 5564 | } |
| 5565 | |
| 5566 | exit: |
| 5567 | return ret; |
| 5568 | } |
| 5569 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5570 | static int drv_cmd_set_cckm_ie(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5571 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5572 | uint8_t *command, |
| 5573 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5574 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5575 | { |
| 5576 | int ret; |
| 5577 | uint8_t *value = command; |
Jeff Johnson | 264e2d3 | 2019-02-26 13:16:58 -0800 | [diff] [blame] | 5578 | uint8_t *cckm_ie = NULL; |
Jeff Johnson | b9eeef3 | 2019-02-26 13:15:49 -0800 | [diff] [blame] | 5579 | uint8_t cckm_ie_len = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5580 | |
Jeff Johnson | 264e2d3 | 2019-02-26 13:16:58 -0800 | [diff] [blame] | 5581 | ret = hdd_parse_get_cckm_ie(value, &cckm_ie, &cckm_ie_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5582 | if (ret) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5583 | hdd_err("Failed to parse cckm ie data"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5584 | goto exit; |
| 5585 | } |
| 5586 | |
Jeff Johnson | b9eeef3 | 2019-02-26 13:15:49 -0800 | [diff] [blame] | 5587 | if (cckm_ie_len > DOT11F_IE_RSN_MAX_LEN) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5588 | hdd_err("CCKM Ie input length is more than max[%d]", |
| 5589 | DOT11F_IE_RSN_MAX_LEN); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 5590 | if (cckm_ie) { |
Jeff Johnson | 264e2d3 | 2019-02-26 13:16:58 -0800 | [diff] [blame] | 5591 | qdf_mem_free(cckm_ie); |
| 5592 | cckm_ie = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5593 | } |
| 5594 | ret = -EINVAL; |
| 5595 | goto exit; |
| 5596 | } |
| 5597 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5598 | sme_set_cckm_ie(hdd_ctx->mac_handle, adapter->vdev_id, |
Jeff Johnson | 264e2d3 | 2019-02-26 13:16:58 -0800 | [diff] [blame] | 5599 | cckm_ie, cckm_ie_len); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 5600 | if (cckm_ie) { |
Jeff Johnson | 264e2d3 | 2019-02-26 13:16:58 -0800 | [diff] [blame] | 5601 | qdf_mem_free(cckm_ie); |
| 5602 | cckm_ie = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5603 | } |
| 5604 | |
| 5605 | exit: |
| 5606 | return ret; |
| 5607 | } |
| 5608 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5609 | static int drv_cmd_ccx_beacon_req(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5610 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5611 | uint8_t *command, |
| 5612 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5613 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5614 | { |
| 5615 | int ret; |
| 5616 | uint8_t *value = command; |
Jeff Johnson | 210bc97 | 2019-02-26 19:55:01 -0800 | [diff] [blame] | 5617 | tCsrEseBeaconReq req = {0}; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5618 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5619 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 5620 | if (QDF_STA_MODE != adapter->device_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5621 | hdd_warn("Unsupported in mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 5622 | qdf_opmode_str(adapter->device_mode), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5623 | adapter->device_mode); |
| 5624 | return -EINVAL; |
| 5625 | } |
| 5626 | |
Jeff Johnson | 210bc97 | 2019-02-26 19:55:01 -0800 | [diff] [blame] | 5627 | ret = hdd_parse_ese_beacon_req(value, &req); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5628 | if (ret) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5629 | hdd_err("Failed to parse ese beacon req"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5630 | goto exit; |
| 5631 | } |
| 5632 | |
| 5633 | if (!hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5634 | hdd_debug("Not associated"); |
Rajeev Kumar Sirasanagandla | 8413a48 | 2018-04-19 18:02:45 +0530 | [diff] [blame] | 5635 | |
Jeff Johnson | 210bc97 | 2019-02-26 19:55:01 -0800 | [diff] [blame] | 5636 | if (!req.numBcnReqIe) |
Rajeev Kumar Sirasanagandla | 8413a48 | 2018-04-19 18:02:45 +0530 | [diff] [blame] | 5637 | return -EINVAL; |
| 5638 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5639 | hdd_indicate_ese_bcn_report_no_results(adapter, |
Jeff Johnson | 210bc97 | 2019-02-26 19:55:01 -0800 | [diff] [blame] | 5640 | req.bcnReq[0].measurementToken, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5641 | 0x02, /* BIT(1) set for measurement done */ |
| 5642 | 0); /* no BSS */ |
| 5643 | goto exit; |
| 5644 | } |
| 5645 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5646 | status = sme_set_ese_beacon_request(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5647 | adapter->vdev_id, |
Jeff Johnson | 210bc97 | 2019-02-26 19:55:01 -0800 | [diff] [blame] | 5648 | &req); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5649 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5650 | if (QDF_STATUS_E_RESOURCES == status) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5651 | hdd_err("sme_set_ese_beacon_request failed (%d), a request already in progress", |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5652 | status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5653 | ret = -EBUSY; |
| 5654 | goto exit; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5655 | } else if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5656 | hdd_err("sme_set_ese_beacon_request failed (%d)", |
| 5657 | status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5658 | ret = -EINVAL; |
| 5659 | goto exit; |
| 5660 | } |
| 5661 | |
| 5662 | exit: |
| 5663 | return ret; |
| 5664 | } |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 5665 | |
| 5666 | /** |
| 5667 | * drv_cmd_ccx_plm_req() - Set ESE PLM request |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 5668 | * @adapter: Pointer to the HDD adapter |
| 5669 | * @hdd_ctx: Pointer to the HDD context |
| 5670 | * @command: Driver command string |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 5671 | * @command_len: Driver command string length |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 5672 | * @priv_data: Private data coming with the driver command. Unused here |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 5673 | * |
| 5674 | * This function handles driver command that sets the ESE PLM request |
| 5675 | * |
| 5676 | * Return: 0 on success; negative errno otherwise |
| 5677 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5678 | static int drv_cmd_ccx_plm_req(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5679 | struct hdd_context *hdd_ctx, |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 5680 | uint8_t *command, |
| 5681 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5682 | struct hdd_priv_data *priv_data) |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 5683 | { |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 5684 | QDF_STATUS status; |
| 5685 | struct plm_req_params *req; |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 5686 | |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 5687 | req = qdf_mem_malloc(sizeof(*req)); |
| 5688 | if (!req) |
| 5689 | return -ENOMEM; |
| 5690 | |
| 5691 | status = hdd_parse_plm_cmd(command, req); |
| 5692 | if (QDF_IS_STATUS_SUCCESS(status)) { |
| 5693 | req->vdev_id = adapter->vdev_id; |
| 5694 | status = sme_set_plm_request(hdd_ctx->mac_handle, req); |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 5695 | } |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 5696 | qdf_mem_free(req); |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 5697 | |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 5698 | return qdf_status_to_os_return(status); |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 5699 | } |
| 5700 | |
| 5701 | /** |
| 5702 | * drv_cmd_set_ccx_mode() - Set ESE mode |
| 5703 | * @adapter: Pointer to the HDD adapter |
| 5704 | * @hdd_ctx: Pointer to the HDD context |
| 5705 | * @command: Driver command string |
| 5706 | * @command_len: Driver command string length |
| 5707 | * @priv_data: Private data coming with the driver command. Unused here |
| 5708 | * |
| 5709 | * This function handles driver command that sets ESE mode |
| 5710 | * |
| 5711 | * Return: 0 on success; negative errno otherwise |
| 5712 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5713 | static int drv_cmd_set_ccx_mode(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5714 | struct hdd_context *hdd_ctx, |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 5715 | uint8_t *command, |
| 5716 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5717 | struct hdd_priv_data *priv_data) |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 5718 | { |
| 5719 | int ret = 0; |
| 5720 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5721 | uint8_t ese_mode = cfg_default(CFG_LFR_ESE_FEATURE_ENABLED); |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 5722 | struct pmkid_mode_bits pmkid_modes; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5723 | mac_handle_t mac_handle; |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 5724 | |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 5725 | hdd_get_pmkid_modes(hdd_ctx, &pmkid_modes); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5726 | mac_handle = hdd_ctx->mac_handle; |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 5727 | /* |
| 5728 | * Check if the features OKC/ESE/11R are supported simultaneously, |
| 5729 | * then this operation is not permitted (return FAILURE) |
| 5730 | */ |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5731 | if (sme_get_is_ese_feature_enabled(mac_handle) && |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 5732 | pmkid_modes.fw_okc && |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5733 | sme_get_is_ft_feature_enabled(mac_handle)) { |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 5734 | hdd_warn("OKC/ESE/11R are supported simultaneously hence this operation is not permitted!"); |
| 5735 | ret = -EPERM; |
| 5736 | goto exit; |
| 5737 | } |
| 5738 | |
| 5739 | /* Move pointer to ahead of SETCCXMODE<delimiter> */ |
| 5740 | value = value + command_len + 1; |
| 5741 | |
| 5742 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5743 | ret = kstrtou8(value, 10, &ese_mode); |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 5744 | if (ret < 0) { |
| 5745 | /* |
| 5746 | * If the input value is greater than max value of datatype, |
| 5747 | * then also kstrtou8 fails |
| 5748 | */ |
| 5749 | hdd_err("kstrtou8 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5750 | cfg_min(CFG_LFR_ESE_FEATURE_ENABLED), |
| 5751 | cfg_max(CFG_LFR_ESE_FEATURE_ENABLED)); |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 5752 | ret = -EINVAL; |
| 5753 | goto exit; |
| 5754 | } |
| 5755 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5756 | hdd_debug("Received Command to change ese mode = %d", ese_mode); |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 5757 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5758 | sme_update_is_ese_feature_enabled(mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5759 | adapter->vdev_id, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5760 | ese_mode); |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 5761 | |
| 5762 | exit: |
| 5763 | return ret; |
| 5764 | } |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 5765 | #endif /* FEATURE_WLAN_ESE */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5766 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5767 | static int drv_cmd_set_mc_rate(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5768 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5769 | uint8_t *command, |
| 5770 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5771 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5772 | { |
| 5773 | int ret = 0; |
| 5774 | uint8_t *value = command; |
Srinivas Girigowda | 9d55015 | 2019-03-26 12:19:45 -0700 | [diff] [blame] | 5775 | uint32_t target_rate = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5776 | |
| 5777 | /* input value is in units of hundred kbps */ |
| 5778 | |
| 5779 | /* Move pointer to ahead of SETMCRATE<delimiter> */ |
| 5780 | value = value + command_len + 1; |
| 5781 | |
| 5782 | /* Convert the value from ascii to integer, decimal base */ |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5783 | ret = kstrtouint(value, 10, &target_rate); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5784 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5785 | ret = wlan_hdd_set_mc_rate(adapter, target_rate); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5786 | return ret; |
| 5787 | } |
| 5788 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5789 | static int drv_cmd_max_tx_power(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5790 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5791 | uint8_t *command, |
| 5792 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5793 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5794 | { |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5795 | int ret; |
| 5796 | int tx_power; |
| 5797 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5798 | uint8_t *value = command; |
Dustin Brown | ce5b3d3 | 2018-01-17 15:07:38 -0800 | [diff] [blame] | 5799 | struct qdf_mac_addr bssid = QDF_MAC_ADDR_BCAST_INIT; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5800 | struct qdf_mac_addr selfmac = QDF_MAC_ADDR_BCAST_INIT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5801 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5802 | ret = hdd_parse_setmaxtxpower_command(value, &tx_power); |
| 5803 | if (ret) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5804 | hdd_err("Invalid MAXTXPOWER command"); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5805 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5806 | } |
| 5807 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5808 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5809 | /* Assign correct self MAC address */ |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 5810 | qdf_copy_macaddr(&bssid, |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5811 | &adapter->mac_addr); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5812 | qdf_copy_macaddr(&selfmac, |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5813 | &adapter->mac_addr); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5814 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5815 | hdd_debug("Device mode %d max tx power %d selfMac: " |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 5816 | QDF_MAC_ADDR_STR " bssId: " QDF_MAC_ADDR_STR, |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5817 | adapter->device_mode, tx_power, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 5818 | QDF_MAC_ADDR_ARRAY(selfmac.bytes), |
| 5819 | QDF_MAC_ADDR_ARRAY(bssid.bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5820 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5821 | status = sme_set_max_tx_power(hdd_ctx->mac_handle, |
| 5822 | bssid, selfmac, tx_power); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5823 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5824 | hdd_err("Set max tx power failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5825 | ret = -EINVAL; |
| 5826 | goto exit; |
| 5827 | } |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5828 | hdd_debug("Set max tx power success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5829 | } |
| 5830 | |
| 5831 | exit: |
| 5832 | return ret; |
| 5833 | } |
| 5834 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5835 | static int drv_cmd_set_dfs_scan_mode(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5836 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5837 | uint8_t *command, |
| 5838 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5839 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5840 | { |
| 5841 | int ret = 0; |
| 5842 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5843 | uint8_t dfs_scan_mode = cfg_default(CFG_LFR_ROAMING_DFS_CHANNEL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5844 | |
| 5845 | /* Move pointer to ahead of SETDFSSCANMODE<delimiter> */ |
| 5846 | value = value + command_len + 1; |
| 5847 | |
| 5848 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5849 | ret = kstrtou8(value, 10, &dfs_scan_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5850 | if (ret < 0) { |
| 5851 | /* |
| 5852 | * If the input value is greater than max value of datatype, |
| 5853 | * then also kstrtou8 fails |
| 5854 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5855 | hdd_err("kstrtou8 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5856 | cfg_min(CFG_LFR_ROAMING_DFS_CHANNEL), |
| 5857 | cfg_max(CFG_LFR_ROAMING_DFS_CHANNEL)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5858 | ret = -EINVAL; |
| 5859 | goto exit; |
| 5860 | } |
| 5861 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5862 | if (!cfg_in_range(CFG_LFR_ROAMING_DFS_CHANNEL, dfs_scan_mode)) { |
Jeff Johnson | 6860551 | 2019-02-26 21:30:04 -0800 | [diff] [blame] | 5863 | hdd_err("dfs_scan_mode value %d is out of range (Min: %d Max: %d)", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5864 | dfs_scan_mode, |
| 5865 | cfg_min(CFG_LFR_ROAMING_DFS_CHANNEL), |
| 5866 | cfg_max(CFG_LFR_ROAMING_DFS_CHANNEL)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5867 | ret = -EINVAL; |
| 5868 | goto exit; |
| 5869 | } |
| 5870 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5871 | hdd_debug("Received Command to Set DFS Scan Mode = %d", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5872 | dfs_scan_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5873 | |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 5874 | /* When DFS scanning is disabled, the DFS channels need to be |
| 5875 | * removed from the operation of device. |
| 5876 | */ |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 5877 | ret = wlan_hdd_enable_dfs_chan_scan(hdd_ctx, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5878 | dfs_scan_mode != ROAMING_DFS_CHANNEL_DISABLED); |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 5879 | if (ret < 0) { |
| 5880 | /* Some conditions prevented it from disabling DFS channels */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5881 | hdd_err("disable/enable DFS channel request was denied"); |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 5882 | goto exit; |
| 5883 | } |
| 5884 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5885 | sme_update_dfs_scan_mode(hdd_ctx->mac_handle, adapter->vdev_id, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5886 | dfs_scan_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5887 | |
| 5888 | exit: |
| 5889 | return ret; |
| 5890 | } |
| 5891 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5892 | static int drv_cmd_get_dfs_scan_mode(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5893 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5894 | uint8_t *command, |
| 5895 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5896 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5897 | { |
| 5898 | int ret = 0; |
Jeff Johnson | 6860551 | 2019-02-26 21:30:04 -0800 | [diff] [blame] | 5899 | uint8_t dfs_scan_mode = sme_get_dfs_scan_mode(hdd_ctx->mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5900 | char extra[32]; |
| 5901 | uint8_t len = 0; |
| 5902 | |
Jeff Johnson | 6860551 | 2019-02-26 21:30:04 -0800 | [diff] [blame] | 5903 | len = scnprintf(extra, sizeof(extra), "%s %d", command, dfs_scan_mode); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5904 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5905 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5906 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5907 | ret = -EFAULT; |
| 5908 | } |
| 5909 | |
| 5910 | return ret; |
| 5911 | } |
| 5912 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5913 | static int drv_cmd_get_link_status(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5914 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5915 | uint8_t *command, |
| 5916 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5917 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5918 | { |
| 5919 | int ret = 0; |
| 5920 | int value = wlan_hdd_get_link_status(adapter); |
| 5921 | char extra[32]; |
| 5922 | uint8_t len; |
| 5923 | |
| 5924 | len = scnprintf(extra, sizeof(extra), "%s %d", command, value); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5925 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5926 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5927 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5928 | ret = -EFAULT; |
| 5929 | } |
| 5930 | |
| 5931 | return ret; |
| 5932 | } |
| 5933 | |
| 5934 | #ifdef WLAN_FEATURE_EXTWOW_SUPPORT |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5935 | static int drv_cmd_enable_ext_wow(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5936 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5937 | uint8_t *command, |
| 5938 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5939 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5940 | { |
| 5941 | uint8_t *value = command; |
| 5942 | int set_value; |
| 5943 | |
| 5944 | /* Move pointer to ahead of ENABLEEXTWOW */ |
| 5945 | value = value + command_len; |
| 5946 | |
Anurag Chouhan | 43e0c75 | 2016-09-03 16:17:02 +0530 | [diff] [blame] | 5947 | if (!(sscanf(value, "%d", &set_value))) { |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 5948 | hdd_info("No input identified"); |
Anurag Chouhan | 43e0c75 | 2016-09-03 16:17:02 +0530 | [diff] [blame] | 5949 | return -EINVAL; |
| 5950 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5951 | |
| 5952 | return hdd_enable_ext_wow_parser(adapter, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5953 | adapter->vdev_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5954 | set_value); |
| 5955 | } |
| 5956 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5957 | static int drv_cmd_set_app1_params(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5958 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5959 | uint8_t *command, |
| 5960 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5961 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5962 | { |
| 5963 | int ret; |
| 5964 | uint8_t *value = command; |
| 5965 | |
| 5966 | /* Move pointer to ahead of SETAPP1PARAMS */ |
| 5967 | value = value + command_len; |
| 5968 | |
| 5969 | ret = hdd_set_app_type1_parser(adapter, |
| 5970 | value, strlen(value)); |
| 5971 | if (ret >= 0) |
| 5972 | hdd_ctx->is_extwow_app_type1_param_set = true; |
| 5973 | |
| 5974 | return ret; |
| 5975 | } |
| 5976 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5977 | static int drv_cmd_set_app2_params(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5978 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5979 | uint8_t *command, |
| 5980 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5981 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5982 | { |
| 5983 | int ret; |
| 5984 | uint8_t *value = command; |
| 5985 | |
| 5986 | /* Move pointer to ahead of SETAPP2PARAMS */ |
| 5987 | value = value + command_len; |
| 5988 | |
| 5989 | ret = hdd_set_app_type2_parser(adapter, value, strlen(value)); |
| 5990 | if (ret >= 0) |
| 5991 | hdd_ctx->is_extwow_app_type2_param_set = true; |
| 5992 | |
| 5993 | return ret; |
| 5994 | } |
| 5995 | #endif /* WLAN_FEATURE_EXTWOW_SUPPORT */ |
| 5996 | |
| 5997 | #ifdef FEATURE_WLAN_TDLS |
| 5998 | /** |
| 5999 | * drv_cmd_tdls_secondary_channel_offset() - secondary tdls off channel offset |
| 6000 | * @adapter: Pointer to the HDD adapter |
| 6001 | * @hdd_ctx: Pointer to the HDD context |
| 6002 | * @command: Driver command string |
| 6003 | * @command_len: Driver command string length |
| 6004 | * @priv_data: Private data coming with the driver command. Unused here |
| 6005 | * |
| 6006 | * This function handles driver command that sets the secondary tdls off channel |
| 6007 | * offset |
| 6008 | * |
| 6009 | * Return: 0 on success; negative errno otherwise |
| 6010 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6011 | static int drv_cmd_tdls_secondary_channel_offset(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6012 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6013 | uint8_t *command, |
| 6014 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6015 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6016 | { |
| 6017 | int ret; |
| 6018 | uint8_t *value = command; |
| 6019 | int set_value; |
| 6020 | |
| 6021 | /* Move pointer to point the string */ |
| 6022 | value += command_len; |
| 6023 | |
| 6024 | ret = sscanf(value, "%d", &set_value); |
| 6025 | if (ret != 1) |
| 6026 | return -EINVAL; |
| 6027 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 6028 | hdd_debug("Tdls offchannel offset:%d", set_value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6029 | |
Bala Venkatesh | 113a9e6 | 2018-08-30 15:19:02 +0530 | [diff] [blame] | 6030 | ret = hdd_set_tdls_secoffchanneloffset(hdd_ctx, adapter, set_value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6031 | |
| 6032 | return ret; |
| 6033 | } |
| 6034 | |
| 6035 | /** |
| 6036 | * drv_cmd_tdls_off_channel_mode() - set tdls off channel mode |
| 6037 | * @adapter: Pointer to the HDD adapter |
| 6038 | * @hdd_ctx: Pointer to the HDD context |
| 6039 | * @command: Driver command string |
| 6040 | * @command_len: Driver command string length |
| 6041 | * @priv_data: Private data coming with the driver command. Unused here |
| 6042 | * |
| 6043 | * This function handles driver command that sets tdls off channel mode |
| 6044 | * |
| 6045 | * Return: 0 on success; negative errno otherwise |
| 6046 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6047 | static int drv_cmd_tdls_off_channel_mode(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6048 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6049 | uint8_t *command, |
| 6050 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6051 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6052 | { |
| 6053 | int ret; |
| 6054 | uint8_t *value = command; |
| 6055 | int set_value; |
| 6056 | |
| 6057 | /* Move pointer to point the string */ |
| 6058 | value += command_len; |
| 6059 | |
| 6060 | ret = sscanf(value, "%d", &set_value); |
| 6061 | if (ret != 1) |
| 6062 | return -EINVAL; |
| 6063 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 6064 | hdd_debug("Tdls offchannel mode:%d", set_value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6065 | |
Bala Venkatesh | 113a9e6 | 2018-08-30 15:19:02 +0530 | [diff] [blame] | 6066 | ret = hdd_set_tdls_offchannelmode(hdd_ctx, adapter, set_value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6067 | |
| 6068 | return ret; |
| 6069 | } |
| 6070 | |
| 6071 | /** |
| 6072 | * drv_cmd_tdls_off_channel() - set tdls off channel number |
| 6073 | * @adapter: Pointer to the HDD adapter |
| 6074 | * @hdd_ctx: Pointer to the HDD context |
| 6075 | * @command: Driver command string |
| 6076 | * @command_len: Driver command string length |
| 6077 | * @priv_data: Private data coming with the driver command. Unused here |
| 6078 | * |
| 6079 | * This function handles driver command that sets tdls off channel number |
| 6080 | * |
| 6081 | * Return: 0 on success; negative errno otherwise |
| 6082 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6083 | static int drv_cmd_tdls_off_channel(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6084 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6085 | uint8_t *command, |
| 6086 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6087 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6088 | { |
| 6089 | int ret; |
| 6090 | uint8_t *value = command; |
Bala Venkatesh | 07546fb | 2019-07-08 18:29:28 +0530 | [diff] [blame] | 6091 | int channel; |
| 6092 | enum channel_state reg_state; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6093 | |
| 6094 | /* Move pointer to point the string */ |
| 6095 | value += command_len; |
| 6096 | |
Bala Venkatesh | 07546fb | 2019-07-08 18:29:28 +0530 | [diff] [blame] | 6097 | ret = sscanf(value, "%d", &channel); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6098 | if (ret != 1) |
| 6099 | return -EINVAL; |
Bala Venkatesh | 07546fb | 2019-07-08 18:29:28 +0530 | [diff] [blame] | 6100 | reg_state = wlan_reg_get_channel_state(hdd_ctx->pdev, channel); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6101 | |
Bala Venkatesh | 07546fb | 2019-07-08 18:29:28 +0530 | [diff] [blame] | 6102 | if (reg_state == CHANNEL_STATE_DFS || |
| 6103 | reg_state == CHANNEL_STATE_DISABLE || |
| 6104 | reg_state == CHANNEL_STATE_INVALID) { |
| 6105 | hdd_err("reg state of the channel %d is %d and not supported", |
| 6106 | channel, reg_state); |
Krishna Kumaar Natarajan | 4d09035 | 2015-10-26 18:30:53 -0700 | [diff] [blame] | 6107 | return -EINVAL; |
| 6108 | } |
| 6109 | |
Bala Venkatesh | 07546fb | 2019-07-08 18:29:28 +0530 | [diff] [blame] | 6110 | hdd_debug("Tdls offchannel num: %d", channel); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6111 | |
Bala Venkatesh | 07546fb | 2019-07-08 18:29:28 +0530 | [diff] [blame] | 6112 | ret = hdd_set_tdls_offchannel(hdd_ctx, adapter, channel); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6113 | |
| 6114 | return ret; |
| 6115 | } |
| 6116 | |
| 6117 | /** |
| 6118 | * drv_cmd_tdls_scan() - set tdls scan type |
| 6119 | * @adapter: Pointer to the HDD adapter |
| 6120 | * @hdd_ctx: Pointer to the HDD context |
| 6121 | * @command: Driver command string |
| 6122 | * @command_len: Driver command string length |
| 6123 | * @priv_data: Private data coming with the driver command. Unused here |
| 6124 | * |
| 6125 | * This function handles driver command that sets tdls scan type |
| 6126 | * |
| 6127 | * Return: 0 on success; negative errno otherwise |
| 6128 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6129 | static int drv_cmd_tdls_scan(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6130 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6131 | uint8_t *command, |
| 6132 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6133 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6134 | { |
| 6135 | int ret; |
| 6136 | uint8_t *value = command; |
| 6137 | int set_value; |
| 6138 | |
| 6139 | /* Move pointer to point the string */ |
| 6140 | value += command_len; |
| 6141 | |
| 6142 | ret = sscanf(value, "%d", &set_value); |
| 6143 | if (ret != 1) |
| 6144 | return -EINVAL; |
| 6145 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 6146 | hdd_debug("Tdls scan type val: %d", set_value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6147 | |
| 6148 | ret = hdd_set_tdls_scan_type(hdd_ctx, set_value); |
| 6149 | |
| 6150 | return ret; |
| 6151 | } |
| 6152 | #endif |
| 6153 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6154 | static int drv_cmd_get_rssi(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6155 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6156 | uint8_t *command, |
| 6157 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6158 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6159 | { |
Orhan K AKYILDIZ | c409461 | 2015-11-11 18:01:15 -0800 | [diff] [blame] | 6160 | int ret = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6161 | int8_t rssi = 0; |
| 6162 | char extra[32]; |
Orhan K AKYILDIZ | c409461 | 2015-11-11 18:01:15 -0800 | [diff] [blame] | 6163 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6164 | uint8_t len = 0; |
| 6165 | |
| 6166 | wlan_hdd_get_rssi(adapter, &rssi); |
| 6167 | |
| 6168 | len = scnprintf(extra, sizeof(extra), "%s %d", command, rssi); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6169 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6170 | |
| 6171 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 6172 | hdd_err("Failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6173 | ret = -EFAULT; |
| 6174 | } |
| 6175 | |
| 6176 | return ret; |
| 6177 | } |
| 6178 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6179 | static int drv_cmd_get_linkspeed(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6180 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6181 | uint8_t *command, |
| 6182 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6183 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6184 | { |
| 6185 | int ret; |
| 6186 | uint32_t link_speed = 0; |
| 6187 | char extra[32]; |
| 6188 | uint8_t len = 0; |
| 6189 | |
| 6190 | ret = wlan_hdd_get_link_speed(adapter, &link_speed); |
| 6191 | if (0 != ret) |
| 6192 | return ret; |
| 6193 | |
| 6194 | len = scnprintf(extra, sizeof(extra), "%s %d", command, link_speed); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6195 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6196 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 6197 | hdd_err("Failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6198 | ret = -EFAULT; |
| 6199 | } |
| 6200 | |
| 6201 | return ret; |
| 6202 | } |
| 6203 | |
Qiwei Cai | 4505fc6 | 2018-05-17 18:35:19 +0800 | [diff] [blame] | 6204 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6205 | /** |
| 6206 | * hdd_set_rx_filter() - set RX filter |
| 6207 | * @adapter: Pointer to adapter |
| 6208 | * @action: Filter action |
| 6209 | * @pattern: Address pattern |
| 6210 | * |
| 6211 | * Address pattern is most significant byte of address for example |
| 6212 | * 0x01 for IPV4 multicast address |
| 6213 | * 0x33 for IPV6 multicast address |
| 6214 | * 0xFF for broadcast address |
| 6215 | * |
| 6216 | * Return: 0 for success, non-zero for failure |
| 6217 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6218 | static int hdd_set_rx_filter(struct hdd_adapter *adapter, bool action, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6219 | uint8_t pattern) |
| 6220 | { |
| 6221 | int ret; |
Frank Liu | f95e813 | 2016-09-29 19:01:30 +0800 | [diff] [blame] | 6222 | uint8_t i, j; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6223 | tSirRcvFltMcAddrList *filter; |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6224 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6225 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6226 | |
| 6227 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 6228 | if (0 != ret) |
| 6229 | return ret; |
| 6230 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6231 | mac_handle = hdd_ctx->mac_handle; |
| 6232 | if (!mac_handle) { |
| 6233 | hdd_err("MAC Handle is NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6234 | return -EINVAL; |
| 6235 | } |
| 6236 | |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 6237 | if (!ucfg_pmo_is_mc_addr_list_enabled(hdd_ctx->psoc)) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 6238 | hdd_warn("mc addr ini is disabled"); |
Mukul Sharma | 3a1ab30 | 2017-01-15 19:02:37 +0530 | [diff] [blame] | 6239 | return -EINVAL; |
| 6240 | } |
| 6241 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6242 | /* |
| 6243 | * If action is false it means start dropping packets |
| 6244 | * Set addr_filter_pattern which will be used when sending |
| 6245 | * MC/BC address list to target |
| 6246 | */ |
| 6247 | if (!action) |
| 6248 | adapter->addr_filter_pattern = pattern; |
| 6249 | else |
| 6250 | adapter->addr_filter_pattern = 0; |
| 6251 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 6252 | if (((adapter->device_mode == QDF_STA_MODE) || |
| 6253 | (adapter->device_mode == QDF_P2P_CLIENT_MODE)) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6254 | adapter->mc_addr_list.mc_cnt && |
| 6255 | hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
| 6256 | |
| 6257 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6258 | filter = qdf_mem_malloc(sizeof(*filter)); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 6259 | if (!filter) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6260 | hdd_err("Could not allocate Memory"); |
| 6261 | return -ENOMEM; |
| 6262 | } |
| 6263 | filter->action = action; |
Frank Liu | f95e813 | 2016-09-29 19:01:30 +0800 | [diff] [blame] | 6264 | for (i = 0, j = 0; i < adapter->mc_addr_list.mc_cnt; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6265 | if (!memcmp(adapter->mc_addr_list.addr[i], |
| 6266 | &pattern, 1)) { |
Frank Liu | f95e813 | 2016-09-29 19:01:30 +0800 | [diff] [blame] | 6267 | memcpy(filter->multicastAddr[j].bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6268 | adapter->mc_addr_list.addr[i], |
| 6269 | sizeof(adapter->mc_addr_list.addr[i])); |
Frank Liu | f95e813 | 2016-09-29 19:01:30 +0800 | [diff] [blame] | 6270 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 6271 | hdd_debug("%s RX filter : addr =" |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 6272 | QDF_MAC_ADDR_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6273 | action ? "setting" : "clearing", |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 6274 | QDF_MAC_ADDR_ARRAY(filter->multicastAddr[j].bytes)); |
Frank Liu | f95e813 | 2016-09-29 19:01:30 +0800 | [diff] [blame] | 6275 | j++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6276 | } |
SaidiReddy Yenuga | 0b2c9f4 | 2017-02-03 12:26:38 +0530 | [diff] [blame] | 6277 | if (j == SIR_MAX_NUM_MULTICAST_ADDRESS) |
| 6278 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6279 | } |
Frank Liu | f95e813 | 2016-09-29 19:01:30 +0800 | [diff] [blame] | 6280 | filter->ulMulticastAddrCnt = j; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6281 | /* Set rx filter */ |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 6282 | sme_8023_multicast_list(mac_handle, adapter->vdev_id, |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6283 | filter); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6284 | qdf_mem_free(filter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6285 | } else { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 6286 | hdd_debug("mode %d mc_cnt %d", |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6287 | adapter->device_mode, adapter->mc_addr_list.mc_cnt); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6288 | } |
| 6289 | |
| 6290 | return 0; |
| 6291 | } |
| 6292 | |
| 6293 | /** |
Jeff Johnson | 0f7440e | 2018-05-06 16:12:39 -0700 | [diff] [blame] | 6294 | * hdd_driver_rxfilter_command_handler() - RXFILTER driver command handler |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6295 | * @command: Pointer to input string driver command |
| 6296 | * @adapter: Pointer to adapter |
| 6297 | * @action: Action to enable/disable filtering |
| 6298 | * |
| 6299 | * If action == false |
| 6300 | * Start filtering out data packets based on type |
| 6301 | * RXFILTER-REMOVE 0 -> Start filtering out unicast data packets |
| 6302 | * RXFILTER-REMOVE 1 -> Start filtering out broadcast data packets |
| 6303 | * RXFILTER-REMOVE 2 -> Start filtering out IPV4 mcast data packets |
| 6304 | * RXFILTER-REMOVE 3 -> Start filtering out IPV6 mcast data packets |
| 6305 | * |
| 6306 | * if action == true |
| 6307 | * Stop filtering data packets based on type |
| 6308 | * RXFILTER-ADD 0 -> Stop filtering unicast data packets |
| 6309 | * RXFILTER-ADD 1 -> Stop filtering broadcast data packets |
| 6310 | * RXFILTER-ADD 2 -> Stop filtering IPV4 mcast data packets |
| 6311 | * RXFILTER-ADD 3 -> Stop filtering IPV6 mcast data packets |
| 6312 | * |
| 6313 | * Current implementation only supports IPV4 address filtering by |
| 6314 | * selectively allowing IPV4 multicast data packest based on |
| 6315 | * address list received in .ndo_set_rx_mode |
| 6316 | * |
| 6317 | * Return: 0 for success, non-zero for failure |
| 6318 | */ |
Jeff Johnson | 0f7440e | 2018-05-06 16:12:39 -0700 | [diff] [blame] | 6319 | static int hdd_driver_rxfilter_command_handler(uint8_t *command, |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6320 | struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6321 | bool action) |
| 6322 | { |
| 6323 | int ret = 0; |
| 6324 | uint8_t *value; |
| 6325 | uint8_t type; |
| 6326 | |
| 6327 | value = command; |
| 6328 | /* Skip space after RXFILTER-REMOVE OR RXFILTER-ADD based on action */ |
| 6329 | if (!action) |
| 6330 | value = command + 16; |
| 6331 | else |
| 6332 | value = command + 13; |
| 6333 | ret = kstrtou8(value, 10, &type); |
| 6334 | if (ret < 0) { |
Dustin Brown | 933cd2a | 2018-04-18 11:28:15 -0700 | [diff] [blame] | 6335 | hdd_err("kstrtou8 failed invalid input value"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6336 | return -EINVAL; |
| 6337 | } |
| 6338 | |
| 6339 | switch (type) { |
| 6340 | case 2: |
| 6341 | /* Set rx filter for IPV4 multicast data packets */ |
| 6342 | ret = hdd_set_rx_filter(adapter, action, 0x01); |
| 6343 | break; |
| 6344 | default: |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 6345 | hdd_warn("Unsupported RXFILTER type %d", type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6346 | break; |
| 6347 | } |
| 6348 | |
| 6349 | return ret; |
| 6350 | } |
| 6351 | |
| 6352 | /** |
| 6353 | * drv_cmd_rx_filter_remove() - RXFILTER REMOVE driver command handler |
| 6354 | * @adapter: Pointer to network adapter |
| 6355 | * @hdd_ctx: Pointer to hdd context |
| 6356 | * @command: Pointer to input command |
| 6357 | * @command_len: Command length |
| 6358 | * @priv_data: Pointer to private data in command |
| 6359 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6360 | static int drv_cmd_rx_filter_remove(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6361 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6362 | uint8_t *command, |
| 6363 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6364 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6365 | { |
Jeff Johnson | 0f7440e | 2018-05-06 16:12:39 -0700 | [diff] [blame] | 6366 | return hdd_driver_rxfilter_command_handler(command, adapter, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6367 | } |
| 6368 | |
| 6369 | /** |
| 6370 | * drv_cmd_rx_filter_add() - RXFILTER ADD driver command handler |
| 6371 | * @adapter: Pointer to network adapter |
| 6372 | * @hdd_ctx: Pointer to hdd context |
| 6373 | * @command: Pointer to input command |
| 6374 | * @command_len: Command length |
| 6375 | * @priv_data: Pointer to private data in command |
| 6376 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6377 | static int drv_cmd_rx_filter_add(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6378 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6379 | uint8_t *command, |
| 6380 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6381 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6382 | { |
Jeff Johnson | 0f7440e | 2018-05-06 16:12:39 -0700 | [diff] [blame] | 6383 | return hdd_driver_rxfilter_command_handler(command, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6384 | } |
Qiwei Cai | 4505fc6 | 2018-05-17 18:35:19 +0800 | [diff] [blame] | 6385 | #endif /* WLAN_FEATURE_PACKET_FILTERING */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6386 | |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6387 | /** |
| 6388 | * hdd_parse_setantennamode_command() - HDD Parse SETANTENNAMODE |
| 6389 | * command |
| 6390 | * @value: Pointer to SETANTENNAMODE command |
| 6391 | * @mode: Pointer to antenna mode |
| 6392 | * @reason: Pointer to reason for set antenna mode |
| 6393 | * |
| 6394 | * This function parses the SETANTENNAMODE command passed in the format |
| 6395 | * SETANTENNAMODE<space>mode |
| 6396 | * |
| 6397 | * Return: 0 for success non-zero for failure |
| 6398 | */ |
| 6399 | static int hdd_parse_setantennamode_command(const uint8_t *value) |
| 6400 | { |
| 6401 | const uint8_t *in_ptr = value; |
| 6402 | int tmp, v; |
| 6403 | char arg1[32]; |
| 6404 | |
| 6405 | in_ptr = strnchr(value, strlen(value), SPACE_ASCII_VALUE); |
| 6406 | |
| 6407 | /* no argument after the command */ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 6408 | if (!in_ptr) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 6409 | hdd_err("No argument after the command"); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6410 | return -EINVAL; |
| 6411 | } |
| 6412 | |
| 6413 | /* no space after the command */ |
| 6414 | if (SPACE_ASCII_VALUE != *in_ptr) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 6415 | hdd_err("No space after the command"); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6416 | return -EINVAL; |
| 6417 | } |
| 6418 | |
| 6419 | /* remove empty spaces */ |
| 6420 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 6421 | in_ptr++; |
| 6422 | |
| 6423 | /* no argument followed by spaces */ |
| 6424 | if ('\0' == *in_ptr) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 6425 | hdd_err("No argument followed by spaces"); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6426 | return -EINVAL; |
| 6427 | } |
| 6428 | |
| 6429 | /* get the argument i.e. antenna mode */ |
| 6430 | v = sscanf(in_ptr, "%31s ", arg1); |
| 6431 | if (1 != v) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 6432 | hdd_err("argument retrieval from cmd string failed"); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6433 | return -EINVAL; |
| 6434 | } |
| 6435 | |
| 6436 | v = kstrtos32(arg1, 10, &tmp); |
| 6437 | if (v < 0) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 6438 | hdd_err("argument string to int conversion failed"); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6439 | return -EINVAL; |
| 6440 | } |
| 6441 | |
| 6442 | return tmp; |
| 6443 | } |
| 6444 | |
| 6445 | /** |
| 6446 | * hdd_is_supported_chain_mask_2x2() - Verify if supported chain |
| 6447 | * mask is 2x2 mode |
| 6448 | * @hdd_ctx: Pointer to hdd contex |
| 6449 | * |
| 6450 | * Return: true if supported chain mask 2x2 else false |
| 6451 | */ |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6452 | static bool hdd_is_supported_chain_mask_2x2(struct hdd_context *hdd_ctx) |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6453 | { |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 6454 | QDF_STATUS status; |
| 6455 | bool bval = false; |
| 6456 | |
| 6457 | /* |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6458 | * Revisit and the update logic to determine the number |
| 6459 | * of TX/RX chains supported in the system when |
| 6460 | * antenna sharing per band chain mask support is |
| 6461 | * brought in |
| 6462 | */ |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 6463 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 6464 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 6465 | hdd_err("unable to get vht_enable2x2"); |
| 6466 | |
| 6467 | return (bval == 0x01) ? true : false; |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6468 | } |
| 6469 | |
| 6470 | /** |
| 6471 | * hdd_is_supported_chain_mask_1x1() - Verify if the supported |
| 6472 | * chain mask is 1x1 |
| 6473 | * @hdd_ctx: Pointer to hdd contex |
| 6474 | * |
| 6475 | * Return: true if supported chain mask 1x1 else false |
| 6476 | */ |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6477 | static bool hdd_is_supported_chain_mask_1x1(struct hdd_context *hdd_ctx) |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6478 | { |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 6479 | QDF_STATUS status; |
| 6480 | bool bval = false; |
| 6481 | |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6482 | /* |
| 6483 | * Revisit and update the logic to determine the number |
| 6484 | * of TX/RX chains supported in the system when |
| 6485 | * antenna sharing per band chain mask support is |
| 6486 | * brought in |
| 6487 | */ |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 6488 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 6489 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 6490 | hdd_err("unable to get vht_enable2x2"); |
| 6491 | |
| 6492 | return (!bval) ? true : false; |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6493 | } |
| 6494 | |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6495 | QDF_STATUS hdd_update_smps_antenna_mode(struct hdd_context *hdd_ctx, int mode) |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 6496 | { |
| 6497 | QDF_STATUS status; |
| 6498 | uint8_t smps_mode; |
| 6499 | uint8_t smps_enable; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6500 | mac_handle_t mac_handle; |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 6501 | |
| 6502 | /* Update SME SMPS config */ |
| 6503 | if (HDD_ANTENNA_MODE_1X1 == mode) { |
| 6504 | smps_enable = true; |
| 6505 | smps_mode = HDD_SMPS_MODE_STATIC; |
| 6506 | } else { |
| 6507 | smps_enable = false; |
| 6508 | smps_mode = HDD_SMPS_MODE_DISABLED; |
| 6509 | } |
| 6510 | |
| 6511 | hdd_debug("Update SME SMPS enable: %d mode: %d", |
| 6512 | smps_enable, smps_mode); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6513 | mac_handle = hdd_ctx->mac_handle; |
| 6514 | status = sme_update_mimo_power_save(mac_handle, smps_enable, |
| 6515 | smps_mode, false); |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 6516 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6517 | hdd_err("Update SMPS config failed enable: %d mode: %d status: %d", |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 6518 | smps_enable, smps_mode, status); |
| 6519 | return QDF_STATUS_E_FAILURE; |
| 6520 | } |
| 6521 | |
| 6522 | hdd_ctx->current_antenna_mode = mode; |
| 6523 | /* |
| 6524 | * Update the user requested nss in the mac context. |
| 6525 | * This will be used in tdls protocol engine to form tdls |
| 6526 | * Management frames. |
| 6527 | */ |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6528 | sme_update_user_configured_nss(mac_handle, |
| 6529 | hdd_ctx->current_antenna_mode); |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 6530 | |
| 6531 | hdd_debug("Successfully switched to mode: %d x %d", |
| 6532 | hdd_ctx->current_antenna_mode, |
| 6533 | hdd_ctx->current_antenna_mode); |
| 6534 | |
| 6535 | return QDF_STATUS_SUCCESS; |
| 6536 | } |
| 6537 | |
Dundi Raviteja | 4016e93 | 2018-08-02 12:16:25 +0530 | [diff] [blame] | 6538 | /** |
| 6539 | * wlan_hdd_soc_set_antenna_mode_cb() - Callback for set antenna mode |
| 6540 | * @status: Status of set antenna mode |
| 6541 | * @context: callback context |
| 6542 | * |
| 6543 | * Callback on setting antenna mode |
| 6544 | * |
| 6545 | * Return: None |
| 6546 | */ |
| 6547 | static void |
| 6548 | wlan_hdd_soc_set_antenna_mode_cb(enum set_antenna_mode_status status, |
| 6549 | void *context) |
| 6550 | { |
| 6551 | struct osif_request *request = NULL; |
| 6552 | |
| 6553 | hdd_debug("Status: %d", status); |
| 6554 | |
| 6555 | request = osif_request_get(context); |
| 6556 | if (!request) { |
| 6557 | hdd_err("obselete request"); |
| 6558 | return; |
| 6559 | } |
| 6560 | |
| 6561 | /* Signal the completion of set dual mac config */ |
| 6562 | osif_request_complete(request); |
| 6563 | osif_request_put(request); |
| 6564 | } |
| 6565 | |
gaurank kathpalia | 7cb6a32 | 2018-10-24 19:50:34 +0530 | [diff] [blame] | 6566 | static QDF_STATUS |
| 6567 | hdd_populate_vdev_chains(struct wlan_mlme_nss_chains *nss_chains_cfg, |
| 6568 | uint8_t tx_chains, |
| 6569 | uint8_t rx_chains, |
| 6570 | enum nss_chains_band_info band, |
| 6571 | struct wlan_objmgr_vdev *vdev) |
| 6572 | { |
| 6573 | struct wlan_mlme_nss_chains *dynamic_cfg; |
| 6574 | |
| 6575 | nss_chains_cfg->num_rx_chains[band] = rx_chains; |
| 6576 | nss_chains_cfg->num_tx_chains[band] = tx_chains; |
| 6577 | |
gaurank kathpalia | b414bce | 2018-11-09 18:44:46 +0530 | [diff] [blame] | 6578 | dynamic_cfg = ucfg_mlme_get_dynamic_vdev_config(vdev); |
gaurank kathpalia | 7cb6a32 | 2018-10-24 19:50:34 +0530 | [diff] [blame] | 6579 | if (!dynamic_cfg) { |
| 6580 | hdd_err("nss chain dynamic config NULL"); |
| 6581 | return QDF_STATUS_E_FAILURE; |
| 6582 | } |
| 6583 | /* |
| 6584 | * If user gives any nss value, then chains will be adjusted based on |
| 6585 | * nss (in SME func sme_validate_user_nss_chain_params). |
| 6586 | * If Chains are not suitable as per current NSS then, we need to |
| 6587 | * return, and the below logic is added for the same. |
| 6588 | */ |
| 6589 | |
| 6590 | if ((dynamic_cfg->rx_nss[band] > rx_chains) || |
| 6591 | (dynamic_cfg->tx_nss[band] > tx_chains)) { |
| 6592 | hdd_err("Chains less than nss, configure correct nss first."); |
| 6593 | return QDF_STATUS_E_FAILURE; |
| 6594 | } |
| 6595 | |
| 6596 | return QDF_STATUS_SUCCESS; |
| 6597 | } |
| 6598 | |
| 6599 | static int |
| 6600 | hdd_set_dynamic_antenna_mode(struct hdd_adapter *adapter, |
| 6601 | uint8_t num_rx_chains, |
| 6602 | uint8_t num_tx_chains) |
| 6603 | { |
| 6604 | enum nss_chains_band_info band; |
| 6605 | struct wlan_mlme_nss_chains user_cfg; |
| 6606 | QDF_STATUS status; |
| 6607 | mac_handle_t mac_handle; |
| 6608 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6609 | |
| 6610 | mac_handle = hdd_ctx->mac_handle; |
| 6611 | if (!mac_handle) { |
| 6612 | hdd_err("NULL MAC handle"); |
| 6613 | return -EINVAL; |
| 6614 | } |
| 6615 | |
gaurank kathpalia | 6982d47 | 2018-10-31 21:54:15 +0530 | [diff] [blame] | 6616 | if (!hdd_is_vdev_in_conn_state(adapter)) { |
| 6617 | hdd_debug("Vdev (id %d) not in connected/started state, cannot accept command", |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 6618 | adapter->vdev_id); |
gaurank kathpalia | 6982d47 | 2018-10-31 21:54:15 +0530 | [diff] [blame] | 6619 | return -EINVAL; |
| 6620 | } |
| 6621 | |
gaurank kathpalia | 7cb6a32 | 2018-10-24 19:50:34 +0530 | [diff] [blame] | 6622 | qdf_mem_zero(&user_cfg, sizeof(user_cfg)); |
gaurank kathpalia | b414bce | 2018-11-09 18:44:46 +0530 | [diff] [blame] | 6623 | for (band = NSS_CHAINS_BAND_2GHZ; band < NSS_CHAINS_BAND_MAX; band++) { |
gaurank kathpalia | 7cb6a32 | 2018-10-24 19:50:34 +0530 | [diff] [blame] | 6624 | status = hdd_populate_vdev_chains(&user_cfg, |
| 6625 | num_rx_chains, |
| 6626 | num_tx_chains, band, |
| 6627 | adapter->vdev); |
| 6628 | if (QDF_IS_STATUS_ERROR(status)) |
| 6629 | return -EINVAL; |
| 6630 | } |
| 6631 | status = sme_nss_chains_update(mac_handle, |
| 6632 | &user_cfg, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 6633 | adapter->vdev_id); |
gaurank kathpalia | 7cb6a32 | 2018-10-24 19:50:34 +0530 | [diff] [blame] | 6634 | if (QDF_IS_STATUS_ERROR(status)) |
| 6635 | return -EINVAL; |
| 6636 | |
| 6637 | return 0; |
| 6638 | } |
Abhishek Singh | 1571ca7 | 2018-04-17 15:14:21 +0530 | [diff] [blame] | 6639 | int hdd_set_antenna_mode(struct hdd_adapter *adapter, |
| 6640 | struct hdd_context *hdd_ctx, int mode) |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6641 | { |
| 6642 | struct sir_antenna_mode_param params; |
| 6643 | QDF_STATUS status; |
| 6644 | int ret = 0; |
Dundi Raviteja | 6bb9e32 | 2018-05-16 17:04:41 +0530 | [diff] [blame] | 6645 | struct osif_request *request = NULL; |
| 6646 | static const struct osif_request_params request_params = { |
| 6647 | .priv_size = 0, |
Abhishek Singh | d1f21c7 | 2019-01-21 15:16:34 +0530 | [diff] [blame] | 6648 | .timeout_ms = SME_POLICY_MGR_CMD_TIMEOUT, |
Dundi Raviteja | 6bb9e32 | 2018-05-16 17:04:41 +0530 | [diff] [blame] | 6649 | }; |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6650 | |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6651 | switch (mode) { |
| 6652 | case HDD_ANTENNA_MODE_1X1: |
| 6653 | params.num_rx_chains = 1; |
| 6654 | params.num_tx_chains = 1; |
| 6655 | break; |
| 6656 | case HDD_ANTENNA_MODE_2X2: |
| 6657 | params.num_rx_chains = 2; |
| 6658 | params.num_tx_chains = 2; |
| 6659 | break; |
| 6660 | default: |
| 6661 | hdd_err("unsupported antenna mode"); |
| 6662 | ret = -EINVAL; |
| 6663 | goto exit; |
| 6664 | } |
| 6665 | |
gaurank kathpalia | 1281b30 | 2018-11-05 21:10:37 +0530 | [diff] [blame] | 6666 | if (hdd_ctx->dynamic_nss_chains_support) |
gaurank kathpalia | 7cb6a32 | 2018-10-24 19:50:34 +0530 | [diff] [blame] | 6667 | return hdd_set_dynamic_antenna_mode(adapter, |
| 6668 | params.num_rx_chains, |
| 6669 | params.num_tx_chains); |
gaurank kathpalia | 7cb6a32 | 2018-10-24 19:50:34 +0530 | [diff] [blame] | 6670 | |
gaurank kathpalia | f95ae68 | 2018-11-05 21:13:07 +0530 | [diff] [blame] | 6671 | if ((HDD_ANTENNA_MODE_2X2 == mode) && |
| 6672 | (!hdd_is_supported_chain_mask_2x2(hdd_ctx))) { |
| 6673 | hdd_err("System does not support 2x2 mode"); |
| 6674 | ret = -EPERM; |
| 6675 | goto exit; |
| 6676 | } |
| 6677 | |
| 6678 | if ((HDD_ANTENNA_MODE_1X1 == mode) && |
| 6679 | hdd_is_supported_chain_mask_1x1(hdd_ctx)) { |
| 6680 | hdd_err("System only supports 1x1 mode"); |
| 6681 | goto exit; |
| 6682 | } |
| 6683 | |
Archana Ramachandran | d5d2e92 | 2016-04-20 16:57:35 -0700 | [diff] [blame] | 6684 | /* Check TDLS status and update antenna mode */ |
| 6685 | if ((QDF_STA_MODE == adapter->device_mode) && |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 6686 | policy_mgr_is_sta_active_connection_exists(hdd_ctx->psoc)) { |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6687 | ret = wlan_hdd_tdls_antenna_switch(hdd_ctx, adapter, mode); |
Archana Ramachandran | d5d2e92 | 2016-04-20 16:57:35 -0700 | [diff] [blame] | 6688 | if (0 != ret) |
| 6689 | goto exit; |
| 6690 | } |
| 6691 | |
Dundi Raviteja | 6bb9e32 | 2018-05-16 17:04:41 +0530 | [diff] [blame] | 6692 | request = osif_request_alloc(&request_params); |
| 6693 | if (!request) { |
| 6694 | hdd_err("Request Allocation Failure"); |
| 6695 | ret = -ENOMEM; |
| 6696 | goto exit; |
| 6697 | } |
| 6698 | |
| 6699 | params.set_antenna_mode_ctx = osif_request_cookie(request); |
| 6700 | params.set_antenna_mode_resp = (void *)wlan_hdd_soc_set_antenna_mode_cb; |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 6701 | hdd_debug("Set antenna mode rx chains: %d tx chains: %d", |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6702 | params.num_rx_chains, |
| 6703 | params.num_tx_chains); |
| 6704 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6705 | status = sme_soc_set_antenna_mode(hdd_ctx->mac_handle, ¶ms); |
Abhishek Singh | 1571ca7 | 2018-04-17 15:14:21 +0530 | [diff] [blame] | 6706 | if (QDF_IS_STATUS_ERROR(status)) { |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6707 | hdd_err("set antenna mode failed status : %d", status); |
| 6708 | ret = -EFAULT; |
Dundi Raviteja | 6bb9e32 | 2018-05-16 17:04:41 +0530 | [diff] [blame] | 6709 | goto request_put; |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6710 | } |
| 6711 | |
Dundi Raviteja | 6bb9e32 | 2018-05-16 17:04:41 +0530 | [diff] [blame] | 6712 | ret = osif_request_wait_for_response(request); |
| 6713 | if (ret) { |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6714 | hdd_err("send set antenna mode timed out"); |
Dundi Raviteja | 6bb9e32 | 2018-05-16 17:04:41 +0530 | [diff] [blame] | 6715 | goto request_put; |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6716 | } |
| 6717 | |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 6718 | status = hdd_update_smps_antenna_mode(hdd_ctx, mode); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6719 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6720 | ret = -EFAULT; |
Dundi Raviteja | 6bb9e32 | 2018-05-16 17:04:41 +0530 | [diff] [blame] | 6721 | goto request_put; |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6722 | } |
Archana Ramachandran | 5041b25 | 2016-04-25 14:29:25 -0700 | [diff] [blame] | 6723 | ret = 0; |
Dundi Raviteja | 6bb9e32 | 2018-05-16 17:04:41 +0530 | [diff] [blame] | 6724 | request_put: |
| 6725 | osif_request_put(request); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6726 | exit: |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 6727 | hdd_debug("Set antenna status: %d current mode: %d", |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6728 | ret, hdd_ctx->current_antenna_mode); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6729 | |
Abhishek Singh | 1571ca7 | 2018-04-17 15:14:21 +0530 | [diff] [blame] | 6730 | return ret; |
| 6731 | } |
gaurank kathpalia | b414bce | 2018-11-09 18:44:46 +0530 | [diff] [blame] | 6732 | |
Abhishek Singh | 1571ca7 | 2018-04-17 15:14:21 +0530 | [diff] [blame] | 6733 | /** |
| 6734 | * drv_cmd_set_antenna_mode() - SET ANTENNA MODE driver command |
| 6735 | * handler |
| 6736 | * @adapter: Pointer to network adapter |
| 6737 | * @hdd_ctx: Pointer to hdd context |
| 6738 | * @command: Pointer to input command |
| 6739 | * @command_len: Command length |
| 6740 | * @priv_data: Pointer to private data in command |
| 6741 | */ |
| 6742 | static int drv_cmd_set_antenna_mode(struct hdd_adapter *adapter, |
| 6743 | struct hdd_context *hdd_ctx, |
| 6744 | uint8_t *command, |
| 6745 | uint8_t command_len, |
| 6746 | struct hdd_priv_data *priv_data) |
| 6747 | { |
| 6748 | int mode; |
| 6749 | uint8_t *value = command; |
| 6750 | |
| 6751 | mode = hdd_parse_setantennamode_command(value); |
| 6752 | if (mode < 0) { |
| 6753 | hdd_err("Invalid SETANTENNA command"); |
| 6754 | return mode; |
| 6755 | } |
| 6756 | |
| 6757 | hdd_debug("Processing antenna mode switch to: %d", mode); |
| 6758 | |
| 6759 | return hdd_set_antenna_mode(adapter, hdd_ctx, mode); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6760 | } |
| 6761 | |
| 6762 | /** |
gaurank kathpalia | 2472fb9 | 2018-10-31 17:40:18 +0530 | [diff] [blame] | 6763 | * hdd_get_dynamic_antenna_mode() -get the dynamic antenna mode for vdev |
| 6764 | * @antenna_mode: pointer to antenna mode of vdev |
| 6765 | * @dynamic_nss_chains_support: feature support for dynamic nss chains update |
| 6766 | * @vdev: Pointer to vdev |
| 6767 | * |
| 6768 | * This API will check for the num of chains configured for the vdev, and fill |
| 6769 | * that info in the antenna mode if the dynamic chains per vdev are supported. |
| 6770 | * |
| 6771 | * Return: None |
| 6772 | */ |
| 6773 | static void |
| 6774 | hdd_get_dynamic_antenna_mode(uint32_t *antenna_mode, |
| 6775 | bool dynamic_nss_chains_support, |
| 6776 | struct wlan_objmgr_vdev *vdev) |
| 6777 | { |
| 6778 | struct wlan_mlme_nss_chains *nss_chains_dynamic_cfg; |
| 6779 | |
| 6780 | if (!dynamic_nss_chains_support) |
| 6781 | return; |
| 6782 | |
gaurank kathpalia | b414bce | 2018-11-09 18:44:46 +0530 | [diff] [blame] | 6783 | nss_chains_dynamic_cfg = ucfg_mlme_get_dynamic_vdev_config(vdev); |
gaurank kathpalia | 2472fb9 | 2018-10-31 17:40:18 +0530 | [diff] [blame] | 6784 | if (!nss_chains_dynamic_cfg) { |
| 6785 | hdd_err("nss chain dynamic config NULL"); |
| 6786 | return; |
| 6787 | } |
| 6788 | /* |
| 6789 | * At present, this command doesn't include band, so by default |
| 6790 | * it will return the band 2ghz present rf chains. |
| 6791 | */ |
gaurank kathpalia | b414bce | 2018-11-09 18:44:46 +0530 | [diff] [blame] | 6792 | *antenna_mode = |
| 6793 | nss_chains_dynamic_cfg->num_rx_chains[NSS_CHAINS_BAND_2GHZ]; |
gaurank kathpalia | 2472fb9 | 2018-10-31 17:40:18 +0530 | [diff] [blame] | 6794 | } |
| 6795 | |
| 6796 | /** |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6797 | * drv_cmd_get_antenna_mode() - GET ANTENNA MODE driver command |
| 6798 | * handler |
| 6799 | * @adapter: Pointer to hdd adapter |
| 6800 | * @hdd_ctx: Pointer to hdd context |
| 6801 | * @command: Pointer to input command |
| 6802 | * @command_len: length of the command |
| 6803 | * @priv_data: private data coming with the driver command |
| 6804 | * |
| 6805 | * Return: 0 for success non-zero for failure |
| 6806 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6807 | static inline int drv_cmd_get_antenna_mode(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6808 | struct hdd_context *hdd_ctx, |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6809 | uint8_t *command, |
| 6810 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6811 | struct hdd_priv_data *priv_data) |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6812 | { |
| 6813 | uint32_t antenna_mode = 0; |
| 6814 | char extra[32]; |
| 6815 | uint8_t len = 0; |
| 6816 | |
| 6817 | antenna_mode = hdd_ctx->current_antenna_mode; |
gaurank kathpalia | 2472fb9 | 2018-10-31 17:40:18 +0530 | [diff] [blame] | 6818 | /* Overwrite this antenna mode if dynamic vdev chains are supported */ |
| 6819 | hdd_get_dynamic_antenna_mode(&antenna_mode, |
| 6820 | hdd_ctx->dynamic_nss_chains_support, |
| 6821 | adapter->vdev); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6822 | len = scnprintf(extra, sizeof(extra), "%s %d", command, |
| 6823 | antenna_mode); |
| 6824 | len = QDF_MIN(priv_data->total_len, len + 1); |
| 6825 | if (copy_to_user(priv_data->buf, &extra, len)) { |
| 6826 | hdd_err("Failed to copy data to user buffer"); |
| 6827 | return -EFAULT; |
| 6828 | } |
| 6829 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 6830 | hdd_debug("Get antenna mode: %d", antenna_mode); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6831 | |
| 6832 | return 0; |
| 6833 | } |
| 6834 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6835 | /* |
| 6836 | * dummy (no-op) hdd driver command handler |
| 6837 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6838 | static int drv_cmd_dummy(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6839 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6840 | uint8_t *command, |
| 6841 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6842 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6843 | { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 6844 | hdd_debug("%s: Ignoring driver command \"%s\"", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6845 | adapter->dev->name, command); |
| 6846 | return 0; |
| 6847 | } |
| 6848 | |
| 6849 | /* |
| 6850 | * handler for any unsupported wlan hdd driver command |
| 6851 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6852 | static int drv_cmd_invalid(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6853 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6854 | uint8_t *command, |
| 6855 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6856 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6857 | { |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 6858 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 6859 | TRACE_CODE_HDD_UNSUPPORTED_IOCTL, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 6860 | adapter->vdev_id, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6861 | |
| 6862 | hdd_warn("%s: Unsupported driver command \"%s\"", |
| 6863 | adapter->dev->name, command); |
| 6864 | |
| 6865 | return -ENOTSUPP; |
| 6866 | } |
| 6867 | |
| 6868 | /** |
Rajeev Kumar Sirasanagandla | 1a21bf6 | 2019-04-08 15:28:57 +0530 | [diff] [blame] | 6869 | * drv_cmd_set_fcc_channel() - Handle fcc constraint request |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6870 | * @adapter: HDD adapter |
| 6871 | * @hdd_ctx: HDD context |
Rajeev Kumar Sirasanagandla | 1a21bf6 | 2019-04-08 15:28:57 +0530 | [diff] [blame] | 6872 | * @command: command ptr, SET_FCC_CHANNEL 0/-1 is the command |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6873 | * @command_len: command len |
| 6874 | * @priv_data: private data |
| 6875 | * |
| 6876 | * Return: status |
| 6877 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6878 | static int drv_cmd_set_fcc_channel(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6879 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6880 | uint8_t *command, |
| 6881 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6882 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6883 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6884 | QDF_STATUS status; |
Rajeev Kumar Sirasanagandla | 1a21bf6 | 2019-04-08 15:28:57 +0530 | [diff] [blame] | 6885 | int8_t input_value; |
| 6886 | bool fcc_constraint; |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 6887 | int err; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6888 | |
| 6889 | /* |
Rajeev Kumar Sirasanagandla | 1a21bf6 | 2019-04-08 15:28:57 +0530 | [diff] [blame] | 6890 | * This command would be called by user-space when it detects WLAN |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6891 | * ON after airplane mode is set. When APM is set, WLAN turns off. |
| 6892 | * But it can be turned back on. Otherwise; when APM is turned back |
| 6893 | * off, WLAN would turn back on. So at that point the command is |
Rajeev Kumar Sirasanagandla | 1a21bf6 | 2019-04-08 15:28:57 +0530 | [diff] [blame] | 6894 | * expected to come down. 0 means reduce power as per fcc constraint |
| 6895 | * and -1 means remove constraint. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6896 | */ |
| 6897 | |
Rajeev Kumar Sirasanagandla | 1a21bf6 | 2019-04-08 15:28:57 +0530 | [diff] [blame] | 6898 | err = kstrtos8(command + command_len + 1, 10, &input_value); |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 6899 | if (err) { |
| 6900 | hdd_err("error %d parsing userspace fcc parameter", err); |
| 6901 | return err; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6902 | } |
| 6903 | |
Rajeev Kumar Sirasanagandla | 1a21bf6 | 2019-04-08 15:28:57 +0530 | [diff] [blame] | 6904 | fcc_constraint = input_value ? false : true; |
| 6905 | hdd_debug("input_value = %d && fcc_constraint = %u", |
| 6906 | input_value, fcc_constraint); |
| 6907 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 6908 | status = ucfg_reg_set_fcc_constraint(hdd_ctx->pdev, fcc_constraint); |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 6909 | |
| 6910 | if (QDF_IS_STATUS_ERROR(status)) |
| 6911 | hdd_err("Failed to %s tx power for channels 12/13", |
Rajeev Kumar Sirasanagandla | 1a21bf6 | 2019-04-08 15:28:57 +0530 | [diff] [blame] | 6912 | fcc_constraint ? "restore" : "reduce"); |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 6913 | |
| 6914 | return qdf_status_to_os_return(status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6915 | } |
| 6916 | |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 6917 | /** |
| 6918 | * hdd_parse_set_channel_switch_command() - Parse and validate CHANNEL_SWITCH |
| 6919 | * command |
| 6920 | * @value: Pointer to the command |
| 6921 | * @chan_number: Pointer to the channel number |
| 6922 | * @chan_bw: Pointer to the channel bandwidth |
| 6923 | * |
| 6924 | * Parses and provides the channel number and channel width from the input |
| 6925 | * command which is expected to be of the format: CHANNEL_SWITCH <CH> <BW> |
| 6926 | * <CH> is channel number to move (where 1 = channel 1, 149 = channel 149, ...) |
| 6927 | * <BW> is bandwidth to move (where 20 = BW 20, 40 = BW 40, 80 = BW 80) |
| 6928 | * |
| 6929 | * Return: 0 for success, non-zero for failure |
| 6930 | */ |
| 6931 | static int hdd_parse_set_channel_switch_command(uint8_t *value, |
| 6932 | uint32_t *chan_number, |
| 6933 | uint32_t *chan_bw) |
| 6934 | { |
| 6935 | const uint8_t *in_ptr = value; |
| 6936 | int ret; |
| 6937 | |
| 6938 | in_ptr = strnchr(value, strlen(value), SPACE_ASCII_VALUE); |
| 6939 | |
| 6940 | /* no argument after the command */ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 6941 | if (!in_ptr) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 6942 | hdd_err("No argument after the command"); |
| 6943 | return -EINVAL; |
| 6944 | } |
| 6945 | |
| 6946 | /* no space after the command */ |
| 6947 | if (SPACE_ASCII_VALUE != *in_ptr) { |
| 6948 | hdd_err("No space after the command "); |
| 6949 | return -EINVAL; |
| 6950 | } |
| 6951 | |
| 6952 | /* remove empty spaces and move the next argument */ |
| 6953 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 6954 | in_ptr++; |
| 6955 | |
| 6956 | /* no argument followed by spaces */ |
| 6957 | if ('\0' == *in_ptr) { |
| 6958 | hdd_err("No argument followed by spaces"); |
| 6959 | return -EINVAL; |
| 6960 | } |
| 6961 | |
| 6962 | /* get the two arguments: channel number and bandwidth */ |
| 6963 | ret = sscanf(in_ptr, "%u %u", chan_number, chan_bw); |
| 6964 | if (ret != 2) { |
| 6965 | hdd_err("Arguments retrieval from cmd string failed"); |
| 6966 | return -EINVAL; |
| 6967 | } |
| 6968 | |
| 6969 | return 0; |
| 6970 | } |
| 6971 | |
| 6972 | /** |
| 6973 | * drv_cmd_set_channel_switch() - Switch SAP/P2P-GO operating channel |
| 6974 | * @adapter: HDD adapter |
| 6975 | * @hdd_ctx: HDD context |
| 6976 | * @command: Pointer to the input command CHANNEL_SWITCH |
| 6977 | * @command_len: Command len |
| 6978 | * @priv_data: Private data |
| 6979 | * |
| 6980 | * Handles private IOCTL CHANNEL_SWITCH command to switch the operating channel |
| 6981 | * of SAP/P2P-GO |
| 6982 | * |
| 6983 | * Return: 0 for success, non-zero for failure |
| 6984 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6985 | static int drv_cmd_set_channel_switch(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6986 | struct hdd_context *hdd_ctx, |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 6987 | uint8_t *command, |
| 6988 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6989 | struct hdd_priv_data *priv_data) |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 6990 | { |
| 6991 | struct net_device *dev = adapter->dev; |
| 6992 | int status; |
| 6993 | uint32_t chan_number = 0, chan_bw = 0; |
| 6994 | uint8_t *value = command; |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 6995 | enum phy_ch_width width; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 6996 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 6997 | if ((adapter->device_mode != QDF_P2P_GO_MODE) && |
| 6998 | (adapter->device_mode != QDF_SAP_MODE)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 6999 | hdd_err("IOCTL CHANNEL_SWITCH not supported for mode %d", |
| 7000 | adapter->device_mode); |
| 7001 | return -EINVAL; |
| 7002 | } |
| 7003 | |
| 7004 | status = hdd_parse_set_channel_switch_command(value, |
| 7005 | &chan_number, &chan_bw); |
| 7006 | if (status) { |
| 7007 | hdd_err("Invalid CHANNEL_SWITCH command"); |
| 7008 | return status; |
| 7009 | } |
| 7010 | |
| 7011 | if ((chan_bw != 20) && (chan_bw != 40) && (chan_bw != 80)) { |
| 7012 | hdd_err("BW %d is not allowed for CHANNEL_SWITCH", chan_bw); |
| 7013 | return -EINVAL; |
| 7014 | } |
| 7015 | |
| 7016 | if (chan_bw == 80) |
| 7017 | width = CH_WIDTH_80MHZ; |
| 7018 | else if (chan_bw == 40) |
| 7019 | width = CH_WIDTH_40MHZ; |
| 7020 | else |
| 7021 | width = CH_WIDTH_20MHZ; |
| 7022 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 7023 | hdd_debug("CH:%d BW:%d", chan_number, chan_bw); |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 7024 | |
Bala Venkatesh | 8b9bbde | 2019-07-03 16:25:16 +0530 | [diff] [blame] | 7025 | wlan_hdd_set_sap_csa_reason(hdd_ctx->psoc, adapter->vdev_id, |
| 7026 | CSA_REASON_USER_INITIATED); |
Wu Gao | 9daee1a | 2018-05-22 14:49:59 +0800 | [diff] [blame] | 7027 | status = hdd_softap_set_channel_change(dev, chan_number, width, true); |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 7028 | if (status) { |
| 7029 | hdd_err("Set channel change fail"); |
| 7030 | return status; |
| 7031 | } |
| 7032 | |
| 7033 | return 0; |
| 7034 | } |
| 7035 | |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7036 | #ifdef DISABLE_CHANNEL_LIST |
| 7037 | void wlan_hdd_free_cache_channels(struct hdd_context *hdd_ctx) |
| 7038 | { |
| 7039 | hdd_enter(); |
| 7040 | |
| 7041 | if (!hdd_ctx->original_channels) |
| 7042 | return; |
| 7043 | |
| 7044 | qdf_mutex_acquire(&hdd_ctx->cache_channel_lock); |
| 7045 | hdd_ctx->original_channels->num_channels = 0; |
| 7046 | if (hdd_ctx->original_channels->channel_info) { |
| 7047 | qdf_mem_free(hdd_ctx->original_channels->channel_info); |
| 7048 | hdd_ctx->original_channels->channel_info = NULL; |
| 7049 | } |
| 7050 | qdf_mem_free(hdd_ctx->original_channels); |
| 7051 | hdd_ctx->original_channels = NULL; |
| 7052 | qdf_mutex_release(&hdd_ctx->cache_channel_lock); |
| 7053 | |
| 7054 | hdd_exit(); |
| 7055 | } |
| 7056 | |
| 7057 | /** |
| 7058 | * hdd_alloc_chan_cache() - Allocate the memory to cache the channel |
| 7059 | * info for the channels received in command SET_DISABLE_CHANNEL_LIST |
| 7060 | * @hdd_ctx: Pointer to HDD context |
| 7061 | * @num_chan: Number of channels for which memory needs to |
| 7062 | * be allocated |
| 7063 | * |
| 7064 | * Return: 0 on success and error code on failure |
| 7065 | */ |
| 7066 | static int hdd_alloc_chan_cache(struct hdd_context *hdd_ctx, int num_chan) |
| 7067 | { |
| 7068 | hdd_ctx->original_channels = |
| 7069 | qdf_mem_malloc(sizeof(struct hdd_cache_channels)); |
| 7070 | if (!hdd_ctx->original_channels) { |
| 7071 | hdd_err("QDF_MALLOC_ERR"); |
| 7072 | return -ENOMEM; |
| 7073 | } |
| 7074 | hdd_ctx->original_channels->num_channels = num_chan; |
| 7075 | hdd_ctx->original_channels->channel_info = |
| 7076 | qdf_mem_malloc(num_chan * |
| 7077 | sizeof(struct hdd_cache_channel_info)); |
| 7078 | if (!hdd_ctx->original_channels->channel_info) { |
| 7079 | hdd_err("QDF_MALLOC_ERR"); |
| 7080 | hdd_ctx->original_channels->num_channels = 0; |
| 7081 | qdf_mem_free(hdd_ctx->original_channels); |
| 7082 | hdd_ctx->original_channels = NULL; |
| 7083 | return -ENOMEM; |
| 7084 | } |
| 7085 | return 0; |
| 7086 | } |
| 7087 | |
| 7088 | /** |
Ashish Kumar Dhanotiya | d63d686 | 2019-03-14 18:54:10 +0530 | [diff] [blame] | 7089 | * check_disable_channels() - Check for disable channel |
| 7090 | * @hdd_ctx: Pointer to hdd context |
| 7091 | * @operating_channel: Current operating channel of adapter |
| 7092 | * |
| 7093 | * This function checks original_channels array for a specific channel |
| 7094 | * |
| 7095 | * Return: 0 if channel not found, 1 if channel found |
| 7096 | */ |
| 7097 | static bool check_disable_channels(struct hdd_context *hdd_ctx, |
| 7098 | uint8_t operating_channel) |
| 7099 | { |
| 7100 | uint32_t num_channels; |
| 7101 | uint8_t i; |
| 7102 | |
| 7103 | if (!hdd_ctx || !hdd_ctx->original_channels || |
| 7104 | !hdd_ctx->original_channels->channel_info) |
| 7105 | return false; |
| 7106 | |
| 7107 | num_channels = hdd_ctx->original_channels->num_channels; |
| 7108 | for (i = 0; i < num_channels; i++) |
| 7109 | if (hdd_ctx->original_channels->channel_info[i].channel_num == |
| 7110 | operating_channel) |
| 7111 | return true; |
| 7112 | return false; |
| 7113 | } |
| 7114 | |
| 7115 | /** |
| 7116 | * disconnect_sta_and_stop_sap() - Disconnect STA and stop SAP |
| 7117 | * |
| 7118 | * @hdd_ctx: Pointer to hdd context |
| 7119 | * |
| 7120 | * Disable channels provided by user and disconnect STA if it is |
| 7121 | * connected to any AP, stop SAP and send deauthentication request |
| 7122 | * to STAs connected to SAP. |
| 7123 | * |
| 7124 | * Return: None |
| 7125 | */ |
| 7126 | static void disconnect_sta_and_stop_sap(struct hdd_context *hdd_ctx) |
| 7127 | { |
| 7128 | struct hdd_adapter *adapter, *next = NULL; |
| 7129 | QDF_STATUS status; |
| 7130 | |
| 7131 | if (!hdd_ctx) |
| 7132 | return; |
| 7133 | |
| 7134 | hdd_check_and_disconnect_sta_on_invalid_channel(hdd_ctx); |
| 7135 | |
| 7136 | status = hdd_get_front_adapter(hdd_ctx, &adapter); |
| 7137 | while (adapter && (status == QDF_STATUS_SUCCESS)) { |
| 7138 | if (!hdd_validate_adapter(adapter) && |
| 7139 | (adapter->device_mode == QDF_SAP_MODE) && |
| 7140 | (check_disable_channels(hdd_ctx, |
| 7141 | adapter->session.ap.operating_channel))) |
| 7142 | wlan_hdd_stop_sap(adapter); |
| 7143 | |
| 7144 | status = hdd_get_next_adapter(hdd_ctx, adapter, &next); |
| 7145 | adapter = next; |
| 7146 | } |
| 7147 | } |
| 7148 | |
| 7149 | /** |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7150 | * hdd_parse_disable_chan_cmd() - Parse the channel list received |
| 7151 | * in command. |
| 7152 | * @adapter: pointer to hdd adapter |
| 7153 | * @ptr: Pointer to the command string |
| 7154 | * |
| 7155 | * This function parses the channel list received in the command. |
| 7156 | * command should be a string having format |
| 7157 | * SET_DISABLE_CHANNEL_LIST <num of channels> |
| 7158 | * <channels separated by spaces>. |
| 7159 | * If the command comes multiple times than this function will compare |
| 7160 | * the channels received in the command with the channles cached in the |
| 7161 | * first command, if the channel list matches with the cached channles, |
| 7162 | * it returns success otherwise returns failure. |
| 7163 | * |
| 7164 | * Return: 0 on success, Error code on failure |
| 7165 | */ |
| 7166 | |
| 7167 | static int hdd_parse_disable_chan_cmd(struct hdd_adapter *adapter, uint8_t *ptr) |
| 7168 | { |
| 7169 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7170 | uint8_t *param; |
| 7171 | int j, i, temp_int, ret = 0, num_channels; |
| 7172 | uint32_t parsed_channels[MAX_CHANNEL]; |
| 7173 | bool is_command_repeated = false; |
| 7174 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 7175 | if (!hdd_ctx) { |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7176 | hdd_err("HDD Context is NULL"); |
| 7177 | return -EINVAL; |
| 7178 | } |
| 7179 | |
| 7180 | param = strnchr(ptr, strlen(ptr), ' '); |
| 7181 | /*no argument after the command*/ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 7182 | if (!param) |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7183 | return -EINVAL; |
| 7184 | |
| 7185 | /*no space after the command*/ |
| 7186 | else if (SPACE_ASCII_VALUE != *param) |
| 7187 | return -EINVAL; |
| 7188 | |
| 7189 | param++; |
| 7190 | |
| 7191 | /*removing empty spaces*/ |
| 7192 | while ((SPACE_ASCII_VALUE == *param) && ('\0' != *param)) |
| 7193 | param++; |
| 7194 | |
| 7195 | /*no argument followed by spaces*/ |
| 7196 | if ('\0' == *param) |
| 7197 | return -EINVAL; |
| 7198 | |
| 7199 | /*getting the first argument ie the number of channels*/ |
| 7200 | if (sscanf(param, "%d ", &temp_int) != 1) { |
| 7201 | hdd_err("Cannot get number of channels from input"); |
| 7202 | return -EINVAL; |
| 7203 | } |
| 7204 | |
| 7205 | if (temp_int < 0 || temp_int > MAX_CHANNEL) { |
| 7206 | hdd_err("Invalid Number of channel received"); |
| 7207 | return -EINVAL; |
| 7208 | } |
| 7209 | |
| 7210 | hdd_debug("Number of channel to disable are: %d", temp_int); |
| 7211 | |
| 7212 | if (!temp_int) { |
| 7213 | if (!wlan_hdd_restore_channels(hdd_ctx, false)) { |
| 7214 | /* |
| 7215 | * Free the cache channels only when the command is |
| 7216 | * received with num channels as 0 |
| 7217 | */ |
| 7218 | wlan_hdd_free_cache_channels(hdd_ctx); |
| 7219 | } |
| 7220 | return 0; |
| 7221 | } |
| 7222 | |
| 7223 | qdf_mutex_acquire(&hdd_ctx->cache_channel_lock); |
| 7224 | |
| 7225 | if (!hdd_ctx->original_channels) { |
| 7226 | if (hdd_alloc_chan_cache(hdd_ctx, temp_int)) { |
| 7227 | ret = -ENOMEM; |
| 7228 | goto mem_alloc_failed; |
| 7229 | } |
| 7230 | } else if (hdd_ctx->original_channels->num_channels != temp_int) { |
| 7231 | hdd_err("Invalid Number of channels"); |
| 7232 | ret = -EINVAL; |
| 7233 | is_command_repeated = true; |
| 7234 | goto parse_failed; |
| 7235 | } else { |
| 7236 | is_command_repeated = true; |
| 7237 | } |
| 7238 | num_channels = temp_int; |
| 7239 | for (j = 0; j < num_channels; j++) { |
| 7240 | /* |
| 7241 | * param pointing to the beginning of first space |
| 7242 | * after number of channels |
| 7243 | */ |
| 7244 | param = strpbrk(param, " "); |
| 7245 | /*no channel list after the number of channels argument*/ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 7246 | if (!param) { |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7247 | hdd_err("Invalid No of channel provided in the list"); |
| 7248 | ret = -EINVAL; |
| 7249 | goto parse_failed; |
| 7250 | } |
| 7251 | |
| 7252 | param++; |
| 7253 | |
| 7254 | /*removing empty space*/ |
| 7255 | while ((SPACE_ASCII_VALUE == *param) && ('\0' != *param)) |
| 7256 | param++; |
| 7257 | |
| 7258 | if ('\0' == *param) { |
| 7259 | hdd_err("No channel is provided in the list"); |
| 7260 | ret = -EINVAL; |
| 7261 | goto parse_failed; |
| 7262 | } |
| 7263 | |
| 7264 | if (sscanf(param, "%d ", &temp_int) != 1) { |
| 7265 | hdd_err("Cannot read channel number"); |
| 7266 | ret = -EINVAL; |
| 7267 | goto parse_failed; |
| 7268 | } |
| 7269 | |
| 7270 | if (!IS_CHANNEL_VALID(temp_int)) { |
| 7271 | hdd_err("Invalid channel number received"); |
| 7272 | ret = -EINVAL; |
| 7273 | goto parse_failed; |
| 7274 | } |
| 7275 | |
| 7276 | hdd_debug("channel[%d] = %d", j, temp_int); |
| 7277 | parsed_channels[j] = temp_int; |
| 7278 | } |
| 7279 | |
| 7280 | /*extra arguments check*/ |
| 7281 | param = strpbrk(param, " "); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 7282 | if (param) { |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7283 | while ((SPACE_ASCII_VALUE == *param) && ('\0' != *param)) |
| 7284 | param++; |
| 7285 | |
| 7286 | if ('\0' != *param) { |
| 7287 | hdd_err("Invalid argument received"); |
| 7288 | ret = -EINVAL; |
| 7289 | goto parse_failed; |
| 7290 | } |
| 7291 | } |
| 7292 | |
| 7293 | /* |
| 7294 | * If command is received first time, cache the channels to |
| 7295 | * be disabled else compare the channels received in the |
| 7296 | * command with the cached channels, if channel list matches |
| 7297 | * return success otherewise return failure. |
| 7298 | */ |
| 7299 | if (!is_command_repeated) { |
| 7300 | for (j = 0; j < num_channels; j++) |
| 7301 | hdd_ctx->original_channels-> |
| 7302 | channel_info[j].channel_num = |
| 7303 | parsed_channels[j]; |
Dustin Brown | 3f0d710 | 2018-08-02 12:01:52 -0700 | [diff] [blame] | 7304 | |
| 7305 | /* Cache the channel list in regulatory also */ |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 7306 | ucfg_reg_cache_channel_state(hdd_ctx->pdev, parsed_channels, |
Dustin Brown | 3f0d710 | 2018-08-02 12:01:52 -0700 | [diff] [blame] | 7307 | num_channels); |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7308 | } else { |
| 7309 | for (i = 0; i < num_channels; i++) { |
| 7310 | for (j = 0; j < num_channels; j++) |
| 7311 | if (hdd_ctx->original_channels-> |
| 7312 | channel_info[i].channel_num == |
| 7313 | parsed_channels[j]) |
| 7314 | break; |
| 7315 | if (j == num_channels) { |
| 7316 | ret = -EINVAL; |
| 7317 | goto parse_failed; |
| 7318 | } |
| 7319 | } |
| 7320 | ret = 0; |
| 7321 | } |
| 7322 | mem_alloc_failed: |
| 7323 | |
| 7324 | qdf_mutex_release(&hdd_ctx->cache_channel_lock); |
Ashish Kumar Dhanotiya | dd5f74c | 2019-03-14 16:50:41 +0530 | [diff] [blame] | 7325 | /* Disable the channels received in command SET_DISABLE_CHANNEL_LIST */ |
| 7326 | if (!is_command_repeated && hdd_ctx->original_channels) { |
Ashish Kumar Dhanotiya | d63d686 | 2019-03-14 18:54:10 +0530 | [diff] [blame] | 7327 | ret = wlan_hdd_disable_channels(hdd_ctx); |
| 7328 | if (ret) |
| 7329 | return ret; |
| 7330 | disconnect_sta_and_stop_sap(hdd_ctx); |
Ashish Kumar Dhanotiya | dd5f74c | 2019-03-14 16:50:41 +0530 | [diff] [blame] | 7331 | } |
| 7332 | |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7333 | hdd_exit(); |
| 7334 | |
| 7335 | return ret; |
| 7336 | |
| 7337 | parse_failed: |
| 7338 | if (!is_command_repeated) |
| 7339 | wlan_hdd_free_cache_channels(hdd_ctx); |
Ashish Kumar Dhanotiya | dd5f74c | 2019-03-14 16:50:41 +0530 | [diff] [blame] | 7340 | |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7341 | qdf_mutex_release(&hdd_ctx->cache_channel_lock); |
| 7342 | hdd_exit(); |
| 7343 | |
| 7344 | return ret; |
| 7345 | } |
| 7346 | |
| 7347 | static int drv_cmd_set_disable_chan_list(struct hdd_adapter *adapter, |
| 7348 | struct hdd_context *hdd_ctx, |
| 7349 | uint8_t *command, |
| 7350 | uint8_t command_len, |
| 7351 | struct hdd_priv_data *priv_data) |
| 7352 | { |
| 7353 | return hdd_parse_disable_chan_cmd(adapter, command); |
| 7354 | } |
Ashish Kumar Dhanotiya | 2853ba0 | 2018-03-15 15:51:25 +0530 | [diff] [blame] | 7355 | |
| 7356 | /** |
| 7357 | * hdd_get_disable_ch_list() - get disable channel list |
| 7358 | * @hdd_ctx: hdd context |
| 7359 | * @buf: buffer to hold disable channel list |
| 7360 | * @buf_len: buffer length |
| 7361 | * |
| 7362 | * Return: length of data copied to buf |
| 7363 | */ |
| 7364 | static int hdd_get_disable_ch_list(struct hdd_context *hdd_ctx, uint8_t *buf, |
| 7365 | uint32_t buf_len) |
| 7366 | { |
| 7367 | struct hdd_cache_channel_info *ch_list; |
| 7368 | unsigned char i, num_ch; |
| 7369 | int len = 0; |
| 7370 | |
| 7371 | qdf_mutex_acquire(&hdd_ctx->cache_channel_lock); |
| 7372 | if (hdd_ctx->original_channels && |
| 7373 | hdd_ctx->original_channels->num_channels && |
| 7374 | hdd_ctx->original_channels->channel_info) { |
| 7375 | num_ch = hdd_ctx->original_channels->num_channels; |
| 7376 | |
| 7377 | len = scnprintf(buf, buf_len, "%s %hhu", |
| 7378 | "GET_DISABLE_CHANNEL_LIST", num_ch); |
| 7379 | ch_list = hdd_ctx->original_channels->channel_info; |
| 7380 | for (i = 0; (i < num_ch) && (len < buf_len - 1); i++) { |
| 7381 | len += scnprintf(buf + len, buf_len - len, |
| 7382 | " %d", ch_list[i].channel_num); |
| 7383 | } |
| 7384 | } |
| 7385 | qdf_mutex_release(&hdd_ctx->cache_channel_lock); |
| 7386 | |
| 7387 | return len; |
| 7388 | } |
| 7389 | |
| 7390 | static int drv_cmd_get_disable_chan_list(struct hdd_adapter *adapter, |
| 7391 | struct hdd_context *hdd_ctx, |
| 7392 | uint8_t *command, |
| 7393 | uint8_t command_len, |
| 7394 | struct hdd_priv_data *priv_data) |
| 7395 | { |
| 7396 | char extra[512] = {0}; |
| 7397 | int max_len, copied_length; |
| 7398 | |
| 7399 | hdd_debug("Received Command to get disable Channels list"); |
| 7400 | |
| 7401 | max_len = QDF_MIN(priv_data->total_len, sizeof(extra)); |
| 7402 | copied_length = hdd_get_disable_ch_list(hdd_ctx, extra, max_len); |
| 7403 | if (copied_length == 0) { |
| 7404 | hdd_err("disable channel list is not yet programmed"); |
| 7405 | return -EINVAL; |
| 7406 | } |
| 7407 | |
| 7408 | if (copy_to_user(priv_data->buf, &extra, copied_length + 1)) { |
| 7409 | hdd_err("failed to copy data to user buffer"); |
| 7410 | return -EFAULT; |
| 7411 | } |
| 7412 | |
| 7413 | hdd_debug("data:%s", extra); |
| 7414 | return 0; |
| 7415 | } |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7416 | #else |
| 7417 | |
| 7418 | static int drv_cmd_set_disable_chan_list(struct hdd_adapter *adapter, |
| 7419 | struct hdd_context *hdd_ctx, |
| 7420 | uint8_t *command, |
| 7421 | uint8_t command_len, |
| 7422 | struct hdd_priv_data *priv_data) |
| 7423 | { |
| 7424 | return 0; |
| 7425 | } |
| 7426 | |
| 7427 | void wlan_hdd_free_cache_channels(struct hdd_context *hdd_ctx) |
| 7428 | { |
| 7429 | } |
Ashish Kumar Dhanotiya | 2853ba0 | 2018-03-15 15:51:25 +0530 | [diff] [blame] | 7430 | |
| 7431 | static int drv_cmd_get_disable_chan_list(struct hdd_adapter *adapter, |
| 7432 | struct hdd_context *hdd_ctx, |
| 7433 | uint8_t *command, |
| 7434 | uint8_t command_len, |
| 7435 | struct hdd_priv_data *priv_data) |
| 7436 | { |
| 7437 | return 0; |
| 7438 | } |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7439 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7440 | /* |
| 7441 | * The following table contains all supported WLAN HDD |
| 7442 | * IOCTL driver commands and the handler for each of them. |
| 7443 | */ |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 7444 | static const struct hdd_drv_cmd hdd_drv_cmds[] = { |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7445 | {"P2P_DEV_ADDR", drv_cmd_p2p_dev_addr, false}, |
| 7446 | {"P2P_SET_NOA", drv_cmd_p2p_set_noa, true}, |
| 7447 | {"P2P_SET_PS", drv_cmd_p2p_set_ps, true}, |
| 7448 | {"SETBAND", drv_cmd_set_band, true}, |
| 7449 | {"SETWMMPS", drv_cmd_set_wmmps, true}, |
| 7450 | {"COUNTRY", drv_cmd_country, true}, |
Rajeev Kumar Sirasanagandla | 32ae804 | 2019-03-25 16:37:02 +0530 | [diff] [blame] | 7451 | {"SETCOUNTRYREV", drv_cmd_country, true}, |
| 7452 | {"GETCOUNTRYREV", drv_cmd_get_country, false}, |
Pragaspathi Thilagaraj | aa8320e | 2019-04-16 02:47:50 +0530 | [diff] [blame] | 7453 | {"SETSUSPENDMODE", drv_cmd_set_suspend_mode, true}, |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7454 | {"SET_AP_WPS_P2P_IE", drv_cmd_dummy, false}, |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7455 | {"SETROAMTRIGGER", drv_cmd_set_roam_trigger, true}, |
| 7456 | {"GETROAMTRIGGER", drv_cmd_get_roam_trigger, false}, |
| 7457 | {"SETROAMSCANPERIOD", drv_cmd_set_roam_scan_period, true}, |
| 7458 | {"GETROAMSCANPERIOD", drv_cmd_get_roam_scan_period, false}, |
| 7459 | {"SETROAMSCANREFRESHPERIOD", drv_cmd_set_roam_scan_refresh_period, |
| 7460 | true}, |
| 7461 | {"GETROAMSCANREFRESHPERIOD", drv_cmd_get_roam_scan_refresh_period, |
| 7462 | false}, |
| 7463 | {"SETROAMMODE", drv_cmd_set_roam_mode, true}, |
| 7464 | {"GETROAMMODE", drv_cmd_get_roam_mode, false}, |
| 7465 | {"SETROAMDELTA", drv_cmd_set_roam_delta, true}, |
| 7466 | {"GETROAMDELTA", drv_cmd_get_roam_delta, false}, |
| 7467 | {"GETBAND", drv_cmd_get_band, false}, |
| 7468 | {"SETROAMSCANCHANNELS", drv_cmd_set_roam_scan_channels, true}, |
| 7469 | {"GETROAMSCANCHANNELS", drv_cmd_get_roam_scan_channels, false}, |
| 7470 | {"GETCCXMODE", drv_cmd_get_ccx_mode, false}, |
| 7471 | {"GETOKCMODE", drv_cmd_get_okc_mode, false}, |
| 7472 | {"GETFASTROAM", drv_cmd_get_fast_roam, false}, |
| 7473 | {"GETFASTTRANSITION", drv_cmd_get_fast_transition, false}, |
| 7474 | {"SETROAMSCANCHANNELMINTIME", drv_cmd_set_roam_scan_channel_min_time, |
| 7475 | true}, |
| 7476 | {"SENDACTIONFRAME", drv_cmd_send_action_frame, true}, |
| 7477 | {"GETROAMSCANCHANNELMINTIME", drv_cmd_get_roam_scan_channel_min_time, |
| 7478 | false}, |
| 7479 | {"SETSCANCHANNELTIME", drv_cmd_set_scan_channel_time, true}, |
| 7480 | {"GETSCANCHANNELTIME", drv_cmd_get_scan_channel_time, false}, |
| 7481 | {"SETSCANHOMETIME", drv_cmd_set_scan_home_time, true}, |
| 7482 | {"GETSCANHOMETIME", drv_cmd_get_scan_home_time, false}, |
| 7483 | {"SETROAMINTRABAND", drv_cmd_set_roam_intra_band, true}, |
| 7484 | {"GETROAMINTRABAND", drv_cmd_get_roam_intra_band, false}, |
| 7485 | {"SETSCANNPROBES", drv_cmd_set_scan_n_probes, true}, |
| 7486 | {"GETSCANNPROBES", drv_cmd_get_scan_n_probes, false}, |
| 7487 | {"SETSCANHOMEAWAYTIME", drv_cmd_set_scan_home_away_time, true}, |
| 7488 | {"GETSCANHOMEAWAYTIME", drv_cmd_get_scan_home_away_time, false}, |
| 7489 | {"REASSOC", drv_cmd_reassoc, true}, |
| 7490 | {"SETWESMODE", drv_cmd_set_wes_mode, true}, |
| 7491 | {"GETWESMODE", drv_cmd_get_wes_mode, false}, |
| 7492 | {"SETOPPORTUNISTICRSSIDIFF", drv_cmd_set_opportunistic_rssi_diff, |
| 7493 | true}, |
| 7494 | {"GETOPPORTUNISTICRSSIDIFF", drv_cmd_get_opportunistic_rssi_diff, |
| 7495 | false}, |
| 7496 | {"SETROAMRESCANRSSIDIFF", drv_cmd_set_roam_rescan_rssi_diff, true}, |
| 7497 | {"GETROAMRESCANRSSIDIFF", drv_cmd_get_roam_rescan_rssi_diff, false}, |
| 7498 | {"SETFASTROAM", drv_cmd_set_fast_roam, true}, |
| 7499 | {"SETFASTTRANSITION", drv_cmd_set_fast_transition, true}, |
| 7500 | {"FASTREASSOC", drv_cmd_fast_reassoc, true}, |
| 7501 | {"SETROAMSCANCONTROL", drv_cmd_set_roam_scan_control, true}, |
| 7502 | {"SETOKCMODE", drv_cmd_set_okc_mode, true}, |
| 7503 | {"GETROAMSCANCONTROL", drv_cmd_get_roam_scan_control, false}, |
| 7504 | {"BTCOEXMODE", drv_cmd_bt_coex_mode, true}, |
| 7505 | {"SCAN-ACTIVE", drv_cmd_scan_active, false}, |
| 7506 | {"SCAN-PASSIVE", drv_cmd_scan_passive, false}, |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 7507 | {"CONCSETDWELLTIME", drv_cmd_conc_set_dwell_time, true}, |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7508 | {"GETDWELLTIME", drv_cmd_get_dwell_time, false}, |
| 7509 | {"SETDWELLTIME", drv_cmd_set_dwell_time, true}, |
| 7510 | {"MIRACAST", drv_cmd_miracast, true}, |
| 7511 | {"SETIBSSBEACONOUIDATA", drv_cmd_set_ibss_beacon_oui_data, true}, |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 7512 | #ifdef FEATURE_WLAN_RMC |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7513 | {"SETRMCENABLE", drv_cmd_set_rmc_enable, true}, |
| 7514 | {"SETRMCACTIONPERIOD", drv_cmd_set_rmc_action_period, true}, |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 7515 | {"SETRMCTXRATE", drv_cmd_set_rmc_tx_rate, true}, |
| 7516 | #endif |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7517 | {"GETIBSSPEERINFOALL", drv_cmd_get_ibss_peer_info_all, false}, |
| 7518 | {"GETIBSSPEERINFO", drv_cmd_get_ibss_peer_info, true}, |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7519 | {"SETIBSSTXFAILEVENT", drv_cmd_set_ibss_tx_fail_event, true}, |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 7520 | #ifdef FEATURE_WLAN_ESE |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7521 | {"SETCCXROAMSCANCHANNELS", drv_cmd_set_ccx_roam_scan_channels, true}, |
| 7522 | {"GETTSMSTATS", drv_cmd_get_tsm_stats, true}, |
| 7523 | {"SETCCKMIE", drv_cmd_set_cckm_ie, true}, |
| 7524 | {"CCXBEACONREQ", drv_cmd_ccx_beacon_req, true}, |
| 7525 | {"CCXPLMREQ", drv_cmd_ccx_plm_req, true}, |
| 7526 | {"SETCCXMODE", drv_cmd_set_ccx_mode, true}, |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 7527 | #endif /* FEATURE_WLAN_ESE */ |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7528 | {"SETMCRATE", drv_cmd_set_mc_rate, true}, |
| 7529 | {"MAXTXPOWER", drv_cmd_max_tx_power, true}, |
| 7530 | {"SETDFSSCANMODE", drv_cmd_set_dfs_scan_mode, true}, |
| 7531 | {"GETDFSSCANMODE", drv_cmd_get_dfs_scan_mode, false}, |
| 7532 | {"GETLINKSTATUS", drv_cmd_get_link_status, false}, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7533 | #ifdef WLAN_FEATURE_EXTWOW_SUPPORT |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7534 | {"ENABLEEXTWOW", drv_cmd_enable_ext_wow, true}, |
| 7535 | {"SETAPP1PARAMS", drv_cmd_set_app1_params, true}, |
| 7536 | {"SETAPP2PARAMS", drv_cmd_set_app2_params, true}, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7537 | #endif |
| 7538 | #ifdef FEATURE_WLAN_TDLS |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7539 | {"TDLSSECONDARYCHANNELOFFSET", drv_cmd_tdls_secondary_channel_offset, |
| 7540 | true}, |
| 7541 | {"TDLSOFFCHANNELMODE", drv_cmd_tdls_off_channel_mode, true}, |
| 7542 | {"TDLSOFFCHANNEL", drv_cmd_tdls_off_channel, true}, |
| 7543 | {"TDLSSCAN", drv_cmd_tdls_scan, true}, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7544 | #endif |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7545 | {"RSSI", drv_cmd_get_rssi, false}, |
| 7546 | {"LINKSPEED", drv_cmd_get_linkspeed, false}, |
Qiwei Cai | 4505fc6 | 2018-05-17 18:35:19 +0800 | [diff] [blame] | 7547 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7548 | {"RXFILTER-REMOVE", drv_cmd_rx_filter_remove, true}, |
| 7549 | {"RXFILTER-ADD", drv_cmd_rx_filter_add, true}, |
Qiwei Cai | 4505fc6 | 2018-05-17 18:35:19 +0800 | [diff] [blame] | 7550 | #endif |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7551 | {"SET_FCC_CHANNEL", drv_cmd_set_fcc_channel, true}, |
| 7552 | {"CHANNEL_SWITCH", drv_cmd_set_channel_switch, true}, |
| 7553 | {"SETANTENNAMODE", drv_cmd_set_antenna_mode, true}, |
| 7554 | {"GETANTENNAMODE", drv_cmd_get_antenna_mode, false}, |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7555 | {"SET_DISABLE_CHANNEL_LIST", drv_cmd_set_disable_chan_list, true}, |
Ashish Kumar Dhanotiya | 2853ba0 | 2018-03-15 15:51:25 +0530 | [diff] [blame] | 7556 | {"GET_DISABLE_CHANNEL_LIST", drv_cmd_get_disable_chan_list, false}, |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7557 | {"STOP", drv_cmd_dummy, false}, |
Srinivas Girigowda | 836475e | 2018-04-17 14:42:23 -0700 | [diff] [blame] | 7558 | /* Deprecated commands */ |
| 7559 | {"RXFILTER-START", drv_cmd_dummy, false}, |
| 7560 | {"RXFILTER-STOP", drv_cmd_dummy, false}, |
| 7561 | {"BTCOEXSCAN-START", drv_cmd_dummy, false}, |
| 7562 | {"BTCOEXSCAN-STOP", drv_cmd_dummy, false}, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7563 | }; |
| 7564 | |
| 7565 | /** |
| 7566 | * hdd_drv_cmd_process() - chooses and runs the proper |
| 7567 | * handler based on the input command |
| 7568 | * @adapter: Pointer to the hdd adapter |
| 7569 | * @cmd: Pointer to the driver command |
| 7570 | * @priv_data: Pointer to the data associated with the command |
| 7571 | * |
| 7572 | * This function parses the input hdd driver command and runs |
| 7573 | * the proper handler |
| 7574 | * |
| 7575 | * Return: 0 for success non-zero for failure |
| 7576 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 7577 | static int hdd_drv_cmd_process(struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7578 | uint8_t *cmd, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 7579 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7580 | { |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 7581 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7582 | int i; |
| 7583 | const int cmd_num_total = ARRAY_SIZE(hdd_drv_cmds); |
| 7584 | uint8_t *cmd_i = NULL; |
| 7585 | hdd_drv_cmd_handler_t handler = NULL; |
Nachiket Kukade | b7e0497 | 2017-12-13 20:38:00 +0530 | [diff] [blame] | 7586 | int len = 0, cmd_len = 0; |
| 7587 | uint8_t *ptr; |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7588 | bool args; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7589 | |
| 7590 | if (!adapter || !cmd || !priv_data) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 7591 | hdd_err("at least 1 param is NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7592 | return -EINVAL; |
| 7593 | } |
| 7594 | |
Nachiket Kukade | b7e0497 | 2017-12-13 20:38:00 +0530 | [diff] [blame] | 7595 | /* Calculate length of the first word */ |
| 7596 | ptr = strchrnul(cmd, ' '); |
| 7597 | cmd_len = ptr - cmd; |
| 7598 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 7599 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7600 | |
| 7601 | for (i = 0; i < cmd_num_total; i++) { |
| 7602 | |
| 7603 | cmd_i = (uint8_t *)hdd_drv_cmds[i].cmd; |
| 7604 | handler = hdd_drv_cmds[i].handler; |
| 7605 | len = strlen(cmd_i); |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7606 | args = hdd_drv_cmds[i].args; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7607 | |
| 7608 | if (!handler) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 7609 | hdd_err("no. %d handler is NULL", i); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7610 | return -EINVAL; |
| 7611 | } |
| 7612 | |
Nachiket Kukade | b7e0497 | 2017-12-13 20:38:00 +0530 | [diff] [blame] | 7613 | if (len == cmd_len && strncasecmp(cmd, cmd_i, len) == 0) { |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7614 | if (args && drv_cmd_validate(cmd, len)) |
| 7615 | return -EINVAL; |
| 7616 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7617 | return handler(adapter, hdd_ctx, |
| 7618 | cmd, len, priv_data); |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7619 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7620 | } |
| 7621 | |
| 7622 | return drv_cmd_invalid(adapter, hdd_ctx, cmd, len, priv_data); |
| 7623 | } |
| 7624 | |
| 7625 | /** |
| 7626 | * hdd_driver_command() - top level wlan hdd driver command handler |
| 7627 | * @adapter: Pointer to the hdd adapter |
| 7628 | * @priv_data: Pointer to the raw command data |
| 7629 | * |
| 7630 | * This function is the top level wlan hdd driver command handler. It |
| 7631 | * handles the command with the help of hdd_drv_cmd_process() |
| 7632 | * |
| 7633 | * Return: 0 for success non-zero for failure |
| 7634 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 7635 | static int hdd_driver_command(struct hdd_adapter *adapter, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 7636 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7637 | { |
| 7638 | uint8_t *command = NULL; |
| 7639 | int ret = 0; |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 7640 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7641 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 7642 | hdd_enter(); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 7643 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7644 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 7645 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7646 | return -EINVAL; |
| 7647 | } |
| 7648 | |
Ashish Kumar Dhanotiya | ff4e1c4 | 2017-03-14 15:54:05 +0530 | [diff] [blame] | 7649 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 7650 | if (ret) |
| 7651 | return ret; |
| 7652 | |
| 7653 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 7654 | hdd_err("Driver module is closed; command can not be processed"); |
| 7655 | return -EINVAL; |
| 7656 | } |
| 7657 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7658 | /* |
| 7659 | * Note that valid pointers are provided by caller |
| 7660 | */ |
| 7661 | |
| 7662 | /* copy to local struct to avoid numerous changes to legacy code */ |
| 7663 | if (priv_data->total_len <= 0 || |
| 7664 | priv_data->total_len > WLAN_PRIV_DATA_MAX_LEN) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 7665 | hdd_warn("Invalid priv_data.total_len: %d!!!", |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 7666 | priv_data->total_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7667 | ret = -EINVAL; |
| 7668 | goto exit; |
| 7669 | } |
| 7670 | |
| 7671 | /* Allocate +1 for '\0' */ |
Mahesh Kumar Kalikot Veetil | 9c65618 | 2016-11-02 10:28:03 -0700 | [diff] [blame] | 7672 | command = qdf_mem_malloc(priv_data->total_len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7673 | if (!command) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 7674 | hdd_err("failed to allocate memory"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7675 | ret = -ENOMEM; |
| 7676 | goto exit; |
| 7677 | } |
| 7678 | |
| 7679 | if (copy_from_user(command, priv_data->buf, priv_data->total_len)) { |
| 7680 | ret = -EFAULT; |
| 7681 | goto exit; |
| 7682 | } |
| 7683 | |
| 7684 | /* Make sure the command is NUL-terminated */ |
| 7685 | command[priv_data->total_len] = '\0'; |
| 7686 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 7687 | hdd_debug("%s: %s", adapter->dev->name, command); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7688 | ret = hdd_drv_cmd_process(adapter, command, priv_data); |
| 7689 | |
| 7690 | exit: |
| 7691 | if (command) |
Mahesh Kumar Kalikot Veetil | 9c65618 | 2016-11-02 10:28:03 -0700 | [diff] [blame] | 7692 | qdf_mem_free(command); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 7693 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7694 | return ret; |
| 7695 | } |
| 7696 | |
| 7697 | #ifdef CONFIG_COMPAT |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 7698 | static int hdd_driver_compat_ioctl(struct hdd_adapter *adapter, struct ifreq *ifr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7699 | { |
| 7700 | struct { |
| 7701 | compat_uptr_t buf; |
| 7702 | int used_len; |
| 7703 | int total_len; |
| 7704 | } compat_priv_data; |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 7705 | struct hdd_priv_data priv_data; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7706 | int ret = 0; |
| 7707 | |
| 7708 | /* |
| 7709 | * Note that adapter and ifr have already been verified by caller, |
| 7710 | * and HDD context has also been validated |
| 7711 | */ |
| 7712 | if (copy_from_user(&compat_priv_data, ifr->ifr_data, |
| 7713 | sizeof(compat_priv_data))) { |
| 7714 | ret = -EFAULT; |
| 7715 | goto exit; |
| 7716 | } |
| 7717 | priv_data.buf = compat_ptr(compat_priv_data.buf); |
| 7718 | priv_data.used_len = compat_priv_data.used_len; |
| 7719 | priv_data.total_len = compat_priv_data.total_len; |
| 7720 | ret = hdd_driver_command(adapter, &priv_data); |
| 7721 | exit: |
| 7722 | return ret; |
| 7723 | } |
| 7724 | #else /* CONFIG_COMPAT */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 7725 | static int hdd_driver_compat_ioctl(struct hdd_adapter *adapter, struct ifreq *ifr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7726 | { |
| 7727 | /* will never be invoked */ |
| 7728 | return 0; |
| 7729 | } |
| 7730 | #endif /* CONFIG_COMPAT */ |
| 7731 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 7732 | static int hdd_driver_ioctl(struct hdd_adapter *adapter, struct ifreq *ifr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7733 | { |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 7734 | struct hdd_priv_data priv_data; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7735 | int ret = 0; |
| 7736 | |
| 7737 | /* |
| 7738 | * Note that adapter and ifr have already been verified by caller, |
| 7739 | * and HDD context has also been validated |
| 7740 | */ |
| 7741 | if (copy_from_user(&priv_data, ifr->ifr_data, sizeof(priv_data))) |
| 7742 | ret = -EFAULT; |
| 7743 | else |
| 7744 | ret = hdd_driver_command(adapter, &priv_data); |
| 7745 | |
| 7746 | return ret; |
| 7747 | } |
| 7748 | |
| 7749 | /** |
| 7750 | * __hdd_ioctl() - ioctl handler for wlan network interfaces |
| 7751 | * @dev: device upon which the ioctl was received |
| 7752 | * @ifr: ioctl request information |
| 7753 | * @cmd: ioctl command |
| 7754 | * |
| 7755 | * This function does initial processing of wlan device ioctls. |
| 7756 | * Currently two flavors of ioctls are supported. The primary ioctl |
| 7757 | * that is supported is the (SIOCDEVPRIVATE + 1) ioctl which is used |
| 7758 | * for Android "DRIVER" commands. The other ioctl that is |
| 7759 | * conditionally supported is the SIOCIOCTLTX99 ioctl which is used |
| 7760 | * for FTM on some platforms. This function simply verifies that the |
| 7761 | * driver is in a sane state, and that the ioctl is one of the |
| 7762 | * supported flavors, in which case flavor-specific handlers are |
| 7763 | * dispatched. |
| 7764 | * |
| 7765 | * Return: 0 on success, non-zero on error |
| 7766 | */ |
| 7767 | static int __hdd_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) |
| 7768 | { |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 7769 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 7770 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7771 | int ret; |
| 7772 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 7773 | hdd_enter_dev(dev); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 7774 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7775 | if (dev != adapter->dev) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 7776 | hdd_err("HDD adapter/dev inconsistency"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7777 | ret = -ENODEV; |
| 7778 | goto exit; |
| 7779 | } |
| 7780 | |
| 7781 | if ((!ifr) || (!ifr->ifr_data)) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 7782 | hdd_err("invalid data cmd: %d", cmd); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7783 | ret = -EINVAL; |
| 7784 | goto exit; |
| 7785 | } |
| 7786 | #if defined(QCA_WIFI_FTM) && defined(LINUX_QCMBR) |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7787 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7788 | if (SIOCIOCTLTX99 == cmd) { |
| 7789 | ret = wlan_hdd_qcmbr_unified_ioctl(adapter, ifr); |
| 7790 | goto exit; |
| 7791 | } |
| 7792 | } |
| 7793 | #endif |
| 7794 | |
| 7795 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7796 | ret = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 7797 | if (ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7798 | goto exit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7799 | |
| 7800 | switch (cmd) { |
| 7801 | case (SIOCDEVPRIVATE + 1): |
Mahesh Kumar Kalikot Veetil | 885a77b | 2018-03-26 14:46:59 -0700 | [diff] [blame] | 7802 | if (in_compat_syscall()) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7803 | ret = hdd_driver_compat_ioctl(adapter, ifr); |
| 7804 | else |
| 7805 | ret = hdd_driver_ioctl(adapter, ifr); |
| 7806 | break; |
| 7807 | default: |
Srinivas Girigowda | 86ecc01 | 2017-03-10 12:26:57 -0800 | [diff] [blame] | 7808 | hdd_warn("unknown ioctl %d", cmd); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7809 | ret = -EINVAL; |
| 7810 | break; |
| 7811 | } |
| 7812 | exit: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 7813 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7814 | return ret; |
| 7815 | } |
| 7816 | |
| 7817 | /** |
| 7818 | * hdd_ioctl() - ioctl handler (wrapper) for wlan network interfaces |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 7819 | * @net_dev: device upon which the ioctl was received |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7820 | * @ifr: ioctl request information |
| 7821 | * @cmd: ioctl command |
| 7822 | * |
| 7823 | * This function acts as an SSR-protecting wrapper to __hdd_ioctl() |
| 7824 | * which is where the ioctls are really handled. |
| 7825 | * |
| 7826 | * Return: 0 on success, non-zero on error |
| 7827 | */ |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 7828 | int hdd_ioctl(struct net_device *net_dev, struct ifreq *ifr, int cmd) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7829 | { |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 7830 | struct osif_vdev_sync *vdev_sync; |
| 7831 | int errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7832 | |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 7833 | errno = osif_vdev_sync_op_start(net_dev, &vdev_sync); |
| 7834 | if (errno) |
| 7835 | return errno; |
| 7836 | |
| 7837 | errno = __hdd_ioctl(net_dev, ifr, cmd); |
| 7838 | |
| 7839 | osif_vdev_sync_op_stop(vdev_sync); |
| 7840 | |
| 7841 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7842 | } |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 7843 | |