Commit 9f5b6c63 authored by Eugenia Emantayev's avatar Eugenia Emantayev Committed by David S. Miller

mlx4: add unicast steering entries to resource_tracker

Add unicast steering entries to resource tracker.
Do qp_detach also for these entries when VF doesn't shut down gracefully.
Otherwise there is leakage of these resources, since they are not tracked.
Signed-off-by: default avatarEugenia Emantayev <eugenia@mellanox.co.il>
Reviewed-by: default avatarYevgeny Petrilin <yevgenyp@mellanox.co.il>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2531188b
...@@ -73,6 +73,7 @@ struct res_gid { ...@@ -73,6 +73,7 @@ struct res_gid {
struct list_head list; struct list_head list;
u8 gid[16]; u8 gid[16];
enum mlx4_protocol prot; enum mlx4_protocol prot;
enum mlx4_steer_type steer;
}; };
enum res_qp_states { enum res_qp_states {
...@@ -2480,7 +2481,8 @@ static struct res_gid *find_gid(struct mlx4_dev *dev, int slave, ...@@ -2480,7 +2481,8 @@ static struct res_gid *find_gid(struct mlx4_dev *dev, int slave,
} }
static int add_mcg_res(struct mlx4_dev *dev, int slave, struct res_qp *rqp, static int add_mcg_res(struct mlx4_dev *dev, int slave, struct res_qp *rqp,
u8 *gid, enum mlx4_protocol prot) u8 *gid, enum mlx4_protocol prot,
enum mlx4_steer_type steer)
{ {
struct res_gid *res; struct res_gid *res;
int err; int err;
...@@ -2496,6 +2498,7 @@ static int add_mcg_res(struct mlx4_dev *dev, int slave, struct res_qp *rqp, ...@@ -2496,6 +2498,7 @@ static int add_mcg_res(struct mlx4_dev *dev, int slave, struct res_qp *rqp,
} else { } else {
memcpy(res->gid, gid, 16); memcpy(res->gid, gid, 16);
res->prot = prot; res->prot = prot;
res->steer = steer;
list_add_tail(&res->list, &rqp->mcg_list); list_add_tail(&res->list, &rqp->mcg_list);
err = 0; err = 0;
} }
...@@ -2505,14 +2508,15 @@ static int add_mcg_res(struct mlx4_dev *dev, int slave, struct res_qp *rqp, ...@@ -2505,14 +2508,15 @@ static int add_mcg_res(struct mlx4_dev *dev, int slave, struct res_qp *rqp,
} }
static int rem_mcg_res(struct mlx4_dev *dev, int slave, struct res_qp *rqp, static int rem_mcg_res(struct mlx4_dev *dev, int slave, struct res_qp *rqp,
u8 *gid, enum mlx4_protocol prot) u8 *gid, enum mlx4_protocol prot,
enum mlx4_steer_type steer)
{ {
struct res_gid *res; struct res_gid *res;
int err; int err;
spin_lock_irq(&rqp->mcg_spl); spin_lock_irq(&rqp->mcg_spl);
res = find_gid(dev, slave, rqp, gid); res = find_gid(dev, slave, rqp, gid);
if (!res || res->prot != prot) if (!res || res->prot != prot || res->steer != steer)
err = -EINVAL; err = -EINVAL;
else { else {
list_del(&res->list); list_del(&res->list);
...@@ -2548,7 +2552,7 @@ int mlx4_QP_ATTACH_wrapper(struct mlx4_dev *dev, int slave, ...@@ -2548,7 +2552,7 @@ int mlx4_QP_ATTACH_wrapper(struct mlx4_dev *dev, int slave,
qp.qpn = qpn; qp.qpn = qpn;
if (attach) { if (attach) {
err = add_mcg_res(dev, slave, rqp, gid, prot); err = add_mcg_res(dev, slave, rqp, gid, prot, type);
if (err) if (err)
goto ex_put; goto ex_put;
...@@ -2557,7 +2561,7 @@ int mlx4_QP_ATTACH_wrapper(struct mlx4_dev *dev, int slave, ...@@ -2557,7 +2561,7 @@ int mlx4_QP_ATTACH_wrapper(struct mlx4_dev *dev, int slave,
if (err) if (err)
goto ex_rem; goto ex_rem;
} else { } else {
err = rem_mcg_res(dev, slave, rqp, gid, prot); err = rem_mcg_res(dev, slave, rqp, gid, prot, type);
if (err) if (err)
goto ex_put; goto ex_put;
err = mlx4_qp_detach_common(dev, &qp, gid, prot, type); err = mlx4_qp_detach_common(dev, &qp, gid, prot, type);
...@@ -2568,7 +2572,7 @@ int mlx4_QP_ATTACH_wrapper(struct mlx4_dev *dev, int slave, ...@@ -2568,7 +2572,7 @@ int mlx4_QP_ATTACH_wrapper(struct mlx4_dev *dev, int slave,
ex_rem: ex_rem:
/* ignore error return below, already in error */ /* ignore error return below, already in error */
err1 = rem_mcg_res(dev, slave, rqp, gid, prot); err1 = rem_mcg_res(dev, slave, rqp, gid, prot, type);
ex_put: ex_put:
put_res(dev, slave, qpn, RES_QP); put_res(dev, slave, qpn, RES_QP);
...@@ -2607,7 +2611,7 @@ static void detach_qp(struct mlx4_dev *dev, int slave, struct res_qp *rqp) ...@@ -2607,7 +2611,7 @@ static void detach_qp(struct mlx4_dev *dev, int slave, struct res_qp *rqp)
list_for_each_entry_safe(rgid, tmp, &rqp->mcg_list, list) { list_for_each_entry_safe(rgid, tmp, &rqp->mcg_list, list) {
qp.qpn = rqp->local_qpn; qp.qpn = rqp->local_qpn;
err = mlx4_qp_detach_common(dev, &qp, rgid->gid, rgid->prot, err = mlx4_qp_detach_common(dev, &qp, rgid->gid, rgid->prot,
MLX4_MC_STEER); rgid->steer);
list_del(&rgid->list); list_del(&rgid->list);
kfree(rgid); kfree(rgid);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment