Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Marvell Wireless LAN device driver: 802.11n RX Re-ordering |
| 3 | * |
| 4 | * Copyright (C) 2011, Marvell International Ltd. |
| 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 | #include "11n.h" |
| 27 | #include "11n_rxreorder.h" |
| 28 | |
| 29 | /* |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 30 | * This function dispatches all packets in the Rx reorder table until the |
| 31 | * start window. |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 32 | * |
| 33 | * There could be holes in the buffer, which are skipped by the function. |
| 34 | * Since the buffer is linear, the function uses rotation to simulate |
| 35 | * circular buffer. |
| 36 | */ |
Yogesh Ashok Powar | ab58147 | 2011-11-07 21:41:08 -0800 | [diff] [blame] | 37 | static void |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 38 | mwifiex_11n_dispatch_pkt(struct mwifiex_private *priv, |
| 39 | struct mwifiex_rx_reorder_tbl *tbl, int start_win) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 40 | { |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 41 | int pkt_to_send, i; |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 42 | void *rx_tmp_ptr; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 43 | unsigned long flags; |
| 44 | |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 45 | pkt_to_send = (start_win > tbl->start_win) ? |
| 46 | min((start_win - tbl->start_win), tbl->win_size) : |
| 47 | tbl->win_size; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 48 | |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 49 | for (i = 0; i < pkt_to_send; ++i) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 50 | spin_lock_irqsave(&priv->rx_pkt_lock, flags); |
| 51 | rx_tmp_ptr = NULL; |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 52 | if (tbl->rx_reorder_ptr[i]) { |
| 53 | rx_tmp_ptr = tbl->rx_reorder_ptr[i]; |
| 54 | tbl->rx_reorder_ptr[i] = NULL; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 55 | } |
| 56 | spin_unlock_irqrestore(&priv->rx_pkt_lock, flags); |
Avinash Patil | d1cf3b9 | 2012-08-03 18:06:09 -0700 | [diff] [blame] | 57 | if (rx_tmp_ptr) { |
| 58 | if (priv->bss_role == MWIFIEX_BSS_ROLE_UAP) |
| 59 | mwifiex_handle_uap_rx_forward(priv, rx_tmp_ptr); |
| 60 | else |
Avinash Patil | f3b369e | 2012-10-19 19:19:21 -0700 | [diff] [blame^] | 61 | mwifiex_process_rx_packet(priv, rx_tmp_ptr); |
Avinash Patil | d1cf3b9 | 2012-08-03 18:06:09 -0700 | [diff] [blame] | 62 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | spin_lock_irqsave(&priv->rx_pkt_lock, flags); |
| 66 | /* |
| 67 | * We don't have a circular buffer, hence use rotation to simulate |
| 68 | * circular buffer |
| 69 | */ |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 70 | for (i = 0; i < tbl->win_size - pkt_to_send; ++i) { |
| 71 | tbl->rx_reorder_ptr[i] = tbl->rx_reorder_ptr[pkt_to_send + i]; |
| 72 | tbl->rx_reorder_ptr[pkt_to_send + i] = NULL; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 73 | } |
| 74 | |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 75 | tbl->start_win = start_win; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 76 | spin_unlock_irqrestore(&priv->rx_pkt_lock, flags); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | /* |
| 80 | * This function dispatches all packets in the Rx reorder table until |
| 81 | * a hole is found. |
| 82 | * |
| 83 | * The start window is adjusted automatically when a hole is located. |
| 84 | * Since the buffer is linear, the function uses rotation to simulate |
| 85 | * circular buffer. |
| 86 | */ |
Yogesh Ashok Powar | ab58147 | 2011-11-07 21:41:08 -0800 | [diff] [blame] | 87 | static void |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 88 | mwifiex_11n_scan_and_dispatch(struct mwifiex_private *priv, |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 89 | struct mwifiex_rx_reorder_tbl *tbl) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 90 | { |
| 91 | int i, j, xchg; |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 92 | void *rx_tmp_ptr; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 93 | unsigned long flags; |
| 94 | |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 95 | for (i = 0; i < tbl->win_size; ++i) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 96 | spin_lock_irqsave(&priv->rx_pkt_lock, flags); |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 97 | if (!tbl->rx_reorder_ptr[i]) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 98 | spin_unlock_irqrestore(&priv->rx_pkt_lock, flags); |
| 99 | break; |
| 100 | } |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 101 | rx_tmp_ptr = tbl->rx_reorder_ptr[i]; |
| 102 | tbl->rx_reorder_ptr[i] = NULL; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 103 | spin_unlock_irqrestore(&priv->rx_pkt_lock, flags); |
Avinash Patil | d1cf3b9 | 2012-08-03 18:06:09 -0700 | [diff] [blame] | 104 | |
| 105 | if (priv->bss_role == MWIFIEX_BSS_ROLE_UAP) |
| 106 | mwifiex_handle_uap_rx_forward(priv, rx_tmp_ptr); |
| 107 | else |
Avinash Patil | f3b369e | 2012-10-19 19:19:21 -0700 | [diff] [blame^] | 108 | mwifiex_process_rx_packet(priv, rx_tmp_ptr); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | spin_lock_irqsave(&priv->rx_pkt_lock, flags); |
| 112 | /* |
| 113 | * We don't have a circular buffer, hence use rotation to simulate |
| 114 | * circular buffer |
| 115 | */ |
| 116 | if (i > 0) { |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 117 | xchg = tbl->win_size - i; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 118 | for (j = 0; j < xchg; ++j) { |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 119 | tbl->rx_reorder_ptr[j] = tbl->rx_reorder_ptr[i + j]; |
| 120 | tbl->rx_reorder_ptr[i + j] = NULL; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 121 | } |
| 122 | } |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 123 | tbl->start_win = (tbl->start_win + i) & (MAX_TID_VALUE - 1); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 124 | spin_unlock_irqrestore(&priv->rx_pkt_lock, flags); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | /* |
| 128 | * This function deletes the Rx reorder table and frees the memory. |
| 129 | * |
| 130 | * The function stops the associated timer and dispatches all the |
| 131 | * pending packets in the Rx reorder table before deletion. |
| 132 | */ |
| 133 | static void |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 134 | mwifiex_del_rx_reorder_entry(struct mwifiex_private *priv, |
| 135 | struct mwifiex_rx_reorder_tbl *tbl) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 136 | { |
| 137 | unsigned long flags; |
| 138 | |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 139 | if (!tbl) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 140 | return; |
| 141 | |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 142 | mwifiex_11n_dispatch_pkt(priv, tbl, (tbl->start_win + tbl->win_size) & |
| 143 | (MAX_TID_VALUE - 1)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 144 | |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 145 | del_timer(&tbl->timer_context.timer); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 146 | |
| 147 | spin_lock_irqsave(&priv->rx_reorder_tbl_lock, flags); |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 148 | list_del(&tbl->list); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 149 | spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock, flags); |
| 150 | |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 151 | kfree(tbl->rx_reorder_ptr); |
| 152 | kfree(tbl); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | /* |
| 156 | * This function returns the pointer to an entry in Rx reordering |
| 157 | * table which matches the given TA/TID pair. |
| 158 | */ |
Avinash Patil | d1cf3b9 | 2012-08-03 18:06:09 -0700 | [diff] [blame] | 159 | struct mwifiex_rx_reorder_tbl * |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 160 | mwifiex_11n_get_rx_reorder_tbl(struct mwifiex_private *priv, int tid, u8 *ta) |
| 161 | { |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 162 | struct mwifiex_rx_reorder_tbl *tbl; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 163 | unsigned long flags; |
| 164 | |
| 165 | spin_lock_irqsave(&priv->rx_reorder_tbl_lock, flags); |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 166 | list_for_each_entry(tbl, &priv->rx_reorder_tbl_ptr, list) { |
| 167 | if (!memcmp(tbl->ta, ta, ETH_ALEN) && tbl->tid == tid) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 168 | spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock, |
| 169 | flags); |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 170 | return tbl; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 171 | } |
| 172 | } |
| 173 | spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock, flags); |
| 174 | |
| 175 | return NULL; |
| 176 | } |
| 177 | |
Avinash Patil | 3e238a1 | 2012-08-03 18:06:11 -0700 | [diff] [blame] | 178 | /* This function retrieves the pointer to an entry in Rx reordering |
| 179 | * table which matches the given TA and deletes it. |
| 180 | */ |
| 181 | void mwifiex_11n_del_rx_reorder_tbl_by_ta(struct mwifiex_private *priv, u8 *ta) |
| 182 | { |
| 183 | struct mwifiex_rx_reorder_tbl *tbl, *tmp; |
| 184 | unsigned long flags; |
| 185 | |
| 186 | if (!ta) |
| 187 | return; |
| 188 | |
| 189 | spin_lock_irqsave(&priv->rx_reorder_tbl_lock, flags); |
| 190 | list_for_each_entry_safe(tbl, tmp, &priv->rx_reorder_tbl_ptr, list) { |
| 191 | if (!memcmp(tbl->ta, ta, ETH_ALEN)) { |
| 192 | spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock, |
| 193 | flags); |
| 194 | mwifiex_del_rx_reorder_entry(priv, tbl); |
| 195 | spin_lock_irqsave(&priv->rx_reorder_tbl_lock, flags); |
| 196 | } |
| 197 | } |
| 198 | spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock, flags); |
| 199 | |
| 200 | return; |
| 201 | } |
| 202 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 203 | /* |
| 204 | * This function finds the last sequence number used in the packets |
| 205 | * buffered in Rx reordering table. |
| 206 | */ |
| 207 | static int |
| 208 | mwifiex_11n_find_last_seq_num(struct mwifiex_rx_reorder_tbl *rx_reorder_tbl_ptr) |
| 209 | { |
| 210 | int i; |
| 211 | |
| 212 | for (i = (rx_reorder_tbl_ptr->win_size - 1); i >= 0; --i) |
| 213 | if (rx_reorder_tbl_ptr->rx_reorder_ptr[i]) |
| 214 | return i; |
| 215 | |
| 216 | return -1; |
| 217 | } |
| 218 | |
| 219 | /* |
| 220 | * This function flushes all the packets in Rx reordering table. |
| 221 | * |
| 222 | * The function checks if any packets are currently buffered in the |
| 223 | * table or not. In case there are packets available, it dispatches |
| 224 | * them and then dumps the Rx reordering table. |
| 225 | */ |
| 226 | static void |
| 227 | mwifiex_flush_data(unsigned long context) |
| 228 | { |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 229 | struct reorder_tmr_cnxt *ctx = |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 230 | (struct reorder_tmr_cnxt *) context; |
| 231 | int start_win; |
| 232 | |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 233 | start_win = mwifiex_11n_find_last_seq_num(ctx->ptr); |
Yogesh Ashok Powar | bb7de2b | 2012-03-12 19:35:12 -0700 | [diff] [blame] | 234 | |
| 235 | if (start_win < 0) |
| 236 | return; |
| 237 | |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 238 | dev_dbg(ctx->priv->adapter->dev, "info: flush data %d\n", start_win); |
| 239 | mwifiex_11n_dispatch_pkt(ctx->priv, ctx->ptr, |
| 240 | (ctx->ptr->start_win + start_win + 1) & |
| 241 | (MAX_TID_VALUE - 1)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | /* |
| 245 | * This function creates an entry in Rx reordering table for the |
| 246 | * given TA/TID. |
| 247 | * |
| 248 | * The function also initializes the entry with sequence number, window |
| 249 | * size as well as initializes the timer. |
| 250 | * |
| 251 | * If the received TA/TID pair is already present, all the packets are |
| 252 | * dispatched and the window size is moved until the SSN. |
| 253 | */ |
| 254 | static void |
| 255 | mwifiex_11n_create_rx_reorder_tbl(struct mwifiex_private *priv, u8 *ta, |
Yogesh Ashok Powar | 8426684 | 2012-03-13 19:22:34 -0700 | [diff] [blame] | 256 | int tid, int win_size, int seq_num) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 257 | { |
| 258 | int i; |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 259 | struct mwifiex_rx_reorder_tbl *tbl, *new_node; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 260 | u16 last_seq = 0; |
| 261 | unsigned long flags; |
Avinash Patil | 5a009ad | 2012-08-03 18:06:10 -0700 | [diff] [blame] | 262 | struct mwifiex_sta_node *node; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 263 | |
| 264 | /* |
| 265 | * If we get a TID, ta pair which is already present dispatch all the |
| 266 | * the packets and move the window size until the ssn |
| 267 | */ |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 268 | tbl = mwifiex_11n_get_rx_reorder_tbl(priv, tid, ta); |
| 269 | if (tbl) { |
| 270 | mwifiex_11n_dispatch_pkt(priv, tbl, seq_num); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 271 | return; |
| 272 | } |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 273 | /* if !tbl then create one */ |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 274 | new_node = kzalloc(sizeof(struct mwifiex_rx_reorder_tbl), GFP_KERNEL); |
| 275 | if (!new_node) { |
| 276 | dev_err(priv->adapter->dev, "%s: failed to alloc new_node\n", |
Yogesh Ashok Powar | 8426684 | 2012-03-13 19:22:34 -0700 | [diff] [blame] | 277 | __func__); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 278 | return; |
| 279 | } |
| 280 | |
| 281 | INIT_LIST_HEAD(&new_node->list); |
| 282 | new_node->tid = tid; |
| 283 | memcpy(new_node->ta, ta, ETH_ALEN); |
| 284 | new_node->start_win = seq_num; |
Avinash Patil | 5a009ad | 2012-08-03 18:06:10 -0700 | [diff] [blame] | 285 | |
| 286 | if (mwifiex_queuing_ra_based(priv)) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 287 | dev_dbg(priv->adapter->dev, |
Avinash Patil | 5a009ad | 2012-08-03 18:06:10 -0700 | [diff] [blame] | 288 | "info: AP/ADHOC:last_seq=%d start_win=%d\n", |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 289 | last_seq, new_node->start_win); |
Avinash Patil | 5a009ad | 2012-08-03 18:06:10 -0700 | [diff] [blame] | 290 | if (priv->bss_role == MWIFIEX_BSS_ROLE_UAP) { |
| 291 | node = mwifiex_get_sta_entry(priv, ta); |
| 292 | if (node) |
| 293 | last_seq = node->rx_seq[tid]; |
| 294 | } |
| 295 | } else { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 296 | last_seq = priv->rx_seq[tid]; |
Avinash Patil | 5a009ad | 2012-08-03 18:06:10 -0700 | [diff] [blame] | 297 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 298 | |
Stone Piao | 9258392 | 2012-06-20 20:21:10 -0700 | [diff] [blame] | 299 | if (last_seq != MWIFIEX_DEF_11N_RX_SEQ_NUM && |
| 300 | last_seq >= new_node->start_win) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 301 | new_node->start_win = last_seq + 1; |
| 302 | |
| 303 | new_node->win_size = win_size; |
Avinash Patil | 2db96c3 | 2012-09-27 19:00:10 -0700 | [diff] [blame] | 304 | new_node->flags = 0; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 305 | |
| 306 | new_node->rx_reorder_ptr = kzalloc(sizeof(void *) * win_size, |
| 307 | GFP_KERNEL); |
| 308 | if (!new_node->rx_reorder_ptr) { |
| 309 | kfree((u8 *) new_node); |
| 310 | dev_err(priv->adapter->dev, |
| 311 | "%s: failed to alloc reorder_ptr\n", __func__); |
| 312 | return; |
| 313 | } |
| 314 | |
| 315 | new_node->timer_context.ptr = new_node; |
| 316 | new_node->timer_context.priv = priv; |
| 317 | |
| 318 | init_timer(&new_node->timer_context.timer); |
| 319 | new_node->timer_context.timer.function = mwifiex_flush_data; |
| 320 | new_node->timer_context.timer.data = |
| 321 | (unsigned long) &new_node->timer_context; |
| 322 | |
| 323 | for (i = 0; i < win_size; ++i) |
| 324 | new_node->rx_reorder_ptr[i] = NULL; |
| 325 | |
| 326 | spin_lock_irqsave(&priv->rx_reorder_tbl_lock, flags); |
| 327 | list_add_tail(&new_node->list, &priv->rx_reorder_tbl_ptr); |
| 328 | spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock, flags); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 329 | } |
| 330 | |
| 331 | /* |
| 332 | * This function prepares command for adding a BA request. |
| 333 | * |
| 334 | * Preparation includes - |
| 335 | * - Setting command ID and proper size |
| 336 | * - Setting add BA request buffer |
| 337 | * - Ensuring correct endian-ness |
| 338 | */ |
Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 339 | int mwifiex_cmd_11n_addba_req(struct host_cmd_ds_command *cmd, void *data_buf) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 340 | { |
Joe Perches | 2c20889 | 2012-06-04 12:44:17 +0000 | [diff] [blame] | 341 | struct host_cmd_ds_11n_addba_req *add_ba_req = &cmd->params.add_ba_req; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 342 | |
| 343 | cmd->command = cpu_to_le16(HostCmd_CMD_11N_ADDBA_REQ); |
| 344 | cmd->size = cpu_to_le16(sizeof(*add_ba_req) + S_DS_GEN); |
| 345 | memcpy(add_ba_req, data_buf, sizeof(*add_ba_req)); |
| 346 | |
| 347 | return 0; |
| 348 | } |
| 349 | |
| 350 | /* |
| 351 | * This function prepares command for adding a BA response. |
| 352 | * |
| 353 | * Preparation includes - |
| 354 | * - Setting command ID and proper size |
| 355 | * - Setting add BA response buffer |
| 356 | * - Ensuring correct endian-ness |
| 357 | */ |
| 358 | int mwifiex_cmd_11n_addba_rsp_gen(struct mwifiex_private *priv, |
| 359 | struct host_cmd_ds_command *cmd, |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 360 | struct host_cmd_ds_11n_addba_req |
| 361 | *cmd_addba_req) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 362 | { |
Joe Perches | 2c20889 | 2012-06-04 12:44:17 +0000 | [diff] [blame] | 363 | struct host_cmd_ds_11n_addba_rsp *add_ba_rsp = &cmd->params.add_ba_rsp; |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 364 | u8 tid; |
| 365 | int win_size; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 366 | uint16_t block_ack_param_set; |
| 367 | |
| 368 | cmd->command = cpu_to_le16(HostCmd_CMD_11N_ADDBA_RSP); |
| 369 | cmd->size = cpu_to_le16(sizeof(*add_ba_rsp) + S_DS_GEN); |
| 370 | |
| 371 | memcpy(add_ba_rsp->peer_mac_addr, cmd_addba_req->peer_mac_addr, |
| 372 | ETH_ALEN); |
| 373 | add_ba_rsp->dialog_token = cmd_addba_req->dialog_token; |
| 374 | add_ba_rsp->block_ack_tmo = cmd_addba_req->block_ack_tmo; |
| 375 | add_ba_rsp->ssn = cmd_addba_req->ssn; |
| 376 | |
| 377 | block_ack_param_set = le16_to_cpu(cmd_addba_req->block_ack_param_set); |
| 378 | tid = (block_ack_param_set & IEEE80211_ADDBA_PARAM_TID_MASK) |
| 379 | >> BLOCKACKPARAM_TID_POS; |
| 380 | add_ba_rsp->status_code = cpu_to_le16(ADDBA_RSP_STATUS_ACCEPT); |
| 381 | block_ack_param_set &= ~IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK; |
| 382 | /* We donot support AMSDU inside AMPDU, hence reset the bit */ |
| 383 | block_ack_param_set &= ~BLOCKACKPARAM_AMSDU_SUPP_MASK; |
| 384 | block_ack_param_set |= (priv->add_ba_param.rx_win_size << |
| 385 | BLOCKACKPARAM_WINSIZE_POS); |
| 386 | add_ba_rsp->block_ack_param_set = cpu_to_le16(block_ack_param_set); |
| 387 | win_size = (le16_to_cpu(add_ba_rsp->block_ack_param_set) |
| 388 | & IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK) |
| 389 | >> BLOCKACKPARAM_WINSIZE_POS; |
| 390 | cmd_addba_req->block_ack_param_set = cpu_to_le16(block_ack_param_set); |
| 391 | |
| 392 | mwifiex_11n_create_rx_reorder_tbl(priv, cmd_addba_req->peer_mac_addr, |
Yogesh Ashok Powar | 8426684 | 2012-03-13 19:22:34 -0700 | [diff] [blame] | 393 | tid, win_size, |
| 394 | le16_to_cpu(cmd_addba_req->ssn)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 395 | return 0; |
| 396 | } |
| 397 | |
| 398 | /* |
| 399 | * This function prepares command for deleting a BA request. |
| 400 | * |
| 401 | * Preparation includes - |
| 402 | * - Setting command ID and proper size |
| 403 | * - Setting del BA request buffer |
| 404 | * - Ensuring correct endian-ness |
| 405 | */ |
Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 406 | int mwifiex_cmd_11n_delba(struct host_cmd_ds_command *cmd, void *data_buf) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 407 | { |
Joe Perches | 2c20889 | 2012-06-04 12:44:17 +0000 | [diff] [blame] | 408 | struct host_cmd_ds_11n_delba *del_ba = &cmd->params.del_ba; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 409 | |
| 410 | cmd->command = cpu_to_le16(HostCmd_CMD_11N_DELBA); |
| 411 | cmd->size = cpu_to_le16(sizeof(*del_ba) + S_DS_GEN); |
| 412 | memcpy(del_ba, data_buf, sizeof(*del_ba)); |
| 413 | |
| 414 | return 0; |
| 415 | } |
| 416 | |
| 417 | /* |
| 418 | * This function identifies if Rx reordering is needed for a received packet. |
| 419 | * |
| 420 | * In case reordering is required, the function will do the reordering |
| 421 | * before sending it to kernel. |
| 422 | * |
| 423 | * The Rx reorder table is checked first with the received TID/TA pair. If |
| 424 | * not found, the received packet is dispatched immediately. But if found, |
| 425 | * the packet is reordered and all the packets in the updated Rx reordering |
| 426 | * table is dispatched until a hole is found. |
| 427 | * |
| 428 | * For sequence number less than the starting window, the packet is dropped. |
| 429 | */ |
| 430 | int mwifiex_11n_rx_reorder_pkt(struct mwifiex_private *priv, |
| 431 | u16 seq_num, u16 tid, |
| 432 | u8 *ta, u8 pkt_type, void *payload) |
| 433 | { |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 434 | struct mwifiex_rx_reorder_tbl *tbl; |
Yogesh Ashok Powar | ab58147 | 2011-11-07 21:41:08 -0800 | [diff] [blame] | 435 | int start_win, end_win, win_size; |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 436 | u16 pkt_index; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 437 | |
Joe Perches | 2c20889 | 2012-06-04 12:44:17 +0000 | [diff] [blame] | 438 | tbl = mwifiex_11n_get_rx_reorder_tbl(priv, tid, ta); |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 439 | if (!tbl) { |
Avinash Patil | d1cf3b9 | 2012-08-03 18:06:09 -0700 | [diff] [blame] | 440 | if (pkt_type != PKT_TYPE_BAR) { |
| 441 | if (priv->bss_role == MWIFIEX_BSS_ROLE_UAP) |
| 442 | mwifiex_handle_uap_rx_forward(priv, payload); |
| 443 | else |
Avinash Patil | f3b369e | 2012-10-19 19:19:21 -0700 | [diff] [blame^] | 444 | mwifiex_process_rx_packet(priv, payload); |
Avinash Patil | d1cf3b9 | 2012-08-03 18:06:09 -0700 | [diff] [blame] | 445 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 446 | return 0; |
| 447 | } |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 448 | start_win = tbl->start_win; |
| 449 | win_size = tbl->win_size; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 450 | end_win = ((start_win + win_size) - 1) & (MAX_TID_VALUE - 1); |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 451 | del_timer(&tbl->timer_context.timer); |
| 452 | mod_timer(&tbl->timer_context.timer, |
| 453 | jiffies + (MIN_FLUSH_TIMER_MS * win_size * HZ) / 1000); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 454 | |
| 455 | /* |
| 456 | * If seq_num is less then starting win then ignore and drop the |
| 457 | * packet |
| 458 | */ |
Avinash Patil | 2db96c3 | 2012-09-27 19:00:10 -0700 | [diff] [blame] | 459 | if (tbl->flags & RXREOR_FORCE_NO_DROP) { |
| 460 | dev_dbg(priv->adapter->dev, |
| 461 | "RXREOR_FORCE_NO_DROP when HS is activated\n"); |
| 462 | tbl->flags &= ~RXREOR_FORCE_NO_DROP; |
| 463 | } else { |
| 464 | if ((start_win + TWOPOW11) > (MAX_TID_VALUE - 1)) { |
| 465 | if (seq_num >= ((start_win + TWOPOW11) & |
| 466 | (MAX_TID_VALUE - 1)) && |
| 467 | seq_num < start_win) |
| 468 | return -1; |
| 469 | } else if ((seq_num < start_win) || |
| 470 | (seq_num > (start_win + TWOPOW11))) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 471 | return -1; |
Avinash Patil | 2db96c3 | 2012-09-27 19:00:10 -0700 | [diff] [blame] | 472 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 473 | } |
| 474 | |
| 475 | /* |
| 476 | * If this packet is a BAR we adjust seq_num as |
| 477 | * WinStart = seq_num |
| 478 | */ |
| 479 | if (pkt_type == PKT_TYPE_BAR) |
| 480 | seq_num = ((seq_num + win_size) - 1) & (MAX_TID_VALUE - 1); |
| 481 | |
Yogesh Ashok Powar | 8426684 | 2012-03-13 19:22:34 -0700 | [diff] [blame] | 482 | if (((end_win < start_win) && |
Avinash Patil | 2db96c3 | 2012-09-27 19:00:10 -0700 | [diff] [blame] | 483 | (seq_num < start_win) && (seq_num > end_win)) || |
Yogesh Ashok Powar | 8426684 | 2012-03-13 19:22:34 -0700 | [diff] [blame] | 484 | ((end_win > start_win) && ((seq_num > end_win) || |
| 485 | (seq_num < start_win)))) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 486 | end_win = seq_num; |
| 487 | if (((seq_num - win_size) + 1) >= 0) |
| 488 | start_win = (end_win - win_size) + 1; |
| 489 | else |
| 490 | start_win = (MAX_TID_VALUE - (win_size - seq_num)) + 1; |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 491 | mwifiex_11n_dispatch_pkt(priv, tbl, start_win); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 492 | } |
| 493 | |
| 494 | if (pkt_type != PKT_TYPE_BAR) { |
| 495 | if (seq_num >= start_win) |
| 496 | pkt_index = seq_num - start_win; |
| 497 | else |
| 498 | pkt_index = (seq_num+MAX_TID_VALUE) - start_win; |
| 499 | |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 500 | if (tbl->rx_reorder_ptr[pkt_index]) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 501 | return -1; |
| 502 | |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 503 | tbl->rx_reorder_ptr[pkt_index] = payload; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 504 | } |
| 505 | |
| 506 | /* |
| 507 | * Dispatch all packets sequentially from start_win until a |
| 508 | * hole is found and adjust the start_win appropriately |
| 509 | */ |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 510 | mwifiex_11n_scan_and_dispatch(priv, tbl); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 511 | |
Yogesh Ashok Powar | ab58147 | 2011-11-07 21:41:08 -0800 | [diff] [blame] | 512 | return 0; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 513 | } |
| 514 | |
| 515 | /* |
| 516 | * This function deletes an entry for a given TID/TA pair. |
| 517 | * |
| 518 | * The TID/TA are taken from del BA event body. |
| 519 | */ |
| 520 | void |
Yogesh Ashok Powar | 3e82263 | 2012-03-12 19:35:08 -0700 | [diff] [blame] | 521 | mwifiex_del_ba_tbl(struct mwifiex_private *priv, int tid, u8 *peer_mac, |
| 522 | u8 type, int initiator) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 523 | { |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 524 | struct mwifiex_rx_reorder_tbl *tbl; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 525 | struct mwifiex_tx_ba_stream_tbl *ptx_tbl; |
| 526 | u8 cleanup_rx_reorder_tbl; |
| 527 | unsigned long flags; |
| 528 | |
| 529 | if (type == TYPE_DELBA_RECEIVE) |
| 530 | cleanup_rx_reorder_tbl = (initiator) ? true : false; |
| 531 | else |
| 532 | cleanup_rx_reorder_tbl = (initiator) ? false : true; |
| 533 | |
Yogesh Ashok Powar | 8426684 | 2012-03-13 19:22:34 -0700 | [diff] [blame] | 534 | dev_dbg(priv->adapter->dev, "event: DELBA: %pM tid=%d initiator=%d\n", |
| 535 | peer_mac, tid, initiator); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 536 | |
| 537 | if (cleanup_rx_reorder_tbl) { |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 538 | tbl = mwifiex_11n_get_rx_reorder_tbl(priv, tid, |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 539 | peer_mac); |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 540 | if (!tbl) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 541 | dev_dbg(priv->adapter->dev, |
Yogesh Ashok Powar | 8426684 | 2012-03-13 19:22:34 -0700 | [diff] [blame] | 542 | "event: TID, TA not found in table\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 543 | return; |
| 544 | } |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 545 | mwifiex_del_rx_reorder_entry(priv, tbl); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 546 | } else { |
Yogesh Ashok Powar | 3e82263 | 2012-03-12 19:35:08 -0700 | [diff] [blame] | 547 | ptx_tbl = mwifiex_get_ba_tbl(priv, tid, peer_mac); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 548 | if (!ptx_tbl) { |
| 549 | dev_dbg(priv->adapter->dev, |
Yogesh Ashok Powar | 8426684 | 2012-03-13 19:22:34 -0700 | [diff] [blame] | 550 | "event: TID, RA not found in table\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 551 | return; |
| 552 | } |
| 553 | |
| 554 | spin_lock_irqsave(&priv->tx_ba_stream_tbl_lock, flags); |
| 555 | mwifiex_11n_delete_tx_ba_stream_tbl_entry(priv, ptx_tbl); |
| 556 | spin_unlock_irqrestore(&priv->tx_ba_stream_tbl_lock, flags); |
| 557 | } |
| 558 | } |
| 559 | |
| 560 | /* |
| 561 | * This function handles the command response of an add BA response. |
| 562 | * |
| 563 | * Handling includes changing the header fields into CPU format and |
| 564 | * creating the stream, provided the add BA is accepted. |
| 565 | */ |
| 566 | int mwifiex_ret_11n_addba_resp(struct mwifiex_private *priv, |
| 567 | struct host_cmd_ds_command *resp) |
| 568 | { |
Joe Perches | 2c20889 | 2012-06-04 12:44:17 +0000 | [diff] [blame] | 569 | struct host_cmd_ds_11n_addba_rsp *add_ba_rsp = &resp->params.add_ba_rsp; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 570 | int tid, win_size; |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 571 | struct mwifiex_rx_reorder_tbl *tbl; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 572 | uint16_t block_ack_param_set; |
| 573 | |
| 574 | block_ack_param_set = le16_to_cpu(add_ba_rsp->block_ack_param_set); |
| 575 | |
| 576 | tid = (block_ack_param_set & IEEE80211_ADDBA_PARAM_TID_MASK) |
| 577 | >> BLOCKACKPARAM_TID_POS; |
| 578 | /* |
| 579 | * Check if we had rejected the ADDBA, if yes then do not create |
| 580 | * the stream |
| 581 | */ |
| 582 | if (le16_to_cpu(add_ba_rsp->status_code) == BA_RESULT_SUCCESS) { |
| 583 | win_size = (block_ack_param_set & |
| 584 | IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK) |
| 585 | >> BLOCKACKPARAM_WINSIZE_POS; |
| 586 | |
Yogesh Ashok Powar | 8426684 | 2012-03-13 19:22:34 -0700 | [diff] [blame] | 587 | dev_dbg(priv->adapter->dev, |
| 588 | "cmd: ADDBA RSP: %pM tid=%d ssn=%d win_size=%d\n", |
| 589 | add_ba_rsp->peer_mac_addr, tid, |
| 590 | add_ba_rsp->ssn, win_size); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 591 | } else { |
| 592 | dev_err(priv->adapter->dev, "ADDBA RSP: failed %pM tid=%d)\n", |
Yogesh Ashok Powar | 8426684 | 2012-03-13 19:22:34 -0700 | [diff] [blame] | 593 | add_ba_rsp->peer_mac_addr, tid); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 594 | |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 595 | tbl = mwifiex_11n_get_rx_reorder_tbl(priv, tid, |
| 596 | add_ba_rsp->peer_mac_addr); |
| 597 | if (tbl) |
| 598 | mwifiex_del_rx_reorder_entry(priv, tbl); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 599 | } |
| 600 | |
| 601 | return 0; |
| 602 | } |
| 603 | |
| 604 | /* |
| 605 | * This function handles BA stream timeout event by preparing and sending |
| 606 | * a command to the firmware. |
| 607 | */ |
| 608 | void mwifiex_11n_ba_stream_timeout(struct mwifiex_private *priv, |
| 609 | struct host_cmd_ds_11n_batimeout *event) |
| 610 | { |
| 611 | struct host_cmd_ds_11n_delba delba; |
| 612 | |
| 613 | memset(&delba, 0, sizeof(struct host_cmd_ds_11n_delba)); |
| 614 | memcpy(delba.peer_mac_addr, event->peer_mac_addr, ETH_ALEN); |
| 615 | |
| 616 | delba.del_ba_param_set |= |
| 617 | cpu_to_le16((u16) event->tid << DELBA_TID_POS); |
| 618 | delba.del_ba_param_set |= cpu_to_le16( |
| 619 | (u16) event->origninator << DELBA_INITIATOR_POS); |
| 620 | delba.reason_code = cpu_to_le16(WLAN_REASON_QSTA_TIMEOUT); |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 621 | mwifiex_send_cmd_async(priv, HostCmd_CMD_11N_DELBA, 0, 0, &delba); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 622 | } |
| 623 | |
| 624 | /* |
| 625 | * This function cleans up the Rx reorder table by deleting all the entries |
| 626 | * and re-initializing. |
| 627 | */ |
| 628 | void mwifiex_11n_cleanup_reorder_tbl(struct mwifiex_private *priv) |
| 629 | { |
| 630 | struct mwifiex_rx_reorder_tbl *del_tbl_ptr, *tmp_node; |
| 631 | unsigned long flags; |
| 632 | |
| 633 | spin_lock_irqsave(&priv->rx_reorder_tbl_lock, flags); |
| 634 | list_for_each_entry_safe(del_tbl_ptr, tmp_node, |
| 635 | &priv->rx_reorder_tbl_ptr, list) { |
| 636 | spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock, flags); |
Yogesh Ashok Powar | 8c00228 | 2012-03-12 19:35:13 -0700 | [diff] [blame] | 637 | mwifiex_del_rx_reorder_entry(priv, del_tbl_ptr); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 638 | spin_lock_irqsave(&priv->rx_reorder_tbl_lock, flags); |
| 639 | } |
| 640 | spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock, flags); |
| 641 | |
| 642 | INIT_LIST_HEAD(&priv->rx_reorder_tbl_ptr); |
Stone Piao | 9258392 | 2012-06-20 20:21:10 -0700 | [diff] [blame] | 643 | mwifiex_reset_11n_rx_seq_num(priv); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 644 | } |
Avinash Patil | 2db96c3 | 2012-09-27 19:00:10 -0700 | [diff] [blame] | 645 | |
| 646 | /* |
| 647 | * This function updates all rx_reorder_tbl's flags. |
| 648 | */ |
| 649 | void mwifiex_update_rxreor_flags(struct mwifiex_adapter *adapter, u8 flags) |
| 650 | { |
| 651 | struct mwifiex_private *priv; |
| 652 | struct mwifiex_rx_reorder_tbl *tbl; |
| 653 | unsigned long lock_flags; |
| 654 | int i; |
| 655 | |
| 656 | for (i = 0; i < adapter->priv_num; i++) { |
| 657 | priv = adapter->priv[i]; |
| 658 | if (!priv) |
| 659 | continue; |
| 660 | if (list_empty(&priv->rx_reorder_tbl_ptr)) |
| 661 | continue; |
| 662 | |
| 663 | spin_lock_irqsave(&priv->rx_reorder_tbl_lock, lock_flags); |
| 664 | list_for_each_entry(tbl, &priv->rx_reorder_tbl_ptr, list) |
| 665 | tbl->flags = flags; |
| 666 | spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock, lock_flags); |
| 667 | } |
| 668 | |
| 669 | return; |
| 670 | } |