Skip to content

Commit d019b1a

Browse files
Michal Swiatkowskianguy11
authored andcommitted
ice: clear port vlan config during reset
Since commit 2a2cb4c ("ice: replace ice_vf_recreate_vsi() with ice_vf_reconfig_vsi()") VF VSI is only reconfigured instead of recreated. The context configuration from previous setting is still the same. If any of the config needs to be cleared it needs to be cleared explicitly. Previously there was assumption that port vlan will be cleared automatically. Now, when VSI is only reconfigured we have to do it in the code. Not clearing port vlan configuration leads to situation when the driver VSI config is different than the VSI config in HW. Traffic can't be passed after setting and clearing port vlan, because of invalid VSI config in HW. Example reproduction: > ip a a dev $(VF) $(VF_IP_ADDRESS) > ip l s dev $(VF) up > ping $(VF_IP_ADDRESS) ping is working fine here > ip link set eth5 vf 0 vlan 100 > ip link set eth5 vf 0 vlan 0 > ping $(VF_IP_ADDRESS) ping isn't working Fixes: 2a2cb4c ("ice: replace ice_vf_recreate_vsi() with ice_vf_reconfig_vsi()") Signed-off-by: Michal Swiatkowski <[email protected]> Reviewed-by: Wojciech Drewek <[email protected]> Tested-by: Piotr Tyda <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent d517cf8 commit d019b1a

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed

drivers/net/ethernet/intel/ice/ice_vf_lib.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,13 @@ static int ice_vf_rebuild_host_vlan_cfg(struct ice_vf *vf, struct ice_vsi *vsi)
335335

336336
err = vlan_ops->add_vlan(vsi, &vf->port_vlan_info);
337337
} else {
338+
/* clear possible previous port vlan config */
339+
err = ice_vsi_clear_port_vlan(vsi);
340+
if (err) {
341+
dev_err(dev, "failed to clear port VLAN via VSI parameters for VF %u, error %d\n",
342+
vf->vf_id, err);
343+
return err;
344+
}
338345
err = ice_vsi_add_vlan_zero(vsi);
339346
}
340347

drivers/net/ethernet/intel/ice/ice_vsi_vlan_lib.c

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,3 +787,60 @@ int ice_vsi_clear_outer_port_vlan(struct ice_vsi *vsi)
787787
kfree(ctxt);
788788
return err;
789789
}
790+
791+
int ice_vsi_clear_port_vlan(struct ice_vsi *vsi)
792+
{
793+
struct ice_hw *hw = &vsi->back->hw;
794+
struct ice_vsi_ctx *ctxt;
795+
int err;
796+
797+
ctxt = kzalloc(sizeof(*ctxt), GFP_KERNEL);
798+
if (!ctxt)
799+
return -ENOMEM;
800+
801+
ctxt->info = vsi->info;
802+
803+
ctxt->info.port_based_outer_vlan = 0;
804+
ctxt->info.port_based_inner_vlan = 0;
805+
806+
ctxt->info.inner_vlan_flags =
807+
FIELD_PREP(ICE_AQ_VSI_INNER_VLAN_TX_MODE_M,
808+
ICE_AQ_VSI_INNER_VLAN_TX_MODE_ALL);
809+
if (ice_is_dvm_ena(hw)) {
810+
ctxt->info.inner_vlan_flags |=
811+
FIELD_PREP(ICE_AQ_VSI_INNER_VLAN_EMODE_M,
812+
ICE_AQ_VSI_INNER_VLAN_EMODE_NOTHING);
813+
ctxt->info.outer_vlan_flags =
814+
FIELD_PREP(ICE_AQ_VSI_OUTER_VLAN_TX_MODE_M,
815+
ICE_AQ_VSI_OUTER_VLAN_TX_MODE_ALL);
816+
ctxt->info.outer_vlan_flags |=
817+
FIELD_PREP(ICE_AQ_VSI_OUTER_TAG_TYPE_M,
818+
ICE_AQ_VSI_OUTER_TAG_VLAN_8100);
819+
ctxt->info.outer_vlan_flags |=
820+
ICE_AQ_VSI_OUTER_VLAN_EMODE_NOTHING <<
821+
ICE_AQ_VSI_OUTER_VLAN_EMODE_S;
822+
}
823+
824+
ctxt->info.sw_flags2 &= ~ICE_AQ_VSI_SW_FLAG_RX_VLAN_PRUNE_ENA;
825+
ctxt->info.valid_sections =
826+
cpu_to_le16(ICE_AQ_VSI_PROP_OUTER_TAG_VALID |
827+
ICE_AQ_VSI_PROP_VLAN_VALID |
828+
ICE_AQ_VSI_PROP_SW_VALID);
829+
830+
err = ice_update_vsi(hw, vsi->idx, ctxt, NULL);
831+
if (err) {
832+
dev_err(ice_pf_to_dev(vsi->back), "update VSI for clearing port based VLAN failed, err %d aq_err %s\n",
833+
err, ice_aq_str(hw->adminq.sq_last_status));
834+
} else {
835+
vsi->info.port_based_outer_vlan =
836+
ctxt->info.port_based_outer_vlan;
837+
vsi->info.port_based_inner_vlan =
838+
ctxt->info.port_based_inner_vlan;
839+
vsi->info.outer_vlan_flags = ctxt->info.outer_vlan_flags;
840+
vsi->info.inner_vlan_flags = ctxt->info.inner_vlan_flags;
841+
vsi->info.sw_flags2 = ctxt->info.sw_flags2;
842+
}
843+
844+
kfree(ctxt);
845+
return err;
846+
}

drivers/net/ethernet/intel/ice/ice_vsi_vlan_lib.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@ int ice_vsi_ena_outer_insertion(struct ice_vsi *vsi, u16 tpid);
3636
int ice_vsi_dis_outer_insertion(struct ice_vsi *vsi);
3737
int ice_vsi_set_outer_port_vlan(struct ice_vsi *vsi, struct ice_vlan *vlan);
3838
int ice_vsi_clear_outer_port_vlan(struct ice_vsi *vsi);
39+
int ice_vsi_clear_port_vlan(struct ice_vsi *vsi);
3940

4041
#endif /* _ICE_VSI_VLAN_LIB_H_ */

0 commit comments

Comments
 (0)