Initial cut of the open ath9k htc firmware.
[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
50 struct ath_ratectrl {
51         size_t  arc_space;      /* space required for per-node state */
52 };
53
54 #define ATH_RC_DS_FLAG               0x01
55 #define ATH_RC_CW40_FLAG             0x02
56 #define ATH_RC_HT40_SGI_FLAG         0x04
57 #define ATH_RC_HT_FLAG               0x08
58 #define ATH_RC_RTSCTS_FLAG           0x10
59 #define ATH_RC_TX_STBC_FLAG          0x20    /* TX STBC */
60 #define ATH_RC_RX_STBC_FLAG          0xC0    /* RX STBC ,2 bits */
61 #define ATH_RC_RX_STBC_FLAG_S        6   
62 #define ATH_RC_WEP_TKIP_FLAG         0x100    /* WEP/TKIP encryption */
63
64 enum ath_rc_cwmode{
65         ATH_RC_CW20_MODE,
66         ATH_RC_CW40_MODE,     
67 };
68
69 #define ATH_RC_PROBE_ALLOWED    0x00000001
70 #define ATH_RC_MINRATE_LASTRATE 0x00000002
71
72 struct ath_rc_series {
73         a_uint8_t rix;  
74         a_uint8_t tries;        
75         u_int8_t tx_chainmask;
76         a_uint8_t flags;
77         a_uint32_t max4msframelen;
78         a_uint32_t txrateKbps;
79 };
80
81 /*
82  * Attach/detach a rate control module.
83  */
84 struct ath_ratectrl *ath_rate_attach(struct ath_softc_tgt *);
85 void ath_rate_detach(struct ath_ratectrl *);
86
87 /*
88  * Return the transmit info for a data packet.  If multi-rate state
89  * is to be setup then try0 should contain a value other than ATH_TXMATRY
90  * and ath_rate_setupxtxdesc will be called after deciding if the frame
91  * can be transmitted with multi-rate retry.
92  */
93 void ath_rate_findrate(struct ath_softc_tgt *sc,
94                        struct ath_node_target *an,
95                        a_int32_t shortPreamble,
96                        size_t frameLen,
97                        a_int32_t numTries,
98                        a_int32_t numRates,
99                        a_int32_t stepDnInc,
100                        a_uint32_t rcflag,
101                        struct ath_rc_series series[],
102                        a_int32_t *isProbe);
103 /*
104  * Update rate control state for a packet associated with the
105  * supplied transmit descriptor.  The routine is invoked both
106  * for packets that were successfully sent and for those that
107  * failed (consult the descriptor for details).
108  */
109 void ath_rate_tx_complete(struct ath_softc_tgt *, struct ath_node_target *,
110                           struct ath_tx_desc *, struct ath_rc_series series[],
111                           a_int32_t nframes, a_int32_t nbad);
112
113
114 void ath_rate_stateupdate(struct ath_softc_tgt *sc, struct ath_node_target *an, 
115                           enum ath_rc_cwmode cwmode);
116
117 #endif /* _ATH_RATECTRL_H_ */