drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.c- Extension
.c- Size
- 10492 bytes
- Lines
- 469
- 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/mlx5/vport.hlinux/list.hlinux/lockdep.hlib/devcom.hlib/mlx5.hmlx5_core.h
Detected Declarations
struct mlx5_devcom_devstruct mlx5_devcom_keystruct mlx5_devcom_compstruct mlx5_devcom_comp_devfunction devcom_dev_existsfunction mlx5_devcom_dev_allocfunction mlx5_devcom_register_devicefunction mlx5_devcom_dev_releasefunction mlx5_devcom_unregister_devicefunction mlx5_devcom_comp_allocfunction mlx5_devcom_comp_releasefunction devcom_alloc_comp_devfunction devcom_free_comp_devfunction devcom_component_equalfunction devcom_component_getfunction devcom_for_each_componentfunction mlx5_devcom_register_componentfunction mlx5_devcom_unregister_componentfunction mlx5_devcom_comp_get_sizefunction mlx5_devcom_locked_send_eventfunction mlx5_devcom_send_eventfunction mlx5_devcom_comp_set_readyfunction mlx5_devcom_comp_is_readyfunction mlx5_devcom_for_each_peer_beginfunction mlx5_devcom_for_each_peer_endfunction list_for_each_entry_continuefunction list_for_each_entry_continuefunction mlx5_devcom_comp_lockfunction mlx5_devcom_comp_unlockfunction mlx5_devcom_comp_trylockfunction mlx5_devcom_comp_assert_locked
Annotated Snippet
struct mlx5_devcom_dev {
struct list_head list;
struct mlx5_core_dev *dev;
struct kref ref;
};
struct mlx5_devcom_key {
u32 flags;
union mlx5_devcom_match_key key;
possible_net_t net;
};
struct mlx5_devcom_comp {
struct list_head comp_list;
enum mlx5_devcom_component id;
struct list_head comp_dev_list_head;
struct mlx5_devcom_key key;
mlx5_devcom_event_handler_t handler;
struct kref ref;
bool ready;
struct rw_semaphore sem;
struct lock_class_key lock_key;
};
struct mlx5_devcom_comp_dev {
struct list_head list;
struct mlx5_devcom_comp *comp;
struct mlx5_devcom_dev *devc;
void __rcu *data;
};
static bool devcom_dev_exists(struct mlx5_core_dev *dev)
{
struct mlx5_devcom_dev *iter;
list_for_each_entry(iter, &devcom_dev_list, list)
if (iter->dev == dev)
return true;
return false;
}
static struct mlx5_devcom_dev *
mlx5_devcom_dev_alloc(struct mlx5_core_dev *dev)
{
struct mlx5_devcom_dev *devc;
devc = kzalloc_obj(*devc);
if (!devc)
return NULL;
devc->dev = dev;
kref_init(&devc->ref);
return devc;
}
struct mlx5_devcom_dev *
mlx5_devcom_register_device(struct mlx5_core_dev *dev)
{
struct mlx5_devcom_dev *devc = NULL;
mutex_lock(&dev_list_lock);
if (devcom_dev_exists(dev)) {
mlx5_core_err(dev, "devcom device already exists");
goto out;
}
devc = mlx5_devcom_dev_alloc(dev);
if (!devc)
goto out;
list_add_tail(&devc->list, &devcom_dev_list);
out:
mutex_unlock(&dev_list_lock);
return devc;
}
static void
mlx5_devcom_dev_release(struct kref *ref)
{
struct mlx5_devcom_dev *devc = container_of(ref, struct mlx5_devcom_dev, ref);
mutex_lock(&dev_list_lock);
list_del(&devc->list);
mutex_unlock(&dev_list_lock);
kfree(devc);
}
void mlx5_devcom_unregister_device(struct mlx5_devcom_dev *devc)
Annotation
- Immediate include surface: `linux/mlx5/vport.h`, `linux/list.h`, `linux/lockdep.h`, `lib/devcom.h`, `lib/mlx5.h`, `mlx5_core.h`.
- Detected declarations: `struct mlx5_devcom_dev`, `struct mlx5_devcom_key`, `struct mlx5_devcom_comp`, `struct mlx5_devcom_comp_dev`, `function devcom_dev_exists`, `function mlx5_devcom_dev_alloc`, `function mlx5_devcom_register_device`, `function mlx5_devcom_dev_release`, `function mlx5_devcom_unregister_device`, `function mlx5_devcom_comp_alloc`.
- 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.