drivers/net/ethernet/microchip/lan966x/lan966x_mirror.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/microchip/lan966x/lan966x_mirror.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/microchip/lan966x/lan966x_mirror.c- Extension
.c- Size
- 3426 bytes
- Lines
- 139
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
lan966x_main.h
Detected Declarations
function lan966x_mirror_port_addfunction lan966x_mirror_port_delfunction lan966x_mirror_port_stats
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
#include "lan966x_main.h"
int lan966x_mirror_port_add(struct lan966x_port *port,
struct flow_action_entry *action,
unsigned long mirror_id,
bool ingress,
struct netlink_ext_ack *extack)
{
struct lan966x *lan966x = port->lan966x;
struct lan966x_port *monitor_port;
if (!lan966x_netdevice_check(action->dev)) {
NL_SET_ERR_MSG_MOD(extack,
"Destination not an lan966x port");
return -EOPNOTSUPP;
}
monitor_port = netdev_priv(action->dev);
if (lan966x->mirror_mask[ingress] & BIT(port->chip_port)) {
NL_SET_ERR_MSG_MOD(extack,
"Mirror already exists");
return -EEXIST;
}
if (lan966x->mirror_monitor &&
lan966x->mirror_monitor != monitor_port) {
NL_SET_ERR_MSG_MOD(extack,
"Cannot change mirror port while in use");
return -EBUSY;
}
if (port == monitor_port) {
NL_SET_ERR_MSG_MOD(extack,
"Cannot mirror the monitor port");
return -EINVAL;
}
lan966x->mirror_mask[ingress] |= BIT(port->chip_port);
lan966x->mirror_monitor = monitor_port;
lan_wr(BIT(monitor_port->chip_port), lan966x, ANA_MIRRORPORTS);
if (ingress) {
lan_rmw(ANA_PORT_CFG_SRC_MIRROR_ENA_SET(1),
ANA_PORT_CFG_SRC_MIRROR_ENA,
lan966x, ANA_PORT_CFG(port->chip_port));
} else {
lan_wr(lan966x->mirror_mask[0], lan966x,
ANA_EMIRRORPORTS);
}
lan966x->mirror_count++;
if (ingress)
port->tc.ingress_mirror_id = mirror_id;
else
port->tc.egress_mirror_id = mirror_id;
return 0;
}
int lan966x_mirror_port_del(struct lan966x_port *port,
bool ingress,
struct netlink_ext_ack *extack)
{
struct lan966x *lan966x = port->lan966x;
if (!(lan966x->mirror_mask[ingress] & BIT(port->chip_port))) {
NL_SET_ERR_MSG_MOD(extack,
"There is no mirroring for this port");
return -ENOENT;
}
lan966x->mirror_mask[ingress] &= ~BIT(port->chip_port);
if (ingress) {
lan_rmw(ANA_PORT_CFG_SRC_MIRROR_ENA_SET(0),
ANA_PORT_CFG_SRC_MIRROR_ENA,
lan966x, ANA_PORT_CFG(port->chip_port));
} else {
lan_wr(lan966x->mirror_mask[0], lan966x,
ANA_EMIRRORPORTS);
}
lan966x->mirror_count--;
if (lan966x->mirror_count == 0) {
Annotation
- Immediate include surface: `lan966x_main.h`.
- Detected declarations: `function lan966x_mirror_port_add`, `function lan966x_mirror_port_del`, `function lan966x_mirror_port_stats`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source 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.