Merge ath-next from ath.git
[firefly-linux-kernel-4.4.55.git] / drivers / infiniband / hw / mlx4 / main.c
index cc64400d41ace3005c8a878b4c6811b0506726f9..024b0f745035caee392ea24e3a75b1e75fe6a1c9 100644 (file)
@@ -1090,7 +1090,7 @@ static int __mlx4_ib_create_flow(struct ib_qp *qp, struct ib_flow_attr *flow_att
 
        ret = mlx4_cmd_imm(mdev->dev, mailbox->dma, reg_id, size >> 2, 0,
                           MLX4_QP_FLOW_STEERING_ATTACH, MLX4_CMD_TIME_CLASS_A,
-                          MLX4_CMD_NATIVE);
+                          MLX4_CMD_WRAPPED);
        if (ret == -ENOMEM)
                pr_err("mcg table is full. Fail to register network rule.\n");
        else if (ret == -ENXIO)
@@ -1107,7 +1107,7 @@ static int __mlx4_ib_destroy_flow(struct mlx4_dev *dev, u64 reg_id)
        int err;
        err = mlx4_cmd(dev, reg_id, 0, 0,
                       MLX4_QP_FLOW_STEERING_DETACH, MLX4_CMD_TIME_CLASS_A,
-                      MLX4_CMD_NATIVE);
+                      MLX4_CMD_WRAPPED);
        if (err)
                pr_err("Fail to detach network rule. registration id = 0x%llx\n",
                       reg_id);
@@ -2041,77 +2041,52 @@ static void init_pkeys(struct mlx4_ib_dev *ibdev)
 
 static void mlx4_ib_alloc_eqs(struct mlx4_dev *dev, struct mlx4_ib_dev *ibdev)
 {
-       char name[80];
-       int eq_per_port = 0;
-       int added_eqs = 0;
-       int total_eqs = 0;
-       int i, j, eq;
-
-       /* Legacy mode or comp_pool is not large enough */
-       if (dev->caps.comp_pool == 0 ||
-           dev->caps.num_ports > dev->caps.comp_pool)
-               return;
-
-       eq_per_port = dev->caps.comp_pool / dev->caps.num_ports;
-
-       /* Init eq table */
-       added_eqs = 0;
-       mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_IB)
-               added_eqs += eq_per_port;
-
-       total_eqs = dev->caps.num_comp_vectors + added_eqs;
+       int i, j, eq = 0, total_eqs = 0;
 
-       ibdev->eq_table = kzalloc(total_eqs * sizeof(int), GFP_KERNEL);
+       ibdev->eq_table = kcalloc(dev->caps.num_comp_vectors,
+                                 sizeof(ibdev->eq_table[0]), GFP_KERNEL);
        if (!ibdev->eq_table)
                return;
 
-       ibdev->eq_added = added_eqs;
-
-       eq = 0;
-       mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_IB) {
-               for (j = 0; j < eq_per_port; j++) {
-                       snprintf(name, sizeof(name), "mlx4-ib-%d-%d@%s",
-                                i, j, dev->persist->pdev->bus->name);
-                       /* Set IRQ for specific name (per ring) */
-                       if (mlx4_assign_eq(dev, name, NULL,
-                                          &ibdev->eq_table[eq])) {
-                               /* Use legacy (same as mlx4_en driver) */
-                               pr_warn("Can't allocate EQ %d; reverting to legacy\n", eq);
-                               ibdev->eq_table[eq] =
-                                       (eq % dev->caps.num_comp_vectors);
-                       }
-                       eq++;
+       for (i = 1; i <= dev->caps.num_ports; i++) {
+               for (j = 0; j < mlx4_get_eqs_per_port(dev, i);
+                    j++, total_eqs++) {
+                       if (i > 1 &&  mlx4_is_eq_shared(dev, total_eqs))
+                               continue;
+                       ibdev->eq_table[eq] = total_eqs;
+                       if (!mlx4_assign_eq(dev, i,
+                                           &ibdev->eq_table[eq]))
+                               eq++;
+                       else
+                               ibdev->eq_table[eq] = -1;
                }
        }
 
-       /* Fill the reset of the vector with legacy EQ */
-       for (i = 0, eq = added_eqs; i < dev->caps.num_comp_vectors; i++)
-               ibdev->eq_table[eq++] = i;
+       for (i = eq; i < dev->caps.num_comp_vectors;
+            ibdev->eq_table[i++] = -1)
+               ;
 
        /* Advertise the new number of EQs to clients */
-       ibdev->ib_dev.num_comp_vectors = total_eqs;
+       ibdev->ib_dev.num_comp_vectors = eq;
 }
 
 static void mlx4_ib_free_eqs(struct mlx4_dev *dev, struct mlx4_ib_dev *ibdev)
 {
        int i;
+       int total_eqs = ibdev->ib_dev.num_comp_vectors;
 
-       /* no additional eqs were added */
+       /* no eqs were allocated */
        if (!ibdev->eq_table)
                return;
 
        /* Reset the advertised EQ number */
-       ibdev->ib_dev.num_comp_vectors = dev->caps.num_comp_vectors;
+       ibdev->ib_dev.num_comp_vectors = 0;
 
-       /* Free only the added eqs */
-       for (i = 0; i < ibdev->eq_added; i++) {
-               /* Don't free legacy eqs if used */
-               if (ibdev->eq_table[i] <= dev->caps.num_comp_vectors)
-                       continue;
+       for (i = 0; i < total_eqs; i++)
                mlx4_release_eq(dev, ibdev->eq_table[i]);
-       }
 
        kfree(ibdev->eq_table);
+       ibdev->eq_table = NULL;
 }
 
 static void *mlx4_ib_add(struct mlx4_dev *dev)