Guest User

Untitled

a guest
May 31st, 2020
110
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. From c43ba514079ce96342e10eeaef4bf9e9a5d50529 Mon Sep 17 00:00:00 2001
  2. Message-Id: <c43ba514079ce96342e10eeaef4bf9e9a5d50529.1590948748.git.lorenzo@kernel.org>
  3. From: Lorenzo Bianconi <lorenzo@kernel.org>
  4. Date: Sun, 31 May 2020 16:24:55 +0200
  5. Subject: [PATCH] mt76: overwrite qid for non-buggerable mgmt frames
  6.  
  7. Overwrite hw queue id for non-bufferable management frames if the hw
  8. support always txq (altxq) in order to be in sync with mac txwi code
  9.  
  10. Suggested-by: Felix Fietkau <nbd@nbd.name>
  11. Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
  12. ---
  13. drivers/net/wireless/mediatek/mt76/mt76.h     |  1 +
  14.  .../net/wireless/mediatek/mt76/mt7615/dma.c   |  1 +
  15.  .../net/wireless/mediatek/mt76/mt7615/mac.c   | 20 +++++++------------
  16.  .../net/wireless/mediatek/mt76/mt7615/mmio.c  |  2 +-
  17.  .../net/wireless/mediatek/mt76/mt7615/usb.c   |  2 +-
  18.  drivers/net/wireless/mediatek/mt76/tx.c       |  7 +++++++
  19.  6 files changed, 18 insertions(+), 15 deletions(-)
  20.  
  21. diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
  22. index dfe625a53c63..3d7db6ffb599 100644
  23. --- a/drivers/net/wireless/mediatek/mt76/mt76.h
  24. +++ b/drivers/net/wireless/mediatek/mt76/mt76.h
  25. @@ -301,6 +301,7 @@ struct mt76_hw_cap {
  26.  #define MT_DRV_TX_ALIGNED4_SKBS        BIT(1)
  27.  #define MT_DRV_SW_RX_AIRTIME       BIT(2)
  28.  #define MT_DRV_RX_DMA_HDR      BIT(3)
  29. +#define MT_DRV_HW_MGMT_TXQ     BIT(4)
  30.  
  31.  struct mt76_driver_ops {
  32.     u32 drv_flags;
  33. diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/dma.c b/drivers/net/wireless/mediatek/mt76/mt7615/dma.c
  34. index 83fdcf5db3c7..e5a965df899a 100644
  35. --- a/drivers/net/wireless/mediatek/mt76/mt7615/dma.c
  36. +++ b/drivers/net/wireless/mediatek/mt76/mt7615/dma.c
  37. @@ -100,6 +100,7 @@ mt7615_tx_cleanup(struct mt7615_dev *dev)
  38.     int i;
  39.  
  40.     mt76_queue_tx_cleanup(dev, MT_TXQ_MCU, false);
  41. +   mt76_queue_tx_cleanup(dev, MT_TXQ_PSD, false);
  42.     if (is_mt7615(&dev->mt76)) {
  43.         mt76_queue_tx_cleanup(dev, MT_TXQ_BE, false);
  44.     } else {
  45. diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
  46. index 5990355bc731..d97315ec7265 100644
  47. --- a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
  48. +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
  49. @@ -526,22 +526,16 @@ int mt7615_mac_write_txwi(struct mt7615_dev *dev, __le32 *txwi,
  50.     fc_type = (le16_to_cpu(fc) & IEEE80211_FCTL_FTYPE) >> 2;
  51.     fc_stype = (le16_to_cpu(fc) & IEEE80211_FCTL_STYPE) >> 4;
  52.  
  53. -   if (ieee80211_is_data(fc) || ieee80211_is_bufferable_mmpdu(fc)) {
  54. -       q_idx = wmm_idx * MT7615_MAX_WMM_SETS +
  55. -           mt7615_lmac_mapping(dev, skb_get_queue_mapping(skb));
  56. -       p_fmt = is_usb ? MT_TX_TYPE_SF : MT_TX_TYPE_CT;
  57. -   } else if (beacon) {
  58. -       if (ext_phy)
  59. -           q_idx = MT_LMAC_BCN1;
  60. -       else
  61. -           q_idx = MT_LMAC_BCN0;
  62. +   if (beacon) {
  63.         p_fmt = MT_TX_TYPE_FW;
  64. +       q_idx = ext_phy ? MT_LMAC_BCN1 : MT_LMAC_BCN0;
  65. +   } else if (skb_get_queue_mapping(skb) >= MT_TXQ_PSD) {
  66. +       p_fmt = is_usb ? MT_TX_TYPE_SF : MT_TX_TYPE_CT;
  67. +       q_idx = ext_phy ? MT_LMAC_ALTX1 : MT_LMAC_ALTX0;
  68.     } else {
  69. -       if (ext_phy)
  70. -           q_idx = MT_LMAC_ALTX1;
  71. -       else
  72. -           q_idx = MT_LMAC_ALTX0;
  73.         p_fmt = is_usb ? MT_TX_TYPE_SF : MT_TX_TYPE_CT;
  74. +       q_idx = wmm_idx * MT7615_MAX_WMM_SETS +
  75. +           mt7615_lmac_mapping(dev, skb_get_queue_mapping(skb));
  76.     }
  77.  
  78.     val = FIELD_PREP(MT_TXD0_TX_BYTES, skb->len + sz_txd) |
  79. diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mmio.c b/drivers/net/wireless/mediatek/mt76/mt7615/mmio.c
  80. index e670393506f0..2e99845b9c96 100644
  81. --- a/drivers/net/wireless/mediatek/mt76/mt7615/mmio.c
  82. +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mmio.c
  83. @@ -146,7 +146,7 @@ int mt7615_mmio_probe(struct device *pdev, void __iomem *mem_base,
  84.     static const struct mt76_driver_ops drv_ops = {
  85.         /* txwi_size = txd size + txp size */
  86.         .txwi_size = MT_TXD_SIZE + sizeof(struct mt7615_txp_common),
  87. -       .drv_flags = MT_DRV_TXWI_NO_FREE,
  88. +       .drv_flags = MT_DRV_TXWI_NO_FREE | MT_DRV_HW_MGMT_TXQ,
  89.         .survey_flags = SURVEY_INFO_TIME_TX |
  90.                 SURVEY_INFO_TIME_RX |
  91.                 SURVEY_INFO_TIME_BSS_RX,
  92. diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/usb.c b/drivers/net/wireless/mediatek/mt76/mt7615/usb.c
  93. index a50077eb24d7..f5dc1b828518 100644
  94. --- a/drivers/net/wireless/mediatek/mt76/mt7615/usb.c
  95. +++ b/drivers/net/wireless/mediatek/mt76/mt7615/usb.c
  96. @@ -270,7 +270,7 @@ static int mt7663u_probe(struct usb_interface *usb_intf,
  97.  {
  98.     static const struct mt76_driver_ops drv_ops = {
  99.         .txwi_size = MT_USB_TXD_SIZE,
  100. -       .drv_flags = MT_DRV_RX_DMA_HDR,
  101. +       .drv_flags = MT_DRV_RX_DMA_HDR | MT_DRV_HW_MGMT_TXQ,
  102.         .tx_prepare_skb = mt7663u_tx_prepare_skb,
  103.         .tx_complete_skb = mt7663u_tx_complete_skb,
  104.         .tx_status_data = mt7663u_tx_status_data,
  105. diff --git a/drivers/net/wireless/mediatek/mt76/tx.c b/drivers/net/wireless/mediatek/mt76/tx.c
  106. index fca38ea2441f..f10c98aa883c 100644
  107. --- a/drivers/net/wireless/mediatek/mt76/tx.c
  108. +++ b/drivers/net/wireless/mediatek/mt76/tx.c
  109. @@ -264,6 +264,13 @@ mt76_tx(struct mt76_phy *phy, struct ieee80211_sta *sta,
  110.         skb_set_queue_mapping(skb, qid);
  111.     }
  112.  
  113. +   if ((dev->drv->drv_flags & MT_DRV_HW_MGMT_TXQ) &&
  114. +       !ieee80211_is_data(hdr->frame_control) &&
  115. +       !ieee80211_is_bufferable_mmpdu(hdr->frame_control)) {
  116. +       qid = MT_TXQ_PSD;
  117. +       skb_set_queue_mapping(skb, qid);
  118. +   }
  119. +
  120.     if (!(wcid->tx_info & MT_WCID_TX_INFO_SET))
  121.         ieee80211_get_tx_rates(info->control.vif, sta, skb,
  122.                        info->control.rates, 1);
  123. --
  124. 2.26.2
RAW Paste Data