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 | |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 67 | #ifdef FEATURE_WLAN_ESE |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 68 | #define TID_MIN_VALUE 0 |
| 69 | #define TID_MAX_VALUE 15 |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 70 | #endif /* FEATURE_WLAN_ESE */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 71 | |
| 72 | /* |
| 73 | * Maximum buffer size used for returning the data back to user space |
| 74 | */ |
| 75 | #define WLAN_MAX_BUF_SIZE 1024 |
| 76 | #define WLAN_PRIV_DATA_MAX_LEN 8192 |
| 77 | |
| 78 | /* |
| 79 | * Driver miracast parameters 0-Disabled |
| 80 | * 1-Source, 2-Sink |
| 81 | */ |
| 82 | #define WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL 0 |
| 83 | #define WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL 2 |
| 84 | |
| 85 | /* |
| 86 | * When ever we need to print IBSSPEERINFOALL for more than 16 STA |
| 87 | * we will split the printing. |
| 88 | */ |
| 89 | #define NUM_OF_STA_DATA_TO_PRINT 16 |
| 90 | |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 91 | #ifdef WLAN_FEATURE_EXTWOW_SUPPORT |
| 92 | /** |
| 93 | * struct enable_ext_wow_priv - Private data structure for ext wow |
| 94 | * @ext_wow_should_suspend: Suspend status of ext wow |
| 95 | */ |
| 96 | struct enable_ext_wow_priv { |
| 97 | bool ext_wow_should_suspend; |
| 98 | }; |
| 99 | #endif |
| 100 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 101 | /* |
| 102 | * Android DRIVER command structures |
| 103 | */ |
| 104 | struct android_wifi_reassoc_params { |
| 105 | unsigned char bssid[18]; |
| 106 | int channel; |
| 107 | }; |
| 108 | |
| 109 | #define ANDROID_WIFI_ACTION_FRAME_SIZE 1040 |
| 110 | struct android_wifi_af_params { |
| 111 | unsigned char bssid[18]; |
| 112 | int channel; |
| 113 | int dwell_time; |
| 114 | int len; |
| 115 | unsigned char data[ANDROID_WIFI_ACTION_FRAME_SIZE]; |
| 116 | }; |
| 117 | |
| 118 | /* |
| 119 | * Define HDD driver command handling entry, each contains a command |
| 120 | * string and the handler. |
| 121 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 122 | typedef int (*hdd_drv_cmd_handler_t)(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 123 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 124 | uint8_t *cmd, |
| 125 | uint8_t cmd_name_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 126 | struct hdd_priv_data *priv_data); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 127 | |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 128 | /** |
| 129 | * struct hdd_drv_cmd - Structure to store ioctl command handling info |
| 130 | * @cmd: Name of the command |
| 131 | * @handler: Command handler to be invoked |
| 132 | * @args: Set to true if command expects input parameters |
| 133 | */ |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 134 | struct hdd_drv_cmd { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 135 | const char *cmd; |
| 136 | hdd_drv_cmd_handler_t handler; |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 137 | bool args; |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 138 | }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 139 | |
| 140 | #ifdef WLAN_FEATURE_EXTWOW_SUPPORT |
| 141 | #define WLAN_WAIT_TIME_READY_TO_EXTWOW 2000 |
| 142 | #define WLAN_HDD_MAX_TCP_PORT 65535 |
| 143 | #endif |
| 144 | |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 145 | /** |
| 146 | * drv_cmd_validate() - Validates for space in hdd driver command |
| 147 | * @command: pointer to input data (its a NULL terminated string) |
| 148 | * @len: length of command name |
| 149 | * |
| 150 | * This function checks for space after command name and if no space |
| 151 | * is found returns error. |
| 152 | * |
| 153 | * Return: 0 for success non-zero for failure |
| 154 | */ |
| 155 | static int drv_cmd_validate(uint8_t *command, int len) |
| 156 | { |
| 157 | if (command[len] != ' ') |
| 158 | return -EINVAL; |
| 159 | |
| 160 | return 0; |
| 161 | } |
| 162 | |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 163 | #ifdef FEATURE_WLAN_ESE |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 164 | struct tsm_priv { |
| 165 | tAniTrafStrmMetrics tsm_metrics; |
| 166 | }; |
| 167 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 168 | static void hdd_get_tsm_stats_cb(tAniTrafStrmMetrics tsm_metrics, |
Sourav Mohapatra | dcd8f8d | 2019-07-03 15:43:15 +0530 | [diff] [blame] | 169 | void *context) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 170 | { |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 171 | struct osif_request *request; |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 172 | struct tsm_priv *priv; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 173 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 174 | request = osif_request_get(context); |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 175 | if (!request) { |
| 176 | hdd_err("Obsolete request"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 177 | return; |
| 178 | } |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 179 | priv = osif_request_priv(request); |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 180 | priv->tsm_metrics = tsm_metrics; |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 181 | osif_request_complete(request); |
| 182 | osif_request_put(request); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 183 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 184 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 185 | } |
| 186 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 187 | static int hdd_get_tsm_stats(struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 188 | const uint8_t tid, |
| 189 | tAniTrafStrmMetrics *tsm_metrics) |
| 190 | { |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 191 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 192 | struct hdd_station_ctx *hdd_sta_ctx; |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 193 | QDF_STATUS status; |
| 194 | int ret; |
| 195 | void *cookie; |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 196 | struct osif_request *request; |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 197 | struct tsm_priv *priv; |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 198 | static const struct osif_request_params params = { |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 199 | .priv_size = sizeof(*priv), |
| 200 | .timeout_ms = WLAN_WAIT_TIME_STATS, |
| 201 | }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 202 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 203 | if (!adapter) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 204 | hdd_err("adapter is NULL"); |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 205 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 209 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 210 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 211 | request = osif_request_alloc(¶ms); |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 212 | if (!request) { |
| 213 | hdd_err("Request allocation failure"); |
| 214 | return -ENOMEM; |
| 215 | } |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 216 | cookie = osif_request_cookie(request); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 217 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 218 | 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] | 219 | hdd_sta_ctx->conn_info.bssid, |
Jeff Johnson | 30f8455 | 2017-09-13 14:55:25 -0700 | [diff] [blame] | 220 | cookie, tid); |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 221 | if (QDF_STATUS_SUCCESS != status) { |
| 222 | hdd_err("Unable to retrieve tsm statistics"); |
| 223 | ret = qdf_status_to_os_return(status); |
| 224 | goto cleanup; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 225 | } |
| 226 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 227 | ret = osif_request_wait_for_response(request); |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 228 | if (ret) { |
| 229 | hdd_err("SME timed out while retrieving tsm statistics"); |
| 230 | goto cleanup; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 231 | } |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 232 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 233 | priv = osif_request_priv(request); |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 234 | *tsm_metrics = priv->tsm_metrics; |
| 235 | |
| 236 | cleanup: |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 237 | osif_request_put(request); |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 238 | |
| 239 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 240 | } |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 241 | #endif /*FEATURE_WLAN_ESE */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 242 | |
Abhishek Ambure | 6867746 | 2019-09-13 12:44:26 +0530 | [diff] [blame] | 243 | #ifdef QCA_IBSS_SUPPORT |
| 244 | /* |
| 245 | * Ibss prop IE from command will be of size: |
| 246 | * size = sizeof(oui) + sizeof(oui_data) + 1(Element ID) + 1(EID Length) |
| 247 | * OUI_DATA should be at least 3 bytes long |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 248 | */ |
Abhishek Ambure | 6867746 | 2019-09-13 12:44:26 +0530 | [diff] [blame] | 249 | #define WLAN_HDD_IBSS_MIN_OUI_DATA_LENGTH (3) |
| 250 | static uint16_t cesium_pid; |
| 251 | |
Rajeev Kumar | 94c9b45 | 2016-03-24 12:58:47 -0700 | [diff] [blame] | 252 | void |
Jeff Johnson | afa022c | 2019-02-26 09:24:17 -0800 | [diff] [blame] | 253 | hdd_get_ibss_peer_info_cb(void *context, |
Jeff Johnson | 52f19d5 | 2019-02-26 08:35:38 -0800 | [diff] [blame] | 254 | tSirPeerInfoRspParams *peer_info) |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 255 | { |
Jeff Johnson | afa022c | 2019-02-26 09:24:17 -0800 | [diff] [blame] | 256 | struct hdd_adapter *adapter = context; |
Jeff Johnson | 93107ad | 2019-02-26 08:14:46 -0800 | [diff] [blame] | 257 | struct hdd_station_ctx *sta_ctx; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 258 | uint8_t i; |
| 259 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 260 | if ((!adapter) || |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 261 | (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 262 | hdd_err("invalid adapter or adapter has invalid magic"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 263 | return; |
| 264 | } |
| 265 | |
Jeff Johnson | 93107ad | 2019-02-26 08:14:46 -0800 | [diff] [blame] | 266 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 267 | if (peer_info && QDF_STATUS_SUCCESS == peer_info->status) { |
Rajeev Kumar | 94c9b45 | 2016-03-24 12:58:47 -0700 | [diff] [blame] | 268 | /* validate number of peers */ |
Jeff Johnson | 52f19d5 | 2019-02-26 08:35:38 -0800 | [diff] [blame] | 269 | if (peer_info->numPeers > SIR_MAX_NUM_STA_IN_IBSS) { |
Sriram Madhvapathi | 58f0e27 | 2016-10-03 11:47:51 +0530 | [diff] [blame] | 270 | hdd_warn("Limiting num_peers %u to %u", |
Jeff Johnson | 52f19d5 | 2019-02-26 08:35:38 -0800 | [diff] [blame] | 271 | peer_info->numPeers, SIR_MAX_NUM_STA_IN_IBSS); |
| 272 | peer_info->numPeers = SIR_MAX_NUM_STA_IN_IBSS; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 273 | } |
Jeff Johnson | 52f19d5 | 2019-02-26 08:35:38 -0800 | [diff] [blame] | 274 | sta_ctx->ibss_peer_info.status = peer_info->status; |
| 275 | sta_ctx->ibss_peer_info.numPeers = peer_info->numPeers; |
Sriram Madhvapathi | 58f0e27 | 2016-10-03 11:47:51 +0530 | [diff] [blame] | 276 | |
Jeff Johnson | 52f19d5 | 2019-02-26 08:35:38 -0800 | [diff] [blame] | 277 | for (i = 0; i < peer_info->numPeers; i++) |
Jeff Johnson | 93107ad | 2019-02-26 08:14:46 -0800 | [diff] [blame] | 278 | sta_ctx->ibss_peer_info.peerInfoParams[i] = |
Jeff Johnson | 52f19d5 | 2019-02-26 08:35:38 -0800 | [diff] [blame] | 279 | peer_info->peerInfoParams[i]; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 280 | } else { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 281 | hdd_debug("peerInfo %s: status %u, numPeers %u", |
Jeff Johnson | 52f19d5 | 2019-02-26 08:35:38 -0800 | [diff] [blame] | 282 | peer_info ? "valid" : "null", |
| 283 | peer_info ? peer_info->status : QDF_STATUS_E_FAILURE, |
| 284 | peer_info ? peer_info->numPeers : 0); |
Jeff Johnson | 93107ad | 2019-02-26 08:14:46 -0800 | [diff] [blame] | 285 | sta_ctx->ibss_peer_info.numPeers = 0; |
| 286 | sta_ctx->ibss_peer_info.status = QDF_STATUS_E_FAILURE; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 287 | } |
| 288 | |
| 289 | complete(&adapter->ibss_peer_info_comp); |
| 290 | } |
| 291 | |
| 292 | /** |
| 293 | * hdd_cfg80211_get_ibss_peer_info_all() - get ibss peers' info |
| 294 | * @adapter: Adapter context |
| 295 | * |
| 296 | * Request function to get IBSS peer info from lower layers |
| 297 | * |
| 298 | * Return: 0 for success non-zero for failure |
| 299 | */ |
| 300 | static |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 301 | 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] | 302 | { |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 303 | QDF_STATUS status; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 304 | unsigned long rc; |
Yeshwanth Sriram Guntuka | 3f26210 | 2019-07-16 15:41:08 +0530 | [diff] [blame] | 305 | struct qdf_mac_addr bcast = QDF_MAC_ADDR_BCAST_INIT; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 306 | |
| 307 | INIT_COMPLETION(adapter->ibss_peer_info_comp); |
| 308 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 309 | status = sme_request_ibss_peer_info(adapter->hdd_ctx->mac_handle, |
| 310 | adapter, |
| 311 | hdd_get_ibss_peer_info_cb, |
Yeshwanth Sriram Guntuka | 3f26210 | 2019-07-16 15:41:08 +0530 | [diff] [blame] | 312 | true, bcast.bytes); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 313 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 314 | if (QDF_STATUS_SUCCESS == status) { |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 315 | rc = wait_for_completion_timeout |
| 316 | (&adapter->ibss_peer_info_comp, |
| 317 | msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT)); |
| 318 | |
| 319 | /* status will be 0 if timed out */ |
| 320 | if (!rc) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 321 | hdd_warn("Warning: IBSS_PEER_INFO_TIMEOUT"); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 322 | status = QDF_STATUS_E_FAILURE; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 323 | } |
| 324 | } else { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 325 | hdd_warn("Warning: sme_request_ibss_peer_info Request failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 326 | } |
| 327 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 328 | return status; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 329 | } |
| 330 | |
| 331 | /** |
| 332 | * hdd_cfg80211_get_ibss_peer_info() - get ibss peer info |
| 333 | * @adapter: Adapter context |
Jeff Johnson | 0a082d9 | 2019-03-04 12:25:49 -0800 | [diff] [blame] | 334 | * @sta_id: Sta index for which the peer info is requested |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 335 | * |
| 336 | * Request function to get IBSS peer info from lower layers |
| 337 | * |
| 338 | * Return: 0 for success non-zero for failure |
| 339 | */ |
| 340 | static QDF_STATUS |
Sourav Mohapatra | a3cf12a | 2019-08-19 15:40:49 +0530 | [diff] [blame] | 341 | hdd_cfg80211_get_ibss_peer_info(struct hdd_adapter *adapter, uint8_t *mac_addr) |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 342 | { |
| 343 | unsigned long rc; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 344 | QDF_STATUS status; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 345 | |
| 346 | INIT_COMPLETION(adapter->ibss_peer_info_comp); |
| 347 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 348 | status = sme_request_ibss_peer_info(adapter->hdd_ctx->mac_handle, |
| 349 | adapter, |
| 350 | hdd_get_ibss_peer_info_cb, |
Sourav Mohapatra | a3cf12a | 2019-08-19 15:40:49 +0530 | [diff] [blame] | 351 | false, mac_addr); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 352 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 353 | if (QDF_STATUS_SUCCESS == status) { |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 354 | rc = wait_for_completion_timeout( |
| 355 | &adapter->ibss_peer_info_comp, |
| 356 | msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT)); |
| 357 | |
| 358 | /* status = 0 on timeout */ |
| 359 | if (!rc) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 360 | hdd_warn("Warning: IBSS_PEER_INFO_TIMEOUT"); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 361 | status = QDF_STATUS_E_FAILURE; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 362 | } |
| 363 | } else { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 364 | hdd_warn("Warning: sme_request_ibss_peer_info Request failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 365 | } |
| 366 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 367 | return status; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 368 | } |
| 369 | |
| 370 | /* Function header is left blank intentionally */ |
Jeff Johnson | f731b30 | 2016-10-05 16:00:55 -0700 | [diff] [blame] | 371 | static QDF_STATUS |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 372 | hdd_parse_get_ibss_peer_info(uint8_t *command, |
Jeff Johnson | 64ba9af | 2019-02-26 12:57:35 -0800 | [diff] [blame] | 373 | struct qdf_mac_addr *peer_macaddr) |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 374 | { |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 375 | uint8_t *in_ptr = command; |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 376 | size_t in_ptr_len = strlen(command); |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 377 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 378 | in_ptr = strnchr(command, in_ptr_len, SPACE_ASCII_VALUE); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 379 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 380 | if (!in_ptr) |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 381 | return QDF_STATUS_E_FAILURE; |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 382 | else if (SPACE_ASCII_VALUE != *in_ptr) |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 383 | return QDF_STATUS_E_FAILURE; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 384 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 385 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 386 | in_ptr++; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 387 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 388 | if ('\0' == *in_ptr) |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 389 | return QDF_STATUS_E_FAILURE; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 390 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 391 | in_ptr_len -= (in_ptr - command); |
Min Liu | 5359ab1 | 2018-03-29 14:30:24 +0800 | [diff] [blame] | 392 | if (in_ptr_len < 17) |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 393 | return QDF_STATUS_E_FAILURE; |
Min Liu | 5359ab1 | 2018-03-29 14:30:24 +0800 | [diff] [blame] | 394 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 395 | if (in_ptr[2] != ':' || in_ptr[5] != ':' || in_ptr[8] != ':' || |
| 396 | in_ptr[11] != ':' || in_ptr[14] != ':') |
Min Liu | 5359ab1 | 2018-03-29 14:30:24 +0800 | [diff] [blame] | 397 | return QDF_STATUS_E_FAILURE; |
| 398 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 399 | sscanf(in_ptr, "%2x:%2x:%2x:%2x:%2x:%2x", |
Jeff Johnson | 64ba9af | 2019-02-26 12:57:35 -0800 | [diff] [blame] | 400 | (unsigned int *)&peer_macaddr->bytes[0], |
| 401 | (unsigned int *)&peer_macaddr->bytes[1], |
| 402 | (unsigned int *)&peer_macaddr->bytes[2], |
| 403 | (unsigned int *)&peer_macaddr->bytes[3], |
| 404 | (unsigned int *)&peer_macaddr->bytes[4], |
| 405 | (unsigned int *)&peer_macaddr->bytes[5]); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 406 | |
| 407 | return QDF_STATUS_SUCCESS; |
| 408 | } |
| 409 | |
Abhishek Ambure | 6867746 | 2019-09-13 12:44:26 +0530 | [diff] [blame] | 410 | static void hdd_tx_fail_ind_callback(uint8_t *macaddr, uint8_t seq_no) |
| 411 | { |
| 412 | int payload_len; |
| 413 | struct sk_buff *skb; |
| 414 | struct nlmsghdr *nlh; |
| 415 | uint8_t *data; |
| 416 | |
| 417 | payload_len = ETH_ALEN; |
| 418 | |
| 419 | if (0 == cesium_pid || !cesium_nl_srv_sock) { |
| 420 | hdd_err("cesium process not registered"); |
| 421 | return; |
| 422 | } |
| 423 | |
| 424 | skb = nlmsg_new(payload_len, GFP_ATOMIC); |
| 425 | if (!skb) { |
| 426 | hdd_err("nlmsg_new() failed for msg size[%d]", |
| 427 | NLMSG_SPACE(payload_len)); |
| 428 | return; |
| 429 | } |
| 430 | |
| 431 | nlh = nlmsg_put(skb, cesium_pid, seq_no, 0, payload_len, NLM_F_REQUEST); |
| 432 | |
| 433 | if (!nlh) { |
| 434 | hdd_err("nlmsg_put() failed for msg size[%d]", |
| 435 | NLMSG_SPACE(payload_len)); |
| 436 | |
| 437 | kfree_skb(skb); |
| 438 | return; |
| 439 | } |
| 440 | |
| 441 | data = nlmsg_data(nlh); |
| 442 | memcpy(data, macaddr, ETH_ALEN); |
| 443 | |
| 444 | if (nlmsg_unicast(cesium_nl_srv_sock, skb, cesium_pid) < 0) { |
| 445 | hdd_err("nlmsg_unicast() failed for msg size[%d]", |
| 446 | NLMSG_SPACE(payload_len)); |
| 447 | } |
| 448 | } |
| 449 | |
| 450 | /** |
| 451 | * hdd_parse_user_params() - return a pointer to the next argument |
| 452 | * @command: Input argument string |
| 453 | * @arg: Output pointer to the next argument |
| 454 | * |
| 455 | * This function parses argument stream and finds the pointer |
| 456 | * to the next argument |
| 457 | * |
| 458 | * Return: 0 if the next argument found; -EINVAL otherwise |
| 459 | */ |
| 460 | static int hdd_parse_user_params(uint8_t *command, uint8_t **arg) |
| 461 | { |
| 462 | uint8_t *cursor; |
| 463 | |
| 464 | cursor = strnchr(command, strlen(command), SPACE_ASCII_VALUE); |
| 465 | |
| 466 | /* no argument remains ? */ |
| 467 | if (!cursor) |
| 468 | return -EINVAL; |
| 469 | |
| 470 | /* no space after the current arg ? */ |
| 471 | if (SPACE_ASCII_VALUE != *cursor) |
| 472 | return -EINVAL; |
| 473 | |
| 474 | cursor++; |
| 475 | |
| 476 | /* remove empty spaces */ |
| 477 | while (SPACE_ASCII_VALUE == *cursor) |
| 478 | cursor++; |
| 479 | |
| 480 | /* no argument after the spaces ? */ |
| 481 | if ('\0' == *cursor) |
| 482 | return -EINVAL; |
| 483 | |
| 484 | *arg = cursor; |
| 485 | |
| 486 | return 0; |
| 487 | } |
| 488 | |
| 489 | /** |
| 490 | * hdd_parse_ibsstx_fail_event_params - Parse params |
| 491 | * for SETIBSSTXFAILEVENT |
| 492 | * @command: Input ibss tx fail event argument |
| 493 | * @tx_fail_count: (Output parameter) Tx fail counter |
| 494 | * @pid: (Output parameter) PID |
| 495 | * |
| 496 | * Return: 0 if the parsing succeeds; -EINVAL otherwise |
| 497 | */ |
| 498 | static int hdd_parse_ibsstx_fail_event_params(uint8_t *command, |
| 499 | uint8_t *tx_fail_count, |
| 500 | uint16_t *pid) |
| 501 | { |
| 502 | uint8_t *param = NULL; |
| 503 | int ret; |
| 504 | |
| 505 | ret = hdd_parse_user_params(command, ¶m); |
| 506 | |
| 507 | if (0 == ret && param) { |
| 508 | if (1 != sscanf(param, "%hhu", tx_fail_count)) { |
| 509 | ret = -EINVAL; |
| 510 | goto done; |
| 511 | } |
| 512 | } else { |
| 513 | goto done; |
| 514 | } |
| 515 | |
| 516 | if (0 == *tx_fail_count) { |
| 517 | *pid = 0; |
| 518 | goto done; |
| 519 | } |
| 520 | |
| 521 | command = param; |
| 522 | command++; |
| 523 | |
| 524 | ret = hdd_parse_user_params(command, ¶m); |
| 525 | |
| 526 | if (0 == ret) { |
| 527 | if (1 != sscanf(param, "%hu", pid)) { |
| 528 | ret = -EINVAL; |
| 529 | goto done; |
| 530 | } |
| 531 | } else { |
| 532 | goto done; |
| 533 | } |
| 534 | |
| 535 | done: |
| 536 | return ret; |
| 537 | } |
| 538 | |
| 539 | /* Function header is left blank intentionally */ |
| 540 | static int hdd_parse_set_ibss_oui_data_command(uint8_t *command, uint8_t *ie, |
| 541 | int32_t *oui_length, int32_t limit) |
| 542 | { |
| 543 | uint8_t len; |
| 544 | uint8_t data; |
| 545 | |
| 546 | while ((SPACE_ASCII_VALUE == *command) && ('\0' != *command)) { |
| 547 | command++; |
| 548 | limit--; |
| 549 | } |
| 550 | |
| 551 | len = 2; |
| 552 | |
| 553 | while ((SPACE_ASCII_VALUE != *command) && ('\0' != *command) && |
| 554 | (limit > 1)) { |
| 555 | sscanf(command, "%02x", (unsigned int *)&data); |
| 556 | ie[len++] = data; |
| 557 | command += 2; |
| 558 | limit -= 2; |
| 559 | } |
| 560 | |
| 561 | *oui_length = len - 2; |
| 562 | |
| 563 | while ((SPACE_ASCII_VALUE == *command) && ('\0' != *command)) { |
| 564 | command++; |
| 565 | limit--; |
| 566 | } |
| 567 | |
| 568 | while ((SPACE_ASCII_VALUE != *command) && ('\0' != *command) && |
| 569 | (limit > 1)) { |
| 570 | sscanf(command, "%02x", (unsigned int *)&data); |
| 571 | ie[len++] = data; |
| 572 | command += 2; |
| 573 | limit -= 2; |
| 574 | } |
| 575 | |
| 576 | ie[0] = WLAN_ELEMID_VENDOR; |
| 577 | ie[1] = len - 2; |
| 578 | |
| 579 | return len; |
| 580 | } |
| 581 | |
| 582 | /** |
| 583 | * drv_cmd_set_ibss_beacon_oui_data() - set ibss oui data command |
| 584 | * @adapter: Pointer to adapter |
| 585 | * @hdd_ctx: Pointer to HDD context |
| 586 | * @command: Pointer to command string |
| 587 | * @command_len : Command length |
| 588 | * @priv_data : Pointer to priv data |
| 589 | * |
| 590 | * Return: |
| 591 | * int status code |
| 592 | */ |
| 593 | static int drv_cmd_set_ibss_beacon_oui_data(struct hdd_adapter *adapter, |
| 594 | struct hdd_context *hdd_ctx, |
| 595 | uint8_t *command, |
| 596 | uint8_t command_len, |
| 597 | struct hdd_priv_data *priv_data) |
| 598 | { |
| 599 | int i = 0; |
| 600 | int status; |
| 601 | int ret = 0; |
| 602 | uint8_t *ibss_ie; |
| 603 | int32_t oui_length = 0; |
| 604 | uint32_t ibss_ie_length; |
| 605 | uint8_t *value = command; |
| 606 | tSirModifyIE modify_ie; |
| 607 | struct csr_roam_profile *roam_profile; |
| 608 | mac_handle_t mac_handle; |
| 609 | |
| 610 | if (QDF_IBSS_MODE != adapter->device_mode) { |
| 611 | hdd_debug("Device_mode %s(%d) not IBSS", |
| 612 | qdf_opmode_str(adapter->device_mode), |
| 613 | adapter->device_mode); |
| 614 | return ret; |
| 615 | } |
| 616 | |
| 617 | hdd_debug("received command %s", ((char *)value)); |
| 618 | |
| 619 | /* validate argument of command */ |
| 620 | if (strlen(value) <= command_len) { |
| 621 | hdd_err("No arguments in command length %zu", |
| 622 | strlen(value)); |
| 623 | ret = -EFAULT; |
| 624 | goto exit; |
| 625 | } |
| 626 | |
| 627 | /* moving to arguments of commands */ |
| 628 | value = value + command_len; |
| 629 | command_len = strlen(value); |
| 630 | |
| 631 | /* oui_data can't be less than 3 bytes */ |
| 632 | if (command_len < (2 * WLAN_HDD_IBSS_MIN_OUI_DATA_LENGTH)) { |
| 633 | hdd_err("Invalid SETIBSSBEACONOUIDATA command length %d", |
| 634 | command_len); |
| 635 | ret = -EFAULT; |
| 636 | goto exit; |
| 637 | } |
| 638 | |
| 639 | ibss_ie = qdf_mem_malloc(command_len); |
| 640 | if (!ibss_ie) { |
| 641 | hdd_err("Could not allocate memory for command length %d", |
| 642 | command_len); |
| 643 | ret = -ENOMEM; |
| 644 | goto exit; |
| 645 | } |
| 646 | |
| 647 | ibss_ie_length = hdd_parse_set_ibss_oui_data_command(value, ibss_ie, |
| 648 | &oui_length, |
| 649 | command_len); |
| 650 | if (ibss_ie_length <= (2 * WLAN_HDD_IBSS_MIN_OUI_DATA_LENGTH)) { |
| 651 | hdd_err("Could not parse command %s return length %d", |
| 652 | value, ibss_ie_length); |
| 653 | ret = -EFAULT; |
| 654 | qdf_mem_free(ibss_ie); |
| 655 | goto exit; |
| 656 | } |
| 657 | |
| 658 | roam_profile = hdd_roam_profile(adapter); |
| 659 | |
| 660 | qdf_copy_macaddr(&modify_ie.bssid, |
| 661 | roam_profile->BSSIDs.bssid); |
| 662 | |
Abhishek Singh | 5a2c42f | 2019-11-19 11:39:23 +0530 | [diff] [blame] | 663 | modify_ie.vdev_id = adapter->vdev_id; |
Abhishek Ambure | 6867746 | 2019-09-13 12:44:26 +0530 | [diff] [blame] | 664 | modify_ie.notify = true; |
| 665 | modify_ie.ieID = WLAN_ELEMID_VENDOR; |
| 666 | modify_ie.ieIDLen = ibss_ie_length; |
| 667 | modify_ie.ieBufferlength = ibss_ie_length; |
| 668 | modify_ie.pIEBuffer = ibss_ie; |
| 669 | modify_ie.oui_length = oui_length; |
| 670 | |
| 671 | hdd_warn("ibss_ie length %d oui_length %d ibss_ie:", |
| 672 | ibss_ie_length, oui_length); |
| 673 | while (i < modify_ie.ieBufferlength) |
| 674 | hdd_warn("0x%x", ibss_ie[i++]); |
| 675 | |
| 676 | /* Probe Bcn modification */ |
| 677 | mac_handle = hdd_ctx->mac_handle; |
| 678 | sme_modify_add_ie(mac_handle, &modify_ie, eUPDATE_IE_PROBE_BCN); |
| 679 | |
| 680 | /* Populating probe resp frame */ |
| 681 | sme_modify_add_ie(mac_handle, &modify_ie, eUPDATE_IE_PROBE_RESP); |
| 682 | |
| 683 | qdf_mem_free(ibss_ie); |
| 684 | |
| 685 | status = sme_send_cesium_enable_ind(mac_handle, |
| 686 | adapter->vdev_id); |
| 687 | if (QDF_STATUS_SUCCESS != status) { |
| 688 | hdd_err("Could not send cesium enable indication %d", |
| 689 | status); |
| 690 | ret = -EINVAL; |
| 691 | goto exit; |
| 692 | } |
| 693 | |
| 694 | exit: |
| 695 | return ret; |
| 696 | } |
| 697 | |
| 698 | static int drv_cmd_get_ibss_peer_info_all(struct hdd_adapter *adapter, |
| 699 | struct hdd_context *hdd_ctx, |
| 700 | uint8_t *command, |
| 701 | uint8_t command_len, |
| 702 | struct hdd_priv_data *priv_data) |
| 703 | { |
| 704 | int ret = 0; |
| 705 | int status = QDF_STATUS_SUCCESS; |
| 706 | struct hdd_station_ctx *sta_ctx = NULL; |
| 707 | char *extra = NULL; |
| 708 | int idx = 0; |
| 709 | int length = 0; |
| 710 | uint8_t mac_addr[QDF_MAC_ADDR_SIZE]; |
| 711 | uint32_t print_break_index = 0; |
| 712 | |
| 713 | if (QDF_IBSS_MODE != adapter->device_mode) { |
| 714 | hdd_warn("Unsupported in mode %s(%d)", |
| 715 | qdf_opmode_str(adapter->device_mode), |
| 716 | adapter->device_mode); |
| 717 | return -EINVAL; |
| 718 | } |
| 719 | |
| 720 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 721 | hdd_debug("Received GETIBSSPEERINFOALL Command"); |
| 722 | |
| 723 | /* Handle the command */ |
| 724 | status = hdd_cfg80211_get_ibss_peer_info_all(adapter); |
| 725 | if (QDF_STATUS_SUCCESS == status) { |
| 726 | size_t user_size = qdf_min(WLAN_MAX_BUF_SIZE, |
| 727 | priv_data->total_len); |
| 728 | |
| 729 | /* |
| 730 | * The variable extra needed to be allocated on the heap since |
| 731 | * amount of memory required to copy the data for 32 devices |
| 732 | * exceeds the size of 1024 bytes of default stack size. On |
| 733 | * 64 bit devices, the default max stack size of 2048 bytes |
| 734 | */ |
| 735 | extra = qdf_mem_malloc(user_size); |
| 736 | |
| 737 | if (!extra) { |
| 738 | hdd_err("memory allocation failed"); |
| 739 | ret = -ENOMEM; |
| 740 | goto exit; |
| 741 | } |
| 742 | |
| 743 | /* Copy number of stations */ |
| 744 | length = scnprintf(extra, user_size, "%d ", |
| 745 | sta_ctx->ibss_peer_info.numPeers); |
| 746 | print_break_index = length; |
| 747 | for (idx = 0; idx < sta_ctx->ibss_peer_info.numPeers; |
| 748 | idx++) { |
| 749 | int8_t rssi; |
| 750 | uint32_t tx_rate; |
| 751 | |
| 752 | qdf_mem_copy(mac_addr, |
| 753 | sta_ctx->ibss_peer_info.peerInfoParams[idx]. |
| 754 | mac_addr, sizeof(mac_addr)); |
| 755 | |
| 756 | tx_rate = |
| 757 | sta_ctx->ibss_peer_info.peerInfoParams[idx]. |
| 758 | txRate; |
| 759 | /* |
| 760 | * Only lower 3 bytes are rate info. Mask of the MSByte |
| 761 | */ |
| 762 | tx_rate &= 0x00FFFFFF; |
| 763 | |
| 764 | rssi = sta_ctx->ibss_peer_info.peerInfoParams[idx]. |
| 765 | rssi; |
| 766 | |
| 767 | length += scnprintf(extra + length, |
| 768 | user_size - length, |
| 769 | QDF_MAC_ADDR_STR" %d %d ", |
| 770 | QDF_MAC_ADDR_ARRAY(mac_addr), |
| 771 | tx_rate, rssi); |
| 772 | /* |
| 773 | * cdf_trace_msg has limitation of 512 bytes for the |
| 774 | * print buffer. Hence printing the data in two chunks. |
| 775 | * The first chunk will have the data for 16 devices |
| 776 | * and the second chunk will have the rest. |
| 777 | */ |
| 778 | if (idx < NUM_OF_STA_DATA_TO_PRINT) |
| 779 | print_break_index = length; |
| 780 | } |
| 781 | |
| 782 | /* |
| 783 | * Copy the data back into buffer, if the data to copy is |
| 784 | * more than 512 bytes than we will split the data and do |
| 785 | * it in two shots |
| 786 | */ |
| 787 | if (copy_to_user(priv_data->buf, extra, print_break_index)) { |
| 788 | hdd_err("Copy into user data buffer failed"); |
| 789 | ret = -EFAULT; |
| 790 | goto mem_free; |
| 791 | } |
| 792 | |
| 793 | /* This overwrites the last space, which we already copied */ |
| 794 | extra[print_break_index - 1] = '\0'; |
| 795 | hdd_debug("%s", extra); |
| 796 | |
| 797 | if (length > print_break_index) { |
| 798 | if (copy_to_user |
| 799 | (priv_data->buf + print_break_index, |
| 800 | extra + print_break_index, |
| 801 | length - print_break_index + 1)) { |
| 802 | hdd_err("Copy into user data buffer failed"); |
| 803 | ret = -EFAULT; |
| 804 | goto mem_free; |
| 805 | } |
| 806 | hdd_debug("%s", &extra[print_break_index]); |
| 807 | } |
| 808 | } else { |
| 809 | /* Command failed, log error */ |
| 810 | hdd_err("GETIBSSPEERINFOALL command failed with status code %d", |
| 811 | status); |
| 812 | ret = -EINVAL; |
| 813 | goto exit; |
| 814 | } |
| 815 | ret = 0; |
| 816 | |
| 817 | mem_free: |
| 818 | qdf_mem_free(extra); |
| 819 | exit: |
| 820 | return ret; |
| 821 | } |
| 822 | |
| 823 | /* Peer Info <Peer Addr> command */ |
| 824 | static int drv_cmd_get_ibss_peer_info(struct hdd_adapter *adapter, |
| 825 | struct hdd_context *hdd_ctx, |
| 826 | uint8_t *command, |
| 827 | uint8_t command_len, |
| 828 | struct hdd_priv_data *priv_data) |
| 829 | { |
| 830 | int ret = 0; |
| 831 | uint8_t *value = command; |
| 832 | QDF_STATUS status; |
| 833 | struct hdd_station_ctx *sta_ctx = NULL; |
| 834 | char extra[128] = { 0 }; |
| 835 | uint32_t length = 0; |
Abhishek Ambure | 6867746 | 2019-09-13 12:44:26 +0530 | [diff] [blame] | 836 | struct qdf_mac_addr peer_macaddr; |
| 837 | |
| 838 | if (QDF_IBSS_MODE != adapter->device_mode) { |
| 839 | hdd_warn("Unsupported in mode %s(%d)", |
| 840 | qdf_opmode_str(adapter->device_mode), |
| 841 | adapter->device_mode); |
| 842 | return -EINVAL; |
| 843 | } |
| 844 | |
| 845 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 846 | |
| 847 | hdd_debug("Received GETIBSSPEERINFO Command"); |
| 848 | |
| 849 | /* if there are no peers, no need to continue with the command */ |
| 850 | if (eConnectionState_IbssConnected != |
| 851 | sta_ctx->conn_info.conn_state) { |
| 852 | hdd_err("No IBSS Peers coalesced"); |
| 853 | ret = -EINVAL; |
| 854 | goto exit; |
| 855 | } |
| 856 | |
| 857 | /* Parse the incoming command buffer */ |
| 858 | status = hdd_parse_get_ibss_peer_info(value, &peer_macaddr); |
| 859 | if (QDF_STATUS_SUCCESS != status) { |
| 860 | hdd_err("Invalid GETIBSSPEERINFO command"); |
| 861 | ret = -EINVAL; |
| 862 | goto exit; |
| 863 | } |
| 864 | |
Abhishek Ambure | 6867746 | 2019-09-13 12:44:26 +0530 | [diff] [blame] | 865 | /* Handle the command */ |
Sourav Mohapatra | a3cf12a | 2019-08-19 15:40:49 +0530 | [diff] [blame] | 866 | status = hdd_cfg80211_get_ibss_peer_info(adapter, peer_macaddr.bytes); |
Abhishek Ambure | 6867746 | 2019-09-13 12:44:26 +0530 | [diff] [blame] | 867 | if (QDF_STATUS_SUCCESS == status) { |
| 868 | uint32_t tx_rate = |
| 869 | sta_ctx->ibss_peer_info.peerInfoParams[0].txRate; |
| 870 | /* Only lower 3 bytes are rate info. Mask of the MSByte */ |
| 871 | tx_rate &= 0x00FFFFFF; |
| 872 | |
| 873 | length = scnprintf(extra, sizeof(extra), "%d %d", |
| 874 | (int)tx_rate, |
| 875 | (int)sta_ctx->ibss_peer_info. |
| 876 | peerInfoParams[0].rssi); |
| 877 | length = QDF_MIN(priv_data->total_len, length + 1); |
| 878 | |
| 879 | /* Copy the data back into buffer */ |
| 880 | if (copy_to_user(priv_data->buf, &extra, length)) { |
| 881 | hdd_err("copy data to user buffer failed GETIBSSPEERINFO command"); |
| 882 | ret = -EFAULT; |
| 883 | goto exit; |
| 884 | } |
| 885 | } else { |
| 886 | /* Command failed, log error */ |
| 887 | hdd_err("GETIBSSPEERINFO command failed with status code %d", |
| 888 | status); |
| 889 | ret = -EINVAL; |
| 890 | goto exit; |
| 891 | } |
| 892 | |
| 893 | /* Success ! */ |
| 894 | hdd_debug("%s", extra); |
| 895 | ret = 0; |
| 896 | |
| 897 | exit: |
| 898 | return ret; |
| 899 | } |
| 900 | |
| 901 | static int drv_cmd_set_ibss_tx_fail_event(struct hdd_adapter *adapter, |
| 902 | struct hdd_context *hdd_ctx, |
| 903 | uint8_t *command, |
| 904 | uint8_t command_len, |
| 905 | struct hdd_priv_data *priv_data) |
| 906 | { |
| 907 | int ret = 0; |
| 908 | char *value; |
| 909 | uint8_t tx_fail_count = 0; |
| 910 | uint16_t pid = 0; |
| 911 | mac_handle_t mac_handle; |
| 912 | |
| 913 | value = command; |
| 914 | |
| 915 | ret = hdd_parse_ibsstx_fail_event_params(value, &tx_fail_count, &pid); |
| 916 | |
| 917 | if (0 != ret) { |
| 918 | hdd_err("Failed to parse SETIBSSTXFAILEVENT arguments"); |
| 919 | goto exit; |
| 920 | } |
| 921 | |
| 922 | hdd_debug("tx_fail_cnt=%hhu, pid=%hu", tx_fail_count, pid); |
| 923 | mac_handle = hdd_ctx->mac_handle; |
| 924 | |
| 925 | if (0 == tx_fail_count) { |
| 926 | /* Disable TX Fail Indication */ |
| 927 | if (QDF_STATUS_SUCCESS == |
| 928 | sme_tx_fail_monitor_start_stop_ind(mac_handle, |
| 929 | tx_fail_count, |
| 930 | NULL)) { |
| 931 | cesium_pid = 0; |
| 932 | } else { |
| 933 | hdd_err("failed to disable TX Fail Event"); |
| 934 | ret = -EINVAL; |
| 935 | } |
| 936 | } else { |
| 937 | if (QDF_STATUS_SUCCESS == |
| 938 | sme_tx_fail_monitor_start_stop_ind(mac_handle, |
| 939 | tx_fail_count, |
| 940 | (void *)hdd_tx_fail_ind_callback)) { |
| 941 | cesium_pid = pid; |
| 942 | hdd_debug("Registered Cesium pid %u", |
| 943 | cesium_pid); |
| 944 | } else { |
| 945 | hdd_err("Failed to enable TX Fail Monitoring"); |
| 946 | ret = -EINVAL; |
| 947 | } |
| 948 | } |
| 949 | |
| 950 | exit: |
| 951 | return ret; |
| 952 | } |
| 953 | #else |
| 954 | /** |
| 955 | * drv_cmd_get_ibss_peer_info() - get ibss peer info all |
| 956 | * @adapter: Pointer to adapter |
| 957 | * @hdd_ctx: Pointer to HDD context |
| 958 | * @command: Pointer to command string |
| 959 | * @command_len : Command length |
| 960 | * @priv_data : Pointer to priv data |
| 961 | * |
| 962 | * This function is dummy |
| 963 | * |
| 964 | * Return: 0 |
| 965 | */ |
| 966 | static inline int |
| 967 | drv_cmd_get_ibss_peer_info_all(struct hdd_adapter *adapter, |
| 968 | struct hdd_context *hdd_ctx, |
| 969 | uint8_t *command, |
| 970 | uint8_t command_len, |
| 971 | struct hdd_priv_data *priv_data) |
| 972 | { |
| 973 | return 0; |
| 974 | } |
| 975 | |
| 976 | /** |
| 977 | * drv_cmd_get_ibss_peer_info() - get ibss peer info |
| 978 | * @adapter: Pointer to adapter |
| 979 | * @hdd_ctx: Pointer to HDD context |
| 980 | * @command: Pointer to command string |
| 981 | * @command_len : Command length |
| 982 | * @priv_data : Pointer to priv data |
| 983 | * |
| 984 | * This function is dummy |
| 985 | * |
| 986 | * Return: 0 |
| 987 | */ |
| 988 | static inline int |
| 989 | drv_cmd_get_ibss_peer_info(struct hdd_adapter *adapter, |
| 990 | struct hdd_context *hdd_ctx, |
| 991 | uint8_t *command, |
| 992 | uint8_t command_len, |
| 993 | struct hdd_priv_data *priv_data) |
| 994 | { |
| 995 | return 0; |
| 996 | } |
| 997 | |
| 998 | /** |
| 999 | * drv_cmd_set_ibss_tx_fail_event() - set ibss tx fail event |
| 1000 | * @adapter: Pointer to adapter |
| 1001 | * @hdd_ctx: Pointer to HDD context |
| 1002 | * @command: Pointer to command string |
| 1003 | * @command_len : Command length |
| 1004 | * @priv_data : Pointer to priv data |
| 1005 | * |
| 1006 | * This function is dummy |
| 1007 | * |
| 1008 | * Return: 0 |
| 1009 | */ |
| 1010 | static inline int |
| 1011 | drv_cmd_set_ibss_tx_fail_event(struct hdd_adapter *adapter, |
| 1012 | struct hdd_context *hdd_ctx, |
| 1013 | uint8_t *command, |
| 1014 | uint8_t command_len, |
| 1015 | struct hdd_priv_data *priv_data) |
| 1016 | { |
| 1017 | return 0; |
| 1018 | } |
| 1019 | |
| 1020 | /** |
| 1021 | * drv_cmd_set_ibss_beacon_oui_data() - set ibss oui data command |
| 1022 | * @adapter: Pointer to adapter |
| 1023 | * @hdd_ctx: Pointer to HDD context |
| 1024 | * @command: Pointer to command string |
| 1025 | * @command_len : Command length |
| 1026 | * @priv_data : Pointer to priv data |
| 1027 | * |
| 1028 | * This function is dummy |
| 1029 | * |
| 1030 | * Return: 0 |
| 1031 | */ |
| 1032 | static inline int |
| 1033 | drv_cmd_set_ibss_beacon_oui_data(struct hdd_adapter *adapter, |
| 1034 | struct hdd_context *hdd_ctx, |
| 1035 | uint8_t *command, |
| 1036 | uint8_t command_len, |
| 1037 | struct hdd_priv_data *priv_data) |
| 1038 | { |
| 1039 | return 0; |
| 1040 | } |
| 1041 | #endif |
| 1042 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1043 | 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] | 1044 | { |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1045 | enum band_info band = -1; |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 1046 | |
Harprit Chhabada | 5dff30e | 2019-03-12 17:56:45 -0700 | [diff] [blame] | 1047 | ucfg_reg_get_band(hdd_ctx->pdev, &band); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1048 | switch (band) { |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1049 | case BAND_ALL: |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1050 | *ui_band = WLAN_HDD_UI_BAND_AUTO; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1051 | break; |
| 1052 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1053 | case BAND_2G: |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1054 | *ui_band = WLAN_HDD_UI_BAND_2_4_GHZ; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1055 | break; |
| 1056 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1057 | case BAND_5G: |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1058 | *ui_band = WLAN_HDD_UI_BAND_5_GHZ; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1059 | break; |
| 1060 | |
| 1061 | default: |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1062 | hdd_warn("Invalid Band %d", band); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1063 | *ui_band = -1; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1064 | break; |
| 1065 | } |
| 1066 | } |
| 1067 | |
| 1068 | /** |
| 1069 | * _hdd_parse_bssid_and_chan() - helper function to parse bssid and channel |
| 1070 | * @data: input data |
| 1071 | * @target_ap_bssid: pointer to bssid (output parameter) |
| 1072 | * @channel: pointer to channel (output parameter) |
| 1073 | * |
| 1074 | * Return: 0 if parsing is successful; -EINVAL otherwise |
| 1075 | */ |
| 1076 | static int _hdd_parse_bssid_and_chan(const uint8_t **data, |
| 1077 | uint8_t *bssid, |
| 1078 | uint8_t *channel) |
| 1079 | { |
| 1080 | const uint8_t *in_ptr; |
| 1081 | int v = 0; |
| 1082 | int temp_int; |
| 1083 | uint8_t temp_buf[32]; |
| 1084 | |
| 1085 | /* 12 hexa decimal digits, 5 ':' and '\0' */ |
| 1086 | uint8_t mac_addr[18]; |
| 1087 | |
| 1088 | if (!data || !*data) |
| 1089 | return -EINVAL; |
| 1090 | |
| 1091 | in_ptr = *data; |
| 1092 | |
| 1093 | in_ptr = strnchr(in_ptr, strlen(in_ptr), SPACE_ASCII_VALUE); |
| 1094 | /* no argument after the command */ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 1095 | if (!in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1096 | goto error; |
| 1097 | /* no space after the command */ |
| 1098 | else if (SPACE_ASCII_VALUE != *in_ptr) |
| 1099 | goto error; |
| 1100 | |
| 1101 | /* remove empty spaces */ |
| 1102 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 1103 | in_ptr++; |
| 1104 | |
| 1105 | /* no argument followed by spaces */ |
| 1106 | if ('\0' == *in_ptr) |
| 1107 | goto error; |
| 1108 | |
| 1109 | v = sscanf(in_ptr, "%17s", mac_addr); |
| 1110 | if (!((1 == v) && hdd_is_valid_mac_address(mac_addr))) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1111 | hdd_err("Invalid MAC address or All hex inputs are not read (%d)", |
| 1112 | v); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1113 | goto error; |
| 1114 | } |
| 1115 | |
| 1116 | bssid[0] = hex_to_bin(mac_addr[0]) << 4 | |
| 1117 | hex_to_bin(mac_addr[1]); |
| 1118 | bssid[1] = hex_to_bin(mac_addr[3]) << 4 | |
| 1119 | hex_to_bin(mac_addr[4]); |
| 1120 | bssid[2] = hex_to_bin(mac_addr[6]) << 4 | |
| 1121 | hex_to_bin(mac_addr[7]); |
| 1122 | bssid[3] = hex_to_bin(mac_addr[9]) << 4 | |
| 1123 | hex_to_bin(mac_addr[10]); |
| 1124 | bssid[4] = hex_to_bin(mac_addr[12]) << 4 | |
| 1125 | hex_to_bin(mac_addr[13]); |
| 1126 | bssid[5] = hex_to_bin(mac_addr[15]) << 4 | |
| 1127 | hex_to_bin(mac_addr[16]); |
| 1128 | |
| 1129 | /* point to the next argument */ |
| 1130 | in_ptr = strnchr(in_ptr, strlen(in_ptr), SPACE_ASCII_VALUE); |
| 1131 | /* no argument after the command */ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 1132 | if (!in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1133 | goto error; |
| 1134 | |
| 1135 | /* remove empty spaces */ |
| 1136 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 1137 | in_ptr++; |
| 1138 | |
| 1139 | /* no argument followed by spaces */ |
| 1140 | if ('\0' == *in_ptr) |
| 1141 | goto error; |
| 1142 | |
| 1143 | /* get the next argument ie the channel number */ |
| 1144 | v = sscanf(in_ptr, "%31s ", temp_buf); |
| 1145 | if (1 != v) |
| 1146 | goto error; |
| 1147 | |
| 1148 | v = kstrtos32(temp_buf, 10, &temp_int); |
| 1149 | if ((v < 0) || (temp_int < 0) || |
| 1150 | (temp_int > WNI_CFG_CURRENT_CHANNEL_STAMAX)) |
| 1151 | return -EINVAL; |
| 1152 | |
| 1153 | *channel = temp_int; |
| 1154 | *data = in_ptr; |
| 1155 | return 0; |
| 1156 | error: |
| 1157 | *data = in_ptr; |
| 1158 | return -EINVAL; |
| 1159 | } |
| 1160 | |
| 1161 | /** |
| 1162 | * hdd_parse_send_action_frame_data() - HDD Parse send action frame data |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 1163 | * @command: Pointer to input data |
Jeff Johnson | b7d5279 | 2019-02-26 12:42:08 -0800 | [diff] [blame] | 1164 | * @bssid: Pointer to target Ap bssid |
Jeff Johnson | d727cdc | 2019-02-26 12:47:05 -0800 | [diff] [blame] | 1165 | * @channel: Pointer to the Target AP channel |
Jeff Johnson | 80d220a | 2019-02-26 12:27:24 -0800 | [diff] [blame] | 1166 | * @dwell_time: Pointer to the time to stay off-channel |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 1167 | * after transmitting action frame |
Jeff Johnson | 5f3a612 | 2019-02-26 17:20:59 -0800 | [diff] [blame] | 1168 | * @buf: Pointer to data |
Jeff Johnson | 103f67a | 2019-02-26 17:11:01 -0800 | [diff] [blame] | 1169 | * @buf_len: Pointer to data length |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1170 | * |
| 1171 | * This function parses the send action frame data passed in the format |
| 1172 | * SENDACTIONFRAME<space><bssid><space><channel><space><dwelltime><space><data> |
| 1173 | * |
| 1174 | * Return: 0 for success non-zero for failure |
| 1175 | */ |
| 1176 | static int |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 1177 | hdd_parse_send_action_frame_v1_data(const uint8_t *command, |
Jeff Johnson | b7d5279 | 2019-02-26 12:42:08 -0800 | [diff] [blame] | 1178 | uint8_t *bssid, |
Jeff Johnson | d727cdc | 2019-02-26 12:47:05 -0800 | [diff] [blame] | 1179 | uint8_t *channel, uint8_t *dwell_time, |
Jeff Johnson | 5f3a612 | 2019-02-26 17:20:59 -0800 | [diff] [blame] | 1180 | uint8_t **buf, uint8_t *buf_len) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1181 | { |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1182 | const uint8_t *in_ptr = command; |
Jeff Johnson | aae00ae | 2019-02-26 17:25:11 -0800 | [diff] [blame] | 1183 | const uint8_t *end_ptr; |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 1184 | int temp_int; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1185 | int j = 0; |
| 1186 | int i = 0; |
| 1187 | int v = 0; |
Jeff Johnson | 72f498b | 2019-02-26 18:37:25 -0800 | [diff] [blame] | 1188 | uint8_t temp_buf[32]; |
| 1189 | uint8_t temp_u8 = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1190 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1191 | if (_hdd_parse_bssid_and_chan(&in_ptr, bssid, channel)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1192 | return -EINVAL; |
| 1193 | |
| 1194 | /* point to the next argument */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1195 | in_ptr = strnchr(in_ptr, strlen(in_ptr), SPACE_ASCII_VALUE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1196 | /* no argument after the command */ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 1197 | if (!in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1198 | return -EINVAL; |
| 1199 | /* removing empty spaces */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1200 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 1201 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1202 | |
| 1203 | /* no argument followed by spaces */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1204 | if ('\0' == *in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1205 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1206 | |
| 1207 | /* getting the next argument ie the dwell time */ |
Jeff Johnson | 72f498b | 2019-02-26 18:37:25 -0800 | [diff] [blame] | 1208 | v = sscanf(in_ptr, "%31s ", temp_buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1209 | if (1 != v) |
| 1210 | return -EINVAL; |
| 1211 | |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 1212 | v = kstrtos32(temp_buf, 10, &temp_int); |
| 1213 | if (v < 0 || temp_int < 0) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1214 | return -EINVAL; |
| 1215 | |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 1216 | *dwell_time = temp_int; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1217 | |
| 1218 | /* point to the next argument */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1219 | in_ptr = strnchr(in_ptr, strlen(in_ptr), SPACE_ASCII_VALUE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1220 | /* no argument after the command */ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 1221 | if (!in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1222 | return -EINVAL; |
| 1223 | /* removing empty spaces */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1224 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 1225 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1226 | |
| 1227 | /* no argument followed by spaces */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1228 | if ('\0' == *in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1229 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1230 | |
| 1231 | /* find the length of data */ |
Jeff Johnson | aae00ae | 2019-02-26 17:25:11 -0800 | [diff] [blame] | 1232 | end_ptr = in_ptr; |
| 1233 | while (('\0' != *end_ptr)) |
| 1234 | end_ptr++; |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 1235 | |
Jeff Johnson | aae00ae | 2019-02-26 17:25:11 -0800 | [diff] [blame] | 1236 | *buf_len = end_ptr - in_ptr; |
Jeff Johnson | 103f67a | 2019-02-26 17:11:01 -0800 | [diff] [blame] | 1237 | if (*buf_len <= 0) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1238 | return -EINVAL; |
| 1239 | |
| 1240 | /* |
| 1241 | * Allocate the number of bytes based on the number of input characters |
| 1242 | * whether it is even or odd. |
| 1243 | * if the number of input characters are even, then we need N/2 byte. |
| 1244 | * if the number of input characters are odd, then we need do (N+1)/2 |
| 1245 | * to compensate rounding off. |
| 1246 | * For example, if N = 18, then (18 + 1)/2 = 9 bytes are enough. |
| 1247 | * If N = 19, then we need 10 bytes, hence (19 + 1)/2 = 10 bytes |
| 1248 | */ |
Jeff Johnson | 5f3a612 | 2019-02-26 17:20:59 -0800 | [diff] [blame] | 1249 | *buf = qdf_mem_malloc((*buf_len + 1) / 2); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 1250 | if (!*buf) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1251 | hdd_err("qdf_mem_malloc failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1252 | return -ENOMEM; |
| 1253 | } |
| 1254 | |
| 1255 | /* the buffer received from the upper layer is character buffer, |
| 1256 | * we need to prepare the buffer taking 2 characters in to a U8 hex |
| 1257 | * decimal number for example 7f0000f0...form a buffer to contain 7f |
| 1258 | * in 0th location, 00 in 1st and f0 in 3rd location |
| 1259 | */ |
Jeff Johnson | 103f67a | 2019-02-26 17:11:01 -0800 | [diff] [blame] | 1260 | for (i = 0, j = 0; j < *buf_len; j += 2) { |
| 1261 | if (j + 1 == *buf_len) { |
Jeff Johnson | 72f498b | 2019-02-26 18:37:25 -0800 | [diff] [blame] | 1262 | temp_u8 = hex_to_bin(in_ptr[j]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1263 | } else { |
Jeff Johnson | 72f498b | 2019-02-26 18:37:25 -0800 | [diff] [blame] | 1264 | temp_u8 = |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1265 | (hex_to_bin(in_ptr[j]) << 4) | |
| 1266 | (hex_to_bin(in_ptr[j + 1])); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1267 | } |
Jeff Johnson | 72f498b | 2019-02-26 18:37:25 -0800 | [diff] [blame] | 1268 | (*buf)[i++] = temp_u8; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1269 | } |
Jeff Johnson | 103f67a | 2019-02-26 17:11:01 -0800 | [diff] [blame] | 1270 | *buf_len = i; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1271 | return 0; |
| 1272 | } |
| 1273 | |
| 1274 | /** |
| 1275 | * hdd_parse_reassoc_command_data() - HDD Parse reassoc command data |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 1276 | * @command: Pointer to input data (its a NULL terminated string) |
Jeff Johnson | b7d5279 | 2019-02-26 12:42:08 -0800 | [diff] [blame] | 1277 | * @bssid: Pointer to target Ap bssid |
Jeff Johnson | d727cdc | 2019-02-26 12:47:05 -0800 | [diff] [blame] | 1278 | * @channel: Pointer to the Target AP channel |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1279 | * |
| 1280 | * This function parses the reasoc command data passed in the format |
| 1281 | * REASSOC<space><bssid><space><channel> |
| 1282 | * |
| 1283 | * Return: 0 for success non-zero for failure |
| 1284 | */ |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 1285 | static int hdd_parse_reassoc_command_v1_data(const uint8_t *command, |
Jeff Johnson | b7d5279 | 2019-02-26 12:42:08 -0800 | [diff] [blame] | 1286 | uint8_t *bssid, |
Jeff Johnson | d727cdc | 2019-02-26 12:47:05 -0800 | [diff] [blame] | 1287 | uint8_t *channel) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1288 | { |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1289 | const uint8_t *in_ptr = command; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1290 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1291 | if (_hdd_parse_bssid_and_chan(&in_ptr, bssid, channel)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1292 | return -EINVAL; |
| 1293 | |
| 1294 | return 0; |
| 1295 | } |
| 1296 | |
Naveen Rawat | 05376ee | 2016-07-18 16:43:32 -0700 | [diff] [blame] | 1297 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
Abhinav Kumar | eab2593 | 2018-07-13 11:48:43 +0530 | [diff] [blame] | 1298 | QDF_STATUS hdd_wma_send_fastreassoc_cmd(struct hdd_adapter *adapter, |
| 1299 | const tSirMacAddr bssid, |
Manikandan Mohan | 5c1e9ae | 2019-10-23 15:45:35 -0700 | [diff] [blame] | 1300 | uint32_t ch_freq) |
Naveen Rawat | 05376ee | 2016-07-18 16:43:32 -0700 | [diff] [blame] | 1301 | { |
Krunal Soni | 332f4af | 2017-06-01 14:36:17 -0700 | [diff] [blame] | 1302 | struct hdd_station_ctx *hdd_sta_ctx = |
| 1303 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | 8313b9d | 2018-03-14 15:09:28 -0700 | [diff] [blame] | 1304 | struct csr_roam_profile *roam_profile; |
Krunal Soni | 332f4af | 2017-06-01 14:36:17 -0700 | [diff] [blame] | 1305 | tSirMacAddr connected_bssid; |
Naveen Rawat | 05376ee | 2016-07-18 16:43:32 -0700 | [diff] [blame] | 1306 | |
Jeff Johnson | 8313b9d | 2018-03-14 15:09:28 -0700 | [diff] [blame] | 1307 | roam_profile = hdd_roam_profile(adapter); |
Jeff Johnson | e04b699 | 2019-02-27 14:06:55 -0800 | [diff] [blame] | 1308 | qdf_mem_copy(connected_bssid, hdd_sta_ctx->conn_info.bssid.bytes, |
Krunal Soni | 332f4af | 2017-06-01 14:36:17 -0700 | [diff] [blame] | 1309 | ETH_ALEN); |
Abhinav Kumar | eab2593 | 2018-07-13 11:48:43 +0530 | [diff] [blame] | 1310 | return sme_fast_reassoc(adapter->hdd_ctx->mac_handle, |
Manikandan Mohan | 5c1e9ae | 2019-10-23 15:45:35 -0700 | [diff] [blame] | 1311 | roam_profile, bssid, ch_freq, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 1312 | adapter->vdev_id, connected_bssid); |
Naveen Rawat | 05376ee | 2016-07-18 16:43:32 -0700 | [diff] [blame] | 1313 | } |
Naveen Rawat | 05376ee | 2016-07-18 16:43:32 -0700 | [diff] [blame] | 1314 | #endif |
| 1315 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 1316 | int hdd_reassoc(struct hdd_adapter *adapter, const uint8_t *bssid, |
Manikandan Mohan | 5c1e9ae | 2019-10-23 15:45:35 -0700 | [diff] [blame] | 1317 | uint32_t ch_freq, const handoff_src src) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1318 | { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 1319 | struct hdd_station_ctx *sta_ctx; |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 1320 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1321 | int ret = 0; |
Abhinav Kumar | eab2593 | 2018-07-13 11:48:43 +0530 | [diff] [blame] | 1322 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1323 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 1324 | if (!hdd_ctx) { |
Naveen Rawat | 05376ee | 2016-07-18 16:43:32 -0700 | [diff] [blame] | 1325 | hdd_err("Invalid hdd ctx"); |
| 1326 | return -EINVAL; |
| 1327 | } |
| 1328 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 1329 | if (QDF_STA_MODE != adapter->device_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1330 | hdd_warn("Unsupported in mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 1331 | qdf_opmode_str(adapter->device_mode), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1332 | adapter->device_mode); |
| 1333 | return -EINVAL; |
| 1334 | } |
| 1335 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 1336 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1337 | |
Vignesh Viswanathan | 7c43a7a | 2018-09-24 15:52:47 +0530 | [diff] [blame] | 1338 | /* |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 1339 | * pHddStaCtx->conn_info.conn_state is set to disconnected only |
Vignesh Viswanathan | 7c43a7a | 2018-09-24 15:52:47 +0530 | [diff] [blame] | 1340 | * after the disconnect done indication from SME. If the SME is |
| 1341 | * in the process of disconnecting, the SME Connection state is |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 1342 | * set to disconnected and the pHddStaCtx->conn_info.conn_state |
Vignesh Viswanathan | 7c43a7a | 2018-09-24 15:52:47 +0530 | [diff] [blame] | 1343 | * will still be associated till the disconnect is done. |
| 1344 | * So check both the HDD state and SME state here. |
| 1345 | * If not associated, no need to proceed with reassoc |
| 1346 | */ |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 1347 | if ((eConnectionState_Associated != sta_ctx->conn_info.conn_state) || |
Vignesh Viswanathan | 7c43a7a | 2018-09-24 15:52:47 +0530 | [diff] [blame] | 1348 | (!sme_is_conn_state_connected(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 1349 | adapter->vdev_id))) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 1350 | hdd_warn("Not associated"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1351 | ret = -EINVAL; |
| 1352 | goto exit; |
| 1353 | } |
| 1354 | |
| 1355 | /* |
| 1356 | * if the target bssid is same as currently associated AP, |
Deepak Dhamdhere | 5a36a4a | 2016-11-12 15:08:22 -0800 | [diff] [blame] | 1357 | * use the current connections's channel. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1358 | */ |
Jeff Johnson | e04b699 | 2019-02-27 14:06:55 -0800 | [diff] [blame] | 1359 | if (!memcmp(bssid, sta_ctx->conn_info.bssid.bytes, |
Manikandan Mohan | 5c1e9ae | 2019-10-23 15:45:35 -0700 | [diff] [blame] | 1360 | QDF_MAC_ADDR_SIZE)) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 1361 | hdd_warn("Reassoc BSSID is same as currently associated AP bssid"); |
Manikandan Mohan | 5c1e9ae | 2019-10-23 15:45:35 -0700 | [diff] [blame] | 1362 | ch_freq = sta_ctx->conn_info.chan_freq; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1363 | } |
| 1364 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1365 | if (QDF_STATUS_SUCCESS != |
Manikandan Mohan | 5c1e9ae | 2019-10-23 15:45:35 -0700 | [diff] [blame] | 1366 | wlan_hdd_validate_operation_channel(adapter, ch_freq)) { |
| 1367 | hdd_err("Invalid Ch freq: %d", ch_freq); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1368 | ret = -EINVAL; |
| 1369 | goto exit; |
| 1370 | } |
| 1371 | |
| 1372 | /* Proceed with reassoc */ |
Naveen Rawat | 05376ee | 2016-07-18 16:43:32 -0700 | [diff] [blame] | 1373 | if (roaming_offload_enabled(hdd_ctx)) { |
Manikandan Mohan | 5c1e9ae | 2019-10-23 15:45:35 -0700 | [diff] [blame] | 1374 | status = hdd_wma_send_fastreassoc_cmd(adapter, bssid, ch_freq); |
Abhinav Kumar | eab2593 | 2018-07-13 11:48:43 +0530 | [diff] [blame] | 1375 | if (status != QDF_STATUS_SUCCESS) { |
| 1376 | hdd_err("Failed to send fast reassoc cmd"); |
| 1377 | ret = -EINVAL; |
| 1378 | } |
Naveen Rawat | 05376ee | 2016-07-18 16:43:32 -0700 | [diff] [blame] | 1379 | } else { |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1380 | tCsrHandoffRequest handoff; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1381 | |
Manikandan Mohan | 5c1e9ae | 2019-10-23 15:45:35 -0700 | [diff] [blame] | 1382 | handoff.ch_freq = ch_freq; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1383 | handoff.src = src; |
| 1384 | qdf_mem_copy(handoff.bssid.bytes, bssid, QDF_MAC_ADDR_SIZE); |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 1385 | sme_handoff_request(hdd_ctx->mac_handle, adapter->vdev_id, |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1386 | &handoff); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1387 | } |
| 1388 | exit: |
| 1389 | return ret; |
| 1390 | } |
| 1391 | |
| 1392 | /** |
| 1393 | * hdd_parse_reassoc_v1() - parse version 1 of the REASSOC command |
| 1394 | * @adapter: Adapter upon which the command was received |
| 1395 | * @command: ASCII text command that was received |
| 1396 | * |
| 1397 | * This function parses the v1 REASSOC command with the format |
| 1398 | * |
| 1399 | * REASSOC xx:xx:xx:xx:xx:xx CH |
| 1400 | * |
| 1401 | * Where "xx:xx:xx:xx:xx:xx" is the Hex-ASCII representation of the |
| 1402 | * BSSID and CH is the ASCII representation of the channel. For |
| 1403 | * example |
| 1404 | * |
| 1405 | * REASSOC 00:0a:0b:11:22:33 48 |
| 1406 | * |
| 1407 | * Return: 0 for success non-zero for failure |
| 1408 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 1409 | 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] | 1410 | { |
| 1411 | uint8_t channel = 0; |
| 1412 | tSirMacAddr bssid; |
| 1413 | int ret; |
| 1414 | |
| 1415 | ret = hdd_parse_reassoc_command_v1_data(command, bssid, &channel); |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 1416 | if (ret) |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1417 | hdd_err("Failed to parse reassoc command data"); |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 1418 | else |
Manikandan Mohan | 5c1e9ae | 2019-10-23 15:45:35 -0700 | [diff] [blame] | 1419 | ret = hdd_reassoc(adapter, bssid, |
| 1420 | wlan_chan_to_freq(channel), REASSOC); |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 1421 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1422 | return ret; |
| 1423 | } |
| 1424 | |
| 1425 | /** |
| 1426 | * hdd_parse_reassoc_v2() - parse version 2 of the REASSOC command |
| 1427 | * @adapter: Adapter upon which the command was received |
| 1428 | * @command: Command that was received, ASCII command |
Jeff Johnson | 560dc56 | 2017-03-17 15:19:31 -0700 | [diff] [blame] | 1429 | * followed by binary data |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 1430 | * @total_len: Total length of the command received |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1431 | * |
| 1432 | * This function parses the v2 REASSOC command with the format |
| 1433 | * |
| 1434 | * REASSOC <android_wifi_reassoc_params> |
| 1435 | * |
| 1436 | * Return: 0 for success non-zero for failure |
| 1437 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 1438 | static int hdd_parse_reassoc_v2(struct hdd_adapter *adapter, |
| 1439 | const char *command, |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 1440 | int total_len) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1441 | { |
| 1442 | struct android_wifi_reassoc_params params; |
| 1443 | tSirMacAddr bssid; |
| 1444 | int ret; |
| 1445 | |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 1446 | if (total_len < sizeof(params) + 8) { |
| 1447 | hdd_err("Invalid command length"); |
| 1448 | return -EINVAL; |
| 1449 | } |
| 1450 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1451 | /* The params are located after "REASSOC " */ |
| 1452 | memcpy(¶ms, command + 8, sizeof(params)); |
| 1453 | |
| 1454 | if (!mac_pton(params.bssid, (u8 *) &bssid)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1455 | hdd_err("MAC address parsing failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1456 | ret = -EINVAL; |
| 1457 | } else { |
Manikandan Mohan | 5c1e9ae | 2019-10-23 15:45:35 -0700 | [diff] [blame] | 1458 | ret = hdd_reassoc(adapter, bssid, |
| 1459 | wlan_chan_to_freq(params.channel), REASSOC); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1460 | } |
| 1461 | return ret; |
| 1462 | } |
| 1463 | |
| 1464 | /** |
| 1465 | * hdd_parse_reassoc() - parse the REASSOC command |
| 1466 | * @adapter: Adapter upon which the command was received |
| 1467 | * @command: Command that was received |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 1468 | * @total_len: Total length of the command received |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1469 | * |
| 1470 | * There are two different versions of the REASSOC command. Version 1 |
| 1471 | * of the command contains a parameter list that is ASCII characters |
| 1472 | * whereas version 2 contains a combination of ASCII and binary |
| 1473 | * payload. Determine if a version 1 or a version 2 command is being |
| 1474 | * parsed by examining the parameters, and then dispatch the parser |
| 1475 | * that is appropriate for the command. |
| 1476 | * |
| 1477 | * Return: 0 for success non-zero for failure |
| 1478 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 1479 | 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] | 1480 | int total_len) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1481 | { |
| 1482 | int ret; |
| 1483 | |
| 1484 | /* both versions start with "REASSOC " |
| 1485 | * v1 has a bssid and channel # as an ASCII string |
| 1486 | * REASSOC xx:xx:xx:xx:xx:xx CH |
| 1487 | * v2 has a C struct |
| 1488 | * REASSOC <binary c struct> |
| 1489 | * |
| 1490 | * The first field in the v2 struct is also the bssid in ASCII. |
| 1491 | * But in the case of a v2 message the BSSID is NUL-terminated. |
| 1492 | * Hence we can peek at that offset to see if this is V1 or V2 |
| 1493 | * REASSOC xx:xx:xx:xx:xx:xx* |
| 1494 | * 1111111111222222 |
| 1495 | * 01234567890123456789012345 |
| 1496 | */ |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 1497 | |
| 1498 | if (total_len < 26) { |
| 1499 | hdd_err("Invalid command, total_len = %d", total_len); |
| 1500 | return -EINVAL; |
| 1501 | } |
| 1502 | |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 1503 | if (command[25]) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1504 | ret = hdd_parse_reassoc_v1(adapter, command); |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 1505 | else |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 1506 | ret = hdd_parse_reassoc_v2(adapter, command, total_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1507 | |
| 1508 | return ret; |
| 1509 | } |
| 1510 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1511 | /** |
| 1512 | * hdd_sendactionframe() - send a userspace-supplied action frame |
| 1513 | * @adapter: Adapter upon which the command was received |
| 1514 | * @bssid: BSSID target of the action frame |
| 1515 | * @channel: Channel upon which to send the frame |
| 1516 | * @dwell_time: Amount of time to dwell when the frame is sent |
| 1517 | * @payload_len:Length of the payload |
| 1518 | * @payload: Payload of the frame |
| 1519 | * |
| 1520 | * This function sends a userspace-supplied action frame |
| 1521 | * |
| 1522 | * Return: 0 for success non-zero for failure |
| 1523 | */ |
| 1524 | static int |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 1525 | hdd_sendactionframe(struct hdd_adapter *adapter, const uint8_t *bssid, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1526 | const uint8_t channel, const uint8_t dwell_time, |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 1527 | const int payload_len, const uint8_t *payload) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1528 | { |
| 1529 | struct ieee80211_channel chan; |
Jingxiang Ge | ce7c547 | 2019-07-23 16:19:23 +0800 | [diff] [blame] | 1530 | uint8_t conn_info_channel; |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 1531 | int frame_len, ret = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1532 | uint8_t *frame; |
| 1533 | struct ieee80211_hdr_3addr *hdr; |
| 1534 | u64 cookie; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 1535 | struct hdd_station_ctx *sta_ctx; |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 1536 | struct hdd_context *hdd_ctx; |
Jeff Johnson | ecdf83b | 2019-02-26 18:33:56 -0800 | [diff] [blame] | 1537 | tpSirMacVendorSpecificFrameHdr vendor = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1538 | (tpSirMacVendorSpecificFrameHdr) payload; |
| 1539 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) |
| 1540 | struct cfg80211_mgmt_tx_params params; |
| 1541 | #endif |
| 1542 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 1543 | if (QDF_STA_MODE != adapter->device_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1544 | hdd_warn("Unsupported in mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 1545 | qdf_opmode_str(adapter->device_mode), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1546 | adapter->device_mode); |
| 1547 | return -EINVAL; |
| 1548 | } |
| 1549 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 1550 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1551 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 1552 | |
| 1553 | /* if not associated, no need to send action frame */ |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 1554 | if (eConnectionState_Associated != sta_ctx->conn_info.conn_state) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 1555 | hdd_warn("Not associated"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1556 | ret = -EINVAL; |
| 1557 | goto exit; |
| 1558 | } |
| 1559 | |
| 1560 | /* |
| 1561 | * if the target bssid is different from currently associated AP, |
| 1562 | * then no need to send action frame |
| 1563 | */ |
Jeff Johnson | e04b699 | 2019-02-27 14:06:55 -0800 | [diff] [blame] | 1564 | if (memcmp(bssid, sta_ctx->conn_info.bssid.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1565 | QDF_MAC_ADDR_SIZE)) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 1566 | hdd_warn("STA is not associated to this AP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1567 | ret = -EINVAL; |
| 1568 | goto exit; |
| 1569 | } |
| 1570 | |
| 1571 | chan.center_freq = sme_chn_to_freq(channel); |
| 1572 | /* Check if it is specific action frame */ |
Jeff Johnson | ecdf83b | 2019-02-26 18:33:56 -0800 | [diff] [blame] | 1573 | if (vendor->category == |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1574 | SIR_MAC_ACTION_VENDOR_SPECIFIC_CATEGORY) { |
Jeff Johnson | 2971e3a | 2019-02-26 18:31:54 -0800 | [diff] [blame] | 1575 | static const uint8_t oui[] = { 0x00, 0x00, 0xf0 }; |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 1576 | |
Jeff Johnson | ecdf83b | 2019-02-26 18:33:56 -0800 | [diff] [blame] | 1577 | if (!qdf_mem_cmp(vendor->Oui, oui, 3)) { |
Jingxiang Ge | ce7c547 | 2019-07-23 16:19:23 +0800 | [diff] [blame] | 1578 | conn_info_channel = wlan_reg_freq_to_chan( |
| 1579 | hdd_ctx->pdev, |
Jingxiang Ge | ae80dc6 | 2019-08-13 17:32:22 +0800 | [diff] [blame] | 1580 | sta_ctx->conn_info.chan_freq); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1581 | /* |
| 1582 | * if the channel number is different from operating |
| 1583 | * channel then no need to send action frame |
| 1584 | */ |
| 1585 | if (channel != 0) { |
Jingxiang Ge | ce7c547 | 2019-07-23 16:19:23 +0800 | [diff] [blame] | 1586 | if (channel != conn_info_channel) { |
| 1587 | hdd_warn("channel(%u) is different from operating channel(%u)", |
| 1588 | channel, |
| 1589 | conn_info_channel); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1590 | ret = -EINVAL; |
| 1591 | goto exit; |
| 1592 | } |
| 1593 | /* |
| 1594 | * If channel number is specified and same |
| 1595 | * as home channel, ensure that action frame |
| 1596 | * is sent immediately by cancelling |
| 1597 | * roaming scans. Otherwise large dwell times |
| 1598 | * may cause long delays in sending action |
| 1599 | * frames. |
| 1600 | */ |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1601 | sme_abort_roam_scan(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 1602 | adapter->vdev_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1603 | } else { |
| 1604 | /* |
| 1605 | * 0 is accepted as current home channel, |
| 1606 | * delayed transmission of action frame is ok. |
| 1607 | */ |
Jingxiang Ge | ae80dc6 | 2019-08-13 17:32:22 +0800 | [diff] [blame] | 1608 | chan.center_freq = sta_ctx->conn_info.chan_freq; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1609 | } |
| 1610 | } |
| 1611 | } |
| 1612 | if (chan.center_freq == 0) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 1613 | hdd_err("Invalid channel number: %d", channel); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1614 | ret = -EINVAL; |
| 1615 | goto exit; |
| 1616 | } |
| 1617 | |
| 1618 | frame_len = payload_len + 24; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1619 | frame = qdf_mem_malloc(frame_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1620 | if (!frame) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1621 | hdd_err("memory allocation failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1622 | ret = -ENOMEM; |
| 1623 | goto exit; |
| 1624 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1625 | |
| 1626 | hdr = (struct ieee80211_hdr_3addr *)frame; |
| 1627 | hdr->frame_control = |
| 1628 | cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ACTION); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1629 | qdf_mem_copy(hdr->addr1, bssid, QDF_MAC_ADDR_SIZE); |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 1630 | qdf_mem_copy(hdr->addr2, adapter->mac_addr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1631 | QDF_MAC_ADDR_SIZE); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1632 | qdf_mem_copy(hdr->addr3, bssid, QDF_MAC_ADDR_SIZE); |
| 1633 | qdf_mem_copy(hdr + 1, payload, payload_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1634 | |
| 1635 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) |
| 1636 | params.chan = &chan; |
| 1637 | params.offchan = 0; |
| 1638 | params.wait = dwell_time; |
| 1639 | params.buf = frame; |
| 1640 | params.len = frame_len; |
| 1641 | params.no_cck = 1; |
| 1642 | params.dont_wait_for_ack = 1; |
| 1643 | ret = wlan_hdd_mgmt_tx(NULL, &adapter->wdev, ¶ms, &cookie); |
| 1644 | #else |
| 1645 | ret = wlan_hdd_mgmt_tx(NULL, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1646 | &(adapter->wdev), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1647 | &chan, 0, |
Amar Singhal | 01098f7 | 2015-10-08 11:55:32 -0700 | [diff] [blame] | 1648 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1649 | dwell_time, frame, frame_len, 1, 1, &cookie); |
| 1650 | #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0) */ |
| 1651 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1652 | qdf_mem_free(frame); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1653 | exit: |
| 1654 | return ret; |
| 1655 | } |
| 1656 | |
| 1657 | /** |
| 1658 | * hdd_parse_sendactionframe_v1() - parse version 1 of the |
| 1659 | * SENDACTIONFRAME command |
| 1660 | * @adapter: Adapter upon which the command was received |
| 1661 | * @command: ASCII text command that was received |
| 1662 | * |
| 1663 | * This function parses the v1 SENDACTIONFRAME command with the format |
| 1664 | * |
| 1665 | * SENDACTIONFRAME xx:xx:xx:xx:xx:xx CH DW xxxxxx |
| 1666 | * |
| 1667 | * Where "xx:xx:xx:xx:xx:xx" is the Hex-ASCII representation of the |
| 1668 | * BSSID, CH is the ASCII representation of the channel, DW is the |
| 1669 | * ASCII representation of the dwell time, and xxxxxx is the Hex-ASCII |
| 1670 | * payload. For example |
| 1671 | * |
| 1672 | * SENDACTIONFRAME 00:0a:0b:11:22:33 48 40 aabbccddee |
| 1673 | * |
| 1674 | * Return: 0 for success non-zero for failure |
| 1675 | */ |
| 1676 | static int |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 1677 | hdd_parse_sendactionframe_v1(struct hdd_adapter *adapter, const char *command) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1678 | { |
| 1679 | uint8_t channel = 0; |
| 1680 | uint8_t dwell_time = 0; |
| 1681 | uint8_t payload_len = 0; |
| 1682 | uint8_t *payload = NULL; |
| 1683 | tSirMacAddr bssid; |
| 1684 | int ret; |
| 1685 | |
| 1686 | ret = hdd_parse_send_action_frame_v1_data(command, bssid, &channel, |
| 1687 | &dwell_time, &payload, |
| 1688 | &payload_len); |
| 1689 | if (ret) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1690 | hdd_err("Failed to parse send action frame data"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1691 | } else { |
| 1692 | ret = hdd_sendactionframe(adapter, bssid, channel, |
| 1693 | dwell_time, payload_len, payload); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1694 | qdf_mem_free(payload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1695 | } |
| 1696 | |
| 1697 | return ret; |
| 1698 | } |
| 1699 | |
| 1700 | /** |
| 1701 | * hdd_parse_sendactionframe_v2() - parse version 2 of the |
| 1702 | * SENDACTIONFRAME command |
| 1703 | * @adapter: Adapter upon which the command was received |
| 1704 | * @command: Command that was received, ASCII command |
Jeff Johnson | 560dc56 | 2017-03-17 15:19:31 -0700 | [diff] [blame] | 1705 | * followed by binary data |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1706 | * |
| 1707 | * This function parses the v2 SENDACTIONFRAME command with the format |
| 1708 | * |
| 1709 | * SENDACTIONFRAME <android_wifi_af_params> |
| 1710 | * |
| 1711 | * Return: 0 for success non-zero for failure |
| 1712 | */ |
| 1713 | static int |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 1714 | hdd_parse_sendactionframe_v2(struct hdd_adapter *adapter, |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 1715 | const char *command, int total_len) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1716 | { |
| 1717 | struct android_wifi_af_params *params; |
| 1718 | tSirMacAddr bssid; |
| 1719 | int ret; |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 1720 | int len_wo_payload = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1721 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1722 | /* The params are located after "SENDACTIONFRAME " */ |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 1723 | total_len -= 16; |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 1724 | len_wo_payload = sizeof(*params) - ANDROID_WIFI_ACTION_FRAME_SIZE; |
| 1725 | if (total_len <= len_wo_payload) { |
| 1726 | hdd_err("Invalid command len"); |
| 1727 | return -EINVAL; |
| 1728 | } |
| 1729 | |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 1730 | params = (struct android_wifi_af_params *)(command + 16); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1731 | |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 1732 | if (params->len <= 0 || params->len > ANDROID_WIFI_ACTION_FRAME_SIZE || |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 1733 | (params->len > (total_len - len_wo_payload))) { |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 1734 | hdd_err("Invalid payload length: %d", params->len); |
| 1735 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1736 | } |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 1737 | |
| 1738 | if (!mac_pton(params->bssid, (u8 *)&bssid)) { |
| 1739 | hdd_err("MAC address parsing failed"); |
| 1740 | return -EINVAL; |
| 1741 | } |
| 1742 | |
| 1743 | if (params->channel < 0 || |
| 1744 | params->channel > WNI_CFG_CURRENT_CHANNEL_STAMAX) { |
| 1745 | hdd_err("Invalid channel: %d", params->channel); |
| 1746 | return -EINVAL; |
| 1747 | } |
| 1748 | |
| 1749 | if (params->dwell_time < 0) { |
| 1750 | hdd_err("Invalid dwell_time: %d", params->dwell_time); |
| 1751 | return -EINVAL; |
| 1752 | } |
| 1753 | |
| 1754 | ret = hdd_sendactionframe(adapter, bssid, params->channel, |
| 1755 | params->dwell_time, params->len, params->data); |
| 1756 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1757 | return ret; |
| 1758 | } |
| 1759 | |
| 1760 | /** |
| 1761 | * hdd_parse_sendactionframe() - parse the SENDACTIONFRAME command |
| 1762 | * @adapter: Adapter upon which the command was received |
| 1763 | * @command: Command that was received |
| 1764 | * |
| 1765 | * There are two different versions of the SENDACTIONFRAME command. |
| 1766 | * Version 1 of the command contains a parameter list that is ASCII |
| 1767 | * characters whereas version 2 contains a combination of ASCII and |
| 1768 | * binary payload. Determine if a version 1 or a version 2 command is |
| 1769 | * being parsed by examining the parameters, and then dispatch the |
| 1770 | * parser that is appropriate for the version of the command. |
| 1771 | * |
| 1772 | * Return: 0 for success non-zero for failure |
| 1773 | */ |
| 1774 | static int |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 1775 | hdd_parse_sendactionframe(struct hdd_adapter *adapter, const char *command, |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 1776 | int total_len) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1777 | { |
| 1778 | int ret; |
| 1779 | |
| 1780 | /* |
| 1781 | * both versions start with "SENDACTIONFRAME " |
| 1782 | * v1 has a bssid and other parameters as an ASCII string |
| 1783 | * SENDACTIONFRAME xx:xx:xx:xx:xx:xx CH DWELL LEN FRAME |
| 1784 | * v2 has a C struct |
| 1785 | * SENDACTIONFRAME <binary c struct> |
| 1786 | * |
| 1787 | * The first field in the v2 struct is also the bssid in ASCII. |
| 1788 | * But in the case of a v2 message the BSSID is NUL-terminated. |
| 1789 | * Hence we can peek at that offset to see if this is V1 or V2 |
| 1790 | * SENDACTIONFRAME xx:xx:xx:xx:xx:xx* |
| 1791 | * 111111111122222222223333 |
| 1792 | * 0123456789012345678901234567890123 |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 1793 | * For both the commands, a valid command must have atleast |
| 1794 | * first 34 length of data. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1795 | */ |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 1796 | if (total_len < 34) { |
| 1797 | hdd_err("Invalid command (total_len=%d)", total_len); |
| 1798 | return -EINVAL; |
| 1799 | } |
| 1800 | |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 1801 | if (command[33]) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1802 | ret = hdd_parse_sendactionframe_v1(adapter, command); |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 1803 | else |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 1804 | ret = hdd_parse_sendactionframe_v2(adapter, command, total_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1805 | |
| 1806 | return ret; |
| 1807 | } |
| 1808 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1809 | /** |
| 1810 | * hdd_parse_channellist() - HDD Parse channel list |
Liangwei Dong | 075afa7 | 2019-10-30 12:58:22 +0800 | [diff] [blame] | 1811 | * @hdd_ctx: hdd context |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 1812 | * @command: Pointer to input channel list |
Liangwei Dong | 075afa7 | 2019-10-30 12:58:22 +0800 | [diff] [blame] | 1813 | * @channel_freq_list: Pointer to local output array to record |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 1814 | * channel list |
Jeff Johnson | c3eac6c | 2019-02-26 18:09:53 -0800 | [diff] [blame] | 1815 | * @num_channels: Pointer to number of roam scan channels |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1816 | * |
| 1817 | * This function parses the channel list passed in the format |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 1818 | * SETROAMSCANCHANNELS<space><Number of channels><space>Channel 1<space> |
| 1819 | * Channel 2<space>Channel N |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1820 | * if the Number of channels (N) does not match with the actual number |
| 1821 | * of channels passed then take the minimum of N and count of |
| 1822 | * (Ch1, Ch2, ...Ch M). For example, if SETROAMSCANCHANNELS 3 36 40 44 48, |
| 1823 | * only 36, 40 and 44 shall be taken. If SETROAMSCANCHANNELS 5 36 40 44 48, |
| 1824 | * ignore 5 and take 36, 40, 44 and 48. This function does not take care of |
| 1825 | * removing duplicate channels from the list |
| 1826 | * |
| 1827 | * Return: 0 for success non-zero for failure |
| 1828 | */ |
| 1829 | static int |
Liangwei Dong | 075afa7 | 2019-10-30 12:58:22 +0800 | [diff] [blame] | 1830 | hdd_parse_channellist(struct hdd_context *hdd_ctx, |
| 1831 | const uint8_t *command, |
| 1832 | uint32_t *channel_freq_list, |
Jeff Johnson | c3eac6c | 2019-02-26 18:09:53 -0800 | [diff] [blame] | 1833 | uint8_t *num_channels) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1834 | { |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1835 | const uint8_t *in_ptr = command; |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 1836 | int temp_int; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1837 | int j = 0; |
| 1838 | int v = 0; |
| 1839 | char buf[32]; |
| 1840 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1841 | in_ptr = strnchr(command, strlen(command), SPACE_ASCII_VALUE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1842 | /* no argument after the command */ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 1843 | if (!in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1844 | return -EINVAL; |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1845 | else if (SPACE_ASCII_VALUE != *in_ptr) /* no space after the command */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1846 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1847 | |
| 1848 | /* remove empty spaces */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1849 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 1850 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1851 | |
| 1852 | /* no argument followed by spaces */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1853 | if ('\0' == *in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1854 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1855 | |
| 1856 | /* get the first argument ie the number of channels */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1857 | v = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1858 | if (1 != v) |
| 1859 | return -EINVAL; |
| 1860 | |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 1861 | v = kstrtos32(buf, 10, &temp_int); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1862 | if ((v < 0) || |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 1863 | (temp_int <= 0) || (temp_int > CFG_VALID_CHANNEL_LIST_LEN)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1864 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1865 | |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 1866 | *num_channels = temp_int; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1867 | |
Jeff Johnson | c3eac6c | 2019-02-26 18:09:53 -0800 | [diff] [blame] | 1868 | hdd_debug("Number of channels are: %d", *num_channels); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1869 | |
Jeff Johnson | c3eac6c | 2019-02-26 18:09:53 -0800 | [diff] [blame] | 1870 | for (j = 0; j < (*num_channels); j++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1871 | /* |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1872 | * in_ptr pointing to the beginning of first space after number |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1873 | * of channels |
| 1874 | */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1875 | in_ptr = strpbrk(in_ptr, " "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1876 | /* no channel list after the number of channels argument */ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 1877 | if (!in_ptr) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1878 | if (0 != j) { |
Jeff Johnson | c3eac6c | 2019-02-26 18:09:53 -0800 | [diff] [blame] | 1879 | *num_channels = j; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1880 | return 0; |
| 1881 | } else { |
| 1882 | return -EINVAL; |
| 1883 | } |
| 1884 | } |
| 1885 | |
| 1886 | /* remove empty space */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1887 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 1888 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1889 | |
| 1890 | /* |
| 1891 | * no channel list after the number of channels |
| 1892 | * argument and spaces |
| 1893 | */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1894 | if ('\0' == *in_ptr) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1895 | if (0 != j) { |
Jeff Johnson | c3eac6c | 2019-02-26 18:09:53 -0800 | [diff] [blame] | 1896 | *num_channels = j; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1897 | return 0; |
| 1898 | } else { |
| 1899 | return -EINVAL; |
| 1900 | } |
| 1901 | } |
| 1902 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1903 | v = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1904 | if (1 != v) |
| 1905 | return -EINVAL; |
| 1906 | |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 1907 | v = kstrtos32(buf, 10, &temp_int); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1908 | if ((v < 0) || |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 1909 | (temp_int <= 0) || |
| 1910 | (temp_int > WNI_CFG_CURRENT_CHANNEL_STAMAX)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1911 | return -EINVAL; |
| 1912 | } |
Liangwei Dong | 075afa7 | 2019-10-30 12:58:22 +0800 | [diff] [blame] | 1913 | channel_freq_list[j] = |
| 1914 | wlan_reg_chan_to_freq(hdd_ctx->pdev, temp_int); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1915 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 1916 | hdd_debug("Channel %d added to preferred channel list", |
Liangwei Dong | 075afa7 | 2019-10-30 12:58:22 +0800 | [diff] [blame] | 1917 | channel_freq_list[j]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1918 | } |
| 1919 | |
| 1920 | return 0; |
| 1921 | } |
| 1922 | |
| 1923 | /** |
| 1924 | * hdd_parse_set_roam_scan_channels_v1() - parse version 1 of the |
| 1925 | * SETROAMSCANCHANNELS command |
| 1926 | * @adapter: Adapter upon which the command was received |
| 1927 | * @command: ASCII text command that was received |
| 1928 | * |
| 1929 | * This function parses the v1 SETROAMSCANCHANNELS command with the format |
| 1930 | * |
| 1931 | * SETROAMSCANCHANNELS N C1 C2 ... Cn |
| 1932 | * |
| 1933 | * Where "N" is the ASCII representation of the number of channels and |
| 1934 | * C1 thru Cn is the ASCII representation of the channels. For example |
| 1935 | * |
| 1936 | * SETROAMSCANCHANNELS 4 36 40 44 48 |
| 1937 | * |
| 1938 | * Return: 0 for success non-zero for failure |
| 1939 | */ |
| 1940 | static int |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 1941 | hdd_parse_set_roam_scan_channels_v1(struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1942 | const char *command) |
| 1943 | { |
Liangwei Dong | 075afa7 | 2019-10-30 12:58:22 +0800 | [diff] [blame] | 1944 | uint32_t channel_freq_list[CFG_VALID_CHANNEL_LIST_LEN] = { 0 }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1945 | uint8_t num_chan = 0; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1946 | QDF_STATUS status; |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 1947 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1948 | int ret; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1949 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1950 | |
Liangwei Dong | 075afa7 | 2019-10-30 12:58:22 +0800 | [diff] [blame] | 1951 | if (!hdd_ctx) { |
| 1952 | hdd_err("invalid hdd ctx"); |
| 1953 | ret = -EINVAL; |
| 1954 | goto exit; |
| 1955 | } |
| 1956 | |
| 1957 | ret = hdd_parse_channellist(hdd_ctx, command, channel_freq_list, |
| 1958 | &num_chan); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1959 | if (ret) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1960 | hdd_err("Failed to parse channel list information"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1961 | goto exit; |
| 1962 | } |
| 1963 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 1964 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 1965 | TRACE_CODE_HDD_SETROAMSCANCHANNELS_IOCTL, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 1966 | adapter->vdev_id, num_chan); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1967 | |
Wu Gao | 0821b0d | 2019-01-11 17:31:11 +0800 | [diff] [blame] | 1968 | if (num_chan > CFG_VALID_CHANNEL_LIST_LEN) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1969 | hdd_err("number of channels (%d) supported exceeded max (%d)", |
Wu Gao | 0821b0d | 2019-01-11 17:31:11 +0800 | [diff] [blame] | 1970 | num_chan, CFG_VALID_CHANNEL_LIST_LEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1971 | ret = -EINVAL; |
| 1972 | goto exit; |
| 1973 | } |
| 1974 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1975 | mac_handle = hdd_ctx->mac_handle; |
Liangwei Dong | 075afa7 | 2019-10-30 12:58:22 +0800 | [diff] [blame] | 1976 | if (!sme_validate_channel_list(mac_handle, |
| 1977 | channel_freq_list, num_chan)) { |
Vignesh Viswanathan | a2f5ce58 | 2018-05-09 20:38:39 +0530 | [diff] [blame] | 1978 | hdd_err("List contains invalid channel(s)"); |
| 1979 | ret = -EINVAL; |
| 1980 | goto exit; |
| 1981 | } |
| 1982 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1983 | status = sme_change_roam_scan_channel_list(mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 1984 | adapter->vdev_id, |
Liangwei Dong | 075afa7 | 2019-10-30 12:58:22 +0800 | [diff] [blame] | 1985 | channel_freq_list, |
| 1986 | num_chan); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1987 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1988 | hdd_err("Failed to update channel list information"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1989 | ret = -EINVAL; |
| 1990 | goto exit; |
| 1991 | } |
| 1992 | exit: |
| 1993 | return ret; |
| 1994 | } |
| 1995 | |
| 1996 | /** |
| 1997 | * hdd_parse_set_roam_scan_channels_v2() - parse version 2 of the |
| 1998 | * SETROAMSCANCHANNELS command |
| 1999 | * @adapter: Adapter upon which the command was received |
| 2000 | * @command: Command that was received, ASCII command |
Jeff Johnson | 560dc56 | 2017-03-17 15:19:31 -0700 | [diff] [blame] | 2001 | * followed by binary data |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2002 | * |
| 2003 | * This function parses the v2 SETROAMSCANCHANNELS command with the format |
| 2004 | * |
| 2005 | * SETROAMSCANCHANNELS [N][C1][C2][Cn] |
| 2006 | * |
| 2007 | * The command begins with SETROAMSCANCHANNELS followed by a space, but |
| 2008 | * what follows the space is an array of u08 parameters. For example |
| 2009 | * |
| 2010 | * SETROAMSCANCHANNELS [0x04 0x24 0x28 0x2c 0x30] |
| 2011 | * |
| 2012 | * Return: 0 for success non-zero for failure |
| 2013 | */ |
| 2014 | static int |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 2015 | hdd_parse_set_roam_scan_channels_v2(struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2016 | const char *command) |
| 2017 | { |
| 2018 | const uint8_t *value; |
Liangwei Dong | 075afa7 | 2019-10-30 12:58:22 +0800 | [diff] [blame] | 2019 | uint32_t channel_freq_list[CFG_VALID_CHANNEL_LIST_LEN] = { 0 }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2020 | uint8_t channel; |
| 2021 | uint8_t num_chan; |
| 2022 | int i; |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 2023 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2024 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2025 | int ret = 0; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2026 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2027 | |
| 2028 | /* array of values begins after "SETROAMSCANCHANNELS " */ |
| 2029 | value = command + 20; |
| 2030 | |
| 2031 | num_chan = *value++; |
Wu Gao | 0821b0d | 2019-01-11 17:31:11 +0800 | [diff] [blame] | 2032 | if (num_chan > CFG_VALID_CHANNEL_LIST_LEN) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2033 | hdd_err("number of channels (%d) supported exceeded max (%d)", |
Wu Gao | 0821b0d | 2019-01-11 17:31:11 +0800 | [diff] [blame] | 2034 | num_chan, CFG_VALID_CHANNEL_LIST_LEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2035 | ret = -EINVAL; |
| 2036 | goto exit; |
| 2037 | } |
| 2038 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 2039 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 2040 | TRACE_CODE_HDD_SETROAMSCANCHANNELS_IOCTL, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 2041 | adapter->vdev_id, num_chan); |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 2042 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2043 | |
| 2044 | for (i = 0; i < num_chan; i++) { |
| 2045 | channel = *value++; |
Nachiket Kukade | caa2e84 | 2018-05-09 17:56:12 +0530 | [diff] [blame] | 2046 | if (!channel) { |
| 2047 | hdd_err("Channels end at index %d, expected %d", |
| 2048 | i, num_chan); |
| 2049 | ret = -EINVAL; |
| 2050 | goto exit; |
| 2051 | } |
| 2052 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2053 | if (channel > WNI_CFG_CURRENT_CHANNEL_STAMAX) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2054 | hdd_err("index %d invalid channel %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2055 | i, channel); |
| 2056 | ret = -EINVAL; |
| 2057 | goto exit; |
| 2058 | } |
Liangwei Dong | 075afa7 | 2019-10-30 12:58:22 +0800 | [diff] [blame] | 2059 | channel_freq_list[i] = wlan_reg_chan_to_freq(hdd_ctx->pdev, |
| 2060 | channel); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2061 | } |
Vignesh Viswanathan | a2f5ce58 | 2018-05-09 20:38:39 +0530 | [diff] [blame] | 2062 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2063 | mac_handle = hdd_ctx->mac_handle; |
Liangwei Dong | 075afa7 | 2019-10-30 12:58:22 +0800 | [diff] [blame] | 2064 | if (!sme_validate_channel_list(mac_handle, channel_freq_list, |
| 2065 | num_chan)) { |
Vignesh Viswanathan | a2f5ce58 | 2018-05-09 20:38:39 +0530 | [diff] [blame] | 2066 | hdd_err("List contains invalid channel(s)"); |
| 2067 | ret = -EINVAL; |
| 2068 | goto exit; |
| 2069 | } |
| 2070 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2071 | status = sme_change_roam_scan_channel_list(mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 2072 | adapter->vdev_id, |
Liangwei Dong | 075afa7 | 2019-10-30 12:58:22 +0800 | [diff] [blame] | 2073 | channel_freq_list, num_chan); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2074 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2075 | hdd_err("Failed to update channel list information"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2076 | ret = -EINVAL; |
| 2077 | goto exit; |
| 2078 | } |
| 2079 | exit: |
| 2080 | return ret; |
| 2081 | } |
| 2082 | |
| 2083 | /** |
| 2084 | * hdd_parse_set_roam_scan_channels() - parse the |
| 2085 | * SETROAMSCANCHANNELS command |
| 2086 | * @adapter: Adapter upon which the command was received |
| 2087 | * @command: Command that was received |
| 2088 | * |
| 2089 | * There are two different versions of the SETROAMSCANCHANNELS command. |
| 2090 | * Version 1 of the command contains a parameter list that is ASCII |
| 2091 | * characters whereas version 2 contains a binary payload. Determine |
| 2092 | * if a version 1 or a version 2 command is being parsed by examining |
| 2093 | * the parameters, and then dispatch the parser that is appropriate for |
| 2094 | * the command. |
| 2095 | * |
| 2096 | * Return: 0 for success non-zero for failure |
| 2097 | */ |
| 2098 | static int |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 2099 | 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] | 2100 | { |
| 2101 | const char *cursor; |
| 2102 | char ch; |
| 2103 | bool v1; |
| 2104 | int ret; |
| 2105 | |
| 2106 | /* start after "SETROAMSCANCHANNELS " */ |
| 2107 | cursor = command + 20; |
| 2108 | |
| 2109 | /* assume we have a version 1 command until proven otherwise */ |
| 2110 | v1 = true; |
| 2111 | |
| 2112 | /* v1 params will only contain ASCII digits and space */ |
| 2113 | while ((ch = *cursor++) && v1) { |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 2114 | if (!(isdigit(ch) || isspace(ch))) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2115 | v1 = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2116 | } |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 2117 | |
| 2118 | if (v1) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2119 | ret = hdd_parse_set_roam_scan_channels_v1(adapter, command); |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 2120 | else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2121 | ret = hdd_parse_set_roam_scan_channels_v2(adapter, command); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2122 | |
| 2123 | return ret; |
| 2124 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2125 | |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 2126 | #ifdef FEATURE_WLAN_ESE |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2127 | /** |
| 2128 | * hdd_parse_plm_cmd() - HDD Parse Plm command |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 2129 | * @command: Pointer to input data |
Jeff Johnson | a0b6c3c | 2019-02-26 11:04:52 -0800 | [diff] [blame] | 2130 | * @req: Pointer to output struct plm_req |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2131 | * |
| 2132 | * This function parses the plm command passed in the format |
| 2133 | * CCXPLMREQ<space><enable><space><dialog_token><space> |
| 2134 | * <meas_token><space><num_of_bursts><space><burst_int><space> |
| 2135 | * <measu duration><space><burst_len><space><desired_tx_pwr> |
| 2136 | * <space><multcast_addr><space><number_of_channels> |
| 2137 | * <space><channel_numbers> |
| 2138 | * |
| 2139 | * Return: 0 for success non-zero for failure |
| 2140 | */ |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 2141 | static QDF_STATUS hdd_parse_plm_cmd(uint8_t *command, |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 2142 | struct plm_req_params *req) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2143 | { |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2144 | uint8_t *in_ptr = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2145 | int count, content = 0, ret = 0; |
| 2146 | char buf[32]; |
| 2147 | |
| 2148 | /* move to argument list */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2149 | in_ptr = strnchr(command, strlen(command), SPACE_ASCII_VALUE); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2150 | if (!in_ptr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2151 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2152 | |
| 2153 | /* no space after the command */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2154 | if (SPACE_ASCII_VALUE != *in_ptr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2155 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2156 | |
| 2157 | /* remove empty spaces */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2158 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 2159 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2160 | |
| 2161 | /* START/STOP PLM req */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2162 | ret = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2163 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2164 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2165 | |
| 2166 | ret = kstrtos32(buf, 10, &content); |
| 2167 | if (ret < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2168 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2169 | |
Jeff Johnson | a0b6c3c | 2019-02-26 11:04:52 -0800 | [diff] [blame] | 2170 | req->enable = content; |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2171 | in_ptr = strpbrk(in_ptr, " "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2172 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2173 | if (!in_ptr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2174 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2175 | |
| 2176 | /* remove empty spaces */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2177 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 2178 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2179 | |
| 2180 | /* Dialog token of radio meas req containing meas reqIE */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2181 | ret = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2182 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2183 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2184 | |
| 2185 | ret = kstrtos32(buf, 10, &content); |
| 2186 | if (ret < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2187 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2188 | |
Jeff Johnson | a0b6c3c | 2019-02-26 11:04:52 -0800 | [diff] [blame] | 2189 | req->diag_token = content; |
| 2190 | hdd_debug("diag token %d", req->diag_token); |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2191 | in_ptr = strpbrk(in_ptr, " "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2192 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2193 | if (!in_ptr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2194 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2195 | |
| 2196 | /* remove empty spaces */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2197 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 2198 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2199 | |
| 2200 | /* measurement token of meas req IE */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2201 | ret = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2202 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2203 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2204 | |
| 2205 | ret = kstrtos32(buf, 10, &content); |
| 2206 | if (ret < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2207 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2208 | |
Jeff Johnson | a0b6c3c | 2019-02-26 11:04:52 -0800 | [diff] [blame] | 2209 | req->meas_token = content; |
| 2210 | hdd_debug("meas token %d", req->meas_token); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2211 | |
Jeff Johnson | a0b6c3c | 2019-02-26 11:04:52 -0800 | [diff] [blame] | 2212 | hdd_debug("PLM req %s", req->enable ? "START" : "STOP"); |
| 2213 | if (req->enable) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2214 | |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2215 | in_ptr = strpbrk(in_ptr, " "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2216 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2217 | if (!in_ptr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2218 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2219 | |
| 2220 | /* remove empty spaces */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2221 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 2222 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2223 | |
| 2224 | /* total number of bursts after which STA stops sending */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2225 | ret = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2226 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2227 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2228 | |
| 2229 | ret = kstrtos32(buf, 10, &content); |
| 2230 | if (ret < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2231 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2232 | |
| 2233 | if (content < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2234 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2235 | |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 2236 | req->num_bursts = content; |
| 2237 | hdd_debug("num bursts %d", req->num_bursts); |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2238 | in_ptr = strpbrk(in_ptr, " "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2239 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2240 | if (!in_ptr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2241 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2242 | |
| 2243 | /* remove empty spaces */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2244 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 2245 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2246 | |
| 2247 | /* burst interval in seconds */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2248 | ret = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2249 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2250 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2251 | |
| 2252 | ret = kstrtos32(buf, 10, &content); |
| 2253 | if (ret < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2254 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2255 | |
| 2256 | if (content <= 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2257 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2258 | |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 2259 | req->burst_int = content; |
| 2260 | hdd_debug("burst int %d", req->burst_int); |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2261 | in_ptr = strpbrk(in_ptr, " "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2262 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2263 | if (!in_ptr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2264 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2265 | |
| 2266 | /* remove empty spaces */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2267 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 2268 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2269 | |
| 2270 | /* 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] | 2271 | ret = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2272 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2273 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2274 | |
| 2275 | ret = kstrtos32(buf, 10, &content); |
| 2276 | if (ret < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2277 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2278 | |
| 2279 | if (content <= 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2280 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2281 | |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 2282 | req->meas_duration = content; |
| 2283 | hdd_debug("meas duration %d", req->meas_duration); |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2284 | in_ptr = strpbrk(in_ptr, " "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2285 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2286 | if (!in_ptr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2287 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2288 | |
| 2289 | /* remove empty spaces */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2290 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 2291 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2292 | |
| 2293 | /* burst length of PLM bursts */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2294 | ret = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2295 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2296 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2297 | |
| 2298 | ret = kstrtos32(buf, 10, &content); |
| 2299 | if (ret < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2300 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2301 | |
| 2302 | if (content <= 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2303 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2304 | |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 2305 | req->burst_len = content; |
| 2306 | hdd_debug("burst len %d", req->burst_len); |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2307 | in_ptr = strpbrk(in_ptr, " "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2308 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2309 | if (!in_ptr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2310 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2311 | |
| 2312 | /* remove empty spaces */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2313 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 2314 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2315 | |
| 2316 | /* desired tx power for transmission of PLM bursts */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2317 | ret = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2318 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2319 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2320 | |
| 2321 | ret = kstrtos32(buf, 10, &content); |
| 2322 | if (ret < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2323 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2324 | |
| 2325 | if (content <= 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2326 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2327 | |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 2328 | req->desired_tx_pwr = content; |
| 2329 | hdd_debug("desired tx pwr %d", req->desired_tx_pwr); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2330 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2331 | for (count = 0; count < QDF_MAC_ADDR_SIZE; count++) { |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2332 | in_ptr = strpbrk(in_ptr, " "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2333 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2334 | if (!in_ptr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2335 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2336 | |
| 2337 | /* remove empty spaces */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2338 | while ((SPACE_ASCII_VALUE == *in_ptr) |
| 2339 | && ('\0' != *in_ptr)) |
| 2340 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2341 | |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2342 | ret = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2343 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2344 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2345 | |
| 2346 | ret = kstrtos32(buf, 16, &content); |
| 2347 | if (ret < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2348 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2349 | |
Jeff Johnson | a0b6c3c | 2019-02-26 11:04:52 -0800 | [diff] [blame] | 2350 | req->mac_addr.bytes[count] = content; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2351 | } |
| 2352 | |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 2353 | hdd_debug("MAC addr " QDF_MAC_ADDR_STR, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 2354 | QDF_MAC_ADDR_ARRAY(req->mac_addr.bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2355 | |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2356 | in_ptr = strpbrk(in_ptr, " "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2357 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2358 | if (!in_ptr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2359 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2360 | |
| 2361 | /* remove empty spaces */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2362 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 2363 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2364 | |
| 2365 | /* number of channels */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2366 | ret = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2367 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2368 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2369 | |
| 2370 | ret = kstrtos32(buf, 10, &content); |
| 2371 | if (ret < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2372 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2373 | |
| 2374 | if (content < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2375 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2376 | |
Wu Gao | 0821b0d | 2019-01-11 17:31:11 +0800 | [diff] [blame] | 2377 | content = QDF_MIN(content, CFG_VALID_CHANNEL_LIST_LEN); |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 2378 | req->plm_num_ch = content; |
| 2379 | hdd_debug("num ch: %d", req->plm_num_ch); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2380 | |
| 2381 | /* Channel numbers */ |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 2382 | for (count = 0; count < req->plm_num_ch; count++) { |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2383 | in_ptr = strpbrk(in_ptr, " "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2384 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2385 | if (!in_ptr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2386 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2387 | |
| 2388 | /* remove empty spaces */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2389 | while ((SPACE_ASCII_VALUE == *in_ptr) |
| 2390 | && ('\0' != *in_ptr)) |
| 2391 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2392 | |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2393 | ret = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2394 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2395 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2396 | |
| 2397 | ret = kstrtos32(buf, 10, &content); |
Srinivas Girigowda | 0fb6cc4 | 2016-08-26 14:53:59 -0700 | [diff] [blame] | 2398 | if (ret < 0 || content <= 0 || |
| 2399 | content > WNI_CFG_CURRENT_CHANNEL_STAMAX) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2400 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2401 | |
wadesong | 88aa89a | 2019-11-04 12:34:12 +0800 | [diff] [blame] | 2402 | req->plm_ch_freq_list[count] = |
| 2403 | cds_chan_to_freq(content); |
| 2404 | hdd_debug(" ch-freq- %d", req->plm_ch_freq_list[count]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2405 | } |
| 2406 | } |
| 2407 | /* If PLM START */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2408 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2409 | } |
| 2410 | #endif |
| 2411 | |
| 2412 | #ifdef WLAN_FEATURE_EXTWOW_SUPPORT |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 2413 | /** |
| 2414 | * wlan_hdd_ready_to_extwow() - Callback function for enable ext wow |
| 2415 | * @cookie: callback context |
| 2416 | * @is_success: suspend status of ext wow |
| 2417 | * |
| 2418 | * Return: none |
| 2419 | */ |
| 2420 | static void wlan_hdd_ready_to_extwow(void *cookie, bool is_success) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2421 | { |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 2422 | struct osif_request *request = NULL; |
| 2423 | struct enable_ext_wow_priv *priv = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2424 | |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 2425 | request = osif_request_get(cookie); |
| 2426 | if (!request) { |
| 2427 | hdd_err("Obselete request"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2428 | return; |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 2429 | } |
| 2430 | priv = osif_request_priv(request); |
| 2431 | priv->ext_wow_should_suspend = is_success; |
| 2432 | |
| 2433 | osif_request_complete(request); |
| 2434 | osif_request_put(request); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2435 | } |
| 2436 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 2437 | static int hdd_enable_ext_wow(struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2438 | tpSirExtWoWParams arg_params) |
| 2439 | { |
| 2440 | tSirExtWoWParams params; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2441 | QDF_STATUS status; |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 2442 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2443 | int rc; |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 2444 | struct enable_ext_wow_priv *priv = NULL; |
| 2445 | struct osif_request *request = NULL; |
| 2446 | void *cookie = NULL; |
| 2447 | struct osif_request_params hdd_params = { |
| 2448 | .priv_size = sizeof(*priv), |
| 2449 | .timeout_ms = WLAN_WAIT_TIME_READY_TO_EXTWOW, |
| 2450 | }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2451 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2452 | qdf_mem_copy(¶ms, arg_params, sizeof(params)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2453 | |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 2454 | request = osif_request_alloc(&hdd_params); |
| 2455 | if (!request) { |
| 2456 | hdd_err("Request Allocation Failure"); |
| 2457 | return -ENOMEM; |
| 2458 | } |
| 2459 | cookie = osif_request_cookie(request); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2460 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2461 | status = sme_configure_ext_wow(hdd_ctx->mac_handle, ¶ms, |
| 2462 | &wlan_hdd_ready_to_extwow, |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 2463 | cookie); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2464 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2465 | hdd_err("sme_configure_ext_wow returned failure %d", |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2466 | status); |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 2467 | rc = -EPERM; |
| 2468 | goto exit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2469 | } |
| 2470 | |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 2471 | rc = osif_request_wait_for_response(request); |
| 2472 | if (rc) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2473 | hdd_err("Failed to get ready to extwow"); |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 2474 | rc = -EPERM; |
| 2475 | goto exit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2476 | } |
| 2477 | |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 2478 | priv = osif_request_priv(request); |
| 2479 | if (!priv->ext_wow_should_suspend) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2480 | hdd_err("Received ready to ExtWoW failure"); |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 2481 | rc = -EPERM; |
| 2482 | goto exit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2483 | } |
| 2484 | |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 2485 | if (ucfg_pmo_extwow_is_goto_suspend_enabled(hdd_ctx->psoc)) { |
Jeff Johnson | 17d6267 | 2017-03-27 08:00:11 -0700 | [diff] [blame] | 2486 | hdd_info("Received ready to ExtWoW. Going to suspend"); |
| 2487 | |
| 2488 | rc = wlan_hdd_cfg80211_suspend_wlan(hdd_ctx->wiphy, NULL); |
| 2489 | if (rc < 0) { |
| 2490 | hdd_err("wlan_hdd_cfg80211_suspend_wlan failed, error = %d", |
| 2491 | rc); |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 2492 | goto exit; |
Jeff Johnson | 17d6267 | 2017-03-27 08:00:11 -0700 | [diff] [blame] | 2493 | } |
| 2494 | rc = wlan_hdd_bus_suspend(); |
| 2495 | if (rc) { |
| 2496 | hdd_err("wlan_hdd_bus_suspend failed, status = %d", |
| 2497 | rc); |
| 2498 | wlan_hdd_cfg80211_resume_wlan(hdd_ctx->wiphy); |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 2499 | goto exit; |
Jeff Johnson | 17d6267 | 2017-03-27 08:00:11 -0700 | [diff] [blame] | 2500 | } |
| 2501 | } |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 2502 | |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 2503 | exit: |
| 2504 | osif_request_put(request); |
| 2505 | return rc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2506 | } |
| 2507 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 2508 | 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] | 2509 | int value) |
| 2510 | { |
| 2511 | tSirExtWoWParams params; |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 2512 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2513 | int rc; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 2514 | uint8_t pin1, pin2; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2515 | |
| 2516 | rc = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 2517 | if (rc) |
| 2518 | return rc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2519 | |
| 2520 | if (value < EXT_WOW_TYPE_APP_TYPE1 || |
| 2521 | value > EXT_WOW_TYPE_APP_TYPE1_2) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 2522 | hdd_err("Invalid type: %d", value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2523 | return -EINVAL; |
| 2524 | } |
| 2525 | |
| 2526 | if (value == EXT_WOW_TYPE_APP_TYPE1 && |
| 2527 | hdd_ctx->is_extwow_app_type1_param_set) |
| 2528 | params.type = value; |
| 2529 | else if (value == EXT_WOW_TYPE_APP_TYPE2 && |
| 2530 | hdd_ctx->is_extwow_app_type2_param_set) |
| 2531 | params.type = value; |
| 2532 | else if (value == EXT_WOW_TYPE_APP_TYPE1_2 && |
| 2533 | hdd_ctx->is_extwow_app_type1_param_set && |
| 2534 | hdd_ctx->is_extwow_app_type2_param_set) |
| 2535 | params.type = value; |
| 2536 | else { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2537 | hdd_err("Set app params before enable it value %d", |
| 2538 | value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2539 | return -EINVAL; |
| 2540 | } |
| 2541 | |
| 2542 | params.vdev_id = vdev_id; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 2543 | pin1 = ucfg_pmo_extwow_app1_wakeup_pin_num(hdd_ctx->psoc); |
| 2544 | pin2 = ucfg_pmo_extwow_app2_wakeup_pin_num(hdd_ctx->psoc); |
| 2545 | params.wakeup_pin_num = pin1 | (pin2 << 8); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2546 | |
| 2547 | return hdd_enable_ext_wow(adapter, ¶ms); |
| 2548 | } |
| 2549 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2550 | static int hdd_set_app_type1_params(mac_handle_t mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2551 | tpSirAppType1Params arg_params) |
| 2552 | { |
| 2553 | tSirAppType1Params params; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2554 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2555 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2556 | qdf_mem_copy(¶ms, arg_params, sizeof(params)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2557 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2558 | status = sme_configure_app_type1_params(mac_handle, ¶ms); |
| 2559 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2560 | hdd_err("sme_configure_app_type1_params returned failure %d", |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2561 | status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2562 | return -EPERM; |
| 2563 | } |
| 2564 | |
| 2565 | return 0; |
| 2566 | } |
| 2567 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 2568 | static int hdd_set_app_type1_parser(struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2569 | char *arg, int len) |
| 2570 | { |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 2571 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2572 | char id[20], password[20]; |
| 2573 | tSirAppType1Params params; |
Srinivas Girigowda | 0420991 | 2015-11-24 12:11:13 -0800 | [diff] [blame] | 2574 | int rc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2575 | |
| 2576 | rc = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 2577 | if (rc) |
| 2578 | return rc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2579 | |
| 2580 | if (2 != sscanf(arg, "%8s %16s", id, password)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2581 | hdd_err("Invalid Number of arguments"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2582 | return -EINVAL; |
| 2583 | } |
| 2584 | |
| 2585 | memset(¶ms, 0, sizeof(tSirAppType1Params)); |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 2586 | params.vdev_id = adapter->vdev_id; |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 2587 | qdf_copy_macaddr(¶ms.wakee_mac_addr, &adapter->mac_addr); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2588 | |
| 2589 | params.id_length = strlen(id); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2590 | qdf_mem_copy(params.identification_id, id, params.id_length); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2591 | params.pass_length = strlen(password); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2592 | qdf_mem_copy(params.password, password, params.pass_length); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2593 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 2594 | hdd_debug("%d %pM %.8s %u %.16s %u", |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2595 | params.vdev_id, params.wakee_mac_addr.bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2596 | params.identification_id, params.id_length, |
| 2597 | params.password, params.pass_length); |
| 2598 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2599 | return hdd_set_app_type1_params(hdd_ctx->mac_handle, ¶ms); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2600 | } |
| 2601 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2602 | static int hdd_set_app_type2_params(mac_handle_t mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2603 | tpSirAppType2Params arg_params) |
| 2604 | { |
| 2605 | tSirAppType2Params params; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2606 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2607 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2608 | qdf_mem_copy(¶ms, arg_params, sizeof(params)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2609 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2610 | status = sme_configure_app_type2_params(mac_handle, ¶ms); |
| 2611 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2612 | hdd_err("sme_configure_app_type2_params returned failure %d", |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2613 | status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2614 | return -EPERM; |
| 2615 | } |
| 2616 | |
| 2617 | return 0; |
| 2618 | } |
| 2619 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 2620 | static int hdd_set_app_type2_parser(struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2621 | char *arg, int len) |
| 2622 | { |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 2623 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2624 | char mac_addr[20], rc4_key[20]; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2625 | unsigned int gateway_mac[QDF_MAC_ADDR_SIZE]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2626 | tSirAppType2Params params; |
| 2627 | int ret; |
| 2628 | |
| 2629 | ret = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 2630 | if (ret) |
| 2631 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2632 | |
| 2633 | memset(¶ms, 0, sizeof(tSirAppType2Params)); |
| 2634 | |
Bhargav Shah | f4fd97d | 2015-07-08 10:21:37 +0530 | [diff] [blame] | 2635 | 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] | 2636 | mac_addr, rc4_key, (unsigned int *)¶ms.ip_id, |
| 2637 | (unsigned int *)¶ms.ip_device_ip, |
| 2638 | (unsigned int *)¶ms.ip_server_ip, |
| 2639 | (unsigned int *)¶ms.tcp_seq, |
| 2640 | (unsigned int *)¶ms.tcp_ack_seq, |
Bhargav Shah | f4fd97d | 2015-07-08 10:21:37 +0530 | [diff] [blame] | 2641 | (uint16_t *)¶ms.tcp_src_port, |
| 2642 | (uint16_t *)¶ms.tcp_dst_port, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2643 | (unsigned int *)¶ms.keepalive_init, |
| 2644 | (unsigned int *)¶ms.keepalive_min, |
| 2645 | (unsigned int *)¶ms.keepalive_max, |
| 2646 | (unsigned int *)¶ms.keepalive_inc, |
| 2647 | (unsigned int *)¶ms.tcp_tx_timeout_val, |
| 2648 | (unsigned int *)¶ms.tcp_rx_timeout_val); |
| 2649 | |
| 2650 | if (ret != 15 && ret != 7) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2651 | hdd_err("Invalid Number of arguments"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2652 | return -EINVAL; |
| 2653 | } |
| 2654 | |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 2655 | if (6 != sscanf(mac_addr, QDF_MAC_ADDR_STR, |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 2656 | &gateway_mac[0], &gateway_mac[1], &gateway_mac[2], |
| 2657 | &gateway_mac[3], &gateway_mac[4], &gateway_mac[5])) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2658 | hdd_err("Invalid MacAddress Input %s", mac_addr); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2659 | return -EINVAL; |
| 2660 | } |
| 2661 | |
| 2662 | if (params.tcp_src_port > WLAN_HDD_MAX_TCP_PORT || |
| 2663 | params.tcp_dst_port > WLAN_HDD_MAX_TCP_PORT) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2664 | hdd_err("Invalid TCP Port Number"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2665 | return -EINVAL; |
| 2666 | } |
| 2667 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2668 | qdf_mem_copy(¶ms.gateway_mac.bytes, (uint8_t *) &gateway_mac, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2669 | QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2670 | |
| 2671 | params.rc4_key_len = strlen(rc4_key); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2672 | qdf_mem_copy(params.rc4_key, rc4_key, params.rc4_key_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2673 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 2674 | params.vdev_id = adapter->vdev_id; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 2675 | |
| 2676 | if (!params.tcp_src_port) |
| 2677 | params.tcp_src_port = |
| 2678 | ucfg_pmo_extwow_app2_tcp_src_port(hdd_ctx->psoc); |
| 2679 | |
| 2680 | if (!params.tcp_dst_port) |
| 2681 | params.tcp_dst_port = |
| 2682 | ucfg_pmo_extwow_app2_tcp_dst_port(hdd_ctx->psoc); |
| 2683 | |
| 2684 | if (!params.keepalive_init) |
| 2685 | params.keepalive_init = |
| 2686 | ucfg_pmo_extwow_app2_init_ping_interval(hdd_ctx->psoc); |
| 2687 | |
| 2688 | if (!params.keepalive_min) |
| 2689 | params.keepalive_min = |
| 2690 | ucfg_pmo_extwow_app2_min_ping_interval(hdd_ctx->psoc); |
| 2691 | |
| 2692 | if (!params.keepalive_max) |
| 2693 | params.keepalive_max = |
| 2694 | ucfg_pmo_extwow_app2_max_ping_interval(hdd_ctx->psoc); |
| 2695 | |
| 2696 | if (!params.keepalive_inc) |
| 2697 | params.keepalive_inc = |
| 2698 | ucfg_pmo_extwow_app2_inc_ping_interval(hdd_ctx->psoc); |
| 2699 | |
| 2700 | if (!params.tcp_tx_timeout_val) |
| 2701 | params.tcp_tx_timeout_val = |
| 2702 | ucfg_pmo_extwow_app2_tcp_tx_timeout(hdd_ctx->psoc); |
| 2703 | |
| 2704 | if (!params.tcp_rx_timeout_val) |
| 2705 | params.tcp_rx_timeout_val = |
| 2706 | ucfg_pmo_extwow_app2_tcp_rx_timeout(hdd_ctx->psoc); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2707 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 2708 | 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] | 2709 | gateway_mac, rc4_key, params.ip_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2710 | params.ip_device_ip, params.ip_server_ip, params.tcp_seq, |
| 2711 | params.tcp_ack_seq, params.tcp_src_port, params.tcp_dst_port, |
| 2712 | params.keepalive_init, params.keepalive_min, |
| 2713 | params.keepalive_max, params.keepalive_inc, |
| 2714 | params.tcp_tx_timeout_val, params.tcp_rx_timeout_val); |
| 2715 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2716 | return hdd_set_app_type2_params(hdd_ctx->mac_handle, ¶ms); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2717 | } |
| 2718 | #endif /* WLAN_FEATURE_EXTWOW_SUPPORT */ |
| 2719 | |
| 2720 | /** |
| 2721 | * hdd_parse_setmaxtxpower_command() - HDD Parse MAXTXPOWER command |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 2722 | * @command: Pointer to MAXTXPOWER command |
Jeff Johnson | 93f47cf | 2019-02-26 13:08:48 -0800 | [diff] [blame] | 2723 | * @tx_power: Pointer to tx power |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2724 | * |
| 2725 | * This function parses the MAXTXPOWER command passed in the format |
| 2726 | * MAXTXPOWER<space>X(Tx power in dbm) |
| 2727 | * |
| 2728 | * For example input commands: |
| 2729 | * 1) MAXTXPOWER -8 -> This is translated into set max TX power to -8 dbm |
| 2730 | * 2) MAXTXPOWER -23 -> This is translated into set max TX power to -23 dbm |
| 2731 | * |
| 2732 | * Return: 0 for success non-zero for failure |
| 2733 | */ |
Jeff Johnson | 93f47cf | 2019-02-26 13:08:48 -0800 | [diff] [blame] | 2734 | static int hdd_parse_setmaxtxpower_command(uint8_t *command, int *tx_power) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2735 | { |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 2736 | uint8_t *in_ptr = command; |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 2737 | int temp_int; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2738 | int v = 0; |
Jeff Johnson | 93f47cf | 2019-02-26 13:08:48 -0800 | [diff] [blame] | 2739 | *tx_power = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2740 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 2741 | in_ptr = strnchr(command, strlen(command), SPACE_ASCII_VALUE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2742 | /* no argument after the command */ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2743 | if (!in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2744 | return -EINVAL; |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 2745 | else if (SPACE_ASCII_VALUE != *in_ptr) /* no space after the command */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2746 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2747 | |
| 2748 | /* remove empty spaces */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 2749 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 2750 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2751 | |
| 2752 | /* no argument followed by spaces */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 2753 | if ('\0' == *in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2754 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2755 | |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 2756 | v = kstrtos32(in_ptr, 10, &temp_int); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2757 | |
| 2758 | /* Range checking for passed parameter */ |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 2759 | 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] | 2760 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2761 | |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 2762 | *tx_power = temp_int; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2763 | |
Jeff Johnson | 93f47cf | 2019-02-26 13:08:48 -0800 | [diff] [blame] | 2764 | hdd_debug("SETMAXTXPOWER: %d", *tx_power); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2765 | |
| 2766 | return 0; |
| 2767 | } /* End of hdd_parse_setmaxtxpower_command */ |
| 2768 | |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2769 | 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] | 2770 | char *extra, uint8_t n, uint8_t *len) |
| 2771 | { |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2772 | uint32_t val = 0; |
| 2773 | |
| 2774 | if (!psoc || !command || !extra || !len) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2775 | hdd_err("argument passed for GETDWELLTIME is incorrect"); |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 2776 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2777 | } |
| 2778 | |
| 2779 | if (strncmp(command, "GETDWELLTIME ACTIVE MAX", 23) == 0) { |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2780 | ucfg_scan_cfg_get_active_dwelltime(psoc, &val); |
| 2781 | *len = scnprintf(extra, n, "GETDWELLTIME ACTIVE MAX %u\n", val); |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 2782 | return 0; |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 2783 | } |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 2784 | if (strncmp(command, "GETDWELLTIME PASSIVE MAX", 24) == 0) { |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2785 | ucfg_scan_cfg_get_passive_dwelltime(psoc, &val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2786 | *len = scnprintf(extra, n, "GETDWELLTIME PASSIVE MAX %u\n", |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2787 | val); |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 2788 | return 0; |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 2789 | } |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 2790 | if (strncmp(command, "GETDWELLTIME", 12) == 0) { |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2791 | ucfg_scan_cfg_get_active_dwelltime(psoc, &val); |
| 2792 | *len = scnprintf(extra, n, "GETDWELLTIME %u\n", val); |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 2793 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2794 | } |
| 2795 | |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 2796 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2797 | } |
| 2798 | |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2799 | 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] | 2800 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2801 | uint8_t *value = command; |
Srinivas Girigowda | a9ce5e6 | 2019-03-28 13:44:31 -0700 | [diff] [blame] | 2802 | int retval = 0, temp = 0; |
| 2803 | uint32_t val = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2804 | |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2805 | if (!psoc) { |
| 2806 | hdd_err("psoc is null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2807 | return -EINVAL; |
| 2808 | } |
| 2809 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2810 | if (strncmp(command, "SETDWELLTIME ACTIVE MAX", 23) == 0) { |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 2811 | if (drv_cmd_validate(command, 23)) |
| 2812 | return -EINVAL; |
| 2813 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2814 | value = value + 24; |
| 2815 | temp = kstrtou32(value, 10, &val); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2816 | if (temp || !cfg_in_range(CFG_ACTIVE_MAX_CHANNEL_TIME, val)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2817 | hdd_err("argument passed for SETDWELLTIME ACTIVE MAX is incorrect"); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2818 | return -EFAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2819 | } |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2820 | ucfg_scan_cfg_set_active_dwelltime(psoc, val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2821 | } else if (strncmp(command, "SETDWELLTIME PASSIVE MAX", 24) == 0) { |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 2822 | if (drv_cmd_validate(command, 24)) |
| 2823 | return -EINVAL; |
| 2824 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2825 | value = value + 25; |
| 2826 | temp = kstrtou32(value, 10, &val); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2827 | if (temp || !cfg_in_range(CFG_PASSIVE_MAX_CHANNEL_TIME, val)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2828 | hdd_err("argument passed for SETDWELLTIME PASSIVE MAX is incorrect"); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2829 | return -EFAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2830 | } |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2831 | ucfg_scan_cfg_set_passive_dwelltime(psoc, val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2832 | } else if (strncmp(command, "SETDWELLTIME", 12) == 0) { |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 2833 | if (drv_cmd_validate(command, 12)) |
| 2834 | return -EINVAL; |
| 2835 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2836 | value = value + 13; |
| 2837 | temp = kstrtou32(value, 10, &val); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2838 | if (temp || !cfg_in_range(CFG_ACTIVE_MAX_CHANNEL_TIME, val)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2839 | hdd_err("argument passed for SETDWELLTIME is incorrect"); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2840 | return -EFAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2841 | } |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2842 | ucfg_scan_cfg_set_active_dwelltime(psoc, val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2843 | } else { |
Sridhar Selvaraj | 48c4709 | 2017-07-31 18:18:14 +0530 | [diff] [blame] | 2844 | retval = -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2845 | } |
| 2846 | |
Sridhar Selvaraj | 48c4709 | 2017-07-31 18:18:14 +0530 | [diff] [blame] | 2847 | return retval; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2848 | } |
| 2849 | |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 2850 | struct link_status_priv { |
| 2851 | uint8_t link_status; |
| 2852 | }; |
| 2853 | |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2854 | /** |
| 2855 | * hdd_conc_set_dwell_time() - Set Concurrent dwell time parameters |
| 2856 | * @adapter: Adapter upon which the command was received |
| 2857 | * @command: ASCII text command that is received |
| 2858 | * |
| 2859 | * Driver commands: |
| 2860 | * wpa_cli DRIVER CONCSETDWELLTIME ACTIVE MAX <value> |
| 2861 | * wpa_cli DRIVER CONCSETDWELLTIME ACTIVE MIN <value> |
| 2862 | * wpa_cli DRIVER CONCSETDWELLTIME PASSIVE MAX <value> |
| 2863 | * wpa_cli DRIVER CONCSETDWELLTIME PASSIVE MIN <value> |
| 2864 | * |
| 2865 | * Return: 0 for success non-zero for failure |
| 2866 | */ |
Ashish Kumar Dhanotiya | 652c233 | 2018-12-11 17:33:17 +0530 | [diff] [blame] | 2867 | static int hdd_conc_set_dwell_time(struct hdd_adapter *adapter, |
| 2868 | uint8_t *command) |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2869 | { |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2870 | u8 *value = command; |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2871 | int val = 0, temp = 0; |
| 2872 | int retval = 0; |
| 2873 | |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2874 | if (strncmp(command, "CONCSETDWELLTIME ACTIVE MAX", 27) == 0) { |
| 2875 | if (drv_cmd_validate(command, 27)) { |
| 2876 | hdd_err("Invalid driver command"); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2877 | return -EINVAL; |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2878 | } |
| 2879 | |
| 2880 | value = value + 28; |
| 2881 | temp = kstrtou32(value, 10, &val); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2882 | if (temp || |
| 2883 | !cfg_in_range(CFG_ACTIVE_MAX_CHANNEL_TIME_CONC, val)) { |
Harprit Chhabada | 4691a47 | 2018-12-07 11:22:48 -0800 | [diff] [blame] | 2884 | hdd_err("CONC ACTIVE MAX value %d incorrect", val); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2885 | return -EFAULT; |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2886 | } |
Ashish Kumar Dhanotiya | 652c233 | 2018-12-11 17:33:17 +0530 | [diff] [blame] | 2887 | ucfg_scan_cfg_set_conc_active_dwelltime( |
| 2888 | (WLAN_HDD_GET_CTX(adapter))->psoc, val); |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2889 | } else if (strncmp(command, "CONCSETDWELLTIME PASSIVE MAX", 28) == 0) { |
| 2890 | if (drv_cmd_validate(command, 28)) { |
| 2891 | hdd_err("Invalid driver command"); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2892 | return -EINVAL; |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2893 | } |
| 2894 | |
| 2895 | value = value + 29; |
| 2896 | temp = kstrtou32(value, 10, &val); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2897 | if (temp || |
| 2898 | !cfg_in_range(CFG_PASSIVE_MAX_CHANNEL_TIME_CONC, val)) { |
Harprit Chhabada | 4691a47 | 2018-12-07 11:22:48 -0800 | [diff] [blame] | 2899 | hdd_err("CONC PASSIVE MAX val %d incorrect", val); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2900 | return -EFAULT; |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2901 | } |
Ashish Kumar Dhanotiya | 652c233 | 2018-12-11 17:33:17 +0530 | [diff] [blame] | 2902 | ucfg_scan_cfg_set_conc_passive_dwelltime( |
| 2903 | (WLAN_HDD_GET_CTX(adapter))->psoc, val); |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2904 | } else { |
| 2905 | retval = -EINVAL; |
| 2906 | } |
| 2907 | |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2908 | return retval; |
| 2909 | } |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2910 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2911 | static void hdd_get_link_status_cb(uint8_t status, void *context) |
| 2912 | { |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 2913 | struct osif_request *request; |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 2914 | struct link_status_priv *priv; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2915 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 2916 | request = osif_request_get(context); |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 2917 | if (!request) { |
| 2918 | hdd_err("Obsolete request"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2919 | return; |
| 2920 | } |
| 2921 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 2922 | priv = osif_request_priv(request); |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 2923 | priv->link_status = status; |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 2924 | osif_request_complete(request); |
| 2925 | osif_request_put(request); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2926 | } |
| 2927 | |
| 2928 | /** |
| 2929 | * wlan_hdd_get_link_status() - get link status |
Jeff Johnson | 25c7734 | 2017-10-02 13:28:03 -0700 | [diff] [blame] | 2930 | * @adapter: pointer to the adapter |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2931 | * |
| 2932 | * This function sends a request to query the link status and waits |
| 2933 | * on a timer to invoke the callback. if the callback is invoked then |
| 2934 | * latest link status shall be returned or otherwise cached value |
| 2935 | * will be returned. |
| 2936 | * |
| 2937 | * Return: On success, link status shall be returned. |
| 2938 | * On error or not associated, link status 0 will be returned. |
| 2939 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 2940 | static int wlan_hdd_get_link_status(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2941 | { |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2942 | struct hdd_station_ctx *sta_ctx; |
| 2943 | QDF_STATUS status; |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 2944 | int ret; |
| 2945 | void *cookie; |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 2946 | struct osif_request *request; |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 2947 | struct link_status_priv *priv; |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 2948 | static const struct osif_request_params params = { |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 2949 | .priv_size = sizeof(*priv), |
| 2950 | .timeout_ms = WLAN_WAIT_TIME_LINK_STATUS, |
| 2951 | }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2952 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 2953 | if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) { |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 2954 | hdd_warn("Recovery in Progress. State: 0x%x Ignore!!!", |
| 2955 | cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2956 | return 0; |
| 2957 | } |
| 2958 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 2959 | if ((QDF_STA_MODE != adapter->device_mode) && |
| 2960 | (QDF_P2P_CLIENT_MODE != adapter->device_mode)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2961 | hdd_warn("Unsupported in mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 2962 | qdf_opmode_str(adapter->device_mode), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2963 | adapter->device_mode); |
| 2964 | return 0; |
| 2965 | } |
| 2966 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 2967 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 2968 | if (eConnectionState_Associated != sta_ctx->conn_info.conn_state) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2969 | /* If not associated, then expected link status return |
| 2970 | * value is 0 |
| 2971 | */ |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 2972 | hdd_warn("Not associated!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2973 | return 0; |
| 2974 | } |
| 2975 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 2976 | request = osif_request_alloc(¶ms); |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 2977 | if (!request) { |
| 2978 | hdd_err("Request allocation failure"); |
| 2979 | return 0; |
| 2980 | } |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 2981 | cookie = osif_request_cookie(request); |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 2982 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2983 | status = sme_get_link_status(adapter->hdd_ctx->mac_handle, |
| 2984 | hdd_get_link_status_cb, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 2985 | cookie, adapter->vdev_id); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2986 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2987 | hdd_err("Unable to retrieve link status"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2988 | /* return a cached value */ |
| 2989 | } else { |
| 2990 | /* request is sent -- wait for the response */ |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 2991 | ret = osif_request_wait_for_response(request); |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 2992 | if (ret) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2993 | hdd_err("SME timed out while retrieving link status"); |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 2994 | /* return a cached value */ |
| 2995 | } else { |
| 2996 | /* update the adapter with the fresh results */ |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 2997 | priv = osif_request_priv(request); |
Jeff Johnson | bd4c4f0 | 2017-10-30 20:33:01 -0700 | [diff] [blame] | 2998 | adapter->link_status = priv->link_status; |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 2999 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3000 | } |
| 3001 | |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 3002 | /* |
| 3003 | * either we never sent a request, we sent a request and |
| 3004 | * received a response or we sent a request and timed out. |
| 3005 | * regardless we are done with the request. |
| 3006 | */ |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 3007 | osif_request_put(request); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3008 | |
| 3009 | /* either callback updated adapter stats or it has cached data */ |
Jeff Johnson | bd4c4f0 | 2017-10-30 20:33:01 -0700 | [diff] [blame] | 3010 | return adapter->link_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3011 | } |
| 3012 | |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 3013 | #ifdef FEATURE_WLAN_ESE |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3014 | /** |
| 3015 | * hdd_parse_ese_beacon_req() - Parse ese beacon request |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 3016 | * @command: Pointer to data |
Jeff Johnson | b2c3d04 | 2019-02-26 12:23:26 -0800 | [diff] [blame] | 3017 | * @req: Output pointer to store parsed ie information |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3018 | * |
| 3019 | * This function parses the ese beacon request passed in the format |
| 3020 | * CCXBEACONREQ<space><Number of fields><space><Measurement token> |
| 3021 | * <space>Channel 1<space>Scan Mode <space>Meas Duration<space>Channel N |
| 3022 | * <space>Scan Mode N<space>Meas Duration N |
| 3023 | * |
| 3024 | * If the Number of bcn req fields (N) does not match with the |
| 3025 | * actual number of fields passed then take N. |
| 3026 | * <Meas Token><Channel><Scan Mode> and <Meas Duration> are treated |
| 3027 | * as one pair. For example, CCXBEACONREQ 2 1 1 1 30 2 44 0 40. |
| 3028 | * This function does not take care of removing duplicate channels from the |
| 3029 | * list |
| 3030 | * |
| 3031 | * Return: 0 for success non-zero for failure |
| 3032 | */ |
gaurank kathpalia | 88f78ec | 2019-09-04 20:18:02 +0530 | [diff] [blame] | 3033 | static int hdd_parse_ese_beacon_req(struct wlan_objmgr_pdev *pdev, |
| 3034 | uint8_t *command, |
Jeff Johnson | b2c3d04 | 2019-02-26 12:23:26 -0800 | [diff] [blame] | 3035 | tCsrEseBeaconReq *req) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3036 | { |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 3037 | uint8_t *in_ptr = command; |
Srinivas Girigowda | 67e2da6 | 2016-07-19 16:33:01 -0700 | [diff] [blame] | 3038 | uint8_t input = 0; |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 3039 | uint32_t temp_int = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3040 | int j = 0, i = 0, v = 0; |
| 3041 | char buf[32]; |
| 3042 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 3043 | in_ptr = strnchr(command, strlen(command), SPACE_ASCII_VALUE); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 3044 | if (!in_ptr) /* no argument after the command */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3045 | return -EINVAL; |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 3046 | else if (SPACE_ASCII_VALUE != *in_ptr) /* no space after the command */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3047 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3048 | |
| 3049 | /* remove empty spaces */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 3050 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 3051 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3052 | |
| 3053 | /* no argument followed by spaces */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 3054 | if ('\0' == *in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3055 | return -EINVAL; |
| 3056 | |
Srinivas Girigowda | 476deeb | 2016-07-19 16:21:29 -0700 | [diff] [blame] | 3057 | /* Getting the first argument ie Number of IE fields */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 3058 | v = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3059 | if (1 != v) |
| 3060 | return -EINVAL; |
| 3061 | |
Srinivas Girigowda | 67e2da6 | 2016-07-19 16:33:01 -0700 | [diff] [blame] | 3062 | v = kstrtou8(buf, 10, &input); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3063 | if (v < 0) |
| 3064 | return -EINVAL; |
| 3065 | |
Srinivas Girigowda | 67e2da6 | 2016-07-19 16:33:01 -0700 | [diff] [blame] | 3066 | input = QDF_MIN(input, SIR_ESE_MAX_MEAS_IE_REQS); |
Jeff Johnson | b2c3d04 | 2019-02-26 12:23:26 -0800 | [diff] [blame] | 3067 | req->numBcnReqIe = input; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3068 | |
Jeff Johnson | b2c3d04 | 2019-02-26 12:23:26 -0800 | [diff] [blame] | 3069 | hdd_debug("Number of Bcn Req Ie fields: %d", req->numBcnReqIe); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3070 | |
Jeff Johnson | b2c3d04 | 2019-02-26 12:23:26 -0800 | [diff] [blame] | 3071 | for (j = 0; j < (req->numBcnReqIe); j++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3072 | for (i = 0; i < 4; i++) { |
| 3073 | /* |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 3074 | * in_ptr pointing to the beginning of 1st space |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3075 | * after number of ie fields |
| 3076 | */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 3077 | in_ptr = strpbrk(in_ptr, " "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3078 | /* no ie data after the number of ie fields argument */ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 3079 | if (!in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3080 | return -EINVAL; |
| 3081 | |
| 3082 | /* remove empty space */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 3083 | while ((SPACE_ASCII_VALUE == *in_ptr) |
| 3084 | && ('\0' != *in_ptr)) |
| 3085 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3086 | |
| 3087 | /* |
| 3088 | * no ie data after the number of ie fields |
| 3089 | * argument and spaces |
| 3090 | */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 3091 | if ('\0' == *in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3092 | return -EINVAL; |
| 3093 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 3094 | v = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3095 | if (1 != v) |
| 3096 | return -EINVAL; |
| 3097 | |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 3098 | v = kstrtou32(buf, 10, &temp_int); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3099 | if (v < 0) |
| 3100 | return -EINVAL; |
| 3101 | |
| 3102 | switch (i) { |
| 3103 | case 0: /* Measurement token */ |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 3104 | if (!temp_int) { |
Srinivas Girigowda | 67e2da6 | 2016-07-19 16:33:01 -0700 | [diff] [blame] | 3105 | hdd_err("Invalid Measurement Token: %u", |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 3106 | temp_int); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3107 | return -EINVAL; |
| 3108 | } |
Jeff Johnson | b2c3d04 | 2019-02-26 12:23:26 -0800 | [diff] [blame] | 3109 | req->bcnReq[j].measurementToken = |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 3110 | temp_int; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3111 | break; |
| 3112 | |
| 3113 | case 1: /* Channel number */ |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 3114 | if (!temp_int || |
| 3115 | (temp_int > |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3116 | WNI_CFG_CURRENT_CHANNEL_STAMAX)) { |
Srinivas Girigowda | 67e2da6 | 2016-07-19 16:33:01 -0700 | [diff] [blame] | 3117 | hdd_err("Invalid Channel Number: %u", |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 3118 | temp_int); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3119 | return -EINVAL; |
| 3120 | } |
gaurank kathpalia | 88f78ec | 2019-09-04 20:18:02 +0530 | [diff] [blame] | 3121 | req->bcnReq[j].ch_freq = |
| 3122 | wlan_reg_chan_to_freq(pdev, temp_int); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3123 | break; |
| 3124 | |
| 3125 | case 2: /* Scan mode */ |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 3126 | if ((temp_int < eSIR_PASSIVE_SCAN) |
| 3127 | || (temp_int > eSIR_BEACON_TABLE)) { |
Srinivas Girigowda | 67e2da6 | 2016-07-19 16:33:01 -0700 | [diff] [blame] | 3128 | hdd_err("Invalid Scan Mode: %u Expected{0|1|2}", |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 3129 | temp_int); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3130 | return -EINVAL; |
| 3131 | } |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 3132 | req->bcnReq[j].scanMode = temp_int; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3133 | break; |
| 3134 | |
| 3135 | case 3: /* Measurement duration */ |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 3136 | if ((!temp_int |
Jeff Johnson | b2c3d04 | 2019-02-26 12:23:26 -0800 | [diff] [blame] | 3137 | && (req->bcnReq[j].scanMode != |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3138 | eSIR_BEACON_TABLE)) || |
Jeff Johnson | b2c3d04 | 2019-02-26 12:23:26 -0800 | [diff] [blame] | 3139 | (req->bcnReq[j].scanMode == |
Srinivas Girigowda | 67e2da6 | 2016-07-19 16:33:01 -0700 | [diff] [blame] | 3140 | eSIR_BEACON_TABLE)) { |
| 3141 | hdd_err("Invalid Measurement Duration: %u", |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 3142 | temp_int); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3143 | return -EINVAL; |
| 3144 | } |
Jeff Johnson | b2c3d04 | 2019-02-26 12:23:26 -0800 | [diff] [blame] | 3145 | req->bcnReq[j].measurementDuration = |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 3146 | temp_int; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3147 | break; |
| 3148 | } |
| 3149 | } |
| 3150 | } |
| 3151 | |
Jeff Johnson | b2c3d04 | 2019-02-26 12:23:26 -0800 | [diff] [blame] | 3152 | for (j = 0; j < req->numBcnReqIe; j++) { |
gaurank kathpalia | 88f78ec | 2019-09-04 20:18:02 +0530 | [diff] [blame] | 3153 | hdd_debug("Index: %d Measurement Token: %u ch_freq: %u Scan Mode: %u Measurement Duration: %u", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3154 | j, |
Jeff Johnson | b2c3d04 | 2019-02-26 12:23:26 -0800 | [diff] [blame] | 3155 | req->bcnReq[j].measurementToken, |
gaurank kathpalia | 88f78ec | 2019-09-04 20:18:02 +0530 | [diff] [blame] | 3156 | req->bcnReq[j].ch_freq, |
Jeff Johnson | b2c3d04 | 2019-02-26 12:23:26 -0800 | [diff] [blame] | 3157 | req->bcnReq[j].scanMode, |
| 3158 | req->bcnReq[j].measurementDuration); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3159 | } |
| 3160 | |
| 3161 | return 0; |
| 3162 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3163 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3164 | /** |
| 3165 | * hdd_parse_get_cckm_ie() - HDD Parse and fetch the CCKM IE |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 3166 | * @command: Pointer to input data |
Jeff Johnson | 64c01b1 | 2019-02-26 13:12:50 -0800 | [diff] [blame] | 3167 | * @cckm_ie: Pointer to output cckm Ie |
Jeff Johnson | ecbb79f | 2019-02-26 13:10:24 -0800 | [diff] [blame] | 3168 | * @cckm_ie_len: Pointer to output cckm ie length |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3169 | * |
| 3170 | * This function parses the SETCCKM IE command |
| 3171 | * SETCCKMIE<space><ie data> |
| 3172 | * |
| 3173 | * Return: 0 for success non-zero for failure |
| 3174 | */ |
Jeff Johnson | 64c01b1 | 2019-02-26 13:12:50 -0800 | [diff] [blame] | 3175 | 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] | 3176 | uint8_t *cckm_ie_len) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3177 | { |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 3178 | uint8_t *in_ptr = command; |
Jeff Johnson | aae00ae | 2019-02-26 17:25:11 -0800 | [diff] [blame] | 3179 | uint8_t *end_ptr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3180 | int j = 0; |
| 3181 | int i = 0; |
Jeff Johnson | 72f498b | 2019-02-26 18:37:25 -0800 | [diff] [blame] | 3182 | uint8_t temp_u8 = 0; |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 3183 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 3184 | in_ptr = strnchr(command, strlen(command), SPACE_ASCII_VALUE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3185 | /* no argument after the command */ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 3186 | if (!in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3187 | return -EINVAL; |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 3188 | else if (SPACE_ASCII_VALUE != *in_ptr) /* no space after the command */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3189 | return -EINVAL; |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 3190 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3191 | /* remove empty spaces */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 3192 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 3193 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3194 | /* no argument followed by spaces */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 3195 | if ('\0' == *in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3196 | return -EINVAL; |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 3197 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3198 | /* find the length of data */ |
Jeff Johnson | aae00ae | 2019-02-26 17:25:11 -0800 | [diff] [blame] | 3199 | end_ptr = in_ptr; |
| 3200 | while (('\0' != *end_ptr)) { |
| 3201 | end_ptr++; |
Jeff Johnson | ecbb79f | 2019-02-26 13:10:24 -0800 | [diff] [blame] | 3202 | ++(*cckm_ie_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3203 | } |
Jeff Johnson | ecbb79f | 2019-02-26 13:10:24 -0800 | [diff] [blame] | 3204 | if (*cckm_ie_len <= 0) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3205 | return -EINVAL; |
| 3206 | /* |
| 3207 | * Allocate the number of bytes based on the number of input characters |
| 3208 | * whether it is even or odd. |
| 3209 | * if the number of input characters are even, then we need N / 2 byte. |
| 3210 | * if the number of input characters are odd, then we need do |
| 3211 | * (N + 1) / 2 to compensate rounding off. |
| 3212 | * For example, if N = 18, then (18 + 1) / 2 = 9 bytes are enough. |
| 3213 | * If N = 19, then we need 10 bytes, hence (19 + 1) / 2 = 10 bytes |
| 3214 | */ |
Jeff Johnson | 64c01b1 | 2019-02-26 13:12:50 -0800 | [diff] [blame] | 3215 | *cckm_ie = qdf_mem_malloc((*cckm_ie_len + 1) / 2); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 3216 | if (!*cckm_ie) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3217 | hdd_err("qdf_mem_malloc failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3218 | return -ENOMEM; |
| 3219 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3220 | /* |
| 3221 | * the buffer received from the upper layer is character buffer, |
| 3222 | * we need to prepare the buffer taking 2 characters in to a U8 hex |
| 3223 | * decimal number for example 7f0000f0...form a buffer to contain |
| 3224 | * 7f in 0th location, 00 in 1st and f0 in 3rd location |
| 3225 | */ |
Jeff Johnson | ecbb79f | 2019-02-26 13:10:24 -0800 | [diff] [blame] | 3226 | for (i = 0, j = 0; j < *cckm_ie_len; j += 2) { |
Jeff Johnson | 72f498b | 2019-02-26 18:37:25 -0800 | [diff] [blame] | 3227 | temp_u8 = (hex_to_bin(in_ptr[j]) << 4) | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 3228 | (hex_to_bin(in_ptr[j + 1])); |
Jeff Johnson | 72f498b | 2019-02-26 18:37:25 -0800 | [diff] [blame] | 3229 | (*cckm_ie)[i++] = temp_u8; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3230 | } |
Jeff Johnson | ecbb79f | 2019-02-26 13:10:24 -0800 | [diff] [blame] | 3231 | *cckm_ie_len = i; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3232 | return 0; |
| 3233 | } |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 3234 | #endif /* FEATURE_WLAN_ESE */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3235 | |
Jeff Johnson | b3f8043 | 2019-02-26 20:25:38 -0800 | [diff] [blame] | 3236 | 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] | 3237 | { |
Jeff Johnson | 1a0c72b | 2019-02-26 20:29:43 -0800 | [diff] [blame] | 3238 | tSirRateUpdateInd rate_update = {0}; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3239 | QDF_STATUS status; |
Jeff Johnson | 25c7734 | 2017-10-02 13:28:03 -0700 | [diff] [blame] | 3240 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 3241 | bool bval = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3242 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 3243 | if (!hdd_ctx) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3244 | hdd_err("HDD context is null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3245 | return -EINVAL; |
| 3246 | } |
Jeff Johnson | 25c7734 | 2017-10-02 13:28:03 -0700 | [diff] [blame] | 3247 | if ((QDF_IBSS_MODE != adapter->device_mode) && |
| 3248 | (QDF_SAP_MODE != adapter->device_mode) && |
| 3249 | (QDF_STA_MODE != adapter->device_mode)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3250 | hdd_err("Received SETMCRATE cmd in invalid mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 3251 | qdf_opmode_str(adapter->device_mode), |
| 3252 | adapter->device_mode); |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3253 | 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] | 3254 | return -EINVAL; |
| 3255 | } |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 3256 | |
| 3257 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 3258 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 3259 | hdd_err("unable to get vht_enable2x2"); |
| 3260 | return -EINVAL; |
| 3261 | } |
Jeff Johnson | 1a0c72b | 2019-02-26 20:29:43 -0800 | [diff] [blame] | 3262 | rate_update.nss = (bval == 0) ? 0 : 1; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 3263 | |
Jeff Johnson | 1a0c72b | 2019-02-26 20:29:43 -0800 | [diff] [blame] | 3264 | rate_update.dev_mode = adapter->device_mode; |
| 3265 | rate_update.mcastDataRate24GHz = target_rate; |
| 3266 | rate_update.mcastDataRate24GHzTxFlag = 1; |
| 3267 | rate_update.mcastDataRate5GHz = target_rate; |
| 3268 | rate_update.bcastDataRate = -1; |
| 3269 | qdf_copy_macaddr(&rate_update.bssid, &adapter->mac_addr); |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 3270 | hdd_debug("MC Target rate %d, mac = %pM, dev_mode %s(%d)", |
Jeff Johnson | 1a0c72b | 2019-02-26 20:29:43 -0800 | [diff] [blame] | 3271 | rate_update.mcastDataRate24GHz, rate_update.bssid.bytes, |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 3272 | qdf_opmode_str(adapter->device_mode), adapter->device_mode); |
Jeff Johnson | 1a0c72b | 2019-02-26 20:29:43 -0800 | [diff] [blame] | 3273 | status = sme_send_rate_update_ind(hdd_ctx->mac_handle, &rate_update); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3274 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3275 | hdd_err("SETMCRATE failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3276 | return -EFAULT; |
| 3277 | } |
| 3278 | return 0; |
| 3279 | } |
| 3280 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3281 | static int drv_cmd_p2p_dev_addr(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3282 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3283 | uint8_t *command, |
| 3284 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3285 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3286 | { |
Dustin Brown | ee22071 | 2018-04-19 16:24:23 -0700 | [diff] [blame] | 3287 | struct qdf_mac_addr *addr = &hdd_ctx->p2p_device_address; |
| 3288 | size_t user_size = qdf_min(sizeof(addr->bytes), |
| 3289 | (size_t)priv_data->total_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3290 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3291 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 3292 | TRACE_CODE_HDD_P2P_DEV_ADDR_IOCTL, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3293 | adapter->vdev_id, |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3294 | (unsigned int)(*(addr->bytes + 2) << 24 | |
Dustin Brown | ee22071 | 2018-04-19 16:24:23 -0700 | [diff] [blame] | 3295 | *(addr->bytes + 3) << 16 | |
| 3296 | *(addr->bytes + 4) << 8 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3297 | *(addr->bytes + 5))); |
| 3298 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3299 | |
Dustin Brown | ee22071 | 2018-04-19 16:24:23 -0700 | [diff] [blame] | 3300 | if (copy_to_user(priv_data->buf, addr->bytes, user_size)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3301 | hdd_err("failed to copy data to user buffer"); |
Dustin Brown | ee22071 | 2018-04-19 16:24:23 -0700 | [diff] [blame] | 3302 | return -EFAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3303 | } |
| 3304 | |
Dustin Brown | ee22071 | 2018-04-19 16:24:23 -0700 | [diff] [blame] | 3305 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3306 | } |
| 3307 | |
| 3308 | /** |
| 3309 | * drv_cmd_p2p_set_noa() - Handler for P2P_SET_NOA driver command |
| 3310 | * @adapter: Adapter on which the command was received |
| 3311 | * @hdd_ctx: HDD global context |
| 3312 | * @command: Entire driver command received from userspace |
| 3313 | * @command_len: Length of @command |
| 3314 | * @priv_data: Pointer to ioctl private data structure |
| 3315 | * |
Jeff Johnson | 78073fa | 2018-05-06 16:08:58 -0700 | [diff] [blame] | 3316 | * This is a trivial command handler function which simply forwards the |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3317 | * command to the actual command processor within the P2P module. |
| 3318 | * |
| 3319 | * Return: 0 on success, non-zero on failure |
| 3320 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3321 | static int drv_cmd_p2p_set_noa(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3322 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3323 | uint8_t *command, |
| 3324 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3325 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3326 | { |
| 3327 | return hdd_set_p2p_noa(adapter->dev, command); |
| 3328 | } |
| 3329 | |
| 3330 | /** |
| 3331 | * drv_cmd_p2p_set_ps() - Handler for P2P_SET_PS driver command |
| 3332 | * @adapter: Adapter on which the command was received |
| 3333 | * @hdd_ctx: HDD global context |
| 3334 | * @command: Entire driver command received from userspace |
| 3335 | * @command_len: Length of @command |
| 3336 | * @priv_data: Pointer to ioctl private data structure |
| 3337 | * |
Jeff Johnson | 78073fa | 2018-05-06 16:08:58 -0700 | [diff] [blame] | 3338 | * This is a trivial command handler function which simply forwards the |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3339 | * command to the actual command processor within the P2P module. |
| 3340 | * |
| 3341 | * Return: 0 on success, non-zero on failure |
| 3342 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3343 | static int drv_cmd_p2p_set_ps(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3344 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3345 | uint8_t *command, |
| 3346 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3347 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3348 | { |
| 3349 | return hdd_set_p2p_opps(adapter->dev, command); |
| 3350 | } |
| 3351 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3352 | static int drv_cmd_set_band(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3353 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3354 | uint8_t *command, |
| 3355 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3356 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3357 | { |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 3358 | int err; |
| 3359 | uint8_t band; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3360 | |
| 3361 | /* |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 3362 | * Parse the band value passed from userspace. The first 8 bytes |
| 3363 | * 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] | 3364 | */ |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 3365 | err = kstrtou8(command + command_len + 1, 10, &band); |
| 3366 | if (err) { |
| 3367 | hdd_err("error %d parsing userspace band parameter", err); |
| 3368 | return err; |
| 3369 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3370 | |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 3371 | return hdd_reg_set_band(adapter->dev, band); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3372 | } |
| 3373 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3374 | static int drv_cmd_set_wmmps(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3375 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3376 | uint8_t *command, |
| 3377 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3378 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3379 | { |
| 3380 | return hdd_wmmps_helper(adapter, command); |
| 3381 | } |
| 3382 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3383 | static inline int drv_cmd_country(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3384 | struct hdd_context *hdd_ctx, |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 3385 | uint8_t *command, |
| 3386 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3387 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3388 | { |
Sourav Mohapatra | a30c457 | 2018-05-22 11:18:39 +0530 | [diff] [blame] | 3389 | char *country_code; |
| 3390 | |
| 3391 | country_code = strnchr(command, strlen(command), ' '); |
| 3392 | /* no argument after the command */ |
| 3393 | if (!country_code) |
| 3394 | return -EINVAL; |
| 3395 | |
| 3396 | /* no space after the command */ |
| 3397 | if (*country_code != SPACE_ASCII_VALUE) |
| 3398 | return -EINVAL; |
| 3399 | |
| 3400 | country_code++; |
| 3401 | |
| 3402 | /* removing empty spaces */ |
| 3403 | while ((*country_code == SPACE_ASCII_VALUE) && |
| 3404 | (*country_code != '\0')) |
| 3405 | country_code++; |
| 3406 | |
| 3407 | /* no or less than 2 arguments followed by spaces */ |
| 3408 | if (*country_code == '\0' || *(country_code + 1) == '\0') |
| 3409 | return -EINVAL; |
| 3410 | |
| 3411 | return hdd_reg_set_country(hdd_ctx, country_code); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3412 | } |
| 3413 | |
Rajeev Kumar Sirasanagandla | 32ae804 | 2019-03-25 16:37:02 +0530 | [diff] [blame] | 3414 | /** |
| 3415 | * drv_cmd_get_country() - Helper function to get current county code |
| 3416 | * @adapter: pointer to adapter on which request is received |
| 3417 | * @hdd_ctx: pointer to hdd context |
| 3418 | * @command: command name |
| 3419 | * @command_len: command buffer length |
| 3420 | * @priv_data: output pointer to hold current country code |
| 3421 | * |
| 3422 | * Return: On success 0, negative value on error. |
| 3423 | */ |
| 3424 | static int drv_cmd_get_country(struct hdd_adapter *adapter, |
| 3425 | struct hdd_context *hdd_ctx, |
| 3426 | uint8_t *command, uint8_t command_len, |
| 3427 | struct hdd_priv_data *priv_data) |
| 3428 | { |
| 3429 | uint8_t buf[SIZE_OF_GETCOUNTRYREV_OUTPUT] = {0}; |
| 3430 | uint8_t cc[REG_ALPHA2_LEN + 1]; |
| 3431 | int ret = 0, len; |
| 3432 | |
| 3433 | qdf_mem_copy(cc, hdd_ctx->reg.alpha2, REG_ALPHA2_LEN); |
| 3434 | cc[REG_ALPHA2_LEN] = '\0'; |
| 3435 | |
| 3436 | len = scnprintf(buf, sizeof(buf), "%s %s", |
| 3437 | "GETCOUNTRYREV", cc); |
| 3438 | hdd_debug("buf = %s", buf); |
| 3439 | len = QDF_MIN(priv_data->total_len, len + 1); |
| 3440 | if (copy_to_user(priv_data->buf, buf, len)) { |
| 3441 | hdd_err("failed to copy data to user buffer"); |
| 3442 | ret = -EFAULT; |
| 3443 | } |
| 3444 | |
| 3445 | return ret; |
| 3446 | } |
| 3447 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3448 | static int drv_cmd_set_roam_trigger(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3449 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3450 | uint8_t *command, |
| 3451 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3452 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3453 | { |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3454 | int ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3455 | uint8_t *value = command; |
| 3456 | int8_t rssi = 0; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3457 | uint8_t lookup_threshold = cfg_default( |
| 3458 | CFG_LFR_NEIGHBOR_LOOKUP_RSSI_THRESHOLD); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3459 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3460 | |
| 3461 | /* Move pointer to ahead of SETROAMTRIGGER<delimiter> */ |
| 3462 | value = value + command_len + 1; |
| 3463 | |
| 3464 | /* Convert the value from ascii to integer */ |
| 3465 | ret = kstrtos8(value, 10, &rssi); |
| 3466 | if (ret < 0) { |
| 3467 | /* |
| 3468 | * If the input value is greater than max value of datatype, |
| 3469 | * then also kstrtou8 fails |
| 3470 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3471 | 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] | 3472 | cfg_min(CFG_LFR_NEIGHBOR_LOOKUP_RSSI_THRESHOLD), |
| 3473 | cfg_max(CFG_LFR_NEIGHBOR_LOOKUP_RSSI_THRESHOLD)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3474 | ret = -EINVAL; |
| 3475 | goto exit; |
| 3476 | } |
| 3477 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3478 | lookup_threshold = abs(rssi); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3479 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3480 | if (!cfg_in_range(CFG_LFR_NEIGHBOR_LOOKUP_RSSI_THRESHOLD, |
| 3481 | lookup_threshold)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3482 | 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] | 3483 | lookup_threshold, |
| 3484 | cfg_min(CFG_LFR_NEIGHBOR_LOOKUP_RSSI_THRESHOLD), |
| 3485 | cfg_max(CFG_LFR_NEIGHBOR_LOOKUP_RSSI_THRESHOLD)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3486 | ret = -EINVAL; |
| 3487 | goto exit; |
| 3488 | } |
| 3489 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3490 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 3491 | TRACE_CODE_HDD_SETROAMTRIGGER_IOCTL, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3492 | adapter->vdev_id, lookup_threshold); |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3493 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 3494 | hdd_debug("Received Command to Set Roam trigger (Neighbor lookup threshold) = %d", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3495 | lookup_threshold); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3496 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3497 | status = sme_set_neighbor_lookup_rssi_threshold(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3498 | adapter->vdev_id, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3499 | lookup_threshold); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3500 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3501 | hdd_err("Failed to set roam trigger, try again"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3502 | ret = -EPERM; |
| 3503 | goto exit; |
| 3504 | } |
| 3505 | |
| 3506 | exit: |
| 3507 | return ret; |
| 3508 | } |
| 3509 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3510 | static int drv_cmd_get_roam_trigger(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3511 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3512 | uint8_t *command, |
| 3513 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3514 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3515 | { |
| 3516 | int ret = 0; |
Srinivas Dasari | 9249a98 | 2019-09-16 14:56:27 +0530 | [diff] [blame] | 3517 | uint8_t lookup_threshold; |
| 3518 | int rssi; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3519 | char extra[32]; |
| 3520 | uint8_t len = 0; |
Srinivas Dasari | 9249a98 | 2019-09-16 14:56:27 +0530 | [diff] [blame] | 3521 | QDF_STATUS status; |
| 3522 | |
| 3523 | status = sme_get_neighbor_lookup_rssi_threshold(hdd_ctx->mac_handle, |
| 3524 | adapter->vdev_id, |
| 3525 | &lookup_threshold); |
| 3526 | if (QDF_IS_STATUS_ERROR(status)) |
| 3527 | return qdf_status_to_os_return(status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3528 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3529 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 3530 | TRACE_CODE_HDD_GETROAMTRIGGER_IOCTL, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3531 | adapter->vdev_id, lookup_threshold); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3532 | |
Srinivas Dasari | 9249a98 | 2019-09-16 14:56:27 +0530 | [diff] [blame] | 3533 | hdd_debug("vdev_id: %u, lookup_threshold: %u", |
| 3534 | adapter->vdev_id, lookup_threshold); |
| 3535 | |
| 3536 | rssi = (-1) * lookup_threshold; |
| 3537 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3538 | len = scnprintf(extra, sizeof(extra), "%s %d", command, rssi); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3539 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3540 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3541 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3542 | ret = -EFAULT; |
| 3543 | } |
| 3544 | |
| 3545 | return ret; |
| 3546 | } |
| 3547 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3548 | static int drv_cmd_set_roam_scan_period(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3549 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3550 | uint8_t *command, |
| 3551 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3552 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3553 | { |
| 3554 | int ret = 0; |
| 3555 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3556 | uint8_t roam_scan_period = 0; |
| 3557 | uint16_t empty_scan_refresh_period = |
| 3558 | cfg_default(CFG_LFR_EMPTY_SCAN_REFRESH_PERIOD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3559 | |
| 3560 | /* input refresh period is in terms of seconds */ |
| 3561 | |
| 3562 | /* Move pointer to ahead of SETROAMSCANPERIOD<delimiter> */ |
| 3563 | value = value + command_len + 1; |
| 3564 | |
| 3565 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3566 | ret = kstrtou8(value, 10, &roam_scan_period); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3567 | if (ret < 0) { |
| 3568 | /* |
| 3569 | * If the input value is greater than max value of datatype, |
| 3570 | * then also kstrtou8 fails |
| 3571 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3572 | 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] | 3573 | (cfg_min(CFG_LFR_EMPTY_SCAN_REFRESH_PERIOD) / 1000), |
| 3574 | (cfg_max(CFG_LFR_EMPTY_SCAN_REFRESH_PERIOD) / 1000)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3575 | ret = -EINVAL; |
| 3576 | goto exit; |
| 3577 | } |
| 3578 | |
Srinivas Dasari | b5d9f3e | 2019-08-22 01:43:42 +0530 | [diff] [blame] | 3579 | if (!ucfg_mlme_validate_scan_period(roam_scan_period * 1000)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3580 | ret = -EINVAL; |
| 3581 | goto exit; |
| 3582 | } |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3583 | |
| 3584 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 3585 | TRACE_CODE_HDD_SETROAMSCANPERIOD_IOCTL, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3586 | adapter->vdev_id, roam_scan_period); |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3587 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3588 | empty_scan_refresh_period = roam_scan_period * 1000; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3589 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 3590 | 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] | 3591 | roam_scan_period); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3592 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3593 | sme_update_empty_scan_refresh_period(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3594 | adapter->vdev_id, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3595 | empty_scan_refresh_period); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3596 | |
| 3597 | exit: |
| 3598 | return ret; |
| 3599 | } |
| 3600 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3601 | static int drv_cmd_get_roam_scan_period(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3602 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3603 | uint8_t *command, |
| 3604 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3605 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3606 | { |
| 3607 | int ret = 0; |
Srinivas Dasari | 456aa70 | 2019-09-17 14:19:50 +0530 | [diff] [blame] | 3608 | uint16_t empty_scan_refresh_period; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3609 | char extra[32]; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3610 | uint8_t len; |
Srinivas Dasari | 456aa70 | 2019-09-17 14:19:50 +0530 | [diff] [blame] | 3611 | QDF_STATUS status; |
| 3612 | |
| 3613 | status = sme_get_empty_scan_refresh_period(hdd_ctx->mac_handle, |
| 3614 | adapter->vdev_id, |
| 3615 | &empty_scan_refresh_period); |
| 3616 | if (QDF_IS_STATUS_ERROR(status)) |
| 3617 | return qdf_status_to_os_return(status); |
| 3618 | |
| 3619 | hdd_debug("vdev_id: %u, empty_scan_refresh_period: %u", |
| 3620 | adapter->vdev_id, empty_scan_refresh_period); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3621 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3622 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 3623 | TRACE_CODE_HDD_GETROAMSCANPERIOD_IOCTL, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3624 | adapter->vdev_id, |
Jeff Johnson | 9625945 | 2019-02-26 20:38:17 -0800 | [diff] [blame] | 3625 | empty_scan_refresh_period); |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3626 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3627 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3628 | "GETROAMSCANPERIOD", |
Jeff Johnson | 9625945 | 2019-02-26 20:38:17 -0800 | [diff] [blame] | 3629 | (empty_scan_refresh_period / 1000)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3630 | /* Returned value is in units of seconds */ |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3631 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3632 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3633 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3634 | ret = -EFAULT; |
| 3635 | } |
| 3636 | |
| 3637 | return ret; |
| 3638 | } |
| 3639 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3640 | 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] | 3641 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3642 | uint8_t *command, |
| 3643 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3644 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3645 | { |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3646 | int ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3647 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3648 | uint8_t roam_scan_refresh_period = 0; |
| 3649 | uint16_t neighbor_scan_refresh_period = |
| 3650 | cfg_default(CFG_LFR_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3651 | |
| 3652 | /* input refresh period is in terms of seconds */ |
| 3653 | /* Move pointer to ahead of SETROAMSCANREFRESHPERIOD<delimiter> */ |
| 3654 | value = value + command_len + 1; |
| 3655 | |
| 3656 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3657 | ret = kstrtou8(value, 10, &roam_scan_refresh_period); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3658 | if (ret < 0) { |
| 3659 | /* |
| 3660 | * If the input value is greater than max value of datatype, |
| 3661 | * then also kstrtou8 fails |
| 3662 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3663 | 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] | 3664 | (cfg_min(CFG_LFR_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD) |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3665 | / 1000), |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3666 | (cfg_max(CFG_LFR_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD) |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3667 | / 1000)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3668 | ret = -EINVAL; |
| 3669 | goto exit; |
| 3670 | } |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3671 | |
| 3672 | if (!cfg_in_range(CFG_LFR_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD, |
| 3673 | roam_scan_refresh_period)) { |
| 3674 | hdd_err("Neighbor scan results refresh period value %d is out of range (Min: %d Max: %d)", |
| 3675 | roam_scan_refresh_period, |
| 3676 | (cfg_min(CFG_LFR_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD) |
| 3677 | / 1000), |
| 3678 | (cfg_max(CFG_LFR_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD) |
| 3679 | / 1000)); |
| 3680 | ret = -EINVAL; |
| 3681 | goto exit; |
| 3682 | } |
| 3683 | neighbor_scan_refresh_period = roam_scan_refresh_period * 1000; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3684 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 3685 | 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] | 3686 | neighbor_scan_refresh_period); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3687 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3688 | sme_set_neighbor_scan_refresh_period(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3689 | adapter->vdev_id, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3690 | neighbor_scan_refresh_period); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3691 | |
| 3692 | exit: |
| 3693 | return ret; |
| 3694 | } |
| 3695 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3696 | 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] | 3697 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3698 | uint8_t *command, |
| 3699 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3700 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3701 | { |
| 3702 | int ret = 0; |
| 3703 | uint16_t value = |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3704 | sme_get_neighbor_scan_refresh_period(hdd_ctx->mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3705 | char extra[32]; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3706 | uint8_t len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3707 | |
| 3708 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3709 | "GETROAMSCANREFRESHPERIOD", |
| 3710 | (value / 1000)); |
| 3711 | /* Returned value is in units of seconds */ |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3712 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3713 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3714 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3715 | ret = -EFAULT; |
| 3716 | } |
| 3717 | |
| 3718 | return ret; |
| 3719 | } |
| 3720 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3721 | static int drv_cmd_set_roam_mode(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3722 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3723 | uint8_t *command, |
| 3724 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3725 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3726 | { |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3727 | mac_handle_t mac_handle; |
| 3728 | int ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3729 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3730 | uint8_t roam_mode = cfg_default(CFG_LFR_FEATURE_ENABLED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3731 | |
| 3732 | /* Move pointer to ahead of SETROAMMODE<delimiter> */ |
| 3733 | value = value + SIZE_OF_SETROAMMODE + 1; |
| 3734 | |
| 3735 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3736 | ret = kstrtou8(value, 10, &roam_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3737 | if (ret < 0) { |
| 3738 | /* |
| 3739 | * If the input value is greater than max value of datatype, |
| 3740 | * then also kstrtou8 fails |
| 3741 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3742 | hdd_err("kstrtou8 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3743 | cfg_min(CFG_LFR_FEATURE_ENABLED), |
| 3744 | cfg_max(CFG_LFR_FEATURE_ENABLED)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3745 | ret = -EINVAL; |
| 3746 | goto exit; |
| 3747 | } |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3748 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3749 | hdd_debug("Received Command to Set Roam Mode = %d", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3750 | roam_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3751 | /* |
| 3752 | * Note that |
| 3753 | * SETROAMMODE 0 is to enable LFR while |
| 3754 | * SETROAMMODE 1 is to disable LFR, but |
| 3755 | * notify_is_fast_roam_ini_feature_enabled 0/1 is to |
| 3756 | * enable/disable. So, we have to invert the value |
| 3757 | * to call sme_update_is_fast_roam_ini_feature_enabled. |
| 3758 | */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3759 | if (roam_mode) { |
| 3760 | /* Roam enable */ |
| 3761 | roam_mode = cfg_min(CFG_LFR_FEATURE_ENABLED); |
| 3762 | } else { |
| 3763 | /* Roam disable */ |
| 3764 | roam_mode = cfg_max(CFG_LFR_FEATURE_ENABLED); |
| 3765 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3766 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3767 | ucfg_mlme_set_lfr_enabled(hdd_ctx->psoc, (bool)roam_mode); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3768 | mac_handle = hdd_ctx->mac_handle; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3769 | if (roam_mode) { |
| 3770 | ucfg_mlme_set_roam_scan_offload_enabled(hdd_ctx->psoc, |
| 3771 | (bool)roam_mode); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3772 | sme_update_is_fast_roam_ini_feature_enabled(mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3773 | adapter->vdev_id, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3774 | roam_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3775 | } else { |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3776 | sme_update_is_fast_roam_ini_feature_enabled(mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3777 | adapter->vdev_id, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3778 | roam_mode); |
| 3779 | ucfg_mlme_set_roam_scan_offload_enabled(hdd_ctx->psoc, |
| 3780 | roam_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3781 | } |
| 3782 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3783 | exit: |
| 3784 | return ret; |
| 3785 | } |
| 3786 | |
Pragaspathi Thilagaraj | aa8320e | 2019-04-16 02:47:50 +0530 | [diff] [blame] | 3787 | static int drv_cmd_set_suspend_mode(struct hdd_adapter *adapter, |
| 3788 | struct hdd_context *hdd_ctx, |
| 3789 | uint8_t *command, |
| 3790 | uint8_t command_len, |
| 3791 | struct hdd_priv_data *priv_data) |
| 3792 | { |
| 3793 | int errno; |
| 3794 | uint8_t *value = command; |
| 3795 | QDF_STATUS status; |
| 3796 | uint8_t idle_monitor; |
| 3797 | |
| 3798 | if (QDF_STA_MODE != adapter->device_mode) { |
| 3799 | hdd_debug("Non-STA interface"); |
| 3800 | return 0; |
| 3801 | } |
| 3802 | |
| 3803 | /* Move pointer to ahead of SETSUSPENDMODE<delimiter> */ |
| 3804 | value = value + SIZE_OF_SETSUSPENDMODE + 1; |
| 3805 | |
| 3806 | /* Convert the value from ascii to integer */ |
| 3807 | errno = kstrtou8(value, 10, &idle_monitor); |
| 3808 | if (errno < 0) { |
| 3809 | /* |
| 3810 | * If the input value is greater than max value of datatype, |
| 3811 | * then also kstrtou8 fails |
| 3812 | */ |
| 3813 | hdd_err("Range validation failed"); |
| 3814 | return -EINVAL; |
| 3815 | } |
| 3816 | |
| 3817 | hdd_debug("idle_monitor:%d", idle_monitor); |
| 3818 | status = ucfg_pmo_tgt_psoc_send_idle_roam_suspend_mode(hdd_ctx->psoc, |
| 3819 | idle_monitor); |
| 3820 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3821 | hdd_debug("Send suspend mode to fw failed"); |
| 3822 | return -EINVAL; |
| 3823 | } |
| 3824 | return 0; |
| 3825 | } |
| 3826 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3827 | static int drv_cmd_get_roam_mode(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3828 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3829 | uint8_t *command, |
| 3830 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3831 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3832 | { |
| 3833 | int ret = 0; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3834 | 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] | 3835 | char extra[32]; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3836 | uint8_t len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3837 | |
| 3838 | /* |
| 3839 | * roamMode value shall be inverted because the sementics is different. |
| 3840 | */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3841 | if (roam_mode) |
| 3842 | roam_mode = cfg_min(CFG_LFR_FEATURE_ENABLED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3843 | else |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3844 | roam_mode = cfg_max(CFG_LFR_FEATURE_ENABLED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3845 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3846 | len = scnprintf(extra, sizeof(extra), "%s %d", command, roam_mode); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3847 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3848 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3849 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3850 | ret = -EFAULT; |
| 3851 | } |
| 3852 | |
| 3853 | return ret; |
| 3854 | } |
| 3855 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3856 | static int drv_cmd_set_roam_delta(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3857 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3858 | uint8_t *command, |
| 3859 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3860 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3861 | { |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3862 | int ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3863 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3864 | uint8_t roam_rssi_diff = cfg_default(CFG_LFR_ROAM_RSSI_DIFF); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3865 | |
| 3866 | /* Move pointer to ahead of SETROAMDELTA<delimiter> */ |
| 3867 | value = value + command_len + 1; |
| 3868 | |
| 3869 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3870 | ret = kstrtou8(value, 10, &roam_rssi_diff); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3871 | if (ret < 0) { |
| 3872 | /* |
| 3873 | * If the input value is greater than max value of datatype, |
| 3874 | * then also kstrtou8 fails |
| 3875 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3876 | hdd_err("kstrtou8 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3877 | cfg_min(CFG_LFR_ROAM_RSSI_DIFF), |
| 3878 | cfg_max(CFG_LFR_ROAM_RSSI_DIFF)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3879 | ret = -EINVAL; |
| 3880 | goto exit; |
| 3881 | } |
| 3882 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3883 | if (!cfg_in_range(CFG_LFR_ROAM_RSSI_DIFF, roam_rssi_diff)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3884 | 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] | 3885 | roam_rssi_diff, |
| 3886 | cfg_min(CFG_LFR_ROAM_RSSI_DIFF), |
| 3887 | cfg_max(CFG_LFR_ROAM_RSSI_DIFF)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3888 | ret = -EINVAL; |
| 3889 | goto exit; |
| 3890 | } |
| 3891 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 3892 | hdd_debug("Received Command to Set roam rssi diff = %d", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3893 | roam_rssi_diff); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3894 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3895 | sme_update_roam_rssi_diff(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3896 | adapter->vdev_id, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3897 | roam_rssi_diff); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3898 | |
| 3899 | exit: |
| 3900 | return ret; |
| 3901 | } |
| 3902 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3903 | static int drv_cmd_get_roam_delta(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3904 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3905 | uint8_t *command, |
| 3906 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3907 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3908 | { |
| 3909 | int ret = 0; |
Srinivas Dasari | 7f48ac0 | 2019-09-16 17:44:43 +0530 | [diff] [blame] | 3910 | uint8_t rssi_diff; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3911 | char extra[32]; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3912 | uint8_t len; |
Srinivas Dasari | 7f48ac0 | 2019-09-16 17:44:43 +0530 | [diff] [blame] | 3913 | QDF_STATUS status; |
| 3914 | |
| 3915 | status = sme_get_roam_rssi_diff(hdd_ctx->mac_handle, adapter->vdev_id, |
| 3916 | &rssi_diff); |
| 3917 | if (QDF_IS_STATUS_ERROR(status)) |
| 3918 | return qdf_status_to_os_return(status); |
| 3919 | |
| 3920 | hdd_debug("vdev_id: %u, rssi_diff: %u", adapter->vdev_id, rssi_diff); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3921 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3922 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 3923 | TRACE_CODE_HDD_GETROAMDELTA_IOCTL, |
Jeff Johnson | 6500380 | 2019-02-26 20:50:49 -0800 | [diff] [blame] | 3924 | adapter->vdev_id, rssi_diff); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3925 | len = scnprintf(extra, sizeof(extra), "%s %d", |
Jeff Johnson | 6500380 | 2019-02-26 20:50:49 -0800 | [diff] [blame] | 3926 | command, rssi_diff); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3927 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3928 | |
| 3929 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3930 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3931 | ret = -EFAULT; |
| 3932 | } |
| 3933 | |
| 3934 | return ret; |
| 3935 | } |
| 3936 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3937 | static int drv_cmd_get_band(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3938 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3939 | uint8_t *command, |
| 3940 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3941 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3942 | { |
| 3943 | int ret = 0; |
| 3944 | int band = -1; |
| 3945 | char extra[32]; |
| 3946 | uint8_t len = 0; |
| 3947 | |
| 3948 | hdd_get_band_helper(hdd_ctx, &band); |
| 3949 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3950 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 3951 | TRACE_CODE_HDD_GETBAND_IOCTL, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3952 | adapter->vdev_id, band); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3953 | |
| 3954 | len = scnprintf(extra, sizeof(extra), "%s %d", command, band); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3955 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3956 | |
| 3957 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3958 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3959 | ret = -EFAULT; |
| 3960 | } |
| 3961 | |
| 3962 | return ret; |
| 3963 | } |
| 3964 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3965 | static int drv_cmd_set_roam_scan_channels(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3966 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3967 | uint8_t *command, |
| 3968 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3969 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3970 | { |
| 3971 | return hdd_parse_set_roam_scan_channels(adapter, command); |
| 3972 | } |
| 3973 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3974 | static int drv_cmd_get_roam_scan_channels(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3975 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3976 | uint8_t *command, |
| 3977 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3978 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3979 | { |
| 3980 | int ret = 0; |
Jianmin Zhu | 203d753 | 2019-10-28 17:17:05 +0800 | [diff] [blame] | 3981 | uint32_t freq_list[CFG_VALID_CHANNEL_LIST_LEN] = { 0 }; |
Jeff Johnson | 8a2e1da | 2019-02-26 17:56:24 -0800 | [diff] [blame] | 3982 | uint8_t num_channels = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3983 | uint8_t j = 0; |
| 3984 | char extra[128] = { 0 }; |
| 3985 | int len; |
Jianmin Zhu | 203d753 | 2019-10-28 17:17:05 +0800 | [diff] [blame] | 3986 | uint8_t chan; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3987 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3988 | if (QDF_STATUS_SUCCESS != |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3989 | sme_get_roam_scan_channel_list(hdd_ctx->mac_handle, |
Jianmin Zhu | 203d753 | 2019-10-28 17:17:05 +0800 | [diff] [blame] | 3990 | freq_list, |
Jeff Johnson | 8a2e1da | 2019-02-26 17:56:24 -0800 | [diff] [blame] | 3991 | &num_channels, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3992 | adapter->vdev_id)) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 3993 | hdd_err("failed to get roam scan channel list"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3994 | ret = -EFAULT; |
| 3995 | goto exit; |
| 3996 | } |
| 3997 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3998 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 3999 | TRACE_CODE_HDD_GETROAMSCANCHANNELS_IOCTL, |
Jeff Johnson | 8a2e1da | 2019-02-26 17:56:24 -0800 | [diff] [blame] | 4000 | adapter->vdev_id, num_channels); |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 4001 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4002 | /* |
| 4003 | * output channel list is of the format |
| 4004 | * [Number of roam scan channels][Channel1][Channel2]... |
| 4005 | * copy the number of channels in the 0th index |
| 4006 | */ |
| 4007 | len = scnprintf(extra, sizeof(extra), "%s %d", command, |
Jeff Johnson | 8a2e1da | 2019-02-26 17:56:24 -0800 | [diff] [blame] | 4008 | num_channels); |
Jianmin Zhu | 203d753 | 2019-10-28 17:17:05 +0800 | [diff] [blame] | 4009 | for (j = 0; (j < num_channels) && len <= sizeof(extra); j++) { |
| 4010 | chan = wlan_reg_freq_to_chan(hdd_ctx->pdev, freq_list[j]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4011 | len += scnprintf(extra + len, sizeof(extra) - len, |
Jianmin Zhu | 203d753 | 2019-10-28 17:17:05 +0800 | [diff] [blame] | 4012 | " %d", chan); |
| 4013 | } |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4014 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4015 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4016 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4017 | ret = -EFAULT; |
| 4018 | goto exit; |
| 4019 | } |
| 4020 | |
| 4021 | exit: |
| 4022 | return ret; |
| 4023 | } |
| 4024 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4025 | static int drv_cmd_get_ccx_mode(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4026 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4027 | uint8_t *command, |
| 4028 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4029 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4030 | { |
| 4031 | int ret = 0; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4032 | mac_handle_t mac_handle = hdd_ctx->mac_handle; |
Jeff Johnson | 22345e1 | 2019-02-26 21:33:02 -0800 | [diff] [blame] | 4033 | bool ese_mode = sme_get_is_ese_feature_enabled(mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4034 | char extra[32]; |
| 4035 | uint8_t len = 0; |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 4036 | struct pmkid_mode_bits pmkid_modes; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4037 | |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 4038 | hdd_get_pmkid_modes(hdd_ctx, &pmkid_modes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4039 | /* |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 4040 | * Check if the features PMKID/ESE/11R are supported simultaneously, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4041 | * then this operation is not permitted (return FAILURE) |
| 4042 | */ |
Jeff Johnson | 22345e1 | 2019-02-26 21:33:02 -0800 | [diff] [blame] | 4043 | if (ese_mode && |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 4044 | (pmkid_modes.fw_okc || pmkid_modes.fw_pmksa_cache) && |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4045 | sme_get_is_ft_feature_enabled(mac_handle)) { |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 4046 | 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] | 4047 | ret = -EPERM; |
| 4048 | goto exit; |
| 4049 | } |
| 4050 | |
| 4051 | len = scnprintf(extra, sizeof(extra), "%s %d", |
Jeff Johnson | 22345e1 | 2019-02-26 21:33:02 -0800 | [diff] [blame] | 4052 | "GETCCXMODE", ese_mode); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4053 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4054 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4055 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4056 | ret = -EFAULT; |
| 4057 | goto exit; |
| 4058 | } |
| 4059 | |
| 4060 | exit: |
| 4061 | return ret; |
| 4062 | } |
| 4063 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4064 | static int drv_cmd_get_okc_mode(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 | { |
| 4070 | int ret = 0; |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 4071 | struct pmkid_mode_bits pmkid_modes; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4072 | char extra[32]; |
| 4073 | uint8_t len = 0; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4074 | mac_handle_t mac_handle = hdd_ctx->mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4075 | |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 4076 | hdd_get_pmkid_modes(hdd_ctx, &pmkid_modes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4077 | /* |
| 4078 | * Check if the features OKC/ESE/11R are supported simultaneously, |
| 4079 | * then this operation is not permitted (return FAILURE) |
| 4080 | */ |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 4081 | if (pmkid_modes.fw_okc && |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4082 | sme_get_is_ese_feature_enabled(mac_handle) && |
| 4083 | sme_get_is_ft_feature_enabled(mac_handle)) { |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 4084 | 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] | 4085 | ret = -EPERM; |
| 4086 | goto exit; |
| 4087 | } |
| 4088 | |
| 4089 | len = scnprintf(extra, sizeof(extra), "%s %d", |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 4090 | "GETOKCMODE", pmkid_modes.fw_okc); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4091 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4092 | |
| 4093 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4094 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4095 | ret = -EFAULT; |
| 4096 | goto exit; |
| 4097 | } |
| 4098 | |
| 4099 | exit: |
| 4100 | return ret; |
| 4101 | } |
| 4102 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4103 | static int drv_cmd_get_fast_roam(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4104 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4105 | uint8_t *command, |
| 4106 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4107 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4108 | { |
| 4109 | int ret = 0; |
Jeff Johnson | 22345e1 | 2019-02-26 21:33:02 -0800 | [diff] [blame] | 4110 | 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] | 4111 | char extra[32]; |
| 4112 | uint8_t len = 0; |
| 4113 | |
| 4114 | len = scnprintf(extra, sizeof(extra), "%s %d", |
Jeff Johnson | 22345e1 | 2019-02-26 21:33:02 -0800 | [diff] [blame] | 4115 | "GETFASTROAM", lfr_mode); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4116 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4117 | |
| 4118 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4119 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4120 | ret = -EFAULT; |
| 4121 | } |
| 4122 | |
| 4123 | return ret; |
| 4124 | } |
| 4125 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4126 | static int drv_cmd_get_fast_transition(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4127 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4128 | uint8_t *command, |
| 4129 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4130 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4131 | { |
| 4132 | int ret = 0; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4133 | bool ft = sme_get_is_ft_feature_enabled(hdd_ctx->mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4134 | char extra[32]; |
| 4135 | uint8_t len = 0; |
| 4136 | |
| 4137 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 4138 | "GETFASTTRANSITION", ft); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4139 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4140 | |
| 4141 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4142 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4143 | ret = -EFAULT; |
| 4144 | } |
| 4145 | |
| 4146 | return ret; |
| 4147 | } |
| 4148 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4149 | 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] | 4150 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4151 | uint8_t *command, |
| 4152 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4153 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4154 | { |
| 4155 | int ret = 0; |
| 4156 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4157 | 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] | 4158 | |
| 4159 | /* Move pointer to ahead of SETROAMSCANCHANNELMINTIME<delimiter> */ |
| 4160 | value = value + command_len + 1; |
| 4161 | |
| 4162 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4163 | ret = kstrtou8(value, 10, &min_time); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4164 | if (ret < 0) { |
| 4165 | /* |
| 4166 | * If the input value is greater than max value of datatype, |
| 4167 | * then also kstrtou8 fails |
| 4168 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4169 | hdd_err("kstrtou8 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4170 | cfg_min(CFG_LFR_NEIGHBOR_SCAN_MIN_CHAN_TIME), |
| 4171 | cfg_max(CFG_LFR_NEIGHBOR_SCAN_MIN_CHAN_TIME)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4172 | ret = -EINVAL; |
| 4173 | goto exit; |
| 4174 | } |
| 4175 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4176 | 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] | 4177 | 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] | 4178 | min_time, |
| 4179 | cfg_min(CFG_LFR_NEIGHBOR_SCAN_MIN_CHAN_TIME), |
| 4180 | cfg_max(CFG_LFR_NEIGHBOR_SCAN_MIN_CHAN_TIME)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4181 | ret = -EINVAL; |
| 4182 | goto exit; |
| 4183 | } |
| 4184 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 4185 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 4186 | TRACE_CODE_HDD_SETROAMSCANCHANNELMINTIME_IOCTL, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4187 | adapter->vdev_id, min_time); |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 4188 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4189 | hdd_debug("Received Command to change channel min time = %d", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4190 | min_time); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4191 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4192 | sme_set_neighbor_scan_min_chan_time(hdd_ctx->mac_handle, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4193 | min_time, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4194 | adapter->vdev_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4195 | |
| 4196 | exit: |
| 4197 | return ret; |
| 4198 | } |
| 4199 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4200 | static int drv_cmd_send_action_frame(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4201 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4202 | uint8_t *command, |
| 4203 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4204 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4205 | { |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 4206 | return hdd_parse_sendactionframe(adapter, command, |
| 4207 | priv_data->total_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4208 | } |
| 4209 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4210 | 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] | 4211 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4212 | uint8_t *command, |
| 4213 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4214 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4215 | { |
| 4216 | int ret = 0; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4217 | 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] | 4218 | adapter->vdev_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4219 | char extra[32]; |
| 4220 | uint8_t len = 0; |
| 4221 | |
| 4222 | /* value is interms of msec */ |
| 4223 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 4224 | "GETROAMSCANCHANNELMINTIME", val); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4225 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4226 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 4227 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 4228 | TRACE_CODE_HDD_GETROAMSCANCHANNELMINTIME_IOCTL, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4229 | adapter->vdev_id, val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4230 | |
| 4231 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4232 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4233 | ret = -EFAULT; |
| 4234 | } |
| 4235 | |
| 4236 | return ret; |
| 4237 | } |
| 4238 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4239 | static int drv_cmd_set_scan_channel_time(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4240 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4241 | uint8_t *command, |
| 4242 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4243 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4244 | { |
| 4245 | int ret = 0; |
| 4246 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4247 | 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] | 4248 | |
| 4249 | /* Move pointer to ahead of SETSCANCHANNELTIME<delimiter> */ |
| 4250 | value = value + command_len + 1; |
| 4251 | |
| 4252 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4253 | ret = kstrtou16(value, 10, &max_time); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4254 | if (ret < 0) { |
| 4255 | /* |
| 4256 | * If the input value is greater than max value of datatype, |
| 4257 | * then also kstrtou8 fails |
| 4258 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4259 | hdd_err("kstrtou16 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4260 | cfg_min(CFG_LFR_NEIGHBOR_SCAN_MAX_CHAN_TIME), |
| 4261 | cfg_max(CFG_LFR_NEIGHBOR_SCAN_MAX_CHAN_TIME)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4262 | ret = -EINVAL; |
| 4263 | goto exit; |
| 4264 | } |
| 4265 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4266 | 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] | 4267 | 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] | 4268 | max_time, |
| 4269 | cfg_min(CFG_LFR_NEIGHBOR_SCAN_MAX_CHAN_TIME), |
| 4270 | cfg_max(CFG_LFR_NEIGHBOR_SCAN_MAX_CHAN_TIME)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4271 | ret = -EINVAL; |
| 4272 | goto exit; |
| 4273 | } |
| 4274 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4275 | hdd_debug("Received Command to change channel max time = %d", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4276 | max_time); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4277 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4278 | sme_set_neighbor_scan_max_chan_time(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4279 | adapter->vdev_id, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4280 | max_time); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4281 | |
| 4282 | exit: |
| 4283 | return ret; |
| 4284 | } |
| 4285 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4286 | static int drv_cmd_get_scan_channel_time(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4287 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4288 | uint8_t *command, |
| 4289 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4290 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4291 | { |
| 4292 | int ret = 0; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4293 | 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] | 4294 | adapter->vdev_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4295 | char extra[32]; |
| 4296 | uint8_t len = 0; |
| 4297 | |
| 4298 | /* value is interms of msec */ |
| 4299 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 4300 | "GETSCANCHANNELTIME", val); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4301 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4302 | |
| 4303 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4304 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4305 | ret = -EFAULT; |
| 4306 | } |
| 4307 | |
| 4308 | return ret; |
| 4309 | } |
| 4310 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4311 | static int drv_cmd_set_scan_home_time(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4312 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4313 | uint8_t *command, |
| 4314 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4315 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4316 | { |
| 4317 | int ret = 0; |
| 4318 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4319 | uint16_t val = cfg_default(CFG_LFR_NEIGHBOR_SCAN_TIMER_PERIOD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4320 | |
| 4321 | /* Move pointer to ahead of SETSCANHOMETIME<delimiter> */ |
| 4322 | value = value + command_len + 1; |
| 4323 | |
| 4324 | /* Convert the value from ascii to integer */ |
| 4325 | ret = kstrtou16(value, 10, &val); |
| 4326 | if (ret < 0) { |
| 4327 | /* |
| 4328 | * If the input value is greater than max value of datatype, |
| 4329 | * then also kstrtou8 fails |
| 4330 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4331 | hdd_err("kstrtou16 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4332 | cfg_min(CFG_LFR_NEIGHBOR_SCAN_TIMER_PERIOD), |
| 4333 | cfg_max(CFG_LFR_NEIGHBOR_SCAN_TIMER_PERIOD)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4334 | ret = -EINVAL; |
| 4335 | goto exit; |
| 4336 | } |
| 4337 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4338 | if (!cfg_in_range(CFG_LFR_NEIGHBOR_SCAN_TIMER_PERIOD, val)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4339 | hdd_err("scan home time value %d is out of range (Min: %d Max: %d)", |
| 4340 | val, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4341 | cfg_min(CFG_LFR_NEIGHBOR_SCAN_TIMER_PERIOD), |
| 4342 | cfg_max(CFG_LFR_NEIGHBOR_SCAN_TIMER_PERIOD)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4343 | ret = -EINVAL; |
| 4344 | goto exit; |
| 4345 | } |
| 4346 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4347 | hdd_debug("Received Command to change scan home time = %d", |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4348 | val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4349 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4350 | sme_set_neighbor_scan_period(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4351 | adapter->vdev_id, val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4352 | |
| 4353 | exit: |
| 4354 | return ret; |
| 4355 | } |
| 4356 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4357 | static int drv_cmd_get_scan_home_time(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4358 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4359 | uint8_t *command, |
| 4360 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4361 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4362 | { |
| 4363 | int ret = 0; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4364 | uint16_t val = sme_get_neighbor_scan_period(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4365 | adapter->vdev_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4366 | char extra[32]; |
| 4367 | uint8_t len = 0; |
| 4368 | |
| 4369 | /* value is interms of msec */ |
| 4370 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 4371 | "GETSCANHOMETIME", val); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4372 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4373 | |
| 4374 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4375 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4376 | ret = -EFAULT; |
| 4377 | } |
| 4378 | |
| 4379 | return ret; |
| 4380 | } |
| 4381 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4382 | static int drv_cmd_set_roam_intra_band(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4383 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4384 | uint8_t *command, |
| 4385 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4386 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4387 | { |
| 4388 | int ret = 0; |
| 4389 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4390 | uint8_t val = cfg_default(CFG_LFR_ROAM_INTRA_BAND); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4391 | |
| 4392 | /* Move pointer to ahead of SETROAMINTRABAND<delimiter> */ |
| 4393 | value = value + command_len + 1; |
| 4394 | |
| 4395 | /* Convert the value from ascii to integer */ |
| 4396 | ret = kstrtou8(value, 10, &val); |
| 4397 | if (ret < 0) { |
| 4398 | /* |
| 4399 | * If the input value is greater than max value of datatype, |
| 4400 | * then also kstrtou8 fails |
| 4401 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4402 | hdd_err("kstrtou8 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4403 | cfg_min(CFG_LFR_ROAM_INTRA_BAND), |
| 4404 | cfg_max(CFG_LFR_ROAM_INTRA_BAND)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4405 | ret = -EINVAL; |
| 4406 | goto exit; |
| 4407 | } |
| 4408 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4409 | hdd_debug("Received Command to change intra band = %d", |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4410 | val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4411 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4412 | ucfg_mlme_set_roam_intra_band(hdd_ctx->psoc, (bool)val); |
Jianmin Zhu | 0b505a6 | 2019-04-30 16:22:49 +0800 | [diff] [blame] | 4413 | policy_mgr_set_pcl_for_existing_combo( |
| 4414 | hdd_ctx->psoc, |
| 4415 | PM_STA_MODE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4416 | |
| 4417 | exit: |
| 4418 | return ret; |
| 4419 | } |
| 4420 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4421 | static int drv_cmd_get_roam_intra_band(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4422 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4423 | uint8_t *command, |
| 4424 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4425 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4426 | { |
| 4427 | int ret = 0; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4428 | uint16_t val = sme_get_roam_intra_band(hdd_ctx->mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4429 | char extra[32]; |
| 4430 | uint8_t len = 0; |
| 4431 | |
| 4432 | /* value is interms of msec */ |
| 4433 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 4434 | "GETROAMINTRABAND", val); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4435 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4436 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4437 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4438 | ret = -EFAULT; |
| 4439 | } |
| 4440 | |
| 4441 | return ret; |
| 4442 | } |
| 4443 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4444 | static int drv_cmd_set_scan_n_probes(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4445 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4446 | uint8_t *command, |
| 4447 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4448 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4449 | { |
| 4450 | int ret = 0; |
| 4451 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4452 | uint8_t nprobes = cfg_default(CFG_LFR_ROAM_SCAN_N_PROBES); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4453 | |
| 4454 | /* Move pointer to ahead of SETSCANNPROBES<delimiter> */ |
| 4455 | value = value + command_len + 1; |
| 4456 | |
| 4457 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4458 | ret = kstrtou8(value, 10, &nprobes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4459 | if (ret < 0) { |
| 4460 | /* |
| 4461 | * If the input value is greater than max value of datatype, |
| 4462 | * then also kstrtou8 fails |
| 4463 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4464 | hdd_err("kstrtou8 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4465 | cfg_min(CFG_LFR_ROAM_SCAN_N_PROBES), |
| 4466 | cfg_max(CFG_LFR_ROAM_SCAN_N_PROBES)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4467 | ret = -EINVAL; |
| 4468 | goto exit; |
| 4469 | } |
| 4470 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4471 | if (!cfg_in_range(CFG_LFR_ROAM_SCAN_N_PROBES, nprobes)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4472 | 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] | 4473 | nprobes, |
| 4474 | cfg_min(CFG_LFR_ROAM_SCAN_N_PROBES), |
| 4475 | cfg_max(CFG_LFR_ROAM_SCAN_N_PROBES)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4476 | ret = -EINVAL; |
| 4477 | goto exit; |
| 4478 | } |
| 4479 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4480 | hdd_debug("Received Command to Set nProbes = %d", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4481 | nprobes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4482 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4483 | sme_update_roam_scan_n_probes(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4484 | adapter->vdev_id, nprobes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4485 | |
| 4486 | exit: |
| 4487 | return ret; |
| 4488 | } |
| 4489 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4490 | static int drv_cmd_get_scan_n_probes(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4491 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4492 | uint8_t *command, |
| 4493 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4494 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4495 | { |
| 4496 | int ret = 0; |
Srinivas Dasari | a5a42fa | 2019-09-20 12:47:15 +0530 | [diff] [blame] | 4497 | uint8_t val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4498 | char extra[32]; |
| 4499 | uint8_t len = 0; |
Srinivas Dasari | a5a42fa | 2019-09-20 12:47:15 +0530 | [diff] [blame] | 4500 | QDF_STATUS status; |
| 4501 | |
| 4502 | status = sme_get_roam_scan_n_probes(hdd_ctx->mac_handle, |
| 4503 | adapter->vdev_id, |
| 4504 | &val); |
| 4505 | if (QDF_IS_STATUS_ERROR(status)) |
| 4506 | return qdf_status_to_os_return(status); |
| 4507 | |
| 4508 | hdd_debug("vdev_id: %u, scan_n_probes: %u", |
| 4509 | adapter->vdev_id, val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4510 | |
| 4511 | len = scnprintf(extra, sizeof(extra), "%s %d", command, val); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4512 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4513 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4514 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4515 | ret = -EFAULT; |
| 4516 | } |
| 4517 | |
| 4518 | return ret; |
| 4519 | } |
| 4520 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4521 | 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] | 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; |
| 4528 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4529 | uint16_t home_away_time = cfg_default(CFG_LFR_ROAM_SCAN_HOME_AWAY_TIME); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4530 | |
| 4531 | /* input value is in units of msec */ |
| 4532 | |
| 4533 | /* Move pointer to ahead of SETSCANHOMEAWAYTIME<delimiter> */ |
| 4534 | value = value + command_len + 1; |
| 4535 | |
| 4536 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4537 | ret = kstrtou16(value, 10, &home_away_time); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4538 | if (ret < 0) { |
| 4539 | /* |
| 4540 | * If the input value is greater than max value of datatype, |
| 4541 | * then also kstrtou8 fails |
| 4542 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4543 | hdd_err("kstrtou8 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4544 | cfg_min(CFG_LFR_ROAM_SCAN_HOME_AWAY_TIME), |
| 4545 | cfg_max(CFG_LFR_ROAM_SCAN_HOME_AWAY_TIME)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4546 | ret = -EINVAL; |
| 4547 | goto exit; |
| 4548 | } |
| 4549 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4550 | if (!cfg_in_range(CFG_LFR_ROAM_SCAN_HOME_AWAY_TIME, home_away_time)) { |
| 4551 | hdd_err("home_away_time value %d is out of range (min: %d max: %d)", |
| 4552 | home_away_time, |
| 4553 | cfg_min(CFG_LFR_ROAM_SCAN_HOME_AWAY_TIME), |
| 4554 | cfg_max(CFG_LFR_ROAM_SCAN_HOME_AWAY_TIME)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4555 | ret = -EINVAL; |
| 4556 | goto exit; |
| 4557 | } |
| 4558 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4559 | hdd_debug("Received Command to Set scan away time = %d", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4560 | home_away_time); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4561 | |
Srinivas Dasari | 7bedcd1 | 2019-09-20 12:43:11 +0530 | [diff] [blame] | 4562 | sme_update_roam_scan_home_away_time(hdd_ctx->mac_handle, |
| 4563 | adapter->vdev_id, |
| 4564 | home_away_time, |
| 4565 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4566 | |
| 4567 | exit: |
| 4568 | return ret; |
| 4569 | } |
| 4570 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4571 | 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] | 4572 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4573 | uint8_t *command, |
| 4574 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4575 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4576 | { |
| 4577 | int ret = 0; |
Srinivas Dasari | 7bedcd1 | 2019-09-20 12:43:11 +0530 | [diff] [blame] | 4578 | uint16_t val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4579 | char extra[32]; |
| 4580 | uint8_t len = 0; |
Srinivas Dasari | 7bedcd1 | 2019-09-20 12:43:11 +0530 | [diff] [blame] | 4581 | QDF_STATUS status; |
| 4582 | |
| 4583 | status = sme_get_roam_scan_home_away_time(hdd_ctx->mac_handle, |
| 4584 | adapter->vdev_id, |
| 4585 | &val); |
| 4586 | if (QDF_IS_STATUS_ERROR(status)) |
| 4587 | return qdf_status_to_os_return(status); |
| 4588 | |
| 4589 | hdd_debug("vdev_id: %u, scan home away time: %u", |
| 4590 | adapter->vdev_id, val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4591 | |
| 4592 | len = scnprintf(extra, sizeof(extra), "%s %d", command, val); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4593 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4594 | |
| 4595 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4596 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4597 | ret = -EFAULT; |
| 4598 | } |
| 4599 | |
| 4600 | return ret; |
| 4601 | } |
| 4602 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4603 | static int drv_cmd_reassoc(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4604 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4605 | uint8_t *command, |
| 4606 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4607 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4608 | { |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 4609 | return hdd_parse_reassoc(adapter, command, priv_data->total_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4610 | } |
| 4611 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4612 | static int drv_cmd_set_wes_mode(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4613 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4614 | uint8_t *command, |
| 4615 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4616 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4617 | { |
| 4618 | int ret = 0; |
| 4619 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4620 | uint8_t wes_mode = cfg_default(CFG_LFR_ENABLE_WES_MODE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4621 | |
| 4622 | /* Move pointer to ahead of SETWESMODE<delimiter> */ |
| 4623 | value = value + command_len + 1; |
| 4624 | |
| 4625 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4626 | ret = kstrtou8(value, 10, &wes_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4627 | if (ret < 0) { |
| 4628 | /* |
| 4629 | * If the input value is greater than max value of datatype, |
| 4630 | * then also kstrtou8 fails |
| 4631 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4632 | hdd_err("kstrtou8 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4633 | cfg_min(CFG_LFR_ENABLE_WES_MODE), |
| 4634 | cfg_max(CFG_LFR_ENABLE_WES_MODE)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4635 | ret = -EINVAL; |
| 4636 | goto exit; |
| 4637 | } |
| 4638 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4639 | 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] | 4640 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4641 | 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] | 4642 | |
| 4643 | exit: |
| 4644 | return ret; |
| 4645 | } |
| 4646 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4647 | static int drv_cmd_get_wes_mode(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4648 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4649 | uint8_t *command, |
| 4650 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4651 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4652 | { |
| 4653 | int ret = 0; |
Jeff Johnson | 22345e1 | 2019-02-26 21:33:02 -0800 | [diff] [blame] | 4654 | bool wes_mode = sme_get_wes_mode(hdd_ctx->mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4655 | char extra[32]; |
| 4656 | uint8_t len = 0; |
| 4657 | |
Jeff Johnson | 22345e1 | 2019-02-26 21:33:02 -0800 | [diff] [blame] | 4658 | len = scnprintf(extra, sizeof(extra), "%s %d", command, wes_mode); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4659 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4660 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4661 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4662 | ret = -EFAULT; |
| 4663 | } |
| 4664 | |
| 4665 | return ret; |
| 4666 | } |
| 4667 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4668 | static int drv_cmd_set_opportunistic_rssi_diff(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4669 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4670 | uint8_t *command, |
| 4671 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4672 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4673 | { |
| 4674 | int ret = 0; |
| 4675 | uint8_t *value = command; |
Jeff Johnson | 8e3ca4c | 2019-02-26 20:42:24 -0800 | [diff] [blame] | 4676 | uint8_t diff = |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4677 | cfg_default(CFG_LFR_OPPORTUNISTIC_SCAN_THRESHOLD_DIFF); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4678 | |
| 4679 | /* Move pointer to ahead of SETOPPORTUNISTICRSSIDIFF<delimiter> */ |
| 4680 | value = value + command_len + 1; |
| 4681 | |
| 4682 | /* Convert the value from ascii to integer */ |
Jeff Johnson | 8e3ca4c | 2019-02-26 20:42:24 -0800 | [diff] [blame] | 4683 | ret = kstrtou8(value, 10, &diff); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4684 | if (ret < 0) { |
| 4685 | /* |
| 4686 | * If the input value is greater than max value of datatype, |
| 4687 | * then also kstrtou8 fails |
| 4688 | */ |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4689 | hdd_err("kstrtou8 failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4690 | ret = -EINVAL; |
| 4691 | goto exit; |
| 4692 | } |
| 4693 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4694 | hdd_debug("Received Command to Set Opportunistic Threshold diff = %d", |
Jeff Johnson | 8e3ca4c | 2019-02-26 20:42:24 -0800 | [diff] [blame] | 4695 | diff); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4696 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4697 | sme_set_roam_opportunistic_scan_threshold_diff(hdd_ctx->mac_handle, |
Jeff Johnson | 8e3ca4c | 2019-02-26 20:42:24 -0800 | [diff] [blame] | 4698 | adapter->vdev_id, |
| 4699 | diff); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4700 | |
| 4701 | exit: |
| 4702 | return ret; |
| 4703 | } |
| 4704 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4705 | static int drv_cmd_get_opportunistic_rssi_diff(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4706 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4707 | uint8_t *command, |
| 4708 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4709 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4710 | { |
| 4711 | int ret = 0; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4712 | mac_handle_t mac_handle = hdd_ctx->mac_handle; |
| 4713 | int8_t val = sme_get_roam_opportunistic_scan_threshold_diff(mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4714 | char extra[32]; |
| 4715 | uint8_t len = 0; |
| 4716 | |
| 4717 | len = scnprintf(extra, sizeof(extra), "%s %d", command, val); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4718 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4719 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4720 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4721 | ret = -EFAULT; |
| 4722 | } |
| 4723 | |
| 4724 | return ret; |
| 4725 | } |
| 4726 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4727 | 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] | 4728 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4729 | uint8_t *command, |
| 4730 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4731 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4732 | { |
| 4733 | int ret = 0; |
| 4734 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4735 | 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] | 4736 | |
| 4737 | /* Move pointer to ahead of SETROAMRESCANRSSIDIFF<delimiter> */ |
| 4738 | value = value + command_len + 1; |
| 4739 | |
| 4740 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4741 | ret = kstrtou8(value, 10, &rescan_rssi_diff); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4742 | if (ret < 0) { |
| 4743 | /* |
| 4744 | * If the input value is greater than max value of datatype, |
| 4745 | * then also kstrtou8 fails |
| 4746 | */ |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4747 | hdd_err("kstrtou8 failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4748 | ret = -EINVAL; |
| 4749 | goto exit; |
| 4750 | } |
| 4751 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4752 | hdd_debug("Received Command to Set Roam Rescan RSSI Diff = %d", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4753 | rescan_rssi_diff); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4754 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4755 | sme_set_roam_rescan_rssi_diff(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4756 | adapter->vdev_id, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4757 | rescan_rssi_diff); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4758 | |
| 4759 | exit: |
| 4760 | return ret; |
| 4761 | } |
| 4762 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4763 | 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] | 4764 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4765 | uint8_t *command, |
| 4766 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4767 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4768 | { |
| 4769 | int ret = 0; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4770 | 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] | 4771 | char extra[32]; |
| 4772 | uint8_t len = 0; |
| 4773 | |
| 4774 | len = scnprintf(extra, sizeof(extra), "%s %d", command, val); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4775 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4776 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4777 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4778 | ret = -EFAULT; |
| 4779 | } |
| 4780 | |
| 4781 | return ret; |
| 4782 | } |
| 4783 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4784 | static int drv_cmd_set_fast_roam(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4785 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4786 | uint8_t *command, |
| 4787 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4788 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4789 | { |
| 4790 | int ret = 0; |
| 4791 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4792 | uint8_t lfr_mode = cfg_default(CFG_LFR_FEATURE_ENABLED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4793 | |
| 4794 | /* Move pointer to ahead of SETFASTROAM<delimiter> */ |
| 4795 | value = value + command_len + 1; |
| 4796 | |
| 4797 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4798 | ret = kstrtou8(value, 10, &lfr_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4799 | if (ret < 0) { |
| 4800 | /* |
| 4801 | * If the input value is greater than max value of datatype, |
| 4802 | * then also kstrtou8 fails |
| 4803 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4804 | hdd_err("kstrtou8 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4805 | cfg_min(CFG_LFR_FEATURE_ENABLED), |
| 4806 | cfg_max(CFG_LFR_FEATURE_ENABLED)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4807 | ret = -EINVAL; |
| 4808 | goto exit; |
| 4809 | } |
| 4810 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4811 | hdd_debug("Received Command to change lfr mode = %d", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4812 | lfr_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4813 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4814 | ucfg_mlme_set_lfr_enabled(hdd_ctx->psoc, (bool)lfr_mode); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4815 | sme_update_is_fast_roam_ini_feature_enabled(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4816 | adapter->vdev_id, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4817 | lfr_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4818 | |
| 4819 | exit: |
| 4820 | return ret; |
| 4821 | } |
| 4822 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4823 | static int drv_cmd_set_fast_transition(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4824 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4825 | uint8_t *command, |
| 4826 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4827 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4828 | { |
| 4829 | int ret = 0; |
| 4830 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4831 | uint8_t ft = cfg_default(CFG_LFR_FAST_TRANSITION_ENABLED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4832 | |
| 4833 | /* Move pointer to ahead of SETFASTROAM<delimiter> */ |
| 4834 | value = value + command_len + 1; |
| 4835 | |
| 4836 | /* Convert the value from ascii to integer */ |
| 4837 | ret = kstrtou8(value, 10, &ft); |
| 4838 | if (ret < 0) { |
| 4839 | /* |
| 4840 | * If the input value is greater than max value of datatype, |
| 4841 | * then also kstrtou8 fails |
| 4842 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4843 | hdd_err("kstrtou8 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4844 | cfg_min(CFG_LFR_FAST_TRANSITION_ENABLED), |
| 4845 | cfg_max(CFG_LFR_FAST_TRANSITION_ENABLED)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4846 | ret = -EINVAL; |
| 4847 | goto exit; |
| 4848 | } |
| 4849 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4850 | hdd_debug("Received Command to change ft mode = %d", ft); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4851 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4852 | ucfg_mlme_set_fast_transition_enabled(hdd_ctx->psoc, (bool)ft); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4853 | |
| 4854 | exit: |
| 4855 | return ret; |
| 4856 | } |
| 4857 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4858 | static int drv_cmd_fast_reassoc(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4859 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4860 | uint8_t *command, |
| 4861 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4862 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4863 | { |
| 4864 | int ret = 0; |
| 4865 | uint8_t *value = command; |
| 4866 | uint8_t channel = 0; |
Jeff Johnson | 8ff3ffe | 2019-02-26 13:21:07 -0800 | [diff] [blame] | 4867 | tSirMacAddr bssid; |
Jeff Johnson | 29c7867 | 2019-02-26 21:05:53 -0800 | [diff] [blame] | 4868 | uint32_t roam_id = INVALID_ROAM_ID; |
Jeff Johnson | 9ff1695 | 2019-02-26 20:58:44 -0800 | [diff] [blame] | 4869 | tCsrRoamModifyProfileFields mod_fields; |
Jeff Johnson | dcaa8fc | 2019-02-26 21:26:31 -0800 | [diff] [blame] | 4870 | tCsrHandoffRequest req; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4871 | struct hdd_station_ctx *sta_ctx; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4872 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4873 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 4874 | if (QDF_STA_MODE != adapter->device_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4875 | hdd_warn("Unsupported in mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 4876 | qdf_opmode_str(adapter->device_mode), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4877 | adapter->device_mode); |
| 4878 | return -EINVAL; |
| 4879 | } |
| 4880 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4881 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jingxiang Ge | ce7c547 | 2019-07-23 16:19:23 +0800 | [diff] [blame] | 4882 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4883 | |
| 4884 | /* if not associated, no need to proceed with reassoc */ |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 4885 | if (eConnectionState_Associated != sta_ctx->conn_info.conn_state) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4886 | hdd_warn("Not associated!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4887 | ret = -EINVAL; |
| 4888 | goto exit; |
| 4889 | } |
| 4890 | |
Jeff Johnson | 8ff3ffe | 2019-02-26 13:21:07 -0800 | [diff] [blame] | 4891 | ret = hdd_parse_reassoc_command_v1_data(value, bssid, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4892 | &channel); |
| 4893 | if (ret) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4894 | hdd_err("Failed to parse reassoc command data"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4895 | goto exit; |
| 4896 | } |
| 4897 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4898 | mac_handle = hdd_ctx->mac_handle; |
| 4899 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4900 | /* |
| 4901 | * if the target bssid is same as currently associated AP, |
| 4902 | * issue reassoc to same AP |
| 4903 | */ |
Jeff Johnson | e04b699 | 2019-02-27 14:06:55 -0800 | [diff] [blame] | 4904 | if (!qdf_mem_cmp(bssid, sta_ctx->conn_info.bssid.bytes, |
Jeff Johnson | 8ff3ffe | 2019-02-26 13:21:07 -0800 | [diff] [blame] | 4905 | QDF_MAC_ADDR_SIZE)) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4906 | hdd_warn("Reassoc BSSID is same as currently associated AP bssid"); |
Deepak Dhamdhere | 5fda0e4 | 2016-06-24 18:30:02 +0530 | [diff] [blame] | 4907 | if (roaming_offload_enabled(hdd_ctx)) { |
Jingxiang Ge | ce7c547 | 2019-07-23 16:19:23 +0800 | [diff] [blame] | 4908 | channel = wlan_reg_freq_to_chan( |
| 4909 | hdd_ctx->pdev, |
Jingxiang Ge | ae80dc6 | 2019-08-13 17:32:22 +0800 | [diff] [blame] | 4910 | sta_ctx->conn_info.chan_freq); |
Jeff Johnson | 8ff3ffe | 2019-02-26 13:21:07 -0800 | [diff] [blame] | 4911 | hdd_wma_send_fastreassoc_cmd(adapter, bssid, |
| 4912 | channel); |
Deepak Dhamdhere | 5fda0e4 | 2016-06-24 18:30:02 +0530 | [diff] [blame] | 4913 | } else { |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4914 | sme_get_modify_profile_fields(mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4915 | adapter->vdev_id, |
Jeff Johnson | 9ff1695 | 2019-02-26 20:58:44 -0800 | [diff] [blame] | 4916 | &mod_fields); |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4917 | sme_roam_reassoc(mac_handle, adapter->vdev_id, |
Jeff Johnson | 29c7867 | 2019-02-26 21:05:53 -0800 | [diff] [blame] | 4918 | NULL, mod_fields, &roam_id, 1); |
Deepak Dhamdhere | 5fda0e4 | 2016-06-24 18:30:02 +0530 | [diff] [blame] | 4919 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4920 | return 0; |
| 4921 | } |
| 4922 | |
Padma, Santhosh Kumar | af9f08c | 2016-10-21 21:26:29 +0530 | [diff] [blame] | 4923 | /* Check channel number is a valid channel number */ |
Selvaraj, Sridhar | 64b0a9c | 2017-05-11 16:50:15 +0530 | [diff] [blame] | 4924 | if (channel && (QDF_STATUS_SUCCESS != |
| 4925 | wlan_hdd_validate_operation_channel(adapter, channel))) { |
Padma, Santhosh Kumar | af9f08c | 2016-10-21 21:26:29 +0530 | [diff] [blame] | 4926 | hdd_err("Invalid Channel [%d]", channel); |
| 4927 | return -EINVAL; |
| 4928 | } |
| 4929 | |
Varun Reddy Yeturu | d351a6c | 2016-03-16 14:01:00 -0700 | [diff] [blame] | 4930 | if (roaming_offload_enabled(hdd_ctx)) { |
Jeff Johnson | 8ff3ffe | 2019-02-26 13:21:07 -0800 | [diff] [blame] | 4931 | hdd_wma_send_fastreassoc_cmd(adapter, bssid, (int)channel); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4932 | goto exit; |
| 4933 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4934 | /* Proceed with reassoc */ |
gaurank kathpalia | 88f78ec | 2019-09-04 20:18:02 +0530 | [diff] [blame] | 4935 | req.ch_freq = wlan_reg_chan_to_freq(hdd_ctx->pdev, channel); |
Jeff Johnson | dcaa8fc | 2019-02-26 21:26:31 -0800 | [diff] [blame] | 4936 | req.src = FASTREASSOC; |
| 4937 | qdf_mem_copy(req.bssid.bytes, bssid, sizeof(tSirMacAddr)); |
| 4938 | sme_handoff_request(mac_handle, adapter->vdev_id, &req); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4939 | exit: |
| 4940 | return ret; |
| 4941 | } |
| 4942 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4943 | static int drv_cmd_set_roam_scan_control(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4944 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4945 | uint8_t *command, |
| 4946 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4947 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4948 | { |
| 4949 | int ret = 0; |
| 4950 | uint8_t *value = command; |
Jeff Johnson | d7ee476 | 2019-02-26 21:01:00 -0800 | [diff] [blame] | 4951 | uint8_t roam_scan_control = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4952 | |
| 4953 | /* Move pointer to ahead of SETROAMSCANCONTROL<delimiter> */ |
| 4954 | value = value + command_len + 1; |
| 4955 | |
| 4956 | /* Convert the value from ascii to integer */ |
Jeff Johnson | d7ee476 | 2019-02-26 21:01:00 -0800 | [diff] [blame] | 4957 | ret = kstrtou8(value, 10, &roam_scan_control); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4958 | if (ret < 0) { |
| 4959 | /* |
| 4960 | * If the input value is greater than max value of datatype, |
| 4961 | * then also kstrtou8 fails |
| 4962 | */ |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4963 | hdd_err("kstrtou8 failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4964 | ret = -EINVAL; |
| 4965 | goto exit; |
| 4966 | } |
| 4967 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4968 | hdd_debug("Received Command to Set roam scan control = %d", |
Jeff Johnson | d7ee476 | 2019-02-26 21:01:00 -0800 | [diff] [blame] | 4969 | roam_scan_control); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4970 | |
Jeff Johnson | d7ee476 | 2019-02-26 21:01:00 -0800 | [diff] [blame] | 4971 | if (0 != roam_scan_control) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4972 | ret = 0; /* return success but ignore param value "true" */ |
| 4973 | goto exit; |
| 4974 | } |
| 4975 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4976 | sme_set_roam_scan_control(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4977 | adapter->vdev_id, |
Jeff Johnson | d7ee476 | 2019-02-26 21:01:00 -0800 | [diff] [blame] | 4978 | roam_scan_control); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4979 | |
| 4980 | exit: |
| 4981 | return ret; |
| 4982 | } |
| 4983 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4984 | static int drv_cmd_set_okc_mode(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4985 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4986 | uint8_t *command, |
| 4987 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4988 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4989 | { |
| 4990 | int ret = 0; |
| 4991 | uint8_t *value = command; |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 4992 | uint32_t okc_mode; |
| 4993 | struct pmkid_mode_bits pmkid_modes; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4994 | mac_handle_t mac_handle; |
Wu Gao | 9381621 | 2018-08-31 16:49:54 +0800 | [diff] [blame] | 4995 | uint32_t cur_pmkid_modes; |
| 4996 | QDF_STATUS status; |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 4997 | |
| 4998 | hdd_get_pmkid_modes(hdd_ctx, &pmkid_modes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4999 | |
| 5000 | /* |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 5001 | * Check if the features PMKID/ESE/11R are supported simultaneously, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5002 | * then this operation is not permitted (return FAILURE) |
| 5003 | */ |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5004 | mac_handle = hdd_ctx->mac_handle; |
| 5005 | if (sme_get_is_ese_feature_enabled(mac_handle) && |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 5006 | pmkid_modes.fw_okc && |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5007 | sme_get_is_ft_feature_enabled(mac_handle)) { |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 5008 | 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] | 5009 | ret = -EPERM; |
| 5010 | goto exit; |
| 5011 | } |
| 5012 | |
| 5013 | /* Move pointer to ahead of SETOKCMODE<delimiter> */ |
| 5014 | value = value + command_len + 1; |
| 5015 | |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 5016 | /* get the current configured value */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 5017 | status = ucfg_mlme_get_pmkid_modes(hdd_ctx->psoc, |
Wu Gao | 9381621 | 2018-08-31 16:49:54 +0800 | [diff] [blame] | 5018 | &cur_pmkid_modes); |
| 5019 | if (status != QDF_STATUS_SUCCESS) |
| 5020 | hdd_err("get pmkid modes failed"); |
| 5021 | |
| 5022 | okc_mode = cur_pmkid_modes & CFG_PMKID_MODES_OKC; |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 5023 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5024 | /* Convert the value from ascii to integer */ |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 5025 | ret = kstrtou32(value, 10, &okc_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5026 | if (ret < 0) { |
| 5027 | /* |
| 5028 | * If the input value is greater than max value of datatype, |
| 5029 | * then also kstrtou8 fails |
| 5030 | */ |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 5031 | hdd_err("value out of range [0 - 1]"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5032 | ret = -EINVAL; |
| 5033 | goto exit; |
| 5034 | } |
| 5035 | |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 5036 | if ((okc_mode < 0) || |
| 5037 | (okc_mode > 1)) { |
| 5038 | hdd_err("Okc mode value %d is out of range (Min: 0 Max: 1)", |
| 5039 | okc_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5040 | ret = -EINVAL; |
| 5041 | goto exit; |
| 5042 | } |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5043 | hdd_debug("Received Command to change okc mode = %d", |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 5044 | okc_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5045 | |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 5046 | if (okc_mode) |
Wu Gao | 9381621 | 2018-08-31 16:49:54 +0800 | [diff] [blame] | 5047 | cur_pmkid_modes |= CFG_PMKID_MODES_OKC; |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 5048 | else |
Wu Gao | 9381621 | 2018-08-31 16:49:54 +0800 | [diff] [blame] | 5049 | cur_pmkid_modes &= ~CFG_PMKID_MODES_OKC; |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 5050 | status = ucfg_mlme_set_pmkid_modes(hdd_ctx->psoc, |
Wu Gao | 9381621 | 2018-08-31 16:49:54 +0800 | [diff] [blame] | 5051 | cur_pmkid_modes); |
| 5052 | if (status != QDF_STATUS_SUCCESS) { |
| 5053 | ret = -EPERM; |
| 5054 | hdd_err("set pmkid modes failed"); |
| 5055 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5056 | exit: |
| 5057 | return ret; |
| 5058 | } |
| 5059 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5060 | static int drv_cmd_get_roam_scan_control(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5061 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5062 | uint8_t *command, |
| 5063 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5064 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5065 | { |
| 5066 | int ret = 0; |
Jeff Johnson | d7ee476 | 2019-02-26 21:01:00 -0800 | [diff] [blame] | 5067 | 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] | 5068 | char extra[32]; |
| 5069 | uint8_t len = 0; |
| 5070 | |
| 5071 | len = scnprintf(extra, sizeof(extra), "%s %d", |
Jeff Johnson | d7ee476 | 2019-02-26 21:01:00 -0800 | [diff] [blame] | 5072 | command, roam_scan_control); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5073 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5074 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5075 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5076 | ret = -EFAULT; |
| 5077 | } |
| 5078 | |
| 5079 | return ret; |
| 5080 | } |
| 5081 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5082 | static int drv_cmd_bt_coex_mode(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5083 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5084 | uint8_t *command, |
| 5085 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5086 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5087 | { |
| 5088 | int ret = 0; |
Jeff Johnson | 3019241 | 2019-02-26 20:32:52 -0800 | [diff] [blame] | 5089 | char *coex_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5090 | |
Jeff Johnson | 3019241 | 2019-02-26 20:32:52 -0800 | [diff] [blame] | 5091 | coex_mode = command + 11; |
| 5092 | if ('1' == *coex_mode) { |
| 5093 | hdd_debug("BTCOEXMODE %d", *coex_mode); |
Jeff Johnson | 59b1931 | 2017-11-02 21:14:33 -0700 | [diff] [blame] | 5094 | hdd_ctx->bt_coex_mode_set = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5095 | ret = wlan_hdd_scan_abort(adapter); |
| 5096 | if (ret < 0) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5097 | hdd_err("Failed to abort existing scan status: %d", |
| 5098 | ret); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5099 | } |
Jeff Johnson | 3019241 | 2019-02-26 20:32:52 -0800 | [diff] [blame] | 5100 | } else if ('2' == *coex_mode) { |
| 5101 | hdd_debug("BTCOEXMODE %d", *coex_mode); |
Jeff Johnson | 59b1931 | 2017-11-02 21:14:33 -0700 | [diff] [blame] | 5102 | hdd_ctx->bt_coex_mode_set = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5103 | } |
| 5104 | |
| 5105 | return ret; |
| 5106 | } |
| 5107 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5108 | static int drv_cmd_scan_active(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5109 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5110 | uint8_t *command, |
| 5111 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5112 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5113 | { |
| 5114 | hdd_ctx->ioctl_scan_mode = eSIR_ACTIVE_SCAN; |
| 5115 | return 0; |
| 5116 | } |
| 5117 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5118 | static int drv_cmd_scan_passive(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5119 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5120 | uint8_t *command, |
| 5121 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5122 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5123 | { |
| 5124 | hdd_ctx->ioctl_scan_mode = eSIR_PASSIVE_SCAN; |
| 5125 | return 0; |
| 5126 | } |
| 5127 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5128 | static int drv_cmd_get_dwell_time(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5129 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5130 | uint8_t *command, |
| 5131 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5132 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5133 | { |
| 5134 | int ret = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5135 | char extra[32]; |
| 5136 | uint8_t len = 0; |
| 5137 | |
| 5138 | memset(extra, 0, sizeof(extra)); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 5139 | ret = hdd_get_dwell_time(hdd_ctx->psoc, command, extra, |
| 5140 | sizeof(extra), &len); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5141 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5142 | if (ret != 0 || copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5143 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5144 | ret = -EFAULT; |
| 5145 | goto exit; |
| 5146 | } |
| 5147 | ret = len; |
| 5148 | exit: |
| 5149 | return ret; |
| 5150 | } |
| 5151 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5152 | static int drv_cmd_set_dwell_time(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5153 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -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) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5157 | { |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 5158 | return hdd_set_dwell_time(hdd_ctx->psoc, command); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5159 | } |
| 5160 | |
Ashish Kumar Dhanotiya | 652c233 | 2018-12-11 17:33:17 +0530 | [diff] [blame] | 5161 | static int drv_cmd_conc_set_dwell_time(struct hdd_adapter *adapter, |
| 5162 | struct hdd_context *hdd_ctx, |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 5163 | u8 *command, |
| 5164 | u8 command_len, |
Ashish Kumar Dhanotiya | 652c233 | 2018-12-11 17:33:17 +0530 | [diff] [blame] | 5165 | struct hdd_priv_data *priv_data) |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 5166 | { |
Ashish Kumar Dhanotiya | 652c233 | 2018-12-11 17:33:17 +0530 | [diff] [blame] | 5167 | return hdd_conc_set_dwell_time(adapter, command); |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 5168 | } |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 5169 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5170 | static int drv_cmd_miracast(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5171 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5172 | uint8_t *command, |
| 5173 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5174 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5175 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5176 | QDF_STATUS ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5177 | int ret = 0; |
Jeff Johnson | 3dd8a54 | 2019-02-26 21:38:14 -0800 | [diff] [blame] | 5178 | uint8_t filter_type = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5179 | uint8_t *value; |
| 5180 | |
Jeff Johnson | 6da2db1 | 2017-09-03 09:18:52 -0700 | [diff] [blame] | 5181 | if (wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5182 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5183 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5184 | value = command + 9; |
| 5185 | |
| 5186 | /* Convert the value from ascii to integer */ |
Jeff Johnson | 3dd8a54 | 2019-02-26 21:38:14 -0800 | [diff] [blame] | 5187 | ret = kstrtou8(value, 10, &filter_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5188 | if (ret < 0) { |
| 5189 | /* |
| 5190 | * If the input value is greater than max value of datatype, |
| 5191 | * then also kstrtou8 fails |
| 5192 | */ |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5193 | hdd_err("kstrtou8 failed range"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5194 | ret = -EINVAL; |
| 5195 | goto exit; |
| 5196 | } |
Jeff Johnson | 3dd8a54 | 2019-02-26 21:38:14 -0800 | [diff] [blame] | 5197 | if ((filter_type < WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL) || |
| 5198 | (filter_type > WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL)) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5199 | 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] | 5200 | ret = -EINVAL; |
| 5201 | goto exit; |
| 5202 | } |
| 5203 | /* Filtertype value should be either 0-Disabled, 1-Source, 2-sink */ |
Jeff Johnson | 3dd8a54 | 2019-02-26 21:38:14 -0800 | [diff] [blame] | 5204 | hdd_ctx->miracast_value = filter_type; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5205 | |
Jeff Johnson | 3dd8a54 | 2019-02-26 21:38:14 -0800 | [diff] [blame] | 5206 | ret_status = sme_set_miracast(hdd_ctx->mac_handle, filter_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5207 | if (QDF_STATUS_SUCCESS != ret_status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5208 | hdd_err("Failed to set miracast"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5209 | return -EBUSY; |
| 5210 | } |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 5211 | ret_status = ucfg_scan_set_miracast(hdd_ctx->psoc, |
Jeff Johnson | 3dd8a54 | 2019-02-26 21:38:14 -0800 | [diff] [blame] | 5212 | filter_type ? true : false); |
Abhishek Singh | c87bb04 | 2018-01-30 17:10:42 +0530 | [diff] [blame] | 5213 | if (QDF_IS_STATUS_ERROR(ret_status)) { |
| 5214 | hdd_err("Failed to set miracastn scan"); |
| 5215 | return -EBUSY; |
| 5216 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5217 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 5218 | if (policy_mgr_is_mcc_in_24G(hdd_ctx->psoc)) |
Jeff Johnson | 3dd8a54 | 2019-02-26 21:38:14 -0800 | [diff] [blame] | 5219 | return wlan_hdd_set_mas(adapter, filter_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5220 | |
| 5221 | exit: |
| 5222 | return ret; |
| 5223 | } |
| 5224 | |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5225 | #ifdef FEATURE_WLAN_RMC |
| 5226 | /* Function header is left blank intentionally */ |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 5227 | static int hdd_parse_setrmcenable_command(uint8_t *command, |
Jeff Johnson | 259f3e9 | 2019-02-26 13:36:01 -0800 | [diff] [blame] | 5228 | uint8_t *rmc_enable) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5229 | { |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 5230 | uint8_t *in_ptr = command; |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 5231 | int temp_int; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5232 | int v = 0; |
| 5233 | char buf[32]; |
Jeff Johnson | 259f3e9 | 2019-02-26 13:36:01 -0800 | [diff] [blame] | 5234 | *rmc_enable = 0; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5235 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 5236 | in_ptr = strnchr(command, strlen(command), SPACE_ASCII_VALUE); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5237 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 5238 | if (!in_ptr) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5239 | return 0; |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 5240 | else if (SPACE_ASCII_VALUE != *in_ptr) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5241 | return 0; |
| 5242 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 5243 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 5244 | in_ptr++; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5245 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 5246 | if ('\0' == *in_ptr) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5247 | return 0; |
| 5248 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 5249 | v = sscanf(in_ptr, "%31s ", buf); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5250 | if (1 != v) |
| 5251 | return -EINVAL; |
| 5252 | |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 5253 | v = kstrtos32(buf, 10, &temp_int); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5254 | if (v < 0) |
| 5255 | return -EINVAL; |
| 5256 | |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 5257 | *rmc_enable = temp_int; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5258 | |
Jeff Johnson | f8a0b8f | 2019-02-26 19:26:31 -0800 | [diff] [blame] | 5259 | hdd_debug("rmc_enable: %d", *rmc_enable); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5260 | |
| 5261 | return 0; |
| 5262 | } |
| 5263 | |
| 5264 | /* Function header is left blank intentionally */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5265 | static int hdd_parse_setrmcactionperiod_command(uint8_t *pvalue, |
| 5266 | uint32_t *paction_period) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5267 | { |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5268 | uint8_t *inptr = pvalue; |
| 5269 | int temp_int; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5270 | int v = 0; |
| 5271 | char buf[32]; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5272 | *paction_period = 0; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5273 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5274 | inptr = strnchr(pvalue, strlen(pvalue), SPACE_ASCII_VALUE); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5275 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 5276 | if (!inptr) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5277 | return -EINVAL; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5278 | else if (SPACE_ASCII_VALUE != *inptr) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5279 | return -EINVAL; |
| 5280 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5281 | while ((SPACE_ASCII_VALUE == *inptr) && ('\0' != *inptr)) |
| 5282 | inptr++; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5283 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5284 | if ('\0' == *inptr) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5285 | return 0; |
| 5286 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5287 | v = sscanf(inptr, "%31s ", buf); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5288 | if (1 != v) |
| 5289 | return -EINVAL; |
| 5290 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5291 | v = kstrtos32(buf, 10, &temp_int); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5292 | if (v < 0) |
| 5293 | return -EINVAL; |
| 5294 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5295 | if (!cfg_in_range(CFG_RMC_ACTION_PERIOD_FREQUENCY, temp_int)) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5296 | return -EINVAL; |
| 5297 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5298 | *paction_period = temp_int; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5299 | |
Jeff Johnson | 3972e0d | 2019-02-26 19:42:35 -0800 | [diff] [blame] | 5300 | hdd_debug("action_period: %d", *paction_period); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5301 | |
| 5302 | return 0; |
| 5303 | } |
| 5304 | |
| 5305 | /* Function header is left blank intentionally */ |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 5306 | static int hdd_parse_setrmcrate_command(uint8_t *command, |
Jeff Johnson | b9f9b28 | 2019-02-26 13:40:32 -0800 | [diff] [blame] | 5307 | uint32_t *rate, |
Jeff Johnson | 269d7fb | 2019-02-26 10:47:33 -0800 | [diff] [blame] | 5308 | enum tx_rate_info *tx_flags) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5309 | { |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 5310 | uint8_t *in_ptr = command; |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 5311 | int temp_int; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5312 | int v = 0; |
| 5313 | char buf[32]; |
Jeff Johnson | b9f9b28 | 2019-02-26 13:40:32 -0800 | [diff] [blame] | 5314 | *rate = 0; |
Jeff Johnson | 269d7fb | 2019-02-26 10:47:33 -0800 | [diff] [blame] | 5315 | *tx_flags = 0; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5316 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 5317 | in_ptr = strnchr(command, strlen(command), SPACE_ASCII_VALUE); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5318 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 5319 | if (!in_ptr) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5320 | return -EINVAL; |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 5321 | else if (SPACE_ASCII_VALUE != *in_ptr) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5322 | return -EINVAL; |
| 5323 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 5324 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 5325 | in_ptr++; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5326 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 5327 | if ('\0' == *in_ptr) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5328 | return 0; |
| 5329 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 5330 | v = sscanf(in_ptr, "%31s ", buf); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5331 | if (1 != v) |
| 5332 | return -EINVAL; |
| 5333 | |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 5334 | v = kstrtos32(buf, 10, &temp_int); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5335 | if (v < 0) |
| 5336 | return -EINVAL; |
| 5337 | |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 5338 | switch (temp_int) { |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5339 | default: |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 5340 | hdd_warn("Unsupported rate: %d", temp_int); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5341 | return -EINVAL; |
| 5342 | case 0: |
| 5343 | case 6: |
| 5344 | case 9: |
| 5345 | case 12: |
| 5346 | case 18: |
| 5347 | case 24: |
| 5348 | case 36: |
| 5349 | case 48: |
| 5350 | case 54: |
Jeff Johnson | 269d7fb | 2019-02-26 10:47:33 -0800 | [diff] [blame] | 5351 | *tx_flags = TX_RATE_LEGACY; |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 5352 | *rate = temp_int * 10; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5353 | break; |
| 5354 | case 65: |
Jeff Johnson | 269d7fb | 2019-02-26 10:47:33 -0800 | [diff] [blame] | 5355 | *tx_flags = TX_RATE_HT20; |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 5356 | *rate = temp_int * 10; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5357 | break; |
| 5358 | case 72: |
Jeff Johnson | 269d7fb | 2019-02-26 10:47:33 -0800 | [diff] [blame] | 5359 | *tx_flags = TX_RATE_HT20 | TX_RATE_SGI; |
Jeff Johnson | b9f9b28 | 2019-02-26 13:40:32 -0800 | [diff] [blame] | 5360 | *rate = 722; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5361 | break; |
| 5362 | } |
| 5363 | |
Jeff Johnson | b9f9b28 | 2019-02-26 13:40:32 -0800 | [diff] [blame] | 5364 | hdd_debug("Rate: %d", *rate); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5365 | |
| 5366 | return 0; |
| 5367 | } |
| 5368 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5369 | static int drv_cmd_set_rmc_enable(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5370 | struct hdd_context *hdd_ctx, |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5371 | uint8_t *command, |
| 5372 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5373 | struct hdd_priv_data *priv_data) |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5374 | { |
| 5375 | int ret = 0; |
| 5376 | uint8_t *value = command; |
Jeff Johnson | f8a0b8f | 2019-02-26 19:26:31 -0800 | [diff] [blame] | 5377 | uint8_t rmc_enable = 0; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5378 | int status; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5379 | mac_handle_t mac_handle; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5380 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 5381 | if ((QDF_IBSS_MODE != adapter->device_mode) && |
| 5382 | (QDF_SAP_MODE != adapter->device_mode)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5383 | hdd_err("Received SETRMCENABLE cmd in invalid mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 5384 | qdf_opmode_str(adapter->device_mode), |
| 5385 | adapter->device_mode); |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5386 | hdd_err("SETRMCENABLE cmd is allowed only in IBSS/SOFTAP mode"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5387 | ret = -EINVAL; |
| 5388 | goto exit; |
| 5389 | } |
| 5390 | |
Jeff Johnson | f8a0b8f | 2019-02-26 19:26:31 -0800 | [diff] [blame] | 5391 | status = hdd_parse_setrmcenable_command(value, &rmc_enable); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5392 | if (status) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5393 | hdd_err("Invalid SETRMCENABLE command"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5394 | ret = -EINVAL; |
| 5395 | goto exit; |
| 5396 | } |
| 5397 | |
Jeff Johnson | f8a0b8f | 2019-02-26 19:26:31 -0800 | [diff] [blame] | 5398 | hdd_debug("rmc_enable %d", rmc_enable); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5399 | mac_handle = hdd_ctx->mac_handle; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5400 | |
Jeff Johnson | f8a0b8f | 2019-02-26 19:26:31 -0800 | [diff] [blame] | 5401 | if (true == rmc_enable) { |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5402 | status = sme_enable_rmc(mac_handle, adapter->vdev_id); |
Jeff Johnson | f8a0b8f | 2019-02-26 19:26:31 -0800 | [diff] [blame] | 5403 | } else if (false == rmc_enable) { |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5404 | status = sme_disable_rmc(mac_handle, adapter->vdev_id); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5405 | } else { |
Jeff Johnson | f8a0b8f | 2019-02-26 19:26:31 -0800 | [diff] [blame] | 5406 | hdd_err("Invalid SETRMCENABLE command %d", rmc_enable); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5407 | ret = -EINVAL; |
| 5408 | goto exit; |
| 5409 | } |
| 5410 | |
| 5411 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | f8a0b8f | 2019-02-26 19:26:31 -0800 | [diff] [blame] | 5412 | hdd_err("SETRMC %d failed status %d", rmc_enable, status); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5413 | ret = -EINVAL; |
| 5414 | goto exit; |
| 5415 | } |
| 5416 | |
| 5417 | exit: |
| 5418 | return ret; |
| 5419 | } |
| 5420 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5421 | static int drv_cmd_set_rmc_action_period(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5422 | struct hdd_context *hdd_ctx, |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5423 | uint8_t *command, |
| 5424 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5425 | struct hdd_priv_data *priv_data) |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5426 | { |
| 5427 | int ret = 0; |
| 5428 | uint8_t *value = command; |
Jeff Johnson | 3972e0d | 2019-02-26 19:42:35 -0800 | [diff] [blame] | 5429 | uint32_t action_period = 0; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5430 | int status; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5431 | mac_handle_t mac_handle; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5432 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 5433 | if ((QDF_IBSS_MODE != adapter->device_mode) && |
| 5434 | (QDF_SAP_MODE != adapter->device_mode)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5435 | hdd_err("Received SETRMC cmd in invalid mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 5436 | qdf_opmode_str(adapter->device_mode), |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5437 | adapter->device_mode); |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5438 | hdd_err("SETRMC cmd is allowed only in IBSS/SOFTAP mode"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5439 | ret = -EINVAL; |
| 5440 | goto exit; |
| 5441 | } |
| 5442 | |
Jeff Johnson | 3972e0d | 2019-02-26 19:42:35 -0800 | [diff] [blame] | 5443 | status = hdd_parse_setrmcactionperiod_command(value, &action_period); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5444 | if (status) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5445 | hdd_err("Invalid SETRMCACTIONPERIOD command"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5446 | ret = -EINVAL; |
| 5447 | goto exit; |
| 5448 | } |
| 5449 | |
Jeff Johnson | 3972e0d | 2019-02-26 19:42:35 -0800 | [diff] [blame] | 5450 | hdd_debug("action_period %d", action_period); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5451 | mac_handle = hdd_ctx->mac_handle; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5452 | |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 5453 | if (ucfg_mlme_set_rmc_action_period_freq(hdd_ctx->psoc, |
Jeff Johnson | 3972e0d | 2019-02-26 19:42:35 -0800 | [diff] [blame] | 5454 | action_period) != |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 5455 | QDF_STATUS_SUCCESS) { |
Jeff Johnson | 3972e0d | 2019-02-26 19:42:35 -0800 | [diff] [blame] | 5456 | hdd_err("Could not set SETRMCACTIONPERIOD %d", action_period); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5457 | ret = -EINVAL; |
| 5458 | goto exit; |
| 5459 | } |
| 5460 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5461 | status = sme_send_rmc_action_period(mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5462 | adapter->vdev_id); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5463 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5464 | hdd_err("Could not send cesium enable indication %d", |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5465 | status); |
| 5466 | ret = -EINVAL; |
| 5467 | goto exit; |
| 5468 | } |
| 5469 | |
| 5470 | exit: |
| 5471 | return ret; |
| 5472 | } |
| 5473 | |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5474 | static int drv_cmd_set_rmc_tx_rate(struct hdd_adapter *adapter, |
| 5475 | struct hdd_context *hdd_ctx, |
| 5476 | uint8_t *command, |
| 5477 | uint8_t command_len, |
| 5478 | struct hdd_priv_data *priv_data) |
| 5479 | { |
| 5480 | int ret = 0; |
| 5481 | uint8_t *value = command; |
Jeff Johnson | af5283f | 2019-02-26 19:31:48 -0800 | [diff] [blame] | 5482 | uint32_t rate = 0; |
Jeff Johnson | 269d7fb | 2019-02-26 10:47:33 -0800 | [diff] [blame] | 5483 | enum tx_rate_info tx_flags = 0; |
Jeff Johnson | 2370b85 | 2019-02-26 17:03:12 -0800 | [diff] [blame] | 5484 | tSirRateUpdateInd params = {0}; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5485 | int status; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 5486 | bool bval = false; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5487 | |
| 5488 | if ((QDF_IBSS_MODE != adapter->device_mode) && |
| 5489 | (QDF_SAP_MODE != adapter->device_mode)) { |
| 5490 | hdd_err("Received SETRMCTXRATE cmd in invalid mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 5491 | qdf_opmode_str(adapter->device_mode), |
| 5492 | adapter->device_mode); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5493 | hdd_err("SETRMCTXRATE cmd is allowed only in IBSS/SOFTAP mode"); |
| 5494 | ret = -EINVAL; |
| 5495 | goto exit; |
| 5496 | } |
| 5497 | |
Jeff Johnson | af5283f | 2019-02-26 19:31:48 -0800 | [diff] [blame] | 5498 | status = hdd_parse_setrmcrate_command(value, &rate, &tx_flags); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5499 | if (status) { |
| 5500 | hdd_err("Invalid SETRMCTXRATE command"); |
| 5501 | ret = -EINVAL; |
| 5502 | goto exit; |
| 5503 | } |
Jeff Johnson | af5283f | 2019-02-26 19:31:48 -0800 | [diff] [blame] | 5504 | hdd_debug("rate %d", rate); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5505 | |
| 5506 | /* |
| 5507 | * Fill the user specifieed RMC rate param |
| 5508 | * and the derived tx flags. |
| 5509 | */ |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 5510 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 5511 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 5512 | hdd_err("unable to get vht_enable2x2"); |
| 5513 | ret = -EINVAL; |
| 5514 | goto exit; |
| 5515 | } |
Jeff Johnson | 2370b85 | 2019-02-26 17:03:12 -0800 | [diff] [blame] | 5516 | params.nss = (bval == 0) ? 0 : 1; |
Jeff Johnson | af5283f | 2019-02-26 19:31:48 -0800 | [diff] [blame] | 5517 | params.reliableMcastDataRate = rate; |
Jeff Johnson | 2370b85 | 2019-02-26 17:03:12 -0800 | [diff] [blame] | 5518 | params.reliableMcastDataRateTxFlag = tx_flags; |
| 5519 | params.dev_mode = adapter->device_mode; |
| 5520 | params.bcastDataRate = -1; |
| 5521 | memcpy(params.bssid.bytes, |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5522 | adapter->mac_addr.bytes, |
Jeff Johnson | 2370b85 | 2019-02-26 17:03:12 -0800 | [diff] [blame] | 5523 | sizeof(params.bssid)); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5524 | status = sme_send_rate_update_ind(hdd_ctx->mac_handle, |
Jeff Johnson | 2370b85 | 2019-02-26 17:03:12 -0800 | [diff] [blame] | 5525 | ¶ms); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5526 | |
| 5527 | exit: |
| 5528 | return ret; |
| 5529 | } |
| 5530 | #endif /* FEATURE_WLAN_RMC */ |
| 5531 | |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 5532 | #ifdef FEATURE_WLAN_ESE |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5533 | 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] | 5534 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5535 | uint8_t *command, |
| 5536 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5537 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5538 | { |
| 5539 | int ret = 0; |
| 5540 | uint8_t *value = command; |
Liangwei Dong | 075afa7 | 2019-10-30 12:58:22 +0800 | [diff] [blame] | 5541 | uint32_t channel_freq_list[CFG_VALID_CHANNEL_LIST_LEN] = { 0 }; |
Jeff Johnson | 8a2e1da | 2019-02-26 17:56:24 -0800 | [diff] [blame] | 5542 | uint8_t num_channels = 0; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5543 | QDF_STATUS status; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5544 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5545 | |
Liangwei Dong | 075afa7 | 2019-10-30 12:58:22 +0800 | [diff] [blame] | 5546 | if (!hdd_ctx) { |
| 5547 | hdd_err("invalid hdd ctx"); |
| 5548 | ret = -EINVAL; |
| 5549 | goto exit; |
| 5550 | } |
| 5551 | |
| 5552 | ret = hdd_parse_channellist(hdd_ctx, value, channel_freq_list, |
| 5553 | &num_channels); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5554 | if (ret) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5555 | hdd_err("Failed to parse channel list information"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5556 | goto exit; |
| 5557 | } |
Jeff Johnson | 8a2e1da | 2019-02-26 17:56:24 -0800 | [diff] [blame] | 5558 | if (num_channels > CFG_VALID_CHANNEL_LIST_LEN) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5559 | hdd_err("number of channels (%d) supported exceeded max (%d)", |
Jeff Johnson | 8a2e1da | 2019-02-26 17:56:24 -0800 | [diff] [blame] | 5560 | num_channels, |
| 5561 | CFG_VALID_CHANNEL_LIST_LEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5562 | ret = -EINVAL; |
| 5563 | goto exit; |
| 5564 | } |
Vignesh Viswanathan | a2f5ce58 | 2018-05-09 20:38:39 +0530 | [diff] [blame] | 5565 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5566 | mac_handle = hdd_ctx->mac_handle; |
Liangwei Dong | 075afa7 | 2019-10-30 12:58:22 +0800 | [diff] [blame] | 5567 | if (!sme_validate_channel_list(mac_handle, channel_freq_list, |
Jeff Johnson | 8a2e1da | 2019-02-26 17:56:24 -0800 | [diff] [blame] | 5568 | num_channels)) { |
Vignesh Viswanathan | a2f5ce58 | 2018-05-09 20:38:39 +0530 | [diff] [blame] | 5569 | hdd_err("List contains invalid channel(s)"); |
| 5570 | ret = -EINVAL; |
| 5571 | goto exit; |
| 5572 | } |
| 5573 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5574 | status = sme_set_ese_roam_scan_channel_list(mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5575 | adapter->vdev_id, |
Liangwei Dong | 075afa7 | 2019-10-30 12:58:22 +0800 | [diff] [blame] | 5576 | channel_freq_list, |
Jeff Johnson | 8a2e1da | 2019-02-26 17:56:24 -0800 | [diff] [blame] | 5577 | num_channels); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5578 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5579 | hdd_err("Failed to update channel list information"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5580 | ret = -EINVAL; |
| 5581 | goto exit; |
| 5582 | } |
| 5583 | |
| 5584 | exit: |
| 5585 | return ret; |
| 5586 | } |
| 5587 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5588 | static int drv_cmd_get_tsm_stats(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5589 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5590 | uint8_t *command, |
| 5591 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5592 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5593 | { |
| 5594 | int ret = 0; |
| 5595 | uint8_t *value = command; |
| 5596 | char extra[128] = { 0 }; |
| 5597 | int len = 0; |
| 5598 | uint8_t tid = 0; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5599 | struct hdd_station_ctx *sta_ctx; |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 5600 | tAniTrafStrmMetrics tsm_metrics = {0}; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5601 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 5602 | if ((QDF_STA_MODE != adapter->device_mode) && |
| 5603 | (QDF_P2P_CLIENT_MODE != adapter->device_mode)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5604 | hdd_warn("Unsupported in mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 5605 | qdf_opmode_str(adapter->device_mode), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5606 | adapter->device_mode); |
| 5607 | return -EINVAL; |
| 5608 | } |
| 5609 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5610 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5611 | |
| 5612 | /* if not associated, return error */ |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 5613 | if (eConnectionState_Associated != sta_ctx->conn_info.conn_state) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5614 | hdd_err("Not associated!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5615 | ret = -EINVAL; |
| 5616 | goto exit; |
| 5617 | } |
| 5618 | |
| 5619 | /* Move pointer to ahead of GETTSMSTATS<delimiter> */ |
| 5620 | value = value + command_len + 1; |
| 5621 | |
| 5622 | /* Convert the value from ascii to integer */ |
| 5623 | ret = kstrtou8(value, 10, &tid); |
| 5624 | if (ret < 0) { |
| 5625 | /* |
| 5626 | * If the input value is greater than max value of datatype, |
| 5627 | * then also kstrtou8 fails |
| 5628 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5629 | hdd_err("kstrtou8 failed range [%d - %d]", |
| 5630 | TID_MIN_VALUE, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5631 | TID_MAX_VALUE); |
| 5632 | ret = -EINVAL; |
| 5633 | goto exit; |
| 5634 | } |
| 5635 | if ((tid < TID_MIN_VALUE) || (tid > TID_MAX_VALUE)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5636 | 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] | 5637 | tid, TID_MIN_VALUE, TID_MAX_VALUE); |
| 5638 | ret = -EINVAL; |
| 5639 | goto exit; |
| 5640 | } |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5641 | hdd_debug("Received Command to get tsm stats tid = %d", |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5642 | tid); |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 5643 | ret = hdd_get_tsm_stats(adapter, tid, &tsm_metrics); |
| 5644 | if (ret) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5645 | hdd_err("failed to get tsm stats"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5646 | goto exit; |
| 5647 | } |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5648 | hdd_debug( |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5649 | "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] | 5650 | tsm_metrics.UplinkPktQueueDly, |
| 5651 | tsm_metrics.UplinkPktQueueDlyHist[0], |
| 5652 | tsm_metrics.UplinkPktQueueDlyHist[1], |
| 5653 | tsm_metrics.UplinkPktQueueDlyHist[2], |
| 5654 | tsm_metrics.UplinkPktQueueDlyHist[3], |
| 5655 | tsm_metrics.UplinkPktTxDly, |
| 5656 | tsm_metrics.UplinkPktLoss, |
| 5657 | tsm_metrics.UplinkPktCount, |
| 5658 | tsm_metrics.RoamingCount, |
| 5659 | tsm_metrics.RoamingDly); |
| 5660 | /* |
| 5661 | * Output TSM stats is of the format |
| 5662 | * GETTSMSTATS [PktQueueDly] |
| 5663 | * [PktQueueDlyHist[0]]:[PktQueueDlyHist[1]] ...[RoamingDly] |
| 5664 | * eg., GETTSMSTATS 10 1:0:0:161 20 1 17 8 39800 |
| 5665 | */ |
| 5666 | len = scnprintf(extra, |
| 5667 | sizeof(extra), |
| 5668 | "%s %d %d:%d:%d:%d %u %d %d %d %d", |
| 5669 | command, |
| 5670 | tsm_metrics.UplinkPktQueueDly, |
| 5671 | tsm_metrics.UplinkPktQueueDlyHist[0], |
| 5672 | tsm_metrics.UplinkPktQueueDlyHist[1], |
| 5673 | tsm_metrics.UplinkPktQueueDlyHist[2], |
| 5674 | tsm_metrics.UplinkPktQueueDlyHist[3], |
| 5675 | tsm_metrics.UplinkPktTxDly, |
| 5676 | tsm_metrics.UplinkPktLoss, |
| 5677 | tsm_metrics.UplinkPktCount, |
| 5678 | tsm_metrics.RoamingCount, |
| 5679 | tsm_metrics.RoamingDly); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5680 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5681 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5682 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5683 | ret = -EFAULT; |
| 5684 | goto exit; |
| 5685 | } |
| 5686 | |
| 5687 | exit: |
| 5688 | return ret; |
| 5689 | } |
| 5690 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5691 | static int drv_cmd_set_cckm_ie(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5692 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5693 | uint8_t *command, |
| 5694 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5695 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5696 | { |
| 5697 | int ret; |
| 5698 | uint8_t *value = command; |
Jeff Johnson | 264e2d3 | 2019-02-26 13:16:58 -0800 | [diff] [blame] | 5699 | uint8_t *cckm_ie = NULL; |
Jeff Johnson | b9eeef3 | 2019-02-26 13:15:49 -0800 | [diff] [blame] | 5700 | uint8_t cckm_ie_len = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5701 | |
Jeff Johnson | 264e2d3 | 2019-02-26 13:16:58 -0800 | [diff] [blame] | 5702 | ret = hdd_parse_get_cckm_ie(value, &cckm_ie, &cckm_ie_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5703 | if (ret) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5704 | hdd_err("Failed to parse cckm ie data"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5705 | goto exit; |
| 5706 | } |
| 5707 | |
Jeff Johnson | b9eeef3 | 2019-02-26 13:15:49 -0800 | [diff] [blame] | 5708 | if (cckm_ie_len > DOT11F_IE_RSN_MAX_LEN) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5709 | hdd_err("CCKM Ie input length is more than max[%d]", |
| 5710 | DOT11F_IE_RSN_MAX_LEN); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 5711 | if (cckm_ie) { |
Jeff Johnson | 264e2d3 | 2019-02-26 13:16:58 -0800 | [diff] [blame] | 5712 | qdf_mem_free(cckm_ie); |
| 5713 | cckm_ie = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5714 | } |
| 5715 | ret = -EINVAL; |
| 5716 | goto exit; |
| 5717 | } |
| 5718 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5719 | sme_set_cckm_ie(hdd_ctx->mac_handle, adapter->vdev_id, |
Jeff Johnson | 264e2d3 | 2019-02-26 13:16:58 -0800 | [diff] [blame] | 5720 | cckm_ie, cckm_ie_len); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 5721 | if (cckm_ie) { |
Jeff Johnson | 264e2d3 | 2019-02-26 13:16:58 -0800 | [diff] [blame] | 5722 | qdf_mem_free(cckm_ie); |
| 5723 | cckm_ie = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5724 | } |
| 5725 | |
| 5726 | exit: |
| 5727 | return ret; |
| 5728 | } |
| 5729 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5730 | static int drv_cmd_ccx_beacon_req(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5731 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5732 | uint8_t *command, |
| 5733 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5734 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5735 | { |
| 5736 | int ret; |
| 5737 | uint8_t *value = command; |
Jeff Johnson | 210bc97 | 2019-02-26 19:55:01 -0800 | [diff] [blame] | 5738 | tCsrEseBeaconReq req = {0}; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5739 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5740 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 5741 | if (QDF_STA_MODE != adapter->device_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5742 | hdd_warn("Unsupported in mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 5743 | qdf_opmode_str(adapter->device_mode), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5744 | adapter->device_mode); |
| 5745 | return -EINVAL; |
| 5746 | } |
| 5747 | |
gaurank kathpalia | 88f78ec | 2019-09-04 20:18:02 +0530 | [diff] [blame] | 5748 | ret = hdd_parse_ese_beacon_req(hdd_ctx->pdev, value, &req); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5749 | if (ret) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5750 | hdd_err("Failed to parse ese beacon req"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5751 | goto exit; |
| 5752 | } |
| 5753 | |
| 5754 | if (!hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5755 | hdd_debug("Not associated"); |
Rajeev Kumar Sirasanagandla | 8413a48 | 2018-04-19 18:02:45 +0530 | [diff] [blame] | 5756 | |
Jeff Johnson | 210bc97 | 2019-02-26 19:55:01 -0800 | [diff] [blame] | 5757 | if (!req.numBcnReqIe) |
Rajeev Kumar Sirasanagandla | 8413a48 | 2018-04-19 18:02:45 +0530 | [diff] [blame] | 5758 | return -EINVAL; |
| 5759 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5760 | hdd_indicate_ese_bcn_report_no_results(adapter, |
Jeff Johnson | 210bc97 | 2019-02-26 19:55:01 -0800 | [diff] [blame] | 5761 | req.bcnReq[0].measurementToken, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5762 | 0x02, /* BIT(1) set for measurement done */ |
| 5763 | 0); /* no BSS */ |
| 5764 | goto exit; |
| 5765 | } |
| 5766 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5767 | status = sme_set_ese_beacon_request(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5768 | adapter->vdev_id, |
Jeff Johnson | 210bc97 | 2019-02-26 19:55:01 -0800 | [diff] [blame] | 5769 | &req); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5770 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5771 | if (QDF_STATUS_E_RESOURCES == status) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5772 | 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] | 5773 | status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5774 | ret = -EBUSY; |
| 5775 | goto exit; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5776 | } else if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5777 | hdd_err("sme_set_ese_beacon_request failed (%d)", |
| 5778 | status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5779 | ret = -EINVAL; |
| 5780 | goto exit; |
| 5781 | } |
| 5782 | |
| 5783 | exit: |
| 5784 | return ret; |
| 5785 | } |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 5786 | |
| 5787 | /** |
| 5788 | * drv_cmd_ccx_plm_req() - Set ESE PLM request |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 5789 | * @adapter: Pointer to the HDD adapter |
| 5790 | * @hdd_ctx: Pointer to the HDD context |
| 5791 | * @command: Driver command string |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 5792 | * @command_len: Driver command string length |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 5793 | * @priv_data: Private data coming with the driver command. Unused here |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 5794 | * |
| 5795 | * This function handles driver command that sets the ESE PLM request |
| 5796 | * |
| 5797 | * Return: 0 on success; negative errno otherwise |
| 5798 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5799 | static int drv_cmd_ccx_plm_req(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5800 | struct hdd_context *hdd_ctx, |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 5801 | uint8_t *command, |
| 5802 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5803 | struct hdd_priv_data *priv_data) |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 5804 | { |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 5805 | QDF_STATUS status; |
| 5806 | struct plm_req_params *req; |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 5807 | |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 5808 | req = qdf_mem_malloc(sizeof(*req)); |
| 5809 | if (!req) |
| 5810 | return -ENOMEM; |
| 5811 | |
| 5812 | status = hdd_parse_plm_cmd(command, req); |
| 5813 | if (QDF_IS_STATUS_SUCCESS(status)) { |
| 5814 | req->vdev_id = adapter->vdev_id; |
| 5815 | status = sme_set_plm_request(hdd_ctx->mac_handle, req); |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 5816 | } |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 5817 | qdf_mem_free(req); |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 5818 | |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 5819 | return qdf_status_to_os_return(status); |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 5820 | } |
| 5821 | |
| 5822 | /** |
| 5823 | * drv_cmd_set_ccx_mode() - Set ESE mode |
| 5824 | * @adapter: Pointer to the HDD adapter |
| 5825 | * @hdd_ctx: Pointer to the HDD context |
| 5826 | * @command: Driver command string |
| 5827 | * @command_len: Driver command string length |
| 5828 | * @priv_data: Private data coming with the driver command. Unused here |
| 5829 | * |
| 5830 | * This function handles driver command that sets ESE mode |
| 5831 | * |
| 5832 | * Return: 0 on success; negative errno otherwise |
| 5833 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5834 | static int drv_cmd_set_ccx_mode(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5835 | struct hdd_context *hdd_ctx, |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 5836 | uint8_t *command, |
| 5837 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5838 | struct hdd_priv_data *priv_data) |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 5839 | { |
| 5840 | int ret = 0; |
| 5841 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5842 | uint8_t ese_mode = cfg_default(CFG_LFR_ESE_FEATURE_ENABLED); |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 5843 | struct pmkid_mode_bits pmkid_modes; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5844 | mac_handle_t mac_handle; |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 5845 | |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 5846 | hdd_get_pmkid_modes(hdd_ctx, &pmkid_modes); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5847 | mac_handle = hdd_ctx->mac_handle; |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 5848 | /* |
| 5849 | * Check if the features OKC/ESE/11R are supported simultaneously, |
| 5850 | * then this operation is not permitted (return FAILURE) |
| 5851 | */ |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5852 | if (sme_get_is_ese_feature_enabled(mac_handle) && |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 5853 | pmkid_modes.fw_okc && |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5854 | sme_get_is_ft_feature_enabled(mac_handle)) { |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 5855 | hdd_warn("OKC/ESE/11R are supported simultaneously hence this operation is not permitted!"); |
| 5856 | ret = -EPERM; |
| 5857 | goto exit; |
| 5858 | } |
| 5859 | |
| 5860 | /* Move pointer to ahead of SETCCXMODE<delimiter> */ |
| 5861 | value = value + command_len + 1; |
| 5862 | |
| 5863 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5864 | ret = kstrtou8(value, 10, &ese_mode); |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 5865 | if (ret < 0) { |
| 5866 | /* |
| 5867 | * If the input value is greater than max value of datatype, |
| 5868 | * then also kstrtou8 fails |
| 5869 | */ |
| 5870 | hdd_err("kstrtou8 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5871 | cfg_min(CFG_LFR_ESE_FEATURE_ENABLED), |
| 5872 | cfg_max(CFG_LFR_ESE_FEATURE_ENABLED)); |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 5873 | ret = -EINVAL; |
| 5874 | goto exit; |
| 5875 | } |
| 5876 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5877 | hdd_debug("Received Command to change ese mode = %d", ese_mode); |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 5878 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5879 | sme_update_is_ese_feature_enabled(mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5880 | adapter->vdev_id, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5881 | ese_mode); |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 5882 | |
| 5883 | exit: |
| 5884 | return ret; |
| 5885 | } |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 5886 | #endif /* FEATURE_WLAN_ESE */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5887 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5888 | static int drv_cmd_set_mc_rate(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5889 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5890 | uint8_t *command, |
| 5891 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5892 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5893 | { |
| 5894 | int ret = 0; |
| 5895 | uint8_t *value = command; |
Srinivas Girigowda | 9d55015 | 2019-03-26 12:19:45 -0700 | [diff] [blame] | 5896 | uint32_t target_rate = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5897 | |
| 5898 | /* input value is in units of hundred kbps */ |
| 5899 | |
| 5900 | /* Move pointer to ahead of SETMCRATE<delimiter> */ |
| 5901 | value = value + command_len + 1; |
| 5902 | |
| 5903 | /* Convert the value from ascii to integer, decimal base */ |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5904 | ret = kstrtouint(value, 10, &target_rate); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5905 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5906 | ret = wlan_hdd_set_mc_rate(adapter, target_rate); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5907 | return ret; |
| 5908 | } |
| 5909 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5910 | static int drv_cmd_max_tx_power(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5911 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5912 | uint8_t *command, |
| 5913 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5914 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5915 | { |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5916 | int ret; |
| 5917 | int tx_power; |
| 5918 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5919 | uint8_t *value = command; |
Dustin Brown | ce5b3d3 | 2018-01-17 15:07:38 -0800 | [diff] [blame] | 5920 | struct qdf_mac_addr bssid = QDF_MAC_ADDR_BCAST_INIT; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5921 | struct qdf_mac_addr selfmac = QDF_MAC_ADDR_BCAST_INIT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5922 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5923 | ret = hdd_parse_setmaxtxpower_command(value, &tx_power); |
| 5924 | if (ret) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5925 | hdd_err("Invalid MAXTXPOWER command"); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5926 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5927 | } |
| 5928 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5929 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5930 | /* Assign correct self MAC address */ |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 5931 | qdf_copy_macaddr(&bssid, |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5932 | &adapter->mac_addr); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5933 | qdf_copy_macaddr(&selfmac, |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5934 | &adapter->mac_addr); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5935 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5936 | hdd_debug("Device mode %d max tx power %d selfMac: " |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 5937 | QDF_MAC_ADDR_STR " bssId: " QDF_MAC_ADDR_STR, |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5938 | adapter->device_mode, tx_power, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 5939 | QDF_MAC_ADDR_ARRAY(selfmac.bytes), |
| 5940 | QDF_MAC_ADDR_ARRAY(bssid.bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5941 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5942 | status = sme_set_max_tx_power(hdd_ctx->mac_handle, |
| 5943 | bssid, selfmac, tx_power); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5944 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5945 | hdd_err("Set max tx power failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5946 | ret = -EINVAL; |
| 5947 | goto exit; |
| 5948 | } |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5949 | hdd_debug("Set max tx power success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5950 | } |
| 5951 | |
| 5952 | exit: |
| 5953 | return ret; |
| 5954 | } |
| 5955 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5956 | static int drv_cmd_set_dfs_scan_mode(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5957 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5958 | uint8_t *command, |
| 5959 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5960 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5961 | { |
| 5962 | int ret = 0; |
| 5963 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5964 | uint8_t dfs_scan_mode = cfg_default(CFG_LFR_ROAMING_DFS_CHANNEL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5965 | |
| 5966 | /* Move pointer to ahead of SETDFSSCANMODE<delimiter> */ |
| 5967 | value = value + command_len + 1; |
| 5968 | |
| 5969 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5970 | ret = kstrtou8(value, 10, &dfs_scan_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5971 | if (ret < 0) { |
| 5972 | /* |
| 5973 | * If the input value is greater than max value of datatype, |
| 5974 | * then also kstrtou8 fails |
| 5975 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5976 | hdd_err("kstrtou8 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5977 | cfg_min(CFG_LFR_ROAMING_DFS_CHANNEL), |
| 5978 | cfg_max(CFG_LFR_ROAMING_DFS_CHANNEL)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5979 | ret = -EINVAL; |
| 5980 | goto exit; |
| 5981 | } |
| 5982 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5983 | if (!cfg_in_range(CFG_LFR_ROAMING_DFS_CHANNEL, dfs_scan_mode)) { |
Jeff Johnson | 6860551 | 2019-02-26 21:30:04 -0800 | [diff] [blame] | 5984 | 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] | 5985 | dfs_scan_mode, |
| 5986 | cfg_min(CFG_LFR_ROAMING_DFS_CHANNEL), |
| 5987 | cfg_max(CFG_LFR_ROAMING_DFS_CHANNEL)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5988 | ret = -EINVAL; |
| 5989 | goto exit; |
| 5990 | } |
| 5991 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5992 | hdd_debug("Received Command to Set DFS Scan Mode = %d", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5993 | dfs_scan_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5994 | |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 5995 | /* When DFS scanning is disabled, the DFS channels need to be |
| 5996 | * removed from the operation of device. |
| 5997 | */ |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 5998 | ret = wlan_hdd_enable_dfs_chan_scan(hdd_ctx, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5999 | dfs_scan_mode != ROAMING_DFS_CHANNEL_DISABLED); |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 6000 | if (ret < 0) { |
| 6001 | /* Some conditions prevented it from disabling DFS channels */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 6002 | hdd_err("disable/enable DFS channel request was denied"); |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 6003 | goto exit; |
| 6004 | } |
| 6005 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 6006 | sme_update_dfs_scan_mode(hdd_ctx->mac_handle, adapter->vdev_id, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 6007 | dfs_scan_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6008 | |
| 6009 | exit: |
| 6010 | return ret; |
| 6011 | } |
| 6012 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6013 | static int drv_cmd_get_dfs_scan_mode(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6014 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6015 | uint8_t *command, |
| 6016 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6017 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6018 | { |
| 6019 | int ret = 0; |
Jeff Johnson | 6860551 | 2019-02-26 21:30:04 -0800 | [diff] [blame] | 6020 | 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] | 6021 | char extra[32]; |
| 6022 | uint8_t len = 0; |
| 6023 | |
Jeff Johnson | 6860551 | 2019-02-26 21:30:04 -0800 | [diff] [blame] | 6024 | len = scnprintf(extra, sizeof(extra), "%s %d", command, dfs_scan_mode); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6025 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6026 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 6027 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6028 | ret = -EFAULT; |
| 6029 | } |
| 6030 | |
| 6031 | return ret; |
| 6032 | } |
| 6033 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6034 | static int drv_cmd_get_link_status(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6035 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6036 | uint8_t *command, |
| 6037 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6038 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6039 | { |
| 6040 | int ret = 0; |
| 6041 | int value = wlan_hdd_get_link_status(adapter); |
| 6042 | char extra[32]; |
| 6043 | uint8_t len; |
| 6044 | |
| 6045 | len = scnprintf(extra, sizeof(extra), "%s %d", command, value); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6046 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6047 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 6048 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6049 | ret = -EFAULT; |
| 6050 | } |
| 6051 | |
| 6052 | return ret; |
| 6053 | } |
| 6054 | |
| 6055 | #ifdef WLAN_FEATURE_EXTWOW_SUPPORT |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6056 | static int drv_cmd_enable_ext_wow(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6057 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6058 | uint8_t *command, |
| 6059 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6060 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6061 | { |
| 6062 | uint8_t *value = command; |
| 6063 | int set_value; |
| 6064 | |
| 6065 | /* Move pointer to ahead of ENABLEEXTWOW */ |
| 6066 | value = value + command_len; |
| 6067 | |
Anurag Chouhan | 43e0c75 | 2016-09-03 16:17:02 +0530 | [diff] [blame] | 6068 | if (!(sscanf(value, "%d", &set_value))) { |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 6069 | hdd_info("No input identified"); |
Anurag Chouhan | 43e0c75 | 2016-09-03 16:17:02 +0530 | [diff] [blame] | 6070 | return -EINVAL; |
| 6071 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6072 | |
| 6073 | return hdd_enable_ext_wow_parser(adapter, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 6074 | adapter->vdev_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6075 | set_value); |
| 6076 | } |
| 6077 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6078 | static int drv_cmd_set_app1_params(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6079 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6080 | uint8_t *command, |
| 6081 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6082 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6083 | { |
| 6084 | int ret; |
| 6085 | uint8_t *value = command; |
| 6086 | |
| 6087 | /* Move pointer to ahead of SETAPP1PARAMS */ |
| 6088 | value = value + command_len; |
| 6089 | |
| 6090 | ret = hdd_set_app_type1_parser(adapter, |
| 6091 | value, strlen(value)); |
| 6092 | if (ret >= 0) |
| 6093 | hdd_ctx->is_extwow_app_type1_param_set = true; |
| 6094 | |
| 6095 | return ret; |
| 6096 | } |
| 6097 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6098 | static int drv_cmd_set_app2_params(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6099 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6100 | uint8_t *command, |
| 6101 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6102 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6103 | { |
| 6104 | int ret; |
| 6105 | uint8_t *value = command; |
| 6106 | |
| 6107 | /* Move pointer to ahead of SETAPP2PARAMS */ |
| 6108 | value = value + command_len; |
| 6109 | |
| 6110 | ret = hdd_set_app_type2_parser(adapter, value, strlen(value)); |
| 6111 | if (ret >= 0) |
| 6112 | hdd_ctx->is_extwow_app_type2_param_set = true; |
| 6113 | |
| 6114 | return ret; |
| 6115 | } |
| 6116 | #endif /* WLAN_FEATURE_EXTWOW_SUPPORT */ |
| 6117 | |
| 6118 | #ifdef FEATURE_WLAN_TDLS |
| 6119 | /** |
| 6120 | * drv_cmd_tdls_secondary_channel_offset() - secondary tdls off channel offset |
| 6121 | * @adapter: Pointer to the HDD adapter |
| 6122 | * @hdd_ctx: Pointer to the HDD context |
| 6123 | * @command: Driver command string |
| 6124 | * @command_len: Driver command string length |
| 6125 | * @priv_data: Private data coming with the driver command. Unused here |
| 6126 | * |
| 6127 | * This function handles driver command that sets the secondary tdls off channel |
| 6128 | * offset |
| 6129 | * |
| 6130 | * Return: 0 on success; negative errno otherwise |
| 6131 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6132 | static int drv_cmd_tdls_secondary_channel_offset(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6133 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6134 | uint8_t *command, |
| 6135 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6136 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6137 | { |
| 6138 | int ret; |
| 6139 | uint8_t *value = command; |
| 6140 | int set_value; |
| 6141 | |
| 6142 | /* Move pointer to point the string */ |
| 6143 | value += command_len; |
| 6144 | |
| 6145 | ret = sscanf(value, "%d", &set_value); |
| 6146 | if (ret != 1) |
| 6147 | return -EINVAL; |
| 6148 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 6149 | hdd_debug("Tdls offchannel offset:%d", set_value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6150 | |
Bala Venkatesh | 113a9e6 | 2018-08-30 15:19:02 +0530 | [diff] [blame] | 6151 | ret = hdd_set_tdls_secoffchanneloffset(hdd_ctx, adapter, set_value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6152 | |
| 6153 | return ret; |
| 6154 | } |
| 6155 | |
| 6156 | /** |
| 6157 | * drv_cmd_tdls_off_channel_mode() - set tdls off channel mode |
| 6158 | * @adapter: Pointer to the HDD adapter |
| 6159 | * @hdd_ctx: Pointer to the HDD context |
| 6160 | * @command: Driver command string |
| 6161 | * @command_len: Driver command string length |
| 6162 | * @priv_data: Private data coming with the driver command. Unused here |
| 6163 | * |
| 6164 | * This function handles driver command that sets tdls off channel mode |
| 6165 | * |
| 6166 | * Return: 0 on success; negative errno otherwise |
| 6167 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6168 | static int drv_cmd_tdls_off_channel_mode(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6169 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6170 | uint8_t *command, |
| 6171 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6172 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6173 | { |
| 6174 | int ret; |
| 6175 | uint8_t *value = command; |
| 6176 | int set_value; |
| 6177 | |
| 6178 | /* Move pointer to point the string */ |
| 6179 | value += command_len; |
| 6180 | |
| 6181 | ret = sscanf(value, "%d", &set_value); |
| 6182 | if (ret != 1) |
| 6183 | return -EINVAL; |
| 6184 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 6185 | hdd_debug("Tdls offchannel mode:%d", set_value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6186 | |
Bala Venkatesh | 113a9e6 | 2018-08-30 15:19:02 +0530 | [diff] [blame] | 6187 | ret = hdd_set_tdls_offchannelmode(hdd_ctx, adapter, set_value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6188 | |
| 6189 | return ret; |
| 6190 | } |
| 6191 | |
| 6192 | /** |
| 6193 | * drv_cmd_tdls_off_channel() - set tdls off channel number |
| 6194 | * @adapter: Pointer to the HDD adapter |
| 6195 | * @hdd_ctx: Pointer to the HDD context |
| 6196 | * @command: Driver command string |
| 6197 | * @command_len: Driver command string length |
| 6198 | * @priv_data: Private data coming with the driver command. Unused here |
| 6199 | * |
| 6200 | * This function handles driver command that sets tdls off channel number |
| 6201 | * |
| 6202 | * Return: 0 on success; negative errno otherwise |
| 6203 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6204 | static int drv_cmd_tdls_off_channel(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6205 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6206 | uint8_t *command, |
| 6207 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6208 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6209 | { |
| 6210 | int ret; |
| 6211 | uint8_t *value = command; |
Bala Venkatesh | 07546fb | 2019-07-08 18:29:28 +0530 | [diff] [blame] | 6212 | int channel; |
| 6213 | enum channel_state reg_state; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6214 | |
| 6215 | /* Move pointer to point the string */ |
| 6216 | value += command_len; |
| 6217 | |
Bala Venkatesh | 07546fb | 2019-07-08 18:29:28 +0530 | [diff] [blame] | 6218 | ret = sscanf(value, "%d", &channel); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6219 | if (ret != 1) |
| 6220 | return -EINVAL; |
Bala Venkatesh | 07546fb | 2019-07-08 18:29:28 +0530 | [diff] [blame] | 6221 | reg_state = wlan_reg_get_channel_state(hdd_ctx->pdev, channel); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6222 | |
Bala Venkatesh | 07546fb | 2019-07-08 18:29:28 +0530 | [diff] [blame] | 6223 | if (reg_state == CHANNEL_STATE_DFS || |
| 6224 | reg_state == CHANNEL_STATE_DISABLE || |
| 6225 | reg_state == CHANNEL_STATE_INVALID) { |
| 6226 | hdd_err("reg state of the channel %d is %d and not supported", |
| 6227 | channel, reg_state); |
Krishna Kumaar Natarajan | 4d09035 | 2015-10-26 18:30:53 -0700 | [diff] [blame] | 6228 | return -EINVAL; |
| 6229 | } |
| 6230 | |
Bala Venkatesh | 07546fb | 2019-07-08 18:29:28 +0530 | [diff] [blame] | 6231 | hdd_debug("Tdls offchannel num: %d", channel); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6232 | |
Bala Venkatesh | 07546fb | 2019-07-08 18:29:28 +0530 | [diff] [blame] | 6233 | ret = hdd_set_tdls_offchannel(hdd_ctx, adapter, channel); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6234 | |
| 6235 | return ret; |
| 6236 | } |
| 6237 | |
| 6238 | /** |
| 6239 | * drv_cmd_tdls_scan() - set tdls scan type |
| 6240 | * @adapter: Pointer to the HDD adapter |
| 6241 | * @hdd_ctx: Pointer to the HDD context |
| 6242 | * @command: Driver command string |
| 6243 | * @command_len: Driver command string length |
| 6244 | * @priv_data: Private data coming with the driver command. Unused here |
| 6245 | * |
| 6246 | * This function handles driver command that sets tdls scan type |
| 6247 | * |
| 6248 | * Return: 0 on success; negative errno otherwise |
| 6249 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6250 | static int drv_cmd_tdls_scan(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6251 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6252 | uint8_t *command, |
| 6253 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6254 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6255 | { |
| 6256 | int ret; |
| 6257 | uint8_t *value = command; |
| 6258 | int set_value; |
| 6259 | |
| 6260 | /* Move pointer to point the string */ |
| 6261 | value += command_len; |
| 6262 | |
| 6263 | ret = sscanf(value, "%d", &set_value); |
| 6264 | if (ret != 1) |
| 6265 | return -EINVAL; |
| 6266 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 6267 | hdd_debug("Tdls scan type val: %d", set_value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6268 | |
| 6269 | ret = hdd_set_tdls_scan_type(hdd_ctx, set_value); |
| 6270 | |
| 6271 | return ret; |
| 6272 | } |
| 6273 | #endif |
| 6274 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6275 | static int drv_cmd_get_rssi(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6276 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6277 | uint8_t *command, |
| 6278 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6279 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6280 | { |
Orhan K AKYILDIZ | c409461 | 2015-11-11 18:01:15 -0800 | [diff] [blame] | 6281 | int ret = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6282 | int8_t rssi = 0; |
| 6283 | char extra[32]; |
Orhan K AKYILDIZ | c409461 | 2015-11-11 18:01:15 -0800 | [diff] [blame] | 6284 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6285 | uint8_t len = 0; |
| 6286 | |
| 6287 | wlan_hdd_get_rssi(adapter, &rssi); |
| 6288 | |
| 6289 | len = scnprintf(extra, sizeof(extra), "%s %d", command, rssi); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6290 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6291 | |
| 6292 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 6293 | hdd_err("Failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6294 | ret = -EFAULT; |
| 6295 | } |
| 6296 | |
| 6297 | return ret; |
| 6298 | } |
| 6299 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6300 | static int drv_cmd_get_linkspeed(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6301 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6302 | uint8_t *command, |
| 6303 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6304 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6305 | { |
| 6306 | int ret; |
| 6307 | uint32_t link_speed = 0; |
| 6308 | char extra[32]; |
| 6309 | uint8_t len = 0; |
| 6310 | |
| 6311 | ret = wlan_hdd_get_link_speed(adapter, &link_speed); |
| 6312 | if (0 != ret) |
| 6313 | return ret; |
| 6314 | |
| 6315 | len = scnprintf(extra, sizeof(extra), "%s %d", command, link_speed); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6316 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6317 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 6318 | hdd_err("Failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6319 | ret = -EFAULT; |
| 6320 | } |
| 6321 | |
| 6322 | return ret; |
| 6323 | } |
| 6324 | |
Qiwei Cai | 4505fc6 | 2018-05-17 18:35:19 +0800 | [diff] [blame] | 6325 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6326 | /** |
| 6327 | * hdd_set_rx_filter() - set RX filter |
| 6328 | * @adapter: Pointer to adapter |
| 6329 | * @action: Filter action |
| 6330 | * @pattern: Address pattern |
| 6331 | * |
| 6332 | * Address pattern is most significant byte of address for example |
| 6333 | * 0x01 for IPV4 multicast address |
| 6334 | * 0x33 for IPV6 multicast address |
| 6335 | * 0xFF for broadcast address |
| 6336 | * |
| 6337 | * Return: 0 for success, non-zero for failure |
| 6338 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6339 | static int hdd_set_rx_filter(struct hdd_adapter *adapter, bool action, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6340 | uint8_t pattern) |
| 6341 | { |
| 6342 | int ret; |
Frank Liu | f95e813 | 2016-09-29 19:01:30 +0800 | [diff] [blame] | 6343 | uint8_t i, j; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6344 | tSirRcvFltMcAddrList *filter; |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6345 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6346 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6347 | |
| 6348 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 6349 | if (0 != ret) |
| 6350 | return ret; |
| 6351 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6352 | mac_handle = hdd_ctx->mac_handle; |
| 6353 | if (!mac_handle) { |
| 6354 | hdd_err("MAC Handle is NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6355 | return -EINVAL; |
| 6356 | } |
| 6357 | |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 6358 | if (!ucfg_pmo_is_mc_addr_list_enabled(hdd_ctx->psoc)) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 6359 | hdd_warn("mc addr ini is disabled"); |
Mukul Sharma | 3a1ab30 | 2017-01-15 19:02:37 +0530 | [diff] [blame] | 6360 | return -EINVAL; |
| 6361 | } |
| 6362 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6363 | /* |
| 6364 | * If action is false it means start dropping packets |
| 6365 | * Set addr_filter_pattern which will be used when sending |
| 6366 | * MC/BC address list to target |
| 6367 | */ |
| 6368 | if (!action) |
| 6369 | adapter->addr_filter_pattern = pattern; |
| 6370 | else |
| 6371 | adapter->addr_filter_pattern = 0; |
| 6372 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 6373 | if (((adapter->device_mode == QDF_STA_MODE) || |
| 6374 | (adapter->device_mode == QDF_P2P_CLIENT_MODE)) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6375 | adapter->mc_addr_list.mc_cnt && |
| 6376 | hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
| 6377 | |
| 6378 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6379 | filter = qdf_mem_malloc(sizeof(*filter)); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 6380 | if (!filter) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6381 | hdd_err("Could not allocate Memory"); |
| 6382 | return -ENOMEM; |
| 6383 | } |
| 6384 | filter->action = action; |
Frank Liu | f95e813 | 2016-09-29 19:01:30 +0800 | [diff] [blame] | 6385 | 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] | 6386 | if (!memcmp(adapter->mc_addr_list.addr[i], |
| 6387 | &pattern, 1)) { |
Frank Liu | f95e813 | 2016-09-29 19:01:30 +0800 | [diff] [blame] | 6388 | memcpy(filter->multicastAddr[j].bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6389 | adapter->mc_addr_list.addr[i], |
| 6390 | sizeof(adapter->mc_addr_list.addr[i])); |
Frank Liu | f95e813 | 2016-09-29 19:01:30 +0800 | [diff] [blame] | 6391 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 6392 | hdd_debug("%s RX filter : addr =" |
Srinivas Girigowda | cb7b8b8 | 2019-04-10 14:27:47 -0700 | [diff] [blame] | 6393 | QDF_MAC_ADDR_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6394 | action ? "setting" : "clearing", |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 6395 | QDF_MAC_ADDR_ARRAY(filter->multicastAddr[j].bytes)); |
Frank Liu | f95e813 | 2016-09-29 19:01:30 +0800 | [diff] [blame] | 6396 | j++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6397 | } |
SaidiReddy Yenuga | 0b2c9f4 | 2017-02-03 12:26:38 +0530 | [diff] [blame] | 6398 | if (j == SIR_MAX_NUM_MULTICAST_ADDRESS) |
| 6399 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6400 | } |
Frank Liu | f95e813 | 2016-09-29 19:01:30 +0800 | [diff] [blame] | 6401 | filter->ulMulticastAddrCnt = j; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6402 | /* Set rx filter */ |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 6403 | sme_8023_multicast_list(mac_handle, adapter->vdev_id, |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6404 | filter); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6405 | qdf_mem_free(filter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6406 | } else { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 6407 | hdd_debug("mode %d mc_cnt %d", |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6408 | adapter->device_mode, adapter->mc_addr_list.mc_cnt); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6409 | } |
| 6410 | |
| 6411 | return 0; |
| 6412 | } |
| 6413 | |
| 6414 | /** |
Jeff Johnson | 0f7440e | 2018-05-06 16:12:39 -0700 | [diff] [blame] | 6415 | * hdd_driver_rxfilter_command_handler() - RXFILTER driver command handler |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6416 | * @command: Pointer to input string driver command |
| 6417 | * @adapter: Pointer to adapter |
| 6418 | * @action: Action to enable/disable filtering |
| 6419 | * |
| 6420 | * If action == false |
| 6421 | * Start filtering out data packets based on type |
| 6422 | * RXFILTER-REMOVE 0 -> Start filtering out unicast data packets |
| 6423 | * RXFILTER-REMOVE 1 -> Start filtering out broadcast data packets |
| 6424 | * RXFILTER-REMOVE 2 -> Start filtering out IPV4 mcast data packets |
| 6425 | * RXFILTER-REMOVE 3 -> Start filtering out IPV6 mcast data packets |
| 6426 | * |
| 6427 | * if action == true |
| 6428 | * Stop filtering data packets based on type |
| 6429 | * RXFILTER-ADD 0 -> Stop filtering unicast data packets |
| 6430 | * RXFILTER-ADD 1 -> Stop filtering broadcast data packets |
| 6431 | * RXFILTER-ADD 2 -> Stop filtering IPV4 mcast data packets |
| 6432 | * RXFILTER-ADD 3 -> Stop filtering IPV6 mcast data packets |
| 6433 | * |
| 6434 | * Current implementation only supports IPV4 address filtering by |
| 6435 | * selectively allowing IPV4 multicast data packest based on |
| 6436 | * address list received in .ndo_set_rx_mode |
| 6437 | * |
| 6438 | * Return: 0 for success, non-zero for failure |
| 6439 | */ |
Jeff Johnson | 0f7440e | 2018-05-06 16:12:39 -0700 | [diff] [blame] | 6440 | static int hdd_driver_rxfilter_command_handler(uint8_t *command, |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6441 | struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6442 | bool action) |
| 6443 | { |
| 6444 | int ret = 0; |
| 6445 | uint8_t *value; |
| 6446 | uint8_t type; |
| 6447 | |
| 6448 | value = command; |
| 6449 | /* Skip space after RXFILTER-REMOVE OR RXFILTER-ADD based on action */ |
| 6450 | if (!action) |
| 6451 | value = command + 16; |
| 6452 | else |
| 6453 | value = command + 13; |
| 6454 | ret = kstrtou8(value, 10, &type); |
| 6455 | if (ret < 0) { |
Dustin Brown | 933cd2a | 2018-04-18 11:28:15 -0700 | [diff] [blame] | 6456 | hdd_err("kstrtou8 failed invalid input value"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6457 | return -EINVAL; |
| 6458 | } |
| 6459 | |
| 6460 | switch (type) { |
| 6461 | case 2: |
| 6462 | /* Set rx filter for IPV4 multicast data packets */ |
| 6463 | ret = hdd_set_rx_filter(adapter, action, 0x01); |
| 6464 | break; |
| 6465 | default: |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 6466 | hdd_warn("Unsupported RXFILTER type %d", type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6467 | break; |
| 6468 | } |
| 6469 | |
| 6470 | return ret; |
| 6471 | } |
| 6472 | |
| 6473 | /** |
| 6474 | * drv_cmd_rx_filter_remove() - RXFILTER REMOVE driver command handler |
| 6475 | * @adapter: Pointer to network adapter |
| 6476 | * @hdd_ctx: Pointer to hdd context |
| 6477 | * @command: Pointer to input command |
| 6478 | * @command_len: Command length |
| 6479 | * @priv_data: Pointer to private data in command |
| 6480 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6481 | static int drv_cmd_rx_filter_remove(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6482 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6483 | uint8_t *command, |
| 6484 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6485 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6486 | { |
Jeff Johnson | 0f7440e | 2018-05-06 16:12:39 -0700 | [diff] [blame] | 6487 | return hdd_driver_rxfilter_command_handler(command, adapter, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6488 | } |
| 6489 | |
| 6490 | /** |
| 6491 | * drv_cmd_rx_filter_add() - RXFILTER ADD driver command handler |
| 6492 | * @adapter: Pointer to network adapter |
| 6493 | * @hdd_ctx: Pointer to hdd context |
| 6494 | * @command: Pointer to input command |
| 6495 | * @command_len: Command length |
| 6496 | * @priv_data: Pointer to private data in command |
| 6497 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6498 | static int drv_cmd_rx_filter_add(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6499 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6500 | uint8_t *command, |
| 6501 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6502 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6503 | { |
Jeff Johnson | 0f7440e | 2018-05-06 16:12:39 -0700 | [diff] [blame] | 6504 | return hdd_driver_rxfilter_command_handler(command, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6505 | } |
Qiwei Cai | 4505fc6 | 2018-05-17 18:35:19 +0800 | [diff] [blame] | 6506 | #endif /* WLAN_FEATURE_PACKET_FILTERING */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6507 | |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6508 | /** |
| 6509 | * hdd_parse_setantennamode_command() - HDD Parse SETANTENNAMODE |
| 6510 | * command |
| 6511 | * @value: Pointer to SETANTENNAMODE command |
| 6512 | * @mode: Pointer to antenna mode |
| 6513 | * @reason: Pointer to reason for set antenna mode |
| 6514 | * |
| 6515 | * This function parses the SETANTENNAMODE command passed in the format |
| 6516 | * SETANTENNAMODE<space>mode |
| 6517 | * |
| 6518 | * Return: 0 for success non-zero for failure |
| 6519 | */ |
| 6520 | static int hdd_parse_setantennamode_command(const uint8_t *value) |
| 6521 | { |
| 6522 | const uint8_t *in_ptr = value; |
| 6523 | int tmp, v; |
| 6524 | char arg1[32]; |
| 6525 | |
| 6526 | in_ptr = strnchr(value, strlen(value), SPACE_ASCII_VALUE); |
| 6527 | |
| 6528 | /* no argument after the command */ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 6529 | if (!in_ptr) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 6530 | hdd_err("No argument after the command"); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6531 | return -EINVAL; |
| 6532 | } |
| 6533 | |
| 6534 | /* no space after the command */ |
| 6535 | if (SPACE_ASCII_VALUE != *in_ptr) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 6536 | hdd_err("No space after the command"); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6537 | return -EINVAL; |
| 6538 | } |
| 6539 | |
| 6540 | /* remove empty spaces */ |
| 6541 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 6542 | in_ptr++; |
| 6543 | |
| 6544 | /* no argument followed by spaces */ |
| 6545 | if ('\0' == *in_ptr) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 6546 | hdd_err("No argument followed by spaces"); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6547 | return -EINVAL; |
| 6548 | } |
| 6549 | |
| 6550 | /* get the argument i.e. antenna mode */ |
| 6551 | v = sscanf(in_ptr, "%31s ", arg1); |
| 6552 | if (1 != v) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 6553 | hdd_err("argument retrieval from cmd string failed"); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6554 | return -EINVAL; |
| 6555 | } |
| 6556 | |
| 6557 | v = kstrtos32(arg1, 10, &tmp); |
| 6558 | if (v < 0) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 6559 | hdd_err("argument string to int conversion failed"); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6560 | return -EINVAL; |
| 6561 | } |
| 6562 | |
| 6563 | return tmp; |
| 6564 | } |
| 6565 | |
| 6566 | /** |
| 6567 | * hdd_is_supported_chain_mask_2x2() - Verify if supported chain |
| 6568 | * mask is 2x2 mode |
| 6569 | * @hdd_ctx: Pointer to hdd contex |
| 6570 | * |
| 6571 | * Return: true if supported chain mask 2x2 else false |
| 6572 | */ |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6573 | 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] | 6574 | { |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 6575 | QDF_STATUS status; |
| 6576 | bool bval = false; |
| 6577 | |
| 6578 | /* |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6579 | * Revisit and the update logic to determine the number |
| 6580 | * of TX/RX chains supported in the system when |
| 6581 | * antenna sharing per band chain mask support is |
| 6582 | * brought in |
| 6583 | */ |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 6584 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 6585 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 6586 | hdd_err("unable to get vht_enable2x2"); |
| 6587 | |
| 6588 | return (bval == 0x01) ? true : false; |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6589 | } |
| 6590 | |
| 6591 | /** |
| 6592 | * hdd_is_supported_chain_mask_1x1() - Verify if the supported |
| 6593 | * chain mask is 1x1 |
| 6594 | * @hdd_ctx: Pointer to hdd contex |
| 6595 | * |
| 6596 | * Return: true if supported chain mask 1x1 else false |
| 6597 | */ |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6598 | 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] | 6599 | { |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 6600 | QDF_STATUS status; |
| 6601 | bool bval = false; |
| 6602 | |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6603 | /* |
| 6604 | * Revisit and update the logic to determine the number |
| 6605 | * of TX/RX chains supported in the system when |
| 6606 | * antenna sharing per band chain mask support is |
| 6607 | * brought in |
| 6608 | */ |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 6609 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 6610 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 6611 | hdd_err("unable to get vht_enable2x2"); |
| 6612 | |
| 6613 | return (!bval) ? true : false; |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6614 | } |
| 6615 | |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6616 | 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] | 6617 | { |
| 6618 | QDF_STATUS status; |
| 6619 | uint8_t smps_mode; |
| 6620 | uint8_t smps_enable; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6621 | mac_handle_t mac_handle; |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 6622 | |
| 6623 | /* Update SME SMPS config */ |
| 6624 | if (HDD_ANTENNA_MODE_1X1 == mode) { |
| 6625 | smps_enable = true; |
| 6626 | smps_mode = HDD_SMPS_MODE_STATIC; |
| 6627 | } else { |
| 6628 | smps_enable = false; |
| 6629 | smps_mode = HDD_SMPS_MODE_DISABLED; |
| 6630 | } |
| 6631 | |
| 6632 | hdd_debug("Update SME SMPS enable: %d mode: %d", |
| 6633 | smps_enable, smps_mode); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6634 | mac_handle = hdd_ctx->mac_handle; |
| 6635 | status = sme_update_mimo_power_save(mac_handle, smps_enable, |
| 6636 | smps_mode, false); |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 6637 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6638 | hdd_err("Update SMPS config failed enable: %d mode: %d status: %d", |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 6639 | smps_enable, smps_mode, status); |
| 6640 | return QDF_STATUS_E_FAILURE; |
| 6641 | } |
| 6642 | |
| 6643 | hdd_ctx->current_antenna_mode = mode; |
| 6644 | /* |
| 6645 | * Update the user requested nss in the mac context. |
| 6646 | * This will be used in tdls protocol engine to form tdls |
| 6647 | * Management frames. |
| 6648 | */ |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6649 | sme_update_user_configured_nss(mac_handle, |
| 6650 | hdd_ctx->current_antenna_mode); |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 6651 | |
| 6652 | hdd_debug("Successfully switched to mode: %d x %d", |
| 6653 | hdd_ctx->current_antenna_mode, |
| 6654 | hdd_ctx->current_antenna_mode); |
| 6655 | |
| 6656 | return QDF_STATUS_SUCCESS; |
| 6657 | } |
| 6658 | |
Dundi Raviteja | 4016e93 | 2018-08-02 12:16:25 +0530 | [diff] [blame] | 6659 | /** |
| 6660 | * wlan_hdd_soc_set_antenna_mode_cb() - Callback for set antenna mode |
| 6661 | * @status: Status of set antenna mode |
| 6662 | * @context: callback context |
| 6663 | * |
| 6664 | * Callback on setting antenna mode |
| 6665 | * |
| 6666 | * Return: None |
| 6667 | */ |
| 6668 | static void |
| 6669 | wlan_hdd_soc_set_antenna_mode_cb(enum set_antenna_mode_status status, |
| 6670 | void *context) |
| 6671 | { |
| 6672 | struct osif_request *request = NULL; |
| 6673 | |
| 6674 | hdd_debug("Status: %d", status); |
| 6675 | |
| 6676 | request = osif_request_get(context); |
| 6677 | if (!request) { |
| 6678 | hdd_err("obselete request"); |
| 6679 | return; |
| 6680 | } |
| 6681 | |
| 6682 | /* Signal the completion of set dual mac config */ |
| 6683 | osif_request_complete(request); |
| 6684 | osif_request_put(request); |
| 6685 | } |
| 6686 | |
gaurank kathpalia | 7cb6a32 | 2018-10-24 19:50:34 +0530 | [diff] [blame] | 6687 | static QDF_STATUS |
| 6688 | hdd_populate_vdev_chains(struct wlan_mlme_nss_chains *nss_chains_cfg, |
| 6689 | uint8_t tx_chains, |
| 6690 | uint8_t rx_chains, |
| 6691 | enum nss_chains_band_info band, |
| 6692 | struct wlan_objmgr_vdev *vdev) |
| 6693 | { |
| 6694 | struct wlan_mlme_nss_chains *dynamic_cfg; |
| 6695 | |
| 6696 | nss_chains_cfg->num_rx_chains[band] = rx_chains; |
| 6697 | nss_chains_cfg->num_tx_chains[band] = tx_chains; |
| 6698 | |
gaurank kathpalia | b414bce | 2018-11-09 18:44:46 +0530 | [diff] [blame] | 6699 | dynamic_cfg = ucfg_mlme_get_dynamic_vdev_config(vdev); |
gaurank kathpalia | 7cb6a32 | 2018-10-24 19:50:34 +0530 | [diff] [blame] | 6700 | if (!dynamic_cfg) { |
| 6701 | hdd_err("nss chain dynamic config NULL"); |
| 6702 | return QDF_STATUS_E_FAILURE; |
| 6703 | } |
| 6704 | /* |
| 6705 | * If user gives any nss value, then chains will be adjusted based on |
| 6706 | * nss (in SME func sme_validate_user_nss_chain_params). |
| 6707 | * If Chains are not suitable as per current NSS then, we need to |
| 6708 | * return, and the below logic is added for the same. |
| 6709 | */ |
| 6710 | |
| 6711 | if ((dynamic_cfg->rx_nss[band] > rx_chains) || |
| 6712 | (dynamic_cfg->tx_nss[band] > tx_chains)) { |
| 6713 | hdd_err("Chains less than nss, configure correct nss first."); |
| 6714 | return QDF_STATUS_E_FAILURE; |
| 6715 | } |
| 6716 | |
| 6717 | return QDF_STATUS_SUCCESS; |
| 6718 | } |
| 6719 | |
| 6720 | static int |
| 6721 | hdd_set_dynamic_antenna_mode(struct hdd_adapter *adapter, |
| 6722 | uint8_t num_rx_chains, |
| 6723 | uint8_t num_tx_chains) |
| 6724 | { |
| 6725 | enum nss_chains_band_info band; |
| 6726 | struct wlan_mlme_nss_chains user_cfg; |
| 6727 | QDF_STATUS status; |
| 6728 | mac_handle_t mac_handle; |
| 6729 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6730 | |
| 6731 | mac_handle = hdd_ctx->mac_handle; |
| 6732 | if (!mac_handle) { |
| 6733 | hdd_err("NULL MAC handle"); |
| 6734 | return -EINVAL; |
| 6735 | } |
| 6736 | |
gaurank kathpalia | 6982d47 | 2018-10-31 21:54:15 +0530 | [diff] [blame] | 6737 | if (!hdd_is_vdev_in_conn_state(adapter)) { |
| 6738 | 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] | 6739 | adapter->vdev_id); |
gaurank kathpalia | 6982d47 | 2018-10-31 21:54:15 +0530 | [diff] [blame] | 6740 | return -EINVAL; |
| 6741 | } |
| 6742 | |
gaurank kathpalia | 7cb6a32 | 2018-10-24 19:50:34 +0530 | [diff] [blame] | 6743 | qdf_mem_zero(&user_cfg, sizeof(user_cfg)); |
gaurank kathpalia | b414bce | 2018-11-09 18:44:46 +0530 | [diff] [blame] | 6744 | for (band = NSS_CHAINS_BAND_2GHZ; band < NSS_CHAINS_BAND_MAX; band++) { |
gaurank kathpalia | 7cb6a32 | 2018-10-24 19:50:34 +0530 | [diff] [blame] | 6745 | status = hdd_populate_vdev_chains(&user_cfg, |
| 6746 | num_rx_chains, |
| 6747 | num_tx_chains, band, |
| 6748 | adapter->vdev); |
| 6749 | if (QDF_IS_STATUS_ERROR(status)) |
| 6750 | return -EINVAL; |
| 6751 | } |
| 6752 | status = sme_nss_chains_update(mac_handle, |
| 6753 | &user_cfg, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 6754 | adapter->vdev_id); |
gaurank kathpalia | 7cb6a32 | 2018-10-24 19:50:34 +0530 | [diff] [blame] | 6755 | if (QDF_IS_STATUS_ERROR(status)) |
| 6756 | return -EINVAL; |
| 6757 | |
| 6758 | return 0; |
| 6759 | } |
Abhishek Singh | 1571ca7 | 2018-04-17 15:14:21 +0530 | [diff] [blame] | 6760 | int hdd_set_antenna_mode(struct hdd_adapter *adapter, |
| 6761 | struct hdd_context *hdd_ctx, int mode) |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6762 | { |
| 6763 | struct sir_antenna_mode_param params; |
| 6764 | QDF_STATUS status; |
| 6765 | int ret = 0; |
Dundi Raviteja | 6bb9e32 | 2018-05-16 17:04:41 +0530 | [diff] [blame] | 6766 | struct osif_request *request = NULL; |
| 6767 | static const struct osif_request_params request_params = { |
| 6768 | .priv_size = 0, |
Abhishek Singh | d1f21c7 | 2019-01-21 15:16:34 +0530 | [diff] [blame] | 6769 | .timeout_ms = SME_POLICY_MGR_CMD_TIMEOUT, |
Dundi Raviteja | 6bb9e32 | 2018-05-16 17:04:41 +0530 | [diff] [blame] | 6770 | }; |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6771 | |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6772 | switch (mode) { |
| 6773 | case HDD_ANTENNA_MODE_1X1: |
| 6774 | params.num_rx_chains = 1; |
| 6775 | params.num_tx_chains = 1; |
| 6776 | break; |
| 6777 | case HDD_ANTENNA_MODE_2X2: |
| 6778 | params.num_rx_chains = 2; |
| 6779 | params.num_tx_chains = 2; |
| 6780 | break; |
| 6781 | default: |
| 6782 | hdd_err("unsupported antenna mode"); |
| 6783 | ret = -EINVAL; |
| 6784 | goto exit; |
| 6785 | } |
| 6786 | |
gaurank kathpalia | 1281b30 | 2018-11-05 21:10:37 +0530 | [diff] [blame] | 6787 | if (hdd_ctx->dynamic_nss_chains_support) |
gaurank kathpalia | 7cb6a32 | 2018-10-24 19:50:34 +0530 | [diff] [blame] | 6788 | return hdd_set_dynamic_antenna_mode(adapter, |
| 6789 | params.num_rx_chains, |
| 6790 | params.num_tx_chains); |
gaurank kathpalia | 7cb6a32 | 2018-10-24 19:50:34 +0530 | [diff] [blame] | 6791 | |
gaurank kathpalia | f95ae68 | 2018-11-05 21:13:07 +0530 | [diff] [blame] | 6792 | if ((HDD_ANTENNA_MODE_2X2 == mode) && |
| 6793 | (!hdd_is_supported_chain_mask_2x2(hdd_ctx))) { |
| 6794 | hdd_err("System does not support 2x2 mode"); |
| 6795 | ret = -EPERM; |
| 6796 | goto exit; |
| 6797 | } |
| 6798 | |
| 6799 | if ((HDD_ANTENNA_MODE_1X1 == mode) && |
| 6800 | hdd_is_supported_chain_mask_1x1(hdd_ctx)) { |
| 6801 | hdd_err("System only supports 1x1 mode"); |
| 6802 | goto exit; |
| 6803 | } |
| 6804 | |
Archana Ramachandran | d5d2e92 | 2016-04-20 16:57:35 -0700 | [diff] [blame] | 6805 | /* Check TDLS status and update antenna mode */ |
| 6806 | if ((QDF_STA_MODE == adapter->device_mode) && |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 6807 | policy_mgr_is_sta_active_connection_exists(hdd_ctx->psoc)) { |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6808 | ret = wlan_hdd_tdls_antenna_switch(hdd_ctx, adapter, mode); |
Archana Ramachandran | d5d2e92 | 2016-04-20 16:57:35 -0700 | [diff] [blame] | 6809 | if (0 != ret) |
| 6810 | goto exit; |
| 6811 | } |
| 6812 | |
Dundi Raviteja | 6bb9e32 | 2018-05-16 17:04:41 +0530 | [diff] [blame] | 6813 | request = osif_request_alloc(&request_params); |
| 6814 | if (!request) { |
| 6815 | hdd_err("Request Allocation Failure"); |
| 6816 | ret = -ENOMEM; |
| 6817 | goto exit; |
| 6818 | } |
| 6819 | |
| 6820 | params.set_antenna_mode_ctx = osif_request_cookie(request); |
| 6821 | 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] | 6822 | hdd_debug("Set antenna mode rx chains: %d tx chains: %d", |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6823 | params.num_rx_chains, |
| 6824 | params.num_tx_chains); |
| 6825 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6826 | status = sme_soc_set_antenna_mode(hdd_ctx->mac_handle, ¶ms); |
Abhishek Singh | 1571ca7 | 2018-04-17 15:14:21 +0530 | [diff] [blame] | 6827 | if (QDF_IS_STATUS_ERROR(status)) { |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6828 | hdd_err("set antenna mode failed status : %d", status); |
| 6829 | ret = -EFAULT; |
Dundi Raviteja | 6bb9e32 | 2018-05-16 17:04:41 +0530 | [diff] [blame] | 6830 | goto request_put; |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6831 | } |
| 6832 | |
Dundi Raviteja | 6bb9e32 | 2018-05-16 17:04:41 +0530 | [diff] [blame] | 6833 | ret = osif_request_wait_for_response(request); |
| 6834 | if (ret) { |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6835 | hdd_err("send set antenna mode timed out"); |
Dundi Raviteja | 6bb9e32 | 2018-05-16 17:04:41 +0530 | [diff] [blame] | 6836 | goto request_put; |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6837 | } |
| 6838 | |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 6839 | status = hdd_update_smps_antenna_mode(hdd_ctx, mode); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6840 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6841 | ret = -EFAULT; |
Dundi Raviteja | 6bb9e32 | 2018-05-16 17:04:41 +0530 | [diff] [blame] | 6842 | goto request_put; |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6843 | } |
Archana Ramachandran | 5041b25 | 2016-04-25 14:29:25 -0700 | [diff] [blame] | 6844 | ret = 0; |
Dundi Raviteja | 6bb9e32 | 2018-05-16 17:04:41 +0530 | [diff] [blame] | 6845 | request_put: |
| 6846 | osif_request_put(request); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6847 | exit: |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 6848 | hdd_debug("Set antenna status: %d current mode: %d", |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6849 | ret, hdd_ctx->current_antenna_mode); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6850 | |
Abhishek Singh | 1571ca7 | 2018-04-17 15:14:21 +0530 | [diff] [blame] | 6851 | return ret; |
| 6852 | } |
gaurank kathpalia | b414bce | 2018-11-09 18:44:46 +0530 | [diff] [blame] | 6853 | |
Abhishek Singh | 1571ca7 | 2018-04-17 15:14:21 +0530 | [diff] [blame] | 6854 | /** |
| 6855 | * drv_cmd_set_antenna_mode() - SET ANTENNA MODE driver command |
| 6856 | * handler |
| 6857 | * @adapter: Pointer to network adapter |
| 6858 | * @hdd_ctx: Pointer to hdd context |
| 6859 | * @command: Pointer to input command |
| 6860 | * @command_len: Command length |
| 6861 | * @priv_data: Pointer to private data in command |
| 6862 | */ |
| 6863 | static int drv_cmd_set_antenna_mode(struct hdd_adapter *adapter, |
| 6864 | struct hdd_context *hdd_ctx, |
| 6865 | uint8_t *command, |
| 6866 | uint8_t command_len, |
| 6867 | struct hdd_priv_data *priv_data) |
| 6868 | { |
| 6869 | int mode; |
| 6870 | uint8_t *value = command; |
| 6871 | |
| 6872 | mode = hdd_parse_setantennamode_command(value); |
| 6873 | if (mode < 0) { |
| 6874 | hdd_err("Invalid SETANTENNA command"); |
| 6875 | return mode; |
| 6876 | } |
| 6877 | |
| 6878 | hdd_debug("Processing antenna mode switch to: %d", mode); |
| 6879 | |
| 6880 | return hdd_set_antenna_mode(adapter, hdd_ctx, mode); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6881 | } |
| 6882 | |
| 6883 | /** |
gaurank kathpalia | 2472fb9 | 2018-10-31 17:40:18 +0530 | [diff] [blame] | 6884 | * hdd_get_dynamic_antenna_mode() -get the dynamic antenna mode for vdev |
| 6885 | * @antenna_mode: pointer to antenna mode of vdev |
| 6886 | * @dynamic_nss_chains_support: feature support for dynamic nss chains update |
| 6887 | * @vdev: Pointer to vdev |
| 6888 | * |
| 6889 | * This API will check for the num of chains configured for the vdev, and fill |
| 6890 | * that info in the antenna mode if the dynamic chains per vdev are supported. |
| 6891 | * |
| 6892 | * Return: None |
| 6893 | */ |
| 6894 | static void |
| 6895 | hdd_get_dynamic_antenna_mode(uint32_t *antenna_mode, |
| 6896 | bool dynamic_nss_chains_support, |
| 6897 | struct wlan_objmgr_vdev *vdev) |
| 6898 | { |
| 6899 | struct wlan_mlme_nss_chains *nss_chains_dynamic_cfg; |
| 6900 | |
| 6901 | if (!dynamic_nss_chains_support) |
| 6902 | return; |
| 6903 | |
gaurank kathpalia | b414bce | 2018-11-09 18:44:46 +0530 | [diff] [blame] | 6904 | nss_chains_dynamic_cfg = ucfg_mlme_get_dynamic_vdev_config(vdev); |
gaurank kathpalia | 2472fb9 | 2018-10-31 17:40:18 +0530 | [diff] [blame] | 6905 | if (!nss_chains_dynamic_cfg) { |
| 6906 | hdd_err("nss chain dynamic config NULL"); |
| 6907 | return; |
| 6908 | } |
| 6909 | /* |
| 6910 | * At present, this command doesn't include band, so by default |
| 6911 | * it will return the band 2ghz present rf chains. |
| 6912 | */ |
gaurank kathpalia | b414bce | 2018-11-09 18:44:46 +0530 | [diff] [blame] | 6913 | *antenna_mode = |
| 6914 | nss_chains_dynamic_cfg->num_rx_chains[NSS_CHAINS_BAND_2GHZ]; |
gaurank kathpalia | 2472fb9 | 2018-10-31 17:40:18 +0530 | [diff] [blame] | 6915 | } |
| 6916 | |
| 6917 | /** |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6918 | * drv_cmd_get_antenna_mode() - GET ANTENNA MODE driver command |
| 6919 | * handler |
| 6920 | * @adapter: Pointer to hdd adapter |
| 6921 | * @hdd_ctx: Pointer to hdd context |
| 6922 | * @command: Pointer to input command |
| 6923 | * @command_len: length of the command |
| 6924 | * @priv_data: private data coming with the driver command |
| 6925 | * |
| 6926 | * Return: 0 for success non-zero for failure |
| 6927 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6928 | static inline int drv_cmd_get_antenna_mode(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6929 | struct hdd_context *hdd_ctx, |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6930 | uint8_t *command, |
| 6931 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6932 | struct hdd_priv_data *priv_data) |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6933 | { |
| 6934 | uint32_t antenna_mode = 0; |
| 6935 | char extra[32]; |
| 6936 | uint8_t len = 0; |
| 6937 | |
| 6938 | antenna_mode = hdd_ctx->current_antenna_mode; |
gaurank kathpalia | 2472fb9 | 2018-10-31 17:40:18 +0530 | [diff] [blame] | 6939 | /* Overwrite this antenna mode if dynamic vdev chains are supported */ |
| 6940 | hdd_get_dynamic_antenna_mode(&antenna_mode, |
| 6941 | hdd_ctx->dynamic_nss_chains_support, |
| 6942 | adapter->vdev); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6943 | len = scnprintf(extra, sizeof(extra), "%s %d", command, |
| 6944 | antenna_mode); |
| 6945 | len = QDF_MIN(priv_data->total_len, len + 1); |
| 6946 | if (copy_to_user(priv_data->buf, &extra, len)) { |
| 6947 | hdd_err("Failed to copy data to user buffer"); |
| 6948 | return -EFAULT; |
| 6949 | } |
| 6950 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 6951 | hdd_debug("Get antenna mode: %d", antenna_mode); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6952 | |
| 6953 | return 0; |
| 6954 | } |
| 6955 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6956 | /* |
| 6957 | * dummy (no-op) hdd driver command handler |
| 6958 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6959 | static int drv_cmd_dummy(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6960 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6961 | uint8_t *command, |
| 6962 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6963 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6964 | { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 6965 | hdd_debug("%s: Ignoring driver command \"%s\"", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6966 | adapter->dev->name, command); |
| 6967 | return 0; |
| 6968 | } |
| 6969 | |
| 6970 | /* |
| 6971 | * handler for any unsupported wlan hdd driver command |
| 6972 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6973 | static int drv_cmd_invalid(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6974 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6975 | uint8_t *command, |
| 6976 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6977 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6978 | { |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 6979 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 6980 | TRACE_CODE_HDD_UNSUPPORTED_IOCTL, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 6981 | adapter->vdev_id, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6982 | |
| 6983 | hdd_warn("%s: Unsupported driver command \"%s\"", |
| 6984 | adapter->dev->name, command); |
| 6985 | |
| 6986 | return -ENOTSUPP; |
| 6987 | } |
| 6988 | |
| 6989 | /** |
Rajeev Kumar Sirasanagandla | 1a21bf6 | 2019-04-08 15:28:57 +0530 | [diff] [blame] | 6990 | * drv_cmd_set_fcc_channel() - Handle fcc constraint request |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6991 | * @adapter: HDD adapter |
| 6992 | * @hdd_ctx: HDD context |
Rajeev Kumar Sirasanagandla | 1a21bf6 | 2019-04-08 15:28:57 +0530 | [diff] [blame] | 6993 | * @command: command ptr, SET_FCC_CHANNEL 0/-1 is the command |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6994 | * @command_len: command len |
| 6995 | * @priv_data: private data |
| 6996 | * |
| 6997 | * Return: status |
| 6998 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6999 | static int drv_cmd_set_fcc_channel(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 7000 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7001 | uint8_t *command, |
| 7002 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 7003 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7004 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7005 | QDF_STATUS status; |
Rajeev Kumar Sirasanagandla | 1a21bf6 | 2019-04-08 15:28:57 +0530 | [diff] [blame] | 7006 | int8_t input_value; |
| 7007 | bool fcc_constraint; |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 7008 | int err; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7009 | |
| 7010 | /* |
Rajeev Kumar Sirasanagandla | 1a21bf6 | 2019-04-08 15:28:57 +0530 | [diff] [blame] | 7011 | * This command would be called by user-space when it detects WLAN |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7012 | * ON after airplane mode is set. When APM is set, WLAN turns off. |
| 7013 | * But it can be turned back on. Otherwise; when APM is turned back |
| 7014 | * 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] | 7015 | * expected to come down. 0 means reduce power as per fcc constraint |
| 7016 | * and -1 means remove constraint. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7017 | */ |
| 7018 | |
Rajeev Kumar Sirasanagandla | 1a21bf6 | 2019-04-08 15:28:57 +0530 | [diff] [blame] | 7019 | err = kstrtos8(command + command_len + 1, 10, &input_value); |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 7020 | if (err) { |
| 7021 | hdd_err("error %d parsing userspace fcc parameter", err); |
| 7022 | return err; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7023 | } |
| 7024 | |
Rajeev Kumar Sirasanagandla | 1a21bf6 | 2019-04-08 15:28:57 +0530 | [diff] [blame] | 7025 | fcc_constraint = input_value ? false : true; |
| 7026 | hdd_debug("input_value = %d && fcc_constraint = %u", |
| 7027 | input_value, fcc_constraint); |
| 7028 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 7029 | status = ucfg_reg_set_fcc_constraint(hdd_ctx->pdev, fcc_constraint); |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 7030 | |
| 7031 | if (QDF_IS_STATUS_ERROR(status)) |
| 7032 | hdd_err("Failed to %s tx power for channels 12/13", |
Rajeev Kumar Sirasanagandla | 1a21bf6 | 2019-04-08 15:28:57 +0530 | [diff] [blame] | 7033 | fcc_constraint ? "restore" : "reduce"); |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 7034 | |
| 7035 | return qdf_status_to_os_return(status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7036 | } |
| 7037 | |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 7038 | /** |
| 7039 | * hdd_parse_set_channel_switch_command() - Parse and validate CHANNEL_SWITCH |
| 7040 | * command |
| 7041 | * @value: Pointer to the command |
| 7042 | * @chan_number: Pointer to the channel number |
| 7043 | * @chan_bw: Pointer to the channel bandwidth |
| 7044 | * |
| 7045 | * Parses and provides the channel number and channel width from the input |
| 7046 | * command which is expected to be of the format: CHANNEL_SWITCH <CH> <BW> |
| 7047 | * <CH> is channel number to move (where 1 = channel 1, 149 = channel 149, ...) |
| 7048 | * <BW> is bandwidth to move (where 20 = BW 20, 40 = BW 40, 80 = BW 80) |
| 7049 | * |
| 7050 | * Return: 0 for success, non-zero for failure |
| 7051 | */ |
| 7052 | static int hdd_parse_set_channel_switch_command(uint8_t *value, |
| 7053 | uint32_t *chan_number, |
| 7054 | uint32_t *chan_bw) |
| 7055 | { |
| 7056 | const uint8_t *in_ptr = value; |
| 7057 | int ret; |
| 7058 | |
| 7059 | in_ptr = strnchr(value, strlen(value), SPACE_ASCII_VALUE); |
| 7060 | |
| 7061 | /* no argument after the command */ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 7062 | if (!in_ptr) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 7063 | hdd_err("No argument after the command"); |
| 7064 | return -EINVAL; |
| 7065 | } |
| 7066 | |
| 7067 | /* no space after the command */ |
| 7068 | if (SPACE_ASCII_VALUE != *in_ptr) { |
| 7069 | hdd_err("No space after the command "); |
| 7070 | return -EINVAL; |
| 7071 | } |
| 7072 | |
| 7073 | /* remove empty spaces and move the next argument */ |
| 7074 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 7075 | in_ptr++; |
| 7076 | |
| 7077 | /* no argument followed by spaces */ |
| 7078 | if ('\0' == *in_ptr) { |
| 7079 | hdd_err("No argument followed by spaces"); |
| 7080 | return -EINVAL; |
| 7081 | } |
| 7082 | |
| 7083 | /* get the two arguments: channel number and bandwidth */ |
| 7084 | ret = sscanf(in_ptr, "%u %u", chan_number, chan_bw); |
| 7085 | if (ret != 2) { |
| 7086 | hdd_err("Arguments retrieval from cmd string failed"); |
| 7087 | return -EINVAL; |
| 7088 | } |
| 7089 | |
| 7090 | return 0; |
| 7091 | } |
| 7092 | |
| 7093 | /** |
| 7094 | * drv_cmd_set_channel_switch() - Switch SAP/P2P-GO operating channel |
| 7095 | * @adapter: HDD adapter |
| 7096 | * @hdd_ctx: HDD context |
| 7097 | * @command: Pointer to the input command CHANNEL_SWITCH |
| 7098 | * @command_len: Command len |
| 7099 | * @priv_data: Private data |
| 7100 | * |
| 7101 | * Handles private IOCTL CHANNEL_SWITCH command to switch the operating channel |
| 7102 | * of SAP/P2P-GO |
| 7103 | * |
| 7104 | * Return: 0 for success, non-zero for failure |
| 7105 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 7106 | static int drv_cmd_set_channel_switch(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 7107 | struct hdd_context *hdd_ctx, |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 7108 | uint8_t *command, |
| 7109 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 7110 | struct hdd_priv_data *priv_data) |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 7111 | { |
| 7112 | struct net_device *dev = adapter->dev; |
| 7113 | int status; |
| 7114 | uint32_t chan_number = 0, chan_bw = 0; |
| 7115 | uint8_t *value = command; |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 7116 | enum phy_ch_width width; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 7117 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 7118 | if ((adapter->device_mode != QDF_P2P_GO_MODE) && |
| 7119 | (adapter->device_mode != QDF_SAP_MODE)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 7120 | hdd_err("IOCTL CHANNEL_SWITCH not supported for mode %d", |
| 7121 | adapter->device_mode); |
| 7122 | return -EINVAL; |
| 7123 | } |
| 7124 | |
| 7125 | status = hdd_parse_set_channel_switch_command(value, |
| 7126 | &chan_number, &chan_bw); |
| 7127 | if (status) { |
| 7128 | hdd_err("Invalid CHANNEL_SWITCH command"); |
| 7129 | return status; |
| 7130 | } |
| 7131 | |
| 7132 | if ((chan_bw != 20) && (chan_bw != 40) && (chan_bw != 80)) { |
| 7133 | hdd_err("BW %d is not allowed for CHANNEL_SWITCH", chan_bw); |
| 7134 | return -EINVAL; |
| 7135 | } |
| 7136 | |
| 7137 | if (chan_bw == 80) |
| 7138 | width = CH_WIDTH_80MHZ; |
| 7139 | else if (chan_bw == 40) |
| 7140 | width = CH_WIDTH_40MHZ; |
| 7141 | else |
| 7142 | width = CH_WIDTH_20MHZ; |
| 7143 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 7144 | hdd_debug("CH:%d BW:%d", chan_number, chan_bw); |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 7145 | |
Bala Venkatesh | 8b9bbde | 2019-07-03 16:25:16 +0530 | [diff] [blame] | 7146 | wlan_hdd_set_sap_csa_reason(hdd_ctx->psoc, adapter->vdev_id, |
| 7147 | CSA_REASON_USER_INITIATED); |
Tushnim Bhattacharyya | 6c40b11 | 2019-10-30 11:39:25 -0700 | [diff] [blame] | 7148 | status = hdd_softap_set_channel_change(dev, |
| 7149 | wlan_reg_legacy_chan_to_freq(hdd_ctx->pdev, chan_number), |
| 7150 | width, true); |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 7151 | if (status) { |
| 7152 | hdd_err("Set channel change fail"); |
| 7153 | return status; |
| 7154 | } |
| 7155 | |
| 7156 | return 0; |
| 7157 | } |
| 7158 | |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7159 | #ifdef DISABLE_CHANNEL_LIST |
| 7160 | void wlan_hdd_free_cache_channels(struct hdd_context *hdd_ctx) |
| 7161 | { |
| 7162 | hdd_enter(); |
| 7163 | |
| 7164 | if (!hdd_ctx->original_channels) |
| 7165 | return; |
| 7166 | |
| 7167 | qdf_mutex_acquire(&hdd_ctx->cache_channel_lock); |
| 7168 | hdd_ctx->original_channels->num_channels = 0; |
| 7169 | if (hdd_ctx->original_channels->channel_info) { |
| 7170 | qdf_mem_free(hdd_ctx->original_channels->channel_info); |
| 7171 | hdd_ctx->original_channels->channel_info = NULL; |
| 7172 | } |
| 7173 | qdf_mem_free(hdd_ctx->original_channels); |
| 7174 | hdd_ctx->original_channels = NULL; |
| 7175 | qdf_mutex_release(&hdd_ctx->cache_channel_lock); |
| 7176 | |
| 7177 | hdd_exit(); |
| 7178 | } |
| 7179 | |
| 7180 | /** |
| 7181 | * hdd_alloc_chan_cache() - Allocate the memory to cache the channel |
| 7182 | * info for the channels received in command SET_DISABLE_CHANNEL_LIST |
| 7183 | * @hdd_ctx: Pointer to HDD context |
| 7184 | * @num_chan: Number of channels for which memory needs to |
| 7185 | * be allocated |
| 7186 | * |
| 7187 | * Return: 0 on success and error code on failure |
| 7188 | */ |
| 7189 | static int hdd_alloc_chan_cache(struct hdd_context *hdd_ctx, int num_chan) |
| 7190 | { |
| 7191 | hdd_ctx->original_channels = |
| 7192 | qdf_mem_malloc(sizeof(struct hdd_cache_channels)); |
| 7193 | if (!hdd_ctx->original_channels) { |
| 7194 | hdd_err("QDF_MALLOC_ERR"); |
| 7195 | return -ENOMEM; |
| 7196 | } |
| 7197 | hdd_ctx->original_channels->num_channels = num_chan; |
| 7198 | hdd_ctx->original_channels->channel_info = |
| 7199 | qdf_mem_malloc(num_chan * |
| 7200 | sizeof(struct hdd_cache_channel_info)); |
| 7201 | if (!hdd_ctx->original_channels->channel_info) { |
| 7202 | hdd_err("QDF_MALLOC_ERR"); |
| 7203 | hdd_ctx->original_channels->num_channels = 0; |
| 7204 | qdf_mem_free(hdd_ctx->original_channels); |
| 7205 | hdd_ctx->original_channels = NULL; |
| 7206 | return -ENOMEM; |
| 7207 | } |
| 7208 | return 0; |
| 7209 | } |
| 7210 | |
| 7211 | /** |
Ashish Kumar Dhanotiya | d63d686 | 2019-03-14 18:54:10 +0530 | [diff] [blame] | 7212 | * check_disable_channels() - Check for disable channel |
| 7213 | * @hdd_ctx: Pointer to hdd context |
| 7214 | * @operating_channel: Current operating channel of adapter |
| 7215 | * |
| 7216 | * This function checks original_channels array for a specific channel |
| 7217 | * |
| 7218 | * Return: 0 if channel not found, 1 if channel found |
| 7219 | */ |
| 7220 | static bool check_disable_channels(struct hdd_context *hdd_ctx, |
| 7221 | uint8_t operating_channel) |
| 7222 | { |
| 7223 | uint32_t num_channels; |
| 7224 | uint8_t i; |
| 7225 | |
| 7226 | if (!hdd_ctx || !hdd_ctx->original_channels || |
| 7227 | !hdd_ctx->original_channels->channel_info) |
| 7228 | return false; |
| 7229 | |
| 7230 | num_channels = hdd_ctx->original_channels->num_channels; |
| 7231 | for (i = 0; i < num_channels; i++) |
| 7232 | if (hdd_ctx->original_channels->channel_info[i].channel_num == |
| 7233 | operating_channel) |
| 7234 | return true; |
| 7235 | return false; |
| 7236 | } |
| 7237 | |
| 7238 | /** |
| 7239 | * disconnect_sta_and_stop_sap() - Disconnect STA and stop SAP |
| 7240 | * |
| 7241 | * @hdd_ctx: Pointer to hdd context |
| 7242 | * |
| 7243 | * Disable channels provided by user and disconnect STA if it is |
| 7244 | * connected to any AP, stop SAP and send deauthentication request |
| 7245 | * to STAs connected to SAP. |
| 7246 | * |
| 7247 | * Return: None |
| 7248 | */ |
| 7249 | static void disconnect_sta_and_stop_sap(struct hdd_context *hdd_ctx) |
| 7250 | { |
| 7251 | struct hdd_adapter *adapter, *next = NULL; |
| 7252 | QDF_STATUS status; |
Will Huang | 4b097f5 | 2019-08-29 10:51:56 -0700 | [diff] [blame] | 7253 | uint8_t ap_ch; |
Ashish Kumar Dhanotiya | d63d686 | 2019-03-14 18:54:10 +0530 | [diff] [blame] | 7254 | |
| 7255 | if (!hdd_ctx) |
| 7256 | return; |
| 7257 | |
| 7258 | hdd_check_and_disconnect_sta_on_invalid_channel(hdd_ctx); |
| 7259 | |
| 7260 | status = hdd_get_front_adapter(hdd_ctx, &adapter); |
| 7261 | while (adapter && (status == QDF_STATUS_SUCCESS)) { |
| 7262 | if (!hdd_validate_adapter(adapter) && |
Will Huang | 4b097f5 | 2019-08-29 10:51:56 -0700 | [diff] [blame] | 7263 | adapter->device_mode == QDF_SAP_MODE) { |
| 7264 | ap_ch = wlan_reg_freq_to_chan( |
| 7265 | hdd_ctx->pdev, |
| 7266 | adapter->session.ap.operating_chan_freq); |
| 7267 | if (check_disable_channels(hdd_ctx, ap_ch)) |
| 7268 | wlan_hdd_stop_sap(adapter); |
| 7269 | } |
Ashish Kumar Dhanotiya | d63d686 | 2019-03-14 18:54:10 +0530 | [diff] [blame] | 7270 | |
| 7271 | status = hdd_get_next_adapter(hdd_ctx, adapter, &next); |
| 7272 | adapter = next; |
| 7273 | } |
| 7274 | } |
| 7275 | |
| 7276 | /** |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7277 | * hdd_parse_disable_chan_cmd() - Parse the channel list received |
| 7278 | * in command. |
| 7279 | * @adapter: pointer to hdd adapter |
| 7280 | * @ptr: Pointer to the command string |
| 7281 | * |
| 7282 | * This function parses the channel list received in the command. |
| 7283 | * command should be a string having format |
| 7284 | * SET_DISABLE_CHANNEL_LIST <num of channels> |
| 7285 | * <channels separated by spaces>. |
| 7286 | * If the command comes multiple times than this function will compare |
| 7287 | * the channels received in the command with the channles cached in the |
| 7288 | * first command, if the channel list matches with the cached channles, |
| 7289 | * it returns success otherwise returns failure. |
| 7290 | * |
| 7291 | * Return: 0 on success, Error code on failure |
| 7292 | */ |
| 7293 | |
| 7294 | static int hdd_parse_disable_chan_cmd(struct hdd_adapter *adapter, uint8_t *ptr) |
| 7295 | { |
| 7296 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7297 | uint8_t *param; |
| 7298 | int j, i, temp_int, ret = 0, num_channels; |
Liangwei Dong | 2eb654f | 2019-09-11 15:54:09 +0800 | [diff] [blame] | 7299 | uint32_t parsed_channels[NUM_CHANNELS]; |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7300 | bool is_command_repeated = false; |
| 7301 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 7302 | if (!hdd_ctx) { |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7303 | hdd_err("HDD Context is NULL"); |
| 7304 | return -EINVAL; |
| 7305 | } |
| 7306 | |
| 7307 | param = strnchr(ptr, strlen(ptr), ' '); |
| 7308 | /*no argument after the command*/ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 7309 | if (!param) |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7310 | return -EINVAL; |
| 7311 | |
| 7312 | /*no space after the command*/ |
| 7313 | else if (SPACE_ASCII_VALUE != *param) |
| 7314 | return -EINVAL; |
| 7315 | |
| 7316 | param++; |
| 7317 | |
| 7318 | /*removing empty spaces*/ |
| 7319 | while ((SPACE_ASCII_VALUE == *param) && ('\0' != *param)) |
| 7320 | param++; |
| 7321 | |
| 7322 | /*no argument followed by spaces*/ |
| 7323 | if ('\0' == *param) |
| 7324 | return -EINVAL; |
| 7325 | |
| 7326 | /*getting the first argument ie the number of channels*/ |
| 7327 | if (sscanf(param, "%d ", &temp_int) != 1) { |
| 7328 | hdd_err("Cannot get number of channels from input"); |
| 7329 | return -EINVAL; |
| 7330 | } |
| 7331 | |
Liangwei Dong | 2eb654f | 2019-09-11 15:54:09 +0800 | [diff] [blame] | 7332 | if (temp_int < 0 || temp_int > NUM_CHANNELS) { |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7333 | hdd_err("Invalid Number of channel received"); |
| 7334 | return -EINVAL; |
| 7335 | } |
| 7336 | |
| 7337 | hdd_debug("Number of channel to disable are: %d", temp_int); |
| 7338 | |
| 7339 | if (!temp_int) { |
Ashish Kumar Dhanotiya | 6176bef | 2019-07-25 15:51:35 +0530 | [diff] [blame] | 7340 | /* |
| 7341 | * Restore and Free the cache channels when the command is |
| 7342 | * received with num channels as 0 |
| 7343 | */ |
| 7344 | wlan_hdd_restore_channels(hdd_ctx, false); |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7345 | return 0; |
| 7346 | } |
| 7347 | |
| 7348 | qdf_mutex_acquire(&hdd_ctx->cache_channel_lock); |
| 7349 | |
| 7350 | if (!hdd_ctx->original_channels) { |
| 7351 | if (hdd_alloc_chan_cache(hdd_ctx, temp_int)) { |
| 7352 | ret = -ENOMEM; |
| 7353 | goto mem_alloc_failed; |
| 7354 | } |
| 7355 | } else if (hdd_ctx->original_channels->num_channels != temp_int) { |
| 7356 | hdd_err("Invalid Number of channels"); |
| 7357 | ret = -EINVAL; |
| 7358 | is_command_repeated = true; |
| 7359 | goto parse_failed; |
| 7360 | } else { |
| 7361 | is_command_repeated = true; |
| 7362 | } |
| 7363 | num_channels = temp_int; |
| 7364 | for (j = 0; j < num_channels; j++) { |
| 7365 | /* |
| 7366 | * param pointing to the beginning of first space |
| 7367 | * after number of channels |
| 7368 | */ |
| 7369 | param = strpbrk(param, " "); |
| 7370 | /*no channel list after the number of channels argument*/ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 7371 | if (!param) { |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7372 | hdd_err("Invalid No of channel provided in the list"); |
| 7373 | ret = -EINVAL; |
| 7374 | goto parse_failed; |
| 7375 | } |
| 7376 | |
| 7377 | param++; |
| 7378 | |
| 7379 | /*removing empty space*/ |
| 7380 | while ((SPACE_ASCII_VALUE == *param) && ('\0' != *param)) |
| 7381 | param++; |
| 7382 | |
| 7383 | if ('\0' == *param) { |
| 7384 | hdd_err("No channel is provided in the list"); |
| 7385 | ret = -EINVAL; |
| 7386 | goto parse_failed; |
| 7387 | } |
| 7388 | |
| 7389 | if (sscanf(param, "%d ", &temp_int) != 1) { |
| 7390 | hdd_err("Cannot read channel number"); |
| 7391 | ret = -EINVAL; |
| 7392 | goto parse_failed; |
| 7393 | } |
| 7394 | |
| 7395 | if (!IS_CHANNEL_VALID(temp_int)) { |
| 7396 | hdd_err("Invalid channel number received"); |
| 7397 | ret = -EINVAL; |
| 7398 | goto parse_failed; |
| 7399 | } |
| 7400 | |
| 7401 | hdd_debug("channel[%d] = %d", j, temp_int); |
| 7402 | parsed_channels[j] = temp_int; |
| 7403 | } |
| 7404 | |
| 7405 | /*extra arguments check*/ |
| 7406 | param = strpbrk(param, " "); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 7407 | if (param) { |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7408 | while ((SPACE_ASCII_VALUE == *param) && ('\0' != *param)) |
| 7409 | param++; |
| 7410 | |
| 7411 | if ('\0' != *param) { |
| 7412 | hdd_err("Invalid argument received"); |
| 7413 | ret = -EINVAL; |
| 7414 | goto parse_failed; |
| 7415 | } |
| 7416 | } |
| 7417 | |
| 7418 | /* |
| 7419 | * If command is received first time, cache the channels to |
| 7420 | * be disabled else compare the channels received in the |
| 7421 | * command with the cached channels, if channel list matches |
| 7422 | * return success otherewise return failure. |
| 7423 | */ |
| 7424 | if (!is_command_repeated) { |
| 7425 | for (j = 0; j < num_channels; j++) |
| 7426 | hdd_ctx->original_channels-> |
| 7427 | channel_info[j].channel_num = |
| 7428 | parsed_channels[j]; |
Dustin Brown | 3f0d710 | 2018-08-02 12:01:52 -0700 | [diff] [blame] | 7429 | |
| 7430 | /* Cache the channel list in regulatory also */ |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 7431 | ucfg_reg_cache_channel_state(hdd_ctx->pdev, parsed_channels, |
Dustin Brown | 3f0d710 | 2018-08-02 12:01:52 -0700 | [diff] [blame] | 7432 | num_channels); |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7433 | } else { |
| 7434 | for (i = 0; i < num_channels; i++) { |
| 7435 | for (j = 0; j < num_channels; j++) |
| 7436 | if (hdd_ctx->original_channels-> |
| 7437 | channel_info[i].channel_num == |
| 7438 | parsed_channels[j]) |
| 7439 | break; |
| 7440 | if (j == num_channels) { |
| 7441 | ret = -EINVAL; |
| 7442 | goto parse_failed; |
| 7443 | } |
| 7444 | } |
| 7445 | ret = 0; |
| 7446 | } |
| 7447 | mem_alloc_failed: |
| 7448 | |
| 7449 | qdf_mutex_release(&hdd_ctx->cache_channel_lock); |
Ashish Kumar Dhanotiya | dd5f74c | 2019-03-14 16:50:41 +0530 | [diff] [blame] | 7450 | /* Disable the channels received in command SET_DISABLE_CHANNEL_LIST */ |
| 7451 | if (!is_command_repeated && hdd_ctx->original_channels) { |
Ashish Kumar Dhanotiya | d63d686 | 2019-03-14 18:54:10 +0530 | [diff] [blame] | 7452 | ret = wlan_hdd_disable_channels(hdd_ctx); |
| 7453 | if (ret) |
| 7454 | return ret; |
| 7455 | disconnect_sta_and_stop_sap(hdd_ctx); |
Ashish Kumar Dhanotiya | dd5f74c | 2019-03-14 16:50:41 +0530 | [diff] [blame] | 7456 | } |
| 7457 | |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7458 | hdd_exit(); |
| 7459 | |
| 7460 | return ret; |
| 7461 | |
| 7462 | parse_failed: |
| 7463 | if (!is_command_repeated) |
| 7464 | wlan_hdd_free_cache_channels(hdd_ctx); |
Ashish Kumar Dhanotiya | dd5f74c | 2019-03-14 16:50:41 +0530 | [diff] [blame] | 7465 | |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7466 | qdf_mutex_release(&hdd_ctx->cache_channel_lock); |
| 7467 | hdd_exit(); |
| 7468 | |
| 7469 | return ret; |
| 7470 | } |
| 7471 | |
| 7472 | static int drv_cmd_set_disable_chan_list(struct hdd_adapter *adapter, |
| 7473 | struct hdd_context *hdd_ctx, |
| 7474 | uint8_t *command, |
| 7475 | uint8_t command_len, |
| 7476 | struct hdd_priv_data *priv_data) |
| 7477 | { |
| 7478 | return hdd_parse_disable_chan_cmd(adapter, command); |
| 7479 | } |
Ashish Kumar Dhanotiya | 2853ba0 | 2018-03-15 15:51:25 +0530 | [diff] [blame] | 7480 | |
| 7481 | /** |
| 7482 | * hdd_get_disable_ch_list() - get disable channel list |
| 7483 | * @hdd_ctx: hdd context |
| 7484 | * @buf: buffer to hold disable channel list |
| 7485 | * @buf_len: buffer length |
| 7486 | * |
| 7487 | * Return: length of data copied to buf |
| 7488 | */ |
| 7489 | static int hdd_get_disable_ch_list(struct hdd_context *hdd_ctx, uint8_t *buf, |
| 7490 | uint32_t buf_len) |
| 7491 | { |
| 7492 | struct hdd_cache_channel_info *ch_list; |
| 7493 | unsigned char i, num_ch; |
| 7494 | int len = 0; |
| 7495 | |
| 7496 | qdf_mutex_acquire(&hdd_ctx->cache_channel_lock); |
| 7497 | if (hdd_ctx->original_channels && |
| 7498 | hdd_ctx->original_channels->num_channels && |
| 7499 | hdd_ctx->original_channels->channel_info) { |
| 7500 | num_ch = hdd_ctx->original_channels->num_channels; |
| 7501 | |
| 7502 | len = scnprintf(buf, buf_len, "%s %hhu", |
| 7503 | "GET_DISABLE_CHANNEL_LIST", num_ch); |
| 7504 | ch_list = hdd_ctx->original_channels->channel_info; |
| 7505 | for (i = 0; (i < num_ch) && (len < buf_len - 1); i++) { |
| 7506 | len += scnprintf(buf + len, buf_len - len, |
| 7507 | " %d", ch_list[i].channel_num); |
| 7508 | } |
| 7509 | } |
| 7510 | qdf_mutex_release(&hdd_ctx->cache_channel_lock); |
| 7511 | |
| 7512 | return len; |
| 7513 | } |
| 7514 | |
| 7515 | static int drv_cmd_get_disable_chan_list(struct hdd_adapter *adapter, |
| 7516 | struct hdd_context *hdd_ctx, |
| 7517 | uint8_t *command, |
| 7518 | uint8_t command_len, |
| 7519 | struct hdd_priv_data *priv_data) |
| 7520 | { |
| 7521 | char extra[512] = {0}; |
| 7522 | int max_len, copied_length; |
| 7523 | |
| 7524 | hdd_debug("Received Command to get disable Channels list"); |
| 7525 | |
| 7526 | max_len = QDF_MIN(priv_data->total_len, sizeof(extra)); |
| 7527 | copied_length = hdd_get_disable_ch_list(hdd_ctx, extra, max_len); |
| 7528 | if (copied_length == 0) { |
| 7529 | hdd_err("disable channel list is not yet programmed"); |
| 7530 | return -EINVAL; |
| 7531 | } |
| 7532 | |
| 7533 | if (copy_to_user(priv_data->buf, &extra, copied_length + 1)) { |
| 7534 | hdd_err("failed to copy data to user buffer"); |
| 7535 | return -EFAULT; |
| 7536 | } |
| 7537 | |
| 7538 | hdd_debug("data:%s", extra); |
| 7539 | return 0; |
| 7540 | } |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7541 | #else |
| 7542 | |
| 7543 | static int drv_cmd_set_disable_chan_list(struct hdd_adapter *adapter, |
| 7544 | struct hdd_context *hdd_ctx, |
| 7545 | uint8_t *command, |
| 7546 | uint8_t command_len, |
| 7547 | struct hdd_priv_data *priv_data) |
| 7548 | { |
| 7549 | return 0; |
| 7550 | } |
| 7551 | |
| 7552 | void wlan_hdd_free_cache_channels(struct hdd_context *hdd_ctx) |
| 7553 | { |
| 7554 | } |
Ashish Kumar Dhanotiya | 2853ba0 | 2018-03-15 15:51:25 +0530 | [diff] [blame] | 7555 | |
| 7556 | static int drv_cmd_get_disable_chan_list(struct hdd_adapter *adapter, |
| 7557 | struct hdd_context *hdd_ctx, |
| 7558 | uint8_t *command, |
| 7559 | uint8_t command_len, |
| 7560 | struct hdd_priv_data *priv_data) |
| 7561 | { |
| 7562 | return 0; |
| 7563 | } |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7564 | #endif |
Sourav Mohapatra | 2a67b0e | 2019-10-15 17:59:59 +0530 | [diff] [blame^] | 7565 | |
| 7566 | #ifdef FEATURE_ANI_LEVEL_REQUEST |
| 7567 | static int drv_cmd_get_ani_level(struct hdd_adapter *adapter, |
| 7568 | struct hdd_context *hdd_ctx, |
| 7569 | uint8_t *command, |
| 7570 | uint8_t command_len, |
| 7571 | struct hdd_priv_data *priv_data) |
| 7572 | { |
| 7573 | char *extra; |
| 7574 | int copied_length = 0, j, temp_int, ret = 0; |
| 7575 | uint8_t *param, num_freqs, num_recv_channels; |
| 7576 | uint32_t parsed_freqs[MAX_NUM_FREQS_FOR_ANI_LEVEL]; |
| 7577 | struct wmi_host_ani_level_event ani[MAX_NUM_FREQS_FOR_ANI_LEVEL]; |
| 7578 | size_t user_size = priv_data->total_len; |
| 7579 | |
| 7580 | hdd_debug("Received Command to get ANI level"); |
| 7581 | |
| 7582 | param = strnchr(command, strlen(command), ' '); |
| 7583 | |
| 7584 | /* No argument after the command */ |
| 7585 | if (!param) |
| 7586 | return -EINVAL; |
| 7587 | |
| 7588 | /* No space after the command */ |
| 7589 | else if (SPACE_ASCII_VALUE != *param) |
| 7590 | return -EINVAL; |
| 7591 | |
| 7592 | param++; |
| 7593 | |
| 7594 | /* Removing empty spaces*/ |
| 7595 | while ((SPACE_ASCII_VALUE == *param) && ('\0' != *param)) |
| 7596 | param++; |
| 7597 | |
| 7598 | /*no argument followed by spaces */ |
| 7599 | if ('\0' == *param) |
| 7600 | return -EINVAL; |
| 7601 | |
| 7602 | /* Getting the first argument ie the number of channels */ |
| 7603 | if (sscanf(param, "%d ", &temp_int) != 1) { |
| 7604 | hdd_err("Cannot get number of freq from input"); |
| 7605 | return -EINVAL; |
| 7606 | } |
| 7607 | |
| 7608 | if (temp_int < 0 || temp_int > MAX_NUM_FREQS_FOR_ANI_LEVEL) { |
| 7609 | hdd_err("Invalid Number of channel received"); |
| 7610 | return -EINVAL; |
| 7611 | } |
| 7612 | |
| 7613 | hdd_debug("Number of freq to fetch ANI level are: %d", temp_int); |
| 7614 | |
| 7615 | if (!temp_int) |
| 7616 | return 0; |
| 7617 | |
| 7618 | num_freqs = temp_int; |
| 7619 | |
| 7620 | for (j = 0; j < num_freqs; j++) { |
| 7621 | /* |
| 7622 | * Param pointing to the beginning of first space |
| 7623 | * after number of channels. |
| 7624 | */ |
| 7625 | param = strpbrk(param, " "); |
| 7626 | /*no channel list after the number of channels argument*/ |
| 7627 | if (!param) { |
| 7628 | hdd_err("Invalid No of freq provided in the list"); |
| 7629 | ret = -EINVAL; |
| 7630 | goto parse_failed; |
| 7631 | } |
| 7632 | |
| 7633 | param++; |
| 7634 | |
| 7635 | /* Removing empty space */ |
| 7636 | while ((SPACE_ASCII_VALUE == *param) && ('\0' != *param)) |
| 7637 | param++; |
| 7638 | |
| 7639 | if ('\0' == *param) { |
| 7640 | hdd_err("No freq is provided in the list"); |
| 7641 | ret = -EINVAL; |
| 7642 | goto parse_failed; |
| 7643 | } |
| 7644 | |
| 7645 | if (sscanf(param, "%d ", &temp_int) != 1) { |
| 7646 | hdd_err("Cannot read freq number"); |
| 7647 | ret = -EINVAL; |
| 7648 | goto parse_failed; |
| 7649 | } |
| 7650 | |
| 7651 | hdd_debug("channel_freq[%d] = %d", j, temp_int); |
| 7652 | parsed_freqs[j] = temp_int; |
| 7653 | } |
| 7654 | |
| 7655 | /* Extra arguments check */ |
| 7656 | param = strpbrk(param, " "); |
| 7657 | if (param) { |
| 7658 | while ((SPACE_ASCII_VALUE == *param) && ('\0' != *param)) |
| 7659 | param++; |
| 7660 | |
| 7661 | if ('\0' != *param) { |
| 7662 | hdd_err("Invalid argument received"); |
| 7663 | ret = -EINVAL; |
| 7664 | goto parse_failed; |
| 7665 | } |
| 7666 | } |
| 7667 | |
| 7668 | qdf_mem_zero(ani, sizeof(ani)); |
| 7669 | hdd_debug("num_freq: %d", num_freqs); |
| 7670 | if (QDF_IS_STATUS_ERROR(wlan_hdd_get_ani_level(adapter, ani, |
| 7671 | parsed_freqs, |
| 7672 | num_freqs))) { |
| 7673 | hdd_err("Unable to retrieve ani level"); |
| 7674 | return -EINVAL; |
| 7675 | } |
| 7676 | |
| 7677 | extra = qdf_mem_malloc(user_size); |
| 7678 | if (!extra) { |
| 7679 | hdd_err("memory allocation failed"); |
| 7680 | ret = -ENOMEM; |
| 7681 | goto parse_failed; |
| 7682 | } |
| 7683 | |
| 7684 | /* |
| 7685 | * Find the number of channels that are populated. If freq is not |
| 7686 | * filled then stop count there |
| 7687 | */ |
| 7688 | for (num_recv_channels = 0; |
| 7689 | (num_recv_channels < num_freqs && |
| 7690 | ani[num_recv_channels].chan_freq); num_recv_channels++) |
| 7691 | ; |
| 7692 | |
| 7693 | for (j = 0; j < num_recv_channels; j++) { |
| 7694 | /* Sanity check for ANI level validity */ |
| 7695 | if (ani[j].ani_level > MAX_ANI_LEVEL) |
| 7696 | continue; |
| 7697 | |
| 7698 | copied_length += scnprintf(extra + copied_length, |
| 7699 | user_size - copied_length, "%d:%d\n", |
| 7700 | ani[j].chan_freq, ani[j].ani_level); |
| 7701 | } |
| 7702 | |
| 7703 | if (copied_length == 0) { |
| 7704 | hdd_err("ANI level not fetched"); |
| 7705 | ret = -EINVAL; |
| 7706 | goto free; |
| 7707 | } |
| 7708 | |
| 7709 | hdd_debug("data: %s", extra); |
| 7710 | |
| 7711 | if (copy_to_user(priv_data->buf, extra, copied_length + 1)) { |
| 7712 | hdd_err("failed to copy data to user buffer"); |
| 7713 | ret = -EFAULT; |
| 7714 | goto free; |
| 7715 | } |
| 7716 | |
| 7717 | free: |
| 7718 | qdf_mem_free(extra); |
| 7719 | |
| 7720 | parse_failed: |
| 7721 | return ret; |
| 7722 | } |
| 7723 | |
| 7724 | #else |
| 7725 | static int drv_cmd_get_ani_level(struct hdd_adapter *adapter, |
| 7726 | struct hdd_context *hdd_ctx, |
| 7727 | uint8_t *command, |
| 7728 | uint8_t command_len, |
| 7729 | struct hdd_priv_data *priv_data) |
| 7730 | { |
| 7731 | return 0; |
| 7732 | } |
| 7733 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7734 | /* |
| 7735 | * The following table contains all supported WLAN HDD |
| 7736 | * IOCTL driver commands and the handler for each of them. |
| 7737 | */ |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 7738 | static const struct hdd_drv_cmd hdd_drv_cmds[] = { |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7739 | {"P2P_DEV_ADDR", drv_cmd_p2p_dev_addr, false}, |
| 7740 | {"P2P_SET_NOA", drv_cmd_p2p_set_noa, true}, |
| 7741 | {"P2P_SET_PS", drv_cmd_p2p_set_ps, true}, |
| 7742 | {"SETBAND", drv_cmd_set_band, true}, |
| 7743 | {"SETWMMPS", drv_cmd_set_wmmps, true}, |
| 7744 | {"COUNTRY", drv_cmd_country, true}, |
Rajeev Kumar Sirasanagandla | 32ae804 | 2019-03-25 16:37:02 +0530 | [diff] [blame] | 7745 | {"SETCOUNTRYREV", drv_cmd_country, true}, |
| 7746 | {"GETCOUNTRYREV", drv_cmd_get_country, false}, |
Pragaspathi Thilagaraj | aa8320e | 2019-04-16 02:47:50 +0530 | [diff] [blame] | 7747 | {"SETSUSPENDMODE", drv_cmd_set_suspend_mode, true}, |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7748 | {"SET_AP_WPS_P2P_IE", drv_cmd_dummy, false}, |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7749 | {"SETROAMTRIGGER", drv_cmd_set_roam_trigger, true}, |
| 7750 | {"GETROAMTRIGGER", drv_cmd_get_roam_trigger, false}, |
| 7751 | {"SETROAMSCANPERIOD", drv_cmd_set_roam_scan_period, true}, |
| 7752 | {"GETROAMSCANPERIOD", drv_cmd_get_roam_scan_period, false}, |
| 7753 | {"SETROAMSCANREFRESHPERIOD", drv_cmd_set_roam_scan_refresh_period, |
| 7754 | true}, |
| 7755 | {"GETROAMSCANREFRESHPERIOD", drv_cmd_get_roam_scan_refresh_period, |
| 7756 | false}, |
| 7757 | {"SETROAMMODE", drv_cmd_set_roam_mode, true}, |
| 7758 | {"GETROAMMODE", drv_cmd_get_roam_mode, false}, |
| 7759 | {"SETROAMDELTA", drv_cmd_set_roam_delta, true}, |
| 7760 | {"GETROAMDELTA", drv_cmd_get_roam_delta, false}, |
| 7761 | {"GETBAND", drv_cmd_get_band, false}, |
| 7762 | {"SETROAMSCANCHANNELS", drv_cmd_set_roam_scan_channels, true}, |
| 7763 | {"GETROAMSCANCHANNELS", drv_cmd_get_roam_scan_channels, false}, |
| 7764 | {"GETCCXMODE", drv_cmd_get_ccx_mode, false}, |
| 7765 | {"GETOKCMODE", drv_cmd_get_okc_mode, false}, |
| 7766 | {"GETFASTROAM", drv_cmd_get_fast_roam, false}, |
| 7767 | {"GETFASTTRANSITION", drv_cmd_get_fast_transition, false}, |
| 7768 | {"SETROAMSCANCHANNELMINTIME", drv_cmd_set_roam_scan_channel_min_time, |
| 7769 | true}, |
| 7770 | {"SENDACTIONFRAME", drv_cmd_send_action_frame, true}, |
| 7771 | {"GETROAMSCANCHANNELMINTIME", drv_cmd_get_roam_scan_channel_min_time, |
| 7772 | false}, |
| 7773 | {"SETSCANCHANNELTIME", drv_cmd_set_scan_channel_time, true}, |
| 7774 | {"GETSCANCHANNELTIME", drv_cmd_get_scan_channel_time, false}, |
| 7775 | {"SETSCANHOMETIME", drv_cmd_set_scan_home_time, true}, |
| 7776 | {"GETSCANHOMETIME", drv_cmd_get_scan_home_time, false}, |
| 7777 | {"SETROAMINTRABAND", drv_cmd_set_roam_intra_band, true}, |
| 7778 | {"GETROAMINTRABAND", drv_cmd_get_roam_intra_band, false}, |
| 7779 | {"SETSCANNPROBES", drv_cmd_set_scan_n_probes, true}, |
| 7780 | {"GETSCANNPROBES", drv_cmd_get_scan_n_probes, false}, |
| 7781 | {"SETSCANHOMEAWAYTIME", drv_cmd_set_scan_home_away_time, true}, |
| 7782 | {"GETSCANHOMEAWAYTIME", drv_cmd_get_scan_home_away_time, false}, |
| 7783 | {"REASSOC", drv_cmd_reassoc, true}, |
| 7784 | {"SETWESMODE", drv_cmd_set_wes_mode, true}, |
| 7785 | {"GETWESMODE", drv_cmd_get_wes_mode, false}, |
| 7786 | {"SETOPPORTUNISTICRSSIDIFF", drv_cmd_set_opportunistic_rssi_diff, |
| 7787 | true}, |
| 7788 | {"GETOPPORTUNISTICRSSIDIFF", drv_cmd_get_opportunistic_rssi_diff, |
| 7789 | false}, |
| 7790 | {"SETROAMRESCANRSSIDIFF", drv_cmd_set_roam_rescan_rssi_diff, true}, |
| 7791 | {"GETROAMRESCANRSSIDIFF", drv_cmd_get_roam_rescan_rssi_diff, false}, |
| 7792 | {"SETFASTROAM", drv_cmd_set_fast_roam, true}, |
| 7793 | {"SETFASTTRANSITION", drv_cmd_set_fast_transition, true}, |
| 7794 | {"FASTREASSOC", drv_cmd_fast_reassoc, true}, |
| 7795 | {"SETROAMSCANCONTROL", drv_cmd_set_roam_scan_control, true}, |
| 7796 | {"SETOKCMODE", drv_cmd_set_okc_mode, true}, |
| 7797 | {"GETROAMSCANCONTROL", drv_cmd_get_roam_scan_control, false}, |
| 7798 | {"BTCOEXMODE", drv_cmd_bt_coex_mode, true}, |
| 7799 | {"SCAN-ACTIVE", drv_cmd_scan_active, false}, |
| 7800 | {"SCAN-PASSIVE", drv_cmd_scan_passive, false}, |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 7801 | {"CONCSETDWELLTIME", drv_cmd_conc_set_dwell_time, true}, |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7802 | {"GETDWELLTIME", drv_cmd_get_dwell_time, false}, |
| 7803 | {"SETDWELLTIME", drv_cmd_set_dwell_time, true}, |
| 7804 | {"MIRACAST", drv_cmd_miracast, true}, |
| 7805 | {"SETIBSSBEACONOUIDATA", drv_cmd_set_ibss_beacon_oui_data, true}, |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 7806 | #ifdef FEATURE_WLAN_RMC |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7807 | {"SETRMCENABLE", drv_cmd_set_rmc_enable, true}, |
| 7808 | {"SETRMCACTIONPERIOD", drv_cmd_set_rmc_action_period, true}, |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 7809 | {"SETRMCTXRATE", drv_cmd_set_rmc_tx_rate, true}, |
| 7810 | #endif |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7811 | {"GETIBSSPEERINFOALL", drv_cmd_get_ibss_peer_info_all, false}, |
| 7812 | {"GETIBSSPEERINFO", drv_cmd_get_ibss_peer_info, true}, |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7813 | {"SETIBSSTXFAILEVENT", drv_cmd_set_ibss_tx_fail_event, true}, |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 7814 | #ifdef FEATURE_WLAN_ESE |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7815 | {"SETCCXROAMSCANCHANNELS", drv_cmd_set_ccx_roam_scan_channels, true}, |
| 7816 | {"GETTSMSTATS", drv_cmd_get_tsm_stats, true}, |
| 7817 | {"SETCCKMIE", drv_cmd_set_cckm_ie, true}, |
| 7818 | {"CCXBEACONREQ", drv_cmd_ccx_beacon_req, true}, |
| 7819 | {"CCXPLMREQ", drv_cmd_ccx_plm_req, true}, |
| 7820 | {"SETCCXMODE", drv_cmd_set_ccx_mode, true}, |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 7821 | #endif /* FEATURE_WLAN_ESE */ |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7822 | {"SETMCRATE", drv_cmd_set_mc_rate, true}, |
| 7823 | {"MAXTXPOWER", drv_cmd_max_tx_power, true}, |
| 7824 | {"SETDFSSCANMODE", drv_cmd_set_dfs_scan_mode, true}, |
| 7825 | {"GETDFSSCANMODE", drv_cmd_get_dfs_scan_mode, false}, |
| 7826 | {"GETLINKSTATUS", drv_cmd_get_link_status, false}, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7827 | #ifdef WLAN_FEATURE_EXTWOW_SUPPORT |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7828 | {"ENABLEEXTWOW", drv_cmd_enable_ext_wow, true}, |
| 7829 | {"SETAPP1PARAMS", drv_cmd_set_app1_params, true}, |
| 7830 | {"SETAPP2PARAMS", drv_cmd_set_app2_params, true}, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7831 | #endif |
| 7832 | #ifdef FEATURE_WLAN_TDLS |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7833 | {"TDLSSECONDARYCHANNELOFFSET", drv_cmd_tdls_secondary_channel_offset, |
| 7834 | true}, |
| 7835 | {"TDLSOFFCHANNELMODE", drv_cmd_tdls_off_channel_mode, true}, |
| 7836 | {"TDLSOFFCHANNEL", drv_cmd_tdls_off_channel, true}, |
| 7837 | {"TDLSSCAN", drv_cmd_tdls_scan, true}, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7838 | #endif |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7839 | {"RSSI", drv_cmd_get_rssi, false}, |
| 7840 | {"LINKSPEED", drv_cmd_get_linkspeed, false}, |
Qiwei Cai | 4505fc6 | 2018-05-17 18:35:19 +0800 | [diff] [blame] | 7841 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7842 | {"RXFILTER-REMOVE", drv_cmd_rx_filter_remove, true}, |
| 7843 | {"RXFILTER-ADD", drv_cmd_rx_filter_add, true}, |
Qiwei Cai | 4505fc6 | 2018-05-17 18:35:19 +0800 | [diff] [blame] | 7844 | #endif |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7845 | {"SET_FCC_CHANNEL", drv_cmd_set_fcc_channel, true}, |
| 7846 | {"CHANNEL_SWITCH", drv_cmd_set_channel_switch, true}, |
| 7847 | {"SETANTENNAMODE", drv_cmd_set_antenna_mode, true}, |
| 7848 | {"GETANTENNAMODE", drv_cmd_get_antenna_mode, false}, |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7849 | {"SET_DISABLE_CHANNEL_LIST", drv_cmd_set_disable_chan_list, true}, |
Ashish Kumar Dhanotiya | 2853ba0 | 2018-03-15 15:51:25 +0530 | [diff] [blame] | 7850 | {"GET_DISABLE_CHANNEL_LIST", drv_cmd_get_disable_chan_list, false}, |
Sourav Mohapatra | 2a67b0e | 2019-10-15 17:59:59 +0530 | [diff] [blame^] | 7851 | {"GET_ANI_LEVEL", drv_cmd_get_ani_level, false}, |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7852 | {"STOP", drv_cmd_dummy, false}, |
Srinivas Girigowda | 836475e | 2018-04-17 14:42:23 -0700 | [diff] [blame] | 7853 | /* Deprecated commands */ |
| 7854 | {"RXFILTER-START", drv_cmd_dummy, false}, |
| 7855 | {"RXFILTER-STOP", drv_cmd_dummy, false}, |
| 7856 | {"BTCOEXSCAN-START", drv_cmd_dummy, false}, |
| 7857 | {"BTCOEXSCAN-STOP", drv_cmd_dummy, false}, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7858 | }; |
| 7859 | |
| 7860 | /** |
| 7861 | * hdd_drv_cmd_process() - chooses and runs the proper |
| 7862 | * handler based on the input command |
| 7863 | * @adapter: Pointer to the hdd adapter |
| 7864 | * @cmd: Pointer to the driver command |
| 7865 | * @priv_data: Pointer to the data associated with the command |
| 7866 | * |
| 7867 | * This function parses the input hdd driver command and runs |
| 7868 | * the proper handler |
| 7869 | * |
| 7870 | * Return: 0 for success non-zero for failure |
| 7871 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 7872 | static int hdd_drv_cmd_process(struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7873 | uint8_t *cmd, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 7874 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7875 | { |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 7876 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7877 | int i; |
| 7878 | const int cmd_num_total = ARRAY_SIZE(hdd_drv_cmds); |
| 7879 | uint8_t *cmd_i = NULL; |
| 7880 | hdd_drv_cmd_handler_t handler = NULL; |
Nachiket Kukade | b7e0497 | 2017-12-13 20:38:00 +0530 | [diff] [blame] | 7881 | int len = 0, cmd_len = 0; |
| 7882 | uint8_t *ptr; |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7883 | bool args; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7884 | |
| 7885 | if (!adapter || !cmd || !priv_data) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 7886 | hdd_err("at least 1 param is NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7887 | return -EINVAL; |
| 7888 | } |
| 7889 | |
Nachiket Kukade | b7e0497 | 2017-12-13 20:38:00 +0530 | [diff] [blame] | 7890 | /* Calculate length of the first word */ |
| 7891 | ptr = strchrnul(cmd, ' '); |
| 7892 | cmd_len = ptr - cmd; |
| 7893 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 7894 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7895 | |
| 7896 | for (i = 0; i < cmd_num_total; i++) { |
| 7897 | |
| 7898 | cmd_i = (uint8_t *)hdd_drv_cmds[i].cmd; |
| 7899 | handler = hdd_drv_cmds[i].handler; |
| 7900 | len = strlen(cmd_i); |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7901 | args = hdd_drv_cmds[i].args; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7902 | |
| 7903 | if (!handler) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 7904 | hdd_err("no. %d handler is NULL", i); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7905 | return -EINVAL; |
| 7906 | } |
| 7907 | |
Nachiket Kukade | b7e0497 | 2017-12-13 20:38:00 +0530 | [diff] [blame] | 7908 | if (len == cmd_len && strncasecmp(cmd, cmd_i, len) == 0) { |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7909 | if (args && drv_cmd_validate(cmd, len)) |
| 7910 | return -EINVAL; |
| 7911 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7912 | return handler(adapter, hdd_ctx, |
| 7913 | cmd, len, priv_data); |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7914 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7915 | } |
| 7916 | |
| 7917 | return drv_cmd_invalid(adapter, hdd_ctx, cmd, len, priv_data); |
| 7918 | } |
| 7919 | |
| 7920 | /** |
| 7921 | * hdd_driver_command() - top level wlan hdd driver command handler |
| 7922 | * @adapter: Pointer to the hdd adapter |
| 7923 | * @priv_data: Pointer to the raw command data |
| 7924 | * |
| 7925 | * This function is the top level wlan hdd driver command handler. It |
| 7926 | * handles the command with the help of hdd_drv_cmd_process() |
| 7927 | * |
| 7928 | * Return: 0 for success non-zero for failure |
| 7929 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 7930 | static int hdd_driver_command(struct hdd_adapter *adapter, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 7931 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7932 | { |
| 7933 | uint8_t *command = NULL; |
| 7934 | int ret = 0; |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 7935 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7936 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 7937 | hdd_enter(); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 7938 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7939 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 7940 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7941 | return -EINVAL; |
| 7942 | } |
| 7943 | |
Ashish Kumar Dhanotiya | ff4e1c4 | 2017-03-14 15:54:05 +0530 | [diff] [blame] | 7944 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 7945 | if (ret) |
| 7946 | return ret; |
| 7947 | |
| 7948 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 7949 | hdd_err("Driver module is closed; command can not be processed"); |
| 7950 | return -EINVAL; |
| 7951 | } |
| 7952 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7953 | /* |
| 7954 | * Note that valid pointers are provided by caller |
| 7955 | */ |
| 7956 | |
| 7957 | /* copy to local struct to avoid numerous changes to legacy code */ |
| 7958 | if (priv_data->total_len <= 0 || |
| 7959 | priv_data->total_len > WLAN_PRIV_DATA_MAX_LEN) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 7960 | hdd_warn("Invalid priv_data.total_len: %d!!!", |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 7961 | priv_data->total_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7962 | ret = -EINVAL; |
| 7963 | goto exit; |
| 7964 | } |
| 7965 | |
| 7966 | /* Allocate +1 for '\0' */ |
Mahesh Kumar Kalikot Veetil | 9c65618 | 2016-11-02 10:28:03 -0700 | [diff] [blame] | 7967 | command = qdf_mem_malloc(priv_data->total_len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7968 | if (!command) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 7969 | hdd_err("failed to allocate memory"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7970 | ret = -ENOMEM; |
| 7971 | goto exit; |
| 7972 | } |
| 7973 | |
| 7974 | if (copy_from_user(command, priv_data->buf, priv_data->total_len)) { |
| 7975 | ret = -EFAULT; |
| 7976 | goto exit; |
| 7977 | } |
| 7978 | |
| 7979 | /* Make sure the command is NUL-terminated */ |
| 7980 | command[priv_data->total_len] = '\0'; |
| 7981 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 7982 | hdd_debug("%s: %s", adapter->dev->name, command); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7983 | ret = hdd_drv_cmd_process(adapter, command, priv_data); |
| 7984 | |
| 7985 | exit: |
| 7986 | if (command) |
Mahesh Kumar Kalikot Veetil | 9c65618 | 2016-11-02 10:28:03 -0700 | [diff] [blame] | 7987 | qdf_mem_free(command); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 7988 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7989 | return ret; |
| 7990 | } |
| 7991 | |
| 7992 | #ifdef CONFIG_COMPAT |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 7993 | 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] | 7994 | { |
| 7995 | struct { |
| 7996 | compat_uptr_t buf; |
| 7997 | int used_len; |
| 7998 | int total_len; |
| 7999 | } compat_priv_data; |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 8000 | struct hdd_priv_data priv_data; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8001 | int ret = 0; |
| 8002 | |
| 8003 | /* |
| 8004 | * Note that adapter and ifr have already been verified by caller, |
| 8005 | * and HDD context has also been validated |
| 8006 | */ |
| 8007 | if (copy_from_user(&compat_priv_data, ifr->ifr_data, |
| 8008 | sizeof(compat_priv_data))) { |
| 8009 | ret = -EFAULT; |
| 8010 | goto exit; |
| 8011 | } |
| 8012 | priv_data.buf = compat_ptr(compat_priv_data.buf); |
| 8013 | priv_data.used_len = compat_priv_data.used_len; |
| 8014 | priv_data.total_len = compat_priv_data.total_len; |
| 8015 | ret = hdd_driver_command(adapter, &priv_data); |
| 8016 | exit: |
| 8017 | return ret; |
| 8018 | } |
| 8019 | #else /* CONFIG_COMPAT */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 8020 | 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] | 8021 | { |
| 8022 | /* will never be invoked */ |
| 8023 | return 0; |
| 8024 | } |
| 8025 | #endif /* CONFIG_COMPAT */ |
| 8026 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 8027 | static int hdd_driver_ioctl(struct hdd_adapter *adapter, struct ifreq *ifr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8028 | { |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 8029 | struct hdd_priv_data priv_data; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8030 | int ret = 0; |
| 8031 | |
| 8032 | /* |
| 8033 | * Note that adapter and ifr have already been verified by caller, |
| 8034 | * and HDD context has also been validated |
| 8035 | */ |
| 8036 | if (copy_from_user(&priv_data, ifr->ifr_data, sizeof(priv_data))) |
| 8037 | ret = -EFAULT; |
| 8038 | else |
| 8039 | ret = hdd_driver_command(adapter, &priv_data); |
| 8040 | |
| 8041 | return ret; |
| 8042 | } |
| 8043 | |
| 8044 | /** |
| 8045 | * __hdd_ioctl() - ioctl handler for wlan network interfaces |
| 8046 | * @dev: device upon which the ioctl was received |
| 8047 | * @ifr: ioctl request information |
| 8048 | * @cmd: ioctl command |
| 8049 | * |
| 8050 | * This function does initial processing of wlan device ioctls. |
| 8051 | * Currently two flavors of ioctls are supported. The primary ioctl |
| 8052 | * that is supported is the (SIOCDEVPRIVATE + 1) ioctl which is used |
| 8053 | * for Android "DRIVER" commands. The other ioctl that is |
| 8054 | * conditionally supported is the SIOCIOCTLTX99 ioctl which is used |
| 8055 | * for FTM on some platforms. This function simply verifies that the |
| 8056 | * driver is in a sane state, and that the ioctl is one of the |
| 8057 | * supported flavors, in which case flavor-specific handlers are |
| 8058 | * dispatched. |
| 8059 | * |
| 8060 | * Return: 0 on success, non-zero on error |
| 8061 | */ |
| 8062 | static int __hdd_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) |
| 8063 | { |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 8064 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 8065 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8066 | int ret; |
| 8067 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 8068 | hdd_enter_dev(dev); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 8069 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8070 | if (dev != adapter->dev) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 8071 | hdd_err("HDD adapter/dev inconsistency"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8072 | ret = -ENODEV; |
| 8073 | goto exit; |
| 8074 | } |
| 8075 | |
| 8076 | if ((!ifr) || (!ifr->ifr_data)) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 8077 | hdd_err("invalid data cmd: %d", cmd); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8078 | ret = -EINVAL; |
| 8079 | goto exit; |
| 8080 | } |
| 8081 | #if defined(QCA_WIFI_FTM) && defined(LINUX_QCMBR) |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8082 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8083 | if (SIOCIOCTLTX99 == cmd) { |
| 8084 | ret = wlan_hdd_qcmbr_unified_ioctl(adapter, ifr); |
| 8085 | goto exit; |
| 8086 | } |
| 8087 | } |
| 8088 | #endif |
| 8089 | |
| 8090 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8091 | ret = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 8092 | if (ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8093 | goto exit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8094 | |
| 8095 | switch (cmd) { |
| 8096 | case (SIOCDEVPRIVATE + 1): |
Mahesh Kumar Kalikot Veetil | 885a77b | 2018-03-26 14:46:59 -0700 | [diff] [blame] | 8097 | if (in_compat_syscall()) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8098 | ret = hdd_driver_compat_ioctl(adapter, ifr); |
| 8099 | else |
| 8100 | ret = hdd_driver_ioctl(adapter, ifr); |
| 8101 | break; |
| 8102 | default: |
Srinivas Girigowda | 86ecc01 | 2017-03-10 12:26:57 -0800 | [diff] [blame] | 8103 | hdd_warn("unknown ioctl %d", cmd); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8104 | ret = -EINVAL; |
| 8105 | break; |
| 8106 | } |
| 8107 | exit: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 8108 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8109 | return ret; |
| 8110 | } |
| 8111 | |
| 8112 | /** |
| 8113 | * hdd_ioctl() - ioctl handler (wrapper) for wlan network interfaces |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 8114 | * @net_dev: device upon which the ioctl was received |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8115 | * @ifr: ioctl request information |
| 8116 | * @cmd: ioctl command |
| 8117 | * |
| 8118 | * This function acts as an SSR-protecting wrapper to __hdd_ioctl() |
| 8119 | * which is where the ioctls are really handled. |
| 8120 | * |
| 8121 | * Return: 0 on success, non-zero on error |
| 8122 | */ |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 8123 | 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] | 8124 | { |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 8125 | struct osif_vdev_sync *vdev_sync; |
| 8126 | int errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8127 | |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 8128 | errno = osif_vdev_sync_op_start(net_dev, &vdev_sync); |
| 8129 | if (errno) |
| 8130 | return errno; |
| 8131 | |
| 8132 | errno = __hdd_ioctl(net_dev, ifr, cmd); |
| 8133 | |
| 8134 | osif_vdev_sync_op_stop(vdev_sync); |
| 8135 | |
| 8136 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8137 | } |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 8138 | |