arch/um/drivers/vector_kern.c
Source file repositories/reference/linux-study-clean/arch/um/drivers/vector_kern.c
File Facts
- System
- Linux kernel
- Corpus path
arch/um/drivers/vector_kern.c- Extension
.c- Size
- 42846 bytes
- Lines
- 1767
- Domain
- Architecture Layer
- Bucket
- arch/um
- Inferred role
- Architecture Layer: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- 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
linux/memblock.hlinux/etherdevice.hlinux/ethtool.hlinux/hex.hlinux/inetdevice.hlinux/init.hlinux/list.hlinux/netdevice.hlinux/platform_device.hlinux/rtnetlink.hlinux/skbuff.hlinux/slab.hlinux/interrupt.hlinux/firmware.hlinux/fs.hasm/atomic.huapi/linux/filter.hinit.hirq_kern.hirq_user.hos.hmconsole_kern.hvector_user.hvector_kern.h
Detected Declarations
struct vector_cmd_line_argstruct vector_devicefunction vector_reset_statsfunction get_mtufunction get_bpf_flashfunction get_depthfunction get_headroomfunction get_req_sizefunction get_transport_optionsfunction vector_advanceheadfunction vector_advancetailfunction prep_msgfunction vector_enqueuefunction consume_vector_skbsfunction vector_sendfunction destroy_queuefunction napi_gro_receivefunction prep_queue_for_rxfunction vector_parsefunction vector_configfunction vector_idfunction vector_removefunction vector_device_releasefunction vector_legacy_rxfunction writev_txfunction vector_mmsg_rxfunction vector_net_start_xmitfunction vector_rx_interruptfunction vector_tx_interruptfunction vector_net_closefunction vector_pollfunction vector_reset_txfunction vector_net_openfunction vector_net_set_multicast_listfunction vector_net_tx_timeoutfunction vector_fix_featuresfunction vector_set_featuresfunction vector_net_poll_controllerfunction vector_net_get_drvinfofunction vector_net_load_bpf_flashfunction vector_get_ringparamfunction vector_get_stringsfunction vector_get_sset_countfunction vector_get_ethtool_statsfunction vector_get_coalescefunction vector_set_coalescefunction vector_timer_expirefunction vector_setup_etheraddr
Annotated Snippet
static const struct net_device_ops vector_netdev_ops = {
.ndo_open = vector_net_open,
.ndo_stop = vector_net_close,
.ndo_start_xmit = vector_net_start_xmit,
.ndo_set_rx_mode = vector_net_set_multicast_list,
.ndo_tx_timeout = vector_net_tx_timeout,
.ndo_set_mac_address = eth_mac_addr,
.ndo_validate_addr = eth_validate_addr,
.ndo_fix_features = vector_fix_features,
.ndo_set_features = vector_set_features,
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = vector_net_poll_controller,
#endif
};
static void vector_timer_expire(struct timer_list *t)
{
struct vector_private *vp = timer_container_of(vp, t, tl);
vp->estats.tx_kicks++;
napi_schedule(&vp->napi);
}
static void vector_setup_etheraddr(struct net_device *dev, char *str)
{
u8 addr[ETH_ALEN];
if (str == NULL)
goto random;
if (!mac_pton(str, addr)) {
netdev_err(dev,
"Failed to parse '%s' as an ethernet address\n", str);
goto random;
}
if (is_multicast_ether_addr(addr)) {
netdev_err(dev,
"Attempt to assign a multicast ethernet address to a device disallowed\n");
goto random;
}
if (!is_valid_ether_addr(addr)) {
netdev_err(dev,
"Attempt to assign an invalid ethernet address to a device disallowed\n");
goto random;
}
if (!is_local_ether_addr(addr)) {
netdev_warn(dev, "Warning: Assigning a globally valid ethernet address to a device\n");
netdev_warn(dev, "You should set the 2nd rightmost bit in the first byte of the MAC,\n");
netdev_warn(dev, "i.e. %02x:%02x:%02x:%02x:%02x:%02x\n",
addr[0] | 0x02, addr[1], addr[2], addr[3], addr[4], addr[5]);
}
eth_hw_addr_set(dev, addr);
return;
random:
netdev_info(dev, "Choosing a random ethernet address\n");
eth_hw_addr_random(dev);
}
static void vector_eth_configure(
int n,
struct arglist *def
)
{
struct vector_device *device;
struct net_device *dev;
struct vector_private *vp;
int err;
device = kzalloc_obj(*device);
if (device == NULL) {
pr_err("Failed to allocate struct vector_device for vec%d\n", n);
return;
}
dev = alloc_etherdev(sizeof(struct vector_private));
if (dev == NULL) {
pr_err("Failed to allocate struct net_device for vec%d\n", n);
goto out_free_device;
}
dev->mtu = get_mtu(def);
INIT_LIST_HEAD(&device->list);
device->unit = n;
/* If this name ends up conflicting with an existing registered
* netdevice, that is OK, register_netdev{,ice}() will notice this
* and fail.
*/
snprintf(dev->name, sizeof(dev->name), "vec%d", n);
Annotation
- Immediate include surface: `linux/memblock.h`, `linux/etherdevice.h`, `linux/ethtool.h`, `linux/hex.h`, `linux/inetdevice.h`, `linux/init.h`, `linux/list.h`, `linux/netdevice.h`.
- Detected declarations: `struct vector_cmd_line_arg`, `struct vector_device`, `function vector_reset_stats`, `function get_mtu`, `function get_bpf_flash`, `function get_depth`, `function get_headroom`, `function get_req_size`, `function get_transport_options`, `function vector_advancehead`.
- Atlas domain: Architecture Layer / arch/um.
- 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.