From patchwork Fri Apr 20 06:52:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamizh chelvam X-Patchwork-Id: 10351881 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 2745D60365 for ; Fri, 20 Apr 2018 06:54:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1889028639 for ; Fri, 20 Apr 2018 06:54:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C72C28643; Fri, 20 Apr 2018 06:54:49 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, 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 8BC1528639 for ; Fri, 20 Apr 2018 06:54:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753569AbeDTGyh (ORCPT ); Fri, 20 Apr 2018 02:54:37 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:35936 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753508AbeDTGye (ORCPT ); Fri, 20 Apr 2018 02:54:34 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 8260260F94; Fri, 20 Apr 2018 06:54:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1524207274; bh=G0s0oOaYFJe0Ipeg7LskeftLFkG49o5nhOQf3hizwC4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FjdLESb3XyQ3cZEktAj0l1dFd+d/M1byKZqulZDdkHBT4dmRzm7nAS0rz/3nTitkj KJN6A8/gpeA6hg84efWeP0rh5EhTIjN/2oyHRSs3oE0XLoRVH+/uRCxgW4annD+8GL Jjvk3yxVwWwQuHiE2ffireWdzeXefOLILefXRdak= 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 621FB60F6E; Fri, 20 Apr 2018 06:54:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1524207273; bh=G0s0oOaYFJe0Ipeg7LskeftLFkG49o5nhOQf3hizwC4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DoJnv6FPd7GEYY8sYm7biExf5u8E37zQjxGGVOzew4lS4k8xOj96SogfRZ8bIIsaO D4w6MCZuomGDMb37FAd139VeTXWqX2JxUuv1ky+AdulOq9C9Z9iIGLiIeSPyY37BUU bdFJ39A9RrzdZWj9lEbW9Ub0Nl0VujxukX+HkG2o= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 621FB60F6E 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: Tamizh chelvam To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Tamizh chelvam Subject: [RFC 2/6] mac80211: enable setting rssi threshold config for AP mode Date: Fri, 20 Apr 2018 12:22:47 +0530 Message-Id: <1524207171-3325-3-git-send-email-tamizhr@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1524207171-3325-1-git-send-email-tamizhr@codeaurora.org> References: <1524207171-3325-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 This patch introduce new api to set rssi single or low/high rssi threshold value to track the connected stations signal strength. Signed-off-by: Tamizh chelvam --- net/mac80211/cfg.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++ net/mac80211/sta_info.h | 18 ++++++++++++ 2 files changed, 93 insertions(+) diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 85dbaa8..0e2047c 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -3705,6 +3705,79 @@ static int ieee80211_set_multicast_to_unicast(struct wiphy *wiphy, return 0; } +static int ieee80211_set_sta_mon_rssi_config(struct wiphy *wiphy, + struct net_device *dev, + const u8 *peer, s32 rssi_thold, + u32 rssi_hyst) +{ + struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); + struct sta_info *sta; + + if (sdata->vif.type == NL80211_IFTYPE_AP && + (!sdata->vif.bss_conf.enable_beacon || + !wiphy_ext_feature_isset(sdata->local->hw.wiphy, + NL80211_EXT_FEATURE_STA_MON_RSSI_CONFIG))) + return -EOPNOTSUPP; + + mutex_lock(&sdata->local->sta_mtx); + + sta = sta_info_get_bss(sdata, peer); + if (!sta) { + mutex_unlock(&sdata->local->sta_mtx); + return -ENOENT; + } + + if (sta->rssi_thold == rssi_thold && + sta->rssi_hyst == rssi_hyst) + goto unlock; + + sta->rssi_thold = rssi_thold; + sta->rssi_hyst = rssi_hyst; + sta->rssi_low = 0; + sta->rssi_high = 0; + sta->last_sta_mon_event_signal = 0; +unlock: + mutex_unlock(&sdata->local->sta_mtx); + return 0; +} + +static int ieee80211_set_sta_mon_rssi_range_confg(struct wiphy *wiphy, + struct net_device *dev, + const u8 *peer, + s32 rssi_low, s32 rssi_high) +{ + struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); + struct sta_info *sta; + + if (sdata->vif.type == NL80211_IFTYPE_AP && + (!sdata->vif.bss_conf.enable_beacon || + !wiphy_ext_feature_isset(sdata->local->hw.wiphy, + NL80211_EXT_FEATURE_STA_MON_RSSI_LIST))) + return -EOPNOTSUPP; + + mutex_lock(&sdata->local->sta_mtx); + + sta = sta_info_get_bss(sdata, peer); + if (!sta) { + mutex_unlock(&sdata->local->sta_mtx); + return -ENOENT; + } + + if (sta->rssi_low == rssi_low && + sta->rssi_high == rssi_high) + goto unlock; + + sta->rssi_thold = 0; + sta->rssi_hyst = 0; + sta->rssi_low = rssi_low; + sta->rssi_high = rssi_high; + sta->last_sta_mon_event_signal = 0; + +unlock: + mutex_unlock(&sdata->local->sta_mtx); + return 0; +} + const struct cfg80211_ops mac80211_config_ops = { .add_virtual_intf = ieee80211_add_iface, .del_virtual_intf = ieee80211_del_iface, @@ -3798,4 +3871,6 @@ static int ieee80211_set_multicast_to_unicast(struct wiphy *wiphy, .del_nan_func = ieee80211_del_nan_func, .set_multicast_to_unicast = ieee80211_set_multicast_to_unicast, .tx_control_port = ieee80211_tx_control_port, + .set_sta_mon_rssi_config = ieee80211_set_sta_mon_rssi_config, + .set_sta_mon_rssi_range_config = ieee80211_set_sta_mon_rssi_range_confg, }; diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h index f64eb86..701eb37 100644 --- a/net/mac80211/sta_info.h +++ b/net/mac80211/sta_info.h @@ -481,6 +481,18 @@ struct ieee80211_sta_rx_stats { * @pcpu_rx_stats: per-CPU RX statistics, assigned only if the driver needs * this (by advertising the USES_RSS hw flag) * @status_stats: TX status statistics + * @rssi_thold: RSSI threshold to monitor station's signal strength, a zero + * value implies disabled. As with the cfg80211 callback, a change here + * should cause an event to be sent indicating where the current value + * is in relation to the newly configured threshold + * @rssi_hyst: Station's RSSI hysteresis + * @rssi_low: RSSI lower threshold to monitor station's signal strength, a zero + * value implies disabled. This is an alternative mechanism to the single + * threshold event and can't be enabled simultaneously with it + * @rssi_high: RSSI upper threshold for station + * @last_sta_mon_event_signal: Last signal strength average for a station + * that triggered a sta_mon event. 0 indicates that no event has been + * generated for the current association */ struct sta_info { /* General information, mostly static */ @@ -581,6 +593,12 @@ struct sta_info { struct cfg80211_chan_def tdls_chandef; + s32 rssi_thold; + u32 rssi_hyst; + s32 rssi_low; + s32 rssi_high; + int last_sta_mon_event_signal; + /* keep last! */ struct ieee80211_sta sta; };