drivers/net/ethernet/fungible/funcore/fun_queue.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/fungible/funcore/fun_queue.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/fungible/funcore/fun_queue.c- Extension
.c- Size
- 14192 bytes
- Lines
- 537
- 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/dma-mapping.hlinux/interrupt.hlinux/log2.hlinux/mm.hlinux/netdevice.hlinux/pci.hlinux/slab.hfun_dev.hfun_queue.h
Detected Declarations
function fun_free_ring_memfunction fun_sq_createfunction fun_cq_createfunction fun_sq_is_head_wbfunction fun_clean_rqfunction fun_fill_rqfunction fun_rq_update_posfunction __fun_process_cqfunction fun_process_cqfunction fun_alloc_sqesfunction fun_alloc_cqesfunction fun_alloc_rqesfunction fun_free_queuefunction fun_create_rqfunction funq_irqfunction fun_request_irqfunction fun_free_irqexport fun_alloc_ring_memexport fun_free_ring_memexport fun_sq_createexport fun_cq_create
Annotated Snippet
if (!*sw_va) {
dma_free_coherent(dma_dev, dma_sz, va, *dma_addr);
return NULL;
}
}
if (wb)
*wb_va = va + dma_sz - sizeof(u64);
return va;
}
EXPORT_SYMBOL_GPL(fun_alloc_ring_mem);
void fun_free_ring_mem(struct device *dma_dev, size_t depth, size_t hw_desc_sz,
bool wb, void *hw_va, dma_addr_t dma_addr, void *sw_va)
{
if (hw_va) {
size_t sz = depth * hw_desc_sz;
if (wb)
sz += sizeof(u64);
dma_free_coherent(dma_dev, sz, hw_va, dma_addr);
}
kvfree(sw_va);
}
EXPORT_SYMBOL_GPL(fun_free_ring_mem);
/* Prepare and issue an admin command to create an SQ on the device with the
* provided parameters. If the queue ID is auto-allocated by the device it is
* returned in *sqidp.
*/
int fun_sq_create(struct fun_dev *fdev, u16 flags, u32 sqid, u32 cqid,
u8 sqe_size_log2, u32 sq_depth, dma_addr_t dma_addr,
u8 coal_nentries, u8 coal_usec, u32 irq_num,
u32 scan_start_id, u32 scan_end_id,
u32 rq_buf_size_log2, u32 *sqidp, u32 __iomem **dbp)
{
union {
struct fun_admin_epsq_req req;
struct fun_admin_generic_create_rsp rsp;
} cmd;
dma_addr_t wb_addr;
u32 hw_qid;
int rc;
if (sq_depth > fdev->q_depth)
return -EINVAL;
if (flags & FUN_ADMIN_EPSQ_CREATE_FLAG_RQ)
sqe_size_log2 = ilog2(sizeof(struct fun_eprq_rqbuf));
wb_addr = dma_addr + (sq_depth << sqe_size_log2);
cmd.req.common = FUN_ADMIN_REQ_COMMON_INIT2(FUN_ADMIN_OP_EPSQ,
sizeof(cmd.req));
cmd.req.u.create =
FUN_ADMIN_EPSQ_CREATE_REQ_INIT(FUN_ADMIN_SUBOP_CREATE, flags,
sqid, cqid, sqe_size_log2,
sq_depth - 1, dma_addr, 0,
coal_nentries, coal_usec,
irq_num, scan_start_id,
scan_end_id, 0,
rq_buf_size_log2,
ilog2(sizeof(u64)), wb_addr);
rc = fun_submit_admin_sync_cmd(fdev, &cmd.req.common,
&cmd.rsp, sizeof(cmd.rsp), 0);
if (rc)
return rc;
hw_qid = be32_to_cpu(cmd.rsp.id);
*dbp = fun_sq_db_addr(fdev, hw_qid);
if (flags & FUN_ADMIN_RES_CREATE_FLAG_ALLOCATOR)
*sqidp = hw_qid;
return rc;
}
EXPORT_SYMBOL_GPL(fun_sq_create);
/* Prepare and issue an admin command to create a CQ on the device with the
* provided parameters. If the queue ID is auto-allocated by the device it is
* returned in *cqidp.
*/
int fun_cq_create(struct fun_dev *fdev, u16 flags, u32 cqid, u32 rqid,
u8 cqe_size_log2, u32 cq_depth, dma_addr_t dma_addr,
u16 headroom, u16 tailroom, u8 coal_nentries, u8 coal_usec,
u32 irq_num, u32 scan_start_id, u32 scan_end_id, u32 *cqidp,
u32 __iomem **dbp)
{
union {
struct fun_admin_epcq_req req;
struct fun_admin_generic_create_rsp rsp;
} cmd;
Annotation
- Immediate include surface: `linux/dma-mapping.h`, `linux/interrupt.h`, `linux/log2.h`, `linux/mm.h`, `linux/netdevice.h`, `linux/pci.h`, `linux/slab.h`, `fun_dev.h`.
- Detected declarations: `function fun_free_ring_mem`, `function fun_sq_create`, `function fun_cq_create`, `function fun_sq_is_head_wb`, `function fun_clean_rq`, `function fun_fill_rq`, `function fun_rq_update_pos`, `function __fun_process_cq`, `function fun_process_cq`, `function fun_alloc_sqes`.
- 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.