netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: lan966x: Improve the CPU TX bitrate.
@ 2022-03-08 16:57 Horatiu Vultur
  2022-03-08 21:36 ` Andrew Lunn
  0 siblings, 1 reply; 12+ messages in thread
From: Horatiu Vultur @ 2022-03-08 16:57 UTC (permalink / raw)
  To: netdev, linux-kernel; +Cc: UNGLinuxDriver, davem, kuba, Horatiu Vultur

Replace 'readx_poll_timeout_atomic' with a simple while loop + timeout
when checking if it is possible to write to the HW the next word of the
frame.
Doing this will improve the TX bitrate by 65%. The measurements were
done using iperf3.

Before:
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.03  sec  55.2 MBytes  46.2 Mbits/sec    0 sender
[  5]   0.00-10.04  sec  53.8 MBytes  45.0 Mbits/sec      receiver

After:
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.02  sec  91.4 MBytes  76.6 Mbits/sec    0 sender
[  5]   0.00-10.03  sec  90.2 MBytes  75.5 Mbits/sec      receiver

Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
---
 .../ethernet/microchip/lan966x/lan966x_main.c | 20 ++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
index 81c01665d01e..f6cef29b9d36 100644
--- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
+++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
@@ -176,18 +176,20 @@ static int lan966x_port_stop(struct net_device *dev)
 	return 0;
 }
 
-static int lan966x_port_inj_status(struct lan966x *lan966x)
-{
-	return lan_rd(lan966x, QS_INJ_STATUS);
-}
-
 static int lan966x_port_inj_ready(struct lan966x *lan966x, u8 grp)
 {
-	u32 val;
+	unsigned long time = jiffies + usecs_to_jiffies(READL_TIMEOUT_US);
+	int ret = 0;
 
-	return readx_poll_timeout_atomic(lan966x_port_inj_status, lan966x, val,
-					 QS_INJ_STATUS_FIFO_RDY_GET(val) & BIT(grp),
-					 READL_SLEEP_US, READL_TIMEOUT_US);
+	while (!(lan_rd(lan966x, QS_INJ_STATUS) &
+		 QS_INJ_STATUS_FIFO_RDY_SET(BIT(grp)))) {
+		if (time_after(jiffies, time)) {
+			ret = -ETIMEDOUT;
+			break;
+		}
+	}
+
+	return ret;
 }
 
 static int lan966x_port_ifh_xmit(struct sk_buff *skb,
-- 
2.33.0


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

end of thread, other threads:[~2022-03-10  0:37 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-08 16:57 [PATCH net-next] net: lan966x: Improve the CPU TX bitrate Horatiu Vultur
2022-03-08 21:36 ` Andrew Lunn
2022-03-08 22:30   ` Horatiu Vultur
2022-03-08 22:46     ` David Laight
2022-03-09  9:11       ` 'Horatiu Vultur'
2022-03-09  9:57         ` David Laight
2022-03-09 12:16           ` 'Horatiu Vultur'
2022-03-09  0:40     ` Jakub Kicinski
2022-03-09  9:14       ` Horatiu Vultur
2022-03-09 13:11     ` Andrew Lunn
2022-03-09 22:05       ` Horatiu Vultur
2022-03-10  0:37         ` Andrew Lunn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).