drivers/net/wireless/ath/ath12k/ce.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/ath/ath12k/ce.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/ath/ath12k/ce.c- Extension
.c- Size
- 18593 bytes
- Lines
- 756
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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
dp_rx.hdebug.hhif.h
Detected Declarations
function Copyrightfunction ath12k_ce_rx_post_pipefunction ath12k_ce_completed_recv_nextfunction ath12k_ce_recv_process_cbfunction ath12k_ce_send_done_cbfunction ath12k_ce_srng_msi_ring_params_setupfunction ath12k_ce_init_ringfunction ath12k_ce_alloc_ringfunction ath12k_ce_alloc_pipefunction ath12k_ce_per_engine_servicefunction ath12k_ce_poll_send_completedfunction ath12k_ce_sendfunction ath12k_ce_rx_pipe_cleanupfunction ath12k_ce_cleanup_pipesfunction ath12k_ce_rx_post_buffunction ath12k_ce_rx_replenish_retryfunction ath12k_ce_shadow_configfunction ath12k_ce_get_shadow_configfunction ath12k_ce_init_pipesfunction ath12k_ce_free_pipesfunction ath12k_ce_alloc_pipesfunction ath12k_ce_get_attr_flags
Annotated Snippet
if (!skb) {
ret = -ENOMEM;
goto exit;
}
WARN_ON_ONCE(!IS_ALIGNED((unsigned long)skb->data, 4));
paddr = dma_map_single(ab->dev, skb->data,
skb->len + skb_tailroom(skb),
DMA_FROM_DEVICE);
if (unlikely(dma_mapping_error(ab->dev, paddr))) {
ath12k_warn(ab, "failed to dma map ce rx buf\n");
dev_kfree_skb_any(skb);
ret = -EIO;
goto exit;
}
ATH12K_SKB_RXCB(skb)->paddr = paddr;
ret = ath12k_ce_rx_buf_enqueue_pipe(pipe, skb, paddr);
if (ret) {
ath12k_dbg(ab, ATH12K_DBG_CE, "failed to enqueue rx buf: %d\n",
ret);
dma_unmap_single(ab->dev, paddr,
skb->len + skb_tailroom(skb),
DMA_FROM_DEVICE);
dev_kfree_skb_any(skb);
goto exit;
}
}
exit:
spin_unlock_bh(&ab->ce.ce_lock);
return ret;
}
static int ath12k_ce_completed_recv_next(struct ath12k_ce_pipe *pipe,
struct sk_buff **skb, int *nbytes)
{
struct ath12k_base *ab = pipe->ab;
struct hal_ce_srng_dst_status_desc *desc;
struct hal_srng *srng;
unsigned int sw_index;
unsigned int nentries_mask;
int ret = 0;
spin_lock_bh(&ab->ce.ce_lock);
sw_index = pipe->dest_ring->sw_index;
nentries_mask = pipe->dest_ring->nentries_mask;
srng = &ab->hal.srng_list[pipe->status_ring->hal_ring_id];
spin_lock_bh(&srng->lock);
ath12k_hal_srng_access_begin(ab, srng);
desc = ath12k_hal_srng_dst_get_next_entry(ab, srng);
if (!desc) {
ret = -EIO;
goto err;
}
*nbytes = ath12k_hal_ce_dst_status_get_length(&ab->hal, desc);
*skb = pipe->dest_ring->skb[sw_index];
pipe->dest_ring->skb[sw_index] = NULL;
sw_index = CE_RING_IDX_INCR(nentries_mask, sw_index);
pipe->dest_ring->sw_index = sw_index;
pipe->rx_buf_needed++;
err:
ath12k_hal_srng_access_end(ab, srng);
spin_unlock_bh(&srng->lock);
spin_unlock_bh(&ab->ce.ce_lock);
return ret;
}
static void ath12k_ce_recv_process_cb(struct ath12k_ce_pipe *pipe)
{
struct ath12k_base *ab = pipe->ab;
struct sk_buff *skb;
struct sk_buff_head list;
unsigned int nbytes, max_nbytes;
int ret;
Annotation
- Immediate include surface: `dp_rx.h`, `debug.h`, `hif.h`.
- Detected declarations: `function Copyright`, `function ath12k_ce_rx_post_pipe`, `function ath12k_ce_completed_recv_next`, `function ath12k_ce_recv_process_cb`, `function ath12k_ce_send_done_cb`, `function ath12k_ce_srng_msi_ring_params_setup`, `function ath12k_ce_init_ring`, `function ath12k_ce_alloc_ring`, `function ath12k_ce_alloc_pipe`, `function ath12k_ce_per_engine_service`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.