Skip to content

Commit 9abf4e4

Browse files
nbd168jmberg-intel
authored andcommitted
mac80211: optimize station connection monitor
Calling mod_timer for every rx/tx packet can be quite expensive. Instead of constantly updating the timer, we can simply let it run out and check the timestamp of the last ACK or rx packet to re-arm it. Signed-off-by: Felix Fietkau <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Johannes Berg <[email protected]>
1 parent 1ff4e8f commit 9abf4e4

File tree

5 files changed

+22
-47
lines changed

5 files changed

+22
-47
lines changed

net/mac80211/ieee80211_i.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2039,8 +2039,6 @@ void ieee80211_dynamic_ps_timer(struct timer_list *t);
20392039
void ieee80211_send_nullfunc(struct ieee80211_local *local,
20402040
struct ieee80211_sub_if_data *sdata,
20412041
bool powersave);
2042-
void ieee80211_sta_rx_notify(struct ieee80211_sub_if_data *sdata,
2043-
struct ieee80211_hdr *hdr);
20442042
void ieee80211_sta_tx_notify(struct ieee80211_sub_if_data *sdata,
20452043
struct ieee80211_hdr *hdr, bool ack, u16 tx_time);
20462044

net/mac80211/mlme.c

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2432,23 +2432,6 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
24322432
sdata->encrypt_headroom = IEEE80211_ENCRYPT_HEADROOM;
24332433
}
24342434

2435-
void ieee80211_sta_rx_notify(struct ieee80211_sub_if_data *sdata,
2436-
struct ieee80211_hdr *hdr)
2437-
{
2438-
/*
2439-
* We can postpone the mgd.timer whenever receiving unicast frames
2440-
* from AP because we know that the connection is working both ways
2441-
* at that time. But multicast frames (and hence also beacons) must
2442-
* be ignored here, because we need to trigger the timer during
2443-
* data idle periods for sending the periodic probe request to the
2444-
* AP we're connected to.
2445-
*/
2446-
if (is_multicast_ether_addr(hdr->addr1))
2447-
return;
2448-
2449-
ieee80211_sta_reset_conn_monitor(sdata);
2450-
}
2451-
24522435
static void ieee80211_reset_ap_probe(struct ieee80211_sub_if_data *sdata)
24532436
{
24542437
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
@@ -2521,21 +2504,13 @@ void ieee80211_sta_tx_notify(struct ieee80211_sub_if_data *sdata,
25212504
{
25222505
ieee80211_sta_tx_wmm_ac_notify(sdata, hdr, tx_time);
25232506

2524-
if (!ieee80211_is_data(hdr->frame_control))
2525-
return;
2526-
2527-
if (ieee80211_is_any_nullfunc(hdr->frame_control) &&
2528-
sdata->u.mgd.probe_send_count > 0) {
2529-
if (ack)
2530-
ieee80211_sta_reset_conn_monitor(sdata);
2531-
else
2532-
sdata->u.mgd.nullfunc_failed = true;
2533-
ieee80211_queue_work(&sdata->local->hw, &sdata->work);
2507+
if (!ieee80211_is_any_nullfunc(hdr->frame_control) ||
2508+
!sdata->u.mgd.probe_send_count)
25342509
return;
2535-
}
25362510

2537-
if (ack)
2538-
ieee80211_sta_reset_conn_monitor(sdata);
2511+
if (!ack)
2512+
sdata->u.mgd.nullfunc_failed = true;
2513+
ieee80211_queue_work(&sdata->local->hw, &sdata->work);
25392514
}
25402515

25412516
static void ieee80211_mlme_send_probe_req(struct ieee80211_sub_if_data *sdata,
@@ -3608,8 +3583,8 @@ static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata,
36083583
* Start timer to probe the connection to the AP now.
36093584
* Also start the timer that will detect beacon loss.
36103585
*/
3611-
ieee80211_sta_rx_notify(sdata, (struct ieee80211_hdr *)mgmt);
36123586
ieee80211_sta_reset_beacon_monitor(sdata);
3587+
ieee80211_sta_reset_conn_monitor(sdata);
36133588

36143589
ret = true;
36153590
out:
@@ -4580,10 +4555,26 @@ static void ieee80211_sta_conn_mon_timer(struct timer_list *t)
45804555
from_timer(sdata, t, u.mgd.conn_mon_timer);
45814556
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
45824557
struct ieee80211_local *local = sdata->local;
4558+
struct sta_info *sta;
4559+
unsigned long timeout;
45834560

45844561
if (sdata->vif.csa_active && !ifmgd->csa_waiting_bcn)
45854562
return;
45864563

4564+
sta = sta_info_get(sdata, ifmgd->bssid);
4565+
if (!sta)
4566+
return;
4567+
4568+
timeout = sta->status_stats.last_ack;
4569+
if (time_before(sta->status_stats.last_ack, sta->rx_stats.last_rx))
4570+
timeout = sta->rx_stats.last_rx;
4571+
timeout += IEEE80211_CONNECTION_IDLE_TIME;
4572+
4573+
if (time_is_before_jiffies(timeout)) {
4574+
mod_timer(&ifmgd->conn_mon_timer, round_jiffies_up(timeout));
4575+
return;
4576+
}
4577+
45874578
ieee80211_queue_work(&local->hw, &ifmgd->monitor_work);
45884579
}
45894580

net/mac80211/rx.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1811,9 +1811,6 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx)
18111811
sta->rx_stats.last_rate = sta_stats_encode_rate(status);
18121812
}
18131813

1814-
if (rx->sdata->vif.type == NL80211_IFTYPE_STATION)
1815-
ieee80211_sta_rx_notify(rx->sdata, hdr);
1816-
18171814
sta->rx_stats.fragments++;
18181815

18191816
u64_stats_update_begin(&rx->sta->rx_stats.syncp);
@@ -4148,7 +4145,6 @@ void ieee80211_check_fast_rx(struct sta_info *sta)
41484145
fastrx.sa_offs = offsetof(struct ieee80211_hdr, addr2);
41494146
fastrx.expected_ds_bits = 0;
41504147
} else {
4151-
fastrx.sta_notify = sdata->u.mgd.probe_send_count > 0;
41524148
fastrx.da_offs = offsetof(struct ieee80211_hdr, addr1);
41534149
fastrx.sa_offs = offsetof(struct ieee80211_hdr, addr3);
41544150
fastrx.expected_ds_bits =
@@ -4378,11 +4374,6 @@ static bool ieee80211_invoke_fast_rx(struct ieee80211_rx_data *rx,
43784374
pskb_trim(skb, skb->len - fast_rx->icv_len))
43794375
goto drop;
43804376

4381-
if (unlikely(fast_rx->sta_notify)) {
4382-
ieee80211_sta_rx_notify(rx->sdata, hdr);
4383-
fast_rx->sta_notify = false;
4384-
}
4385-
43864377
/* statistics part of ieee80211_rx_h_sta_process() */
43874378
if (!(status->flag & RX_FLAG_NO_SIGNAL_VAL)) {
43884379
stats->last_signal = status->signal;

net/mac80211/sta_info.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,6 @@ struct ieee80211_fast_tx {
336336
* @expected_ds_bits: from/to DS bits expected
337337
* @icv_len: length of the MIC if present
338338
* @key: bool indicating encryption is expected (key is set)
339-
* @sta_notify: notify the MLME code (once)
340339
* @internal_forward: forward froms internally on AP/VLAN type interfaces
341340
* @uses_rss: copy of USES_RSS hw flag
342341
* @da_offs: offset of the DA in the header (for header conversion)
@@ -352,7 +351,6 @@ struct ieee80211_fast_rx {
352351
__le16 expected_ds_bits;
353352
u8 icv_len;
354353
u8 key:1,
355-
sta_notify:1,
356354
internal_forward:1,
357355
uses_rss:1;
358356
u8 da_offs, sa_offs;

net/mac80211/status.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,9 +1218,6 @@ void ieee80211_tx_status_8023(struct ieee80211_hw *hw,
12181218
sta->status_stats.retry_count += retry_count;
12191219

12201220
if (ieee80211_hw_check(hw, REPORTS_TX_ACK_STATUS)) {
1221-
if (acked && vif->type == NL80211_IFTYPE_STATION)
1222-
ieee80211_sta_reset_conn_monitor(sdata);
1223-
12241221
sta->status_stats.last_ack = jiffies;
12251222
if (info->flags & IEEE80211_TX_STAT_ACK) {
12261223
if (sta->status_stats.lost_packets)

0 commit comments

Comments
 (0)