mt76: move connac txp code in shared module
Subsystems (2)
Lorenzo Bianconi
maintainercover mt76: move connac txp code in shared module
Move fw/hw txp code in mt76-connac module since it is shared between mt7915e, mt7921e and mt7615 drivers. This is a preliminary series to add mt7990e chipset support.
Lorenzo Bianconi (6):
mt76: connac: move mt76_connac_fw_txp in common module
mt76: move mt7615_txp_ptr in mt76_connac module
mt76: connac: move mt76_connac_tx_free in shared code
mt76: connac: move mt76_connac_tx_complete_skb in shared code
mt76: connac: move mt76_connac_write_hw_txp in shared code
mt76: connac: move mt7615_txp_skb_unmap in common code
.../net/wireless/mediatek/mt76/mt7615/mac.c | 63 +-------- .../net/wireless/mediatek/mt76/mt7615/mac.h | 69 ---------- .../net/wireless/mediatek/mt76/mt7615/mmio.c | 4 +- .../wireless/mediatek/mt76/mt7615/mt7615.h | 3 - .../wireless/mediatek/mt76/mt7615/pci_mac.c | 78 +---------- .../net/wireless/mediatek/mt76/mt76_connac.h | 91 ++++++++++++ .../wireless/mediatek/mt76/mt76_connac2_mac.h | 13 +- .../wireless/mediatek/mt76/mt76_connac_mac.c | 130 ++++++++++++++++++ .../net/wireless/mediatek/mt76/mt7915/mac.c | 41 +----- .../net/wireless/mediatek/mt76/mt7915/mac.h | 32 ----- .../net/wireless/mediatek/mt76/mt7915/mmio.c | 4 +- .../wireless/mediatek/mt76/mt7915/mt7915.h | 1 - .../net/wireless/mediatek/mt76/mt7921/mac.h | 68 --------- .../wireless/mediatek/mt76/mt7921/mt7921.h | 1 - .../net/wireless/mediatek/mt76/mt7921/pci.c | 4 +- .../wireless/mediatek/mt76/mt7921/pci_mac.c | 102 ++------------ 16 files changed, 257 insertions(+), 447 deletions(-)
Signature · 1 line
2.36.1
Lorenzo Bianconi
maintainerPATCH 1/6 mt76: connac: move mt76_connac_fw_txp in common module
Since mt76_connac_fw_txp struct is shared between mt7615e, mt7915e and mt7921e, move it in mt76_connac module.
--- .../net/wireless/mediatek/mt76/mt7615/mac.c | 4 +-- .../net/wireless/mediatek/mt76/mt7615/mac.h | 33 +---------------- .../wireless/mediatek/mt76/mt7615/pci_mac.c | 7 ++-- .../net/wireless/mediatek/mt76/mt76_connac.h | 35 +++++++++++++++++++ .../wireless/mediatek/mt76/mt76_connac2_mac.h | 13 +++---- .../net/wireless/mediatek/mt76/mt7915/mac.c | 14 ++++---- .../net/wireless/mediatek/mt76/mt7915/mac.h | 32 ----------------- .../net/wireless/mediatek/mt76/mt7915/mmio.c | 2 +- .../net/wireless/mediatek/mt76/mt7921/mac.h | 32 ----------------- .../wireless/mediatek/mt76/mt7921/pci_mac.c | 4 +-- 10 files changed, 59 insertions(+), 117 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7615/mac.c +2 -2
@@ -877,7 +877,7 @@ int mt7615_mac_write_txwi(struct mt7615_dev *dev, __le32 *txwi,EXPORT_SYMBOL_GPL (mt7615_mac_write_txwi);static void -mt7615_txp_skb_unmap_fw (struct mt76_dev *dev,struct mt7615_fw_txp *txp) +mt7615_txp_skb_unmap_fw (struct mt76_dev *dev,struct mt76_connac_fw_txp *txp) {int i;
@@ -922,7 +922,7 @@ void mt7615_txp_skb_unmap(struct mt76_dev *dev, {struct mt7615_txp_common *txp; - txp =mt7615_txwi_to_txp (dev, t); + txp =mt76_connac_txwi_to_txp (dev, t);if (is_mt7615 (dev))mt7615_txp_skb_unmap_fw (dev, &txp->fw);else
drivers/net/wireless/mediatek/mt76/mt7615/mac.h +1 -32
@@ -165,12 +165,6 @@ enum tx_phy_bandwidth {#define MT_CT_INFO_NONE_CIPHER_FRAME BIT(3)#define MT_CT_INFO_HSR2_TX BIT(4) -#define MT_TXD_SIZE (8 * 4) - -#define MT_USB_TXD_SIZE (MT_TXD_SIZE + 8 * 4) -#define MT_USB_HDR_SIZE 4 -#define MT_USB_TAIL_SIZE 4 -#define MT_TXD0_P_IDX BIT(31)#define MT_TXD0_Q_IDX GENMASK(30, 26)#define MT_TXD0_UDP_TCP_SUM BIT(24)
@@ -250,7 +244,6 @@ enum tx_phy_bandwidth {#define MT_TX_RATE_MODE GENMASK(8, 6)#define MT_TX_RATE_IDX GENMASK(5, 0) -#define MT_TXP_MAX_BUF_NUM 6#define MT_HW_TXP_MAX_MSDU_NUM 4#define MT_HW_TXP_MAX_BUF_NUM 4
@@ -274,20 +267,9 @@ struct mt7615_hw_txp {struct mt7615_txp_ptr ptr[MT_HW_TXP_MAX_BUF_NUM /2 ]; } __packed__aligned(4) ; -struct mt7615_fw_txp { -__le16 flags; -__le16 token; -u8 bss_idx; -u8 rept_wds_wcid; -u8 rsv; -u8 nbuf; -__le32 buf[MT_TXP_MAX_BUF_NUM ]; -__le16 len[MT_TXP_MAX_BUF_NUM ]; -} __packed__aligned(4) ; -struct mt7615_txp_common {union { -struct mt7615_fw_txp fw; +struct mt76_connac_fw_txp fw;struct mt7615_hw_txp hw; }; };
@@ -385,19 +367,6 @@ struct mt7615_dfs_radar_spec {struct mt7615_dfs_pattern radar_pattern[16 ]; }; -static inline struct mt7615_txp_common * -mt7615_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 mt7615_txp_common *)(txwi +MT_TXD_SIZE ); -} -static inline u32 mt7615_mac_wtbl_addr (struct mt7615_dev *dev,int wcid) {return MT_WTBL_BASE (dev) + wcid *MT_WTBL_ENTRY_SIZE ;
drivers/net/wireless/mediatek/mt76/mt7615/pci_mac.c +4 -3
@@ -29,7 +29,7 @@ void mt7615_tx_complete_skb(struct mt76_dev *mdev, struct mt76_queue_entry *e)u16 token; dev = container_of(mdev, struct mt7615_dev, mt76); - txp =mt7615_txwi_to_txp (mdev, e->txwi); + txp =mt76_connac_txwi_to_txp (mdev, e->txwi);if (is_mt7615 (&dev->mt76)) token =le16_to_cpu (txp->fw.token);
@@ -91,7 +91,8 @@ mt7615_write_fw_txp(struct mt7615_dev *dev, struct mt76_tx_info *tx_info,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 mt7615_fw_txp *txp = txp_ptr; +struct mt76_connac_fw_txp *txp = txp_ptr; +u8 *rept_wds_wcid = (u8 *)&txp->rept_wds_wcid;int nbuf = tx_info->nbuf -1 ;int i;
@@ -122,7 +123,7 @@ mt7615_write_fw_txp(struct mt7615_dev *dev, struct mt76_tx_info *tx_info, } txp->token =cpu_to_le16 (id); - txp->rept_wds_wcid =0xff ; + *rept_wds_wcid =0xff ; } int mt7615_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
drivers/net/wireless/mediatek/mt76/mt76_connac.h +35 -0
@@ -17,6 +17,16 @@#define MT76_CONNAC_COREDUMP_TIMEOUT (HZ / 20)#define MT76_CONNAC_COREDUMP_SZ (1300 * 1024) +#define MT_TXD_SIZE (8 * 4) + +#define MT_USB_TXD_SIZE (MT_TXD_SIZE + 8 * 4) +#define MT_USB_HDR_SIZE 4 +#define MT_USB_TAIL_SIZE 4 + +#define MT_SDIO_TXD_SIZE (MT_TXD_SIZE + 8 * 4) +#define MT_SDIO_TAIL_SIZE 8 +#define MT_SDIO_HDR_SIZE 4 +enum {CMD_CBW_20MHZ =IEEE80211_STA_RX_BW_20 ,CMD_CBW_40MHZ =IEEE80211_STA_RX_BW_40 ,
@@ -92,6 +102,18 @@ struct mt76_connac_sta_key_conf {u8 key[16 ]; }; +#define MT_TXP_MAX_BUF_NUM 6 + +struct mt76_connac_fw_txp { +__le16 flags; +__le16 token; +u8 bss_idx; +__le16 rept_wds_wcid; +u8 nbuf; +__le32 buf[MT_TXP_MAX_BUF_NUM ]; +__le16 len[MT_TXP_MAX_BUF_NUM ]; +} __packed__aligned(4) ; +extern const struct wiphy_wowlan_support mt76_connac_wowlan_support;static inline bool is_mt7922 (struct mt76_dev *dev)
@@ -172,6 +194,19 @@ static inline u8 mt76_connac_lmac_mapping(u8 ac)return 3 - ac; } +static inline void * +mt76_connac_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 (void *)(txwi +MT_TXD_SIZE ); +} +int mt76_connac_pm_wake (struct mt76_phy *phy,struct mt76_connac_pm *pm);void mt76_connac_power_save_sched (struct mt76_phy *phy,struct mt76_connac_pm *pm);
drivers/net/wireless/mediatek/mt76/mt76_connac2_mac.h +7 -6
@@ -32,12 +32,6 @@ enum { MT_LMAC_PSMP0, }; -#define MT_TXD_SIZE (8 * 4) -#define MT_SDIO_TXD_SIZE (MT_TXD_SIZE + 8 * 4) -#define MT_SDIO_TAIL_SIZE 8 -#define MT_SDIO_HDR_SIZE 4 -#define MT_USB_TAIL_SIZE 4 -#define MT_TXD0_Q_IDX GENMASK(31, 25)#define MT_TXD0_PKT_FMT GENMASK(24, 23)#define MT_TXD0_ETH_TYPE_OFFSET GENMASK(22, 16)
@@ -306,4 +300,11 @@ enum {#define MT_CRXV_FOE_HI GENMASK(6, 0)#define MT_CRXV_FOE_SHIFT 13 +#define MT_CT_INFO_APPLY_TXD BIT(0) +#define MT_CT_INFO_COPY_HOST_TXD_ALL BIT(1) +#define MT_CT_INFO_MGMT_FRAME BIT(2) +#define MT_CT_INFO_NONE_CIPHER_FRAME BIT(3) +#define MT_CT_INFO_HSR2_TX BIT(4) +#define MT_CT_INFO_FROM_HOST BIT(7) +#endif /* __MT76_CONNAC2_MAC_H */
drivers/net/wireless/mediatek/mt76/mt7915/mac.c +7 -7
@@ -686,8 +686,8 @@ int mt7915_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_fw_txp *txp;struct mt76_txwi_cache *t; -struct mt7915_txp *txp;int id, i, nbuf = tx_info->nbuf -1 ;u8 *txwi = (u8 *)txwi_ptr;int pid;
@@ -719,7 +719,7 @@ int mt7915_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, pid =mt76_tx_status_skb_add (mdev, wcid, tx_info->skb);mt7915_mac_write_txwi (mdev, txwi_ptr, tx_info->skb, wcid, pid, key,0 ); - txp = (struct mt7915_txp *)(txwi +MT_TXD_SIZE ); + txp = (struct mt76_connac_fw_txp *)(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);
@@ -758,7 +758,7 @@ int mt7915_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,u32 mt7915_wed_init_buf (void *ptr,dma_addr_t phys,int token_id) { -struct mt7915_txp *txp = ptr +MT_TXD_SIZE ; +struct mt76_connac_fw_txp *txp = ptr +MT_TXD_SIZE ;__le32 *txwi = ptr;u32 val;
@@ -807,10 +807,10 @@ mt7915_tx_check_aggr(struct ieee80211_sta *sta, __le32 *txwi)static void mt7915_txp_skb_unmap (struct mt76_dev *dev,struct mt76_txwi_cache *t) { -struct mt7915_txp *txp; +struct mt76_connac_fw_txp *txp;int i; - txp =mt7915_txwi_to_txp (dev, t); + txp =mt76_connac_txwi_to_txp (dev, t);for (i =0 ; i < txp->nbuf; i++)dma_unmap_single (dev->dma_dev,le32_to_cpu (txp->buf[i]),le16_to_cpu (txp->len[i]),DMA_TO_DEVICE );
@@ -1120,10 +1120,10 @@ void mt7915_tx_complete_skb(struct mt76_dev *mdev, struct mt76_queue_entry *e)/* error path */ if (e->skb ==DMA_DUMMY_DATA ) { +struct mt76_connac_fw_txp *txp;struct mt76_txwi_cache *t; -struct mt7915_txp *txp; - txp =mt7915_txwi_to_txp (mdev, e->txwi); + txp =mt76_connac_txwi_to_txp (mdev, e->txwi); t =mt76_token_put (mdev,le16_to_cpu (txp->token)); e->skb = t ? t->skb :NULL ; }
drivers/net/wireless/mediatek/mt76/mt7915/mac.h +0 -32
@@ -42,25 +42,6 @@ enum tx_mcu_port_q_idx {MT_TX_MCU_PORT_RX_FWDL =0x3e }; -#define MT_CT_INFO_APPLY_TXD BIT(0) -#define MT_CT_INFO_COPY_HOST_TXD_ALL BIT(1) -#define MT_CT_INFO_MGMT_FRAME BIT(2) -#define MT_CT_INFO_NONE_CIPHER_FRAME BIT(3) -#define MT_CT_INFO_HSR2_TX BIT(4) -#define MT_CT_INFO_FROM_HOST BIT(7) - -#define MT_TXP_MAX_BUF_NUM 6 - -struct mt7915_txp { -__le16 flags; -__le16 token; -u8 bss_idx; -__le16 rept_wds_wcid; -u8 nbuf; -__le32 buf[MT_TXP_MAX_BUF_NUM ]; -__le16 len[MT_TXP_MAX_BUF_NUM ]; -} __packed__aligned(4) ; -struct mt7915_tx_free {__le16 rx_byte_cnt;__le16 ctrl;
@@ -137,17 +118,4 @@ struct mt7915_dfs_radar_spec { struct mt7915_dfs_pattern radar_pattern[16]; }; -static inline struct mt7915_txp * -mt7915_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 mt7915_txp *)(txwi +MT_TXD_SIZE ); -} -#endif
drivers/net/wireless/mediatek/mt76/mt7915/mmio.c +1 -1
@@ -645,7 +645,7 @@ struct mt7915_dev *mt7915_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 mt7915_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 | SURVEY_INFO_TIME_RX |
drivers/net/wireless/mediatek/mt76/mt7921/mac.h +0 -32
@@ -42,25 +42,6 @@ enum tx_mcu_port_q_idx {MT_TX_MCU_PORT_RX_FWDL =0x3e }; -#define MT_CT_INFO_APPLY_TXD BIT(0) -#define MT_CT_INFO_COPY_HOST_TXD_ALL BIT(1) -#define MT_CT_INFO_MGMT_FRAME BIT(2) -#define MT_CT_INFO_NONE_CIPHER_FRAME BIT(3) -#define MT_CT_INFO_HSR2_TX BIT(4) -#define MT_CT_INFO_FROM_HOST BIT(7) - -#define MT_TXP_MAX_BUF_NUM 6 - -struct mt7921_txp { -__le16 flags; -__le16 token; -u8 bss_idx; -__le16 rept_wds_wcid; -u8 nbuf; -__le32 buf[MT_TXP_MAX_BUF_NUM ]; -__le16 len[MT_TXP_MAX_BUF_NUM ]; -} __packed__aligned(4) ; -struct mt7921_tx_free {__le16 rx_byte_cnt;__le16 ctrl;
@@ -79,19 +60,6 @@ struct mt7921_tx_free {/* will support this field in further revision */ #define MT_TX_FREE_RATE GENMASK(13, 0) -static inline struct mt7921_txp_common * -mt7921_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 mt7921_txp_common *)(txwi +MT_TXD_SIZE ); -} -#define MT_HW_TXP_MAX_MSDU_NUM 4#define MT_HW_TXP_MAX_BUF_NUM 4
drivers/net/wireless/mediatek/mt76/mt7921/pci_mac.c +2 -2
@@ -90,7 +90,7 @@ mt7921_txp_skb_unmap(struct mt76_dev *dev, struct mt76_txwi_cache *t)struct mt7921_txp_common *txp;int i; - txp =mt7921_txwi_to_txp (dev, t); + txp =mt76_connac_txwi_to_txp (dev, t);for (i =0 ; i <ARRAY_SIZE (txp->hw.ptr); i++) {struct mt7921_txp_ptr *ptr = &txp->hw.ptr[i];
@@ -275,7 +275,7 @@ void mt7921e_tx_complete_skb(struct mt76_dev *mdev, struct mt76_queue_entry *e)struct mt7921_txp_common *txp;u16 token; - txp =mt7921_txwi_to_txp (mdev, e->txwi); + txp =mt76_connac_txwi_to_txp (mdev, e->txwi); token =le16_to_cpu (txp->hw.msdu_id[0 ]) & ~MT_MSDU_ID_VALID ; t =mt76_token_put (mdev, token); e->skb = t ? t->skb :NULL ;
Signature · 1 line
2.36.1
Lorenzo Bianconi
maintainerPATCH 2/6 mt76: move mt7615_txp_ptr in mt76_connac module
In reply to Lorenzo BianconiSince mt7615_txp_ptr is shared between mt7615 and mt7921 move it in mt76_connac module.
--- .../net/wireless/mediatek/mt76/mt7615/mac.c | 6 ++--- .../net/wireless/mediatek/mt76/mt7615/mac.h | 22 ------------------- .../net/wireless/mediatek/mt76/mt7615/mmio.c | 2 +- .../wireless/mediatek/mt76/mt7615/pci_mac.c | 8 +++---- .../net/wireless/mediatek/mt76/mt76_connac.h | 22 +++++++++++++++++++ .../net/wireless/mediatek/mt76/mt7921/mac.h | 21 ------------------ .../net/wireless/mediatek/mt76/mt7921/pci.c | 2 +- .../wireless/mediatek/mt76/mt7921/pci_mac.c | 16 +++++++------- 8 files changed, 39 insertions(+), 60 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7615/mac.c +3 -3
@@ -887,7 +887,7 @@ mt7615_txp_skb_unmap_fw(struct mt76_dev *dev, struct mt76_connac_fw_txp *txp) }static void -mt7615_txp_skb_unmap_hw (struct mt76_dev *dev,struct mt7615_hw_txp *txp) +mt7615_txp_skb_unmap_hw (struct mt76_dev *dev,struct mt76_connac_hw_txp *txp) {u32 last_mask;int i;
@@ -895,7 +895,7 @@ mt7615_txp_skb_unmap_hw(struct mt76_dev *dev, struct mt7615_hw_txp *txp) last_mask =is_mt7663 (dev) ?MT_TXD_LEN_LAST :MT_TXD_LEN_MSDU_LAST ;for (i =0 ; i <ARRAY_SIZE (txp->ptr); i++) { -struct mt7615_txp_ptr *ptr = &txp->ptr[i]; +struct mt76_connac_txp_ptr *ptr = &txp->ptr[i];bool last;u16 len;
@@ -920,7 +920,7 @@ mt7615_txp_skb_unmap_hw(struct mt76_dev *dev, struct mt7615_hw_txp *txp)void mt7615_txp_skb_unmap (struct mt76_dev *dev,struct mt76_txwi_cache *t) { -struct mt7615_txp_common *txp; +struct mt76_connac_txp_common *txp; txp =mt76_connac_txwi_to_txp (dev, t);if (is_mt7615 (dev))
drivers/net/wireless/mediatek/mt76/mt7615/mac.h +0 -22
@@ -244,9 +244,6 @@ enum tx_phy_bandwidth {#define MT_TX_RATE_MODE GENMASK(8, 6)#define MT_TX_RATE_IDX GENMASK(5, 0) -#define MT_HW_TXP_MAX_MSDU_NUM 4 -#define MT_HW_TXP_MAX_BUF_NUM 4 -#define MT_MSDU_ID_VALID BIT(15)#define MT_TXD_LEN_MASK GENMASK(11, 0)
@@ -255,25 +252,6 @@ enum tx_phy_bandwidth {/* mt7663 */ #define MT_TXD_LEN_LAST BIT(15) -struct mt7615_txp_ptr { -__le32 buf0; -__le16 len0; -__le16 len1; -__le32 buf1; -} __packed__aligned(4) ; - -struct mt7615_hw_txp { -__le16 msdu_id[MT_HW_TXP_MAX_MSDU_NUM ]; -struct mt7615_txp_ptr ptr[MT_HW_TXP_MAX_BUF_NUM /2 ]; -} __packed__aligned(4) ; - -struct mt7615_txp_common { -union { -struct mt76_connac_fw_txp fw; -struct mt7615_hw_txp hw; - }; -}; -struct mt7615_tx_free {__le16 rx_byte_cnt;__le16 ctrl;
drivers/net/wireless/mediatek/mt76/mt7615/mmio.c +1 -1
@@ -186,7 +186,7 @@ int mt7615_mmio_probe(struct device *pdev, void __iomem *mem_base, { static const struct mt76_driver_ops drv_ops = { /* txwi_size = txd size + txp size */ - .txwi_size = MT_TXD_SIZE + sizeof(struct mt7615_txp_common), + .txwi_size = MT_TXD_SIZE + sizeof(struct mt76_connac_txp_common), .drv_flags = MT_DRV_TXWI_NO_FREE | MT_DRV_HW_MGMT_TXQ, .survey_flags = SURVEY_INFO_TIME_TX | SURVEY_INFO_TIME_RX |
drivers/net/wireless/mediatek/mt76/mt7615/pci_mac.c +4 -4
@@ -23,9 +23,9 @@ void mt7615_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 mt7615_dev *dev; -struct mt7615_txp_common *txp;u16 token; dev = container_of(mdev, struct mt7615_dev, mt76);
@@ -49,8 +49,8 @@ static void mt7615_write_hw_txp(struct mt7615_dev *dev, struct mt76_tx_info *tx_info, void *txp_ptr, u32 id) { - struct mt7615_hw_txp *txp = txp_ptr; -struct mt7615_txp_ptr *ptr = &txp->ptr[0 ]; + struct mt76_connac_hw_txp *txp = txp_ptr; +struct mt76_connac_txp_ptr *ptr = &txp->ptr[0 ];int i, nbuf = tx_info->nbuf -1 ;u32 last_mask;
@@ -168,7 +168,7 @@ int mt7615_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, pid, key, false); txp = txwi +MT_TXD_SIZE ; -memset (txp,0 ,sizeof (struct mt7615_txp_common )); +memset (txp,0 ,sizeof (struct mt76_connac_txp_common ));if (is_mt7615 (&dev->mt76))mt7615_write_fw_txp (dev, tx_info, txp, id);else
drivers/net/wireless/mediatek/mt76/mt76_connac.h +22 -0
@@ -114,6 +114,28 @@ struct mt76_connac_fw_txp {__le16 len[MT_TXP_MAX_BUF_NUM ]; } __packed__aligned(4) ; +#define MT_HW_TXP_MAX_MSDU_NUM 4 +#define MT_HW_TXP_MAX_BUF_NUM 4 + +struct mt76_connac_txp_ptr { +__le32 buf0; +__le16 len0; +__le16 len1; +__le32 buf1; +} __packed__aligned(4) ; + +struct mt76_connac_hw_txp { +__le16 msdu_id[MT_HW_TXP_MAX_MSDU_NUM ]; +struct mt76_connac_txp_ptr ptr[MT_HW_TXP_MAX_BUF_NUM /2 ]; +} __packed__aligned(4) ; + +struct mt76_connac_txp_common { +union { +struct mt76_connac_fw_txp fw; +struct mt76_connac_hw_txp hw; + }; +}; +extern const struct wiphy_wowlan_support mt76_connac_wowlan_support;static inline bool is_mt7922 (struct mt76_dev *dev)
drivers/net/wireless/mediatek/mt76/mt7921/mac.h +0 -21
@@ -60,9 +60,6 @@ struct mt7921_tx_free {/* will support this field in further revision */ #define MT_TX_FREE_RATE GENMASK(13, 0) -#define MT_HW_TXP_MAX_MSDU_NUM 4 -#define MT_HW_TXP_MAX_BUF_NUM 4 -#define MT_MSDU_ID_VALID BIT(15)#define MT_TXD_LEN_MASK GENMASK(11, 0)
@@ -70,24 +67,6 @@ struct mt7921_tx_free {#define MT_TXD_LEN_AMSDU_LAST BIT(15)#define MT_TXD_LEN_LAST BIT(15) -struct mt7921_txp_ptr { -__le32 buf0; -__le16 len0; -__le16 len1; -__le32 buf1; -} __packed__aligned(4) ; - -struct mt7921_hw_txp { -__le16 msdu_id[MT_HW_TXP_MAX_MSDU_NUM ]; -struct mt7921_txp_ptr ptr[MT_HW_TXP_MAX_BUF_NUM /2 ]; -} __packed__aligned(4) ; - -struct mt7921_txp_common { -union { -struct mt7921_hw_txp hw; - }; -}; -#define MT_WTBL_TXRX_CAP_RATE_OFFSET 7#define MT_WTBL_TXRX_RATE_G2_HE 24#define MT_WTBL_TXRX_RATE_G2 12
drivers/net/wireless/mediatek/mt76/mt7921/pci.c +1 -1
@@ -230,7 +230,7 @@ static int mt7921_pci_probe(struct pci_dev *pdev, { static const struct mt76_driver_ops drv_ops = { /* txwi_size = txd size + txp size */ - .txwi_size = MT_TXD_SIZE + sizeof(struct mt7921_txp_common), + .txwi_size = MT_TXD_SIZE + sizeof(struct mt76_connac_txp_common), .drv_flags = MT_DRV_TXWI_NO_FREE | MT_DRV_HW_MGMT_TXQ, .survey_flags = SURVEY_INFO_TIME_TX | SURVEY_INFO_TIME_RX |
drivers/net/wireless/mediatek/mt76/mt7921/pci_mac.c +8 -8
@@ -9,8 +9,8 @@ static void mt7921_write_hw_txp(struct mt7921_dev *dev, struct mt76_tx_info *tx_info, void *txp_ptr, u32 id) { - struct mt7921_hw_txp *txp = txp_ptr; -struct mt7921_txp_ptr *ptr = &txp->ptr[0 ]; + struct mt76_connac_hw_txp *txp = txp_ptr; +struct mt76_connac_txp_ptr *ptr = &txp->ptr[0 ];int i, nbuf = tx_info->nbuf -1 ; tx_info->buf[0 ].len =MT_TXD_SIZE +sizeof (*txp);
@@ -44,8 +44,8 @@ int mt7921e_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76);struct ieee80211_tx_info *info =IEEE80211_SKB_CB (tx_info->skb);struct ieee80211_key_conf *key = info->control.hw_key; +struct mt76_connac_txp_common *txp;struct mt76_txwi_cache *t; -struct mt7921_txp_common *txp;int id, pid;u8 *txwi = (u8 *)txwi_ptr;
@@ -75,8 +75,8 @@ int mt7921e_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,mt76_connac2_mac_write_txwi (mdev, txwi_ptr, tx_info->skb, wcid, key, pid,0 ); - txp = (struct mt7921_txp_common *)(txwi +MT_TXD_SIZE ); -memset (txp,0 ,sizeof (struct mt7921_txp_common )); + txp = (struct mt76_connac_txp_common *)(txwi +MT_TXD_SIZE ); +memset (txp,0 ,sizeof (struct mt76_connac_txp_common ));mt7921_write_hw_txp (dev, tx_info, txp, id); tx_info->skb =DMA_DUMMY_DATA ;
@@ -87,13 +87,13 @@ int mt7921e_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,static void mt7921_txp_skb_unmap (struct mt76_dev *dev,struct mt76_txwi_cache *t) { -struct mt7921_txp_common *txp; +struct mt76_connac_txp_common *txp;int i; txp =mt76_connac_txwi_to_txp (dev, t);for (i =0 ; i <ARRAY_SIZE (txp->hw.ptr); i++) { -struct mt7921_txp_ptr *ptr = &txp->hw.ptr[i]; +struct mt76_connac_txp_ptr *ptr = &txp->hw.ptr[i];bool last;u16 len;
@@ -271,8 +271,8 @@ void mt7921e_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 mt7921_txp_common *txp;u16 token; txp =mt76_connac_txwi_to_txp (mdev, e->txwi);
Signature · 1 line
2.36.1
Lorenzo Bianconi
maintainerRe: [PATCH 2/6] mt76: move mt7615_txp_ptr in mt76_connac module
[...]
drivers/net/wireless/mediatek/mt76/mt7921/pci.c static int mt7921_pci_probe(struct pci_dev *pdev, · line 233
Quoted 10 lines
drivers/net/wireless/mediatek/mt76/mt7921/pci.c +1
-1@@ -230,7 +230,7 @@ static int mt7921_pci_probe(struct pci_dev *pdev, {static const struct mt76_driver_ops drv_ops = {/* txwi_size = txd size + txp size */ - .txwi_size =MT_TXD_SIZE +sizeof (struct mt7921_txp_common ), + .txwi_size =MT_TXD_SIZE +sizeof (struct mt76_connac_txp_common ),
I spotted a minor issue in this patch, we should use mt76_connac_hw_txp here. @Felix: please drop this patch, I will post v2 soon.
Regards,
Lorenzo
Quoted 68 lines
drivers/net/wireless/mediatek/mt76/mt7921/pci.c +0
-0.drv_flags = MT_DRV_TXWI_NO_FREE | MT_DRV_HW_MGMT_TXQ, .survey_flags =SURVEY_INFO_TIME_TX | SURVEY_INFO_TIME_RX |drivers/net/wireless/mediatek/mt76/mt7921/pci_mac.c +8
-8@@ -9,8 +9,8 @@ static void mt7921_write_hw_txp(struct mt7921_dev *dev, struct mt76_tx_info *tx_info, void *txp_ptr, u32 id) { - struct mt7921_hw_txp *txp = txp_ptr; -struct mt7921_txp_ptr *ptr = &txp->ptr[0 ]; + struct mt76_connac_hw_txp *txp = txp_ptr; +struct mt76_connac_txp_ptr *ptr = &txp->ptr[0 ];int i, nbuf = tx_info->nbuf -1 ; tx_info->buf[0 ].len =MT_TXD_SIZE +sizeof (*txp);@@ -44,8 +44,8 @@ int mt7921e_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76);struct ieee80211_tx_info *info =IEEE80211_SKB_CB (tx_info->skb);struct ieee80211_key_conf *key = info->control.hw_key; +struct mt76_connac_txp_common *txp;struct mt76_txwi_cache *t; -struct mt7921_txp_common *txp;int id, pid;u8 *txwi = (u8 *)txwi_ptr;@@ -75,8 +75,8 @@ int mt7921e_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,mt76_connac2_mac_write_txwi (mdev, txwi_ptr, tx_info->skb, wcid, key, pid,0 ); - txp = (struct mt7921_txp_common *)(txwi +MT_TXD_SIZE ); -memset (txp,0 ,sizeof (struct mt7921_txp_common )); + txp = (struct mt76_connac_txp_common *)(txwi +MT_TXD_SIZE ); +memset (txp,0 ,sizeof (struct mt76_connac_txp_common ));mt7921_write_hw_txp (dev, tx_info, txp, id); tx_info->skb =DMA_DUMMY_DATA ;@@ -87,13 +87,13 @@ int mt7921e_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,static void mt7921_txp_skb_unmap (struct mt76_dev *dev,struct mt76_txwi_cache *t) { -struct mt7921_txp_common *txp; +struct mt76_connac_txp_common *txp;int i; txp =mt76_connac_txwi_to_txp (dev, t);for (i =0 ; i <ARRAY_SIZE (txp->hw.ptr); i++) { -struct mt7921_txp_ptr *ptr = &txp->hw.ptr[i]; +struct mt76_connac_txp_ptr *ptr = &txp->hw.ptr[i];bool last;u16 len;@@ -271,8 +271,8 @@ void mt7921e_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 mt7921_txp_common *txp;u16 token; txp =mt76_connac_txwi_to_txp (mdev, e->txwi);Signature · 1 line
2.36.1
Lorenzo Bianconi
maintainerPATCH 3/6 mt76: connac: move mt76_connac_tx_free in shared code
In reply to Lorenzo BianconiMove mt76_connac_tx_free structure in mt76_connac module since it is shared by mt7615 and mt7921 drivers.
--- drivers/net/wireless/mediatek/mt76/mt7615/mac.c | 7 ++++--- drivers/net/wireless/mediatek/mt76/mt7615/mac.h | 8 -------- drivers/net/wireless/mediatek/mt76/mt76_connac.h | 7 +++++++ drivers/net/wireless/mediatek/mt76/mt7921/mac.h | 8 -------- drivers/net/wireless/mediatek/mt76/mt7921/pci_mac.c | 7 ++++--- 5 files changed, 15 insertions(+), 22 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7615/mac.c +4 -3
@@ -1638,7 +1638,8 @@ mt7615_mac_tx_free_token(struct mt7615_dev *dev, u16 token)static void mt7615_mac_tx_free (struct mt7615_dev *dev,void *data,int len) { -struct mt7615_tx_free *free = (struct mt7615_tx_free *)data; +struct mt76_connac_tx_free *free = data; +void *tx_token = data +sizeof (*free);void *end = data + len;u8 i, count;
@@ -1652,7 +1653,7 @@ static void mt7615_mac_tx_free(struct mt7615_dev *dev, void *data, int len) count =le16_get_bits (free->ctrl,MT_TX_FREE_MSDU_ID_CNT );if (is_mt7615 (&dev->mt76)) { -__le16 *token = &free->token[0 ]; +__le16 *token = tx_token;if (WARN_ON_ONCE ((void *)&token[count] > end))return ;
@@ -1660,7 +1661,7 @@ static void mt7615_mac_tx_free(struct mt7615_dev *dev, void *data, int len)for (i =0 ; i < count; i++)mt7615_mac_tx_free_token (dev,le16_to_cpu (token[i])); }else { -__le32 *token = (__le32 *)&free->token[0 ]; +__le32 *token = tx_token;if (WARN_ON_ONCE ((void *)&token[count] > end))return ;
drivers/net/wireless/mediatek/mt76/mt7615/mac.h +0 -8
@@ -252,14 +252,6 @@ enum tx_phy_bandwidth {/* mt7663 */ #define MT_TXD_LEN_LAST BIT(15) -struct mt7615_tx_free { -__le16 rx_byte_cnt; -__le16 ctrl; -u8 txd_cnt; -u8 rsv[3 ]; -__le16 token[]; -} __packed__aligned(4) ; -#define MT_TX_FREE_MSDU_ID_CNT GENMASK(6, 0)#define MT_TXS0_PID GENMASK(31, 24)
drivers/net/wireless/mediatek/mt76/mt76_connac.h +7 -0
@@ -136,6 +136,13 @@ struct mt76_connac_txp_common { }; }; +struct mt76_connac_tx_free { +__le16 rx_byte_cnt; +__le16 ctrl; +u8 txd_cnt; +u8 rsv[3 ]; +} __packed__aligned(4) ; +extern const struct wiphy_wowlan_support mt76_connac_wowlan_support;static inline bool is_mt7922 (struct mt76_dev *dev)
drivers/net/wireless/mediatek/mt76/mt7921/mac.h +0 -8
@@ -42,14 +42,6 @@ enum tx_mcu_port_q_idx { MT_TX_MCU_PORT_RX_FWDL = 0x3e }; -struct mt7921_tx_free { -__le16 rx_byte_cnt; -__le16 ctrl; -u8 txd_cnt; -u8 rsv[3 ]; -__le32 info[]; -} __packed__aligned(4) ; -#define MT_TX_FREE_MSDU_CNT GENMASK(9, 0)#define MT_TX_FREE_WLAN_ID GENMASK(23, 14)#define MT_TX_FREE_LATENCY GENMASK(12, 0)
drivers/net/wireless/mediatek/mt76/mt7921/pci_mac.c +4 -3
@@ -150,7 +150,8 @@ mt7921_txwi_free(struct mt7921_dev *dev, struct mt76_txwi_cache *t,static void mt7921e_mac_tx_free (struct mt7921_dev *dev,void *data,int len) { -struct mt7921_tx_free *free = (struct mt7921_tx_free *)data; +struct mt76_connac_tx_free *free = data; +__le32 *tx_info = (__le32 *)(data +sizeof (*free));struct mt76_dev *mdev = &dev->mt76;struct mt76_txwi_cache *txwi;struct ieee80211_sta *sta =NULL ;
@@ -165,11 +166,11 @@ mt7921e_mac_tx_free(struct mt7921_dev *dev, void *data, int len)mt76_queue_tx_cleanup (dev, dev->mphy.q_tx[MT_TXQ_BE ], false); count =le16_get_bits (free->ctrl,MT_TX_FREE_MSDU_CNT ); -if (WARN_ON_ONCE ((void *)&free->info[count] > end)) +if (WARN_ON_ONCE ((void *)&tx_info[count] > end))return ;for (i =0 ; i < count; i++) { -u32 msdu, info =le32_to_cpu (free->info[i]); +u32 msdu, info =le32_to_cpu (tx_info[i]);u8 stat;/* 1'b1: new wcid pair.
Signature · 1 line
2.36.1
Lorenzo Bianconi
maintainerPATCH 4/6 mt76: connac: move mt76_connac_tx_complete_skb in shared code
In reply to Lorenzo BianconiSince now txp structures are in common code we can reuse mt76_connac_tx_complete_skb routine in mt7921e, mt7915e and mt7615e drivers.
--- .../net/wireless/mediatek/mt76/mt7615/mac.h | 2 -- .../net/wireless/mediatek/mt76/mt7615/mmio.c | 2 +- .../wireless/mediatek/mt76/mt7615/mt7615.h | 1 - .../wireless/mediatek/mt76/mt7615/pci_mac.c | 31 ------------------- .../net/wireless/mediatek/mt76/mt76_connac.h | 17 ++++++++++ .../wireless/mediatek/mt76/mt76_connac_mac.c | 31 +++++++++++++++++++ .../net/wireless/mediatek/mt76/mt7915/mac.c | 21 ------------- .../net/wireless/mediatek/mt76/mt7915/mmio.c | 2 +- .../wireless/mediatek/mt76/mt7915/mt7915.h | 1 - .../net/wireless/mediatek/mt76/mt7921/mac.h | 2 -- .../wireless/mediatek/mt76/mt7921/mt7921.h | 1 - .../net/wireless/mediatek/mt76/mt7921/pci.c | 2 +- .../wireless/mediatek/mt76/mt7921/pci_mac.c | 23 -------------- 13 files changed, 51 insertions(+), 85 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7615/mac.h +0 -2
@@ -244,8 +244,6 @@ enum tx_phy_bandwidth {#define MT_TX_RATE_MODE GENMASK(8, 6)#define MT_TX_RATE_IDX GENMASK(5, 0) -#define MT_MSDU_ID_VALID BIT(15) -#define MT_TXD_LEN_MASK GENMASK(11, 0)#define MT_TXD_LEN_MSDU_LAST BIT(14)#define MT_TXD_LEN_AMSDU_LAST BIT(15)
drivers/net/wireless/mediatek/mt76/mt7615/mmio.c +1 -1
@@ -193,7 +193,7 @@ int mt7615_mmio_probe(struct device *pdev, void __iomem *mem_base, SURVEY_INFO_TIME_BSS_RX, .token_size = MT7615_TOKEN_SIZE, .tx_prepare_skb = mt7615_tx_prepare_skb, - .tx_complete_skb = mt7615_tx_complete_skb, + .tx_complete_skb = mt76_connac_tx_complete_skb, .rx_check = mt7615_rx_check, .rx_skb = mt7615_queue_rx_skb, .rx_poll_complete = mt7615_rx_poll_complete,
drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h +0 -1
@@ -507,7 +507,6 @@ int mt7615_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, struct mt76_tx_info *tx_info);void mt7615_tx_worker (struct mt76_worker *w); -void mt7615_tx_complete_skb (struct mt76_dev *mdev,struct mt76_queue_entry *e);void mt7615_tx_token_put (struct mt7615_dev *dev);bool mt7615_rx_check (struct mt76_dev *mdev,void *data,int len); void mt7615_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q,
drivers/net/wireless/mediatek/mt76/mt7615/pci_mac.c +0 -31
@@ -14,37 +14,6 @@#include "../dma.h" #include "mac.h" -void mt7615_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; -struct mt7615_dev *dev; -u16 token; - - dev = container_of(mdev, struct mt7615_dev, mt76); - txp =mt76_connac_txwi_to_txp (mdev, e->txwi); - -if (is_mt7615 (&dev->mt76)) - token =le16_to_cpu (txp->fw.token); -else - token =le16_to_cpu (txp->hw.msdu_id[0 ]) & - ~MT_MSDU_ID_VALID ; - - t =mt76_token_put (mdev, token); - e->skb = t ? t->skb :NULL ; - } - -if (e->skb) -mt76_tx_complete_skb (mdev, e->wcid, e->skb); -} -static void mt7615_write_hw_txp (struct mt7615_dev *dev,struct mt76_tx_info *tx_info,void *txp_ptr,u32 id)
drivers/net/wireless/mediatek/mt76/mt76_connac.h +17 -0
@@ -27,6 +27,8 @@#define MT_SDIO_TAIL_SIZE 8#define MT_SDIO_HDR_SIZE 4 +#define MT_MSDU_ID_VALID BIT(15) +enum {CMD_CBW_20MHZ =IEEE80211_STA_RX_BW_20 ,CMD_CBW_40MHZ =IEEE80211_STA_RX_BW_40 ,
@@ -198,6 +200,19 @@ static inline bool is_connac_v1(struct mt76_dev *dev)return is_mt7615 (dev) ||is_mt7663 (dev) ||is_mt7622 (dev); } +static inline bool is_mt76_fw_txp (struct mt76_dev *dev) +{ +switch (mt76_chip (dev)) { +case 0x7961 : +case 0x7922 : +case 0x7663 : +case 0x7622 : +return false; +default : +return true; + } +} +static inline u8 mt76_connac_chan_bw (struct cfg80211_chan_def *chandef) {static const u8 width_to_bw[] = {
@@ -304,6 +319,8 @@ mt76_connac_mutex_release(struct mt76_dev *dev, struct mt76_connac_pm *pm)mutex_unlock (&dev->mutex); } +void mt76_connac_tx_complete_skb (struct mt76_dev *mdev, +struct mt76_queue_entry *e); void mt76_connac_pm_queue_skb(struct ieee80211_hw *hw, struct mt76_connac_pm *pm, struct mt76_wcid *wcid,
drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c +31 -0
@@ -3,6 +3,7 @@#include "mt76_connac.h" #include "mt76_connac2_mac.h" +#include "dma.h" #define HE_BITS (f) cpu_to_le16(IEEE80211_RADIOTAP_HE_##f)#define HE_PREP (f, m, v) le16_encode_bits(le32_get_bits(v, MT_CRXV_HE_##m),\
@@ -121,6 +122,36 @@ void mt76_connac_pm_dequeue_skbs(struct mt76_phy *phy, }EXPORT_SYMBOL_GPL (mt76_connac_pm_dequeue_skbs); +void mt76_connac_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; +u16 token; + + txp =mt76_connac_txwi_to_txp (mdev, e->txwi); +if (is_mt76_fw_txp (mdev)) + token =le16_to_cpu (txp->fw.token); +else + token =le16_to_cpu (txp->hw.msdu_id[0 ]) & + ~MT_MSDU_ID_VALID ; + + t =mt76_token_put (mdev, token); + e->skb = t ? t->skb :NULL ; + } + +if (e->skb) +mt76_tx_complete_skb (mdev, e->wcid, e->skb); +} +EXPORT_SYMBOL_GPL (mt76_connac_tx_complete_skb); +static u16 mt76_connac2_mac_tx_rate_val (struct mt76_phy *mphy,struct ieee80211_vif *vif,bool beacon,bool mcast)
drivers/net/wireless/mediatek/mt76/mt7915/mac.c +0 -21
@@ -1111,27 +1111,6 @@ void mt7915_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q, } } -void mt7915_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_fw_txp *txp; -struct mt76_txwi_cache *t; - - txp =mt76_connac_txwi_to_txp (mdev, e->txwi); - t =mt76_token_put (mdev,le16_to_cpu (txp->token)); - e->skb = t ? t->skb :NULL ; - } - -if (e->skb) -mt76_tx_complete_skb (mdev, e->wcid, e->skb); -} -void mt7915_mac_cca_stats_reset (struct mt7915_phy *phy) {struct mt7915_dev *dev = phy->dev;
drivers/net/wireless/mediatek/mt76/mt7915/mmio.c +1 -1
@@ -652,7 +652,7 @@ struct mt7915_dev *mt7915_mmio_probe(struct device *pdev, SURVEY_INFO_TIME_BSS_RX, .token_size = MT7915_TOKEN_SIZE, .tx_prepare_skb = mt7915_tx_prepare_skb, - .tx_complete_skb = mt7915_tx_complete_skb, + .tx_complete_skb = mt76_connac_tx_complete_skb, .rx_skb = mt7915_queue_rx_skb, .rx_check = mt7915_rx_check, .rx_poll_complete = mt7915_rx_poll_complete,
drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +0 -1
@@ -571,7 +571,6 @@ int mt7915_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 mt7915_tx_complete_skb (struct mt76_dev *mdev,struct mt76_queue_entry *e);void mt7915_tx_token_put (struct mt7915_dev *dev);void mt7915_queue_rx_skb (struct mt76_dev *mdev,enum mt76_rxq_id q,struct sk_buff *skb);
drivers/net/wireless/mediatek/mt76/mt7921/mac.h +0 -2
@@ -52,8 +52,6 @@ enum tx_mcu_port_q_idx {/* will support this field in further revision */ #define MT_TX_FREE_RATE GENMASK(13, 0) -#define MT_MSDU_ID_VALID BIT(15) -#define MT_TXD_LEN_MASK GENMASK(11, 0)#define MT_TXD_LEN_MSDU_LAST BIT(14)#define MT_TXD_LEN_AMSDU_LAST BIT(15)
drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h +0 -1
@@ -386,7 +386,6 @@ int mt7921e_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, struct mt76_tx_info *tx_info);void mt7921_tx_worker (struct mt76_worker *w); -void mt7921e_tx_complete_skb (struct mt76_dev *mdev,struct mt76_queue_entry *e);void mt7921_tx_token_put (struct mt7921_dev *dev);void mt7921_queue_rx_skb (struct mt76_dev *mdev,enum mt76_rxq_id q,struct sk_buff *skb);
drivers/net/wireless/mediatek/mt76/mt7921/pci.c +1 -1
@@ -237,7 +237,7 @@ static int mt7921_pci_probe(struct pci_dev *pdev, SURVEY_INFO_TIME_BSS_RX, .token_size = MT7921_TOKEN_SIZE, .tx_prepare_skb = mt7921e_tx_prepare_skb, - .tx_complete_skb = mt7921e_tx_complete_skb, + .tx_complete_skb = mt76_connac_tx_complete_skb, .rx_check = mt7921e_rx_check, .rx_skb = mt7921e_queue_rx_skb, .rx_poll_complete = mt7921_rx_poll_complete,
drivers/net/wireless/mediatek/mt76/mt7921/pci_mac.c +0 -23
@@ -263,29 +263,6 @@ void mt7921e_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q, } } -void mt7921e_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; -u16 token; - - txp =mt76_connac_txwi_to_txp (mdev, e->txwi); - token =le16_to_cpu (txp->hw.msdu_id[0 ]) & ~MT_MSDU_ID_VALID ; - t =mt76_token_put (mdev, token); - e->skb = t ? t->skb :NULL ; - } - -if (e->skb) -mt76_tx_complete_skb (mdev, e->wcid, e->skb); -} -void mt7921_tx_token_put (struct mt7921_dev *dev) {struct mt76_txwi_cache *txwi;
Signature · 1 line
2.36.1
Lorenzo Bianconi
maintainerPATCH 5/6 mt76: connac: move mt76_connac_write_hw_txp in shared code
In reply to Lorenzo BianconiNow we can move mt76_connac_write_hw_txp routine in mt76-connac module and reuse it in mt7921e and mt7615e driver.
--- .../net/wireless/mediatek/mt76/mt7615/mac.h | 6 --- .../wireless/mediatek/mt76/mt7615/pci_mac.c | 40 +------------------ .../net/wireless/mediatek/mt76/mt76_connac.h | 8 ++++ .../wireless/mediatek/mt76/mt76_connac_mac.c | 39 ++++++++++++++++++ .../net/wireless/mediatek/mt76/mt7921/mac.h | 5 --- .../wireless/mediatek/mt76/mt7921/pci_mac.c | 33 +-------------- 6 files changed, 49 insertions(+), 82 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7615/mac.h +0 -6
@@ -244,12 +244,6 @@ enum tx_phy_bandwidth {#define MT_TX_RATE_MODE GENMASK(8, 6)#define MT_TX_RATE_IDX GENMASK(5, 0) -#define MT_TXD_LEN_MASK GENMASK(11, 0) -#define MT_TXD_LEN_MSDU_LAST BIT(14) -#define MT_TXD_LEN_AMSDU_LAST BIT(15) -/* mt7663 */ -#define MT_TXD_LEN_LAST BIT(15) -#define MT_TX_FREE_MSDU_ID_CNT GENMASK(6, 0)#define MT_TXS0_PID GENMASK(31, 24)
drivers/net/wireless/mediatek/mt76/mt7615/pci_mac.c +1 -39
@@ -14,44 +14,6 @@#include "../dma.h" #include "mac.h" -static void -mt7615_write_hw_txp (struct mt7615_dev *dev,struct mt76_tx_info *tx_info, -void *txp_ptr,u32 id) -{ -struct mt76_connac_hw_txp *txp = txp_ptr; -struct mt76_connac_txp_ptr *ptr = &txp->ptr[0 ]; -int i, nbuf = tx_info->nbuf -1 ; -u32 last_mask; - - tx_info->buf[0 ].len =MT_TXD_SIZE +sizeof (*txp); - tx_info->nbuf =1 ; - - txp->msdu_id[0 ] =cpu_to_le16 (id |MT_MSDU_ID_VALID ); - -if (is_mt7663 (&dev->mt76)) - last_mask =MT_TXD_LEN_LAST ; -else - last_mask =MT_TXD_LEN_AMSDU_LAST | -MT_TXD_LEN_MSDU_LAST ; - -for (i =0 ; i < nbuf; i++) { -u16 len = tx_info->buf[i +1 ].len &MT_TXD_LEN_MASK ; -u32 addr = tx_info->buf[i +1 ].addr; - -if (i == nbuf -1 ) - len |= last_mask; - -if (i &1 ) { - ptr->buf1 =cpu_to_le32 (addr); - ptr->len1 =cpu_to_le16 (len); - ptr++; - }else { - ptr->buf0 =cpu_to_le32 (addr); - ptr->len0 =cpu_to_le16 (len); - } - } -} -static void mt7615_write_fw_txp (struct mt7615_dev *dev,struct mt76_tx_info *tx_info,void *txp_ptr,u32 id)
@@ -141,7 +103,7 @@ int mt7615_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,if (is_mt7615 (&dev->mt76))mt7615_write_fw_txp (dev, tx_info, txp, id);else -mt7615_write_hw_txp (dev, tx_info, txp, id); +mt76_connac_write_hw_txp (mdev, tx_info, txp, id); tx_info->skb =DMA_DUMMY_DATA ;
drivers/net/wireless/mediatek/mt76/mt76_connac.h +8 -0
@@ -29,6 +29,11 @@#define MT_MSDU_ID_VALID BIT(15) +#define MT_TXD_LEN_LAST BIT(15) +#define MT_TXD_LEN_MASK GENMASK(11, 0) +#define MT_TXD_LEN_MSDU_LAST BIT(14) +#define MT_TXD_LEN_AMSDU_LAST BIT(15) +enum {CMD_CBW_20MHZ =IEEE80211_STA_RX_BW_20 ,CMD_CBW_40MHZ =IEEE80211_STA_RX_BW_40 ,
@@ -319,6 +324,9 @@ mt76_connac_mutex_release(struct mt76_dev *dev, struct mt76_connac_pm *pm)mutex_unlock (&dev->mutex); } +void mt76_connac_write_hw_txp (struct mt76_dev *dev, +struct mt76_tx_info *tx_info, +void *txp_ptr,u32 id);void mt76_connac_tx_complete_skb (struct mt76_dev *mdev,struct mt76_queue_entry *e); void mt76_connac_pm_queue_skb(struct ieee80211_hw *hw,
drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c +39 -0
@@ -152,6 +152,45 @@ void mt76_connac_tx_complete_skb(struct mt76_dev *mdev, }EXPORT_SYMBOL_GPL (mt76_connac_tx_complete_skb); +void mt76_connac_write_hw_txp (struct mt76_dev *dev, +struct mt76_tx_info *tx_info, +void *txp_ptr,u32 id) +{ +struct mt76_connac_hw_txp *txp = txp_ptr; +struct mt76_connac_txp_ptr *ptr = &txp->ptr[0 ]; +int i, nbuf = tx_info->nbuf -1 ; +u32 last_mask; + + tx_info->buf[0 ].len =MT_TXD_SIZE +sizeof (*txp); + tx_info->nbuf =1 ; + + txp->msdu_id[0 ] =cpu_to_le16 (id |MT_MSDU_ID_VALID ); + +if (is_mt7663 (dev) ||is_mt7921 (dev)) + last_mask =MT_TXD_LEN_LAST ; +else + last_mask =MT_TXD_LEN_AMSDU_LAST | +MT_TXD_LEN_MSDU_LAST ; + +for (i =0 ; i < nbuf; i++) { +u16 len = tx_info->buf[i +1 ].len &MT_TXD_LEN_MASK ; +u32 addr = tx_info->buf[i +1 ].addr; + +if (i == nbuf -1 ) + len |= last_mask; + +if (i &1 ) { + ptr->buf1 =cpu_to_le32 (addr); + ptr->len1 =cpu_to_le16 (len); + ptr++; + }else { + ptr->buf0 =cpu_to_le32 (addr); + ptr->len0 =cpu_to_le16 (len); + } + } +} +EXPORT_SYMBOL_GPL (mt76_connac_write_hw_txp); +static u16 mt76_connac2_mac_tx_rate_val (struct mt76_phy *mphy,struct ieee80211_vif *vif,bool beacon,bool mcast)
drivers/net/wireless/mediatek/mt76/mt7921/mac.h +0 -5
@@ -52,11 +52,6 @@ enum tx_mcu_port_q_idx {/* will support this field in further revision */ #define MT_TX_FREE_RATE GENMASK(13, 0) -#define MT_TXD_LEN_MASK GENMASK(11, 0) -#define MT_TXD_LEN_MSDU_LAST BIT(14) -#define MT_TXD_LEN_AMSDU_LAST BIT(15) -#define MT_TXD_LEN_LAST BIT(15) -#define MT_WTBL_TXRX_CAP_RATE_OFFSET 7#define MT_WTBL_TXRX_RATE_G2_HE 24#define MT_WTBL_TXRX_RATE_G2 12
drivers/net/wireless/mediatek/mt76/mt7921/pci_mac.c +1 -32
@@ -5,37 +5,6 @@#include "../dma.h" #include "mac.h" -static void -mt7921_write_hw_txp (struct mt7921_dev *dev,struct mt76_tx_info *tx_info, -void *txp_ptr,u32 id) -{ -struct mt76_connac_hw_txp *txp = txp_ptr; -struct mt76_connac_txp_ptr *ptr = &txp->ptr[0 ]; -int i, nbuf = tx_info->nbuf -1 ; - - tx_info->buf[0 ].len =MT_TXD_SIZE +sizeof (*txp); - tx_info->nbuf =1 ; - - txp->msdu_id[0 ] =cpu_to_le16 (id |MT_MSDU_ID_VALID ); - -for (i =0 ; i < nbuf; i++) { -u16 len = tx_info->buf[i +1 ].len &MT_TXD_LEN_MASK ; -u32 addr = tx_info->buf[i +1 ].addr; - -if (i == nbuf -1 ) - len |=MT_TXD_LEN_LAST ; - -if (i &1 ) { - ptr->buf1 =cpu_to_le32 (addr); - ptr->len1 =cpu_to_le16 (len); - ptr++; - }else { - ptr->buf0 =cpu_to_le32 (addr); - ptr->len0 =cpu_to_le16 (len); - } - } -} - int mt7921e_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, enum mt76_txq_id qid, struct mt76_wcid *wcid, struct ieee80211_sta *sta,
@@ -77,7 +46,7 @@ int mt7921e_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, txp = (struct mt76_connac_txp_common *)(txwi +MT_TXD_SIZE );memset (txp,0 ,sizeof (struct mt76_connac_txp_common )); -mt7921_write_hw_txp (dev, tx_info, txp, id); +mt76_connac_write_hw_txp (mdev, tx_info, txp, id); tx_info->skb =DMA_DUMMY_DATA ;
Signature · 1 line
2.36.1
Lorenzo Bianconi
maintainerPATCH 6/6 mt76: connac: move mt7615_txp_skb_unmap in common code
In reply to Lorenzo BianconiMove mt7615_txp_skb_unmap in shared code and reuse it in mt7915e and mt7921e driver.
--- .../net/wireless/mediatek/mt76/mt7615/mac.c | 56 +---------------- .../wireless/mediatek/mt76/mt7615/mt7615.h | 2 - .../net/wireless/mediatek/mt76/mt76_connac.h | 2 + .../wireless/mediatek/mt76/mt76_connac_mac.c | 60 +++++++++++++++++++ .../net/wireless/mediatek/mt76/mt7915/mac.c | 14 +---- .../wireless/mediatek/mt76/mt7921/pci_mac.c | 33 +--------- 6 files changed, 65 insertions(+), 102 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7615/mac.c +1 -55
@@ -876,60 +876,6 @@ int mt7615_mac_write_txwi(struct mt7615_dev *dev, __le32 *txwi, }EXPORT_SYMBOL_GPL (mt7615_mac_write_txwi); -static void -mt7615_txp_skb_unmap_fw (struct mt76_dev *dev,struct mt76_connac_fw_txp *txp) -{ -int i; - -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 ); -} - -static void -mt7615_txp_skb_unmap_hw (struct mt76_dev *dev,struct mt76_connac_hw_txp *txp) -{ -u32 last_mask; -int i; - - last_mask =is_mt7663 (dev) ?MT_TXD_LEN_LAST :MT_TXD_LEN_MSDU_LAST ; - -for (i =0 ; i <ARRAY_SIZE (txp->ptr); i++) { -struct mt76_connac_txp_ptr *ptr = &txp->ptr[i]; -bool last; -u16 len; - - len =le16_to_cpu (ptr->len0); - last = len & last_mask; - len &=MT_TXD_LEN_MASK ; -dma_unmap_single (dev->dev,le32_to_cpu (ptr->buf0), len, -DMA_TO_DEVICE ); -if (last) -break ; - - len =le16_to_cpu (ptr->len1); - last = len & last_mask; - len &=MT_TXD_LEN_MASK ; -dma_unmap_single (dev->dev,le32_to_cpu (ptr->buf1), len, -DMA_TO_DEVICE ); -if (last) -break ; - } -} - -void mt7615_txp_skb_unmap (struct mt76_dev *dev, -struct mt76_txwi_cache *t) -{ -struct mt76_connac_txp_common *txp; - - txp =mt76_connac_txwi_to_txp (dev, t); -if (is_mt7615 (dev)) -mt7615_txp_skb_unmap_fw (dev, &txp->fw); -else -mt7615_txp_skb_unmap_hw (dev, &txp->hw); -} -EXPORT_SYMBOL_GPL (mt7615_txp_skb_unmap); -bool mt7615_mac_wtbl_update (struct mt7615_dev *dev,int idx,u32 mask) { mt76_rmw(dev, MT_WTBL_UPDATE, MT_WTBL_UPDATE_WLAN_IDX,
@@ -1608,7 +1554,7 @@ mt7615_txwi_free(struct mt7615_dev *dev, struct mt76_txwi_cache *txwi)u32 val;u8 wcid; -mt7615_txp_skb_unmap (mdev, txwi); +mt76_connac_txp_skb_unmap (mdev, txwi);if (!txwi->skb) goto out;
drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h +0 -2
@@ -517,8 +517,6 @@ int mt7615_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,void mt7615_mac_sta_remove (struct mt76_dev *mdev,struct ieee80211_vif *vif,struct ieee80211_sta *sta);void mt7615_mac_work (struct work_struct *work); -void mt7615_txp_skb_unmap (struct mt76_dev *dev, -struct mt76_txwi_cache *txwi);int mt7615_mcu_set_rx_hdr_trans_blacklist (struct mt7615_dev *dev);int mt7615_mcu_set_fcc5_lpn (struct mt7615_dev *dev,int val); int mt7615_mcu_set_pulse_th(struct mt7615_dev *dev,
drivers/net/wireless/mediatek/mt76/mt76_connac.h +2 -0
@@ -327,6 +327,8 @@ mt76_connac_mutex_release(struct mt76_dev *dev, struct mt76_connac_pm *pm)void mt76_connac_write_hw_txp (struct mt76_dev *dev,struct mt76_tx_info *tx_info,void *txp_ptr,u32 id); +void mt76_connac_txp_skb_unmap (struct mt76_dev *dev, +struct mt76_txwi_cache *txwi);void mt76_connac_tx_complete_skb (struct mt76_dev *mdev,struct mt76_queue_entry *e); void mt76_connac_pm_queue_skb(struct ieee80211_hw *hw,
drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c +60 -0
66 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt7915/mac.c +1 -13
@@ -804,18 +804,6 @@ mt7915_tx_check_aggr(struct ieee80211_sta *sta, __le32 *txwi)ieee80211_start_tx_ba_session (sta, tid,0 ); } -static void -mt7915_txp_skb_unmap (struct mt76_dev *dev,struct mt76_txwi_cache *t) -{ -struct mt76_connac_fw_txp *txp; -int i; - - txp =mt76_connac_txwi_to_txp (dev, t); -for (i =0 ; i < txp->nbuf; i++) -dma_unmap_single (dev->dma_dev,le32_to_cpu (txp->buf[i]), -le16_to_cpu (txp->len[i]),DMA_TO_DEVICE ); -} -static void mt7915_txwi_free (struct mt7915_dev *dev,struct mt76_txwi_cache *t,struct ieee80211_sta *sta,struct list_head *free_list)
@@ -826,7 +814,7 @@ mt7915_txwi_free(struct mt7915_dev *dev, struct mt76_txwi_cache *t,__le32 *txwi;u16 wcid_idx; -mt7915_txp_skb_unmap (mdev, t); +mt76_connac_txp_skb_unmap (mdev, t);if (!t->skb) goto out;
drivers/net/wireless/mediatek/mt76/mt7921/pci_mac.c +1 -32
@@ -53,37 +53,6 @@ int mt7921e_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,return 0 ; } -static void -mt7921_txp_skb_unmap (struct mt76_dev *dev,struct mt76_txwi_cache *t) -{ -struct mt76_connac_txp_common *txp; -int i; - - txp =mt76_connac_txwi_to_txp (dev, t); - -for (i =0 ; i <ARRAY_SIZE (txp->hw.ptr); i++) { -struct mt76_connac_txp_ptr *ptr = &txp->hw.ptr[i]; -bool last; -u16 len; - - len =le16_to_cpu (ptr->len0); - last = len &MT_TXD_LEN_LAST ; - len &=MT_TXD_LEN_MASK ; -dma_unmap_single (dev->dev,le32_to_cpu (ptr->buf0), len, -DMA_TO_DEVICE ); -if (last) -break ; - - len =le16_to_cpu (ptr->len1); - last = len &MT_TXD_LEN_LAST ; - len &=MT_TXD_LEN_MASK ; -dma_unmap_single (dev->dev,le32_to_cpu (ptr->buf1), len, -DMA_TO_DEVICE ); -if (last) -break ; - } -} - static void mt7921_txwi_free(struct mt7921_dev *dev, struct mt76_txwi_cache *t, struct ieee80211_sta *sta, bool clear_status,
@@ -93,7 +62,7 @@ mt7921_txwi_free(struct mt7921_dev *dev, struct mt76_txwi_cache *t,__le32 *txwi;u16 wcid_idx; -mt7921_txp_skb_unmap (mdev, t); +mt76_connac_txp_skb_unmap (mdev, t);if (!t->skb) goto out;
Signature · 1 line
2.36.1