if_athrate.h revision 165185
1285SN/A/*- 2461SN/A * Copyright (c) 2004-2005 Sam Leffler, Errno Consulting 3285SN/A * Copyright (c) 2004 Video54 Technologies, Inc. 4285SN/A * All rights reserved. 5285SN/A * 6285SN/A * Redistribution and use in source and binary forms, with or without 7285SN/A * modification, are permitted provided that the following conditions 8285SN/A * are met: 9285SN/A * 1. Redistributions of source code must retain the above copyright 10285SN/A * notice, this list of conditions and the following disclaimer, 11285SN/A without modification. 12285SN/A * 2. Redistributions in binary form must reproduce at minimum a disclaimer 13285SN/A * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any 14285SN/A * redistribution must be conditioned upon including a substantially 15285SN/A * similar Disclaimer requirement for further binary redistribution. 16285SN/A * 3. Neither the names of the above-listed copyright holders nor the names 17285SN/A * of any contributors may be used to endorse or promote products derived 18285SN/A * from this software without specific prior written permission. 19285SN/A * 20285SN/A * Alternatively, this software may be distributed under the terms of the 21285SN/A * GNU General Public License ("GPL") version 2 as published by the Free 22285SN/A * Software Foundation. 23285SN/A * 24285SN/A * NO WARRANTY 25285SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 26285SN/A * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 27285SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY 28285SN/A * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 29285SN/A * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, 30285SN/A * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31285SN/A * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32285SN/A * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 33285SN/A * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34285SN/A * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 35285SN/A * THE POSSIBILITY OF SUCH DAMAGES. 36285SN/A * 37285SN/A * $FreeBSD: head/sys/dev/ath/if_athrate.h 165185 2006-12-13 19:34:35Z sam $ 38285SN/A */ 39285SN/A#ifndef _ATH_RATECTRL_H_ 40285SN/A#define _ATH_RATECTRL_H_ 41285SN/A 42285SN/A/* 43285SN/A * Interface definitions for transmit rate control modules for the 44285SN/A * Atheros driver. 45285SN/A * 46285SN/A * A rate control module is responsible for choosing the transmit rate 47285SN/A * for each data frame. Management+control frames are always sent at 48285SN/A * a fixed rate. 49285SN/A * 50285SN/A * Only one module may be present at a time; the driver references 51285SN/A * rate control interfaces by symbol name. If multiple modules are 52285SN/A * to be supported we'll need to switch to a registration-based scheme 53285SN/A * as is currently done, for example, for authentication modules. 54285SN/A * 55285SN/A * An instance of the rate control module is attached to each device 56285SN/A * at attach time and detached when the device is destroyed. The module 57285SN/A * may associate data with each device and each node (station). Both 58285SN/A * sets of storage are opaque except for the size of the per-node storage 59285SN/A * which must be provided when the module is attached. 60285SN/A * 61285SN/A * The rate control module is notified for each state transition and 62285SN/A * station association/reassociation. Otherwise it is queried for a 63285SN/A * rate for each outgoing frame and provided status from each transmitted 64285SN/A * frame. Any ancillary processing is the responsibility of the module 65285SN/A * (e.g. if periodic processing is required then the module should setup 66 * it's own timer). 67 * 68 * In addition to the transmit rate for each frame the module must also 69 * indicate the number of attempts to make at the specified rate. If this 70 * number is != ATH_TXMAXTRY then an additional callback is made to setup 71 * additional transmit state. The rate control code is assumed to write 72 * this additional data directly to the transmit descriptor. 73 */ 74struct ath_softc; 75struct ath_node; 76struct ath_desc; 77 78struct ath_ratectrl { 79 size_t arc_space; /* space required for per-node state */ 80}; 81/* 82 * Attach/detach a rate control module. 83 */ 84struct ath_ratectrl *ath_rate_attach(struct ath_softc *); 85void ath_rate_detach(struct ath_ratectrl *); 86 87 88/* 89 * State storage handling. 90 */ 91/* 92 * Initialize per-node state already allocated for the specified 93 * node; this space can be assumed initialized to zero. 94 */ 95void ath_rate_node_init(struct ath_softc *, struct ath_node *); 96/* 97 * Cleanup any per-node state prior to the node being reclaimed. 98 */ 99void ath_rate_node_cleanup(struct ath_softc *, struct ath_node *); 100/* 101 * Update rate control state on station associate/reassociate 102 * (when operating as an ap or for nodes discovered when operating 103 * in ibss mode). 104 */ 105void ath_rate_newassoc(struct ath_softc *, struct ath_node *, 106 int isNewAssociation); 107/* 108 * Update/reset rate control state for 802.11 state transitions. 109 * Important mostly as the analog to ath_rate_newassoc when operating 110 * in station mode. 111 */ 112void ath_rate_newstate(struct ath_softc *, enum ieee80211_state); 113 114/* 115 * Transmit handling. 116 */ 117/* 118 * Return the transmit info for a data packet. If multi-rate state 119 * is to be setup then try0 should contain a value other than ATH_TXMATRY 120 * and ath_rate_setupxtxdesc will be called after deciding if the frame 121 * can be transmitted with multi-rate retry. 122 */ 123void ath_rate_findrate(struct ath_softc *, struct ath_node *, 124 int shortPreamble, size_t frameLen, 125 u_int8_t *rix, int *try0, u_int8_t *txrate); 126/* 127 * Setup any extended (multi-rate) descriptor state for a data packet. 128 * The rate index returned by ath_rate_findrate is passed back in. 129 */ 130void ath_rate_setupxtxdesc(struct ath_softc *, struct ath_node *, 131 struct ath_desc *, int shortPreamble, u_int8_t rix); 132/* 133 * Update rate control state for a packet associated with the 134 * supplied transmit descriptor. The routine is invoked both 135 * for packets that were successfully sent and for those that 136 * failed (consult the descriptor for details). 137 */ 138struct ath_buf; 139void ath_rate_tx_complete(struct ath_softc *, struct ath_node *, 140 const struct ath_buf *); 141#endif /* _ATH_RATECTRL_H_ */ 142