xref: /wlan-dirver/qca-wifi-host-cmn/umac/green_ap/core/src/wlan_green_ap_main_i.h (revision 3149adf58a329e17232a4c0e58d460d025edd55a)
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_log(level, args...) \
40 			QDF_TRACE(QDF_MODULE_ID_GREEN_AP, level, ## args)
41 #define green_ap_logfl(level, format, args...) \
42 			green_ap_log(level, FL(format), ## args)
43 
44 #define green_ap_alert(format, args...) \
45 		green_ap_logfl(QDF_TRACE_LEVEL_FATAL, format, ## args)
46 #define green_ap_err(format, args...) \
47 		green_ap_logfl(QDF_TRACE_LEVEL_ERROR, format, ## args)
48 #define green_apwarn(format, args...) \
49 		green_ap_logfl(QDF_TRACE_LEVEL_WARN, format, ## args)
50 #define green_ap_notice(format, args...) \
51 		green_ap_logfl(QDF_TRACE_LEVEL_INFO, format, ## args)
52 #define green_ap_info(format, args...) \
53 		green_ap_logfl(QDF_TRACE_LEVEL_INFO_HIGH, format, ## args)
54 #define green_ap_debug(format, args...) \
55 		green_ap_logfl(QDF_TRACE_LEVEL_DEBUG, format, ## args)
56 
57 #define WLAN_GREEN_AP_PS_DISABLE 0
58 #define WLAN_GREEN_AP_PS_ENABLE 1
59 #define WLAN_GREEN_AP_PS_SUSPEND 2
60 /**
61  * enum wlan_green_ap_ps_state - PS states
62  * @WLAN_GREEN_AP_PS_IDLE_STATE - Idle
63  * @WLAN_GREEN_AP_PS_OFF_STATE  - Off
64  * @WLAN_GREEN_AP_PS_WAIT_STATE - Wait
65  * @WLAN_GREEN_AP_PS_ON_STATE   - On
66  */
67 enum wlan_green_ap_ps_state {
68 	WLAN_GREEN_AP_PS_IDLE_STATE = 1,
69 	WLAN_GREEN_AP_PS_OFF_STATE,
70 	WLAN_GREEN_AP_PS_WAIT_STATE,
71 	WLAN_GREEN_AP_PS_ON_STATE,
72 };
73 
74 /**
75  * enum wlan_green_ap_ps_event   - PS event
76  * @WLAN_GREEN_AP_PS_START_EVENT - Start
77  * @WLAN_GREEN_AP_PS_STOP_EVENT  - Stop
78  * @WLAN_GREEN_AP_ADD_STA_EVENT  - Sta assoc
79  * @WLAN_GREEN_AP_DEL_STA_EVENT  - Sta disassoc
80  * @WLAN_GREEN_AP_PS_ON_EVENT    - PS on
81  * @WLAN_GREEN_AP_PS_OFF_EVENT   - PS off
82  */
83 enum wlan_green_ap_ps_event {
84 	WLAN_GREEN_AP_PS_START_EVENT = 1,
85 	WLAN_GREEN_AP_PS_STOP_EVENT,
86 	WLAN_GREEN_AP_ADD_STA_EVENT,
87 	WLAN_GREEN_AP_DEL_STA_EVENT,
88 	WLAN_GREEN_AP_PS_ON_EVENT,
89 	WLAN_GREEN_AP_PS_WAIT_EVENT,
90 };
91 
92 /**
93  * struct wlan_pdev_green_ap_ctx - green ap context
94  * @pdev - Pdev pointer
95  * @ps_enable  - Enable PS
96  * @ps_on_time - PS on time, once enabled
97  * @ps_trans_time - PS transition time
98  * @num_nodes - Number of nodes associated to radio
99  * @ps_state - PS state
100  * @ps_event - PS event
101  * @ps_timer - Timer
102  * @lock: green ap spinlock
103  * @egap_params - Enhanced green ap params
104  */
105 struct wlan_pdev_green_ap_ctx {
106 	struct wlan_objmgr_pdev *pdev;
107 	uint8_t ps_enable;
108 	uint8_t ps_on_time;
109 	uint32_t ps_trans_time;
110 	uint32_t num_nodes;
111 	enum wlan_green_ap_ps_state ps_state;
112 	enum wlan_green_ap_ps_event ps_event;
113 	qdf_timer_t ps_timer;
114 	qdf_spinlock_t lock;
115 	struct wlan_green_ap_egap_params egap_params;
116 	bool dbg_enable;
117 };
118 
119 /**
120  * wlan_psoc_get_green_ap_tx_ops() - Obtain green ap tx ops from green ap ctx
121  * @green_ap_ctx: green ap context
122  *
123  * @Return: green ap tx ops pointer
124  */
125 struct wlan_lmac_if_green_ap_tx_ops *
126 wlan_psoc_get_green_ap_tx_ops(struct wlan_pdev_green_ap_ctx *green_ap_ctx);
127 
128 /**
129  * wlan_is_egap_enabled() - Get Enhance Green AP feature status
130  * @green_ap_ctx: green ap context
131  *
132  * Return: true if firmware, feature_flag and ini are all egap enabled
133  */
134 bool wlan_is_egap_enabled(struct wlan_pdev_green_ap_ctx *green_ap_ctx);
135 
136 /**
137  * wlan_green_ap_state_mc() - Green ap state machine
138  * @green_ap_ctx: green ap context
139  * @event: ps event
140  *
141  * @Return: Success or Failure
142  */
143 QDF_STATUS wlan_green_ap_state_mc(struct wlan_pdev_green_ap_ctx *green_ap_ctx,
144 				  enum wlan_green_ap_ps_event event);
145 
146 /**
147  * wlan_green_ap_timer_fn() - Green ap timer callback
148  * @pdev: pdev pointer
149  *
150  * @Return: None
151  */
152 void wlan_green_ap_timer_fn(void *pdev);
153 
154 /**
155  * wlan_green_ap_check_mode() - Check for mode
156  * @pdev: pdev pointer
157  * @object:  vdev object
158  * @arg: flag to be set
159  *
160  * Callback to check if all modes on radio are configured as AP
161  *
162  * @Return: None
163  */
164 void wlan_green_ap_check_mode(struct wlan_objmgr_pdev *pdev,
165 		void *object,
166 		void *arg);
167 #endif  /* _WLAN_GREEN_AP_MAIN_I_H_ */
168