Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'net-mlx5e-enhance-dcbnl-get-set-maxrate-code'

Tariq Toukan says:

====================
net/mlx5e: Enhance DCBNL get/set maxrate code

This series by Gal introduces multiple small code quality improvements
for the DCBNL operations mlx5e_dcbnl_ieee_[gs]etmaxrate().

No functional change.
====================

Link: https://patch.msgid.link/1764498334-1327918-1-git-send-email-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+12 -11
+12 -11
drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
··· 31 31 */ 32 32 #include <linux/device.h> 33 33 #include <linux/netdevice.h> 34 + #include <linux/units.h> 34 35 #include "en.h" 35 36 #include "en/port.h" 36 37 #include "en/port_buffer.h" 37 38 38 39 #define MLX5E_MAX_BW_ALLOC 100 /* Max percentage of BW allocation */ 39 40 40 - #define MLX5E_100MB (100000) 41 - #define MLX5E_1GB (1000000) 41 + #define MLX5E_100MB_TO_KB (100 * MEGA / KILO) 42 + #define MLX5E_1GB_TO_KB (GIGA / KILO) 42 43 43 44 #define MLX5E_CEE_STATE_UP 1 44 45 #define MLX5E_CEE_STATE_DOWN 0 ··· 573 572 for (i = 0; i <= mlx5_max_tc(mdev); i++) { 574 573 switch (max_bw_unit[i]) { 575 574 case MLX5_100_MBPS_UNIT: 576 - maxrate->tc_maxrate[i] = max_bw_value[i] * MLX5E_100MB; 575 + maxrate->tc_maxrate[i] = max_bw_value[i] * MLX5E_100MB_TO_KB; 577 576 break; 578 577 case MLX5_GBPS_UNIT: 579 - maxrate->tc_maxrate[i] = max_bw_value[i] * MLX5E_1GB; 578 + maxrate->tc_maxrate[i] = max_bw_value[i] * MLX5E_1GB_TO_KB; 580 579 break; 581 580 case MLX5_BW_NO_LIMIT: 582 581 break; ··· 596 595 struct mlx5_core_dev *mdev = priv->mdev; 597 596 u8 max_bw_value[IEEE_8021QAZ_MAX_TCS]; 598 597 u8 max_bw_unit[IEEE_8021QAZ_MAX_TCS]; 599 - __u64 upper_limit_mbps; 600 - __u64 upper_limit_gbps; 598 + u64 upper_limit_100mbps; 599 + u64 upper_limit_gbps; 601 600 int i; 602 601 struct { 603 602 int scale; ··· 615 614 616 615 memset(max_bw_value, 0, sizeof(max_bw_value)); 617 616 memset(max_bw_unit, 0, sizeof(max_bw_unit)); 618 - upper_limit_mbps = 255 * MLX5E_100MB; 619 - upper_limit_gbps = 255 * MLX5E_1GB; 617 + upper_limit_100mbps = U8_MAX * MLX5E_100MB_TO_KB; 618 + upper_limit_gbps = U8_MAX * MLX5E_1GB_TO_KB; 620 619 621 620 for (i = 0; i <= mlx5_max_tc(mdev); i++) { 622 621 if (!maxrate->tc_maxrate[i]) { 623 622 max_bw_unit[i] = MLX5_BW_NO_LIMIT; 624 623 continue; 625 624 } 626 - if (maxrate->tc_maxrate[i] <= upper_limit_mbps) { 625 + if (maxrate->tc_maxrate[i] <= upper_limit_100mbps) { 627 626 max_bw_value[i] = div_u64(maxrate->tc_maxrate[i], 628 - MLX5E_100MB); 627 + MLX5E_100MB_TO_KB); 629 628 max_bw_value[i] = max_bw_value[i] ? max_bw_value[i] : 1; 630 629 max_bw_unit[i] = MLX5_100_MBPS_UNIT; 631 630 } else if (maxrate->tc_maxrate[i] <= upper_limit_gbps) { 632 631 max_bw_value[i] = div_u64(maxrate->tc_maxrate[i], 633 - MLX5E_1GB); 632 + MLX5E_1GB_TO_KB); 634 633 max_bw_unit[i] = MLX5_GBPS_UNIT; 635 634 } else { 636 635 netdev_err(netdev,