drivers/net/ethernet/mellanox/mlx4/mcg.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx4/mcg.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx4/mcg.c- Extension
.c- Size
- 42750 bytes
- Lines
- 1650
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/string.hlinux/etherdevice.hlinux/mlx4/cmd.hlinux/mlx4/qp.hlinux/export.hmlx4.h
Detected Declarations
function Copyrightfunction mlx4_get_qp_per_mgmfunction mlx4_QP_FLOW_STEERING_ATTACHfunction mlx4_QP_FLOW_STEERING_DETACHfunction mlx4_READ_ENTRYfunction mlx4_WRITE_ENTRYfunction mlx4_WRITE_PROMISCfunction mlx4_GID_HASHfunction list_for_each_entryfunction new_steering_entryfunction existing_steering_entryfunction list_for_each_entryfunction check_duplicate_entryfunction promisc_steering_entryfunction can_remove_steering_entryfunction list_for_each_entry_safefunction add_promisc_qpfunction remove_promisc_qpfunction list_for_each_entryfunction find_entryfunction mlx4_map_sw_to_hw_steering_modefunction trans_rule_ctrl_to_hwfunction mlx4_map_sw_to_hw_steering_idfunction mlx4_hw_rule_szfunction parse_trans_rulefunction mlx4_err_rulefunction list_for_each_entryfunction mlx4_flow_attachfunction list_for_each_entryfunction mlx4_flow_detachfunction mlx4_tunnel_steer_addfunction mlx4_FLOW_STEERING_IB_UC_QP_RANGEfunction mlx4_qp_attach_commonfunction mlx4_qp_detach_commonfunction mlx4_QP_ATTACHfunction mlx4_trans_to_dmfs_attachfunction mlx4_multicast_attachfunction mlx4_multicast_detachfunction mlx4_flow_steer_promisc_addfunction mlx4_flow_steer_promisc_removefunction mlx4_unicast_attachfunction mlx4_unicast_detachfunction mlx4_PROMISC_wrapperfunction mlx4_PROMISCfunction mlx4_multicast_promisc_addfunction mlx4_multicast_promisc_removefunction mlx4_unicast_promisc_addfunction mlx4_unicast_promisc_remove
Annotated Snippet
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]))
return 0;
/* now need to add all the promisc qps to the new
* steering entry, as they should also receive the packets
* 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)
return 0;
out_alloc:
if (dqp) {
list_del(&dqp->list);
kfree(dqp);
}
list_del(&new_entry->list);
kfree(new_entry);
return err;
}
/* update the data structures with existing steering entry */
static int existing_steering_entry(struct mlx4_dev *dev, u8 port,
enum mlx4_steer_type steer,
unsigned int index, u32 qpn)
{
struct mlx4_steer *s_steer;
struct mlx4_steer_index *tmp_entry, *entry = NULL;
struct mlx4_promisc_qp *pqp;
struct mlx4_promisc_qp *dqp;
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)
return 0; /* 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
Annotation
- Immediate include surface: `linux/string.h`, `linux/etherdevice.h`, `linux/mlx4/cmd.h`, `linux/mlx4/qp.h`, `linux/export.h`, `mlx4.h`.
- Detected declarations: `function Copyright`, `function mlx4_get_qp_per_mgm`, `function mlx4_QP_FLOW_STEERING_ATTACH`, `function mlx4_QP_FLOW_STEERING_DETACH`, `function mlx4_READ_ENTRY`, `function mlx4_WRITE_ENTRY`, `function mlx4_WRITE_PROMISC`, `function mlx4_GID_HASH`, `function list_for_each_entry`, `function new_steering_entry`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.