ice: preventing VLAN configuration in switchdev
Subsystems (2)
cover ice: preventing VLAN configuration in switchdev
In switchdev for any VLAN configuration requested from VF PF should answer with not supported error. Instead of adding custom ops for all VLAN ops prevent setting VLAN VF caps.
Thanks for that ugly error from dmesg will be removed as VF should not send VLAN configuration commands. If it sends any PF driver will return not supported error because all VLAN opcodes are remove from allowlist (only in switchdev mode).
Michal Swiatkowski (2):
ice: don't set VF VLAN caps in switchdev
ice: remove VLAN representor specific ops
drivers/net/ethernet/intel/ice/ice_virtchnl.c | 121 ++++++++---------- 1 file changed, 54 insertions(+), 67 deletions(-)
Signature · 1 line
2.31.1
PATCH 1/2 ice: don't set VF VLAN caps in switchdev
In switchdev mode any VLAN manipulation from VF side isn't allowed. In order to prevent parsing VLAN commands don't set VF VLAN caps. This will result in removing VLAN specific opcodes from allowlist. If VF send any VLAN specific opcode PF driver will answer with not supported error.
With this approach VF driver know that VLAN caps aren't supported so it shouldn't send VLAN specific opcodes. Thanks to that, some ugly errors will not show up in dmesg (ex. on creating VFs in switchdev mode there are errors about not supported VLAN insertion and stripping)
Move setting VLAN caps to separate function, including switchdev mode specific code.
--- drivers/net/ethernet/intel/ice/ice_virtchnl.c | 77 ++++++++++++------- 1 file changed, 50 insertions(+), 27 deletions(-)
drivers/net/ethernet/intel/ice/ice_virtchnl.c +50 -27
@@ -359,6 +359,54 @@ static u16 ice_vc_get_max_frame_size(struct ice_vf *vf)return max_frame_size; } +/** +* ice_vc_get_vlan_caps +* @hw: pointer to the hw +* @vf: pointer to the VF info +* @vsi: pointer to the VSI +* @driver_caps: current driver caps +* +* Return 0 if there is no VLAN caps supported, or VLAN caps value +*/ +static u32 +ice_vc_get_vlan_caps (struct ice_hw *hw,struct ice_vf *vf,struct ice_vsi *vsi, +u32 driver_caps) +{ +if (ice_is_eswitch_mode_switchdev (vf->pf)) +/* In switchdev setting VLAN from VF isn't supported */ +return 0 ; + +if (driver_caps &VIRTCHNL_VF_OFFLOAD_VLAN_V2 ) { +/* VLAN offloads based on current device configuration */ +return VIRTCHNL_VF_OFFLOAD_VLAN_V2 ; + }else if (driver_caps &VIRTCHNL_VF_OFFLOAD_VLAN ) { +/* allow VF to negotiate VIRTCHNL_VF_OFFLOAD explicitly for +* these two conditions, which amounts to guest VLAN filtering +* and offloads being based on the inner VLAN or the +* inner/single VLAN respectively and don't allow VF to +* negotiate VIRTCHNL_VF_OFFLOAD in any other cases +*/ +if (ice_is_dvm_ena (hw) &&ice_vf_is_port_vlan_ena (vf)) { +return VIRTCHNL_VF_OFFLOAD_VLAN ; + }else if (!ice_is_dvm_ena (hw) && + !ice_vf_is_port_vlan_ena (vf)) { +/* configure backward compatible support for VFs that +* only support VIRTCHNL_VF_OFFLOAD_VLAN, the PF is +* configured in SVM, and no port VLAN is configured +*/ +ice_vf_vsi_cfg_svm_legacy_vlan_mode (vsi); +return VIRTCHNL_VF_OFFLOAD_VLAN ; + }else if (ice_is_dvm_ena (hw)) { +/* configure software offloaded VLAN support when DVM +* is enabled, but no port VLAN is enabled +*/ +ice_vf_vsi_cfg_dvm_legacy_vlan_mode (vsi); + } + } + +return 0 ; +} +/** * ice_vc_get_vf_res_msg * @vf: pointer to the VF info
@@ -402,33 +450,8 @@ static int ice_vc_get_vf_res_msg(struct ice_vf *vf, u8 *msg) goto err; } -if (vf->driver_caps &VIRTCHNL_VF_OFFLOAD_VLAN_V2 ) { -/* VLAN offloads based on current device configuration */ - vfres->vf_cap_flags |=VIRTCHNL_VF_OFFLOAD_VLAN_V2 ; - }else if (vf->driver_caps &VIRTCHNL_VF_OFFLOAD_VLAN ) { -/* allow VF to negotiate VIRTCHNL_VF_OFFLOAD explicitly for -* these two conditions, which amounts to guest VLAN filtering -* and offloads being based on the inner VLAN or the -* inner/single VLAN respectively and don't allow VF to -* negotiate VIRTCHNL_VF_OFFLOAD in any other cases -*/ -if (ice_is_dvm_ena (hw) &&ice_vf_is_port_vlan_ena (vf)) { - vfres->vf_cap_flags |=VIRTCHNL_VF_OFFLOAD_VLAN ; - }else if (!ice_is_dvm_ena (hw) && - !ice_vf_is_port_vlan_ena (vf)) { - vfres->vf_cap_flags |=VIRTCHNL_VF_OFFLOAD_VLAN ; -/* configure backward compatible support for VFs that -* only support VIRTCHNL_VF_OFFLOAD_VLAN, the PF is -* configured in SVM, and no port VLAN is configured -*/ -ice_vf_vsi_cfg_svm_legacy_vlan_mode (vsi); - }else if (ice_is_dvm_ena (hw)) { -/* configure software offloaded VLAN support when DVM -* is enabled, but no port VLAN is enabled -*/ -ice_vf_vsi_cfg_dvm_legacy_vlan_mode (vsi); - } - } + vfres->vf_cap_flags |=ice_vc_get_vlan_caps (hw, vf, vsi, + vf->driver_caps);if (vf->driver_caps &VIRTCHNL_VF_OFFLOAD_RSS_PF ) { vfres->vf_cap_flags |=VIRTCHNL_VF_OFFLOAD_RSS_PF ;
Signature · 1 line
2.31.1
Penigalapati
PATCH 1/2 ice: don't set VF VLAN caps in switchdev
Quoted 4 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Michal Swiatkowski
Sent: Monday, April 25, 2022 11:58 AM
Quoted 15 lines
Cc: Wilczynski, Michal <[email protected]>
Subject: [Intel-wired-lan] [PATCH net-next 1/2] ice: don't set VF VLAN caps in switchdevIn switchdev mode any VLAN manipulation from VF side isn't allowed. In order to prevent parsing VLAN commands don't set VF VLAN caps. This will result in removing VLAN specific opcodes from allowlist. If VF send any VLAN specific opcode PF driver will answer with not supported error.
With this approach VF driver know that VLAN caps aren't supported so it shouldn't send VLAN specific opcodes. Thanks to that, some ugly errors will not show up in dmesg (ex. on creating VFs in switchdev mode there are errors about not supported VLAN insertion and stripping)
Quoted 8 lines
Move setting VLAN caps to separate function, including switchdev mode specific code.
Signed-off-by Michal Swiatkowski <[email protected]>---
drivers/net/ethernet/intel/ice/ice_virtchnl.c| 77 ++++++++++++-------1 file changed, 50 insertions(+), 27 deletions(-)
PATCH 2/2 ice: remove VLAN representor specific ops
In reply to Michal SwiatkowskiAs in switchdev mode VF VLAN caps will not be set there is no need to have specific VLAN ops for representor that only returns not supported error.
--- drivers/net/ethernet/intel/ice/ice_virtchnl.c | 44 ++----------------- 1 file changed, 4 insertions(+), 40 deletions(-)
drivers/net/ethernet/intel/ice/ice_virtchnl.c +4 -40
@@ -3520,42 +3520,6 @@ ice_vc_repr_del_mac(struct ice_vf __always_unused *vf, u8 __always_unused *msg) VIRTCHNL_STATUS_SUCCESS, NULL, 0); } -static int ice_vc_repr_add_vlan (struct ice_vf *vf,u8 __always_unused *msg) -{ -dev_dbg (ice_pf_to_dev (vf->pf), -"Can't add VLAN in switchdev mode for VF %d\n" , vf->vf_id); -return ice_vc_send_msg_to_vf (vf,VIRTCHNL_OP_ADD_VLAN , -VIRTCHNL_STATUS_SUCCESS ,NULL ,0 ); -} - -static int ice_vc_repr_del_vlan (struct ice_vf *vf,u8 __always_unused *msg) -{ -dev_dbg (ice_pf_to_dev (vf->pf), -"Can't delete VLAN in switchdev mode for VF %d\n" , vf->vf_id); -return ice_vc_send_msg_to_vf (vf,VIRTCHNL_OP_DEL_VLAN , -VIRTCHNL_STATUS_SUCCESS ,NULL ,0 ); -} - -static int ice_vc_repr_ena_vlan_stripping (struct ice_vf *vf) -{ -dev_dbg (ice_pf_to_dev (vf->pf), -"Can't enable VLAN stripping in switchdev mode for VF %d\n" , - vf->vf_id); -return ice_vc_send_msg_to_vf (vf,VIRTCHNL_OP_ENABLE_VLAN_STRIPPING , -VIRTCHNL_STATUS_ERR_NOT_SUPPORTED , -NULL ,0 ); -} - -static int ice_vc_repr_dis_vlan_stripping (struct ice_vf *vf) -{ -dev_dbg (ice_pf_to_dev (vf->pf), -"Can't disable VLAN stripping in switchdev mode for VF %d\n" , - vf->vf_id); -return ice_vc_send_msg_to_vf (vf,VIRTCHNL_OP_DISABLE_VLAN_STRIPPING , -VIRTCHNL_STATUS_ERR_NOT_SUPPORTED , -NULL ,0 ); -} -static int ice_vc_repr_cfg_promiscuous_mode (struct ice_vf *vf,u8 __always_unused *msg) {
@@ -3582,10 +3546,10 @@ static const struct ice_virtchnl_ops ice_virtchnl_repr_ops = { .config_rss_lut = ice_vc_config_rss_lut, .get_stats_msg = ice_vc_get_stats_msg, .cfg_promiscuous_mode_msg = ice_vc_repr_cfg_promiscuous_mode, - .add_vlan_msg = ice_vc_repr_add_vlan, - .remove_vlan_msg = ice_vc_repr_del_vlan, - .ena_vlan_stripping = ice_vc_repr_ena_vlan_stripping, - .dis_vlan_stripping = ice_vc_repr_dis_vlan_stripping, + .add_vlan_msg = ice_vc_add_vlan_msg, + .remove_vlan_msg = ice_vc_remove_vlan_msg, + .ena_vlan_stripping = ice_vc_ena_vlan_stripping, + .dis_vlan_stripping = ice_vc_dis_vlan_stripping, .handle_rss_cfg_msg = ice_vc_handle_rss_cfg, .add_fdir_fltr_msg = ice_vc_add_fdir_fltr, .del_fdir_fltr_msg = ice_vc_del_fdir_fltr,
Signature · 1 line
2.31.1
Penigalapati
PATCH 2/2 ice: remove VLAN representor specific ops
Quoted 4 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Michal Swiatkowski
Sent: Monday, April 25, 2022 11:58 AM
Quoted 4 lines
Cc: Wilczynski, Michal <[email protected]>
Subject: [Intel-wired-lan] [PATCH net-next 2/2] ice: remove VLAN representor specific ops
Quoted 8 lines
As in switchdev mode VF VLAN caps will not be set there is no need to have specific VLAN ops for representor that only returns not supported error.
Signed-off-by Michal Swiatkowski <[email protected]>---
drivers/net/ethernet/intel/ice/ice_virtchnl.c| 44 ++-----------------1 file changed, 4 insertions(+), 40 deletions(-)