Skip to contentSkip to conversation

mac80211: add sta_update_rates callback

PATCH In review Antonio Quartulli 3 participants 9 messages Aug 9, 2012 – Aug 20, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 mac80211: add sta_update_rates callback

some drivers need to be notified in case of rates update. This callback tells the driver that something has been changed in the supported rates set of the station passed as argument and that it needs to update its internal tables

---

** This is the first time that I play with trace.h, so it could be the case that I made something completely wrong! Sorry :)

 include/net/mac80211.h    |    4 ++++
 net/mac80211/driver-ops.h |   14 ++++++++++++++
 net/mac80211/ibss.c       |    4 +++-
 net/mac80211/trace.h      |   27 +++++++++++++++++++++++++++
 4 files changed, 48 insertions(+), 1 deletion(-)
include/net/mac80211.h +4 -0
index bb86aa6..c5dc725 100644
@@ -2284,6 +2284,10 @@ struct ieee80211_ops {
 				 struct ieee80211_vif *vif,
 				 struct ieee80211_bss_conf *info,
 				 u32 changed);
+	void (*sta_update_rates)(struct ieee80211_hw *hw,
+				 struct ieee80211_sta *sta,
+				 struct ieee80211_vif *vif,
+				 struct ieee80211_bss_conf *info);
 
 	u64 (*prepare_multicast)(struct ieee80211_hw *hw,
 				 struct netdev_hw_addr_list *mc_list);
net/mac80211/driver-ops.h +14 -0
index df92031..2cec563 100644
@@ -213,6 +213,20 @@ static inline void drv_bss_info_changed(struct ieee80211_local *local,
 	trace_drv_return_void(local);
 }
 
+static inline void drv_sta_update_rates(struct ieee80211_local *local,
+					struct ieee80211_sta *sta,
+					struct ieee80211_sub_if_data *sdata)
+{
+	might_sleep();
+
+	check_sdata_in_driver(sdata);
+	trace_drv_sta_update_rates(local, sta, sdata);
+	if (local->ops->sta_update_rates)
+		local->ops->sta_update_rates(&local->hw, sta, &sdata->vif,
+					     &sdata->vif.bss_conf);
+	trace_drv_return_void(local);
+}
+
 static inline u64 drv_prepare_multicast(struct ieee80211_local *local,
 					struct netdev_hw_addr_list *mc_list)
 {
net/mac80211/ibss.c +3 -1
index 37e71a3..5e16dbc 100644
@@ -467,8 +467,10 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
 			}
 		}
 
-		if (sta && rates_updated)
+		if (sta && rates_updated) {
+			drv_sta_update_rates(local, &sta->sta, sdata);
 			rate_control_rate_init(sta);
+		}
 
 		rcu_read_unlock();
 	}
net/mac80211/trace.h +27 -0
index c6d33b5..c9a60ee 100644
@@ -339,6 +339,33 @@ TRACE_EVENT(drv_bss_info_changed,
 	)
 );
 
+TRACE_EVENT(drv_sta_update_rates,
+	TP_PROTO(struct ieee80211_local *local,
+		 struct ieee80211_sta *sta,
+		 struct ieee80211_sub_if_data *sdata),
+
+	TP_ARGS(local, sta, sdata),
+
+	TP_STRUCT__entry(
+		LOCAL_ENTRY
+		STA_ENTRY
+		VIF_ENTRY
+		__array(u32, supp_rates, IEEE80211_NUM_BANDS)
+	),
+
+	TP_fast_assign(
+		LOCAL_ASSIGN;
+		STA_ASSIGN;
+		VIF_ASSIGN;
+		memcpy(__entry->supp_rates, sta->supp_rates,
+		       IEEE80211_NUM_BANDS);
+	),
+
+	TP_printk(
+		LOCAL_PR_FMT STA_PR_FMT,
+		LOCAL_PR_ARG, STA_PR_ARG
+	)
+);
 TRACE_EVENT(drv_prepare_multicast,
 	TP_PROTO(struct ieee80211_local *local, int mc_count),
 
Signature · 1 line
1.7.9.4
#1 lore raw

PATCH 2/2 ath9k_htc: implement sta_update_rates callback

Since this driver internally stores the supported rate set for each station in order to perform rate control, this callback is needed to update the internal table as soon as the rate set changes in the mac80211 station configuration.

---
 drivers/net/wireless/ath/ath9k/htc_drv_main.c |   24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)
drivers/net/wireless/ath/ath9k/htc_drv_main.c +19 -5
index c785129..6f5c134 100644
@@ -676,21 +676,24 @@ static void ath9k_htc_init_rate(struct ath9k_htc_priv *priv,
 }
 
 static void ath9k_htc_update_rate(struct ath9k_htc_priv *priv,
+				  struct ieee80211_sta *sta,
 				  struct ieee80211_vif *vif,
 				  struct ieee80211_bss_conf *bss_conf)
 {
 	struct ath_common *common = ath9k_hw_common(priv->ah);
 	struct ath9k_htc_target_rate trate;
-	struct ieee80211_sta *sta;
 	int ret;
 
 	memset(&trate, 0, sizeof(struct ath9k_htc_target_rate));
 
 	rcu_read_lock();
-	sta = ieee80211_find_sta(vif, bss_conf->bssid);
+	/* if no sta was passed, look for the AP */
 	if (!sta) {
-		rcu_read_unlock();
-		return;
+		sta = ieee80211_find_sta(vif, bss_conf->bssid);
+		if (!sta) {
+			rcu_read_unlock();
+			return;
+		}
 	}
 	ath9k_htc_setup_rate(priv, sta, &trate);
 	rcu_read_unlock();
@@ -702,6 +705,16 @@ static void ath9k_htc_update_rate(struct ath9k_htc_priv *priv,
 			bss_conf->bssid, be32_to_cpu(trate.capflags));
 }
 
+static void ath9k_htc_sta_update_rates(struct ieee80211_hw *hw,
+				       struct ieee80211_sta *sta,
+				       struct ieee80211_vif *vif,
+				       struct ieee80211_bss_conf *info)
+{
+	struct ath9k_htc_priv *priv = hw->priv;
+
+	ath9k_htc_update_rate(priv, sta, vif, info);
+}
+
 static int ath9k_htc_tx_aggr_oper(struct ath9k_htc_priv *priv,
 				  struct ieee80211_vif *vif,
 				  struct ieee80211_sta *sta,
@@ -1550,7 +1563,7 @@ static void ath9k_htc_bss_info_changed(struct ieee80211_hw *hw,
 	}
 
 	if (changed & BSS_CHANGED_HT)
-		ath9k_htc_update_rate(priv, vif, bss_conf);
+		ath9k_htc_update_rate(priv, NULL, vif, bss_conf);
 
 	ath9k_htc_ps_restore(priv);
 	mutex_unlock(&priv->mutex);
@@ -1759,6 +1772,7 @@ struct ieee80211_ops ath9k_htc_ops = {
 	.sta_remove         = ath9k_htc_sta_remove,
 	.conf_tx            = ath9k_htc_conf_tx,
 	.bss_info_changed   = ath9k_htc_bss_info_changed,
+	.sta_update_rates   = ath9k_htc_sta_update_rates,
 	.set_key            = ath9k_htc_set_key,
 	.get_tsf            = ath9k_htc_get_tsf,
 	.set_tsf            = ath9k_htc_set_tsf,
Signature · 1 line
1.7.9.4
#2 lore raw

PATCH 2/2 ath9k_htc: implement sta_update_rates callback

Quoted 3 lines · Antonio Quartulli

Since this driver internally stores the supported rate set for each station in order to perform rate control, this callback is needed to update the internal table as soon as the rate set changes in the mac80211 station configuration.

This looks good to me.

Sujith

maintainer
#3 lore raw

PATCH 1/2 mac80211: add sta_update_rates callback

In reply to Antonio Quartulli
Quoted 26 lines · Antonio Quartulli

some drivers need to be notified in case of rates update. This callback tells the driver that something has been changed in the supported rates set of the station passed as argument and that it needs to update its internal tables

---

** This is the first time that I play with trace.h, so it could be the case that I made something completely wrong! Sorry :)

 include/net/mac80211.h    |    4 ++++
 net/mac80211/driver-ops.h |   14 ++++++++++++++
 net/mac80211/ibss.c       |    4 +++-
 net/mac80211/trace.h      |   27 +++++++++++++++++++++++++++
 4 files changed, 48 insertions(+), 1 deletion(-)
include/net/mac80211.h +0 -0
index bb86aa6..c5dc725 100644

include/net/mac80211.h struct ieee80211_ops { · line 2290

Quoted 7 lines
include/net/mac80211.h +4 -0
@@ -2284,6 +2284,10 @@ struct ieee80211_ops {
 				 struct ieee80211_vif *vif,
 				 struct ieee80211_bss_conf *info,
 				 u32 changed);
+	void (*sta_update_rates)(struct ieee80211_hw *hw,
+				 struct ieee80211_sta *sta,
+				 struct ieee80211_vif *vif,
+				 struct ieee80211_bss_conf *info);

Passing bss_conf doesn't make a lot of sense, it hasn't changed when the rate changes...?

Also there's already an update call sta_rc_update() so I think you should just define a new change flag for that?

johannes

#4 lore raw

PATCH 1/2 mac80211: add sta_update_rates callback

Quoted 22 lines · Johannes Berg
Quoted 21 lines · Antonio Quartulli

some drivers need to be notified in case of rates update. This callback tells the driver that something has been changed in the supported rates set of the station passed as argument and that it needs to update its internal tables

---

** This is the first time that I play with trace.h, so it could be the case that I made something completely wrong! Sorry :)

 include/net/mac80211.h    |    4 ++++
 net/mac80211/driver-ops.h |   14 ++++++++++++++
 net/mac80211/ibss.c       |    4 +++-
 net/mac80211/trace.h      |   27 +++++++++++++++++++++++++++
 4 files changed, 48 insertions(+), 1 deletion(-)
Quoted 15 lines

include/net/mac80211.h struct ieee80211_ops { · line 2290

Quoted 12 lines
include/net/mac80211.h +4 -0
index bb86aa6..c5dc725 100644
@@ -2284,6 +2284,10 @@ struct ieee80211_ops {
 				 struct ieee80211_vif *vif,
 				 struct ieee80211_bss_conf *info,
 				 u32 changed);
+	void (*sta_update_rates)(struct ieee80211_hw *hw,
+				 struct ieee80211_sta *sta,
+				 struct ieee80211_vif *vif,
+				 struct ieee80211_bss_conf *info);

Passing bss_conf doesn't make a lot of sense, it hasn't changed when the rate changes...?

Right. I approached this the other way around..starting from the ath9k_htc driver and I wrongly exposed useless arguments. Will fix this.

Quoted 3 lines

Also there's already an update call sta_rc_update() so I think you should just define a new change flag for that?

mh, at the very beginning I thought it was not correct what you said, but indeed we should be able to do the job in sta_rc_update().

But then why does the ath9k_htc driver implement ath9k_htc_update_rate() to update the rate used to talk to the AP? Should it use sta_rc_update() as well?

Cheers,

Quoted 2 lines

johannes

Signature · 11 lines
Antonio Quartulli

..each of us alone is worth nothing..
Ernesto "Che" Guevara
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
Url : http://lists.ath9k.org/pipermail/ath9k-devel/attachments/20120809/7a37a3de/attachment-0001.pgp 
#5 lore raw

PATCH 1/2 mac80211: add sta_update_rates callback

Quoted 9 lines · Antonio Quartulli
Quoted 2 lines · Johannes Berg

Also there's already an update call sta_rc_update() so I think you should just define a new change flag for that?

mh, at the very beginning I thought it was not correct what you said, but indeed we should be able to do the job in sta_rc_update().

But then why does the ath9k_htc driver implement ath9k_htc_update_rate() to update the rate used to talk to the AP? Should it use sta_rc_update() as well?

Well, I am digging into the driver a bit more and I realised that the supported rate set does not touch the RC at all. The supported rates are only stored in the device (this is why there is another function for doing that in case of STA mode) and then the RC will play its game from a different point.

For the reason above sta_rc_update() can't do what we want. At this point I think we have two options:
1) mac80211 forces this change to be done by sta_rc_update() => ath9k has to adapt it's implementation to follow the API
2) mac80211 uses another callback (sta_update_rates()) to refresh the supported rates set.

I think that option 2) is probably the way to go, because the RC stuff is usually not strictly related to the real device (e.g. ath9k has its own rc routines shared among ath9k and ath9k_htc but they have different routins to set the supported_rates set for a station.)

Cheers,

Quoted 12 lines

Cheers,

Quoted 2 lines

johannes

Signature · 4 lines
Antonio Quartulli

..each of us alone is worth nothing..
Ernesto "Che" Guevara
Signature · 11 lines
Antonio Quartulli

..each of us alone is worth nothing..
Ernesto "Che" Guevara
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
Url : http://lists.ath9k.org/pipermail/ath9k-devel/attachments/20120809/698f818e/attachment.pgp 
maintainer
#6 lore raw
Quoted 8 lines · Antonio Quartulli
Quoted 7 lines · Antonio Quartulli
Quoted 2 lines · Johannes Berg

Also there's already an update call sta_rc_update() so I think you should just define a new change flag for that?

mh, at the very beginning I thought it was not correct what you said, but indeed we should be able to do the job in sta_rc_update().

Quoted 7 lines
Quoted 2 lines

But then why does the ath9k_htc driver implement ath9k_htc_update_rate() to update the rate used to talk to the AP? Should it use sta_rc_update() as well?

Well, I am digging into the driver a bit more and I realised that the supported rate set does not touch the RC at all. The supported rates are only stored in the device (this is why there is another function for doing that in case of STA mode) and then the RC will play its game from a different point.

That's strange, why would the device care about the supported rateset of an IBSS peer? or does it have some rate control in the device?

Quoted 11 lines

For the reason above sta_rc_update() can't do what we want. At this point I think we have two options:
1) mac80211 forces this change to be done by sta_rc_update() => ath9k has to adapt it's implementation to follow the API
2) mac80211 uses another callback (sta_update_rates()) to refresh the supported rates set.

I think that option 2) is probably the way to go, because the RC stuff is usually not strictly related to the real device (e.g. ath9k has its own rc routines shared among ath9k and ath9k_htc but they have different routins to set the supported_rates set for a station.)

But the rate control algorithm is re-inited in this case or something?

johannes

#7 lore raw

PATCH 1/2 mac80211: add sta_update_rates callback

In reply to Antonio Quartulli
Quoted 5 lines · Antonio Quartulli

mh, at the very beginning I thought it was not correct what you said, but indeed we should be able to do the job in sta_rc_update().

But then why does the ath9k_htc driver implement ath9k_htc_update_rate() to update the rate used to talk to the AP? Should it use sta_rc_update() as well?

We didn't have this new callback back then, and sta_rc_update() is sufficient to fix this. Maybe with a new flag - IEEE80211_RC_BASIC_RATES_CHANGED.

Sujith

#8 lore raw

PATCH 1/2 mac80211: add sta_update_rates callback

Quoted 2 lines · Sujith Manoharan

We didn't have this new callback back then, and sta_rc_update() is sufficient to fix this. Maybe with a new flag - IEEE80211_RC_BASIC_RATES_CHANGED.

Um, IEEE80211_RC_SUPP_RATES_CHANGED or something.

Sujith