Home | History | Annotate | Line # | Download | only in net80211
ieee80211_rssadapt.h revision 1.7.40.1
      1  1.7.40.1   skrll /* $NetBSD: ieee80211_rssadapt.h,v 1.7.40.1 2016/04/22 15:44:17 skrll Exp $ */
      2       1.1  dyoung /*-
      3       1.1  dyoung  * Copyright (c) 2003, 2004 David Young.  All rights reserved.
      4       1.1  dyoung  *
      5       1.1  dyoung  * Redistribution and use in source and binary forms, with or
      6       1.1  dyoung  * without modification, are permitted provided that the following
      7       1.1  dyoung  * conditions are met:
      8       1.1  dyoung  * 1. Redistributions of source code must retain the above copyright
      9       1.1  dyoung  *    notice, this list of conditions and the following disclaimer.
     10       1.1  dyoung  * 2. Redistributions in binary form must reproduce the above
     11       1.1  dyoung  *    copyright notice, this list of conditions and the following
     12       1.1  dyoung  *    disclaimer in the documentation and/or other materials provided
     13       1.1  dyoung  *    with the distribution.
     14       1.1  dyoung  *
     15       1.1  dyoung  * THIS SOFTWARE IS PROVIDED BY David Young ``AS IS'' AND ANY
     16       1.1  dyoung  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     17       1.1  dyoung  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
     18       1.1  dyoung  * PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL David
     19       1.1  dyoung  * Young BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     20       1.1  dyoung  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
     21       1.1  dyoung  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     22       1.1  dyoung  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
     23       1.1  dyoung  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     24       1.1  dyoung  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25       1.1  dyoung  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
     26       1.1  dyoung  * OF SUCH DAMAGE.
     27       1.1  dyoung  */
     28       1.1  dyoung 
     29       1.6    elad #ifndef _NET80211_IEEE80211_RSSADAPT_H_
     30       1.6    elad #define _NET80211_IEEE80211_RSSADAPT_H_
     31       1.6    elad 
     32       1.1  dyoung /* Data-rate adaptation loosely based on "Link Adaptation Strategy
     33       1.1  dyoung  * for IEEE 802.11 WLAN via Received Signal Strength Measurement"
     34       1.1  dyoung  * by Javier del Prado Pavon and Sunghyun Choi.
     35       1.4   perry  */
     36       1.1  dyoung 
     37       1.1  dyoung /* Buckets for frames 0-128 bytes long, 129-1024, 1025-maximum. */
     38       1.1  dyoung #define	IEEE80211_RSSADAPT_BKTS		3
     39       1.1  dyoung #define IEEE80211_RSSADAPT_BKT0		128
     40       1.4   perry #define	IEEE80211_RSSADAPT_BKTPOWER	3	/* 2**_BKTPOWER */
     41       1.1  dyoung 
     42       1.1  dyoung #define	ieee80211_rssadapt_thresh_new \
     43       1.1  dyoung     (ieee80211_rssadapt_thresh_denom - ieee80211_rssadapt_thresh_old)
     44       1.1  dyoung #define	ieee80211_rssadapt_decay_new \
     45       1.1  dyoung     (ieee80211_rssadapt_decay_denom - ieee80211_rssadapt_decay_old)
     46       1.1  dyoung #define	ieee80211_rssadapt_avgrssi_new \
     47       1.1  dyoung     (ieee80211_rssadapt_avgrssi_denom - ieee80211_rssadapt_avgrssi_old)
     48       1.1  dyoung 
     49       1.2  dyoung struct ieee80211_rssadapt_expavgctl {
     50       1.2  dyoung 	/* RSS threshold decay. */
     51       1.2  dyoung 	u_int rc_decay_denom;
     52       1.2  dyoung 	u_int rc_decay_old;
     53       1.2  dyoung 	/* RSS threshold update. */
     54       1.2  dyoung 	u_int rc_thresh_denom;
     55       1.2  dyoung 	u_int rc_thresh_old;
     56       1.2  dyoung 	/* RSS average update. */
     57       1.2  dyoung 	u_int rc_avgrssi_denom;
     58       1.2  dyoung 	u_int rc_avgrssi_old;
     59       1.2  dyoung };
     60       1.2  dyoung 
     61       1.1  dyoung struct ieee80211_rssadapt {
     62       1.1  dyoung 	/* exponential average RSSI << 8 */
     63       1.1  dyoung 	u_int16_t		ra_avg_rssi;
     64       1.1  dyoung 	/* Tx failures in this update interval */
     65       1.1  dyoung 	u_int32_t		ra_nfail;
     66       1.1  dyoung 	/* Tx successes in this update interval */
     67       1.1  dyoung 	u_int32_t		ra_nok;
     68       1.1  dyoung 	/* exponential average packets/second */
     69       1.1  dyoung 	u_int32_t		ra_pktrate;
     70       1.1  dyoung 	/* RSSI threshold for each Tx rate */
     71       1.1  dyoung 	u_int16_t		ra_rate_thresh[IEEE80211_RSSADAPT_BKTS]
     72       1.1  dyoung 					      [IEEE80211_RATE_SIZE];
     73       1.1  dyoung 	struct timeval		ra_last_raise;
     74       1.1  dyoung 	struct timeval		ra_raise_interval;
     75       1.1  dyoung };
     76       1.1  dyoung 
     77       1.4   perry /* Properties of a Tx packet, for link adaptation. */
     78       1.1  dyoung struct ieee80211_rssdesc {
     79       1.1  dyoung 	u_int			 id_len;	/* Tx packet length */
     80       1.1  dyoung 	u_int			 id_rateidx;	/* index into ni->ni_rates */
     81       1.1  dyoung 	struct ieee80211_node	*id_node;	/* destination STA MAC */
     82       1.1  dyoung 	u_int8_t		 id_rssi;	/* destination STA avg RSS @
     83       1.1  dyoung 						 * Tx time
     84       1.1  dyoung 						 */
     85       1.1  dyoung };
     86       1.1  dyoung 
     87       1.1  dyoung void	ieee80211_rssadapt_updatestats(struct ieee80211_rssadapt *);
     88       1.1  dyoung void	ieee80211_rssadapt_input(struct ieee80211com *, struct ieee80211_node *,
     89       1.1  dyoung 	    struct ieee80211_rssadapt *, int);
     90       1.1  dyoung void	ieee80211_rssadapt_lower_rate(struct ieee80211com *,
     91       1.1  dyoung 	    struct ieee80211_node *, struct ieee80211_rssadapt *,
     92       1.1  dyoung 	    struct ieee80211_rssdesc *);
     93       1.1  dyoung void	ieee80211_rssadapt_raise_rate(struct ieee80211com *,
     94       1.1  dyoung 	    struct ieee80211_rssadapt *, struct ieee80211_rssdesc *);
     95       1.2  dyoung int	ieee80211_rssadapt_choose(struct ieee80211_rssadapt *,
     96       1.2  dyoung 	    struct ieee80211_rateset *, struct ieee80211_frame *, u_int, int,
     97       1.2  dyoung 	    const char *, int);
     98       1.3  dyoung #ifdef IEEE80211_DEBUG
     99       1.3  dyoung extern int ieee80211_rssadapt_debug;
    100       1.3  dyoung #endif /* IEEE80211_DEBUG */
    101       1.6    elad 
    102       1.6    elad #endif /* !_NET80211_IEEE80211_RSSADAPT_H_ */
    103       1.6    elad 
    104