drivers/infiniband/hw/usnic/usnic_ib_verbs.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/hw/usnic/usnic_ib_verbs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/hw/usnic/usnic_ib_verbs.c- Extension
.c- Size
- 18889 bytes
- Lines
- 709
- 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.
- 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/init.hlinux/slab.hlinux/errno.hrdma/ib_user_verbs.hrdma/ib_addr.hrdma/uverbs_ioctl.husnic_abi.husnic_ib.husnic_common_util.husnic_ib_qp_grp.husnic_ib_verbs.husnic_fwd.husnic_log.husnic_uiom.husnic_transport.h
Detected Declarations
function usnic_ib_fw_string_to_u64function usnic_ib_fill_create_qp_respfunction find_free_vf_and_create_qp_grpfunction qp_grp_destroyfunction create_qp_validate_user_datafunction usnic_ib_port_link_layerfunction usnic_ib_query_devicefunction usnic_ib_query_portfunction usnic_ib_query_qpfunction usnic_ib_query_gidfunction usnic_ib_alloc_pdfunction usnic_ib_dealloc_pdfunction usnic_ib_create_qpfunction usnic_ib_destroy_qpfunction usnic_ib_modify_qpfunction usnic_ib_create_cqfunction usnic_ib_destroy_cqfunction usnic_ib_dereg_mrfunction usnic_ib_alloc_ucontextfunction usnic_ib_dealloc_ucontextfunction usnic_ib_mmap
Annotated Snippet
if (!usnic_vnic_check_room(vnic, res_spec)) {
usnic_dbg("Found used vnic %s from %s\n",
dev_name(&us_ibdev->ib_dev.dev),
pci_name(usnic_vnic_get_pdev(
vnic)));
ret = usnic_ib_qp_grp_create(qp_grp,
us_ibdev->ufdev,
vf, pd, res_spec,
trans_spec);
mutex_unlock(&vf->lock);
goto qp_grp_check;
}
mutex_unlock(&vf->lock);
}
usnic_uiom_free_dev_list(dev_list);
dev_list = NULL;
}
/* Try to find resources on an unused vf */
list_for_each_entry(vf, &us_ibdev->vf_dev_list, link) {
mutex_lock(&vf->lock);
vnic = vf->vnic;
if (vf->qp_grp_ref_cnt == 0 &&
usnic_vnic_check_room(vnic, res_spec) == 0) {
ret = usnic_ib_qp_grp_create(qp_grp, us_ibdev->ufdev,
vf, pd, res_spec,
trans_spec);
mutex_unlock(&vf->lock);
goto qp_grp_check;
}
mutex_unlock(&vf->lock);
}
usnic_info("No free qp grp found on %s\n",
dev_name(&us_ibdev->ib_dev.dev));
return -ENOMEM;
qp_grp_check:
if (ret) {
usnic_err("Failed to allocate qp_grp\n");
if (usnic_ib_share_vf)
usnic_uiom_free_dev_list(dev_list);
}
return ret;
}
static void qp_grp_destroy(struct usnic_ib_qp_grp *qp_grp)
{
struct usnic_ib_vf *vf = qp_grp->vf;
WARN_ON(qp_grp->state != IB_QPS_RESET);
mutex_lock(&vf->lock);
usnic_ib_qp_grp_destroy(qp_grp);
mutex_unlock(&vf->lock);
}
static int create_qp_validate_user_data(struct usnic_ib_create_qp_cmd cmd)
{
if (cmd.spec.trans_type <= USNIC_TRANSPORT_UNKNOWN ||
cmd.spec.trans_type >= USNIC_TRANSPORT_MAX)
return -EINVAL;
return 0;
}
/* Start of ib callback functions */
enum rdma_link_layer usnic_ib_port_link_layer(struct ib_device *device,
u32 port_num)
{
return IB_LINK_LAYER_ETHERNET;
}
int usnic_ib_query_device(struct ib_device *ibdev,
struct ib_device_attr *props,
struct ib_udata *uhw)
{
struct usnic_ib_dev *us_ibdev = to_usdev(ibdev);
union ib_gid gid;
struct ethtool_drvinfo info;
int qp_per_vf;
int err;
usnic_dbg("\n");
err = ib_is_udata_in_empty(uhw);
if (err)
Annotation
- Immediate include surface: `linux/init.h`, `linux/slab.h`, `linux/errno.h`, `rdma/ib_user_verbs.h`, `rdma/ib_addr.h`, `rdma/uverbs_ioctl.h`, `usnic_abi.h`, `usnic_ib.h`.
- Detected declarations: `function usnic_ib_fw_string_to_u64`, `function usnic_ib_fill_create_qp_resp`, `function find_free_vf_and_create_qp_grp`, `function qp_grp_destroy`, `function create_qp_validate_user_data`, `function usnic_ib_port_link_layer`, `function usnic_ib_query_device`, `function usnic_ib_query_port`, `function usnic_ib_query_qp`, `function usnic_ib_query_gid`.
- 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.
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.