drivers/hv/mshv_portid_table.c
Source file repositories/reference/linux-study-clean/drivers/hv/mshv_portid_table.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hv/mshv_portid_table.c- Extension
.c- Size
- 1596 bytes
- Lines
- 84
- Domain
- Driver Families
- Bucket
- drivers/hv
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/types.hlinux/mm.hlinux/slab.hlinux/idr.hasm/mshyperv.hmshv.hmshv_root.h
Detected Declarations
function mshv_port_table_finifunction idr_for_each_entry_ulfunction mshv_portid_allocfunction mshv_portid_freefunction mshv_portid_lookup
Annotated Snippet
idr_for_each_entry_ul(&port_table_idr, port_info, tmp, i) {
port_info = idr_remove(&port_table_idr, i);
kfree_rcu(port_info, portbl_rcu);
}
}
idr_unlock(&port_table_idr);
}
int
mshv_portid_alloc(struct port_table_info *info)
{
int ret = 0;
idr_lock(&port_table_idr);
ret = idr_alloc(&port_table_idr, info, PORTID_MIN,
PORTID_MAX, GFP_KERNEL);
idr_unlock(&port_table_idr);
return ret;
}
void
mshv_portid_free(int port_id)
{
struct port_table_info *info;
idr_lock(&port_table_idr);
info = idr_remove(&port_table_idr, port_id);
WARN_ON(!info);
idr_unlock(&port_table_idr);
synchronize_rcu();
kfree(info);
}
int
mshv_portid_lookup(int port_id, struct port_table_info *info)
{
struct port_table_info *_info;
int ret = -ENOENT;
rcu_read_lock();
_info = idr_find(&port_table_idr, port_id);
rcu_read_unlock();
if (_info) {
*info = *_info;
ret = 0;
}
return ret;
}
Annotation
- Immediate include surface: `linux/types.h`, `linux/mm.h`, `linux/slab.h`, `linux/idr.h`, `asm/mshyperv.h`, `mshv.h`, `mshv_root.h`.
- Detected declarations: `function mshv_port_table_fini`, `function idr_for_each_entry_ul`, `function mshv_portid_alloc`, `function mshv_portid_free`, `function mshv_portid_lookup`.
- Atlas domain: Driver Families / drivers/hv.
- 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.