drivers/net/ethernet/intel/igb/igb_ptp.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/intel/igb/igb_ptp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/intel/igb/igb_ptp.c- Extension
.c- Size
- 43085 bytes
- Lines
- 1520
- 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/module.hlinux/device.hlinux/pci.hlinux/ptp_classify.higb.h
Detected Declarations
function igb_ptp_read_82576function igb_ptp_read_82580function igb_ptp_read_i210function igb_ptp_write_i210function twofunction igb_ptp_adjfine_82576function igb_ptp_adjfine_82580function igb_ptp_adjtime_82576function igb_ptp_adjtime_i210function igb_ptp_gettimex_82576function igb_ptp_gettimex_82580function igb_ptp_gettimex_i210function igb_ptp_settime_82576function igb_ptp_settime_i210function igb_pin_directionfunction igb_pin_exttsfunction igb_pin_peroutfunction igb_ptp_feature_enable_82580function igb_ptp_feature_enable_i210function igb_ptp_feature_enablefunction igb_ptp_verify_pinfunction igb_ptp_tx_workfunction igb_ptp_overflow_checkfunction igb_ptp_rx_hangfunction igb_ptp_tx_hangfunction igb_ptp_tx_hwtstampfunction igb_ptp_rx_pktstampfunction igb_ptp_rx_rgtstampfunction igb_ptp_hwtstamp_getfunction igb_ptp_set_timestamp_modefunction igb_ptp_hwtstamp_setfunction igb_ptp_initfunction igb_ptp_sdp_initfunction igb_ptp_suspendfunction igb_ptp_stopfunction igb_ptp_reset
Annotated Snippet
if (on) {
pin = ptp_find_pin(igb->ptp_clock, PTP_PF_EXTTS,
rq->extts.index);
if (pin < 0)
return -EBUSY;
}
if (rq->extts.index == 1) {
tsauxc_mask = TSAUXC_EN_TS1;
tsim_mask = TSINTR_AUTT1;
} else {
tsauxc_mask = TSAUXC_EN_TS0;
tsim_mask = TSINTR_AUTT0;
}
spin_lock_irqsave(&igb->tmreg_lock, flags);
tsauxc = rd32(E1000_TSAUXC);
tsim = rd32(E1000_TSIM);
if (on) {
igb_pin_extts(igb, rq->extts.index, pin);
tsauxc |= tsauxc_mask;
tsim |= tsim_mask;
} else {
tsauxc &= ~tsauxc_mask;
tsim &= ~tsim_mask;
}
wr32(E1000_TSAUXC, tsauxc);
wr32(E1000_TSIM, tsim);
spin_unlock_irqrestore(&igb->tmreg_lock, flags);
return 0;
case PTP_CLK_REQ_PEROUT:
/* Reject requests with unsupported flags */
if (rq->perout.flags)
return -EOPNOTSUPP;
if (on) {
pin = ptp_find_pin(igb->ptp_clock, PTP_PF_PEROUT,
rq->perout.index);
if (pin < 0)
return -EBUSY;
}
ts.tv_sec = rq->perout.period.sec;
ts.tv_nsec = rq->perout.period.nsec;
ns = timespec64_to_ns(&ts);
ns = ns >> 1;
if (on && ns < 8LL)
return -EINVAL;
ts = ns_to_timespec64(ns);
if (rq->perout.index == 1) {
tsauxc_mask = TSAUXC_EN_TT1;
tsim_mask = TSINTR_TT1;
trgttiml = E1000_TRGTTIML1;
trgttimh = E1000_TRGTTIMH1;
} else {
tsauxc_mask = TSAUXC_EN_TT0;
tsim_mask = TSINTR_TT0;
trgttiml = E1000_TRGTTIML0;
trgttimh = E1000_TRGTTIMH0;
}
spin_lock_irqsave(&igb->tmreg_lock, flags);
tsauxc = rd32(E1000_TSAUXC);
tsim = rd32(E1000_TSIM);
if (rq->perout.index == 1) {
tsauxc &= ~(TSAUXC_EN_TT1 | TSAUXC_EN_CLK1 | TSAUXC_ST1);
tsim &= ~TSINTR_TT1;
} else {
tsauxc &= ~(TSAUXC_EN_TT0 | TSAUXC_EN_CLK0 | TSAUXC_ST0);
tsim &= ~TSINTR_TT0;
}
if (on) {
int i = rq->perout.index;
/* read systim registers in sequence */
rd32(E1000_SYSTIMR);
systiml = rd32(E1000_SYSTIML);
systimh = rd32(E1000_SYSTIMH);
systim = (((u64)(systimh & 0xFF)) << 32) | ((u64)systiml);
now = timecounter_cyc2time(&igb->tc, systim);
if (pin < 2) {
level_mask = (i == 1) ? 0x80000 : 0x40000;
level = (rd32(E1000_CTRL) & level_mask) ? 1 : 0;
} else {
level_mask = (i == 1) ? 0x80 : 0x40;
level = (rd32(E1000_CTRL_EXT) & level_mask) ? 1 : 0;
}
div_u64_rem(now, ns, &rem);
systim = systim + (ns - rem);
/* synchronize pin level with rising/falling edges */
Annotation
- Immediate include surface: `linux/module.h`, `linux/device.h`, `linux/pci.h`, `linux/ptp_classify.h`, `igb.h`.
- Detected declarations: `function igb_ptp_read_82576`, `function igb_ptp_read_82580`, `function igb_ptp_read_i210`, `function igb_ptp_write_i210`, `function two`, `function igb_ptp_adjfine_82576`, `function igb_ptp_adjfine_82580`, `function igb_ptp_adjtime_82576`, `function igb_ptp_adjtime_i210`, `function igb_ptp_gettimex_82576`.
- 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.