2017-10-29 09:51:19

by Luca Coelho

[permalink] [raw]
Subject: [PATCH 0/5] cfg80211/mac80211 patches from our internal tree 2017-10-29

From: Luca Coelho <[email protected]>

Hi,

Here are some cfg80211/mac80211 patches from our internal tree.

Please review.

Cheers,
Luca.


Emmanuel Grumbach (1):
mac80211: always update the PM state of a peer on MGMT / DATA frames

Luca Coelho (1):
mac80211: remove BUG() when interface type is invalid

Sara Sharon (2):
mac80211: call synchronize_net once in the restart flow
mac80211: tear down RX aggregations first

Tova Mussai (1):
cfg80211: IBSS: Add support for static WEP in driver for IBSS

include/net/cfg80211.h | 5 +++++
net/mac80211/agg-tx.c | 3 ++-
net/mac80211/ht.c | 4 +++-
net/mac80211/iface.c | 2 +-
net/mac80211/main.c | 3 +++
net/mac80211/rx.c | 17 +++++------------
net/mac80211/util.c | 19 ++++++++++---------
net/wireless/ibss.c | 5 +++++
8 files changed, 34 insertions(+), 24 deletions(-)

--
2.14.2


2017-10-29 09:51:19

by Luca Coelho

[permalink] [raw]
Subject: [PATCH 2/5] mac80211: call synchronize_net once in the restart flow

From: Sara Sharon <[email protected]>

Currently the restart flow enables RX back, and then proceeds
to tear down RX and TX aggregations.
The TX aggregation tear down calls synchronize_net(), which
waits for packet receiving to be done.
This is done for every session, while RX processing is already
active, and in some reproductions it takes up to 3 seconds.
Add a call once in the restart_work, before we have traffic
active again, and remove the subsequent calls when tearing
down the aggregation.
This requires to move down the code that turns off the
reconfig flag in order to be able to test it in
_ieee80211_stop_tx_ba_session().

Signed-off-by: Sara Sharon <[email protected]>
Signed-off-by: Luca Coelho <[email protected]>
---
net/mac80211/agg-tx.c | 3 ++-
net/mac80211/main.c | 3 +++
net/mac80211/util.c | 19 ++++++++++---------
3 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/net/mac80211/agg-tx.c b/net/mac80211/agg-tx.c
index 1d0bf857a3b5..96d1013d277d 100644
--- a/net/mac80211/agg-tx.c
+++ b/net/mac80211/agg-tx.c
@@ -387,7 +387,8 @@ int ___ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid,
* telling the driver. New packets will not go through since
* the aggregation session is no longer OPERATIONAL.
*/
- synchronize_net();
+ if (!local->in_reconfig)
+ synchronize_net();

tid_tx->stop_initiator = reason == AGG_STOP_PEER_REQUEST ?
WLAN_BACK_RECIPIENT :
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index e054a2fd8d38..0785d04a80bc 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -263,6 +263,9 @@ static void ieee80211_restart_work(struct work_struct *work)
flush_delayed_work(&local->roc_work);
flush_work(&local->hw_roc_done);

+ /* wait for all packet processing to be done */
+ synchronize_net();
+
ieee80211_reconfig(local);
rtnl_unlock();
}
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index d57e5f6bd8b6..1f82191ce601 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -2110,15 +2110,6 @@ int ieee80211_reconfig(struct ieee80211_local *local)
cfg80211_sched_scan_stopped_rtnl(local->hw.wiphy, 0);

wake_up:
- if (local->in_reconfig) {
- local->in_reconfig = false;
- barrier();
-
- /* Restart deferred ROCs */
- mutex_lock(&local->mtx);
- ieee80211_start_next_roc(local);
- mutex_unlock(&local->mtx);
- }

if (local->monitors == local->open_count && local->monitors > 0)
ieee80211_add_virtual_monitor(local);
@@ -2146,6 +2137,16 @@ int ieee80211_reconfig(struct ieee80211_local *local)
mutex_unlock(&local->sta_mtx);
}

+ if (local->in_reconfig) {
+ local->in_reconfig = false;
+ barrier();
+
+ /* Restart deferred ROCs */
+ mutex_lock(&local->mtx);
+ ieee80211_start_next_roc(local);
+ mutex_unlock(&local->mtx);
+ }
+
ieee80211_wake_queues_by_reason(hw, IEEE80211_MAX_QUEUE_MAP,
IEEE80211_QUEUE_STOP_REASON_SUSPEND,
false);
--
2.14.2

2017-10-29 09:51:21

by Luca Coelho

[permalink] [raw]
Subject: [PATCH 5/5] cfg80211: IBSS: Add support for static WEP in driver for IBSS

From: Tova Mussai <[email protected]>

Add support for drivers that implement static WEP internally for IBSS.
Add the WEP keys to the IBSS params struct, that will allow the driver
to use the keys in the join flow, and not only after the connection.

Signed-off-by: Tova Mussai <[email protected]>
Signed-off-by: Luca Coelho <[email protected]>
---
include/net/cfg80211.h | 5 +++++
net/wireless/ibss.c | 5 +++++
2 files changed, 10 insertions(+)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 8b8118a7fadb..698cebf2de2a 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -2021,6 +2021,9 @@ struct cfg80211_disassoc_request {
* @ht_capa: HT Capabilities over-rides. Values set in ht_capa_mask
* will be used in ht_capa. Un-supported values will be ignored.
* @ht_capa_mask: The bits of ht_capa which are to be used.
+ * @wep_keys: static WEP keys, if not NULL points to an array of
+ * CFG80211_MAX_WEP_KEYS WEP keys
+ * @wep_tx_key: key index (0..3) of the default TX static WEP key
*/
struct cfg80211_ibss_params {
const u8 *ssid;
@@ -2037,6 +2040,8 @@ struct cfg80211_ibss_params {
int mcast_rate[NUM_NL80211_BANDS];
struct ieee80211_ht_cap ht_capa;
struct ieee80211_ht_cap ht_capa_mask;
+ struct key_params *wep_keys;
+ int wep_tx_key;
};

/**
diff --git a/net/wireless/ibss.c b/net/wireless/ibss.c
index 10bf040a0982..6a4ad21174d5 100644
--- a/net/wireless/ibss.c
+++ b/net/wireless/ibss.c
@@ -125,6 +125,11 @@ static int __cfg80211_join_ibss(struct cfg80211_registered_device *rdev,
wdev->ibss_fixed = params->channel_fixed;
wdev->ibss_dfs_possible = params->userspace_handles_dfs;
wdev->chandef = params->chandef;
+ if (connkeys) {
+ params->wep_keys = connkeys->params;
+ params->wep_tx_key = connkeys->def;
+ }
+
#ifdef CONFIG_CFG80211_WEXT
wdev->wext.ibss.chandef = params->chandef;
#endif
--
2.14.2

2017-10-29 09:51:20

by Luca Coelho

[permalink] [raw]
Subject: [PATCH 4/5] mac80211: remove BUG() when interface type is invalid

From: Luca Coelho <[email protected]>

In the ieee80211_setup_sdata() we check if the interface type is valid
and, if not, call BUG(). This should never happen, but if there is
something wrong with the code, it will not be caught until the bug
happens when an interface is being set up. Calling BUG() is too
extreme for this and a WARN_ON() would be better used instead. Change
that.

Signed-off-by: Luca Coelho <[email protected]>
---
net/mac80211/iface.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index 435e7358004c..5fe01f82df12 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -1474,7 +1474,7 @@ static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata,
break;
case NL80211_IFTYPE_UNSPECIFIED:
case NUM_NL80211_IFTYPES:
- BUG();
+ WARN_ON(1);
break;
}

--
2.14.2

2017-10-30 08:48:23

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 1/5] mac80211: always update the PM state of a peer on MGMT / DATA frames

On Sun, 2017-10-29 at 11:51 +0200, Luca Coelho wrote:
> From: Emmanuel Grumbach <[email protected]>
>
> The 2016 version of the spec is more generic about when the
> AP should update the power management state of the peer:
> the AP shall update the state based on any management or
> data frames. This means that even non-bufferable management
> frames should be looked at to update to maintain the power
> management state of the peer.
>
> This can avoid problematic cases for example if a station
> disappears while being asleep and then re-appears. The AP
> would remember it as in power save, but the Authentication
> frame couldn't be used to set the peer as awake again.
> Note that this issues wasn't really critical since at some
> point (after the association) we would have removed the
> station and created another one with all the states cleared.

IIRC this caused a hwsim test failure - is that addressed yet?

johannes

2017-10-29 09:51:20

by Luca Coelho

[permalink] [raw]
Subject: [PATCH 3/5] mac80211: tear down RX aggregations first

From: Sara Sharon <[email protected]>

When doing HW restart we tear down aggregations.
Since at this point we are not TX'ing any aggregation, while
the peer is still sending RX aggregation over the air, it will
make sense to tear down the RX aggregations first.

Signed-off-by: Sara Sharon <[email protected]>
Signed-off-by: Luca Coelho <[email protected]>
---
net/mac80211/ht.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/mac80211/ht.c b/net/mac80211/ht.c
index e55dabf42722..cb0860d751fd 100644
--- a/net/mac80211/ht.c
+++ b/net/mac80211/ht.c
@@ -292,7 +292,6 @@ void ieee80211_sta_tear_down_BA_sessions(struct sta_info *sta,

mutex_lock(&sta->ampdu_mlme.mtx);
for (i = 0; i < IEEE80211_NUM_TIDS; i++) {
- ___ieee80211_stop_tx_ba_session(sta, i, reason);
___ieee80211_stop_rx_ba_session(sta, i, WLAN_BACK_RECIPIENT,
WLAN_REASON_QSTA_LEAVE_QBSS,
reason != AGG_STOP_DESTROY_STA &&
@@ -300,6 +299,9 @@ void ieee80211_sta_tear_down_BA_sessions(struct sta_info *sta,
}
mutex_unlock(&sta->ampdu_mlme.mtx);

+ for (i = 0; i < IEEE80211_NUM_TIDS; i++)
+ ___ieee80211_stop_tx_ba_session(sta, i, reason);
+
/* stopping might queue the work again - so cancel only afterwards */
cancel_work_sync(&sta->ampdu_mlme.work);

--
2.14.2

2017-10-29 09:51:19

by Luca Coelho

[permalink] [raw]
Subject: [PATCH 1/5] mac80211: always update the PM state of a peer on MGMT / DATA frames

From: Emmanuel Grumbach <[email protected]>

The 2016 version of the spec is more generic about when the
AP should update the power management state of the peer:
the AP shall update the state based on any management or
data frames. This means that even non-bufferable management
frames should be looked at to update to maintain the power
management state of the peer.

This can avoid problematic cases for example if a station
disappears while being asleep and then re-appears. The AP
would remember it as in power save, but the Authentication
frame couldn't be used to set the peer as awake again.
Note that this issues wasn't really critical since at some
point (after the association) we would have removed the
station and created another one with all the states cleared.

Signed-off-by: Emmanuel Grumbach <[email protected]>
Signed-off-by: Luca Coelho <[email protected]>
---
net/mac80211/rx.c | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 70e9d2ca8bbe..b3cff69bfd66 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -1607,23 +1607,16 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx)

/*
* Change STA power saving mode only at the end of a frame
- * exchange sequence.
+ * exchange sequence, and only for a data or management
+ * frame as specified in IEEE 802.11-2016 11.2.3.2
*/
if (!ieee80211_hw_check(&sta->local->hw, AP_LINK_PS) &&
!ieee80211_has_morefrags(hdr->frame_control) &&
- !ieee80211_is_back_req(hdr->frame_control) &&
+ (ieee80211_is_mgmt(hdr->frame_control) ||
+ ieee80211_is_data(hdr->frame_control)) &&
!(status->rx_flags & IEEE80211_RX_DEFERRED_RELEASE) &&
(rx->sdata->vif.type == NL80211_IFTYPE_AP ||
- rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN) &&
- /*
- * PM bit is only checked in frames where it isn't reserved,
- * in AP mode it's reserved in non-bufferable management frames
- * (cf. IEEE 802.11-2012 8.2.4.1.7 Power Management field)
- * BAR frames should be ignored as specified in
- * IEEE 802.11-2012 10.2.1.2.
- */
- (!ieee80211_is_mgmt(hdr->frame_control) ||
- ieee80211_is_bufferable_mmpdu(hdr->frame_control))) {
+ rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN)) {
if (test_sta_flag(sta, WLAN_STA_PS_STA)) {
if (!ieee80211_has_pm(hdr->frame_control))
sta_ps_end(sta);
--
2.14.2

2017-12-01 13:07:42

by Luciano Coelho

[permalink] [raw]
Subject: Re: [PATCH 1/5] mac80211: always update the PM state of a peer on MGMT / DATA frames

On Fri, 2017-12-01 at 13:09 +0100, Johannes Berg wrote:
> On Fri, 2017-12-01 at 13:48 +0200, Luciano Coelho wrote:
> >
> > FTR, I'm sending a separate patch with the hwsim fix, as we agreed,
> > as
> > part of the patchset I'm sending today.
> >
>
> Still need a fix to the test case as well though :-)

Yeah, I guess you should hold this patch until the test fix reaches
hostap. I'll leave that coordination with you. ;)

--
Cheers,
Luca.

2017-12-01 12:09:31

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH 1/5] mac80211: always update the PM state of a peer on MGMT / DATA frames

On Fri, 2017-12-01 at 13:48 +0200, Luciano Coelho wrote:
>
> FTR, I'm sending a separate patch with the hwsim fix, as we agreed, as
> part of the patchset I'm sending today.
>

Still need a fix to the test case as well though :-)

johannes

2017-12-01 11:48:48

by Luciano Coelho

[permalink] [raw]
Subject: Re: [PATCH 1/5] mac80211: always update the PM state of a peer on MGMT / DATA frames

On Mon, 2017-10-30 at 09:48 +0100, Johannes Berg wrote:
> On Sun, 2017-10-29 at 11:51 +0200, Luca Coelho wrote:
> > From: Emmanuel Grumbach <[email protected]>
> >
> > The 2016 version of the spec is more generic about when the
> > AP should update the power management state of the peer:
> > the AP shall update the state based on any management or
> > data frames. This means that even non-bufferable management
> > frames should be looked at to update to maintain the power
> > management state of the peer.
> >
> > This can avoid problematic cases for example if a station
> > disappears while being asleep and then re-appears. The AP
> > would remember it as in power save, but the Authentication
> > frame couldn't be used to set the peer as awake again.
> > Note that this issues wasn't really critical since at some
> > point (after the association) we would have removed the
> > station and created another one with all the states cleared.
>
> IIRC this caused a hwsim test failure - is that addressed yet?

FTR, I'm sending a separate patch with the hwsim fix, as we agreed, as
part of the patchset I'm sending today.

--
Luca.