[Intel-wired-lan] [PATCH iwl-next v2] ice: add E830 HW VF mailbox message limit support

Alexander Lobakin aleksander.lobakin at intel.com
Fri Aug 9 12:00:27 UTC 2024


From: Paul Greenwalt <paul.greenwalt at intel.com>
Date: Wed, 31 Jul 2024 21:58:29 -0400

> E830 adds hardware support to prevent the VF from overflowing the PF
> mailbox with VIRTCHNL messages. E830 will use the hardware feature
> (ICE_F_MBX_LIMIT) instead of the software solution ice_is_malicious_vf().
> 
> To prevent a VF from overflowing the PF, the PF sets the number of
> messages per VF that can be in the PF's mailbox queue
> (ICE_MBX_OVERFLOW_WATERMARK). When the PF process a message from a VF,
> the PF decrements the per VF message count using the E830_MBX_VF_DEC_TRIG
> register.
> 
> Signed-off-by: Paul Greenwalt <paul.greenwalt at intel.com>
> ---
> v1 -> v2:
> - Update ice_mbx_vf_dec_trig_e830 and ice_mbx_vf_clear_cnt_e830 onstack
>   variables to const
> ---
>  drivers/net/ethernet/intel/ice/ice.h          |  1 +
>  .../net/ethernet/intel/ice/ice_hw_autogen.h   |  3 ++
>  drivers/net/ethernet/intel/ice/ice_lib.c      | 12 +++++++
>  drivers/net/ethernet/intel/ice/ice_main.c     | 24 ++++++++++----
>  drivers/net/ethernet/intel/ice/ice_sriov.c    |  3 +-
>  drivers/net/ethernet/intel/ice/ice_vf_lib.c   | 26 +++++++++++++--
>  drivers/net/ethernet/intel/ice/ice_vf_mbx.c   | 32 +++++++++++++++++++
>  drivers/net/ethernet/intel/ice/ice_vf_mbx.h   |  3 ++
>  drivers/net/ethernet/intel/ice/ice_virtchnl.c |  8 +++--
>  9 files changed, 99 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h
> index 4c563b0d57ac..53c8edbfaede 100644
> --- a/drivers/net/ethernet/intel/ice/ice.h
> +++ b/drivers/net/ethernet/intel/ice/ice.h
> @@ -207,6 +207,7 @@ enum ice_feature {
>  	ICE_F_GNSS,
>  	ICE_F_ROCE_LAG,
>  	ICE_F_SRIOV_LAG,
> +	ICE_F_MBX_LIMIT,
>  	ICE_F_MAX
>  };
>  
> diff --git a/drivers/net/ethernet/intel/ice/ice_hw_autogen.h b/drivers/net/ethernet/intel/ice/ice_hw_autogen.h
> index 91cbae1eec89..a306ea9b207c 100644
> --- a/drivers/net/ethernet/intel/ice/ice_hw_autogen.h
> +++ b/drivers/net/ethernet/intel/ice/ice_hw_autogen.h
> @@ -539,5 +539,8 @@
>  #define E830_PRTMAC_CL01_QNT_THR_CL0_M		GENMASK(15, 0)
>  #define VFINT_DYN_CTLN(_i)			(0x00003800 + ((_i) * 4))
>  #define VFINT_DYN_CTLN_CLEARPBA_M		BIT(1)
> +#define E830_MBX_PF_IN_FLIGHT_VF_MSGS_THRESH    0x00234000
> +#define E830_MBX_VF_DEC_TRIG(_VF)               (0x00233800 + ((_VF) * 4))
> +#define E830_MBX_VF_IN_FLIGHT_MSGS_AT_PF_CNT(_VF) (0x00233000 + ((_VF) * 4))

Still poor indentation, there must be tabs, no spaces.
Also, parenthesis around `(_VF) * 4` are redundant.

>  
>  #endif /* _ICE_HW_AUTOGEN_H_ */
> diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c
> index fc5b87f51702..a6fa2ed6c4ab 100644
> --- a/drivers/net/ethernet/intel/ice/ice_lib.c
> +++ b/drivers/net/ethernet/intel/ice/ice_lib.c
> @@ -3938,6 +3938,18 @@ void ice_init_feature_support(struct ice_pf *pf)
>  		if (ice_gnss_is_gps_present(&pf->hw))
>  			ice_set_feature_support(pf, ICE_F_GNSS);
>  		break;
> +	case ICE_DEV_ID_E830CC_BACKPLANE:
> +	case ICE_DEV_ID_E830CC_QSFP56:
> +	case ICE_DEV_ID_E830CC_SFP:
> +	case ICE_DEV_ID_E830CC_SFP_DD:
> +	case ICE_DEV_ID_E830C_BACKPLANE:
> +	case ICE_DEV_ID_E830C_QSFP:
> +	case ICE_DEV_ID_E830C_SFP:
> +	case ICE_DEV_ID_E830_XXV_BACKPLANE:
> +	case ICE_DEV_ID_E830_XXV_QSFP:
> +	case ICE_DEV_ID_E830_XXV_SFP:

Can't this be somehow compressed via

	case A .. B

There are no holes between at least some of these.

> +		ice_set_feature_support(pf, ICE_F_MBX_LIMIT);
> +		break;
>  	default:
>  		break;
>  	}

[...]

> diff --git a/drivers/net/ethernet/intel/ice/ice_vf_mbx.c b/drivers/net/ethernet/intel/ice/ice_vf_mbx.c
> index 40cb4ba0789c..65d9c41bed21 100644
> --- a/drivers/net/ethernet/intel/ice/ice_vf_mbx.c
> +++ b/drivers/net/ethernet/intel/ice/ice_vf_mbx.c
> @@ -210,6 +210,38 @@ ice_mbx_detect_malvf(struct ice_hw *hw, struct ice_mbx_vf_info *vf_info,
>  	return 0;
>  }
>  
> +/**
> + * ice_mbx_vf_dec_trig_e830 - Decrements the VF mailbox queue counter
> + * @hw: pointer to the HW struct
> + * @event: pointer to the control queue receive event
> + *
> + * This function triggers to decrement the counter
> + * MBX_VF_IN_FLIGHT_MSGS_AT_PF_CNT when the driver replenishes
> + * the buffers at the PF mailbox queue.
> + */
> +void ice_mbx_vf_dec_trig_e830(const struct ice_hw *hw,
> +			      const struct ice_rq_event_info *event)
> +{
> +	const u16 vfid = le16_to_cpu(event->desc.retval);

Oops, I may've confused you. You don't need to constify scalars. Mainly
pointers and structures when possible.

> +
> +	wr32(hw, E830_MBX_VF_DEC_TRIG(vfid), 1);
> +}
> +
> +/**
> + * ice_mbx_vf_clear_cnt_e830 - Clear the VF mailbox queue count
> + * @hw: pointer to the HW struct
> + * @vf_id: VF ID in the PF space
> + *
> + * This function clears the counter MBX_VF_IN_FLIGHT_MSGS_AT_PF_CNT, and should
> + * be called when a VF is created and on VF reset.
> + */
> +void ice_mbx_vf_clear_cnt_e830(const struct ice_hw *hw, const u16 vf_id)
> +{
> +	const u32 reg = rd32(hw, E830_MBX_VF_IN_FLIGHT_MSGS_AT_PF_CNT(vf_id));

Same here for @vf_id and @reg.

> +
> +	wr32(hw, E830_MBX_VF_DEC_TRIG(vf_id), reg);
> +}

Thanks,
Olek


More information about the Intel-wired-lan mailing list