mt76: pratially unify add_interface
Create common mt76x02_vif_init function and use int on drivers add_interface callback. Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
parent
624400e4cd
commit
cab12953ec
@ -56,7 +56,6 @@ static int mt76x0_add_interface(struct ieee80211_hw *hw,
|
|||||||
struct ieee80211_vif *vif)
|
struct ieee80211_vif *vif)
|
||||||
{
|
{
|
||||||
struct mt76x0_dev *dev = hw->priv;
|
struct mt76x0_dev *dev = hw->priv;
|
||||||
struct mt76x02_vif *mvif = (struct mt76x02_vif *) vif->drv_priv;
|
|
||||||
unsigned int idx;
|
unsigned int idx;
|
||||||
|
|
||||||
idx = ffs(~dev->vif_mask);
|
idx = ffs(~dev->vif_mask);
|
||||||
@ -66,11 +65,7 @@ static int mt76x0_add_interface(struct ieee80211_hw *hw,
|
|||||||
idx--;
|
idx--;
|
||||||
dev->vif_mask |= BIT(idx);
|
dev->vif_mask |= BIT(idx);
|
||||||
|
|
||||||
mvif->idx = idx;
|
mt76x02_vif_init(&dev->mt76, vif, idx);
|
||||||
mvif->group_wcid.idx = GROUP_WCID(idx);
|
|
||||||
mvif->group_wcid.hw_key_idx = -1;
|
|
||||||
mt76x02_txq_init(&dev->mt76, vif->txq);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,15 +89,6 @@ struct mt76x0_tx_queue {
|
|||||||
unsigned int fifo_seq;
|
unsigned int fifo_seq;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* WCID allocation:
|
|
||||||
* 0: mcast wcid
|
|
||||||
* 1: bssid wcid
|
|
||||||
* 1...: STAs
|
|
||||||
* ...7e: group wcids
|
|
||||||
* 7f: reserved
|
|
||||||
*/
|
|
||||||
#define GROUP_WCID(idx) (254 - idx)
|
|
||||||
|
|
||||||
struct mt76x0_eeprom_params;
|
struct mt76x0_eeprom_params;
|
||||||
|
|
||||||
#define MT_EE_TEMPERATURE_SLOPE 39
|
#define MT_EE_TEMPERATURE_SLOPE 39
|
||||||
|
@ -31,6 +31,9 @@ struct mt76x02_tx_status {
|
|||||||
u16 rate;
|
u16 rate;
|
||||||
} __packed __aligned(2);
|
} __packed __aligned(2);
|
||||||
|
|
||||||
|
#define MT_VIF_WCID(_n) (254 - ((_n) & 7))
|
||||||
|
#define MT_MAX_VIFS 8
|
||||||
|
|
||||||
struct mt76x02_vif {
|
struct mt76x02_vif {
|
||||||
u8 idx;
|
u8 idx;
|
||||||
|
|
||||||
|
@ -115,4 +115,16 @@ int mt76x02_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(mt76x02_sta_remove);
|
EXPORT_SYMBOL_GPL(mt76x02_sta_remove);
|
||||||
|
|
||||||
|
void mt76x02_vif_init(struct mt76_dev *dev, struct ieee80211_vif *vif,
|
||||||
|
unsigned int idx)
|
||||||
|
{
|
||||||
|
struct mt76x02_vif *mvif = (struct mt76x02_vif *) vif->drv_priv;
|
||||||
|
|
||||||
|
mvif->idx = idx;
|
||||||
|
mvif->group_wcid.idx = MT_VIF_WCID(idx);
|
||||||
|
mvif->group_wcid.hw_key_idx = -1;
|
||||||
|
mt76x02_txq_init(dev, vif->txq);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(mt76x02_vif_init);
|
||||||
|
|
||||||
MODULE_LICENSE("Dual BSD/GPL");
|
MODULE_LICENSE("Dual BSD/GPL");
|
||||||
|
@ -25,4 +25,7 @@ int mt76x02_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
|||||||
struct ieee80211_sta *sta);
|
struct ieee80211_sta *sta);
|
||||||
int mt76x02_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
int mt76x02_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
||||||
struct ieee80211_sta *sta);
|
struct ieee80211_sta *sta);
|
||||||
|
|
||||||
|
void mt76x02_vif_init(struct mt76_dev *dev, struct ieee80211_vif *vif,
|
||||||
|
unsigned int idx);
|
||||||
#endif
|
#endif
|
||||||
|
@ -42,9 +42,6 @@
|
|||||||
|
|
||||||
#define MT_CALIBRATE_INTERVAL HZ
|
#define MT_CALIBRATE_INTERVAL HZ
|
||||||
|
|
||||||
#define MT_MAX_VIFS 8
|
|
||||||
#define MT_VIF_WCID(_n) (254 - ((_n) & 7))
|
|
||||||
|
|
||||||
#include "mt76.h"
|
#include "mt76.h"
|
||||||
#include "mt76x02_regs.h"
|
#include "mt76x02_regs.h"
|
||||||
#include "mt76x2_mac.h"
|
#include "mt76x2_mac.h"
|
||||||
|
@ -58,7 +58,6 @@ static int
|
|||||||
mt76x2_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
|
mt76x2_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
|
||||||
{
|
{
|
||||||
struct mt76x2_dev *dev = hw->priv;
|
struct mt76x2_dev *dev = hw->priv;
|
||||||
struct mt76x02_vif *mvif = (struct mt76x02_vif *) vif->drv_priv;
|
|
||||||
unsigned int idx = 0;
|
unsigned int idx = 0;
|
||||||
|
|
||||||
if (vif->addr[0] & BIT(1))
|
if (vif->addr[0] & BIT(1))
|
||||||
@ -80,11 +79,7 @@ mt76x2_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
|
|||||||
if (vif->type == NL80211_IFTYPE_STATION)
|
if (vif->type == NL80211_IFTYPE_STATION)
|
||||||
idx += 8;
|
idx += 8;
|
||||||
|
|
||||||
mvif->idx = idx;
|
mt76x02_vif_init(&dev->mt76, vif, idx);
|
||||||
mvif->group_wcid.idx = MT_VIF_WCID(idx);
|
|
||||||
mvif->group_wcid.hw_key_idx = -1;
|
|
||||||
mt76x02_txq_init(&dev->mt76, vif->txq);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,17 +49,11 @@ static int mt76x2u_add_interface(struct ieee80211_hw *hw,
|
|||||||
struct ieee80211_vif *vif)
|
struct ieee80211_vif *vif)
|
||||||
{
|
{
|
||||||
struct mt76x2_dev *dev = hw->priv;
|
struct mt76x2_dev *dev = hw->priv;
|
||||||
struct mt76x02_vif *mvif = (struct mt76x02_vif *)vif->drv_priv;
|
|
||||||
unsigned int idx = 0;
|
|
||||||
|
|
||||||
if (!ether_addr_equal(dev->mt76.macaddr, vif->addr))
|
if (!ether_addr_equal(dev->mt76.macaddr, vif->addr))
|
||||||
mt76x2u_mac_setaddr(dev, vif->addr);
|
mt76x2u_mac_setaddr(dev, vif->addr);
|
||||||
|
|
||||||
mvif->idx = idx;
|
mt76x02_vif_init(&dev->mt76, vif, 0);
|
||||||
mvif->group_wcid.idx = MT_VIF_WCID(idx);
|
|
||||||
mvif->group_wcid.hw_key_idx = -1;
|
|
||||||
mt76x02_txq_init(&dev->mt76, vif->txq);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user