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: declares driver functions interfacing with linux kernel
22 */
23
24 #ifndef _WLAN_CFG80211_TDLS_H_
25 #define _WLAN_CFG80211_TDLS_H_
26
27 #include <linux/version.h>
28 #include <linux/netdevice.h>
29 #include <linux/completion.h>
30 #include <net/cfg80211.h>
31 #include <qca_vendor.h>
32 #include <wlan_tdls_public_structs.h>
33 #include <qdf_list.h>
34 #include <qdf_types.h>
35 #include <wlan_hdd_main.h>
36 #include <wlan_tdls_ucfg_api.h>
37
38 #ifdef FEATURE_WLAN_TDLS
39
40 #define TDLS_VDEV_MAGIC 0x54444c53 /* "TDLS" */
41
42 /**
43 * struct osif_tdls_vdev - OS tdls vdev private structure
44 * @tdls_add_peer_comp: Completion to add tdls peer
45 * @tdls_del_peer_comp: Completion to delete tdls peer
46 * @tdls_mgmt_comp: Completion to send tdls mgmt packets
47 * @tdls_link_establish_req_comp: Completion to establish link, sync to
48 * send establish params to firmware, not used today.
49 * @tdls_teardown_comp: Completion to teardown tdls peer
50 * @tdls_user_cmd_comp: tdls user command completion event
51 * @tdls_antenna_switch_comp: Completion to switch antenna
52 * @tdls_add_peer_status: Peer status after add peer
53 * @mgmt_tx_completion_status: Tdls mgmt frames TX completion status code
54 * @tdls_user_cmd_len: tdls user command written buffer length
55 * @tdls_antenna_switch_status: return status after antenna switch
56 * @tdls_user_cmd_in_progress: tdls user command progress status.
57 */
58 struct osif_tdls_vdev {
59 struct completion tdls_add_peer_comp;
60 struct completion tdls_del_peer_comp;
61 struct completion tdls_mgmt_comp;
62 struct completion tdls_link_establish_req_comp;
63 struct completion tdls_teardown_comp;
64 struct completion tdls_user_cmd_comp;
65 struct completion tdls_antenna_switch_comp;
66 QDF_STATUS tdls_add_peer_status;
67 uint32_t mgmt_tx_completion_status;
68 uint32_t tdls_user_cmd_len;
69 int tdls_antenna_switch_status;
70 bool tdls_user_cmd_in_progress;
71 };
72
73 /**
74 * enum qca_wlan_vendor_tdls_trigger_mode_vdev_map: Maps the user space TDLS
75 * trigger mode in the host driver.
76 * @WLAN_VENDOR_TDLS_TRIGGER_MODE_EXPLICIT: TDLS Connection and
77 * disconnection handled by user space.
78 * @WLAN_VENDOR_TDLS_TRIGGER_MODE_IMPLICIT: TDLS connection and
79 * disconnection controlled by host driver based on data traffic.
80 * @WLAN_VENDOR_TDLS_TRIGGER_MODE_EXTERNAL: TDLS connection and
81 * disconnection jointly controlled by user space and host driver.
82 */
83 enum qca_wlan_vendor_tdls_trigger_mode_vdev_map {
84 WLAN_VENDOR_TDLS_TRIGGER_MODE_EXPLICIT =
85 QCA_WLAN_VENDOR_TDLS_TRIGGER_MODE_EXPLICIT,
86 WLAN_VENDOR_TDLS_TRIGGER_MODE_IMPLICIT =
87 QCA_WLAN_VENDOR_TDLS_TRIGGER_MODE_IMPLICIT,
88 WLAN_VENDOR_TDLS_TRIGGER_MODE_EXTERNAL =
89 ((QCA_WLAN_VENDOR_TDLS_TRIGGER_MODE_EXPLICIT |
90 QCA_WLAN_VENDOR_TDLS_TRIGGER_MODE_IMPLICIT) << 1),
91 };
92
93 /**
94 * wlan_cfg80211_tdls_osif_priv_init() - API to initialize tdls os private
95 * @vdev: vdev object
96 *
97 * API to initialize tdls os private
98 *
99 * Return: QDF_STATUS
100 */
101 QDF_STATUS wlan_cfg80211_tdls_osif_priv_init(struct wlan_objmgr_vdev *vdev);
102
103 /**
104 * wlan_cfg80211_tdls_osif_priv_deinit() - API to deinitialize tdls os private
105 * @vdev: vdev object
106 *
107 * API to deinitialize tdls os private
108 *
109 * Return: None
110 */
111 void wlan_cfg80211_tdls_osif_priv_deinit(struct wlan_objmgr_vdev *vdev);
112
113 /**
114 * wlan_cfg80211_tdls_add_peer_mlo() - process cfg80211 add TDLS peer request
115 * @adapter: adapter pointer
116 * @mac: MAC address for TDLS peer
117 * @link_id: link id
118 *
119 * Return: 0 for success; negative errno otherwise
120 */
121 int wlan_cfg80211_tdls_add_peer_mlo(struct hdd_adapter *adapter,
122 const uint8_t *mac, uint8_t link_id);
123
124 /**
125 * wlan_cfg80211_tdls_update_peer() - process cfg80211 update TDLS peer request
126 * @vdev: vdev object
127 * @mac: MAC address for TDLS peer
128 * @params: Pointer to station parameters
129 *
130 * Return: 0 for success; negative errno otherwise
131 */
132 int wlan_cfg80211_tdls_update_peer(struct wlan_objmgr_vdev *vdev,
133 const uint8_t *mac,
134 struct station_parameters *params);
135
136 /**
137 * wlan_cfg80211_tdls_configure_mode() - configure tdls mode
138 * @vdev: vdev obj manager
139 * @trigger_mode: tdls trgger mode
140 *
141 * Return: 0 for success; negative errno otherwise
142 */
143 int wlan_cfg80211_tdls_configure_mode(struct wlan_objmgr_vdev *vdev,
144 uint32_t trigger_mode);
145
146 /**
147 * wlan_cfg80211_tdls_oper() - process cfg80211 operation on an TDLS peer
148 * @vdev: vdev object
149 * @peer: MAC address of the TDLS peer
150 * @oper: cfg80211 TDLS operation
151 *
152 * Return: 0 on success; negative errno otherwise
153 */
154 int wlan_cfg80211_tdls_oper(struct wlan_objmgr_vdev *vdev,
155 const uint8_t *peer,
156 enum nl80211_tdls_operation oper);
157
158 /**
159 * wlan_cfg80211_tdls_get_all_peers() - get all the TDLS peers from the list
160 * @vdev: vdev object
161 * @buf: output buffer
162 * @buflen: valid length of the output error
163 *
164 * Return: length of the output buffer
165 */
166 int wlan_cfg80211_tdls_get_all_peers(struct wlan_objmgr_vdev *vdev,
167 char *buf, int buflen);
168
169 /**
170 * wlan_cfg80211_tdls_is_fw_wideband_capable() - Check whether fw supports
171 * wideband TDLS
172 * @vdev: Pointer to vdev
173 *
174 * Return: true if fw supports wideband TDLS connection
175 */
176 bool wlan_cfg80211_tdls_is_fw_wideband_capable(struct wlan_objmgr_vdev *vdev);
177
178 #ifdef WLAN_FEATURE_11AX
179 /**
180 * wlan_cfg80211_tdls_is_fw_6ghz_capable() - Check whether fw supports 6 GHz
181 * band TDLS
182 * @vdev: Pointer to vdev
183 *
184 * Return: true if fw supports 6 GHz TDLS connection
185 */
186 bool wlan_cfg80211_tdls_is_fw_6ghz_capable(struct wlan_objmgr_vdev *vdev);
187 #endif
188
189 /**
190 * wlan_cfg80211_tdls_mgmt_mlo() - process TDLS management frames from
191 * the supplicant
192 * @adapter: adapter object
193 * @peer: MAC address of the TDLS peer
194 * @action_code: type of TDLS mgmt frame to be sent
195 * @dialog_token: dialog token used in the frame
196 * @status_code: status to be included in the frame
197 * @peer_capability: peer capability information
198 * @buf: additional IEs to be included
199 * @len: length of additional Ies
200 * @link_id: link id
201 *
202 * Return: 0 on success; negative errno otherwise
203 */
204 int wlan_cfg80211_tdls_mgmt_mlo(struct hdd_adapter *adapter,
205 const uint8_t *peer,
206 uint8_t action_code, uint8_t dialog_token,
207 uint16_t status_code, uint32_t peer_capability,
208 const uint8_t *buf, size_t len, int link_id);
209
210 /**
211 * wlan_tdls_antenna_switch() - process TDLS antenna switch
212 * @vdev: vdev object
213 * @mode: antenna mode
214 *
215 * Return: 0 on success; -EAGAIN to retry
216 */
217 int wlan_tdls_antenna_switch(struct wlan_objmgr_vdev *vdev, uint32_t mode);
218
219 /**
220 * wlan_cfg80211_tdls_event_callback() - callback for TDLS module
221 * @userdata: user data
222 * @type: request callback type
223 * @param: passed parameter
224 *
225 * This is used by TDLS to sync with os interface
226 *
227 * Return: None
228 */
229 void wlan_cfg80211_tdls_event_callback(void *userdata,
230 enum tdls_event_type type,
231 struct tdls_osif_indication *param);
232
233 /**
234 * wlan_cfg80211_tdls_rx_callback() - Callback for rx mgmt frame
235 * @user_data: pointer to soc object
236 * @rx_frame: RX mgmt frame information
237 *
238 * This callback will be used to rx frames in os interface.
239 *
240 * Return: None
241 */
242 void wlan_cfg80211_tdls_rx_callback(void *user_data,
243 struct tdls_rx_mgmt_frame *rx_frame);
244
245 /**
246 * hdd_notify_tdls_reset_adapter() - notify reset adapter to TDLS
247 * @vdev: vdev object manager
248 *
249 * Notify hdd reset adapter to TDLS component
250 *
251 * Return: None
252 */
253 void hdd_notify_tdls_reset_adapter(struct wlan_objmgr_vdev *vdev);
254
255 #else /* FEATURE_WLAN_TDLS */
256 static inline
wlan_cfg80211_tdls_osif_priv_init(struct wlan_objmgr_vdev * vdev)257 QDF_STATUS wlan_cfg80211_tdls_osif_priv_init(struct wlan_objmgr_vdev *vdev)
258 {
259 return QDF_STATUS_SUCCESS;
260 }
261
262 static inline
wlan_cfg80211_tdls_osif_priv_deinit(struct wlan_objmgr_vdev * vdev)263 void wlan_cfg80211_tdls_osif_priv_deinit(struct wlan_objmgr_vdev *vdev)
264 {
265 }
266
267 static inline void
hdd_notify_tdls_reset_adapter(struct wlan_objmgr_vdev * vdev)268 hdd_notify_tdls_reset_adapter(struct wlan_objmgr_vdev *vdev)
269 {
270 }
271
272 static inline
wlan_cfg80211_tdls_configure_mode(struct wlan_objmgr_vdev * vdev,uint32_t trigger_mode)273 int wlan_cfg80211_tdls_configure_mode(struct wlan_objmgr_vdev *vdev,
274 uint32_t trigger_mode)
275 {
276 return 0;
277 }
278 #endif /* FEATURE_WLAN_TDLS */
279 #endif /* _WLAN_CFG80211_TDLS_H_ */
280