mt76: create new mt76x02-lib module for common mt76x{0,2} code
Move rxfilter and mutex to common structure. Create mt76x02-lib.ko for mt76x0 and mt76x2 common functions and create new unified mt76x02_configure_filter() function there. Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
This commit is contained in:
parent
797ea24078
commit
108a4861ef
@ -5,8 +5,13 @@ config MT76_USB
|
|||||||
tristate
|
tristate
|
||||||
depends on MT76_CORE
|
depends on MT76_CORE
|
||||||
|
|
||||||
|
config MT76x02_LIB
|
||||||
|
tristate
|
||||||
|
depends on MT76_CORE
|
||||||
|
|
||||||
config MT76x2_COMMON
|
config MT76x2_COMMON
|
||||||
tristate
|
tristate
|
||||||
|
select MT76x02_LIB
|
||||||
depends on MT76_CORE
|
depends on MT76_CORE
|
||||||
|
|
||||||
config MT76x0U
|
config MT76x0U
|
||||||
@ -14,6 +19,7 @@ config MT76x0U
|
|||||||
select MT76_CORE
|
select MT76_CORE
|
||||||
depends on MAC80211
|
depends on MAC80211
|
||||||
depends on USB
|
depends on USB
|
||||||
|
select MT76x02_LIB
|
||||||
help
|
help
|
||||||
This adds support for MT7610U-based wireless USB dongles.
|
This adds support for MT7610U-based wireless USB dongles.
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
obj-$(CONFIG_MT76_CORE) += mt76.o
|
obj-$(CONFIG_MT76_CORE) += mt76.o
|
||||||
obj-$(CONFIG_MT76_USB) += mt76-usb.o
|
obj-$(CONFIG_MT76_USB) += mt76-usb.o
|
||||||
obj-$(CONFIG_MT76x0U) += mt76x0/
|
obj-$(CONFIG_MT76x0U) += mt76x0/
|
||||||
|
obj-$(CONFIG_MT76x02_LIB) += mt76x02-lib.o
|
||||||
obj-$(CONFIG_MT76x2_COMMON) += mt76x2-common.o
|
obj-$(CONFIG_MT76x2_COMMON) += mt76x2-common.o
|
||||||
obj-$(CONFIG_MT76x2E) += mt76x2e.o
|
obj-$(CONFIG_MT76x2E) += mt76x2e.o
|
||||||
obj-$(CONFIG_MT76x2U) += mt76x2u.o
|
obj-$(CONFIG_MT76x2U) += mt76x2u.o
|
||||||
@ -13,6 +14,8 @@ mt76-usb-y := usb.o usb_trace.o usb_mcu.o
|
|||||||
CFLAGS_trace.o := -I$(src)
|
CFLAGS_trace.o := -I$(src)
|
||||||
CFLAGS_usb_trace.o := -I$(src)
|
CFLAGS_usb_trace.o := -I$(src)
|
||||||
|
|
||||||
|
mt76x02-lib-y := mt76x02_util.o
|
||||||
|
|
||||||
mt76x2-common-y := \
|
mt76x2-common-y := \
|
||||||
mt76x2_eeprom.o mt76x2_tx_common.o mt76x2_mac_common.o \
|
mt76x2_eeprom.o mt76x2_tx_common.o mt76x2_mac_common.o \
|
||||||
mt76x2_init_common.o mt76x2_common.o mt76x2_phy_common.o \
|
mt76x2_init_common.o mt76x2_common.o mt76x2_phy_common.o \
|
||||||
|
@ -283,6 +283,7 @@ mt76_alloc_device(unsigned int size, const struct ieee80211_ops *ops)
|
|||||||
spin_lock_init(&dev->rx_lock);
|
spin_lock_init(&dev->rx_lock);
|
||||||
spin_lock_init(&dev->lock);
|
spin_lock_init(&dev->lock);
|
||||||
spin_lock_init(&dev->cc_lock);
|
spin_lock_init(&dev->cc_lock);
|
||||||
|
mutex_init(&dev->mutex);
|
||||||
init_waitqueue_head(&dev->tx_wait);
|
init_waitqueue_head(&dev->tx_wait);
|
||||||
|
|
||||||
return dev;
|
return dev;
|
||||||
|
@ -317,6 +317,9 @@ struct mt76_dev {
|
|||||||
|
|
||||||
spinlock_t lock;
|
spinlock_t lock;
|
||||||
spinlock_t cc_lock;
|
spinlock_t cc_lock;
|
||||||
|
|
||||||
|
struct mutex mutex;
|
||||||
|
|
||||||
const struct mt76_bus_ops *bus;
|
const struct mt76_bus_ops *bus;
|
||||||
const struct mt76_driver_ops *drv;
|
const struct mt76_driver_ops *drv;
|
||||||
void __iomem *regs;
|
void __iomem *regs;
|
||||||
@ -353,6 +356,8 @@ struct mt76_dev {
|
|||||||
bool led_al;
|
bool led_al;
|
||||||
u8 led_pin;
|
u8 led_pin;
|
||||||
|
|
||||||
|
u32 rxfilter;
|
||||||
|
|
||||||
struct mt76_usb usb;
|
struct mt76_usb usb;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -290,14 +290,14 @@ int mt76x0_mac_start(struct mt76x0_dev *dev)
|
|||||||
MT_WPDMA_GLO_CFG_RX_DMA_BUSY, 0, 200000))
|
MT_WPDMA_GLO_CFG_RX_DMA_BUSY, 0, 200000))
|
||||||
return -ETIMEDOUT;
|
return -ETIMEDOUT;
|
||||||
|
|
||||||
dev->rxfilter = MT_RX_FILTR_CFG_CRC_ERR |
|
dev->mt76.rxfilter = MT_RX_FILTR_CFG_CRC_ERR |
|
||||||
MT_RX_FILTR_CFG_PHY_ERR | MT_RX_FILTR_CFG_PROMISC |
|
MT_RX_FILTR_CFG_PHY_ERR | MT_RX_FILTR_CFG_PROMISC |
|
||||||
MT_RX_FILTR_CFG_VER_ERR | MT_RX_FILTR_CFG_DUP |
|
MT_RX_FILTR_CFG_VER_ERR | MT_RX_FILTR_CFG_DUP |
|
||||||
MT_RX_FILTR_CFG_CFACK | MT_RX_FILTR_CFG_CFEND |
|
MT_RX_FILTR_CFG_CFACK | MT_RX_FILTR_CFG_CFEND |
|
||||||
MT_RX_FILTR_CFG_ACK | MT_RX_FILTR_CFG_CTS |
|
MT_RX_FILTR_CFG_ACK | MT_RX_FILTR_CFG_CTS |
|
||||||
MT_RX_FILTR_CFG_RTS | MT_RX_FILTR_CFG_PSPOLL |
|
MT_RX_FILTR_CFG_RTS | MT_RX_FILTR_CFG_PSPOLL |
|
||||||
MT_RX_FILTR_CFG_BA | MT_RX_FILTR_CFG_CTRL_RSV;
|
MT_RX_FILTR_CFG_BA | MT_RX_FILTR_CFG_CTRL_RSV;
|
||||||
mt76_wr(dev, MT_RX_FILTR_CFG, dev->rxfilter);
|
mt76_wr(dev, MT_RX_FILTR_CFG, dev->mt76.rxfilter);
|
||||||
|
|
||||||
mt76_wr(dev, MT_MAC_SYS_CTRL,
|
mt76_wr(dev, MT_MAC_SYS_CTRL,
|
||||||
MT_MAC_SYS_CTRL_ENABLE_TX | MT_MAC_SYS_CTRL_ENABLE_RX);
|
MT_MAC_SYS_CTRL_ENABLE_TX | MT_MAC_SYS_CTRL_ENABLE_RX);
|
||||||
@ -495,7 +495,7 @@ struct mt76x0_dev *mt76x0_alloc_device(struct device *pdev)
|
|||||||
mutex_init(&dev->usb_ctrl_mtx);
|
mutex_init(&dev->usb_ctrl_mtx);
|
||||||
mutex_init(&dev->reg_atomic_mutex);
|
mutex_init(&dev->reg_atomic_mutex);
|
||||||
mutex_init(&dev->hw_atomic_mutex);
|
mutex_init(&dev->hw_atomic_mutex);
|
||||||
mutex_init(&dev->mutex);
|
mutex_init(&dev->mt76.mutex);
|
||||||
spin_lock_init(&dev->tx_lock);
|
spin_lock_init(&dev->tx_lock);
|
||||||
spin_lock_init(&dev->rx_lock);
|
spin_lock_init(&dev->rx_lock);
|
||||||
spin_lock_init(&dev->mt76.lock);
|
spin_lock_init(&dev->mt76.lock);
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
#include "mt76x0.h"
|
#include "mt76x0.h"
|
||||||
#include "mac.h"
|
#include "mac.h"
|
||||||
|
#include "../mt76x02_util.h"
|
||||||
#include <linux/etherdevice.h>
|
#include <linux/etherdevice.h>
|
||||||
|
|
||||||
static int mt76x0_start(struct ieee80211_hw *hw)
|
static int mt76x0_start(struct ieee80211_hw *hw)
|
||||||
@ -22,7 +23,7 @@ static int mt76x0_start(struct ieee80211_hw *hw)
|
|||||||
struct mt76x0_dev *dev = hw->priv;
|
struct mt76x0_dev *dev = hw->priv;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
mutex_lock(&dev->mutex);
|
mutex_lock(&dev->mt76.mutex);
|
||||||
|
|
||||||
ret = mt76x0_mac_start(dev);
|
ret = mt76x0_mac_start(dev);
|
||||||
if (ret)
|
if (ret)
|
||||||
@ -33,7 +34,7 @@ static int mt76x0_start(struct ieee80211_hw *hw)
|
|||||||
ieee80211_queue_delayed_work(dev->mt76.hw, &dev->cal_work,
|
ieee80211_queue_delayed_work(dev->mt76.hw, &dev->cal_work,
|
||||||
MT_CALIBRATE_INTERVAL);
|
MT_CALIBRATE_INTERVAL);
|
||||||
out:
|
out:
|
||||||
mutex_unlock(&dev->mutex);
|
mutex_unlock(&dev->mt76.mutex);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,13 +42,13 @@ static void mt76x0_stop(struct ieee80211_hw *hw)
|
|||||||
{
|
{
|
||||||
struct mt76x0_dev *dev = hw->priv;
|
struct mt76x0_dev *dev = hw->priv;
|
||||||
|
|
||||||
mutex_lock(&dev->mutex);
|
mutex_lock(&dev->mt76.mutex);
|
||||||
|
|
||||||
cancel_delayed_work_sync(&dev->cal_work);
|
cancel_delayed_work_sync(&dev->cal_work);
|
||||||
cancel_delayed_work_sync(&dev->mac_work);
|
cancel_delayed_work_sync(&dev->mac_work);
|
||||||
mt76x0_mac_stop(dev);
|
mt76x0_mac_stop(dev);
|
||||||
|
|
||||||
mutex_unlock(&dev->mutex);
|
mutex_unlock(&dev->mt76.mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -87,16 +88,7 @@ static int mt76x0_config(struct ieee80211_hw *hw, u32 changed)
|
|||||||
struct mt76x0_dev *dev = hw->priv;
|
struct mt76x0_dev *dev = hw->priv;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
mutex_lock(&dev->mutex);
|
mutex_lock(&dev->mt76.mutex);
|
||||||
|
|
||||||
if (changed & IEEE80211_CONF_CHANGE_MONITOR) {
|
|
||||||
if (!(hw->conf.flags & IEEE80211_CONF_MONITOR))
|
|
||||||
dev->rxfilter |= MT_RX_FILTR_CFG_PROMISC;
|
|
||||||
else
|
|
||||||
dev->rxfilter &= ~MT_RX_FILTR_CFG_PROMISC;
|
|
||||||
|
|
||||||
mt76_wr(dev, MT_RX_FILTR_CFG, dev->rxfilter);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
|
if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
|
||||||
ieee80211_stop_queues(hw);
|
ieee80211_stop_queues(hw);
|
||||||
@ -104,51 +96,18 @@ static int mt76x0_config(struct ieee80211_hw *hw, u32 changed)
|
|||||||
ieee80211_wake_queues(hw);
|
ieee80211_wake_queues(hw);
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_unlock(&dev->mutex);
|
mutex_unlock(&dev->mt76.mutex);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
mt76_configure_filter(struct ieee80211_hw *hw, unsigned int changed_flags,
|
|
||||||
unsigned int *total_flags, u64 multicast)
|
|
||||||
{
|
|
||||||
struct mt76x0_dev *dev = hw->priv;
|
|
||||||
u32 flags = 0;
|
|
||||||
|
|
||||||
#define MT76_FILTER(_flag, _hw) do { \
|
|
||||||
flags |= *total_flags & FIF_##_flag; \
|
|
||||||
dev->rxfilter &= ~(_hw); \
|
|
||||||
dev->rxfilter |= !(flags & FIF_##_flag) * (_hw); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
mutex_lock(&dev->mutex);
|
|
||||||
|
|
||||||
dev->rxfilter &= ~MT_RX_FILTR_CFG_OTHER_BSS;
|
|
||||||
|
|
||||||
MT76_FILTER(FCSFAIL, MT_RX_FILTR_CFG_CRC_ERR);
|
|
||||||
MT76_FILTER(PLCPFAIL, MT_RX_FILTR_CFG_PHY_ERR);
|
|
||||||
MT76_FILTER(CONTROL, MT_RX_FILTR_CFG_ACK |
|
|
||||||
MT_RX_FILTR_CFG_CTS |
|
|
||||||
MT_RX_FILTR_CFG_CFEND |
|
|
||||||
MT_RX_FILTR_CFG_CFACK |
|
|
||||||
MT_RX_FILTR_CFG_BA |
|
|
||||||
MT_RX_FILTR_CFG_CTRL_RSV);
|
|
||||||
MT76_FILTER(PSPOLL, MT_RX_FILTR_CFG_PSPOLL);
|
|
||||||
|
|
||||||
*total_flags = flags;
|
|
||||||
mt76_wr(dev, MT_RX_FILTR_CFG, dev->rxfilter);
|
|
||||||
|
|
||||||
mutex_unlock(&dev->mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mt76x0_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
mt76x0_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
||||||
struct ieee80211_bss_conf *info, u32 changed)
|
struct ieee80211_bss_conf *info, u32 changed)
|
||||||
{
|
{
|
||||||
struct mt76x0_dev *dev = hw->priv;
|
struct mt76x0_dev *dev = hw->priv;
|
||||||
|
|
||||||
mutex_lock(&dev->mutex);
|
mutex_lock(&dev->mt76.mutex);
|
||||||
|
|
||||||
if (changed & BSS_CHANGED_ASSOC)
|
if (changed & BSS_CHANGED_ASSOC)
|
||||||
mt76x0_phy_con_cal_onoff(dev, info);
|
mt76x0_phy_con_cal_onoff(dev, info);
|
||||||
@ -192,7 +151,7 @@ mt76x0_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
|||||||
if (changed & BSS_CHANGED_ASSOC)
|
if (changed & BSS_CHANGED_ASSOC)
|
||||||
mt76x0_phy_recalibrate_after_assoc(dev);
|
mt76x0_phy_recalibrate_after_assoc(dev);
|
||||||
|
|
||||||
mutex_unlock(&dev->mutex);
|
mutex_unlock(&dev->mt76.mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -205,7 +164,7 @@ mt76x0_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
|
|
||||||
mutex_lock(&dev->mutex);
|
mutex_lock(&dev->mt76.mutex);
|
||||||
|
|
||||||
idx = mt76_wcid_alloc(dev->wcid_mask, ARRAY_SIZE(dev->wcid));
|
idx = mt76_wcid_alloc(dev->wcid_mask, ARRAY_SIZE(dev->wcid));
|
||||||
if (idx < 0) {
|
if (idx < 0) {
|
||||||
@ -221,7 +180,7 @@ mt76x0_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
|||||||
mt76x0_mac_set_ampdu_factor(dev);
|
mt76x0_mac_set_ampdu_factor(dev);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
mutex_unlock(&dev->mutex);
|
mutex_unlock(&dev->mt76.mutex);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -234,13 +193,13 @@ mt76x0_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
|||||||
struct mt76_sta *msta = (struct mt76_sta *) sta->drv_priv;
|
struct mt76_sta *msta = (struct mt76_sta *) sta->drv_priv;
|
||||||
int idx = msta->wcid.idx;
|
int idx = msta->wcid.idx;
|
||||||
|
|
||||||
mutex_lock(&dev->mutex);
|
mutex_lock(&dev->mt76.mutex);
|
||||||
rcu_assign_pointer(dev->wcid[idx], NULL);
|
rcu_assign_pointer(dev->wcid[idx], NULL);
|
||||||
mt76_set(dev, MT_WCID_DROP(idx), MT_WCID_DROP_MASK(idx));
|
mt76_set(dev, MT_WCID_DROP(idx), MT_WCID_DROP_MASK(idx));
|
||||||
dev->wcid_mask[idx / BITS_PER_LONG] &= ~BIT(idx % BITS_PER_LONG);
|
dev->wcid_mask[idx / BITS_PER_LONG] &= ~BIT(idx % BITS_PER_LONG);
|
||||||
mt76x0_mac_wcid_setup(dev, idx, 0, NULL);
|
mt76x0_mac_wcid_setup(dev, idx, 0, NULL);
|
||||||
mt76x0_mac_set_ampdu_factor(dev);
|
mt76x0_mac_set_ampdu_factor(dev);
|
||||||
mutex_unlock(&dev->mutex);
|
mutex_unlock(&dev->mt76.mutex);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -388,7 +347,7 @@ const struct ieee80211_ops mt76x0_ops = {
|
|||||||
.add_interface = mt76x0_add_interface,
|
.add_interface = mt76x0_add_interface,
|
||||||
.remove_interface = mt76x0_remove_interface,
|
.remove_interface = mt76x0_remove_interface,
|
||||||
.config = mt76x0_config,
|
.config = mt76x0_config,
|
||||||
.configure_filter = mt76_configure_filter,
|
.configure_filter = mt76x02_configure_filter,
|
||||||
.bss_info_changed = mt76x0_bss_info_changed,
|
.bss_info_changed = mt76x0_bss_info_changed,
|
||||||
.sta_add = mt76x0_sta_add,
|
.sta_add = mt76x0_sta_add,
|
||||||
.sta_remove = mt76x0_sta_remove,
|
.sta_remove = mt76x0_sta_remove,
|
||||||
|
@ -147,8 +147,6 @@ enum mt_bw {
|
|||||||
struct mt76x0_dev {
|
struct mt76x0_dev {
|
||||||
struct mt76_dev mt76; /* must be first */
|
struct mt76_dev mt76; /* must be first */
|
||||||
|
|
||||||
struct mutex mutex;
|
|
||||||
|
|
||||||
struct mutex usb_ctrl_mtx;
|
struct mutex usb_ctrl_mtx;
|
||||||
u8 data[32];
|
u8 data[32];
|
||||||
|
|
||||||
@ -184,7 +182,6 @@ struct mt76x0_dev {
|
|||||||
struct mutex reg_atomic_mutex;
|
struct mutex reg_atomic_mutex;
|
||||||
struct mutex hw_atomic_mutex;
|
struct mutex hw_atomic_mutex;
|
||||||
|
|
||||||
u32 rxfilter;
|
|
||||||
u32 debugfs_reg;
|
u32 debugfs_reg;
|
||||||
|
|
||||||
/* TX */
|
/* TX */
|
||||||
|
55
drivers/net/wireless/mediatek/mt76/mt76x02_util.c
Normal file
55
drivers/net/wireless/mediatek/mt76/mt76x02_util.c
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 Stanislaw Gruszka <stf_xl@wp.pl>
|
||||||
|
* Copyright (C) 2016 Felix Fietkau <nbd@nbd.name>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "mt76.h"
|
||||||
|
#include "mt76x02_regs.h"
|
||||||
|
|
||||||
|
void mt76x02_configure_filter(struct ieee80211_hw *hw,
|
||||||
|
unsigned int changed_flags,
|
||||||
|
unsigned int *total_flags, u64 multicast)
|
||||||
|
{
|
||||||
|
struct mt76_dev *dev = hw->priv;
|
||||||
|
u32 flags = 0;
|
||||||
|
|
||||||
|
#define MT76_FILTER(_flag, _hw) do { \
|
||||||
|
flags |= *total_flags & FIF_##_flag; \
|
||||||
|
dev->rxfilter &= ~(_hw); \
|
||||||
|
dev->rxfilter |= !(flags & FIF_##_flag) * (_hw); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
mutex_lock(&dev->mutex);
|
||||||
|
|
||||||
|
dev->rxfilter &= ~MT_RX_FILTR_CFG_OTHER_BSS;
|
||||||
|
|
||||||
|
MT76_FILTER(FCSFAIL, MT_RX_FILTR_CFG_CRC_ERR);
|
||||||
|
MT76_FILTER(PLCPFAIL, MT_RX_FILTR_CFG_PHY_ERR);
|
||||||
|
MT76_FILTER(CONTROL, MT_RX_FILTR_CFG_ACK |
|
||||||
|
MT_RX_FILTR_CFG_CTS |
|
||||||
|
MT_RX_FILTR_CFG_CFEND |
|
||||||
|
MT_RX_FILTR_CFG_CFACK |
|
||||||
|
MT_RX_FILTR_CFG_BA |
|
||||||
|
MT_RX_FILTR_CFG_CTRL_RSV);
|
||||||
|
MT76_FILTER(PSPOLL, MT_RX_FILTR_CFG_PSPOLL);
|
||||||
|
|
||||||
|
*total_flags = flags;
|
||||||
|
dev->bus->wr(dev, MT_RX_FILTR_CFG, dev->rxfilter);
|
||||||
|
|
||||||
|
mutex_unlock(&dev->mutex);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(mt76x02_configure_filter);
|
||||||
|
|
||||||
|
MODULE_LICENSE("Dual BSD/GPL");
|
25
drivers/net/wireless/mediatek/mt76/mt76x02_util.h
Normal file
25
drivers/net/wireless/mediatek/mt76/mt76x02_util.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Felix Fietkau <nbd@nbd.name>
|
||||||
|
* Copyright (C) 2018 Stanislaw Gruszka <stf_xl@wp.pl>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __MT76X02_UTIL_H
|
||||||
|
#define __MT76X02_UTIL_H
|
||||||
|
|
||||||
|
void mt76x02_configure_filter(struct ieee80211_hw *hw,
|
||||||
|
unsigned int changed_flags,
|
||||||
|
unsigned int *total_flags, u64 multicast);
|
||||||
|
|
||||||
|
#endif
|
@ -131,8 +131,6 @@ struct mt76x2_dev {
|
|||||||
|
|
||||||
u16 chainmask;
|
u16 chainmask;
|
||||||
|
|
||||||
u32 rxfilter;
|
|
||||||
|
|
||||||
struct mt76x2_calibration cal;
|
struct mt76x2_calibration cal;
|
||||||
|
|
||||||
s8 target_power;
|
s8 target_power;
|
||||||
@ -293,9 +291,6 @@ int mt76x2_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
|
|||||||
struct ieee80211_key_conf *key);
|
struct ieee80211_key_conf *key);
|
||||||
int mt76x2_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
int mt76x2_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
||||||
u16 queue, const struct ieee80211_tx_queue_params *params);
|
u16 queue, const struct ieee80211_tx_queue_params *params);
|
||||||
void mt76x2_configure_filter(struct ieee80211_hw *hw,
|
|
||||||
unsigned int changed_flags,
|
|
||||||
unsigned int *total_flags, u64 multicast);
|
|
||||||
void mt76x2_txq_init(struct mt76x2_dev *dev, struct ieee80211_txq *txq);
|
void mt76x2_txq_init(struct mt76x2_dev *dev, struct ieee80211_txq *txq);
|
||||||
void mt76x2_sta_rate_tbl_update(struct ieee80211_hw *hw,
|
void mt76x2_sta_rate_tbl_update(struct ieee80211_hw *hw,
|
||||||
struct ieee80211_vif *vif,
|
struct ieee80211_vif *vif,
|
||||||
|
@ -102,7 +102,7 @@ int mt76x2_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
|||||||
int idx = 0;
|
int idx = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
mutex_lock(&dev->mutex);
|
mutex_lock(&dev->mt76.mutex);
|
||||||
|
|
||||||
idx = mt76_wcid_alloc(dev->wcid_mask, ARRAY_SIZE(dev->wcid));
|
idx = mt76_wcid_alloc(dev->wcid_mask, ARRAY_SIZE(dev->wcid));
|
||||||
if (idx < 0) {
|
if (idx < 0) {
|
||||||
@ -127,7 +127,7 @@ int mt76x2_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
|||||||
rcu_assign_pointer(dev->wcid[idx], &msta->wcid);
|
rcu_assign_pointer(dev->wcid[idx], &msta->wcid);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
mutex_unlock(&dev->mutex);
|
mutex_unlock(&dev->mt76.mutex);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -141,14 +141,14 @@ int mt76x2_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
|||||||
int idx = msta->wcid.idx;
|
int idx = msta->wcid.idx;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
mutex_lock(&dev->mutex);
|
mutex_lock(&dev->mt76.mutex);
|
||||||
rcu_assign_pointer(dev->wcid[idx], NULL);
|
rcu_assign_pointer(dev->wcid[idx], NULL);
|
||||||
for (i = 0; i < ARRAY_SIZE(sta->txq); i++)
|
for (i = 0; i < ARRAY_SIZE(sta->txq); i++)
|
||||||
mt76_txq_remove(&dev->mt76, sta->txq[i]);
|
mt76_txq_remove(&dev->mt76, sta->txq[i]);
|
||||||
mt76x2_mac_wcid_set_drop(dev, idx, true);
|
mt76x2_mac_wcid_set_drop(dev, idx, true);
|
||||||
mt76_wcid_free(dev->wcid_mask, idx);
|
mt76_wcid_free(dev->wcid_mask, idx);
|
||||||
mt76x2_mac_wcid_setup(dev, idx, 0, NULL);
|
mt76x2_mac_wcid_setup(dev, idx, 0, NULL);
|
||||||
mutex_unlock(&dev->mutex);
|
mutex_unlock(&dev->mt76.mutex);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -274,40 +274,6 @@ int mt76x2_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(mt76x2_conf_tx);
|
EXPORT_SYMBOL_GPL(mt76x2_conf_tx);
|
||||||
|
|
||||||
void mt76x2_configure_filter(struct ieee80211_hw *hw,
|
|
||||||
unsigned int changed_flags,
|
|
||||||
unsigned int *total_flags, u64 multicast)
|
|
||||||
{
|
|
||||||
struct mt76x2_dev *dev = hw->priv;
|
|
||||||
u32 flags = 0;
|
|
||||||
|
|
||||||
#define MT76_FILTER(_flag, _hw) do { \
|
|
||||||
flags |= *total_flags & FIF_##_flag; \
|
|
||||||
dev->rxfilter &= ~(_hw); \
|
|
||||||
dev->rxfilter |= !(flags & FIF_##_flag) * (_hw); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
mutex_lock(&dev->mutex);
|
|
||||||
|
|
||||||
dev->rxfilter &= ~MT_RX_FILTR_CFG_OTHER_BSS;
|
|
||||||
|
|
||||||
MT76_FILTER(FCSFAIL, MT_RX_FILTR_CFG_CRC_ERR);
|
|
||||||
MT76_FILTER(PLCPFAIL, MT_RX_FILTR_CFG_PHY_ERR);
|
|
||||||
MT76_FILTER(CONTROL, MT_RX_FILTR_CFG_ACK |
|
|
||||||
MT_RX_FILTR_CFG_CTS |
|
|
||||||
MT_RX_FILTR_CFG_CFEND |
|
|
||||||
MT_RX_FILTR_CFG_CFACK |
|
|
||||||
MT_RX_FILTR_CFG_BA |
|
|
||||||
MT_RX_FILTR_CFG_CTRL_RSV);
|
|
||||||
MT76_FILTER(PSPOLL, MT_RX_FILTR_CFG_PSPOLL);
|
|
||||||
|
|
||||||
*total_flags = flags;
|
|
||||||
mt76_wr(dev, MT_RX_FILTR_CFG, dev->rxfilter);
|
|
||||||
|
|
||||||
mutex_unlock(&dev->mutex);
|
|
||||||
}
|
|
||||||
EXPORT_SYMBOL_GPL(mt76x2_configure_filter);
|
|
||||||
|
|
||||||
void mt76x2_sta_rate_tbl_update(struct ieee80211_hw *hw,
|
void mt76x2_sta_rate_tbl_update(struct ieee80211_hw *hw,
|
||||||
struct ieee80211_vif *vif,
|
struct ieee80211_vif *vif,
|
||||||
struct ieee80211_sta *sta)
|
struct ieee80211_sta *sta)
|
||||||
|
@ -214,7 +214,7 @@ int mt76x2_mac_start(struct mt76x2_dev *dev)
|
|||||||
|
|
||||||
mt76_clear(dev, MT_WPDMA_GLO_CFG, MT_WPDMA_GLO_CFG_TX_WRITEBACK_DONE);
|
mt76_clear(dev, MT_WPDMA_GLO_CFG, MT_WPDMA_GLO_CFG_TX_WRITEBACK_DONE);
|
||||||
|
|
||||||
mt76_wr(dev, MT_RX_FILTR_CFG, dev->rxfilter);
|
mt76_wr(dev, MT_RX_FILTR_CFG, dev->mt76.rxfilter);
|
||||||
|
|
||||||
mt76_wr(dev, MT_MAC_SYS_CTRL,
|
mt76_wr(dev, MT_MAC_SYS_CTRL,
|
||||||
MT_MAC_SYS_CTRL_ENABLE_TX |
|
MT_MAC_SYS_CTRL_ENABLE_TX |
|
||||||
@ -377,7 +377,7 @@ int mt76x2_init_hardware(struct mt76x2_dev *dev)
|
|||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
dev->rxfilter = mt76_rr(dev, MT_RX_FILTR_CFG);
|
dev->mt76.rxfilter = mt76_rr(dev, MT_RX_FILTR_CFG);
|
||||||
|
|
||||||
ret = mt76x2_dma_init(dev);
|
ret = mt76x2_dma_init(dev);
|
||||||
if (ret)
|
if (ret)
|
||||||
@ -435,7 +435,6 @@ struct mt76x2_dev *mt76x2_alloc_device(struct device *pdev)
|
|||||||
dev = container_of(mdev, struct mt76x2_dev, mt76);
|
dev = container_of(mdev, struct mt76x2_dev, mt76);
|
||||||
mdev->dev = pdev;
|
mdev->dev = pdev;
|
||||||
mdev->drv = &drv_ops;
|
mdev->drv = &drv_ops;
|
||||||
mutex_init(&dev->mutex);
|
|
||||||
spin_lock_init(&dev->irq_lock);
|
spin_lock_init(&dev->irq_lock);
|
||||||
|
|
||||||
return dev;
|
return dev;
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "mt76x2.h"
|
#include "mt76x2.h"
|
||||||
|
#include "mt76x02_util.h"
|
||||||
|
|
||||||
static int
|
static int
|
||||||
mt76x2_start(struct ieee80211_hw *hw)
|
mt76x2_start(struct ieee80211_hw *hw)
|
||||||
@ -22,7 +23,7 @@ mt76x2_start(struct ieee80211_hw *hw)
|
|||||||
struct mt76x2_dev *dev = hw->priv;
|
struct mt76x2_dev *dev = hw->priv;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
mutex_lock(&dev->mutex);
|
mutex_lock(&dev->mt76.mutex);
|
||||||
|
|
||||||
ret = mt76x2_mac_start(dev);
|
ret = mt76x2_mac_start(dev);
|
||||||
if (ret)
|
if (ret)
|
||||||
@ -38,7 +39,7 @@ mt76x2_start(struct ieee80211_hw *hw)
|
|||||||
set_bit(MT76_STATE_RUNNING, &dev->mt76.state);
|
set_bit(MT76_STATE_RUNNING, &dev->mt76.state);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
mutex_unlock(&dev->mutex);
|
mutex_unlock(&dev->mt76.mutex);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,10 +48,10 @@ mt76x2_stop(struct ieee80211_hw *hw)
|
|||||||
{
|
{
|
||||||
struct mt76x2_dev *dev = hw->priv;
|
struct mt76x2_dev *dev = hw->priv;
|
||||||
|
|
||||||
mutex_lock(&dev->mutex);
|
mutex_lock(&dev->mt76.mutex);
|
||||||
clear_bit(MT76_STATE_RUNNING, &dev->mt76.state);
|
clear_bit(MT76_STATE_RUNNING, &dev->mt76.state);
|
||||||
mt76x2_stop_hardware(dev);
|
mt76x2_stop_hardware(dev);
|
||||||
mutex_unlock(&dev->mutex);
|
mutex_unlock(&dev->mt76.mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -127,15 +128,15 @@ mt76x2_config(struct ieee80211_hw *hw, u32 changed)
|
|||||||
struct mt76x2_dev *dev = hw->priv;
|
struct mt76x2_dev *dev = hw->priv;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
mutex_lock(&dev->mutex);
|
mutex_lock(&dev->mt76.mutex);
|
||||||
|
|
||||||
if (changed & IEEE80211_CONF_CHANGE_MONITOR) {
|
if (changed & IEEE80211_CONF_CHANGE_MONITOR) {
|
||||||
if (!(hw->conf.flags & IEEE80211_CONF_MONITOR))
|
if (!(hw->conf.flags & IEEE80211_CONF_MONITOR))
|
||||||
dev->rxfilter |= MT_RX_FILTR_CFG_PROMISC;
|
dev->mt76.rxfilter |= MT_RX_FILTR_CFG_PROMISC;
|
||||||
else
|
else
|
||||||
dev->rxfilter &= ~MT_RX_FILTR_CFG_PROMISC;
|
dev->mt76.rxfilter &= ~MT_RX_FILTR_CFG_PROMISC;
|
||||||
|
|
||||||
mt76_wr(dev, MT_RX_FILTR_CFG, dev->rxfilter);
|
mt76_wr(dev, MT_RX_FILTR_CFG, dev->mt76.rxfilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed & IEEE80211_CONF_CHANGE_POWER) {
|
if (changed & IEEE80211_CONF_CHANGE_POWER) {
|
||||||
@ -156,7 +157,7 @@ mt76x2_config(struct ieee80211_hw *hw, u32 changed)
|
|||||||
ieee80211_wake_queues(hw);
|
ieee80211_wake_queues(hw);
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_unlock(&dev->mutex);
|
mutex_unlock(&dev->mt76.mutex);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -168,7 +169,7 @@ mt76x2_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
|||||||
struct mt76x2_dev *dev = hw->priv;
|
struct mt76x2_dev *dev = hw->priv;
|
||||||
struct mt76x2_vif *mvif = (struct mt76x2_vif *) vif->drv_priv;
|
struct mt76x2_vif *mvif = (struct mt76x2_vif *) vif->drv_priv;
|
||||||
|
|
||||||
mutex_lock(&dev->mutex);
|
mutex_lock(&dev->mt76.mutex);
|
||||||
|
|
||||||
if (changed & BSS_CHANGED_BSSID)
|
if (changed & BSS_CHANGED_BSSID)
|
||||||
mt76x2_mac_set_bssid(dev, mvif->idx, info->bssid);
|
mt76x2_mac_set_bssid(dev, mvif->idx, info->bssid);
|
||||||
@ -195,7 +196,7 @@ mt76x2_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
|||||||
mt76x2_set_tx_ackto(dev);
|
mt76x2_set_tx_ackto(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_unlock(&dev->mutex);
|
mutex_unlock(&dev->mt76.mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -252,10 +253,10 @@ static void mt76x2_set_coverage_class(struct ieee80211_hw *hw,
|
|||||||
{
|
{
|
||||||
struct mt76x2_dev *dev = hw->priv;
|
struct mt76x2_dev *dev = hw->priv;
|
||||||
|
|
||||||
mutex_lock(&dev->mutex);
|
mutex_lock(&dev->mt76.mutex);
|
||||||
dev->coverage_class = coverage_class;
|
dev->coverage_class = coverage_class;
|
||||||
mt76x2_set_tx_ackto(dev);
|
mt76x2_set_tx_ackto(dev);
|
||||||
mutex_unlock(&dev->mutex);
|
mutex_unlock(&dev->mt76.mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -272,7 +273,7 @@ static int mt76x2_set_antenna(struct ieee80211_hw *hw, u32 tx_ant,
|
|||||||
if (!tx_ant || tx_ant > 3 || tx_ant != rx_ant)
|
if (!tx_ant || tx_ant > 3 || tx_ant != rx_ant)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
mutex_lock(&dev->mutex);
|
mutex_lock(&dev->mt76.mutex);
|
||||||
|
|
||||||
dev->chainmask = (tx_ant == 3) ? 0x202 : 0x101;
|
dev->chainmask = (tx_ant == 3) ? 0x202 : 0x101;
|
||||||
dev->mt76.antenna_mask = tx_ant;
|
dev->mt76.antenna_mask = tx_ant;
|
||||||
@ -280,7 +281,7 @@ static int mt76x2_set_antenna(struct ieee80211_hw *hw, u32 tx_ant,
|
|||||||
mt76_set_stream_caps(&dev->mt76, true);
|
mt76_set_stream_caps(&dev->mt76, true);
|
||||||
mt76x2_phy_set_antenna(dev);
|
mt76x2_phy_set_antenna(dev);
|
||||||
|
|
||||||
mutex_unlock(&dev->mutex);
|
mutex_unlock(&dev->mt76.mutex);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -290,10 +291,10 @@ static int mt76x2_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant,
|
|||||||
{
|
{
|
||||||
struct mt76x2_dev *dev = hw->priv;
|
struct mt76x2_dev *dev = hw->priv;
|
||||||
|
|
||||||
mutex_lock(&dev->mutex);
|
mutex_lock(&dev->mt76.mutex);
|
||||||
*tx_ant = dev->mt76.antenna_mask;
|
*tx_ant = dev->mt76.antenna_mask;
|
||||||
*rx_ant = dev->mt76.antenna_mask;
|
*rx_ant = dev->mt76.antenna_mask;
|
||||||
mutex_unlock(&dev->mutex);
|
mutex_unlock(&dev->mt76.mutex);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -320,7 +321,7 @@ const struct ieee80211_ops mt76x2_ops = {
|
|||||||
.add_interface = mt76x2_add_interface,
|
.add_interface = mt76x2_add_interface,
|
||||||
.remove_interface = mt76x2_remove_interface,
|
.remove_interface = mt76x2_remove_interface,
|
||||||
.config = mt76x2_config,
|
.config = mt76x2_config,
|
||||||
.configure_filter = mt76x2_configure_filter,
|
.configure_filter = mt76x02_configure_filter,
|
||||||
.bss_info_changed = mt76x2_bss_info_changed,
|
.bss_info_changed = mt76x2_bss_info_changed,
|
||||||
.sta_add = mt76x2_sta_add,
|
.sta_add = mt76x2_sta_add,
|
||||||
.sta_remove = mt76x2_sta_remove,
|
.sta_remove = mt76x2_sta_remove,
|
||||||
|
@ -151,8 +151,6 @@ struct mt76x2_dev *mt76x2u_alloc_device(struct device *pdev)
|
|||||||
mdev->dev = pdev;
|
mdev->dev = pdev;
|
||||||
mdev->drv = &drv_ops;
|
mdev->drv = &drv_ops;
|
||||||
|
|
||||||
mutex_init(&dev->mutex);
|
|
||||||
|
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,7 +212,7 @@ int mt76x2u_init_hardware(struct mt76x2_dev *dev)
|
|||||||
return err;
|
return err;
|
||||||
|
|
||||||
mt76x2u_mac_setaddr(dev, dev->mt76.eeprom.data + MT_EE_MAC_ADDR);
|
mt76x2u_mac_setaddr(dev, dev->mt76.eeprom.data + MT_EE_MAC_ADDR);
|
||||||
dev->rxfilter = mt76_rr(dev, MT_RX_FILTR_CFG);
|
dev->mt76.rxfilter = mt76_rr(dev, MT_RX_FILTR_CFG);
|
||||||
|
|
||||||
mt76x2u_init_beacon_offsets(dev);
|
mt76x2u_init_beacon_offsets(dev);
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ int mt76x2u_mac_start(struct mt76x2_dev *dev)
|
|||||||
wait_for_wpdma(dev);
|
wait_for_wpdma(dev);
|
||||||
usleep_range(50, 100);
|
usleep_range(50, 100);
|
||||||
|
|
||||||
mt76_wr(dev, MT_RX_FILTR_CFG, dev->rxfilter);
|
mt76_wr(dev, MT_RX_FILTR_CFG, dev->mt76.rxfilter);
|
||||||
|
|
||||||
mt76_wr(dev, MT_MAC_SYS_CTRL,
|
mt76_wr(dev, MT_MAC_SYS_CTRL,
|
||||||
MT_MAC_SYS_CTRL_ENABLE_TX |
|
MT_MAC_SYS_CTRL_ENABLE_TX |
|
||||||
|
@ -15,13 +15,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "mt76x2u.h"
|
#include "mt76x2u.h"
|
||||||
|
#include "mt76x02_util.h"
|
||||||
|
|
||||||
static int mt76x2u_start(struct ieee80211_hw *hw)
|
static int mt76x2u_start(struct ieee80211_hw *hw)
|
||||||
{
|
{
|
||||||
struct mt76x2_dev *dev = hw->priv;
|
struct mt76x2_dev *dev = hw->priv;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
mutex_lock(&dev->mutex);
|
mutex_lock(&dev->mt76.mutex);
|
||||||
|
|
||||||
ret = mt76x2u_mac_start(dev);
|
ret = mt76x2u_mac_start(dev);
|
||||||
if (ret)
|
if (ret)
|
||||||
@ -30,7 +31,7 @@ static int mt76x2u_start(struct ieee80211_hw *hw)
|
|||||||
set_bit(MT76_STATE_RUNNING, &dev->mt76.state);
|
set_bit(MT76_STATE_RUNNING, &dev->mt76.state);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
mutex_unlock(&dev->mutex);
|
mutex_unlock(&dev->mt76.mutex);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,10 +39,10 @@ static void mt76x2u_stop(struct ieee80211_hw *hw)
|
|||||||
{
|
{
|
||||||
struct mt76x2_dev *dev = hw->priv;
|
struct mt76x2_dev *dev = hw->priv;
|
||||||
|
|
||||||
mutex_lock(&dev->mutex);
|
mutex_lock(&dev->mt76.mutex);
|
||||||
clear_bit(MT76_STATE_RUNNING, &dev->mt76.state);
|
clear_bit(MT76_STATE_RUNNING, &dev->mt76.state);
|
||||||
mt76x2u_stop_hw(dev);
|
mt76x2u_stop_hw(dev);
|
||||||
mutex_unlock(&dev->mutex);
|
mutex_unlock(&dev->mt76.mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mt76x2u_add_interface(struct ieee80211_hw *hw,
|
static int mt76x2u_add_interface(struct ieee80211_hw *hw,
|
||||||
@ -93,7 +94,7 @@ mt76x2u_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
|||||||
{
|
{
|
||||||
struct mt76x2_dev *dev = hw->priv;
|
struct mt76x2_dev *dev = hw->priv;
|
||||||
|
|
||||||
mutex_lock(&dev->mutex);
|
mutex_lock(&dev->mt76.mutex);
|
||||||
|
|
||||||
if (changed & BSS_CHANGED_ASSOC) {
|
if (changed & BSS_CHANGED_ASSOC) {
|
||||||
mt76x2u_phy_channel_calibrate(dev);
|
mt76x2u_phy_channel_calibrate(dev);
|
||||||
@ -107,7 +108,7 @@ mt76x2u_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
|||||||
get_unaligned_le16(info->bssid + 4));
|
get_unaligned_le16(info->bssid + 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_unlock(&dev->mutex);
|
mutex_unlock(&dev->mt76.mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -116,14 +117,14 @@ mt76x2u_config(struct ieee80211_hw *hw, u32 changed)
|
|||||||
struct mt76x2_dev *dev = hw->priv;
|
struct mt76x2_dev *dev = hw->priv;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
mutex_lock(&dev->mutex);
|
mutex_lock(&dev->mt76.mutex);
|
||||||
|
|
||||||
if (changed & IEEE80211_CONF_CHANGE_MONITOR) {
|
if (changed & IEEE80211_CONF_CHANGE_MONITOR) {
|
||||||
if (!(hw->conf.flags & IEEE80211_CONF_MONITOR))
|
if (!(hw->conf.flags & IEEE80211_CONF_MONITOR))
|
||||||
dev->rxfilter |= MT_RX_FILTR_CFG_PROMISC;
|
dev->mt76.rxfilter |= MT_RX_FILTR_CFG_PROMISC;
|
||||||
else
|
else
|
||||||
dev->rxfilter &= ~MT_RX_FILTR_CFG_PROMISC;
|
dev->mt76.rxfilter &= ~MT_RX_FILTR_CFG_PROMISC;
|
||||||
mt76_wr(dev, MT_RX_FILTR_CFG, dev->rxfilter);
|
mt76_wr(dev, MT_RX_FILTR_CFG, dev->mt76.rxfilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
|
if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
|
||||||
@ -142,7 +143,7 @@ mt76x2u_config(struct ieee80211_hw *hw, u32 changed)
|
|||||||
mt76x2_phy_set_txpower(dev);
|
mt76x2_phy_set_txpower(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_unlock(&dev->mutex);
|
mutex_unlock(&dev->mt76.mutex);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -177,7 +178,7 @@ const struct ieee80211_ops mt76x2u_ops = {
|
|||||||
.config = mt76x2u_config,
|
.config = mt76x2u_config,
|
||||||
.wake_tx_queue = mt76_wake_tx_queue,
|
.wake_tx_queue = mt76_wake_tx_queue,
|
||||||
.bss_info_changed = mt76x2u_bss_info_changed,
|
.bss_info_changed = mt76x2u_bss_info_changed,
|
||||||
.configure_filter = mt76x2_configure_filter,
|
.configure_filter = mt76x02_configure_filter,
|
||||||
.conf_tx = mt76x2_conf_tx,
|
.conf_tx = mt76x2_conf_tx,
|
||||||
.sw_scan_start = mt76x2u_sw_scan,
|
.sw_scan_start = mt76x2u_sw_scan,
|
||||||
.sw_scan_complete = mt76x2u_sw_scan_complete,
|
.sw_scan_complete = mt76x2u_sw_scan_complete,
|
||||||
|
Loading…
Reference in New Issue
Block a user