]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/net/ethernet/mellanox/mlx4/main.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[karo-tx-linux.git] / drivers / net / ethernet / mellanox / mlx4 / main.c
index e717091734d016fdb4e3d5c612a497d12e887457..48d0e90194cb19d2a322990425b478f9e178b623 100644 (file)
@@ -218,6 +218,10 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
        for (i = 1; i <= dev->caps.num_ports; ++i) {
                dev->caps.vl_cap[i]         = dev_cap->max_vl[i];
                dev->caps.ib_mtu_cap[i]     = dev_cap->ib_mtu[i];
+               dev->phys_caps.gid_phys_table_len[i]  = dev_cap->max_gids[i];
+               dev->phys_caps.pkey_phys_table_len[i] = dev_cap->max_pkeys[i];
+               /* set gid and pkey table operating lengths by default
+                * to non-sriov values */
                dev->caps.gid_table_len[i]  = dev_cap->max_gids[i];
                dev->caps.pkey_table_len[i] = dev_cap->max_pkeys[i];
                dev->caps.port_width_cap[i] = dev_cap->max_port_width[i];
@@ -312,29 +316,19 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
                        /* if only ETH is supported - assign ETH */
                        if (dev->caps.supported_type[i] == MLX4_PORT_TYPE_ETH)
                                dev->caps.port_type[i] = MLX4_PORT_TYPE_ETH;
-                       /* if only IB is supported,
-                        * assign IB only if SRIOV is off*/
+                       /* if only IB is supported, assign IB */
                        else if (dev->caps.supported_type[i] ==
-                                MLX4_PORT_TYPE_IB) {
-                               if (dev->flags & MLX4_FLAG_SRIOV)
-                                       dev->caps.port_type[i] =
-                                               MLX4_PORT_TYPE_NONE;
-                               else
-                                       dev->caps.port_type[i] =
-                                               MLX4_PORT_TYPE_IB;
-                       /* if IB and ETH are supported,
-                        * first of all check if SRIOV is on */
-                       } else if (dev->flags & MLX4_FLAG_SRIOV)
-                               dev->caps.port_type[i] = MLX4_PORT_TYPE_ETH;
+                                MLX4_PORT_TYPE_IB)
+                               dev->caps.port_type[i] = MLX4_PORT_TYPE_IB;
                        else {
-                               /* In non-SRIOV mode, we set the port type
-                                * according to user selection of port type,
-                                * if usere selected none, take the FW hint */
-                               if (port_type_array[i-1] == MLX4_PORT_TYPE_NONE)
+                               /* if IB and ETH are supported, we set the port
+                                * type according to user selection of port type;
+                                * if user selected none, take the FW hint */
+                               if (port_type_array[i - 1] == MLX4_PORT_TYPE_NONE)
                                        dev->caps.port_type[i] = dev->caps.suggested_type[i] ?
                                                MLX4_PORT_TYPE_ETH : MLX4_PORT_TYPE_IB;
                                else
-                                       dev->caps.port_type[i] = port_type_array[i-1];
+                                       dev->caps.port_type[i] = port_type_array[i - 1];
                        }
                }
                /*
@@ -415,6 +409,23 @@ static int mlx4_how_many_lives_vf(struct mlx4_dev *dev)
        return ret;
 }
 
+int mlx4_get_parav_qkey(struct mlx4_dev *dev, u32 qpn, u32 *qkey)
+{
+       u32 qk = MLX4_RESERVED_QKEY_BASE;
+       if (qpn >= dev->caps.base_tunnel_sqpn + 8 * MLX4_MFUNC_MAX ||
+           qpn < dev->caps.sqp_start)
+               return -EINVAL;
+
+       if (qpn >= dev->caps.base_tunnel_sqpn)
+               /* tunnel qp */
+               qk += qpn - dev->caps.base_tunnel_sqpn;
+       else
+               qk += qpn - dev->caps.sqp_start;
+       *qkey = qk;
+       return 0;
+}
+EXPORT_SYMBOL(mlx4_get_parav_qkey);
+
 int mlx4_is_slave_active(struct mlx4_dev *dev, int slave)
 {
        struct mlx4_priv *priv = mlx4_priv(dev);
@@ -515,8 +526,13 @@ static int mlx4_slave_cap(struct mlx4_dev *dev)
                return -ENODEV;
        }
 
-       for (i = 1; i <= dev->caps.num_ports; ++i)
+       for (i = 1; i <= dev->caps.num_ports; ++i) {
                dev->caps.port_mask[i] = dev->caps.port_type[i];
+               if (mlx4_get_slave_pkey_gid_tbl_len(dev, i,
+                                                   &dev->caps.gid_table_len[i],
+                                                   &dev->caps.pkey_table_len[i]))
+                       return -ENODEV;
+       }
 
        if (dev->caps.uar_page_size * (dev->caps.num_uars -
                                       dev->caps.reserved_uars) >
@@ -553,7 +569,7 @@ int mlx4_change_port_types(struct mlx4_dev *dev,
                for (port = 1; port <= dev->caps.num_ports; port++) {
                        mlx4_CLOSE_PORT(dev, port);
                        dev->caps.port_type[port] = port_types[port - 1];
-                       err = mlx4_SET_PORT(dev, port);
+                       err = mlx4_SET_PORT(dev, port, -1);
                        if (err) {
                                mlx4_err(dev, "Failed to set port %d, "
                                              "aborting\n", port);
@@ -739,7 +755,7 @@ static ssize_t set_port_ib_mtu(struct device *dev,
        mlx4_unregister_device(mdev);
        for (port = 1; port <= mdev->caps.num_ports; port++) {
                mlx4_CLOSE_PORT(mdev, port);
-               err = mlx4_SET_PORT(mdev, port);
+               err = mlx4_SET_PORT(mdev, port, -1);
                if (err) {
                        mlx4_err(mdev, "Failed to set port %d, "
                                      "aborting\n", port);
@@ -1192,6 +1208,17 @@ err:
        return -EIO;
 }
 
+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;
+               dev->caps.pkey_table_len[i] =
+                       dev->phys_caps.pkey_phys_table_len[i] - 1;
+       }
+}
+
 static int mlx4_init_hca(struct mlx4_dev *dev)
 {
        struct mlx4_priv          *priv = mlx4_priv(dev);
@@ -1231,6 +1258,9 @@ static int mlx4_init_hca(struct mlx4_dev *dev)
                        goto err_stop_fw;
                }
 
+               if (mlx4_is_master(dev))
+                       mlx4_parav_master_pf_caps(dev);
+
                priv->fs_hash_mode = MLX4_FS_L2_HASH;
 
                switch (priv->fs_hash_mode) {
@@ -1522,12 +1552,24 @@ static int mlx4_setup_hca(struct mlx4_dev *dev)
                                          "with caps = 0\n", port, err);
                        dev->caps.ib_port_def_cap[port] = ib_port_default_caps;
 
+                       /* initialize per-slave default ib port capabilities */
+                       if (mlx4_is_master(dev)) {
+                               int i;
+                               for (i = 0; i < dev->num_slaves; i++) {
+                                       if (i == mlx4_master_func_num(dev))
+                                               continue;
+                                       priv->mfunc.master.slave_state[i].ib_cap_mask[port] =
+                                                       ib_port_default_caps;
+                               }
+                       }
+
                        if (mlx4_is_mfunc(dev))
                                dev->caps.port_ib_mtu[port] = IB_MTU_2048;
                        else
                                dev->caps.port_ib_mtu[port] = IB_MTU_4096;
 
-                       err = mlx4_SET_PORT(dev, port);
+                       err = mlx4_SET_PORT(dev, port, mlx4_is_master(dev) ?
+                                           dev->caps.pkey_table_len[port] : -1);
                        if (err) {
                                mlx4_err(dev, "Failed to set port %d, aborting\n",
                                        port);