]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ice: allow creating VFs when !CONFIG_ICE_SWITCHDEV
authorVincent Chen <vincent.chen@sifive.com>
Fri, 17 Jul 2026 18:53:23 +0000 (11:53 -0700)
committerJakub Kicinski <kuba@kernel.org>
Thu, 23 Jul 2026 16:00:50 +0000 (09:00 -0700)
Currently ice_eswitch_attach_vf() is called unconditionally in
ice_start_vfs(), which causes VF creation to fail when CONFIG_ICE_SWITCHDEV
is not defined.

Fix this by adding switchdev mode checks at the call sites before
calling ice_eswitch_attach_vf(), consistent with how
ice_eswitch_attach_sf() is already handled in ice_devlink_port_new().
This is similar to commit aacca7a83b97 ("ice: allow creating VFs for
!CONFIG_NET_SWITCHDEV") which fixed the same issue for the previous
ice_eswitch_configure() API.

Fixes: 415db8399d06 ("ice: make representor code generic")
Signed-off-by: Vincent Chen <vincent.chen@sifive.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Tested-by: Rafal Romanowski <rafal.romanowski@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Link: https://patch.msgid.link/20260717185340.3595286-2-anthony.l.nguyen@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/intel/ice/ice_eswitch.c
drivers/net/ethernet/intel/ice/ice_sriov.c
drivers/net/ethernet/intel/ice/ice_vf_lib.c

index c30e27bbfe6e25722472c5c6497acb2a46b50114..b069e6c514fb1279ddd9e941e76271be0e72c912 100644 (file)
@@ -512,9 +512,6 @@ int ice_eswitch_attach_vf(struct ice_pf *pf, struct ice_vf *vf)
        struct ice_repr *repr;
        int err;
 
-       if (!ice_is_eswitch_mode_switchdev(pf))
-               return 0;
-
        repr = ice_repr_create_vf(vf);
        if (IS_ERR(repr))
                return PTR_ERR(repr);
index 7e00e091756ddc675a4cc211d8379d67309fd219..e04de02155966589cc04bfdf2786ad7ffc4e0ea9 100644 (file)
@@ -484,12 +484,14 @@ static int ice_start_vfs(struct ice_pf *pf)
                        goto teardown;
                }
 
-               retval = ice_eswitch_attach_vf(pf, vf);
-               if (retval) {
-                       dev_err(ice_pf_to_dev(pf), "Failed to attach VF %d to eswitch, error %d",
-                               vf->vf_id, retval);
-                       ice_vf_vsi_release(vf);
-                       goto teardown;
+               if (ice_is_eswitch_mode_switchdev(pf)) {
+                       retval = ice_eswitch_attach_vf(pf, vf);
+                       if (retval) {
+                               dev_err(ice_pf_to_dev(pf), "Failed to attach VF %d to eswitch, error %d",
+                                       vf->vf_id, retval);
+                               ice_vf_vsi_release(vf);
+                               goto teardown;
+                       }
                }
 
                set_bit(ICE_VF_STATE_INIT, vf->vf_states);
index 27e4acb1620f0c3381e0f3b60f49f0b93176ea61..9052e71e9c99e35b5a7a40a824b019a376b4833c 100644 (file)
@@ -812,7 +812,8 @@ void ice_reset_all_vfs(struct ice_pf *pf)
                }
                ice_vf_post_vsi_rebuild(vf);
 
-               ice_eswitch_attach_vf(pf, vf);
+               if (ice_is_eswitch_mode_switchdev(pf))
+                       ice_eswitch_attach_vf(pf, vf);
 
                mutex_unlock(&vf->cfg_lock);
        }