ice: Add support for VF rate limiting
Subsystems (2)
Tony Nguyen
maintainerPATCH 1/1 ice: Add support for VF rate limiting
From: Brett Creeley <[email protected]>
Implement ndo_set_vf_rate to support setting of min_tx_rate and max_tx_rate; set the appropriate bandwidth in the scheduler for the node representing the specified VF VSI.
Co-developed-by Tarun Singh <[email protected]>
Signed-off-by Tarun Singh <[email protected]>
Signed-off-by Brett Creeley <[email protected]>
Signed-off-by Tony Nguyen <[email protected]>
--- drivers/net/ethernet/intel/ice/ice_lib.c | 174 ++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_lib.h | 4 +- drivers/net/ethernet/intel/ice/ice_main.c | 1 + drivers/net/ethernet/intel/ice/ice_sched.c | 129 +++++++++++++ drivers/net/ethernet/intel/ice/ice_sched.h | 10 + .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 160 +++++++++++++++- .../net/ethernet/intel/ice/ice_virtchnl_pf.h | 15 +- 7 files changed, 489 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/ice/ice_lib.c +174 -0
@@ -3592,6 +3592,180 @@ int ice_clear_dflt_vsi(struct ice_sw *sw)return 0 ; } +/** +* ice_get_link_speed_mbps - get link speed in Mbps +* @vsi: the VSI whose link speed is being queried +* +* Return current VSI link speed and 0 if the speed is unknown. +*/ +int ice_get_link_speed_mbps (struct ice_vsi *vsi) +{ +switch (vsi->port_info->phy.link_info.link_speed) { +case ICE_AQ_LINK_SPEED_100GB : +return SPEED_100000 ; +case ICE_AQ_LINK_SPEED_50GB : +return SPEED_50000 ; +case ICE_AQ_LINK_SPEED_40GB : +return SPEED_40000 ; +case ICE_AQ_LINK_SPEED_25GB : +return SPEED_25000 ; +case ICE_AQ_LINK_SPEED_20GB : +return SPEED_20000 ; +case ICE_AQ_LINK_SPEED_10GB : +return SPEED_10000 ; +case ICE_AQ_LINK_SPEED_5GB : +return SPEED_5000 ; +case ICE_AQ_LINK_SPEED_2500MB : +return SPEED_2500 ; +case ICE_AQ_LINK_SPEED_1000MB : +return SPEED_1000 ; +case ICE_AQ_LINK_SPEED_100MB : +return SPEED_100 ; +case ICE_AQ_LINK_SPEED_10MB : +return SPEED_10 ; +case ICE_AQ_LINK_SPEED_UNKNOWN : +default : +return 0 ; + } +} + +/** +* ice_get_link_speed_kbps - get link speed in Kbps +* @vsi: the VSI whose link speed is being queried +* +* Return current VSI link speed and 0 if the speed is unknown. +*/ +static int ice_get_link_speed_kbps (struct ice_vsi *vsi) +{ +int speed_mbps; + + speed_mbps =ice_get_link_speed_mbps (vsi); + +return speed_mbps *1000 ; +} + +/** +* ice_set_min_bw_limit - setup minimum BW limit for Tx based on min_tx_rate +* @vsi: VSI to be configured +* @min_tx_rate: min Tx rate in Kbps to be configured as BW limit +* +* If the min_tx_rate is specified as 0 that means to clear the minimum BW limit +* profile, otherwise a non-zero value will force a minimum BW limit for the VSI +* on TC 0. +*/ +int ice_set_min_bw_limit (struct ice_vsi *vsi,u64 min_tx_rate) +{ +struct ice_pf *pf = vsi->back; +enum ice_status status; +struct device *dev; +int speed; + + dev =ice_pf_to_dev (pf); +if (!vsi->port_info) { +dev_dbg (dev,"VSI %d, type %u specified doesn't have valid port_info\n" , + vsi->idx, vsi->type); +return -EINVAL ; + } + + speed =ice_get_link_speed_kbps (vsi); +if (min_tx_rate > (u64 )speed) { +dev_err (dev,"invalid min Tx rate %llu Kbps specified for %s %d is greater than current link speed %u Kbps\n" , + min_tx_rate,ice_vsi_type_str (vsi->type), vsi->idx, + speed); +return -EINVAL ; + } + +/* Configure min BW for VSI limit */ +if (min_tx_rate) { + status =ice_cfg_vsi_bw_lmt_per_tc (vsi->port_info, vsi->idx,0 , +ICE_MIN_BW , min_tx_rate); +if (status) { +dev_err (dev,"failed to set min Tx rate(%llu Kbps) for %s %d\n" , + min_tx_rate,ice_vsi_type_str (vsi->type), + vsi->idx); +return -EIO ; + } + +dev_dbg (dev,"set min Tx rate(%llu Kbps) for %s\n" , + min_tx_rate,ice_vsi_type_str (vsi->type)); + }else { + status =ice_cfg_vsi_bw_dflt_lmt_per_tc (vsi->port_info, + vsi->idx,0 , +ICE_MIN_BW ); +if (status) { +dev_err (dev,"failed to clear min Tx rate configuration for %s %d\n" , +ice_vsi_type_str (vsi->type), vsi->idx); +return -EIO ; + } + +dev_dbg (dev,"cleared min Tx rate configuration for %s %d\n" , +ice_vsi_type_str (vsi->type), vsi->idx); + } + +return 0 ; +} + +/** +* ice_set_max_bw_limit - setup maximum BW limit for Tx based on max_tx_rate +* @vsi: VSI to be configured +* @max_tx_rate: max Tx rate in Kbps to be configured as BW limit +* +* If the max_tx_rate is specified as 0 that means to clear the maximum BW limit +* profile, otherwise a non-zero value will force a maximum BW limit for the VSI +* on TC 0. +*/ +int ice_set_max_bw_limit (struct ice_vsi *vsi,u64 max_tx_rate) +{ +struct ice_pf *pf = vsi->back; +enum ice_status status; +struct device *dev; +int speed; + + dev =ice_pf_to_dev (pf); +if (!vsi->port_info) { +dev_dbg (dev,"VSI %d, type %u specified doesn't have valid port_info\n" , + vsi->idx, vsi->type); +return -EINVAL ; + } + + speed =ice_get_link_speed_kbps (vsi); +if (max_tx_rate > (u64 )speed) { +dev_err (dev,"invalid max Tx rate %llu Kbps specified for %s %d is greater than current link speed %u Kbps\n" , + max_tx_rate,ice_vsi_type_str (vsi->type), vsi->idx, + speed); +return -EINVAL ; + } + +/* Configure max BW for VSI limit */ +if (max_tx_rate) { + status =ice_cfg_vsi_bw_lmt_per_tc (vsi->port_info, vsi->idx,0 , +ICE_MAX_BW , max_tx_rate); +if (status) { +dev_err (dev,"failed setting max Tx rate(%llu Kbps) for %s %d\n" , + max_tx_rate,ice_vsi_type_str (vsi->type), + vsi->idx); +return -EIO ; + } + +dev_dbg (dev,"set max Tx rate(%llu Kbps) for %s %d\n" , + max_tx_rate,ice_vsi_type_str (vsi->type), vsi->idx); + }else { + status =ice_cfg_vsi_bw_dflt_lmt_per_tc (vsi->port_info, + vsi->idx,0 , +ICE_MAX_BW ); +if (status) { +dev_err (dev,"failed clearing max Tx rate configuration for %s %d\n" , +ice_vsi_type_str (vsi->type), vsi->idx); +return -EIO ; + } + +dev_dbg (dev,"cleared max Tx rate configuration for %s %d\n" , +ice_vsi_type_str (vsi->type), vsi->idx); + } + +return 0 ; +} +/** * ice_set_link - turn on/off physical link * @vsi: VSI to modify physical link on
drivers/net/ethernet/intel/ice/ice_lib.h +3 -1
@@ -116,7 +116,9 @@ bool ice_is_vsi_dflt_vsi(struct ice_sw *sw, struct ice_vsi *vsi);int ice_set_dflt_vsi (struct ice_sw *sw,struct ice_vsi *vsi);int ice_clear_dflt_vsi (struct ice_sw *sw); - +int ice_set_min_bw_limit (struct ice_vsi *vsi,u64 min_tx_rate); +int ice_set_max_bw_limit (struct ice_vsi *vsi,u64 max_tx_rate); +int ice_get_link_speed_mbps (struct ice_vsi *vsi);int ice_vsi_update_security (struct ice_vsi *vsi,void (*fill)(struct ice_vsi_ctx *));
drivers/net/ethernet/intel/ice/ice_main.c +1 -0
@@ -7443,6 +7443,7 @@ static const struct net_device_ops ice_netdev_ops = { .ndo_set_vf_vlan = ice_set_vf_port_vlan, .ndo_set_vf_link_state = ice_set_vf_link_state, .ndo_get_vf_stats = ice_get_vf_stats, + .ndo_set_vf_rate = ice_set_vf_bw, .ndo_vlan_rx_add_vid = ice_vlan_rx_add_vid, .ndo_vlan_rx_kill_vid = ice_vlan_rx_kill_vid, .ndo_setup_tc = ice_setup_tc,
drivers/net/ethernet/intel/ice/ice_sched.c +129 -0
141 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_sched.h +10 -0
@@ -104,6 +104,16 @@ ice_cfg_q_bw_lmt(struct ice_port_info *pi, u16 vsi_handle, u8 tc,enum ice_status ice_cfg_q_bw_dflt_lmt (struct ice_port_info *pi,u16 vsi_handle,u8 tc,u16 q_handle,enum ice_rl_type rl_type); +enum ice_status +ice_cfg_vsi_bw_lmt_per_tc (struct ice_port_info *pi,u16 vsi_handle,u8 tc, +enum ice_rl_type rl_type,u32 bw); +enum ice_status +ice_cfg_vsi_bw_dflt_lmt_per_tc (struct ice_port_info *pi,u16 vsi_handle,u8 tc, +enum ice_rl_type rl_type); +enum ice_status +ice_sched_set_node_bw_lmt_per_tc (struct ice_port_info *pi,u32 id, +enum ice_agg_type agg_type,u8 tc, +enum ice_rl_type rl_type,u32 bw);enum ice_status ice_cfg_rl_burst_size (struct ice_hw *hw,u32 bytes);void ice_sched_replay_agg_vsi_preinit (struct ice_hw *hw);void ice_sched_replay_agg (struct ice_hw *hw);
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +158 -2
190 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h +14 -1
@@ -125,7 +125,8 @@ struct ice_vf {* the main LAN VSI for the PF. */ u16 lan_vsi_num;/* ID as used by firmware */ -unsigned int tx_rate;/* Tx bandwidth limit in Mbps */ +unsigned int min_tx_rate;/* Minimum Tx bandwidth limit in Mbps */ +unsigned int max_tx_rate;/* Maximum Tx bandwidth limit in Mbps */ DECLARE_BITMAP (vf_states,ICE_VF_STATES_NBITS );/* VF runtime states */ u64 num_inval_msgs;/* number of continuous invalid msgs */
@@ -172,6 +173,10 @@ int ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos, __be16 vlan_proto); +int +ice_set_vf_bw (struct net_device *netdev,int vf_id,int min_tx_rate, +int max_tx_rate); +int ice_set_vf_trust (struct net_device *netdev,int vf_id,bool trusted);int ice_set_vf_link_state (struct net_device *netdev,int vf_id,int link_state);
@@ -297,6 +302,14 @@ ice_set_vf_link_state(struct net_device __always_unused *netdev,return -EOPNOTSUPP ; } +static inline int +ice_set_vf_bw (struct net_device __always_unused *netdev, +int __always_unused vf_id,int __always_unused min_tx_rate, +int __always_unused max_tx_rate) +{ +return -EOPNOTSUPP ; +} +static inline int ice_calc_vf_reg_idx (struct ice_vf __always_unused *vf,struct ice_q_vector __always_unused *q_vector)
Signature · 1 line
2.20.1