ath9k: implement tx_last_beacon() to allow mac80211 to respond to probe requests...
[librecmc/librecmc.git] / package / mac80211 / patches / 572-ath9k_tx_last_beacon.patch
1 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
2 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
3 @@ -397,6 +397,9 @@ struct ath_beacon {
4         struct ath_descdma bdma;
5         struct ath_txq *cabq;
6         struct list_head bbuf;
7 +
8 +       bool tx_processed;
9 +       bool tx_last;
10  };
11  
12  void ath_beacon_tasklet(unsigned long data);
13 --- a/drivers/net/wireless/ath/ath9k/beacon.c
14 +++ b/drivers/net/wireless/ath/ath9k/beacon.c
15 @@ -18,6 +18,12 @@
16  
17  #define FUDGE 2
18  
19 +static void ath9k_reset_beacon_status(struct ath_softc *sc)
20 +{
21 +       sc->beacon.tx_processed = false;
22 +       sc->beacon.tx_last = false;
23 +}
24 +
25  /*
26   *  This function will modify certain transmit queue properties depending on
27   *  the operating mode of the station (AP or AdHoc).  Parameters are AIFS
28 @@ -72,6 +78,8 @@ static void ath_beacon_setup(struct ath_
29         struct ieee80211_supported_band *sband;
30         u8 rate = 0;
31  
32 +       ath9k_reset_beacon_status(sc);
33 +
34         ds = bf->bf_desc;
35         flags = ATH9K_TXDESC_NOACK;
36  
37 @@ -134,6 +142,8 @@ static struct ath_buf *ath_beacon_genera
38         struct ieee80211_tx_info *info;
39         int cabq_depth;
40  
41 +       ath9k_reset_beacon_status(sc);
42 +
43         avp = (void *)vif->drv_priv;
44         cabq = sc->beacon.cabq;
45  
46 @@ -644,6 +654,8 @@ static void ath_beacon_config_adhoc(stru
47         struct ath_common *common = ath9k_hw_common(ah);
48         u32 tsf, delta, intval, nexttbtt;
49  
50 +       ath9k_reset_beacon_status(sc);
51 +
52         tsf = ath9k_hw_gettsf32(ah) + TU_TO_USEC(FUDGE);
53         intval = TU_TO_USEC(conf->beacon_interval & ATH9K_BEACON_PERIOD);
54  
55 --- a/drivers/net/wireless/ath/ath9k/main.c
56 +++ b/drivers/net/wireless/ath/ath9k/main.c
57 @@ -2314,6 +2314,43 @@ static bool ath9k_tx_frames_pending(stru
58         return false;
59  }
60  
61 +int ath9k_tx_last_beacon(struct ieee80211_hw *hw)
62 +{
63 +       struct ath_softc *sc = hw->priv;
64 +       struct ath_hw *ah = sc->sc_ah;
65 +       struct ieee80211_vif *vif;
66 +       struct ath_vif *avp;
67 +       struct ath_buf *bf;
68 +       struct ath_tx_status ts;
69 +       int status;
70 +
71 +       if (ah->opmode != NL80211_IFTYPE_ADHOC)
72 +               return 0;
73 +
74 +       vif = sc->beacon.bslot[0];
75 +       if (!vif)
76 +               return 0;
77 +
78 +       avp = (void *)vif->drv_priv;
79 +       if (!avp->is_bslot_active)
80 +               return 0;
81 +
82 +       if (!sc->beacon.tx_processed) {
83 +               bf = avp->av_bcbuf;
84 +               if (!bf || !bf->bf_mpdu)
85 +                       return 0;
86 +
87 +               status = ath9k_hw_txprocdesc(ah, bf->bf_desc, &ts);
88 +               if (status == -EINPROGRESS)
89 +                       return 0;
90 +
91 +               sc->beacon.tx_processed = true;
92 +               sc->beacon.tx_last = !(ts.ts_status & ATH9K_TXERR_FILT);
93 +       }
94 +
95 +       return sc->beacon.tx_last;
96 +}
97 +
98  struct ieee80211_ops ath9k_ops = {
99         .tx                 = ath9k_tx,
100         .start              = ath9k_start,
101 @@ -2338,4 +2375,5 @@ struct ieee80211_ops ath9k_ops = {
102         .set_coverage_class = ath9k_set_coverage_class,
103         .flush              = ath9k_flush,
104         .tx_frames_pending  = ath9k_tx_frames_pending,
105 +       .tx_last_beacon = ath9k_tx_last_beacon,
106  };