drivers/net/ethernet/mscc/ocelot_net.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mscc/ocelot_net.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mscc/ocelot_net.c- Extension
.c- Size
- 51507 bytes
- Lines
- 1929
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/dsa/ocelot.hlinux/if_bridge.hlinux/of_net.hlinux/phy/phy.hnet/pkt_cls.hocelot.hocelot_police.hocelot_vcap.hocelot_fdma.h
Detected Declarations
struct ocelot_dump_ctxstruct ocelot_mact_work_ctxenum ocelot_action_typefunction devlink_port_to_portfunction ocelot_devlink_sb_pool_getfunction ocelot_devlink_sb_pool_setfunction ocelot_devlink_sb_port_pool_getfunction ocelot_devlink_sb_port_pool_setfunction ocelot_devlink_sb_tc_pool_bind_getfunction ocelot_devlink_sb_tc_pool_bind_setfunction ocelot_devlink_sb_occ_snapshotfunction ocelot_devlink_sb_occ_max_clearfunction ocelot_devlink_sb_occ_port_pool_getfunction ocelot_devlink_sb_occ_tc_port_bind_getfunction ocelot_port_devlink_initfunction ocelot_port_devlink_teardownfunction ocelot_setup_tc_cls_flowerfunction ocelot_setup_tc_cls_matchall_policefunction ocelot_setup_tc_cls_matchall_mirredfunction ocelot_del_tc_cls_matchall_policefunction ocelot_del_tc_cls_matchall_mirredfunction ocelot_setup_tc_cls_matchallfunction ocelot_setup_tc_block_cbfunction ocelot_setup_tc_block_cb_igfunction ocelot_setup_tc_block_cb_egfunction ocelot_setup_tc_blockfunction ocelot_setup_tcfunction ocelot_vlan_vid_addfunction ocelot_vlan_vid_delfunction ocelot_port_openfunction ocelot_port_stopfunction ocelot_xmit_timestampfunction ocelot_port_xmit_fdmafunction ocelot_port_xmit_injfunction ocelot_port_xmitfunction ocelot_mact_workfunction ocelot_enqueue_mact_actionfunction ocelot_mc_unsyncfunction ocelot_mc_syncfunction ocelot_set_rx_modefunction ocelot_port_set_mac_addressfunction ocelot_get_stats64function ocelot_port_fdb_addfunction ocelot_port_fdb_delfunction ocelot_port_fdb_do_dumpfunction ocelot_port_fdb_dumpfunction ocelot_vlan_rx_add_vidfunction ocelot_vlan_rx_kill_vid
Annotated Snippet
static const struct net_device_ops ocelot_port_netdev_ops = {
.ndo_open = ocelot_port_open,
.ndo_stop = ocelot_port_stop,
.ndo_start_xmit = ocelot_port_xmit,
.ndo_change_mtu = ocelot_change_mtu,
.ndo_set_rx_mode = ocelot_set_rx_mode,
.ndo_set_mac_address = ocelot_port_set_mac_address,
.ndo_get_stats64 = ocelot_get_stats64,
.ndo_fdb_add = ocelot_port_fdb_add,
.ndo_fdb_del = ocelot_port_fdb_del,
.ndo_fdb_dump = ocelot_port_fdb_dump,
.ndo_vlan_rx_add_vid = ocelot_vlan_rx_add_vid,
.ndo_vlan_rx_kill_vid = ocelot_vlan_rx_kill_vid,
.ndo_set_features = ocelot_set_features,
.ndo_setup_tc = ocelot_setup_tc,
.ndo_eth_ioctl = ocelot_ioctl,
.ndo_hwtstamp_get = ocelot_port_hwtstamp_get,
.ndo_hwtstamp_set = ocelot_port_hwtstamp_set,
};
struct net_device *ocelot_port_to_netdev(struct ocelot *ocelot, int port)
{
struct ocelot_port *ocelot_port = ocelot->ports[port];
struct ocelot_port_private *priv;
if (!ocelot_port)
return NULL;
priv = container_of(ocelot_port, struct ocelot_port_private, port);
return priv->dev;
}
/* Checks if the net_device instance given to us originates from our driver */
static bool ocelot_netdevice_dev_check(const struct net_device *dev)
{
return dev->netdev_ops == &ocelot_port_netdev_ops;
}
int ocelot_netdev_to_port(struct ocelot *ocelot, struct net_device *dev)
{
struct ocelot_port_private *priv;
if (!dev || !ocelot_netdevice_dev_check(dev))
return -EINVAL;
priv = netdev_priv(dev);
if (priv->port.ocelot != ocelot)
return -EINVAL;
return priv->port.index;
}
static void ocelot_port_get_strings(struct net_device *netdev, u32 sset,
u8 *data)
{
struct ocelot_port_private *priv = netdev_priv(netdev);
struct ocelot *ocelot = priv->port.ocelot;
int port = priv->port.index;
ocelot_get_strings(ocelot, port, sset, data);
}
static void ocelot_port_get_ethtool_stats(struct net_device *dev,
struct ethtool_stats *stats,
u64 *data)
{
struct ocelot_port_private *priv = netdev_priv(dev);
struct ocelot *ocelot = priv->port.ocelot;
int port = priv->port.index;
ocelot_get_ethtool_stats(ocelot, port, data);
}
static int ocelot_port_get_sset_count(struct net_device *dev, int sset)
{
struct ocelot_port_private *priv = netdev_priv(dev);
struct ocelot *ocelot = priv->port.ocelot;
int port = priv->port.index;
return ocelot_get_sset_count(ocelot, port, sset);
}
static int ocelot_port_get_ts_info(struct net_device *dev,
struct kernel_ethtool_ts_info *info)
{
struct ocelot_port_private *priv = netdev_priv(dev);
struct ocelot *ocelot = priv->port.ocelot;
int port = priv->port.index;
Annotation
- Immediate include surface: `linux/dsa/ocelot.h`, `linux/if_bridge.h`, `linux/of_net.h`, `linux/phy/phy.h`, `net/pkt_cls.h`, `ocelot.h`, `ocelot_police.h`, `ocelot_vcap.h`.
- Detected declarations: `struct ocelot_dump_ctx`, `struct ocelot_mact_work_ctx`, `enum ocelot_action_type`, `function devlink_port_to_port`, `function ocelot_devlink_sb_pool_get`, `function ocelot_devlink_sb_pool_set`, `function ocelot_devlink_sb_port_pool_get`, `function ocelot_devlink_sb_port_pool_set`, `function ocelot_devlink_sb_tc_pool_bind_get`, `function ocelot_devlink_sb_tc_pool_bind_set`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern implementation candidate.
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.