From patchwork Wed Jun 13 10:58:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamizh chelvam X-Patchwork-Id: 10462015 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 3C2D96020A for ; Wed, 13 Jun 2018 10:59:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F8BA2886A for ; Wed, 13 Jun 2018 10:59:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 229AF28891; Wed, 13 Jun 2018 10:59: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=-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 A38102886A for ; Wed, 13 Jun 2018 10:59:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935319AbeFMK7m (ORCPT ); Wed, 13 Jun 2018 06:59:42 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:52624 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934466AbeFMK7k (ORCPT ); Wed, 13 Jun 2018 06:59:40 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 62D5C607A4; Wed, 13 Jun 2018 10:59:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1528887580; bh=PGLLbRlTxMoKkNjzDrmsMujDjIwIq+gRA7eocmcs80Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O3BW6NHhrgGjyzGdTKTFt+MBC4iCR8U2CrXAg46zWJinG2MPZ560fP+cI93suaY26 YtvYOLgofLaXPlYDaG5t+SZ48qJSrB2VOHyAB6DgZS3/j3aZR4TxZRuMmjvBL9nczf lXE6NUl/e8plJxsHHVBQ60/BQr45y9Zdi2mbsCaY= 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 AEA266074D; Wed, 13 Jun 2018 10:59:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1528887579; bh=PGLLbRlTxMoKkNjzDrmsMujDjIwIq+gRA7eocmcs80Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cBZ3wVThuNTG+FaEDVDiDm3U6JZG/GKo4NDVRTUTLuy7ymWzZ+ht/luPNCyLPkFU+ Nqp3CauehLzWhfimjo7h9MYIbFhT+UWPmUvv1BnDpuJhG8tZMsBLbDqM4f3p0VmEmf WHWImaRWpYdflLmLGV+SGxP4/NG9FudO9cWQoxUk= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org AEA266074D 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: [PATCH 3/4] cfg80211: Add support to notify station's txrate crossing event Date: Wed, 13 Jun 2018 16:28:58 +0530 Message-Id: <1528887539-26821-4-git-send-email-tamizhr@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1528887539-26821-1-git-send-email-tamizhr@codeaurora.org> References: <1528887539-26821-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 Add cfg80211_sta_mon_txrate_notify to update userspace upon crossing the configured txrate threshold for a station. This uses NL80211_CMD_NOTIFY_STA_MON along with NL80211_ATTR_STA_MON_TXRATE_THRESHOLD_EVENT, NL80211_ATTR_MAC and NL80211_ATTR_STA_MON_TXRATE_LEVEL. Userspace application can make a decision on the station depends on this notification. Signed-off-by: Tamizh chelvam --- include/net/cfg80211.h | 17 +++++++++++++++++ net/wireless/nl80211.c | 38 ++++++++++++++++++++++++++++++++++++++ net/wireless/trace.h | 25 +++++++++++++++++++++++++ 3 files changed, 80 insertions(+) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 5bf0000..c0f8018 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -5899,6 +5899,23 @@ void cfg80211_cqm_rssi_notify(struct net_device *dev, s32 rssi_level, gfp_t gfp); /** + * cfg80211_sta_mon_txrate_notify - txrate event for connected stations + * @dev: network device + * @peer: peer's MAC address + * @txrate_event: the triggered TX RATE event + * @txrate_level: new TX RATE level value or 0 if not available + * @gfp: context flags + * + * This function is called when a average of attempted frame txrate crossed + * above configured high txrate or below configured low txrate event + * occurs for a station. + */ +void +cfg80211_sta_mon_txrate_notify(struct net_device *dev, const u8 *peer, + enum nl80211_sta_mon_txrate_threshold_event txrate_event, + u32 txrate_level, gfp_t gfp); + +/** * cfg80211_cqm_pktloss_notify - notify userspace about packetloss to peer * @dev: network device * @peer: peer's MAC address diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 31680d6..645a9fd 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -15576,6 +15576,44 @@ void cfg80211_sta_mon_rssi_notify(struct net_device *dev, const u8 *peer, } EXPORT_SYMBOL(cfg80211_sta_mon_rssi_notify); +void +cfg80211_sta_mon_txrate_notify(struct net_device *dev, const u8 *peer, + enum nl80211_sta_mon_txrate_threshold_event txrate_event, + u32 txrate_level, gfp_t gfp) +{ + struct sk_buff *msg; + + trace_cfg80211_sta_mon_txrate_notify(dev, peer, txrate_event, + txrate_level); + + if (WARN_ON(txrate_event != + NL80211_STA_MON_TXRATE_THRESHOLD_EVENT_LOW && + txrate_event != + NL80211_STA_MON_TXRATE_THRESHOLD_EVENT_HIGH && + txrate_event != + NL80211_STA_MON_TXRATE_THRESHOLD_IN_RANGE)) + return; + + msg = cfg80211_prepare_sta_mon(dev, peer, gfp); + if (!msg) + return; + + if (nla_put_u32(msg, NL80211_ATTR_STA_MON_TXRATE_THRESHOLD_EVENT, + txrate_event)) + goto nla_put_failure; + + if (txrate_level && nla_put_u32(msg, NL80211_ATTR_STA_MON_TXRATE_LEVEL, + txrate_level)) + goto nla_put_failure; + + cfg80211_send_sta_mon(msg, gfp); + + return; +nla_put_failure: + nlmsg_free(msg); +} +EXPORT_SYMBOL(cfg80211_sta_mon_txrate_notify); + static void nl80211_ch_switch_notify(struct cfg80211_registered_device *rdev, struct net_device *netdev, struct cfg80211_chan_def *chandef, diff --git a/net/wireless/trace.h b/net/wireless/trace.h index ca985c2..95f4a31 100644 --- a/net/wireless/trace.h +++ b/net/wireless/trace.h @@ -3355,6 +3355,31 @@ WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(peer), __entry->low_txrate_thold, __entry->high_txrate_thold) ); + +TRACE_EVENT(cfg80211_sta_mon_txrate_notify, + TP_PROTO(struct net_device *netdev, const u8 *peer, + enum nl80211_sta_mon_txrate_threshold_event txrate_event, + u32 txrate_level), + TP_ARGS(netdev, peer, txrate_event, txrate_level), + TP_STRUCT__entry( + NETDEV_ENTRY + MAC_ENTRY(peer) + __field(enum nl80211_sta_mon_txrate_threshold_event, + txrate_event) + __field(u32, txrate_level) + ), + TP_fast_assign( + NETDEV_ASSIGN; + MAC_ASSIGN(peer, peer); + __entry->txrate_event = txrate_event; + __entry->txrate_level = txrate_level; + ), + TP_printk(NETDEV_PR_FMT ", peer: " MAC_PR_FMT + ", tx_rate event: %d, txrate : %u", + NETDEV_PR_ARG, MAC_PR_ARG(peer), + __entry->txrate_event, __entry->txrate_level) +); + #endif /* !__RDEV_OPS_TRACE || TRACE_HEADER_MULTI_READ */ #undef TRACE_INCLUDE_PATH