drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c- Extension
.c- Size
- 38548 bytes
- Lines
- 1491
- 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
asm/byteorder.hlinux/brcmphy.hlinux/clk.hlinux/delay.hlinux/etherdevice.hlinux/netdevice.hlinux/of_net.hlinux/of_mdio.hlinux/phy.hlinux/phy_fixed.hlinux/ptp_classify.hlinux/platform_device.hnet/ip.hnet/ipv6.hnet/page_pool/helpers.hbcmasp.hbcmasp_intf_defs.h
Detected Declarations
function incr_ringfunction incr_last_bytefunction incr_first_bytefunction bcmasp_enable_txfunction bcmasp_enable_rxfunction bcmasp_set_rx_modefunction netdev_for_each_mc_addrfunction netdev_for_each_uc_addrfunction bcmasp_clean_txcbfunction tx_spb_ring_fullfunction bcmasp_xmitfunction umac_reset_and_initfunction umac_enable_setfunction bcmasp_tx_reclaimfunction bcmasp_tx_pollfunction bcmasp_rx_pollfunction bcmasp_adj_linkfunction bcmasp_rx_page_pool_createfunction bcmasp_alloc_rx_buffersfunction bcmasp_reclaim_rx_buffersfunction bcmasp_alloc_buffersfunction bcmasp_reclaim_free_buffersfunction bcmasp_init_rxfunction bcmasp_init_txfunction bcmasp_ephy_enable_setfunction bcmasp_rgmii_mode_en_setfunction bcmasp_phy_hw_unpreparefunction bcmasp_netif_deinitfunction bcmasp_stopfunction bcmasp_phy_hw_preparefunction bcmasp_phy_iface_for_connectfunction bcmasp_phy_attachfunction bcmasp_netif_initfunction bcmasp_openfunction bcmasp_tx_timeoutfunction bcmasp_get_phys_port_namefunction bcmasp_get_stats64function bcmasp_map_resfunction bcmasp_interface_destroyfunction bcmasp_suspend_to_wolfunction bcmasp_interface_suspendfunction bcmasp_resume_from_wolfunction bcmasp_interface_resume
Annotated Snippet
static const struct net_device_ops bcmasp_netdev_ops = {
.ndo_open = bcmasp_open,
.ndo_stop = bcmasp_stop,
.ndo_start_xmit = bcmasp_xmit,
.ndo_tx_timeout = bcmasp_tx_timeout,
.ndo_set_rx_mode = bcmasp_set_rx_mode,
.ndo_get_phys_port_name = bcmasp_get_phys_port_name,
.ndo_eth_ioctl = phy_do_ioctl_running,
.ndo_set_mac_address = eth_mac_addr,
.ndo_get_stats64 = bcmasp_get_stats64,
};
static void bcmasp_map_res(struct bcmasp_priv *priv, struct bcmasp_intf *intf)
{
/* Per port */
intf->res.umac = priv->base + UMC_OFFSET(intf);
intf->res.umac2fb = priv->base + (UMAC2FB_OFFSET + priv->rx_ctrl_offset +
(intf->port * 0x4));
intf->res.rgmii = priv->base + RGMII_OFFSET(intf);
/* Per ch */
intf->tx_spb_dma = priv->base + TX_SPB_DMA_OFFSET(intf);
intf->res.tx_spb_ctrl = priv->base + TX_SPB_CTRL_OFFSET(intf);
intf->res.tx_spb_top = priv->base + TX_SPB_TOP_OFFSET(intf);
intf->res.tx_epkt_core = priv->base + TX_EPKT_C_OFFSET(intf);
intf->res.tx_pause_ctrl = priv->base + TX_PAUSE_CTRL_OFFSET(intf);
intf->rx_edpkt_dma = priv->base + RX_EDPKT_DMA_OFFSET(intf);
intf->rx_edpkt_cfg = priv->base + RX_EDPKT_CFG_OFFSET(intf);
}
struct bcmasp_intf *bcmasp_interface_create(struct bcmasp_priv *priv,
struct device_node *ndev_dn, int i)
{
struct device *dev = &priv->pdev->dev;
struct bcmasp_intf *intf;
struct net_device *ndev;
int ch, port, ret;
if (of_property_read_u32(ndev_dn, "reg", &port)) {
dev_warn(dev, "%s: invalid port number\n", ndev_dn->name);
goto err;
}
if (of_property_read_u32(ndev_dn, "brcm,channel", &ch)) {
dev_warn(dev, "%s: invalid ch number\n", ndev_dn->name);
goto err;
}
ndev = alloc_etherdev(sizeof(struct bcmasp_intf));
if (!ndev) {
dev_warn(dev, "%s: unable to alloc ndev\n", ndev_dn->name);
goto err;
}
intf = netdev_priv(ndev);
intf->parent = priv;
intf->ndev = ndev;
intf->channel = ch;
intf->port = port;
intf->ndev_dn = ndev_dn;
intf->index = i;
ret = of_get_phy_mode(ndev_dn, &intf->phy_interface);
if (ret < 0) {
dev_err(dev, "invalid PHY mode property\n");
goto err_free_netdev;
}
if (intf->phy_interface == PHY_INTERFACE_MODE_INTERNAL)
intf->internal_phy = true;
intf->phy_dn = of_parse_phandle(ndev_dn, "phy-handle", 0);
if (!intf->phy_dn && of_phy_is_fixed_link(ndev_dn)) {
ret = of_phy_register_fixed_link(ndev_dn);
if (ret) {
dev_warn(dev, "%s: failed to register fixed PHY\n",
ndev_dn->name);
goto err_free_netdev;
}
intf->phy_dn = ndev_dn;
}
/* Map resource */
bcmasp_map_res(priv, intf);
if ((!phy_interface_mode_is_rgmii(intf->phy_interface) &&
intf->phy_interface != PHY_INTERFACE_MODE_MII &&
intf->phy_interface != PHY_INTERFACE_MODE_INTERNAL) ||
(intf->port != 1 && intf->internal_phy)) {
Annotation
- Immediate include surface: `asm/byteorder.h`, `linux/brcmphy.h`, `linux/clk.h`, `linux/delay.h`, `linux/etherdevice.h`, `linux/netdevice.h`, `linux/of_net.h`, `linux/of_mdio.h`.
- Detected declarations: `function incr_ring`, `function incr_last_byte`, `function incr_first_byte`, `function bcmasp_enable_tx`, `function bcmasp_enable_rx`, `function bcmasp_set_rx_mode`, `function netdev_for_each_mc_addr`, `function netdev_for_each_uc_addr`, `function bcmasp_clean_txcb`, `function tx_spb_ring_full`.
- 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.