1c774d57fSLorenzo Bianconi /*
2c774d57fSLorenzo Bianconi  * Copyright (c) 2014, Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
3c774d57fSLorenzo Bianconi  *
4c774d57fSLorenzo Bianconi  * Permission to use, copy, modify, and/or distribute this software for any
5c774d57fSLorenzo Bianconi  * purpose with or without fee is hereby granted, provided that the above
6c774d57fSLorenzo Bianconi  * copyright notice and this permission notice appear in all copies.
7c774d57fSLorenzo Bianconi  *
8c774d57fSLorenzo Bianconi  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9c774d57fSLorenzo Bianconi  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10c774d57fSLorenzo Bianconi  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11c774d57fSLorenzo Bianconi  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12c774d57fSLorenzo Bianconi  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13c774d57fSLorenzo Bianconi  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14c774d57fSLorenzo Bianconi  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15c774d57fSLorenzo Bianconi  */
16c774d57fSLorenzo Bianconi 
17c774d57fSLorenzo Bianconi #ifndef DYNACK_H
18c774d57fSLorenzo Bianconi #define DYNACK_H
19c774d57fSLorenzo Bianconi 
20c774d57fSLorenzo Bianconi #define ATH_DYN_BUF	64
21c774d57fSLorenzo Bianconi 
22c774d57fSLorenzo Bianconi struct ath_hw;
23c774d57fSLorenzo Bianconi struct ath_node;
24c774d57fSLorenzo Bianconi 
25c774d57fSLorenzo Bianconi /**
26c774d57fSLorenzo Bianconi  * struct ath_dyn_rxbuf - ACK frame ring buffer
27c774d57fSLorenzo Bianconi  * @h_rb: ring buffer head
28c774d57fSLorenzo Bianconi  * @t_rb: ring buffer tail
29c774d57fSLorenzo Bianconi  * @tstamp: ACK RX timestamp buffer
30c774d57fSLorenzo Bianconi  */
31c774d57fSLorenzo Bianconi struct ath_dyn_rxbuf {
32c774d57fSLorenzo Bianconi 	u16 h_rb, t_rb;
33c774d57fSLorenzo Bianconi 	u32 tstamp[ATH_DYN_BUF];
34c774d57fSLorenzo Bianconi };
35c774d57fSLorenzo Bianconi 
36c774d57fSLorenzo Bianconi struct ts_info {
37c774d57fSLorenzo Bianconi 	u32 tstamp;
38c774d57fSLorenzo Bianconi 	u32 dur;
39c774d57fSLorenzo Bianconi };
40c774d57fSLorenzo Bianconi 
41c774d57fSLorenzo Bianconi struct haddr_pair {
42c774d57fSLorenzo Bianconi 	u8 h_dest[ETH_ALEN];
43c774d57fSLorenzo Bianconi 	u8 h_src[ETH_ALEN];
44c774d57fSLorenzo Bianconi };
45c774d57fSLorenzo Bianconi 
46c774d57fSLorenzo Bianconi /**
47c774d57fSLorenzo Bianconi  * struct ath_dyn_txbuf - tx frame ring buffer
48c774d57fSLorenzo Bianconi  * @h_rb: ring buffer head
49c774d57fSLorenzo Bianconi  * @t_rb: ring buffer tail
50c774d57fSLorenzo Bianconi  * @addr: dest/src address pair for a given TX frame
51c774d57fSLorenzo Bianconi  * @ts: TX frame timestamp buffer
52c774d57fSLorenzo Bianconi  */
53c774d57fSLorenzo Bianconi struct ath_dyn_txbuf {
54c774d57fSLorenzo Bianconi 	u16 h_rb, t_rb;
55c774d57fSLorenzo Bianconi 	struct haddr_pair addr[ATH_DYN_BUF];
56c774d57fSLorenzo Bianconi 	struct ts_info ts[ATH_DYN_BUF];
57c774d57fSLorenzo Bianconi };
58c774d57fSLorenzo Bianconi 
59c774d57fSLorenzo Bianconi /**
60c774d57fSLorenzo Bianconi  * struct ath_dynack - dynack processing info
61c774d57fSLorenzo Bianconi  * @enabled: enable dyn ack processing
62c774d57fSLorenzo Bianconi  * @ackto: current ACK timeout
63c774d57fSLorenzo Bianconi  * @lto: last ACK timeout computation
64c774d57fSLorenzo Bianconi  * @nodes: ath_node linked list
65c774d57fSLorenzo Bianconi  * @qlock: ts queue spinlock
66c774d57fSLorenzo Bianconi  * @ack_rbf: ACK ts ring buffer
67c774d57fSLorenzo Bianconi  * @st_rbf: status ts ring buffer
68c774d57fSLorenzo Bianconi  */
69c774d57fSLorenzo Bianconi struct ath_dynack {
70c774d57fSLorenzo Bianconi 	bool enabled;
71c774d57fSLorenzo Bianconi 	int ackto;
72c774d57fSLorenzo Bianconi 	unsigned long lto;
73c774d57fSLorenzo Bianconi 
74c774d57fSLorenzo Bianconi 	struct list_head nodes;
75c774d57fSLorenzo Bianconi 
76c774d57fSLorenzo Bianconi 	/* protect timestamp queue access */
77c774d57fSLorenzo Bianconi 	spinlock_t qlock;
78c774d57fSLorenzo Bianconi 	struct ath_dyn_rxbuf ack_rbf;
79c774d57fSLorenzo Bianconi 	struct ath_dyn_txbuf st_rbf;
80c774d57fSLorenzo Bianconi };
81c774d57fSLorenzo Bianconi 
82c774d57fSLorenzo Bianconi #if defined(CONFIG_ATH9K_DYNACK)
83c774d57fSLorenzo Bianconi void ath_dynack_reset(struct ath_hw *ah);
84c774d57fSLorenzo Bianconi void ath_dynack_node_init(struct ath_hw *ah, struct ath_node *an);
85c774d57fSLorenzo Bianconi void ath_dynack_node_deinit(struct ath_hw *ah, struct ath_node *an);
86c774d57fSLorenzo Bianconi void ath_dynack_init(struct ath_hw *ah);
87c774d57fSLorenzo Bianconi void ath_dynack_sample_ack_ts(struct ath_hw *ah, struct sk_buff *skb, u32 ts);
88c774d57fSLorenzo Bianconi void ath_dynack_sample_tx_ts(struct ath_hw *ah, struct sk_buff *skb,
890c60c490SLorenzo Bianconi 			     struct ath_tx_status *ts,
900c60c490SLorenzo Bianconi 			     struct ieee80211_sta *sta);
91c774d57fSLorenzo Bianconi #else
ath_dynack_init(struct ath_hw * ah)92c774d57fSLorenzo Bianconi static inline void ath_dynack_init(struct ath_hw *ah) {}
ath_dynack_node_init(struct ath_hw * ah,struct ath_node * an)93c774d57fSLorenzo Bianconi static inline void ath_dynack_node_init(struct ath_hw *ah,
94c774d57fSLorenzo Bianconi 					struct ath_node *an) {}
ath_dynack_node_deinit(struct ath_hw * ah,struct ath_node * an)95c774d57fSLorenzo Bianconi static inline void ath_dynack_node_deinit(struct ath_hw *ah,
96c774d57fSLorenzo Bianconi 					  struct ath_node *an) {}
ath_dynack_sample_ack_ts(struct ath_hw * ah,struct sk_buff * skb,u32 ts)97c774d57fSLorenzo Bianconi static inline void ath_dynack_sample_ack_ts(struct ath_hw *ah,
98c774d57fSLorenzo Bianconi 					    struct sk_buff *skb, u32 ts) {}
ath_dynack_sample_tx_ts(struct ath_hw * ah,struct sk_buff * skb,struct ath_tx_status * ts,struct ieee80211_sta * sta)99c774d57fSLorenzo Bianconi static inline void ath_dynack_sample_tx_ts(struct ath_hw *ah,
100c774d57fSLorenzo Bianconi 					   struct sk_buff *skb,
1010c60c490SLorenzo Bianconi 					   struct ath_tx_status *ts,
1020c60c490SLorenzo Bianconi 					   struct ieee80211_sta *sta) {}
103c774d57fSLorenzo Bianconi #endif
104c774d57fSLorenzo Bianconi 
105c774d57fSLorenzo Bianconi #endif /* DYNACK_H */
106