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