Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp89114pxa; Fri, 21 Aug 2020 01:51:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkt3vyP8/yDxdHKRtPERc6stt/kgDbDpOW0/dMoHImsUS9Qx3gldEd6yvMRDIehnvz6Bdn X-Received: by 2002:aa7:cd04:: with SMTP id b4mr1737351edw.254.1597999868379; Fri, 21 Aug 2020 01:51:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597999868; cv=none; d=google.com; s=arc-20160816; b=agzkbw9nCb+xqSL/eKV3j8gbbr9C9OlR+vd5yXjH4ZBab9GL/yLO6rgsMh0CBurlRQ CAxjgfTTvx7y4o2TrjbVY5VcUSa0WEo/xHOMzDVDFUcJ2OOPFGzl0j1Yw02t5JPVE+Z6 56vMNr7qWLsTS3xI7SO9HI5WgXgC71wyyUKeDTuYYDj5fQpfAk2WmE5dApiSSp9D/hrm L4Goskx5XB+meJuIYRcCnPmRO7BB0py5Ix2h2MK/Rmp4vFb9JOroDuExGJzMcRN8o0aN zDWruMfsrr2GE3gviGZ/k+9L6YtrV0Z/3pkwNanD1oA4tR6GivdNbI4hh3Deb+KfSAMv KLDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3bKhuwMXKBfq/Ho3kUouM3H0+iWcaoy2ObtimfrkTEM=; b=I2skBj9ik8aZxDoKdKBBAqpU/Wdn8zSjRiqEmNf3LZP6RmerOoqsuAg95I88Tmkd22 wFfi8whuYReDl7OdIiSrCA7/JbBGuA848MFOylVMWiiu7FdSTu9WXiVt16UZVb3VcSLV VG3O9Fu2ECvBtJGKZ7UWi0KnbbpHpy0GQB0RE2kPdT0yxCsI1/E8qkCOLCNIHz+9i46H tGag8LT3MYMSpzETl+Ash7/u/OiAS7m3Y8a5jRIhNRCo9KSw7hbLzt8NhafeIViXATGD GwZOHCL4qc4LIxmFxUIrFS7xdZLhheddLP6k9IUEoS6z9/6z8OR0m/T/AfHsdMXwwZy2 S+Ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=gBWUnMVI; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t14si764319ejb.435.2020.08.21.01.50.43; Fri, 21 Aug 2020 01:51:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=gBWUnMVI; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728140AbgHUItq (ORCPT + 99 others); Fri, 21 Aug 2020 04:49:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728037AbgHUItd (ORCPT ); Fri, 21 Aug 2020 04:49:33 -0400 Received: from nbd.name (nbd.name [IPv6:2a01:4f8:221:3d45::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54A6DC061342 for ; Fri, 21 Aug 2020 01:49:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=3bKhuwMXKBfq/Ho3kUouM3H0+iWcaoy2ObtimfrkTEM=; b=gBWUnMVIBi3lKmNuxEPh3hJuHm NqVt3PAjEeifpRsCq0N82gDm7BUxvgfS0RvF/6ao16kJI6JI8VHFFUyvvtU/FwJAlsQ+3JD8Z82lu wwHyiXzuatZwk41pkntav4grZFpt+4FB55nGQMbZjq1elk6AR+0rwdr/ZE0wT1HT11MU=; Received: from p5b206497.dip0.t-ipconnect.de ([91.32.100.151] helo=localhost.localdomain) by ds12 with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.89) (envelope-from ) id 1k92jp-0005lO-NS; Fri, 21 Aug 2020 10:49:29 +0200 From: Felix Fietkau To: linux-wireless@vger.kernel.org Cc: johannes@sipsolutions.net Subject: [PATCH v3 04/13] mac80211: optimize station connection monitor Date: Fri, 21 Aug 2020 10:49:17 +0200 Message-Id: <20200821084926.10650-5-nbd@nbd.name> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200821084926.10650-1-nbd@nbd.name> References: <20200821084926.10650-1-nbd@nbd.name> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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 --- net/mac80211/ieee80211_i.h | 2 -- net/mac80211/mlme.c | 53 ++++++++++++++++---------------------- net/mac80211/rx.c | 9 ------- net/mac80211/sta_info.h | 2 -- net/mac80211/status.c | 3 --- 5 files changed, 22 insertions(+), 47 deletions(-) diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index b6fb85ff3ce4..54f2bf67d2cc 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -2039,8 +2039,6 @@ void ieee80211_dynamic_ps_timer(struct timer_list *t); void ieee80211_send_nullfunc(struct ieee80211_local *local, struct ieee80211_sub_if_data *sdata, bool powersave); -void ieee80211_sta_rx_notify(struct ieee80211_sub_if_data *sdata, - struct ieee80211_hdr *hdr); void ieee80211_sta_tx_notify(struct ieee80211_sub_if_data *sdata, struct ieee80211_hdr *hdr, bool ack, u16 tx_time); diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index ac870309b911..f241decf843d 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -2432,23 +2432,6 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata, sdata->encrypt_headroom = IEEE80211_ENCRYPT_HEADROOM; } -void ieee80211_sta_rx_notify(struct ieee80211_sub_if_data *sdata, - struct ieee80211_hdr *hdr) -{ - /* - * We can postpone the mgd.timer whenever receiving unicast frames - * from AP because we know that the connection is working both ways - * at that time. But multicast frames (and hence also beacons) must - * be ignored here, because we need to trigger the timer during - * data idle periods for sending the periodic probe request to the - * AP we're connected to. - */ - if (is_multicast_ether_addr(hdr->addr1)) - return; - - ieee80211_sta_reset_conn_monitor(sdata); -} - static void ieee80211_reset_ap_probe(struct ieee80211_sub_if_data *sdata) { struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; @@ -2521,21 +2504,13 @@ void ieee80211_sta_tx_notify(struct ieee80211_sub_if_data *sdata, { ieee80211_sta_tx_wmm_ac_notify(sdata, hdr, tx_time); - if (!ieee80211_is_data(hdr->frame_control)) - return; - - if (ieee80211_is_any_nullfunc(hdr->frame_control) && - sdata->u.mgd.probe_send_count > 0) { - if (ack) - ieee80211_sta_reset_conn_monitor(sdata); - else - sdata->u.mgd.nullfunc_failed = true; - ieee80211_queue_work(&sdata->local->hw, &sdata->work); + if (!ieee80211_is_any_nullfunc(hdr->frame_control) || + !sdata->u.mgd.probe_send_count) return; - } - if (ack) - ieee80211_sta_reset_conn_monitor(sdata); + if (!ack) + sdata->u.mgd.nullfunc_failed = true; + ieee80211_queue_work(&sdata->local->hw, &sdata->work); } static void ieee80211_mlme_send_probe_req(struct ieee80211_sub_if_data *sdata, @@ -3605,8 +3580,8 @@ static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata, * Start timer to probe the connection to the AP now. * Also start the timer that will detect beacon loss. */ - ieee80211_sta_rx_notify(sdata, (struct ieee80211_hdr *)mgmt); ieee80211_sta_reset_beacon_monitor(sdata); + ieee80211_sta_reset_conn_monitor(sdata); ret = true; out: @@ -4577,10 +4552,26 @@ static void ieee80211_sta_conn_mon_timer(struct timer_list *t) from_timer(sdata, t, u.mgd.conn_mon_timer); struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; struct ieee80211_local *local = sdata->local; + struct sta_info *sta; + unsigned long timeout; if (sdata->vif.csa_active && !ifmgd->csa_waiting_bcn) return; + sta = sta_info_get(sdata, ifmgd->bssid); + if (!sta) + return; + + timeout = sta->status_stats.last_ack; + if (time_before(sta->status_stats.last_ack, sta->rx_stats.last_rx)) + timeout = sta->rx_stats.last_rx; + timeout += IEEE80211_CONNECTION_IDLE_TIME; + + if (time_is_before_jiffies(timeout)) { + mod_timer(&ifmgd->conn_mon_timer, round_jiffies_up(timeout)); + return; + } + ieee80211_queue_work(&local->hw, &ifmgd->monitor_work); } diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 836cde516a18..bd8c15a65a16 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -1811,9 +1811,6 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx) sta->rx_stats.last_rate = sta_stats_encode_rate(status); } - if (rx->sdata->vif.type == NL80211_IFTYPE_STATION) - ieee80211_sta_rx_notify(rx->sdata, hdr); - sta->rx_stats.fragments++; u64_stats_update_begin(&rx->sta->rx_stats.syncp); @@ -4148,7 +4145,6 @@ void ieee80211_check_fast_rx(struct sta_info *sta) fastrx.sa_offs = offsetof(struct ieee80211_hdr, addr2); fastrx.expected_ds_bits = 0; } else { - fastrx.sta_notify = sdata->u.mgd.probe_send_count > 0; fastrx.da_offs = offsetof(struct ieee80211_hdr, addr1); fastrx.sa_offs = offsetof(struct ieee80211_hdr, addr3); fastrx.expected_ds_bits = @@ -4378,11 +4374,6 @@ static bool ieee80211_invoke_fast_rx(struct ieee80211_rx_data *rx, pskb_trim(skb, skb->len - fast_rx->icv_len)) goto drop; - if (unlikely(fast_rx->sta_notify)) { - ieee80211_sta_rx_notify(rx->sdata, hdr); - fast_rx->sta_notify = false; - } - /* statistics part of ieee80211_rx_h_sta_process() */ if (!(status->flag & RX_FLAG_NO_SIGNAL_VAL)) { stats->last_signal = status->signal; diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h index 459310d2b921..51b284852dfd 100644 --- a/net/mac80211/sta_info.h +++ b/net/mac80211/sta_info.h @@ -336,7 +336,6 @@ struct ieee80211_fast_tx { * @expected_ds_bits: from/to DS bits expected * @icv_len: length of the MIC if present * @key: bool indicating encryption is expected (key is set) - * @sta_notify: notify the MLME code (once) * @internal_forward: forward froms internally on AP/VLAN type interfaces * @uses_rss: copy of USES_RSS hw flag * @da_offs: offset of the DA in the header (for header conversion) @@ -352,7 +351,6 @@ struct ieee80211_fast_rx { __le16 expected_ds_bits; u8 icv_len; u8 key:1, - sta_notify:1, internal_forward:1, uses_rss:1; u8 da_offs, sa_offs; diff --git a/net/mac80211/status.c b/net/mac80211/status.c index 67df7a5acee5..28ab29a5694d 100644 --- a/net/mac80211/status.c +++ b/net/mac80211/status.c @@ -1214,9 +1214,6 @@ void ieee80211_tx_status_8023(struct ieee80211_hw *hw, sta->status_stats.retry_count += retry_count; if (ieee80211_hw_check(hw, REPORTS_TX_ACK_STATUS)) { - if (acked && vif->type == NL80211_IFTYPE_STATION) - ieee80211_sta_reset_conn_monitor(sdata); - sta->status_stats.last_ack = jiffies; if (info->flags & IEEE80211_TX_STAT_ACK) { if (sta->status_stats.lost_packets) -- 2.28.0