drivers/net/ethernet/marvell/prestera/prestera_main.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/marvell/prestera/prestera_main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/marvell/prestera/prestera_main.c- Extension
.c- Size
- 36122 bytes
- Lines
- 1527
- 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.
- 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/etherdevice.hlinux/jiffies.hlinux/list.hlinux/module.hlinux/netdev_features.hlinux/of.hlinux/of_net.hlinux/if_vlan.hlinux/phylink.hprestera.hprestera_hw.hprestera_acl.hprestera_flow.hprestera_span.hprestera_rxtx.hprestera_devlink.hprestera_ethtool.hprestera_counter.hprestera_switchdev.h
Detected Declarations
function prestera_queue_workfunction prestera_queue_delayed_workfunction prestera_queue_drainfunction prestera_port_learning_setfunction prestera_port_uc_flood_setfunction prestera_port_mc_flood_setfunction prestera_port_br_locked_setfunction prestera_port_pvid_setfunction prestera_port_cfg_mac_readfunction prestera_port_cfg_mac_writefunction prestera_port_openfunction prestera_port_closefunction prestera_port_mac_state_cache_readfunction prestera_port_mac_state_cache_writefunction prestera_mac_configfunction prestera_mac_link_upfunction prestera_pcs_get_statefunction prestera_pcs_configfunction prestera_pcs_an_restartfunction prestera_port_sfp_bindfunction for_each_child_of_nodefunction prestera_port_sfp_unbindfunction prestera_port_xmitfunction prestera_is_valid_mac_addrfunction prestera_port_set_mac_addressfunction prestera_port_change_mtufunction prestera_port_get_stats64function prestera_port_get_hw_statsfunction prestera_port_stats_updatefunction prestera_port_setup_tcfunction prestera_port_autoneg_setfunction prestera_port_list_addfunction prestera_port_list_delfunction prestera_port_createfunction prestera_port_destroyfunction prestera_destroy_portsfunction prestera_create_portsfunction prestera_port_handle_eventfunction prestera_event_handlers_registerfunction prestera_event_handlers_unregisterfunction prestera_switch_set_base_mac_addrfunction prestera_lag_idfunction prestera_lag_destroyfunction prestera_lag_port_addfunction prestera_lag_port_delfunction prestera_port_is_lag_memberfunction prestera_port_lag_idfunction prestera_lag_init
Annotated Snippet
static const struct net_device_ops prestera_netdev_ops = {
.ndo_open = prestera_port_open,
.ndo_stop = prestera_port_close,
.ndo_start_xmit = prestera_port_xmit,
.ndo_setup_tc = prestera_port_setup_tc,
.ndo_change_mtu = prestera_port_change_mtu,
.ndo_get_stats64 = prestera_port_get_stats64,
.ndo_set_mac_address = prestera_port_set_mac_address,
};
int prestera_port_autoneg_set(struct prestera_port *port, u64 link_modes)
{
int err;
if (port->autoneg && port->adver_link_modes == link_modes)
return 0;
err = prestera_hw_port_phy_mode_set(port, port->cfg_phy.admin,
true, 0, link_modes,
port->cfg_phy.mdix);
if (err)
return err;
port->adver_fec = BIT(PRESTERA_PORT_FEC_OFF);
port->adver_link_modes = link_modes;
port->cfg_phy.mode = 0;
port->autoneg = true;
return 0;
}
static void prestera_port_list_add(struct prestera_port *port)
{
write_lock(&port->sw->port_list_lock);
list_add(&port->list, &port->sw->port_list);
write_unlock(&port->sw->port_list_lock);
}
static void prestera_port_list_del(struct prestera_port *port)
{
write_lock(&port->sw->port_list_lock);
list_del(&port->list);
write_unlock(&port->sw->port_list_lock);
}
static int prestera_port_create(struct prestera_switch *sw, u32 id)
{
struct prestera_port_mac_config cfg_mac;
struct prestera_port *port;
struct net_device *dev;
int err;
dev = alloc_etherdev(sizeof(*port));
if (!dev)
return -ENOMEM;
port = netdev_priv(dev);
INIT_LIST_HEAD(&port->vlans_list);
port->pvid = PRESTERA_DEFAULT_VID;
port->lag = NULL;
port->dev = dev;
port->id = id;
port->sw = sw;
spin_lock_init(&port->state_mac_lock);
err = prestera_hw_port_info_get(port, &port->dev_id, &port->hw_id,
&port->fp_id);
if (err) {
dev_err(prestera_dev(sw), "Failed to get port(%u) info\n", id);
goto err_port_info_get;
}
err = prestera_devlink_port_register(port);
if (err)
goto err_dl_port_register;
dev->features |= NETIF_F_HW_TC;
dev->netns_immutable = true;
dev->netdev_ops = &prestera_netdev_ops;
dev->ethtool_ops = &prestera_ethtool_ops;
SET_NETDEV_DEV(dev, sw->dev->dev);
SET_NETDEV_DEVLINK_PORT(dev, &port->dl_port);
if (port->caps.transceiver != PRESTERA_PORT_TCVR_SFP)
netif_carrier_off(dev);
dev->mtu = min_t(unsigned int, sw->mtu_max, PRESTERA_MTU_DEFAULT);
dev->min_mtu = sw->mtu_min;
Annotation
- Immediate include surface: `linux/etherdevice.h`, `linux/jiffies.h`, `linux/list.h`, `linux/module.h`, `linux/netdev_features.h`, `linux/of.h`, `linux/of_net.h`, `linux/if_vlan.h`.
- Detected declarations: `function prestera_queue_work`, `function prestera_queue_delayed_work`, `function prestera_queue_drain`, `function prestera_port_learning_set`, `function prestera_port_uc_flood_set`, `function prestera_port_mc_flood_set`, `function prestera_port_br_locked_set`, `function prestera_port_pvid_set`, `function prestera_port_cfg_mac_read`, `function prestera_port_cfg_mac_write`.
- 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.
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.