ath9k_htc: Update to upstream's commit d19607454d656cb14d8c16dfbf161eebb542e8fe dated...
[linux-libre-firmware.git] / ath9k_htc / target_firmware / wlan / if_athrate.h
1 /*-
2  * Copyright (c) 2004 Sam Leffler, Errno Consulting
3  * Copyright (c) 2004 Video54 Technologies, Inc.
4  * Copyright (c) 2013 Qualcomm Atheros, Inc.
5  *
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted (subject to the limitations in the
10  * disclaimer below) provided that the following conditions are met:
11  *
12  *  * Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  *
15  *  * Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the
18  *    distribution.
19  *
20  *  * Neither the name of Qualcomm Atheros nor the names of its
21  *    contributors may be used to endorse or promote products derived
22  *    from this software without specific prior written permission.
23  *
24  * Alternatively, this software may be distributed under the terms of the
25  * GNU General Public License ("GPL") version 2 as published by the Free
26  * Software Foundation.
27  *
28  * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
29  * GRANTED BY THIS LICENSE.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
30  * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
31  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
32  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
33  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
34  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
35  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
36  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
37  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
38  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
39  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
40  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41  */
42 #ifndef _ATH_RATECTRL_H_
43 #define _ATH_RATECTRL_H_
44
45 struct ath_softc_tgt;
46 struct ath_node;
47 struct ath_node_target;
48 struct ath_desc;
49 struct ieee80211vap;
50 struct ieee80211com_target;
51 struct ath_tx_desc;
52
53 struct ath_ratectrl {
54         size_t  arc_space;      /* space required for per-node state */
55 };
56
57 #define ATH_RC_DS_FLAG               0x01
58 #define ATH_RC_CW40_FLAG             0x02
59 #define ATH_RC_HT40_SGI_FLAG         0x04
60 #define ATH_RC_HT_FLAG               0x08
61 #define ATH_RC_RTSCTS_FLAG           0x10
62 #define ATH_RC_TX_STBC_FLAG          0x20    /* TX STBC */
63 #define ATH_RC_RX_STBC_FLAG          0xC0    /* RX STBC ,2 bits */
64 #define ATH_RC_RX_STBC_FLAG_S        6
65 #define ATH_RC_WEP_TKIP_FLAG         0x100    /* WEP/TKIP encryption */
66
67 enum ath_rc_cwmode{
68         ATH_RC_CW20_MODE,
69         ATH_RC_CW40_MODE,
70 };
71
72 #define ATH_RC_PROBE_ALLOWED    0x00000001
73 #define ATH_RC_MINRATE_LASTRATE 0x00000002
74
75 struct ath_rc_series {
76         a_uint8_t rix;
77         a_uint8_t tries;
78         u_int8_t tx_chainmask;
79         a_uint8_t flags;
80         a_uint32_t max4msframelen;
81         a_uint32_t txrateKbps;
82 };
83
84 /*
85  * Attach/detach a rate control module.
86  */
87 struct ath_ratectrl *ath_rate_attach(struct ath_softc_tgt *);
88
89 /*
90  * Return the transmit info for a data packet.  If multi-rate state
91  * is to be setup then try0 should contain a value other than ATH_TXMATRY
92  * and ath_rate_setupxtxdesc will be called after deciding if the frame
93  * can be transmitted with multi-rate retry.
94  */
95 void ath_rate_findrate(struct ath_softc_tgt *sc,
96                        struct ath_node_target *an,
97                        a_int32_t shortPreamble,
98                        size_t frameLen,
99                        a_int32_t numTries,
100                        a_int32_t numRates,
101                        a_int32_t stepDnInc,
102                        a_uint32_t rcflag,
103                        struct ath_rc_series series[],
104                        a_int32_t *isProbe);
105 /*
106  * Update rate control state for a packet associated with the
107  * supplied transmit descriptor.  The routine is invoked both
108  * for packets that were successfully sent and for those that
109  * failed (consult the descriptor for details).
110  */
111 void ath_rate_tx_complete(struct ath_softc_tgt *, struct ath_node_target *,
112                           struct ath_tx_desc *, struct ath_rc_series series[],
113                           a_int32_t nframes, a_int32_t nbad);
114
115
116 void ath_rate_stateupdate(struct ath_softc_tgt *sc, struct ath_node_target *an,
117                           enum ath_rc_cwmode cwmode);
118
119
120 void ath_tx_status_update_rate(struct ath_softc_tgt *sc,
121                                struct ath_rc_series rcs[],
122                                int series,
123                                WMI_TXSTATUS_EVENT *txs);
124
125 #endif /* _ATH_RATECTRL_H_ */