summaryrefslogtreecommitdiff
path: root/drivers/net/wireless/realtek/rtw89/chan.c
AgeCommit message (Collapse)AuthorFilesLines
2023-09-28wifi: rtw89: pause/proceed MCC for ROC and HW scanZong-Zhe Yang1-0/+70
During (TDMA-based) MCC (multi-channel concurrency), the below two cases might not have a good behavior on channel usage. * ROC (remain on channel) * HW scan So, we tend to separate them from MCC. The two cases would expect to operate the channel to which they want. However, during MCC, channels are scheduled by FW MCC state mechanism. So, channels cannot be controlled explicitly. To avoid the two cases from operating wrong channels with chance, we pause MCC (essentially stop FW MCC) once the two cases are coming. And then, we proceed MCC again (essentially restart FW MCC) once the two cases finish. Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Kalle Valo <kvalo@kernel.org> Link: https://lore.kernel.org/r/20230921003559.11588-3-pkshih@realtek.com
2023-09-28wifi: rtw89: mcc: fix NoA start time when GO is auxiliaryZong-Zhe Yang1-0/+4
Under TDMA-based MCC (multi-channel concurrency), there are two roles, reference and auxiliary. We arrange MCC timeline based on time domain of reference role. Then, we calculate NoA start time according to MCC timeline. Besides, when MCC runs GO+STA mode, we plan an offset between GO time domain and STA time domain to make their TBTTs have a time gap. However, if GO is auxiliary role instead of reference role, NoA start time is described by STA time domain instead of GO time domain. To fix this, we apply the offset mentioned above to NoA start time to convert time domain from STA to GO. Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Kalle Valo <kvalo@kernel.org> Link: https://lore.kernel.org/r/20230921003559.11588-2-pkshih@realtek.com
2023-09-22wifi: rtw89: add subband index of primary channel to struct rtw89_chanPing-Ke Shih1-0/+15
The subband index is a hardware value of relationship between primary channel and bandwidth, and it is used by setting channel/bandwidth to specify the primary channel. Because this index is only needed when bandwidth >= 20 MHz, adjust order of enumerator bandwidth to access offsets array easier. To prevent misuse RTW89_CHANNEL_WIDTH_NUM as size, change it to RTW89_CHANNEL_WIDTH_ORDINARY_NUM that will be the size of array. The enumerator values of bandwidth (before ordinary number) will be also used by upcoming TX power table built in firmware file, so add a comment to remind keeping the order. Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Kalle Valo <kvalo@kernel.org> Link: https://lore.kernel.org/r/20230920074322.42898-2-pkshih@realtek.com
2023-09-18wifi: rtw89: mcc: deal with beacon NoA if GO existsZong-Zhe Yang1-1/+92
In MCC STA+GO mode, we calculate NoA information and fill it into the beacon of P2P GO. Since NoA uses only 32 bits to describe time things, we need to deal with renewal when TSF[63:32] is carried. We trigger FW to notify that. Then, we can update NoA information for new time period once we get notification from FW. Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Kalle Valo <kvalo@kernel.org> Link: https://lore.kernel.org/r/20230908031145.20931-9-pkshih@realtek.com
2023-09-18wifi: rtw89: mcc: deal with BT slot changeZong-Zhe Yang1-1/+4
When receiving request of adjusting BT slot from coex. mechanism, we need to fetch the new BT slot and use the new one to calculate MCC (multi-channel concurrency) pattern. Then, we update the new MCC pattern to FW. Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Kalle Valo <kvalo@kernel.org> Link: https://lore.kernel.org/r/20230908031145.20931-8-pkshih@realtek.com
2023-09-18wifi: rtw89: mcc: deal with P2P PS changeZong-Zhe Yang1-1/+24
MCC fills duration limit of a role according to NoA description. If P2P PS changes during MCC, we don't process P2P PS via normal flow. Instead, we re-fill duration limit of the role for new NoA description, and then we do MCC update. Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Kalle Valo <kvalo@kernel.org> Link: https://lore.kernel.org/r/20230908031145.20931-7-pkshih@realtek.com
2023-09-18wifi: rtw89: mcc: track beacon offset and update when neededZong-Zhe Yang1-2/+143
In MCC STA+GC mode, the offset between TBTTs of remote AP and remote GO might change. If the change is larger than tolerance, we should update MCC after re-calculating parameters for new things. So, we track that in rtw89_track_work() now. And, we add MCC update flow to tell FW either to change durations of roles or to replace entire pattern according to how MCC plans BT slot. Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Kalle Valo <kvalo@kernel.org> Link: https://lore.kernel.org/r/20230908031145.20931-6-pkshih@realtek.com
2023-09-18wifi: rtw89: mcc: update role bitmap when changedZong-Zhe Yang1-1/+73
Each MCC (multi-channel concurrency) role maintains a bitmap of mac IDs. The bitmap is supposed to contain the two points below. * mac ID of itself * mac ID(s) of STA(s) connecting to it Under STA+GC mode, the bitmaps of both roles should not change. However, under STA+GO mode, the bitmap of GO may change due to P2P clients which connect/disconnect to/from it. FW controls (TDMA-based) MCC things via mac IDs in bitmap of each role. For example, mac IDs are required by FW when it wants to pause role1's TX in role0 slot. So, to sync between driver and FW, we update the new mac ID bitmap of GO to FW once it's changed. Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Kalle Valo <kvalo@kernel.org> Link: https://lore.kernel.org/r/20230908031145.20931-5-pkshih@realtek.com
2023-09-07wifi: rtw89: mcc: trigger FW to start/stop MCCZong-Zhe Yang1-0/+173
According to Wi-Fi/BT roles' settings, we fill corresponding H2Cs (host to chip packets). Then, following MCC (multi-channel concurrency) pattern, we send these H2Cs as planned. Eventually, the trigger H2Cs will be sent to tell FW to really start/stop MCC. Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Kalle Valo <kvalo@kernel.org> Link: https://lore.kernel.org/r/20230831053133.24015-7-pkshih@realtek.com
2023-09-07wifi: rtw89: mcc: decide pattern and calculate parametersZong-Zhe Yang1-0/+233
After the previous works, we can now expand and display the MCC pattern in more detail, as shown below. |< MCC interval >| |< duration ref >| (if mid bt) |< duration aux >| (if tail bt) | |<tob ref >|< toa ref>| ... |<tob aux >|< toa aux>| ... | V V tbtt ref tbtt aux |< beacon offset >| (where tob means `time offset behind` and toa means `time offset ahead`) There are two key points. 1. decide position of BT slot if MCC pattern needs to handle BT duration. 2. calculate all parameters related to tob and toa in MCC pattern. For point (1), when BT duration needs to be handled, BT position will rely on beacon offset, either middle or tail. For point (2), to ensure durations of the Wi-Fi roles cover their beacons, we have to calculate tob and toa for them according to their TBTT. And, there are two strategies to calculate parameters, strict and loose. In strict pattern, all parameters take HW time into account as limitation. But, the strict calculation are not always successful. In loose pattern, it only tries to give positive parameters to reference role and doesn't care much about auxiliary role. If unfortunately auxiliary role gets negative parameters in loose pattern, FW will be notified and then deal with it. So, the loose calculation won't fail. In general, we always try strict pattern cases before using a loose pattern. Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Kalle Valo <kvalo@kernel.org> Link: https://lore.kernel.org/r/20230831053133.24015-5-pkshih@realtek.com
2023-09-07wifi: rtw89: mcc: consider and determine BT durationZong-Zhe Yang1-0/+169
Before calculating MCC pattern, we have to determine whether to handle BT duration in it or not. The decision will depend on the channels that Wi-Fi roles use. And, we have three cases shown below. 1. non-2GHz + non-2GHz 2. non-2GHz + 2GHz (different band) 3. 2GHz + 2GHz (dual 2GHz) For case (1), we don't care BT duration in MCC pattern. For case (2), we still don't care BT duration in MCC pattern. Instead, we try to satisfy it by modifying duration of Wi-Fi role on non-2GHz channel. For case (3), we need to modify Wi-Fi durations and also need to handle BT duration in MCC pattern. Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Kalle Valo <kvalo@kernel.org> Link: https://lore.kernel.org/r/20230831053133.24015-4-pkshih@realtek.com
2023-09-07wifi: rtw89: mcc: fill fundamental configurationsZong-Zhe Yang1-0/+167
We determine the fundamental settings shown below. |< MCC interval >| |< duration ref >|< duration aux >| | | | | |< beacon offset >| | | V V (tbtt ref) (tbtt aux) (where `ref` (reference) and `aux` (auxiliary) mean the two MCC roles) Based on MCC mode (GO+STA or GC+STA), we fill configurations of MCC interval and beacon offset. And, we make sure each MCC role have a basically required duration in the MCC interval. The beacon offset mentioned above is a parameter for further MCC pattern calculation. If MCC is in GC+STA mode, we will calculate the real beacon offset through TSFs shown in beacons of both MCC roles. Otherwise, we will use a default beacon offset, and make GO sync STA's TSF timer with this offset. MCC pattern calculation will break down each MCC role's duration in more detail. We will implement it in the following. Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Kalle Valo <kvalo@kernel.org> Link: https://lore.kernel.org/r/20230831053133.24015-3-pkshih@realtek.com
2023-09-07wifi: rtw89: mcc: initialize start flowZong-Zhe Yang1-0/+413
We prepare to support TDMA-based MCC (multi-channel concurrency) which allows two kinds of modes below. * P2P GO + normal STA * P2P GC + normal STA Each mode has two vif and two chanctx. Then, each vif binds one separate chanctx and becomes one MCC role. We name the two MCC roles as follows. * MCC role - reference (ref) We calculate the baseline of our TDMA things accodring to its info, e.g. TBTT. In normal case, it will be put at the first slot of TDMA. * MCC role - auxiliary (aux) MCC state machine will be running in FW eventually, but before that, we have to fill and calculate things that are needed by FW. We fill the information of MCC role according to its vif and its chanctx. Then, we calculate the start time for MCC. Note that the parameters used in the calculation now is assigned by default rules. The precise parameters for better MCC behavior will be derived in the following. Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Kalle Valo <kvalo@kernel.org> Link: https://lore.kernel.org/r/20230831053133.24015-2-pkshih@realtek.com
2023-08-25wifi: rtw89: initialize multi-channel handlingZong-Zhe Yang1-0/+124
We prepare to deal with multiple channels via new entity modes. * MCC_PREPARE: Transitional mode before MCC * MCC: Multi-Channel Concurrent mode And, enum of sub-entity is extended for second channel context. We add the entry flow of multi-channel handling and the core stuffs for extended index of sub-entity. And, we now deal with the filling of entity channels' info in entity recalc where we know the number of active chanctx. However, the other detail coding of MCC start/stop will be implemented in the following. Besides, chanctx listener struct is pre-added in chip info. Each component can add callback type in chanctx listener and configure its callback function to react according to chanctx states. We know at least RFK (RF calibration) and BTC (BT coexistence) will require such callbacks. Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Kalle Valo <kvalo@kernel.org> Link: https://lore.kernel.org/r/20230816082133.57474-7-pkshih@realtek.com
2023-04-14wifi: rtw89: add ieee80211::remain_on_channel opsPo-Hao Huang1-0/+35
Add support of remain on channel ops. Since channel context is required to enable multi-channel concurrent(MCC) and the current ROC in mac80211 don't support more than 1 channel context, add this to let P2P and other protocols relying on this work as expected. The off-channel duration and cancel timing is purely controlled by upper layers. Signed-off-by: Po-Hao Huang <phhuang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Kalle Valo <kvalo@kernel.org> Link: https://lore.kernel.org/r/20230411124832.14965-4-pkshih@realtek.com
2022-12-01wifi: rtw89: link rtw89_vif and chanctx stuffsZong-Zhe Yang1-4/+36
First, introduce struct rtw89_sub_entity for chanctx related stuffs. Second, add enum rtw89_sub_entity_idx to rtw89_vif for vif operation to access its/right chanctx stuffs after future multi-channel support. Besides, RTW89_SUB_ENTITY_0 is the default chanctx entry throughout driver, i.e. it's used for things which may not have a target chanctx yet. So, we need to ensure that RTW89_SUB_ENTITY_0 is always working. If there is at least one alive chanctx, then one of them must take RTW89_SUB_ENTITY_0. If no alive chanctx, RTW89_SUB_ENTITY_0 will be filled by rtw89_config_default_chandef(). Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Kalle Valo <kvalo@kernel.org> Link: https://lore.kernel.org/r/20221129083130.45708-7-pkshih@realtek.com
2022-09-02wifi: rtw89: declare support for mac80211 chanctx ops by chipZong-Zhe Yang1-1/+2
Some HW features are required if we hook chanctx ops to mac80211. With it, mac80211 would expect the HW-supported variant ops exists on some behavior, e.g. HW scan. But, HW features may depend on chip's FW or its development. Besides, how many chanctx can be supported also depends on chip design. We can neither decide whether to generally support chanctx ops nor how many chanctx can be supported. So, support_chanctx_num is added under chip info to deal with this by chip. For now, all chip configure support_chanctx_num as 0. We haven't really hook chanctx ops yet. So, chip can run without mac80211 chanctx as before. Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Kalle Valo <kvalo@kernel.org> Link: https://lore.kernel.org/r/20220809104952.61355-13-pkshih@realtek.com
2022-09-02wifi: rtw89: add skeleton of mac80211 chanctx ops supportZong-Zhe Yang1-0/+53
Support mac80211 chanctx series ops. Still, currently support single channel. Based on this premise, things should be similar to before. So, we haven't dealt with relationship between vif and chanctx in depth. Instead, we leave both ::assign_vif() and ::unassign_vif() as noops for now. Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Kalle Valo <kvalo@kernel.org> Link: https://lore.kernel.org/r/20220809104952.61355-12-pkshih@realtek.com
2022-09-02wifi: rtw89: introduce entity mode and its recalculated prototypeZong-Zhe Yang1-0/+25
After supporting more than one channel, we need entity mode to decide how to set current channel(s) on the sub-entities. This decision may happen on set_channel() and rtw89_core_set_chip_txpwr(). For now, we support single one channel and use only first HW entry, i.e. RTW89_SUB_ENTITY_0, RTW89_MAC_0, RTW89_PHY_0. Without something unexpected, the entity mode should always be RTW89_ENT_MODE_SCC after recalcated, where SCC means single channel concurrency. So, an assert is added in set_channel() and rtw89_core_set_chip_txpwr(). Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Kalle Valo <kvalo@kernel.org> Link: https://lore.kernel.org/r/20220809104952.61355-11-pkshih@realtek.com
2022-09-02wifi: rtw89: initialize entity and configure default chandefZong-Zhe Yang1-0/+16
While idle, we need a default chandef to set channel for things, such as scan. Before support of mac80211 chanctx, mac80211 would configure a default one on ieee80211_hw::conf::chandef. And we just queried it whenever we did set channel. However, after support of mac80211 chanctx, the flow won't work like before. Besides, we don't now query chandef from ieee80211_hw::conf::chandef either. So, similar to mac80211 without using chanctx, we configure the default chandef with ieee80211_channel of index 0 in 2GHz. Although we have not added the support of mac80211 chanctx here, this configuration should be compatible before that. So, we commit this ahead. Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Kalle Valo <kvalo@kernel.org> Link: https://lore.kernel.org/r/20220809104952.61355-10-pkshih@realtek.com
2022-09-02wifi: rtw89: concentrate chandef setting to stack callbackZong-Zhe Yang1-0/+20
Originally, we didn't support mac80211 chanctx, so it's expected that ieee80211_hw::conf::chandef would be filled by mac80211. And then, we could just query it whenever we need the current chandef. However, we are planing to support mac80211 chanctx. After that, the above assumption would be broken. So, we adjust a bit ahead to reduce future works about mac80211 chanctx. After this, we don't query ieee80211_hw::conf::chandef directly, and we add a map, entity_map, to HAL to indicate which chandef came from stack. And it will later be used to recalcate entity mode. Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Kalle Valo <kvalo@kernel.org> Link: https://lore.kernel.org/r/20220809104952.61355-9-pkshih@realtek.com
2022-09-02wifi: rtw89: create rtw89_chan centrally to avoid breakageZong-Zhe Yang1-0/+98
Sometimes we need to write current rtw89_chan outside set_channel(), e.g. during HW scan, we adjust it to align FW process through C2H. However, we don't have full parameters to fill entire rtw89_chan. And it will breakage if we update only part of current rtw89_chan. That is what we don't want to see because most flows throughout driver treat rtw89_chan as a whole. So, we divide struct rtw89_chan to basic part and derived part. The basic part contains the parameters which we are always able to know. And the derived part will be calculated by the basic part. Then, a central function, rtw89_chan_create(), is added to deal with this. Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Kalle Valo <kvalo@kernel.org> Link: https://lore.kernel.org/r/20220809104952.61355-5-pkshih@realtek.com
2022-09-02wifi: rtw89: re-arrange channel related stuffs under HALZong-Zhe Yang1-0/+22
We are planning to support mac80211 chanctx. To reduce future works, the driver architecture is adjusted first to isolate related things. According to chip, our HW may have multiple sub-entities to support multiple mac80211 chanctx. Struct rtw89_chan has been introduced for things about channel/band/subband/... Now introduce struct rtw89_chan_rcd to record difference after assigning new one of struct rtw89_chan. We will implement and support chanctx with single channel first, i.e. only use entry in RTW89_SUB_ENTITY_0, before handling dual channels. Our hierarchy in planning will become as the following. DEV -> HAL ---> entity (manage status across sub-entities) -----> sub-entity[*] (support mac80211 chanctx) where each sub-entity contains one struct rtw89_chan. Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Signed-off-by: Kalle Valo <kvalo@kernel.org> Link: https://lore.kernel.org/r/20220809104952.61355-4-pkshih@realtek.com