ice: fix VF creation when !CONFIG_ICE_SWITCHDEV
Subsystems (3)
cover ice: fix VF creation when !CONFIG_ICE_SWITCHDEV
This patch series fixes an issue where VF creation fails when CONFIG_ICE_SWITCHDEV is disabled.
When CONFIG_ICE_SWITCHDEV is disabled, the stub function ice_eswitch_attach_vf() returns -EOPNOTSUPP, causing VF initialization to fail even though basic VF functionality should work without switchdev support.
The fix is split into two patches:
1. Add switchdev mode checks at caller sites to fix the immediate issue while maintaining backward compatibility. This ensures ice_eswitch_attach_vf() is only called when switchdev mode is enabled, consistent with how ice_eswitch_attach_sf() is handled.
2. Remove the now-redundant internal switchdev check from ice_eswitch_attach_vf().
Vincent Chen (2):
ice: allow creating VFs when !CONFIG_ICE_SWITCHDEV
ice: remove redundant switchdev check in ice_eswitch_attach_vf()
drivers/net/ethernet/intel/ice/ice_eswitch.c | 3 --- drivers/net/ethernet/intel/ice/ice_sriov.c | 14 ++++++++------ drivers/net/ethernet/intel/ice/ice_vf_lib.c | 3 ++- 3 files changed, 10 insertions(+), 10 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/2 ice: allow creating VFs when !CONFIG_ICE_SWITCHDEV
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.
--- drivers/net/ethernet/intel/ice/ice_sriov.c | 14 ++++++++------ drivers/net/ethernet/intel/ice/ice_vf_lib.c | 3 ++- 2 files changed, 10 insertions(+), 7 deletions(-)
drivers/net/ethernet/intel/ice/ice_sriov.c +8 -6
@@ -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);
drivers/net/ethernet/intel/ice/ice_vf_lib.c +2 -1
@@ -807,7 +807,8 @@ void ice_reset_all_vfs(struct ice_pf *pf)ice_vf_rebuild_vsi (vf);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); }
Signature · 1 line
2.34.1
RE: [Intel-wired-lan] [PATCH 1/2] ice: allow creating VFs when !CONFIG_ICE_SWITCHDEV
Quoted 75 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Vincent Chen via Intel-wired-lan
Sent: Wednesday, April 29, 2026 8:51 AM
To: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [Intel-wired-lan] [PATCH 1/2] ice: allow creating VFs when !CONFIG_ICE_SWITCHDEVCurrently
ice_eswitch_attach_vf()is called unconditionally inice_start_vfs(), which causes VF creation to fail whenCONFIG_ICE_SWITCHDEVis not defined.Fix this by adding switchdev mode checks at the call sites before calling
ice_eswitch_attach_vf(), consistent with howice_eswitch_attach_sf()is already handled inice_devlink_port_new(). This is similar to commitaacca7a83b97("ice: allow creating VFs for !CONFIG_NET_SWITCHDEV") which fixed the same issue for the previousice_eswitch_configure()API.Signed-off-by Vincent Chen <[email protected]>--- drivers/net/ethernet/intel/ice/ice_sriov.c | 14 ++++++++------ drivers/net/ethernet/intel/ice/ice_vf_lib.c | 3 ++- 2 files changed, 10 insertions(+), 7 deletions(-)drivers/net/ethernet/intel/ice/ice_sriov.c +8
-6@@ -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); diff --gita/drivers/net/ethernet/intel/ice/ice_vf_lib.cb/drivers/net/ethernet/intel/ice/ice_vf_lib.c
indexde9e81ccee66..71595410174c100644drivers/net/ethernet/intel/ice/ice_vf_lib.c +2
-2@@ -807,7 +807,8 @@ void ice_reset_all_vfs(struct ice_pf *pf)ice_vf_rebuild_vsi (vf);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); } --
Quoted 1 line
2.34.1
Romanowski, Rafal
Tested-byRE: [Intel-wired-lan] [PATCH 1/2] ice: allow creating VFs when !CONFIG_ICE_SWITCHDEV
Quoted 44 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Loktionov, Aleksandr
Sent: Wednesday, April 29, 2026 11:18 AM
To: Vincent Chen <[email protected]>; Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [Intel-wired-lan] [PATCH 1/2] ice: allow creating VFs when !CONFIG_ICE_SWITCHDEVQuoted 29 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Vincent Chen via Intel-wired-lan
Sent: Wednesday, April 29, 2026 8:51 AM
To: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [Intel-wired-lan] [PATCH 1/2] ice: allow creating VFs when !CONFIG_ICE_SWITCHDEVCurrently
ice_eswitch_attach_vf()is called unconditionally inice_start_vfs(), which causes VF creation to fail whenCONFIG_ICE_SWITCHDEVis not defined.Fix this by adding switchdev mode checks at the call sites before calling
ice_eswitch_attach_vf(), consistent with howice_eswitch_attach_sf()is already handled inice_devlink_port_new(). This is similar to commitaacca7a83b97("ice: allow creating VFs for !CONFIG_NET_SWITCHDEV") which fixed the same issue for the previousice_eswitch_configure()API.Signed-off-by Vincent Chen <[email protected]>--- drivers/net/ethernet/intel/ice/ice_sriov.c | 14 ++++++++------ drivers/net/ethernet/intel/ice/ice_vf_lib.c | 3 ++- 2 files changed, 10 insertions(+), 7 deletions(-)
Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_sriov.c static int ice_start_vfs(struct ice_pf *pf)
Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_sriov.c +0
-0@@ -484,12 +484,14 @@ static int ice_start_vfs(struct ice_pf *pf)
PATCH 2/2 ice: remove redundant switchdev check in ice_eswitch_attach_vf()
In reply to Vincent ChenAll callers of ice_eswitch_attach_vf() check the switchdev mode before calling the function, the internal switchdev mode check in ice_eswitch_attach_vf() is redundant. Remove this check to align with the design pattern used for ice_eswitch_attach_sf(), where the caller is responsible for checking switchdev mode before attachment.
--- drivers/net/ethernet/intel/ice/ice_eswitch.c | 3 --- 1 file changed, 3 deletions(-)
drivers/net/ethernet/intel/ice/ice_eswitch.c +0 -3
@@ -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);
Signature · 1 line
2.34.1
RE: [Intel-wired-lan] [PATCH 2/2] ice: remove redundant switchdev check in ice_eswitch_attach_vf()
Quoted 40 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Vincent Chen via Intel-wired-lan
Sent: Wednesday, April 29, 2026 8:51 AM
To: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [Intel-wired-lan] [PATCH 2/2] ice: remove redundant switchdev check inice_eswitch_attach_vf()All callers of
ice_eswitch_attach_vf()check the switchdev mode before calling the function, the internal switchdev mode check inice_eswitch_attach_vf()is redundant. Remove this check to align with the design pattern used forice_eswitch_attach_sf(), where the caller is responsible for checking switchdev mode before attachment.Signed-off-by Vincent Chen <[email protected]>--- drivers/net/ethernet/intel/ice/ice_eswitch.c | 3 --- 1 file changed, 3 deletions(-)drivers/net/ethernet/intel/ice/ice_eswitch.c +0
-3@@ -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))
Quoted 3 lines
return
PTR_ERR(repr);
--
2.34.1
Romanowski, Rafal
Tested-byRE: [Intel-wired-lan] [PATCH 2/2] ice: remove redundant switchdev check in ice_eswitch_attach_vf()
Quoted 48 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Loktionov, Aleksandr
Sent: Wednesday, April 29, 2026 11:18 AM
To: Vincent Chen <[email protected]>; Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [Intel-wired-lan] [PATCH 2/2] ice: remove redundant switchdev check inice_eswitch_attach_vf()Quoted 33 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Vincent Chen via Intel-wired-lan
Sent: Wednesday, April 29, 2026 8:51 AM
To: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [Intel-wired-lan] [PATCH 2/2] ice: remove redundant switchdev check inice_eswitch_attach_vf()All callers of
ice_eswitch_attach_vf()check the switchdev mode before calling the function, the internal switchdev mode check inice_eswitch_attach_vf()is redundant. Remove this check to align with the design pattern used forice_eswitch_attach_sf(), where the caller is responsible for checking switchdev mode before attachment.Signed-off-by Vincent Chen <[email protected]>--- drivers/net/ethernet/intel/ice/ice_eswitch.c | 3 --- 1 file changed, 3 deletions(-)drivers/net/ethernet/intel/ice/ice_eswitch.c +0
-0@@ -512,9 +512,6 @@ int ice_eswitch_attach_vf(struct ice_pf *pf, struct ice_vf *vf)struct ice_repr *repr;int err;
Quoted 10 lines
Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_eswitch.c +0
-3-if (!ice_is_eswitch_mode_switchdev (pf)) -return 0 ; - repr =ice_repr_create_vf (vf);if (IS_ERR (repr))return
PTR_ERR(repr);
--
2.34.1Reviewed-by Aleksandr Loktionov <[email protected]>