drivers/net/ethernet/engleder/tsnep_main.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/engleder/tsnep_main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/engleder/tsnep_main.c- Extension
.c- Size
- 69391 bytes
- Lines
- 2714
- 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.
- 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
tsnep.htsnep_hw.hlinux/module.hlinux/of.hlinux/of_net.hlinux/of_mdio.hlinux/interrupt.hlinux/etherdevice.hlinux/phy.hlinux/iopoll.hlinux/bpf.hlinux/bpf_trace.hnet/page_pool/helpers.hnet/xdp_sock_drv.h
Detected Declarations
function SKB_DATA_ALIGNfunction tsnep_disable_irqfunction tsnep_irqfunction tsnep_irq_txrxfunction tsnep_set_irq_coalescefunction tsnep_get_irq_coalescefunction tsnep_mdiobus_readfunction tsnep_mdiobus_writefunction tsnep_set_link_modefunction tsnep_phy_link_status_changefunction tsnep_phy_loopbackfunction tsnep_phy_openfunction tsnep_phy_closefunction tsnep_tx_ring_cleanupfunction tsnep_tx_ring_createfunction tsnep_tx_initfunction tsnep_tx_enablefunction tsnep_tx_disablefunction tsnep_tx_activatefunction tsnep_tx_desc_availablefunction tsnep_tx_map_fragfunction tsnep_tx_mapfunction tsnep_tx_unmapfunction tsnep_xmit_frame_ringfunction tsnep_xdp_tx_mapfunction tsnep_xdp_xmit_frame_ringfunction tsnep_xdp_xmit_flushfunction tsnep_xdp_xmit_backfunction tsnep_xdp_tx_map_zcfunction tsnep_xdp_xmit_frame_ring_zcfunction tsnep_xdp_xmit_zcfunction tsnep_tx_pollfunction tsnep_tx_pendingfunction tsnep_tx_openfunction tsnep_tx_closefunction tsnep_rx_ring_cleanupfunction tsnep_rx_ring_createfunction tsnep_rx_initfunction tsnep_rx_enablefunction tsnep_rx_disablefunction tsnep_rx_desc_availablefunction tsnep_rx_free_page_bufferfunction tsnep_rx_alloc_page_bufferfunction tsnep_rx_set_pagefunction tsnep_rx_alloc_bufferfunction tsnep_rx_reuse_bufferfunction tsnep_rx_activatefunction tsnep_rx_alloc
Annotated Snippet
static const struct net_device_ops tsnep_netdev_ops = {
.ndo_open = tsnep_netdev_open,
.ndo_stop = tsnep_netdev_close,
.ndo_start_xmit = tsnep_netdev_xmit_frame,
.ndo_eth_ioctl = phy_do_ioctl_running,
.ndo_set_rx_mode = tsnep_netdev_set_multicast,
.ndo_get_stats64 = tsnep_netdev_get_stats64,
.ndo_set_mac_address = tsnep_netdev_set_mac_address,
.ndo_set_features = tsnep_netdev_set_features,
.ndo_get_tstamp = tsnep_netdev_get_tstamp,
.ndo_setup_tc = tsnep_tc_setup,
.ndo_bpf = tsnep_netdev_bpf,
.ndo_xdp_xmit = tsnep_netdev_xdp_xmit,
.ndo_xsk_wakeup = tsnep_netdev_xsk_wakeup,
.ndo_hwtstamp_get = tsnep_ptp_hwtstamp_get,
.ndo_hwtstamp_set = tsnep_ptp_hwtstamp_set,
};
static int tsnep_mac_init(struct tsnep_adapter *adapter)
{
int retval;
/* initialize RX filtering, at least configured MAC address and
* broadcast are not filtered
*/
iowrite16(0, adapter->addr + TSNEP_RX_FILTER);
/* try to get MAC address in the following order:
* - device tree
* - valid MAC address already set
* - MAC address register if valid
* - random MAC address
*/
retval = of_get_mac_address(adapter->pdev->dev.of_node,
adapter->mac_address);
if (retval == -EPROBE_DEFER)
return retval;
if (retval && !is_valid_ether_addr(adapter->mac_address)) {
*(u32 *)adapter->mac_address =
ioread32(adapter->addr + TSNEP_MAC_ADDRESS_LOW);
*(u16 *)(adapter->mac_address + sizeof(u32)) =
ioread16(adapter->addr + TSNEP_MAC_ADDRESS_HIGH);
if (!is_valid_ether_addr(adapter->mac_address))
eth_random_addr(adapter->mac_address);
}
tsnep_mac_set_address(adapter, adapter->mac_address);
eth_hw_addr_set(adapter->netdev, adapter->mac_address);
return 0;
}
static int tsnep_mdio_init(struct tsnep_adapter *adapter)
{
struct device_node *np = adapter->pdev->dev.of_node;
int retval;
if (np) {
np = of_get_child_by_name(np, "mdio");
if (!np)
return 0;
adapter->suppress_preamble =
of_property_read_bool(np, "suppress-preamble");
}
adapter->mdiobus = devm_mdiobus_alloc(&adapter->pdev->dev);
if (!adapter->mdiobus) {
retval = -ENOMEM;
goto out;
}
adapter->mdiobus->priv = (void *)adapter;
adapter->mdiobus->parent = &adapter->pdev->dev;
adapter->mdiobus->read = tsnep_mdiobus_read;
adapter->mdiobus->write = tsnep_mdiobus_write;
adapter->mdiobus->name = TSNEP "-mdiobus";
snprintf(adapter->mdiobus->id, MII_BUS_ID_SIZE, "%s",
adapter->pdev->name);
/* do not scan broadcast address */
adapter->mdiobus->phy_mask = 0x0000001;
retval = of_mdiobus_register(adapter->mdiobus, np);
out:
of_node_put(np);
return retval;
Annotation
- Immediate include surface: `tsnep.h`, `tsnep_hw.h`, `linux/module.h`, `linux/of.h`, `linux/of_net.h`, `linux/of_mdio.h`, `linux/interrupt.h`, `linux/etherdevice.h`.
- Detected declarations: `function SKB_DATA_ALIGN`, `function tsnep_disable_irq`, `function tsnep_irq`, `function tsnep_irq_txrx`, `function tsnep_set_irq_coalesce`, `function tsnep_get_irq_coalesce`, `function tsnep_mdiobus_read`, `function tsnep_mdiobus_write`, `function tsnep_set_link_mode`, `function tsnep_phy_link_status_change`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern implementation candidate.
- 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.