1 /*
2  * Copyright (c) 2012-2018, 2020 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 #ifndef __WLAN_HDD_RSSI_MONITOR_H
20 #define __WLAN_HDD_RSSI_MONITOR_H
21 
22 /**
23  * DOC: wlan_hdd_rssi_monitor_h
24  *
25  * WLAN Host Device Driver RSSI monitoring API specification
26  */
27 
28 #ifdef FEATURE_RSSI_MONITOR
29 
30 /* QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI policy */
31 extern const struct nla_policy moitor_rssi_policy[
32 			QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MAX + 1];
33 
34 /**
35  * wlan_hdd_cfg80211_monitor_rssi() - SSR wrapper to rssi monitoring
36  * @wiphy:    wiphy structure pointer
37  * @wdev:     Wireless device structure pointer
38  * @data:     Pointer to the data received
39  * @data_len: Length of @data
40  *
41  * Return: 0 on success; errno on failure
42  */
43 int
44 wlan_hdd_cfg80211_monitor_rssi(struct wiphy *wiphy, struct wireless_dev *wdev,
45 			       const void *data, int data_len);
46 
47 /**
48  * hdd_rssi_threshold_breached() - rssi breached NL event
49  * @hdd_handle: HDD handle
50  * @data: rssi breached event data
51  *
52  * This function reads the rssi breached event %data and fill in the skb with
53  * NL attributes and send up the NL event.
54  *
55  * Return: none
56  */
57 void hdd_rssi_threshold_breached(hdd_handle_t hdd_handle,
58 				 struct rssi_breach_event *data);
59 
60 #define FEATURE_RSSI_MONITOR_VENDOR_EVENTS                      \
61 [QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI_INDEX] = {              \
62 	.vendor_id = QCA_NL80211_VENDOR_ID,                     \
63 	.subcmd = QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI        \
64 },
65 
66 #define FEATURE_RSSI_MONITOR_VENDOR_COMMANDS                            \
67 {                                                                       \
68 	.info.vendor_id = QCA_NL80211_VENDOR_ID,                        \
69 	.info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MONITOR_RSSI,          \
70 	.flags = WIPHY_VENDOR_CMD_NEED_WDEV |                           \
71 		WIPHY_VENDOR_CMD_NEED_NETDEV |                          \
72 		WIPHY_VENDOR_CMD_NEED_RUNNING,                          \
73 	.doit = wlan_hdd_cfg80211_monitor_rssi,                         \
74 	vendor_command_policy(moitor_rssi_policy,                       \
75 			      QCA_WLAN_VENDOR_ATTR_RSSI_MONITORING_MAX) \
76 },
77 
78 #else /* FEATURE_RSSI_MONITOR */
79 static inline
hdd_rssi_threshold_breached(hdd_handle_t hdd_handle,struct rssi_breach_event * data)80 void hdd_rssi_threshold_breached(hdd_handle_t hdd_handle,
81 				 struct rssi_breach_event *data)
82 {
83 }
84 
85 #define FEATURE_RSSI_MONITOR_VENDOR_EVENTS
86 #define FEATURE_RSSI_MONITOR_VENDOR_COMMANDS
87 #endif /* FEATURE_RSSI_MONITOR */
88 
89 #endif /* __WLAN_HDD_RSSI_MONITOR_H */
90 
91