mac80211: update to version based on 4.19-rc4
[openwrt/staging/wigyori.git] / package / kernel / mac80211 / patches / 395-ath9k-add-back-support-for-using-active-monitor-inte.patch
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Sat, 22 Sep 2018 15:20:50 +0200
3 Subject: [PATCH] ath9k: add back support for using active monitor interfaces
4 for tx99
5
6 Various documented examples on how to set up tx99 with ath9k rely
7 on setting up a regular monitor interface for setting the channel.
8 My previous patch "ath9k: fix tx99 with monitor mode interface" made
9 it possible to set it up this way again. However, it was removing support
10 for using an active monitor interface, which is required for controlling
11 the bitrate as well, since the bitrate is not passed down with a regular
12 monitor interface.
13
14 This patch partially reverts the previous one, but keeps support for using
15 a regular monitor interface to keep documented steps working in cases
16 where the bitrate does not matter
17
18 Fixes: d9c52fd17cb48 ("ath9k: fix tx99 with monitor mode interface")
19 Signed-off-by: Felix Fietkau <nbd@nbd.name>
20 ---
21
22 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
23 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
24 @@ -1074,6 +1074,7 @@ struct ath_softc {
25
26 struct ath_spec_scan_priv spec_priv;
27
28 + struct ieee80211_vif *tx99_vif;
29 struct sk_buff *tx99_skb;
30 bool tx99_state;
31 s16 tx99_power;
32 --- a/drivers/net/wireless/ath/ath9k/main.c
33 +++ b/drivers/net/wireless/ath/ath9k/main.c
34 @@ -1251,8 +1251,13 @@ static int ath9k_add_interface(struct ie
35 struct ath_vif *avp = (void *)vif->drv_priv;
36 struct ath_node *an = &avp->mcast_node;
37
38 - if (IS_ENABLED(CPTCFG_ATH9K_TX99))
39 - return -EOPNOTSUPP;
40 + if (IS_ENABLED(CPTCFG_ATH9K_TX99)) {
41 + if (sc->cur_chan->nvifs >= 1) {
42 + mutex_unlock(&sc->mutex);
43 + return -EOPNOTSUPP;
44 + }
45 + sc->tx99_vif = vif;
46 + }
47
48 mutex_lock(&sc->mutex);
49
50 @@ -1337,6 +1342,7 @@ static void ath9k_remove_interface(struc
51 ath9k_p2p_remove_vif(sc, vif);
52
53 sc->cur_chan->nvifs--;
54 + sc->tx99_vif = NULL;
55 if (!ath9k_is_chanctx_enabled())
56 list_del(&avp->list);
57
58 --- a/drivers/net/wireless/ath/ath9k/tx99.c
59 +++ b/drivers/net/wireless/ath/ath9k/tx99.c
60 @@ -54,6 +54,7 @@ static struct sk_buff *ath9k_build_tx99_
61 struct ieee80211_hdr *hdr;
62 struct ieee80211_tx_info *tx_info;
63 struct sk_buff *skb;
64 + struct ath_vif *avp;
65
66 skb = alloc_skb(len, GFP_KERNEL);
67 if (!skb)
68 @@ -71,11 +72,17 @@ static struct sk_buff *ath9k_build_tx99_
69 memcpy(hdr->addr2, hw->wiphy->perm_addr, ETH_ALEN);
70 memcpy(hdr->addr3, hw->wiphy->perm_addr, ETH_ALEN);
71
72 + if (sc->tx99_vif) {
73 + avp = (struct ath_vif *) sc->tx99_vif->drv_priv;
74 + hdr->seq_ctrl |= cpu_to_le16(avp->seq_no);
75 + }
76 +
77 tx_info = IEEE80211_SKB_CB(skb);
78 memset(tx_info, 0, sizeof(*tx_info));
79 rate = &tx_info->control.rates[0];
80 tx_info->band = sc->cur_chan->chandef.chan->band;
81 tx_info->flags = IEEE80211_TX_CTL_NO_ACK;
82 + tx_info->control.vif = sc->tx99_vif;
83 rate->count = 1;
84 if (ah->curchan && IS_CHAN_HT(ah->curchan)) {
85 rate->flags |= IEEE80211_TX_RC_MCS;
86 --- a/drivers/net/wireless/ath/ath9k/xmit.c
87 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
88 @@ -2973,7 +2973,7 @@ int ath9k_tx99_send(struct ath_softc *sc
89 return -EINVAL;
90 }
91
92 - ath_set_rates(NULL, NULL, bf);
93 + ath_set_rates(sc->tx99_vif, NULL, bf);
94
95 ath9k_hw_set_desc_link(sc->sc_ah, bf->bf_desc, bf->bf_daddr);
96 ath9k_hw_tx99_start(sc->sc_ah, txctl->txq->axq_qnum);