drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c- Extension
.c- Size
- 126987 bytes
- Lines
- 4477
- Domain
- Driver Families
- Bucket
- drivers/net
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/export.hnet/libeth/rx.hidpf.hidpf_virtchnl.hidpf_ptp.h
Detected Declarations
struct idpf_vc_xn_managerstruct idpf_chunked_msg_paramsfunction idpf_handle_event_linkfunction idpf_recv_event_msgfunction idpf_mb_cleanfunction idpf_ptp_is_mb_msgfunction idpf_prepare_ptp_mb_msgfunction idpf_prepare_ptp_mb_msgfunction idpf_vc_xn_release_bufsfunction idpf_vc_xn_initfunction idpf_vc_xn_shutdownfunction idpf_vc_xn_push_freefunction idpf_vc_xn_execfunction idpf_vc_xn_forward_asyncfunction idpf_vc_xn_forward_replyfunction idpf_recv_mb_msgfunction idpf_send_chunked_msgfunction idpf_wait_for_marker_event_setfunction idpf_wait_for_marker_eventfunction idpf_send_ver_msgfunction idpf_send_get_caps_msgfunction idpf_send_get_lan_memory_regionsfunction idpf_calc_remaining_mmio_regsfunction idpf_map_lan_mmio_regsfunction idpf_add_del_fsteer_filtersfunction idpf_vport_alloc_max_qsfunction idpf_vport_dealloc_max_qsfunction idpf_init_avail_queuesfunction idpf_vport_init_queue_reg_chunksfunction idpf_get_reg_intr_vecsfunction idpf_vport_get_q_regfunction __idpf_queue_reg_initfunction idpf_queue_reg_initfunction idpf_send_create_vport_msgfunction idpf_check_supported_desc_idsfunction idpf_send_destroy_vport_msgfunction idpf_send_enable_vport_msgfunction idpf_send_disable_vport_msgfunction idpf_fill_txq_config_chunkfunction idpf_fill_complq_config_chunkfunction idpf_prepare_cfg_txqs_msgfunction idpf_send_config_tx_queue_set_msgfunction idpf_send_config_tx_queues_msgfunction idpf_fill_rxq_config_chunkfunction idpf_fill_bufq_config_chunkfunction idpf_prepare_cfg_rxqs_msgfunction idpf_send_config_rx_queue_set_msgfunction idpf_send_config_rx_queues_msg
Annotated Snippet
struct idpf_vc_xn_manager {
struct idpf_vc_xn ring[IDPF_VC_XN_RING_LEN];
DECLARE_BITMAP(free_xn_bm, IDPF_VC_XN_RING_LEN);
spinlock_t xn_bm_lock;
u8 salt;
};
/**
* idpf_vid_to_vport - Translate vport id to vport pointer
* @adapter: private data struct
* @v_id: vport id to translate
*
* Returns vport matching v_id, NULL if not found.
*/
static
struct idpf_vport *idpf_vid_to_vport(struct idpf_adapter *adapter, u32 v_id)
{
u16 num_max_vports = idpf_get_max_vports(adapter);
int i;
for (i = 0; i < num_max_vports; i++)
if (adapter->vport_ids[i] == v_id)
return adapter->vports[i];
return NULL;
}
/**
* idpf_handle_event_link - Handle link event message
* @adapter: private data struct
* @v2e: virtchnl event message
*/
static void idpf_handle_event_link(struct idpf_adapter *adapter,
const struct virtchnl2_event *v2e)
{
struct idpf_netdev_priv *np;
struct idpf_vport *vport;
vport = idpf_vid_to_vport(adapter, le32_to_cpu(v2e->vport_id));
if (!vport) {
dev_err_ratelimited(&adapter->pdev->dev, "Failed to find vport_id %d for link event\n",
v2e->vport_id);
return;
}
np = netdev_priv(vport->netdev);
np->link_speed_mbps = le32_to_cpu(v2e->link_speed);
if (vport->link_up == v2e->link_status)
return;
vport->link_up = v2e->link_status;
if (!test_bit(IDPF_VPORT_UP, np->state))
return;
if (vport->link_up) {
netif_tx_start_all_queues(vport->netdev);
netif_carrier_on(vport->netdev);
} else {
netif_tx_stop_all_queues(vport->netdev);
netif_carrier_off(vport->netdev);
}
}
/**
* idpf_recv_event_msg - Receive virtchnl event message
* @adapter: Driver specific private structure
* @ctlq_msg: message to copy from
*
* Receive virtchnl event message
*/
static void idpf_recv_event_msg(struct idpf_adapter *adapter,
struct idpf_ctlq_msg *ctlq_msg)
{
int payload_size = ctlq_msg->ctx.indirect.payload->size;
struct virtchnl2_event *v2e;
u32 event;
if (payload_size < sizeof(*v2e)) {
dev_err_ratelimited(&adapter->pdev->dev, "Failed to receive valid payload for event msg (op %d len %d)\n",
ctlq_msg->cookie.mbx.chnl_opcode,
payload_size);
return;
}
v2e = (struct virtchnl2_event *)ctlq_msg->ctx.indirect.payload->va;
event = le32_to_cpu(v2e->event);
switch (event) {
Annotation
- Immediate include surface: `linux/export.h`, `net/libeth/rx.h`, `idpf.h`, `idpf_virtchnl.h`, `idpf_ptp.h`.
- Detected declarations: `struct idpf_vc_xn_manager`, `struct idpf_chunked_msg_params`, `function idpf_handle_event_link`, `function idpf_recv_event_msg`, `function idpf_mb_clean`, `function idpf_ptp_is_mb_msg`, `function idpf_prepare_ptp_mb_msg`, `function idpf_prepare_ptp_mb_msg`, `function idpf_vc_xn_release_bufs`, `function idpf_vc_xn_init`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.