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.
- 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.
- 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/acpi.hlinux/bitfield.hlinux/circ_buf.hlinux/efi.hlinux/irq.hlinux/module.hlinux/mutex.hlinux/platform_device.hlinux/types.hlinux/virtio_config.hlinux/virtio_console.hlinux/virtio_ids.hlinux/virtio_net.hlinux/virtio_ring.hmlxbf-tmfifo-regs.h
Detected Declarations
struct mlxbf_tmfifostruct mlxbf_tmfifo_vringstruct mlxbf_tmfifo_vdevstruct mlxbf_tmfifo_irq_infostruct mlxbf_tmfifo_iostruct mlxbf_tmfifostruct mlxbf_tmfifo_msg_hdrfunction BIT_ULLfunction mlxbf_tmfifo_alloc_vringsfunction mlxbf_tmfifo_disable_irqsfunction mlxbf_tmfifo_irq_handlerfunction mlxbf_tmfifo_get_next_descfunction mlxbf_tmfifo_release_descfunction mlxbf_tmfifo_get_pkt_lenfunction mlxbf_tmfifo_release_pktfunction mlxbf_tmfifo_init_net_descfunction mlxbf_tmfifo_get_next_pktfunction mlxbf_tmfifo_timerfunction mlxbf_tmfifo_console_output_onefunction mlxbf_tmfifo_console_outputfunction mlxbf_tmfifo_get_rx_availfunction mlxbf_tmfifo_get_tx_availfunction mlxbf_tmfifo_console_txfunction mlxbf_tmfifo_rxtx_wordfunction mlxbf_tmfifo_rxtx_headerfunction mlxbf_tmfifo_rxtx_one_descfunction mlxbf_tmfifo_check_tx_timeoutfunction mlxbf_tmfifo_rxtxfunction mlxbf_tmfifo_work_rxtxfunction mlxbf_tmfifo_work_handlerfunction mlxbf_tmfifo_virtio_notifyfunction mlxbf_tmfifo_virtio_get_featuresfunction mlxbf_tmfifo_virtio_finalize_featuresfunction mlxbf_tmfifo_virtio_del_vqsfunction mlxbf_tmfifo_virtio_find_vqsfunction mlxbf_tmfifo_virtio_get_statusfunction mlxbf_tmfifo_virtio_set_statusfunction mlxbf_tmfifo_virtio_resetfunction mlxbf_tmfifo_virtio_getfunction mlxbf_tmfifo_virtio_setfunction tmfifo_virtio_dev_releasefunction mlxbf_tmfifo_create_vdevfunction mlxbf_tmfifo_delete_vdevfunction mlxbf_tmfifo_get_cfg_macfunction mlxbf_tmfifo_set_thresholdfunction mlxbf_tmfifo_cleanupfunction mlxbf_tmfifo_probefunction mlxbf_tmfifo_remove
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
- Immediate include surface: `linux/acpi.h`, `linux/bitfield.h`, `linux/circ_buf.h`, `linux/efi.h`, `linux/irq.h`, `linux/module.h`, `linux/mutex.h`, `linux/platform_device.h`.
- Detected declarations: `struct mlxbf_tmfifo`, `struct mlxbf_tmfifo_vring`, `struct mlxbf_tmfifo_vdev`, `struct mlxbf_tmfifo_irq_info`, `struct mlxbf_tmfifo_io`, `struct mlxbf_tmfifo`, `struct mlxbf_tmfifo_msg_hdr`, `function BIT_ULL`, `function mlxbf_tmfifo_alloc_vrings`, `function mlxbf_tmfifo_disable_irqs`.
- Atlas domain: Driver Families / drivers/platform.
- Implementation status: source 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.