/* If the given qpn is also a promisc qp, *itshouldbeinsertedtoduplicateslist
*/
pqp = get_promisc_qp(dev, port, steer, qpn); if (pqp) {
dqp = kmalloc(sizeof(*dqp), GFP_KERNEL); if (!dqp) {
err = -ENOMEM; goto out_alloc;
}
dqp->qpn = qpn;
list_add_tail(&dqp->list, &new_entry->duplicates);
}
/* if no promisc qps for this vep, we are done */ if (list_empty(&s_steer->promisc_qps[steer])) return0;
/* now need to add all the promisc qps to the new *steeringentry,astheyshouldalsoreceivethepackets
* destined to this address */
mailbox = mlx4_alloc_cmd_mailbox(dev); if (IS_ERR(mailbox)) {
err = -ENOMEM; goto out_alloc;
}
mgm = mailbox->buf;
err = mlx4_READ_ENTRY(dev, index, mailbox); if (err) goto out_mailbox;
members_count = be32_to_cpu(mgm->members_count) & 0xffffff;
prot = be32_to_cpu(mgm->members_count) >> 30;
list_for_each_entry(pqp, &s_steer->promisc_qps[steer], list) { /* don't add already existing qpn */ if (pqp->qpn == qpn) continue; if (members_count == dev->caps.num_qp_per_mgm) { /* out of space */
err = -ENOMEM; goto out_mailbox;
}
/* add the qpn */
mgm->qp[members_count++] = cpu_to_be32(pqp->qpn & MGM_QPN_MASK);
} /* update the qps count and update the entry with all the promisc qps*/
mgm->members_count = cpu_to_be32(members_count | (prot << 30));
err = mlx4_WRITE_ENTRY(dev, index, mailbox);
out_mailbox:
mlx4_free_cmd_mailbox(dev, mailbox); if (!err) return0;
out_alloc: if (dqp) {
list_del(&dqp->list);
kfree(dqp);
}
list_del(&new_entry->list);
kfree(new_entry); return err;
}
if (port < 1 || port > dev->caps.num_ports) return -EINVAL;
s_steer = &mlx4_priv(dev)->steer[port - 1];
pqp = get_promisc_qp(dev, port, steer, qpn); if (!pqp) return0; /* nothing to do */
list_for_each_entry(tmp_entry, &s_steer->steer_entries[steer], list) { if (tmp_entry->index == index) {
entry = tmp_entry; break;
}
} if (unlikely(!entry)) {
mlx4_warn(dev, "Steering entry at index %x is not registered\n", index); return -EINVAL;
}
/* the given qpn is listed as a promisc qpn *weneedtoadditasaduplicatetothisentry
* for future references */
list_for_each_entry(dqp, &entry->duplicates, list) { if (qpn == dqp->qpn) return0; /* qp is already duplicated */
}
/* add the qp as a duplicate on this index */
dqp = kmalloc(sizeof(*dqp), GFP_KERNEL); if (!dqp) return -ENOMEM;
dqp->qpn = qpn;
list_add_tail(&dqp->list, &entry->duplicates);
return0;
}
/* Check whether a qpn is a duplicate on steering entry
* If so, it should not be removed from mgm */ staticbool check_duplicate_entry(struct mlx4_dev *dev, u8 port, enum mlx4_steer_type steer, unsignedint index, u32 qpn)
{ struct mlx4_steer *s_steer; struct mlx4_steer_index *tmp_entry, *entry = NULL; struct mlx4_promisc_qp *dqp, *tmp_dqp;
if (port < 1 || port > dev->caps.num_ports) returnfalse;
s_steer = &mlx4_priv(dev)->steer[port - 1];
/* if qp is not promisc, it cannot be duplicated */ if (!get_promisc_qp(dev, port, steer, qpn)) returnfalse;
/* The qp is promisc qp so it is a duplicate on this index
* Find the index entry, and remove the duplicate */
list_for_each_entry(tmp_entry, &s_steer->steer_entries[steer], list) { if (tmp_entry->index == index) {
entry = tmp_entry; break;
}
} if (unlikely(!entry)) {
mlx4_warn(dev, "Steering entry for index %x is not registered\n", index); returnfalse;
}
list_for_each_entry_safe(dqp, tmp_dqp, &entry->duplicates, list) { if (dqp->qpn == qpn) {
list_del(&dqp->list);
kfree(dqp);
}
} returntrue;
}
/* Returns true if all the QPs != tqpn contained in this entry *arePromiscQPs.Returnsfalseotherwise.
*/ staticbool promisc_steering_entry(struct mlx4_dev *dev, u8 port, enum mlx4_steer_type steer, unsignedint index, u32 tqpn,
u32 *members_count)
{ struct mlx4_cmd_mailbox *mailbox; struct mlx4_mgm *mgm;
u32 m_count; bool ret = false; int i;
if (port < 1 || port > dev->caps.num_ports) returnfalse;
mailbox = mlx4_alloc_cmd_mailbox(dev); if (IS_ERR(mailbox)) returnfalse;
mgm = mailbox->buf;
if (mlx4_READ_ENTRY(dev, index, mailbox)) goto out;
m_count = be32_to_cpu(mgm->members_count) & 0xffffff; if (members_count)
*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) { /* the qp is not promisc, the entry can't be removed */ goto out;
}
}
ret = true;
out:
mlx4_free_cmd_mailbox(dev, mailbox); return ret;
}
/* IF a steering entry contains only promisc QPs, it can be removed. */ staticbool can_remove_steering_entry(struct mlx4_dev *dev, u8 port, enum mlx4_steer_type steer, unsignedint 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) returnfalse;
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 */
ret = true;
list_for_each_entry_safe(entry, tmp_entry, &s_steer->steer_entries[steer], list) { if (entry->index == index) { if (list_empty(&entry->duplicates) ||
members_count == 1) { struct mlx4_promisc_qp *pqp, *tmp_pqp; /* If there is only 1 entry in duplicates then *thisistheQPwewanttodelete,goingover *thelistanddeletingtheentry.
*/
list_del(&entry->list);
list_for_each_entry_safe(pqp, tmp_pqp,
&entry->duplicates,
list) {
list_del(&pqp->list);
kfree(pqp);
}
kfree(entry);
} else { /* This entry contains duplicates so it shouldn't be removed */
ret = false; goto out;
}
}
}
if (!(mlx4_is_mfunc(dev) && steer == MLX4_UC_STEER)) { /* The promisc QP needs to be added for each one of the steering *entries.Ifitalreadyexists,needstobeaddedas *aduplicateforthisentry.
*/
list_for_each_entry(entry,
&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;
prot = be32_to_cpu(mgm->members_count) >> 30;
found = false; for (i = 0; i < members_count; i++) { if ((be32_to_cpu(mgm->qp[i]) &
MGM_QPN_MASK) == qpn) { /* Entry already exists. *Addtoduplicates.
*/
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; 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;
}
}
}
/* add the new qpn to list of promisc qps */
list_add_tail(&pqp->list, &s_steer->promisc_qps[steer]); /* now need to add all the promisc qps to default entry */
memset(mgm, 0, sizeof(*mgm));
members_count = 0;
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->members_count = cpu_to_be32(members_count | MLX4_PROT_ETH << 30);
err = mlx4_WRITE_PROMISC(dev, port, steer, mailbox); if (err) goto out_list;
pqp = get_promisc_qp(dev, port, steer, qpn); if (unlikely(!pqp)) {
mlx4_warn(dev, "QP %x is not promiscuous QP\n", qpn); /* nothing to do */
err = 0; goto out_mutex;
}
/*remove from list of promisc qps */
list_del(&pqp->list);
/* set the default entry not to include the removed one */
mailbox = mlx4_alloc_cmd_mailbox(dev); if (IS_ERR(mailbox)) {
err = -ENOMEM;
back_to_list = true; goto out_list;
}
mgm = mailbox->buf;
members_count = 0;
list_for_each_entry(dqp, &s_steer->promisc_qps[steer], list)
mgm->qp[members_count++] = cpu_to_be32(dqp->qpn & MGM_QPN_MASK);
mgm->members_count = cpu_to_be32(members_count | MLX4_PROT_ETH << 30);
err = mlx4_WRITE_PROMISC(dev, port, steer, mailbox); if (err) goto out_mailbox;
if (!(mlx4_is_mfunc(dev) && steer == MLX4_UC_STEER)) { /* Remove the QP from all the steering entries */
list_for_each_entry_safe(entry, tmp_entry,
&s_steer->steer_entries[steer],
list) {
found = false;
list_for_each_entry(dqp, &entry->duplicates, list) { if (dqp->qpn == qpn) {
found = true; break;
}
} if (found) { /* A duplicate, no need to change the MGM, *onlyupdatetheduplicateslist
*/
list_del(&dqp->list);
kfree(dqp);
} else { int loc = -1;
err = mlx4_READ_ENTRY(dev,
entry->index,
mailbox); if (err) goto out_mailbox;
members_count =
be32_to_cpu(mgm->members_count) & 0xffffff; if (!members_count) {
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;
}
for (i = 0; i < members_count; ++i) 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;
}
/* Copy the last QP in this MGM *overremovedQP
*/
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));
members_count = be32_to_cpu(mgm->members_count) & 0xffffff; if (members_count == dev->caps.num_qp_per_mgm) {
mlx4_err(dev, "MGM at index %x is full\n", index);
err = -ENOMEM; goto out;
}
for (i = 0; i < members_count; ++i) if ((be32_to_cpu(mgm->qp[i]) & MGM_QPN_MASK) == qp->qpn) {
mlx4_dbg(dev, "QP %06x already a member of MGM\n", qp->qpn);
err = 0; goto out;
}
if (index == -1) {
mlx4_err(dev, "MGID %pI6 not found\n", gid);
err = -EINVAL; goto out;
}
/* If this QP is also a promisc QP, it shouldn't be removed only if *atleastonenonepromiscQPisalsoattachedtothisMCG
*/ if (prot == MLX4_PROT_ETH &&
check_duplicate_entry(dev, port, steer, index, qp->qpn) &&
!promisc_steering_entry(dev, port, steer, index, qp->qpn, NULL)) goto out;
members_count = be32_to_cpu(mgm->members_count) & 0xffffff; for (i = 0; i < members_count; ++i) if ((be32_to_cpu(mgm->qp[i]) & MGM_QPN_MASK) == qp->qpn) {
loc = i; break;
}
if (loc == -1) {
mlx4_err(dev, "QP %06x not found in MGM\n", qp->qpn);
err = -EINVAL; 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);
err = mlx4_WRITE_ENTRY(dev, prev, mailbox); if (err) goto out;
if (index < dev->caps.num_mgms)
mlx4_warn(dev, "entry %d had next AMGM index %d < %d\n",
prev, index, dev->caps.num_mgms); else
mlx4_bitmap_free(&priv->mcg_table.bitmap,
index - dev->caps.num_mgms, MLX4_USE_RR);
}
out:
mutex_unlock(&priv->mcg_table.mutex);
mlx4_free_cmd_mailbox(dev, mailbox); if (err && dev->persist->state & MLX4_DEVICE_STATE_INTERNAL_ERROR) /* In case device is under an error, return success as a closing command */
err = 0; return err;
}
int mlx4_init_mcg_table(struct mlx4_dev *dev)
{ struct mlx4_priv *priv = mlx4_priv(dev); int err;
/* No need for mcg_table when fw managed the mcg table*/ if (dev->caps.steering_mode ==
MLX4_STEERING_MODE_DEVICE_MANAGED) return0;
err = mlx4_bitmap_init(&priv->mcg_table.bitmap, dev->caps.num_amgms,
dev->caps.num_amgms - 1, 0, 0); if (err) return err;
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.26Angebot
(Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-10-03)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.