linux/drivers/net/ethernet/fungible/funcore/fun_queue.c

// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)

#include <linux/dma-mapping.h>
#include <linux/interrupt.h>
#include <linux/log2.h>
#include <linux/mm.h>
#include <linux/netdevice.h>
#include <linux/pci.h>
#include <linux/slab.h>

#include "fun_dev.h"
#include "fun_queue.h"

/* Allocate memory for a queue. This includes the memory for the HW descriptor
 * ring, an optional 64b HW write-back area, and an optional SW state ring.
 * Returns the virtual and DMA addresses of the HW ring, the VA of the SW ring,
 * and the VA of the write-back area.
 */
void *fun_alloc_ring_mem(struct device *dma_dev, size_t depth,
			 size_t hw_desc_sz, size_t sw_desc_sz, bool wb,
			 int numa_node, dma_addr_t *dma_addr, void **sw_va,
			 volatile __be64 **wb_va)
{}
EXPORT_SYMBOL_GPL();

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)
{}
EXPORT_SYMBOL_GPL();

/* 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)
{}
EXPORT_SYMBOL_GPL();

/* 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)
{}
EXPORT_SYMBOL_GPL();

static bool fun_sq_is_head_wb(const struct fun_queue *funq)
{}

static void fun_clean_rq(struct fun_queue *funq)
{}

static int fun_fill_rq(struct fun_queue *funq)
{}

static void fun_rq_update_pos(struct fun_queue *funq, int buf_offset)
{}

/* Given a command response with data scattered across >= 1 RQ buffers return
 * a pointer to a contiguous buffer containing all the data. If the data is in
 * one RQ buffer the start address within that buffer is returned, otherwise a
 * new buffer is allocated and the data is gathered into it.
 */
static void *fun_data_from_rq(struct fun_queue *funq,
			      const struct fun_rsp_common *rsp, bool *need_free)
{}

unsigned int __fun_process_cq(struct fun_queue *funq, unsigned int max)
{}

unsigned int fun_process_cq(struct fun_queue *funq, unsigned int max)
{}

static int fun_alloc_sqes(struct fun_queue *funq)
{}

static int fun_alloc_cqes(struct fun_queue *funq)
{}

static int fun_alloc_rqes(struct fun_queue *funq)
{}

/* Free a queue's structures. */
void fun_free_queue(struct fun_queue *funq)
{}

/* Allocate and initialize a funq's structures. */
struct fun_queue *fun_alloc_queue(struct fun_dev *fdev, int qid,
				  const struct fun_queue_alloc_req *req)
{}

/* Create a funq's CQ on the device. */
static int fun_create_cq(struct fun_queue *funq)
{}

/* Create a funq's SQ on the device. */
static int fun_create_sq(struct fun_queue *funq)
{}

/* Create a funq's RQ on the device. */
int fun_create_rq(struct fun_queue *funq)
{}

static unsigned int funq_irq(struct fun_queue *funq)
{}

int fun_request_irq(struct fun_queue *funq, const char *devname,
		    irq_handler_t handler, void *data)
{}

/* Create all component queues of a funq  on the device. */
int fun_create_queue(struct fun_queue *funq)
{}

void fun_free_irq(struct fun_queue *funq)
{}