ath9k: Disable SWBA interrupt on remove_interface
PATCH 1/3 ath9k: Disable SWBA interrupt on remove_interface
while removing beaconing mode interface, SWBA interrupt was never disabled when there are no other beaconing interfaces.
--- drivers/net/wireless/ath/ath9k/main.c | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-)
drivers/net/wireless/ath/ath9k/main.c +10 -1
@@ -1436,6 +1436,7 @@ static void ath9k_remove_interface(struct ieee80211_hw *hw,struct ath_softc *sc = aphy->sc;struct ath_common *common =ath9k_hw_common (sc->sc_ah);struct ath_vif *avp = (void *)vif->drv_priv; +bool bs_valid = false;int i;ath_print (common,ATH_DBG_CONFIG ,"Detach Interface\n" );
@@ -1464,7 +1465,15 @@ static void ath9k_remove_interface(struct ieee80211_hw *hw, "slot\n", __func__); sc->beacon.bslot[i] =NULL ; sc->beacon.bslot_aphy[i] =NULL ; - } + }else if (sc->beacon.bslot[i]) + bs_valid = true; + } +if (!bs_valid && (sc->sc_ah->imask &ATH9K_INT_SWBA )) { +/* Disable SWBA interrupt */ + sc->sc_ah->imask &= ~ATH9K_INT_SWBA ; +ath9k_ps_wakeup (sc); +ath9k_hw_set_interrupts (sc->sc_ah, sc->sc_ah->imask); +ath9k_ps_restore (sc); } sc->nvifs--;
Signature · 1 line
1.7.3.2
PATCH 2/3 ath9k: Add change_interface callback
Add support to change interface type
without bringing down the interface.
--- drivers/net/wireless/ath/ath9k/main.c | 91 +++++++++++++++++++++++++-------- 1 files changed, 69 insertions(+), 22 deletions(-)
drivers/net/wireless/ath/ath9k/main.c +69 -22
@@ -1429,40 +1429,26 @@ out:return ret; } -static void ath9k_remove_interface (struct ieee80211_hw *hw, -struct ieee80211_vif *vif) +static void ath9k_reclaim_beacon (struct ath_softc *sc, +struct ieee80211_vif *vif) { -struct ath_wiphy *aphy = hw->priv; -struct ath_softc *sc = aphy->sc;struct ath_common *common =ath9k_hw_common (sc->sc_ah);struct ath_vif *avp = (void *)vif->drv_priv;bool bs_valid = false;int i; -ath_print (common,ATH_DBG_CONFIG ,"Detach Interface\n" ); - -mutex_lock (&sc->mutex); - -/* Stop ANI */ - sc->sc_flags &= ~SC_OP_ANI_RUN ; -del_timer_sync (&common->ani.timer); - -/* Reclaim beacon resources */ -if ((sc->sc_ah->opmode ==NL80211_IFTYPE_AP ) || - (sc->sc_ah->opmode ==NL80211_IFTYPE_ADHOC ) || - (sc->sc_ah->opmode ==NL80211_IFTYPE_MESH_POINT )) { -ath9k_ps_wakeup (sc); -ath9k_hw_stoptxdma (sc->sc_ah, sc->beacon.beaconq); -ath9k_ps_restore (sc); - } +ath9k_ps_wakeup (sc); +ath9k_hw_stoptxdma (sc->sc_ah, sc->beacon.beaconq); +ath9k_ps_restore (sc);ath_beacon_return (sc, avp); sc->sc_flags &= ~SC_OP_BEACONS ;for (i =0 ; i <ARRAY_SIZE (sc->beacon.bslot); i++) {if (sc->beacon.bslot[i] == vif) { -printk (KERN_DEBUG "%s: vif had allocated beacon " -"slot\n" , __func__); +ath_print (common,ATH_DBG_BEACON , +"%s: vif had allocated beacon " +"slot\n" , __func__); sc->beacon.bslot[i] =NULL ; sc->beacon.bslot_aphy[i] =NULL ; }else if (sc->beacon.bslot[i])
@@ -1475,6 +1461,66 @@ static void ath9k_remove_interface(struct ieee80211_hw *hw,ath9k_hw_set_interrupts (sc->sc_ah, sc->sc_ah->imask);ath9k_ps_restore (sc); } +} + +static int ath9k_change_interface (struct ieee80211_hw *hw, +struct ieee80211_vif *vif, +enum nl80211_iftype new_type, +bool p2p) +{ +struct ath_wiphy *aphy = hw->priv; +struct ath_softc *sc = aphy->sc; +struct ath_common *common =ath9k_hw_common (sc->sc_ah); + +ath_print (common,ATH_DBG_CONFIG ,"Change Interface\n" ); +mutex_lock (&sc->mutex); + + new_type =ieee80211_iftype_p2p (new_type, p2p); + +switch (new_type) { +case NL80211_IFTYPE_AP : +case NL80211_IFTYPE_ADHOC : +break ; +case NL80211_IFTYPE_STATION : +/* Stop ANI */ + sc->sc_flags &= ~SC_OP_ANI_RUN ; +del_timer_sync (&common->ani.timer); +if ((vif->type ==NL80211_IFTYPE_AP ) || + (vif->type ==NL80211_IFTYPE_ADHOC )) +ath9k_reclaim_beacon (sc, vif); +break ; +default : +ath_print (common,ATH_DBG_FATAL , +"Interface type %d not yet supported\n" , vif->type); +mutex_unlock (&sc->mutex); +return -ENOTSUPP ; + } + vif->type = new_type; + +mutex_unlock (&sc->mutex); +return 0 ; +} + +static void ath9k_remove_interface (struct ieee80211_hw *hw, +struct ieee80211_vif *vif) +{ +struct ath_wiphy *aphy = hw->priv; +struct ath_softc *sc = aphy->sc; +struct ath_common *common =ath9k_hw_common (sc->sc_ah); + +ath_print (common,ATH_DBG_CONFIG ,"Detach Interface\n" ); + +mutex_lock (&sc->mutex); + +/* Stop ANI */ + sc->sc_flags &= ~SC_OP_ANI_RUN ; +del_timer_sync (&common->ani.timer); + +/* Reclaim beacon resources */ +if ((sc->sc_ah->opmode ==NL80211_IFTYPE_AP ) || + (sc->sc_ah->opmode ==NL80211_IFTYPE_ADHOC ) || + (sc->sc_ah->opmode ==NL80211_IFTYPE_MESH_POINT )) +ath9k_reclaim_beacon (sc, vif); sc->nvifs--;
@@ -2123,6 +2169,7 @@ struct ieee80211_ops ath9k_ops = { .start = ath9k_start, .stop = ath9k_stop, .add_interface = ath9k_add_interface, + .change_interface = ath9k_change_interface, .remove_interface = ath9k_remove_interface, .config = ath9k_config, .configure_filter = ath9k_configure_filter,
Signature · 1 line
1.7.3.2
Re: [PATCH 2/3] ath9k: Add change_interface callback
drivers/net/wireless/ath/ath9k/main.c static void ath9k_remove_interface(struct ieee80211_hw *hw, · line 1478
Quoted 13 lines · Rajkumar Manoharan
drivers/net/wireless/ath/ath9k/main.c +13
-0+static int ath9k_change_interface (struct ieee80211_hw *hw, +struct ieee80211_vif *vif, +enum nl80211_iftype new_type, +bool p2p) +{ +struct ath_wiphy *aphy = hw->priv; +struct ath_softc *sc = aphy->sc; +struct ath_common *common =ath9k_hw_common (sc->sc_ah); + +ath_print (common,ATH_DBG_CONFIG ,"Change Interface\n" ); +mutex_lock (&sc->mutex); + + new_type =ieee80211_iftype_p2p (new_type, p2p);
I'm pretty sure you won't want that, and will just use new_type directly because you don't care about P2P or non-P2P as of now.
johannes
Re: [PATCH 2/3] ath9k: Add change_interface callback
Quoted 19 lines · Johannes Berg
drivers/net/wireless/ath/ath9k/main.c static void ath9k_remove_interface(struct ieee80211_hw *hw, · line 1478
Quoted 13 lines · Rajkumar Manoharan
drivers/net/wireless/ath/ath9k/main.c +13
-0+static int ath9k_change_interface (struct ieee80211_hw *hw, +struct ieee80211_vif *vif, +enum nl80211_iftype new_type, +bool p2p) +{ +struct ath_wiphy *aphy = hw->priv; +struct ath_softc *sc = aphy->sc; +struct ath_common *common =ath9k_hw_common (sc->sc_ah); + +ath_print (common,ATH_DBG_CONFIG ,"Change Interface\n" ); +mutex_lock (&sc->mutex); + + new_type =ieee80211_iftype_p2p (new_type, p2p);I'm pretty sure you won't want that, and will just use
new_typedirectly because you don't care about P2P or non-P2P as of now.
Yes and I missed to store new p2p bool value too ;) Thanks for pointing out.
--
Rajkumar
Re: [PATCH 2/3] ath9k: Add change_interface callback
In reply to Rajkumar ManoharanQuoted 5 lines · Rajkumar Manoharan
Add support to change interface type
without bringing down the interface.Signed-off-by Rajkumar Manoharan <[email protected]>---
[snip]
Quoted 8 lines
drivers/net/wireless/ath/ath9k/main.c +8
-0+static int ath9k_change_interface (struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + enum nl80211_iftype new_type, + bool p2p) +{ + struct ath_wiphy *aphy = hw->priv; + struct ath_softc *sc = aphy->sc; + struct ath_common *common = ath9k_hw_common(sc->sc_ah);
drivers/net/wireless/ath/ath9k/main.c static void ath9k_remove_interface(struct ieee80211_hw *hw, · line 1483
Quoted 10 lines
drivers/net/wireless/ath/ath9k/main.c +10
-0+ + ath_print(common, ATH_DBG_CONFIG, "Change Interface\n"); + mutex_lock(&sc->mutex); + + new_type = ieee80211_iftype_p2p(new_type, p2p); + + switch (new_type) { + case NL80211_IFTYPE_AP: + case NL80211_IFTYPE_ADHOC: + break;
If you have to reclaim beacon in the case where you go from AP -> STA (replicate remove_interface), don't you have to replicate what add_interface does in this case, e.g. the check below etc?
if (sc->nbcnvifs >= ATH_BCBUF) {
ret = -ENOBUFS;
goto out;
}Quoted 15 lines
+ case
NL80211_IFTYPE_STATION:
+ /* Stop ANI */
+sc->sc_flags&= ~SC_OP_ANI_RUN;
+del_timer_sync(&common->ani.timer);
+ if ((vif->type==NL80211_IFTYPE_AP) ||
+ (vif->type==NL80211_IFTYPE_ADHOC))
+ath9k_reclaim_beacon(sc, vif);
+ break;
+ default:
+ ath_print(common,ATH_DBG_FATAL,
+ "Interface type %d not yet supported\n",vif->type);
+mutex_unlock(&sc->mutex);
+ return-ENOTSUPP;
+ }
+vif->type=new_type;
drivers/net/wireless/ath/ath9k/main.c static void ath9k_remove_interface(struct ieee80211_hw *hw, · line 1502
Quoted 4 lines
drivers/net/wireless/ath/ath9k/main.c +4
-0+ + mutex_unlock(&sc->mutex); + return 0; +}
Also, doesn't this patch introduce yet another race condition between configuration change in process context and bcn_tasklet?
/Björn
PATCH 3/3 Revert "ath9k_htc: Handle monitor mode properly for HTC devices"
In reply to Rajkumar ManoharanThis reverts commit 446fad5a5b6be765c8ec39bfdbbc6c7aa63fbcbb.
The change had broken the packet injection on monitoring mode.
--- drivers/net/wireless/ath/ath9k/htc_drv_main.c | 64 +++++++++++++++++++++++-- 1 files changed, 59 insertions(+), 5 deletions(-)
drivers/net/wireless/ath/ath9k/htc_drv_main.c +59 -5
@@ -184,6 +184,47 @@ err:return ret; } +static int ath9k_htc_add_monitor_interface (struct ath9k_htc_priv *priv) +{ +struct ath_common *common =ath9k_hw_common (priv->ah); +struct ath9k_htc_target_vif hvif; +int ret =0 ; +u8 cmd_rsp; + +if (priv->nvifs >0 ) +return -ENOBUFS ; + +memset (&hvif,0 ,sizeof (struct ath9k_htc_target_vif )); +memcpy (&hvif.myaddr, common->macaddr,ETH_ALEN ); + + hvif.opmode =cpu_to_be32 (HTC_M_MONITOR ); + priv->ah->opmode =NL80211_IFTYPE_MONITOR ; + hvif.index = priv->nvifs; + +WMI_CMD_BUF (WMI_VAP_CREATE_CMDID , &hvif); +if (ret) +return ret; + + priv->nvifs++; +return 0 ; +} + +static int ath9k_htc_remove_monitor_interface (struct ath9k_htc_priv *priv) +{ +struct ath_common *common =ath9k_hw_common (priv->ah); +struct ath9k_htc_target_vif hvif; +int ret =0 ; +u8 cmd_rsp; + +memset (&hvif,0 ,sizeof (struct ath9k_htc_target_vif )); +memcpy (&hvif.myaddr, common->macaddr,ETH_ALEN ); + hvif.index =0 ;/* Should do for now */ +WMI_CMD_BUF (WMI_VAP_REMOVE_CMDID , &hvif); + priv->nvifs--; + +return ret; +} +static int ath9k_htc_add_station (struct ath9k_htc_priv *priv,struct ieee80211_vif *vif,struct ieee80211_sta *sta)
@@ -1199,6 +1240,16 @@ static void ath9k_htc_stop(struct ieee80211_hw *hw)WMI_CMD (WMI_STOP_RECV_CMDID );skb_queue_purge (&priv->tx_queue); +/* Remove monitor interface here */ +if (ah->opmode ==NL80211_IFTYPE_MONITOR ) { +if (ath9k_htc_remove_monitor_interface (priv)) +ath_print (common,ATH_DBG_FATAL , +"Unable to remove monitor interface\n" ); +else +ath_print (common,ATH_DBG_CONFIG , +"Monitor interface removed\n" ); + } +if (ah->btcoex_hw.enabled) {ath9k_hw_btcoex_disable (ah);if (ah->btcoex_hw.scheme ==ATH_BTCOEX_CFG_3WIRE )
@@ -1372,13 +1423,16 @@ static int ath9k_htc_config(struct ieee80211_hw *hw, u32 changed) } } -if (changed &IEEE80211_CONF_CHANGE_MONITOR ) +if (changed &IEEE80211_CONF_CHANGE_MONITOR ) {if (conf->flags &IEEE80211_CONF_MONITOR ) { -ath_print (common,ATH_DBG_CONFIG , -"HW opmode set to Monitor mode\n" ); - priv->ah->opmode =NL80211_IFTYPE_MONITOR ; +if (ath9k_htc_add_monitor_interface (priv)) +ath_print (common,ATH_DBG_FATAL , +"Failed to set monitor mode\n" ); +else +ath_print (common,ATH_DBG_CONFIG , +"HW opmode set to Monitor mode\n" ); } - + }if (changed &IEEE80211_CONF_CHANGE_IDLE ) {mutex_lock (&priv->htc_pm_lock);
Signature · 1 line
1.7.3.2
Quoted 3 lines · Rajkumar Manoharan
while removing beaconing mode interface, SWBA interrupt was never disabled when there are no other beaconing interfaces.
Race condition needs to be taken care. will send v2 patch.
--
Rajkumar