Skip to content

Commit 1a8c777

Browse files
bcreeley13anguy11
authored andcommitted
ice: Fix VF true promiscuous mode
When a VF requests promiscuous mode and it's trusted and true promiscuous mode is enabled the PF driver attempts to enable unicast and/or multicast promiscuous mode filters based on the request. This is fine, but there are a couple issues with the current code. [1] The define to configure the unicast promiscuous mode mask also includes bits to configure the multicast promiscuous mode mask, which causes multicast to be set/cleared unintentionally. [2] All 4 cases for enable/disable unicast/multicast mode are not handled in the promiscuous mode message handler, which causes unexpected results regarding the current promiscuous mode settings. To fix [1] make sure any promiscuous mask defines include the correct bits for each of the promiscuous modes. To fix [2] make sure that all 4 cases are handled since there are 2 bits (FLAG_VF_UNICAST_PROMISC and FLAG_VF_MULTICAST_PROMISC) that can be either set or cleared. Also, since either unicast and/or multicast promiscuous configuration can fail, introduce two separate error values to handle each of these cases. Fixes: 01b5e89 ("ice: Add VF promiscuous support") Signed-off-by: Brett Creeley <[email protected]> Tested-by: Tony Brelinski <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 92f6248 commit 1a8c777

File tree

2 files changed

+40
-43
lines changed

2 files changed

+40
-43
lines changed

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,10 @@
165165
#define ice_for_each_chnl_tc(i) \
166166
for ((i) = ICE_CHNL_START_TC; (i) < ICE_CHNL_MAX_TC; (i)++)
167167

168-
#define ICE_UCAST_PROMISC_BITS (ICE_PROMISC_UCAST_TX | ICE_PROMISC_MCAST_TX | \
169-
ICE_PROMISC_UCAST_RX | ICE_PROMISC_MCAST_RX)
168+
#define ICE_UCAST_PROMISC_BITS (ICE_PROMISC_UCAST_TX | ICE_PROMISC_UCAST_RX)
170169

171170
#define ICE_UCAST_VLAN_PROMISC_BITS (ICE_PROMISC_UCAST_TX | \
172-
ICE_PROMISC_MCAST_TX | \
173171
ICE_PROMISC_UCAST_RX | \
174-
ICE_PROMISC_MCAST_RX | \
175172
ICE_PROMISC_VLAN_TX | \
176173
ICE_PROMISC_VLAN_RX)
177174

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

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3013,6 +3013,7 @@ bool ice_is_any_vf_in_promisc(struct ice_pf *pf)
30133013
static int ice_vc_cfg_promiscuous_mode_msg(struct ice_vf *vf, u8 *msg)
30143014
{
30153015
enum virtchnl_status_code v_ret = VIRTCHNL_STATUS_SUCCESS;
3016+
enum ice_status mcast_status = 0, ucast_status = 0;
30163017
bool rm_promisc, alluni = false, allmulti = false;
30173018
struct virtchnl_promisc_info *info =
30183019
(struct virtchnl_promisc_info *)msg;
@@ -3105,52 +3106,51 @@ static int ice_vc_cfg_promiscuous_mode_msg(struct ice_vf *vf, u8 *msg)
31053106
goto error_param;
31063107
}
31073108
} else {
3108-
enum ice_status status;
3109-
u8 promisc_m;
3110-
3111-
if (alluni) {
3112-
if (vf->port_vlan_info || vsi->num_vlan)
3113-
promisc_m = ICE_UCAST_VLAN_PROMISC_BITS;
3114-
else
3115-
promisc_m = ICE_UCAST_PROMISC_BITS;
3116-
} else if (allmulti) {
3117-
if (vf->port_vlan_info || vsi->num_vlan)
3118-
promisc_m = ICE_MCAST_VLAN_PROMISC_BITS;
3119-
else
3120-
promisc_m = ICE_MCAST_PROMISC_BITS;
3109+
u8 mcast_m, ucast_m;
3110+
3111+
if (vf->port_vlan_info || vsi->num_vlan > 1) {
3112+
mcast_m = ICE_MCAST_VLAN_PROMISC_BITS;
3113+
ucast_m = ICE_UCAST_VLAN_PROMISC_BITS;
31213114
} else {
3122-
if (vf->port_vlan_info || vsi->num_vlan)
3123-
promisc_m = ICE_UCAST_VLAN_PROMISC_BITS;
3124-
else
3125-
promisc_m = ICE_UCAST_PROMISC_BITS;
3115+
mcast_m = ICE_MCAST_PROMISC_BITS;
3116+
ucast_m = ICE_UCAST_PROMISC_BITS;
31263117
}
31273118

3128-
/* Configure multicast/unicast with or without VLAN promiscuous
3129-
* mode
3130-
*/
3131-
status = ice_vf_set_vsi_promisc(vf, vsi, promisc_m, rm_promisc);
3132-
if (status) {
3133-
dev_err(dev, "%sable Tx/Rx filter promiscuous mode on VF-%d failed, error: %s\n",
3134-
rm_promisc ? "dis" : "en", vf->vf_id,
3135-
ice_stat_str(status));
3136-
v_ret = ice_err_to_virt_err(status);
3137-
goto error_param;
3138-
} else {
3139-
dev_dbg(dev, "%sable Tx/Rx filter promiscuous mode on VF-%d succeeded\n",
3140-
rm_promisc ? "dis" : "en", vf->vf_id);
3119+
ucast_status = ice_vf_set_vsi_promisc(vf, vsi, ucast_m,
3120+
!alluni);
3121+
if (ucast_status) {
3122+
dev_err(dev, "%sable Tx/Rx filter promiscuous mode on VF-%d failed\n",
3123+
alluni ? "en" : "dis", vf->vf_id);
3124+
v_ret = ice_err_to_virt_err(ucast_status);
3125+
}
3126+
3127+
mcast_status = ice_vf_set_vsi_promisc(vf, vsi, mcast_m,
3128+
!allmulti);
3129+
if (mcast_status) {
3130+
dev_err(dev, "%sable Tx/Rx filter promiscuous mode on VF-%d failed\n",
3131+
allmulti ? "en" : "dis", vf->vf_id);
3132+
v_ret = ice_err_to_virt_err(mcast_status);
31413133
}
31423134
}
31433135

3144-
if (allmulti &&
3145-
!test_and_set_bit(ICE_VF_STATE_MC_PROMISC, vf->vf_states))
3146-
dev_info(dev, "VF %u successfully set multicast promiscuous mode\n", vf->vf_id);
3147-
else if (!allmulti && test_and_clear_bit(ICE_VF_STATE_MC_PROMISC, vf->vf_states))
3148-
dev_info(dev, "VF %u successfully unset multicast promiscuous mode\n", vf->vf_id);
3136+
if (!mcast_status) {
3137+
if (allmulti &&
3138+
!test_and_set_bit(ICE_VF_STATE_MC_PROMISC, vf->vf_states))
3139+
dev_info(dev, "VF %u successfully set multicast promiscuous mode\n",
3140+
vf->vf_id);
3141+
else if (!allmulti && test_and_clear_bit(ICE_VF_STATE_MC_PROMISC, vf->vf_states))
3142+
dev_info(dev, "VF %u successfully unset multicast promiscuous mode\n",
3143+
vf->vf_id);
3144+
}
31493145

3150-
if (alluni && !test_and_set_bit(ICE_VF_STATE_UC_PROMISC, vf->vf_states))
3151-
dev_info(dev, "VF %u successfully set unicast promiscuous mode\n", vf->vf_id);
3152-
else if (!alluni && test_and_clear_bit(ICE_VF_STATE_UC_PROMISC, vf->vf_states))
3153-
dev_info(dev, "VF %u successfully unset unicast promiscuous mode\n", vf->vf_id);
3146+
if (!ucast_status) {
3147+
if (alluni && !test_and_set_bit(ICE_VF_STATE_UC_PROMISC, vf->vf_states))
3148+
dev_info(dev, "VF %u successfully set unicast promiscuous mode\n",
3149+
vf->vf_id);
3150+
else if (!alluni && test_and_clear_bit(ICE_VF_STATE_UC_PROMISC, vf->vf_states))
3151+
dev_info(dev, "VF %u successfully unset unicast promiscuous mode\n",
3152+
vf->vf_id);
3153+
}
31543154

31553155
error_param:
31563156
return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE,

0 commit comments

Comments
 (0)