Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
[sfrench/cifs-2.6.git] / drivers / infiniband / hw / cxgb3 / iwch_provider.c
index df1838f8f94d9b59b700fa1212fb622b5f1e3811..ab4695c1dd5614b3e881ad6d03abca913621ebf6 100644 (file)
@@ -101,7 +101,7 @@ static int iwch_dealloc_ucontext(struct ib_ucontext *context)
        struct iwch_ucontext *ucontext = to_iwch_ucontext(context);
        struct iwch_mm_entry *mm, *tmp;
 
-       PDBG("%s context %p\n", __FUNCTION__, context);
+       PDBG("%s context %p\n", __func__, context);
        list_for_each_entry_safe(mm, tmp, &ucontext->mmaps, entry)
                kfree(mm);
        cxio_release_ucontext(&rhp->rdev, &ucontext->uctx);
@@ -115,7 +115,7 @@ static struct ib_ucontext *iwch_alloc_ucontext(struct ib_device *ibdev,
        struct iwch_ucontext *context;
        struct iwch_dev *rhp = to_iwch_dev(ibdev);
 
-       PDBG("%s ibdev %p\n", __FUNCTION__, ibdev);
+       PDBG("%s ibdev %p\n", __func__, ibdev);
        context = kzalloc(sizeof(*context), GFP_KERNEL);
        if (!context)
                return ERR_PTR(-ENOMEM);
@@ -129,7 +129,7 @@ static int iwch_destroy_cq(struct ib_cq *ib_cq)
 {
        struct iwch_cq *chp;
 
-       PDBG("%s ib_cq %p\n", __FUNCTION__, ib_cq);
+       PDBG("%s ib_cq %p\n", __func__, ib_cq);
        chp = to_iwch_cq(ib_cq);
 
        remove_handle(chp->rhp, &chp->rhp->cqidr, chp->cq.cqid);
@@ -151,7 +151,7 @@ static struct ib_cq *iwch_create_cq(struct ib_device *ibdev, int entries, int ve
        struct iwch_create_cq_req ureq;
        struct iwch_ucontext *ucontext = NULL;
 
-       PDBG("%s ib_dev %p entries %d\n", __FUNCTION__, ibdev, entries);
+       PDBG("%s ib_dev %p entries %d\n", __func__, ibdev, entries);
        rhp = to_iwch_dev(ibdev);
        chp = kzalloc(sizeof(*chp), GFP_KERNEL);
        if (!chp)
@@ -189,7 +189,7 @@ static struct ib_cq *iwch_create_cq(struct ib_device *ibdev, int entries, int ve
                return ERR_PTR(-ENOMEM);
        }
        chp->rhp = rhp;
-       chp->ibcq.cqe = (1 << chp->cq.size_log2) - 1;
+       chp->ibcq.cqe = 1 << chp->cq.size_log2;
        spin_lock_init(&chp->lock);
        atomic_set(&chp->refcnt, 1);
        init_waitqueue_head(&chp->wait);
@@ -233,7 +233,7 @@ static int iwch_resize_cq(struct ib_cq *cq, int cqe, struct ib_udata *udata)
        struct t3_cq oldcq, newcq;
        int ret;
 
-       PDBG("%s ib_cq %p cqe %d\n", __FUNCTION__, cq, cqe);
+       PDBG("%s ib_cq %p cqe %d\n", __func__, cq, cqe);
 
        /* We don't downsize... */
        if (cqe <= cq->cqe)
@@ -281,7 +281,7 @@ static int iwch_resize_cq(struct ib_cq *cq, int cqe, struct ib_udata *udata)
        ret = cxio_destroy_cq(&chp->rhp->rdev, &oldcq);
        if (ret) {
                printk(KERN_ERR MOD "%s - cxio_destroy_cq failed %d\n",
-                       __FUNCTION__, ret);
+                       __func__, ret);
        }
 
        /* add user hooks here */
@@ -316,7 +316,7 @@ static int iwch_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags)
                chp->cq.rptr = rptr;
        } else
                spin_lock_irqsave(&chp->lock, flag);
-       PDBG("%s rptr 0x%x\n", __FUNCTION__, chp->cq.rptr);
+       PDBG("%s rptr 0x%x\n", __func__, chp->cq.rptr);
        err = cxio_hal_cq_op(&rhp->rdev, &chp->cq, cq_op, 0);
        spin_unlock_irqrestore(&chp->lock, flag);
        if (err < 0)
@@ -337,7 +337,7 @@ static int iwch_mmap(struct ib_ucontext *context, struct vm_area_struct *vma)
        struct iwch_ucontext *ucontext;
        u64 addr;
 
-       PDBG("%s pgoff 0x%lx key 0x%x len %d\n", __FUNCTION__, vma->vm_pgoff,
+       PDBG("%s pgoff 0x%lx key 0x%x len %d\n", __func__, vma->vm_pgoff,
             key, len);
 
        if (vma->vm_start & (PAGE_SIZE-1)) {
@@ -390,7 +390,7 @@ static int iwch_deallocate_pd(struct ib_pd *pd)
 
        php = to_iwch_pd(pd);
        rhp = php->rhp;
-       PDBG("%s ibpd %p pdid 0x%x\n", __FUNCTION__, pd, php->pdid);
+       PDBG("%s ibpd %p pdid 0x%x\n", __func__, pd, php->pdid);
        cxio_hal_put_pdid(rhp->rdev.rscp, php->pdid);
        kfree(php);
        return 0;
@@ -404,7 +404,7 @@ static struct ib_pd *iwch_allocate_pd(struct ib_device *ibdev,
        u32 pdid;
        struct iwch_dev *rhp;
 
-       PDBG("%s ibdev %p\n", __FUNCTION__, ibdev);
+       PDBG("%s ibdev %p\n", __func__, ibdev);
        rhp = (struct iwch_dev *) ibdev;
        pdid = cxio_hal_get_pdid(rhp->rdev.rscp);
        if (!pdid)
@@ -422,7 +422,7 @@ static struct ib_pd *iwch_allocate_pd(struct ib_device *ibdev,
                        return ERR_PTR(-EFAULT);
                }
        }
-       PDBG("%s pdid 0x%0x ptr 0x%p\n", __FUNCTION__, pdid, php);
+       PDBG("%s pdid 0x%0x ptr 0x%p\n", __func__, pdid, php);
        return &php->ibpd;
 }
 
@@ -432,7 +432,7 @@ static int iwch_dereg_mr(struct ib_mr *ib_mr)
        struct iwch_mr *mhp;
        u32 mmid;
 
-       PDBG("%s ib_mr %p\n", __FUNCTION__, ib_mr);
+       PDBG("%s ib_mr %p\n", __func__, ib_mr);
        /* There can be no memory windows */
        if (atomic_read(&ib_mr->usecnt))
                return -EINVAL;
@@ -447,7 +447,7 @@ static int iwch_dereg_mr(struct ib_mr *ib_mr)
                kfree((void *) (unsigned long) mhp->kva);
        if (mhp->umem)
                ib_umem_release(mhp->umem);
-       PDBG("%s mmid 0x%x ptr %p\n", __FUNCTION__, mmid, mhp);
+       PDBG("%s mmid 0x%x ptr %p\n", __func__, mmid, mhp);
        kfree(mhp);
        return 0;
 }
@@ -467,7 +467,7 @@ static struct ib_mr *iwch_register_phys_mem(struct ib_pd *pd,
        struct iwch_mr *mhp;
        int ret;
 
-       PDBG("%s ib_pd %p\n", __FUNCTION__, pd);
+       PDBG("%s ib_pd %p\n", __func__, pd);
        php = to_iwch_pd(pd);
        rhp = php->rhp;
 
@@ -531,7 +531,7 @@ static int iwch_reregister_phys_mem(struct ib_mr *mr,
        int npages;
        int ret;
 
-       PDBG("%s ib_mr %p ib_pd %p\n", __FUNCTION__, mr, pd);
+       PDBG("%s ib_mr %p ib_pd %p\n", __func__, mr, pd);
 
        /* There can be no memory windows */
        if (atomic_read(&mr->usecnt))
@@ -594,7 +594,7 @@ static struct ib_mr *iwch_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
        struct iwch_mr *mhp;
        struct iwch_reg_user_mr_resp uresp;
 
-       PDBG("%s ib_pd %p\n", __FUNCTION__, pd);
+       PDBG("%s ib_pd %p\n", __func__, pd);
 
        php = to_iwch_pd(pd);
        rhp = php->rhp;
@@ -649,7 +649,7 @@ static struct ib_mr *iwch_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
        if (udata && !t3a_device(rhp)) {
                uresp.pbl_addr = (mhp->attr.pbl_addr -
                                 rhp->rdev.rnic_info.pbl_base) >> 3;
-               PDBG("%s user resp pbl_addr 0x%x\n", __FUNCTION__,
+               PDBG("%s user resp pbl_addr 0x%x\n", __func__,
                     uresp.pbl_addr);
 
                if (ib_copy_to_udata(udata, &uresp, sizeof (uresp))) {
@@ -673,7 +673,7 @@ static struct ib_mr *iwch_get_dma_mr(struct ib_pd *pd, int acc)
        u64 kva;
        struct ib_mr *ibmr;
 
-       PDBG("%s ib_pd %p\n", __FUNCTION__, pd);
+       PDBG("%s ib_pd %p\n", __func__, pd);
 
        /*
         * T3 only supports 32 bits of size.
@@ -710,7 +710,7 @@ static struct ib_mw *iwch_alloc_mw(struct ib_pd *pd)
        mhp->attr.stag = stag;
        mmid = (stag) >> 8;
        insert_handle(rhp, &rhp->mmidr, mhp, mmid);
-       PDBG("%s mmid 0x%x mhp %p stag 0x%x\n", __FUNCTION__, mmid, mhp, stag);
+       PDBG("%s mmid 0x%x mhp %p stag 0x%x\n", __func__, mmid, mhp, stag);
        return &(mhp->ibmw);
 }
 
@@ -726,7 +726,7 @@ static int iwch_dealloc_mw(struct ib_mw *mw)
        cxio_deallocate_window(&rhp->rdev, mhp->attr.stag);
        remove_handle(rhp, &rhp->mmidr, mmid);
        kfree(mhp);
-       PDBG("%s ib_mw %p mmid 0x%x ptr %p\n", __FUNCTION__, mw, mmid, mhp);
+       PDBG("%s ib_mw %p mmid 0x%x ptr %p\n", __func__, mw, mmid, mhp);
        return 0;
 }
 
@@ -754,7 +754,7 @@ static int iwch_destroy_qp(struct ib_qp *ib_qp)
        cxio_destroy_qp(&rhp->rdev, &qhp->wq,
                        ucontext ? &ucontext->uctx : &rhp->rdev.uctx);
 
-       PDBG("%s ib_qp %p qpid 0x%0x qhp %p\n", __FUNCTION__,
+       PDBG("%s ib_qp %p qpid 0x%0x qhp %p\n", __func__,
             ib_qp, qhp->wq.qpid, qhp);
        kfree(qhp);
        return 0;
@@ -773,7 +773,7 @@ static struct ib_qp *iwch_create_qp(struct ib_pd *pd,
        int wqsize, sqsize, rqsize;
        struct iwch_ucontext *ucontext;
 
-       PDBG("%s ib_pd %p\n", __FUNCTION__, pd);
+       PDBG("%s ib_pd %p\n", __func__, pd);
        if (attrs->qp_type != IB_QPT_RC)
                return ERR_PTR(-EINVAL);
        php = to_iwch_pd(pd);
@@ -805,7 +805,7 @@ static struct ib_qp *iwch_create_qp(struct ib_pd *pd,
         */
        sqsize = roundup_pow_of_two(attrs->cap.max_send_wr);
        wqsize = roundup_pow_of_two(rqsize + sqsize);
-       PDBG("%s wqsize %d sqsize %d rqsize %d\n", __FUNCTION__,
+       PDBG("%s wqsize %d sqsize %d rqsize %d\n", __func__,
             wqsize, sqsize, rqsize);
        qhp = kzalloc(sizeof(*qhp), GFP_KERNEL);
        if (!qhp)
@@ -819,8 +819,11 @@ static struct ib_qp *iwch_create_qp(struct ib_pd *pd,
                kfree(qhp);
                return ERR_PTR(-ENOMEM);
        }
+
        attrs->cap.max_recv_wr = rqsize - 1;
        attrs->cap.max_send_wr = sqsize;
+       attrs->cap.max_inline_data = T3_MAX_INLINE;
+
        qhp->rhp = rhp;
        qhp->attr.pd = php->pdid;
        qhp->attr.scq = ((struct iwch_cq *) attrs->send_cq)->cq.cqid;
@@ -895,7 +898,7 @@ static struct ib_qp *iwch_create_qp(struct ib_pd *pd,
        init_timer(&(qhp->timer));
        PDBG("%s sq_num_entries %d, rq_num_entries %d "
             "qpid 0x%0x qhp %p dma_addr 0x%llx size %d\n",
-            __FUNCTION__, qhp->attr.sq_num_entries, qhp->attr.rq_num_entries,
+            __func__, qhp->attr.sq_num_entries, qhp->attr.rq_num_entries,
             qhp->wq.qpid, qhp, (unsigned long long) qhp->wq.dma_addr,
             1 << qhp->wq.size_log2);
        return &qhp->ibqp;
@@ -909,7 +912,7 @@ static int iwch_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
        enum iwch_qp_attr_mask mask = 0;
        struct iwch_qp_attributes attrs;
 
-       PDBG("%s ib_qp %p\n", __FUNCTION__, ibqp);
+       PDBG("%s ib_qp %p\n", __func__, ibqp);
 
        /* iwarp does not support the RTR state */
        if ((attr_mask & IB_QP_STATE) && (attr->qp_state == IB_QPS_RTR))
@@ -942,20 +945,20 @@ static int iwch_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
 
 void iwch_qp_add_ref(struct ib_qp *qp)
 {
-       PDBG("%s ib_qp %p\n", __FUNCTION__, qp);
+       PDBG("%s ib_qp %p\n", __func__, qp);
        atomic_inc(&(to_iwch_qp(qp)->refcnt));
 }
 
 void iwch_qp_rem_ref(struct ib_qp *qp)
 {
-       PDBG("%s ib_qp %p\n", __FUNCTION__, qp);
+       PDBG("%s ib_qp %p\n", __func__, qp);
        if (atomic_dec_and_test(&(to_iwch_qp(qp)->refcnt)))
                wake_up(&(to_iwch_qp(qp)->wait));
 }
 
 static struct ib_qp *iwch_get_qp(struct ib_device *dev, int qpn)
 {
-       PDBG("%s ib_dev %p qpn 0x%x\n", __FUNCTION__, dev, qpn);
+       PDBG("%s ib_dev %p qpn 0x%x\n", __func__, dev, qpn);
        return (struct ib_qp *)get_qhp(to_iwch_dev(dev), qpn);
 }
 
@@ -963,7 +966,7 @@ static struct ib_qp *iwch_get_qp(struct ib_device *dev, int qpn)
 static int iwch_query_pkey(struct ib_device *ibdev,
                           u8 port, u16 index, u16 * pkey)
 {
-       PDBG("%s ibdev %p\n", __FUNCTION__, ibdev);
+       PDBG("%s ibdev %p\n", __func__, ibdev);
        *pkey = 0;
        return 0;
 }
@@ -974,7 +977,7 @@ static int iwch_query_gid(struct ib_device *ibdev, u8 port,
        struct iwch_dev *dev;
 
        PDBG("%s ibdev %p, port %d, index %d, gid %p\n",
-              __FUNCTION__, ibdev, port, index, gid);
+              __func__, ibdev, port, index, gid);
        dev = to_iwch_dev(ibdev);
        BUG_ON(port == 0 || port > 2);
        memset(&(gid->raw[0]), 0, sizeof(gid->raw));
@@ -987,7 +990,7 @@ static int iwch_query_device(struct ib_device *ibdev,
 {
 
        struct iwch_dev *dev;
-       PDBG("%s ibdev %p\n", __FUNCTION__, ibdev);
+       PDBG("%s ibdev %p\n", __func__, ibdev);
 
        dev = to_iwch_dev(ibdev);
        memset(props, 0, sizeof *props);
@@ -1014,7 +1017,7 @@ static int iwch_query_device(struct ib_device *ibdev,
 static int iwch_query_port(struct ib_device *ibdev,
                           u8 port, struct ib_port_attr *props)
 {
-       PDBG("%s ibdev %p\n", __FUNCTION__, ibdev);
+       PDBG("%s ibdev %p\n", __func__, ibdev);
        props->max_mtu = IB_MTU_4096;
        props->lid = 0;
        props->lmc = 0;
@@ -1038,61 +1041,60 @@ static int iwch_query_port(struct ib_device *ibdev,
        return 0;
 }
 
-static ssize_t show_rev(struct class_device *cdev, char *buf)
+static ssize_t show_rev(struct device *dev, struct device_attribute *attr,
+                       char *buf)
 {
-       struct iwch_dev *dev = container_of(cdev, struct iwch_dev,
-                                           ibdev.class_dev);
-       PDBG("%s class dev 0x%p\n", __FUNCTION__, cdev);
-       return sprintf(buf, "%d\n", dev->rdev.t3cdev_p->type);
+       struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev,
+                                                ibdev.dev);
+       PDBG("%s dev 0x%p\n", __func__, dev);
+       return sprintf(buf, "%d\n", iwch_dev->rdev.t3cdev_p->type);
 }
 
-static ssize_t show_fw_ver(struct class_device *cdev, char *buf)
+static ssize_t show_fw_ver(struct device *dev, struct device_attribute *attr, char *buf)
 {
-       struct iwch_dev *dev = container_of(cdev, struct iwch_dev,
-                                           ibdev.class_dev);
+       struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev,
+                                                ibdev.dev);
        struct ethtool_drvinfo info;
-       struct net_device *lldev = dev->rdev.t3cdev_p->lldev;
+       struct net_device *lldev = iwch_dev->rdev.t3cdev_p->lldev;
 
-       PDBG("%s class dev 0x%p\n", __FUNCTION__, cdev);
-       rtnl_lock();
+       PDBG("%s dev 0x%p\n", __func__, dev);
        lldev->ethtool_ops->get_drvinfo(lldev, &info);
-       rtnl_unlock();
        return sprintf(buf, "%s\n", info.fw_version);
 }
 
-static ssize_t show_hca(struct class_device *cdev, char *buf)
+static ssize_t show_hca(struct device *dev, struct device_attribute *attr,
+                       char *buf)
 {
-       struct iwch_dev *dev = container_of(cdev, struct iwch_dev,
-                                           ibdev.class_dev);
+       struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev,
+                                                ibdev.dev);
        struct ethtool_drvinfo info;
-       struct net_device *lldev = dev->rdev.t3cdev_p->lldev;
+       struct net_device *lldev = iwch_dev->rdev.t3cdev_p->lldev;
 
-       PDBG("%s class dev 0x%p\n", __FUNCTION__, cdev);
-       rtnl_lock();
+       PDBG("%s dev 0x%p\n", __func__, dev);
        lldev->ethtool_ops->get_drvinfo(lldev, &info);
-       rtnl_unlock();
        return sprintf(buf, "%s\n", info.driver);
 }
 
-static ssize_t show_board(struct class_device *cdev, char *buf)
+static ssize_t show_board(struct device *dev, struct device_attribute *attr,
+                         char *buf)
 {
-       struct iwch_dev *dev = container_of(cdev, struct iwch_dev,
-                                           ibdev.class_dev);
-       PDBG("%s class dev 0x%p\n", __FUNCTION__, dev);
-       return sprintf(buf, "%x.%x\n", dev->rdev.rnic_info.pdev->vendor,
-                                      dev->rdev.rnic_info.pdev->device);
+       struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev,
+                                                ibdev.dev);
+       PDBG("%s dev 0x%p\n", __func__, dev);
+       return sprintf(buf, "%x.%x\n", iwch_dev->rdev.rnic_info.pdev->vendor,
+                      iwch_dev->rdev.rnic_info.pdev->device);
 }
 
-static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
-static CLASS_DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL);
-static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
-static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL);
+static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
+static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL);
+static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
+static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL);
 
-static struct class_device_attribute *iwch_class_attributes[] = {
-       &class_device_attr_hw_rev,
-       &class_device_attr_fw_ver,
-       &class_device_attr_hca_type,
-       &class_device_attr_board_id
+static struct device_attribute *iwch_class_attributes[] = {
+       &dev_attr_hw_rev,
+       &dev_attr_fw_ver,
+       &dev_attr_hca_type,
+       &dev_attr_board_id
 };
 
 int iwch_register_device(struct iwch_dev *dev)
@@ -1100,14 +1102,13 @@ int iwch_register_device(struct iwch_dev *dev)
        int ret;
        int i;
 
-       PDBG("%s iwch_dev %p\n", __FUNCTION__, dev);
+       PDBG("%s iwch_dev %p\n", __func__, dev);
        strlcpy(dev->ibdev.name, "cxgb3_%d", IB_DEVICE_NAME_MAX);
        memset(&dev->ibdev.node_guid, 0, sizeof(dev->ibdev.node_guid));
        memcpy(&dev->ibdev.node_guid, dev->rdev.t3cdev_p->lldev->dev_addr, 6);
        dev->ibdev.owner = THIS_MODULE;
        dev->device_cap_flags =
-           (IB_DEVICE_ZERO_STAG |
-            IB_DEVICE_SEND_W_INV | IB_DEVICE_MEM_WINDOW);
+           (IB_DEVICE_ZERO_STAG | IB_DEVICE_MEM_WINDOW);
 
        dev->ibdev.uverbs_cmd_mask =
            (1ull << IB_USER_VERBS_CMD_GET_CONTEXT) |
@@ -1187,8 +1188,8 @@ int iwch_register_device(struct iwch_dev *dev)
                goto bail1;
 
        for (i = 0; i < ARRAY_SIZE(iwch_class_attributes); ++i) {
-               ret = class_device_create_file(&dev->ibdev.class_dev,
-                                              iwch_class_attributes[i]);
+               ret = device_create_file(&dev->ibdev.dev,
+                                        iwch_class_attributes[i]);
                if (ret) {
                        goto bail2;
                }
@@ -1204,10 +1205,10 @@ void iwch_unregister_device(struct iwch_dev *dev)
 {
        int i;
 
-       PDBG("%s iwch_dev %p\n", __FUNCTION__, dev);
+       PDBG("%s iwch_dev %p\n", __func__, dev);
        for (i = 0; i < ARRAY_SIZE(iwch_class_attributes); ++i)
-               class_device_remove_file(&dev->ibdev.class_dev,
-                                        iwch_class_attributes[i]);
+               device_remove_file(&dev->ibdev.dev,
+                                  iwch_class_attributes[i]);
        ib_unregister_device(&dev->ibdev);
        return;
 }