From patchwork Tue Apr 4 05:42:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: c_traja@qti.qualcomm.com X-Patchwork-Id: 9660865 X-Patchwork-Delegate: kvalo@adurom.com 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 CA418602B9 for ; Tue, 4 Apr 2017 05:42:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BAB5E2847B for ; Tue, 4 Apr 2017 05:42:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF2FB28498; Tue, 4 Apr 2017 05:42:53 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 138242847B for ; Tue, 4 Apr 2017 05:42:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3vqm2GeQLECmeXr8S+rsi4O0Ser+B9BXpaA4GG3JFqg=; b=pw6o0/lllu+/BL xNJ0C0wTExTbafP38UGaMBETvbW5mU2kkQAg0Wsxn7R6yZDf5rk2Re1Ttt0SkLBKLWn98BhpUzz6Q WBhTN00MmoAX2Uly3ILi/ACsEmx3cYjrr6cCqMmfsmepRKVSGrUZdcW0XeohYnXey1iWN6gs3N5ck MWccVo6ugcOkFVww7/rmQyDsRjcMl7p2+t/WSGtEfsUuuPsr0evkT4CtELO5DO7hbAyN9EVUXCk2h cxvvAG69sFKFXbUGI3BsMNJftM0duYs1rreoQYr4FlBOc38HTeE97RUgj/m7FBFFQc/6jDzeOtQ4d 3r0i0zuSHl3pVEK28G6Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cvHEt-0005rY-PJ; Tue, 04 Apr 2017 05:42:47 +0000 Received: from wolverine01.qualcomm.com ([199.106.114.254]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cvHEp-0005mT-2k for ath10k@lists.infradead.org; Tue, 04 Apr 2017 05:42:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=qti.qualcomm.com; i=@qti.qualcomm.com; q=dns/txt; s=qcdkim; t=1491284563; x=1522820563; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=g5qRDbVXGaOw1qdlcyU8LiO0p0CModsUfmH0fSS0clI=; b=cAG6iTP//2m22BPsaiwp2JpfZoObsZTYtpIhXcm0vlOOakv8CbDjiJXn AhFCgt99whqP3y7sPzy3hJv12YzW2VTkk0PJHOUWBTyxEd7MCTYFSoHIi tAVRtfX2Yxn7C7fNQL2G71bn0La/STEsCOupFRhqjhn8SVU7rehTktoel g=; X-IronPort-AV: E=Sophos;i="5.36,273,1486454400"; d="scan'208";a="275781129" Received: from unknown (HELO Ironmsg03-R.qualcomm.com) ([10.53.140.107]) by wolverine01.qualcomm.com with ESMTP; 03 Apr 2017 22:42:24 -0700 X-IronPort-AV: E=McAfee;i="5800,7501,8487"; a="1340565083" X-MGA-submission: =?us-ascii?q?MDFlPiJpm088D7JVxMuR+RHqu6apaj3Nb14jUh?= =?us-ascii?q?gf04QNcfNUHo4FJEiu0yxBhLKxJ9t4TiUbTKH1lE20XX/J/eYgsAjIL+?= =?us-ascii?q?zdgKSlfpObTNFSNevv6dlilZqa0P69zBz3suq6XSZ5PJEfpmt1ZHjCQH?= =?us-ascii?q?l6?= Received: from nasanexm02e.na.qualcomm.com ([10.85.0.86]) by Ironmsg03-R.qualcomm.com with ESMTP/TLS/RC4-SHA; 03 Apr 2017 22:42:24 -0700 Received: from aphydexm01b.ap.qualcomm.com (10.252.127.11) by nasanexm02e.na.qualcomm.com (10.85.0.86) with Microsoft SMTP Server (TLS) id 15.0.1178.4; Mon, 3 Apr 2017 22:42:23 -0700 Received: from localhost (10.80.80.8) by aphydexm01b.ap.qualcomm.com (10.252.127.11) with Microsoft SMTP Server (TLS) id 15.0.1178.4; Tue, 4 Apr 2017 11:12:17 +0530 From: To: Subject: [PATCHv3 1/2] cfg80211: Add support to enable or disable btcoex and set btcoex_priority Date: Tue, 4 Apr 2017 11:12:37 +0530 Message-ID: <1491284558-1915-2-git-send-email-c_traja@qti.qualcomm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1491284558-1915-1-git-send-email-c_traja@qti.qualcomm.com> References: <1491284558-1915-1-git-send-email-c_traja@qti.qualcomm.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: NASANEXM01F.na.qualcomm.com (10.85.0.32) To aphydexm01b.ap.qualcomm.com (10.252.127.11) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170403_224243_348848_656E08D6 X-CRM114-Status: GOOD ( 18.13 ) X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tamizh chelvam , johannes@sipsolutions.net, tamizhchelvam@codeaurora.org, ath10k@lists.infradead.org Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Tamizh chelvam This patch introduces NL80211_CMD_SET_BTCOEX command and NL80211_ATTR_BTCOEX_OP attribute to enable or disable btcoex. And this change enables user to set btcoex priority by using NL80211_ATTR_BTCOEX_PRIORITY attribute for the driver which has the btcoex priority capability. Driver should expose such capability and make use of this priority to decide whom to share the radio (either bluetooth or WLAN). When the high priority wlan frames are queued driver or firmware will signal to block BT activity. Capable drivers should advertise this support by setting NL80211_EXT_FEATURE_BTCOEX_PRIORITY nl80211 extended feature. Signed-off-by: Tamizh chelvam --- include/net/cfg80211.h | 35 ++++++++++++++++++++++++++++++++ include/uapi/linux/nl80211.h | 20 +++++++++++++++++++ net/wireless/nl80211.c | 45 ++++++++++++++++++++++++++++++++++++++++++ net/wireless/rdev-ops.h | 13 ++++++++++++ net/wireless/trace.h | 17 ++++++++++++++++ 5 files changed, 130 insertions(+) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 273b1dc..b144998 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -2856,6 +2856,10 @@ struct cfg80211_nan_func { * All other parameters must be ignored. * * @set_multicast_to_unicast: configure multicast to unicast conversion for BSS + * @set_btcoex: Use this callback to call driver API when user wants to + * enable/disable btcoex and use this callback to set wlan high priority + * over bluetooth. When BTCOEX enabled, the high priority wlan frames + * will have more priority than BT. */ struct cfg80211_ops { int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow); @@ -3144,6 +3148,8 @@ struct cfg80211_ops { int (*set_multicast_to_unicast)(struct wiphy *wiphy, struct net_device *dev, const bool enabled); + int (*set_btcoex)(struct wiphy *wiphy, bool enabled, + u32 btcoex_priority); }; /* @@ -3488,6 +3494,35 @@ struct wiphy_iftype_ext_capab { }; /** + * enum btcoex_priority_support_flag - btcoex priority supported frame types and + * its bitmap values. + * @WIPHY_BTCOEX_SUPPORTS_BE_PREF - BE wlan frame takes more preference than + * BT traffic. + * @WIPHY_BTCOEX_SUPPORTS_BK_PREF - BK wlan frame takes more preference than + * BT traffic. + * @WIPHY_BTCOEX_SUPPORTS_VI_PREF - VI wlan frame takes more preference than + * BT traffic. + * @WIPHY_BTCOEX_SUPPORTS_VO_PREF - VO wlan frame takes more preference than + * BT traffic. + * @WIPHY_BTCOEX_SUPPORTS_BEACON_PREF - BEACON wlan frame takes more preference + * than BT traffic. + * @WIPHY_BTCOEX_SUPPORTS_MGMT_PREF - MGMT wlan frame takes more preference than + * BT traffic. + * @WIPHY_BTCOEX_SUPPORTS_MAX_PREF - MAX supported value for btcoex priority + * feature. + */ + +enum btcoex_priority_support_flag { + WIPHY_BTCOEX_SUPPORTS_BE_PREF = BIT(0), + WIPHY_BTCOEX_SUPPORTS_BK_PREF = BIT(1), + WIPHY_BTCOEX_SUPPORTS_VI_PREF = BIT(2), + WIPHY_BTCOEX_SUPPORTS_VO_PREF = BIT(3), + WIPHY_BTCOEX_SUPPORTS_BEACON_PREF = BIT(4), + WIPHY_BTCOEX_SUPPORTS_MGMT_PREF = BIT(5), + WIPHY_BTCOEX_SUPPORTS_MAX_PREF = BIT(6) - 1, +}; + +/** * struct wiphy - wireless hardware description * @reg_notifier: the driver's regulatory notification callback, * note that if your driver uses wiphy_apply_custom_regulatory() diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h index 6095a6c..e6b2647 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -944,6 +944,8 @@ * BSS selection. This command can be issued only while connected and it * does not result in a change for the current association. Currently, * only the %NL80211_ATTR_IE data is used and updated with this command. + * @NL80211_CMD_SET_BTCOEX: Enable/Disable btcoex using + * %NL80211_ATTR_SET_BTCOEX * * @NL80211_CMD_MAX: highest used command number * @__NL80211_CMD_AFTER_LAST: internal use @@ -1144,6 +1146,8 @@ enum nl80211_commands { NL80211_CMD_UPDATE_CONNECT_PARAMS, + NL80211_CMD_SET_BTCOEX, + /* add new commands above here */ /* used to define NL80211_CMD_MAX below */ @@ -2081,6 +2085,16 @@ enum nl80211_commands { * @NL80211_ATTR_PMK: PMK for the PMKSA identified by %NL80211_ATTR_PMKID. * This is used with @NL80211_CMD_SET_PMKSA. * + * @NL80211_ATTR_BTCOEX_OP: u8 attribute for driver supporting + * the btcoex feature. When used with %NL80211_CMD_SET_BTCOEX it contains + * either 0 for disable or 1 for enable btcoex. + * + * @NL80211_ATTR_BTCOEX_PRIORITY: This is for the driver which supprot + * btcoex priority feature. It used with %NL80211_CMD_SET_BTCOEX. + * This will have u32 BITMAP value which represents + * frame(bk, be, vi, vo, mgmt, beacon) type and that will have more + * priority than a BT traffic. + * * @NUM_NL80211_ATTR: total number of nl80211_attrs available * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use @@ -2500,6 +2514,9 @@ enum nl80211_attrs { NL80211_ATTR_PMK, + NL80211_ATTR_BTCOEX_OP, + NL80211_ATTR_BTCOEX_PRIORITY, + /* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST, @@ -4838,6 +4855,8 @@ enum nl80211_feature_flags { * RSSI threshold values to monitor rather than exactly one threshold. * @NL80211_EXT_FEATURE_FILS_SK_OFFLOAD: Driver SME supports FILS shared key * authentication with %NL80211_CMD_CONNECT. + * @NL80211_EXT_FEATURE_BTCOEX_PRIORITY: Driver supprots btcoex priority + * feature with %NL80211_ATTR_BTCOEX_PRIORITY. * * @NUM_NL80211_EXT_FEATURES: number of extended features. * @MAX_NL80211_EXT_FEATURES: highest extended feature index. @@ -4858,6 +4877,7 @@ enum nl80211_ext_feature_index { NL80211_EXT_FEATURE_SCHED_SCAN_RELATIVE_RSSI, NL80211_EXT_FEATURE_CQM_RSSI_LIST, NL80211_EXT_FEATURE_FILS_SK_OFFLOAD, + NL80211_EXT_FEATURE_BTCOEX_PRIORITY, /* add new features before the definition below */ NUM_NL80211_EXT_FEATURES, diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 9910aae..3e39d0d 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -419,6 +419,8 @@ enum nl80211_multicast_groups { .len = FILS_ERP_MAX_RRK_LEN }, [NL80211_ATTR_FILS_CACHE_ID] = { .len = 2 }, [NL80211_ATTR_PMK] = { .type = NLA_BINARY, .len = PMK_MAX_LEN }, + [NL80211_ATTR_BTCOEX_OP] = { .type = NLA_U8 }, + [NL80211_ATTR_BTCOEX_PRIORITY] = { .type = NLA_U32 }, }; /* policy for the key attributes */ @@ -12184,6 +12186,41 @@ static int nl80211_set_multicast_to_unicast(struct sk_buff *skb, return rdev_set_multicast_to_unicast(rdev, dev, enabled); } +static int nl80211_set_btcoex(struct sk_buff *skb, struct genl_info *info) +{ + struct cfg80211_registered_device *rdev = info->user_ptr[0]; + struct wiphy *wiphy = &rdev->wiphy; + u8 val = 0; + u32 btcoex_priority = 0; + + if (!rdev->ops->set_btcoex) + return -ENOTSUPP; + + if (!(info->attrs[NL80211_ATTR_BTCOEX_OP])) + goto set_btcoex; + + if (info->attrs[NL80211_ATTR_BTCOEX_OP]) + val = nla_get_u8(info->attrs[NL80211_ATTR_BTCOEX_OP]); + + if (val > 1) + return -EINVAL; + + if (info->attrs[NL80211_ATTR_BTCOEX_PRIORITY]) { + if (!wiphy_ext_feature_isset(wiphy, + NL80211_EXT_FEATURE_BTCOEX_PRIORITY)) + return -EOPNOTSUPP; + + btcoex_priority = + nla_get_u32(info->attrs[NL80211_ATTR_BTCOEX_PRIORITY]); + + if (btcoex_priority > WIPHY_BTCOEX_SUPPORTS_MAX_PREF) + return -E2BIG; + } + +set_btcoex: + return rdev_set_btcoex(rdev, val, btcoex_priority); +} + #define NL80211_FLAG_NEED_WIPHY 0x01 #define NL80211_FLAG_NEED_NETDEV 0x02 #define NL80211_FLAG_NEED_RTNL 0x04 @@ -13059,6 +13096,14 @@ static void nl80211_post_doit(const struct genl_ops *ops, struct sk_buff *skb, .internal_flags = NL80211_FLAG_NEED_NETDEV | NL80211_FLAG_NEED_RTNL, }, + { + .cmd = NL80211_CMD_SET_BTCOEX, + .doit = nl80211_set_btcoex, + .policy = nl80211_policy, + .flags = GENL_UNS_ADMIN_PERM, + .internal_flags = NL80211_FLAG_NEED_WIPHY | + NL80211_FLAG_NEED_RTNL, + }, }; static struct genl_family nl80211_fam __ro_after_init = { diff --git a/net/wireless/rdev-ops.h b/net/wireless/rdev-ops.h index f2baf59..d0dec56 100644 --- a/net/wireless/rdev-ops.h +++ b/net/wireless/rdev-ops.h @@ -1165,4 +1165,17 @@ static inline int rdev_set_qos_map(struct cfg80211_registered_device *rdev, trace_rdev_return_int(&rdev->wiphy, ret); return ret; } + +static inline int +rdev_set_btcoex(struct cfg80211_registered_device *rdev, bool enabled, + u32 btcoex_priority) +{ + int ret = -ENOTSUPP; + + trace_rdev_set_btcoex(&rdev->wiphy, enabled, btcoex_priority); + ret = rdev->ops->set_btcoex(&rdev->wiphy, enabled, btcoex_priority); + trace_rdev_return_int(&rdev->wiphy, ret); + return ret; +} + #endif /* __CFG80211_RDEV_OPS */ diff --git a/net/wireless/trace.h b/net/wireless/trace.h index fd55786..1947011 100644 --- a/net/wireless/trace.h +++ b/net/wireless/trace.h @@ -3069,6 +3069,23 @@ WIPHY_PR_ARG, __entry->n_rules) ); +TRACE_EVENT(rdev_set_btcoex, + TP_PROTO(struct wiphy *wiphy, bool enabled, u32 btcoex_priority), + TP_ARGS(wiphy, enabled, btcoex_priority), + TP_STRUCT__entry( + WIPHY_ENTRY + __field(bool, enabled) + __field(u32, btcoex_priority) + ), + TP_fast_assign( + WIPHY_ASSIGN; + __entry->enabled = enabled; + __entry->btcoex_priority = btcoex_priority; + ), + TP_printk(WIPHY_PR_FMT ", enabled=%d btcoex_priority :%u", + WIPHY_PR_ARG, __entry->enabled, __entry->btcoex_priority) +); + DEFINE_EVENT(wiphy_wdev_evt, rdev_abort_scan, TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev), TP_ARGS(wiphy, wdev)