return 0;
}
+static bool
+ath_chanctx_send_vif_ps_frame(struct ath_softc *sc, struct ath_vif *avp,
+ bool powersave)
+{
+ struct ieee80211_vif *vif = avp->vif;
+ struct ieee80211_sta *sta = NULL;
+ struct ieee80211_hdr_3addr *nullfunc;
+ struct ath_tx_control txctl;
+ struct sk_buff *skb;
+ int band = sc->cur_chan->chandef.chan->band;
+
+ switch (vif->type) {
+ case NL80211_IFTYPE_STATION:
+ if (!vif->bss_conf.assoc)
+ return false;
+
+ skb = ieee80211_nullfunc_get(sc->hw, vif);
+ if (!skb)
+ return false;
+
+ nullfunc = (struct ieee80211_hdr_3addr *) skb->data;
+ if (powersave)
+ nullfunc->frame_control |=
+ cpu_to_le16(IEEE80211_FCTL_PM);
+
+ skb_set_queue_mapping(skb, IEEE80211_AC_VO);
+ if (!ieee80211_tx_prepare_skb(sc->hw, vif, skb, band, &sta)) {
+ dev_kfree_skb_any(skb);
+ return false;
+ }
+ break;
+ default:
+ return false;
+ }
+
+ memset(&txctl, 0, sizeof(txctl));
+ txctl.txq = sc->tx.txq_map[IEEE80211_AC_VO];
+ txctl.sta = sta;
+ txctl.force_channel = true;
+ if (ath_tx_start(sc->hw, skb, &txctl)) {
+ ieee80211_free_txskb(sc->hw, skb);
+ return false;
+ }
+
+ return true;
+}
+
+void ath_chanctx_check_active(struct ath_softc *sc, struct ath_chanctx *ctx)
+{
+ struct ath_vif *avp;
+ bool active = false;
+
+ if (!ctx)
+ return;
+
+ list_for_each_entry(avp, &ctx->vifs, list) {
+ struct ieee80211_vif *vif = avp->vif;
+
+ switch (vif->type) {
+ case NL80211_IFTYPE_P2P_CLIENT:
+ case NL80211_IFTYPE_STATION:
+ if (vif->bss_conf.assoc)
+ active = true;
+ break;
+ default:
+ active = true;
+ break;
+ }
+ }
+ ctx->active = active;
+}
+
+static bool
+ath_chanctx_send_ps_frame(struct ath_softc *sc, bool powersave)
+{
+ struct ath_vif *avp;
+ bool sent = false;
+
+ rcu_read_lock();
+ list_for_each_entry(avp, &sc->cur_chan->vifs, list) {
+ if (ath_chanctx_send_vif_ps_frame(sc, avp, powersave))
+ sent = true;
+ }
+ rcu_read_unlock();
+
+ return sent;
+}
+
void ath_chanctx_work(struct work_struct *work)
{
struct ath_softc *sc = container_of(work, struct ath_softc,
chanctx_work);
+ bool send_ps = false;
mutex_lock(&sc->mutex);
spin_lock_bh(&sc->chan_lock);
__ath9k_flush(sc->hw, ~0, true);
+ if (ath_chanctx_send_ps_frame(sc, true))
+ __ath9k_flush(sc->hw, BIT(IEEE80211_AC_VO), false);
+
+ send_ps = true;
spin_lock_bh(&sc->chan_lock);
}
sc->cur_chan = sc->next_chan;
memcmp(&sc->cur_chandef, &sc->cur_chan->chandef,
sizeof(sc->cur_chandef)))
ath_set_channel(sc);
+
+ if (send_ps)
+ ath_chanctx_send_ps_frame(sc, false);
+
mutex_unlock(&sc->mutex);
}
/* XXX - will be removed once chanctx ops are added */
avp->chanctx = sc->cur_chan;
list_add_tail(&avp->list, &sc->cur_chan->vifs);
+ ath_chanctx_check_active(sc, avp->chanctx);
an->sc = sc;
an->sta = NULL;
{
struct ath_softc *sc = hw->priv;
struct ath_common *common = ath9k_hw_common(sc->sc_ah);
+ struct ath_vif *avp = (void *)vif->drv_priv;
mutex_lock(&sc->mutex);
if (ath9k_uses_beacons(vif->type))
ath9k_beacon_assign_slot(sc, vif);
+ ath_chanctx_check_active(sc, avp->chanctx);
mutex_unlock(&sc->mutex);
return 0;
ath9k_ps_restore(sc);
ath_tx_node_cleanup(sc, &avp->mcast_node);
+ ath_chanctx_check_active(sc, avp->chanctx);
mutex_unlock(&sc->mutex);
}
if (ath9k_hw_mci_is_enabled(sc->sc_ah))
ath9k_mci_update_wlan_channels(sc, true);
}
+
+ ath_chanctx_check_active(sc, avp->chanctx);
}
if (changed & BSS_CHANGED_IBSS) {