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