Ethernet Device Polling for OpenBSD

Polling helps prevent livelock when the machine starts receving packets at a high rate. Interrupts, especially one per packet, increase the time spent processsing each packet. Interrupts are more efficient for slower packet rates, however, so you don't waste time polling for packets which don't exist. To use: enable option DEVICE_POLLING and rebuild kernel. There are sysctls available to control: And an ioctl to turn polling on/off by interface. All settings are currently enabled, and I set some (to me) sane defaults. In actual practice, polling should perhaps not be the default. Note that if you're using gigabit, the default values are probably too slow.

The patch is here polling.diff

Driver support:
Tested: rl, fxp, ti
Should work: dc, sk, bge, nge, lge, em, gem

The current code to switch modes automatically is rather retarded. It will turn off polling if it doesn't get enough traffic, but the very next packet will turn it back on. wantpoll should be used as an integer instead of a boolean, and the driver will go to polling only after receiving the requisite number of packets.

Improve the speed of the fast path since it's probably going to be called more often. Don't do PCI reads.

Maybe not call txeof or rxeof every poll if there's some way to avoid it. I took a stab at this with the rl driver, since it fixed a funky bug where txeof was inflating the outbound packet count.

fxp driver will not deal with the rnr condition in poll mode. This could be problematic. FreeBSD has a workaround, but I haven't imported it yet.

More drivers.