xref: /wlan-driver/qcacld-3.0/core/hdd/inc/wlan_hdd_he.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2017-2020 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022-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 /**
21  * DOC: wlan_hdd_he.h
22  *
23  * WLAN Host Device Driver file for 802.11ax (High Efficiency) support.
24  *
25  */
26 
27 #if !defined(WLAN_HDD_HE_H)
28 #define WLAN_HDD_HE_H
29 
30 struct hdd_context;
31 struct wma_tgt_cfg;
32 struct hdd_beacon_data;
33 struct sap_config;
34 
35 #ifdef WLAN_FEATURE_11AX
36 /**
37  * enum qca_wlan_vendor_attr_get_he_capabilities - attributes for HE caps
38  *						   vendor command.
39  * @QCA_WLAN_VENDOR_ATTR_HE_CAPABILITIES_INVALID: invalid
40  * @QCA_WLAN_VENDOR_ATTR_HE_SUPPORTED: to check if HE capabilities is supported
41  * @QCA_WLAN_VENDOR_ATTR_PHY_CAPAB: to get HE PHY capabilities
42  * @QCA_WLAN_VENDOR_ATTR_MAC_CAPAB: to get HE MAC capabilities
43  * @QCA_WLAN_VENDOR_ATTR_HE_MCS: to get HE MCS
44  * @QCA_WLAN_VENDOR_ATTR_NUM_SS: to get NUM SS
45  * @QCA_WLAN_VENDOR_ATTR_RU_IDX_MASK: to get RU index mask
46  * @QCA_WLAN_VENDOR_ATTR_PPE_THRESHOLD: to get PPE Threshold,
47  * @QCA_WLAN_VENDOR_ATTR_HE_CAPABILITIES_AFTER_LAST: next to last valid enum
48  * @QCA_WLAN_VENDOR_ATTR_HE_CAPABILITIES_MAX: max value supported
49  *
50  * enum values are used for NL attributes for data used by
51  * QCA_NL80211_VENDOR_SUBCMD_GET_HE_CAPABILITIES sub command.
52  */
53 enum qca_wlan_vendor_attr_get_he_capabilities {
54 	QCA_WLAN_VENDOR_ATTR_HE_CAPABILITIES_INVALID = 0,
55 	QCA_WLAN_VENDOR_ATTR_HE_SUPPORTED,
56 	QCA_WLAN_VENDOR_ATTR_PHY_CAPAB,
57 	QCA_WLAN_VENDOR_ATTR_MAC_CAPAB,
58 	QCA_WLAN_VENDOR_ATTR_HE_MCS,
59 	QCA_WLAN_VENDOR_ATTR_NUM_SS = 5,
60 	QCA_WLAN_VENDOR_ATTR_RU_IDX_MASK,
61 	QCA_WLAN_VENDOR_ATTR_PPE_THRESHOLD,
62 
63 	/* keep last */
64 	QCA_WLAN_VENDOR_ATTR_HE_CAPABILITIES_AFTER_LAST,
65 	QCA_WLAN_VENDOR_ATTR_HE_CAPABILITIES_MAX =
66 	QCA_WLAN_VENDOR_ATTR_HE_CAPABILITIES_AFTER_LAST - 1,
67 };
68 
69 /* QCA_NL80211_VENDOR_SUBCMD_SR policy*/
70 extern const struct nla_policy
71 wlan_hdd_sr_policy[QCA_WLAN_VENDOR_ATTR_SR_MAX + 1];
72 
73 /**
74  * hdd_update_tgt_he_cap() - Update HE related capabilities
75  * @hdd_ctx: HDD context
76  * @cfg: Target capabilities
77  *
78  * This function updaates WNI CFG with Target capabilities received as part of
79  * Default values present in WNI CFG are the values supported by FW/HW.
80  * INI should be introduced if user control is required to control the value.
81  *
82  * Return: None
83  */
84 void hdd_update_tgt_he_cap(struct hdd_context *hdd_ctx,
85 			   struct wma_tgt_cfg *cfg);
86 
87 /**
88  * wlan_hdd_check_11ax_support() - check if beacon IE and update hw mode
89  * @beacon: beacon IE buffer
90  * @config: pointer to sap config
91  *
92  * Check if HE cap IE is present in beacon IE, if present update hw mode
93  * to 11ax.
94  *
95  * Return: None
96  */
97 void wlan_hdd_check_11ax_support(struct hdd_beacon_data *beacon,
98 				 struct sap_config *config);
99 
100 /**
101  * hdd_update_he_cap_in_cfg() - update HE cap in global CFG
102  * @hdd_ctx: pointer to hdd context
103  *
104  * This API will update the HE config in CFG after taking intersection
105  * of INI and firmware capabilities provided reading CFG
106  *
107  * Return: 0 on success and errno on failure
108  */
109 int hdd_update_he_cap_in_cfg(struct hdd_context *hdd_ctx);
110 
111 /**
112  * wlan_hdd_cfg80211_get_he_cap() - get HE Capabilities
113  * @wiphy: Pointer to wiphy
114  * @wdev: Pointer to wdev
115  * @data: Pointer to data
116  * @data_len: Data length
117  *
118  * Return: 0 if success, non-zero for failure
119  */
120 int wlan_hdd_cfg80211_get_he_cap(struct wiphy *wiphy,
121 				 struct wireless_dev *wdev, const void *data,
122 				 int data_len);
123 #ifdef WLAN_FEATURE_SR
124 /**
125  * wlan_hdd_cfg80211_sr_operations() - Spatial Reuse Operations
126  * @wiphy:   pointer to wireless wiphy structure.
127  * @wdev:    pointer to wireless_dev structure.
128  * @data:    Pointer to the data to be passed via vendor interface
129  * @data_len:Length of the data to be passed
130  *
131  * Return:   Return the Success or Failure code.
132  */
133 int wlan_hdd_cfg80211_sr_operations(struct wiphy *wiphy,
134 				    struct wireless_dev *wdev,
135 				    const void *data, int data_len);
136 
137 /**
138  * hdd_sr_register_callbacks() - register hdd callback for sr
139  * @hdd_ctx: hdd context
140  *
141  * Return: void
142  */
143 void hdd_sr_register_callbacks(struct hdd_context *hdd_ctx);
144 
145 #else
146 static inline
wlan_hdd_cfg80211_sr_operations(struct wiphy * wiphy,struct wireless_dev * wdev,const void * data,int data_len)147 int wlan_hdd_cfg80211_sr_operations(struct wiphy *wiphy,
148 				    struct wireless_dev *wdev,
149 				    const void *data, int data_len)
150 {
151 	return -ENOTSUPP;
152 }
153 
hdd_sr_register_callbacks(struct hdd_context * hdd_ctx)154 static inline void hdd_sr_register_callbacks(struct hdd_context *hdd_ctx)
155 {
156 }
157 #endif
158 
159 #define FEATURE_11AX_VENDOR_COMMANDS                                    \
160 {                                                                       \
161 	.info.vendor_id = QCA_NL80211_VENDOR_ID,                        \
162 	.info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_HE_CAPABILITIES,   \
163 	.flags = WIPHY_VENDOR_CMD_NEED_WDEV |                           \
164 		 WIPHY_VENDOR_CMD_NEED_NETDEV,                          \
165 	.doit = wlan_hdd_cfg80211_get_he_cap,                           \
166 	vendor_command_policy(VENDOR_CMD_RAW_DATA, 0)                   \
167 },									\
168 {                                                                       \
169 	.info.vendor_id = QCA_NL80211_VENDOR_ID,                        \
170 	.info.subcmd = QCA_NL80211_VENDOR_SUBCMD_SR,			\
171 	.flags = WIPHY_VENDOR_CMD_NEED_WDEV |                           \
172 		 WIPHY_VENDOR_CMD_NEED_NETDEV |                         \
173 		 WIPHY_VENDOR_CMD_NEED_RUNNING,				\
174 	.doit = wlan_hdd_cfg80211_sr_operations,			\
175 	vendor_command_policy(wlan_hdd_sr_policy,			\
176 			      QCA_WLAN_VENDOR_ATTR_SR_MAX)		\
177 },
178 
179 #else
hdd_update_tgt_he_cap(struct hdd_context * hdd_ctx,struct wma_tgt_cfg * cfg)180 static inline void hdd_update_tgt_he_cap(struct hdd_context *hdd_ctx,
181 					 struct wma_tgt_cfg *cfg)
182 {
183 }
184 
wlan_hdd_check_11ax_support(struct hdd_beacon_data * beacon,struct sap_config * config)185 static inline void wlan_hdd_check_11ax_support(struct hdd_beacon_data *beacon,
186 					       struct sap_config *config)
187 {
188 }
189 
hdd_update_he_cap_in_cfg(struct hdd_context * hdd_ctx)190 static inline int hdd_update_he_cap_in_cfg(struct hdd_context *hdd_ctx)
191 {
192 	return 0;
193 }
194 
hdd_sr_register_callbacks(struct hdd_context * hdd_ctx)195 static inline void hdd_sr_register_callbacks(struct hdd_context *hdd_ctx)
196 {
197 }
198 
199 /* dummy definition */
200 #define FEATURE_11AX_VENDOR_COMMANDS
201 
202 #endif
203 #endif /* if !defined(WLAN_HDD_HE_H)*/
204