Lines Matching +full:mailbox +full:-

14  *      - Redistributions of source code must retain the above
18 * - Redistributions in binary form must reproduce the above
54 * If GID is found in MGM or MGM is empty, *index = *hash, *prev = -1
60 * If no AMGM exists for given gid, *index = -1, *prev = index of last
67 struct mthca_mailbox *mailbox; in find_mgm() local
68 struct mthca_mgm *mgm = mgm_mailbox->buf; in find_mgm()
72 mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL); in find_mgm()
73 if (IS_ERR(mailbox)) in find_mgm()
74 return -ENOMEM; in find_mgm()
75 mgid = mailbox->buf; in find_mgm()
79 err = mthca_MGID_HASH(dev, mailbox, hash); in find_mgm()
89 *prev = -1; in find_mgm()
98 if (!memcmp(mgm->gid, zero_gid, 16)) { in find_mgm()
101 err = -EINVAL; in find_mgm()
106 if (!memcmp(mgm->gid, gid, 16)) in find_mgm()
110 *index = be32_to_cpu(mgm->next_gid_index) >> 6; in find_mgm()
113 *index = -1; in find_mgm()
116 mthca_free_mailbox(dev, mailbox); in find_mgm()
122 struct mthca_dev *dev = to_mdev(ibqp->device); in mthca_multicast_attach()
123 struct mthca_mailbox *mailbox; in mthca_multicast_attach() local
131 mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL); in mthca_multicast_attach()
132 if (IS_ERR(mailbox)) in mthca_multicast_attach()
133 return PTR_ERR(mailbox); in mthca_multicast_attach()
134 mgm = mailbox->buf; in mthca_multicast_attach()
136 mutex_lock(&dev->mcg_table.mutex); in mthca_multicast_attach()
138 err = find_mgm(dev, gid->raw, mailbox, &hash, &prev, &index); in mthca_multicast_attach()
142 if (index != -1) { in mthca_multicast_attach()
143 if (!memcmp(mgm->gid, zero_gid, 16)) in mthca_multicast_attach()
144 memcpy(mgm->gid, gid->raw, 16); in mthca_multicast_attach()
148 index = mthca_alloc(&dev->mcg_table.alloc); in mthca_multicast_attach()
149 if (index == -1) { in mthca_multicast_attach()
151 err = -ENOMEM; in mthca_multicast_attach()
155 err = mthca_READ_MGM(dev, index, mailbox); in mthca_multicast_attach()
161 memcpy(mgm->gid, gid->raw, 16); in mthca_multicast_attach()
165 if (mgm->qp[i] == cpu_to_be32(ibqp->qp_num | (1 << 31))) { in mthca_multicast_attach()
167 ibqp->qp_num); in mthca_multicast_attach()
170 } else if (!(mgm->qp[i] & cpu_to_be32(1 << 31))) { in mthca_multicast_attach()
171 mgm->qp[i] = cpu_to_be32(ibqp->qp_num | (1 << 31)); in mthca_multicast_attach()
177 err = -ENOMEM; in mthca_multicast_attach()
181 err = mthca_WRITE_MGM(dev, index, mailbox); in mthca_multicast_attach()
184 err = -EINVAL; in mthca_multicast_attach()
191 err = mthca_READ_MGM(dev, prev, mailbox); in mthca_multicast_attach()
197 mgm->next_gid_index = cpu_to_be32(index << 6); in mthca_multicast_attach()
199 err = mthca_WRITE_MGM(dev, prev, mailbox); in mthca_multicast_attach()
204 if (err && link && index != -1) { in mthca_multicast_attach()
205 BUG_ON(index < dev->limits.num_mgms); in mthca_multicast_attach()
206 mthca_free(&dev->mcg_table.alloc, index); in mthca_multicast_attach()
208 mutex_unlock(&dev->mcg_table.mutex); in mthca_multicast_attach()
210 mthca_free_mailbox(dev, mailbox); in mthca_multicast_attach()
216 struct mthca_dev *dev = to_mdev(ibqp->device); in mthca_multicast_detach()
217 struct mthca_mailbox *mailbox; in mthca_multicast_detach() local
224 mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL); in mthca_multicast_detach()
225 if (IS_ERR(mailbox)) in mthca_multicast_detach()
226 return PTR_ERR(mailbox); in mthca_multicast_detach()
227 mgm = mailbox->buf; in mthca_multicast_detach()
229 mutex_lock(&dev->mcg_table.mutex); in mthca_multicast_detach()
231 err = find_mgm(dev, gid->raw, mailbox, &hash, &prev, &index); in mthca_multicast_detach()
235 if (index == -1) { in mthca_multicast_detach()
236 mthca_err(dev, "MGID %pI6 not found\n", gid->raw); in mthca_multicast_detach()
237 err = -EINVAL; in mthca_multicast_detach()
241 for (loc = -1, i = 0; i < MTHCA_QP_PER_MGM; ++i) { in mthca_multicast_detach()
242 if (mgm->qp[i] == cpu_to_be32(ibqp->qp_num | (1 << 31))) in mthca_multicast_detach()
244 if (!(mgm->qp[i] & cpu_to_be32(1 << 31))) in mthca_multicast_detach()
248 if (loc == -1) { in mthca_multicast_detach()
249 mthca_err(dev, "QP %06x not found in MGM\n", ibqp->qp_num); in mthca_multicast_detach()
250 err = -EINVAL; in mthca_multicast_detach()
254 mgm->qp[loc] = mgm->qp[i - 1]; in mthca_multicast_detach()
255 mgm->qp[i - 1] = 0; in mthca_multicast_detach()
257 err = mthca_WRITE_MGM(dev, index, mailbox); in mthca_multicast_detach()
266 if (prev == -1) { in mthca_multicast_detach()
268 int amgm_index_to_free = be32_to_cpu(mgm->next_gid_index) >> 6; in mthca_multicast_detach()
271 mailbox); in mthca_multicast_detach()
277 memset(mgm->gid, 0, 16); in mthca_multicast_detach()
279 err = mthca_WRITE_MGM(dev, index, mailbox); in mthca_multicast_detach()
285 BUG_ON(amgm_index_to_free < dev->limits.num_mgms); in mthca_multicast_detach()
286 mthca_free(&dev->mcg_table.alloc, amgm_index_to_free); in mthca_multicast_detach()
290 int curr_next_index = be32_to_cpu(mgm->next_gid_index) >> 6; in mthca_multicast_detach()
291 err = mthca_READ_MGM(dev, prev, mailbox); in mthca_multicast_detach()
297 mgm->next_gid_index = cpu_to_be32(curr_next_index << 6); in mthca_multicast_detach()
299 err = mthca_WRITE_MGM(dev, prev, mailbox); in mthca_multicast_detach()
304 BUG_ON(index < dev->limits.num_mgms); in mthca_multicast_detach()
305 mthca_free(&dev->mcg_table.alloc, index); in mthca_multicast_detach()
309 mutex_unlock(&dev->mcg_table.mutex); in mthca_multicast_detach()
311 mthca_free_mailbox(dev, mailbox); in mthca_multicast_detach()
318 int table_size = dev->limits.num_mgms + dev->limits.num_amgms; in mthca_init_mcg_table()
320 err = mthca_alloc_init(&dev->mcg_table.alloc, in mthca_init_mcg_table()
322 table_size - 1, in mthca_init_mcg_table()
323 dev->limits.num_mgms); in mthca_init_mcg_table()
327 mutex_init(&dev->mcg_table.mutex); in mthca_init_mcg_table()
334 mthca_alloc_cleanup(&dev->mcg_table.alloc); in mthca_cleanup_mcg_table()