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.

Dependency Surface

Detected Declarations

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

Implementation Notes