drivers/infiniband/hw/mlx4/alias_GUID.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/hw/mlx4/alias_GUID.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/hw/mlx4/alias_GUID.c- Extension
.c- Size
- 29407 bytes
- Lines
- 900
- Domain
- Driver Families
- Bucket
- drivers/infiniband
- 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
rdma/ib_mad.hrdma/ib_smi.hrdma/ib_cache.hrdma/ib_sa.hrdma/ib_pack.hlinux/mlx4/cmd.hlinux/init.hlinux/errno.hrdma/ib_user_verbs.hlinux/delay.hmlx4_ib.h
Detected Declarations
struct mlx4_alias_guid_work_contextstruct mlx4_next_alias_guid_workfunction mlx4_ib_update_cache_on_guid_changefunction get_cached_alias_guidfunction mlx4_ib_get_aguid_comp_mask_from_ixfunction mlx4_ib_slave_alias_guid_eventfunction mlx4_ib_notify_slaves_on_guid_changefunction aliasguid_query_handlerfunction invalidate_guid_recordfunction set_guid_recfunction mlx4_ib_guid_port_initfunction mlx4_ib_invalidate_all_guid_recordfunction set_required_recordfunction get_low_record_time_indexfunction configuredfunction alias_guid_workfunction mlx4_ib_init_alias_guid_workfunction mlx4_ib_destroy_alias_guid_servicefunction mlx4_ib_init_alias_guid_service
Annotated Snippet
struct mlx4_alias_guid_work_context {
u8 port;
struct mlx4_ib_dev *dev ;
struct ib_sa_query *sa_query;
struct completion done;
int query_id;
struct list_head list;
int block_num;
ib_sa_comp_mask guid_indexes;
u8 method;
};
struct mlx4_next_alias_guid_work {
u8 port;
u8 block_num;
u8 method;
struct mlx4_sriov_alias_guid_info_rec_det rec_det;
};
static int get_low_record_time_index(struct mlx4_ib_dev *dev, u8 port,
int *resched_delay_sec);
void mlx4_ib_update_cache_on_guid_change(struct mlx4_ib_dev *dev, int block_num,
u32 port_num, u8 *p_data)
{
int i;
u64 guid_indexes;
int slave_id;
u32 port_index = port_num - 1;
if (!mlx4_is_master(dev->dev))
return;
guid_indexes = be64_to_cpu((__force __be64) dev->sriov.alias_guid.
ports_guid[port_num - 1].
all_rec_per_port[block_num].guid_indexes);
pr_debug("port: %u, guid_indexes: 0x%llx\n", port_num, guid_indexes);
for (i = 0; i < NUM_ALIAS_GUID_IN_REC; i++) {
/* The location of the specific index starts from bit number 4
* until bit num 11 */
if (test_bit(i + 4, (unsigned long *)&guid_indexes)) {
slave_id = (block_num * NUM_ALIAS_GUID_IN_REC) + i ;
if (slave_id >= dev->dev->num_slaves) {
pr_debug("The last slave: %d\n", slave_id);
return;
}
/* cache the guid: */
memcpy(&dev->sriov.demux[port_index].guid_cache[slave_id],
&p_data[i * GUID_REC_SIZE],
GUID_REC_SIZE);
} else
pr_debug("Guid number: %d in block: %d"
" was not updated\n", i, block_num);
}
}
static __be64 get_cached_alias_guid(struct mlx4_ib_dev *dev, int port, int index)
{
if (index >= NUM_ALIAS_GUID_PER_PORT) {
pr_err("%s: ERROR: asked for index:%d\n", __func__, index);
return (__force __be64) -1;
}
return *(__be64 *)&dev->sriov.demux[port - 1].guid_cache[index];
}
ib_sa_comp_mask mlx4_ib_get_aguid_comp_mask_from_ix(int index)
{
return IB_SA_COMP_MASK(4 + index);
}
void mlx4_ib_slave_alias_guid_event(struct mlx4_ib_dev *dev, int slave,
int port, int slave_init)
{
__be64 curr_guid, required_guid;
int record_num = slave / 8;
int index = slave % 8;
int port_index = port - 1;
unsigned long flags;
int do_work = 0;
spin_lock_irqsave(&dev->sriov.alias_guid.ag_work_lock, flags);
if (dev->sriov.alias_guid.ports_guid[port_index].state_flags &
GUID_STATE_NEED_PORT_INIT)
goto unlock;
if (!slave_init) {
curr_guid = *(__be64 *)&dev->sriov.
alias_guid.ports_guid[port_index].
Annotation
- Immediate include surface: `rdma/ib_mad.h`, `rdma/ib_smi.h`, `rdma/ib_cache.h`, `rdma/ib_sa.h`, `rdma/ib_pack.h`, `linux/mlx4/cmd.h`, `linux/init.h`, `linux/errno.h`.
- Detected declarations: `struct mlx4_alias_guid_work_context`, `struct mlx4_next_alias_guid_work`, `function mlx4_ib_update_cache_on_guid_change`, `function get_cached_alias_guid`, `function mlx4_ib_get_aguid_comp_mask_from_ix`, `function mlx4_ib_slave_alias_guid_event`, `function mlx4_ib_notify_slaves_on_guid_change`, `function aliasguid_query_handler`, `function invalidate_guid_record`, `function set_guid_rec`.
- Atlas domain: Driver Families / drivers/infiniband.
- 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.