Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp4063480iog; Tue, 28 Jun 2022 08:16:31 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u6fFgJ22agJ2chiUpIoemRB1ENpHO3qPl6W3JeepW8psnHxoo3vLUssGOzQds/gj+3HrPw X-Received: by 2002:a63:84c6:0:b0:40d:4364:ca31 with SMTP id k189-20020a6384c6000000b0040d4364ca31mr18145000pgd.144.1656429390923; Tue, 28 Jun 2022 08:16:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656429390; cv=none; d=google.com; s=arc-20160816; b=KrJBJsZMpr6E4yCCR8eEPJ/9Ah5HJOGMjiwweol4VZ3CP82G8xnUyoQRo11ZB1wvXK QYH0GWkkeI1FSjut91hfocPIDWABtBnG8/tYPuV1KZA8lvZWjl/SvfUwebo4Xew8cE98 J9iSqV5BNq9Tk6aPQkVoQfMiATSzQ2JrcVKn4fRZbmEKHZiLl8dIwoCNZ0cKL/mqSXc7 MPD4BMv/87ogDSwWs4Yj8WUYziJ4WimGnlYqV/HfgrkVrpw06fnzikmCQl7xnaMLQDov N4mY688DKnYfuQI0uQxyRug8Jx8jLuzrVrcyjiQCsdt2eIYtC17dKl6rWAGSl2y+yiL4 Ot0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=wiuDeGvogiQckUXaPkS+dYAGC+MlxCfzFSG7qobyBGk=; b=DCAQsbK7peMqO8QlHXzGqO2ndBsJwdet77BVhjoMTKTl6p5IWlTcqtD5MukbSw9Kx7 1JMUAuqK09pEG/VV8HeCYOU1U+wLh7ZDo3u2BZnFvq9KbvXMrKqo3M1zWml6JNvlXCTs 5CU9Zi5EEYaWuRVRA03+9ARdcVjTMUKBKNToNP3vse/mrF6nUprtJL7nZB0UxkyDlBnw how5eT03rUbn4Ma4A5g5tmVNWIs5Jkq7dZ/z47tW8PgIJCpoa/9+B9PO8LfooDc3KNqz oVctyw8iCc7yPdAYDY4pxAG3nHFTxuZskiKlEZK6raIZMLWuOrq5th5S6TPICyW8W1vY mQMA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p4-20020a056a000b4400b00506475da4desi10755238pfo.151.2022.06.28.08.16.21; Tue, 28 Jun 2022 08:16:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348131AbiF1PPm (ORCPT + 64 others); Tue, 28 Jun 2022 11:15:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348083AbiF1PPQ (ORCPT ); Tue, 28 Jun 2022 11:15:16 -0400 X-Greylist: delayed 582 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 28 Jun 2022 08:15:04 PDT Received: from simonwunderlich.de (simonwunderlich.de [23.88.38.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEDC031343 for ; Tue, 28 Jun 2022 08:15:04 -0700 (PDT) Received: from localhost (p200300c5974564900000000000000607.dip0.t-ipconnect.de [IPv6:2003:c5:9745:6490::607]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simonwunderlich.de (Postfix) with ESMTPSA id 4A8E1FA22B; Tue, 28 Jun 2022 17:05:20 +0200 (CEST) From: Issam Hamdi To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, sw@simonwunderlich.de, Issam Hamdi Subject: [PATCH] wifi: mac80211: fix get inactive time for station mode Date: Tue, 28 Jun 2022 17:05:11 +0200 Message-Id: <20220628150511.1185132-1-ih@simonwunderlich.de> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org In station mode, the value last_rx is not updated often. Therefore the calculation of the inactive time will be wrong (will give values between 1000 ms to 30000 ms). To fix this add the update of "sta->deflink.rx_stats.last_rx" for station mode in the response of the packets process (ieee80211_rx_h_sta_process). Signed-off-by: Issam Hamdi --- net/mac80211/rx.c | 3 +++ net/mac80211/sta_info.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index d017ad14d7db..6ce899b18614 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -1756,6 +1756,9 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx) sta->deflink.rx_stats.last_rate = sta_stats_encode_rate(status); } + if (rx->sdata->vif.type == NL80211_IFTYPE_STATION) + sta->deflink.rx_stats.last_rx = jiffies; + sta->deflink.rx_stats.fragments++; u64_stats_update_begin(&rx->sta->deflink.rx_stats.syncp); diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index 014032369994..88a9f81e7083 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c @@ -2430,7 +2430,7 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo, sinfo->connected_time = ktime_get_seconds() - sta->last_connected; sinfo->assoc_at = sta->assoc_at; sinfo->inactive_time = - jiffies_to_msecs(jiffies - ieee80211_sta_last_active(sta)); + jiffies_to_msecs(abs(jiffies - ieee80211_sta_last_active(sta))); if (!(sinfo->filled & (BIT_ULL(NL80211_STA_INFO_TX_BYTES64) | BIT_ULL(NL80211_STA_INFO_TX_BYTES)))) { -- 2.30.2