From patchwork Fri Apr 27 05:30:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamizh chelvam X-Patchwork-Id: 10367437 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 282416053F for ; Fri, 27 Apr 2018 05:30:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 18059292F8 for ; Fri, 27 Apr 2018 05:30:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0CACB292FB; Fri, 27 Apr 2018 05:30:27 +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 8667D292FA for ; Fri, 27 Apr 2018 05:30:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757419AbeD0FaY (ORCPT ); Fri, 27 Apr 2018 01:30:24 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:52544 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757320AbeD0FaU (ORCPT ); Fri, 27 Apr 2018 01:30:20 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 15F3E60AE0; Fri, 27 Apr 2018 05:30:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1524807020; bh=viYEw+1Sc27zBrgpfNGLAYo4dDZqaL91zmtCz5q6bac=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RdXfEsFyL2Vi0XmSWa8in4OupNhWYqNLLttmV+btVAAcDWZzUI9KoCiNIB+znb4o5 ujlUh/Q75jwAcCncNA/5GGZPNbkceTXeJiR6wyyP5JLau4GIb+jFzR2o+W2vtVGMZQ 1zhuEqUlyHvX9oprKCneRmcr6ge3Enkabomc7KN8= Received: from che-swdbs-01.qca.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: tamizhr@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id E52DB6081C; Fri, 27 Apr 2018 05:30:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1524807019; bh=viYEw+1Sc27zBrgpfNGLAYo4dDZqaL91zmtCz5q6bac=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NcaObjaheuTThFr+9nwLpJfyZUcjwXVKpA3t1RSOPJnK4Sbd/DQDeKK0ba9jQcWlA irqWMRlpMCNJZYSlB7gFe9WnnexerpR+ODtu1qq4reyiNypDgYXfdL/SSZst3GsqkP fmD25iyS59rfo6RRvC6eLeLliZSZ97dIp0N/fxjk= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org E52DB6081C 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: [RFCv2 2/6] mac80211: Add support to configure rssi threshold for AP mode Date: Fri, 27 Apr 2018 11:00:32 +0530 Message-Id: <1524807036-28056-3-git-send-email-tamizhr@codeaurora.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1524807036-28056-1-git-send-email-tamizhr@codeaurora.org> References: <1524807036-28056-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 add support to configure station specific single or multi rssi thresholds using ieee80211_set_sta_mon_rssi_config and ieee80211_set_sta_mon_rssi_range_confg APIs. This configuration is used for tracking the connected station's 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; };