blob: 3944386cfe66ca767e5fa2da503de69e0ad0260e [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302 * Copyright (c) 2011-2012,2016 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28#ifndef _WLAN_HDD_WMM_H
29#define _WLAN_HDD_WMM_H
30
31/**
32 * DOC: HDD WMM
33 *
34 * This module (wlan_hdd_wmm.h interface + wlan_hdd_wmm.c implementation)
35 * houses all the logic for WMM in HDD.
36 *
37 * On the control path, it has the logic to setup QoS, modify QoS and delete
38 * QoS (QoS here refers to a TSPEC). The setup QoS comes in two flavors: an
39 * explicit application invoked and an internal HDD invoked. The implicit QoS
40 * is for applications that do NOT call the custom QCT WLAN OIDs for QoS but
41 * which DO mark their traffic for priortization. It also has logic to start,
42 * update and stop the U-APSD trigger frame generation. It also has logic to
43 * read WMM related config parameters from the registry.
44 *
45 * On the data path, it has the logic to figure out the WMM AC of an egress
46 * packet and when to signal TL to serve a particular AC queue. It also has the
47 * logic to retrieve a packet based on WMM priority in response to a fetch from
48 * TL.
49 *
50 * The remaining functions are utility functions for information hiding.
51 */
52
53/* Include files */
54#include <linux/workqueue.h>
55#include <linux/list.h>
56#include <wlan_hdd_main.h>
57#include <wlan_hdd_wext.h>
58#include <sme_qos_api.h>
59
60/*Maximum number of ACs */
61#define WLAN_MAX_AC 4
62
63
64/* Preprocessor Definitions and Constants */
65
66/* #define HDD_WMM_DEBUG 1 */
67
68#define HDD_WMM_CTX_MAGIC 0x574d4d58 /* "WMMX" */
69
70#define HDD_WMM_HANDLE_IMPLICIT 0xFFFFFFFF
71
72#define HDD_WLAN_INVALID_STA_ID 0xFF
73
74/* Type Declarations */
75
76/**
77 * enum hdd_wmm_classification: types of classification supported
78 */
79typedef enum hdd_wmm_classification {
80 HDD_WMM_CLASSIFICATION_DSCP = 0,
81 HDD_WMM_CLASSIFICATION_802_1Q = 1
82} hdd_wmm_classification_t;
83
84/**
85 * enum hdd_wmm_user_mode - WMM modes of operation
86 *
87 * @HDD_WMM_USER_MODE_AUTO: STA can associate with any AP, & HDD looks at
88 * the SME notification after association to find out if associated
89 * with QAP and acts accordingly
90 * @HDD_WMM_USER_MODE_QBSS_ONLY - SME will add the extra logic to make sure
91 * STA associates with a QAP only
Padma, Santhosh Kumara9e08e92016-10-12 16:44:23 +053092 * @HDD_WMM_USER_MODE_NO_QOS - Join any AP, but uapsd is disabled
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080093 */
94typedef enum hdd_wmm_user_mode {
95 HDD_WMM_USER_MODE_AUTO = 0,
96 HDD_WMM_USER_MODE_QBSS_ONLY = 1,
97 HDD_WMM_USER_MODE_NO_QOS = 2,
98} hdd_wmm_user_mode_t;
99
100/* UAPSD Mask bits */
101/* (Bit0:VO; Bit1:VI; Bit2:BK; Bit3:BE all other bits are ignored) */
102#define HDD_AC_VO 0x1
103#define HDD_AC_VI 0x2
104#define HDD_AC_BK 0x4
105#define HDD_AC_BE 0x8
106
107/**
108 * struct hdd_wmm_qos_context - HDD WMM QoS Context
109 *
110 * This structure holds the context for a single flow which has either
111 * been confgured explicitly from userspace or implicitly via the
112 * Implicit QoS feature.
113 *
114 * @node: list node which can be used to put the context into a list
115 * of contexts
116 * @handle: identifer which uniquely identifies this context to userspace
117 * @qosFlowID: identifier which uniquely identifies this flow to SME
118 * @pAdapter: adapter upon which this flow was configured
119 * @acType: access category for this flow
120 * @lastStatus: the status of the last operation performed on this flow by SME
121 * @wmmAcSetupImplicitQos: work structure used for deferring implicit QoS work
122 * from softirq context to thread context
123 * @magic: magic number used to verify that this is a valid context when
124 * referenced anonymously
125 */
126typedef struct hdd_wmm_qos_context {
127 struct list_head node;
128 uint32_t handle;
129 uint32_t qosFlowId;
130 hdd_adapter_t *pAdapter;
131 sme_ac_enum_type acType;
132 hdd_wlan_wmm_status_e lastStatus;
133 struct work_struct wmmAcSetupImplicitQos;
134 uint32_t magic;
135 bool is_inactivity_timer_running;
136} hdd_wmm_qos_context_t;
137
138/**
139 * struct hdd_wmm_ac_status - WMM related per-AC state & status info
140 * @wmmAcAccessRequired - does the AP require access to this AC?
141 * @wmmAcAccessNeeded - does the worker thread need to acquire access to
142 * this AC?
143 * @wmmAcAccessPending - is implicit QoS negotiation currently taking place?
144 * @wmmAcAccessFailed - has implicit QoS negotiation already failed?
145 * @wmmAcAccessGranted - has implicit QoS negotiation already succeeded?
146 * @wmmAcAccessAllowed - is access to this AC allowed, either because we
147 * are not doing WMM, we are not doing implicit QoS, implict QoS has
148 * completed, or explicit QoS has completed?
149 * @wmmAcTspecValid - is the wmmAcTspecInfo valid?
150 * @wmmAcUapsdInfoValid - are the wmmAcUapsd* fields valid?
151 * @wmmAcTspecInfo - current (possibly aggregate) Tspec for this AC
152 * @wmmAcIsUapsdEnabled - is UAPSD enabled on this AC?
153 * @wmmAcUapsdServiceInterval - service interval for this AC
154 * @wmmAcUapsdSuspensionInterval - suspension interval for this AC
155 * @wmmAcUapsdDirection - direction for this AC
156 * @wmmInactivityTime - inactivity time for this AC
157 * @wmmPrevTrafficCnt - TX counter used for inactivity detection
158 * @wmmInactivityTimer - timer used for inactivity detection
159 */
160typedef struct hdd_wmm_ac_status {
161 bool wmmAcAccessRequired;
162 bool wmmAcAccessNeeded;
163 bool wmmAcAccessPending;
164 bool wmmAcAccessFailed;
165 bool wmmAcAccessGranted;
166 bool wmmAcAccessAllowed;
167 bool wmmAcTspecValid;
168 bool wmmAcUapsdInfoValid;
169 sme_QosWmmTspecInfo wmmAcTspecInfo;
170 bool wmmAcIsUapsdEnabled;
171 uint32_t wmmAcUapsdServiceInterval;
172 uint32_t wmmAcUapsdSuspensionInterval;
173 sme_QosWmmDirType wmmAcUapsdDirection;
174
175#ifdef FEATURE_WLAN_ESE
176 uint32_t wmmInactivityTime;
177 uint32_t wmmPrevTrafficCnt;
Anurag Chouhan210db072016-02-22 18:42:15 +0530178 qdf_mc_timer_t wmmInactivityTimer;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800179#endif
180
181} hdd_wmm_ac_status_t;
182
183/**
184 * struct hdd_wmm_status - WMM status maintained per-adapter
185 * @wmmContextList - list of WMM contexts active on the adapter
186 * @wmmLock - mutex used for exclusive access to this adapter's WMM status
187 * @wmmACStatus - per-AC WMM status
188 * @wmmQap - is this connected to a QoS-enabled AP?
189 * @wmmQosConnection - is this a QoS connection?
190 */
191typedef struct hdd_wmm_status {
192 struct list_head wmmContextList;
193 struct mutex wmmLock;
194 hdd_wmm_ac_status_t wmmAcStatus[WLAN_MAX_AC];
195 bool wmmQap;
196 bool wmmQosConnection;
197} hdd_wmm_status_t;
198
199extern const uint8_t hdd_qdisc_ac_to_tl_ac[];
200extern const uint8_t hdd_wmm_up_to_ac_map[];
201extern const uint8_t hdd_linux_up_to_ac_map[];
202
203#define WLAN_HDD_MAX_DSCP 0x3f
204
205/**
206 * hdd_wmmps_helper() - Function to set uapsd psb dynamically
207 *
208 * @pAdapter: [in] pointer to adapter structure
209 * @ptr: [in] pointer to command buffer
210 *
211 * Return: Zero on success, appropriate error on failure.
212 */
213int hdd_wmmps_helper(hdd_adapter_t *pAdapter, uint8_t *ptr);
214
215/**
216 * hdd_wmm_init() - initialize the WMM DSCP configuation
217 * @pAdapter : [in] pointer to Adapter context
218 *
219 * This function will initialize the WMM DSCP configuation of an
220 * adapter to an initial state. The configuration can later be
221 * overwritten via application APIs or via QoS Map sent OTA.
222 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530223 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800224 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530225QDF_STATUS hdd_wmm_init(hdd_adapter_t *pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800226
227/**
228 * hdd_wmm_adapter_init() - initialize the WMM configuration of an adapter
229 * @pAdapter: [in] pointer to Adapter context
230 *
231 * This function will initialize the WMM configuation and status of an
232 * adapter to an initial state. The configuration can later be
233 * overwritten via application APIs
234 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530235 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800236 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530237QDF_STATUS hdd_wmm_adapter_init(hdd_adapter_t *pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800238
239/**
240 * hdd_wmm_close() - WMM close function
241 * @pAdapter: [in] pointer to adapter context
242 *
243 * Function which will perform any necessary work to to clean up the
244 * WMM functionality prior to the kernel module unload.
245 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530246 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800247 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530248QDF_STATUS hdd_wmm_adapter_close(hdd_adapter_t *pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800249
250/**
251 * hdd_wmm_select_queue() - Function which will classify the packet
252 * according to linux qdisc expectation.
253 *
254 * @dev: [in] pointer to net_device structure
255 * @skb: [in] pointer to os packet
256 *
257 * Return: Qdisc queue index
258 */
259uint16_t hdd_wmm_select_queue(struct net_device *dev, struct sk_buff *skb);
260
261/**
262 * hdd_hostapd_select_queue() - Function which will classify the packet
263 * according to linux qdisc expectation.
264 *
265 * @dev: [in] pointer to net_device structure
266 * @skb: [in] pointer to os packet
267 *
268 * Return: Qdisc queue index
269 */
270uint16_t hdd_hostapd_select_queue(struct net_device *dev, struct sk_buff *skb
271#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0))
272 , void *accel_priv
273#endif
274#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0))
275 , select_queue_fallback_t fallback
276#endif
277);
278
279/**
280 * hdd_wmm_acquire_access_required() - Function which will determine
281 * acquire admittance for a WMM AC is required or not based on psb configuration
282 * done in framework
283 *
284 * @pAdapter: [in] pointer to adapter structure
285 * @acType: [in] WMM AC type of OS packet
286 *
287 * Return: void
288 */
289void hdd_wmm_acquire_access_required(hdd_adapter_t *pAdapter,
290 sme_ac_enum_type acType);
291
292/**
293 * hdd_wmm_acquire_access() - Function which will attempt to acquire
294 * admittance for a WMM AC
295 *
296 * @pAdapter: [in] pointer to adapter context
297 * @acType: [in] WMM AC type of OS packet
298 * @pGranted: [out] pointer to bool flag when indicates if access
299 * has been granted or not
300 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530301 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800302 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530303QDF_STATUS hdd_wmm_acquire_access(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800304 sme_ac_enum_type acType, bool *pGranted);
305
306/**
307 * hdd_wmm_assoc() - Function which will handle the housekeeping
308 * required by WMM when association takes place
309 *
310 * @pAdapter: [in] pointer to adapter context
311 * @pRoamInfo: [in] pointer to roam information
312 * @eBssType: [in] type of BSS
313 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530314 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800315 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530316QDF_STATUS hdd_wmm_assoc(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800317 tCsrRoamInfo *pRoamInfo, eCsrRoamBssType eBssType);
318
319/**
320 * hdd_wmm_connect() - Function which will handle the housekeeping
321 * required by WMM when a connection is established
322 *
323 * @pAdapter : [in] pointer to adapter context
324 * @pRoamInfo: [in] pointer to roam information
325 * @eBssType : [in] type of BSS
326 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530327 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800328 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530329QDF_STATUS hdd_wmm_connect(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800330 tCsrRoamInfo *pRoamInfo, eCsrRoamBssType eBssType);
331
332/**
333 * hdd_wmm_get_uapsd_mask() - Function which will calculate the
334 * initial value of the UAPSD mask based upon the device configuration
335 *
336 * @pAdapter : [in] pointer to adapter context
337 * @pUapsdMask: [out] pointer to where the UAPSD Mask is to be stored
338 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530339 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800340 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530341QDF_STATUS hdd_wmm_get_uapsd_mask(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800342 uint8_t *pUapsdMask);
343
344/**
345 * hdd_wmm_is_active() - Function which will determine if WMM is
346 * active on the current connection
347 *
348 * @pAdapter: [in] pointer to adapter context
349 *
350 * Return: true if WMM is enabled, false if WMM is not enabled
351 */
352bool hdd_wmm_is_active(hdd_adapter_t *pAdapter);
353
354/**
355 * hdd_wmm_addts() - Function which will add a traffic spec at the
356 * request of an application
357 *
358 * @pAdapter : [in] pointer to adapter context
359 * @handle : [in] handle to uniquely identify a TS
360 * @pTspec : [in] pointer to the traffic spec
361 *
362 * Return: HDD_WLAN_WMM_STATUS_*
363 */
364hdd_wlan_wmm_status_e hdd_wmm_addts(hdd_adapter_t *pAdapter,
365 uint32_t handle,
366 sme_QosWmmTspecInfo *pTspec);
367
368/**
369 * hdd_wmm_delts() - Function which will delete a traffic spec at the
370 * request of an application
371 *
372 * @pAdapter: [in] pointer to adapter context
373 * @handle: [in] handle to uniquely identify a TS
374 *
375 * Return: HDD_WLAN_WMM_STATUS_*
376 */
377hdd_wlan_wmm_status_e hdd_wmm_delts(hdd_adapter_t *pAdapter, uint32_t handle);
378
379/**
380 * hdd_wmm_checkts() - Function which will return the status of a traffic
381 * spec at the request of an application
382 *
383 * @pAdapter: [in] pointer to adapter context
384 * @handle: [in] handle to uniquely identify a TS
385 *
386 * Return: HDD_WLAN_WMM_STATUS_*
387 */
388hdd_wlan_wmm_status_e hdd_wmm_checkts(hdd_adapter_t *pAdapter,
389 uint32_t handle);
390/**
391 * hdd_wmm_adapter_clear() - Function which will clear the WMM status
392 * for all the ACs
393 *
394 * @pAdapter: [in] pointer to Adapter context
395 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530396 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800397 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530398QDF_STATUS hdd_wmm_adapter_clear(hdd_adapter_t *pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800399
400void wlan_hdd_process_peer_unauthorised_pause(hdd_adapter_t *adapter);
401#endif /* #ifndef _WLAN_HDD_WMM_H */