xref: /freebsd/sys/net80211/ieee80211_rssadapt.h (revision b6108616acebd2c24b2b866ea1e3ebe8599fcf9c)
1b032f27cSSam Leffler /*	$FreeBSD$	*/
2b032f27cSSam Leffler /* $NetBSD: ieee80211_rssadapt.h,v 1.4 2005/02/26 22:45:09 perry Exp $ */
3b032f27cSSam Leffler /*-
4b032f27cSSam Leffler  * Copyright (c) 2003, 2004 David Young.  All rights reserved.
5b032f27cSSam Leffler  *
6b032f27cSSam Leffler  * Redistribution and use in source and binary forms, with or
7b032f27cSSam Leffler  * without modification, are permitted provided that the following
8b032f27cSSam Leffler  * conditions are met:
9b032f27cSSam Leffler  * 1. Redistributions of source code must retain the above copyright
10b032f27cSSam Leffler  *    notice, this list of conditions and the following disclaimer.
11b032f27cSSam Leffler  * 2. Redistributions in binary form must reproduce the above
12b032f27cSSam Leffler  *    copyright notice, this list of conditions and the following
13b032f27cSSam Leffler  *    disclaimer in the documentation and/or other materials provided
14b032f27cSSam Leffler  *    with the distribution.
15b032f27cSSam Leffler  * 3. The name of David Young may not be used to endorse or promote
16b032f27cSSam Leffler  *    products derived from this software without specific prior
17b032f27cSSam Leffler  *    written permission.
18b032f27cSSam Leffler  *
19b032f27cSSam Leffler  * THIS SOFTWARE IS PROVIDED BY David Young ``AS IS'' AND ANY
20b032f27cSSam Leffler  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21b032f27cSSam Leffler  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22b032f27cSSam Leffler  * PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL David
23b032f27cSSam Leffler  * Young BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24b032f27cSSam Leffler  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
25b032f27cSSam Leffler  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26b032f27cSSam Leffler  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27b032f27cSSam Leffler  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28b032f27cSSam Leffler  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29b032f27cSSam Leffler  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
30b032f27cSSam Leffler  * OF SUCH DAMAGE.
31b032f27cSSam Leffler  */
32b032f27cSSam Leffler #ifndef _NET80211_IEEE80211_RSSADAPT_H_
33b032f27cSSam Leffler #define _NET80211_IEEE80211_RSSADAPT_H_
34b032f27cSSam Leffler 
35b032f27cSSam Leffler /* Data-rate adaptation loosely based on "Link Adaptation Strategy
36b032f27cSSam Leffler  * for IEEE 802.11 WLAN via Received Signal Strength Measurement"
37b032f27cSSam Leffler  * by Javier del Prado Pavon and Sunghyun Choi.
38b032f27cSSam Leffler  */
39b032f27cSSam Leffler 
40b032f27cSSam Leffler /* Buckets for frames 0-128 bytes long, 129-1024, 1025-maximum. */
41b032f27cSSam Leffler #define	IEEE80211_RSSADAPT_BKTS		3
42b032f27cSSam Leffler #define IEEE80211_RSSADAPT_BKT0		128
43b032f27cSSam Leffler #define	IEEE80211_RSSADAPT_BKTPOWER	3	/* 2**_BKTPOWER */
44b032f27cSSam Leffler 
45b032f27cSSam Leffler struct ieee80211_rssadapt {
46b6108616SRui Paulo 	const struct ieee80211vap *vap;
47b032f27cSSam Leffler 	int	interval;			/* update interval (ticks) */
48b032f27cSSam Leffler };
49b032f27cSSam Leffler 
50b032f27cSSam Leffler struct ieee80211_rssadapt_node {
51b032f27cSSam Leffler 	struct ieee80211_rssadapt *ra_rs;	/* backpointer */
52b032f27cSSam Leffler 	struct ieee80211_rateset ra_rates;	/* negotiated rates */
53b032f27cSSam Leffler 	int	ra_rix;				/* current rate index */
54b032f27cSSam Leffler 	int	ra_ticks;			/* time of last update */
55b032f27cSSam Leffler 	int	ra_last_raise;			/* time of last rate raise */
56b032f27cSSam Leffler 	int	ra_raise_interval;		/* rate raise time threshold */
57b032f27cSSam Leffler 
58b032f27cSSam Leffler 	/* Tx failures in this update interval */
59b032f27cSSam Leffler 	uint32_t		ra_nfail;
60b032f27cSSam Leffler 	/* Tx successes in this update interval */
61b032f27cSSam Leffler 	uint32_t		ra_nok;
62b032f27cSSam Leffler 	/* exponential average packets/second */
63b032f27cSSam Leffler 	uint32_t		ra_pktrate;
64b032f27cSSam Leffler 	/* RSSI threshold for each Tx rate */
65b032f27cSSam Leffler 	uint16_t		ra_rate_thresh[IEEE80211_RSSADAPT_BKTS]
66b032f27cSSam Leffler 					      [IEEE80211_RATE_SIZE];
67b032f27cSSam Leffler };
68b032f27cSSam Leffler 
69b032f27cSSam Leffler #define	IEEE80211_RSSADAPT_SUCCESS	1
70b032f27cSSam Leffler #define	IEEE80211_RSSADAPT_FAILURE	0
71b032f27cSSam Leffler #endif /* _NET80211_IEEE80211_RSSADAPT_H_ */
72