drivers/net/ethernet/marvell/prestera/prestera_rxtx.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/marvell/prestera/prestera_rxtx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/marvell/prestera/prestera_rxtx.c- Extension
.c- Size
- 19165 bytes
- Lines
- 830
- 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/bitfield.hlinux/dmapool.hlinux/etherdevice.hlinux/if_vlan.hlinux/platform_device.hprestera_dsa.hprestera.hprestera_hw.hprestera_rxtx.hprestera_devlink.h
Detected Declarations
struct prestera_sdma_descstruct prestera_sdma_bufstruct prestera_rx_ringstruct prestera_tx_ringstruct prestera_sdmastruct prestera_rxtxfunction prestera_sdma_buf_initfunction prestera_sdma_mapfunction prestera_sdma_rx_desc_initfunction prestera_sdma_rx_desc_set_nextfunction prestera_sdma_rx_skb_allocfunction prestera_rxtx_process_skbfunction prestera_sdma_next_rx_buf_idxfunction prestera_sdma_rx_pollfunction prestera_sdma_rx_finifunction prestera_sdma_rx_initfunction prestera_sdma_tx_desc_initfunction prestera_sdma_tx_desc_set_nextfunction prestera_sdma_tx_desc_set_buffunction prestera_sdma_tx_desc_xmitfunction prestera_sdma_tx_buf_mapfunction prestera_sdma_tx_buf_unmapfunction prestera_sdma_tx_recycle_work_fnfunction prestera_sdma_tx_initfunction prestera_sdma_tx_finifunction prestera_rxtx_handle_eventfunction prestera_sdma_switch_initfunction prestera_sdma_switch_finifunction prestera_sdma_is_readyfunction prestera_sdma_tx_waitfunction prestera_sdma_tx_startfunction prestera_sdma_xmitfunction prestera_rxtx_switch_initfunction prestera_rxtx_switch_finifunction prestera_rxtx_port_initfunction prestera_rxtx_xmit
Annotated Snippet
struct prestera_sdma_desc {
__le32 word1;
__le32 word2;
__le32 buff;
__le32 next;
} __packed __aligned(16);
#define PRESTERA_SDMA_BUFF_SIZE_MAX 1544
#define PRESTERA_SDMA_RX_DESC_PKT_LEN(desc) \
((le32_to_cpu((desc)->word2) >> 16) & GENMASK(13, 0))
#define PRESTERA_SDMA_RX_DESC_OWNER(desc) \
((le32_to_cpu((desc)->word1) & BIT(31)) >> 31)
#define PRESTERA_SDMA_RX_DESC_IS_RCVD(desc) \
(PRESTERA_SDMA_RX_DESC_OWNER(desc) == PRESTERA_SDMA_RX_DESC_CPU_OWN)
#define PRESTERA_SDMA_RX_DESC_CPU_OWN 0
#define PRESTERA_SDMA_RX_DESC_DMA_OWN 1
#define PRESTERA_SDMA_RX_QUEUE_NUM 8
#define PRESTERA_SDMA_RX_DESC_PER_Q 1000
#define PRESTERA_SDMA_TX_DESC_PER_Q 1000
#define PRESTERA_SDMA_TX_MAX_BURST 64
#define PRESTERA_SDMA_TX_DESC_OWNER(desc) \
((le32_to_cpu((desc)->word1) & BIT(31)) >> 31)
#define PRESTERA_SDMA_TX_DESC_CPU_OWN 0
#define PRESTERA_SDMA_TX_DESC_DMA_OWN 1U
#define PRESTERA_SDMA_TX_DESC_IS_SENT(desc) \
(PRESTERA_SDMA_TX_DESC_OWNER(desc) == PRESTERA_SDMA_TX_DESC_CPU_OWN)
#define PRESTERA_SDMA_TX_DESC_LAST BIT(20)
#define PRESTERA_SDMA_TX_DESC_FIRST BIT(21)
#define PRESTERA_SDMA_TX_DESC_CALC_CRC BIT(12)
#define PRESTERA_SDMA_TX_DESC_SINGLE \
(PRESTERA_SDMA_TX_DESC_FIRST | PRESTERA_SDMA_TX_DESC_LAST)
#define PRESTERA_SDMA_TX_DESC_INIT \
(PRESTERA_SDMA_TX_DESC_SINGLE | PRESTERA_SDMA_TX_DESC_CALC_CRC)
#define PRESTERA_SDMA_RX_INTR_MASK_REG 0x2814
#define PRESTERA_SDMA_RX_QUEUE_STATUS_REG 0x2680
#define PRESTERA_SDMA_RX_QUEUE_DESC_REG(n) (0x260C + (n) * 16)
#define PRESTERA_SDMA_TX_QUEUE_DESC_REG 0x26C0
#define PRESTERA_SDMA_TX_QUEUE_START_REG 0x2868
struct prestera_sdma_buf {
struct prestera_sdma_desc *desc;
dma_addr_t desc_dma;
struct sk_buff *skb;
dma_addr_t buf_dma;
bool is_used;
};
struct prestera_rx_ring {
struct prestera_sdma_buf *bufs;
int next_rx;
};
struct prestera_tx_ring {
struct prestera_sdma_buf *bufs;
int next_tx;
int max_burst;
int burst;
};
struct prestera_sdma {
struct prestera_rx_ring rx_ring[PRESTERA_SDMA_RX_QUEUE_NUM];
struct prestera_tx_ring tx_ring;
struct prestera_switch *sw;
struct dma_pool *desc_pool;
struct work_struct tx_work;
struct napi_struct rx_napi;
struct net_device *napi_dev;
u32 map_addr;
u64 dma_mask;
/* protect SDMA with concurrent access from multiple CPUs */
spinlock_t tx_lock;
};
struct prestera_rxtx {
struct prestera_sdma sdma;
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/dmapool.h`, `linux/etherdevice.h`, `linux/if_vlan.h`, `linux/platform_device.h`, `prestera_dsa.h`, `prestera.h`, `prestera_hw.h`.
- Detected declarations: `struct prestera_sdma_desc`, `struct prestera_sdma_buf`, `struct prestera_rx_ring`, `struct prestera_tx_ring`, `struct prestera_sdma`, `struct prestera_rxtx`, `function prestera_sdma_buf_init`, `function prestera_sdma_map`, `function prestera_sdma_rx_desc_init`, `function prestera_sdma_rx_desc_set_next`.
- 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.