drivers/net/ethernet/amazon/ena/ena_phc.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/amazon/ena/ena_phc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/amazon/ena/ena_phc.c- Extension
.c- Size
- 5615 bytes
- Lines
- 237
- 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/pci.hena_netdev.hena_phc.hena_devlink.h
Detected Declarations
function ena_phc_adjtimefunction ena_phc_adjfinefunction ena_phc_feature_enablefunction ena_phc_gettimex64function ena_phc_settime64function ena_phc_enablefunction ena_phc_is_enabledfunction ena_phc_is_activefunction ena_phc_registerfunction ena_phc_unregisterfunction ena_phc_allocfunction ena_phc_freefunction ena_phc_initfunction ena_phc_destroyfunction ena_phc_get_index
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
/*
* Copyright 2015-2022 Amazon.com, Inc. or its affiliates. All rights reserved.
*/
#include <linux/pci.h>
#include "ena_netdev.h"
#include "ena_phc.h"
#include "ena_devlink.h"
static int ena_phc_adjtime(struct ptp_clock_info *clock_info, s64 delta)
{
return -EOPNOTSUPP;
}
static int ena_phc_adjfine(struct ptp_clock_info *clock_info, long scaled_ppm)
{
return -EOPNOTSUPP;
}
static int ena_phc_feature_enable(struct ptp_clock_info *clock_info,
struct ptp_clock_request *rq,
int on)
{
return -EOPNOTSUPP;
}
static int ena_phc_gettimex64(struct ptp_clock_info *clock_info,
struct timespec64 *ts,
struct ptp_system_timestamp *sts)
{
struct ena_phc_info *phc_info =
container_of(clock_info, struct ena_phc_info, clock_info);
unsigned long flags;
u64 timestamp_nsec;
int rc;
spin_lock_irqsave(&phc_info->lock, flags);
ptp_read_system_prets(sts);
rc = ena_com_phc_get_timestamp(phc_info->adapter->ena_dev,
×tamp_nsec);
ptp_read_system_postts(sts);
spin_unlock_irqrestore(&phc_info->lock, flags);
if (rc)
return rc;
*ts = ns_to_timespec64(timestamp_nsec);
return 0;
}
static int ena_phc_settime64(struct ptp_clock_info *clock_info,
const struct timespec64 *ts)
{
return -EOPNOTSUPP;
}
static struct ptp_clock_info ena_ptp_clock_info = {
.owner = THIS_MODULE,
.n_alarm = 0,
.n_ext_ts = 0,
.n_per_out = 0,
.pps = 0,
.adjtime = ena_phc_adjtime,
.adjfine = ena_phc_adjfine,
.gettimex64 = ena_phc_gettimex64,
.settime64 = ena_phc_settime64,
.enable = ena_phc_feature_enable,
};
/* Enable/Disable PHC by the kernel, affects on the next init flow */
void ena_phc_enable(struct ena_adapter *adapter, bool enable)
{
struct ena_phc_info *phc_info = adapter->phc_info;
if (!phc_info) {
netdev_err(adapter->netdev, "phc_info is not allocated\n");
return;
}
phc_info->enabled = enable;
}
/* Check if PHC is enabled by the kernel */
bool ena_phc_is_enabled(struct ena_adapter *adapter)
Annotation
- Immediate include surface: `linux/pci.h`, `ena_netdev.h`, `ena_phc.h`, `ena_devlink.h`.
- Detected declarations: `function ena_phc_adjtime`, `function ena_phc_adjfine`, `function ena_phc_feature_enable`, `function ena_phc_gettimex64`, `function ena_phc_settime64`, `function ena_phc_enable`, `function ena_phc_is_enabled`, `function ena_phc_is_active`, `function ena_phc_register`, `function ena_phc_unregister`.
- 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.