1178354Ssam/*	$FreeBSD$	*/
2178354Ssam/* $NetBSD: ieee80211_rssadapt.h,v 1.4 2005/02/26 22:45:09 perry Exp $ */
3178354Ssam/*-
4178354Ssam * Copyright (c) 2003, 2004 David Young.  All rights reserved.
5178354Ssam *
6178354Ssam * Redistribution and use in source and binary forms, with or
7178354Ssam * without modification, are permitted provided that the following
8178354Ssam * conditions are met:
9178354Ssam * 1. Redistributions of source code must retain the above copyright
10178354Ssam *    notice, this list of conditions and the following disclaimer.
11178354Ssam * 2. Redistributions in binary form must reproduce the above
12178354Ssam *    copyright notice, this list of conditions and the following
13178354Ssam *    disclaimer in the documentation and/or other materials provided
14178354Ssam *    with the distribution.
15178354Ssam * 3. The name of David Young may not be used to endorse or promote
16178354Ssam *    products derived from this software without specific prior
17178354Ssam *    written permission.
18178354Ssam *
19178354Ssam * THIS SOFTWARE IS PROVIDED BY David Young ``AS IS'' AND ANY
20178354Ssam * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21178354Ssam * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22178354Ssam * PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL David
23178354Ssam * Young BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24178354Ssam * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
25178354Ssam * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26178354Ssam * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27178354Ssam * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28178354Ssam * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29178354Ssam * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
30178354Ssam * OF SUCH DAMAGE.
31178354Ssam */
32178354Ssam#ifndef _NET80211_IEEE80211_RSSADAPT_H_
33178354Ssam#define _NET80211_IEEE80211_RSSADAPT_H_
34178354Ssam
35178354Ssam/* Data-rate adaptation loosely based on "Link Adaptation Strategy
36178354Ssam * for IEEE 802.11 WLAN via Received Signal Strength Measurement"
37178354Ssam * by Javier del Prado Pavon and Sunghyun Choi.
38178354Ssam */
39178354Ssam
40178354Ssam/* Buckets for frames 0-128 bytes long, 129-1024, 1025-maximum. */
41178354Ssam#define	IEEE80211_RSSADAPT_BKTS		3
42178354Ssam#define IEEE80211_RSSADAPT_BKT0		128
43178354Ssam#define	IEEE80211_RSSADAPT_BKTPOWER	3	/* 2**_BKTPOWER */
44178354Ssam
45178354Ssamstruct ieee80211_rssadapt {
46206358Srpaulo	const struct ieee80211vap *vap;
47178354Ssam	int	interval;			/* update interval (ticks) */
48178354Ssam};
49178354Ssam
50178354Ssamstruct ieee80211_rssadapt_node {
51178354Ssam	struct ieee80211_rssadapt *ra_rs;	/* backpointer */
52178354Ssam	struct ieee80211_rateset ra_rates;	/* negotiated rates */
53178354Ssam	int	ra_rix;				/* current rate index */
54178354Ssam	int	ra_ticks;			/* time of last update */
55178354Ssam	int	ra_last_raise;			/* time of last rate raise */
56178354Ssam	int	ra_raise_interval;		/* rate raise time threshold */
57178354Ssam
58178354Ssam	/* Tx failures in this update interval */
59178354Ssam	uint32_t		ra_nfail;
60178354Ssam	/* Tx successes in this update interval */
61178354Ssam	uint32_t		ra_nok;
62178354Ssam	/* exponential average packets/second */
63178354Ssam	uint32_t		ra_pktrate;
64178354Ssam	/* RSSI threshold for each Tx rate */
65178354Ssam	uint16_t		ra_rate_thresh[IEEE80211_RSSADAPT_BKTS]
66178354Ssam					      [IEEE80211_RATE_SIZE];
67178354Ssam};
68178354Ssam
69178354Ssam#define	IEEE80211_RSSADAPT_SUCCESS	1
70178354Ssam#define	IEEE80211_RSSADAPT_FAILURE	0
71178354Ssam#endif /* _NET80211_IEEE80211_RSSADAPT_H_ */
72