diff --git a/mt7603.h b/mt7603.h index 9b77adb4..be80892b 100644 --- a/mt7603.h +++ b/mt7603.h @@ -45,6 +45,9 @@ #define MT7603_WATCHDOG_TIME 100 /* ms */ #define MT7603_WATCHDOG_TIMEOUT 10 /* number of checks */ +struct mt7603_vif; +struct mt7603_sta; + enum { MT7603_REV_E1 = 0x00, MT7603_REV_E2 = 0x10, @@ -69,12 +72,6 @@ struct mt7603_mcu { bool running; }; -struct mt7603_vif { - u8 idx; - - struct mt76_wcid wcid; -}; - struct mt7603_sta { struct mt76_wcid wcid; /* must be first */ @@ -91,6 +88,12 @@ struct mt7603_sta { int ampdu_acked; }; +struct mt7603_vif { + u8 idx; + + struct mt7603_sta sta; +}; + #define MT7603_CB_DMA_DONE BIT(0) #define MT7603_CB_TXS_DONE BIT(1) #define MT7603_CB_TXS_FAILED BIT(2) diff --git a/mt7603_beacon.c b/mt7603_beacon.c index 59474cf8..01962d40 100644 --- a/mt7603_beacon.c +++ b/mt7603_beacon.c @@ -38,7 +38,7 @@ mt7603_update_beacon_iter(void *priv, u8 *mac, struct ieee80211_vif *vif) return; mt76_tx_queue_skb(&dev->mt76, &dev->mt76.q_tx[MT_TXQ_BEACON], skb, - &mvif->wcid, NULL); + &mvif->sta.wcid, NULL); } static void @@ -123,7 +123,7 @@ void mt7603_pre_tbtt_tasklet(unsigned long arg) struct ieee80211_vif *vif = info->control.vif; struct mt7603_vif *mvif = (struct mt7603_vif *) vif->drv_priv; - mt76_tx_queue_skb(&dev->mt76, q, skb, &mvif->wcid, NULL); + mt76_tx_queue_skb(&dev->mt76, q, skb, &mvif->sta.wcid, NULL); } mt76_queue_kick(dev, q); spin_unlock_bh(&q->lock); diff --git a/mt7603_mac.c b/mt7603_mac.c index 4621d734..7f5cc90d 100644 --- a/mt7603_mac.c +++ b/mt7603_mac.c @@ -370,7 +370,7 @@ mt7603_rx_get_wcid(struct mt7603_dev *dev, u8 idx, bool unicast) if (!sta->vif) return NULL; - return &sta->vif->wcid; + return &sta->vif->sta.wcid; } static void @@ -1095,7 +1095,6 @@ void mt7603_mac_add_txs(struct mt7603_dev *dev, void *data) struct mt7603_sta *msta = NULL; struct mt76_wcid *wcid; __le32 *txs_data = data; - void *priv; u32 txs; u8 wcidx; u8 pid; @@ -1117,14 +1116,14 @@ void mt7603_mac_add_txs(struct mt7603_dev *dev, void *data) if (!wcid) goto out; - priv = msta = container_of(wcid, struct mt7603_sta, wcid); - sta = container_of(priv, struct ieee80211_sta, drv_priv); + msta = container_of(wcid, struct mt7603_sta, wcid); + sta = wcid_to_sta(wcid); pid &= MT_PID_INDEX; if (mt7603_mac_add_txs_skb(dev, msta, pid, txs_data)) goto out; - if (wcidx >= MT7603_WTBL_STA) + if (wcidx >= MT7603_WTBL_STA || !sta) goto out; if (mt7603_fill_txs(dev, msta, &info, txs_data)) diff --git a/mt7603_main.c b/mt7603_main.c index fe43c85f..6f6b6b74 100644 --- a/mt7603_main.c +++ b/mt7603_main.c @@ -58,7 +58,7 @@ mt7603_txq_init(struct mt7603_dev *dev, struct ieee80211_txq *txq) mtxq->wcid = &sta->wcid; } else { struct mt7603_vif *mvif = (struct mt7603_vif *) txq->vif->drv_priv; - mtxq->wcid = &mvif->wcid; + mtxq->wcid = &mvif->sta.wcid; } mt76_txq_init(&dev->mt76, txq); @@ -89,14 +89,14 @@ mt7603_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) idx = MT7603_WTBL_RESERVED - 1 - mvif->idx; dev->vif_mask |= BIT(mvif->idx); - mvif->wcid.idx = idx; - mvif->wcid.hw_key_idx = -1; + mvif->sta.wcid.idx = idx; + mvif->sta.wcid.hw_key_idx = -1; eth_broadcast_addr(bc_addr); mt7603_wtbl_init(dev, idx, mvif->idx, bc_addr); mt7603_wtbl_set_ps(dev, idx, false); - rcu_assign_pointer(dev->wcid[idx], &mvif->wcid); + rcu_assign_pointer(dev->wcid[idx], &mvif->sta.wcid); mt7603_txq_init(dev, vif->txq); out: @@ -110,7 +110,7 @@ mt7603_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { struct mt7603_vif *mvif = (struct mt7603_vif *) vif->drv_priv; struct mt7603_dev *dev = hw->priv; - int idx = mvif->wcid.idx; + int idx = mvif->sta.wcid.idx; mt7603_beacon_set_timer(dev, mvif->idx, 0); @@ -339,8 +339,9 @@ mt7603_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, { struct mt7603_dev *dev = hw->priv; struct mt7603_vif *mvif = (struct mt7603_vif *) vif->drv_priv; - struct mt7603_sta *msta = sta ? (struct mt7603_sta *) sta->drv_priv : NULL; - struct mt76_wcid *wcid = msta ? &msta->wcid : &mvif->wcid; + struct mt7603_sta *msta = sta ? (struct mt7603_sta *) sta->drv_priv : + &mvif->sta; + struct mt76_wcid *wcid = &msta->wcid; int idx = key->keyidx; /* fall back to sw encryption for unsupported ciphers */