Date: Mon, 11 May 2020 17:42:04 +0000 (UTC) From: Eric Joyner <erj@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r360902 - in head/sys/dev: e1000 ixgbe ixl Message-ID: <202005111742.04BHg40G001112@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: erj Date: Mon May 11 17:42:04 2020 New Revision: 360902 URL: https://svnweb.freebsd.org/changeset/base/360902 Log: em/ix/ixv/ixl/iavf: Implement ifdi_needs_restart iflib method Pursuant to r360398, implement driver-specific versions of the ifdi_needs_restart iflib device method. Some (if not most?) Intel network cards don't need reinitializing when a VLAN is added or removed from the device hardware, so these implement ifdi_needs_restart in a way that tell iflib not to bring the interface up or down when a VLAN is added or removed, regardless of whether the VLAN_HWFILTER interface capability flag is set or not. This could potentially solve several PRs relating to link flaps that occur when VLANs are added/removed to devices. Signed-off-by: Eric Joyner <erj@freebsd.org> PR: 240818, 241785 Reviewed by: gallatin@, olivier@ MFC after: 3 days MFC with: r360398 Sponsored by: Intel Corporation Differential Revision: https://reviews.freebsd.org/D24659 Modified: head/sys/dev/e1000/if_em.c head/sys/dev/ixgbe/if_ix.c head/sys/dev/ixgbe/if_ixv.c head/sys/dev/ixl/if_iavf.c head/sys/dev/ixl/if_ixl.c Modified: head/sys/dev/e1000/if_em.c ============================================================================== --- head/sys/dev/e1000/if_em.c Mon May 11 16:14:20 2020 (r360901) +++ head/sys/dev/e1000/if_em.c Mon May 11 17:42:04 2020 (r360902) @@ -251,6 +251,7 @@ static void em_if_timer(if_ctx_t ctx, uint16_t qid); static void em_if_vlan_register(if_ctx_t ctx, u16 vtag); static void em_if_vlan_unregister(if_ctx_t ctx, u16 vtag); static void em_if_watchdog_reset(if_ctx_t ctx); +static bool em_if_needs_restart(if_ctx_t ctx, enum iflib_restart_event event); static void em_identify_hardware(if_ctx_t ctx); static int em_allocate_pci_resources(if_ctx_t ctx); @@ -400,6 +401,7 @@ static device_method_t em_if_methods[] = { DEVMETHOD(ifdi_rx_queue_intr_enable, em_if_rx_queue_intr_enable), DEVMETHOD(ifdi_tx_queue_intr_enable, em_if_tx_queue_intr_enable), DEVMETHOD(ifdi_debug, em_if_debug), + DEVMETHOD(ifdi_needs_restart, em_if_needs_restart), DEVMETHOD_END }; @@ -437,6 +439,7 @@ static device_method_t igb_if_methods[] = { DEVMETHOD(ifdi_rx_queue_intr_enable, igb_if_rx_queue_intr_enable), DEVMETHOD(ifdi_tx_queue_intr_enable, igb_if_tx_queue_intr_enable), DEVMETHOD(ifdi_debug, em_if_debug), + DEVMETHOD(ifdi_needs_restart, em_if_needs_restart), DEVMETHOD_END }; @@ -4035,6 +4038,25 @@ em_if_get_counter(if_ctx_t ctx, ift_counter cnt) adapter->watchdog_events); default: return (if_get_counter_default(ifp, cnt)); + } +} + +/* em_if_needs_restart - Tell iflib when the driver needs to be reinitialized + * @ctx: iflib context + * @event: event code to check + * + * Defaults to returning true for unknown events. + * + * @returns true if iflib needs to reinit the interface + */ +static bool +em_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); } } Modified: head/sys/dev/ixgbe/if_ix.c ============================================================================== --- head/sys/dev/ixgbe/if_ix.c Mon May 11 16:14:20 2020 (r360901) +++ head/sys/dev/ixgbe/if_ix.c Mon May 11 17:42:04 2020 (r360902) @@ -139,6 +139,7 @@ static void ixgbe_if_update_admin_status(if_ctx_t ctx) static void ixgbe_if_vlan_register(if_ctx_t ctx, u16 vtag); static void ixgbe_if_vlan_unregister(if_ctx_t ctx, u16 vtag); static int ixgbe_if_i2c_req(if_ctx_t ctx, struct ifi2creq *req); +static bool ixgbe_if_needs_restart(if_ctx_t ctx, enum iflib_restart_event event); int ixgbe_intr(void *arg); /************************************************************************ @@ -273,6 +274,7 @@ static device_method_t ixgbe_if_methods[] = { DEVMETHOD(ifdi_vlan_unregister, ixgbe_if_vlan_unregister), DEVMETHOD(ifdi_get_counter, ixgbe_if_get_counter), DEVMETHOD(ifdi_i2c_req, ixgbe_if_i2c_req), + DEVMETHOD(ifdi_needs_restart, ixgbe_if_needs_restart), #ifdef PCI_IOV DEVMETHOD(ifdi_iov_init, ixgbe_if_iov_init), DEVMETHOD(ifdi_iov_uninit, ixgbe_if_iov_uninit), @@ -1234,6 +1236,25 @@ ixgbe_if_i2c_req(if_ctx_t ctx, struct ifi2creq *req) req->dev_addr, &req->data[i]); return (0); } /* ixgbe_if_i2c_req */ + +/* ixgbe_if_needs_restart - Tell iflib when the driver needs to be reinitialized + * @ctx: iflib context + * @event: event code to check + * + * Defaults to returning true for unknown events. + * + * @returns true if iflib needs to reinit the interface + */ +static bool +ixgbe_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); + } +} /************************************************************************ * ixgbe_add_media_types Modified: head/sys/dev/ixgbe/if_ixv.c ============================================================================== --- head/sys/dev/ixgbe/if_ixv.c Mon May 11 16:14:20 2020 (r360901) +++ head/sys/dev/ixgbe/if_ixv.c Mon May 11 17:42:04 2020 (r360902) @@ -110,6 +110,7 @@ static void ixv_if_register_vlan(if_ctx_t, u16); static void ixv_if_unregister_vlan(if_ctx_t, u16); static uint64_t ixv_if_get_counter(if_ctx_t, ift_counter); +static bool ixv_if_needs_restart(if_ctx_t, enum iflib_restart_event); static void ixv_save_stats(struct adapter *); static void ixv_init_stats(struct adapter *); @@ -172,6 +173,7 @@ static device_method_t ixv_if_methods[] = { DEVMETHOD(ifdi_vlan_register, ixv_if_register_vlan), DEVMETHOD(ifdi_vlan_unregister, ixv_if_unregister_vlan), DEVMETHOD(ifdi_get_counter, ixv_if_get_counter), + DEVMETHOD(ifdi_needs_restart, ixv_if_needs_restart), DEVMETHOD_END }; @@ -1186,6 +1188,25 @@ ixv_if_get_counter(if_ctx_t ctx, ift_counter cnt) return (if_get_counter_default(ifp, cnt)); } } /* ixv_if_get_counter */ + +/* ixv_if_needs_restart - Tell iflib when the driver needs to be reinitialized + * @ctx: iflib context + * @event: event code to check + * + * Defaults to returning true for every event. + * + * @returns true if iflib needs to reinit the interface + */ +static bool +ixv_if_needs_restart(if_ctx_t ctx __unused, enum iflib_restart_event event) +{ + switch (event) { + case IFLIB_RESTART_VLAN_CONFIG: + /* XXX: This may not need to return true */ + default: + return (true); + } +} /************************************************************************ * ixv_initialize_transmit_units - Enable transmit unit. Modified: head/sys/dev/ixl/if_iavf.c ============================================================================== --- head/sys/dev/ixl/if_iavf.c Mon May 11 16:14:20 2020 (r360901) +++ head/sys/dev/ixl/if_iavf.c Mon May 11 17:42:04 2020 (r360902) @@ -92,6 +92,7 @@ static void iavf_if_vlan_register(if_ctx_t ctx, u16 v 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_stop(if_ctx_t ctx); +static bool iavf_if_needs_restart(if_ctx_t ctx, enum iflib_restart_event event); static int iavf_allocate_pci_resources(struct iavf_sc *); static int iavf_reset_complete(struct i40e_hw *); @@ -190,6 +191,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 }; @@ -1467,7 +1469,27 @@ 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 true for every event. + * + * @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: + /* This case must return true if VLAN anti-spoof checks are + * enabled by the PF driver for the VF. + */ + default: + return (true); + } +} + static void iavf_free_pci_resources(struct iavf_sc *sc) { Modified: head/sys/dev/ixl/if_ixl.c ============================================================================== --- head/sys/dev/ixl/if_ixl.c Mon May 11 16:14:20 2020 (r360901) +++ head/sys/dev/ixl/if_ixl.c Mon May 11 17:42:04 2020 (r360902) @@ -117,6 +117,7 @@ static void ixl_if_vlan_unregister(if_ctx_t ctx, u16 static uint64_t ixl_if_get_counter(if_ctx_t ctx, ift_counter cnt); static int ixl_if_i2c_req(if_ctx_t ctx, struct ifi2creq *req); static int ixl_if_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t data); +static bool ixl_if_needs_restart(if_ctx_t ctx, enum iflib_restart_event event); #ifdef PCI_IOV static void ixl_if_vflr_handle(if_ctx_t ctx); #endif @@ -187,6 +188,7 @@ static device_method_t ixl_if_methods[] = { DEVMETHOD(ifdi_get_counter, ixl_if_get_counter), DEVMETHOD(ifdi_i2c_req, ixl_if_i2c_req), DEVMETHOD(ifdi_priv_ioctl, ixl_if_priv_ioctl), + DEVMETHOD(ifdi_needs_restart, ixl_if_needs_restart), #ifdef PCI_IOV DEVMETHOD(ifdi_iov_init, ixl_if_iov_init), DEVMETHOD(ifdi_iov_uninit, ixl_if_iov_uninit), @@ -1650,6 +1652,24 @@ ixl_if_priv_ioctl(if_ctx_t ctx, u_long command, caddr_ } return (error); +} + +/* ixl_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 every event. + * + * @returns true if iflib needs to reinit the interface, false otherwise + */ +static bool +ixl_if_needs_restart(if_ctx_t ctx __unused, enum iflib_restart_event event) +{ + switch (event) { + case IFLIB_RESTART_VLAN_CONFIG: + default: + return (false); + } } static u_int
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202005111742.04BHg40G001112>