xref: /OK3568_Linux_fs/external/rkwifibt/drivers/rtl8852bs/phl/phl_ecsa.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /******************************************************************************
2  *
3  * Copyright(c) 2020 Realtek Corporation.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  *****************************************************************************/
15 #ifndef _PHL_ECSA_H_
16 #define _PHL_ECSA_H_
17 
18 #define ECSA_UPDATE_BCN_BEFORE_TBTT 25 /* unit: TU */
19 #define ECSA_UPDATE_BCN_BEFORE_TBTT_US (ECSA_UPDATE_BCN_BEFORE_TBTT * TU)
20 
21 #define ECSA_DEFAULT_CHANNEL_SWITCH_COUNT 10
22 #define ECSA_SWITCH_TIME_AFTER_LAST_COUNT_DOWN (10 * TU)
23 
24 #define IS_ECSA_TYPE_AP(_ecsa_ctrl) (_ecsa_ctrl->ecsa_param.ecsa_type == ECSA_TYPE_AP)
25 #define IS_ECSA_TYPE_STA(_ecsa_ctrl) (_ecsa_ctrl->ecsa_param.ecsa_type == ECSA_TYPE_STA)
26 
27 enum phl_ecsa_state{
28 	ECSA_STATE_NONE = 0,
29 	ECSA_STATE_WAIT_DELAY = 1,
30 	ECSA_STATE_START,
31 	ECSA_STATE_UPDATE_FIRST_BCN_DONE,
32 	ECSA_STATE_COUNT_DOWN,
33 	ECSA_STATE_SWITCH,
34 	ECSA_STATE_DONE
35 };
36 
37 struct phl_ecsa_ctrl_t{
38 	enum phl_ecsa_state state;
39 	struct rtw_phl_com_t *phl_com;
40 	struct rtw_wifi_role_t *role;
41 	struct rtw_phl_ecsa_param ecsa_param;
42 	struct rtw_phl_ecsa_ops ops;
43 	_os_timer timer;
44 	_os_lock lock;
45 	u32 expected_tbtt_ms;
46 	u32 req_hdl;
47 };
48 
49 #ifdef CONFIG_PHL_ECSA
50 enum rtw_phl_status phl_ecsa_ctrl_init(struct phl_info_t *phl_info);
51 void phl_ecsa_ctrl_deinit(struct phl_info_t *phl_info);
52 #else
53 #define phl_ecsa_ctrl_init(_phl_info) RTW_PHL_STATUS_SUCCESS
54 #define phl_ecsa_ctrl_deinit(_phl_info)
55 #endif /* CONFIG_PHL_ECSA */
56 
57 #endif /*_PHL_ECSA_H_*/
58