提交 3e1c0f0b 编写于 作者: D David S. Miller

Merge branch 'mlx4-next'

Amir Vadai says:

====================
Mellanox driver update Jul-16-2014

This patchset contains some bug fixes related to MCG table management (flow
steering) in Mellanox NIC.

Fixes were applied and tested over commit 0854a7f1 ("Merge branch
'amd811e-cleanups'").
====================
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
...@@ -270,7 +270,7 @@ static int existing_steering_entry(struct mlx4_dev *dev, u8 port, ...@@ -270,7 +270,7 @@ static int existing_steering_entry(struct mlx4_dev *dev, u8 port,
* we need to add it as a duplicate to this entry * we need to add it as a duplicate to this entry
* for future references */ * for future references */
list_for_each_entry(dqp, &entry->duplicates, list) { list_for_each_entry(dqp, &entry->duplicates, list) {
if (qpn == pqp->qpn) if (qpn == dqp->qpn)
return 0; /* qp is already duplicated */ return 0; /* qp is already duplicated */
} }
...@@ -324,24 +324,22 @@ static bool check_duplicate_entry(struct mlx4_dev *dev, u8 port, ...@@ -324,24 +324,22 @@ static bool check_duplicate_entry(struct mlx4_dev *dev, u8 port,
return true; return true;
} }
/* I a steering entry contains only promisc QPs, it can be removed. */ /* Returns true if all the QPs != tqpn contained in this entry
static bool can_remove_steering_entry(struct mlx4_dev *dev, u8 port, * are Promisc QPs. Returns false otherwise.
enum mlx4_steer_type steer, */
unsigned int index, u32 tqpn) static bool promisc_steering_entry(struct mlx4_dev *dev, u8 port,
enum mlx4_steer_type steer,
unsigned int index, u32 tqpn,
u32 *members_count)
{ {
struct mlx4_steer *s_steer;
struct mlx4_cmd_mailbox *mailbox; struct mlx4_cmd_mailbox *mailbox;
struct mlx4_mgm *mgm; struct mlx4_mgm *mgm;
struct mlx4_steer_index *entry = NULL, *tmp_entry; u32 m_count;
u32 qpn;
u32 members_count;
bool ret = false; bool ret = false;
int i; int i;
if (port < 1 || port > dev->caps.num_ports) if (port < 1 || port > dev->caps.num_ports)
return NULL; return false;
s_steer = &mlx4_priv(dev)->steer[port - 1];
mailbox = mlx4_alloc_cmd_mailbox(dev); mailbox = mlx4_alloc_cmd_mailbox(dev);
if (IS_ERR(mailbox)) if (IS_ERR(mailbox))
...@@ -350,21 +348,61 @@ static bool can_remove_steering_entry(struct mlx4_dev *dev, u8 port, ...@@ -350,21 +348,61 @@ static bool can_remove_steering_entry(struct mlx4_dev *dev, u8 port,
if (mlx4_READ_ENTRY(dev, index, mailbox)) if (mlx4_READ_ENTRY(dev, index, mailbox))
goto out; goto out;
members_count = be32_to_cpu(mgm->members_count) & 0xffffff; m_count = be32_to_cpu(mgm->members_count) & 0xffffff;
for (i = 0; i < members_count; i++) { if (members_count)
qpn = be32_to_cpu(mgm->qp[i]) & MGM_QPN_MASK; *members_count = m_count;
for (i = 0; i < m_count; i++) {
u32 qpn = be32_to_cpu(mgm->qp[i]) & MGM_QPN_MASK;
if (!get_promisc_qp(dev, port, steer, qpn) && qpn != tqpn) { if (!get_promisc_qp(dev, port, steer, qpn) && qpn != tqpn) {
/* the qp is not promisc, the entry can't be removed */ /* the qp is not promisc, the entry can't be removed */
goto out; goto out;
} }
} }
/* All the qps currently registered for this entry are promiscuous, ret = true;
out:
mlx4_free_cmd_mailbox(dev, mailbox);
return ret;
}
/* IF a steering entry contains only promisc QPs, it can be removed. */
static bool can_remove_steering_entry(struct mlx4_dev *dev, u8 port,
enum mlx4_steer_type steer,
unsigned int index, u32 tqpn)
{
struct mlx4_steer *s_steer;
struct mlx4_steer_index *entry = NULL, *tmp_entry;
u32 members_count;
bool ret = false;
if (port < 1 || port > dev->caps.num_ports)
return NULL;
s_steer = &mlx4_priv(dev)->steer[port - 1];
if (!promisc_steering_entry(dev, port, steer, index,
tqpn, &members_count))
goto out;
/* All the qps currently registered for this entry are promiscuous,
* Checking for duplicates */ * Checking for duplicates */
ret = true; ret = true;
list_for_each_entry_safe(entry, tmp_entry, &s_steer->steer_entries[steer], list) { list_for_each_entry_safe(entry, tmp_entry, &s_steer->steer_entries[steer], list) {
if (entry->index == index) { if (entry->index == index) {
if (list_empty(&entry->duplicates)) { if (list_empty(&entry->duplicates) ||
members_count == 1) {
struct mlx4_promisc_qp *pqp, *tmp_pqp;
/* If there is only 1 entry in duplicates then
* this is the QP we want to delete, going over
* the list and deleting the entry.
*/
list_del(&entry->list); list_del(&entry->list);
list_for_each_entry_safe(pqp, tmp_pqp,
&entry->duplicates,
list) {
list_del(&pqp->list);
kfree(pqp);
}
kfree(entry); kfree(entry);
} else { } else {
/* This entry contains duplicates so it shouldn't be removed */ /* This entry contains duplicates so it shouldn't be removed */
...@@ -375,7 +413,6 @@ static bool can_remove_steering_entry(struct mlx4_dev *dev, u8 port, ...@@ -375,7 +413,6 @@ static bool can_remove_steering_entry(struct mlx4_dev *dev, u8 port,
} }
out: out:
mlx4_free_cmd_mailbox(dev, mailbox);
return ret; return ret;
} }
...@@ -421,42 +458,57 @@ static int add_promisc_qp(struct mlx4_dev *dev, u8 port, ...@@ -421,42 +458,57 @@ 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.
err = mlx4_READ_ENTRY(dev, entry->index, mailbox); */
if (err) list_for_each_entry(entry,
goto out_mailbox; &s_steer->steer_entries[steer],
list) {
err = mlx4_READ_ENTRY(dev, entry->index, mailbox);
if (err)
goto out_mailbox;
members_count = be32_to_cpu(mgm->members_count) & 0xffffff; members_count = be32_to_cpu(mgm->members_count) &
prot = be32_to_cpu(mgm->members_count) >> 30; 0xffffff;
found = false; prot = be32_to_cpu(mgm->members_count) >> 30;
for (i = 0; i < members_count; i++) { found = false;
if ((be32_to_cpu(mgm->qp[i]) & MGM_QPN_MASK) == qpn) { for (i = 0; i < members_count; i++) {
/* Entry already exists, add to duplicates */ if ((be32_to_cpu(mgm->qp[i]) &
dqp = kmalloc(sizeof *dqp, GFP_KERNEL); MGM_QPN_MASK) == qpn) {
if (!dqp) { /* Entry already exists.
* Add to duplicates.
*/
dqp = kmalloc(sizeof(*dqp), GFP_KERNEL);
if (!dqp) {
err = -ENOMEM;
goto out_mailbox;
}
dqp->qpn = qpn;
list_add_tail(&dqp->list,
&entry->duplicates);
found = true;
}
}
if (!found) {
/* Need to add the qpn to mgm */
if (members_count ==
dev->caps.num_qp_per_mgm) {
/* entry is full */
err = -ENOMEM; err = -ENOMEM;
goto out_mailbox; goto out_mailbox;
} }
dqp->qpn = qpn; mgm->qp[members_count++] =
list_add_tail(&dqp->list, &entry->duplicates); cpu_to_be32(qpn & MGM_QPN_MASK);
found = true; mgm->members_count =
} cpu_to_be32(members_count |
} (prot << 30));
if (!found) { err = mlx4_WRITE_ENTRY(dev, entry->index,
/* Need to add the qpn to mgm */ mailbox);
if (members_count == dev->caps.num_qp_per_mgm) { if (err)
/* entry is full */ goto out_mailbox;
err = -ENOMEM;
goto out_mailbox;
} }
mgm->qp[members_count++] = cpu_to_be32(qpn & MGM_QPN_MASK);
mgm->members_count = cpu_to_be32(members_count | (prot << 30));
err = mlx4_WRITE_ENTRY(dev, entry->index, mailbox);
if (err)
goto out_mailbox;
} }
} }
...@@ -465,8 +517,14 @@ static int add_promisc_qp(struct mlx4_dev *dev, u8 port, ...@@ -465,8 +517,14 @@ static int add_promisc_qp(struct mlx4_dev *dev, u8 port,
/* now need to add all the promisc qps to default entry */ /* now need to add all the promisc qps to default entry */
memset(mgm, 0, sizeof *mgm); memset(mgm, 0, sizeof *mgm);
members_count = 0; members_count = 0;
list_for_each_entry(dqp, &s_steer->promisc_qps[steer], list) list_for_each_entry(dqp, &s_steer->promisc_qps[steer], list) {
if (members_count == dev->caps.num_qp_per_mgm) {
/* entry is full */
err = -ENOMEM;
goto out_list;
}
mgm->qp[members_count++] = cpu_to_be32(dqp->qpn & MGM_QPN_MASK); mgm->qp[members_count++] = cpu_to_be32(dqp->qpn & MGM_QPN_MASK);
}
mgm->members_count = cpu_to_be32(members_count | MLX4_PROT_ETH << 30); mgm->members_count = cpu_to_be32(members_count | MLX4_PROT_ETH << 30);
err = mlx4_WRITE_PROMISC(dev, port, steer, mailbox); err = mlx4_WRITE_PROMISC(dev, port, steer, mailbox);
...@@ -495,13 +553,13 @@ static int remove_promisc_qp(struct mlx4_dev *dev, u8 port, ...@@ -495,13 +553,13 @@ static int remove_promisc_qp(struct mlx4_dev *dev, u8 port,
struct mlx4_steer *s_steer; struct mlx4_steer *s_steer;
struct mlx4_cmd_mailbox *mailbox; struct mlx4_cmd_mailbox *mailbox;
struct mlx4_mgm *mgm; struct mlx4_mgm *mgm;
struct mlx4_steer_index *entry; struct mlx4_steer_index *entry, *tmp_entry;
struct mlx4_promisc_qp *pqp; struct mlx4_promisc_qp *pqp;
struct mlx4_promisc_qp *dqp; struct mlx4_promisc_qp *dqp;
u32 members_count; u32 members_count;
bool found; bool found;
bool back_to_list = false; bool back_to_list = false;
int loc, i; int i;
int err; int err;
if (port < 1 || port > dev->caps.num_ports) if (port < 1 || port > dev->caps.num_ports)
...@@ -538,39 +596,73 @@ static int remove_promisc_qp(struct mlx4_dev *dev, u8 port, ...@@ -538,39 +596,73 @@ static int remove_promisc_qp(struct mlx4_dev *dev, u8 port,
if (err) if (err)
goto out_mailbox; goto out_mailbox;
/* remove the qp from all the steering entries*/ if (!(mlx4_is_mfunc(dev) && steer == MLX4_UC_STEER)) {
list_for_each_entry(entry, &s_steer->steer_entries[steer], list) { /* Remove the QP from all the steering entries */
found = false; list_for_each_entry_safe(entry, tmp_entry,
list_for_each_entry(dqp, &entry->duplicates, list) { &s_steer->steer_entries[steer],
if (dqp->qpn == qpn) { list) {
found = true; found = false;
break; list_for_each_entry(dqp, &entry->duplicates, list) {
if (dqp->qpn == qpn) {
found = true;
break;
}
} }
} 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 {
err = mlx4_READ_ENTRY(dev, entry->index, mailbox); int loc = -1;
if (err)
goto out_mailbox; err = mlx4_READ_ENTRY(dev,
members_count = be32_to_cpu(mgm->members_count) & 0xffffff; entry->index,
for (loc = -1, i = 0; i < members_count; ++i) mailbox);
if ((be32_to_cpu(mgm->qp[i]) & MGM_QPN_MASK) == qpn) if (err)
loc = i; goto out_mailbox;
members_count =
mgm->members_count = cpu_to_be32(--members_count | be32_to_cpu(mgm->members_count) &
(MLX4_PROT_ETH << 30)); 0xffffff;
mgm->qp[loc] = mgm->qp[i - 1]; if (!members_count) {
mgm->qp[i - 1] = 0; mlx4_warn(dev, "QP %06x wasn't found in entry %x mcount=0. deleting entry...\n",
qpn, entry->index);
list_del(&entry->list);
kfree(entry);
continue;
}
err = mlx4_WRITE_ENTRY(dev, entry->index, mailbox); for (i = 0; i < members_count; ++i)
if (err) if ((be32_to_cpu(mgm->qp[i]) &
MGM_QPN_MASK) == qpn) {
loc = i;
break;
}
if (loc < 0) {
mlx4_err(dev, "QP %06x wasn't found in entry %d\n",
qpn, entry->index);
err = -EINVAL;
goto out_mailbox; goto out_mailbox;
} }
/* Copy the last QP in this MGM
* over removed QP
*/
mgm->qp[loc] = mgm->qp[members_count - 1];
mgm->qp[members_count - 1] = 0;
mgm->members_count =
cpu_to_be32(--members_count |
(MLX4_PROT_ETH << 30));
err = mlx4_WRITE_ENTRY(dev,
entry->index,
mailbox);
if (err)
goto out_mailbox;
}
}
} }
out_mailbox: out_mailbox:
...@@ -1062,7 +1154,7 @@ int mlx4_qp_detach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], ...@@ -1062,7 +1154,7 @@ int mlx4_qp_detach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
struct mlx4_mgm *mgm; struct mlx4_mgm *mgm;
u32 members_count; u32 members_count;
int prev, index; int prev, index;
int i, loc; int i, loc = -1;
int err; int err;
u8 port = gid[5]; u8 port = gid[5];
bool removed_entry = false; bool removed_entry = false;
...@@ -1085,15 +1177,20 @@ int mlx4_qp_detach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], ...@@ -1085,15 +1177,20 @@ int mlx4_qp_detach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
goto out; goto out;
} }
/* if this pq is also a promisc qp, it shouldn't be removed */ /* If this QP is also a promisc QP, it shouldn't be removed only if
* at least one none promisc QP is also attached to this MCG
*/
if (prot == MLX4_PROT_ETH && if (prot == MLX4_PROT_ETH &&
check_duplicate_entry(dev, port, steer, index, qp->qpn)) check_duplicate_entry(dev, port, steer, index, qp->qpn) &&
goto out; !promisc_steering_entry(dev, port, steer, index, qp->qpn, NULL))
goto out;
members_count = be32_to_cpu(mgm->members_count) & 0xffffff; members_count = be32_to_cpu(mgm->members_count) & 0xffffff;
for (loc = -1, i = 0; i < members_count; ++i) for (i = 0; i < members_count; ++i)
if ((be32_to_cpu(mgm->qp[i]) & MGM_QPN_MASK) == qp->qpn) if ((be32_to_cpu(mgm->qp[i]) & MGM_QPN_MASK) == qp->qpn) {
loc = i; loc = i;
break;
}
if (loc == -1) { if (loc == -1) {
mlx4_err(dev, "QP %06x not found in MGM\n", qp->qpn); mlx4_err(dev, "QP %06x not found in MGM\n", qp->qpn);
...@@ -1101,15 +1198,15 @@ int mlx4_qp_detach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], ...@@ -1101,15 +1198,15 @@ int mlx4_qp_detach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
goto out; goto out;
} }
/* copy the last QP in this MGM over removed QP */
mgm->qp[loc] = mgm->qp[members_count - 1];
mgm->qp[members_count - 1] = 0;
mgm->members_count = cpu_to_be32(--members_count | (u32) prot << 30); mgm->members_count = cpu_to_be32(--members_count | (u32) prot << 30);
mgm->qp[loc] = mgm->qp[i - 1];
mgm->qp[i - 1] = 0;
if (prot == MLX4_PROT_ETH) if (prot == MLX4_PROT_ETH)
removed_entry = can_remove_steering_entry(dev, port, steer, removed_entry = can_remove_steering_entry(dev, port, steer,
index, qp->qpn); index, qp->qpn);
if (i != 1 && (prot != MLX4_PROT_ETH || !removed_entry)) { if (members_count && (prot != MLX4_PROT_ETH || !removed_entry)) {
err = mlx4_WRITE_ENTRY(dev, index, mailbox); err = mlx4_WRITE_ENTRY(dev, index, mailbox);
goto out; goto out;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册