drivers/hv/channel_mgmt.c
Source file repositories/reference/linux-study-clean/drivers/hv/channel_mgmt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hv/channel_mgmt.c- Extension
.c- Size
- 49001 bytes
- Lines
- 1689
- Domain
- Driver Families
- Bucket
- drivers/hv
- 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/kernel.hlinux/interrupt.hlinux/sched.hlinux/wait.hlinux/mm.hlinux/slab.hlinux/list.hlinux/module.hlinux/completion.hlinux/delay.hlinux/cpu.hlinux/hyperv.hlinux/export.hasm/mshyperv.hlinux/sched/isolation.hhyperv_vmbus.h
Detected Declarations
function vmbus_rescind_cleanupfunction is_unsupported_vmbus_devsfunction hv_get_dev_typefunction vmbus_prep_negotiate_respfunction ICMSG_NEGOTIATE_PKT_SIZEfunction free_channelfunction vmbus_channel_map_relidfunction vmbus_channel_unmap_relidfunction vmbus_release_relidfunction hv_process_channel_removalfunction vmbus_free_channelsfunction list_for_each_entry_safefunction vmbus_add_channel_workfunction vmbus_process_offerfunction list_for_each_entryfunction init_vp_indexfunction init_vp_indexfunction vmbus_wait_for_unloadfunction for_each_present_cpufunction vmbus_unload_responsefunction vmbus_initiate_unloadfunction vmbus_setup_channel_statefunction find_primary_channel_by_offerfunction list_for_each_entryfunction vmbus_is_valid_offerfunction vmbus_onofferfunction check_ready_for_suspend_eventfunction vmbus_onoffer_rescindfunction vmbus_onoffer_rescindfunction vmbus_hvsock_device_unregisterfunction Linuxfunction vmbus_onopen_resultfunction list_for_each_entryfunction vmbus_ongpadl_createdfunction list_for_each_entryfunction vmbus_onmodifychannel_responsefunction list_for_each_entryfunction vmbus_ongpadl_torndownfunction list_for_each_entryfunction vmbus_onversion_responsefunction list_for_each_entryfunction vmbus_onmessagefunction vmbus_request_offersfunction secs_to_jiffiesfunction vmbus_set_sc_create_callbackfunction vmbus_set_chn_rescind_callbackexport vmbus_devsexport vmbus_prep_negotiate_resp
Annotated Snippet
if (msginfo->waiting_channel == channel) {
complete(&msginfo->waitevent);
break;
}
}
spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
}
static bool is_unsupported_vmbus_devs(const guid_t *guid)
{
int i;
for (i = 0; i < ARRAY_SIZE(vmbus_unsupported_devs); i++)
if (guid_equal(guid, &vmbus_unsupported_devs[i].guid))
return true;
return false;
}
static u16 hv_get_dev_type(const struct vmbus_channel *channel)
{
const guid_t *guid = &channel->offermsg.offer.if_type;
u16 i;
if (is_hvsock_channel(channel) || is_unsupported_vmbus_devs(guid))
return HV_UNKNOWN;
for (i = HV_IDE; i < HV_UNKNOWN; i++) {
if (guid_equal(guid, &vmbus_devs[i].guid))
return i;
}
pr_info("Unknown GUID: %pUl\n", guid);
return i;
}
/**
* vmbus_prep_negotiate_resp() - Create default response for Negotiate message
* @icmsghdrp: Pointer to msg header structure
* @buf: Raw buffer channel data
* @buflen: Length of the raw buffer channel data.
* @fw_version: The framework versions we can support.
* @fw_vercnt: The size of @fw_version.
* @srv_version: The service versions we can support.
* @srv_vercnt: The size of @srv_version.
* @nego_fw_version: The selected framework version.
* @nego_srv_version: The selected service version.
*
* Note: Versions are given in decreasing order.
*
* Set up and fill in default negotiate response message.
* Mainly used by Hyper-V drivers.
*/
bool vmbus_prep_negotiate_resp(struct icmsg_hdr *icmsghdrp, u8 *buf,
u32 buflen, const int *fw_version, int fw_vercnt,
const int *srv_version, int srv_vercnt,
int *nego_fw_version, int *nego_srv_version)
{
int icframe_major, icframe_minor;
int icmsg_major, icmsg_minor;
int fw_major, fw_minor;
int srv_major, srv_minor;
int i, j;
bool found_match = false;
struct icmsg_negotiate *negop;
/* Check that there's enough space for icframe_vercnt, icmsg_vercnt */
if (buflen < ICMSG_HDR + offsetof(struct icmsg_negotiate, reserved)) {
pr_err_ratelimited("Invalid icmsg negotiate\n");
return false;
}
icmsghdrp->icmsgsize = 0x10;
negop = (struct icmsg_negotiate *)&buf[ICMSG_HDR];
icframe_major = negop->icframe_vercnt;
icframe_minor = 0;
icmsg_major = negop->icmsg_vercnt;
icmsg_minor = 0;
/* Validate negop packet */
if (icframe_major > IC_VERSION_NEGOTIATION_MAX_VER_COUNT ||
icmsg_major > IC_VERSION_NEGOTIATION_MAX_VER_COUNT ||
ICMSG_NEGOTIATE_PKT_SIZE(icframe_major, icmsg_major) > buflen) {
pr_err_ratelimited("Invalid icmsg negotiate - icframe_major: %u, icmsg_major: %u\n",
icframe_major, icmsg_major);
goto fw_error;
}
/*
* Select the framework version number we will
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/interrupt.h`, `linux/sched.h`, `linux/wait.h`, `linux/mm.h`, `linux/slab.h`, `linux/list.h`, `linux/module.h`.
- Detected declarations: `function vmbus_rescind_cleanup`, `function is_unsupported_vmbus_devs`, `function hv_get_dev_type`, `function vmbus_prep_negotiate_resp`, `function ICMSG_NEGOTIATE_PKT_SIZE`, `function free_channel`, `function vmbus_channel_map_relid`, `function vmbus_channel_unmap_relid`, `function vmbus_release_relid`, `function hv_process_channel_removal`.
- Atlas domain: Driver Families / drivers/hv.
- 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.