mlxsw: spectrum_qdisc: Fix 64-bit division error in mlxsw_sp_qdisc_tbf_rate_kbps
Subsystems (3)
PATCH 1/1 mlxsw: spectrum_qdisc: Fix 64-bit division error in mlxsw_sp_qdisc_tbf_rate_kbps
When building arm32 allmodconfig:
ERROR: "__aeabi_uldivmod" [drivers/net/ethernet/mellanox/mlxsw/mlxsw_spectrum.ko] undefined!
rate_bytes_ps has type u64, we need to use a 64-bit division helper to avoid a build error.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c +1 -1
@@ -614,7 +614,7 @@ mlxsw_sp_qdisc_tbf_rate_kbps(struct tc_tbf_qopt_offload_replace_params *p)/* TBF interface is in bytes/s, whereas Spectrum ASIC is configured in * Kbits/s. */ -return p->rate.rate_bytes_ps /1000 *8 ; +return div_u64 (p->rate.rate_bytes_ps,1000 *8 ); } static int
Signature · 1 line
2.25.0
Quoted 19 lines · Nathan Chancellor
When building arm32 allmodconfig:
ERROR: "
__aeabi_uldivmod" [drivers/net/ethernet/mellanox/mlxsw/mlxsw_spectrum.ko] undefined!
rate_bytes_pshas type u64, we need to use a 64-bit division helper to avoid a build error.Fixes a44f58c41bfb ("mlxsw: spectrum_qdisc: Support offloading of TBF Qdisc")Signed-off-by Nathan Chancellor <[email protected]>--- drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c +0
-0
drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c mlxsw_sp_qdisc_tbf_rate_kbps(struct tc_tbf_qopt_offload_replace_params *p) · line 617
Quoted 5 lines
drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c +1
-1@@ -614,7 +614,7 @@ mlxsw_sp_qdisc_tbf_rate_kbps(struct tc_tbf_qopt_offload_replace_params *p)/* TBF interface is in bytes/s, whereas Spectrum ASIC is configured in * Kbits/s. */ -return p->rate.rate_bytes_ps /1000 *8 ; +return div_u64 (p->rate.rate_bytes_ps,1000 *8 );
not quite right AFAICT.
try either
return div_u64(p->rate.rate_bytes_ps * 8, 1000); or return div_u64(p->rate.rate_bytes_ps, 1000) * 8;
Quoted 4 lines
drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c +0
-0} static int
Signature · 1 line
~Randy
Quoted 28 lines · Randy Dunlap
Quoted 19 lines · Nathan Chancellor
When building arm32 allmodconfig:
ERROR: "
__aeabi_uldivmod" [drivers/net/ethernet/mellanox/mlxsw/mlxsw_spectrum.ko] undefined!
rate_bytes_pshas type u64, we need to use a 64-bit division helper to avoid a build error.Fixes a44f58c41bfb ("mlxsw: spectrum_qdisc: Support offloading of TBF Qdisc")Signed-off-by Nathan Chancellor <[email protected]>--- drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c +0
-0drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c mlxsw_sp_qdisc_tbf_rate_kbps(struct tc_tbf_qopt_offload_replace_params *p) · line 617
Quoted 5 lines
drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c +1
-1@@ -614,7 +614,7 @@ mlxsw_sp_qdisc_tbf_rate_kbps(struct tc_tbf_qopt_offload_replace_params *p)/* TBF interface is in bytes/s, whereas Spectrum ASIC is configured in * Kbits/s. */ -return p->rate.rate_bytes_ps /1000 *8 ; +return div_u64 (p->rate.rate_bytes_ps,1000 *8 );not quite right AFAICT.
Quoted 5 lines
try either
return div_u64(p->rate.rate_bytes_ps * 8, 1000); or return div_u64(p->rate.rate_bytes_ps, 1000) * 8;
Gah, I swear I can math... Thank you for catching this, v2 incoming with the later because I think it looks better.
Cheers,
Nathan
Quoted 9 lines
Quoted 4 lines
drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c +0
-0} static intSignature · 1 line
~Randy
Quoted 29 lines · Nathan Chancellor
Quoted 28 lines · Randy Dunlap
Quoted 19 lines · Nathan Chancellor
When building arm32 allmodconfig:
ERROR: "
__aeabi_uldivmod" [drivers/net/ethernet/mellanox/mlxsw/mlxsw_spectrum.ko] undefined!
rate_bytes_pshas type u64, we need to use a 64-bit division helper to avoid a build error.Fixes a44f58c41bfb ("mlxsw: spectrum_qdisc: Support offloading of TBF Qdisc")Signed-off-by Nathan Chancellor <[email protected]>--- drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c +0
-0drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c mlxsw_sp_qdisc_tbf_rate_kbps(struct tc_tbf_qopt_offload_replace_params *p) · line 617
Quoted 5 lines
drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c +1
-1@@ -614,7 +614,7 @@ mlxsw_sp_qdisc_tbf_rate_kbps(struct tc_tbf_qopt_offload_replace_params *p)/* TBF interface is in bytes/s, whereas Spectrum ASIC is configured in * Kbits/s. */ -return p->rate.rate_bytes_ps /1000 *8 ; +return div_u64 (p->rate.rate_bytes_ps,1000 *8 );not quite right AFAICT.
Quoted 8 lines
Quoted 5 lines
try either
return div_u64(p->rate.rate_bytes_ps * 8, 1000); or return div_u64(p->rate.rate_bytes_ps, 1000) * 8;Gah, I swear I can math... Thank you for catching this, v2 incoming with the later because I think it looks better.
Yes, that's the correct choice. Divide first, that way we can't overflow.
Thanks for taking care of this.
PATCH v2 1/1 mlxsw: spectrum_qdisc: Fix 64-bit division error in mlxsw_sp_qdisc_tbf_rate_kbps
In reply to Nathan ChancellorWhen building arm32 allmodconfig:
ERROR: "__aeabi_uldivmod" [drivers/net/ethernet/mellanox/mlxsw/mlxsw_spectrum.ko] undefined!
rate_bytes_ps has type u64, we need to use a 64-bit division helper to avoid a build error.
---
v1 -> v2:
* Fix incorrect math as pointed out by Randy Dunlap
drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c +1 -1
@@ -614,7 +614,7 @@ mlxsw_sp_qdisc_tbf_rate_kbps(struct tc_tbf_qopt_offload_replace_params *p)/* TBF interface is in bytes/s, whereas Spectrum ASIC is configured in * Kbits/s. */ -return p->rate.rate_bytes_ps /1000 *8 ; +return div_u64 (p->rate.rate_bytes_ps,1000 ) *8 ; } static int
Signature · 1 line
2.25.0
Quoted 10 lines · Nathan Chancellor
When building arm32 allmodconfig:
ERROR: "
__aeabi_uldivmod" [drivers/net/ethernet/mellanox/mlxsw/mlxsw_spectrum.ko] undefined!
rate_bytes_pshas type u64, we need to use a 64-bit division helper to avoid a build error.Fixes a44f58c41bfb ("mlxsw: spectrum_qdisc: Support offloading of TBF Qdisc")Signed-off-by Nathan Chancellor <[email protected]>
Thanks, Nathan.
Quoted 10 lines · Fri, Jan 31, 2020 at 02:51:23AM CET, [email protected] wrote:
When building arm32 allmodconfig:
ERROR: "
__aeabi_uldivmod" [drivers/net/ethernet/mellanox/mlxsw/mlxsw_spectrum.ko] undefined!
rate_bytes_pshas type u64, we need to use a 64-bit division helper to avoid a build error.Fixes a44f58c41bfb ("mlxsw: spectrum_qdisc: Support offloading of TBF Qdisc")Signed-off-by Nathan Chancellor <[email protected]>
Quoted 10 lines · Nathan Chancellor
When building arm32 allmodconfig:
ERROR: "
__aeabi_uldivmod" [drivers/net/ethernet/mellanox/mlxsw/mlxsw_spectrum.ko] undefined!
rate_bytes_pshas type u64, we need to use a 64-bit division helper to avoid a build error.Fixes a44f58c41bfb ("mlxsw: spectrum_qdisc: Support offloading of TBF Qdisc")Signed-off-by Nathan Chancellor <[email protected]>
Applied, thank you.