drivers/net/dsa/realtek/rtl83xx.c
Source file repositories/reference/linux-study-clean/drivers/net/dsa/realtek/rtl83xx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/dsa/realtek/rtl83xx.c- Extension
.c- Size
- 22969 bytes
- Lines
- 895
- 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/module.hlinux/regmap.hlinux/of_mdio.hlinux/if_bridge.hlinux/etherdevice.hrealtek.hrtl83xx.h
Detected Declarations
function rtl83xx_lockfunction rtl83xx_unlockfunction rtl83xx_user_mdio_readfunction rtl83xx_user_mdio_writefunction rtl83xx_setup_user_mdiofunction rtl83xx_probefunction rtl83xx_register_switchfunction rtl83xx_unregister_switchfunction rtl83xx_shutdownfunction rtl83xx_removefunction rtl83xx_reset_assertfunction rtl83xx_reset_deassertfunction rtl83xx_port_bridge_joinfunction rtl83xx_port_bridge_leavefunction rtl83xx_port_fast_agefunction rtl83xx_port_fdb_addfunction rtl83xx_port_fdb_delfunction rtl83xx_port_fdb_dumpfunction rtl83xx_port_mdb_addfunction rtl83xx_port_mdb_delfunction rtl83xx_port_bridge_flagsfunction rtl83xx_setup_port_flood_control
Annotated Snippet
if (ret == -ENOENT) {
/* If the table is empty, returns without errors. Note
* that the l2_get_next_uc overflow to the first match
* when it reaches the end of the table.
*/
ret = 0;
break;
}
if (ret)
break;
/* When the addr returned is before the requested one, it
* indicates that we reached the end.
*/
if (addr < start_addr)
break;
ret = cb(entry.mac_addr, entry.vid, entry.is_static, data);
if (ret)
break;
addr++;
}
mutex_unlock(&priv->l2_lock);
return ret;
}
EXPORT_SYMBOL_NS_GPL(rtl83xx_port_fdb_dump, "REALTEK_DSA");
/**
* rtl83xx_port_mdb_add() - add a multicast database entry to a port database
* @ds: DSA switch instance
* @port: port index
* @mdb: multicast database entry to add
* @db: database where the entry should be added
*
* This function adds a multicast database entry to the standalone port
* database or to a bridge database.
*
* Context: Can sleep.
* Return: 0 on success, negative value for failure.
*/
int rtl83xx_port_mdb_add(struct dsa_switch *ds, int port,
const struct switchdev_obj_port_mdb *mdb,
struct dsa_db db)
{
struct realtek_priv *priv = ds->priv;
const unsigned char *addr = mdb->addr;
u16 vid = mdb->vid;
int efid;
int ret;
if (!priv->ops->l2_add_mc)
return -EOPNOTSUPP;
if (db.type != DSA_DB_PORT && db.type != DSA_DB_BRIDGE)
return -EOPNOTSUPP;
/* EFID is not used by hardware MDB entries; debugging only */
efid = db.type == DSA_DB_BRIDGE ? db.bridge.num : 0;
dev_dbg(priv->dev, "%s: port:%d addr:%pM efid:%d vid:%d dbtype:%d\n",
__func__, port, addr, efid, vid, db.type);
mutex_lock(&priv->l2_lock);
ret = priv->ops->l2_add_mc(priv, port, addr, vid);
mutex_unlock(&priv->l2_lock);
if (ret)
dev_err(priv->dev, "mdb_add ERROR %pe\n", ERR_PTR(ret));
return ret;
}
EXPORT_SYMBOL_NS_GPL(rtl83xx_port_mdb_add, "REALTEK_DSA");
/**
* rtl83xx_port_mdb_del() - delete a multicast database entry from a port
* database
* @ds: DSA switch instance
* @port: port index
* @mdb: multicast database entry to delete
* @db: database where the entry should be removed
*
* This function deletes a multicast database entry from the standalone port
* database or from a bridge database.
*
* Context: Can sleep.
* Return: 0 on success, negative value for failure.
*/
int rtl83xx_port_mdb_del(struct dsa_switch *ds, int port,
Annotation
- Immediate include surface: `linux/module.h`, `linux/regmap.h`, `linux/of_mdio.h`, `linux/if_bridge.h`, `linux/etherdevice.h`, `realtek.h`, `rtl83xx.h`.
- Detected declarations: `function rtl83xx_lock`, `function rtl83xx_unlock`, `function rtl83xx_user_mdio_read`, `function rtl83xx_user_mdio_write`, `function rtl83xx_setup_user_mdio`, `function rtl83xx_probe`, `function rtl83xx_register_switch`, `function rtl83xx_unregister_switch`, `function rtl83xx_shutdown`, `function rtl83xx_remove`.
- 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.