drivers/net/ethernet/google/gve/gve_ptp.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/google/gve/gve_ptp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/google/gve/gve_ptp.c- Extension
.c- Size
- 3432 bytes
- Lines
- 159
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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
gve.hgve_adminq.h
Detected Declarations
function Copyrightfunction gve_ptp_gettimex64function gve_ptp_settime64function gve_ptp_do_aux_workfunction gve_ptp_initfunction gve_ptp_releasefunction gve_init_clockfunction gve_teardown_clock
Annotated Snippet
// SPDX-License-Identifier: (GPL-2.0 OR MIT)
/* Google virtual Ethernet (gve) driver
*
* Copyright (C) 2025 Google LLC
*/
#include "gve.h"
#include "gve_adminq.h"
/* Interval to schedule a nic timestamp calibration, 250ms. */
#define GVE_NIC_TS_SYNC_INTERVAL_MS 250
/* Read the nic timestamp from hardware via the admin queue. */
int gve_clock_nic_ts_read(struct gve_priv *priv)
{
u64 nic_raw;
int err;
err = gve_adminq_report_nic_ts(priv, priv->nic_ts_report_bus);
if (err)
return err;
nic_raw = be64_to_cpu(priv->nic_ts_report->nic_timestamp);
WRITE_ONCE(priv->last_sync_nic_counter, nic_raw);
return 0;
}
static int gve_ptp_gettimex64(struct ptp_clock_info *info,
struct timespec64 *ts,
struct ptp_system_timestamp *sts)
{
return -EOPNOTSUPP;
}
static int gve_ptp_settime64(struct ptp_clock_info *info,
const struct timespec64 *ts)
{
return -EOPNOTSUPP;
}
static long gve_ptp_do_aux_work(struct ptp_clock_info *info)
{
const struct gve_ptp *ptp = container_of(info, struct gve_ptp, info);
struct gve_priv *priv = ptp->priv;
int err;
if (gve_get_reset_in_progress(priv) || !gve_get_admin_queue_ok(priv))
goto out;
err = gve_clock_nic_ts_read(priv);
if (err && net_ratelimit())
dev_err(&priv->pdev->dev,
"%s read err %d\n", __func__, err);
out:
return msecs_to_jiffies(GVE_NIC_TS_SYNC_INTERVAL_MS);
}
static const struct ptp_clock_info gve_ptp_caps = {
.owner = THIS_MODULE,
.name = "gve clock",
.gettimex64 = gve_ptp_gettimex64,
.settime64 = gve_ptp_settime64,
.do_aux_work = gve_ptp_do_aux_work,
};
static int gve_ptp_init(struct gve_priv *priv)
{
struct gve_ptp *ptp;
int err;
priv->ptp = kzalloc_obj(*priv->ptp);
if (!priv->ptp)
return -ENOMEM;
ptp = priv->ptp;
ptp->info = gve_ptp_caps;
ptp->clock = ptp_clock_register(&ptp->info, &priv->pdev->dev);
if (IS_ERR(ptp->clock)) {
dev_err(&priv->pdev->dev, "PTP clock registration failed\n");
err = PTR_ERR(ptp->clock);
goto free_ptp;
}
ptp->priv = priv;
return 0;
free_ptp:
Annotation
- Immediate include surface: `gve.h`, `gve_adminq.h`.
- Detected declarations: `function Copyright`, `function gve_ptp_gettimex64`, `function gve_ptp_settime64`, `function gve_ptp_do_aux_work`, `function gve_ptp_init`, `function gve_ptp_release`, `function gve_init_clock`, `function gve_teardown_clock`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- 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.