git: 749c7da9b9b4 - stable/12 - ixl(4): Fix SR-IOV panics

From: Eric Joyner <erj_at_FreeBSD.org>
Date: Wed, 19 Oct 2022 23:23:50 UTC
The branch stable/12 has been updated by erj:

URL: https://cgit.FreeBSD.org/src/commit/?id=749c7da9b9b45949c2aae76bffafb626e7316b06

commit 749c7da9b9b45949c2aae76bffafb626e7316b06
Author:     Yan Ka Chiu <nyan@myuji.xyz>
AuthorDate: 2022-07-13 01:16:29 +0000
Commit:     Eric Joyner <erj@FreeBSD.org>
CommitDate: 2022-10-19 23:19:43 +0000

    ixl(4): Fix SR-IOV panics
    
    The hw and ifp of a vsi will be NULL if such ixl_vsi is allocated
    for a VF. When ixl_reconfigure_filters called, it is trying to
    access vsi->ifp and hw->mac.addr and therefore is casuing panic.
    
    This commit add checks to determine if vsi is a VF by checking
    if vsi->hw is NULL, before adding IXL_VLAN_ANY filter (which
    is already in a VF vsi's filter list) and VLAN filters.
    
    (erj's Note: The SR-IOV flows need revisiting; this will help
    prevent panics for now)
    
    Reviewed by:    krzysztof.galazka@intel.com, erj@
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D35649
    
    (cherry picked from commit e706512a2b64fa2741144caf056c9fe923b60004)
---
 sys/dev/ixl/ixl_pf_main.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/sys/dev/ixl/ixl_pf_main.c b/sys/dev/ixl/ixl_pf_main.c
index 4d75200ea739..61dd4da05030 100644
--- a/sys/dev/ixl/ixl_pf_main.c
+++ b/sys/dev/ixl/ixl_pf_main.c
@@ -1124,6 +1124,14 @@ ixl_reconfigure_filters(struct ixl_vsi *vsi)
 
 	ixl_add_hw_filters(vsi, &tmp, cnt);
 
+	/*
+	 * When the vsi is allocated for the VFs, both vsi->hw and vsi->ifp
+	 * will be NULL. Furthermore, the ftl of such vsi already contains
+	 * IXL_VLAN_ANY filter so we can skip that as well.
+	 */
+	if (hw == NULL)
+		return;
+
 	/* Filter could be removed if MAC address was changed */
 	ixl_add_filter(vsi, hw->mac.addr, IXL_VLAN_ANY);