Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Yun Park | e423980 | 2018-01-09 11:01:40 -0800 | [diff] [blame] | 2 | * Copyright (c) 2012-2018 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 | |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame] | 28 | /* denote that this file does not allow legacy hddLog */ |
| 29 | #define HDD_DISALLOW_LEGACY_HDDLOG 1 |
| 30 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 31 | /* Include files */ |
| 32 | #include <linux/semaphore.h> |
| 33 | #include <wlan_hdd_tx_rx.h> |
| 34 | #include <wlan_hdd_softap_tx_rx.h> |
| 35 | #include <linux/netdevice.h> |
| 36 | #include <linux/skbuff.h> |
| 37 | #include <linux/etherdevice.h> |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 38 | #include <qdf_types.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 39 | #include <ani_global.h> |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 40 | #include <qdf_types.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 41 | #include <net/ieee80211_radiotap.h> |
| 42 | #include <cds_sched.h> |
| 43 | #include <wlan_hdd_napi.h> |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 44 | #include <cdp_txrx_cmn.h> |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 45 | #include <cdp_txrx_peer_ops.h> |
Manjunathappa Prakash | 779e486 | 2016-09-12 17:00:11 -0700 | [diff] [blame] | 46 | #include <cds_utils.h> |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 47 | #include <cdp_txrx_flow_ctrl_v2.h> |
Sravan Kumar Kairam | 3a69831 | 2017-10-16 14:16:16 +0530 | [diff] [blame] | 48 | #include <cdp_txrx_misc.h> |
Abhishek Singh | 07c627e | 2017-03-20 17:56:34 +0530 | [diff] [blame] | 49 | #include <wlan_hdd_object_manager.h> |
Rachit Kankane | 2487f8f | 2017-04-19 14:30:19 +0530 | [diff] [blame] | 50 | #include "wlan_p2p_ucfg_api.h" |
Mukul Sharma | ecf8e09 | 2017-12-19 22:36:31 +0530 | [diff] [blame] | 51 | #include <wlan_hdd_regulatory.h> |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 52 | #include "wlan_ipa_ucfg_api.h" |
Yun Park | c3e3556 | 2018-03-08 12:05:52 -0800 | [diff] [blame] | 53 | #include <wma_types.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 54 | |
| 55 | /* Preprocessor definitions and constants */ |
| 56 | #undef QCA_HDD_SAP_DUMP_SK_BUFF |
| 57 | |
| 58 | /* Type declarations */ |
| 59 | |
| 60 | /* Function definitions and documenation */ |
| 61 | #ifdef QCA_HDD_SAP_DUMP_SK_BUFF |
| 62 | /** |
| 63 | * hdd_softap_dump_sk_buff() - Dump an skb |
| 64 | * @skb: skb to dump |
| 65 | * |
| 66 | * Return: None |
| 67 | */ |
| 68 | static void hdd_softap_dump_sk_buff(struct sk_buff *skb) |
| 69 | { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 70 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR, |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 71 | "%s: head = %pK ", __func__, skb->head); |
Srinivas Girigowda | e806a82 | 2017-03-25 11:25:30 -0700 | [diff] [blame] | 72 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO, |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 73 | "%s: tail = %pK ", __func__, skb->tail); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 74 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR, |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 75 | "%s: end = %pK ", __func__, skb->end); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 76 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 77 | "%s: len = %d ", __func__, skb->len); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 78 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 79 | "%s: data_len = %d ", __func__, skb->data_len); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 80 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 81 | "%s: mac_len = %d", __func__, skb->mac_len); |
| 82 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 83 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 84 | "0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x ", skb->data[0], |
| 85 | skb->data[1], skb->data[2], skb->data[3], skb->data[4], |
| 86 | skb->data[5], skb->data[6], skb->data[7]); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 87 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 88 | "0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", skb->data[8], |
| 89 | skb->data[9], skb->data[10], skb->data[11], skb->data[12], |
| 90 | skb->data[13], skb->data[14], skb->data[15]); |
| 91 | } |
| 92 | #else |
| 93 | static void hdd_softap_dump_sk_buff(struct sk_buff *skb) |
| 94 | { |
| 95 | } |
| 96 | #endif |
| 97 | |
| 98 | #ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL |
| 99 | /** |
| 100 | * hdd_softap_tx_resume_timer_expired_handler() - TX Q resume timer handler |
| 101 | * @adapter_context: pointer to vdev adapter |
| 102 | * |
| 103 | * TX Q resume timer handler for SAP and P2P GO interface. If Blocked |
| 104 | * OS Q is not resumed during timeout period, to prevent permanent |
| 105 | * stall, resume OS Q forcefully for SAP and P2P GO interface. |
| 106 | * |
| 107 | * Return: None |
| 108 | */ |
| 109 | void hdd_softap_tx_resume_timer_expired_handler(void *adapter_context) |
| 110 | { |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 111 | struct hdd_adapter *adapter = (struct hdd_adapter *) adapter_context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 112 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 113 | if (!adapter) { |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame] | 114 | hdd_err("NULL adapter"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 115 | return; |
| 116 | } |
| 117 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 118 | hdd_debug("Enabling queues"); |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 119 | wlan_hdd_netif_queue_control(adapter, WLAN_WAKE_ALL_NETIF_QUEUE, |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame] | 120 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 121 | } |
| 122 | |
Poddar, Siddarth | b61cf64 | 2016-04-28 16:02:39 +0530 | [diff] [blame] | 123 | #if defined(CONFIG_PER_VDEV_TX_DESC_POOL) |
| 124 | |
| 125 | /** |
| 126 | * hdd_softap_tx_resume_false() - Resume OS TX Q false leads to queue disabling |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 127 | * @adapter: pointer to hdd adapter |
Poddar, Siddarth | b61cf64 | 2016-04-28 16:02:39 +0530 | [diff] [blame] | 128 | * @tx_resume: TX Q resume trigger |
| 129 | * |
| 130 | * |
| 131 | * Return: None |
| 132 | */ |
| 133 | static void |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 134 | hdd_softap_tx_resume_false(struct hdd_adapter *adapter, bool tx_resume) |
Poddar, Siddarth | b61cf64 | 2016-04-28 16:02:39 +0530 | [diff] [blame] | 135 | { |
| 136 | if (true == tx_resume) |
| 137 | return; |
| 138 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 139 | hdd_debug("Disabling queues"); |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 140 | wlan_hdd_netif_queue_control(adapter, WLAN_STOP_ALL_NETIF_QUEUE, |
Poddar, Siddarth | b61cf64 | 2016-04-28 16:02:39 +0530 | [diff] [blame] | 141 | WLAN_DATA_FLOW_CONTROL); |
| 142 | |
| 143 | if (QDF_TIMER_STATE_STOPPED == |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 144 | qdf_mc_timer_get_current_state(&adapter-> |
Poddar, Siddarth | b61cf64 | 2016-04-28 16:02:39 +0530 | [diff] [blame] | 145 | tx_flow_control_timer)) { |
| 146 | QDF_STATUS status; |
Srinivas Girigowda | e806a82 | 2017-03-25 11:25:30 -0700 | [diff] [blame] | 147 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 148 | status = qdf_mc_timer_start(&adapter->tx_flow_control_timer, |
Poddar, Siddarth | b61cf64 | 2016-04-28 16:02:39 +0530 | [diff] [blame] | 149 | WLAN_SAP_HDD_TX_FLOW_CONTROL_OS_Q_BLOCK_TIME); |
| 150 | |
| 151 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 152 | hdd_err("Failed to start tx_flow_control_timer"); |
| 153 | else |
Jeff Johnson | 6ced42c | 2017-10-20 12:48:11 -0700 | [diff] [blame] | 154 | adapter->hdd_stats.tx_rx_stats.txflow_timer_cnt++; |
Poddar, Siddarth | b61cf64 | 2016-04-28 16:02:39 +0530 | [diff] [blame] | 155 | } |
Poddar, Siddarth | b61cf64 | 2016-04-28 16:02:39 +0530 | [diff] [blame] | 156 | } |
| 157 | #else |
| 158 | |
| 159 | static inline void |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 160 | hdd_softap_tx_resume_false(struct hdd_adapter *adapter, bool tx_resume) |
Poddar, Siddarth | b61cf64 | 2016-04-28 16:02:39 +0530 | [diff] [blame] | 161 | { |
Poddar, Siddarth | b61cf64 | 2016-04-28 16:02:39 +0530 | [diff] [blame] | 162 | } |
| 163 | #endif |
| 164 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 165 | /** |
| 166 | * hdd_softap_tx_resume_cb() - Resume OS TX Q. |
| 167 | * @adapter_context: pointer to vdev apdapter |
| 168 | * @tx_resume: TX Q resume trigger |
| 169 | * |
| 170 | * Q was stopped due to WLAN TX path low resource condition |
| 171 | * |
| 172 | * Return: None |
| 173 | */ |
| 174 | void hdd_softap_tx_resume_cb(void *adapter_context, bool tx_resume) |
| 175 | { |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 176 | struct hdd_adapter *adapter = (struct hdd_adapter *) adapter_context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 177 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 178 | if (!adapter) { |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame] | 179 | hdd_err("NULL adapter"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 180 | return; |
| 181 | } |
| 182 | |
| 183 | /* Resume TX */ |
| 184 | if (true == tx_resume) { |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 185 | if (QDF_TIMER_STATE_STOPPED != |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 186 | qdf_mc_timer_get_current_state(&adapter-> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 187 | tx_flow_control_timer)) { |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 188 | qdf_mc_timer_stop(&adapter->tx_flow_control_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 189 | } |
| 190 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 191 | hdd_debug("Enabling queues"); |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 192 | wlan_hdd_netif_queue_control(adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 193 | WLAN_WAKE_ALL_NETIF_QUEUE, |
| 194 | WLAN_DATA_FLOW_CONTROL); |
| 195 | } |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 196 | hdd_softap_tx_resume_false(adapter, tx_resume); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 197 | } |
gbian | ec670c59 | 2016-11-24 11:21:30 +0800 | [diff] [blame] | 198 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 199 | static inline struct sk_buff *hdd_skb_orphan(struct hdd_adapter *adapter, |
gbian | ec670c59 | 2016-11-24 11:21:30 +0800 | [diff] [blame] | 200 | struct sk_buff *skb) |
| 201 | { |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 202 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
tfyu | bdf453e | 2017-09-27 13:34:30 +0800 | [diff] [blame] | 203 | int need_orphan = 0; |
| 204 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 205 | if (adapter->tx_flow_low_watermark > 0) { |
tfyu | bdf453e | 2017-09-27 13:34:30 +0800 | [diff] [blame] | 206 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 19, 0)) |
| 207 | /* |
| 208 | * The TCP TX throttling logic is changed a little after |
| 209 | * 3.19-rc1 kernel, the TCP sending limit will be smaller, |
| 210 | * which will throttle the TCP packets to the host driver. |
| 211 | * The TCP UP LINK throughput will drop heavily. In order to |
| 212 | * fix this issue, need to orphan the socket buffer asap, which |
| 213 | * will call skb's destructor to notify the TCP stack that the |
| 214 | * SKB buffer is unowned. And then the TCP stack will pump more |
| 215 | * packets to host driver. |
| 216 | * |
| 217 | * The TX packets might be dropped for UDP case in the iperf |
| 218 | * testing. So need to be protected by follow control. |
| 219 | */ |
| 220 | need_orphan = 1; |
| 221 | #else |
| 222 | if (hdd_ctx->config->tx_orphan_enable) |
| 223 | need_orphan = 1; |
| 224 | #endif |
tfyu | 5f01db2 | 2017-10-11 13:51:04 +0800 | [diff] [blame] | 225 | } else if (hdd_ctx->config->tx_orphan_enable) { |
| 226 | if (qdf_nbuf_is_ipv4_tcp_pkt(skb) || |
Tiger Yu | 438c648 | 2017-10-13 11:07:00 +0800 | [diff] [blame] | 227 | qdf_nbuf_is_ipv6_tcp_pkt(skb)) |
tfyu | 5f01db2 | 2017-10-11 13:51:04 +0800 | [diff] [blame] | 228 | need_orphan = 1; |
tfyu | bdf453e | 2017-09-27 13:34:30 +0800 | [diff] [blame] | 229 | } |
| 230 | |
tfyu | 5f01db2 | 2017-10-11 13:51:04 +0800 | [diff] [blame] | 231 | if (need_orphan) { |
gbian | ec670c59 | 2016-11-24 11:21:30 +0800 | [diff] [blame] | 232 | skb_orphan(skb); |
Jeff Johnson | 6ced42c | 2017-10-20 12:48:11 -0700 | [diff] [blame] | 233 | ++adapter->hdd_stats.tx_rx_stats.tx_orphaned; |
Tiger Yu | 438c648 | 2017-10-13 11:07:00 +0800 | [diff] [blame] | 234 | } else |
gbian | ec670c59 | 2016-11-24 11:21:30 +0800 | [diff] [blame] | 235 | skb = skb_unshare(skb, GFP_ATOMIC); |
gbian | ec670c59 | 2016-11-24 11:21:30 +0800 | [diff] [blame] | 236 | |
| 237 | return skb; |
| 238 | } |
| 239 | |
| 240 | #else |
Mohit Khanna | d0b63f5 | 2017-02-18 18:05:52 -0800 | [diff] [blame] | 241 | /** |
| 242 | * hdd_skb_orphan() - skb_unshare a cloned packed else skb_orphan |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 243 | * @adapter: pointer to HDD adapter |
Mohit Khanna | d0b63f5 | 2017-02-18 18:05:52 -0800 | [diff] [blame] | 244 | * @skb: pointer to skb data packet |
| 245 | * |
| 246 | * Return: pointer to skb structure |
| 247 | */ |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 248 | static inline struct sk_buff *hdd_skb_orphan(struct hdd_adapter *adapter, |
Mohit Khanna | d0b63f5 | 2017-02-18 18:05:52 -0800 | [diff] [blame] | 249 | struct sk_buff *skb) { |
gbian | ec670c59 | 2016-11-24 11:21:30 +0800 | [diff] [blame] | 250 | |
Mohit Khanna | d0b63f5 | 2017-02-18 18:05:52 -0800 | [diff] [blame] | 251 | struct sk_buff *nskb; |
tfyu | bdf453e | 2017-09-27 13:34:30 +0800 | [diff] [blame] | 252 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 19, 0)) |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 253 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
tfyu | bdf453e | 2017-09-27 13:34:30 +0800 | [diff] [blame] | 254 | #endif |
Mohit Khanna | d0b63f5 | 2017-02-18 18:05:52 -0800 | [diff] [blame] | 255 | |
Mohit Khanna | 8749373 | 2017-08-27 23:26:44 -0700 | [diff] [blame] | 256 | hdd_skb_fill_gso_size(adapter->dev, skb); |
| 257 | |
Manjunathappa Prakash | dab74fa | 2017-06-19 12:11:03 -0700 | [diff] [blame] | 258 | nskb = skb_unshare(skb, GFP_ATOMIC); |
tfyu | bdf453e | 2017-09-27 13:34:30 +0800 | [diff] [blame] | 259 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 19, 0)) |
Manjunathappa Prakash | dab74fa | 2017-06-19 12:11:03 -0700 | [diff] [blame] | 260 | if (unlikely(hdd_ctx->config->tx_orphan_enable) && (nskb == skb)) { |
Mohit Khanna | d0b63f5 | 2017-02-18 18:05:52 -0800 | [diff] [blame] | 261 | /* |
| 262 | * For UDP packets we want to orphan the packet to allow the app |
| 263 | * to send more packets. The flow would ultimately be controlled |
| 264 | * by the limited number of tx descriptors for the vdev. |
| 265 | */ |
Jeff Johnson | 6ced42c | 2017-10-20 12:48:11 -0700 | [diff] [blame] | 266 | ++adapter->hdd_stats.tx_rx_stats.tx_orphaned; |
Mohit Khanna | d0b63f5 | 2017-02-18 18:05:52 -0800 | [diff] [blame] | 267 | skb_orphan(skb); |
| 268 | } |
tfyu | bdf453e | 2017-09-27 13:34:30 +0800 | [diff] [blame] | 269 | #endif |
Mohit Khanna | d0b63f5 | 2017-02-18 18:05:52 -0800 | [diff] [blame] | 270 | return nskb; |
gbian | ec670c59 | 2016-11-24 11:21:30 +0800 | [diff] [blame] | 271 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 272 | #endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */ |
| 273 | |
| 274 | /** |
Yun Park | c3e3556 | 2018-03-08 12:05:52 -0800 | [diff] [blame] | 275 | * hdd_post_dhcp_ind() - Send DHCP START/STOP indication to FW |
| 276 | * @adapter: pointer to hdd adapter |
| 277 | * @sta_id: peer station ID |
| 278 | * @type: WMA message type |
| 279 | * |
| 280 | * Return: error number |
| 281 | */ |
| 282 | int hdd_post_dhcp_ind(struct hdd_adapter *adapter, |
| 283 | uint8_t sta_id, uint16_t type) |
| 284 | { |
| 285 | tAniDHCPInd pmsg; |
| 286 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
| 287 | |
| 288 | hdd_debug("Post DHCP indication,sta_id=%d, type=%d", sta_id, type); |
| 289 | |
| 290 | if (!adapter) { |
| 291 | hdd_err("NULL adapter"); |
| 292 | return -EINVAL; |
| 293 | } |
| 294 | |
| 295 | pmsg.msgType = type; |
| 296 | pmsg.msgLen = (uint16_t) sizeof(tAniDHCPInd); |
| 297 | pmsg.device_mode = adapter->device_mode; |
| 298 | qdf_mem_copy(pmsg.adapterMacAddr.bytes, |
| 299 | adapter->mac_addr.bytes, |
| 300 | QDF_MAC_ADDR_SIZE); |
| 301 | qdf_mem_copy(pmsg.peerMacAddr.bytes, |
| 302 | adapter->sta_info[sta_id].sta_mac.bytes, |
| 303 | QDF_MAC_ADDR_SIZE); |
| 304 | |
| 305 | status = wma_process_dhcp_ind(cds_get_context(QDF_MODULE_ID_WMA), |
| 306 | &pmsg); |
| 307 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 308 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR, |
| 309 | "%s: Post DHCP Ind MSG fail", __func__); |
| 310 | return -EFAULT; |
| 311 | } |
| 312 | |
| 313 | return 0; |
| 314 | } |
| 315 | |
| 316 | /** |
| 317 | * hdd_inspect_dhcp_packet() - Inspect DHCP packet |
| 318 | * @adapter: pointer to hdd adapter |
| 319 | * @sta_id: peer station ID |
| 320 | * @skb: pointer to OS packet (sk_buff) |
| 321 | * @dir: direction |
| 322 | * |
| 323 | * Inspect the Tx/Rx frame, and send DHCP START/STOP notification to the FW |
| 324 | * through WMI message, during DHCP based IP address acquisition phase. |
| 325 | * |
| 326 | * - Send DHCP_START notification to FW when SAP gets DHCP Discovery |
| 327 | * - Send DHCP_STOP notification to FW when SAP sends DHCP ACK/NAK |
| 328 | * |
| 329 | * DHCP subtypes are determined by a status octet in the DHCP Message type |
| 330 | * option (option code 53 (0x35)). |
| 331 | * |
| 332 | * Each peer will be in one of 4 DHCP phases, starts from QDF_DHCP_PHASE_ACK, |
| 333 | * and transitioned per DHCP message type as it arrives. |
| 334 | * |
| 335 | * - QDF_DHCP_PHASE_DISCOVER: upon receiving DHCP_DISCOVER message in ACK phase |
| 336 | * - QDF_DHCP_PHASE_OFFER: upon receiving DHCP_OFFER message in DISCOVER phase |
| 337 | * - QDF_DHCP_PHASE_REQUEST: upon receiving DHCP_REQUEST message in OFFER phase |
| 338 | * or ACK phase (Renewal process) |
| 339 | * - QDF_DHCP_PHASE_ACK : upon receiving DHCP_ACK/NAK message in REQUEST phase |
| 340 | * or DHCP_DELINE message in OFFER phase |
| 341 | * |
| 342 | * Return: error number |
| 343 | */ |
| 344 | int hdd_inspect_dhcp_packet(struct hdd_adapter *adapter, |
| 345 | uint8_t sta_id, |
| 346 | struct sk_buff *skb, |
| 347 | enum qdf_proto_dir dir) |
| 348 | { |
| 349 | enum qdf_proto_subtype subtype = QDF_PROTO_INVALID; |
| 350 | struct hdd_station_info *hdd_sta_info; |
| 351 | int errno = 0; |
| 352 | |
| 353 | hdd_debug("sta_id=%d, dir=%d", sta_id, dir); |
| 354 | |
| 355 | if ((adapter->device_mode == QDF_SAP_MODE) && |
| 356 | ((dir == QDF_TX && QDF_NBUF_CB_PACKET_TYPE_DHCP == |
| 357 | QDF_NBUF_CB_GET_PACKET_TYPE(skb)) || |
| 358 | (dir == QDF_RX && qdf_nbuf_is_ipv4_dhcp_pkt(skb) == true))) { |
| 359 | |
| 360 | subtype = qdf_nbuf_get_dhcp_subtype(skb); |
| 361 | hdd_sta_info = &adapter->sta_info[sta_id]; |
| 362 | |
| 363 | hdd_debug("ENTER: type=%d, phase=%d, nego_status=%d", |
| 364 | subtype, |
| 365 | hdd_sta_info->dhcp_phase, |
| 366 | hdd_sta_info->dhcp_nego_status); |
| 367 | |
| 368 | switch (subtype) { |
| 369 | case QDF_PROTO_DHCP_DISCOVER: |
| 370 | if (dir != QDF_RX) |
| 371 | break; |
| 372 | if (hdd_sta_info->dhcp_nego_status == DHCP_NEGO_STOP) |
| 373 | errno = hdd_post_dhcp_ind(adapter, sta_id, |
| 374 | WMA_DHCP_START_IND); |
| 375 | hdd_sta_info->dhcp_phase = DHCP_PHASE_DISCOVER; |
| 376 | hdd_sta_info->dhcp_nego_status = DHCP_NEGO_IN_PROGRESS; |
| 377 | break; |
| 378 | case QDF_PROTO_DHCP_OFFER: |
| 379 | hdd_sta_info->dhcp_phase = DHCP_PHASE_OFFER; |
| 380 | break; |
| 381 | case QDF_PROTO_DHCP_REQUEST: |
| 382 | if (dir != QDF_RX) |
| 383 | break; |
| 384 | if (hdd_sta_info->dhcp_nego_status == DHCP_NEGO_STOP) |
| 385 | errno = hdd_post_dhcp_ind(adapter, sta_id, |
| 386 | WMA_DHCP_START_IND); |
| 387 | hdd_sta_info->dhcp_nego_status = DHCP_NEGO_IN_PROGRESS; |
| 388 | case QDF_PROTO_DHCP_DECLINE: |
| 389 | if (dir == QDF_RX) |
| 390 | hdd_sta_info->dhcp_phase = DHCP_PHASE_REQUEST; |
| 391 | break; |
| 392 | case QDF_PROTO_DHCP_ACK: |
| 393 | case QDF_PROTO_DHCP_NACK: |
| 394 | hdd_sta_info->dhcp_phase = DHCP_PHASE_ACK; |
Yun Park | 0ac1282 | 2018-04-02 11:18:04 -0700 | [diff] [blame] | 395 | if (hdd_sta_info->dhcp_nego_status == |
| 396 | DHCP_NEGO_IN_PROGRESS) |
Yun Park | c3e3556 | 2018-03-08 12:05:52 -0800 | [diff] [blame] | 397 | errno = hdd_post_dhcp_ind(adapter, sta_id, |
| 398 | WMA_DHCP_STOP_IND); |
| 399 | hdd_sta_info->dhcp_nego_status = DHCP_NEGO_STOP; |
| 400 | break; |
| 401 | default: |
| 402 | break; |
| 403 | } |
| 404 | |
| 405 | hdd_debug("EXIT: phase=%d, nego_status=%d", |
| 406 | hdd_sta_info->dhcp_phase, |
| 407 | hdd_sta_info->dhcp_nego_status); |
| 408 | } |
| 409 | |
| 410 | return errno; |
| 411 | } |
| 412 | |
| 413 | /** |
Mukul Sharma | c4de4ef | 2016-09-12 15:39:00 +0530 | [diff] [blame] | 414 | * __hdd_softap_hard_start_xmit() - Transmit a frame |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 415 | * @skb: pointer to OS packet (sk_buff) |
| 416 | * @dev: pointer to network device |
| 417 | * |
| 418 | * Function registered with the Linux OS for transmitting |
| 419 | * packets. This version of the function directly passes |
| 420 | * the packet to Transport Layer. |
Poddar, Siddarth | 31b9b8b | 2017-04-07 12:04:55 +0530 | [diff] [blame] | 421 | * In case of any packet drop or error, log the error with |
| 422 | * INFO HIGH/LOW/MEDIUM to avoid excessive logging in kmsg. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 423 | * |
| 424 | * Return: Always returns NETDEV_TX_OK |
| 425 | */ |
Srinivas Girigowda | 49b48b2 | 2018-04-05 09:23:28 -0700 | [diff] [blame] | 426 | static netdev_tx_t __hdd_softap_hard_start_xmit(struct sk_buff *skb, |
| 427 | struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 428 | { |
| 429 | sme_ac_enum_type ac = SME_AC_BE; |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 430 | struct hdd_adapter *adapter = (struct hdd_adapter *) netdev_priv(dev); |
Jeff Johnson | 9bf2497 | 2017-10-04 09:26:58 -0700 | [diff] [blame] | 431 | struct hdd_ap_ctx *ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 432 | struct qdf_mac_addr *pDestMacAddress; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 433 | uint8_t STAId; |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 434 | uint32_t num_seg; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 435 | |
Jeff Johnson | 6ced42c | 2017-10-20 12:48:11 -0700 | [diff] [blame] | 436 | ++adapter->hdd_stats.tx_rx_stats.tx_called; |
| 437 | adapter->hdd_stats.tx_rx_stats.cont_txtimeout_cnt = 0; |
Sravan Kumar Kairam | 3a69831 | 2017-10-16 14:16:16 +0530 | [diff] [blame] | 438 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 439 | /* Prevent this function from being called during SSR since TL |
| 440 | * context may not be reinitialized at this time which may |
| 441 | * lead to a crash. |
| 442 | */ |
Will Huang | 20de943 | 2018-02-06 17:01:03 +0800 | [diff] [blame] | 443 | if (cds_is_driver_recovering() || cds_is_driver_in_bad_state() || |
| 444 | cds_is_load_or_unload_in_progress()) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 445 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO_HIGH, |
Will Huang | 20de943 | 2018-02-06 17:01:03 +0800 | [diff] [blame] | 446 | "%s: Recovery/(Un)load in Progress. Ignore!!!", |
| 447 | __func__); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 448 | goto drop_pkt; |
| 449 | } |
| 450 | |
| 451 | /* |
| 452 | * If the device is operating on a DFS Channel |
| 453 | * then check if SAP is in CAC WAIT state and |
| 454 | * drop the packets. In CAC WAIT state device |
| 455 | * is expected not to transmit any frames. |
| 456 | * SAP starts Tx only after the BSS START is |
| 457 | * done. |
| 458 | */ |
Jeff Johnson | 9bf2497 | 2017-10-04 09:26:58 -0700 | [diff] [blame] | 459 | if (ap_ctx->dfs_cac_block_tx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 460 | goto drop_pkt; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 461 | |
Dhanashri Atre | 168d2b4 | 2016-02-22 14:43:06 -0800 | [diff] [blame] | 462 | /* |
Jeff Johnson | 4fca3b5 | 2017-01-12 08:44:18 -0800 | [diff] [blame] | 463 | * If a transmit function is not registered, drop packet |
| 464 | */ |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 465 | if (!adapter->tx_fn) { |
Dhanashri Atre | 168d2b4 | 2016-02-22 14:43:06 -0800 | [diff] [blame] | 466 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO_HIGH, |
| 467 | "%s: TX function not registered by the data path", |
| 468 | __func__); |
| 469 | goto drop_pkt; |
| 470 | } |
| 471 | |
Nirav Shah | 5e74bb8 | 2016-07-20 16:01:27 +0530 | [diff] [blame] | 472 | wlan_hdd_classify_pkt(skb); |
| 473 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 474 | pDestMacAddress = (struct qdf_mac_addr *) skb->data; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 475 | |
Nirav Shah | 5e74bb8 | 2016-07-20 16:01:27 +0530 | [diff] [blame] | 476 | if (QDF_NBUF_CB_GET_IS_BCAST(skb) || |
| 477 | QDF_NBUF_CB_GET_IS_MCAST(skb)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 478 | /* The BC/MC station ID is assigned during BSS |
| 479 | * starting phase. SAP will return the station ID |
| 480 | * used for BC/MC traffic. |
| 481 | */ |
Jeff Johnson | 42518cf | 2017-10-26 13:33:29 -0700 | [diff] [blame] | 482 | STAId = ap_ctx->broadcast_sta_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 483 | } else { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 484 | if (QDF_STATUS_SUCCESS != |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 485 | hdd_softap_get_sta_id(adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 486 | pDestMacAddress, &STAId)) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 487 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, |
Poddar, Siddarth | 31b9b8b | 2017-04-07 12:04:55 +0530 | [diff] [blame] | 488 | QDF_TRACE_LEVEL_INFO_HIGH, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 489 | "%s: Failed to find right station", __func__); |
| 490 | goto drop_pkt; |
| 491 | } |
| 492 | |
Prakash Dhavali | 3107b75 | 2016-11-28 14:35:06 +0530 | [diff] [blame] | 493 | if (STAId >= WLAN_MAX_STA_COUNT) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 494 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, |
Poddar, Siddarth | 31b9b8b | 2017-04-07 12:04:55 +0530 | [diff] [blame] | 495 | QDF_TRACE_LEVEL_INFO_HIGH, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 496 | "%s: Failed to find right station", __func__); |
| 497 | goto drop_pkt; |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 498 | } else if (false == adapter->sta_info[STAId].in_use) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 499 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, |
Poddar, Siddarth | 31b9b8b | 2017-04-07 12:04:55 +0530 | [diff] [blame] | 500 | QDF_TRACE_LEVEL_INFO_HIGH, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 501 | "%s: STA %d is unregistered", __func__, |
| 502 | STAId); |
| 503 | goto drop_pkt; |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 504 | } else if (true == adapter->sta_info[STAId]. |
Jeff Johnson | e4f5d93 | 2017-10-21 13:21:15 -0700 | [diff] [blame] | 505 | is_deauth_in_progress) { |
Poddar, Siddarth | a507546 | 2017-03-16 19:20:09 +0530 | [diff] [blame] | 506 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, |
Poddar, Siddarth | 31b9b8b | 2017-04-07 12:04:55 +0530 | [diff] [blame] | 507 | QDF_TRACE_LEVEL_INFO_HIGH, |
Poddar, Siddarth | a507546 | 2017-03-16 19:20:09 +0530 | [diff] [blame] | 508 | "%s: STA %d deauth in progress", __func__, |
| 509 | STAId); |
| 510 | goto drop_pkt; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 511 | } |
| 512 | |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 513 | if ((OL_TXRX_PEER_STATE_CONN != |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 514 | adapter->sta_info[STAId].peer_state) |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 515 | && (OL_TXRX_PEER_STATE_AUTH != |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 516 | adapter->sta_info[STAId].peer_state)) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 517 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, |
Poddar, Siddarth | 31b9b8b | 2017-04-07 12:04:55 +0530 | [diff] [blame] | 518 | QDF_TRACE_LEVEL_INFO_HIGH, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 519 | "%s: Station not connected yet", __func__); |
| 520 | goto drop_pkt; |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 521 | } else if (OL_TXRX_PEER_STATE_CONN == |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 522 | adapter->sta_info[STAId].peer_state) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 523 | if (ntohs(skb->protocol) != HDD_ETHERTYPE_802_1_X) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 524 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, |
Poddar, Siddarth | 31b9b8b | 2017-04-07 12:04:55 +0530 | [diff] [blame] | 525 | QDF_TRACE_LEVEL_INFO_HIGH, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 526 | "%s: NON-EAPOL packet in non-Authenticated state", |
| 527 | __func__); |
| 528 | goto drop_pkt; |
| 529 | } |
| 530 | } |
| 531 | } |
| 532 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 533 | hdd_get_tx_resource(adapter, STAId, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 534 | WLAN_SAP_HDD_TX_FLOW_CONTROL_OS_Q_BLOCK_TIME); |
| 535 | |
| 536 | /* Get TL AC corresponding to Qdisc queue index/AC. */ |
| 537 | ac = hdd_qdisc_ac_to_tl_ac[skb->queue_mapping]; |
Jeff Johnson | 6ced42c | 2017-10-20 12:48:11 -0700 | [diff] [blame] | 538 | ++adapter->hdd_stats.tx_rx_stats.tx_classified_ac[ac]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 539 | |
Srinivas Girigowda | e806a82 | 2017-03-25 11:25:30 -0700 | [diff] [blame] | 540 | #if defined(IPA_OFFLOAD) |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 541 | if (!qdf_nbuf_ipa_owned_get(skb)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 542 | #endif |
gbian | ec670c59 | 2016-11-24 11:21:30 +0800 | [diff] [blame] | 543 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 544 | skb = hdd_skb_orphan(adapter, skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 545 | if (!skb) |
Jeff Johnson | edeff23 | 2015-11-11 17:19:42 -0800 | [diff] [blame] | 546 | goto drop_pkt_accounting; |
gbian | ec670c59 | 2016-11-24 11:21:30 +0800 | [diff] [blame] | 547 | |
Srinivas Girigowda | e806a82 | 2017-03-25 11:25:30 -0700 | [diff] [blame] | 548 | #if defined(IPA_OFFLOAD) |
Yun Park | 01deb2c | 2017-06-14 15:21:44 -0700 | [diff] [blame] | 549 | } else { |
| 550 | /* |
| 551 | * Clear the IPA ownership after check it to avoid ipa_free_skb |
| 552 | * is called when Tx completed for intra-BSS Tx packets |
| 553 | */ |
| 554 | qdf_nbuf_ipa_owned_clear(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 555 | } |
| 556 | #endif |
| 557 | |
Himanshu Agarwal | 53298d1 | 2017-02-20 19:14:17 +0530 | [diff] [blame] | 558 | /* |
| 559 | * Add SKB to internal tracking table before further processing |
| 560 | * in WLAN driver. |
| 561 | */ |
| 562 | qdf_net_buf_debug_acquire_skb(skb, __FILE__, __LINE__); |
| 563 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 564 | adapter->stats.tx_bytes += skb->len; |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 565 | adapter->sta_info[STAId].tx_bytes += skb->len; |
Mohit Khanna | b1dd1e8 | 2017-02-04 15:14:38 -0800 | [diff] [blame] | 566 | |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 567 | if (qdf_nbuf_is_tso(skb)) { |
| 568 | num_seg = qdf_nbuf_get_tso_num_seg(skb); |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 569 | adapter->stats.tx_packets += num_seg; |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 570 | adapter->sta_info[STAId].tx_packets += num_seg; |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 571 | } else { |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 572 | ++adapter->stats.tx_packets; |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 573 | adapter->sta_info[STAId].tx_packets++; |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 574 | } |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 575 | adapter->sta_info[STAId].last_tx_rx_ts = qdf_system_ticks(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 576 | |
Yun Park | c3e3556 | 2018-03-08 12:05:52 -0800 | [diff] [blame] | 577 | if (STAId != ap_ctx->broadcast_sta_id) |
| 578 | hdd_inspect_dhcp_packet(adapter, STAId, skb, QDF_TX); |
| 579 | |
Nirav Shah | 5e74bb8 | 2016-07-20 16:01:27 +0530 | [diff] [blame] | 580 | hdd_event_eapol_log(skb, QDF_TX); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 581 | qdf_dp_trace_log_pkt(adapter->session_id, skb, QDF_TX, |
Venkata Sharath Chandra Manchala | 0b9fc63 | 2017-05-15 14:35:15 -0700 | [diff] [blame] | 582 | QDF_TRACE_DEFAULT_PDEV_ID); |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 583 | QDF_NBUF_CB_TX_PACKET_TRACK(skb) = QDF_NBUF_TX_PKT_DATA_TRACK; |
| 584 | QDF_NBUF_UPDATE_TX_PKT_COUNT(skb, QDF_NBUF_TX_PKT_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 585 | |
Nirav Shah | 0d58a7e | 2016-04-26 22:54:12 +0530 | [diff] [blame] | 586 | qdf_dp_trace_set_track(skb, QDF_TX); |
| 587 | DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_HDD_TX_PACKET_PTR_RECORD, |
Venkata Sharath Chandra Manchala | 0b9fc63 | 2017-05-15 14:35:15 -0700 | [diff] [blame] | 588 | QDF_TRACE_DEFAULT_PDEV_ID, qdf_nbuf_data_addr(skb), |
| 589 | sizeof(qdf_nbuf_data(skb)), |
Himanshu Agarwal | ee3411a | 2017-01-31 12:56:47 +0530 | [diff] [blame] | 590 | QDF_TX)); |
Nirav Shah | 0d58a7e | 2016-04-26 22:54:12 +0530 | [diff] [blame] | 591 | DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_HDD_TX_PACKET_RECORD, |
Venkata Sharath Chandra Manchala | 0b9fc63 | 2017-05-15 14:35:15 -0700 | [diff] [blame] | 592 | QDF_TRACE_DEFAULT_PDEV_ID, (uint8_t *)skb->data, |
| 593 | qdf_nbuf_len(skb), QDF_TX)); |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 594 | if (qdf_nbuf_len(skb) > QDF_DP_TRACE_RECORD_SIZE) |
Nirav Shah | 0d58a7e | 2016-04-26 22:54:12 +0530 | [diff] [blame] | 595 | DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_HDD_TX_PACKET_RECORD, |
Venkata Sharath Chandra Manchala | 0b9fc63 | 2017-05-15 14:35:15 -0700 | [diff] [blame] | 596 | QDF_TRACE_DEFAULT_PDEV_ID, |
Nirav Shah | 0d58a7e | 2016-04-26 22:54:12 +0530 | [diff] [blame] | 597 | (uint8_t *)&skb->data[QDF_DP_TRACE_RECORD_SIZE], |
| 598 | (qdf_nbuf_len(skb)-QDF_DP_TRACE_RECORD_SIZE), QDF_TX)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 599 | |
jinweic chen | 5104601 | 2018-04-11 16:02:22 +0800 | [diff] [blame^] | 600 | /* check whether need to linearize skb, like non-linear udp data */ |
| 601 | if (hdd_skb_nontso_linearize(skb) != QDF_STATUS_SUCCESS) { |
| 602 | QDF_TRACE(QDF_MODULE_ID_HDD_DATA, |
| 603 | QDF_TRACE_LEVEL_INFO_HIGH, |
| 604 | "%s: skb %pK linearize failed. drop the pkt", |
| 605 | __func__, skb); |
| 606 | ++adapter->hdd_stats.tx_rx_stats.tx_dropped_ac[ac]; |
| 607 | goto drop_pkt_and_release_skb; |
| 608 | } |
| 609 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 610 | if (adapter->tx_fn(adapter->txrx_vdev, |
Dhanashri Atre | 168d2b4 | 2016-02-22 14:43:06 -0800 | [diff] [blame] | 611 | (qdf_nbuf_t) skb) != NULL) { |
Poddar, Siddarth | 31b9b8b | 2017-04-07 12:04:55 +0530 | [diff] [blame] | 612 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO_HIGH, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 613 | "%s: Failed to send packet to txrx for staid:%d", |
| 614 | __func__, STAId); |
Jeff Johnson | 6ced42c | 2017-10-20 12:48:11 -0700 | [diff] [blame] | 615 | ++adapter->hdd_stats.tx_rx_stats.tx_dropped_ac[ac]; |
Himanshu Agarwal | 53298d1 | 2017-02-20 19:14:17 +0530 | [diff] [blame] | 616 | goto drop_pkt_and_release_skb; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 617 | } |
Dustin Brown | e0024fa | 2016-10-14 16:29:21 -0700 | [diff] [blame] | 618 | netif_trans_update(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 619 | |
| 620 | return NETDEV_TX_OK; |
| 621 | |
Himanshu Agarwal | 53298d1 | 2017-02-20 19:14:17 +0530 | [diff] [blame] | 622 | drop_pkt_and_release_skb: |
| 623 | qdf_net_buf_debug_release_skb(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 624 | drop_pkt: |
| 625 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 626 | DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_DROP_PACKET_RECORD, |
Venkata Sharath Chandra Manchala | 0b9fc63 | 2017-05-15 14:35:15 -0700 | [diff] [blame] | 627 | QDF_TRACE_DEFAULT_PDEV_ID, (uint8_t *)skb->data, |
| 628 | qdf_nbuf_len(skb), QDF_TX)); |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 629 | if (qdf_nbuf_len(skb) > QDF_DP_TRACE_RECORD_SIZE) |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 630 | DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_DROP_PACKET_RECORD, |
Venkata Sharath Chandra Manchala | 0b9fc63 | 2017-05-15 14:35:15 -0700 | [diff] [blame] | 631 | QDF_TRACE_DEFAULT_PDEV_ID, |
Nirav Shah | 0d58a7e | 2016-04-26 22:54:12 +0530 | [diff] [blame] | 632 | (uint8_t *)&skb->data[QDF_DP_TRACE_RECORD_SIZE], |
| 633 | (qdf_nbuf_len(skb)-QDF_DP_TRACE_RECORD_SIZE), QDF_TX)); |
Jeff Johnson | edeff23 | 2015-11-11 17:19:42 -0800 | [diff] [blame] | 634 | kfree_skb(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 635 | |
Jeff Johnson | edeff23 | 2015-11-11 17:19:42 -0800 | [diff] [blame] | 636 | drop_pkt_accounting: |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 637 | ++adapter->stats.tx_dropped; |
Jeff Johnson | 6ced42c | 2017-10-20 12:48:11 -0700 | [diff] [blame] | 638 | ++adapter->hdd_stats.tx_rx_stats.tx_dropped; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 639 | |
| 640 | return NETDEV_TX_OK; |
| 641 | } |
| 642 | |
| 643 | /** |
Mukul Sharma | c4de4ef | 2016-09-12 15:39:00 +0530 | [diff] [blame] | 644 | * hdd_softap_hard_start_xmit() - Wrapper function to protect |
| 645 | * __hdd_softap_hard_start_xmit from SSR |
| 646 | * @skb: pointer to OS packet |
| 647 | * @dev: pointer to net_device structure |
| 648 | * |
| 649 | * Function called by OS if any packet needs to transmit. |
| 650 | * |
| 651 | * Return: Always returns NETDEV_TX_OK |
| 652 | */ |
Srinivas Girigowda | 49b48b2 | 2018-04-05 09:23:28 -0700 | [diff] [blame] | 653 | netdev_tx_t hdd_softap_hard_start_xmit(struct sk_buff *skb, |
| 654 | struct net_device *dev) |
Mukul Sharma | c4de4ef | 2016-09-12 15:39:00 +0530 | [diff] [blame] | 655 | { |
Srinivas Girigowda | 49b48b2 | 2018-04-05 09:23:28 -0700 | [diff] [blame] | 656 | netdev_tx_t ret; |
Mukul Sharma | c4de4ef | 2016-09-12 15:39:00 +0530 | [diff] [blame] | 657 | |
| 658 | cds_ssr_protect(__func__); |
| 659 | ret = __hdd_softap_hard_start_xmit(skb, dev); |
| 660 | cds_ssr_unprotect(__func__); |
| 661 | |
| 662 | return ret; |
| 663 | } |
| 664 | |
| 665 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 666 | * __hdd_softap_tx_timeout() - TX timeout handler |
| 667 | * @dev: pointer to network device |
| 668 | * |
| 669 | * This function is registered as a netdev ndo_tx_timeout method, and |
| 670 | * is invoked by the kernel if the driver takes too long to transmit a |
| 671 | * frame. |
| 672 | * |
| 673 | * Return: None |
| 674 | */ |
| 675 | static void __hdd_softap_tx_timeout(struct net_device *dev) |
| 676 | { |
Jeff Johnson | 18dd7e1 | 2017-08-29 14:22:28 -0700 | [diff] [blame] | 677 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | f772687 | 2017-08-28 11:38:31 -0700 | [diff] [blame] | 678 | struct hdd_context *hdd_ctx; |
Nirav Shah | 89223f7 | 2016-03-01 18:10:38 +0530 | [diff] [blame] | 679 | struct netdev_queue *txq; |
Sravan Kumar Kairam | 3a69831 | 2017-10-16 14:16:16 +0530 | [diff] [blame] | 680 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
Nirav Shah | 89223f7 | 2016-03-01 18:10:38 +0530 | [diff] [blame] | 681 | int i; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 682 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 683 | DPTRACE(qdf_dp_trace(NULL, QDF_DP_TRACE_HDD_SOFTAP_TX_TIMEOUT, |
Venkata Sharath Chandra Manchala | 0b9fc63 | 2017-05-15 14:35:15 -0700 | [diff] [blame] | 684 | QDF_TRACE_DEFAULT_PDEV_ID, |
| 685 | NULL, 0, QDF_TX)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 686 | /* Getting here implies we disabled the TX queues for too |
| 687 | * long. Queues are disabled either because of disassociation |
| 688 | * or low resource scenarios. In case of disassociation it is |
| 689 | * ok to ignore this. But if associated, we have do possible |
| 690 | * recovery here |
| 691 | */ |
| 692 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 693 | if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 694 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR, |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 695 | "%s: Recovery in Progress. Ignore!!!", __func__); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 696 | return; |
| 697 | } |
Nirav Shah | 89223f7 | 2016-03-01 18:10:38 +0530 | [diff] [blame] | 698 | |
Dustin Brown | e0024fa | 2016-10-14 16:29:21 -0700 | [diff] [blame] | 699 | TX_TIMEOUT_TRACE(dev, QDF_MODULE_ID_HDD_SAP_DATA); |
Nirav Shah | 89223f7 | 2016-03-01 18:10:38 +0530 | [diff] [blame] | 700 | |
| 701 | for (i = 0; i < NUM_TX_QUEUES; i++) { |
| 702 | txq = netdev_get_tx_queue(dev, i); |
| 703 | QDF_TRACE(QDF_MODULE_ID_HDD_DATA, |
Srinivas Girigowda | 028c448 | 2017-03-09 18:52:02 -0800 | [diff] [blame] | 704 | QDF_TRACE_LEVEL_DEBUG, |
| 705 | "Queue: %d status: %d txq->trans_start: %lu", |
Nirav Shah | 89223f7 | 2016-03-01 18:10:38 +0530 | [diff] [blame] | 706 | i, netif_tx_queue_stopped(txq), txq->trans_start); |
| 707 | } |
| 708 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 709 | wlan_hdd_display_netif_queue_history(hdd_ctx, |
| 710 | QDF_STATS_VERBOSITY_LEVEL_HIGH); |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 711 | cdp_dump_flow_pool_info(cds_get_context(QDF_MODULE_ID_SOC)); |
Srinivas Girigowda | 028c448 | 2017-03-09 18:52:02 -0800 | [diff] [blame] | 712 | QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_DEBUG, |
Nirav Shah | 89223f7 | 2016-03-01 18:10:38 +0530 | [diff] [blame] | 713 | "carrier state: %d", netif_carrier_ok(dev)); |
Sravan Kumar Kairam | 3a69831 | 2017-10-16 14:16:16 +0530 | [diff] [blame] | 714 | |
Jeff Johnson | 6ced42c | 2017-10-20 12:48:11 -0700 | [diff] [blame] | 715 | ++adapter->hdd_stats.tx_rx_stats.tx_timeout_cnt; |
| 716 | ++adapter->hdd_stats.tx_rx_stats.cont_txtimeout_cnt; |
Sravan Kumar Kairam | 3a69831 | 2017-10-16 14:16:16 +0530 | [diff] [blame] | 717 | |
Jeff Johnson | 6ced42c | 2017-10-20 12:48:11 -0700 | [diff] [blame] | 718 | if (adapter->hdd_stats.tx_rx_stats.cont_txtimeout_cnt > |
Sravan Kumar Kairam | 3a69831 | 2017-10-16 14:16:16 +0530 | [diff] [blame] | 719 | HDD_TX_STALL_THRESHOLD) { |
| 720 | QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_ERROR, |
| 721 | "Detected data stall due to continuous TX timeouts"); |
Jeff Johnson | 6ced42c | 2017-10-20 12:48:11 -0700 | [diff] [blame] | 722 | adapter->hdd_stats.tx_rx_stats.cont_txtimeout_cnt = 0; |
Poddar, Siddarth | 3703303 | 2017-10-11 15:47:40 +0530 | [diff] [blame] | 723 | if (hdd_ctx->config->enable_data_stall_det) |
| 724 | cdp_post_data_stall_event(soc, |
Sravan Kumar Kairam | 3a69831 | 2017-10-16 14:16:16 +0530 | [diff] [blame] | 725 | DATA_STALL_LOG_INDICATOR_HOST_DRIVER, |
| 726 | DATA_STALL_LOG_HOST_SOFTAP_TX_TIMEOUT, |
| 727 | 0xFF, 0xFF, |
| 728 | DATA_STALL_LOG_RECOVERY_TRIGGER_PDR); |
| 729 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 730 | } |
| 731 | |
| 732 | /** |
| 733 | * hdd_softap_tx_timeout() - SSR wrapper for __hdd_softap_tx_timeout |
| 734 | * @dev: pointer to net_device |
| 735 | * |
| 736 | * Return: none |
| 737 | */ |
| 738 | void hdd_softap_tx_timeout(struct net_device *dev) |
| 739 | { |
| 740 | cds_ssr_protect(__func__); |
| 741 | __hdd_softap_tx_timeout(dev); |
| 742 | cds_ssr_unprotect(__func__); |
| 743 | } |
| 744 | |
| 745 | /** |
| 746 | * @hdd_softap_init_tx_rx() - Initialize Tx/RX module |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 747 | * @adapter: pointer to adapter context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 748 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 749 | * Return: QDF_STATUS_E_FAILURE if any errors encountered, |
| 750 | * QDF_STATUS_SUCCESS otherwise |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 751 | */ |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 752 | QDF_STATUS hdd_softap_init_tx_rx(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 753 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 754 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 755 | |
| 756 | uint8_t STAId = 0; |
| 757 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 758 | qdf_mem_zero(&adapter->stats, sizeof(struct net_device_stats)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 759 | |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 760 | spin_lock_init(&adapter->sta_info_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 761 | |
| 762 | for (STAId = 0; STAId < WLAN_MAX_STA_COUNT; STAId++) { |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 763 | qdf_mem_zero(&adapter->sta_info[STAId], |
Jeff Johnson | 8215592 | 2017-09-30 16:54:14 -0700 | [diff] [blame] | 764 | sizeof(struct hdd_station_info)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 765 | } |
| 766 | |
| 767 | return status; |
| 768 | } |
| 769 | |
| 770 | /** |
| 771 | * @hdd_softap_deinit_tx_rx() - Deinitialize Tx/RX module |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 772 | * @adapter: pointer to adapter context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 773 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 774 | * Return: QDF_STATUS_E_FAILURE if any errors encountered, |
| 775 | * QDF_STATUS_SUCCESS otherwise |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 776 | */ |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 777 | QDF_STATUS hdd_softap_deinit_tx_rx(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 778 | { |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 779 | if (adapter == NULL) { |
| 780 | hdd_err("Called with adapter = NULL."); |
Dhanashri Atre | ed3bf51 | 2017-02-21 12:25:53 -0800 | [diff] [blame] | 781 | return QDF_STATUS_E_FAILURE; |
| 782 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 783 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 784 | adapter->txrx_vdev = NULL; |
| 785 | adapter->tx_fn = NULL; |
Dhanashri Atre | ed3bf51 | 2017-02-21 12:25:53 -0800 | [diff] [blame] | 786 | hdd_info("Deregistering TX function hook !"); |
| 787 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 788 | } |
| 789 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 790 | QDF_STATUS hdd_softap_init_tx_rx_sta(struct hdd_adapter *adapter, |
Jeff Johnson | 349d9a9 | 2017-10-21 15:38:03 -0700 | [diff] [blame] | 791 | uint8_t sta_id, |
| 792 | struct qdf_mac_addr *sta_mac) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 793 | { |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 794 | spin_lock_bh(&adapter->sta_info_lock); |
| 795 | if (adapter->sta_info[sta_id].in_use) { |
| 796 | spin_unlock_bh(&adapter->sta_info_lock); |
Jeff Johnson | 349d9a9 | 2017-10-21 15:38:03 -0700 | [diff] [blame] | 797 | hdd_err("Reinit of in use station %d", sta_id); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 798 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 799 | } |
| 800 | |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 801 | qdf_mem_zero(&adapter->sta_info[sta_id], |
Jeff Johnson | 8215592 | 2017-09-30 16:54:14 -0700 | [diff] [blame] | 802 | sizeof(struct hdd_station_info)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 803 | |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 804 | adapter->sta_info[sta_id].in_use = true; |
| 805 | adapter->sta_info[sta_id].is_deauth_in_progress = false; |
| 806 | qdf_copy_macaddr(&adapter->sta_info[sta_id].sta_mac, sta_mac); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 807 | |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 808 | spin_unlock_bh(&adapter->sta_info_lock); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 809 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 810 | } |
| 811 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 812 | QDF_STATUS hdd_softap_deinit_tx_rx_sta(struct hdd_adapter *adapter, |
Jeff Johnson | b157c72 | 2017-10-21 15:46:42 -0700 | [diff] [blame] | 813 | uint8_t sta_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 814 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 815 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Jeff Johnson | 5c19ade | 2017-10-04 09:52:12 -0700 | [diff] [blame] | 816 | struct hdd_hostapd_state *hostapd_state; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 817 | |
Jeff Johnson | 5c19ade | 2017-10-04 09:52:12 -0700 | [diff] [blame] | 818 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 819 | |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 820 | spin_lock_bh(&adapter->sta_info_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 821 | |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 822 | if (false == adapter->sta_info[sta_id].in_use) { |
| 823 | spin_unlock_bh(&adapter->sta_info_lock); |
Jeff Johnson | b157c72 | 2017-10-21 15:46:42 -0700 | [diff] [blame] | 824 | hdd_err("Deinit station not inited %d", sta_id); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 825 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 826 | } |
| 827 | |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 828 | adapter->sta_info[sta_id].in_use = false; |
| 829 | adapter->sta_info[sta_id].is_deauth_in_progress = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 830 | |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 831 | spin_unlock_bh(&adapter->sta_info_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 832 | return status; |
| 833 | } |
| 834 | |
| 835 | /** |
| 836 | * hdd_softap_rx_packet_cbk() - Receive packet handler |
Dhanashri Atre | 182b027 | 2016-02-17 15:35:07 -0800 | [diff] [blame] | 837 | * @context: pointer to HDD context |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 838 | * @rxBuf: pointer to rx qdf_nbuf |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 839 | * |
| 840 | * Receive callback registered with TL. TL will call this to notify |
| 841 | * the HDD when one or more packets were received for a registered |
| 842 | * STA. |
| 843 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 844 | * Return: QDF_STATUS_E_FAILURE if any errors encountered, |
| 845 | * QDF_STATUS_SUCCESS otherwise |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 846 | */ |
Dhanashri Atre | 182b027 | 2016-02-17 15:35:07 -0800 | [diff] [blame] | 847 | QDF_STATUS hdd_softap_rx_packet_cbk(void *context, qdf_nbuf_t rxBuf) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 848 | { |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 849 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 850 | int rxstat; |
| 851 | unsigned int cpu_index; |
| 852 | struct sk_buff *skb = NULL; |
Dhanashri Atre | cefa880 | 2017-02-02 16:17:14 -0800 | [diff] [blame] | 853 | struct sk_buff *next = NULL; |
Jeff Johnson | 9240287 | 2017-09-03 09:25:37 -0700 | [diff] [blame] | 854 | struct hdd_context *hdd_ctx = NULL; |
Yun Park | c3e3556 | 2018-03-08 12:05:52 -0800 | [diff] [blame] | 855 | struct qdf_mac_addr *src_mac; |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 856 | uint8_t staid; |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 857 | bool proto_pkt_logged = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 858 | |
| 859 | /* Sanity check on inputs */ |
Dhanashri Atre | 182b027 | 2016-02-17 15:35:07 -0800 | [diff] [blame] | 860 | if (unlikely((NULL == context) || (NULL == rxBuf))) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 861 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 862 | "%s: Null params being passed", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 863 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 864 | } |
| 865 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 866 | adapter = (struct hdd_adapter *)context; |
| 867 | if (unlikely(WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) { |
Srinivas Girigowda | 028c448 | 2017-03-09 18:52:02 -0800 | [diff] [blame] | 868 | QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_ERROR, |
Dhanashri Atre | 182b027 | 2016-02-17 15:35:07 -0800 | [diff] [blame] | 869 | "Magic cookie(%x) for adapter sanity verification is invalid", |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 870 | adapter->magic); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 871 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 872 | } |
| 873 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 874 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 9240287 | 2017-09-03 09:25:37 -0700 | [diff] [blame] | 875 | if (unlikely(NULL == hdd_ctx)) { |
Dhanashri Atre | 182b027 | 2016-02-17 15:35:07 -0800 | [diff] [blame] | 876 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR, |
| 877 | "%s: HDD context is Null", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 878 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 879 | } |
| 880 | |
| 881 | /* walk the chain until all are processed */ |
Dhanashri Atre | cefa880 | 2017-02-02 16:17:14 -0800 | [diff] [blame] | 882 | next = (struct sk_buff *)rxBuf; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 883 | |
Dhanashri Atre | cefa880 | 2017-02-02 16:17:14 -0800 | [diff] [blame] | 884 | while (next) { |
| 885 | skb = next; |
| 886 | next = skb->next; |
Dhanashri Atre | 63d9802 | 2017-01-24 18:22:09 -0800 | [diff] [blame] | 887 | skb->next = NULL; |
Dhanashri Atre | cefa880 | 2017-02-02 16:17:14 -0800 | [diff] [blame] | 888 | |
psimha | 884025c | 2017-08-01 15:07:32 -0700 | [diff] [blame] | 889 | #ifdef QCA_WIFI_QCA6290 /* Debug code, remove later */ |
Yun Park | e423980 | 2018-01-09 11:01:40 -0800 | [diff] [blame] | 890 | QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_DEBUG, |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 891 | "%s: skb %pK skb->len %d\n", __func__, skb, skb->len); |
Dhanashri Atre | cefa880 | 2017-02-02 16:17:14 -0800 | [diff] [blame] | 892 | #endif |
| 893 | |
Dhanashri Atre | 63d9802 | 2017-01-24 18:22:09 -0800 | [diff] [blame] | 894 | hdd_softap_dump_sk_buff(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 895 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 896 | skb->dev = adapter->dev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 897 | |
Dhanashri Atre | 63d9802 | 2017-01-24 18:22:09 -0800 | [diff] [blame] | 898 | if (unlikely(skb->dev == NULL)) { |
Yun Park | c3e3556 | 2018-03-08 12:05:52 -0800 | [diff] [blame] | 899 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, |
| 900 | QDF_TRACE_LEVEL_ERROR, |
Dhanashri Atre | 63d9802 | 2017-01-24 18:22:09 -0800 | [diff] [blame] | 901 | "%s: ERROR!!Invalid netdevice", __func__); |
Dhanashri Atre | cefa880 | 2017-02-02 16:17:14 -0800 | [diff] [blame] | 902 | continue; |
Dhanashri Atre | 63d9802 | 2017-01-24 18:22:09 -0800 | [diff] [blame] | 903 | } |
| 904 | cpu_index = wlan_hdd_get_cpu(); |
Jeff Johnson | 6ced42c | 2017-10-20 12:48:11 -0700 | [diff] [blame] | 905 | ++adapter->hdd_stats.tx_rx_stats.rx_packets[cpu_index]; |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 906 | ++adapter->stats.rx_packets; |
| 907 | adapter->stats.rx_bytes += skb->len; |
Dhanashri Atre | 63d9802 | 2017-01-24 18:22:09 -0800 | [diff] [blame] | 908 | |
Yun Park | c3e3556 | 2018-03-08 12:05:52 -0800 | [diff] [blame] | 909 | /* Send DHCP Indication to FW */ |
| 910 | src_mac = (struct qdf_mac_addr *)(skb->data + |
| 911 | QDF_NBUF_SRC_MAC_OFFSET); |
| 912 | if (QDF_STATUS_SUCCESS == |
| 913 | hdd_softap_get_sta_id(adapter, src_mac, &staid)) { |
| 914 | if (staid < WLAN_MAX_STA_COUNT) { |
| 915 | adapter->sta_info[staid].rx_packets++; |
| 916 | adapter->sta_info[staid].rx_bytes += skb->len; |
| 917 | adapter->sta_info[staid].last_tx_rx_ts = |
| 918 | qdf_system_ticks(); |
| 919 | } |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 920 | } |
Yun Park | c3e3556 | 2018-03-08 12:05:52 -0800 | [diff] [blame] | 921 | |
| 922 | hdd_inspect_dhcp_packet(adapter, staid, skb, QDF_RX); |
| 923 | |
Dhanashri Atre | 63d9802 | 2017-01-24 18:22:09 -0800 | [diff] [blame] | 924 | hdd_event_eapol_log(skb, QDF_RX); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 925 | proto_pkt_logged = qdf_dp_trace_log_pkt(adapter->session_id, |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 926 | skb, QDF_RX, |
| 927 | QDF_TRACE_DEFAULT_PDEV_ID); |
Himanshu Agarwal | ee3411a | 2017-01-31 12:56:47 +0530 | [diff] [blame] | 928 | DPTRACE(qdf_dp_trace(skb, |
Dhanashri Atre | 63d9802 | 2017-01-24 18:22:09 -0800 | [diff] [blame] | 929 | QDF_DP_TRACE_RX_HDD_PACKET_PTR_RECORD, |
Venkata Sharath Chandra Manchala | 0b9fc63 | 2017-05-15 14:35:15 -0700 | [diff] [blame] | 930 | QDF_TRACE_DEFAULT_PDEV_ID, |
Himanshu Agarwal | ee3411a | 2017-01-31 12:56:47 +0530 | [diff] [blame] | 931 | qdf_nbuf_data_addr(skb), |
| 932 | sizeof(qdf_nbuf_data(skb)), QDF_RX)); |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 933 | if (!proto_pkt_logged) { |
| 934 | DPTRACE(qdf_dp_trace(skb, |
| 935 | QDF_DP_TRACE_HDD_RX_PACKET_RECORD, |
Venkata Sharath Chandra Manchala | 0b9fc63 | 2017-05-15 14:35:15 -0700 | [diff] [blame] | 936 | QDF_TRACE_DEFAULT_PDEV_ID, |
| 937 | (uint8_t *)skb->data, qdf_nbuf_len(skb), |
| 938 | QDF_RX)); |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 939 | if (qdf_nbuf_len(skb) > QDF_DP_TRACE_RECORD_SIZE) |
| 940 | DPTRACE(qdf_dp_trace(skb, |
Himanshu Agarwal | ee3411a | 2017-01-31 12:56:47 +0530 | [diff] [blame] | 941 | QDF_DP_TRACE_HDD_RX_PACKET_RECORD, |
Venkata Sharath Chandra Manchala | 0b9fc63 | 2017-05-15 14:35:15 -0700 | [diff] [blame] | 942 | QDF_TRACE_DEFAULT_PDEV_ID, |
Himanshu Agarwal | ee3411a | 2017-01-31 12:56:47 +0530 | [diff] [blame] | 943 | (uint8_t *)&skb->data[QDF_DP_TRACE_RECORD_SIZE], |
| 944 | (qdf_nbuf_len(skb)-QDF_DP_TRACE_RECORD_SIZE), |
| 945 | QDF_RX)); |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 946 | } |
Dhanashri Atre | 63d9802 | 2017-01-24 18:22:09 -0800 | [diff] [blame] | 947 | |
| 948 | skb->protocol = eth_type_trans(skb, skb->dev); |
| 949 | |
| 950 | /* hold configurable wakelock for unicast traffic */ |
Jeff Johnson | 9240287 | 2017-09-03 09:25:37 -0700 | [diff] [blame] | 951 | if (hdd_ctx->config->rx_wakelock_timeout && |
Dhanashri Atre | 63d9802 | 2017-01-24 18:22:09 -0800 | [diff] [blame] | 952 | skb->pkt_type != PACKET_BROADCAST && |
| 953 | skb->pkt_type != PACKET_MULTICAST) { |
Jeff Johnson | 9240287 | 2017-09-03 09:25:37 -0700 | [diff] [blame] | 954 | cds_host_diag_log_work(&hdd_ctx->rx_wake_lock, |
| 955 | hdd_ctx->config->rx_wakelock_timeout, |
Dhanashri Atre | 63d9802 | 2017-01-24 18:22:09 -0800 | [diff] [blame] | 956 | WIFI_POWER_EVENT_WAKELOCK_HOLD_RX); |
Jeff Johnson | 9240287 | 2017-09-03 09:25:37 -0700 | [diff] [blame] | 957 | qdf_wake_lock_timeout_acquire(&hdd_ctx->rx_wake_lock, |
| 958 | hdd_ctx->config-> |
Dhanashri Atre | 63d9802 | 2017-01-24 18:22:09 -0800 | [diff] [blame] | 959 | rx_wakelock_timeout); |
| 960 | } |
| 961 | |
| 962 | /* Remove SKB from internal tracking table before submitting |
| 963 | * it to stack |
| 964 | */ |
Manjunathappa Prakash | 17c07bd | 2017-04-27 21:24:28 -0700 | [diff] [blame] | 965 | qdf_net_buf_debug_release_skb(skb); |
Dhanashri Atre | 63d9802 | 2017-01-24 18:22:09 -0800 | [diff] [blame] | 966 | if (hdd_napi_enabled(HDD_NAPI_ANY) && |
Jeff Johnson | e2ba3cd | 2017-10-30 20:02:09 -0700 | [diff] [blame] | 967 | !hdd_ctx->enable_rxthread) |
Dhanashri Atre | 63d9802 | 2017-01-24 18:22:09 -0800 | [diff] [blame] | 968 | rxstat = netif_receive_skb(skb); |
| 969 | else |
| 970 | rxstat = netif_rx_ni(skb); |
Srinivas Girigowda | e806a82 | 2017-03-25 11:25:30 -0700 | [diff] [blame] | 971 | if (NET_RX_SUCCESS == rxstat) |
Jeff Johnson | 6ced42c | 2017-10-20 12:48:11 -0700 | [diff] [blame] | 972 | ++adapter->hdd_stats.tx_rx_stats.rx_delivered[cpu_index]; |
Srinivas Girigowda | e806a82 | 2017-03-25 11:25:30 -0700 | [diff] [blame] | 973 | else |
Jeff Johnson | 6ced42c | 2017-10-20 12:48:11 -0700 | [diff] [blame] | 974 | ++adapter->hdd_stats.tx_rx_stats.rx_refused[cpu_index]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 975 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 976 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 977 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 978 | } |
| 979 | |
| 980 | /** |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 981 | * hdd_softap_deregister_sta(struct hdd_adapter *adapter, uint8_t staId) |
| 982 | * @adapter: pointer to adapter context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 983 | * @staId: Station ID to deregister |
| 984 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 985 | * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 986 | */ |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 987 | QDF_STATUS hdd_softap_deregister_sta(struct hdd_adapter *adapter, |
Jeff Johnson | 18dd7e1 | 2017-08-29 14:22:28 -0700 | [diff] [blame] | 988 | uint8_t staId) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 989 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 990 | QDF_STATUS qdf_status = QDF_STATUS_SUCCESS; |
Jeff Johnson | 9240287 | 2017-09-03 09:25:37 -0700 | [diff] [blame] | 991 | struct hdd_context *hdd_ctx; |
Abhishek Singh | 07c627e | 2017-03-20 17:56:34 +0530 | [diff] [blame] | 992 | int ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 993 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 994 | if (NULL == adapter) { |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame] | 995 | hdd_err("NULL adapter"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 996 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 997 | } |
| 998 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 999 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame] | 1000 | hdd_err("Invalid adapter magic"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1001 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1002 | } |
| 1003 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1004 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1005 | /* Clear station in TL and then update HDD data |
| 1006 | * structures. This helps to block RX frames from other |
| 1007 | * station to this station. |
| 1008 | */ |
Krishna Kumaar Natarajan | e58b409 | 2017-01-25 15:47:35 -0800 | [diff] [blame] | 1009 | qdf_status = cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC), |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 1010 | (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX), |
| 1011 | staId); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1012 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Krishna Kumaar Natarajan | e58b409 | 2017-01-25 15:47:35 -0800 | [diff] [blame] | 1013 | hdd_err("cdp_clear_peer failed for staID %d, Status=%d [0x%08X]", |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame] | 1014 | staId, qdf_status, qdf_status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1015 | } |
| 1016 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1017 | ret = hdd_objmgr_remove_peer_object(adapter->hdd_vdev, |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 1018 | adapter->sta_info[staId]. |
Jeff Johnson | f235651 | 2017-10-21 16:04:12 -0700 | [diff] [blame] | 1019 | sta_mac.bytes); |
Abhishek Singh | 07c627e | 2017-03-20 17:56:34 +0530 | [diff] [blame] | 1020 | if (ret) |
| 1021 | hdd_err("Peer obj %pM delete fails", |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 1022 | adapter->sta_info[staId].sta_mac.bytes); |
Abhishek Singh | 07c627e | 2017-03-20 17:56:34 +0530 | [diff] [blame] | 1023 | |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 1024 | if (adapter->sta_info[staId].in_use) { |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 1025 | if (ucfg_ipa_is_enabled()) { |
| 1026 | ucfg_ipa_wlan_evt(hdd_ctx->hdd_pdev, adapter->dev, |
| 1027 | adapter->device_mode, |
| 1028 | adapter->sta_info[staId].sta_id, |
| 1029 | adapter->session_id, |
| 1030 | WLAN_IPA_CLIENT_DISCONNECT, |
| 1031 | adapter->sta_info[staId].sta_mac. |
| 1032 | bytes); |
Will Huang | ac3fd9a | 2017-11-01 16:18:12 +0800 | [diff] [blame] | 1033 | } |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 1034 | spin_lock_bh(&adapter->sta_info_lock); |
| 1035 | qdf_mem_zero(&adapter->sta_info[staId], |
Jeff Johnson | 8215592 | 2017-09-30 16:54:14 -0700 | [diff] [blame] | 1036 | sizeof(struct hdd_station_info)); |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 1037 | spin_unlock_bh(&adapter->sta_info_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1038 | } |
Abhishek Singh | 07c627e | 2017-03-20 17:56:34 +0530 | [diff] [blame] | 1039 | |
Jeff Johnson | 9240287 | 2017-09-03 09:25:37 -0700 | [diff] [blame] | 1040 | hdd_ctx->sta_to_adapter[staId] = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1041 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1042 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1043 | } |
| 1044 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1045 | QDF_STATUS hdd_softap_register_sta(struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1046 | bool fAuthRequired, |
| 1047 | bool fPrivacyBit, |
| 1048 | uint8_t staId, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1049 | struct qdf_mac_addr *pPeerMacAddress, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1050 | bool fWmmEnabled) |
| 1051 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1052 | QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1053 | struct ol_txrx_desc_type staDesc = { 0 }; |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1054 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Dhanashri Atre | 182b027 | 2016-02-17 15:35:07 -0800 | [diff] [blame] | 1055 | struct ol_txrx_ops txrx_ops; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 1056 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
| 1057 | void *pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1058 | |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame] | 1059 | hdd_info("STA:%u, Auth:%u, Priv:%u, WMM:%u", |
| 1060 | staId, fAuthRequired, fPrivacyBit, fWmmEnabled); |
| 1061 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1062 | /* |
| 1063 | * Clean up old entry if it is not cleaned up properly |
| 1064 | */ |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 1065 | if (adapter->sta_info[staId].in_use) { |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame] | 1066 | hdd_info("clean up old entry for STA %d", staId); |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1067 | hdd_softap_deregister_sta(adapter, staId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1068 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1069 | |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame] | 1070 | /* Get the Station ID from the one saved during the assocation. */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1071 | staDesc.sta_id = staId; |
| 1072 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1073 | /* Save the adapter Pointer for this staId */ |
| 1074 | hdd_ctx->sta_to_adapter[staId] = adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1075 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1076 | qdf_status = |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1077 | hdd_softap_init_tx_rx_sta(adapter, staId, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1078 | pPeerMacAddress); |
| 1079 | |
| 1080 | staDesc.is_qos_enabled = fWmmEnabled; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1081 | |
Dhanashri Atre | 182b027 | 2016-02-17 15:35:07 -0800 | [diff] [blame] | 1082 | /* Register the vdev transmit and receive functions */ |
| 1083 | qdf_mem_zero(&txrx_ops, sizeof(txrx_ops)); |
| 1084 | txrx_ops.rx.rx = hdd_softap_rx_packet_cbk; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 1085 | cdp_vdev_register(soc, |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 1086 | (struct cdp_vdev *)cdp_get_vdev_from_vdev_id(soc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1087 | (struct cdp_pdev *)pdev, adapter->session_id), |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1088 | adapter, &txrx_ops); |
| 1089 | adapter->txrx_vdev = (void *)cdp_get_vdev_from_vdev_id(soc, |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 1090 | (struct cdp_pdev *)pdev, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1091 | adapter->session_id); |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1092 | adapter->tx_fn = txrx_ops.tx.tx; |
Dhanashri Atre | 182b027 | 2016-02-17 15:35:07 -0800 | [diff] [blame] | 1093 | |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 1094 | qdf_status = cdp_peer_register(soc, |
| 1095 | (struct cdp_pdev *)pdev, &staDesc); |
Dhanashri Atre | 50141c5 | 2016-04-07 13:15:29 -0700 | [diff] [blame] | 1096 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame] | 1097 | hdd_err("cdp_peer_register() failed to register. Status = %d [0x%08X]", |
| 1098 | qdf_status, qdf_status); |
Dhanashri Atre | 50141c5 | 2016-04-07 13:15:29 -0700 | [diff] [blame] | 1099 | return qdf_status; |
| 1100 | } |
| 1101 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1102 | /* if ( WPA ), tell TL to go to 'connected' and after keys come to the |
| 1103 | * driver then go to 'authenticated'. For all other authentication |
| 1104 | * types (those that do not require upper layer authentication) we can |
| 1105 | * put TL directly into 'authenticated' state |
| 1106 | */ |
| 1107 | |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 1108 | adapter->sta_info[staId].sta_id = staId; |
| 1109 | adapter->sta_info[staId].is_qos_enabled = fWmmEnabled; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1110 | |
| 1111 | if (!fAuthRequired) { |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame] | 1112 | hdd_info("open/shared auth StaId= %d. Changing TL state to AUTHENTICATED at Join time", |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 1113 | adapter->sta_info[staId].sta_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1114 | |
| 1115 | /* Connections that do not need Upper layer auth, |
| 1116 | * transition TL directly to 'Authenticated' state. |
| 1117 | */ |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1118 | qdf_status = hdd_change_peer_state(adapter, staDesc.sta_id, |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 1119 | OL_TXRX_PEER_STATE_AUTH, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1120 | |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 1121 | adapter->sta_info[staId].peer_state = OL_TXRX_PEER_STATE_AUTH; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1122 | } else { |
| 1123 | |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame] | 1124 | hdd_info("ULA auth StaId= %d. Changing TL state to CONNECTED at Join time", |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 1125 | adapter->sta_info[staId].sta_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1126 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1127 | qdf_status = hdd_change_peer_state(adapter, staDesc.sta_id, |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 1128 | OL_TXRX_PEER_STATE_CONN, false); |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 1129 | adapter->sta_info[staId].peer_state = OL_TXRX_PEER_STATE_CONN; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1130 | } |
| 1131 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 1132 | hdd_debug("Enabling queues"); |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1133 | wlan_hdd_netif_queue_control(adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1134 | WLAN_START_ALL_NETIF_QUEUE_N_CARRIER, |
| 1135 | WLAN_CONTROL_PATH); |
| 1136 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1137 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1138 | } |
| 1139 | |
| 1140 | /** |
| 1141 | * hdd_softap_register_bc_sta() - Register the SoftAP broadcast STA |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1142 | * @adapter: pointer to adapter context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1143 | * @fPrivacyBit: should 802.11 privacy bit be set? |
| 1144 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 1145 | * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1146 | */ |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1147 | QDF_STATUS hdd_softap_register_bc_sta(struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1148 | bool fPrivacyBit) |
| 1149 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1150 | QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE; |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1151 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Dustin Brown | ce5b3d3 | 2018-01-17 15:07:38 -0800 | [diff] [blame] | 1152 | struct qdf_mac_addr broadcastMacAddr = QDF_MAC_ADDR_BCAST_INIT; |
Jeff Johnson | 9bf2497 | 2017-10-04 09:26:58 -0700 | [diff] [blame] | 1153 | struct hdd_ap_ctx *ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1154 | |
Jeff Johnson | 9bf2497 | 2017-10-04 09:26:58 -0700 | [diff] [blame] | 1155 | ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1156 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1157 | hdd_ctx->sta_to_adapter[WLAN_RX_BCMC_STA_ID] = adapter; |
Jeff Johnson | 42518cf | 2017-10-26 13:33:29 -0700 | [diff] [blame] | 1158 | hdd_ctx->sta_to_adapter[ap_ctx->broadcast_sta_id] = adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1159 | qdf_status = |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1160 | hdd_softap_register_sta(adapter, false, fPrivacyBit, |
Jeff Johnson | 42518cf | 2017-10-26 13:33:29 -0700 | [diff] [blame] | 1161 | ap_ctx->broadcast_sta_id, |
Jeff Johnson | 3f6c89f | 2018-03-01 14:27:38 -0800 | [diff] [blame] | 1162 | &broadcastMacAddr, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1163 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1164 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1165 | } |
| 1166 | |
| 1167 | /** |
| 1168 | * hdd_softap_deregister_bc_sta() - Deregister the SoftAP broadcast STA |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1169 | * @adapter: pointer to adapter context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1170 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 1171 | * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1172 | */ |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1173 | QDF_STATUS hdd_softap_deregister_bc_sta(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1174 | { |
Jeff Johnson | 42518cf | 2017-10-26 13:33:29 -0700 | [diff] [blame] | 1175 | struct hdd_ap_ctx *ap_ctx; |
| 1176 | |
| 1177 | ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 1178 | return hdd_softap_deregister_sta(adapter, ap_ctx->broadcast_sta_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1179 | } |
| 1180 | |
| 1181 | /** |
| 1182 | * hdd_softap_stop_bss() - Stop the BSS |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1183 | * @adapter: pointer to adapter context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1184 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 1185 | * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1186 | */ |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1187 | QDF_STATUS hdd_softap_stop_bss(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1188 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1189 | QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1190 | uint8_t staId = 0; |
Jeff Johnson | 9240287 | 2017-09-03 09:25:37 -0700 | [diff] [blame] | 1191 | struct hdd_context *hdd_ctx; |
Srinivas Girigowda | e806a82 | 2017-03-25 11:25:30 -0700 | [diff] [blame] | 1192 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1193 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1194 | |
Rajeev Kumar | 07bbe12 | 2017-10-24 13:06:05 -0700 | [diff] [blame] | 1195 | /* This is stop bss callback running in scheduler thread so do not |
| 1196 | * driver unload in progress check otherwise it can lead to peer |
| 1197 | * object leak |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1198 | */ |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1199 | qdf_status = hdd_softap_deregister_bc_sta(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1200 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1201 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 42518cf | 2017-10-26 13:33:29 -0700 | [diff] [blame] | 1202 | struct hdd_ap_ctx *ap_ctx; |
| 1203 | |
| 1204 | ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame] | 1205 | hdd_err("Failed to deregister BC sta Id %d", |
Jeff Johnson | 42518cf | 2017-10-26 13:33:29 -0700 | [diff] [blame] | 1206 | ap_ctx->broadcast_sta_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1207 | } |
| 1208 | |
| 1209 | for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++) { |
| 1210 | /* This excludes BC sta as it is already deregistered */ |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 1211 | if (adapter->sta_info[staId].in_use) { |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1212 | qdf_status = hdd_softap_deregister_sta(adapter, staId); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1213 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame] | 1214 | hdd_err("Failed to deregister sta Id %d", |
| 1215 | staId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1216 | } |
| 1217 | } |
| 1218 | } |
Mukul Sharma | ecf8e09 | 2017-12-19 22:36:31 +0530 | [diff] [blame] | 1219 | |
| 1220 | /* Mark the indoor channel (passive) to enable */ |
| 1221 | if (hdd_ctx->config->force_ssc_disable_indoor_channel) { |
| 1222 | hdd_update_indoor_channel(hdd_ctx, false); |
| 1223 | sme_update_channel_list(hdd_ctx->hHal); |
| 1224 | } |
| 1225 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1226 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1227 | } |
| 1228 | |
| 1229 | /** |
| 1230 | * hdd_softap_change_sta_state() - Change the state of a SoftAP station |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1231 | * @adapter: pointer to adapter context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1232 | * @pDestMacAddress: MAC address of the station |
| 1233 | * @state: new state of the station |
| 1234 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 1235 | * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1236 | */ |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1237 | QDF_STATUS hdd_softap_change_sta_state(struct hdd_adapter *adapter, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1238 | struct qdf_mac_addr *pDestMacAddress, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1239 | enum ol_txrx_peer_state state) |
| 1240 | { |
Jeff Johnson | 4c0ab7b | 2017-10-21 16:13:09 -0700 | [diff] [blame] | 1241 | uint8_t sta_id = WLAN_MAX_STA_COUNT; |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame] | 1242 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1243 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 1244 | hdd_enter_dev(adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1245 | |
Jeff Johnson | 4c0ab7b | 2017-10-21 16:13:09 -0700 | [diff] [blame] | 1246 | qdf_status = hdd_softap_get_sta_id(adapter, pDestMacAddress, &sta_id); |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame] | 1247 | if (QDF_STATUS_SUCCESS != qdf_status) { |
| 1248 | hdd_err("Failed to find right station"); |
| 1249 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1250 | } |
| 1251 | |
| 1252 | if (false == |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 1253 | qdf_is_macaddr_equal(&adapter->sta_info[sta_id].sta_mac, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1254 | pDestMacAddress)) { |
Jeff Johnson | 4c0ab7b | 2017-10-21 16:13:09 -0700 | [diff] [blame] | 1255 | hdd_err("Station %u MAC address not matching", sta_id); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1256 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1257 | } |
| 1258 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1259 | qdf_status = |
Jeff Johnson | 4c0ab7b | 2017-10-21 16:13:09 -0700 | [diff] [blame] | 1260 | hdd_change_peer_state(adapter, sta_id, state, false); |
| 1261 | hdd_info("Station %u changed to state %d", sta_id, state); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1262 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1263 | if (QDF_STATUS_SUCCESS == qdf_status) { |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 1264 | adapter->sta_info[sta_id].peer_state = |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 1265 | OL_TXRX_PEER_STATE_AUTH; |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1266 | p2p_peer_authorized(adapter->hdd_vdev, pDestMacAddress->bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1267 | } |
| 1268 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 1269 | hdd_exit(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1270 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1271 | } |
| 1272 | |
| 1273 | /* |
| 1274 | * hdd_softap_get_sta_id() - Find station ID from MAC address |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1275 | * @adapter: pointer to adapter context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1276 | * @pDestMacAddress: MAC address of the destination |
| 1277 | * @staId: Station ID associated with the MAC address |
| 1278 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1279 | * Return: QDF_STATUS_SUCCESS if a match was found, in which case |
| 1280 | * staId is populated, QDF_STATUS_E_FAILURE if a match is |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1281 | * not found |
| 1282 | */ |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1283 | QDF_STATUS hdd_softap_get_sta_id(struct hdd_adapter *adapter, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1284 | struct qdf_mac_addr *pMacAddress, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1285 | uint8_t *staId) |
| 1286 | { |
| 1287 | uint8_t i; |
| 1288 | |
| 1289 | for (i = 0; i < WLAN_MAX_STA_COUNT; i++) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1290 | if (!qdf_mem_cmp |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 1291 | (&adapter->sta_info[i].sta_mac, pMacAddress, |
| 1292 | QDF_MAC_ADDR_SIZE) && adapter->sta_info[i].in_use) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1293 | *staId = i; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1294 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1295 | } |
| 1296 | } |
| 1297 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1298 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1299 | } |