drivers/net/wireless/ath/ath12k/htc.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/ath/ath12k/htc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/ath/ath12k/htc.c- Extension
.c- Size
- 21134 bytes
- Lines
- 797
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/skbuff.hlinux/ctype.hdebug.hhif.h
Detected Declarations
function Copyrightfunction ath12k_htc_control_tx_completefunction ath12k_htc_prepare_tx_skbfunction ath12k_htc_sendfunction ath12k_htc_process_credit_reportfunction ath12k_htc_process_trailerfunction ath12k_htc_suspend_completefunction ath12k_htc_wakeup_from_suspendfunction ath12k_htc_rx_completion_handlerfunction ath12k_htc_control_rx_completefunction ath12k_htc_reset_endpoint_statesfunction ath12k_htc_get_credit_allocationfunction ath12k_htc_setup_target_buffer_assignmentsfunction ath12k_htc_wait_targetfunction ath12k_htc_connect_servicefunction ath12k_htc_startfunction ath12k_htc_initexport ath12k_htc_rx_completion_handler
Annotated Snippet
if (ep->tx_credits < credits) {
ath12k_dbg(ab, ATH12K_DBG_HTC,
"htc insufficient credits ep %d required %d available %d\n",
eid, credits, ep->tx_credits);
spin_unlock_bh(&htc->tx_lock);
ret = -EAGAIN;
goto err_pull;
}
ep->tx_credits -= credits;
ath12k_dbg(ab, ATH12K_DBG_HTC,
"htc ep %d consumed %d credits (total %d)\n",
eid, credits, ep->tx_credits);
spin_unlock_bh(&htc->tx_lock);
}
ath12k_htc_prepare_tx_skb(ep, skb);
skb_cb->paddr = dma_map_single(dev, skb->data, skb->len, DMA_TO_DEVICE);
ret = dma_mapping_error(dev, skb_cb->paddr);
if (ret) {
ret = -EIO;
goto err_credits;
}
ret = ath12k_ce_send(htc->ab, skb, ep->ul_pipe_id, ep->eid);
if (ret)
goto err_unmap;
return 0;
err_unmap:
dma_unmap_single(dev, skb_cb->paddr, skb->len, DMA_TO_DEVICE);
err_credits:
if (ep->tx_credit_flow_enabled) {
spin_lock_bh(&htc->tx_lock);
ep->tx_credits += credits;
ath12k_dbg(ab, ATH12K_DBG_HTC,
"htc ep %d reverted %d credits back (total %d)\n",
eid, credits, ep->tx_credits);
spin_unlock_bh(&htc->tx_lock);
if (ep->ep_ops.ep_tx_credits)
ep->ep_ops.ep_tx_credits(htc->ab);
}
err_pull:
skb_pull(skb, sizeof(struct ath12k_htc_hdr));
return ret;
}
static void
ath12k_htc_process_credit_report(struct ath12k_htc *htc,
const struct ath12k_htc_credit_report *report,
int len,
enum ath12k_htc_ep_id eid)
{
struct ath12k_base *ab = htc->ab;
struct ath12k_htc_ep *ep;
int i, n_reports;
if (len % sizeof(*report))
ath12k_warn(ab, "Uneven credit report len %d", len);
n_reports = len / sizeof(*report);
spin_lock_bh(&htc->tx_lock);
for (i = 0; i < n_reports; i++, report++) {
if (report->eid >= ATH12K_HTC_EP_COUNT)
break;
ep = &htc->endpoint[report->eid];
ep->tx_credits += report->credits;
ath12k_dbg(ab, ATH12K_DBG_HTC, "htc ep %d got %d credits (total %d)\n",
report->eid, report->credits, ep->tx_credits);
if (ep->ep_ops.ep_tx_credits) {
spin_unlock_bh(&htc->tx_lock);
ep->ep_ops.ep_tx_credits(htc->ab);
spin_lock_bh(&htc->tx_lock);
}
}
spin_unlock_bh(&htc->tx_lock);
}
static int ath12k_htc_process_trailer(struct ath12k_htc *htc,
u8 *buffer,
int length,
enum ath12k_htc_ep_id src_eid)
{
struct ath12k_base *ab = htc->ab;
Annotation
- Immediate include surface: `linux/skbuff.h`, `linux/ctype.h`, `debug.h`, `hif.h`.
- Detected declarations: `function Copyright`, `function ath12k_htc_control_tx_complete`, `function ath12k_htc_prepare_tx_skb`, `function ath12k_htc_send`, `function ath12k_htc_process_credit_report`, `function ath12k_htc_process_trailer`, `function ath12k_htc_suspend_complete`, `function ath12k_htc_wakeup_from_suspend`, `function ath12k_htc_rx_completion_handler`, `function ath12k_htc_control_rx_complete`.
- 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.