linux-loongson/drivers/net/ethernet/mellanox
Armen Ratner 8b0587a885 net/mlx5e: Preserve shared buffer capacity during headroom updates
When port buffer headroom changes, port_update_shared_buffer()
recalculates the shared buffer size and splits it in a 3:1 ratio
(lossy:lossless) - Currently, the calculation is:
lossless = shared / 4;
lossy = (shared / 4) * 3;

Meaning, the calculation dropped the remainder of shared % 4 due to
integer division, unintentionally reducing the total shared buffer
by up to three cells on each update. Over time, this could shrink
the buffer below usable size.

Fix it by changing the calculation to:
lossless = shared / 4;
lossy = shared - lossless;

This retains all buffer cells while still approximating the
intended 3:1 split, preventing capacity loss over time.

While at it, perform headroom calculations in units of cells rather than
in bytes for more accurate calculations avoiding extra divisions.

Fixes: a440030d89 ("net/mlx5e: Update shared buffer along with device buffer changes")
Signed-off-by: Armen Ratner <armeng@nvidia.com>
Signed-off-by: Maher Sanalla <msanalla@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Alexei Lazar <alazar@nvidia.com>
Signed-off-by: Mark Bloch <mbloch@nvidia.com>
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Link: https://patch.msgid.link/20250820133209.389065-9-mbloch@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2025-08-21 07:58:33 -07:00
..
mlx4 Networking changes for 6.17. 2025-07-30 08:58:55 -07:00
mlx5/core net/mlx5e: Preserve shared buffer capacity during headroom updates 2025-08-21 07:58:33 -07:00
mlxbf_gige mlxbf_gige: emit messages during open and probe failures 2025-07-07 18:34:46 -07:00
mlxfw net/mlxfw: Drop hard coded max FW flash image size 2025-01-17 19:01:07 -08:00
mlxsw mlxsw: spectrum: Forward packets with an IPv4 link-local source IP 2025-08-15 10:44:48 -07:00
Kconfig
Makefile