All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] rtlwifi: Refactor TX/RX flow to improve throughput
@ 2017-11-13  9:39 pkshih
  2017-11-13  9:39 ` [PATCH 1/3] rtlwifi: Reduce IO in RX interrupt to boost throughput pkshih
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: pkshih @ 2017-11-13  9:39 UTC (permalink / raw)
  To: Larry.Finger, kvalo; +Cc: linux-wireless, steventing, yhchuang

From: Ping-Ke Shih <pkshih@realtek.com>

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(-)

-- 
2.14.1

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/3] rtlwifi: Reduce IO in RX interrupt to boost throughput
  2017-11-13  9:39 [PATCH 0/3] rtlwifi: Refactor TX/RX flow to improve throughput pkshih
@ 2017-11-13  9:39 ` pkshih
  2017-12-07 13:15   ` [1/3] " Kalle Valo
  2017-11-13  9:39 ` [PATCH 2/3] rtlwifi: fix the wrong size to calculate fifo space pkshih
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: pkshih @ 2017-11-13  9:39 UTC (permalink / raw)
  To: Larry.Finger, kvalo; +Cc: linux-wireless, steventing, yhchuang

From: Ping-Ke Shih <pkshih@realtek.com>

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.

Signed-off-by: Steven Ting <steventing@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
---
 drivers/net/wireless/realtek/rtlwifi/pci.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/pci.c b/drivers/net/wireless/realtek/rtlwifi/pci.c
index c2575b0b9440..ca3f4716c1b6 100644
--- a/drivers/net/wireless/realtek/rtlwifi/pci.c
+++ b/drivers/net/wireless/realtek/rtlwifi/pci.c
@@ -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)
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] rtlwifi: fix the wrong size to calculate fifo space
  2017-11-13  9:39 [PATCH 0/3] rtlwifi: Refactor TX/RX flow to improve throughput pkshih
  2017-11-13  9:39 ` [PATCH 1/3] rtlwifi: Reduce IO in RX interrupt to boost throughput pkshih
@ 2017-11-13  9:39 ` pkshih
  2017-11-13  9:39 ` [PATCH 3/3] rtlwifi: cleanup the code that check whether TX ring is available pkshih
  2017-11-13 21:23 ` [PATCH 0/3] rtlwifi: Refactor TX/RX flow to improve throughput Larry Finger
  3 siblings, 0 replies; 6+ messages in thread
From: pkshih @ 2017-11-13  9:39 UTC (permalink / raw)
  To: Larry.Finger, kvalo; +Cc: linux-wireless, steventing, yhchuang

From: Ping-Ke Shih <pkshih@realtek.com>

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.

Signed-off-by: Steven Ting <steventing@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
---
 drivers/net/wireless/realtek/rtlwifi/pci.h           | 4 ++--
 drivers/net/wireless/realtek/rtlwifi/rtl8192ee/trx.c | 6 ++++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/pci.h b/drivers/net/wireless/realtek/rtlwifi/pci.h
index e7d070e8da2d..ed5de1218bd9 100644
--- a/drivers/net/wireless/realtek/rtlwifi/pci.h
+++ b/drivers/net/wireless/realtek/rtlwifi/pci.h
@@ -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;
 }
 
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/trx.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/trx.c
index 12255682e890..bc44d9d912d8 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/trx.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/trx.c
@@ -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;
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] rtlwifi: cleanup the code that check whether TX ring is available
  2017-11-13  9:39 [PATCH 0/3] rtlwifi: Refactor TX/RX flow to improve throughput pkshih
  2017-11-13  9:39 ` [PATCH 1/3] rtlwifi: Reduce IO in RX interrupt to boost throughput pkshih
  2017-11-13  9:39 ` [PATCH 2/3] rtlwifi: fix the wrong size to calculate fifo space pkshih
@ 2017-11-13  9:39 ` pkshih
  2017-11-13 21:23 ` [PATCH 0/3] rtlwifi: Refactor TX/RX flow to improve throughput Larry Finger
  3 siblings, 0 replies; 6+ messages in thread
From: pkshih @ 2017-11-13  9:39 UTC (permalink / raw)
  To: Larry.Finger, kvalo; +Cc: linux-wireless, steventing, yhchuang

From: Ping-Ke Shih <pkshih@realtek.com>

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.

Signed-off-by: Steven Ting <steventing@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
---
 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(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/pci.c b/drivers/net/wireless/realtek/rtlwifi/pci.c
index ca3f4716c1b6..e544f4bcfae9 100644
--- a/drivers/net/wireless/realtek/rtlwifi/pci.c
+++ b/drivers/net/wireless/realtek/rtlwifi/pci.c
@@ -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 */
diff --git a/drivers/net/wireless/realtek/rtlwifi/pci.h b/drivers/net/wireless/realtek/rtlwifi/pci.h
index ed5de1218bd9..3fb56c845a61 100644
--- a/drivers/net/wireless/realtek/rtlwifi/pci.h
+++ b/drivers/net/wireless/realtek/rtlwifi/pci.h
@@ -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 */
 };
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/trx.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/trx.c
index bc44d9d912d8..4f7444331b07 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/trx.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/trx.c
@@ -549,7 +549,6 @@ static u16 get_desc_addr_fr_q_idx(u16 queue_index)
 
 u16 rtl92ee_get_available_desc(struct ieee80211_hw *hw, u8 q_idx)
 {
-	struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	u16 point_diff = 0;
 	u16 current_tx_read_point = 0, current_tx_write_point = 0;
@@ -564,7 +563,6 @@ u16 rtl92ee_get_available_desc(struct ieee80211_hw *hw, u8 q_idx)
 				     current_tx_write_point,
 				     TX_DESC_NUM_92E);
 
-	rtlpci->tx_ring[q_idx].avl_desc = point_diff;
 	return point_diff;
 }
 
@@ -909,10 +907,6 @@ void rtl92ee_set_desc(struct ieee80211_hw *hw, u8 *pdesc, bool istx,
 		      u8 desc_name, u8 *val)
 {
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
-	u16 cur_tx_rp = 0;
-	u16 cur_tx_wp = 0;
-	static bool over_run;
-	u32 tmp = 0;
 	u8 q_idx = *val;
 	bool dma64 = rtlpriv->cfg->mod_params->dma64;
 
@@ -933,38 +927,12 @@ void rtl92ee_set_desc(struct ieee80211_hw *hw, u8 *pdesc, bool istx,
 				return;
 			}
 
+			/* make sure tx desc is available by caller */
 			ring->cur_tx_wp = ((ring->cur_tx_wp + 1) % max_tx_desc);
 
-			if (over_run) {
-				ring->cur_tx_wp = 0;
-				over_run = false;
-			}
-			if (ring->avl_desc > 1) {
-				ring->avl_desc--;
-
-				rtl_write_word(rtlpriv,
-					       get_desc_addr_fr_q_idx(q_idx),
-					       ring->cur_tx_wp);
-			}
-
-			if (ring->avl_desc < (max_tx_desc - 15)) {
-				u16 point_diff = 0;
-
-				tmp =
-				  rtl_read_dword(rtlpriv,
-						 get_desc_addr_fr_q_idx(q_idx));
-				cur_tx_rp = (u16)((tmp >> 16) & 0x0fff);
-				cur_tx_wp = (u16)(tmp & 0x0fff);
-
-				ring->cur_tx_wp = cur_tx_wp;
-				ring->cur_tx_rp = cur_tx_rp;
-				point_diff = ((cur_tx_rp > cur_tx_wp) ?
-					      (cur_tx_rp - cur_tx_wp) :
-					      (TX_DESC_NUM_92E - 1 -
-					       cur_tx_wp + cur_tx_rp));
-
-				ring->avl_desc = point_diff;
-			}
+			rtl_write_word(rtlpriv,
+				       get_desc_addr_fr_q_idx(q_idx),
+				       ring->cur_tx_wp);
 		}
 		break;
 		}
@@ -1046,13 +1014,12 @@ bool rtl92ee_is_tx_desc_closed(struct ieee80211_hw *hw, u8 hw_queue, u16 index)
 {
 	struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
-	u16 read_point, write_point, available_desc_num;
+	u16 read_point, write_point;
 	bool ret = false;
 	static u8 stop_report_cnt;
 	struct rtl8192_tx_ring *ring = &rtlpci->tx_ring[hw_queue];
 
 	{
-		u16 point_diff = 0;
 		u16 cur_tx_rp, cur_tx_wp;
 		u32 tmpu32 = 0;
 
@@ -1062,18 +1029,12 @@ bool rtl92ee_is_tx_desc_closed(struct ieee80211_hw *hw, u8 hw_queue, u16 index)
 		cur_tx_rp = (u16)((tmpu32 >> 16) & 0x0fff);
 		cur_tx_wp = (u16)(tmpu32 & 0x0fff);
 
-		ring->cur_tx_wp = cur_tx_wp;
+		/* don't need to update ring->cur_tx_wp */
 		ring->cur_tx_rp = cur_tx_rp;
-		point_diff = ((cur_tx_rp > cur_tx_wp) ?
-			      (cur_tx_rp - cur_tx_wp) :
-			      (TX_DESC_NUM_92E - cur_tx_wp + cur_tx_rp));
-
-		ring->avl_desc = point_diff;
 	}
 
 	read_point = ring->cur_tx_rp;
 	write_point = ring->cur_tx_wp;
-	available_desc_num = ring->avl_desc;
 
 	if (write_point > read_point) {
 		if (index < write_point && index >= read_point)
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/3] rtlwifi: Refactor TX/RX flow to improve throughput
  2017-11-13  9:39 [PATCH 0/3] rtlwifi: Refactor TX/RX flow to improve throughput pkshih
                   ` (2 preceding siblings ...)
  2017-11-13  9:39 ` [PATCH 3/3] rtlwifi: cleanup the code that check whether TX ring is available pkshih
@ 2017-11-13 21:23 ` Larry Finger
  3 siblings, 0 replies; 6+ messages in thread
From: Larry Finger @ 2017-11-13 21:23 UTC (permalink / raw)
  To: pkshih, kvalo; +Cc: linux-wireless, steventing, yhchuang

On 11/13/2017 03:39 AM, pkshih@realtek.com wrote:
> From: Ping-Ke Shih <pkshih@realtek.com>
> 
> 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 <Larry.Finger@lwfinger.net>

Larry

> 
>   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(-)
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [1/3] rtlwifi: Reduce IO in RX interrupt to boost throughput
  2017-11-13  9:39 ` [PATCH 1/3] rtlwifi: Reduce IO in RX interrupt to boost throughput pkshih
@ 2017-12-07 13:15   ` Kalle Valo
  0 siblings, 0 replies; 6+ messages in thread
From: Kalle Valo @ 2017-12-07 13:15 UTC (permalink / raw)
  To: Ping-Ke Shih; +Cc: Larry.Finger, linux-wireless, steventing, yhchuang

Ping-Ke Shih <pkshih@realtek.com> wrote:

> From: Ping-Ke Shih <pkshih@realtek.com>
> 
> 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.
> 
> Signed-off-by: Steven Ting <steventing@realtek.com>
> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>

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

-- 
https://patchwork.kernel.org/patch/10055429/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-12-07 13:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-13  9:39 [PATCH 0/3] rtlwifi: Refactor TX/RX flow to improve throughput pkshih
2017-11-13  9:39 ` [PATCH 1/3] rtlwifi: Reduce IO in RX interrupt to boost throughput pkshih
2017-12-07 13:15   ` [1/3] " Kalle Valo
2017-11-13  9:39 ` [PATCH 2/3] rtlwifi: fix the wrong size to calculate fifo space pkshih
2017-11-13  9:39 ` [PATCH 3/3] rtlwifi: cleanup the code that check whether TX ring is available pkshih
2017-11-13 21:23 ` [PATCH 0/3] rtlwifi: Refactor TX/RX flow to improve throughput Larry Finger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.