drivers/net/ethernet/via/via-velocity.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/via/via-velocity.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/via/via-velocity.c- Extension
.c- Size
- 96228 bytes
- Lines
- 3744
- 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
linux/module.hlinux/types.hlinux/bitops.hlinux/init.hlinux/dma-mapping.hlinux/mm.hlinux/errno.hlinux/ioport.hlinux/pci.hlinux/kernel.hlinux/netdevice.hlinux/etherdevice.hlinux/skbuff.hlinux/delay.hlinux/timer.hlinux/slab.hlinux/interrupt.hlinux/string.hlinux/wait.hlinux/io.hlinux/if.hlinux/uaccess.hlinux/proc_fs.hlinux/of.hlinux/of_address.hlinux/of_irq.hlinux/inetdevice.hlinux/platform_device.hlinux/reboot.hlinux/ethtool.hlinux/mii.hlinux/in.h
Detected Declarations
enum velocity_bus_typefunction velocity_set_power_statefunction mac_get_cam_maskfunction mac_set_cam_maskfunction mac_set_vlan_cam_maskfunction mac_set_camfunction mac_set_vlan_camfunction mac_wol_resetfunction velocity_set_int_optfunction velocity_set_bool_optfunction velocity_get_optionsfunction velocity_init_cam_filterfunction velocity_vlan_rx_add_vidfunction velocity_vlan_rx_kill_vidfunction velocity_init_rx_ring_indexesfunction velocity_rx_resetfunction velocity_get_opt_media_modefunction safe_disable_mii_autopollfunction enable_mii_autopollfunction velocity_mii_readfunction mii_check_media_modefunction velocity_mii_writefunction set_mii_flow_controlfunction mii_set_auto_onfunction check_connection_typefunction velocity_set_media_modefunction velocity_print_link_statusfunction enable_flow_control_abilityfunction velocity_soft_resetfunction velocity_set_multifunction netdev_for_each_mc_addrfunction mii_initfunction suppressionfunction setup_adaptive_interruptsfunction velocity_init_registersfunction velocity_give_many_rx_descsfunction velocity_init_dma_ringsfunction velocity_set_rxbufsizefunction velocity_alloc_rx_buffunction velocity_rx_refillfunction velocity_free_rd_ringfunction velocity_init_rd_ringfunction velocity_init_td_ringfunction velocity_free_dma_ringsfunction velocity_init_ringsfunction velocity_free_tx_buffunction velocity_free_td_ring_entryfunction velocity_free_td_ring
Annotated Snippet
static const struct net_device_ops velocity_netdev_ops = {
.ndo_open = velocity_open,
.ndo_stop = velocity_close,
.ndo_start_xmit = velocity_xmit,
.ndo_get_stats = velocity_get_stats,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = eth_mac_addr,
.ndo_set_rx_mode = velocity_set_multi,
.ndo_change_mtu = velocity_change_mtu,
.ndo_eth_ioctl = velocity_ioctl,
.ndo_vlan_rx_add_vid = velocity_vlan_rx_add_vid,
.ndo_vlan_rx_kill_vid = velocity_vlan_rx_kill_vid,
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = velocity_poll_controller,
#endif
};
/**
* velocity_init_info - init private data
* @vptr: Velocity info
* @info: Board type
*
* Set up the initial velocity_info struct for the device that has been
* discovered.
*/
static void velocity_init_info(struct velocity_info *vptr,
const struct velocity_info_tbl *info)
{
vptr->chip_id = info->chip_id;
vptr->tx.numq = info->txqueue;
vptr->multicast_limit = MCAM_SIZE;
spin_lock_init(&vptr->lock);
}
/**
* velocity_get_pci_info - retrieve PCI info for device
* @vptr: velocity device
*
* Retrieve the PCI configuration space data that interests us from
* the kernel PCI layer
*/
static int velocity_get_pci_info(struct velocity_info *vptr)
{
struct pci_dev *pdev = vptr->pdev;
pci_set_master(pdev);
vptr->ioaddr = pci_resource_start(pdev, 0);
vptr->memaddr = pci_resource_start(pdev, 1);
if (!(pci_resource_flags(pdev, 0) & IORESOURCE_IO)) {
dev_err(&pdev->dev,
"region #0 is not an I/O resource, aborting.\n");
return -EINVAL;
}
if ((pci_resource_flags(pdev, 1) & IORESOURCE_IO)) {
dev_err(&pdev->dev,
"region #1 is an I/O resource, aborting.\n");
return -EINVAL;
}
if (pci_resource_len(pdev, 1) < VELOCITY_IO_SIZE) {
dev_err(&pdev->dev, "region #1 is too small.\n");
return -EINVAL;
}
return 0;
}
/**
* velocity_get_platform_info - retrieve platform info for device
* @vptr: velocity device
*
* Retrieve the Platform configuration data that interests us
*/
static int velocity_get_platform_info(struct velocity_info *vptr)
{
struct resource res;
int ret;
vptr->no_eeprom = of_property_read_bool(vptr->dev->of_node, "no-eeprom");
ret = of_address_to_resource(vptr->dev->of_node, 0, &res);
if (ret) {
dev_err(vptr->dev, "unable to find memory address\n");
return ret;
}
vptr->memaddr = res.start;
Annotation
- Immediate include surface: `linux/module.h`, `linux/types.h`, `linux/bitops.h`, `linux/init.h`, `linux/dma-mapping.h`, `linux/mm.h`, `linux/errno.h`, `linux/ioport.h`.
- Detected declarations: `enum velocity_bus_type`, `function velocity_set_power_state`, `function mac_get_cam_mask`, `function mac_set_cam_mask`, `function mac_set_vlan_cam_mask`, `function mac_set_cam`, `function mac_set_vlan_cam`, `function mac_wol_reset`, `function velocity_set_int_opt`, `function velocity_set_bool_opt`.
- 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.