drivers/net/ethernet/renesas/rswitch_main.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/renesas/rswitch_main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/renesas/rswitch_main.c- Extension
.c- Size
- 57296 bytes
- Lines
- 2295
- 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/err.hlinux/etherdevice.hlinux/ethtool.hlinux/ip.hlinux/iopoll.hlinux/kernel.hlinux/list.hlinux/module.hlinux/net_tstamp.hlinux/of.hlinux/of_mdio.hlinux/of_net.hlinux/phy/phy.hlinux/platform_device.hlinux/pm.hlinux/pm_runtime.hlinux/rtnetlink.hlinux/slab.hlinux/spinlock.hlinux/sys_soc.hrswitch.hrswitch_l2.h
Detected Declarations
function Copyrightfunction rswitch_modifyfunction rswitch_resetfunction rswitch_clock_enablefunction rswitch_clock_disablefunction rswitch_agent_clock_is_enabledfunction rswitch_agent_clock_ctrlfunction rswitch_bpool_configfunction rswitch_coma_initfunction rswitch_top_initfunction rswitch_fwd_initfunction rswitch_gwca_change_modefunction rswitch_gwca_mcast_table_resetfunction rswitch_gwca_axi_ram_resetfunction rswitch_is_any_data_irqfunction rswitch_get_data_irq_statusfunction rswitch_enadis_data_irqfunction rswitch_ack_data_irqfunction rswitch_next_queue_indexfunction rswitch_get_num_cur_queuesfunction rswitch_is_queue_rxedfunction rswitch_gwca_queue_alloc_rx_buffunction rswitch_gwca_queue_freefunction rswitch_gwca_ts_queue_freefunction rswitch_gwca_queue_allocfunction rswitch_desc_set_dptrfunction rswitch_desc_get_dptrfunction rswitch_gwca_queue_formatfunction rswitch_gwca_ts_queue_fillfunction rswitch_gwca_queue_ext_ts_fillfunction rswitch_gwca_queue_ext_ts_formatfunction rswitch_gwca_linkfix_allocfunction rswitch_gwca_linkfix_freefunction rswitch_gwca_ts_queue_allocfunction rswitch_gwca_putfunction rswitch_txdmac_allocfunction rswitch_txdmac_freefunction rswitch_txdmac_initfunction rswitch_rxdmac_allocfunction rswitch_rxdmac_freefunction rswitch_rxdmac_initfunction rswitch_gwca_hw_initfunction rswitch_gwca_hw_deinitfunction rswitch_gwca_haltfunction rswitch_rxfunction rswitch_tx_freefunction rswitch_pollfunction rswitch_queue_interrupt
Annotated Snippet
static const struct net_device_ops rswitch_netdev_ops = {
.ndo_open = rswitch_open,
.ndo_stop = rswitch_stop,
.ndo_start_xmit = rswitch_start_xmit,
.ndo_get_stats = rswitch_get_stats,
.ndo_eth_ioctl = phy_do_ioctl_running,
.ndo_get_port_parent_id = rswitch_get_port_parent_id,
.ndo_get_phys_port_name = rswitch_get_phys_port_name,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = eth_mac_addr,
.ndo_hwtstamp_get = rswitch_hwstamp_get,
.ndo_hwtstamp_set = rswitch_hwstamp_set,
};
bool is_rdev(const struct net_device *ndev)
{
return (ndev->netdev_ops == &rswitch_netdev_ops);
}
static int rswitch_get_ts_info(struct net_device *ndev, struct kernel_ethtool_ts_info *info)
{
struct rswitch_device *rdev = netdev_priv(ndev);
info->phc_index = rcar_gen4_ptp_clock_index(rdev->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 rswitch_ethtool_ops = {
.get_ts_info = rswitch_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 renesas_eth_sw_of_table[] = {
{ .compatible = "renesas,r8a779f0-ether-switch", },
{ }
};
MODULE_DEVICE_TABLE(of, renesas_eth_sw_of_table);
static void rswitch_etha_init(struct rswitch_private *priv, unsigned int index)
{
struct rswitch_etha *etha = &priv->etha[index];
memset(etha, 0, sizeof(*etha));
etha->index = index;
etha->addr = priv->addr + RSWITCH_ETHA_OFFSET + index * RSWITCH_ETHA_SIZE;
etha->coma_addr = priv->addr;
/* MPIC.PSMCS = (clk [MHz] / (MDC frequency [MHz] * 2) - 1.
* Calculating PSMCS value as MDC frequency = 2.5MHz. So, multiply
* both the numerator and the denominator by 10.
*/
etha->psmcs = clk_get_rate(priv->clk) / 100000 / (25 * 2) - 1;
}
static int rswitch_device_alloc(struct rswitch_private *priv, unsigned int index)
{
struct platform_device *pdev = priv->pdev;
struct rswitch_device *rdev;
struct net_device *ndev;
int err;
if (index >= RSWITCH_NUM_PORTS)
return -EINVAL;
ndev = alloc_etherdev_mqs(sizeof(struct rswitch_device), 1, 1);
if (!ndev)
return -ENOMEM;
SET_NETDEV_DEV(ndev, &pdev->dev);
ether_setup(ndev);
rdev = netdev_priv(ndev);
rdev->ndev = ndev;
rdev->priv = priv;
priv->rdev[index] = rdev;
rdev->port = index;
rdev->etha = &priv->etha[index];
rdev->addr = priv->addr;
ndev->base_addr = (unsigned long)rdev->addr;
snprintf(ndev->name, IFNAMSIZ, "tsn%d", index);
ndev->netdev_ops = &rswitch_netdev_ops;
Annotation
- Immediate include surface: `linux/clk.h`, `linux/dma-mapping.h`, `linux/err.h`, `linux/etherdevice.h`, `linux/ethtool.h`, `linux/ip.h`, `linux/iopoll.h`, `linux/kernel.h`.
- Detected declarations: `function Copyright`, `function rswitch_modify`, `function rswitch_reset`, `function rswitch_clock_enable`, `function rswitch_clock_disable`, `function rswitch_agent_clock_is_enabled`, `function rswitch_agent_clock_ctrl`, `function rswitch_bpool_config`, `function rswitch_coma_init`, `function rswitch_top_init`.
- 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.