drivers/net/ethernet/microchip/sparx5/lan969x/lan969x.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/microchip/sparx5/lan969x/lan969x.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/microchip/sparx5/lan969x/lan969x.c- Extension
.c- Size
- 12152 bytes
- Lines
- 358
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
lan969x.h
Detected Declarations
function lan969x_get_hsch_max_group_ratefunction lan969x_get_dev_mode_bitfunction lan969x_port_dev_mappingfunction lan969x_port_mux_setfunction lan969x_ptp_irq_handlerfunction skb_queue_walk_safe
Annotated Snippet
switch (port) {
case 9:
return 0;
case 13:
return 1;
case 17:
return 2;
case 21:
return 3;
}
}
if (lan969x_port_is_10g(port)) {
switch (port) {
case 0:
return 0;
case 4:
return 1;
case 8:
return 2;
case 12:
return 3;
case 16:
return 4;
case 20:
return 5;
case 24:
return 6;
case 25:
return 7;
case 26:
return 8;
case 27:
return 9;
}
}
/* 2g5 port */
return port;
}
static int lan969x_port_mux_set(struct sparx5 *sparx5, struct sparx5_port *port,
struct sparx5_port_config *conf)
{
u32 portno = port->portno;
u32 inst;
if (port->conf.portmode == conf->portmode)
return 0; /* Nothing to do */
switch (conf->portmode) {
case PHY_INTERFACE_MODE_QSGMII: /* QSGMII: 4x2G5 devices. Mode Q' */
inst = (portno - portno % 4) / 4;
spx5_rmw(BIT(inst), BIT(inst), sparx5, PORT_CONF_QSGMII_ENA);
break;
default:
break;
}
return 0;
}
static irqreturn_t lan969x_ptp_irq_handler(int irq, void *args)
{
int budget = SPARX5_MAX_PTP_ID;
struct sparx5 *sparx5 = args;
while (budget--) {
struct sk_buff *skb, *skb_tmp, *skb_match = NULL;
struct skb_shared_hwtstamps shhwtstamps;
struct sparx5_port *port;
struct timespec64 ts;
unsigned long flags;
u32 val, id, txport;
u32 delay;
val = spx5_rd(sparx5, PTP_TWOSTEP_CTRL);
/* Check if a timestamp can be retrieved */
if (!(val & PTP_TWOSTEP_CTRL_PTP_VLD))
break;
WARN_ON(val & PTP_TWOSTEP_CTRL_PTP_OVFL);
if (!(val & PTP_TWOSTEP_CTRL_STAMP_TX))
continue;
/* Retrieve the ts Tx port */
txport = PTP_TWOSTEP_CTRL_STAMP_PORT_GET(val);
/* Retrieve its associated skb */
Annotation
- Immediate include surface: `lan969x.h`.
- Detected declarations: `function lan969x_get_hsch_max_group_rate`, `function lan969x_get_dev_mode_bit`, `function lan969x_port_dev_mapping`, `function lan969x_port_mux_set`, `function lan969x_ptp_irq_handler`, `function skb_queue_walk_safe`.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.