drivers/net/ethernet/ti/am65-cpsw-switchdev.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/ti/am65-cpsw-switchdev.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/ti/am65-cpsw-switchdev.c- Extension
.c- Size
- 14306 bytes
- Lines
- 535
- 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.
- 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/if_bridge.hlinux/netdevice.hlinux/workqueue.hnet/switchdev.ham65-cpsw-nuss.ham65-cpsw-switchdev.hcpsw_ale.h
Detected Declarations
struct am65_cpsw_switchdev_event_workfunction am65_cpsw_port_stp_state_setfunction am65_cpsw_port_attr_br_flags_setfunction am65_cpsw_port_attr_br_flags_pre_setfunction am65_cpsw_port_attr_setfunction am65_cpsw_get_pvidfunction am65_cpsw_set_pvidfunction am65_cpsw_port_vlan_addfunction am65_cpsw_port_vlan_delfunction am65_cpsw_port_vlans_addfunction am65_cpsw_port_vlans_delfunction am65_cpsw_port_mdb_addfunction am65_cpsw_port_mdb_delfunction am65_cpsw_port_obj_addfunction am65_cpsw_port_obj_delfunction am65_cpsw_fdb_offload_notifyfunction am65_cpsw_switchdev_event_workfunction am65_cpsw_switchdev_eventfunction am65_cpsw_switchdev_blocking_eventfunction am65_cpsw_switchdev_register_notifiersfunction am65_cpsw_switchdev_unregister_notifiers
Annotated Snippet
struct am65_cpsw_switchdev_event_work {
struct work_struct work;
struct switchdev_notifier_fdb_info fdb_info;
struct am65_cpsw_port *port;
unsigned long event;
};
static int am65_cpsw_port_stp_state_set(struct am65_cpsw_port *port, u8 state)
{
struct am65_cpsw_common *cpsw = port->common;
u8 cpsw_state;
int ret = 0;
switch (state) {
case BR_STATE_FORWARDING:
cpsw_state = ALE_PORT_STATE_FORWARD;
break;
case BR_STATE_LEARNING:
cpsw_state = ALE_PORT_STATE_LEARN;
break;
case BR_STATE_DISABLED:
cpsw_state = ALE_PORT_STATE_DISABLE;
break;
case BR_STATE_LISTENING:
case BR_STATE_BLOCKING:
cpsw_state = ALE_PORT_STATE_BLOCK;
break;
default:
return -EOPNOTSUPP;
}
ret = cpsw_ale_control_set(cpsw->ale, port->port_id,
ALE_PORT_STATE, cpsw_state);
netdev_dbg(port->ndev, "ale state: %u\n", cpsw_state);
return ret;
}
static int am65_cpsw_port_attr_br_flags_set(struct am65_cpsw_port *port,
struct net_device *orig_dev,
struct switchdev_brport_flags flags)
{
struct am65_cpsw_common *cpsw = port->common;
if (flags.mask & BR_MCAST_FLOOD) {
bool unreg_mcast_add = false;
if (flags.val & BR_MCAST_FLOOD)
unreg_mcast_add = true;
netdev_dbg(port->ndev, "BR_MCAST_FLOOD: %d port %u\n",
unreg_mcast_add, port->port_id);
cpsw_ale_set_unreg_mcast(cpsw->ale, BIT(port->port_id),
unreg_mcast_add);
}
return 0;
}
static int am65_cpsw_port_attr_br_flags_pre_set(struct net_device *netdev,
struct switchdev_brport_flags flags)
{
if (flags.mask & ~(BR_LEARNING | BR_MCAST_FLOOD))
return -EINVAL;
return 0;
}
static int am65_cpsw_port_attr_set(struct net_device *ndev, const void *ctx,
const struct switchdev_attr *attr,
struct netlink_ext_ack *extack)
{
struct am65_cpsw_port *port = am65_ndev_to_port(ndev);
int ret;
netdev_dbg(ndev, "attr: id %u port: %u\n", attr->id, port->port_id);
switch (attr->id) {
case SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS:
ret = am65_cpsw_port_attr_br_flags_pre_set(ndev,
attr->u.brport_flags);
break;
case SWITCHDEV_ATTR_ID_PORT_STP_STATE:
ret = am65_cpsw_port_stp_state_set(port, attr->u.stp_state);
netdev_dbg(ndev, "stp state: %u\n", attr->u.stp_state);
break;
case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS:
ret = am65_cpsw_port_attr_br_flags_set(port, attr->orig_dev,
attr->u.brport_flags);
Annotation
- Immediate include surface: `linux/etherdevice.h`, `linux/if_bridge.h`, `linux/netdevice.h`, `linux/workqueue.h`, `net/switchdev.h`, `am65-cpsw-nuss.h`, `am65-cpsw-switchdev.h`, `cpsw_ale.h`.
- Detected declarations: `struct am65_cpsw_switchdev_event_work`, `function am65_cpsw_port_stp_state_set`, `function am65_cpsw_port_attr_br_flags_set`, `function am65_cpsw_port_attr_br_flags_pre_set`, `function am65_cpsw_port_attr_set`, `function am65_cpsw_get_pvid`, `function am65_cpsw_set_pvid`, `function am65_cpsw_port_vlan_add`, `function am65_cpsw_port_vlan_del`, `function am65_cpsw_port_vlans_add`.
- 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.