The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/net80211/ieee80211_amrr.c

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: ieee80211_amrr.c,v 1.2 2007/12/11 12:40:10 lukem Exp $ */
    2 /*      $OpenBSD: ieee80211_amrr.c,v 1.1 2006/06/17 19:07:19 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 
   21 #include <sys/cdefs.h>
   22 __KERNEL_RCSID(0, "$NetBSD: ieee80211_amrr.c,v 1.2 2007/12/11 12:40:10 lukem Exp $");
   23 
   24 #include <sys/param.h>
   25 #include <sys/kernel.h>
   26 #include <sys/socket.h>
   27 #include <sys/sysctl.h>
   28 
   29 #include <net/if.h>
   30 #include <net/if_media.h>
   31 
   32 #ifdef INET
   33 #include <netinet/in.h>
   34 #include <netinet/if_ether.h>
   35 #endif
   36 
   37 #include <net80211/ieee80211.h>
   38 #include <net80211/ieee80211_var.h>
   39 #include <net80211/ieee80211_amrr.h>
   40 
   41 #define is_success(amn) \
   42         ((amn)->amn_retrycnt < (amn)->amn_txcnt / 10)
   43 #define is_failure(amn) \
   44         ((amn)->amn_retrycnt > (amn)->amn_txcnt / 3)
   45 #define is_enough(amn)          \
   46         ((amn)->amn_txcnt > 10)
   47 #define is_min_rate(ni)         \
   48         ((ni)->ni_txrate == 0)
   49 #define is_max_rate(ni)         \
   50         ((ni)->ni_txrate == (ni)->ni_rates.rs_nrates - 1)
   51 #define increase_rate(ni)       \
   52         ((ni)->ni_txrate++)
   53 #define decrease_rate(ni)       \
   54         ((ni)->ni_txrate--)
   55 #define reset_cnt(amn)          \
   56         do { (amn)->amn_txcnt = (amn)->amn_retrycnt = 0; } while (0)
   57 
   58 void
   59 ieee80211_amrr_node_init(struct ieee80211_amrr *amrr,
   60     struct ieee80211_amrr_node *amn)
   61 {
   62         amn->amn_success = 0;
   63         amn->amn_recovery = 0;
   64         amn->amn_txcnt = amn->amn_retrycnt = 0;
   65         amn->amn_success_threshold = amrr->amrr_min_success_threshold;
   66 }
   67 
   68 /*
   69  * Update ni->ni_txrate.
   70  */
   71 void
   72 ieee80211_amrr_choose(struct ieee80211_amrr *amrr, struct ieee80211_node *ni,
   73     struct ieee80211_amrr_node *amn)
   74 {
   75         int need_change = 0;
   76 
   77         if (is_success(amn) && is_enough(amn)) {
   78                 amn->amn_success++;
   79                 if (amn->amn_success >= amn->amn_success_threshold &&
   80                     !is_max_rate(ni)) {
   81                         amn->amn_recovery = 1;
   82                         amn->amn_success = 0;
   83                         increase_rate(ni);
   84                         IEEE80211_DPRINTF(ni->ni_ic, IEEE80211_MSG_DEBUG,
   85                             "AMRR increasing rate %d (txcnt=%d retrycnt=%d)\n",
   86                             ni->ni_rates.rs_rates[ni->ni_txrate] &
   87                                 IEEE80211_RATE_VAL,
   88                             amn->amn_txcnt, amn->amn_retrycnt);
   89                         need_change = 1;
   90                 } else {
   91                         amn->amn_recovery = 0;
   92                 }
   93         } else if (is_failure(amn)) {
   94                 amn->amn_success = 0;
   95                 if (!is_min_rate(ni)) {
   96                         if (amn->amn_recovery) {
   97                                 amn->amn_success_threshold *= 2;
   98                                 if (amn->amn_success_threshold >
   99                                     amrr->amrr_max_success_threshold)
  100                                         amn->amn_success_threshold =
  101                                             amrr->amrr_max_success_threshold;
  102                         } else {
  103                                 amn->amn_success_threshold =
  104                                     amrr->amrr_min_success_threshold;
  105                         }
  106                         decrease_rate(ni);
  107                         IEEE80211_DPRINTF(ni->ni_ic, IEEE80211_MSG_DEBUG,
  108                             "AMRR decreasing rate %d (txcnt=%d retrycnt=%d)\n",
  109                             ni->ni_rates.rs_rates[ni->ni_txrate] &
  110                                 IEEE80211_RATE_VAL,
  111                             amn->amn_txcnt, amn->amn_retrycnt);
  112                         need_change = 1;
  113                 }
  114                 amn->amn_recovery = 0;
  115         }
  116 
  117         if (is_enough(amn) || need_change)
  118                 reset_cnt(amn);
  119 }

Cache object: c55b1d7d6eadb3abe0ae9aabc8399d57


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.