drivers/infiniband/hw/mana/main.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/hw/mana/main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/hw/mana/main.c- Extension
.c- Size
- 32141 bytes
- Lines
- 1102
- Domain
- Driver Families
- Bucket
- drivers/infiniband
- 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
mana_ib.hlinux/pci.h
Detected Declarations
function Copyrightfunction mana_ib_cfg_vportfunction mana_ib_alloc_pdfunction mana_ib_dealloc_pdfunction mana_gd_destroy_doorbell_pagefunction mana_gd_allocate_doorbell_pagefunction mana_ib_alloc_ucontextfunction mana_ib_dealloc_ucontextfunction mana_ib_create_kernel_queuefunction mana_ib_create_queuefunction mana_ib_destroy_queuefunction mana_ib_gd_first_dma_regionfunction mana_ib_gd_add_dma_regionfunction mana_ib_gd_create_dma_regionfunction mana_ib_create_dma_regionfunction mana_ib_create_zero_offset_dma_regionfunction mana_ib_gd_destroy_dma_regionfunction mana_ib_mmapfunction mana_ib_get_port_immutablefunction mana_ib_query_devicefunction mana_ib_query_portfunction mana_ib_get_link_layerfunction mana_ib_query_pkeyfunction mana_ib_query_gidfunction mana_ib_disassociate_ucontextfunction mana_eth_query_adapter_capsfunction mana_ib_event_handlerfunction mana_ib_create_eqsfunction mana_ib_destroy_eqsfunction mana_ib_gd_create_rnic_adapterfunction mana_ib_gd_destroy_rnic_adapterfunction mana_ib_gd_add_gidfunction mana_ib_gd_del_gidfunction mana_ib_gd_config_macfunction mana_ib_gd_create_cqfunction mana_ib_gd_destroy_cqfunction mana_ib_gd_create_rc_qpfunction mana_ib_gd_destroy_rc_qpfunction mana_ib_gd_create_ud_qpfunction mana_ib_gd_destroy_ud_qp
Annotated Snippet
if (pd->vport_port != port) {
pd->vport_use_count--;
mutex_unlock(&pd->vport_mutex);
ibdev_dbg(&dev->ib_dev,
"PD already bound to port %u\n",
pd->vport_port);
return -EINVAL;
}
ibdev_dbg(&dev->ib_dev,
"Skip as this PD is already configured vport\n");
mutex_unlock(&pd->vport_mutex);
return 0;
}
pd->vport_port = port;
err = mana_cfg_vport(mpc, pd->pdn, doorbell_id, true);
if (err) {
pd->vport_use_count--;
mutex_unlock(&pd->vport_mutex);
ibdev_dbg(&dev->ib_dev, "Failed to configure vPort %d\n", err);
return err;
}
err = mana_create_eq(mpc);
if (err) {
mana_uncfg_vport(mpc);
pd->vport_use_count--;
} else {
pd->tx_shortform_allowed = mpc->tx_shortform_allowed;
pd->tx_vp_offset = mpc->tx_vp_offset;
}
mutex_unlock(&pd->vport_mutex);
if (!err)
ibdev_dbg(&dev->ib_dev, "vport handle %llx pdid %x doorbell_id %x\n",
mpc->port_handle, pd->pdn, doorbell_id);
return err;
}
int mana_ib_alloc_pd(struct ib_pd *ibpd, struct ib_udata *udata)
{
struct mana_ib_pd *pd = container_of(ibpd, struct mana_ib_pd, ibpd);
struct ib_device *ibdev = ibpd->device;
struct gdma_create_pd_resp resp = {};
struct gdma_create_pd_req req = {};
enum gdma_pd_flags flags = 0;
struct mana_ib_dev *dev;
struct gdma_context *gc;
int err;
dev = container_of(ibdev, struct mana_ib_dev, ib_dev);
gc = mdev_to_gc(dev);
mana_gd_init_req_hdr(&req.hdr, GDMA_CREATE_PD, sizeof(req),
sizeof(resp));
if (!udata)
flags |= GDMA_PD_FLAG_ALLOW_GPA_MR;
req.flags = flags;
err = mana_gd_send_request(gc, sizeof(req), &req, sizeof(resp), &resp);
if (err)
return err;
pd->pd_handle = resp.pd_handle;
pd->pdn = resp.pd_id;
ibdev_dbg(&dev->ib_dev, "pd_handle 0x%llx pd_id %d\n",
pd->pd_handle, pd->pdn);
mutex_init(&pd->vport_mutex);
pd->vport_use_count = 0;
return 0;
}
int mana_ib_dealloc_pd(struct ib_pd *ibpd, struct ib_udata *udata)
{
struct mana_ib_pd *pd = container_of(ibpd, struct mana_ib_pd, ibpd);
struct ib_device *ibdev = ibpd->device;
struct gdma_destory_pd_resp resp = {};
struct gdma_destroy_pd_req req = {};
struct mana_ib_dev *dev;
struct gdma_context *gc;
dev = container_of(ibdev, struct mana_ib_dev, ib_dev);
gc = mdev_to_gc(dev);
Annotation
- Immediate include surface: `mana_ib.h`, `linux/pci.h`.
- Detected declarations: `function Copyright`, `function mana_ib_cfg_vport`, `function mana_ib_alloc_pd`, `function mana_ib_dealloc_pd`, `function mana_gd_destroy_doorbell_page`, `function mana_gd_allocate_doorbell_page`, `function mana_ib_alloc_ucontext`, `function mana_ib_dealloc_ucontext`, `function mana_ib_create_kernel_queue`, `function mana_ib_create_queue`.
- Atlas domain: Driver Families / drivers/infiniband.
- 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.