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

Configure Feed

Select the types of activity you want to include in your feed.

net/mlx5e: Extend TC max ratelimit using max_bw_value_msb

The per-TC rate limit was restricted to 255 Gbps due to the 8-bit
max_bw_value field in the QETC register.
This limit is insufficient for newer, higher-bandwidth NICs.

Extend the rate limit by using the full 16-bit max_bw_value field.
This allows the finer 100Mbps granularity to be used for rates up to
~6.5 Tbps, instead of switching to 1Gbps granularity at higher rates.

The extended range is only used when the device advertises support
via the qetcr_qshr_max_bw_val_msb capability bit in the QCAM register.

Signed-off-by: Alexei Lazar <alazar@nvidia.com>
Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
Reviewed-by: Gal Pressman <gal@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20260203073021.1710806-2-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Alexei Lazar and committed by
Jakub Kicinski
3e5aa52b 23fb09db

+44 -34
+4
drivers/net/ethernet/mellanox/mlx5/core/en/dcbnl.h
··· 29 29 u32 cable_len; 30 30 u32 xoff; 31 31 u16 port_buff_cell_sz; 32 + 33 + /* Upper limit for 100Mbps and 1Gbps in Kbps units */ 34 + u64 upper_limit_100mbps; 35 + u64 upper_limit_gbps; 32 36 }; 33 37 34 38 #define MLX5E_MAX_DSCP (64)
+36 -30
drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
··· 58 58 MLX5_DCB_CHG_NO_RESET, 59 59 }; 60 60 61 + static const struct { 62 + int scale; 63 + const char *units_str; 64 + } mlx5e_bw_units[] = { 65 + [MLX5_100_MBPS_UNIT] = { 66 + .scale = 100, 67 + .units_str = "Mbps", 68 + }, 69 + [MLX5_GBPS_UNIT] = { 70 + .scale = 1, 71 + .units_str = "Gbps", 72 + }, 73 + }; 74 + 61 75 #define MLX5_DSCP_SUPPORTED(mdev) (MLX5_CAP_GEN(mdev, qcam_reg) && \ 62 76 MLX5_CAP_QCAM_REG(mdev, qpts) && \ 63 77 MLX5_CAP_QCAM_REG(mdev, qpdpm)) ··· 573 559 { 574 560 struct mlx5e_priv *priv = netdev_priv(netdev); 575 561 struct mlx5_core_dev *mdev = priv->mdev; 576 - u8 max_bw_value[IEEE_8021QAZ_MAX_TCS]; 562 + u16 max_bw_value[IEEE_8021QAZ_MAX_TCS]; 577 563 u8 max_bw_unit[IEEE_8021QAZ_MAX_TCS]; 578 564 int err; 579 565 int i; ··· 608 594 { 609 595 struct mlx5e_priv *priv = netdev_priv(netdev); 610 596 struct mlx5_core_dev *mdev = priv->mdev; 611 - u8 max_bw_value[IEEE_8021QAZ_MAX_TCS]; 597 + u16 max_bw_value[IEEE_8021QAZ_MAX_TCS]; 612 598 u8 max_bw_unit[IEEE_8021QAZ_MAX_TCS]; 613 - u64 upper_limit_100mbps; 614 - u64 upper_limit_gbps; 615 599 int i; 616 - struct { 617 - int scale; 618 - const char *units_str; 619 - } units[] = { 620 - [MLX5_100_MBPS_UNIT] = { 621 - .scale = 100, 622 - .units_str = "Mbps", 623 - }, 624 - [MLX5_GBPS_UNIT] = { 625 - .scale = 1, 626 - .units_str = "Gbps", 627 - }, 628 - }; 629 600 630 601 memset(max_bw_value, 0, sizeof(max_bw_value)); 631 602 memset(max_bw_unit, 0, sizeof(max_bw_unit)); 632 - upper_limit_100mbps = U8_MAX * MLX5E_100MB_TO_KB; 633 - upper_limit_gbps = U8_MAX * MLX5E_1GB_TO_KB; 634 603 635 604 for (i = 0; i <= mlx5_max_tc(mdev); i++) { 636 - if (!maxrate->tc_maxrate[i]) { 605 + u64 rate = maxrate->tc_maxrate[i]; 606 + 607 + if (!rate) { 637 608 max_bw_unit[i] = MLX5_BW_NO_LIMIT; 638 609 continue; 639 610 } 640 - if (maxrate->tc_maxrate[i] <= upper_limit_100mbps) { 641 - max_bw_value[i] = div_u64(maxrate->tc_maxrate[i], 642 - MLX5E_100MB_TO_KB); 611 + if (rate <= priv->dcbx.upper_limit_100mbps) { 612 + max_bw_value[i] = div_u64(rate, MLX5E_100MB_TO_KB); 643 613 max_bw_value[i] = max_bw_value[i] ? max_bw_value[i] : 1; 644 614 max_bw_unit[i] = MLX5_100_MBPS_UNIT; 645 - } else if (maxrate->tc_maxrate[i] <= upper_limit_gbps) { 646 - max_bw_value[i] = div_u64(maxrate->tc_maxrate[i], 647 - MLX5E_1GB_TO_KB); 615 + } else if (rate <= priv->dcbx.upper_limit_gbps) { 616 + max_bw_value[i] = div_u64(rate, MLX5E_1GB_TO_KB); 648 617 max_bw_unit[i] = MLX5_GBPS_UNIT; 649 618 } else { 650 619 netdev_err(netdev, 651 620 "tc_%d maxrate %llu Kbps exceeds limit %llu\n", 652 - i, maxrate->tc_maxrate[i], 653 - upper_limit_gbps); 621 + i, rate, priv->dcbx.upper_limit_gbps); 654 622 return -EINVAL; 655 623 } 656 624 } 657 625 658 626 for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) { 627 + u8 unit = max_bw_unit[i]; 628 + 659 629 netdev_dbg(netdev, "%s: tc_%d <=> max_bw %u %s\n", __func__, i, 660 - max_bw_value[i] * units[max_bw_unit[i]].scale, 661 - units[max_bw_unit[i]].units_str); 630 + max_bw_value[i] * mlx5e_bw_units[unit].scale, 631 + mlx5e_bw_units[unit].units_str); 662 632 } 663 633 664 634 return mlx5_modify_port_ets_rate_limit(mdev, max_bw_value, max_bw_unit); ··· 1266 1268 void mlx5e_dcbnl_initialize(struct mlx5e_priv *priv) 1267 1269 { 1268 1270 struct mlx5e_dcbx *dcbx = &priv->dcbx; 1271 + bool max_bw_msb_supported; 1272 + u16 type_max; 1269 1273 1270 1274 mlx5e_trust_initialize(priv); 1271 1275 ··· 1284 1284 1285 1285 priv->dcbx.port_buff_cell_sz = mlx5e_query_port_buffers_cell_size(priv); 1286 1286 priv->dcbx.cable_len = MLX5E_DEFAULT_CABLE_LEN; 1287 + 1288 + max_bw_msb_supported = MLX5_CAP_QCAM_FEATURE(priv->mdev, 1289 + qetcr_qshr_max_bw_val_msb); 1290 + type_max = max_bw_msb_supported ? U16_MAX : U8_MAX; 1291 + priv->dcbx.upper_limit_100mbps = type_max * MLX5E_100MB_TO_KB; 1292 + priv->dcbx.upper_limit_gbps = type_max * MLX5E_1GB_TO_KB; 1287 1293 1288 1294 mlx5e_ets_init(priv); 1289 1295 }
+2 -2
drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
··· 345 345 int mlx5_query_port_tc_bw_alloc(struct mlx5_core_dev *mdev, 346 346 u8 tc, u8 *bw_pct); 347 347 int mlx5_modify_port_ets_rate_limit(struct mlx5_core_dev *mdev, 348 - u8 *max_bw_value, 348 + u16 *max_bw_value, 349 349 u8 *max_bw_unit); 350 350 int mlx5_query_port_ets_rate_limit(struct mlx5_core_dev *mdev, 351 - u8 *max_bw_value, 351 + u16 *max_bw_value, 352 352 u8 *max_bw_unit); 353 353 int mlx5_set_port_wol(struct mlx5_core_dev *mdev, u8 wol_mode); 354 354 int mlx5_query_port_wol(struct mlx5_core_dev *mdev, u8 *wol_mode);
+2 -2
drivers/net/ethernet/mellanox/mlx5/core/port.c
··· 773 773 } 774 774 775 775 int mlx5_modify_port_ets_rate_limit(struct mlx5_core_dev *mdev, 776 - u8 *max_bw_value, 776 + u16 *max_bw_value, 777 777 u8 *max_bw_units) 778 778 { 779 779 u32 in[MLX5_ST_SZ_DW(qetc_reg)] = {0}; ··· 796 796 } 797 797 798 798 int mlx5_query_port_ets_rate_limit(struct mlx5_core_dev *mdev, 799 - u8 *max_bw_value, 799 + u16 *max_bw_value, 800 800 u8 *max_bw_units) 801 801 { 802 802 u32 out[MLX5_ST_SZ_DW(qetc_reg)];