drivers/net/xen-netback/interface.c
Source file repositories/reference/linux-study-clean/drivers/net/xen-netback/interface.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/xen-netback/interface.c- Extension
.c- Size
- 22155 bytes
- Lines
- 858
- 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.
- 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
common.hlinux/kthread.hlinux/sched/task.hlinux/ethtool.hlinux/rtnetlink.hlinux/if_vlan.hlinux/vmalloc.hxen/events.hasm/xen/hypercall.hxen/balloon.h
Detected Declarations
function filefunction xenvif_skb_zerocopy_completefunction xenvif_schedulablefunction xenvif_handle_tx_interruptfunction xenvif_tx_interruptfunction xenvif_pollfunction xenvif_handle_rx_interruptfunction xenvif_rx_interruptfunction xenvif_interruptfunction xenvif_select_queuefunction xenvif_start_xmitfunction xenvif_upfunction xenvif_downfunction xenvif_openfunction xenvif_closefunction xenvif_change_mtufunction xenvif_fix_featuresfunction xenvif_get_sset_countfunction xenvif_get_ethtool_statsfunction xenvif_get_stringsfunction xenvif_init_queuefunction xenvif_carrier_onfunction xenvif_connect_ctrlfunction xenvif_disconnect_queuefunction xenvif_connect_datafunction xenvif_carrier_offfunction xenvif_disconnect_datafunction xenvif_disconnect_ctrlfunction xenvif_freefunction xenvif_free
Annotated Snippet
static const struct net_device_ops xenvif_netdev_ops = {
.ndo_select_queue = xenvif_select_queue,
.ndo_start_xmit = xenvif_start_xmit,
.ndo_get_stats = xenvif_get_stats,
.ndo_open = xenvif_open,
.ndo_stop = xenvif_close,
.ndo_change_mtu = xenvif_change_mtu,
.ndo_fix_features = xenvif_fix_features,
.ndo_set_mac_address = eth_mac_addr,
.ndo_validate_addr = eth_validate_addr,
};
struct xenvif *xenvif_alloc(struct device *parent, domid_t domid,
unsigned int handle)
{
static const u8 dummy_addr[ETH_ALEN] = {
0xfe, 0xff, 0xff, 0xff, 0xff, 0xff,
};
int err;
struct net_device *dev;
struct xenvif *vif;
char name[IFNAMSIZ] = {};
snprintf(name, IFNAMSIZ - 1, "vif%u.%u", domid, handle);
/* Allocate a netdev with the max. supported number of queues.
* When the guest selects the desired number, it will be updated
* via netif_set_real_num_*_queues().
*/
dev = alloc_netdev_mq(sizeof(struct xenvif), name, NET_NAME_UNKNOWN,
ether_setup, xenvif_max_queues);
if (dev == NULL) {
pr_warn("Could not allocate netdev for %s\n", name);
return ERR_PTR(-ENOMEM);
}
SET_NETDEV_DEV(dev, parent);
vif = netdev_priv(dev);
vif->domid = domid;
vif->handle = handle;
vif->can_sg = 1;
vif->ip_csum = 1;
vif->dev = dev;
vif->disabled = false;
vif->drain_timeout = msecs_to_jiffies(rx_drain_timeout_msecs);
vif->stall_timeout = msecs_to_jiffies(rx_stall_timeout_msecs);
/* Start out with no queues. */
vif->queues = NULL;
vif->num_queues = 0;
vif->xdp_headroom = 0;
spin_lock_init(&vif->lock);
INIT_LIST_HEAD(&vif->fe_mcast_addr);
dev->netdev_ops = &xenvif_netdev_ops;
dev->hw_features = NETIF_F_SG |
NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_FRAGLIST;
dev->features = dev->hw_features | NETIF_F_RXCSUM;
dev->ethtool_ops = &xenvif_ethtool_ops;
dev->min_mtu = ETH_MIN_MTU;
dev->max_mtu = ETH_MAX_MTU - VLAN_ETH_HLEN;
/*
* Initialise a dummy MAC address. We choose the numerically
* largest non-broadcast address to prevent the address getting
* stolen by an Ethernet bridge for STP purposes.
* (FE:FF:FF:FF:FF:FF)
*/
eth_hw_addr_set(dev, dummy_addr);
netif_carrier_off(dev);
err = register_netdev(dev);
if (err) {
netdev_warn(dev, "Could not register device: err=%d\n", err);
free_netdev(dev);
return ERR_PTR(err);
}
netdev_dbg(dev, "Successfully created xenvif\n");
__module_get(THIS_MODULE);
return vif;
}
Annotation
- Immediate include surface: `common.h`, `linux/kthread.h`, `linux/sched/task.h`, `linux/ethtool.h`, `linux/rtnetlink.h`, `linux/if_vlan.h`, `linux/vmalloc.h`, `xen/events.h`.
- Detected declarations: `function file`, `function xenvif_skb_zerocopy_complete`, `function xenvif_schedulable`, `function xenvif_handle_tx_interrupt`, `function xenvif_tx_interrupt`, `function xenvif_poll`, `function xenvif_handle_rx_interrupt`, `function xenvif_rx_interrupt`, `function xenvif_interrupt`, `function xenvif_select_queue`.
- 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.
- 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.