/*
* Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
* Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
- * Copyright (c) 2005, 2006 Cisco Systems. All rights reserved.
+ * Copyright (c) 2005 Cisco Systems. All rights reserved.
* Copyright (c) 2005 Mellanox Technologies. All rights reserved.
* Copyright (c) 2004 Voltaire, Inc. All rights reserved.
*
props->max_res_rd_atom = props->max_qp_rd_atom * props->max_qp;
props->max_srq = mdev->limits.num_srqs - mdev->limits.reserved_srqs;
props->max_srq_wr = mdev->limits.max_srq_wqes;
- props->max_srq_sge = mdev->limits.max_srq_sge;
+ props->max_srq_sge = mdev->limits.max_sg;
props->local_ca_ack_delay = mdev->limits.local_ca_ack_delay;
- props->atomic_cap = mdev->limits.flags & DEV_LIM_FLAG_ATOMIC ?
+ props->atomic_cap = mdev->limits.flags & DEV_LIM_FLAG_ATOMIC ?
IB_ATOMIC_HCA : IB_ATOMIC_NONE;
props->max_pkeys = mdev->limits.pkey_table_len;
props->max_mcast_grp = mdev->limits.num_mgms + mdev->limits.num_amgms;
props->max_mcast_qp_attach = MTHCA_QP_PER_MGM;
- props->max_total_mcast_qp_attach = props->max_mcast_qp_attach *
+ props->max_total_mcast_qp_attach = props->max_mcast_qp_attach *
props->max_mcast_grp;
- /*
- * If Sinai memory key optimization is being used, then only
- * the 8-bit key portion will change. For other HCAs, the
- * unused index bits will also be used for FMR remapping.
- */
- if (mdev->mthca_flags & MTHCA_FLAG_SINAI_OPT)
- props->max_map_per_fmr = 255;
- else
- props->max_map_per_fmr =
- (1 << (32 - long_log2(mdev->limits.num_mpts))) - 1;
err = 0;
out:
return err;
}
-static int mthca_modify_device(struct ib_device *ibdev,
- int mask,
- struct ib_device_modify *props)
-{
- if (mask & ~IB_DEVICE_MODIFY_NODE_DESC)
- return -EOPNOTSUPP;
-
- if (mask & IB_DEVICE_MODIFY_NODE_DESC) {
- if (mutex_lock_interruptible(&to_mdev(ibdev)->cap_mask_mutex))
- return -ERESTARTSYS;
- memcpy(ibdev->node_desc, props->node_desc, 64);
- mutex_unlock(&to_mdev(ibdev)->cap_mask_mutex);
- }
-
- return 0;
-}
-
static int mthca_modify_port(struct ib_device *ibdev,
u8 port, int port_modify_mask,
struct ib_port_modify *props)
goto out;
}
- memcpy(gid->raw + 8, out_mad->data + (index % 8) * 8, 8);
+ memcpy(gid->raw + 8, out_mad->data + (index % 8) * 16, 8);
out:
kfree(in_mad);
}
if (context) {
- cq->buf.mr.ibmr.lkey = ucmd.lkey;
- cq->set_ci_db_index = ucmd.set_db_index;
- cq->arm_db_index = ucmd.arm_db_index;
+ cq->mr.ibmr.lkey = ucmd.lkey;
+ cq->set_ci_db_index = ucmd.set_db_index;
+ cq->arm_db_index = ucmd.arm_db_index;
}
for (nent = 1; nent <= entries; nent <<= 1)
goto err_free;
}
- cq->resize_buf = NULL;
-
return &cq->ibcq;
err_free:
return ERR_PTR(err);
}
-static int mthca_alloc_resize_buf(struct mthca_dev *dev, struct mthca_cq *cq,
- int entries)
-{
- int ret;
-
- spin_lock_irq(&cq->lock);
- if (cq->resize_buf) {
- ret = -EBUSY;
- goto unlock;
- }
-
- cq->resize_buf = kmalloc(sizeof *cq->resize_buf, GFP_ATOMIC);
- if (!cq->resize_buf) {
- ret = -ENOMEM;
- goto unlock;
- }
-
- cq->resize_buf->state = CQ_RESIZE_ALLOC;
-
- ret = 0;
-
-unlock:
- spin_unlock_irq(&cq->lock);
-
- if (ret)
- return ret;
-
- ret = mthca_alloc_cq_buf(dev, &cq->resize_buf->buf, entries);
- if (ret) {
- spin_lock_irq(&cq->lock);
- kfree(cq->resize_buf);
- cq->resize_buf = NULL;
- spin_unlock_irq(&cq->lock);
- return ret;
- }
-
- cq->resize_buf->cqe = entries - 1;
-
- spin_lock_irq(&cq->lock);
- cq->resize_buf->state = CQ_RESIZE_READY;
- spin_unlock_irq(&cq->lock);
-
- return 0;
-}
-
-static int mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
-{
- struct mthca_dev *dev = to_mdev(ibcq->device);
- struct mthca_cq *cq = to_mcq(ibcq);
- struct mthca_resize_cq ucmd;
- u32 lkey;
- u8 status;
- int ret;
-
- if (entries < 1 || entries > dev->limits.max_cqes)
- return -EINVAL;
-
- mutex_lock(&cq->mutex);
-
- entries = roundup_pow_of_two(entries + 1);
- if (entries == ibcq->cqe + 1) {
- ret = 0;
- goto out;
- }
-
- if (cq->is_kernel) {
- ret = mthca_alloc_resize_buf(dev, cq, entries);
- if (ret)
- goto out;
- lkey = cq->resize_buf->buf.mr.ibmr.lkey;
- } else {
- if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) {
- ret = -EFAULT;
- goto out;
- }
- lkey = ucmd.lkey;
- }
-
- ret = mthca_RESIZE_CQ(dev, cq->cqn, lkey, long_log2(entries), &status);
- if (status)
- ret = -EINVAL;
-
- if (ret) {
- if (cq->resize_buf) {
- mthca_free_cq_buf(dev, &cq->resize_buf->buf,
- cq->resize_buf->cqe);
- kfree(cq->resize_buf);
- spin_lock_irq(&cq->lock);
- cq->resize_buf = NULL;
- spin_unlock_irq(&cq->lock);
- }
- goto out;
- }
-
- if (cq->is_kernel) {
- struct mthca_cq_buf tbuf;
- int tcqe;
-
- spin_lock_irq(&cq->lock);
- if (cq->resize_buf->state == CQ_RESIZE_READY) {
- mthca_cq_resize_copy_cqes(cq);
- tbuf = cq->buf;
- tcqe = cq->ibcq.cqe;
- cq->buf = cq->resize_buf->buf;
- cq->ibcq.cqe = cq->resize_buf->cqe;
- } else {
- tbuf = cq->resize_buf->buf;
- tcqe = cq->resize_buf->cqe;
- }
-
- kfree(cq->resize_buf);
- cq->resize_buf = NULL;
- spin_unlock_irq(&cq->lock);
-
- mthca_free_cq_buf(dev, &tbuf, tcqe);
- } else
- ibcq->cqe = entries - 1;
-
-out:
- mutex_unlock(&cq->mutex);
-
- return ret;
-}
-
static int mthca_destroy_cq(struct ib_cq *cq)
{
if (cq->uobject) {
goto out;
init_query_mad(in_mad);
- in_mad->attr_id = IB_SMP_ATTR_NODE_DESC;
-
- err = mthca_MAD_IFC(dev, 1, 1,
- 1, NULL, NULL, in_mad, out_mad,
- &status);
- if (err)
- goto out;
- if (status) {
- err = -EINVAL;
- goto out;
- }
-
- memcpy(dev->ib_dev.node_desc, out_mad->data, 64);
-
in_mad->attr_id = IB_SMP_ATTR_NODE_INFO;
err = mthca_MAD_IFC(dev, 1, 1,
(1ull << IB_USER_VERBS_CMD_DEREG_MR) |
(1ull << IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL) |
(1ull << IB_USER_VERBS_CMD_CREATE_CQ) |
- (1ull << IB_USER_VERBS_CMD_RESIZE_CQ) |
(1ull << IB_USER_VERBS_CMD_DESTROY_CQ) |
(1ull << IB_USER_VERBS_CMD_CREATE_QP) |
- (1ull << IB_USER_VERBS_CMD_QUERY_QP) |
(1ull << IB_USER_VERBS_CMD_MODIFY_QP) |
(1ull << IB_USER_VERBS_CMD_DESTROY_QP) |
(1ull << IB_USER_VERBS_CMD_ATTACH_MCAST) |
- (1ull << IB_USER_VERBS_CMD_DETACH_MCAST);
+ (1ull << IB_USER_VERBS_CMD_DETACH_MCAST) |
+ (1ull << IB_USER_VERBS_CMD_CREATE_SRQ) |
+ (1ull << IB_USER_VERBS_CMD_MODIFY_SRQ) |
+ (1ull << IB_USER_VERBS_CMD_DESTROY_SRQ);
dev->ib_dev.node_type = IB_NODE_CA;
dev->ib_dev.phys_port_cnt = dev->limits.num_ports;
dev->ib_dev.dma_device = &dev->pdev->dev;
dev->ib_dev.class_dev.dev = &dev->pdev->dev;
dev->ib_dev.query_device = mthca_query_device;
dev->ib_dev.query_port = mthca_query_port;
- dev->ib_dev.modify_device = mthca_modify_device;
dev->ib_dev.modify_port = mthca_modify_port;
dev->ib_dev.query_pkey = mthca_query_pkey;
dev->ib_dev.query_gid = mthca_query_gid;
dev->ib_dev.alloc_pd = mthca_alloc_pd;
dev->ib_dev.dealloc_pd = mthca_dealloc_pd;
dev->ib_dev.create_ah = mthca_ah_create;
- dev->ib_dev.query_ah = mthca_ah_query;
dev->ib_dev.destroy_ah = mthca_ah_destroy;
if (dev->mthca_flags & MTHCA_FLAG_SRQ) {
dev->ib_dev.create_srq = mthca_create_srq;
- dev->ib_dev.modify_srq = mthca_modify_srq;
- dev->ib_dev.query_srq = mthca_query_srq;
+ dev->ib_dev.modify_srq = mthca_modify_srq;
dev->ib_dev.destroy_srq = mthca_destroy_srq;
- dev->ib_dev.uverbs_cmd_mask |=
- (1ull << IB_USER_VERBS_CMD_CREATE_SRQ) |
- (1ull << IB_USER_VERBS_CMD_MODIFY_SRQ) |
- (1ull << IB_USER_VERBS_CMD_QUERY_SRQ) |
- (1ull << IB_USER_VERBS_CMD_DESTROY_SRQ);
if (mthca_is_memfree(dev))
dev->ib_dev.post_srq_recv = mthca_arbel_post_srq_recv;
dev->ib_dev.create_qp = mthca_create_qp;
dev->ib_dev.modify_qp = mthca_modify_qp;
- dev->ib_dev.query_qp = mthca_query_qp;
dev->ib_dev.destroy_qp = mthca_destroy_qp;
dev->ib_dev.create_cq = mthca_create_cq;
- dev->ib_dev.resize_cq = mthca_resize_cq;
dev->ib_dev.destroy_cq = mthca_destroy_cq;
dev->ib_dev.poll_cq = mthca_poll_cq;
dev->ib_dev.get_dma_mr = mthca_get_dma_mr;