From 61576263210400ee86791f5d4fdc202442f1e55f Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Tue, 15 Jan 2008 03:03:25 +0000 Subject: [PATCH] Simplify tx rate control for drivers which only support periodic TX data statistics. --- sys/dev/netif/rum/if_rum.c | 12 +++---- sys/dev/netif/ural/if_ural.c | 15 +++----- sys/netproto/802_11/ieee80211_ratectl.h | 19 +++------- .../wlan_ratectl/amrr/ieee80211_ratectl_amrr.c | 40 +++------------------- .../wlan_ratectl/onoe/ieee80211_ratectl_onoe.c | 20 ++--------- 5 files changed, 22 insertions(+), 84 deletions(-) diff --git a/sys/dev/netif/rum/if_rum.c b/sys/dev/netif/rum/if_rum.c index d75a80738f..8dc7ace3c4 100644 --- a/sys/dev/netif/rum/if_rum.c +++ b/sys/dev/netif/rum/if_rum.c @@ -1,5 +1,5 @@ /* $OpenBSD: if_rum.c,v 1.40 2006/09/18 16:20:20 damien Exp $ */ -/* $DragonFly: src/sys/dev/netif/rum/if_rum.c,v 1.24 2008/01/14 19:27:11 josepht Exp $ */ +/* $DragonFly: src/sys/dev/netif/rum/if_rum.c,v 1.25 2008/01/15 03:03:25 sephe Exp $ */ /*- * Copyright (c) 2005, 2006 Damien Bergamini @@ -236,9 +236,12 @@ static driver_t rum_driver = { sizeof(struct rum_softc) }; -MODULE_DEPEND(rum, usb, 1, 1, 1); DRIVER_MODULE(rum, uhub, rum_driver, rum_devclass, usbd_driver_load, 0); +MODULE_DEPEND(rum, usb, 1, 1, 1); +MODULE_DEPEND(rum, wlan, 1, 1, 1); +MODULE_DEPEND(rum, wlan_ratectl_onoe, 1, 1, 1); + static int rum_match(device_t self) { @@ -406,11 +409,6 @@ rum_attach(device_t self) ic->ic_ratectl.rc_st_ratectl_cap = IEEE80211_RATECTL_CAP_ONOE; ic->ic_ratectl.rc_st_ratectl = IEEE80211_RATECTL_ONOE; - ic->ic_ratectl.rc_st_valid_stats = - IEEE80211_RATECTL_STATS_PKT_NORETRY | - IEEE80211_RATECTL_STATS_PKT_OK | - IEEE80211_RATECTL_STATS_PKT_ERR | - IEEE80211_RATECTL_STATS_RETRIES; ic->ic_ratectl.rc_st_stats = rum_stats; ic->ic_ratectl.rc_st_change = rum_ratectl_change; diff --git a/sys/dev/netif/ural/if_ural.c b/sys/dev/netif/ural/if_ural.c index 486c14bca7..aa884278d5 100644 --- a/sys/dev/netif/ural/if_ural.c +++ b/sys/dev/netif/ural/if_ural.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/dev/usb/if_ural.c,v 1.10.2.8 2006/07/08 07:48:43 maxim Exp $ */ -/* $DragonFly: src/sys/dev/netif/ural/if_ural.c,v 1.23 2007/11/06 07:37:00 hasso Exp $ */ +/* $DragonFly: src/sys/dev/netif/ural/if_ural.c,v 1.24 2008/01/15 03:03:25 sephe Exp $ */ /*- * Copyright (c) 2005, 2006 @@ -98,8 +98,6 @@ static const struct usb_devno ural_devs[] = { { USB_DEVICE(0x5a57, 0x0260) }, /* Zinwell RT2570 */ }; -MODULE_DEPEND(ural, wlan, 1, 1, 1); - static int ural_alloc_tx_list(struct ural_softc *); static void ural_free_tx_list(struct ural_softc *); static int ural_alloc_rx_list(struct ural_softc *); @@ -359,7 +357,11 @@ static driver_t ural_driver = { sizeof(struct ural_softc) }; +DRIVER_MODULE(ural, uhub, ural_driver, ural_devclass, usbd_driver_load, 0); + MODULE_DEPEND(ural, usb, 1, 1, 1); +MODULE_DEPEND(ural, wlan, 1, 1, 1); +MODULE_DEPEND(ural, wlan_ratectl_onoe, 1, 1, 1); static int ural_match(device_t self) @@ -457,11 +459,6 @@ ural_attach(device_t self) ic->ic_ratectl.rc_st_ratectl_cap = IEEE80211_RATECTL_CAP_ONOE; ic->ic_ratectl.rc_st_ratectl = IEEE80211_RATECTL_ONOE; - ic->ic_ratectl.rc_st_valid_stats = - IEEE80211_RATECTL_STATS_PKT_NORETRY | - IEEE80211_RATECTL_STATS_PKT_OK | - IEEE80211_RATECTL_STATS_PKT_ERR | - IEEE80211_RATECTL_STATS_RETRIES; ic->ic_ratectl.rc_st_stats = ural_stats; ic->ic_ratectl.rc_st_change = ural_ratectl_change; @@ -2453,5 +2450,3 @@ ural_ratectl_change(struct ieee80211com *ic, u_int orc __unused, u_int nrc) panic("unknown rate control algo %u\n", nrc); } } - -DRIVER_MODULE(ural, uhub, ural_driver, ural_devclass, usbd_driver_load, 0); diff --git a/sys/netproto/802_11/ieee80211_ratectl.h b/sys/netproto/802_11/ieee80211_ratectl.h index ffce538b8b..a81a1cca9f 100644 --- a/sys/netproto/802_11/ieee80211_ratectl.h +++ b/sys/netproto/802_11/ieee80211_ratectl.h @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/netproto/802_11/ieee80211_ratectl.h,v 1.5 2007/04/01 13:59:40 sephe Exp $ + * $DragonFly: src/sys/netproto/802_11/ieee80211_ratectl.h,v 1.6 2008/01/15 03:03:25 sephe Exp $ */ #ifndef _NET80211_IEEE80211_RATECTL_H @@ -47,7 +47,6 @@ struct ieee80211_ratectl_state { uint32_t rc_st_flags; /* see IEEE80211_RATECTL_F_ */ u_int rc_st_ratectl; /* see IEEE80211_RATECTL_ */ uint32_t rc_st_ratectl_cap; /* see IEEE80211_RATECTL_CAP_ */ - uint64_t rc_st_valid_stats; /* see IEEE80211_RATECTL_STATS_ */ void (*rc_st_change)(struct ieee80211com *, u_int, u_int); void (*rc_st_stats)(struct ieee80211com *, struct ieee80211_node *, @@ -62,21 +61,13 @@ struct ieee80211_ratectl_res { int rc_res_tries; }; -#define IEEE80211_RATECTL_STATS_RES 0x1 -#define IEEE80211_RATECTL_STATS_PKT_NORETRY 0x2 -#define IEEE80211_RATECTL_STATS_PKT_OK 0x4 -#define IEEE80211_RATECTL_STATS_PKT_ERR 0x8 -#define IEEE80211_RATECTL_STATS_RETRIES 0x10 - #define IEEE80211_RATEIDX_MAX 5 struct ieee80211_ratectl_stats { - struct ieee80211_ratectl_res stats_res[IEEE80211_RATEIDX_MAX]; - int stats_res_len; - int stats_pkt_noretry; - int stats_pkt_ok; - int stats_pkt_err; - int stats_retries; + int stats_pkt_noretry; + int stats_pkt_ok; + int stats_pkt_err; + int stats_retries; }; struct ieee80211_ratectl { diff --git a/sys/netproto/802_11/wlan_ratectl/amrr/ieee80211_ratectl_amrr.c b/sys/netproto/802_11/wlan_ratectl/amrr/ieee80211_ratectl_amrr.c index 04bca96dee..bdeb8b27ec 100644 --- a/sys/netproto/802_11/wlan_ratectl/amrr/ieee80211_ratectl_amrr.c +++ b/sys/netproto/802_11/wlan_ratectl/amrr/ieee80211_ratectl_amrr.c @@ -35,7 +35,7 @@ * THE POSSIBILITY OF SUCH DAMAGES. * * $FreeBSD: src/sys/dev/ath/ath_rate/amrr/amrr.c,v 1.8.2.3 2006/02/24 19:51:11 sam Exp $ - * $DragonFly: src/sys/netproto/802_11/wlan_ratectl/amrr/ieee80211_ratectl_amrr.c,v 1.9 2007/03/19 13:38:43 sephe Exp $ + * $DragonFly: src/sys/netproto/802_11/wlan_ratectl/amrr/ieee80211_ratectl_amrr.c,v 1.10 2008/01/15 03:03:25 sephe Exp $ */ /* @@ -70,17 +70,6 @@ #define DPRINTF(asc, lv, fmt, ...) #endif -#define AMRR_REQUIRE_STATS1 (IEEE80211_RATECTL_STATS_RES | \ - IEEE80211_RATECTL_STATS_PKT_NORETRY) -#define AMRR_REQUIRE_STATS2 (IEEE80211_RATECTL_STATS_PKT_NORETRY | \ - IEEE80211_RATECTL_STATS_PKT_OK | \ - IEEE80211_RATECTL_STATS_PKT_ERR | \ - IEEE80211_RATECTL_STATS_RETRIES) -#define AMRR_MEET_REQUIRE_STATS1(stats_mask) \ - (((stats_mask) & AMRR_REQUIRE_STATS1) == AMRR_REQUIRE_STATS1) -#define AMRR_MEET_REQUIRE_STATS2(stats_mask) \ - (((stats_mask) & AMRR_REQUIRE_STATS2) == AMRR_REQUIRE_STATS2) - static void *amrr_attach(struct ieee80211com *); static void amrr_detach(void *); static void amrr_data_alloc(struct ieee80211_node *); @@ -340,16 +329,9 @@ amrr_gather_stats(struct amrr_softc *asc, struct ieee80211_node *ni) st->rc_st_stats(ic, ni, &stats); - if (AMRR_MEET_REQUIRE_STATS1(st->rc_st_valid_stats)) { - int i; - - for (i = 0; i < stats.stats_res_len; ++i) - total_tries += stats.stats_res[i].rc_res_tries; - } else if (AMRR_MEET_REQUIRE_STATS2(st->rc_st_valid_stats)) { - total_tries = stats.stats_pkt_ok + - stats.stats_pkt_err + - stats.stats_retries; - } + total_tries = stats.stats_pkt_ok + + stats.stats_pkt_err + + stats.stats_retries; ad->ad_tx_cnt += total_tries; ad->ad_tx_failure_cnt += (total_tries - stats.stats_pkt_noretry); @@ -380,12 +362,8 @@ amrr_ratectl(void *arg, struct ieee80211_node *ni) old_rate = ni->ni_txrate; - if (st->rc_st_stats != NULL) { - if (!AMRR_MEET_REQUIRE_STATS1(st->rc_st_valid_stats) && - !AMRR_MEET_REQUIRE_STATS2(st->rc_st_valid_stats)) - return; + if (st->rc_st_stats != NULL) amrr_gather_stats(asc, ni); - } DPRINTF(asc, 10, "tx_cnt: %u tx_failure_cnt: %u -- " "threshold: %d\n", @@ -509,16 +487,8 @@ amrr_sysctl_attach(struct amrr_softc *asc) static void * amrr_attach(struct ieee80211com *ic) { - const struct ieee80211_ratectl_state *st = &ic->ic_ratectl; struct amrr_softc *asc; - if (st->rc_st_stats != NULL && - !AMRR_MEET_REQUIRE_STATS1(st->rc_st_valid_stats) && - !AMRR_MEET_REQUIRE_STATS2(st->rc_st_valid_stats)) { - if_printf(&ic->ic_if, "WARNING: %s needs more average " - "statistics to work properly\n", amrr.rc_name); - } - amrr_nrefs++; asc = kmalloc(sizeof(struct amrr_softc), M_DEVBUF, M_WAITOK | M_ZERO); diff --git a/sys/netproto/802_11/wlan_ratectl/onoe/ieee80211_ratectl_onoe.c b/sys/netproto/802_11/wlan_ratectl/onoe/ieee80211_ratectl_onoe.c index 0fa1292e13..732b0c27b3 100644 --- a/sys/netproto/802_11/wlan_ratectl/onoe/ieee80211_ratectl_onoe.c +++ b/sys/netproto/802_11/wlan_ratectl/onoe/ieee80211_ratectl_onoe.c @@ -34,7 +34,7 @@ * THE POSSIBILITY OF SUCH DAMAGES. * * $FreeBSD: src/sys/dev/ath/ath_rate/onoe/onoe.c,v 1.8.2.3 2006/02/24 19:51:11 sam Exp $ - * $DragonFly: src/sys/netproto/802_11/wlan_ratectl/onoe/ieee80211_ratectl_onoe.c,v 1.8 2007/03/19 13:38:43 sephe Exp $ + * $DragonFly: src/sys/netproto/802_11/wlan_ratectl/onoe/ieee80211_ratectl_onoe.c,v 1.9 2008/01/15 03:03:25 sephe Exp $ */ /* @@ -67,12 +67,6 @@ #define DPRINTF(osc, lv, fmt, ...) #endif -#define ONOE_REQUIRE_STATS (IEEE80211_RATECTL_STATS_PKT_OK | \ - IEEE80211_RATECTL_STATS_PKT_ERR | \ - IEEE80211_RATECTL_STATS_RETRIES) -#define ONOE_MEET_REQUIRE_STATS(stats_mask) \ - (((stats_mask) & ONOE_REQUIRE_STATS) == ONOE_REQUIRE_STATS) - /* * Default parameters for the rate control algorithm. These are * all tunable with sysctls. The rate controller runs periodically @@ -351,11 +345,8 @@ onoe_ratectl(void *arg, struct ieee80211_node *ni) return; } - if (st->rc_st_stats != NULL) { - if (!ONOE_MEET_REQUIRE_STATS(st->rc_st_valid_stats)) - return; + if (st->rc_st_stats != NULL) onoe_gather_stats(osc, ni); - } /* * Rate control @@ -489,15 +480,8 @@ onoe_sysctl_attach(struct onoe_softc *osc) static void * onoe_attach(struct ieee80211com *ic) { - const struct ieee80211_ratectl_state *st = &ic->ic_ratectl; struct onoe_softc *osc; - if (st->rc_st_stats != NULL && - !ONOE_MEET_REQUIRE_STATS(st->rc_st_valid_stats)) { - if_printf(&ic->ic_if, "WARNING: %s needs more average " - "statistics to work properly\n", onoe.rc_name); - } - onoe_nrefs++; osc = kmalloc(sizeof(struct onoe_softc), M_DEVBUF, M_WAITOK | M_ZERO); -- 2.11.4.GIT