ice: allow creating VFs when !CONFIG_ICE_SWITCHDEV
Subsystems (3)
RFC PATCH 1/1 ice: allow creating VFs when !CONFIG_ICE_SWITCHDEV
Currently ice_eswitch_attach_vf() is called unconditionally in ice_start_vfs() and ice_reset_all_vfs(), which causes VF creation to fail when CONFIG_ICE_SWITCHDEV is not defined or switchdev mode is not enabled at runtime.
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(). Also remove the redundant check inside ice_eswitch_attach_vf() itself. 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_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(-)
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);
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
Dear Vincent,
Thank you for your patch.
Am 27.04.26 um 05:11 schrieb Vincent Chen via Intel-wired-lan:
Quoted 4 lines
Currently
ice_eswitch_attach_vf()is called unconditionally inice_start_vfs()andice_reset_all_vfs(), which causes VF creation to fail whenCONFIG_ICE_SWITCHDEVis not defined or switchdev mode is not enabled at runtime.
I’d add a blank line between paragraphs.
Quoted 4 lines
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(). Also remove the redundant check insideice_eswitch_attach_vf()itself.
*Also* is a good indicator to make it a separate patch. I’d favor this in this case.
Quoted 55 lines
This is similar to commit
aacca7a83b97("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_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(-)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);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 +0
-0
drivers/net/ethernet/intel/ice/ice_vf_lib.c void ice_reset_all_vfs(struct ice_pf *pf) · line 814
Quoted 9 lines
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); }
The diff looks good.
Kind regards,
Paul
Quoted 6 lines · Paul Menzel
Dear Vincent,
Thank you for your patch.
Quoted 7 lines
Am 27.04.26 um 05:11 schrieb Vincent Chen via Intel-wired-lan:
Quoted 4 lines
Currently
ice_eswitch_attach_vf()is called unconditionally inice_start_vfs()andice_reset_all_vfs(), which causes VF creation to fail whenCONFIG_ICE_SWITCHDEVis not defined or switchdev mode is not enabled at runtime.I’d add a blank line between paragraphs.
This is a good suggestion. I will modify it in my next version patch.
Quoted 9 lines
Quoted 5 lines
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(). Also remove the redundant check insideice_eswitch_attach_vf()itself.*Also* is a good indicator to make it a separate patch. I’d favor this in this case.
OK, I will move the code snippet used to remove the redundant check inside ice_eswitch_attach_vf() to a separate patch in my next version patch.
Quoted 71 lines
Quoted 55 lines
This is similar to commit
aacca7a83b97("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_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(-)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);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 +0
-0drivers/net/ethernet/intel/ice/ice_vf_lib.c void ice_reset_all_vfs(struct ice_pf *pf) · line 814
Quoted 9 lines
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); }The diff looks good.
Kind regards,
Paul