drivers/net/ethernet/marvell/octeontx2/af/ptp.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/marvell/octeontx2/af/ptp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/marvell/octeontx2/af/ptp.c- Extension
.c- Size
- 18221 bytes
- Lines
- 677
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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 an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/bitfield.hlinux/device.hlinux/module.hlinux/pci.hlinux/hrtimer.hlinux/ktime.hmbox.hptp.hrvu.h
Detected Declarations
enum atomic_opcodefunction is_ptp_dev_cnf10kafunction is_ptp_dev_cn10kafunction cn10k_ptp_erratafunction is_tstmp_atomic_update_supportedfunction ptp_reset_threshfunction ptp_hrtimer_startfunction read_ptp_tstmp_sec_nsecfunction read_ptp_tstmp_nsecfunction ptp_calc_adjusted_compfunction ptp_putfunction ptp_atomic_updatefunction ptp_atomic_adjtimefunction ptp_adjfinefunction ptp_get_clockfunction ptp_startfunction ptp_get_tstmpfunction ptp_set_threshfunction ptp_config_hrtimerfunction ptp_pps_onfunction ptp_probefunction ptp_removefunction rvu_mbox_handler_ptp_opfunction rvu_mbox_handler_ptp_get_cap
Annotated Snippet
struct pci_driver ptp_driver = {
.name = DRV_NAME,
.id_table = ptp_id_table,
.probe = ptp_probe,
.remove = ptp_remove,
};
int rvu_mbox_handler_ptp_op(struct rvu *rvu, struct ptp_req *req,
struct ptp_rsp *rsp)
{
int err = 0;
/* This function is the PTP mailbox handler invoked when
* called by AF consumers/netdev drivers via mailbox mechanism.
* It is used by netdev driver to get the PTP clock and to set
* frequency adjustments. Since mailbox can be called without
* notion of whether the driver is bound to ptp device below
* validation is needed as first step.
*/
if (!rvu->ptp)
return -ENODEV;
switch (req->op) {
case PTP_OP_ADJFINE:
err = ptp_adjfine(rvu->ptp, req->scaled_ppm);
break;
case PTP_OP_GET_CLOCK:
err = ptp_get_clock(rvu->ptp, &rsp->clk);
break;
case PTP_OP_GET_TSTMP:
err = ptp_get_tstmp(rvu->ptp, &rsp->clk);
break;
case PTP_OP_SET_THRESH:
err = ptp_set_thresh(rvu->ptp, req->thresh);
break;
case PTP_OP_PPS_ON:
err = ptp_pps_on(rvu->ptp, req->pps_on, req->period);
break;
case PTP_OP_ADJTIME:
ptp_atomic_adjtime(rvu->ptp, req->delta);
break;
case PTP_OP_SET_CLOCK:
ptp_atomic_update(rvu->ptp, (u64)req->clk);
break;
default:
err = -EINVAL;
break;
}
return err;
}
int rvu_mbox_handler_ptp_get_cap(struct rvu *rvu, struct msg_req *req,
struct ptp_get_cap_rsp *rsp)
{
if (!rvu->ptp)
return -ENODEV;
if (is_tstmp_atomic_update_supported(rvu))
rsp->cap |= PTP_CAP_HW_ATOMIC_UPDATE;
else
rsp->cap &= ~BIT_ULL_MASK(0);
return 0;
}
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/device.h`, `linux/module.h`, `linux/pci.h`, `linux/hrtimer.h`, `linux/ktime.h`, `mbox.h`, `ptp.h`.
- Detected declarations: `enum atomic_opcode`, `function is_ptp_dev_cnf10ka`, `function is_ptp_dev_cn10ka`, `function cn10k_ptp_errata`, `function is_tstmp_atomic_update_supported`, `function ptp_reset_thresh`, `function ptp_hrtimer_start`, `function read_ptp_tstmp_sec_nsec`, `function read_ptp_tstmp_nsec`, `function ptp_calc_adjusted_comp`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern 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.