aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrea Merello <andrea.merello@gmail.com>2014-03-22 13:51:20 -0400
committerJohn W. Linville <linville@tuxdriver.com>2014-03-27 14:20:04 -0400
commitfd6564fcdc0bfcd432e6e939f9538acc3905d08a (patch)
tree9feb0e42cd626e9f0a6973f79ea71c9897de1d04
parent4818d82899aa97a482ba3508cd75864a60c483ac (diff)
rtl8180: rationalize TX queues
On currently supported HW there are four TX queues (three for normal packets and one for beacons). The driver uses just one TX queue, and declare to mac80211 to support just one queue, but it allocates coherent memory for all queues. Furthermore the TX is code is written assumimg four queues exists, and even if we decide to enable more queues in future, its mapping rule to mac80211 is fixed. This means we have memory waste on rtl8180/rtl8185, and we have also not enough flexibility to add support for boards (rtl8187se) that will use more queues. This patch changes things in order to allocate coherent memory only for the queues effectively used and it make it possible to specify how to map hardware queues on mac80211 queues, that will be used by rtl8187se code as soon it will be merged. Note: even if the beacon queue is currently unused, this should change, so I kept it. Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/rtl818x/rtl8180/dev.c58
-rw-r--r--drivers/net/wireless/rtl818x/rtl8180/rtl8180.h7
2 files changed, 49 insertions, 16 deletions
diff --git a/drivers/net/wireless/rtl818x/rtl8180/dev.c b/drivers/net/wireless/rtl818x/rtl8180/dev.c
index 091eb2eb1a3c..767e1048f336 100644
--- a/drivers/net/wireless/rtl818x/rtl8180/dev.c
+++ b/drivers/net/wireless/rtl818x/rtl8180/dev.c
@@ -85,6 +85,30 @@ static const struct ieee80211_channel rtl818x_channels[] = {
85 { .center_freq = 2484 }, 85 { .center_freq = 2484 },
86}; 86};
87 87
88/* Queues for rtl8180/rtl8185 cards
89 *
90 * name | reg | prio
91 * BC | 7 | 3
92 * HI | 6 | 0
93 * NO | 5 | 1
94 * LO | 4 | 2
95 *
96 * The complete map for DMA kick reg using all queue is:
97 * static const int rtl8180_queues_map[RTL8180_NR_TX_QUEUES] = {6, 5, 4, 7};
98 *
99 * .. but .. Because the mac80211 needs at least 4 queues for QoS or
100 * otherwise QoS can't be done, we use just one.
101 * Beacon queue could be used, but this is not finished yet.
102 * Actual map is:
103 *
104 * name | reg | prio
105 * BC | 7 | 1 <- currently not used yet.
106 * HI | 6 | x <- not used
107 * NO | 5 | x <- not used
108 * LO | 4 | 0 <- used
109 */
110
111static const int rtl8180_queues_map[RTL8180_NR_TX_QUEUES] = {4, 7};
88 112
89void rtl8180_write_phy(struct ieee80211_hw *dev, u8 addr, u32 data) 113void rtl8180_write_phy(struct ieee80211_hw *dev, u8 addr, u32 data)
90{ 114{
@@ -235,12 +259,6 @@ static irqreturn_t rtl8180_interrupt(int irq, void *dev_id)
235 rtl818x_iowrite16(priv, &priv->map->INT_STATUS, reg); 259 rtl818x_iowrite16(priv, &priv->map->INT_STATUS, reg);
236 260
237 if (reg & (RTL818X_INT_TXB_OK | RTL818X_INT_TXB_ERR)) 261 if (reg & (RTL818X_INT_TXB_OK | RTL818X_INT_TXB_ERR))
238 rtl8180_handle_tx(dev, 3);
239
240 if (reg & (RTL818X_INT_TXH_OK | RTL818X_INT_TXH_ERR))
241 rtl8180_handle_tx(dev, 2);
242
243 if (reg & (RTL818X_INT_TXN_OK | RTL818X_INT_TXN_ERR))
244 rtl8180_handle_tx(dev, 1); 262 rtl8180_handle_tx(dev, 1);
245 263
246 if (reg & (RTL818X_INT_TXL_OK | RTL818X_INT_TXL_ERR)) 264 if (reg & (RTL818X_INT_TXL_OK | RTL818X_INT_TXL_ERR))
@@ -264,7 +282,7 @@ static void rtl8180_tx(struct ieee80211_hw *dev,
264 struct rtl8180_tx_ring *ring; 282 struct rtl8180_tx_ring *ring;
265 struct rtl8180_tx_desc *entry; 283 struct rtl8180_tx_desc *entry;
266 unsigned long flags; 284 unsigned long flags;
267 unsigned int idx, prio; 285 unsigned int idx, prio, hw_prio;
268 dma_addr_t mapping; 286 dma_addr_t mapping;
269 u32 tx_flags; 287 u32 tx_flags;
270 u8 rc_flags; 288 u8 rc_flags;
@@ -354,7 +372,11 @@ static void rtl8180_tx(struct ieee80211_hw *dev,
354 372
355 spin_unlock_irqrestore(&priv->lock, flags); 373 spin_unlock_irqrestore(&priv->lock, flags);
356 374
357 rtl818x_iowrite8(priv, &priv->map->TX_DMA_POLLING, (1 << (prio + 4))); 375 hw_prio = rtl8180_queues_map[prio];
376
377 rtl818x_iowrite8(priv, &priv->map->TX_DMA_POLLING,
378 (1 << hw_prio) | /* ring to poll */
379 (1<<1) | (1<<2));/* stopped rings */
358} 380}
359 381
360void rtl8180_set_anaparam(struct rtl8180_priv *priv, u32 anaparam) 382void rtl8180_set_anaparam(struct rtl8180_priv *priv, u32 anaparam)
@@ -447,9 +469,7 @@ static int rtl8180_init_hw(struct ieee80211_hw *dev)
447 rtl8180_set_anaparam(priv, priv->anaparam); 469 rtl8180_set_anaparam(priv, priv->anaparam);
448 470
449 rtl818x_iowrite32(priv, &priv->map->RDSAR, priv->rx_ring_dma); 471 rtl818x_iowrite32(priv, &priv->map->RDSAR, priv->rx_ring_dma);
450 rtl818x_iowrite32(priv, &priv->map->TBDA, priv->tx_ring[3].dma); 472 rtl818x_iowrite32(priv, &priv->map->TBDA, priv->tx_ring[1].dma);
451 rtl818x_iowrite32(priv, &priv->map->THPDA, priv->tx_ring[2].dma);
452 rtl818x_iowrite32(priv, &priv->map->TNPDA, priv->tx_ring[1].dma);
453 rtl818x_iowrite32(priv, &priv->map->TLPDA, priv->tx_ring[0].dma); 473 rtl818x_iowrite32(priv, &priv->map->TLPDA, priv->tx_ring[0].dma);
454 474
455 /* TODO: necessary? specs indicate not */ 475 /* TODO: necessary? specs indicate not */
@@ -627,7 +647,7 @@ static int rtl8180_start(struct ieee80211_hw *dev)
627 if (ret) 647 if (ret)
628 return ret; 648 return ret;
629 649
630 for (i = 0; i < 4; i++) 650 for (i = 0; i < (dev->queues + 1); i++)
631 if ((ret = rtl8180_init_tx_ring(dev, i, 16))) 651 if ((ret = rtl8180_init_tx_ring(dev, i, 16)))
632 goto err_free_rings; 652 goto err_free_rings;
633 653
@@ -722,7 +742,7 @@ static int rtl8180_start(struct ieee80211_hw *dev)
722 742
723 err_free_rings: 743 err_free_rings:
724 rtl8180_free_rx_ring(dev); 744 rtl8180_free_rx_ring(dev);
725 for (i = 0; i < 4; i++) 745 for (i = 0; i < (dev->queues + 1); i++)
726 if (priv->tx_ring[i].desc) 746 if (priv->tx_ring[i].desc)
727 rtl8180_free_tx_ring(dev, i); 747 rtl8180_free_tx_ring(dev, i);
728 748
@@ -752,7 +772,7 @@ static void rtl8180_stop(struct ieee80211_hw *dev)
752 free_irq(priv->pdev->irq, dev); 772 free_irq(priv->pdev->irq, dev);
753 773
754 rtl8180_free_rx_ring(dev); 774 rtl8180_free_rx_ring(dev);
755 for (i = 0; i < 4; i++) 775 for (i = 0; i < (dev->queues + 1); i++)
756 rtl8180_free_tx_ring(dev, i); 776 rtl8180_free_tx_ring(dev, i);
757} 777}
758 778
@@ -1215,7 +1235,6 @@ static int rtl8180_probe(struct pci_dev *pdev,
1215 dev->vif_data_size = sizeof(struct rtl8180_vif); 1235 dev->vif_data_size = sizeof(struct rtl8180_vif);
1216 dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | 1236 dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
1217 BIT(NL80211_IFTYPE_ADHOC); 1237 BIT(NL80211_IFTYPE_ADHOC);
1218 dev->queues = 1;
1219 dev->max_signal = 65; 1238 dev->max_signal = 65;
1220 1239
1221 reg = rtl818x_ioread32(priv, &priv->map->TX_CONF); 1240 reg = rtl818x_ioread32(priv, &priv->map->TX_CONF);
@@ -1246,6 +1265,15 @@ static int rtl8180_probe(struct pci_dev *pdev,
1246 goto err_iounmap; 1265 goto err_iounmap;
1247 } 1266 }
1248 1267
1268 /* we declare to MAC80211 all the queues except for beacon queue
1269 * that will be eventually handled by DRV.
1270 * TX rings are arranged in such a way that lower is the IDX,
1271 * higher is the priority, in order to achieve direct mapping
1272 * with mac80211, however the beacon queue is an exception and it
1273 * is mapped on the highst tx ring IDX.
1274 */
1275 dev->queues = RTL8180_NR_TX_QUEUES - 1;
1276
1249 if (priv->chip_family != RTL818X_CHIP_FAMILY_RTL8180) { 1277 if (priv->chip_family != RTL818X_CHIP_FAMILY_RTL8180) {
1250 priv->band.n_bitrates = ARRAY_SIZE(rtl818x_rates); 1278 priv->band.n_bitrates = ARRAY_SIZE(rtl818x_rates);
1251 pci_try_set_mwi(pdev); 1279 pci_try_set_mwi(pdev);
diff --git a/drivers/net/wireless/rtl818x/rtl8180/rtl8180.h b/drivers/net/wireless/rtl818x/rtl8180/rtl8180.h
index 26383d77fc3a..ad64c5e84857 100644
--- a/drivers/net/wireless/rtl818x/rtl8180/rtl8180.h
+++ b/drivers/net/wireless/rtl818x/rtl8180/rtl8180.h
@@ -24,6 +24,11 @@
24#define ANAPARAM_PWR1_SHIFT 20 24#define ANAPARAM_PWR1_SHIFT 20
25#define ANAPARAM_PWR1_MASK (0x7F << ANAPARAM_PWR1_SHIFT) 25#define ANAPARAM_PWR1_MASK (0x7F << ANAPARAM_PWR1_SHIFT)
26 26
27/* rtl8180/rtl8185 have 3 queue + beacon queue.
28 * mac80211 can use just one, + beacon = 2 tot.
29 */
30#define RTL8180_NR_TX_QUEUES 2
31
27struct rtl8180_tx_desc { 32struct rtl8180_tx_desc {
28 __le32 flags; 33 __le32 flags;
29 __le16 rts_duration; 34 __le16 rts_duration;
@@ -75,7 +80,7 @@ struct rtl8180_priv {
75 dma_addr_t rx_ring_dma; 80 dma_addr_t rx_ring_dma;
76 unsigned int rx_idx; 81 unsigned int rx_idx;
77 struct sk_buff *rx_buf[32]; 82 struct sk_buff *rx_buf[32];
78 struct rtl8180_tx_ring tx_ring[4]; 83 struct rtl8180_tx_ring tx_ring[RTL8180_NR_TX_QUEUES];
79 struct ieee80211_channel channels[14]; 84 struct ieee80211_channel channels[14];
80 struct ieee80211_rate rates[12]; 85 struct ieee80211_rate rates[12];
81 struct ieee80211_supported_band band; 86 struct ieee80211_supported_band band;