if_athrate.h revision 170375
1138570Ssam/*- 2170375Ssam * Copyright (c) 2004-2007 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, 11170375Ssam * 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 * 17138570Ssam * NO WARRANTY 18138570Ssam * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19138570Ssam * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20138570Ssam * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY 21138570Ssam * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 22138570Ssam * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, 23138570Ssam * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24138570Ssam * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25138570Ssam * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 26138570Ssam * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27138570Ssam * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 28138570Ssam * THE POSSIBILITY OF SUCH DAMAGES. 29138570Ssam * 30138570Ssam * $FreeBSD: head/sys/dev/ath/if_athrate.h 170375 2007-06-06 15:49:16Z sam $ 31138570Ssam */ 32138570Ssam#ifndef _ATH_RATECTRL_H_ 33138570Ssam#define _ATH_RATECTRL_H_ 34138570Ssam 35138570Ssam/* 36138570Ssam * Interface definitions for transmit rate control modules for the 37138570Ssam * Atheros driver. 38138570Ssam * 39138570Ssam * A rate control module is responsible for choosing the transmit rate 40138570Ssam * for each data frame. Management+control frames are always sent at 41138570Ssam * a fixed rate. 42138570Ssam * 43138570Ssam * Only one module may be present at a time; the driver references 44138570Ssam * rate control interfaces by symbol name. If multiple modules are 45138570Ssam * to be supported we'll need to switch to a registration-based scheme 46138570Ssam * as is currently done, for example, for authentication modules. 47138570Ssam * 48138570Ssam * An instance of the rate control module is attached to each device 49138570Ssam * at attach time and detached when the device is destroyed. The module 50138570Ssam * may associate data with each device and each node (station). Both 51138570Ssam * sets of storage are opaque except for the size of the per-node storage 52138570Ssam * which must be provided when the module is attached. 53138570Ssam * 54138570Ssam * The rate control module is notified for each state transition and 55138570Ssam * station association/reassociation. Otherwise it is queried for a 56138570Ssam * rate for each outgoing frame and provided status from each transmitted 57138570Ssam * frame. Any ancillary processing is the responsibility of the module 58138570Ssam * (e.g. if periodic processing is required then the module should setup 59138570Ssam * it's own timer). 60138570Ssam * 61138570Ssam * In addition to the transmit rate for each frame the module must also 62138570Ssam * indicate the number of attempts to make at the specified rate. If this 63138570Ssam * number is != ATH_TXMAXTRY then an additional callback is made to setup 64138570Ssam * additional transmit state. The rate control code is assumed to write 65138570Ssam * this additional data directly to the transmit descriptor. 66138570Ssam */ 67138570Ssamstruct ath_softc; 68138570Ssamstruct ath_node; 69138570Ssamstruct ath_desc; 70138570Ssam 71138570Ssamstruct ath_ratectrl { 72138570Ssam size_t arc_space; /* space required for per-node state */ 73138570Ssam}; 74138570Ssam/* 75138570Ssam * Attach/detach a rate control module. 76138570Ssam */ 77138570Ssamstruct ath_ratectrl *ath_rate_attach(struct ath_softc *); 78138570Ssamvoid ath_rate_detach(struct ath_ratectrl *); 79138570Ssam 80138570Ssam 81138570Ssam/* 82138570Ssam * State storage handling. 83138570Ssam */ 84138570Ssam/* 85138570Ssam * Initialize per-node state already allocated for the specified 86138570Ssam * node; this space can be assumed initialized to zero. 87138570Ssam */ 88138570Ssamvoid ath_rate_node_init(struct ath_softc *, struct ath_node *); 89138570Ssam/* 90138570Ssam * Cleanup any per-node state prior to the node being reclaimed. 91138570Ssam */ 92138570Ssamvoid ath_rate_node_cleanup(struct ath_softc *, struct ath_node *); 93138570Ssam/* 94138570Ssam * Update rate control state on station associate/reassociate 95138570Ssam * (when operating as an ap or for nodes discovered when operating 96138570Ssam * in ibss mode). 97138570Ssam */ 98138570Ssamvoid ath_rate_newassoc(struct ath_softc *, struct ath_node *, 99138570Ssam int isNewAssociation); 100138570Ssam/* 101138570Ssam * Update/reset rate control state for 802.11 state transitions. 102138570Ssam * Important mostly as the analog to ath_rate_newassoc when operating 103138570Ssam * in station mode. 104138570Ssam */ 105138570Ssamvoid ath_rate_newstate(struct ath_softc *, enum ieee80211_state); 106138570Ssam 107138570Ssam/* 108138570Ssam * Transmit handling. 109138570Ssam */ 110138570Ssam/* 111138570Ssam * Return the transmit info for a data packet. If multi-rate state 112138570Ssam * is to be setup then try0 should contain a value other than ATH_TXMATRY 113138570Ssam * and ath_rate_setupxtxdesc will be called after deciding if the frame 114138570Ssam * can be transmitted with multi-rate retry. 115138570Ssam */ 116138570Ssamvoid ath_rate_findrate(struct ath_softc *, struct ath_node *, 117144546Ssam int shortPreamble, size_t frameLen, 118138570Ssam u_int8_t *rix, int *try0, u_int8_t *txrate); 119138570Ssam/* 120138570Ssam * Setup any extended (multi-rate) descriptor state for a data packet. 121138570Ssam * The rate index returned by ath_rate_findrate is passed back in. 122138570Ssam */ 123138570Ssamvoid ath_rate_setupxtxdesc(struct ath_softc *, struct ath_node *, 124144546Ssam struct ath_desc *, int shortPreamble, u_int8_t rix); 125138570Ssam/* 126138570Ssam * Update rate control state for a packet associated with the 127138570Ssam * supplied transmit descriptor. The routine is invoked both 128138570Ssam * for packets that were successfully sent and for those that 129138570Ssam * failed (consult the descriptor for details). 130138570Ssam */ 131165185Ssamstruct ath_buf; 132138570Ssamvoid ath_rate_tx_complete(struct ath_softc *, struct ath_node *, 133165185Ssam const struct ath_buf *); 134138570Ssam#endif /* _ATH_RATECTRL_H_ */ 135