Skip to contentSkip to conversation

ath9k: fix BSSID mask calculation

PATCH In review Felix Fietkau 2 participants 7 messages Sep 14, 2010

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

PATCH 1/2 ath9k: fix BSSID mask calculation

At the time the .add_interface driver op is called, the interface has not been marked as running yet, so ieee80211_iterate_active_interfaces will not pass it to the iterator function.
Because of this, the calculated BSSID mask is wrong, which breaks multi-BSS operation.

Additionally, the current way of comparing all addresses against each other is pointless, as the hardware only uses the hardware MAC address and the BSSID mask for matching the destination address, so all the address array reallocation is completely unnecessary.

This patch simplifies the logic by setting the initial mask bytes to 0xff and removing all bits in the iterator call that don't match the hardware MAC address. It also calls the iterator for the vif that was passed to add_interface()

---
 drivers/net/wireless/ath/ath9k/ath9k.h   |    2 +-
 drivers/net/wireless/ath/ath9k/main.c    |    2 +-
 drivers/net/wireless/ath/ath9k/virtual.c |   63 +++++++----------------------
 3 files changed, 17 insertions(+), 50 deletions(-)
drivers/net/wireless/ath/ath9k/ath9k.h +1 -1
index 5fe570b..c8ff417 100644
@@ -719,7 +719,7 @@ static inline void ath_ahb_exit(void) {};
 void ath9k_ps_wakeup(struct ath_softc *sc);
 void ath9k_ps_restore(struct ath_softc *sc);
 
-void ath9k_set_bssid_mask(struct ieee80211_hw *hw);
+void ath9k_set_bssid_mask(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
 int ath9k_wiphy_add(struct ath_softc *sc);
 int ath9k_wiphy_del(struct ath_wiphy *aphy);
 void ath9k_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb);
drivers/net/wireless/ath/ath9k/main.c +1 -1
index 1165f90..d3f96e4 100644
@@ -1415,7 +1415,7 @@ static int ath9k_add_interface(struct ieee80211_hw *hw,
 	sc->nvifs++;
 
 	if (ah->caps.hw_caps & ATH9K_HW_CAP_BSSIDMASK)
-		ath9k_set_bssid_mask(hw);
+		ath9k_set_bssid_mask(hw, vif);
 
 	if (sc->nvifs > 1)
 		goto out; /* skip global settings for secondary vif */
drivers/net/wireless/ath/ath9k/virtual.c +15 -48

91 lines not on this page · raw message

Signature · 1 line
1.7.2.2
#1 lore raw

PATCH 2/2 mac80211: add a note about iterating interfaces during add_interface()

---
 include/net/mac80211.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
include/net/mac80211.h +2 -0
index f91fc33..19a5cb4 100644
@@ -2293,6 +2293,7 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted);
  * This function allows the iterator function to sleep, when the iterator
  * function is atomic @ieee80211_iterate_active_interfaces_atomic can
  * be used.
+ * Does not iterate over a new interface during add_interface()
  *
  * @hw: the hardware struct of which the interfaces should be iterated over
  * @iterator: the iterator function to call
@@ -2310,6 +2311,7 @@ void ieee80211_iterate_active_interfaces(struct ieee80211_hw *hw,
  * hardware that are currently active and calls the callback for them.
  * This function requires the iterator callback function to be atomic,
  * if that is not desired, use @ieee80211_iterate_active_interfaces instead.
+ * Does not iterate over a new interface during add_interface()
  *
  * @hw: the hardware struct of which the interfaces should be iterated over
  * @iterator: the iterator function to call, cannot sleep
Signature · 1 line
1.7.2.2
#2 lore raw
In reply to Felix Fietkau
Quoted 11 lines · Felix Fietkau

At the time the .add_interface driver op is called, the interface has not been marked as running yet, so ieee80211_iterate_active_interfaces will not pass it to the iterator function.
Because of this, the calculated BSSID mask is wrong, which breaks multi-BSS operation.

Additionally, the current way of comparing all addresses against each other is pointless, as the hardware only uses the hardware MAC address and the BSSID mask for matching the destination address, so all the address array reallocation is completely unnecessary.

Quoted 4 lines

This patch simplifies the logic by setting the initial mask bytes to 0xff and removing all bits in the iterator call that don't match the hardware MAC address. It also calls the iterator for the vif that was passed to add_interface()

You probably need to fix the mask-setting logic in ath_opmode_init as well?

Thanks,
Ben

Signature · 2 lines
Ben Greear <[email protected]>
Candela Technologies Inc  http://www.candelatech.com
#3 lore raw
Quoted 12 lines · Ben Greear
Quoted 11 lines · Felix Fietkau

At the time the .add_interface driver op is called, the interface has not been marked as running yet, so ieee80211_iterate_active_interfaces will not pass it to the iterator function.
Because of this, the calculated BSSID mask is wrong, which breaks multi-BSS operation.

Additionally, the current way of comparing all addresses against each other is pointless, as the hardware only uses the hardware MAC address and the BSSID mask for matching the destination address, so all the address array reallocation is completely unnecessary.

Quoted 7 lines
Quoted 4 lines

This patch simplifies the logic by setting the initial mask bytes to 0xff and removing all bits in the iterator call that don't match the hardware MAC address. It also calls the iterator for the vif that was passed to add_interface()

You probably need to fix the mask-setting logic in ath_opmode_init as well?

What do you mean?

- Felix

#4 lore raw
Quoted 13 lines · Felix Fietkau
Quoted 12 lines · Ben Greear
Quoted 11 lines · Felix Fietkau

At the time the .add_interface driver op is called, the interface has not been marked as running yet, so ieee80211_iterate_active_interfaces will not pass it to the iterator function.
Because of this, the calculated BSSID mask is wrong, which breaks multi-BSS operation.

Additionally, the current way of comparing all addresses against each other is pointless, as the hardware only uses the hardware MAC address and the BSSID mask for matching the destination address, so all the address array reallocation is completely unnecessary.

Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

This patch simplifies the logic by setting the initial mask bytes to 0xff and removing all bits in the iterator call that don't match the hardware MAC address. It also calls the iterator for the vif that was passed to add_interface()

You probably need to fix the mask-setting logic in ath_opmode_init as well?

What do you mean?

It seems I saw this code over-write the mask with a bad value when debugging this a few days ago..but perhaps I was mistaken, or perhaps your patch fixes this already.

	/* configure bssid mask */
	if (ah->caps.hw_caps & ATH9K_HW_CAP_BSSIDMASK)
		ath_hw_setbssidmask(common);

My plan was to have it call ath9k_set_bssid_mask(common->hw) instead.

Were you able to create multiple STA interfaces and have them send/receive data with your patch?

Thanks,
Ben

Signature · 2 lines
Ben Greear <[email protected]>
Candela Technologies Inc  http://www.candelatech.com
#5 lore raw
Quoted 9 lines · Ben Greear

It seems I saw this code over-write the mask with a bad value when debugging this a few days ago..but perhaps I was mistaken, or perhaps your patch fixes this already.

	/* configure bssid mask */
	if (ah->caps.hw_caps & ATH9K_HW_CAP_BSSIDMASK)
		ath_hw_setbssidmask(common);

My plan was to have it call ath9k_set_bssid_mask(common->hw) instead.

Not necessary. The bssid mask only needs to be recalculated when interfaces are brought up (and maybe when they are brought down, but that's less important).
The code here only needs to apply the precalculated mask to the hardware.

Quoted 2 lines

Were you able to create multiple STA interfaces and have them send/receive data with your patch?

I did not test that, but I suspect that my changes help there as well.

- Felix

Tested-by on v1 1/2
#6 lore raw
In reply to Felix Fietkau
Quoted 11 lines · Felix Fietkau

At the time the .add_interface driver op is called, the interface has not been marked as running yet, so ieee80211_iterate_active_interfaces will not pass it to the iterator function.
Because of this, the calculated BSSID mask is wrong, which breaks multi-BSS operation.

Additionally, the current way of comparing all addresses against each other is pointless, as the hardware only uses the hardware MAC address and the BSSID mask for matching the destination address, so all the address array reallocation is completely unnecessary.

Quoted 6 lines

This patch simplifies the logic by setting the initial mask bytes to 0xff and removing all bits in the iterator call that don't match the hardware MAC address. It also calls the iterator for the vif that was passed to add_interface()

I tried this on top of Johannes' sta_info patch and my ath9k rfilt patch, and I'm able to create two STAs that talk to each other (for around 15 seconds after AP reboots, then no luck).

The mask looks right to me, so I think my particular problem must be elsewhere. So, you can add:

Thanks,
Ben

Signature · 2 lines
Ben Greear <[email protected]>
Candela Technologies Inc  http://www.candelatech.com