drivers/net/ethernet/altera/altera_tse_main.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/altera/altera_tse_main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/altera/altera_tse_main.c- Extension
.c- Size
- 40872 bytes
- Lines
- 1534
- 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/atomic.hlinux/delay.hlinux/etherdevice.hlinux/if_vlan.hlinux/init.hlinux/interrupt.hlinux/io.hlinux/kernel.hlinux/module.hlinux/mii.hlinux/mdio/mdio-regmap.hlinux/netdevice.hlinux/of.hlinux/of_mdio.hlinux/of_net.hlinux/pcs-lynx.hlinux/phy.hlinux/platform_device.hlinux/property.hlinux/regmap.hlinux/skbuff.hasm/cacheflush.haltera_utils.haltera_tse.haltera_sgdma.haltera_msgdma.h
Detected Declarations
function tse_tx_availfunction altera_tse_mdio_readfunction altera_tse_mdio_writefunction altera_tse_mdio_createfunction for_each_child_of_nodefunction altera_tse_mdio_destroyfunction tse_init_rx_bufferfunction tse_free_rx_bufferfunction tse_free_tx_bufferfunction alloc_init_skbufsfunction free_skbufsfunction tse_rx_refillfunction tse_rx_vlanfunction tse_rxfunction tse_tx_completefunction tse_pollfunction altera_isrfunction tse_start_xmitfunction altera_tse_phy_get_addr_mdio_createfunction tse_update_mac_addrfunction reset_macfunction init_macfunction tse_set_macfunction tse_change_mtufunction altera_tse_set_mcfilterfunction netdev_for_each_mc_addrfunction altera_tse_set_mcfilterallfunction tse_set_rx_mode_hashfilterfunction tse_set_rx_modefunction tse_openfunction tse_shutdownfunction alt_tse_mac_configfunction alt_tse_mac_link_downfunction request_and_mapfunction altera_tse_probefunction altera_tse_remove
Annotated Snippet
static struct net_device_ops altera_tse_netdev_ops = {
.ndo_open = tse_open,
.ndo_stop = tse_shutdown,
.ndo_start_xmit = tse_start_xmit,
.ndo_set_mac_address = eth_mac_addr,
.ndo_set_rx_mode = tse_set_rx_mode,
.ndo_change_mtu = tse_change_mtu,
.ndo_validate_addr = eth_validate_addr,
};
static void alt_tse_mac_config(struct phylink_config *config, unsigned int mode,
const struct phylink_link_state *state)
{
struct net_device *ndev = to_net_dev(config->dev);
struct altera_tse_private *priv = netdev_priv(ndev);
spin_lock(&priv->mac_cfg_lock);
reset_mac(priv);
tse_set_mac(priv, true);
spin_unlock(&priv->mac_cfg_lock);
}
static void alt_tse_mac_link_down(struct phylink_config *config,
unsigned int mode, phy_interface_t interface)
{
}
static void alt_tse_mac_link_up(struct phylink_config *config,
struct phy_device *phy, unsigned int mode,
phy_interface_t interface, int speed,
int duplex, bool tx_pause, bool rx_pause)
{
struct net_device *ndev = to_net_dev(config->dev);
struct altera_tse_private *priv = netdev_priv(ndev);
u32 ctrl;
ctrl = csrrd32(priv->mac_dev, tse_csroffs(command_config));
ctrl &= ~(MAC_CMDCFG_ENA_10 | MAC_CMDCFG_ETH_SPEED | MAC_CMDCFG_HD_ENA);
if (duplex == DUPLEX_HALF)
ctrl |= MAC_CMDCFG_HD_ENA;
if (speed == SPEED_1000)
ctrl |= MAC_CMDCFG_ETH_SPEED;
else if (speed == SPEED_10)
ctrl |= MAC_CMDCFG_ENA_10;
spin_lock(&priv->mac_cfg_lock);
csrwr32(ctrl, priv->mac_dev, tse_csroffs(command_config));
spin_unlock(&priv->mac_cfg_lock);
}
static struct phylink_pcs *alt_tse_select_pcs(struct phylink_config *config,
phy_interface_t interface)
{
struct net_device *ndev = to_net_dev(config->dev);
struct altera_tse_private *priv = netdev_priv(ndev);
if (interface == PHY_INTERFACE_MODE_SGMII ||
interface == PHY_INTERFACE_MODE_1000BASEX)
return priv->pcs;
else
return NULL;
}
static const struct phylink_mac_ops alt_tse_phylink_ops = {
.mac_config = alt_tse_mac_config,
.mac_link_down = alt_tse_mac_link_down,
.mac_link_up = alt_tse_mac_link_up,
.mac_select_pcs = alt_tse_select_pcs,
};
static int request_and_map(struct platform_device *pdev, const char *name,
struct resource **res, void __iomem **ptr)
{
struct device *device = &pdev->dev;
struct resource *region;
*res = platform_get_resource_byname(pdev, IORESOURCE_MEM, name);
if (*res == NULL) {
dev_err(device, "resource %s not defined\n", name);
return -ENODEV;
}
region = devm_request_mem_region(device, (*res)->start,
resource_size(*res), dev_name(device));
if (region == NULL) {
dev_err(device, "unable to request %s\n", name);
return -EBUSY;
}
Annotation
- Immediate include surface: `linux/atomic.h`, `linux/delay.h`, `linux/etherdevice.h`, `linux/if_vlan.h`, `linux/init.h`, `linux/interrupt.h`, `linux/io.h`, `linux/kernel.h`.
- Detected declarations: `function tse_tx_avail`, `function altera_tse_mdio_read`, `function altera_tse_mdio_write`, `function altera_tse_mdio_create`, `function for_each_child_of_node`, `function altera_tse_mdio_destroy`, `function tse_init_rx_buffer`, `function tse_free_rx_buffer`, `function tse_free_tx_buffer`, `function alloc_init_skbufs`.
- 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.