drivers/net/dsa/microchip/ksz_ptp.c
Source file repositories/reference/linux-study-clean/drivers/net/dsa/microchip/ksz_ptp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/dsa/microchip/ksz_ptp.c- Extension
.c- Size
- 28580 bytes
- Lines
- 1209
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/dsa/ksz_common.hlinux/irq.hlinux/irqdomain.hlinux/kernel.hlinux/ptp_classify.hlinux/ptp_clock_kernel.hksz_common.hksz_ptp.hksz_ptp_reg.h
Detected Declarations
function Copyrightfunction ksz_ptp_tou_resetfunction ksz_ptp_tou_pulse_verifyfunction ksz_ptp_tou_target_time_setfunction ksz_ptp_tou_startfunction ksz_ptp_configure_peroutfunction ksz_ptp_enable_peroutfunction ksz_ptp_enable_modefunction dsa_switch_for_each_user_portfunction ksz_get_ts_infofunction ksz_hwtstamp_getfunction ksz_set_hwtstamp_configfunction ksz_hwtstamp_setfunction ksz_tstamp_reconstructfunction ksz_port_rxtstampfunction ksz_port_txtstampfunction ksz_ptp_txtstamp_skbfunction ksz_port_deferred_xmitfunction _ksz_ptp_gettimefunction ksz_ptp_gettimefunction ksz_ptp_restart_peroutfunction ksz_ptp_settimefunction ksz_ptp_adjfinefunction ksz_ptp_adjtimefunction ksz_ptp_enablefunction ksz_ptp_verify_pinfunction ksz_ptp_do_aux_workfunction ksz_ptp_start_clockfunction ksz_ptp_clock_registerfunction ksz_ptp_clock_unregisterfunction ksz_read_tsfunction ksz_ptp_msg_thread_fnfunction ksz_ptp_irq_thread_fnfunction ksz_ptp_irq_maskfunction ksz_ptp_irq_unmaskfunction ksz_ptp_irq_bus_lockfunction ksz_ptp_irq_bus_sync_unlockfunction ksz_ptp_irq_domain_mapfunction ksz_ptp_msg_irq_freefunction ksz_ptp_msg_irq_setupfunction ksz_ptp_irq_setupfunction ksz_ptp_irq_free
Annotated Snippet
if (prt->hwts_tx_en || prt->hwts_rx_en) {
tag_en = true;
break;
}
}
if (tag_en) {
ptp_schedule_worker(ptp_data->clock, 0);
} else {
ptp_cancel_worker_sync(ptp_data->clock);
}
tagger_data->hwtstamp_set_state(dev->ds, tag_en);
return ksz_rmw16(dev, regs[PTP_MSG_CONF1], PTP_ENABLE,
tag_en ? PTP_ENABLE : 0);
}
/* The function is return back the capability of timestamping feature when
* requested through ethtool -T <interface> utility
*/
int ksz_get_ts_info(struct dsa_switch *ds, int port, struct kernel_ethtool_ts_info *ts)
{
struct ksz_device *dev = ds->priv;
struct ksz_ptp_data *ptp_data;
ptp_data = &dev->ptp_data;
if (!ptp_data->clock)
return -ENODEV;
ts->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE |
SOF_TIMESTAMPING_RX_HARDWARE |
SOF_TIMESTAMPING_RAW_HARDWARE;
ts->tx_types = BIT(HWTSTAMP_TX_OFF) | BIT(HWTSTAMP_TX_ONESTEP_P2P);
if (is_lan937x(dev))
ts->tx_types |= BIT(HWTSTAMP_TX_ON);
ts->rx_filters = BIT(HWTSTAMP_FILTER_NONE) |
BIT(HWTSTAMP_FILTER_PTP_V2_L4_EVENT) |
BIT(HWTSTAMP_FILTER_PTP_V2_L2_EVENT) |
BIT(HWTSTAMP_FILTER_PTP_V2_EVENT);
ts->phc_index = ptp_clock_index(ptp_data->clock);
return 0;
}
int ksz_hwtstamp_get(struct dsa_switch *ds, int port,
struct kernel_hwtstamp_config *config)
{
struct ksz_device *dev = ds->priv;
struct ksz_port *prt;
prt = &dev->ports[port];
*config = prt->tstamp_config;
return 0;
}
static int ksz_set_hwtstamp_config(struct ksz_device *dev,
struct ksz_port *prt,
struct kernel_hwtstamp_config *config)
{
const u16 *regs = dev->info->regs;
int ret;
if (config->flags)
return -EINVAL;
switch (config->tx_type) {
case HWTSTAMP_TX_OFF:
prt->ptpmsg_irq[KSZ_SYNC_MSG].ts_en = false;
prt->ptpmsg_irq[KSZ_XDREQ_MSG].ts_en = false;
prt->ptpmsg_irq[KSZ_PDRES_MSG].ts_en = false;
prt->hwts_tx_en = false;
break;
case HWTSTAMP_TX_ONESTEP_P2P:
prt->ptpmsg_irq[KSZ_SYNC_MSG].ts_en = false;
prt->ptpmsg_irq[KSZ_XDREQ_MSG].ts_en = true;
prt->ptpmsg_irq[KSZ_PDRES_MSG].ts_en = false;
prt->hwts_tx_en = true;
ret = ksz_rmw16(dev, regs[PTP_MSG_CONF1], PTP_1STEP, PTP_1STEP);
if (ret)
return ret;
break;
Annotation
- Immediate include surface: `linux/dsa/ksz_common.h`, `linux/irq.h`, `linux/irqdomain.h`, `linux/kernel.h`, `linux/ptp_classify.h`, `linux/ptp_clock_kernel.h`, `ksz_common.h`, `ksz_ptp.h`.
- Detected declarations: `function Copyright`, `function ksz_ptp_tou_reset`, `function ksz_ptp_tou_pulse_verify`, `function ksz_ptp_tou_target_time_set`, `function ksz_ptp_tou_start`, `function ksz_ptp_configure_perout`, `function ksz_ptp_enable_perout`, `function ksz_ptp_enable_mode`, `function dsa_switch_for_each_user_port`, `function ksz_get_ts_info`.
- 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.
- 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.