blob: 081a6a233dbbb37dfa0b6bf4424c1e779d41c137 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Dustin Brown0cbc7572016-12-16 13:54:40 -08002 * Copyright (c) 2012, 2014-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_POWER_H
29#define __WLAN_HDD_POWER_H
30
31/**
32 * DOC: wlan_hdd_power.h
33 *
34 * HDD Power Management API
35 */
36
37#include "wlan_hdd_main.h"
38
39#ifdef WLAN_FEATURE_PACKET_FILTERING
40
Dustin Brown0cbc7572016-12-16 13:54:40 -080041#define HDD_MAX_CMP_PER_PACKET_FILTER 5
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080042
43/**
44 * enum pkt_filter_protocol_layer - packet filter protocol layer
45 * @HDD_FILTER_PROTO_TYPE_INVALID: Invalid initial value
46 * @HDD_FILTER_PROTO_TYPE_MAC: MAC protocol
47 * @HDD_FILTER_PROTO_TYPE_ARP: ARP protocol
48 * @HDD_FILTER_PROTO_TYPE_IPV4: IP V4 protocol
49 * @HDD_FILTER_PROTO_TYPE_IPV6: IP V6 protocol
50 * @HDD_FILTER_PROTO_TYPE_UDP: UDP protocol
51 * @HDD_FILTER_PROTO_TYPE_INVALID: Max place holder value
52 */
53enum pkt_filter_protocol_layer {
54 HDD_FILTER_PROTO_TYPE_INVALID = 0,
55 HDD_FILTER_PROTO_TYPE_MAC = 1,
56 HDD_FILTER_PROTO_TYPE_ARP = 2,
57 HDD_FILTER_PROTO_TYPE_IPV4 = 3,
58 HDD_FILTER_PROTO_TYPE_IPV6 = 4,
59 HDD_FILTER_PROTO_TYPE_UDP = 5,
60 HDD_FILTER_PROTO_TYPE_MAX
61};
62
63/**
64 * enum pkt_filter_action - packet filter action
65 * @HDD_RCV_FILTER_INVALID: Invalid initial value
66 * @HDD_RCV_FILTER_SET: Packet filter set
67 * @HDD_RCV_FILTER_CLEAR: Packet filter clear
68 * @HDD_RCV_FILTER_MAX: Max place holder value
69 */
70enum pkt_filter_action {
71 HDD_RCV_FILTER_INVALID = 0,
72 HDD_RCV_FILTER_SET = 1,
73 HDD_RCV_FILTER_CLEAR = 2,
74 HDD_RCV_FILTER_MAX
75};
76
77/**
78 * enum pkt_filter_compare_flag - packet filter compare flag
79 * @HDD_FILTER_CMP_TYPE_INVALID: Invalid initial value
80 * @HDD_FILTER_CMP_TYPE_EQUAL: Compare if filter is equal
81 * @HDD_FILTER_CMP_TYPE_MASK_EQUAL: Compare if filter mask is equal
82 * @HDD_FILTER_CMP_TYPE_NOT_EQUAL: Compare if filter is not equal
83 * @HDD_FILTER_CMP_TYPE_MASK_NOT_EQUAL: Compare if filter mask is not equal
84 * @HDD_FILTER_CMP_TYPE_MAX: Max place holder value
85 */
86enum pkt_filter_compare_flag {
87 HDD_FILTER_CMP_TYPE_INVALID = 0,
88 HDD_FILTER_CMP_TYPE_EQUAL = 1,
89 HDD_FILTER_CMP_TYPE_MASK_EQUAL = 2,
90 HDD_FILTER_CMP_TYPE_NOT_EQUAL = 3,
91 HDD_FILTER_CMP_TYPE_MASK_NOT_EQUAL = 4,
92 HDD_FILTER_CMP_TYPE_MAX
93};
94
95/**
96 * struct pkt_filter_param_cfg - packet filter parameter config
97 * @protocol_layer: Protocol layer
98 * @compare_flag: Compare flag
99 * @data_fffset: Data offset
100 * @data_length: Data length
101 * @compare_data: Compare data
102 * @data_mask: Data mask
103 */
104struct pkt_filter_param_cfg {
105 uint8_t protocol_layer;
106 uint8_t compare_flag;
107 uint8_t data_offset;
108 uint8_t data_length;
109 uint8_t compare_data[SIR_MAX_FILTER_TEST_DATA_LEN];
110 uint8_t data_mask[SIR_MAX_FILTER_TEST_DATA_LEN];
111};
112
113/**
114 * struct pkt_filter_cfg - packet filter config received from user space
115 * @filter_action: Filter action
116 * @filter_id: Filter id
117 * @num_params: Number of parameters
118 * @params_data: Packet filter parameters detail
119 */
120struct pkt_filter_cfg {
121 uint8_t filter_action;
122 uint8_t filter_id;
123 uint8_t num_params;
124 struct pkt_filter_param_cfg params_data[HDD_MAX_CMP_PER_PACKET_FILTER];
125};
126
127#endif
128
Abhishek Singhbaea27d2016-04-27 13:29:30 +0530129/**
130 * enum suspend_resume_state - Suspend resume state
131 * @HDD_WLAN_EARLY_SUSPEND: Early suspend state.
132 * @HDD_WLAN_SUSPEND: Suspend state.
133 * @HDD_WLAN_EARLY_RESUME: Early resume state.
134 * @HDD_WLAN_RESUME: Resume state.
135 *
136 * Suspend state to indicate in diag event of suspend resume.
137 */
138enum suspend_resume_state {
139 HDD_WLAN_EARLY_SUSPEND,
140 HDD_WLAN_SUSPEND,
141 HDD_WLAN_EARLY_RESUME,
142 HDD_WLAN_RESUME
143};
144
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800145
146/* SSR shutdown & re-init functions */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530147QDF_STATUS hdd_wlan_shutdown(void);
Arun Khandavallifae92942016-08-01 13:31:08 +0530148QDF_STATUS hdd_wlan_re_init(void);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800149
Mukul Sharma3ba26b82017-01-12 21:59:41 +0530150/**
Ravi Kumar Bokka794fd712017-03-21 20:52:46 +0530151 * hdd_enable_non_arp_hw_broadcast_filter() - API to enable broadcast filter
152 * @adapter: Adapter context for which ARP offload is to be configured
153 *
154 * Return: None
155 */
156void hdd_enable_non_arp_hw_broadcast_filter(hdd_adapter_t *adapter);
157
158/**
159 * hdd_disable_non_arp_hw_broadcast_filter() - API to disable broadcast filter
160 * @adapter: Adapter context for which ARP offload is to be configured
161 *
162 * Return: None
163 */
164void hdd_disable_non_arp_hw_broadcast_filter(hdd_adapter_t *adapter);
165
166/**
Mukul Sharma3ba26b82017-01-12 21:59:41 +0530167 * hdd_enable_arp_offload() - API to enable ARP offload
168 * @adapter: Adapter context for which ARP offload is to be configured
169 * @trigger: trigger reason for request
170 *
171 * Return: None
172 */
173void hdd_enable_arp_offload(hdd_adapter_t *adapter,
174 enum pmo_offload_trigger trigger);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800175
Mukul Sharma3ba26b82017-01-12 21:59:41 +0530176/**
177 * hdd_disable_arp_offload() - API to disable ARP offload
178 * @adapter: Adapter context for which ARP offload is to be configured
179 * @trigger: trigger reason for request
180 *
181 * Return: None
182 */
183void hdd_disable_arp_offload(hdd_adapter_t *adapter,
184 enum pmo_offload_trigger trigger);
185
186/**
187 * hdd_enable_host_offloads() - Central API to enable the supported offloads
188 * @adapter: pointer to the adapter
189 * @trigger: trigger reason for request
190 *
191 * Central function to enable the supported offloads
192 *
193 * Return: nothing
194 */
195void hdd_enable_host_offloads(hdd_adapter_t *adapter,
196 enum pmo_offload_trigger trigger);
197
198/**
199 * hdd_disable_host_offloads() - Central API to disable the supported offloads
200 * @adapter: pointer to the adapter
201 * @trigger: trigger reason for request
202 *
203 * Central function to disable the supported offloads
204 *
205 * Return: nothing
206 */
207void hdd_disable_host_offloads(hdd_adapter_t *adapter,
208 enum pmo_offload_trigger trigger);
209
210/**
Mukul Sharmaff2ac2e2017-01-16 15:51:29 +0530211 * hdd_enable_mc_addr_filtering() - enable MC address list in FW
212 * @adapter: adapter whose MC list is being set
Mukul Sharma3ba26b82017-01-12 21:59:41 +0530213 * @trigger: trigger reason for request
214 *
215 * Return: nothing
216 */
Mukul Sharmaff2ac2e2017-01-16 15:51:29 +0530217void hdd_enable_mc_addr_filtering(hdd_adapter_t *adapter,
218 enum pmo_offload_trigger trigger);
219
220/**
221 * hdd_disable_mc_addr_filtering() - disable MC address list in FW
222 * @adapter: adapter whose MC list is being set
223 * @trigger: trigger reason for request
224 *
225 * Return: nothing
226 */
227void hdd_disable_mc_addr_filtering(hdd_adapter_t *adapter,
228 enum pmo_offload_trigger trigger);
229
230/**
231 * hdd_cache_mc_addr_list() - API to cache MC address list
232 * @mc_list_config: set of mc address list configurations
233 *
234 * Return: 0 on success else error code
235 */
236int hdd_cache_mc_addr_list(struct pmo_mc_addr_list_params *mc_list_config);
237
238/**
239 * hdd_disable_and_flush_mc_addr_list() - API to Disable & Flush cached MC list
240 * @adapter: adapter whose MC list is being set
241 * @trigger: trigger reason for request
242 *
243 * Return: nothing
244 */
245void hdd_disable_and_flush_mc_addr_list(hdd_adapter_t *adapter,
246 enum pmo_offload_trigger trigger);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800247
Mukul Sharma3d36c392017-01-18 18:39:12 +0530248/**
249 * wlan_hdd_cfg80211_update_replay_counter_callback() - replay counter callback
250 * @cb_ctx: Callback context as void* as PMO do not about HDD adapter type
251 * @gtk_rsp_param: Pointer to gtk offload response parameter
252 *
253 * Callback routine called upon receiving of gtk offload rsp from fwr
254 *
255 * Return: none
256 */
257void wlan_hdd_cfg80211_update_replay_counter_callback(
258 void *cb_ctx,
259 struct pmo_gtk_rsp_params *gtk_rsp_param);
260
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800261int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
262 struct cfg80211_wowlan *wow);
263
264int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy);
265
266void hdd_ipv4_notifier_work_queue(struct work_struct *work);
Mukul Sharma3ba26b82017-01-12 21:59:41 +0530267
268
269/**
270 * hdd_enable_ns_offload() - enable NS offload
271 * @adapter: pointer to the adapter
272 *
273 * Return: nothing
274 */
275void hdd_enable_ns_offload(hdd_adapter_t *adapter,
276 enum pmo_offload_trigger trigger);
277
278/**
279 * hdd_disable_ns_offload() - disable NS offload
280 * @adapter: pointer to the adapter
281 *
282 * Return: nothing
283 */
284void hdd_disable_ns_offload(hdd_adapter_t *adapter,
285 enum pmo_offload_trigger trigger);
286
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800287void hdd_ipv6_notifier_work_queue(struct work_struct *work);
Mukul Sharma3ba26b82017-01-12 21:59:41 +0530288
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800289
290int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800291 struct wireless_dev *wdev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800292 int *dbm);
293int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800294 struct wireless_dev *wdev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800295 enum nl80211_tx_power_setting type,
296 int dbm);
297int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Dustin Brownf660fb42016-09-09 12:04:00 -0700298 struct net_device *dev,
299 bool allow_power_save,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800300 int timeout);
301
302int wlan_hdd_ipv4_changed(struct notifier_block *nb,
303 unsigned long data, void *arg);
304
305int wlan_hdd_ipv6_changed(struct notifier_block *nb,
306 unsigned long data, void *arg);
307
Kapil Gupta6213c012016-09-02 19:39:09 +0530308int hdd_set_qpower_config(hdd_context_t *hddctx, hdd_adapter_t *adapter,
309 uint8_t qpower);
310
Abhishek Singhbaea27d2016-04-27 13:29:30 +0530311#ifdef FEATURE_WLAN_DIAG_SUPPORT
312void hdd_wlan_suspend_resume_event(uint8_t state);
313#else
314static inline
315void hdd_wlan_suspend_resume_event(uint8_t state) {}
316#endif /* FEATURE_WLAN_DIAG_SUPPORT */
317
Dustin Brown105d7902016-10-03 16:27:59 -0700318/**
319 * wlan_hdd_inc_suspend_stats() - Prints, then increments, then prints suspend
320 * failed statistics.
321 * @hdd_ctx: The HDD context to operate on
322 * @reason: The suspend failed reason to increment
323 *
324 * This function prints all of the suspend failed statistics, increments the
325 * specified suspend fail reason statistic, and prints the them all again. This
326 * is for easily keeping track of the most common reasons suspend fails.
327 *
328 * Return: none
329 */
330void wlan_hdd_inc_suspend_stats(hdd_context_t *hdd_ctx,
331 enum suspend_fail_reason reason);
Abhishek Singhbaea27d2016-04-27 13:29:30 +0530332
Rajeev Kumar9bb2e852016-09-24 12:29:25 -0700333/*
334 * Unit-test suspend/resume is a testing feature that allows putting firmware
335 * into WoW suspend irrespective of Apps suspend status. It emulates the chain
336 * of events that occur durring normal system-level suspend/resume, such as
337 * initiating all of the suspend/resume stages in the correct order, and
338 * enabling/disabling appropriate copy engine irqs.
339 */
340#ifdef WLAN_SUSPEND_RESUME_TEST
Dustin Brownd53d1a82016-10-03 12:57:33 -0700341/**
Dustin Browne70fd972016-11-10 11:17:40 -0800342 * wlan_hdd_unit_test_bus_suspend() - suspend the wlan bus
Dustin Brown54096432017-02-23 13:00:44 -0800343 * @wow_params: collection of wow enable override parameters
Dustin Browne70fd972016-11-10 11:17:40 -0800344 *
345 * This function does the same as wlan_hdd_bus_suspend, but additionally passes
346 * the appropriate flags to FW, indicating this is a unit-test suspend and it
347 * should use an HTC wakeup method to resume.
348 *
349 * Return: 0 for success or error code
350 */
Dustin Brown9ef609b2017-03-15 12:19:37 -0700351int wlan_hdd_unit_test_bus_suspend(struct wow_enable_params wow_params);
Dustin Browne70fd972016-11-10 11:17:40 -0800352
353/**
Dustin Brownd53d1a82016-10-03 12:57:33 -0700354 * hdd_wlan_fake_apps_resume() - Resume from unit-test triggered suspend
Dustin Brownbc81a472016-10-26 16:56:59 -0700355 * @wiphy: the kernel wiphy struct for the device being resumed
356 * @dev: the kernel net_device struct for the device being resumed
Dustin Brownd53d1a82016-10-03 12:57:33 -0700357 *
358 * Return: Zero on success, calls QDF_BUG() on failure
359 */
Dustin Brownbc81a472016-10-26 16:56:59 -0700360int hdd_wlan_fake_apps_resume(struct wiphy *wiphy, struct net_device *dev);
Dustin Brownd53d1a82016-10-03 12:57:33 -0700361
362/**
363 * hdd_wlan_fake_apps_suspend() - Initiate a unit-test triggered suspend
Dustin Brownbc81a472016-10-26 16:56:59 -0700364 * @wiphy: the kernel wiphy struct for the device being suspended
365 * @dev: the kernel net_device struct for the device being suspended
Dustin Brown54096432017-02-23 13:00:44 -0800366 * @pause_setting: interface pause override setting
367 * @resume_setting: resume trigger override setting
Dustin Brownd53d1a82016-10-03 12:57:33 -0700368 *
369 * Return: Zero on success, suspend related non-zero error code on failure
370 */
Dustin Brown54096432017-02-23 13:00:44 -0800371int hdd_wlan_fake_apps_suspend(struct wiphy *wiphy, struct net_device *dev,
372 enum wow_interface_pause pause_setting,
373 enum wow_resume_trigger resume_setting);
Rajeev Kumar9bb2e852016-09-24 12:29:25 -0700374#else
Dustin Brownbc81a472016-10-26 16:56:59 -0700375static inline int
376hdd_wlan_fake_apps_resume(struct wiphy *wiphy, struct net_device *dev)
Rajeev Kumar9bb2e852016-09-24 12:29:25 -0700377{
378 return 0;
379}
380
Dustin Brownbc81a472016-10-26 16:56:59 -0700381static inline int
Dustin Brown54096432017-02-23 13:00:44 -0800382hdd_wlan_fake_apps_suspend(struct wiphy *wiphy, struct net_device *dev,
383 enum wow_interface_pause pause_setting,
384 enum wow_resume_trigger resume_setting)
Rajeev Kumar9bb2e852016-09-24 12:29:25 -0700385{
386 return 0;
387}
388#endif /* WLAN_SUSPEND_RESUME_TEST */
389
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800390#endif /* __WLAN_HDD_POWER_H */