Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Marvell Wireless LAN device driver: generic TX/RX data handling |
| 3 | * |
Xinming Hu | 65da33f | 2014-06-19 21:38:57 -0700 | [diff] [blame] | 4 | * Copyright (C) 2011-2014, Marvell International Ltd. |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 5 | * |
| 6 | * This software file (the "File") is distributed by Marvell International |
| 7 | * Ltd. under the terms of the GNU General Public License Version 2, June 1991 |
| 8 | * (the "License"). You may use, redistribute and/or modify this File in |
| 9 | * accordance with the terms and conditions of the License, a copy of which |
| 10 | * is available by writing to the Free Software Foundation, Inc., |
| 11 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the |
| 12 | * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. |
| 13 | * |
| 14 | * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE |
| 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE |
| 16 | * ARE EXPRESSLY DISCLAIMED. The License provides additional details about |
| 17 | * this warranty disclaimer. |
| 18 | */ |
| 19 | |
| 20 | #include "decl.h" |
| 21 | #include "ioctl.h" |
| 22 | #include "util.h" |
| 23 | #include "fw.h" |
| 24 | #include "main.h" |
| 25 | #include "wmm.h" |
| 26 | |
| 27 | /* |
| 28 | * This function processes the received buffer. |
| 29 | * |
| 30 | * Main responsibility of this function is to parse the RxPD to |
| 31 | * identify the correct interface this packet is headed for and |
| 32 | * forwarding it to the associated handling function, where the |
| 33 | * packet will be further processed and sent to kernel/upper layer |
| 34 | * if required. |
| 35 | */ |
| 36 | int mwifiex_handle_rx_packet(struct mwifiex_adapter *adapter, |
| 37 | struct sk_buff *skb) |
| 38 | { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 39 | struct mwifiex_private *priv = |
| 40 | mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY); |
| 41 | struct rxpd *local_rx_pd; |
| 42 | struct mwifiex_rxinfo *rx_info = MWIFIEX_SKB_RXCB(skb); |
Ujjal Roy | ca8d6df | 2013-12-02 23:17:53 -0800 | [diff] [blame] | 43 | int ret; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 44 | |
| 45 | local_rx_pd = (struct rxpd *) (skb->data); |
| 46 | /* Get the BSS number from rxpd, get corresponding priv */ |
| 47 | priv = mwifiex_get_priv_by_id(adapter, local_rx_pd->bss_num & |
| 48 | BSS_NUM_MASK, local_rx_pd->bss_type); |
| 49 | if (!priv) |
| 50 | priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY); |
| 51 | |
Avinash Patil | f3b369e | 2012-10-19 19:19:21 -0700 | [diff] [blame] | 52 | if (!priv) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 53 | mwifiex_dbg(adapter, ERROR, |
| 54 | "data: priv not found. Drop RX packet\n"); |
Avinash Patil | f3b369e | 2012-10-19 19:19:21 -0700 | [diff] [blame] | 55 | dev_kfree_skb_any(skb); |
| 56 | return -1; |
| 57 | } |
| 58 | |
Zhaoyang Liu | 868093a | 2015-05-12 00:48:19 +0530 | [diff] [blame] | 59 | mwifiex_dbg_dump(adapter, DAT_D, "rx pkt:", skb->data, |
| 60 | min_t(size_t, skb->len, DEBUG_DUMP_DATA_MAX_LEN)); |
| 61 | |
Amitkumar Karwar | 701a9e6 | 2014-07-01 14:39:04 -0700 | [diff] [blame] | 62 | memset(rx_info, 0, sizeof(*rx_info)); |
Yogesh Ashok Powar | 9da9a3b | 2012-01-11 20:06:11 -0800 | [diff] [blame] | 63 | rx_info->bss_num = priv->bss_num; |
| 64 | rx_info->bss_type = priv->bss_type; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 65 | |
Avinash Patil | 838e4f4 | 2012-08-03 18:06:08 -0700 | [diff] [blame] | 66 | if (priv->bss_role == MWIFIEX_BSS_ROLE_UAP) |
Ujjal Roy | ca8d6df | 2013-12-02 23:17:53 -0800 | [diff] [blame] | 67 | ret = mwifiex_process_uap_rx_packet(priv, skb); |
| 68 | else |
| 69 | ret = mwifiex_process_sta_rx_packet(priv, skb); |
Avinash Patil | 838e4f4 | 2012-08-03 18:06:08 -0700 | [diff] [blame] | 70 | |
Ujjal Roy | ca8d6df | 2013-12-02 23:17:53 -0800 | [diff] [blame] | 71 | return ret; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 72 | } |
| 73 | EXPORT_SYMBOL_GPL(mwifiex_handle_rx_packet); |
| 74 | |
| 75 | /* |
| 76 | * This function sends a packet to device. |
| 77 | * |
| 78 | * It processes the packet to add the TxPD, checks condition and |
| 79 | * sends the processed packet to firmware for transmission. |
| 80 | * |
| 81 | * On successful completion, the function calls the completion callback |
| 82 | * and logs the time. |
| 83 | */ |
| 84 | int mwifiex_process_tx(struct mwifiex_private *priv, struct sk_buff *skb, |
| 85 | struct mwifiex_tx_param *tx_param) |
| 86 | { |
Zhaoyang Liu | 4ce7bc0 | 2015-02-13 20:38:16 +0530 | [diff] [blame] | 87 | int hroom, ret = -1; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 88 | struct mwifiex_adapter *adapter = priv->adapter; |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 89 | u8 *head_ptr; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 90 | struct txpd *local_tx_pd = NULL; |
Xinming Hu | 442f6f9 | 2015-06-03 16:59:38 +0530 | [diff] [blame] | 91 | struct mwifiex_sta_node *dest_node; |
| 92 | struct ethhdr *hdr = (void *)skb->data; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 93 | |
Zhaoyang Liu | 4ce7bc0 | 2015-02-13 20:38:16 +0530 | [diff] [blame] | 94 | hroom = (adapter->iface_type == MWIFIEX_USB) ? 0 : INTF_HEADER_LEN; |
| 95 | |
Xinming Hu | 442f6f9 | 2015-06-03 16:59:38 +0530 | [diff] [blame] | 96 | if (priv->bss_role == MWIFIEX_BSS_ROLE_UAP) { |
| 97 | dest_node = mwifiex_get_sta_entry(priv, hdr->h_dest); |
| 98 | if (dest_node) { |
| 99 | dest_node->stats.tx_bytes += skb->len; |
| 100 | dest_node->stats.tx_packets++; |
| 101 | } |
| 102 | |
Avinash Patil | 4ac8764 | 2012-09-10 18:30:49 -0700 | [diff] [blame] | 103 | head_ptr = mwifiex_process_uap_txpd(priv, skb); |
Xinming Hu | 442f6f9 | 2015-06-03 16:59:38 +0530 | [diff] [blame] | 104 | } else { |
Avinash Patil | 4ac8764 | 2012-09-10 18:30:49 -0700 | [diff] [blame] | 105 | head_ptr = mwifiex_process_sta_txpd(priv, skb); |
Xinming Hu | 442f6f9 | 2015-06-03 16:59:38 +0530 | [diff] [blame] | 106 | } |
Avinash Patil | 4ac8764 | 2012-09-10 18:30:49 -0700 | [diff] [blame] | 107 | |
Zhaoyang Liu | e35000e | 2015-03-13 17:37:57 +0530 | [diff] [blame] | 108 | if ((adapter->data_sent || adapter->tx_lock_flag) && head_ptr) { |
| 109 | skb_queue_tail(&adapter->tx_data_q, skb); |
| 110 | atomic_inc(&adapter->tx_queued); |
| 111 | return 0; |
| 112 | } |
| 113 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 114 | if (head_ptr) { |
| 115 | if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA) |
Zhaoyang Liu | 4ce7bc0 | 2015-02-13 20:38:16 +0530 | [diff] [blame] | 116 | local_tx_pd = (struct txpd *)(head_ptr + hroom); |
Amitkumar Karwar | 4daffe3 | 2012-04-18 20:08:28 -0700 | [diff] [blame] | 117 | if (adapter->iface_type == MWIFIEX_USB) { |
Amitkumar Karwar | 4daffe3 | 2012-04-18 20:08:28 -0700 | [diff] [blame] | 118 | ret = adapter->if_ops.host_to_card(adapter, |
Zhaoyang Liu | 735ab6b | 2015-09-18 06:32:18 -0700 | [diff] [blame] | 119 | priv->usb_port, |
Amitkumar Karwar | 4daffe3 | 2012-04-18 20:08:28 -0700 | [diff] [blame] | 120 | skb, NULL); |
| 121 | } else { |
| 122 | ret = adapter->if_ops.host_to_card(adapter, |
| 123 | MWIFIEX_TYPE_DATA, |
| 124 | skb, tx_param); |
| 125 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 126 | } |
Zhaoyang Liu | 868093a | 2015-05-12 00:48:19 +0530 | [diff] [blame] | 127 | mwifiex_dbg_dump(adapter, DAT_D, "tx pkt:", skb->data, |
| 128 | min_t(size_t, skb->len, DEBUG_DUMP_DATA_MAX_LEN)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 129 | |
| 130 | switch (ret) { |
Amitkumar Karwar | 4daffe3 | 2012-04-18 20:08:28 -0700 | [diff] [blame] | 131 | case -ENOSR: |
Amitkumar Karwar | 17090be | 2015-09-18 06:32:12 -0700 | [diff] [blame] | 132 | mwifiex_dbg(adapter, DATA, "data: -ENOSR is returned\n"); |
Amitkumar Karwar | 4daffe3 | 2012-04-18 20:08:28 -0700 | [diff] [blame] | 133 | break; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 134 | case -EBUSY: |
| 135 | if ((GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA) && |
Yogesh Ashok Powar | c65a30f | 2012-03-13 19:22:42 -0700 | [diff] [blame] | 136 | (adapter->pps_uapsd_mode) && (adapter->tx_lock_flag)) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 137 | priv->adapter->tx_lock_flag = false; |
Yogesh Ashok Powar | 3d82de0 | 2011-10-05 14:58:24 -0700 | [diff] [blame] | 138 | if (local_tx_pd) |
| 139 | local_tx_pd->flags = 0; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 140 | } |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 141 | mwifiex_dbg(adapter, ERROR, "data: -EBUSY is returned\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 142 | break; |
| 143 | case -1: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 144 | mwifiex_dbg(adapter, ERROR, |
| 145 | "mwifiex_write_data_async failed: 0x%X\n", |
| 146 | ret); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 147 | adapter->dbg.num_tx_host_to_card_failure++; |
Avinash Patil | 47411a0 | 2012-11-01 18:44:16 -0700 | [diff] [blame] | 148 | mwifiex_write_data_complete(adapter, skb, 0, ret); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 149 | break; |
| 150 | case -EINPROGRESS: |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 151 | break; |
| 152 | case 0: |
Avinash Patil | 47411a0 | 2012-11-01 18:44:16 -0700 | [diff] [blame] | 153 | mwifiex_write_data_complete(adapter, skb, 0, ret); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 154 | break; |
| 155 | default: |
| 156 | break; |
| 157 | } |
| 158 | |
| 159 | return ret; |
| 160 | } |
| 161 | |
Zhaoyang Liu | e35000e | 2015-03-13 17:37:57 +0530 | [diff] [blame] | 162 | static int mwifiex_host_to_card(struct mwifiex_adapter *adapter, |
| 163 | struct sk_buff *skb, |
| 164 | struct mwifiex_tx_param *tx_param) |
| 165 | { |
| 166 | struct txpd *local_tx_pd = NULL; |
| 167 | u8 *head_ptr = skb->data; |
| 168 | int ret = 0; |
| 169 | struct mwifiex_private *priv; |
| 170 | struct mwifiex_txinfo *tx_info; |
| 171 | |
| 172 | tx_info = MWIFIEX_SKB_TXCB(skb); |
| 173 | priv = mwifiex_get_priv_by_id(adapter, tx_info->bss_num, |
| 174 | tx_info->bss_type); |
| 175 | if (!priv) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 176 | mwifiex_dbg(adapter, ERROR, |
| 177 | "data: priv not found. Drop TX packet\n"); |
Zhaoyang Liu | e35000e | 2015-03-13 17:37:57 +0530 | [diff] [blame] | 178 | adapter->dbg.num_tx_host_to_card_failure++; |
| 179 | mwifiex_write_data_complete(adapter, skb, 0, 0); |
| 180 | return ret; |
| 181 | } |
| 182 | if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA) { |
| 183 | if (adapter->iface_type == MWIFIEX_USB) |
| 184 | local_tx_pd = (struct txpd *)head_ptr; |
| 185 | else |
| 186 | local_tx_pd = (struct txpd *) (head_ptr + |
| 187 | INTF_HEADER_LEN); |
| 188 | } |
| 189 | |
| 190 | if (adapter->iface_type == MWIFIEX_USB) { |
Zhaoyang Liu | e35000e | 2015-03-13 17:37:57 +0530 | [diff] [blame] | 191 | ret = adapter->if_ops.host_to_card(adapter, |
Zhaoyang Liu | 735ab6b | 2015-09-18 06:32:18 -0700 | [diff] [blame] | 192 | priv->usb_port, |
Zhaoyang Liu | e35000e | 2015-03-13 17:37:57 +0530 | [diff] [blame] | 193 | skb, NULL); |
| 194 | } else { |
| 195 | ret = adapter->if_ops.host_to_card(adapter, |
| 196 | MWIFIEX_TYPE_DATA, |
| 197 | skb, tx_param); |
| 198 | } |
| 199 | switch (ret) { |
| 200 | case -ENOSR: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 201 | mwifiex_dbg(adapter, ERROR, "data: -ENOSR is returned\n"); |
Zhaoyang Liu | e35000e | 2015-03-13 17:37:57 +0530 | [diff] [blame] | 202 | break; |
| 203 | case -EBUSY: |
| 204 | if ((GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA) && |
| 205 | (adapter->pps_uapsd_mode) && |
| 206 | (adapter->tx_lock_flag)) { |
| 207 | priv->adapter->tx_lock_flag = false; |
| 208 | if (local_tx_pd) |
| 209 | local_tx_pd->flags = 0; |
| 210 | } |
| 211 | skb_queue_head(&adapter->tx_data_q, skb); |
| 212 | if (tx_info->flags & MWIFIEX_BUF_FLAG_AGGR_PKT) |
| 213 | atomic_add(tx_info->aggr_num, &adapter->tx_queued); |
| 214 | else |
| 215 | atomic_inc(&adapter->tx_queued); |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 216 | mwifiex_dbg(adapter, ERROR, "data: -EBUSY is returned\n"); |
Zhaoyang Liu | e35000e | 2015-03-13 17:37:57 +0530 | [diff] [blame] | 217 | break; |
| 218 | case -1: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 219 | mwifiex_dbg(adapter, ERROR, |
| 220 | "mwifiex_write_data_async failed: 0x%X\n", ret); |
Zhaoyang Liu | e35000e | 2015-03-13 17:37:57 +0530 | [diff] [blame] | 221 | adapter->dbg.num_tx_host_to_card_failure++; |
| 222 | mwifiex_write_data_complete(adapter, skb, 0, ret); |
| 223 | break; |
| 224 | case -EINPROGRESS: |
Zhaoyang Liu | e35000e | 2015-03-13 17:37:57 +0530 | [diff] [blame] | 225 | break; |
| 226 | case 0: |
| 227 | mwifiex_write_data_complete(adapter, skb, 0, ret); |
| 228 | break; |
| 229 | default: |
| 230 | break; |
| 231 | } |
| 232 | return ret; |
| 233 | } |
| 234 | |
| 235 | static int |
| 236 | mwifiex_dequeue_tx_queue(struct mwifiex_adapter *adapter) |
| 237 | { |
| 238 | struct sk_buff *skb, *skb_next; |
| 239 | struct mwifiex_txinfo *tx_info; |
| 240 | struct mwifiex_tx_param tx_param; |
| 241 | |
| 242 | skb = skb_dequeue(&adapter->tx_data_q); |
| 243 | if (!skb) |
| 244 | return -1; |
| 245 | |
| 246 | tx_info = MWIFIEX_SKB_TXCB(skb); |
| 247 | if (tx_info->flags & MWIFIEX_BUF_FLAG_AGGR_PKT) |
| 248 | atomic_sub(tx_info->aggr_num, &adapter->tx_queued); |
| 249 | else |
| 250 | atomic_dec(&adapter->tx_queued); |
| 251 | |
| 252 | if (!skb_queue_empty(&adapter->tx_data_q)) |
| 253 | skb_next = skb_peek(&adapter->tx_data_q); |
| 254 | else |
| 255 | skb_next = NULL; |
| 256 | tx_param.next_pkt_len = ((skb_next) ? skb_next->len : 0); |
| 257 | if (!tx_param.next_pkt_len) { |
| 258 | if (!mwifiex_wmm_lists_empty(adapter)) |
| 259 | tx_param.next_pkt_len = 1; |
| 260 | } |
| 261 | return mwifiex_host_to_card(adapter, skb, &tx_param); |
| 262 | } |
| 263 | |
| 264 | void |
| 265 | mwifiex_process_tx_queue(struct mwifiex_adapter *adapter) |
| 266 | { |
| 267 | do { |
| 268 | if (adapter->data_sent || adapter->tx_lock_flag) |
| 269 | break; |
| 270 | if (mwifiex_dequeue_tx_queue(adapter)) |
| 271 | break; |
| 272 | } while (!skb_queue_empty(&adapter->tx_data_q)); |
| 273 | } |
| 274 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 275 | /* |
| 276 | * Packet send completion callback handler. |
| 277 | * |
| 278 | * It either frees the buffer directly or forwards it to another |
| 279 | * completion callback which checks conditions, updates statistics, |
| 280 | * wakes up stalled traffic queue if required, and then frees the buffer. |
| 281 | */ |
| 282 | int mwifiex_write_data_complete(struct mwifiex_adapter *adapter, |
Avinash Patil | 47411a0 | 2012-11-01 18:44:16 -0700 | [diff] [blame] | 283 | struct sk_buff *skb, int aggr, int status) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 284 | { |
Avinash Patil | 47411a0 | 2012-11-01 18:44:16 -0700 | [diff] [blame] | 285 | struct mwifiex_private *priv; |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 286 | struct mwifiex_txinfo *tx_info; |
Avinash Patil | 47411a0 | 2012-11-01 18:44:16 -0700 | [diff] [blame] | 287 | struct netdev_queue *txq; |
| 288 | int index; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 289 | |
| 290 | if (!skb) |
| 291 | return 0; |
| 292 | |
| 293 | tx_info = MWIFIEX_SKB_TXCB(skb); |
Yogesh Ashok Powar | 9da9a3b | 2012-01-11 20:06:11 -0800 | [diff] [blame] | 294 | priv = mwifiex_get_priv_by_id(adapter, tx_info->bss_num, |
Yogesh Ashok Powar | c65a30f | 2012-03-13 19:22:42 -0700 | [diff] [blame] | 295 | tx_info->bss_type); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 296 | if (!priv) |
| 297 | goto done; |
| 298 | |
Avinash Patil | bbea3bc | 2011-12-08 20:41:05 -0800 | [diff] [blame] | 299 | mwifiex_set_trans_start(priv->netdev); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 300 | if (!status) { |
| 301 | priv->stats.tx_packets++; |
Ujjal Roy | a1ed484 | 2013-12-02 23:17:55 -0800 | [diff] [blame] | 302 | priv->stats.tx_bytes += tx_info->pkt_len; |
Ashok Nagarajan | 8908c7d | 2013-03-08 10:58:45 -0800 | [diff] [blame] | 303 | if (priv->tx_timeout_cnt) |
| 304 | priv->tx_timeout_cnt = 0; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 305 | } else { |
| 306 | priv->stats.tx_errors++; |
| 307 | } |
Marc Yang | 62a5b7d | 2011-05-16 19:17:53 -0700 | [diff] [blame] | 308 | |
Xinming Hu | ec264a4 | 2015-06-03 16:59:47 +0530 | [diff] [blame] | 309 | if (tx_info->flags & MWIFIEX_BUF_FLAG_BRIDGED_PKT) |
Avinash Patil | 838e4f4 | 2012-08-03 18:06:08 -0700 | [diff] [blame] | 310 | atomic_dec_return(&adapter->pending_bridged_pkts); |
Xinming Hu | ec264a4 | 2015-06-03 16:59:47 +0530 | [diff] [blame] | 311 | |
| 312 | if (tx_info->flags & MWIFIEX_BUF_FLAG_AGGR_PKT) |
| 313 | goto done; |
Avinash Patil | 47411a0 | 2012-11-01 18:44:16 -0700 | [diff] [blame] | 314 | |
| 315 | if (aggr) |
| 316 | /* For skb_aggr, do not wake up tx queue */ |
Marc Yang | 62a5b7d | 2011-05-16 19:17:53 -0700 | [diff] [blame] | 317 | goto done; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 318 | |
Avinash Patil | 47411a0 | 2012-11-01 18:44:16 -0700 | [diff] [blame] | 319 | atomic_dec(&adapter->tx_pending); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 320 | |
Avinash Patil | 47411a0 | 2012-11-01 18:44:16 -0700 | [diff] [blame] | 321 | index = mwifiex_1d_to_wmm_queue[skb->priority]; |
| 322 | if (atomic_dec_return(&priv->wmm_tx_pending[index]) < LOW_TX_PENDING) { |
| 323 | txq = netdev_get_tx_queue(priv->netdev, index); |
| 324 | if (netif_tx_queue_stopped(txq)) { |
| 325 | netif_tx_wake_queue(txq); |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 326 | mwifiex_dbg(adapter, DATA, "wake queue: %d\n", index); |
Avinash Patil | 47411a0 | 2012-11-01 18:44:16 -0700 | [diff] [blame] | 327 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 328 | } |
| 329 | done: |
| 330 | dev_kfree_skb_any(skb); |
| 331 | |
| 332 | return 0; |
| 333 | } |
Amitkumar Karwar | 4daffe3 | 2012-04-18 20:08:28 -0700 | [diff] [blame] | 334 | EXPORT_SYMBOL_GPL(mwifiex_write_data_complete); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 335 | |
Amitkumar Karwar | 808bbeb | 2014-11-25 06:43:05 -0800 | [diff] [blame] | 336 | void mwifiex_parse_tx_status_event(struct mwifiex_private *priv, |
| 337 | void *event_body) |
| 338 | { |
| 339 | struct tx_status_event *tx_status = (void *)priv->adapter->event_body; |
| 340 | struct sk_buff *ack_skb; |
| 341 | unsigned long flags; |
Amitkumar Karwar | 18ca438 | 2014-11-25 06:43:06 -0800 | [diff] [blame] | 342 | struct mwifiex_txinfo *tx_info; |
Amitkumar Karwar | 808bbeb | 2014-11-25 06:43:05 -0800 | [diff] [blame] | 343 | |
| 344 | if (!tx_status->tx_token_id) |
| 345 | return; |
| 346 | |
| 347 | spin_lock_irqsave(&priv->ack_status_lock, flags); |
| 348 | ack_skb = idr_find(&priv->ack_status_frames, tx_status->tx_token_id); |
| 349 | if (ack_skb) |
| 350 | idr_remove(&priv->ack_status_frames, tx_status->tx_token_id); |
| 351 | spin_unlock_irqrestore(&priv->ack_status_lock, flags); |
| 352 | |
Amitkumar Karwar | 18ca438 | 2014-11-25 06:43:06 -0800 | [diff] [blame] | 353 | if (ack_skb) { |
| 354 | tx_info = MWIFIEX_SKB_TXCB(ack_skb); |
| 355 | |
| 356 | if (tx_info->flags & MWIFIEX_BUF_FLAG_EAPOL_TX_STATUS) { |
| 357 | /* consumes ack_skb */ |
| 358 | skb_complete_wifi_ack(ack_skb, !tx_status->status); |
| 359 | } else { |
Aniket Nagarnaik | ae86c58 | 2015-07-02 06:07:02 -0700 | [diff] [blame] | 360 | /* Remove broadcast address which was added by driver */ |
| 361 | memmove(ack_skb->data + |
| 362 | sizeof(struct ieee80211_hdr_3addr) + |
| 363 | MWIFIEX_MGMT_FRAME_HEADER_SIZE + sizeof(u16), |
| 364 | ack_skb->data + |
| 365 | sizeof(struct ieee80211_hdr_3addr) + |
| 366 | MWIFIEX_MGMT_FRAME_HEADER_SIZE + sizeof(u16) + |
| 367 | ETH_ALEN, ack_skb->len - |
| 368 | (sizeof(struct ieee80211_hdr_3addr) + |
| 369 | MWIFIEX_MGMT_FRAME_HEADER_SIZE + sizeof(u16) + |
| 370 | ETH_ALEN)); |
| 371 | ack_skb->len = ack_skb->len - ETH_ALEN; |
| 372 | /* Remove driver's proprietary header including 2 bytes |
| 373 | * of packet length and pass actual management frame buffer |
| 374 | * to cfg80211. |
| 375 | */ |
Avinash Patil | 4facc34 | 2015-01-28 15:42:00 +0530 | [diff] [blame] | 376 | cfg80211_mgmt_tx_status(&priv->wdev, tx_info->cookie, |
Aniket Nagarnaik | ae86c58 | 2015-07-02 06:07:02 -0700 | [diff] [blame] | 377 | ack_skb->data + |
| 378 | MWIFIEX_MGMT_FRAME_HEADER_SIZE + |
| 379 | sizeof(u16), ack_skb->len - |
| 380 | (MWIFIEX_MGMT_FRAME_HEADER_SIZE |
| 381 | + sizeof(u16)), |
Amitkumar Karwar | 18ca438 | 2014-11-25 06:43:06 -0800 | [diff] [blame] | 382 | !tx_status->status, GFP_ATOMIC); |
| 383 | dev_kfree_skb_any(ack_skb); |
| 384 | } |
| 385 | } |
Amitkumar Karwar | 808bbeb | 2014-11-25 06:43:05 -0800 | [diff] [blame] | 386 | } |