From 1976da20e6203b8871806d63f1c2242a805af7c4 Mon Sep 17 00:00:00 2001 From: nbd Date: Sun, 28 Nov 2010 18:28:12 +0000 Subject: mac80211: merge the new version of the throughput led trigger patch git-svn-id: svn://svn.openwrt.org/openwrt/trunk@24182 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../mac80211/patches/562-throughput_trigger.patch | 77 +++--- .../patches/563-ath9k_cleanup_led_blink.patch | 299 +++++++++++++++++++++ .../patches/563-tpt_trigger_register_fix.patch | 29 -- .../patches/564-tpt_trigger_idle_fix.patch | 29 -- .../patches/565-ath9k_cleanup_led_blink.patch | 278 ------------------- 5 files changed, 345 insertions(+), 367 deletions(-) create mode 100644 package/mac80211/patches/563-ath9k_cleanup_led_blink.patch delete mode 100644 package/mac80211/patches/563-tpt_trigger_register_fix.patch delete mode 100644 package/mac80211/patches/564-tpt_trigger_idle_fix.patch delete mode 100644 package/mac80211/patches/565-ath9k_cleanup_led_blink.patch (limited to 'package/mac80211/patches') diff --git a/package/mac80211/patches/562-throughput_trigger.patch b/package/mac80211/patches/562-throughput_trigger.patch index 811054794..7f85c466a 100644 --- a/package/mac80211/patches/562-throughput_trigger.patch +++ b/package/mac80211/patches/562-throughput_trigger.patch @@ -14,20 +14,23 @@ device, best with blink hardware offload. Signed-off-by: Johannes Berg --- v2: turn off LED when turning off radio +v3: - use only data frames + - fix update frequency to 1 second + - use DIV_ROUND_UP - include/net/mac80211.h | 42 +++++++++++++++ - net/mac80211/ieee80211_i.h | 14 +++++ + include/net/mac80211.h | 38 ++++++++++++++ + net/mac80211/ieee80211_i.h | 13 ++++ net/mac80211/iface.c | 1 - net/mac80211/led.c | 120 +++++++++++++++++++++++++++++++++++++++++++++ + net/mac80211/led.c | 119 +++++++++++++++++++++++++++++++++++++++++++++ net/mac80211/led.h | 44 +++++++++++++--- - net/mac80211/rx.c | 1 - net/mac80211/tx.c | 1 + net/mac80211/rx.c | 3 + + net/mac80211/tx.c | 3 + net/mac80211/util.c | 2 - 8 files changed, 216 insertions(+), 9 deletions(-) + 8 files changed, 214 insertions(+), 9 deletions(-) --- a/include/net/mac80211.h +++ b/include/net/mac80211.h -@@ -1849,11 +1849,27 @@ struct ieee80211_hw *ieee80211_alloc_hw( +@@ -1849,11 +1849,26 @@ struct ieee80211_hw *ieee80211_alloc_hw( */ int ieee80211_register_hw(struct ieee80211_hw *hw); @@ -49,19 +52,17 @@ v2: turn off LED when turning off radio extern char *__ieee80211_get_radio_led_name(struct ieee80211_hw *hw); +extern char *__ieee80211_create_tpt_led_trigger( + struct ieee80211_hw *hw, -+ unsigned long update_timeout, + const struct ieee80211_tpt_blink *blink_table, + unsigned int blink_table_len); #endif /** * ieee80211_get_tx_led_name - get name of TX LED -@@ -1932,6 +1948,32 @@ static inline char *ieee80211_get_radio_ +@@ -1932,6 +1947,29 @@ static inline char *ieee80211_get_radio_ } /** + * ieee80211_create_tpt_led_trigger - create throughput LED trigger + * @hw: the hardware to create the trigger for -+ * @update_timeout: the update timeout (in jiffies) + * @blink_table: the blink table -- needs to be ordered by throughput + * @blink_table_len: size of the blink table + * @@ -71,13 +72,11 @@ v2: turn off LED when turning off radio + */ +static inline char * +ieee80211_create_tpt_led_trigger(struct ieee80211_hw *hw, -+ unsigned long update_timeout, + const struct ieee80211_tpt_blink *blink_table, + unsigned int blink_table_len) +{ +#ifdef CONFIG_MAC80211_LEDS -+ return __ieee80211_create_tpt_led_trigger(hw, update_timeout, -+ blink_table, ++ return __ieee80211_create_tpt_led_trigger(hw, blink_table, + blink_table_len); +#else + return NULL; @@ -98,7 +97,7 @@ v2: turn off LED when turning off radio #include #include #include -@@ -636,6 +637,18 @@ enum queue_stop_reason { +@@ -636,6 +637,17 @@ enum queue_stop_reason { IEEE80211_QUEUE_STOP_REASON_SKB_ADD, }; @@ -107,7 +106,6 @@ v2: turn off LED when turning off radio + char name[32]; + const struct ieee80211_tpt_blink *blink_table; + unsigned int blink_table_len; -+ unsigned long update_timeout; + struct timer_list timer; + bool running; + unsigned long prev_traffic; @@ -117,7 +115,7 @@ v2: turn off LED when turning off radio /** * mac80211 scan flags - currently active scan mode * -@@ -849,6 +862,7 @@ struct ieee80211_local { +@@ -849,6 +861,7 @@ struct ieee80211_local { #ifdef CONFIG_MAC80211_LEDS int tx_led_counter, rx_led_counter; struct led_trigger *tx_led, *rx_led, *assoc_led, *radio_led; @@ -153,7 +151,7 @@ v2: turn off LED when turning off radio } char *__ieee80211_get_radio_led_name(struct ieee80211_hw *hw) -@@ -156,3 +168,111 @@ char *__ieee80211_get_rx_led_name(struct +@@ -156,3 +168,110 @@ char *__ieee80211_get_rx_led_name(struct return local->rx_led_name; } EXPORT_SYMBOL(__ieee80211_get_rx_led_name); @@ -167,7 +165,7 @@ v2: turn off LED when turning off radio + + delta = traffic - tpt_trig->prev_traffic; + tpt_trig->prev_traffic = traffic; -+ return delta / (1024 / 8); ++ return DIV_ROUND_UP(delta, 1024 / 8); +} + +static void tpt_trig_timer(unsigned long data) @@ -181,7 +179,7 @@ v2: turn off LED when turning off radio + if (!tpt_trig->running) + return; + -+ mod_timer(&tpt_trig->timer, jiffies + tpt_trig->update_timeout); ++ mod_timer(&tpt_trig->timer, round_jiffies(jiffies + HZ)); + + tpt = tpt_trig_traffic(local, tpt_trig); + @@ -190,7 +188,7 @@ v2: turn off LED when turning off radio + off = 0; + + for (i = tpt_trig->blink_table_len - 1; i >= 0; i--) { -+ if (tpt >= tpt_trig->blink_table[i].throughput) { ++ if (tpt > tpt_trig->blink_table[i].throughput) { + off = tpt_trig->blink_table[i].blink_time / 2; + on = tpt_trig->blink_table[i].blink_time - off; + break; @@ -205,7 +203,6 @@ v2: turn off LED when turning off radio + +extern char *__ieee80211_create_tpt_led_trigger( + struct ieee80211_hw *hw, -+ unsigned long update_timeout, + const struct ieee80211_tpt_blink *blink_table, + unsigned int blink_table_len) +{ @@ -224,7 +221,6 @@ v2: turn off LED when turning off radio + + tpt_trig->trig.name = tpt_trig->name; + -+ tpt_trig->update_timeout = update_timeout; + tpt_trig->blink_table = blink_table; + tpt_trig->blink_table_len = blink_table_len; + @@ -246,7 +242,8 @@ v2: turn off LED when turning off radio + /* reset traffic */ + tpt_trig_traffic(local, tpt_trig); + tpt_trig->running = true; -+ mod_timer(&tpt_trig->timer, jiffies + tpt_trig->update_timeout); ++ ++ mod_timer(&tpt_trig->timer, round_jiffies(jiffies + HZ)); +} + +void ieee80211_stop_tpt_led_trig(struct ieee80211_local *local) @@ -307,19 +304,19 @@ v2: turn off LED when turning off radio +#endif + +static inline void -+ieee80211_tpt_led_trig_tx(struct ieee80211_local *local, int bytes) ++ieee80211_tpt_led_trig_tx(struct ieee80211_local *local, __le16 fc, int bytes) +{ +#ifdef CONFIG_MAC80211_LEDS -+ if (local->tpt_led_trigger) ++ if (local->tpt_led_trigger && ieee80211_is_data(fc)) + local->tpt_led_trigger->tx_bytes += bytes; #endif +} + +static inline void -+ieee80211_tpt_led_trig_rx(struct ieee80211_local *local, int bytes) ++ieee80211_tpt_led_trig_rx(struct ieee80211_local *local, __le16 fc, int bytes) +{ +#ifdef CONFIG_MAC80211_LEDS -+ if (local->tpt_led_trigger) ++ if (local->tpt_led_trigger && ieee80211_is_data(fc)) + local->tpt_led_trigger->rx_bytes += bytes; +#endif +} @@ -353,21 +350,39 @@ v2: turn off LED when turning off radio /* add interfaces */ --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c -@@ -2873,6 +2873,7 @@ void ieee80211_rx(struct ieee80211_hw *h +@@ -2873,6 +2873,9 @@ void ieee80211_rx(struct ieee80211_hw *h return; } -+ ieee80211_tpt_led_trig_rx(local, skb->len); ++ ieee80211_tpt_led_trig_rx(local, ++ ((struct ieee80211_hdr *)skb->data)->frame_control, ++ skb->len); __ieee80211_rx_handle_packet(hw, skb); rcu_read_unlock(); --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c -@@ -1344,6 +1344,7 @@ static int __ieee80211_tx(struct ieee802 +@@ -1292,6 +1292,7 @@ static int __ieee80211_tx(struct ieee802 + + while (skb) { + int q = skb_get_queue_mapping(skb); ++ __le16 fc; + + spin_lock_irqsave(&local->queue_stop_reason_lock, flags); + ret = IEEE80211_TX_OK; +@@ -1334,6 +1335,7 @@ static int __ieee80211_tx(struct ieee802 + else + info->control.sta = NULL; + ++ fc = ((struct ieee80211_hdr *)skb->data)->frame_control; + ret = drv_tx(local, skb); + if (WARN_ON(ret != NETDEV_TX_OK && skb->len != len)) { + dev_kfree_skb(skb); +@@ -1344,6 +1346,7 @@ static int __ieee80211_tx(struct ieee802 return IEEE80211_TX_AGAIN; } -+ ieee80211_tpt_led_trig_tx(local, len); ++ ieee80211_tpt_led_trig_tx(local, fc, len); *skbp = skb = next; ieee80211_led_tx(local, 1); fragm = true; diff --git a/package/mac80211/patches/563-ath9k_cleanup_led_blink.patch b/package/mac80211/patches/563-ath9k_cleanup_led_blink.patch new file mode 100644 index 000000000..3c804d2ad --- /dev/null +++ b/package/mac80211/patches/563-ath9k_cleanup_led_blink.patch @@ -0,0 +1,299 @@ +--- a/drivers/net/wireless/ath/ath9k/ath9k.h ++++ b/drivers/net/wireless/ath/ath9k/ath9k.h +@@ -437,26 +437,20 @@ void ath9k_btcoex_timer_pause(struct ath + + #define ATH_LED_PIN_DEF 1 + #define ATH_LED_PIN_9287 8 +-#define ATH_LED_ON_DURATION_IDLE 350 /* in msecs */ +-#define ATH_LED_OFF_DURATION_IDLE 250 /* in msecs */ +- +-enum ath_led_type { +- ATH_LED_RADIO, +- ATH_LED_ASSOC, +- ATH_LED_TX, +- ATH_LED_RX +-}; +- +-struct ath_led { +- struct ath_softc *sc; +- struct led_classdev led_cdev; +- enum ath_led_type led_type; +- char name[32]; +- bool registered; +-}; + ++#ifdef CONFIG_MAC80211_LEDS + void ath_init_leds(struct ath_softc *sc); + void ath_deinit_leds(struct ath_softc *sc); ++#else ++static inline void ath_init_leds(struct ath_softc *sc) ++{ ++} ++ ++static inline void ath_deinit_leds(struct ath_softc *sc) ++{ ++} ++#endif ++ + + /* Antenna diversity/combining */ + #define ATH_ANT_RX_CURRENT_SHIFT 4 +@@ -606,15 +600,11 @@ struct ath_softc { + struct ath_beacon beacon; + struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS]; + +- struct ath_led radio_led; +- struct ath_led assoc_led; +- struct ath_led tx_led; +- struct ath_led rx_led; +- struct delayed_work ath_led_blink_work; +- int led_on_duration; +- int led_off_duration; +- int led_on_cnt; +- int led_off_cnt; ++#ifdef CONFIG_MAC80211_LEDS ++ bool led_registered; ++ char led_name[32]; ++ struct led_classdev led_cdev; ++#endif + + int beacon_interval; + +--- a/drivers/net/wireless/ath/ath9k/gpio.c ++++ b/drivers/net/wireless/ath/ath9k/gpio.c +@@ -20,120 +20,25 @@ + /* LED functions */ + /********************************/ + +-static void ath_led_blink_work(struct work_struct *work) +-{ +- struct ath_softc *sc = container_of(work, struct ath_softc, +- ath_led_blink_work.work); +- +- if (!(sc->sc_flags & SC_OP_LED_ASSOCIATED)) +- return; +- +- if ((sc->led_on_duration == ATH_LED_ON_DURATION_IDLE) || +- (sc->led_off_duration == ATH_LED_OFF_DURATION_IDLE)) +- ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 0); +- else +- ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, +- (sc->sc_flags & SC_OP_LED_ON) ? 1 : 0); +- +- ieee80211_queue_delayed_work(sc->hw, +- &sc->ath_led_blink_work, +- (sc->sc_flags & SC_OP_LED_ON) ? +- msecs_to_jiffies(sc->led_off_duration) : +- msecs_to_jiffies(sc->led_on_duration)); +- +- sc->led_on_duration = sc->led_on_cnt ? +- max((ATH_LED_ON_DURATION_IDLE - sc->led_on_cnt), 25) : +- ATH_LED_ON_DURATION_IDLE; +- sc->led_off_duration = sc->led_off_cnt ? +- max((ATH_LED_OFF_DURATION_IDLE - sc->led_off_cnt), 10) : +- ATH_LED_OFF_DURATION_IDLE; +- sc->led_on_cnt = sc->led_off_cnt = 0; +- if (sc->sc_flags & SC_OP_LED_ON) +- sc->sc_flags &= ~SC_OP_LED_ON; +- else +- sc->sc_flags |= SC_OP_LED_ON; +-} +- ++#ifdef CONFIG_MAC80211_LEDS + static void ath_led_brightness(struct led_classdev *led_cdev, + enum led_brightness brightness) + { +- struct ath_led *led = container_of(led_cdev, struct ath_led, led_cdev); +- struct ath_softc *sc = led->sc; +- +- switch (brightness) { +- case LED_OFF: +- if (led->led_type == ATH_LED_ASSOC || +- led->led_type == ATH_LED_RADIO) { +- ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, +- (led->led_type == ATH_LED_RADIO)); +- sc->sc_flags &= ~SC_OP_LED_ASSOCIATED; +- if (led->led_type == ATH_LED_RADIO) +- sc->sc_flags &= ~SC_OP_LED_ON; +- } else { +- sc->led_off_cnt++; +- } +- break; +- case LED_FULL: +- if (led->led_type == ATH_LED_ASSOC) { +- sc->sc_flags |= SC_OP_LED_ASSOCIATED; +- if (led_blink) +- ieee80211_queue_delayed_work(sc->hw, +- &sc->ath_led_blink_work, 0); +- } else if (led->led_type == ATH_LED_RADIO) { +- ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 0); +- sc->sc_flags |= SC_OP_LED_ON; +- } else { +- sc->led_on_cnt++; +- } +- break; +- default: +- break; +- } +-} +- +-static int ath_register_led(struct ath_softc *sc, struct ath_led *led, +- char *trigger) +-{ +- int ret; +- +- led->sc = sc; +- led->led_cdev.name = led->name; +- led->led_cdev.default_trigger = trigger; +- led->led_cdev.brightness_set = ath_led_brightness; +- +- ret = led_classdev_register(wiphy_dev(sc->hw->wiphy), &led->led_cdev); +- if (ret) +- ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_FATAL, +- "Failed to register led:%s", led->name); +- else +- led->registered = 1; +- return ret; +-} +- +-static void ath_unregister_led(struct ath_led *led) +-{ +- if (led->registered) { +- led_classdev_unregister(&led->led_cdev); +- led->registered = 0; +- } ++ struct ath_softc *sc = container_of(led_cdev, struct ath_softc, led_cdev); ++ ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, (brightness == LED_OFF)); + } + + void ath_deinit_leds(struct ath_softc *sc) + { +- if (AR_SREV_9100(sc->sc_ah)) ++ if (!sc->led_registered) + return; + +- ath_unregister_led(&sc->assoc_led); +- sc->sc_flags &= ~SC_OP_LED_ASSOCIATED; +- ath_unregister_led(&sc->tx_led); +- ath_unregister_led(&sc->rx_led); +- ath_unregister_led(&sc->radio_led); +- ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 1); ++ ath_led_brightness(&sc->led_cdev, LED_OFF); ++ led_classdev_unregister(&sc->led_cdev); + } + + void ath_init_leds(struct ath_softc *sc) + { +- char *trigger; + int ret; + + if (AR_SREV_9100(sc->sc_ah)) +@@ -152,48 +57,22 @@ void ath_init_leds(struct ath_softc *sc) + /* LED off, active low */ + ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 1); + +- if (led_blink) +- INIT_DELAYED_WORK(&sc->ath_led_blink_work, ath_led_blink_work); ++ if (!led_blink) ++ sc->led_cdev.default_trigger = ++ ieee80211_get_radio_led_name(sc->hw); ++ ++ snprintf(sc->led_name, sizeof(sc->led_name), ++ "ath9k-%s", wiphy_name(sc->hw->wiphy)); ++ sc->led_cdev.name = sc->led_name; ++ sc->led_cdev.brightness_set = ath_led_brightness; ++ ++ ret = led_classdev_register(wiphy_dev(sc->hw->wiphy), &sc->led_cdev); ++ if (ret < 0) ++ return; + +- trigger = ieee80211_get_radio_led_name(sc->hw); +- snprintf(sc->radio_led.name, sizeof(sc->radio_led.name), +- "ath9k-%s::radio", wiphy_name(sc->hw->wiphy)); +- ret = ath_register_led(sc, &sc->radio_led, trigger); +- sc->radio_led.led_type = ATH_LED_RADIO; +- if (ret) +- goto fail; +- +- trigger = ieee80211_get_assoc_led_name(sc->hw); +- snprintf(sc->assoc_led.name, sizeof(sc->assoc_led.name), +- "ath9k-%s::assoc", wiphy_name(sc->hw->wiphy)); +- ret = ath_register_led(sc, &sc->assoc_led, trigger); +- sc->assoc_led.led_type = ATH_LED_ASSOC; +- if (ret) +- goto fail; +- +- trigger = ieee80211_get_tx_led_name(sc->hw); +- snprintf(sc->tx_led.name, sizeof(sc->tx_led.name), +- "ath9k-%s::tx", wiphy_name(sc->hw->wiphy)); +- ret = ath_register_led(sc, &sc->tx_led, trigger); +- sc->tx_led.led_type = ATH_LED_TX; +- if (ret) +- goto fail; +- +- trigger = ieee80211_get_rx_led_name(sc->hw); +- snprintf(sc->rx_led.name, sizeof(sc->rx_led.name), +- "ath9k-%s::rx", wiphy_name(sc->hw->wiphy)); +- ret = ath_register_led(sc, &sc->rx_led, trigger); +- sc->rx_led.led_type = ATH_LED_RX; +- if (ret) +- goto fail; +- +- return; +- +-fail: +- if (led_blink) +- cancel_delayed_work_sync(&sc->ath_led_blink_work); +- ath_deinit_leds(sc); ++ sc->led_registered = true; + } ++#endif + + /*******************/ + /* Rfkill */ +--- a/drivers/net/wireless/ath/ath9k/main.c ++++ b/drivers/net/wireless/ath/ath9k/main.c +@@ -1276,9 +1276,6 @@ static void ath9k_stop(struct ieee80211_ + + aphy->state = ATH_WIPHY_INACTIVE; + +- if (led_blink) +- cancel_delayed_work_sync(&sc->ath_led_blink_work); +- + cancel_delayed_work_sync(&sc->tx_complete_work); + cancel_work_sync(&sc->paprd_work); + cancel_work_sync(&sc->hw_check_work); +--- a/drivers/net/wireless/ath/ath9k/init.c ++++ b/drivers/net/wireless/ath/ath9k/init.c +@@ -136,6 +136,20 @@ static struct ieee80211_rate ath9k_legac + RATE(540, 0x0c, 0), + }; + ++static const struct ieee80211_tpt_blink ath9k_tpt_blink[] = { ++ { .throughput = 0 * 1024, .blink_time = 334 }, ++ { .throughput = 1 * 1024, .blink_time = 260 }, ++ { .throughput = 5 * 1024, .blink_time = 220 }, ++ { .throughput = 10 * 1024, .blink_time = 190 }, ++ { .throughput = 20 * 1024, .blink_time = 170 }, ++ { .throughput = 50 * 1024, .blink_time = 150 }, ++ { .throughput = 70 * 1024, .blink_time = 130 }, ++ { .throughput = 100 * 1024, .blink_time = 110 }, ++ { .throughput = 200 * 1024, .blink_time = 80 }, ++ { .throughput = 300 * 1024, .blink_time = 50 }, ++}; ++ ++ + static void ath9k_deinit_softc(struct ath_softc *sc); + + /* +@@ -746,6 +760,10 @@ int ath9k_init_device(u16 devid, struct + + ath9k_init_txpower_limits(sc); + ++ /* must be initialized before ieee80211_register_hw */ ++ sc->led_cdev.default_trigger = ieee80211_create_tpt_led_trigger(sc->hw, ++ ath9k_tpt_blink, ARRAY_SIZE(ath9k_tpt_blink)); ++ + /* Register with mac80211 */ + error = ieee80211_register_hw(hw); + if (error) diff --git a/package/mac80211/patches/563-tpt_trigger_register_fix.patch b/package/mac80211/patches/563-tpt_trigger_register_fix.patch deleted file mode 100644 index 270a5558b..000000000 --- a/package/mac80211/patches/563-tpt_trigger_register_fix.patch +++ /dev/null @@ -1,29 +0,0 @@ ---- a/net/mac80211/led.c -+++ b/net/mac80211/led.c -@@ -103,13 +103,6 @@ void ieee80211_led_init(struct ieee80211 - local->radio_led = NULL; - } - } -- -- if (local->tpt_led_trigger) { -- if (led_trigger_register(&local->tpt_led_trigger->trig)) { -- kfree(local->tpt_led_trigger); -- local->tpt_led_trigger = NULL; -- } -- } - } - - void ieee80211_led_exit(struct ieee80211_local *local) -@@ -243,6 +236,12 @@ extern char *__ieee80211_create_tpt_led_ - - local->tpt_led_trigger = tpt_trig; - -+ if (led_trigger_register(&local->tpt_led_trigger->trig)) { -+ kfree(local->tpt_led_trigger); -+ local->tpt_led_trigger = NULL; -+ return NULL; -+ } -+ - return tpt_trig->name; - } - EXPORT_SYMBOL(__ieee80211_create_tpt_led_trigger); diff --git a/package/mac80211/patches/564-tpt_trigger_idle_fix.patch b/package/mac80211/patches/564-tpt_trigger_idle_fix.patch deleted file mode 100644 index 3578bcf0c..000000000 --- a/package/mac80211/patches/564-tpt_trigger_idle_fix.patch +++ /dev/null @@ -1,29 +0,0 @@ ---- a/net/mac80211/led.c -+++ b/net/mac80211/led.c -@@ -194,7 +194,7 @@ static void tpt_trig_timer(unsigned long - off = 0; - - for (i = tpt_trig->blink_table_len - 1; i >= 0; i--) { -- if (tpt >= tpt_trig->blink_table[i].throughput) { -+ if (tpt > tpt_trig->blink_table[i].throughput) { - off = tpt_trig->blink_table[i].blink_time / 2; - on = tpt_trig->blink_table[i].blink_time - off; - break; ---- a/net/mac80211/rx.c -+++ b/net/mac80211/rx.c -@@ -1877,6 +1877,7 @@ ieee80211_rx_h_data(struct ieee80211_rx_ - msecs_to_jiffies(local->hw.conf.dynamic_ps_timeout)); - } - -+ ieee80211_tpt_led_trig_rx(local, rx->skb->len); - ieee80211_deliver_skb(rx); - - return RX_QUEUED; -@@ -2873,7 +2874,6 @@ void ieee80211_rx(struct ieee80211_hw *h - return; - } - -- ieee80211_tpt_led_trig_rx(local, skb->len); - __ieee80211_rx_handle_packet(hw, skb); - - rcu_read_unlock(); diff --git a/package/mac80211/patches/565-ath9k_cleanup_led_blink.patch b/package/mac80211/patches/565-ath9k_cleanup_led_blink.patch deleted file mode 100644 index 86aec433f..000000000 --- a/package/mac80211/patches/565-ath9k_cleanup_led_blink.patch +++ /dev/null @@ -1,278 +0,0 @@ ---- a/drivers/net/wireless/ath/ath9k/ath9k.h -+++ b/drivers/net/wireless/ath/ath9k/ath9k.h -@@ -437,26 +437,20 @@ void ath9k_btcoex_timer_pause(struct ath - - #define ATH_LED_PIN_DEF 1 - #define ATH_LED_PIN_9287 8 --#define ATH_LED_ON_DURATION_IDLE 350 /* in msecs */ --#define ATH_LED_OFF_DURATION_IDLE 250 /* in msecs */ -- --enum ath_led_type { -- ATH_LED_RADIO, -- ATH_LED_ASSOC, -- ATH_LED_TX, -- ATH_LED_RX --}; -- --struct ath_led { -- struct ath_softc *sc; -- struct led_classdev led_cdev; -- enum ath_led_type led_type; -- char name[32]; -- bool registered; --}; - -+#ifdef CONFIG_MAC80211_LEDS - void ath_init_leds(struct ath_softc *sc); - void ath_deinit_leds(struct ath_softc *sc); -+#else -+static inline void ath_init_leds(struct ath_softc *sc) -+{ -+} -+ -+static inline void ath_deinit_leds(struct ath_softc *sc) -+{ -+} -+#endif -+ - - /* Antenna diversity/combining */ - #define ATH_ANT_RX_CURRENT_SHIFT 4 -@@ -606,15 +600,11 @@ struct ath_softc { - struct ath_beacon beacon; - struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS]; - -- struct ath_led radio_led; -- struct ath_led assoc_led; -- struct ath_led tx_led; -- struct ath_led rx_led; -- struct delayed_work ath_led_blink_work; -- int led_on_duration; -- int led_off_duration; -- int led_on_cnt; -- int led_off_cnt; -+#ifdef CONFIG_MAC80211_LEDS -+ bool led_registered; -+ char led_name[32]; -+ struct led_classdev led_cdev; -+#endif - - int beacon_interval; - ---- a/drivers/net/wireless/ath/ath9k/gpio.c -+++ b/drivers/net/wireless/ath/ath9k/gpio.c -@@ -20,115 +20,34 @@ - /* LED functions */ - /********************************/ - --static void ath_led_blink_work(struct work_struct *work) --{ -- struct ath_softc *sc = container_of(work, struct ath_softc, -- ath_led_blink_work.work); -- -- if (!(sc->sc_flags & SC_OP_LED_ASSOCIATED)) -- return; -- -- if ((sc->led_on_duration == ATH_LED_ON_DURATION_IDLE) || -- (sc->led_off_duration == ATH_LED_OFF_DURATION_IDLE)) -- ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 0); -- else -- ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, -- (sc->sc_flags & SC_OP_LED_ON) ? 1 : 0); -- -- ieee80211_queue_delayed_work(sc->hw, -- &sc->ath_led_blink_work, -- (sc->sc_flags & SC_OP_LED_ON) ? -- msecs_to_jiffies(sc->led_off_duration) : -- msecs_to_jiffies(sc->led_on_duration)); -- -- sc->led_on_duration = sc->led_on_cnt ? -- max((ATH_LED_ON_DURATION_IDLE - sc->led_on_cnt), 25) : -- ATH_LED_ON_DURATION_IDLE; -- sc->led_off_duration = sc->led_off_cnt ? -- max((ATH_LED_OFF_DURATION_IDLE - sc->led_off_cnt), 10) : -- ATH_LED_OFF_DURATION_IDLE; -- sc->led_on_cnt = sc->led_off_cnt = 0; -- if (sc->sc_flags & SC_OP_LED_ON) -- sc->sc_flags &= ~SC_OP_LED_ON; -- else -- sc->sc_flags |= SC_OP_LED_ON; --} -+#ifdef CONFIG_MAC80211_LEDS -+static const struct ieee80211_tpt_blink ath9k_blink[] = { -+ { .throughput = 0 * 1024, .blink_time = 334 }, -+ { .throughput = 1 * 1024, .blink_time = 260 }, -+ { .throughput = 5 * 1024, .blink_time = 220 }, -+ { .throughput = 10 * 1024, .blink_time = 190 }, -+ { .throughput = 20 * 1024, .blink_time = 170 }, -+ { .throughput = 50 * 1024, .blink_time = 150 }, -+ { .throughput = 70 * 1024, .blink_time = 130 }, -+ { .throughput = 100 * 1024, .blink_time = 110 }, -+ { .throughput = 200 * 1024, .blink_time = 80 }, -+ { .throughput = 300 * 1024, .blink_time = 50 }, -+}; - - static void ath_led_brightness(struct led_classdev *led_cdev, - enum led_brightness brightness) - { -- struct ath_led *led = container_of(led_cdev, struct ath_led, led_cdev); -- struct ath_softc *sc = led->sc; -- -- switch (brightness) { -- case LED_OFF: -- if (led->led_type == ATH_LED_ASSOC || -- led->led_type == ATH_LED_RADIO) { -- ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, -- (led->led_type == ATH_LED_RADIO)); -- sc->sc_flags &= ~SC_OP_LED_ASSOCIATED; -- if (led->led_type == ATH_LED_RADIO) -- sc->sc_flags &= ~SC_OP_LED_ON; -- } else { -- sc->led_off_cnt++; -- } -- break; -- case LED_FULL: -- if (led->led_type == ATH_LED_ASSOC) { -- sc->sc_flags |= SC_OP_LED_ASSOCIATED; -- if (led_blink) -- ieee80211_queue_delayed_work(sc->hw, -- &sc->ath_led_blink_work, 0); -- } else if (led->led_type == ATH_LED_RADIO) { -- ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 0); -- sc->sc_flags |= SC_OP_LED_ON; -- } else { -- sc->led_on_cnt++; -- } -- break; -- default: -- break; -- } --} -- --static int ath_register_led(struct ath_softc *sc, struct ath_led *led, -- char *trigger) --{ -- int ret; -- -- led->sc = sc; -- led->led_cdev.name = led->name; -- led->led_cdev.default_trigger = trigger; -- led->led_cdev.brightness_set = ath_led_brightness; -- -- ret = led_classdev_register(wiphy_dev(sc->hw->wiphy), &led->led_cdev); -- if (ret) -- ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_FATAL, -- "Failed to register led:%s", led->name); -- else -- led->registered = 1; -- return ret; --} -- --static void ath_unregister_led(struct ath_led *led) --{ -- if (led->registered) { -- led_classdev_unregister(&led->led_cdev); -- led->registered = 0; -- } -+ struct ath_softc *sc = container_of(led_cdev, struct ath_softc, led_cdev); -+ ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, (brightness == LED_OFF)); - } - - void ath_deinit_leds(struct ath_softc *sc) - { -- if (AR_SREV_9100(sc->sc_ah)) -+ if (!sc->led_registered) - return; - -- ath_unregister_led(&sc->assoc_led); -- sc->sc_flags &= ~SC_OP_LED_ASSOCIATED; -- ath_unregister_led(&sc->tx_led); -- ath_unregister_led(&sc->rx_led); -- ath_unregister_led(&sc->radio_led); -- ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 1); -+ ath_led_brightness(&sc->led_cdev, LED_OFF); -+ led_classdev_unregister(&sc->led_cdev); - } - - void ath_init_leds(struct ath_softc *sc) -@@ -152,48 +71,28 @@ void ath_init_leds(struct ath_softc *sc) - /* LED off, active low */ - ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 1); - -- if (led_blink) -- INIT_DELAYED_WORK(&sc->ath_led_blink_work, ath_led_blink_work); -+ /* -+ * create the tpt trigger even if led_blink is disabled, so that -+ * user space can still make use of it -+ */ -+ trigger = ieee80211_create_tpt_led_trigger(sc->hw, HZ, ath9k_blink, -+ ARRAY_SIZE(ath9k_blink)); -+ if (!led_blink) -+ trigger = ieee80211_get_radio_led_name(sc->hw); -+ -+ snprintf(sc->led_name, sizeof(sc->led_name), -+ "ath9k-%s", wiphy_name(sc->hw->wiphy)); -+ sc->led_cdev.name = sc->led_name; -+ sc->led_cdev.default_trigger = trigger; -+ sc->led_cdev.brightness_set = ath_led_brightness; -+ -+ ret = led_classdev_register(wiphy_dev(sc->hw->wiphy), &sc->led_cdev); -+ if (ret < 0) -+ return; - -- trigger = ieee80211_get_radio_led_name(sc->hw); -- snprintf(sc->radio_led.name, sizeof(sc->radio_led.name), -- "ath9k-%s::radio", wiphy_name(sc->hw->wiphy)); -- ret = ath_register_led(sc, &sc->radio_led, trigger); -- sc->radio_led.led_type = ATH_LED_RADIO; -- if (ret) -- goto fail; -- -- trigger = ieee80211_get_assoc_led_name(sc->hw); -- snprintf(sc->assoc_led.name, sizeof(sc->assoc_led.name), -- "ath9k-%s::assoc", wiphy_name(sc->hw->wiphy)); -- ret = ath_register_led(sc, &sc->assoc_led, trigger); -- sc->assoc_led.led_type = ATH_LED_ASSOC; -- if (ret) -- goto fail; -- -- trigger = ieee80211_get_tx_led_name(sc->hw); -- snprintf(sc->tx_led.name, sizeof(sc->tx_led.name), -- "ath9k-%s::tx", wiphy_name(sc->hw->wiphy)); -- ret = ath_register_led(sc, &sc->tx_led, trigger); -- sc->tx_led.led_type = ATH_LED_TX; -- if (ret) -- goto fail; -- -- trigger = ieee80211_get_rx_led_name(sc->hw); -- snprintf(sc->rx_led.name, sizeof(sc->rx_led.name), -- "ath9k-%s::rx", wiphy_name(sc->hw->wiphy)); -- ret = ath_register_led(sc, &sc->rx_led, trigger); -- sc->rx_led.led_type = ATH_LED_RX; -- if (ret) -- goto fail; -- -- return; -- --fail: -- if (led_blink) -- cancel_delayed_work_sync(&sc->ath_led_blink_work); -- ath_deinit_leds(sc); -+ sc->led_registered = true; - } -+#endif - - /*******************/ - /* Rfkill */ ---- a/drivers/net/wireless/ath/ath9k/main.c -+++ b/drivers/net/wireless/ath/ath9k/main.c -@@ -1276,9 +1276,6 @@ static void ath9k_stop(struct ieee80211_ - - aphy->state = ATH_WIPHY_INACTIVE; - -- if (led_blink) -- cancel_delayed_work_sync(&sc->ath_led_blink_work); -- - cancel_delayed_work_sync(&sc->tx_complete_work); - cancel_work_sync(&sc->paprd_work); - cancel_work_sync(&sc->hw_check_work); -- cgit v1.2.3