drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx4/resource_tracker.c- Extension
.c- Size
- 135629 bytes
- Lines
- 5416
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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/sched.hlinux/pci.hlinux/errno.hlinux/kernel.hlinux/io.hlinux/slab.hlinux/mlx4/cmd.hlinux/mlx4/qp.hlinux/if_ether.hlinux/etherdevice.hmlx4.hfw.hmlx4_stats.h
Detected Declarations
struct mac_resstruct vlan_resstruct res_commonstruct res_gidstruct res_qpstruct res_mttstruct res_mptstruct res_eqstruct res_cqstruct res_srqstruct res_counterstruct res_xrcdnstruct res_fs_ruleenum res_qp_statesenum res_mtt_statesenum res_mpt_statesenum res_eq_statesenum res_cq_statesenum res_srq_statesenum res_counter_statesenum res_xrcdn_statesenum res_fs_rule_statesenum qp_transitionfunction res_tracker_insertfunction mlx4_grant_resourcefunction mlx4_release_resourcefunction initialize_res_quotasfunction mlx4_init_quotasfunction mlx4_calc_res_counter_guaranteedfunction mlx4_init_resource_trackerfunction mlx4_free_resource_trackerfunction update_pkey_indexfunction update_gidfunction update_vport_qp_paramfunction mpt_maskfunction _get_resfunction mlx4_get_slave_from_resource_idfunction put_resfunction handle_existing_counterfunction handle_unexisting_counterfunction handle_counterfunction mlx4_calc_vf_countersfunction add_res_rangefunction remove_qp_okfunction remove_mtt_okfunction remove_mpt_okfunction remove_eq_okfunction remove_counter_ok
Annotated Snippet
struct mac_res {
struct list_head list;
u64 mac;
int ref_count;
u8 smac_index;
u8 port;
};
struct vlan_res {
struct list_head list;
u16 vlan;
int ref_count;
int vlan_index;
u8 port;
};
struct res_common {
struct list_head list;
struct rb_node node;
u64 res_id;
int owner;
int state;
int from_state;
int to_state;
int removing;
const char *func_name;
};
enum {
RES_ANY_BUSY = 1
};
struct res_gid {
struct list_head list;
u8 gid[16];
enum mlx4_protocol prot;
enum mlx4_steer_type steer;
u64 reg_id;
};
enum res_qp_states {
RES_QP_BUSY = RES_ANY_BUSY,
/* QP number was allocated */
RES_QP_RESERVED,
/* ICM memory for QP context was mapped */
RES_QP_MAPPED,
/* QP is in hw ownership */
RES_QP_HW
};
struct res_qp {
struct res_common com;
struct res_mtt *mtt;
struct res_cq *rcq;
struct res_cq *scq;
struct res_srq *srq;
struct list_head mcg_list;
spinlock_t mcg_spl;
int local_qpn;
atomic_t ref_count;
u32 qpc_flags;
/* saved qp params before VST enforcement in order to restore on VGT */
u8 sched_queue;
__be32 param3;
u8 vlan_control;
u8 fvl_rx;
u8 pri_path_fl;
u8 vlan_index;
u8 feup;
};
enum res_mtt_states {
RES_MTT_BUSY = RES_ANY_BUSY,
RES_MTT_ALLOCATED,
};
static inline const char *mtt_states_str(enum res_mtt_states state)
{
switch (state) {
case RES_MTT_BUSY: return "RES_MTT_BUSY";
case RES_MTT_ALLOCATED: return "RES_MTT_ALLOCATED";
default: return "Unknown";
}
}
struct res_mtt {
struct res_common com;
Annotation
- Immediate include surface: `linux/sched.h`, `linux/pci.h`, `linux/errno.h`, `linux/kernel.h`, `linux/io.h`, `linux/slab.h`, `linux/mlx4/cmd.h`, `linux/mlx4/qp.h`.
- Detected declarations: `struct mac_res`, `struct vlan_res`, `struct res_common`, `struct res_gid`, `struct res_qp`, `struct res_mtt`, `struct res_mpt`, `struct res_eq`, `struct res_cq`, `struct res_srq`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source 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.