1 /*
2  * Copyright (c) 2014-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-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 #if !defined(WLAN_HDD_SOFTAP_TX_RX_H)
21 #define WLAN_HDD_SOFTAP_TX_RX_H
22 
23 /**
24  * DOC: wlan_hdd_softap_tx_rx.h
25  *
26  * Linux HDD SOFTAP Tx/Rx APIs
27  */
28 
29 #include <wlan_hdd_hostapd.h>
30 #include <cdp_txrx_peer_ops.h>
31 
32 #define hdd_sapd_alert(params...) \
33 	QDF_TRACE_FATAL(QDF_MODULE_ID_HDD_SAP_DATA, params)
34 #define hdd_sapd_err(params...) \
35 	QDF_TRACE_ERROR(QDF_MODULE_ID_HDD_SAP_DATA, params)
36 #define hdd_sapd_warn(params...) \
37 	QDF_TRACE_WARN(QDF_MODULE_ID_HDD_SAP_DATA, params)
38 #define hdd_sapd_info(params...) \
39 	QDF_TRACE_INFO(QDF_MODULE_ID_HDD_SAP_DATA, params)
40 #define hdd_sapd_debug(params...) \
41 	QDF_TRACE_DEBUG(QDF_MODULE_ID_HDD_SAP_DATA, params)
42 
43 #define hdd_sapd_nofl_alert(params...) \
44 	QDF_TRACE_FATAL_NO_FL(QDF_MODULE_ID_HDD_SAP_DATA, params)
45 #define hdd_sapd_nofl_err(params...) \
46 	QDF_TRACE_ERROR_NO_FL(QDF_MODULE_ID_HDD_SAP_DATA, params)
47 #define hdd_sapd_nofl_warn(params...) \
48 	QDF_TRACE_WARN_NO_FL(QDF_MODULE_ID_HDD_SAP_DATA, params)
49 #define hdd_sapd_nofl_info(params...) \
50 	QDF_TRACE_INFO_NO_FL(QDF_MODULE_ID_HDD_SAP_DATA, params)
51 #define hdd_sapd_nofl_debug(params...) \
52 	QDF_TRACE_DEBUG_NO_FL(QDF_MODULE_ID_HDD_SAP_DATA, params)
53 
54 #define hdd_sapd_alert_rl(params...) \
55 	QDF_TRACE_FATAL_RL(QDF_MODULE_ID_HDD_SAP_DATA, params)
56 #define hdd_sapd_err_rl(params...) \
57 	QDF_TRACE_ERROR_RL(QDF_MODULE_ID_HDD_SAP_DATA, params)
58 #define hdd_sapd_warn_rl(params...) \
59 	QDF_TRACE_WARN_RL(QDF_MODULE_ID_HDD_SAP_DATA, params)
60 #define hdd_sapd_info_rl(params...) \
61 	QDF_TRACE_INFO_RL(QDF_MODULE_ID_HDD_SAP_DATA, params)
62 #define hdd_sapd_debug_rl(params...) \
63 	QDF_TRACE_DEBUG_RL(QDF_MODULE_ID_HDD_SAP_DATA, params)
64 
65 /**
66  * hdd_softap_hard_start_xmit() - Transmit a frame
67  * @skb: pointer to OS packet
68  * @dev: pointer to net_device structure
69  *
70  * Function registered as a net_device .ndo_start_xmit() method for
71  * master mode interfaces (SoftAP/P2P GO), called by the OS if any
72  * packet needs to be transmitted.
73  *
74  * Return: Status of the transmission
75  */
76 netdev_tx_t hdd_softap_hard_start_xmit(struct sk_buff *skb,
77 				       struct net_device *dev);
78 
79 /**
80  * hdd_softap_ipa_start_xmit() - Transmit a frame, request from IPA
81  * @nbuf: pointer to buffer/packet
82  * @dev: pointer to net_device structure
83  *
84  * Function registered as a xmit callback in SAP mode,
85  * called by IPA if any packet needs to be transmitted.
86  *
87  * Return: Status of the transmission
88  */
89 QDF_STATUS hdd_softap_ipa_start_xmit(qdf_nbuf_t nbuf, qdf_netdev_t dev);
90 
91 /**
92  * hdd_softap_tx_timeout() - TX timeout handler
93  * @dev: pointer to network device
94  * @txqueue: tx queue
95  *
96  * Function registered as a net_device .ndo_tx_timeout() method for
97  * master mode interfaces (SoftAP/P2P GO), called by the OS if the
98  * driver takes too long to transmit a frame.
99  *
100  * Return: None
101  */
102 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0))
103 void hdd_softap_tx_timeout(struct net_device *dev, unsigned int txqueue);
104 #else
105 void hdd_softap_tx_timeout(struct net_device *dev);
106 #endif
107 
108 /**
109  * hdd_softap_init_tx_rx_sta() - Initialize Tx/Rx for a softap station
110  * @adapter: pointer to adapter context
111  * @sta_mac: pointer to the MAC address of the station
112  *
113  * Return: QDF_STATUS_E_FAILURE if any errors encountered,
114  *	   QDF_STATUS_SUCCESS otherwise
115  */
116 QDF_STATUS hdd_softap_init_tx_rx_sta(struct hdd_adapter *adapter,
117 				     struct qdf_mac_addr *sta_mac);
118 
119 /**
120  * hdd_softap_deregister_sta() - Deregister a STA with the Data Path
121  * @adapter: pointer to adapter context
122  * @sta_info: double pointer to HDD station info structure
123  *
124  * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
125  */
126 QDF_STATUS hdd_softap_deregister_sta(struct hdd_adapter *adapter,
127 				     struct hdd_station_info **sta_info);
128 
129 /**
130  * hdd_softap_register_sta() - Register a SoftAP STA
131  * @link_info: Link info pointer in HDD adapter
132  * @auth_required: is additional authentication required?
133  * @privacy_required: should 802.11 privacy bit be set?
134  * @sta_mac: station MAC address
135  * @event: STA assoc complete event (Can be NULL)
136  *
137  * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
138  */
139 QDF_STATUS
140 hdd_softap_register_sta(struct wlan_hdd_link_info *link_info,
141 			bool auth_required, bool privacy_required,
142 			struct qdf_mac_addr *sta_mac,
143 			tSap_StationAssocReassocCompleteEvent *event);
144 
145 /**
146  * hdd_softap_register_bc_sta() - Register the SoftAP broadcast STA
147  * @link_info: Link info pointer in HDD adapter
148  * @privacy_required: should 802.11 privacy bit be set?
149  *
150  * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
151  */
152 QDF_STATUS hdd_softap_register_bc_sta(struct wlan_hdd_link_info *link_info,
153 				      bool privacy_required);
154 
155 /**
156  * hdd_softap_stop_bss() - Stop the BSS
157  * @adapter: pointer to adapter context
158  *
159  * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
160  */
161 QDF_STATUS hdd_softap_stop_bss(struct hdd_adapter *adapter);
162 
163 /**
164  * hdd_softap_change_sta_state() - Change the state of a SoftAP station
165  * @adapter: pointer to adapter context
166  * @sta_mac: MAC address of the station
167  * @state: new state of the station
168  *
169  * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
170  */
171 QDF_STATUS hdd_softap_change_sta_state(struct hdd_adapter *adapter,
172 				       struct qdf_mac_addr *sta_mac,
173 				       enum ol_txrx_peer_state state);
174 
175 #ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL
176 /**
177  * hdd_softap_tx_resume_timer_expired_handler() - TX Q resume timer handler
178  * @adapter_context: pointer to vdev adapter
179  *
180  * TX Q resume timer handler for SAP and P2P GO interface.  If Blocked
181  * OS Q is not resumed during timeout period, to prevent permanent
182  * stall, resume OS Q forcefully for SAP and P2P GO interface.
183  *
184  * Return: None
185  */
186 void hdd_softap_tx_resume_timer_expired_handler(void *adapter_context);
187 
188 /**
189  * hdd_softap_tx_resume_cb() - Resume OS TX Q.
190  * @adapter_context: pointer to vdev apdapter
191  * @tx_resume: TX Q resume trigger
192  *
193  * Q was stopped due to WLAN TX path low resource condition
194  *
195  * Return: None
196  */
197 void hdd_softap_tx_resume_cb(void *adapter_context, bool tx_resume);
198 #else
199 static inline
hdd_softap_tx_resume_timer_expired_handler(void * adapter_context)200 void hdd_softap_tx_resume_timer_expired_handler(void *adapter_context)
201 {
202 }
203 
204 static inline
hdd_softap_tx_resume_cb(void * adapter_context,bool tx_resume)205 void hdd_softap_tx_resume_cb(void *adapter_context, bool tx_resume)
206 {
207 }
208 #endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */
209 
210 /**
211  * hdd_ipa_update_rx_mcbc_stats() - Update broadcast multicast stats
212  * @adapter: pointer to hdd adapter
213  * @skb: pointer to netbuf
214  *
215  * Check if multicast or broadcast pkt was received and increment
216  * the stats accordingly. This is required only if IPA is enabled
217  * as in case of regular Rx path mcast/bcast stats are processed
218  * in the dp layer.
219  *
220  * Return: None
221  */
222 void hdd_ipa_update_rx_mcbc_stats(struct hdd_adapter *adapter,
223 				  struct sk_buff *skb);
224 
225 #ifdef FEATURE_WDS
226 /**
227  * hdd_softap_ind_l2_update() - Send L2 update frame to bridge
228  * @adapter: pointer to adapter context
229  * @sta_mac: pointer to the MAC address of the station
230  *
231  * The layer-2 update frame is an 802.2 type LLC exchange identifier (XID)
232  * update response frame. This frame is sent using a MAC source address of
233  * the newly associated station. Upon the reception of this frame,
234  * all the layer-2 devices update their forwarding tables with the correct
235  * port to reach the new location of the station according to the ieee802.1d
236  * bridge table self learning procedure.
237  *
238  * Return: QDF_STATUS_E_FAILURE if any errors encountered,
239  *	   QDF_STATUS_SUCCESS otherwise
240  */
241 QDF_STATUS hdd_softap_ind_l2_update(struct hdd_adapter *adapter,
242 				    struct qdf_mac_addr *sta_mac);
243 #else
244 static inline
hdd_softap_ind_l2_update(struct hdd_adapter * adapter,struct qdf_mac_addr * sta_mac)245 QDF_STATUS hdd_softap_ind_l2_update(struct hdd_adapter *adapter,
246 				    struct qdf_mac_addr *sta_mac)
247 {
248 	return QDF_STATUS_SUCCESS;
249 }
250 #endif
251 #endif /* end #if !defined(WLAN_HDD_SOFTAP_TX_RX_H) */
252