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