igc: Fix up hw vlan ops

Adapt 2796f7cab1 to igc(4)

* Don't reset the entire adapter for vlan changes, fix up the problems
* Remove the VFTA, this hardware doesn't seem to implement it

Approved by:	grehan
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D31979
This commit is contained in:
Kevin Bowling 2022-10-10 16:09:21 -07:00
parent 8938d16266
commit 2eaef8ec4a
2 changed files with 19 additions and 79 deletions

View File

@ -93,8 +93,6 @@ static void igc_if_media_status(if_ctx_t, struct ifmediareq *);
static int igc_if_media_change(if_ctx_t ctx);
static int igc_if_mtu_set(if_ctx_t ctx, uint32_t mtu);
static void igc_if_timer(if_ctx_t ctx, uint16_t qid);
static void igc_if_vlan_register(if_ctx_t ctx, u16 vtag);
static void igc_if_vlan_unregister(if_ctx_t ctx, u16 vtag);
static void igc_if_watchdog_reset(if_ctx_t ctx);
static bool igc_if_needs_restart(if_ctx_t ctx, enum iflib_restart_event event);
@ -118,7 +116,7 @@ static void igc_if_debug(if_ctx_t ctx);
static void igc_update_stats_counters(struct igc_adapter *);
static void igc_add_hw_stats(struct igc_adapter *adapter);
static int igc_if_set_promisc(if_ctx_t ctx, int flags);
static void igc_setup_vlan_hw_support(struct igc_adapter *);
static void igc_setup_vlan_hw_support(if_ctx_t ctx);
static int igc_sysctl_nvm_info(SYSCTL_HANDLER_ARGS);
static void igc_print_nvm_info(struct igc_adapter *);
static int igc_sysctl_debug_info(SYSCTL_HANDLER_ARGS);
@ -199,8 +197,6 @@ static device_method_t igc_if_methods[] = {
DEVMETHOD(ifdi_promisc_set, igc_if_set_promisc),
DEVMETHOD(ifdi_timer, igc_if_timer),
DEVMETHOD(ifdi_watchdog_reset, igc_if_watchdog_reset),
DEVMETHOD(ifdi_vlan_register, igc_if_vlan_register),
DEVMETHOD(ifdi_vlan_unregister, igc_if_vlan_unregister),
DEVMETHOD(ifdi_get_counter, igc_if_get_counter),
DEVMETHOD(ifdi_rx_queue_intr_enable, igc_if_rx_queue_intr_enable),
DEVMETHOD(ifdi_tx_queue_intr_enable, igc_if_tx_queue_intr_enable),
@ -441,9 +437,8 @@ igc_set_num_queues(if_ctx_t ctx)
#define IGC_CAPS \
IFCAP_HWCSUM | IFCAP_VLAN_MTU | IFCAP_VLAN_HWTAGGING | \
IFCAP_VLAN_HWCSUM | IFCAP_WOL | IFCAP_VLAN_HWFILTER | IFCAP_TSO4 | \
IFCAP_LRO | IFCAP_VLAN_HWTSO | IFCAP_JUMBO_MTU | IFCAP_HWCSUM_IPV6 |\
IFCAP_TSO6
IFCAP_VLAN_HWCSUM | IFCAP_WOL | IFCAP_TSO4 | IFCAP_LRO | \
IFCAP_VLAN_HWTSO | IFCAP_JUMBO_MTU | IFCAP_HWCSUM_IPV6 | IFCAP_TSO6
/*********************************************************************
* Device initialization routine
@ -844,18 +839,8 @@ igc_if_init(if_ctx_t ctx)
adapter->rx_mbuf_sz = iflib_get_rx_mbuf_sz(ctx);
igc_initialize_receive_unit(ctx);
/* Use real VLAN Filter support? */
if (if_getcapenable(ifp) & IFCAP_VLAN_HWTAGGING) {
if (if_getcapenable(ifp) & IFCAP_VLAN_HWFILTER)
/* Use real VLAN Filter support */
igc_setup_vlan_hw_support(adapter);
else {
u32 ctrl;
ctrl = IGC_READ_REG(&adapter->hw, IGC_CTRL);
ctrl |= IGC_CTRL_VME;
IGC_WRITE_REG(&adapter->hw, IGC_CTRL, ctrl);
}
}
/* Set up VLAN support */
igc_setup_vlan_hw_support(ctx);
/* Don't lose promiscuous settings */
igc_if_set_promisc(ctx, if_getflags(ifp));
@ -2138,62 +2123,25 @@ igc_initialize_receive_unit(if_ctx_t ctx)
}
static void
igc_if_vlan_register(if_ctx_t ctx, u16 vtag)
igc_setup_vlan_hw_support(if_ctx_t ctx)
{
struct igc_adapter *adapter = iflib_get_softc(ctx);
u32 index, bit;
index = (vtag >> 5) & 0x7F;
bit = vtag & 0x1F;
adapter->shadow_vfta[index] |= (1 << bit);
++adapter->num_vlans;
}
static void
igc_if_vlan_unregister(if_ctx_t ctx, u16 vtag)
{
struct igc_adapter *adapter = iflib_get_softc(ctx);
u32 index, bit;
index = (vtag >> 5) & 0x7F;
bit = vtag & 0x1F;
adapter->shadow_vfta[index] &= ~(1 << bit);
--adapter->num_vlans;
}
static void
igc_setup_vlan_hw_support(struct igc_adapter *adapter)
{
struct igc_hw *hw = &adapter->hw;
struct ifnet *ifp = iflib_get_ifp(ctx);
u32 reg;
/*
* We get here thru init_locked, meaning
* a soft reset, this has already cleared
* the VFTA and other state, so if there
* have been no vlan's registered do nothing.
*/
if (adapter->num_vlans == 0)
return;
/* igc hardware doesn't seem to implement VFTA for HWFILTER */
/*
* A soft reset zero's out the VFTA, so
* we need to repopulate it now.
*/
for (int i = 0; i < IGC_VFTA_SIZE; i++)
if (adapter->shadow_vfta[i] != 0)
IGC_WRITE_REG_ARRAY(hw, IGC_VFTA,
i, adapter->shadow_vfta[i]);
reg = IGC_READ_REG(hw, IGC_CTRL);
reg |= IGC_CTRL_VME;
IGC_WRITE_REG(hw, IGC_CTRL, reg);
/* Enable the Filter Table */
reg = IGC_READ_REG(hw, IGC_RCTL);
reg &= ~IGC_RCTL_CFIEN;
reg |= IGC_RCTL_VFE;
IGC_WRITE_REG(hw, IGC_RCTL, reg);
if (if_getcapenable(ifp) & IFCAP_VLAN_HWTAGGING &&
!igc_disable_crc_stripping) {
reg = IGC_READ_REG(hw, IGC_CTRL);
reg |= IGC_CTRL_VME;
IGC_WRITE_REG(hw, IGC_CTRL, reg);
} else {
reg = IGC_READ_REG(hw, IGC_CTRL);
reg &= ~IGC_CTRL_VME;
IGC_WRITE_REG(hw, IGC_CTRL, reg);
}
}
static void
@ -2469,6 +2417,7 @@ igc_if_needs_restart(if_ctx_t ctx __unused, enum iflib_restart_event event)
{
switch (event) {
case IFLIB_RESTART_VLAN_CONFIG:
return (false);
default:
return (true);
}

View File

@ -372,7 +372,6 @@ struct igc_adapter {
/* Task for FAST handling */
struct grouptask link_task;
u16 num_vlans;
u32 txd_cmd;
u32 tx_process_limit;
@ -385,14 +384,6 @@ struct igc_adapter {
/* Multicast array memory */
u8 *mta;
/*
** Shadow VFTA table, this is needed because
** the real vlan filter table gets cleared during
** a soft reset and the driver needs to be able
** to repopulate it.
*/
u32 shadow_vfta[IGC_VFTA_SIZE];
/* Info about the interface */
u16 link_active;
u16 fc;