Commit | Line | Data |
---|---|---|
5e6e3a92 BZ |
1 | /* |
2 | * Marvell Wireless LAN device driver: 802.11n RX Re-ordering | |
3 | * | |
65da33f5 | 4 | * Copyright (C) 2011-2014, Marvell International Ltd. |
5e6e3a92 BZ |
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 | ||
4c9f9fb2 AK |
29 | /* This function will dispatch amsdu packet and forward it to kernel/upper |
30 | * layer. | |
31 | */ | |
32 | static int mwifiex_11n_dispatch_amsdu_pkt(struct mwifiex_private *priv, | |
33 | struct sk_buff *skb) | |
34 | { | |
35 | struct rxpd *local_rx_pd = (struct rxpd *)(skb->data); | |
36 | int ret; | |
37 | ||
38 | if (le16_to_cpu(local_rx_pd->rx_pkt_type) == PKT_TYPE_AMSDU) { | |
39 | struct sk_buff_head list; | |
40 | struct sk_buff *rx_skb; | |
41 | ||
42 | __skb_queue_head_init(&list); | |
43 | ||
44 | skb_pull(skb, le16_to_cpu(local_rx_pd->rx_pkt_offset)); | |
45 | skb_trim(skb, le16_to_cpu(local_rx_pd->rx_pkt_length)); | |
46 | ||
47 | ieee80211_amsdu_to_8023s(skb, &list, priv->curr_addr, | |
4facc34a | 48 | priv->wdev.iftype, 0, false); |
4c9f9fb2 AK |
49 | |
50 | while (!skb_queue_empty(&list)) { | |
776f7420 AK |
51 | struct rx_packet_hdr *rx_hdr; |
52 | ||
4c9f9fb2 | 53 | rx_skb = __skb_dequeue(&list); |
776f7420 AK |
54 | rx_hdr = (struct rx_packet_hdr *)rx_skb->data; |
55 | if (ISSUPP_TDLS_ENABLED(priv->adapter->fw_cap_info) && | |
56 | ntohs(rx_hdr->eth803_hdr.h_proto) == ETH_P_TDLS) { | |
57 | mwifiex_process_tdls_action_frame(priv, | |
58 | (u8 *)rx_hdr, | |
59 | skb->len); | |
60 | } | |
61 | ||
4c9f9fb2 AK |
62 | ret = mwifiex_recv_packet(priv, rx_skb); |
63 | if (ret == -1) | |
acebe8c1 ZL |
64 | mwifiex_dbg(priv->adapter, ERROR, |
65 | "Rx of A-MSDU failed"); | |
4c9f9fb2 AK |
66 | } |
67 | return 0; | |
68 | } | |
69 | ||
70 | return -1; | |
71 | } | |
72 | ||
5e6e43eb AK |
73 | /* This function will process the rx packet and forward it to kernel/upper |
74 | * layer. | |
75 | */ | |
76 | static int mwifiex_11n_dispatch_pkt(struct mwifiex_private *priv, void *payload) | |
77 | { | |
4c9f9fb2 AK |
78 | int ret = mwifiex_11n_dispatch_amsdu_pkt(priv, payload); |
79 | ||
80 | if (!ret) | |
81 | return 0; | |
82 | ||
5e6e43eb AK |
83 | if (priv->bss_role == MWIFIEX_BSS_ROLE_UAP) |
84 | return mwifiex_handle_uap_rx_forward(priv, payload); | |
85 | ||
86 | return mwifiex_process_rx_packet(priv, payload); | |
87 | } | |
88 | ||
5e6e3a92 | 89 | /* |
8c00228e YAP |
90 | * This function dispatches all packets in the Rx reorder table until the |
91 | * start window. | |
5e6e3a92 BZ |
92 | * |
93 | * There could be holes in the buffer, which are skipped by the function. | |
94 | * Since the buffer is linear, the function uses rotation to simulate | |
95 | * circular buffer. | |
96 | */ | |
ab581472 | 97 | static void |
5e6e43eb AK |
98 | mwifiex_11n_dispatch_pkt_until_start_win(struct mwifiex_private *priv, |
99 | struct mwifiex_rx_reorder_tbl *tbl, | |
100 | int start_win) | |
5e6e3a92 | 101 | { |
8c00228e | 102 | int pkt_to_send, i; |
270e58e8 | 103 | void *rx_tmp_ptr; |
5e6e3a92 BZ |
104 | unsigned long flags; |
105 | ||
8c00228e YAP |
106 | pkt_to_send = (start_win > tbl->start_win) ? |
107 | min((start_win - tbl->start_win), tbl->win_size) : | |
108 | tbl->win_size; | |
5e6e3a92 | 109 | |
8c00228e | 110 | for (i = 0; i < pkt_to_send; ++i) { |
5e6e3a92 BZ |
111 | spin_lock_irqsave(&priv->rx_pkt_lock, flags); |
112 | rx_tmp_ptr = NULL; | |
8c00228e YAP |
113 | if (tbl->rx_reorder_ptr[i]) { |
114 | rx_tmp_ptr = tbl->rx_reorder_ptr[i]; | |
115 | tbl->rx_reorder_ptr[i] = NULL; | |
5e6e3a92 BZ |
116 | } |
117 | spin_unlock_irqrestore(&priv->rx_pkt_lock, flags); | |
5e6e43eb AK |
118 | if (rx_tmp_ptr) |
119 | mwifiex_11n_dispatch_pkt(priv, rx_tmp_ptr); | |
5e6e3a92 BZ |
120 | } |
121 | ||
122 | spin_lock_irqsave(&priv->rx_pkt_lock, flags); | |
123 | /* | |
124 | * We don't have a circular buffer, hence use rotation to simulate | |
125 | * circular buffer | |
126 | */ | |
8c00228e YAP |
127 | for (i = 0; i < tbl->win_size - pkt_to_send; ++i) { |
128 | tbl->rx_reorder_ptr[i] = tbl->rx_reorder_ptr[pkt_to_send + i]; | |
129 | tbl->rx_reorder_ptr[pkt_to_send + i] = NULL; | |
5e6e3a92 BZ |
130 | } |
131 | ||
8c00228e | 132 | tbl->start_win = start_win; |
5e6e3a92 | 133 | spin_unlock_irqrestore(&priv->rx_pkt_lock, flags); |
5e6e3a92 BZ |
134 | } |
135 | ||
136 | /* | |
137 | * This function dispatches all packets in the Rx reorder table until | |
138 | * a hole is found. | |
139 | * | |
140 | * The start window is adjusted automatically when a hole is located. | |
141 | * Since the buffer is linear, the function uses rotation to simulate | |
142 | * circular buffer. | |
143 | */ | |
ab581472 | 144 | static void |
5e6e3a92 | 145 | mwifiex_11n_scan_and_dispatch(struct mwifiex_private *priv, |
8c00228e | 146 | struct mwifiex_rx_reorder_tbl *tbl) |
5e6e3a92 BZ |
147 | { |
148 | int i, j, xchg; | |
270e58e8 | 149 | void *rx_tmp_ptr; |
5e6e3a92 BZ |
150 | unsigned long flags; |
151 | ||
8c00228e | 152 | for (i = 0; i < tbl->win_size; ++i) { |
5e6e3a92 | 153 | spin_lock_irqsave(&priv->rx_pkt_lock, flags); |
8c00228e | 154 | if (!tbl->rx_reorder_ptr[i]) { |
5e6e3a92 BZ |
155 | spin_unlock_irqrestore(&priv->rx_pkt_lock, flags); |
156 | break; | |
157 | } | |
8c00228e YAP |
158 | rx_tmp_ptr = tbl->rx_reorder_ptr[i]; |
159 | tbl->rx_reorder_ptr[i] = NULL; | |
5e6e3a92 | 160 | spin_unlock_irqrestore(&priv->rx_pkt_lock, flags); |
5e6e43eb | 161 | mwifiex_11n_dispatch_pkt(priv, rx_tmp_ptr); |
5e6e3a92 BZ |
162 | } |
163 | ||
164 | spin_lock_irqsave(&priv->rx_pkt_lock, flags); | |
165 | /* | |
166 | * We don't have a circular buffer, hence use rotation to simulate | |
167 | * circular buffer | |
168 | */ | |
169 | if (i > 0) { | |
8c00228e | 170 | xchg = tbl->win_size - i; |
5e6e3a92 | 171 | for (j = 0; j < xchg; ++j) { |
8c00228e YAP |
172 | tbl->rx_reorder_ptr[j] = tbl->rx_reorder_ptr[i + j]; |
173 | tbl->rx_reorder_ptr[i + j] = NULL; | |
5e6e3a92 BZ |
174 | } |
175 | } | |
8c00228e | 176 | tbl->start_win = (tbl->start_win + i) & (MAX_TID_VALUE - 1); |
5e6e3a92 | 177 | spin_unlock_irqrestore(&priv->rx_pkt_lock, flags); |
5e6e3a92 BZ |
178 | } |
179 | ||
180 | /* | |
181 | * This function deletes the Rx reorder table and frees the memory. | |
182 | * | |
183 | * The function stops the associated timer and dispatches all the | |
184 | * pending packets in the Rx reorder table before deletion. | |
185 | */ | |
186 | static void | |
8c00228e YAP |
187 | mwifiex_del_rx_reorder_entry(struct mwifiex_private *priv, |
188 | struct mwifiex_rx_reorder_tbl *tbl) | |
5e6e3a92 BZ |
189 | { |
190 | unsigned long flags; | |
63410c37 | 191 | int start_win; |
5e6e3a92 | 192 | |
8c00228e | 193 | if (!tbl) |
5e6e3a92 BZ |
194 | return; |
195 | ||
6e251174 AP |
196 | spin_lock_irqsave(&priv->adapter->rx_proc_lock, flags); |
197 | priv->adapter->rx_locked = true; | |
198 | if (priv->adapter->rx_processing) { | |
199 | spin_unlock_irqrestore(&priv->adapter->rx_proc_lock, flags); | |
200 | flush_workqueue(priv->adapter->rx_workqueue); | |
201 | } else { | |
202 | spin_unlock_irqrestore(&priv->adapter->rx_proc_lock, flags); | |
203 | } | |
204 | ||
63410c37 | 205 | start_win = (tbl->start_win + tbl->win_size) & (MAX_TID_VALUE - 1); |
5e6e43eb | 206 | mwifiex_11n_dispatch_pkt_until_start_win(priv, tbl, start_win); |
5e6e3a92 | 207 | |
629873f2 | 208 | del_timer_sync(&tbl->timer_context.timer); |
3a8fede1 | 209 | tbl->timer_context.timer_is_set = false; |
5e6e3a92 BZ |
210 | |
211 | spin_lock_irqsave(&priv->rx_reorder_tbl_lock, flags); | |
8c00228e | 212 | list_del(&tbl->list); |
5e6e3a92 BZ |
213 | spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock, flags); |
214 | ||
8c00228e YAP |
215 | kfree(tbl->rx_reorder_ptr); |
216 | kfree(tbl); | |
6e251174 AP |
217 | |
218 | spin_lock_irqsave(&priv->adapter->rx_proc_lock, flags); | |
219 | priv->adapter->rx_locked = false; | |
220 | spin_unlock_irqrestore(&priv->adapter->rx_proc_lock, flags); | |
221 | ||
5e6e3a92 BZ |
222 | } |
223 | ||
224 | /* | |
225 | * This function returns the pointer to an entry in Rx reordering | |
226 | * table which matches the given TA/TID pair. | |
227 | */ | |
d1cf3b95 | 228 | struct mwifiex_rx_reorder_tbl * |
5e6e3a92 BZ |
229 | mwifiex_11n_get_rx_reorder_tbl(struct mwifiex_private *priv, int tid, u8 *ta) |
230 | { | |
8c00228e | 231 | struct mwifiex_rx_reorder_tbl *tbl; |
5e6e3a92 BZ |
232 | unsigned long flags; |
233 | ||
234 | spin_lock_irqsave(&priv->rx_reorder_tbl_lock, flags); | |
8c00228e YAP |
235 | list_for_each_entry(tbl, &priv->rx_reorder_tbl_ptr, list) { |
236 | if (!memcmp(tbl->ta, ta, ETH_ALEN) && tbl->tid == tid) { | |
5e6e3a92 BZ |
237 | spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock, |
238 | flags); | |
8c00228e | 239 | return tbl; |
5e6e3a92 BZ |
240 | } |
241 | } | |
242 | spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock, flags); | |
243 | ||
244 | return NULL; | |
245 | } | |
246 | ||
3e238a11 AP |
247 | /* This function retrieves the pointer to an entry in Rx reordering |
248 | * table which matches the given TA and deletes it. | |
249 | */ | |
250 | void mwifiex_11n_del_rx_reorder_tbl_by_ta(struct mwifiex_private *priv, u8 *ta) | |
251 | { | |
252 | struct mwifiex_rx_reorder_tbl *tbl, *tmp; | |
253 | unsigned long flags; | |
254 | ||
255 | if (!ta) | |
256 | return; | |
257 | ||
258 | spin_lock_irqsave(&priv->rx_reorder_tbl_lock, flags); | |
259 | list_for_each_entry_safe(tbl, tmp, &priv->rx_reorder_tbl_ptr, list) { | |
260 | if (!memcmp(tbl->ta, ta, ETH_ALEN)) { | |
261 | spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock, | |
262 | flags); | |
263 | mwifiex_del_rx_reorder_entry(priv, tbl); | |
264 | spin_lock_irqsave(&priv->rx_reorder_tbl_lock, flags); | |
265 | } | |
266 | } | |
267 | spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock, flags); | |
268 | ||
269 | return; | |
270 | } | |
271 | ||
5e6e3a92 BZ |
272 | /* |
273 | * This function finds the last sequence number used in the packets | |
274 | * buffered in Rx reordering table. | |
275 | */ | |
276 | static int | |
2d702830 | 277 | mwifiex_11n_find_last_seq_num(struct reorder_tmr_cnxt *ctx) |
5e6e3a92 | 278 | { |
2d702830 AK |
279 | struct mwifiex_rx_reorder_tbl *rx_reorder_tbl_ptr = ctx->ptr; |
280 | struct mwifiex_private *priv = ctx->priv; | |
281 | unsigned long flags; | |
5e6e3a92 BZ |
282 | int i; |
283 | ||
2d702830 AK |
284 | spin_lock_irqsave(&priv->rx_reorder_tbl_lock, flags); |
285 | for (i = rx_reorder_tbl_ptr->win_size - 1; i >= 0; --i) { | |
286 | if (rx_reorder_tbl_ptr->rx_reorder_ptr[i]) { | |
287 | spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock, | |
288 | flags); | |
5e6e3a92 | 289 | return i; |
2d702830 AK |
290 | } |
291 | } | |
292 | spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock, flags); | |
5e6e3a92 BZ |
293 | |
294 | return -1; | |
295 | } | |
296 | ||
297 | /* | |
298 | * This function flushes all the packets in Rx reordering table. | |
299 | * | |
300 | * The function checks if any packets are currently buffered in the | |
301 | * table or not. In case there are packets available, it dispatches | |
302 | * them and then dumps the Rx reordering table. | |
303 | */ | |
304 | static void | |
305 | mwifiex_flush_data(unsigned long context) | |
306 | { | |
8c00228e | 307 | struct reorder_tmr_cnxt *ctx = |
5e6e3a92 | 308 | (struct reorder_tmr_cnxt *) context; |
63410c37 | 309 | int start_win, seq_num; |
5e6e3a92 | 310 | |
3a8fede1 | 311 | ctx->timer_is_set = false; |
2d702830 | 312 | seq_num = mwifiex_11n_find_last_seq_num(ctx); |
bb7de2ba | 313 | |
63410c37 | 314 | if (seq_num < 0) |
bb7de2ba YAP |
315 | return; |
316 | ||
acebe8c1 | 317 | mwifiex_dbg(ctx->priv->adapter, INFO, "info: flush data %d\n", seq_num); |
63410c37 | 318 | start_win = (ctx->ptr->start_win + seq_num + 1) & (MAX_TID_VALUE - 1); |
5e6e43eb AK |
319 | mwifiex_11n_dispatch_pkt_until_start_win(ctx->priv, ctx->ptr, |
320 | start_win); | |
5e6e3a92 BZ |
321 | } |
322 | ||
323 | /* | |
324 | * This function creates an entry in Rx reordering table for the | |
325 | * given TA/TID. | |
326 | * | |
327 | * The function also initializes the entry with sequence number, window | |
328 | * size as well as initializes the timer. | |
329 | * | |
330 | * If the received TA/TID pair is already present, all the packets are | |
331 | * dispatched and the window size is moved until the SSN. | |
332 | */ | |
333 | static void | |
334 | mwifiex_11n_create_rx_reorder_tbl(struct mwifiex_private *priv, u8 *ta, | |
84266841 | 335 | int tid, int win_size, int seq_num) |
5e6e3a92 BZ |
336 | { |
337 | int i; | |
8c00228e | 338 | struct mwifiex_rx_reorder_tbl *tbl, *new_node; |
5e6e3a92 BZ |
339 | u16 last_seq = 0; |
340 | unsigned long flags; | |
5a009adf | 341 | struct mwifiex_sta_node *node; |
5e6e3a92 BZ |
342 | |
343 | /* | |
344 | * If we get a TID, ta pair which is already present dispatch all the | |
345 | * the packets and move the window size until the ssn | |
346 | */ | |
8c00228e YAP |
347 | tbl = mwifiex_11n_get_rx_reorder_tbl(priv, tid, ta); |
348 | if (tbl) { | |
5e6e43eb | 349 | mwifiex_11n_dispatch_pkt_until_start_win(priv, tbl, seq_num); |
5e6e3a92 BZ |
350 | return; |
351 | } | |
8c00228e | 352 | /* if !tbl then create one */ |
5e6e3a92 | 353 | new_node = kzalloc(sizeof(struct mwifiex_rx_reorder_tbl), GFP_KERNEL); |
0d2e7a5c | 354 | if (!new_node) |
5e6e3a92 | 355 | return; |
5e6e3a92 BZ |
356 | |
357 | INIT_LIST_HEAD(&new_node->list); | |
358 | new_node->tid = tid; | |
359 | memcpy(new_node->ta, ta, ETH_ALEN); | |
360 | new_node->start_win = seq_num; | |
8acbea61 PS |
361 | new_node->init_win = seq_num; |
362 | new_node->flags = 0; | |
5a009adf | 363 | |
c11fb985 | 364 | spin_lock_irqsave(&priv->sta_list_spinlock, flags); |
5a009adf | 365 | if (mwifiex_queuing_ra_based(priv)) { |
5a009adf AP |
366 | if (priv->bss_role == MWIFIEX_BSS_ROLE_UAP) { |
367 | node = mwifiex_get_sta_entry(priv, ta); | |
368 | if (node) | |
369 | last_seq = node->rx_seq[tid]; | |
370 | } | |
371 | } else { | |
daeb5bb4 AP |
372 | node = mwifiex_get_sta_entry(priv, ta); |
373 | if (node) | |
374 | last_seq = node->rx_seq[tid]; | |
375 | else | |
376 | last_seq = priv->rx_seq[tid]; | |
5a009adf | 377 | } |
c11fb985 | 378 | spin_unlock_irqrestore(&priv->sta_list_spinlock, flags); |
5e6e3a92 | 379 | |
acebe8c1 ZL |
380 | mwifiex_dbg(priv->adapter, INFO, |
381 | "info: last_seq=%d start_win=%d\n", | |
382 | last_seq, new_node->start_win); | |
09bd1976 | 383 | |
92583924 | 384 | if (last_seq != MWIFIEX_DEF_11N_RX_SEQ_NUM && |
8acbea61 | 385 | last_seq >= new_node->start_win) { |
5e6e3a92 | 386 | new_node->start_win = last_seq + 1; |
8acbea61 PS |
387 | new_node->flags |= RXREOR_INIT_WINDOW_SHIFT; |
388 | } | |
5e6e3a92 BZ |
389 | |
390 | new_node->win_size = win_size; | |
391 | ||
392 | new_node->rx_reorder_ptr = kzalloc(sizeof(void *) * win_size, | |
393 | GFP_KERNEL); | |
394 | if (!new_node->rx_reorder_ptr) { | |
395 | kfree((u8 *) new_node); | |
acebe8c1 ZL |
396 | mwifiex_dbg(priv->adapter, ERROR, |
397 | "%s: failed to alloc reorder_ptr\n", __func__); | |
5e6e3a92 BZ |
398 | return; |
399 | } | |
400 | ||
401 | new_node->timer_context.ptr = new_node; | |
402 | new_node->timer_context.priv = priv; | |
3a8fede1 | 403 | new_node->timer_context.timer_is_set = false; |
5e6e3a92 | 404 | |
e4a1c3f8 JL |
405 | setup_timer(&new_node->timer_context.timer, mwifiex_flush_data, |
406 | (unsigned long)&new_node->timer_context); | |
5e6e3a92 BZ |
407 | |
408 | for (i = 0; i < win_size; ++i) | |
409 | new_node->rx_reorder_ptr[i] = NULL; | |
410 | ||
411 | spin_lock_irqsave(&priv->rx_reorder_tbl_lock, flags); | |
412 | list_add_tail(&new_node->list, &priv->rx_reorder_tbl_ptr); | |
413 | spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock, flags); | |
5e6e3a92 BZ |
414 | } |
415 | ||
3a8fede1 MY |
416 | static void |
417 | mwifiex_11n_rxreorder_timer_restart(struct mwifiex_rx_reorder_tbl *tbl) | |
418 | { | |
419 | u32 min_flush_time; | |
420 | ||
421 | if (tbl->win_size >= MWIFIEX_BA_WIN_SIZE_32) | |
422 | min_flush_time = MIN_FLUSH_TIMER_15_MS; | |
423 | else | |
424 | min_flush_time = MIN_FLUSH_TIMER_MS; | |
425 | ||
426 | mod_timer(&tbl->timer_context.timer, | |
427 | jiffies + msecs_to_jiffies(min_flush_time * tbl->win_size)); | |
428 | ||
429 | tbl->timer_context.timer_is_set = true; | |
430 | } | |
431 | ||
5e6e3a92 BZ |
432 | /* |
433 | * This function prepares command for adding a BA request. | |
434 | * | |
435 | * Preparation includes - | |
436 | * - Setting command ID and proper size | |
437 | * - Setting add BA request buffer | |
438 | * - Ensuring correct endian-ness | |
439 | */ | |
572e8f3e | 440 | int mwifiex_cmd_11n_addba_req(struct host_cmd_ds_command *cmd, void *data_buf) |
5e6e3a92 | 441 | { |
2c208890 | 442 | struct host_cmd_ds_11n_addba_req *add_ba_req = &cmd->params.add_ba_req; |
5e6e3a92 BZ |
443 | |
444 | cmd->command = cpu_to_le16(HostCmd_CMD_11N_ADDBA_REQ); | |
445 | cmd->size = cpu_to_le16(sizeof(*add_ba_req) + S_DS_GEN); | |
446 | memcpy(add_ba_req, data_buf, sizeof(*add_ba_req)); | |
447 | ||
448 | return 0; | |
449 | } | |
450 | ||
451 | /* | |
452 | * This function prepares command for adding a BA response. | |
453 | * | |
454 | * Preparation includes - | |
455 | * - Setting command ID and proper size | |
456 | * - Setting add BA response buffer | |
457 | * - Ensuring correct endian-ness | |
458 | */ | |
459 | int mwifiex_cmd_11n_addba_rsp_gen(struct mwifiex_private *priv, | |
460 | struct host_cmd_ds_command *cmd, | |
a5ffddb7 AK |
461 | struct host_cmd_ds_11n_addba_req |
462 | *cmd_addba_req) | |
5e6e3a92 | 463 | { |
2c208890 | 464 | struct host_cmd_ds_11n_addba_rsp *add_ba_rsp = &cmd->params.add_ba_rsp; |
b06c5321 AP |
465 | struct mwifiex_sta_node *sta_ptr; |
466 | u32 rx_win_size = priv->add_ba_param.rx_win_size; | |
270e58e8 YAP |
467 | u8 tid; |
468 | int win_size; | |
c11fb985 | 469 | unsigned long flags; |
5e6e3a92 BZ |
470 | uint16_t block_ack_param_set; |
471 | ||
b06c5321 AP |
472 | if ((GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA) && |
473 | ISSUPP_TDLS_ENABLED(priv->adapter->fw_cap_info) && | |
474 | priv->adapter->is_hw_11ac_capable && | |
475 | memcmp(priv->cfg_bssid, cmd_addba_req->peer_mac_addr, ETH_ALEN)) { | |
c11fb985 | 476 | spin_lock_irqsave(&priv->sta_list_spinlock, flags); |
b06c5321 AP |
477 | sta_ptr = mwifiex_get_sta_entry(priv, |
478 | cmd_addba_req->peer_mac_addr); | |
479 | if (!sta_ptr) { | |
09bd1976 | 480 | spin_unlock_irqrestore(&priv->sta_list_spinlock, flags); |
acebe8c1 ZL |
481 | mwifiex_dbg(priv->adapter, ERROR, |
482 | "BA setup with unknown TDLS peer %pM!\n", | |
483 | cmd_addba_req->peer_mac_addr); | |
b06c5321 AP |
484 | return -1; |
485 | } | |
486 | if (sta_ptr->is_11ac_enabled) | |
487 | rx_win_size = MWIFIEX_11AC_STA_AMPDU_DEF_RXWINSIZE; | |
c11fb985 | 488 | spin_unlock_irqrestore(&priv->sta_list_spinlock, flags); |
b06c5321 AP |
489 | } |
490 | ||
5e6e3a92 BZ |
491 | cmd->command = cpu_to_le16(HostCmd_CMD_11N_ADDBA_RSP); |
492 | cmd->size = cpu_to_le16(sizeof(*add_ba_rsp) + S_DS_GEN); | |
493 | ||
494 | memcpy(add_ba_rsp->peer_mac_addr, cmd_addba_req->peer_mac_addr, | |
495 | ETH_ALEN); | |
496 | add_ba_rsp->dialog_token = cmd_addba_req->dialog_token; | |
497 | add_ba_rsp->block_ack_tmo = cmd_addba_req->block_ack_tmo; | |
498 | add_ba_rsp->ssn = cmd_addba_req->ssn; | |
499 | ||
500 | block_ack_param_set = le16_to_cpu(cmd_addba_req->block_ack_param_set); | |
501 | tid = (block_ack_param_set & IEEE80211_ADDBA_PARAM_TID_MASK) | |
502 | >> BLOCKACKPARAM_TID_POS; | |
503 | add_ba_rsp->status_code = cpu_to_le16(ADDBA_RSP_STATUS_ACCEPT); | |
504 | block_ack_param_set &= ~IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK; | |
4c9f9fb2 AK |
505 | |
506 | /* If we don't support AMSDU inside AMPDU, reset the bit */ | |
507 | if (!priv->add_ba_param.rx_amsdu || | |
508 | (priv->aggr_prio_tbl[tid].amsdu == BA_STREAM_NOT_ALLOWED)) | |
509 | block_ack_param_set &= ~BLOCKACKPARAM_AMSDU_SUPP_MASK; | |
b06c5321 | 510 | block_ack_param_set |= rx_win_size << BLOCKACKPARAM_WINSIZE_POS; |
5e6e3a92 BZ |
511 | add_ba_rsp->block_ack_param_set = cpu_to_le16(block_ack_param_set); |
512 | win_size = (le16_to_cpu(add_ba_rsp->block_ack_param_set) | |
513 | & IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK) | |
514 | >> BLOCKACKPARAM_WINSIZE_POS; | |
515 | cmd_addba_req->block_ack_param_set = cpu_to_le16(block_ack_param_set); | |
516 | ||
517 | mwifiex_11n_create_rx_reorder_tbl(priv, cmd_addba_req->peer_mac_addr, | |
84266841 YAP |
518 | tid, win_size, |
519 | le16_to_cpu(cmd_addba_req->ssn)); | |
5e6e3a92 BZ |
520 | return 0; |
521 | } | |
522 | ||
523 | /* | |
524 | * This function prepares command for deleting a BA request. | |
525 | * | |
526 | * Preparation includes - | |
527 | * - Setting command ID and proper size | |
528 | * - Setting del BA request buffer | |
529 | * - Ensuring correct endian-ness | |
530 | */ | |
572e8f3e | 531 | int mwifiex_cmd_11n_delba(struct host_cmd_ds_command *cmd, void *data_buf) |
5e6e3a92 | 532 | { |
2c208890 | 533 | struct host_cmd_ds_11n_delba *del_ba = &cmd->params.del_ba; |
5e6e3a92 BZ |
534 | |
535 | cmd->command = cpu_to_le16(HostCmd_CMD_11N_DELBA); | |
536 | cmd->size = cpu_to_le16(sizeof(*del_ba) + S_DS_GEN); | |
537 | memcpy(del_ba, data_buf, sizeof(*del_ba)); | |
538 | ||
539 | return 0; | |
540 | } | |
541 | ||
542 | /* | |
543 | * This function identifies if Rx reordering is needed for a received packet. | |
544 | * | |
545 | * In case reordering is required, the function will do the reordering | |
546 | * before sending it to kernel. | |
547 | * | |
548 | * The Rx reorder table is checked first with the received TID/TA pair. If | |
549 | * not found, the received packet is dispatched immediately. But if found, | |
550 | * the packet is reordered and all the packets in the updated Rx reordering | |
551 | * table is dispatched until a hole is found. | |
552 | * | |
553 | * For sequence number less than the starting window, the packet is dropped. | |
554 | */ | |
555 | int mwifiex_11n_rx_reorder_pkt(struct mwifiex_private *priv, | |
556 | u16 seq_num, u16 tid, | |
557 | u8 *ta, u8 pkt_type, void *payload) | |
558 | { | |
8c00228e | 559 | struct mwifiex_rx_reorder_tbl *tbl; |
3a8fede1 | 560 | int prev_start_win, start_win, end_win, win_size; |
270e58e8 | 561 | u16 pkt_index; |
8acbea61 | 562 | bool init_window_shift = false; |
3a8fede1 | 563 | int ret = 0; |
5e6e3a92 | 564 | |
2c208890 | 565 | tbl = mwifiex_11n_get_rx_reorder_tbl(priv, tid, ta); |
8c00228e | 566 | if (!tbl) { |
5e6e43eb AK |
567 | if (pkt_type != PKT_TYPE_BAR) |
568 | mwifiex_11n_dispatch_pkt(priv, payload); | |
3a8fede1 | 569 | return ret; |
5e6e3a92 | 570 | } |
4c9f9fb2 AK |
571 | |
572 | if ((pkt_type == PKT_TYPE_AMSDU) && !tbl->amsdu) { | |
573 | mwifiex_11n_dispatch_pkt(priv, payload); | |
3a8fede1 | 574 | return ret; |
4c9f9fb2 AK |
575 | } |
576 | ||
8c00228e | 577 | start_win = tbl->start_win; |
3a8fede1 | 578 | prev_start_win = start_win; |
8c00228e | 579 | win_size = tbl->win_size; |
5e6e3a92 | 580 | end_win = ((start_win + win_size) - 1) & (MAX_TID_VALUE - 1); |
8acbea61 PS |
581 | if (tbl->flags & RXREOR_INIT_WINDOW_SHIFT) { |
582 | init_window_shift = true; | |
583 | tbl->flags &= ~RXREOR_INIT_WINDOW_SHIFT; | |
584 | } | |
5e6e3a92 | 585 | |
2db96c3d | 586 | if (tbl->flags & RXREOR_FORCE_NO_DROP) { |
acebe8c1 ZL |
587 | mwifiex_dbg(priv->adapter, INFO, |
588 | "RXREOR_FORCE_NO_DROP when HS is activated\n"); | |
2db96c3d | 589 | tbl->flags &= ~RXREOR_FORCE_NO_DROP; |
8acbea61 PS |
590 | } else if (init_window_shift && seq_num < start_win && |
591 | seq_num >= tbl->init_win) { | |
acebe8c1 ZL |
592 | mwifiex_dbg(priv->adapter, INFO, |
593 | "Sender TID sequence number reset %d->%d for SSN %d\n", | |
594 | start_win, seq_num, tbl->init_win); | |
8acbea61 PS |
595 | tbl->start_win = start_win = seq_num; |
596 | end_win = ((start_win + win_size) - 1) & (MAX_TID_VALUE - 1); | |
2db96c3d | 597 | } else { |
8acbea61 PS |
598 | /* |
599 | * If seq_num is less then starting win then ignore and drop | |
600 | * the packet | |
601 | */ | |
2db96c3d AP |
602 | if ((start_win + TWOPOW11) > (MAX_TID_VALUE - 1)) { |
603 | if (seq_num >= ((start_win + TWOPOW11) & | |
604 | (MAX_TID_VALUE - 1)) && | |
3a8fede1 MY |
605 | seq_num < start_win) { |
606 | ret = -1; | |
607 | goto done; | |
608 | } | |
2db96c3d | 609 | } else if ((seq_num < start_win) || |
3a8fede1 MY |
610 | (seq_num >= (start_win + TWOPOW11))) { |
611 | ret = -1; | |
612 | goto done; | |
2db96c3d | 613 | } |
5e6e3a92 BZ |
614 | } |
615 | ||
616 | /* | |
617 | * If this packet is a BAR we adjust seq_num as | |
618 | * WinStart = seq_num | |
619 | */ | |
620 | if (pkt_type == PKT_TYPE_BAR) | |
621 | seq_num = ((seq_num + win_size) - 1) & (MAX_TID_VALUE - 1); | |
622 | ||
84266841 | 623 | if (((end_win < start_win) && |
2db96c3d | 624 | (seq_num < start_win) && (seq_num > end_win)) || |
84266841 YAP |
625 | ((end_win > start_win) && ((seq_num > end_win) || |
626 | (seq_num < start_win)))) { | |
5e6e3a92 | 627 | end_win = seq_num; |
cc751498 | 628 | if (((end_win - win_size) + 1) >= 0) |
5e6e3a92 BZ |
629 | start_win = (end_win - win_size) + 1; |
630 | else | |
cc751498 | 631 | start_win = (MAX_TID_VALUE - (win_size - end_win)) + 1; |
5e6e43eb | 632 | mwifiex_11n_dispatch_pkt_until_start_win(priv, tbl, start_win); |
5e6e3a92 BZ |
633 | } |
634 | ||
635 | if (pkt_type != PKT_TYPE_BAR) { | |
636 | if (seq_num >= start_win) | |
637 | pkt_index = seq_num - start_win; | |
638 | else | |
639 | pkt_index = (seq_num+MAX_TID_VALUE) - start_win; | |
640 | ||
3a8fede1 MY |
641 | if (tbl->rx_reorder_ptr[pkt_index]) { |
642 | ret = -1; | |
643 | goto done; | |
644 | } | |
5e6e3a92 | 645 | |
8c00228e | 646 | tbl->rx_reorder_ptr[pkt_index] = payload; |
5e6e3a92 BZ |
647 | } |
648 | ||
649 | /* | |
650 | * Dispatch all packets sequentially from start_win until a | |
651 | * hole is found and adjust the start_win appropriately | |
652 | */ | |
8c00228e | 653 | mwifiex_11n_scan_and_dispatch(priv, tbl); |
5e6e3a92 | 654 | |
3a8fede1 MY |
655 | done: |
656 | if (!tbl->timer_context.timer_is_set || | |
657 | prev_start_win != tbl->start_win) | |
658 | mwifiex_11n_rxreorder_timer_restart(tbl); | |
659 | return ret; | |
5e6e3a92 BZ |
660 | } |
661 | ||
662 | /* | |
663 | * This function deletes an entry for a given TID/TA pair. | |
664 | * | |
665 | * The TID/TA are taken from del BA event body. | |
666 | */ | |
667 | void | |
3e822635 YAP |
668 | mwifiex_del_ba_tbl(struct mwifiex_private *priv, int tid, u8 *peer_mac, |
669 | u8 type, int initiator) | |
5e6e3a92 | 670 | { |
8c00228e | 671 | struct mwifiex_rx_reorder_tbl *tbl; |
5e6e3a92 | 672 | struct mwifiex_tx_ba_stream_tbl *ptx_tbl; |
39df5e82 | 673 | struct mwifiex_ra_list_tbl *ra_list; |
5e6e3a92 BZ |
674 | u8 cleanup_rx_reorder_tbl; |
675 | unsigned long flags; | |
719a25e3 | 676 | int tid_down; |
5e6e3a92 BZ |
677 | |
678 | if (type == TYPE_DELBA_RECEIVE) | |
679 | cleanup_rx_reorder_tbl = (initiator) ? true : false; | |
680 | else | |
681 | cleanup_rx_reorder_tbl = (initiator) ? false : true; | |
682 | ||
acebe8c1 ZL |
683 | mwifiex_dbg(priv->adapter, EVENT, "event: DELBA: %pM tid=%d initiator=%d\n", |
684 | peer_mac, tid, initiator); | |
5e6e3a92 BZ |
685 | |
686 | if (cleanup_rx_reorder_tbl) { | |
8c00228e | 687 | tbl = mwifiex_11n_get_rx_reorder_tbl(priv, tid, |
5e6e3a92 | 688 | peer_mac); |
8c00228e | 689 | if (!tbl) { |
acebe8c1 ZL |
690 | mwifiex_dbg(priv->adapter, EVENT, |
691 | "event: TID, TA not found in table\n"); | |
5e6e3a92 BZ |
692 | return; |
693 | } | |
8c00228e | 694 | mwifiex_del_rx_reorder_entry(priv, tbl); |
5e6e3a92 | 695 | } else { |
3e822635 | 696 | ptx_tbl = mwifiex_get_ba_tbl(priv, tid, peer_mac); |
5e6e3a92 | 697 | if (!ptx_tbl) { |
acebe8c1 ZL |
698 | mwifiex_dbg(priv->adapter, EVENT, |
699 | "event: TID, RA not found in table\n"); | |
5e6e3a92 BZ |
700 | return; |
701 | } | |
719a25e3 XH |
702 | |
703 | tid_down = mwifiex_wmm_downgrade_tid(priv, tid); | |
704 | ra_list = mwifiex_wmm_get_ralist_node(priv, tid_down, peer_mac); | |
39df5e82 ZL |
705 | if (ra_list) { |
706 | ra_list->amsdu_in_ampdu = false; | |
707 | ra_list->ba_status = BA_SETUP_NONE; | |
708 | } | |
5e6e3a92 BZ |
709 | spin_lock_irqsave(&priv->tx_ba_stream_tbl_lock, flags); |
710 | mwifiex_11n_delete_tx_ba_stream_tbl_entry(priv, ptx_tbl); | |
711 | spin_unlock_irqrestore(&priv->tx_ba_stream_tbl_lock, flags); | |
712 | } | |
713 | } | |
714 | ||
715 | /* | |
716 | * This function handles the command response of an add BA response. | |
717 | * | |
718 | * Handling includes changing the header fields into CPU format and | |
719 | * creating the stream, provided the add BA is accepted. | |
720 | */ | |
721 | int mwifiex_ret_11n_addba_resp(struct mwifiex_private *priv, | |
722 | struct host_cmd_ds_command *resp) | |
723 | { | |
2c208890 | 724 | struct host_cmd_ds_11n_addba_rsp *add_ba_rsp = &resp->params.add_ba_rsp; |
5e6e3a92 | 725 | int tid, win_size; |
8c00228e | 726 | struct mwifiex_rx_reorder_tbl *tbl; |
5e6e3a92 BZ |
727 | uint16_t block_ack_param_set; |
728 | ||
729 | block_ack_param_set = le16_to_cpu(add_ba_rsp->block_ack_param_set); | |
730 | ||
731 | tid = (block_ack_param_set & IEEE80211_ADDBA_PARAM_TID_MASK) | |
732 | >> BLOCKACKPARAM_TID_POS; | |
733 | /* | |
734 | * Check if we had rejected the ADDBA, if yes then do not create | |
735 | * the stream | |
736 | */ | |
63410c37 | 737 | if (le16_to_cpu(add_ba_rsp->status_code) != BA_RESULT_SUCCESS) { |
acebe8c1 ZL |
738 | mwifiex_dbg(priv->adapter, ERROR, "ADDBA RSP: failed %pM tid=%d)\n", |
739 | add_ba_rsp->peer_mac_addr, tid); | |
5e6e3a92 | 740 | |
8c00228e YAP |
741 | tbl = mwifiex_11n_get_rx_reorder_tbl(priv, tid, |
742 | add_ba_rsp->peer_mac_addr); | |
743 | if (tbl) | |
744 | mwifiex_del_rx_reorder_entry(priv, tbl); | |
63410c37 AK |
745 | |
746 | return 0; | |
5e6e3a92 BZ |
747 | } |
748 | ||
63410c37 AK |
749 | win_size = (block_ack_param_set & IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK) |
750 | >> BLOCKACKPARAM_WINSIZE_POS; | |
751 | ||
4c9f9fb2 AK |
752 | tbl = mwifiex_11n_get_rx_reorder_tbl(priv, tid, |
753 | add_ba_rsp->peer_mac_addr); | |
754 | if (tbl) { | |
755 | if ((block_ack_param_set & BLOCKACKPARAM_AMSDU_SUPP_MASK) && | |
756 | priv->add_ba_param.rx_amsdu && | |
757 | (priv->aggr_prio_tbl[tid].amsdu != BA_STREAM_NOT_ALLOWED)) | |
758 | tbl->amsdu = true; | |
759 | else | |
760 | tbl->amsdu = false; | |
761 | } | |
762 | ||
acebe8c1 ZL |
763 | mwifiex_dbg(priv->adapter, CMD, |
764 | "cmd: ADDBA RSP: %pM tid=%d ssn=%d win_size=%d\n", | |
63410c37 AK |
765 | add_ba_rsp->peer_mac_addr, tid, add_ba_rsp->ssn, win_size); |
766 | ||
5e6e3a92 BZ |
767 | return 0; |
768 | } | |
769 | ||
770 | /* | |
771 | * This function handles BA stream timeout event by preparing and sending | |
772 | * a command to the firmware. | |
773 | */ | |
774 | void mwifiex_11n_ba_stream_timeout(struct mwifiex_private *priv, | |
775 | struct host_cmd_ds_11n_batimeout *event) | |
776 | { | |
777 | struct host_cmd_ds_11n_delba delba; | |
778 | ||
779 | memset(&delba, 0, sizeof(struct host_cmd_ds_11n_delba)); | |
780 | memcpy(delba.peer_mac_addr, event->peer_mac_addr, ETH_ALEN); | |
781 | ||
782 | delba.del_ba_param_set |= | |
783 | cpu_to_le16((u16) event->tid << DELBA_TID_POS); | |
784 | delba.del_ba_param_set |= cpu_to_le16( | |
785 | (u16) event->origninator << DELBA_INITIATOR_POS); | |
786 | delba.reason_code = cpu_to_le16(WLAN_REASON_QSTA_TIMEOUT); | |
fa0ecbb9 | 787 | mwifiex_send_cmd(priv, HostCmd_CMD_11N_DELBA, 0, 0, &delba, false); |
5e6e3a92 BZ |
788 | } |
789 | ||
790 | /* | |
791 | * This function cleans up the Rx reorder table by deleting all the entries | |
792 | * and re-initializing. | |
793 | */ | |
794 | void mwifiex_11n_cleanup_reorder_tbl(struct mwifiex_private *priv) | |
795 | { | |
796 | struct mwifiex_rx_reorder_tbl *del_tbl_ptr, *tmp_node; | |
797 | unsigned long flags; | |
798 | ||
799 | spin_lock_irqsave(&priv->rx_reorder_tbl_lock, flags); | |
800 | list_for_each_entry_safe(del_tbl_ptr, tmp_node, | |
801 | &priv->rx_reorder_tbl_ptr, list) { | |
802 | spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock, flags); | |
8c00228e | 803 | mwifiex_del_rx_reorder_entry(priv, del_tbl_ptr); |
5e6e3a92 BZ |
804 | spin_lock_irqsave(&priv->rx_reorder_tbl_lock, flags); |
805 | } | |
2d702830 | 806 | INIT_LIST_HEAD(&priv->rx_reorder_tbl_ptr); |
5e6e3a92 BZ |
807 | spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock, flags); |
808 | ||
92583924 | 809 | mwifiex_reset_11n_rx_seq_num(priv); |
5e6e3a92 | 810 | } |
2db96c3d AP |
811 | |
812 | /* | |
813 | * This function updates all rx_reorder_tbl's flags. | |
814 | */ | |
815 | void mwifiex_update_rxreor_flags(struct mwifiex_adapter *adapter, u8 flags) | |
816 | { | |
817 | struct mwifiex_private *priv; | |
818 | struct mwifiex_rx_reorder_tbl *tbl; | |
819 | unsigned long lock_flags; | |
820 | int i; | |
821 | ||
822 | for (i = 0; i < adapter->priv_num; i++) { | |
823 | priv = adapter->priv[i]; | |
824 | if (!priv) | |
825 | continue; | |
2db96c3d AP |
826 | |
827 | spin_lock_irqsave(&priv->rx_reorder_tbl_lock, lock_flags); | |
2d702830 AK |
828 | if (list_empty(&priv->rx_reorder_tbl_ptr)) { |
829 | spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock, | |
830 | lock_flags); | |
831 | continue; | |
832 | } | |
833 | ||
2db96c3d AP |
834 | list_for_each_entry(tbl, &priv->rx_reorder_tbl_ptr, list) |
835 | tbl->flags = flags; | |
836 | spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock, lock_flags); | |
837 | } | |
838 | ||
839 | return; | |
840 | } | |
d219b7eb CC |
841 | |
842 | /* This function update all the rx_win_size based on coex flag | |
843 | */ | |
844 | static void mwifiex_update_ampdu_rxwinsize(struct mwifiex_adapter *adapter, | |
845 | bool coex_flag) | |
846 | { | |
847 | u8 i; | |
848 | u32 rx_win_size; | |
849 | struct mwifiex_private *priv; | |
850 | ||
851 | dev_dbg(adapter->dev, "Update rxwinsize %d\n", coex_flag); | |
852 | ||
853 | for (i = 0; i < adapter->priv_num; i++) { | |
854 | if (!adapter->priv[i]) | |
855 | continue; | |
856 | priv = adapter->priv[i]; | |
857 | rx_win_size = priv->add_ba_param.rx_win_size; | |
858 | if (coex_flag) { | |
859 | if (priv->bss_type == MWIFIEX_BSS_TYPE_STA) | |
860 | priv->add_ba_param.rx_win_size = | |
861 | MWIFIEX_STA_COEX_AMPDU_DEF_RXWINSIZE; | |
862 | if (priv->bss_type == MWIFIEX_BSS_TYPE_P2P) | |
863 | priv->add_ba_param.rx_win_size = | |
864 | MWIFIEX_STA_COEX_AMPDU_DEF_RXWINSIZE; | |
865 | if (priv->bss_type == MWIFIEX_BSS_TYPE_UAP) | |
866 | priv->add_ba_param.rx_win_size = | |
867 | MWIFIEX_UAP_COEX_AMPDU_DEF_RXWINSIZE; | |
868 | } else { | |
869 | if (priv->bss_type == MWIFIEX_BSS_TYPE_STA) | |
870 | priv->add_ba_param.rx_win_size = | |
871 | MWIFIEX_STA_AMPDU_DEF_RXWINSIZE; | |
872 | if (priv->bss_type == MWIFIEX_BSS_TYPE_P2P) | |
873 | priv->add_ba_param.rx_win_size = | |
874 | MWIFIEX_STA_AMPDU_DEF_RXWINSIZE; | |
875 | if (priv->bss_type == MWIFIEX_BSS_TYPE_UAP) | |
876 | priv->add_ba_param.rx_win_size = | |
877 | MWIFIEX_UAP_AMPDU_DEF_RXWINSIZE; | |
878 | } | |
879 | ||
880 | if (adapter->coex_win_size && adapter->coex_rx_win_size) | |
881 | priv->add_ba_param.rx_win_size = | |
882 | adapter->coex_rx_win_size; | |
883 | ||
884 | if (rx_win_size != priv->add_ba_param.rx_win_size) { | |
885 | if (!priv->media_connected) | |
886 | continue; | |
887 | for (i = 0; i < MAX_NUM_TID; i++) | |
888 | mwifiex_11n_delba(priv, i); | |
889 | } | |
890 | } | |
891 | } | |
892 | ||
893 | /* This function check coex for RX BA | |
894 | */ | |
895 | void mwifiex_coex_ampdu_rxwinsize(struct mwifiex_adapter *adapter) | |
896 | { | |
897 | u8 i; | |
898 | struct mwifiex_private *priv; | |
899 | u8 count = 0; | |
900 | ||
901 | for (i = 0; i < adapter->priv_num; i++) { | |
902 | if (adapter->priv[i]) { | |
903 | priv = adapter->priv[i]; | |
904 | if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA) { | |
905 | if (priv->media_connected) | |
906 | count++; | |
907 | } | |
908 | if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_UAP) { | |
909 | if (priv->bss_started) | |
910 | count++; | |
911 | } | |
912 | } | |
913 | if (count >= MWIFIEX_BSS_COEX_COUNT) | |
914 | break; | |
915 | } | |
916 | if (count >= MWIFIEX_BSS_COEX_COUNT) | |
917 | mwifiex_update_ampdu_rxwinsize(adapter, true); | |
918 | else | |
919 | mwifiex_update_ampdu_rxwinsize(adapter, false); | |
920 | } |