1 2/*- 3 * Copyright (c) 2009-2010 Alexander Egorenkov <egorenar@gmail.com> 4 * Copyright (c) 2009 Damien Bergamini <damien.bergamini@free.fr> 5 * 6 * Permission to use, copy, modify, and distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19#ifndef _RT2860_AMRR_H_ 20#define _RT2860_AMRR_H_ 21 22#define RT2860_AMRR_MIN_SUCCESS_THRESHOLD 1 23#define RT2860_AMRR_MAX_SUCCESS_THRESHOLD 15 24 25struct rt2860_amrr 26{ 27 int ntxpath; 28 29 unsigned int min_success_threshold; 30 unsigned int max_success_threshold; 31 32 int interval; 33}; 34 35struct rt2860_amrr_node 36{ 37 struct rt2860_amrr *amrr; 38 39 int rate_index; 40 41 int ticks; 42 43 unsigned int txcnt; 44 unsigned int success; 45 unsigned int success_threshold; 46 unsigned int recovery; 47 unsigned int retrycnt; 48}; 49 50void rt2860_amrr_init(struct rt2860_amrr *amrr, struct ieee80211vap *vap, 51 int ntxpath, int min_success_threshold, int max_success_threshold, int msecs); 52 53void rt2860_amrr_cleanup(struct rt2860_amrr *amrr); 54 55void rt2860_amrr_node_init(struct rt2860_amrr *amrr, 56 struct rt2860_amrr_node *amrr_node, struct ieee80211_node *ni); 57 58int rt2860_amrr_choose(struct ieee80211_node *ni, 59 struct rt2860_amrr_node *amrr_node); 60 61static __inline void rt2860_amrr_tx_complete(struct rt2860_amrr_node *amrr_node, 62 int ok, int retries) 63{ 64 amrr_node->txcnt++; 65 66 if (ok) 67 amrr_node->success++; 68 69 amrr_node->retrycnt += retries; 70} 71 72static __inline void rt2860_amrr_tx_update(struct rt2860_amrr_node *amrr_node, 73 int txcnt, int success, int retrycnt) 74{ 75 amrr_node->txcnt = txcnt; 76 amrr_node->success = success; 77 amrr_node->retrycnt = retrycnt; 78} 79 80#endif /* #ifndef _RT2860_AMRR_H_ */ 81