* [PATCH net-next 0/4] net/mlx5e: Enhance DCBNL get/set maxrate code
@ 2025-11-30 10:25 Tariq Toukan
2025-11-30 10:25 ` [PATCH net-next 1/4] net/mlx5e: Use u64 instead of __u64 in ieee_setmaxrate Tariq Toukan
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Tariq Toukan @ 2025-11-30 10:25 UTC (permalink / raw)
To: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Andrew Lunn,
David S. Miller
Cc: Saeed Mahameed, Tariq Toukan, Mark Bloch, Leon Romanovsky, netdev,
linux-rdma, linux-kernel, Gal Pressman, Moshe Shemesh,
Nimrod Oren, Danielle Costantino
Hi,
This series by Gal introduces multiple small code quality improvements
for the DCBNL operations mlx5e_dcbnl_ieee_[gs]etmaxrate().
No functional change.
Regards,
Tariq
Gal Pressman (4):
net/mlx5e: Use u64 instead of __u64 in ieee_setmaxrate
net/mlx5e: Rename upper_limit_mbps to upper_limit_100mbps
net/mlx5e: Use U8_MAX instead of hard coded magic number
net/mlx5e: Use standard unit definitions for bandwidth conversion
.../ethernet/mellanox/mlx5/core/en_dcbnl.c | 23 ++++++++++---------
1 file changed, 12 insertions(+), 11 deletions(-)
base-commit: 0177f0f07886e54e12c6f18fa58f63e63ddd3c58
--
2.31.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net-next 1/4] net/mlx5e: Use u64 instead of __u64 in ieee_setmaxrate
2025-11-30 10:25 [PATCH net-next 0/4] net/mlx5e: Enhance DCBNL get/set maxrate code Tariq Toukan
@ 2025-11-30 10:25 ` Tariq Toukan
2025-11-30 10:25 ` [PATCH net-next 2/4] net/mlx5e: Rename upper_limit_mbps to upper_limit_100mbps Tariq Toukan
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Tariq Toukan @ 2025-11-30 10:25 UTC (permalink / raw)
To: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Andrew Lunn,
David S. Miller
Cc: Saeed Mahameed, Tariq Toukan, Mark Bloch, Leon Romanovsky, netdev,
linux-rdma, linux-kernel, Gal Pressman, Moshe Shemesh,
Nimrod Oren, Danielle Costantino
From: Gal Pressman <gal@nvidia.com>
Change upper_limit_mbps/gbps from __u64 to u64 to follow kernel coding
conventions.
Signed-off-by: Gal Pressman <gal@nvidia.com>
Reviewed-by: Nimrod Oren <noren@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c b/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
index cf8f14ce4cd5..dd491fd8162b 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
@@ -595,8 +595,8 @@ static int mlx5e_dcbnl_ieee_setmaxrate(struct net_device *netdev,
struct mlx5_core_dev *mdev = priv->mdev;
u8 max_bw_value[IEEE_8021QAZ_MAX_TCS];
u8 max_bw_unit[IEEE_8021QAZ_MAX_TCS];
- __u64 upper_limit_mbps;
- __u64 upper_limit_gbps;
+ u64 upper_limit_mbps;
+ u64 upper_limit_gbps;
int i;
struct {
int scale;
--
2.31.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next 2/4] net/mlx5e: Rename upper_limit_mbps to upper_limit_100mbps
2025-11-30 10:25 [PATCH net-next 0/4] net/mlx5e: Enhance DCBNL get/set maxrate code Tariq Toukan
2025-11-30 10:25 ` [PATCH net-next 1/4] net/mlx5e: Use u64 instead of __u64 in ieee_setmaxrate Tariq Toukan
@ 2025-11-30 10:25 ` Tariq Toukan
2025-11-30 10:25 ` [PATCH net-next 3/4] net/mlx5e: Use U8_MAX instead of hard coded magic number Tariq Toukan
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Tariq Toukan @ 2025-11-30 10:25 UTC (permalink / raw)
To: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Andrew Lunn,
David S. Miller
Cc: Saeed Mahameed, Tariq Toukan, Mark Bloch, Leon Romanovsky, netdev,
linux-rdma, linux-kernel, Gal Pressman, Moshe Shemesh,
Nimrod Oren, Danielle Costantino
From: Gal Pressman <gal@nvidia.com>
Clarify that the limit represents the threshold for using 100 Mbps
units rather than a general Mbps limit.
Signed-off-by: Gal Pressman <gal@nvidia.com>
Reviewed-by: Nimrod Oren <noren@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c b/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
index dd491fd8162b..7127442f8003 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
@@ -595,7 +595,7 @@ static int mlx5e_dcbnl_ieee_setmaxrate(struct net_device *netdev,
struct mlx5_core_dev *mdev = priv->mdev;
u8 max_bw_value[IEEE_8021QAZ_MAX_TCS];
u8 max_bw_unit[IEEE_8021QAZ_MAX_TCS];
- u64 upper_limit_mbps;
+ u64 upper_limit_100mbps;
u64 upper_limit_gbps;
int i;
struct {
@@ -614,7 +614,7 @@ static int mlx5e_dcbnl_ieee_setmaxrate(struct net_device *netdev,
memset(max_bw_value, 0, sizeof(max_bw_value));
memset(max_bw_unit, 0, sizeof(max_bw_unit));
- upper_limit_mbps = 255 * MLX5E_100MB;
+ upper_limit_100mbps = 255 * MLX5E_100MB;
upper_limit_gbps = 255 * MLX5E_1GB;
for (i = 0; i <= mlx5_max_tc(mdev); i++) {
@@ -622,7 +622,7 @@ static int mlx5e_dcbnl_ieee_setmaxrate(struct net_device *netdev,
max_bw_unit[i] = MLX5_BW_NO_LIMIT;
continue;
}
- if (maxrate->tc_maxrate[i] <= upper_limit_mbps) {
+ if (maxrate->tc_maxrate[i] <= upper_limit_100mbps) {
max_bw_value[i] = div_u64(maxrate->tc_maxrate[i],
MLX5E_100MB);
max_bw_value[i] = max_bw_value[i] ? max_bw_value[i] : 1;
--
2.31.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next 3/4] net/mlx5e: Use U8_MAX instead of hard coded magic number
2025-11-30 10:25 [PATCH net-next 0/4] net/mlx5e: Enhance DCBNL get/set maxrate code Tariq Toukan
2025-11-30 10:25 ` [PATCH net-next 1/4] net/mlx5e: Use u64 instead of __u64 in ieee_setmaxrate Tariq Toukan
2025-11-30 10:25 ` [PATCH net-next 2/4] net/mlx5e: Rename upper_limit_mbps to upper_limit_100mbps Tariq Toukan
@ 2025-11-30 10:25 ` Tariq Toukan
2025-11-30 10:25 ` [PATCH net-next 4/4] net/mlx5e: Use standard unit definitions for bandwidth conversion Tariq Toukan
2025-12-01 23:10 ` [PATCH net-next 0/4] net/mlx5e: Enhance DCBNL get/set maxrate code patchwork-bot+netdevbpf
4 siblings, 0 replies; 6+ messages in thread
From: Tariq Toukan @ 2025-11-30 10:25 UTC (permalink / raw)
To: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Andrew Lunn,
David S. Miller
Cc: Saeed Mahameed, Tariq Toukan, Mark Bloch, Leon Romanovsky, netdev,
linux-rdma, linux-kernel, Gal Pressman, Moshe Shemesh,
Nimrod Oren, Danielle Costantino
From: Gal Pressman <gal@nvidia.com>
Replace hard coded 255 magic number with U8_MAX (the register field is 8
bits).
Signed-off-by: Gal Pressman <gal@nvidia.com>
Reviewed-by: Nimrod Oren <noren@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c b/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
index 7127442f8003..79f9d43b09b3 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
@@ -614,8 +614,8 @@ static int mlx5e_dcbnl_ieee_setmaxrate(struct net_device *netdev,
memset(max_bw_value, 0, sizeof(max_bw_value));
memset(max_bw_unit, 0, sizeof(max_bw_unit));
- upper_limit_100mbps = 255 * MLX5E_100MB;
- upper_limit_gbps = 255 * MLX5E_1GB;
+ upper_limit_100mbps = U8_MAX * MLX5E_100MB;
+ upper_limit_gbps = U8_MAX * MLX5E_1GB;
for (i = 0; i <= mlx5_max_tc(mdev); i++) {
if (!maxrate->tc_maxrate[i]) {
--
2.31.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next 4/4] net/mlx5e: Use standard unit definitions for bandwidth conversion
2025-11-30 10:25 [PATCH net-next 0/4] net/mlx5e: Enhance DCBNL get/set maxrate code Tariq Toukan
` (2 preceding siblings ...)
2025-11-30 10:25 ` [PATCH net-next 3/4] net/mlx5e: Use U8_MAX instead of hard coded magic number Tariq Toukan
@ 2025-11-30 10:25 ` Tariq Toukan
2025-12-01 23:10 ` [PATCH net-next 0/4] net/mlx5e: Enhance DCBNL get/set maxrate code patchwork-bot+netdevbpf
4 siblings, 0 replies; 6+ messages in thread
From: Tariq Toukan @ 2025-11-30 10:25 UTC (permalink / raw)
To: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Andrew Lunn,
David S. Miller
Cc: Saeed Mahameed, Tariq Toukan, Mark Bloch, Leon Romanovsky, netdev,
linux-rdma, linux-kernel, Gal Pressman, Moshe Shemesh,
Nimrod Oren, Danielle Costantino
From: Gal Pressman <gal@nvidia.com>
MLX5E_100MB and MLX5E_1GB defines are confusing, MLX5E_100MB is not
equal to 100 * MEGA, and MLX5E_1GB is not equal to one GIGA, as they
hide the Kbps rate conversion required for ieee_maxrate.
Replace hardcoded bandwidth conversion values with standard unit
definitions from linux/units.h. Rename MLX5E_100MB/MLX5E_1GB to
MLX5E_100MB_TO_KB/MLX5E_1GB_TO_KB to clarify these are conversion
factors to Kbps, not absolute bandwidth values.
Signed-off-by: Gal Pressman <gal@nvidia.com>
Reviewed-by: Nimrod Oren <noren@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
.../net/ethernet/mellanox/mlx5/core/en_dcbnl.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c b/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
index 79f9d43b09b3..fddf7c207f8e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
@@ -31,14 +31,15 @@
*/
#include <linux/device.h>
#include <linux/netdevice.h>
+#include <linux/units.h>
#include "en.h"
#include "en/port.h"
#include "en/port_buffer.h"
#define MLX5E_MAX_BW_ALLOC 100 /* Max percentage of BW allocation */
-#define MLX5E_100MB (100000)
-#define MLX5E_1GB (1000000)
+#define MLX5E_100MB_TO_KB (100 * MEGA / KILO)
+#define MLX5E_1GB_TO_KB (GIGA / KILO)
#define MLX5E_CEE_STATE_UP 1
#define MLX5E_CEE_STATE_DOWN 0
@@ -572,10 +573,10 @@ static int mlx5e_dcbnl_ieee_getmaxrate(struct net_device *netdev,
for (i = 0; i <= mlx5_max_tc(mdev); i++) {
switch (max_bw_unit[i]) {
case MLX5_100_MBPS_UNIT:
- maxrate->tc_maxrate[i] = max_bw_value[i] * MLX5E_100MB;
+ maxrate->tc_maxrate[i] = max_bw_value[i] * MLX5E_100MB_TO_KB;
break;
case MLX5_GBPS_UNIT:
- maxrate->tc_maxrate[i] = max_bw_value[i] * MLX5E_1GB;
+ maxrate->tc_maxrate[i] = max_bw_value[i] * MLX5E_1GB_TO_KB;
break;
case MLX5_BW_NO_LIMIT:
break;
@@ -614,8 +615,8 @@ static int mlx5e_dcbnl_ieee_setmaxrate(struct net_device *netdev,
memset(max_bw_value, 0, sizeof(max_bw_value));
memset(max_bw_unit, 0, sizeof(max_bw_unit));
- upper_limit_100mbps = U8_MAX * MLX5E_100MB;
- upper_limit_gbps = U8_MAX * MLX5E_1GB;
+ upper_limit_100mbps = U8_MAX * MLX5E_100MB_TO_KB;
+ upper_limit_gbps = U8_MAX * MLX5E_1GB_TO_KB;
for (i = 0; i <= mlx5_max_tc(mdev); i++) {
if (!maxrate->tc_maxrate[i]) {
@@ -624,12 +625,12 @@ static int mlx5e_dcbnl_ieee_setmaxrate(struct net_device *netdev,
}
if (maxrate->tc_maxrate[i] <= upper_limit_100mbps) {
max_bw_value[i] = div_u64(maxrate->tc_maxrate[i],
- MLX5E_100MB);
+ MLX5E_100MB_TO_KB);
max_bw_value[i] = max_bw_value[i] ? max_bw_value[i] : 1;
max_bw_unit[i] = MLX5_100_MBPS_UNIT;
} else if (maxrate->tc_maxrate[i] <= upper_limit_gbps) {
max_bw_value[i] = div_u64(maxrate->tc_maxrate[i],
- MLX5E_1GB);
+ MLX5E_1GB_TO_KB);
max_bw_unit[i] = MLX5_GBPS_UNIT;
} else {
netdev_err(netdev,
--
2.31.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net-next 0/4] net/mlx5e: Enhance DCBNL get/set maxrate code
2025-11-30 10:25 [PATCH net-next 0/4] net/mlx5e: Enhance DCBNL get/set maxrate code Tariq Toukan
` (3 preceding siblings ...)
2025-11-30 10:25 ` [PATCH net-next 4/4] net/mlx5e: Use standard unit definitions for bandwidth conversion Tariq Toukan
@ 2025-12-01 23:10 ` patchwork-bot+netdevbpf
4 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-12-01 23:10 UTC (permalink / raw)
To: Tariq Toukan
Cc: edumazet, kuba, pabeni, andrew+netdev, davem, saeedm, mbloch,
leon, netdev, linux-rdma, linux-kernel, gal, moshe, noren,
dcostantino
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Sun, 30 Nov 2025 12:25:30 +0200 you wrote:
> Hi,
>
> This series by Gal introduces multiple small code quality improvements
> for the DCBNL operations mlx5e_dcbnl_ieee_[gs]etmaxrate().
>
> No functional change.
>
> [...]
Here is the summary with links:
- [net-next,1/4] net/mlx5e: Use u64 instead of __u64 in ieee_setmaxrate
https://git.kernel.org/netdev/net-next/c/e1de33c377b6
- [net-next,2/4] net/mlx5e: Rename upper_limit_mbps to upper_limit_100mbps
https://git.kernel.org/netdev/net-next/c/e1098bb02f2d
- [net-next,3/4] net/mlx5e: Use U8_MAX instead of hard coded magic number
https://git.kernel.org/netdev/net-next/c/53f7a7712851
- [net-next,4/4] net/mlx5e: Use standard unit definitions for bandwidth conversion
https://git.kernel.org/netdev/net-next/c/87a5112bfc40
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-12-01 23:13 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-30 10:25 [PATCH net-next 0/4] net/mlx5e: Enhance DCBNL get/set maxrate code Tariq Toukan
2025-11-30 10:25 ` [PATCH net-next 1/4] net/mlx5e: Use u64 instead of __u64 in ieee_setmaxrate Tariq Toukan
2025-11-30 10:25 ` [PATCH net-next 2/4] net/mlx5e: Rename upper_limit_mbps to upper_limit_100mbps Tariq Toukan
2025-11-30 10:25 ` [PATCH net-next 3/4] net/mlx5e: Use U8_MAX instead of hard coded magic number Tariq Toukan
2025-11-30 10:25 ` [PATCH net-next 4/4] net/mlx5e: Use standard unit definitions for bandwidth conversion Tariq Toukan
2025-12-01 23:10 ` [PATCH net-next 0/4] net/mlx5e: Enhance DCBNL get/set maxrate code patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox