net/mlx4_en: Use vlan id instead of vlan index for unregistration
[cascardo/linux.git] / drivers / net / ethernet / mellanox / mlx4 / resource_tracker.c
index f984a89..993a2ef 100644 (file)
@@ -1443,7 +1443,7 @@ static void rem_slave_macs(struct mlx4_dev *dev, int slave)
 }
 
 static int mac_alloc_res(struct mlx4_dev *dev, int slave, int op, int cmd,
-                        u64 in_param, u64 *out_param)
+                        u64 in_param, u64 *out_param, int in_port)
 {
        int err = -EINVAL;
        int port;
@@ -1452,7 +1452,7 @@ static int mac_alloc_res(struct mlx4_dev *dev, int slave, int op, int cmd,
        if (op != RES_OP_RESERVE_AND_MAP)
                return err;
 
-       port = get_param_l(out_param);
+       port = !in_port ? get_param_l(out_param) : in_port;
        mac = in_param;
 
        err = __mlx4_register_mac(dev, port, mac);
@@ -1470,7 +1470,7 @@ static int mac_alloc_res(struct mlx4_dev *dev, int slave, int op, int cmd,
 }
 
 static int vlan_alloc_res(struct mlx4_dev *dev, int slave, int op, int cmd,
-                        u64 in_param, u64 *out_param)
+                        u64 in_param, u64 *out_param, int port)
 {
        return 0;
 }
@@ -1528,7 +1528,7 @@ int mlx4_ALLOC_RES_wrapper(struct mlx4_dev *dev, int slave,
        int err;
        int alop = vhcr->op_modifier;
 
-       switch (vhcr->in_modifier) {
+       switch (vhcr->in_modifier & 0xFF) {
        case RES_QP:
                err = qp_alloc_res(dev, slave, vhcr->op_modifier, alop,
                                   vhcr->in_param, &vhcr->out_param);
@@ -1556,12 +1556,14 @@ int mlx4_ALLOC_RES_wrapper(struct mlx4_dev *dev, int slave,
 
        case RES_MAC:
                err = mac_alloc_res(dev, slave, vhcr->op_modifier, alop,
-                                   vhcr->in_param, &vhcr->out_param);
+                                   vhcr->in_param, &vhcr->out_param,
+                                   (vhcr->in_modifier >> 8) & 0xFF);
                break;
 
        case RES_VLAN:
                err = vlan_alloc_res(dev, slave, vhcr->op_modifier, alop,
-                                   vhcr->in_param, &vhcr->out_param);
+                                    vhcr->in_param, &vhcr->out_param,
+                                    (vhcr->in_modifier >> 8) & 0xFF);
                break;
 
        case RES_COUNTER:
@@ -1730,14 +1732,14 @@ static int srq_free_res(struct mlx4_dev *dev, int slave, int op, int cmd,
 }
 
 static int mac_free_res(struct mlx4_dev *dev, int slave, int op, int cmd,
-                           u64 in_param, u64 *out_param)
+                           u64 in_param, u64 *out_param, int in_port)
 {
        int port;
        int err = 0;
 
        switch (op) {
        case RES_OP_RESERVE_AND_MAP:
-               port = get_param_l(out_param);
+               port = !in_port ? get_param_l(out_param) : in_port;
                mac_del_from_slave(dev, slave, in_param, port);
                __mlx4_unregister_mac(dev, port, in_param);
                break;
@@ -1751,7 +1753,7 @@ static int mac_free_res(struct mlx4_dev *dev, int slave, int op, int cmd,
 }
 
 static int vlan_free_res(struct mlx4_dev *dev, int slave, int op, int cmd,
-                           u64 in_param, u64 *out_param)
+                           u64 in_param, u64 *out_param, int port)
 {
        return 0;
 }
@@ -1803,7 +1805,7 @@ int mlx4_FREE_RES_wrapper(struct mlx4_dev *dev, int slave,
        int err = -EINVAL;
        int alop = vhcr->op_modifier;
 
-       switch (vhcr->in_modifier) {
+       switch (vhcr->in_modifier & 0xFF) {
        case RES_QP:
                err = qp_free_res(dev, slave, vhcr->op_modifier, alop,
                                  vhcr->in_param);
@@ -1831,12 +1833,14 @@ int mlx4_FREE_RES_wrapper(struct mlx4_dev *dev, int slave,
 
        case RES_MAC:
                err = mac_free_res(dev, slave, vhcr->op_modifier, alop,
-                                  vhcr->in_param, &vhcr->out_param);
+                                  vhcr->in_param, &vhcr->out_param,
+                                  (vhcr->in_modifier >> 8) & 0xFF);
                break;
 
        case RES_VLAN:
                err = vlan_free_res(dev, slave, vhcr->op_modifier, alop,
-                                  vhcr->in_param, &vhcr->out_param);
+                                   vhcr->in_param, &vhcr->out_param,
+                                   (vhcr->in_modifier >> 8) & 0xFF);
                break;
 
        case RES_COUNTER:
@@ -1909,7 +1913,8 @@ static int qp_get_mtt_size(struct mlx4_qp_context *qpc)
        int log_rq_stride = qpc->rq_size_stride & 7;
        int srq = (be32_to_cpu(qpc->srqn) >> 24) & 1;
        int rss = (be32_to_cpu(qpc->flags) >> 13) & 1;
-       int xrc = (be32_to_cpu(qpc->local_qpn) >> 23) & 1;
+       u32 ts = (be32_to_cpu(qpc->flags) >> 16) & 0xff;
+       int xrc = (ts == MLX4_QP_ST_XRC) ? 1 : 0;
        int sq_size;
        int rq_size;
        int total_pages;
@@ -4080,7 +4085,7 @@ void mlx4_vf_immed_vlan_work_handler(struct work_struct *_work)
        if (work->flags & MLX4_VF_IMMED_VLAN_FLAG_VLAN && !errors &&
            NO_INDX != work->orig_vlan_ix)
                __mlx4_unregister_vlan(&work->priv->dev, work->port,
-                                      work->orig_vlan_ix);
+                                      work->orig_vlan_id);
 out:
        kfree(work);
        return;