Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Arun Kumar Khandavalli | afcb055 | 2020-01-20 11:46:36 +0530 | [diff] [blame] | 2 | * Copyright (c) 2012-2020 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" |
Ashish Kumar Dhanotiya | 7efe26e | 2018-11-14 16:35:57 +0530 | [diff] [blame^] | 48 | #include "qdf_func_tracker.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 49 | |
| 50 | #if defined(LINUX_QCMBR) |
| 51 | #define SIOCIOCTLTX99 (SIOCDEVPRIVATE+13) |
| 52 | #endif |
| 53 | |
| 54 | /* |
| 55 | * Size of Driver command strings from upper layer |
| 56 | */ |
| 57 | #define SIZE_OF_SETROAMMODE 11 /* size of SETROAMMODE */ |
| 58 | #define SIZE_OF_GETROAMMODE 11 /* size of GETROAMMODE */ |
Pragaspathi Thilagaraj | aa8320e | 2019-04-16 02:47:50 +0530 | [diff] [blame] | 59 | #define SIZE_OF_SETSUSPENDMODE 14 |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 60 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 61 | /* |
Rajeev Kumar Sirasanagandla | 32ae804 | 2019-03-25 16:37:02 +0530 | [diff] [blame] | 62 | * Size of GETCOUNTRYREV output = (sizeof("GETCOUNTRYREV") = 14) + one (space) + |
| 63 | * (sizeof("country_code") = 3) + |
| 64 | * one (NULL terminating character) |
| 65 | */ |
| 66 | #define SIZE_OF_GETCOUNTRYREV_OUTPUT 20 |
| 67 | |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 68 | #ifdef FEATURE_WLAN_ESE |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 69 | #define TID_MIN_VALUE 0 |
| 70 | #define TID_MAX_VALUE 15 |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 71 | #endif /* FEATURE_WLAN_ESE */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 72 | |
| 73 | /* |
| 74 | * Maximum buffer size used for returning the data back to user space |
| 75 | */ |
| 76 | #define WLAN_MAX_BUF_SIZE 1024 |
| 77 | #define WLAN_PRIV_DATA_MAX_LEN 8192 |
| 78 | |
| 79 | /* |
| 80 | * Driver miracast parameters 0-Disabled |
| 81 | * 1-Source, 2-Sink |
| 82 | */ |
| 83 | #define WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL 0 |
| 84 | #define WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL 2 |
| 85 | |
| 86 | /* |
| 87 | * When ever we need to print IBSSPEERINFOALL for more than 16 STA |
| 88 | * we will split the printing. |
| 89 | */ |
| 90 | #define NUM_OF_STA_DATA_TO_PRINT 16 |
| 91 | |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 92 | #ifdef WLAN_FEATURE_EXTWOW_SUPPORT |
| 93 | /** |
| 94 | * struct enable_ext_wow_priv - Private data structure for ext wow |
| 95 | * @ext_wow_should_suspend: Suspend status of ext wow |
| 96 | */ |
| 97 | struct enable_ext_wow_priv { |
| 98 | bool ext_wow_should_suspend; |
| 99 | }; |
| 100 | #endif |
| 101 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 102 | /* |
| 103 | * Android DRIVER command structures |
| 104 | */ |
| 105 | struct android_wifi_reassoc_params { |
| 106 | unsigned char bssid[18]; |
| 107 | int channel; |
| 108 | }; |
| 109 | |
| 110 | #define ANDROID_WIFI_ACTION_FRAME_SIZE 1040 |
| 111 | struct android_wifi_af_params { |
| 112 | unsigned char bssid[18]; |
| 113 | int channel; |
| 114 | int dwell_time; |
| 115 | int len; |
| 116 | unsigned char data[ANDROID_WIFI_ACTION_FRAME_SIZE]; |
| 117 | }; |
| 118 | |
| 119 | /* |
| 120 | * Define HDD driver command handling entry, each contains a command |
| 121 | * string and the handler. |
| 122 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 123 | typedef int (*hdd_drv_cmd_handler_t)(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 124 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 125 | uint8_t *cmd, |
| 126 | uint8_t cmd_name_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 127 | struct hdd_priv_data *priv_data); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 128 | |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 129 | /** |
| 130 | * struct hdd_drv_cmd - Structure to store ioctl command handling info |
| 131 | * @cmd: Name of the command |
| 132 | * @handler: Command handler to be invoked |
| 133 | * @args: Set to true if command expects input parameters |
| 134 | */ |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 135 | struct hdd_drv_cmd { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 136 | const char *cmd; |
| 137 | hdd_drv_cmd_handler_t handler; |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 138 | bool args; |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 139 | }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 140 | |
| 141 | #ifdef WLAN_FEATURE_EXTWOW_SUPPORT |
| 142 | #define WLAN_WAIT_TIME_READY_TO_EXTWOW 2000 |
| 143 | #define WLAN_HDD_MAX_TCP_PORT 65535 |
| 144 | #endif |
| 145 | |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 146 | /** |
| 147 | * drv_cmd_validate() - Validates for space in hdd driver command |
| 148 | * @command: pointer to input data (its a NULL terminated string) |
| 149 | * @len: length of command name |
| 150 | * |
| 151 | * This function checks for space after command name and if no space |
| 152 | * is found returns error. |
| 153 | * |
| 154 | * Return: 0 for success non-zero for failure |
| 155 | */ |
| 156 | static int drv_cmd_validate(uint8_t *command, int len) |
| 157 | { |
| 158 | if (command[len] != ' ') |
| 159 | return -EINVAL; |
| 160 | |
| 161 | return 0; |
| 162 | } |
| 163 | |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 164 | #ifdef FEATURE_WLAN_ESE |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 165 | struct tsm_priv { |
| 166 | tAniTrafStrmMetrics tsm_metrics; |
| 167 | }; |
| 168 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 169 | static void hdd_get_tsm_stats_cb(tAniTrafStrmMetrics tsm_metrics, |
Sourav Mohapatra | dcd8f8d | 2019-07-03 15:43:15 +0530 | [diff] [blame] | 170 | void *context) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 171 | { |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 172 | struct osif_request *request; |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 173 | struct tsm_priv *priv; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 174 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 175 | request = osif_request_get(context); |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 176 | if (!request) { |
| 177 | hdd_err("Obsolete request"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 178 | return; |
| 179 | } |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 180 | priv = osif_request_priv(request); |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 181 | priv->tsm_metrics = tsm_metrics; |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 182 | osif_request_complete(request); |
| 183 | osif_request_put(request); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 184 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 185 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 186 | } |
| 187 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 188 | static int hdd_get_tsm_stats(struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 189 | const uint8_t tid, |
| 190 | tAniTrafStrmMetrics *tsm_metrics) |
| 191 | { |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 192 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 193 | struct hdd_station_ctx *hdd_sta_ctx; |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 194 | QDF_STATUS status; |
| 195 | int ret; |
| 196 | void *cookie; |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 197 | struct osif_request *request; |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 198 | struct tsm_priv *priv; |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 199 | static const struct osif_request_params params = { |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 200 | .priv_size = sizeof(*priv), |
| 201 | .timeout_ms = WLAN_WAIT_TIME_STATS, |
| 202 | }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 203 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 204 | if (!adapter) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 205 | hdd_err("adapter is NULL"); |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 206 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 210 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 211 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 212 | request = osif_request_alloc(¶ms); |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 213 | if (!request) { |
| 214 | hdd_err("Request allocation failure"); |
| 215 | return -ENOMEM; |
| 216 | } |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 217 | cookie = osif_request_cookie(request); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 218 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 219 | 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] | 220 | hdd_sta_ctx->conn_info.bssid, |
Jeff Johnson | 30f8455 | 2017-09-13 14:55:25 -0700 | [diff] [blame] | 221 | cookie, tid); |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 222 | if (QDF_STATUS_SUCCESS != status) { |
| 223 | hdd_err("Unable to retrieve tsm statistics"); |
| 224 | ret = qdf_status_to_os_return(status); |
| 225 | goto cleanup; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 226 | } |
| 227 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 228 | ret = osif_request_wait_for_response(request); |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 229 | if (ret) { |
| 230 | hdd_err("SME timed out while retrieving tsm statistics"); |
| 231 | goto cleanup; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 232 | } |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 233 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 234 | priv = osif_request_priv(request); |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 235 | *tsm_metrics = priv->tsm_metrics; |
| 236 | |
| 237 | cleanup: |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 238 | osif_request_put(request); |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 239 | |
| 240 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 241 | } |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 242 | #endif /*FEATURE_WLAN_ESE */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 243 | |
Abhishek Ambure | 6867746 | 2019-09-13 12:44:26 +0530 | [diff] [blame] | 244 | #ifdef QCA_IBSS_SUPPORT |
| 245 | /* |
| 246 | * Ibss prop IE from command will be of size: |
| 247 | * size = sizeof(oui) + sizeof(oui_data) + 1(Element ID) + 1(EID Length) |
| 248 | * OUI_DATA should be at least 3 bytes long |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 249 | */ |
Abhishek Ambure | 6867746 | 2019-09-13 12:44:26 +0530 | [diff] [blame] | 250 | #define WLAN_HDD_IBSS_MIN_OUI_DATA_LENGTH (3) |
| 251 | static uint16_t cesium_pid; |
| 252 | |
Rajeev Kumar | 94c9b45 | 2016-03-24 12:58:47 -0700 | [diff] [blame] | 253 | void |
Jeff Johnson | afa022c | 2019-02-26 09:24:17 -0800 | [diff] [blame] | 254 | hdd_get_ibss_peer_info_cb(void *context, |
Jeff Johnson | 52f19d5 | 2019-02-26 08:35:38 -0800 | [diff] [blame] | 255 | tSirPeerInfoRspParams *peer_info) |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 256 | { |
Jeff Johnson | afa022c | 2019-02-26 09:24:17 -0800 | [diff] [blame] | 257 | struct hdd_adapter *adapter = context; |
Jeff Johnson | 93107ad | 2019-02-26 08:14:46 -0800 | [diff] [blame] | 258 | struct hdd_station_ctx *sta_ctx; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 259 | uint8_t i; |
| 260 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 261 | if ((!adapter) || |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 262 | (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 263 | hdd_err("invalid adapter or adapter has invalid magic"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 264 | return; |
| 265 | } |
| 266 | |
Jeff Johnson | 93107ad | 2019-02-26 08:14:46 -0800 | [diff] [blame] | 267 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 268 | if (peer_info && QDF_STATUS_SUCCESS == peer_info->status) { |
Rajeev Kumar | 94c9b45 | 2016-03-24 12:58:47 -0700 | [diff] [blame] | 269 | /* validate number of peers */ |
Jeff Johnson | 52f19d5 | 2019-02-26 08:35:38 -0800 | [diff] [blame] | 270 | if (peer_info->numPeers > SIR_MAX_NUM_STA_IN_IBSS) { |
Sriram Madhvapathi | 58f0e27 | 2016-10-03 11:47:51 +0530 | [diff] [blame] | 271 | hdd_warn("Limiting num_peers %u to %u", |
Jeff Johnson | 52f19d5 | 2019-02-26 08:35:38 -0800 | [diff] [blame] | 272 | peer_info->numPeers, SIR_MAX_NUM_STA_IN_IBSS); |
| 273 | peer_info->numPeers = SIR_MAX_NUM_STA_IN_IBSS; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 274 | } |
Jeff Johnson | 52f19d5 | 2019-02-26 08:35:38 -0800 | [diff] [blame] | 275 | sta_ctx->ibss_peer_info.status = peer_info->status; |
| 276 | sta_ctx->ibss_peer_info.numPeers = peer_info->numPeers; |
Sriram Madhvapathi | 58f0e27 | 2016-10-03 11:47:51 +0530 | [diff] [blame] | 277 | |
Jeff Johnson | 52f19d5 | 2019-02-26 08:35:38 -0800 | [diff] [blame] | 278 | for (i = 0; i < peer_info->numPeers; i++) |
Jeff Johnson | 93107ad | 2019-02-26 08:14:46 -0800 | [diff] [blame] | 279 | sta_ctx->ibss_peer_info.peerInfoParams[i] = |
Jeff Johnson | 52f19d5 | 2019-02-26 08:35:38 -0800 | [diff] [blame] | 280 | peer_info->peerInfoParams[i]; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 281 | } else { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 282 | hdd_debug("peerInfo %s: status %u, numPeers %u", |
Jeff Johnson | 52f19d5 | 2019-02-26 08:35:38 -0800 | [diff] [blame] | 283 | peer_info ? "valid" : "null", |
| 284 | peer_info ? peer_info->status : QDF_STATUS_E_FAILURE, |
| 285 | peer_info ? peer_info->numPeers : 0); |
Jeff Johnson | 93107ad | 2019-02-26 08:14:46 -0800 | [diff] [blame] | 286 | sta_ctx->ibss_peer_info.numPeers = 0; |
| 287 | sta_ctx->ibss_peer_info.status = QDF_STATUS_E_FAILURE; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 288 | } |
| 289 | |
| 290 | complete(&adapter->ibss_peer_info_comp); |
| 291 | } |
| 292 | |
| 293 | /** |
| 294 | * hdd_cfg80211_get_ibss_peer_info_all() - get ibss peers' info |
| 295 | * @adapter: Adapter context |
| 296 | * |
| 297 | * Request function to get IBSS peer info from lower layers |
| 298 | * |
| 299 | * Return: 0 for success non-zero for failure |
| 300 | */ |
| 301 | static |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 302 | 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] | 303 | { |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 304 | QDF_STATUS status; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 305 | unsigned long rc; |
Yeshwanth Sriram Guntuka | 3f26210 | 2019-07-16 15:41:08 +0530 | [diff] [blame] | 306 | struct qdf_mac_addr bcast = QDF_MAC_ADDR_BCAST_INIT; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 307 | |
| 308 | INIT_COMPLETION(adapter->ibss_peer_info_comp); |
| 309 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 310 | status = sme_request_ibss_peer_info(adapter->hdd_ctx->mac_handle, |
| 311 | adapter, |
| 312 | hdd_get_ibss_peer_info_cb, |
Yeshwanth Sriram Guntuka | 3f26210 | 2019-07-16 15:41:08 +0530 | [diff] [blame] | 313 | true, bcast.bytes); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 314 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 315 | if (QDF_STATUS_SUCCESS == status) { |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 316 | rc = wait_for_completion_timeout |
| 317 | (&adapter->ibss_peer_info_comp, |
| 318 | msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT)); |
| 319 | |
| 320 | /* status will be 0 if timed out */ |
| 321 | if (!rc) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 322 | hdd_warn("Warning: IBSS_PEER_INFO_TIMEOUT"); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 323 | status = QDF_STATUS_E_FAILURE; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 324 | } |
| 325 | } else { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 326 | hdd_warn("Warning: sme_request_ibss_peer_info Request failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 327 | } |
| 328 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 329 | return status; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 330 | } |
| 331 | |
| 332 | /** |
| 333 | * hdd_cfg80211_get_ibss_peer_info() - get ibss peer info |
| 334 | * @adapter: Adapter context |
Jeff Johnson | 0a082d9 | 2019-03-04 12:25:49 -0800 | [diff] [blame] | 335 | * @sta_id: Sta index for which the peer info is requested |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 336 | * |
| 337 | * Request function to get IBSS peer info from lower layers |
| 338 | * |
| 339 | * Return: 0 for success non-zero for failure |
| 340 | */ |
| 341 | static QDF_STATUS |
Sourav Mohapatra | a3cf12a | 2019-08-19 15:40:49 +0530 | [diff] [blame] | 342 | 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] | 343 | { |
| 344 | unsigned long rc; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 345 | QDF_STATUS status; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 346 | |
| 347 | INIT_COMPLETION(adapter->ibss_peer_info_comp); |
| 348 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 349 | status = sme_request_ibss_peer_info(adapter->hdd_ctx->mac_handle, |
| 350 | adapter, |
| 351 | hdd_get_ibss_peer_info_cb, |
Sourav Mohapatra | a3cf12a | 2019-08-19 15:40:49 +0530 | [diff] [blame] | 352 | false, mac_addr); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 353 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 354 | if (QDF_STATUS_SUCCESS == status) { |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 355 | rc = wait_for_completion_timeout( |
| 356 | &adapter->ibss_peer_info_comp, |
| 357 | msecs_to_jiffies(IBSS_PEER_INFO_REQ_TIMOEUT)); |
| 358 | |
| 359 | /* status = 0 on timeout */ |
| 360 | if (!rc) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 361 | hdd_warn("Warning: IBSS_PEER_INFO_TIMEOUT"); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 362 | status = QDF_STATUS_E_FAILURE; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 363 | } |
| 364 | } else { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 365 | hdd_warn("Warning: sme_request_ibss_peer_info Request failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 366 | } |
| 367 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 368 | return status; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 369 | } |
| 370 | |
| 371 | /* Function header is left blank intentionally */ |
Jeff Johnson | f731b30 | 2016-10-05 16:00:55 -0700 | [diff] [blame] | 372 | static QDF_STATUS |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 373 | hdd_parse_get_ibss_peer_info(uint8_t *command, |
Jeff Johnson | 64ba9af | 2019-02-26 12:57:35 -0800 | [diff] [blame] | 374 | struct qdf_mac_addr *peer_macaddr) |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 375 | { |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 376 | uint8_t *in_ptr = command; |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 377 | size_t in_ptr_len = strlen(command); |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 378 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 379 | in_ptr = strnchr(command, in_ptr_len, SPACE_ASCII_VALUE); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 380 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 381 | if (!in_ptr) |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 382 | return QDF_STATUS_E_FAILURE; |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 383 | else if (SPACE_ASCII_VALUE != *in_ptr) |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 384 | return QDF_STATUS_E_FAILURE; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 385 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 386 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 387 | in_ptr++; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 388 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 389 | if ('\0' == *in_ptr) |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 390 | return QDF_STATUS_E_FAILURE; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 391 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 392 | in_ptr_len -= (in_ptr - command); |
Min Liu | 5359ab1 | 2018-03-29 14:30:24 +0800 | [diff] [blame] | 393 | if (in_ptr_len < 17) |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 394 | return QDF_STATUS_E_FAILURE; |
Min Liu | 5359ab1 | 2018-03-29 14:30:24 +0800 | [diff] [blame] | 395 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 396 | if (in_ptr[2] != ':' || in_ptr[5] != ':' || in_ptr[8] != ':' || |
| 397 | in_ptr[11] != ':' || in_ptr[14] != ':') |
Min Liu | 5359ab1 | 2018-03-29 14:30:24 +0800 | [diff] [blame] | 398 | return QDF_STATUS_E_FAILURE; |
| 399 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 400 | sscanf(in_ptr, "%2x:%2x:%2x:%2x:%2x:%2x", |
Jeff Johnson | 64ba9af | 2019-02-26 12:57:35 -0800 | [diff] [blame] | 401 | (unsigned int *)&peer_macaddr->bytes[0], |
| 402 | (unsigned int *)&peer_macaddr->bytes[1], |
| 403 | (unsigned int *)&peer_macaddr->bytes[2], |
| 404 | (unsigned int *)&peer_macaddr->bytes[3], |
| 405 | (unsigned int *)&peer_macaddr->bytes[4], |
| 406 | (unsigned int *)&peer_macaddr->bytes[5]); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 407 | |
| 408 | return QDF_STATUS_SUCCESS; |
| 409 | } |
| 410 | |
Abhishek Ambure | 6867746 | 2019-09-13 12:44:26 +0530 | [diff] [blame] | 411 | static void hdd_tx_fail_ind_callback(uint8_t *macaddr, uint8_t seq_no) |
| 412 | { |
| 413 | int payload_len; |
| 414 | struct sk_buff *skb; |
| 415 | struct nlmsghdr *nlh; |
| 416 | uint8_t *data; |
| 417 | |
| 418 | payload_len = ETH_ALEN; |
| 419 | |
| 420 | if (0 == cesium_pid || !cesium_nl_srv_sock) { |
| 421 | hdd_err("cesium process not registered"); |
| 422 | return; |
| 423 | } |
| 424 | |
| 425 | skb = nlmsg_new(payload_len, GFP_ATOMIC); |
| 426 | if (!skb) { |
| 427 | hdd_err("nlmsg_new() failed for msg size[%d]", |
| 428 | NLMSG_SPACE(payload_len)); |
| 429 | return; |
| 430 | } |
| 431 | |
| 432 | nlh = nlmsg_put(skb, cesium_pid, seq_no, 0, payload_len, NLM_F_REQUEST); |
| 433 | |
| 434 | if (!nlh) { |
| 435 | hdd_err("nlmsg_put() failed for msg size[%d]", |
| 436 | NLMSG_SPACE(payload_len)); |
| 437 | |
| 438 | kfree_skb(skb); |
| 439 | return; |
| 440 | } |
| 441 | |
| 442 | data = nlmsg_data(nlh); |
| 443 | memcpy(data, macaddr, ETH_ALEN); |
| 444 | |
| 445 | if (nlmsg_unicast(cesium_nl_srv_sock, skb, cesium_pid) < 0) { |
| 446 | hdd_err("nlmsg_unicast() failed for msg size[%d]", |
| 447 | NLMSG_SPACE(payload_len)); |
| 448 | } |
| 449 | } |
| 450 | |
| 451 | /** |
| 452 | * hdd_parse_user_params() - return a pointer to the next argument |
| 453 | * @command: Input argument string |
| 454 | * @arg: Output pointer to the next argument |
| 455 | * |
| 456 | * This function parses argument stream and finds the pointer |
| 457 | * to the next argument |
| 458 | * |
| 459 | * Return: 0 if the next argument found; -EINVAL otherwise |
| 460 | */ |
| 461 | static int hdd_parse_user_params(uint8_t *command, uint8_t **arg) |
| 462 | { |
| 463 | uint8_t *cursor; |
| 464 | |
| 465 | cursor = strnchr(command, strlen(command), SPACE_ASCII_VALUE); |
| 466 | |
| 467 | /* no argument remains ? */ |
| 468 | if (!cursor) |
| 469 | return -EINVAL; |
| 470 | |
| 471 | /* no space after the current arg ? */ |
| 472 | if (SPACE_ASCII_VALUE != *cursor) |
| 473 | return -EINVAL; |
| 474 | |
| 475 | cursor++; |
| 476 | |
| 477 | /* remove empty spaces */ |
| 478 | while (SPACE_ASCII_VALUE == *cursor) |
| 479 | cursor++; |
| 480 | |
| 481 | /* no argument after the spaces ? */ |
| 482 | if ('\0' == *cursor) |
| 483 | return -EINVAL; |
| 484 | |
| 485 | *arg = cursor; |
| 486 | |
| 487 | return 0; |
| 488 | } |
| 489 | |
| 490 | /** |
| 491 | * hdd_parse_ibsstx_fail_event_params - Parse params |
| 492 | * for SETIBSSTXFAILEVENT |
| 493 | * @command: Input ibss tx fail event argument |
| 494 | * @tx_fail_count: (Output parameter) Tx fail counter |
| 495 | * @pid: (Output parameter) PID |
| 496 | * |
| 497 | * Return: 0 if the parsing succeeds; -EINVAL otherwise |
| 498 | */ |
| 499 | static int hdd_parse_ibsstx_fail_event_params(uint8_t *command, |
| 500 | uint8_t *tx_fail_count, |
| 501 | uint16_t *pid) |
| 502 | { |
| 503 | uint8_t *param = NULL; |
| 504 | int ret; |
| 505 | |
| 506 | ret = hdd_parse_user_params(command, ¶m); |
| 507 | |
| 508 | if (0 == ret && param) { |
| 509 | if (1 != sscanf(param, "%hhu", tx_fail_count)) { |
| 510 | ret = -EINVAL; |
| 511 | goto done; |
| 512 | } |
| 513 | } else { |
| 514 | goto done; |
| 515 | } |
| 516 | |
| 517 | if (0 == *tx_fail_count) { |
| 518 | *pid = 0; |
| 519 | goto done; |
| 520 | } |
| 521 | |
| 522 | command = param; |
| 523 | command++; |
| 524 | |
| 525 | ret = hdd_parse_user_params(command, ¶m); |
| 526 | |
| 527 | if (0 == ret) { |
| 528 | if (1 != sscanf(param, "%hu", pid)) { |
| 529 | ret = -EINVAL; |
| 530 | goto done; |
| 531 | } |
| 532 | } else { |
| 533 | goto done; |
| 534 | } |
| 535 | |
| 536 | done: |
| 537 | return ret; |
| 538 | } |
| 539 | |
| 540 | /* Function header is left blank intentionally */ |
| 541 | static int hdd_parse_set_ibss_oui_data_command(uint8_t *command, uint8_t *ie, |
| 542 | int32_t *oui_length, int32_t limit) |
| 543 | { |
| 544 | uint8_t len; |
| 545 | uint8_t data; |
| 546 | |
| 547 | while ((SPACE_ASCII_VALUE == *command) && ('\0' != *command)) { |
| 548 | command++; |
| 549 | limit--; |
| 550 | } |
| 551 | |
| 552 | len = 2; |
| 553 | |
| 554 | while ((SPACE_ASCII_VALUE != *command) && ('\0' != *command) && |
| 555 | (limit > 1)) { |
| 556 | sscanf(command, "%02x", (unsigned int *)&data); |
| 557 | ie[len++] = data; |
| 558 | command += 2; |
| 559 | limit -= 2; |
| 560 | } |
| 561 | |
| 562 | *oui_length = len - 2; |
| 563 | |
| 564 | while ((SPACE_ASCII_VALUE == *command) && ('\0' != *command)) { |
| 565 | command++; |
| 566 | limit--; |
| 567 | } |
| 568 | |
| 569 | while ((SPACE_ASCII_VALUE != *command) && ('\0' != *command) && |
| 570 | (limit > 1)) { |
| 571 | sscanf(command, "%02x", (unsigned int *)&data); |
| 572 | ie[len++] = data; |
| 573 | command += 2; |
| 574 | limit -= 2; |
| 575 | } |
| 576 | |
| 577 | ie[0] = WLAN_ELEMID_VENDOR; |
| 578 | ie[1] = len - 2; |
| 579 | |
| 580 | return len; |
| 581 | } |
| 582 | |
| 583 | /** |
| 584 | * drv_cmd_set_ibss_beacon_oui_data() - set ibss oui data command |
| 585 | * @adapter: Pointer to adapter |
| 586 | * @hdd_ctx: Pointer to HDD context |
| 587 | * @command: Pointer to command string |
| 588 | * @command_len : Command length |
| 589 | * @priv_data : Pointer to priv data |
| 590 | * |
| 591 | * Return: |
| 592 | * int status code |
| 593 | */ |
| 594 | static int drv_cmd_set_ibss_beacon_oui_data(struct hdd_adapter *adapter, |
| 595 | struct hdd_context *hdd_ctx, |
| 596 | uint8_t *command, |
| 597 | uint8_t command_len, |
| 598 | struct hdd_priv_data *priv_data) |
| 599 | { |
| 600 | int i = 0; |
| 601 | int status; |
| 602 | int ret = 0; |
| 603 | uint8_t *ibss_ie; |
| 604 | int32_t oui_length = 0; |
| 605 | uint32_t ibss_ie_length; |
| 606 | uint8_t *value = command; |
| 607 | tSirModifyIE modify_ie; |
| 608 | struct csr_roam_profile *roam_profile; |
| 609 | mac_handle_t mac_handle; |
| 610 | |
| 611 | if (QDF_IBSS_MODE != adapter->device_mode) { |
| 612 | hdd_debug("Device_mode %s(%d) not IBSS", |
| 613 | qdf_opmode_str(adapter->device_mode), |
| 614 | adapter->device_mode); |
| 615 | return ret; |
| 616 | } |
| 617 | |
| 618 | hdd_debug("received command %s", ((char *)value)); |
| 619 | |
| 620 | /* validate argument of command */ |
| 621 | if (strlen(value) <= command_len) { |
| 622 | hdd_err("No arguments in command length %zu", |
| 623 | strlen(value)); |
| 624 | ret = -EFAULT; |
| 625 | goto exit; |
| 626 | } |
| 627 | |
| 628 | /* moving to arguments of commands */ |
| 629 | value = value + command_len; |
| 630 | command_len = strlen(value); |
| 631 | |
| 632 | /* oui_data can't be less than 3 bytes */ |
| 633 | if (command_len < (2 * WLAN_HDD_IBSS_MIN_OUI_DATA_LENGTH)) { |
| 634 | hdd_err("Invalid SETIBSSBEACONOUIDATA command length %d", |
| 635 | command_len); |
| 636 | ret = -EFAULT; |
| 637 | goto exit; |
| 638 | } |
| 639 | |
| 640 | ibss_ie = qdf_mem_malloc(command_len); |
| 641 | if (!ibss_ie) { |
| 642 | hdd_err("Could not allocate memory for command length %d", |
| 643 | command_len); |
| 644 | ret = -ENOMEM; |
| 645 | goto exit; |
| 646 | } |
| 647 | |
| 648 | ibss_ie_length = hdd_parse_set_ibss_oui_data_command(value, ibss_ie, |
| 649 | &oui_length, |
| 650 | command_len); |
| 651 | if (ibss_ie_length <= (2 * WLAN_HDD_IBSS_MIN_OUI_DATA_LENGTH)) { |
| 652 | hdd_err("Could not parse command %s return length %d", |
| 653 | value, ibss_ie_length); |
| 654 | ret = -EFAULT; |
| 655 | qdf_mem_free(ibss_ie); |
| 656 | goto exit; |
| 657 | } |
| 658 | |
| 659 | roam_profile = hdd_roam_profile(adapter); |
| 660 | |
| 661 | qdf_copy_macaddr(&modify_ie.bssid, |
| 662 | roam_profile->BSSIDs.bssid); |
| 663 | |
Abhishek Singh | 5a2c42f | 2019-11-19 11:39:23 +0530 | [diff] [blame] | 664 | modify_ie.vdev_id = adapter->vdev_id; |
Abhishek Ambure | 6867746 | 2019-09-13 12:44:26 +0530 | [diff] [blame] | 665 | modify_ie.notify = true; |
| 666 | modify_ie.ieID = WLAN_ELEMID_VENDOR; |
| 667 | modify_ie.ieIDLen = ibss_ie_length; |
| 668 | modify_ie.ieBufferlength = ibss_ie_length; |
| 669 | modify_ie.pIEBuffer = ibss_ie; |
| 670 | modify_ie.oui_length = oui_length; |
| 671 | |
| 672 | hdd_warn("ibss_ie length %d oui_length %d ibss_ie:", |
| 673 | ibss_ie_length, oui_length); |
| 674 | while (i < modify_ie.ieBufferlength) |
| 675 | hdd_warn("0x%x", ibss_ie[i++]); |
| 676 | |
| 677 | /* Probe Bcn modification */ |
| 678 | mac_handle = hdd_ctx->mac_handle; |
| 679 | sme_modify_add_ie(mac_handle, &modify_ie, eUPDATE_IE_PROBE_BCN); |
| 680 | |
| 681 | /* Populating probe resp frame */ |
| 682 | sme_modify_add_ie(mac_handle, &modify_ie, eUPDATE_IE_PROBE_RESP); |
| 683 | |
| 684 | qdf_mem_free(ibss_ie); |
| 685 | |
| 686 | status = sme_send_cesium_enable_ind(mac_handle, |
| 687 | adapter->vdev_id); |
| 688 | if (QDF_STATUS_SUCCESS != status) { |
| 689 | hdd_err("Could not send cesium enable indication %d", |
| 690 | status); |
| 691 | ret = -EINVAL; |
| 692 | goto exit; |
| 693 | } |
| 694 | |
| 695 | exit: |
| 696 | return ret; |
| 697 | } |
| 698 | |
| 699 | static int drv_cmd_get_ibss_peer_info_all(struct hdd_adapter *adapter, |
| 700 | struct hdd_context *hdd_ctx, |
| 701 | uint8_t *command, |
| 702 | uint8_t command_len, |
| 703 | struct hdd_priv_data *priv_data) |
| 704 | { |
| 705 | int ret = 0; |
| 706 | int status = QDF_STATUS_SUCCESS; |
| 707 | struct hdd_station_ctx *sta_ctx = NULL; |
| 708 | char *extra = NULL; |
| 709 | int idx = 0; |
| 710 | int length = 0; |
| 711 | uint8_t mac_addr[QDF_MAC_ADDR_SIZE]; |
| 712 | uint32_t print_break_index = 0; |
| 713 | |
| 714 | if (QDF_IBSS_MODE != adapter->device_mode) { |
| 715 | hdd_warn("Unsupported in mode %s(%d)", |
| 716 | qdf_opmode_str(adapter->device_mode), |
| 717 | adapter->device_mode); |
| 718 | return -EINVAL; |
| 719 | } |
| 720 | |
| 721 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 722 | hdd_debug("Received GETIBSSPEERINFOALL Command"); |
| 723 | |
| 724 | /* Handle the command */ |
| 725 | status = hdd_cfg80211_get_ibss_peer_info_all(adapter); |
| 726 | if (QDF_STATUS_SUCCESS == status) { |
| 727 | size_t user_size = qdf_min(WLAN_MAX_BUF_SIZE, |
| 728 | priv_data->total_len); |
| 729 | |
| 730 | /* |
| 731 | * The variable extra needed to be allocated on the heap since |
| 732 | * amount of memory required to copy the data for 32 devices |
| 733 | * exceeds the size of 1024 bytes of default stack size. On |
| 734 | * 64 bit devices, the default max stack size of 2048 bytes |
| 735 | */ |
| 736 | extra = qdf_mem_malloc(user_size); |
| 737 | |
| 738 | if (!extra) { |
| 739 | hdd_err("memory allocation failed"); |
| 740 | ret = -ENOMEM; |
| 741 | goto exit; |
| 742 | } |
| 743 | |
| 744 | /* Copy number of stations */ |
| 745 | length = scnprintf(extra, user_size, "%d ", |
| 746 | sta_ctx->ibss_peer_info.numPeers); |
| 747 | print_break_index = length; |
| 748 | for (idx = 0; idx < sta_ctx->ibss_peer_info.numPeers; |
| 749 | idx++) { |
| 750 | int8_t rssi; |
| 751 | uint32_t tx_rate; |
| 752 | |
| 753 | qdf_mem_copy(mac_addr, |
| 754 | sta_ctx->ibss_peer_info.peerInfoParams[idx]. |
| 755 | mac_addr, sizeof(mac_addr)); |
| 756 | |
| 757 | tx_rate = |
| 758 | sta_ctx->ibss_peer_info.peerInfoParams[idx]. |
| 759 | txRate; |
| 760 | /* |
| 761 | * Only lower 3 bytes are rate info. Mask of the MSByte |
| 762 | */ |
| 763 | tx_rate &= 0x00FFFFFF; |
| 764 | |
| 765 | rssi = sta_ctx->ibss_peer_info.peerInfoParams[idx]. |
| 766 | rssi; |
| 767 | |
| 768 | length += scnprintf(extra + length, |
| 769 | user_size - length, |
Srinivas Girigowda | 9cd4296 | 2020-08-31 18:37:54 -0700 | [diff] [blame] | 770 | QDF_FULL_MAC_FMT" %d %d ", |
| 771 | QDF_FULL_MAC_REF(mac_addr), |
Abhishek Ambure | 6867746 | 2019-09-13 12:44:26 +0530 | [diff] [blame] | 772 | tx_rate, rssi); |
| 773 | /* |
| 774 | * cdf_trace_msg has limitation of 512 bytes for the |
| 775 | * print buffer. Hence printing the data in two chunks. |
| 776 | * The first chunk will have the data for 16 devices |
| 777 | * and the second chunk will have the rest. |
| 778 | */ |
| 779 | if (idx < NUM_OF_STA_DATA_TO_PRINT) |
| 780 | print_break_index = length; |
| 781 | } |
| 782 | |
| 783 | /* |
| 784 | * Copy the data back into buffer, if the data to copy is |
| 785 | * more than 512 bytes than we will split the data and do |
| 786 | * it in two shots |
| 787 | */ |
| 788 | if (copy_to_user(priv_data->buf, extra, print_break_index)) { |
| 789 | hdd_err("Copy into user data buffer failed"); |
| 790 | ret = -EFAULT; |
| 791 | goto mem_free; |
| 792 | } |
| 793 | |
| 794 | /* This overwrites the last space, which we already copied */ |
| 795 | extra[print_break_index - 1] = '\0'; |
| 796 | hdd_debug("%s", extra); |
| 797 | |
| 798 | if (length > print_break_index) { |
| 799 | if (copy_to_user |
| 800 | (priv_data->buf + print_break_index, |
| 801 | extra + print_break_index, |
| 802 | length - print_break_index + 1)) { |
| 803 | hdd_err("Copy into user data buffer failed"); |
| 804 | ret = -EFAULT; |
| 805 | goto mem_free; |
| 806 | } |
| 807 | hdd_debug("%s", &extra[print_break_index]); |
| 808 | } |
| 809 | } else { |
| 810 | /* Command failed, log error */ |
| 811 | hdd_err("GETIBSSPEERINFOALL command failed with status code %d", |
| 812 | status); |
| 813 | ret = -EINVAL; |
| 814 | goto exit; |
| 815 | } |
| 816 | ret = 0; |
| 817 | |
| 818 | mem_free: |
| 819 | qdf_mem_free(extra); |
| 820 | exit: |
| 821 | return ret; |
| 822 | } |
| 823 | |
| 824 | /* Peer Info <Peer Addr> command */ |
| 825 | static int drv_cmd_get_ibss_peer_info(struct hdd_adapter *adapter, |
| 826 | struct hdd_context *hdd_ctx, |
| 827 | uint8_t *command, |
| 828 | uint8_t command_len, |
| 829 | struct hdd_priv_data *priv_data) |
| 830 | { |
| 831 | int ret = 0; |
| 832 | uint8_t *value = command; |
| 833 | QDF_STATUS status; |
| 834 | struct hdd_station_ctx *sta_ctx = NULL; |
| 835 | char extra[128] = { 0 }; |
| 836 | uint32_t length = 0; |
Abhishek Ambure | 6867746 | 2019-09-13 12:44:26 +0530 | [diff] [blame] | 837 | struct qdf_mac_addr peer_macaddr; |
| 838 | |
| 839 | if (QDF_IBSS_MODE != adapter->device_mode) { |
| 840 | hdd_warn("Unsupported in mode %s(%d)", |
| 841 | qdf_opmode_str(adapter->device_mode), |
| 842 | adapter->device_mode); |
| 843 | return -EINVAL; |
| 844 | } |
| 845 | |
| 846 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 847 | |
| 848 | hdd_debug("Received GETIBSSPEERINFO Command"); |
| 849 | |
| 850 | /* if there are no peers, no need to continue with the command */ |
| 851 | if (eConnectionState_IbssConnected != |
| 852 | sta_ctx->conn_info.conn_state) { |
| 853 | hdd_err("No IBSS Peers coalesced"); |
| 854 | ret = -EINVAL; |
| 855 | goto exit; |
| 856 | } |
| 857 | |
| 858 | /* Parse the incoming command buffer */ |
| 859 | status = hdd_parse_get_ibss_peer_info(value, &peer_macaddr); |
| 860 | if (QDF_STATUS_SUCCESS != status) { |
| 861 | hdd_err("Invalid GETIBSSPEERINFO command"); |
| 862 | ret = -EINVAL; |
| 863 | goto exit; |
| 864 | } |
| 865 | |
Abhishek Ambure | 6867746 | 2019-09-13 12:44:26 +0530 | [diff] [blame] | 866 | /* Handle the command */ |
Sourav Mohapatra | a3cf12a | 2019-08-19 15:40:49 +0530 | [diff] [blame] | 867 | status = hdd_cfg80211_get_ibss_peer_info(adapter, peer_macaddr.bytes); |
Abhishek Ambure | 6867746 | 2019-09-13 12:44:26 +0530 | [diff] [blame] | 868 | if (QDF_STATUS_SUCCESS == status) { |
| 869 | uint32_t tx_rate = |
| 870 | sta_ctx->ibss_peer_info.peerInfoParams[0].txRate; |
| 871 | /* Only lower 3 bytes are rate info. Mask of the MSByte */ |
| 872 | tx_rate &= 0x00FFFFFF; |
| 873 | |
| 874 | length = scnprintf(extra, sizeof(extra), "%d %d", |
| 875 | (int)tx_rate, |
| 876 | (int)sta_ctx->ibss_peer_info. |
| 877 | peerInfoParams[0].rssi); |
| 878 | length = QDF_MIN(priv_data->total_len, length + 1); |
| 879 | |
| 880 | /* Copy the data back into buffer */ |
| 881 | if (copy_to_user(priv_data->buf, &extra, length)) { |
| 882 | hdd_err("copy data to user buffer failed GETIBSSPEERINFO command"); |
| 883 | ret = -EFAULT; |
| 884 | goto exit; |
| 885 | } |
| 886 | } else { |
| 887 | /* Command failed, log error */ |
| 888 | hdd_err("GETIBSSPEERINFO command failed with status code %d", |
| 889 | status); |
| 890 | ret = -EINVAL; |
| 891 | goto exit; |
| 892 | } |
| 893 | |
| 894 | /* Success ! */ |
| 895 | hdd_debug("%s", extra); |
| 896 | ret = 0; |
| 897 | |
| 898 | exit: |
| 899 | return ret; |
| 900 | } |
| 901 | |
| 902 | static int drv_cmd_set_ibss_tx_fail_event(struct hdd_adapter *adapter, |
| 903 | struct hdd_context *hdd_ctx, |
| 904 | uint8_t *command, |
| 905 | uint8_t command_len, |
| 906 | struct hdd_priv_data *priv_data) |
| 907 | { |
| 908 | int ret = 0; |
| 909 | char *value; |
| 910 | uint8_t tx_fail_count = 0; |
| 911 | uint16_t pid = 0; |
| 912 | mac_handle_t mac_handle; |
| 913 | |
| 914 | value = command; |
| 915 | |
| 916 | ret = hdd_parse_ibsstx_fail_event_params(value, &tx_fail_count, &pid); |
| 917 | |
| 918 | if (0 != ret) { |
| 919 | hdd_err("Failed to parse SETIBSSTXFAILEVENT arguments"); |
| 920 | goto exit; |
| 921 | } |
| 922 | |
| 923 | hdd_debug("tx_fail_cnt=%hhu, pid=%hu", tx_fail_count, pid); |
| 924 | mac_handle = hdd_ctx->mac_handle; |
| 925 | |
| 926 | if (0 == tx_fail_count) { |
| 927 | /* Disable TX Fail Indication */ |
| 928 | if (QDF_STATUS_SUCCESS == |
| 929 | sme_tx_fail_monitor_start_stop_ind(mac_handle, |
| 930 | tx_fail_count, |
| 931 | NULL)) { |
| 932 | cesium_pid = 0; |
| 933 | } else { |
| 934 | hdd_err("failed to disable TX Fail Event"); |
| 935 | ret = -EINVAL; |
| 936 | } |
| 937 | } else { |
| 938 | if (QDF_STATUS_SUCCESS == |
| 939 | sme_tx_fail_monitor_start_stop_ind(mac_handle, |
| 940 | tx_fail_count, |
| 941 | (void *)hdd_tx_fail_ind_callback)) { |
| 942 | cesium_pid = pid; |
| 943 | hdd_debug("Registered Cesium pid %u", |
| 944 | cesium_pid); |
| 945 | } else { |
| 946 | hdd_err("Failed to enable TX Fail Monitoring"); |
| 947 | ret = -EINVAL; |
| 948 | } |
| 949 | } |
| 950 | |
| 951 | exit: |
| 952 | return ret; |
| 953 | } |
| 954 | #else |
| 955 | /** |
| 956 | * drv_cmd_get_ibss_peer_info() - get ibss peer info all |
| 957 | * @adapter: Pointer to adapter |
| 958 | * @hdd_ctx: Pointer to HDD context |
| 959 | * @command: Pointer to command string |
| 960 | * @command_len : Command length |
| 961 | * @priv_data : Pointer to priv data |
| 962 | * |
| 963 | * This function is dummy |
| 964 | * |
| 965 | * Return: 0 |
| 966 | */ |
| 967 | static inline int |
| 968 | drv_cmd_get_ibss_peer_info_all(struct hdd_adapter *adapter, |
| 969 | struct hdd_context *hdd_ctx, |
| 970 | uint8_t *command, |
| 971 | uint8_t command_len, |
| 972 | struct hdd_priv_data *priv_data) |
| 973 | { |
| 974 | return 0; |
| 975 | } |
| 976 | |
| 977 | /** |
| 978 | * drv_cmd_get_ibss_peer_info() - get ibss peer info |
| 979 | * @adapter: Pointer to adapter |
| 980 | * @hdd_ctx: Pointer to HDD context |
| 981 | * @command: Pointer to command string |
| 982 | * @command_len : Command length |
| 983 | * @priv_data : Pointer to priv data |
| 984 | * |
| 985 | * This function is dummy |
| 986 | * |
| 987 | * Return: 0 |
| 988 | */ |
| 989 | static inline int |
| 990 | drv_cmd_get_ibss_peer_info(struct hdd_adapter *adapter, |
| 991 | struct hdd_context *hdd_ctx, |
| 992 | uint8_t *command, |
| 993 | uint8_t command_len, |
| 994 | struct hdd_priv_data *priv_data) |
| 995 | { |
| 996 | return 0; |
| 997 | } |
| 998 | |
| 999 | /** |
| 1000 | * drv_cmd_set_ibss_tx_fail_event() - set ibss tx fail event |
| 1001 | * @adapter: Pointer to adapter |
| 1002 | * @hdd_ctx: Pointer to HDD context |
| 1003 | * @command: Pointer to command string |
| 1004 | * @command_len : Command length |
| 1005 | * @priv_data : Pointer to priv data |
| 1006 | * |
| 1007 | * This function is dummy |
| 1008 | * |
| 1009 | * Return: 0 |
| 1010 | */ |
| 1011 | static inline int |
| 1012 | drv_cmd_set_ibss_tx_fail_event(struct hdd_adapter *adapter, |
| 1013 | struct hdd_context *hdd_ctx, |
| 1014 | uint8_t *command, |
| 1015 | uint8_t command_len, |
| 1016 | struct hdd_priv_data *priv_data) |
| 1017 | { |
| 1018 | return 0; |
| 1019 | } |
| 1020 | |
| 1021 | /** |
| 1022 | * drv_cmd_set_ibss_beacon_oui_data() - set ibss oui data command |
| 1023 | * @adapter: Pointer to adapter |
| 1024 | * @hdd_ctx: Pointer to HDD context |
| 1025 | * @command: Pointer to command string |
| 1026 | * @command_len : Command length |
| 1027 | * @priv_data : Pointer to priv data |
| 1028 | * |
| 1029 | * This function is dummy |
| 1030 | * |
| 1031 | * Return: 0 |
| 1032 | */ |
| 1033 | static inline int |
| 1034 | drv_cmd_set_ibss_beacon_oui_data(struct hdd_adapter *adapter, |
| 1035 | struct hdd_context *hdd_ctx, |
| 1036 | uint8_t *command, |
| 1037 | uint8_t command_len, |
| 1038 | struct hdd_priv_data *priv_data) |
| 1039 | { |
| 1040 | return 0; |
| 1041 | } |
| 1042 | #endif |
| 1043 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1044 | 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] | 1045 | { |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1046 | enum band_info band = -1; |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 1047 | |
Harprit Chhabada | 5dff30e | 2019-03-12 17:56:45 -0700 | [diff] [blame] | 1048 | ucfg_reg_get_band(hdd_ctx->pdev, &band); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1049 | switch (band) { |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1050 | case BAND_ALL: |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1051 | *ui_band = WLAN_HDD_UI_BAND_AUTO; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1052 | break; |
| 1053 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1054 | case BAND_2G: |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1055 | *ui_band = WLAN_HDD_UI_BAND_2_4_GHZ; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1056 | break; |
| 1057 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1058 | case BAND_5G: |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1059 | *ui_band = WLAN_HDD_UI_BAND_5_GHZ; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1060 | break; |
| 1061 | |
| 1062 | default: |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1063 | hdd_warn("Invalid Band %d", band); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1064 | *ui_band = -1; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1065 | break; |
| 1066 | } |
| 1067 | } |
| 1068 | |
| 1069 | /** |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 1070 | * hdd_check_and_fill_freq() - to validate chan and convert into freq |
| 1071 | * @in_chan: input as channel number or freq to be checked |
| 1072 | * @freq: frequency for input in_chan (output parameter) |
| 1073 | * |
| 1074 | * This function checks input "in_chan" is channel number, if yes then fills |
| 1075 | * appropriate frequency into "freq" out param. If the "in_param" is greater |
| 1076 | * than WNI_CFG_CURRENT_CHANNEL_STAMAX then checks for valid frequencies. |
| 1077 | * |
| 1078 | * Return: true if "in_chan" is valid channel/frequency; false otherwise |
| 1079 | */ |
| 1080 | static bool hdd_check_and_fill_freq(uint32_t in_chan, qdf_freq_t *freq) |
| 1081 | { |
| 1082 | if (in_chan <= WNI_CFG_CURRENT_CHANNEL_STAMAX) |
| 1083 | *freq = wlan_chan_to_freq(in_chan); |
| 1084 | else if (WLAN_REG_IS_24GHZ_CH_FREQ(in_chan) || |
| 1085 | WLAN_REG_IS_5GHZ_CH_FREQ(in_chan) || |
| 1086 | WLAN_REG_IS_6GHZ_CHAN_FREQ(in_chan)) |
| 1087 | *freq = in_chan; |
| 1088 | else |
| 1089 | return false; |
| 1090 | |
| 1091 | return true; |
| 1092 | } |
| 1093 | |
| 1094 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1095 | * _hdd_parse_bssid_and_chan() - helper function to parse bssid and channel |
| 1096 | * @data: input data |
| 1097 | * @target_ap_bssid: pointer to bssid (output parameter) |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 1098 | * @freq: pointer to freq (output parameter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1099 | * |
| 1100 | * Return: 0 if parsing is successful; -EINVAL otherwise |
| 1101 | */ |
| 1102 | static int _hdd_parse_bssid_and_chan(const uint8_t **data, |
| 1103 | uint8_t *bssid, |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 1104 | qdf_freq_t *freq) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1105 | { |
| 1106 | const uint8_t *in_ptr; |
| 1107 | int v = 0; |
| 1108 | int temp_int; |
| 1109 | uint8_t temp_buf[32]; |
| 1110 | |
| 1111 | /* 12 hexa decimal digits, 5 ':' and '\0' */ |
| 1112 | uint8_t mac_addr[18]; |
| 1113 | |
| 1114 | if (!data || !*data) |
| 1115 | return -EINVAL; |
| 1116 | |
| 1117 | in_ptr = *data; |
| 1118 | |
| 1119 | in_ptr = strnchr(in_ptr, strlen(in_ptr), SPACE_ASCII_VALUE); |
| 1120 | /* no argument after the command */ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 1121 | if (!in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1122 | goto error; |
| 1123 | /* no space after the command */ |
| 1124 | else if (SPACE_ASCII_VALUE != *in_ptr) |
| 1125 | goto error; |
| 1126 | |
| 1127 | /* remove empty spaces */ |
| 1128 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 1129 | in_ptr++; |
| 1130 | |
| 1131 | /* no argument followed by spaces */ |
| 1132 | if ('\0' == *in_ptr) |
| 1133 | goto error; |
| 1134 | |
| 1135 | v = sscanf(in_ptr, "%17s", mac_addr); |
| 1136 | if (!((1 == v) && hdd_is_valid_mac_address(mac_addr))) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1137 | hdd_err("Invalid MAC address or All hex inputs are not read (%d)", |
| 1138 | v); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1139 | goto error; |
| 1140 | } |
| 1141 | |
| 1142 | bssid[0] = hex_to_bin(mac_addr[0]) << 4 | |
| 1143 | hex_to_bin(mac_addr[1]); |
| 1144 | bssid[1] = hex_to_bin(mac_addr[3]) << 4 | |
| 1145 | hex_to_bin(mac_addr[4]); |
| 1146 | bssid[2] = hex_to_bin(mac_addr[6]) << 4 | |
| 1147 | hex_to_bin(mac_addr[7]); |
| 1148 | bssid[3] = hex_to_bin(mac_addr[9]) << 4 | |
| 1149 | hex_to_bin(mac_addr[10]); |
| 1150 | bssid[4] = hex_to_bin(mac_addr[12]) << 4 | |
| 1151 | hex_to_bin(mac_addr[13]); |
| 1152 | bssid[5] = hex_to_bin(mac_addr[15]) << 4 | |
| 1153 | hex_to_bin(mac_addr[16]); |
| 1154 | |
| 1155 | /* point to the next argument */ |
| 1156 | in_ptr = strnchr(in_ptr, strlen(in_ptr), SPACE_ASCII_VALUE); |
| 1157 | /* no argument after the command */ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 1158 | if (!in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1159 | goto error; |
| 1160 | |
| 1161 | /* remove empty spaces */ |
| 1162 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 1163 | in_ptr++; |
| 1164 | |
| 1165 | /* no argument followed by spaces */ |
| 1166 | if ('\0' == *in_ptr) |
| 1167 | goto error; |
| 1168 | |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 1169 | /* get the next argument ie the channel/freq number */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1170 | v = sscanf(in_ptr, "%31s ", temp_buf); |
| 1171 | if (1 != v) |
| 1172 | goto error; |
| 1173 | |
| 1174 | v = kstrtos32(temp_buf, 10, &temp_int); |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 1175 | if (v < 0 || temp_int < 0) |
| 1176 | goto error; |
| 1177 | else if (!hdd_check_and_fill_freq(temp_int, freq)) |
| 1178 | goto error; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1179 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1180 | *data = in_ptr; |
| 1181 | return 0; |
| 1182 | error: |
| 1183 | *data = in_ptr; |
| 1184 | return -EINVAL; |
| 1185 | } |
| 1186 | |
| 1187 | /** |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 1188 | * hdd_parse_send_action_frame_v1_data() - HDD Parse send action frame data |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 1189 | * @command: Pointer to input data |
Jeff Johnson | b7d5279 | 2019-02-26 12:42:08 -0800 | [diff] [blame] | 1190 | * @bssid: Pointer to target Ap bssid |
Jeff Johnson | d727cdc | 2019-02-26 12:47:05 -0800 | [diff] [blame] | 1191 | * @channel: Pointer to the Target AP channel |
Jeff Johnson | 80d220a | 2019-02-26 12:27:24 -0800 | [diff] [blame] | 1192 | * @dwell_time: Pointer to the time to stay off-channel |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 1193 | * after transmitting action frame |
Jeff Johnson | 5f3a612 | 2019-02-26 17:20:59 -0800 | [diff] [blame] | 1194 | * @buf: Pointer to data |
Jeff Johnson | 103f67a | 2019-02-26 17:11:01 -0800 | [diff] [blame] | 1195 | * @buf_len: Pointer to data length |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1196 | * |
| 1197 | * This function parses the send action frame data passed in the format |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 1198 | * SENDACTIONFRAME<space><bssid><space><channel | frequency><space><dwelltime> |
| 1199 | * <space><data> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1200 | * |
| 1201 | * Return: 0 for success non-zero for failure |
| 1202 | */ |
| 1203 | static int |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 1204 | hdd_parse_send_action_frame_v1_data(const uint8_t *command, |
Jeff Johnson | b7d5279 | 2019-02-26 12:42:08 -0800 | [diff] [blame] | 1205 | uint8_t *bssid, |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 1206 | qdf_freq_t *freq, uint8_t *dwell_time, |
Jeff Johnson | 5f3a612 | 2019-02-26 17:20:59 -0800 | [diff] [blame] | 1207 | uint8_t **buf, uint8_t *buf_len) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1208 | { |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1209 | const uint8_t *in_ptr = command; |
Jeff Johnson | aae00ae | 2019-02-26 17:25:11 -0800 | [diff] [blame] | 1210 | const uint8_t *end_ptr; |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 1211 | int temp_int; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1212 | int j = 0; |
| 1213 | int i = 0; |
| 1214 | int v = 0; |
Jeff Johnson | 72f498b | 2019-02-26 18:37:25 -0800 | [diff] [blame] | 1215 | uint8_t temp_buf[32]; |
| 1216 | uint8_t temp_u8 = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1217 | |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 1218 | if (_hdd_parse_bssid_and_chan(&in_ptr, bssid, freq)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1219 | return -EINVAL; |
| 1220 | |
| 1221 | /* point to the next argument */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1222 | in_ptr = strnchr(in_ptr, strlen(in_ptr), SPACE_ASCII_VALUE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1223 | /* no argument after the command */ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 1224 | if (!in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1225 | return -EINVAL; |
| 1226 | /* removing empty spaces */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1227 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 1228 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1229 | |
| 1230 | /* no argument followed by spaces */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1231 | if ('\0' == *in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1232 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1233 | |
| 1234 | /* getting the next argument ie the dwell time */ |
Jeff Johnson | 72f498b | 2019-02-26 18:37:25 -0800 | [diff] [blame] | 1235 | v = sscanf(in_ptr, "%31s ", temp_buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1236 | if (1 != v) |
| 1237 | return -EINVAL; |
| 1238 | |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 1239 | v = kstrtos32(temp_buf, 10, &temp_int); |
| 1240 | if (v < 0 || temp_int < 0) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1241 | return -EINVAL; |
| 1242 | |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 1243 | *dwell_time = temp_int; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1244 | |
| 1245 | /* point to the next argument */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1246 | in_ptr = strnchr(in_ptr, strlen(in_ptr), SPACE_ASCII_VALUE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1247 | /* no argument after the command */ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 1248 | if (!in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1249 | return -EINVAL; |
| 1250 | /* removing empty spaces */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1251 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 1252 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1253 | |
| 1254 | /* no argument followed by spaces */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1255 | if ('\0' == *in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1256 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1257 | |
| 1258 | /* find the length of data */ |
Jeff Johnson | aae00ae | 2019-02-26 17:25:11 -0800 | [diff] [blame] | 1259 | end_ptr = in_ptr; |
| 1260 | while (('\0' != *end_ptr)) |
| 1261 | end_ptr++; |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 1262 | |
Jeff Johnson | aae00ae | 2019-02-26 17:25:11 -0800 | [diff] [blame] | 1263 | *buf_len = end_ptr - in_ptr; |
Jeff Johnson | 103f67a | 2019-02-26 17:11:01 -0800 | [diff] [blame] | 1264 | if (*buf_len <= 0) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1265 | return -EINVAL; |
| 1266 | |
| 1267 | /* |
| 1268 | * Allocate the number of bytes based on the number of input characters |
| 1269 | * whether it is even or odd. |
| 1270 | * if the number of input characters are even, then we need N/2 byte. |
| 1271 | * if the number of input characters are odd, then we need do (N+1)/2 |
| 1272 | * to compensate rounding off. |
| 1273 | * For example, if N = 18, then (18 + 1)/2 = 9 bytes are enough. |
| 1274 | * If N = 19, then we need 10 bytes, hence (19 + 1)/2 = 10 bytes |
| 1275 | */ |
Jeff Johnson | 5f3a612 | 2019-02-26 17:20:59 -0800 | [diff] [blame] | 1276 | *buf = qdf_mem_malloc((*buf_len + 1) / 2); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 1277 | if (!*buf) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1278 | hdd_err("qdf_mem_malloc failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1279 | return -ENOMEM; |
| 1280 | } |
| 1281 | |
| 1282 | /* the buffer received from the upper layer is character buffer, |
| 1283 | * we need to prepare the buffer taking 2 characters in to a U8 hex |
| 1284 | * decimal number for example 7f0000f0...form a buffer to contain 7f |
| 1285 | * in 0th location, 00 in 1st and f0 in 3rd location |
| 1286 | */ |
Jeff Johnson | 103f67a | 2019-02-26 17:11:01 -0800 | [diff] [blame] | 1287 | for (i = 0, j = 0; j < *buf_len; j += 2) { |
| 1288 | if (j + 1 == *buf_len) { |
Jeff Johnson | 72f498b | 2019-02-26 18:37:25 -0800 | [diff] [blame] | 1289 | temp_u8 = hex_to_bin(in_ptr[j]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1290 | } else { |
Jeff Johnson | 72f498b | 2019-02-26 18:37:25 -0800 | [diff] [blame] | 1291 | temp_u8 = |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1292 | (hex_to_bin(in_ptr[j]) << 4) | |
| 1293 | (hex_to_bin(in_ptr[j + 1])); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1294 | } |
Jeff Johnson | 72f498b | 2019-02-26 18:37:25 -0800 | [diff] [blame] | 1295 | (*buf)[i++] = temp_u8; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1296 | } |
Jeff Johnson | 103f67a | 2019-02-26 17:11:01 -0800 | [diff] [blame] | 1297 | *buf_len = i; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1298 | return 0; |
| 1299 | } |
| 1300 | |
| 1301 | /** |
| 1302 | * hdd_parse_reassoc_command_data() - HDD Parse reassoc command data |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 1303 | * @command: Pointer to input data (its a NULL terminated string) |
Jeff Johnson | b7d5279 | 2019-02-26 12:42:08 -0800 | [diff] [blame] | 1304 | * @bssid: Pointer to target Ap bssid |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 1305 | * @freq: Pointer to the Target AP frequency |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1306 | * |
| 1307 | * This function parses the reasoc command data passed in the format |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 1308 | * REASSOC<space><bssid><space><channel/frequency> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1309 | * |
| 1310 | * Return: 0 for success non-zero for failure |
| 1311 | */ |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 1312 | static int hdd_parse_reassoc_command_v1_data(const uint8_t *command, |
Jeff Johnson | b7d5279 | 2019-02-26 12:42:08 -0800 | [diff] [blame] | 1313 | uint8_t *bssid, |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 1314 | qdf_freq_t *freq) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1315 | { |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1316 | const uint8_t *in_ptr = command; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1317 | |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 1318 | if (_hdd_parse_bssid_and_chan(&in_ptr, bssid, freq)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1319 | return -EINVAL; |
| 1320 | |
| 1321 | return 0; |
| 1322 | } |
| 1323 | |
Naveen Rawat | 05376ee | 2016-07-18 16:43:32 -0700 | [diff] [blame] | 1324 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
Abhinav Kumar | eab2593 | 2018-07-13 11:48:43 +0530 | [diff] [blame] | 1325 | QDF_STATUS hdd_wma_send_fastreassoc_cmd(struct hdd_adapter *adapter, |
| 1326 | const tSirMacAddr bssid, |
Manikandan Mohan | 5c1e9ae | 2019-10-23 15:45:35 -0700 | [diff] [blame] | 1327 | uint32_t ch_freq) |
Naveen Rawat | 05376ee | 2016-07-18 16:43:32 -0700 | [diff] [blame] | 1328 | { |
Krunal Soni | 332f4af | 2017-06-01 14:36:17 -0700 | [diff] [blame] | 1329 | struct hdd_station_ctx *hdd_sta_ctx = |
| 1330 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | 8313b9d | 2018-03-14 15:09:28 -0700 | [diff] [blame] | 1331 | struct csr_roam_profile *roam_profile; |
Krunal Soni | 332f4af | 2017-06-01 14:36:17 -0700 | [diff] [blame] | 1332 | tSirMacAddr connected_bssid; |
Naveen Rawat | 05376ee | 2016-07-18 16:43:32 -0700 | [diff] [blame] | 1333 | |
Jeff Johnson | 8313b9d | 2018-03-14 15:09:28 -0700 | [diff] [blame] | 1334 | roam_profile = hdd_roam_profile(adapter); |
Jeff Johnson | e04b699 | 2019-02-27 14:06:55 -0800 | [diff] [blame] | 1335 | qdf_mem_copy(connected_bssid, hdd_sta_ctx->conn_info.bssid.bytes, |
Krunal Soni | 332f4af | 2017-06-01 14:36:17 -0700 | [diff] [blame] | 1336 | ETH_ALEN); |
Abhinav Kumar | eab2593 | 2018-07-13 11:48:43 +0530 | [diff] [blame] | 1337 | return sme_fast_reassoc(adapter->hdd_ctx->mac_handle, |
Manikandan Mohan | 5c1e9ae | 2019-10-23 15:45:35 -0700 | [diff] [blame] | 1338 | roam_profile, bssid, ch_freq, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 1339 | adapter->vdev_id, connected_bssid); |
Naveen Rawat | 05376ee | 2016-07-18 16:43:32 -0700 | [diff] [blame] | 1340 | } |
Naveen Rawat | 05376ee | 2016-07-18 16:43:32 -0700 | [diff] [blame] | 1341 | #endif |
| 1342 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 1343 | int hdd_reassoc(struct hdd_adapter *adapter, const uint8_t *bssid, |
Manikandan Mohan | 5c1e9ae | 2019-10-23 15:45:35 -0700 | [diff] [blame] | 1344 | uint32_t ch_freq, const handoff_src src) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1345 | { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 1346 | struct hdd_station_ctx *sta_ctx; |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 1347 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1348 | int ret = 0; |
Abhinav Kumar | eab2593 | 2018-07-13 11:48:43 +0530 | [diff] [blame] | 1349 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1350 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 1351 | if (!hdd_ctx) { |
Naveen Rawat | 05376ee | 2016-07-18 16:43:32 -0700 | [diff] [blame] | 1352 | hdd_err("Invalid hdd ctx"); |
| 1353 | return -EINVAL; |
| 1354 | } |
| 1355 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 1356 | if (QDF_STA_MODE != adapter->device_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1357 | hdd_warn("Unsupported in mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 1358 | qdf_opmode_str(adapter->device_mode), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1359 | adapter->device_mode); |
| 1360 | return -EINVAL; |
| 1361 | } |
| 1362 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 1363 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1364 | |
Vignesh Viswanathan | 7c43a7a | 2018-09-24 15:52:47 +0530 | [diff] [blame] | 1365 | /* |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 1366 | * pHddStaCtx->conn_info.conn_state is set to disconnected only |
Vignesh Viswanathan | 7c43a7a | 2018-09-24 15:52:47 +0530 | [diff] [blame] | 1367 | * after the disconnect done indication from SME. If the SME is |
| 1368 | * in the process of disconnecting, the SME Connection state is |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 1369 | * set to disconnected and the pHddStaCtx->conn_info.conn_state |
Vignesh Viswanathan | 7c43a7a | 2018-09-24 15:52:47 +0530 | [diff] [blame] | 1370 | * will still be associated till the disconnect is done. |
| 1371 | * So check both the HDD state and SME state here. |
| 1372 | * If not associated, no need to proceed with reassoc |
| 1373 | */ |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 1374 | if ((eConnectionState_Associated != sta_ctx->conn_info.conn_state) || |
Vignesh Viswanathan | 7c43a7a | 2018-09-24 15:52:47 +0530 | [diff] [blame] | 1375 | (!sme_is_conn_state_connected(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 1376 | adapter->vdev_id))) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 1377 | hdd_warn("Not associated"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1378 | ret = -EINVAL; |
| 1379 | goto exit; |
| 1380 | } |
| 1381 | |
| 1382 | /* |
| 1383 | * if the target bssid is same as currently associated AP, |
Deepak Dhamdhere | 5a36a4a | 2016-11-12 15:08:22 -0800 | [diff] [blame] | 1384 | * use the current connections's channel. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1385 | */ |
Jeff Johnson | e04b699 | 2019-02-27 14:06:55 -0800 | [diff] [blame] | 1386 | if (!memcmp(bssid, sta_ctx->conn_info.bssid.bytes, |
Manikandan Mohan | 5c1e9ae | 2019-10-23 15:45:35 -0700 | [diff] [blame] | 1387 | QDF_MAC_ADDR_SIZE)) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 1388 | hdd_warn("Reassoc BSSID is same as currently associated AP bssid"); |
Manikandan Mohan | 5c1e9ae | 2019-10-23 15:45:35 -0700 | [diff] [blame] | 1389 | ch_freq = sta_ctx->conn_info.chan_freq; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1390 | } |
| 1391 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1392 | if (QDF_STATUS_SUCCESS != |
Manikandan Mohan | 5c1e9ae | 2019-10-23 15:45:35 -0700 | [diff] [blame] | 1393 | wlan_hdd_validate_operation_channel(adapter, ch_freq)) { |
| 1394 | hdd_err("Invalid Ch freq: %d", ch_freq); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1395 | ret = -EINVAL; |
| 1396 | goto exit; |
| 1397 | } |
| 1398 | |
| 1399 | /* Proceed with reassoc */ |
Naveen Rawat | 05376ee | 2016-07-18 16:43:32 -0700 | [diff] [blame] | 1400 | if (roaming_offload_enabled(hdd_ctx)) { |
Manikandan Mohan | 5c1e9ae | 2019-10-23 15:45:35 -0700 | [diff] [blame] | 1401 | status = hdd_wma_send_fastreassoc_cmd(adapter, bssid, ch_freq); |
Abhinav Kumar | eab2593 | 2018-07-13 11:48:43 +0530 | [diff] [blame] | 1402 | if (status != QDF_STATUS_SUCCESS) { |
| 1403 | hdd_err("Failed to send fast reassoc cmd"); |
| 1404 | ret = -EINVAL; |
| 1405 | } |
Naveen Rawat | 05376ee | 2016-07-18 16:43:32 -0700 | [diff] [blame] | 1406 | } else { |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1407 | tCsrHandoffRequest handoff; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1408 | |
Manikandan Mohan | 5c1e9ae | 2019-10-23 15:45:35 -0700 | [diff] [blame] | 1409 | handoff.ch_freq = ch_freq; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1410 | handoff.src = src; |
| 1411 | qdf_mem_copy(handoff.bssid.bytes, bssid, QDF_MAC_ADDR_SIZE); |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 1412 | sme_handoff_request(hdd_ctx->mac_handle, adapter->vdev_id, |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1413 | &handoff); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1414 | } |
| 1415 | exit: |
| 1416 | return ret; |
| 1417 | } |
| 1418 | |
| 1419 | /** |
| 1420 | * hdd_parse_reassoc_v1() - parse version 1 of the REASSOC command |
| 1421 | * @adapter: Adapter upon which the command was received |
| 1422 | * @command: ASCII text command that was received |
| 1423 | * |
| 1424 | * This function parses the v1 REASSOC command with the format |
| 1425 | * |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 1426 | * REASSOC xx:xx:xx:xx:xx:xx CH/FREQ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1427 | * |
| 1428 | * Where "xx:xx:xx:xx:xx:xx" is the Hex-ASCII representation of the |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 1429 | * BSSID and CH/FREQ is the ASCII representation of the channel/frequency. |
| 1430 | * For example |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1431 | * |
| 1432 | * REASSOC 00:0a:0b:11:22:33 48 |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 1433 | * REASSOC 00:0a:0b:11:22:33 2412 |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1434 | * |
| 1435 | * Return: 0 for success non-zero for failure |
| 1436 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 1437 | 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] | 1438 | { |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 1439 | qdf_freq_t freq = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1440 | tSirMacAddr bssid; |
| 1441 | int ret; |
| 1442 | |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 1443 | ret = hdd_parse_reassoc_command_v1_data(command, bssid, &freq); |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 1444 | if (ret) |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1445 | hdd_err("Failed to parse reassoc command data"); |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 1446 | else |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 1447 | ret = hdd_reassoc(adapter, bssid, freq, REASSOC); |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 1448 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1449 | return ret; |
| 1450 | } |
| 1451 | |
| 1452 | /** |
| 1453 | * hdd_parse_reassoc_v2() - parse version 2 of the REASSOC command |
| 1454 | * @adapter: Adapter upon which the command was received |
| 1455 | * @command: Command that was received, ASCII command |
Jeff Johnson | 560dc56 | 2017-03-17 15:19:31 -0700 | [diff] [blame] | 1456 | * followed by binary data |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 1457 | * @total_len: Total length of the command received |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1458 | * |
| 1459 | * This function parses the v2 REASSOC command with the format |
| 1460 | * |
| 1461 | * REASSOC <android_wifi_reassoc_params> |
| 1462 | * |
| 1463 | * Return: 0 for success non-zero for failure |
| 1464 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 1465 | static int hdd_parse_reassoc_v2(struct hdd_adapter *adapter, |
| 1466 | const char *command, |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 1467 | int total_len) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1468 | { |
| 1469 | struct android_wifi_reassoc_params params; |
| 1470 | tSirMacAddr bssid; |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 1471 | qdf_freq_t freq = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1472 | int ret; |
| 1473 | |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 1474 | if (total_len < sizeof(params) + 8) { |
| 1475 | hdd_err("Invalid command length"); |
| 1476 | return -EINVAL; |
| 1477 | } |
| 1478 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1479 | /* The params are located after "REASSOC " */ |
| 1480 | memcpy(¶ms, command + 8, sizeof(params)); |
| 1481 | |
| 1482 | if (!mac_pton(params.bssid, (u8 *) &bssid)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1483 | hdd_err("MAC address parsing failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1484 | ret = -EINVAL; |
| 1485 | } else { |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 1486 | /* |
| 1487 | * In Reassoc command, user can send channel number or frequency |
| 1488 | * along with BSSID. If params.channel param of REASSOC command |
| 1489 | * is less than WNI_CFG_CURRENT_CHANNEL_STAMAX, then host |
| 1490 | * consider this as channel number else frequency. |
| 1491 | */ |
| 1492 | if (!hdd_check_and_fill_freq(params.channel, &freq)) |
| 1493 | return -EINVAL; |
| 1494 | |
| 1495 | ret = hdd_reassoc(adapter, bssid, freq, REASSOC); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1496 | } |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 1497 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1498 | return ret; |
| 1499 | } |
| 1500 | |
| 1501 | /** |
| 1502 | * hdd_parse_reassoc() - parse the REASSOC command |
| 1503 | * @adapter: Adapter upon which the command was received |
| 1504 | * @command: Command that was received |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 1505 | * @total_len: Total length of the command received |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1506 | * |
| 1507 | * There are two different versions of the REASSOC command. Version 1 |
| 1508 | * of the command contains a parameter list that is ASCII characters |
| 1509 | * whereas version 2 contains a combination of ASCII and binary |
| 1510 | * payload. Determine if a version 1 or a version 2 command is being |
| 1511 | * parsed by examining the parameters, and then dispatch the parser |
| 1512 | * that is appropriate for the command. |
| 1513 | * |
| 1514 | * Return: 0 for success non-zero for failure |
| 1515 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 1516 | 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] | 1517 | int total_len) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1518 | { |
| 1519 | int ret; |
| 1520 | |
| 1521 | /* both versions start with "REASSOC " |
| 1522 | * v1 has a bssid and channel # as an ASCII string |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 1523 | * REASSOC xx:xx:xx:xx:xx:xx CH/FREQ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1524 | * v2 has a C struct |
| 1525 | * REASSOC <binary c struct> |
| 1526 | * |
| 1527 | * The first field in the v2 struct is also the bssid in ASCII. |
| 1528 | * But in the case of a v2 message the BSSID is NUL-terminated. |
| 1529 | * Hence we can peek at that offset to see if this is V1 or V2 |
| 1530 | * REASSOC xx:xx:xx:xx:xx:xx* |
| 1531 | * 1111111111222222 |
| 1532 | * 01234567890123456789012345 |
| 1533 | */ |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 1534 | |
| 1535 | if (total_len < 26) { |
| 1536 | hdd_err("Invalid command, total_len = %d", total_len); |
| 1537 | return -EINVAL; |
| 1538 | } |
| 1539 | |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 1540 | if (command[25]) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1541 | ret = hdd_parse_reassoc_v1(adapter, command); |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 1542 | else |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 1543 | ret = hdd_parse_reassoc_v2(adapter, command, total_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1544 | |
| 1545 | return ret; |
| 1546 | } |
| 1547 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1548 | /** |
| 1549 | * hdd_sendactionframe() - send a userspace-supplied action frame |
| 1550 | * @adapter: Adapter upon which the command was received |
| 1551 | * @bssid: BSSID target of the action frame |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 1552 | * @freq: Frequency upon which to send the frame |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1553 | * @dwell_time: Amount of time to dwell when the frame is sent |
| 1554 | * @payload_len:Length of the payload |
| 1555 | * @payload: Payload of the frame |
| 1556 | * |
| 1557 | * This function sends a userspace-supplied action frame |
| 1558 | * |
| 1559 | * Return: 0 for success non-zero for failure |
| 1560 | */ |
| 1561 | static int |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 1562 | hdd_sendactionframe(struct hdd_adapter *adapter, const uint8_t *bssid, |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 1563 | const qdf_freq_t freq, const uint8_t dwell_time, |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 1564 | const int payload_len, const uint8_t *payload) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1565 | { |
| 1566 | struct ieee80211_channel chan; |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 1567 | int frame_len, ret = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1568 | uint8_t *frame; |
| 1569 | struct ieee80211_hdr_3addr *hdr; |
| 1570 | u64 cookie; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 1571 | struct hdd_station_ctx *sta_ctx; |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 1572 | struct hdd_context *hdd_ctx; |
Jeff Johnson | ecdf83b | 2019-02-26 18:33:56 -0800 | [diff] [blame] | 1573 | tpSirMacVendorSpecificFrameHdr vendor = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1574 | (tpSirMacVendorSpecificFrameHdr) payload; |
| 1575 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) |
| 1576 | struct cfg80211_mgmt_tx_params params; |
| 1577 | #endif |
| 1578 | |
Sourav Mohapatra | 762ed1e | 2019-09-05 14:34:19 +0530 | [diff] [blame] | 1579 | if (payload_len < sizeof(tSirMacVendorSpecificFrameHdr)) { |
| 1580 | hdd_warn("Invalid payload length: %d", payload_len); |
| 1581 | return -EINVAL; |
| 1582 | } |
| 1583 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 1584 | if (QDF_STA_MODE != adapter->device_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1585 | hdd_warn("Unsupported in mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 1586 | qdf_opmode_str(adapter->device_mode), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1587 | adapter->device_mode); |
| 1588 | return -EINVAL; |
| 1589 | } |
| 1590 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 1591 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1592 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 1593 | |
| 1594 | /* if not associated, no need to send action frame */ |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 1595 | if (eConnectionState_Associated != sta_ctx->conn_info.conn_state) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 1596 | hdd_warn("Not associated"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1597 | ret = -EINVAL; |
| 1598 | goto exit; |
| 1599 | } |
| 1600 | |
| 1601 | /* |
| 1602 | * if the target bssid is different from currently associated AP, |
| 1603 | * then no need to send action frame |
| 1604 | */ |
Jeff Johnson | e04b699 | 2019-02-27 14:06:55 -0800 | [diff] [blame] | 1605 | if (memcmp(bssid, sta_ctx->conn_info.bssid.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1606 | QDF_MAC_ADDR_SIZE)) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 1607 | hdd_warn("STA is not associated to this AP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1608 | ret = -EINVAL; |
| 1609 | goto exit; |
| 1610 | } |
| 1611 | |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 1612 | chan.center_freq = freq; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1613 | /* Check if it is specific action frame */ |
Jeff Johnson | ecdf83b | 2019-02-26 18:33:56 -0800 | [diff] [blame] | 1614 | if (vendor->category == |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1615 | SIR_MAC_ACTION_VENDOR_SPECIFIC_CATEGORY) { |
Jeff Johnson | 2971e3a | 2019-02-26 18:31:54 -0800 | [diff] [blame] | 1616 | static const uint8_t oui[] = { 0x00, 0x00, 0xf0 }; |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 1617 | |
Jeff Johnson | ecdf83b | 2019-02-26 18:33:56 -0800 | [diff] [blame] | 1618 | if (!qdf_mem_cmp(vendor->Oui, oui, 3)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1619 | /* |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 1620 | * if the freq number is different from operating |
| 1621 | * freq then no need to send action frame |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1622 | */ |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 1623 | if (freq) { |
| 1624 | if (freq != sta_ctx->conn_info.chan_freq) { |
| 1625 | hdd_warn("freq(%u) is different from operating freq(%u)", |
| 1626 | freq, |
| 1627 | sta_ctx->conn_info.chan_freq); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1628 | ret = -EINVAL; |
| 1629 | goto exit; |
| 1630 | } |
| 1631 | /* |
| 1632 | * If channel number is specified and same |
| 1633 | * as home channel, ensure that action frame |
| 1634 | * is sent immediately by cancelling |
| 1635 | * roaming scans. Otherwise large dwell times |
| 1636 | * may cause long delays in sending action |
| 1637 | * frames. |
| 1638 | */ |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1639 | sme_abort_roam_scan(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 1640 | adapter->vdev_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1641 | } else { |
| 1642 | /* |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 1643 | * 0 is accepted as current home frequency, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1644 | * delayed transmission of action frame is ok. |
| 1645 | */ |
Jingxiang Ge | ae80dc6 | 2019-08-13 17:32:22 +0800 | [diff] [blame] | 1646 | chan.center_freq = sta_ctx->conn_info.chan_freq; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1647 | } |
| 1648 | } |
| 1649 | } |
| 1650 | if (chan.center_freq == 0) { |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 1651 | hdd_nofl_err("Invalid freq : %d", freq); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1652 | ret = -EINVAL; |
| 1653 | goto exit; |
| 1654 | } |
| 1655 | |
| 1656 | frame_len = payload_len + 24; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1657 | frame = qdf_mem_malloc(frame_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1658 | if (!frame) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 1659 | hdd_err("memory allocation failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1660 | ret = -ENOMEM; |
| 1661 | goto exit; |
| 1662 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1663 | |
| 1664 | hdr = (struct ieee80211_hdr_3addr *)frame; |
| 1665 | hdr->frame_control = |
| 1666 | cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_ACTION); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1667 | qdf_mem_copy(hdr->addr1, bssid, QDF_MAC_ADDR_SIZE); |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 1668 | qdf_mem_copy(hdr->addr2, adapter->mac_addr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1669 | QDF_MAC_ADDR_SIZE); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1670 | qdf_mem_copy(hdr->addr3, bssid, QDF_MAC_ADDR_SIZE); |
| 1671 | qdf_mem_copy(hdr + 1, payload, payload_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1672 | |
| 1673 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) |
| 1674 | params.chan = &chan; |
| 1675 | params.offchan = 0; |
| 1676 | params.wait = dwell_time; |
| 1677 | params.buf = frame; |
| 1678 | params.len = frame_len; |
| 1679 | params.no_cck = 1; |
| 1680 | params.dont_wait_for_ack = 1; |
| 1681 | ret = wlan_hdd_mgmt_tx(NULL, &adapter->wdev, ¶ms, &cookie); |
| 1682 | #else |
| 1683 | ret = wlan_hdd_mgmt_tx(NULL, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1684 | &(adapter->wdev), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1685 | &chan, 0, |
Amar Singhal | 01098f7 | 2015-10-08 11:55:32 -0700 | [diff] [blame] | 1686 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1687 | dwell_time, frame, frame_len, 1, 1, &cookie); |
| 1688 | #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0) */ |
| 1689 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1690 | qdf_mem_free(frame); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1691 | exit: |
| 1692 | return ret; |
| 1693 | } |
| 1694 | |
| 1695 | /** |
| 1696 | * hdd_parse_sendactionframe_v1() - parse version 1 of the |
| 1697 | * SENDACTIONFRAME command |
| 1698 | * @adapter: Adapter upon which the command was received |
| 1699 | * @command: ASCII text command that was received |
| 1700 | * |
| 1701 | * This function parses the v1 SENDACTIONFRAME command with the format |
| 1702 | * |
| 1703 | * SENDACTIONFRAME xx:xx:xx:xx:xx:xx CH DW xxxxxx |
| 1704 | * |
| 1705 | * Where "xx:xx:xx:xx:xx:xx" is the Hex-ASCII representation of the |
| 1706 | * BSSID, CH is the ASCII representation of the channel, DW is the |
| 1707 | * ASCII representation of the dwell time, and xxxxxx is the Hex-ASCII |
| 1708 | * payload. For example |
| 1709 | * |
| 1710 | * SENDACTIONFRAME 00:0a:0b:11:22:33 48 40 aabbccddee |
| 1711 | * |
| 1712 | * Return: 0 for success non-zero for failure |
| 1713 | */ |
| 1714 | static int |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 1715 | hdd_parse_sendactionframe_v1(struct hdd_adapter *adapter, const char *command) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1716 | { |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 1717 | qdf_freq_t freq = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1718 | uint8_t dwell_time = 0; |
| 1719 | uint8_t payload_len = 0; |
| 1720 | uint8_t *payload = NULL; |
| 1721 | tSirMacAddr bssid; |
| 1722 | int ret; |
| 1723 | |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 1724 | ret = hdd_parse_send_action_frame_v1_data(command, bssid, &freq, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1725 | &dwell_time, &payload, |
| 1726 | &payload_len); |
| 1727 | if (ret) { |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 1728 | hdd_nofl_err("Failed to parse send action frame data"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1729 | } else { |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 1730 | ret = hdd_sendactionframe(adapter, bssid, freq, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1731 | dwell_time, payload_len, payload); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1732 | qdf_mem_free(payload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1733 | } |
| 1734 | |
| 1735 | return ret; |
| 1736 | } |
| 1737 | |
| 1738 | /** |
| 1739 | * hdd_parse_sendactionframe_v2() - parse version 2 of the |
| 1740 | * SENDACTIONFRAME command |
| 1741 | * @adapter: Adapter upon which the command was received |
| 1742 | * @command: Command that was received, ASCII command |
Jeff Johnson | 560dc56 | 2017-03-17 15:19:31 -0700 | [diff] [blame] | 1743 | * followed by binary data |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1744 | * |
| 1745 | * This function parses the v2 SENDACTIONFRAME command with the format |
| 1746 | * |
| 1747 | * SENDACTIONFRAME <android_wifi_af_params> |
| 1748 | * |
| 1749 | * Return: 0 for success non-zero for failure |
| 1750 | */ |
| 1751 | static int |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 1752 | hdd_parse_sendactionframe_v2(struct hdd_adapter *adapter, |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 1753 | const char *command, int total_len) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1754 | { |
| 1755 | struct android_wifi_af_params *params; |
| 1756 | tSirMacAddr bssid; |
| 1757 | int ret; |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 1758 | int len_wo_payload = 0; |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 1759 | qdf_freq_t freq = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1760 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1761 | /* The params are located after "SENDACTIONFRAME " */ |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 1762 | total_len -= 16; |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 1763 | len_wo_payload = sizeof(*params) - ANDROID_WIFI_ACTION_FRAME_SIZE; |
| 1764 | if (total_len <= len_wo_payload) { |
| 1765 | hdd_err("Invalid command len"); |
| 1766 | return -EINVAL; |
| 1767 | } |
| 1768 | |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 1769 | params = (struct android_wifi_af_params *)(command + 16); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1770 | |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 1771 | if (params->len <= 0 || params->len > ANDROID_WIFI_ACTION_FRAME_SIZE || |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 1772 | (params->len > (total_len - len_wo_payload))) { |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 1773 | hdd_err("Invalid payload length: %d", params->len); |
| 1774 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1775 | } |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 1776 | |
| 1777 | if (!mac_pton(params->bssid, (u8 *)&bssid)) { |
| 1778 | hdd_err("MAC address parsing failed"); |
| 1779 | return -EINVAL; |
| 1780 | } |
| 1781 | |
| 1782 | if (params->channel < 0 || |
| 1783 | params->channel > WNI_CFG_CURRENT_CHANNEL_STAMAX) { |
| 1784 | hdd_err("Invalid channel: %d", params->channel); |
| 1785 | return -EINVAL; |
| 1786 | } |
| 1787 | |
| 1788 | if (params->dwell_time < 0) { |
| 1789 | hdd_err("Invalid dwell_time: %d", params->dwell_time); |
| 1790 | return -EINVAL; |
| 1791 | } |
| 1792 | |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 1793 | if (!hdd_check_and_fill_freq(params->channel, &freq)) { |
| 1794 | hdd_err("Invalid channel: %d", params->channel); |
| 1795 | return -EINVAL; |
| 1796 | } |
| 1797 | |
| 1798 | ret = hdd_sendactionframe(adapter, bssid, freq, params->dwell_time, |
| 1799 | params->len, params->data); |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 1800 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1801 | return ret; |
| 1802 | } |
| 1803 | |
| 1804 | /** |
| 1805 | * hdd_parse_sendactionframe() - parse the SENDACTIONFRAME command |
| 1806 | * @adapter: Adapter upon which the command was received |
| 1807 | * @command: Command that was received |
| 1808 | * |
| 1809 | * There are two different versions of the SENDACTIONFRAME command. |
| 1810 | * Version 1 of the command contains a parameter list that is ASCII |
| 1811 | * characters whereas version 2 contains a combination of ASCII and |
| 1812 | * binary payload. Determine if a version 1 or a version 2 command is |
| 1813 | * being parsed by examining the parameters, and then dispatch the |
| 1814 | * parser that is appropriate for the version of the command. |
| 1815 | * |
| 1816 | * Return: 0 for success non-zero for failure |
| 1817 | */ |
| 1818 | static int |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 1819 | hdd_parse_sendactionframe(struct hdd_adapter *adapter, const char *command, |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 1820 | int total_len) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1821 | { |
| 1822 | int ret; |
| 1823 | |
| 1824 | /* |
| 1825 | * both versions start with "SENDACTIONFRAME " |
| 1826 | * v1 has a bssid and other parameters as an ASCII string |
| 1827 | * SENDACTIONFRAME xx:xx:xx:xx:xx:xx CH DWELL LEN FRAME |
| 1828 | * v2 has a C struct |
| 1829 | * SENDACTIONFRAME <binary c struct> |
| 1830 | * |
| 1831 | * The first field in the v2 struct is also the bssid in ASCII. |
| 1832 | * But in the case of a v2 message the BSSID is NUL-terminated. |
| 1833 | * Hence we can peek at that offset to see if this is V1 or V2 |
| 1834 | * SENDACTIONFRAME xx:xx:xx:xx:xx:xx* |
| 1835 | * 111111111122222222223333 |
| 1836 | * 0123456789012345678901234567890123 |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 1837 | * For both the commands, a valid command must have atleast |
| 1838 | * first 34 length of data. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1839 | */ |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 1840 | if (total_len < 34) { |
| 1841 | hdd_err("Invalid command (total_len=%d)", total_len); |
| 1842 | return -EINVAL; |
| 1843 | } |
| 1844 | |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 1845 | if (command[33]) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1846 | ret = hdd_parse_sendactionframe_v1(adapter, command); |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 1847 | else |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 1848 | ret = hdd_parse_sendactionframe_v2(adapter, command, total_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1849 | |
| 1850 | return ret; |
| 1851 | } |
| 1852 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1853 | /** |
| 1854 | * hdd_parse_channellist() - HDD Parse channel list |
Liangwei Dong | 075afa7 | 2019-10-30 12:58:22 +0800 | [diff] [blame] | 1855 | * @hdd_ctx: hdd context |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 1856 | * @command: Pointer to input channel list |
Liangwei Dong | 075afa7 | 2019-10-30 12:58:22 +0800 | [diff] [blame] | 1857 | * @channel_freq_list: Pointer to local output array to record |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 1858 | * channel list |
Jeff Johnson | c3eac6c | 2019-02-26 18:09:53 -0800 | [diff] [blame] | 1859 | * @num_channels: Pointer to number of roam scan channels |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1860 | * |
| 1861 | * This function parses the channel list passed in the format |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 1862 | * SETROAMSCANCHANNELS<space><Number of channels><space>Channel 1<space> |
| 1863 | * Channel 2<space>Channel N |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1864 | * if the Number of channels (N) does not match with the actual number |
| 1865 | * of channels passed then take the minimum of N and count of |
| 1866 | * (Ch1, Ch2, ...Ch M). For example, if SETROAMSCANCHANNELS 3 36 40 44 48, |
| 1867 | * only 36, 40 and 44 shall be taken. If SETROAMSCANCHANNELS 5 36 40 44 48, |
| 1868 | * ignore 5 and take 36, 40, 44 and 48. This function does not take care of |
| 1869 | * removing duplicate channels from the list |
| 1870 | * |
| 1871 | * Return: 0 for success non-zero for failure |
| 1872 | */ |
| 1873 | static int |
Liangwei Dong | 075afa7 | 2019-10-30 12:58:22 +0800 | [diff] [blame] | 1874 | hdd_parse_channellist(struct hdd_context *hdd_ctx, |
| 1875 | const uint8_t *command, |
| 1876 | uint32_t *channel_freq_list, |
Jeff Johnson | c3eac6c | 2019-02-26 18:09:53 -0800 | [diff] [blame] | 1877 | uint8_t *num_channels) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1878 | { |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1879 | const uint8_t *in_ptr = command; |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 1880 | int temp_int; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1881 | int j = 0; |
| 1882 | int v = 0; |
| 1883 | char buf[32]; |
| 1884 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1885 | in_ptr = strnchr(command, strlen(command), SPACE_ASCII_VALUE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1886 | /* no argument after the command */ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 1887 | if (!in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1888 | return -EINVAL; |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1889 | else if (SPACE_ASCII_VALUE != *in_ptr) /* no space after the command */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1890 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1891 | |
| 1892 | /* remove empty spaces */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1893 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 1894 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1895 | |
| 1896 | /* no argument followed by spaces */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1897 | if ('\0' == *in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1898 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1899 | |
| 1900 | /* get the first argument ie the number of channels */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1901 | v = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1902 | if (1 != v) |
| 1903 | return -EINVAL; |
| 1904 | |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 1905 | v = kstrtos32(buf, 10, &temp_int); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1906 | if ((v < 0) || |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 1907 | (temp_int <= 0) || (temp_int > CFG_VALID_CHANNEL_LIST_LEN)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1908 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1909 | |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 1910 | *num_channels = temp_int; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1911 | |
Jeff Johnson | c3eac6c | 2019-02-26 18:09:53 -0800 | [diff] [blame] | 1912 | hdd_debug("Number of channels are: %d", *num_channels); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1913 | |
Jeff Johnson | c3eac6c | 2019-02-26 18:09:53 -0800 | [diff] [blame] | 1914 | for (j = 0; j < (*num_channels); j++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1915 | /* |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1916 | * in_ptr pointing to the beginning of first space after number |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1917 | * of channels |
| 1918 | */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1919 | in_ptr = strpbrk(in_ptr, " "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1920 | /* no channel list after the number of channels argument */ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 1921 | if (!in_ptr) { |
Abhishek Ambure | f4e9946 | 2020-01-30 16:16:07 +0530 | [diff] [blame] | 1922 | if ((j != 0) && (*num_channels == j)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1923 | return 0; |
Abhishek Ambure | f4e9946 | 2020-01-30 16:16:07 +0530 | [diff] [blame] | 1924 | else |
| 1925 | goto cnt_mismatch; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1926 | } |
| 1927 | |
| 1928 | /* remove empty space */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1929 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 1930 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1931 | |
| 1932 | /* |
| 1933 | * no channel list after the number of channels |
| 1934 | * argument and spaces |
| 1935 | */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1936 | if ('\0' == *in_ptr) { |
Abhishek Ambure | f4e9946 | 2020-01-30 16:16:07 +0530 | [diff] [blame] | 1937 | if ((j != 0) && (*num_channels == j)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1938 | return 0; |
Abhishek Ambure | f4e9946 | 2020-01-30 16:16:07 +0530 | [diff] [blame] | 1939 | else |
| 1940 | goto cnt_mismatch; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1941 | } |
| 1942 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 1943 | v = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1944 | if (1 != v) |
| 1945 | return -EINVAL; |
| 1946 | |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 1947 | v = kstrtos32(buf, 10, &temp_int); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1948 | if ((v < 0) || |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 1949 | (temp_int <= 0) || |
| 1950 | (temp_int > WNI_CFG_CURRENT_CHANNEL_STAMAX)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1951 | return -EINVAL; |
| 1952 | } |
Liangwei Dong | 075afa7 | 2019-10-30 12:58:22 +0800 | [diff] [blame] | 1953 | channel_freq_list[j] = |
| 1954 | wlan_reg_chan_to_freq(hdd_ctx->pdev, temp_int); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1955 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 1956 | hdd_debug("Channel %d added to preferred channel list", |
Liangwei Dong | 075afa7 | 2019-10-30 12:58:22 +0800 | [diff] [blame] | 1957 | channel_freq_list[j]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1958 | } |
| 1959 | |
| 1960 | return 0; |
Abhishek Ambure | f4e9946 | 2020-01-30 16:16:07 +0530 | [diff] [blame] | 1961 | |
| 1962 | cnt_mismatch: |
| 1963 | hdd_debug("Mismatch in ch cnt: %d and num of ch: %d", *num_channels, j); |
| 1964 | *num_channels = 0; |
| 1965 | return -EINVAL; |
| 1966 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1967 | } |
| 1968 | |
| 1969 | /** |
| 1970 | * hdd_parse_set_roam_scan_channels_v1() - parse version 1 of the |
| 1971 | * SETROAMSCANCHANNELS command |
| 1972 | * @adapter: Adapter upon which the command was received |
| 1973 | * @command: ASCII text command that was received |
| 1974 | * |
| 1975 | * This function parses the v1 SETROAMSCANCHANNELS command with the format |
| 1976 | * |
| 1977 | * SETROAMSCANCHANNELS N C1 C2 ... Cn |
| 1978 | * |
| 1979 | * Where "N" is the ASCII representation of the number of channels and |
| 1980 | * C1 thru Cn is the ASCII representation of the channels. For example |
| 1981 | * |
| 1982 | * SETROAMSCANCHANNELS 4 36 40 44 48 |
| 1983 | * |
| 1984 | * Return: 0 for success non-zero for failure |
| 1985 | */ |
| 1986 | static int |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 1987 | hdd_parse_set_roam_scan_channels_v1(struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1988 | const char *command) |
| 1989 | { |
Liangwei Dong | 075afa7 | 2019-10-30 12:58:22 +0800 | [diff] [blame] | 1990 | uint32_t channel_freq_list[CFG_VALID_CHANNEL_LIST_LEN] = { 0 }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1991 | uint8_t num_chan = 0; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1992 | QDF_STATUS status; |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 1993 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1994 | int ret; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 1995 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1996 | |
Liangwei Dong | 075afa7 | 2019-10-30 12:58:22 +0800 | [diff] [blame] | 1997 | if (!hdd_ctx) { |
| 1998 | hdd_err("invalid hdd ctx"); |
| 1999 | ret = -EINVAL; |
| 2000 | goto exit; |
| 2001 | } |
| 2002 | |
| 2003 | ret = hdd_parse_channellist(hdd_ctx, command, channel_freq_list, |
| 2004 | &num_chan); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2005 | if (ret) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2006 | hdd_err("Failed to parse channel list information"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2007 | goto exit; |
| 2008 | } |
| 2009 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 2010 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 2011 | TRACE_CODE_HDD_SETROAMSCANCHANNELS_IOCTL, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 2012 | adapter->vdev_id, num_chan); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2013 | |
Wu Gao | 0821b0d | 2019-01-11 17:31:11 +0800 | [diff] [blame] | 2014 | if (num_chan > CFG_VALID_CHANNEL_LIST_LEN) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2015 | hdd_err("number of channels (%d) supported exceeded max (%d)", |
Wu Gao | 0821b0d | 2019-01-11 17:31:11 +0800 | [diff] [blame] | 2016 | num_chan, CFG_VALID_CHANNEL_LIST_LEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2017 | ret = -EINVAL; |
| 2018 | goto exit; |
| 2019 | } |
| 2020 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2021 | mac_handle = hdd_ctx->mac_handle; |
Liangwei Dong | 075afa7 | 2019-10-30 12:58:22 +0800 | [diff] [blame] | 2022 | if (!sme_validate_channel_list(mac_handle, |
| 2023 | channel_freq_list, num_chan)) { |
Vignesh Viswanathan | a2f5ce58 | 2018-05-09 20:38:39 +0530 | [diff] [blame] | 2024 | hdd_err("List contains invalid channel(s)"); |
| 2025 | ret = -EINVAL; |
| 2026 | goto exit; |
| 2027 | } |
| 2028 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2029 | status = sme_change_roam_scan_channel_list(mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 2030 | adapter->vdev_id, |
Liangwei Dong | 075afa7 | 2019-10-30 12:58:22 +0800 | [diff] [blame] | 2031 | channel_freq_list, |
| 2032 | num_chan); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2033 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2034 | hdd_err("Failed to update channel list information"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2035 | ret = -EINVAL; |
| 2036 | goto exit; |
| 2037 | } |
| 2038 | exit: |
| 2039 | return ret; |
| 2040 | } |
| 2041 | |
| 2042 | /** |
| 2043 | * hdd_parse_set_roam_scan_channels_v2() - parse version 2 of the |
| 2044 | * SETROAMSCANCHANNELS command |
| 2045 | * @adapter: Adapter upon which the command was received |
| 2046 | * @command: Command that was received, ASCII command |
Jeff Johnson | 560dc56 | 2017-03-17 15:19:31 -0700 | [diff] [blame] | 2047 | * followed by binary data |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2048 | * |
| 2049 | * This function parses the v2 SETROAMSCANCHANNELS command with the format |
| 2050 | * |
| 2051 | * SETROAMSCANCHANNELS [N][C1][C2][Cn] |
| 2052 | * |
| 2053 | * The command begins with SETROAMSCANCHANNELS followed by a space, but |
| 2054 | * what follows the space is an array of u08 parameters. For example |
| 2055 | * |
| 2056 | * SETROAMSCANCHANNELS [0x04 0x24 0x28 0x2c 0x30] |
| 2057 | * |
| 2058 | * Return: 0 for success non-zero for failure |
| 2059 | */ |
| 2060 | static int |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 2061 | hdd_parse_set_roam_scan_channels_v2(struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2062 | const char *command) |
| 2063 | { |
| 2064 | const uint8_t *value; |
Liangwei Dong | 075afa7 | 2019-10-30 12:58:22 +0800 | [diff] [blame] | 2065 | uint32_t channel_freq_list[CFG_VALID_CHANNEL_LIST_LEN] = { 0 }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2066 | uint8_t channel; |
| 2067 | uint8_t num_chan; |
| 2068 | int i; |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 2069 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2070 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2071 | int ret = 0; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2072 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2073 | |
| 2074 | /* array of values begins after "SETROAMSCANCHANNELS " */ |
| 2075 | value = command + 20; |
| 2076 | |
| 2077 | num_chan = *value++; |
Wu Gao | 0821b0d | 2019-01-11 17:31:11 +0800 | [diff] [blame] | 2078 | if (num_chan > CFG_VALID_CHANNEL_LIST_LEN) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2079 | hdd_err("number of channels (%d) supported exceeded max (%d)", |
Wu Gao | 0821b0d | 2019-01-11 17:31:11 +0800 | [diff] [blame] | 2080 | num_chan, CFG_VALID_CHANNEL_LIST_LEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2081 | ret = -EINVAL; |
| 2082 | goto exit; |
| 2083 | } |
| 2084 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 2085 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 2086 | TRACE_CODE_HDD_SETROAMSCANCHANNELS_IOCTL, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 2087 | adapter->vdev_id, num_chan); |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 2088 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2089 | |
| 2090 | for (i = 0; i < num_chan; i++) { |
| 2091 | channel = *value++; |
Nachiket Kukade | caa2e84 | 2018-05-09 17:56:12 +0530 | [diff] [blame] | 2092 | if (!channel) { |
| 2093 | hdd_err("Channels end at index %d, expected %d", |
| 2094 | i, num_chan); |
| 2095 | ret = -EINVAL; |
| 2096 | goto exit; |
| 2097 | } |
| 2098 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2099 | if (channel > WNI_CFG_CURRENT_CHANNEL_STAMAX) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2100 | hdd_err("index %d invalid channel %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2101 | i, channel); |
| 2102 | ret = -EINVAL; |
| 2103 | goto exit; |
| 2104 | } |
Liangwei Dong | 075afa7 | 2019-10-30 12:58:22 +0800 | [diff] [blame] | 2105 | channel_freq_list[i] = wlan_reg_chan_to_freq(hdd_ctx->pdev, |
| 2106 | channel); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2107 | } |
Vignesh Viswanathan | a2f5ce58 | 2018-05-09 20:38:39 +0530 | [diff] [blame] | 2108 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2109 | mac_handle = hdd_ctx->mac_handle; |
Liangwei Dong | 075afa7 | 2019-10-30 12:58:22 +0800 | [diff] [blame] | 2110 | if (!sme_validate_channel_list(mac_handle, channel_freq_list, |
| 2111 | num_chan)) { |
Vignesh Viswanathan | a2f5ce58 | 2018-05-09 20:38:39 +0530 | [diff] [blame] | 2112 | hdd_err("List contains invalid channel(s)"); |
| 2113 | ret = -EINVAL; |
| 2114 | goto exit; |
| 2115 | } |
| 2116 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2117 | status = sme_change_roam_scan_channel_list(mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 2118 | adapter->vdev_id, |
Liangwei Dong | 075afa7 | 2019-10-30 12:58:22 +0800 | [diff] [blame] | 2119 | channel_freq_list, num_chan); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2120 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2121 | hdd_err("Failed to update channel list information"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2122 | ret = -EINVAL; |
| 2123 | goto exit; |
| 2124 | } |
| 2125 | exit: |
| 2126 | return ret; |
| 2127 | } |
| 2128 | |
| 2129 | /** |
| 2130 | * hdd_parse_set_roam_scan_channels() - parse the |
| 2131 | * SETROAMSCANCHANNELS command |
| 2132 | * @adapter: Adapter upon which the command was received |
| 2133 | * @command: Command that was received |
| 2134 | * |
| 2135 | * There are two different versions of the SETROAMSCANCHANNELS command. |
| 2136 | * Version 1 of the command contains a parameter list that is ASCII |
| 2137 | * characters whereas version 2 contains a binary payload. Determine |
| 2138 | * if a version 1 or a version 2 command is being parsed by examining |
| 2139 | * the parameters, and then dispatch the parser that is appropriate for |
| 2140 | * the command. |
| 2141 | * |
| 2142 | * Return: 0 for success non-zero for failure |
| 2143 | */ |
| 2144 | static int |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 2145 | 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] | 2146 | { |
| 2147 | const char *cursor; |
| 2148 | char ch; |
| 2149 | bool v1; |
| 2150 | int ret; |
| 2151 | |
| 2152 | /* start after "SETROAMSCANCHANNELS " */ |
| 2153 | cursor = command + 20; |
| 2154 | |
| 2155 | /* assume we have a version 1 command until proven otherwise */ |
| 2156 | v1 = true; |
| 2157 | |
| 2158 | /* v1 params will only contain ASCII digits and space */ |
| 2159 | while ((ch = *cursor++) && v1) { |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 2160 | if (!(isdigit(ch) || isspace(ch))) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2161 | v1 = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2162 | } |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 2163 | |
| 2164 | if (v1) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2165 | ret = hdd_parse_set_roam_scan_channels_v1(adapter, command); |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 2166 | else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2167 | ret = hdd_parse_set_roam_scan_channels_v2(adapter, command); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2168 | |
| 2169 | return ret; |
| 2170 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2171 | |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 2172 | #ifdef FEATURE_WLAN_ESE |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2173 | /** |
| 2174 | * hdd_parse_plm_cmd() - HDD Parse Plm command |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 2175 | * @command: Pointer to input data |
Jeff Johnson | a0b6c3c | 2019-02-26 11:04:52 -0800 | [diff] [blame] | 2176 | * @req: Pointer to output struct plm_req |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2177 | * |
| 2178 | * This function parses the plm command passed in the format |
| 2179 | * CCXPLMREQ<space><enable><space><dialog_token><space> |
| 2180 | * <meas_token><space><num_of_bursts><space><burst_int><space> |
| 2181 | * <measu duration><space><burst_len><space><desired_tx_pwr> |
| 2182 | * <space><multcast_addr><space><number_of_channels> |
| 2183 | * <space><channel_numbers> |
| 2184 | * |
| 2185 | * Return: 0 for success non-zero for failure |
| 2186 | */ |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 2187 | static QDF_STATUS hdd_parse_plm_cmd(uint8_t *command, |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 2188 | struct plm_req_params *req) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2189 | { |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2190 | uint8_t *in_ptr = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2191 | int count, content = 0, ret = 0; |
| 2192 | char buf[32]; |
| 2193 | |
| 2194 | /* move to argument list */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2195 | in_ptr = strnchr(command, strlen(command), SPACE_ASCII_VALUE); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2196 | if (!in_ptr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2197 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2198 | |
| 2199 | /* no space after the command */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2200 | if (SPACE_ASCII_VALUE != *in_ptr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2201 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2202 | |
| 2203 | /* remove empty spaces */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2204 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 2205 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2206 | |
| 2207 | /* START/STOP PLM req */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2208 | ret = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2209 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2210 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2211 | |
| 2212 | ret = kstrtos32(buf, 10, &content); |
| 2213 | if (ret < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2214 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2215 | |
Jeff Johnson | a0b6c3c | 2019-02-26 11:04:52 -0800 | [diff] [blame] | 2216 | req->enable = content; |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2217 | in_ptr = strpbrk(in_ptr, " "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2218 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2219 | if (!in_ptr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2220 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2221 | |
| 2222 | /* remove empty spaces */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2223 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 2224 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2225 | |
| 2226 | /* Dialog token of radio meas req containing meas reqIE */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2227 | ret = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2228 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2229 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2230 | |
| 2231 | ret = kstrtos32(buf, 10, &content); |
| 2232 | if (ret < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2233 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2234 | |
Jeff Johnson | a0b6c3c | 2019-02-26 11:04:52 -0800 | [diff] [blame] | 2235 | req->diag_token = content; |
| 2236 | hdd_debug("diag token %d", req->diag_token); |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2237 | in_ptr = strpbrk(in_ptr, " "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2238 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2239 | if (!in_ptr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2240 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2241 | |
| 2242 | /* remove empty spaces */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2243 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 2244 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2245 | |
| 2246 | /* measurement token of meas req IE */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2247 | ret = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2248 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2249 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2250 | |
| 2251 | ret = kstrtos32(buf, 10, &content); |
| 2252 | if (ret < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2253 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2254 | |
Jeff Johnson | a0b6c3c | 2019-02-26 11:04:52 -0800 | [diff] [blame] | 2255 | req->meas_token = content; |
| 2256 | hdd_debug("meas token %d", req->meas_token); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2257 | |
Jeff Johnson | a0b6c3c | 2019-02-26 11:04:52 -0800 | [diff] [blame] | 2258 | hdd_debug("PLM req %s", req->enable ? "START" : "STOP"); |
| 2259 | if (req->enable) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2260 | |
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 | /* total number of bursts after which STA stops sending */ |
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->num_bursts = content; |
| 2283 | hdd_debug("num bursts %d", req->num_bursts); |
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 interval in seconds */ |
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_int = content; |
| 2306 | hdd_debug("burst int %d", req->burst_int); |
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 | /* 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] | 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->meas_duration = content; |
| 2329 | hdd_debug("meas duration %d", req->meas_duration); |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2330 | in_ptr = strpbrk(in_ptr, " "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2331 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2332 | if (!in_ptr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2333 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2334 | |
| 2335 | /* remove empty spaces */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2336 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 2337 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2338 | |
| 2339 | /* burst length of PLM bursts */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2340 | ret = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2341 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2342 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2343 | |
| 2344 | ret = kstrtos32(buf, 10, &content); |
| 2345 | if (ret < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2346 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2347 | |
| 2348 | if (content <= 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2349 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2350 | |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 2351 | req->burst_len = content; |
| 2352 | hdd_debug("burst len %d", req->burst_len); |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2353 | in_ptr = strpbrk(in_ptr, " "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2354 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2355 | if (!in_ptr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2356 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2357 | |
| 2358 | /* remove empty spaces */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2359 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 2360 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2361 | |
| 2362 | /* desired tx power for transmission of PLM bursts */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2363 | ret = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2364 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2365 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2366 | |
| 2367 | ret = kstrtos32(buf, 10, &content); |
| 2368 | if (ret < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2369 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2370 | |
| 2371 | if (content <= 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 | |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 2374 | req->desired_tx_pwr = content; |
| 2375 | hdd_debug("desired tx pwr %d", req->desired_tx_pwr); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2376 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2377 | for (count = 0; count < QDF_MAC_ADDR_SIZE; count++) { |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2378 | in_ptr = strpbrk(in_ptr, " "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2379 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2380 | if (!in_ptr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2381 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2382 | |
| 2383 | /* remove empty spaces */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2384 | while ((SPACE_ASCII_VALUE == *in_ptr) |
| 2385 | && ('\0' != *in_ptr)) |
| 2386 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2387 | |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2388 | ret = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2389 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2390 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2391 | |
| 2392 | ret = kstrtos32(buf, 16, &content); |
| 2393 | if (ret < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2394 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2395 | |
Jeff Johnson | a0b6c3c | 2019-02-26 11:04:52 -0800 | [diff] [blame] | 2396 | req->mac_addr.bytes[count] = content; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2397 | } |
| 2398 | |
Srinivas Girigowda | 951b3f6 | 2020-08-10 16:54:46 -0700 | [diff] [blame] | 2399 | hdd_debug("MAC addr " QDF_MAC_ADDR_FMT, |
| 2400 | QDF_MAC_ADDR_REF(req->mac_addr.bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2401 | |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2402 | in_ptr = strpbrk(in_ptr, " "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2403 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2404 | if (!in_ptr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2405 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2406 | |
| 2407 | /* remove empty spaces */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2408 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 2409 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2410 | |
| 2411 | /* number of channels */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2412 | ret = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2413 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2414 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2415 | |
| 2416 | ret = kstrtos32(buf, 10, &content); |
| 2417 | if (ret < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2418 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2419 | |
| 2420 | if (content < 0) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2421 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2422 | |
Wu Gao | 0821b0d | 2019-01-11 17:31:11 +0800 | [diff] [blame] | 2423 | content = QDF_MIN(content, CFG_VALID_CHANNEL_LIST_LEN); |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 2424 | req->plm_num_ch = content; |
| 2425 | hdd_debug("num ch: %d", req->plm_num_ch); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2426 | |
| 2427 | /* Channel numbers */ |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 2428 | for (count = 0; count < req->plm_num_ch; count++) { |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2429 | in_ptr = strpbrk(in_ptr, " "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2430 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2431 | if (!in_ptr) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2432 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2433 | |
| 2434 | /* remove empty spaces */ |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2435 | while ((SPACE_ASCII_VALUE == *in_ptr) |
| 2436 | && ('\0' != *in_ptr)) |
| 2437 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2438 | |
Jeff Johnson | 4fab64d | 2019-02-26 13:06:31 -0800 | [diff] [blame] | 2439 | ret = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2440 | if (1 != ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2441 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2442 | |
| 2443 | ret = kstrtos32(buf, 10, &content); |
Srinivas Girigowda | 0fb6cc4 | 2016-08-26 14:53:59 -0700 | [diff] [blame] | 2444 | if (ret < 0 || content <= 0 || |
| 2445 | content > WNI_CFG_CURRENT_CHANNEL_STAMAX) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2446 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2447 | |
wadesong | 88aa89a | 2019-11-04 12:34:12 +0800 | [diff] [blame] | 2448 | req->plm_ch_freq_list[count] = |
| 2449 | cds_chan_to_freq(content); |
| 2450 | hdd_debug(" ch-freq- %d", req->plm_ch_freq_list[count]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2451 | } |
| 2452 | } |
| 2453 | /* If PLM START */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2454 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2455 | } |
| 2456 | #endif |
| 2457 | |
| 2458 | #ifdef WLAN_FEATURE_EXTWOW_SUPPORT |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 2459 | /** |
| 2460 | * wlan_hdd_ready_to_extwow() - Callback function for enable ext wow |
| 2461 | * @cookie: callback context |
| 2462 | * @is_success: suspend status of ext wow |
| 2463 | * |
| 2464 | * Return: none |
| 2465 | */ |
| 2466 | static void wlan_hdd_ready_to_extwow(void *cookie, bool is_success) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2467 | { |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 2468 | struct osif_request *request = NULL; |
| 2469 | struct enable_ext_wow_priv *priv = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2470 | |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 2471 | request = osif_request_get(cookie); |
| 2472 | if (!request) { |
| 2473 | hdd_err("Obselete request"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2474 | return; |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 2475 | } |
| 2476 | priv = osif_request_priv(request); |
| 2477 | priv->ext_wow_should_suspend = is_success; |
| 2478 | |
| 2479 | osif_request_complete(request); |
| 2480 | osif_request_put(request); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2481 | } |
| 2482 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 2483 | static int hdd_enable_ext_wow(struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2484 | tpSirExtWoWParams arg_params) |
| 2485 | { |
| 2486 | tSirExtWoWParams params; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2487 | QDF_STATUS status; |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 2488 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2489 | int rc; |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 2490 | struct enable_ext_wow_priv *priv = NULL; |
| 2491 | struct osif_request *request = NULL; |
| 2492 | void *cookie = NULL; |
| 2493 | struct osif_request_params hdd_params = { |
| 2494 | .priv_size = sizeof(*priv), |
| 2495 | .timeout_ms = WLAN_WAIT_TIME_READY_TO_EXTWOW, |
| 2496 | }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2497 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2498 | qdf_mem_copy(¶ms, arg_params, sizeof(params)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2499 | |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 2500 | request = osif_request_alloc(&hdd_params); |
| 2501 | if (!request) { |
| 2502 | hdd_err("Request Allocation Failure"); |
| 2503 | return -ENOMEM; |
| 2504 | } |
| 2505 | cookie = osif_request_cookie(request); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2506 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2507 | status = sme_configure_ext_wow(hdd_ctx->mac_handle, ¶ms, |
| 2508 | &wlan_hdd_ready_to_extwow, |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 2509 | cookie); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2510 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2511 | hdd_err("sme_configure_ext_wow returned failure %d", |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2512 | status); |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 2513 | rc = -EPERM; |
| 2514 | goto exit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2515 | } |
| 2516 | |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 2517 | rc = osif_request_wait_for_response(request); |
| 2518 | if (rc) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2519 | hdd_err("Failed to get ready to extwow"); |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 2520 | rc = -EPERM; |
| 2521 | goto exit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2522 | } |
| 2523 | |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 2524 | priv = osif_request_priv(request); |
| 2525 | if (!priv->ext_wow_should_suspend) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2526 | hdd_err("Received ready to ExtWoW failure"); |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 2527 | rc = -EPERM; |
| 2528 | goto exit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2529 | } |
| 2530 | |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 2531 | if (ucfg_pmo_extwow_is_goto_suspend_enabled(hdd_ctx->psoc)) { |
Jeff Johnson | 17d6267 | 2017-03-27 08:00:11 -0700 | [diff] [blame] | 2532 | hdd_info("Received ready to ExtWoW. Going to suspend"); |
| 2533 | |
| 2534 | rc = wlan_hdd_cfg80211_suspend_wlan(hdd_ctx->wiphy, NULL); |
| 2535 | if (rc < 0) { |
| 2536 | hdd_err("wlan_hdd_cfg80211_suspend_wlan failed, error = %d", |
| 2537 | rc); |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 2538 | goto exit; |
Jeff Johnson | 17d6267 | 2017-03-27 08:00:11 -0700 | [diff] [blame] | 2539 | } |
| 2540 | rc = wlan_hdd_bus_suspend(); |
| 2541 | if (rc) { |
| 2542 | hdd_err("wlan_hdd_bus_suspend failed, status = %d", |
| 2543 | rc); |
| 2544 | wlan_hdd_cfg80211_resume_wlan(hdd_ctx->wiphy); |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 2545 | goto exit; |
Jeff Johnson | 17d6267 | 2017-03-27 08:00:11 -0700 | [diff] [blame] | 2546 | } |
| 2547 | } |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 2548 | |
Dundi Raviteja | 53de6c3 | 2018-05-16 16:56:30 +0530 | [diff] [blame] | 2549 | exit: |
| 2550 | osif_request_put(request); |
| 2551 | return rc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2552 | } |
| 2553 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 2554 | 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] | 2555 | int value) |
| 2556 | { |
| 2557 | tSirExtWoWParams params; |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 2558 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2559 | int rc; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 2560 | uint8_t pin1, pin2; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2561 | |
| 2562 | rc = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 2563 | if (rc) |
| 2564 | return rc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2565 | |
| 2566 | if (value < EXT_WOW_TYPE_APP_TYPE1 || |
| 2567 | value > EXT_WOW_TYPE_APP_TYPE1_2) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 2568 | hdd_err("Invalid type: %d", value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2569 | return -EINVAL; |
| 2570 | } |
| 2571 | |
| 2572 | if (value == EXT_WOW_TYPE_APP_TYPE1 && |
| 2573 | hdd_ctx->is_extwow_app_type1_param_set) |
| 2574 | params.type = value; |
| 2575 | else if (value == EXT_WOW_TYPE_APP_TYPE2 && |
| 2576 | hdd_ctx->is_extwow_app_type2_param_set) |
| 2577 | params.type = value; |
| 2578 | else if (value == EXT_WOW_TYPE_APP_TYPE1_2 && |
| 2579 | hdd_ctx->is_extwow_app_type1_param_set && |
| 2580 | hdd_ctx->is_extwow_app_type2_param_set) |
| 2581 | params.type = value; |
| 2582 | else { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2583 | hdd_err("Set app params before enable it value %d", |
| 2584 | value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2585 | return -EINVAL; |
| 2586 | } |
| 2587 | |
| 2588 | params.vdev_id = vdev_id; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 2589 | pin1 = ucfg_pmo_extwow_app1_wakeup_pin_num(hdd_ctx->psoc); |
| 2590 | pin2 = ucfg_pmo_extwow_app2_wakeup_pin_num(hdd_ctx->psoc); |
| 2591 | params.wakeup_pin_num = pin1 | (pin2 << 8); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2592 | |
| 2593 | return hdd_enable_ext_wow(adapter, ¶ms); |
| 2594 | } |
| 2595 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2596 | static int hdd_set_app_type1_params(mac_handle_t mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2597 | tpSirAppType1Params arg_params) |
| 2598 | { |
| 2599 | tSirAppType1Params params; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2600 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2601 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2602 | qdf_mem_copy(¶ms, arg_params, sizeof(params)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2603 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2604 | status = sme_configure_app_type1_params(mac_handle, ¶ms); |
| 2605 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2606 | hdd_err("sme_configure_app_type1_params returned failure %d", |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2607 | status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2608 | return -EPERM; |
| 2609 | } |
| 2610 | |
| 2611 | return 0; |
| 2612 | } |
| 2613 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 2614 | static int hdd_set_app_type1_parser(struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2615 | char *arg, int len) |
| 2616 | { |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 2617 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2618 | char id[20], password[20]; |
| 2619 | tSirAppType1Params params; |
Srinivas Girigowda | 0420991 | 2015-11-24 12:11:13 -0800 | [diff] [blame] | 2620 | int rc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2621 | |
| 2622 | rc = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 2623 | if (rc) |
| 2624 | return rc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2625 | |
| 2626 | if (2 != sscanf(arg, "%8s %16s", id, password)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2627 | hdd_err("Invalid Number of arguments"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2628 | return -EINVAL; |
| 2629 | } |
| 2630 | |
| 2631 | memset(¶ms, 0, sizeof(tSirAppType1Params)); |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 2632 | params.vdev_id = adapter->vdev_id; |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 2633 | qdf_copy_macaddr(¶ms.wakee_mac_addr, &adapter->mac_addr); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2634 | |
| 2635 | params.id_length = strlen(id); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2636 | qdf_mem_copy(params.identification_id, id, params.id_length); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2637 | params.pass_length = strlen(password); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2638 | qdf_mem_copy(params.password, password, params.pass_length); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2639 | |
Srinivas Girigowda | 951b3f6 | 2020-08-10 16:54:46 -0700 | [diff] [blame] | 2640 | hdd_debug("%d "QDF_MAC_ADDR_FMT" %.8s %u %.16s %u", |
| 2641 | params.vdev_id, |
| 2642 | QDF_MAC_ADDR_REF(params.wakee_mac_addr.bytes), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2643 | params.identification_id, params.id_length, |
| 2644 | params.password, params.pass_length); |
| 2645 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2646 | return hdd_set_app_type1_params(hdd_ctx->mac_handle, ¶ms); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2647 | } |
| 2648 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2649 | static int hdd_set_app_type2_params(mac_handle_t mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2650 | tpSirAppType2Params arg_params) |
| 2651 | { |
| 2652 | tSirAppType2Params params; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2653 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2654 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2655 | qdf_mem_copy(¶ms, arg_params, sizeof(params)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2656 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2657 | status = sme_configure_app_type2_params(mac_handle, ¶ms); |
| 2658 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2659 | hdd_err("sme_configure_app_type2_params returned failure %d", |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2660 | status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2661 | return -EPERM; |
| 2662 | } |
| 2663 | |
| 2664 | return 0; |
| 2665 | } |
| 2666 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 2667 | static int hdd_set_app_type2_parser(struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2668 | char *arg, int len) |
| 2669 | { |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 2670 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2671 | char mac_addr[20], rc4_key[20]; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2672 | unsigned int gateway_mac[QDF_MAC_ADDR_SIZE]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2673 | tSirAppType2Params params; |
| 2674 | int ret; |
| 2675 | |
| 2676 | ret = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 2677 | if (ret) |
| 2678 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2679 | |
| 2680 | memset(¶ms, 0, sizeof(tSirAppType2Params)); |
| 2681 | |
Bhargav Shah | f4fd97d | 2015-07-08 10:21:37 +0530 | [diff] [blame] | 2682 | 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] | 2683 | mac_addr, rc4_key, (unsigned int *)¶ms.ip_id, |
| 2684 | (unsigned int *)¶ms.ip_device_ip, |
| 2685 | (unsigned int *)¶ms.ip_server_ip, |
| 2686 | (unsigned int *)¶ms.tcp_seq, |
| 2687 | (unsigned int *)¶ms.tcp_ack_seq, |
Bhargav Shah | f4fd97d | 2015-07-08 10:21:37 +0530 | [diff] [blame] | 2688 | (uint16_t *)¶ms.tcp_src_port, |
| 2689 | (uint16_t *)¶ms.tcp_dst_port, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2690 | (unsigned int *)¶ms.keepalive_init, |
| 2691 | (unsigned int *)¶ms.keepalive_min, |
| 2692 | (unsigned int *)¶ms.keepalive_max, |
| 2693 | (unsigned int *)¶ms.keepalive_inc, |
| 2694 | (unsigned int *)¶ms.tcp_tx_timeout_val, |
| 2695 | (unsigned int *)¶ms.tcp_rx_timeout_val); |
| 2696 | |
| 2697 | if (ret != 15 && ret != 7) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2698 | hdd_err("Invalid Number of arguments"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2699 | return -EINVAL; |
| 2700 | } |
| 2701 | |
Srinivas Girigowda | 951b3f6 | 2020-08-10 16:54:46 -0700 | [diff] [blame] | 2702 | if (6 != sscanf(mac_addr, "%02x:%02x:%02x:%02x:%02x:%02x", |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 2703 | &gateway_mac[0], &gateway_mac[1], &gateway_mac[2], |
| 2704 | &gateway_mac[3], &gateway_mac[4], &gateway_mac[5])) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2705 | hdd_err("Invalid MacAddress Input %s", mac_addr); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2706 | return -EINVAL; |
| 2707 | } |
| 2708 | |
| 2709 | if (params.tcp_src_port > WLAN_HDD_MAX_TCP_PORT || |
| 2710 | params.tcp_dst_port > WLAN_HDD_MAX_TCP_PORT) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2711 | hdd_err("Invalid TCP Port Number"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2712 | return -EINVAL; |
| 2713 | } |
| 2714 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2715 | qdf_mem_copy(¶ms.gateway_mac.bytes, (uint8_t *) &gateway_mac, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2716 | QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2717 | |
| 2718 | params.rc4_key_len = strlen(rc4_key); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2719 | qdf_mem_copy(params.rc4_key, rc4_key, params.rc4_key_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2720 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 2721 | params.vdev_id = adapter->vdev_id; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 2722 | |
| 2723 | if (!params.tcp_src_port) |
| 2724 | params.tcp_src_port = |
| 2725 | ucfg_pmo_extwow_app2_tcp_src_port(hdd_ctx->psoc); |
| 2726 | |
| 2727 | if (!params.tcp_dst_port) |
| 2728 | params.tcp_dst_port = |
| 2729 | ucfg_pmo_extwow_app2_tcp_dst_port(hdd_ctx->psoc); |
| 2730 | |
| 2731 | if (!params.keepalive_init) |
| 2732 | params.keepalive_init = |
| 2733 | ucfg_pmo_extwow_app2_init_ping_interval(hdd_ctx->psoc); |
| 2734 | |
| 2735 | if (!params.keepalive_min) |
| 2736 | params.keepalive_min = |
| 2737 | ucfg_pmo_extwow_app2_min_ping_interval(hdd_ctx->psoc); |
| 2738 | |
| 2739 | if (!params.keepalive_max) |
| 2740 | params.keepalive_max = |
| 2741 | ucfg_pmo_extwow_app2_max_ping_interval(hdd_ctx->psoc); |
| 2742 | |
| 2743 | if (!params.keepalive_inc) |
| 2744 | params.keepalive_inc = |
| 2745 | ucfg_pmo_extwow_app2_inc_ping_interval(hdd_ctx->psoc); |
| 2746 | |
| 2747 | if (!params.tcp_tx_timeout_val) |
| 2748 | params.tcp_tx_timeout_val = |
| 2749 | ucfg_pmo_extwow_app2_tcp_tx_timeout(hdd_ctx->psoc); |
| 2750 | |
| 2751 | if (!params.tcp_rx_timeout_val) |
| 2752 | params.tcp_rx_timeout_val = |
| 2753 | ucfg_pmo_extwow_app2_tcp_rx_timeout(hdd_ctx->psoc); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2754 | |
Srinivas Girigowda | 951b3f6 | 2020-08-10 16:54:46 -0700 | [diff] [blame] | 2755 | hdd_debug(QDF_MAC_ADDR_FMT" %.16s %u %u %u %u %u %u %u %u %u %u %u %u %u", |
| 2756 | QDF_MAC_ADDR_REF(gateway_mac), rc4_key, params.ip_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2757 | params.ip_device_ip, params.ip_server_ip, params.tcp_seq, |
| 2758 | params.tcp_ack_seq, params.tcp_src_port, params.tcp_dst_port, |
| 2759 | params.keepalive_init, params.keepalive_min, |
| 2760 | params.keepalive_max, params.keepalive_inc, |
| 2761 | params.tcp_tx_timeout_val, params.tcp_rx_timeout_val); |
| 2762 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 2763 | return hdd_set_app_type2_params(hdd_ctx->mac_handle, ¶ms); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2764 | } |
| 2765 | #endif /* WLAN_FEATURE_EXTWOW_SUPPORT */ |
| 2766 | |
| 2767 | /** |
| 2768 | * hdd_parse_setmaxtxpower_command() - HDD Parse MAXTXPOWER command |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 2769 | * @command: Pointer to MAXTXPOWER command |
Jeff Johnson | 93f47cf | 2019-02-26 13:08:48 -0800 | [diff] [blame] | 2770 | * @tx_power: Pointer to tx power |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2771 | * |
| 2772 | * This function parses the MAXTXPOWER command passed in the format |
| 2773 | * MAXTXPOWER<space>X(Tx power in dbm) |
| 2774 | * |
| 2775 | * For example input commands: |
| 2776 | * 1) MAXTXPOWER -8 -> This is translated into set max TX power to -8 dbm |
| 2777 | * 2) MAXTXPOWER -23 -> This is translated into set max TX power to -23 dbm |
| 2778 | * |
| 2779 | * Return: 0 for success non-zero for failure |
| 2780 | */ |
Jeff Johnson | 93f47cf | 2019-02-26 13:08:48 -0800 | [diff] [blame] | 2781 | static int hdd_parse_setmaxtxpower_command(uint8_t *command, int *tx_power) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2782 | { |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 2783 | uint8_t *in_ptr = command; |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 2784 | int temp_int; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2785 | int v = 0; |
Jeff Johnson | 93f47cf | 2019-02-26 13:08:48 -0800 | [diff] [blame] | 2786 | *tx_power = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2787 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 2788 | in_ptr = strnchr(command, strlen(command), SPACE_ASCII_VALUE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2789 | /* no argument after the command */ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2790 | if (!in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2791 | return -EINVAL; |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 2792 | else if (SPACE_ASCII_VALUE != *in_ptr) /* no space after the command */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2793 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2794 | |
| 2795 | /* remove empty spaces */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 2796 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 2797 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2798 | |
| 2799 | /* no argument followed by spaces */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 2800 | if ('\0' == *in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2801 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2802 | |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 2803 | v = kstrtos32(in_ptr, 10, &temp_int); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2804 | |
| 2805 | /* Range checking for passed parameter */ |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 2806 | 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] | 2807 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2808 | |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 2809 | *tx_power = temp_int; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2810 | |
Jeff Johnson | 93f47cf | 2019-02-26 13:08:48 -0800 | [diff] [blame] | 2811 | hdd_debug("SETMAXTXPOWER: %d", *tx_power); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2812 | |
| 2813 | return 0; |
| 2814 | } /* End of hdd_parse_setmaxtxpower_command */ |
| 2815 | |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2816 | 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] | 2817 | char *extra, uint8_t n, uint8_t *len) |
| 2818 | { |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2819 | uint32_t val = 0; |
| 2820 | |
| 2821 | if (!psoc || !command || !extra || !len) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 2822 | hdd_err("argument passed for GETDWELLTIME is incorrect"); |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 2823 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2824 | } |
| 2825 | |
| 2826 | if (strncmp(command, "GETDWELLTIME ACTIVE MAX", 23) == 0) { |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2827 | ucfg_scan_cfg_get_active_dwelltime(psoc, &val); |
| 2828 | *len = scnprintf(extra, n, "GETDWELLTIME ACTIVE MAX %u\n", val); |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 2829 | return 0; |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 2830 | } |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 2831 | if (strncmp(command, "GETDWELLTIME PASSIVE MAX", 24) == 0) { |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2832 | ucfg_scan_cfg_get_passive_dwelltime(psoc, &val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2833 | *len = scnprintf(extra, n, "GETDWELLTIME PASSIVE MAX %u\n", |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2834 | val); |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 2835 | return 0; |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 2836 | } |
Ashish Kumar Dhanotiya | 223fdc4 | 2020-02-12 12:58:09 +0530 | [diff] [blame] | 2837 | if (strncmp(command, "GETDWELLTIME 2G MAX", 19) == 0) { |
| 2838 | ucfg_scan_cfg_get_active_2g_dwelltime(psoc, &val); |
| 2839 | *len = scnprintf(extra, n, "GETDWELLTIME 2G MAX %u\n", |
| 2840 | val); |
| 2841 | return 0; |
| 2842 | } |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 2843 | if (strncmp(command, "GETDWELLTIME", 12) == 0) { |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2844 | ucfg_scan_cfg_get_active_dwelltime(psoc, &val); |
| 2845 | *len = scnprintf(extra, n, "GETDWELLTIME %u\n", val); |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 2846 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2847 | } |
| 2848 | |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 2849 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2850 | } |
| 2851 | |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2852 | 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] | 2853 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2854 | uint8_t *value = command; |
Srinivas Girigowda | a9ce5e6 | 2019-03-28 13:44:31 -0700 | [diff] [blame] | 2855 | int retval = 0, temp = 0; |
| 2856 | uint32_t val = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2857 | |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2858 | if (!psoc) { |
| 2859 | hdd_err("psoc is null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2860 | return -EINVAL; |
| 2861 | } |
| 2862 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2863 | if (strncmp(command, "SETDWELLTIME ACTIVE MAX", 23) == 0) { |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 2864 | if (drv_cmd_validate(command, 23)) |
| 2865 | return -EINVAL; |
| 2866 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2867 | value = value + 24; |
| 2868 | temp = kstrtou32(value, 10, &val); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2869 | if (temp || !cfg_in_range(CFG_ACTIVE_MAX_CHANNEL_TIME, val)) { |
Ashish Kumar Dhanotiya | 223fdc4 | 2020-02-12 12:58:09 +0530 | [diff] [blame] | 2870 | hdd_err_rl("argument passed for SETDWELLTIME ACTIVE MAX is incorrect"); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2871 | return -EFAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2872 | } |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2873 | ucfg_scan_cfg_set_active_dwelltime(psoc, val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2874 | } else if (strncmp(command, "SETDWELLTIME PASSIVE MAX", 24) == 0) { |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 2875 | if (drv_cmd_validate(command, 24)) |
| 2876 | return -EINVAL; |
| 2877 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2878 | value = value + 25; |
| 2879 | temp = kstrtou32(value, 10, &val); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2880 | if (temp || !cfg_in_range(CFG_PASSIVE_MAX_CHANNEL_TIME, val)) { |
Ashish Kumar Dhanotiya | 223fdc4 | 2020-02-12 12:58:09 +0530 | [diff] [blame] | 2881 | hdd_err_rl("argument passed for SETDWELLTIME PASSIVE MAX is incorrect"); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2882 | return -EFAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2883 | } |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2884 | ucfg_scan_cfg_set_passive_dwelltime(psoc, val); |
Ashish Kumar Dhanotiya | 223fdc4 | 2020-02-12 12:58:09 +0530 | [diff] [blame] | 2885 | } else if (strncmp(command, "SETDWELLTIME 2G MAX", 19) == 0) { |
| 2886 | if (drv_cmd_validate(command, 19)) |
| 2887 | return -EINVAL; |
| 2888 | |
| 2889 | value = value + 20; |
| 2890 | temp = kstrtou32(value, 10, &val); |
| 2891 | if (temp || !cfg_in_range(CFG_ACTIVE_MAX_2G_CHANNEL_TIME, |
| 2892 | val)) { |
| 2893 | hdd_err_rl("argument passed for SETDWELLTIME 2G MAX is incorrect"); |
| 2894 | return -EFAULT; |
| 2895 | } |
| 2896 | ucfg_scan_cfg_set_active_2g_dwelltime(psoc, val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2897 | } else if (strncmp(command, "SETDWELLTIME", 12) == 0) { |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 2898 | if (drv_cmd_validate(command, 12)) |
| 2899 | return -EINVAL; |
| 2900 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2901 | value = value + 13; |
| 2902 | temp = kstrtou32(value, 10, &val); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2903 | if (temp || !cfg_in_range(CFG_ACTIVE_MAX_CHANNEL_TIME, val)) { |
Ashish Kumar Dhanotiya | 223fdc4 | 2020-02-12 12:58:09 +0530 | [diff] [blame] | 2904 | hdd_err_rl("argument passed for SETDWELLTIME is incorrect"); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2905 | return -EFAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2906 | } |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2907 | ucfg_scan_cfg_set_active_dwelltime(psoc, val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2908 | } else { |
Sridhar Selvaraj | 48c4709 | 2017-07-31 18:18:14 +0530 | [diff] [blame] | 2909 | retval = -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2910 | } |
| 2911 | |
Sridhar Selvaraj | 48c4709 | 2017-07-31 18:18:14 +0530 | [diff] [blame] | 2912 | return retval; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2913 | } |
| 2914 | |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 2915 | struct link_status_priv { |
| 2916 | uint8_t link_status; |
| 2917 | }; |
| 2918 | |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2919 | /** |
| 2920 | * hdd_conc_set_dwell_time() - Set Concurrent dwell time parameters |
| 2921 | * @adapter: Adapter upon which the command was received |
| 2922 | * @command: ASCII text command that is received |
| 2923 | * |
| 2924 | * Driver commands: |
| 2925 | * wpa_cli DRIVER CONCSETDWELLTIME ACTIVE MAX <value> |
| 2926 | * wpa_cli DRIVER CONCSETDWELLTIME ACTIVE MIN <value> |
| 2927 | * wpa_cli DRIVER CONCSETDWELLTIME PASSIVE MAX <value> |
| 2928 | * wpa_cli DRIVER CONCSETDWELLTIME PASSIVE MIN <value> |
| 2929 | * |
| 2930 | * Return: 0 for success non-zero for failure |
| 2931 | */ |
Ashish Kumar Dhanotiya | 652c233 | 2018-12-11 17:33:17 +0530 | [diff] [blame] | 2932 | static int hdd_conc_set_dwell_time(struct hdd_adapter *adapter, |
| 2933 | uint8_t *command) |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2934 | { |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2935 | u8 *value = command; |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2936 | int val = 0, temp = 0; |
| 2937 | int retval = 0; |
| 2938 | |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2939 | if (strncmp(command, "CONCSETDWELLTIME ACTIVE MAX", 27) == 0) { |
| 2940 | if (drv_cmd_validate(command, 27)) { |
| 2941 | hdd_err("Invalid driver command"); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2942 | return -EINVAL; |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2943 | } |
| 2944 | |
| 2945 | value = value + 28; |
| 2946 | temp = kstrtou32(value, 10, &val); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2947 | if (temp || |
| 2948 | !cfg_in_range(CFG_ACTIVE_MAX_CHANNEL_TIME_CONC, val)) { |
Harprit Chhabada | 4691a47 | 2018-12-07 11:22:48 -0800 | [diff] [blame] | 2949 | hdd_err("CONC ACTIVE MAX value %d incorrect", val); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2950 | return -EFAULT; |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2951 | } |
Ashish Kumar Dhanotiya | 652c233 | 2018-12-11 17:33:17 +0530 | [diff] [blame] | 2952 | ucfg_scan_cfg_set_conc_active_dwelltime( |
| 2953 | (WLAN_HDD_GET_CTX(adapter))->psoc, val); |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2954 | } else if (strncmp(command, "CONCSETDWELLTIME PASSIVE MAX", 28) == 0) { |
| 2955 | if (drv_cmd_validate(command, 28)) { |
| 2956 | hdd_err("Invalid driver command"); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2957 | return -EINVAL; |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2958 | } |
| 2959 | |
| 2960 | value = value + 29; |
| 2961 | temp = kstrtou32(value, 10, &val); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2962 | if (temp || |
| 2963 | !cfg_in_range(CFG_PASSIVE_MAX_CHANNEL_TIME_CONC, val)) { |
Harprit Chhabada | 4691a47 | 2018-12-07 11:22:48 -0800 | [diff] [blame] | 2964 | hdd_err("CONC PASSIVE MAX val %d incorrect", val); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 2965 | return -EFAULT; |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2966 | } |
Ashish Kumar Dhanotiya | 652c233 | 2018-12-11 17:33:17 +0530 | [diff] [blame] | 2967 | ucfg_scan_cfg_set_conc_passive_dwelltime( |
| 2968 | (WLAN_HDD_GET_CTX(adapter))->psoc, val); |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2969 | } else { |
| 2970 | retval = -EINVAL; |
| 2971 | } |
| 2972 | |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2973 | return retval; |
| 2974 | } |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 2975 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2976 | static void hdd_get_link_status_cb(uint8_t status, void *context) |
| 2977 | { |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 2978 | struct osif_request *request; |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 2979 | struct link_status_priv *priv; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2980 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 2981 | request = osif_request_get(context); |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 2982 | if (!request) { |
| 2983 | hdd_err("Obsolete request"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2984 | return; |
| 2985 | } |
| 2986 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 2987 | priv = osif_request_priv(request); |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 2988 | priv->link_status = status; |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 2989 | osif_request_complete(request); |
| 2990 | osif_request_put(request); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2991 | } |
| 2992 | |
| 2993 | /** |
| 2994 | * wlan_hdd_get_link_status() - get link status |
Jeff Johnson | 25c7734 | 2017-10-02 13:28:03 -0700 | [diff] [blame] | 2995 | * @adapter: pointer to the adapter |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2996 | * |
| 2997 | * This function sends a request to query the link status and waits |
| 2998 | * on a timer to invoke the callback. if the callback is invoked then |
| 2999 | * latest link status shall be returned or otherwise cached value |
| 3000 | * will be returned. |
| 3001 | * |
| 3002 | * Return: On success, link status shall be returned. |
| 3003 | * On error or not associated, link status 0 will be returned. |
| 3004 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3005 | static int wlan_hdd_get_link_status(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3006 | { |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3007 | struct hdd_station_ctx *sta_ctx; |
| 3008 | QDF_STATUS status; |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 3009 | int ret; |
| 3010 | void *cookie; |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 3011 | struct osif_request *request; |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 3012 | struct link_status_priv *priv; |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 3013 | static const struct osif_request_params params = { |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 3014 | .priv_size = sizeof(*priv), |
| 3015 | .timeout_ms = WLAN_WAIT_TIME_LINK_STATUS, |
| 3016 | }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3017 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 3018 | if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) { |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 3019 | hdd_warn("Recovery in Progress. State: 0x%x Ignore!!!", |
| 3020 | cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3021 | return 0; |
| 3022 | } |
| 3023 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 3024 | if ((QDF_STA_MODE != adapter->device_mode) && |
| 3025 | (QDF_P2P_CLIENT_MODE != adapter->device_mode)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3026 | hdd_warn("Unsupported in mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 3027 | qdf_opmode_str(adapter->device_mode), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3028 | adapter->device_mode); |
| 3029 | return 0; |
| 3030 | } |
| 3031 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 3032 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 3033 | if (eConnectionState_Associated != sta_ctx->conn_info.conn_state) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3034 | /* If not associated, then expected link status return |
| 3035 | * value is 0 |
| 3036 | */ |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 3037 | hdd_warn("Not associated!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3038 | return 0; |
| 3039 | } |
| 3040 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 3041 | request = osif_request_alloc(¶ms); |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 3042 | if (!request) { |
| 3043 | hdd_err("Request allocation failure"); |
| 3044 | return 0; |
| 3045 | } |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 3046 | cookie = osif_request_cookie(request); |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 3047 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3048 | status = sme_get_link_status(adapter->hdd_ctx->mac_handle, |
| 3049 | hdd_get_link_status_cb, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3050 | cookie, adapter->vdev_id); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3051 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3052 | hdd_err("Unable to retrieve link status"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3053 | /* return a cached value */ |
| 3054 | } else { |
| 3055 | /* request is sent -- wait for the response */ |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 3056 | ret = osif_request_wait_for_response(request); |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 3057 | if (ret) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3058 | hdd_err("SME timed out while retrieving link status"); |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 3059 | /* return a cached value */ |
| 3060 | } else { |
| 3061 | /* update the adapter with the fresh results */ |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 3062 | priv = osif_request_priv(request); |
Jeff Johnson | bd4c4f0 | 2017-10-30 20:33:01 -0700 | [diff] [blame] | 3063 | adapter->link_status = priv->link_status; |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 3064 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3065 | } |
| 3066 | |
Jeff Johnson | 253c0c2 | 2017-01-23 16:59:38 -0800 | [diff] [blame] | 3067 | /* |
| 3068 | * either we never sent a request, we sent a request and |
| 3069 | * received a response or we sent a request and timed out. |
| 3070 | * regardless we are done with the request. |
| 3071 | */ |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 3072 | osif_request_put(request); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3073 | |
| 3074 | /* either callback updated adapter stats or it has cached data */ |
Jeff Johnson | bd4c4f0 | 2017-10-30 20:33:01 -0700 | [diff] [blame] | 3075 | return adapter->link_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3076 | } |
| 3077 | |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 3078 | #ifdef FEATURE_WLAN_ESE |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3079 | /** |
| 3080 | * hdd_parse_ese_beacon_req() - Parse ese beacon request |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 3081 | * @command: Pointer to data |
Jeff Johnson | b2c3d04 | 2019-02-26 12:23:26 -0800 | [diff] [blame] | 3082 | * @req: Output pointer to store parsed ie information |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3083 | * |
| 3084 | * This function parses the ese beacon request passed in the format |
| 3085 | * CCXBEACONREQ<space><Number of fields><space><Measurement token> |
| 3086 | * <space>Channel 1<space>Scan Mode <space>Meas Duration<space>Channel N |
| 3087 | * <space>Scan Mode N<space>Meas Duration N |
| 3088 | * |
| 3089 | * If the Number of bcn req fields (N) does not match with the |
| 3090 | * actual number of fields passed then take N. |
| 3091 | * <Meas Token><Channel><Scan Mode> and <Meas Duration> are treated |
| 3092 | * as one pair. For example, CCXBEACONREQ 2 1 1 1 30 2 44 0 40. |
| 3093 | * This function does not take care of removing duplicate channels from the |
| 3094 | * list |
| 3095 | * |
| 3096 | * Return: 0 for success non-zero for failure |
| 3097 | */ |
gaurank kathpalia | 88f78ec | 2019-09-04 20:18:02 +0530 | [diff] [blame] | 3098 | static int hdd_parse_ese_beacon_req(struct wlan_objmgr_pdev *pdev, |
| 3099 | uint8_t *command, |
Jeff Johnson | b2c3d04 | 2019-02-26 12:23:26 -0800 | [diff] [blame] | 3100 | tCsrEseBeaconReq *req) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3101 | { |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 3102 | uint8_t *in_ptr = command; |
Srinivas Girigowda | 67e2da6 | 2016-07-19 16:33:01 -0700 | [diff] [blame] | 3103 | uint8_t input = 0; |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 3104 | uint32_t temp_int = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3105 | int j = 0, i = 0, v = 0; |
| 3106 | char buf[32]; |
| 3107 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 3108 | in_ptr = strnchr(command, strlen(command), SPACE_ASCII_VALUE); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 3109 | if (!in_ptr) /* no argument after the command */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3110 | return -EINVAL; |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 3111 | else if (SPACE_ASCII_VALUE != *in_ptr) /* no space after the command */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3112 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3113 | |
| 3114 | /* remove empty spaces */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 3115 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 3116 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3117 | |
| 3118 | /* no argument followed by spaces */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 3119 | if ('\0' == *in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3120 | return -EINVAL; |
| 3121 | |
Srinivas Girigowda | 476deeb | 2016-07-19 16:21:29 -0700 | [diff] [blame] | 3122 | /* Getting the first argument ie Number of IE fields */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 3123 | v = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3124 | if (1 != v) |
| 3125 | return -EINVAL; |
| 3126 | |
Srinivas Girigowda | 67e2da6 | 2016-07-19 16:33:01 -0700 | [diff] [blame] | 3127 | v = kstrtou8(buf, 10, &input); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3128 | if (v < 0) |
| 3129 | return -EINVAL; |
| 3130 | |
Srinivas Girigowda | 67e2da6 | 2016-07-19 16:33:01 -0700 | [diff] [blame] | 3131 | input = QDF_MIN(input, SIR_ESE_MAX_MEAS_IE_REQS); |
Jeff Johnson | b2c3d04 | 2019-02-26 12:23:26 -0800 | [diff] [blame] | 3132 | req->numBcnReqIe = input; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3133 | |
Jeff Johnson | b2c3d04 | 2019-02-26 12:23:26 -0800 | [diff] [blame] | 3134 | hdd_debug("Number of Bcn Req Ie fields: %d", req->numBcnReqIe); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3135 | |
Jeff Johnson | b2c3d04 | 2019-02-26 12:23:26 -0800 | [diff] [blame] | 3136 | for (j = 0; j < (req->numBcnReqIe); j++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3137 | for (i = 0; i < 4; i++) { |
| 3138 | /* |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 3139 | * in_ptr pointing to the beginning of 1st space |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3140 | * after number of ie fields |
| 3141 | */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 3142 | in_ptr = strpbrk(in_ptr, " "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3143 | /* no ie data after the number of ie fields argument */ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 3144 | if (!in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3145 | return -EINVAL; |
| 3146 | |
| 3147 | /* remove empty space */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 3148 | while ((SPACE_ASCII_VALUE == *in_ptr) |
| 3149 | && ('\0' != *in_ptr)) |
| 3150 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3151 | |
| 3152 | /* |
| 3153 | * no ie data after the number of ie fields |
| 3154 | * argument and spaces |
| 3155 | */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 3156 | if ('\0' == *in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3157 | return -EINVAL; |
| 3158 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 3159 | v = sscanf(in_ptr, "%31s ", buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3160 | if (1 != v) |
| 3161 | return -EINVAL; |
| 3162 | |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 3163 | v = kstrtou32(buf, 10, &temp_int); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3164 | if (v < 0) |
| 3165 | return -EINVAL; |
| 3166 | |
| 3167 | switch (i) { |
| 3168 | case 0: /* Measurement token */ |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 3169 | if (!temp_int) { |
Srinivas Girigowda | 67e2da6 | 2016-07-19 16:33:01 -0700 | [diff] [blame] | 3170 | hdd_err("Invalid Measurement Token: %u", |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 3171 | temp_int); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3172 | return -EINVAL; |
| 3173 | } |
Jeff Johnson | b2c3d04 | 2019-02-26 12:23:26 -0800 | [diff] [blame] | 3174 | req->bcnReq[j].measurementToken = |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 3175 | temp_int; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3176 | break; |
| 3177 | |
| 3178 | case 1: /* Channel number */ |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 3179 | if (!temp_int || |
| 3180 | (temp_int > |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3181 | WNI_CFG_CURRENT_CHANNEL_STAMAX)) { |
Srinivas Girigowda | 67e2da6 | 2016-07-19 16:33:01 -0700 | [diff] [blame] | 3182 | hdd_err("Invalid Channel Number: %u", |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 3183 | temp_int); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3184 | return -EINVAL; |
| 3185 | } |
gaurank kathpalia | 88f78ec | 2019-09-04 20:18:02 +0530 | [diff] [blame] | 3186 | req->bcnReq[j].ch_freq = |
| 3187 | wlan_reg_chan_to_freq(pdev, temp_int); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3188 | break; |
| 3189 | |
| 3190 | case 2: /* Scan mode */ |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 3191 | if ((temp_int < eSIR_PASSIVE_SCAN) |
| 3192 | || (temp_int > eSIR_BEACON_TABLE)) { |
Srinivas Girigowda | 67e2da6 | 2016-07-19 16:33:01 -0700 | [diff] [blame] | 3193 | hdd_err("Invalid Scan Mode: %u Expected{0|1|2}", |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 3194 | temp_int); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3195 | return -EINVAL; |
| 3196 | } |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 3197 | req->bcnReq[j].scanMode = temp_int; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3198 | break; |
| 3199 | |
| 3200 | case 3: /* Measurement duration */ |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 3201 | if ((!temp_int |
Jeff Johnson | b2c3d04 | 2019-02-26 12:23:26 -0800 | [diff] [blame] | 3202 | && (req->bcnReq[j].scanMode != |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3203 | eSIR_BEACON_TABLE)) || |
Jeff Johnson | b2c3d04 | 2019-02-26 12:23:26 -0800 | [diff] [blame] | 3204 | (req->bcnReq[j].scanMode == |
Srinivas Girigowda | 67e2da6 | 2016-07-19 16:33:01 -0700 | [diff] [blame] | 3205 | eSIR_BEACON_TABLE)) { |
| 3206 | hdd_err("Invalid Measurement Duration: %u", |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 3207 | temp_int); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3208 | return -EINVAL; |
| 3209 | } |
Jeff Johnson | b2c3d04 | 2019-02-26 12:23:26 -0800 | [diff] [blame] | 3210 | req->bcnReq[j].measurementDuration = |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 3211 | temp_int; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3212 | break; |
| 3213 | } |
| 3214 | } |
| 3215 | } |
| 3216 | |
Jeff Johnson | b2c3d04 | 2019-02-26 12:23:26 -0800 | [diff] [blame] | 3217 | for (j = 0; j < req->numBcnReqIe; j++) { |
gaurank kathpalia | 88f78ec | 2019-09-04 20:18:02 +0530 | [diff] [blame] | 3218 | 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] | 3219 | j, |
Jeff Johnson | b2c3d04 | 2019-02-26 12:23:26 -0800 | [diff] [blame] | 3220 | req->bcnReq[j].measurementToken, |
gaurank kathpalia | 88f78ec | 2019-09-04 20:18:02 +0530 | [diff] [blame] | 3221 | req->bcnReq[j].ch_freq, |
Jeff Johnson | b2c3d04 | 2019-02-26 12:23:26 -0800 | [diff] [blame] | 3222 | req->bcnReq[j].scanMode, |
| 3223 | req->bcnReq[j].measurementDuration); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3224 | } |
| 3225 | |
| 3226 | return 0; |
| 3227 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3228 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3229 | /** |
| 3230 | * hdd_parse_get_cckm_ie() - HDD Parse and fetch the CCKM IE |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 3231 | * @command: Pointer to input data |
Jeff Johnson | 64c01b1 | 2019-02-26 13:12:50 -0800 | [diff] [blame] | 3232 | * @cckm_ie: Pointer to output cckm Ie |
Jeff Johnson | ecbb79f | 2019-02-26 13:10:24 -0800 | [diff] [blame] | 3233 | * @cckm_ie_len: Pointer to output cckm ie length |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3234 | * |
| 3235 | * This function parses the SETCCKM IE command |
| 3236 | * SETCCKMIE<space><ie data> |
| 3237 | * |
| 3238 | * Return: 0 for success non-zero for failure |
| 3239 | */ |
Jeff Johnson | 64c01b1 | 2019-02-26 13:12:50 -0800 | [diff] [blame] | 3240 | 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] | 3241 | uint8_t *cckm_ie_len) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3242 | { |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 3243 | uint8_t *in_ptr = command; |
Jeff Johnson | aae00ae | 2019-02-26 17:25:11 -0800 | [diff] [blame] | 3244 | uint8_t *end_ptr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3245 | int j = 0; |
| 3246 | int i = 0; |
Jeff Johnson | 72f498b | 2019-02-26 18:37:25 -0800 | [diff] [blame] | 3247 | uint8_t temp_u8 = 0; |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 3248 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 3249 | in_ptr = strnchr(command, strlen(command), SPACE_ASCII_VALUE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3250 | /* no argument after the command */ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 3251 | if (!in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3252 | return -EINVAL; |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 3253 | else if (SPACE_ASCII_VALUE != *in_ptr) /* no space after the command */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3254 | return -EINVAL; |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 3255 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3256 | /* remove empty spaces */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 3257 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 3258 | in_ptr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3259 | /* no argument followed by spaces */ |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 3260 | if ('\0' == *in_ptr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3261 | return -EINVAL; |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 3262 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3263 | /* find the length of data */ |
Jeff Johnson | aae00ae | 2019-02-26 17:25:11 -0800 | [diff] [blame] | 3264 | end_ptr = in_ptr; |
| 3265 | while (('\0' != *end_ptr)) { |
| 3266 | end_ptr++; |
Jeff Johnson | ecbb79f | 2019-02-26 13:10:24 -0800 | [diff] [blame] | 3267 | ++(*cckm_ie_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3268 | } |
Jeff Johnson | ecbb79f | 2019-02-26 13:10:24 -0800 | [diff] [blame] | 3269 | if (*cckm_ie_len <= 0) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3270 | return -EINVAL; |
| 3271 | /* |
| 3272 | * Allocate the number of bytes based on the number of input characters |
| 3273 | * whether it is even or odd. |
| 3274 | * if the number of input characters are even, then we need N / 2 byte. |
| 3275 | * if the number of input characters are odd, then we need do |
| 3276 | * (N + 1) / 2 to compensate rounding off. |
| 3277 | * For example, if N = 18, then (18 + 1) / 2 = 9 bytes are enough. |
| 3278 | * If N = 19, then we need 10 bytes, hence (19 + 1) / 2 = 10 bytes |
| 3279 | */ |
Jeff Johnson | 64c01b1 | 2019-02-26 13:12:50 -0800 | [diff] [blame] | 3280 | *cckm_ie = qdf_mem_malloc((*cckm_ie_len + 1) / 2); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 3281 | if (!*cckm_ie) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3282 | hdd_err("qdf_mem_malloc failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3283 | return -ENOMEM; |
| 3284 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3285 | /* |
| 3286 | * the buffer received from the upper layer is character buffer, |
| 3287 | * we need to prepare the buffer taking 2 characters in to a U8 hex |
| 3288 | * decimal number for example 7f0000f0...form a buffer to contain |
| 3289 | * 7f in 0th location, 00 in 1st and f0 in 3rd location |
| 3290 | */ |
Jeff Johnson | ecbb79f | 2019-02-26 13:10:24 -0800 | [diff] [blame] | 3291 | for (i = 0, j = 0; j < *cckm_ie_len; j += 2) { |
Jeff Johnson | 72f498b | 2019-02-26 18:37:25 -0800 | [diff] [blame] | 3292 | temp_u8 = (hex_to_bin(in_ptr[j]) << 4) | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 3293 | (hex_to_bin(in_ptr[j + 1])); |
Jeff Johnson | 72f498b | 2019-02-26 18:37:25 -0800 | [diff] [blame] | 3294 | (*cckm_ie)[i++] = temp_u8; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3295 | } |
Jeff Johnson | ecbb79f | 2019-02-26 13:10:24 -0800 | [diff] [blame] | 3296 | *cckm_ie_len = i; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3297 | return 0; |
| 3298 | } |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 3299 | #endif /* FEATURE_WLAN_ESE */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3300 | |
Jeff Johnson | b3f8043 | 2019-02-26 20:25:38 -0800 | [diff] [blame] | 3301 | 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] | 3302 | { |
Jeff Johnson | 1a0c72b | 2019-02-26 20:29:43 -0800 | [diff] [blame] | 3303 | tSirRateUpdateInd rate_update = {0}; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3304 | QDF_STATUS status; |
Jeff Johnson | 25c7734 | 2017-10-02 13:28:03 -0700 | [diff] [blame] | 3305 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 3306 | bool bval = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3307 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 3308 | if (!hdd_ctx) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3309 | hdd_err("HDD context is null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3310 | return -EINVAL; |
| 3311 | } |
Jeff Johnson | 25c7734 | 2017-10-02 13:28:03 -0700 | [diff] [blame] | 3312 | if ((QDF_IBSS_MODE != adapter->device_mode) && |
| 3313 | (QDF_SAP_MODE != adapter->device_mode) && |
| 3314 | (QDF_STA_MODE != adapter->device_mode)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3315 | hdd_err("Received SETMCRATE cmd in invalid mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 3316 | qdf_opmode_str(adapter->device_mode), |
| 3317 | adapter->device_mode); |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3318 | 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] | 3319 | return -EINVAL; |
| 3320 | } |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 3321 | |
| 3322 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 3323 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 3324 | hdd_err("unable to get vht_enable2x2"); |
| 3325 | return -EINVAL; |
| 3326 | } |
Jeff Johnson | 1a0c72b | 2019-02-26 20:29:43 -0800 | [diff] [blame] | 3327 | rate_update.nss = (bval == 0) ? 0 : 1; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 3328 | |
Jeff Johnson | 1a0c72b | 2019-02-26 20:29:43 -0800 | [diff] [blame] | 3329 | rate_update.dev_mode = adapter->device_mode; |
| 3330 | rate_update.mcastDataRate24GHz = target_rate; |
| 3331 | rate_update.mcastDataRate24GHzTxFlag = 1; |
| 3332 | rate_update.mcastDataRate5GHz = target_rate; |
| 3333 | rate_update.bcastDataRate = -1; |
| 3334 | qdf_copy_macaddr(&rate_update.bssid, &adapter->mac_addr); |
Srinivas Girigowda | 951b3f6 | 2020-08-10 16:54:46 -0700 | [diff] [blame] | 3335 | hdd_debug("MC Target rate %d, mac = "QDF_MAC_ADDR_FMT", dev_mode %s(%d)", |
| 3336 | rate_update.mcastDataRate24GHz, |
| 3337 | QDF_MAC_ADDR_REF(rate_update.bssid.bytes), |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 3338 | qdf_opmode_str(adapter->device_mode), adapter->device_mode); |
Jeff Johnson | 1a0c72b | 2019-02-26 20:29:43 -0800 | [diff] [blame] | 3339 | status = sme_send_rate_update_ind(hdd_ctx->mac_handle, &rate_update); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3340 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3341 | hdd_err("SETMCRATE failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3342 | return -EFAULT; |
| 3343 | } |
| 3344 | return 0; |
| 3345 | } |
| 3346 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3347 | static int drv_cmd_p2p_dev_addr(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3348 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3349 | uint8_t *command, |
| 3350 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3351 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3352 | { |
Dustin Brown | ee22071 | 2018-04-19 16:24:23 -0700 | [diff] [blame] | 3353 | struct qdf_mac_addr *addr = &hdd_ctx->p2p_device_address; |
| 3354 | size_t user_size = qdf_min(sizeof(addr->bytes), |
| 3355 | (size_t)priv_data->total_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3356 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3357 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 3358 | TRACE_CODE_HDD_P2P_DEV_ADDR_IOCTL, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3359 | adapter->vdev_id, |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3360 | (unsigned int)(*(addr->bytes + 2) << 24 | |
Dustin Brown | ee22071 | 2018-04-19 16:24:23 -0700 | [diff] [blame] | 3361 | *(addr->bytes + 3) << 16 | |
| 3362 | *(addr->bytes + 4) << 8 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3363 | *(addr->bytes + 5))); |
| 3364 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3365 | |
Dustin Brown | ee22071 | 2018-04-19 16:24:23 -0700 | [diff] [blame] | 3366 | if (copy_to_user(priv_data->buf, addr->bytes, user_size)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3367 | hdd_err("failed to copy data to user buffer"); |
Dustin Brown | ee22071 | 2018-04-19 16:24:23 -0700 | [diff] [blame] | 3368 | return -EFAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3369 | } |
| 3370 | |
Dustin Brown | ee22071 | 2018-04-19 16:24:23 -0700 | [diff] [blame] | 3371 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3372 | } |
| 3373 | |
| 3374 | /** |
| 3375 | * drv_cmd_p2p_set_noa() - Handler for P2P_SET_NOA driver command |
| 3376 | * @adapter: Adapter on which the command was received |
| 3377 | * @hdd_ctx: HDD global context |
| 3378 | * @command: Entire driver command received from userspace |
| 3379 | * @command_len: Length of @command |
| 3380 | * @priv_data: Pointer to ioctl private data structure |
| 3381 | * |
Jeff Johnson | 78073fa | 2018-05-06 16:08:58 -0700 | [diff] [blame] | 3382 | * This is a trivial command handler function which simply forwards the |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3383 | * command to the actual command processor within the P2P module. |
| 3384 | * |
| 3385 | * Return: 0 on success, non-zero on failure |
| 3386 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3387 | static int drv_cmd_p2p_set_noa(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3388 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3389 | uint8_t *command, |
| 3390 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3391 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3392 | { |
| 3393 | return hdd_set_p2p_noa(adapter->dev, command); |
| 3394 | } |
| 3395 | |
| 3396 | /** |
| 3397 | * drv_cmd_p2p_set_ps() - Handler for P2P_SET_PS driver command |
| 3398 | * @adapter: Adapter on which the command was received |
| 3399 | * @hdd_ctx: HDD global context |
| 3400 | * @command: Entire driver command received from userspace |
| 3401 | * @command_len: Length of @command |
| 3402 | * @priv_data: Pointer to ioctl private data structure |
| 3403 | * |
Jeff Johnson | 78073fa | 2018-05-06 16:08:58 -0700 | [diff] [blame] | 3404 | * This is a trivial command handler function which simply forwards the |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3405 | * command to the actual command processor within the P2P module. |
| 3406 | * |
| 3407 | * Return: 0 on success, non-zero on failure |
| 3408 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3409 | static int drv_cmd_p2p_set_ps(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3410 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3411 | uint8_t *command, |
| 3412 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3413 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3414 | { |
| 3415 | return hdd_set_p2p_opps(adapter->dev, command); |
| 3416 | } |
| 3417 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3418 | static int drv_cmd_set_band(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3419 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3420 | uint8_t *command, |
| 3421 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3422 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3423 | { |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 3424 | int err; |
| 3425 | uint8_t band; |
Lincoln Tran | 0fb32be | 2020-06-16 13:37:06 -0700 | [diff] [blame] | 3426 | uint32_t band_bitmap; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3427 | |
| 3428 | /* |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 3429 | * Parse the band value passed from userspace. The first 8 bytes |
| 3430 | * 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] | 3431 | */ |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 3432 | err = kstrtou8(command + command_len + 1, 10, &band); |
| 3433 | if (err) { |
| 3434 | hdd_err("error %d parsing userspace band parameter", err); |
| 3435 | return err; |
| 3436 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3437 | |
Lincoln Tran | 0fb32be | 2020-06-16 13:37:06 -0700 | [diff] [blame] | 3438 | band_bitmap = hdd_reg_legacy_setband_to_reg_wifi_band_bitmap(band); |
| 3439 | |
| 3440 | return hdd_reg_set_band(adapter->dev, band_bitmap); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3441 | } |
| 3442 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3443 | static int drv_cmd_set_wmmps(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3444 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3445 | uint8_t *command, |
| 3446 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3447 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3448 | { |
| 3449 | return hdd_wmmps_helper(adapter, command); |
| 3450 | } |
| 3451 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3452 | static inline int drv_cmd_country(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3453 | struct hdd_context *hdd_ctx, |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 3454 | uint8_t *command, |
| 3455 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3456 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3457 | { |
Sourav Mohapatra | a30c457 | 2018-05-22 11:18:39 +0530 | [diff] [blame] | 3458 | char *country_code; |
| 3459 | |
| 3460 | country_code = strnchr(command, strlen(command), ' '); |
| 3461 | /* no argument after the command */ |
| 3462 | if (!country_code) |
| 3463 | return -EINVAL; |
| 3464 | |
| 3465 | /* no space after the command */ |
| 3466 | if (*country_code != SPACE_ASCII_VALUE) |
| 3467 | return -EINVAL; |
| 3468 | |
| 3469 | country_code++; |
| 3470 | |
| 3471 | /* removing empty spaces */ |
| 3472 | while ((*country_code == SPACE_ASCII_VALUE) && |
| 3473 | (*country_code != '\0')) |
| 3474 | country_code++; |
| 3475 | |
| 3476 | /* no or less than 2 arguments followed by spaces */ |
| 3477 | if (*country_code == '\0' || *(country_code + 1) == '\0') |
| 3478 | return -EINVAL; |
| 3479 | |
| 3480 | return hdd_reg_set_country(hdd_ctx, country_code); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3481 | } |
| 3482 | |
Rajeev Kumar Sirasanagandla | 32ae804 | 2019-03-25 16:37:02 +0530 | [diff] [blame] | 3483 | /** |
| 3484 | * drv_cmd_get_country() - Helper function to get current county code |
| 3485 | * @adapter: pointer to adapter on which request is received |
| 3486 | * @hdd_ctx: pointer to hdd context |
| 3487 | * @command: command name |
| 3488 | * @command_len: command buffer length |
| 3489 | * @priv_data: output pointer to hold current country code |
| 3490 | * |
| 3491 | * Return: On success 0, negative value on error. |
| 3492 | */ |
| 3493 | static int drv_cmd_get_country(struct hdd_adapter *adapter, |
| 3494 | struct hdd_context *hdd_ctx, |
| 3495 | uint8_t *command, uint8_t command_len, |
| 3496 | struct hdd_priv_data *priv_data) |
| 3497 | { |
| 3498 | uint8_t buf[SIZE_OF_GETCOUNTRYREV_OUTPUT] = {0}; |
| 3499 | uint8_t cc[REG_ALPHA2_LEN + 1]; |
| 3500 | int ret = 0, len; |
| 3501 | |
| 3502 | qdf_mem_copy(cc, hdd_ctx->reg.alpha2, REG_ALPHA2_LEN); |
| 3503 | cc[REG_ALPHA2_LEN] = '\0'; |
| 3504 | |
| 3505 | len = scnprintf(buf, sizeof(buf), "%s %s", |
| 3506 | "GETCOUNTRYREV", cc); |
| 3507 | hdd_debug("buf = %s", buf); |
| 3508 | len = QDF_MIN(priv_data->total_len, len + 1); |
| 3509 | if (copy_to_user(priv_data->buf, buf, len)) { |
| 3510 | hdd_err("failed to copy data to user buffer"); |
| 3511 | ret = -EFAULT; |
| 3512 | } |
| 3513 | |
| 3514 | return ret; |
| 3515 | } |
| 3516 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3517 | static int drv_cmd_set_roam_trigger(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3518 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3519 | uint8_t *command, |
| 3520 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3521 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3522 | { |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3523 | int ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3524 | uint8_t *value = command; |
| 3525 | int8_t rssi = 0; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3526 | uint8_t lookup_threshold = cfg_default( |
| 3527 | CFG_LFR_NEIGHBOR_LOOKUP_RSSI_THRESHOLD); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3528 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3529 | |
| 3530 | /* Move pointer to ahead of SETROAMTRIGGER<delimiter> */ |
| 3531 | value = value + command_len + 1; |
| 3532 | |
| 3533 | /* Convert the value from ascii to integer */ |
| 3534 | ret = kstrtos8(value, 10, &rssi); |
| 3535 | if (ret < 0) { |
| 3536 | /* |
| 3537 | * If the input value is greater than max value of datatype, |
| 3538 | * then also kstrtou8 fails |
| 3539 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3540 | 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] | 3541 | cfg_min(CFG_LFR_NEIGHBOR_LOOKUP_RSSI_THRESHOLD), |
| 3542 | cfg_max(CFG_LFR_NEIGHBOR_LOOKUP_RSSI_THRESHOLD)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3543 | ret = -EINVAL; |
| 3544 | goto exit; |
| 3545 | } |
| 3546 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3547 | lookup_threshold = abs(rssi); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3548 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3549 | if (!cfg_in_range(CFG_LFR_NEIGHBOR_LOOKUP_RSSI_THRESHOLD, |
| 3550 | lookup_threshold)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3551 | 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] | 3552 | lookup_threshold, |
| 3553 | cfg_min(CFG_LFR_NEIGHBOR_LOOKUP_RSSI_THRESHOLD), |
| 3554 | cfg_max(CFG_LFR_NEIGHBOR_LOOKUP_RSSI_THRESHOLD)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3555 | ret = -EINVAL; |
| 3556 | goto exit; |
| 3557 | } |
| 3558 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3559 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 3560 | TRACE_CODE_HDD_SETROAMTRIGGER_IOCTL, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3561 | adapter->vdev_id, lookup_threshold); |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3562 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 3563 | hdd_debug("Received Command to Set Roam trigger (Neighbor lookup threshold) = %d", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3564 | lookup_threshold); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3565 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3566 | status = sme_set_neighbor_lookup_rssi_threshold(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3567 | adapter->vdev_id, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3568 | lookup_threshold); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3569 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3570 | hdd_err("Failed to set roam trigger, try again"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3571 | ret = -EPERM; |
| 3572 | goto exit; |
| 3573 | } |
| 3574 | |
| 3575 | exit: |
| 3576 | return ret; |
| 3577 | } |
| 3578 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3579 | static int drv_cmd_get_roam_trigger(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3580 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3581 | uint8_t *command, |
| 3582 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3583 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3584 | { |
| 3585 | int ret = 0; |
Srinivas Dasari | 9249a98 | 2019-09-16 14:56:27 +0530 | [diff] [blame] | 3586 | uint8_t lookup_threshold; |
| 3587 | int rssi; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3588 | char extra[32]; |
| 3589 | uint8_t len = 0; |
Srinivas Dasari | 9249a98 | 2019-09-16 14:56:27 +0530 | [diff] [blame] | 3590 | QDF_STATUS status; |
| 3591 | |
| 3592 | status = sme_get_neighbor_lookup_rssi_threshold(hdd_ctx->mac_handle, |
| 3593 | adapter->vdev_id, |
| 3594 | &lookup_threshold); |
| 3595 | if (QDF_IS_STATUS_ERROR(status)) |
| 3596 | return qdf_status_to_os_return(status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3597 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3598 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 3599 | TRACE_CODE_HDD_GETROAMTRIGGER_IOCTL, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3600 | adapter->vdev_id, lookup_threshold); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3601 | |
Srinivas Dasari | 9249a98 | 2019-09-16 14:56:27 +0530 | [diff] [blame] | 3602 | hdd_debug("vdev_id: %u, lookup_threshold: %u", |
| 3603 | adapter->vdev_id, lookup_threshold); |
| 3604 | |
| 3605 | rssi = (-1) * lookup_threshold; |
| 3606 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3607 | len = scnprintf(extra, sizeof(extra), "%s %d", command, rssi); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3608 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3609 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3610 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3611 | ret = -EFAULT; |
| 3612 | } |
| 3613 | |
| 3614 | return ret; |
| 3615 | } |
| 3616 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3617 | static int drv_cmd_set_roam_scan_period(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3618 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3619 | uint8_t *command, |
| 3620 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3621 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3622 | { |
| 3623 | int ret = 0; |
| 3624 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3625 | uint8_t roam_scan_period = 0; |
| 3626 | uint16_t empty_scan_refresh_period = |
| 3627 | cfg_default(CFG_LFR_EMPTY_SCAN_REFRESH_PERIOD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3628 | |
| 3629 | /* input refresh period is in terms of seconds */ |
| 3630 | |
| 3631 | /* Move pointer to ahead of SETROAMSCANPERIOD<delimiter> */ |
| 3632 | value = value + command_len + 1; |
| 3633 | |
| 3634 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3635 | ret = kstrtou8(value, 10, &roam_scan_period); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3636 | if (ret < 0) { |
| 3637 | /* |
| 3638 | * If the input value is greater than max value of datatype, |
| 3639 | * then also kstrtou8 fails |
| 3640 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3641 | 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] | 3642 | (cfg_min(CFG_LFR_EMPTY_SCAN_REFRESH_PERIOD) / 1000), |
| 3643 | (cfg_max(CFG_LFR_EMPTY_SCAN_REFRESH_PERIOD) / 1000)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3644 | ret = -EINVAL; |
| 3645 | goto exit; |
| 3646 | } |
| 3647 | |
Srinivas Dasari | b5d9f3e | 2019-08-22 01:43:42 +0530 | [diff] [blame] | 3648 | if (!ucfg_mlme_validate_scan_period(roam_scan_period * 1000)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3649 | ret = -EINVAL; |
| 3650 | goto exit; |
| 3651 | } |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3652 | |
| 3653 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 3654 | TRACE_CODE_HDD_SETROAMSCANPERIOD_IOCTL, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3655 | adapter->vdev_id, roam_scan_period); |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3656 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3657 | empty_scan_refresh_period = roam_scan_period * 1000; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3658 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 3659 | 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] | 3660 | roam_scan_period); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3661 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3662 | sme_update_empty_scan_refresh_period(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3663 | adapter->vdev_id, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3664 | empty_scan_refresh_period); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3665 | |
| 3666 | exit: |
| 3667 | return ret; |
| 3668 | } |
| 3669 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3670 | static int drv_cmd_get_roam_scan_period(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3671 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3672 | uint8_t *command, |
| 3673 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3674 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3675 | { |
| 3676 | int ret = 0; |
Srinivas Dasari | 456aa70 | 2019-09-17 14:19:50 +0530 | [diff] [blame] | 3677 | uint16_t empty_scan_refresh_period; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3678 | char extra[32]; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3679 | uint8_t len; |
Srinivas Dasari | 456aa70 | 2019-09-17 14:19:50 +0530 | [diff] [blame] | 3680 | QDF_STATUS status; |
| 3681 | |
| 3682 | status = sme_get_empty_scan_refresh_period(hdd_ctx->mac_handle, |
| 3683 | adapter->vdev_id, |
| 3684 | &empty_scan_refresh_period); |
| 3685 | if (QDF_IS_STATUS_ERROR(status)) |
| 3686 | return qdf_status_to_os_return(status); |
| 3687 | |
| 3688 | hdd_debug("vdev_id: %u, empty_scan_refresh_period: %u", |
| 3689 | adapter->vdev_id, empty_scan_refresh_period); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3690 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3691 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 3692 | TRACE_CODE_HDD_GETROAMSCANPERIOD_IOCTL, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3693 | adapter->vdev_id, |
Jeff Johnson | 9625945 | 2019-02-26 20:38:17 -0800 | [diff] [blame] | 3694 | empty_scan_refresh_period); |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3695 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3696 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3697 | "GETROAMSCANPERIOD", |
Jeff Johnson | 9625945 | 2019-02-26 20:38:17 -0800 | [diff] [blame] | 3698 | (empty_scan_refresh_period / 1000)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3699 | /* Returned value is in units of seconds */ |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3700 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3701 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3702 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3703 | ret = -EFAULT; |
| 3704 | } |
| 3705 | |
| 3706 | return ret; |
| 3707 | } |
| 3708 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3709 | 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] | 3710 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3711 | uint8_t *command, |
| 3712 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3713 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3714 | { |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3715 | int ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3716 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3717 | uint8_t roam_scan_refresh_period = 0; |
| 3718 | uint16_t neighbor_scan_refresh_period = |
| 3719 | cfg_default(CFG_LFR_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3720 | |
| 3721 | /* input refresh period is in terms of seconds */ |
| 3722 | /* Move pointer to ahead of SETROAMSCANREFRESHPERIOD<delimiter> */ |
| 3723 | value = value + command_len + 1; |
| 3724 | |
| 3725 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3726 | ret = kstrtou8(value, 10, &roam_scan_refresh_period); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3727 | if (ret < 0) { |
| 3728 | /* |
| 3729 | * If the input value is greater than max value of datatype, |
| 3730 | * then also kstrtou8 fails |
| 3731 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3732 | 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] | 3733 | (cfg_min(CFG_LFR_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD) |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3734 | / 1000), |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3735 | (cfg_max(CFG_LFR_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD) |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3736 | / 1000)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3737 | ret = -EINVAL; |
| 3738 | goto exit; |
| 3739 | } |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3740 | |
| 3741 | if (!cfg_in_range(CFG_LFR_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD, |
| 3742 | roam_scan_refresh_period)) { |
| 3743 | hdd_err("Neighbor scan results refresh period value %d is out of range (Min: %d Max: %d)", |
| 3744 | roam_scan_refresh_period, |
| 3745 | (cfg_min(CFG_LFR_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD) |
| 3746 | / 1000), |
| 3747 | (cfg_max(CFG_LFR_NEIGHBOR_SCAN_RESULTS_REFRESH_PERIOD) |
| 3748 | / 1000)); |
| 3749 | ret = -EINVAL; |
| 3750 | goto exit; |
| 3751 | } |
| 3752 | neighbor_scan_refresh_period = roam_scan_refresh_period * 1000; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3753 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 3754 | 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] | 3755 | neighbor_scan_refresh_period); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3756 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3757 | sme_set_neighbor_scan_refresh_period(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3758 | adapter->vdev_id, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3759 | neighbor_scan_refresh_period); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3760 | |
| 3761 | exit: |
| 3762 | return ret; |
| 3763 | } |
| 3764 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3765 | 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] | 3766 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3767 | uint8_t *command, |
| 3768 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3769 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3770 | { |
| 3771 | int ret = 0; |
| 3772 | uint16_t value = |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3773 | sme_get_neighbor_scan_refresh_period(hdd_ctx->mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3774 | char extra[32]; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3775 | uint8_t len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3776 | |
| 3777 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 3778 | "GETROAMSCANREFRESHPERIOD", |
| 3779 | (value / 1000)); |
| 3780 | /* Returned value is in units of seconds */ |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3781 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3782 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3783 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3784 | ret = -EFAULT; |
| 3785 | } |
| 3786 | |
| 3787 | return ret; |
| 3788 | } |
| 3789 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3790 | static int drv_cmd_set_roam_mode(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3791 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3792 | uint8_t *command, |
| 3793 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3794 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3795 | { |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3796 | mac_handle_t mac_handle; |
| 3797 | int ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3798 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3799 | uint8_t roam_mode = cfg_default(CFG_LFR_FEATURE_ENABLED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3800 | |
| 3801 | /* Move pointer to ahead of SETROAMMODE<delimiter> */ |
| 3802 | value = value + SIZE_OF_SETROAMMODE + 1; |
| 3803 | |
| 3804 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3805 | ret = kstrtou8(value, 10, &roam_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3806 | if (ret < 0) { |
| 3807 | /* |
| 3808 | * If the input value is greater than max value of datatype, |
| 3809 | * then also kstrtou8 fails |
| 3810 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3811 | hdd_err("kstrtou8 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3812 | cfg_min(CFG_LFR_FEATURE_ENABLED), |
| 3813 | cfg_max(CFG_LFR_FEATURE_ENABLED)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3814 | ret = -EINVAL; |
| 3815 | goto exit; |
| 3816 | } |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3817 | |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3818 | hdd_debug("Received Command to Set Roam Mode = %d", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3819 | roam_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3820 | /* |
| 3821 | * Note that |
| 3822 | * SETROAMMODE 0 is to enable LFR while |
| 3823 | * SETROAMMODE 1 is to disable LFR, but |
| 3824 | * notify_is_fast_roam_ini_feature_enabled 0/1 is to |
| 3825 | * enable/disable. So, we have to invert the value |
| 3826 | * to call sme_update_is_fast_roam_ini_feature_enabled. |
| 3827 | */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3828 | if (roam_mode) { |
| 3829 | /* Roam enable */ |
| 3830 | roam_mode = cfg_min(CFG_LFR_FEATURE_ENABLED); |
| 3831 | } else { |
| 3832 | /* Roam disable */ |
| 3833 | roam_mode = cfg_max(CFG_LFR_FEATURE_ENABLED); |
| 3834 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3835 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3836 | ucfg_mlme_set_lfr_enabled(hdd_ctx->psoc, (bool)roam_mode); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3837 | mac_handle = hdd_ctx->mac_handle; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3838 | if (roam_mode) { |
| 3839 | ucfg_mlme_set_roam_scan_offload_enabled(hdd_ctx->psoc, |
| 3840 | (bool)roam_mode); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3841 | sme_update_is_fast_roam_ini_feature_enabled(mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3842 | adapter->vdev_id, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3843 | roam_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3844 | } else { |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3845 | sme_update_is_fast_roam_ini_feature_enabled(mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3846 | adapter->vdev_id, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3847 | roam_mode); |
| 3848 | ucfg_mlme_set_roam_scan_offload_enabled(hdd_ctx->psoc, |
| 3849 | roam_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3850 | } |
| 3851 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3852 | exit: |
| 3853 | return ret; |
| 3854 | } |
| 3855 | |
Pragaspathi Thilagaraj | aa8320e | 2019-04-16 02:47:50 +0530 | [diff] [blame] | 3856 | static int drv_cmd_set_suspend_mode(struct hdd_adapter *adapter, |
| 3857 | struct hdd_context *hdd_ctx, |
| 3858 | uint8_t *command, |
| 3859 | uint8_t command_len, |
| 3860 | struct hdd_priv_data *priv_data) |
| 3861 | { |
| 3862 | int errno; |
| 3863 | uint8_t *value = command; |
| 3864 | QDF_STATUS status; |
| 3865 | uint8_t idle_monitor; |
| 3866 | |
| 3867 | if (QDF_STA_MODE != adapter->device_mode) { |
| 3868 | hdd_debug("Non-STA interface"); |
| 3869 | return 0; |
| 3870 | } |
| 3871 | |
| 3872 | /* Move pointer to ahead of SETSUSPENDMODE<delimiter> */ |
| 3873 | value = value + SIZE_OF_SETSUSPENDMODE + 1; |
| 3874 | |
| 3875 | /* Convert the value from ascii to integer */ |
| 3876 | errno = kstrtou8(value, 10, &idle_monitor); |
| 3877 | if (errno < 0) { |
| 3878 | /* |
| 3879 | * If the input value is greater than max value of datatype, |
| 3880 | * then also kstrtou8 fails |
| 3881 | */ |
| 3882 | hdd_err("Range validation failed"); |
| 3883 | return -EINVAL; |
| 3884 | } |
| 3885 | |
| 3886 | hdd_debug("idle_monitor:%d", idle_monitor); |
| 3887 | status = ucfg_pmo_tgt_psoc_send_idle_roam_suspend_mode(hdd_ctx->psoc, |
| 3888 | idle_monitor); |
| 3889 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3890 | hdd_debug("Send suspend mode to fw failed"); |
| 3891 | return -EINVAL; |
| 3892 | } |
| 3893 | return 0; |
| 3894 | } |
| 3895 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3896 | static int drv_cmd_get_roam_mode(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3897 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3898 | uint8_t *command, |
| 3899 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3900 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3901 | { |
| 3902 | int ret = 0; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3903 | 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] | 3904 | char extra[32]; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3905 | uint8_t len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3906 | |
| 3907 | /* |
| 3908 | * roamMode value shall be inverted because the sementics is different. |
| 3909 | */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3910 | if (roam_mode) |
| 3911 | roam_mode = cfg_min(CFG_LFR_FEATURE_ENABLED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3912 | else |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3913 | roam_mode = cfg_max(CFG_LFR_FEATURE_ENABLED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3914 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3915 | len = scnprintf(extra, sizeof(extra), "%s %d", command, roam_mode); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3916 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3917 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3918 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3919 | ret = -EFAULT; |
| 3920 | } |
| 3921 | |
| 3922 | return ret; |
| 3923 | } |
| 3924 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3925 | static int drv_cmd_set_roam_delta(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3926 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3927 | uint8_t *command, |
| 3928 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3929 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3930 | { |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3931 | int ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3932 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3933 | uint8_t roam_rssi_diff = cfg_default(CFG_LFR_ROAM_RSSI_DIFF); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3934 | |
| 3935 | /* Move pointer to ahead of SETROAMDELTA<delimiter> */ |
| 3936 | value = value + command_len + 1; |
| 3937 | |
| 3938 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3939 | ret = kstrtou8(value, 10, &roam_rssi_diff); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3940 | if (ret < 0) { |
| 3941 | /* |
| 3942 | * If the input value is greater than max value of datatype, |
| 3943 | * then also kstrtou8 fails |
| 3944 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3945 | hdd_err("kstrtou8 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3946 | cfg_min(CFG_LFR_ROAM_RSSI_DIFF), |
| 3947 | cfg_max(CFG_LFR_ROAM_RSSI_DIFF)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3948 | ret = -EINVAL; |
| 3949 | goto exit; |
| 3950 | } |
| 3951 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3952 | if (!cfg_in_range(CFG_LFR_ROAM_RSSI_DIFF, roam_rssi_diff)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3953 | 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] | 3954 | roam_rssi_diff, |
| 3955 | cfg_min(CFG_LFR_ROAM_RSSI_DIFF), |
| 3956 | cfg_max(CFG_LFR_ROAM_RSSI_DIFF)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3957 | ret = -EINVAL; |
| 3958 | goto exit; |
| 3959 | } |
| 3960 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 3961 | hdd_debug("Received Command to Set roam rssi diff = %d", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3962 | roam_rssi_diff); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3963 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3964 | sme_update_roam_rssi_diff(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3965 | adapter->vdev_id, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3966 | roam_rssi_diff); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3967 | |
| 3968 | exit: |
| 3969 | return ret; |
| 3970 | } |
| 3971 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 3972 | static int drv_cmd_get_roam_delta(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 3973 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3974 | uint8_t *command, |
| 3975 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 3976 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3977 | { |
| 3978 | int ret = 0; |
Srinivas Dasari | 7f48ac0 | 2019-09-16 17:44:43 +0530 | [diff] [blame] | 3979 | uint8_t rssi_diff; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3980 | char extra[32]; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 3981 | uint8_t len; |
Srinivas Dasari | 7f48ac0 | 2019-09-16 17:44:43 +0530 | [diff] [blame] | 3982 | QDF_STATUS status; |
| 3983 | |
| 3984 | status = sme_get_roam_rssi_diff(hdd_ctx->mac_handle, adapter->vdev_id, |
| 3985 | &rssi_diff); |
| 3986 | if (QDF_IS_STATUS_ERROR(status)) |
| 3987 | return qdf_status_to_os_return(status); |
| 3988 | |
| 3989 | 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] | 3990 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3991 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 3992 | TRACE_CODE_HDD_GETROAMDELTA_IOCTL, |
Jeff Johnson | 6500380 | 2019-02-26 20:50:49 -0800 | [diff] [blame] | 3993 | adapter->vdev_id, rssi_diff); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3994 | len = scnprintf(extra, sizeof(extra), "%s %d", |
Jeff Johnson | 6500380 | 2019-02-26 20:50:49 -0800 | [diff] [blame] | 3995 | command, rssi_diff); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3996 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3997 | |
| 3998 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 3999 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4000 | ret = -EFAULT; |
| 4001 | } |
| 4002 | |
| 4003 | return ret; |
| 4004 | } |
| 4005 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4006 | static int drv_cmd_get_band(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4007 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4008 | uint8_t *command, |
| 4009 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4010 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4011 | { |
| 4012 | int ret = 0; |
| 4013 | int band = -1; |
| 4014 | char extra[32]; |
| 4015 | uint8_t len = 0; |
| 4016 | |
| 4017 | hdd_get_band_helper(hdd_ctx, &band); |
| 4018 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 4019 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 4020 | TRACE_CODE_HDD_GETBAND_IOCTL, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4021 | adapter->vdev_id, band); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4022 | |
| 4023 | len = scnprintf(extra, sizeof(extra), "%s %d", command, band); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4024 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4025 | |
| 4026 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4027 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4028 | ret = -EFAULT; |
| 4029 | } |
| 4030 | |
| 4031 | return ret; |
| 4032 | } |
| 4033 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4034 | static int drv_cmd_set_roam_scan_channels(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4035 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4036 | uint8_t *command, |
| 4037 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4038 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4039 | { |
| 4040 | return hdd_parse_set_roam_scan_channels(adapter, command); |
| 4041 | } |
| 4042 | |
Abhishek Ambure | 5e9b6a4 | 2020-02-12 21:32:35 +0530 | [diff] [blame] | 4043 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 4044 | static bool is_roam_ch_from_fw_supported(struct hdd_context *hdd_ctx) |
| 4045 | { |
| 4046 | return hdd_ctx->roam_ch_from_fw_supported; |
| 4047 | } |
| 4048 | |
| 4049 | struct roam_ch_priv { |
| 4050 | struct roam_scan_ch_resp roam_ch; |
| 4051 | }; |
| 4052 | |
| 4053 | void hdd_get_roam_scan_ch_cb(hdd_handle_t hdd_handle, |
| 4054 | struct roam_scan_ch_resp *roam_ch, |
| 4055 | void *context) |
| 4056 | { |
| 4057 | struct osif_request *request; |
| 4058 | struct roam_ch_priv *priv; |
| 4059 | uint8_t *event = NULL, i = 0; |
| 4060 | uint32_t *freq = NULL, len; |
| 4061 | struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle); |
| 4062 | |
| 4063 | hdd_debug("roam scan ch list event received : vdev_id:%d command resp: %d", |
| 4064 | roam_ch->vdev_id, roam_ch->command_resp); |
| 4065 | /** |
| 4066 | * If command response is set in the response message, then it is |
| 4067 | * getroamscanchannels command response else this event is asyncronous |
| 4068 | * event raised by firmware. |
| 4069 | */ |
| 4070 | if (!roam_ch->command_resp) { |
| 4071 | len = roam_ch->num_channels * sizeof(roam_ch->chan_list[0]); |
sheenam monga | 6d9aaff | 2020-03-16 11:53:23 +0530 | [diff] [blame] | 4072 | if (!len) { |
| 4073 | hdd_err("Invalid len"); |
| 4074 | return; |
| 4075 | } |
Abhishek Ambure | 5e9b6a4 | 2020-02-12 21:32:35 +0530 | [diff] [blame] | 4076 | event = (uint8_t *)qdf_mem_malloc(len); |
| 4077 | if (!event) { |
| 4078 | hdd_err("Failed to alloc event response buf vdev_id: %d", |
| 4079 | roam_ch->vdev_id); |
| 4080 | return; |
| 4081 | } |
| 4082 | freq = (uint32_t *)event; |
| 4083 | for (i = 0; i < roam_ch->num_channels && |
| 4084 | i < WNI_CFG_VALID_CHANNEL_LIST_LEN; i++) { |
| 4085 | freq[i] = roam_ch->chan_list[i]; |
| 4086 | } |
| 4087 | |
Abhishek Ambure | 3823c36 | 2020-03-18 14:15:08 +0530 | [diff] [blame] | 4088 | hdd_send_roam_scan_ch_list_event(hdd_ctx, roam_ch->vdev_id, |
| 4089 | len, event); |
Abhishek Ambure | 5e9b6a4 | 2020-02-12 21:32:35 +0530 | [diff] [blame] | 4090 | qdf_mem_free(event); |
| 4091 | return; |
| 4092 | } |
| 4093 | |
| 4094 | request = osif_request_get(context); |
| 4095 | if (!request) { |
| 4096 | hdd_err("Obsolete request"); |
| 4097 | return; |
| 4098 | } |
| 4099 | priv = osif_request_priv(request); |
| 4100 | |
| 4101 | priv->roam_ch.num_channels = roam_ch->num_channels; |
| 4102 | for (i = 0; i < priv->roam_ch.num_channels && |
| 4103 | i < WNI_CFG_VALID_CHANNEL_LIST_LEN; i++) |
| 4104 | priv->roam_ch.chan_list[i] = roam_ch->chan_list[i]; |
| 4105 | |
| 4106 | osif_request_complete(request); |
| 4107 | osif_request_put(request); |
| 4108 | } |
| 4109 | |
| 4110 | static uint32_t |
| 4111 | hdd_get_roam_chan_from_fw(struct hdd_adapter *adapter, uint32_t *chan_list, |
| 4112 | uint8_t *num_channels) |
| 4113 | { |
| 4114 | QDF_STATUS status = QDF_STATUS_E_INVAL; |
| 4115 | struct hdd_context *hdd_ctx; |
| 4116 | int ret, i; |
| 4117 | void *cookie; |
| 4118 | struct osif_request *request; |
| 4119 | struct roam_ch_priv *priv; |
| 4120 | struct roam_scan_ch_resp *p_roam_ch; |
| 4121 | static const struct osif_request_params params = { |
| 4122 | .priv_size = sizeof(*priv) + |
| 4123 | sizeof(priv->roam_ch.chan_list[0]) * |
| 4124 | WNI_CFG_VALID_CHANNEL_LIST_LEN, |
| 4125 | .timeout_ms = WLAN_WAIT_TIME_STATS, |
| 4126 | }; |
| 4127 | |
| 4128 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 4129 | request = osif_request_alloc(¶ms); |
| 4130 | if (!request) { |
| 4131 | hdd_err("Request allocation failure"); |
| 4132 | return -ENOMEM; |
| 4133 | } |
| 4134 | |
| 4135 | priv = osif_request_priv(request); |
| 4136 | p_roam_ch = &priv->roam_ch; |
| 4137 | /** channel list starts after response structure*/ |
| 4138 | priv->roam_ch.chan_list = (uint32_t *)(p_roam_ch + 1); |
| 4139 | cookie = osif_request_cookie(request); |
| 4140 | status = sme_get_roam_scan_ch(hdd_ctx->mac_handle, |
| 4141 | adapter->vdev_id, cookie); |
| 4142 | |
| 4143 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4144 | hdd_err("Unable to retrieve roam channels"); |
| 4145 | ret = qdf_status_to_os_return(status); |
| 4146 | goto cleanup; |
| 4147 | } |
| 4148 | |
| 4149 | ret = osif_request_wait_for_response(request); |
| 4150 | if (ret) { |
| 4151 | hdd_err("SME timed out while retrieving raom channels"); |
| 4152 | goto cleanup; |
| 4153 | } |
| 4154 | |
| 4155 | priv = osif_request_priv(request); |
| 4156 | *num_channels = priv->roam_ch.num_channels; |
| 4157 | for (i = 0; i < *num_channels; i++) |
| 4158 | chan_list[i] = priv->roam_ch.chan_list[i]; |
| 4159 | |
| 4160 | cleanup: |
| 4161 | osif_request_put(request); |
| 4162 | |
| 4163 | return ret; |
| 4164 | } |
Abhishek Ambure | 5e9b6a4 | 2020-02-12 21:32:35 +0530 | [diff] [blame] | 4165 | |
Abhishek Ambure | d9c047f | 2020-07-06 02:26:37 +0530 | [diff] [blame] | 4166 | int |
| 4167 | hdd_get_roam_scan_freq(struct hdd_adapter *adapter, mac_handle_t mac_handle, |
| 4168 | uint32_t *chan_list, uint8_t *num_channels) |
Abhishek Ambure | 5e9b6a4 | 2020-02-12 21:32:35 +0530 | [diff] [blame] | 4169 | { |
Abhishek Ambure | d9c047f | 2020-07-06 02:26:37 +0530 | [diff] [blame] | 4170 | int ret = 0; |
| 4171 | |
| 4172 | if (!adapter || !mac_handle || !chan_list || !num_channels) { |
| 4173 | hdd_err("failed to get roam scan channel, invalid input"); |
| 4174 | return -EFAULT; |
| 4175 | } |
| 4176 | |
| 4177 | if (is_roam_ch_from_fw_supported(adapter->hdd_ctx)) { |
| 4178 | ret = hdd_get_roam_chan_from_fw(adapter, chan_list, |
| 4179 | num_channels); |
| 4180 | if (ret != QDF_STATUS_SUCCESS) { |
| 4181 | hdd_err("failed to get roam scan channel list from FW"); |
| 4182 | return -EFAULT; |
| 4183 | } |
| 4184 | |
| 4185 | return ret; |
| 4186 | } |
| 4187 | |
| 4188 | if (sme_get_roam_scan_channel_list(mac_handle, chan_list, |
| 4189 | num_channels, adapter->vdev_id) != |
| 4190 | QDF_STATUS_SUCCESS) { |
| 4191 | hdd_err("failed to get roam scan channel list"); |
| 4192 | return -EFAULT; |
| 4193 | } |
| 4194 | |
| 4195 | return ret; |
Abhishek Ambure | 5e9b6a4 | 2020-02-12 21:32:35 +0530 | [diff] [blame] | 4196 | } |
| 4197 | #endif |
| 4198 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4199 | static int drv_cmd_get_roam_scan_channels(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4200 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4201 | uint8_t *command, |
| 4202 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4203 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4204 | { |
| 4205 | int ret = 0; |
Jianmin Zhu | 203d753 | 2019-10-28 17:17:05 +0800 | [diff] [blame] | 4206 | uint32_t freq_list[CFG_VALID_CHANNEL_LIST_LEN] = { 0 }; |
Jeff Johnson | 8a2e1da | 2019-02-26 17:56:24 -0800 | [diff] [blame] | 4207 | uint8_t num_channels = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4208 | uint8_t j = 0; |
| 4209 | char extra[128] = { 0 }; |
| 4210 | int len; |
Jianmin Zhu | 203d753 | 2019-10-28 17:17:05 +0800 | [diff] [blame] | 4211 | uint8_t chan; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4212 | |
Abhishek Ambure | d9c047f | 2020-07-06 02:26:37 +0530 | [diff] [blame] | 4213 | ret = hdd_get_roam_scan_freq(adapter, hdd_ctx->mac_handle, freq_list, |
| 4214 | &num_channels); |
| 4215 | if (ret != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4216 | goto exit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4217 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 4218 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 4219 | TRACE_CODE_HDD_GETROAMSCANCHANNELS_IOCTL, |
Jeff Johnson | 8a2e1da | 2019-02-26 17:56:24 -0800 | [diff] [blame] | 4220 | adapter->vdev_id, num_channels); |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 4221 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4222 | /* |
| 4223 | * output channel list is of the format |
| 4224 | * [Number of roam scan channels][Channel1][Channel2]... |
| 4225 | * copy the number of channels in the 0th index |
| 4226 | */ |
| 4227 | len = scnprintf(extra, sizeof(extra), "%s %d", command, |
Jeff Johnson | 8a2e1da | 2019-02-26 17:56:24 -0800 | [diff] [blame] | 4228 | num_channels); |
Jianmin Zhu | 203d753 | 2019-10-28 17:17:05 +0800 | [diff] [blame] | 4229 | for (j = 0; (j < num_channels) && len <= sizeof(extra); j++) { |
| 4230 | chan = wlan_reg_freq_to_chan(hdd_ctx->pdev, freq_list[j]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4231 | len += scnprintf(extra + len, sizeof(extra) - len, |
Jianmin Zhu | 203d753 | 2019-10-28 17:17:05 +0800 | [diff] [blame] | 4232 | " %d", chan); |
| 4233 | } |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4234 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4235 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4236 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4237 | ret = -EFAULT; |
| 4238 | goto exit; |
| 4239 | } |
| 4240 | |
| 4241 | exit: |
| 4242 | return ret; |
| 4243 | } |
| 4244 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4245 | static int drv_cmd_get_ccx_mode(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4246 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4247 | uint8_t *command, |
| 4248 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4249 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4250 | { |
| 4251 | int ret = 0; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4252 | mac_handle_t mac_handle = hdd_ctx->mac_handle; |
Jeff Johnson | 22345e1 | 2019-02-26 21:33:02 -0800 | [diff] [blame] | 4253 | bool ese_mode = sme_get_is_ese_feature_enabled(mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4254 | char extra[32]; |
| 4255 | uint8_t len = 0; |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 4256 | struct pmkid_mode_bits pmkid_modes; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4257 | |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 4258 | hdd_get_pmkid_modes(hdd_ctx, &pmkid_modes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4259 | /* |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 4260 | * Check if the features PMKID/ESE/11R are supported simultaneously, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4261 | * then this operation is not permitted (return FAILURE) |
| 4262 | */ |
Jeff Johnson | 22345e1 | 2019-02-26 21:33:02 -0800 | [diff] [blame] | 4263 | if (ese_mode && |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 4264 | (pmkid_modes.fw_okc || pmkid_modes.fw_pmksa_cache) && |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4265 | sme_get_is_ft_feature_enabled(mac_handle)) { |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 4266 | 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] | 4267 | ret = -EPERM; |
| 4268 | goto exit; |
| 4269 | } |
| 4270 | |
| 4271 | len = scnprintf(extra, sizeof(extra), "%s %d", |
Jeff Johnson | 22345e1 | 2019-02-26 21:33:02 -0800 | [diff] [blame] | 4272 | "GETCCXMODE", ese_mode); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4273 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4274 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4275 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4276 | ret = -EFAULT; |
| 4277 | goto exit; |
| 4278 | } |
| 4279 | |
| 4280 | exit: |
| 4281 | return ret; |
| 4282 | } |
| 4283 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4284 | static int drv_cmd_get_okc_mode(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4285 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4286 | uint8_t *command, |
| 4287 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4288 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4289 | { |
| 4290 | int ret = 0; |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 4291 | struct pmkid_mode_bits pmkid_modes; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4292 | char extra[32]; |
| 4293 | uint8_t len = 0; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4294 | mac_handle_t mac_handle = hdd_ctx->mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4295 | |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 4296 | hdd_get_pmkid_modes(hdd_ctx, &pmkid_modes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4297 | /* |
| 4298 | * Check if the features OKC/ESE/11R are supported simultaneously, |
| 4299 | * then this operation is not permitted (return FAILURE) |
| 4300 | */ |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 4301 | if (pmkid_modes.fw_okc && |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4302 | sme_get_is_ese_feature_enabled(mac_handle) && |
| 4303 | sme_get_is_ft_feature_enabled(mac_handle)) { |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 4304 | 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] | 4305 | ret = -EPERM; |
| 4306 | goto exit; |
| 4307 | } |
| 4308 | |
| 4309 | len = scnprintf(extra, sizeof(extra), "%s %d", |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 4310 | "GETOKCMODE", pmkid_modes.fw_okc); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4311 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4312 | |
| 4313 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4314 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4315 | ret = -EFAULT; |
| 4316 | goto exit; |
| 4317 | } |
| 4318 | |
| 4319 | exit: |
| 4320 | return ret; |
| 4321 | } |
| 4322 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4323 | static int drv_cmd_get_fast_roam(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4324 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4325 | uint8_t *command, |
| 4326 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4327 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4328 | { |
| 4329 | int ret = 0; |
Jeff Johnson | 22345e1 | 2019-02-26 21:33:02 -0800 | [diff] [blame] | 4330 | 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] | 4331 | char extra[32]; |
| 4332 | uint8_t len = 0; |
| 4333 | |
| 4334 | len = scnprintf(extra, sizeof(extra), "%s %d", |
Jeff Johnson | 22345e1 | 2019-02-26 21:33:02 -0800 | [diff] [blame] | 4335 | "GETFASTROAM", lfr_mode); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4336 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4337 | |
| 4338 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4339 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4340 | ret = -EFAULT; |
| 4341 | } |
| 4342 | |
| 4343 | return ret; |
| 4344 | } |
| 4345 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4346 | static int drv_cmd_get_fast_transition(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4347 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4348 | uint8_t *command, |
| 4349 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4350 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4351 | { |
| 4352 | int ret = 0; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4353 | bool ft = sme_get_is_ft_feature_enabled(hdd_ctx->mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4354 | char extra[32]; |
| 4355 | uint8_t len = 0; |
| 4356 | |
| 4357 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 4358 | "GETFASTTRANSITION", ft); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4359 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4360 | |
| 4361 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4362 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4363 | ret = -EFAULT; |
| 4364 | } |
| 4365 | |
| 4366 | return ret; |
| 4367 | } |
| 4368 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4369 | 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] | 4370 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4371 | uint8_t *command, |
| 4372 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4373 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4374 | { |
| 4375 | int ret = 0; |
| 4376 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4377 | 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] | 4378 | |
| 4379 | /* Move pointer to ahead of SETROAMSCANCHANNELMINTIME<delimiter> */ |
| 4380 | value = value + command_len + 1; |
| 4381 | |
| 4382 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4383 | ret = kstrtou8(value, 10, &min_time); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4384 | if (ret < 0) { |
| 4385 | /* |
| 4386 | * If the input value is greater than max value of datatype, |
| 4387 | * then also kstrtou8 fails |
| 4388 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4389 | hdd_err("kstrtou8 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4390 | cfg_min(CFG_LFR_NEIGHBOR_SCAN_MIN_CHAN_TIME), |
| 4391 | cfg_max(CFG_LFR_NEIGHBOR_SCAN_MIN_CHAN_TIME)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4392 | ret = -EINVAL; |
| 4393 | goto exit; |
| 4394 | } |
| 4395 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4396 | 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] | 4397 | 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] | 4398 | min_time, |
| 4399 | cfg_min(CFG_LFR_NEIGHBOR_SCAN_MIN_CHAN_TIME), |
| 4400 | cfg_max(CFG_LFR_NEIGHBOR_SCAN_MIN_CHAN_TIME)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4401 | ret = -EINVAL; |
| 4402 | goto exit; |
| 4403 | } |
| 4404 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 4405 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 4406 | TRACE_CODE_HDD_SETROAMSCANCHANNELMINTIME_IOCTL, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4407 | adapter->vdev_id, min_time); |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 4408 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4409 | hdd_debug("Received Command to change channel min time = %d", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4410 | min_time); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4411 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4412 | sme_set_neighbor_scan_min_chan_time(hdd_ctx->mac_handle, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4413 | min_time, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4414 | adapter->vdev_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4415 | |
| 4416 | exit: |
| 4417 | return ret; |
| 4418 | } |
| 4419 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4420 | static int drv_cmd_send_action_frame(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4421 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4422 | uint8_t *command, |
| 4423 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4424 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4425 | { |
Srinivas Girigowda | 1efc80e | 2016-08-26 18:53:47 -0700 | [diff] [blame] | 4426 | return hdd_parse_sendactionframe(adapter, command, |
| 4427 | priv_data->total_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4428 | } |
| 4429 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4430 | 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] | 4431 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4432 | uint8_t *command, |
| 4433 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4434 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4435 | { |
| 4436 | int ret = 0; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4437 | 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] | 4438 | adapter->vdev_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4439 | char extra[32]; |
| 4440 | uint8_t len = 0; |
| 4441 | |
| 4442 | /* value is interms of msec */ |
| 4443 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 4444 | "GETROAMSCANCHANNELMINTIME", val); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4445 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4446 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 4447 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 4448 | TRACE_CODE_HDD_GETROAMSCANCHANNELMINTIME_IOCTL, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4449 | adapter->vdev_id, val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4450 | |
| 4451 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4452 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4453 | ret = -EFAULT; |
| 4454 | } |
| 4455 | |
| 4456 | return ret; |
| 4457 | } |
| 4458 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4459 | static int drv_cmd_set_scan_channel_time(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4460 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4461 | uint8_t *command, |
| 4462 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4463 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4464 | { |
| 4465 | int ret = 0; |
| 4466 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4467 | 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] | 4468 | |
| 4469 | /* Move pointer to ahead of SETSCANCHANNELTIME<delimiter> */ |
| 4470 | value = value + command_len + 1; |
| 4471 | |
| 4472 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4473 | ret = kstrtou16(value, 10, &max_time); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4474 | if (ret < 0) { |
| 4475 | /* |
| 4476 | * If the input value is greater than max value of datatype, |
| 4477 | * then also kstrtou8 fails |
| 4478 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4479 | hdd_err("kstrtou16 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4480 | cfg_min(CFG_LFR_NEIGHBOR_SCAN_MAX_CHAN_TIME), |
| 4481 | cfg_max(CFG_LFR_NEIGHBOR_SCAN_MAX_CHAN_TIME)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4482 | ret = -EINVAL; |
| 4483 | goto exit; |
| 4484 | } |
| 4485 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4486 | 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] | 4487 | 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] | 4488 | max_time, |
| 4489 | cfg_min(CFG_LFR_NEIGHBOR_SCAN_MAX_CHAN_TIME), |
| 4490 | cfg_max(CFG_LFR_NEIGHBOR_SCAN_MAX_CHAN_TIME)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4491 | ret = -EINVAL; |
| 4492 | goto exit; |
| 4493 | } |
| 4494 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4495 | hdd_debug("Received Command to change channel max time = %d", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4496 | max_time); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4497 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4498 | sme_set_neighbor_scan_max_chan_time(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4499 | adapter->vdev_id, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4500 | max_time); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4501 | |
| 4502 | exit: |
| 4503 | return ret; |
| 4504 | } |
| 4505 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4506 | static int drv_cmd_get_scan_channel_time(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4507 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4508 | uint8_t *command, |
| 4509 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4510 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4511 | { |
| 4512 | int ret = 0; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4513 | 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] | 4514 | adapter->vdev_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4515 | char extra[32]; |
| 4516 | uint8_t len = 0; |
| 4517 | |
| 4518 | /* value is interms of msec */ |
| 4519 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 4520 | "GETSCANCHANNELTIME", val); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4521 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4522 | |
| 4523 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4524 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4525 | ret = -EFAULT; |
| 4526 | } |
| 4527 | |
| 4528 | return ret; |
| 4529 | } |
| 4530 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4531 | static int drv_cmd_set_scan_home_time(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4532 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4533 | uint8_t *command, |
| 4534 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4535 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4536 | { |
| 4537 | int ret = 0; |
| 4538 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4539 | uint16_t val = cfg_default(CFG_LFR_NEIGHBOR_SCAN_TIMER_PERIOD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4540 | |
| 4541 | /* Move pointer to ahead of SETSCANHOMETIME<delimiter> */ |
| 4542 | value = value + command_len + 1; |
| 4543 | |
| 4544 | /* Convert the value from ascii to integer */ |
| 4545 | ret = kstrtou16(value, 10, &val); |
| 4546 | if (ret < 0) { |
| 4547 | /* |
| 4548 | * If the input value is greater than max value of datatype, |
| 4549 | * then also kstrtou8 fails |
| 4550 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4551 | hdd_err("kstrtou16 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4552 | cfg_min(CFG_LFR_NEIGHBOR_SCAN_TIMER_PERIOD), |
| 4553 | cfg_max(CFG_LFR_NEIGHBOR_SCAN_TIMER_PERIOD)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4554 | ret = -EINVAL; |
| 4555 | goto exit; |
| 4556 | } |
| 4557 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4558 | if (!cfg_in_range(CFG_LFR_NEIGHBOR_SCAN_TIMER_PERIOD, val)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4559 | hdd_err("scan home time value %d is out of range (Min: %d Max: %d)", |
| 4560 | val, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4561 | cfg_min(CFG_LFR_NEIGHBOR_SCAN_TIMER_PERIOD), |
| 4562 | cfg_max(CFG_LFR_NEIGHBOR_SCAN_TIMER_PERIOD)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4563 | ret = -EINVAL; |
| 4564 | goto exit; |
| 4565 | } |
| 4566 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4567 | hdd_debug("Received Command to change scan home time = %d", |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4568 | val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4569 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4570 | sme_set_neighbor_scan_period(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4571 | adapter->vdev_id, val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4572 | |
| 4573 | exit: |
| 4574 | return ret; |
| 4575 | } |
| 4576 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4577 | static int drv_cmd_get_scan_home_time(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4578 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4579 | uint8_t *command, |
| 4580 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4581 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4582 | { |
| 4583 | int ret = 0; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4584 | uint16_t val = sme_get_neighbor_scan_period(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4585 | adapter->vdev_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4586 | char extra[32]; |
| 4587 | uint8_t len = 0; |
| 4588 | |
| 4589 | /* value is interms of msec */ |
| 4590 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 4591 | "GETSCANHOMETIME", val); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4592 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4593 | |
| 4594 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4595 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4596 | ret = -EFAULT; |
| 4597 | } |
| 4598 | |
| 4599 | return ret; |
| 4600 | } |
| 4601 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4602 | static int drv_cmd_set_roam_intra_band(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4603 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4604 | uint8_t *command, |
| 4605 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4606 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4607 | { |
| 4608 | int ret = 0; |
| 4609 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4610 | uint8_t val = cfg_default(CFG_LFR_ROAM_INTRA_BAND); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4611 | |
| 4612 | /* Move pointer to ahead of SETROAMINTRABAND<delimiter> */ |
| 4613 | value = value + command_len + 1; |
| 4614 | |
| 4615 | /* Convert the value from ascii to integer */ |
| 4616 | ret = kstrtou8(value, 10, &val); |
| 4617 | if (ret < 0) { |
| 4618 | /* |
| 4619 | * If the input value is greater than max value of datatype, |
| 4620 | * then also kstrtou8 fails |
| 4621 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4622 | hdd_err("kstrtou8 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4623 | cfg_min(CFG_LFR_ROAM_INTRA_BAND), |
| 4624 | cfg_max(CFG_LFR_ROAM_INTRA_BAND)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4625 | ret = -EINVAL; |
| 4626 | goto exit; |
| 4627 | } |
| 4628 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4629 | hdd_debug("Received Command to change intra band = %d", |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4630 | val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4631 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4632 | ucfg_mlme_set_roam_intra_band(hdd_ctx->psoc, (bool)val); |
Jianmin Zhu | 0b505a6 | 2019-04-30 16:22:49 +0800 | [diff] [blame] | 4633 | policy_mgr_set_pcl_for_existing_combo( |
| 4634 | hdd_ctx->psoc, |
| 4635 | PM_STA_MODE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4636 | |
| 4637 | exit: |
| 4638 | return ret; |
| 4639 | } |
| 4640 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4641 | static int drv_cmd_get_roam_intra_band(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4642 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4643 | uint8_t *command, |
| 4644 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4645 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4646 | { |
| 4647 | int ret = 0; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4648 | uint16_t val = sme_get_roam_intra_band(hdd_ctx->mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4649 | char extra[32]; |
| 4650 | uint8_t len = 0; |
| 4651 | |
| 4652 | /* value is interms of msec */ |
| 4653 | len = scnprintf(extra, sizeof(extra), "%s %d", |
| 4654 | "GETROAMINTRABAND", val); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4655 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4656 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4657 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4658 | ret = -EFAULT; |
| 4659 | } |
| 4660 | |
| 4661 | return ret; |
| 4662 | } |
| 4663 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4664 | static int drv_cmd_set_scan_n_probes(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4665 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4666 | uint8_t *command, |
| 4667 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4668 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4669 | { |
| 4670 | int ret = 0; |
| 4671 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4672 | uint8_t nprobes = cfg_default(CFG_LFR_ROAM_SCAN_N_PROBES); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4673 | |
| 4674 | /* Move pointer to ahead of SETSCANNPROBES<delimiter> */ |
| 4675 | value = value + command_len + 1; |
| 4676 | |
| 4677 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4678 | ret = kstrtou8(value, 10, &nprobes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4679 | if (ret < 0) { |
| 4680 | /* |
| 4681 | * If the input value is greater than max value of datatype, |
| 4682 | * then also kstrtou8 fails |
| 4683 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4684 | hdd_err("kstrtou8 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4685 | cfg_min(CFG_LFR_ROAM_SCAN_N_PROBES), |
| 4686 | cfg_max(CFG_LFR_ROAM_SCAN_N_PROBES)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4687 | ret = -EINVAL; |
| 4688 | goto exit; |
| 4689 | } |
| 4690 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4691 | if (!cfg_in_range(CFG_LFR_ROAM_SCAN_N_PROBES, nprobes)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4692 | 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] | 4693 | nprobes, |
| 4694 | cfg_min(CFG_LFR_ROAM_SCAN_N_PROBES), |
| 4695 | cfg_max(CFG_LFR_ROAM_SCAN_N_PROBES)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4696 | ret = -EINVAL; |
| 4697 | goto exit; |
| 4698 | } |
| 4699 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4700 | hdd_debug("Received Command to Set nProbes = %d", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4701 | nprobes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4702 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4703 | sme_update_roam_scan_n_probes(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4704 | adapter->vdev_id, nprobes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4705 | |
| 4706 | exit: |
| 4707 | return ret; |
| 4708 | } |
| 4709 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4710 | static int drv_cmd_get_scan_n_probes(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4711 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4712 | uint8_t *command, |
| 4713 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4714 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4715 | { |
| 4716 | int ret = 0; |
Srinivas Dasari | a5a42fa | 2019-09-20 12:47:15 +0530 | [diff] [blame] | 4717 | uint8_t val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4718 | char extra[32]; |
| 4719 | uint8_t len = 0; |
Srinivas Dasari | a5a42fa | 2019-09-20 12:47:15 +0530 | [diff] [blame] | 4720 | QDF_STATUS status; |
| 4721 | |
| 4722 | status = sme_get_roam_scan_n_probes(hdd_ctx->mac_handle, |
| 4723 | adapter->vdev_id, |
| 4724 | &val); |
| 4725 | if (QDF_IS_STATUS_ERROR(status)) |
| 4726 | return qdf_status_to_os_return(status); |
| 4727 | |
| 4728 | hdd_debug("vdev_id: %u, scan_n_probes: %u", |
| 4729 | adapter->vdev_id, val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4730 | |
| 4731 | len = scnprintf(extra, sizeof(extra), "%s %d", command, val); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4732 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4733 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4734 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4735 | ret = -EFAULT; |
| 4736 | } |
| 4737 | |
| 4738 | return ret; |
| 4739 | } |
| 4740 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4741 | 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] | 4742 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4743 | uint8_t *command, |
| 4744 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4745 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4746 | { |
| 4747 | int ret = 0; |
| 4748 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4749 | 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] | 4750 | |
| 4751 | /* input value is in units of msec */ |
| 4752 | |
| 4753 | /* Move pointer to ahead of SETSCANHOMEAWAYTIME<delimiter> */ |
| 4754 | value = value + command_len + 1; |
| 4755 | |
| 4756 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4757 | ret = kstrtou16(value, 10, &home_away_time); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4758 | if (ret < 0) { |
| 4759 | /* |
| 4760 | * If the input value is greater than max value of datatype, |
| 4761 | * then also kstrtou8 fails |
| 4762 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4763 | hdd_err("kstrtou8 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4764 | cfg_min(CFG_LFR_ROAM_SCAN_HOME_AWAY_TIME), |
| 4765 | cfg_max(CFG_LFR_ROAM_SCAN_HOME_AWAY_TIME)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4766 | ret = -EINVAL; |
| 4767 | goto exit; |
| 4768 | } |
| 4769 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4770 | if (!cfg_in_range(CFG_LFR_ROAM_SCAN_HOME_AWAY_TIME, home_away_time)) { |
| 4771 | hdd_err("home_away_time value %d is out of range (min: %d max: %d)", |
| 4772 | home_away_time, |
| 4773 | cfg_min(CFG_LFR_ROAM_SCAN_HOME_AWAY_TIME), |
| 4774 | cfg_max(CFG_LFR_ROAM_SCAN_HOME_AWAY_TIME)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4775 | ret = -EINVAL; |
| 4776 | goto exit; |
| 4777 | } |
| 4778 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4779 | hdd_debug("Received Command to Set scan away time = %d", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4780 | home_away_time); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4781 | |
Srinivas Dasari | 7bedcd1 | 2019-09-20 12:43:11 +0530 | [diff] [blame] | 4782 | sme_update_roam_scan_home_away_time(hdd_ctx->mac_handle, |
| 4783 | adapter->vdev_id, |
| 4784 | home_away_time, |
| 4785 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4786 | |
| 4787 | exit: |
| 4788 | return ret; |
| 4789 | } |
| 4790 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4791 | 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] | 4792 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4793 | uint8_t *command, |
| 4794 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4795 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4796 | { |
| 4797 | int ret = 0; |
Srinivas Dasari | 7bedcd1 | 2019-09-20 12:43:11 +0530 | [diff] [blame] | 4798 | uint16_t val; |
Abhishek Ambure | 7b4b2ff | 2020-01-29 17:47:05 +0530 | [diff] [blame] | 4799 | char extra[32] = {0}; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4800 | uint8_t len = 0; |
Srinivas Dasari | 7bedcd1 | 2019-09-20 12:43:11 +0530 | [diff] [blame] | 4801 | QDF_STATUS status; |
| 4802 | |
| 4803 | status = sme_get_roam_scan_home_away_time(hdd_ctx->mac_handle, |
| 4804 | adapter->vdev_id, |
| 4805 | &val); |
| 4806 | if (QDF_IS_STATUS_ERROR(status)) |
| 4807 | return qdf_status_to_os_return(status); |
| 4808 | |
| 4809 | hdd_debug("vdev_id: %u, scan home away time: %u", |
| 4810 | adapter->vdev_id, val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4811 | |
| 4812 | len = scnprintf(extra, sizeof(extra), "%s %d", command, val); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4813 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4814 | |
| 4815 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4816 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4817 | ret = -EFAULT; |
| 4818 | } |
| 4819 | |
| 4820 | return ret; |
| 4821 | } |
| 4822 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4823 | static int drv_cmd_reassoc(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 | { |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 4829 | return hdd_parse_reassoc(adapter, command, priv_data->total_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4830 | } |
| 4831 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4832 | static int drv_cmd_set_wes_mode(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4833 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4834 | uint8_t *command, |
| 4835 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4836 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4837 | { |
| 4838 | int ret = 0; |
| 4839 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4840 | uint8_t wes_mode = cfg_default(CFG_LFR_ENABLE_WES_MODE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4841 | |
| 4842 | /* Move pointer to ahead of SETWESMODE<delimiter> */ |
| 4843 | value = value + command_len + 1; |
| 4844 | |
| 4845 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4846 | ret = kstrtou8(value, 10, &wes_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4847 | if (ret < 0) { |
| 4848 | /* |
| 4849 | * If the input value is greater than max value of datatype, |
| 4850 | * then also kstrtou8 fails |
| 4851 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4852 | hdd_err("kstrtou8 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4853 | cfg_min(CFG_LFR_ENABLE_WES_MODE), |
| 4854 | cfg_max(CFG_LFR_ENABLE_WES_MODE)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4855 | ret = -EINVAL; |
| 4856 | goto exit; |
| 4857 | } |
| 4858 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4859 | 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] | 4860 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4861 | 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] | 4862 | |
| 4863 | exit: |
| 4864 | return ret; |
| 4865 | } |
| 4866 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4867 | static int drv_cmd_get_wes_mode(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4868 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4869 | uint8_t *command, |
| 4870 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4871 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4872 | { |
| 4873 | int ret = 0; |
Jeff Johnson | 22345e1 | 2019-02-26 21:33:02 -0800 | [diff] [blame] | 4874 | bool wes_mode = sme_get_wes_mode(hdd_ctx->mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4875 | char extra[32]; |
| 4876 | uint8_t len = 0; |
| 4877 | |
Jeff Johnson | 22345e1 | 2019-02-26 21:33:02 -0800 | [diff] [blame] | 4878 | len = scnprintf(extra, sizeof(extra), "%s %d", command, wes_mode); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4879 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4880 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4881 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4882 | ret = -EFAULT; |
| 4883 | } |
| 4884 | |
| 4885 | return ret; |
| 4886 | } |
| 4887 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4888 | static int drv_cmd_set_opportunistic_rssi_diff(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4889 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4890 | uint8_t *command, |
| 4891 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4892 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4893 | { |
| 4894 | int ret = 0; |
| 4895 | uint8_t *value = command; |
Jeff Johnson | 8e3ca4c | 2019-02-26 20:42:24 -0800 | [diff] [blame] | 4896 | uint8_t diff = |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4897 | cfg_default(CFG_LFR_OPPORTUNISTIC_SCAN_THRESHOLD_DIFF); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4898 | |
| 4899 | /* Move pointer to ahead of SETOPPORTUNISTICRSSIDIFF<delimiter> */ |
| 4900 | value = value + command_len + 1; |
| 4901 | |
| 4902 | /* Convert the value from ascii to integer */ |
Jeff Johnson | 8e3ca4c | 2019-02-26 20:42:24 -0800 | [diff] [blame] | 4903 | ret = kstrtou8(value, 10, &diff); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4904 | if (ret < 0) { |
| 4905 | /* |
| 4906 | * If the input value is greater than max value of datatype, |
| 4907 | * then also kstrtou8 fails |
| 4908 | */ |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4909 | hdd_err("kstrtou8 failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4910 | ret = -EINVAL; |
| 4911 | goto exit; |
| 4912 | } |
| 4913 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4914 | hdd_debug("Received Command to Set Opportunistic Threshold diff = %d", |
Jeff Johnson | 8e3ca4c | 2019-02-26 20:42:24 -0800 | [diff] [blame] | 4915 | diff); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4916 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4917 | sme_set_roam_opportunistic_scan_threshold_diff(hdd_ctx->mac_handle, |
Jeff Johnson | 8e3ca4c | 2019-02-26 20:42:24 -0800 | [diff] [blame] | 4918 | adapter->vdev_id, |
| 4919 | diff); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4920 | |
| 4921 | exit: |
| 4922 | return ret; |
| 4923 | } |
| 4924 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4925 | static int drv_cmd_get_opportunistic_rssi_diff(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 4926 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4927 | uint8_t *command, |
| 4928 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4929 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4930 | { |
| 4931 | int ret = 0; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4932 | mac_handle_t mac_handle = hdd_ctx->mac_handle; |
| 4933 | int8_t val = sme_get_roam_opportunistic_scan_threshold_diff(mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4934 | char extra[32]; |
| 4935 | uint8_t len = 0; |
| 4936 | |
| 4937 | len = scnprintf(extra, sizeof(extra), "%s %d", command, val); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4938 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4939 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4940 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4941 | ret = -EFAULT; |
| 4942 | } |
| 4943 | |
| 4944 | return ret; |
| 4945 | } |
| 4946 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4947 | 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] | 4948 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4949 | uint8_t *command, |
| 4950 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4951 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4952 | { |
| 4953 | int ret = 0; |
| 4954 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4955 | 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] | 4956 | |
| 4957 | /* Move pointer to ahead of SETROAMRESCANRSSIDIFF<delimiter> */ |
| 4958 | value = value + command_len + 1; |
| 4959 | |
| 4960 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4961 | ret = kstrtou8(value, 10, &rescan_rssi_diff); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4962 | if (ret < 0) { |
| 4963 | /* |
| 4964 | * If the input value is greater than max value of datatype, |
| 4965 | * then also kstrtou8 fails |
| 4966 | */ |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4967 | hdd_err("kstrtou8 failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4968 | ret = -EINVAL; |
| 4969 | goto exit; |
| 4970 | } |
| 4971 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 4972 | hdd_debug("Received Command to Set Roam Rescan RSSI Diff = %d", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4973 | rescan_rssi_diff); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4974 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4975 | sme_set_roam_rescan_rssi_diff(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4976 | adapter->vdev_id, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 4977 | rescan_rssi_diff); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4978 | |
| 4979 | exit: |
| 4980 | return ret; |
| 4981 | } |
| 4982 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 4983 | 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] | 4984 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4985 | uint8_t *command, |
| 4986 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 4987 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4988 | { |
| 4989 | int ret = 0; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 4990 | 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] | 4991 | char extra[32]; |
| 4992 | uint8_t len = 0; |
| 4993 | |
| 4994 | len = scnprintf(extra, sizeof(extra), "%s %d", command, val); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4995 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4996 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 4997 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4998 | ret = -EFAULT; |
| 4999 | } |
| 5000 | |
| 5001 | return ret; |
| 5002 | } |
| 5003 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5004 | static int drv_cmd_set_fast_roam(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5005 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5006 | uint8_t *command, |
| 5007 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5008 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5009 | { |
| 5010 | int ret = 0; |
| 5011 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5012 | uint8_t lfr_mode = cfg_default(CFG_LFR_FEATURE_ENABLED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5013 | |
| 5014 | /* Move pointer to ahead of SETFASTROAM<delimiter> */ |
| 5015 | value = value + command_len + 1; |
| 5016 | |
| 5017 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5018 | ret = kstrtou8(value, 10, &lfr_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5019 | if (ret < 0) { |
| 5020 | /* |
| 5021 | * If the input value is greater than max value of datatype, |
| 5022 | * then also kstrtou8 fails |
| 5023 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5024 | hdd_err("kstrtou8 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5025 | cfg_min(CFG_LFR_FEATURE_ENABLED), |
| 5026 | cfg_max(CFG_LFR_FEATURE_ENABLED)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5027 | ret = -EINVAL; |
| 5028 | goto exit; |
| 5029 | } |
| 5030 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5031 | hdd_debug("Received Command to change lfr mode = %d", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5032 | lfr_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5033 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5034 | ucfg_mlme_set_lfr_enabled(hdd_ctx->psoc, (bool)lfr_mode); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5035 | sme_update_is_fast_roam_ini_feature_enabled(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5036 | adapter->vdev_id, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5037 | lfr_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5038 | |
| 5039 | exit: |
| 5040 | return ret; |
| 5041 | } |
| 5042 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5043 | static int drv_cmd_set_fast_transition(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5044 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5045 | uint8_t *command, |
| 5046 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5047 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5048 | { |
| 5049 | int ret = 0; |
| 5050 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5051 | uint8_t ft = cfg_default(CFG_LFR_FAST_TRANSITION_ENABLED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5052 | |
| 5053 | /* Move pointer to ahead of SETFASTROAM<delimiter> */ |
| 5054 | value = value + command_len + 1; |
| 5055 | |
| 5056 | /* Convert the value from ascii to integer */ |
| 5057 | ret = kstrtou8(value, 10, &ft); |
| 5058 | if (ret < 0) { |
| 5059 | /* |
| 5060 | * If the input value is greater than max value of datatype, |
| 5061 | * then also kstrtou8 fails |
| 5062 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5063 | hdd_err("kstrtou8 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5064 | cfg_min(CFG_LFR_FAST_TRANSITION_ENABLED), |
| 5065 | cfg_max(CFG_LFR_FAST_TRANSITION_ENABLED)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5066 | ret = -EINVAL; |
| 5067 | goto exit; |
| 5068 | } |
| 5069 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5070 | hdd_debug("Received Command to change ft mode = %d", ft); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5071 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5072 | ucfg_mlme_set_fast_transition_enabled(hdd_ctx->psoc, (bool)ft); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5073 | |
| 5074 | exit: |
| 5075 | return ret; |
| 5076 | } |
| 5077 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5078 | static int drv_cmd_fast_reassoc(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5079 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5080 | uint8_t *command, |
| 5081 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5082 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5083 | { |
| 5084 | int ret = 0; |
| 5085 | uint8_t *value = command; |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 5086 | qdf_freq_t freq = 0; |
Jeff Johnson | 8ff3ffe | 2019-02-26 13:21:07 -0800 | [diff] [blame] | 5087 | tSirMacAddr bssid; |
Jeff Johnson | 29c7867 | 2019-02-26 21:05:53 -0800 | [diff] [blame] | 5088 | uint32_t roam_id = INVALID_ROAM_ID; |
Jeff Johnson | 9ff1695 | 2019-02-26 20:58:44 -0800 | [diff] [blame] | 5089 | tCsrRoamModifyProfileFields mod_fields; |
Jeff Johnson | dcaa8fc | 2019-02-26 21:26:31 -0800 | [diff] [blame] | 5090 | tCsrHandoffRequest req; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5091 | struct hdd_station_ctx *sta_ctx; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5092 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5093 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 5094 | if (QDF_STA_MODE != adapter->device_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5095 | hdd_warn("Unsupported in mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 5096 | qdf_opmode_str(adapter->device_mode), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5097 | adapter->device_mode); |
| 5098 | return -EINVAL; |
| 5099 | } |
| 5100 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5101 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jingxiang Ge | ce7c547 | 2019-07-23 16:19:23 +0800 | [diff] [blame] | 5102 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5103 | |
| 5104 | /* if not associated, no need to proceed with reassoc */ |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 5105 | if (eConnectionState_Associated != sta_ctx->conn_info.conn_state) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5106 | hdd_warn("Not associated!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5107 | ret = -EINVAL; |
| 5108 | goto exit; |
| 5109 | } |
| 5110 | |
Jeff Johnson | 8ff3ffe | 2019-02-26 13:21:07 -0800 | [diff] [blame] | 5111 | ret = hdd_parse_reassoc_command_v1_data(value, bssid, |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 5112 | &freq); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5113 | if (ret) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5114 | hdd_err("Failed to parse reassoc command data"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5115 | goto exit; |
| 5116 | } |
| 5117 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5118 | mac_handle = hdd_ctx->mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5119 | /* |
| 5120 | * if the target bssid is same as currently associated AP, |
| 5121 | * issue reassoc to same AP |
| 5122 | */ |
Jeff Johnson | e04b699 | 2019-02-27 14:06:55 -0800 | [diff] [blame] | 5123 | if (!qdf_mem_cmp(bssid, sta_ctx->conn_info.bssid.bytes, |
Jeff Johnson | 8ff3ffe | 2019-02-26 13:21:07 -0800 | [diff] [blame] | 5124 | QDF_MAC_ADDR_SIZE)) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5125 | hdd_warn("Reassoc BSSID is same as currently associated AP bssid"); |
Deepak Dhamdhere | 5fda0e4 | 2016-06-24 18:30:02 +0530 | [diff] [blame] | 5126 | if (roaming_offload_enabled(hdd_ctx)) { |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 5127 | hdd_wma_send_fastreassoc_cmd( |
| 5128 | adapter, bssid, sta_ctx->conn_info.chan_freq); |
Deepak Dhamdhere | 5fda0e4 | 2016-06-24 18:30:02 +0530 | [diff] [blame] | 5129 | } else { |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5130 | sme_get_modify_profile_fields(mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5131 | adapter->vdev_id, |
Jeff Johnson | 9ff1695 | 2019-02-26 20:58:44 -0800 | [diff] [blame] | 5132 | &mod_fields); |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5133 | sme_roam_reassoc(mac_handle, adapter->vdev_id, |
Jeff Johnson | 29c7867 | 2019-02-26 21:05:53 -0800 | [diff] [blame] | 5134 | NULL, mod_fields, &roam_id, 1); |
Deepak Dhamdhere | 5fda0e4 | 2016-06-24 18:30:02 +0530 | [diff] [blame] | 5135 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5136 | return 0; |
| 5137 | } |
| 5138 | |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 5139 | /* Check freq number is a valid freq number */ |
| 5140 | if (freq && QDF_STATUS_SUCCESS != |
| 5141 | wlan_hdd_validate_operation_channel(adapter, freq)) { |
| 5142 | hdd_err("Invalid freq [%d]", freq); |
Padma, Santhosh Kumar | af9f08c | 2016-10-21 21:26:29 +0530 | [diff] [blame] | 5143 | return -EINVAL; |
| 5144 | } |
| 5145 | |
Varun Reddy Yeturu | d351a6c | 2016-03-16 14:01:00 -0700 | [diff] [blame] | 5146 | if (roaming_offload_enabled(hdd_ctx)) { |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 5147 | hdd_wma_send_fastreassoc_cmd(adapter, bssid, freq); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5148 | goto exit; |
| 5149 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5150 | /* Proceed with reassoc */ |
Abhishek Ambure | d742944 | 2020-08-25 01:03:57 +0530 | [diff] [blame] | 5151 | req.ch_freq = freq; |
Jeff Johnson | dcaa8fc | 2019-02-26 21:26:31 -0800 | [diff] [blame] | 5152 | req.src = FASTREASSOC; |
| 5153 | qdf_mem_copy(req.bssid.bytes, bssid, sizeof(tSirMacAddr)); |
| 5154 | sme_handoff_request(mac_handle, adapter->vdev_id, &req); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5155 | exit: |
| 5156 | return ret; |
| 5157 | } |
| 5158 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5159 | static int drv_cmd_set_roam_scan_control(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5160 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5161 | uint8_t *command, |
| 5162 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5163 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5164 | { |
| 5165 | int ret = 0; |
| 5166 | uint8_t *value = command; |
Jeff Johnson | d7ee476 | 2019-02-26 21:01:00 -0800 | [diff] [blame] | 5167 | uint8_t roam_scan_control = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5168 | |
| 5169 | /* Move pointer to ahead of SETROAMSCANCONTROL<delimiter> */ |
| 5170 | value = value + command_len + 1; |
| 5171 | |
| 5172 | /* Convert the value from ascii to integer */ |
Jeff Johnson | d7ee476 | 2019-02-26 21:01:00 -0800 | [diff] [blame] | 5173 | ret = kstrtou8(value, 10, &roam_scan_control); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5174 | if (ret < 0) { |
| 5175 | /* |
| 5176 | * If the input value is greater than max value of datatype, |
| 5177 | * then also kstrtou8 fails |
| 5178 | */ |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5179 | hdd_err("kstrtou8 failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5180 | ret = -EINVAL; |
| 5181 | goto exit; |
| 5182 | } |
| 5183 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5184 | hdd_debug("Received Command to Set roam scan control = %d", |
Jeff Johnson | d7ee476 | 2019-02-26 21:01:00 -0800 | [diff] [blame] | 5185 | roam_scan_control); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5186 | |
Jeff Johnson | d7ee476 | 2019-02-26 21:01:00 -0800 | [diff] [blame] | 5187 | if (0 != roam_scan_control) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5188 | ret = 0; /* return success but ignore param value "true" */ |
| 5189 | goto exit; |
| 5190 | } |
| 5191 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5192 | sme_set_roam_scan_control(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5193 | adapter->vdev_id, |
Jeff Johnson | d7ee476 | 2019-02-26 21:01:00 -0800 | [diff] [blame] | 5194 | roam_scan_control); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5195 | |
| 5196 | exit: |
| 5197 | return ret; |
| 5198 | } |
| 5199 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5200 | static int drv_cmd_set_okc_mode(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5201 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5202 | uint8_t *command, |
| 5203 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5204 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5205 | { |
| 5206 | int ret = 0; |
| 5207 | uint8_t *value = command; |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 5208 | uint32_t okc_mode; |
| 5209 | struct pmkid_mode_bits pmkid_modes; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5210 | mac_handle_t mac_handle; |
Wu Gao | 9381621 | 2018-08-31 16:49:54 +0800 | [diff] [blame] | 5211 | uint32_t cur_pmkid_modes; |
| 5212 | QDF_STATUS status; |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 5213 | |
| 5214 | hdd_get_pmkid_modes(hdd_ctx, &pmkid_modes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5215 | |
| 5216 | /* |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 5217 | * Check if the features PMKID/ESE/11R are supported simultaneously, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5218 | * then this operation is not permitted (return FAILURE) |
| 5219 | */ |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5220 | mac_handle = hdd_ctx->mac_handle; |
| 5221 | if (sme_get_is_ese_feature_enabled(mac_handle) && |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 5222 | pmkid_modes.fw_okc && |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5223 | sme_get_is_ft_feature_enabled(mac_handle)) { |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 5224 | 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] | 5225 | ret = -EPERM; |
| 5226 | goto exit; |
| 5227 | } |
| 5228 | |
| 5229 | /* Move pointer to ahead of SETOKCMODE<delimiter> */ |
| 5230 | value = value + command_len + 1; |
| 5231 | |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 5232 | /* get the current configured value */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 5233 | status = ucfg_mlme_get_pmkid_modes(hdd_ctx->psoc, |
Wu Gao | 9381621 | 2018-08-31 16:49:54 +0800 | [diff] [blame] | 5234 | &cur_pmkid_modes); |
| 5235 | if (status != QDF_STATUS_SUCCESS) |
| 5236 | hdd_err("get pmkid modes failed"); |
| 5237 | |
| 5238 | okc_mode = cur_pmkid_modes & CFG_PMKID_MODES_OKC; |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 5239 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5240 | /* Convert the value from ascii to integer */ |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 5241 | ret = kstrtou32(value, 10, &okc_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5242 | if (ret < 0) { |
| 5243 | /* |
| 5244 | * If the input value is greater than max value of datatype, |
| 5245 | * then also kstrtou8 fails |
| 5246 | */ |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 5247 | hdd_err("value out of range [0 - 1]"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5248 | ret = -EINVAL; |
| 5249 | goto exit; |
| 5250 | } |
| 5251 | |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 5252 | if ((okc_mode < 0) || |
| 5253 | (okc_mode > 1)) { |
| 5254 | hdd_err("Okc mode value %d is out of range (Min: 0 Max: 1)", |
| 5255 | okc_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5256 | ret = -EINVAL; |
| 5257 | goto exit; |
| 5258 | } |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5259 | hdd_debug("Received Command to change okc mode = %d", |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 5260 | okc_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5261 | |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 5262 | if (okc_mode) |
Wu Gao | 9381621 | 2018-08-31 16:49:54 +0800 | [diff] [blame] | 5263 | cur_pmkid_modes |= CFG_PMKID_MODES_OKC; |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 5264 | else |
Wu Gao | 9381621 | 2018-08-31 16:49:54 +0800 | [diff] [blame] | 5265 | cur_pmkid_modes &= ~CFG_PMKID_MODES_OKC; |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 5266 | status = ucfg_mlme_set_pmkid_modes(hdd_ctx->psoc, |
Wu Gao | 9381621 | 2018-08-31 16:49:54 +0800 | [diff] [blame] | 5267 | cur_pmkid_modes); |
| 5268 | if (status != QDF_STATUS_SUCCESS) { |
| 5269 | ret = -EPERM; |
| 5270 | hdd_err("set pmkid modes failed"); |
| 5271 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5272 | exit: |
| 5273 | return ret; |
| 5274 | } |
| 5275 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5276 | static int drv_cmd_get_roam_scan_control(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5277 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5278 | uint8_t *command, |
| 5279 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5280 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5281 | { |
| 5282 | int ret = 0; |
Jeff Johnson | d7ee476 | 2019-02-26 21:01:00 -0800 | [diff] [blame] | 5283 | 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] | 5284 | char extra[32]; |
| 5285 | uint8_t len = 0; |
| 5286 | |
| 5287 | len = scnprintf(extra, sizeof(extra), "%s %d", |
Jeff Johnson | d7ee476 | 2019-02-26 21:01:00 -0800 | [diff] [blame] | 5288 | command, roam_scan_control); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5289 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5290 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5291 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5292 | ret = -EFAULT; |
| 5293 | } |
| 5294 | |
| 5295 | return ret; |
| 5296 | } |
| 5297 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5298 | static int drv_cmd_bt_coex_mode(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5299 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5300 | uint8_t *command, |
| 5301 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5302 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5303 | { |
| 5304 | int ret = 0; |
Jeff Johnson | 3019241 | 2019-02-26 20:32:52 -0800 | [diff] [blame] | 5305 | char *coex_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5306 | |
Jeff Johnson | 3019241 | 2019-02-26 20:32:52 -0800 | [diff] [blame] | 5307 | coex_mode = command + 11; |
| 5308 | if ('1' == *coex_mode) { |
| 5309 | hdd_debug("BTCOEXMODE %d", *coex_mode); |
Jeff Johnson | 59b1931 | 2017-11-02 21:14:33 -0700 | [diff] [blame] | 5310 | hdd_ctx->bt_coex_mode_set = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5311 | ret = wlan_hdd_scan_abort(adapter); |
| 5312 | if (ret < 0) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5313 | hdd_err("Failed to abort existing scan status: %d", |
| 5314 | ret); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5315 | } |
Jeff Johnson | 3019241 | 2019-02-26 20:32:52 -0800 | [diff] [blame] | 5316 | } else if ('2' == *coex_mode) { |
| 5317 | hdd_debug("BTCOEXMODE %d", *coex_mode); |
Jeff Johnson | 59b1931 | 2017-11-02 21:14:33 -0700 | [diff] [blame] | 5318 | hdd_ctx->bt_coex_mode_set = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5319 | } |
| 5320 | |
| 5321 | return ret; |
| 5322 | } |
| 5323 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5324 | static int drv_cmd_scan_active(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5325 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5326 | uint8_t *command, |
| 5327 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5328 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5329 | { |
| 5330 | hdd_ctx->ioctl_scan_mode = eSIR_ACTIVE_SCAN; |
| 5331 | return 0; |
| 5332 | } |
| 5333 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5334 | static int drv_cmd_scan_passive(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5335 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5336 | uint8_t *command, |
| 5337 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5338 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5339 | { |
| 5340 | hdd_ctx->ioctl_scan_mode = eSIR_PASSIVE_SCAN; |
| 5341 | return 0; |
| 5342 | } |
| 5343 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5344 | static int drv_cmd_get_dwell_time(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5345 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5346 | uint8_t *command, |
| 5347 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5348 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5349 | { |
| 5350 | int ret = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5351 | char extra[32]; |
| 5352 | uint8_t len = 0; |
| 5353 | |
| 5354 | memset(extra, 0, sizeof(extra)); |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 5355 | ret = hdd_get_dwell_time(hdd_ctx->psoc, command, extra, |
| 5356 | sizeof(extra), &len); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5357 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5358 | if (ret != 0 || copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5359 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5360 | ret = -EFAULT; |
| 5361 | goto exit; |
| 5362 | } |
| 5363 | ret = len; |
| 5364 | exit: |
| 5365 | return ret; |
| 5366 | } |
| 5367 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5368 | static int drv_cmd_set_dwell_time(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5369 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5370 | uint8_t *command, |
| 5371 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5372 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5373 | { |
Abhishek Singh | 8ebda9db | 2018-12-18 15:15:01 +0530 | [diff] [blame] | 5374 | return hdd_set_dwell_time(hdd_ctx->psoc, command); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5375 | } |
| 5376 | |
Ashish Kumar Dhanotiya | 652c233 | 2018-12-11 17:33:17 +0530 | [diff] [blame] | 5377 | static int drv_cmd_conc_set_dwell_time(struct hdd_adapter *adapter, |
| 5378 | struct hdd_context *hdd_ctx, |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 5379 | u8 *command, |
| 5380 | u8 command_len, |
Ashish Kumar Dhanotiya | 652c233 | 2018-12-11 17:33:17 +0530 | [diff] [blame] | 5381 | struct hdd_priv_data *priv_data) |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 5382 | { |
Ashish Kumar Dhanotiya | 652c233 | 2018-12-11 17:33:17 +0530 | [diff] [blame] | 5383 | return hdd_conc_set_dwell_time(adapter, command); |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 5384 | } |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 5385 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5386 | static int drv_cmd_miracast(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5387 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5388 | uint8_t *command, |
| 5389 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5390 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5391 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5392 | QDF_STATUS ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5393 | int ret = 0; |
Jeff Johnson | 3dd8a54 | 2019-02-26 21:38:14 -0800 | [diff] [blame] | 5394 | uint8_t filter_type = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5395 | uint8_t *value; |
| 5396 | |
Jeff Johnson | 6da2db1 | 2017-09-03 09:18:52 -0700 | [diff] [blame] | 5397 | if (wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5398 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5399 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5400 | value = command + 9; |
| 5401 | |
| 5402 | /* Convert the value from ascii to integer */ |
Jeff Johnson | 3dd8a54 | 2019-02-26 21:38:14 -0800 | [diff] [blame] | 5403 | ret = kstrtou8(value, 10, &filter_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5404 | if (ret < 0) { |
| 5405 | /* |
| 5406 | * If the input value is greater than max value of datatype, |
| 5407 | * then also kstrtou8 fails |
| 5408 | */ |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5409 | hdd_err("kstrtou8 failed range"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5410 | ret = -EINVAL; |
| 5411 | goto exit; |
| 5412 | } |
Jeff Johnson | 3dd8a54 | 2019-02-26 21:38:14 -0800 | [diff] [blame] | 5413 | if ((filter_type < WLAN_HDD_DRIVER_MIRACAST_CFG_MIN_VAL) || |
| 5414 | (filter_type > WLAN_HDD_DRIVER_MIRACAST_CFG_MAX_VAL)) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5415 | 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] | 5416 | ret = -EINVAL; |
| 5417 | goto exit; |
| 5418 | } |
| 5419 | /* Filtertype value should be either 0-Disabled, 1-Source, 2-sink */ |
Jeff Johnson | 3dd8a54 | 2019-02-26 21:38:14 -0800 | [diff] [blame] | 5420 | hdd_ctx->miracast_value = filter_type; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5421 | |
Jeff Johnson | 3dd8a54 | 2019-02-26 21:38:14 -0800 | [diff] [blame] | 5422 | ret_status = sme_set_miracast(hdd_ctx->mac_handle, filter_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5423 | if (QDF_STATUS_SUCCESS != ret_status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5424 | hdd_err("Failed to set miracast"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5425 | return -EBUSY; |
| 5426 | } |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 5427 | ret_status = ucfg_scan_set_miracast(hdd_ctx->psoc, |
Jeff Johnson | 3dd8a54 | 2019-02-26 21:38:14 -0800 | [diff] [blame] | 5428 | filter_type ? true : false); |
Abhishek Singh | c87bb04 | 2018-01-30 17:10:42 +0530 | [diff] [blame] | 5429 | if (QDF_IS_STATUS_ERROR(ret_status)) { |
| 5430 | hdd_err("Failed to set miracastn scan"); |
| 5431 | return -EBUSY; |
| 5432 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5433 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 5434 | if (policy_mgr_is_mcc_in_24G(hdd_ctx->psoc)) |
Jeff Johnson | 3dd8a54 | 2019-02-26 21:38:14 -0800 | [diff] [blame] | 5435 | return wlan_hdd_set_mas(adapter, filter_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5436 | |
| 5437 | exit: |
| 5438 | return ret; |
| 5439 | } |
| 5440 | |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5441 | #ifdef FEATURE_WLAN_RMC |
| 5442 | /* Function header is left blank intentionally */ |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 5443 | static int hdd_parse_setrmcenable_command(uint8_t *command, |
Jeff Johnson | 259f3e9 | 2019-02-26 13:36:01 -0800 | [diff] [blame] | 5444 | uint8_t *rmc_enable) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5445 | { |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 5446 | uint8_t *in_ptr = command; |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 5447 | int temp_int; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5448 | int v = 0; |
| 5449 | char buf[32]; |
Jeff Johnson | 259f3e9 | 2019-02-26 13:36:01 -0800 | [diff] [blame] | 5450 | *rmc_enable = 0; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5451 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 5452 | in_ptr = strnchr(command, strlen(command), SPACE_ASCII_VALUE); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5453 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 5454 | if (!in_ptr) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5455 | return 0; |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 5456 | else if (SPACE_ASCII_VALUE != *in_ptr) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5457 | return 0; |
| 5458 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 5459 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 5460 | in_ptr++; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5461 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 5462 | if ('\0' == *in_ptr) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5463 | return 0; |
| 5464 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 5465 | v = sscanf(in_ptr, "%31s ", buf); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5466 | if (1 != v) |
| 5467 | return -EINVAL; |
| 5468 | |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 5469 | v = kstrtos32(buf, 10, &temp_int); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5470 | if (v < 0) |
| 5471 | return -EINVAL; |
| 5472 | |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 5473 | *rmc_enable = temp_int; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5474 | |
Jeff Johnson | f8a0b8f | 2019-02-26 19:26:31 -0800 | [diff] [blame] | 5475 | hdd_debug("rmc_enable: %d", *rmc_enable); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5476 | |
| 5477 | return 0; |
| 5478 | } |
| 5479 | |
| 5480 | /* Function header is left blank intentionally */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5481 | static int hdd_parse_setrmcactionperiod_command(uint8_t *pvalue, |
| 5482 | uint32_t *paction_period) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5483 | { |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5484 | uint8_t *inptr = pvalue; |
| 5485 | int temp_int; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5486 | int v = 0; |
| 5487 | char buf[32]; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5488 | *paction_period = 0; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5489 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5490 | inptr = strnchr(pvalue, strlen(pvalue), SPACE_ASCII_VALUE); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5491 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 5492 | if (!inptr) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5493 | return -EINVAL; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5494 | else if (SPACE_ASCII_VALUE != *inptr) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5495 | return -EINVAL; |
| 5496 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5497 | while ((SPACE_ASCII_VALUE == *inptr) && ('\0' != *inptr)) |
| 5498 | inptr++; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5499 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5500 | if ('\0' == *inptr) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5501 | return 0; |
| 5502 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5503 | v = sscanf(inptr, "%31s ", buf); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5504 | if (1 != v) |
| 5505 | return -EINVAL; |
| 5506 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5507 | v = kstrtos32(buf, 10, &temp_int); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5508 | if (v < 0) |
| 5509 | return -EINVAL; |
| 5510 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5511 | if (!cfg_in_range(CFG_RMC_ACTION_PERIOD_FREQUENCY, temp_int)) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5512 | return -EINVAL; |
| 5513 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 5514 | *paction_period = temp_int; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5515 | |
Jeff Johnson | 3972e0d | 2019-02-26 19:42:35 -0800 | [diff] [blame] | 5516 | hdd_debug("action_period: %d", *paction_period); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5517 | |
| 5518 | return 0; |
| 5519 | } |
| 5520 | |
| 5521 | /* Function header is left blank intentionally */ |
Jeff Johnson | 6636e62 | 2019-02-26 10:22:39 -0800 | [diff] [blame] | 5522 | static int hdd_parse_setrmcrate_command(uint8_t *command, |
Jeff Johnson | b9f9b28 | 2019-02-26 13:40:32 -0800 | [diff] [blame] | 5523 | uint32_t *rate, |
Jeff Johnson | 269d7fb | 2019-02-26 10:47:33 -0800 | [diff] [blame] | 5524 | enum tx_rate_info *tx_flags) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5525 | { |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 5526 | uint8_t *in_ptr = command; |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 5527 | int temp_int; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5528 | int v = 0; |
| 5529 | char buf[32]; |
Jeff Johnson | b9f9b28 | 2019-02-26 13:40:32 -0800 | [diff] [blame] | 5530 | *rate = 0; |
Jeff Johnson | 269d7fb | 2019-02-26 10:47:33 -0800 | [diff] [blame] | 5531 | *tx_flags = 0; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5532 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 5533 | in_ptr = strnchr(command, strlen(command), SPACE_ASCII_VALUE); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5534 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 5535 | if (!in_ptr) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5536 | return -EINVAL; |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 5537 | else if (SPACE_ASCII_VALUE != *in_ptr) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5538 | return -EINVAL; |
| 5539 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 5540 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 5541 | in_ptr++; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5542 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 5543 | if ('\0' == *in_ptr) |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5544 | return 0; |
| 5545 | |
Jeff Johnson | 4ff36b2 | 2019-02-26 13:01:07 -0800 | [diff] [blame] | 5546 | v = sscanf(in_ptr, "%31s ", buf); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5547 | if (1 != v) |
| 5548 | return -EINVAL; |
| 5549 | |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 5550 | v = kstrtos32(buf, 10, &temp_int); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5551 | if (v < 0) |
| 5552 | return -EINVAL; |
| 5553 | |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 5554 | switch (temp_int) { |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5555 | default: |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 5556 | hdd_warn("Unsupported rate: %d", temp_int); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5557 | return -EINVAL; |
| 5558 | case 0: |
| 5559 | case 6: |
| 5560 | case 9: |
| 5561 | case 12: |
| 5562 | case 18: |
| 5563 | case 24: |
| 5564 | case 36: |
| 5565 | case 48: |
| 5566 | case 54: |
Jeff Johnson | 269d7fb | 2019-02-26 10:47:33 -0800 | [diff] [blame] | 5567 | *tx_flags = TX_RATE_LEGACY; |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 5568 | *rate = temp_int * 10; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5569 | break; |
| 5570 | case 65: |
Jeff Johnson | 269d7fb | 2019-02-26 10:47:33 -0800 | [diff] [blame] | 5571 | *tx_flags = TX_RATE_HT20; |
Jeff Johnson | cd361c9 | 2019-02-26 19:23:49 -0800 | [diff] [blame] | 5572 | *rate = temp_int * 10; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5573 | break; |
| 5574 | case 72: |
Jeff Johnson | 269d7fb | 2019-02-26 10:47:33 -0800 | [diff] [blame] | 5575 | *tx_flags = TX_RATE_HT20 | TX_RATE_SGI; |
Jeff Johnson | b9f9b28 | 2019-02-26 13:40:32 -0800 | [diff] [blame] | 5576 | *rate = 722; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5577 | break; |
| 5578 | } |
| 5579 | |
Jeff Johnson | b9f9b28 | 2019-02-26 13:40:32 -0800 | [diff] [blame] | 5580 | hdd_debug("Rate: %d", *rate); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5581 | |
| 5582 | return 0; |
| 5583 | } |
| 5584 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5585 | static int drv_cmd_set_rmc_enable(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5586 | struct hdd_context *hdd_ctx, |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5587 | uint8_t *command, |
| 5588 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5589 | struct hdd_priv_data *priv_data) |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5590 | { |
| 5591 | int ret = 0; |
| 5592 | uint8_t *value = command; |
Jeff Johnson | f8a0b8f | 2019-02-26 19:26:31 -0800 | [diff] [blame] | 5593 | uint8_t rmc_enable = 0; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5594 | int status; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5595 | mac_handle_t mac_handle; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5596 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 5597 | if ((QDF_IBSS_MODE != adapter->device_mode) && |
| 5598 | (QDF_SAP_MODE != adapter->device_mode)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5599 | hdd_err("Received SETRMCENABLE cmd in invalid mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 5600 | qdf_opmode_str(adapter->device_mode), |
| 5601 | adapter->device_mode); |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5602 | hdd_err("SETRMCENABLE cmd is allowed only in IBSS/SOFTAP mode"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5603 | ret = -EINVAL; |
| 5604 | goto exit; |
| 5605 | } |
| 5606 | |
Jeff Johnson | f8a0b8f | 2019-02-26 19:26:31 -0800 | [diff] [blame] | 5607 | status = hdd_parse_setrmcenable_command(value, &rmc_enable); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5608 | if (status) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5609 | hdd_err("Invalid SETRMCENABLE command"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5610 | ret = -EINVAL; |
| 5611 | goto exit; |
| 5612 | } |
| 5613 | |
Jeff Johnson | f8a0b8f | 2019-02-26 19:26:31 -0800 | [diff] [blame] | 5614 | hdd_debug("rmc_enable %d", rmc_enable); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5615 | mac_handle = hdd_ctx->mac_handle; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5616 | |
Jeff Johnson | f8a0b8f | 2019-02-26 19:26:31 -0800 | [diff] [blame] | 5617 | if (true == rmc_enable) { |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5618 | status = sme_enable_rmc(mac_handle, adapter->vdev_id); |
Jeff Johnson | f8a0b8f | 2019-02-26 19:26:31 -0800 | [diff] [blame] | 5619 | } else if (false == rmc_enable) { |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5620 | status = sme_disable_rmc(mac_handle, adapter->vdev_id); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5621 | } else { |
Jeff Johnson | f8a0b8f | 2019-02-26 19:26:31 -0800 | [diff] [blame] | 5622 | hdd_err("Invalid SETRMCENABLE command %d", rmc_enable); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5623 | ret = -EINVAL; |
| 5624 | goto exit; |
| 5625 | } |
| 5626 | |
| 5627 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | f8a0b8f | 2019-02-26 19:26:31 -0800 | [diff] [blame] | 5628 | hdd_err("SETRMC %d failed status %d", rmc_enable, status); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5629 | ret = -EINVAL; |
| 5630 | goto exit; |
| 5631 | } |
| 5632 | |
| 5633 | exit: |
| 5634 | return ret; |
| 5635 | } |
| 5636 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5637 | static int drv_cmd_set_rmc_action_period(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5638 | struct hdd_context *hdd_ctx, |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5639 | uint8_t *command, |
| 5640 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5641 | struct hdd_priv_data *priv_data) |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5642 | { |
| 5643 | int ret = 0; |
| 5644 | uint8_t *value = command; |
Jeff Johnson | 3972e0d | 2019-02-26 19:42:35 -0800 | [diff] [blame] | 5645 | uint32_t action_period = 0; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5646 | int status; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5647 | mac_handle_t mac_handle; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5648 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 5649 | if ((QDF_IBSS_MODE != adapter->device_mode) && |
| 5650 | (QDF_SAP_MODE != adapter->device_mode)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5651 | hdd_err("Received SETRMC cmd in invalid mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 5652 | qdf_opmode_str(adapter->device_mode), |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5653 | adapter->device_mode); |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5654 | hdd_err("SETRMC cmd is allowed only in IBSS/SOFTAP mode"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5655 | ret = -EINVAL; |
| 5656 | goto exit; |
| 5657 | } |
| 5658 | |
Jeff Johnson | 3972e0d | 2019-02-26 19:42:35 -0800 | [diff] [blame] | 5659 | status = hdd_parse_setrmcactionperiod_command(value, &action_period); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5660 | if (status) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5661 | hdd_err("Invalid SETRMCACTIONPERIOD command"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5662 | ret = -EINVAL; |
| 5663 | goto exit; |
| 5664 | } |
| 5665 | |
Jeff Johnson | 3972e0d | 2019-02-26 19:42:35 -0800 | [diff] [blame] | 5666 | hdd_debug("action_period %d", action_period); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5667 | mac_handle = hdd_ctx->mac_handle; |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5668 | |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 5669 | if (ucfg_mlme_set_rmc_action_period_freq(hdd_ctx->psoc, |
Jeff Johnson | 3972e0d | 2019-02-26 19:42:35 -0800 | [diff] [blame] | 5670 | action_period) != |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 5671 | QDF_STATUS_SUCCESS) { |
Jeff Johnson | 3972e0d | 2019-02-26 19:42:35 -0800 | [diff] [blame] | 5672 | hdd_err("Could not set SETRMCACTIONPERIOD %d", action_period); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5673 | ret = -EINVAL; |
| 5674 | goto exit; |
| 5675 | } |
| 5676 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5677 | status = sme_send_rmc_action_period(mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5678 | adapter->vdev_id); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5679 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5680 | hdd_err("Could not send cesium enable indication %d", |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 5681 | status); |
| 5682 | ret = -EINVAL; |
| 5683 | goto exit; |
| 5684 | } |
| 5685 | |
| 5686 | exit: |
| 5687 | return ret; |
| 5688 | } |
| 5689 | |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5690 | static int drv_cmd_set_rmc_tx_rate(struct hdd_adapter *adapter, |
| 5691 | struct hdd_context *hdd_ctx, |
| 5692 | uint8_t *command, |
| 5693 | uint8_t command_len, |
| 5694 | struct hdd_priv_data *priv_data) |
| 5695 | { |
| 5696 | int ret = 0; |
| 5697 | uint8_t *value = command; |
Jeff Johnson | af5283f | 2019-02-26 19:31:48 -0800 | [diff] [blame] | 5698 | uint32_t rate = 0; |
Jeff Johnson | 269d7fb | 2019-02-26 10:47:33 -0800 | [diff] [blame] | 5699 | enum tx_rate_info tx_flags = 0; |
Jeff Johnson | 2370b85 | 2019-02-26 17:03:12 -0800 | [diff] [blame] | 5700 | tSirRateUpdateInd params = {0}; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5701 | int status; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 5702 | bool bval = false; |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5703 | |
| 5704 | if ((QDF_IBSS_MODE != adapter->device_mode) && |
| 5705 | (QDF_SAP_MODE != adapter->device_mode)) { |
| 5706 | hdd_err("Received SETRMCTXRATE cmd in invalid mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 5707 | qdf_opmode_str(adapter->device_mode), |
| 5708 | adapter->device_mode); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5709 | hdd_err("SETRMCTXRATE cmd is allowed only in IBSS/SOFTAP mode"); |
| 5710 | ret = -EINVAL; |
| 5711 | goto exit; |
| 5712 | } |
| 5713 | |
Jeff Johnson | af5283f | 2019-02-26 19:31:48 -0800 | [diff] [blame] | 5714 | status = hdd_parse_setrmcrate_command(value, &rate, &tx_flags); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5715 | if (status) { |
| 5716 | hdd_err("Invalid SETRMCTXRATE command"); |
| 5717 | ret = -EINVAL; |
| 5718 | goto exit; |
| 5719 | } |
Jeff Johnson | af5283f | 2019-02-26 19:31:48 -0800 | [diff] [blame] | 5720 | hdd_debug("rate %d", rate); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5721 | |
| 5722 | /* |
| 5723 | * Fill the user specifieed RMC rate param |
| 5724 | * and the derived tx flags. |
| 5725 | */ |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 5726 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 5727 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 5728 | hdd_err("unable to get vht_enable2x2"); |
| 5729 | ret = -EINVAL; |
| 5730 | goto exit; |
| 5731 | } |
Jeff Johnson | 2370b85 | 2019-02-26 17:03:12 -0800 | [diff] [blame] | 5732 | params.nss = (bval == 0) ? 0 : 1; |
Jeff Johnson | af5283f | 2019-02-26 19:31:48 -0800 | [diff] [blame] | 5733 | params.reliableMcastDataRate = rate; |
Jeff Johnson | 2370b85 | 2019-02-26 17:03:12 -0800 | [diff] [blame] | 5734 | params.reliableMcastDataRateTxFlag = tx_flags; |
| 5735 | params.dev_mode = adapter->device_mode; |
| 5736 | params.bcastDataRate = -1; |
| 5737 | memcpy(params.bssid.bytes, |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5738 | adapter->mac_addr.bytes, |
Jeff Johnson | 2370b85 | 2019-02-26 17:03:12 -0800 | [diff] [blame] | 5739 | sizeof(params.bssid)); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5740 | status = sme_send_rate_update_ind(hdd_ctx->mac_handle, |
Jeff Johnson | 2370b85 | 2019-02-26 17:03:12 -0800 | [diff] [blame] | 5741 | ¶ms); |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 5742 | |
| 5743 | exit: |
| 5744 | return ret; |
| 5745 | } |
| 5746 | #endif /* FEATURE_WLAN_RMC */ |
| 5747 | |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 5748 | #ifdef FEATURE_WLAN_ESE |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5749 | 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] | 5750 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5751 | uint8_t *command, |
| 5752 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5753 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5754 | { |
| 5755 | int ret = 0; |
| 5756 | uint8_t *value = command; |
Liangwei Dong | 075afa7 | 2019-10-30 12:58:22 +0800 | [diff] [blame] | 5757 | uint32_t channel_freq_list[CFG_VALID_CHANNEL_LIST_LEN] = { 0 }; |
Jeff Johnson | 8a2e1da | 2019-02-26 17:56:24 -0800 | [diff] [blame] | 5758 | uint8_t num_channels = 0; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5759 | QDF_STATUS status; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5760 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5761 | |
Liangwei Dong | 075afa7 | 2019-10-30 12:58:22 +0800 | [diff] [blame] | 5762 | if (!hdd_ctx) { |
| 5763 | hdd_err("invalid hdd ctx"); |
| 5764 | ret = -EINVAL; |
| 5765 | goto exit; |
| 5766 | } |
| 5767 | |
| 5768 | ret = hdd_parse_channellist(hdd_ctx, value, channel_freq_list, |
| 5769 | &num_channels); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5770 | if (ret) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5771 | hdd_err("Failed to parse channel list information"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5772 | goto exit; |
| 5773 | } |
Jeff Johnson | 8a2e1da | 2019-02-26 17:56:24 -0800 | [diff] [blame] | 5774 | if (num_channels > CFG_VALID_CHANNEL_LIST_LEN) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5775 | hdd_err("number of channels (%d) supported exceeded max (%d)", |
Jeff Johnson | 8a2e1da | 2019-02-26 17:56:24 -0800 | [diff] [blame] | 5776 | num_channels, |
| 5777 | CFG_VALID_CHANNEL_LIST_LEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5778 | ret = -EINVAL; |
| 5779 | goto exit; |
| 5780 | } |
Vignesh Viswanathan | a2f5ce58 | 2018-05-09 20:38:39 +0530 | [diff] [blame] | 5781 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5782 | mac_handle = hdd_ctx->mac_handle; |
Liangwei Dong | 075afa7 | 2019-10-30 12:58:22 +0800 | [diff] [blame] | 5783 | if (!sme_validate_channel_list(mac_handle, channel_freq_list, |
Jeff Johnson | 8a2e1da | 2019-02-26 17:56:24 -0800 | [diff] [blame] | 5784 | num_channels)) { |
Vignesh Viswanathan | a2f5ce58 | 2018-05-09 20:38:39 +0530 | [diff] [blame] | 5785 | hdd_err("List contains invalid channel(s)"); |
| 5786 | ret = -EINVAL; |
| 5787 | goto exit; |
| 5788 | } |
| 5789 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5790 | status = sme_set_ese_roam_scan_channel_list(mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5791 | adapter->vdev_id, |
Liangwei Dong | 075afa7 | 2019-10-30 12:58:22 +0800 | [diff] [blame] | 5792 | channel_freq_list, |
Jeff Johnson | 8a2e1da | 2019-02-26 17:56:24 -0800 | [diff] [blame] | 5793 | num_channels); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5794 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5795 | hdd_err("Failed to update channel list information"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5796 | ret = -EINVAL; |
| 5797 | goto exit; |
| 5798 | } |
| 5799 | |
| 5800 | exit: |
| 5801 | return ret; |
| 5802 | } |
| 5803 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5804 | static int drv_cmd_get_tsm_stats(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5805 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5806 | uint8_t *command, |
| 5807 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5808 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5809 | { |
| 5810 | int ret = 0; |
| 5811 | uint8_t *value = command; |
| 5812 | char extra[128] = { 0 }; |
| 5813 | int len = 0; |
| 5814 | uint8_t tid = 0; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5815 | struct hdd_station_ctx *sta_ctx; |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 5816 | tAniTrafStrmMetrics tsm_metrics = {0}; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5817 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 5818 | if ((QDF_STA_MODE != adapter->device_mode) && |
| 5819 | (QDF_P2P_CLIENT_MODE != adapter->device_mode)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5820 | hdd_warn("Unsupported in mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 5821 | qdf_opmode_str(adapter->device_mode), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5822 | adapter->device_mode); |
| 5823 | return -EINVAL; |
| 5824 | } |
| 5825 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5826 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5827 | |
| 5828 | /* if not associated, return error */ |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 5829 | if (eConnectionState_Associated != sta_ctx->conn_info.conn_state) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5830 | hdd_err("Not associated!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5831 | ret = -EINVAL; |
| 5832 | goto exit; |
| 5833 | } |
| 5834 | |
| 5835 | /* Move pointer to ahead of GETTSMSTATS<delimiter> */ |
| 5836 | value = value + command_len + 1; |
| 5837 | |
| 5838 | /* Convert the value from ascii to integer */ |
| 5839 | ret = kstrtou8(value, 10, &tid); |
| 5840 | if (ret < 0) { |
| 5841 | /* |
| 5842 | * If the input value is greater than max value of datatype, |
| 5843 | * then also kstrtou8 fails |
| 5844 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5845 | hdd_err("kstrtou8 failed range [%d - %d]", |
| 5846 | TID_MIN_VALUE, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5847 | TID_MAX_VALUE); |
| 5848 | ret = -EINVAL; |
| 5849 | goto exit; |
| 5850 | } |
| 5851 | if ((tid < TID_MIN_VALUE) || (tid > TID_MAX_VALUE)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5852 | 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] | 5853 | tid, TID_MIN_VALUE, TID_MAX_VALUE); |
| 5854 | ret = -EINVAL; |
| 5855 | goto exit; |
| 5856 | } |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5857 | hdd_debug("Received Command to get tsm stats tid = %d", |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5858 | tid); |
Jeff Johnson | c13bdf1 | 2017-01-25 16:28:19 -0800 | [diff] [blame] | 5859 | ret = hdd_get_tsm_stats(adapter, tid, &tsm_metrics); |
| 5860 | if (ret) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5861 | hdd_err("failed to get tsm stats"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5862 | goto exit; |
| 5863 | } |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5864 | hdd_debug( |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5865 | "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] | 5866 | tsm_metrics.UplinkPktQueueDly, |
| 5867 | tsm_metrics.UplinkPktQueueDlyHist[0], |
| 5868 | tsm_metrics.UplinkPktQueueDlyHist[1], |
| 5869 | tsm_metrics.UplinkPktQueueDlyHist[2], |
| 5870 | tsm_metrics.UplinkPktQueueDlyHist[3], |
| 5871 | tsm_metrics.UplinkPktTxDly, |
| 5872 | tsm_metrics.UplinkPktLoss, |
| 5873 | tsm_metrics.UplinkPktCount, |
| 5874 | tsm_metrics.RoamingCount, |
| 5875 | tsm_metrics.RoamingDly); |
| 5876 | /* |
| 5877 | * Output TSM stats is of the format |
| 5878 | * GETTSMSTATS [PktQueueDly] |
| 5879 | * [PktQueueDlyHist[0]]:[PktQueueDlyHist[1]] ...[RoamingDly] |
| 5880 | * eg., GETTSMSTATS 10 1:0:0:161 20 1 17 8 39800 |
| 5881 | */ |
| 5882 | len = scnprintf(extra, |
| 5883 | sizeof(extra), |
| 5884 | "%s %d %d:%d:%d:%d %u %d %d %d %d", |
| 5885 | command, |
| 5886 | tsm_metrics.UplinkPktQueueDly, |
| 5887 | tsm_metrics.UplinkPktQueueDlyHist[0], |
| 5888 | tsm_metrics.UplinkPktQueueDlyHist[1], |
| 5889 | tsm_metrics.UplinkPktQueueDlyHist[2], |
| 5890 | tsm_metrics.UplinkPktQueueDlyHist[3], |
| 5891 | tsm_metrics.UplinkPktTxDly, |
| 5892 | tsm_metrics.UplinkPktLoss, |
| 5893 | tsm_metrics.UplinkPktCount, |
| 5894 | tsm_metrics.RoamingCount, |
| 5895 | tsm_metrics.RoamingDly); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5896 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5897 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5898 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5899 | ret = -EFAULT; |
| 5900 | goto exit; |
| 5901 | } |
| 5902 | |
| 5903 | exit: |
| 5904 | return ret; |
| 5905 | } |
| 5906 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5907 | static int drv_cmd_set_cckm_ie(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5908 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5909 | uint8_t *command, |
| 5910 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5911 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5912 | { |
| 5913 | int ret; |
| 5914 | uint8_t *value = command; |
Jeff Johnson | 264e2d3 | 2019-02-26 13:16:58 -0800 | [diff] [blame] | 5915 | uint8_t *cckm_ie = NULL; |
Jeff Johnson | b9eeef3 | 2019-02-26 13:15:49 -0800 | [diff] [blame] | 5916 | uint8_t cckm_ie_len = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5917 | |
Jeff Johnson | 264e2d3 | 2019-02-26 13:16:58 -0800 | [diff] [blame] | 5918 | ret = hdd_parse_get_cckm_ie(value, &cckm_ie, &cckm_ie_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5919 | if (ret) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5920 | hdd_err("Failed to parse cckm ie data"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5921 | goto exit; |
| 5922 | } |
| 5923 | |
Jeff Johnson | b9eeef3 | 2019-02-26 13:15:49 -0800 | [diff] [blame] | 5924 | if (cckm_ie_len > DOT11F_IE_RSN_MAX_LEN) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5925 | hdd_err("CCKM Ie input length is more than max[%d]", |
| 5926 | DOT11F_IE_RSN_MAX_LEN); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 5927 | if (cckm_ie) { |
Jeff Johnson | 264e2d3 | 2019-02-26 13:16:58 -0800 | [diff] [blame] | 5928 | qdf_mem_free(cckm_ie); |
| 5929 | cckm_ie = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5930 | } |
| 5931 | ret = -EINVAL; |
| 5932 | goto exit; |
| 5933 | } |
| 5934 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5935 | sme_set_cckm_ie(hdd_ctx->mac_handle, adapter->vdev_id, |
Jeff Johnson | 264e2d3 | 2019-02-26 13:16:58 -0800 | [diff] [blame] | 5936 | cckm_ie, cckm_ie_len); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 5937 | if (cckm_ie) { |
Jeff Johnson | 264e2d3 | 2019-02-26 13:16:58 -0800 | [diff] [blame] | 5938 | qdf_mem_free(cckm_ie); |
| 5939 | cckm_ie = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5940 | } |
| 5941 | |
| 5942 | exit: |
| 5943 | return ret; |
| 5944 | } |
| 5945 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 5946 | static int drv_cmd_ccx_beacon_req(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 5947 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5948 | uint8_t *command, |
| 5949 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 5950 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5951 | { |
| 5952 | int ret; |
| 5953 | uint8_t *value = command; |
Jeff Johnson | 210bc97 | 2019-02-26 19:55:01 -0800 | [diff] [blame] | 5954 | tCsrEseBeaconReq req = {0}; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5955 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5956 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 5957 | if (QDF_STA_MODE != adapter->device_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5958 | hdd_warn("Unsupported in mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 5959 | qdf_opmode_str(adapter->device_mode), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5960 | adapter->device_mode); |
| 5961 | return -EINVAL; |
| 5962 | } |
| 5963 | |
gaurank kathpalia | 88f78ec | 2019-09-04 20:18:02 +0530 | [diff] [blame] | 5964 | ret = hdd_parse_ese_beacon_req(hdd_ctx->pdev, value, &req); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5965 | if (ret) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5966 | hdd_err("Failed to parse ese beacon req"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5967 | goto exit; |
| 5968 | } |
| 5969 | |
| 5970 | if (!hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5971 | hdd_debug("Not associated"); |
Rajeev Kumar Sirasanagandla | 8413a48 | 2018-04-19 18:02:45 +0530 | [diff] [blame] | 5972 | |
Jeff Johnson | 210bc97 | 2019-02-26 19:55:01 -0800 | [diff] [blame] | 5973 | if (!req.numBcnReqIe) |
Rajeev Kumar Sirasanagandla | 8413a48 | 2018-04-19 18:02:45 +0530 | [diff] [blame] | 5974 | return -EINVAL; |
| 5975 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5976 | hdd_indicate_ese_bcn_report_no_results(adapter, |
Jeff Johnson | 210bc97 | 2019-02-26 19:55:01 -0800 | [diff] [blame] | 5977 | req.bcnReq[0].measurementToken, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5978 | 0x02, /* BIT(1) set for measurement done */ |
| 5979 | 0); /* no BSS */ |
| 5980 | goto exit; |
| 5981 | } |
| 5982 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 5983 | status = sme_set_ese_beacon_request(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5984 | adapter->vdev_id, |
Jeff Johnson | 210bc97 | 2019-02-26 19:55:01 -0800 | [diff] [blame] | 5985 | &req); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5986 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5987 | if (QDF_STATUS_E_RESOURCES == status) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 5988 | 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] | 5989 | status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5990 | ret = -EBUSY; |
| 5991 | goto exit; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5992 | } else if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 5993 | hdd_err("sme_set_ese_beacon_request failed (%d)", |
| 5994 | status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5995 | ret = -EINVAL; |
| 5996 | goto exit; |
| 5997 | } |
| 5998 | |
| 5999 | exit: |
| 6000 | return ret; |
| 6001 | } |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 6002 | |
| 6003 | /** |
| 6004 | * drv_cmd_ccx_plm_req() - Set ESE PLM request |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 6005 | * @adapter: Pointer to the HDD adapter |
| 6006 | * @hdd_ctx: Pointer to the HDD context |
| 6007 | * @command: Driver command string |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 6008 | * @command_len: Driver command string length |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 6009 | * @priv_data: Private data coming with the driver command. Unused here |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 6010 | * |
| 6011 | * This function handles driver command that sets the ESE PLM request |
| 6012 | * |
| 6013 | * Return: 0 on success; negative errno otherwise |
| 6014 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6015 | static int drv_cmd_ccx_plm_req(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6016 | struct hdd_context *hdd_ctx, |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 6017 | uint8_t *command, |
| 6018 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6019 | struct hdd_priv_data *priv_data) |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 6020 | { |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 6021 | QDF_STATUS status; |
| 6022 | struct plm_req_params *req; |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 6023 | |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 6024 | req = qdf_mem_malloc(sizeof(*req)); |
| 6025 | if (!req) |
| 6026 | return -ENOMEM; |
| 6027 | |
| 6028 | status = hdd_parse_plm_cmd(command, req); |
| 6029 | if (QDF_IS_STATUS_SUCCESS(status)) { |
| 6030 | req->vdev_id = adapter->vdev_id; |
| 6031 | status = sme_set_plm_request(hdd_ctx->mac_handle, req); |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 6032 | } |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 6033 | qdf_mem_free(req); |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 6034 | |
Jeff Johnson | 36583f0 | 2019-02-26 08:02:11 -0800 | [diff] [blame] | 6035 | return qdf_status_to_os_return(status); |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 6036 | } |
| 6037 | |
| 6038 | /** |
| 6039 | * drv_cmd_set_ccx_mode() - Set ESE mode |
| 6040 | * @adapter: Pointer to the HDD adapter |
| 6041 | * @hdd_ctx: Pointer to the HDD context |
| 6042 | * @command: Driver command string |
| 6043 | * @command_len: Driver command string length |
| 6044 | * @priv_data: Private data coming with the driver command. Unused here |
| 6045 | * |
| 6046 | * This function handles driver command that sets ESE mode |
| 6047 | * |
| 6048 | * Return: 0 on success; negative errno otherwise |
| 6049 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6050 | static int drv_cmd_set_ccx_mode(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6051 | struct hdd_context *hdd_ctx, |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 6052 | uint8_t *command, |
| 6053 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6054 | struct hdd_priv_data *priv_data) |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 6055 | { |
| 6056 | int ret = 0; |
| 6057 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 6058 | uint8_t ese_mode = cfg_default(CFG_LFR_ESE_FEATURE_ENABLED); |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 6059 | struct pmkid_mode_bits pmkid_modes; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6060 | mac_handle_t mac_handle; |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 6061 | |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 6062 | hdd_get_pmkid_modes(hdd_ctx, &pmkid_modes); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6063 | mac_handle = hdd_ctx->mac_handle; |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 6064 | /* |
| 6065 | * Check if the features OKC/ESE/11R are supported simultaneously, |
| 6066 | * then this operation is not permitted (return FAILURE) |
| 6067 | */ |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6068 | if (sme_get_is_ese_feature_enabled(mac_handle) && |
Deepak Dhamdhere | 828f189 | 2017-02-09 11:51:19 -0800 | [diff] [blame] | 6069 | pmkid_modes.fw_okc && |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6070 | sme_get_is_ft_feature_enabled(mac_handle)) { |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 6071 | hdd_warn("OKC/ESE/11R are supported simultaneously hence this operation is not permitted!"); |
| 6072 | ret = -EPERM; |
| 6073 | goto exit; |
| 6074 | } |
| 6075 | |
| 6076 | /* Move pointer to ahead of SETCCXMODE<delimiter> */ |
| 6077 | value = value + command_len + 1; |
| 6078 | |
| 6079 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 6080 | ret = kstrtou8(value, 10, &ese_mode); |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 6081 | if (ret < 0) { |
| 6082 | /* |
| 6083 | * If the input value is greater than max value of datatype, |
| 6084 | * then also kstrtou8 fails |
| 6085 | */ |
| 6086 | hdd_err("kstrtou8 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 6087 | cfg_min(CFG_LFR_ESE_FEATURE_ENABLED), |
| 6088 | cfg_max(CFG_LFR_ESE_FEATURE_ENABLED)); |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 6089 | ret = -EINVAL; |
| 6090 | goto exit; |
| 6091 | } |
| 6092 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 6093 | hdd_debug("Received Command to change ese mode = %d", ese_mode); |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 6094 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6095 | sme_update_is_ese_feature_enabled(mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 6096 | adapter->vdev_id, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 6097 | ese_mode); |
Srinivas Girigowda | d79b345 | 2016-07-19 18:39:46 -0700 | [diff] [blame] | 6098 | |
| 6099 | exit: |
| 6100 | return ret; |
| 6101 | } |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 6102 | #endif /* FEATURE_WLAN_ESE */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6103 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6104 | static int drv_cmd_set_mc_rate(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6105 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6106 | uint8_t *command, |
| 6107 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6108 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6109 | { |
| 6110 | int ret = 0; |
| 6111 | uint8_t *value = command; |
Srinivas Girigowda | 9d55015 | 2019-03-26 12:19:45 -0700 | [diff] [blame] | 6112 | uint32_t target_rate = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6113 | |
| 6114 | /* input value is in units of hundred kbps */ |
| 6115 | |
| 6116 | /* Move pointer to ahead of SETMCRATE<delimiter> */ |
| 6117 | value = value + command_len + 1; |
| 6118 | |
| 6119 | /* Convert the value from ascii to integer, decimal base */ |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6120 | ret = kstrtouint(value, 10, &target_rate); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6121 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6122 | ret = wlan_hdd_set_mc_rate(adapter, target_rate); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6123 | return ret; |
| 6124 | } |
| 6125 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6126 | static int drv_cmd_max_tx_power(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6127 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6128 | uint8_t *command, |
| 6129 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6130 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6131 | { |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6132 | int ret; |
| 6133 | int tx_power; |
| 6134 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6135 | uint8_t *value = command; |
Dustin Brown | ce5b3d3 | 2018-01-17 15:07:38 -0800 | [diff] [blame] | 6136 | struct qdf_mac_addr bssid = QDF_MAC_ADDR_BCAST_INIT; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6137 | struct qdf_mac_addr selfmac = QDF_MAC_ADDR_BCAST_INIT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6138 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6139 | ret = hdd_parse_setmaxtxpower_command(value, &tx_power); |
| 6140 | if (ret) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 6141 | hdd_err("Invalid MAXTXPOWER command"); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6142 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6143 | } |
| 6144 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6145 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6146 | /* Assign correct self MAC address */ |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 6147 | qdf_copy_macaddr(&bssid, |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 6148 | &adapter->mac_addr); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6149 | qdf_copy_macaddr(&selfmac, |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 6150 | &adapter->mac_addr); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6151 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 6152 | hdd_debug("Device mode %d max tx power %d selfMac: " |
Srinivas Girigowda | 951b3f6 | 2020-08-10 16:54:46 -0700 | [diff] [blame] | 6153 | QDF_MAC_ADDR_FMT " bssId: " QDF_MAC_ADDR_FMT, |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6154 | adapter->device_mode, tx_power, |
Srinivas Girigowda | 951b3f6 | 2020-08-10 16:54:46 -0700 | [diff] [blame] | 6155 | QDF_MAC_ADDR_REF(selfmac.bytes), |
| 6156 | QDF_MAC_ADDR_REF(bssid.bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6157 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6158 | status = sme_set_max_tx_power(hdd_ctx->mac_handle, |
| 6159 | bssid, selfmac, tx_power); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6160 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 6161 | hdd_err("Set max tx power failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6162 | ret = -EINVAL; |
| 6163 | goto exit; |
| 6164 | } |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 6165 | hdd_debug("Set max tx power success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6166 | } |
| 6167 | |
| 6168 | exit: |
| 6169 | return ret; |
| 6170 | } |
| 6171 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6172 | static int drv_cmd_set_dfs_scan_mode(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6173 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6174 | uint8_t *command, |
| 6175 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6176 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6177 | { |
| 6178 | int ret = 0; |
| 6179 | uint8_t *value = command; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 6180 | uint8_t dfs_scan_mode = cfg_default(CFG_LFR_ROAMING_DFS_CHANNEL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6181 | |
| 6182 | /* Move pointer to ahead of SETDFSSCANMODE<delimiter> */ |
| 6183 | value = value + command_len + 1; |
| 6184 | |
| 6185 | /* Convert the value from ascii to integer */ |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 6186 | ret = kstrtou8(value, 10, &dfs_scan_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6187 | if (ret < 0) { |
| 6188 | /* |
| 6189 | * If the input value is greater than max value of datatype, |
| 6190 | * then also kstrtou8 fails |
| 6191 | */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 6192 | hdd_err("kstrtou8 failed range [%d - %d]", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 6193 | cfg_min(CFG_LFR_ROAMING_DFS_CHANNEL), |
| 6194 | cfg_max(CFG_LFR_ROAMING_DFS_CHANNEL)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6195 | ret = -EINVAL; |
| 6196 | goto exit; |
| 6197 | } |
| 6198 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 6199 | if (!cfg_in_range(CFG_LFR_ROAMING_DFS_CHANNEL, dfs_scan_mode)) { |
Jeff Johnson | 6860551 | 2019-02-26 21:30:04 -0800 | [diff] [blame] | 6200 | 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] | 6201 | dfs_scan_mode, |
| 6202 | cfg_min(CFG_LFR_ROAMING_DFS_CHANNEL), |
| 6203 | cfg_max(CFG_LFR_ROAMING_DFS_CHANNEL)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6204 | ret = -EINVAL; |
| 6205 | goto exit; |
| 6206 | } |
| 6207 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 6208 | hdd_debug("Received Command to Set DFS Scan Mode = %d", |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 6209 | dfs_scan_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6210 | |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 6211 | /* When DFS scanning is disabled, the DFS channels need to be |
| 6212 | * removed from the operation of device. |
| 6213 | */ |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 6214 | ret = wlan_hdd_enable_dfs_chan_scan(hdd_ctx, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 6215 | dfs_scan_mode != ROAMING_DFS_CHANNEL_DISABLED); |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 6216 | if (ret < 0) { |
| 6217 | /* Some conditions prevented it from disabling DFS channels */ |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 6218 | hdd_err("disable/enable DFS channel request was denied"); |
Deepak Dhamdhere | 29b3b2f | 2015-01-22 11:09:55 -0800 | [diff] [blame] | 6219 | goto exit; |
| 6220 | } |
| 6221 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 6222 | sme_update_dfs_scan_mode(hdd_ctx->mac_handle, adapter->vdev_id, |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 6223 | dfs_scan_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6224 | |
| 6225 | exit: |
| 6226 | return ret; |
| 6227 | } |
| 6228 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6229 | static int drv_cmd_get_dfs_scan_mode(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6230 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6231 | uint8_t *command, |
| 6232 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6233 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6234 | { |
| 6235 | int ret = 0; |
Jeff Johnson | 6860551 | 2019-02-26 21:30:04 -0800 | [diff] [blame] | 6236 | 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] | 6237 | char extra[32]; |
| 6238 | uint8_t len = 0; |
| 6239 | |
Jeff Johnson | 6860551 | 2019-02-26 21:30:04 -0800 | [diff] [blame] | 6240 | len = scnprintf(extra, sizeof(extra), "%s %d", command, dfs_scan_mode); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6241 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6242 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 6243 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6244 | ret = -EFAULT; |
| 6245 | } |
| 6246 | |
| 6247 | return ret; |
| 6248 | } |
| 6249 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6250 | static int drv_cmd_get_link_status(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 = 0; |
| 6257 | int value = wlan_hdd_get_link_status(adapter); |
| 6258 | char extra[32]; |
| 6259 | uint8_t len; |
| 6260 | |
| 6261 | len = scnprintf(extra, sizeof(extra), "%s %d", command, value); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6262 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6263 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 6264 | hdd_err("failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6265 | ret = -EFAULT; |
| 6266 | } |
| 6267 | |
| 6268 | return ret; |
| 6269 | } |
| 6270 | |
| 6271 | #ifdef WLAN_FEATURE_EXTWOW_SUPPORT |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6272 | static int drv_cmd_enable_ext_wow(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6273 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6274 | uint8_t *command, |
| 6275 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6276 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6277 | { |
| 6278 | uint8_t *value = command; |
| 6279 | int set_value; |
| 6280 | |
| 6281 | /* Move pointer to ahead of ENABLEEXTWOW */ |
| 6282 | value = value + command_len; |
| 6283 | |
Anurag Chouhan | 43e0c75 | 2016-09-03 16:17:02 +0530 | [diff] [blame] | 6284 | if (!(sscanf(value, "%d", &set_value))) { |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 6285 | hdd_info("No input identified"); |
Anurag Chouhan | 43e0c75 | 2016-09-03 16:17:02 +0530 | [diff] [blame] | 6286 | return -EINVAL; |
| 6287 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6288 | |
| 6289 | return hdd_enable_ext_wow_parser(adapter, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 6290 | adapter->vdev_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6291 | set_value); |
| 6292 | } |
| 6293 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6294 | static int drv_cmd_set_app1_params(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6295 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6296 | uint8_t *command, |
| 6297 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6298 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6299 | { |
| 6300 | int ret; |
| 6301 | uint8_t *value = command; |
| 6302 | |
| 6303 | /* Move pointer to ahead of SETAPP1PARAMS */ |
| 6304 | value = value + command_len; |
| 6305 | |
| 6306 | ret = hdd_set_app_type1_parser(adapter, |
| 6307 | value, strlen(value)); |
| 6308 | if (ret >= 0) |
| 6309 | hdd_ctx->is_extwow_app_type1_param_set = true; |
| 6310 | |
| 6311 | return ret; |
| 6312 | } |
| 6313 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6314 | static int drv_cmd_set_app2_params(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6315 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6316 | uint8_t *command, |
| 6317 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6318 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6319 | { |
| 6320 | int ret; |
| 6321 | uint8_t *value = command; |
| 6322 | |
| 6323 | /* Move pointer to ahead of SETAPP2PARAMS */ |
| 6324 | value = value + command_len; |
| 6325 | |
| 6326 | ret = hdd_set_app_type2_parser(adapter, value, strlen(value)); |
| 6327 | if (ret >= 0) |
| 6328 | hdd_ctx->is_extwow_app_type2_param_set = true; |
| 6329 | |
| 6330 | return ret; |
| 6331 | } |
| 6332 | #endif /* WLAN_FEATURE_EXTWOW_SUPPORT */ |
| 6333 | |
| 6334 | #ifdef FEATURE_WLAN_TDLS |
| 6335 | /** |
| 6336 | * drv_cmd_tdls_secondary_channel_offset() - secondary tdls off channel offset |
| 6337 | * @adapter: Pointer to the HDD adapter |
| 6338 | * @hdd_ctx: Pointer to the HDD context |
| 6339 | * @command: Driver command string |
| 6340 | * @command_len: Driver command string length |
| 6341 | * @priv_data: Private data coming with the driver command. Unused here |
| 6342 | * |
| 6343 | * This function handles driver command that sets the secondary tdls off channel |
| 6344 | * offset |
| 6345 | * |
| 6346 | * Return: 0 on success; negative errno otherwise |
| 6347 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6348 | static int drv_cmd_tdls_secondary_channel_offset(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6349 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6350 | uint8_t *command, |
| 6351 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6352 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6353 | { |
| 6354 | int ret; |
| 6355 | uint8_t *value = command; |
| 6356 | int set_value; |
| 6357 | |
| 6358 | /* Move pointer to point the string */ |
| 6359 | value += command_len; |
| 6360 | |
| 6361 | ret = sscanf(value, "%d", &set_value); |
| 6362 | if (ret != 1) |
| 6363 | return -EINVAL; |
| 6364 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 6365 | hdd_debug("Tdls offchannel offset:%d", set_value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6366 | |
Bala Venkatesh | 113a9e6 | 2018-08-30 15:19:02 +0530 | [diff] [blame] | 6367 | ret = hdd_set_tdls_secoffchanneloffset(hdd_ctx, adapter, set_value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6368 | |
| 6369 | return ret; |
| 6370 | } |
| 6371 | |
| 6372 | /** |
| 6373 | * drv_cmd_tdls_off_channel_mode() - set tdls off channel mode |
| 6374 | * @adapter: Pointer to the HDD adapter |
| 6375 | * @hdd_ctx: Pointer to the HDD context |
| 6376 | * @command: Driver command string |
| 6377 | * @command_len: Driver command string length |
| 6378 | * @priv_data: Private data coming with the driver command. Unused here |
| 6379 | * |
| 6380 | * This function handles driver command that sets tdls off channel mode |
| 6381 | * |
| 6382 | * Return: 0 on success; negative errno otherwise |
| 6383 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6384 | static int drv_cmd_tdls_off_channel_mode(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6385 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6386 | uint8_t *command, |
| 6387 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6388 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6389 | { |
| 6390 | int ret; |
| 6391 | uint8_t *value = command; |
| 6392 | int set_value; |
| 6393 | |
| 6394 | /* Move pointer to point the string */ |
| 6395 | value += command_len; |
| 6396 | |
| 6397 | ret = sscanf(value, "%d", &set_value); |
| 6398 | if (ret != 1) |
| 6399 | return -EINVAL; |
| 6400 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 6401 | hdd_debug("Tdls offchannel mode:%d", set_value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6402 | |
Bala Venkatesh | 113a9e6 | 2018-08-30 15:19:02 +0530 | [diff] [blame] | 6403 | ret = hdd_set_tdls_offchannelmode(hdd_ctx, adapter, set_value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6404 | |
| 6405 | return ret; |
| 6406 | } |
| 6407 | |
| 6408 | /** |
| 6409 | * drv_cmd_tdls_off_channel() - set tdls off channel number |
| 6410 | * @adapter: Pointer to the HDD adapter |
| 6411 | * @hdd_ctx: Pointer to the HDD context |
| 6412 | * @command: Driver command string |
| 6413 | * @command_len: Driver command string length |
| 6414 | * @priv_data: Private data coming with the driver command. Unused here |
| 6415 | * |
| 6416 | * This function handles driver command that sets tdls off channel number |
| 6417 | * |
| 6418 | * Return: 0 on success; negative errno otherwise |
| 6419 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6420 | static int drv_cmd_tdls_off_channel(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6421 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6422 | uint8_t *command, |
| 6423 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6424 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6425 | { |
| 6426 | int ret; |
| 6427 | uint8_t *value = command; |
Bala Venkatesh | 07546fb | 2019-07-08 18:29:28 +0530 | [diff] [blame] | 6428 | int channel; |
| 6429 | enum channel_state reg_state; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6430 | |
| 6431 | /* Move pointer to point the string */ |
| 6432 | value += command_len; |
| 6433 | |
Bala Venkatesh | 07546fb | 2019-07-08 18:29:28 +0530 | [diff] [blame] | 6434 | ret = sscanf(value, "%d", &channel); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6435 | if (ret != 1) |
| 6436 | return -EINVAL; |
Bala Venkatesh | 07546fb | 2019-07-08 18:29:28 +0530 | [diff] [blame] | 6437 | reg_state = wlan_reg_get_channel_state(hdd_ctx->pdev, channel); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6438 | |
Bala Venkatesh | 07546fb | 2019-07-08 18:29:28 +0530 | [diff] [blame] | 6439 | if (reg_state == CHANNEL_STATE_DFS || |
| 6440 | reg_state == CHANNEL_STATE_DISABLE || |
| 6441 | reg_state == CHANNEL_STATE_INVALID) { |
| 6442 | hdd_err("reg state of the channel %d is %d and not supported", |
| 6443 | channel, reg_state); |
Krishna Kumaar Natarajan | 4d09035 | 2015-10-26 18:30:53 -0700 | [diff] [blame] | 6444 | return -EINVAL; |
| 6445 | } |
| 6446 | |
Bala Venkatesh | 07546fb | 2019-07-08 18:29:28 +0530 | [diff] [blame] | 6447 | hdd_debug("Tdls offchannel num: %d", channel); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6448 | |
Bala Venkatesh | 07546fb | 2019-07-08 18:29:28 +0530 | [diff] [blame] | 6449 | ret = hdd_set_tdls_offchannel(hdd_ctx, adapter, channel); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6450 | |
| 6451 | return ret; |
| 6452 | } |
| 6453 | |
| 6454 | /** |
| 6455 | * drv_cmd_tdls_scan() - set tdls scan type |
| 6456 | * @adapter: Pointer to the HDD adapter |
| 6457 | * @hdd_ctx: Pointer to the HDD context |
| 6458 | * @command: Driver command string |
| 6459 | * @command_len: Driver command string length |
| 6460 | * @priv_data: Private data coming with the driver command. Unused here |
| 6461 | * |
| 6462 | * This function handles driver command that sets tdls scan type |
| 6463 | * |
| 6464 | * Return: 0 on success; negative errno otherwise |
| 6465 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6466 | static int drv_cmd_tdls_scan(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6467 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6468 | uint8_t *command, |
| 6469 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6470 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6471 | { |
| 6472 | int ret; |
| 6473 | uint8_t *value = command; |
| 6474 | int set_value; |
| 6475 | |
| 6476 | /* Move pointer to point the string */ |
| 6477 | value += command_len; |
| 6478 | |
| 6479 | ret = sscanf(value, "%d", &set_value); |
| 6480 | if (ret != 1) |
| 6481 | return -EINVAL; |
| 6482 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 6483 | hdd_debug("Tdls scan type val: %d", set_value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6484 | |
| 6485 | ret = hdd_set_tdls_scan_type(hdd_ctx, set_value); |
| 6486 | |
| 6487 | return ret; |
| 6488 | } |
| 6489 | #endif |
| 6490 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6491 | static int drv_cmd_get_rssi(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6492 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6493 | uint8_t *command, |
| 6494 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6495 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6496 | { |
Orhan K AKYILDIZ | c409461 | 2015-11-11 18:01:15 -0800 | [diff] [blame] | 6497 | int ret = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6498 | int8_t rssi = 0; |
| 6499 | char extra[32]; |
Orhan K AKYILDIZ | c409461 | 2015-11-11 18:01:15 -0800 | [diff] [blame] | 6500 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6501 | uint8_t len = 0; |
| 6502 | |
| 6503 | wlan_hdd_get_rssi(adapter, &rssi); |
| 6504 | |
| 6505 | len = scnprintf(extra, sizeof(extra), "%s %d", command, rssi); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6506 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6507 | |
| 6508 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 6509 | hdd_err("Failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6510 | ret = -EFAULT; |
| 6511 | } |
| 6512 | |
| 6513 | return ret; |
| 6514 | } |
| 6515 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6516 | static int drv_cmd_get_linkspeed(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6517 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6518 | uint8_t *command, |
| 6519 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6520 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6521 | { |
| 6522 | int ret; |
| 6523 | uint32_t link_speed = 0; |
| 6524 | char extra[32]; |
| 6525 | uint8_t len = 0; |
| 6526 | |
| 6527 | ret = wlan_hdd_get_link_speed(adapter, &link_speed); |
| 6528 | if (0 != ret) |
| 6529 | return ret; |
| 6530 | |
| 6531 | len = scnprintf(extra, sizeof(extra), "%s %d", command, link_speed); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6532 | len = QDF_MIN(priv_data->total_len, len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6533 | if (copy_to_user(priv_data->buf, &extra, len)) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 6534 | hdd_err("Failed to copy data to user buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6535 | ret = -EFAULT; |
| 6536 | } |
| 6537 | |
| 6538 | return ret; |
| 6539 | } |
| 6540 | |
Qiwei Cai | 4505fc6 | 2018-05-17 18:35:19 +0800 | [diff] [blame] | 6541 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6542 | /** |
| 6543 | * hdd_set_rx_filter() - set RX filter |
| 6544 | * @adapter: Pointer to adapter |
| 6545 | * @action: Filter action |
| 6546 | * @pattern: Address pattern |
| 6547 | * |
| 6548 | * Address pattern is most significant byte of address for example |
| 6549 | * 0x01 for IPV4 multicast address |
| 6550 | * 0x33 for IPV6 multicast address |
| 6551 | * 0xFF for broadcast address |
| 6552 | * |
| 6553 | * Return: 0 for success, non-zero for failure |
| 6554 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6555 | static int hdd_set_rx_filter(struct hdd_adapter *adapter, bool action, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6556 | uint8_t pattern) |
| 6557 | { |
| 6558 | int ret; |
Frank Liu | f95e813 | 2016-09-29 19:01:30 +0800 | [diff] [blame] | 6559 | uint8_t i, j; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6560 | tSirRcvFltMcAddrList *filter; |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6561 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6562 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6563 | |
| 6564 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 6565 | if (0 != ret) |
| 6566 | return ret; |
| 6567 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6568 | mac_handle = hdd_ctx->mac_handle; |
| 6569 | if (!mac_handle) { |
| 6570 | hdd_err("MAC Handle is NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6571 | return -EINVAL; |
| 6572 | } |
| 6573 | |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 6574 | if (!ucfg_pmo_is_mc_addr_list_enabled(hdd_ctx->psoc)) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 6575 | hdd_warn("mc addr ini is disabled"); |
Mukul Sharma | 3a1ab30 | 2017-01-15 19:02:37 +0530 | [diff] [blame] | 6576 | return -EINVAL; |
| 6577 | } |
| 6578 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6579 | /* |
| 6580 | * If action is false it means start dropping packets |
| 6581 | * Set addr_filter_pattern which will be used when sending |
| 6582 | * MC/BC address list to target |
| 6583 | */ |
| 6584 | if (!action) |
| 6585 | adapter->addr_filter_pattern = pattern; |
| 6586 | else |
| 6587 | adapter->addr_filter_pattern = 0; |
| 6588 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 6589 | if (((adapter->device_mode == QDF_STA_MODE) || |
| 6590 | (adapter->device_mode == QDF_P2P_CLIENT_MODE)) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6591 | adapter->mc_addr_list.mc_cnt && |
| 6592 | hdd_conn_is_connected(WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
| 6593 | |
| 6594 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6595 | filter = qdf_mem_malloc(sizeof(*filter)); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 6596 | if (!filter) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6597 | hdd_err("Could not allocate Memory"); |
| 6598 | return -ENOMEM; |
| 6599 | } |
| 6600 | filter->action = action; |
Frank Liu | f95e813 | 2016-09-29 19:01:30 +0800 | [diff] [blame] | 6601 | 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] | 6602 | if (!memcmp(adapter->mc_addr_list.addr[i], |
| 6603 | &pattern, 1)) { |
Frank Liu | f95e813 | 2016-09-29 19:01:30 +0800 | [diff] [blame] | 6604 | memcpy(filter->multicastAddr[j].bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6605 | adapter->mc_addr_list.addr[i], |
| 6606 | sizeof(adapter->mc_addr_list.addr[i])); |
Frank Liu | f95e813 | 2016-09-29 19:01:30 +0800 | [diff] [blame] | 6607 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 6608 | hdd_debug("%s RX filter : addr =" |
Srinivas Girigowda | 951b3f6 | 2020-08-10 16:54:46 -0700 | [diff] [blame] | 6609 | QDF_MAC_ADDR_FMT, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6610 | action ? "setting" : "clearing", |
Srinivas Girigowda | 951b3f6 | 2020-08-10 16:54:46 -0700 | [diff] [blame] | 6611 | QDF_MAC_ADDR_REF(filter->multicastAddr[j].bytes)); |
Frank Liu | f95e813 | 2016-09-29 19:01:30 +0800 | [diff] [blame] | 6612 | j++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6613 | } |
SaidiReddy Yenuga | 0b2c9f4 | 2017-02-03 12:26:38 +0530 | [diff] [blame] | 6614 | if (j == SIR_MAX_NUM_MULTICAST_ADDRESS) |
| 6615 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6616 | } |
Frank Liu | f95e813 | 2016-09-29 19:01:30 +0800 | [diff] [blame] | 6617 | filter->ulMulticastAddrCnt = j; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6618 | /* Set rx filter */ |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 6619 | sme_8023_multicast_list(mac_handle, adapter->vdev_id, |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6620 | filter); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6621 | qdf_mem_free(filter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6622 | } else { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 6623 | hdd_debug("mode %d mc_cnt %d", |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6624 | adapter->device_mode, adapter->mc_addr_list.mc_cnt); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6625 | } |
| 6626 | |
| 6627 | return 0; |
| 6628 | } |
| 6629 | |
| 6630 | /** |
Jeff Johnson | 0f7440e | 2018-05-06 16:12:39 -0700 | [diff] [blame] | 6631 | * hdd_driver_rxfilter_command_handler() - RXFILTER driver command handler |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6632 | * @command: Pointer to input string driver command |
| 6633 | * @adapter: Pointer to adapter |
| 6634 | * @action: Action to enable/disable filtering |
| 6635 | * |
| 6636 | * If action == false |
| 6637 | * Start filtering out data packets based on type |
| 6638 | * RXFILTER-REMOVE 0 -> Start filtering out unicast data packets |
| 6639 | * RXFILTER-REMOVE 1 -> Start filtering out broadcast data packets |
| 6640 | * RXFILTER-REMOVE 2 -> Start filtering out IPV4 mcast data packets |
| 6641 | * RXFILTER-REMOVE 3 -> Start filtering out IPV6 mcast data packets |
| 6642 | * |
| 6643 | * if action == true |
| 6644 | * Stop filtering data packets based on type |
| 6645 | * RXFILTER-ADD 0 -> Stop filtering unicast data packets |
| 6646 | * RXFILTER-ADD 1 -> Stop filtering broadcast data packets |
| 6647 | * RXFILTER-ADD 2 -> Stop filtering IPV4 mcast data packets |
| 6648 | * RXFILTER-ADD 3 -> Stop filtering IPV6 mcast data packets |
| 6649 | * |
| 6650 | * Current implementation only supports IPV4 address filtering by |
| 6651 | * selectively allowing IPV4 multicast data packest based on |
| 6652 | * address list received in .ndo_set_rx_mode |
| 6653 | * |
| 6654 | * Return: 0 for success, non-zero for failure |
| 6655 | */ |
Jeff Johnson | 0f7440e | 2018-05-06 16:12:39 -0700 | [diff] [blame] | 6656 | static int hdd_driver_rxfilter_command_handler(uint8_t *command, |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6657 | struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6658 | bool action) |
| 6659 | { |
| 6660 | int ret = 0; |
| 6661 | uint8_t *value; |
| 6662 | uint8_t type; |
| 6663 | |
| 6664 | value = command; |
| 6665 | /* Skip space after RXFILTER-REMOVE OR RXFILTER-ADD based on action */ |
| 6666 | if (!action) |
| 6667 | value = command + 16; |
| 6668 | else |
| 6669 | value = command + 13; |
| 6670 | ret = kstrtou8(value, 10, &type); |
| 6671 | if (ret < 0) { |
Dustin Brown | 933cd2a | 2018-04-18 11:28:15 -0700 | [diff] [blame] | 6672 | hdd_err("kstrtou8 failed invalid input value"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6673 | return -EINVAL; |
| 6674 | } |
| 6675 | |
| 6676 | switch (type) { |
| 6677 | case 2: |
| 6678 | /* Set rx filter for IPV4 multicast data packets */ |
| 6679 | ret = hdd_set_rx_filter(adapter, action, 0x01); |
| 6680 | break; |
| 6681 | default: |
Arun Kumar Khandavalli | afcb055 | 2020-01-20 11:46:36 +0530 | [diff] [blame] | 6682 | hdd_debug("Unsupported RXFILTER type %d", type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6683 | break; |
| 6684 | } |
| 6685 | |
| 6686 | return ret; |
| 6687 | } |
| 6688 | |
| 6689 | /** |
| 6690 | * drv_cmd_rx_filter_remove() - RXFILTER REMOVE driver command handler |
| 6691 | * @adapter: Pointer to network adapter |
| 6692 | * @hdd_ctx: Pointer to hdd context |
| 6693 | * @command: Pointer to input command |
| 6694 | * @command_len: Command length |
| 6695 | * @priv_data: Pointer to private data in command |
| 6696 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6697 | static int drv_cmd_rx_filter_remove(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6698 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6699 | uint8_t *command, |
| 6700 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6701 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6702 | { |
Jeff Johnson | 0f7440e | 2018-05-06 16:12:39 -0700 | [diff] [blame] | 6703 | return hdd_driver_rxfilter_command_handler(command, adapter, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6704 | } |
| 6705 | |
| 6706 | /** |
| 6707 | * drv_cmd_rx_filter_add() - RXFILTER ADD driver command handler |
| 6708 | * @adapter: Pointer to network adapter |
| 6709 | * @hdd_ctx: Pointer to hdd context |
| 6710 | * @command: Pointer to input command |
| 6711 | * @command_len: Command length |
| 6712 | * @priv_data: Pointer to private data in command |
| 6713 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 6714 | static int drv_cmd_rx_filter_add(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6715 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6716 | uint8_t *command, |
| 6717 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 6718 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6719 | { |
Jeff Johnson | 0f7440e | 2018-05-06 16:12:39 -0700 | [diff] [blame] | 6720 | return hdd_driver_rxfilter_command_handler(command, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6721 | } |
Qiwei Cai | 4505fc6 | 2018-05-17 18:35:19 +0800 | [diff] [blame] | 6722 | #endif /* WLAN_FEATURE_PACKET_FILTERING */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6723 | |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6724 | /** |
| 6725 | * hdd_parse_setantennamode_command() - HDD Parse SETANTENNAMODE |
| 6726 | * command |
| 6727 | * @value: Pointer to SETANTENNAMODE command |
| 6728 | * @mode: Pointer to antenna mode |
| 6729 | * @reason: Pointer to reason for set antenna mode |
| 6730 | * |
| 6731 | * This function parses the SETANTENNAMODE command passed in the format |
| 6732 | * SETANTENNAMODE<space>mode |
| 6733 | * |
| 6734 | * Return: 0 for success non-zero for failure |
| 6735 | */ |
| 6736 | static int hdd_parse_setantennamode_command(const uint8_t *value) |
| 6737 | { |
| 6738 | const uint8_t *in_ptr = value; |
| 6739 | int tmp, v; |
| 6740 | char arg1[32]; |
| 6741 | |
| 6742 | in_ptr = strnchr(value, strlen(value), SPACE_ASCII_VALUE); |
| 6743 | |
| 6744 | /* no argument after the command */ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 6745 | if (!in_ptr) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 6746 | hdd_err("No argument after the command"); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6747 | return -EINVAL; |
| 6748 | } |
| 6749 | |
| 6750 | /* no space after the command */ |
| 6751 | if (SPACE_ASCII_VALUE != *in_ptr) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 6752 | hdd_err("No space after the command"); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6753 | return -EINVAL; |
| 6754 | } |
| 6755 | |
| 6756 | /* remove empty spaces */ |
| 6757 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 6758 | in_ptr++; |
| 6759 | |
| 6760 | /* no argument followed by spaces */ |
| 6761 | if ('\0' == *in_ptr) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 6762 | hdd_err("No argument followed by spaces"); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6763 | return -EINVAL; |
| 6764 | } |
| 6765 | |
| 6766 | /* get the argument i.e. antenna mode */ |
| 6767 | v = sscanf(in_ptr, "%31s ", arg1); |
| 6768 | if (1 != v) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 6769 | hdd_err("argument retrieval from cmd string failed"); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6770 | return -EINVAL; |
| 6771 | } |
| 6772 | |
| 6773 | v = kstrtos32(arg1, 10, &tmp); |
| 6774 | if (v < 0) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 6775 | hdd_err("argument string to int conversion failed"); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6776 | return -EINVAL; |
| 6777 | } |
| 6778 | |
| 6779 | return tmp; |
| 6780 | } |
| 6781 | |
| 6782 | /** |
| 6783 | * hdd_is_supported_chain_mask_2x2() - Verify if supported chain |
| 6784 | * mask is 2x2 mode |
| 6785 | * @hdd_ctx: Pointer to hdd contex |
| 6786 | * |
| 6787 | * Return: true if supported chain mask 2x2 else false |
| 6788 | */ |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6789 | 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] | 6790 | { |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 6791 | QDF_STATUS status; |
| 6792 | bool bval = false; |
| 6793 | |
| 6794 | /* |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6795 | * Revisit and the update logic to determine the number |
| 6796 | * of TX/RX chains supported in the system when |
| 6797 | * antenna sharing per band chain mask support is |
| 6798 | * brought in |
| 6799 | */ |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 6800 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 6801 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 6802 | hdd_err("unable to get vht_enable2x2"); |
| 6803 | |
| 6804 | return (bval == 0x01) ? true : false; |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6805 | } |
| 6806 | |
| 6807 | /** |
| 6808 | * hdd_is_supported_chain_mask_1x1() - Verify if the supported |
| 6809 | * chain mask is 1x1 |
| 6810 | * @hdd_ctx: Pointer to hdd contex |
| 6811 | * |
| 6812 | * Return: true if supported chain mask 1x1 else false |
| 6813 | */ |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6814 | 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] | 6815 | { |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 6816 | QDF_STATUS status; |
| 6817 | bool bval = false; |
| 6818 | |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6819 | /* |
| 6820 | * Revisit and update the logic to determine the number |
| 6821 | * of TX/RX chains supported in the system when |
| 6822 | * antenna sharing per band chain mask support is |
| 6823 | * brought in |
| 6824 | */ |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 6825 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 6826 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 6827 | hdd_err("unable to get vht_enable2x2"); |
| 6828 | |
| 6829 | return (!bval) ? true : false; |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6830 | } |
| 6831 | |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 6832 | 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] | 6833 | { |
| 6834 | QDF_STATUS status; |
| 6835 | uint8_t smps_mode; |
| 6836 | uint8_t smps_enable; |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6837 | mac_handle_t mac_handle; |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 6838 | |
| 6839 | /* Update SME SMPS config */ |
| 6840 | if (HDD_ANTENNA_MODE_1X1 == mode) { |
| 6841 | smps_enable = true; |
| 6842 | smps_mode = HDD_SMPS_MODE_STATIC; |
| 6843 | } else { |
| 6844 | smps_enable = false; |
| 6845 | smps_mode = HDD_SMPS_MODE_DISABLED; |
| 6846 | } |
| 6847 | |
| 6848 | hdd_debug("Update SME SMPS enable: %d mode: %d", |
| 6849 | smps_enable, smps_mode); |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6850 | mac_handle = hdd_ctx->mac_handle; |
| 6851 | status = sme_update_mimo_power_save(mac_handle, smps_enable, |
| 6852 | smps_mode, false); |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 6853 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6854 | hdd_err("Update SMPS config failed enable: %d mode: %d status: %d", |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 6855 | smps_enable, smps_mode, status); |
| 6856 | return QDF_STATUS_E_FAILURE; |
| 6857 | } |
| 6858 | |
| 6859 | hdd_ctx->current_antenna_mode = mode; |
| 6860 | /* |
| 6861 | * Update the user requested nss in the mac context. |
| 6862 | * This will be used in tdls protocol engine to form tdls |
| 6863 | * Management frames. |
| 6864 | */ |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6865 | sme_update_user_configured_nss(mac_handle, |
| 6866 | hdd_ctx->current_antenna_mode); |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 6867 | |
| 6868 | hdd_debug("Successfully switched to mode: %d x %d", |
| 6869 | hdd_ctx->current_antenna_mode, |
| 6870 | hdd_ctx->current_antenna_mode); |
| 6871 | |
| 6872 | return QDF_STATUS_SUCCESS; |
| 6873 | } |
| 6874 | |
Dundi Raviteja | 4016e93 | 2018-08-02 12:16:25 +0530 | [diff] [blame] | 6875 | /** |
| 6876 | * wlan_hdd_soc_set_antenna_mode_cb() - Callback for set antenna mode |
| 6877 | * @status: Status of set antenna mode |
| 6878 | * @context: callback context |
| 6879 | * |
| 6880 | * Callback on setting antenna mode |
| 6881 | * |
| 6882 | * Return: None |
| 6883 | */ |
| 6884 | static void |
| 6885 | wlan_hdd_soc_set_antenna_mode_cb(enum set_antenna_mode_status status, |
| 6886 | void *context) |
| 6887 | { |
| 6888 | struct osif_request *request = NULL; |
| 6889 | |
| 6890 | hdd_debug("Status: %d", status); |
| 6891 | |
| 6892 | request = osif_request_get(context); |
| 6893 | if (!request) { |
| 6894 | hdd_err("obselete request"); |
| 6895 | return; |
| 6896 | } |
| 6897 | |
| 6898 | /* Signal the completion of set dual mac config */ |
| 6899 | osif_request_complete(request); |
| 6900 | osif_request_put(request); |
| 6901 | } |
| 6902 | |
Abhishek Singh | 1571ca7 | 2018-04-17 15:14:21 +0530 | [diff] [blame] | 6903 | int hdd_set_antenna_mode(struct hdd_adapter *adapter, |
| 6904 | struct hdd_context *hdd_ctx, int mode) |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6905 | { |
| 6906 | struct sir_antenna_mode_param params; |
| 6907 | QDF_STATUS status; |
| 6908 | int ret = 0; |
Dundi Raviteja | 6bb9e32 | 2018-05-16 17:04:41 +0530 | [diff] [blame] | 6909 | struct osif_request *request = NULL; |
| 6910 | static const struct osif_request_params request_params = { |
| 6911 | .priv_size = 0, |
Abhishek Singh | d1f21c7 | 2019-01-21 15:16:34 +0530 | [diff] [blame] | 6912 | .timeout_ms = SME_POLICY_MGR_CMD_TIMEOUT, |
Dundi Raviteja | 6bb9e32 | 2018-05-16 17:04:41 +0530 | [diff] [blame] | 6913 | }; |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6914 | |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6915 | switch (mode) { |
| 6916 | case HDD_ANTENNA_MODE_1X1: |
| 6917 | params.num_rx_chains = 1; |
| 6918 | params.num_tx_chains = 1; |
| 6919 | break; |
| 6920 | case HDD_ANTENNA_MODE_2X2: |
| 6921 | params.num_rx_chains = 2; |
| 6922 | params.num_tx_chains = 2; |
| 6923 | break; |
| 6924 | default: |
| 6925 | hdd_err("unsupported antenna mode"); |
| 6926 | ret = -EINVAL; |
| 6927 | goto exit; |
| 6928 | } |
| 6929 | |
gaurank kathpalia | 1281b30 | 2018-11-05 21:10:37 +0530 | [diff] [blame] | 6930 | if (hdd_ctx->dynamic_nss_chains_support) |
gaurank kathpalia | 7cb6a32 | 2018-10-24 19:50:34 +0530 | [diff] [blame] | 6931 | return hdd_set_dynamic_antenna_mode(adapter, |
| 6932 | params.num_rx_chains, |
| 6933 | params.num_tx_chains); |
gaurank kathpalia | 7cb6a32 | 2018-10-24 19:50:34 +0530 | [diff] [blame] | 6934 | |
gaurank kathpalia | f95ae68 | 2018-11-05 21:13:07 +0530 | [diff] [blame] | 6935 | if ((HDD_ANTENNA_MODE_2X2 == mode) && |
| 6936 | (!hdd_is_supported_chain_mask_2x2(hdd_ctx))) { |
| 6937 | hdd_err("System does not support 2x2 mode"); |
| 6938 | ret = -EPERM; |
| 6939 | goto exit; |
| 6940 | } |
| 6941 | |
| 6942 | if ((HDD_ANTENNA_MODE_1X1 == mode) && |
| 6943 | hdd_is_supported_chain_mask_1x1(hdd_ctx)) { |
| 6944 | hdd_err("System only supports 1x1 mode"); |
| 6945 | goto exit; |
| 6946 | } |
| 6947 | |
Archana Ramachandran | d5d2e92 | 2016-04-20 16:57:35 -0700 | [diff] [blame] | 6948 | /* Check TDLS status and update antenna mode */ |
| 6949 | if ((QDF_STA_MODE == adapter->device_mode) && |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 6950 | policy_mgr_is_sta_active_connection_exists(hdd_ctx->psoc)) { |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6951 | ret = wlan_hdd_tdls_antenna_switch(hdd_ctx, adapter, mode); |
Archana Ramachandran | d5d2e92 | 2016-04-20 16:57:35 -0700 | [diff] [blame] | 6952 | if (0 != ret) |
| 6953 | goto exit; |
| 6954 | } |
| 6955 | |
Dundi Raviteja | 6bb9e32 | 2018-05-16 17:04:41 +0530 | [diff] [blame] | 6956 | request = osif_request_alloc(&request_params); |
| 6957 | if (!request) { |
| 6958 | hdd_err("Request Allocation Failure"); |
| 6959 | ret = -ENOMEM; |
| 6960 | goto exit; |
| 6961 | } |
| 6962 | |
| 6963 | params.set_antenna_mode_ctx = osif_request_cookie(request); |
| 6964 | 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] | 6965 | hdd_debug("Set antenna mode rx chains: %d tx chains: %d", |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6966 | params.num_rx_chains, |
| 6967 | params.num_tx_chains); |
| 6968 | |
Jeff Johnson | d549efa | 2018-06-13 20:27:47 -0700 | [diff] [blame] | 6969 | status = sme_soc_set_antenna_mode(hdd_ctx->mac_handle, ¶ms); |
Abhishek Singh | 1571ca7 | 2018-04-17 15:14:21 +0530 | [diff] [blame] | 6970 | if (QDF_IS_STATUS_ERROR(status)) { |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6971 | hdd_err("set antenna mode failed status : %d", status); |
| 6972 | ret = -EFAULT; |
Dundi Raviteja | 6bb9e32 | 2018-05-16 17:04:41 +0530 | [diff] [blame] | 6973 | goto request_put; |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6974 | } |
| 6975 | |
Dundi Raviteja | 6bb9e32 | 2018-05-16 17:04:41 +0530 | [diff] [blame] | 6976 | ret = osif_request_wait_for_response(request); |
| 6977 | if (ret) { |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6978 | hdd_err("send set antenna mode timed out"); |
Dundi Raviteja | 6bb9e32 | 2018-05-16 17:04:41 +0530 | [diff] [blame] | 6979 | goto request_put; |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6980 | } |
| 6981 | |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 6982 | status = hdd_update_smps_antenna_mode(hdd_ctx, mode); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6983 | if (QDF_STATUS_SUCCESS != status) { |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6984 | ret = -EFAULT; |
Dundi Raviteja | 6bb9e32 | 2018-05-16 17:04:41 +0530 | [diff] [blame] | 6985 | goto request_put; |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6986 | } |
Archana Ramachandran | 5041b25 | 2016-04-25 14:29:25 -0700 | [diff] [blame] | 6987 | ret = 0; |
Dundi Raviteja | 6bb9e32 | 2018-05-16 17:04:41 +0530 | [diff] [blame] | 6988 | request_put: |
| 6989 | osif_request_put(request); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6990 | exit: |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 6991 | hdd_debug("Set antenna status: %d current mode: %d", |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6992 | ret, hdd_ctx->current_antenna_mode); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 6993 | |
Abhishek Singh | 1571ca7 | 2018-04-17 15:14:21 +0530 | [diff] [blame] | 6994 | return ret; |
| 6995 | } |
gaurank kathpalia | b414bce | 2018-11-09 18:44:46 +0530 | [diff] [blame] | 6996 | |
Abhishek Singh | 1571ca7 | 2018-04-17 15:14:21 +0530 | [diff] [blame] | 6997 | /** |
| 6998 | * drv_cmd_set_antenna_mode() - SET ANTENNA MODE driver command |
| 6999 | * handler |
| 7000 | * @adapter: Pointer to network adapter |
| 7001 | * @hdd_ctx: Pointer to hdd context |
| 7002 | * @command: Pointer to input command |
| 7003 | * @command_len: Command length |
| 7004 | * @priv_data: Pointer to private data in command |
| 7005 | */ |
| 7006 | static int drv_cmd_set_antenna_mode(struct hdd_adapter *adapter, |
| 7007 | struct hdd_context *hdd_ctx, |
| 7008 | uint8_t *command, |
| 7009 | uint8_t command_len, |
| 7010 | struct hdd_priv_data *priv_data) |
| 7011 | { |
| 7012 | int mode; |
| 7013 | uint8_t *value = command; |
| 7014 | |
| 7015 | mode = hdd_parse_setantennamode_command(value); |
| 7016 | if (mode < 0) { |
| 7017 | hdd_err("Invalid SETANTENNA command"); |
| 7018 | return mode; |
| 7019 | } |
| 7020 | |
| 7021 | hdd_debug("Processing antenna mode switch to: %d", mode); |
| 7022 | |
| 7023 | return hdd_set_antenna_mode(adapter, hdd_ctx, mode); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 7024 | } |
| 7025 | |
| 7026 | /** |
gaurank kathpalia | 2472fb9 | 2018-10-31 17:40:18 +0530 | [diff] [blame] | 7027 | * hdd_get_dynamic_antenna_mode() -get the dynamic antenna mode for vdev |
| 7028 | * @antenna_mode: pointer to antenna mode of vdev |
| 7029 | * @dynamic_nss_chains_support: feature support for dynamic nss chains update |
| 7030 | * @vdev: Pointer to vdev |
| 7031 | * |
| 7032 | * This API will check for the num of chains configured for the vdev, and fill |
| 7033 | * that info in the antenna mode if the dynamic chains per vdev are supported. |
| 7034 | * |
| 7035 | * Return: None |
| 7036 | */ |
| 7037 | static void |
| 7038 | hdd_get_dynamic_antenna_mode(uint32_t *antenna_mode, |
| 7039 | bool dynamic_nss_chains_support, |
| 7040 | struct wlan_objmgr_vdev *vdev) |
| 7041 | { |
| 7042 | struct wlan_mlme_nss_chains *nss_chains_dynamic_cfg; |
| 7043 | |
| 7044 | if (!dynamic_nss_chains_support) |
| 7045 | return; |
| 7046 | |
gaurank kathpalia | b414bce | 2018-11-09 18:44:46 +0530 | [diff] [blame] | 7047 | nss_chains_dynamic_cfg = ucfg_mlme_get_dynamic_vdev_config(vdev); |
gaurank kathpalia | 2472fb9 | 2018-10-31 17:40:18 +0530 | [diff] [blame] | 7048 | if (!nss_chains_dynamic_cfg) { |
| 7049 | hdd_err("nss chain dynamic config NULL"); |
| 7050 | return; |
| 7051 | } |
| 7052 | /* |
| 7053 | * At present, this command doesn't include band, so by default |
| 7054 | * it will return the band 2ghz present rf chains. |
| 7055 | */ |
gaurank kathpalia | b414bce | 2018-11-09 18:44:46 +0530 | [diff] [blame] | 7056 | *antenna_mode = |
| 7057 | nss_chains_dynamic_cfg->num_rx_chains[NSS_CHAINS_BAND_2GHZ]; |
gaurank kathpalia | 2472fb9 | 2018-10-31 17:40:18 +0530 | [diff] [blame] | 7058 | } |
| 7059 | |
| 7060 | /** |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 7061 | * drv_cmd_get_antenna_mode() - GET ANTENNA MODE driver command |
| 7062 | * handler |
| 7063 | * @adapter: Pointer to hdd adapter |
| 7064 | * @hdd_ctx: Pointer to hdd context |
| 7065 | * @command: Pointer to input command |
| 7066 | * @command_len: length of the command |
| 7067 | * @priv_data: private data coming with the driver command |
| 7068 | * |
| 7069 | * Return: 0 for success non-zero for failure |
| 7070 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 7071 | static inline int drv_cmd_get_antenna_mode(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 7072 | struct hdd_context *hdd_ctx, |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 7073 | uint8_t *command, |
| 7074 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 7075 | struct hdd_priv_data *priv_data) |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 7076 | { |
| 7077 | uint32_t antenna_mode = 0; |
| 7078 | char extra[32]; |
| 7079 | uint8_t len = 0; |
| 7080 | |
| 7081 | antenna_mode = hdd_ctx->current_antenna_mode; |
gaurank kathpalia | 2472fb9 | 2018-10-31 17:40:18 +0530 | [diff] [blame] | 7082 | /* Overwrite this antenna mode if dynamic vdev chains are supported */ |
| 7083 | hdd_get_dynamic_antenna_mode(&antenna_mode, |
| 7084 | hdd_ctx->dynamic_nss_chains_support, |
| 7085 | adapter->vdev); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 7086 | len = scnprintf(extra, sizeof(extra), "%s %d", command, |
| 7087 | antenna_mode); |
| 7088 | len = QDF_MIN(priv_data->total_len, len + 1); |
| 7089 | if (copy_to_user(priv_data->buf, &extra, len)) { |
| 7090 | hdd_err("Failed to copy data to user buffer"); |
| 7091 | return -EFAULT; |
| 7092 | } |
| 7093 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 7094 | hdd_debug("Get antenna mode: %d", antenna_mode); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 7095 | |
| 7096 | return 0; |
| 7097 | } |
| 7098 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7099 | /* |
| 7100 | * dummy (no-op) hdd driver command handler |
| 7101 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 7102 | static int drv_cmd_dummy(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 7103 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7104 | uint8_t *command, |
| 7105 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 7106 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7107 | { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 7108 | hdd_debug("%s: Ignoring driver command \"%s\"", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7109 | adapter->dev->name, command); |
| 7110 | return 0; |
| 7111 | } |
| 7112 | |
| 7113 | /* |
| 7114 | * handler for any unsupported wlan hdd driver command |
| 7115 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 7116 | static int drv_cmd_invalid(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 7117 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7118 | uint8_t *command, |
| 7119 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 7120 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7121 | { |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 7122 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 7123 | TRACE_CODE_HDD_UNSUPPORTED_IOCTL, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 7124 | adapter->vdev_id, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7125 | |
| 7126 | hdd_warn("%s: Unsupported driver command \"%s\"", |
| 7127 | adapter->dev->name, command); |
| 7128 | |
| 7129 | return -ENOTSUPP; |
| 7130 | } |
| 7131 | |
| 7132 | /** |
Rajeev Kumar Sirasanagandla | 1a21bf6 | 2019-04-08 15:28:57 +0530 | [diff] [blame] | 7133 | * drv_cmd_set_fcc_channel() - Handle fcc constraint request |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7134 | * @adapter: HDD adapter |
| 7135 | * @hdd_ctx: HDD context |
Rajeev Kumar Sirasanagandla | 1a21bf6 | 2019-04-08 15:28:57 +0530 | [diff] [blame] | 7136 | * @command: command ptr, SET_FCC_CHANNEL 0/-1 is the command |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7137 | * @command_len: command len |
| 7138 | * @priv_data: private data |
| 7139 | * |
| 7140 | * Return: status |
| 7141 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 7142 | static int drv_cmd_set_fcc_channel(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 7143 | struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7144 | uint8_t *command, |
| 7145 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 7146 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7147 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7148 | QDF_STATUS status; |
Rajeev Kumar Sirasanagandla | 1a21bf6 | 2019-04-08 15:28:57 +0530 | [diff] [blame] | 7149 | int8_t input_value; |
| 7150 | bool fcc_constraint; |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 7151 | int err; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7152 | |
| 7153 | /* |
Rajeev Kumar Sirasanagandla | 1a21bf6 | 2019-04-08 15:28:57 +0530 | [diff] [blame] | 7154 | * This command would be called by user-space when it detects WLAN |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7155 | * ON after airplane mode is set. When APM is set, WLAN turns off. |
| 7156 | * But it can be turned back on. Otherwise; when APM is turned back |
| 7157 | * 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] | 7158 | * expected to come down. 0 means reduce power as per fcc constraint |
| 7159 | * and -1 means remove constraint. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7160 | */ |
| 7161 | |
Rajeev Kumar Sirasanagandla | 1a21bf6 | 2019-04-08 15:28:57 +0530 | [diff] [blame] | 7162 | err = kstrtos8(command + command_len + 1, 10, &input_value); |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 7163 | if (err) { |
| 7164 | hdd_err("error %d parsing userspace fcc parameter", err); |
| 7165 | return err; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7166 | } |
| 7167 | |
Rajeev Kumar Sirasanagandla | 1a21bf6 | 2019-04-08 15:28:57 +0530 | [diff] [blame] | 7168 | fcc_constraint = input_value ? false : true; |
| 7169 | hdd_debug("input_value = %d && fcc_constraint = %u", |
| 7170 | input_value, fcc_constraint); |
| 7171 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 7172 | status = ucfg_reg_set_fcc_constraint(hdd_ctx->pdev, fcc_constraint); |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 7173 | |
| 7174 | if (QDF_IS_STATUS_ERROR(status)) |
| 7175 | hdd_err("Failed to %s tx power for channels 12/13", |
Rajeev Kumar Sirasanagandla | 1a21bf6 | 2019-04-08 15:28:57 +0530 | [diff] [blame] | 7176 | fcc_constraint ? "restore" : "reduce"); |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 7177 | |
| 7178 | return qdf_status_to_os_return(status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7179 | } |
| 7180 | |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 7181 | /** |
| 7182 | * hdd_parse_set_channel_switch_command() - Parse and validate CHANNEL_SWITCH |
| 7183 | * command |
| 7184 | * @value: Pointer to the command |
| 7185 | * @chan_number: Pointer to the channel number |
| 7186 | * @chan_bw: Pointer to the channel bandwidth |
| 7187 | * |
| 7188 | * Parses and provides the channel number and channel width from the input |
| 7189 | * command which is expected to be of the format: CHANNEL_SWITCH <CH> <BW> |
| 7190 | * <CH> is channel number to move (where 1 = channel 1, 149 = channel 149, ...) |
| 7191 | * <BW> is bandwidth to move (where 20 = BW 20, 40 = BW 40, 80 = BW 80) |
| 7192 | * |
| 7193 | * Return: 0 for success, non-zero for failure |
| 7194 | */ |
| 7195 | static int hdd_parse_set_channel_switch_command(uint8_t *value, |
| 7196 | uint32_t *chan_number, |
| 7197 | uint32_t *chan_bw) |
| 7198 | { |
| 7199 | const uint8_t *in_ptr = value; |
| 7200 | int ret; |
| 7201 | |
| 7202 | in_ptr = strnchr(value, strlen(value), SPACE_ASCII_VALUE); |
| 7203 | |
| 7204 | /* no argument after the command */ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 7205 | if (!in_ptr) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 7206 | hdd_err("No argument after the command"); |
| 7207 | return -EINVAL; |
| 7208 | } |
| 7209 | |
| 7210 | /* no space after the command */ |
| 7211 | if (SPACE_ASCII_VALUE != *in_ptr) { |
| 7212 | hdd_err("No space after the command "); |
| 7213 | return -EINVAL; |
| 7214 | } |
| 7215 | |
| 7216 | /* remove empty spaces and move the next argument */ |
| 7217 | while ((SPACE_ASCII_VALUE == *in_ptr) && ('\0' != *in_ptr)) |
| 7218 | in_ptr++; |
| 7219 | |
| 7220 | /* no argument followed by spaces */ |
| 7221 | if ('\0' == *in_ptr) { |
| 7222 | hdd_err("No argument followed by spaces"); |
| 7223 | return -EINVAL; |
| 7224 | } |
| 7225 | |
| 7226 | /* get the two arguments: channel number and bandwidth */ |
| 7227 | ret = sscanf(in_ptr, "%u %u", chan_number, chan_bw); |
| 7228 | if (ret != 2) { |
| 7229 | hdd_err("Arguments retrieval from cmd string failed"); |
| 7230 | return -EINVAL; |
| 7231 | } |
| 7232 | |
| 7233 | return 0; |
| 7234 | } |
| 7235 | |
| 7236 | /** |
| 7237 | * drv_cmd_set_channel_switch() - Switch SAP/P2P-GO operating channel |
| 7238 | * @adapter: HDD adapter |
| 7239 | * @hdd_ctx: HDD context |
| 7240 | * @command: Pointer to the input command CHANNEL_SWITCH |
| 7241 | * @command_len: Command len |
| 7242 | * @priv_data: Private data |
| 7243 | * |
| 7244 | * Handles private IOCTL CHANNEL_SWITCH command to switch the operating channel |
| 7245 | * of SAP/P2P-GO |
| 7246 | * |
| 7247 | * Return: 0 for success, non-zero for failure |
| 7248 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 7249 | static int drv_cmd_set_channel_switch(struct hdd_adapter *adapter, |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 7250 | struct hdd_context *hdd_ctx, |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 7251 | uint8_t *command, |
| 7252 | uint8_t command_len, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 7253 | struct hdd_priv_data *priv_data) |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 7254 | { |
| 7255 | struct net_device *dev = adapter->dev; |
| 7256 | int status; |
| 7257 | uint32_t chan_number = 0, chan_bw = 0; |
| 7258 | uint8_t *value = command; |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 7259 | enum phy_ch_width width; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 7260 | |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 7261 | if ((adapter->device_mode != QDF_P2P_GO_MODE) && |
| 7262 | (adapter->device_mode != QDF_SAP_MODE)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 7263 | hdd_err("IOCTL CHANNEL_SWITCH not supported for mode %d", |
| 7264 | adapter->device_mode); |
| 7265 | return -EINVAL; |
| 7266 | } |
| 7267 | |
| 7268 | status = hdd_parse_set_channel_switch_command(value, |
| 7269 | &chan_number, &chan_bw); |
| 7270 | if (status) { |
| 7271 | hdd_err("Invalid CHANNEL_SWITCH command"); |
| 7272 | return status; |
| 7273 | } |
| 7274 | |
| 7275 | if ((chan_bw != 20) && (chan_bw != 40) && (chan_bw != 80)) { |
| 7276 | hdd_err("BW %d is not allowed for CHANNEL_SWITCH", chan_bw); |
| 7277 | return -EINVAL; |
| 7278 | } |
| 7279 | |
| 7280 | if (chan_bw == 80) |
| 7281 | width = CH_WIDTH_80MHZ; |
| 7282 | else if (chan_bw == 40) |
| 7283 | width = CH_WIDTH_40MHZ; |
| 7284 | else |
| 7285 | width = CH_WIDTH_20MHZ; |
| 7286 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 7287 | hdd_debug("CH:%d BW:%d", chan_number, chan_bw); |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 7288 | |
Bala Venkatesh | 8b9bbde | 2019-07-03 16:25:16 +0530 | [diff] [blame] | 7289 | wlan_hdd_set_sap_csa_reason(hdd_ctx->psoc, adapter->vdev_id, |
| 7290 | CSA_REASON_USER_INITIATED); |
Tushnim Bhattacharyya | 6c40b11 | 2019-10-30 11:39:25 -0700 | [diff] [blame] | 7291 | status = hdd_softap_set_channel_change(dev, |
| 7292 | wlan_reg_legacy_chan_to_freq(hdd_ctx->pdev, chan_number), |
| 7293 | width, true); |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 7294 | if (status) { |
| 7295 | hdd_err("Set channel change fail"); |
| 7296 | return status; |
| 7297 | } |
| 7298 | |
| 7299 | return 0; |
| 7300 | } |
| 7301 | |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7302 | #ifdef DISABLE_CHANNEL_LIST |
| 7303 | void wlan_hdd_free_cache_channels(struct hdd_context *hdd_ctx) |
| 7304 | { |
| 7305 | hdd_enter(); |
| 7306 | |
| 7307 | if (!hdd_ctx->original_channels) |
| 7308 | return; |
| 7309 | |
| 7310 | qdf_mutex_acquire(&hdd_ctx->cache_channel_lock); |
| 7311 | hdd_ctx->original_channels->num_channels = 0; |
| 7312 | if (hdd_ctx->original_channels->channel_info) { |
| 7313 | qdf_mem_free(hdd_ctx->original_channels->channel_info); |
| 7314 | hdd_ctx->original_channels->channel_info = NULL; |
| 7315 | } |
| 7316 | qdf_mem_free(hdd_ctx->original_channels); |
| 7317 | hdd_ctx->original_channels = NULL; |
| 7318 | qdf_mutex_release(&hdd_ctx->cache_channel_lock); |
| 7319 | |
| 7320 | hdd_exit(); |
| 7321 | } |
| 7322 | |
| 7323 | /** |
| 7324 | * hdd_alloc_chan_cache() - Allocate the memory to cache the channel |
| 7325 | * info for the channels received in command SET_DISABLE_CHANNEL_LIST |
| 7326 | * @hdd_ctx: Pointer to HDD context |
| 7327 | * @num_chan: Number of channels for which memory needs to |
| 7328 | * be allocated |
| 7329 | * |
| 7330 | * Return: 0 on success and error code on failure |
| 7331 | */ |
| 7332 | static int hdd_alloc_chan_cache(struct hdd_context *hdd_ctx, int num_chan) |
| 7333 | { |
| 7334 | hdd_ctx->original_channels = |
| 7335 | qdf_mem_malloc(sizeof(struct hdd_cache_channels)); |
| 7336 | if (!hdd_ctx->original_channels) { |
| 7337 | hdd_err("QDF_MALLOC_ERR"); |
| 7338 | return -ENOMEM; |
| 7339 | } |
| 7340 | hdd_ctx->original_channels->num_channels = num_chan; |
| 7341 | hdd_ctx->original_channels->channel_info = |
| 7342 | qdf_mem_malloc(num_chan * |
| 7343 | sizeof(struct hdd_cache_channel_info)); |
| 7344 | if (!hdd_ctx->original_channels->channel_info) { |
| 7345 | hdd_err("QDF_MALLOC_ERR"); |
| 7346 | hdd_ctx->original_channels->num_channels = 0; |
| 7347 | qdf_mem_free(hdd_ctx->original_channels); |
| 7348 | hdd_ctx->original_channels = NULL; |
| 7349 | return -ENOMEM; |
| 7350 | } |
| 7351 | return 0; |
| 7352 | } |
| 7353 | |
| 7354 | /** |
Ashish Kumar Dhanotiya | d63d686 | 2019-03-14 18:54:10 +0530 | [diff] [blame] | 7355 | * check_disable_channels() - Check for disable channel |
| 7356 | * @hdd_ctx: Pointer to hdd context |
| 7357 | * @operating_channel: Current operating channel of adapter |
| 7358 | * |
| 7359 | * This function checks original_channels array for a specific channel |
| 7360 | * |
| 7361 | * Return: 0 if channel not found, 1 if channel found |
| 7362 | */ |
| 7363 | static bool check_disable_channels(struct hdd_context *hdd_ctx, |
| 7364 | uint8_t operating_channel) |
| 7365 | { |
| 7366 | uint32_t num_channels; |
| 7367 | uint8_t i; |
| 7368 | |
| 7369 | if (!hdd_ctx || !hdd_ctx->original_channels || |
| 7370 | !hdd_ctx->original_channels->channel_info) |
| 7371 | return false; |
| 7372 | |
| 7373 | num_channels = hdd_ctx->original_channels->num_channels; |
| 7374 | for (i = 0; i < num_channels; i++) |
| 7375 | if (hdd_ctx->original_channels->channel_info[i].channel_num == |
| 7376 | operating_channel) |
| 7377 | return true; |
| 7378 | return false; |
| 7379 | } |
| 7380 | |
| 7381 | /** |
| 7382 | * disconnect_sta_and_stop_sap() - Disconnect STA and stop SAP |
| 7383 | * |
| 7384 | * @hdd_ctx: Pointer to hdd context |
Srinivas Dasari | e2495dc | 2020-02-13 09:49:24 +0530 | [diff] [blame] | 7385 | * @reason: Disconnect reason code as per @enum eSirMacReasonCodes |
Ashish Kumar Dhanotiya | d63d686 | 2019-03-14 18:54:10 +0530 | [diff] [blame] | 7386 | * |
| 7387 | * Disable channels provided by user and disconnect STA if it is |
| 7388 | * connected to any AP, stop SAP and send deauthentication request |
| 7389 | * to STAs connected to SAP. |
| 7390 | * |
| 7391 | * Return: None |
| 7392 | */ |
Srinivas Dasari | e2495dc | 2020-02-13 09:49:24 +0530 | [diff] [blame] | 7393 | static void disconnect_sta_and_stop_sap(struct hdd_context *hdd_ctx, |
| 7394 | enum eSirMacReasonCodes reason) |
Ashish Kumar Dhanotiya | d63d686 | 2019-03-14 18:54:10 +0530 | [diff] [blame] | 7395 | { |
| 7396 | struct hdd_adapter *adapter, *next = NULL; |
| 7397 | QDF_STATUS status; |
Will Huang | 4b097f5 | 2019-08-29 10:51:56 -0700 | [diff] [blame] | 7398 | uint8_t ap_ch; |
Ashish Kumar Dhanotiya | d63d686 | 2019-03-14 18:54:10 +0530 | [diff] [blame] | 7399 | |
| 7400 | if (!hdd_ctx) |
| 7401 | return; |
| 7402 | |
Srinivas Dasari | e2495dc | 2020-02-13 09:49:24 +0530 | [diff] [blame] | 7403 | hdd_check_and_disconnect_sta_on_invalid_channel(hdd_ctx, reason); |
Ashish Kumar Dhanotiya | d63d686 | 2019-03-14 18:54:10 +0530 | [diff] [blame] | 7404 | |
| 7405 | status = hdd_get_front_adapter(hdd_ctx, &adapter); |
| 7406 | while (adapter && (status == QDF_STATUS_SUCCESS)) { |
| 7407 | if (!hdd_validate_adapter(adapter) && |
Will Huang | 4b097f5 | 2019-08-29 10:51:56 -0700 | [diff] [blame] | 7408 | adapter->device_mode == QDF_SAP_MODE) { |
| 7409 | ap_ch = wlan_reg_freq_to_chan( |
| 7410 | hdd_ctx->pdev, |
| 7411 | adapter->session.ap.operating_chan_freq); |
| 7412 | if (check_disable_channels(hdd_ctx, ap_ch)) |
| 7413 | wlan_hdd_stop_sap(adapter); |
| 7414 | } |
Ashish Kumar Dhanotiya | d63d686 | 2019-03-14 18:54:10 +0530 | [diff] [blame] | 7415 | |
| 7416 | status = hdd_get_next_adapter(hdd_ctx, adapter, &next); |
| 7417 | adapter = next; |
| 7418 | } |
| 7419 | } |
| 7420 | |
| 7421 | /** |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7422 | * hdd_parse_disable_chan_cmd() - Parse the channel list received |
| 7423 | * in command. |
| 7424 | * @adapter: pointer to hdd adapter |
| 7425 | * @ptr: Pointer to the command string |
| 7426 | * |
| 7427 | * This function parses the channel list received in the command. |
| 7428 | * command should be a string having format |
| 7429 | * SET_DISABLE_CHANNEL_LIST <num of channels> |
| 7430 | * <channels separated by spaces>. |
| 7431 | * If the command comes multiple times than this function will compare |
| 7432 | * the channels received in the command with the channles cached in the |
| 7433 | * first command, if the channel list matches with the cached channles, |
| 7434 | * it returns success otherwise returns failure. |
| 7435 | * |
| 7436 | * Return: 0 on success, Error code on failure |
| 7437 | */ |
| 7438 | |
| 7439 | static int hdd_parse_disable_chan_cmd(struct hdd_adapter *adapter, uint8_t *ptr) |
| 7440 | { |
| 7441 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7442 | uint8_t *param; |
| 7443 | int j, i, temp_int, ret = 0, num_channels; |
Liangwei Dong | 2eb654f | 2019-09-11 15:54:09 +0800 | [diff] [blame] | 7444 | uint32_t parsed_channels[NUM_CHANNELS]; |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7445 | bool is_command_repeated = false; |
| 7446 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 7447 | if (!hdd_ctx) { |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7448 | hdd_err("HDD Context is NULL"); |
| 7449 | return -EINVAL; |
| 7450 | } |
| 7451 | |
| 7452 | param = strnchr(ptr, strlen(ptr), ' '); |
| 7453 | /*no argument after the command*/ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 7454 | if (!param) |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7455 | return -EINVAL; |
| 7456 | |
| 7457 | /*no space after the command*/ |
| 7458 | else if (SPACE_ASCII_VALUE != *param) |
| 7459 | return -EINVAL; |
| 7460 | |
| 7461 | param++; |
| 7462 | |
| 7463 | /*removing empty spaces*/ |
| 7464 | while ((SPACE_ASCII_VALUE == *param) && ('\0' != *param)) |
| 7465 | param++; |
| 7466 | |
| 7467 | /*no argument followed by spaces*/ |
| 7468 | if ('\0' == *param) |
| 7469 | return -EINVAL; |
| 7470 | |
| 7471 | /*getting the first argument ie the number of channels*/ |
| 7472 | if (sscanf(param, "%d ", &temp_int) != 1) { |
| 7473 | hdd_err("Cannot get number of channels from input"); |
| 7474 | return -EINVAL; |
| 7475 | } |
| 7476 | |
Liangwei Dong | 2eb654f | 2019-09-11 15:54:09 +0800 | [diff] [blame] | 7477 | if (temp_int < 0 || temp_int > NUM_CHANNELS) { |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7478 | hdd_err("Invalid Number of channel received"); |
| 7479 | return -EINVAL; |
| 7480 | } |
| 7481 | |
| 7482 | hdd_debug("Number of channel to disable are: %d", temp_int); |
| 7483 | |
| 7484 | if (!temp_int) { |
Ashish Kumar Dhanotiya | 6176bef | 2019-07-25 15:51:35 +0530 | [diff] [blame] | 7485 | /* |
| 7486 | * Restore and Free the cache channels when the command is |
| 7487 | * received with num channels as 0 |
| 7488 | */ |
| 7489 | wlan_hdd_restore_channels(hdd_ctx, false); |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7490 | return 0; |
| 7491 | } |
| 7492 | |
| 7493 | qdf_mutex_acquire(&hdd_ctx->cache_channel_lock); |
| 7494 | |
| 7495 | if (!hdd_ctx->original_channels) { |
| 7496 | if (hdd_alloc_chan_cache(hdd_ctx, temp_int)) { |
| 7497 | ret = -ENOMEM; |
| 7498 | goto mem_alloc_failed; |
| 7499 | } |
| 7500 | } else if (hdd_ctx->original_channels->num_channels != temp_int) { |
| 7501 | hdd_err("Invalid Number of channels"); |
| 7502 | ret = -EINVAL; |
| 7503 | is_command_repeated = true; |
| 7504 | goto parse_failed; |
| 7505 | } else { |
| 7506 | is_command_repeated = true; |
| 7507 | } |
| 7508 | num_channels = temp_int; |
| 7509 | for (j = 0; j < num_channels; j++) { |
| 7510 | /* |
| 7511 | * param pointing to the beginning of first space |
| 7512 | * after number of channels |
| 7513 | */ |
| 7514 | param = strpbrk(param, " "); |
| 7515 | /*no channel list after the number of channels argument*/ |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 7516 | if (!param) { |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7517 | hdd_err("Invalid No of channel provided in the list"); |
| 7518 | ret = -EINVAL; |
| 7519 | goto parse_failed; |
| 7520 | } |
| 7521 | |
| 7522 | param++; |
| 7523 | |
| 7524 | /*removing empty space*/ |
| 7525 | while ((SPACE_ASCII_VALUE == *param) && ('\0' != *param)) |
| 7526 | param++; |
| 7527 | |
| 7528 | if ('\0' == *param) { |
| 7529 | hdd_err("No channel is provided in the list"); |
| 7530 | ret = -EINVAL; |
| 7531 | goto parse_failed; |
| 7532 | } |
| 7533 | |
| 7534 | if (sscanf(param, "%d ", &temp_int) != 1) { |
| 7535 | hdd_err("Cannot read channel number"); |
| 7536 | ret = -EINVAL; |
| 7537 | goto parse_failed; |
| 7538 | } |
| 7539 | |
| 7540 | if (!IS_CHANNEL_VALID(temp_int)) { |
| 7541 | hdd_err("Invalid channel number received"); |
| 7542 | ret = -EINVAL; |
| 7543 | goto parse_failed; |
| 7544 | } |
| 7545 | |
| 7546 | hdd_debug("channel[%d] = %d", j, temp_int); |
| 7547 | parsed_channels[j] = temp_int; |
| 7548 | } |
| 7549 | |
| 7550 | /*extra arguments check*/ |
| 7551 | param = strpbrk(param, " "); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 7552 | if (param) { |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7553 | while ((SPACE_ASCII_VALUE == *param) && ('\0' != *param)) |
| 7554 | param++; |
| 7555 | |
| 7556 | if ('\0' != *param) { |
| 7557 | hdd_err("Invalid argument received"); |
| 7558 | ret = -EINVAL; |
| 7559 | goto parse_failed; |
| 7560 | } |
| 7561 | } |
| 7562 | |
| 7563 | /* |
| 7564 | * If command is received first time, cache the channels to |
| 7565 | * be disabled else compare the channels received in the |
| 7566 | * command with the cached channels, if channel list matches |
| 7567 | * return success otherewise return failure. |
| 7568 | */ |
| 7569 | if (!is_command_repeated) { |
| 7570 | for (j = 0; j < num_channels; j++) |
| 7571 | hdd_ctx->original_channels-> |
| 7572 | channel_info[j].channel_num = |
| 7573 | parsed_channels[j]; |
Dustin Brown | 3f0d710 | 2018-08-02 12:01:52 -0700 | [diff] [blame] | 7574 | |
| 7575 | /* Cache the channel list in regulatory also */ |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 7576 | ucfg_reg_cache_channel_state(hdd_ctx->pdev, parsed_channels, |
Dustin Brown | 3f0d710 | 2018-08-02 12:01:52 -0700 | [diff] [blame] | 7577 | num_channels); |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7578 | } else { |
| 7579 | for (i = 0; i < num_channels; i++) { |
| 7580 | for (j = 0; j < num_channels; j++) |
| 7581 | if (hdd_ctx->original_channels-> |
| 7582 | channel_info[i].channel_num == |
| 7583 | parsed_channels[j]) |
| 7584 | break; |
| 7585 | if (j == num_channels) { |
| 7586 | ret = -EINVAL; |
| 7587 | goto parse_failed; |
| 7588 | } |
| 7589 | } |
| 7590 | ret = 0; |
| 7591 | } |
| 7592 | mem_alloc_failed: |
| 7593 | |
| 7594 | qdf_mutex_release(&hdd_ctx->cache_channel_lock); |
Ashish Kumar Dhanotiya | dd5f74c | 2019-03-14 16:50:41 +0530 | [diff] [blame] | 7595 | /* Disable the channels received in command SET_DISABLE_CHANNEL_LIST */ |
| 7596 | if (!is_command_repeated && hdd_ctx->original_channels) { |
Ashish Kumar Dhanotiya | d63d686 | 2019-03-14 18:54:10 +0530 | [diff] [blame] | 7597 | ret = wlan_hdd_disable_channels(hdd_ctx); |
| 7598 | if (ret) |
| 7599 | return ret; |
Srinivas Dasari | e2495dc | 2020-02-13 09:49:24 +0530 | [diff] [blame] | 7600 | disconnect_sta_and_stop_sap(hdd_ctx, |
| 7601 | eSIR_MAC_OPER_CHANNEL_BAND_CHANGE); |
Ashish Kumar Dhanotiya | dd5f74c | 2019-03-14 16:50:41 +0530 | [diff] [blame] | 7602 | } |
| 7603 | |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7604 | hdd_exit(); |
| 7605 | |
| 7606 | return ret; |
| 7607 | |
| 7608 | parse_failed: |
| 7609 | if (!is_command_repeated) |
| 7610 | wlan_hdd_free_cache_channels(hdd_ctx); |
Ashish Kumar Dhanotiya | dd5f74c | 2019-03-14 16:50:41 +0530 | [diff] [blame] | 7611 | |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7612 | qdf_mutex_release(&hdd_ctx->cache_channel_lock); |
| 7613 | hdd_exit(); |
| 7614 | |
| 7615 | return ret; |
| 7616 | } |
| 7617 | |
| 7618 | static int drv_cmd_set_disable_chan_list(struct hdd_adapter *adapter, |
| 7619 | struct hdd_context *hdd_ctx, |
| 7620 | uint8_t *command, |
| 7621 | uint8_t command_len, |
| 7622 | struct hdd_priv_data *priv_data) |
| 7623 | { |
| 7624 | return hdd_parse_disable_chan_cmd(adapter, command); |
| 7625 | } |
Ashish Kumar Dhanotiya | 2853ba0 | 2018-03-15 15:51:25 +0530 | [diff] [blame] | 7626 | |
| 7627 | /** |
| 7628 | * hdd_get_disable_ch_list() - get disable channel list |
| 7629 | * @hdd_ctx: hdd context |
| 7630 | * @buf: buffer to hold disable channel list |
| 7631 | * @buf_len: buffer length |
| 7632 | * |
| 7633 | * Return: length of data copied to buf |
| 7634 | */ |
| 7635 | static int hdd_get_disable_ch_list(struct hdd_context *hdd_ctx, uint8_t *buf, |
| 7636 | uint32_t buf_len) |
| 7637 | { |
| 7638 | struct hdd_cache_channel_info *ch_list; |
| 7639 | unsigned char i, num_ch; |
| 7640 | int len = 0; |
| 7641 | |
| 7642 | qdf_mutex_acquire(&hdd_ctx->cache_channel_lock); |
| 7643 | if (hdd_ctx->original_channels && |
| 7644 | hdd_ctx->original_channels->num_channels && |
| 7645 | hdd_ctx->original_channels->channel_info) { |
| 7646 | num_ch = hdd_ctx->original_channels->num_channels; |
| 7647 | |
| 7648 | len = scnprintf(buf, buf_len, "%s %hhu", |
| 7649 | "GET_DISABLE_CHANNEL_LIST", num_ch); |
| 7650 | ch_list = hdd_ctx->original_channels->channel_info; |
| 7651 | for (i = 0; (i < num_ch) && (len < buf_len - 1); i++) { |
| 7652 | len += scnprintf(buf + len, buf_len - len, |
| 7653 | " %d", ch_list[i].channel_num); |
| 7654 | } |
| 7655 | } |
| 7656 | qdf_mutex_release(&hdd_ctx->cache_channel_lock); |
| 7657 | |
| 7658 | return len; |
| 7659 | } |
| 7660 | |
| 7661 | static int drv_cmd_get_disable_chan_list(struct hdd_adapter *adapter, |
| 7662 | struct hdd_context *hdd_ctx, |
| 7663 | uint8_t *command, |
| 7664 | uint8_t command_len, |
| 7665 | struct hdd_priv_data *priv_data) |
| 7666 | { |
| 7667 | char extra[512] = {0}; |
| 7668 | int max_len, copied_length; |
| 7669 | |
| 7670 | hdd_debug("Received Command to get disable Channels list"); |
| 7671 | |
| 7672 | max_len = QDF_MIN(priv_data->total_len, sizeof(extra)); |
| 7673 | copied_length = hdd_get_disable_ch_list(hdd_ctx, extra, max_len); |
| 7674 | if (copied_length == 0) { |
| 7675 | hdd_err("disable channel list is not yet programmed"); |
| 7676 | return -EINVAL; |
| 7677 | } |
| 7678 | |
| 7679 | if (copy_to_user(priv_data->buf, &extra, copied_length + 1)) { |
| 7680 | hdd_err("failed to copy data to user buffer"); |
| 7681 | return -EFAULT; |
| 7682 | } |
| 7683 | |
| 7684 | hdd_debug("data:%s", extra); |
| 7685 | return 0; |
| 7686 | } |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7687 | #else |
| 7688 | |
| 7689 | static int drv_cmd_set_disable_chan_list(struct hdd_adapter *adapter, |
| 7690 | struct hdd_context *hdd_ctx, |
| 7691 | uint8_t *command, |
| 7692 | uint8_t command_len, |
| 7693 | struct hdd_priv_data *priv_data) |
| 7694 | { |
| 7695 | return 0; |
| 7696 | } |
| 7697 | |
| 7698 | void wlan_hdd_free_cache_channels(struct hdd_context *hdd_ctx) |
| 7699 | { |
| 7700 | } |
Ashish Kumar Dhanotiya | 2853ba0 | 2018-03-15 15:51:25 +0530 | [diff] [blame] | 7701 | |
| 7702 | static int drv_cmd_get_disable_chan_list(struct hdd_adapter *adapter, |
| 7703 | struct hdd_context *hdd_ctx, |
| 7704 | uint8_t *command, |
| 7705 | uint8_t command_len, |
| 7706 | struct hdd_priv_data *priv_data) |
| 7707 | { |
| 7708 | return 0; |
| 7709 | } |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7710 | #endif |
Sourav Mohapatra | 2a67b0e | 2019-10-15 17:59:59 +0530 | [diff] [blame] | 7711 | |
| 7712 | #ifdef FEATURE_ANI_LEVEL_REQUEST |
| 7713 | static int drv_cmd_get_ani_level(struct hdd_adapter *adapter, |
| 7714 | struct hdd_context *hdd_ctx, |
| 7715 | uint8_t *command, |
| 7716 | uint8_t command_len, |
| 7717 | struct hdd_priv_data *priv_data) |
| 7718 | { |
| 7719 | char *extra; |
| 7720 | int copied_length = 0, j, temp_int, ret = 0; |
| 7721 | uint8_t *param, num_freqs, num_recv_channels; |
| 7722 | uint32_t parsed_freqs[MAX_NUM_FREQS_FOR_ANI_LEVEL]; |
| 7723 | struct wmi_host_ani_level_event ani[MAX_NUM_FREQS_FOR_ANI_LEVEL]; |
| 7724 | size_t user_size = priv_data->total_len; |
| 7725 | |
| 7726 | hdd_debug("Received Command to get ANI level"); |
| 7727 | |
| 7728 | param = strnchr(command, strlen(command), ' '); |
| 7729 | |
| 7730 | /* No argument after the command */ |
| 7731 | if (!param) |
| 7732 | return -EINVAL; |
| 7733 | |
| 7734 | /* No space after the command */ |
| 7735 | else if (SPACE_ASCII_VALUE != *param) |
| 7736 | return -EINVAL; |
| 7737 | |
| 7738 | param++; |
| 7739 | |
| 7740 | /* Removing empty spaces*/ |
| 7741 | while ((SPACE_ASCII_VALUE == *param) && ('\0' != *param)) |
| 7742 | param++; |
| 7743 | |
| 7744 | /*no argument followed by spaces */ |
| 7745 | if ('\0' == *param) |
| 7746 | return -EINVAL; |
| 7747 | |
| 7748 | /* Getting the first argument ie the number of channels */ |
| 7749 | if (sscanf(param, "%d ", &temp_int) != 1) { |
| 7750 | hdd_err("Cannot get number of freq from input"); |
| 7751 | return -EINVAL; |
| 7752 | } |
| 7753 | |
| 7754 | if (temp_int < 0 || temp_int > MAX_NUM_FREQS_FOR_ANI_LEVEL) { |
| 7755 | hdd_err("Invalid Number of channel received"); |
| 7756 | return -EINVAL; |
| 7757 | } |
| 7758 | |
| 7759 | hdd_debug("Number of freq to fetch ANI level are: %d", temp_int); |
| 7760 | |
| 7761 | if (!temp_int) |
| 7762 | return 0; |
| 7763 | |
| 7764 | num_freqs = temp_int; |
| 7765 | |
| 7766 | for (j = 0; j < num_freqs; j++) { |
| 7767 | /* |
| 7768 | * Param pointing to the beginning of first space |
| 7769 | * after number of channels. |
| 7770 | */ |
| 7771 | param = strpbrk(param, " "); |
| 7772 | /*no channel list after the number of channels argument*/ |
| 7773 | if (!param) { |
| 7774 | hdd_err("Invalid No of freq provided in the list"); |
| 7775 | ret = -EINVAL; |
| 7776 | goto parse_failed; |
| 7777 | } |
| 7778 | |
| 7779 | param++; |
| 7780 | |
| 7781 | /* Removing empty space */ |
| 7782 | while ((SPACE_ASCII_VALUE == *param) && ('\0' != *param)) |
| 7783 | param++; |
| 7784 | |
| 7785 | if ('\0' == *param) { |
| 7786 | hdd_err("No freq is provided in the list"); |
| 7787 | ret = -EINVAL; |
| 7788 | goto parse_failed; |
| 7789 | } |
| 7790 | |
| 7791 | if (sscanf(param, "%d ", &temp_int) != 1) { |
| 7792 | hdd_err("Cannot read freq number"); |
| 7793 | ret = -EINVAL; |
| 7794 | goto parse_failed; |
| 7795 | } |
| 7796 | |
| 7797 | hdd_debug("channel_freq[%d] = %d", j, temp_int); |
| 7798 | parsed_freqs[j] = temp_int; |
| 7799 | } |
| 7800 | |
| 7801 | /* Extra arguments check */ |
| 7802 | param = strpbrk(param, " "); |
| 7803 | if (param) { |
| 7804 | while ((SPACE_ASCII_VALUE == *param) && ('\0' != *param)) |
| 7805 | param++; |
| 7806 | |
| 7807 | if ('\0' != *param) { |
| 7808 | hdd_err("Invalid argument received"); |
| 7809 | ret = -EINVAL; |
| 7810 | goto parse_failed; |
| 7811 | } |
| 7812 | } |
| 7813 | |
| 7814 | qdf_mem_zero(ani, sizeof(ani)); |
| 7815 | hdd_debug("num_freq: %d", num_freqs); |
| 7816 | if (QDF_IS_STATUS_ERROR(wlan_hdd_get_ani_level(adapter, ani, |
| 7817 | parsed_freqs, |
| 7818 | num_freqs))) { |
| 7819 | hdd_err("Unable to retrieve ani level"); |
| 7820 | return -EINVAL; |
| 7821 | } |
| 7822 | |
| 7823 | extra = qdf_mem_malloc(user_size); |
| 7824 | if (!extra) { |
| 7825 | hdd_err("memory allocation failed"); |
| 7826 | ret = -ENOMEM; |
| 7827 | goto parse_failed; |
| 7828 | } |
| 7829 | |
| 7830 | /* |
| 7831 | * Find the number of channels that are populated. If freq is not |
| 7832 | * filled then stop count there |
| 7833 | */ |
| 7834 | for (num_recv_channels = 0; |
| 7835 | (num_recv_channels < num_freqs && |
| 7836 | ani[num_recv_channels].chan_freq); num_recv_channels++) |
| 7837 | ; |
| 7838 | |
| 7839 | for (j = 0; j < num_recv_channels; j++) { |
| 7840 | /* Sanity check for ANI level validity */ |
| 7841 | if (ani[j].ani_level > MAX_ANI_LEVEL) |
| 7842 | continue; |
| 7843 | |
| 7844 | copied_length += scnprintf(extra + copied_length, |
| 7845 | user_size - copied_length, "%d:%d\n", |
| 7846 | ani[j].chan_freq, ani[j].ani_level); |
| 7847 | } |
| 7848 | |
| 7849 | if (copied_length == 0) { |
| 7850 | hdd_err("ANI level not fetched"); |
| 7851 | ret = -EINVAL; |
| 7852 | goto free; |
| 7853 | } |
| 7854 | |
| 7855 | hdd_debug("data: %s", extra); |
| 7856 | |
| 7857 | if (copy_to_user(priv_data->buf, extra, copied_length + 1)) { |
| 7858 | hdd_err("failed to copy data to user buffer"); |
| 7859 | ret = -EFAULT; |
| 7860 | goto free; |
| 7861 | } |
| 7862 | |
| 7863 | free: |
| 7864 | qdf_mem_free(extra); |
| 7865 | |
| 7866 | parse_failed: |
| 7867 | return ret; |
| 7868 | } |
| 7869 | |
| 7870 | #else |
| 7871 | static int drv_cmd_get_ani_level(struct hdd_adapter *adapter, |
| 7872 | struct hdd_context *hdd_ctx, |
| 7873 | uint8_t *command, |
| 7874 | uint8_t command_len, |
| 7875 | struct hdd_priv_data *priv_data) |
| 7876 | { |
| 7877 | return 0; |
| 7878 | } |
| 7879 | #endif |
Ashish Kumar Dhanotiya | 7efe26e | 2018-11-14 16:35:57 +0530 | [diff] [blame^] | 7880 | |
| 7881 | #ifdef FUNC_CALL_MAP |
| 7882 | static int drv_cmd_get_function_call_map(struct hdd_adapter *adapter, |
| 7883 | struct hdd_context *hdd_ctx, |
| 7884 | uint8_t *command, |
| 7885 | uint8_t command_len, |
| 7886 | struct hdd_priv_data *priv_data) |
| 7887 | { |
| 7888 | char *cc_buf = qdf_mem_malloc(QDF_FUNCTION_CALL_MAP_BUF_LEN); |
| 7889 | uint8_t *param; |
| 7890 | int temp_int; |
| 7891 | |
| 7892 | param = strnchr(command, strlen(command), ' '); |
| 7893 | /*no argument after the command*/ |
| 7894 | if (NULL == param) |
| 7895 | return -EINVAL; |
| 7896 | |
| 7897 | /*no space after the command*/ |
| 7898 | else if (SPACE_ASCII_VALUE != *param) |
| 7899 | return -EINVAL; |
| 7900 | |
| 7901 | param++; |
| 7902 | |
| 7903 | /*removing empty spaces*/ |
| 7904 | while ((SPACE_ASCII_VALUE == *param) && ('\0' != *param)) |
| 7905 | param++; |
| 7906 | |
| 7907 | /*no argument followed by spaces*/ |
| 7908 | if ('\0' == *param) |
| 7909 | return -EINVAL; |
| 7910 | |
| 7911 | /*getting the first argument */ |
| 7912 | if (sscanf(param, "%d ", &temp_int) != 1) { |
| 7913 | hdd_err("No option given"); |
| 7914 | return -EINVAL; |
| 7915 | } |
| 7916 | |
| 7917 | if (temp_int < 0 || temp_int > 1) { |
| 7918 | hdd_err("Invalid option given"); |
| 7919 | return -EINVAL; |
| 7920 | } |
| 7921 | |
| 7922 | /* Read the buffer */ |
| 7923 | if (temp_int) { |
| 7924 | /* |
| 7925 | * These logs are required as these indicates the start and end of the |
| 7926 | * dump for the auto script to parse |
| 7927 | */ |
| 7928 | hdd_info("Function call map dump start"); |
| 7929 | qdf_get_func_call_map(cc_buf); |
| 7930 | qdf_trace_hex_dump(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_INFO, |
| 7931 | cc_buf, QDF_FUNCTION_CALL_MAP_BUF_LEN); |
| 7932 | hdd_info("Function call map dump end"); |
| 7933 | } else { |
| 7934 | qdf_clear_func_call_map(); |
| 7935 | hdd_info("Function call map clear"); |
| 7936 | } |
| 7937 | qdf_mem_free(cc_buf); |
| 7938 | |
| 7939 | return 0; |
| 7940 | } |
| 7941 | #endif |
| 7942 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7943 | /* |
| 7944 | * The following table contains all supported WLAN HDD |
| 7945 | * IOCTL driver commands and the handler for each of them. |
| 7946 | */ |
Srinivas Girigowda | 91a6b63 | 2017-03-25 13:57:14 -0700 | [diff] [blame] | 7947 | static const struct hdd_drv_cmd hdd_drv_cmds[] = { |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7948 | {"P2P_DEV_ADDR", drv_cmd_p2p_dev_addr, false}, |
| 7949 | {"P2P_SET_NOA", drv_cmd_p2p_set_noa, true}, |
| 7950 | {"P2P_SET_PS", drv_cmd_p2p_set_ps, true}, |
| 7951 | {"SETBAND", drv_cmd_set_band, true}, |
| 7952 | {"SETWMMPS", drv_cmd_set_wmmps, true}, |
| 7953 | {"COUNTRY", drv_cmd_country, true}, |
Rajeev Kumar Sirasanagandla | 32ae804 | 2019-03-25 16:37:02 +0530 | [diff] [blame] | 7954 | {"SETCOUNTRYREV", drv_cmd_country, true}, |
| 7955 | {"GETCOUNTRYREV", drv_cmd_get_country, false}, |
Pragaspathi Thilagaraj | aa8320e | 2019-04-16 02:47:50 +0530 | [diff] [blame] | 7956 | {"SETSUSPENDMODE", drv_cmd_set_suspend_mode, true}, |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7957 | {"SET_AP_WPS_P2P_IE", drv_cmd_dummy, false}, |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 7958 | {"SETROAMTRIGGER", drv_cmd_set_roam_trigger, true}, |
| 7959 | {"GETROAMTRIGGER", drv_cmd_get_roam_trigger, false}, |
| 7960 | {"SETROAMSCANPERIOD", drv_cmd_set_roam_scan_period, true}, |
| 7961 | {"GETROAMSCANPERIOD", drv_cmd_get_roam_scan_period, false}, |
| 7962 | {"SETROAMSCANREFRESHPERIOD", drv_cmd_set_roam_scan_refresh_period, |
| 7963 | true}, |
| 7964 | {"GETROAMSCANREFRESHPERIOD", drv_cmd_get_roam_scan_refresh_period, |
| 7965 | false}, |
| 7966 | {"SETROAMMODE", drv_cmd_set_roam_mode, true}, |
| 7967 | {"GETROAMMODE", drv_cmd_get_roam_mode, false}, |
| 7968 | {"SETROAMDELTA", drv_cmd_set_roam_delta, true}, |
| 7969 | {"GETROAMDELTA", drv_cmd_get_roam_delta, false}, |
| 7970 | {"GETBAND", drv_cmd_get_band, false}, |
| 7971 | {"SETROAMSCANCHANNELS", drv_cmd_set_roam_scan_channels, true}, |
| 7972 | {"GETROAMSCANCHANNELS", drv_cmd_get_roam_scan_channels, false}, |
| 7973 | {"GETCCXMODE", drv_cmd_get_ccx_mode, false}, |
| 7974 | {"GETOKCMODE", drv_cmd_get_okc_mode, false}, |
| 7975 | {"GETFASTROAM", drv_cmd_get_fast_roam, false}, |
| 7976 | {"GETFASTTRANSITION", drv_cmd_get_fast_transition, false}, |
| 7977 | {"SETROAMSCANCHANNELMINTIME", drv_cmd_set_roam_scan_channel_min_time, |
| 7978 | true}, |
| 7979 | {"SENDACTIONFRAME", drv_cmd_send_action_frame, true}, |
| 7980 | {"GETROAMSCANCHANNELMINTIME", drv_cmd_get_roam_scan_channel_min_time, |
| 7981 | false}, |
| 7982 | {"SETSCANCHANNELTIME", drv_cmd_set_scan_channel_time, true}, |
| 7983 | {"GETSCANCHANNELTIME", drv_cmd_get_scan_channel_time, false}, |
| 7984 | {"SETSCANHOMETIME", drv_cmd_set_scan_home_time, true}, |
| 7985 | {"GETSCANHOMETIME", drv_cmd_get_scan_home_time, false}, |
| 7986 | {"SETROAMINTRABAND", drv_cmd_set_roam_intra_band, true}, |
| 7987 | {"GETROAMINTRABAND", drv_cmd_get_roam_intra_band, false}, |
| 7988 | {"SETSCANNPROBES", drv_cmd_set_scan_n_probes, true}, |
| 7989 | {"GETSCANNPROBES", drv_cmd_get_scan_n_probes, false}, |
| 7990 | {"SETSCANHOMEAWAYTIME", drv_cmd_set_scan_home_away_time, true}, |
| 7991 | {"GETSCANHOMEAWAYTIME", drv_cmd_get_scan_home_away_time, false}, |
| 7992 | {"REASSOC", drv_cmd_reassoc, true}, |
| 7993 | {"SETWESMODE", drv_cmd_set_wes_mode, true}, |
| 7994 | {"GETWESMODE", drv_cmd_get_wes_mode, false}, |
| 7995 | {"SETOPPORTUNISTICRSSIDIFF", drv_cmd_set_opportunistic_rssi_diff, |
| 7996 | true}, |
| 7997 | {"GETOPPORTUNISTICRSSIDIFF", drv_cmd_get_opportunistic_rssi_diff, |
| 7998 | false}, |
| 7999 | {"SETROAMRESCANRSSIDIFF", drv_cmd_set_roam_rescan_rssi_diff, true}, |
| 8000 | {"GETROAMRESCANRSSIDIFF", drv_cmd_get_roam_rescan_rssi_diff, false}, |
| 8001 | {"SETFASTROAM", drv_cmd_set_fast_roam, true}, |
| 8002 | {"SETFASTTRANSITION", drv_cmd_set_fast_transition, true}, |
| 8003 | {"FASTREASSOC", drv_cmd_fast_reassoc, true}, |
| 8004 | {"SETROAMSCANCONTROL", drv_cmd_set_roam_scan_control, true}, |
| 8005 | {"SETOKCMODE", drv_cmd_set_okc_mode, true}, |
| 8006 | {"GETROAMSCANCONTROL", drv_cmd_get_roam_scan_control, false}, |
| 8007 | {"BTCOEXMODE", drv_cmd_bt_coex_mode, true}, |
| 8008 | {"SCAN-ACTIVE", drv_cmd_scan_active, false}, |
| 8009 | {"SCAN-PASSIVE", drv_cmd_scan_passive, false}, |
Dundi Raviteja | e1f0d3b | 2018-04-25 16:48:05 +0530 | [diff] [blame] | 8010 | {"CONCSETDWELLTIME", drv_cmd_conc_set_dwell_time, true}, |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 8011 | {"GETDWELLTIME", drv_cmd_get_dwell_time, false}, |
| 8012 | {"SETDWELLTIME", drv_cmd_set_dwell_time, true}, |
| 8013 | {"MIRACAST", drv_cmd_miracast, true}, |
| 8014 | {"SETIBSSBEACONOUIDATA", drv_cmd_set_ibss_beacon_oui_data, true}, |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 8015 | #ifdef FEATURE_WLAN_RMC |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 8016 | {"SETRMCENABLE", drv_cmd_set_rmc_enable, true}, |
| 8017 | {"SETRMCACTIONPERIOD", drv_cmd_set_rmc_action_period, true}, |
Rachit Kankane | ee1735c | 2018-08-02 13:19:34 +0530 | [diff] [blame] | 8018 | {"SETRMCTXRATE", drv_cmd_set_rmc_tx_rate, true}, |
| 8019 | #endif |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 8020 | {"GETIBSSPEERINFOALL", drv_cmd_get_ibss_peer_info_all, false}, |
| 8021 | {"GETIBSSPEERINFO", drv_cmd_get_ibss_peer_info, true}, |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 8022 | {"SETIBSSTXFAILEVENT", drv_cmd_set_ibss_tx_fail_event, true}, |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 8023 | #ifdef FEATURE_WLAN_ESE |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 8024 | {"SETCCXROAMSCANCHANNELS", drv_cmd_set_ccx_roam_scan_channels, true}, |
| 8025 | {"GETTSMSTATS", drv_cmd_get_tsm_stats, true}, |
| 8026 | {"SETCCKMIE", drv_cmd_set_cckm_ie, true}, |
| 8027 | {"CCXBEACONREQ", drv_cmd_ccx_beacon_req, true}, |
| 8028 | {"CCXPLMREQ", drv_cmd_ccx_plm_req, true}, |
| 8029 | {"SETCCXMODE", drv_cmd_set_ccx_mode, true}, |
Srinivas Girigowda | 515a9ef | 2015-12-11 11:00:48 -0800 | [diff] [blame] | 8030 | #endif /* FEATURE_WLAN_ESE */ |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 8031 | {"SETMCRATE", drv_cmd_set_mc_rate, true}, |
| 8032 | {"MAXTXPOWER", drv_cmd_max_tx_power, true}, |
| 8033 | {"SETDFSSCANMODE", drv_cmd_set_dfs_scan_mode, true}, |
| 8034 | {"GETDFSSCANMODE", drv_cmd_get_dfs_scan_mode, false}, |
| 8035 | {"GETLINKSTATUS", drv_cmd_get_link_status, false}, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8036 | #ifdef WLAN_FEATURE_EXTWOW_SUPPORT |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 8037 | {"ENABLEEXTWOW", drv_cmd_enable_ext_wow, true}, |
| 8038 | {"SETAPP1PARAMS", drv_cmd_set_app1_params, true}, |
| 8039 | {"SETAPP2PARAMS", drv_cmd_set_app2_params, true}, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8040 | #endif |
| 8041 | #ifdef FEATURE_WLAN_TDLS |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 8042 | {"TDLSSECONDARYCHANNELOFFSET", drv_cmd_tdls_secondary_channel_offset, |
| 8043 | true}, |
| 8044 | {"TDLSOFFCHANNELMODE", drv_cmd_tdls_off_channel_mode, true}, |
| 8045 | {"TDLSOFFCHANNEL", drv_cmd_tdls_off_channel, true}, |
| 8046 | {"TDLSSCAN", drv_cmd_tdls_scan, true}, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8047 | #endif |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 8048 | {"RSSI", drv_cmd_get_rssi, false}, |
| 8049 | {"LINKSPEED", drv_cmd_get_linkspeed, false}, |
Qiwei Cai | 4505fc6 | 2018-05-17 18:35:19 +0800 | [diff] [blame] | 8050 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 8051 | {"RXFILTER-REMOVE", drv_cmd_rx_filter_remove, true}, |
| 8052 | {"RXFILTER-ADD", drv_cmd_rx_filter_add, true}, |
Qiwei Cai | 4505fc6 | 2018-05-17 18:35:19 +0800 | [diff] [blame] | 8053 | #endif |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 8054 | {"SET_FCC_CHANNEL", drv_cmd_set_fcc_channel, true}, |
| 8055 | {"CHANNEL_SWITCH", drv_cmd_set_channel_switch, true}, |
| 8056 | {"SETANTENNAMODE", drv_cmd_set_antenna_mode, true}, |
| 8057 | {"GETANTENNAMODE", drv_cmd_get_antenna_mode, false}, |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 8058 | {"SET_DISABLE_CHANNEL_LIST", drv_cmd_set_disable_chan_list, true}, |
Ashish Kumar Dhanotiya | 2853ba0 | 2018-03-15 15:51:25 +0530 | [diff] [blame] | 8059 | {"GET_DISABLE_CHANNEL_LIST", drv_cmd_get_disable_chan_list, false}, |
Sourav Mohapatra | 2a67b0e | 2019-10-15 17:59:59 +0530 | [diff] [blame] | 8060 | {"GET_ANI_LEVEL", drv_cmd_get_ani_level, false}, |
Ashish Kumar Dhanotiya | 7efe26e | 2018-11-14 16:35:57 +0530 | [diff] [blame^] | 8061 | #ifdef FUNC_CALL_MAP |
| 8062 | {"GET_FUNCTION_CALL_MAP", drv_cmd_get_function_call_map, true}, |
| 8063 | #endif |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 8064 | {"STOP", drv_cmd_dummy, false}, |
Srinivas Girigowda | 836475e | 2018-04-17 14:42:23 -0700 | [diff] [blame] | 8065 | /* Deprecated commands */ |
| 8066 | {"RXFILTER-START", drv_cmd_dummy, false}, |
| 8067 | {"RXFILTER-STOP", drv_cmd_dummy, false}, |
| 8068 | {"BTCOEXSCAN-START", drv_cmd_dummy, false}, |
| 8069 | {"BTCOEXSCAN-STOP", drv_cmd_dummy, false}, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8070 | }; |
| 8071 | |
| 8072 | /** |
| 8073 | * hdd_drv_cmd_process() - chooses and runs the proper |
| 8074 | * handler based on the input command |
| 8075 | * @adapter: Pointer to the hdd adapter |
| 8076 | * @cmd: Pointer to the driver command |
| 8077 | * @priv_data: Pointer to the data associated with the command |
| 8078 | * |
| 8079 | * This function parses the input hdd driver command and runs |
| 8080 | * the proper handler |
| 8081 | * |
| 8082 | * Return: 0 for success non-zero for failure |
| 8083 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 8084 | static int hdd_drv_cmd_process(struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8085 | uint8_t *cmd, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 8086 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8087 | { |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 8088 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8089 | int i; |
| 8090 | const int cmd_num_total = ARRAY_SIZE(hdd_drv_cmds); |
| 8091 | uint8_t *cmd_i = NULL; |
| 8092 | hdd_drv_cmd_handler_t handler = NULL; |
Nachiket Kukade | b7e0497 | 2017-12-13 20:38:00 +0530 | [diff] [blame] | 8093 | int len = 0, cmd_len = 0; |
| 8094 | uint8_t *ptr; |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 8095 | bool args; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8096 | |
| 8097 | if (!adapter || !cmd || !priv_data) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 8098 | hdd_err("at least 1 param is NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8099 | return -EINVAL; |
| 8100 | } |
| 8101 | |
Nachiket Kukade | b7e0497 | 2017-12-13 20:38:00 +0530 | [diff] [blame] | 8102 | /* Calculate length of the first word */ |
| 8103 | ptr = strchrnul(cmd, ' '); |
| 8104 | cmd_len = ptr - cmd; |
| 8105 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 8106 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8107 | |
| 8108 | for (i = 0; i < cmd_num_total; i++) { |
| 8109 | |
| 8110 | cmd_i = (uint8_t *)hdd_drv_cmds[i].cmd; |
| 8111 | handler = hdd_drv_cmds[i].handler; |
| 8112 | len = strlen(cmd_i); |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 8113 | args = hdd_drv_cmds[i].args; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8114 | |
| 8115 | if (!handler) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 8116 | hdd_err("no. %d handler is NULL", i); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8117 | return -EINVAL; |
| 8118 | } |
| 8119 | |
Nachiket Kukade | b7e0497 | 2017-12-13 20:38:00 +0530 | [diff] [blame] | 8120 | if (len == cmd_len && strncasecmp(cmd, cmd_i, len) == 0) { |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 8121 | if (args && drv_cmd_validate(cmd, len)) |
| 8122 | return -EINVAL; |
| 8123 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8124 | return handler(adapter, hdd_ctx, |
| 8125 | cmd, len, priv_data); |
Rajeev Kumar Sirasanagandla | b50e3a5 | 2017-08-08 16:37:58 +0530 | [diff] [blame] | 8126 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8127 | } |
| 8128 | |
| 8129 | return drv_cmd_invalid(adapter, hdd_ctx, cmd, len, priv_data); |
| 8130 | } |
| 8131 | |
| 8132 | /** |
| 8133 | * hdd_driver_command() - top level wlan hdd driver command handler |
| 8134 | * @adapter: Pointer to the hdd adapter |
| 8135 | * @priv_data: Pointer to the raw command data |
| 8136 | * |
| 8137 | * This function is the top level wlan hdd driver command handler. It |
| 8138 | * handles the command with the help of hdd_drv_cmd_process() |
| 8139 | * |
| 8140 | * Return: 0 for success non-zero for failure |
| 8141 | */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 8142 | static int hdd_driver_command(struct hdd_adapter *adapter, |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 8143 | struct hdd_priv_data *priv_data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8144 | { |
| 8145 | uint8_t *command = NULL; |
| 8146 | int ret = 0; |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 8147 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8148 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8149 | hdd_enter(); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 8150 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8151 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 8152 | hdd_err("Command not allowed in FTM mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8153 | return -EINVAL; |
| 8154 | } |
| 8155 | |
Ashish Kumar Dhanotiya | ff4e1c4 | 2017-03-14 15:54:05 +0530 | [diff] [blame] | 8156 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 8157 | if (ret) |
| 8158 | return ret; |
| 8159 | |
| 8160 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 8161 | hdd_err("Driver module is closed; command can not be processed"); |
| 8162 | return -EINVAL; |
| 8163 | } |
| 8164 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8165 | /* |
| 8166 | * Note that valid pointers are provided by caller |
| 8167 | */ |
| 8168 | |
| 8169 | /* copy to local struct to avoid numerous changes to legacy code */ |
| 8170 | if (priv_data->total_len <= 0 || |
| 8171 | priv_data->total_len > WLAN_PRIV_DATA_MAX_LEN) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 8172 | hdd_warn("Invalid priv_data.total_len: %d!!!", |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 8173 | priv_data->total_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8174 | ret = -EINVAL; |
| 8175 | goto exit; |
| 8176 | } |
| 8177 | |
| 8178 | /* Allocate +1 for '\0' */ |
Mahesh Kumar Kalikot Veetil | 9c65618 | 2016-11-02 10:28:03 -0700 | [diff] [blame] | 8179 | command = qdf_mem_malloc(priv_data->total_len + 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8180 | if (!command) { |
Archana Ramachandran | 3abc391 | 2016-04-29 17:01:32 -0700 | [diff] [blame] | 8181 | hdd_err("failed to allocate memory"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8182 | ret = -ENOMEM; |
| 8183 | goto exit; |
| 8184 | } |
| 8185 | |
| 8186 | if (copy_from_user(command, priv_data->buf, priv_data->total_len)) { |
| 8187 | ret = -EFAULT; |
| 8188 | goto exit; |
| 8189 | } |
| 8190 | |
| 8191 | /* Make sure the command is NUL-terminated */ |
| 8192 | command[priv_data->total_len] = '\0'; |
| 8193 | |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 8194 | hdd_debug("%s: %s", adapter->dev->name, command); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8195 | ret = hdd_drv_cmd_process(adapter, command, priv_data); |
| 8196 | |
| 8197 | exit: |
| 8198 | if (command) |
Mahesh Kumar Kalikot Veetil | 9c65618 | 2016-11-02 10:28:03 -0700 | [diff] [blame] | 8199 | qdf_mem_free(command); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 8200 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8201 | return ret; |
| 8202 | } |
| 8203 | |
| 8204 | #ifdef CONFIG_COMPAT |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 8205 | 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] | 8206 | { |
| 8207 | struct { |
| 8208 | compat_uptr_t buf; |
| 8209 | int used_len; |
| 8210 | int total_len; |
| 8211 | } compat_priv_data; |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 8212 | struct hdd_priv_data priv_data; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8213 | int ret = 0; |
| 8214 | |
| 8215 | /* |
| 8216 | * Note that adapter and ifr have already been verified by caller, |
| 8217 | * and HDD context has also been validated |
| 8218 | */ |
| 8219 | if (copy_from_user(&compat_priv_data, ifr->ifr_data, |
| 8220 | sizeof(compat_priv_data))) { |
| 8221 | ret = -EFAULT; |
| 8222 | goto exit; |
| 8223 | } |
| 8224 | priv_data.buf = compat_ptr(compat_priv_data.buf); |
| 8225 | priv_data.used_len = compat_priv_data.used_len; |
| 8226 | priv_data.total_len = compat_priv_data.total_len; |
| 8227 | ret = hdd_driver_command(adapter, &priv_data); |
| 8228 | exit: |
| 8229 | return ret; |
| 8230 | } |
| 8231 | #else /* CONFIG_COMPAT */ |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 8232 | 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] | 8233 | { |
| 8234 | /* will never be invoked */ |
| 8235 | return 0; |
| 8236 | } |
| 8237 | #endif /* CONFIG_COMPAT */ |
| 8238 | |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 8239 | static int hdd_driver_ioctl(struct hdd_adapter *adapter, struct ifreq *ifr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8240 | { |
Jeff Johnson | 353cd29 | 2017-08-17 06:47:26 -0700 | [diff] [blame] | 8241 | struct hdd_priv_data priv_data; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8242 | int ret = 0; |
| 8243 | |
| 8244 | /* |
| 8245 | * Note that adapter and ifr have already been verified by caller, |
| 8246 | * and HDD context has also been validated |
| 8247 | */ |
| 8248 | if (copy_from_user(&priv_data, ifr->ifr_data, sizeof(priv_data))) |
| 8249 | ret = -EFAULT; |
| 8250 | else |
| 8251 | ret = hdd_driver_command(adapter, &priv_data); |
| 8252 | |
| 8253 | return ret; |
| 8254 | } |
| 8255 | |
| 8256 | /** |
| 8257 | * __hdd_ioctl() - ioctl handler for wlan network interfaces |
| 8258 | * @dev: device upon which the ioctl was received |
| 8259 | * @ifr: ioctl request information |
| 8260 | * @cmd: ioctl command |
| 8261 | * |
| 8262 | * This function does initial processing of wlan device ioctls. |
| 8263 | * Currently two flavors of ioctls are supported. The primary ioctl |
| 8264 | * that is supported is the (SIOCDEVPRIVATE + 1) ioctl which is used |
| 8265 | * for Android "DRIVER" commands. The other ioctl that is |
| 8266 | * conditionally supported is the SIOCIOCTLTX99 ioctl which is used |
| 8267 | * for FTM on some platforms. This function simply verifies that the |
| 8268 | * driver is in a sane state, and that the ioctl is one of the |
| 8269 | * supported flavors, in which case flavor-specific handlers are |
| 8270 | * dispatched. |
| 8271 | * |
| 8272 | * Return: 0 on success, non-zero on error |
| 8273 | */ |
| 8274 | static int __hdd_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) |
| 8275 | { |
Jeff Johnson | e44b701 | 2017-09-10 15:25:47 -0700 | [diff] [blame] | 8276 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 621cf97 | 2017-08-28 11:58:44 -0700 | [diff] [blame] | 8277 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8278 | int ret; |
| 8279 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 8280 | hdd_enter_dev(dev); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 8281 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8282 | if (dev != adapter->dev) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 8283 | hdd_err("HDD adapter/dev inconsistency"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8284 | ret = -ENODEV; |
| 8285 | goto exit; |
| 8286 | } |
| 8287 | |
| 8288 | if ((!ifr) || (!ifr->ifr_data)) { |
Srinivas Girigowda | dc99f84 | 2017-03-06 17:15:59 -0800 | [diff] [blame] | 8289 | hdd_err("invalid data cmd: %d", cmd); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8290 | ret = -EINVAL; |
| 8291 | goto exit; |
| 8292 | } |
| 8293 | #if defined(QCA_WIFI_FTM) && defined(LINUX_QCMBR) |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8294 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8295 | if (SIOCIOCTLTX99 == cmd) { |
| 8296 | ret = wlan_hdd_qcmbr_unified_ioctl(adapter, ifr); |
| 8297 | goto exit; |
| 8298 | } |
| 8299 | } |
| 8300 | #endif |
| 8301 | |
| 8302 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8303 | ret = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 8304 | if (ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8305 | goto exit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8306 | |
| 8307 | switch (cmd) { |
| 8308 | case (SIOCDEVPRIVATE + 1): |
Mahesh Kumar Kalikot Veetil | 885a77b | 2018-03-26 14:46:59 -0700 | [diff] [blame] | 8309 | if (in_compat_syscall()) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8310 | ret = hdd_driver_compat_ioctl(adapter, ifr); |
| 8311 | else |
| 8312 | ret = hdd_driver_ioctl(adapter, ifr); |
| 8313 | break; |
| 8314 | default: |
Srinivas Girigowda | 86ecc01 | 2017-03-10 12:26:57 -0800 | [diff] [blame] | 8315 | hdd_warn("unknown ioctl %d", cmd); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8316 | ret = -EINVAL; |
| 8317 | break; |
| 8318 | } |
| 8319 | exit: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 8320 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8321 | return ret; |
| 8322 | } |
| 8323 | |
| 8324 | /** |
| 8325 | * hdd_ioctl() - ioctl handler (wrapper) for wlan network interfaces |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 8326 | * @net_dev: device upon which the ioctl was received |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8327 | * @ifr: ioctl request information |
| 8328 | * @cmd: ioctl command |
| 8329 | * |
| 8330 | * This function acts as an SSR-protecting wrapper to __hdd_ioctl() |
| 8331 | * which is where the ioctls are really handled. |
| 8332 | * |
| 8333 | * Return: 0 on success, non-zero on error |
| 8334 | */ |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 8335 | 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] | 8336 | { |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 8337 | struct osif_vdev_sync *vdev_sync; |
| 8338 | int errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8339 | |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 8340 | errno = osif_vdev_sync_op_start(net_dev, &vdev_sync); |
| 8341 | if (errno) |
| 8342 | return errno; |
| 8343 | |
| 8344 | errno = __hdd_ioctl(net_dev, ifr, cmd); |
| 8345 | |
| 8346 | osif_vdev_sync_op_stop(vdev_sync); |
| 8347 | |
| 8348 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8349 | } |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 8350 | |