drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c- Extension
.c- Size
- 28406 bytes
- Lines
- 996
- Domain
- Driver Families
- Bucket
- drivers/net
- 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
net/addrconf.hlinux/etherdevice.hlinux/mlx5/vport.hmlx5_core.hlib/mlx5.hfpga/conn.h
Detected Declarations
function Copyrightfunction mlx5_fpga_conn_unmap_buffunction mlx5_fpga_conn_post_recvfunction mlx5_fpga_conn_notify_hwfunction mlx5_fpga_conn_post_sendfunction mlx5_fpga_conn_sendfunction mlx5_fpga_conn_post_recv_buffunction mlx5_fpga_conn_create_mkeyfunction mlx5_fpga_conn_rq_cqefunction mlx5_fpga_conn_sq_cqefunction mlx5_fpga_conn_handle_cqefunction mlx5_fpga_conn_arm_cqfunction mlx5_fpga_conn_cqesfunction mlx5_fpga_conn_cq_taskletfunction mlx5_fpga_conn_cq_completefunction mlx5_fpga_conn_create_cqfunction mlx5_fpga_conn_destroy_cqfunction mlx5_fpga_conn_create_wqfunction mlx5_fpga_conn_create_qpfunction mlx5_fpga_conn_free_recv_bufsfunction mlx5_fpga_conn_flush_send_bufsfunction mlx5_fpga_conn_destroy_qpfunction mlx5_fpga_conn_reset_qpfunction mlx5_fpga_conn_init_qpfunction mlx5_fpga_conn_rtr_qpfunction mlx5_fpga_conn_rts_qpfunction mlx5_fpga_conn_connectfunction mlx5_fpga_conn_destroyfunction mlx5_fpga_conn_device_initfunction mlx5_fpga_conn_device_cleanup
Annotated Snippet
if (likely(conn->qp.active)) {
nextbuf = list_first_entry(&conn->qp.sq.backlog,
struct mlx5_fpga_dma_buf, list);
list_del(&nextbuf->list);
mlx5_fpga_conn_post_send(conn, nextbuf);
}
}
spin_unlock_irqrestore(&conn->qp.sq.lock, flags);
if (unlikely(status && (status != MLX5_CQE_SYNDROME_WR_FLUSH_ERR)))
mlx5_fpga_warn(conn->fdev, "SQ buf %p on FPGA QP %u completion status %d\n",
buf, conn->fpga_qpn, status);
else
mlx5_fpga_dbg(conn->fdev, "SQ buf %p on FPGA QP %u completion status %d\n",
buf, conn->fpga_qpn, status);
mlx5_fpga_conn_unmap_buf(conn, buf);
if (likely(buf->complete))
buf->complete(conn, conn->fdev, buf, status);
if (unlikely(status))
conn->qp.active = false;
}
static void mlx5_fpga_conn_handle_cqe(struct mlx5_fpga_conn *conn,
struct mlx5_cqe64 *cqe)
{
u8 opcode, status = 0;
opcode = get_cqe_opcode(cqe);
switch (opcode) {
case MLX5_CQE_REQ_ERR:
status = ((struct mlx5_err_cqe *)cqe)->syndrome;
fallthrough;
case MLX5_CQE_REQ:
mlx5_fpga_conn_sq_cqe(conn, cqe, status);
break;
case MLX5_CQE_RESP_ERR:
status = ((struct mlx5_err_cqe *)cqe)->syndrome;
fallthrough;
case MLX5_CQE_RESP_SEND:
mlx5_fpga_conn_rq_cqe(conn, cqe, status);
break;
default:
mlx5_fpga_warn(conn->fdev, "Unexpected cqe opcode %u\n",
opcode);
}
}
static void mlx5_fpga_conn_arm_cq(struct mlx5_fpga_conn *conn)
{
mlx5_cq_arm(&conn->cq.mcq, MLX5_CQ_DB_REQ_NOT,
conn->fdev->conn_res.uar->map, conn->cq.wq.cc);
}
static inline void mlx5_fpga_conn_cqes(struct mlx5_fpga_conn *conn,
unsigned int budget)
{
struct mlx5_cqe64 *cqe;
while (budget) {
cqe = mlx5_cqwq_get_cqe(&conn->cq.wq);
if (!cqe)
break;
budget--;
mlx5_cqwq_pop(&conn->cq.wq);
mlx5_fpga_conn_handle_cqe(conn, cqe);
mlx5_cqwq_update_db_record(&conn->cq.wq);
}
if (!budget) {
tasklet_schedule(&conn->cq.tasklet);
return;
}
mlx5_fpga_dbg(conn->fdev, "Re-arming CQ with cc# %u\n", conn->cq.wq.cc);
/* ensure cq space is freed before enabling more cqes */
wmb();
mlx5_fpga_conn_arm_cq(conn);
}
static void mlx5_fpga_conn_cq_tasklet(struct tasklet_struct *t)
{
struct mlx5_fpga_conn *conn = from_tasklet(conn, t, cq.tasklet);
if (unlikely(!conn->qp.active))
Annotation
- Immediate include surface: `net/addrconf.h`, `linux/etherdevice.h`, `linux/mlx5/vport.h`, `mlx5_core.h`, `lib/mlx5.h`, `fpga/conn.h`.
- Detected declarations: `function Copyright`, `function mlx5_fpga_conn_unmap_buf`, `function mlx5_fpga_conn_post_recv`, `function mlx5_fpga_conn_notify_hw`, `function mlx5_fpga_conn_post_send`, `function mlx5_fpga_conn_send`, `function mlx5_fpga_conn_post_recv_buf`, `function mlx5_fpga_conn_create_mkey`, `function mlx5_fpga_conn_rq_cqe`, `function mlx5_fpga_conn_sq_cqe`.
- Atlas domain: Driver Families / drivers/net.
- 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.