drivers/infiniband/core/iwpm_util.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/core/iwpm_util.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/core/iwpm_util.c- Extension
.c- Size
- 22059 bytes
- Lines
- 794
- 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
iwpm_util.h
Detected Declarations
function iwpm_initfunction iwpm_exitfunction iwpm_create_mapinfofunction iwpm_remove_mapinfofunction hlist_for_each_entry_safefunction free_hash_bucketfunction hlist_for_each_entry_safefunction free_reminfo_bucketfunction hlist_for_each_entry_safefunction iwpm_add_remote_infofunction iwpm_get_remote_infofunction hlist_for_each_entry_safefunction iwpm_free_nlmsg_requestfunction iwpm_wait_complete_reqfunction iwpm_get_nlmsg_seqfunction iwpm_get_registrationfunction iwpm_set_registrationfunction iwpm_check_registrationfunction iwpm_compare_sockaddrfunction iwpm_parse_nlmsgfunction iwpm_print_sockaddrfunction iwpm_ipv6_jhashfunction iwpm_ipv4_jhashfunction get_hash_bucketfunction send_mapinfo_numfunction send_nlmsg_donefunction iwpm_send_mapinfofunction hlist_for_each_entryfunction iwpm_mapinfo_availablefunction iwpm_send_hello
Annotated Snippet
if (hash_bucket_head) {
hlist_add_head(&map_info->hlist_node, hash_bucket_head);
ret = 0;
}
}
spin_unlock_irqrestore(&iwpm_mapinfo_lock, flags);
if (!hash_bucket_head)
kfree(map_info);
return ret;
}
/**
* iwpm_remove_mapinfo - Remove local and mapped IPv4/IPv6 address
* info from the hash table
* @local_sockaddr: Local ip/tcp address
* @mapped_local_addr: Mapped local ip/tcp address
*
* Returns err code if mapping info is not found in the hash table,
* otherwise returns 0
*/
int iwpm_remove_mapinfo(struct sockaddr_storage *local_sockaddr,
struct sockaddr_storage *mapped_local_addr)
{
struct hlist_node *tmp_hlist_node;
struct hlist_head *hash_bucket_head;
struct iwpm_mapping_info *map_info = NULL;
unsigned long flags;
int ret = -EINVAL;
spin_lock_irqsave(&iwpm_mapinfo_lock, flags);
if (iwpm_hash_bucket) {
hash_bucket_head = get_mapinfo_hash_bucket(
local_sockaddr,
mapped_local_addr);
if (!hash_bucket_head)
goto remove_mapinfo_exit;
hlist_for_each_entry_safe(map_info, tmp_hlist_node,
hash_bucket_head, hlist_node) {
if (!iwpm_compare_sockaddr(&map_info->mapped_sockaddr,
mapped_local_addr)) {
hlist_del_init(&map_info->hlist_node);
kfree(map_info);
ret = 0;
break;
}
}
}
remove_mapinfo_exit:
spin_unlock_irqrestore(&iwpm_mapinfo_lock, flags);
return ret;
}
static void free_hash_bucket(void)
{
struct hlist_node *tmp_hlist_node;
struct iwpm_mapping_info *map_info;
unsigned long flags;
int i;
/* remove all the mapinfo data from the list */
spin_lock_irqsave(&iwpm_mapinfo_lock, flags);
for (i = 0; i < IWPM_MAPINFO_HASH_SIZE; i++) {
hlist_for_each_entry_safe(map_info, tmp_hlist_node,
&iwpm_hash_bucket[i], hlist_node) {
hlist_del_init(&map_info->hlist_node);
kfree(map_info);
}
}
/* free the hash list */
kfree(iwpm_hash_bucket);
iwpm_hash_bucket = NULL;
spin_unlock_irqrestore(&iwpm_mapinfo_lock, flags);
}
static void free_reminfo_bucket(void)
{
struct hlist_node *tmp_hlist_node;
struct iwpm_remote_info *rem_info;
unsigned long flags;
int i;
/* remove all the remote info from the list */
spin_lock_irqsave(&iwpm_reminfo_lock, flags);
for (i = 0; i < IWPM_REMINFO_HASH_SIZE; i++) {
hlist_for_each_entry_safe(rem_info, tmp_hlist_node,
Annotation
- Immediate include surface: `iwpm_util.h`.
- Detected declarations: `function iwpm_init`, `function iwpm_exit`, `function iwpm_create_mapinfo`, `function iwpm_remove_mapinfo`, `function hlist_for_each_entry_safe`, `function free_hash_bucket`, `function hlist_for_each_entry_safe`, `function free_reminfo_bucket`, `function hlist_for_each_entry_safe`, `function iwpm_add_remote_info`.
- 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.