Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
jge | 6203786 | 2016-12-09 10:44:33 +0800 | [diff] [blame] | 2 | * Copyright (c) 2013-2017 The Linux Foundation. All rights reserved. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | |
| 22 | /* |
| 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
| 27 | |
| 28 | /** |
| 29 | * DOC: wlan_hdd_ipa.c |
| 30 | * |
| 31 | * WLAN HDD and ipa interface implementation |
| 32 | * Originally written by Qualcomm Atheros, Inc |
| 33 | */ |
| 34 | |
| 35 | #ifdef IPA_OFFLOAD |
| 36 | |
| 37 | /* Include Files */ |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 38 | #include <ipa.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 39 | #include <wlan_hdd_includes.h> |
| 40 | #include <wlan_hdd_ipa.h> |
| 41 | |
| 42 | #include <linux/etherdevice.h> |
| 43 | #include <linux/atomic.h> |
| 44 | #include <linux/netdevice.h> |
| 45 | #include <linux/skbuff.h> |
| 46 | #include <linux/list.h> |
| 47 | #include <linux/debugfs.h> |
| 48 | #include <linux/inetdevice.h> |
| 49 | #include <linux/ip.h> |
| 50 | #include <wlan_hdd_softap_tx_rx.h> |
Poddar, Siddarth | 8e3ee2d | 2016-11-29 20:17:01 +0530 | [diff] [blame] | 51 | #include <ol_txrx.h> |
Manjunathappa Prakash | 3454fd6 | 2016-04-01 08:52:06 -0700 | [diff] [blame] | 52 | #include <cdp_txrx_peer_ops.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 53 | |
| 54 | #include "cds_sched.h" |
| 55 | |
| 56 | #include "wma.h" |
| 57 | #include "wma_api.h" |
Prakash Dhavali | 87b38e3 | 2016-11-14 16:22:53 -0800 | [diff] [blame] | 58 | #include "wal_rx_desc.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 59 | |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 60 | #include "cdp_txrx_ipa.h" |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 61 | #include "wlan_policy_mgr_api.h" |
| 62 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 63 | #define HDD_IPA_RX_INACTIVITY_MSEC_DELAY 1000 |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 64 | #define HDD_IPA_UC_WLAN_8023_HDR_SIZE 14 |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 65 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 66 | #define HDD_IPA_UC_NUM_WDI_PIPE 2 |
| 67 | #define HDD_IPA_UC_MAX_PENDING_EVENT 33 |
| 68 | |
| 69 | #define HDD_IPA_UC_DEBUG_DUMMY_MEM_SIZE 32000 |
| 70 | #define HDD_IPA_UC_RT_DEBUG_PERIOD 300 |
| 71 | #define HDD_IPA_UC_RT_DEBUG_BUF_COUNT 30 |
| 72 | #define HDD_IPA_UC_RT_DEBUG_FILL_INTERVAL 10000 |
| 73 | |
| 74 | #define HDD_IPA_WLAN_HDR_DES_MAC_OFFSET 0 |
| 75 | #define HDD_IPA_MAX_IFACE 3 |
| 76 | #define HDD_IPA_MAX_SYSBAM_PIPE 4 |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 77 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 78 | #define HDD_IPA_RX_PIPE HDD_IPA_MAX_IFACE |
| 79 | #define HDD_IPA_ENABLE_MASK BIT(0) |
| 80 | #define HDD_IPA_PRE_FILTER_ENABLE_MASK BIT(1) |
| 81 | #define HDD_IPA_IPV6_ENABLE_MASK BIT(2) |
| 82 | #define HDD_IPA_RM_ENABLE_MASK BIT(3) |
| 83 | #define HDD_IPA_CLK_SCALING_ENABLE_MASK BIT(4) |
| 84 | #define HDD_IPA_UC_ENABLE_MASK BIT(5) |
| 85 | #define HDD_IPA_UC_STA_ENABLE_MASK BIT(6) |
| 86 | #define HDD_IPA_REAL_TIME_DEBUGGING BIT(8) |
| 87 | |
Yun Park | f19e07d | 2015-11-20 11:34:27 -0800 | [diff] [blame] | 88 | #define HDD_IPA_MAX_PENDING_EVENT_COUNT 20 |
| 89 | |
tfyu | 0380a97 | 2017-07-13 18:19:37 +0800 | [diff] [blame] | 90 | #define IPA_WLAN_RX_SOFTIRQ_THRESH 16 |
| 91 | |
Srinivas Girigowda | c16ba6d | 2017-03-25 11:43:26 -0700 | [diff] [blame] | 92 | enum hdd_ipa_uc_op_code { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 93 | HDD_IPA_UC_OPCODE_TX_SUSPEND = 0, |
| 94 | HDD_IPA_UC_OPCODE_TX_RESUME = 1, |
| 95 | HDD_IPA_UC_OPCODE_RX_SUSPEND = 2, |
| 96 | HDD_IPA_UC_OPCODE_RX_RESUME = 3, |
| 97 | HDD_IPA_UC_OPCODE_STATS = 4, |
Yun Park | 637d648 | 2016-10-05 10:51:33 -0700 | [diff] [blame] | 98 | #ifdef FEATURE_METERING |
| 99 | HDD_IPA_UC_OPCODE_SHARING_STATS = 5, |
| 100 | HDD_IPA_UC_OPCODE_QUOTA_RSP = 6, |
| 101 | HDD_IPA_UC_OPCODE_QUOTA_IND = 7, |
| 102 | #endif |
Manikandan Mohan | 153a4c3 | 2017-02-16 15:04:30 -0800 | [diff] [blame] | 103 | HDD_IPA_UC_OPCODE_UC_READY = 8, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 104 | /* keep this last */ |
| 105 | HDD_IPA_UC_OPCODE_MAX |
Srinivas Girigowda | c16ba6d | 2017-03-25 11:43:26 -0700 | [diff] [blame] | 106 | }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 107 | |
| 108 | /** |
| 109 | * enum - Reason codes for stat query |
| 110 | * |
| 111 | * @HDD_IPA_UC_STAT_REASON_NONE: Initial value |
| 112 | * @HDD_IPA_UC_STAT_REASON_DEBUG: For debug/info |
| 113 | * @HDD_IPA_UC_STAT_REASON_BW_CAL: For bandwidth calibration |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 114 | * @HDD_IPA_UC_STAT_REASON_DUMP_INFO: For debug info dump |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 115 | */ |
| 116 | enum { |
| 117 | HDD_IPA_UC_STAT_REASON_NONE, |
| 118 | HDD_IPA_UC_STAT_REASON_DEBUG, |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 119 | HDD_IPA_UC_STAT_REASON_BW_CAL, |
| 120 | HDD_IPA_UC_STAT_REASON_DUMP_INFO |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 121 | }; |
| 122 | |
| 123 | /** |
| 124 | * enum hdd_ipa_rm_state - IPA resource manager state |
| 125 | * @HDD_IPA_RM_RELEASED: PROD pipe resource released |
| 126 | * @HDD_IPA_RM_GRANT_PENDING: PROD pipe resource requested but not granted yet |
| 127 | * @HDD_IPA_RM_GRANTED: PROD pipe resource granted |
| 128 | */ |
| 129 | enum hdd_ipa_rm_state { |
| 130 | HDD_IPA_RM_RELEASED, |
| 131 | HDD_IPA_RM_GRANT_PENDING, |
| 132 | HDD_IPA_RM_GRANTED, |
| 133 | }; |
| 134 | |
| 135 | struct llc_snap_hdr { |
| 136 | uint8_t dsap; |
| 137 | uint8_t ssap; |
| 138 | uint8_t resv[4]; |
| 139 | __be16 eth_type; |
| 140 | } __packed; |
| 141 | |
Leo Chang | 3bc8fed | 2015-11-13 10:59:47 -0800 | [diff] [blame] | 142 | /** |
| 143 | * struct hdd_ipa_tx_hdr - header type which IPA should handle to TX packet |
| 144 | * @eth: ether II header |
| 145 | * @llc_snap: LLC snap header |
| 146 | * |
| 147 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 148 | struct hdd_ipa_tx_hdr { |
| 149 | struct ethhdr eth; |
| 150 | struct llc_snap_hdr llc_snap; |
| 151 | } __packed; |
| 152 | |
Leo Chang | 3bc8fed | 2015-11-13 10:59:47 -0800 | [diff] [blame] | 153 | /** |
| 154 | * struct frag_header - fragment header type registered to IPA hardware |
| 155 | * @length: fragment length |
| 156 | * @reserved1: Reserved not used |
| 157 | * @reserved2: Reserved not used |
| 158 | * |
| 159 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 160 | struct frag_header { |
Leo Chang | 3bc8fed | 2015-11-13 10:59:47 -0800 | [diff] [blame] | 161 | uint16_t length; |
| 162 | uint32_t reserved1; |
| 163 | uint32_t reserved2; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 164 | } __packed; |
| 165 | |
Leo Chang | 3bc8fed | 2015-11-13 10:59:47 -0800 | [diff] [blame] | 166 | /** |
| 167 | * struct ipa_header - ipa header type registered to IPA hardware |
| 168 | * @vdev_id: vdev id |
| 169 | * @reserved: Reserved not used |
| 170 | * |
| 171 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 172 | struct ipa_header { |
| 173 | uint32_t |
| 174 | vdev_id:8, /* vdev_id field is LSB of IPA DESC */ |
| 175 | reserved:24; |
| 176 | } __packed; |
| 177 | |
Leo Chang | 3bc8fed | 2015-11-13 10:59:47 -0800 | [diff] [blame] | 178 | /** |
| 179 | * struct hdd_ipa_uc_tx_hdr - full tx header registered to IPA hardware |
| 180 | * @frag_hd: fragment header |
| 181 | * @ipa_hd: ipa header |
| 182 | * @eth: ether II header |
| 183 | * |
| 184 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 185 | struct hdd_ipa_uc_tx_hdr { |
| 186 | struct frag_header frag_hd; |
| 187 | struct ipa_header ipa_hd; |
| 188 | struct ethhdr eth; |
| 189 | } __packed; |
| 190 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 191 | /** |
| 192 | * struct hdd_ipa_cld_hdr - IPA CLD Header |
| 193 | * @reserved: reserved fields |
| 194 | * @iface_id: interface ID |
| 195 | * @sta_id: Station ID |
| 196 | * |
| 197 | * Packed 32-bit structure |
| 198 | * +----------+----------+--------------+--------+ |
| 199 | * | Reserved | QCMAP ID | interface id | STA ID | |
| 200 | * +----------+----------+--------------+--------+ |
| 201 | */ |
| 202 | struct hdd_ipa_cld_hdr { |
| 203 | uint8_t reserved[2]; |
| 204 | uint8_t iface_id; |
| 205 | uint8_t sta_id; |
| 206 | } __packed; |
| 207 | |
| 208 | struct hdd_ipa_rx_hdr { |
| 209 | struct hdd_ipa_cld_hdr cld_hdr; |
| 210 | struct ethhdr eth; |
| 211 | } __packed; |
| 212 | |
| 213 | struct hdd_ipa_pm_tx_cb { |
Leo Chang | 69c3969 | 2016-10-12 20:11:12 -0700 | [diff] [blame] | 214 | bool exception; |
| 215 | hdd_adapter_t *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 216 | struct hdd_ipa_iface_context *iface_context; |
| 217 | struct ipa_rx_data *ipa_tx_desc; |
| 218 | }; |
| 219 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 220 | struct hdd_ipa_sys_pipe { |
| 221 | uint32_t conn_hdl; |
| 222 | uint8_t conn_hdl_valid; |
| 223 | struct ipa_sys_connect_params ipa_sys_params; |
| 224 | }; |
| 225 | |
| 226 | struct hdd_ipa_iface_stats { |
| 227 | uint64_t num_tx; |
| 228 | uint64_t num_tx_drop; |
| 229 | uint64_t num_tx_err; |
| 230 | uint64_t num_tx_cac_drop; |
| 231 | uint64_t num_rx_prefilter; |
| 232 | uint64_t num_rx_ipa_excep; |
| 233 | uint64_t num_rx_recv; |
| 234 | uint64_t num_rx_recv_mul; |
| 235 | uint64_t num_rx_send_desc_err; |
| 236 | uint64_t max_rx_mul; |
| 237 | }; |
| 238 | |
| 239 | struct hdd_ipa_priv; |
| 240 | |
| 241 | struct hdd_ipa_iface_context { |
| 242 | struct hdd_ipa_priv *hdd_ipa; |
| 243 | hdd_adapter_t *adapter; |
| 244 | void *tl_context; |
| 245 | |
| 246 | enum ipa_client_type cons_client; |
| 247 | enum ipa_client_type prod_client; |
| 248 | |
| 249 | uint8_t iface_id; /* This iface ID */ |
| 250 | uint8_t sta_id; /* This iface station ID */ |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 251 | qdf_spinlock_t interface_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 252 | uint32_t ifa_address; |
| 253 | struct hdd_ipa_iface_stats stats; |
| 254 | }; |
| 255 | |
| 256 | struct hdd_ipa_stats { |
| 257 | uint32_t event[IPA_WLAN_EVENT_MAX]; |
| 258 | uint64_t num_send_msg; |
| 259 | uint64_t num_free_msg; |
| 260 | |
| 261 | uint64_t num_rm_grant; |
| 262 | uint64_t num_rm_release; |
| 263 | uint64_t num_rm_grant_imm; |
| 264 | uint64_t num_cons_perf_req; |
| 265 | uint64_t num_prod_perf_req; |
| 266 | |
| 267 | uint64_t num_rx_drop; |
| 268 | uint64_t num_rx_ipa_tx_dp; |
| 269 | uint64_t num_rx_ipa_splice; |
| 270 | uint64_t num_rx_ipa_loop; |
| 271 | uint64_t num_rx_ipa_tx_dp_err; |
| 272 | uint64_t num_rx_ipa_write_done; |
| 273 | uint64_t num_max_ipa_tx_mul; |
| 274 | uint64_t num_rx_ipa_hw_maxed_out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 275 | |
Yun Park | 52b2b99 | 2016-09-22 15:49:51 -0700 | [diff] [blame] | 276 | uint64_t num_tx_desc_q_cnt; |
| 277 | uint64_t num_tx_desc_error; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 278 | uint64_t num_tx_comp_cnt; |
| 279 | uint64_t num_tx_queued; |
| 280 | uint64_t num_tx_dequeued; |
| 281 | uint64_t num_max_pm_queue; |
| 282 | |
| 283 | uint64_t num_freeq_empty; |
| 284 | uint64_t num_pri_freeq_empty; |
| 285 | uint64_t num_rx_excep; |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 286 | uint64_t num_tx_fwd_ok; |
| 287 | uint64_t num_tx_fwd_err; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 288 | }; |
| 289 | |
| 290 | struct ipa_uc_stas_map { |
| 291 | bool is_reserved; |
| 292 | uint8_t sta_id; |
| 293 | }; |
| 294 | struct op_msg_type { |
| 295 | uint8_t msg_t; |
| 296 | uint8_t rsvd; |
| 297 | uint16_t op_code; |
| 298 | uint16_t len; |
| 299 | uint16_t rsvd_snd; |
| 300 | }; |
| 301 | |
| 302 | struct ipa_uc_fw_stats { |
| 303 | uint32_t tx_comp_ring_base; |
| 304 | uint32_t tx_comp_ring_size; |
| 305 | uint32_t tx_comp_ring_dbell_addr; |
| 306 | uint32_t tx_comp_ring_dbell_ind_val; |
| 307 | uint32_t tx_comp_ring_dbell_cached_val; |
| 308 | uint32_t tx_pkts_enqueued; |
| 309 | uint32_t tx_pkts_completed; |
| 310 | uint32_t tx_is_suspend; |
| 311 | uint32_t tx_reserved; |
| 312 | uint32_t rx_ind_ring_base; |
| 313 | uint32_t rx_ind_ring_size; |
| 314 | uint32_t rx_ind_ring_dbell_addr; |
| 315 | uint32_t rx_ind_ring_dbell_ind_val; |
| 316 | uint32_t rx_ind_ring_dbell_ind_cached_val; |
| 317 | uint32_t rx_ind_ring_rdidx_addr; |
| 318 | uint32_t rx_ind_ring_rd_idx_cached_val; |
| 319 | uint32_t rx_refill_idx; |
| 320 | uint32_t rx_num_pkts_indicated; |
| 321 | uint32_t rx_buf_refilled; |
| 322 | uint32_t rx_num_ind_drop_no_space; |
| 323 | uint32_t rx_num_ind_drop_no_buf; |
| 324 | uint32_t rx_is_suspend; |
| 325 | uint32_t rx_reserved; |
| 326 | }; |
| 327 | |
| 328 | struct ipa_uc_pending_event { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 329 | qdf_list_node_t node; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 330 | hdd_adapter_t *adapter; |
| 331 | enum ipa_wlan_event type; |
| 332 | uint8_t sta_id; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 333 | uint8_t mac_addr[QDF_MAC_ADDR_SIZE]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 334 | }; |
| 335 | |
| 336 | /** |
| 337 | * struct uc_rm_work_struct |
| 338 | * @work: uC RM work |
| 339 | * @event: IPA RM event |
| 340 | */ |
| 341 | struct uc_rm_work_struct { |
| 342 | struct work_struct work; |
| 343 | enum ipa_rm_event event; |
| 344 | }; |
| 345 | |
| 346 | /** |
| 347 | * struct uc_op_work_struct |
| 348 | * @work: uC OP work |
| 349 | * @msg: OP message |
| 350 | */ |
| 351 | struct uc_op_work_struct { |
| 352 | struct work_struct work; |
| 353 | struct op_msg_type *msg; |
| 354 | }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 355 | |
| 356 | /** |
| 357 | * struct uc_rt_debug_info |
| 358 | * @time: system time |
| 359 | * @ipa_excep_count: IPA exception packet count |
| 360 | * @rx_drop_count: IPA Rx drop packet count |
| 361 | * @net_sent_count: IPA Rx packet sent to network stack count |
| 362 | * @rx_discard_count: IPA Rx discard packet count |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 363 | * @tx_fwd_ok_count: IPA Tx forward success packet count |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 364 | * @tx_fwd_count: IPA Tx forward packet count |
| 365 | * @rx_destructor_call: IPA Rx packet destructor count |
| 366 | */ |
| 367 | struct uc_rt_debug_info { |
Deepthi Gowri | 6acee34 | 2016-10-28 15:00:38 +0530 | [diff] [blame] | 368 | uint64_t time; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 369 | uint64_t ipa_excep_count; |
| 370 | uint64_t rx_drop_count; |
| 371 | uint64_t net_sent_count; |
| 372 | uint64_t rx_discard_count; |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 373 | uint64_t tx_fwd_ok_count; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 374 | uint64_t tx_fwd_count; |
| 375 | uint64_t rx_destructor_call; |
| 376 | }; |
| 377 | |
Yun Park | 637d648 | 2016-10-05 10:51:33 -0700 | [diff] [blame] | 378 | #ifdef FEATURE_METERING |
| 379 | struct ipa_uc_sharing_stats { |
| 380 | uint64_t ipv4_rx_packets; |
| 381 | uint64_t ipv4_rx_bytes; |
| 382 | uint64_t ipv6_rx_packets; |
| 383 | uint64_t ipv6_rx_bytes; |
| 384 | uint64_t ipv4_tx_packets; |
| 385 | uint64_t ipv4_tx_bytes; |
| 386 | uint64_t ipv6_tx_packets; |
| 387 | uint64_t ipv6_tx_bytes; |
| 388 | }; |
| 389 | |
| 390 | struct ipa_uc_quota_rsp { |
| 391 | uint8_t success; |
| 392 | uint8_t reserved[3]; |
| 393 | uint32_t quota_lo; /* quota limit low bytes */ |
| 394 | uint32_t quota_hi; /* quota limit high bytes */ |
| 395 | }; |
| 396 | |
| 397 | struct ipa_uc_quota_ind { |
| 398 | uint64_t quota_bytes; /* quota limit in bytes */ |
| 399 | }; |
| 400 | #endif |
| 401 | |
Yun Park | 52b2b99 | 2016-09-22 15:49:51 -0700 | [diff] [blame] | 402 | /** |
| 403 | * struct hdd_ipa_tx_desc |
| 404 | * @link: link to list head |
| 405 | * @priv: pointer to priv list entry |
| 406 | * @id: Tx desc idex |
| 407 | * @ipa_tx_desc_ptr: pointer to IPA Tx descriptor |
| 408 | */ |
| 409 | struct hdd_ipa_tx_desc { |
| 410 | struct list_head link; |
| 411 | void *priv; |
| 412 | uint32_t id; |
| 413 | struct ipa_rx_data *ipa_tx_desc_ptr; |
| 414 | }; |
| 415 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 416 | struct hdd_ipa_priv { |
| 417 | struct hdd_ipa_sys_pipe sys_pipe[HDD_IPA_MAX_SYSBAM_PIPE]; |
| 418 | struct hdd_ipa_iface_context iface_context[HDD_IPA_MAX_IFACE]; |
| 419 | uint8_t num_iface; |
| 420 | enum hdd_ipa_rm_state rm_state; |
| 421 | /* |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 422 | * IPA driver can send RM notifications with IRQ disabled so using qdf |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 423 | * APIs as it is taken care gracefully. Without this, kernel would throw |
| 424 | * an warning if spin_lock_bh is used while IRQ is disabled |
| 425 | */ |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 426 | qdf_spinlock_t rm_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 427 | struct uc_rm_work_struct uc_rm_work; |
| 428 | struct uc_op_work_struct uc_op_work[HDD_IPA_UC_OPCODE_MAX]; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 429 | qdf_wake_lock_t wake_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 430 | struct delayed_work wake_lock_work; |
| 431 | bool wake_lock_released; |
| 432 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 433 | atomic_t tx_ref_cnt; |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 434 | qdf_nbuf_queue_t pm_queue_head; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 435 | struct work_struct pm_work; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 436 | qdf_spinlock_t pm_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 437 | bool suspended; |
| 438 | |
Yun Park | 52b2b99 | 2016-09-22 15:49:51 -0700 | [diff] [blame] | 439 | qdf_spinlock_t q_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 440 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 441 | struct list_head pend_desc_head; |
Yun Park | 52b2b99 | 2016-09-22 15:49:51 -0700 | [diff] [blame] | 442 | struct hdd_ipa_tx_desc *tx_desc_list; |
| 443 | struct list_head free_tx_desc_head; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 444 | |
| 445 | hdd_context_t *hdd_ctx; |
| 446 | |
| 447 | struct dentry *debugfs_dir; |
| 448 | struct hdd_ipa_stats stats; |
| 449 | |
| 450 | struct notifier_block ipv4_notifier; |
| 451 | uint32_t curr_prod_bw; |
| 452 | uint32_t curr_cons_bw; |
| 453 | |
| 454 | uint8_t activated_fw_pipe; |
| 455 | uint8_t sap_num_connected_sta; |
| 456 | uint8_t sta_connected; |
| 457 | uint32_t tx_pipe_handle; |
| 458 | uint32_t rx_pipe_handle; |
| 459 | bool resource_loading; |
| 460 | bool resource_unloading; |
| 461 | bool pending_cons_req; |
| 462 | struct ipa_uc_stas_map assoc_stas_map[WLAN_MAX_STA_COUNT]; |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 463 | qdf_list_t pending_event; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 464 | qdf_mutex_t event_lock; |
Leo Chang | e3e4944 | 2015-10-26 20:07:13 -0700 | [diff] [blame] | 465 | bool ipa_pipes_down; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 466 | uint32_t ipa_tx_packets_diff; |
| 467 | uint32_t ipa_rx_packets_diff; |
| 468 | uint32_t ipa_p_tx_packets; |
| 469 | uint32_t ipa_p_rx_packets; |
| 470 | uint32_t stat_req_reason; |
| 471 | uint64_t ipa_tx_forward; |
| 472 | uint64_t ipa_rx_discard; |
| 473 | uint64_t ipa_rx_net_send_count; |
| 474 | uint64_t ipa_rx_internel_drop_count; |
| 475 | uint64_t ipa_rx_destructor_count; |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 476 | qdf_mc_timer_t rt_debug_timer; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 477 | struct uc_rt_debug_info rt_bug_buffer[HDD_IPA_UC_RT_DEBUG_BUF_COUNT]; |
| 478 | unsigned int rt_buf_fill_index; |
Manikandan Mohan | 153a4c3 | 2017-02-16 15:04:30 -0800 | [diff] [blame] | 479 | struct ipa_wdi_in_params cons_pipe_in; |
| 480 | struct ipa_wdi_in_params prod_pipe_in; |
| 481 | bool uc_loaded; |
Manikandan Mohan | cd64c0b | 2017-03-08 13:00:24 -0800 | [diff] [blame] | 482 | bool wdi_enabled; |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 483 | qdf_mc_timer_t rt_debug_fill_timer; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 484 | qdf_mutex_t rt_debug_lock; |
| 485 | qdf_mutex_t ipa_lock; |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 486 | |
Prakash Dhavali | 89d406d | 2016-11-23 11:11:00 -0800 | [diff] [blame] | 487 | uint8_t vdev_to_iface[CSR_ROAM_SESSION_MAX]; |
| 488 | bool vdev_offload_enabled[CSR_ROAM_SESSION_MAX]; |
Yun Park | 637d648 | 2016-10-05 10:51:33 -0700 | [diff] [blame] | 489 | #ifdef FEATURE_METERING |
| 490 | struct ipa_uc_sharing_stats ipa_sharing_stats; |
| 491 | struct ipa_uc_quota_rsp ipa_quota_rsp; |
| 492 | struct ipa_uc_quota_ind ipa_quota_ind; |
| 493 | struct completion ipa_uc_sharing_stats_comp; |
| 494 | struct completion ipa_uc_set_quota_comp; |
| 495 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 496 | }; |
| 497 | |
Leo Chang | cc923e2 | 2016-06-16 15:29:03 -0700 | [diff] [blame] | 498 | #define HDD_IPA_WLAN_FRAG_HEADER sizeof(struct frag_header) |
| 499 | #define HDD_IPA_WLAN_IPA_HEADER sizeof(struct ipa_header) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 500 | #define HDD_IPA_WLAN_CLD_HDR_LEN sizeof(struct hdd_ipa_cld_hdr) |
| 501 | #define HDD_IPA_UC_WLAN_CLD_HDR_LEN 0 |
| 502 | #define HDD_IPA_WLAN_TX_HDR_LEN sizeof(struct hdd_ipa_tx_hdr) |
| 503 | #define HDD_IPA_UC_WLAN_TX_HDR_LEN sizeof(struct hdd_ipa_uc_tx_hdr) |
| 504 | #define HDD_IPA_WLAN_RX_HDR_LEN sizeof(struct hdd_ipa_rx_hdr) |
Leo Chang | cc923e2 | 2016-06-16 15:29:03 -0700 | [diff] [blame] | 505 | #define HDD_IPA_UC_WLAN_HDR_DES_MAC_OFFSET \ |
| 506 | (HDD_IPA_WLAN_FRAG_HEADER + HDD_IPA_WLAN_IPA_HEADER) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 507 | |
| 508 | #define HDD_IPA_GET_IFACE_ID(_data) \ |
| 509 | (((struct hdd_ipa_cld_hdr *) (_data))->iface_id) |
| 510 | |
| 511 | #define HDD_IPA_LOG(LVL, fmt, args ...) \ |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 512 | QDF_TRACE(QDF_MODULE_ID_HDD, LVL, \ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 513 | "%s:%d: "fmt, __func__, __LINE__, ## args) |
| 514 | |
Govind Singh | b6a8977 | 2016-08-12 11:23:35 +0530 | [diff] [blame] | 515 | #define HDD_IPA_DP_LOG(LVL, fmt, args...) \ |
| 516 | QDF_TRACE(QDF_MODULE_ID_HDD_DATA, LVL, \ |
| 517 | "%s:%d: "fmt, __func__, __LINE__, ## args) |
| 518 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 519 | #define HDD_IPA_DBG_DUMP(_lvl, _prefix, _buf, _len) \ |
| 520 | do { \ |
Yun Park | ec84530 | 2016-12-15 09:22:57 -0800 | [diff] [blame] | 521 | QDF_TRACE(QDF_MODULE_ID_HDD_DATA, _lvl, "%s:", _prefix); \ |
| 522 | QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD_DATA, _lvl, _buf, _len); \ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 523 | } while (0) |
| 524 | |
| 525 | #define HDD_IPA_IS_CONFIG_ENABLED(_hdd_ctx, _mask) \ |
| 526 | (((_hdd_ctx)->config->IpaConfig & (_mask)) == (_mask)) |
| 527 | |
| 528 | #define HDD_IPA_INCREASE_INTERNAL_DROP_COUNT(hdd_ipa) \ |
| 529 | do { \ |
| 530 | hdd_ipa->ipa_rx_internel_drop_count++; \ |
| 531 | } while (0) |
| 532 | #define HDD_IPA_INCREASE_NET_SEND_COUNT(hdd_ipa) \ |
| 533 | do { \ |
| 534 | hdd_ipa->ipa_rx_net_send_count++; \ |
| 535 | } while (0) |
| 536 | #define HDD_BW_GET_DIFF(_x, _y) (unsigned long)((ULONG_MAX - (_y)) + (_x) + 1) |
| 537 | |
Srinivas Girigowda | c16ba6d | 2017-03-25 11:43:26 -0700 | [diff] [blame] | 538 | #if defined(QCA_WIFI_3_0) && defined(CONFIG_IPA3) |
Leo Chang | 63d7361 | 2016-10-18 18:09:43 -0700 | [diff] [blame] | 539 | #define HDD_IPA_CHECK_HW() ipa_uc_reg_rdyCB(NULL) |
Leo Chang | 3bc8fed | 2015-11-13 10:59:47 -0800 | [diff] [blame] | 540 | #else |
| 541 | /* Do nothing */ |
Leo Chang | 63d7361 | 2016-10-18 18:09:43 -0700 | [diff] [blame] | 542 | #define HDD_IPA_CHECK_HW() 0 |
Leo Chang | 07b28f6 | 2016-05-11 12:29:22 -0700 | [diff] [blame] | 543 | #endif /* IPA3 */ |
Leo Chang | 3bc8fed | 2015-11-13 10:59:47 -0800 | [diff] [blame] | 544 | |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 545 | #define HDD_IPA_DBG_DUMP_RX_LEN 32 |
| 546 | #define HDD_IPA_DBG_DUMP_TX_LEN 48 |
| 547 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 548 | static struct hdd_ipa_adapter_2_client { |
| 549 | enum ipa_client_type cons_client; |
| 550 | enum ipa_client_type prod_client; |
| 551 | } hdd_ipa_adapter_2_client[HDD_IPA_MAX_IFACE] = { |
| 552 | { |
| 553 | IPA_CLIENT_WLAN2_CONS, IPA_CLIENT_WLAN1_PROD |
| 554 | }, { |
| 555 | IPA_CLIENT_WLAN3_CONS, IPA_CLIENT_WLAN1_PROD |
| 556 | }, { |
| 557 | IPA_CLIENT_WLAN4_CONS, IPA_CLIENT_WLAN1_PROD |
| 558 | }, |
| 559 | }; |
| 560 | |
Yun Park | 637d648 | 2016-10-05 10:51:33 -0700 | [diff] [blame] | 561 | #ifdef FEATURE_METERING |
| 562 | #define IPA_UC_SHARING_STATES_WAIT_TIME 500 |
| 563 | #define IPA_UC_SET_QUOTA_WAIT_TIME 500 |
| 564 | #endif |
| 565 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 566 | static struct hdd_ipa_priv *ghdd_ipa; |
| 567 | |
| 568 | /* Local Function Prototypes */ |
| 569 | static void hdd_ipa_i2w_cb(void *priv, enum ipa_dp_evt_type evt, |
| 570 | unsigned long data); |
| 571 | static void hdd_ipa_w2i_cb(void *priv, enum ipa_dp_evt_type evt, |
| 572 | unsigned long data); |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 573 | #ifdef FEATURE_METERING |
| 574 | static void hdd_ipa_wdi_meter_notifier_cb(enum ipa_wdi_meter_evt_type evt, |
| 575 | void *data); |
| 576 | #else |
| 577 | static void hdd_ipa_wdi_meter_notifier_cb(void); |
| 578 | #endif |
Manikandan Mohan | 153a4c3 | 2017-02-16 15:04:30 -0800 | [diff] [blame] | 579 | static void hdd_ipa_msg_free_fn(void *buff, uint32_t len, uint32_t type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 580 | |
| 581 | static void hdd_ipa_cleanup_iface(struct hdd_ipa_iface_context *iface_context); |
Srinivas Girigowda | c16ba6d | 2017-03-25 11:43:26 -0700 | [diff] [blame] | 582 | static void hdd_ipa_uc_proc_pending_event(struct hdd_ipa_priv *hdd_ipa); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 583 | |
Manikandan Mohan | 153a4c3 | 2017-02-16 15:04:30 -0800 | [diff] [blame] | 584 | #if ((defined(QCA_WIFI_3_0) && defined(CONFIG_IPA3)) || \ |
| 585 | defined(IPA_CLIENT_IS_MHI_CONS)) |
| 586 | /** |
Manikandan Mohan | 153a4c3 | 2017-02-16 15:04:30 -0800 | [diff] [blame] | 587 | * hdd_ipa_uc_loaded_uc_cb() - IPA UC loaded event callback |
| 588 | * @priv_ctxt: hdd ipa local context |
| 589 | * |
| 590 | * Will be called by IPA context. |
| 591 | * It's atomic context, then should be scheduled to kworker thread |
| 592 | * |
| 593 | * Return: None |
| 594 | */ |
| 595 | static void hdd_ipa_uc_loaded_uc_cb(void *priv_ctxt) |
| 596 | { |
| 597 | struct hdd_ipa_priv *hdd_ipa; |
| 598 | struct op_msg_type *msg; |
| 599 | struct uc_op_work_struct *uc_op_work; |
| 600 | |
| 601 | if (priv_ctxt == NULL) { |
| 602 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, "Invalid IPA context"); |
| 603 | return; |
| 604 | } |
| 605 | |
| 606 | hdd_ipa = (struct hdd_ipa_priv *)priv_ctxt; |
| 607 | msg = (struct op_msg_type *)qdf_mem_malloc(sizeof(*msg)); |
| 608 | if (!msg) { |
| 609 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, "op_msg allocation fails"); |
| 610 | return; |
| 611 | } |
| 612 | |
| 613 | msg->op_code = HDD_IPA_UC_OPCODE_UC_READY; |
| 614 | |
| 615 | uc_op_work = &hdd_ipa->uc_op_work[msg->op_code]; |
| 616 | |
| 617 | /* When the same uC OPCODE is already pended, just return */ |
| 618 | if (uc_op_work->msg) |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 619 | goto done; |
Manikandan Mohan | 153a4c3 | 2017-02-16 15:04:30 -0800 | [diff] [blame] | 620 | |
| 621 | uc_op_work->msg = msg; |
| 622 | schedule_work(&uc_op_work->work); |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 623 | |
jiad | d91a684 | 2017-08-01 14:46:02 +0800 | [diff] [blame] | 624 | /* work handler will free the msg buffer */ |
| 625 | return; |
| 626 | |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 627 | done: |
| 628 | qdf_mem_free(msg); |
Manikandan Mohan | 153a4c3 | 2017-02-16 15:04:30 -0800 | [diff] [blame] | 629 | } |
| 630 | |
| 631 | /** |
Manikandan Mohan | 153a4c3 | 2017-02-16 15:04:30 -0800 | [diff] [blame] | 632 | * hdd_ipa_uc_send_wdi_control_msg() - Set WDI control message |
| 633 | * @ctrl: WDI control value |
| 634 | * |
| 635 | * Send WLAN_WDI_ENABLE for ctrl = true and WLAN_WDI_DISABLE otherwise. |
| 636 | * |
| 637 | * Return: 0 on message send to ipa, -1 on failure |
| 638 | */ |
| 639 | static int hdd_ipa_uc_send_wdi_control_msg(bool ctrl) |
| 640 | { |
| 641 | struct ipa_msg_meta meta; |
| 642 | struct ipa_wlan_msg *ipa_msg; |
| 643 | int ret = 0; |
| 644 | |
| 645 | /* WDI enable message to IPA */ |
| 646 | meta.msg_len = sizeof(*ipa_msg); |
| 647 | ipa_msg = qdf_mem_malloc(meta.msg_len); |
| 648 | if (ipa_msg == NULL) { |
| 649 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
| 650 | "msg allocation failed"); |
| 651 | return -ENOMEM; |
| 652 | } |
| 653 | |
| 654 | if (ctrl == true) |
| 655 | meta.msg_type = WLAN_WDI_ENABLE; |
| 656 | else |
| 657 | meta.msg_type = WLAN_WDI_DISABLE; |
| 658 | |
Srinivas Girigowda | 9785237 | 2017-03-06 16:52:59 -0800 | [diff] [blame] | 659 | HDD_IPA_LOG(QDF_TRACE_LEVEL_DEBUG, |
Manikandan Mohan | 153a4c3 | 2017-02-16 15:04:30 -0800 | [diff] [blame] | 660 | "ipa_send_msg(Evt:%d)", meta.msg_type); |
| 661 | ret = ipa_send_msg(&meta, ipa_msg, hdd_ipa_msg_free_fn); |
| 662 | if (ret) { |
| 663 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
| 664 | "ipa_send_msg(Evt:%d)-fail=%d", |
| 665 | meta.msg_type, ret); |
| 666 | qdf_mem_free(ipa_msg); |
| 667 | } |
Manikandan Mohan | cd64c0b | 2017-03-08 13:00:24 -0800 | [diff] [blame] | 668 | return ret; |
Manikandan Mohan | 153a4c3 | 2017-02-16 15:04:30 -0800 | [diff] [blame] | 669 | } |
Manikandan Mohan | 153a4c3 | 2017-02-16 15:04:30 -0800 | [diff] [blame] | 670 | |
Manikandan Mohan | cd64c0b | 2017-03-08 13:00:24 -0800 | [diff] [blame] | 671 | /** |
| 672 | * hdd_ipa_uc_register_uc_ready() - Register UC ready callback function to IPA |
| 673 | * @hdd_ipa: HDD IPA local context |
| 674 | * |
| 675 | * Register IPA UC ready callback function to IPA kernel driver |
| 676 | * Even IPA UC loaded later than WLAN kernel driver, WLAN kernel driver will |
| 677 | * open WDI pipe after WLAN driver loading finished |
| 678 | * |
| 679 | * Return: 0 Success |
| 680 | * -EPERM Registration fail |
| 681 | */ |
| 682 | static int hdd_ipa_uc_register_uc_ready(struct hdd_ipa_priv *hdd_ipa) |
| 683 | { |
| 684 | struct ipa_wdi_uc_ready_params uc_ready_param; |
| 685 | int ret = 0; |
| 686 | |
| 687 | hdd_ipa->uc_loaded = false; |
| 688 | uc_ready_param.priv = (void *)hdd_ipa; |
| 689 | uc_ready_param.notify = hdd_ipa_uc_loaded_uc_cb; |
| 690 | if (ipa_uc_reg_rdyCB(&uc_ready_param)) { |
| 691 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
| 692 | "UC Ready CB register fail"); |
| 693 | return -EPERM; |
| 694 | } |
| 695 | if (true == uc_ready_param.is_uC_ready) { |
Srinivas Girigowda | 2b5d47c | 2017-03-29 00:28:46 -0700 | [diff] [blame] | 696 | HDD_IPA_LOG(QDF_TRACE_LEVEL_INFO, "UC Ready"); |
Manikandan Mohan | cd64c0b | 2017-03-08 13:00:24 -0800 | [diff] [blame] | 697 | hdd_ipa->uc_loaded = true; |
| 698 | } else { |
| 699 | ret = hdd_ipa_uc_send_wdi_control_msg(false); |
| 700 | } |
| 701 | |
| 702 | return ret; |
| 703 | } |
Manikandan Mohan | 153a4c3 | 2017-02-16 15:04:30 -0800 | [diff] [blame] | 704 | #else |
Manikandan Mohan | 153a4c3 | 2017-02-16 15:04:30 -0800 | [diff] [blame] | 705 | static int hdd_ipa_uc_register_uc_ready(struct hdd_ipa_priv *hdd_ipa) |
| 706 | { |
| 707 | hdd_ipa->uc_loaded = true; |
| 708 | return 0; |
| 709 | } |
| 710 | |
| 711 | static int hdd_ipa_uc_send_wdi_control_msg(bool ctrl) |
| 712 | { |
| 713 | return 0; |
| 714 | } |
| 715 | #endif |
| 716 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 717 | /** |
| 718 | * hdd_ipa_is_enabled() - Is IPA enabled? |
| 719 | * @hdd_ctx: Global HDD context |
| 720 | * |
| 721 | * Return: true if IPA is enabled, false otherwise |
| 722 | */ |
| 723 | bool hdd_ipa_is_enabled(hdd_context_t *hdd_ctx) |
| 724 | { |
| 725 | return HDD_IPA_IS_CONFIG_ENABLED(hdd_ctx, HDD_IPA_ENABLE_MASK); |
| 726 | } |
| 727 | |
| 728 | /** |
| 729 | * hdd_ipa_uc_is_enabled() - Is IPA uC offload enabled? |
| 730 | * @hdd_ctx: Global HDD context |
| 731 | * |
| 732 | * Return: true if IPA uC offload is enabled, false otherwise |
| 733 | */ |
| 734 | bool hdd_ipa_uc_is_enabled(hdd_context_t *hdd_ctx) |
| 735 | { |
| 736 | return HDD_IPA_IS_CONFIG_ENABLED(hdd_ctx, HDD_IPA_UC_ENABLE_MASK); |
| 737 | } |
| 738 | |
| 739 | /** |
| 740 | * hdd_ipa_uc_sta_is_enabled() - Is STA mode IPA uC offload enabled? |
| 741 | * @hdd_ctx: Global HDD context |
| 742 | * |
| 743 | * Return: true if STA mode IPA uC offload is enabled, false otherwise |
| 744 | */ |
| 745 | static inline bool hdd_ipa_uc_sta_is_enabled(hdd_context_t *hdd_ctx) |
| 746 | { |
| 747 | return HDD_IPA_IS_CONFIG_ENABLED(hdd_ctx, HDD_IPA_UC_STA_ENABLE_MASK); |
| 748 | } |
| 749 | |
| 750 | /** |
Guolei Bian | ca144d8 | 2016-11-10 11:07:42 +0800 | [diff] [blame] | 751 | * hdd_ipa_uc_sta_reset_sta_connected() - Reset sta_connected flag |
| 752 | * @hdd_ipa: Global HDD IPA context |
| 753 | * |
| 754 | * Return: None |
| 755 | */ |
Guolei Bian | ca144d8 | 2016-11-10 11:07:42 +0800 | [diff] [blame] | 756 | static inline void hdd_ipa_uc_sta_reset_sta_connected( |
| 757 | struct hdd_ipa_priv *hdd_ipa) |
| 758 | { |
Yun Park | 637d648 | 2016-10-05 10:51:33 -0700 | [diff] [blame] | 759 | qdf_mutex_acquire(&hdd_ipa->ipa_lock); |
Guolei Bian | ca144d8 | 2016-11-10 11:07:42 +0800 | [diff] [blame] | 760 | hdd_ipa->sta_connected = 0; |
Yun Park | 637d648 | 2016-10-05 10:51:33 -0700 | [diff] [blame] | 761 | qdf_mutex_release(&hdd_ipa->ipa_lock); |
Guolei Bian | ca144d8 | 2016-11-10 11:07:42 +0800 | [diff] [blame] | 762 | } |
Guolei Bian | ca144d8 | 2016-11-10 11:07:42 +0800 | [diff] [blame] | 763 | |
| 764 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 765 | * hdd_ipa_is_pre_filter_enabled() - Is IPA pre-filter enabled? |
| 766 | * @hdd_ipa: Global HDD IPA context |
| 767 | * |
| 768 | * Return: true if pre-filter is enabled, otherwise false |
| 769 | */ |
| 770 | static inline bool hdd_ipa_is_pre_filter_enabled(hdd_context_t *hdd_ctx) |
| 771 | { |
| 772 | return HDD_IPA_IS_CONFIG_ENABLED(hdd_ctx, |
| 773 | HDD_IPA_PRE_FILTER_ENABLE_MASK); |
| 774 | } |
| 775 | |
| 776 | /** |
| 777 | * hdd_ipa_is_ipv6_enabled() - Is IPA IPv6 enabled? |
| 778 | * @hdd_ipa: Global HDD IPA context |
| 779 | * |
| 780 | * Return: true if IPv6 is enabled, otherwise false |
| 781 | */ |
| 782 | static inline bool hdd_ipa_is_ipv6_enabled(hdd_context_t *hdd_ctx) |
| 783 | { |
| 784 | return HDD_IPA_IS_CONFIG_ENABLED(hdd_ctx, HDD_IPA_IPV6_ENABLE_MASK); |
| 785 | } |
| 786 | |
| 787 | /** |
| 788 | * hdd_ipa_is_rm_enabled() - Is IPA resource manager enabled? |
| 789 | * @hdd_ipa: Global HDD IPA context |
| 790 | * |
| 791 | * Return: true if resource manager is enabled, otherwise false |
| 792 | */ |
| 793 | static inline bool hdd_ipa_is_rm_enabled(hdd_context_t *hdd_ctx) |
| 794 | { |
| 795 | return HDD_IPA_IS_CONFIG_ENABLED(hdd_ctx, HDD_IPA_RM_ENABLE_MASK); |
| 796 | } |
| 797 | |
| 798 | /** |
| 799 | * hdd_ipa_is_rt_debugging_enabled() - Is IPA real-time debug enabled? |
| 800 | * @hdd_ipa: Global HDD IPA context |
| 801 | * |
| 802 | * Return: true if resource manager is enabled, otherwise false |
| 803 | */ |
| 804 | static inline bool hdd_ipa_is_rt_debugging_enabled(hdd_context_t *hdd_ctx) |
| 805 | { |
| 806 | return HDD_IPA_IS_CONFIG_ENABLED(hdd_ctx, HDD_IPA_REAL_TIME_DEBUGGING); |
| 807 | } |
| 808 | |
| 809 | /** |
| 810 | * hdd_ipa_is_clk_scaling_enabled() - Is IPA clock scaling enabled? |
| 811 | * @hdd_ipa: Global HDD IPA context |
| 812 | * |
| 813 | * Return: true if clock scaling is enabled, otherwise false |
| 814 | */ |
| 815 | static inline bool hdd_ipa_is_clk_scaling_enabled(hdd_context_t *hdd_ctx) |
| 816 | { |
| 817 | return HDD_IPA_IS_CONFIG_ENABLED(hdd_ctx, |
| 818 | HDD_IPA_CLK_SCALING_ENABLE_MASK | |
| 819 | HDD_IPA_RM_ENABLE_MASK); |
| 820 | } |
| 821 | |
| 822 | /** |
| 823 | * hdd_ipa_uc_rt_debug_host_fill - fill rt debug buffer |
| 824 | * @ctext: pointer to hdd context. |
| 825 | * |
| 826 | * If rt debug enabled, periodically called, and fill debug buffer |
| 827 | * |
| 828 | * Return: none |
| 829 | */ |
| 830 | static void hdd_ipa_uc_rt_debug_host_fill(void *ctext) |
| 831 | { |
| 832 | hdd_context_t *hdd_ctx = (hdd_context_t *)ctext; |
| 833 | struct hdd_ipa_priv *hdd_ipa; |
| 834 | struct uc_rt_debug_info *dump_info = NULL; |
| 835 | |
| 836 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 837 | return; |
| 838 | |
| 839 | if (!hdd_ctx->hdd_ipa || !hdd_ipa_uc_is_enabled(hdd_ctx)) { |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 840 | HDD_IPA_LOG(QDF_TRACE_LEVEL_DEBUG, "IPA UC is not enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 841 | return; |
| 842 | } |
| 843 | |
| 844 | hdd_ipa = (struct hdd_ipa_priv *)hdd_ctx->hdd_ipa; |
| 845 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 846 | qdf_mutex_acquire(&hdd_ipa->rt_debug_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 847 | dump_info = &hdd_ipa->rt_bug_buffer[ |
| 848 | hdd_ipa->rt_buf_fill_index % HDD_IPA_UC_RT_DEBUG_BUF_COUNT]; |
| 849 | |
Deepthi Gowri | 6acee34 | 2016-10-28 15:00:38 +0530 | [diff] [blame] | 850 | dump_info->time = (uint64_t)qdf_mc_timer_get_system_time(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 851 | dump_info->ipa_excep_count = hdd_ipa->stats.num_rx_excep; |
| 852 | dump_info->rx_drop_count = hdd_ipa->ipa_rx_internel_drop_count; |
| 853 | dump_info->net_sent_count = hdd_ipa->ipa_rx_net_send_count; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 854 | dump_info->tx_fwd_count = hdd_ipa->ipa_tx_forward; |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 855 | dump_info->tx_fwd_ok_count = hdd_ipa->stats.num_tx_fwd_ok; |
| 856 | dump_info->rx_discard_count = hdd_ipa->ipa_rx_discard; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 857 | dump_info->rx_destructor_call = hdd_ipa->ipa_rx_destructor_count; |
| 858 | hdd_ipa->rt_buf_fill_index++; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 859 | qdf_mutex_release(&hdd_ipa->rt_debug_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 860 | |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 861 | qdf_mc_timer_start(&hdd_ipa->rt_debug_fill_timer, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 862 | HDD_IPA_UC_RT_DEBUG_FILL_INTERVAL); |
| 863 | } |
| 864 | |
| 865 | /** |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 866 | * __hdd_ipa_uc_rt_debug_host_dump - dump rt debug buffer |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 867 | * @hdd_ctx: pointer to hdd context. |
| 868 | * |
| 869 | * If rt debug enabled, dump debug buffer contents based on requirement |
| 870 | * |
| 871 | * Return: none |
| 872 | */ |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 873 | static void __hdd_ipa_uc_rt_debug_host_dump(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 874 | { |
| 875 | struct hdd_ipa_priv *hdd_ipa; |
| 876 | unsigned int dump_count; |
| 877 | unsigned int dump_index; |
| 878 | struct uc_rt_debug_info *dump_info = NULL; |
| 879 | |
| 880 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 881 | return; |
| 882 | |
| 883 | hdd_ipa = hdd_ctx->hdd_ipa; |
| 884 | if (!hdd_ipa || !hdd_ipa_uc_is_enabled(hdd_ctx)) { |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 885 | HDD_IPA_LOG(QDF_TRACE_LEVEL_DEBUG, "IPA UC is not enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 886 | return; |
| 887 | } |
| 888 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 889 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 890 | "========= WLAN-IPA DEBUG BUF DUMP ==========\n"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 891 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 892 | " TM : EXEP : DROP : NETS : FWOK : TXFD : DSTR : DSCD\n"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 893 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 894 | qdf_mutex_acquire(&hdd_ipa->rt_debug_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 895 | for (dump_count = 0; |
| 896 | dump_count < HDD_IPA_UC_RT_DEBUG_BUF_COUNT; |
| 897 | dump_count++) { |
| 898 | dump_index = (hdd_ipa->rt_buf_fill_index + dump_count) % |
| 899 | HDD_IPA_UC_RT_DEBUG_BUF_COUNT; |
| 900 | dump_info = &hdd_ipa->rt_bug_buffer[dump_index]; |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 901 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
Deepthi Gowri | 6acee34 | 2016-10-28 15:00:38 +0530 | [diff] [blame] | 902 | "%12llu:%10llu:%10llu:%10llu:%10llu:%10llu:%10llu:%10llu\n", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 903 | dump_info->time, dump_info->ipa_excep_count, |
| 904 | dump_info->rx_drop_count, dump_info->net_sent_count, |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 905 | dump_info->tx_fwd_ok_count, dump_info->tx_fwd_count, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 906 | dump_info->rx_destructor_call, |
| 907 | dump_info->rx_discard_count); |
| 908 | } |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 909 | qdf_mutex_release(&hdd_ipa->rt_debug_lock); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 910 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 911 | "======= WLAN-IPA DEBUG BUF DUMP END ========\n"); |
| 912 | } |
| 913 | |
| 914 | /** |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 915 | * hdd_ipa_uc_rt_debug_host_dump - SSR wrapper for |
| 916 | * __hdd_ipa_uc_rt_debug_host_dump |
| 917 | * @hdd_ctx: pointer to hdd context. |
| 918 | * |
| 919 | * If rt debug enabled, dump debug buffer contents based on requirement |
| 920 | * |
| 921 | * Return: none |
| 922 | */ |
| 923 | void hdd_ipa_uc_rt_debug_host_dump(hdd_context_t *hdd_ctx) |
| 924 | { |
| 925 | cds_ssr_protect(__func__); |
| 926 | __hdd_ipa_uc_rt_debug_host_dump(hdd_ctx); |
| 927 | cds_ssr_unprotect(__func__); |
| 928 | } |
| 929 | |
| 930 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 931 | * hdd_ipa_uc_rt_debug_handler - periodic memory health monitor handler |
| 932 | * @ctext: pointer to hdd context. |
| 933 | * |
| 934 | * periodically called by timer expire |
| 935 | * will try to alloc dummy memory and detect out of memory condition |
| 936 | * if out of memory detected, dump wlan-ipa stats |
| 937 | * |
| 938 | * Return: none |
| 939 | */ |
| 940 | static void hdd_ipa_uc_rt_debug_handler(void *ctext) |
| 941 | { |
| 942 | hdd_context_t *hdd_ctx = (hdd_context_t *)ctext; |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 943 | struct hdd_ipa_priv *hdd_ipa; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 944 | void *dummy_ptr = NULL; |
| 945 | |
| 946 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 947 | return; |
| 948 | |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 949 | hdd_ipa = (struct hdd_ipa_priv *)hdd_ctx->hdd_ipa; |
| 950 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 951 | if (!hdd_ipa_is_rt_debugging_enabled(hdd_ctx)) { |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 952 | HDD_IPA_LOG(QDF_TRACE_LEVEL_DEBUG, |
| 953 | "IPA RT debug is not enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 954 | return; |
| 955 | } |
| 956 | |
| 957 | /* Allocate dummy buffer periodically and free immediately. this will |
| 958 | * proactively detect OOM and if allocation fails dump ipa stats |
| 959 | */ |
| 960 | dummy_ptr = kmalloc(HDD_IPA_UC_DEBUG_DUMMY_MEM_SIZE, |
| 961 | GFP_KERNEL | GFP_ATOMIC); |
| 962 | if (!dummy_ptr) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 963 | hdd_ipa_uc_rt_debug_host_dump(hdd_ctx); |
| 964 | hdd_ipa_uc_stat_request( |
Yun Park | 637d648 | 2016-10-05 10:51:33 -0700 | [diff] [blame] | 965 | hdd_get_adapter(hdd_ctx, QDF_SAP_MODE), |
| 966 | HDD_IPA_UC_STAT_REASON_DEBUG); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 967 | } else { |
| 968 | kfree(dummy_ptr); |
| 969 | } |
| 970 | |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 971 | qdf_mc_timer_start(&hdd_ipa->rt_debug_timer, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 972 | HDD_IPA_UC_RT_DEBUG_PERIOD); |
| 973 | } |
| 974 | |
| 975 | /** |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 976 | * hdd_ipa_uc_rt_debug_destructor() - called by data packet free |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 977 | * @skb: packet pinter |
| 978 | * |
| 979 | * when free data packet, will be invoked by wlan client and will increase |
| 980 | * free counter |
| 981 | * |
| 982 | * Return: none |
| 983 | */ |
Jeff Johnson | d772063 | 2016-10-05 16:04:32 -0700 | [diff] [blame] | 984 | static void hdd_ipa_uc_rt_debug_destructor(struct sk_buff *skb) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 985 | { |
| 986 | if (!ghdd_ipa) { |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 987 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, "invalid hdd context"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 988 | return; |
| 989 | } |
| 990 | |
| 991 | ghdd_ipa->ipa_rx_destructor_count++; |
| 992 | } |
| 993 | |
| 994 | /** |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 995 | * hdd_ipa_uc_rt_debug_deinit() - remove resources to handle rt debugging |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 996 | * @hdd_ctx: hdd main context |
| 997 | * |
| 998 | * free all rt debugging resources |
| 999 | * |
| 1000 | * Return: none |
| 1001 | */ |
| 1002 | static void hdd_ipa_uc_rt_debug_deinit(hdd_context_t *hdd_ctx) |
| 1003 | { |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 1004 | struct hdd_ipa_priv *hdd_ipa; |
| 1005 | |
| 1006 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 1007 | return; |
| 1008 | |
| 1009 | hdd_ipa = (struct hdd_ipa_priv *)hdd_ctx->hdd_ipa; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1010 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 1011 | qdf_mutex_destroy(&hdd_ipa->rt_debug_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1012 | |
| 1013 | if (!hdd_ipa_is_rt_debugging_enabled(hdd_ctx)) { |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 1014 | HDD_IPA_LOG(QDF_TRACE_LEVEL_DEBUG, |
| 1015 | "IPA RT debug is not enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1016 | return; |
| 1017 | } |
| 1018 | |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 1019 | if (QDF_TIMER_STATE_STOPPED != |
Prakash Dhavali | 169de30 | 2016-11-30 12:52:49 -0800 | [diff] [blame] | 1020 | qdf_mc_timer_get_current_state(&hdd_ipa->rt_debug_fill_timer)) { |
| 1021 | qdf_mc_timer_stop(&hdd_ipa->rt_debug_fill_timer); |
| 1022 | } |
| 1023 | qdf_mc_timer_destroy(&hdd_ipa->rt_debug_fill_timer); |
| 1024 | |
| 1025 | if (QDF_TIMER_STATE_STOPPED != |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 1026 | qdf_mc_timer_get_current_state(&hdd_ipa->rt_debug_timer)) { |
| 1027 | qdf_mc_timer_stop(&hdd_ipa->rt_debug_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1028 | } |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 1029 | qdf_mc_timer_destroy(&hdd_ipa->rt_debug_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1030 | } |
| 1031 | |
| 1032 | /** |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 1033 | * hdd_ipa_uc_rt_debug_init() - intialize resources to handle rt debugging |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1034 | * @hdd_ctx: hdd main context |
| 1035 | * |
| 1036 | * alloc and initialize all rt debugging resources |
| 1037 | * |
| 1038 | * Return: none |
| 1039 | */ |
| 1040 | static void hdd_ipa_uc_rt_debug_init(hdd_context_t *hdd_ctx) |
| 1041 | { |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 1042 | struct hdd_ipa_priv *hdd_ipa; |
| 1043 | |
| 1044 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 1045 | return; |
| 1046 | |
| 1047 | hdd_ipa = (struct hdd_ipa_priv *)hdd_ctx->hdd_ipa; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1048 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 1049 | qdf_mutex_create(&hdd_ipa->rt_debug_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1050 | hdd_ipa->rt_buf_fill_index = 0; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1051 | qdf_mem_zero(hdd_ipa->rt_bug_buffer, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1052 | sizeof(struct uc_rt_debug_info) * |
| 1053 | HDD_IPA_UC_RT_DEBUG_BUF_COUNT); |
| 1054 | hdd_ipa->ipa_tx_forward = 0; |
| 1055 | hdd_ipa->ipa_rx_discard = 0; |
| 1056 | hdd_ipa->ipa_rx_net_send_count = 0; |
| 1057 | hdd_ipa->ipa_rx_internel_drop_count = 0; |
| 1058 | hdd_ipa->ipa_rx_destructor_count = 0; |
| 1059 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1060 | /* Reatime debug enable on feature enable */ |
| 1061 | if (!hdd_ipa_is_rt_debugging_enabled(hdd_ctx)) { |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 1062 | HDD_IPA_LOG(QDF_TRACE_LEVEL_DEBUG, |
| 1063 | "IPA RT debug is not enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1064 | return; |
| 1065 | } |
Yun Park | dfc1da5 | 2016-11-15 14:50:11 -0800 | [diff] [blame] | 1066 | |
| 1067 | qdf_mc_timer_init(&hdd_ipa->rt_debug_fill_timer, QDF_TIMER_TYPE_SW, |
| 1068 | hdd_ipa_uc_rt_debug_host_fill, (void *)hdd_ctx); |
| 1069 | qdf_mc_timer_start(&hdd_ipa->rt_debug_fill_timer, |
| 1070 | HDD_IPA_UC_RT_DEBUG_FILL_INTERVAL); |
| 1071 | |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 1072 | qdf_mc_timer_init(&hdd_ipa->rt_debug_timer, QDF_TIMER_TYPE_SW, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1073 | hdd_ipa_uc_rt_debug_handler, (void *)hdd_ctx); |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 1074 | qdf_mc_timer_start(&hdd_ipa->rt_debug_timer, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1075 | HDD_IPA_UC_RT_DEBUG_PERIOD); |
| 1076 | |
| 1077 | } |
| 1078 | |
| 1079 | /** |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 1080 | * hdd_ipa_dump_hdd_ipa() - dump entries in HDD IPA struct |
| 1081 | * @hdd_ipa: HDD IPA struct |
| 1082 | * |
| 1083 | * Dump entries in struct hdd_ipa |
| 1084 | * |
| 1085 | * Return: none |
| 1086 | */ |
| 1087 | static void hdd_ipa_dump_hdd_ipa(struct hdd_ipa_priv *hdd_ipa) |
| 1088 | { |
| 1089 | int i; |
| 1090 | |
| 1091 | /* HDD IPA */ |
Srinivas Girigowda | 9785237 | 2017-03-06 16:52:59 -0800 | [diff] [blame] | 1092 | hdd_info("==== HDD IPA ====\n" |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 1093 | "num_iface: %d\n" |
| 1094 | "rm_state: %d\n" |
| 1095 | "rm_lock: %p\n" |
| 1096 | "uc_rm_work: %p\n" |
| 1097 | "uc_op_work: %p\n" |
| 1098 | "wake_lock: %p\n" |
| 1099 | "wake_lock_work: %p\n" |
| 1100 | "wake_lock_released: %d\n" |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 1101 | "tx_ref_cnt: %d\n" |
| 1102 | "pm_queue_head----\n" |
| 1103 | "\thead: %p\n" |
| 1104 | "\ttail: %p\n" |
| 1105 | "\tqlen: %d\n" |
| 1106 | "pm_work: %p\n" |
| 1107 | "pm_lock: %p\n" |
| 1108 | "suspended: %d\n", |
| 1109 | hdd_ipa->num_iface, |
| 1110 | hdd_ipa->rm_state, |
| 1111 | &hdd_ipa->rm_lock, |
| 1112 | &hdd_ipa->uc_rm_work, |
| 1113 | &hdd_ipa->uc_op_work, |
| 1114 | &hdd_ipa->wake_lock, |
| 1115 | &hdd_ipa->wake_lock_work, |
| 1116 | hdd_ipa->wake_lock_released, |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 1117 | hdd_ipa->tx_ref_cnt.counter, |
| 1118 | hdd_ipa->pm_queue_head.head, |
| 1119 | hdd_ipa->pm_queue_head.tail, |
| 1120 | hdd_ipa->pm_queue_head.qlen, |
| 1121 | &hdd_ipa->pm_work, |
| 1122 | &hdd_ipa->pm_lock, |
| 1123 | hdd_ipa->suspended); |
Yun Park | 52b2b99 | 2016-09-22 15:49:51 -0700 | [diff] [blame] | 1124 | hdd_err("\nq_lock: %p\n" |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 1125 | "pend_desc_head----\n" |
| 1126 | "\tnext: %p\n" |
| 1127 | "\tprev: %p\n" |
| 1128 | "hdd_ctx: %p\n" |
| 1129 | "debugfs_dir: %p\n" |
| 1130 | "stats: %p\n" |
| 1131 | "ipv4_notifier: %p\n" |
| 1132 | "curr_prod_bw: %d\n" |
| 1133 | "curr_cons_bw: %d\n" |
| 1134 | "activated_fw_pipe: %d\n" |
| 1135 | "sap_num_connected_sta: %d\n" |
| 1136 | "sta_connected: %d\n", |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 1137 | &hdd_ipa->q_lock, |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 1138 | hdd_ipa->pend_desc_head.next, |
| 1139 | hdd_ipa->pend_desc_head.prev, |
| 1140 | hdd_ipa->hdd_ctx, |
| 1141 | hdd_ipa->debugfs_dir, |
| 1142 | &hdd_ipa->stats, |
| 1143 | &hdd_ipa->ipv4_notifier, |
| 1144 | hdd_ipa->curr_prod_bw, |
| 1145 | hdd_ipa->curr_cons_bw, |
| 1146 | hdd_ipa->activated_fw_pipe, |
| 1147 | hdd_ipa->sap_num_connected_sta, |
| 1148 | (unsigned int)hdd_ipa->sta_connected |
| 1149 | ); |
Srinivas Girigowda | 9785237 | 2017-03-06 16:52:59 -0800 | [diff] [blame] | 1150 | hdd_info("\ntx_pipe_handle: 0x%x\n" |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 1151 | "rx_pipe_handle: 0x%x\n" |
| 1152 | "resource_loading: %d\n" |
| 1153 | "resource_unloading: %d\n" |
| 1154 | "pending_cons_req: %d\n" |
| 1155 | "pending_event----\n" |
| 1156 | "\tanchor.next: %p\n" |
| 1157 | "\tanchor.prev: %p\n" |
| 1158 | "\tcount: %d\n" |
| 1159 | "\tmax_size: %d\n" |
| 1160 | "event_lock: %p\n" |
| 1161 | "ipa_tx_packets_diff: %d\n" |
| 1162 | "ipa_rx_packets_diff: %d\n" |
| 1163 | "ipa_p_tx_packets: %d\n" |
| 1164 | "ipa_p_rx_packets: %d\n" |
| 1165 | "stat_req_reason: %d\n", |
| 1166 | hdd_ipa->tx_pipe_handle, |
| 1167 | hdd_ipa->rx_pipe_handle, |
| 1168 | hdd_ipa->resource_loading, |
| 1169 | hdd_ipa->resource_unloading, |
| 1170 | hdd_ipa->pending_cons_req, |
| 1171 | hdd_ipa->pending_event.anchor.next, |
| 1172 | hdd_ipa->pending_event.anchor.prev, |
| 1173 | hdd_ipa->pending_event.count, |
| 1174 | hdd_ipa->pending_event.max_size, |
| 1175 | &hdd_ipa->event_lock, |
| 1176 | hdd_ipa->ipa_tx_packets_diff, |
| 1177 | hdd_ipa->ipa_rx_packets_diff, |
| 1178 | hdd_ipa->ipa_p_tx_packets, |
| 1179 | hdd_ipa->ipa_p_rx_packets, |
| 1180 | hdd_ipa->stat_req_reason); |
| 1181 | |
Srinivas Girigowda | 9785237 | 2017-03-06 16:52:59 -0800 | [diff] [blame] | 1182 | hdd_info("assoc_stas_map([id]is_reserved/sta_id): "); |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 1183 | for (i = 0; i < WLAN_MAX_STA_COUNT; i++) { |
Srinivas Girigowda | 9785237 | 2017-03-06 16:52:59 -0800 | [diff] [blame] | 1184 | hdd_info(" [%d]%d/%d", i, |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 1185 | hdd_ipa->assoc_stas_map[i].is_reserved, |
| 1186 | hdd_ipa->assoc_stas_map[i].sta_id); |
| 1187 | } |
| 1188 | } |
| 1189 | |
| 1190 | /** |
| 1191 | * hdd_ipa_dump_sys_pipe() - dump HDD IPA SYS Pipe struct |
| 1192 | * @hdd_ipa: HDD IPA struct |
| 1193 | * |
| 1194 | * Dump entire struct hdd_ipa_sys_pipe |
| 1195 | * |
| 1196 | * Return: none |
| 1197 | */ |
| 1198 | static void hdd_ipa_dump_sys_pipe(struct hdd_ipa_priv *hdd_ipa) |
| 1199 | { |
| 1200 | int i; |
| 1201 | |
| 1202 | /* IPA SYS Pipes */ |
Srinivas Girigowda | 9785237 | 2017-03-06 16:52:59 -0800 | [diff] [blame] | 1203 | hdd_info("==== IPA SYS Pipes ====\n"); |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 1204 | |
| 1205 | for (i = 0; i < HDD_IPA_MAX_SYSBAM_PIPE; i++) { |
| 1206 | struct hdd_ipa_sys_pipe *sys_pipe; |
| 1207 | struct ipa_sys_connect_params *ipa_sys_params; |
| 1208 | |
| 1209 | sys_pipe = &hdd_ipa->sys_pipe[i]; |
| 1210 | ipa_sys_params = &sys_pipe->ipa_sys_params; |
| 1211 | |
Srinivas Girigowda | 9785237 | 2017-03-06 16:52:59 -0800 | [diff] [blame] | 1212 | hdd_info("sys_pipe[%d]----\n" |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 1213 | "\tconn_hdl: 0x%x\n" |
| 1214 | "\tconn_hdl_valid: %d\n" |
| 1215 | "\tnat_en: %d\n" |
| 1216 | "\thdr_len %d\n" |
| 1217 | "\thdr_additional_const_len: %d\n" |
| 1218 | "\thdr_ofst_pkt_size_valid: %d\n" |
| 1219 | "\thdr_ofst_pkt_size: %d\n" |
| 1220 | "\thdr_little_endian: %d\n" |
| 1221 | "\tmode: %d\n" |
| 1222 | "\tclient: %d\n" |
| 1223 | "\tdesc_fifo_sz: %d\n" |
| 1224 | "\tpriv: %p\n" |
| 1225 | "\tnotify: %p\n" |
| 1226 | "\tskip_ep_cfg: %d\n" |
| 1227 | "\tkeep_ipa_awake: %d\n", |
| 1228 | i, |
| 1229 | sys_pipe->conn_hdl, |
| 1230 | sys_pipe->conn_hdl_valid, |
| 1231 | ipa_sys_params->ipa_ep_cfg.nat.nat_en, |
| 1232 | ipa_sys_params->ipa_ep_cfg.hdr.hdr_len, |
| 1233 | ipa_sys_params->ipa_ep_cfg.hdr.hdr_additional_const_len, |
| 1234 | ipa_sys_params->ipa_ep_cfg.hdr.hdr_ofst_pkt_size_valid, |
| 1235 | ipa_sys_params->ipa_ep_cfg.hdr.hdr_ofst_pkt_size, |
| 1236 | ipa_sys_params->ipa_ep_cfg.hdr_ext.hdr_little_endian, |
| 1237 | ipa_sys_params->ipa_ep_cfg.mode.mode, |
| 1238 | ipa_sys_params->client, |
| 1239 | ipa_sys_params->desc_fifo_sz, |
| 1240 | ipa_sys_params->priv, |
| 1241 | ipa_sys_params->notify, |
| 1242 | ipa_sys_params->skip_ep_cfg, |
| 1243 | ipa_sys_params->keep_ipa_awake); |
| 1244 | } |
| 1245 | } |
| 1246 | |
| 1247 | /** |
| 1248 | * hdd_ipa_dump_iface_context() - dump HDD IPA Interface Context struct |
| 1249 | * @hdd_ipa: HDD IPA struct |
| 1250 | * |
| 1251 | * Dump entire struct hdd_ipa_iface_context |
| 1252 | * |
| 1253 | * Return: none |
| 1254 | */ |
| 1255 | static void hdd_ipa_dump_iface_context(struct hdd_ipa_priv *hdd_ipa) |
| 1256 | { |
| 1257 | int i; |
| 1258 | |
| 1259 | /* IPA Interface Contexts */ |
Srinivas Girigowda | 9785237 | 2017-03-06 16:52:59 -0800 | [diff] [blame] | 1260 | hdd_info("==== IPA Interface Contexts ====\n"); |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 1261 | |
| 1262 | for (i = 0; i < HDD_IPA_MAX_IFACE; i++) { |
| 1263 | struct hdd_ipa_iface_context *iface_context; |
| 1264 | |
| 1265 | iface_context = &hdd_ipa->iface_context[i]; |
| 1266 | |
Srinivas Girigowda | 9785237 | 2017-03-06 16:52:59 -0800 | [diff] [blame] | 1267 | hdd_info("iface_context[%d]----\n" |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 1268 | "\thdd_ipa: %p\n" |
| 1269 | "\tadapter: %p\n" |
| 1270 | "\ttl_context: %p\n" |
| 1271 | "\tcons_client: %d\n" |
| 1272 | "\tprod_client: %d\n" |
| 1273 | "\tiface_id: %d\n" |
| 1274 | "\tsta_id: %d\n" |
| 1275 | "\tinterface_lock: %p\n" |
| 1276 | "\tifa_address: 0x%x\n", |
| 1277 | i, |
| 1278 | iface_context->hdd_ipa, |
| 1279 | iface_context->adapter, |
| 1280 | iface_context->tl_context, |
| 1281 | iface_context->cons_client, |
| 1282 | iface_context->prod_client, |
| 1283 | iface_context->iface_id, |
| 1284 | iface_context->sta_id, |
| 1285 | &iface_context->interface_lock, |
| 1286 | iface_context->ifa_address); |
| 1287 | } |
| 1288 | } |
| 1289 | |
| 1290 | /** |
| 1291 | * hdd_ipa_dump_info() - dump HDD IPA struct |
| 1292 | * @pHddCtx: hdd main context |
| 1293 | * |
| 1294 | * Dump entire struct hdd_ipa |
| 1295 | * |
| 1296 | * Return: none |
| 1297 | */ |
| 1298 | void hdd_ipa_dump_info(hdd_context_t *hdd_ctx) |
| 1299 | { |
| 1300 | struct hdd_ipa_priv *hdd_ipa = (struct hdd_ipa_priv *)hdd_ctx->hdd_ipa; |
| 1301 | |
| 1302 | hdd_ipa_dump_hdd_ipa(hdd_ipa); |
| 1303 | hdd_ipa_dump_sys_pipe(hdd_ipa); |
| 1304 | hdd_ipa_dump_iface_context(hdd_ipa); |
| 1305 | } |
| 1306 | |
| 1307 | /** |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 1308 | * hdd_ipa_set_tx_flow_info() - To set TX flow info if IPA is |
| 1309 | * enabled |
| 1310 | * |
| 1311 | * This routine is called to set TX flow info if IPA is enabled |
| 1312 | * |
| 1313 | * Return: None |
| 1314 | */ |
| 1315 | void hdd_ipa_set_tx_flow_info(void) |
| 1316 | { |
| 1317 | hdd_adapter_list_node_t *adapterNode = NULL, *pNext = NULL; |
| 1318 | QDF_STATUS status; |
| 1319 | hdd_adapter_t *adapter; |
| 1320 | hdd_station_ctx_t *pHddStaCtx; |
| 1321 | hdd_ap_ctx_t *hdd_ap_ctx; |
| 1322 | hdd_hostapd_state_t *hostapd_state; |
| 1323 | struct qdf_mac_addr staBssid = QDF_MAC_ADDR_ZERO_INITIALIZER; |
| 1324 | struct qdf_mac_addr p2pBssid = QDF_MAC_ADDR_ZERO_INITIALIZER; |
| 1325 | struct qdf_mac_addr apBssid = QDF_MAC_ADDR_ZERO_INITIALIZER; |
| 1326 | uint8_t staChannel = 0, p2pChannel = 0, apChannel = 0; |
| 1327 | const char *p2pMode = "DEV"; |
| 1328 | hdd_context_t *hdd_ctx; |
| 1329 | cds_context_type *cds_ctx; |
| 1330 | #ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL |
| 1331 | uint8_t targetChannel = 0; |
| 1332 | uint8_t preAdapterChannel = 0; |
| 1333 | uint8_t channel24; |
| 1334 | uint8_t channel5; |
| 1335 | hdd_adapter_t *preAdapterContext = NULL; |
| 1336 | hdd_adapter_t *adapter2_4 = NULL; |
| 1337 | hdd_adapter_t *adapter5 = NULL; |
| 1338 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
| 1339 | #endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */ |
| 1340 | struct wlan_objmgr_psoc *psoc; |
| 1341 | |
| 1342 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 1343 | if (!hdd_ctx) { |
| 1344 | cds_err("HDD context is NULL"); |
| 1345 | return; |
| 1346 | } |
| 1347 | |
| 1348 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 1349 | if (!cds_ctx) { |
| 1350 | cds_err("Invalid CDS Context"); |
| 1351 | return; |
| 1352 | } |
| 1353 | |
| 1354 | psoc = hdd_ctx->hdd_psoc; |
| 1355 | status = hdd_get_front_adapter(hdd_ctx, &adapterNode); |
| 1356 | while (NULL != adapterNode && QDF_STATUS_SUCCESS == status) { |
| 1357 | adapter = adapterNode->pAdapter; |
| 1358 | switch (adapter->device_mode) { |
| 1359 | case QDF_STA_MODE: |
| 1360 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 1361 | if (eConnectionState_Associated == |
| 1362 | pHddStaCtx->conn_info.connState) { |
| 1363 | staChannel = |
| 1364 | pHddStaCtx->conn_info.operationChannel; |
| 1365 | qdf_copy_macaddr(&staBssid, |
| 1366 | &pHddStaCtx->conn_info.bssId); |
| 1367 | #ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL |
| 1368 | targetChannel = staChannel; |
| 1369 | #endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */ |
| 1370 | } |
| 1371 | break; |
| 1372 | case QDF_P2P_CLIENT_MODE: |
| 1373 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 1374 | if (eConnectionState_Associated == |
| 1375 | pHddStaCtx->conn_info.connState) { |
| 1376 | p2pChannel = |
| 1377 | pHddStaCtx->conn_info.operationChannel; |
| 1378 | qdf_copy_macaddr(&p2pBssid, |
| 1379 | &pHddStaCtx->conn_info.bssId); |
| 1380 | p2pMode = "CLI"; |
| 1381 | #ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL |
| 1382 | targetChannel = p2pChannel; |
| 1383 | #endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */ |
| 1384 | } |
| 1385 | break; |
| 1386 | case QDF_P2P_GO_MODE: |
| 1387 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 1388 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
| 1389 | if (hostapd_state->bssState == BSS_START |
| 1390 | && hostapd_state->qdf_status == |
| 1391 | QDF_STATUS_SUCCESS) { |
| 1392 | p2pChannel = hdd_ap_ctx->operatingChannel; |
| 1393 | qdf_copy_macaddr(&p2pBssid, |
| 1394 | &adapter->macAddressCurrent); |
| 1395 | #ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL |
| 1396 | targetChannel = p2pChannel; |
| 1397 | #endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */ |
| 1398 | } |
| 1399 | p2pMode = "GO"; |
| 1400 | break; |
| 1401 | case QDF_SAP_MODE: |
| 1402 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 1403 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
| 1404 | if (hostapd_state->bssState == BSS_START |
| 1405 | && hostapd_state->qdf_status == |
| 1406 | QDF_STATUS_SUCCESS) { |
| 1407 | apChannel = hdd_ap_ctx->operatingChannel; |
| 1408 | qdf_copy_macaddr(&apBssid, |
| 1409 | &adapter->macAddressCurrent); |
| 1410 | #ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL |
| 1411 | targetChannel = apChannel; |
| 1412 | #endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */ |
| 1413 | } |
| 1414 | break; |
| 1415 | case QDF_IBSS_MODE: |
| 1416 | default: |
| 1417 | break; |
| 1418 | } |
| 1419 | #ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL |
| 1420 | if (targetChannel) { |
| 1421 | /* |
| 1422 | * This is first adapter detected as active |
| 1423 | * set as default for none concurrency case |
| 1424 | */ |
| 1425 | if (!preAdapterChannel) { |
| 1426 | /* If IPA UC data path is enabled, |
| 1427 | * target should reserve extra tx descriptors |
| 1428 | * for IPA data path. |
| 1429 | * Then host data path should allow less TX |
| 1430 | * packet pumping in case IPA |
| 1431 | * data path enabled |
| 1432 | */ |
| 1433 | if (hdd_ipa_uc_is_enabled(hdd_ctx) && |
| 1434 | (QDF_SAP_MODE == adapter->device_mode)) { |
| 1435 | adapter->tx_flow_low_watermark = |
| 1436 | hdd_ctx->config->TxFlowLowWaterMark + |
| 1437 | WLAN_TFC_IPAUC_TX_DESC_RESERVE; |
| 1438 | } else { |
| 1439 | adapter->tx_flow_low_watermark = |
| 1440 | hdd_ctx->config-> |
| 1441 | TxFlowLowWaterMark; |
| 1442 | } |
| 1443 | adapter->tx_flow_high_watermark_offset = |
| 1444 | hdd_ctx->config->TxFlowHighWaterMarkOffset; |
| 1445 | cdp_fc_ll_set_tx_pause_q_depth(soc, |
| 1446 | adapter->sessionId, |
| 1447 | hdd_ctx->config->TxFlowMaxQueueDepth); |
| 1448 | cds_info("MODE %d,CH %d,LWM %d,HWM %d,TXQDEP %d", |
| 1449 | adapter->device_mode, |
| 1450 | targetChannel, |
| 1451 | adapter->tx_flow_low_watermark, |
| 1452 | adapter->tx_flow_low_watermark + |
| 1453 | adapter->tx_flow_high_watermark_offset, |
| 1454 | hdd_ctx->config->TxFlowMaxQueueDepth); |
| 1455 | preAdapterChannel = targetChannel; |
| 1456 | preAdapterContext = adapter; |
| 1457 | } else { |
| 1458 | /* |
| 1459 | * SCC, disable TX flow control for both |
| 1460 | * SCC each adapter cannot reserve dedicated |
| 1461 | * channel resource, as a result, if any adapter |
| 1462 | * blocked OS Q by flow control, |
| 1463 | * blocked adapter will lost chance to recover |
| 1464 | */ |
| 1465 | if (preAdapterChannel == targetChannel) { |
| 1466 | /* Current adapter */ |
| 1467 | adapter->tx_flow_low_watermark = 0; |
| 1468 | adapter-> |
| 1469 | tx_flow_high_watermark_offset = 0; |
| 1470 | cdp_fc_ll_set_tx_pause_q_depth(soc, |
| 1471 | adapter->sessionId, |
| 1472 | hdd_ctx->config-> |
| 1473 | TxHbwFlowMaxQueueDepth); |
| 1474 | cds_info("SCC: MODE %s(%d), CH %d, LWM %d, HWM %d, TXQDEP %d", |
| 1475 | hdd_device_mode_to_string( |
| 1476 | adapter->device_mode), |
| 1477 | adapter->device_mode, |
| 1478 | targetChannel, |
| 1479 | adapter->tx_flow_low_watermark, |
| 1480 | adapter->tx_flow_low_watermark + |
| 1481 | adapter-> |
| 1482 | tx_flow_high_watermark_offset, |
| 1483 | hdd_ctx->config-> |
| 1484 | TxHbwFlowMaxQueueDepth); |
| 1485 | |
| 1486 | if (!preAdapterContext) { |
| 1487 | cds_err("SCC: Previous adapter context NULL"); |
| 1488 | continue; |
| 1489 | } |
| 1490 | |
| 1491 | /* Previous adapter */ |
| 1492 | preAdapterContext-> |
| 1493 | tx_flow_low_watermark = 0; |
| 1494 | preAdapterContext-> |
| 1495 | tx_flow_high_watermark_offset = 0; |
| 1496 | cdp_fc_ll_set_tx_pause_q_depth(soc, |
| 1497 | preAdapterContext->sessionId, |
| 1498 | hdd_ctx->config-> |
| 1499 | TxHbwFlowMaxQueueDepth); |
| 1500 | cds_info("SCC: MODE %s(%d), CH %d, LWM %d, HWM %d, TXQDEP %d", |
| 1501 | hdd_device_mode_to_string( |
| 1502 | preAdapterContext->device_mode |
| 1503 | ), |
| 1504 | preAdapterContext->device_mode, |
| 1505 | targetChannel, |
| 1506 | preAdapterContext-> |
| 1507 | tx_flow_low_watermark, |
| 1508 | preAdapterContext-> |
| 1509 | tx_flow_low_watermark + |
| 1510 | preAdapterContext-> |
| 1511 | tx_flow_high_watermark_offset, |
| 1512 | hdd_ctx->config-> |
| 1513 | TxHbwFlowMaxQueueDepth); |
| 1514 | } |
| 1515 | /* |
| 1516 | * MCC, each adapter will have dedicated |
| 1517 | * resource |
| 1518 | */ |
| 1519 | else { |
| 1520 | /* current channel is 2.4 */ |
| 1521 | if (targetChannel <= |
| 1522 | WLAN_HDD_TX_FLOW_CONTROL_MAX_24BAND_CH) { |
| 1523 | channel24 = targetChannel; |
| 1524 | channel5 = preAdapterChannel; |
| 1525 | adapter2_4 = adapter; |
| 1526 | adapter5 = preAdapterContext; |
| 1527 | } else { |
| 1528 | /* Current channel is 5 */ |
| 1529 | channel24 = preAdapterChannel; |
| 1530 | channel5 = targetChannel; |
| 1531 | adapter2_4 = preAdapterContext; |
| 1532 | adapter5 = adapter; |
| 1533 | } |
| 1534 | |
| 1535 | if (!adapter5) { |
| 1536 | cds_err("MCC: 5GHz adapter context NULL"); |
| 1537 | continue; |
| 1538 | } |
| 1539 | adapter5->tx_flow_low_watermark = |
| 1540 | hdd_ctx->config-> |
| 1541 | TxHbwFlowLowWaterMark; |
| 1542 | adapter5-> |
| 1543 | tx_flow_high_watermark_offset = |
| 1544 | hdd_ctx->config-> |
| 1545 | TxHbwFlowHighWaterMarkOffset; |
| 1546 | cdp_fc_ll_set_tx_pause_q_depth(soc, |
| 1547 | adapter5->sessionId, |
| 1548 | hdd_ctx->config-> |
| 1549 | TxHbwFlowMaxQueueDepth); |
| 1550 | cds_info("MCC: MODE %s(%d), CH %d, LWM %d, HWM %d, TXQDEP %d", |
| 1551 | hdd_device_mode_to_string( |
| 1552 | adapter5->device_mode), |
| 1553 | adapter5->device_mode, |
| 1554 | channel5, |
| 1555 | adapter5->tx_flow_low_watermark, |
| 1556 | adapter5-> |
| 1557 | tx_flow_low_watermark + |
| 1558 | adapter5-> |
| 1559 | tx_flow_high_watermark_offset, |
| 1560 | hdd_ctx->config-> |
| 1561 | TxHbwFlowMaxQueueDepth); |
| 1562 | |
| 1563 | if (!adapter2_4) { |
| 1564 | cds_err("MCC: 2.4GHz adapter context NULL"); |
| 1565 | continue; |
| 1566 | } |
| 1567 | adapter2_4->tx_flow_low_watermark = |
| 1568 | hdd_ctx->config-> |
| 1569 | TxLbwFlowLowWaterMark; |
| 1570 | adapter2_4-> |
| 1571 | tx_flow_high_watermark_offset = |
| 1572 | hdd_ctx->config-> |
| 1573 | TxLbwFlowHighWaterMarkOffset; |
| 1574 | cdp_fc_ll_set_tx_pause_q_depth(soc, |
| 1575 | adapter2_4->sessionId, |
| 1576 | hdd_ctx->config-> |
| 1577 | TxLbwFlowMaxQueueDepth); |
| 1578 | cds_info("MCC: MODE %s(%d), CH %d, LWM %d, HWM %d, TXQDEP %d", |
| 1579 | hdd_device_mode_to_string( |
| 1580 | adapter2_4->device_mode), |
| 1581 | adapter2_4->device_mode, |
| 1582 | channel24, |
| 1583 | adapter2_4-> |
| 1584 | tx_flow_low_watermark, |
| 1585 | adapter2_4-> |
| 1586 | tx_flow_low_watermark + |
| 1587 | adapter2_4-> |
| 1588 | tx_flow_high_watermark_offset, |
| 1589 | hdd_ctx->config-> |
| 1590 | TxLbwFlowMaxQueueDepth); |
| 1591 | |
| 1592 | } |
| 1593 | } |
| 1594 | } |
| 1595 | targetChannel = 0; |
| 1596 | #endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */ |
| 1597 | status = hdd_get_next_adapter(hdd_ctx, adapterNode, &pNext); |
| 1598 | adapterNode = pNext; |
| 1599 | } |
| 1600 | hdd_ctx->mcc_mode = policy_mgr_current_concurrency_is_mcc(psoc); |
| 1601 | } |
| 1602 | |
| 1603 | /** |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 1604 | * __hdd_ipa_uc_stat_query() - Query the IPA stats |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1605 | * @hdd_ctx: Global HDD context |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 1606 | * @ipa_tx_diff: tx packet count diff from previous tx packet count |
| 1607 | * @ipa_rx_diff: rx packet count diff from previous rx packet count |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1608 | * |
| 1609 | * Return: true if IPA is enabled, false otherwise |
| 1610 | */ |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 1611 | static void __hdd_ipa_uc_stat_query(hdd_context_t *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1612 | uint32_t *ipa_tx_diff, uint32_t *ipa_rx_diff) |
| 1613 | { |
| 1614 | struct hdd_ipa_priv *hdd_ipa; |
| 1615 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1616 | *ipa_tx_diff = 0; |
| 1617 | *ipa_rx_diff = 0; |
| 1618 | |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 1619 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 1620 | return; |
| 1621 | |
| 1622 | hdd_ipa = (struct hdd_ipa_priv *)hdd_ctx->hdd_ipa; |
| 1623 | |
| 1624 | if (!hdd_ipa_is_enabled(hdd_ctx) || |
| 1625 | !(hdd_ipa_uc_is_enabled(hdd_ctx))) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1626 | return; |
| 1627 | } |
| 1628 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 1629 | qdf_mutex_acquire(&hdd_ipa->ipa_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1630 | if ((HDD_IPA_UC_NUM_WDI_PIPE == hdd_ipa->activated_fw_pipe) && |
| 1631 | (false == hdd_ipa->resource_loading)) { |
| 1632 | *ipa_tx_diff = hdd_ipa->ipa_tx_packets_diff; |
| 1633 | *ipa_rx_diff = hdd_ipa->ipa_rx_packets_diff; |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 1634 | hdd_debug("STAT Query TX DIFF %d, RX DIFF %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1635 | *ipa_tx_diff, *ipa_rx_diff); |
| 1636 | } |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 1637 | qdf_mutex_release(&hdd_ipa->ipa_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1638 | } |
| 1639 | |
| 1640 | /** |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 1641 | * hdd_ipa_uc_stat_query() - SSR wrapper for __hdd_ipa_uc_stat_query |
| 1642 | * @hdd_ctx: Global HDD context |
| 1643 | * @ipa_tx_diff: tx packet count diff from previous tx packet count |
| 1644 | * @ipa_rx_diff: rx packet count diff from previous rx packet count |
| 1645 | * |
| 1646 | * Return: true if IPA is enabled, false otherwise |
| 1647 | */ |
| 1648 | void hdd_ipa_uc_stat_query(hdd_context_t *hdd_ctx, |
| 1649 | uint32_t *ipa_tx_diff, uint32_t *ipa_rx_diff) |
| 1650 | { |
| 1651 | cds_ssr_protect(__func__); |
| 1652 | __hdd_ipa_uc_stat_query(hdd_ctx, ipa_tx_diff, ipa_rx_diff); |
| 1653 | cds_ssr_unprotect(__func__); |
| 1654 | } |
| 1655 | |
| 1656 | /** |
| 1657 | * __hdd_ipa_uc_stat_request() - Get IPA stats from IPA. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1658 | * @adapter: network adapter |
| 1659 | * @reason: STAT REQ Reason |
| 1660 | * |
| 1661 | * Return: None |
| 1662 | */ |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 1663 | static void __hdd_ipa_uc_stat_request(hdd_adapter_t *adapter, uint8_t reason) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1664 | { |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 1665 | hdd_context_t *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1666 | struct hdd_ipa_priv *hdd_ipa; |
| 1667 | |
Yun Park | 637d648 | 2016-10-05 10:51:33 -0700 | [diff] [blame] | 1668 | if (!adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1669 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1670 | |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 1671 | hdd_ctx = (hdd_context_t *)adapter->pHddCtx; |
| 1672 | |
| 1673 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 1674 | return; |
| 1675 | |
| 1676 | hdd_ipa = (struct hdd_ipa_priv *)hdd_ctx->hdd_ipa; |
| 1677 | if (!hdd_ipa_is_enabled(hdd_ctx) || |
| 1678 | !(hdd_ipa_uc_is_enabled(hdd_ctx))) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1679 | return; |
| 1680 | } |
| 1681 | |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 1682 | hdd_debug("STAT REQ Reason %d", reason); |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 1683 | qdf_mutex_acquire(&hdd_ipa->ipa_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1684 | if ((HDD_IPA_UC_NUM_WDI_PIPE == hdd_ipa->activated_fw_pipe) && |
| 1685 | (false == hdd_ipa->resource_loading)) { |
| 1686 | hdd_ipa->stat_req_reason = reason; |
Yun Park | 637d648 | 2016-10-05 10:51:33 -0700 | [diff] [blame] | 1687 | qdf_mutex_release(&hdd_ipa->ipa_lock); |
Sandeep Puligilla | f587adf | 2017-04-27 19:53:21 -0700 | [diff] [blame] | 1688 | sme_ipa_uc_stat_request(WLAN_HDD_GET_HAL_CTX(adapter), |
| 1689 | adapter->sessionId, |
| 1690 | WMA_VDEV_TXRX_GET_IPA_UC_FW_STATS_CMDID, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1691 | 0, VDEV_CMD); |
Yun Park | 637d648 | 2016-10-05 10:51:33 -0700 | [diff] [blame] | 1692 | } else { |
| 1693 | qdf_mutex_release(&hdd_ipa->ipa_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1694 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1695 | } |
| 1696 | |
| 1697 | /** |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 1698 | * hdd_ipa_uc_stat_request() - SSR wrapper for __hdd_ipa_uc_stat_request |
| 1699 | * @adapter: network adapter |
| 1700 | * @reason: STAT REQ Reason |
| 1701 | * |
| 1702 | * Return: None |
| 1703 | */ |
| 1704 | void hdd_ipa_uc_stat_request(hdd_adapter_t *adapter, uint8_t reason) |
| 1705 | { |
| 1706 | cds_ssr_protect(__func__); |
| 1707 | __hdd_ipa_uc_stat_request(adapter, reason); |
| 1708 | cds_ssr_unprotect(__func__); |
| 1709 | } |
| 1710 | |
Yun Park | 637d648 | 2016-10-05 10:51:33 -0700 | [diff] [blame] | 1711 | #ifdef FEATURE_METERING |
| 1712 | /** |
| 1713 | * hdd_ipa_uc_sharing_stats_request() - Get IPA stats from IPA. |
| 1714 | * @adapter: network adapter |
| 1715 | * @reset_stats: reset stat countis after response |
| 1716 | * |
| 1717 | * Return: None |
| 1718 | */ |
| 1719 | void hdd_ipa_uc_sharing_stats_request(hdd_adapter_t *adapter, |
| 1720 | uint8_t reset_stats) |
| 1721 | { |
| 1722 | hdd_context_t *pHddCtx; |
| 1723 | struct hdd_ipa_priv *hdd_ipa; |
| 1724 | |
| 1725 | if (!adapter) |
| 1726 | return; |
| 1727 | |
| 1728 | pHddCtx = adapter->pHddCtx; |
| 1729 | hdd_ipa = pHddCtx->hdd_ipa; |
| 1730 | if (!hdd_ipa_is_enabled(pHddCtx) || |
| 1731 | !(hdd_ipa_uc_is_enabled(pHddCtx))) { |
| 1732 | return; |
| 1733 | } |
| 1734 | |
| 1735 | HDD_IPA_LOG(LOG1, "SHARING_STATS: reset_stats=%d", reset_stats); |
| 1736 | qdf_mutex_acquire(&hdd_ipa->ipa_lock); |
Yun Park | 3374a4b | 2016-12-15 16:52:15 -0800 | [diff] [blame] | 1737 | if (false == hdd_ipa->resource_loading) { |
Yun Park | 637d648 | 2016-10-05 10:51:33 -0700 | [diff] [blame] | 1738 | qdf_mutex_release(&hdd_ipa->ipa_lock); |
| 1739 | wma_cli_set_command( |
| 1740 | (int)adapter->sessionId, |
| 1741 | (int)WMA_VDEV_TXRX_GET_IPA_UC_SHARING_STATS_CMDID, |
| 1742 | reset_stats, VDEV_CMD); |
| 1743 | } else { |
| 1744 | qdf_mutex_release(&hdd_ipa->ipa_lock); |
| 1745 | } |
| 1746 | } |
| 1747 | |
| 1748 | /** |
| 1749 | * hdd_ipa_uc_set_quota() - Set quota limit bytes from IPA. |
| 1750 | * @adapter: network adapter |
| 1751 | * @set_quota: when 1, FW starts quota monitoring |
| 1752 | * @quota_bytes: quota limit in bytes |
| 1753 | * |
| 1754 | * Return: None |
| 1755 | */ |
| 1756 | void hdd_ipa_uc_set_quota(hdd_adapter_t *adapter, uint8_t set_quota, |
| 1757 | uint64_t quota_bytes) |
| 1758 | { |
| 1759 | hdd_context_t *pHddCtx; |
| 1760 | struct hdd_ipa_priv *hdd_ipa; |
| 1761 | |
| 1762 | if (!adapter) |
| 1763 | return; |
| 1764 | |
| 1765 | pHddCtx = adapter->pHddCtx; |
| 1766 | hdd_ipa = pHddCtx->hdd_ipa; |
| 1767 | if (!hdd_ipa_is_enabled(pHddCtx) || |
| 1768 | !(hdd_ipa_uc_is_enabled(pHddCtx))) { |
| 1769 | return; |
| 1770 | } |
| 1771 | |
| 1772 | HDD_IPA_LOG(LOG1, "SET_QUOTA: set_quota=%d, quota_bytes=%llu", |
| 1773 | set_quota, quota_bytes); |
| 1774 | |
| 1775 | qdf_mutex_acquire(&hdd_ipa->ipa_lock); |
Yun Park | 3374a4b | 2016-12-15 16:52:15 -0800 | [diff] [blame] | 1776 | if (false == hdd_ipa->resource_loading) { |
Yun Park | 637d648 | 2016-10-05 10:51:33 -0700 | [diff] [blame] | 1777 | qdf_mutex_release(&hdd_ipa->ipa_lock); |
Yun Park | 327e781 | 2017-02-14 15:18:10 -0800 | [diff] [blame] | 1778 | wma_cli_set2_command( |
Yun Park | 637d648 | 2016-10-05 10:51:33 -0700 | [diff] [blame] | 1779 | (int)adapter->sessionId, |
| 1780 | (int)WMA_VDEV_TXRX_SET_IPA_UC_QUOTA_CMDID, |
Yun Park | 327e781 | 2017-02-14 15:18:10 -0800 | [diff] [blame] | 1781 | (set_quota ? quota_bytes&0xffffffff : 0), |
| 1782 | (set_quota ? quota_bytes>>32 : 0), |
| 1783 | VDEV_CMD); |
Yun Park | 637d648 | 2016-10-05 10:51:33 -0700 | [diff] [blame] | 1784 | } else { |
| 1785 | qdf_mutex_release(&hdd_ipa->ipa_lock); |
| 1786 | } |
| 1787 | } |
| 1788 | #endif |
| 1789 | |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 1790 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1791 | * hdd_ipa_uc_find_add_assoc_sta() - Find associated station |
| 1792 | * @hdd_ipa: Global HDD IPA context |
| 1793 | * @sta_add: Should station be added |
| 1794 | * @sta_id: ID of the station being queried |
| 1795 | * |
| 1796 | * Return: true if the station was found |
| 1797 | */ |
| 1798 | static bool hdd_ipa_uc_find_add_assoc_sta(struct hdd_ipa_priv *hdd_ipa, |
| 1799 | bool sta_add, uint8_t sta_id) |
| 1800 | { |
| 1801 | bool sta_found = false; |
| 1802 | uint8_t idx; |
Srinivas Girigowda | c16ba6d | 2017-03-25 11:43:26 -0700 | [diff] [blame] | 1803 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1804 | for (idx = 0; idx < WLAN_MAX_STA_COUNT; idx++) { |
| 1805 | if ((hdd_ipa->assoc_stas_map[idx].is_reserved) && |
| 1806 | (hdd_ipa->assoc_stas_map[idx].sta_id == sta_id)) { |
| 1807 | sta_found = true; |
| 1808 | break; |
| 1809 | } |
| 1810 | } |
| 1811 | if (sta_add && sta_found) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1812 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 1813 | "STA ID %d already exist, cannot add", sta_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1814 | return sta_found; |
| 1815 | } |
| 1816 | if (sta_add) { |
| 1817 | for (idx = 0; idx < WLAN_MAX_STA_COUNT; idx++) { |
| 1818 | if (!hdd_ipa->assoc_stas_map[idx].is_reserved) { |
| 1819 | hdd_ipa->assoc_stas_map[idx].is_reserved = true; |
| 1820 | hdd_ipa->assoc_stas_map[idx].sta_id = sta_id; |
| 1821 | return sta_found; |
| 1822 | } |
| 1823 | } |
| 1824 | } |
| 1825 | if (!sta_add && !sta_found) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1826 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 1827 | "STA ID %d does not exist, cannot delete", sta_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1828 | return sta_found; |
| 1829 | } |
| 1830 | if (!sta_add) { |
| 1831 | for (idx = 0; idx < WLAN_MAX_STA_COUNT; idx++) { |
| 1832 | if ((hdd_ipa->assoc_stas_map[idx].is_reserved) && |
| 1833 | (hdd_ipa->assoc_stas_map[idx].sta_id == sta_id)) { |
| 1834 | hdd_ipa->assoc_stas_map[idx].is_reserved = |
| 1835 | false; |
| 1836 | hdd_ipa->assoc_stas_map[idx].sta_id = 0xFF; |
| 1837 | return sta_found; |
| 1838 | } |
| 1839 | } |
| 1840 | } |
| 1841 | return sta_found; |
| 1842 | } |
| 1843 | |
| 1844 | /** |
| 1845 | * hdd_ipa_uc_enable_pipes() - Enable IPA uC pipes |
| 1846 | * @hdd_ipa: Global HDD IPA context |
| 1847 | * |
| 1848 | * Return: 0 on success, negative errno if error |
| 1849 | */ |
| 1850 | static int hdd_ipa_uc_enable_pipes(struct hdd_ipa_priv *hdd_ipa) |
| 1851 | { |
| 1852 | int result; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 1853 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 1854 | struct ol_txrx_pdev_t *pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1855 | |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 1856 | result = cdp_ipa_enable_pipes(soc, (struct cdp_pdev *)pdev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1857 | if (result) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1858 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 1859 | "Enable PIPE fail, code %d", result); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1860 | return result; |
| 1861 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1862 | |
Leo Chang | e3e4944 | 2015-10-26 20:07:13 -0700 | [diff] [blame] | 1863 | hdd_ipa->ipa_pipes_down = false; |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 1864 | |
| 1865 | cdp_ipa_enable_autonomy(soc, (struct cdp_pdev *)pdev); |
| 1866 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1867 | return 0; |
| 1868 | } |
| 1869 | |
| 1870 | /** |
| 1871 | * hdd_ipa_uc_disable_pipes() - Disable IPA uC pipes |
| 1872 | * @hdd_ipa: Global HDD IPA context |
| 1873 | * |
| 1874 | * Return: 0 on success, negative errno if error |
| 1875 | */ |
| 1876 | static int hdd_ipa_uc_disable_pipes(struct hdd_ipa_priv *hdd_ipa) |
| 1877 | { |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 1878 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
| 1879 | struct ol_txrx_pdev_t *pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1880 | int result; |
| 1881 | |
Leo Chang | e3e4944 | 2015-10-26 20:07:13 -0700 | [diff] [blame] | 1882 | hdd_ipa->ipa_pipes_down = true; |
| 1883 | |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 1884 | cdp_ipa_disable_autonomy(soc, (struct cdp_pdev *)pdev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1885 | |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 1886 | result = cdp_ipa_disable_pipes(soc, (struct cdp_pdev *)pdev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1887 | if (result) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1888 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 1889 | "Disable WDI PIPE fail, code %d", result); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1890 | return result; |
| 1891 | } |
| 1892 | |
| 1893 | return 0; |
| 1894 | } |
| 1895 | |
| 1896 | /** |
| 1897 | * hdd_ipa_uc_handle_first_con() - Handle first uC IPA connection |
| 1898 | * @hdd_ipa: Global HDD IPA context |
| 1899 | * |
| 1900 | * Return: 0 on success, negative errno if error |
| 1901 | */ |
| 1902 | static int hdd_ipa_uc_handle_first_con(struct hdd_ipa_priv *hdd_ipa) |
| 1903 | { |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 1904 | hdd_context_t *hdd_ctx = hdd_ipa->hdd_ctx; |
| 1905 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1906 | hdd_ipa->activated_fw_pipe = 0; |
| 1907 | hdd_ipa->resource_loading = true; |
Yun Park | 4cab6ee | 2015-10-27 11:43:40 -0700 | [diff] [blame] | 1908 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1909 | /* If RM feature enabled |
| 1910 | * Request PROD Resource first |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 1911 | * PROD resource may return sync or async manners */ |
| 1912 | if (hdd_ipa_is_rm_enabled(hdd_ctx)) { |
Yun Park | 4cab6ee | 2015-10-27 11:43:40 -0700 | [diff] [blame] | 1913 | if (!ipa_rm_request_resource(IPA_RM_RESOURCE_WLAN_PROD)) { |
| 1914 | /* RM PROD request sync return |
| 1915 | * enable pipe immediately |
| 1916 | */ |
| 1917 | if (hdd_ipa_uc_enable_pipes(hdd_ipa)) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1918 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 1919 | "IPA WDI Pipe activation failed"); |
Yun Park | 4cab6ee | 2015-10-27 11:43:40 -0700 | [diff] [blame] | 1920 | hdd_ipa->resource_loading = false; |
| 1921 | return -EBUSY; |
| 1922 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1923 | } |
| 1924 | } else { |
| 1925 | /* RM Disabled |
Yun Park | 4cab6ee | 2015-10-27 11:43:40 -0700 | [diff] [blame] | 1926 | * Just enabled all the PIPEs |
| 1927 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1928 | if (hdd_ipa_uc_enable_pipes(hdd_ipa)) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1929 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 1930 | "IPA WDI Pipe activation failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1931 | hdd_ipa->resource_loading = false; |
| 1932 | return -EBUSY; |
| 1933 | } |
| 1934 | hdd_ipa->resource_loading = false; |
| 1935 | } |
Yun Park | 4cab6ee | 2015-10-27 11:43:40 -0700 | [diff] [blame] | 1936 | |
Srinivas Girigowda | 9785237 | 2017-03-06 16:52:59 -0800 | [diff] [blame] | 1937 | HDD_IPA_LOG(QDF_TRACE_LEVEL_DEBUG, |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 1938 | "IPA WDI Pipes activated successfully"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1939 | return 0; |
| 1940 | } |
| 1941 | |
| 1942 | /** |
| 1943 | * hdd_ipa_uc_handle_last_discon() - Handle last uC IPA disconnection |
| 1944 | * @hdd_ipa: Global HDD IPA context |
| 1945 | * |
| 1946 | * Return: None |
| 1947 | */ |
| 1948 | static void hdd_ipa_uc_handle_last_discon(struct hdd_ipa_priv *hdd_ipa) |
| 1949 | { |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 1950 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 1951 | void *pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1952 | |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 1953 | if (!pdev) { |
Yun Park | 7c4f31b | 2016-11-30 10:09:21 -0800 | [diff] [blame] | 1954 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, "txrx context is NULL"); |
| 1955 | QDF_ASSERT(0); |
| 1956 | return; |
| 1957 | } |
| 1958 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1959 | hdd_ipa->resource_unloading = true; |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 1960 | HDD_IPA_LOG(QDF_TRACE_LEVEL_DEBUG, "Disable FW RX PIPE"); |
| 1961 | cdp_ipa_set_active(soc, (struct cdp_pdev *)pdev, false, false); |
| 1962 | HDD_IPA_LOG(QDF_TRACE_LEVEL_DEBUG, "Disable FW TX PIPE"); |
| 1963 | cdp_ipa_set_active(soc, (struct cdp_pdev *)pdev, false, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1964 | } |
| 1965 | |
| 1966 | /** |
| 1967 | * hdd_ipa_uc_rm_notify_handler() - IPA uC resource notification handler |
| 1968 | * @context: User context registered with TL (the IPA Global context is |
| 1969 | * registered |
| 1970 | * @rxpkt: Packet containing the notification |
| 1971 | * @staid: ID of the station associated with the packet |
| 1972 | * |
| 1973 | * Return: None |
| 1974 | */ |
| 1975 | static void |
| 1976 | hdd_ipa_uc_rm_notify_handler(void *context, enum ipa_rm_event event) |
| 1977 | { |
| 1978 | struct hdd_ipa_priv *hdd_ipa = context; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1979 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 1980 | hdd_context_t *hdd_ctx = hdd_ipa->hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1981 | |
| 1982 | /* |
| 1983 | * When SSR is going on or driver is unloading, just return. |
| 1984 | */ |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 1985 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 1986 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1987 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1988 | |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 1989 | if (!hdd_ipa_is_rm_enabled(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1990 | return; |
| 1991 | |
Srinivas Girigowda | 9785237 | 2017-03-06 16:52:59 -0800 | [diff] [blame] | 1992 | HDD_IPA_LOG(QDF_TRACE_LEVEL_DEBUG, "%s, event code %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1993 | __func__, event); |
| 1994 | |
| 1995 | switch (event) { |
| 1996 | case IPA_RM_RESOURCE_GRANTED: |
| 1997 | /* Differed RM Granted */ |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 1998 | qdf_mutex_acquire(&hdd_ipa->ipa_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1999 | if ((false == hdd_ipa->resource_unloading) && |
| 2000 | (!hdd_ipa->activated_fw_pipe)) { |
| 2001 | hdd_ipa_uc_enable_pipes(hdd_ipa); |
| 2002 | } |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 2003 | qdf_mutex_release(&hdd_ipa->ipa_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2004 | break; |
| 2005 | |
| 2006 | case IPA_RM_RESOURCE_RELEASED: |
| 2007 | /* Differed RM Released */ |
| 2008 | hdd_ipa->resource_unloading = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2009 | break; |
| 2010 | |
| 2011 | default: |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 2012 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2013 | "%s, invalid event code %d", __func__, event); |
| 2014 | break; |
| 2015 | } |
| 2016 | } |
| 2017 | |
| 2018 | /** |
| 2019 | * hdd_ipa_uc_rm_notify_defer() - Defer IPA uC notification |
| 2020 | * @hdd_ipa: Global HDD IPA context |
| 2021 | * @event: IPA resource manager event to be deferred |
| 2022 | * |
| 2023 | * This function is called when a resource manager event is received |
| 2024 | * from firmware in interrupt context. This function will defer the |
| 2025 | * handling to the OL RX thread |
| 2026 | * |
| 2027 | * Return: None |
| 2028 | */ |
| 2029 | static void hdd_ipa_uc_rm_notify_defer(struct work_struct *work) |
| 2030 | { |
| 2031 | enum ipa_rm_event event; |
| 2032 | struct uc_rm_work_struct *uc_rm_work = container_of(work, |
| 2033 | struct uc_rm_work_struct, work); |
| 2034 | struct hdd_ipa_priv *hdd_ipa = container_of(uc_rm_work, |
| 2035 | struct hdd_ipa_priv, uc_rm_work); |
| 2036 | |
| 2037 | cds_ssr_protect(__func__); |
| 2038 | event = uc_rm_work->event; |
Srinivas Girigowda | 9785237 | 2017-03-06 16:52:59 -0800 | [diff] [blame] | 2039 | HDD_IPA_LOG(QDF_TRACE_LEVEL_DEBUG, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2040 | "%s, posted event %d", __func__, event); |
| 2041 | |
| 2042 | hdd_ipa_uc_rm_notify_handler(hdd_ipa, event); |
| 2043 | cds_ssr_unprotect(__func__); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2044 | } |
| 2045 | |
| 2046 | /** |
Manikandan Mohan | 153a4c3 | 2017-02-16 15:04:30 -0800 | [diff] [blame] | 2047 | * hdd_ipa_uc_loaded_handler() - Process IPA uC loaded indication |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 2048 | * @hdd_ipa: hdd ipa local context |
Manikandan Mohan | 153a4c3 | 2017-02-16 15:04:30 -0800 | [diff] [blame] | 2049 | * |
| 2050 | * Will handle IPA UC image loaded indication comes from IPA kernel |
| 2051 | * |
| 2052 | * Return: None |
| 2053 | */ |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 2054 | static void hdd_ipa_uc_loaded_handler(struct hdd_ipa_priv *hdd_ipa) |
Manikandan Mohan | 153a4c3 | 2017-02-16 15:04:30 -0800 | [diff] [blame] | 2055 | { |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 2056 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
| 2057 | void *pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
| 2058 | hdd_context_t *hdd_ctx; |
| 2059 | QDF_STATUS status; |
Manikandan Mohan | 153a4c3 | 2017-02-16 15:04:30 -0800 | [diff] [blame] | 2060 | |
| 2061 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, "%s : UC READY", __func__); |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 2062 | if (true == hdd_ipa->uc_loaded) { |
Srinivas Girigowda | 9785237 | 2017-03-06 16:52:59 -0800 | [diff] [blame] | 2063 | HDD_IPA_LOG(QDF_TRACE_LEVEL_DEBUG, "%s : UC already loaded", |
Manikandan Mohan | 153a4c3 | 2017-02-16 15:04:30 -0800 | [diff] [blame] | 2064 | __func__); |
| 2065 | return; |
| 2066 | } |
| 2067 | |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 2068 | hdd_ctx = hdd_ipa->hdd_ctx; |
| 2069 | hdd_ipa->uc_loaded = true; |
Manikandan Mohan | 153a4c3 | 2017-02-16 15:04:30 -0800 | [diff] [blame] | 2070 | |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 2071 | /* Connect pipe */ |
| 2072 | status = cdp_ipa_setup(soc, (struct cdp_pdev *)pdev, |
| 2073 | hdd_ipa_i2w_cb, hdd_ipa_w2i_cb, |
| 2074 | hdd_ipa_wdi_meter_notifier_cb, |
| 2075 | hdd_ctx->config->IpaDescSize, |
| 2076 | hdd_ipa, hdd_ipa_is_rm_enabled(hdd_ctx), |
| 2077 | &hdd_ipa->tx_pipe_handle, |
| 2078 | &hdd_ipa->rx_pipe_handle); |
| 2079 | if (status) { |
| 2080 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
| 2081 | "Failure to setup IPA pipes (status=%d)", |
| 2082 | status); |
| 2083 | return; |
| 2084 | } |
| 2085 | |
| 2086 | cdp_ipa_set_doorbell_paddr(soc, (struct cdp_pdev *)pdev); |
Manikandan Mohan | 153a4c3 | 2017-02-16 15:04:30 -0800 | [diff] [blame] | 2087 | |
| 2088 | /* If already any STA connected, enable IPA/FW PIPEs */ |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 2089 | if (hdd_ipa->sap_num_connected_sta) { |
Srinivas Girigowda | 9785237 | 2017-03-06 16:52:59 -0800 | [diff] [blame] | 2090 | HDD_IPA_LOG(QDF_TRACE_LEVEL_DEBUG, |
Manikandan Mohan | 153a4c3 | 2017-02-16 15:04:30 -0800 | [diff] [blame] | 2091 | "Client already connected, enable IPA/FW PIPEs"); |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 2092 | hdd_ipa_uc_handle_first_con(hdd_ipa); |
Manikandan Mohan | 153a4c3 | 2017-02-16 15:04:30 -0800 | [diff] [blame] | 2093 | } |
| 2094 | } |
| 2095 | |
| 2096 | /** |
Yun Park | 637d648 | 2016-10-05 10:51:33 -0700 | [diff] [blame] | 2097 | * hdd_ipa_uc_op_metering() - IPA uC operation for stats and quota limit |
| 2098 | * @hdd_ctx: Global HDD context |
| 2099 | * @op_msg: operation message received from firmware |
| 2100 | * |
| 2101 | * Return: QDF_STATUS enumeration |
| 2102 | */ |
| 2103 | #ifdef FEATURE_METERING |
| 2104 | static QDF_STATUS hdd_ipa_uc_op_metering(hdd_context_t *hdd_ctx, |
| 2105 | struct op_msg_type *op_msg) |
| 2106 | { |
| 2107 | struct op_msg_type *msg = op_msg; |
| 2108 | struct ipa_uc_sharing_stats *uc_sharing_stats; |
| 2109 | struct ipa_uc_quota_rsp *uc_quota_rsp; |
| 2110 | struct ipa_uc_quota_ind *uc_quota_ind; |
| 2111 | struct hdd_ipa_priv *hdd_ipa; |
| 2112 | hdd_adapter_t *adapter; |
| 2113 | |
| 2114 | hdd_ipa = (struct hdd_ipa_priv *)hdd_ctx->hdd_ipa; |
| 2115 | |
| 2116 | if (HDD_IPA_UC_OPCODE_SHARING_STATS == msg->op_code) { |
| 2117 | /* fill-up ipa_uc_sharing_stats structure from FW */ |
| 2118 | uc_sharing_stats = (struct ipa_uc_sharing_stats *) |
| 2119 | ((uint8_t *)op_msg + sizeof(struct op_msg_type)); |
| 2120 | |
| 2121 | memcpy(&(hdd_ipa->ipa_sharing_stats), uc_sharing_stats, |
| 2122 | sizeof(struct ipa_uc_sharing_stats)); |
| 2123 | |
| 2124 | complete(&hdd_ipa->ipa_uc_sharing_stats_comp); |
| 2125 | |
| 2126 | HDD_IPA_DP_LOG(QDF_TRACE_LEVEL_DEBUG, |
| 2127 | "%s: %llu,%llu,%llu,%llu,%llu,%llu,%llu,%llu", |
| 2128 | "HDD_IPA_UC_OPCODE_SHARING_STATS", |
| 2129 | hdd_ipa->ipa_sharing_stats.ipv4_rx_packets, |
| 2130 | hdd_ipa->ipa_sharing_stats.ipv4_rx_bytes, |
| 2131 | hdd_ipa->ipa_sharing_stats.ipv6_rx_packets, |
| 2132 | hdd_ipa->ipa_sharing_stats.ipv6_rx_bytes, |
| 2133 | hdd_ipa->ipa_sharing_stats.ipv4_tx_packets, |
| 2134 | hdd_ipa->ipa_sharing_stats.ipv4_tx_bytes, |
| 2135 | hdd_ipa->ipa_sharing_stats.ipv6_tx_packets, |
| 2136 | hdd_ipa->ipa_sharing_stats.ipv6_tx_bytes); |
| 2137 | } else if (HDD_IPA_UC_OPCODE_QUOTA_RSP == msg->op_code) { |
| 2138 | /* received set quota response */ |
| 2139 | uc_quota_rsp = (struct ipa_uc_quota_rsp *) |
| 2140 | ((uint8_t *)op_msg + sizeof(struct op_msg_type)); |
| 2141 | |
| 2142 | memcpy(&(hdd_ipa->ipa_quota_rsp), uc_quota_rsp, |
| 2143 | sizeof(struct ipa_uc_quota_rsp)); |
| 2144 | |
| 2145 | complete(&hdd_ipa->ipa_uc_set_quota_comp); |
| 2146 | HDD_IPA_DP_LOG(QDF_TRACE_LEVEL_DEBUG, |
| 2147 | "%s: success=%d, quota_bytes=%llu", |
| 2148 | "HDD_IPA_UC_OPCODE_QUOTA_RSP", |
| 2149 | hdd_ipa->ipa_quota_rsp.success, |
| 2150 | ((uint64_t)(hdd_ipa->ipa_quota_rsp.quota_hi)<<32)| |
| 2151 | hdd_ipa->ipa_quota_rsp.quota_lo); |
| 2152 | } else if (HDD_IPA_UC_OPCODE_QUOTA_IND == msg->op_code) { |
| 2153 | /* hit quota limit */ |
| 2154 | uc_quota_ind = (struct ipa_uc_quota_ind *) |
| 2155 | ((uint8_t *)op_msg + sizeof(struct op_msg_type)); |
| 2156 | |
| 2157 | hdd_ipa->ipa_quota_ind.quota_bytes = |
| 2158 | uc_quota_ind->quota_bytes; |
| 2159 | |
| 2160 | /* send quota exceeded indication to IPA */ |
| 2161 | HDD_IPA_DP_LOG(QDF_TRACE_LEVEL_DEBUG, |
| 2162 | "OPCODE_QUOTA_IND: quota exceed! (quota_bytes=%llu)", |
| 2163 | hdd_ipa->ipa_quota_ind.quota_bytes); |
| 2164 | |
| 2165 | adapter = hdd_get_adapter(hdd_ipa->hdd_ctx, QDF_STA_MODE); |
| 2166 | if (adapter) |
| 2167 | ipa_broadcast_wdi_quota_reach_ind( |
| 2168 | adapter->dev->ifindex, |
| 2169 | uc_quota_ind->quota_bytes); |
| 2170 | else |
| 2171 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
| 2172 | "Failed quota_reach_ind: NULL adapter"); |
| 2173 | } else { |
| 2174 | return QDF_STATUS_E_INVAL; |
| 2175 | } |
| 2176 | |
| 2177 | return QDF_STATUS_SUCCESS; |
| 2178 | } |
| 2179 | #else |
| 2180 | static QDF_STATUS hdd_ipa_uc_op_metering(hdd_context_t *hdd_ctx, |
| 2181 | struct op_msg_type *op_msg) |
| 2182 | { |
| 2183 | return QDF_STATUS_E_INVAL; |
| 2184 | } |
| 2185 | #endif |
| 2186 | |
| 2187 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2188 | * hdd_ipa_uc_op_cb() - IPA uC operation callback |
| 2189 | * @op_msg: operation message received from firmware |
| 2190 | * @usr_ctxt: user context registered with TL (we register the HDD Global |
| 2191 | * context) |
| 2192 | * |
| 2193 | * Return: None |
| 2194 | */ |
| 2195 | static void hdd_ipa_uc_op_cb(struct op_msg_type *op_msg, void *usr_ctxt) |
| 2196 | { |
| 2197 | struct op_msg_type *msg = op_msg; |
| 2198 | struct ipa_uc_fw_stats *uc_fw_stat; |
| 2199 | struct IpaHwStatsWDIInfoData_t ipa_stat; |
| 2200 | struct hdd_ipa_priv *hdd_ipa; |
| 2201 | hdd_context_t *hdd_ctx; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2202 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2203 | |
| 2204 | if (!op_msg || !usr_ctxt) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 2205 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, "%s, INVALID ARG", __func__); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2206 | return; |
| 2207 | } |
| 2208 | |
| 2209 | if (HDD_IPA_UC_OPCODE_MAX <= msg->op_code) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 2210 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2211 | "%s, INVALID OPCODE %d", __func__, msg->op_code); |
jiad | d91a684 | 2017-08-01 14:46:02 +0800 | [diff] [blame] | 2212 | qdf_mem_free(op_msg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2213 | return; |
| 2214 | } |
| 2215 | |
| 2216 | hdd_ctx = (hdd_context_t *) usr_ctxt; |
| 2217 | |
| 2218 | /* |
| 2219 | * When SSR is going on or driver is unloading, just return. |
| 2220 | */ |
| 2221 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 2222 | if (status) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2223 | qdf_mem_free(op_msg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2224 | return; |
| 2225 | } |
| 2226 | |
| 2227 | hdd_ipa = (struct hdd_ipa_priv *)hdd_ctx->hdd_ipa; |
| 2228 | |
Govind Singh | b6a8977 | 2016-08-12 11:23:35 +0530 | [diff] [blame] | 2229 | HDD_IPA_DP_LOG(QDF_TRACE_LEVEL_DEBUG, |
Yun Park | 5f0fc23 | 2017-02-10 10:34:57 -0800 | [diff] [blame] | 2230 | "OPCODE=%d", msg->op_code); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2231 | |
| 2232 | if ((HDD_IPA_UC_OPCODE_TX_RESUME == msg->op_code) || |
| 2233 | (HDD_IPA_UC_OPCODE_RX_RESUME == msg->op_code)) { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 2234 | qdf_mutex_acquire(&hdd_ipa->ipa_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2235 | hdd_ipa->activated_fw_pipe++; |
| 2236 | if (HDD_IPA_UC_NUM_WDI_PIPE == hdd_ipa->activated_fw_pipe) { |
| 2237 | hdd_ipa->resource_loading = false; |
Manikandan Mohan | cd64c0b | 2017-03-08 13:00:24 -0800 | [diff] [blame] | 2238 | if (hdd_ipa->wdi_enabled == false) { |
| 2239 | hdd_ipa->wdi_enabled = true; |
| 2240 | if (hdd_ipa_uc_send_wdi_control_msg(true) == 0) |
| 2241 | hdd_ipa_send_mcc_scc_msg(hdd_ctx, |
| 2242 | hdd_ctx->mcc_mode); |
Manikandan Mohan | 153a4c3 | 2017-02-16 15:04:30 -0800 | [diff] [blame] | 2243 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2244 | hdd_ipa_uc_proc_pending_event(hdd_ipa); |
Yun Park | ccc6d7a | 2015-12-02 14:50:13 -0800 | [diff] [blame] | 2245 | if (hdd_ipa->pending_cons_req) |
| 2246 | ipa_rm_notify_completion( |
| 2247 | IPA_RM_RESOURCE_GRANTED, |
| 2248 | IPA_RM_RESOURCE_WLAN_CONS); |
Yun Park | 5b63501 | 2015-12-02 15:05:01 -0800 | [diff] [blame] | 2249 | hdd_ipa->pending_cons_req = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2250 | } |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 2251 | qdf_mutex_release(&hdd_ipa->ipa_lock); |
Yun Park | 8292dcb | 2016-10-07 16:46:06 -0700 | [diff] [blame] | 2252 | } else if ((HDD_IPA_UC_OPCODE_TX_SUSPEND == msg->op_code) || |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2253 | (HDD_IPA_UC_OPCODE_RX_SUSPEND == msg->op_code)) { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 2254 | qdf_mutex_acquire(&hdd_ipa->ipa_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2255 | hdd_ipa->activated_fw_pipe--; |
| 2256 | if (!hdd_ipa->activated_fw_pipe) { |
| 2257 | hdd_ipa_uc_disable_pipes(hdd_ipa); |
Yun Park | 5b63501 | 2015-12-02 15:05:01 -0800 | [diff] [blame] | 2258 | if (hdd_ipa_is_rm_enabled(hdd_ipa->hdd_ctx)) |
| 2259 | ipa_rm_release_resource( |
| 2260 | IPA_RM_RESOURCE_WLAN_PROD); |
Jeff Johnson | faa63b8 | 2017-01-12 09:46:43 -0800 | [diff] [blame] | 2261 | /* |
| 2262 | * Sync return success from IPA |
| 2263 | * Enable/resume all the PIPEs |
| 2264 | */ |
Yun Park | 5b63501 | 2015-12-02 15:05:01 -0800 | [diff] [blame] | 2265 | hdd_ipa->resource_unloading = false; |
| 2266 | hdd_ipa_uc_proc_pending_event(hdd_ipa); |
| 2267 | hdd_ipa->pending_cons_req = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2268 | } |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 2269 | qdf_mutex_release(&hdd_ipa->ipa_lock); |
Yun Park | 8292dcb | 2016-10-07 16:46:06 -0700 | [diff] [blame] | 2270 | } else if ((HDD_IPA_UC_OPCODE_STATS == msg->op_code) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2271 | (HDD_IPA_UC_STAT_REASON_DEBUG == hdd_ipa->stat_req_reason)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2272 | /* STATs from host */ |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 2273 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2274 | "==== IPA_UC WLAN_HOST RX ====\n" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2275 | "NUM EXCP PKT : %llu\n" |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 2276 | "NUM TX FWD OK : %llu\n" |
| 2277 | "NUM TX FWD ERR : %llu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2278 | hdd_ipa->stats.num_rx_excep, |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 2279 | hdd_ipa->stats.num_tx_fwd_ok, |
| 2280 | hdd_ipa->stats.num_tx_fwd_err); |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 2281 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2282 | "==== IPA_UC WLAN_HOST CONTROL ====\n" |
| 2283 | "SAP NUM STAs: %d\n" |
| 2284 | "STA CONNECTED: %d\n" |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 2285 | "CONCURRENT MODE: %s\n" |
| 2286 | "TX PIPE HDL: 0x%x\n" |
| 2287 | "RX PIPE HDL : 0x%x\n" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2288 | "RSC LOADING : %d\n" |
| 2289 | "RSC UNLOADING : %d\n" |
| 2290 | "PNDNG CNS RQT : %d", |
| 2291 | hdd_ipa->sap_num_connected_sta, |
| 2292 | hdd_ipa->sta_connected, |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 2293 | (hdd_ctx->mcc_mode ? "MCC" : "SCC"), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2294 | hdd_ipa->tx_pipe_handle, |
| 2295 | hdd_ipa->rx_pipe_handle, |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 2296 | hdd_ipa->resource_loading, |
| 2297 | hdd_ipa->resource_unloading, |
| 2298 | hdd_ipa->pending_cons_req); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2299 | |
| 2300 | /* STATs from FW */ |
| 2301 | uc_fw_stat = (struct ipa_uc_fw_stats *) |
| 2302 | ((uint8_t *)op_msg + sizeof(struct op_msg_type)); |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 2303 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2304 | "==== IPA_UC WLAN_FW TX ====\n" |
| 2305 | "COMP RING BASE: 0x%x\n" |
| 2306 | "COMP RING SIZE: %d\n" |
| 2307 | "COMP RING DBELL : 0x%x\n" |
| 2308 | "COMP RING DBELL IND VAL : %d\n" |
| 2309 | "COMP RING DBELL CACHED VAL : %d\n" |
| 2310 | "COMP RING DBELL CACHED VAL : %d\n" |
| 2311 | "PKTS ENQ : %d\n" |
| 2312 | "PKTS COMP : %d\n" |
| 2313 | "IS SUSPEND : %d\n" |
| 2314 | "RSVD : 0x%x", |
| 2315 | uc_fw_stat->tx_comp_ring_base, |
| 2316 | uc_fw_stat->tx_comp_ring_size, |
| 2317 | uc_fw_stat->tx_comp_ring_dbell_addr, |
| 2318 | uc_fw_stat->tx_comp_ring_dbell_ind_val, |
| 2319 | uc_fw_stat->tx_comp_ring_dbell_cached_val, |
| 2320 | uc_fw_stat->tx_comp_ring_dbell_cached_val, |
| 2321 | uc_fw_stat->tx_pkts_enqueued, |
| 2322 | uc_fw_stat->tx_pkts_completed, |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 2323 | uc_fw_stat->tx_is_suspend, |
| 2324 | uc_fw_stat->tx_reserved); |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 2325 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2326 | "==== IPA_UC WLAN_FW RX ====\n" |
| 2327 | "IND RING BASE: 0x%x\n" |
| 2328 | "IND RING SIZE: %d\n" |
| 2329 | "IND RING DBELL : 0x%x\n" |
| 2330 | "IND RING DBELL IND VAL : %d\n" |
| 2331 | "IND RING DBELL CACHED VAL : %d\n" |
| 2332 | "RDY IND ADDR : 0x%x\n" |
| 2333 | "RDY IND CACHE VAL : %d\n" |
| 2334 | "RFIL IND : %d\n" |
| 2335 | "NUM PKT INDICAT : %d\n" |
| 2336 | "BUF REFIL : %d\n" |
| 2337 | "NUM DROP NO SPC : %d\n" |
| 2338 | "NUM DROP NO BUF : %d\n" |
| 2339 | "IS SUSPND : %d\n" |
| 2340 | "RSVD : 0x%x\n", |
| 2341 | uc_fw_stat->rx_ind_ring_base, |
| 2342 | uc_fw_stat->rx_ind_ring_size, |
| 2343 | uc_fw_stat->rx_ind_ring_dbell_addr, |
| 2344 | uc_fw_stat->rx_ind_ring_dbell_ind_val, |
| 2345 | uc_fw_stat->rx_ind_ring_dbell_ind_cached_val, |
| 2346 | uc_fw_stat->rx_ind_ring_rdidx_addr, |
| 2347 | uc_fw_stat->rx_ind_ring_rd_idx_cached_val, |
| 2348 | uc_fw_stat->rx_refill_idx, |
| 2349 | uc_fw_stat->rx_num_pkts_indicated, |
| 2350 | uc_fw_stat->rx_buf_refilled, |
| 2351 | uc_fw_stat->rx_num_ind_drop_no_space, |
| 2352 | uc_fw_stat->rx_num_ind_drop_no_buf, |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 2353 | uc_fw_stat->rx_is_suspend, |
| 2354 | uc_fw_stat->rx_reserved); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2355 | /* STATs from IPA */ |
| 2356 | ipa_get_wdi_stats(&ipa_stat); |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 2357 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2358 | "==== IPA_UC IPA TX ====\n" |
| 2359 | "NUM PROCD : %d\n" |
| 2360 | "CE DBELL : 0x%x\n" |
| 2361 | "NUM DBELL FIRED : %d\n" |
| 2362 | "COMP RNG FULL : %d\n" |
| 2363 | "COMP RNG EMPT : %d\n" |
| 2364 | "COMP RNG USE HGH : %d\n" |
| 2365 | "COMP RNG USE LOW : %d\n" |
| 2366 | "BAM FIFO FULL : %d\n" |
| 2367 | "BAM FIFO EMPT : %d\n" |
| 2368 | "BAM FIFO USE HGH : %d\n" |
| 2369 | "BAM FIFO USE LOW : %d\n" |
| 2370 | "NUM DBELL : %d\n" |
| 2371 | "NUM UNEXP DBELL : %d\n" |
| 2372 | "NUM BAM INT HDL : 0x%x\n" |
| 2373 | "NUM BAM INT NON-RUN : 0x%x\n" |
| 2374 | "NUM QMB INT HDL : 0x%x", |
| 2375 | ipa_stat.tx_ch_stats.num_pkts_processed, |
| 2376 | ipa_stat.tx_ch_stats.copy_engine_doorbell_value, |
| 2377 | ipa_stat.tx_ch_stats.num_db_fired, |
| 2378 | ipa_stat.tx_ch_stats.tx_comp_ring_stats.ringFull, |
| 2379 | ipa_stat.tx_ch_stats.tx_comp_ring_stats.ringEmpty, |
| 2380 | ipa_stat.tx_ch_stats.tx_comp_ring_stats.ringUsageHigh, |
| 2381 | ipa_stat.tx_ch_stats.tx_comp_ring_stats.ringUsageLow, |
| 2382 | ipa_stat.tx_ch_stats.bam_stats.bamFifoFull, |
| 2383 | ipa_stat.tx_ch_stats.bam_stats.bamFifoEmpty, |
| 2384 | ipa_stat.tx_ch_stats.bam_stats.bamFifoUsageHigh, |
| 2385 | ipa_stat.tx_ch_stats.bam_stats.bamFifoUsageLow, |
| 2386 | ipa_stat.tx_ch_stats.num_db, |
| 2387 | ipa_stat.tx_ch_stats.num_unexpected_db, |
| 2388 | ipa_stat.tx_ch_stats.num_bam_int_handled, |
| 2389 | ipa_stat.tx_ch_stats. |
| 2390 | num_bam_int_in_non_runnning_state, |
| 2391 | ipa_stat.tx_ch_stats.num_qmb_int_handled); |
| 2392 | |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 2393 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2394 | "==== IPA_UC IPA RX ====\n" |
| 2395 | "MAX OST PKT : %d\n" |
| 2396 | "NUM PKT PRCSD : %d\n" |
| 2397 | "RNG RP : 0x%x\n" |
| 2398 | "COMP RNG FULL : %d\n" |
| 2399 | "COMP RNG EMPT : %d\n" |
| 2400 | "COMP RNG USE HGH : %d\n" |
| 2401 | "COMP RNG USE LOW : %d\n" |
| 2402 | "BAM FIFO FULL : %d\n" |
| 2403 | "BAM FIFO EMPT : %d\n" |
| 2404 | "BAM FIFO USE HGH : %d\n" |
| 2405 | "BAM FIFO USE LOW : %d\n" |
| 2406 | "NUM DB : %d\n" |
| 2407 | "NUM UNEXP DB : %d\n" |
| 2408 | "NUM BAM INT HNDL : 0x%x\n", |
| 2409 | ipa_stat.rx_ch_stats.max_outstanding_pkts, |
| 2410 | ipa_stat.rx_ch_stats.num_pkts_processed, |
| 2411 | ipa_stat.rx_ch_stats.rx_ring_rp_value, |
| 2412 | ipa_stat.rx_ch_stats.rx_ind_ring_stats.ringFull, |
| 2413 | ipa_stat.rx_ch_stats.rx_ind_ring_stats.ringEmpty, |
| 2414 | ipa_stat.rx_ch_stats.rx_ind_ring_stats.ringUsageHigh, |
| 2415 | ipa_stat.rx_ch_stats.rx_ind_ring_stats.ringUsageLow, |
| 2416 | ipa_stat.rx_ch_stats.bam_stats.bamFifoFull, |
| 2417 | ipa_stat.rx_ch_stats.bam_stats.bamFifoEmpty, |
| 2418 | ipa_stat.rx_ch_stats.bam_stats.bamFifoUsageHigh, |
| 2419 | ipa_stat.rx_ch_stats.bam_stats.bamFifoUsageLow, |
| 2420 | ipa_stat.rx_ch_stats.num_db, |
| 2421 | ipa_stat.rx_ch_stats.num_unexpected_db, |
| 2422 | ipa_stat.rx_ch_stats.num_bam_int_handled); |
| 2423 | } else if ((HDD_IPA_UC_OPCODE_STATS == msg->op_code) && |
| 2424 | (HDD_IPA_UC_STAT_REASON_BW_CAL == hdd_ipa->stat_req_reason)) { |
| 2425 | /* STATs from FW */ |
| 2426 | uc_fw_stat = (struct ipa_uc_fw_stats *) |
| 2427 | ((uint8_t *)op_msg + sizeof(struct op_msg_type)); |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 2428 | qdf_mutex_acquire(&hdd_ipa->ipa_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2429 | hdd_ipa->ipa_tx_packets_diff = HDD_BW_GET_DIFF( |
| 2430 | uc_fw_stat->tx_pkts_completed, |
| 2431 | hdd_ipa->ipa_p_tx_packets); |
| 2432 | hdd_ipa->ipa_rx_packets_diff = HDD_BW_GET_DIFF( |
| 2433 | (uc_fw_stat->rx_num_ind_drop_no_space + |
| 2434 | uc_fw_stat->rx_num_ind_drop_no_buf + |
| 2435 | uc_fw_stat->rx_num_pkts_indicated), |
| 2436 | hdd_ipa->ipa_p_rx_packets); |
| 2437 | |
| 2438 | hdd_ipa->ipa_p_tx_packets = uc_fw_stat->tx_pkts_completed; |
| 2439 | hdd_ipa->ipa_p_rx_packets = |
| 2440 | (uc_fw_stat->rx_num_ind_drop_no_space + |
| 2441 | uc_fw_stat->rx_num_ind_drop_no_buf + |
| 2442 | uc_fw_stat->rx_num_pkts_indicated); |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 2443 | qdf_mutex_release(&hdd_ipa->ipa_lock); |
Manikandan Mohan | 153a4c3 | 2017-02-16 15:04:30 -0800 | [diff] [blame] | 2444 | } else if (msg->op_code == HDD_IPA_UC_OPCODE_UC_READY) { |
| 2445 | qdf_mutex_acquire(&hdd_ipa->ipa_lock); |
| 2446 | hdd_ipa_uc_loaded_handler(hdd_ipa); |
| 2447 | qdf_mutex_release(&hdd_ipa->ipa_lock); |
Yun Park | 637d648 | 2016-10-05 10:51:33 -0700 | [diff] [blame] | 2448 | } else if (hdd_ipa_uc_op_metering(hdd_ctx, op_msg)) { |
| 2449 | HDD_IPA_LOG(LOGE, "Invalid message: op_code=%d, reason=%d", |
| 2450 | msg->op_code, hdd_ipa->stat_req_reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2451 | } |
Yun Park | 8957d80 | 2017-01-25 12:27:29 -0800 | [diff] [blame] | 2452 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2453 | qdf_mem_free(op_msg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2454 | } |
| 2455 | |
| 2456 | |
| 2457 | /** |
| 2458 | * hdd_ipa_uc_offload_enable_disable() - wdi enable/disable notify to fw |
| 2459 | * @adapter: device adapter instance |
| 2460 | * @offload_type: MCC or SCC |
| 2461 | * @enable: TX offload enable or disable |
| 2462 | * |
| 2463 | * Return: none |
| 2464 | */ |
| 2465 | static void hdd_ipa_uc_offload_enable_disable(hdd_adapter_t *adapter, |
Prakash Dhavali | 89d406d | 2016-11-23 11:11:00 -0800 | [diff] [blame] | 2466 | uint32_t offload_type, bool enable) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2467 | { |
Prakash Dhavali | 89d406d | 2016-11-23 11:11:00 -0800 | [diff] [blame] | 2468 | struct hdd_ipa_priv *hdd_ipa = ghdd_ipa; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2469 | struct sir_ipa_offload_enable_disable ipa_offload_enable_disable; |
Yun Park | 8292dcb | 2016-10-07 16:46:06 -0700 | [diff] [blame] | 2470 | struct hdd_ipa_iface_context *iface_context = NULL; |
Prakash Dhavali | 89d406d | 2016-11-23 11:11:00 -0800 | [diff] [blame] | 2471 | uint8_t session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2472 | |
Prakash Dhavali | 89d406d | 2016-11-23 11:11:00 -0800 | [diff] [blame] | 2473 | if (!adapter || !hdd_ipa) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2474 | return; |
| 2475 | |
Yun Park | 8292dcb | 2016-10-07 16:46:06 -0700 | [diff] [blame] | 2476 | iface_context = adapter->ipa_context; |
Prakash Dhavali | 89d406d | 2016-11-23 11:11:00 -0800 | [diff] [blame] | 2477 | session_id = adapter->sessionId; |
Yun Park | 8292dcb | 2016-10-07 16:46:06 -0700 | [diff] [blame] | 2478 | |
Prakash Dhavali | 89d406d | 2016-11-23 11:11:00 -0800 | [diff] [blame] | 2479 | if (!iface_context) { |
| 2480 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
| 2481 | "Interface context is NULL"); |
| 2482 | return; |
| 2483 | } |
Zhu Jianmin | ded9d2d | 2017-06-22 09:39:36 +0800 | [diff] [blame] | 2484 | if (session_id >= CSR_ROAM_SESSION_MAX) { |
| 2485 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
| 2486 | "invalid session id: %d", session_id); |
| 2487 | return; |
| 2488 | } |
Prakash Dhavali | 89d406d | 2016-11-23 11:11:00 -0800 | [diff] [blame] | 2489 | if (enable == hdd_ipa->vdev_offload_enabled[session_id]) { |
Yun Park | 8292dcb | 2016-10-07 16:46:06 -0700 | [diff] [blame] | 2490 | /* IPA offload status is already set as desired */ |
| 2491 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 2492 | "%s (offload_type=%d, vdev_id=%d, enable=%d)", |
Prakash Dhavali | 89d406d | 2016-11-23 11:11:00 -0800 | [diff] [blame] | 2493 | "IPA offload status is already set", |
| 2494 | offload_type, session_id, enable); |
Yun Park | 8292dcb | 2016-10-07 16:46:06 -0700 | [diff] [blame] | 2495 | return; |
| 2496 | } |
| 2497 | |
Yun Park | 4540e86 | 2016-11-10 16:30:06 -0800 | [diff] [blame] | 2498 | if (wlan_hdd_validate_session_id(adapter->sessionId)) { |
| 2499 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
| 2500 | "invalid session id: %d, offload_type=%d, enable=%d", |
| 2501 | adapter->sessionId, offload_type, enable); |
| 2502 | return; |
| 2503 | } |
| 2504 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2505 | qdf_mem_zero(&ipa_offload_enable_disable, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2506 | sizeof(ipa_offload_enable_disable)); |
| 2507 | ipa_offload_enable_disable.offload_type = offload_type; |
Prakash Dhavali | 89d406d | 2016-11-23 11:11:00 -0800 | [diff] [blame] | 2508 | ipa_offload_enable_disable.vdev_id = session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2509 | ipa_offload_enable_disable.enable = enable; |
| 2510 | |
Srinivas Girigowda | 9785237 | 2017-03-06 16:52:59 -0800 | [diff] [blame] | 2511 | HDD_IPA_LOG(QDF_TRACE_LEVEL_DEBUG, |
Yun Park | 8292dcb | 2016-10-07 16:46:06 -0700 | [diff] [blame] | 2512 | "offload_type=%d, vdev_id=%d, enable=%d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2513 | ipa_offload_enable_disable.offload_type, |
| 2514 | ipa_offload_enable_disable.vdev_id, |
| 2515 | ipa_offload_enable_disable.enable); |
| 2516 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2517 | if (QDF_STATUS_SUCCESS != |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2518 | sme_ipa_offload_enable_disable(WLAN_HDD_GET_HAL_CTX(adapter), |
| 2519 | adapter->sessionId, &ipa_offload_enable_disable)) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 2520 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 2521 | "%s (offload_type=%d, vdev_id=%d, enable=%d)", |
| 2522 | "Failure to enable IPA offload", |
Jeff Johnson | a8a4f54 | 2016-11-08 10:56:53 -0800 | [diff] [blame] | 2523 | ipa_offload_enable_disable.offload_type, |
| 2524 | ipa_offload_enable_disable.vdev_id, |
| 2525 | ipa_offload_enable_disable.enable); |
Yun Park | 8292dcb | 2016-10-07 16:46:06 -0700 | [diff] [blame] | 2526 | } else { |
| 2527 | /* Update the IPA offload status */ |
Prakash Dhavali | 89d406d | 2016-11-23 11:11:00 -0800 | [diff] [blame] | 2528 | hdd_ipa->vdev_offload_enabled[session_id] = |
Yun Park | 8292dcb | 2016-10-07 16:46:06 -0700 | [diff] [blame] | 2529 | ipa_offload_enable_disable.enable; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2530 | } |
| 2531 | } |
| 2532 | |
| 2533 | /** |
| 2534 | * hdd_ipa_uc_fw_op_event_handler - IPA uC FW OPvent handler |
| 2535 | * @work: uC OP work |
| 2536 | * |
| 2537 | * Return: None |
| 2538 | */ |
| 2539 | static void hdd_ipa_uc_fw_op_event_handler(struct work_struct *work) |
| 2540 | { |
| 2541 | struct op_msg_type *msg; |
| 2542 | struct uc_op_work_struct *uc_op_work = container_of(work, |
| 2543 | struct uc_op_work_struct, work); |
| 2544 | struct hdd_ipa_priv *hdd_ipa = ghdd_ipa; |
| 2545 | |
| 2546 | cds_ssr_protect(__func__); |
| 2547 | |
| 2548 | msg = uc_op_work->msg; |
| 2549 | uc_op_work->msg = NULL; |
Srinivas Girigowda | 9785237 | 2017-03-06 16:52:59 -0800 | [diff] [blame] | 2550 | HDD_IPA_LOG(QDF_TRACE_LEVEL_DEBUG, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2551 | "%s, posted msg %d", __func__, msg->op_code); |
| 2552 | |
| 2553 | hdd_ipa_uc_op_cb(msg, hdd_ipa->hdd_ctx); |
| 2554 | |
| 2555 | cds_ssr_unprotect(__func__); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2556 | } |
| 2557 | |
| 2558 | /** |
| 2559 | * hdd_ipa_uc_op_event_handler() - Adapter lookup |
| 2560 | * hdd_ipa_uc_fw_op_event_handler - IPA uC FW OPvent handler |
| 2561 | * @op_msg: operation message received from firmware |
| 2562 | * @hdd_ctx: Global HDD context |
| 2563 | * |
| 2564 | * Return: None |
| 2565 | */ |
| 2566 | static void hdd_ipa_uc_op_event_handler(uint8_t *op_msg, void *hdd_ctx) |
| 2567 | { |
| 2568 | struct hdd_ipa_priv *hdd_ipa; |
| 2569 | struct op_msg_type *msg; |
| 2570 | struct uc_op_work_struct *uc_op_work; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2571 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2572 | |
| 2573 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 2574 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2575 | goto end; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2576 | |
| 2577 | msg = (struct op_msg_type *)op_msg; |
| 2578 | hdd_ipa = ((hdd_context_t *)hdd_ctx)->hdd_ipa; |
| 2579 | |
| 2580 | if (unlikely(!hdd_ipa)) |
| 2581 | goto end; |
| 2582 | |
| 2583 | if (HDD_IPA_UC_OPCODE_MAX <= msg->op_code) { |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 2584 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, "Invalid OP Code (%d)", |
| 2585 | msg->op_code); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2586 | goto end; |
| 2587 | } |
| 2588 | |
| 2589 | uc_op_work = &hdd_ipa->uc_op_work[msg->op_code]; |
| 2590 | if (uc_op_work->msg) |
| 2591 | /* When the same uC OPCODE is already pended, just return */ |
| 2592 | goto end; |
| 2593 | |
| 2594 | uc_op_work->msg = msg; |
| 2595 | schedule_work(&uc_op_work->work); |
| 2596 | return; |
| 2597 | |
| 2598 | end: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2599 | qdf_mem_free(op_msg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2600 | } |
| 2601 | |
| 2602 | /** |
Rajeev Kumar | 217f217 | 2016-01-06 18:11:55 -0800 | [diff] [blame] | 2603 | * hdd_ipa_init_uc_op_work - init ipa uc op work |
| 2604 | * @work: struct work_struct |
| 2605 | * @work_handler: work_handler |
| 2606 | * |
| 2607 | * Return: none |
| 2608 | */ |
Rajeev Kumar | 217f217 | 2016-01-06 18:11:55 -0800 | [diff] [blame] | 2609 | static void hdd_ipa_init_uc_op_work(struct work_struct *work, |
Yun Park | 637d648 | 2016-10-05 10:51:33 -0700 | [diff] [blame] | 2610 | work_func_t work_handler) |
Rajeev Kumar | 217f217 | 2016-01-06 18:11:55 -0800 | [diff] [blame] | 2611 | { |
| 2612 | INIT_WORK(work, work_handler); |
| 2613 | } |
Rajeev Kumar | 217f217 | 2016-01-06 18:11:55 -0800 | [diff] [blame] | 2614 | |
Yun Park | 637d648 | 2016-10-05 10:51:33 -0700 | [diff] [blame] | 2615 | #ifdef FEATURE_METERING |
| 2616 | /** |
| 2617 | * __hdd_ipa_wdi_meter_notifier_cb() - WLAN to IPA callback handler. |
| 2618 | * IPA calls to get WLAN stats or set quota limit. |
| 2619 | * @priv: pointer to private data registered with IPA (we register a |
| 2620 | *» pointer to the global IPA context) |
| 2621 | * @evt: the IPA event which triggered the callback |
| 2622 | * @data: data associated with the event |
| 2623 | * |
| 2624 | * Return: None |
| 2625 | */ |
| 2626 | static void __hdd_ipa_wdi_meter_notifier_cb(enum ipa_wdi_meter_evt_type evt, |
| 2627 | void *data) |
| 2628 | { |
| 2629 | struct hdd_ipa_priv *hdd_ipa = ghdd_ipa; |
| 2630 | hdd_adapter_t *adapter = NULL; |
| 2631 | struct ipa_get_wdi_sap_stats *wdi_sap_stats; |
| 2632 | struct ipa_set_wifi_quota *ipa_set_quota; |
| 2633 | int ret = 0; |
| 2634 | |
| 2635 | if (wlan_hdd_validate_context(hdd_ipa->hdd_ctx)) |
| 2636 | return; |
| 2637 | |
| 2638 | adapter = hdd_get_adapter(hdd_ipa->hdd_ctx, QDF_STA_MODE); |
| 2639 | |
| 2640 | HDD_IPA_LOG(QDF_TRACE_LEVEL_INFO, "event=%d", evt); |
| 2641 | |
| 2642 | switch (evt) { |
| 2643 | case IPA_GET_WDI_SAP_STATS: |
| 2644 | /* fill-up ipa_get_wdi_sap_stats structure after getting |
| 2645 | ipa_uc_fw_stats from FW */ |
| 2646 | wdi_sap_stats = data; |
| 2647 | |
| 2648 | if (!adapter) { |
| 2649 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
| 2650 | "IPA uC share stats failed - no adapter"); |
| 2651 | wdi_sap_stats->stats_valid = 0; |
| 2652 | return; |
| 2653 | } |
| 2654 | |
| 2655 | INIT_COMPLETION(hdd_ipa->ipa_uc_sharing_stats_comp); |
| 2656 | INIT_COMPLETION(hdd_ipa->ipa_uc_set_quota_comp); |
| 2657 | hdd_ipa_uc_sharing_stats_request(adapter, |
| 2658 | wdi_sap_stats->reset_stats); |
| 2659 | ret = wait_for_completion_timeout( |
| 2660 | &hdd_ipa->ipa_uc_sharing_stats_comp, |
| 2661 | msecs_to_jiffies(IPA_UC_SHARING_STATES_WAIT_TIME)); |
| 2662 | if (!ret) { |
| 2663 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
| 2664 | "IPA uC share stats request timed out"); |
| 2665 | wdi_sap_stats->stats_valid = 0; |
| 2666 | } else { |
| 2667 | wdi_sap_stats->stats_valid = 1; |
| 2668 | |
| 2669 | wdi_sap_stats->ipv4_rx_packets = |
| 2670 | hdd_ipa->ipa_sharing_stats.ipv4_rx_packets; |
| 2671 | wdi_sap_stats->ipv4_rx_bytes = |
| 2672 | hdd_ipa->ipa_sharing_stats.ipv4_rx_bytes; |
| 2673 | wdi_sap_stats->ipv6_rx_packets = |
| 2674 | hdd_ipa->ipa_sharing_stats.ipv6_rx_packets; |
| 2675 | wdi_sap_stats->ipv6_rx_bytes = |
| 2676 | hdd_ipa->ipa_sharing_stats.ipv6_rx_bytes; |
| 2677 | wdi_sap_stats->ipv4_tx_packets = |
| 2678 | hdd_ipa->ipa_sharing_stats.ipv4_tx_packets; |
| 2679 | wdi_sap_stats->ipv4_tx_bytes = |
| 2680 | hdd_ipa->ipa_sharing_stats.ipv4_tx_bytes; |
| 2681 | wdi_sap_stats->ipv6_tx_packets = |
| 2682 | hdd_ipa->ipa_sharing_stats.ipv6_tx_packets; |
| 2683 | wdi_sap_stats->ipv6_tx_bytes = |
| 2684 | hdd_ipa->ipa_sharing_stats.ipv6_tx_bytes; |
| 2685 | HDD_IPA_DP_LOG(QDF_TRACE_LEVEL_DEBUG, |
| 2686 | "%s:%d,%llu,%llu,%llu,%llu,%llu,%llu,%llu,%llu", |
| 2687 | "IPA_GET_WDI_SAP_STATS", |
| 2688 | wdi_sap_stats->stats_valid, |
| 2689 | wdi_sap_stats->ipv4_rx_packets, |
| 2690 | wdi_sap_stats->ipv4_rx_bytes, |
| 2691 | wdi_sap_stats->ipv6_rx_packets, |
| 2692 | wdi_sap_stats->ipv6_rx_bytes, |
| 2693 | wdi_sap_stats->ipv4_tx_packets, |
| 2694 | wdi_sap_stats->ipv4_tx_bytes, |
| 2695 | wdi_sap_stats->ipv6_tx_packets, |
| 2696 | wdi_sap_stats->ipv6_tx_bytes); |
| 2697 | } |
| 2698 | break; |
| 2699 | case IPA_SET_WIFI_QUOTA: |
| 2700 | /* get ipa_set_wifi_quota structure from IPA and pass to FW |
| 2701 | through quota_exceeded field in ipa_uc_fw_stats */ |
| 2702 | ipa_set_quota = data; |
| 2703 | |
| 2704 | if (!adapter) { |
| 2705 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
| 2706 | "IPA uC set quota failed - no adapter"); |
| 2707 | ipa_set_quota->set_valid = 0; |
| 2708 | return; |
| 2709 | } |
| 2710 | |
| 2711 | hdd_ipa_uc_set_quota(adapter, ipa_set_quota->set_quota, |
| 2712 | ipa_set_quota->quota_bytes); |
| 2713 | |
| 2714 | ret = wait_for_completion_timeout( |
| 2715 | &hdd_ipa->ipa_uc_set_quota_comp, |
| 2716 | msecs_to_jiffies(IPA_UC_SET_QUOTA_WAIT_TIME)); |
| 2717 | if (!ret) { |
| 2718 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
| 2719 | "IPA uC set quota request timed out"); |
| 2720 | ipa_set_quota->set_valid = 0; |
| 2721 | } else { |
| 2722 | ipa_set_quota->quota_bytes = |
| 2723 | ((uint64_t)(hdd_ipa->ipa_quota_rsp.quota_hi) |
| 2724 | <<32)|hdd_ipa->ipa_quota_rsp.quota_lo; |
| 2725 | ipa_set_quota->set_valid = |
| 2726 | hdd_ipa->ipa_quota_rsp.success; |
| 2727 | } |
| 2728 | |
| 2729 | HDD_IPA_DP_LOG(QDF_TRACE_LEVEL_DEBUG, "SET_QUOTA: %llu, %d", |
| 2730 | ipa_set_quota->quota_bytes, |
| 2731 | ipa_set_quota->set_valid); |
| 2732 | break; |
| 2733 | } |
| 2734 | } |
| 2735 | |
| 2736 | /** |
| 2737 | * hdd_ipa_wdi_meter_notifier_cb() - WLAN to IPA callback handler. |
| 2738 | * IPA calls to get WLAN stats or set quota limit. |
| 2739 | * @priv: pointer to private data registered with IPA (we register a |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 2740 | * pointer to the global IPA context) |
Yun Park | 637d648 | 2016-10-05 10:51:33 -0700 | [diff] [blame] | 2741 | * @evt: the IPA event which triggered the callback |
| 2742 | * @data: data associated with the event |
| 2743 | * |
| 2744 | * Return: None |
| 2745 | */ |
| 2746 | static void hdd_ipa_wdi_meter_notifier_cb(enum ipa_wdi_meter_evt_type evt, |
| 2747 | void *data) |
| 2748 | { |
| 2749 | cds_ssr_protect(__func__); |
| 2750 | __hdd_ipa_wdi_meter_notifier_cb(evt, data); |
| 2751 | cds_ssr_unprotect(__func__); |
| 2752 | } |
| 2753 | |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 2754 | static void hdd_ipa_init_metering(struct hdd_ipa_priv *ipa_ctxt) |
Yun Park | 637d648 | 2016-10-05 10:51:33 -0700 | [diff] [blame] | 2755 | { |
Yun Park | 637d648 | 2016-10-05 10:51:33 -0700 | [diff] [blame] | 2756 | init_completion(&ipa_ctxt->ipa_uc_sharing_stats_comp); |
| 2757 | init_completion(&ipa_ctxt->ipa_uc_set_quota_comp); |
| 2758 | } |
| 2759 | #else |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 2760 | static void hdd_ipa_wdi_meter_notifier_cb(void) |
| 2761 | { |
| 2762 | } |
| 2763 | |
| 2764 | static void hdd_ipa_init_metering(struct hdd_ipa_priv *ipa_ctxt) |
Yun Park | 637d648 | 2016-10-05 10:51:33 -0700 | [diff] [blame] | 2765 | { |
| 2766 | } |
| 2767 | #endif |
| 2768 | |
Rajeev Kumar | 217f217 | 2016-01-06 18:11:55 -0800 | [diff] [blame] | 2769 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2770 | * hdd_ipa_uc_ol_init() - Initialize IPA uC offload |
| 2771 | * @hdd_ctx: Global HDD context |
| 2772 | * |
Manikandan Mohan | 2e803a0 | 2017-02-14 14:57:53 -0800 | [diff] [blame] | 2773 | * This function is called to update IPA pipe configuration with resources |
| 2774 | * allocated by wlan driver (cds_pre_enable) before enabling it in FW |
| 2775 | * (cds_enable) |
| 2776 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2777 | * Return: QDF_STATUS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2778 | */ |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 2779 | QDF_STATUS hdd_ipa_uc_ol_init(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2780 | { |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 2781 | struct hdd_ipa_priv *hdd_ipa = (struct hdd_ipa_priv *)hdd_ctx->hdd_ipa; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 2782 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
Yun Park | baa6286 | 2017-01-18 13:43:34 -0800 | [diff] [blame] | 2783 | struct ol_txrx_pdev_t *pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 2784 | uint8_t i; |
| 2785 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2786 | |
Manikandan Mohan | 2e803a0 | 2017-02-14 14:57:53 -0800 | [diff] [blame] | 2787 | if (!hdd_ipa_uc_is_enabled(hdd_ctx)) |
| 2788 | return QDF_STATUS_SUCCESS; |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 2789 | |
Manikandan Mohan | 2e803a0 | 2017-02-14 14:57:53 -0800 | [diff] [blame] | 2790 | ENTER(); |
| 2791 | /* Do only IPA Pipe specific configuration here. All one time |
| 2792 | * initialization wrt IPA UC shall in hdd_ipa_init and those need |
| 2793 | * to be reinit at SSR shall in be SSR deinit / reinit functions. |
| 2794 | */ |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 2795 | if (!pdev || !soc) { |
| 2796 | HDD_IPA_LOG(QDF_TRACE_LEVEL_FATAL, "DP context is NULL"); |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 2797 | status = QDF_STATUS_E_FAILURE; |
Yun Park | baa6286 | 2017-01-18 13:43:34 -0800 | [diff] [blame] | 2798 | goto fail_return; |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 2799 | } |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 2800 | if (cdp_ipa_get_resource(soc, (struct cdp_pdev *)pdev)) { |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 2801 | HDD_IPA_LOG(QDF_TRACE_LEVEL_FATAL, |
| 2802 | "IPA UC resource alloc fail"); |
| 2803 | return QDF_STATUS_E_FAILURE; |
| 2804 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2805 | |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 2806 | if (true == hdd_ipa->uc_loaded) { |
| 2807 | status = cdp_ipa_setup(soc, (struct cdp_pdev *)pdev, |
| 2808 | hdd_ipa_i2w_cb, hdd_ipa_w2i_cb, |
| 2809 | hdd_ipa_wdi_meter_notifier_cb, |
| 2810 | hdd_ctx->config->IpaDescSize, |
| 2811 | hdd_ipa, hdd_ipa_is_rm_enabled(hdd_ctx), |
| 2812 | &hdd_ipa->tx_pipe_handle, |
| 2813 | &hdd_ipa->rx_pipe_handle); |
| 2814 | if (status) { |
Yun Park | baa6286 | 2017-01-18 13:43:34 -0800 | [diff] [blame] | 2815 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 2816 | "Failure to setup IPA pipes (status=%d)", |
| 2817 | status); |
| 2818 | return QDF_STATUS_E_FAILURE; |
Yun Park | baa6286 | 2017-01-18 13:43:34 -0800 | [diff] [blame] | 2819 | } |
Yun Park | 637d648 | 2016-10-05 10:51:33 -0700 | [diff] [blame] | 2820 | |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 2821 | cdp_ipa_set_doorbell_paddr(soc, (struct cdp_pdev *)pdev); |
| 2822 | hdd_ipa_init_metering(hdd_ipa); |
Manikandan Mohan | 153a4c3 | 2017-02-16 15:04:30 -0800 | [diff] [blame] | 2823 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2824 | |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 2825 | cdp_ipa_register_op_cb(soc, (struct cdp_pdev *)pdev, |
Yun Park | baa6286 | 2017-01-18 13:43:34 -0800 | [diff] [blame] | 2826 | hdd_ipa_uc_op_event_handler, (void *)hdd_ctx); |
| 2827 | |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 2828 | for (i = 0; i < HDD_IPA_UC_OPCODE_MAX; i++) { |
| 2829 | hdd_ipa_init_uc_op_work(&hdd_ipa->uc_op_work[i].work, |
| 2830 | hdd_ipa_uc_fw_op_event_handler); |
| 2831 | hdd_ipa->uc_op_work[i].msg = NULL; |
| 2832 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2833 | |
Yun Park | baa6286 | 2017-01-18 13:43:34 -0800 | [diff] [blame] | 2834 | fail_return: |
| 2835 | EXIT(); |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 2836 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2837 | } |
| 2838 | |
Leo Chang | e3e4944 | 2015-10-26 20:07:13 -0700 | [diff] [blame] | 2839 | /** |
Sravan Kumar Kairam | 7112171 | 2017-04-15 00:34:42 +0530 | [diff] [blame] | 2840 | * hdd_ipa_uc_ol_deinit() - Disconnect IPA TX and RX pipes |
| 2841 | * @hdd_ctx: Global HDD context |
| 2842 | * |
| 2843 | * Return: 0 on success, negativer errno on error |
| 2844 | */ |
| 2845 | int hdd_ipa_uc_ol_deinit(hdd_context_t *hdd_ctx) |
| 2846 | { |
| 2847 | struct hdd_ipa_priv *hdd_ipa = hdd_ctx->hdd_ipa; |
| 2848 | int ret = 0; |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 2849 | QDF_STATUS status; |
Sravan Kumar Kairam | 7112171 | 2017-04-15 00:34:42 +0530 | [diff] [blame] | 2850 | |
| 2851 | if (!hdd_ipa_uc_is_enabled(hdd_ctx)) |
| 2852 | return ret; |
| 2853 | |
Sravan Kumar Kairam | 374a868 | 2017-05-15 13:19:44 +0530 | [diff] [blame] | 2854 | if (!hdd_ipa->ipa_pipes_down) |
| 2855 | hdd_ipa_uc_disable_pipes(hdd_ipa); |
| 2856 | |
Sravan Kumar Kairam | 7112171 | 2017-04-15 00:34:42 +0530 | [diff] [blame] | 2857 | if (true == hdd_ipa->uc_loaded) { |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 2858 | status = cdp_ipa_cleanup(cds_get_context(QDF_MODULE_ID_SOC), |
| 2859 | hdd_ipa->tx_pipe_handle, |
| 2860 | hdd_ipa->rx_pipe_handle); |
| 2861 | if (status) { |
| 2862 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
| 2863 | "Failure to cleanup IPA pipes (status=%d)", |
| 2864 | status); |
| 2865 | return -EFAULT; |
| 2866 | } |
Sravan Kumar Kairam | 7112171 | 2017-04-15 00:34:42 +0530 | [diff] [blame] | 2867 | } |
| 2868 | |
| 2869 | return ret; |
| 2870 | } |
| 2871 | |
| 2872 | /** |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 2873 | * __hdd_ipa_uc_force_pipe_shutdown() - Force shutdown IPA pipe |
Leo Chang | e3e4944 | 2015-10-26 20:07:13 -0700 | [diff] [blame] | 2874 | * @hdd_ctx: hdd main context |
| 2875 | * |
| 2876 | * Force shutdown IPA pipe |
| 2877 | * Independent of FW pipe status, IPA pipe shutdonw progress |
| 2878 | * in case, any STA does not leave properly, IPA HW pipe should cleaned up |
| 2879 | * independent from FW pipe status |
| 2880 | * |
| 2881 | * Return: NONE |
| 2882 | */ |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 2883 | static void __hdd_ipa_uc_force_pipe_shutdown(hdd_context_t *hdd_ctx) |
Leo Chang | e3e4944 | 2015-10-26 20:07:13 -0700 | [diff] [blame] | 2884 | { |
| 2885 | struct hdd_ipa_priv *hdd_ipa; |
| 2886 | |
| 2887 | if (!hdd_ipa_is_enabled(hdd_ctx) || !hdd_ctx->hdd_ipa) |
| 2888 | return; |
| 2889 | |
| 2890 | hdd_ipa = (struct hdd_ipa_priv *)hdd_ctx->hdd_ipa; |
| 2891 | if (false == hdd_ipa->ipa_pipes_down) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 2892 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 2893 | "IPA pipes are not down yet, force shutdown"); |
Leo Chang | e3e4944 | 2015-10-26 20:07:13 -0700 | [diff] [blame] | 2894 | hdd_ipa_uc_disable_pipes(hdd_ipa); |
| 2895 | } else { |
Srinivas Girigowda | 9785237 | 2017-03-06 16:52:59 -0800 | [diff] [blame] | 2896 | HDD_IPA_LOG(QDF_TRACE_LEVEL_DEBUG, |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 2897 | "IPA pipes are down, do nothing"); |
Leo Chang | e3e4944 | 2015-10-26 20:07:13 -0700 | [diff] [blame] | 2898 | } |
Leo Chang | e3e4944 | 2015-10-26 20:07:13 -0700 | [diff] [blame] | 2899 | } |
| 2900 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2901 | /** |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 2902 | * hdd_ipa_uc_force_pipe_shutdown() - SSR wrapper for |
| 2903 | * __hdd_ipa_uc_force_pipe_shutdown |
| 2904 | * @hdd_ctx: hdd main context |
| 2905 | * |
| 2906 | * Force shutdown IPA pipe |
| 2907 | * Independent of FW pipe status, IPA pipe shutdonw progress |
| 2908 | * in case, any STA does not leave properly, IPA HW pipe should cleaned up |
| 2909 | * independent from FW pipe status |
| 2910 | * |
| 2911 | * Return: NONE |
| 2912 | */ |
| 2913 | void hdd_ipa_uc_force_pipe_shutdown(hdd_context_t *hdd_ctx) |
| 2914 | { |
| 2915 | cds_ssr_protect(__func__); |
| 2916 | __hdd_ipa_uc_force_pipe_shutdown(hdd_ctx); |
| 2917 | cds_ssr_unprotect(__func__); |
| 2918 | } |
| 2919 | |
| 2920 | /** |
Govind Singh | 9c58eba | 2016-09-02 16:23:06 +0530 | [diff] [blame] | 2921 | * hdd_ipa_msg_free_fn() - Free an IPA message |
| 2922 | * @buff: pointer to the IPA message |
| 2923 | * @len: length of the IPA message |
| 2924 | * @type: type of IPA message |
| 2925 | * |
| 2926 | * Return: None |
| 2927 | */ |
| 2928 | static void hdd_ipa_msg_free_fn(void *buff, uint32_t len, uint32_t type) |
| 2929 | { |
Srinivas Girigowda | 9785237 | 2017-03-06 16:52:59 -0800 | [diff] [blame] | 2930 | HDD_IPA_LOG(QDF_TRACE_LEVEL_DEBUG, "msg type:%d, len:%d", type, len); |
Govind Singh | 9c58eba | 2016-09-02 16:23:06 +0530 | [diff] [blame] | 2931 | ghdd_ipa->stats.num_free_msg++; |
| 2932 | qdf_mem_free(buff); |
| 2933 | } |
| 2934 | |
Govind Singh | 9c58eba | 2016-09-02 16:23:06 +0530 | [diff] [blame] | 2935 | /** |
jge | 6203786 | 2016-12-09 10:44:33 +0800 | [diff] [blame] | 2936 | * hdd_ipa_uc_send_evt() - send event to ipa |
| 2937 | * @hdd_ctx: pointer to hdd context |
| 2938 | * @type: event type |
| 2939 | * @mac_addr: pointer to mac address |
| 2940 | * |
| 2941 | * Send event to IPA driver |
Govind Singh | 9c58eba | 2016-09-02 16:23:06 +0530 | [diff] [blame] | 2942 | * |
| 2943 | * Return: 0 - Success |
| 2944 | */ |
jge | 6203786 | 2016-12-09 10:44:33 +0800 | [diff] [blame] | 2945 | static int hdd_ipa_uc_send_evt(hdd_adapter_t *adapter, |
| 2946 | enum ipa_wlan_event type, uint8_t *mac_addr) |
Govind Singh | 9c58eba | 2016-09-02 16:23:06 +0530 | [diff] [blame] | 2947 | { |
jge | 6203786 | 2016-12-09 10:44:33 +0800 | [diff] [blame] | 2948 | struct hdd_ipa_priv *hdd_ipa = ghdd_ipa; |
Govind Singh | 9c58eba | 2016-09-02 16:23:06 +0530 | [diff] [blame] | 2949 | struct ipa_msg_meta meta; |
| 2950 | struct ipa_wlan_msg *msg; |
| 2951 | int ret = 0; |
jge | 6203786 | 2016-12-09 10:44:33 +0800 | [diff] [blame] | 2952 | |
| 2953 | meta.msg_len = sizeof(struct ipa_wlan_msg); |
| 2954 | msg = qdf_mem_malloc(meta.msg_len); |
| 2955 | if (msg == NULL) { |
| 2956 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
| 2957 | "msg allocation failed"); |
| 2958 | return -ENOMEM; |
| 2959 | } |
| 2960 | |
| 2961 | meta.msg_type = type; |
| 2962 | strlcpy(msg->name, adapter->dev->name, |
| 2963 | IPA_RESOURCE_NAME_MAX); |
| 2964 | memcpy(msg->mac_addr, mac_addr, ETH_ALEN); |
Srinivas Girigowda | 9785237 | 2017-03-06 16:52:59 -0800 | [diff] [blame] | 2965 | HDD_IPA_LOG(QDF_TRACE_LEVEL_DEBUG, "%s: Evt: %d", |
jge | 6203786 | 2016-12-09 10:44:33 +0800 | [diff] [blame] | 2966 | msg->name, meta.msg_type); |
| 2967 | ret = ipa_send_msg(&meta, msg, hdd_ipa_msg_free_fn); |
| 2968 | if (ret) { |
| 2969 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
| 2970 | "%s: Evt: %d fail:%d", |
| 2971 | msg->name, meta.msg_type, ret); |
| 2972 | qdf_mem_free(msg); |
| 2973 | return ret; |
| 2974 | } |
| 2975 | |
| 2976 | hdd_ipa->stats.num_send_msg++; |
| 2977 | |
| 2978 | return ret; |
| 2979 | } |
| 2980 | |
| 2981 | /** |
| 2982 | * hdd_ipa_uc_disconnect_client() - send client disconnect event |
| 2983 | * @hdd_ctx: pointer to hdd adapter |
| 2984 | * |
| 2985 | * Send disconnect client event to IPA driver during SSR |
| 2986 | * |
| 2987 | * Return: 0 - Success |
| 2988 | */ |
| 2989 | static int hdd_ipa_uc_disconnect_client(hdd_adapter_t *adapter) |
| 2990 | { |
| 2991 | struct hdd_ipa_priv *hdd_ipa = ghdd_ipa; |
| 2992 | int ret = 0; |
Govind Singh | 9c58eba | 2016-09-02 16:23:06 +0530 | [diff] [blame] | 2993 | int i; |
| 2994 | |
| 2995 | for (i = 0; i < WLAN_MAX_STA_COUNT; i++) { |
| 2996 | if (qdf_is_macaddr_broadcast(&adapter->aStaInfo[i].macAddrSTA)) |
| 2997 | continue; |
| 2998 | if ((adapter->aStaInfo[i].isUsed) && |
jge | 6203786 | 2016-12-09 10:44:33 +0800 | [diff] [blame] | 2999 | (!adapter->aStaInfo[i].isDeauthInProgress) && |
| 3000 | hdd_ipa->sap_num_connected_sta) { |
| 3001 | hdd_ipa_uc_send_evt(adapter, WLAN_CLIENT_DISCONNECT, |
| 3002 | adapter->aStaInfo[i].macAddrSTA.bytes); |
| 3003 | hdd_ipa->sap_num_connected_sta--; |
Govind Singh | 9c58eba | 2016-09-02 16:23:06 +0530 | [diff] [blame] | 3004 | } |
| 3005 | } |
| 3006 | |
| 3007 | return ret; |
| 3008 | } |
| 3009 | |
| 3010 | /** |
jge | 6203786 | 2016-12-09 10:44:33 +0800 | [diff] [blame] | 3011 | * hdd_ipa_uc_disconnect_ap() - send ap disconnect event |
| 3012 | * @hdd_ctx: pointer to hdd adapter |
| 3013 | * |
| 3014 | * Send disconnect ap event to IPA driver during SSR |
Govind Singh | 9c58eba | 2016-09-02 16:23:06 +0530 | [diff] [blame] | 3015 | * |
| 3016 | * Return: 0 - Success |
| 3017 | */ |
jge | 6203786 | 2016-12-09 10:44:33 +0800 | [diff] [blame] | 3018 | |
| 3019 | static int hdd_ipa_uc_disconnect_ap(hdd_adapter_t *adapter) |
| 3020 | { |
| 3021 | int ret = 0; |
| 3022 | |
| 3023 | if (adapter->ipa_context) |
| 3024 | hdd_ipa_uc_send_evt(adapter, WLAN_AP_DISCONNECT, |
| 3025 | adapter->dev->dev_addr); |
| 3026 | |
| 3027 | return ret; |
| 3028 | } |
| 3029 | |
jge | 6203786 | 2016-12-09 10:44:33 +0800 | [diff] [blame] | 3030 | /** |
| 3031 | * hdd_ipa_uc_disconnect_sta() - send sta disconnect event |
| 3032 | * @hdd_ctx: pointer to hdd adapter |
| 3033 | * |
| 3034 | * Send disconnect sta event to IPA driver during SSR |
| 3035 | * |
| 3036 | * Return: 0 - Success |
| 3037 | */ |
| 3038 | static int hdd_ipa_uc_disconnect_sta(hdd_adapter_t *adapter) |
| 3039 | { |
| 3040 | hdd_station_ctx_t *pHddStaCtx; |
| 3041 | struct hdd_ipa_priv *hdd_ipa = ghdd_ipa; |
| 3042 | int ret = 0; |
| 3043 | |
Manikandan Mohan | cd64c0b | 2017-03-08 13:00:24 -0800 | [diff] [blame] | 3044 | if (hdd_ipa_uc_sta_is_enabled(hdd_ipa->hdd_ctx) && |
jge | 6203786 | 2016-12-09 10:44:33 +0800 | [diff] [blame] | 3045 | hdd_ipa->sta_connected) { |
| 3046 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 3047 | hdd_ipa_uc_send_evt(adapter, WLAN_STA_DISCONNECT, |
Manikandan Mohan | cd64c0b | 2017-03-08 13:00:24 -0800 | [diff] [blame] | 3048 | pHddStaCtx->conn_info.bssId.bytes); |
jge | 6203786 | 2016-12-09 10:44:33 +0800 | [diff] [blame] | 3049 | } |
| 3050 | |
| 3051 | return ret; |
| 3052 | } |
jge | 6203786 | 2016-12-09 10:44:33 +0800 | [diff] [blame] | 3053 | |
| 3054 | /** |
| 3055 | * hdd_ipa_uc_disconnect() - send disconnect ipa event |
| 3056 | * @hdd_ctx: pointer to hdd context |
| 3057 | * |
| 3058 | * Send disconnect event to IPA driver during SSR |
| 3059 | * |
| 3060 | * Return: 0 - Success |
| 3061 | */ |
| 3062 | static int hdd_ipa_uc_disconnect(hdd_context_t *hdd_ctx) |
Govind Singh | 9c58eba | 2016-09-02 16:23:06 +0530 | [diff] [blame] | 3063 | { |
| 3064 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
| 3065 | QDF_STATUS status; |
| 3066 | hdd_adapter_t *adapter; |
| 3067 | int ret = 0; |
| 3068 | |
Govind Singh | 9c58eba | 2016-09-02 16:23:06 +0530 | [diff] [blame] | 3069 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
| 3070 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
| 3071 | adapter = adapter_node->pAdapter; |
jge | 6203786 | 2016-12-09 10:44:33 +0800 | [diff] [blame] | 3072 | if (adapter->device_mode == QDF_SAP_MODE) { |
| 3073 | hdd_ipa_uc_disconnect_client(adapter); |
| 3074 | hdd_ipa_uc_disconnect_ap(adapter); |
| 3075 | } else if (adapter->device_mode == QDF_STA_MODE) { |
| 3076 | hdd_ipa_uc_disconnect_sta(adapter); |
| 3077 | } |
| 3078 | |
Govind Singh | 9c58eba | 2016-09-02 16:23:06 +0530 | [diff] [blame] | 3079 | status = hdd_get_next_adapter( |
| 3080 | hdd_ctx, adapter_node, &next); |
| 3081 | adapter_node = next; |
| 3082 | } |
| 3083 | |
| 3084 | return ret; |
| 3085 | } |
| 3086 | |
| 3087 | /** |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 3088 | * __hdd_ipa_uc_ssr_deinit() - handle ipa deinit for SSR |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3089 | * |
| 3090 | * Deinit basic IPA UC host side to be in sync reloaded FW during |
| 3091 | * SSR |
| 3092 | * |
| 3093 | * Return: 0 - Success |
| 3094 | */ |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 3095 | static int __hdd_ipa_uc_ssr_deinit(void) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3096 | { |
| 3097 | struct hdd_ipa_priv *hdd_ipa = ghdd_ipa; |
| 3098 | int idx; |
| 3099 | struct hdd_ipa_iface_context *iface_context; |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 3100 | hdd_context_t *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3101 | |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 3102 | if (!hdd_ipa) |
| 3103 | return 0; |
| 3104 | |
| 3105 | hdd_ctx = hdd_ipa->hdd_ctx; |
| 3106 | if (!hdd_ipa_uc_is_enabled(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3107 | return 0; |
| 3108 | |
jge | 6203786 | 2016-12-09 10:44:33 +0800 | [diff] [blame] | 3109 | /* send disconnect to ipa driver */ |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 3110 | hdd_ipa_uc_disconnect(hdd_ctx); |
jge | 6203786 | 2016-12-09 10:44:33 +0800 | [diff] [blame] | 3111 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3112 | /* Clean up HDD IPA interfaces */ |
| 3113 | for (idx = 0; (hdd_ipa->num_iface > 0) && |
| 3114 | (idx < HDD_IPA_MAX_IFACE); idx++) { |
| 3115 | iface_context = &hdd_ipa->iface_context[idx]; |
Manikandan Mohan | eab5824 | 2017-02-17 14:21:53 -0800 | [diff] [blame] | 3116 | if (iface_context->adapter && iface_context->adapter->magic == |
| 3117 | WLAN_HDD_ADAPTER_MAGIC) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3118 | hdd_ipa_cleanup_iface(iface_context); |
| 3119 | } |
Manikandan Mohan | eab5824 | 2017-02-17 14:21:53 -0800 | [diff] [blame] | 3120 | hdd_ipa->num_iface = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3121 | /* After SSR, wlan driver reloads FW again. But we need to protect |
| 3122 | * IPA submodule during SSR transient state. So deinit basic IPA |
| 3123 | * UC host side to be in sync with reloaded FW during SSR |
| 3124 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3125 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 3126 | qdf_mutex_acquire(&hdd_ipa->ipa_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3127 | for (idx = 0; idx < WLAN_MAX_STA_COUNT; idx++) { |
| 3128 | hdd_ipa->assoc_stas_map[idx].is_reserved = false; |
| 3129 | hdd_ipa->assoc_stas_map[idx].sta_id = 0xFF; |
| 3130 | } |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 3131 | qdf_mutex_release(&hdd_ipa->ipa_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3132 | |
Guolei Bian | ca144d8 | 2016-11-10 11:07:42 +0800 | [diff] [blame] | 3133 | if (hdd_ipa_uc_sta_is_enabled(hdd_ipa->hdd_ctx)) |
| 3134 | hdd_ipa_uc_sta_reset_sta_connected(hdd_ipa); |
| 3135 | |
Manikandan Mohan | 2e803a0 | 2017-02-14 14:57:53 -0800 | [diff] [blame] | 3136 | for (idx = 0; idx < HDD_IPA_UC_OPCODE_MAX; idx++) { |
| 3137 | cancel_work_sync(&hdd_ipa->uc_op_work[idx].work); |
| 3138 | qdf_mem_free(hdd_ipa->uc_op_work[idx].msg); |
| 3139 | hdd_ipa->uc_op_work[idx].msg = NULL; |
| 3140 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3141 | return 0; |
| 3142 | } |
| 3143 | |
| 3144 | /** |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 3145 | * hdd_ipa_uc_ssr_deinit() - SSR wrapper for __hdd_ipa_uc_ssr_deinit |
| 3146 | * |
| 3147 | * Deinit basic IPA UC host side to be in sync reloaded FW during |
| 3148 | * SSR |
| 3149 | * |
| 3150 | * Return: 0 - Success |
| 3151 | */ |
| 3152 | int hdd_ipa_uc_ssr_deinit(void) |
| 3153 | { |
| 3154 | int ret; |
| 3155 | |
| 3156 | cds_ssr_protect(__func__); |
| 3157 | ret = __hdd_ipa_uc_ssr_deinit(); |
| 3158 | cds_ssr_unprotect(__func__); |
| 3159 | |
| 3160 | return ret; |
| 3161 | } |
| 3162 | |
| 3163 | /** |
| 3164 | * __hdd_ipa_uc_ssr_reinit() - handle ipa reinit after SSR |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3165 | * |
| 3166 | * Init basic IPA UC host side to be in sync with reloaded FW after |
| 3167 | * SSR to resume IPA UC operations |
| 3168 | * |
| 3169 | * Return: 0 - Success |
| 3170 | */ |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 3171 | static int __hdd_ipa_uc_ssr_reinit(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3172 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3173 | |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 3174 | struct hdd_ipa_priv *hdd_ipa = ghdd_ipa; |
| 3175 | int i; |
| 3176 | struct hdd_ipa_iface_context *iface_context = NULL; |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 3177 | |
| 3178 | if (!hdd_ipa || !hdd_ipa_uc_is_enabled(hdd_ctx)) |
| 3179 | return 0; |
| 3180 | |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 3181 | /* Create the interface context */ |
| 3182 | for (i = 0; i < HDD_IPA_MAX_IFACE; i++) { |
| 3183 | iface_context = &hdd_ipa->iface_context[i]; |
| 3184 | iface_context->hdd_ipa = hdd_ipa; |
| 3185 | iface_context->cons_client = |
| 3186 | hdd_ipa_adapter_2_client[i].cons_client; |
| 3187 | iface_context->prod_client = |
| 3188 | hdd_ipa_adapter_2_client[i].prod_client; |
| 3189 | iface_context->iface_id = i; |
| 3190 | iface_context->adapter = NULL; |
| 3191 | } |
| 3192 | for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { |
| 3193 | hdd_ipa->vdev_to_iface[i] = CSR_ROAM_SESSION_MAX; |
| 3194 | hdd_ipa->vdev_offload_enabled[i] = false; |
| 3195 | } |
| 3196 | |
| 3197 | if (hdd_ipa_uc_is_enabled(hdd_ipa->hdd_ctx)) { |
| 3198 | hdd_ipa->resource_loading = false; |
| 3199 | hdd_ipa->resource_unloading = false; |
| 3200 | hdd_ipa->sta_connected = 0; |
| 3201 | hdd_ipa->ipa_pipes_down = true; |
| 3202 | hdd_ipa->uc_loaded = true; |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 3203 | } |
| 3204 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3205 | return 0; |
| 3206 | } |
Leo Chang | 3bc8fed | 2015-11-13 10:59:47 -0800 | [diff] [blame] | 3207 | |
| 3208 | /** |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 3209 | * hdd_ipa_uc_ssr_reinit() - SSR wrapper for __hdd_ipa_uc_ssr_reinit |
| 3210 | * |
| 3211 | * Init basic IPA UC host side to be in sync with reloaded FW after |
| 3212 | * SSR to resume IPA UC operations |
| 3213 | * |
| 3214 | * Return: 0 - Success |
| 3215 | */ |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 3216 | int hdd_ipa_uc_ssr_reinit(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 3217 | { |
| 3218 | int ret; |
| 3219 | |
| 3220 | cds_ssr_protect(__func__); |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 3221 | ret = __hdd_ipa_uc_ssr_reinit(hdd_ctx); |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 3222 | cds_ssr_unprotect(__func__); |
| 3223 | |
| 3224 | return ret; |
| 3225 | } |
| 3226 | |
| 3227 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3228 | * hdd_ipa_wake_lock_timer_func() - Wake lock work handler |
| 3229 | * @work: scheduled work |
| 3230 | * |
| 3231 | * When IPA resources are released in hdd_ipa_rm_try_release() we do |
| 3232 | * not want to immediately release the wake lock since the system |
| 3233 | * would then potentially try to suspend when there is a healthy data |
| 3234 | * rate. Deferred work is scheduled and this function handles the |
| 3235 | * work. When this function is called, if the IPA resource is still |
| 3236 | * released then we release the wake lock. |
| 3237 | * |
| 3238 | * Return: None |
| 3239 | */ |
| 3240 | static void hdd_ipa_wake_lock_timer_func(struct work_struct *work) |
| 3241 | { |
| 3242 | struct hdd_ipa_priv *hdd_ipa = container_of(to_delayed_work(work), |
| 3243 | struct hdd_ipa_priv, |
| 3244 | wake_lock_work); |
| 3245 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 3246 | qdf_spin_lock_bh(&hdd_ipa->rm_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3247 | |
| 3248 | if (hdd_ipa->rm_state != HDD_IPA_RM_RELEASED) |
| 3249 | goto end; |
| 3250 | |
| 3251 | hdd_ipa->wake_lock_released = true; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 3252 | qdf_wake_lock_release(&hdd_ipa->wake_lock, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3253 | WIFI_POWER_EVENT_WAKELOCK_IPA); |
| 3254 | |
| 3255 | end: |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 3256 | qdf_spin_unlock_bh(&hdd_ipa->rm_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3257 | } |
| 3258 | |
| 3259 | /** |
| 3260 | * hdd_ipa_rm_request() - Request resource from IPA |
| 3261 | * @hdd_ipa: Global HDD IPA context |
| 3262 | * |
| 3263 | * Return: 0 on success, negative errno on error |
| 3264 | */ |
| 3265 | static int hdd_ipa_rm_request(struct hdd_ipa_priv *hdd_ipa) |
| 3266 | { |
| 3267 | int ret = 0; |
| 3268 | |
| 3269 | if (!hdd_ipa_is_rm_enabled(hdd_ipa->hdd_ctx)) |
| 3270 | return 0; |
| 3271 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 3272 | qdf_spin_lock_bh(&hdd_ipa->rm_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3273 | |
| 3274 | switch (hdd_ipa->rm_state) { |
| 3275 | case HDD_IPA_RM_GRANTED: |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 3276 | qdf_spin_unlock_bh(&hdd_ipa->rm_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3277 | return 0; |
| 3278 | case HDD_IPA_RM_GRANT_PENDING: |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 3279 | qdf_spin_unlock_bh(&hdd_ipa->rm_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3280 | return -EINPROGRESS; |
| 3281 | case HDD_IPA_RM_RELEASED: |
| 3282 | hdd_ipa->rm_state = HDD_IPA_RM_GRANT_PENDING; |
| 3283 | break; |
| 3284 | } |
| 3285 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 3286 | qdf_spin_unlock_bh(&hdd_ipa->rm_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3287 | |
| 3288 | ret = ipa_rm_inactivity_timer_request_resource( |
| 3289 | IPA_RM_RESOURCE_WLAN_PROD); |
| 3290 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 3291 | qdf_spin_lock_bh(&hdd_ipa->rm_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3292 | if (ret == 0) { |
| 3293 | hdd_ipa->rm_state = HDD_IPA_RM_GRANTED; |
| 3294 | hdd_ipa->stats.num_rm_grant_imm++; |
| 3295 | } |
| 3296 | |
| 3297 | cancel_delayed_work(&hdd_ipa->wake_lock_work); |
| 3298 | if (hdd_ipa->wake_lock_released) { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 3299 | qdf_wake_lock_acquire(&hdd_ipa->wake_lock, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3300 | WIFI_POWER_EVENT_WAKELOCK_IPA); |
| 3301 | hdd_ipa->wake_lock_released = false; |
| 3302 | } |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 3303 | qdf_spin_unlock_bh(&hdd_ipa->rm_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3304 | |
| 3305 | return ret; |
| 3306 | } |
| 3307 | |
| 3308 | /** |
| 3309 | * hdd_ipa_rm_try_release() - Attempt to release IPA resource |
| 3310 | * @hdd_ipa: Global HDD IPA context |
| 3311 | * |
| 3312 | * Return: 0 if resources released, negative errno otherwise |
| 3313 | */ |
| 3314 | static int hdd_ipa_rm_try_release(struct hdd_ipa_priv *hdd_ipa) |
| 3315 | { |
| 3316 | int ret = 0; |
| 3317 | |
| 3318 | if (!hdd_ipa_is_rm_enabled(hdd_ipa->hdd_ctx)) |
| 3319 | return 0; |
| 3320 | |
| 3321 | if (atomic_read(&hdd_ipa->tx_ref_cnt)) |
| 3322 | return -EAGAIN; |
| 3323 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 3324 | qdf_spin_lock_bh(&hdd_ipa->pm_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3325 | |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 3326 | if (!qdf_nbuf_is_queue_empty(&hdd_ipa->pm_queue_head)) { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 3327 | qdf_spin_unlock_bh(&hdd_ipa->pm_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3328 | return -EAGAIN; |
| 3329 | } |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 3330 | qdf_spin_unlock_bh(&hdd_ipa->pm_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3331 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 3332 | qdf_spin_lock_bh(&hdd_ipa->rm_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3333 | switch (hdd_ipa->rm_state) { |
| 3334 | case HDD_IPA_RM_GRANTED: |
| 3335 | break; |
| 3336 | case HDD_IPA_RM_GRANT_PENDING: |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 3337 | qdf_spin_unlock_bh(&hdd_ipa->rm_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3338 | return -EINPROGRESS; |
| 3339 | case HDD_IPA_RM_RELEASED: |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 3340 | qdf_spin_unlock_bh(&hdd_ipa->rm_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3341 | return 0; |
| 3342 | } |
| 3343 | |
| 3344 | /* IPA driver returns immediately so set the state here to avoid any |
| 3345 | * race condition. |
| 3346 | */ |
| 3347 | hdd_ipa->rm_state = HDD_IPA_RM_RELEASED; |
| 3348 | hdd_ipa->stats.num_rm_release++; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 3349 | qdf_spin_unlock_bh(&hdd_ipa->rm_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3350 | |
Srinivas Girigowda | c16ba6d | 2017-03-25 11:43:26 -0700 | [diff] [blame] | 3351 | ret = ipa_rm_inactivity_timer_release_resource( |
| 3352 | IPA_RM_RESOURCE_WLAN_PROD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3353 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 3354 | qdf_spin_lock_bh(&hdd_ipa->rm_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3355 | if (unlikely(ret != 0)) { |
| 3356 | hdd_ipa->rm_state = HDD_IPA_RM_GRANTED; |
| 3357 | WARN_ON(1); |
| 3358 | } |
| 3359 | |
| 3360 | /* |
| 3361 | * If wake_lock is released immediately, kernel would try to suspend |
| 3362 | * immediately as well, Just avoid ping-pong between suspend-resume |
| 3363 | * while there is healthy amount of data transfer going on by |
| 3364 | * releasing the wake_lock after some delay. |
| 3365 | */ |
| 3366 | schedule_delayed_work(&hdd_ipa->wake_lock_work, |
| 3367 | msecs_to_jiffies |
| 3368 | (HDD_IPA_RX_INACTIVITY_MSEC_DELAY)); |
| 3369 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 3370 | qdf_spin_unlock_bh(&hdd_ipa->rm_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3371 | |
| 3372 | return ret; |
| 3373 | } |
| 3374 | |
| 3375 | /** |
| 3376 | * hdd_ipa_rm_notify() - IPA resource manager notifier callback |
| 3377 | * @user_data: user data registered with IPA |
| 3378 | * @event: the IPA resource manager event that occurred |
| 3379 | * @data: the data associated with the event |
| 3380 | * |
| 3381 | * Return: None |
| 3382 | */ |
| 3383 | static void hdd_ipa_rm_notify(void *user_data, enum ipa_rm_event event, |
| 3384 | unsigned long data) |
| 3385 | { |
| 3386 | struct hdd_ipa_priv *hdd_ipa = user_data; |
| 3387 | |
| 3388 | if (unlikely(!hdd_ipa)) |
| 3389 | return; |
| 3390 | |
| 3391 | if (!hdd_ipa_is_rm_enabled(hdd_ipa->hdd_ctx)) |
| 3392 | return; |
| 3393 | |
Srinivas Girigowda | 9785237 | 2017-03-06 16:52:59 -0800 | [diff] [blame] | 3394 | HDD_IPA_LOG(QDF_TRACE_LEVEL_DEBUG, "Evt: %d", event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3395 | |
| 3396 | switch (event) { |
| 3397 | case IPA_RM_RESOURCE_GRANTED: |
| 3398 | if (hdd_ipa_uc_is_enabled(hdd_ipa->hdd_ctx)) { |
| 3399 | /* RM Notification comes with ISR context |
| 3400 | * it should be serialized into work queue to avoid |
| 3401 | * ISR sleep problem |
| 3402 | */ |
| 3403 | hdd_ipa->uc_rm_work.event = event; |
| 3404 | schedule_work(&hdd_ipa->uc_rm_work.work); |
| 3405 | break; |
| 3406 | } |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 3407 | qdf_spin_lock_bh(&hdd_ipa->rm_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3408 | hdd_ipa->rm_state = HDD_IPA_RM_GRANTED; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 3409 | qdf_spin_unlock_bh(&hdd_ipa->rm_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3410 | hdd_ipa->stats.num_rm_grant++; |
| 3411 | break; |
| 3412 | |
| 3413 | case IPA_RM_RESOURCE_RELEASED: |
Srinivas Girigowda | 9785237 | 2017-03-06 16:52:59 -0800 | [diff] [blame] | 3414 | HDD_IPA_LOG(QDF_TRACE_LEVEL_DEBUG, "RM Release"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3415 | hdd_ipa->resource_unloading = false; |
| 3416 | break; |
| 3417 | |
| 3418 | default: |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3419 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, "Unknown RM Evt: %d", event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3420 | break; |
| 3421 | } |
| 3422 | } |
| 3423 | |
| 3424 | /** |
| 3425 | * hdd_ipa_rm_cons_release() - WLAN consumer resource release handler |
| 3426 | * |
| 3427 | * Callback function registered with IPA that is called when IPA wants |
| 3428 | * to release the WLAN consumer resource |
| 3429 | * |
| 3430 | * Return: 0 if the request is granted, negative errno otherwise |
| 3431 | */ |
| 3432 | static int hdd_ipa_rm_cons_release(void) |
| 3433 | { |
| 3434 | return 0; |
| 3435 | } |
| 3436 | |
| 3437 | /** |
| 3438 | * hdd_ipa_rm_cons_request() - WLAN consumer resource request handler |
| 3439 | * |
| 3440 | * Callback function registered with IPA that is called when IPA wants |
| 3441 | * to access the WLAN consumer resource |
| 3442 | * |
| 3443 | * Return: 0 if the request is granted, negative errno otherwise |
| 3444 | */ |
| 3445 | static int hdd_ipa_rm_cons_request(void) |
| 3446 | { |
Yun Park | 4d8b60a | 2015-10-22 13:59:32 -0700 | [diff] [blame] | 3447 | int ret = 0; |
| 3448 | |
| 3449 | if (ghdd_ipa->resource_loading) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3450 | HDD_IPA_LOG(QDF_TRACE_LEVEL_FATAL, |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 3451 | "IPA resource loading in progress"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3452 | ghdd_ipa->pending_cons_req = true; |
Yun Park | 4d8b60a | 2015-10-22 13:59:32 -0700 | [diff] [blame] | 3453 | ret = -EINPROGRESS; |
| 3454 | } else if (ghdd_ipa->resource_unloading) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3455 | HDD_IPA_LOG(QDF_TRACE_LEVEL_FATAL, |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 3456 | "IPA resource unloading in progress"); |
Yun Park | 4d8b60a | 2015-10-22 13:59:32 -0700 | [diff] [blame] | 3457 | ghdd_ipa->pending_cons_req = true; |
| 3458 | ret = -EPERM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3459 | } |
Yun Park | 4d8b60a | 2015-10-22 13:59:32 -0700 | [diff] [blame] | 3460 | |
| 3461 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3462 | } |
| 3463 | |
| 3464 | /** |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 3465 | * __hdd_ipa_set_perf_level() - Set IPA performance level |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3466 | * @hdd_ctx: Global HDD context |
| 3467 | * @tx_packets: Number of packets transmitted in the last sample period |
| 3468 | * @rx_packets: Number of packets received in the last sample period |
| 3469 | * |
| 3470 | * Return: 0 on success, negative errno on error |
| 3471 | */ |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 3472 | static int __hdd_ipa_set_perf_level(hdd_context_t *hdd_ctx, uint64_t tx_packets, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3473 | uint64_t rx_packets) |
| 3474 | { |
| 3475 | uint32_t next_cons_bw, next_prod_bw; |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 3476 | struct hdd_ipa_priv *hdd_ipa; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3477 | struct ipa_rm_perf_profile profile; |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 3478 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3479 | int ret; |
| 3480 | |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 3481 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 3482 | return 0; |
| 3483 | |
| 3484 | hdd_ipa = hdd_ctx->hdd_ipa; |
| 3485 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3486 | if ((!hdd_ipa_is_enabled(hdd_ctx)) || |
| 3487 | (!hdd_ipa_is_clk_scaling_enabled(hdd_ctx))) |
| 3488 | return 0; |
| 3489 | |
| 3490 | memset(&profile, 0, sizeof(profile)); |
| 3491 | |
| 3492 | if (tx_packets > (hdd_ctx->config->busBandwidthHighThreshold / 2)) |
| 3493 | next_cons_bw = hdd_ctx->config->IpaHighBandwidthMbps; |
| 3494 | else if (tx_packets > |
| 3495 | (hdd_ctx->config->busBandwidthMediumThreshold / 2)) |
| 3496 | next_cons_bw = hdd_ctx->config->IpaMediumBandwidthMbps; |
| 3497 | else |
| 3498 | next_cons_bw = hdd_ctx->config->IpaLowBandwidthMbps; |
| 3499 | |
| 3500 | if (rx_packets > (hdd_ctx->config->busBandwidthHighThreshold / 2)) |
| 3501 | next_prod_bw = hdd_ctx->config->IpaHighBandwidthMbps; |
| 3502 | else if (rx_packets > |
| 3503 | (hdd_ctx->config->busBandwidthMediumThreshold / 2)) |
| 3504 | next_prod_bw = hdd_ctx->config->IpaMediumBandwidthMbps; |
| 3505 | else |
| 3506 | next_prod_bw = hdd_ctx->config->IpaLowBandwidthMbps; |
| 3507 | |
Yun Park | ec84530 | 2016-12-15 09:22:57 -0800 | [diff] [blame] | 3508 | HDD_IPA_DP_LOG(QDF_TRACE_LEVEL_DEBUG, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3509 | "CONS perf curr: %d, next: %d", |
| 3510 | hdd_ipa->curr_cons_bw, next_cons_bw); |
Yun Park | ec84530 | 2016-12-15 09:22:57 -0800 | [diff] [blame] | 3511 | HDD_IPA_DP_LOG(QDF_TRACE_LEVEL_DEBUG, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3512 | "PROD perf curr: %d, next: %d", |
| 3513 | hdd_ipa->curr_prod_bw, next_prod_bw); |
| 3514 | |
| 3515 | if (hdd_ipa->curr_cons_bw != next_cons_bw) { |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 3516 | hdd_debug("Requesting CONS perf curr: %d, next: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3517 | hdd_ipa->curr_cons_bw, next_cons_bw); |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 3518 | ret = cdp_ipa_set_perf_level(soc, IPA_RM_RESOURCE_WLAN_CONS, |
| 3519 | next_cons_bw); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3520 | if (ret) { |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 3521 | hdd_err("RM CONS set perf profile failed: %d", ret); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3522 | |
| 3523 | return ret; |
| 3524 | } |
| 3525 | hdd_ipa->curr_cons_bw = next_cons_bw; |
| 3526 | hdd_ipa->stats.num_cons_perf_req++; |
| 3527 | } |
| 3528 | |
| 3529 | if (hdd_ipa->curr_prod_bw != next_prod_bw) { |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 3530 | hdd_debug("Requesting PROD perf curr: %d, next: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3531 | hdd_ipa->curr_prod_bw, next_prod_bw); |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 3532 | ret = cdp_ipa_set_perf_level(soc, IPA_RM_RESOURCE_WLAN_PROD, |
| 3533 | next_prod_bw); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3534 | if (ret) { |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 3535 | hdd_err("RM PROD set perf profile failed: %d", ret); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3536 | return ret; |
| 3537 | } |
| 3538 | hdd_ipa->curr_prod_bw = next_prod_bw; |
| 3539 | hdd_ipa->stats.num_prod_perf_req++; |
| 3540 | } |
| 3541 | |
| 3542 | return 0; |
| 3543 | } |
| 3544 | |
| 3545 | /** |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 3546 | * hdd_ipa_set_perf_level() - SSR wrapper for __hdd_ipa_set_perf_level |
| 3547 | * @hdd_ctx: Global HDD context |
| 3548 | * @tx_packets: Number of packets transmitted in the last sample period |
| 3549 | * @rx_packets: Number of packets received in the last sample period |
| 3550 | * |
| 3551 | * Return: 0 on success, negative errno on error |
| 3552 | */ |
| 3553 | int hdd_ipa_set_perf_level(hdd_context_t *hdd_ctx, uint64_t tx_packets, |
| 3554 | uint64_t rx_packets) |
| 3555 | { |
| 3556 | int ret; |
| 3557 | |
| 3558 | cds_ssr_protect(__func__); |
| 3559 | ret = __hdd_ipa_set_perf_level(hdd_ctx, tx_packets, rx_packets); |
| 3560 | cds_ssr_unprotect(__func__); |
| 3561 | |
| 3562 | return ret; |
| 3563 | } |
| 3564 | |
| 3565 | /** |
Rajeev Kumar | 217f217 | 2016-01-06 18:11:55 -0800 | [diff] [blame] | 3566 | * hdd_ipa_init_uc_rm_work - init ipa uc resource manager work |
| 3567 | * @work: struct work_struct |
| 3568 | * @work_handler: work_handler |
| 3569 | * |
| 3570 | * Return: none |
| 3571 | */ |
Rajeev Kumar | 217f217 | 2016-01-06 18:11:55 -0800 | [diff] [blame] | 3572 | static void hdd_ipa_init_uc_rm_work(struct work_struct *work, |
| 3573 | work_func_t work_handler) |
| 3574 | { |
| 3575 | INIT_WORK(work, work_handler); |
| 3576 | } |
Rajeev Kumar | 217f217 | 2016-01-06 18:11:55 -0800 | [diff] [blame] | 3577 | |
| 3578 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3579 | * hdd_ipa_setup_rm() - Setup IPA resource management |
| 3580 | * @hdd_ipa: Global HDD IPA context |
| 3581 | * |
| 3582 | * Return: 0 on success, negative errno on error |
| 3583 | */ |
| 3584 | static int hdd_ipa_setup_rm(struct hdd_ipa_priv *hdd_ipa) |
| 3585 | { |
| 3586 | struct ipa_rm_create_params create_params = { 0 }; |
| 3587 | int ret; |
| 3588 | |
| 3589 | if (!hdd_ipa_is_rm_enabled(hdd_ipa->hdd_ctx)) |
| 3590 | return 0; |
| 3591 | |
Rajeev Kumar | 217f217 | 2016-01-06 18:11:55 -0800 | [diff] [blame] | 3592 | hdd_ipa_init_uc_rm_work(&hdd_ipa->uc_rm_work.work, |
| 3593 | hdd_ipa_uc_rm_notify_defer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3594 | memset(&create_params, 0, sizeof(create_params)); |
| 3595 | create_params.name = IPA_RM_RESOURCE_WLAN_PROD; |
| 3596 | create_params.reg_params.user_data = hdd_ipa; |
| 3597 | create_params.reg_params.notify_cb = hdd_ipa_rm_notify; |
| 3598 | create_params.floor_voltage = IPA_VOLTAGE_SVS; |
| 3599 | |
| 3600 | ret = ipa_rm_create_resource(&create_params); |
| 3601 | if (ret) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3602 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3603 | "Create RM resource failed: %d", ret); |
| 3604 | goto setup_rm_fail; |
| 3605 | } |
| 3606 | |
| 3607 | memset(&create_params, 0, sizeof(create_params)); |
| 3608 | create_params.name = IPA_RM_RESOURCE_WLAN_CONS; |
| 3609 | create_params.request_resource = hdd_ipa_rm_cons_request; |
| 3610 | create_params.release_resource = hdd_ipa_rm_cons_release; |
| 3611 | create_params.floor_voltage = IPA_VOLTAGE_SVS; |
| 3612 | |
| 3613 | ret = ipa_rm_create_resource(&create_params); |
| 3614 | if (ret) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3615 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3616 | "Create RM CONS resource failed: %d", ret); |
| 3617 | goto delete_prod; |
| 3618 | } |
| 3619 | |
| 3620 | ipa_rm_add_dependency(IPA_RM_RESOURCE_WLAN_PROD, |
| 3621 | IPA_RM_RESOURCE_APPS_CONS); |
| 3622 | |
| 3623 | ret = ipa_rm_inactivity_timer_init(IPA_RM_RESOURCE_WLAN_PROD, |
| 3624 | HDD_IPA_RX_INACTIVITY_MSEC_DELAY); |
| 3625 | if (ret) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3626 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, "Timer init failed: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3627 | ret); |
| 3628 | goto timer_init_failed; |
| 3629 | } |
| 3630 | |
| 3631 | /* Set the lowest bandwidth to start with */ |
| 3632 | ret = hdd_ipa_set_perf_level(hdd_ipa->hdd_ctx, 0, 0); |
| 3633 | |
| 3634 | if (ret) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3635 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3636 | "Set perf level failed: %d", ret); |
| 3637 | goto set_perf_failed; |
| 3638 | } |
| 3639 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 3640 | qdf_wake_lock_create(&hdd_ipa->wake_lock, "wlan_ipa"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3641 | INIT_DELAYED_WORK(&hdd_ipa->wake_lock_work, |
| 3642 | hdd_ipa_wake_lock_timer_func); |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 3643 | qdf_spinlock_create(&hdd_ipa->rm_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3644 | hdd_ipa->rm_state = HDD_IPA_RM_RELEASED; |
| 3645 | hdd_ipa->wake_lock_released = true; |
| 3646 | atomic_set(&hdd_ipa->tx_ref_cnt, 0); |
| 3647 | |
| 3648 | return ret; |
| 3649 | |
| 3650 | set_perf_failed: |
| 3651 | ipa_rm_inactivity_timer_destroy(IPA_RM_RESOURCE_WLAN_PROD); |
| 3652 | |
| 3653 | timer_init_failed: |
| 3654 | ipa_rm_delete_resource(IPA_RM_RESOURCE_WLAN_CONS); |
| 3655 | |
| 3656 | delete_prod: |
| 3657 | ipa_rm_delete_resource(IPA_RM_RESOURCE_WLAN_PROD); |
| 3658 | |
| 3659 | setup_rm_fail: |
| 3660 | return ret; |
| 3661 | } |
| 3662 | |
| 3663 | /** |
| 3664 | * hdd_ipa_destroy_rm_resource() - Destroy IPA resources |
| 3665 | * @hdd_ipa: Global HDD IPA context |
| 3666 | * |
| 3667 | * Destroys all resources associated with the IPA resource manager |
| 3668 | * |
| 3669 | * Return: None |
| 3670 | */ |
| 3671 | static void hdd_ipa_destroy_rm_resource(struct hdd_ipa_priv *hdd_ipa) |
| 3672 | { |
| 3673 | int ret; |
| 3674 | |
| 3675 | if (!hdd_ipa_is_rm_enabled(hdd_ipa->hdd_ctx)) |
| 3676 | return; |
| 3677 | |
| 3678 | cancel_delayed_work_sync(&hdd_ipa->wake_lock_work); |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 3679 | qdf_wake_lock_destroy(&hdd_ipa->wake_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3680 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3681 | cancel_work_sync(&hdd_ipa->uc_rm_work.work); |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 3682 | qdf_spinlock_destroy(&hdd_ipa->rm_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3683 | |
| 3684 | ipa_rm_inactivity_timer_destroy(IPA_RM_RESOURCE_WLAN_PROD); |
| 3685 | |
| 3686 | ret = ipa_rm_delete_resource(IPA_RM_RESOURCE_WLAN_PROD); |
| 3687 | if (ret) |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3688 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3689 | "RM PROD resource delete failed %d", ret); |
| 3690 | |
| 3691 | ret = ipa_rm_delete_resource(IPA_RM_RESOURCE_WLAN_CONS); |
| 3692 | if (ret) |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3693 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3694 | "RM CONS resource delete failed %d", ret); |
| 3695 | } |
| 3696 | |
tfyu | 0380a97 | 2017-07-13 18:19:37 +0800 | [diff] [blame] | 3697 | #ifdef QCA_CONFIG_SMP |
| 3698 | static int hdd_ipa_aggregated_rx_ind(qdf_nbuf_t skb) |
| 3699 | { |
| 3700 | return netif_rx_ni(skb); |
| 3701 | } |
| 3702 | #else |
| 3703 | static int hdd_ipa_aggregated_rx_ind(qdf_nbuf_t skb) |
| 3704 | { |
| 3705 | struct iphdr *ip_h; |
| 3706 | static atomic_t softirq_mitigation_cntr = |
| 3707 | ATOMIC_INIT(IPA_WLAN_RX_SOFTIRQ_THRESH); |
| 3708 | int result; |
| 3709 | |
| 3710 | ip_h = (struct iphdr *)(skb->data); |
| 3711 | if ((skb->protocol == htons(ETH_P_IP)) && |
| 3712 | (ip_h->protocol == IPPROTO_ICMP)) { |
| 3713 | result = netif_rx_ni(skb); |
| 3714 | } else { |
| 3715 | /* Call netif_rx_ni for every IPA_WLAN_RX_SOFTIRQ_THRESH packets |
| 3716 | * to avoid excessive softirq's. |
| 3717 | */ |
| 3718 | if (atomic_dec_and_test(&softirq_mitigation_cntr)) { |
| 3719 | result = netif_rx_ni(skb); |
| 3720 | atomic_set(&softirq_mitigation_cntr, |
| 3721 | IPA_WLAN_RX_SOFTIRQ_THRESH); |
| 3722 | } else { |
| 3723 | result = netif_rx(skb); |
| 3724 | } |
| 3725 | } |
| 3726 | |
| 3727 | return result; |
| 3728 | } |
| 3729 | #endif |
| 3730 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3731 | /** |
| 3732 | * hdd_ipa_send_skb_to_network() - Send skb to kernel |
| 3733 | * @skb: network buffer |
| 3734 | * @adapter: network adapter |
| 3735 | * |
| 3736 | * Called when a network buffer is received which should not be routed |
| 3737 | * to the IPA module. |
| 3738 | * |
| 3739 | * Return: None |
| 3740 | */ |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 3741 | static void hdd_ipa_send_skb_to_network(qdf_nbuf_t skb, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3742 | hdd_adapter_t *adapter) |
| 3743 | { |
tfyu | 0380a97 | 2017-07-13 18:19:37 +0800 | [diff] [blame] | 3744 | int result; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3745 | struct hdd_ipa_priv *hdd_ipa = ghdd_ipa; |
| 3746 | unsigned int cpu_index; |
| 3747 | |
| 3748 | if (!adapter || adapter->magic != WLAN_HDD_ADAPTER_MAGIC) { |
Srinivas Girigowda | 9785237 | 2017-03-06 16:52:59 -0800 | [diff] [blame] | 3749 | HDD_IPA_LOG(QDF_TRACE_LEVEL_DEBUG, "Invalid adapter: 0x%p", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3750 | adapter); |
| 3751 | HDD_IPA_INCREASE_INTERNAL_DROP_COUNT(hdd_ipa); |
Yun Park | f8d6a12 | 2016-10-11 15:49:43 -0700 | [diff] [blame] | 3752 | kfree_skb(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3753 | return; |
| 3754 | } |
| 3755 | |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 3756 | if (cds_is_driver_unloading()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3757 | HDD_IPA_INCREASE_INTERNAL_DROP_COUNT(hdd_ipa); |
Yun Park | f8d6a12 | 2016-10-11 15:49:43 -0700 | [diff] [blame] | 3758 | kfree_skb(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3759 | return; |
| 3760 | } |
| 3761 | |
| 3762 | skb->destructor = hdd_ipa_uc_rt_debug_destructor; |
| 3763 | skb->dev = adapter->dev; |
| 3764 | skb->protocol = eth_type_trans(skb, skb->dev); |
| 3765 | skb->ip_summed = CHECKSUM_NONE; |
| 3766 | |
| 3767 | cpu_index = wlan_hdd_get_cpu(); |
| 3768 | |
| 3769 | ++adapter->hdd_stats.hddTxRxStats.rxPackets[cpu_index]; |
tfyu | 0380a97 | 2017-07-13 18:19:37 +0800 | [diff] [blame] | 3770 | result = hdd_ipa_aggregated_rx_ind(skb); |
| 3771 | if (result == NET_RX_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3772 | ++adapter->hdd_stats.hddTxRxStats.rxDelivered[cpu_index]; |
| 3773 | else |
| 3774 | ++adapter->hdd_stats.hddTxRxStats.rxRefused[cpu_index]; |
| 3775 | |
| 3776 | HDD_IPA_INCREASE_NET_SEND_COUNT(hdd_ipa); |
| 3777 | adapter->dev->last_rx = jiffies; |
| 3778 | } |
| 3779 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3780 | /** |
Leo Chang | 69c3969 | 2016-10-12 20:11:12 -0700 | [diff] [blame] | 3781 | * hdd_ipa_forward() - handle packet forwarding to wlan tx |
| 3782 | * @hdd_ipa: pointer to hdd ipa context |
| 3783 | * @adapter: network adapter |
| 3784 | * @skb: data pointer |
| 3785 | * |
| 3786 | * if exception packet has set forward bit, copied new packet should be |
| 3787 | * forwarded to wlan tx. if wlan subsystem is in suspend state, packet should |
| 3788 | * put into pm queue and tx procedure will be differed |
| 3789 | * |
| 3790 | * Return: None |
| 3791 | */ |
Jeff Johnson | 414f7ea | 2016-10-19 18:50:02 -0700 | [diff] [blame] | 3792 | static void hdd_ipa_forward(struct hdd_ipa_priv *hdd_ipa, |
| 3793 | hdd_adapter_t *adapter, qdf_nbuf_t skb) |
Leo Chang | 69c3969 | 2016-10-12 20:11:12 -0700 | [diff] [blame] | 3794 | { |
Leo Chang | 69c3969 | 2016-10-12 20:11:12 -0700 | [diff] [blame] | 3795 | struct hdd_ipa_pm_tx_cb *pm_tx_cb; |
| 3796 | |
Leo Chang | 69c3969 | 2016-10-12 20:11:12 -0700 | [diff] [blame] | 3797 | qdf_spin_lock_bh(&hdd_ipa->pm_lock); |
| 3798 | /* WLAN subsystem is in suspend, put int queue */ |
| 3799 | if (hdd_ipa->suspended) { |
| 3800 | qdf_spin_unlock_bh(&hdd_ipa->pm_lock); |
| 3801 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
| 3802 | "TX in SUSPEND PUT QUEUE"); |
Prakash Dhavali | 87b38e3 | 2016-11-14 16:22:53 -0800 | [diff] [blame] | 3803 | qdf_mem_set(skb->cb, sizeof(skb->cb), 0); |
| 3804 | pm_tx_cb = (struct hdd_ipa_pm_tx_cb *)skb->cb; |
Leo Chang | 69c3969 | 2016-10-12 20:11:12 -0700 | [diff] [blame] | 3805 | pm_tx_cb->exception = true; |
| 3806 | pm_tx_cb->adapter = adapter; |
| 3807 | qdf_spin_lock_bh(&hdd_ipa->pm_lock); |
Prakash Dhavali | 87b38e3 | 2016-11-14 16:22:53 -0800 | [diff] [blame] | 3808 | qdf_nbuf_queue_add(&hdd_ipa->pm_queue_head, skb); |
Leo Chang | 69c3969 | 2016-10-12 20:11:12 -0700 | [diff] [blame] | 3809 | qdf_spin_unlock_bh(&hdd_ipa->pm_lock); |
| 3810 | hdd_ipa->stats.num_tx_queued++; |
| 3811 | } else { |
| 3812 | /* Resume, put packet into WLAN TX */ |
| 3813 | qdf_spin_unlock_bh(&hdd_ipa->pm_lock); |
Prakash Dhavali | 87b38e3 | 2016-11-14 16:22:53 -0800 | [diff] [blame] | 3814 | if (hdd_softap_hard_start_xmit(skb, adapter->dev)) { |
Leo Chang | 69c3969 | 2016-10-12 20:11:12 -0700 | [diff] [blame] | 3815 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
| 3816 | "packet tx fail"); |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 3817 | hdd_ipa->stats.num_tx_fwd_err++; |
Leo Chang | 69c3969 | 2016-10-12 20:11:12 -0700 | [diff] [blame] | 3818 | } else { |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 3819 | hdd_ipa->stats.num_tx_fwd_ok++; |
Leo Chang | 69c3969 | 2016-10-12 20:11:12 -0700 | [diff] [blame] | 3820 | hdd_ipa->ipa_tx_forward++; |
| 3821 | } |
| 3822 | } |
| 3823 | } |
| 3824 | |
| 3825 | /** |
Prakash Dhavali | 87b38e3 | 2016-11-14 16:22:53 -0800 | [diff] [blame] | 3826 | * hdd_ipa_intrabss_forward() - Forward intra bss packets. |
| 3827 | * @hdd_ipa: pointer to HDD IPA struct |
| 3828 | * @adapter: hdd adapter pointer |
| 3829 | * @desc: Firmware descriptor |
| 3830 | * @skb: Data buffer |
| 3831 | * |
| 3832 | * Return: |
| 3833 | * HDD_IPA_FORWARD_PKT_NONE |
| 3834 | * HDD_IPA_FORWARD_PKT_DISCARD |
| 3835 | * HDD_IPA_FORWARD_PKT_LOCAL_STACK |
| 3836 | * |
| 3837 | */ |
| 3838 | |
| 3839 | static enum hdd_ipa_forward_type hdd_ipa_intrabss_forward( |
| 3840 | struct hdd_ipa_priv *hdd_ipa, |
| 3841 | hdd_adapter_t *adapter, |
| 3842 | uint8_t desc, |
| 3843 | qdf_nbuf_t skb) |
| 3844 | { |
| 3845 | int ret = HDD_IPA_FORWARD_PKT_NONE; |
| 3846 | |
| 3847 | if ((desc & FW_RX_DESC_FORWARD_M)) { |
Poddar, Siddarth | 8e3ee2d | 2016-11-29 20:17:01 +0530 | [diff] [blame] | 3848 | if (!ol_txrx_fwd_desc_thresh_check( |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 3849 | (struct ol_txrx_vdev_t *)ol_txrx_get_vdev_from_vdev_id( |
| 3850 | adapter->sessionId))) { |
Poddar, Siddarth | 8e3ee2d | 2016-11-29 20:17:01 +0530 | [diff] [blame] | 3851 | /* Drop the packet*/ |
| 3852 | hdd_ipa->stats.num_tx_fwd_err++; |
| 3853 | kfree_skb(skb); |
| 3854 | ret = HDD_IPA_FORWARD_PKT_DISCARD; |
| 3855 | return ret; |
| 3856 | } |
Prakash Dhavali | 87b38e3 | 2016-11-14 16:22:53 -0800 | [diff] [blame] | 3857 | HDD_IPA_LOG(QDF_TRACE_LEVEL_DEBUG, |
| 3858 | "Forward packet to Tx (fw_desc=%d)", desc); |
| 3859 | hdd_ipa->ipa_tx_forward++; |
| 3860 | |
| 3861 | if ((desc & FW_RX_DESC_DISCARD_M)) { |
| 3862 | hdd_ipa_forward(hdd_ipa, adapter, skb); |
| 3863 | hdd_ipa->ipa_rx_internel_drop_count++; |
| 3864 | hdd_ipa->ipa_rx_discard++; |
| 3865 | ret = HDD_IPA_FORWARD_PKT_DISCARD; |
| 3866 | } else { |
| 3867 | struct sk_buff *cloned_skb = skb_clone(skb, GFP_ATOMIC); |
Srinivas Girigowda | c16ba6d | 2017-03-25 11:43:26 -0700 | [diff] [blame] | 3868 | |
Prakash Dhavali | 87b38e3 | 2016-11-14 16:22:53 -0800 | [diff] [blame] | 3869 | if (cloned_skb) |
| 3870 | hdd_ipa_forward(hdd_ipa, adapter, cloned_skb); |
| 3871 | else |
| 3872 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
| 3873 | "%s: tx skb alloc failed", |
| 3874 | __func__); |
| 3875 | ret = HDD_IPA_FORWARD_PKT_LOCAL_STACK; |
| 3876 | } |
| 3877 | } |
| 3878 | |
| 3879 | return ret; |
| 3880 | } |
| 3881 | |
| 3882 | /** |
Yun Park | 637d648 | 2016-10-05 10:51:33 -0700 | [diff] [blame] | 3883 | * __hdd_ipa_w2i_cb() - WLAN to IPA callback handler |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3884 | * @priv: pointer to private data registered with IPA (we register a |
| 3885 | * pointer to the global IPA context) |
| 3886 | * @evt: the IPA event which triggered the callback |
| 3887 | * @data: data associated with the event |
| 3888 | * |
| 3889 | * Return: None |
| 3890 | */ |
Yun Park | f8d6a12 | 2016-10-11 15:49:43 -0700 | [diff] [blame] | 3891 | static void __hdd_ipa_w2i_cb(void *priv, enum ipa_dp_evt_type evt, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3892 | unsigned long data) |
| 3893 | { |
| 3894 | struct hdd_ipa_priv *hdd_ipa = NULL; |
| 3895 | hdd_adapter_t *adapter = NULL; |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 3896 | qdf_nbuf_t skb; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3897 | uint8_t iface_id; |
| 3898 | uint8_t session_id; |
| 3899 | struct hdd_ipa_iface_context *iface_context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3900 | uint8_t fw_desc; |
Yun Park | f8d6a12 | 2016-10-11 15:49:43 -0700 | [diff] [blame] | 3901 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3902 | |
| 3903 | hdd_ipa = (struct hdd_ipa_priv *)priv; |
| 3904 | |
Prakash Dhavali | 63f8fd6 | 2016-11-14 14:40:42 -0800 | [diff] [blame] | 3905 | if (!hdd_ipa || wlan_hdd_validate_context(hdd_ipa->hdd_ctx)) |
| 3906 | return; |
| 3907 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3908 | switch (evt) { |
| 3909 | case IPA_RECEIVE: |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 3910 | skb = (qdf_nbuf_t) data; |
Yun Park | f8d6a12 | 2016-10-11 15:49:43 -0700 | [diff] [blame] | 3911 | |
| 3912 | /* |
| 3913 | * When SSR is going on or driver is unloading, |
| 3914 | * just drop the packets. |
| 3915 | */ |
| 3916 | status = wlan_hdd_validate_context(hdd_ipa->hdd_ctx); |
| 3917 | if (0 != status) { |
| 3918 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
| 3919 | "Invalid context: drop packet"); |
| 3920 | HDD_IPA_INCREASE_INTERNAL_DROP_COUNT(hdd_ipa); |
| 3921 | kfree_skb(skb); |
| 3922 | return; |
| 3923 | } |
| 3924 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3925 | if (hdd_ipa_uc_is_enabled(hdd_ipa->hdd_ctx)) { |
| 3926 | session_id = (uint8_t)skb->cb[0]; |
Prakash Dhavali | 89d406d | 2016-11-23 11:11:00 -0800 | [diff] [blame] | 3927 | iface_id = hdd_ipa->vdev_to_iface[session_id]; |
Srinivas Girigowda | 9785237 | 2017-03-06 16:52:59 -0800 | [diff] [blame] | 3928 | HDD_IPA_DP_LOG(QDF_TRACE_LEVEL_DEBUG, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3929 | "IPA_RECEIVE: session_id=%u, iface_id=%u", |
| 3930 | session_id, iface_id); |
| 3931 | } else { |
| 3932 | iface_id = HDD_IPA_GET_IFACE_ID(skb->data); |
| 3933 | } |
| 3934 | |
| 3935 | if (iface_id >= HDD_IPA_MAX_IFACE) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3936 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3937 | "IPA_RECEIVE: Invalid iface_id: %u", |
| 3938 | iface_id); |
Srinivas Girigowda | 9785237 | 2017-03-06 16:52:59 -0800 | [diff] [blame] | 3939 | HDD_IPA_DBG_DUMP(QDF_TRACE_LEVEL_DEBUG, |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 3940 | "w2i -- skb", |
| 3941 | skb->data, HDD_IPA_DBG_DUMP_RX_LEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3942 | HDD_IPA_INCREASE_INTERNAL_DROP_COUNT(hdd_ipa); |
Yun Park | f8d6a12 | 2016-10-11 15:49:43 -0700 | [diff] [blame] | 3943 | kfree_skb(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3944 | return; |
| 3945 | } |
| 3946 | |
| 3947 | iface_context = &hdd_ipa->iface_context[iface_id]; |
| 3948 | adapter = iface_context->adapter; |
Yun Park | 16a7826 | 2017-02-01 12:15:03 -0800 | [diff] [blame] | 3949 | if (!adapter) { |
| 3950 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
| 3951 | "IPA_RECEIVE: Adapter is NULL"); |
| 3952 | HDD_IPA_INCREASE_INTERNAL_DROP_COUNT(hdd_ipa); |
| 3953 | kfree_skb(skb); |
| 3954 | return; |
| 3955 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3956 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3957 | HDD_IPA_DBG_DUMP(QDF_TRACE_LEVEL_DEBUG, |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 3958 | "w2i -- skb", |
| 3959 | skb->data, HDD_IPA_DBG_DUMP_RX_LEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3960 | if (hdd_ipa_uc_is_enabled(hdd_ipa->hdd_ctx)) { |
| 3961 | hdd_ipa->stats.num_rx_excep++; |
| 3962 | skb_pull(skb, HDD_IPA_UC_WLAN_CLD_HDR_LEN); |
| 3963 | } else { |
| 3964 | skb_pull(skb, HDD_IPA_WLAN_CLD_HDR_LEN); |
| 3965 | } |
| 3966 | |
| 3967 | iface_context->stats.num_rx_ipa_excep++; |
| 3968 | |
| 3969 | /* Disable to forward Intra-BSS Rx packets when |
| 3970 | * ap_isolate=1 in hostapd.conf |
| 3971 | */ |
Yun Park | 046101c | 2016-09-02 15:32:14 -0700 | [diff] [blame] | 3972 | if (!adapter->sessionCtx.ap.apDisableIntraBssFwd) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3973 | /* |
| 3974 | * When INTRA_BSS_FWD_OFFLOAD is enabled, FW will send |
| 3975 | * all Rx packets to IPA uC, which need to be forwarded |
| 3976 | * to other interface. |
| 3977 | * And, IPA driver will send back to WLAN host driver |
| 3978 | * through exception pipe with fw_desc field set by FW. |
| 3979 | * Here we are checking fw_desc field for FORWARD bit |
| 3980 | * set, and forward to Tx. Then copy to kernel stack |
| 3981 | * only when DISCARD bit is not set. |
| 3982 | */ |
| 3983 | fw_desc = (uint8_t)skb->cb[1]; |
Prakash Dhavali | 87b38e3 | 2016-11-14 16:22:53 -0800 | [diff] [blame] | 3984 | if (HDD_IPA_FORWARD_PKT_DISCARD == |
| 3985 | hdd_ipa_intrabss_forward(hdd_ipa, adapter, |
| 3986 | fw_desc, skb)) |
Mahesh Kumar Kalikot Veetil | 221dc67 | 2015-11-06 14:27:28 -0800 | [diff] [blame] | 3987 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3988 | } else { |
Srinivas Girigowda | 9785237 | 2017-03-06 16:52:59 -0800 | [diff] [blame] | 3989 | HDD_IPA_LOG(QDF_TRACE_LEVEL_DEBUG, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3990 | "Intra-BSS FWD is disabled-skip forward to Tx"); |
| 3991 | } |
| 3992 | |
| 3993 | hdd_ipa_send_skb_to_network(skb, adapter); |
| 3994 | break; |
| 3995 | |
| 3996 | default: |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3997 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3998 | "w2i cb wrong event: 0x%x", evt); |
| 3999 | return; |
| 4000 | } |
| 4001 | } |
| 4002 | |
| 4003 | /** |
Yun Park | f8d6a12 | 2016-10-11 15:49:43 -0700 | [diff] [blame] | 4004 | * hdd_ipa_w2i_cb() - SSR wrapper for __hdd_ipa_w2i_cb |
| 4005 | * @priv: pointer to private data registered with IPA (we register a |
| 4006 | * pointer to the global IPA context) |
| 4007 | * @evt: the IPA event which triggered the callback |
| 4008 | * @data: data associated with the event |
| 4009 | * |
| 4010 | * Return: None |
| 4011 | */ |
| 4012 | static void hdd_ipa_w2i_cb(void *priv, enum ipa_dp_evt_type evt, |
| 4013 | unsigned long data) |
| 4014 | { |
| 4015 | cds_ssr_protect(__func__); |
| 4016 | __hdd_ipa_w2i_cb(priv, evt, data); |
| 4017 | cds_ssr_unprotect(__func__); |
| 4018 | } |
| 4019 | |
| 4020 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4021 | * hdd_ipa_nbuf_cb() - IPA TX complete callback |
| 4022 | * @skb: packet buffer which was transmitted |
| 4023 | * |
| 4024 | * Return: None |
| 4025 | */ |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 4026 | void hdd_ipa_nbuf_cb(qdf_nbuf_t skb) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4027 | { |
| 4028 | struct hdd_ipa_priv *hdd_ipa = ghdd_ipa; |
Yun Park | 52b2b99 | 2016-09-22 15:49:51 -0700 | [diff] [blame] | 4029 | struct ipa_rx_data *ipa_tx_desc; |
| 4030 | struct hdd_ipa_tx_desc *tx_desc; |
| 4031 | uint16_t id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4032 | |
Yun Park | 52b2b99 | 2016-09-22 15:49:51 -0700 | [diff] [blame] | 4033 | if (!qdf_nbuf_ipa_owned_get(skb)) { |
| 4034 | dev_kfree_skb_any(skb); |
| 4035 | return; |
| 4036 | } |
| 4037 | |
| 4038 | /* Get Tx desc pointer from SKB CB */ |
| 4039 | id = QDF_NBUF_CB_TX_IPA_PRIV(skb); |
| 4040 | tx_desc = hdd_ipa->tx_desc_list + id; |
| 4041 | ipa_tx_desc = tx_desc->ipa_tx_desc_ptr; |
| 4042 | |
| 4043 | /* Return Tx Desc to IPA */ |
| 4044 | ipa_free_skb(ipa_tx_desc); |
| 4045 | |
| 4046 | /* Return to free tx desc list */ |
| 4047 | qdf_spin_lock_bh(&hdd_ipa->q_lock); |
| 4048 | tx_desc->ipa_tx_desc_ptr = NULL; |
| 4049 | list_add_tail(&tx_desc->link, &hdd_ipa->free_tx_desc_head); |
| 4050 | hdd_ipa->stats.num_tx_desc_q_cnt--; |
| 4051 | qdf_spin_unlock_bh(&hdd_ipa->q_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4052 | |
| 4053 | hdd_ipa->stats.num_tx_comp_cnt++; |
| 4054 | |
| 4055 | atomic_dec(&hdd_ipa->tx_ref_cnt); |
| 4056 | |
| 4057 | hdd_ipa_rm_try_release(hdd_ipa); |
| 4058 | } |
| 4059 | |
| 4060 | /** |
| 4061 | * hdd_ipa_send_pkt_to_tl() - Send an IPA packet to TL |
| 4062 | * @iface_context: interface-specific IPA context |
| 4063 | * @ipa_tx_desc: packet data descriptor |
| 4064 | * |
| 4065 | * Return: None |
| 4066 | */ |
| 4067 | static void hdd_ipa_send_pkt_to_tl( |
| 4068 | struct hdd_ipa_iface_context *iface_context, |
| 4069 | struct ipa_rx_data *ipa_tx_desc) |
| 4070 | { |
| 4071 | struct hdd_ipa_priv *hdd_ipa = iface_context->hdd_ipa; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4072 | hdd_adapter_t *adapter = NULL; |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 4073 | qdf_nbuf_t skb; |
Yun Park | 52b2b99 | 2016-09-22 15:49:51 -0700 | [diff] [blame] | 4074 | struct hdd_ipa_tx_desc *tx_desc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4075 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 4076 | qdf_spin_lock_bh(&iface_context->interface_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4077 | adapter = iface_context->adapter; |
| 4078 | if (!adapter) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4079 | HDD_IPA_LOG(QDF_TRACE_LEVEL_WARN, "Interface Down"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4080 | ipa_free_skb(ipa_tx_desc); |
| 4081 | iface_context->stats.num_tx_drop++; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 4082 | qdf_spin_unlock_bh(&iface_context->interface_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4083 | hdd_ipa_rm_try_release(hdd_ipa); |
| 4084 | return; |
| 4085 | } |
| 4086 | |
| 4087 | /* |
| 4088 | * During CAC period, data packets shouldn't be sent over the air so |
| 4089 | * drop all the packets here |
| 4090 | */ |
| 4091 | if (WLAN_HDD_GET_AP_CTX_PTR(adapter)->dfs_cac_block_tx) { |
| 4092 | ipa_free_skb(ipa_tx_desc); |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 4093 | qdf_spin_unlock_bh(&iface_context->interface_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4094 | iface_context->stats.num_tx_cac_drop++; |
| 4095 | hdd_ipa_rm_try_release(hdd_ipa); |
| 4096 | return; |
| 4097 | } |
| 4098 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4099 | ++adapter->stats.tx_packets; |
| 4100 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 4101 | qdf_spin_unlock_bh(&iface_context->interface_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4102 | |
| 4103 | skb = ipa_tx_desc->skb; |
| 4104 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4105 | qdf_mem_set(skb->cb, sizeof(skb->cb), 0); |
Yun Park | 52b2b99 | 2016-09-22 15:49:51 -0700 | [diff] [blame] | 4106 | |
| 4107 | /* Store IPA Tx buffer ownership into SKB CB */ |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 4108 | qdf_nbuf_ipa_owned_set(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4109 | if (hdd_ipa_uc_sta_is_enabled(hdd_ipa->hdd_ctx)) { |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 4110 | qdf_nbuf_mapped_paddr_set(skb, |
Houston Hoffman | 43d47fa | 2016-02-24 16:34:30 -0800 | [diff] [blame] | 4111 | ipa_tx_desc->dma_addr |
| 4112 | + HDD_IPA_WLAN_FRAG_HEADER |
| 4113 | + HDD_IPA_WLAN_IPA_HEADER); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4114 | ipa_tx_desc->skb->len -= |
| 4115 | HDD_IPA_WLAN_FRAG_HEADER + HDD_IPA_WLAN_IPA_HEADER; |
| 4116 | } else |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 4117 | qdf_nbuf_mapped_paddr_set(skb, ipa_tx_desc->dma_addr); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4118 | |
Yun Park | 52b2b99 | 2016-09-22 15:49:51 -0700 | [diff] [blame] | 4119 | qdf_spin_lock_bh(&hdd_ipa->q_lock); |
| 4120 | /* get free Tx desc and assign ipa_tx_desc pointer */ |
| 4121 | if (!list_empty(&hdd_ipa->free_tx_desc_head)) { |
| 4122 | tx_desc = list_first_entry(&hdd_ipa->free_tx_desc_head, |
| 4123 | struct hdd_ipa_tx_desc, link); |
| 4124 | list_del(&tx_desc->link); |
| 4125 | tx_desc->ipa_tx_desc_ptr = ipa_tx_desc; |
| 4126 | hdd_ipa->stats.num_tx_desc_q_cnt++; |
| 4127 | qdf_spin_unlock_bh(&hdd_ipa->q_lock); |
| 4128 | /* Store Tx Desc index into SKB CB */ |
| 4129 | QDF_NBUF_CB_TX_IPA_PRIV(skb) = tx_desc->id; |
| 4130 | } else { |
| 4131 | hdd_ipa->stats.num_tx_desc_error++; |
| 4132 | qdf_spin_unlock_bh(&hdd_ipa->q_lock); |
| 4133 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, "No free Tx desc!"); |
| 4134 | ipa_free_skb(ipa_tx_desc); |
| 4135 | hdd_ipa_rm_try_release(hdd_ipa); |
| 4136 | return; |
| 4137 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4138 | |
| 4139 | adapter->stats.tx_bytes += ipa_tx_desc->skb->len; |
| 4140 | |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 4141 | skb = cdp_ipa_tx_send_data_frame(cds_get_context(QDF_MODULE_ID_SOC), |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 4142 | (struct cdp_vdev *)iface_context->tl_context, |
| 4143 | ipa_tx_desc->skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4144 | if (skb) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4145 | HDD_IPA_LOG(QDF_TRACE_LEVEL_DEBUG, "TLSHIM tx fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4146 | ipa_free_skb(ipa_tx_desc); |
| 4147 | iface_context->stats.num_tx_err++; |
| 4148 | hdd_ipa_rm_try_release(hdd_ipa); |
| 4149 | return; |
| 4150 | } |
| 4151 | |
| 4152 | atomic_inc(&hdd_ipa->tx_ref_cnt); |
| 4153 | |
| 4154 | iface_context->stats.num_tx++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4155 | } |
| 4156 | |
| 4157 | /** |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 4158 | * hdd_ipa_is_present() - get IPA hw status |
| 4159 | * @hdd_ctx: pointer to hdd context |
| 4160 | * |
| 4161 | * ipa_uc_reg_rdyCB is not directly designed to check |
| 4162 | * ipa hw status. This is an undocumented function which |
| 4163 | * has confirmed with IPA team. |
| 4164 | * |
| 4165 | * Return: true - ipa hw present |
| 4166 | * false - ipa hw not present |
| 4167 | */ |
| 4168 | bool hdd_ipa_is_present(hdd_context_t *hdd_ctx) |
| 4169 | { |
| 4170 | /* Check if ipa hw is enabled */ |
Leo Chang | 63d7361 | 2016-10-18 18:09:43 -0700 | [diff] [blame] | 4171 | if (HDD_IPA_CHECK_HW() != -EPERM) |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 4172 | return true; |
| 4173 | else |
| 4174 | return false; |
| 4175 | } |
| 4176 | |
| 4177 | /** |
Leo Chang | 69c3969 | 2016-10-12 20:11:12 -0700 | [diff] [blame] | 4178 | * hdd_ipa_pm_flush() - flush queued packets |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4179 | * @work: pointer to the scheduled work |
| 4180 | * |
| 4181 | * Called during PM resume to send packets to TL which were queued |
| 4182 | * while host was in the process of suspending. |
| 4183 | * |
| 4184 | * Return: None |
| 4185 | */ |
Leo Chang | 69c3969 | 2016-10-12 20:11:12 -0700 | [diff] [blame] | 4186 | static void hdd_ipa_pm_flush(struct work_struct *work) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4187 | { |
| 4188 | struct hdd_ipa_priv *hdd_ipa = container_of(work, |
| 4189 | struct hdd_ipa_priv, |
| 4190 | pm_work); |
| 4191 | struct hdd_ipa_pm_tx_cb *pm_tx_cb = NULL; |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 4192 | qdf_nbuf_t skb; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4193 | uint32_t dequeued = 0; |
| 4194 | |
Leo Chang | 69c3969 | 2016-10-12 20:11:12 -0700 | [diff] [blame] | 4195 | qdf_wake_lock_acquire(&hdd_ipa->wake_lock, |
| 4196 | WIFI_POWER_EVENT_WAKELOCK_IPA); |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 4197 | qdf_spin_lock_bh(&hdd_ipa->pm_lock); |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 4198 | while (((skb = qdf_nbuf_queue_remove(&hdd_ipa->pm_queue_head)) |
| 4199 | != NULL)) { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 4200 | qdf_spin_unlock_bh(&hdd_ipa->pm_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4201 | |
| 4202 | pm_tx_cb = (struct hdd_ipa_pm_tx_cb *)skb->cb; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4203 | dequeued++; |
Leo Chang | 69c3969 | 2016-10-12 20:11:12 -0700 | [diff] [blame] | 4204 | if (pm_tx_cb->exception) { |
| 4205 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
| 4206 | "FLUSH EXCEPTION"); |
| 4207 | hdd_softap_hard_start_xmit(skb, pm_tx_cb->adapter->dev); |
| 4208 | } else { |
| 4209 | hdd_ipa_send_pkt_to_tl(pm_tx_cb->iface_context, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4210 | pm_tx_cb->ipa_tx_desc); |
Leo Chang | 69c3969 | 2016-10-12 20:11:12 -0700 | [diff] [blame] | 4211 | } |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 4212 | qdf_spin_lock_bh(&hdd_ipa->pm_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4213 | } |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 4214 | qdf_spin_unlock_bh(&hdd_ipa->pm_lock); |
Leo Chang | 69c3969 | 2016-10-12 20:11:12 -0700 | [diff] [blame] | 4215 | qdf_wake_lock_release(&hdd_ipa->wake_lock, |
| 4216 | WIFI_POWER_EVENT_WAKELOCK_IPA); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4217 | |
| 4218 | hdd_ipa->stats.num_tx_dequeued += dequeued; |
| 4219 | if (dequeued > hdd_ipa->stats.num_max_pm_queue) |
| 4220 | hdd_ipa->stats.num_max_pm_queue = dequeued; |
| 4221 | } |
| 4222 | |
| 4223 | /** |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 4224 | * __hdd_ipa_i2w_cb() - IPA to WLAN callback |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4225 | * @priv: pointer to private data registered with IPA (we register a |
| 4226 | * pointer to the interface-specific IPA context) |
| 4227 | * @evt: the IPA event which triggered the callback |
| 4228 | * @data: data associated with the event |
| 4229 | * |
| 4230 | * Return: None |
| 4231 | */ |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 4232 | static void __hdd_ipa_i2w_cb(void *priv, enum ipa_dp_evt_type evt, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4233 | unsigned long data) |
| 4234 | { |
| 4235 | struct hdd_ipa_priv *hdd_ipa = NULL; |
| 4236 | struct ipa_rx_data *ipa_tx_desc; |
| 4237 | struct hdd_ipa_iface_context *iface_context; |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 4238 | qdf_nbuf_t skb; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4239 | struct hdd_ipa_pm_tx_cb *pm_tx_cb = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4240 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4241 | |
Mukul Sharma | 81661ae | 2015-10-30 20:26:02 +0530 | [diff] [blame] | 4242 | iface_context = (struct hdd_ipa_iface_context *)priv; |
Prakash Dhavali | 87b38e3 | 2016-11-14 16:22:53 -0800 | [diff] [blame] | 4243 | ipa_tx_desc = (struct ipa_rx_data *)data; |
| 4244 | hdd_ipa = iface_context->hdd_ipa; |
| 4245 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4246 | if (evt != IPA_RECEIVE) { |
Prakash Dhavali | 87b38e3 | 2016-11-14 16:22:53 -0800 | [diff] [blame] | 4247 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, "Event is not IPA_RECEIVE"); |
| 4248 | ipa_free_skb(ipa_tx_desc); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4249 | iface_context->stats.num_tx_drop++; |
| 4250 | return; |
| 4251 | } |
| 4252 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4253 | /* |
| 4254 | * When SSR is going on or driver is unloading, just drop the packets. |
| 4255 | * During SSR, there is no use in queueing the packets as STA has to |
| 4256 | * connect back any way |
| 4257 | */ |
| 4258 | status = wlan_hdd_validate_context(hdd_ipa->hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 4259 | if (status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4260 | ipa_free_skb(ipa_tx_desc); |
| 4261 | iface_context->stats.num_tx_drop++; |
| 4262 | return; |
| 4263 | } |
| 4264 | |
| 4265 | skb = ipa_tx_desc->skb; |
| 4266 | |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 4267 | HDD_IPA_DBG_DUMP(QDF_TRACE_LEVEL_DEBUG, |
| 4268 | "i2w", skb->data, HDD_IPA_DBG_DUMP_TX_LEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4269 | |
| 4270 | /* |
| 4271 | * If PROD resource is not requested here then there may be cases where |
| 4272 | * IPA hardware may be clocked down because of not having proper |
| 4273 | * dependency graph between WLAN CONS and modem PROD pipes. Adding the |
| 4274 | * workaround to request PROD resource while data is going over CONS |
| 4275 | * pipe to prevent the IPA hardware clockdown. |
| 4276 | */ |
| 4277 | hdd_ipa_rm_request(hdd_ipa); |
| 4278 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 4279 | qdf_spin_lock_bh(&hdd_ipa->pm_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4280 | /* |
| 4281 | * If host is still suspended then queue the packets and these will be |
| 4282 | * drained later when resume completes. When packet is arrived here and |
| 4283 | * host is suspended, this means that there is already resume is in |
| 4284 | * progress. |
| 4285 | */ |
| 4286 | if (hdd_ipa->suspended) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4287 | qdf_mem_set(skb->cb, sizeof(skb->cb), 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4288 | pm_tx_cb = (struct hdd_ipa_pm_tx_cb *)skb->cb; |
| 4289 | pm_tx_cb->iface_context = iface_context; |
| 4290 | pm_tx_cb->ipa_tx_desc = ipa_tx_desc; |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 4291 | qdf_nbuf_queue_add(&hdd_ipa->pm_queue_head, skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4292 | hdd_ipa->stats.num_tx_queued++; |
| 4293 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 4294 | qdf_spin_unlock_bh(&hdd_ipa->pm_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4295 | return; |
| 4296 | } |
| 4297 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 4298 | qdf_spin_unlock_bh(&hdd_ipa->pm_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4299 | |
| 4300 | /* |
| 4301 | * If we are here means, host is not suspended, wait for the work queue |
| 4302 | * to finish. |
| 4303 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4304 | flush_work(&hdd_ipa->pm_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4305 | |
| 4306 | return hdd_ipa_send_pkt_to_tl(iface_context, ipa_tx_desc); |
| 4307 | } |
| 4308 | |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 4309 | /* |
| 4310 | * hdd_ipa_i2w_cb() - SSR wrapper for __hdd_ipa_i2w_cb |
| 4311 | * @priv: pointer to private data registered with IPA (we register a |
| 4312 | * pointer to the interface-specific IPA context) |
| 4313 | * @evt: the IPA event which triggered the callback |
| 4314 | * @data: data associated with the event |
| 4315 | * |
| 4316 | * Return: None |
| 4317 | */ |
| 4318 | static void hdd_ipa_i2w_cb(void *priv, enum ipa_dp_evt_type evt, |
| 4319 | unsigned long data) |
| 4320 | { |
| 4321 | cds_ssr_protect(__func__); |
| 4322 | __hdd_ipa_i2w_cb(priv, evt, data); |
| 4323 | cds_ssr_unprotect(__func__); |
| 4324 | } |
| 4325 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4326 | /** |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 4327 | * __hdd_ipa_suspend() - Suspend IPA |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4328 | * @hdd_ctx: Global HDD context |
| 4329 | * |
| 4330 | * Return: 0 on success, negativer errno on error |
| 4331 | */ |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 4332 | static int __hdd_ipa_suspend(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4333 | { |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 4334 | struct hdd_ipa_priv *hdd_ipa; |
| 4335 | |
| 4336 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 4337 | return 0; |
| 4338 | |
| 4339 | hdd_ipa = hdd_ctx->hdd_ipa; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4340 | |
| 4341 | if (!hdd_ipa_is_enabled(hdd_ctx)) |
| 4342 | return 0; |
| 4343 | |
| 4344 | /* |
| 4345 | * Check if IPA is ready for suspend, If we are here means, there is |
| 4346 | * high chance that suspend would go through but just to avoid any race |
| 4347 | * condition after suspend started, these checks are conducted before |
| 4348 | * allowing to suspend. |
| 4349 | */ |
| 4350 | if (atomic_read(&hdd_ipa->tx_ref_cnt)) |
| 4351 | return -EAGAIN; |
| 4352 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 4353 | qdf_spin_lock_bh(&hdd_ipa->rm_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4354 | |
| 4355 | if (hdd_ipa->rm_state != HDD_IPA_RM_RELEASED) { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 4356 | qdf_spin_unlock_bh(&hdd_ipa->rm_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4357 | return -EAGAIN; |
| 4358 | } |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 4359 | qdf_spin_unlock_bh(&hdd_ipa->rm_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4360 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 4361 | qdf_spin_lock_bh(&hdd_ipa->pm_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4362 | hdd_ipa->suspended = true; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 4363 | qdf_spin_unlock_bh(&hdd_ipa->pm_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4364 | |
| 4365 | return 0; |
| 4366 | } |
| 4367 | |
| 4368 | /** |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 4369 | * hdd_ipa_suspend() - SSR wrapper for __hdd_ipa_suspend |
| 4370 | * @hdd_ctx: Global HDD context |
| 4371 | * |
| 4372 | * Return: 0 on success, negativer errno on error |
| 4373 | */ |
| 4374 | int hdd_ipa_suspend(hdd_context_t *hdd_ctx) |
| 4375 | { |
| 4376 | int ret; |
| 4377 | |
| 4378 | cds_ssr_protect(__func__); |
| 4379 | ret = __hdd_ipa_suspend(hdd_ctx); |
| 4380 | cds_ssr_unprotect(__func__); |
| 4381 | |
| 4382 | return ret; |
| 4383 | } |
| 4384 | |
| 4385 | /** |
| 4386 | * __hdd_ipa_resume() - Resume IPA following suspend |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4387 | * hdd_ctx: Global HDD context |
| 4388 | * |
| 4389 | * Return: 0 on success, negative errno on error |
| 4390 | */ |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 4391 | static int __hdd_ipa_resume(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4392 | { |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 4393 | struct hdd_ipa_priv *hdd_ipa; |
| 4394 | |
| 4395 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 4396 | return 0; |
| 4397 | |
| 4398 | hdd_ipa = hdd_ctx->hdd_ipa; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4399 | |
| 4400 | if (!hdd_ipa_is_enabled(hdd_ctx)) |
| 4401 | return 0; |
| 4402 | |
| 4403 | schedule_work(&hdd_ipa->pm_work); |
| 4404 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 4405 | qdf_spin_lock_bh(&hdd_ipa->pm_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4406 | hdd_ipa->suspended = false; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 4407 | qdf_spin_unlock_bh(&hdd_ipa->pm_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4408 | |
| 4409 | return 0; |
| 4410 | } |
| 4411 | |
| 4412 | /** |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 4413 | * hdd_ipa_resume() - SSR wrapper for __hdd_ipa_resume |
| 4414 | * hdd_ctx: Global HDD context |
| 4415 | * |
| 4416 | * Return: 0 on success, negative errno on error |
| 4417 | */ |
| 4418 | int hdd_ipa_resume(hdd_context_t *hdd_ctx) |
| 4419 | { |
| 4420 | int ret; |
| 4421 | |
| 4422 | cds_ssr_protect(__func__); |
| 4423 | ret = __hdd_ipa_resume(hdd_ctx); |
| 4424 | cds_ssr_unprotect(__func__); |
| 4425 | |
| 4426 | return ret; |
| 4427 | } |
| 4428 | |
| 4429 | /** |
Yun Park | 52b2b99 | 2016-09-22 15:49:51 -0700 | [diff] [blame] | 4430 | * hdd_ipa_alloc_tx_desc_list() - Allocate IPA Tx desc list |
| 4431 | * @hdd_ipa: Global HDD IPA context |
| 4432 | * |
| 4433 | * Return: 0 on success, negative errno on error |
| 4434 | */ |
| 4435 | static int hdd_ipa_alloc_tx_desc_list(struct hdd_ipa_priv *hdd_ipa) |
| 4436 | { |
| 4437 | int i; |
| 4438 | uint32_t max_desc_cnt; |
| 4439 | struct hdd_ipa_tx_desc *tmp_desc; |
| 4440 | |
| 4441 | max_desc_cnt = hdd_ipa->hdd_ctx->config->IpaUcTxBufCount; |
| 4442 | |
| 4443 | INIT_LIST_HEAD(&hdd_ipa->free_tx_desc_head); |
| 4444 | |
| 4445 | tmp_desc = qdf_mem_malloc(sizeof(struct hdd_ipa_tx_desc)*max_desc_cnt); |
| 4446 | |
| 4447 | if (!tmp_desc) { |
| 4448 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
| 4449 | "Free Tx descriptor allocation failed"); |
| 4450 | return -ENOMEM; |
| 4451 | } |
| 4452 | |
| 4453 | hdd_ipa->tx_desc_list = tmp_desc; |
| 4454 | |
| 4455 | qdf_spin_lock_bh(&hdd_ipa->q_lock); |
| 4456 | for (i = 0; i < max_desc_cnt; i++) { |
| 4457 | tmp_desc->id = i; |
| 4458 | tmp_desc->ipa_tx_desc_ptr = NULL; |
| 4459 | list_add_tail(&tmp_desc->link, |
| 4460 | &hdd_ipa->free_tx_desc_head); |
| 4461 | tmp_desc++; |
| 4462 | } |
| 4463 | |
| 4464 | hdd_ipa->stats.num_tx_desc_q_cnt = 0; |
| 4465 | hdd_ipa->stats.num_tx_desc_error = 0; |
| 4466 | |
| 4467 | qdf_spin_unlock_bh(&hdd_ipa->q_lock); |
| 4468 | |
| 4469 | return 0; |
| 4470 | } |
| 4471 | |
| 4472 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4473 | * hdd_ipa_setup_sys_pipe() - Setup all IPA Sys pipes |
| 4474 | * @hdd_ipa: Global HDD IPA context |
| 4475 | * |
| 4476 | * Return: 0 on success, negative errno on error |
| 4477 | */ |
| 4478 | static int hdd_ipa_setup_sys_pipe(struct hdd_ipa_priv *hdd_ipa) |
| 4479 | { |
| 4480 | int i, ret = 0; |
| 4481 | struct ipa_sys_connect_params *ipa; |
| 4482 | uint32_t desc_fifo_sz; |
| 4483 | |
| 4484 | /* The maximum number of descriptors that can be provided to a BAM at |
| 4485 | * once is one less than the total number of descriptors that the buffer |
| 4486 | * can contain. |
| 4487 | * If max_num_of_descriptors = (BAM_PIPE_DESCRIPTOR_FIFO_SIZE / sizeof |
| 4488 | * (SPS_DESCRIPTOR)), then (max_num_of_descriptors - 1) descriptors can |
| 4489 | * be provided at once. |
| 4490 | * Because of above requirement, one extra descriptor will be added to |
| 4491 | * make sure hardware always has one descriptor. |
| 4492 | */ |
| 4493 | desc_fifo_sz = hdd_ipa->hdd_ctx->config->IpaDescSize |
| 4494 | + sizeof(struct sps_iovec); |
| 4495 | |
| 4496 | /*setup TX pipes */ |
| 4497 | for (i = 0; i < HDD_IPA_MAX_IFACE; i++) { |
| 4498 | ipa = &hdd_ipa->sys_pipe[i].ipa_sys_params; |
| 4499 | |
| 4500 | ipa->client = hdd_ipa_adapter_2_client[i].cons_client; |
| 4501 | ipa->desc_fifo_sz = desc_fifo_sz; |
| 4502 | ipa->priv = &hdd_ipa->iface_context[i]; |
| 4503 | ipa->notify = hdd_ipa_i2w_cb; |
| 4504 | |
| 4505 | if (hdd_ipa_uc_sta_is_enabled(hdd_ipa->hdd_ctx)) { |
| 4506 | ipa->ipa_ep_cfg.hdr.hdr_len = |
| 4507 | HDD_IPA_UC_WLAN_TX_HDR_LEN; |
| 4508 | ipa->ipa_ep_cfg.nat.nat_en = IPA_BYPASS_NAT; |
| 4509 | ipa->ipa_ep_cfg.hdr.hdr_ofst_pkt_size_valid = 1; |
| 4510 | ipa->ipa_ep_cfg.hdr.hdr_ofst_pkt_size = 0; |
| 4511 | ipa->ipa_ep_cfg.hdr.hdr_additional_const_len = |
| 4512 | HDD_IPA_UC_WLAN_8023_HDR_SIZE; |
| 4513 | ipa->ipa_ep_cfg.hdr_ext.hdr_little_endian = true; |
| 4514 | } else { |
| 4515 | ipa->ipa_ep_cfg.hdr.hdr_len = HDD_IPA_WLAN_TX_HDR_LEN; |
| 4516 | } |
| 4517 | ipa->ipa_ep_cfg.mode.mode = IPA_BASIC; |
| 4518 | |
| 4519 | if (!hdd_ipa_is_rm_enabled(hdd_ipa->hdd_ctx)) |
| 4520 | ipa->keep_ipa_awake = 1; |
| 4521 | |
| 4522 | ret = ipa_setup_sys_pipe(ipa, &(hdd_ipa->sys_pipe[i].conn_hdl)); |
| 4523 | if (ret) { |
Srinivas Girigowda | c16ba6d | 2017-03-25 11:43:26 -0700 | [diff] [blame] | 4524 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
| 4525 | "Failed for pipe %d ret: %d", i, ret); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4526 | goto setup_sys_pipe_fail; |
| 4527 | } |
| 4528 | hdd_ipa->sys_pipe[i].conn_hdl_valid = 1; |
| 4529 | } |
| 4530 | |
| 4531 | if (!hdd_ipa_uc_sta_is_enabled(hdd_ipa->hdd_ctx)) { |
| 4532 | /* |
| 4533 | * Hard code it here, this can be extended if in case |
| 4534 | * PROD pipe is also per interface. |
| 4535 | * Right now there is no advantage of doing this. |
| 4536 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4537 | ipa = &hdd_ipa->sys_pipe[HDD_IPA_RX_PIPE].ipa_sys_params; |
| 4538 | |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 4539 | ipa->client = IPA_CLIENT_WLAN1_PROD; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4540 | |
| 4541 | ipa->desc_fifo_sz = desc_fifo_sz; |
| 4542 | ipa->priv = hdd_ipa; |
| 4543 | ipa->notify = hdd_ipa_w2i_cb; |
| 4544 | |
| 4545 | ipa->ipa_ep_cfg.nat.nat_en = IPA_BYPASS_NAT; |
| 4546 | ipa->ipa_ep_cfg.hdr.hdr_len = HDD_IPA_WLAN_RX_HDR_LEN; |
| 4547 | ipa->ipa_ep_cfg.hdr.hdr_ofst_metadata_valid = 1; |
| 4548 | ipa->ipa_ep_cfg.mode.mode = IPA_BASIC; |
| 4549 | |
| 4550 | if (!hdd_ipa_is_rm_enabled(hdd_ipa->hdd_ctx)) |
| 4551 | ipa->keep_ipa_awake = 1; |
| 4552 | |
| 4553 | ret = ipa_setup_sys_pipe(ipa, &(hdd_ipa->sys_pipe[i].conn_hdl)); |
| 4554 | if (ret) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4555 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4556 | "Failed for RX pipe: %d", ret); |
| 4557 | goto setup_sys_pipe_fail; |
| 4558 | } |
| 4559 | hdd_ipa->sys_pipe[HDD_IPA_RX_PIPE].conn_hdl_valid = 1; |
| 4560 | } |
| 4561 | |
Yun Park | 52b2b99 | 2016-09-22 15:49:51 -0700 | [diff] [blame] | 4562 | /* Allocate free Tx desc list */ |
| 4563 | ret = hdd_ipa_alloc_tx_desc_list(hdd_ipa); |
| 4564 | if (ret) |
| 4565 | goto setup_sys_pipe_fail; |
| 4566 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4567 | return ret; |
| 4568 | |
| 4569 | setup_sys_pipe_fail: |
| 4570 | |
| 4571 | while (--i >= 0) { |
| 4572 | ipa_teardown_sys_pipe(hdd_ipa->sys_pipe[i].conn_hdl); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4573 | qdf_mem_zero(&hdd_ipa->sys_pipe[i], |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4574 | sizeof(struct hdd_ipa_sys_pipe)); |
| 4575 | } |
| 4576 | |
| 4577 | return ret; |
| 4578 | } |
| 4579 | |
| 4580 | /** |
| 4581 | * hdd_ipa_teardown_sys_pipe() - Tear down all IPA Sys pipes |
| 4582 | * @hdd_ipa: Global HDD IPA context |
| 4583 | * |
| 4584 | * Return: None |
| 4585 | */ |
| 4586 | static void hdd_ipa_teardown_sys_pipe(struct hdd_ipa_priv *hdd_ipa) |
| 4587 | { |
| 4588 | int ret = 0, i; |
Yun Park | 52b2b99 | 2016-09-22 15:49:51 -0700 | [diff] [blame] | 4589 | uint32_t max_desc_cnt; |
| 4590 | struct hdd_ipa_tx_desc *tmp_desc; |
| 4591 | struct ipa_rx_data *ipa_tx_desc; |
| 4592 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4593 | for (i = 0; i < HDD_IPA_MAX_SYSBAM_PIPE; i++) { |
| 4594 | if (hdd_ipa->sys_pipe[i].conn_hdl_valid) { |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 4595 | ret = ipa_teardown_sys_pipe(hdd_ipa->sys_pipe[i]. |
| 4596 | conn_hdl); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4597 | if (ret) |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4598 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, "Failed: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4599 | ret); |
| 4600 | |
| 4601 | hdd_ipa->sys_pipe[i].conn_hdl_valid = 0; |
| 4602 | } |
| 4603 | } |
Yun Park | 52b2b99 | 2016-09-22 15:49:51 -0700 | [diff] [blame] | 4604 | |
| 4605 | if (hdd_ipa->tx_desc_list) { |
| 4606 | max_desc_cnt = hdd_ipa->hdd_ctx->config->IpaUcTxBufCount; |
| 4607 | |
| 4608 | qdf_spin_lock_bh(&hdd_ipa->q_lock); |
| 4609 | for (i = 0; i < max_desc_cnt; i++) { |
| 4610 | tmp_desc = hdd_ipa->tx_desc_list + i; |
| 4611 | ipa_tx_desc = tmp_desc->ipa_tx_desc_ptr; |
| 4612 | if (ipa_tx_desc) |
| 4613 | ipa_free_skb(ipa_tx_desc); |
| 4614 | } |
| 4615 | tmp_desc = hdd_ipa->tx_desc_list; |
| 4616 | hdd_ipa->tx_desc_list = NULL; |
| 4617 | hdd_ipa->stats.num_tx_desc_q_cnt = 0; |
| 4618 | hdd_ipa->stats.num_tx_desc_error = 0; |
| 4619 | qdf_spin_unlock_bh(&hdd_ipa->q_lock); |
| 4620 | qdf_mem_free(tmp_desc); |
| 4621 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4622 | } |
| 4623 | |
| 4624 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4625 | * hdd_ipa_cleanup_iface() - Cleanup IPA on a given interface |
| 4626 | * @iface_context: interface-specific IPA context |
| 4627 | * |
| 4628 | * Return: None |
| 4629 | */ |
| 4630 | static void hdd_ipa_cleanup_iface(struct hdd_ipa_iface_context *iface_context) |
| 4631 | { |
| 4632 | if (iface_context == NULL) |
| 4633 | return; |
| 4634 | |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 4635 | cdp_ipa_cleanup_iface(cds_get_context(QDF_MODULE_ID_SOC), |
| 4636 | iface_context->adapter->dev->name, |
| 4637 | hdd_ipa_is_ipv6_enabled(iface_context->hdd_ipa->hdd_ctx)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4638 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 4639 | qdf_spin_lock_bh(&iface_context->interface_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4640 | iface_context->adapter->ipa_context = NULL; |
| 4641 | iface_context->adapter = NULL; |
| 4642 | iface_context->tl_context = NULL; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 4643 | qdf_spin_unlock_bh(&iface_context->interface_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4644 | iface_context->ifa_address = 0; |
| 4645 | if (!iface_context->hdd_ipa->num_iface) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4646 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4647 | "NUM INTF 0, Invalid"); |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 4648 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4649 | } |
| 4650 | iface_context->hdd_ipa->num_iface--; |
| 4651 | } |
| 4652 | |
| 4653 | /** |
| 4654 | * hdd_ipa_setup_iface() - Setup IPA on a given interface |
| 4655 | * @hdd_ipa: HDD IPA global context |
| 4656 | * @adapter: Interface upon which IPA is being setup |
| 4657 | * @sta_id: Station ID of the API instance |
| 4658 | * |
| 4659 | * Return: 0 on success, negative errno value on error |
| 4660 | */ |
| 4661 | static int hdd_ipa_setup_iface(struct hdd_ipa_priv *hdd_ipa, |
| 4662 | hdd_adapter_t *adapter, uint8_t sta_id) |
| 4663 | { |
| 4664 | struct hdd_ipa_iface_context *iface_context = NULL; |
| 4665 | void *tl_context = NULL; |
| 4666 | int i, ret = 0; |
| 4667 | |
| 4668 | /* Lower layer may send multiple START_BSS_EVENT in DFS mode or during |
| 4669 | * channel change indication. Since these indications are sent by lower |
| 4670 | * layer as SAP updates and IPA doesn't have to do anything for these |
| 4671 | * updates so ignoring! |
| 4672 | */ |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 4673 | if (QDF_SAP_MODE == adapter->device_mode && adapter->ipa_context) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4674 | return 0; |
| 4675 | |
| 4676 | for (i = 0; i < HDD_IPA_MAX_IFACE; i++) { |
| 4677 | if (hdd_ipa->iface_context[i].adapter == NULL) { |
| 4678 | iface_context = &(hdd_ipa->iface_context[i]); |
| 4679 | break; |
| 4680 | } |
| 4681 | } |
| 4682 | |
| 4683 | if (iface_context == NULL) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4684 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4685 | "All the IPA interfaces are in use"); |
| 4686 | ret = -ENOMEM; |
| 4687 | goto end; |
| 4688 | } |
| 4689 | |
| 4690 | adapter->ipa_context = iface_context; |
| 4691 | iface_context->adapter = adapter; |
| 4692 | iface_context->sta_id = sta_id; |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 4693 | tl_context = (void *)cdp_peer_get_vdev_by_sta_id( |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 4694 | cds_get_context(QDF_MODULE_ID_SOC), sta_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4695 | if (tl_context == NULL) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4696 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4697 | "Not able to get TL context sta_id: %d", sta_id); |
| 4698 | ret = -EINVAL; |
| 4699 | goto end; |
| 4700 | } |
| 4701 | |
| 4702 | iface_context->tl_context = tl_context; |
| 4703 | |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame^] | 4704 | ret = cdp_ipa_setup_iface(cds_get_context(QDF_MODULE_ID_SOC), |
| 4705 | adapter->dev->name, adapter->dev->dev_addr, |
| 4706 | iface_context->prod_client, |
| 4707 | iface_context->cons_client, |
| 4708 | adapter->sessionId, |
| 4709 | hdd_ipa_is_ipv6_enabled(hdd_ipa->hdd_ctx)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4710 | if (ret) |
| 4711 | goto end; |
| 4712 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4713 | hdd_ipa->num_iface++; |
| 4714 | return ret; |
| 4715 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4716 | end: |
| 4717 | if (iface_context) |
| 4718 | hdd_ipa_cleanup_iface(iface_context); |
| 4719 | return ret; |
| 4720 | } |
| 4721 | |
Yun Park | a27049a | 2016-10-11 12:30:49 -0700 | [diff] [blame] | 4722 | #ifndef QCA_LL_TX_FLOW_CONTROL_V2 |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4723 | /** |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 4724 | * __hdd_ipa_send_mcc_scc_msg() - send IPA WLAN_SWITCH_TO_MCC/SCC message |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4725 | * @mcc_mode: 0=MCC/1=SCC |
| 4726 | * |
| 4727 | * Return: 0 on success, negative errno value on error |
| 4728 | */ |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 4729 | static int __hdd_ipa_send_mcc_scc_msg(hdd_context_t *hdd_ctx, bool mcc_mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4730 | { |
| 4731 | hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4732 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4733 | hdd_adapter_t *pAdapter; |
| 4734 | struct ipa_msg_meta meta; |
| 4735 | struct ipa_wlan_msg *msg; |
| 4736 | int ret; |
| 4737 | |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 4738 | if (wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4739 | return -EINVAL; |
| 4740 | |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 4741 | if (!hdd_ipa_uc_sta_is_enabled(hdd_ctx)) |
| 4742 | return -EINVAL; |
| 4743 | |
| 4744 | if (!hdd_ctx->mcc_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4745 | /* Flush TxRx queue for each adapter before switch to SCC */ |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 4746 | status = hdd_get_front_adapter(hdd_ctx, &adapter_node); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4747 | while (NULL != adapter_node && QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4748 | pAdapter = adapter_node->pAdapter; |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 4749 | if (pAdapter->device_mode == QDF_STA_MODE || |
Jeff Johnson | ab2cd40 | 2016-12-05 13:54:28 -0800 | [diff] [blame] | 4750 | pAdapter->device_mode == QDF_SAP_MODE) { |
Srinivas Girigowda | 9785237 | 2017-03-06 16:52:59 -0800 | [diff] [blame] | 4751 | hdd_debug("MCC->SCC: Flush TxRx queue(d_mode=%d)", |
Jeff Johnson | ab2cd40 | 2016-12-05 13:54:28 -0800 | [diff] [blame] | 4752 | pAdapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4753 | hdd_deinit_tx_rx(pAdapter); |
| 4754 | } |
| 4755 | status = hdd_get_next_adapter( |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 4756 | hdd_ctx, adapter_node, &next); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4757 | adapter_node = next; |
| 4758 | } |
| 4759 | } |
| 4760 | |
| 4761 | /* Send SCC/MCC Switching event to IPA */ |
| 4762 | meta.msg_len = sizeof(*msg); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4763 | msg = qdf_mem_malloc(meta.msg_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4764 | if (msg == NULL) { |
Jeff Johnson | ab2cd40 | 2016-12-05 13:54:28 -0800 | [diff] [blame] | 4765 | hdd_err("msg allocation failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4766 | return -ENOMEM; |
| 4767 | } |
| 4768 | |
| 4769 | meta.msg_type = mcc_mode ? |
| 4770 | WLAN_SWITCH_TO_MCC : WLAN_SWITCH_TO_SCC; |
Srinivas Girigowda | 9785237 | 2017-03-06 16:52:59 -0800 | [diff] [blame] | 4771 | hdd_debug("ipa_send_msg(Evt:%d)", meta.msg_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4772 | |
| 4773 | ret = ipa_send_msg(&meta, msg, hdd_ipa_msg_free_fn); |
| 4774 | |
| 4775 | if (ret) { |
Jeff Johnson | ab2cd40 | 2016-12-05 13:54:28 -0800 | [diff] [blame] | 4776 | hdd_err("ipa_send_msg(Evt:%d) - fail=%d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4777 | meta.msg_type, ret); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4778 | qdf_mem_free(msg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4779 | } |
| 4780 | |
| 4781 | return ret; |
| 4782 | } |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 4783 | |
| 4784 | /** |
| 4785 | * hdd_ipa_send_mcc_scc_msg() - SSR wrapper for __hdd_ipa_send_mcc_scc_msg |
| 4786 | * @mcc_mode: 0=MCC/1=SCC |
| 4787 | * |
| 4788 | * Return: 0 on success, negative errno value on error |
| 4789 | */ |
| 4790 | int hdd_ipa_send_mcc_scc_msg(hdd_context_t *hdd_ctx, bool mcc_mode) |
| 4791 | { |
| 4792 | int ret; |
| 4793 | |
| 4794 | cds_ssr_protect(__func__); |
| 4795 | ret = __hdd_ipa_send_mcc_scc_msg(hdd_ctx, mcc_mode); |
| 4796 | cds_ssr_unprotect(__func__); |
| 4797 | |
| 4798 | return ret; |
| 4799 | } |
Yun Park | a27049a | 2016-10-11 12:30:49 -0700 | [diff] [blame] | 4800 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4801 | |
| 4802 | /** |
| 4803 | * hdd_ipa_wlan_event_to_str() - convert IPA WLAN event to string |
| 4804 | * @event: IPA WLAN event to be converted to a string |
| 4805 | * |
| 4806 | * Return: ASCII string representing the IPA WLAN event |
| 4807 | */ |
| 4808 | static inline char *hdd_ipa_wlan_event_to_str(enum ipa_wlan_event event) |
| 4809 | { |
| 4810 | switch (event) { |
| 4811 | case WLAN_CLIENT_CONNECT: |
| 4812 | return "WLAN_CLIENT_CONNECT"; |
| 4813 | case WLAN_CLIENT_DISCONNECT: |
| 4814 | return "WLAN_CLIENT_DISCONNECT"; |
| 4815 | case WLAN_CLIENT_POWER_SAVE_MODE: |
| 4816 | return "WLAN_CLIENT_POWER_SAVE_MODE"; |
| 4817 | case WLAN_CLIENT_NORMAL_MODE: |
| 4818 | return "WLAN_CLIENT_NORMAL_MODE"; |
| 4819 | case SW_ROUTING_ENABLE: |
| 4820 | return "SW_ROUTING_ENABLE"; |
| 4821 | case SW_ROUTING_DISABLE: |
| 4822 | return "SW_ROUTING_DISABLE"; |
| 4823 | case WLAN_AP_CONNECT: |
| 4824 | return "WLAN_AP_CONNECT"; |
| 4825 | case WLAN_AP_DISCONNECT: |
| 4826 | return "WLAN_AP_DISCONNECT"; |
| 4827 | case WLAN_STA_CONNECT: |
| 4828 | return "WLAN_STA_CONNECT"; |
| 4829 | case WLAN_STA_DISCONNECT: |
| 4830 | return "WLAN_STA_DISCONNECT"; |
| 4831 | case WLAN_CLIENT_CONNECT_EX: |
| 4832 | return "WLAN_CLIENT_CONNECT_EX"; |
| 4833 | |
| 4834 | case IPA_WLAN_EVENT_MAX: |
| 4835 | default: |
| 4836 | return "UNKNOWN"; |
| 4837 | } |
| 4838 | } |
| 4839 | |
| 4840 | /** |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 4841 | * hdd_to_ipa_wlan_event() - convert hdd_ipa_wlan_event to ipa_wlan_event |
| 4842 | * @hdd_ipa_event_type: HDD IPA WLAN event to be converted to an ipa_wlan_event |
| 4843 | * |
| 4844 | * Return: ipa_wlan_event representing the hdd_ipa_wlan_event |
| 4845 | */ |
| 4846 | static enum ipa_wlan_event |
| 4847 | hdd_to_ipa_wlan_event(enum hdd_ipa_wlan_event hdd_ipa_event_type) |
| 4848 | { |
| 4849 | enum ipa_wlan_event ipa_event; |
| 4850 | |
| 4851 | switch (hdd_ipa_event_type) { |
| 4852 | case HDD_IPA_CLIENT_CONNECT: |
| 4853 | ipa_event = WLAN_CLIENT_CONNECT; |
| 4854 | break; |
| 4855 | case HDD_IPA_CLIENT_DISCONNECT: |
| 4856 | ipa_event = WLAN_CLIENT_DISCONNECT; |
| 4857 | break; |
| 4858 | case HDD_IPA_AP_CONNECT: |
| 4859 | ipa_event = WLAN_AP_CONNECT; |
| 4860 | break; |
| 4861 | case HDD_IPA_AP_DISCONNECT: |
| 4862 | ipa_event = WLAN_AP_DISCONNECT; |
| 4863 | break; |
| 4864 | case HDD_IPA_STA_CONNECT: |
| 4865 | ipa_event = WLAN_STA_CONNECT; |
| 4866 | break; |
| 4867 | case HDD_IPA_STA_DISCONNECT: |
| 4868 | ipa_event = WLAN_STA_DISCONNECT; |
| 4869 | break; |
| 4870 | case HDD_IPA_CLIENT_CONNECT_EX: |
| 4871 | ipa_event = WLAN_CLIENT_CONNECT_EX; |
| 4872 | break; |
| 4873 | case HDD_IPA_WLAN_EVENT_MAX: |
| 4874 | default: |
| 4875 | ipa_event = IPA_WLAN_EVENT_MAX; |
| 4876 | break; |
| 4877 | } |
| 4878 | return ipa_event; |
| 4879 | |
| 4880 | } |
| 4881 | |
| 4882 | /** |
| 4883 | * __hdd_ipa_wlan_evt() - IPA event handler |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4884 | * @adapter: adapter upon which the event was received |
| 4885 | * @sta_id: station id for the event |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 4886 | * @type: event enum of type ipa_wlan_event |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4887 | * @mac_address: MAC address associated with the event |
| 4888 | * |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 4889 | * This function is meant to be called from within wlan_hdd_ipa.c |
| 4890 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4891 | * Return: 0 on success, negative errno value on error |
| 4892 | */ |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 4893 | static int __hdd_ipa_wlan_evt(hdd_adapter_t *adapter, uint8_t sta_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4894 | enum ipa_wlan_event type, uint8_t *mac_addr) |
| 4895 | { |
| 4896 | struct hdd_ipa_priv *hdd_ipa = ghdd_ipa; |
| 4897 | struct ipa_msg_meta meta; |
| 4898 | struct ipa_wlan_msg *msg; |
| 4899 | struct ipa_wlan_msg_ex *msg_ex = NULL; |
| 4900 | int ret; |
| 4901 | |
Srinivas Girigowda | 9785237 | 2017-03-06 16:52:59 -0800 | [diff] [blame] | 4902 | HDD_IPA_LOG(QDF_TRACE_LEVEL_DEBUG, "%s: %s evt, MAC: %pM sta_id: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4903 | adapter->dev->name, hdd_ipa_wlan_event_to_str(type), |
| 4904 | mac_addr, sta_id); |
| 4905 | |
| 4906 | if (type >= IPA_WLAN_EVENT_MAX) |
| 4907 | return -EINVAL; |
| 4908 | |
| 4909 | if (WARN_ON(is_zero_ether_addr(mac_addr))) |
| 4910 | return -EINVAL; |
| 4911 | |
| 4912 | if (!hdd_ipa || !hdd_ipa_is_enabled(hdd_ipa->hdd_ctx)) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4913 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, "IPA OFFLOAD NOT ENABLED"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4914 | return -EINVAL; |
| 4915 | } |
| 4916 | |
| 4917 | if (hdd_ipa_uc_is_enabled(hdd_ipa->hdd_ctx) && |
| 4918 | !hdd_ipa_uc_sta_is_enabled(hdd_ipa->hdd_ctx) && |
Krunal Soni | be766b0 | 2016-03-10 13:00:44 -0800 | [diff] [blame] | 4919 | (QDF_SAP_MODE != adapter->device_mode)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4920 | return 0; |
| 4921 | } |
| 4922 | |
| 4923 | /* |
| 4924 | * During IPA UC resource loading/unloading new events can be issued. |
| 4925 | * Store the events separately and handle them later. |
| 4926 | */ |
Prakash Dhavali | bf6d5d2 | 2016-08-17 10:17:46 -0700 | [diff] [blame] | 4927 | if (hdd_ipa_uc_is_enabled(hdd_ipa->hdd_ctx)) { |
| 4928 | if (hdd_ipa->resource_loading) { |
| 4929 | unsigned int pending_event_count; |
Prakash Dhavali | bf6d5d2 | 2016-08-17 10:17:46 -0700 | [diff] [blame] | 4930 | struct ipa_uc_pending_event *pending_event = NULL; |
Yun Park | f19e07d | 2015-11-20 11:34:27 -0800 | [diff] [blame] | 4931 | |
Yun Park | 64c405e | 2017-01-10 22:35:51 -0800 | [diff] [blame] | 4932 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
| 4933 | "IPA resource load in progress"); |
Yun Park | 7c4f31b | 2016-11-30 10:09:21 -0800 | [diff] [blame] | 4934 | |
Yun Park | 64c405e | 2017-01-10 22:35:51 -0800 | [diff] [blame] | 4935 | qdf_mutex_acquire(&hdd_ipa->ipa_lock); |
Yun Park | f19e07d | 2015-11-20 11:34:27 -0800 | [diff] [blame] | 4936 | |
Srinivas Girigowda | c16ba6d | 2017-03-25 11:43:26 -0700 | [diff] [blame] | 4937 | pending_event_count = |
| 4938 | qdf_list_size(&hdd_ipa->pending_event); |
| 4939 | if (pending_event_count >= |
| 4940 | HDD_IPA_MAX_PENDING_EVENT_COUNT) { |
Srinivas Girigowda | 9785237 | 2017-03-06 16:52:59 -0800 | [diff] [blame] | 4941 | hdd_debug("Reached max pending event count"); |
Prakash Dhavali | bf6d5d2 | 2016-08-17 10:17:46 -0700 | [diff] [blame] | 4942 | qdf_list_remove_front(&hdd_ipa->pending_event, |
Srinivas Girigowda | c16ba6d | 2017-03-25 11:43:26 -0700 | [diff] [blame] | 4943 | (qdf_list_node_t **)&pending_event); |
Prakash Dhavali | bf6d5d2 | 2016-08-17 10:17:46 -0700 | [diff] [blame] | 4944 | } else { |
| 4945 | pending_event = |
Srinivas Girigowda | c16ba6d | 2017-03-25 11:43:26 -0700 | [diff] [blame] | 4946 | qdf_mem_malloc(sizeof(*pending_event)); |
Prakash Dhavali | bf6d5d2 | 2016-08-17 10:17:46 -0700 | [diff] [blame] | 4947 | } |
| 4948 | |
| 4949 | if (!pending_event) { |
Yun Park | 64c405e | 2017-01-10 22:35:51 -0800 | [diff] [blame] | 4950 | qdf_mutex_release(&hdd_ipa->ipa_lock); |
Yun Park | 7c4f31b | 2016-11-30 10:09:21 -0800 | [diff] [blame] | 4951 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
| 4952 | "Pending event memory alloc fail"); |
Prakash Dhavali | bf6d5d2 | 2016-08-17 10:17:46 -0700 | [diff] [blame] | 4953 | return -ENOMEM; |
| 4954 | } |
| 4955 | |
| 4956 | pending_event->adapter = adapter; |
| 4957 | pending_event->sta_id = sta_id; |
| 4958 | pending_event->type = type; |
| 4959 | qdf_mem_copy(pending_event->mac_addr, |
| 4960 | mac_addr, |
| 4961 | QDF_MAC_ADDR_SIZE); |
| 4962 | qdf_list_insert_back(&hdd_ipa->pending_event, |
| 4963 | &pending_event->node); |
| 4964 | |
Yun Park | 64c405e | 2017-01-10 22:35:51 -0800 | [diff] [blame] | 4965 | qdf_mutex_release(&hdd_ipa->ipa_lock); |
Prakash Dhavali | bf6d5d2 | 2016-08-17 10:17:46 -0700 | [diff] [blame] | 4966 | return 0; |
| 4967 | } else if (hdd_ipa->resource_unloading) { |
Yun Park | 64c405e | 2017-01-10 22:35:51 -0800 | [diff] [blame] | 4968 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
| 4969 | "IPA resource unload in progress"); |
Prakash Dhavali | bf6d5d2 | 2016-08-17 10:17:46 -0700 | [diff] [blame] | 4970 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4971 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4972 | } |
| 4973 | |
| 4974 | hdd_ipa->stats.event[type]++; |
| 4975 | |
Leo Chang | 3bc8fed | 2015-11-13 10:59:47 -0800 | [diff] [blame] | 4976 | meta.msg_type = type; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4977 | switch (type) { |
| 4978 | case WLAN_STA_CONNECT: |
Yun Park | 8f289c8 | 2016-10-18 16:38:21 -0700 | [diff] [blame] | 4979 | qdf_mutex_acquire(&hdd_ipa->event_lock); |
| 4980 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4981 | /* STA already connected and without disconnect, connect again |
| 4982 | * This is Roaming scenario |
| 4983 | */ |
| 4984 | if (hdd_ipa->sta_connected) |
| 4985 | hdd_ipa_cleanup_iface(adapter->ipa_context); |
| 4986 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4987 | ret = hdd_ipa_setup_iface(hdd_ipa, adapter, sta_id); |
| 4988 | if (ret) { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 4989 | qdf_mutex_release(&hdd_ipa->event_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4990 | goto end; |
Yun Park | a37592b | 2016-06-11 17:10:28 -0700 | [diff] [blame] | 4991 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4992 | |
Yun Park | 8f289c8 | 2016-10-18 16:38:21 -0700 | [diff] [blame] | 4993 | if (hdd_ipa_uc_sta_is_enabled(hdd_ipa->hdd_ctx) && |
| 4994 | (hdd_ipa->sap_num_connected_sta > 0) && |
| 4995 | !hdd_ipa->sta_connected) { |
| 4996 | qdf_mutex_release(&hdd_ipa->event_lock); |
| 4997 | hdd_ipa_uc_offload_enable_disable(adapter, |
Prakash Dhavali | 89d406d | 2016-11-23 11:11:00 -0800 | [diff] [blame] | 4998 | SIR_STA_RX_DATA_OFFLOAD, true); |
Yun Park | 8f289c8 | 2016-10-18 16:38:21 -0700 | [diff] [blame] | 4999 | qdf_mutex_acquire(&hdd_ipa->event_lock); |
| 5000 | } |
| 5001 | |
Prakash Dhavali | 89d406d | 2016-11-23 11:11:00 -0800 | [diff] [blame] | 5002 | hdd_ipa->vdev_to_iface[adapter->sessionId] = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5003 | ((struct hdd_ipa_iface_context *) |
Yun Park | a37592b | 2016-06-11 17:10:28 -0700 | [diff] [blame] | 5004 | (adapter->ipa_context))->iface_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5005 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5006 | hdd_ipa->sta_connected = 1; |
Yun Park | 8f289c8 | 2016-10-18 16:38:21 -0700 | [diff] [blame] | 5007 | |
| 5008 | qdf_mutex_release(&hdd_ipa->event_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5009 | break; |
| 5010 | |
| 5011 | case WLAN_AP_CONNECT: |
Yun Park | 8f289c8 | 2016-10-18 16:38:21 -0700 | [diff] [blame] | 5012 | qdf_mutex_acquire(&hdd_ipa->event_lock); |
| 5013 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5014 | /* For DFS channel we get two start_bss event (before and after |
| 5015 | * CAC). Also when ACS range includes both DFS and non DFS |
| 5016 | * channels, we could possibly change channel many times due to |
| 5017 | * RADAR detection and chosen channel may not be a DFS channels. |
| 5018 | * So dont return error here. Just discard the event. |
| 5019 | */ |
Yun Park | 8f289c8 | 2016-10-18 16:38:21 -0700 | [diff] [blame] | 5020 | if (adapter->ipa_context) { |
| 5021 | qdf_mutex_release(&hdd_ipa->event_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5022 | return 0; |
Yun Park | 8f289c8 | 2016-10-18 16:38:21 -0700 | [diff] [blame] | 5023 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5024 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5025 | ret = hdd_ipa_setup_iface(hdd_ipa, adapter, sta_id); |
| 5026 | if (ret) { |
Yun Park | 64c405e | 2017-01-10 22:35:51 -0800 | [diff] [blame] | 5027 | qdf_mutex_release(&hdd_ipa->event_lock); |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 5028 | hdd_err("%s: Evt: %d, Interface setup failed", |
| 5029 | msg_ex->name, meta.msg_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5030 | goto end; |
Yun Park | a37592b | 2016-06-11 17:10:28 -0700 | [diff] [blame] | 5031 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5032 | |
Yun Park | 8f289c8 | 2016-10-18 16:38:21 -0700 | [diff] [blame] | 5033 | if (hdd_ipa_uc_is_enabled(hdd_ipa->hdd_ctx)) { |
| 5034 | qdf_mutex_release(&hdd_ipa->event_lock); |
| 5035 | hdd_ipa_uc_offload_enable_disable(adapter, |
Prakash Dhavali | 89d406d | 2016-11-23 11:11:00 -0800 | [diff] [blame] | 5036 | SIR_AP_RX_DATA_OFFLOAD, true); |
Yun Park | 8f289c8 | 2016-10-18 16:38:21 -0700 | [diff] [blame] | 5037 | qdf_mutex_acquire(&hdd_ipa->event_lock); |
| 5038 | } |
| 5039 | |
Prakash Dhavali | 89d406d | 2016-11-23 11:11:00 -0800 | [diff] [blame] | 5040 | hdd_ipa->vdev_to_iface[adapter->sessionId] = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5041 | ((struct hdd_ipa_iface_context *) |
Yun Park | a37592b | 2016-06-11 17:10:28 -0700 | [diff] [blame] | 5042 | (adapter->ipa_context))->iface_id; |
| 5043 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 5044 | qdf_mutex_release(&hdd_ipa->event_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5045 | break; |
| 5046 | |
| 5047 | case WLAN_STA_DISCONNECT: |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 5048 | qdf_mutex_acquire(&hdd_ipa->event_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5049 | |
| 5050 | if (!hdd_ipa->sta_connected) { |
Yun Park | 64c405e | 2017-01-10 22:35:51 -0800 | [diff] [blame] | 5051 | qdf_mutex_release(&hdd_ipa->event_lock); |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 5052 | hdd_err("%s: Evt: %d, STA already disconnected", |
| 5053 | msg_ex->name, meta.msg_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5054 | return -EINVAL; |
| 5055 | } |
Yun Park | a37592b | 2016-06-11 17:10:28 -0700 | [diff] [blame] | 5056 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5057 | hdd_ipa->sta_connected = 0; |
Yun Park | a37592b | 2016-06-11 17:10:28 -0700 | [diff] [blame] | 5058 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5059 | if (!hdd_ipa_uc_is_enabled(hdd_ipa->hdd_ctx)) { |
Srinivas Girigowda | 9785237 | 2017-03-06 16:52:59 -0800 | [diff] [blame] | 5060 | hdd_debug("%s: IPA UC OFFLOAD NOT ENABLED", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5061 | msg_ex->name); |
| 5062 | } else { |
| 5063 | /* Disable IPA UC TX PIPE when STA disconnected */ |
Yun Park | a37592b | 2016-06-11 17:10:28 -0700 | [diff] [blame] | 5064 | if (!hdd_ipa->num_iface && |
| 5065 | (HDD_IPA_UC_NUM_WDI_PIPE == |
Govind Singh | b78a75c | 2017-02-21 17:37:11 +0530 | [diff] [blame] | 5066 | hdd_ipa->activated_fw_pipe) && |
| 5067 | !hdd_ipa->ipa_pipes_down) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5068 | hdd_ipa_uc_handle_last_discon(hdd_ipa); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5069 | } |
| 5070 | |
Yun Park | 74127cf | 2016-09-18 11:22:41 -0700 | [diff] [blame] | 5071 | if (hdd_ipa_uc_sta_is_enabled(hdd_ipa->hdd_ctx) && |
| 5072 | (hdd_ipa->sap_num_connected_sta > 0)) { |
Yun Park | 8f289c8 | 2016-10-18 16:38:21 -0700 | [diff] [blame] | 5073 | qdf_mutex_release(&hdd_ipa->event_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5074 | hdd_ipa_uc_offload_enable_disable(adapter, |
Prakash Dhavali | 89d406d | 2016-11-23 11:11:00 -0800 | [diff] [blame] | 5075 | SIR_STA_RX_DATA_OFFLOAD, false); |
Yun Park | 8f289c8 | 2016-10-18 16:38:21 -0700 | [diff] [blame] | 5076 | qdf_mutex_acquire(&hdd_ipa->event_lock); |
Prakash Dhavali | 89d406d | 2016-11-23 11:11:00 -0800 | [diff] [blame] | 5077 | hdd_ipa->vdev_to_iface[adapter->sessionId] = |
| 5078 | CSR_ROAM_SESSION_MAX; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5079 | } |
| 5080 | |
Yun Park | 8f289c8 | 2016-10-18 16:38:21 -0700 | [diff] [blame] | 5081 | hdd_ipa_cleanup_iface(adapter->ipa_context); |
| 5082 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 5083 | qdf_mutex_release(&hdd_ipa->event_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5084 | break; |
| 5085 | |
| 5086 | case WLAN_AP_DISCONNECT: |
Yun Park | 8f289c8 | 2016-10-18 16:38:21 -0700 | [diff] [blame] | 5087 | qdf_mutex_acquire(&hdd_ipa->event_lock); |
| 5088 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5089 | if (!adapter->ipa_context) { |
Yun Park | 64c405e | 2017-01-10 22:35:51 -0800 | [diff] [blame] | 5090 | qdf_mutex_release(&hdd_ipa->event_lock); |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 5091 | hdd_err("%s: Evt: %d, SAP already disconnected", |
| 5092 | msg_ex->name, meta.msg_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5093 | return -EINVAL; |
| 5094 | } |
| 5095 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5096 | if ((!hdd_ipa->num_iface) && |
| 5097 | (HDD_IPA_UC_NUM_WDI_PIPE == |
Govind Singh | b78a75c | 2017-02-21 17:37:11 +0530 | [diff] [blame] | 5098 | hdd_ipa->activated_fw_pipe) && |
| 5099 | !hdd_ipa->ipa_pipes_down) { |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 5100 | if (cds_is_driver_unloading()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5101 | /* |
| 5102 | * We disable WDI pipes directly here since |
| 5103 | * IPA_OPCODE_TX/RX_SUSPEND message will not be |
| 5104 | * processed when unloading WLAN driver is in |
| 5105 | * progress |
| 5106 | */ |
| 5107 | hdd_ipa_uc_disable_pipes(hdd_ipa); |
| 5108 | } else { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 5109 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5110 | "NO INTF left but still pipe clean up"); |
| 5111 | hdd_ipa_uc_handle_last_discon(hdd_ipa); |
| 5112 | } |
| 5113 | } |
| 5114 | |
| 5115 | if (hdd_ipa_uc_is_enabled(hdd_ipa->hdd_ctx)) { |
Yun Park | 8f289c8 | 2016-10-18 16:38:21 -0700 | [diff] [blame] | 5116 | qdf_mutex_release(&hdd_ipa->event_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5117 | hdd_ipa_uc_offload_enable_disable(adapter, |
Prakash Dhavali | 89d406d | 2016-11-23 11:11:00 -0800 | [diff] [blame] | 5118 | SIR_AP_RX_DATA_OFFLOAD, false); |
Yun Park | 8f289c8 | 2016-10-18 16:38:21 -0700 | [diff] [blame] | 5119 | qdf_mutex_acquire(&hdd_ipa->event_lock); |
Prakash Dhavali | 89d406d | 2016-11-23 11:11:00 -0800 | [diff] [blame] | 5120 | hdd_ipa->vdev_to_iface[adapter->sessionId] = |
| 5121 | CSR_ROAM_SESSION_MAX; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5122 | } |
Yun Park | a37592b | 2016-06-11 17:10:28 -0700 | [diff] [blame] | 5123 | |
Yun Park | 8f289c8 | 2016-10-18 16:38:21 -0700 | [diff] [blame] | 5124 | hdd_ipa_cleanup_iface(adapter->ipa_context); |
| 5125 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 5126 | qdf_mutex_release(&hdd_ipa->event_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5127 | break; |
| 5128 | |
| 5129 | case WLAN_CLIENT_CONNECT_EX: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5130 | if (!hdd_ipa_uc_is_enabled(hdd_ipa->hdd_ctx)) { |
Srinivas Girigowda | 9785237 | 2017-03-06 16:52:59 -0800 | [diff] [blame] | 5131 | HDD_IPA_LOG(QDF_TRACE_LEVEL_DEBUG, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5132 | "%s: Evt: %d, IPA UC OFFLOAD NOT ENABLED", |
Manjeet Singh | fd51d8f | 2016-11-09 15:58:26 +0530 | [diff] [blame] | 5133 | adapter->dev->name, type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5134 | return 0; |
| 5135 | } |
| 5136 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 5137 | qdf_mutex_acquire(&hdd_ipa->event_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5138 | if (hdd_ipa_uc_find_add_assoc_sta(hdd_ipa, |
| 5139 | true, sta_id)) { |
Yun Park | 8f289c8 | 2016-10-18 16:38:21 -0700 | [diff] [blame] | 5140 | qdf_mutex_release(&hdd_ipa->event_lock); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 5141 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5142 | "%s: STA ID %d found, not valid", |
| 5143 | adapter->dev->name, sta_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5144 | return 0; |
| 5145 | } |
Yun Park | 312f71a | 2015-12-08 10:22:42 -0800 | [diff] [blame] | 5146 | |
| 5147 | /* Enable IPA UC Data PIPEs when first STA connected */ |
Manikandan Mohan | 153a4c3 | 2017-02-16 15:04:30 -0800 | [diff] [blame] | 5148 | if (hdd_ipa->sap_num_connected_sta == 0 && |
| 5149 | hdd_ipa->uc_loaded == true) { |
Yun Park | a37592b | 2016-06-11 17:10:28 -0700 | [diff] [blame] | 5150 | if (hdd_ipa_uc_sta_is_enabled(hdd_ipa->hdd_ctx) && |
Yun Park | 8f289c8 | 2016-10-18 16:38:21 -0700 | [diff] [blame] | 5151 | hdd_ipa->sta_connected) { |
| 5152 | qdf_mutex_release(&hdd_ipa->event_lock); |
Yun Park | a37592b | 2016-06-11 17:10:28 -0700 | [diff] [blame] | 5153 | hdd_ipa_uc_offload_enable_disable( |
| 5154 | hdd_get_adapter(hdd_ipa->hdd_ctx, |
| 5155 | QDF_STA_MODE), |
Prakash Dhavali | 89d406d | 2016-11-23 11:11:00 -0800 | [diff] [blame] | 5156 | SIR_STA_RX_DATA_OFFLOAD, true); |
Yun Park | 8f289c8 | 2016-10-18 16:38:21 -0700 | [diff] [blame] | 5157 | qdf_mutex_acquire(&hdd_ipa->event_lock); |
| 5158 | } |
Yun Park | a37592b | 2016-06-11 17:10:28 -0700 | [diff] [blame] | 5159 | |
Yun Park | 312f71a | 2015-12-08 10:22:42 -0800 | [diff] [blame] | 5160 | ret = hdd_ipa_uc_handle_first_con(hdd_ipa); |
| 5161 | if (ret) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 5162 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
Yun Park | 312f71a | 2015-12-08 10:22:42 -0800 | [diff] [blame] | 5163 | "%s: handle 1st con ret %d", |
| 5164 | adapter->dev->name, ret); |
Yun Park | a37592b | 2016-06-11 17:10:28 -0700 | [diff] [blame] | 5165 | |
| 5166 | if (hdd_ipa_uc_sta_is_enabled( |
| 5167 | hdd_ipa->hdd_ctx) && |
Yun Park | 8f289c8 | 2016-10-18 16:38:21 -0700 | [diff] [blame] | 5168 | hdd_ipa->sta_connected) { |
| 5169 | qdf_mutex_release(&hdd_ipa->event_lock); |
Yun Park | a37592b | 2016-06-11 17:10:28 -0700 | [diff] [blame] | 5170 | hdd_ipa_uc_offload_enable_disable( |
| 5171 | hdd_get_adapter( |
| 5172 | hdd_ipa->hdd_ctx, |
| 5173 | QDF_STA_MODE), |
Prakash Dhavali | 89d406d | 2016-11-23 11:11:00 -0800 | [diff] [blame] | 5174 | SIR_STA_RX_DATA_OFFLOAD, false); |
Yun Park | 8f289c8 | 2016-10-18 16:38:21 -0700 | [diff] [blame] | 5175 | } else { |
| 5176 | qdf_mutex_release(&hdd_ipa->event_lock); |
| 5177 | } |
Yun Park | a37592b | 2016-06-11 17:10:28 -0700 | [diff] [blame] | 5178 | |
Yun Park | 312f71a | 2015-12-08 10:22:42 -0800 | [diff] [blame] | 5179 | return ret; |
| 5180 | } |
| 5181 | } |
| 5182 | |
| 5183 | hdd_ipa->sap_num_connected_sta++; |
Yun Park | 312f71a | 2015-12-08 10:22:42 -0800 | [diff] [blame] | 5184 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 5185 | qdf_mutex_release(&hdd_ipa->event_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5186 | |
| 5187 | meta.msg_type = type; |
| 5188 | meta.msg_len = (sizeof(struct ipa_wlan_msg_ex) + |
| 5189 | sizeof(struct ipa_wlan_hdr_attrib_val)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 5190 | msg_ex = qdf_mem_malloc(meta.msg_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5191 | |
| 5192 | if (msg_ex == NULL) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 5193 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5194 | "msg_ex allocation failed"); |
| 5195 | return -ENOMEM; |
| 5196 | } |
| 5197 | strlcpy(msg_ex->name, adapter->dev->name, |
| 5198 | IPA_RESOURCE_NAME_MAX); |
| 5199 | msg_ex->num_of_attribs = 1; |
| 5200 | msg_ex->attribs[0].attrib_type = WLAN_HDR_ATTRIB_MAC_ADDR; |
| 5201 | if (hdd_ipa_uc_is_enabled(hdd_ipa->hdd_ctx)) { |
| 5202 | msg_ex->attribs[0].offset = |
| 5203 | HDD_IPA_UC_WLAN_HDR_DES_MAC_OFFSET; |
| 5204 | } else { |
| 5205 | msg_ex->attribs[0].offset = |
| 5206 | HDD_IPA_WLAN_HDR_DES_MAC_OFFSET; |
| 5207 | } |
| 5208 | memcpy(msg_ex->attribs[0].u.mac_addr, mac_addr, |
| 5209 | IPA_MAC_ADDR_SIZE); |
| 5210 | |
| 5211 | ret = ipa_send_msg(&meta, msg_ex, hdd_ipa_msg_free_fn); |
| 5212 | |
| 5213 | if (ret) { |
Srinivas Girigowda | 9785237 | 2017-03-06 16:52:59 -0800 | [diff] [blame] | 5214 | HDD_IPA_LOG(QDF_TRACE_LEVEL_DEBUG, "%s: Evt: %d : %d", |
Manjeet Singh | fd51d8f | 2016-11-09 15:58:26 +0530 | [diff] [blame] | 5215 | adapter->dev->name, type, ret); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 5216 | qdf_mem_free(msg_ex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5217 | return ret; |
| 5218 | } |
| 5219 | hdd_ipa->stats.num_send_msg++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5220 | return ret; |
| 5221 | |
| 5222 | case WLAN_CLIENT_DISCONNECT: |
| 5223 | if (!hdd_ipa_uc_is_enabled(hdd_ipa->hdd_ctx)) { |
Srinivas Girigowda | 9785237 | 2017-03-06 16:52:59 -0800 | [diff] [blame] | 5224 | HDD_IPA_LOG(QDF_TRACE_LEVEL_DEBUG, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5225 | "%s: IPA UC OFFLOAD NOT ENABLED", |
| 5226 | msg_ex->name); |
| 5227 | return 0; |
| 5228 | } |
| 5229 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 5230 | qdf_mutex_acquire(&hdd_ipa->event_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5231 | if (!hdd_ipa_uc_find_add_assoc_sta(hdd_ipa, false, sta_id)) { |
Yun Park | 64c405e | 2017-01-10 22:35:51 -0800 | [diff] [blame] | 5232 | qdf_mutex_release(&hdd_ipa->event_lock); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 5233 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5234 | "%s: STA ID %d NOT found, not valid", |
| 5235 | msg_ex->name, sta_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5236 | return 0; |
| 5237 | } |
| 5238 | hdd_ipa->sap_num_connected_sta--; |
Yun Park | a37592b | 2016-06-11 17:10:28 -0700 | [diff] [blame] | 5239 | |
Yun Park | 9b5030f | 2016-11-08 12:02:37 -0800 | [diff] [blame] | 5240 | /* Disable IPA UC TX PIPE when last STA disconnected */ |
Manikandan Mohan | 153a4c3 | 2017-02-16 15:04:30 -0800 | [diff] [blame] | 5241 | if (!hdd_ipa->sap_num_connected_sta && |
| 5242 | hdd_ipa->uc_loaded == true) { |
Yun Park | 9b5030f | 2016-11-08 12:02:37 -0800 | [diff] [blame] | 5243 | if ((false == hdd_ipa->resource_unloading) |
| 5244 | && (HDD_IPA_UC_NUM_WDI_PIPE == |
Govind Singh | b78a75c | 2017-02-21 17:37:11 +0530 | [diff] [blame] | 5245 | hdd_ipa->activated_fw_pipe) && |
| 5246 | !hdd_ipa->ipa_pipes_down) { |
Yun Park | 9b5030f | 2016-11-08 12:02:37 -0800 | [diff] [blame] | 5247 | hdd_ipa_uc_handle_last_discon(hdd_ipa); |
| 5248 | } |
| 5249 | |
Yun Park | 9b5030f | 2016-11-08 12:02:37 -0800 | [diff] [blame] | 5250 | if (hdd_ipa_uc_sta_is_enabled(hdd_ipa->hdd_ctx) && |
jiad | 9d472c9 | 2017-07-28 14:05:31 +0800 | [diff] [blame] | 5251 | hdd_ipa->sta_connected) { |
| 5252 | qdf_mutex_release(&hdd_ipa->event_lock); |
Yun Park | 9b5030f | 2016-11-08 12:02:37 -0800 | [diff] [blame] | 5253 | hdd_ipa_uc_offload_enable_disable( |
| 5254 | hdd_get_adapter(hdd_ipa->hdd_ctx, |
| 5255 | QDF_STA_MODE), |
Prakash Dhavali | 89d406d | 2016-11-23 11:11:00 -0800 | [diff] [blame] | 5256 | SIR_STA_RX_DATA_OFFLOAD, false); |
jiad | 9d472c9 | 2017-07-28 14:05:31 +0800 | [diff] [blame] | 5257 | } else { |
| 5258 | qdf_mutex_release(&hdd_ipa->event_lock); |
| 5259 | } |
Yun Park | 8f289c8 | 2016-10-18 16:38:21 -0700 | [diff] [blame] | 5260 | } else { |
| 5261 | qdf_mutex_release(&hdd_ipa->event_lock); |
| 5262 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5263 | break; |
| 5264 | |
| 5265 | default: |
| 5266 | return 0; |
| 5267 | } |
| 5268 | |
| 5269 | meta.msg_len = sizeof(struct ipa_wlan_msg); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 5270 | msg = qdf_mem_malloc(meta.msg_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5271 | if (msg == NULL) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 5272 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, "msg allocation failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5273 | return -ENOMEM; |
| 5274 | } |
| 5275 | |
| 5276 | meta.msg_type = type; |
| 5277 | strlcpy(msg->name, adapter->dev->name, IPA_RESOURCE_NAME_MAX); |
| 5278 | memcpy(msg->mac_addr, mac_addr, ETH_ALEN); |
| 5279 | |
Srinivas Girigowda | 9785237 | 2017-03-06 16:52:59 -0800 | [diff] [blame] | 5280 | HDD_IPA_LOG(QDF_TRACE_LEVEL_DEBUG, "%s: Evt: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5281 | msg->name, meta.msg_type); |
| 5282 | |
| 5283 | ret = ipa_send_msg(&meta, msg, hdd_ipa_msg_free_fn); |
| 5284 | |
| 5285 | if (ret) { |
Yun Park | b187d54 | 2016-11-14 18:10:04 -0800 | [diff] [blame] | 5286 | hdd_err("%s: Evt: %d fail:%d", |
| 5287 | msg->name, meta.msg_type, ret); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 5288 | qdf_mem_free(msg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5289 | return ret; |
| 5290 | } |
| 5291 | |
| 5292 | hdd_ipa->stats.num_send_msg++; |
| 5293 | |
| 5294 | end: |
| 5295 | return ret; |
| 5296 | } |
| 5297 | |
| 5298 | /** |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 5299 | * hdd_ipa_wlan_evt() - SSR wrapper for __hdd_ipa_wlan_evt |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 5300 | * @adapter: adapter upon which the event was received |
| 5301 | * @sta_id: station id for the event |
| 5302 | * @hdd_event_type: event enum of type hdd_ipa_wlan_event |
| 5303 | * @mac_address: MAC address associated with the event |
| 5304 | * |
| 5305 | * This function is meant to be called from outside of wlan_hdd_ipa.c. |
| 5306 | * |
| 5307 | * Return: 0 on success, negative errno value on error |
| 5308 | */ |
| 5309 | int hdd_ipa_wlan_evt(hdd_adapter_t *adapter, uint8_t sta_id, |
| 5310 | enum hdd_ipa_wlan_event hdd_event_type, uint8_t *mac_addr) |
| 5311 | { |
| 5312 | enum ipa_wlan_event type = hdd_to_ipa_wlan_event(hdd_event_type); |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 5313 | int ret = 0; |
| 5314 | |
| 5315 | cds_ssr_protect(__func__); |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 5316 | |
Leo Chang | a202b52 | 2016-10-14 16:13:50 -0700 | [diff] [blame] | 5317 | /* Data path offload only support for STA and SAP mode */ |
| 5318 | if ((QDF_STA_MODE == adapter->device_mode) || |
| 5319 | (QDF_SAP_MODE == adapter->device_mode)) |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 5320 | ret = __hdd_ipa_wlan_evt(adapter, sta_id, type, mac_addr); |
Leo Chang | a202b52 | 2016-10-14 16:13:50 -0700 | [diff] [blame] | 5321 | |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 5322 | cds_ssr_unprotect(__func__); |
| 5323 | |
| 5324 | return ret; |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 5325 | } |
| 5326 | |
| 5327 | /** |
| 5328 | * hdd_ipa_uc_proc_pending_event() - Process IPA uC pending events |
| 5329 | * @hdd_ipa: Global HDD IPA context |
| 5330 | * |
| 5331 | * Return: None |
| 5332 | */ |
| 5333 | static void |
| 5334 | hdd_ipa_uc_proc_pending_event(struct hdd_ipa_priv *hdd_ipa) |
| 5335 | { |
| 5336 | unsigned int pending_event_count; |
| 5337 | struct ipa_uc_pending_event *pending_event = NULL; |
| 5338 | |
| 5339 | pending_event_count = qdf_list_size(&hdd_ipa->pending_event); |
Srinivas Girigowda | 9785237 | 2017-03-06 16:52:59 -0800 | [diff] [blame] | 5340 | HDD_IPA_LOG(QDF_TRACE_LEVEL_DEBUG, |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 5341 | "%s, Pending Event Count %d", __func__, pending_event_count); |
| 5342 | if (!pending_event_count) { |
Srinivas Girigowda | 9785237 | 2017-03-06 16:52:59 -0800 | [diff] [blame] | 5343 | HDD_IPA_LOG(QDF_TRACE_LEVEL_DEBUG, |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 5344 | "%s, No Pending Event", __func__); |
| 5345 | return; |
| 5346 | } |
| 5347 | |
| 5348 | qdf_list_remove_front(&hdd_ipa->pending_event, |
| 5349 | (qdf_list_node_t **)&pending_event); |
| 5350 | while (pending_event != NULL) { |
| 5351 | __hdd_ipa_wlan_evt(pending_event->adapter, |
| 5352 | pending_event->type, |
| 5353 | pending_event->sta_id, |
| 5354 | pending_event->mac_addr); |
| 5355 | qdf_mem_free(pending_event); |
| 5356 | pending_event = NULL; |
| 5357 | qdf_list_remove_front(&hdd_ipa->pending_event, |
| 5358 | (qdf_list_node_t **)&pending_event); |
| 5359 | } |
| 5360 | } |
| 5361 | |
| 5362 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5363 | * hdd_ipa_rm_state_to_str() - Convert IPA RM state to string |
| 5364 | * @state: IPA RM state value |
| 5365 | * |
| 5366 | * Return: ASCII string representing the IPA RM state |
| 5367 | */ |
| 5368 | static inline char *hdd_ipa_rm_state_to_str(enum hdd_ipa_rm_state state) |
| 5369 | { |
| 5370 | switch (state) { |
| 5371 | case HDD_IPA_RM_RELEASED: |
| 5372 | return "RELEASED"; |
| 5373 | case HDD_IPA_RM_GRANT_PENDING: |
| 5374 | return "GRANT_PENDING"; |
| 5375 | case HDD_IPA_RM_GRANTED: |
| 5376 | return "GRANTED"; |
| 5377 | } |
| 5378 | |
| 5379 | return "UNKNOWN"; |
| 5380 | } |
| 5381 | |
| 5382 | /** |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 5383 | * __hdd_ipa_init() - IPA initialization function |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5384 | * @hdd_ctx: HDD global context |
| 5385 | * |
| 5386 | * Allocate hdd_ipa resources, ipa pipe resource and register |
| 5387 | * wlan interface with IPA module. |
| 5388 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5389 | * Return: QDF_STATUS enumeration |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5390 | */ |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 5391 | static QDF_STATUS __hdd_ipa_init(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5392 | { |
| 5393 | struct hdd_ipa_priv *hdd_ipa = NULL; |
| 5394 | int ret, i; |
| 5395 | struct hdd_ipa_iface_context *iface_context = NULL; |
Yun Park | baa6286 | 2017-01-18 13:43:34 -0800 | [diff] [blame] | 5396 | struct ol_txrx_pdev_t *pdev = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5397 | |
| 5398 | if (!hdd_ipa_is_enabled(hdd_ctx)) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5399 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5400 | |
Yun Park | baa6286 | 2017-01-18 13:43:34 -0800 | [diff] [blame] | 5401 | ENTER(); |
| 5402 | |
| 5403 | pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
Yun Park | 7f171ab | 2016-07-29 15:44:22 -0700 | [diff] [blame] | 5404 | if (!pdev) { |
| 5405 | HDD_IPA_LOG(QDF_TRACE_LEVEL_FATAL, "pdev is NULL"); |
| 5406 | goto fail_return; |
| 5407 | } |
| 5408 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 5409 | hdd_ipa = qdf_mem_malloc(sizeof(*hdd_ipa)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5410 | if (!hdd_ipa) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 5411 | HDD_IPA_LOG(QDF_TRACE_LEVEL_FATAL, "hdd_ipa allocation failed"); |
Leo Chang | 3bc8fed | 2015-11-13 10:59:47 -0800 | [diff] [blame] | 5412 | goto fail_return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5413 | } |
| 5414 | |
| 5415 | hdd_ctx->hdd_ipa = hdd_ipa; |
| 5416 | ghdd_ipa = hdd_ipa; |
| 5417 | hdd_ipa->hdd_ctx = hdd_ctx; |
| 5418 | hdd_ipa->num_iface = 0; |
| 5419 | |
| 5420 | /* Create the interface context */ |
| 5421 | for (i = 0; i < HDD_IPA_MAX_IFACE; i++) { |
| 5422 | iface_context = &hdd_ipa->iface_context[i]; |
| 5423 | iface_context->hdd_ipa = hdd_ipa; |
| 5424 | iface_context->cons_client = |
| 5425 | hdd_ipa_adapter_2_client[i].cons_client; |
| 5426 | iface_context->prod_client = |
| 5427 | hdd_ipa_adapter_2_client[i].prod_client; |
| 5428 | iface_context->iface_id = i; |
| 5429 | iface_context->adapter = NULL; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 5430 | qdf_spinlock_create(&iface_context->interface_lock); |
Yun Park | 9b5030f | 2016-11-08 12:02:37 -0800 | [diff] [blame] | 5431 | } |
| 5432 | for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { |
Prakash Dhavali | 89d406d | 2016-11-23 11:11:00 -0800 | [diff] [blame] | 5433 | hdd_ipa->vdev_to_iface[i] = CSR_ROAM_SESSION_MAX; |
| 5434 | hdd_ipa->vdev_offload_enabled[i] = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5435 | } |
| 5436 | |
Leo Chang | 69c3969 | 2016-10-12 20:11:12 -0700 | [diff] [blame] | 5437 | INIT_WORK(&hdd_ipa->pm_work, hdd_ipa_pm_flush); |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 5438 | qdf_spinlock_create(&hdd_ipa->pm_lock); |
Yun Park | 52b2b99 | 2016-09-22 15:49:51 -0700 | [diff] [blame] | 5439 | qdf_spinlock_create(&hdd_ipa->q_lock); |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 5440 | qdf_nbuf_queue_init(&hdd_ipa->pm_queue_head); |
Manikandan Mohan | 2e803a0 | 2017-02-14 14:57:53 -0800 | [diff] [blame] | 5441 | qdf_list_create(&hdd_ipa->pending_event, 1000); |
| 5442 | qdf_mutex_create(&hdd_ipa->event_lock); |
| 5443 | qdf_mutex_create(&hdd_ipa->ipa_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5444 | |
| 5445 | ret = hdd_ipa_setup_rm(hdd_ipa); |
| 5446 | if (ret) |
| 5447 | goto fail_setup_rm; |
| 5448 | |
| 5449 | if (hdd_ipa_uc_is_enabled(hdd_ipa->hdd_ctx)) { |
| 5450 | hdd_ipa_uc_rt_debug_init(hdd_ctx); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 5451 | qdf_mem_zero(&hdd_ipa->stats, sizeof(hdd_ipa->stats)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5452 | hdd_ipa->sap_num_connected_sta = 0; |
| 5453 | hdd_ipa->ipa_tx_packets_diff = 0; |
| 5454 | hdd_ipa->ipa_rx_packets_diff = 0; |
| 5455 | hdd_ipa->ipa_p_tx_packets = 0; |
| 5456 | hdd_ipa->ipa_p_rx_packets = 0; |
| 5457 | hdd_ipa->resource_loading = false; |
| 5458 | hdd_ipa->resource_unloading = false; |
| 5459 | hdd_ipa->sta_connected = 0; |
Leo Chang | e3e4944 | 2015-10-26 20:07:13 -0700 | [diff] [blame] | 5460 | hdd_ipa->ipa_pipes_down = true; |
Manikandan Mohan | cd64c0b | 2017-03-08 13:00:24 -0800 | [diff] [blame] | 5461 | hdd_ipa->wdi_enabled = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5462 | /* Setup IPA sys_pipe for MCC */ |
| 5463 | if (hdd_ipa_uc_sta_is_enabled(hdd_ipa->hdd_ctx)) { |
| 5464 | ret = hdd_ipa_setup_sys_pipe(hdd_ipa); |
| 5465 | if (ret) |
| 5466 | goto fail_create_sys_pipe; |
| 5467 | } |
Manikandan Mohan | 153a4c3 | 2017-02-16 15:04:30 -0800 | [diff] [blame] | 5468 | if (hdd_ipa_uc_register_uc_ready(hdd_ipa)) |
| 5469 | goto fail_create_sys_pipe; |
Manikandan Mohan | 2e803a0 | 2017-02-14 14:57:53 -0800 | [diff] [blame] | 5470 | |
| 5471 | for (i = 0; i < HDD_IPA_UC_OPCODE_MAX; i++) { |
| 5472 | hdd_ipa_init_uc_op_work(&hdd_ipa->uc_op_work[i].work, |
| 5473 | hdd_ipa_uc_fw_op_event_handler); |
| 5474 | hdd_ipa->uc_op_work[i].msg = NULL; |
| 5475 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5476 | } else { |
| 5477 | ret = hdd_ipa_setup_sys_pipe(hdd_ipa); |
| 5478 | if (ret) |
| 5479 | goto fail_create_sys_pipe; |
| 5480 | } |
| 5481 | |
Yun Park | baa6286 | 2017-01-18 13:43:34 -0800 | [diff] [blame] | 5482 | EXIT(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5483 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5484 | |
| 5485 | fail_create_sys_pipe: |
| 5486 | hdd_ipa_destroy_rm_resource(hdd_ipa); |
| 5487 | fail_setup_rm: |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 5488 | qdf_spinlock_destroy(&hdd_ipa->pm_lock); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 5489 | qdf_mem_free(hdd_ipa); |
Leo Chang | 3bc8fed | 2015-11-13 10:59:47 -0800 | [diff] [blame] | 5490 | hdd_ctx->hdd_ipa = NULL; |
| 5491 | ghdd_ipa = NULL; |
| 5492 | fail_return: |
Yun Park | baa6286 | 2017-01-18 13:43:34 -0800 | [diff] [blame] | 5493 | EXIT(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5494 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5495 | } |
| 5496 | |
| 5497 | /** |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 5498 | * hdd_ipa_init() - SSR wrapper for __hdd_ipa_init |
| 5499 | * @hdd_ctx: HDD global context |
| 5500 | * |
| 5501 | * Allocate hdd_ipa resources, ipa pipe resource and register |
| 5502 | * wlan interface with IPA module. |
| 5503 | * |
| 5504 | * Return: QDF_STATUS enumeration |
| 5505 | */ |
| 5506 | QDF_STATUS hdd_ipa_init(hdd_context_t *hdd_ctx) |
| 5507 | { |
| 5508 | QDF_STATUS ret; |
| 5509 | |
| 5510 | cds_ssr_protect(__func__); |
| 5511 | ret = __hdd_ipa_init(hdd_ctx); |
| 5512 | cds_ssr_unprotect(__func__); |
| 5513 | |
| 5514 | return ret; |
| 5515 | } |
| 5516 | |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5517 | |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 5518 | /** |
Yun Park | f19e07d | 2015-11-20 11:34:27 -0800 | [diff] [blame] | 5519 | * hdd_ipa_cleanup_pending_event() - Cleanup IPA pending event list |
| 5520 | * @hdd_ipa: pointer to HDD IPA struct |
| 5521 | * |
| 5522 | * Return: none |
| 5523 | */ |
Jeff Johnson | d772063 | 2016-10-05 16:04:32 -0700 | [diff] [blame] | 5524 | static void hdd_ipa_cleanup_pending_event(struct hdd_ipa_priv *hdd_ipa) |
Yun Park | f19e07d | 2015-11-20 11:34:27 -0800 | [diff] [blame] | 5525 | { |
| 5526 | struct ipa_uc_pending_event *pending_event = NULL; |
| 5527 | |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5528 | while (qdf_list_remove_front(&hdd_ipa->pending_event, |
| 5529 | (qdf_list_node_t **)&pending_event) == QDF_STATUS_SUCCESS) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 5530 | qdf_mem_free(pending_event); |
Yun Park | f19e07d | 2015-11-20 11:34:27 -0800 | [diff] [blame] | 5531 | } |
| 5532 | |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5533 | qdf_list_destroy(&hdd_ipa->pending_event); |
Yun Park | f19e07d | 2015-11-20 11:34:27 -0800 | [diff] [blame] | 5534 | } |
| 5535 | |
| 5536 | /** |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 5537 | * __hdd_ipa_cleanup - IPA cleanup function |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5538 | * @hdd_ctx: HDD global context |
| 5539 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5540 | * Return: QDF_STATUS enumeration |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5541 | */ |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 5542 | static QDF_STATUS __hdd_ipa_cleanup(hdd_context_t *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5543 | { |
| 5544 | struct hdd_ipa_priv *hdd_ipa = hdd_ctx->hdd_ipa; |
| 5545 | int i; |
| 5546 | struct hdd_ipa_iface_context *iface_context = NULL; |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 5547 | qdf_nbuf_t skb; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5548 | struct hdd_ipa_pm_tx_cb *pm_tx_cb = NULL; |
| 5549 | |
| 5550 | if (!hdd_ipa_is_enabled(hdd_ctx)) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5551 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5552 | |
| 5553 | if (!hdd_ipa_uc_is_enabled(hdd_ctx)) { |
| 5554 | unregister_inetaddr_notifier(&hdd_ipa->ipv4_notifier); |
| 5555 | hdd_ipa_teardown_sys_pipe(hdd_ipa); |
| 5556 | } |
| 5557 | |
| 5558 | /* Teardown IPA sys_pipe for MCC */ |
| 5559 | if (hdd_ipa_uc_sta_is_enabled(hdd_ipa->hdd_ctx)) |
| 5560 | hdd_ipa_teardown_sys_pipe(hdd_ipa); |
| 5561 | |
| 5562 | hdd_ipa_destroy_rm_resource(hdd_ipa); |
| 5563 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5564 | cancel_work_sync(&hdd_ipa->pm_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5565 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 5566 | qdf_spin_lock_bh(&hdd_ipa->pm_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5567 | |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 5568 | while (((skb = qdf_nbuf_queue_remove(&hdd_ipa->pm_queue_head)) |
| 5569 | != NULL)) { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 5570 | qdf_spin_unlock_bh(&hdd_ipa->pm_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5571 | |
| 5572 | pm_tx_cb = (struct hdd_ipa_pm_tx_cb *)skb->cb; |
Yun Park | ed827b4 | 2017-05-12 23:59:27 -0700 | [diff] [blame] | 5573 | if (pm_tx_cb->ipa_tx_desc) |
| 5574 | ipa_free_skb(pm_tx_cb->ipa_tx_desc); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5575 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 5576 | qdf_spin_lock_bh(&hdd_ipa->pm_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5577 | } |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 5578 | qdf_spin_unlock_bh(&hdd_ipa->pm_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5579 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 5580 | qdf_spinlock_destroy(&hdd_ipa->pm_lock); |
Yun Park | 52b2b99 | 2016-09-22 15:49:51 -0700 | [diff] [blame] | 5581 | qdf_spinlock_destroy(&hdd_ipa->q_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5582 | |
| 5583 | /* destory the interface lock */ |
| 5584 | for (i = 0; i < HDD_IPA_MAX_IFACE; i++) { |
| 5585 | iface_context = &hdd_ipa->iface_context[i]; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 5586 | qdf_spinlock_destroy(&iface_context->interface_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5587 | } |
| 5588 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5589 | if (hdd_ipa_uc_is_enabled(hdd_ctx)) { |
Yun Park | 7e1f7c0 | 2017-01-05 08:19:49 -0800 | [diff] [blame] | 5590 | if (ipa_uc_dereg_rdyCB()) |
| 5591 | HDD_IPA_LOG(QDF_TRACE_LEVEL_ERROR, |
| 5592 | "UC Ready CB deregister fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5593 | hdd_ipa_uc_rt_debug_deinit(hdd_ctx); |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 5594 | qdf_mutex_destroy(&hdd_ipa->event_lock); |
| 5595 | qdf_mutex_destroy(&hdd_ipa->ipa_lock); |
Yun Park | f19e07d | 2015-11-20 11:34:27 -0800 | [diff] [blame] | 5596 | hdd_ipa_cleanup_pending_event(hdd_ipa); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5597 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5598 | for (i = 0; i < HDD_IPA_UC_OPCODE_MAX; i++) { |
| 5599 | cancel_work_sync(&hdd_ipa->uc_op_work[i].work); |
| 5600 | hdd_ipa->uc_op_work[i].msg = NULL; |
| 5601 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5602 | } |
| 5603 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 5604 | qdf_mem_free(hdd_ipa); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5605 | hdd_ctx->hdd_ipa = NULL; |
| 5606 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5607 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5608 | } |
Prakash Dhavali | 412cdb0 | 2016-10-20 21:19:31 -0700 | [diff] [blame] | 5609 | |
| 5610 | /** |
| 5611 | * hdd_ipa_cleanup - SSR wrapper for __hdd_ipa_cleanup |
| 5612 | * @hdd_ctx: HDD global context |
| 5613 | * |
| 5614 | * Return: QDF_STATUS enumeration |
| 5615 | */ |
| 5616 | QDF_STATUS hdd_ipa_cleanup(hdd_context_t *hdd_ctx) |
| 5617 | { |
| 5618 | QDF_STATUS ret; |
| 5619 | |
| 5620 | cds_ssr_protect(__func__); |
| 5621 | ret = __hdd_ipa_cleanup(hdd_ctx); |
| 5622 | cds_ssr_unprotect(__func__); |
| 5623 | |
| 5624 | return ret; |
| 5625 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5626 | #endif /* IPA_OFFLOAD */ |