1 /** @file mlan_wmm.h
2 *
3 * @brief This file contains related macros, enum, and struct
4 * of wmm functionalities
5 *
6 *
7 * Copyright 2008-2021 NXP
8 *
9 * This software file (the File) is distributed by NXP
10 * under the terms of the GNU General Public License Version 2, June 1991
11 * (the License). You may use, redistribute and/or modify the File in
12 * accordance with the terms and conditions of the License, a copy of which
13 * is available by writing to the Free Software Foundation, Inc.,
14 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
15 * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
16 *
17 * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
19 * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
20 * this warranty disclaimer.
21 *
22 */
23
24 /****************************************************
25 Change log:
26 10/24/2008: initial version
27 ****************************************************/
28
29 #ifndef _MLAN_WMM_H_
30 #define _MLAN_WMM_H_
31
32 /**
33 * @brief This function gets the TID
34 *
35 * @param pmadapter A pointer to mlan_adapter structure
36 * @param ptr A pointer to RA list table
37 *
38 * @return TID
39 */
wlan_get_tid(pmlan_adapter pmadapter,praListTbl ptr)40 static INLINE t_u32 wlan_get_tid(pmlan_adapter pmadapter, praListTbl ptr)
41 {
42 pmlan_buffer mbuf;
43
44 ENTER();
45 mbuf = (pmlan_buffer)util_peek_list(pmadapter->pmoal_handle,
46 &ptr->buf_head, MNULL, MNULL);
47 LEAVE();
48
49 if (!mbuf) {
50 return 0; // The default TID,BE
51 } else
52 return mbuf->priority;
53 }
54
55 /**
56 * @brief This function gets the length of a list
57 *
58 * @param head A pointer to mlan_list_head
59 *
60 * @return Length of list
61 */
wlan_wmm_list_len(pmlan_list_head head)62 static INLINE t_u32 wlan_wmm_list_len(pmlan_list_head head)
63 {
64 pmlan_linked_list pos;
65 t_u32 count = 0;
66
67 ENTER();
68
69 pos = head->pnext;
70
71 while (pos != (pmlan_linked_list)head) {
72 ++count;
73 pos = pos->pnext;
74 }
75
76 LEAVE();
77 return count;
78 }
79
80 /**
81 * @brief This function requests a ralist lock
82 *
83 * @param priv A pointer to mlan_private structure
84 *
85 * @return N/A
86 */
wlan_request_ralist_lock(pmlan_private priv)87 static INLINE t_void wlan_request_ralist_lock(pmlan_private priv)
88 {
89 mlan_adapter *pmadapter = priv->adapter;
90 mlan_callbacks *pcb = (mlan_callbacks *)&pmadapter->callbacks;
91
92 ENTER();
93
94 /* Call MOAL spin lock callback function */
95 pcb->moal_spin_lock(pmadapter->pmoal_handle,
96 priv->wmm.ra_list_spinlock);
97
98 LEAVE();
99 return;
100 }
101
102 /**
103 * @brief This function releases a lock on ralist
104 *
105 * @param priv A pointer to mlan_private structure
106 *
107 * @return N/A
108 */
wlan_release_ralist_lock(pmlan_private priv)109 static INLINE t_void wlan_release_ralist_lock(pmlan_private priv)
110 {
111 mlan_adapter *pmadapter = priv->adapter;
112 mlan_callbacks *pcb = (mlan_callbacks *)&pmadapter->callbacks;
113
114 ENTER();
115
116 /* Call MOAL spin unlock callback function */
117 pcb->moal_spin_unlock(pmadapter->pmoal_handle,
118 priv->wmm.ra_list_spinlock);
119
120 LEAVE();
121 return;
122 }
123
124 /** Add buffer to WMM Tx queue */
125 void wlan_wmm_add_buf_txqueue(pmlan_adapter pmadapter, pmlan_buffer pmbuf);
126 /** Add to RA list */
127 void wlan_ralist_add(mlan_private *priv, t_u8 *ra);
128 /** Update the RA list */
129 int wlan_ralist_update(mlan_private *priv, t_u8 *old_ra, t_u8 *new_ra);
130
131 /** WMM status change command handler */
132 mlan_status wlan_cmd_wmm_status_change(pmlan_private priv);
133 /** Check if WMM lists are empty */
134 int wlan_wmm_lists_empty(pmlan_adapter pmadapter);
135 /** Process WMM transmission */
136 t_void wlan_wmm_process_tx(pmlan_adapter pmadapter);
137 /** Test to see if the ralist ptr is valid */
138 int wlan_is_ralist_valid(mlan_private *priv, raListTbl *ra_list, int tid);
139
140 raListTbl *wlan_wmm_get_ralist_node(pmlan_private priv, t_u8 tid,
141 t_u8 *ra_addr);
142 t_u8 wlan_get_random_ba_threshold(pmlan_adapter pmadapter);
143
144 /** Compute driver packet delay */
145 t_u8 wlan_wmm_compute_driver_packet_delay(pmlan_private priv,
146 const pmlan_buffer pmbuf);
147 /** Initialize WMM */
148 t_void wlan_wmm_init(pmlan_adapter pmadapter);
149 /** Initialize WMM paramter */
150 t_void wlan_init_wmm_param(pmlan_adapter pmadapter);
151 /** Setup WMM queues */
152 extern void wlan_wmm_setup_queues(pmlan_private priv);
153 /* Setup default queues */
154 void wlan_wmm_default_queue_priorities(pmlan_private priv);
155 /* process wmm_param_config command */
156 mlan_status wlan_cmd_wmm_param_config(pmlan_private pmpriv,
157 HostCmd_DS_COMMAND *cmd, t_u8 cmd_action,
158 t_void *pdata_buf);
159
160 /* process wmm_param_config command response */
161 mlan_status wlan_ret_wmm_param_config(pmlan_private pmpriv,
162 const HostCmd_DS_COMMAND *resp,
163 mlan_ioctl_req *pioctl_buf);
164
165 #ifdef STA_SUPPORT
166 /** Process WMM association request */
167 extern t_u32 wlan_wmm_process_association_req(pmlan_private priv,
168 t_u8 **ppAssocBuf,
169 IEEEtypes_WmmParameter_t *pWmmIE);
170 #endif /* STA_SUPPORT */
171
172 /** setup wmm queue priorities */
173 void wlan_wmm_setup_queue_priorities(pmlan_private priv,
174 IEEEtypes_WmmParameter_t *wmm_ie);
175
176 /* Get tid_down from tid */
177 int wlan_get_wmm_tid_down(mlan_private *priv, int tid);
178 /** Downgrade WMM priority queue */
179 void wlan_wmm_setup_ac_downgrade(pmlan_private priv);
180 /** select WMM queue */
181 t_u8 wlan_wmm_select_queue(mlan_private *pmpriv, t_u8 tid);
182 t_void wlan_wmm_delete_peer_ralist(pmlan_private priv, t_u8 *mac);
183
184 #ifdef STA_SUPPORT
185 /*
186 * Functions used in the cmd handling routine
187 */
188 /** WMM ADDTS request command handler */
189 extern mlan_status wlan_cmd_wmm_addts_req(pmlan_private pmpriv,
190 HostCmd_DS_COMMAND *cmd,
191 t_void *pdata_buf);
192 /** WMM DELTS request command handler */
193 extern mlan_status wlan_cmd_wmm_delts_req(pmlan_private pmpriv,
194 HostCmd_DS_COMMAND *cmd,
195 t_void *pdata_buf);
196 /** WMM QUEUE_STATS command handler */
197 extern mlan_status wlan_cmd_wmm_queue_stats(pmlan_private pmpriv,
198 HostCmd_DS_COMMAND *cmd,
199 t_void *pdata_buf);
200 /** WMM TS_STATUS command handler */
201 extern mlan_status wlan_cmd_wmm_ts_status(pmlan_private pmpriv,
202 HostCmd_DS_COMMAND *cmd,
203 t_void *pdata_buf);
204
205 /*
206 * Functions used in the cmdresp handling routine
207 */
208 /** WMM get status command response handler */
209 extern mlan_status wlan_ret_wmm_get_status(pmlan_private priv, t_u8 *ptlv,
210 int resp_len);
211 /** WMM ADDTS request command response handler */
212 extern mlan_status wlan_ret_wmm_addts_req(pmlan_private pmpriv,
213 const HostCmd_DS_COMMAND *resp,
214 mlan_ioctl_req *pioctl_buf);
215 /** WMM DELTS request command response handler */
216 extern mlan_status wlan_ret_wmm_delts_req(pmlan_private pmpriv,
217 const HostCmd_DS_COMMAND *resp,
218 mlan_ioctl_req *pioctl_buf);
219 /** WMM QUEUE_STATS command response handler */
220 extern mlan_status wlan_ret_wmm_queue_stats(pmlan_private pmpriv,
221 const HostCmd_DS_COMMAND *resp,
222 mlan_ioctl_req *pioctl_buf);
223 /** WMM TS_STATUS command response handler */
224 extern mlan_status wlan_ret_wmm_ts_status(pmlan_private pmpriv,
225 HostCmd_DS_COMMAND *resp,
226 mlan_ioctl_req *pioctl_buf);
227
228 extern t_u8 tos_to_tid_inv[];
229 extern t_u8 ac_to_tid[4][2];
230 #endif /* STA_SUPPORT */
231
232 /** WMM QUEUE_CONFIG command handler */
233 extern mlan_status wlan_cmd_wmm_queue_config(pmlan_private pmpriv,
234 HostCmd_DS_COMMAND *cmd,
235 t_void *pdata_buf);
236
237 /** WMM QUEUE_CONFIG command response handler */
238 extern mlan_status wlan_ret_wmm_queue_config(pmlan_private pmpriv,
239 const HostCmd_DS_COMMAND *resp,
240 mlan_ioctl_req *pioctl_buf);
241
242 mlan_status wlan_wmm_cfg_ioctl(pmlan_adapter pmadapter,
243 pmlan_ioctl_req pioctl_req);
244 #endif /* !_MLAN_WMM_H_ */
245