drivers/platform/mellanox/mlxbf-tmfifo.c

Source file repositories/reference/linux-study-clean/drivers/platform/mellanox/mlxbf-tmfifo.c

File Facts

System
Linux kernel
Corpus path
drivers/platform/mellanox/mlxbf-tmfifo.c
Extension
.c
Size
38737 bytes
Lines
1462
Domain
Driver Families
Bucket
drivers/platform
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct mlxbf_tmfifo_vring {
	void *va;
	dma_addr_t dma;
	struct virtqueue *vq;
	struct vring_desc *desc;
	struct vring_desc *desc_head;
	struct vring_desc drop_desc;
	int cur_len;
	int rem_len;
	int rem_padding;
	u32 pkt_len;
	u16 next_avail;
	int num;
	int align;
	int index;
	int vdev_id;
	unsigned long tx_timeout;
	struct mlxbf_tmfifo *fifo;
};

/* Check whether vring is in drop mode. */
#define IS_VRING_DROP(_r) ({ \
	typeof(_r) (r) = (_r); \
	r->desc_head == &r->drop_desc; })

/* A stub length to drop maximum length packet. */
#define VRING_DROP_DESC_MAX_LEN		GENMASK(15, 0)

/* Interrupt types. */
enum {
	MLXBF_TM_RX_LWM_IRQ,
	MLXBF_TM_RX_HWM_IRQ,
	MLXBF_TM_TX_LWM_IRQ,
	MLXBF_TM_TX_HWM_IRQ,
	MLXBF_TM_MAX_IRQ
};

/* Ring types (Rx & Tx). */
enum {
	MLXBF_TMFIFO_VRING_RX,
	MLXBF_TMFIFO_VRING_TX,
	MLXBF_TMFIFO_VRING_MAX
};

/**
 * struct mlxbf_tmfifo_vdev - Structure of the TmFifo virtual device
 * @vdev: virtio device, in which the vdev.id.device field has the
 *        VIRTIO_ID_xxx id to distinguish the virtual device.
 * @status: status of the device
 * @features: supported features of the device
 * @vrings: array of tmfifo vrings of this device
 * @config: non-anonymous union for cons and net
 * @config.cons: virtual console config -
 *               select if vdev.id.device is VIRTIO_ID_CONSOLE
 * @config.net: virtual network config -
 *              select if vdev.id.device is VIRTIO_ID_NET
 * @tx_buf: tx buffer used to buffer data before writing into the FIFO
 */
struct mlxbf_tmfifo_vdev {
	struct virtio_device vdev;
	u8 status;
	u64 features;
	struct mlxbf_tmfifo_vring vrings[MLXBF_TMFIFO_VRING_MAX];
	union {
		struct virtio_console_config cons;
		struct virtio_net_config net;
	} config;
	struct circ_buf tx_buf;
};

/**
 * struct mlxbf_tmfifo_irq_info - Structure of the interrupt information
 * @fifo: pointer to the tmfifo structure
 * @irq: interrupt number
 * @index: index into the interrupt array
 */
struct mlxbf_tmfifo_irq_info {
	struct mlxbf_tmfifo *fifo;
	int irq;
	int index;
};

/**
 * struct mlxbf_tmfifo_io - Structure of the TmFifo IO resource (for both rx & tx)
 * @ctl: control register offset (TMFIFO_RX_CTL / TMFIFO_TX_CTL)
 * @sts: status register offset (TMFIFO_RX_STS / TMFIFO_TX_STS)
 * @data: data register offset (TMFIFO_RX_DATA / TMFIFO_TX_DATA)
 */
struct mlxbf_tmfifo_io {
	void __iomem *ctl;

Annotation

Implementation Notes