File Index
Files and directories
Sign in
FILE

chan.h

File preview with syntax highlighting.

linux-6.19.14/drivers/net/wireless/realtek/rtw89/chan.h C
  1/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
  2 * Copyright(c) 2020-2022  Realtek Corporation
  3 */
  4
  5#ifndef __RTW89_CHAN_H__
  6#define __RTW89_CHAN_H__
  7
  8#include "core.h"
  9
 10/* The dwell time in TU before doing rtw89_chanctx_work(). */
 11#define RTW89_CHANCTX_TIME_MCC_PREPARE 100
 12#define RTW89_CHANCTX_TIME_MCC 100
 13
 14/* various MCC setting time in TU */
 15#define RTW89_MCC_LONG_TRIGGER_TIME 300
 16#define RTW89_MCC_SHORT_TRIGGER_TIME 100
 17#define RTW89_MCC_EARLY_TX_BCN_TIME 10
 18#define RTW89_MCC_EARLY_RX_BCN_TIME 5
 19#define RTW89_MCC_MIN_RX_BCN_TIME 10
 20#define RTW89_MCC_DFLT_BCN_OFST_TIME 40
 21#define RTW89_MCC_SWITCH_CH_TIME 3
 22
 23#define RTW89_MCC_PROBE_TIMEOUT 100
 24#define RTW89_MCC_PROBE_MAX_TRIES 3
 25
 26#define RTW89_MCC_DETECT_BCN_MAX_TRIES 2
 27
 28#define RTW89_MCC_MIN_GO_DURATION \
 29	(RTW89_MCC_EARLY_TX_BCN_TIME + RTW89_MCC_MIN_RX_BCN_TIME)
 30
 31#define RTW89_MCC_MIN_STA_DURATION \
 32	(RTW89_MCC_EARLY_RX_BCN_TIME + RTW89_MCC_MIN_RX_BCN_TIME)
 33
 34#define RTW89_MCC_MIN_RX_BCN_WITH_SWITCH_CH_TIME \
 35	(RTW89_MCC_MIN_RX_BCN_TIME + RTW89_MCC_SWITCH_CH_TIME)
 36
 37#define RTW89_MCC_DFLT_GROUP 0
 38#define RTW89_MCC_NEXT_GROUP(cur) (((cur) + 1) % 4)
 39
 40#define RTW89_MCC_DFLT_TX_NULL_EARLY 7
 41#define RTW89_MCC_DFLT_COURTESY_SLOT 3
 42
 43#define RTW89_MCC_REQ_COURTESY_TIME 5
 44#define RTW89_MCC_REQ_COURTESY(pattern, role)			\
 45({								\
 46	const struct rtw89_mcc_pattern *p = pattern;		\
 47	p->tob_ ## role <= RTW89_MCC_REQ_COURTESY_TIME ||	\
 48	p->toa_ ## role <= RTW89_MCC_REQ_COURTESY_TIME;		\
 49})
 50
 51#define NUM_OF_RTW89_MCC_ROLES 2
 52
 53enum rtw89_mr_wtype {
 54	RTW89_MR_WTYPE_NONE,
 55	RTW89_MR_WTYPE_NONMLD,
 56	RTW89_MR_WTYPE_MLD1L1R,
 57	RTW89_MR_WTYPE_MLD2L1R,
 58	RTW89_MR_WTYPE_MLD2L2R,
 59	RTW89_MR_WTYPE_NONMLD_NONMLD,
 60	RTW89_MR_WTYPE_MLD1L1R_NONMLD,
 61	RTW89_MR_WTYPE_MLD2L1R_NONMLD,
 62	RTW89_MR_WTYPE_MLD2L2R_NONMLD,
 63	RTW89_MR_WTYPE_UNKNOWN,
 64};
 65
 66enum rtw89_mr_wmode {
 67	RTW89_MR_WMODE_NONE,
 68	RTW89_MR_WMODE_1CLIENT,
 69	RTW89_MR_WMODE_1AP,
 70	RTW89_MR_WMODE_1AP_1CLIENT,
 71	RTW89_MR_WMODE_2CLIENTS,
 72	RTW89_MR_WMODE_2APS,
 73	RTW89_MR_WMODE_UNKNOWN,
 74};
 75
 76enum rtw89_mr_ctxtype {
 77	RTW89_MR_CTX_NONE,
 78	RTW89_MR_CTX1_2GHZ,
 79	RTW89_MR_CTX1_5GHZ,
 80	RTW89_MR_CTX1_6GHZ,
 81	RTW89_MR_CTX2_2GHZ,
 82	RTW89_MR_CTX2_5GHZ,
 83	RTW89_MR_CTX2_6GHZ,
 84	RTW89_MR_CTX2_2GHZ_5GHZ,
 85	RTW89_MR_CTX2_2GHZ_6GHZ,
 86	RTW89_MR_CTX2_5GHZ_6GHZ,
 87	RTW89_MR_CTX_UNKNOWN,
 88};
 89
 90struct rtw89_mr_chanctx_info {
 91	enum rtw89_mr_wtype wtype;
 92	enum rtw89_mr_wmode wmode;
 93	enum rtw89_mr_ctxtype ctxtype;
 94};
 95
 96enum rtw89_chanctx_pause_reasons {
 97	RTW89_CHANCTX_PAUSE_REASON_HW_SCAN,
 98	RTW89_CHANCTX_PAUSE_REASON_ROC,
 99	RTW89_CHANCTX_PAUSE_REASON_GC_BCN_LOSS,
100};
101
102struct rtw89_chanctx_pause_parm {
103	const struct rtw89_vif_link *trigger;
104	enum rtw89_chanctx_pause_reasons rsn;
105};
106
107struct rtw89_chanctx_cb_parm {
108	int (*cb)(struct rtw89_dev *rtwdev, void *data);
109	void *data;
110	const char *caller;
111};
112
113struct rtw89_entity_weight {
114	unsigned int registered_chanctxs;
115	unsigned int active_chanctxs;
116	unsigned int active_roles;
117};
118
119static inline bool rtw89_get_entity_state(struct rtw89_dev *rtwdev,
120					  enum rtw89_phy_idx phy_idx)
121{
122	struct rtw89_hal *hal = &rtwdev->hal;
123
124	return READ_ONCE(hal->entity_active[phy_idx]);
125}
126
127static inline void rtw89_set_entity_state(struct rtw89_dev *rtwdev,
128					  enum rtw89_phy_idx phy_idx,
129					  bool active)
130{
131	struct rtw89_hal *hal = &rtwdev->hal;
132
133	WRITE_ONCE(hal->entity_active[phy_idx], active);
134}
135
136static inline
137enum rtw89_entity_mode rtw89_get_entity_mode(struct rtw89_dev *rtwdev)
138{
139	struct rtw89_hal *hal = &rtwdev->hal;
140
141	return READ_ONCE(hal->entity_mode);
142}
143
144static inline void rtw89_set_entity_mode(struct rtw89_dev *rtwdev,
145					 enum rtw89_entity_mode mode)
146{
147	struct rtw89_hal *hal = &rtwdev->hal;
148
149	WRITE_ONCE(hal->entity_mode, mode);
150}
151
152void rtw89_chan_create(struct rtw89_chan *chan, u8 center_chan, u8 primary_chan,
153		       enum rtw89_band band, enum rtw89_bandwidth bandwidth);
154bool rtw89_assign_entity_chan(struct rtw89_dev *rtwdev,
155			      enum rtw89_chanctx_idx idx,
156			      const struct rtw89_chan *new);
157int rtw89_iterate_entity_chan(struct rtw89_dev *rtwdev,
158			      int (*iterator)(const struct rtw89_chan *chan,
159					      void *data),
160			      void *data);
161void rtw89_config_entity_chandef(struct rtw89_dev *rtwdev,
162				 enum rtw89_chanctx_idx idx,
163				 const struct cfg80211_chan_def *chandef);
164void rtw89_config_roc_chandef(struct rtw89_dev *rtwdev,
165			      struct rtw89_vif_link *rtwvif_link,
166			      const struct cfg80211_chan_def *chandef);
167void rtw89_entity_init(struct rtw89_dev *rtwdev);
168enum rtw89_entity_mode rtw89_entity_recalc(struct rtw89_dev *rtwdev);
169void rtw89_chanctx_work(struct wiphy *wiphy, struct wiphy_work *work);
170void rtw89_queue_chanctx_work(struct rtw89_dev *rtwdev);
171void rtw89_queue_chanctx_change(struct rtw89_dev *rtwdev,
172				enum rtw89_chanctx_changes change);
173void rtw89_query_mr_chanctx_info(struct rtw89_dev *rtwdev, u8 inst_idx,
174				 struct rtw89_mr_chanctx_info *info);
175void rtw89_chanctx_track(struct rtw89_dev *rtwdev);
176void rtw89_chanctx_pause(struct rtw89_dev *rtwdev,
177			 const struct rtw89_chanctx_pause_parm *parm);
178void rtw89_chanctx_proceed(struct rtw89_dev *rtwdev,
179			   const struct rtw89_chanctx_cb_parm *cb_parm);
180
181const struct rtw89_chan *__rtw89_mgnt_chan_get(struct rtw89_dev *rtwdev,
182					       const char *caller_message,
183					       u8 link_index, bool nullchk);
184
185#define rtw89_mgnt_chan_get(rtwdev, link_index) \
186	__rtw89_mgnt_chan_get(rtwdev, __func__, link_index, false)
187
188static inline const struct rtw89_chan *
189rtw89_mgnt_chan_get_or_null(struct rtw89_dev *rtwdev, u8 link_index)
190{
191	return __rtw89_mgnt_chan_get(rtwdev, NULL, link_index, true);
192}
193
194struct rtw89_mcc_links_info {
195	struct rtw89_vif_link *links[NUM_OF_RTW89_MCC_ROLES];
196};
197
198void rtw89_mcc_get_links(struct rtw89_dev *rtwdev, struct rtw89_mcc_links_info *info);
199void rtw89_mcc_prepare_done_work(struct wiphy *wiphy, struct wiphy_work *work);
200void rtw89_mcc_gc_detect_beacon_work(struct wiphy *wiphy, struct wiphy_work *work);
201bool rtw89_mcc_detect_go_bcn(struct rtw89_dev *rtwdev,
202			     struct rtw89_vif_link *rtwvif_link);
203
204int rtw89_chanctx_ops_add(struct rtw89_dev *rtwdev,
205			  struct ieee80211_chanctx_conf *ctx);
206void rtw89_chanctx_ops_remove(struct rtw89_dev *rtwdev,
207			      struct ieee80211_chanctx_conf *ctx);
208void rtw89_chanctx_ops_change(struct rtw89_dev *rtwdev,
209			      struct ieee80211_chanctx_conf *ctx,
210			      u32 changed);
211int rtw89_chanctx_ops_assign_vif(struct rtw89_dev *rtwdev,
212				 struct rtw89_vif_link *rtwvif_link,
213				 struct ieee80211_chanctx_conf *ctx);
214void rtw89_chanctx_ops_unassign_vif(struct rtw89_dev *rtwdev,
215				    struct rtw89_vif_link *rtwvif_link,
216				    struct ieee80211_chanctx_conf *ctx);
217int rtw89_chanctx_ops_reassign_vif(struct rtw89_dev *rtwdev,
218				   struct rtw89_vif_link *rtwvif_link,
219				   struct ieee80211_chanctx_conf *old_ctx,
220				   struct ieee80211_chanctx_conf *new_ctx,
221				   bool replace);
222
223#endif
~/ Read-only file preview.