Skip to content

Commit c10e4fc

Browse files
ogerlitzdavem330
authored andcommitted
net/mlx4_en: Add tx queue maxrate support
Add ndo_set_tx_maxrate support. To support per tx queue maxrate limit, we use the update-qp firmware command to do run-time rate setting for the qp that serves this tx ring. Signed-off-by: Or Gerlitz <[email protected]> Signed-off-by: Ido Shamay <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent fc31e25 commit c10e4fc

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

drivers/net/ethernet/mellanox/mlx4/en_netdev.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2379,6 +2379,33 @@ static netdev_features_t mlx4_en_features_check(struct sk_buff *skb,
23792379
}
23802380
#endif
23812381

2382+
int mlx4_en_set_tx_maxrate(struct net_device *dev, int queue_index, u32 maxrate)
2383+
{
2384+
struct mlx4_en_priv *priv = netdev_priv(dev);
2385+
struct mlx4_en_tx_ring *tx_ring = priv->tx_ring[queue_index];
2386+
struct mlx4_update_qp_params params;
2387+
int err;
2388+
2389+
if (!(priv->mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_QP_RATE_LIMIT))
2390+
return -EOPNOTSUPP;
2391+
2392+
/* rate provided to us in Mbs, check if it fits into 12 bits, if not use Gbs */
2393+
if (maxrate >> 12) {
2394+
params.rate_unit = MLX4_QP_RATE_LIMIT_GBS;
2395+
params.rate_val = maxrate / 1000;
2396+
} else if (maxrate) {
2397+
params.rate_unit = MLX4_QP_RATE_LIMIT_MBS;
2398+
params.rate_val = maxrate;
2399+
} else { /* zero serves to revoke the QP rate-limitation */
2400+
params.rate_unit = 0;
2401+
params.rate_val = 0;
2402+
}
2403+
2404+
err = mlx4_update_qp(priv->mdev->dev, tx_ring->qpn, MLX4_UPDATE_QP_RATE_LIMIT,
2405+
&params);
2406+
return err;
2407+
}
2408+
23822409
static const struct net_device_ops mlx4_netdev_ops = {
23832410
.ndo_open = mlx4_en_open,
23842411
.ndo_stop = mlx4_en_close,
@@ -2410,6 +2437,7 @@ static const struct net_device_ops mlx4_netdev_ops = {
24102437
.ndo_del_vxlan_port = mlx4_en_del_vxlan_port,
24112438
.ndo_features_check = mlx4_en_features_check,
24122439
#endif
2440+
.ndo_set_tx_maxrate = mlx4_en_set_tx_maxrate,
24132441
};
24142442

24152443
static const struct net_device_ops mlx4_netdev_ops_master = {
@@ -2444,6 +2472,7 @@ static const struct net_device_ops mlx4_netdev_ops_master = {
24442472
.ndo_del_vxlan_port = mlx4_en_del_vxlan_port,
24452473
.ndo_features_check = mlx4_en_features_check,
24462474
#endif
2475+
.ndo_set_tx_maxrate = mlx4_en_set_tx_maxrate,
24472476
};
24482477

24492478
struct mlx4_en_bond {

0 commit comments

Comments
 (0)