Skip to contentSkip to conversation

igc: Fix XSK queue NAPI ID mapping

PATCH In review Joe Damato 5 participants 7 messages Mar 5, 2025 – Mar 25, 2025

Subsystems (6)
lore
Share & tools
lore

Joe Damato

author
#0 lore raw

PATCH 1/1 igc: Fix XSK queue NAPI ID mapping

In commit b65969856d4f ("igc: Link queues to NAPI instances"), the XSK queues were incorrectly unmapped from their NAPI instances. After discussion on the mailing list and the introduction of a test to codify the expected behavior, we can see that the unmapping causes the check_xsk test to fail:

NETIF=enp86s0 ./tools/testing/selftests/drivers/net/queues.py

[...]
# Check| ksft_eq(q.get('xsk', None), {},
# Check failed None != {} xsk attr on queue we configured not ok 4 queues.check_xsk

After this commit, the test passes:

ok 4 queues.check_xsk

Note that the test itself is only in net-next, so I tested this change by applying it to my local net-next tree, booting, and running the test.

Fixes b65969856d4f ("igc: Link queues to NAPI instances")
---
 drivers/net/ethernet/intel/igc/igc_xdp.c | 2 --
 1 file changed, 2 deletions(-)
drivers/net/ethernet/intel/igc/igc_xdp.c +0 -2
index 13bbd3346e01..869815f48ac1 100644
@@ -86,7 +86,6 @@ static int igc_xdp_enable_pool(struct igc_adapter *adapter,
 		napi_disable(napi);
 	}
 
-	igc_set_queue_napi(adapter, queue_id, NULL);
 	set_bit(IGC_RING_FLAG_AF_XDP_ZC, &rx_ring->flags);
 	set_bit(IGC_RING_FLAG_AF_XDP_ZC, &tx_ring->flags);
 
@@ -136,7 +135,6 @@ static int igc_xdp_disable_pool(struct igc_adapter *adapter, u16 queue_id)
 	xsk_pool_dma_unmap(pool, IGC_RX_DMA_ATTR);
 	clear_bit(IGC_RING_FLAG_AF_XDP_ZC, &rx_ring->flags);
 	clear_bit(IGC_RING_FLAG_AF_XDP_ZC, &tx_ring->flags);
-	igc_set_queue_napi(adapter, queue_id, napi);
 
 	if (needs_reset) {
 		napi_enable(napi);

base-commit: 3c9231ea6497dfc50ac0ef69fff484da27d0df66

Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 48 lines · Joe Damato

In commit b65969856d4f ("igc: Link queues to NAPI instances"), the XSK queues were incorrectly unmapped from their NAPI instances. After discussion on the mailing list and the introduction of a test to codify the expected behavior, we can see that the unmapping causes the check_xsk test to fail:

NETIF=enp86s0 ./tools/testing/selftests/drivers/net/queues.py

[...]
# Check| ksft_eq(q.get('xsk', None), {},
# Check failed None != {} xsk attr on queue we configured not ok 4 queues.check_xsk

After this commit, the test passes:

ok 4 queues.check_xsk

Note that the test itself is only in net-next, so I tested this change by applying it to my local net-next tree, booting, and running the test.

Fixes b65969856d4f ("igc: Link queues to NAPI instances")
---
  drivers/net/ethernet/intel/igc/igc_xdp.c | 2 --
  1 file changed, 2 deletions(-)
drivers/net/ethernet/intel/igc/igc_xdp.c +0 -2
index 13bbd3346e01..869815f48ac1 100644
@@ -86,7 +86,6 @@ static int igc_xdp_enable_pool(struct igc_adapter *adapter,
  		napi_disable(napi);
  	}
 
-	igc_set_queue_napi(adapter, queue_id, NULL);
  	set_bit(IGC_RING_FLAG_AF_XDP_ZC, &rx_ring->flags);
  	set_bit(IGC_RING_FLAG_AF_XDP_ZC, &tx_ring->flags);
 
@@ -136,7 +135,6 @@ static int igc_xdp_disable_pool(struct igc_adapter *adapter, u16 queue_id)
  	xsk_pool_dma_unmap(pool, IGC_RX_DMA_ATTR);
  	clear_bit(IGC_RING_FLAG_AF_XDP_ZC, &rx_ring->flags);
  	clear_bit(IGC_RING_FLAG_AF_XDP_ZC, &tx_ring->flags);
-	igc_set_queue_napi(adapter, queue_id, napi);
 
  	if (needs_reset) {
  		napi_enable(napi);
Quoted 1 line

base-commit: 3c9231ea6497dfc50ac0ef69fff484da27d0df66

igc_set_queue_napi() could be made static as it only used within igc_main.c after this change.

#2 lore raw
In reply to Joe Damato

Hi Joe,

Quoted 49 lines · Joe Damato

In commit b65969856d4f ("igc: Link queues to NAPI instances"), the XSK queues were incorrectly unmapped from their NAPI instances. After discussion on the mailing list and the introduction of a test to codify the expected behavior, we can see that the unmapping causes the check_xsk test to fail:

NETIF=enp86s0 ./tools/testing/selftests/drivers/net/queues.py

[...]
# Check| ksft_eq(q.get('xsk', None), {},
# Check failed None != {} xsk attr on queue we configured not ok 4 queues.check_xsk

After this commit, the test passes:

ok 4 queues.check_xsk

Note that the test itself is only in net-next, so I tested this change by applying it to my local net-next tree, booting, and running the test.

Fixes b65969856d4f ("igc: Link queues to NAPI instances")
---
 drivers/net/ethernet/intel/igc/igc_xdp.c | 2 --
 1 file changed, 2 deletions(-)
drivers/net/ethernet/intel/igc/igc_xdp.c +0 -2
index 13bbd3346e01..869815f48ac1 100644
@@ -86,7 +86,6 @@ static int igc_xdp_enable_pool(struct igc_adapter 
 *adapter,
 		napi_disable(napi);
 	}
 
-	igc_set_queue_napi(adapter, queue_id, NULL);
 	set_bit(IGC_RING_FLAG_AF_XDP_ZC, &rx_ring->flags);
 	set_bit(IGC_RING_FLAG_AF_XDP_ZC, &tx_ring->flags);
@@ -136,7 +135,6 @@ static int igc_xdp_disable_pool(struct igc_adapter
 *adapter, u16 queue_id)
 	xsk_pool_dma_unmap(pool, IGC_RX_DMA_ATTR);
 	clear_bit(IGC_RING_FLAG_AF_XDP_ZC, &rx_ring->flags);
 	clear_bit(IGC_RING_FLAG_AF_XDP_ZC, &tx_ring->flags);
-	igc_set_queue_napi(adapter, queue_id, napi);
 
 	if (needs_reset) {
Quoted 1 line

napi_enable(napi);

That doesn't look correct to me. You removed both invocations of igc_set_queue_napi() from igc_xdp.c. Where is the napi mapping now done (in case XDP is enabled)?

To me it seems flipped. igc_xdp_enable_pool() should do the mapping (previously did the unmapping) and igc_xdp_disable_pool() should do the unmapping (previously did the mapping). No?

Btw: I got this patch via stable. It doesn't make sense to send it to stable where this patch does not apply.

Quoted 2 lines

base-commit: 3c9231ea6497dfc50ac0ef69fff484da27d0df66

author
#3 lore raw
Quoted 51 lines · On Thu, Mar 06, 2025 at 05:27:38PM +0100, [email protected] wrote:

Hi Joe,

Quoted 48 lines · Joe Damato

In commit b65969856d4f ("igc: Link queues to NAPI instances"), the XSK queues were incorrectly unmapped from their NAPI instances. After discussion on the mailing list and the introduction of a test to codify the expected behavior, we can see that the unmapping causes the check_xsk test to fail:

NETIF=enp86s0 ./tools/testing/selftests/drivers/net/queues.py

[...]
# Check| ksft_eq(q.get('xsk', None), {},
# Check failed None != {} xsk attr on queue we configured not ok 4 queues.check_xsk

After this commit, the test passes:

ok 4 queues.check_xsk

Note that the test itself is only in net-next, so I tested this change by applying it to my local net-next tree, booting, and running the test.

Fixes b65969856d4f ("igc: Link queues to NAPI instances")
---
 drivers/net/ethernet/intel/igc/igc_xdp.c | 2 --
 1 file changed, 2 deletions(-)
drivers/net/ethernet/intel/igc/igc_xdp.c +0 -2
index 13bbd3346e01..869815f48ac1 100644
@@ -86,7 +86,6 @@ static int igc_xdp_enable_pool(struct igc_adapter
 *adapter,
 		napi_disable(napi);
 	}
 
-	igc_set_queue_napi(adapter, queue_id, NULL);
 	set_bit(IGC_RING_FLAG_AF_XDP_ZC, &rx_ring->flags);
 	set_bit(IGC_RING_FLAG_AF_XDP_ZC, &tx_ring->flags);
@@ -136,7 +135,6 @@ static int igc_xdp_disable_pool(struct igc_adapter
 *adapter, u16 queue_id)
 	xsk_pool_dma_unmap(pool, IGC_RX_DMA_ATTR);
 	clear_bit(IGC_RING_FLAG_AF_XDP_ZC, &rx_ring->flags);
 	clear_bit(IGC_RING_FLAG_AF_XDP_ZC, &tx_ring->flags);
-	igc_set_queue_napi(adapter, queue_id, napi);
 
Quoted 6 lines
Quoted 2 lines
drivers/net/ethernet/intel/igc/igc_xdp.c +0 -0
 	if (needs_reset) {

napi_enable(napi);

That doesn't look correct to me. You removed both invocations of igc_set_queue_napi() from igc_xdp.c. Where is the napi mapping now done (in case XDP is enabled)?

igc_set_queue_napi is called when the queues are created (igc_up, __igc_open). When the queues are created they'll be linked. Whether or not XDP is enabled does not affect the queues being linked.

The test added for this (which I mentioned in the commit message) confirms that this is the correct behavior, as does the documentation in Documentation/netlink/specs/netdev.yaml.

See commit df524c8f5771 ("netdev-genl: Add an XSK attribute to queues").

Quoted 3 lines

To me it seems flipped. igc_xdp_enable_pool() should do the mapping (previously did the unmapping) and igc_xdp_disable_pool() should do the unmapping (previously did the mapping). No?

In igc, all queues get their NAPIs mapped in igc_up or __igc_open. I had mistakenly added code to remove the mapping for XDP because I was under the impression that NAPIs should not be mapped for XDP queues. See the commit under fixes.

This was incorrect, so this commit removes the unmapping and corrects the behavior.

With this change, all queues have their NAPIs mapped (whether or not they are used for AF_XDP) and is the agreed upon behavior based on prior conversations on the list and the documentation I mentioned above.

Quoted 2 lines

Btw: I got this patch via stable. It doesn't make sense to send it to stable where this patch does not apply.

Maybe I made a mistake, but as far as I can tell the commit under fixes is in 6.14-rc*:

$ git tag --contains b65969856d4f
v6.14-rc1
v6.14-rc2
v6.14-rc3
v6.14-rc4

So, I think this change is:
- Correct
- Definitely a "fixes" and should go to iwl-net
- But maybe does not need to CC stable ?

If the Intel folks would like me to resend with some change please let me know.

maintainer
#4 lore raw
Quoted 1 line · Joe Damato

On Thu, Mar 06, 2025 at 05:27:38PM +0100, [email protected] wrote:

...

Quoted 12 lines
Quoted 2 lines

Btw: I got this patch via stable. It doesn't make sense to send it to stable where this patch does not apply.

Maybe I made a mistake, but as far as I can tell the commit under fixes is in 6.14-rc*:

$ git tag --contains b65969856d4f
v6.14-rc1
v6.14-rc2
v6.14-rc3
v6.14-rc4
Quoted 7 lines

So, I think this change is:
- Correct
- Definitely a "fixes" and should go to iwl-net
- But maybe does not need to CC stable ?

If the Intel folks would like me to resend with some change please let me know.

Seems like the only change needed is the omission of stable. If so, no changes need. I can take care of that when sending on to netdev.

Thanks,
Tony

maintainer
#5 lore raw
Quoted 22 lines · Tony Nguyen
Quoted 1 line · Joe Damato

On Thu, Mar 06, 2025 at 05:27:38PM +0100, [email protected] wrote:

...

Quoted 17 lines
Quoted 2 lines

Btw: I got this patch via stable. It doesn't make sense to send it to stable where this patch does not apply.

Maybe I made a mistake, but as far as I can tell the commit under fixes is in 6.14-rc*:

$ git tag --contains b65969856d4f
v6.14-rc1
v6.14-rc2
v6.14-rc3
v6.14-rc4

So, I think this change is:
   - Correct
   - Definitely a "fixes" and should go to iwl-net
   - But maybe does not need to CC stable ?

Quoted 4 lines
Quoted 2 lines

If the Intel folks would like me to resend with some change please let me know.

Seems like the only change needed is the omission of stable. If so, no changes need. I can take care of that when sending on to netdev.

I missed this comment [1] when I responded; I can make this change though.

Thanks,
Tony

[1] https://lore.kernel.org/intel-wired-lan/[email protected]/T/#m47dd425fb4de4c1738839c2f8253ec51718d299e

Tested-by on v1 1/1
#6 lore raw
In reply to Joe Damato
Quoted 20 lines · Joe Damato

In commit b65969856d4f ("igc: Link queues to NAPI instances"), the XSK queues were incorrectly unmapped from their NAPI instances. After discussion on the mailing list and the introduction of a test to codify the expected behavior, we can see that the unmapping causes the check_xsk test to fail:

NETIF=enp86s0 ./tools/testing/selftests/drivers/net/queues.py

[...]
# Check| ksft_eq(q.get('xsk', None), {},
# Check failed None != {} xsk attr on queue we configured not ok 4 queues.check_xsk

After this commit, the test passes:

ok 4 queues.check_xsk

Note that the test itself is only in net-next, so I tested this change by applying it to my local net-next tree, booting, and running the test.

Quoted 8 lines
Fixes b65969856d4f ("igc: Link queues to NAPI instances")
---
  drivers/net/ethernet/intel/igc/igc_xdp.c | 2 --
  1 file changed, 2 deletions(-)