drivers/net/hyperv/netvsc_bpf.c
Source file repositories/reference/linux-study-clean/drivers/net/hyperv/netvsc_bpf.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/hyperv/netvsc_bpf.c- Extension
.c- Size
- 6257 bytes
- Lines
- 293
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/netdevice.hlinux/etherdevice.hlinux/ethtool.hlinux/netpoll.hlinux/bpf.hlinux/bpf_trace.hlinux/kernel.hnet/xdp.hlinux/mutex.hlinux/rtnetlink.hhyperv_net.h
Detected Declarations
function netvsc_run_xdpfunction netvsc_xdp_fraglenfunction netvsc_xdp_setfunction netvsc_vf_setxdpfunction netvsc_bpffunction netvsc_ndoxdp_xmit_fmfunction netvsc_ndoxdp_xmitfunction netif_carrier_ok
Annotated Snippet
const struct net_device_ops *vf_ops;
struct netvsc_stats_tx *tx_stats;
struct netvsc_device *nvsc_dev;
struct net_device *vf_netdev;
int i, count = 0;
u16 q_idx;
/* Don't transmit if netvsc_device is gone */
nvsc_dev = rcu_dereference_bh(ndev_ctx->nvdev);
if (unlikely(!nvsc_dev || nvsc_dev->destroy))
return 0;
/* If VF is present and up then redirect packets to it.
* Skip the VF if it is marked down or has no carrier.
* If netpoll is in uses, then VF can not be used either.
*/
vf_netdev = rcu_dereference_bh(ndev_ctx->vf_netdev);
if (vf_netdev && netif_running(vf_netdev) &&
netif_carrier_ok(vf_netdev) && !netpoll_tx_running(ndev) &&
vf_netdev->netdev_ops->ndo_xdp_xmit &&
ndev_ctx->data_path_is_vf) {
vf_ops = vf_netdev->netdev_ops;
return vf_ops->ndo_xdp_xmit(vf_netdev, n, frames, flags);
}
q_idx = smp_processor_id() % ndev->real_num_tx_queues;
for (i = 0; i < n; i++) {
if (netvsc_ndoxdp_xmit_fm(ndev, frames[i], q_idx))
break;
count++;
}
tx_stats = &nvsc_dev->chan_table[q_idx].tx_stats;
u64_stats_update_begin(&tx_stats->syncp);
tx_stats->xdp_xmit += count;
u64_stats_update_end(&tx_stats->syncp);
return count;
}
Annotation
- Immediate include surface: `linux/netdevice.h`, `linux/etherdevice.h`, `linux/ethtool.h`, `linux/netpoll.h`, `linux/bpf.h`, `linux/bpf_trace.h`, `linux/kernel.h`, `net/xdp.h`.
- Detected declarations: `function netvsc_run_xdp`, `function netvsc_xdp_fraglen`, `function netvsc_xdp_set`, `function netvsc_vf_setxdp`, `function netvsc_bpf`, `function netvsc_ndoxdp_xmit_fm`, `function netvsc_ndoxdp_xmit`, `function netif_carrier_ok`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern 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.