if_athrate.h revision 165185
1138570Ssam/*- 2139530Ssam * Copyright (c) 2004-2005 Sam Leffler, Errno Consulting 3138570Ssam * Copyright (c) 2004 Video54 Technologies, Inc. 4138570Ssam * All rights reserved. 5138570Ssam * 6138570Ssam * Redistribution and use in source and binary forms, with or without 7138570Ssam * modification, are permitted provided that the following conditions 8138570Ssam * are met: 9138570Ssam * 1. Redistributions of source code must retain the above copyright 10138570Ssam * notice, this list of conditions and the following disclaimer, 11138570Ssam without modification. 12138570Ssam * 2. Redistributions in binary form must reproduce at minimum a disclaimer 13138570Ssam * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any 14138570Ssam * redistribution must be conditioned upon including a substantially 15138570Ssam * similar Disclaimer requirement for further binary redistribution. 16138570Ssam * 3. Neither the names of the above-listed copyright holders nor the names 17138570Ssam * of any contributors may be used to endorse or promote products derived 18138570Ssam * from this software without specific prior written permission. 19138570Ssam * 20138570Ssam * Alternatively, this software may be distributed under the terms of the 21138570Ssam * GNU General Public License ("GPL") version 2 as published by the Free 22138570Ssam * Software Foundation. 23138570Ssam * 24138570Ssam * NO WARRANTY 25138570Ssam * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 26138570Ssam * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 27138570Ssam * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY 28138570Ssam * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 29138570Ssam * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, 30138570Ssam * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31138570Ssam * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32138570Ssam * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 33138570Ssam * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34138570Ssam * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 35138570Ssam * THE POSSIBILITY OF SUCH DAMAGES. 36138570Ssam * 37138570Ssam * $FreeBSD: head/sys/dev/ath/if_athrate.h 165185 2006-12-13 19:34:35Z sam $ 38138570Ssam */ 39138570Ssam#ifndef _ATH_RATECTRL_H_ 40138570Ssam#define _ATH_RATECTRL_H_ 41138570Ssam 42138570Ssam/* 43138570Ssam * Interface definitions for transmit rate control modules for the 44138570Ssam * Atheros driver. 45138570Ssam * 46138570Ssam * A rate control module is responsible for choosing the transmit rate 47138570Ssam * for each data frame. Management+control frames are always sent at 48138570Ssam * a fixed rate. 49138570Ssam * 50138570Ssam * Only one module may be present at a time; the driver references 51138570Ssam * rate control interfaces by symbol name. If multiple modules are 52138570Ssam * to be supported we'll need to switch to a registration-based scheme 53138570Ssam * as is currently done, for example, for authentication modules. 54138570Ssam * 55138570Ssam * An instance of the rate control module is attached to each device 56138570Ssam * at attach time and detached when the device is destroyed. The module 57138570Ssam * may associate data with each device and each node (station). Both 58138570Ssam * sets of storage are opaque except for the size of the per-node storage 59138570Ssam * which must be provided when the module is attached. 60138570Ssam * 61138570Ssam * The rate control module is notified for each state transition and 62138570Ssam * station association/reassociation. Otherwise it is queried for a 63138570Ssam * rate for each outgoing frame and provided status from each transmitted 64138570Ssam * frame. Any ancillary processing is the responsibility of the module 65138570Ssam * (e.g. if periodic processing is required then the module should setup 66138570Ssam * it's own timer). 67138570Ssam * 68138570Ssam * In addition to the transmit rate for each frame the module must also 69138570Ssam * indicate the number of attempts to make at the specified rate. If this 70138570Ssam * number is != ATH_TXMAXTRY then an additional callback is made to setup 71138570Ssam * additional transmit state. The rate control code is assumed to write 72138570Ssam * this additional data directly to the transmit descriptor. 73138570Ssam */ 74138570Ssamstruct ath_softc; 75138570Ssamstruct ath_node; 76138570Ssamstruct ath_desc; 77138570Ssam 78138570Ssamstruct ath_ratectrl { 79138570Ssam size_t arc_space; /* space required for per-node state */ 80138570Ssam}; 81138570Ssam/* 82138570Ssam * Attach/detach a rate control module. 83138570Ssam */ 84138570Ssamstruct ath_ratectrl *ath_rate_attach(struct ath_softc *); 85138570Ssamvoid ath_rate_detach(struct ath_ratectrl *); 86138570Ssam 87138570Ssam 88138570Ssam/* 89138570Ssam * State storage handling. 90138570Ssam */ 91138570Ssam/* 92138570Ssam * Initialize per-node state already allocated for the specified 93138570Ssam * node; this space can be assumed initialized to zero. 94138570Ssam */ 95138570Ssamvoid ath_rate_node_init(struct ath_softc *, struct ath_node *); 96138570Ssam/* 97138570Ssam * Cleanup any per-node state prior to the node being reclaimed. 98138570Ssam */ 99138570Ssamvoid ath_rate_node_cleanup(struct ath_softc *, struct ath_node *); 100138570Ssam/* 101138570Ssam * Update rate control state on station associate/reassociate 102138570Ssam * (when operating as an ap or for nodes discovered when operating 103138570Ssam * in ibss mode). 104138570Ssam */ 105138570Ssamvoid ath_rate_newassoc(struct ath_softc *, struct ath_node *, 106138570Ssam int isNewAssociation); 107138570Ssam/* 108138570Ssam * Update/reset rate control state for 802.11 state transitions. 109138570Ssam * Important mostly as the analog to ath_rate_newassoc when operating 110138570Ssam * in station mode. 111138570Ssam */ 112138570Ssamvoid ath_rate_newstate(struct ath_softc *, enum ieee80211_state); 113138570Ssam 114138570Ssam/* 115138570Ssam * Transmit handling. 116138570Ssam */ 117138570Ssam/* 118138570Ssam * Return the transmit info for a data packet. If multi-rate state 119138570Ssam * is to be setup then try0 should contain a value other than ATH_TXMATRY 120138570Ssam * and ath_rate_setupxtxdesc will be called after deciding if the frame 121138570Ssam * can be transmitted with multi-rate retry. 122138570Ssam */ 123138570Ssamvoid ath_rate_findrate(struct ath_softc *, struct ath_node *, 124144546Ssam int shortPreamble, size_t frameLen, 125138570Ssam u_int8_t *rix, int *try0, u_int8_t *txrate); 126138570Ssam/* 127138570Ssam * Setup any extended (multi-rate) descriptor state for a data packet. 128138570Ssam * The rate index returned by ath_rate_findrate is passed back in. 129138570Ssam */ 130138570Ssamvoid ath_rate_setupxtxdesc(struct ath_softc *, struct ath_node *, 131144546Ssam struct ath_desc *, int shortPreamble, u_int8_t rix); 132138570Ssam/* 133138570Ssam * Update rate control state for a packet associated with the 134138570Ssam * supplied transmit descriptor. The routine is invoked both 135138570Ssam * for packets that were successfully sent and for those that 136138570Ssam * failed (consult the descriptor for details). 137138570Ssam */ 138165185Ssamstruct ath_buf; 139138570Ssamvoid ath_rate_tx_complete(struct ath_softc *, struct ath_node *, 140165185Ssam const struct ath_buf *); 141138570Ssam#endif /* _ATH_RATECTRL_H_ */ 142