Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
[linux-2.6-microblaze.git] / drivers / net / ethernet / mellanox / mlx4 / en_netdev.c
index d4697be..7af75b6 100644 (file)
@@ -91,6 +91,7 @@ int mlx4_en_alloc_tx_queue_per_tc(struct net_device *dev, u8 tc)
        struct mlx4_en_dev *mdev = priv->mdev;
        struct mlx4_en_port_profile new_prof;
        struct mlx4_en_priv *tmp;
+       int total_count;
        int port_up = 0;
        int err = 0;
 
@@ -104,6 +105,14 @@ int mlx4_en_alloc_tx_queue_per_tc(struct net_device *dev, u8 tc)
                                      MLX4_EN_NUM_UP_HIGH;
        new_prof.tx_ring_num[TX] = new_prof.num_tx_rings_p_up *
                                   new_prof.num_up;
+       total_count = new_prof.tx_ring_num[TX] + new_prof.tx_ring_num[TX_XDP];
+       if (total_count > MAX_TX_RINGS) {
+               err = -EINVAL;
+               en_err(priv,
+                      "Total number of TX and XDP rings (%d) exceeds the maximum supported (%d)\n",
+                      total_count, MAX_TX_RINGS);
+               goto out;
+       }
        err = mlx4_en_try_alloc_resources(priv, tmp, &new_prof, true);
        if (err)
                goto out;