git: a5728b82826f - stable/12 - igc: Fix up hw vlan ops
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 17 Oct 2022 03:38:33 UTC
The branch stable/12 has been updated by kbowling (ports committer):
URL: https://cgit.FreeBSD.org/src/commit/?id=a5728b82826f8b07289754fbc976e7593b3fa820
commit a5728b82826f8b07289754fbc976e7593b3fa820
Author: Kevin Bowling <kbowling@FreeBSD.org>
AuthorDate: 2022-10-10 23:09:21 +0000
Commit: Kevin Bowling <kbowling@FreeBSD.org>
CommitDate: 2022-10-17 03:37:39 +0000
igc: Fix up hw vlan ops
Adapt 2796f7cab10785ef40efbba97ef67ab319c96e9c 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
Differential Revision: https://reviews.freebsd.org/D31979
(cherry picked from commit 2eaef8ec4af1f7576a1444180020e23d2e142107)
---
sys/dev/igc/if_igc.c | 89 +++++++++++-----------------------------------------
sys/dev/igc/if_igc.h | 9 ------
2 files changed, 19 insertions(+), 79 deletions(-)
diff --git a/sys/dev/igc/if_igc.c b/sys/dev/igc/if_igc.c
index e5c42e0eb235..0ce2439f93f0 100644
--- a/sys/dev/igc/if_igc.c
+++ b/sys/dev/igc/if_igc.c
@@ -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);
@@ -200,8 +198,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),
@@ -442,9 +438,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
@@ -845,18 +840,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, IFF_PROMISC);
@@ -2139,62 +2124,25 @@ igc_initialize_receive_unit(if_ctx_t ctx)
}
static void
-igc_if_vlan_register(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_if_vlan_unregister(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_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;
-
- /*
- * 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);
+ /* igc hardware doesn't seem to implement VFTA for HWFILTER */
- /* 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
@@ -2470,6 +2418,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);
}
diff --git a/sys/dev/igc/if_igc.h b/sys/dev/igc/if_igc.h
index 69b2123cd73f..86a02266a81c 100644
--- a/sys/dev/igc/if_igc.h
+++ b/sys/dev/igc/if_igc.h
@@ -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;