Skip to contentSkip to conversation

tsnep: Throttle interrupts, RX buffer allocation and ethtool_get_channels()

PATCH Applied Gerhard Engleder 3 participants 9 messages Nov 30, 2022 – Dec 2, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover tsnep: Throttle interrupts, RX buffer allocation and ethtool_get_channels()

Collection of improvements found during development of XDP support. Hopefully the last patch series before the XDP support.

ethtool_get_channels() is needed for automatic TAPRIO configuration in combination with multiple queues.

Rework of the RX buffer allocation is prework of XDP. It ensures that packets are only dropped if RX queue would otherwise run empty because of failed allocations. So it should reduce the number of dropped packets under low memory conditions.

v2:
- post rotten packet fix separately (Jakub Kicinski)
- implement ethtool::get_coalesce / set_coalesce (Jakub Kicinski)

Gerhard Engleder (4):
tsnep: Consistent naming of struct net_device
tsnep: Add ethtool::get_channels support
tsnep: Throttle interrupts
tsnep: Rework RX buffer allocation

 drivers/net/ethernet/engleder/tsnep.h         |   8 +
 drivers/net/ethernet/engleder/tsnep_ethtool.c | 165 +++++++++++-
 drivers/net/ethernet/engleder/tsnep_hw.h      |   7 +
 drivers/net/ethernet/engleder/tsnep_main.c    | 245 ++++++++++++------
 4 files changed, 345 insertions(+), 80 deletions(-)
Signature · 1 line
2.30.2
#1 lore raw

PATCH v2 1/4 tsnep: Consistent naming of struct net_device

---
 drivers/net/ethernet/engleder/tsnep_ethtool.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/ethernet/engleder/tsnep_ethtool.c +6 -6
index a713a126b227..c2640e88f347 100644
@@ -250,10 +250,10 @@ static int tsnep_ethtool_get_sset_count(struct net_device *netdev, int sset)
 	}
 }
 
-static int tsnep_ethtool_get_rxnfc(struct net_device *dev,
+static int tsnep_ethtool_get_rxnfc(struct net_device *netdev,
 				   struct ethtool_rxnfc *cmd, u32 *rule_locs)
 {
-	struct tsnep_adapter *adapter = netdev_priv(dev);
+	struct tsnep_adapter *adapter = netdev_priv(netdev);
 
 	switch (cmd->cmd) {
 	case ETHTOOL_GRXRINGS:
@@ -273,10 +273,10 @@ static int tsnep_ethtool_get_rxnfc(struct net_device *dev,
 	}
 }
 
-static int tsnep_ethtool_set_rxnfc(struct net_device *dev,
+static int tsnep_ethtool_set_rxnfc(struct net_device *netdev,
 				   struct ethtool_rxnfc *cmd)
 {
-	struct tsnep_adapter *adapter = netdev_priv(dev);
+	struct tsnep_adapter *adapter = netdev_priv(netdev);
 
 	switch (cmd->cmd) {
 	case ETHTOOL_SRXCLSRLINS:
@@ -288,10 +288,10 @@ static int tsnep_ethtool_set_rxnfc(struct net_device *dev,
 	}
 }
 
-static int tsnep_ethtool_get_ts_info(struct net_device *dev,
+static int tsnep_ethtool_get_ts_info(struct net_device *netdev,
 				     struct ethtool_ts_info *info)
 {
-	struct tsnep_adapter *adapter = netdev_priv(dev);
+	struct tsnep_adapter *adapter = netdev_priv(netdev);
 
 	info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE |
 				SOF_TIMESTAMPING_RX_SOFTWARE |
Signature · 1 line
2.30.2
#3 lore raw

PATCH v2 2/4 tsnep: Add ethtool::get_channels support

In reply to Gerhard Engleder

Allow user space to read number of TX and RX queue. This is useful for device dependent qdisc configurations like TAPRIO with hardware offload. Also ethtool::get_per_queue_coalesce / set_per_queue_coalesce requires that interface.

---
 drivers/net/ethernet/engleder/tsnep_ethtool.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/net/ethernet/engleder/tsnep_ethtool.c +12 -0
index c2640e88f347..517ac8de32bb 100644
@@ -288,6 +288,17 @@ static int tsnep_ethtool_set_rxnfc(struct net_device *netdev,
 	}
 }
 
+static void tsnep_ethtool_get_channels(struct net_device *netdev,
+				       struct ethtool_channels *ch)
+{
+	struct tsnep_adapter *adapter = netdev_priv(netdev);
+
+	ch->max_rx = adapter->num_rx_queues;
+	ch->max_tx = adapter->num_tx_queues;
+	ch->rx_count = adapter->num_rx_queues;
+	ch->tx_count = adapter->num_tx_queues;
+}
+
 static int tsnep_ethtool_get_ts_info(struct net_device *netdev,
 				     struct ethtool_ts_info *info)
 {
@@ -327,6 +338,7 @@ const struct ethtool_ops tsnep_ethtool_ops = {
 	.get_sset_count = tsnep_ethtool_get_sset_count,
 	.get_rxnfc = tsnep_ethtool_get_rxnfc,
 	.set_rxnfc = tsnep_ethtool_set_rxnfc,
+	.get_channels = tsnep_ethtool_get_channels,
 	.get_ts_info = tsnep_ethtool_get_ts_info,
 	.get_link_ksettings = phy_ethtool_get_link_ksettings,
 	.set_link_ksettings = phy_ethtool_set_link_ksettings,
Signature · 1 line
2.30.2
Reviewed-by on v2 2/4
#4 lore raw

Re: [PATCH net-next v2 2/4] tsnep: Add ethtool::get_channels support

Quoted 6 lines · Gerhard Engleder

Allow user space to read number of TX and RX queue. This is useful for device dependent qdisc configurations like TAPRIO with hardware offload. Also ethtool::get_per_queue_coalesce / set_per_queue_coalesce requires that interface.

Andrew

#5 lore raw

PATCH v2 3/4 tsnep: Throttle interrupts

In reply to Gerhard Engleder

Without interrupt throttling, iperf server mode generates a CPU load of 100% (A53 1.2GHz). Also the throughput suffers with less than 900Mbit/s on a 1Gbit/s link. The reason is a high interrupt load with interrupts every ~20us.

Reduce interrupt load by throttling of interrupts. Interrupt delay default is 64us. For iperf server mode the CPU load is significantly reduced to ~20% and the throughput reaches the maximum of 941MBit/s. Interrupts are generated every ~140us.

RX and TX coalesce can be configured with ethtool. RX coalesce has priority over TX coalesce if the same interrupt is used.

---
 drivers/net/ethernet/engleder/tsnep.h         |   4 +
 drivers/net/ethernet/engleder/tsnep_ethtool.c | 134 ++++++++++++++++++
 drivers/net/ethernet/engleder/tsnep_hw.h      |   7 +
 drivers/net/ethernet/engleder/tsnep_main.c    |  42 ++++++
 4 files changed, 187 insertions(+)
drivers/net/ethernet/engleder/tsnep.h +4 -0
index 09a723b827c7..6bb74dd36544 100644
@@ -132,6 +132,8 @@ struct tsnep_queue {
 
 	int irq;
 	u32 irq_mask;
+	void __iomem *irq_delay_addr;
+	u8 irq_delay;
 };
 
 struct tsnep_adapter {
@@ -223,5 +225,7 @@ static inline void tsnep_ethtool_self_test(struct net_device *dev,
 #endif /* CONFIG_TSNEP_SELFTESTS */
 
 void tsnep_get_system_time(struct tsnep_adapter *adapter, u64 *time);
+int tsnep_set_irq_coalesce(struct tsnep_queue *queue, u32 usecs);
+u32 tsnep_get_irq_coalesce(struct tsnep_queue *queue);
 
 #endif /* _TSNEP_H */
drivers/net/ethernet/engleder/tsnep_ethtool.c +134 -0

147 lines not on this page · raw message

drivers/net/ethernet/engleder/tsnep_hw.h +7 -0
index 315dada75323..55e1caf193a6 100644
@@ -48,6 +48,13 @@
 #define ECM_COUNTER_LOW 0x0028
 #define ECM_COUNTER_HIGH 0x002C
 
+/* interrupt delay */
+#define ECM_INT_DELAY 0x0030
+#define ECM_INT_DELAY_MASK 0xF0
+#define ECM_INT_DELAY_SHIFT 4
+#define ECM_INT_DELAY_BASE_US 16
+#define ECM_INT_DELAY_OFFSET 1
+
 /* control and status */
 #define ECM_STATUS 0x0080
 #define ECM_LINK_MODE_OFF 0x01000000
drivers/net/ethernet/engleder/tsnep_main.c +42 -0

66 lines not on this page · raw message

Signature · 1 line
2.30.2
Reviewed-by on v2 3/4
#6 lore raw

Re: [PATCH net-next v2 3/4] tsnep: Throttle interrupts

Quoted 10 lines · Gerhard Engleder

Without interrupt throttling, iperf server mode generates a CPU load of 100% (A53 1.2GHz). Also the throughput suffers with less than 900Mbit/s on a 1Gbit/s link. The reason is a high interrupt load with interrupts every ~20us.

Reduce interrupt load by throttling of interrupts. Interrupt delay default is 64us. For iperf server mode the CPU load is significantly reduced to ~20% and the throughput reaches the maximum of 941MBit/s. Interrupts are generated every ~140us.

Quoted 4 lines

RX and TX coalesce can be configured with ethtool. RX coalesce has priority over TX coalesce if the same interrupt is used.

Andrew

#7 lore raw

PATCH v2 4/4 tsnep: Rework RX buffer allocation

In reply to Gerhard Engleder

Refill RX queue in batches of descriptors to improve performance. Refill is allowed to fail as long as a minimum number of descriptors is active. Thus, a limited number of failed RX buffer allocations is now allowed for normal operation. Previously every failed allocation resulted in a dropped frame.

If the minimum number of active descriptors is reached, then RX buffers are still reused and frames are dropped. This ensures that the RX queue never runs empty and always continues to operate.

Prework for future XDP support.

---
 drivers/net/ethernet/engleder/tsnep.h         |   4 +
 drivers/net/ethernet/engleder/tsnep_ethtool.c |   7 +
 drivers/net/ethernet/engleder/tsnep_main.c    | 203 +++++++++++-------
 3 files changed, 140 insertions(+), 74 deletions(-)
drivers/net/ethernet/engleder/tsnep.h +4 -0
index 6bb74dd36544..f93ba48bac3f 100644
@@ -18,6 +18,8 @@
 #define TSNEP "tsnep"
 
 #define TSNEP_RING_SIZE 256
+#define TSNEP_RING_RX_REFILL 16
+#define TSNEP_RING_RX_REUSE (TSNEP_RING_SIZE - TSNEP_RING_SIZE / 4)
 #define TSNEP_RING_ENTRIES_PER_PAGE (PAGE_SIZE / TSNEP_DESC_SIZE)
 #define TSNEP_RING_PAGE_COUNT (TSNEP_RING_SIZE / TSNEP_RING_ENTRIES_PER_PAGE)
 
@@ -110,6 +112,7 @@ struct tsnep_rx {
 	dma_addr_t page_dma[TSNEP_RING_PAGE_COUNT];
 
 	struct tsnep_rx_entry entry[TSNEP_RING_SIZE];
+	int write;
 	int read;
 	u32 owner_counter;
 	int increment_owner_counter;
@@ -119,6 +122,7 @@ struct tsnep_rx {
 	u32 bytes;
 	u32 dropped;
 	u32 multicast;
+	u32 alloc_failed;
 };
 
 struct tsnep_queue {
drivers/net/ethernet/engleder/tsnep_ethtool.c +7 -0
index b97ba3544708..716815dad7d2 100644
@@ -8,6 +8,7 @@ static const char tsnep_stats_strings[][ETH_GSTRING_LEN] = {
 	"rx_bytes",
 	"rx_dropped",
 	"rx_multicast",
+	"rx_alloc_failed",
 	"rx_phy_errors",
 	"rx_forwarded_phy_errors",
 	"rx_invalid_frame_errors",
@@ -21,6 +22,7 @@ struct tsnep_stats {
 	u64 rx_bytes;
 	u64 rx_dropped;
 	u64 rx_multicast;
+	u64 rx_alloc_failed;
 	u64 rx_phy_errors;
 	u64 rx_forwarded_phy_errors;
 	u64 rx_invalid_frame_errors;
@@ -36,6 +38,7 @@ static const char tsnep_rx_queue_stats_strings[][ETH_GSTRING_LEN] = {
 	"rx_%d_bytes",
 	"rx_%d_dropped",
 	"rx_%d_multicast",
+	"rx_%d_alloc_failed",
 	"rx_%d_no_descriptor_errors",
 	"rx_%d_buffer_too_small_errors",
 	"rx_%d_fifo_overflow_errors",
@@ -47,6 +50,7 @@ struct tsnep_rx_queue_stats {
 	u64 rx_bytes;
 	u64 rx_dropped;
 	u64 rx_multicast;
+	u64 rx_alloc_failed;
 	u64 rx_no_descriptor_errors;
 	u64 rx_buffer_too_small_errors;
 	u64 rx_fifo_overflow_errors;
@@ -178,6 +182,7 @@ static void tsnep_ethtool_get_ethtool_stats(struct net_device *netdev,
 		tsnep_stats.rx_bytes += adapter->rx[i].bytes;
 		tsnep_stats.rx_dropped += adapter->rx[i].dropped;
 		tsnep_stats.rx_multicast += adapter->rx[i].multicast;
+		tsnep_stats.rx_alloc_failed += adapter->rx[i].alloc_failed;
 	}
 	reg = ioread32(adapter->addr + ECM_STAT);
 	tsnep_stats.rx_phy_errors =
@@ -200,6 +205,8 @@ static void tsnep_ethtool_get_ethtool_stats(struct net_device *netdev,
 		tsnep_rx_queue_stats.rx_bytes = adapter->rx[i].bytes;
 		tsnep_rx_queue_stats.rx_dropped = adapter->rx[i].dropped;
 		tsnep_rx_queue_stats.rx_multicast = adapter->rx[i].multicast;
+		tsnep_rx_queue_stats.rx_alloc_failed =
+			adapter->rx[i].alloc_failed;
 		reg = ioread32(adapter->addr + TSNEP_QUEUE(i) +
 			       TSNEP_RX_STATISTIC);
 		tsnep_rx_queue_stats.rx_no_descriptor_errors =
drivers/net/ethernet/engleder/tsnep_main.c +129 -74

277 lines not on this page · raw message

Signature · 1 line
2.30.2
#8 lore raw
In reply to Gerhard Engleder
This series was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:

Quoted 6 lines · On Wed, 30 Nov 2022 20:37:04 +0100 you wrote:

Collection of improvements found during development of XDP support. Hopefully the last patch series before the XDP support.

ethtool_get_channels() is needed for automatic TAPRIO configuration in combination with multiple queues.

Quoted 6 lines

Rework of the RX buffer allocation is prework of XDP. It ensures that packets are only dropped if RX queue would otherwise run empty because of failed allocations. So it should reduce the number of dropped packets under low memory conditions.

[...]

Here is the summary with links:
- [net-next,v2,1/4] tsnep: Consistent naming of struct net_device

    https://git.kernel.org/netdev/net-next/c/91644df1ba01
  - [net-next,v2,2/4] tsnep: Add ethtool::get_channels support
    https://git.kernel.org/netdev/net-next/c/4f661ccfcac7
  - [net-next,v2,3/4] tsnep: Throttle interrupts
    https://git.kernel.org/netdev/net-next/c/d3dfe8d6c040
  - [net-next,v2,4/4] tsnep: Rework RX buffer allocation
    https://git.kernel.org/netdev/net-next/c/dbadae927287

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html