drivers/net/ethernet/ti/cpsw_new.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/ti/cpsw_new.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/ti/cpsw_new.c- Extension
.c- Size
- 54657 bytes
- Lines
- 2170
- 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
linux/io.hlinux/clk.hlinux/platform_device.hlinux/timer.hlinux/module.hlinux/irqreturn.hlinux/interrupt.hlinux/if_ether.hlinux/etherdevice.hlinux/net_tstamp.hlinux/phy.hlinux/phy/phy.hlinux/delay.hlinux/pinctrl/consumer.hlinux/pm_runtime.hlinux/gpio/consumer.hlinux/of.hlinux/of_mdio.hlinux/of_net.hlinux/of_platform.hlinux/if_vlan.hlinux/kmemleak.hlinux/sys_soc.hnet/switchdev.hnet/page_pool/helpers.hnet/pkt_cls.hnet/devlink.hcpsw.hcpsw_ale.hcpsw_priv.hcpsw_sl.hcpsw_switchdev.h
Detected Declarations
struct cpsw_devlinkenum cpsw_devlink_param_idfunction cpsw_slave_index_privfunction cpsw_is_switch_enfunction cpsw_set_promisciousfunction cpsw_set_mcfunction cpsw_update_vlan_mcfunction cpsw_add_mc_addrfunction cpsw_del_mc_addrfunction cpsw_purge_vlan_mcfunction cpsw_purge_all_mcfunction cpsw_ndo_set_rx_mode_workfunction cpsw_ndo_set_rx_modefunction cpsw_rxbuf_total_lenfunction cpsw_rx_handlerfunction cpsw_add_vlan_ale_entryfunction cpsw_ndo_vlan_rx_add_vidfunction cpsw_restore_vlansfunction cpsw_restorefunction cpsw_init_stp_ale_entryfunction cpsw_init_host_port_switchfunction cpsw_init_host_port_dual_macfunction cpsw_init_host_portfunction cpsw_port_add_dual_emac_def_ale_entriesfunction cpsw_port_add_switch_def_ale_entriesfunction cpsw_adjust_linkfunction cpsw_slave_openfunction cpsw_ndo_stopfunction cpsw_ndo_openfunction cpsw_ndo_start_xmitfunction cpsw_ndo_set_mac_addressfunction cpsw_ndo_vlan_rx_kill_vidfunction cpsw_ndo_get_phys_port_namefunction cpsw_ndo_poll_controllerfunction cpsw_ndo_xdp_xmitfunction cpsw_get_port_parent_idfunction cpsw_get_drvinfofunction cpsw_set_pauseparamfunction cpsw_set_channelsfunction cpsw_probe_dtfunction for_each_child_of_nodefunction cpsw_remove_dtfunction cpsw_create_portsfunction cpsw_unregister_portsfunction cpsw_register_portsfunction cpsw_port_dev_checkfunction cpsw_port_offload_fwd_mark_updatefunction cpsw_netdevice_port_link
Annotated Snippet
static const struct net_device_ops cpsw_netdev_ops = {
.ndo_open = cpsw_ndo_open,
.ndo_stop = cpsw_ndo_stop,
.ndo_start_xmit = cpsw_ndo_start_xmit,
.ndo_set_mac_address = cpsw_ndo_set_mac_address,
.ndo_eth_ioctl = phy_do_ioctl_running,
.ndo_validate_addr = eth_validate_addr,
.ndo_tx_timeout = cpsw_ndo_tx_timeout,
.ndo_set_rx_mode = cpsw_ndo_set_rx_mode,
.ndo_set_tx_maxrate = cpsw_ndo_set_tx_maxrate,
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = cpsw_ndo_poll_controller,
#endif
.ndo_vlan_rx_add_vid = cpsw_ndo_vlan_rx_add_vid,
.ndo_vlan_rx_kill_vid = cpsw_ndo_vlan_rx_kill_vid,
.ndo_setup_tc = cpsw_ndo_setup_tc,
.ndo_get_phys_port_name = cpsw_ndo_get_phys_port_name,
.ndo_bpf = cpsw_ndo_bpf,
.ndo_xdp_xmit = cpsw_ndo_xdp_xmit,
.ndo_get_port_parent_id = cpsw_get_port_parent_id,
.ndo_hwtstamp_get = cpsw_hwtstamp_get,
.ndo_hwtstamp_set = cpsw_hwtstamp_set,
};
static void cpsw_get_drvinfo(struct net_device *ndev,
struct ethtool_drvinfo *info)
{
struct cpsw_common *cpsw = ndev_to_cpsw(ndev);
struct platform_device *pdev;
pdev = to_platform_device(cpsw->dev);
strscpy(info->driver, "cpsw-switch", sizeof(info->driver));
strscpy(info->version, "2.0", sizeof(info->version));
strscpy(info->bus_info, pdev->name, sizeof(info->bus_info));
}
static int cpsw_set_pauseparam(struct net_device *ndev,
struct ethtool_pauseparam *pause)
{
struct cpsw_common *cpsw = ndev_to_cpsw(ndev);
struct cpsw_priv *priv = netdev_priv(ndev);
int slave_no;
slave_no = cpsw_slave_index(cpsw, priv);
if (!cpsw->slaves[slave_no].phy)
return -EINVAL;
if (!phy_validate_pause(cpsw->slaves[slave_no].phy, pause))
return -EINVAL;
priv->rx_pause = pause->rx_pause ? true : false;
priv->tx_pause = pause->tx_pause ? true : false;
phy_set_asym_pause(cpsw->slaves[slave_no].phy,
priv->rx_pause, priv->tx_pause);
return 0;
}
static int cpsw_set_channels(struct net_device *ndev,
struct ethtool_channels *chs)
{
return cpsw_set_channels_common(ndev, chs, cpsw_rx_handler);
}
static const struct ethtool_ops cpsw_ethtool_ops = {
.supported_coalesce_params = ETHTOOL_COALESCE_RX_USECS,
.get_drvinfo = cpsw_get_drvinfo,
.get_msglevel = cpsw_get_msglevel,
.set_msglevel = cpsw_set_msglevel,
.get_link = ethtool_op_get_link,
.get_ts_info = cpsw_get_ts_info,
.get_coalesce = cpsw_get_coalesce,
.set_coalesce = cpsw_set_coalesce,
.get_sset_count = cpsw_get_sset_count,
.get_strings = cpsw_get_strings,
.get_ethtool_stats = cpsw_get_ethtool_stats,
.get_pauseparam = cpsw_get_pauseparam,
.set_pauseparam = cpsw_set_pauseparam,
.get_wol = cpsw_get_wol,
.set_wol = cpsw_set_wol,
.get_regs_len = cpsw_get_regs_len,
.get_regs = cpsw_get_regs,
.begin = cpsw_ethtool_op_begin,
.complete = cpsw_ethtool_op_complete,
.get_channels = cpsw_get_channels,
.set_channels = cpsw_set_channels,
.get_link_ksettings = cpsw_get_link_ksettings,
.set_link_ksettings = cpsw_set_link_ksettings,
.get_eee = cpsw_get_eee,
Annotation
- Immediate include surface: `linux/io.h`, `linux/clk.h`, `linux/platform_device.h`, `linux/timer.h`, `linux/module.h`, `linux/irqreturn.h`, `linux/interrupt.h`, `linux/if_ether.h`.
- Detected declarations: `struct cpsw_devlink`, `enum cpsw_devlink_param_id`, `function cpsw_slave_index_priv`, `function cpsw_is_switch_en`, `function cpsw_set_promiscious`, `function cpsw_set_mc`, `function cpsw_update_vlan_mc`, `function cpsw_add_mc_addr`, `function cpsw_del_mc_addr`, `function cpsw_purge_vlan_mc`.
- 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.