xref: /OK3568_Linux_fs/external/rkwifibt/drivers/rtl8852bs/phl/phl_mr.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /******************************************************************************
2  *
3  * Copyright(c) 2019 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_MR_H_
16 #define _PHL_MR_H_
17 
18 static inline int
phl_mr_get_chanctx_num(struct phl_info_t * phl_info,struct hw_band_ctl_t * band_ctrl)19 phl_mr_get_chanctx_num(struct phl_info_t *phl_info, struct hw_band_ctl_t *band_ctrl)
20 {
21 	void *drv = phl_to_drvpriv(phl_info);
22 	int chanctx_num = 0;
23 
24 	_os_spinlock(drv, &band_ctrl->chan_ctx_queue.lock, _ps, NULL);
25 	chanctx_num = band_ctrl->chan_ctx_queue.cnt;
26 	_os_spinunlock(drv, &band_ctrl->chan_ctx_queue.lock, _ps, NULL);
27 	return chanctx_num;
28 }
29 
30 static inline u8
phl_mr_get_role_num(struct phl_info_t * phl_info,struct hw_band_ctl_t * band_ctrl)31 phl_mr_get_role_num(struct phl_info_t *phl_info,
32 				struct hw_band_ctl_t *band_ctrl)
33 {
34 	void *drv = phl_to_drvpriv(phl_info);
35 	u8 i;
36 	u8 role_num = 0;
37 
38 	_os_spinlock(drv, &band_ctrl->lock, _ps, NULL);
39 	for (i = 0; i < MAX_WIFI_ROLE_NUMBER; i++) {
40 		if (band_ctrl->role_map & BIT(i)) {
41 			role_num++;
42 		}
43 	}
44 	_os_spinunlock(drv, &band_ctrl->lock, _ps, NULL);
45 
46 	return role_num;
47 }
48 
49 enum rtw_phl_status
50 phl_mr_sync_chandef(struct phl_info_t *phl_info, struct hw_band_ctl_t *band_ctrl,
51 			struct rtw_chan_ctx *chanctx, struct rtw_chan_def *chandef);
52 
53 enum rtw_phl_status
54 phl_mr_chandef_chg(struct phl_info_t *phl,
55 		struct rtw_wifi_role_t *wrole, struct rtw_chan_def *new_chan,
56 		struct rtw_chan_def *chctx_result);
57 
58 enum rtw_phl_status
59 phl_mr_chandef_upt(struct phl_info_t *phl_info,
60 		struct hw_band_ctl_t *band_ctrl, struct rtw_chan_ctx *chanctx);
61 
62 enum rtw_phl_status
63 phl_mr_get_chandef(struct phl_info_t *phl_info, struct rtw_wifi_role_t *wifi_role,
64 			bool sync, struct rtw_chan_def *chandef);
65 
66 enum rtw_phl_status
67 phl_mr_ctrl_init(struct phl_info_t *phl_info);
68 
69 enum rtw_phl_status
70 phl_mr_ctrl_deinit(struct phl_info_t *phl_info);
71 
72 enum rtw_phl_status
73 phl_mr_err_recovery(struct phl_info_t *phl, enum phl_msg_evt_id eid);
74 
75 #ifdef CONFIG_MCC_SUPPORT
76 enum rtw_phl_status
77 phl_mr_mcc_query_role_time_slot_lim (struct phl_info_t *phl_info, struct rtw_wifi_role_t *wrole,
78 								struct phl_mcc_dur_lim_req_info *limit_req_info);
79 
80 
81 enum rtw_phl_status
82 phl_mr_coex_handle(struct phl_info_t *phl, struct rtw_wifi_role_t *cur_wrole,
83 	u16 slot, enum phl_band_idx band_idx, enum mr_coex_trigger trgger);
84 
85 enum rtw_phl_status
86 phl_mr_coex_disable(struct phl_info_t *phl,
87 		struct rtw_wifi_role_t *cur_wrole, enum phl_band_idx band_idx,
88 		enum mr_coex_trigger trgger);
89 
90 #endif
91 
92 #ifdef CONFIG_PHL_P2PPS
93 bool phl_mr_noa_dur_lim_change (struct phl_info_t *phl_info, struct rtw_wifi_role_t *wrole,
94 								struct rtw_phl_noa_desc *noa_desc);
95 #endif
96 enum rtw_phl_status
97 phl_mr_info_upt(struct phl_info_t *phl_info, struct rtw_wifi_role_t *wrole);
98 
99 enum rtw_phl_status
100 phl_mr_state_upt(struct phl_info_t *phl_info, struct rtw_wifi_role_t *wrole);
101 
102 enum rtw_phl_status
103 rtw_phl_mr_rx_filter(void *phl, struct rtw_wifi_role_t *wrole);
104 
105 enum rtw_phl_status
106 phl_mr_tsf_sync(void *phl, struct rtw_wifi_role_t *wrole,
107 					enum role_state state);
108 
109 void phl_mr_stop_all_beacon(struct phl_info_t *phl_info,
110 			    struct rtw_wifi_role_t *wrole,
111 			    bool stop);
112 
113 enum rtw_phl_status
114 phl_mr_offch_hdl(struct phl_info_t *phl_info,
115 		  struct rtw_wifi_role_t *wrole,
116 		  bool off_ch,
117 		  void *obj_priv,
118 		  u8 (*issue_null_data)(void *priv, u8 ridx, bool ps));
119 
120 enum rtw_phl_status phl_mr_watchdog(struct phl_info_t *phl_info);
121 
122 u8 rtw_phl_mr_get_opch_list(void *phl, struct rtw_wifi_role_t *wifi_role,
123 			    struct rtw_chan_def *chdef_list, u8 list_size);
124 
125 void
126 phl_mr_check_ecsa(struct phl_info_t *phl_info,
127 		  struct rtw_wifi_role_t *wrole);
128 
129 void
130 phl_mr_check_ecsa_cancel(struct phl_info_t *phl_info,
131 			 struct rtw_wifi_role_t *wrole);
132 
133 #ifdef CONFIG_MCC_SUPPORT
134 u8 phl_mr_query_mcc_inprogress (struct phl_info_t *phl_info, struct rtw_wifi_role_t *wrole,
135 				enum rtw_phl_mcc_chk_inprocess_type check_type);
136 #endif
137 
138 #ifdef DBG_PHL_MR
139 enum rtw_phl_status phl_mr_info_dbg(struct phl_info_t *phl_info);
140 
141 void phl_mr_dump_cur_chandef(const char *caller, const int line, bool show_caller,
142 		struct phl_info_t *phl_info, struct rtw_wifi_role_t *wifi_role);
143 #define PHL_DUMP_CUR_CHANDEF(_phl_info, _wrole) \
144 	phl_mr_dump_cur_chandef(__FUNCTION__, __LINE__, false, _phl_info, _wrole);
145 #define PHL_DUMP_CUR_CHANDEF_EX(_phl_info, _wrole) \
146 	phl_mr_dump_cur_chandef(__FUNCTION__, __LINE__, true, _phl_info, _wrole);
147 
148 void phl_mr_dump_chctx_info(const char *caller, const int line, bool show_caller,
149 	struct phl_info_t *phl_info, struct phl_queue *chan_ctx_queue, struct rtw_chan_ctx *chanctx);
150 #define PHL_DUMP_CHAN_CTX(_phl_info, _chctx_q, _chctx) \
151 		phl_mr_dump_chctx_info(__FUNCTION__, __LINE__, false, _phl_info, _chctx_q, _chctx);
152 #define PHL_DUMP_CHAN_CTX_EX(_phl_info, _chctx_q, _chctx) \
153 		phl_mr_dump_chctx_info(__FUNCTION__, __LINE__, true, _phl_info, _chctx_q, _chctx);
154 
155 void phl_mr_dump_band_info(const char *caller, const int line, bool show_caller,
156 	struct phl_info_t *phl_info, struct hw_band_ctl_t *band_ctrl);
157 #define PHL_DUMP_BAND_CTL(_phl_info, band_ctl) \
158 		phl_mr_dump_band_info(__FUNCTION__, __LINE__, false, _phl_info, band_ctl)
159 #define PHL_DUMP_BAND_CTL_EX(_phl_info, band_ctl) \
160 		phl_mr_dump_band_info(__FUNCTION__, __LINE__, true, _phl_info, band_ctl)
161 
162 void phl_mr_dump_role_info(const char *caller, const int line, bool show_caller,
163 	struct phl_info_t *phl_info, struct rtw_wifi_role_t *wrole);
164 #define PHL_DUMP_ROLE(_phl_info, _wrole) \
165 		phl_mr_dump_role_info(__FUNCTION__, __LINE__, false, _phl_info, _wrole)
166 #define PHL_DUMP_ROLE_EX(_phl_info, _wrole) \
167 		phl_mr_dump_role_info(__FUNCTION__, __LINE__, true, _phl_info, _wrole)
168 
169 void phl_mr_dump_info(const char *caller, const int line, bool show_caller,
170 	struct phl_info_t *phl_info);
171 #define PHL_DUMP_MR(_phl_info) phl_mr_dump_info(__FUNCTION__, __LINE__, false, _phl_info)
172 #define PHL_DUMP_MR_EX(_phl_info) phl_mr_dump_info(__FUNCTION__, __LINE__, true, _phl_info)
173 
174 #else
175 #define PHL_DUMP_CUR_CHANDEF(_phl_info, _wrole)
176 #define PHL_DUMP_CUR_CHANDEF_EX(_phl_info, _wrole)
177 #define PHL_DUMP_CHAN_CTX(_phl_info, _chctx_q, _chctx)
178 #define PHL_DUMP_CHAN_CTX_EX(_phl_info, _chctx_q, _chctx)
179 #define PHL_DUMP_BAND_CTL(_phl_info, band_ctl)
180 #define PHL_DUMP_BAND_CTL_EX(_phl_info, band_ctl)
181 #define PHL_DUMP_ROLE(_phl_info, _wrole)
182 #define PHL_DUMP_ROLE_EX(_phl_info, _wrole)
183 #define PHL_DUMP_MR(_phl_info)
184 #define PHL_DUMP_MR_EX(_phl_info)
185 #endif
186 
187 #endif  /*_PHL_MR_H_*/
188 
189