xref: /wlan-driver/qcacld-3.0/core/hdd/src/wlan_hdd_tx_power.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2012-2018,2020 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef __WLAN_HDD_TX_POWER_H
21 #define __WLAN_HDD_TX_POWER_H
22 
23 /**
24  * DOC: wlan_hdd_tx_power_h
25  *
26  * WLAN Host Device Driver TX power setting API specification
27  */
28 
29 #ifdef FEATURE_TX_POWER
30 
31 extern const struct nla_policy txpower_scale_policy[
32 			QCA_WLAN_VENDOR_ATTR_TXPOWER_SCALE_MAX + 1];
33 
34 extern const struct nla_policy txpower_scale_decr_db_policy[
35 			QCA_WLAN_VENDOR_ATTR_TXPOWER_SCALE_DECR_DB_MAX + 1];
36 
37 /**
38  * wlan_hdd_cfg80211_txpower_scale () - txpower scaling
39  * @wiphy: Pointer to wireless phy
40  * @wdev: Pointer to wireless device
41  * @data: Pointer to data
42  * @data_len: Data length
43  *
44  * Return: 0 on success, negative errno on failure
45  */
46 int wlan_hdd_cfg80211_txpower_scale(struct wiphy *wiphy,
47 				    struct wireless_dev *wdev,
48 				    const void *data,
49 				    int data_len);
50 
51 /**
52  * wlan_hdd_cfg80211_txpower_scale_decr_db () - txpower scaling
53  * @wiphy: Pointer to wireless phy
54  * @wdev: Pointer to wireless device
55  * @data: Pointer to data
56  * @data_len: Data length
57  *
58  * Return: 0 on success, negative errno on failure
59  */
60 int wlan_hdd_cfg80211_txpower_scale_decr_db(struct wiphy *wiphy,
61 					    struct wireless_dev *wdev,
62 					    const void *data,
63 					    int data_len);
64 
65 /**
66  * wlan_hdd_cfg80211_get_reg_tpc_info () - get regulatory tpc information of
67  * connected AP
68  * @wiphy: Pointer to wireless phy
69  * @wdev: Pointer to wireless device
70  * @data: Pointer to data
71  * @data_len: Data length
72  *
73  * Return: 0 on success, negative errno on failure
74  */
75 int wlan_hdd_cfg80211_get_reg_tpc_info(struct wiphy *wiphy,
76 				       struct wireless_dev *wdev,
77 				       const void *data,
78 				       int data_len);
79 
80 #define FEATURE_TX_POWER_VENDOR_COMMANDS				\
81 {									\
82 	.info.vendor_id = QCA_NL80211_VENDOR_ID,			\
83 	.info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SET_TXPOWER_SCALE,	\
84 	.flags = WIPHY_VENDOR_CMD_NEED_WDEV |				\
85 			 WIPHY_VENDOR_CMD_NEED_NETDEV |			\
86 			 WIPHY_VENDOR_CMD_NEED_RUNNING,			\
87 	.doit = wlan_hdd_cfg80211_txpower_scale,			\
88 	vendor_command_policy(txpower_scale_policy,                     \
89 			      QCA_WLAN_VENDOR_ATTR_TXPOWER_SCALE_MAX)   \
90 },									\
91 {									\
92 	.info.vendor_id = QCA_NL80211_VENDOR_ID,			\
93 	.info.subcmd =							\
94 		QCA_NL80211_VENDOR_SUBCMD_SET_TXPOWER_SCALE_DECR_DB,	\
95 	.flags = WIPHY_VENDOR_CMD_NEED_WDEV |				\
96 			 WIPHY_VENDOR_CMD_NEED_NETDEV |			\
97 			 WIPHY_VENDOR_CMD_NEED_RUNNING,			\
98 	.doit = wlan_hdd_cfg80211_txpower_scale_decr_db,                \
99 	vendor_command_policy(txpower_scale_decr_db_policy,             \
100 			      QCA_WLAN_VENDOR_ATTR_TXPOWER_SCALE_DECR_DB_MAX) \
101 },
102 
103 #define FEATURE_REGULATORY_TPC_INFO_VENDOR_COMMANDS                     \
104 {                                                                       \
105 	.info.vendor_id = QCA_NL80211_VENDOR_ID,                        \
106 	.info.subcmd = QCA_NL80211_VENDOR_SUBCMD_REGULATORY_TPC_INFO,   \
107 	.flags = WIPHY_VENDOR_CMD_NEED_WDEV |                           \
108 		 WIPHY_VENDOR_CMD_NEED_NETDEV |                         \
109 		 WIPHY_VENDOR_CMD_NEED_RUNNING,                         \
110 	.doit = wlan_hdd_cfg80211_get_reg_tpc_info,                     \
111 	vendor_command_policy(VENDOR_CMD_RAW_DATA, 0)                   \
112 },
113 
114 #else /* FEATURE_TX_POWER */
115 #define FEATURE_TX_POWER_VENDOR_COMMANDS
116 #define FEATURE_REGULATORY_TPC_INFO_VENDOR_COMMANDS
117 #endif /* FEATURE_TX_POWER */
118 
119 #endif /* __WLAN_HDD_TX_POWER_H */
120 
121