drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/intel/idpf/idpf_virtchnl_ptp.c- Extension
.c- Size
- 20990 bytes
- Lines
- 673
- 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
idpf.hidpf_ptp.hidpf_virtchnl.h
Detected Declarations
function idpf_ptp_get_capsfunction idpf_ptp_get_dev_clk_timefunction idpf_ptp_get_cross_timefunction idpf_ptp_set_dev_clk_timefunction idpf_ptp_adj_dev_clk_timefunction idpf_ptp_adj_dev_clk_finefunction idpf_ptp_get_vport_tstamps_capsfunction idpf_ptp_update_tstamp_trackerfunction idpf_ptp_get_tstamp_valuefunction idpf_ptp_get_tx_tstamp_async_handlerfunction idpf_for_each_vportfunction list_for_each_entry_safefunction idpf_ptp_get_tx_tstamp
Annotated Snippet
if (!ptp_tx_tstamp) {
err = -ENOMEM;
goto err_free_ptp_tx_stamp_list;
}
tx_tstamp_latch_caps = rcv_tx_tstamp_caps->tstamp_latches[i];
if (tstamp_access != IDPF_PTP_DIRECT)
goto skip_offsets;
offset_l = tx_tstamp_latch_caps.tx_latch_reg_offset_l;
offset_h = tx_tstamp_latch_caps.tx_latch_reg_offset_h;
ptp_tx_tstamp->tx_latch_reg_offset_l = le32_to_cpu(offset_l);
ptp_tx_tstamp->tx_latch_reg_offset_h = le32_to_cpu(offset_h);
skip_offsets:
ptp_tx_tstamp->idx = tx_tstamp_latch_caps.index;
list_add(&ptp_tx_tstamp->list_member,
&tstamp_caps->latches_free);
tstamp_caps->tx_tstamp_status[i].state = IDPF_PTP_FREE;
}
vport->tx_tstamp_caps = tstamp_caps;
kfree(rcv_tx_tstamp_caps);
return 0;
err_free_ptp_tx_stamp_list:
head = &tstamp_caps->latches_free;
list_for_each_entry_safe(ptp_tx_tstamp, tmp, head, list_member) {
list_del(&ptp_tx_tstamp->list_member);
kfree(ptp_tx_tstamp);
}
kfree(tstamp_caps);
get_tstamp_caps_out:
kfree(rcv_tx_tstamp_caps);
return err;
}
/**
* idpf_ptp_update_tstamp_tracker - Update the Tx timestamp tracker based on
* the skb compatibility.
* @caps: Tx timestamp capabilities that monitor the latch status
* @skb: skb for which the tstamp value is returned through virtchnl message
* @current_state: Current state of the Tx timestamp latch
* @expected_state: Expected state of the Tx timestamp latch
*
* Find a proper skb tracker for which the Tx timestamp is received and change
* the state to expected value.
*
* Return: true if the tracker has been found and updated, false otherwise.
*/
static bool
idpf_ptp_update_tstamp_tracker(struct idpf_ptp_vport_tx_tstamp_caps *caps,
struct sk_buff *skb,
enum idpf_ptp_tx_tstamp_state current_state,
enum idpf_ptp_tx_tstamp_state expected_state)
{
bool updated = false;
spin_lock(&caps->status_lock);
for (u16 i = 0; i < caps->num_entries; i++) {
struct idpf_ptp_tx_tstamp_status *status;
status = &caps->tx_tstamp_status[i];
if (skb == status->skb && status->state == current_state) {
status->state = expected_state;
updated = true;
break;
}
}
spin_unlock(&caps->status_lock);
return updated;
}
/**
* idpf_ptp_get_tstamp_value - Get the Tx timestamp value and provide it
* back to the skb.
* @vport: Virtual port structure
* @tstamp_latch: Tx timestamp latch structure fulfilled by the Control Plane
* @ptp_tx_tstamp: Tx timestamp latch to add to the free list
*
* Read the value of the Tx timestamp for a given latch received from the
* Control Plane, extend it to 64 bit and provide back to the skb.
Annotation
- Immediate include surface: `idpf.h`, `idpf_ptp.h`, `idpf_virtchnl.h`.
- Detected declarations: `function idpf_ptp_get_caps`, `function idpf_ptp_get_dev_clk_time`, `function idpf_ptp_get_cross_time`, `function idpf_ptp_set_dev_clk_time`, `function idpf_ptp_adj_dev_clk_time`, `function idpf_ptp_adj_dev_clk_fine`, `function idpf_ptp_get_vport_tstamps_caps`, `function idpf_ptp_update_tstamp_tracker`, `function idpf_ptp_get_tstamp_value`, `function idpf_ptp_get_tx_tstamp_async_handler`.
- 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.