drivers/net/dsa/qca/qca8k-common.c
Source file repositories/reference/linux-study-clean/drivers/net/dsa/qca/qca8k-common.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/dsa/qca/qca8k-common.c- Extension
.c- Size
- 31192 bytes
- Lines
- 1258
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/netdevice.hnet/dsa.hlinux/if_bridge.hqca8k.h
Detected Declarations
function qca8k_readfunction qca8k_writefunction qca8k_rmwfunction qca8k_busy_waitfunction qca8k_fdb_readfunction qca8k_fdb_writefunction qca8k_fdb_accessfunction qca8k_fdb_nextfunction qca8k_fdb_addfunction qca8k_fdb_delfunction qca8k_fdb_flushfunction qca8k_fdb_search_and_insertfunction qca8k_fdb_search_and_delfunction qca8k_vlan_accessfunction qca8k_vlan_addfunction qca8k_vlan_delfunction qca8k_mib_initfunction qca8k_port_set_statusfunction qca8k_get_stringsfunction qca8k_get_ethtool_statsfunction qca8k_get_sset_countfunction qca8k_set_mac_eeefunction qca8k_port_configure_learningfunction qca8k_port_stp_state_setfunction qca8k_update_port_memberfunction qca8k_port_pre_bridge_flagsfunction qca8k_port_bridge_flagsfunction qca8k_port_bridge_joinfunction qca8k_port_bridge_leavefunction qca8k_port_fast_agefunction qca8k_set_ageing_timefunction qca8k_port_enablefunction qca8k_port_disablefunction qca8k_port_change_mtufunction qca8k_port_max_mtufunction qca8k_port_fdb_insertfunction qca8k_port_fdb_addfunction qca8k_port_fdb_delfunction qca8k_port_fdb_dumpfunction qca8k_port_mdb_addfunction qca8k_port_mdb_delfunction qca8k_port_mirror_addfunction qca8k_port_mirror_delfunction qca8k_port_vlan_filteringfunction qca8k_port_vlan_addfunction qca8k_port_vlan_delfunction qca8k_lag_can_offloadfunction qca8k_lag_setup_hash
Annotated Snippet
if ((reg & mask) != mask) {
del = false;
break;
}
}
if (del) {
ret = qca8k_vlan_access(priv, QCA8K_VLAN_PURGE, vid);
} else {
ret = qca8k_write(priv, QCA8K_REG_VTU_FUNC0, reg);
if (ret)
goto out;
ret = qca8k_vlan_access(priv, QCA8K_VLAN_LOAD, vid);
}
out:
mutex_unlock(&priv->reg_mutex);
return ret;
}
int qca8k_mib_init(struct qca8k_priv *priv)
{
int ret;
mutex_lock(&priv->reg_mutex);
ret = regmap_update_bits(priv->regmap, QCA8K_REG_MIB,
QCA8K_MIB_FUNC | QCA8K_MIB_BUSY,
FIELD_PREP(QCA8K_MIB_FUNC, QCA8K_MIB_FLUSH) |
QCA8K_MIB_BUSY);
if (ret)
goto exit;
ret = qca8k_busy_wait(priv, QCA8K_REG_MIB, QCA8K_MIB_BUSY);
if (ret)
goto exit;
ret = regmap_set_bits(priv->regmap, QCA8K_REG_MIB, QCA8K_MIB_CPU_KEEP);
if (ret)
goto exit;
ret = qca8k_write(priv, QCA8K_REG_MODULE_EN, QCA8K_MODULE_EN_MIB);
exit:
mutex_unlock(&priv->reg_mutex);
return ret;
}
void qca8k_port_set_status(struct qca8k_priv *priv, int port, int enable)
{
u32 mask = QCA8K_PORT_STATUS_TXMAC | QCA8K_PORT_STATUS_RXMAC;
/* Port 0 and 6 have no internal PHY */
if (port > 0 && port < 6)
mask |= QCA8K_PORT_STATUS_LINK_AUTO;
if (enable)
regmap_set_bits(priv->regmap, QCA8K_REG_PORT_STATUS(port), mask);
else
regmap_clear_bits(priv->regmap, QCA8K_REG_PORT_STATUS(port), mask);
}
void qca8k_get_strings(struct dsa_switch *ds, int port, u32 stringset,
uint8_t *data)
{
struct qca8k_priv *priv = ds->priv;
int i;
if (stringset != ETH_SS_STATS)
return;
for (i = 0; i < priv->info->mib_count; i++)
ethtool_puts(&data, ar8327_mib[i].name);
}
void qca8k_get_ethtool_stats(struct dsa_switch *ds, int port,
uint64_t *data)
{
struct qca8k_priv *priv = ds->priv;
const struct qca8k_mib_desc *mib;
u32 reg, i, val;
u32 hi = 0;
int ret;
if (priv->mgmt_conduit && priv->info->ops->autocast_mib &&
priv->info->ops->autocast_mib(ds, port, data) > 0)
return;
for (i = 0; i < priv->info->mib_count; i++) {
mib = &ar8327_mib[i];
Annotation
- Immediate include surface: `linux/netdevice.h`, `net/dsa.h`, `linux/if_bridge.h`, `qca8k.h`.
- Detected declarations: `function qca8k_read`, `function qca8k_write`, `function qca8k_rmw`, `function qca8k_busy_wait`, `function qca8k_fdb_read`, `function qca8k_fdb_write`, `function qca8k_fdb_access`, `function qca8k_fdb_next`, `function qca8k_fdb_add`, `function qca8k_fdb_del`.
- 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.