drivers/net/ethernet/ti/davinci_cpdma.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/ti/davinci_cpdma.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/ti/davinci_cpdma.c- Extension
.c- Size
- 36551 bytes
- Lines
- 1472
- 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.
- 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/kernel.hlinux/spinlock.hlinux/device.hlinux/module.hlinux/slab.hlinux/err.hlinux/dma-mapping.hlinux/io.hlinux/delay.hlinux/genalloc.hdavinci_cpdma.h
Detected Declarations
struct cpdma_descstruct cpdma_desc_poolstruct cpdma_ctlrstruct cpdma_chanstruct cpdma_control_infostruct submit_infoenum cpdma_statefunction cpdma_desc_pool_destroyfunction devicesfunction desc_physfunction desc_from_physfunction cpdma_desc_allocfunction cpdma_desc_freefunction _cpdma_control_setfunction _cpdma_control_getfunction cpdma_chan_set_chan_shaperfunction cpdma_chan_onfunction cpdma_chan_fit_ratefunction cpdma_chan_set_factorsfunction cpdma_ctlr_startfunction cpdma_ctlr_stopfunction cpdma_ctlr_destroyfunction cpdma_ctlr_int_ctrlfunction cpdma_ctlr_eoifunction cpdma_ctrl_rxchs_statefunction cpdma_ctrl_txchs_statefunction cpdma_chan_set_descsfunction cpdma_chan_split_poolfunction cpdma_chan_set_weightfunction cpdma_chan_get_min_ratefunction cpdma_chan_set_ratefunction cpdma_chan_get_ratefunction cpdma_chan_get_rx_buf_numfunction cpdma_chan_destroyfunction cpdma_chan_get_statsfunction __cpdma_chan_submitfunction cpdma_chan_submit_sifunction cpdma_chan_idle_submitfunction cpdma_chan_idle_submit_mappedfunction cpdma_chan_submitfunction cpdma_chan_submit_mappedfunction cpdma_check_free_tx_descfunction __cpdma_chan_freefunction __cpdma_chan_processfunction cpdma_chan_processfunction cpdma_chan_startfunction cpdma_chan_stopfunction cpdma_chan_int_ctrl
Annotated Snippet
struct cpdma_desc {
/* hardware fields */
u32 hw_next;
u32 hw_buffer;
u32 hw_len;
u32 hw_mode;
/* software fields */
void *sw_token;
u32 sw_buffer;
u32 sw_len;
};
struct cpdma_desc_pool {
phys_addr_t phys;
dma_addr_t hw_addr;
void __iomem *iomap; /* ioremap map */
void *cpumap; /* dma_alloc map */
int desc_size, mem_size;
int num_desc;
struct device *dev;
struct gen_pool *gen_pool;
};
enum cpdma_state {
CPDMA_STATE_IDLE,
CPDMA_STATE_ACTIVE,
CPDMA_STATE_TEARDOWN,
};
struct cpdma_ctlr {
enum cpdma_state state;
struct cpdma_params params;
struct device *dev;
struct cpdma_desc_pool *pool;
spinlock_t lock;
struct cpdma_chan *channels[2 * CPDMA_MAX_CHANNELS];
int chan_num;
int num_rx_desc; /* RX descriptors number */
int num_tx_desc; /* TX descriptors number */
};
struct cpdma_chan {
struct cpdma_desc __iomem *head, *tail;
void __iomem *hdp, *cp, *rxfree;
enum cpdma_state state;
struct cpdma_ctlr *ctlr;
int chan_num;
spinlock_t lock;
int count;
u32 desc_num;
u32 mask;
cpdma_handler_fn handler;
enum dma_data_direction dir;
struct cpdma_chan_stats stats;
/* offsets into dmaregs */
int int_set, int_clear, td;
int weight;
u32 rate_factor;
u32 rate;
};
struct cpdma_control_info {
u32 reg;
u32 shift, mask;
int access;
#define ACCESS_RO BIT(0)
#define ACCESS_WO BIT(1)
#define ACCESS_RW (ACCESS_RO | ACCESS_WO)
};
struct submit_info {
struct cpdma_chan *chan;
int directed;
void *token;
void *data_virt;
dma_addr_t data_dma;
int len;
};
static struct cpdma_control_info controls[] = {
[CPDMA_TX_RLIM] = {CPDMA_DMACONTROL, 8, 0xffff, ACCESS_RW},
[CPDMA_CMD_IDLE] = {CPDMA_DMACONTROL, 3, 1, ACCESS_WO},
[CPDMA_COPY_ERROR_FRAMES] = {CPDMA_DMACONTROL, 4, 1, ACCESS_RW},
[CPDMA_RX_OFF_LEN_UPDATE] = {CPDMA_DMACONTROL, 2, 1, ACCESS_RW},
[CPDMA_RX_OWNERSHIP_FLIP] = {CPDMA_DMACONTROL, 1, 1, ACCESS_RW},
[CPDMA_TX_PRIO_FIXED] = {CPDMA_DMACONTROL, 0, 1, ACCESS_RW},
[CPDMA_STAT_IDLE] = {CPDMA_DMASTATUS, 31, 1, ACCESS_RO},
[CPDMA_STAT_TX_ERR_CODE] = {CPDMA_DMASTATUS, 20, 0xf, ACCESS_RW},
[CPDMA_STAT_TX_ERR_CHAN] = {CPDMA_DMASTATUS, 16, 0x7, ACCESS_RW},
[CPDMA_STAT_RX_ERR_CODE] = {CPDMA_DMASTATUS, 12, 0xf, ACCESS_RW},
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/spinlock.h`, `linux/device.h`, `linux/module.h`, `linux/slab.h`, `linux/err.h`, `linux/dma-mapping.h`, `linux/io.h`.
- Detected declarations: `struct cpdma_desc`, `struct cpdma_desc_pool`, `struct cpdma_ctlr`, `struct cpdma_chan`, `struct cpdma_control_info`, `struct submit_info`, `enum cpdma_state`, `function cpdma_desc_pool_destroy`, `function devices`, `function desc_phys`.
- 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.
- 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.