2 * Copyright (c) 2010 Broadcom Corporation
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 #include <linux/kernel.h>
17 #include <net/mac80211.h>
26 #include "wlc_types.h"
32 #include "phy/wlc_phy_hal.h"
33 #include "wlc_antsel.h"
34 #include "wlc_channel.h"
36 #include "wlc_ampdu.h"
38 #define AMPDU_MAX_MPDU 32 /* max number of mpdus in an ampdu */
39 #define AMPDU_NUM_MPDU_LEGACY 16 /* max number of mpdus in an ampdu to a legacy */
40 #define AMPDU_TX_BA_MAX_WSIZE 64 /* max Tx ba window size (in pdu) */
41 #define AMPDU_TX_BA_DEF_WSIZE 64 /* default Tx ba window size (in pdu) */
42 #define AMPDU_RX_BA_DEF_WSIZE 64 /* max Rx ba window size (in pdu) */
43 #define AMPDU_RX_BA_MAX_WSIZE 64 /* default Rx ba window size (in pdu) */
44 #define AMPDU_MAX_DUR 5 /* max dur of tx ampdu (in msec) */
45 #define AMPDU_DEF_RETRY_LIMIT 5 /* default tx retry limit */
46 #define AMPDU_DEF_RR_RETRY_LIMIT 2 /* default tx retry limit at reg rate */
47 #define AMPDU_DEF_TXPKT_WEIGHT 2 /* default weight of ampdu in txfifo */
48 #define AMPDU_DEF_FFPLD_RSVD 2048 /* default ffpld reserved bytes */
49 #define AMPDU_INI_FREE 10 /* # of inis to be freed on detach */
50 #define AMPDU_SCB_MAX_RELEASE 20 /* max # of mpdus released at a time */
52 #define NUM_FFPLD_FIFO 4 /* number of fifo concerned by pre-loading */
53 #define FFPLD_TX_MAX_UNFL 200 /* default value of the average number of ampdu
56 #define FFPLD_MPDU_SIZE 1800 /* estimate of maximum mpdu size */
57 #define FFPLD_MAX_MCS 23 /* we don't deal with mcs 32 */
58 #define FFPLD_PLD_INCR 1000 /* increments in bytes */
59 #define FFPLD_MAX_AMPDU_CNT 5000 /* maximum number of ampdu we
60 * accumulate between resets.
63 #define TX_SEQ_TO_INDEX(seq) ((seq) % AMPDU_TX_BA_MAX_WSIZE)
65 /* max possible overhead per mpdu in the ampdu; 3 is for roundup if needed */
66 #define AMPDU_MAX_MPDU_OVERHEAD (FCS_LEN + DOT11_ICV_AES_LEN +\
67 AMPDU_DELIMITER_LEN + 3\
68 + DOT11_A4_HDR_LEN + DOT11_QOS_LEN + DOT11_IV_MAX_LEN)
70 /* structure to hold tx fifo information and pre-loading state
71 * counters specific to tx underflows of ampdus
72 * some counters might be redundant with the ones in wlc or ampdu structures.
73 * This allows to maintain a specific state independently of
74 * how often and/or when the wlc counters are updated.
76 typedef struct wlc_fifo_info
{
77 u16 ampdu_pld_size
; /* number of bytes to be pre-loaded */
78 u8 mcs2ampdu_table
[FFPLD_MAX_MCS
+ 1]; /* per-mcs max # of mpdus in an ampdu */
79 u16 prev_txfunfl
; /* num of underflows last read from the HW macstats counter */
80 u32 accum_txfunfl
; /* num of underflows since we modified pld params */
81 u32 accum_txampdu
; /* num of tx ampdu since we modified pld params */
82 u32 prev_txampdu
; /* previous reading of tx ampdu */
83 u32 dmaxferrate
; /* estimated dma avg xfer rate in kbits/sec */
86 /* AMPDU module specific state */
88 struct wlc_info
*wlc
; /* pointer to main wlc structure */
89 int scb_handle
; /* scb cubby handle to retrieve data from scb */
90 u8 ini_enable
[AMPDU_MAX_SCB_TID
]; /* per-tid initiator enable/disable of ampdu */
91 u8 ba_tx_wsize
; /* Tx ba window size (in pdu) */
92 u8 ba_rx_wsize
; /* Rx ba window size (in pdu) */
93 u8 retry_limit
; /* mpdu transmit retry limit */
94 u8 rr_retry_limit
; /* mpdu transmit retry limit at regular rate */
95 u8 retry_limit_tid
[AMPDU_MAX_SCB_TID
]; /* per-tid mpdu transmit retry limit */
96 /* per-tid mpdu transmit retry limit at regular rate */
97 u8 rr_retry_limit_tid
[AMPDU_MAX_SCB_TID
];
98 u8 mpdu_density
; /* min mpdu spacing (0-7) ==> 2^(x-1)/8 usec */
99 s8 max_pdu
; /* max pdus allowed in ampdu */
100 u8 dur
; /* max duration of an ampdu (in msec) */
101 u8 txpkt_weight
; /* weight of ampdu in txfifo; reduces rate lag */
102 u8 rx_factor
; /* maximum rx ampdu factor (0-3) ==> 2^(13+x) bytes */
103 u32 ffpld_rsvd
; /* number of bytes to reserve for preload */
104 u32 max_txlen
[MCS_TABLE_SIZE
][2][2]; /* max size of ampdu per mcs, bw and sgi */
105 void *ini_free
[AMPDU_INI_FREE
]; /* array of ini's to be freed on detach */
106 bool mfbr
; /* enable multiple fallback rate */
107 u32 tx_max_funl
; /* underflows should be kept such that
108 * (tx_max_funfl*underflows) < tx frames
110 wlc_fifo_info_t fifo_tb
[NUM_FFPLD_FIFO
]; /* table of fifo infos */
114 /* used for flushing ampdu packets */
115 struct cb_del_ampdu_pars
{
116 struct ieee80211_sta
*sta
;
120 #define AMPDU_CLEANUPFLAG_RX (0x1)
121 #define AMPDU_CLEANUPFLAG_TX (0x2)
123 #define SCB_AMPDU_CUBBY(ampdu, scb) (&(scb->scb_ampdu))
124 #define SCB_AMPDU_INI(scb_ampdu, tid) (&(scb_ampdu->ini[tid]))
126 static void wlc_ffpld_init(struct ampdu_info
*ampdu
);
127 static int wlc_ffpld_check_txfunfl(struct wlc_info
*wlc
, int f
);
128 static void wlc_ffpld_calc_mcs2ampdu_table(struct ampdu_info
*ampdu
, int f
);
130 static scb_ampdu_tid_ini_t
*wlc_ampdu_init_tid_ini(struct ampdu_info
*ampdu
,
131 scb_ampdu_t
*scb_ampdu
,
132 u8 tid
, bool override
);
133 static void ampdu_update_max_txlen(struct ampdu_info
*ampdu
, u8 dur
);
134 static void scb_ampdu_update_config(struct ampdu_info
*ampdu
, struct scb
*scb
);
135 static void scb_ampdu_update_config_all(struct ampdu_info
*ampdu
);
137 #define wlc_ampdu_txflowcontrol(a, b, c) do {} while (0)
139 static void wlc_ampdu_dotxstatus_complete(struct ampdu_info
*ampdu
,
141 struct sk_buff
*p
, tx_status_t
*txs
,
142 u32 frmtxstatus
, u32 frmtxstatus2
);
143 static bool wlc_ampdu_cap(struct ampdu_info
*ampdu
);
144 static int wlc_ampdu_set(struct ampdu_info
*ampdu
, bool on
);
146 struct ampdu_info
*wlc_ampdu_attach(struct wlc_info
*wlc
)
148 struct ampdu_info
*ampdu
;
151 ampdu
= kzalloc(sizeof(struct ampdu_info
), GFP_ATOMIC
);
153 wiphy_err(wlc
->wiphy
, "wl%d: wlc_ampdu_attach: out of mem\n",
159 for (i
= 0; i
< AMPDU_MAX_SCB_TID
; i
++)
160 ampdu
->ini_enable
[i
] = true;
161 /* Disable ampdu for VO by default */
162 ampdu
->ini_enable
[PRIO_8021D_VO
] = false;
163 ampdu
->ini_enable
[PRIO_8021D_NC
] = false;
165 /* Disable ampdu for BK by default since not enough fifo space */
166 ampdu
->ini_enable
[PRIO_8021D_NONE
] = false;
167 ampdu
->ini_enable
[PRIO_8021D_BK
] = false;
169 ampdu
->ba_tx_wsize
= AMPDU_TX_BA_DEF_WSIZE
;
170 ampdu
->ba_rx_wsize
= AMPDU_RX_BA_DEF_WSIZE
;
171 ampdu
->mpdu_density
= AMPDU_DEF_MPDU_DENSITY
;
172 ampdu
->max_pdu
= AUTO
;
173 ampdu
->dur
= AMPDU_MAX_DUR
;
174 ampdu
->txpkt_weight
= AMPDU_DEF_TXPKT_WEIGHT
;
176 ampdu
->ffpld_rsvd
= AMPDU_DEF_FFPLD_RSVD
;
177 /* bump max ampdu rcv size to 64k for all 11n devices except 4321A0 and 4321A1 */
178 if (WLCISNPHY(wlc
->band
) && NREV_LT(wlc
->band
->phyrev
, 2))
179 ampdu
->rx_factor
= IEEE80211_HT_MAX_AMPDU_32K
;
181 ampdu
->rx_factor
= IEEE80211_HT_MAX_AMPDU_64K
;
182 ampdu
->retry_limit
= AMPDU_DEF_RETRY_LIMIT
;
183 ampdu
->rr_retry_limit
= AMPDU_DEF_RR_RETRY_LIMIT
;
185 for (i
= 0; i
< AMPDU_MAX_SCB_TID
; i
++) {
186 ampdu
->retry_limit_tid
[i
] = ampdu
->retry_limit
;
187 ampdu
->rr_retry_limit_tid
[i
] = ampdu
->rr_retry_limit
;
190 ampdu_update_max_txlen(ampdu
, ampdu
->dur
);
192 /* try to set ampdu to the default value */
193 wlc_ampdu_set(ampdu
, wlc
->pub
->_ampdu
);
195 ampdu
->tx_max_funl
= FFPLD_TX_MAX_UNFL
;
196 wlc_ffpld_init(ampdu
);
201 void wlc_ampdu_detach(struct ampdu_info
*ampdu
)
208 /* free all ini's which were to be freed on callbacks which were never called */
209 for (i
= 0; i
< AMPDU_INI_FREE
; i
++) {
210 kfree(ampdu
->ini_free
[i
]);
213 wlc_module_unregister(ampdu
->wlc
->pub
, "ampdu", ampdu
);
217 static void scb_ampdu_update_config(struct ampdu_info
*ampdu
, struct scb
*scb
)
219 scb_ampdu_t
*scb_ampdu
= SCB_AMPDU_CUBBY(ampdu
, scb
);
222 scb_ampdu
->max_pdu
= (u8
) ampdu
->wlc
->pub
->tunables
->ampdunummpdu
;
224 /* go back to legacy size if some preloading is occurring */
225 for (i
= 0; i
< NUM_FFPLD_FIFO
; i
++) {
226 if (ampdu
->fifo_tb
[i
].ampdu_pld_size
> FFPLD_PLD_INCR
)
227 scb_ampdu
->max_pdu
= AMPDU_NUM_MPDU_LEGACY
;
230 /* apply user override */
231 if (ampdu
->max_pdu
!= AUTO
)
232 scb_ampdu
->max_pdu
= (u8
) ampdu
->max_pdu
;
234 scb_ampdu
->release
= min_t(u8
, scb_ampdu
->max_pdu
, AMPDU_SCB_MAX_RELEASE
);
236 if (scb_ampdu
->max_rxlen
)
238 min_t(u8
, scb_ampdu
->release
, scb_ampdu
->max_rxlen
/ 1600);
240 scb_ampdu
->release
= min(scb_ampdu
->release
,
241 ampdu
->fifo_tb
[TX_AC_BE_FIFO
].
242 mcs2ampdu_table
[FFPLD_MAX_MCS
]);
245 static void scb_ampdu_update_config_all(struct ampdu_info
*ampdu
)
247 scb_ampdu_update_config(ampdu
, ampdu
->wlc
->pub
->global_scb
);
250 static void wlc_ffpld_init(struct ampdu_info
*ampdu
)
253 wlc_fifo_info_t
*fifo
;
255 for (j
= 0; j
< NUM_FFPLD_FIFO
; j
++) {
256 fifo
= (ampdu
->fifo_tb
+ j
);
257 fifo
->ampdu_pld_size
= 0;
258 for (i
= 0; i
<= FFPLD_MAX_MCS
; i
++)
259 fifo
->mcs2ampdu_table
[i
] = 255;
260 fifo
->dmaxferrate
= 0;
261 fifo
->accum_txampdu
= 0;
262 fifo
->prev_txfunfl
= 0;
263 fifo
->accum_txfunfl
= 0;
268 /* evaluate the dma transfer rate using the tx underflows as feedback.
269 * If necessary, increase tx fifo preloading. If not enough,
270 * decrease maximum ampdu size for each mcs till underflows stop
271 * Return 1 if pre-loading not active, -1 if not an underflow event,
272 * 0 if pre-loading module took care of the event.
274 static int wlc_ffpld_check_txfunfl(struct wlc_info
*wlc
, int fid
)
276 struct ampdu_info
*ampdu
= wlc
->ampdu
;
277 u32 phy_rate
= MCS_RATE(FFPLD_MAX_MCS
, true, false);
280 u32 current_ampdu_cnt
= 0;
283 wlc_fifo_info_t
*fifo
= (ampdu
->fifo_tb
+ fid
);
287 /* return if we got here for a different reason than underflows */
290 M_UCODE_MACSTAT
+ offsetof(macstat_t
, txfunfl
[fid
]));
291 new_txunfl
= (u16
) (cur_txunfl
- fifo
->prev_txfunfl
);
292 if (new_txunfl
== 0) {
293 BCMMSG(wlc
->wiphy
, "TX status FRAG set but no tx underflows\n");
296 fifo
->prev_txfunfl
= cur_txunfl
;
298 if (!ampdu
->tx_max_funl
)
301 /* check if fifo is big enough */
302 if (wlc_xmtfifo_sz_get(wlc
, fid
, &xmtfifo_sz
)) {
306 if ((TXFIFO_SIZE_UNIT
* (u32
) xmtfifo_sz
) <= ampdu
->ffpld_rsvd
)
309 max_pld_size
= TXFIFO_SIZE_UNIT
* xmtfifo_sz
- ampdu
->ffpld_rsvd
;
310 fifo
->accum_txfunfl
+= new_txunfl
;
312 /* we need to wait for at least 10 underflows */
313 if (fifo
->accum_txfunfl
< 10)
316 BCMMSG(wlc
->wiphy
, "ampdu_count %d tx_underflows %d\n",
317 current_ampdu_cnt
, fifo
->accum_txfunfl
);
320 compute the current ratio of tx unfl per ampdu.
321 When the current ampdu count becomes too
322 big while the ratio remains small, we reset
323 the current count in order to not
324 introduce too big of a latency in detecting a
325 large amount of tx underflows later.
328 txunfl_ratio
= current_ampdu_cnt
/ fifo
->accum_txfunfl
;
330 if (txunfl_ratio
> ampdu
->tx_max_funl
) {
331 if (current_ampdu_cnt
>= FFPLD_MAX_AMPDU_CNT
) {
332 fifo
->accum_txfunfl
= 0;
337 min_t(u8
, fifo
->mcs2ampdu_table
[FFPLD_MAX_MCS
], AMPDU_NUM_MPDU_LEGACY
);
339 /* In case max value max_pdu is already lower than
340 the fifo depth, there is nothing more we can do.
343 if (fifo
->ampdu_pld_size
>= max_mpdu
* FFPLD_MPDU_SIZE
) {
344 fifo
->accum_txfunfl
= 0;
348 if (fifo
->ampdu_pld_size
< max_pld_size
) {
350 /* increment by TX_FIFO_PLD_INC bytes */
351 fifo
->ampdu_pld_size
+= FFPLD_PLD_INCR
;
352 if (fifo
->ampdu_pld_size
> max_pld_size
)
353 fifo
->ampdu_pld_size
= max_pld_size
;
355 /* update scb release size */
356 scb_ampdu_update_config_all(ampdu
);
359 compute a new dma xfer rate for max_mpdu @ max mcs.
360 This is the minimum dma rate that
361 can achieve no underflow condition for the current mpdu size.
363 /* note : we divide/multiply by 100 to avoid integer overflows */
366 (max_mpdu
* FFPLD_MPDU_SIZE
- fifo
->ampdu_pld_size
))
367 / (max_mpdu
* FFPLD_MPDU_SIZE
)) * 100;
369 BCMMSG(wlc
->wiphy
, "DMA estimated transfer rate %d; "
370 "pre-load size %d\n",
371 fifo
->dmaxferrate
, fifo
->ampdu_pld_size
);
374 /* decrease ampdu size */
375 if (fifo
->mcs2ampdu_table
[FFPLD_MAX_MCS
] > 1) {
376 if (fifo
->mcs2ampdu_table
[FFPLD_MAX_MCS
] == 255)
377 fifo
->mcs2ampdu_table
[FFPLD_MAX_MCS
] =
378 AMPDU_NUM_MPDU_LEGACY
- 1;
380 fifo
->mcs2ampdu_table
[FFPLD_MAX_MCS
] -= 1;
382 /* recompute the table */
383 wlc_ffpld_calc_mcs2ampdu_table(ampdu
, fid
);
385 /* update scb release size */
386 scb_ampdu_update_config_all(ampdu
);
389 fifo
->accum_txfunfl
= 0;
393 static void wlc_ffpld_calc_mcs2ampdu_table(struct ampdu_info
*ampdu
, int f
)
396 u32 phy_rate
, dma_rate
, tmp
;
398 wlc_fifo_info_t
*fifo
= (ampdu
->fifo_tb
+ f
);
400 /* recompute the dma rate */
401 /* note : we divide/multiply by 100 to avoid integer overflows */
403 min_t(u8
, fifo
->mcs2ampdu_table
[FFPLD_MAX_MCS
], AMPDU_NUM_MPDU_LEGACY
);
404 phy_rate
= MCS_RATE(FFPLD_MAX_MCS
, true, false);
407 (max_mpdu
* FFPLD_MPDU_SIZE
- fifo
->ampdu_pld_size
))
408 / (max_mpdu
* FFPLD_MPDU_SIZE
)) * 100;
409 fifo
->dmaxferrate
= dma_rate
;
411 /* fill up the mcs2ampdu table; do not recalc the last mcs */
412 dma_rate
= dma_rate
>> 7;
413 for (i
= 0; i
< FFPLD_MAX_MCS
; i
++) {
414 /* shifting to keep it within integer range */
415 phy_rate
= MCS_RATE(i
, true, false) >> 7;
416 if (phy_rate
> dma_rate
) {
417 tmp
= ((fifo
->ampdu_pld_size
* phy_rate
) /
418 ((phy_rate
- dma_rate
) * FFPLD_MPDU_SIZE
)) + 1;
419 tmp
= min_t(u32
, tmp
, 255);
420 fifo
->mcs2ampdu_table
[i
] = (u8
) tmp
;
426 wlc_ampdu_agg(struct ampdu_info
*ampdu
, struct scb
*scb
, struct sk_buff
*p
,
429 scb_ampdu_t
*scb_ampdu
;
430 scb_ampdu_tid_ini_t
*ini
;
431 u8 tid
= (u8
) (p
->priority
);
433 scb_ampdu
= SCB_AMPDU_CUBBY(ampdu
, scb
);
435 /* initialize initiator on first packet; sends addba req */
436 ini
= SCB_AMPDU_INI(scb_ampdu
, tid
);
437 if (ini
->magic
!= INI_MAGIC
) {
438 ini
= wlc_ampdu_init_tid_ini(ampdu
, scb_ampdu
, tid
, false);
444 wlc_sendampdu(struct ampdu_info
*ampdu
, struct wlc_txq_info
*qi
,
445 struct sk_buff
**pdu
, int prec
)
447 struct wlc_info
*wlc
;
448 struct sk_buff
*p
, *pkt
[AMPDU_MAX_MPDU
];
451 u8 preamble_type
= WLC_GF_PREAMBLE
;
452 u8 fbr_preamble_type
= WLC_GF_PREAMBLE
;
453 u8 rts_preamble_type
= WLC_LONG_PREAMBLE
;
454 u8 rts_fbr_preamble_type
= WLC_LONG_PREAMBLE
;
456 bool rr
= true, fbr
= false;
457 uint i
, count
= 0, fifo
, seg_cnt
= 0;
458 u16 plen
, len
, seq
= 0, mcl
, mch
, index
, frameid
, dma_len
= 0;
459 u32 ampdu_len
, maxlen
= 0;
460 d11txh_t
*txh
= NULL
;
462 struct ieee80211_hdr
*h
;
464 scb_ampdu_t
*scb_ampdu
;
465 scb_ampdu_tid_ini_t
*ini
;
467 bool use_rts
= false, use_cts
= false;
468 ratespec_t rspec
= 0, rspec_fallback
= 0;
469 ratespec_t rts_rspec
= 0, rts_rspec_fallback
= 0;
470 u16 mimo_ctlchbw
= PHY_TXC1_BW_20MHZ
;
471 struct ieee80211_rts
*rts
;
475 struct ieee80211_tx_info
*tx_info
;
483 tid
= (u8
) (p
->priority
);
485 f
= ampdu
->fifo_tb
+ prio2fifo
[tid
];
487 scb
= wlc
->pub
->global_scb
;
488 scb_ampdu
= SCB_AMPDU_CUBBY(ampdu
, scb
);
489 ini
= &scb_ampdu
->ini
[tid
];
491 /* Let pressure continue to build ... */
492 qlen
= pktq_plen(&qi
->q
, prec
);
493 if (ini
->tx_in_transit
> 0 && qlen
< scb_ampdu
->max_pdu
) {
497 wlc_ampdu_agg(ampdu
, scb
, p
, tid
);
499 rr_retry_limit
= ampdu
->rr_retry_limit_tid
[tid
];
503 struct ieee80211_tx_rate
*txrate
;
505 tx_info
= IEEE80211_SKB_CB(p
);
506 txrate
= tx_info
->status
.rates
;
508 if (tx_info
->flags
& IEEE80211_TX_CTL_AMPDU
) {
509 err
= wlc_prep_pdu(wlc
, p
, &fifo
);
511 wiphy_err(wiphy
, "%s: AMPDU flag is off!\n", __func__
);
519 wiphy_err(wiphy
, "wl%d: wlc_sendampdu: "
520 "prep_xdu retry; seq 0x%x\n",
521 wlc
->pub
->unit
, seq
);
526 /* error in the packet; reject it */
527 wiphy_err(wiphy
, "wl%d: wlc_sendampdu: prep_xdu "
528 "rejected; seq 0x%x\n", wlc
->pub
->unit
, seq
);
533 /* pkt is good to be aggregated */
534 txh
= (d11txh_t
*) p
->data
;
535 plcp
= (u8
*) (txh
+ 1);
536 h
= (struct ieee80211_hdr
*)(plcp
+ D11_PHY_HDR_LEN
);
537 seq
= le16_to_cpu(h
->seq_ctrl
) >> SEQNUM_SHIFT
;
538 index
= TX_SEQ_TO_INDEX(seq
);
540 /* check mcl fields and test whether it can be agg'd */
541 mcl
= le16_to_cpu(txh
->MacTxControlLow
);
542 mcl
&= ~TXC_AMPDU_MASK
;
543 fbr_iscck
= !(le16_to_cpu(txh
->XtraFrameTypes
) & 0x3);
544 txh
->PreloadSize
= 0; /* always default to 0 */
546 /* Handle retry limits */
547 if (txrate
[0].count
<= rr_retry_limit
) {
557 /* extract the length info */
558 len
= fbr_iscck
? WLC_GET_CCK_PLCP_LEN(txh
->FragPLCPFallback
)
559 : WLC_GET_MIMO_PLCP_LEN(txh
->FragPLCPFallback
);
561 /* retrieve null delimiter count */
562 ndelim
= txh
->RTSPLCPFallback
[AMPDU_FBR_NULL_DELIM
];
565 BCMMSG(wlc
->wiphy
, "wl%d: mpdu %d plcp_len %d\n",
566 wlc
->pub
->unit
, count
, len
);
569 * aggregateable mpdu. For ucode/hw agg,
570 * test whether need to break or change the epoch
573 mcl
|= (TXC_AMPDU_FIRST
<< TXC_AMPDU_SHIFT
);
574 /* refill the bits since might be a retx mpdu */
575 mcl
|= TXC_STARTMSDU
;
576 rts
= (struct ieee80211_rts
*)&txh
->rts_frame
;
578 if (ieee80211_is_rts(rts
->frame_control
)) {
582 if (ieee80211_is_cts(rts
->frame_control
)) {
587 mcl
|= (TXC_AMPDU_MIDDLE
<< TXC_AMPDU_SHIFT
);
588 mcl
&= ~(TXC_STARTMSDU
| TXC_SENDRTS
| TXC_SENDCTS
);
591 len
= roundup(len
, 4);
592 ampdu_len
+= (len
+ (ndelim
+ 1) * AMPDU_DELIMITER_LEN
);
594 dma_len
+= (u16
) brcmu_pkttotlen(p
);
596 BCMMSG(wlc
->wiphy
, "wl%d: ampdu_len %d"
597 " seg_cnt %d null delim %d\n",
598 wlc
->pub
->unit
, ampdu_len
, seg_cnt
, ndelim
);
600 txh
->MacTxControlLow
= cpu_to_le16(mcl
);
602 /* this packet is added */
605 /* patch the first MPDU */
607 u8 plcp0
, plcp3
, is40
, sgi
;
608 struct ieee80211_sta
*sta
;
610 sta
= tx_info
->control
.sta
;
616 plcp0
= txh
->FragPLCPFallback
[0];
617 plcp3
= txh
->FragPLCPFallback
[3];
620 is40
= (plcp0
& MIMO_PLCP_40MHZ
) ? 1 : 0;
621 sgi
= PLCP3_ISSGI(plcp3
) ? 1 : 0;
622 mcs
= plcp0
& ~MIMO_PLCP_40MHZ
;
624 min(scb_ampdu
->max_rxlen
,
625 ampdu
->max_txlen
[mcs
][is40
][sgi
]);
627 /* XXX Fix me to honor real max_rxlen */
628 /* can fix this as soon as ampdu_action() in mac80211.h
629 * gets extra u8buf_size par */
634 CHSPEC_SB_UPPER(WLC_BAND_PI_RADIO_CHANSPEC
)
635 ? PHY_TXC1_BW_20MHZ_UP
: PHY_TXC1_BW_20MHZ
;
637 /* rebuild the rspec and rspec_fallback */
638 rspec
= RSPEC_MIMORATE
;
639 rspec
|= plcp
[0] & ~MIMO_PLCP_40MHZ
;
640 if (plcp
[0] & MIMO_PLCP_40MHZ
)
641 rspec
|= (PHY_TXC1_BW_40MHZ
<< RSPEC_BW_SHIFT
);
643 if (fbr_iscck
) /* CCK */
645 CCK_RSPEC(CCK_PHY2MAC_RATE
646 (txh
->FragPLCPFallback
[0]));
648 rspec_fallback
= RSPEC_MIMORATE
;
650 txh
->FragPLCPFallback
[0] & ~MIMO_PLCP_40MHZ
;
651 if (txh
->FragPLCPFallback
[0] & MIMO_PLCP_40MHZ
)
653 (PHY_TXC1_BW_40MHZ
<<
657 if (use_rts
|| use_cts
) {
659 wlc_rspec_to_rts_rspec(wlc
, rspec
, false,
662 wlc_rspec_to_rts_rspec(wlc
, rspec_fallback
,
663 false, mimo_ctlchbw
);
667 /* if (first mpdu for host agg) */
668 /* test whether to add more */
669 if ((MCS_RATE(mcs
, true, false) >= f
->dmaxferrate
) &&
670 (count
== f
->mcs2ampdu_table
[mcs
])) {
671 BCMMSG(wlc
->wiphy
, "wl%d: PR 37644: stopping"
672 " ampdu at %d for mcs %d\n",
673 wlc
->pub
->unit
, count
, mcs
);
677 if (count
== scb_ampdu
->max_pdu
) {
681 /* check to see if the next pkt is a candidate for aggregation */
682 p
= pktq_ppeek(&qi
->q
, prec
);
683 tx_info
= IEEE80211_SKB_CB(p
); /* tx_info must be checked with current p */
686 if ((tx_info
->flags
& IEEE80211_TX_CTL_AMPDU
) &&
687 ((u8
) (p
->priority
) == tid
)) {
689 plen
= brcmu_pkttotlen(p
) +
690 AMPDU_MAX_MPDU_OVERHEAD
;
691 plen
= max(scb_ampdu
->min_len
, plen
);
693 if ((plen
+ ampdu_len
) > maxlen
) {
695 wiphy_err(wiphy
, "%s: Bogus plen #1\n",
700 /* check if there are enough descriptors available */
701 if (TXAVAIL(wlc
, fifo
) <= (seg_cnt
+ 1)) {
702 wiphy_err(wiphy
, "%s: No fifo space "
707 p
= brcmu_pktq_pdeq(&qi
->q
, prec
);
714 ini
->tx_in_transit
+= count
;
717 /* patch up the last txh */
718 txh
= (d11txh_t
*) pkt
[count
- 1]->data
;
719 mcl
= le16_to_cpu(txh
->MacTxControlLow
);
720 mcl
&= ~TXC_AMPDU_MASK
;
721 mcl
|= (TXC_AMPDU_LAST
<< TXC_AMPDU_SHIFT
);
722 txh
->MacTxControlLow
= cpu_to_le16(mcl
);
724 /* remove the null delimiter after last mpdu */
725 ndelim
= txh
->RTSPLCPFallback
[AMPDU_FBR_NULL_DELIM
];
726 txh
->RTSPLCPFallback
[AMPDU_FBR_NULL_DELIM
] = 0;
727 ampdu_len
-= ndelim
* AMPDU_DELIMITER_LEN
;
729 /* remove the pad len from last mpdu */
730 fbr_iscck
= ((le16_to_cpu(txh
->XtraFrameTypes
) & 0x3) == 0);
731 len
= fbr_iscck
? WLC_GET_CCK_PLCP_LEN(txh
->FragPLCPFallback
)
732 : WLC_GET_MIMO_PLCP_LEN(txh
->FragPLCPFallback
);
733 ampdu_len
-= roundup(len
, 4) - len
;
735 /* patch up the first txh & plcp */
736 txh
= (d11txh_t
*) pkt
[0]->data
;
737 plcp
= (u8
*) (txh
+ 1);
739 WLC_SET_MIMO_PLCP_LEN(plcp
, ampdu_len
);
740 /* mark plcp to indicate ampdu */
741 WLC_SET_MIMO_PLCP_AMPDU(plcp
);
743 /* reset the mixed mode header durations */
746 wlc_calc_lsig_len(wlc
, rspec
, ampdu_len
);
747 txh
->MModeLen
= cpu_to_le16(mmodelen
);
748 preamble_type
= WLC_MM_PREAMBLE
;
750 if (txh
->MModeFbrLen
) {
752 wlc_calc_lsig_len(wlc
, rspec_fallback
, ampdu_len
);
753 txh
->MModeFbrLen
= cpu_to_le16(mmfbrlen
);
754 fbr_preamble_type
= WLC_MM_PREAMBLE
;
757 /* set the preload length */
758 if (MCS_RATE(mcs
, true, false) >= f
->dmaxferrate
) {
759 dma_len
= min(dma_len
, f
->ampdu_pld_size
);
760 txh
->PreloadSize
= cpu_to_le16(dma_len
);
762 txh
->PreloadSize
= 0;
764 mch
= le16_to_cpu(txh
->MacTxControlHigh
);
766 /* update RTS dur fields */
767 if (use_rts
|| use_cts
) {
769 rts
= (struct ieee80211_rts
*)&txh
->rts_frame
;
770 if ((mch
& TXC_PREAMBLE_RTS_MAIN_SHORT
) ==
771 TXC_PREAMBLE_RTS_MAIN_SHORT
)
772 rts_preamble_type
= WLC_SHORT_PREAMBLE
;
774 if ((mch
& TXC_PREAMBLE_RTS_FB_SHORT
) ==
775 TXC_PREAMBLE_RTS_FB_SHORT
)
776 rts_fbr_preamble_type
= WLC_SHORT_PREAMBLE
;
779 wlc_compute_rtscts_dur(wlc
, use_cts
, rts_rspec
,
780 rspec
, rts_preamble_type
,
781 preamble_type
, ampdu_len
,
783 rts
->duration
= cpu_to_le16(durid
);
784 durid
= wlc_compute_rtscts_dur(wlc
, use_cts
,
787 rts_fbr_preamble_type
,
790 txh
->RTSDurFallback
= cpu_to_le16(durid
);
791 /* set TxFesTimeNormal */
792 txh
->TxFesTimeNormal
= rts
->duration
;
793 /* set fallback rate version of TxFesTimeNormal */
794 txh
->TxFesTimeFallback
= txh
->RTSDurFallback
;
797 /* set flag and plcp for fallback rate */
799 mch
|= TXC_AMPDU_FBR
;
800 txh
->MacTxControlHigh
= cpu_to_le16(mch
);
801 WLC_SET_MIMO_PLCP_AMPDU(plcp
);
802 WLC_SET_MIMO_PLCP_AMPDU(txh
->FragPLCPFallback
);
805 BCMMSG(wlc
->wiphy
, "wl%d: count %d ampdu_len %d\n",
806 wlc
->pub
->unit
, count
, ampdu_len
);
808 /* inform rate_sel if it this is a rate probe pkt */
809 frameid
= le16_to_cpu(txh
->TxFrameID
);
810 if (frameid
& TXFID_RATE_PROBE_MASK
) {
811 wiphy_err(wiphy
, "%s: XXX what to do with "
812 "TXFID_RATE_PROBE_MASK!?\n", __func__
);
814 for (i
= 0; i
< count
; i
++)
815 wlc_txfifo(wlc
, fifo
, pkt
[i
], i
== (count
- 1),
816 ampdu
->txpkt_weight
);
824 wlc_ampdu_dotxstatus(struct ampdu_info
*ampdu
, struct scb
*scb
,
825 struct sk_buff
*p
, tx_status_t
*txs
)
827 scb_ampdu_t
*scb_ampdu
;
828 struct wlc_info
*wlc
= ampdu
->wlc
;
829 scb_ampdu_tid_ini_t
*ini
;
831 struct ieee80211_tx_info
*tx_info
;
833 tx_info
= IEEE80211_SKB_CB(p
);
835 /* BMAC_NOTE: For the split driver, second level txstatus comes later
836 * So if the ACK was received then wait for the second level else just
839 if (txs
->status
& TX_STATUS_ACK_RCV
) {
842 /* wait till the next 8 bytes of txstatus is available */
843 while (((s1
= R_REG(&wlc
->regs
->frmtxstatus
)) & TXS_V
) == 0) {
846 if (status_delay
> 10) {
847 return; /* error condition */
851 s2
= R_REG(&wlc
->regs
->frmtxstatus2
);
855 scb_ampdu
= SCB_AMPDU_CUBBY(ampdu
, scb
);
856 ini
= SCB_AMPDU_INI(scb_ampdu
, p
->priority
);
857 wlc_ampdu_dotxstatus_complete(ampdu
, scb
, p
, txs
, s1
, s2
);
859 /* loop through all pkts and free */
860 u8 queue
= txs
->frameid
& TXFID_QUEUE_MASK
;
864 tx_info
= IEEE80211_SKB_CB(p
);
865 txh
= (d11txh_t
*) p
->data
;
866 mcl
= le16_to_cpu(txh
->MacTxControlLow
);
867 brcmu_pkt_buf_free_skb(p
);
868 /* break out if last packet of ampdu */
869 if (((mcl
& TXC_AMPDU_MASK
) >> TXC_AMPDU_SHIFT
) ==
872 p
= GETNEXTTXP(wlc
, queue
);
874 wlc_txfifo_complete(wlc
, queue
, ampdu
->txpkt_weight
);
876 wlc_ampdu_txflowcontrol(wlc
, scb_ampdu
, ini
);
880 rate_status(struct wlc_info
*wlc
, struct ieee80211_tx_info
*tx_info
,
881 tx_status_t
*txs
, u8 mcs
)
883 struct ieee80211_tx_rate
*txrate
= tx_info
->status
.rates
;
886 /* clear the rest of the rates */
887 for (i
= 2; i
< IEEE80211_TX_MAX_RATES
; i
++) {
893 #define SHORTNAME "AMPDU status"
896 wlc_ampdu_dotxstatus_complete(struct ampdu_info
*ampdu
, struct scb
*scb
,
897 struct sk_buff
*p
, tx_status_t
*txs
,
900 scb_ampdu_t
*scb_ampdu
;
901 struct wlc_info
*wlc
= ampdu
->wlc
;
902 scb_ampdu_tid_ini_t
*ini
;
903 u8 bitmap
[8], queue
, tid
;
906 struct ieee80211_hdr
*h
;
907 u16 seq
, start_seq
= 0, bindex
, index
, mcl
;
909 bool ba_recd
= false, ack_recd
= false;
910 u8 suc_mpdu
= 0, tot_mpdu
= 0;
912 bool update_rate
= true, retry
= true, tx_error
= false;
915 u8 retry_limit
, rr_retry_limit
;
916 struct ieee80211_tx_info
*tx_info
= IEEE80211_SKB_CB(p
);
917 struct wiphy
*wiphy
= wlc
->wiphy
;
920 u8 hole
[AMPDU_MAX_MPDU
];
921 memset(hole
, 0, sizeof(hole
));
924 scb_ampdu
= SCB_AMPDU_CUBBY(ampdu
, scb
);
925 tid
= (u8
) (p
->priority
);
927 ini
= SCB_AMPDU_INI(scb_ampdu
, tid
);
928 retry_limit
= ampdu
->retry_limit_tid
[tid
];
929 rr_retry_limit
= ampdu
->rr_retry_limit_tid
[tid
];
930 memset(bitmap
, 0, sizeof(bitmap
));
931 queue
= txs
->frameid
& TXFID_QUEUE_MASK
;
932 supr_status
= txs
->status
& TX_STATUS_SUPR_MASK
;
934 if (txs
->status
& TX_STATUS_ACK_RCV
) {
935 if (TX_STATUS_SUPR_UF
== supr_status
) {
939 WARN_ON(!(txs
->status
& TX_STATUS_INTERMEDIATE
));
940 start_seq
= txs
->sequence
>> SEQNUM_SHIFT
;
941 bitmap
[0] = (txs
->status
& TX_STATUS_BA_BMAP03_MASK
) >>
942 TX_STATUS_BA_BMAP03_SHIFT
;
944 WARN_ON(s1
& TX_STATUS_INTERMEDIATE
);
945 WARN_ON(!(s1
& TX_STATUS_AMPDU
));
948 (s1
& TX_STATUS_BA_BMAP47_MASK
) <<
949 TX_STATUS_BA_BMAP47_SHIFT
;
950 bitmap
[1] = (s1
>> 8) & 0xff;
951 bitmap
[2] = (s1
>> 16) & 0xff;
952 bitmap
[3] = (s1
>> 24) & 0xff;
954 bitmap
[4] = s2
& 0xff;
955 bitmap
[5] = (s2
>> 8) & 0xff;
956 bitmap
[6] = (s2
>> 16) & 0xff;
957 bitmap
[7] = (s2
>> 24) & 0xff;
963 if (supr_status
== TX_STATUS_SUPR_BADCH
) {
964 wiphy_err(wiphy
, "%s: Pkt tx suppressed, "
965 "illegal channel possibly %d\n",
966 __func__
, CHSPEC_CHANNEL(
967 wlc
->default_bss
->chanspec
));
969 if (supr_status
!= TX_STATUS_SUPR_FRAG
)
970 wiphy_err(wiphy
, "%s: wlc_ampdu_dotx"
971 "status:supr_status 0x%x\n",
972 __func__
, supr_status
);
974 /* no need to retry for badch; will fail again */
975 if (supr_status
== TX_STATUS_SUPR_BADCH
||
976 supr_status
== TX_STATUS_SUPR_EXPTIME
) {
978 } else if (supr_status
== TX_STATUS_SUPR_EXPTIME
) {
979 /* TX underflow : try tuning pre-loading or ampdu size */
980 } else if (supr_status
== TX_STATUS_SUPR_FRAG
) {
981 /* if there were underflows, but pre-loading is not active,
982 notify rate adaptation.
984 if (wlc_ffpld_check_txfunfl(wlc
, prio2fifo
[tid
])
989 } else if (txs
->phyerr
) {
991 wiphy_err(wiphy
, "wl%d: wlc_ampdu_dotxstatus: tx phy "
992 "error (0x%x)\n", wlc
->pub
->unit
,
996 brcmu_prpkt("txpkt (AMPDU)", p
);
997 wlc_print_txdesc((d11txh_t
*) p
->data
);
999 wlc_print_txstatus(txs
);
1003 /* loop through all pkts and retry if not acked */
1005 tx_info
= IEEE80211_SKB_CB(p
);
1006 txh
= (d11txh_t
*) p
->data
;
1007 mcl
= le16_to_cpu(txh
->MacTxControlLow
);
1008 plcp
= (u8
*) (txh
+ 1);
1009 h
= (struct ieee80211_hdr
*)(plcp
+ D11_PHY_HDR_LEN
);
1010 seq
= le16_to_cpu(h
->seq_ctrl
) >> SEQNUM_SHIFT
;
1012 if (tot_mpdu
== 0) {
1013 mcs
= plcp
[0] & MIMO_PLCP_MCS_MASK
;
1014 mimoantsel
= le16_to_cpu(txh
->ABI_MimoAntSel
);
1017 index
= TX_SEQ_TO_INDEX(seq
);
1020 bindex
= MODSUB_POW2(seq
, start_seq
, SEQNUM_MAX
);
1021 BCMMSG(wlc
->wiphy
, "tid %d seq %d,"
1022 " start_seq %d, bindex %d set %d, index %d\n",
1023 tid
, seq
, start_seq
, bindex
,
1024 isset(bitmap
, bindex
), index
);
1025 /* if acked then clear bit and free packet */
1026 if ((bindex
< AMPDU_TX_BA_MAX_WSIZE
)
1027 && isset(bitmap
, bindex
)) {
1028 ini
->tx_in_transit
--;
1029 ini
->txretry
[index
] = 0;
1031 /* ampdu_ack_len: number of acked aggregated frames */
1032 /* ampdu_len: number of aggregated frames */
1033 rate_status(wlc
, tx_info
, txs
, mcs
);
1034 tx_info
->flags
|= IEEE80211_TX_STAT_ACK
;
1035 tx_info
->flags
|= IEEE80211_TX_STAT_AMPDU
;
1036 tx_info
->status
.ampdu_ack_len
=
1037 tx_info
->status
.ampdu_len
= 1;
1039 skb_pull(p
, D11_PHY_HDR_LEN
);
1040 skb_pull(p
, D11_TXH_LEN
);
1042 ieee80211_tx_status_irqsafe(wlc
->pub
->ieee_hw
,
1048 /* either retransmit or send bar if ack not recd */
1050 struct ieee80211_tx_rate
*txrate
=
1051 tx_info
->status
.rates
;
1052 if (retry
&& (txrate
[0].count
< (int)retry_limit
)) {
1053 ini
->txretry
[index
]++;
1054 ini
->tx_in_transit
--;
1055 /* Use high prededence for retransmit to give some punch */
1056 /* wlc_txq_enq(wlc, scb, p, WLC_PRIO_TO_PREC(tid)); */
1057 wlc_txq_enq(wlc
, scb
, p
,
1058 WLC_PRIO_TO_HI_PREC(tid
));
1061 ini
->tx_in_transit
--;
1062 ieee80211_tx_info_clear_status(tx_info
);
1063 tx_info
->status
.ampdu_ack_len
= 0;
1064 tx_info
->status
.ampdu_len
= 1;
1066 IEEE80211_TX_STAT_AMPDU_NO_BACK
;
1067 skb_pull(p
, D11_PHY_HDR_LEN
);
1068 skb_pull(p
, D11_TXH_LEN
);
1069 wiphy_err(wiphy
, "%s: BA Timeout, seq %d, in_"
1070 "transit %d\n", SHORTNAME
, seq
,
1071 ini
->tx_in_transit
);
1072 ieee80211_tx_status_irqsafe(wlc
->pub
->ieee_hw
,
1078 /* break out if last packet of ampdu */
1079 if (((mcl
& TXC_AMPDU_MASK
) >> TXC_AMPDU_SHIFT
) ==
1083 p
= GETNEXTTXP(wlc
, queue
);
1087 /* update rate state */
1088 antselid
= wlc_antsel_antsel2id(wlc
->asi
, mimoantsel
);
1090 wlc_txfifo_complete(wlc
, queue
, ampdu
->txpkt_weight
);
1093 /* initialize the initiator code for tid */
1094 static scb_ampdu_tid_ini_t
*wlc_ampdu_init_tid_ini(struct ampdu_info
*ampdu
,
1095 scb_ampdu_t
*scb_ampdu
,
1096 u8 tid
, bool override
)
1098 scb_ampdu_tid_ini_t
*ini
;
1100 /* check for per-tid control of ampdu */
1101 if (!ampdu
->ini_enable
[tid
]) {
1102 wiphy_err(ampdu
->wlc
->wiphy
, "%s: Rejecting tid %d\n",
1107 ini
= SCB_AMPDU_INI(scb_ampdu
, tid
);
1109 ini
->scb
= scb_ampdu
->scb
;
1110 ini
->magic
= INI_MAGIC
;
1114 static int wlc_ampdu_set(struct ampdu_info
*ampdu
, bool on
)
1116 struct wlc_info
*wlc
= ampdu
->wlc
;
1118 wlc
->pub
->_ampdu
= false;
1121 if (!N_ENAB(wlc
->pub
)) {
1122 wiphy_err(ampdu
->wlc
->wiphy
, "wl%d: driver not "
1123 "nmode enabled\n", wlc
->pub
->unit
);
1126 if (!wlc_ampdu_cap(ampdu
)) {
1127 wiphy_err(ampdu
->wlc
->wiphy
, "wl%d: device not "
1128 "ampdu capable\n", wlc
->pub
->unit
);
1131 wlc
->pub
->_ampdu
= on
;
1137 static bool wlc_ampdu_cap(struct ampdu_info
*ampdu
)
1139 if (WLC_PHY_11N_CAP(ampdu
->wlc
->band
))
1145 static void ampdu_update_max_txlen(struct ampdu_info
*ampdu
, u8 dur
)
1149 for (mcs
= 0; mcs
< MCS_TABLE_SIZE
; mcs
++) {
1150 /* rate is in Kbps; dur is in msec ==> len = (rate * dur) / 8 */
1152 rate
= MCS_RATE(mcs
, false, false);
1153 ampdu
->max_txlen
[mcs
][0][0] = (rate
* dur
) >> 3;
1154 /* 40 MHz, No SGI */
1155 rate
= MCS_RATE(mcs
, true, false);
1156 ampdu
->max_txlen
[mcs
][1][0] = (rate
* dur
) >> 3;
1158 rate
= MCS_RATE(mcs
, false, true);
1159 ampdu
->max_txlen
[mcs
][0][1] = (rate
* dur
) >> 3;
1161 rate
= MCS_RATE(mcs
, true, true);
1162 ampdu
->max_txlen
[mcs
][1][1] = (rate
* dur
) >> 3;
1166 void wlc_ampdu_macaddr_upd(struct wlc_info
*wlc
)
1168 char template[T_RAM_ACCESS_SZ
* 2];
1170 /* driver needs to write the ta in the template; ta is at offset 16 */
1171 memset(template, 0, sizeof(template));
1172 memcpy(template, wlc
->pub
->cur_etheraddr
, ETH_ALEN
);
1173 wlc_write_template_ram(wlc
, (T_BA_TPL_BASE
+ 16), (T_RAM_ACCESS_SZ
* 2),
1177 bool wlc_aggregatable(struct wlc_info
*wlc
, u8 tid
)
1179 return wlc
->ampdu
->ini_enable
[tid
];
1182 void wlc_ampdu_shm_upd(struct ampdu_info
*ampdu
)
1184 struct wlc_info
*wlc
= ampdu
->wlc
;
1186 /* Extend ucode internal watchdog timer to match larger received frames */
1187 if ((ampdu
->rx_factor
& IEEE80211_HT_AMPDU_PARM_FACTOR
) ==
1188 IEEE80211_HT_MAX_AMPDU_64K
) {
1189 wlc_write_shm(wlc
, M_MIMO_MAXSYM
, MIMO_MAXSYM_MAX
);
1190 wlc_write_shm(wlc
, M_WATCHDOG_8TU
, WATCHDOG_8TU_MAX
);
1192 wlc_write_shm(wlc
, M_MIMO_MAXSYM
, MIMO_MAXSYM_DEF
);
1193 wlc_write_shm(wlc
, M_WATCHDOG_8TU
, WATCHDOG_8TU_DEF
);
1198 * callback function that helps flushing ampdu packets from a priority queue
1200 static bool cb_del_ampdu_pkt(struct sk_buff
*mpdu
, void *arg_a
)
1202 struct ieee80211_tx_info
*tx_info
= IEEE80211_SKB_CB(mpdu
);
1203 struct cb_del_ampdu_pars
*ampdu_pars
=
1204 (struct cb_del_ampdu_pars
*)arg_a
;
1207 rc
= tx_info
->flags
& IEEE80211_TX_CTL_AMPDU
? true : false;
1208 rc
= rc
&& (tx_info
->control
.sta
== NULL
|| ampdu_pars
->sta
== NULL
||
1209 tx_info
->control
.sta
== ampdu_pars
->sta
);
1210 rc
= rc
&& ((u8
)(mpdu
->priority
) == ampdu_pars
->tid
);
1215 * callback function that helps invalidating ampdu packets in a DMA queue
1217 static void dma_cb_fn_ampdu(void *txi
, void *arg_a
)
1219 struct ieee80211_sta
*sta
= arg_a
;
1220 struct ieee80211_tx_info
*tx_info
= (struct ieee80211_tx_info
*)txi
;
1222 if ((tx_info
->flags
& IEEE80211_TX_CTL_AMPDU
) &&
1223 (tx_info
->control
.sta
== sta
|| sta
== NULL
))
1224 tx_info
->control
.sta
= NULL
;
1228 * When a remote party is no longer available for ampdu communication, any
1229 * pending tx ampdu packets in the driver have to be flushed.
1231 void wlc_ampdu_flush(struct wlc_info
*wlc
,
1232 struct ieee80211_sta
*sta
, u16 tid
)
1234 struct wlc_txq_info
*qi
= wlc
->pkt_queue
;
1235 struct pktq
*pq
= &qi
->q
;
1237 struct cb_del_ampdu_pars ampdu_pars
;
1239 ampdu_pars
.sta
= sta
;
1240 ampdu_pars
.tid
= tid
;
1241 for (prec
= 0; prec
< pq
->num_prec
; prec
++) {
1242 brcmu_pktq_pflush(pq
, prec
, true, cb_del_ampdu_pkt
,
1243 (void *)&du_pars
);
1245 wlc_inval_dma_pkts(wlc
->hw
, sta
, dma_cb_fn_ampdu
);