1 /* $FreeBSD$ */ 2 /* $OpenBSD: ieee80211_amrr.h,v 1.3 2006/06/17 19:34:31 damien Exp $ */ 3 4 /*- 5 * Copyright (c) 2006 6 * Damien Bergamini <damien.bergamini@free.fr> 7 * 8 * Permission to use, copy, modify, and distribute this software for any 9 * purpose with or without fee is hereby granted, provided that the above 10 * copyright notice and this permission notice appear in all copies. 11 * 12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 */ 20 #ifndef _NET80211_IEEE80211_AMRR_H_ 21 #define _NET80211_IEEE80211_AMRR_H_ 22 23 /*- 24 * Naive implementation of the Adaptive Multi Rate Retry algorithm: 25 * 26 * "IEEE 802.11 Rate Adaptation: A Practical Approach" 27 * Mathieu Lacage, Hossein Manshaei, Thierry Turletti 28 * INRIA Sophia - Projet Planete 29 * http://www-sop.inria.fr/rapports/sophia/RR-5208.html 30 */ 31 32 /* 33 * Rate control settings. 34 */ 35 struct ieee80211vap; 36 37 struct ieee80211_amrr { 38 u_int amrr_min_success_threshold; 39 u_int amrr_max_success_threshold; 40 int amrr_interval; /* update interval (ticks) */ 41 }; 42 43 #define IEEE80211_AMRR_MIN_SUCCESS_THRESHOLD 1 44 #define IEEE80211_AMRR_MAX_SUCCESS_THRESHOLD 15 45 46 /* 47 * Rate control state for a given node. 48 */ 49 struct ieee80211_amrr_node { 50 struct ieee80211_amrr *amn_amrr;/* backpointer */ 51 int amn_rix; /* current rate index */ 52 int amn_ticks; /* time of last update */ 53 /* statistics */ 54 u_int amn_txcnt; 55 u_int amn_success; 56 u_int amn_success_threshold; 57 u_int amn_recovery; 58 u_int amn_retrycnt; 59 }; 60 61 void ieee80211_amrr_init(struct ieee80211_amrr *, struct ieee80211vap *, 62 int, int, int); 63 void ieee80211_amrr_cleanup(struct ieee80211_amrr *); 64 void ieee80211_amrr_setinterval(struct ieee80211_amrr *, int); 65 void ieee80211_amrr_node_init(struct ieee80211_amrr *, 66 struct ieee80211_amrr_node *, struct ieee80211_node *); 67 int ieee80211_amrr_choose(struct ieee80211_node *, 68 struct ieee80211_amrr_node *); 69 70 #define IEEE80211_AMRR_SUCCESS 1 71 #define IEEE80211_AMRR_FAILURE 0 72 73 /* 74 * Update statistics with tx complete status. Ok is non-zero 75 * if the packet is known to be ACK'd. Retries has the number 76 * retransmissions (i.e. xmit attempts - 1). 77 */ 78 static __inline void 79 ieee80211_amrr_tx_complete(struct ieee80211_amrr_node *amn, 80 int ok, int retries) 81 { 82 amn->amn_txcnt++; 83 if (ok) 84 amn->amn_success++; 85 amn->amn_retrycnt += retries; 86 } 87 88 /* 89 * Set tx count/retry statistics explicitly. Intended for 90 * drivers that poll the device for statistics maintained 91 * in the device. 92 */ 93 static __inline void 94 ieee80211_amrr_tx_update(struct ieee80211_amrr_node *amn, 95 int txcnt, int success, int retrycnt) 96 { 97 amn->amn_txcnt = txcnt; 98 amn->amn_success = success; 99 amn->amn_retrycnt = retrycnt; 100 } 101 #endif /* _NET80211_IEEE80211_AMRR_H_ */ 102