drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c- Extension
.c- Size
- 93297 bytes
- Lines
- 3652
- 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/module.hlinux/interrupt.hlinux/kthread.hlinux/workqueue.hlinux/iommu.hnet/pkt_cls.hlinux/fsl/mc.hdpaa2-switch.h
Detected Declarations
struct ethsw_dump_ctxstruct ethsw_switchdev_event_workfunction dpaa2_switch_port_get_fdb_idfunction dpaa2_switch_filter_block_get_unusedfunction dpaa2_switch_fdb_in_use_by_othersfunction dpaa2_switch_fdb_for_joinfunction dpaa2_switch_fdb_for_leavefunction dpaa2_switch_port_set_fdbfunction dpaa2_switch_fdb_get_flood_cfgfunction dpaa2_switch_fdb_set_egress_floodfunction dpaa2_switch_add_vlanfunction dpaa2_switch_port_is_upfunction dpaa2_switch_port_set_pvidfunction dpaa2_switch_port_add_vlanfunction br_stp_state_to_dpswfunction dpaa2_switch_port_set_stp_statefunction dpaa2_switch_dellinkfunction dpaa2_switch_port_fdb_add_ucfunction dpaa2_switch_port_fdb_del_ucfunction dpaa2_switch_port_fdb_add_mcfunction dpaa2_switch_port_fdb_del_mcfunction dpaa2_switch_port_get_statsfunction dpaa2_switch_port_has_offload_statsfunction dpaa2_switch_port_get_offload_statsfunction dpaa2_switch_port_change_mtufunction dpaa2_switch_port_link_state_updatefunction dpaa2_switch_enable_ctrl_if_napifunction dpaa2_switch_disable_ctrl_if_napifunction dpaa2_switch_port_openfunction dpaa2_switch_port_stopfunction dpaa2_switch_port_parent_idfunction dpaa2_switch_port_get_phys_namefunction dpaa2_switch_fdb_dump_nlfunction dpaa2_switch_port_fdb_valid_entryfunction dpaa2_switch_fdb_iteratefunction dpaa2_switch_fdb_entry_dumpfunction dpaa2_switch_port_fdb_dumpfunction dpaa2_switch_fdb_entry_fast_agefunction dpaa2_switch_port_fast_agefunction dpaa2_switch_port_vlan_addfunction dpaa2_switch_port_vlan_killfunction dpaa2_switch_port_set_mac_addrfunction dpaa2_switch_free_fdfunction dpaa2_switch_build_single_fdfunction dpaa2_switch_port_txfunction dpaa2_switch_setup_tc_cls_flowerfunction dpaa2_switch_setup_tc_cls_matchallfunction dpaa2_switch_port_setup_tc_block_cb_ig
Annotated Snippet
static const struct net_device_ops dpaa2_switch_port_ops = {
.ndo_open = dpaa2_switch_port_open,
.ndo_stop = dpaa2_switch_port_stop,
.ndo_set_mac_address = eth_mac_addr,
.ndo_get_stats64 = dpaa2_switch_port_get_stats,
.ndo_change_mtu = dpaa2_switch_port_change_mtu,
.ndo_has_offload_stats = dpaa2_switch_port_has_offload_stats,
.ndo_get_offload_stats = dpaa2_switch_port_get_offload_stats,
.ndo_fdb_dump = dpaa2_switch_port_fdb_dump,
.ndo_vlan_rx_add_vid = dpaa2_switch_port_vlan_add,
.ndo_vlan_rx_kill_vid = dpaa2_switch_port_vlan_kill,
.ndo_start_xmit = dpaa2_switch_port_tx,
.ndo_get_port_parent_id = dpaa2_switch_port_parent_id,
.ndo_get_phys_port_name = dpaa2_switch_port_get_phys_name,
.ndo_setup_tc = dpaa2_switch_port_setup_tc,
};
bool dpaa2_switch_port_dev_check(const struct net_device *netdev)
{
return netdev->netdev_ops == &dpaa2_switch_port_ops;
}
static int dpaa2_switch_port_connect_mac(struct ethsw_port_priv *port_priv)
{
struct fsl_mc_device *dpsw_port_dev, *dpmac_dev;
struct dpaa2_mac *mac;
int err;
dpsw_port_dev = to_fsl_mc_device(port_priv->netdev->dev.parent);
dpmac_dev = fsl_mc_get_endpoint(dpsw_port_dev, port_priv->idx);
if (PTR_ERR(dpmac_dev) == -EPROBE_DEFER)
return PTR_ERR(dpmac_dev);
if (IS_ERR(dpmac_dev))
return 0;
if (dpmac_dev->dev.type != &fsl_mc_bus_dpmac_type) {
err = 0;
goto out_put_device;
}
mac = kzalloc_obj(*mac);
if (!mac) {
err = -ENOMEM;
goto out_put_device;
}
mac->mc_dev = dpmac_dev;
mac->mc_io = port_priv->ethsw_data->mc_io;
mac->net_dev = port_priv->netdev;
err = dpaa2_mac_open(mac);
if (err)
goto err_free_mac;
if (dpaa2_mac_is_type_phy(mac)) {
err = dpaa2_mac_connect(mac);
if (err) {
netdev_err(port_priv->netdev,
"Error connecting to the MAC endpoint %pe\n",
ERR_PTR(err));
goto err_close_mac;
}
}
mutex_lock(&port_priv->mac_lock);
port_priv->mac = mac;
mutex_unlock(&port_priv->mac_lock);
return 0;
err_close_mac:
dpaa2_mac_close(mac);
err_free_mac:
kfree(mac);
out_put_device:
put_device(&dpmac_dev->dev);
return err;
}
static void dpaa2_switch_port_disconnect_mac(struct ethsw_port_priv *port_priv)
{
struct dpaa2_mac *mac;
mutex_lock(&port_priv->mac_lock);
mac = port_priv->mac;
port_priv->mac = NULL;
Annotation
- Immediate include surface: `linux/module.h`, `linux/interrupt.h`, `linux/kthread.h`, `linux/workqueue.h`, `linux/iommu.h`, `net/pkt_cls.h`, `linux/fsl/mc.h`, `dpaa2-switch.h`.
- Detected declarations: `struct ethsw_dump_ctx`, `struct ethsw_switchdev_event_work`, `function dpaa2_switch_port_get_fdb_id`, `function dpaa2_switch_filter_block_get_unused`, `function dpaa2_switch_fdb_in_use_by_others`, `function dpaa2_switch_fdb_for_join`, `function dpaa2_switch_fdb_for_leave`, `function dpaa2_switch_port_set_fdb`, `function dpaa2_switch_fdb_get_flood_cfg`, `function dpaa2_switch_fdb_set_egress_flood`.
- 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.