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