Page MenuHomeFreeBSD

iflib: Allow drivers to veto unsafe hardware detach
Needs ReviewPublic

Authored by kbowling on Fri, Sep 25, 6:20 AM.

Details

Reviewers
gallatin
shurd
Group Reviewers
iflib
Summary

There are some tricky issues particularly in virtual interfaces where we want to temporarily "veto" a detach so we don't leave behind stale DMA windows. iavf will do an FLR in this helper before permitting detach.

Add an optional IFDI_DETACH_PRE callback after stopping an opted-in
datapath but before freeing queue structures or driver state.  A driver
whose failed shutdown left stale DMA addresses can reset the device or
refuse detach without losing its quarantine state.  Drivers without the
callback keep their existing teardown order.

Also check the callback during registration-failure cleanup after a
successful attach_pre.  Failure there is fatal because no attached
driver can retain the unsafe hardware state.  Pre-attach sysctls remain
available on a refused detach so the stopped device stays inspectable.

Run the veto after power preparation and the opt-in early stop, but
before committing to detach.  A refusing driver must undo detach-specific
preparation without restarting queue DMA or discarding quarantine state.

MFC after:      2 weeks
Sponsored by:   BBOX.io

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped