1 /* 2 * Copyright (c) 2017-2019 The Linux Foundation. All rights reserved. 3 * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. 4 * 5 * Permission to use, copy, modify, and/or distribute this software for 6 * any purpose with or without fee is hereby granted, provided that the 7 * above copyright notice and this permission notice appear in all 8 * copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 16 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 17 * PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20 21 /** 22 * DOC: This file has main green ap structures. 23 */ 24 25 #ifndef _WLAN_GREEN_AP_MAIN_I_H_ 26 #define _WLAN_GREEN_AP_MAIN_I_H_ 27 28 #include <wlan_objmgr_cmn.h> 29 #include <wlan_objmgr_pdev_obj.h> 30 #include <wlan_green_ap_api.h> 31 #include <qdf_types.h> 32 #include <qdf_status.h> 33 #include <qdf_timer.h> 34 #include "wlan_utility.h" 35 #include <qdf_module.h> 36 #include "../../dispatcher/inc/wlan_green_ap_api.h" 37 38 #define WLAN_GREEN_AP_PS_ON_TIME (0) 39 #define WLAN_GREEN_AP_PS_TRANS_TIME (20) 40 41 #define green_ap_alert(params...) \ 42 QDF_TRACE_FATAL(QDF_MODULE_ID_GREEN_AP, params) 43 #define green_ap_err(params...) \ 44 QDF_TRACE_ERROR(QDF_MODULE_ID_GREEN_AP, params) 45 #define green_ap_warn(params...) \ 46 QDF_TRACE_WARN(QDF_MODULE_ID_GREEN_AP, params) 47 #define green_ap_notice(params...) \ 48 QDF_TRACE_INFO(QDF_MODULE_ID_GREEN_AP, params) 49 #define green_ap_info(params...) \ 50 QDF_TRACE_INFO(QDF_MODULE_ID_GREEN_AP, params) 51 #define green_ap_debug(params...) \ 52 QDF_TRACE_DEBUG(QDF_MODULE_ID_GREEN_AP, params) 53 54 #define greenap_nofl_alert(params...) \ 55 QDF_TRACE_FATAL_NO_FL(QDF_MODULE_ID_GREEN_AP, params) 56 #define greenap_nofl_err(params...) \ 57 QDF_TRACE_ERROR_NO_FL(QDF_MODULE_ID_GREEN_AP, params) 58 #define greenap_nofl_warn(params...) \ 59 QDF_TRACE_WARN_NO_FL(QDF_MODULE_ID_GREEN_AP, params) 60 #define greenap_nofl_info(params...) \ 61 QDF_TRACE_INFO_NO_FL(QDF_MODULE_ID_GREEN_AP, params) 62 #define greenap_nofl_debug(params...) \ 63 QDF_TRACE_DEBUG_NO_FL(QDF_MODULE_ID_GREEN_AP, params) 64 65 #define WLAN_GREEN_AP_PS_DISABLE 0 66 #define WLAN_GREEN_AP_PS_ENABLE 1 67 #define WLAN_GREEN_AP_PS_SUSPEND 2 68 /** 69 * enum wlan_green_ap_ps_state - PS states 70 * @WLAN_GREEN_AP_PS_IDLE_STATE: Idle 71 * @WLAN_GREEN_AP_PS_OFF_STATE: Off 72 * @WLAN_GREEN_AP_PS_WAIT_STATE: Wait 73 * @WLAN_GREEN_AP_PS_ON_STATE: On 74 */ 75 enum wlan_green_ap_ps_state { 76 WLAN_GREEN_AP_PS_IDLE_STATE = 1, 77 WLAN_GREEN_AP_PS_OFF_STATE, 78 WLAN_GREEN_AP_PS_WAIT_STATE, 79 WLAN_GREEN_AP_PS_ON_STATE, 80 }; 81 82 /** 83 * enum wlan_green_ap_ps_event - PS event 84 * @WLAN_GREEN_AP_PS_START_EVENT: Start 85 * @WLAN_GREEN_AP_PS_STOP_EVENT: Stop 86 * @WLAN_GREEN_AP_ADD_STA_EVENT: Sta assoc 87 * @WLAN_GREEN_AP_DEL_STA_EVENT: Sta disassoc 88 * @WLAN_GREEN_AP_ADD_MULTISTREAM_STA_EVENT: Multistream sta assoc 89 * @WLAN_GREEN_AP_DEL_MULTISTREAM_STA_EVENT: Multistream sta disassoc 90 * @WLAN_GREEN_AP_PS_ON_EVENT: PS on 91 * @WLAN_GREEN_AP_PS_WAIT_EVENT: PS wait 92 */ 93 enum wlan_green_ap_ps_event { 94 WLAN_GREEN_AP_PS_START_EVENT = 1, 95 WLAN_GREEN_AP_PS_STOP_EVENT, 96 WLAN_GREEN_AP_ADD_STA_EVENT, 97 WLAN_GREEN_AP_DEL_STA_EVENT, 98 WLAN_GREEN_AP_ADD_MULTISTREAM_STA_EVENT, 99 WLAN_GREEN_AP_DEL_MULTISTREAM_STA_EVENT, 100 WLAN_GREEN_AP_PS_ON_EVENT, 101 WLAN_GREEN_AP_PS_WAIT_EVENT, 102 }; 103 104 /** 105 * enum wlan_green_ap_ll_ps_state - PS state 106 * @WLAN_GREEN_AP_LL_PS_DISABLE: Disable PS 107 * @WLAN_GREEN_AP_LL_PS_ENABLE: Enable PS 108 */ 109 enum wlan_green_ap_ll_ps_state { 110 WLAN_GREEN_AP_LL_PS_DISABLE = 0, 111 WLAN_GREEN_AP_LL_PS_ENABLE, 112 }; 113 114 /** 115 * struct wlan_pdev_green_ap_ctx - green ap context 116 * @pdev: Pdev pointer 117 * @ps_enable: Enable PS 118 * @ps_mode: No sta or Multistream sta mode 119 * @ps_on_time: PS on time, once enabled 120 * @ps_trans_time: PS transition time 121 * @num_nodes: Number of nodes associated to radio 122 * @num_nodes_multistream: Multistream nodes associated to radio 123 * @ps_state: PS state 124 * @ps_event: PS event 125 * @ps_timer: Timer 126 * @lock: green ap spinlock 127 * @bcn_mult: beacon multiplier 128 * @ps_en_cmd_cnt: Power save enable command count 129 * @ps_dis_cmd_cnt: Power save disable command count 130 * @vdev: vdev pointer 131 * @hdd_cback: hdd callback object for green ap 132 * @egap_params: Enhanced green ap params 133 * @dbg_enable: Debug Enable 134 */ 135 struct wlan_pdev_green_ap_ctx { 136 struct wlan_objmgr_pdev *pdev; 137 uint8_t ps_enable; 138 uint8_t ps_mode; 139 uint8_t ps_on_time; 140 uint32_t ps_trans_time; 141 uint32_t num_nodes; 142 uint32_t num_nodes_multistream; 143 enum wlan_green_ap_ps_state ps_state; 144 enum wlan_green_ap_ps_event ps_event; 145 qdf_timer_t ps_timer; 146 qdf_spinlock_t lock; 147 #ifdef WLAN_SUPPORT_GAP_LL_PS_MODE 148 uint32_t bcn_mult; 149 qdf_atomic_t ps_en_cmd_cnt; 150 qdf_atomic_t ps_dis_cmd_cnt; 151 struct wlan_objmgr_vdev *vdev; 152 struct green_ap_hdd_callback hdd_cback; 153 #endif 154 struct wlan_green_ap_egap_params egap_params; 155 bool dbg_enable; 156 }; 157 158 /** 159 * wlan_psoc_get_green_ap_tx_ops() - Obtain green ap tx ops from green ap ctx 160 * @green_ap_ctx: green ap context 161 * 162 * Return: green ap tx ops pointer 163 */ 164 struct wlan_lmac_if_green_ap_tx_ops * 165 wlan_psoc_get_green_ap_tx_ops(struct wlan_pdev_green_ap_ctx *green_ap_ctx); 166 167 /** 168 * wlan_is_egap_enabled() - Get Enhance Green AP feature status 169 * @green_ap_ctx: green ap context 170 * 171 * Return: true if firmware, feature_flag and ini are all egap enabled 172 */ 173 bool wlan_is_egap_enabled(struct wlan_pdev_green_ap_ctx *green_ap_ctx); 174 175 /** 176 * wlan_green_ap_state_mc() - Green ap state machine 177 * @green_ap_ctx: green ap context 178 * @event: ps event 179 * 180 * Return: Success or Failure 181 */ 182 QDF_STATUS wlan_green_ap_state_mc(struct wlan_pdev_green_ap_ctx *green_ap_ctx, 183 enum wlan_green_ap_ps_event event); 184 185 /** 186 * wlan_green_ap_timer_fn() - Green ap timer callback 187 * @pdev: pdev pointer 188 * 189 * Return: None 190 */ 191 void wlan_green_ap_timer_fn(void *pdev); 192 193 /** 194 * wlan_green_ap_check_mode() - Check for mode 195 * @pdev: pdev pointer 196 * @object: vdev object 197 * @arg: flag to be set 198 * 199 * Callback to check if all modes on radio are configured as AP 200 * 201 * Return: None 202 */ 203 void wlan_green_ap_check_mode(struct wlan_objmgr_pdev *pdev, 204 void *object, 205 void *arg); 206 207 #ifdef WLAN_SUPPORT_GAP_LL_PS_MODE 208 /** 209 * wlan_green_ap_get_cookie_id() - Get Low latency Power save cookie id 210 * @green_ap_ctx: green ap context 211 * @state: Received command state (Enable/Disable) 212 * 213 * Return: New cookie id 214 */ 215 uint32_t wlan_green_ap_get_cookie_id(struct wlan_pdev_green_ap_ctx *green_ap_ctx, 216 enum wlan_green_ap_ll_ps_state state); 217 218 /** 219 * wlan_green_ap_send_ll_ps_event_params() - Api to send event parameter 220 * to userspace 221 * @pdev: pdev pointer 222 * @event_param: event parameter 223 * 224 * Return: QDF_STATUS_SUCCESS on success 225 */ 226 QDF_STATUS wlan_green_ap_send_ll_ps_event_params( 227 struct wlan_objmgr_pdev *pdev, 228 struct wlan_green_ap_ll_ps_event_param *event_param); 229 #endif 230 #endif /* _WLAN_GREEN_AP_MAIN_I_H_ */ 231