Implement a generic TX rate control algorithm framework in 802.11 layer.
[dragonfly.git] / sys / netproto / 802_11 / wlan / ieee80211_ratectl_none.c
1 /*
2  * Copyright (c) 2006 The DragonFly Project.  All rights reserved.
3  * 
4  * This code is derived from software contributed to The DragonFly Project
5  * by Sepherosa Ziehau <sepherosa@gmail.com>
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  * 
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in
15  *    the documentation and/or other materials provided with the
16  *    distribution.
17  * 3. Neither the name of The DragonFly Project nor the names of its
18  *    contributors may be used to endorse or promote products derived
19  *    from this software without specific, prior written permission.
20  * 
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
25  * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  * 
34  * $DragonFly: src/sys/netproto/802_11/wlan/ieee80211_ratectl_none.c,v 1.1 2006/09/01 15:12:11 sephe Exp $
35  */
36
37 #include <sys/param.h>
38 #include <sys/kernel.h>
39  
40 #include <net/if.h>
41 #include <net/if_media.h>
42 #include <net/if_arp.h>
43
44 #include <netproto/802_11/ieee80211_var.h>
45
46 static void     *none_ratectl_attach(struct ieee80211com *);
47 static void     none_ratectl_detach(void *);
48 static void     none_ratectl_data_alloc(struct ieee80211_node *);
49 static void     none_ratectl_data_free(struct ieee80211_node *);
50 static void     none_ratectl_data_dup(const struct ieee80211_node *,
51                                       struct ieee80211_node *);
52 static void     none_ratectl_newstate(void *, enum ieee80211_state);
53 static void     none_ratectl_tx_complete(void *, struct ieee80211_node *,
54                         int, const struct ieee80211_ratectl_res[],
55                         int, int, int, int);
56 static void     none_ratectl_newassoc(void *, struct ieee80211_node *, int);
57 static int      none_ratectl_findrate(void *, struct ieee80211_node *, int,
58                                       int[], int);
59
60 const struct ieee80211_ratectl ieee80211_ratectl_none = {
61         .rc_name        = "none",
62         .rc_ratectl     = IEEE80211_RATECTL_NONE,
63         .rc_attach      = none_ratectl_attach,
64         .rc_detach      = none_ratectl_detach,
65         .rc_data_alloc  = none_ratectl_data_alloc,
66         .rc_data_free   = none_ratectl_data_free,
67         .rc_data_dup    = none_ratectl_data_dup,
68         .rc_newstate    = none_ratectl_newstate,
69         .rc_tx_complete = none_ratectl_tx_complete,
70         .rc_newassoc    = none_ratectl_newassoc,
71         .rc_findrate    = none_ratectl_findrate
72 };
73
74 static void *
75 none_ratectl_attach(struct ieee80211com *ic __unused)
76 {
77         return NULL;
78 }
79
80 static void
81 none_ratectl_detach(void *arg __unused)
82 {
83 }
84
85 static void
86 none_ratectl_data_alloc(struct ieee80211_node *ni __unused)
87 {
88 }
89
90 static void
91 none_ratectl_data_free(struct ieee80211_node *ni __unused)
92 {
93 }
94
95 static void
96 none_ratectl_data_dup(const struct ieee80211_node *oni __unused,
97                       struct ieee80211_node *nni __unused)
98 {
99 }
100
101 static void
102 none_ratectl_newstate(void *arg __unused, enum ieee80211_state state __unused)
103 {
104 }
105
106 static void
107 none_ratectl_tx_complete(void *arg __unused, struct ieee80211_node *ni __unused,
108                          int frame_len __unused,
109                          const struct ieee80211_ratectl_res res[] __unused,
110                          int res_len __unused,
111                          int short_retries __unused, int long_retries __unused,
112                          int is_fail __unused)
113 {
114 }
115
116 static void
117 none_ratectl_newassoc(void *arg __unused, struct ieee80211_node *ni __unused,
118                       int is_new __unused)
119 {
120 }
121
122 static int
123 none_ratectl_findrate(void * arg __unused, struct ieee80211_node *ni,
124                       int frame_len __unused, int rateidx[], int rateidx_len)
125 {
126         int i;
127
128         for (i = 0; i < rateidx_len; ++i)
129                 rateidx[i] = ni->ni_txrate;
130         return rateidx_len;
131 }