drivers/net/phy/mscc/mscc_ptp.c
Source file repositories/reference/linux-study-clean/drivers/net/phy/mscc/mscc_ptp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/phy/mscc/mscc_ptp.c- Extension
.c- Size
- 49356 bytes
- Lines
- 1646
- 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.
- 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/gpio/consumer.hlinux/ip.hlinux/net_tstamp.hlinux/mii.hlinux/phy.hlinux/ptp_classify.hlinux/ptp_clock_kernel.hlinux/udp.hlinux/unaligned.h../phylib.hmscc.hmscc_ptp.h
Detected Declarations
enum ts_blk_hwenum ts_blkfunction Copyrightfunction phy_ts_base_readfunction vsc85xx_ts_read_csrfunction vsc85xx_ts_write_csrfunction vsc85xx_ts_fsb_initfunction vsc85xx_ts_set_latenciesfunction vsc85xx_ts_disable_flowsfunction vsc85xx_ts_eth_cmp1_sigfunction get_sigfunction vsc85xx_dequeue_skbfunction vsc85xx_get_tx_tsfunction vsc85xx_ptp_cmp_initfunction vsc85xx_eth_cmp1_initfunction vsc85xx_ip_cmp1_initfunction vsc85xx_adjfinefunction __vsc85xx_gettimefunction vsc85xx_gettimefunction __vsc85xx_settimefunction vsc85xx_settimefunction vsc85xx_adjtimefunction vsc85xx_eth1_next_compfunction vsc85xx_ip1_next_compfunction vsc85xx_ts_ptp_action_flowfunction vsc85xx_ptp_conffunction vsc85xx_eth1_conffunction vsc85xx_ip1_conffunction vsc85xx_ts_engine_initfunction vsc85xx_link_change_notifyfunction vsc85xx_ts_reset_fifofunction vsc85xx_hwtstamp_getfunction vsc85xx_hwtstamp_setfunction vsc85xx_ts_infofunction vsc85xx_txtstampfunction vsc85xx_rxtstampfunction vsc85xx_do_aux_workfunction vsc8584_is_1588_input_clk_configuredfunction vsc8584_set_input_clk_configuredfunction __vsc8584_init_ptpfunction vsc8584_config_ts_intrfunction vsc8584_ptp_initfunction vsc8584_ptp_deinitfunction vsc8584_handle_ts_interruptfunction vsc8584_ptp_probefunction vsc8584_ptp_probe_once
Annotated Snippet
if (get_sig(skb, skb_sig) < 0) {
kfree_skb(skb);
continue;
}
/* Check if we found the signature we were looking for. */
if (!memcmp(skb_sig, fifo.sig, sizeof(fifo.sig))) {
memset(&shhwtstamps, 0, sizeof(shhwtstamps));
shhwtstamps.hwtstamp = ktime_set(fifo.secs, fifo.ns);
skb_complete_tx_timestamp(skb, &shhwtstamps);
return;
}
/* Valid signature but does not match the one of the
* packet in the FIFO right now, reschedule it for later
* packets.
*/
skb_queue_tail(&ptp->tx_queue, skb);
}
}
static void vsc85xx_get_tx_ts(struct vsc85xx_ptp *ptp)
{
u32 reg;
do {
vsc85xx_dequeue_skb(ptp);
/* If other timestamps are available in the FIFO, process them. */
reg = vsc85xx_ts_read_csr(ptp->phydev, PROCESSOR,
MSCC_PHY_PTP_EGR_TS_FIFO_CTRL);
} while (PTP_EGR_FIFO_LEVEL_LAST_READ(reg) > 1);
}
static int vsc85xx_ptp_cmp_init(struct phy_device *phydev, enum ts_blk blk)
{
struct vsc8531_private *vsc8531 = phydev->priv;
bool base = phydev->mdio.addr == vsc8531->ts_base_addr;
static const u8 msgs[] = {
PTP_MSGTYPE_SYNC,
PTP_MSGTYPE_DELAY_REQ
};
u32 val;
u8 i;
for (i = 0; i < ARRAY_SIZE(msgs); i++) {
vsc85xx_ts_write_csr(phydev, blk, MSCC_ANA_PTP_FLOW_ENA(i),
base ? PTP_FLOW_VALID_CH0 :
PTP_FLOW_VALID_CH1);
val = vsc85xx_ts_read_csr(phydev, blk,
MSCC_ANA_PTP_FLOW_DOMAIN_RANGE(i));
val &= ~PTP_FLOW_DOMAIN_RANGE_ENA;
vsc85xx_ts_write_csr(phydev, blk,
MSCC_ANA_PTP_FLOW_DOMAIN_RANGE(i), val);
vsc85xx_ts_write_csr(phydev, blk,
MSCC_ANA_PTP_FLOW_MATCH_UPPER(i),
msgs[i] << 24);
vsc85xx_ts_write_csr(phydev, blk,
MSCC_ANA_PTP_FLOW_MASK_UPPER(i),
PTP_FLOW_MSG_TYPE_MASK);
}
return 0;
}
static int vsc85xx_eth_cmp1_init(struct phy_device *phydev, enum ts_blk blk)
{
struct vsc8531_private *vsc8531 = phydev->priv;
bool base = phydev->mdio.addr == vsc8531->ts_base_addr;
u32 val;
vsc85xx_ts_write_csr(phydev, blk, MSCC_PHY_ANA_ETH1_NXT_PROT_TAG, 0);
vsc85xx_ts_write_csr(phydev, blk, MSCC_PHY_ANA_ETH1_NTX_PROT_VLAN_TPID,
ANA_ETH1_NTX_PROT_VLAN_TPID(ETH_P_8021AD));
vsc85xx_ts_write_csr(phydev, blk, MSCC_ANA_ETH1_FLOW_ENA(0),
base ? ETH1_FLOW_VALID_CH0 : ETH1_FLOW_VALID_CH1);
vsc85xx_ts_write_csr(phydev, blk, MSCC_ANA_ETH1_FLOW_MATCH_MODE(0),
ANA_ETH1_FLOW_MATCH_VLAN_TAG2);
vsc85xx_ts_write_csr(phydev, blk, MSCC_ANA_ETH1_FLOW_ADDR_MATCH1(0), 0);
vsc85xx_ts_write_csr(phydev, blk, MSCC_ANA_ETH1_FLOW_ADDR_MATCH2(0), 0);
vsc85xx_ts_write_csr(phydev, blk,
MSCC_ANA_ETH1_FLOW_VLAN_RANGE_I_TAG(0), 0);
vsc85xx_ts_write_csr(phydev, blk, MSCC_ANA_ETH1_FLOW_VLAN_TAG1(0), 0);
vsc85xx_ts_write_csr(phydev, blk,
MSCC_ANA_ETH1_FLOW_VLAN_TAG2_I_TAG(0), 0);
Annotation
- Immediate include surface: `linux/gpio/consumer.h`, `linux/ip.h`, `linux/net_tstamp.h`, `linux/mii.h`, `linux/phy.h`, `linux/ptp_classify.h`, `linux/ptp_clock_kernel.h`, `linux/udp.h`.
- Detected declarations: `enum ts_blk_hw`, `enum ts_blk`, `function Copyright`, `function phy_ts_base_read`, `function vsc85xx_ts_read_csr`, `function vsc85xx_ts_write_csr`, `function vsc85xx_ts_fsb_init`, `function vsc85xx_ts_set_latencies`, `function vsc85xx_ts_disable_flows`, `function vsc85xx_ts_eth_cmp1_sig`.
- 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.