aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2015-05-26 19:38:53 -0400
committerDavid S. Miller <davem@davemloft.net>2015-05-26 19:38:53 -0400
commitfe9066ade6a42a6f0bd22333e5831194104713ce (patch)
tree0b295f1663091a1de2e6ae1cdcca74d776a193aa
parent5f59102fdcfeee937439bb4a5e5c9dbc0d6eb4b0 (diff)
parentf9dca80b98caac8b4bfb43a2edf1e9f877ccf322 (diff)
Merge tag 'mac80211-for-davem-2015-05-26' of git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211
Johannes Berg says: ==================== We have three more fixes: * AP_VLAN tailroom calculation fix, the bug leads to warnings along with dropped packets * NAPI context issue, calling napi_gro_receive() from a timer (obviously) can lead to crashes * remain-on-channel combining leads to dropped requests and not being able to finish certain operations, so remove it ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/mac80211/cfg.c59
-rw-r--r--net/mac80211/ieee80211_i.h9
-rw-r--r--net/mac80211/iface.c6
-rw-r--r--net/mac80211/key.c82
-rw-r--r--net/mac80211/key.h1
-rw-r--r--net/mac80211/rx.c5
-rw-r--r--net/mac80211/util.c3
7 files changed, 100 insertions, 65 deletions
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 265e42721a66..ff347a0eebd4 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -2495,51 +2495,22 @@ static bool ieee80211_coalesce_started_roc(struct ieee80211_local *local,
2495 struct ieee80211_roc_work *new_roc, 2495 struct ieee80211_roc_work *new_roc,
2496 struct ieee80211_roc_work *cur_roc) 2496 struct ieee80211_roc_work *cur_roc)
2497{ 2497{
2498 unsigned long j = jiffies; 2498 unsigned long now = jiffies;
2499 unsigned long cur_roc_end = cur_roc->hw_start_time + 2499 unsigned long remaining = cur_roc->hw_start_time +
2500 msecs_to_jiffies(cur_roc->duration); 2500 msecs_to_jiffies(cur_roc->duration) -
2501 struct ieee80211_roc_work *next_roc; 2501 now;
2502 int new_dur;
2503 2502
2504 if (WARN_ON(!cur_roc->started || !cur_roc->hw_begun)) 2503 if (WARN_ON(!cur_roc->started || !cur_roc->hw_begun))
2505 return false; 2504 return false;
2506 2505
2507 if (time_after(j + IEEE80211_ROC_MIN_LEFT, cur_roc_end)) 2506 /* if it doesn't fit entirely, schedule a new one */
2507 if (new_roc->duration > jiffies_to_msecs(remaining))
2508 return false; 2508 return false;
2509 2509
2510 ieee80211_handle_roc_started(new_roc); 2510 ieee80211_handle_roc_started(new_roc);
2511 2511
2512 new_dur = new_roc->duration - jiffies_to_msecs(cur_roc_end - j); 2512 /* add to dependents so we send the expired event properly */
2513 2513 list_add_tail(&new_roc->list, &cur_roc->dependents);
2514 /* cur_roc is long enough - add new_roc to the dependents list. */
2515 if (new_dur <= 0) {
2516 list_add_tail(&new_roc->list, &cur_roc->dependents);
2517 return true;
2518 }
2519
2520 new_roc->duration = new_dur;
2521
2522 /*
2523 * if cur_roc was already coalesced before, we might
2524 * want to extend the next roc instead of adding
2525 * a new one.
2526 */
2527 next_roc = list_entry(cur_roc->list.next,
2528 struct ieee80211_roc_work, list);
2529 if (&next_roc->list != &local->roc_list &&
2530 next_roc->chan == new_roc->chan &&
2531 next_roc->sdata == new_roc->sdata &&
2532 !WARN_ON(next_roc->started)) {
2533 list_add_tail(&new_roc->list, &next_roc->dependents);
2534 next_roc->duration = max(next_roc->duration,
2535 new_roc->duration);
2536 next_roc->type = max(next_roc->type, new_roc->type);
2537 return true;
2538 }
2539
2540 /* add right after cur_roc */
2541 list_add(&new_roc->list, &cur_roc->list);
2542
2543 return true; 2514 return true;
2544} 2515}
2545 2516
@@ -2652,17 +2623,9 @@ static int ieee80211_start_roc_work(struct ieee80211_local *local,
2652 * In the offloaded ROC case, if it hasn't begun, add 2623 * In the offloaded ROC case, if it hasn't begun, add
2653 * this new one to the dependent list to be handled 2624 * this new one to the dependent list to be handled
2654 * when the master one begins. If it has begun, 2625 * when the master one begins. If it has begun,
2655 * check that there's still a minimum time left and 2626 * check if it fits entirely within the existing one,
2656 * if so, start this one, transmitting the frame, but 2627 * in which case it will just be dependent as well.
2657 * add it to the list directly after this one with 2628 * Otherwise, schedule it by itself.
2658 * a reduced time so we'll ask the driver to execute
2659 * it right after finishing the previous one, in the
2660 * hope that it'll also be executed right afterwards,
2661 * effectively extending the old one.
2662 * If there's no minimum time left, just add it to the
2663 * normal list.
2664 * TODO: the ROC type is ignored here, assuming that it
2665 * is better to immediately use the current ROC.
2666 */ 2629 */
2667 if (!tmp->hw_begun) { 2630 if (!tmp->hw_begun) {
2668 list_add_tail(&roc->list, &tmp->dependents); 2631 list_add_tail(&roc->list, &tmp->dependents);
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index ab46ab4a7249..c0a9187bc3a9 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -205,6 +205,8 @@ enum ieee80211_packet_rx_flags {
205 * @IEEE80211_RX_CMNTR: received on cooked monitor already 205 * @IEEE80211_RX_CMNTR: received on cooked monitor already
206 * @IEEE80211_RX_BEACON_REPORTED: This frame was already reported 206 * @IEEE80211_RX_BEACON_REPORTED: This frame was already reported
207 * to cfg80211_report_obss_beacon(). 207 * to cfg80211_report_obss_beacon().
208 * @IEEE80211_RX_REORDER_TIMER: this frame is released by the
209 * reorder buffer timeout timer, not the normal RX path
208 * 210 *
209 * These flags are used across handling multiple interfaces 211 * These flags are used across handling multiple interfaces
210 * for a single frame. 212 * for a single frame.
@@ -212,6 +214,7 @@ enum ieee80211_packet_rx_flags {
212enum ieee80211_rx_flags { 214enum ieee80211_rx_flags {
213 IEEE80211_RX_CMNTR = BIT(0), 215 IEEE80211_RX_CMNTR = BIT(0),
214 IEEE80211_RX_BEACON_REPORTED = BIT(1), 216 IEEE80211_RX_BEACON_REPORTED = BIT(1),
217 IEEE80211_RX_REORDER_TIMER = BIT(2),
215}; 218};
216 219
217struct ieee80211_rx_data { 220struct ieee80211_rx_data {
@@ -325,12 +328,6 @@ struct mesh_preq_queue {
325 u8 flags; 328 u8 flags;
326}; 329};
327 330
328#if HZ/100 == 0
329#define IEEE80211_ROC_MIN_LEFT 1
330#else
331#define IEEE80211_ROC_MIN_LEFT (HZ/100)
332#endif
333
334struct ieee80211_roc_work { 331struct ieee80211_roc_work {
335 struct list_head list; 332 struct list_head list;
336 struct list_head dependents; 333 struct list_head dependents;
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index bab5c63c0bad..84cef600c573 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -522,6 +522,12 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
522 memcpy(sdata->vif.hw_queue, master->vif.hw_queue, 522 memcpy(sdata->vif.hw_queue, master->vif.hw_queue,
523 sizeof(sdata->vif.hw_queue)); 523 sizeof(sdata->vif.hw_queue));
524 sdata->vif.bss_conf.chandef = master->vif.bss_conf.chandef; 524 sdata->vif.bss_conf.chandef = master->vif.bss_conf.chandef;
525
526 mutex_lock(&local->key_mtx);
527 sdata->crypto_tx_tailroom_needed_cnt +=
528 master->crypto_tx_tailroom_needed_cnt;
529 mutex_unlock(&local->key_mtx);
530
525 break; 531 break;
526 } 532 }
527 case NL80211_IFTYPE_AP: 533 case NL80211_IFTYPE_AP:
diff --git a/net/mac80211/key.c b/net/mac80211/key.c
index 2291cd730091..a907f2d5c12d 100644
--- a/net/mac80211/key.c
+++ b/net/mac80211/key.c
@@ -58,6 +58,22 @@ static void assert_key_lock(struct ieee80211_local *local)
58 lockdep_assert_held(&local->key_mtx); 58 lockdep_assert_held(&local->key_mtx);
59} 59}
60 60
61static void
62update_vlan_tailroom_need_count(struct ieee80211_sub_if_data *sdata, int delta)
63{
64 struct ieee80211_sub_if_data *vlan;
65
66 if (sdata->vif.type != NL80211_IFTYPE_AP)
67 return;
68
69 mutex_lock(&sdata->local->mtx);
70
71 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
72 vlan->crypto_tx_tailroom_needed_cnt += delta;
73
74 mutex_unlock(&sdata->local->mtx);
75}
76
61static void increment_tailroom_need_count(struct ieee80211_sub_if_data *sdata) 77static void increment_tailroom_need_count(struct ieee80211_sub_if_data *sdata)
62{ 78{
63 /* 79 /*
@@ -79,6 +95,8 @@ static void increment_tailroom_need_count(struct ieee80211_sub_if_data *sdata)
79 * http://mid.gmane.org/1308590980.4322.19.camel@jlt3.sipsolutions.net 95 * http://mid.gmane.org/1308590980.4322.19.camel@jlt3.sipsolutions.net
80 */ 96 */
81 97
98 update_vlan_tailroom_need_count(sdata, 1);
99
82 if (!sdata->crypto_tx_tailroom_needed_cnt++) { 100 if (!sdata->crypto_tx_tailroom_needed_cnt++) {
83 /* 101 /*
84 * Flush all XMIT packets currently using HW encryption or no 102 * Flush all XMIT packets currently using HW encryption or no
@@ -88,6 +106,15 @@ static void increment_tailroom_need_count(struct ieee80211_sub_if_data *sdata)
88 } 106 }
89} 107}
90 108
109static void decrease_tailroom_need_count(struct ieee80211_sub_if_data *sdata,
110 int delta)
111{
112 WARN_ON_ONCE(sdata->crypto_tx_tailroom_needed_cnt < delta);
113
114 update_vlan_tailroom_need_count(sdata, -delta);
115 sdata->crypto_tx_tailroom_needed_cnt -= delta;
116}
117
91static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key) 118static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key)
92{ 119{
93 struct ieee80211_sub_if_data *sdata; 120 struct ieee80211_sub_if_data *sdata;
@@ -144,7 +171,7 @@ static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key)
144 171
145 if (!((key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) || 172 if (!((key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) ||
146 (key->conf.flags & IEEE80211_KEY_FLAG_RESERVE_TAILROOM))) 173 (key->conf.flags & IEEE80211_KEY_FLAG_RESERVE_TAILROOM)))
147 sdata->crypto_tx_tailroom_needed_cnt--; 174 decrease_tailroom_need_count(sdata, 1);
148 175
149 WARN_ON((key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE) && 176 WARN_ON((key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE) &&
150 (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)); 177 (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV));
@@ -541,7 +568,7 @@ static void __ieee80211_key_destroy(struct ieee80211_key *key,
541 schedule_delayed_work(&sdata->dec_tailroom_needed_wk, 568 schedule_delayed_work(&sdata->dec_tailroom_needed_wk,
542 HZ/2); 569 HZ/2);
543 } else { 570 } else {
544 sdata->crypto_tx_tailroom_needed_cnt--; 571 decrease_tailroom_need_count(sdata, 1);
545 } 572 }
546 } 573 }
547 574
@@ -631,6 +658,7 @@ void ieee80211_key_free(struct ieee80211_key *key, bool delay_tailroom)
631void ieee80211_enable_keys(struct ieee80211_sub_if_data *sdata) 658void ieee80211_enable_keys(struct ieee80211_sub_if_data *sdata)
632{ 659{
633 struct ieee80211_key *key; 660 struct ieee80211_key *key;
661 struct ieee80211_sub_if_data *vlan;
634 662
635 ASSERT_RTNL(); 663 ASSERT_RTNL();
636 664
@@ -639,7 +667,14 @@ void ieee80211_enable_keys(struct ieee80211_sub_if_data *sdata)
639 667
640 mutex_lock(&sdata->local->key_mtx); 668 mutex_lock(&sdata->local->key_mtx);
641 669
642 sdata->crypto_tx_tailroom_needed_cnt = 0; 670 WARN_ON_ONCE(sdata->crypto_tx_tailroom_needed_cnt ||
671 sdata->crypto_tx_tailroom_pending_dec);
672
673 if (sdata->vif.type == NL80211_IFTYPE_AP) {
674 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
675 WARN_ON_ONCE(vlan->crypto_tx_tailroom_needed_cnt ||
676 vlan->crypto_tx_tailroom_pending_dec);
677 }
643 678
644 list_for_each_entry(key, &sdata->key_list, list) { 679 list_for_each_entry(key, &sdata->key_list, list) {
645 increment_tailroom_need_count(sdata); 680 increment_tailroom_need_count(sdata);
@@ -649,6 +684,22 @@ void ieee80211_enable_keys(struct ieee80211_sub_if_data *sdata)
649 mutex_unlock(&sdata->local->key_mtx); 684 mutex_unlock(&sdata->local->key_mtx);
650} 685}
651 686
687void ieee80211_reset_crypto_tx_tailroom(struct ieee80211_sub_if_data *sdata)
688{
689 struct ieee80211_sub_if_data *vlan;
690
691 mutex_lock(&sdata->local->key_mtx);
692
693 sdata->crypto_tx_tailroom_needed_cnt = 0;
694
695 if (sdata->vif.type == NL80211_IFTYPE_AP) {
696 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
697 vlan->crypto_tx_tailroom_needed_cnt = 0;
698 }
699
700 mutex_unlock(&sdata->local->key_mtx);
701}
702
652void ieee80211_iter_keys(struct ieee80211_hw *hw, 703void ieee80211_iter_keys(struct ieee80211_hw *hw,
653 struct ieee80211_vif *vif, 704 struct ieee80211_vif *vif,
654 void (*iter)(struct ieee80211_hw *hw, 705 void (*iter)(struct ieee80211_hw *hw,
@@ -688,8 +739,8 @@ static void ieee80211_free_keys_iface(struct ieee80211_sub_if_data *sdata,
688{ 739{
689 struct ieee80211_key *key, *tmp; 740 struct ieee80211_key *key, *tmp;
690 741
691 sdata->crypto_tx_tailroom_needed_cnt -= 742 decrease_tailroom_need_count(sdata,
692 sdata->crypto_tx_tailroom_pending_dec; 743 sdata->crypto_tx_tailroom_pending_dec);
693 sdata->crypto_tx_tailroom_pending_dec = 0; 744 sdata->crypto_tx_tailroom_pending_dec = 0;
694 745
695 ieee80211_debugfs_key_remove_mgmt_default(sdata); 746 ieee80211_debugfs_key_remove_mgmt_default(sdata);
@@ -709,6 +760,7 @@ void ieee80211_free_keys(struct ieee80211_sub_if_data *sdata,
709{ 760{
710 struct ieee80211_local *local = sdata->local; 761 struct ieee80211_local *local = sdata->local;
711 struct ieee80211_sub_if_data *vlan; 762 struct ieee80211_sub_if_data *vlan;
763 struct ieee80211_sub_if_data *master;
712 struct ieee80211_key *key, *tmp; 764 struct ieee80211_key *key, *tmp;
713 LIST_HEAD(keys); 765 LIST_HEAD(keys);
714 766
@@ -728,8 +780,20 @@ void ieee80211_free_keys(struct ieee80211_sub_if_data *sdata,
728 list_for_each_entry_safe(key, tmp, &keys, list) 780 list_for_each_entry_safe(key, tmp, &keys, list)
729 __ieee80211_key_destroy(key, false); 781 __ieee80211_key_destroy(key, false);
730 782
731 WARN_ON_ONCE(sdata->crypto_tx_tailroom_needed_cnt || 783 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) {
732 sdata->crypto_tx_tailroom_pending_dec); 784 if (sdata->bss) {
785 master = container_of(sdata->bss,
786 struct ieee80211_sub_if_data,
787 u.ap);
788
789 WARN_ON_ONCE(sdata->crypto_tx_tailroom_needed_cnt !=
790 master->crypto_tx_tailroom_needed_cnt);
791 }
792 } else {
793 WARN_ON_ONCE(sdata->crypto_tx_tailroom_needed_cnt ||
794 sdata->crypto_tx_tailroom_pending_dec);
795 }
796
733 if (sdata->vif.type == NL80211_IFTYPE_AP) { 797 if (sdata->vif.type == NL80211_IFTYPE_AP) {
734 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) 798 list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
735 WARN_ON_ONCE(vlan->crypto_tx_tailroom_needed_cnt || 799 WARN_ON_ONCE(vlan->crypto_tx_tailroom_needed_cnt ||
@@ -793,8 +857,8 @@ void ieee80211_delayed_tailroom_dec(struct work_struct *wk)
793 */ 857 */
794 858
795 mutex_lock(&sdata->local->key_mtx); 859 mutex_lock(&sdata->local->key_mtx);
796 sdata->crypto_tx_tailroom_needed_cnt -= 860 decrease_tailroom_need_count(sdata,
797 sdata->crypto_tx_tailroom_pending_dec; 861 sdata->crypto_tx_tailroom_pending_dec);
798 sdata->crypto_tx_tailroom_pending_dec = 0; 862 sdata->crypto_tx_tailroom_pending_dec = 0;
799 mutex_unlock(&sdata->local->key_mtx); 863 mutex_unlock(&sdata->local->key_mtx);
800} 864}
diff --git a/net/mac80211/key.h b/net/mac80211/key.h
index c5a31835be0e..96557dd1e77d 100644
--- a/net/mac80211/key.h
+++ b/net/mac80211/key.h
@@ -161,6 +161,7 @@ void ieee80211_free_keys(struct ieee80211_sub_if_data *sdata,
161void ieee80211_free_sta_keys(struct ieee80211_local *local, 161void ieee80211_free_sta_keys(struct ieee80211_local *local,
162 struct sta_info *sta); 162 struct sta_info *sta);
163void ieee80211_enable_keys(struct ieee80211_sub_if_data *sdata); 163void ieee80211_enable_keys(struct ieee80211_sub_if_data *sdata);
164void ieee80211_reset_crypto_tx_tailroom(struct ieee80211_sub_if_data *sdata);
164 165
165#define key_mtx_dereference(local, ref) \ 166#define key_mtx_dereference(local, ref) \
166 rcu_dereference_protected(ref, lockdep_is_held(&((local)->key_mtx))) 167 rcu_dereference_protected(ref, lockdep_is_held(&((local)->key_mtx)))
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 260eed45b6d2..5793f75c5ffd 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -2121,7 +2121,8 @@ ieee80211_deliver_skb(struct ieee80211_rx_data *rx)
2121 /* deliver to local stack */ 2121 /* deliver to local stack */
2122 skb->protocol = eth_type_trans(skb, dev); 2122 skb->protocol = eth_type_trans(skb, dev);
2123 memset(skb->cb, 0, sizeof(skb->cb)); 2123 memset(skb->cb, 0, sizeof(skb->cb));
2124 if (rx->local->napi) 2124 if (!(rx->flags & IEEE80211_RX_REORDER_TIMER) &&
2125 rx->local->napi)
2125 napi_gro_receive(rx->local->napi, skb); 2126 napi_gro_receive(rx->local->napi, skb);
2126 else 2127 else
2127 netif_receive_skb(skb); 2128 netif_receive_skb(skb);
@@ -3231,7 +3232,7 @@ void ieee80211_release_reorder_timeout(struct sta_info *sta, int tid)
3231 /* This is OK -- must be QoS data frame */ 3232 /* This is OK -- must be QoS data frame */
3232 .security_idx = tid, 3233 .security_idx = tid,
3233 .seqno_idx = tid, 3234 .seqno_idx = tid,
3234 .flags = 0, 3235 .flags = IEEE80211_RX_REORDER_TIMER,
3235 }; 3236 };
3236 struct tid_ampdu_rx *tid_agg_rx; 3237 struct tid_ampdu_rx *tid_agg_rx;
3237 3238
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 79412f16b61d..b864ebc6ab8f 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -2023,6 +2023,9 @@ int ieee80211_reconfig(struct ieee80211_local *local)
2023 2023
2024 /* add back keys */ 2024 /* add back keys */
2025 list_for_each_entry(sdata, &local->interfaces, list) 2025 list_for_each_entry(sdata, &local->interfaces, list)
2026 ieee80211_reset_crypto_tx_tailroom(sdata);
2027
2028 list_for_each_entry(sdata, &local->interfaces, list)
2026 if (ieee80211_sdata_running(sdata)) 2029 if (ieee80211_sdata_running(sdata))
2027 ieee80211_enable_keys(sdata); 2030 ieee80211_enable_keys(sdata);
2028 2031