drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c- Extension
.c- Size
- 45558 bytes
- Lines
- 1688
- 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
linux/ptp_clock_kernel.hlinux/clocksource.hlinux/timecounter.hlinux/spinlock.hlinux/device.hlinux/rhashtable.hlinux/ptp_classify.hlinux/if_ether.hlinux/if_vlan.hlinux/net_tstamp.hlinux/refcount.hspectrum.hspectrum_ptp.hcore.htxheader.h
Detected Declarations
struct mlxsw_sp_ptp_statestruct mlxsw_sp1_ptp_statestruct mlxsw_sp2_ptp_statestruct mlxsw_sp1_ptp_keystruct mlxsw_sp1_ptp_unmatchedstruct mlxsw_sp_ptp_clockstruct mlxsw_sp1_ptp_clockstruct mlxsw_sp1_ptp_shaper_paramsstruct mlxsw_sp_ptp_port_statfunction mlxsw_sp1_ptp_statefunction mlxsw_sp2_ptp_statefunction mlxsw_sp1_ptp_clockfunction __mlxsw_sp1_ptp_read_frcfunction mlxsw_sp1_ptp_read_frcfunction mlxsw_sp_ptp_phc_adjfreqfunction mlxsw_sp1_ptp_ns2cyclesfunction mlxsw_sp1_ptp_phc_settimefunction mlxsw_sp1_ptp_adjfinefunction mlxsw_sp1_ptp_adjtimefunction mlxsw_sp1_ptp_gettimexfunction mlxsw_sp1_ptp_settimefunction mlxsw_sp1_ptp_clock_overflowfunction mlxsw_sp1_ptp_clock_initfunction mlxsw_sp1_ptp_clock_finifunction mlxsw_sp2_ptp_read_utcfunction mlxsw_sp2_ptp_phc_settimefunction mlxsw_sp2_ptp_adjfinefunction mlxsw_sp2_ptp_adjtimefunction mlxsw_sp2_ptp_gettimexfunction mlxsw_sp2_ptp_settimefunction mlxsw_sp2_ptp_clock_initfunction mlxsw_sp2_ptp_clock_finifunction mlxsw_sp_ptp_parsefunction mlxsw_sp1_ptp_unmatched_savefunction mlxsw_sp1_ptp_unmatched_lookupfunction mlxsw_sp1_ptp_unmatched_removefunction mlxsw_sp1_ptp_packet_finishfunction mlxsw_sp1_packet_timestampfunction mlxsw_sp1_ptp_unmatched_finishfunction mlxsw_sp1_ptp_unmatched_free_fnfunction mlxsw_sp1_ptp_got_piecefunction mlxsw_sp1_ptp_got_packetfunction mlxsw_sp1_ptp_got_timestampfunction mlxsw_sp1_ptp_receivefunction mlxsw_sp1_ptp_transmittedfunction mlxsw_sp1_ptp_ht_gc_collectfunction mlxsw_sp1_ptp_ht_gcfunction mlxsw_sp_ptp_mtptpt_set
Annotated Snippet
struct mlxsw_sp_ptp_state {
struct mlxsw_sp *mlxsw_sp;
};
struct mlxsw_sp1_ptp_state {
struct mlxsw_sp_ptp_state common;
struct rhltable unmatched_ht;
spinlock_t unmatched_lock; /* protects the HT */
struct delayed_work ht_gc_dw;
u32 gc_cycle;
};
struct mlxsw_sp2_ptp_state {
struct mlxsw_sp_ptp_state common;
refcount_t ptp_port_enabled_ref; /* Number of ports with time stamping
* enabled.
*/
struct kernel_hwtstamp_config config;
struct mutex lock; /* Protects 'config' and HW configuration. */
};
struct mlxsw_sp1_ptp_key {
u16 local_port;
u8 message_type;
u16 sequence_id;
u8 domain_number;
bool ingress;
};
struct mlxsw_sp1_ptp_unmatched {
struct mlxsw_sp1_ptp_key key;
struct rhlist_head ht_node;
struct rcu_head rcu;
struct sk_buff *skb;
u64 timestamp;
u32 gc_cycle;
};
static const struct rhashtable_params mlxsw_sp1_ptp_unmatched_ht_params = {
.key_len = sizeof_field(struct mlxsw_sp1_ptp_unmatched, key),
.key_offset = offsetof(struct mlxsw_sp1_ptp_unmatched, key),
.head_offset = offsetof(struct mlxsw_sp1_ptp_unmatched, ht_node),
};
struct mlxsw_sp_ptp_clock {
struct mlxsw_core *core;
struct ptp_clock *ptp;
struct ptp_clock_info ptp_info;
};
struct mlxsw_sp1_ptp_clock {
struct mlxsw_sp_ptp_clock common;
spinlock_t lock; /* protect this structure */
struct cyclecounter cycles;
struct timecounter tc;
u32 nominal_c_mult;
unsigned long overflow_period;
struct delayed_work overflow_work;
};
static struct mlxsw_sp1_ptp_state *
mlxsw_sp1_ptp_state(struct mlxsw_sp *mlxsw_sp)
{
return container_of(mlxsw_sp->ptp_state, struct mlxsw_sp1_ptp_state,
common);
}
static struct mlxsw_sp2_ptp_state *
mlxsw_sp2_ptp_state(struct mlxsw_sp *mlxsw_sp)
{
return container_of(mlxsw_sp->ptp_state, struct mlxsw_sp2_ptp_state,
common);
}
static struct mlxsw_sp1_ptp_clock *
mlxsw_sp1_ptp_clock(struct ptp_clock_info *ptp)
{
return container_of(ptp, struct mlxsw_sp1_ptp_clock, common.ptp_info);
}
static u64 __mlxsw_sp1_ptp_read_frc(struct mlxsw_sp1_ptp_clock *clock,
struct ptp_system_timestamp *sts)
{
struct mlxsw_core *mlxsw_core = clock->common.core;
u32 frc_h1, frc_h2, frc_l;
frc_h1 = mlxsw_core_read_frc_h(mlxsw_core);
ptp_read_system_prets(sts);
frc_l = mlxsw_core_read_frc_l(mlxsw_core);
ptp_read_system_postts(sts);
Annotation
- Immediate include surface: `linux/ptp_clock_kernel.h`, `linux/clocksource.h`, `linux/timecounter.h`, `linux/spinlock.h`, `linux/device.h`, `linux/rhashtable.h`, `linux/ptp_classify.h`, `linux/if_ether.h`.
- Detected declarations: `struct mlxsw_sp_ptp_state`, `struct mlxsw_sp1_ptp_state`, `struct mlxsw_sp2_ptp_state`, `struct mlxsw_sp1_ptp_key`, `struct mlxsw_sp1_ptp_unmatched`, `struct mlxsw_sp_ptp_clock`, `struct mlxsw_sp1_ptp_clock`, `struct mlxsw_sp1_ptp_shaper_params`, `struct mlxsw_sp_ptp_port_stat`, `function mlxsw_sp1_ptp_state`.
- 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.