162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
262306a36Sopenharmony_ci * Copyright(c) 2020-2022  Realtek Corporation
362306a36Sopenharmony_ci */
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci#ifndef __RTW89_CHAN_H__
662306a36Sopenharmony_ci#define __RTW89_CHAN_H__
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci#include "core.h"
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci/* The dwell time in TU before doing rtw89_chanctx_work(). */
1162306a36Sopenharmony_ci#define RTW89_CHANCTX_TIME_MCC_PREPARE 100
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_cistatic inline bool rtw89_get_entity_state(struct rtw89_dev *rtwdev)
1462306a36Sopenharmony_ci{
1562306a36Sopenharmony_ci	struct rtw89_hal *hal = &rtwdev->hal;
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci	return READ_ONCE(hal->entity_active);
1862306a36Sopenharmony_ci}
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_cistatic inline void rtw89_set_entity_state(struct rtw89_dev *rtwdev, bool active)
2162306a36Sopenharmony_ci{
2262306a36Sopenharmony_ci	struct rtw89_hal *hal = &rtwdev->hal;
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci	WRITE_ONCE(hal->entity_active, active);
2562306a36Sopenharmony_ci}
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_cistatic inline
2862306a36Sopenharmony_cienum rtw89_entity_mode rtw89_get_entity_mode(struct rtw89_dev *rtwdev)
2962306a36Sopenharmony_ci{
3062306a36Sopenharmony_ci	struct rtw89_hal *hal = &rtwdev->hal;
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ci	return READ_ONCE(hal->entity_mode);
3362306a36Sopenharmony_ci}
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_cistatic inline void rtw89_set_entity_mode(struct rtw89_dev *rtwdev,
3662306a36Sopenharmony_ci					 enum rtw89_entity_mode mode)
3762306a36Sopenharmony_ci{
3862306a36Sopenharmony_ci	struct rtw89_hal *hal = &rtwdev->hal;
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci	WRITE_ONCE(hal->entity_mode, mode);
4162306a36Sopenharmony_ci}
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_civoid rtw89_chan_create(struct rtw89_chan *chan, u8 center_chan, u8 primary_chan,
4462306a36Sopenharmony_ci		       enum rtw89_band band, enum rtw89_bandwidth bandwidth);
4562306a36Sopenharmony_cibool rtw89_assign_entity_chan(struct rtw89_dev *rtwdev,
4662306a36Sopenharmony_ci			      enum rtw89_sub_entity_idx idx,
4762306a36Sopenharmony_ci			      const struct rtw89_chan *new);
4862306a36Sopenharmony_civoid rtw89_config_entity_chandef(struct rtw89_dev *rtwdev,
4962306a36Sopenharmony_ci				 enum rtw89_sub_entity_idx idx,
5062306a36Sopenharmony_ci				 const struct cfg80211_chan_def *chandef);
5162306a36Sopenharmony_civoid rtw89_config_roc_chandef(struct rtw89_dev *rtwdev,
5262306a36Sopenharmony_ci			      enum rtw89_sub_entity_idx idx,
5362306a36Sopenharmony_ci			      const struct cfg80211_chan_def *chandef);
5462306a36Sopenharmony_civoid rtw89_entity_init(struct rtw89_dev *rtwdev);
5562306a36Sopenharmony_cienum rtw89_entity_mode rtw89_entity_recalc(struct rtw89_dev *rtwdev);
5662306a36Sopenharmony_civoid rtw89_chanctx_work(struct work_struct *work);
5762306a36Sopenharmony_civoid rtw89_queue_chanctx_work(struct rtw89_dev *rtwdev);
5862306a36Sopenharmony_ciint rtw89_chanctx_ops_add(struct rtw89_dev *rtwdev,
5962306a36Sopenharmony_ci			  struct ieee80211_chanctx_conf *ctx);
6062306a36Sopenharmony_civoid rtw89_chanctx_ops_remove(struct rtw89_dev *rtwdev,
6162306a36Sopenharmony_ci			      struct ieee80211_chanctx_conf *ctx);
6262306a36Sopenharmony_civoid rtw89_chanctx_ops_change(struct rtw89_dev *rtwdev,
6362306a36Sopenharmony_ci			      struct ieee80211_chanctx_conf *ctx,
6462306a36Sopenharmony_ci			      u32 changed);
6562306a36Sopenharmony_ciint rtw89_chanctx_ops_assign_vif(struct rtw89_dev *rtwdev,
6662306a36Sopenharmony_ci				 struct rtw89_vif *rtwvif,
6762306a36Sopenharmony_ci				 struct ieee80211_chanctx_conf *ctx);
6862306a36Sopenharmony_civoid rtw89_chanctx_ops_unassign_vif(struct rtw89_dev *rtwdev,
6962306a36Sopenharmony_ci				    struct rtw89_vif *rtwvif,
7062306a36Sopenharmony_ci				    struct ieee80211_chanctx_conf *ctx);
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_ci#endif
73