Page MenuHomeFreeBSD

alc(4): fix interrupt handling for the CCR2004-1G-2XS-PCIe
Needs ReviewPublic

Authored by ryan_krammer.me on Mon, Aug 31, 11:39 PM.
Tags
None
Referenced Files
F170563492: D59295.diff
Sat, Sep 5, 10:33 AM
F170426853: D59295.id185590.diff
Fri, Sep 4, 6:57 PM
Unknown Object (File)
Thu, Sep 3, 12:08 PM
Unknown Object (File)
Thu, Sep 3, 11:05 AM
Unknown Object (File)
Thu, Sep 3, 10:33 AM
Unknown Object (File)
Thu, Sep 3, 9:20 AM
Unknown Object (File)
Thu, Sep 3, 9:18 AM
Unknown Object (File)
Thu, Sep 3, 9:08 AM
Subscribers

Details

Reviewers
ivy
Group Reviewers
network
Summary

Bringing the alc interface corresponding to the Mikrotik card can sometimes wedge the whole machine - the SSH session to the box dropped, and testing on the local console revealed that the onboard em(4) interface stopped passing traffic, and ifconfig hung any shell until I rebooted the machine.

This card's interrupt status register does not clear on write. Reading it back after acknowledging INTR_RX_PKT0 returns exactly the same bits that were written. alc_int_task() re-reads the register to figure out if more work arrives, but it always finds the bit it just wrote, and re-queues itself forever.

Skip that check on the Mikrotik card, as there is no way to tell if a bit we just read is stale or fresh. Additionally, we now acknowledge only the bits we actually handle, rather than writing the whole register back blindly, and have a per-softc interrupt mask so this card can use a different mask (in this case, to add interrupts that report the link state, and in the future, handle multiple RX queues.)

The card does not yet pass traffic, but it is a step in the right direction, and prevents a system hang when the alc interface associated with the Mikrotik card is brought up.

Test Plan

Patch has been tested against FreeBSD 15.1-STABLE. The hardware configuration is an HP ProDesk SFF desktop computer, with an Intel Core i5-4570 CPU, 8 gigabytes of DDR3 RAM, and the CCR2004-1G-2XS-PCIe card under test running RouterOS 7.24, installed in the first PCI express slot.

Note that I have not tested this patch in a system with a real alc(4) card; I don't own one. However, all changes here are gated to by an existing flag to only operate when the CCR2004 card is detected.

This patch has been tested only on top of D59228, and not in isolation.

Before the change, if you were to run ifconfig up and ifconfig down enough times (sometimes as few as 1,) on an alc interface corresponding to a CCR2004 card, the system would wedge as described in the summary. After the change, this does not happen anymore.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 76393
Build 73276: arc lint + arc unit

Event Timeline

ryan_krammer.me held this revision as a draft.
sys/dev/alc/if_alc.c
3472

This change is the one exception to my assertion in the Test Plan that all changes are gated by the ALC_FLAG_MT flag. Here, we only acknowledge the interrupts we're actually listening for. If we want to be super careful/defensive without the ability to test on a real Atheros card, then we can gate this change behind the flag check as well, but I don't feel that it should have any meaningful effect on said cards.

sys/dev/alc/if_alc.c
3519

line continuations like this should use four spaces, rather than a tab, per style(9). the removed code just above shows a correct example of this.

fix line continuation indent

ryan_krammer.me marked an inline comment as done.