mlx4: In RoCE allow guests to have multiple GIDS
[cascardo/linux.git] / drivers / net / ethernet / mellanox / mlx4 / main.c
index d711158..4c441aa 100644 (file)
@@ -41,7 +41,6 @@
 #include <linux/slab.h>
 #include <linux/io-mapping.h>
 #include <linux/delay.h>
-#include <linux/netdevice.h>
 #include <linux/kmod.h>
 
 #include <linux/mlx4/device.h>
@@ -1463,7 +1462,11 @@ static void mlx4_parav_master_pf_caps(struct mlx4_dev *dev)
        int i;
 
        for (i = 1; i <= dev->caps.num_ports; i++) {
-               dev->caps.gid_table_len[i] = 1;
+               if (dev->caps.port_type[i] == MLX4_PORT_TYPE_ETH)
+                       dev->caps.gid_table_len[i] =
+                               mlx4_get_slave_num_gids(dev, 0);
+               else
+                       dev->caps.gid_table_len[i] = 1;
                dev->caps.pkey_table_len[i] =
                        dev->phys_caps.pkey_phys_table_len[i] - 1;
        }
@@ -1974,9 +1977,8 @@ static void mlx4_enable_msi_x(struct mlx4_dev *dev)
        struct mlx4_priv *priv = mlx4_priv(dev);
        struct msix_entry *entries;
        int nreq = min_t(int, dev->caps.num_ports *
-                        min_t(int, netif_get_num_default_rss_queues() + 1,
+                        min_t(int, num_online_cpus() + 1,
                               MAX_MSIX_P_PORT) + MSIX_LEGACY_SZ, MAX_MSIX);
-       int err;
        int i;
 
        if (msi_x) {
@@ -1990,23 +1992,13 @@ static void mlx4_enable_msi_x(struct mlx4_dev *dev)
                for (i = 0; i < nreq; ++i)
                        entries[i].entry = i;
 
-       retry:
-               err = pci_enable_msix(dev->pdev, entries, nreq);
-               if (err) {
-                       /* Try again if at least 2 vectors are available */
-                       if (err > 1) {
-                               mlx4_info(dev, "Requested %d vectors, "
-                                         "but only %d MSI-X vectors available, "
-                                         "trying again\n", nreq, err);
-                               nreq = err;
-                               goto retry;
-                       }
+               nreq = pci_enable_msix_range(dev->pdev, entries, 2, nreq);
+
+               if (nreq < 0) {
                        kfree(entries);
                        goto no_msi;
-               }
-
-               if (nreq <
-                   MSIX_LEGACY_SZ + dev->caps.num_ports * MIN_MSIX_P_PORT) {
+               } else if (nreq < MSIX_LEGACY_SZ +
+                                 dev->caps.num_ports * MIN_MSIX_P_PORT) {
                        /*Working in legacy mode , all EQ's shared*/
                        dev->caps.comp_pool           = 0;
                        dev->caps.num_comp_vectors = nreq - 1;