iavf: Add explicit ifdi_needs_reset for VLAN changes

In rS360398, a new iflib device method was added with default of opt out
for VLAN events needing an interface reset.

iavf(4) was the original need for this, because VLAN filter changes
currently have negative interactions with Malicious Driver Detection.

Add iavf_if_needs_restart and explicitly enable VLAN re-init.

MFC after:	2 weeks
Sponsored by:	BBOX.io
Differential Revision:	https://reviews.freebsd.org/D41558
This commit is contained in:
Kevin Bowling 2023-08-24 13:36:00 -07:00
parent fe6c4e214d
commit 1d6c12c511

View File

@ -74,6 +74,7 @@ static void iavf_if_vlan_unregister(if_ctx_t ctx, u16 vtag);
static uint64_t iavf_if_get_counter(if_ctx_t ctx, ift_counter cnt);
static void iavf_if_init(if_ctx_t ctx);
static void iavf_if_stop(if_ctx_t ctx);
static bool iavf_if_needs_restart(if_ctx_t, enum iflib_restart_event);
static int iavf_allocate_pci_resources(struct iavf_sc *);
static void iavf_free_pci_resources(struct iavf_sc *);
@ -169,6 +170,7 @@ static device_method_t iavf_if_methods[] = {
DEVMETHOD(ifdi_vlan_register, iavf_if_vlan_register),
DEVMETHOD(ifdi_vlan_unregister, iavf_if_vlan_unregister),
DEVMETHOD(ifdi_get_counter, iavf_if_get_counter),
DEVMETHOD(ifdi_needs_restart, iavf_if_needs_restart),
DEVMETHOD_END
};
@ -1497,6 +1499,25 @@ iavf_if_get_counter(if_ctx_t ctx, ift_counter cnt)
}
}
/* iavf_if_needs_restart - Tell iflib when the driver needs to be reinitialized
* @ctx: iflib context
* @event: event code to check
*
* Defaults to returning false for unknown events.
*
* @returns true if iflib needs to reinit the interface
*/
static bool
iavf_if_needs_restart(if_ctx_t ctx __unused, enum iflib_restart_event event)
{
switch (event) {
case IFLIB_RESTART_VLAN_CONFIG:
return (true);
default:
return (false);
}
}
/**
* iavf_free_pci_resources - Free PCI resources
* @sc: device softc