link_conf = &vif->bss_conf;
if (cmd == SET_KEY && !sta && !link->mt76.cipher) {
+ struct mt7996_phy *phy = mt7996_vif_link_phy(link);
+
link->mt76.cipher =
mt76_connac_mcu_get_cipher(key->cipher);
- mt7996_mcu_add_bss_info(link->phy, vif, link_conf,
- &link->mt76, msta_link, true);
+ if (phy)
+ mt7996_mcu_add_bss_info(phy, vif, link_conf,
+ &link->mt76, msta_link, true);
}
if (cmd == SET_KEY)
return -ENOSPC;
link->mld_idx = mld_idx;
- link->phy = phy;
mlink->omac_idx = idx;
mlink->band_idx = band_idx;
mlink->wmm_idx = vif->type == NL80211_IFTYPE_AP ? 0 : 3;
for_each_vif_active_link(vif, link_conf, link_id) {
struct mt7996_vif_link *link;
+ struct mt7996_phy *phy;
link = mt7996_vif_link(dev, vif, link_id);
if (!link)
continue;
- if (!link->phy)
+ phy = mt7996_vif_link_phy(link);
+ if (!phy)
continue;
- mt7996_mcu_add_bss_info(link->phy, vif, link_conf,
+ mt7996_mcu_add_bss_info(phy, vif, link_conf,
&link->mt76, &link->msta_link,
true);
mt7996_mcu_add_sta(dev, link_conf, NULL, link, NULL,
mutex_lock(&dev->mt76.mutex);
for_each_vif_active_link(vif, link_conf, link_id) {
- struct mt7996_vif_link *link =
- mt7996_vif_link(dev, vif, link_id);
+ struct mt7996_vif_link *link;
+ struct mt7996_phy *link_phy;
+
+ link = mt7996_vif_link(dev, vif, link_id);
+ if (!link)
+ continue;
- if (!link || link->phy != phy)
+ link_phy = mt7996_vif_link_phy(link);
+ if (link_phy != phy)
continue;
/* Reset beacon when channel switch triggered during CAC to let
{
struct ieee80211_sta *sta = link_sta->sta;
struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
- struct mt7996_phy *phy = link->phy;
+ struct mt7996_phy *phy = mt7996_vif_link_phy(link);
struct mt7996_sta_link *msta_link;
int idx;
+ if (!phy)
+ return -EINVAL;
+
idx = mt76_wcid_alloc(dev->mt76.wcid_mask, MT7996_WTBL_STA);
if (idx < 0)
return -ENOSPC;
u64 __mt7996_get_tsf(struct ieee80211_hw *hw, struct mt7996_vif_link *link)
{
+ struct mt7996_phy *phy = mt7996_vif_link_phy(link);
struct mt7996_dev *dev = mt7996_hw_dev(hw);
- struct mt7996_phy *phy = link->phy;
union {
u64 t64;
u32 t32[2];
n = link->mt76.omac_idx > HW_BSSID_MAX ? HW_BSSID_0
: link->mt76.omac_idx;
- phy = link->phy;
+ phy = mt7996_vif_link_phy(link);
if (!phy)
goto unlock;
if (!link)
goto unlock;
- phy = link->phy;
+ phy = mt7996_vif_link_phy(link);
if (!phy)
goto unlock;
struct mt7996_sta_link *msta_link)
{
struct mt7996_sta *msta = msta_link->sta;
- struct mt7996_dev *dev = msta->vif->deflink.phy->dev;
+ struct mt7996_phy *phy = mt7996_vif_link_phy(&msta->vif->deflink);
+ struct mt7996_dev *dev;
u32 *changed = data;
+ if (!phy)
+ return;
+
+ dev = phy->dev;
spin_lock_bh(&dev->mt76.sta_poll_lock);
msta_link->changed |= *changed;
struct mt7996_vif_link *link,
__le16 *he_mcs, u16 mcs_map)
{
+ struct mt76_phy *mphy = mt76_vif_link_phy(&link->mt76);
int nss, max_nss = link_sta->rx_nss > 3 ? 4 : link_sta->rx_nss;
- enum nl80211_band band = link->phy->mt76->chandef.chan->band;
- const u16 *mask = link->bitrate_mask.control[band].he_mcs;
+ enum nl80211_band band;
+ const u16 *mask;
+
+ if (!mphy)
+ return;
+
+ band = mphy->chandef.chan->band;
+ mask = link->bitrate_mask.control[band].he_mcs;
for (nss = 0; nss < max_nss; nss++) {
int mcs;
#define EBF_MODE BIT(0)
#define IBF_MODE BIT(1)
#define BF_MAT_ORDER 4
+ struct mt7996_phy *phy = mt7996_vif_link_phy(link);
struct ieee80211_vif *vif = link_conf->vif;
- struct mt7996_phy *phy = link->phy;
- int tx_ant = hweight16(phy->mt76->chainmask) - 1;
struct sta_rec_bf *bf;
struct tlv *tlv;
static const u8 matrix[BF_MAT_ORDER][BF_MAT_ORDER] = {
{2, 4, 4, 0}, /* 3x1, 3x2, 3x3, 3x4 */
{3, 5, 6, 0} /* 4x1, 4x2, 4x3, 4x4 */
};
+ int tx_ant;
bool ebf;
+ if (!phy)
+ return;
+
if (!(link_sta->ht_cap.ht_supported || link_sta->he_cap.has_he))
return;
* ht: iBF only, since mac80211 lacks of eBF support
*/
if (link_sta->eht_cap.has_eht)
- mt7996_mcu_sta_bfer_eht(link_sta, vif, link->phy, bf, ebf);
+ mt7996_mcu_sta_bfer_eht(link_sta, vif, phy, bf, ebf);
else if (link_sta->he_cap.has_he)
- mt7996_mcu_sta_bfer_he(link_sta, vif, link->phy, bf, ebf);
+ mt7996_mcu_sta_bfer_he(link_sta, vif, phy, bf, ebf);
else if (link_sta->vht_cap.vht_supported)
- mt7996_mcu_sta_bfer_vht(link_sta, link->phy, bf, ebf);
+ mt7996_mcu_sta_bfer_vht(link_sta, phy, bf, ebf);
else if (link_sta->ht_cap.ht_supported)
- mt7996_mcu_sta_bfer_ht(link_sta, link->phy, bf, ebf);
+ mt7996_mcu_sta_bfer_ht(link_sta, phy, bf, ebf);
else
return;
bf->bf_cap = ebf ? EBF_MODE : (dev->ibf ? IBF_MODE : 0);
+ tx_ant = hweight16(phy->mt76->chainmask) - 1;
if (is_mt7992(&dev->mt76) && tx_ant == 4)
bf->bf_cap |= IBF_MODE;
struct ieee80211_link_sta *link_sta,
struct mt7996_vif_link *link)
{
- struct mt7996_phy *phy = link->phy;
- int tx_ant = hweight8(phy->mt76->antenna_mask) - 1;
+ struct mt7996_phy *phy = mt7996_vif_link_phy(link);
struct sta_rec_bfee *bfee;
struct tlv *tlv;
u8 nrow = 0;
+ int tx_ant;
+
+ if (!phy)
+ return;
if (!(link_sta->vht_cap.vht_supported || link_sta->he_cap.has_he))
return;
}
/* reply with identity matrix to avoid 2x2 BF negative gain */
+ tx_ant = hweight8(phy->mt76->antenna_mask) - 1;
bfee->fb_identity_matrix = (nrow == 1 && tx_ant == 2);
}
struct ieee80211_sta *sta;
int ret, nrates = 0, idx;
enum nl80211_band band;
+ struct mt76_phy *mphy;
bool has_he;
#define __sta_phy_bitrate_mask_check(_mcs, _gi, _ht, _he) \
if (!link_sta)
goto error_unlock;
- band = link->phy->mt76->chandef.chan->band;
+ mphy = mt76_vif_link_phy(&link->mt76);
+ if (!mphy)
+ goto error_unlock;
+
+ band = mphy->chandef.chan->band;
has_he = link_sta->he_cap.has_he;
mask = link->bitrate_mask;
idx = msta_link->wcid.idx;
struct mt7996_vif_link *link)
{
#define INIT_RCPI 180
- struct mt76_phy *mphy = link->phy->mt76;
- struct cfg80211_chan_def *chandef = &mphy->chandef;
+ struct mt76_phy *mphy = mt76_vif_link_phy(&link->mt76);
struct cfg80211_bitrate_mask *mask = &link->bitrate_mask;
u32 cap = link_sta->sta->wme ? STA_CAP_WMM : 0;
- enum nl80211_band band = chandef->chan->band;
+ struct cfg80211_chan_def *chandef;
struct sta_rec_ra_uni *ra;
+ enum nl80211_band band;
struct tlv *tlv;
- u32 supp_rate = link_sta->supp_rates[band];
+ u32 supp_rate;
+
+ if (!mphy)
+ return;
tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_RA, sizeof(*ra));
ra = (struct sta_rec_ra_uni *)tlv;
+ chandef = &mphy->chandef;
+ band = chandef->chan->band;
+ supp_rate = link_sta->supp_rates[band];
+
ra->valid = true;
ra->auto_rate = true;
ra->phy_mode = mt76_connac_get_phy_mode(mphy, vif, band, link_sta);
{
struct mt7996_vif_link *link = (struct mt7996_vif_link *)data;
struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
+ struct mt7996_phy *phy = mt7996_vif_link_phy(link);
struct mt7996_sta_link *msta_link;
struct mt7996_dev *dev;
struct ieee80211_bss_conf *link_conf;
struct sk_buff *skb;
int link_id;
+ if (!phy)
+ return;
+
if (link->mt76.mvif != &msta->vif->mt76)
return;
- dev = link->phy->dev;
+ dev = phy->dev;
link_id = link->msta_link.wcid.link_id;
link_sta = link_sta_dereference_protected(sta, link_id);
if (!link_sta)
{
struct mt7996_dev *dev = mt7996_hw_dev(hw);
struct mt7996_vif_link *link = mt7996_vif_conf_link(dev, vif, link_conf);
+ struct mt76_phy *mphy = link ? mt76_vif_link_phy(&link->mt76) : NULL;
struct mt76_vif_link *mlink = link ? &link->mt76 : NULL;
struct ieee80211_mutable_offsets offs;
struct ieee80211_tx_info *info;
if (!mlink)
return -EINVAL;
- if (link->phy && link->phy->mt76->offchannel)
+ if (mphy && mphy->offchannel)
enabled = false;
rskb = __mt7996_mcu_alloc_bss_req(&dev->mt76, mlink,
{
#define OFFLOAD_TX_MODE_SU BIT(0)
#define OFFLOAD_TX_MODE_MU BIT(1)
+ struct mt76_phy *mphy = mt76_vif_link_phy(&link->mt76);
struct ieee80211_vif *vif = link_conf->vif;
struct ieee80211_hw *hw = mt76_hw(dev);
- struct mt7996_phy *phy = link->phy;
struct mt76_wcid *wcid = &dev->mt76.global_wcid;
struct bss_inband_discovery_tlv *discov;
struct ieee80211_tx_info *info;
u8 *buf, interval;
int len;
- if (!phy)
+ if (!mphy)
return -EINVAL;
- chandef = &phy->mt76->chandef;
+ chandef = &mphy->chandef;
band = chandef->chan->band;
if (link_conf->nontransmitted)
info = IEEE80211_SKB_CB(skb);
info->control.vif = vif;
info->band = band;
- info->hw_queue |= FIELD_PREP(MT_TX_HW_QUEUE_PHY, phy->mt76->band_idx);
+ info->hw_queue |= FIELD_PREP(MT_TX_HW_QUEUE_PHY, mphy->band_idx);
len = ALIGN(sizeof(*discov) + MT_TXD_SIZE + skb->len, 4);
tlv = mt7996_mcu_add_uni_tlv(rskb, UNI_BSS_INFO_OFFLOAD, len);