drivers/net/ethernet/ti/cpts.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/ti/cpts.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/ti/cpts.c- Extension
.c- Size
- 19626 bytes
- Lines
- 815
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/clk-provider.hlinux/err.hlinux/if.hlinux/hrtimer.hlinux/module.hlinux/net_tstamp.hlinux/ptp_classify.hlinux/time.hlinux/uaccess.hlinux/workqueue.hlinux/if_ether.hlinux/if_vlan.hcpts.h
Detected Declarations
struct cpts_skb_cb_datafunction cpts_event_portfunction event_expiredfunction event_typefunction cpts_fifo_popfunction cpts_purge_eventsfunction list_for_each_safefunction cpts_purge_txqfunction skb_queue_walk_safefunction cpts_fifo_readfunction cpts_misc_interruptfunction cpts_systim_readfunction cpts_update_cur_timefunction cpts_ptp_adjfinefunction cpts_ptp_adjtimefunction cpts_ptp_gettimeexfunction cpts_ptp_settimefunction cpts_extts_enablefunction cpts_ptp_enablefunction cpts_match_tx_tsfunction skb_queue_walk_safefunction cpts_process_eventsfunction list_for_each_safefunction cpts_overflow_checkfunction cpts_skb_get_mtype_seqidfunction cpts_find_tsfunction cpts_rx_timestampfunction cpts_tx_timestampfunction cpts_registerfunction cpts_unregisterfunction cpts_calc_mult_shiftfunction cpts_clk_unregisterfunction cpts_clk_del_providerfunction cpts_of_mux_clk_setupfunction cpts_of_parsefunction cpts_releaseexport cpts_misc_interruptexport cpts_rx_timestampexport cpts_tx_timestampexport cpts_registerexport cpts_unregisterexport cpts_createexport cpts_release
Annotated Snippet
struct cpts_skb_cb_data {
u32 skb_mtype_seqid;
unsigned long tmo;
};
#define cpts_read32(c, r) readl_relaxed(&c->reg->r)
#define cpts_write32(c, v, r) writel_relaxed(v, &c->reg->r)
static int cpts_event_port(struct cpts_event *event)
{
return (event->high >> PORT_NUMBER_SHIFT) & PORT_NUMBER_MASK;
}
static int event_expired(struct cpts_event *event)
{
return time_after(jiffies, event->tmo);
}
static int event_type(struct cpts_event *event)
{
return (event->high >> EVENT_TYPE_SHIFT) & EVENT_TYPE_MASK;
}
static int cpts_fifo_pop(struct cpts *cpts, u32 *high, u32 *low)
{
u32 r = cpts_read32(cpts, intstat_raw);
if (r & TS_PEND_RAW) {
*high = cpts_read32(cpts, event_high);
*low = cpts_read32(cpts, event_low);
cpts_write32(cpts, EVENT_POP, event_pop);
return 0;
}
return -1;
}
static int cpts_purge_events(struct cpts *cpts)
{
struct list_head *this, *next;
struct cpts_event *event;
int removed = 0;
list_for_each_safe(this, next, &cpts->events) {
event = list_entry(this, struct cpts_event, list);
if (event_expired(event)) {
list_del_init(&event->list);
list_add(&event->list, &cpts->pool);
++removed;
}
}
if (removed)
dev_dbg(cpts->dev, "cpts: event pool cleaned up %d\n", removed);
return removed ? 0 : -1;
}
static void cpts_purge_txq(struct cpts *cpts)
{
struct cpts_skb_cb_data *skb_cb;
struct sk_buff *skb, *tmp;
int removed = 0;
skb_queue_walk_safe(&cpts->txq, skb, tmp) {
skb_cb = (struct cpts_skb_cb_data *)skb->cb;
if (time_after(jiffies, skb_cb->tmo)) {
__skb_unlink(skb, &cpts->txq);
dev_consume_skb_any(skb);
++removed;
}
}
if (removed)
dev_dbg(cpts->dev, "txq cleaned up %d\n", removed);
}
/*
* Returns zero if matching event type was found.
*/
static int cpts_fifo_read(struct cpts *cpts, int match)
{
struct ptp_clock_event pevent;
bool need_schedule = false;
struct cpts_event *event;
unsigned long flags;
int i, type = -1;
u32 hi, lo;
spin_lock_irqsave(&cpts->lock, flags);
for (i = 0; i < CPTS_FIFO_DEPTH; i++) {
Annotation
- Immediate include surface: `linux/clk-provider.h`, `linux/err.h`, `linux/if.h`, `linux/hrtimer.h`, `linux/module.h`, `linux/net_tstamp.h`, `linux/ptp_classify.h`, `linux/time.h`.
- Detected declarations: `struct cpts_skb_cb_data`, `function cpts_event_port`, `function event_expired`, `function event_type`, `function cpts_fifo_pop`, `function cpts_purge_events`, `function list_for_each_safe`, `function cpts_purge_txq`, `function skb_queue_walk_safe`, `function cpts_fifo_read`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration 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.