xref: /freebsd/sys/net80211/ieee80211_ratectl_none.c (revision a90b9d0159070121c221b966469c3e36d912bf82)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2010 Bernhard Schmidt <bschmidt@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 #include "opt_wlan.h"
30 
31 #include <sys/param.h>
32 #include <sys/systm.h>
33 #include <sys/kernel.h>
34 #include <sys/malloc.h>
35 #include <sys/module.h>
36 #include <sys/socket.h>
37 #include <sys/sysctl.h>
38 
39 #include <net/if.h>
40 #include <net/if_media.h>
41 #include <net/ethernet.h>
42 
43 #ifdef INET
44 #include <netinet/in.h>
45 #include <netinet/if_ether.h>
46 #endif
47 
48 #include <net80211/ieee80211_var.h>
49 #include <net80211/ieee80211_ratectl.h>
50 
51 static void
52 none_init(struct ieee80211vap *vap)
53 {
54 }
55 
56 static void
57 none_deinit(struct ieee80211vap *vap)
58 {
59 	IEEE80211_FREE(vap->iv_rs, M_80211_RATECTL);
60 }
61 
62 static void
63 none_node_init(struct ieee80211_node *ni)
64 {
65 	ni->ni_txrate = ni->ni_rates.rs_rates[0] & IEEE80211_RATE_VAL;
66 }
67 
68 static void
69 none_node_deinit(struct ieee80211_node *ni)
70 {
71 }
72 
73 static int
74 none_rate(struct ieee80211_node *ni, void *arg __unused, uint32_t iarg __unused)
75 {
76 	int rix = 0;
77 
78 	ni->ni_txrate = ni->ni_rates.rs_rates[rix] & IEEE80211_RATE_VAL;
79 	return rix;
80 }
81 
82 static void
83 none_tx_complete(const struct ieee80211_node *ni,
84     const struct ieee80211_ratectl_tx_status *status)
85 {
86 }
87 
88 static void
89 none_tx_update(struct ieee80211vap *vap,
90     struct ieee80211_ratectl_tx_stats *stats)
91 {
92 }
93 
94 static void
95 none_setinterval(const struct ieee80211vap *vap, int msecs)
96 {
97 }
98 
99 /* number of references from net80211 layer */
100 static	int nrefs = 0;
101 
102 static const struct ieee80211_ratectl none = {
103 	.ir_name	= "none",
104 	.ir_attach	= NULL,
105 	.ir_detach	= NULL,
106 	.ir_init	= none_init,
107 	.ir_deinit	= none_deinit,
108 	.ir_node_init	= none_node_init,
109 	.ir_node_deinit	= none_node_deinit,
110 	.ir_rate	= none_rate,
111 	.ir_tx_complete	= none_tx_complete,
112 	.ir_tx_update	= none_tx_update,
113 	.ir_setinterval	= none_setinterval,
114 };
115 IEEE80211_RATECTL_MODULE(ratectl_none, 1);
116 IEEE80211_RATECTL_ALG(none, IEEE80211_RATECTL_NONE, none);
117