err = mthca_READ_MGM(dev, index, mgm, &status); 
err = mthca_READ_MGM(dev, index, mailbox, &status); 
int mthca_multicast_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid){	struct mthca_dev *dev = to_mdev(ibqp->device);	void *mailbox;	struct mthca_mgm *mgm;	u16 hash;	int index, prev;	int link = 0;	int i;	int err;	u8 status;	mailbox = kmalloc(sizeof *mgm + MTHCA_CMD_MAILBOX_EXTRA, GFP_KERNEL);	if (!mailbox)		return -ENOMEM;	mgm = MAILBOX_ALIGN(mailbox);	if (down_interruptible(&dev->mcg_table.sem))		return -EINTR;	err = find_mgm(dev, gid->raw, mgm, &hash, &prev, &index);	if (err)		goto out;	if (index != -1) {		if (!memcmp(mgm->gid, zero_gid, 16))			memcpy(mgm->gid, gid->raw, 16);	} else {		link = 1;		index = mthca_alloc(&dev->mcg_table.alloc);		if (index == -1) {			mthca_err(dev, "No AMGM entries left\n");			err = -ENOMEM;			goto out;		}		err = mthca_READ_MGM(dev, index, mgm, &status);		if (err)			goto out;		if (status) {			mthca_err(dev, "READ_MGM returned status %02x\n", status);			err = -EINVAL;			goto out;		}		memcpy(mgm->gid, gid->raw, 16);		mgm->next_gid_index = 0;	}	for (i = 0; i < MTHCA_QP_PER_MGM; ++i)		if (!(mgm->qp[i] & cpu_to_be32(1 << 31))) {			mgm->qp[i] = cpu_to_be32(ibqp->qp_num | (1 << 31));			break;		}	if (i == MTHCA_QP_PER_MGM) {		mthca_err(dev, "MGM at index %x is full.\n", index);		err = -ENOMEM;		goto out;	}	err = mthca_WRITE_MGM(dev, index, mgm, &status);	if (err)		goto out;	if (status) {		mthca_err(dev, "WRITE_MGM returned status %02x\n", status);		err = -EINVAL;	}	if (!link)		goto out;	err = mthca_READ_MGM(dev, prev, mgm, &status);	if (err)		goto out;	if (status) {		mthca_err(dev, "READ_MGM returned status %02x\n", status);		err = -EINVAL;		goto out;	}	mgm->next_gid_index = cpu_to_be32(index << 5);	err = mthca_WRITE_MGM(dev, prev, mgm, &status);	if (err)		goto out;	if (status) {		mthca_err(dev, "WRITE_MGM returned status %02x\n", status);		err = -EINVAL;	} out:	up(&dev->mcg_table.sem);	kfree(mailbox);	return err;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/ed878458eeff9754d66f1b0325df6ebbfcdce668/mthca_mcg.c/clean/drivers/infiniband/hw/mthca/mthca_mcg.c