mac80211: Add more general interface iterator.
Subsystems (2)
PATCH 1/3 mac80211: Add more general interface iterator.
From: Ben Greear <[email protected]>
This allows callers to specify whether they want all or just active interfaces, and whether their iterator is atomic or not. A count for the number of interfaces is returned to remove need for similar logic in the drivers.
---
:100644 100644 f91fc33... 53e5d5b... M include/net/mac80211.h
:100644 100644 bd40b11... ad96d5f... M net/mac80211/util.c
include/net/mac80211.h | 24 +++++++++++ net/mac80211/util.c | 102 +++++++++++++++++++++++++++--------------------- 2 files changed, 82 insertions(+), 44 deletions(-)
include/net/mac80211.h +24 -0
@@ -2320,6 +2320,30 @@ void ieee80211_iterate_active_interfaces_atomic(struct ieee80211_hw *hw,u8 *mac, struct ieee80211_vif *vif), void *data); +/** +* ieee80211_iterate_interfaces_helper - iterate interfaces +* +* This function iterates over the interfaces associated with a given +* hardware and calls the callback for them. If do_atomic is true, +* this function requires the iterator callback function to be atomic, +* if that is not desired, set do_atomic to false. +* If you want only active interfaces, set active_only to true. +* See also: @ieee80211_iterate_active_interfaces +* @ieee80211_iterate_active_interfaces_atomic +* +* Returns number of interfaces to be filtered. +* @hw: the hardware struct of which the interfaces should be iterated over +* @do_atomic: Should iterator be treated as atomic or not. +* @active_only: Should we only iterate over active interfaces. +* @iterator: the iterator function to call, cannot sleep +* @data: first argument of the iterator function +*/ +int ieee80211_iterate_interfaces_helper (struct ieee80211_hw *hw, +bool do_atomic, +bool active_only, +void (*iterator)(void *data,u8 *mac, +struct ieee80211_vif *vif), +void *data);/** * ieee80211_queue_work - add work onto the mac80211 workqueue
net/mac80211/util.c +58 -44
129 lines not on this page · raw message
Signature · 1 line
1.7.2.2
PATCH 2/3 ath9k: Calculate bssid-mask and rxfilter for 2+ STAs
From: Ben Greear <[email protected]>
The rx-filter wasn't taking multiple VIFs into account when calculating the BEACON and OTHER_BSS filter.
Make sure that bssid-mask is set up properly if we have more than 1 VIF. The BSSID should be calculated over all VIFs, not just running ones. Otherwise, secondary VIFS cannot receive enough packets to bring up their link.
---
:100644 100644 2a6e45a... 26fb322... M drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
:100644 100644 b32c8f0... 6e1aee0... M drivers/net/wireless/ath/ath9k/recv.c
:100644 100644 fd20241... 9c1d529... M drivers/net/wireless/ath/ath9k/virtual.c
drivers/net/wireless/ath/ath9k/htc_drv_txrx.c | 1 + drivers/net/wireless/ath/ath9k/recv.c | 23 ++++++++++++++++------- drivers/net/wireless/ath/ath9k/virtual.c | 12 +++++++----- 3 files changed, 24 insertions(+), 12 deletions(-)
drivers/net/wireless/ath/ath9k/htc_drv_txrx.c +1 -0
@@ -416,6 +416,7 @@ static void ath9k_htc_opmode_init(struct ath9k_htc_priv *priv)/* configure bssid mask */ if (ah->caps.hw_caps &ATH9K_HW_CAP_BSSIDMASK ) +/* NOTE: Maybe this should be ath9k_set_bssid_mask?? */ ath_hw_setbssidmask (common);/* configure operational mode */
drivers/net/wireless/ath/ath9k/recv.c +16 -7
@@ -110,7 +110,6 @@ static void ath_setdefantenna(struct ath_softc *sc, u32 antenna)static void ath_opmode_init (struct ath_softc *sc) {struct ath_hw *ah = sc->sc_ah; -struct ath_common *common =ath9k_hw_common (ah);u32 rfilt, mfilt[2 ];
@@ -118,9 +117,15 @@ static void ath_opmode_init(struct ath_softc *sc) rfilt =ath_calcrxfilter (sc);ath9k_hw_setrxfilter (ah, rfilt); -/* configure bssid mask */ -if (ah->caps.hw_caps &ATH9K_HW_CAP_BSSIDMASK ) -ath_hw_setbssidmask (common); +/* configure bssid mask, if ah->hw is configured. +* it is NOT configured when mac80211 is calling +* ieee80211_do_open, but probably just as well since +* this STA isn't in the list yet. +*/ +if (ah->hw) { +if (ah->caps.hw_caps &ATH9K_HW_CAP_BSSIDMASK ) +ath9k_set_bssid_mask (ah->hw); + }/* configure operational mode */ ath9k_hw_setopmode (ah);
@@ -426,6 +431,8 @@ u32 ath_calcrxfilter(struct ath_softc *sc)#define RX_FILTER_PRESERVE (ATH9K_RX_FILTER_PHYERR | ATH9K_RX_FILTER_PHYRADAR)u32 rfilt; +int avifs =ieee80211_iterate_interfaces_helper (sc->hw, true, false, +NULL ,NULL ); rfilt = (ath9k_hw_getrxfilter (sc->sc_ah) &RX_FILTER_PRESERVE ) |ATH9K_RX_FILTER_UCAST |ATH9K_RX_FILTER_BCAST
@@ -448,7 +455,11 @@ u32 ath_calcrxfilter(struct ath_softc *sc)if (sc->rx.rxfilter &FIF_CONTROL ) rfilt |=ATH9K_RX_FILTER_CONTROL ; +/* If we have more than one active STA, then we need to +* accept more than just MYBEACON. +*/ if ((sc->sc_ah->opmode ==NL80211_IFTYPE_STATION ) && + (avifs <=1 ) && !(sc->rx.rxfilter &FIF_BCN_PRBRESP_PROMISC )) rfilt |=ATH9K_RX_FILTER_MYBEACON ;else
@@ -463,9 +474,7 @@ u32 ath_calcrxfilter(struct ath_softc *sc)if (conf_is_ht (&sc->hw->conf)) rfilt |=ATH9K_RX_FILTER_COMP_BAR ; -if (sc->sec_wiphy || (sc->rx.rxfilter &FIF_OTHER_BSS )) { -/* TODO: only needed if more than one BSSID is in use in -* station/adhoc mode */ +if (sc->sec_wiphy || (avifs >1 ) || (sc->rx.rxfilter &FIF_OTHER_BSS )) {/* The following may also be needed for other older chips */ if (sc->sc_ah->hw_version.macVersion ==AR_SREV_VERSION_9160 ) rfilt |=ATH9K_RX_FILTER_PROM ;
drivers/net/wireless/ath/ath9k/virtual.c +7 -5
@@ -59,15 +59,17 @@ void ath9k_set_bssid_mask(struct ieee80211_hw *hw) }else iter_data.count =0 ; -/* Get list of all active MAC addresses */ +/* Get list of all MAC addresses for STA and ADHOC interfaces. */ spin_lock_bh (&sc->wiphy_lock); -ieee80211_iterate_active_interfaces_atomic (sc->hw, ath9k_vif_iter, - &iter_data); +ieee80211_iterate_interfaces_helper (sc->hw, true, false, + ath9k_vif_iter, + &iter_data);for (i =0 ; i < sc->num_sec_wiphy; i++) {if (sc->sec_wiphy[i] ==NULL )continue ; -ieee80211_iterate_active_interfaces_atomic ( - sc->sec_wiphy[i]->hw, ath9k_vif_iter, &iter_data); +ieee80211_iterate_interfaces_helper ( + sc->sec_wiphy[i]->hw, true, false, + ath9k_vif_iter, &iter_data); }spin_unlock_bh (&sc->wiphy_lock);
Signature · 1 line
1.7.2.2
PATCH 3/3 mac80211: Allow multiple STA on same BSS.
In reply to [email protected]From: Ben Greear <[email protected]>
When adding an STA, the old code checked if there was already an STA with the same BSS. Instead, check to see if there is exactly the same STA in order to allow multiple STA to be associated with the same AP.
---
:100644 100644 687077e... db751f1... M net/mac80211/sta_info.c
net/mac80211/sta_info.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
net/mac80211/sta_info.c +1 -1
@@ -440,7 +440,7 @@ int sta_info_insert_rcu(struct sta_info *sta) __acquires(RCU)spin_lock_irqsave (&local->sta_lock, flags);/* check if STA exists already */ -if (sta_info_get_bss (sdata, sta->sta.addr)) { +if (sta_info_get (sdata, sta->sta.addr)) {spin_unlock_irqrestore (&local->sta_lock, flags);mutex_unlock (&local->sta_mtx);rcu_read_lock ();
Signature · 1 line
1.7.2.2
Re: [virtual-sta 3/3] mac80211: Allow multiple STA on same BSS.
Quoted 6 lines · On 2010-09-10 3:04 PM, [email protected] wrote:
From: Ben Greear <[email protected]>
When adding an STA, the old code checked if there was already an STA with the same BSS. Instead, check to see if there is exactly the same STA in order to allow multiple STA to be associated with the same AP.
I think that's misleading. sta_info_get_bss does not check if there is a STA with the same BSS. Like sta_info_get it looks for a STA with the given address, but unlike sta_info_get, it also accepts it if it's on a different interface than the provided sdata, but part of the same BSS as the sdata's.
Because of that, this change seems bogus to me.
- Felix
Re: [virtual-sta 3/3] mac80211: Allow multiple STA on same BSS.
Quoted 7 lines · Felix Fietkau
Quoted 6 lines · On 2010-09-10 3:04 PM, [email protected] wrote:
From: Ben Greear<[email protected]>
When adding an STA, the old code checked if there was already an STA with the same BSS. Instead, check to see if there is exactly the same STA in order to allow multiple STA to be associated with the same AP.
Quoted 6 lines
I think that's misleading.
sta_info_get_bssdoes not check if there is a STA with the same BSS. Likesta_info_getit looks for a STA with the given address, but unlikesta_info_get, it also accepts it if it's on a different interface than the provided sdata, but part of the same BSS as the sdata's.
Because of that, this change seems bogus to me.
W/out this change, I cannot get a second STA to associate with the AP because that code returns EBUSY, because the first STA and second STA point to the same bss.
There could be a better way to do what I'm trying to do, but that one-line patch made it work for me. I'll be happy to try alternative suggestions.
Thanks,
Ben
Signature · 2 lines
Ben Greear <[email protected]> Candela Technologies Inc http://www.candelatech.com
Re: [virtual-sta 3/3] mac80211: Allow multiple STA on same BSS.
Quoted 15 lines · Ben Greear
Quoted 7 lines · Felix Fietkau
Quoted 6 lines · On 2010-09-10 3:04 PM, [email protected] wrote:
From: Ben Greear<[email protected]>
When adding an STA, the old code checked if there was already an STA with the same BSS. Instead, check to see if there is exactly the same STA in order to allow multiple STA to be associated with the same AP.
Quoted 6 lines
I think that's misleading.
sta_info_get_bssdoes not check if there is a STA with the same BSS. Likesta_info_getit looks for a STA with the given address, but unlikesta_info_get, it also accepts it if it's on a different interface than the provided sdata, but part of the same BSS as the sdata's.
Because of that, this change seems bogus to me.
Quoted 7 lines
W/out this change, I cannot get a second STA to associate with the AP because that code returns EBUSY, because the first STA and second STA point to the same bss.
There could be a better way to do what I'm trying to do, but that one-line patch made it work for me. I'll be happy to try alternative suggestions.
This patch will most likely break other stuff. the sta_info_get -> sta_info_get_bss change was added for a reason. I can look into it later to see what the reason was, but I don't think your change can go in without further review.
- Felix
Johannes Berg
maintainerRe: [virtual-sta 3/3] mac80211: Allow multiple STA on same BSS.
In reply to [email protected]Quoted 6 lines · On Fri, 2010-09-10 at 15:04 -0700, [email protected] wrote:
From: Ben Greear <[email protected]>
When adding an STA, the old code checked if there was already an STA with the same BSS. Instead, check to see if there is exactly the same STA in order to allow multiple STA to be associated with the same AP.
You want this instead:
--- net/mac80211/sta_info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/sta_info.c +1 -1
@@ -125,7 +125,7 @@ struct sta_info *sta_info_get_bss(struct lockdep_is_held(&local->sta_mtx));while (sta) {if ((sta->sdata == sdata || - sta->sdata->bss == sdata->bss) && + (sta->sdata->bss && sta->sdata->bss == sdata->bss)) &&memcmp (sta->sta.addr, addr,ETH_ALEN ) ==0 )break ; sta = rcu_dereference_check(sta->hnext,
johannes
Re: [virtual-sta 3/3] mac80211: Allow multiple STA on same BSS.
Quoted 18 lines · Johannes Berg
Quoted 6 lines · On Fri, 2010-09-10 at 15:04 -0700, [email protected] wrote:
From: Ben Greear<[email protected]>
When adding an STA, the old code checked if there was already an STA with the same BSS. Instead, check to see if there is exactly the same STA in order to allow multiple STA to be associated with the same AP.
You want this instead:
--- net/mac80211/sta_info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/sta_info.c struct sta_info *sta_info_get_bss(struct · line 131
Quoted 8 lines
net/mac80211/sta_info.c +1
-1@@ -125,7 +125,7 @@ struct sta_info *sta_info_get_bss(struct lockdep_is_held(&local->sta_mtx));while (sta) {if ((sta->sdata == sdata || - sta->sdata->bss == sdata->bss)&& + (sta->sdata->bss&& sta->sdata->bss == sdata->bss))&&memcmp (sta->sta.addr, addr,ETH_ALEN ) ==0 )break ; sta = rcu_dereference_check(sta->hnext,
This seems to work fine. Do you want me to respin the patch, or will you push this in?
Thanks,
Ben
Signature · 2 lines
Ben Greear <[email protected]> Candela Technologies Inc http://www.candelatech.com
Johannes Berg
maintainerQuoted 2 lines · On Fri, 2010-09-10 at 15:04 -0700, [email protected] wrote:
This allows callers to specify whether they want all or just active interfaces,
I thought about this, and I don't want to allow drivers to get at inactive interfaces. And with that, I don't think there's a need to restructure the code here. Also, since what you wanted wasn't the count but the STA interface count, you need your own iterator function anyway, no?
johannes
Quoted 10 lines · Johannes Berg
Quoted 2 lines · On Fri, 2010-09-10 at 15:04 -0700, [email protected] wrote:
This allows callers to specify whether they want all or just active interfaces,
I thought about this, and I don't want to allow drivers to get at inactive interfaces. And with that, I don't think there's a need to restructure the code here. Also, since what you wanted wasn't the count but the STA interface count, you need your own iterator function anyway, no?
I'll see if I can get ath9k to use the normal iterator. I didn't need my own iterator, because I could just pass in NULL for iterator and pass active_only as false.
I think you should consider returning the count for the number of times the iterator was called because it's simple code, and it would save the same logic in each driver's iterator methods (or at least, ath9k).
Thanks,
Ben
Signature · 2 lines
Ben Greear <[email protected]> Candela Technologies Inc http://www.candelatech.com
Johannes Berg
maintainerQuoted 3 lines · Ben Greear
I'll see if I can get ath9k to use the normal iterator. I didn't need my own iterator, because I could just pass in NULL for iterator and pass
active_onlyas false.
active_only as false still doesn't seem right. Why would you care about it before an interface is up?
Quoted 3 lines
I think you should consider returning the count for the number of times the iterator was called because it's simple code, and it would save the same logic in each driver's iterator methods (or at least, ath9k).
Yeah, that seems like a good change, but I think we should probably get to the bottom of it first (the sdata->bss change on the other hand seems fine as is)
johannes
Quoted 8 lines · Johannes Berg
Quoted 3 lines · Ben Greear
I'll see if I can get ath9k to use the normal iterator. I didn't need my own iterator, because I could just pass in NULL for iterator and pass
active_onlyas false.
active_onlyas false still doesn't seem right. Why would you care about it before an interface is up?
It 'fixed' the bssid mask logic in ath9k, but based on feedback from ath9k folks, there may be a better way to do that anyway.
I'm going to start integrating the new suggestions now to see if they work.
Thanks,
Ben
Signature · 2 lines
Ben Greear <[email protected]> Candela Technologies Inc http://www.candelatech.com