Skip to content

Commit f181d79

Browse files
jacob-kellergregkh
authored andcommitted
ice: introduce clear_reset_state operation
[ Upstream commit fa4a15c ] When hardware is reset, the VF relies on the VFGEN_RSTAT register to detect when the VF is finished resetting. This is a tri-state register where 0 indicates a reset is in progress, 1 indicates the hardware is done resetting, and 2 indicates that the software is done resetting. Currently the PF driver relies on the device hardware resetting VFGEN_RSTAT when a global reset occurs. This works ok, but it does mean that the VF might not immediately notice a reset when the driver first detects that the global reset is occurring. This is also problematic for Scalable IOV, because there is no read/write equivalent VFGEN_RSTAT register for the Scalable VSI type. Instead, the Scalable IOV VFs will need to emulate this register. To support this, introduce a new VF operation, clear_reset_state, which is called when the PF driver first detects a global reset. The Single Root IOV implementation can just write to VFGEN_RSTAT to ensure it's cleared immediately, without waiting for the actual hardware reset to begin. The Scalable IOV implementation will use this as part of its tracking of the reset status to allow properly reporting the emulated VFGEN_RSTAT to the VF driver. Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de> Tested-by: Marek Szlosek <marek.szlosek@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com> Stable-dep-of: 7255355 ("ice: Fix ice VF reset during iavf initialization") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 36e6c7a commit f181d79

4 files changed

Lines changed: 31 additions & 4 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ ice_prepare_for_reset(struct ice_pf *pf, enum ice_reset_req reset_type)
573573
/* Disable VFs until reset is completed */
574574
mutex_lock(&pf->vfs.table_lock);
575575
ice_for_each_vf(pf, bkt, vf)
576-
ice_set_vf_state_qs_dis(vf);
576+
ice_set_vf_state_dis(vf);
577577
mutex_unlock(&pf->vfs.table_lock);
578578

579579
if (ice_is_eswitch_mode_switchdev(pf)) {

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,21 @@ static void ice_sriov_free_vf(struct ice_vf *vf)
696696
kfree_rcu(vf, rcu);
697697
}
698698

699+
/**
700+
* ice_sriov_clear_reset_state - clears VF Reset status register
701+
* @vf: the vf to configure
702+
*/
703+
static void ice_sriov_clear_reset_state(struct ice_vf *vf)
704+
{
705+
struct ice_hw *hw = &vf->pf->hw;
706+
707+
/* Clear the reset status register so that VF immediately sees that
708+
* the device is resetting, even if hardware hasn't yet gotten around
709+
* to clearing VFGEN_RSTAT for us.
710+
*/
711+
wr32(hw, VFGEN_RSTAT(vf->vf_id), VIRTCHNL_VFR_INPROGRESS);
712+
}
713+
699714
/**
700715
* ice_sriov_clear_mbx_register - clears SRIOV VF's mailbox registers
701716
* @vf: the vf to configure
@@ -835,6 +850,7 @@ static void ice_sriov_post_vsi_rebuild(struct ice_vf *vf)
835850
static const struct ice_vf_ops ice_sriov_vf_ops = {
836851
.reset_type = ICE_VF_RESET,
837852
.free = ice_sriov_free_vf,
853+
.clear_reset_state = ice_sriov_clear_reset_state,
838854
.clear_mbx_register = ice_sriov_clear_mbx_register,
839855
.trigger_reset_register = ice_sriov_trigger_reset_register,
840856
.poll_reset_status = ice_sriov_poll_reset_status,

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,14 +673,24 @@ int ice_reset_vf(struct ice_vf *vf, u32 flags)
673673
* ice_set_vf_state_qs_dis - Set VF queues state to disabled
674674
* @vf: pointer to the VF structure
675675
*/
676-
void ice_set_vf_state_qs_dis(struct ice_vf *vf)
676+
static void ice_set_vf_state_qs_dis(struct ice_vf *vf)
677677
{
678678
/* Clear Rx/Tx enabled queues flag */
679679
bitmap_zero(vf->txq_ena, ICE_MAX_RSS_QS_PER_VF);
680680
bitmap_zero(vf->rxq_ena, ICE_MAX_RSS_QS_PER_VF);
681681
clear_bit(ICE_VF_STATE_QS_ENA, vf->vf_states);
682682
}
683683

684+
/**
685+
* ice_set_vf_state_dis - Set VF state to disabled
686+
* @vf: pointer to the VF structure
687+
*/
688+
void ice_set_vf_state_dis(struct ice_vf *vf)
689+
{
690+
ice_set_vf_state_qs_dis(vf);
691+
vf->vf_ops->clear_reset_state(vf);
692+
}
693+
684694
/* Private functions only accessed from other virtualization files */
685695

686696
/**

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ struct ice_mdd_vf_events {
5656
struct ice_vf_ops {
5757
enum ice_disq_rst_src reset_type;
5858
void (*free)(struct ice_vf *vf);
59+
void (*clear_reset_state)(struct ice_vf *vf);
5960
void (*clear_mbx_register)(struct ice_vf *vf);
6061
void (*trigger_reset_register)(struct ice_vf *vf, bool is_vflr);
6162
bool (*poll_reset_status)(struct ice_vf *vf);
@@ -213,7 +214,7 @@ u16 ice_get_num_vfs(struct ice_pf *pf);
213214
struct ice_vsi *ice_get_vf_vsi(struct ice_vf *vf);
214215
bool ice_is_vf_disabled(struct ice_vf *vf);
215216
int ice_check_vf_ready_for_cfg(struct ice_vf *vf);
216-
void ice_set_vf_state_qs_dis(struct ice_vf *vf);
217+
void ice_set_vf_state_dis(struct ice_vf *vf);
217218
bool ice_is_any_vf_in_unicast_promisc(struct ice_pf *pf);
218219
void
219220
ice_vf_get_promisc_masks(struct ice_vf *vf, struct ice_vsi *vsi,
@@ -259,7 +260,7 @@ static inline int ice_check_vf_ready_for_cfg(struct ice_vf *vf)
259260
return -EOPNOTSUPP;
260261
}
261262

262-
static inline void ice_set_vf_state_qs_dis(struct ice_vf *vf)
263+
static inline void ice_set_vf_state_dis(struct ice_vf *vf)
263264
{
264265
}
265266

0 commit comments

Comments
 (0)