iavf: Fix max_rate limiting
Subsystems (2)
PATCH v3 1/1 iavf: Fix max_rate limiting
From: Przemyslaw Patynowski <[email protected]>
Fix max_rate option in tc, check for proper quanta boundaries. Check for minimum value provided and if it fits expected 50Mbps quanta.
Without this patch, iavf could send settings for max_rate limiting that would be accepted from by PF even the max_rate option is less than expected 50Mbps quanta. It results in no rate limiting on traffic as rate limiting will be floored to 0.
Example:
tc qdisc add dev $vf root mqprio num_tc 3 map 0 2 1 queues \
2@0 2@2 2@4 hw 1 mode channel shaper bw_rlimit \max_rate 50Mbps 500Mbps 500Mbps
Should limit TC0 to circa 50 Mbps
tc qdisc add dev $vf root mqprio num_tc 3 map 0 2 1 queues \
2@0 2@2 2@4 hw 1 mode channel shaper bw_rlimit \max_rate 0Mbps 100Kbit 500Mbps
Should return error
---
v2: Change author to Przemyslaw, and change variable to RCT
v3: Add space between title & commit message body
--- drivers/net/ethernet/intel/iavf/iavf.h | 1 + drivers/net/ethernet/intel/iavf/iavf_main.c | 24 +++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/iavf/iavf.h +1 -0
@@ -93,6 +93,7 @@ struct iavf_vsi {#define IAVF_HKEY_ARRAY_SIZE ((IAVF_VFQF_HKEY_MAX_INDEX + 1) * 4)#define IAVF_HLUT_ARRAY_SIZE ((IAVF_VFQF_HLUT_MAX_INDEX + 1) * 4)#define IAVF_MBPS_DIVISOR 125000/* divisor to convert to Mbps */ +#define IAVF_MBPS_QUANTA 50#define IAVF_VIRTCHNL_VF_RESOURCE_SIZE (sizeof(struct virtchnl_vf_resource) + \ (IAVF_MAX_VF_VSI * \
drivers/net/ethernet/intel/iavf/iavf_main.c +22 -2
@@ -3409,6 +3409,7 @@ static int iavf_validate_ch_config(struct iavf_adapter *adapter, struct tc_mqprio_qopt_offload *mqprio_qopt) {u64 total_max_rate =0 ; +u32 tx_rate_rem =0 ;int i, num_qps =0 ;u64 tx_rate =0 ;int ret =0 ;
@@ -3423,12 +3424,31 @@ static int iavf_validate_ch_config(struct iavf_adapter *adapter,return -EINVAL ;if (mqprio_qopt->min_rate[i]) {dev_err (&adapter->pdev->dev, -"Invalid min tx rate (greater than 0) specified\n" ); +"Invalid min tx rate (greater than 0) specified for TC%d\n" , i);return -EINVAL ; } -/*convert to Mbps */ + +/* convert to Mbps */ tx_rate =div_u64 (mqprio_qopt->max_rate[i],IAVF_MBPS_DIVISOR ); + +if (mqprio_qopt->max_rate[i] && + tx_rate <IAVF_MBPS_QUANTA ) { +dev_err (&adapter->pdev->dev, +"Invalid max tx rate for TC%d, minimum %dMbps\n" , + i,IAVF_MBPS_QUANTA ); +return -EINVAL ; + } + + (void )div_u64_rem (tx_rate,IAVF_MBPS_QUANTA , &tx_rate_rem); + +if (tx_rate_rem !=0 ) { +dev_err (&adapter->pdev->dev, +"Invalid max tx rate for TC%d, not divisible by %d\n" , + i,IAVF_MBPS_QUANTA ); +return -EINVAL ; + } + total_max_rate += tx_rate; num_qps += mqprio_qopt->qopt.count[i]; }
Signature · 6 lines
2.35.3 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Tony Nguyen
maintainerQuoted 18 lines · Jun Zhang
From: Przemyslaw Patynowski <[email protected]>
Fix
max_rateoption in tc, check for proper quanta boundaries. Check for minimum value provided and if it fits expected 50Mbps quanta.Without this patch, iavf could send settings for
max_ratelimiting that would be accepted from by PF even themax_rateoption is less than expected 50Mbps quanta. It results in no rate limiting on traffic as rate limiting will be floored to 0.Example:
tc qdisc add dev $vf root mqprionum_tc3 map 0 2 1 queues \
2@0 2@2 2@4 hw 1 mode channel shaperbw_rlimit\max_rate50Mbps 500Mbps 500MbpsShould limit TC0 to circa 50 Mbps
Quoted 7 lines
tc qdisc add dev $vf root mqprio
num_tc3 map 0 2 1 queues \
2@0 2@2 2@4 hw 1 mode channel shaperbw_rlimit\max_rate0Mbps 100Kbit 500MbpsShould return error
Fixes d5b33d0 ("i40evf: add ndo_setup_tc callback to i40evf")
The fixes tag should be 12 chars [1].
Commit: b181df353c12 ("iavf: Fix max_rate limiting")
Fixes tag: Fixes: d5b33d0 ("i40evf: add ndo_setup_tc callback to i40evf") Has these problem(s):
- SHA1 should be at least 12 digits long
Can be fixed by setting core.abbrev to 12 (or more) or (for git v2.11 or later) just making sure it is not set (or set to "auto").
Quoted 2 lines
Signed-off-by Przemyslaw Patynowski <[email protected]>Signed-off-by Jun Zhang <[email protected]>
[1] https://www.kernel.org/doc/html/latest/process/submitting-patches.html#describe-changes
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan