blob: 84cd0a87add7938beff6b73bb738bcd2f26837f3 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Srinivas Girigowdaea32d6a2017-03-25 00:03:12 -07002 * Copyright (c) 2011-2012,2016-2017 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/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080077 * enum hdd_wmm_user_mode - WMM modes of operation
78 *
79 * @HDD_WMM_USER_MODE_AUTO: STA can associate with any AP, & HDD looks at
80 * the SME notification after association to find out if associated
81 * with QAP and acts accordingly
82 * @HDD_WMM_USER_MODE_QBSS_ONLY - SME will add the extra logic to make sure
83 * STA associates with a QAP only
Padma, Santhosh Kumara9e08e92016-10-12 16:44:23 +053084 * @HDD_WMM_USER_MODE_NO_QOS - Join any AP, but uapsd is disabled
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080085 */
Srinivas Girigowdaea32d6a2017-03-25 00:03:12 -070086enum hdd_wmm_user_mode {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080087 HDD_WMM_USER_MODE_AUTO = 0,
88 HDD_WMM_USER_MODE_QBSS_ONLY = 1,
89 HDD_WMM_USER_MODE_NO_QOS = 2,
Srinivas Girigowdaea32d6a2017-03-25 00:03:12 -070090};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080091
92/* UAPSD Mask bits */
93/* (Bit0:VO; Bit1:VI; Bit2:BK; Bit3:BE all other bits are ignored) */
94#define HDD_AC_VO 0x1
95#define HDD_AC_VI 0x2
96#define HDD_AC_BK 0x4
97#define HDD_AC_BE 0x8
98
99/**
100 * struct hdd_wmm_qos_context - HDD WMM QoS Context
101 *
102 * This structure holds the context for a single flow which has either
103 * been confgured explicitly from userspace or implicitly via the
104 * Implicit QoS feature.
105 *
106 * @node: list node which can be used to put the context into a list
107 * of contexts
108 * @handle: identifer which uniquely identifies this context to userspace
109 * @qosFlowID: identifier which uniquely identifies this flow to SME
110 * @pAdapter: adapter upon which this flow was configured
111 * @acType: access category for this flow
112 * @lastStatus: the status of the last operation performed on this flow by SME
113 * @wmmAcSetupImplicitQos: work structure used for deferring implicit QoS work
114 * from softirq context to thread context
115 * @magic: magic number used to verify that this is a valid context when
116 * referenced anonymously
117 */
Srinivas Girigowdaea32d6a2017-03-25 00:03:12 -0700118struct hdd_wmm_qos_context {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800119 struct list_head node;
120 uint32_t handle;
121 uint32_t qosFlowId;
122 hdd_adapter_t *pAdapter;
123 sme_ac_enum_type acType;
124 hdd_wlan_wmm_status_e lastStatus;
125 struct work_struct wmmAcSetupImplicitQos;
126 uint32_t magic;
127 bool is_inactivity_timer_running;
Srinivas Girigowdaea32d6a2017-03-25 00:03:12 -0700128};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800129
130/**
131 * struct hdd_wmm_ac_status - WMM related per-AC state & status info
132 * @wmmAcAccessRequired - does the AP require access to this AC?
133 * @wmmAcAccessNeeded - does the worker thread need to acquire access to
134 * this AC?
135 * @wmmAcAccessPending - is implicit QoS negotiation currently taking place?
136 * @wmmAcAccessFailed - has implicit QoS negotiation already failed?
137 * @wmmAcAccessGranted - has implicit QoS negotiation already succeeded?
138 * @wmmAcAccessAllowed - is access to this AC allowed, either because we
139 * are not doing WMM, we are not doing implicit QoS, implict QoS has
140 * completed, or explicit QoS has completed?
141 * @wmmAcTspecValid - is the wmmAcTspecInfo valid?
142 * @wmmAcUapsdInfoValid - are the wmmAcUapsd* fields valid?
143 * @wmmAcTspecInfo - current (possibly aggregate) Tspec for this AC
144 * @wmmAcIsUapsdEnabled - is UAPSD enabled on this AC?
145 * @wmmAcUapsdServiceInterval - service interval for this AC
146 * @wmmAcUapsdSuspensionInterval - suspension interval for this AC
147 * @wmmAcUapsdDirection - direction for this AC
148 * @wmmInactivityTime - inactivity time for this AC
149 * @wmmPrevTrafficCnt - TX counter used for inactivity detection
150 * @wmmInactivityTimer - timer used for inactivity detection
151 */
Srinivas Girigowdaea32d6a2017-03-25 00:03:12 -0700152struct hdd_wmm_ac_status {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800153 bool wmmAcAccessRequired;
154 bool wmmAcAccessNeeded;
155 bool wmmAcAccessPending;
156 bool wmmAcAccessFailed;
157 bool wmmAcAccessGranted;
158 bool wmmAcAccessAllowed;
159 bool wmmAcTspecValid;
160 bool wmmAcUapsdInfoValid;
161 sme_QosWmmTspecInfo wmmAcTspecInfo;
162 bool wmmAcIsUapsdEnabled;
163 uint32_t wmmAcUapsdServiceInterval;
164 uint32_t wmmAcUapsdSuspensionInterval;
165 sme_QosWmmDirType wmmAcUapsdDirection;
166
167#ifdef FEATURE_WLAN_ESE
168 uint32_t wmmInactivityTime;
169 uint32_t wmmPrevTrafficCnt;
Anurag Chouhan210db072016-02-22 18:42:15 +0530170 qdf_mc_timer_t wmmInactivityTimer;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800171#endif
Srinivas Girigowdaea32d6a2017-03-25 00:03:12 -0700172};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800173
174/**
175 * struct hdd_wmm_status - WMM status maintained per-adapter
176 * @wmmContextList - list of WMM contexts active on the adapter
177 * @wmmLock - mutex used for exclusive access to this adapter's WMM status
178 * @wmmACStatus - per-AC WMM status
179 * @wmmQap - is this connected to a QoS-enabled AP?
180 * @wmmQosConnection - is this a QoS connection?
181 */
Srinivas Girigowdaea32d6a2017-03-25 00:03:12 -0700182struct hdd_wmm_status {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800183 struct list_head wmmContextList;
184 struct mutex wmmLock;
Srinivas Girigowdaea32d6a2017-03-25 00:03:12 -0700185 struct hdd_wmm_ac_status wmmAcStatus[WLAN_MAX_AC];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800186 bool wmmQap;
187 bool wmmQosConnection;
Srinivas Girigowdaea32d6a2017-03-25 00:03:12 -0700188};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800189
190extern const uint8_t hdd_qdisc_ac_to_tl_ac[];
191extern const uint8_t hdd_wmm_up_to_ac_map[];
192extern const uint8_t hdd_linux_up_to_ac_map[];
193
194#define WLAN_HDD_MAX_DSCP 0x3f
195
196/**
197 * hdd_wmmps_helper() - Function to set uapsd psb dynamically
198 *
199 * @pAdapter: [in] pointer to adapter structure
200 * @ptr: [in] pointer to command buffer
201 *
202 * Return: Zero on success, appropriate error on failure.
203 */
204int hdd_wmmps_helper(hdd_adapter_t *pAdapter, uint8_t *ptr);
205
206/**
207 * hdd_wmm_init() - initialize the WMM DSCP configuation
208 * @pAdapter : [in] pointer to Adapter context
209 *
210 * This function will initialize the WMM DSCP configuation of an
211 * adapter to an initial state. The configuration can later be
212 * overwritten via application APIs or via QoS Map sent OTA.
213 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530214 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800215 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530216QDF_STATUS hdd_wmm_init(hdd_adapter_t *pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800217
218/**
219 * hdd_wmm_adapter_init() - initialize the WMM configuration of an adapter
220 * @pAdapter: [in] pointer to Adapter context
221 *
222 * This function will initialize the WMM configuation and status of an
223 * adapter to an initial state. The configuration can later be
224 * overwritten via application APIs
225 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530226 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800227 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530228QDF_STATUS hdd_wmm_adapter_init(hdd_adapter_t *pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800229
230/**
231 * hdd_wmm_close() - WMM close function
232 * @pAdapter: [in] pointer to adapter context
233 *
234 * Function which will perform any necessary work to to clean up the
235 * WMM functionality prior to the kernel module unload.
236 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530237 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800238 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530239QDF_STATUS hdd_wmm_adapter_close(hdd_adapter_t *pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800240
241/**
242 * hdd_wmm_select_queue() - Function which will classify the packet
243 * according to linux qdisc expectation.
244 *
245 * @dev: [in] pointer to net_device structure
246 * @skb: [in] pointer to os packet
247 *
248 * Return: Qdisc queue index
249 */
250uint16_t hdd_wmm_select_queue(struct net_device *dev, struct sk_buff *skb);
251
252/**
253 * hdd_hostapd_select_queue() - Function which will classify the packet
254 * according to linux qdisc expectation.
255 *
256 * @dev: [in] pointer to net_device structure
257 * @skb: [in] pointer to os packet
258 *
259 * Return: Qdisc queue index
260 */
261uint16_t hdd_hostapd_select_queue(struct net_device *dev, struct sk_buff *skb
262#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0))
263 , void *accel_priv
264#endif
265#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0))
266 , select_queue_fallback_t fallback
267#endif
268);
269
270/**
271 * hdd_wmm_acquire_access_required() - Function which will determine
272 * acquire admittance for a WMM AC is required or not based on psb configuration
273 * done in framework
274 *
275 * @pAdapter: [in] pointer to adapter structure
276 * @acType: [in] WMM AC type of OS packet
277 *
278 * Return: void
279 */
280void hdd_wmm_acquire_access_required(hdd_adapter_t *pAdapter,
281 sme_ac_enum_type acType);
282
283/**
284 * hdd_wmm_acquire_access() - Function which will attempt to acquire
285 * admittance for a WMM AC
286 *
287 * @pAdapter: [in] pointer to adapter context
288 * @acType: [in] WMM AC type of OS packet
289 * @pGranted: [out] pointer to bool flag when indicates if access
290 * has been granted or not
291 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530292 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800293 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530294QDF_STATUS hdd_wmm_acquire_access(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800295 sme_ac_enum_type acType, bool *pGranted);
296
297/**
298 * hdd_wmm_assoc() - Function which will handle the housekeeping
299 * required by WMM when association takes place
300 *
301 * @pAdapter: [in] pointer to adapter context
302 * @pRoamInfo: [in] pointer to roam information
303 * @eBssType: [in] type of BSS
304 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530305 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800306 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530307QDF_STATUS hdd_wmm_assoc(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800308 tCsrRoamInfo *pRoamInfo, eCsrRoamBssType eBssType);
309
310/**
311 * hdd_wmm_connect() - Function which will handle the housekeeping
312 * required by WMM when a connection is established
313 *
314 * @pAdapter : [in] pointer to adapter context
315 * @pRoamInfo: [in] pointer to roam information
316 * @eBssType : [in] type of BSS
317 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530318 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800319 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530320QDF_STATUS hdd_wmm_connect(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800321 tCsrRoamInfo *pRoamInfo, eCsrRoamBssType eBssType);
322
323/**
324 * hdd_wmm_get_uapsd_mask() - Function which will calculate the
325 * initial value of the UAPSD mask based upon the device configuration
326 *
327 * @pAdapter : [in] pointer to adapter context
328 * @pUapsdMask: [out] pointer to where the UAPSD Mask is to be stored
329 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530330 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800331 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530332QDF_STATUS hdd_wmm_get_uapsd_mask(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800333 uint8_t *pUapsdMask);
334
335/**
336 * hdd_wmm_is_active() - Function which will determine if WMM is
337 * active on the current connection
338 *
339 * @pAdapter: [in] pointer to adapter context
340 *
341 * Return: true if WMM is enabled, false if WMM is not enabled
342 */
343bool hdd_wmm_is_active(hdd_adapter_t *pAdapter);
344
345/**
346 * hdd_wmm_addts() - Function which will add a traffic spec at the
347 * request of an application
348 *
349 * @pAdapter : [in] pointer to adapter context
350 * @handle : [in] handle to uniquely identify a TS
351 * @pTspec : [in] pointer to the traffic spec
352 *
353 * Return: HDD_WLAN_WMM_STATUS_*
354 */
355hdd_wlan_wmm_status_e hdd_wmm_addts(hdd_adapter_t *pAdapter,
356 uint32_t handle,
357 sme_QosWmmTspecInfo *pTspec);
358
359/**
360 * hdd_wmm_delts() - Function which will delete a traffic spec at the
361 * request of an application
362 *
363 * @pAdapter: [in] pointer to adapter context
364 * @handle: [in] handle to uniquely identify a TS
365 *
366 * Return: HDD_WLAN_WMM_STATUS_*
367 */
368hdd_wlan_wmm_status_e hdd_wmm_delts(hdd_adapter_t *pAdapter, uint32_t handle);
369
370/**
371 * hdd_wmm_checkts() - Function which will return the status of a traffic
372 * spec at the request of an application
373 *
374 * @pAdapter: [in] pointer to adapter context
375 * @handle: [in] handle to uniquely identify a TS
376 *
377 * Return: HDD_WLAN_WMM_STATUS_*
378 */
379hdd_wlan_wmm_status_e hdd_wmm_checkts(hdd_adapter_t *pAdapter,
380 uint32_t handle);
381/**
382 * hdd_wmm_adapter_clear() - Function which will clear the WMM status
383 * for all the ACs
384 *
385 * @pAdapter: [in] pointer to Adapter context
386 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530387 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800388 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530389QDF_STATUS hdd_wmm_adapter_clear(hdd_adapter_t *pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800390
391void wlan_hdd_process_peer_unauthorised_pause(hdd_adapter_t *adapter);
392#endif /* #ifndef _WLAN_HDD_WMM_H */