mt76: move token management in mt76 module
Subsystems (2)
Lorenzo Bianconi
maintainercover mt76: move token management in mt76 module
Move token management in mt76 common module since it is shared between mt7615, mt7915 and mt7921 drivers
Lorenzo Bianconi (2):
mt76: move token_lock, token and token_count in mt76_dev
mt76: move token utilities in mt76 common module
drivers/net/wireless/mediatek/mt76/mt76.h | 54 +++++++++++++-- .../net/wireless/mediatek/mt76/mt7615/mac.c | 14 ++-- .../net/wireless/mediatek/mt76/mt7615/mmio.c | 1 + .../wireless/mediatek/mt76/mt7615/mt7615.h | 3 - .../wireless/mediatek/mt76/mt7615/pci_init.c | 3 +- .../wireless/mediatek/mt76/mt7615/pci_mac.c | 10 +-- .../net/wireless/mediatek/mt76/mt7915/init.c | 3 +- .../net/wireless/mediatek/mt76/mt7915/mac.c | 64 +++-------------- .../wireless/mediatek/mt76/mt7915/mt7915.h | 5 -- .../net/wireless/mediatek/mt76/mt7915/pci.c | 1 + .../net/wireless/mediatek/mt76/mt7921/init.c | 4 +- .../net/wireless/mediatek/mt76/mt7921/mac.c | 58 +++------------- .../wireless/mediatek/mt76/mt7921/mt7921.h | 5 -- .../net/wireless/mediatek/mt76/mt7921/pci.c | 1 + drivers/net/wireless/mediatek/mt76/tx.c | 68 +++++++++++++++++++ 15 files changed, 153 insertions(+), 141 deletions(-)
Signature · 1 line
2.30.2
Lorenzo Bianconi
maintainerPATCH 1/2 mt76: move token_lock, token and token_count in mt76_dev
Move token_lock, token and token_count data structures in mt76_dev. This is a preliminary patch to move token management in mt76 common module since it is shared by mt7615, mt7915 and mt7921 drivers.
--- drivers/net/wireless/mediatek/mt76/mt76.h | 4 ++ .../net/wireless/mediatek/mt76/mt7615/mac.c | 14 +++---- .../wireless/mediatek/mt76/mt7615/mt7615.h | 3 -- .../wireless/mediatek/mt76/mt7615/pci_init.c | 4 +- .../wireless/mediatek/mt76/mt7615/pci_mac.c | 14 +++---- .../net/wireless/mediatek/mt76/mt7915/init.c | 4 +- .../net/wireless/mediatek/mt76/mt7915/mac.c | 42 +++++++++---------- .../wireless/mediatek/mt76/mt7915/mt7915.h | 4 -- .../net/wireless/mediatek/mt76/mt7921/init.c | 4 +- .../net/wireless/mediatek/mt76/mt7921/mac.c | 42 +++++++++---------- .../wireless/mediatek/mt76/mt7921/mt7921.h | 4 -- 11 files changed, 66 insertions(+), 73 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76.h +4 -0
@@ -659,6 +659,10 @@ struct mt76_dev {struct mt76_worker tx_worker;struct napi_struct tx_napi; +spinlock_t token_lock; +struct idr token; +int token_count; +wait_queue_head_t tx_wait;struct sk_buff_head status_list;
drivers/net/wireless/mediatek/mt76/mt7615/mac.c +7 -7
@@ -1466,9 +1466,9 @@ mt7615_mac_tx_free_token(struct mt7615_dev *dev, u16 token)trace_mac_tx_free (dev, token); -spin_lock_bh (&dev->token_lock); - txwi =idr_remove (&dev->token, token); -spin_unlock_bh (&dev->token_lock); +spin_lock_bh (&mdev->token_lock); + txwi =idr_remove (&mdev->token, token); +spin_unlock_bh (&mdev->token_lock);if (!txwi)return ;
@@ -1977,8 +1977,8 @@ void mt7615_tx_token_put(struct mt7615_dev *dev)struct mt76_txwi_cache *txwi;int id; -spin_lock_bh (&dev->token_lock); -idr_for_each_entry (&dev->token, txwi, id) { +spin_lock_bh (&dev->mt76.token_lock); +idr_for_each_entry (&dev->mt76.token, txwi, id) {mt7615_txp_skb_unmap (&dev->mt76, txwi);if (txwi->skb) {struct ieee80211_hw *hw;
@@ -1988,8 +1988,8 @@ void mt7615_tx_token_put(struct mt7615_dev *dev) }mt76_put_txwi (&dev->mt76, txwi); } -spin_unlock_bh (&dev->token_lock); -idr_destroy (&dev->token); +spin_unlock_bh (&dev->mt76.token_lock); +idr_destroy (&dev->mt76.token); }EXPORT_SYMBOL_GPL (mt7615_tx_token_put);
drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h +0 -3
@@ -263,9 +263,6 @@ struct mt7615_dev {bool flash_eeprom;bool dbdc_support; -spinlock_t token_lock; -struct idr token; -u8 fw_ver;struct work_struct rate_work;
drivers/net/wireless/mediatek/mt76/mt7615/pci_init.c +2 -2
@@ -40,8 +40,8 @@ static int mt7615_init_hardware(struct mt7615_dev *dev)mt76_wr (dev,MT_INT_SOURCE_CSR , ~0 );INIT_WORK (&dev->mcu_work, mt7615_pci_init_work); -spin_lock_init (&dev->token_lock); -idr_init (&dev->token); +spin_lock_init (&dev->mt76.token_lock); +idr_init (&dev->mt76.token); ret =mt7615_eeprom_init (dev, addr);if (ret <0 )
drivers/net/wireless/mediatek/mt76/mt7615/pci_mac.c +7 -7
@@ -37,9 +37,9 @@ void mt7615_tx_complete_skb(struct mt76_dev *mdev, struct mt76_queue_entry *e) token =le16_to_cpu (txp->hw.msdu_id[0 ]) & ~MT_MSDU_ID_VALID ; -spin_lock_bh (&dev->token_lock); - t =idr_remove (&dev->token, token); -spin_unlock_bh (&dev->token_lock); +spin_lock_bh (&mdev->token_lock); + t =idr_remove (&mdev->token, token); +spin_unlock_bh (&mdev->token_lock); e->skb = t ? t->skb :NULL ; }
@@ -161,9 +161,9 @@ int mt7615_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, t = (struct mt76_txwi_cache *)(txwi + mdev->drv->txwi_size); t->skb = tx_info->skb; -spin_lock_bh (&dev->token_lock); - id =idr_alloc (&dev->token, t,0 ,MT7615_TOKEN_SIZE ,GFP_ATOMIC ); -spin_unlock_bh (&dev->token_lock); +spin_lock_bh (&mdev->token_lock); + id =idr_alloc (&mdev->token, t,0 ,MT7615_TOKEN_SIZE ,GFP_ATOMIC ); +spin_unlock_bh (&mdev->token_lock);if (id <0 )return id;
@@ -314,7 +314,7 @@ void mt7615_mac_reset_work(struct work_struct *work)mt7615_dma_reset (dev);mt7615_tx_token_put (dev); -idr_init (&dev->token); +idr_init (&dev->mt76.token);mt76_wr (dev,MT_WPDMA_MEM_RNG_ERR ,0 );
drivers/net/wireless/mediatek/mt76/mt7915/init.c +2 -2
@@ -351,8 +351,8 @@ static int mt7915_init_hardware(struct mt7915_dev *dev)mt76_wr (dev,MT_INT_SOURCE_CSR , ~0 );INIT_WORK (&dev->init_work, mt7915_init_work); -spin_lock_init (&dev->token_lock); -idr_init (&dev->token); +spin_lock_init (&dev->mt76.token_lock); +idr_init (&dev->mt76.token); dev->dbdc_support = !!(mt76_rr (dev,MT_HW_BOUND ) &BIT (5 ));
drivers/net/wireless/mediatek/mt76/mt7915/mac.c +21 -21
92 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +0 -4
@@ -187,10 +187,6 @@ struct mt7915_dev {u32 hw_pattern; -spinlock_t token_lock; -int token_count; -struct idr token; -bool dbdc_support;bool flash_mode;bool fw_debug;
drivers/net/wireless/mediatek/mt76/mt7921/init.c +2 -2
@@ -170,8 +170,8 @@ static int mt7921_init_hardware(struct mt7921_dev *dev) {int ret, idx; -spin_lock_init (&dev->token_lock); -idr_init (&dev->token); +spin_lock_init (&dev->mt76.token_lock); +idr_init (&dev->mt76.token); ret =mt7921_dma_init (dev);if (ret)
drivers/net/wireless/mediatek/mt76/mt7921/mac.c +21 -21
92 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h +0 -4
@@ -161,10 +161,6 @@ struct mt7921_dev {struct list_head sta_poll_list;spinlock_t sta_poll_lock; -spinlock_t token_lock; -int token_count; -struct idr token; -u8 fw_debug;struct mt76_connac_pm pm;
Signature · 1 line
2.30.2
Lorenzo Bianconi
maintainerPATCH 2/2 mt76: move token utilities in mt76 common module
In reply to Lorenzo BianconiMove token management in mt76 common module since it is shared between mt7615, mt7915 and mt7921 drivers
--- drivers/net/wireless/mediatek/mt76/mt76.h | 50 ++++++++++++-- .../net/wireless/mediatek/mt76/mt7615/mac.c | 6 +- .../net/wireless/mediatek/mt76/mt7615/mmio.c | 1 + .../wireless/mediatek/mt76/mt7615/pci_init.c | 3 +- .../wireless/mediatek/mt76/mt7615/pci_mac.c | 8 +-- .../net/wireless/mediatek/mt76/mt7915/init.c | 3 +- .../net/wireless/mediatek/mt76/mt7915/mac.c | 52 ++------------ .../wireless/mediatek/mt76/mt7915/mt7915.h | 1 - .../net/wireless/mediatek/mt76/mt7915/pci.c | 1 + .../net/wireless/mediatek/mt76/mt7921/init.c | 4 +- .../net/wireless/mediatek/mt76/mt7921/mac.c | 46 ++----------- .../wireless/mediatek/mt76/mt7921/mt7921.h | 1 - .../net/wireless/mediatek/mt76/mt7921/pci.c | 1 + drivers/net/wireless/mediatek/mt76/tx.c | 68 +++++++++++++++++++ 14 files changed, 132 insertions(+), 113 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76.h +45 -5
@@ -17,12 +17,14 @@#include "util.h" #include "testmode.h" -#define MT_MCU_RING_SIZE 32 -#define MT_RX_BUF_SIZE 2048 -#define MT_SKB_HEAD_LEN 128 +#define MT_MCU_RING_SIZE 32 +#define MT_RX_BUF_SIZE 2048 +#define MT_SKB_HEAD_LEN 128 -#define MT_MAX_NON_AQL_PKT 16 -#define MT_TXQ_FREE_THR 32 +#define MT_MAX_NON_AQL_PKT 16 +#define MT_TXQ_FREE_THR 32 + +#define MT76_TOKEN_FREE_THR 64struct mt76_dev ;struct mt76_phy ;
@@ -332,6 +334,7 @@ struct mt76_driver_ops {u32 drv_flags;u32 survey_flags;u16 txwi_size; +u16 token_size;u8 mcs_rates;void (*update_survey)(struct mt76_dev *dev);
@@ -1215,4 +1218,41 @@ s8 mt76_get_rate_power_limits(struct mt76_phy *phy,struct mt76_power_limits *dest, s8 target_power); +struct mt76_txwi_cache * +mt76_token_release (struct mt76_dev *dev,int token,bool *wake); +int mt76_token_consume (struct mt76_dev *dev,struct mt76_txwi_cache **ptxwi); +void mt76_token_init (struct mt76_dev *dev); +void __mt76_set_tx_blocked (struct mt76_dev *dev,bool blocked); + +static inline void mt76_set_tx_blocked (struct mt76_dev *dev,bool blocked) +{ +spin_lock_bh (&dev->token_lock); +__mt76_set_tx_blocked (dev, blocked); +spin_unlock_bh (&dev->token_lock); +} + +static inline int +mt76_token_get (struct mt76_dev *dev,struct mt76_txwi_cache **ptxwi) +{ +int token; + +spin_lock_bh (&dev->token_lock); + token =idr_alloc (&dev->token, *ptxwi,0 , dev->drv->token_size, +GFP_ATOMIC ); +spin_unlock_bh (&dev->token_lock); + +return token; +} + +static inline struct mt76_txwi_cache * +mt76_token_put (struct mt76_dev *dev,int token) +{ +struct mt76_txwi_cache *txwi; + +spin_lock_bh (&dev->token_lock); + txwi =idr_remove (&dev->token, token); +spin_unlock_bh (&dev->token_lock); + +return txwi; +}#endif
drivers/net/wireless/mediatek/mt76/mt7615/mac.c +1 -5
@@ -1465,11 +1465,7 @@ mt7615_mac_tx_free_token(struct mt7615_dev *dev, u16 token)u8 wcid;trace_mac_tx_free (dev, token); - -spin_lock_bh (&mdev->token_lock); - txwi =idr_remove (&mdev->token, token); -spin_unlock_bh (&mdev->token_lock); - + txwi =mt76_token_put (mdev, token);if (!txwi)return ;
drivers/net/wireless/mediatek/mt76/mt7615/mmio.c +1 -0
@@ -190,6 +190,7 @@ int mt7615_mmio_probe(struct device *pdev, void __iomem *mem_base, .survey_flags = SURVEY_INFO_TIME_TX |SURVEY_INFO_TIME_RX | SURVEY_INFO_TIME_BSS_RX, + .token_size = MT7615_TOKEN_SIZE, .tx_prepare_skb = mt7615_tx_prepare_skb, .tx_complete_skb = mt7615_tx_complete_skb, .rx_skb = mt7615_queue_rx_skb,
drivers/net/wireless/mediatek/mt76/mt7615/pci_init.c +1 -2
@@ -40,8 +40,7 @@ static int mt7615_init_hardware(struct mt7615_dev *dev)mt76_wr (dev,MT_INT_SOURCE_CSR , ~0 );INIT_WORK (&dev->mcu_work, mt7615_pci_init_work); -spin_lock_init (&dev->mt76.token_lock); -idr_init (&dev->mt76.token); +mt76_token_init (&dev->mt76); ret =mt7615_eeprom_init (dev, addr);if (ret <0 )
drivers/net/wireless/mediatek/mt76/mt7615/pci_mac.c +2 -6
@@ -37,9 +37,7 @@ void mt7615_tx_complete_skb(struct mt76_dev *mdev, struct mt76_queue_entry *e) token =le16_to_cpu (txp->hw.msdu_id[0 ]) & ~MT_MSDU_ID_VALID ; -spin_lock_bh (&mdev->token_lock); - t =idr_remove (&mdev->token, token); -spin_unlock_bh (&mdev->token_lock); + t =mt76_token_put (mdev, token); e->skb = t ? t->skb :NULL ; }
@@ -161,9 +159,7 @@ int mt7615_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, t = (struct mt76_txwi_cache *)(txwi + mdev->drv->txwi_size); t->skb = tx_info->skb; -spin_lock_bh (&mdev->token_lock); - id =idr_alloc (&mdev->token, t,0 ,MT7615_TOKEN_SIZE ,GFP_ATOMIC ); -spin_unlock_bh (&mdev->token_lock); + id =mt76_token_get (mdev, &t);if (id <0 )return id;
drivers/net/wireless/mediatek/mt76/mt7915/init.c +1 -2
@@ -351,8 +351,7 @@ static int mt7915_init_hardware(struct mt7915_dev *dev)mt76_wr (dev,MT_INT_SOURCE_CSR , ~0 );INIT_WORK (&dev->init_work, mt7915_init_work); -spin_lock_init (&dev->mt76.token_lock); -idr_init (&dev->mt76.token); +mt76_token_init (&dev->mt76); dev->dbdc_support = !!(mt76_rr (dev,MT_HW_BOUND ) &BIT (5 ));
drivers/net/wireless/mediatek/mt76/mt7915/mac.c +5 -47
82 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +0 -1
@@ -32,7 +32,6 @@#define MT7915_EEPROM_SIZE 3584#define MT7915_TOKEN_SIZE 8192 -#define MT7915_TOKEN_FREE_THR 64#define MT7915_CFEND_RATE_DEFAULT 0x49/* OFDM 24M */ #define MT7915_CFEND_RATE_11B 0x03/* 11B LP, 11M */
drivers/net/wireless/mediatek/mt76/mt7915/pci.c +1 -0
@@ -212,6 +212,7 @@ static int mt7915_pci_probe(struct pci_dev *pdev, .survey_flags = SURVEY_INFO_TIME_TX |SURVEY_INFO_TIME_RX | SURVEY_INFO_TIME_BSS_RX, + .token_size = MT7915_TOKEN_SIZE, .tx_prepare_skb = mt7915_tx_prepare_skb, .tx_complete_skb = mt7915_tx_complete_skb, .rx_skb = mt7915_queue_rx_skb,
drivers/net/wireless/mediatek/mt76/mt7921/init.c +1 -3
@@ -170,9 +170,7 @@ static int mt7921_init_hardware(struct mt7921_dev *dev) {int ret, idx; -spin_lock_init (&dev->mt76.token_lock); -idr_init (&dev->mt76.token); - +mt76_token_init (&dev->mt76); ret =mt7921_dma_init (dev);if (ret)return ret;
drivers/net/wireless/mediatek/mt76/mt7921/mac.c +5 -41
77 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h +0 -1
@@ -35,7 +35,6 @@#define MT7921_EEPROM_SIZE 3584#define MT7921_TOKEN_SIZE 8192 -#define MT7921_TOKEN_FREE_THR 64#define MT7921_CFEND_RATE_DEFAULT 0x49/* OFDM 24M */ #define MT7921_CFEND_RATE_11B 0x03/* 11B LP, 11M */
drivers/net/wireless/mediatek/mt76/mt7921/pci.c +1 -0
@@ -99,6 +99,7 @@ static int mt7921_pci_probe(struct pci_dev *pdev, .survey_flags = SURVEY_INFO_TIME_TX |SURVEY_INFO_TIME_RX | SURVEY_INFO_TIME_BSS_RX, + .token_size = MT7921_TOKEN_SIZE, .tx_prepare_skb = mt7921_tx_prepare_skb, .tx_complete_skb = mt7921_tx_complete_skb, .rx_skb = mt7921_queue_rx_skb,
drivers/net/wireless/mediatek/mt76/tx.c +68 -0
71 lines not on this page · raw message
Signature · 1 line
2.30.2