From patchwork Wed Jan 17 07:31:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamizh chelvam X-Patchwork-Id: 10168683 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A7241601D3 for ; Wed, 17 Jan 2018 07:34:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9512926255 for ; Wed, 17 Jan 2018 07:34:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 89A8A28179; Wed, 17 Jan 2018 07:34:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1EEC326255 for ; Wed, 17 Jan 2018 07:34:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752402AbeAQHel (ORCPT ); Wed, 17 Jan 2018 02:34:41 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:33126 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752389AbeAQHek (ORCPT ); Wed, 17 Jan 2018 02:34:40 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 9832D608CB; Wed, 17 Jan 2018 07:34:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1516174479; bh=3HQi8E9ZbaNRyllFZvARg6qJWfaqGZ1VAWheGke68/U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CR3xxgUD3sVyW9EaIE3g6tRa7muf50bSN6KkEkeUxsJRwl2MjGBiZeG8ZvieF/LPh Bl9WuLcoREGHubWBU5js8V80j+efmTYXQqMOyQDu8JIchBaFVn+ZpXOfyqAP+BzdKU k8qKdy37ShJ0xq0ZfLsresCZe94uQ7HpmCP62zSU= Received: from cheath10p342229-lin.qca.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: tamizhr@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 0D89260854; Wed, 17 Jan 2018 07:34:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1516174479; bh=3HQi8E9ZbaNRyllFZvARg6qJWfaqGZ1VAWheGke68/U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CR3xxgUD3sVyW9EaIE3g6tRa7muf50bSN6KkEkeUxsJRwl2MjGBiZeG8ZvieF/LPh Bl9WuLcoREGHubWBU5js8V80j+efmTYXQqMOyQDu8JIchBaFVn+ZpXOfyqAP+BzdKU k8qKdy37ShJ0xq0ZfLsresCZe94uQ7HpmCP62zSU= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 0D89260854 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=tamizhr@codeaurora.org From: tamizhr@codeaurora.org To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, tamizhr@qti.qualcomm.com, Tamizh chelvam Subject: [PATCH 4/4] mac80211: implement cqm using rx data signal Date: Wed, 17 Jan 2018 13:01:16 +0530 Message-Id: <1516174276-16789-5-git-send-email-tamizhr@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1516174276-16789-1-git-send-email-tamizhr@codeaurora.org> References: <1516174276-16789-1-git-send-email-tamizhr@codeaurora.org> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Tamizh chelvam Triggers ieee80211_cqm_rssi_notify with the corresponding event when station signal goes lower than the configured rssi threshold. And notify back to user space once the station signal becomes greater than the configured value. It uses rx data signal and compare with rssi value given by user. This rssi threshold is bss specific and it is common for all the stations. Signed-off-by: Tamizh chelvam --- include/net/mac80211.h | 7 +++++++ net/mac80211/rx.c | 43 ++++++++++++++++++++++++++++++++++++++++++- net/mac80211/sta_info.h | 3 +++ 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/include/net/mac80211.h b/include/net/mac80211.h index d71ac81..1dec4ec 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -799,6 +799,13 @@ enum mac80211_rate_control_flags { }; +/* + * How many frames need to have been used in average station's + * signal strength before checking against the threshold + */ +#define IEEE80211_STA_SIGNAL_AVE_MIN_COUNT 4 + + /* there are 40 bytes if you don't need the rateset to be kept */ #define IEEE80211_TX_INFO_DRIVER_DATA_SIZE 40 diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index fd58061..e6f728a 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -1534,6 +1534,39 @@ void ieee80211_sta_uapsd_trigger(struct ieee80211_sta *pubsta, u8 tid) return RX_CONTINUE; } +static void ieee80211_sta_rx_signal_thold_check(struct ieee80211_rx_data *rx) +{ + struct sta_info *sta = rx->sta; + struct ieee80211_bss_conf *bss_conf = + &rx->sdata->vif.bss_conf; + int sig, last_event, thold; + + if (!bss_conf->cqm_rssi_thold || !bss_conf->enable_beacon) { + sta->count_rx_signal = 0; + return; + } + + sig = -ewma_signal_read(&sta->rx_stats_avg.signal); + last_event = sta->last_cqm_event_signal; + thold = bss_conf->cqm_rssi_thold; + + if (sig < thold && last_event == 0) { + sta->last_cqm_event_signal = sig; + ieee80211_cqm_rssi_notify( + &rx->sdata->vif, sta->addr, + NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW, + sig, GFP_ATOMIC); + sta->count_rx_signal = 0; + } else if (last_event && sig > thold) { + sta->last_cqm_event_signal = 0; + ieee80211_cqm_rssi_notify( + &rx->sdata->vif, sta->addr, + NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH, + sig, GFP_ATOMIC); + sta->count_rx_signal = 0; + } +} + static ieee80211_rx_result debug_noinline ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx) { @@ -1589,6 +1622,9 @@ void ieee80211_sta_uapsd_trigger(struct ieee80211_sta *pubsta, u8 tid) if (!(status->flag & RX_FLAG_NO_SIGNAL_VAL)) { sta->rx_stats.last_signal = status->signal; ewma_signal_add(&sta->rx_stats_avg.signal, -status->signal); + sta->count_rx_signal++; + if (sta->count_rx_signal >= IEEE80211_STA_SIGNAL_AVE_MIN_COUNT) + ieee80211_sta_rx_signal_thold_check(rx); } if (status->chains) { @@ -3967,9 +4003,14 @@ static bool ieee80211_invoke_fast_rx(struct ieee80211_rx_data *rx, if (!(status->flag & RX_FLAG_NO_SIGNAL_VAL)) { stats->last_signal = status->signal; - if (!fast_rx->uses_rss) + if (!fast_rx->uses_rss) { ewma_signal_add(&sta->rx_stats_avg.signal, -status->signal); + sta->count_rx_signal++; + if (sta->count_rx_signal >= + IEEE80211_STA_SIGNAL_AVE_MIN_COUNT) + ieee80211_sta_rx_signal_thold_check(rx); + } } if (status->chains) { diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h index cd53619..76e8877 100644 --- a/net/mac80211/sta_info.h +++ b/net/mac80211/sta_info.h @@ -579,6 +579,9 @@ struct sta_info { struct cfg80211_chan_def tdls_chandef; + int last_cqm_event_signal; + unsigned int count_rx_signal; + /* keep last! */ struct ieee80211_sta sta; };