diff options
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c index c59ed925adaf..d8dc3f985c2b 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c | |||
@@ -2379,6 +2379,33 @@ static netdev_features_t mlx4_en_features_check(struct sk_buff *skb, | |||
2379 | } | 2379 | } |
2380 | #endif | 2380 | #endif |
2381 | 2381 | ||
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 | ¶ms); | ||
2406 | return err; | ||
2407 | } | ||
2408 | |||
2382 | static const struct net_device_ops mlx4_netdev_ops = { | 2409 | static const struct net_device_ops mlx4_netdev_ops = { |
2383 | .ndo_open = mlx4_en_open, | 2410 | .ndo_open = mlx4_en_open, |
2384 | .ndo_stop = mlx4_en_close, | 2411 | .ndo_stop = mlx4_en_close, |
@@ -2410,6 +2437,7 @@ static const struct net_device_ops mlx4_netdev_ops = { | |||
2410 | .ndo_del_vxlan_port = mlx4_en_del_vxlan_port, | 2437 | .ndo_del_vxlan_port = mlx4_en_del_vxlan_port, |
2411 | .ndo_features_check = mlx4_en_features_check, | 2438 | .ndo_features_check = mlx4_en_features_check, |
2412 | #endif | 2439 | #endif |
2440 | .ndo_set_tx_maxrate = mlx4_en_set_tx_maxrate, | ||
2413 | }; | 2441 | }; |
2414 | 2442 | ||
2415 | static const struct net_device_ops mlx4_netdev_ops_master = { | 2443 | static const struct net_device_ops mlx4_netdev_ops_master = { |
@@ -2444,6 +2472,7 @@ static const struct net_device_ops mlx4_netdev_ops_master = { | |||
2444 | .ndo_del_vxlan_port = mlx4_en_del_vxlan_port, | 2472 | .ndo_del_vxlan_port = mlx4_en_del_vxlan_port, |
2445 | .ndo_features_check = mlx4_en_features_check, | 2473 | .ndo_features_check = mlx4_en_features_check, |
2446 | #endif | 2474 | #endif |
2475 | .ndo_set_tx_maxrate = mlx4_en_set_tx_maxrate, | ||
2447 | }; | 2476 | }; |
2448 | 2477 | ||
2449 | struct mlx4_en_bond { | 2478 | struct mlx4_en_bond { |