drivers/infiniband/sw/rxe/rxe_mcast.c
Source file repositories/reference/linux-study-clean/drivers/infiniband/sw/rxe/rxe_mcast.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/infiniband/sw/rxe/rxe_mcast.c- Extension
.c- Size
- 11704 bytes
- Lines
- 498
- 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
rxe.h
Detected Declarations
function Copyrightfunction rxe_mcast_delfunction __rxe_insert_mcgfunction __rxe_remove_mcgfunction __rxe_init_mcgfunction rxe_cleanup_mcgfunction __rxe_destroy_mcgfunction rxe_destroy_mcgfunction __rxe_init_mcafunction rxe_attach_mcgfunction __rxe_cleanup_mcafunction rxe_detach_mcgfunction rxe_attach_mcastfunction rxe_detach_mcast
Annotated Snippet
if (mca->qp == qp) {
spin_unlock_bh(&rxe->mcg_lock);
return 0;
}
}
spin_unlock_bh(&rxe->mcg_lock);
/* speculative alloc new mca without using GFP_ATOMIC */
mca = kzalloc_obj(*mca);
if (!mca)
return -ENOMEM;
spin_lock_bh(&rxe->mcg_lock);
/* re-check to see if someone else just attached qp */
list_for_each_entry(tmp, &mcg->qp_list, qp_list) {
if (tmp->qp == qp) {
kfree(mca);
err = 0;
goto out;
}
}
err = __rxe_init_mca(qp, mcg, mca);
if (err)
kfree(mca);
out:
spin_unlock_bh(&rxe->mcg_lock);
return err;
}
/**
* __rxe_cleanup_mca - cleanup mca object holding lock
* @mca: mca object
* @mcg: mcg object
*
* Context: caller must hold a reference to mcg and rxe->mcg_lock
*/
static void __rxe_cleanup_mca(struct rxe_mca *mca, struct rxe_mcg *mcg)
{
list_del(&mca->qp_list);
atomic_dec(&mcg->qp_num);
atomic_dec(&mcg->rxe->mcg_attach);
atomic_dec(&mca->qp->mcg_num);
rxe_put(mca->qp);
kfree(mca);
}
/**
* rxe_detach_mcg - detach qp from mcg
* @mcg: mcg object
* @qp: qp object
*
* Returns: 0 on success else an error if qp is not attached.
*/
static int rxe_detach_mcg(struct rxe_mcg *mcg, struct rxe_qp *qp)
{
struct rxe_dev *rxe = mcg->rxe;
struct rxe_mca *mca, *tmp;
spin_lock_bh(&rxe->mcg_lock);
list_for_each_entry_safe(mca, tmp, &mcg->qp_list, qp_list) {
if (mca->qp == qp) {
__rxe_cleanup_mca(mca, mcg);
/* if the number of qp's attached to the
* mcast group falls to zero go ahead and
* tear it down. This will not free the
* object since we are still holding a ref
* from the caller
*/
if (atomic_read(&mcg->qp_num) <= 0)
__rxe_destroy_mcg(mcg);
spin_unlock_bh(&rxe->mcg_lock);
return 0;
}
}
/* we didn't find the qp on the list */
spin_unlock_bh(&rxe->mcg_lock);
return -EINVAL;
}
/**
* rxe_attach_mcast - attach qp to multicast group (see IBA-11.3.1)
* @ibqp: (IB) qp object
* @mgid: multicast IP address
* @mlid: multicast LID, ignored for RoCEv2 (see IBA-A17.5.6)
Annotation
- Immediate include surface: `rxe.h`.
- Detected declarations: `function Copyright`, `function rxe_mcast_del`, `function __rxe_insert_mcg`, `function __rxe_remove_mcg`, `function __rxe_init_mcg`, `function rxe_cleanup_mcg`, `function __rxe_destroy_mcg`, `function rxe_destroy_mcg`, `function __rxe_init_mca`, `function rxe_attach_mcg`.
- 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.