3 * Copyright (c) 2004-2010 Atheros Communications Inc.
8 // Permission to use, copy, modify, and/or distribute this software for any
9 // purpose with or without fee is hereby granted, provided that the above
10 // copyright notice and this permission notice appear in all copies.
12 // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24 #ifndef __AGGR_RX_INTERNAL_H__
25 #define __AGGR_RX_INTERNAL_H__
28 #include "aggr_recv_api.h"
30 #define AGGR_WIN_IDX(x, y) ((x) % (y))
31 #define AGGR_INCR_IDX(x, y) AGGR_WIN_IDX(((x)+1), (y))
32 #define AGGR_DCRM_IDX(x, y) AGGR_WIN_IDX(((x)-1), (y))
33 #define IEEE80211_MAX_SEQ_NO 0xFFF
34 #define IEEE80211_NEXT_SEQ_NO(x) (((x) + 1) & IEEE80211_MAX_SEQ_NO)
38 #define AGGR_SZ_DEFAULT 8
40 #define AGGR_WIN_SZ_MIN 2
41 #define AGGR_WIN_SZ_MAX 8
42 /* TID Window sz is double of what is negotiated. Derive TID_WINDOW_SZ from win_sz, per tid */
43 #define TID_WINDOW_SZ(_x) ((_x) << 1)
45 #define AGGR_NUM_OF_FREE_NETBUFS 16
47 #define AGGR_GET_RXTID_STATS(_p, _x) (&(_p->stat[(_x)]))
48 #define AGGR_GET_RXTID(_p, _x) (&(_p->RxTid[(_x)]))
50 /* Hold q is a function of win_sz, which is negotiated per tid */
51 #define HOLD_Q_SZ(_x) (TID_WINDOW_SZ((_x))*sizeof(OSBUF_HOLD_Q))
52 /* AGGR_RX_TIMEOUT value is important as a (too) small value can cause frames to be
53 * delivered out of order and a (too) large value can cause undesirable latency in
54 * certain situations. */
55 #define AGGR_RX_TIMEOUT 400 /* Timeout(in ms) for delivery of frames, if they are stuck */
77 bool aggr; /* is it ON or OFF */
78 bool progress; /* true when frames have arrived after a timer start */
79 bool timerMon; /* true if the timer started for the sake of this TID */
80 u16 win_sz; /* negotiated window size */
81 u16 seq_next; /* Next seq no, in current window */
82 u32 hold_q_sz; /* Num of frames that can be held in hold q */
83 OSBUF_HOLD_Q *hold_q; /* Hold q for re-order */
85 WINDOW_SNAPSHOT old_win; /* Sliding window snapshot - for timeout */
87 A_NETBUF_QUEUE_T q; /* q head for enqueuing frames for dispatch */
92 u32 num_into_aggr; /* hitting at the input of this module */
93 u32 num_dups; /* duplicate */
94 u32 num_oow; /* out of window */
95 u32 num_mpdu; /* single payload 802.3/802.11 frame */
96 u32 num_amsdu; /* AMSDU */
97 u32 num_delivered; /* frames delivered to IP stack */
98 u32 num_timeouts; /* num of timeouts, during which frames delivered */
99 u32 num_hole; /* frame not present, when window moved over */
100 u32 num_bar; /* num of resets of seq_num, via BAR */
104 u8 aggr_sz; /* config value of aggregation size */
106 A_TIMER timer; /* timer for returning held up pkts in re-order que */
107 void *dev; /* dev handle */
108 RX_CALLBACK rx_fn; /* callback function to return frames; to upper layer */
109 RXTID RxTid[NUM_OF_TIDS]; /* Per tid window */
110 ALLOC_NETBUFS netbuf_allocator; /* OS netbuf alloc fn */
111 A_NETBUF_QUEUE_T freeQ; /* pre-allocated buffers - for A_MSDU slicing */
112 RXTID_STATS stat[NUM_OF_TIDS]; /* Tid based statistics */
113 PACKET_LOG pkt_log; /* Log info of the packets */
116 #endif /* __AGGR_RX_INTERNAL_H__ */