Avinash Patil | 838e4f4 | 2012-08-03 18:06:08 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Marvell Wireless LAN device driver: AP TX and RX data handling |
| 3 | * |
Xinming Hu | 65da33f | 2014-06-19 21:38:57 -0700 | [diff] [blame] | 4 | * Copyright (C) 2012-2014, Marvell International Ltd. |
Avinash Patil | 838e4f4 | 2012-08-03 18:06:08 -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 "main.h" |
| 23 | #include "wmm.h" |
Avinash Patil | d1cf3b9 | 2012-08-03 18:06:09 -0700 | [diff] [blame] | 24 | #include "11n_aggr.h" |
| 25 | #include "11n_rxreorder.h" |
Avinash Patil | 838e4f4 | 2012-08-03 18:06:08 -0700 | [diff] [blame] | 26 | |
Avinash Patil | 61c87304 | 2013-07-22 19:17:41 -0700 | [diff] [blame] | 27 | /* This function checks if particular RA list has packets more than low bridge |
| 28 | * packet threshold and then deletes packet from this RA list. |
| 29 | * Function deletes packets from such RA list and returns true. If no such list |
| 30 | * is found, false is returned. |
| 31 | */ |
| 32 | static bool |
| 33 | mwifiex_uap_del_tx_pkts_in_ralist(struct mwifiex_private *priv, |
| 34 | struct list_head *ra_list_head) |
| 35 | { |
| 36 | struct mwifiex_ra_list_tbl *ra_list; |
| 37 | struct sk_buff *skb, *tmp; |
| 38 | bool pkt_deleted = false; |
| 39 | struct mwifiex_txinfo *tx_info; |
| 40 | struct mwifiex_adapter *adapter = priv->adapter; |
| 41 | |
| 42 | list_for_each_entry(ra_list, ra_list_head, list) { |
| 43 | if (skb_queue_empty(&ra_list->skb_head)) |
| 44 | continue; |
| 45 | |
| 46 | skb_queue_walk_safe(&ra_list->skb_head, skb, tmp) { |
| 47 | tx_info = MWIFIEX_SKB_TXCB(skb); |
| 48 | if (tx_info->flags & MWIFIEX_BUF_FLAG_BRIDGED_PKT) { |
| 49 | __skb_unlink(skb, &ra_list->skb_head); |
| 50 | mwifiex_write_data_complete(adapter, skb, 0, |
| 51 | -1); |
| 52 | atomic_dec(&priv->wmm.tx_pkts_queued); |
| 53 | pkt_deleted = true; |
| 54 | } |
| 55 | if ((atomic_read(&adapter->pending_bridged_pkts) <= |
| 56 | MWIFIEX_BRIDGED_PKTS_THR_LOW)) |
| 57 | break; |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | return pkt_deleted; |
| 62 | } |
| 63 | |
| 64 | /* This function deletes packets from particular RA List. RA list index |
| 65 | * from which packets are deleted is preserved so that packets from next RA |
| 66 | * list are deleted upon subsequent call thus maintaining fairness. |
| 67 | */ |
| 68 | static void mwifiex_uap_cleanup_tx_queues(struct mwifiex_private *priv) |
| 69 | { |
| 70 | unsigned long flags; |
| 71 | struct list_head *ra_list; |
| 72 | int i; |
| 73 | |
| 74 | spin_lock_irqsave(&priv->wmm.ra_list_spinlock, flags); |
| 75 | |
| 76 | for (i = 0; i < MAX_NUM_TID; i++, priv->del_list_idx++) { |
| 77 | if (priv->del_list_idx == MAX_NUM_TID) |
| 78 | priv->del_list_idx = 0; |
| 79 | ra_list = &priv->wmm.tid_tbl_ptr[priv->del_list_idx].ra_list; |
| 80 | if (mwifiex_uap_del_tx_pkts_in_ralist(priv, ra_list)) { |
| 81 | priv->del_list_idx++; |
| 82 | break; |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | spin_unlock_irqrestore(&priv->wmm.ra_list_spinlock, flags); |
| 87 | } |
| 88 | |
| 89 | |
Avinash Patil | 838e4f4 | 2012-08-03 18:06:08 -0700 | [diff] [blame] | 90 | static void mwifiex_uap_queue_bridged_pkt(struct mwifiex_private *priv, |
| 91 | struct sk_buff *skb) |
| 92 | { |
| 93 | struct mwifiex_adapter *adapter = priv->adapter; |
| 94 | struct uap_rxpd *uap_rx_pd; |
| 95 | struct rx_packet_hdr *rx_pkt_hdr; |
| 96 | struct sk_buff *new_skb; |
| 97 | struct mwifiex_txinfo *tx_info; |
| 98 | int hdr_chop; |
Ujjal Roy | 8d93f1f | 2013-11-05 15:01:45 -0800 | [diff] [blame] | 99 | struct ethhdr *p_ethhdr; |
Xinming Hu | 442f6f9 | 2015-06-03 16:59:38 +0530 | [diff] [blame^] | 100 | struct mwifiex_sta_node *src_node; |
Avinash Patil | 838e4f4 | 2012-08-03 18:06:08 -0700 | [diff] [blame] | 101 | |
| 102 | uap_rx_pd = (struct uap_rxpd *)(skb->data); |
| 103 | rx_pkt_hdr = (void *)uap_rx_pd + le16_to_cpu(uap_rx_pd->rx_pkt_offset); |
| 104 | |
| 105 | if ((atomic_read(&adapter->pending_bridged_pkts) >= |
Avinash Patil | 61c87304 | 2013-07-22 19:17:41 -0700 | [diff] [blame] | 106 | MWIFIEX_BRIDGED_PKTS_THR_HIGH)) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 107 | mwifiex_dbg(priv->adapter, ERROR, |
| 108 | "Tx: Bridge packet limit reached. Drop packet!\n"); |
Avinash Patil | 838e4f4 | 2012-08-03 18:06:08 -0700 | [diff] [blame] | 109 | kfree_skb(skb); |
Avinash Patil | 61c87304 | 2013-07-22 19:17:41 -0700 | [diff] [blame] | 110 | mwifiex_uap_cleanup_tx_queues(priv); |
Avinash Patil | 838e4f4 | 2012-08-03 18:06:08 -0700 | [diff] [blame] | 111 | return; |
| 112 | } |
| 113 | |
Amitkumar Karwar | c613d16 | 2013-12-02 23:17:51 -0800 | [diff] [blame] | 114 | if ((!memcmp(&rx_pkt_hdr->rfc1042_hdr, bridge_tunnel_header, |
| 115 | sizeof(bridge_tunnel_header))) || |
| 116 | (!memcmp(&rx_pkt_hdr->rfc1042_hdr, rfc1042_header, |
| 117 | sizeof(rfc1042_header)) && |
| 118 | ntohs(rx_pkt_hdr->rfc1042_hdr.snap_type) != ETH_P_AARP && |
| 119 | ntohs(rx_pkt_hdr->rfc1042_hdr.snap_type) != ETH_P_IPX)) { |
Ujjal Roy | 8d93f1f | 2013-11-05 15:01:45 -0800 | [diff] [blame] | 120 | /* Replace the 803 header and rfc1042 header (llc/snap) with |
| 121 | * an Ethernet II header, keep the src/dst and snap_type |
| 122 | * (ethertype). |
| 123 | * |
| 124 | * The firmware only passes up SNAP frames converting all RX |
| 125 | * data from 802.11 to 802.2/LLC/SNAP frames. |
| 126 | * |
| 127 | * To create the Ethernet II, just move the src, dst address |
| 128 | * right before the snap_type. |
| 129 | */ |
| 130 | p_ethhdr = (struct ethhdr *) |
| 131 | ((u8 *)(&rx_pkt_hdr->eth803_hdr) |
| 132 | + sizeof(rx_pkt_hdr->eth803_hdr) |
| 133 | + sizeof(rx_pkt_hdr->rfc1042_hdr) |
| 134 | - sizeof(rx_pkt_hdr->eth803_hdr.h_dest) |
| 135 | - sizeof(rx_pkt_hdr->eth803_hdr.h_source) |
| 136 | - sizeof(rx_pkt_hdr->rfc1042_hdr.snap_type)); |
| 137 | memcpy(p_ethhdr->h_source, rx_pkt_hdr->eth803_hdr.h_source, |
| 138 | sizeof(p_ethhdr->h_source)); |
| 139 | memcpy(p_ethhdr->h_dest, rx_pkt_hdr->eth803_hdr.h_dest, |
| 140 | sizeof(p_ethhdr->h_dest)); |
Avinash Patil | 838e4f4 | 2012-08-03 18:06:08 -0700 | [diff] [blame] | 141 | /* Chop off the rxpd + the excess memory from |
| 142 | * 802.2/llc/snap header that was removed. |
| 143 | */ |
Ujjal Roy | 8d93f1f | 2013-11-05 15:01:45 -0800 | [diff] [blame] | 144 | hdr_chop = (u8 *)p_ethhdr - (u8 *)uap_rx_pd; |
| 145 | } else { |
Avinash Patil | 838e4f4 | 2012-08-03 18:06:08 -0700 | [diff] [blame] | 146 | /* Chop off the rxpd */ |
| 147 | hdr_chop = (u8 *)&rx_pkt_hdr->eth803_hdr - (u8 *)uap_rx_pd; |
Ujjal Roy | 8d93f1f | 2013-11-05 15:01:45 -0800 | [diff] [blame] | 148 | } |
Avinash Patil | 838e4f4 | 2012-08-03 18:06:08 -0700 | [diff] [blame] | 149 | |
Ujjal Roy | f7b5985 | 2013-12-02 23:17:56 -0800 | [diff] [blame] | 150 | /* Chop off the leading header bytes so that it points |
Avinash Patil | 838e4f4 | 2012-08-03 18:06:08 -0700 | [diff] [blame] | 151 | * to the start of either the reconstructed EthII frame |
| 152 | * or the 802.2/llc/snap frame. |
| 153 | */ |
| 154 | skb_pull(skb, hdr_chop); |
| 155 | |
| 156 | if (skb_headroom(skb) < MWIFIEX_MIN_DATA_HEADER_LEN) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 157 | mwifiex_dbg(priv->adapter, ERROR, |
| 158 | "data: Tx: insufficient skb headroom %d\n", |
| 159 | skb_headroom(skb)); |
Avinash Patil | 838e4f4 | 2012-08-03 18:06:08 -0700 | [diff] [blame] | 160 | /* Insufficient skb headroom - allocate a new skb */ |
| 161 | new_skb = |
| 162 | skb_realloc_headroom(skb, MWIFIEX_MIN_DATA_HEADER_LEN); |
| 163 | if (unlikely(!new_skb)) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 164 | mwifiex_dbg(priv->adapter, ERROR, |
| 165 | "Tx: cannot allocate new_skb\n"); |
Avinash Patil | 838e4f4 | 2012-08-03 18:06:08 -0700 | [diff] [blame] | 166 | kfree_skb(skb); |
| 167 | priv->stats.tx_dropped++; |
| 168 | return; |
| 169 | } |
| 170 | |
| 171 | kfree_skb(skb); |
| 172 | skb = new_skb; |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 173 | mwifiex_dbg(priv->adapter, INFO, |
| 174 | "info: new skb headroom %d\n", |
| 175 | skb_headroom(skb)); |
Avinash Patil | 838e4f4 | 2012-08-03 18:06:08 -0700 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | tx_info = MWIFIEX_SKB_TXCB(skb); |
Amitkumar Karwar | 701a9e6 | 2014-07-01 14:39:04 -0700 | [diff] [blame] | 179 | memset(tx_info, 0, sizeof(*tx_info)); |
Avinash Patil | 838e4f4 | 2012-08-03 18:06:08 -0700 | [diff] [blame] | 180 | tx_info->bss_num = priv->bss_num; |
| 181 | tx_info->bss_type = priv->bss_type; |
| 182 | tx_info->flags |= MWIFIEX_BUF_FLAG_BRIDGED_PKT; |
| 183 | |
Xinming Hu | 442f6f9 | 2015-06-03 16:59:38 +0530 | [diff] [blame^] | 184 | src_node = mwifiex_get_sta_entry(priv, rx_pkt_hdr->eth803_hdr.h_source); |
| 185 | if (src_node) { |
| 186 | src_node->stats.last_rx = jiffies; |
| 187 | src_node->stats.rx_bytes += skb->len; |
| 188 | src_node->stats.rx_packets++; |
| 189 | src_node->stats.last_tx_rate = uap_rx_pd->rx_rate; |
| 190 | src_node->stats.last_tx_htinfo = uap_rx_pd->ht_info; |
| 191 | } |
| 192 | |
Ujjal Roy | f7b5985 | 2013-12-02 23:17:56 -0800 | [diff] [blame] | 193 | if (is_unicast_ether_addr(rx_pkt_hdr->eth803_hdr.h_dest)) { |
| 194 | /* Update bridge packet statistics as the |
| 195 | * packet is not going to kernel/upper layer. |
| 196 | */ |
| 197 | priv->stats.rx_bytes += skb->len; |
| 198 | priv->stats.rx_packets++; |
| 199 | |
| 200 | /* Sending bridge packet to TX queue, so save the packet |
| 201 | * length in TXCB to update statistics in TX complete. |
| 202 | */ |
| 203 | tx_info->pkt_len = skb->len; |
| 204 | } |
| 205 | |
Thomas Gleixner | c64800e | 2014-06-12 08:31:34 +0100 | [diff] [blame] | 206 | __net_timestamp(skb); |
Avinash Patil | 838e4f4 | 2012-08-03 18:06:08 -0700 | [diff] [blame] | 207 | mwifiex_wmm_add_buf_txqueue(priv, skb); |
| 208 | atomic_inc(&adapter->tx_pending); |
| 209 | atomic_inc(&adapter->pending_bridged_pkts); |
| 210 | |
Avinash Patil | 838e4f4 | 2012-08-03 18:06:08 -0700 | [diff] [blame] | 211 | return; |
| 212 | } |
| 213 | |
| 214 | /* |
| 215 | * This function contains logic for AP packet forwarding. |
| 216 | * |
| 217 | * If a packet is multicast/broadcast, it is sent to kernel/upper layer |
| 218 | * as well as queued back to AP TX queue so that it can be sent to other |
| 219 | * associated stations. |
| 220 | * If a packet is unicast and RA is present in associated station list, |
| 221 | * it is again requeued into AP TX queue. |
| 222 | * If a packet is unicast and RA is not in associated station list, |
| 223 | * packet is forwarded to kernel to handle routing logic. |
| 224 | */ |
| 225 | int mwifiex_handle_uap_rx_forward(struct mwifiex_private *priv, |
| 226 | struct sk_buff *skb) |
| 227 | { |
| 228 | struct mwifiex_adapter *adapter = priv->adapter; |
| 229 | struct uap_rxpd *uap_rx_pd; |
| 230 | struct rx_packet_hdr *rx_pkt_hdr; |
| 231 | u8 ra[ETH_ALEN]; |
| 232 | struct sk_buff *skb_uap; |
| 233 | |
| 234 | uap_rx_pd = (struct uap_rxpd *)(skb->data); |
| 235 | rx_pkt_hdr = (void *)uap_rx_pd + le16_to_cpu(uap_rx_pd->rx_pkt_offset); |
| 236 | |
| 237 | /* don't do packet forwarding in disconnected state */ |
| 238 | if (!priv->media_connected) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 239 | mwifiex_dbg(adapter, ERROR, |
| 240 | "drop packet in disconnected state.\n"); |
Avinash Patil | 838e4f4 | 2012-08-03 18:06:08 -0700 | [diff] [blame] | 241 | dev_kfree_skb_any(skb); |
| 242 | return 0; |
| 243 | } |
| 244 | |
| 245 | memcpy(ra, rx_pkt_hdr->eth803_hdr.h_dest, ETH_ALEN); |
| 246 | |
| 247 | if (is_multicast_ether_addr(ra)) { |
| 248 | skb_uap = skb_copy(skb, GFP_ATOMIC); |
| 249 | mwifiex_uap_queue_bridged_pkt(priv, skb_uap); |
| 250 | } else { |
| 251 | if (mwifiex_get_sta_entry(priv, ra)) { |
| 252 | /* Requeue Intra-BSS packet */ |
| 253 | mwifiex_uap_queue_bridged_pkt(priv, skb); |
| 254 | return 0; |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | /* Forward unicat/Inter-BSS packets to kernel. */ |
Avinash Patil | f3b369e | 2012-10-19 19:19:21 -0700 | [diff] [blame] | 259 | return mwifiex_process_rx_packet(priv, skb); |
Avinash Patil | 838e4f4 | 2012-08-03 18:06:08 -0700 | [diff] [blame] | 260 | } |
| 261 | |
| 262 | /* |
| 263 | * This function processes the packet received on AP interface. |
| 264 | * |
| 265 | * The function looks into the RxPD and performs sanity tests on the |
| 266 | * received buffer to ensure its a valid packet before processing it |
| 267 | * further. If the packet is determined to be aggregated, it is |
| 268 | * de-aggregated accordingly. Then skb is passed to AP packet forwarding logic. |
| 269 | * |
| 270 | * The completion callback is called after processing is complete. |
| 271 | */ |
Avinash Patil | f3b369e | 2012-10-19 19:19:21 -0700 | [diff] [blame] | 272 | int mwifiex_process_uap_rx_packet(struct mwifiex_private *priv, |
Avinash Patil | 838e4f4 | 2012-08-03 18:06:08 -0700 | [diff] [blame] | 273 | struct sk_buff *skb) |
| 274 | { |
Avinash Patil | f3b369e | 2012-10-19 19:19:21 -0700 | [diff] [blame] | 275 | struct mwifiex_adapter *adapter = priv->adapter; |
Avinash Patil | 838e4f4 | 2012-08-03 18:06:08 -0700 | [diff] [blame] | 276 | int ret; |
| 277 | struct uap_rxpd *uap_rx_pd; |
Avinash Patil | 838e4f4 | 2012-08-03 18:06:08 -0700 | [diff] [blame] | 278 | struct rx_packet_hdr *rx_pkt_hdr; |
| 279 | u16 rx_pkt_type; |
Avinash Patil | d1cf3b9 | 2012-08-03 18:06:09 -0700 | [diff] [blame] | 280 | u8 ta[ETH_ALEN], pkt_type; |
Avinash Patil | c11fb98 | 2014-12-05 23:23:41 +0530 | [diff] [blame] | 281 | unsigned long flags; |
Avinash Patil | d1cf3b9 | 2012-08-03 18:06:09 -0700 | [diff] [blame] | 282 | struct mwifiex_sta_node *node; |
| 283 | |
Avinash Patil | 838e4f4 | 2012-08-03 18:06:08 -0700 | [diff] [blame] | 284 | uap_rx_pd = (struct uap_rxpd *)(skb->data); |
| 285 | rx_pkt_type = le16_to_cpu(uap_rx_pd->rx_pkt_type); |
| 286 | rx_pkt_hdr = (void *)uap_rx_pd + le16_to_cpu(uap_rx_pd->rx_pkt_offset); |
| 287 | |
Xinming Hu | 442f6f9 | 2015-06-03 16:59:38 +0530 | [diff] [blame^] | 288 | ether_addr_copy(ta, rx_pkt_hdr->eth803_hdr.h_source); |
| 289 | |
Avinash Patil | 838e4f4 | 2012-08-03 18:06:08 -0700 | [diff] [blame] | 290 | if ((le16_to_cpu(uap_rx_pd->rx_pkt_offset) + |
| 291 | le16_to_cpu(uap_rx_pd->rx_pkt_length)) > (u16) skb->len) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 292 | mwifiex_dbg(adapter, ERROR, |
| 293 | "wrong rx packet: len=%d, offset=%d, length=%d\n", |
| 294 | skb->len, le16_to_cpu(uap_rx_pd->rx_pkt_offset), |
| 295 | le16_to_cpu(uap_rx_pd->rx_pkt_length)); |
Avinash Patil | 838e4f4 | 2012-08-03 18:06:08 -0700 | [diff] [blame] | 296 | priv->stats.rx_dropped++; |
Xinming Hu | 442f6f9 | 2015-06-03 16:59:38 +0530 | [diff] [blame^] | 297 | |
| 298 | node = mwifiex_get_sta_entry(priv, ta); |
| 299 | if (node) |
| 300 | node->stats.tx_failed++; |
| 301 | |
Ujjal Roy | ca8d6df | 2013-12-02 23:17:53 -0800 | [diff] [blame] | 302 | dev_kfree_skb_any(skb); |
Avinash Patil | 838e4f4 | 2012-08-03 18:06:08 -0700 | [diff] [blame] | 303 | return 0; |
| 304 | } |
Avinash Patil | 838e4f4 | 2012-08-03 18:06:08 -0700 | [diff] [blame] | 305 | |
Amitkumar Karwar | 4c9f9fb | 2014-03-07 19:41:31 -0800 | [diff] [blame] | 306 | if (rx_pkt_type == PKT_TYPE_MGMT) { |
Avinash Patil | f3b369e | 2012-10-19 19:19:21 -0700 | [diff] [blame] | 307 | ret = mwifiex_process_mgmt_packet(priv, skb); |
Stone Piao | 2dbaf75 | 2012-09-25 20:23:35 -0700 | [diff] [blame] | 308 | if (ret) |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 309 | mwifiex_dbg(adapter, ERROR, |
| 310 | "Rx of mgmt packet failed"); |
Stone Piao | 2dbaf75 | 2012-09-25 20:23:35 -0700 | [diff] [blame] | 311 | dev_kfree_skb_any(skb); |
| 312 | return ret; |
Avinash Patil | d1cf3b9 | 2012-08-03 18:06:09 -0700 | [diff] [blame] | 313 | } |
| 314 | |
Avinash Patil | d1cf3b9 | 2012-08-03 18:06:09 -0700 | [diff] [blame] | 315 | |
| 316 | if (rx_pkt_type != PKT_TYPE_BAR && uap_rx_pd->priority < MAX_NUM_TID) { |
Avinash Patil | c11fb98 | 2014-12-05 23:23:41 +0530 | [diff] [blame] | 317 | spin_lock_irqsave(&priv->sta_list_spinlock, flags); |
Avinash Patil | d1cf3b9 | 2012-08-03 18:06:09 -0700 | [diff] [blame] | 318 | node = mwifiex_get_sta_entry(priv, ta); |
| 319 | if (node) |
| 320 | node->rx_seq[uap_rx_pd->priority] = |
| 321 | le16_to_cpu(uap_rx_pd->seq_num); |
Avinash Patil | c11fb98 | 2014-12-05 23:23:41 +0530 | [diff] [blame] | 322 | spin_unlock_irqrestore(&priv->sta_list_spinlock, flags); |
Avinash Patil | d1cf3b9 | 2012-08-03 18:06:09 -0700 | [diff] [blame] | 323 | } |
| 324 | |
| 325 | if (!priv->ap_11n_enabled || |
| 326 | (!mwifiex_11n_get_rx_reorder_tbl(priv, uap_rx_pd->priority, ta) && |
| 327 | (le16_to_cpu(uap_rx_pd->rx_pkt_type) != PKT_TYPE_AMSDU))) { |
| 328 | ret = mwifiex_handle_uap_rx_forward(priv, skb); |
| 329 | return ret; |
| 330 | } |
| 331 | |
| 332 | /* Reorder and send to kernel */ |
| 333 | pkt_type = (u8)le16_to_cpu(uap_rx_pd->rx_pkt_type); |
| 334 | ret = mwifiex_11n_rx_reorder_pkt(priv, le16_to_cpu(uap_rx_pd->seq_num), |
| 335 | uap_rx_pd->priority, ta, pkt_type, |
| 336 | skb); |
| 337 | |
Ujjal Roy | ca8d6df | 2013-12-02 23:17:53 -0800 | [diff] [blame] | 338 | if (ret || (rx_pkt_type == PKT_TYPE_BAR)) |
| 339 | dev_kfree_skb_any(skb); |
Avinash Patil | 838e4f4 | 2012-08-03 18:06:08 -0700 | [diff] [blame] | 340 | |
Avinash Patil | d1cf3b9 | 2012-08-03 18:06:09 -0700 | [diff] [blame] | 341 | if (ret) |
| 342 | priv->stats.rx_dropped++; |
| 343 | |
Avinash Patil | 838e4f4 | 2012-08-03 18:06:08 -0700 | [diff] [blame] | 344 | return ret; |
| 345 | } |
Avinash Patil | 4ac8764 | 2012-09-10 18:30:49 -0700 | [diff] [blame] | 346 | |
| 347 | /* |
| 348 | * This function fills the TxPD for AP tx packets. |
| 349 | * |
| 350 | * The Tx buffer received by this function should already have the |
| 351 | * header space allocated for TxPD. |
| 352 | * |
| 353 | * This function inserts the TxPD in between interface header and actual |
| 354 | * data and adjusts the buffer pointers accordingly. |
| 355 | * |
| 356 | * The following TxPD fields are set by this function, as required - |
| 357 | * - BSS number |
| 358 | * - Tx packet length and offset |
| 359 | * - Priority |
| 360 | * - Packet delay |
| 361 | * - Priority specific Tx control |
| 362 | * - Flags |
| 363 | */ |
| 364 | void *mwifiex_process_uap_txpd(struct mwifiex_private *priv, |
| 365 | struct sk_buff *skb) |
| 366 | { |
| 367 | struct mwifiex_adapter *adapter = priv->adapter; |
| 368 | struct uap_txpd *txpd; |
| 369 | struct mwifiex_txinfo *tx_info = MWIFIEX_SKB_TXCB(skb); |
Xinming Hu | 84b313b3 | 2014-12-26 03:02:33 -0800 | [diff] [blame] | 370 | int pad; |
| 371 | u16 pkt_type, pkt_offset; |
| 372 | int hroom = (priv->adapter->iface_type == MWIFIEX_USB) ? 0 : |
| 373 | INTF_HEADER_LEN; |
Avinash Patil | 4ac8764 | 2012-09-10 18:30:49 -0700 | [diff] [blame] | 374 | |
| 375 | if (!skb->len) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 376 | mwifiex_dbg(adapter, ERROR, |
| 377 | "Tx: bad packet length: %d\n", skb->len); |
Avinash Patil | 4ac8764 | 2012-09-10 18:30:49 -0700 | [diff] [blame] | 378 | tx_info->status_code = -1; |
| 379 | return skb->data; |
| 380 | } |
| 381 | |
Xinming Hu | 84b313b3 | 2014-12-26 03:02:33 -0800 | [diff] [blame] | 382 | BUG_ON(skb_headroom(skb) < MWIFIEX_MIN_DATA_HEADER_LEN); |
| 383 | |
Stone Piao | 3215215 | 2012-09-25 20:23:44 -0700 | [diff] [blame] | 384 | pkt_type = mwifiex_is_skb_mgmt_frame(skb) ? PKT_TYPE_MGMT : 0; |
| 385 | |
Xinming Hu | 84b313b3 | 2014-12-26 03:02:33 -0800 | [diff] [blame] | 386 | pad = ((void *)skb->data - (sizeof(*txpd) + hroom) - NULL) & |
| 387 | (MWIFIEX_DMA_ALIGN_SZ - 1); |
Avinash Patil | 4ac8764 | 2012-09-10 18:30:49 -0700 | [diff] [blame] | 388 | |
Xinming Hu | 84b313b3 | 2014-12-26 03:02:33 -0800 | [diff] [blame] | 389 | skb_push(skb, sizeof(*txpd) + pad); |
Avinash Patil | 4ac8764 | 2012-09-10 18:30:49 -0700 | [diff] [blame] | 390 | |
| 391 | txpd = (struct uap_txpd *)skb->data; |
| 392 | memset(txpd, 0, sizeof(*txpd)); |
| 393 | txpd->bss_num = priv->bss_num; |
| 394 | txpd->bss_type = priv->bss_type; |
Xinming Hu | 84b313b3 | 2014-12-26 03:02:33 -0800 | [diff] [blame] | 395 | txpd->tx_pkt_length = cpu_to_le16((u16)(skb->len - (sizeof(*txpd) + |
| 396 | pad))); |
Avinash Patil | 4ac8764 | 2012-09-10 18:30:49 -0700 | [diff] [blame] | 397 | txpd->priority = (u8)skb->priority; |
Amitkumar Karwar | 808bbeb | 2014-11-25 06:43:05 -0800 | [diff] [blame] | 398 | |
Avinash Patil | 4ac8764 | 2012-09-10 18:30:49 -0700 | [diff] [blame] | 399 | txpd->pkt_delay_2ms = mwifiex_wmm_compute_drv_pkt_delay(priv, skb); |
| 400 | |
Amitkumar Karwar | 18ca438 | 2014-11-25 06:43:06 -0800 | [diff] [blame] | 401 | if (tx_info->flags & MWIFIEX_BUF_FLAG_EAPOL_TX_STATUS || |
| 402 | tx_info->flags & MWIFIEX_BUF_FLAG_ACTION_TX_STATUS) { |
Amitkumar Karwar | 808bbeb | 2014-11-25 06:43:05 -0800 | [diff] [blame] | 403 | txpd->tx_token_id = tx_info->ack_frame_id; |
| 404 | txpd->flags |= MWIFIEX_TXPD_FLAGS_REQ_TX_STATUS; |
| 405 | } |
| 406 | |
Avinash Patil | 4ac8764 | 2012-09-10 18:30:49 -0700 | [diff] [blame] | 407 | if (txpd->priority < ARRAY_SIZE(priv->wmm.user_pri_pkt_tx_ctrl)) |
| 408 | /* |
| 409 | * Set the priority specific tx_control field, setting of 0 will |
| 410 | * cause the default value to be used later in this function. |
| 411 | */ |
| 412 | txpd->tx_control = |
| 413 | cpu_to_le32(priv->wmm.user_pri_pkt_tx_ctrl[txpd->priority]); |
| 414 | |
| 415 | /* Offset of actual data */ |
Xinming Hu | 84b313b3 | 2014-12-26 03:02:33 -0800 | [diff] [blame] | 416 | pkt_offset = sizeof(*txpd) + pad; |
Stone Piao | 3215215 | 2012-09-25 20:23:44 -0700 | [diff] [blame] | 417 | if (pkt_type == PKT_TYPE_MGMT) { |
| 418 | /* Set the packet type and add header for management frame */ |
| 419 | txpd->tx_pkt_type = cpu_to_le16(pkt_type); |
Xinming Hu | 84b313b3 | 2014-12-26 03:02:33 -0800 | [diff] [blame] | 420 | pkt_offset += MWIFIEX_MGMT_FRAME_HEADER_SIZE; |
Stone Piao | 3215215 | 2012-09-25 20:23:44 -0700 | [diff] [blame] | 421 | } |
| 422 | |
Xinming Hu | 84b313b3 | 2014-12-26 03:02:33 -0800 | [diff] [blame] | 423 | txpd->tx_pkt_offset = cpu_to_le16(pkt_offset); |
Avinash Patil | 4ac8764 | 2012-09-10 18:30:49 -0700 | [diff] [blame] | 424 | |
| 425 | /* make space for INTF_HEADER_LEN */ |
Xinming Hu | 84b313b3 | 2014-12-26 03:02:33 -0800 | [diff] [blame] | 426 | skb_push(skb, hroom); |
Avinash Patil | 4ac8764 | 2012-09-10 18:30:49 -0700 | [diff] [blame] | 427 | |
| 428 | if (!txpd->tx_control) |
| 429 | /* TxCtrl set by user or default */ |
| 430 | txpd->tx_control = cpu_to_le32(priv->pkt_tx_ctrl); |
| 431 | |
| 432 | return skb->data; |
| 433 | } |