ath9k: merge a fix for queue start/stop handling (fixes #18164, #18130)
[openwrt/staging/wigyori.git] / package / kernel / mac80211 / patches / 336-ath9k-Enable-HW-queue-control-only-for-MCC.patch
1 From: Sujith Manoharan <c_manoha@qca.qualcomm.com>
2 Date: Tue, 21 Oct 2014 19:23:02 +0530
3 Subject: [PATCH] ath9k: Enable HW queue control only for MCC
4
5 Enabling HW queue control for normal (non-mcc) mode
6 causes problems with queue management, resulting
7 in traffic stall. Since it is mainly required for
8 fairness in MCC mode, disable it for the general case.
9
10 Bug: https://dev.openwrt.org/ticket/18164
11
12 Cc: Felix Fietkau <nbd@openwrt.org>
13 Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
14 ---
15
16 --- a/drivers/net/wireless/ath/ath9k/init.c
17 +++ b/drivers/net/wireless/ath/ath9k/init.c
18 @@ -741,6 +741,32 @@ static const struct ieee80211_iface_comb
19 #endif
20 };
21
22 +#ifdef CPTCFG_ATH9K_CHANNEL_CONTEXT
23 +static void ath9k_set_mcc_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
24 +{
25 + struct ath_hw *ah = sc->sc_ah;
26 + struct ath_common *common = ath9k_hw_common(ah);
27 +
28 + if (!ath9k_is_chanctx_enabled())
29 + return;
30 +
31 + hw->flags |= IEEE80211_HW_QUEUE_CONTROL;
32 + hw->queues = ATH9K_NUM_TX_QUEUES;
33 + hw->offchannel_tx_hw_queue = hw->queues - 1;
34 + hw->wiphy->interface_modes &= ~ BIT(NL80211_IFTYPE_WDS);
35 + hw->wiphy->iface_combinations = if_comb_multi;
36 + hw->wiphy->n_iface_combinations = ARRAY_SIZE(if_comb_multi);
37 + hw->wiphy->max_scan_ssids = 255;
38 + hw->wiphy->max_scan_ie_len = IEEE80211_MAX_DATA_LEN;
39 + hw->wiphy->max_remain_on_channel_duration = 10000;
40 + hw->chanctx_data_size = sizeof(void *);
41 + hw->extra_beacon_tailroom =
42 + sizeof(struct ieee80211_p2p_noa_attr) + 9;
43 +
44 + ath_dbg(common, CHAN_CTX, "Use channel contexts\n");
45 +}
46 +#endif /* CPTCFG_ATH9K_CHANNEL_CONTEXT */
47 +
48 static void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
49 {
50 struct ath_hw *ah = sc->sc_ah;
51 @@ -753,7 +779,6 @@ static void ath9k_set_hw_capab(struct at
52 IEEE80211_HW_SPECTRUM_MGMT |
53 IEEE80211_HW_REPORTS_TX_ACK_STATUS |
54 IEEE80211_HW_SUPPORTS_RC_TABLE |
55 - IEEE80211_HW_QUEUE_CONTROL |
56 IEEE80211_HW_SUPPORTS_HT_CCK_RATES;
57
58 if (ath9k_ps_enable)
59 @@ -788,24 +813,6 @@ static void ath9k_set_hw_capab(struct at
60 hw->wiphy->n_iface_combinations = ARRAY_SIZE(if_comb);
61 }
62
63 -#ifdef CPTCFG_ATH9K_CHANNEL_CONTEXT
64 -
65 - if (ath9k_is_chanctx_enabled()) {
66 - hw->wiphy->interface_modes &= ~ BIT(NL80211_IFTYPE_WDS);
67 - hw->wiphy->iface_combinations = if_comb_multi;
68 - hw->wiphy->n_iface_combinations = ARRAY_SIZE(if_comb_multi);
69 - hw->wiphy->max_scan_ssids = 255;
70 - hw->wiphy->max_scan_ie_len = IEEE80211_MAX_DATA_LEN;
71 - hw->wiphy->max_remain_on_channel_duration = 10000;
72 - hw->chanctx_data_size = sizeof(void *);
73 - hw->extra_beacon_tailroom =
74 - sizeof(struct ieee80211_p2p_noa_attr) + 9;
75 -
76 - ath_dbg(common, CHAN_CTX, "Use channel contexts\n");
77 - }
78 -
79 -#endif /* CPTCFG_ATH9K_CHANNEL_CONTEXT */
80 -
81 hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
82
83 hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
84 @@ -815,12 +822,7 @@ static void ath9k_set_hw_capab(struct at
85 hw->wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH;
86 hw->wiphy->flags |= WIPHY_FLAG_AP_UAPSD;
87
88 - /* allow 4 queues per channel context +
89 - * 1 cab queue + 1 offchannel tx queue
90 - */
91 - hw->queues = ATH9K_NUM_TX_QUEUES;
92 - /* last queue for offchannel */
93 - hw->offchannel_tx_hw_queue = hw->queues - 1;
94 + hw->queues = 4;
95 hw->max_rates = 4;
96 hw->max_listen_interval = 10;
97 hw->max_rate_tries = 10;
98 @@ -844,6 +846,9 @@ static void ath9k_set_hw_capab(struct at
99 hw->wiphy->bands[IEEE80211_BAND_5GHZ] =
100 &common->sbands[IEEE80211_BAND_5GHZ];
101
102 +#ifdef CPTCFG_ATH9K_CHANNEL_CONTEXT
103 + ath9k_set_mcc_capab(sc, hw);
104 +#endif
105 ath9k_init_wow(hw);
106 ath9k_cmn_reload_chainmask(ah);
107
108 --- a/drivers/net/wireless/ath/ath9k/main.c
109 +++ b/drivers/net/wireless/ath/ath9k/main.c
110 @@ -1181,6 +1181,9 @@ static void ath9k_assign_hw_queues(struc
111 {
112 int i;
113
114 + if (!ath9k_is_chanctx_enabled())
115 + return;
116 +
117 for (i = 0; i < IEEE80211_NUM_ACS; i++)
118 vif->hw_queue[i] = i;
119
120 --- a/drivers/net/wireless/ath/ath9k/xmit.c
121 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
122 @@ -169,7 +169,10 @@ static void ath_txq_skb_done(struct ath_
123
124 if (txq->stopped &&
125 txq->pending_frames < sc->tx.txq_max_pending[q]) {
126 - ieee80211_wake_queue(sc->hw, info->hw_queue);
127 + if (ath9k_is_chanctx_enabled())
128 + ieee80211_wake_queue(sc->hw, info->hw_queue);
129 + else
130 + ieee80211_wake_queue(sc->hw, q);
131 txq->stopped = false;
132 }
133 }
134 @@ -2247,7 +2250,10 @@ int ath_tx_start(struct ieee80211_hw *hw
135 fi->txq = q;
136 if (++txq->pending_frames > sc->tx.txq_max_pending[q] &&
137 !txq->stopped) {
138 - ieee80211_stop_queue(sc->hw, info->hw_queue);
139 + if (ath9k_is_chanctx_enabled())
140 + ieee80211_stop_queue(sc->hw, info->hw_queue);
141 + else
142 + ieee80211_stop_queue(sc->hw, q);
143 txq->stopped = true;
144 }
145 }