xref: /wlan-dirver/qca-wifi-host-cmn/umac/green_ap/core/src/wlan_green_ap_main_i.h (revision a175314c51a4ce5cec2835cc8a8c7dc0c1810915)
1 /*
2  * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 
20 /**
21  * DOC: This file has main green ap structures.
22  */
23 
24 #ifndef _WLAN_GREEN_AP_MAIN_I_H_
25 #define _WLAN_GREEN_AP_MAIN_I_H_
26 
27 #include <wlan_objmgr_cmn.h>
28 #include <wlan_objmgr_pdev_obj.h>
29 #include <wlan_green_ap_api.h>
30 #include <qdf_types.h>
31 #include <qdf_status.h>
32 #include <qdf_timer.h>
33 #include "wlan_utility.h"
34 #include <qdf_module.h>
35 
36 #define WLAN_GREEN_AP_PS_ON_TIME        (0)
37 #define WLAN_GREEN_AP_PS_TRANS_TIME     (20)
38 
39 #define green_ap_alert(params...) \
40 	QDF_TRACE_FATAL(QDF_MODULE_ID_GREEN_AP, params)
41 #define green_ap_err(params...) \
42 	QDF_TRACE_ERROR(QDF_MODULE_ID_GREEN_AP, params)
43 #define green_ap_warn(params...) \
44 	QDF_TRACE_WARN(QDF_MODULE_ID_GREEN_AP, params)
45 #define green_ap_notice(params...) \
46 	QDF_TRACE_INFO(QDF_MODULE_ID_GREEN_AP, params)
47 #define green_ap_info(params...) \
48 	QDF_TRACE_INFO(QDF_MODULE_ID_GREEN_AP, params)
49 #define green_ap_debug(params...) \
50 	QDF_TRACE_DEBUG(QDF_MODULE_ID_GREEN_AP, params)
51 
52 #define WLAN_GREEN_AP_PS_DISABLE 0
53 #define WLAN_GREEN_AP_PS_ENABLE 1
54 #define WLAN_GREEN_AP_PS_SUSPEND 2
55 /**
56  * enum wlan_green_ap_ps_state - PS states
57  * @WLAN_GREEN_AP_PS_IDLE_STATE - Idle
58  * @WLAN_GREEN_AP_PS_OFF_STATE  - Off
59  * @WLAN_GREEN_AP_PS_WAIT_STATE - Wait
60  * @WLAN_GREEN_AP_PS_ON_STATE   - On
61  */
62 enum wlan_green_ap_ps_state {
63 	WLAN_GREEN_AP_PS_IDLE_STATE = 1,
64 	WLAN_GREEN_AP_PS_OFF_STATE,
65 	WLAN_GREEN_AP_PS_WAIT_STATE,
66 	WLAN_GREEN_AP_PS_ON_STATE,
67 };
68 
69 /**
70  * enum wlan_green_ap_ps_event   - PS event
71  * @WLAN_GREEN_AP_PS_START_EVENT - Start
72  * @WLAN_GREEN_AP_PS_STOP_EVENT  - Stop
73  * @WLAN_GREEN_AP_ADD_STA_EVENT  - Sta assoc
74  * @WLAN_GREEN_AP_DEL_STA_EVENT  - Sta disassoc
75  * @WLAN_GREEN_AP_PS_ON_EVENT    - PS on
76  * @WLAN_GREEN_AP_PS_OFF_EVENT   - PS off
77  */
78 enum wlan_green_ap_ps_event {
79 	WLAN_GREEN_AP_PS_START_EVENT = 1,
80 	WLAN_GREEN_AP_PS_STOP_EVENT,
81 	WLAN_GREEN_AP_ADD_STA_EVENT,
82 	WLAN_GREEN_AP_DEL_STA_EVENT,
83 	WLAN_GREEN_AP_PS_ON_EVENT,
84 	WLAN_GREEN_AP_PS_WAIT_EVENT,
85 };
86 
87 /**
88  * struct wlan_pdev_green_ap_ctx - green ap context
89  * @pdev - Pdev pointer
90  * @ps_enable  - Enable PS
91  * @ps_on_time - PS on time, once enabled
92  * @ps_trans_time - PS transition time
93  * @num_nodes - Number of nodes associated to radio
94  * @ps_state - PS state
95  * @ps_event - PS event
96  * @ps_timer - Timer
97  * @lock: green ap spinlock
98  * @egap_params - Enhanced green ap params
99  */
100 struct wlan_pdev_green_ap_ctx {
101 	struct wlan_objmgr_pdev *pdev;
102 	uint8_t ps_enable;
103 	uint8_t ps_on_time;
104 	uint32_t ps_trans_time;
105 	uint32_t num_nodes;
106 	enum wlan_green_ap_ps_state ps_state;
107 	enum wlan_green_ap_ps_event ps_event;
108 	qdf_timer_t ps_timer;
109 	qdf_spinlock_t lock;
110 	struct wlan_green_ap_egap_params egap_params;
111 	bool dbg_enable;
112 };
113 
114 /**
115  * wlan_psoc_get_green_ap_tx_ops() - Obtain green ap tx ops from green ap ctx
116  * @green_ap_ctx: green ap context
117  *
118  * @Return: green ap tx ops pointer
119  */
120 struct wlan_lmac_if_green_ap_tx_ops *
121 wlan_psoc_get_green_ap_tx_ops(struct wlan_pdev_green_ap_ctx *green_ap_ctx);
122 
123 /**
124  * wlan_is_egap_enabled() - Get Enhance Green AP feature status
125  * @green_ap_ctx: green ap context
126  *
127  * Return: true if firmware, feature_flag and ini are all egap enabled
128  */
129 bool wlan_is_egap_enabled(struct wlan_pdev_green_ap_ctx *green_ap_ctx);
130 
131 /**
132  * wlan_green_ap_state_mc() - Green ap state machine
133  * @green_ap_ctx: green ap context
134  * @event: ps event
135  *
136  * @Return: Success or Failure
137  */
138 QDF_STATUS wlan_green_ap_state_mc(struct wlan_pdev_green_ap_ctx *green_ap_ctx,
139 				  enum wlan_green_ap_ps_event event);
140 
141 /**
142  * wlan_green_ap_timer_fn() - Green ap timer callback
143  * @pdev: pdev pointer
144  *
145  * @Return: None
146  */
147 void wlan_green_ap_timer_fn(void *pdev);
148 
149 /**
150  * wlan_green_ap_check_mode() - Check for mode
151  * @pdev: pdev pointer
152  * @object:  vdev object
153  * @arg: flag to be set
154  *
155  * Callback to check if all modes on radio are configured as AP
156  *
157  * @Return: None
158  */
159 void wlan_green_ap_check_mode(struct wlan_objmgr_pdev *pdev,
160 		void *object,
161 		void *arg);
162 #endif  /* _WLAN_GREEN_AP_MAIN_I_H_ */
163