Skip to content

Conversation

@diegonix
Copy link

Summary

This patch fixes XDP redirect operations failing with -ENXIO when the number of configured network queues is less than the number of online CPUs.

Problem Description

The i40e_xdp_xmit() function uses smp_processor_id() directly as a queue index without proper bounds checking. In performance-optimized environments where users configure fewer queues than CPUs (e.g., 4 queues on a 6-CPU system), XDP redirect operations from higher-numbered CPUs fail with errno 6 (ENXIO).

Root Cause

  • File: src/i40e_txrx.c
  • Function: i40e_xdp_xmit()
  • Issue: queue_index = smp_processor_id() can exceed vsi->num_queue_pairs
  • Result: CPUs 4-5 accessing 4 queues (0-3) triggers bounds check failure

Solution

Implement modulo-based CPU-to-queue mapping to ensure queue index never exceeds available queues:

  • Add i40e_xdp_queue_index() helper function using modulo operation
  • Add configuration warning in ethtool when setting channels < online CPUs with XDP enabled
  • Improve error messages for better diagnostics
  • Clean up debug messages to reduce noise

Testing

Test Environment

  • Hardware: Intel XL710 40GbE NIC (PCI ID: 0000:04:00.0)
  • Firmware: fw 9.154.78653 api 1.15 nvm 9.54
  • Driver: i40e v2.28.7 (patched)
  • Kernel: 5.15.0-309.180.4.el9uek.x86_64 (Oracle Linux)
  • System: 6-CPU server

Test Configuration

# Configure 4 queues on 6-CPU system
ethtool -L data0 combined 4
# Load XDP program for packet processing
# Result: XDP redirect from CPUs 4-5 previously failed

Additional Notes

  • This fix was developed on v2.28.7 release
  • Also tested in combination with pending [PR#7] without conflicts
  • The fix is independent and can be merged without dependencies

Signed-off-by: Diego [email protected]

This patch fixes XDP redirect operations failing with -ENXIO when the
number of configured queues is less than the number of online CPUs.

The issue occurs because i40e_xdp_xmit() uses smp_processor_id() directly
as a queue index without bounds checking. When users configure fewer
queues than CPUs (common in performance-optimized environments), XDP
redirect operations from higher-numbered CPUs fail.

Changes:
- Add i40e_xdp_queue_index() helper using modulo operation to map CPUs
to available queues
- Add configuration warning when channels < online CPUs with XDP enabled
- Improve error messages for better diagnostics
- Add safety check for queue index bounds (should never trigger)

This fix ensures XDP redirect operations work correctly regardless of
the CPU-to-queue ratio, preventing packet loss in optimized configurations.
@mw70830
Copy link

mw70830 commented Aug 7, 2025

Wouldn't it be simpler to fix it like the following, as other drivers do?
queue_index = smp_processor_id() % vsi->num_queue_pairs;

For reference, here’s how the ixgbe driver handles it:

static inline int ixgbe_determine_xdp_q_idx(int cpu) 
{
    if (static_key_enabled(&ixgbe_xdp_locking_key))
        return cpu % IXGBE_MAX_XDP_QS;
    else
        return cpu;
}

static inline
struct ixgbe_ring *ixgbe_determine_xdp_ring(struct ixgbe_adapter *adapter)
{
    int index = ixgbe_determine_xdp_q_idx(smp_processor_id());

    return adapter->xdp_ring[index];
}

@diegonix
Copy link
Author

I'm sorry, I was working with the i40e, I came across this problem and thought I would fix it right away, I didn't think about doing a degree in Intel network drivers before proposing something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants