drivers/net/dsa/mv88e6xxx/hwtstamp.c
Source file repositories/reference/linux-study-clean/drivers/net/dsa/mv88e6xxx/hwtstamp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/dsa/mv88e6xxx/hwtstamp.c- Extension
.c- Size
- 15918 bytes
- Lines
- 612
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
chip.hglobal2.hhwtstamp.hptp.hlinux/ptp_classify.h
Detected Declarations
function Copyrightfunction mv88e6xxx_port_ptp_writefunction mv88e6xxx_ptp_writefunction mv88e6xxx_ptp_readfunction mv88e6xxx_get_ts_infofunction mv88e6xxx_set_hwtstamp_configfunction mv88e6xxx_port_hwtstamp_setfunction mv88e6xxx_port_hwtstamp_getfunction mv88e6xxx_ts_validfunction seq_matchfunction mv88e6xxx_get_rxtsfunction mv88e6xxx_rxtstamp_workfunction is_pdelay_respfunction mv88e6xxx_port_rxtstampfunction mv88e6xxx_txtstamp_workfunction mv88e6xxx_hwtstamp_workfunction mv88e6xxx_port_txtstampfunction mv88e6165_global_disablefunction mv88e6165_global_enablefunction mv88e6352_hwtstamp_port_disablefunction mv88e6352_hwtstamp_port_enablefunction mv88e6xxx_hwtstamp_port_setupfunction mv88e6xxx_hwtstamp_setupfunction mv88e6xxx_hwtstamp_free
Annotated Snippet
if (mv88e6xxx_ts_valid(status) && seq_match(skb, seq_id)) {
ns = timehi << 16 | timelo;
mv88e6xxx_reg_lock(chip);
ns = timecounter_cyc2time(&chip->tstamp_tc, ns);
mv88e6xxx_reg_unlock(chip);
shwt = skb_hwtstamps(skb);
memset(shwt, 0, sizeof(*shwt));
shwt->hwtstamp = ns_to_ktime(ns);
status &= ~MV88E6XXX_PTP_TS_VALID;
}
netif_rx(skb);
}
}
static void mv88e6xxx_rxtstamp_work(struct mv88e6xxx_chip *chip,
struct mv88e6xxx_port_hwtstamp *ps)
{
const struct mv88e6xxx_ptp_ops *ptp_ops = chip->info->ops->ptp_ops;
struct sk_buff *skb;
skb = skb_dequeue(&ps->rx_queue);
if (skb)
mv88e6xxx_get_rxts(chip, ps, skb, ptp_ops->arr0_sts_reg,
&ps->rx_queue);
skb = skb_dequeue(&ps->rx_queue2);
if (skb)
mv88e6xxx_get_rxts(chip, ps, skb, ptp_ops->arr1_sts_reg,
&ps->rx_queue2);
}
static int is_pdelay_resp(const struct ptp_header *hdr)
{
return (hdr->tsmt & 0xf) == 3;
}
bool mv88e6xxx_port_rxtstamp(struct dsa_switch *ds, int port,
struct sk_buff *skb, unsigned int type)
{
struct mv88e6xxx_port_hwtstamp *ps;
struct mv88e6xxx_chip *chip;
struct ptp_header *hdr;
chip = ds->priv;
ps = &chip->port_hwtstamp[port];
if (ps->tstamp_config.rx_filter != HWTSTAMP_FILTER_PTP_V2_EVENT)
return false;
hdr = mv88e6xxx_should_tstamp(chip, port, skb, type);
if (!hdr)
return false;
SKB_PTP_TYPE(skb) = type;
if (is_pdelay_resp(hdr))
skb_queue_tail(&ps->rx_queue2, skb);
else
skb_queue_tail(&ps->rx_queue, skb);
ptp_schedule_worker(chip->ptp_clock, 0);
return true;
}
static int mv88e6xxx_txtstamp_work(struct mv88e6xxx_chip *chip,
struct mv88e6xxx_port_hwtstamp *ps)
{
const struct mv88e6xxx_ptp_ops *ptp_ops = chip->info->ops->ptp_ops;
struct skb_shared_hwtstamps shhwtstamps;
u16 departure_block[4], status;
struct sk_buff *tmp_skb;
u32 time_raw;
int err;
u64 ns;
if (!ps->tx_skb)
return 0;
mv88e6xxx_reg_lock(chip);
err = mv88e6xxx_port_ptp_read(chip, ps->port_id,
ptp_ops->dep_sts_reg,
departure_block,
ARRAY_SIZE(departure_block));
mv88e6xxx_reg_unlock(chip);
if (err)
goto free_and_clear_skb;
Annotation
- Immediate include surface: `chip.h`, `global2.h`, `hwtstamp.h`, `ptp.h`, `linux/ptp_classify.h`.
- Detected declarations: `function Copyright`, `function mv88e6xxx_port_ptp_write`, `function mv88e6xxx_ptp_write`, `function mv88e6xxx_ptp_read`, `function mv88e6xxx_get_ts_info`, `function mv88e6xxx_set_hwtstamp_config`, `function mv88e6xxx_port_hwtstamp_set`, `function mv88e6xxx_port_hwtstamp_get`, `function mv88e6xxx_ts_valid`, `function seq_match`.
- 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.