1 /** @file mlan_wmm.h
2 *
3 * @brief This file contains related macros, enum, and struct
4 * of wmm functionalities
5 *
6 * Copyright (C) 2008-2017, Marvell International Ltd.
7 *
8 * This software file (the "File") is distributed by Marvell International
9 * Ltd. under the terms of the GNU General Public License Version 2, June 1991
10 * (the "License"). You may use, redistribute and/or modify this File in
11 * accordance with the terms and conditions of the License, a copy of which
12 * is available by writing to the Free Software Foundation, Inc.,
13 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
14 * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
15 *
16 * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
18 * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
19 * this warranty disclaimer.
20 */
21
22 /****************************************************
23 Change log:
24 10/24/2008: initial version
25 ****************************************************/
26
27 #ifndef _MLAN_WMM_H_
28 #define _MLAN_WMM_H_
29
30 /**
31 * @brief This function gets the TID
32 *
33 * @param pmadapter A pointer to mlan_adapter structure
34 * @param ptr A pointer to RA list table
35 *
36 * @return TID
37 */
38 static INLINE int
wlan_get_tid(pmlan_adapter pmadapter,raListTbl * ptr)39 wlan_get_tid(pmlan_adapter pmadapter, raListTbl *ptr)
40 {
41 pmlan_buffer mbuf;
42
43 ENTER();
44 mbuf = (pmlan_buffer)util_peek_list(pmadapter->pmoal_handle,
45 &ptr->buf_head, MNULL, MNULL);
46 LEAVE();
47
48 return mbuf->priority;
49 }
50
51 /**
52 * @brief This function gets the length of a list
53 *
54 * @param pmadapter A pointer to mlan_adapter structure
55 * @param head A pointer to mlan_list_head
56 *
57 * @return Length of list
58 */
59 static INLINE int
wlan_wmm_list_len(pmlan_adapter pmadapter,pmlan_list_head head)60 wlan_wmm_list_len(pmlan_adapter pmadapter, pmlan_list_head head)
61 {
62 pmlan_linked_list pos;
63 int count = 0;
64
65 ENTER();
66
67 pos = head->pnext;
68
69 while (pos != (pmlan_linked_list)head) {
70 ++count;
71 pos = pos->pnext;
72 }
73
74 LEAVE();
75 return count;
76 }
77
78 /**
79 * @brief This function requests a ralist lock
80 *
81 * @param priv A pointer to mlan_private structure
82 *
83 * @return N/A
84 */
85 static INLINE t_void
wlan_request_ralist_lock(IN mlan_private * priv)86 wlan_request_ralist_lock(IN mlan_private *priv)
87 {
88 mlan_adapter *pmadapter = priv->adapter;
89 mlan_callbacks *pcb = (mlan_callbacks *)&pmadapter->callbacks;
90
91 ENTER();
92
93 /* Call MOAL spin lock callback function */
94 pcb->moal_spin_lock(pmadapter->pmoal_handle,
95 priv->wmm.ra_list_spinlock);
96
97 LEAVE();
98 return;
99 }
100
101 /**
102 * @brief This function releases a lock on ralist
103 *
104 * @param priv A pointer to mlan_private structure
105 *
106 * @return N/A
107 */
108 static INLINE t_void
wlan_release_ralist_lock(IN mlan_private * priv)109 wlan_release_ralist_lock(IN mlan_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(IN pmlan_private pmpriv,
157 OUT HostCmd_DS_COMMAND *cmd,
158 IN t_u8 cmd_action, IN t_void *pdata_buf);
159
160 /* process wmm_param_config command response */
161 mlan_status wlan_ret_wmm_param_config(IN pmlan_private pmpriv,
162 const IN HostCmd_DS_COMMAND *resp,
163 OUT 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 IEEEtypes_HTCap_t *pHTCap);
171 #endif /* STA_SUPPORT */
172
173 /** setup wmm queue priorities */
174 void wlan_wmm_setup_queue_priorities(pmlan_private priv,
175 IEEEtypes_WmmParameter_t *wmm_ie);
176
177 /* Get tid_down from tid */
178 int wlan_get_wmm_tid_down(mlan_private *priv, int tid);
179 /** Downgrade WMM priority queue */
180 void wlan_wmm_setup_ac_downgrade(pmlan_private priv);
181 /** select WMM queue */
182 t_u8 wlan_wmm_select_queue(mlan_private *pmpriv, t_u8 tid);
183 t_void wlan_wmm_delete_peer_ralist(pmlan_private priv, t_u8 *mac);
184
185 #ifdef STA_SUPPORT
186 /*
187 * Functions used in the cmd handling routine
188 */
189 /** WMM ADDTS request command handler */
190 extern mlan_status wlan_cmd_wmm_addts_req(IN pmlan_private pmpriv,
191 OUT HostCmd_DS_COMMAND *cmd,
192 IN t_void *pdata_buf);
193 /** WMM DELTS request command handler */
194 extern mlan_status wlan_cmd_wmm_delts_req(IN pmlan_private pmpriv,
195 OUT HostCmd_DS_COMMAND *cmd,
196 IN t_void *pdata_buf);
197 /** WMM QUEUE_STATS command handler */
198 extern mlan_status wlan_cmd_wmm_queue_stats(IN pmlan_private pmpriv,
199 OUT HostCmd_DS_COMMAND *cmd,
200 IN t_void *pdata_buf);
201 /** WMM TS_STATUS command handler */
202 extern mlan_status wlan_cmd_wmm_ts_status(IN pmlan_private pmpriv,
203 OUT HostCmd_DS_COMMAND *cmd,
204 IN t_void *pdata_buf);
205
206 /*
207 * Functions used in the cmdresp handling routine
208 */
209 /** WMM get status command response handler */
210 extern mlan_status wlan_ret_wmm_get_status(IN pmlan_private priv,
211 IN t_u8 *ptlv, IN int resp_len);
212 /** WMM ADDTS request command response handler */
213 extern mlan_status wlan_ret_wmm_addts_req(IN pmlan_private pmpriv,
214 const IN HostCmd_DS_COMMAND *resp,
215 OUT mlan_ioctl_req *pioctl_buf);
216 /** WMM DELTS request command response handler */
217 extern mlan_status wlan_ret_wmm_delts_req(IN pmlan_private pmpriv,
218 const IN HostCmd_DS_COMMAND *resp,
219 OUT mlan_ioctl_req *pioctl_buf);
220 /** WMM QUEUE_STATS command response handler */
221 extern mlan_status wlan_ret_wmm_queue_stats(IN pmlan_private pmpriv,
222 const IN HostCmd_DS_COMMAND *resp,
223 OUT mlan_ioctl_req *pioctl_buf);
224 /** WMM TS_STATUS command response handler */
225 extern mlan_status wlan_ret_wmm_ts_status(IN pmlan_private pmpriv,
226 IN HostCmd_DS_COMMAND *resp,
227 OUT mlan_ioctl_req *pioctl_buf);
228 #endif /* STA_SUPPORT */
229
230 /** WMM QUEUE_CONFIG command handler */
231 extern mlan_status wlan_cmd_wmm_queue_config(IN pmlan_private pmpriv,
232 OUT HostCmd_DS_COMMAND *cmd,
233 IN t_void *pdata_buf);
234
235 /** WMM QUEUE_CONFIG command response handler */
236 extern mlan_status wlan_ret_wmm_queue_config(IN pmlan_private pmpriv,
237 const IN HostCmd_DS_COMMAND *resp,
238 OUT mlan_ioctl_req *pioctl_buf);
239
240 mlan_status wlan_wmm_cfg_ioctl(IN pmlan_adapter pmadapter,
241 IN pmlan_ioctl_req pioctl_req);
242 #endif /* !_MLAN_WMM_H_ */
243