drivers/net/ethernet/freescale/fman/mac.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/freescale/fman/mac.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/freescale/fman/mac.c- Extension
.c- Size
- 8602 bytes
- Lines
- 347
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/init.hlinux/module.hlinux/of_address.hlinux/of_platform.hlinux/of_net.hlinux/of_mdio.hlinux/device.hlinux/phy.hlinux/netdevice.hlinux/etherdevice.hlinux/libfdt_env.hlinux/platform_device.hmac.hfman_mac.hfman_dtsec.hfman_tgec.hfman_memac.h
Detected Declarations
struct mac_priv_sstruct mac_addressfunction mac_exceptionfunction mac_probefunction mac_remove
Annotated Snippet
struct mac_priv_s {
u8 cell_index;
struct fman *fman;
struct platform_device *eth_dev;
u16 speed;
};
struct mac_address {
u8 addr[ETH_ALEN];
struct list_head list;
};
static void mac_exception(struct mac_device *mac_dev,
enum fman_mac_exceptions ex)
{
if (ex == FM_MAC_EX_10G_RX_FIFO_OVFL) {
/* don't flag RX FIFO after the first */
mac_dev->set_exception(mac_dev->fman_mac,
FM_MAC_EX_10G_RX_FIFO_OVFL, false);
dev_err(mac_dev->dev, "10G MAC got RX FIFO Error = %x\n", ex);
}
dev_dbg(mac_dev->dev, "%s:%s() -> %d\n", KBUILD_BASENAME ".c",
__func__, ex);
}
static DEFINE_MUTEX(eth_lock);
static struct platform_device *dpaa_eth_add_device(int fman_id,
struct mac_device *mac_dev)
{
struct platform_device *pdev;
struct dpaa_eth_data data;
struct mac_priv_s *priv;
static int dpaa_eth_dev_cnt;
int ret;
priv = mac_dev->priv;
data.mac_dev = mac_dev;
data.mac_hw_id = priv->cell_index;
data.fman_hw_id = fman_id;
mutex_lock(ð_lock);
pdev = platform_device_alloc("dpaa-ethernet", dpaa_eth_dev_cnt);
if (!pdev) {
ret = -ENOMEM;
goto no_mem;
}
pdev->dev.parent = mac_dev->dev;
ret = platform_device_add_data(pdev, &data, sizeof(data));
if (ret)
goto err;
ret = platform_device_add(pdev);
if (ret)
goto err;
dpaa_eth_dev_cnt++;
mutex_unlock(ð_lock);
return pdev;
err:
platform_device_put(pdev);
no_mem:
mutex_unlock(ð_lock);
return ERR_PTR(ret);
}
static const struct of_device_id mac_match[] = {
{ .compatible = "fsl,fman-dtsec", .data = dtsec_initialization },
{ .compatible = "fsl,fman-xgec", .data = tgec_initialization },
{ .compatible = "fsl,fman-memac", .data = memac_initialization },
{}
};
MODULE_DEVICE_TABLE(of, mac_match);
static int mac_probe(struct platform_device *_of_dev)
{
int err, i, nph;
int (*init)(struct mac_device *mac_dev, struct device_node *mac_node,
struct fman_mac_params *params);
struct device *dev;
struct device_node *mac_node, *dev_node;
struct mac_device *mac_dev;
struct platform_device *of_dev;
Annotation
- Immediate include surface: `linux/init.h`, `linux/module.h`, `linux/of_address.h`, `linux/of_platform.h`, `linux/of_net.h`, `linux/of_mdio.h`, `linux/device.h`, `linux/phy.h`.
- Detected declarations: `struct mac_priv_s`, `struct mac_address`, `function mac_exception`, `function mac_probe`, `function mac_remove`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.