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.

Dependency Surface

Detected Declarations

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

Implementation Notes