Lines Matching refs:mcast
12 #include "mcast.h"
30 * rvt_mcast_qp_alloc - alloc a struct to link a QP to mcast GID struct
67 struct rvt_mcast *mcast;
69 mcast = kzalloc(sizeof(*mcast), GFP_KERNEL);
70 if (!mcast)
73 mcast->mcast_addr.mgid = *mgid;
74 mcast->mcast_addr.lid = lid;
76 INIT_LIST_HEAD(&mcast->qp_list);
77 init_waitqueue_head(&mcast->wait);
78 atomic_set(&mcast->refcount, 0);
81 return mcast;
84 static void rvt_mcast_free(struct rvt_mcast *mcast)
88 list_for_each_entry_safe(p, tmp, &mcast->qp_list, list)
91 kfree(mcast);
117 struct rvt_mcast *mcast;
119 mcast = rb_entry(n, struct rvt_mcast, rb_node);
121 ret = memcmp(mgid->raw, mcast->mcast_addr.mgid.raw,
129 if (mcast->mcast_addr.lid == lid) {
130 atomic_inc(&mcast->refcount);
131 found = mcast;
142 * rvt_mcast_add - insert mcast GID into table and attach QP struct
143 * @mcast: the mcast GID table
152 struct rvt_mcast *mcast, struct rvt_mcast_qp *mqp)
167 ret = memcmp(mcast->mcast_addr.mgid.raw,
169 sizeof(mcast->mcast_addr.mgid));
179 if (tmcast->mcast_addr.lid != mcast->mcast_addr.lid) {
214 mcast->n_attached++;
216 list_add_tail_rcu(&mqp->list, &mcast->qp_list);
218 atomic_inc(&mcast->refcount);
219 rb_link_node(&mcast->rb_node, pn, n);
220 rb_insert_color(&mcast->rb_node, &ibp->mcast_tree);
243 struct rvt_mcast *mcast;
254 mcast = rvt_mcast_alloc(gid, lid);
255 if (!mcast)
262 switch (rvt_mcast_add(rdi, ibp, mcast, mqp)) {
267 case EEXIST: /* The mcast wasn't used */
271 /* Exceeded the maximum number of mcast groups. */
288 rvt_mcast_free(mcast);
306 struct rvt_mcast *mcast = NULL;
317 /* Find the GID in the mcast table. */
325 mcast = rb_entry(n, struct rvt_mcast, rb_node);
326 ret = memcmp(gid->raw, mcast->mcast_addr.mgid.raw,
334 if (mcast->mcast_addr.lid != lid) {
343 list_for_each_entry_safe(p, tmp, &mcast->qp_list, list) {
351 mcast->n_attached--;
355 if (list_empty(&mcast->qp_list)) {
356 rb_erase(&mcast->rb_node, &ibp->mcast_tree);
371 wait_event(mcast->wait, atomic_read(&mcast->refcount) <= 1);
375 atomic_dec(&mcast->refcount);
376 wait_event(mcast->wait, !atomic_read(&mcast->refcount));
377 rvt_mcast_free(mcast);
387 * rvt_mcast_tree_empty - determine if any qps are attached to any mcast group