All of lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-wired-lan] [PATCH] igc: Fix trigger of incorrect irq in igc_xsk_wakeup function
@ 2025-12-05 12:39 ` Behera, VIVEK
  0 siblings, 0 replies; 30+ messages in thread
From: Behera, VIVEK @ 2025-12-05 12:39 UTC (permalink / raw)
  To: Tony Nguyen, Przemek Kitszel, Andrew Lunn,
	"David S. Miller", Eric Dumazet, Jakub Kicinski,
	Paolo Abeni
  Cc: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, Behera, VIVEK


[-- Attachment #1.1: Type: text/plain, Size: 6556 bytes --]

From 4e3ebdc0af6baa83ccfc17c61c1eb61408095ffd Mon Sep 17 00:00:00 2001
From: Vivek Behera <vivek.behera@siemens.com>
Date: Fri, 5 Dec 2025 10:26:05 +0100
Subject: [PATCH] igc: Fix trigger of incorrect irq in igc_xsk_wakeup function

When the i226 is configured to use only 2 combined queues using ethtool
or in an environment with only 2 active CPU cores the 4 irq lines
are used in a split configuration with one irq
assigned to each of the two rx and tx queues
(see console output below)

sudo ethtool -l enp1s0
Channel parameters for enp1s0:
Pre-set maximums:
RX:                        n/a
TX:                         n/a
Other:                  1
Combined:        4
Current hardware settings:
RX:                        n/a
TX:                         n/a
Other:                  1
Combined:        2
eddx@mvs:~$ cat /proc/interrupts | grep enp1s0
147:          1          0  IR-PCI-MSIX-0000:01:00.0   0-edge      enp1s0
148:          8          0  IR-PCI-MSIX-0000:01:00.0   1-edge      enp1s0-rx-0
149:          0          0  IR-PCI-MSIX-0000:01:00.0   2-edge      enp1s0-rx-1
150:         26          0  IR-PCI-MSIX-0000:01:00.0   3-edge      enp1s0-tx-0
151:          0          0  IR-PCI-MSIX-0000:01:00.0   4-edge      enp1s0-tx-1

While testing with the RTC Testbench it was noticed
using the bpftrace that the
igc_xsk_wakeup when triggered by xsk_sendmsg
was triggering the incorrect irq for
tx-0(see trace below)

TIMESTAMP: 456992309829 | FUNCTION: igc_xsk_wakeup | ENTRY: RtcTxThread (PID: 945) - queue_id: 0
TIMESTAMP: 456992317157 | FUNCTION: igc_poll | ENTRY: irq/148-enp1s0- (PID: 948)
TIMESTAMP: 456993309408 | FUNCTION: igc_xsk_wakeup | ENTRY: RtcTxThread (PID: 945) - queue_id: 0
TIMESTAMP: 456993316591 | FUNCTION: igc_poll | ENTRY: irq/148-enp1s0- (PID: 948)
TIMESTAMP: 456994309630 | FUNCTION: igc_xsk_wakeup | ENTRY: RtcTxThread (PID: 945) - queue_id: 0
TIMESTAMP: 456994316674 | FUNCTION: igc_poll | ENTRY: irq/148-enp1s0- (PID: 948)
TIMESTAMP: 456995309493 | FUNCTION: igc_xsk_wakeup | ENTRY: RtcTxThread (PID: 945) - queue_id: 0
TIMESTAMP: 456995316593 | FUNCTION: igc_poll | ENTRY: irq/148-enp1s0- (PID: 948)

Due to this bug no XDP Zc send is possible in this split irq configuration.
This patch implements the correct logic of extracting the q_vectors saved
duirng the rx and tx ring allocation.
Furthermore the patch includes usage of flags provided by the ndo_xsk_wakeup
api to trigger the required irq. With this patch correct irqs are triggered

cat /proc/interrupts | grep enp1s0
161:          1          0          0          0 IR-PCI-MSIX-0000:01:00.0    0-edge      enp1s0
162:          2          0          0          0 IR-PCI-MSIX-0000:01:00.0    1-edge      enp1s0-rx-0
163:        359          0          0          0 IR-PCI-MSIX-0000:01:00.0    2-edge      enp1s0-rx-1
164:     872005          0          0          0 IR-PCI-MSIX-0000:01:00.0    3-edge      enp1s0-tx-0
165:         71          0          0          0 IR-PCI-MSIX-0000:01:00.0    4-edge      enp1s0-tx-1

TIMESTAMP: 149658589239205 | FUNCTION: igc_xsk_wakeup | ENTRY: RtcTxThread (PID: 10633) - queue_id: 0
TIMESTAMP: 149658589244662 | FUNCTION: igc_poll | ENTRY: irq/164-enp1s0- (PID: 10593)
TIMESTAMP: 149658589293396 | FUNCTION: igc_poll | ENTRY: irq/164-enp1s0- (PID: 10593)
TIMESTAMP: 149658589295357 | FUNCTION: xsk_tx_completed | ENTRY: irq/164-enp1s0- (PID: 10593) - num_entries: 61
TIMESTAMP: 149658589342151 | FUNCTION: igc_poll | ENTRY: irq/164-enp1s0- (PID: 10593)
TIMESTAMP: 149658589343881 | FUNCTION: xsk_tx_completed | ENTRY: irq/164-enp1s0- (PID: 10593) - num_entries: 3
TIMESTAMP: 149658589391394 | FUNCTION: igc_poll | ENTRY: irq/164-enp1s0- (PID: 10593)
TIMESTAMP: 149658590239215 | FUNCTION: igc_xsk_wakeup | ENTRY: RtcTxThread (PID: 10633) - queue_id: 0

Signed-off-by: Vivek Behera <vivek.behera@siemens.com>
---
drivers/net/ethernet/intel/igc/igc_main.c | 31 +++++++++++++++++++----
1 file changed, 26 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c
index 7aafa60ba0c8..0cfcd20a2536 100644
--- a/drivers/net/ethernet/intel/igc/igc_main.c
+++ b/drivers/net/ethernet/intel/igc/igc_main.c
@@ -6930,21 +6930,42 @@ int igc_xsk_wakeup(struct net_device *dev, u32 queue_id, u32 flags)
           if (!igc_xdp_is_enabled(adapter))
                       return -ENXIO;
-           if (queue_id >= adapter->num_rx_queues)
+          if ((flags & XDP_WAKEUP_RX) && (flags & XDP_WAKEUP_TX)) {
+                      /* If both TX and RX need to be woken up queue pair per IRQ is needed */
+                      if (!(adapter->flags & IGC_FLAG_QUEUE_PAIRS))
+                                  return -EINVAL; /* igc queue pairs are not activated.
+                                                          * Can't trigger irq
+                                                          */
+                      /* Just get the ring params from Rx */
+                      if (queue_id >= adapter->num_rx_queues)
+                                  return -EINVAL;
+                      ring = adapter->rx_ring[queue_id];
+          } else if (flags & XDP_WAKEUP_TX) {
+                      if (queue_id >= adapter->num_tx_queues)
+                                  return -EINVAL;
+                      /* Get the ring params from Tx */
+                      ring = adapter->tx_ring[queue_id];
+          } else if (flags & XDP_WAKEUP_RX) {
+                      if (queue_id >= adapter->num_rx_queues)
+                                  return -EINVAL;
+                      /* Get the ring params from Rx */
+                      ring = adapter->rx_ring[queue_id];
+          } else {
+                      /* Invalid Flags */
                       return -EINVAL;
-
-           ring = adapter->rx_ring[queue_id];
+          }
            if (!ring->xsk_pool)
                       return -ENXIO;
-
-           q_vector = adapter->q_vector[queue_id];
+          /* Retrieve the q_vector saved in the ring */
+          q_vector = ring->q_vector;
           if (!napi_if_scheduled_mark_missed(&q_vector->napi))
                       igc_trigger_rxtxq_interrupt(adapter, q_vector);
            return 0;
}
+
static ktime_t igc_get_tstamp(struct net_device *dev,
                                         const struct skb_shared_hwtstamps *hwtstamps,
                                         bool cycles)
--
2.34.1

[-- Attachment #1.2: Type: text/html, Size: 28632 bytes --]

[-- Attachment #2: 0001-igc-Fix-trigger-of-incorrect-irq-in-igc_xsk_wakeup-f.patch --]
[-- Type: application/octet-stream, Size: 5711 bytes --]

From 4e3ebdc0af6baa83ccfc17c61c1eb61408095ffd Mon Sep 17 00:00:00 2001
From: Vivek Behera <vivek.behera@siemens.com>
Date: Fri, 5 Dec 2025 10:26:05 +0100
Subject: [PATCH] igc: Fix trigger of incorrect irq in igc_xsk_wakeup function

When the i226 is configured to use only 2 comined queues using ethtool
or in an environment with only 2 active CPU cores the 4 irq lines
are used in a split configuration with one irq
assigned to each of the two rx and tx queues
(see console output below)

sudo ethtool -l enp1s0
Channel parameters for enp1s0:
Pre-set maximums:
RX:                        n/a
TX:                         n/a
Other:                  1
Combined:        4
Current hardware settings:
RX:                        n/a
TX:                         n/a
Other:                  1
Combined:        2
eddx@mvs:~$ cat /proc/interrupts | grep enp1s0
147:          1          0  IR-PCI-MSIX-0000:01:00.0   0-edge      enp1s0
148:          8          0  IR-PCI-MSIX-0000:01:00.0   1-edge      enp1s0-rx-0
149:          0          0  IR-PCI-MSIX-0000:01:00.0   2-edge      enp1s0-rx-1
150:         26          0  IR-PCI-MSIX-0000:01:00.0   3-edge      enp1s0-tx-0
151:          0          0  IR-PCI-MSIX-0000:01:00.0   4-edge      enp1s0-tx-1

While testing with the RTC Testbench it was noticed
using the bpftrace that the
igc_xsk_wakeup when triggered by xsk_sendmsg
was triggering the incorrect irq for
tx-0(see trace below)

TIMESTAMP: 456992309829 | FUNCTION: igc_xsk_wakeup | ENTRY: RtcTxThread (PID: 945) - queue_id: 0
TIMESTAMP: 456992317157 | FUNCTION: igc_poll | ENTRY: irq/148-enp1s0- (PID: 948)
TIMESTAMP: 456993309408 | FUNCTION: igc_xsk_wakeup | ENTRY: RtcTxThread (PID: 945) - queue_id: 0
TIMESTAMP: 456993316591 | FUNCTION: igc_poll | ENTRY: irq/148-enp1s0- (PID: 948)
TIMESTAMP: 456994309630 | FUNCTION: igc_xsk_wakeup | ENTRY: RtcTxThread (PID: 945) - queue_id: 0
TIMESTAMP: 456994316674 | FUNCTION: igc_poll | ENTRY: irq/148-enp1s0- (PID: 948)
TIMESTAMP: 456995309493 | FUNCTION: igc_xsk_wakeup | ENTRY: RtcTxThread (PID: 945) - queue_id: 0
TIMESTAMP: 456995316593 | FUNCTION: igc_poll | ENTRY: irq/148-enp1s0- (PID: 948)

Due to this bug no XDP Zc send is possible in this split irq configuration.
This patch implements the correct logic of extracting the q_vectors saved
duirng the rx and tx ring allocation.
Furthermore the patch includes usage of flags provided by the ndo_xsk_wakeup
api to trigger the required irq. With this patch correct irqs are triggered

cat /proc/interrupts | grep enp1s0
 161:          1          0          0          0 IR-PCI-MSIX-0000:01:00.0    0-edge      enp1s0
 162:          2          0          0          0 IR-PCI-MSIX-0000:01:00.0    1-edge      enp1s0-rx-0
 163:        359          0          0          0 IR-PCI-MSIX-0000:01:00.0    2-edge      enp1s0-rx-1
 164:     872005          0          0          0 IR-PCI-MSIX-0000:01:00.0    3-edge      enp1s0-tx-0
 165:         71          0          0          0 IR-PCI-MSIX-0000:01:00.0    4-edge      enp1s0-tx-1

TIMESTAMP: 149658589239205 | FUNCTION: igc_xsk_wakeup | ENTRY: RtcTxThread (PID: 10633) - queue_id: 0
TIMESTAMP: 149658589244662 | FUNCTION: igc_poll | ENTRY: irq/164-enp1s0- (PID: 10593)
TIMESTAMP: 149658589293396 | FUNCTION: igc_poll | ENTRY: irq/164-enp1s0- (PID: 10593)
TIMESTAMP: 149658589295357 | FUNCTION: xsk_tx_completed | ENTRY: irq/164-enp1s0- (PID: 10593) - num_entries: 61
TIMESTAMP: 149658589342151 | FUNCTION: igc_poll | ENTRY: irq/164-enp1s0- (PID: 10593)
TIMESTAMP: 149658589343881 | FUNCTION: xsk_tx_completed | ENTRY: irq/164-enp1s0- (PID: 10593) - num_entries: 3
TIMESTAMP: 149658589391394 | FUNCTION: igc_poll | ENTRY: irq/164-enp1s0- (PID: 10593)
TIMESTAMP: 149658590239215 | FUNCTION: igc_xsk_wakeup | ENTRY: RtcTxThread (PID: 10633) - queue_id: 0

Signed-off-by: Vivek Behera <vivek.behera@siemens.com>
---
 drivers/net/ethernet/intel/igc/igc_main.c | 31 +++++++++++++++++++----
 1 file changed, 26 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c
index 7aafa60ba0c8..0cfcd20a2536 100644
--- a/drivers/net/ethernet/intel/igc/igc_main.c
+++ b/drivers/net/ethernet/intel/igc/igc_main.c
@@ -6930,21 +6930,42 @@ int igc_xsk_wakeup(struct net_device *dev, u32 queue_id, u32 flags)
 	if (!igc_xdp_is_enabled(adapter))
 		return -ENXIO;
 
-	if (queue_id >= adapter->num_rx_queues)
+	if ((flags & XDP_WAKEUP_RX) && (flags & XDP_WAKEUP_TX)) {
+		/* If both TX and RX need to be woken up queue pair per IRQ is needed */
+		if (!(adapter->flags & IGC_FLAG_QUEUE_PAIRS))
+			return -EINVAL; /* igc queue pairs are not activated.
+					 * Can't trigger irq
+					 */
+		/* Just get the ring params from Rx */
+		if (queue_id >= adapter->num_rx_queues)
+			return -EINVAL;
+		ring = adapter->rx_ring[queue_id];
+	} else if (flags & XDP_WAKEUP_TX) {
+		if (queue_id >= adapter->num_tx_queues)
+			return -EINVAL;
+		/* Get the ring params from Tx */
+		ring = adapter->tx_ring[queue_id];
+	} else if (flags & XDP_WAKEUP_RX) {
+		if (queue_id >= adapter->num_rx_queues)
+			return -EINVAL;
+		/* Get the ring params from Rx */
+		ring = adapter->rx_ring[queue_id];
+	} else {
+		/* Invalid Flags */
 		return -EINVAL;
-
-	ring = adapter->rx_ring[queue_id];
+	}
 
 	if (!ring->xsk_pool)
 		return -ENXIO;
-
-	q_vector = adapter->q_vector[queue_id];
+	/* Retrieve the q_vector saved in the ring */
+	q_vector = ring->q_vector;
 	if (!napi_if_scheduled_mark_missed(&q_vector->napi))
 		igc_trigger_rxtxq_interrupt(adapter, q_vector);
 
 	return 0;
 }
 
+
 static ktime_t igc_get_tstamp(struct net_device *dev,
 			      const struct skb_shared_hwtstamps *hwtstamps,
 			      bool cycles)
-- 
2.34.1


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

end of thread, other threads:[~2025-12-10 16:42 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-05 12:39 [Intel-wired-lan] [PATCH] igc: Fix trigger of incorrect irq in igc_xsk_wakeup function Behera, VIVEK
2025-12-05 12:39 ` Behera, VIVEK
2025-12-05 21:05 ` [Intel-wired-lan] " Loktionov, Aleksandr
2025-12-06 12:03   ` Behera, VIVEK
2025-12-06 12:03     ` Behera, VIVEK
2025-12-07 15:46 ` [Intel-wired-lan] [PATCH v2] igc: Enhance xsk wakeup for split IRQ and fix PTP TX wakeup Behera, VIVEK
2025-12-07 15:46   ` Behera, VIVEK
2025-12-08 23:53 ` [Intel-wired-lan] [PATCH] igc: Fix trigger of incorrect irq in igc_xsk_wakeup function Jacob Keller
2025-12-08 23:53   ` Jacob Keller
2025-12-09  6:03   ` [Intel-wired-lan] " Behera, VIVEK
2025-12-09  6:03     ` Behera, VIVEK
2025-12-09  6:46     ` [Intel-wired-lan] [PATCH v3 iwl-net] " Behera, VIVEK
2025-12-09  6:46       ` Behera, VIVEK
2025-12-09  8:05       ` [Intel-wired-lan] " Loktionov, Aleksandr
2025-12-09  8:05         ` Loktionov, Aleksandr
2025-12-10  7:09         ` [Intel-wired-lan] [PATCH v4 " Behera, VIVEK
2025-12-10  7:09           ` AW: " Behera, VIVEK
2025-12-10  7:16         ` [Intel-wired-lan] [PATCH v3 " Loktionov, Aleksandr
2025-12-10  7:16           ` Loktionov, Aleksandr
2025-12-10  7:50           ` [Intel-wired-lan] [PATCH v5 " Behera, VIVEK
2025-12-10  7:50             ` AW: " Behera, VIVEK
2025-12-10  8:57             ` [Intel-wired-lan] " Jakub Kicinski
2025-12-10  8:57               ` Jakub Kicinski
2025-12-10 10:16             ` [Intel-wired-lan] " Kurt Kanzenbach
2025-12-10 10:16               ` AW: " Kurt Kanzenbach
2025-12-10 10:48               ` [Intel-wired-lan] " Behera, VIVEK
2025-12-10 14:34                 ` Kurt Kanzenbach
2025-12-10 16:41             ` Paul Menzel
2025-12-10 10:15       ` [Intel-wired-lan] [PATCH v3 " Kwapulinski, Piotr
2025-12-10 10:15         ` Kwapulinski, Piotr

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.