athrate.h revision 1.1 1 1.1 dyoung /*-
2 1.1 dyoung * Copyright (c) 2004-2005 Sam Leffler, Errno Consulting
3 1.1 dyoung * Copyright (c) 2004 Video54 Technologies, Inc.
4 1.1 dyoung * All rights reserved.
5 1.1 dyoung *
6 1.1 dyoung * Redistribution and use in source and binary forms, with or without
7 1.1 dyoung * modification, are permitted provided that the following conditions
8 1.1 dyoung * are met:
9 1.1 dyoung * 1. Redistributions of source code must retain the above copyright
10 1.1 dyoung * notice, this list of conditions and the following disclaimer,
11 1.1 dyoung without modification.
12 1.1 dyoung * 2. Redistributions in binary form must reproduce at minimum a disclaimer
13 1.1 dyoung * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
14 1.1 dyoung * redistribution must be conditioned upon including a substantially
15 1.1 dyoung * similar Disclaimer requirement for further binary redistribution.
16 1.1 dyoung * 3. Neither the names of the above-listed copyright holders nor the names
17 1.1 dyoung * of any contributors may be used to endorse or promote products derived
18 1.1 dyoung * from this software without specific prior written permission.
19 1.1 dyoung *
20 1.1 dyoung * Alternatively, this software may be distributed under the terms of the
21 1.1 dyoung * GNU General Public License ("GPL") version 2 as published by the Free
22 1.1 dyoung * Software Foundation.
23 1.1 dyoung *
24 1.1 dyoung * NO WARRANTY
25 1.1 dyoung * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 1.1 dyoung * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 1.1 dyoung * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
28 1.1 dyoung * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
29 1.1 dyoung * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
30 1.1 dyoung * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 1.1 dyoung * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 1.1 dyoung * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
33 1.1 dyoung * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 1.1 dyoung * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
35 1.1 dyoung * THE POSSIBILITY OF SUCH DAMAGES.
36 1.1 dyoung *
37 1.1 dyoung * $FreeBSD: src/sys/dev/ath/if_athrate.h,v 1.4 2005/04/02 18:54:30 sam Exp $
38 1.1 dyoung */
39 1.1 dyoung #ifndef _ATH_RATECTRL_H_
40 1.1 dyoung #define _ATH_RATECTRL_H_
41 1.1 dyoung
42 1.1 dyoung /*
43 1.1 dyoung * Interface definitions for transmit rate control modules for the
44 1.1 dyoung * Atheros driver.
45 1.1 dyoung *
46 1.1 dyoung * A rate control module is responsible for choosing the transmit rate
47 1.1 dyoung * for each data frame. Management+control frames are always sent at
48 1.1 dyoung * a fixed rate.
49 1.1 dyoung *
50 1.1 dyoung * Only one module may be present at a time; the driver references
51 1.1 dyoung * rate control interfaces by symbol name. If multiple modules are
52 1.1 dyoung * to be supported we'll need to switch to a registration-based scheme
53 1.1 dyoung * as is currently done, for example, for authentication modules.
54 1.1 dyoung *
55 1.1 dyoung * An instance of the rate control module is attached to each device
56 1.1 dyoung * at attach time and detached when the device is destroyed. The module
57 1.1 dyoung * may associate data with each device and each node (station). Both
58 1.1 dyoung * sets of storage are opaque except for the size of the per-node storage
59 1.1 dyoung * which must be provided when the module is attached.
60 1.1 dyoung *
61 1.1 dyoung * The rate control module is notified for each state transition and
62 1.1 dyoung * station association/reassociation. Otherwise it is queried for a
63 1.1 dyoung * rate for each outgoing frame and provided status from each transmitted
64 1.1 dyoung * frame. Any ancillary processing is the responsibility of the module
65 1.1 dyoung * (e.g. if periodic processing is required then the module should setup
66 1.1 dyoung * it's own timer).
67 1.1 dyoung *
68 1.1 dyoung * In addition to the transmit rate for each frame the module must also
69 1.1 dyoung * indicate the number of attempts to make at the specified rate. If this
70 1.1 dyoung * number is != ATH_TXMAXTRY then an additional callback is made to setup
71 1.1 dyoung * additional transmit state. The rate control code is assumed to write
72 1.1 dyoung * this additional data directly to the transmit descriptor.
73 1.1 dyoung */
74 1.1 dyoung struct ath_softc;
75 1.1 dyoung struct ath_node;
76 1.1 dyoung struct ath_desc;
77 1.1 dyoung
78 1.1 dyoung struct ath_ratectrl {
79 1.1 dyoung size_t arc_space; /* space required for per-node state */
80 1.1 dyoung };
81 1.1 dyoung /*
82 1.1 dyoung * Attach/detach a rate control module.
83 1.1 dyoung */
84 1.1 dyoung struct ath_ratectrl *ath_rate_attach(struct ath_softc *);
85 1.1 dyoung void ath_rate_detach(struct ath_ratectrl *);
86 1.1 dyoung
87 1.1 dyoung
88 1.1 dyoung /*
89 1.1 dyoung * State storage handling.
90 1.1 dyoung */
91 1.1 dyoung /*
92 1.1 dyoung * Initialize per-node state already allocated for the specified
93 1.1 dyoung * node; this space can be assumed initialized to zero.
94 1.1 dyoung */
95 1.1 dyoung void ath_rate_node_init(struct ath_softc *, struct ath_node *);
96 1.1 dyoung /*
97 1.1 dyoung * Cleanup any per-node state prior to the node being reclaimed.
98 1.1 dyoung */
99 1.1 dyoung void ath_rate_node_cleanup(struct ath_softc *, struct ath_node *);
100 1.1 dyoung /*
101 1.1 dyoung * Update rate control state on station associate/reassociate
102 1.1 dyoung * (when operating as an ap or for nodes discovered when operating
103 1.1 dyoung * in ibss mode).
104 1.1 dyoung */
105 1.1 dyoung void ath_rate_newassoc(struct ath_softc *, struct ath_node *,
106 1.1 dyoung int isNewAssociation);
107 1.1 dyoung /*
108 1.1 dyoung * Update/reset rate control state for 802.11 state transitions.
109 1.1 dyoung * Important mostly as the analog to ath_rate_newassoc when operating
110 1.1 dyoung * in station mode.
111 1.1 dyoung */
112 1.1 dyoung void ath_rate_newstate(struct ath_softc *, enum ieee80211_state);
113 1.1 dyoung
114 1.1 dyoung /*
115 1.1 dyoung * Transmit handling.
116 1.1 dyoung */
117 1.1 dyoung /*
118 1.1 dyoung * Return the transmit info for a data packet. If multi-rate state
119 1.1 dyoung * is to be setup then try0 should contain a value other than ATH_TXMATRY
120 1.1 dyoung * and ath_rate_setupxtxdesc will be called after deciding if the frame
121 1.1 dyoung * can be transmitted with multi-rate retry.
122 1.1 dyoung */
123 1.1 dyoung void ath_rate_findrate(struct ath_softc *, struct ath_node *,
124 1.1 dyoung int shortPreamble, size_t frameLen,
125 1.1 dyoung u_int8_t *rix, int *try0, u_int8_t *txrate);
126 1.1 dyoung /*
127 1.1 dyoung * Setup any extended (multi-rate) descriptor state for a data packet.
128 1.1 dyoung * The rate index returned by ath_rate_findrate is passed back in.
129 1.1 dyoung */
130 1.1 dyoung void ath_rate_setupxtxdesc(struct ath_softc *, struct ath_node *,
131 1.1 dyoung struct ath_desc *, int shortPreamble, u_int8_t rix);
132 1.1 dyoung /*
133 1.1 dyoung * Update rate control state for a packet associated with the
134 1.1 dyoung * supplied transmit descriptor. The routine is invoked both
135 1.1 dyoung * for packets that were successfully sent and for those that
136 1.1 dyoung * failed (consult the descriptor for details).
137 1.1 dyoung */
138 1.1 dyoung void ath_rate_tx_complete(struct ath_softc *, struct ath_node *,
139 1.1 dyoung const struct ath_desc *last, const struct ath_desc *first);
140 1.1 dyoung #endif /* _ATH_RATECTRL_H_ */
141