Skip to contentSkip to conversation

convert drivers to new sta add/remove callbacks

PATCH In review Johannes Berg 2 participants 8 messages Feb 19, 2010 – Feb 20, 2010

Subsystems (2)
lore
Share & tools
lore

Johannes Berg

author maintainer
#0 lore raw

cover convert drivers to new sta add/remove callbacks

This series converts the easy drivers.

iwlwifi patch is in progress.

mwl8k is far more involved than I can do easily :)

johannes

author maintainer
#1 lore raw

PATCH 1/4 ar9170: convert to new station add/remove callbacks

This converts ar9170 to use the new station
add/remove callbacks instead of using the
old sta_notify callback.

---
 drivers/net/wireless/ath/ar9170/main.c |   80 ++++++++++++++++-----------------
 1 file changed, 41 insertions(+), 39 deletions(-)
drivers/net/wireless/ath/ar9170/main.c +41 -39
@@ -2329,54 +2329,55 @@ out:
 	return err;
 }
 
-static void ar9170_sta_notify(struct ieee80211_hw *hw,
-			      struct ieee80211_vif *vif,
-			      enum sta_notify_cmd cmd,
-			      struct ieee80211_sta *sta)
+static int ar9170_sta_add(struct ieee80211_hw *hw,
+			  struct ieee80211_vif *vif,
+			  struct ieee80211_sta *sta)
 {
 	struct ar9170 *ar = hw->priv;
 	struct ar9170_sta_info *sta_info = (void *) sta->drv_priv;
 	unsigned int i;
 
-	switch (cmd) {
-	case STA_NOTIFY_ADD:
-		memset(sta_info, 0, sizeof(*sta_info));
-
-		if (!sta->ht_cap.ht_supported)
-			break;
-
-		if (sta->ht_cap.ampdu_density > ar->global_ampdu_density)
-			ar->global_ampdu_density = sta->ht_cap.ampdu_density;
-
-		if (sta->ht_cap.ampdu_factor < ar->global_ampdu_factor)
-			ar->global_ampdu_factor = sta->ht_cap.ampdu_factor;
-
-		for (i = 0; i < AR9170_NUM_TID; i++) {
-			sta_info->agg[i].state = AR9170_TID_STATE_SHUTDOWN;
-			sta_info->agg[i].active = false;
-			sta_info->agg[i].ssn = 0;
-			sta_info->agg[i].tid = i;
-			INIT_LIST_HEAD(&sta_info->agg[i].list);
-			skb_queue_head_init(&sta_info->agg[i].queue);
-		}
+	memset(sta_info, 0, sizeof(*sta_info));
 
-		sta_info->ampdu_max_len = 1 << (3 + sta->ht_cap.ampdu_factor);
-		break;
+	if (!sta->ht_cap.ht_supported)
+		return 0;
 
-	case STA_NOTIFY_REMOVE:
-		if (!sta->ht_cap.ht_supported)
-			break;
-
-		for (i = 0; i < AR9170_NUM_TID; i++) {
-			sta_info->agg[i].state = AR9170_TID_STATE_INVALID;
-			skb_queue_purge(&sta_info->agg[i].queue);
-		}
+	if (sta->ht_cap.ampdu_density > ar->global_ampdu_density)
+		ar->global_ampdu_density = sta->ht_cap.ampdu_density;
 
-		break;
+	if (sta->ht_cap.ampdu_factor < ar->global_ampdu_factor)
+		ar->global_ampdu_factor = sta->ht_cap.ampdu_factor;
+
+	for (i = 0; i < AR9170_NUM_TID; i++) {
+		sta_info->agg[i].state = AR9170_TID_STATE_SHUTDOWN;
+		sta_info->agg[i].active = false;
+		sta_info->agg[i].ssn = 0;
+		sta_info->agg[i].tid = i;
+		INIT_LIST_HEAD(&sta_info->agg[i].list);
+		skb_queue_head_init(&sta_info->agg[i].queue);
+	}
 
-	default:
-		break;
+	sta_info->ampdu_max_len = 1 << (3 + sta->ht_cap.ampdu_factor);
+
+	return 0;
+}
+
+static int ar9170_sta_remove(struct ieee80211_hw *hw,
+			     struct ieee80211_vif *vif,
+			     struct ieee80211_sta *sta)
+{
+	struct ar9170_sta_info *sta_info = (void *) sta->drv_priv;
+	unsigned int i;
+
+	if (!sta->ht_cap.ht_supported)
+		return 0;
+
+	for (i = 0; i < AR9170_NUM_TID; i++) {
+		sta_info->agg[i].state = AR9170_TID_STATE_INVALID;
+		skb_queue_purge(&sta_info->agg[i].queue);
 	}
+
+	return 0;
 }
 
 static int ar9170_get_stats(struct ieee80211_hw *hw,
@@ -2495,7 +2496,8 @@ static const struct ieee80211_ops ar9170
 	.bss_info_changed	= ar9170_op_bss_info_changed,
 	.get_tsf		= ar9170_op_get_tsf,
 	.set_key		= ar9170_set_key,
-	.sta_notify		= ar9170_sta_notify,
+	.sta_add		= ar9170_sta_add,
+	.sta_remove		= ar9170_sta_remove,
 	.get_stats		= ar9170_get_stats,
 	.ampdu_action		= ar9170_ampdu_action,
 };
author maintainer
#2 lore raw

PATCH 2/4 p54: convert to new station add/remove callbacks

In reply to Johannes Berg

This converts p54 to use the new station
add/remove callbacks instead of using the
old sta_notify callback.

---
 drivers/net/wireless/p54/main.c |   28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)
drivers/net/wireless/p54/main.c +19 -9
@@ -33,21 +33,29 @@ MODULE_DESCRIPTION("Softmac Prism54 comm
 MODULE_LICENSE("GPL");
 MODULE_ALIAS("prism54common");
 
+static int p54_sta_add_remove(struct ieee80211_hw *hw,
+			      struct ieee80211_vif *vif,
+			      struct ieee80211_sta *sta)
+{
+	struct p54_common *priv = hw->priv;
+
+	/*
+	 * Notify the firmware that we don't want or we don't
+	 * need to buffer frames for this station anymore.
+	 */
+
+	p54_sta_unlock(priv, sta->addr);
+
+	return 0;
+}
+
 static void p54_sta_notify(struct ieee80211_hw *dev, struct ieee80211_vif *vif,
 			      enum sta_notify_cmd notify_cmd,
 			      struct ieee80211_sta *sta)
 {
 	struct p54_common *priv = dev->priv;
-	switch (notify_cmd) {
-	case STA_NOTIFY_ADD:
-	case STA_NOTIFY_REMOVE:
-		/*
-		 * Notify the firmware that we don't want or we don't
-		 * need to buffer frames for this station anymore.
-		 */
 
-		p54_sta_unlock(priv, sta->addr);
-		break;
+	switch (notify_cmd) {
 	case STA_NOTIFY_AWAKE:
 		/* update the firmware's filter table */
 		p54_sta_unlock(priv, sta->addr);
@@ -506,6 +514,8 @@ static const struct ieee80211_ops p54_op
 	.remove_interface	= p54_remove_interface,
 	.set_tim		= p54_set_tim,
 	.sta_notify		= p54_sta_notify,
+	.sta_add		= p54_sta_add_remove,
+	.sta_remove		= p54_sta_add_remove,
 	.set_key		= p54_set_key,
 	.config			= p54_config,
 	.bss_info_changed	= p54_bss_info_changed,
author maintainer
#3 lore raw

PATCH 3/4 mac80211_hwsim: convert to new station add/remove callbacks

In reply to Johannes Berg

This converts mac80211_hwsim to use the new
station add/remove callbacks instead of using
the old sta_notify callback.

---
 drivers/net/wireless/mac80211_hwsim.c |   32 ++++++++++++++++++++++++++------
 1 file changed, 26 insertions(+), 6 deletions(-)
drivers/net/wireless/mac80211_hwsim.c +26 -6
@@ -771,23 +771,41 @@ static void mac80211_hwsim_bss_info_chan
 	}
 }
 
+static int mac80211_hwsim_sta_add(struct ieee80211_hw *hw,
+				  struct ieee80211_vif *vif,
+				  struct ieee80211_sta *sta)
+{
+	hwsim_check_magic(vif);
+	hwsim_set_sta_magic(sta);
+
+	return 0;
+}
+
+static int mac80211_hwsim_sta_remove(struct ieee80211_hw *hw,
+				     struct ieee80211_vif *vif,
+				     struct ieee80211_sta *sta)
+{
+	hwsim_check_magic(vif);
+	hwsim_clear_sta_magic(sta);
+
+	return 0;
+}
+
 static void mac80211_hwsim_sta_notify(struct ieee80211_hw *hw,
 				      struct ieee80211_vif *vif,
 				      enum sta_notify_cmd cmd,
 				      struct ieee80211_sta *sta)
 {
 	hwsim_check_magic(vif);
+
 	switch (cmd) {
-	case STA_NOTIFY_ADD:
-		hwsim_set_sta_magic(sta);
-		break;
-	case STA_NOTIFY_REMOVE:
-		hwsim_clear_sta_magic(sta);
-		break;
 	case STA_NOTIFY_SLEEP:
 	case STA_NOTIFY_AWAKE:
 		/* TODO: make good use of these flags */
 		break;
+	default:
+		WARN(1, "Invalid sta notify: %d\n", cmd);
+		break;
 	}
 }
 
@@ -958,6 +976,8 @@ static struct ieee80211_ops mac80211_hws
 	.config = mac80211_hwsim_config,
 	.configure_filter = mac80211_hwsim_configure_filter,
 	.bss_info_changed = mac80211_hwsim_bss_info_changed,
+	.sta_add = mac80211_hwsim_sta_add,
+	.sta_remove = mac80211_hwsim_sta_remove,
 	.sta_notify = mac80211_hwsim_sta_notify,
 	.set_tim = mac80211_hwsim_set_tim,
 	.conf_tx = mac80211_hwsim_conf_tx,
author maintainer
#4 lore raw

PATCH 4/4 ath9k: convert to new station add/remove callbacks

In reply to Johannes Berg

This converts ath9k to use the new station
add/remove callbacks instead of using the
old sta_notify callback.

---
 drivers/net/wireless/ath/ath9k/main.c |   35 +++++++++++++++++++---------------
 1 file changed, 20 insertions(+), 15 deletions(-)
drivers/net/wireless/ath/ath9k/main.c +20 -15
@@ -1684,24 +1684,28 @@ static void ath9k_configure_filter(struc
 		  "Set HW RX filter: 0x%x\n", rfilt);
 }
 
-static void ath9k_sta_notify(struct ieee80211_hw *hw,
-			     struct ieee80211_vif *vif,
-			     enum sta_notify_cmd cmd,
-			     struct ieee80211_sta *sta)
+static int ath9k_sta_add(struct ieee80211_hw *hw,
+			 struct ieee80211_vif *vif,
+			 struct ieee80211_sta *sta)
 {
 	struct ath_wiphy *aphy = hw->priv;
 	struct ath_softc *sc = aphy->sc;
 
-	switch (cmd) {
-	case STA_NOTIFY_ADD:
-		ath_node_attach(sc, sta);
-		break;
-	case STA_NOTIFY_REMOVE:
-		ath_node_detach(sc, sta);
-		break;
-	default:
-		break;
-	}
+	ath_node_attach(sc, sta);
+
+	return 0;
+}
+
+static int ath9k_sta_remove(struct ieee80211_hw *hw,
+			    struct ieee80211_vif *vif,
+			    struct ieee80211_sta *sta)
+{
+	struct ath_wiphy *aphy = hw->priv;
+	struct ath_softc *sc = aphy->sc;
+
+	ath_node_detach(sc, sta);
+
+	return 0;
 }
 
 static int ath9k_conf_tx(struct ieee80211_hw *hw, u16 queue,
@@ -2045,7 +2049,8 @@ struct ieee80211_ops ath9k_ops = {
 	.remove_interface   = ath9k_remove_interface,
 	.config 	    = ath9k_config,
 	.configure_filter   = ath9k_configure_filter,
-	.sta_notify         = ath9k_sta_notify,
+	.sta_add	    = ath9k_sta_add,
+	.sta_remove	    = ath9k_sta_remove,
 	.conf_tx 	    = ath9k_conf_tx,
 	.bss_info_changed   = ath9k_bss_info_changed,
 	.set_key            = ath9k_set_key,
author maintainer
#5 lore raw

[RFC/RFT] mwl8k: convert to new station add/remove callbacks

This converts mwl8k to use the new station add/remove callbacks instead of using the old sta_notify callback.

The new callbacks can sleep, so a lot of code can be removed now.

---
FWIW, I did the remove/add order in the file to make the patch easier to read .....

 drivers/net/wireless/mwl8k.c |  106 ++++++++-----------------------------------
 1 file changed, 22 insertions(+), 84 deletions(-)
drivers/net/wireless/mwl8k.c +22 -84
@@ -188,10 +188,6 @@ struct mwl8k_priv {
 	bool sniffer_enabled;
 	bool wmm_enabled;
 
-	struct work_struct sta_notify_worker;
-	spinlock_t sta_notify_list_lock;
-	struct list_head sta_notify_list;
-
 	/* XXX need to convert this to handle multiple interfaces */
 	bool capture_beacon;
 	u8 capture_bssid[ETH_ALEN];
@@ -3706,90 +3702,36 @@ static int mwl8k_set_rts_threshold(struc
 	return mwl8k_cmd_set_rts_threshold(hw, value);
 }
 
-struct mwl8k_sta_notify_item
-{
-	struct list_head list;
-	struct ieee80211_vif *vif;
-	enum sta_notify_cmd cmd;
-	struct ieee80211_sta sta;
-};
-
-static void
-mwl8k_do_sta_notify(struct ieee80211_hw *hw, struct mwl8k_sta_notify_item *s)
+static int mwl8k_sta_remove(struct ieee80211_hw *hw,
+			    struct ieee80211_vif *vif,
+			    struct ieee80211_sta *sta)
 {
 	struct mwl8k_priv *priv = hw->priv;
 
-	/*
-	 * STA firmware uses UPDATE_STADB, AP firmware uses SET_NEW_STN.
-	 */
-	if (!priv->ap_fw && s->cmd == STA_NOTIFY_ADD) {
-		int rc;
-
-		rc = mwl8k_cmd_update_stadb_add(hw, s->vif, &s->sta);
-		if (rc >= 0) {
-			struct ieee80211_sta *sta;
-
-			rcu_read_lock();
-			sta = ieee80211_find_sta(s->vif, s->sta.addr);
-			if (sta != NULL)
-				MWL8K_STA(sta)->peer_id = rc;
-			rcu_read_unlock();
-		}
-	} else if (!priv->ap_fw && s->cmd == STA_NOTIFY_REMOVE) {
-		mwl8k_cmd_update_stadb_del(hw, s->vif, s->sta.addr);
-	} else if (priv->ap_fw && s->cmd == STA_NOTIFY_ADD) {
-		mwl8k_cmd_set_new_stn_add(hw, s->vif, &s->sta);
-	} else if (priv->ap_fw && s->cmd == STA_NOTIFY_REMOVE) {
-		mwl8k_cmd_set_new_stn_del(hw, s->vif, s->sta.addr);
-	}
-}
-
-static void mwl8k_sta_notify_worker(struct work_struct *work)
-{
-	struct mwl8k_priv *priv =
-		container_of(work, struct mwl8k_priv, sta_notify_worker);
-	struct ieee80211_hw *hw = priv->hw;
-
-	spin_lock_bh(&priv->sta_notify_list_lock);
-	while (!list_empty(&priv->sta_notify_list)) {
-		struct mwl8k_sta_notify_item *s;
-
-		s = list_entry(priv->sta_notify_list.next,
-			       struct mwl8k_sta_notify_item, list);
-		list_del(&s->list);
-
-		spin_unlock_bh(&priv->sta_notify_list_lock);
-
-		mwl8k_do_sta_notify(hw, s);
-		kfree(s);
-
-		spin_lock_bh(&priv->sta_notify_list_lock);
-	}
-	spin_unlock_bh(&priv->sta_notify_list_lock);
+	if (priv->ap_fw)
+		return mwl8k_cmd_set_new_stn_del(hw, vif, sta->addr);
+	else
+		return mwl8k_cmd_update_stadb_del(hw, vif, sta->addr);
 }
 
-static void
-mwl8k_sta_notify(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
-		 enum sta_notify_cmd cmd, struct ieee80211_sta *sta)
+static int mwl8k_sta_add(struct ieee80211_hw *hw,
+			 struct ieee80211_vif *vif,
+			 struct ieee80211_sta *sta)
 {
 	struct mwl8k_priv *priv = hw->priv;
-	struct mwl8k_sta_notify_item *s;
-
-	if (cmd != STA_NOTIFY_ADD && cmd != STA_NOTIFY_REMOVE)
-		return;
+	int ret;
 
-	s = kmalloc(sizeof(*s), GFP_ATOMIC);
-	if (s != NULL) {
-		s->vif = vif;
-		s->cmd = cmd;
-		s->sta = *sta;
-
-		spin_lock_bh(&priv->sta_notify_list_lock);
-		list_add_tail(&s->list, &priv->sta_notify_list);
-		spin_unlock_bh(&priv->sta_notify_list_lock);
+	if (!priv->ap_fw) {
+		ret = mwl8k_cmd_update_stadb_add(hw, vif, sta);
+		if (ret >= 0) {
+			MWL8K_STA(sta)->peer_id = ret;
+			return 0;
+		}
 
-		ieee80211_queue_work(hw, &priv->sta_notify_worker);
+		return ret;
 	}
+
+	return mwl8k_cmd_set_new_stn_add(hw, vif, sta);
 }
 
 static int mwl8k_conf_tx(struct ieee80211_hw *hw, u16 queue,
@@ -3849,7 +3791,8 @@ static const struct ieee80211_ops mwl8k_
 	.prepare_multicast	= mwl8k_prepare_multicast,
 	.configure_filter	= mwl8k_configure_filter,
 	.set_rts_threshold	= mwl8k_set_rts_threshold,
-	.sta_notify		= mwl8k_sta_notify,
+	.sta_add		= mwl8k_sta_add,
+	.sta_remove		= mwl8k_sta_remove,
 	.conf_tx		= mwl8k_conf_tx,
 	.get_stats		= mwl8k_get_stats,
 	.ampdu_action		= mwl8k_ampdu_action,
@@ -4051,11 +3994,6 @@ static int __devinit mwl8k_probe(struct
 	priv->radio_on = 0;
 	priv->radio_short_preamble = 0;
 
-	/* Station database handling */
-	INIT_WORK(&priv->sta_notify_worker, mwl8k_sta_notify_worker);
-	spin_lock_init(&priv->sta_notify_list_lock);
-	INIT_LIST_HEAD(&priv->sta_notify_list);
-
 	/* Finalize join worker */
 	INIT_WORK(&priv->finalize_join_worker, mwl8k_finalize_join_worker);
 
author maintainer
#7 lore raw

Re: [RFC/RFT] mwl8k: convert to new station add/remove callbacks

Quoted 6 lines · Lennert Buytenhek
Quoted 4 lines · Johannes Berg

This converts mwl8k to use the new station
add/remove callbacks instead of using the
old sta_notify callback.

Quoted 6 lines
Quoted 4 lines

The new callbacks can sleep, so a lot of
code can be removed now.

Ok, then I'll upgrade this to [PATCH]; John, can you pick it up?

johannes