mt76: mt7996: remove some duplicated code
Subsystems (2)
Lorenzo Bianconi
maintainercover mt76: mt7996: remove some duplicated code
Remove some duplicated code from mt7996 driver that is already available in mt76_connac shared library.
Please note this series is just compiled tested.
Lorenzo Bianconi (4):
wifi: mt76: mt7996: rely on mt76_connac_txp_common structure
wifi: mt76: mt7996: rely on mt76_connac_txp_skb_unmap
wifi: mt76: mt7996: rely on mt76_connac_tx_complete_skb
wifi: mt76: mt7996: rely on mt76_connac2_mac_decode_he_radiotap
.../wireless/mediatek/mt76/mt76_connac_mac.c | 3 +- .../net/wireless/mediatek/mt76/mt7996/mac.c | 240 ++---------------- .../net/wireless/mediatek/mt76/mt7996/mac.h | 24 -- .../net/wireless/mediatek/mt76/mt7996/mmio.c | 4 +- .../wireless/mediatek/mt76/mt7996/mt7996.h | 1 - 5 files changed, 20 insertions(+), 252 deletions(-)
Signature · 1 line
2.39.0
Lorenzo Bianconi
maintainerPATCH 1/4 wifi: mt76: mt7996: rely on mt76_connac_txp_common structure
mt7996_txp structure is equal to mt76_connac_fw_txp one. Drop mt7996_txp and rely on mt76_connac_txp_common.
--- .../net/wireless/mediatek/mt76/mt7996/mac.c | 38 +++++++++---------- .../net/wireless/mediatek/mt76/mt7996/mac.h | 15 +------- .../net/wireless/mediatek/mt76/mt7996/mmio.c | 2 +- 3 files changed, 22 insertions(+), 33 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7996/mac.c +19 -19
@@ -1069,8 +1069,8 @@ int mt7996_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,struct ieee80211_tx_info *info =IEEE80211_SKB_CB (tx_info->skb);struct ieee80211_key_conf *key = info->control.hw_key;struct ieee80211_vif *vif = info->control.vif; +struct mt76_connac_txp_common *txp;struct mt76_txwi_cache *t; -struct mt7996_txp *txp;int id, i, pid, nbuf = tx_info->nbuf -1 ;bool is_8023 = info->flags &IEEE80211_TX_CTL_HW_80211_ENCAP ;u8 *txwi = (u8 *)txwi_ptr;
@@ -1104,35 +1104,35 @@ int mt7996_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,mt7996_mac_write_txwi (dev, txwi_ptr, tx_info->skb, wcid, pid, key,0 ); - txp = (struct mt7996_txp *)(txwi +MT_TXD_SIZE ); + txp = (struct mt76_connac_txp_common *)(txwi +MT_TXD_SIZE );for (i =0 ; i < nbuf; i++) { - txp->buf[i] =cpu_to_le32 (tx_info->buf[i +1 ].addr); - txp->len[i] =cpu_to_le16 (tx_info->buf[i +1 ].len); + txp->fw.buf[i] =cpu_to_le32 (tx_info->buf[i +1 ].addr); + txp->fw.len[i] =cpu_to_le16 (tx_info->buf[i +1 ].len); } - txp->nbuf = nbuf; + txp->fw.nbuf = nbuf; - txp->flags =cpu_to_le16 (MT_CT_INFO_FROM_HOST ); + txp->fw.flags =cpu_to_le16 (MT_CT_INFO_FROM_HOST );if (!is_8023 || pid >=MT_PACKET_ID_FIRST ) - txp->flags |=cpu_to_le16 (MT_CT_INFO_APPLY_TXD ); + txp->fw.flags |=cpu_to_le16 (MT_CT_INFO_APPLY_TXD );if (!key) - txp->flags |=cpu_to_le16 (MT_CT_INFO_NONE_CIPHER_FRAME ); + txp->fw.flags |=cpu_to_le16 (MT_CT_INFO_NONE_CIPHER_FRAME );if (!is_8023 &&ieee80211_is_mgmt (hdr->frame_control)) - txp->flags |=cpu_to_le16 (MT_CT_INFO_MGMT_FRAME ); + txp->fw.flags |=cpu_to_le16 (MT_CT_INFO_MGMT_FRAME );if (vif) {struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; - txp->bss_idx = mvif->mt76.idx; + txp->fw.bss_idx = mvif->mt76.idx; } - txp->token =cpu_to_le16 (id); + txp->fw.token =cpu_to_le16 (id);if (test_bit (MT_WCID_FLAG_4ADDR , &wcid->flags)) - txp->rept_wds_wcid =cpu_to_le16 (wcid->idx); + txp->fw.rept_wds_wcid =cpu_to_le16 (wcid->idx);else - txp->rept_wds_wcid =cpu_to_le16 (0xfff ); + txp->fw.rept_wds_wcid =cpu_to_le16 (0xfff ); tx_info->skb =DMA_DUMMY_DATA ;/* pass partial skb header to fw */
@@ -1171,13 +1171,13 @@ mt7996_tx_check_aggr(struct ieee80211_sta *sta, __le32 *txwi)static void mt7996_txp_skb_unmap (struct mt76_dev *dev,struct mt76_txwi_cache *t) { -struct mt7996_txp *txp; +struct mt76_connac_txp_common *txp;int i; txp =mt7996_txwi_to_txp (dev, t); -for (i =0 ; i < txp->nbuf; i++) -dma_unmap_single (dev->dev,le32_to_cpu (txp->buf[i]), -le16_to_cpu (txp->len[i]),DMA_TO_DEVICE ); +for (i =0 ; i < txp->fw.nbuf; i++) +dma_unmap_single (dev->dev,le32_to_cpu (txp->fw.buf[i]), +le16_to_cpu (txp->fw.len[i]),DMA_TO_DEVICE ); } static void
@@ -1554,11 +1554,11 @@ void mt7996_tx_complete_skb(struct mt76_dev *mdev, struct mt76_queue_entry *e)/* error path */ if (e->skb ==DMA_DUMMY_DATA ) { +struct mt76_connac_txp_common *txp;struct mt76_txwi_cache *t; -struct mt7996_txp *txp; txp =mt7996_txwi_to_txp (mdev, e->txwi); - t =mt76_token_put (mdev,le16_to_cpu (txp->token)); + t =mt76_token_put (mdev,le16_to_cpu (txp->fw.token)); e->skb = t ? t->skb :NULL ; }
drivers/net/wireless/mediatek/mt76/mt7996/mac.h +2 -13
@@ -268,17 +268,6 @@ enum tx_mgnt_type {/* VHT/HE only use bits 0-3 */ #define MT_TX_RATE_IDX GENMASK(5, 0) -struct mt7996_txp { -__le16 flags; -__le16 token; -u8 bss_idx; -__le16 rept_wds_wcid; -u8 nbuf; -#define MT_TXP_MAX_BUF_NUM 6 -__le32 buf[MT_TXP_MAX_BUF_NUM ]; -__le16 len[MT_TXP_MAX_BUF_NUM ]; -} __packed__aligned(4) ; -#define MT_TXFREE0_PKT_TYPE GENMASK(31, 27)#define MT_TXFREE0_MSDU_CNT GENMASK(25, 16)#define MT_TXFREE0_RX_BYTE GENMASK(15, 0)
@@ -382,7 +371,7 @@ struct mt7996_dfs_radar_spec {struct mt7996_dfs_pattern radar_pattern[16 ]; }; -static inline struct mt7996_txp * +static inline struct mt76_connac_txp_common *mt7996_txwi_to_txp (struct mt76_dev *dev,struct mt76_txwi_cache *t) {u8 *txwi;
@@ -392,7 +381,7 @@ mt7996_txwi_to_txp(struct mt76_dev *dev, struct mt76_txwi_cache *t) txwi =mt76_get_txwi_ptr (dev, t); - return (struct mt7996_txp *)(txwi + MT_TXD_SIZE); + return (struct mt76_connac_txp_common *)(txwi + MT_TXD_SIZE); }#endif
drivers/net/wireless/mediatek/mt76/mt7996/mmio.c +1 -1
@@ -317,7 +317,7 @@ struct mt7996_dev *mt7996_mmio_probe(struct device *pdev, { static const struct mt76_driver_ops drv_ops = { /* txwi_size = txd size + txp size */ - .txwi_size = MT_TXD_SIZE + sizeof(struct mt7996_txp), + .txwi_size = MT_TXD_SIZE + sizeof(struct mt76_connac_fw_txp), .drv_flags = MT_DRV_TXWI_NO_FREE | MT_DRV_HW_MGMT_TXQ, .survey_flags = SURVEY_INFO_TIME_TX |
Signature · 1 line
2.39.0
Lorenzo Bianconi
maintainerPATCH 2/4 wifi: mt76: mt7996: rely on mt76_connac_txp_skb_unmap
In reply to Lorenzo BianconiDrop mt7996_txp_skb_unmap routine since it is equivalent to mt76_connac_txp_skb_unmap().
--- drivers/net/wireless/mediatek/mt76/mt7996/mac.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7996/mac.c +1 -13
@@ -1168,18 +1168,6 @@ mt7996_tx_check_aggr(struct ieee80211_sta *sta, __le32 *txwi)ieee80211_start_tx_ba_session (sta, tid,0 ); } -static void -mt7996_txp_skb_unmap (struct mt76_dev *dev,struct mt76_txwi_cache *t) -{ -struct mt76_connac_txp_common *txp; -int i; - - txp =mt7996_txwi_to_txp (dev, t); -for (i =0 ; i < txp->fw.nbuf; i++) -dma_unmap_single (dev->dev,le32_to_cpu (txp->fw.buf[i]), -le16_to_cpu (txp->fw.len[i]),DMA_TO_DEVICE ); -} -static void mt7996_txwi_free (struct mt7996_dev *dev,struct mt76_txwi_cache *t,struct ieee80211_sta *sta,struct list_head *free_list)
@@ -1189,7 +1177,7 @@ mt7996_txwi_free(struct mt7996_dev *dev, struct mt76_txwi_cache *t,__le32 *txwi;u16 wcid_idx; -mt7996_txp_skb_unmap (mdev, t); +mt76_connac_txp_skb_unmap (mdev, t);if (!t->skb) goto out;
Signature · 1 line
2.39.0
Lorenzo Bianconi
maintainerPATCH 4/4 wifi: mt76: mt7996: rely on mt76_connac2_mac_decode_he_radiotap
In reply to Lorenzo BianconiRely on connac library for radiotap parsing and drop the following routines:
- mt7996_mac_decode_he_radiotap
- mt7996_mac_decode_he_mu_radiotap
- mt7996_mac_decode_he_radiotap_ru
--- .../wireless/mediatek/mt76/mt76_connac_mac.c | 3 +- .../net/wireless/mediatek/mt76/mt7996/mac.c | 179 +----------------- 2 files changed, 4 insertions(+), 178 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c +2 -1
@@ -823,6 +823,7 @@ void mt76_connac2_mac_decode_he_radiotap(struct mt76_dev *dev, HE_BITS(DATA2_TXOP_KNOWN), };u32 ltf_size =le32_get_bits (rxv[2 ],MT_CRXV_HE_LTF_SIZE ) +1 ; +u32 txbf_mask =is_mt7996 (dev) ?BIT (11 ) :BIT (10 );struct ieee80211_radiotap_he *he; status->flag |=RX_FLAG_RADIOTAP_HE ;
@@ -836,7 +837,7 @@ void mt76_connac2_mac_decode_he_radiotap(struct mt76_dev *dev, he->data5 =HE_PREP (DATA5_PE_DISAMBIG ,PE_DISAMBIG , rxv[2 ]) |le16_encode_bits (ltf_size,IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE ); -if (le32_to_cpu (rxv[0 ]) &MT_PRXV_TXBF ) +if (le32_to_cpu (rxv[0 ]) & txbf_mask) he->data5 |=HE_BITS (DATA5_TXBF ); he->data6 =HE_PREP (DATA6_TXOP ,TXOP_DUR , rxv[14 ]) |HE_PREP (DATA6_DOPPLER ,DOPPLER , rxv[14 ]);
drivers/net/wireless/mediatek/mt76/mt7996/mac.c +2 -177
197 lines not on this page · raw message
Signature · 1 line
2.39.0
Lorenzo Bianconi
maintainerPATCH 3/4 wifi: mt76: mt7996: rely on mt76_connac_tx_complete_skb
In reply to Lorenzo BianconiDrop mt7996_tx_complete_skb routine since it is equivalent to mt76_connac_tx_complete_skb().
--- .../net/wireless/mediatek/mt76/mt7996/mac.c | 21 ------------------- .../net/wireless/mediatek/mt76/mt7996/mac.h | 13 ------------ .../net/wireless/mediatek/mt76/mt7996/mmio.c | 2 +- .../wireless/mediatek/mt76/mt7996/mt7996.h | 1 - 4 files changed, 1 insertion(+), 36 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7996/mac.c +0 -21
@@ -1533,27 +1533,6 @@ void mt7996_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q, } } -void mt7996_tx_complete_skb (struct mt76_dev *mdev,struct mt76_queue_entry *e) -{ -if (!e->txwi) { -dev_kfree_skb_any (e->skb); -return ; - } - -/* error path */ -if (e->skb ==DMA_DUMMY_DATA ) { -struct mt76_connac_txp_common *txp; -struct mt76_txwi_cache *t; - - txp =mt7996_txwi_to_txp (mdev, e->txwi); - t =mt76_token_put (mdev,le16_to_cpu (txp->fw.token)); - e->skb = t ? t->skb :NULL ; - } - -if (e->skb) -mt76_tx_complete_skb (mdev, e->wcid, e->skb); -} -void mt7996_mac_cca_stats_reset (struct mt7996_phy *phy) {struct mt7996_dev *dev = phy->dev;
drivers/net/wireless/mediatek/mt76/mt7996/mac.h +0 -13
@@ -371,17 +371,4 @@ struct mt7996_dfs_radar_spec { struct mt7996_dfs_pattern radar_pattern[16]; }; -static inline struct mt76_connac_txp_common * -mt7996_txwi_to_txp (struct mt76_dev *dev,struct mt76_txwi_cache *t) -{ -u8 *txwi; - -if (!t) -return NULL ; - - txwi =mt76_get_txwi_ptr (dev, t); - -return (struct mt76_connac_txp_common *)(txwi +MT_TXD_SIZE ); -} -#endif
drivers/net/wireless/mediatek/mt76/mt7996/mmio.c +1 -1
@@ -325,7 +325,7 @@ struct mt7996_dev *mt7996_mmio_probe(struct device *pdev, SURVEY_INFO_TIME_BSS_RX, .token_size = MT7996_TOKEN_SIZE, .tx_prepare_skb = mt7996_tx_prepare_skb, - .tx_complete_skb = mt7996_tx_complete_skb, + .tx_complete_skb = mt76_connac_tx_complete_skb, .rx_skb = mt7996_queue_rx_skb, .rx_check = mt7996_rx_check, .rx_poll_complete = mt7996_rx_poll_complete,
drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h +0 -1
@@ -493,7 +493,6 @@ int mt7996_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, enum mt76_txq_id qid, struct mt76_wcid *wcid, struct ieee80211_sta *sta, struct mt76_tx_info *tx_info); -void mt7996_tx_complete_skb (struct mt76_dev *mdev,struct mt76_queue_entry *e);void mt7996_tx_token_put (struct mt7996_dev *dev);void mt7996_queue_rx_skb (struct mt76_dev *mdev,enum mt76_rxq_id q,struct sk_buff *skb,u32 *info);
Signature · 1 line
2.39.0