New: mac80211 stack from the wireless-dev tree
[librecmc/librecmc.git] / package / mac80211 / src / mac80211 / rc80211_lowest.c
1 /*
2  * Copyright 2002-2005, Instant802 Networks, Inc.
3  * Copyright 2005, Devicescape Software, Inc.
4  * Copyright (c) 2006-2007 Jiri Benc <jbenc@suse.cz>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  */
10
11 #include <linux/module.h>
12 #include <linux/init.h>
13 #include <linux/netdevice.h>
14 #include <linux/types.h>
15 #include <linux/slab.h>
16 #include <linux/skbuff.h>
17 #include <linux/compiler.h>
18
19 #include <net/mac80211.h>
20 #include "ieee80211_i.h"
21 #include "ieee80211_rate.h"
22 #include "debugfs.h"
23
24 static void rate_control_lowest_tx_status(void *priv, struct net_device *dev,
25                                           struct sk_buff *skb,
26                                           struct ieee80211_tx_status *status)
27 {
28 }
29
30 static struct ieee80211_rate *
31 rate_control_lowest_get_rate(void *priv, struct net_device *dev,
32                              struct sk_buff *skb,
33                              struct rate_control_extra *extra)
34 {
35         struct ieee80211_hw_mode *mode = extra->mode;
36         int i;
37
38         for (i = 0; i < mode->num_rates; i++) {
39                 struct ieee80211_rate *rate = &mode->rates[i];
40
41                 if (rate->flags & IEEE80211_RATE_SUPPORTED)
42                         return rate;
43         }
44         return &mode->rates[0];
45 }
46
47 static void rate_control_lowest_rate_init(void *priv, void *priv_sta,
48                                           struct ieee80211_local *local,
49                                           struct sta_info *sta)
50 {
51         sta->txrate = 0;
52 }
53
54 static void *rate_control_lowest_alloc(struct ieee80211_local *local)
55 {
56         return local;
57 }
58
59 static void rate_control_lowest_free(void *priv)
60 {
61 }
62
63 static void rate_control_lowest_clear(void *priv)
64 {
65 }
66
67 static void *rate_control_lowest_alloc_sta(void *priv, gfp_t gfp)
68 {
69         return priv;
70 }
71
72 static void rate_control_lowest_free_sta(void *priv, void *priv_sta)
73 {
74 }
75
76 static struct rate_control_ops rate_control_lowest = {
77         .module = THIS_MODULE,
78         .name = "lowest",
79         .tx_status = rate_control_lowest_tx_status,
80         .get_rate = rate_control_lowest_get_rate,
81         .rate_init = rate_control_lowest_rate_init,
82         .clear = rate_control_lowest_clear,
83         .alloc = rate_control_lowest_alloc,
84         .free = rate_control_lowest_free,
85         .alloc_sta = rate_control_lowest_alloc_sta,
86         .free_sta = rate_control_lowest_free_sta,
87 };
88
89 static int __init rate_control_lowest_init(void)
90 {
91         return ieee80211_rate_control_register(&rate_control_lowest);
92 }
93
94
95 static void __exit rate_control_lowest_exit(void)
96 {
97         ieee80211_rate_control_unregister(&rate_control_lowest);
98 }
99
100
101 module_init(rate_control_lowest_init);
102 module_exit(rate_control_lowest_exit);
103
104 MODULE_DESCRIPTION("Forced 1 mbps rate control module for mac80211");
105 MODULE_LICENSE("GPL");
106