drivers/net/ethernet/intel/iavf/iavf_ptp.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/intel/iavf/iavf_ptp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/intel/iavf/iavf_ptp.c- Extension
.c- Size
- 14699 bytes
- Lines
- 493
- 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.
- 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
iavf.hiavf_ptp.h
Detected Declarations
function iavf_ptp_disable_rx_tstampfunction iavf_ptp_enable_rx_tstampfunction iavf_ptp_set_timestamp_modefunction iavf_ptp_set_ts_configfunction iavf_ptp_cap_supportedfunction iavf_queue_ptp_cmdfunction iavf_send_phc_readfunction iavf_read_phc_indirectfunction iavf_ptp_gettimex64function iavf_ptp_settime64function iavf_ptp_cache_phc_timefunction iavf_ptp_do_aux_workfunction iavf_ptp_register_clockfunction iavf_ptp_initfunction iavf_ptp_releasefunction iavf_ptp_process_capsfunction by
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/* Copyright(c) 2024 Intel Corporation. */
#include "iavf.h"
#include "iavf_ptp.h"
#define iavf_clock_to_adapter(info) \
container_of_const(info, struct iavf_adapter, ptp.info)
/**
* iavf_ptp_disable_rx_tstamp - Disable timestamping in Rx rings
* @adapter: private adapter structure
*
* Disable timestamp reporting for all Rx rings.
*/
static void iavf_ptp_disable_rx_tstamp(struct iavf_adapter *adapter)
{
for (u32 i = 0; i < adapter->num_active_queues; i++)
adapter->rx_rings[i].flags &= ~IAVF_TXRX_FLAGS_HW_TSTAMP;
}
/**
* iavf_ptp_enable_rx_tstamp - Enable timestamping in Rx rings
* @adapter: private adapter structure
*
* Enable timestamp reporting for all Rx rings.
*/
static void iavf_ptp_enable_rx_tstamp(struct iavf_adapter *adapter)
{
for (u32 i = 0; i < adapter->num_active_queues; i++)
adapter->rx_rings[i].flags |= IAVF_TXRX_FLAGS_HW_TSTAMP;
}
/**
* iavf_ptp_set_timestamp_mode - Set device timestamping mode
* @adapter: private adapter structure
* @config: pointer to kernel_hwtstamp_config
*
* Set the timestamping mode requested from the userspace.
*
* Note: this function always translates Rx timestamp requests for any packet
* category into HWTSTAMP_FILTER_ALL.
*
* Return: 0 on success, negative error code otherwise.
*/
static int iavf_ptp_set_timestamp_mode(struct iavf_adapter *adapter,
struct kernel_hwtstamp_config *config)
{
/* Reserved for future extensions. */
if (config->flags)
return -EINVAL;
switch (config->tx_type) {
case HWTSTAMP_TX_OFF:
break;
case HWTSTAMP_TX_ON:
return -EOPNOTSUPP;
default:
return -ERANGE;
}
if (config->rx_filter == HWTSTAMP_FILTER_NONE) {
iavf_ptp_disable_rx_tstamp(adapter);
return 0;
} else if (config->rx_filter > HWTSTAMP_FILTER_NTP_ALL) {
return -ERANGE;
} else if (!(iavf_ptp_cap_supported(adapter,
VIRTCHNL_1588_PTP_CAP_RX_TSTAMP))) {
return -EOPNOTSUPP;
}
config->rx_filter = HWTSTAMP_FILTER_ALL;
iavf_ptp_enable_rx_tstamp(adapter);
return 0;
}
/**
* iavf_ptp_set_ts_config - Set timestamping configuration
* @adapter: private adapter structure
* @config: pointer to kernel_hwtstamp_config structure
* @extack: pointer to netlink_ext_ack structure
*
* Program the requested timestamping configuration to the device.
*
* Return: 0 on success, negative error code otherwise.
*/
int iavf_ptp_set_ts_config(struct iavf_adapter *adapter,
struct kernel_hwtstamp_config *config,
struct netlink_ext_ack *extack)
Annotation
- Immediate include surface: `iavf.h`, `iavf_ptp.h`.
- Detected declarations: `function iavf_ptp_disable_rx_tstamp`, `function iavf_ptp_enable_rx_tstamp`, `function iavf_ptp_set_timestamp_mode`, `function iavf_ptp_set_ts_config`, `function iavf_ptp_cap_supported`, `function iavf_queue_ptp_cmd`, `function iavf_send_phc_read`, `function iavf_read_phc_indirect`, `function iavf_ptp_gettimex64`, `function iavf_ptp_settime64`.
- 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.