Commit 28756d9e authored by Jacob Keller's avatar Jacob Keller Committed by Tony Nguyen

ice: convert ice_mbx_clear_malvf to void and use WARN

The ice_mbx_clear_malvf function checks for a few error conditions before
clearing the appropriate data. These error conditions are really warnings
that should never occur in a properly initialized driver. Every caller of
ice_mbx_clear_malvf just prints a dev_dbg message on failure which will
generally be ignored.

Convert this function to void and switch the error return values to
WARN_ON. This will make any potentially misconfiguration more visible and
makes future refactors that involve changing how we store the malicious VF
data easier.
Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
Reviewed-by: default avatarMichal Swiatkowski <michal.swiatkowski@linux.intel.com>
Tested-by: default avatarMarek Szlosek <marek.szlosek@intel.com>
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
parent 504ce971
...@@ -204,10 +204,8 @@ void ice_free_vfs(struct ice_pf *pf) ...@@ -204,10 +204,8 @@ void ice_free_vfs(struct ice_pf *pf)
} }
/* clear malicious info since the VF is getting released */ /* clear malicious info since the VF is getting released */
if (ice_mbx_clear_malvf(&hw->mbx_snapshot, pf->vfs.malvfs, ice_mbx_clear_malvf(&hw->mbx_snapshot, pf->vfs.malvfs,
ICE_MAX_SRIOV_VFS, vf->vf_id)) ICE_MAX_SRIOV_VFS, vf->vf_id);
dev_dbg(dev, "failed to clear malicious VF state for VF %u\n",
vf->vf_id);
mutex_unlock(&vf->cfg_lock); mutex_unlock(&vf->cfg_lock);
} }
......
...@@ -496,10 +496,8 @@ void ice_reset_all_vfs(struct ice_pf *pf) ...@@ -496,10 +496,8 @@ void ice_reset_all_vfs(struct ice_pf *pf)
/* clear all malicious info if the VFs are getting reset */ /* clear all malicious info if the VFs are getting reset */
ice_for_each_vf(pf, bkt, vf) ice_for_each_vf(pf, bkt, vf)
if (ice_mbx_clear_malvf(&hw->mbx_snapshot, pf->vfs.malvfs, ice_mbx_clear_malvf(&hw->mbx_snapshot, pf->vfs.malvfs,
ICE_MAX_SRIOV_VFS, vf->vf_id)) ICE_MAX_SRIOV_VFS, vf->vf_id);
dev_dbg(dev, "failed to clear malicious VF state for VF %u\n",
vf->vf_id);
/* If VFs have been disabled, there is no need to reset */ /* If VFs have been disabled, there is no need to reset */
if (test_and_set_bit(ICE_VF_DIS, pf->state)) { if (test_and_set_bit(ICE_VF_DIS, pf->state)) {
...@@ -705,10 +703,8 @@ int ice_reset_vf(struct ice_vf *vf, u32 flags) ...@@ -705,10 +703,8 @@ int ice_reset_vf(struct ice_vf *vf, u32 flags)
ice_eswitch_replay_vf_mac_rule(vf); ice_eswitch_replay_vf_mac_rule(vf);
/* if the VF has been reset allow it to come up again */ /* if the VF has been reset allow it to come up again */
if (ice_mbx_clear_malvf(&hw->mbx_snapshot, pf->vfs.malvfs, ice_mbx_clear_malvf(&hw->mbx_snapshot, pf->vfs.malvfs,
ICE_MAX_SRIOV_VFS, vf->vf_id)) ICE_MAX_SRIOV_VFS, vf->vf_id);
dev_dbg(dev, "failed to clear malicious VF state for VF %u\n",
vf->vf_id);
out_unlock: out_unlock:
if (flags & ICE_VF_RESET_LOCK) if (flags & ICE_VF_RESET_LOCK)
......
...@@ -392,19 +392,19 @@ ice_mbx_report_malvf(struct ice_hw *hw, unsigned long *all_malvfs, ...@@ -392,19 +392,19 @@ ice_mbx_report_malvf(struct ice_hw *hw, unsigned long *all_malvfs,
* that the new VF loaded is not considered malicious before going * that the new VF loaded is not considered malicious before going
* through the overflow detection algorithm. * through the overflow detection algorithm.
*/ */
int void
ice_mbx_clear_malvf(struct ice_mbx_snapshot *snap, unsigned long *all_malvfs, ice_mbx_clear_malvf(struct ice_mbx_snapshot *snap, unsigned long *all_malvfs,
u16 bitmap_len, u16 vf_id) u16 bitmap_len, u16 vf_id)
{ {
if (!snap || !all_malvfs) if (WARN_ON(!snap || !all_malvfs))
return -EINVAL; return;
if (bitmap_len < snap->mbx_vf.vfcntr_len) if (WARN_ON(bitmap_len < snap->mbx_vf.vfcntr_len))
return -EINVAL; return;
/* Ensure VF ID value is not larger than bitmap or VF counter length */ /* Ensure VF ID value is not larger than bitmap or VF counter length */
if (vf_id >= bitmap_len || vf_id >= snap->mbx_vf.vfcntr_len) if (WARN_ON(vf_id >= bitmap_len || vf_id >= snap->mbx_vf.vfcntr_len))
return -EIO; return;
/* Clear VF ID bit in the bitmap tracking malicious VFs attached to PF */ /* Clear VF ID bit in the bitmap tracking malicious VFs attached to PF */
clear_bit(vf_id, all_malvfs); clear_bit(vf_id, all_malvfs);
...@@ -416,8 +416,6 @@ ice_mbx_clear_malvf(struct ice_mbx_snapshot *snap, unsigned long *all_malvfs, ...@@ -416,8 +416,6 @@ ice_mbx_clear_malvf(struct ice_mbx_snapshot *snap, unsigned long *all_malvfs,
* values in the mailbox overflow detection algorithm. * values in the mailbox overflow detection algorithm.
*/ */
snap->mbx_vf.vf_cntr[vf_id] = 0; snap->mbx_vf.vf_cntr[vf_id] = 0;
return 0;
} }
/** /**
......
...@@ -22,7 +22,7 @@ u32 ice_conv_link_speed_to_virtchnl(bool adv_link_support, u16 link_speed); ...@@ -22,7 +22,7 @@ u32 ice_conv_link_speed_to_virtchnl(bool adv_link_support, u16 link_speed);
int int
ice_mbx_vf_state_handler(struct ice_hw *hw, struct ice_mbx_data *mbx_data, ice_mbx_vf_state_handler(struct ice_hw *hw, struct ice_mbx_data *mbx_data,
u16 vf_id, bool *is_mal_vf); u16 vf_id, bool *is_mal_vf);
int void
ice_mbx_clear_malvf(struct ice_mbx_snapshot *snap, unsigned long *all_malvfs, ice_mbx_clear_malvf(struct ice_mbx_snapshot *snap, unsigned long *all_malvfs,
u16 bitmap_len, u16 vf_id); u16 bitmap_len, u16 vf_id);
int ice_mbx_init_snapshot(struct ice_hw *hw, u16 vf_count); int ice_mbx_init_snapshot(struct ice_hw *hw, u16 vf_count);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment