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_ratectl.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 /*-
    2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
    3  *
    4  * Copyright (c) 2010 Rui Paulo <rpaulo@FreeBSD.org>
    5  * All rights reserved.
    6  *
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions and the following disclaimer.
   12  * 2. Redistributions in binary form must reproduce the above copyright
   13  *    notice, this list of conditions and the following disclaimer in the
   14  *    documentation and/or other materials provided with the distribution.
   15  *
   16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   19  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   21  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   26  */
   27 
   28 #include <sys/cdefs.h>
   29 __FBSDID("$FreeBSD: releng/12.0/sys/net80211/ieee80211_ratectl.c 326272 2017-11-27 15:23:17Z pfg $");
   30 
   31 #include <sys/param.h>
   32 #include <sys/kernel.h>
   33 #include <sys/sbuf.h>
   34 #include <sys/systm.h>
   35 #include <sys/socket.h>
   36 #include <sys/malloc.h>
   37 
   38 #include <net/if.h>
   39 #include <net/if_media.h>
   40 #include <net/ethernet.h>
   41 #include <net/route.h>
   42 
   43 #include <net80211/ieee80211_var.h>
   44 #include <net80211/ieee80211_ratectl.h>
   45 
   46 static const struct ieee80211_ratectl *ratectls[IEEE80211_RATECTL_MAX];
   47 
   48 static const char *ratectl_modnames[IEEE80211_RATECTL_MAX] = {
   49         [IEEE80211_RATECTL_AMRR]        = "wlan_amrr",
   50         [IEEE80211_RATECTL_RSSADAPT]    = "wlan_rssadapt",
   51         [IEEE80211_RATECTL_ONOE]        = "wlan_onoe",
   52         [IEEE80211_RATECTL_SAMPLE]      = "wlan_sample",
   53         [IEEE80211_RATECTL_NONE]        = "wlan_none",
   54 };
   55 
   56 MALLOC_DEFINE(M_80211_RATECTL, "80211ratectl", "802.11 rate control");
   57 
   58 void
   59 ieee80211_ratectl_register(int type, const struct ieee80211_ratectl *ratectl)
   60 {
   61         if (type >= IEEE80211_RATECTL_MAX)
   62                 return;
   63         ratectls[type] = ratectl;
   64 }
   65 
   66 void
   67 ieee80211_ratectl_unregister(int type)
   68 {
   69         if (type >= IEEE80211_RATECTL_MAX)
   70                 return;
   71         ratectls[type] = NULL;
   72 }
   73 
   74 static void
   75 ieee80211_ratectl_sysctl_stats_node_iter(void *arg, struct ieee80211_node *ni)
   76 {
   77 
   78         struct sbuf *sb = (struct sbuf *) arg;
   79         sbuf_printf(sb, "MAC: %6D\n", ni->ni_macaddr, ":");
   80         ieee80211_ratectl_node_stats(ni, sb);
   81         sbuf_printf(sb, "\n");
   82 }
   83 
   84 static int
   85 ieee80211_ratectl_sysctl_stats(SYSCTL_HANDLER_ARGS)
   86 {
   87         struct ieee80211vap *vap = arg1;
   88         struct ieee80211com *ic = vap->iv_ic;
   89         struct sbuf sb;
   90         int error;
   91 
   92         error = sysctl_wire_old_buffer(req, 0);
   93         if (error)
   94                 return (error);
   95         sbuf_new_for_sysctl(&sb, NULL, 8, req);
   96         sbuf_clear_flags(&sb, SBUF_INCLUDENUL);
   97 
   98         IEEE80211_LOCK(ic);
   99         ieee80211_iterate_nodes(&ic->ic_sta,
  100             ieee80211_ratectl_sysctl_stats_node_iter,
  101             &sb);
  102         IEEE80211_UNLOCK(ic);
  103 
  104         error = sbuf_finish(&sb);
  105         sbuf_delete(&sb);
  106         return (error);
  107 }
  108 
  109 void
  110 ieee80211_ratectl_init(struct ieee80211vap *vap)
  111 {
  112         if (vap->iv_rate == ratectls[IEEE80211_RATECTL_NONE])
  113                 ieee80211_ratectl_set(vap, IEEE80211_RATECTL_AMRR);
  114         vap->iv_rate->ir_init(vap);
  115 
  116         /* Attach generic stats sysctl */
  117         SYSCTL_ADD_PROC(vap->iv_sysctl, SYSCTL_CHILDREN(vap->iv_oid), OID_AUTO,
  118             "rate_stats", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, vap,
  119             0, ieee80211_ratectl_sysctl_stats, "A", "ratectl node stats");
  120 }
  121 
  122 void
  123 ieee80211_ratectl_set(struct ieee80211vap *vap, int type)
  124 {
  125         if (type >= IEEE80211_RATECTL_MAX)
  126                 return;
  127         if (ratectls[type] == NULL) {
  128                 ieee80211_load_module(ratectl_modnames[type]);
  129                 if (ratectls[type] == NULL) {
  130                         IEEE80211_DPRINTF(vap, IEEE80211_MSG_RATECTL,
  131                             "%s: unable to load algo %u, module %s\n",
  132                             __func__, type, ratectl_modnames[type]);
  133                         vap->iv_rate = ratectls[IEEE80211_RATECTL_NONE];
  134                         return;
  135                 }
  136         }
  137         vap->iv_rate = ratectls[type];
  138 }

Cache object: 147f055828b8a4c014e05db8efac9b77


[ 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.