Skip to contentSkip to conversation

rtlwifi: Refactor TX/RX flow to improve throughput

PATCH In review [email protected] 3 participants 6 messages Nov 13, 2017 – Dec 7, 2017 Realtek wireless driver (rtlwifi family)

lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

cover rtlwifi: Refactor TX/RX flow to improve throughput

From: Ping-Ke Shih <[email protected]>

This patchset is aim to reduce IO to improve TX/RX performance, and also I cleanup the code to make it easier and simpler.

Ping-Ke Shih (3):
rtlwifi: Reduce IO in RX interrupt to boost throughput
rtlwifi: fix the wrong size to calculate fifo space
rtlwifi: cleanup the code that check whether TX ring is available

 drivers/net/wireless/realtek/rtlwifi/pci.c         | 13 ++---
 drivers/net/wireless/realtek/rtlwifi/pci.h         |  5 +-
 .../net/wireless/realtek/rtlwifi/rtl8192ee/trx.c   | 57 ++++------------------
 3 files changed, 15 insertions(+), 60 deletions(-)
Signature · 1 line
2.14.1
author maintainer
#1 lore raw

PATCH 1/3 rtlwifi: Reduce IO in RX interrupt to boost throughput

From: Ping-Ke Shih <[email protected]>

Check remaining count of RX packets cost a lot of CPU time, so only update when the counter decreases to zero. In old flow, the counter was updated once a RX packet is received.

---
 drivers/net/wireless/realtek/rtlwifi/pci.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/wireless/realtek/rtlwifi/pci.c +3 -2
index c2575b0b9440..ca3f4716c1b6 100644
@@ -747,7 +747,7 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
 	u8 tmp_one;
 	bool unicast = false;
 	u8 hw_queue = 0;
-	unsigned int rx_remained_cnt;
+	unsigned int rx_remained_cnt = 0;
 	struct rtl_stats stats = {
 		.signal = 0,
 		.rate = 0,
@@ -768,7 +768,8 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
 		struct sk_buff *new_skb;
 
 		if (rtlpriv->use_new_trx_flow) {
-			rx_remained_cnt =
+			if (rx_remained_cnt == 0)
+				rx_remained_cnt =
 				rtlpriv->cfg->ops->rx_desc_buff_remained_cnt(hw,
 								      hw_queue);
 			if (rx_remained_cnt == 0)
Signature · 1 line
2.14.1
#2 lore raw

Re: [1/3] rtlwifi: Reduce IO in RX interrupt to boost throughput

Quoted 8 lines · Ping-Ke Shih

From: Ping-Ke Shih <[email protected]>

Check remaining count of RX packets cost a lot of CPU time, so only update when the counter decreases to zero. In old flow, the counter was updated once a RX packet is received.

3 patches applied to wireless-drivers-next.git, thanks.

fb9829e90dcd rtlwifi: Reduce IO in RX interrupt to boost throughput dc9682a0cca5 rtlwifi: fix the wrong size to calculate fifo space cf54622c8076 rtlwifi: cleanup the code that check whether TX ring is available

Signature · 3 lines
https://patchwork.kernel.org/patch/10055429/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
author maintainer
#3 lore raw

PATCH 2/3 rtlwifi: fix the wrong size to calculate fifo space

In reply to [email protected]

From: Ping-Ke Shih <[email protected]>

Give correct fifo size to calculate fifo space. Fortunately, the values of RTL_PCI_MAX_RX_COUNT and TX_DESC_NUM_92E are the same in old code, so it still works.

---
 drivers/net/wireless/realtek/rtlwifi/pci.h           | 4 ++--
 drivers/net/wireless/realtek/rtlwifi/rtl8192ee/trx.c | 6 ++++--
 2 files changed, 6 insertions(+), 4 deletions(-)
drivers/net/wireless/realtek/rtlwifi/pci.h +2 -2
index e7d070e8da2d..ed5de1218bd9 100644
@@ -320,10 +320,10 @@ static inline void pci_write32_async(struct rtl_priv *rtlpriv,
 	writel(val, (u8 __iomem *)rtlpriv->io.pci_mem_start + addr);
 }
 
-static inline u16 calc_fifo_space(u16 rp, u16 wp)
+static inline u16 calc_fifo_space(u16 rp, u16 wp, u16 size)
 {
 	if (rp <= wp)
-		return RTL_PCI_MAX_RX_COUNT - 1 + rp - wp;
+		return size - 1 + rp - wp;
 	return rp - wp - 1;
 }
 
drivers/net/wireless/realtek/rtlwifi/rtl8192ee/trx.c +4 -2
index 12255682e890..bc44d9d912d8 100644
@@ -498,7 +498,8 @@ u16 rtl92ee_rx_desc_buff_remained_cnt(struct ieee80211_hw *hw, u8 queue_index)
 	if (!start_rx)
 		return 0;
 
-	remind_cnt = calc_fifo_space(read_point, write_point);
+	remind_cnt = calc_fifo_space(read_point, write_point,
+				     RTL_PCI_MAX_RX_COUNT);
 
 	if (remind_cnt == 0)
 		return 0;
@@ -560,7 +561,8 @@ u16 rtl92ee_get_available_desc(struct ieee80211_hw *hw, u8 q_idx)
 	current_tx_write_point = (u16)((tmp_4byte) & 0x0fff);
 
 	point_diff = calc_fifo_space(current_tx_read_point,
-				     current_tx_write_point);
+				     current_tx_write_point,
+				     TX_DESC_NUM_92E);
 
 	rtlpci->tx_ring[q_idx].avl_desc = point_diff;
 	return point_diff;
Signature · 1 line
2.14.1
author maintainer
#4 lore raw

PATCH 3/3 rtlwifi: cleanup the code that check whether TX ring is available

In reply to [email protected]

From: Ping-Ke Shih <[email protected]>

Remove the duplicate checking of TX ring's available number, and remove the variable to store available number that can be calculated by read/write pointers.

---
 drivers/net/wireless/realtek/rtlwifi/pci.c         |  8 ----
 drivers/net/wireless/realtek/rtlwifi/pci.h         |  1 -
 .../net/wireless/realtek/rtlwifi/rtl8192ee/trx.c   | 51 +++-------------------
 3 files changed, 6 insertions(+), 54 deletions(-)
drivers/net/wireless/realtek/rtlwifi/pci.c +0 -8
index ca3f4716c1b6..e544f4bcfae9 100644
@@ -557,13 +557,6 @@ static void _rtl_pci_tx_isr(struct ieee80211_hw *hw, int prio)
 		else
 			entry = (u8 *)(&ring->desc[ring->idx]);
 
-		if (rtlpriv->cfg->ops->get_available_desc &&
-		    rtlpriv->cfg->ops->get_available_desc(hw, prio) <= 1) {
-			RT_TRACE(rtlpriv, (COMP_INTR | COMP_SEND), DBG_DMESG,
-				 "no available desc!\n");
-			return;
-		}
-
 		if (!rtlpriv->cfg->ops->is_tx_desc_closed(hw, prio, ring->idx))
 			return;
 		ring->idx = (ring->idx + 1) % ring->entries;
@@ -1251,7 +1244,6 @@ static int _rtl_pci_init_tx_ring(struct ieee80211_hw *hw,
 
 		rtlpci->tx_ring[prio].cur_tx_rp = 0;
 		rtlpci->tx_ring[prio].cur_tx_wp = 0;
-		rtlpci->tx_ring[prio].avl_desc = entries;
 	}
 
 	/* alloc dma for this ring */
drivers/net/wireless/realtek/rtlwifi/pci.h +0 -1
index ed5de1218bd9..3fb56c845a61 100644
@@ -173,7 +173,6 @@ struct rtl8192_tx_ring {
 	/*add for new trx flow*/
 	struct rtl_tx_buffer_desc *buffer_desc; /*tx buffer descriptor*/
 	dma_addr_t buffer_desc_dma; /*tx bufferd desc dma memory*/
-	u16 avl_desc; /* available_desc_to_write */
 	u16 cur_tx_wp; /* current_tx_write_point */
 	u16 cur_tx_rp; /* current_tx_read_point */
 };
drivers/net/wireless/realtek/rtlwifi/rtl8192ee/trx.c +6 -45

99 lines not on this page · raw message

Signature · 1 line
2.14.1
#5 lore raw
In reply to [email protected]
Quoted 9 lines · On 11/13/2017 03:39 AM, [email protected] wrote:

From: Ping-Ke Shih <[email protected]>

This patchset is aim to reduce IO to improve TX/RX performance, and also I cleanup the code to make it easier and simpler.

Ping-Ke Shih (3):
rtlwifi: Reduce IO in RX interrupt to boost throughput
rtlwifi: fix the wrong size to calculate fifo space
rtlwifi: cleanup the code that check whether TX ring is available

All 3 Tested-by: Larry Finger <[email protected]>

Larry

Quoted 6 lines
  drivers/net/wireless/realtek/rtlwifi/pci.c         | 13 ++---
  drivers/net/wireless/realtek/rtlwifi/pci.h         |  5 +-
  .../net/wireless/realtek/rtlwifi/rtl8192ee/trx.c   | 57 ++++------------------
  3 files changed, 15 insertions(+), 60 deletions(-)