drivers/net/ethernet/mscc/ocelot.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mscc/ocelot.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mscc/ocelot.c- Extension
.c- Size
- 91606 bytes
- Lines
- 3334
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/dsa/ocelot.hlinux/if_bridge.hlinux/iopoll.hlinux/phy/phy.hnet/pkt_sched.hsoc/mscc/ocelot_hsio.hsoc/mscc/ocelot_vcap.hocelot.hocelot_vcap.h
Detected Declarations
struct ocelot_mact_entryfunction ocelot_mact_read_macaccessfunction ocelot_mact_wait_for_completionfunction ocelot_mact_selectfunction __ocelot_mact_learnfunction ocelot_mact_learnfunction ocelot_mact_forgetfunction ocelot_mact_lookupfunction ocelot_mact_learn_streamdatafunction ocelot_mact_initfunction ocelot_pll5_initfunction ocelot_vcap_enablefunction ocelot_single_vlan_aware_bridgefunction ocelot_vlant_read_vlanaccessfunction ocelot_vlant_wait_for_completionfunction ocelot_vlant_set_maskfunction ocelot_port_num_untagged_vlansfunction list_for_each_entryfunction ocelot_port_num_tagged_vlansfunction list_for_each_entryfunction ocelot_port_uses_native_vlanfunction ocelot_port_find_native_vlanfunction ocelot_port_manage_port_tagfunction ocelot_bridge_num_findfunction ocelot_vlan_unaware_pvidfunction ocelot_update_vlan_reclassify_rulefunction ocelot_port_set_pvidfunction ocelot_vlan_member_addfunction ocelot_vlan_member_delfunction ocelot_add_vlan_unaware_pvidfunction ocelot_del_vlan_unaware_pvidfunction ocelot_port_vlan_filteringfunction list_for_each_entryfunction ocelot_vlan_preparefunction ocelot_vlan_addfunction ocelot_bridge_vlan_findfunction ocelot_vlan_delfunction ocelot_vlan_initfunction ocelot_read_eq_availfunction ocelot_port_flushfunction ocelot_port_configure_serdesfunction ocelot_phylink_mac_configfunction ocelot_phylink_mac_link_downfunction ocelot_phylink_mac_link_upfunction ocelot_rx_frame_wordfunction ocelot_xtr_poll_xfhfunction ocelot_ptp_rx_timestampfunction ocelot_lock_inj_grp
Annotated Snippet
struct ocelot_mact_entry {
u8 mac[ETH_ALEN];
u16 vid;
enum macaccess_entry_type type;
};
/* Caller must hold &ocelot->mact_lock */
static inline u32 ocelot_mact_read_macaccess(struct ocelot *ocelot)
{
return ocelot_read(ocelot, ANA_TABLES_MACACCESS);
}
/* Caller must hold &ocelot->mact_lock */
static inline int ocelot_mact_wait_for_completion(struct ocelot *ocelot)
{
u32 val;
return readx_poll_timeout(ocelot_mact_read_macaccess,
ocelot, val,
(val & ANA_TABLES_MACACCESS_MAC_TABLE_CMD_M) ==
MACACCESS_CMD_IDLE,
TABLE_UPDATE_SLEEP_US, TABLE_UPDATE_TIMEOUT_US);
}
/* Caller must hold &ocelot->mact_lock */
static void ocelot_mact_select(struct ocelot *ocelot,
const unsigned char mac[ETH_ALEN],
unsigned int vid)
{
u32 macl = 0, mach = 0;
/* Set the MAC address to handle and the vlan associated in a format
* understood by the hardware.
*/
mach |= vid << 16;
mach |= mac[0] << 8;
mach |= mac[1] << 0;
macl |= mac[2] << 24;
macl |= mac[3] << 16;
macl |= mac[4] << 8;
macl |= mac[5] << 0;
ocelot_write(ocelot, macl, ANA_TABLES_MACLDATA);
ocelot_write(ocelot, mach, ANA_TABLES_MACHDATA);
}
static int __ocelot_mact_learn(struct ocelot *ocelot, int port,
const unsigned char mac[ETH_ALEN],
unsigned int vid, enum macaccess_entry_type type)
{
u32 cmd = ANA_TABLES_MACACCESS_VALID |
ANA_TABLES_MACACCESS_DEST_IDX(port) |
ANA_TABLES_MACACCESS_ENTRYTYPE(type) |
ANA_TABLES_MACACCESS_MAC_TABLE_CMD(MACACCESS_CMD_LEARN);
unsigned int mc_ports;
int err;
/* Set MAC_CPU_COPY if the CPU port is used by a multicast entry */
if (type == ENTRYTYPE_MACv4)
mc_ports = (mac[1] << 8) | mac[2];
else if (type == ENTRYTYPE_MACv6)
mc_ports = (mac[0] << 8) | mac[1];
else
mc_ports = 0;
if (mc_ports & BIT(ocelot->num_phys_ports))
cmd |= ANA_TABLES_MACACCESS_MAC_CPU_COPY;
ocelot_mact_select(ocelot, mac, vid);
/* Issue a write command */
ocelot_write(ocelot, cmd, ANA_TABLES_MACACCESS);
err = ocelot_mact_wait_for_completion(ocelot);
return err;
}
int ocelot_mact_learn(struct ocelot *ocelot, int port,
const unsigned char mac[ETH_ALEN],
unsigned int vid, enum macaccess_entry_type type)
{
int ret;
mutex_lock(&ocelot->mact_lock);
ret = __ocelot_mact_learn(ocelot, port, mac, vid, type);
mutex_unlock(&ocelot->mact_lock);
return ret;
Annotation
- Immediate include surface: `linux/dsa/ocelot.h`, `linux/if_bridge.h`, `linux/iopoll.h`, `linux/phy/phy.h`, `net/pkt_sched.h`, `soc/mscc/ocelot_hsio.h`, `soc/mscc/ocelot_vcap.h`, `ocelot.h`.
- Detected declarations: `struct ocelot_mact_entry`, `function ocelot_mact_read_macaccess`, `function ocelot_mact_wait_for_completion`, `function ocelot_mact_select`, `function __ocelot_mact_learn`, `function ocelot_mact_learn`, `function ocelot_mact_forget`, `function ocelot_mact_lookup`, `function ocelot_mact_learn_streamdata`, `function ocelot_mact_init`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration 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.