drivers/net/ethernet/renesas/rtsn.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/renesas/rtsn.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/renesas/rtsn.c- Extension
.c- Size
- 31170 bytes
- Lines
- 1368
- 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/clk.hlinux/dma-mapping.hlinux/etherdevice.hlinux/ethtool.hlinux/module.hlinux/net_tstamp.hlinux/of.hlinux/of_mdio.hlinux/of_net.hlinux/phy.hlinux/platform_device.hlinux/pm_runtime.hlinux/reset.hlinux/spinlock.hrtsn.hrcar_gen4_ptp.h
Detected Declarations
struct rtsn_privatefunction rtsn_readfunction rtsn_writefunction rtsn_modifyfunction rtsn_reg_waitfunction rtsn_ctrl_data_irqfunction rtsn_tx_freefunction rtsn_rxfunction rtsn_pollfunction rtsn_desc_allocfunction rtsn_desc_freefunction rtsn_chain_freefunction rtsn_chain_initfunction rtsn_chain_formatfunction rtsn_dmac_initfunction rtsn_read_modefunction rtsn_wait_modefunction rtsn_change_modefunction rtsn_get_data_irq_statusfunction rtsn_irqfunction rtsn_request_irqfunction rtsn_free_irqsfunction rtsn_request_irqsfunction rtsn_resetfunction rtsn_axibmi_initfunction rtsn_mhd_initfunction rtsn_get_phy_paramsfunction rtsn_set_phy_interfacefunction rtsn_set_ratefunction rtsn_rmac_initfunction rtsn_hw_initfunction rtsn_mii_accessfunction rtsn_mii_readfunction rtsn_mii_writefunction rtsn_mdio_allocfunction rtsn_mdio_freefunction rtsn_adjust_linkfunction rtsn_phy_initfunction rtsn_phy_deinitfunction rtsn_initfunction rtsn_deinitfunction rtsn_parse_mac_addressfunction rtsn_openfunction rtsn_stopfunction rtsn_start_xmitfunction rtsn_get_stats64function rtsn_do_ioctlfunction rtsn_hwtstamp_get
Annotated Snippet
static const struct net_device_ops rtsn_netdev_ops = {
.ndo_open = rtsn_open,
.ndo_stop = rtsn_stop,
.ndo_start_xmit = rtsn_start_xmit,
.ndo_get_stats64 = rtsn_get_stats64,
.ndo_eth_ioctl = rtsn_do_ioctl,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = eth_mac_addr,
.ndo_hwtstamp_set = rtsn_hwtstamp_set,
.ndo_hwtstamp_get = rtsn_hwtstamp_get,
};
static int rtsn_get_ts_info(struct net_device *ndev,
struct kernel_ethtool_ts_info *info)
{
struct rtsn_private *priv = netdev_priv(ndev);
info->phc_index = rcar_gen4_ptp_clock_index(priv->ptp_priv);
info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE |
SOF_TIMESTAMPING_TX_HARDWARE |
SOF_TIMESTAMPING_RX_HARDWARE |
SOF_TIMESTAMPING_RAW_HARDWARE;
info->tx_types = BIT(HWTSTAMP_TX_OFF) | BIT(HWTSTAMP_TX_ON);
info->rx_filters = BIT(HWTSTAMP_FILTER_NONE) | BIT(HWTSTAMP_FILTER_ALL);
return 0;
}
static const struct ethtool_ops rtsn_ethtool_ops = {
.nway_reset = phy_ethtool_nway_reset,
.get_link = ethtool_op_get_link,
.get_ts_info = rtsn_get_ts_info,
.get_link_ksettings = phy_ethtool_get_link_ksettings,
.set_link_ksettings = phy_ethtool_set_link_ksettings,
};
static const struct of_device_id rtsn_match_table[] = {
{ .compatible = "renesas,r8a779g0-ethertsn", },
{ /* Sentinel */ }
};
MODULE_DEVICE_TABLE(of, rtsn_match_table);
static int rtsn_probe(struct platform_device *pdev)
{
struct rtsn_private *priv;
struct net_device *ndev;
void __iomem *ptpaddr;
struct resource *res;
int ret;
ndev = alloc_etherdev_mqs(sizeof(struct rtsn_private), TX_NUM_CHAINS,
RX_NUM_CHAINS);
if (!ndev)
return -ENOMEM;
priv = netdev_priv(ndev);
priv->pdev = pdev;
priv->ndev = ndev;
spin_lock_init(&priv->lock);
platform_set_drvdata(pdev, priv);
priv->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(priv->clk)) {
ret = PTR_ERR(priv->clk);
goto error_free;
}
priv->reset = devm_reset_control_get(&pdev->dev, NULL);
if (IS_ERR(priv->reset)) {
ret = PTR_ERR(priv->reset);
goto error_free;
}
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "tsnes");
if (!res) {
dev_err(&pdev->dev, "Can't find tsnes resource\n");
ret = -EINVAL;
goto error_free;
}
priv->base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(priv->base)) {
ret = PTR_ERR(priv->base);
goto error_free;
}
SET_NETDEV_DEV(ndev, &pdev->dev);
Annotation
- Immediate include surface: `linux/clk.h`, `linux/dma-mapping.h`, `linux/etherdevice.h`, `linux/ethtool.h`, `linux/module.h`, `linux/net_tstamp.h`, `linux/of.h`, `linux/of_mdio.h`.
- Detected declarations: `struct rtsn_private`, `function rtsn_read`, `function rtsn_write`, `function rtsn_modify`, `function rtsn_reg_wait`, `function rtsn_ctrl_data_irq`, `function rtsn_tx_free`, `function rtsn_rx`, `function rtsn_poll`, `function rtsn_desc_alloc`.
- 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.