Skip to content

feat(rtl8139): implement interrupt-driven packet processing#52

Merged
pradosh-arduino merged 1 commit into
mainfrom
optimize/networking-performance
Jul 5, 2026
Merged

feat(rtl8139): implement interrupt-driven packet processing#52
pradosh-arduino merged 1 commit into
mainfrom
optimize/networking-performance

Conversation

@pradosh-arduino

Copy link
Copy Markdown
Collaborator

This commit enables truly event-driven networking instead of CPU-intensive polling:

RTL8139 Driver Changes (8139.c):

  • Added rtl8139_irq_driven flag to track interrupt mode status
  • Implemented rtl8139_process_packets() to process all available packets
  • Added rtl8139_interrupt_handler() called from ISR context
  • Packets processed immediately when hardware interrupt fires (ROK status)
  • Added rtl8139_irq_enable/disable() functions for mode control
  • Handles RX overflow, TX errors, and RX errors gracefully

Network Core Changes (net_core.c):

  • netif_init() now enables interrupt-driven mode
  • netif_poll() remains as fallback/safety for missed packets
  • Maintains backward compatibility while using interrupts when available

ISR Changes (isr.c):

  • rtl8139_handler() now calls rtl8139_interrupt_handler() for packet processing
  • Processes packets directly in interrupt context for minimum latency
  • Clears interrupt status bits immediately

RTL8139 Header (rtl8139.h):

  • Added new function declarations for interrupt-driven mode
  • Documented the shift from polling to interrupt-driven approach

Benefits:

  • Eliminates busy-waiting in the CPU-intensive netif_poll() loop
  • Packets processed with hardware interrupt latency (~microseconds)
  • CPU no longer wastes cycles polling when no packets available
  • Significant performance improvement for network-heavy workloads
  • Bottleneck now truly at network provider, not OS

This commit enables truly event-driven networking instead of CPU-intensive polling:

RTL8139 Driver Changes (8139.c):
- Added rtl8139_irq_driven flag to track interrupt mode status
- Implemented rtl8139_process_packets() to process all available packets
- Added rtl8139_interrupt_handler() called from ISR context
- Packets processed immediately when hardware interrupt fires (ROK status)
- Added rtl8139_irq_enable/disable() functions for mode control
- Handles RX overflow, TX errors, and RX errors gracefully

Network Core Changes (net_core.c):
- netif_init() now enables interrupt-driven mode
- netif_poll() remains as fallback/safety for missed packets
- Maintains backward compatibility while using interrupts when available

ISR Changes (isr.c):
- rtl8139_handler() now calls rtl8139_interrupt_handler() for packet processing
- Processes packets directly in interrupt context for minimum latency
- Clears interrupt status bits immediately

RTL8139 Header (rtl8139.h):
- Added new function declarations for interrupt-driven mode
- Documented the shift from polling to interrupt-driven approach

Benefits:
- Eliminates busy-waiting in the CPU-intensive netif_poll() loop
- Packets processed with hardware interrupt latency (~microseconds)
- CPU no longer wastes cycles polling when no packets available
- Significant performance improvement for network-heavy workloads
- Bottleneck now truly at network provider, not OS
@pradosh-arduino pradosh-arduino merged commit d31eca8 into main Jul 5, 2026
0 of 2 checks passed
@pradosh-arduino pradosh-arduino deleted the optimize/networking-performance branch July 5, 2026 13:35
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.

1 participant