add mt76x2u support to mt76 driver
Subsystems (2)
cover add mt76x2u support to mt76 driver
Add usb layer to mt76 driver in order to support mt76x2u based devices. Move common code between pci and usb in mt76x2-common module in order to remove pci dependency from usb driver
Lorenzo Bianconi (18):
mt76x2: use completion instead of wait_queue for mcu rx queue
mt76x2: move mt76x2_fw_header and mt76x2_patch_header definitions in
mcu.h
mt76x2: move utility routines in mt76x2.h
mt76x2: introduce mt76x2_init_device routine
mt76x2: move currently mt76x2u unsupported features to mt76x2_init
mt76x2: introduce mt76x2_mac_load_tx_status routine
mt76x2: add napi struct to mt76_rx_poll_complete/mt76_rx_complete
signatures
mt76x2: add buffer len mt76x2_mac_write_txwi signature
mt76: introduce tx_queue_skb function pointer in mt76_bus_ops
mt76: introduce mt76x2-common module
mt76: add mt76x2_tx_common to mt76x2-common module
mt76: add mt76x2_mac_common to mt76x2-common module
mt76: add mt76x2_init_common to mt76x2-common module
mt76: add mt76x2_common to mt76x2-common module
mt76: add mt76x2_phy_common to mt76x2-common module
mt76: move mt76x2_debugfs in mt76-common module
mt76: add usb suppor to mt76 layer
mt76: add driver code for MT76x2u based devices
drivers/net/wireless/mediatek/mt76/Kconfig | 13 + drivers/net/wireless/mediatek/mt76/Makefile | 18 +- drivers/net/wireless/mediatek/mt76/agg-rx.c | 2 +- drivers/net/wireless/mediatek/mt76/dma.c | 3 +- drivers/net/wireless/mediatek/mt76/dma.h | 5 + drivers/net/wireless/mediatek/mt76/mac80211.c | 27 +- drivers/net/wireless/mediatek/mt76/mt76.h | 124 +++- drivers/net/wireless/mediatek/mt76/mt76x2.h | 91 ++- drivers/net/wireless/mediatek/mt76/mt76x2_common.c | 348 +++++++++++ .../net/wireless/mediatek/mt76/mt76x2_debugfs.c | 1 + drivers/net/wireless/mediatek/mt76/mt76x2_dma.c | 23 +- drivers/net/wireless/mediatek/mt76/mt76x2_eeprom.c | 13 +- drivers/net/wireless/mediatek/mt76/mt76x2_eeprom.h | 1 + drivers/net/wireless/mediatek/mt76/mt76x2_init.c | 276 +-------- .../wireless/mediatek/mt76/mt76x2_init_common.c | 253 ++++++++ drivers/net/wireless/mediatek/mt76/mt76x2_mac.c | 608 +------------------ drivers/net/wireless/mediatek/mt76/mt76x2_mac.h | 2 +- .../net/wireless/mediatek/mt76/mt76x2_mac_common.c | 642 ++++++++++++++++++++ drivers/net/wireless/mediatek/mt76/mt76x2_main.c | 305 ---------- drivers/net/wireless/mediatek/mt76/mt76x2_mcu.c | 20 +- drivers/net/wireless/mediatek/mt76/mt76x2_mcu.h | 17 + drivers/net/wireless/mediatek/mt76/mt76x2_phy.c | 290 --------- .../net/wireless/mediatek/mt76/mt76x2_phy_common.c | 302 ++++++++++ drivers/net/wireless/mediatek/mt76/mt76x2_regs.h | 35 ++ drivers/net/wireless/mediatek/mt76/mt76x2_tx.c | 125 +--- .../net/wireless/mediatek/mt76/mt76x2_tx_common.c | 149 +++++ drivers/net/wireless/mediatek/mt76/mt76x2_usb.c | 85 +++ drivers/net/wireless/mediatek/mt76/mt76x2u.h | 93 +++ drivers/net/wireless/mediatek/mt76/mt76x2u_core.c | 194 ++++++ drivers/net/wireless/mediatek/mt76/mt76x2u_init.c | 302 ++++++++++ drivers/net/wireless/mediatek/mt76/mt76x2u_mac.c | 237 ++++++++ drivers/net/wireless/mediatek/mt76/mt76x2u_main.c | 161 +++++ drivers/net/wireless/mediatek/mt76/mt76x2u_mcu.c | 648 +++++++++++++++++++++ drivers/net/wireless/mediatek/mt76/mt76x2u_phy.c | 264 +++++++++ drivers/net/wireless/mediatek/mt76/tx.c | 9 +- drivers/net/wireless/mediatek/mt76/usb.c | 593 +++++++++++++++++++ 36 files changed, 4620 insertions(+), 1659 deletions(-) create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x2_common.c create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x2_init_common.c create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x2_mac_common.c create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x2_phy_common.c create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x2_tx_common.c create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x2_usb.c create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x2u.h create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x2u_core.c create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x2u_init.c create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x2u_mac.c create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x2u_main.c create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x2u_mcu.c create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x2u_phy.c create mode 100644 drivers/net/wireless/mediatek/mt76/usb.c
Signature · 1 line
2.14.3
RFC 1/18 mt76x2: use completion instead of wait_queue for mcu rx queue
In order to reuse mcu related code supporting mt76x2u based devices, use completion instead of wait_queue for mcu responses queue
--- drivers/net/wireless/mediatek/mt76/mt76x2.h | 2 +- drivers/net/wireless/mediatek/mt76/mt76x2_dma.c | 4 ++-- drivers/net/wireless/mediatek/mt76/mt76x2_mcu.c | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x2.h +1 -1
@@ -47,7 +47,7 @@struct mt76x2_mcu {struct mutex mutex; -wait_queue_head_t wait; +struct completion resp_cmpl;struct sk_buff_head res_q;u32 msg_seq;
drivers/net/wireless/mediatek/mt76/mt76x2_dma.c +2 -2
@@ -74,7 +74,7 @@ void mt76x2_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q,if (q ==MT_RXQ_MCU ) {skb_queue_tail (&dev->mcu.res_q, skb); -wake_up (&dev->mcu.wait); +complete (&dev->mcu.resp_cmpl);return ; }
@@ -139,7 +139,7 @@ int mt76x2_dma_init(struct mt76x2_dev *dev)mt76_dma_attach (&dev->mt76); -init_waitqueue_head (&dev->mcu.wait); +init_completion (&dev->mcu.resp_cmpl);skb_queue_head_init (&dev->mcu.res_q);tasklet_init (&dev->tx_tasklet, mt76x2_tx_tasklet, (unsigned long ) dev);
drivers/net/wireless/mediatek/mt76/mt76x2_mcu.c +1 -2
@@ -61,8 +61,7 @@ mt76x2_mcu_get_response(struct mt76x2_dev *dev, unsigned long expires)return NULL ; timeout = expires - jiffies; -wait_event_timeout (dev->mcu.wait, !skb_queue_empty (&dev->mcu.res_q), - timeout); +wait_for_completion_timeout (&dev->mcu.resp_cmpl, timeout);return skb_dequeue (&dev->mcu.res_q); }
Signature · 1 line
2.14.3
RFC 2/18 mt76x2: move mt76x2_fw_header and mt76x2_patch_header definitions in mcu.h
In reply to Lorenzo Bianconimove mt76x2_fw_header and mt76x2_patch_header definitions in mcu.h in order to reuse them in mt76x2u mcu related code
--- drivers/net/wireless/mediatek/mt76/mt76x2_mcu.c | 17 ----------------- drivers/net/wireless/mediatek/mt76/mt76x2_mcu.h | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 17 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x2_mcu.c +0 -17
@@ -23,23 +23,6 @@#include "mt76x2_dma.h" #include "mt76x2_eeprom.h" -struct mt76x2_fw_header { -__le32 ilm_len; -__le32 dlm_len; -__le16 build_ver; -__le16 fw_ver; -u8 pad[4 ]; -char build_time[16 ]; -}; - -struct mt76x2_patch_header { -char build_time[16 ]; -char platform[4 ]; -char hw_version[4 ]; -char patch_version[4 ]; -u8 pad[2 ]; -}; -static struct sk_buff *mt76x2_mcu_msg_alloc (const void *data,int len) {struct sk_buff *skb;
drivers/net/wireless/mediatek/mt76/mt76x2_mcu.h +17 -0
@@ -146,6 +146,23 @@ struct mt76x2_tssi_comp {u8 offset1; } __packed__aligned(4) ; +struct mt76x2_fw_header { +__le32 ilm_len; +__le32 dlm_len; +__le16 build_ver; +__le16 fw_ver; +u8 pad[4 ]; +char build_time[16 ]; +}; + +struct mt76x2_patch_header { +char build_time[16 ]; +char platform[4 ]; +char hw_version[4 ]; +char patch_version[4 ]; +u8 pad[2 ]; +}; +int mt76x2_mcu_calibrate (struct mt76x2_dev *dev,enum mcu_calibration type,u32 param);int mt76x2_mcu_tssi_comp (struct mt76x2_dev *dev,struct mt76x2_tssi_comp *tssi_data);
Signature · 1 line
2.14.3
RFC 3/18 mt76x2: move utility routines in mt76x2.h
In reply to Lorenzo BianconiIn order to reuse them supporting mt76x2u based devices, move mt76x2_wait_for_mac, wait_for_wpdma and mt76x2_channel_silent in mt76x2.h
--- drivers/net/wireless/mediatek/mt76/mt76x2.h | 40 ++++++++++++++++++++++++ drivers/net/wireless/mediatek/mt76/mt76x2_init.c | 28 ----------------- drivers/net/wireless/mediatek/mt76/mt76x2_phy.c | 9 ------ 3 files changed, 40 insertions(+), 37 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x2.h +40 -0
@@ -148,6 +148,23 @@ struct mt76x2_sta {int n_frames; }; +static inline bool mt76x2_wait_for_mac (struct mt76x2_dev *dev) +{ +int i; + +for (i =0 ; i <500 ; i++) { +switch (mt76_rr (dev,MT_MAC_CSR0 )) { +case 0 : +case ~0 : +break ; +default : +return true; + } +usleep_range (5000 ,10000 ); + } +return false; +} +static inline bool is_mt7612 (struct mt76x2_dev *dev) {return mt76_chip (&dev->mt76) ==0x7612 ;
@@ -155,6 +172,14 @@ static inline bool is_mt7612(struct mt76x2_dev *dev)void mt76x2_set_irq_mask (struct mt76x2_dev *dev,u32 clear,u32 set); +static inline bool mt76x2_channel_silent (struct mt76x2_dev *dev) +{ +struct ieee80211_channel *chan = dev->mt76.chandef.chan; + +return ((chan->flags &IEEE80211_CHAN_RADAR ) && + chan->dfs_state !=NL80211_DFS_AVAILABLE ); +} +static inline void mt76x2_irq_enable (struct mt76x2_dev *dev,u32 mask) {mt76x2_set_irq_mask (dev,0 , mask);
@@ -165,6 +190,21 @@ static inline void mt76x2_irq_disable(struct mt76x2_dev *dev, u32 mask)mt76x2_set_irq_mask (dev, mask,0 ); } +static inline bool mt76x2_wait_for_bbp (struct mt76x2_dev *dev) +{ +return mt76_poll_msec (dev,MT_MAC_STATUS , +MT_MAC_STATUS_TX |MT_MAC_STATUS_RX , +0 ,100 ); +} + +static inline bool wait_for_wpdma (struct mt76x2_dev *dev) +{ +return mt76_poll (dev,MT_WPDMA_GLO_CFG , +MT_WPDMA_GLO_CFG_TX_DMA_BUSY | +MT_WPDMA_GLO_CFG_RX_DMA_BUSY , +0 ,1000 ); +} +extern const struct ieee80211_ops mt76x2_ops;struct mt76x2_dev *mt76x2_alloc_device (struct device *pdev);
drivers/net/wireless/mediatek/mt76/mt76x2_init.c +0 -28
@@ -24,34 +24,6 @@ struct mt76x2_reg_pair {u32 value; }; -static bool -mt76x2_wait_for_mac (struct mt76x2_dev *dev) -{ -int i; - -for (i =0 ; i <500 ; i++) { -switch (mt76_rr (dev,MT_MAC_CSR0 )) { -case 0 : -case ~0 : -break ; -default : -return true; - } -usleep_range (5000 ,10000 ); - } - -return false; -} - -static bool -wait_for_wpdma (struct mt76x2_dev *dev) -{ -return mt76_poll (dev,MT_WPDMA_GLO_CFG , -MT_WPDMA_GLO_CFG_TX_DMA_BUSY | -MT_WPDMA_GLO_CFG_RX_DMA_BUSY , -0 ,1000 ); -} -static void mt76x2_mac_pbf_init (struct mt76x2_dev *dev) {
drivers/net/wireless/mediatek/mt76/mt76x2_phy.c +0 -9
@@ -176,15 +176,6 @@ void mt76x2_phy_set_txpower(struct mt76x2_dev *dev) mt76x2_tx_power_mask(t.ht[6], t.vht[8], t.vht[8], 0)); } -static bool -mt76x2_channel_silent (struct mt76x2_dev *dev) -{ -struct ieee80211_channel *chan = dev->mt76.chandef.chan; - -return ((chan->flags &IEEE80211_CHAN_RADAR ) && - chan->dfs_state !=NL80211_DFS_AVAILABLE ); -} -static bool mt76x2_phy_tssi_init_cal (struct mt76x2_dev *dev) {
Signature · 1 line
2.14.3
RFC 4/18 mt76x2: introduce mt76x2_init_device routine
In reply to Lorenzo BianconiAdd mt76x2_init_device routine in order to reuse common pcie/usb mac80211 initialization code supporting mt76x2u based device
--- drivers/net/wireless/mediatek/mt76/mt76x2.h | 1 + drivers/net/wireless/mediatek/mt76/mt76x2_init.c | 58 +++++++++++++----------- 2 files changed, 33 insertions(+), 26 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x2.h +1 -0
@@ -210,6 +210,7 @@ extern const struct ieee80211_ops mt76x2_ops;struct mt76x2_dev *mt76x2_alloc_device (struct device *pdev);int mt76x2_register_device (struct mt76x2_dev *dev);void mt76x2_init_debugfs (struct mt76x2_dev *dev); +void mt76x2_init_device (struct mt76x2_dev *dev);irqreturn_t mt76x2_irq_handler (int irq,void *dev_instance);void mt76x2_phy_power_on (struct mt76x2_dev *dev);
drivers/net/wireless/mediatek/mt76/mt76x2_init.c +32 -26
93 lines not on this page · raw message
Signature · 1 line
2.14.3
RFC 5/18 mt76x2: move currently mt76x2u unsupported features to mt76x2_init
In reply to Lorenzo BianconiMove currently mt76x2u hw unsupported features to mt76x2_init in order to reuse mt76_register_device routine supporting mt76x2u based chipsets
--- drivers/net/wireless/mediatek/mt76/mac80211.c | 15 --------------- drivers/net/wireless/mediatek/mt76/mt76x2_init.c | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 15 deletions(-)
drivers/net/wireless/mediatek/mt76/mac80211.c +0 -15
@@ -284,14 +284,6 @@ int mt76_register_device(struct mt76_dev *dev, bool vht,SET_IEEE80211_DEV (hw, dev->dev);SET_IEEE80211_PERM_ADDR (hw, dev->macaddr); - wiphy->interface_modes = - BIT(NL80211_IFTYPE_STATION) | - BIT(NL80211_IFTYPE_AP) | -#ifdef CONFIG_MAC80211_MESH -BIT (NL80211_IFTYPE_MESH_POINT ) | -#endif -BIT (NL80211_IFTYPE_ADHOC ); - wiphy->features |=NL80211_FEATURE_ACTIVE_MONITOR ; wiphy->available_antennas_tx = dev->antenna_mask;
@@ -301,17 +293,10 @@ int mt76_register_device(struct mt76_dev *dev, bool vht, hw->max_tx_fragments =16 ;ieee80211_hw_set (hw,SIGNAL_DBM ); -ieee80211_hw_set (hw,PS_NULLFUNC_STACK ); -ieee80211_hw_set (hw,HOST_BROADCAST_PS_BUFFERING );ieee80211_hw_set (hw,AMPDU_AGGREGATION );ieee80211_hw_set (hw,SUPPORTS_RC_TABLE );ieee80211_hw_set (hw,SUPPORT_FAST_XMIT ); -ieee80211_hw_set (hw,SUPPORTS_CLONED_SKBS ); -ieee80211_hw_set (hw,SUPPORTS_AMSDU_IN_AMPDU ); -ieee80211_hw_set (hw,TX_AMSDU ); -ieee80211_hw_set (hw,TX_FRAG_LIST );ieee80211_hw_set (hw,MFP_CAPABLE ); -ieee80211_hw_set (hw,AP_LINK_PS ); wiphy->flags |=WIPHY_FLAG_IBSS_RSN ;
drivers/net/wireless/mediatek/mt76/mt76x2_init.c +16 -0
@@ -831,6 +831,14 @@ int mt76x2_register_device(struct mt76x2_dev *dev) wiphy->reg_notifier = mt76x2_regd_notifier; + wiphy->interface_modes = + BIT(NL80211_IFTYPE_STATION) | + BIT(NL80211_IFTYPE_AP) | +#ifdef CONFIG_MAC80211_MESH +BIT (NL80211_IFTYPE_MESH_POINT ) | +#endif +BIT (NL80211_IFTYPE_ADHOC ); +wiphy_ext_feature_set (wiphy,NL80211_EXT_FEATURE_VHT_IBSS );mt76x2_dfs_init_detector (dev);
@@ -839,6 +847,14 @@ int mt76x2_register_device(struct mt76x2_dev *dev) dev->mt76.led_cdev.brightness_set = mt76x2_led_set_brightness; dev->mt76.led_cdev.blink_set = mt76x2_led_set_blink; +ieee80211_hw_set (hw,PS_NULLFUNC_STACK ); +ieee80211_hw_set (hw,HOST_BROADCAST_PS_BUFFERING ); +ieee80211_hw_set (hw,SUPPORTS_CLONED_SKBS ); +ieee80211_hw_set (hw,SUPPORTS_AMSDU_IN_AMPDU ); +ieee80211_hw_set (hw,TX_AMSDU ); +ieee80211_hw_set (hw,TX_FRAG_LIST ); +ieee80211_hw_set (hw,AP_LINK_PS ); + ret =mt76_register_device (&dev->mt76, true, mt76x2_rates,ARRAY_SIZE (mt76x2_rates));if (ret)
Signature · 1 line
2.14.3
RFC 6/18 mt76x2: introduce mt76x2_mac_load_tx_status routine
In reply to Lorenzo BianconiAdd mt76x2_mac_load_tx_status routine since tx stats register map is shared between usb and pci based devices but usb devices do not have a tx stat irq line as pcie ones and it is necessary to load tx statistics using a workqueue
--- drivers/net/wireless/mediatek/mt76/mt76x2_mac.c | 43 +++++++++++++++---------- 1 file changed, 26 insertions(+), 17 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x2_mac.c +26 -17
@@ -515,6 +515,28 @@ mt76x2_send_tx_status(struct mt76x2_dev *dev, struct mt76x2_tx_status *stat,rcu_read_unlock (); } +static struct mt76x2_tx_status +mt76x2_mac_load_tx_status (struct mt76x2_dev *dev) +{ +struct mt76x2_tx_status stat = {}; +u32 stat1, stat2; + + stat2 =mt76_rr (dev,MT_TX_STAT_FIFO_EXT ); + stat1 =mt76_rr (dev,MT_TX_STAT_FIFO ); + + stat.valid = !!(stat1 &MT_TX_STAT_FIFO_VALID ); + stat.success = !!(stat1 &MT_TX_STAT_FIFO_SUCCESS ); + stat.aggr = !!(stat1 &MT_TX_STAT_FIFO_AGGR ); + stat.ack_req = !!(stat1 &MT_TX_STAT_FIFO_ACKREQ ); + stat.wcid =FIELD_GET (MT_TX_STAT_FIFO_WCID , stat1); + stat.rate =FIELD_GET (MT_TX_STAT_FIFO_RATE , stat1); + + stat.retry =FIELD_GET (MT_TX_STAT_FIFO_EXT_RETRY , stat2); + stat.pktid =FIELD_GET (MT_TX_STAT_FIFO_EXT_PKTID , stat2); + +return stat; +} +void mt76x2_mac_poll_tx_status (struct mt76x2_dev *dev,bool irq) {struct mt76x2_tx_status stat = {};
@@ -527,26 +549,13 @@ void mt76x2_mac_poll_tx_status(struct mt76x2_dev *dev, bool irq)trace_mac_txstat_poll (dev);while (!irq || !kfifo_is_full (&dev->txstatus_fifo)) { -u32 stat1, stat2; -spin_lock_irqsave (&dev->irq_lock, flags); - stat2 =mt76_rr (dev,MT_TX_STAT_FIFO_EXT ); - stat1 =mt76_rr (dev,MT_TX_STAT_FIFO ); -if (!(stat1 &MT_TX_STAT_FIFO_VALID )) { -spin_unlock_irqrestore (&dev->irq_lock, flags); -break ; - } - + stat =mt76x2_mac_load_tx_status (dev);spin_unlock_irqrestore (&dev->irq_lock, flags); - stat.valid =1 ; - stat.success = !!(stat1 &MT_TX_STAT_FIFO_SUCCESS ); - stat.aggr = !!(stat1 &MT_TX_STAT_FIFO_AGGR ); - stat.ack_req = !!(stat1 &MT_TX_STAT_FIFO_ACKREQ ); - stat.wcid =FIELD_GET (MT_TX_STAT_FIFO_WCID , stat1); - stat.rate =FIELD_GET (MT_TX_STAT_FIFO_RATE , stat1); - stat.retry =FIELD_GET (MT_TX_STAT_FIFO_EXT_RETRY , stat2); - stat.pktid =FIELD_GET (MT_TX_STAT_FIFO_EXT_PKTID , stat2); +if (!stat.valid) +break ; +trace_mac_txstat_fetch (dev, &stat);if (!irq) {
Signature · 1 line
2.14.3
Re: [RFC 06/18] mt76x2: introduce mt76x2_mac_load_tx_status routine
Quoted 30 lines · Lorenzo Bianconi
Add
mt76x2_mac_load_tx_statusroutine since tx stats register map is shared between usb and pci based devices but usb devices do not have a tx stat irq line as pcie ones and it is necessary to load tx statistics using a workqueueSigned-off-by Lorenzo Bianconi <[email protected]>--- drivers/net/wireless/mediatek/mt76/mt76x2_mac.c | 43 +++++++++++++++---------- 1 file changed, 26 insertions(+), 17 deletions(-)drivers/net/wireless/mediatek/mt76/mt76x2_mac.c +12
-0@@ -515,6 +515,28 @@ mt76x2_send_tx_status(struct mt76x2_dev *dev, struct mt76x2_tx_status *stat,rcu_read_unlock (); } +static struct mt76x2_tx_status +mt76x2_mac_load_tx_status (struct mt76x2_dev *dev) +{ +struct mt76x2_tx_status stat = {}; +u32 stat1, stat2; + + stat2 =mt76_rr (dev,MT_TX_STAT_FIFO_EXT ); + stat1 =mt76_rr (dev,MT_TX_STAT_FIFO ); + + stat.valid = !!(stat1 &MT_TX_STAT_FIFO_VALID ); + stat.success = !!(stat1 &MT_TX_STAT_FIFO_SUCCESS ); + stat.aggr = !!(stat1 &MT_TX_STAT_FIFO_AGGR );
drivers/net/wireless/mediatek/mt76/mt76x2_mac.c mt76x2_send_tx_status(struct mt76x2_dev *dev, struct mt76x2_tx_status *stat, · line 539
Quoted 10 lines
drivers/net/wireless/mediatek/mt76/mt76x2_mac.c +10
-0+ stat.ack_req = !!(stat1 &MT_TX_STAT_FIFO_ACKREQ ); + stat.wcid =FIELD_GET (MT_TX_STAT_FIFO_WCID , stat1); + stat.rate =FIELD_GET (MT_TX_STAT_FIFO_RATE , stat1); + + stat.retry =FIELD_GET (MT_TX_STAT_FIFO_EXT_RETRY , stat2); + stat.pktid =FIELD_GET (MT_TX_STAT_FIFO_EXT_PKTID , stat2); + +return stat; +} +
Just two minor points. We do not need fill structure if stat is not valid. Also returning mt76x2_tx_status structure might require full copy of it. Returning boolean indicator of validity and pass pointer to struct mt76x2_tx_status to the subroutine would be more efficient.
Regards
Stanislaw
Re: [RFC 06/18] mt76x2: introduce mt76x2_mac_load_tx_status routine
Quoted 48 lines · Lorenzo Bianconi
Quoted 30 lines
Add
mt76x2_mac_load_tx_statusroutine since tx stats register map is shared between usb and pci based devices but usb devices do not have a tx stat irq line as pcie ones and it is necessary to load tx statistics using a workqueueSigned-off-by Lorenzo Bianconi <[email protected]>--- drivers/net/wireless/mediatek/mt76/mt76x2_mac.c | 43 +++++++++++++++---------- 1 file changed, 26 insertions(+), 17 deletions(-)drivers/net/wireless/mediatek/mt76/mt76x2_mac.c +12
-0@@ -515,6 +515,28 @@ mt76x2_send_tx_status(struct mt76x2_dev *dev, struct mt76x2_tx_status *stat,rcu_read_unlock (); } +static struct mt76x2_tx_status +mt76x2_mac_load_tx_status (struct mt76x2_dev *dev) +{ +struct mt76x2_tx_status stat = {}; +u32 stat1, stat2; + + stat2 =mt76_rr (dev,MT_TX_STAT_FIFO_EXT ); + stat1 =mt76_rr (dev,MT_TX_STAT_FIFO ); + + stat.valid = !!(stat1 &MT_TX_STAT_FIFO_VALID ); + stat.success = !!(stat1 &MT_TX_STAT_FIFO_SUCCESS ); + stat.aggr = !!(stat1 &MT_TX_STAT_FIFO_AGGR );drivers/net/wireless/mediatek/mt76/mt76x2_mac.c mt76x2_send_tx_status(struct mt76x2_dev *dev, struct mt76x2_tx_status *stat, · line 539
Quoted 10 lines
drivers/net/wireless/mediatek/mt76/mt76x2_mac.c +10
-0+ stat.ack_req = !!(stat1 &MT_TX_STAT_FIFO_ACKREQ ); + stat.wcid =FIELD_GET (MT_TX_STAT_FIFO_WCID , stat1); + stat.rate =FIELD_GET (MT_TX_STAT_FIFO_RATE , stat1); + + stat.retry =FIELD_GET (MT_TX_STAT_FIFO_EXT_RETRY , stat2); + stat.pktid =FIELD_GET (MT_TX_STAT_FIFO_EXT_PKTID , stat2); + +return stat; +} +Just two minor points. We do not need fill structure if stat is not valid. Also returning
mt76x2_tx_statusstructure might require full copy of it. Returning boolean indicator of validity and pass pointer to structmt76x2_tx_statusto the subroutine would be more efficient.
Quoted 2 lines
Regards
Stanislaw
I agree, thx for the review. I will address your suggestions in v1.
Regards,
Lorenzo
RFC 7/18 mt76x2: add napi struct to mt76_rx_poll_complete/mt76_rx_complete signatures
In reply to Lorenzo Bianconiin order to reuse mt76_rx_complete routine supporting mt76x2u based devices add napi struct to mt76_rx_poll_complete and mt76_rx_complete routine signatures and do not fetch it according to the rx queue index
--- drivers/net/wireless/mediatek/mt76/agg-rx.c | 2 +- drivers/net/wireless/mediatek/mt76/dma.c | 2 +- drivers/net/wireless/mediatek/mt76/mac80211.c | 12 +++++------- drivers/net/wireless/mediatek/mt76/mt76.h | 5 +++-- 4 files changed, 10 insertions(+), 11 deletions(-)
drivers/net/wireless/mediatek/mt76/agg-rx.c +1 -1
@@ -113,7 +113,7 @@ mt76_rx_aggr_reorder_work(struct work_struct *work)if (nframes)ieee80211_queue_delayed_work (tid->dev->hw, &tid->reorder_work,REORDER_TIMEOUT ); -mt76_rx_complete (dev, &frames,-1 ); +mt76_rx_complete (dev, &frames,NULL );rcu_read_unlock ();local_bh_enable ();
drivers/net/wireless/mediatek/mt76/dma.c +1 -1
@@ -396,7 +396,7 @@ mt76_dma_rx_poll(struct napi_struct *napi, int budget)do { cur =mt76_dma_rx_process (dev, &dev->q_rx[qid], budget - done); -mt76_rx_poll_complete (dev, qid); +mt76_rx_poll_complete (dev, qid, napi); done += cur; }while (cur && done < budget);
drivers/net/wireless/mediatek/mt76/mac80211.c +5 -7
@@ -537,15 +537,11 @@ mt76_check_ps(struct mt76_dev *dev, struct sk_buff *skb) }void mt76_rx_complete (struct mt76_dev *dev,struct sk_buff_head *frames, -int queue) +struct napi_struct *napi) { -struct napi_struct *napi =NULL ;struct ieee80211_sta *sta;struct sk_buff *skb; -if (queue >=0 ) - napi = &dev->napi[queue]; -spin_lock (&dev->rx_lock);while ((skb =__skb_dequeue (frames)) !=NULL ) {if (mt76_check_ccmp_pn (skb)) {
@@ -559,7 +555,8 @@ void mt76_rx_complete(struct mt76_dev *dev, struct sk_buff_head *frames,spin_unlock (&dev->rx_lock); } -void mt76_rx_poll_complete (struct mt76_dev *dev,enum mt76_rxq_id q) +void mt76_rx_poll_complete (struct mt76_dev *dev,enum mt76_rxq_id q, +struct napi_struct *napi) {struct sk_buff_head frames;struct sk_buff *skb;
@@ -571,5 +568,6 @@ void mt76_rx_poll_complete(struct mt76_dev *dev, enum mt76_rxq_id q)mt76_rx_aggr_reorder (skb, &frames); } -mt76_rx_complete (dev, &frames, q); +mt76_rx_complete (dev, &frames, napi); } +EXPORT_SYMBOL_GPL (mt76_rx_poll_complete);
drivers/net/wireless/mediatek/mt76/mt76.h +3 -2
@@ -439,8 +439,9 @@ void mt76_wcid_key_setup(struct mt76_dev *dev, struct mt76_wcid *wcid,void mt76_tx_free (struct mt76_dev *dev);void mt76_put_txwi (struct mt76_dev *dev,struct mt76_txwi_cache *t);void mt76_rx_complete (struct mt76_dev *dev,struct sk_buff_head *frames, -int queue); -void mt76_rx_poll_complete (struct mt76_dev *dev,enum mt76_rxq_id q); +struct napi_struct *napi); +void mt76_rx_poll_complete (struct mt76_dev *dev,enum mt76_rxq_id q, +struct napi_struct *napi);void mt76_rx_aggr_reorder (struct sk_buff *skb,struct sk_buff_head *frames);#endif
Signature · 1 line
2.14.3
RFC 8/18 mt76x2: add buffer len to mt76x2_mac_write_txwi signature
In reply to Lorenzo BianconiAdd frame length to mt76x2_mac_write_txwi routine signature and do not fetch it from skb since txwi data structure is added at the beginning of the skb for usb based devices and mt76x2_mac_write_txwi will be shared between pci and usb related code
--- drivers/net/wireless/mediatek/mt76/mt76x2_mac.c | 6 +++--- drivers/net/wireless/mediatek/mt76/mt76x2_mac.h | 2 +- drivers/net/wireless/mediatek/mt76/mt76x2_tx.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x2_mac.c +3 -3
@@ -167,7 +167,7 @@ void mt76x2_mac_wcid_set_rate(struct mt76x2_dev *dev, struct mt76_wcid *wcid,void mt76x2_mac_write_txwi (struct mt76x2_dev *dev,struct mt76x2_txwi *txwi,struct sk_buff *skb,struct mt76_wcid *wcid, -struct ieee80211_sta *sta) +struct ieee80211_sta *sta,int len) {struct ieee80211_tx_info *info =IEEE80211_SKB_CB (skb);struct ieee80211_tx_rate *rate = &info->control.rates[0 ];
@@ -254,7 +254,7 @@ void mt76x2_mac_write_txwi(struct mt76x2_dev *dev, struct mt76x2_txwi *txwi, txwi_flags |=MT_TXWI_FLAGS_TS ; txwi->flags |=cpu_to_le16 (txwi_flags); - txwi->len_ctl =cpu_to_le16 (skb->len); + txwi->len_ctl =cpu_to_le16 (len); }static void mt76x2_remove_hdr_pad (struct sk_buff *skb,int len)
@@ -711,7 +711,7 @@ mt76_write_beacon(struct mt76x2_dev *dev, int offset, struct sk_buff *skb)if (WARN_ON_ONCE (beacon_len < skb->len +sizeof (struct mt76x2_txwi )))return -ENOSPC ; -mt76x2_mac_write_txwi (dev, &txwi, skb,NULL ,NULL ); +mt76x2_mac_write_txwi (dev, &txwi, skb,NULL ,NULL , skb->len);mt76_wr_copy (dev, offset, &txwi,sizeof (txwi)); offset +=sizeof (txwi);
drivers/net/wireless/mediatek/mt76/mt76x2_mac.h +1 -1
@@ -166,7 +166,7 @@ int mt76x2_mac_process_rx(struct mt76x2_dev *dev, struct sk_buff *skb, void *rxi);void mt76x2_mac_write_txwi (struct mt76x2_dev *dev,struct mt76x2_txwi *txwi,struct sk_buff *skb,struct mt76_wcid *wcid, -struct ieee80211_sta *sta); +struct ieee80211_sta *sta,int len);void mt76x2_mac_wcid_setup (struct mt76x2_dev *dev,u8 idx,u8 vif_idx,u8 *mac);int mt76x2_mac_wcid_set_key (struct mt76x2_dev *dev,u8 idx,struct ieee80211_key_conf *key);
drivers/net/wireless/mediatek/mt76/mt76x2_tx.c +1 -1
@@ -159,7 +159,7 @@ int mt76x2_tx_prepare_skb(struct mt76_dev *mdev, void *txwi,if (q == &dev->mt76.q_tx[MT_TXQ_PSD ] && wcid && wcid->idx <128 )mt76x2_mac_wcid_set_drop (dev, wcid->idx, false); -mt76x2_mac_write_txwi (dev, txwi, skb, wcid, sta); +mt76x2_mac_write_txwi (dev, txwi, skb, wcid, sta, skb->len); ret =mt76x2_insert_hdr_pad (skb);if (ret <0 )
Signature · 1 line
2.14.3
RFC 9/18 mt76: introduce tx_queue_skb function pointer in mt76_bus_ops
In reply to Lorenzo BianconiAdd tx_queue_skb function pointer in mt76_bus_ops since mt76x2u based devices do not map mt76x2_txwi on dma buffers and it is not possible to reuse mt76_tx_queue_skb() routine to enqueue tx frames to hw buffers
--- drivers/net/wireless/mediatek/mt76/dma.c | 1 + drivers/net/wireless/mediatek/mt76/mt76.h | 5 +++++ drivers/net/wireless/mediatek/mt76/tx.c | 9 +++++---- 3 files changed, 11 insertions(+), 4 deletions(-)
drivers/net/wireless/mediatek/mt76/dma.c +1 -0
@@ -432,6 +432,7 @@ static const struct mt76_queue_ops mt76_dma_ops = { .init = mt76_dma_init, .alloc = mt76_dma_alloc_queue, .add_buf = mt76_dma_add_buf, + .tx_queue_skb = mt76_tx_queue_skb, .tx_cleanup = mt76_dma_tx_cleanup, .rx_reset = mt76_dma_rx_reset, .kick = mt76_dma_kick_queue,
drivers/net/wireless/mediatek/mt76/mt76.h +5 -0
@@ -30,6 +30,7 @@#define MT_RX_BUF_SIZE 2048struct mt76_dev ; +struct mt76_wcid ;struct mt76_bus_ops {u32 (*rr)(struct mt76_dev *dev,u32 offset);
@@ -110,6 +111,10 @@ struct mt76_queue_ops { struct mt76_queue_buf *buf, int nbufs, u32 info, struct sk_buff *skb, void *txwi); +int (*tx_queue_skb)(struct mt76_dev *dev,struct mt76_queue *q, +struct sk_buff *skb,struct mt76_wcid *wcid, +struct ieee80211_sta *sta); +void *(*dequeue)(struct mt76_dev *dev,struct mt76_queue *q,bool flush,int *len,u32 *info,bool *more);
drivers/net/wireless/mediatek/mt76/tx.c +5 -4
@@ -185,7 +185,7 @@ mt76_tx(struct mt76_dev *dev, struct ieee80211_sta *sta, q = &dev->q_tx[qid];spin_lock_bh (&q->lock); -mt76_tx_queue_skb (dev, q, skb, wcid, sta); + dev->queue_ops->tx_queue_skb (dev, q, skb, wcid, sta); dev->queue_ops->kick (dev, q);if (q->queued > q->ndesc -8 )
@@ -241,7 +241,7 @@ mt76_queue_ps_skb(struct mt76_dev *dev, struct ieee80211_sta *sta, info->flags |=IEEE80211_TX_STATUS_EOSP ;mt76_skb_set_moredata (skb, !last); -mt76_tx_queue_skb (dev, hwq, skb, wcid, sta); + dev->queue_ops->tx_queue_skb (dev, hwq, skb, wcid, sta); }void
@@ -321,7 +321,7 @@ mt76_txq_send_burst(struct mt76_dev *dev, struct mt76_queue *hwq,if (ampdu)mt76_check_agg_ssn (mtxq, skb); - idx =mt76_tx_queue_skb (dev, hwq, skb, wcid, txq->sta); + idx = dev->queue_ops->tx_queue_skb (dev, hwq, skb, wcid, txq->sta);if (idx <0 )return idx;
@@ -356,7 +356,8 @@ mt76_txq_send_burst(struct mt76_dev *dev, struct mt76_queue *hwq,if (cur_ampdu)mt76_check_agg_ssn (mtxq, skb); - idx =mt76_tx_queue_skb (dev, hwq, skb, wcid, txq->sta); + idx = dev->queue_ops->tx_queue_skb (dev, hwq, skb, wcid, + txq->sta);if (idx <0 )return idx;
Signature · 1 line
2.14.3
RFC 10/18 mt76: introduce mt76x2-common module
In reply to Lorenzo BianconiIn order to remove usb dependency from pcie code, add mt76x2-common as a container of shared code between mt76x2 and mt76x2u. Add eeprom code to mt76x2-common module
--- drivers/net/wireless/mediatek/mt76/Kconfig | 4 ++++ drivers/net/wireless/mediatek/mt76/Makefile | 6 +++++- drivers/net/wireless/mediatek/mt76/mt76x2_eeprom.c | 13 +++++++++++-- drivers/net/wireless/mediatek/mt76/mt76x2_eeprom.h | 1 + 4 files changed, 21 insertions(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/Kconfig +4 -0
@@ -1,9 +1,13 @@ config MT76_CORE tristate +config MT76x2_COMMON + tristate + config MT76x2E tristate "MediaTek MT76x2E (PCIe) support" select MT76_CORE + select MT76x2_COMMON depends on MAC80211 depends on PCI ---help---
drivers/net/wireless/mediatek/mt76/Makefile +5 -1
@@ -1,4 +1,5 @@ obj-$(CONFIG_MT76_CORE) += mt76.o +obj-$(CONFIG_MT76x2_COMMON) += mt76x2-common.o obj-$(CONFIG_MT76x2E) += mt76x2e.o mt76-y := \
@@ -6,10 +7,13 @@ mt76-y := \ CFLAGS_trace.o := -I$(src) +mt76x2-common-y := \ + mt76x2_eeprom.o + mt76x2e-y := \ mt76x2_pci.o mt76x2_dma.o \ mt76x2_main.o mt76x2_init.o mt76x2_debugfs.o mt76x2_tx.o \ - mt76x2_core.o mt76x2_mac.o mt76x2_eeprom.o mt76x2_mcu.o mt76x2_phy.o \ + mt76x2_core.o mt76x2_mac.o mt76x2_mcu.o mt76x2_phy.o \ mt76x2_dfs.o mt76x2_trace.o CFLAGS_mt76x2_trace.o := -I$(src)
drivers/net/wireless/mediatek/mt76/mt76x2_eeprom.c +11 -2
@@ -40,8 +40,7 @@ mt76x2_eeprom_get_macaddr(struct mt76x2_dev *dev)return 0 ; } -static void -mt76x2_eeprom_parse_hw_cap (struct mt76x2_dev *dev) +void mt76x2_eeprom_parse_hw_cap (struct mt76x2_dev *dev) {u16 val =mt76x2_eeprom_get (dev,MT_EE_NIC_CONF_0 );
@@ -58,6 +57,7 @@ mt76x2_eeprom_parse_hw_cap(struct mt76x2_dev *dev)break ; } } +EXPORT_SYMBOL_GPL (mt76x2_eeprom_parse_hw_cap);static int mt76x2_efuse_read (struct mt76x2_dev *dev,u16 addr,u8 *data)
@@ -415,6 +415,7 @@ void mt76x2_read_rx_gain(struct mt76x2_dev *dev) dev->cal.rx.lna_gain =mt76x2_sign_extend (lna,8 ); } +EXPORT_SYMBOL_GPL (mt76x2_read_rx_gain);static s8 mt76x2_rate_power_val (u8 val)
@@ -482,6 +483,7 @@ void mt76x2_get_rate_power(struct mt76x2_dev *dev, struct mt76_rate_power *t, val >>=8 ; t->vht[8 ] = t->vht[9 ] =mt76x2_rate_power_val (val >>8 ); } +EXPORT_SYMBOL_GPL (mt76x2_get_rate_power);int mt76x2_get_max_rate_power (struct mt76_rate_power *r) {
@@ -493,6 +495,7 @@ int mt76x2_get_max_rate_power(struct mt76_rate_power *r)return ret; } +EXPORT_SYMBOL_GPL (mt76x2_get_max_rate_power); static void mt76x2_get_power_info_2g(struct mt76x2_dev *dev, struct mt76x2_tx_power_info *t,
@@ -600,6 +603,7 @@ void mt76x2_get_power_info(struct mt76x2_dev *dev, t->delta_bw40 =mt76x2_rate_power_val (bw40); t->delta_bw80 =mt76x2_rate_power_val (bw80); } +EXPORT_SYMBOL_GPL (mt76x2_get_power_info);int mt76x2_get_temp_comp (struct mt76x2_dev *dev,struct mt76x2_temp_comp *t) {
@@ -632,6 +636,7 @@ int mt76x2_get_temp_comp(struct mt76x2_dev *dev, struct mt76x2_temp_comp *t)return 0 ; } +EXPORT_SYMBOL_GPL (mt76x2_get_temp_comp);bool mt76x2_ext_pa_enabled (struct mt76x2_dev *dev,enum nl80211_band band) {
@@ -642,6 +647,7 @@ bool mt76x2_ext_pa_enabled(struct mt76x2_dev *dev, enum nl80211_band band)else return !(conf0 &MT_EE_NIC_CONF_0_PA_INT_2G ); } +EXPORT_SYMBOL_GPL (mt76x2_ext_pa_enabled);int mt76x2_eeprom_init (struct mt76x2_dev *dev) {
@@ -658,3 +664,6 @@ int mt76x2_eeprom_init(struct mt76x2_dev *dev)return 0 ; } +EXPORT_SYMBOL_GPL (mt76x2_eeprom_init); + +MODULE_LICENSE ("Dual BSD/GPL" );
drivers/net/wireless/mediatek/mt76/mt76x2_eeprom.h +1 -0
@@ -155,6 +155,7 @@ void mt76x2_get_power_info(struct mt76x2_dev *dev,int mt76x2_get_temp_comp (struct mt76x2_dev *dev,struct mt76x2_temp_comp *t);bool mt76x2_ext_pa_enabled (struct mt76x2_dev *dev,enum nl80211_band band);void mt76x2_read_rx_gain (struct mt76x2_dev *dev); +void mt76x2_eeprom_parse_hw_cap (struct mt76x2_dev *dev);static inline bool mt76x2_temp_tx_alc_enabled (struct mt76x2_dev *dev)
Signature · 1 line
2.14.3
RFC 11/18 mt76: add mt76x2_tx_common to mt76x2-common module
In reply to Lorenzo BianconiMove tx related code shared between mt76x2 and mt76x2u in mt76x2-common module
--- drivers/net/wireless/mediatek/mt76/Makefile | 2 +- drivers/net/wireless/mediatek/mt76/mt76x2.h | 2 + drivers/net/wireless/mediatek/mt76/mt76x2_tx.c | 123 ----------------- .../net/wireless/mediatek/mt76/mt76x2_tx_common.c | 149 +++++++++++++++++++++ 4 files changed, 152 insertions(+), 124 deletions(-) create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x2_tx_common.c
drivers/net/wireless/mediatek/mt76/Makefile +1 -1
@@ -8,7 +8,7 @@ mt76-y := \ CFLAGS_trace.o := -I$(src) mt76x2-common-y := \ - mt76x2_eeprom.o + mt76x2_eeprom.o mt76x2_tx_common.o mt76x2e-y := \ mt76x2_pci.o mt76x2_dma.o \
drivers/net/wireless/mediatek/mt76/mt76x2.h +2 -0
@@ -268,4 +268,6 @@ s8 mt76x2_tx_get_max_txpwr_adj(struct mt76x2_dev *dev,s8 mt76x2_tx_get_txpwr_adj (struct mt76x2_dev *dev,s8 txpwr,s8 max_txpwr_adj);void mt76x2_tx_set_txpwr_auto (struct mt76x2_dev *dev,s8 txpwr); +int mt76x2_insert_hdr_pad (struct sk_buff *skb); +#endif
drivers/net/wireless/mediatek/mt76/mt76x2_tx.c +0 -123
129 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt76x2_tx_common.c new file +149 -0
149 lines not on this page · raw message
Signature · 1 line
2.14.3
RFC 12/18 mt76: add mt76x2_mac_common to mt76x2-common module
In reply to Lorenzo BianconiMove mac related code shared between mt76x2 and mt76x2u in mt76x2-common module
--- drivers/net/wireless/mediatek/mt76/Makefile | 2 +- drivers/net/wireless/mediatek/mt76/mt76x2.h | 6 +- drivers/net/wireless/mediatek/mt76/mt76x2_mac.c | 607 ------------------- .../net/wireless/mediatek/mt76/mt76x2_mac_common.c | 642 +++++++++++++++++++++ 4 files changed, 648 insertions(+), 609 deletions(-) create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x2_mac_common.c
drivers/net/wireless/mediatek/mt76/Makefile +1 -1
@@ -8,7 +8,7 @@ mt76-y := \ CFLAGS_trace.o := -I$(src) mt76x2-common-y := \ - mt76x2_eeprom.o mt76x2_tx_common.o + mt76x2_eeprom.o mt76x2_tx_common.o mt76x2_mac_common.o mt76x2e-y := \ mt76x2_pci.o mt76x2_dma.o \
drivers/net/wireless/mediatek/mt76/mt76x2.h +5 -1
@@ -224,7 +224,7 @@ void mt76x2_phy_set_antenna(struct mt76x2_dev *dev);int mt76x2_phy_start (struct mt76x2_dev *dev);int mt76x2_phy_set_channel (struct mt76x2_dev *dev,struct cfg80211_chan_def *chandef); -int mt76x2_phy_get_rssi (struct mt76x2_dev *dev,s8 rssi,int chain); +int mt76x2_mac_get_rssi (struct mt76x2_dev *dev,s8 rssi,int chain);void mt76x2_phy_calibrate (struct work_struct *work);void mt76x2_phy_set_txpower (struct mt76x2_dev *dev);
@@ -270,4 +270,8 @@ void mt76x2_tx_set_txpwr_auto(struct mt76x2_dev *dev, s8 txpwr);int mt76x2_insert_hdr_pad (struct sk_buff *skb); +struct mt76x2_tx_status mt76x2_mac_load_tx_status (struct mt76x2_dev *dev); +void mt76x2_send_tx_status (struct mt76x2_dev *dev, +struct mt76x2_tx_status *stat,u8 *update); +#endif
drivers/net/wireless/mediatek/mt76/mt76x2_mac.c +0 -607
619 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt76x2_mac_common.c new file +642 -0
642 lines not on this page · raw message
Signature · 1 line
2.14.3
RFC 13/18 mt76: add mt76x2_init_common to mt76x2-common module
In reply to Lorenzo BianconiMove init related code shared between mt76x2 and mt76x2u in mt76x2-common module
--- drivers/net/wireless/mediatek/mt76/Makefile | 3 +- drivers/net/wireless/mediatek/mt76/mt76x2.h | 6 + drivers/net/wireless/mediatek/mt76/mt76x2_init.c | 232 ------------------- .../wireless/mediatek/mt76/mt76x2_init_common.c | 253 +++++++++++++++++++++ 4 files changed, 261 insertions(+), 233 deletions(-) create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x2_init_common.c
drivers/net/wireless/mediatek/mt76/Makefile +2 -1
@@ -8,7 +8,8 @@ mt76-y := \ CFLAGS_trace.o := -I$(src) 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 mt76x2e-y := \ mt76x2_pci.o mt76x2_dma.o \
drivers/net/wireless/mediatek/mt76/mt76x2.h +6 -0
@@ -207,6 +207,8 @@ static inline bool wait_for_wpdma(struct mt76x2_dev *dev)extern const struct ieee80211_ops mt76x2_ops; +extern struct ieee80211_rate mt76x2_rates[12 ]; +struct mt76x2_dev *mt76x2_alloc_device (struct device *pdev);int mt76x2_register_device (struct mt76x2_dev *dev);void mt76x2_init_debugfs (struct mt76x2_dev *dev);
@@ -273,5 +275,9 @@ int mt76x2_insert_hdr_pad(struct sk_buff *skb);struct mt76x2_tx_status mt76x2_mac_load_tx_status (struct mt76x2_dev *dev);void mt76x2_send_tx_status (struct mt76x2_dev *dev,struct mt76x2_tx_status *stat,u8 *update); +void mt76x2_reset_wlan (struct mt76x2_dev *dev,bool enable); +void mt76x2_init_txpower (struct mt76x2_dev *dev, +struct ieee80211_supported_band *sband); +void mt76_write_mac_initvals (struct mt76x2_dev *dev);#endif
drivers/net/wireless/mediatek/mt76/mt76x2_init.c +0 -232
262 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt76x2_init_common.c new file +253 -0
253 lines not on this page · raw message
Signature · 1 line
2.14.3
RFC 14/18 mt76: add mt76x2_common to mt76x2-common module
In reply to Lorenzo BianconiMove core related code shared between mt76x2 and mt76x2u in mt76x2-common module
--- drivers/net/wireless/mediatek/mt76/Makefile | 2 +- drivers/net/wireless/mediatek/mt76/mt76x2.h | 21 ++ drivers/net/wireless/mediatek/mt76/mt76x2_common.c | 348 +++++++++++++++++++++ drivers/net/wireless/mediatek/mt76/mt76x2_dma.c | 21 -- drivers/net/wireless/mediatek/mt76/mt76x2_main.c | 305 ------------------ 5 files changed, 370 insertions(+), 327 deletions(-) create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x2_common.c
drivers/net/wireless/mediatek/mt76/Makefile +1 -1
@@ -9,7 +9,7 @@ CFLAGS_trace.o := -I$(src) mt76x2-common-y := \ mt76x2_eeprom.o mt76x2_tx_common.o mt76x2_mac_common.o \ - mt76x2_init_common.o + mt76x2_init_common.o mt76x2_common.o mt76x2e-y := \ mt76x2_pci.o mt76x2_dma.o \
drivers/net/wireless/mediatek/mt76/mt76x2.h +21 -0
@@ -280,4 +280,25 @@ void mt76x2_init_txpower(struct mt76x2_dev *dev, struct ieee80211_supported_band *sband);void mt76_write_mac_initvals (struct mt76x2_dev *dev); +int mt76x2_ampdu_action (struct ieee80211_hw *hw,struct ieee80211_vif *vif, +struct ieee80211_ampdu_params *params); +int mt76x2_sta_add (struct ieee80211_hw *hw,struct ieee80211_vif *vif, +struct ieee80211_sta *sta); +int mt76x2_sta_remove (struct ieee80211_hw *hw,struct ieee80211_vif *vif, +struct ieee80211_sta *sta); +void mt76x2_remove_interface (struct ieee80211_hw *hw, +struct ieee80211_vif *vif); +int mt76x2_set_key (struct ieee80211_hw *hw,enum set_key_cmd cmd, +struct ieee80211_vif *vif,struct ieee80211_sta *sta, +struct ieee80211_key_conf *key); +int mt76x2_conf_tx (struct ieee80211_hw *hw,struct ieee80211_vif *vif, +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_sta_rate_tbl_update (struct ieee80211_hw *hw, +struct ieee80211_vif *vif, +struct ieee80211_sta *sta); +#endif
drivers/net/wireless/mediatek/mt76/mt76x2_common.c new file +348 -0
348 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt76x2_dma.c +0 -21
@@ -66,27 +66,6 @@ mt76x2_init_tx_queue(struct mt76x2_dev *dev, struct mt76_queue *q,return 0 ; } -void mt76x2_queue_rx_skb (struct mt76_dev *mdev,enum mt76_rxq_id q, -struct sk_buff *skb) -{ - struct mt76x2_dev *dev = container_of(mdev, struct mt76x2_dev, mt76); -void *rxwi = skb->data; - -if (q ==MT_RXQ_MCU ) { -skb_queue_tail (&dev->mcu.res_q, skb); -complete (&dev->mcu.resp_cmpl); -return ; - } - -skb_pull (skb,sizeof (struct mt76x2_rxwi )); -if (mt76x2_mac_process_rx (dev, skb, rxwi)) { -dev_kfree_skb (skb); -return ; - } - -mt76_rx (&dev->mt76, q, skb); -} -static int mt76x2_init_rx_queue (struct mt76x2_dev *dev,struct mt76_queue *q,int idx,int n_desc,int bufsize)
drivers/net/wireless/mediatek/mt76/mt76x2_main.c +0 -305
341 lines not on this page · raw message
Signature · 1 line
2.14.3
RFC 15/18 mt76: add mt76x2_phy_common to mt76x2-common module
In reply to Lorenzo BianconiMove phy related code shared between mt76x2 and mt76x2u in mt76x2-common module
--- drivers/net/wireless/mediatek/mt76/Makefile | 2 +- drivers/net/wireless/mediatek/mt76/mt76x2.h | 8 + drivers/net/wireless/mediatek/mt76/mt76x2_phy.c | 281 ------------------- .../net/wireless/mediatek/mt76/mt76x2_phy_common.c | 302 +++++++++++++++++++++ 4 files changed, 311 insertions(+), 282 deletions(-) create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x2_phy_common.c
drivers/net/wireless/mediatek/mt76/Makefile +1 -1
@@ -9,7 +9,7 @@ CFLAGS_trace.o := -I$(src) mt76x2-common-y := \ mt76x2_eeprom.o mt76x2_tx_common.o mt76x2_mac_common.o \ - mt76x2_init_common.o mt76x2_common.o + mt76x2_init_common.o mt76x2_common.o mt76x2_phy_common.o mt76x2e-y := \ mt76x2_pci.o mt76x2_dma.o \
drivers/net/wireless/mediatek/mt76/mt76x2.h +8 -0
@@ -301,4 +301,12 @@ void mt76x2_sta_rate_tbl_update(struct ieee80211_hw *hw,struct ieee80211_vif *vif, struct ieee80211_sta *sta); +void mt76x2_phy_set_txpower_regs (struct mt76x2_dev *dev, +enum nl80211_band band); +void mt76x2_configure_tx_delay (struct mt76x2_dev *dev, +enum nl80211_band band,u8 bw); +void mt76x2_phy_set_bw (struct mt76x2_dev *dev,int width,u8 ctrl); +void mt76x2_phy_set_band (struct mt76x2_dev *dev,int band,bool primary_upper); +void mt76x2_apply_gain_adj (struct mt76x2_dev *dev); +#endif
drivers/net/wireless/mediatek/mt76/mt76x2_phy.c +0 -281
299 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt76x2_phy_common.c new file +302 -0
302 lines not on this page · raw message
Signature · 1 line
2.14.3
RFC 16/18 mt76: move mt76x2_debugfs in mt76-common module
In reply to Lorenzo BianconiMove mt76x2_debugfs code in mt76-common module since it is shared between mt76x2 and mt76x2u
--- drivers/net/wireless/mediatek/mt76/Makefile | 5 +++-- drivers/net/wireless/mediatek/mt76/mt76x2_debugfs.c | 1 + 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/Makefile +3 -2
@@ -9,11 +9,12 @@ CFLAGS_trace.o := -I$(src) mt76x2-common-y := \ 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 \ + mt76x2_debugfs.o mt76x2e-y := \ mt76x2_pci.o mt76x2_dma.o \ - mt76x2_main.o mt76x2_init.o mt76x2_debugfs.o mt76x2_tx.o \ + mt76x2_main.o mt76x2_init.o mt76x2_tx.o \ mt76x2_core.o mt76x2_mac.o mt76x2_mcu.o mt76x2_phy.o \ mt76x2_dfs.o mt76x2_trace.o
drivers/net/wireless/mediatek/mt76/mt76x2_debugfs.c +1 -0
@@ -131,3 +131,4 @@ void mt76x2_init_debugfs(struct mt76x2_dev *dev)debugfs_create_devm_seqfile (dev->mt76.dev,"txpower" , dir, read_txpower); } +EXPORT_SYMBOL_GPL (mt76x2_init_debugfs);
Signature · 1 line
2.14.3
RFC 17/18 mt76: add usb suppor to mt76 layer
In reply to Lorenzo BianconiThis will be used by drivers for MT76x2u based devices
--- drivers/net/wireless/mediatek/mt76/Makefile | 3 +- drivers/net/wireless/mediatek/mt76/dma.h | 5 + drivers/net/wireless/mediatek/mt76/mt76.h | 114 +++++- drivers/net/wireless/mediatek/mt76/usb.c | 593 ++++++++++++++++++++++++++++ 4 files changed, 713 insertions(+), 2 deletions(-) create mode 100644 drivers/net/wireless/mediatek/mt76/usb.c
drivers/net/wireless/mediatek/mt76/Makefile +2 -1
@@ -3,7 +3,8 @@ obj-$(CONFIG_MT76x2_COMMON) += mt76x2-common.o obj-$(CONFIG_MT76x2E) += mt76x2e.o mt76-y := \ - mmio.o util.o trace.o dma.o mac80211.o debugfs.o eeprom.o tx.o agg-rx.o + mmio.o util.o trace.o dma.o mac80211.o debugfs.o eeprom.o \ + tx.o agg-rx.o usb.o CFLAGS_trace.o := -I$(src)
drivers/net/wireless/mediatek/mt76/dma.h +5 -0
@@ -25,6 +25,11 @@#define MT_DMA_CTL_LAST_SEC0 BIT(30)#define MT_DMA_CTL_DMA_DONE BIT(31) +#define MT_DMA_HDR_LEN 4 +#define MT_RX_INFO_LEN 4 +#define MT_FCE_INFO_LEN 4 +#define MT_RX_RXWI_LEN 32 +struct mt76_desc {__le32 buf0;__le32 ctrl;
drivers/net/wireless/mediatek/mt76/mt76.h +113 -1
165 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/usb.c new file +593 -0
593 lines not on this page · raw message
Signature · 1 line
2.14.3
RFC 18/18 mt76: add driver code for MT76x2u based devices
In reply to Lorenzo BianconiMT76x2u is a 2x2 USB 802.11ac chipset by MediaTek. This driver currently support station mode. Frequency calibration is currently not supported
--- drivers/net/wireless/mediatek/mt76/Kconfig | 9 + drivers/net/wireless/mediatek/mt76/Makefile | 5 + drivers/net/wireless/mediatek/mt76/mt76x2.h | 5 + drivers/net/wireless/mediatek/mt76/mt76x2_regs.h | 35 ++ drivers/net/wireless/mediatek/mt76/mt76x2_usb.c | 85 +++ drivers/net/wireless/mediatek/mt76/mt76x2u.h | 93 ++++ drivers/net/wireless/mediatek/mt76/mt76x2u_core.c | 194 +++++++ drivers/net/wireless/mediatek/mt76/mt76x2u_init.c | 302 ++++++++++ drivers/net/wireless/mediatek/mt76/mt76x2u_mac.c | 237 ++++++++ drivers/net/wireless/mediatek/mt76/mt76x2u_main.c | 161 ++++++ drivers/net/wireless/mediatek/mt76/mt76x2u_mcu.c | 648 ++++++++++++++++++++++ drivers/net/wireless/mediatek/mt76/mt76x2u_phy.c | 264 +++++++++ 12 files changed, 2038 insertions(+) create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x2_usb.c create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x2u.h create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x2u_core.c create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x2u_init.c create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x2u_mac.c create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x2u_main.c create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x2u_mcu.c create mode 100644 drivers/net/wireless/mediatek/mt76/mt76x2u_phy.c
drivers/net/wireless/mediatek/mt76/Kconfig +9 -0
@@ -12,3 +12,12 @@ config MT76x2E depends on PCI ---help--- This adds support for MT7612/MT7602/MT7662-based wireless PCIe devices. + +config MT76x2U + tristate "MediaTek MT76x2U (USB) support" + select MT76_CORE + select MT76x2_COMMON + depends on MAC80211 + depends on USB + help + This adds support for MT7612U-based wireless USB dongles.
drivers/net/wireless/mediatek/mt76/Makefile +5 -0
@@ -1,6 +1,7 @@ obj-$(CONFIG_MT76_CORE) += mt76.o obj-$(CONFIG_MT76x2_COMMON) += mt76x2-common.o obj-$(CONFIG_MT76x2E) += mt76x2e.o +obj-$(CONFIG_MT76x2U) += mt76x2u.o mt76-y := \ mmio.o util.o trace.o dma.o mac80211.o debugfs.o eeprom.o \
@@ -19,4 +20,8 @@ mt76x2e-y := \ mt76x2_core.o mt76x2_mac.o mt76x2_mcu.o mt76x2_phy.o \ mt76x2_dfs.o mt76x2_trace.o +mt76x2u-y := \ + mt76x2_usb.o mt76x2u_init.o mt76x2u_main.o mt76x2u_mac.o \ + mt76x2u_mcu.o mt76x2u_phy.o mt76x2u_core.o + CFLAGS_mt76x2_trace.o := -I$(src)
drivers/net/wireless/mediatek/mt76/mt76x2.h +5 -0
@@ -32,6 +32,9 @@#define MT7662_ROM_PATCH "mt7662_rom_patch.bin"#define MT7662_EEPROM_SIZE 512 +#define MT7662U_FIRMWARE "mt7662u.bin" +#define MT7662U_ROM_PATCH "mt7662u_rom_patch.bin" +#define MT76x2_RX_RING_SIZE 256#define MT_RX_HEADROOM 32
@@ -49,6 +52,7 @@ struct mt76x2_mcu {struct completion resp_cmpl;struct sk_buff_head res_q; +struct mt76_usb_buf res_u;u32 msg_seq; };
@@ -102,6 +106,7 @@ struct mt76x2_dev {struct tasklet_struct tx_tasklet;struct tasklet_struct pre_tbtt_tasklet; +struct delayed_work stat_work;struct delayed_work cal_work;struct delayed_work mac_work;
drivers/net/wireless/mediatek/mt76/mt76x2_regs.h +35 -0
@@ -75,6 +75,21 @@#define MT_XO_CTRL7 0x011c +#define MT_USB_U3DMA_CFG 0x9018 +#define MT_USB_DMA_CFG_RX_BULK_AGG_TOUT GENMASK(7, 0) +#define MT_USB_DMA_CFG_RX_BULK_AGG_LMT GENMASK(15, 8) +#define MT_USB_DMA_CFG_UDMA_TX_WL_DROP BIT(16) +#define MT_USB_DMA_CFG_WAKE_UP_EN BIT(17) +#define MT_USB_DMA_CFG_RX_DROP_OR_PAD BIT(18) +#define MT_USB_DMA_CFG_TX_CLR BIT(19) +#define MT_USB_DMA_CFG_TXOP_HALT BIT(20) +#define MT_USB_DMA_CFG_RX_BULK_AGG_EN BIT(21) +#define MT_USB_DMA_CFG_RX_BULK_EN BIT(22) +#define MT_USB_DMA_CFG_TX_BULK_EN BIT(23) +#define MT_USB_DMA_CFG_EP_OUT_VALID GENMASK(29, 24) +#define MT_USB_DMA_CFG_RX_BUSY BIT(30) +#define MT_USB_DMA_CFG_TX_BUSY BIT(31) +#define MT_WLAN_MTC_CTRL 0x10148#define MT_WLAN_MTC_CTRL_MTCMOS_PWR_UP BIT(0)#define MT_WLAN_MTC_CTRL_PWR_ACK BIT(12)
@@ -141,6 +156,9 @@#define MT_WMM_TXOP_SHIFT (_n) ((_n & 1) * 16)#define MT_WMM_TXOP_MASK GENMASK(15, 0) +#define MT_FCE_DMA_ADDR 0x0230 +#define MT_FCE_DMA_LEN 0x0234 +#define MT_TSO_CTRL 0x0250#define MT_HEADER_TRANS_CTRL_REG 0x0260
@@ -150,6 +168,9 @@#define MT_TX_HW_QUEUE_MCU 8#define MT_TX_HW_QUEUE_MGMT 9 +#define MT_US_CYC_CFG 0x02a4 +#define MT_US_CYC_CNT GENMASK(7, 0) +#define MT_PBF_SYS_CTRL 0x0400#define MT_PBF_SYS_CTRL_MCU_RESET BIT(0)#define MT_PBF_SYS_CTRL_DMA_RESET BIT(1)
@@ -202,6 +223,13 @@#define MT_FCE_WLAN_FLOW_CONTROL1 0x0824 +#define MT_TX_CPU_FROM_FCE_BASE_PTR 0x09a0 +#define MT_TX_CPU_FROM_FCE_MAX_COUNT 0x09a4 +#define MT_FCE_PDMA_GLOBAL_CONF 0x09c4 +#define MT_FCE_SKIP_FS 0x0a6c + +#define MT_TX_CPU_FROM_FCE_CPU_DESC_IDX 0x09a8 +#define MT_PAUSE_ENABLE_CONTROL1 0x0a38#define MT_MAC_CSR0 0x1000
@@ -214,6 +242,7 @@#define MT_MAC_ADDR_DW0 0x1008#define MT_MAC_ADDR_DW1 0x100c +#define MT_MAC_ADDR_DW1_U2ME_MASK GENMASK(23, 16)#define MT_MAC_BSSID_DW0 0x1010#define MT_MAC_BSSID_DW1 0x1014
@@ -351,6 +380,7 @@#define MT_TX_TIMEOUT_CFG_ACKTO GENMASK(15, 8)#define MT_TX_RETRY_CFG 0x134c +#define MT_TX_LINK_CFG 0x1350#define MT_VHT_HT_FBK_CFG1 0x1358#define MT_PROT_CFG_RATE GENMASK(15, 0)
@@ -425,6 +455,7 @@#define MT_RX_FILTR_CFG_BAR BIT(15)#define MT_RX_FILTR_CFG_CTRL_RSV BIT(16) +#define MT_AUTO_RSP_CFG 0x1404#define MT_LEGACY_BASIC_RATE 0x1408#define MT_HT_BASIC_RATE 0x140c
@@ -460,6 +491,10 @@#define MT_RX_STAT_2_DUP_ERRORS GENMASK(15, 0)#define MT_RX_STAT_2_OVERFLOW_ERRORS GENMASK(31, 16) +#define MT_TX_STA_0 0x170c +#define MT_TX_STA_1 0x1710 +#define MT_TX_STA_2 0x1714 +#define MT_TX_STAT_FIFO 0x1718#define MT_TX_STAT_FIFO_VALID BIT(0)#define MT_TX_STAT_FIFO_SUCCESS BIT(5)
drivers/net/wireless/mediatek/mt76/mt76x2_usb.c new file +85 -0
85 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt76x2u.h new file +93 -0
93 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt76x2u_core.c new file +194 -0
194 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt76x2u_init.c new file +302 -0
302 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt76x2u_mac.c new file +237 -0
237 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt76x2u_main.c new file +161 -0
161 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt76x2u_mcu.c new file +648 -0
648 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt76x2u_phy.c new file +264 -0
264 lines not on this page · raw message
Signature · 1 line
2.14.3