Commit 4b475898 authored by Johannes Berg's avatar Johannes Berg Committed by David S. Miller

mac80211: better rate control algorithm selection

This patch changes mac80211's Kconfig/Makefile to:
 * select between the PID and the SIMPLE rate control
   algorithm as default
 * always allow tri-state for the rate control algorithms,
   building those that are selected 'y' into the mac80211
   module (if that is a module, otherwise all into the kernel)
 * force the default rate control algorithm to be built into
   mac80211

It also makes both rate control algorithms proper modules again
with MODULE_LICENSE etc.

Only if EMBEDDED is the user allowed to select "NONE" as default
which will cause no algorithm to be selected, this will work
only when the driver brings one itself (e.g. iwlwifi drivers).
Signed-off-by: default avatarJohannes Berg <johannes@sipsolutions.net>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 688b88a4
...@@ -13,25 +13,17 @@ config MAC80211 ...@@ -13,25 +13,17 @@ config MAC80211
This option enables the hardware independent IEEE 802.11 This option enables the hardware independent IEEE 802.11
networking stack. networking stack.
config MAC80211_RC_DEFAULT_CHOICE menu "Rate control algorithm selection"
bool "Choose default rate control algorithm" if EMBEDDED depends on MAC80211 != n
default y
depends on MAC80211
---help---
This options enables selection of a default rate control
algorithm to be built into the mac80211 module. Alternate
rate control algorithms might be built into the mac80211
module as well.
choice choice
prompt "Default rate control algorithm" prompt "Default rate control algorithm"
default MAC80211_RC_DEFAULT_PID default MAC80211_RC_DEFAULT_PID
depends on MAC80211 && MAC80211_RC_DEFAULT_CHOICE
---help--- ---help---
This option selects the default rate control algorithm This option selects the default rate control algorithm
mac80211 will use. Note that this default can still be mac80211 will use. Note that this default can still be
overriden through the ieee80211_default_rc_algo module overriden through the ieee80211_default_rc_algo module
parameter. parameter if different algorithms are available.
config MAC80211_RC_DEFAULT_PID config MAC80211_RC_DEFAULT_PID
bool "PID controller based rate control algorithm" bool "PID controller based rate control algorithm"
...@@ -50,19 +42,27 @@ config MAC80211_RC_DEFAULT_SIMPLE ...@@ -50,19 +42,27 @@ config MAC80211_RC_DEFAULT_SIMPLE
dumb algorithm. You should choose the PID rate control dumb algorithm. You should choose the PID rate control
instead. instead.
config MAC80211_RC_DEFAULT_NONE
bool "No default algorithm"
depends on EMBEDDED
help
Selecting this option will select no default algorithm
and allow you to not build any. Do not choose this
option unless you know your driver comes with another
suitable algorithm.
endchoice endchoice
comment "Selecting 'y' for an algorithm will"
comment "build the algorithm into mac80211."
config MAC80211_RC_DEFAULT config MAC80211_RC_DEFAULT
string string
depends on MAC80211
default "pid" if MAC80211_RC_DEFAULT_PID default "pid" if MAC80211_RC_DEFAULT_PID
default "simple" if MAC80211_RC_DEFAULT_SIMPLE default "simple" if MAC80211_RC_DEFAULT_SIMPLE
default "" default ""
config MAC80211_RC_PID config MAC80211_RC_PID
bool "PID controller based rate control algorithm" tristate "PID controller based rate control algorithm"
default y
depends on MAC80211
---help--- ---help---
This option enables a TX rate control algorithm for This option enables a TX rate control algorithm for
mac80211 that uses a PID controller to select the TX mac80211 that uses a PID controller to select the TX
...@@ -72,16 +72,15 @@ config MAC80211_RC_PID ...@@ -72,16 +72,15 @@ config MAC80211_RC_PID
different rate control algorithm. different rate control algorithm.
config MAC80211_RC_SIMPLE config MAC80211_RC_SIMPLE
bool "Simple rate control algorithm (DEPRECATED)" tristate "Simple rate control algorithm (DEPRECATED)"
default n
depends on MAC80211
---help--- ---help---
This option enables a very simple, non-responsive TX This option enables a very simple, non-responsive TX
rate control algorithm. This algorithm is deprecated rate control algorithm. This algorithm is deprecated
and will be removed from the kernel in near future. and will be removed from the kernel in the near future.
It has been replaced by the PID algorithm. It has been replaced by the PID algorithm.
Say N unless you know what you are doing. Say N unless you know what you are doing.
endmenu
config MAC80211_LEDS config MAC80211_LEDS
bool "Enable LED triggers" bool "Enable LED triggers"
......
obj-$(CONFIG_MAC80211) += mac80211.o obj-$(CONFIG_MAC80211) += mac80211.o
mac80211-objs-$(CONFIG_MAC80211_LEDS) += ieee80211_led.o # objects for PID algorithm
mac80211-objs-$(CONFIG_NET_SCHED) += wme.o rc80211_pid-y := rc80211_pid_algo.o
mac80211-objs-$(CONFIG_MAC80211_RC_SIMPLE) += rc80211_simple.o rc80211_pid-$(CONFIG_MAC80211_DEBUGFS) += rc80211_pid_debugfs.o
mac80211-objs-$(CONFIG_MAC80211_RC_PID) += rc80211_pid_algo.o
mac80211-debugfs-objs-$(CONFIG_MAC80211_RC_PID) += rc80211_pid_debugfs.o # build helper for PID algorithm
mac80211-objs-$(CONFIG_MAC80211_DEBUGFS) += \ rc-pid-y := $(rc80211_pid-y)
debugfs.o \ rc-pid-m := rc80211_pid.o
debugfs_sta.o \
debugfs_netdev.o \
debugfs_key.o \
$(mac80211-debugfs-objs-y)
mac80211-objs := \ # mac80211 objects
mac80211-y := \
ieee80211.o \ ieee80211.o \
ieee80211_ioctl.o \ ieee80211_ioctl.o \
sta_info.o \ sta_info.o \
...@@ -31,5 +27,22 @@ mac80211-objs := \ ...@@ -31,5 +27,22 @@ mac80211-objs := \
tx.o \ tx.o \
key.o \ key.o \
util.o \ util.o \
event.o \ event.o
$(mac80211-objs-y)
mac80211-$(CONFIG_MAC80211_LEDS) += ieee80211_led.o
mac80211-$(CONFIG_NET_SCHED) += wme.o
mac80211-$(CONFIG_MAC80211_DEBUGFS) += \
debugfs.o \
debugfs_sta.o \
debugfs_netdev.o \
debugfs_key.o
# Build rate control algorithm(s)
CFLAGS_rc80211_simple.o += -DRC80211_SIMPLE_COMPILE
CFLAGS_rc80211_pid_algo.o += -DRC80211_PID_COMPILE
mac80211-$(CONFIG_MAC80211_RC_SIMPLE) += rc80211_simple.o
mac80211-$(CONFIG_MAC80211_RC_PID) += $(rc-pid-$(CONFIG_MAC80211_RC_PID))
# Modular rate algorithms are assigned to mac80211-m - make separate modules
obj-m += $(mac80211-m)
...@@ -1323,23 +1323,19 @@ static int __init ieee80211_init(void) ...@@ -1323,23 +1323,19 @@ static int __init ieee80211_init(void)
BUILD_BUG_ON(sizeof(struct ieee80211_tx_packet_data) > sizeof(skb->cb)); BUILD_BUG_ON(sizeof(struct ieee80211_tx_packet_data) > sizeof(skb->cb));
#ifdef CONFIG_MAC80211_RC_SIMPLE ret = rc80211_simple_init();
ret = ieee80211_rate_control_register(&mac80211_rcsimple);
if (ret) if (ret)
goto fail; goto fail;
#endif
#ifdef CONFIG_MAC80211_RC_PID ret = rc80211_pid_init();
ret = ieee80211_rate_control_register(&mac80211_rcpid);
if (ret) if (ret)
goto fail; goto fail_simple;
#endif
ret = ieee80211_wme_register(); ret = ieee80211_wme_register();
if (ret) { if (ret) {
printk(KERN_DEBUG "ieee80211_init: failed to " printk(KERN_DEBUG "ieee80211_init: failed to "
"initialize WME (err=%d)\n", ret); "initialize WME (err=%d)\n", ret);
goto fail; goto fail_pid;
} }
ieee80211_debugfs_netdev_init(); ieee80211_debugfs_netdev_init();
...@@ -1347,26 +1343,18 @@ static int __init ieee80211_init(void) ...@@ -1347,26 +1343,18 @@ static int __init ieee80211_init(void)
return 0; return 0;
fail: fail_pid:
rc80211_simple_exit();
#ifdef CONFIG_MAC80211_RC_SIMPLE fail_simple:
ieee80211_rate_control_unregister(&mac80211_rcsimple); rc80211_pid_exit();
#endif fail:
#ifdef CONFIG_MAC80211_RC_PID
ieee80211_rate_control_unregister(&mac80211_rcpid);
#endif
return ret; return ret;
} }
static void __exit ieee80211_exit(void) static void __exit ieee80211_exit(void)
{ {
#ifdef CONFIG_MAC80211_RC_SIMPLE rc80211_simple_exit();
ieee80211_rate_control_unregister(&mac80211_rcsimple); rc80211_pid_exit();
#endif
#ifdef CONFIG_MAC80211_RC_PID
ieee80211_rate_control_unregister(&mac80211_rcpid);
#endif
ieee80211_wme_unregister(); ieee80211_wme_unregister();
ieee80211_debugfs_netdev_exit(); ieee80211_debugfs_netdev_exit();
......
...@@ -115,6 +115,10 @@ ieee80211_rate_control_ops_get(const char *name) ...@@ -115,6 +115,10 @@ ieee80211_rate_control_ops_get(const char *name)
/* try default if specific alg requested but not found */ /* try default if specific alg requested but not found */
ops = ieee80211_try_rate_control_ops_get(ieee80211_default_rc_algo); ops = ieee80211_try_rate_control_ops_get(ieee80211_default_rc_algo);
/* try built-in one if specific alg requested but not found */
if (!ops && strlen(CONFIG_MAC80211_RC_DEFAULT))
ops = ieee80211_try_rate_control_ops_get(CONFIG_MAC80211_RC_DEFAULT);
return ops; return ops;
} }
......
...@@ -58,12 +58,6 @@ struct rate_control_ref { ...@@ -58,12 +58,6 @@ struct rate_control_ref {
struct kref kref; struct kref kref;
}; };
/* default 'simple' algorithm */
extern struct rate_control_ops mac80211_rcsimple;
/* 'PID' algorithm */
extern struct rate_control_ops mac80211_rcpid;
int ieee80211_rate_control_register(struct rate_control_ops *ops); int ieee80211_rate_control_register(struct rate_control_ops *ops);
void ieee80211_rate_control_unregister(struct rate_control_ops *ops); void ieee80211_rate_control_unregister(struct rate_control_ops *ops);
...@@ -170,4 +164,36 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local, ...@@ -170,4 +164,36 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
const char *name); const char *name);
void rate_control_deinitialize(struct ieee80211_local *local); void rate_control_deinitialize(struct ieee80211_local *local);
/* Rate control algorithms */
#if defined(RC80211_SIMPLE_COMPILE) || \
(defined(CONFIG_MAC80211_RC_SIMPLE) && \
!defined(CONFIG_MAC80211_RC_SIMPLE_MODULE))
extern int rc80211_simple_init(void);
extern void rc80211_simple_exit(void);
#else
static inline int rc80211_simple_init(void)
{
return 0;
}
static inline void rc80211_simple_exit(void)
{
}
#endif
#if defined(RC80211_PID_COMPILE) || \
(defined(CONFIG_MAC80211_RC_PID) && \
!defined(CONFIG_MAC80211_RC_PID_MODULE))
extern int rc80211_pid_init(void);
extern void rc80211_pid_exit(void);
#else
static inline int rc80211_pid_init(void)
{
return 0;
}
static inline void rc80211_pid_exit(void)
{
}
#endif
#endif /* IEEE80211_RATE_H */ #endif /* IEEE80211_RATE_H */
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/debugfs.h>
#include <net/mac80211.h> #include <net/mac80211.h>
#include "ieee80211_rate.h" #include "ieee80211_rate.h"
...@@ -492,7 +492,7 @@ static void rate_control_pid_free_sta(void *priv, void *priv_sta) ...@@ -492,7 +492,7 @@ static void rate_control_pid_free_sta(void *priv, void *priv_sta)
kfree(spinfo); kfree(spinfo);
} }
struct rate_control_ops mac80211_rcpid = { static struct rate_control_ops mac80211_rcpid = {
.name = "pid", .name = "pid",
.tx_status = rate_control_pid_tx_status, .tx_status = rate_control_pid_tx_status,
.get_rate = rate_control_pid_get_rate, .get_rate = rate_control_pid_get_rate,
...@@ -507,3 +507,23 @@ struct rate_control_ops mac80211_rcpid = { ...@@ -507,3 +507,23 @@ struct rate_control_ops mac80211_rcpid = {
.remove_sta_debugfs = rate_control_pid_remove_sta_debugfs, .remove_sta_debugfs = rate_control_pid_remove_sta_debugfs,
#endif #endif
}; };
MODULE_DESCRIPTION("PID controller based rate control algorithm");
MODULE_AUTHOR("Stefano Brivio");
MODULE_AUTHOR("Mattias Nissler");
MODULE_LICENSE("GPL");
int __init rc80211_pid_init(void)
{
return ieee80211_rate_control_register(&mac80211_rcpid);
}
void __exit rc80211_pid_exit(void)
{
ieee80211_rate_control_unregister(&mac80211_rcpid);
}
#ifdef CONFIG_MAC80211_RC_PID_MODULE
module_init(rc80211_pid_init);
module_exit(rc80211_pid_exit);
#endif
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/compiler.h> #include <linux/compiler.h>
#include <linux/module.h>
#include <net/mac80211.h> #include <net/mac80211.h>
#include "ieee80211_i.h" #include "ieee80211_i.h"
...@@ -349,7 +350,7 @@ static void rate_control_simple_remove_sta_debugfs(void *priv, void *priv_sta) ...@@ -349,7 +350,7 @@ static void rate_control_simple_remove_sta_debugfs(void *priv, void *priv_sta)
} }
#endif #endif
struct rate_control_ops mac80211_rcsimple = { static struct rate_control_ops mac80211_rcsimple = {
.name = "simple", .name = "simple",
.tx_status = rate_control_simple_tx_status, .tx_status = rate_control_simple_tx_status,
.get_rate = rate_control_simple_get_rate, .get_rate = rate_control_simple_get_rate,
...@@ -364,3 +365,21 @@ struct rate_control_ops mac80211_rcsimple = { ...@@ -364,3 +365,21 @@ struct rate_control_ops mac80211_rcsimple = {
.remove_sta_debugfs = rate_control_simple_remove_sta_debugfs, .remove_sta_debugfs = rate_control_simple_remove_sta_debugfs,
#endif #endif
}; };
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Simple rate control algorithm");
int __init rc80211_simple_init(void)
{
return ieee80211_rate_control_register(&mac80211_rcsimple);
}
void __exit rc80211_simple_exit(void)
{
ieee80211_rate_control_unregister(&mac80211_rcsimple);
}
#ifdef CONFIG_MAC80211_RC_SIMPLE_MODULE
module_init(rc80211_simple_init);
module_exit(rc80211_simple_exit);
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment