Lines Matching refs:mcast
87 struct ipath_mcast *mcast; in ipath_mcast_alloc() local
89 mcast = kmalloc(sizeof *mcast, GFP_KERNEL); in ipath_mcast_alloc()
90 if (!mcast) in ipath_mcast_alloc()
93 mcast->mgid = *mgid; in ipath_mcast_alloc()
94 INIT_LIST_HEAD(&mcast->qp_list); in ipath_mcast_alloc()
95 init_waitqueue_head(&mcast->wait); in ipath_mcast_alloc()
96 atomic_set(&mcast->refcount, 0); in ipath_mcast_alloc()
97 mcast->n_attached = 0; in ipath_mcast_alloc()
100 return mcast; in ipath_mcast_alloc()
103 static void ipath_mcast_free(struct ipath_mcast *mcast) in ipath_mcast_free() argument
107 list_for_each_entry_safe(p, tmp, &mcast->qp_list, list) in ipath_mcast_free()
110 kfree(mcast); in ipath_mcast_free()
125 struct ipath_mcast *mcast; in ipath_mcast_find() local
132 mcast = rb_entry(n, struct ipath_mcast, rb_node); in ipath_mcast_find()
134 ret = memcmp(mgid->raw, mcast->mgid.raw, in ipath_mcast_find()
141 atomic_inc(&mcast->refcount); in ipath_mcast_find()
148 mcast = NULL; in ipath_mcast_find()
151 return mcast; in ipath_mcast_find()
164 struct ipath_mcast *mcast, in ipath_mcast_add() argument
180 ret = memcmp(mcast->mgid.raw, tmcast->mgid.raw, in ipath_mcast_add()
220 mcast->n_attached++; in ipath_mcast_add()
222 list_add_tail_rcu(&mqp->list, &mcast->qp_list); in ipath_mcast_add()
224 atomic_inc(&mcast->refcount); in ipath_mcast_add()
225 rb_link_node(&mcast->rb_node, pn, n); in ipath_mcast_add()
226 rb_insert_color(&mcast->rb_node, &mcast_tree); in ipath_mcast_add()
240 struct ipath_mcast *mcast; in ipath_multicast_attach() local
248 mcast = ipath_mcast_alloc(gid); in ipath_multicast_attach()
249 if (mcast == NULL) { in ipath_multicast_attach()
255 ipath_mcast_free(mcast); in ipath_multicast_attach()
259 switch (ipath_mcast_add(dev, mcast, mqp)) { in ipath_multicast_attach()
263 ipath_mcast_free(mcast); in ipath_multicast_attach()
267 ipath_mcast_free(mcast); in ipath_multicast_attach()
272 ipath_mcast_free(mcast); in ipath_multicast_attach()
289 struct ipath_mcast *mcast = NULL; in ipath_multicast_detach() local
306 mcast = rb_entry(n, struct ipath_mcast, rb_node); in ipath_multicast_detach()
307 ret = memcmp(gid->raw, mcast->mgid.raw, in ipath_multicast_detach()
318 list_for_each_entry_safe(p, tmp, &mcast->qp_list, list) { in ipath_multicast_detach()
326 mcast->n_attached--; in ipath_multicast_detach()
329 if (list_empty(&mcast->qp_list)) { in ipath_multicast_detach()
330 rb_erase(&mcast->rb_node, &mcast_tree); in ipath_multicast_detach()
343 wait_event(mcast->wait, atomic_read(&mcast->refcount) <= 1); in ipath_multicast_detach()
347 atomic_dec(&mcast->refcount); in ipath_multicast_detach()
348 wait_event(mcast->wait, !atomic_read(&mcast->refcount)); in ipath_multicast_detach()
349 ipath_mcast_free(mcast); in ipath_multicast_detach()