Commit 816e5984 authored by Eugenia Emantayev's avatar Eugenia Emantayev Committed by David S. Miller

net/mlx4_core: In SR-IOV mode host should add promisc QP to default entry only

In current situation host is adding the promiscuous QP to all steering
entries and the default entry as well. In this case when having PV
and SR-IOV on the same setup bridge will receive all traffic that is
targeted to the other VMs. This is bad.
Solution: In SR-IOV mode host can add promiscuous QP to default entry only.
The above problem and fix are relevant for B0 steering mode only.
Signed-off-by: default avatarEugenia Emantayev <eugenia@mellanox.com>
Signed-off-by: default avatarAmir Vadai <amirv@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 75908376
...@@ -433,44 +433,59 @@ static int add_promisc_qp(struct mlx4_dev *dev, u8 port, ...@@ -433,44 +433,59 @@ static int add_promisc_qp(struct mlx4_dev *dev, u8 port,
} }
mgm = mailbox->buf; mgm = mailbox->buf;
/* the promisc qp needs to be added for each one of the steering if (!(mlx4_is_mfunc(dev) && steer == MLX4_UC_STEER)) {
* entries, if it already exists, needs to be added as a duplicate /* The promisc QP needs to be added for each one of the steering
* for this entry */ * entries. If it already exists, needs to be added as
list_for_each_entry(entry, &s_steer->steer_entries[steer], list) { * a duplicate for this entry.
*/
list_for_each_entry(entry,
&s_steer->steer_entries[steer],
list) {
err = mlx4_READ_ENTRY(dev, entry->index, mailbox); err = mlx4_READ_ENTRY(dev, entry->index, mailbox);
if (err) if (err)
goto out_mailbox; goto out_mailbox;
members_count = be32_to_cpu(mgm->members_count) & 0xffffff; members_count = be32_to_cpu(mgm->members_count) &
0xffffff;
prot = be32_to_cpu(mgm->members_count) >> 30; prot = be32_to_cpu(mgm->members_count) >> 30;
found = false; found = false;
for (i = 0; i < members_count; i++) { for (i = 0; i < members_count; i++) {
if ((be32_to_cpu(mgm->qp[i]) & MGM_QPN_MASK) == qpn) { if ((be32_to_cpu(mgm->qp[i]) &
/* Entry already exists, add to duplicates */ MGM_QPN_MASK) == qpn) {
dqp = kmalloc(sizeof *dqp, GFP_KERNEL); /* Entry already exists.
* Add to duplicates.
*/
dqp = kmalloc(sizeof(*dqp), GFP_KERNEL);
if (!dqp) { if (!dqp) {
err = -ENOMEM; err = -ENOMEM;
goto out_mailbox; goto out_mailbox;
} }
dqp->qpn = qpn; dqp->qpn = qpn;
list_add_tail(&dqp->list, &entry->duplicates); list_add_tail(&dqp->list,
&entry->duplicates);
found = true; found = true;
} }
} }
if (!found) { if (!found) {
/* Need to add the qpn to mgm */ /* Need to add the qpn to mgm */
if (members_count == dev->caps.num_qp_per_mgm) { if (members_count ==
dev->caps.num_qp_per_mgm) {
/* entry is full */ /* entry is full */
err = -ENOMEM; err = -ENOMEM;
goto out_mailbox; goto out_mailbox;
} }
mgm->qp[members_count++] = cpu_to_be32(qpn & MGM_QPN_MASK); mgm->qp[members_count++] =
mgm->members_count = cpu_to_be32(members_count | (prot << 30)); cpu_to_be32(qpn & MGM_QPN_MASK);
err = mlx4_WRITE_ENTRY(dev, entry->index, mailbox); mgm->members_count =
cpu_to_be32(members_count |
(prot << 30));
err = mlx4_WRITE_ENTRY(dev, entry->index,
mailbox);
if (err) if (err)
goto out_mailbox; goto out_mailbox;
} }
} }
}
/* add the new qpn to list of promisc qps */ /* add the new qpn to list of promisc qps */
list_add_tail(&pqp->list, &s_steer->promisc_qps[steer]); list_add_tail(&pqp->list, &s_steer->promisc_qps[steer]);
...@@ -556,8 +571,11 @@ static int remove_promisc_qp(struct mlx4_dev *dev, u8 port, ...@@ -556,8 +571,11 @@ static int remove_promisc_qp(struct mlx4_dev *dev, u8 port,
if (err) if (err)
goto out_mailbox; goto out_mailbox;
if (!(mlx4_is_mfunc(dev) && steer == MLX4_UC_STEER)) {
/* remove the qp from all the steering entries*/ /* remove the qp from all the steering entries*/
list_for_each_entry(entry, &s_steer->steer_entries[steer], list) { list_for_each_entry(entry,
&s_steer->steer_entries[steer],
list) {
found = false; found = false;
list_for_each_entry(dqp, &entry->duplicates, list) { list_for_each_entry(dqp, &entry->duplicates, list) {
if (dqp->qpn == qpn) { if (dqp->qpn == qpn) {
...@@ -566,16 +584,22 @@ static int remove_promisc_qp(struct mlx4_dev *dev, u8 port, ...@@ -566,16 +584,22 @@ static int remove_promisc_qp(struct mlx4_dev *dev, u8 port,
} }
} }
if (found) { if (found) {
/* a duplicate, no need to change the mgm, /* A duplicate, no need to change the MGM,
* only update the duplicates list */ * only update the duplicates list
*/
list_del(&dqp->list); list_del(&dqp->list);
kfree(dqp); kfree(dqp);
} else { } else {
int loc = -1; int loc = -1;
err = mlx4_READ_ENTRY(dev, entry->index, mailbox);
err = mlx4_READ_ENTRY(dev,
entry->index,
mailbox);
if (err) if (err)
goto out_mailbox; goto out_mailbox;
members_count = be32_to_cpu(mgm->members_count) & 0xffffff; members_count =
be32_to_cpu(mgm->members_count) &
0xffffff;
for (i = 0; i < members_count; ++i) for (i = 0; i < members_count; ++i)
if ((be32_to_cpu(mgm->qp[i]) & if ((be32_to_cpu(mgm->qp[i]) &
MGM_QPN_MASK) == qpn) { MGM_QPN_MASK) == qpn) {
...@@ -590,17 +614,22 @@ static int remove_promisc_qp(struct mlx4_dev *dev, u8 port, ...@@ -590,17 +614,22 @@ static int remove_promisc_qp(struct mlx4_dev *dev, u8 port,
goto out_mailbox; goto out_mailbox;
} }
/* copy the last QP in this MGM over removed QP */ /* copy the last QP in this MGM
* over removed QP
*/
mgm->qp[loc] = mgm->qp[members_count - 1]; mgm->qp[loc] = mgm->qp[members_count - 1];
mgm->qp[members_count - 1] = 0; mgm->qp[members_count - 1] = 0;
mgm->members_count = cpu_to_be32(--members_count | mgm->members_count =
cpu_to_be32(--members_count |
(MLX4_PROT_ETH << 30)); (MLX4_PROT_ETH << 30));
err = mlx4_WRITE_ENTRY(dev, entry->index, mailbox); err = mlx4_WRITE_ENTRY(dev,
entry->index,
mailbox);
if (err) if (err)
goto out_mailbox; goto out_mailbox;
} }
}
} }
out_mailbox: out_mailbox:
......
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