mt76: mt7615: take into account sdio bus configuring txwi
authorLorenzo Bianconi <lorenzo@kernel.org>
Wed, 15 Jul 2020 12:46:26 +0000 (14:46 +0200)
committerFelix Fietkau <nbd@nbd.name>
Tue, 21 Jul 2020 17:01:18 +0000 (19:01 +0200)
usb and sdio relies on SF architecture. This is a preliminary patch to
add SDIO support to mt76 driver

Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7615/mac.c

index 126c54afefd44be61d903c1666b0ff4b2832abc8..afac8d81d31729cc60e8b000b886adfb7fc68298 100644 (file)
@@ -529,18 +529,18 @@ int mt7615_mac_write_txwi(struct mt7615_dev *dev, __le32 *txwi,
                          struct ieee80211_sta *sta, int pid,
                          struct ieee80211_key_conf *key, bool beacon)
 {
+       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
+       u8 fc_type, fc_stype, p_fmt, q_idx, omac_idx = 0, wmm_idx = 0;
        struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
        struct ieee80211_tx_rate *rate = &info->control.rates[0];
-       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
+       bool ext_phy = info->hw_queue & MT_TX_HW_QUEUE_EXT_PHY;
        bool multicast = is_multicast_ether_addr(hdr->addr1);
        struct ieee80211_vif *vif = info->control.vif;
+       bool is_mmio = mt76_is_mmio(&dev->mt76);
+       u32 val, sz_txd = is_mmio ? MT_TXD_SIZE : MT_USB_TXD_SIZE;
        struct mt76_phy *mphy = &dev->mphy;
-       bool ext_phy = info->hw_queue & MT_TX_HW_QUEUE_EXT_PHY;
-       bool is_usb = mt76_is_usb(&dev->mt76);
-       int tx_count = 8;
-       u8 fc_type, fc_stype, p_fmt, q_idx, omac_idx = 0, wmm_idx = 0;
        __le16 fc = hdr->frame_control;
-       u32 val, sz_txd = is_usb ? MT_USB_TXD_SIZE : MT_TXD_SIZE;
+       int tx_count = 8;
        u16 seqno = 0;
 
        if (vif) {
@@ -566,10 +566,10 @@ int mt7615_mac_write_txwi(struct mt7615_dev *dev, __le32 *txwi,
                p_fmt = MT_TX_TYPE_FW;
                q_idx = ext_phy ? MT_LMAC_BCN1 : MT_LMAC_BCN0;
        } else if (skb_get_queue_mapping(skb) >= MT_TXQ_PSD) {
-               p_fmt = is_usb ? MT_TX_TYPE_SF : MT_TX_TYPE_CT;
+               p_fmt = is_mmio ? MT_TX_TYPE_CT : MT_TX_TYPE_SF;
                q_idx = ext_phy ? MT_LMAC_ALTX1 : MT_LMAC_ALTX0;
        } else {
-               p_fmt = is_usb ? MT_TX_TYPE_SF : MT_TX_TYPE_CT;
+               p_fmt = is_mmio ? MT_TX_TYPE_CT : MT_TX_TYPE_SF;
                q_idx = wmm_idx * MT7615_MAX_WMM_SETS +
                        mt7615_lmac_mapping(dev, skb_get_queue_mapping(skb));
        }
@@ -675,7 +675,7 @@ int mt7615_mac_write_txwi(struct mt7615_dev *dev, __le32 *txwi,
        txwi[7] = FIELD_PREP(MT_TXD7_TYPE, fc_type) |
                  FIELD_PREP(MT_TXD7_SUB_TYPE, fc_stype) |
                  FIELD_PREP(MT_TXD7_SPE_IDX, 0x18);
-       if (is_usb)
+       if (!is_mmio)
                txwi[8] = FIELD_PREP(MT_TXD8_L_TYPE, fc_type) |
                          FIELD_PREP(MT_TXD8_L_SUB_TYPE, fc_stype);