drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c- Extension
.c- Size
- 79843 bytes
- Lines
- 2957
- 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
linux/dma-mapping.hnet/addrconf.hrdma/ib_verbs.hrdma/ib_user_verbs.hrdma/iw_cm.hrdma/ib_addr.hrdma/ib_cache.hrdma/iter.hrdma/uverbs_ioctl.hocrdma.hocrdma_hw.hocrdma_verbs.hrdma/ocrdma-abi.h
Detected Declarations
function ocrdma_query_pkeyfunction ocrdma_query_devicefunction get_link_speed_and_widthfunction ocrdma_query_portfunction ocrdma_add_mmapfunction ocrdma_del_mmapfunction ocrdma_search_mmapfunction _ocrdma_pd_mgr_get_bitmapfunction _ocrdma_pd_mgr_put_bitmapfunction ocrdma_put_pd_numfunction ocrdma_get_pd_numfunction _ocrdma_alloc_pdfunction is_ucontext_pdfunction _ocrdma_dealloc_pdfunction ocrdma_alloc_ucontext_pdfunction ocrdma_dealloc_ucontext_pdfunction ocrdma_release_ucontext_pdfunction ocrdma_alloc_ucontextfunction ocrdma_dealloc_ucontextfunction list_for_each_entry_safefunction ocrdma_mmapfunction ocrdma_copy_pd_urespfunction ocrdma_alloc_pdfunction ocrdma_dealloc_pdfunction ocrdma_alloc_lkeyfunction ocrdma_free_mr_pbl_tblfunction ocrdma_get_pbl_infofunction ocrdma_build_pbl_tblfunction build_user_pbesfunction rdma_umem_for_each_dma_blockfunction ocrdma_dereg_mrfunction ocrdma_copy_cq_urespfunction ocrdma_create_cqfunction ocrdma_resize_cqfunction ocrdma_flush_cqfunction ocrdma_destroy_cqfunction ocrdma_add_qpn_mapfunction ocrdma_del_qpn_mapfunction ocrdma_check_qp_paramsfunction ocrdma_copy_qp_urespfunction ocrdma_set_qp_dbfunction ocrdma_alloc_wr_id_tblfunction ocrdma_set_qp_init_paramsfunction ocrdma_store_gsi_qp_cqfunction ocrdma_create_qpfunction _ocrdma_modify_qpfunction ocrdma_modify_qpfunction ocrdma_mtu_int_to_enum
Annotated Snippet
if (pd_bit_index >= dev->pd_mgr->max_dpp_pd) {
return -EINVAL;
} else {
__clear_bit(pd_bit_index, dev->pd_mgr->pd_dpp_bitmap);
dev->pd_mgr->pd_dpp_count--;
}
} else {
pd_bit_index = pd_id - dev->pd_mgr->pd_norm_start;
if (pd_bit_index >= dev->pd_mgr->max_normal_pd) {
return -EINVAL;
} else {
__clear_bit(pd_bit_index, dev->pd_mgr->pd_norm_bitmap);
dev->pd_mgr->pd_norm_count--;
}
}
return 0;
}
static int ocrdma_put_pd_num(struct ocrdma_dev *dev, u16 pd_id,
bool dpp_pool)
{
int status;
mutex_lock(&dev->dev_lock);
status = _ocrdma_pd_mgr_put_bitmap(dev, pd_id, dpp_pool);
mutex_unlock(&dev->dev_lock);
return status;
}
static int ocrdma_get_pd_num(struct ocrdma_dev *dev, struct ocrdma_pd *pd)
{
u16 pd_idx = 0;
int status = 0;
mutex_lock(&dev->dev_lock);
if (pd->dpp_enabled) {
/* try allocating DPP PD, if not available then normal PD */
if (dev->pd_mgr->pd_dpp_count < dev->pd_mgr->max_dpp_pd) {
pd_idx = _ocrdma_pd_mgr_get_bitmap(dev, true);
pd->id = dev->pd_mgr->pd_dpp_start + pd_idx;
pd->dpp_page = dev->pd_mgr->dpp_page_index + pd_idx;
} else if (dev->pd_mgr->pd_norm_count <
dev->pd_mgr->max_normal_pd) {
pd_idx = _ocrdma_pd_mgr_get_bitmap(dev, false);
pd->id = dev->pd_mgr->pd_norm_start + pd_idx;
pd->dpp_enabled = false;
} else {
status = -EINVAL;
}
} else {
if (dev->pd_mgr->pd_norm_count < dev->pd_mgr->max_normal_pd) {
pd_idx = _ocrdma_pd_mgr_get_bitmap(dev, false);
pd->id = dev->pd_mgr->pd_norm_start + pd_idx;
} else {
status = -EINVAL;
}
}
mutex_unlock(&dev->dev_lock);
return status;
}
/*
* NOTE:
*
* ocrdma_ucontext must be used here because this function is also
* called from ocrdma_alloc_ucontext where ib_udata does not have
* valid ib_ucontext pointer. ib_uverbs_get_context does not call
* uobj_{alloc|get_xxx} helpers which are used to store the
* ib_ucontext in uverbs_attr_bundle wrapping the ib_udata. so
* ib_udata does NOT imply valid ib_ucontext here!
*/
static int _ocrdma_alloc_pd(struct ocrdma_dev *dev, struct ocrdma_pd *pd,
struct ocrdma_ucontext *uctx,
struct ib_udata *udata)
{
int status;
if (udata && uctx && dev->attr.max_dpp_pds) {
pd->dpp_enabled =
ocrdma_get_asic_type(dev) == OCRDMA_ASIC_GEN_SKH_R;
pd->num_dpp_qp =
pd->dpp_enabled ? (dev->nic_info.db_page_size /
dev->attr.wqe_size) : 0;
}
if (dev->pd_mgr->pd_prealloc_valid)
return ocrdma_get_pd_num(dev, pd);
retry:
Annotation
- Immediate include surface: `linux/dma-mapping.h`, `net/addrconf.h`, `rdma/ib_verbs.h`, `rdma/ib_user_verbs.h`, `rdma/iw_cm.h`, `rdma/ib_addr.h`, `rdma/ib_cache.h`, `rdma/iter.h`.
- Detected declarations: `function ocrdma_query_pkey`, `function ocrdma_query_device`, `function get_link_speed_and_width`, `function ocrdma_query_port`, `function ocrdma_add_mmap`, `function ocrdma_del_mmap`, `function ocrdma_search_mmap`, `function _ocrdma_pd_mgr_get_bitmap`, `function _ocrdma_pd_mgr_put_bitmap`, `function ocrdma_put_pd_num`.
- 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.