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 13 static inline bool rtw89_get_entity_state(struct rtw89_dev *rtwdev) 14 { 15 struct rtw89_hal *hal = &rtwdev->hal; 16 17 return READ_ONCE(hal->entity_active); 18 } 19 20 static inline void rtw89_set_entity_state(struct rtw89_dev *rtwdev, bool active) 21 { 22 struct rtw89_hal *hal = &rtwdev->hal; 23 24 WRITE_ONCE(hal->entity_active, active); 25 } 26 27 static inline 28 enum rtw89_entity_mode rtw89_get_entity_mode(struct rtw89_dev *rtwdev) 29 { 30 struct rtw89_hal *hal = &rtwdev->hal; 31 32 return READ_ONCE(hal->entity_mode); 33 } 34 35 static inline void rtw89_set_entity_mode(struct rtw89_dev *rtwdev, 36 enum rtw89_entity_mode mode) 37 { 38 struct rtw89_hal *hal = &rtwdev->hal; 39 40 WRITE_ONCE(hal->entity_mode, mode); 41 } 42 43 void rtw89_chan_create(struct rtw89_chan *chan, u8 center_chan, u8 primary_chan, 44 enum rtw89_band band, enum rtw89_bandwidth bandwidth); 45 bool rtw89_assign_entity_chan(struct rtw89_dev *rtwdev, 46 enum rtw89_sub_entity_idx idx, 47 const struct rtw89_chan *new); 48 void rtw89_config_entity_chandef(struct rtw89_dev *rtwdev, 49 enum rtw89_sub_entity_idx idx, 50 const struct cfg80211_chan_def *chandef); 51 void rtw89_config_roc_chandef(struct rtw89_dev *rtwdev, 52 enum rtw89_sub_entity_idx idx, 53 const struct cfg80211_chan_def *chandef); 54 void rtw89_entity_init(struct rtw89_dev *rtwdev); 55 enum rtw89_entity_mode rtw89_entity_recalc(struct rtw89_dev *rtwdev); 56 void rtw89_chanctx_work(struct work_struct *work); 57 void rtw89_queue_chanctx_work(struct rtw89_dev *rtwdev); 58 int rtw89_chanctx_ops_add(struct rtw89_dev *rtwdev, 59 struct ieee80211_chanctx_conf *ctx); 60 void rtw89_chanctx_ops_remove(struct rtw89_dev *rtwdev, 61 struct ieee80211_chanctx_conf *ctx); 62 void rtw89_chanctx_ops_change(struct rtw89_dev *rtwdev, 63 struct ieee80211_chanctx_conf *ctx, 64 u32 changed); 65 int rtw89_chanctx_ops_assign_vif(struct rtw89_dev *rtwdev, 66 struct rtw89_vif *rtwvif, 67 struct ieee80211_chanctx_conf *ctx); 68 void rtw89_chanctx_ops_unassign_vif(struct rtw89_dev *rtwdev, 69 struct rtw89_vif *rtwvif, 70 struct ieee80211_chanctx_conf *ctx); 71 72 #endif 73