From patchwork Wed May 30 19:10:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamizh chelvam X-Patchwork-Id: 10439635 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 E8AC860327 for ; Wed, 30 May 2018 19:11:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D0022293C8 for ; Wed, 30 May 2018 19:11:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CC0EC2932D; Wed, 30 May 2018 19:11:56 +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 AF19F29547 for ; Wed, 30 May 2018 19:11:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932178AbeE3TLJ (ORCPT ); Wed, 30 May 2018 15:11:09 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:54164 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932158AbeE3TLG (ORCPT ); Wed, 30 May 2018 15:11:06 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 36C51606FA; Wed, 30 May 2018 19:11:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527707466; bh=AN3dLOU4s7qDFCUaLbCe/JBGTE+uz6oovopflsofAw0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GO8HVjTZ/zKngtbTqoAt8w7wfuIB1Q9TiVXKara7D90iYL1JAKbx74Iq7hjJlB9JE zdhOa1Ixl3s5KrdjoDyXOld/tRJv4DM41McP48GriQ3f9fTxXyU6rMYAkRvgCHsHnJ oABgbL/HfgwwZpOrY+sQoK4mGbRF9A7tq08ko+6E= 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 D1FEA6060A; Wed, 30 May 2018 19:11:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527707465; bh=AN3dLOU4s7qDFCUaLbCe/JBGTE+uz6oovopflsofAw0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ihn7K0e0mvl9mZS6Uc6RDvUdK6s+hptTK7O/qA6ZD8JKStI0TaCX61+uT629doQWI uwh/RTnGMnKHNdbeq5d+QrhOunIRlahiHGsFJalG1joFbfi4+7KARrPna8lX3RCaEz UPy+A60BybhAccjzp8iLVDXUTyYQJRCNqYAhcoo4= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org D1FEA6060A 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: [RFCv3 3/4] cfg80211: Add support to notify station's txrate crossing event Date: Thu, 31 May 2018 00:40:49 +0530 Message-Id: <1527707450-2985-4-git-send-email-tamizhr@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1527707450-2985-1-git-send-email-tamizhr@codeaurora.org> References: <1527707450-2985-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 | 36 ++++++++++++++++++++++++++++++++++++ net/wireless/trace.h | 25 +++++++++++++++++++++++++ 3 files changed, 78 insertions(+) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index ab8a43f..b02ed31 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -5898,6 +5898,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..6701961 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -15576,6 +15576,42 @@ 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)) + 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