drivers/infiniband/core/cache.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/core/cache.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/core/cache.c- Extension
.c- Size
- 43485 bytes
- Lines
- 1658
- Domain
- Driver Families
- Bucket
- drivers/infiniband
- 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/if_vlan.hlinux/errno.hlinux/slab.hlinux/workqueue.hlinux/netdevice.hnet/addrconf.hrdma/ib_cache.hcore_priv.h
Detected Declarations
struct ib_pkey_cachestruct ib_update_workstruct roce_gid_ndev_storagestruct ib_gid_table_entrystruct ib_gid_tableenum gid_attr_find_maskenum gid_table_entry_statefunction dispatch_gid_change_eventfunction rdma_is_zero_gidfunction is_gid_index_defaultfunction ib_cache_gid_parse_type_strfunction is_gid_entry_freefunction is_gid_entry_validfunction schedule_free_gidfunction put_gid_ndevfunction free_gid_entry_lockedfunction free_gid_entryfunction free_gid_workfunction alloc_gid_entryfunction store_gid_entryfunction get_gid_entryfunction put_gid_entryfunction put_gid_entry_lockedfunction add_roce_gidfunction del_gidfunction add_modify_gidfunction find_gidfunction make_default_gidfunction __ib_cache_gid_addfunction ib_cache_gid_addfunction _ib_cache_gid_delfunction ib_cache_gid_delfunction ib_cache_gid_del_all_netdev_gidsfunction rdma_put_gid_attrfunction rdma_find_gid_by_filterfunction release_gid_tablefunction cleanup_gid_table_portfunction ib_cache_gid_set_default_gidfunction gid_table_reserve_defaultfunction gid_table_release_onefunction rdma_for_each_portfunction _gid_table_setup_onefunction rdma_for_each_portfunction gid_table_cleanup_onefunction gid_table_setup_onefunction rdma_query_gidfunction rdma_read_gid_hw_contextfunction rdma_find_gid
Annotated Snippet
struct ib_pkey_cache {
int table_len;
u16 table[] __counted_by(table_len);
};
struct ib_update_work {
struct work_struct work;
struct ib_event event;
bool enforce_security;
};
union ib_gid zgid;
EXPORT_SYMBOL(zgid);
enum gid_attr_find_mask {
GID_ATTR_FIND_MASK_GID = 1UL << 0,
GID_ATTR_FIND_MASK_NETDEV = 1UL << 1,
GID_ATTR_FIND_MASK_DEFAULT = 1UL << 2,
GID_ATTR_FIND_MASK_GID_TYPE = 1UL << 3,
};
enum gid_table_entry_state {
GID_TABLE_ENTRY_INVALID = 1,
GID_TABLE_ENTRY_VALID = 2,
/*
* Indicates that entry is pending to be removed, there may
* be active users of this GID entry.
* When last user of the GID entry releases reference to it,
* GID entry is detached from the table.
*/
GID_TABLE_ENTRY_PENDING_DEL = 3,
};
struct roce_gid_ndev_storage {
struct rcu_head rcu_head;
struct net_device *ndev;
};
struct ib_gid_table_entry {
struct kref kref;
struct work_struct del_work;
struct ib_gid_attr attr;
void *context;
/* Store the ndev pointer to release reference later on in
* call_rcu context because by that time gid_table_entry
* and attr might be already freed. So keep a copy of it.
* ndev_storage is freed by rcu callback.
*/
struct roce_gid_ndev_storage *ndev_storage;
enum gid_table_entry_state state;
};
struct ib_gid_table {
int sz;
/* In RoCE, adding a GID to the table requires:
* (a) Find if this GID is already exists.
* (b) Find a free space.
* (c) Write the new GID
*
* Delete requires different set of operations:
* (a) Find the GID
* (b) Delete it.
*
**/
/* Any writer to data_vec must hold this lock and the write side of
* rwlock. Readers must hold only rwlock. All writers must be in a
* sleepable context.
*/
struct mutex lock;
/* rwlock protects data_vec[ix]->state and entry pointer.
*/
rwlock_t rwlock;
/* bit field, each bit indicates the index of default GID */
u32 default_gid_indices;
struct ib_gid_table_entry *data_vec[] __counted_by(sz);
};
static void dispatch_gid_change_event(struct ib_device *ib_dev, u32 port)
{
struct ib_event event;
event.device = ib_dev;
event.element.port_num = port;
event.event = IB_EVENT_GID_CHANGE;
ib_dispatch_event_clients(&event);
}
static const char * const gid_type_str[] = {
/* IB/RoCE v1 value is set for IB_GID_TYPE_IB and IB_GID_TYPE_ROCE for
Annotation
- Immediate include surface: `linux/if_vlan.h`, `linux/errno.h`, `linux/slab.h`, `linux/workqueue.h`, `linux/netdevice.h`, `net/addrconf.h`, `rdma/ib_cache.h`, `core_priv.h`.
- Detected declarations: `struct ib_pkey_cache`, `struct ib_update_work`, `struct roce_gid_ndev_storage`, `struct ib_gid_table_entry`, `struct ib_gid_table`, `enum gid_attr_find_mask`, `enum gid_table_entry_state`, `function dispatch_gid_change_event`, `function rdma_is_zero_gid`, `function is_gid_index_default`.
- Atlas domain: Driver Families / drivers/infiniband.
- 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.