Skip to content

Commit a419526

Browse files
mwilczyanguy11
authored andcommitted
ice: Fix promiscuous mode not turning off
When trust is turned off for the VF, the expectation is that promiscuous and allmulticast filters are removed. Currently default VSI filter is not getting cleared in this flow. Example: ip link set enp236s0f0 vf 0 trust on ip link set enp236s0f0v0 promisc on ip link set enp236s0f0 vf 0 trust off /* promiscuous mode is still enabled on VF0 */ Remove switch filters for both cases. This commit fixes above behavior by removing default VSI filters and allmulticast filters when vf-true-promisc-support is OFF. Signed-off-by: Michal Wilczynski <[email protected]> Tested-by: Marek Szlosek <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent d739342 commit a419526

File tree

3 files changed

+72
-19
lines changed

3 files changed

+72
-19
lines changed

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

Lines changed: 68 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,73 @@ bool ice_is_any_vf_in_unicast_promisc(struct ice_pf *pf)
297297
return is_vf_promisc;
298298
}
299299

300+
/**
301+
* ice_vf_get_promisc_masks - Calculate masks for promiscuous modes
302+
* @vf: the VF pointer
303+
* @vsi: the VSI to configure
304+
* @ucast_m: promiscuous mask to apply to unicast
305+
* @mcast_m: promiscuous mask to apply to multicast
306+
*
307+
* Decide which mask should be used for unicast and multicast filter,
308+
* based on presence of VLANs
309+
*/
310+
void
311+
ice_vf_get_promisc_masks(struct ice_vf *vf, struct ice_vsi *vsi,
312+
u8 *ucast_m, u8 *mcast_m)
313+
{
314+
if (ice_vf_is_port_vlan_ena(vf) ||
315+
ice_vsi_has_non_zero_vlans(vsi)) {
316+
*mcast_m = ICE_MCAST_VLAN_PROMISC_BITS;
317+
*ucast_m = ICE_UCAST_VLAN_PROMISC_BITS;
318+
} else {
319+
*mcast_m = ICE_MCAST_PROMISC_BITS;
320+
*ucast_m = ICE_UCAST_PROMISC_BITS;
321+
}
322+
}
323+
324+
/**
325+
* ice_vf_clear_all_promisc_modes - Clear promisc/allmulticast on VF VSI
326+
* @vf: the VF pointer
327+
* @vsi: the VSI to configure
328+
*
329+
* Clear all promiscuous/allmulticast filters for a VF
330+
*/
331+
static int
332+
ice_vf_clear_all_promisc_modes(struct ice_vf *vf, struct ice_vsi *vsi)
333+
{
334+
struct ice_pf *pf = vf->pf;
335+
u8 ucast_m, mcast_m;
336+
int ret = 0;
337+
338+
ice_vf_get_promisc_masks(vf, vsi, &ucast_m, &mcast_m);
339+
if (test_bit(ICE_VF_STATE_UC_PROMISC, vf->vf_states)) {
340+
if (!test_bit(ICE_FLAG_VF_TRUE_PROMISC_ENA, pf->flags)) {
341+
if (ice_is_dflt_vsi_in_use(vsi->port_info))
342+
ret = ice_clear_dflt_vsi(vsi);
343+
} else {
344+
ret = ice_vf_clear_vsi_promisc(vf, vsi, ucast_m);
345+
}
346+
347+
if (ret) {
348+
dev_err(ice_pf_to_dev(vf->pf), "Disabling promiscuous mode failed\n");
349+
} else {
350+
clear_bit(ICE_VF_STATE_UC_PROMISC, vf->vf_states);
351+
dev_info(ice_pf_to_dev(vf->pf), "Disabling promiscuous mode succeeded\n");
352+
}
353+
}
354+
355+
if (test_bit(ICE_VF_STATE_MC_PROMISC, vf->vf_states)) {
356+
ret = ice_vf_clear_vsi_promisc(vf, vsi, mcast_m);
357+
if (ret) {
358+
dev_err(ice_pf_to_dev(vf->pf), "Disabling allmulticast mode failed\n");
359+
} else {
360+
clear_bit(ICE_VF_STATE_MC_PROMISC, vf->vf_states);
361+
dev_info(ice_pf_to_dev(vf->pf), "Disabling allmulticast mode succeeded\n");
362+
}
363+
}
364+
return ret;
365+
}
366+
300367
/**
301368
* ice_vf_set_vsi_promisc - Enable promiscuous mode for a VF VSI
302369
* @vf: the VF to configure
@@ -487,7 +554,6 @@ int ice_reset_vf(struct ice_vf *vf, u32 flags)
487554
struct ice_vsi *vsi;
488555
struct device *dev;
489556
struct ice_hw *hw;
490-
u8 promisc_m;
491557
int err = 0;
492558
bool rsd;
493559

@@ -554,16 +620,7 @@ int ice_reset_vf(struct ice_vf *vf, u32 flags)
554620
/* disable promiscuous modes in case they were enabled
555621
* ignore any error if disabling process failed
556622
*/
557-
if (test_bit(ICE_VF_STATE_UC_PROMISC, vf->vf_states) ||
558-
test_bit(ICE_VF_STATE_MC_PROMISC, vf->vf_states)) {
559-
if (ice_vf_is_port_vlan_ena(vf) || vsi->num_vlan)
560-
promisc_m = ICE_UCAST_VLAN_PROMISC_BITS;
561-
else
562-
promisc_m = ICE_UCAST_PROMISC_BITS;
563-
564-
if (ice_vf_clear_vsi_promisc(vf, vsi, promisc_m))
565-
dev_err(dev, "disabling promiscuous mode failed\n");
566-
}
623+
ice_vf_clear_all_promisc_modes(vf, vsi);
567624

568625
ice_eswitch_del_vf_mac_rule(vf);
569626

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ bool ice_is_vf_disabled(struct ice_vf *vf);
215215
int ice_check_vf_ready_for_cfg(struct ice_vf *vf);
216216
void ice_set_vf_state_qs_dis(struct ice_vf *vf);
217217
bool ice_is_any_vf_in_unicast_promisc(struct ice_pf *pf);
218+
void
219+
ice_vf_get_promisc_masks(struct ice_vf *vf, struct ice_vsi *vsi,
220+
u8 *ucast_m, u8 *mcast_m);
218221
int
219222
ice_vf_set_vsi_promisc(struct ice_vf *vf, struct ice_vsi *vsi, u8 promisc_m);
220223
int

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,14 +1046,7 @@ static int ice_vc_cfg_promiscuous_mode_msg(struct ice_vf *vf, u8 *msg)
10461046
goto error_param;
10471047
}
10481048

1049-
if (ice_vf_is_port_vlan_ena(vf) ||
1050-
ice_vsi_has_non_zero_vlans(vsi)) {
1051-
mcast_m = ICE_MCAST_VLAN_PROMISC_BITS;
1052-
ucast_m = ICE_UCAST_VLAN_PROMISC_BITS;
1053-
} else {
1054-
mcast_m = ICE_MCAST_PROMISC_BITS;
1055-
ucast_m = ICE_UCAST_PROMISC_BITS;
1056-
}
1049+
ice_vf_get_promisc_masks(vf, vsi, &ucast_m, &mcast_m);
10571050

10581051
if (!test_bit(ICE_FLAG_VF_TRUE_PROMISC_ENA, pf->flags)) {
10591052
if (alluni) {

0 commit comments

Comments
 (0)