Commit b11e1969 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau
Browse files

mt76x0: add ieee80211_ops ops pointer to mt76x0_alloc_device signature



Add ieee80211_ops ops pointer to mt76x0_alloc_device routine signature
in order to specify mac80211 callbacks and remove usb dependency from
mt76x0 generic code.
Move mt76x0_ops callbacks in usb module in order to remove leftover
usb dependency in mt76x0 generic code.
Introduce mt76x0e_ops mac80211 callbacks for pci code

Signed-off-by: default avatarLorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 6034b2b0
Loading
Loading
Loading
Loading
+8 −29
Original line number Diff line number Diff line
@@ -246,23 +246,13 @@ int mt76x0_mac_start(struct mt76x0_dev *dev)

	return !mt76x02_wait_for_wpdma(&dev->mt76, 50) ? -ETIMEDOUT : 0;
}
EXPORT_SYMBOL_GPL(mt76x0_mac_start);

static void mt76x0_mac_stop_hw(struct mt76x0_dev *dev)
void mt76x0_mac_stop(struct mt76x0_dev *dev)
{
	int i, ok;

	if (test_bit(MT76_REMOVED, &dev->mt76.state))
		return;

	mt76_clear(dev, MT_BEACON_TIME_CFG, MT_BEACON_TIME_CFG_TIMER_EN |
		   MT_BEACON_TIME_CFG_SYNC_MODE | MT_BEACON_TIME_CFG_TBTT_EN |
		   MT_BEACON_TIME_CFG_BEACON_TX);

	if (!mt76_poll(dev, MT_USB_DMA_CFG, MT_USB_DMA_CFG_TX_BUSY, 0, 1000))
		dev_warn(dev->mt76.dev, "Warning: TX DMA did not stop!\n");
	int i = 200, ok = 0;

	/* Page count on TxQ */
	i = 200;
	while (i-- && ((mt76_rr(dev, 0x0438) & 0xffffffff) ||
		       (mt76_rr(dev, 0x0a30) & 0x000000ff) ||
		       (mt76_rr(dev, 0x0a34) & 0x00ff00ff)))
@@ -275,9 +265,7 @@ static void mt76x0_mac_stop_hw(struct mt76x0_dev *dev)
					 MT_MAC_SYS_CTRL_ENABLE_TX);

	/* Page count on RxQ */
	ok = 0;
	i = 200;
	while (i--) {
	for (i = 0; i < 200; i++) {
		if (!(mt76_rr(dev, MT_RXQ_STA) & 0x00ff0000) &&
		    !mt76_rr(dev, 0x0a30) &&
		    !mt76_rr(dev, 0x0a34)) {
@@ -290,17 +278,6 @@ static void mt76x0_mac_stop_hw(struct mt76x0_dev *dev)

	if (!mt76_poll(dev, MT_MAC_STATUS, MT_MAC_STATUS_RX, 0, 1000))
		dev_warn(dev->mt76.dev, "Warning: MAC RX did not stop!\n");

	if (!mt76_poll(dev, MT_USB_DMA_CFG, MT_USB_DMA_CFG_RX_BUSY, 0, 1000))
		dev_warn(dev->mt76.dev, "Warning: RX DMA did not stop!\n");
}

void mt76x0_mac_stop(struct mt76x0_dev *dev)
{
	cancel_delayed_work_sync(&dev->cal_work);
	cancel_delayed_work_sync(&dev->mac_work);
	mt76u_stop_stat_wk(&dev->mt76);
	mt76x0_mac_stop_hw(dev);
}
EXPORT_SYMBOL_GPL(mt76x0_mac_stop);

@@ -359,12 +336,14 @@ int mt76x0_init_hardware(struct mt76x0_dev *dev)
EXPORT_SYMBOL_GPL(mt76x0_init_hardware);

struct mt76x0_dev *
mt76x0_alloc_device(struct device *pdev, const struct mt76_driver_ops *drv_ops)
mt76x0_alloc_device(struct device *pdev,
		    const struct mt76_driver_ops *drv_ops,
		    const struct ieee80211_ops *ops)
{
	struct mt76x0_dev *dev;
	struct mt76_dev *mdev;

	mdev = mt76_alloc_device(sizeof(*dev), &mt76x0_ops);
	mdev = mt76_alloc_device(sizeof(*dev), ops);
	if (!mdev)
		return NULL;

+14 −68
Original line number Diff line number Diff line
@@ -18,42 +18,7 @@
#include "../mt76x02_util.h"
#include <linux/etherdevice.h>

static int mt76x0_start(struct ieee80211_hw *hw)
{
	struct mt76x0_dev *dev = hw->priv;
	int ret;

	mutex_lock(&dev->mt76.mutex);

	ret = mt76x0_mac_start(dev);
	if (ret)
		goto out;

	ieee80211_queue_delayed_work(dev->mt76.hw, &dev->mac_work,
				     MT_CALIBRATE_INTERVAL);
	ieee80211_queue_delayed_work(dev->mt76.hw, &dev->cal_work,
				     MT_CALIBRATE_INTERVAL);

	set_bit(MT76_STATE_RUNNING, &dev->mt76.state);

out:
	mutex_unlock(&dev->mt76.mutex);
	return ret;
}

static void mt76x0_stop(struct ieee80211_hw *hw)
{
	struct mt76x0_dev *dev = hw->priv;

	mutex_lock(&dev->mt76.mutex);

	clear_bit(MT76_STATE_RUNNING, &dev->mt76.state);
	mt76x0_mac_stop(dev);

	mutex_unlock(&dev->mt76.mutex);
}

static int mt76x0_config(struct ieee80211_hw *hw, u32 changed)
int mt76x0_config(struct ieee80211_hw *hw, u32 changed)
{
	struct mt76x0_dev *dev = hw->priv;
	int ret = 0;
@@ -86,6 +51,7 @@ static int mt76x0_config(struct ieee80211_hw *hw, u32 changed)

	return ret;
}
EXPORT_SYMBOL_GPL(mt76x0_config);

static void
mt76x0_addr_wr(struct mt76x0_dev *dev, const u32 offset, const u8 *addr)
@@ -94,8 +60,8 @@ mt76x0_addr_wr(struct mt76x0_dev *dev, const u32 offset, const u8 *addr)
	mt76_wr(dev, offset + 4, addr[4] | addr[5] << 8);
}

static void
mt76x0_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
void mt76x0_bss_info_changed(struct ieee80211_hw *hw,
			     struct ieee80211_vif *vif,
			     struct ieee80211_bss_conf *info, u32 changed)
{
	struct mt76x0_dev *dev = hw->priv;
@@ -146,10 +112,9 @@ mt76x0_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,

	mutex_unlock(&dev->mt76.mutex);
}
EXPORT_SYMBOL_GPL(mt76x0_bss_info_changed);

static void
mt76x0_sw_scan(struct ieee80211_hw *hw,
		struct ieee80211_vif *vif,
void mt76x0_sw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
		    const u8 *mac_addr)
{
	struct mt76x0_dev *dev = hw->priv;
@@ -158,9 +123,9 @@ mt76x0_sw_scan(struct ieee80211_hw *hw,
	mt76x0_agc_save(dev);
	set_bit(MT76_SCANNING, &dev->mt76.state);
}
EXPORT_SYMBOL_GPL(mt76x0_sw_scan);

static void
mt76x0_sw_scan_complete(struct ieee80211_hw *hw,
void mt76x0_sw_scan_complete(struct ieee80211_hw *hw,
			     struct ieee80211_vif *vif)
{
	struct mt76x0_dev *dev = hw->priv;
@@ -171,8 +136,9 @@ mt76x0_sw_scan_complete(struct ieee80211_hw *hw,
	ieee80211_queue_delayed_work(dev->mt76.hw, &dev->cal_work,
				     MT_CALIBRATE_INTERVAL);
}
EXPORT_SYMBOL_GPL(mt76x0_sw_scan_complete);

static int mt76x0_set_rts_threshold(struct ieee80211_hw *hw, u32 value)
int mt76x0_set_rts_threshold(struct ieee80211_hw *hw, u32 value)
{
	struct mt76x0_dev *dev = hw->priv;

@@ -180,24 +146,4 @@ static int mt76x0_set_rts_threshold(struct ieee80211_hw *hw, u32 value)

	return 0;
}

const struct ieee80211_ops mt76x0_ops = {
	.tx = mt76x0_tx,
	.start = mt76x0_start,
	.stop = mt76x0_stop,
	.add_interface = mt76x02_add_interface,
	.remove_interface = mt76x02_remove_interface,
	.config = mt76x0_config,
	.configure_filter = mt76x02_configure_filter,
	.bss_info_changed = mt76x0_bss_info_changed,
	.sta_add = mt76x02_sta_add,
	.sta_remove = mt76x02_sta_remove,
	.set_key = mt76x02_set_key,
	.conf_tx = mt76x02_conf_tx,
	.sw_scan_start = mt76x0_sw_scan,
	.sw_scan_complete = mt76x0_sw_scan_complete,
	.ampdu_action = mt76x02_ampdu_action,
	.sta_rate_tbl_update = mt76x02_sta_rate_tbl_update,
	.set_rts_threshold = mt76x0_set_rts_threshold,
	.wake_tx_queue = mt76_wake_tx_queue,
};
EXPORT_SYMBOL_GPL(mt76x0_set_rts_threshold);
+13 −3
Original line number Diff line number Diff line
@@ -110,8 +110,6 @@ struct mt76x0_dev {
	struct mac_stats stats;
};

extern const struct ieee80211_ops mt76x0_ops;

static inline bool is_mt7610e(struct mt76x0_dev *dev)
{
	/* TODO */
@@ -126,7 +124,9 @@ void mt76x0_init_debugfs(struct mt76x0_dev *dev);

/* Init */
struct mt76x0_dev *
mt76x0_alloc_device(struct device *pdev, const struct mt76_driver_ops *drv_ops);
mt76x0_alloc_device(struct device *pdev,
		    const struct mt76_driver_ops *drv_ops,
		    const struct ieee80211_ops *ops);
int mt76x0_init_hardware(struct mt76x0_dev *dev);
int mt76x0_register_device(struct mt76x0_dev *dev);
void mt76x0_chip_onoff(struct mt76x0_dev *dev, bool enable, bool reset);
@@ -134,6 +134,16 @@ void mt76x0_chip_onoff(struct mt76x0_dev *dev, bool enable, bool reset);
int mt76x0_mac_start(struct mt76x0_dev *dev);
void mt76x0_mac_stop(struct mt76x0_dev *dev);

int mt76x0_config(struct ieee80211_hw *hw, u32 changed);
void mt76x0_bss_info_changed(struct ieee80211_hw *hw,
			     struct ieee80211_vif *vif,
			     struct ieee80211_bss_conf *info, u32 changed);
void mt76x0_sw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
		    const u8 *mac_addr);
void mt76x0_sw_scan_complete(struct ieee80211_hw *hw,
			     struct ieee80211_vif *vif);
int mt76x0_set_rts_threshold(struct ieee80211_hw *hw, u32 value);

/* PHY */
void mt76x0_phy_init(struct mt76x0_dev *dev);
int mt76x0_wait_bbp_ready(struct mt76x0_dev *dev);
+21 −1
Original line number Diff line number Diff line
@@ -21,6 +21,26 @@
#include "mt76x0.h"
#include "mcu.h"
#include "../mt76x02_dma.h"
#include "../mt76x02_util.h"

static int mt76x0e_start(struct ieee80211_hw *hw)
{
	return 0;
}

static void mt76x0e_stop(struct ieee80211_hw *hw)
{
}

static const struct ieee80211_ops mt76x0e_ops = {
	.tx = mt76x0_tx,
	.start = mt76x0e_start,
	.stop = mt76x0e_stop,
	.config = mt76x0_config,
	.add_interface = mt76x02_add_interface,
	.remove_interface = mt76x02_remove_interface,
	.configure_filter = mt76x02_configure_filter,
};

static int mt76x0e_register_device(struct mt76x0_dev *dev)
{
@@ -86,7 +106,7 @@ mt76x0e_probe(struct pci_dev *pdev, const struct pci_device_id *id)
	if (ret)
		return ret;

	dev = mt76x0_alloc_device(&pdev->dev, NULL);
	dev = mt76x0_alloc_device(&pdev->dev, NULL, &mt76x0e_ops);
	if (!dev)
		return -ENOMEM;

+1 −0
Original line number Diff line number Diff line
@@ -81,6 +81,7 @@ void mt76x0_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control,

	mt76_tx(&dev->mt76, control->sta, wcid, skb);
}
EXPORT_SYMBOL_GPL(mt76x0_tx);

int mt76x0_tx_prepare_skb(struct mt76_dev *mdev, void *data,
			  struct sk_buff *skb, struct mt76_queue *q,
Loading