[openib-general] [PATCH 02/18] [RFC] Provider Device Discovery

Steve Wise swise at opengridcomputing.com
Mon Mar 6 10:03:24 PST 2006


--- old/src/linux-kernel/infiniband/hw/cxgb3/iwch.c	1969-12-31 18:00:00.000000000 -0600
+++ new/src/linux-kernel/infiniband/hw/cxgb3/iwch.c	2006-03-06 09:26:21.000000000 -0600
@@ -0,0 +1,198 @@
+/*
+ * Copyright (c) 2006 Chelsio, Inc. All rights reserved.
+ * Copyright (c) 2006 Open Grid Computing, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <rdma/ib_verbs.h>
+
+#include <t3c.h>
+#include "iwch_provider.h"
+#include "iwch_user.h"
+#include "iwch.h"
+#include "iwch_cm.h"
+
+MODULE_AUTHOR("Boyd Faulkner <faulkner at opengridcomputing.com>, "
+	      "Steve Wise <swise at opengridcomputing.com");
+MODULE_DESCRIPTION("Chelsio iWARP OpenIB Driver");
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_VERSION("1.0");
+
+t3c_cpl_handler_t t3c_handlers[NUM_CPL_CMDS];
+
+static void open_rnic_toe(struct t3cdev *);
+static void close_rnic_toe(struct t3cdev *);
+
+struct t3c_client t3c_client = {
+	.name = "iwch",
+	.add = open_rnic_toe,
+	.remove = close_rnic_toe,
+	.handlers = t3c_handlers
+};
+
+static LIST_HEAD(dev_list);
+DECLARE_MUTEX(dev_mutex);
+
+static int open_rnic_init(struct iwch_dev *rnicp)
+{
+	PDBG("%s line %d\n", __FUNCTION__,  __LINE__);
+	if (!(rnicp->pdid2hlp = kzalloc(sizeof(void *) * T3_MAX_NUM_PD, 
+	                                GFP_KERNEL)))
+		goto pdid_err;
+	if (!(rnicp->cqid2hlp = kzalloc(sizeof(void *) * T3_MAX_NUM_CQ, 
+				        GFP_KERNEL)))
+		goto cqid_err;
+	if (!(rnicp->qpid2hlp = kzalloc(sizeof(void *) * T3_MAX_NUM_QP, 
+				        GFP_KERNEL)))
+		goto qpid_err;
+	if (!(rnicp->stag2hlp = kzalloc(sizeof(void *) * T3_MAX_NUM_STAG, 
+			                GFP_KERNEL)))
+		goto stag_err;
+
+	spin_lock_init(&rnicp->lock);
+
+	rnicp->attr.vendorID = 0x168;
+	rnicp->attr.vendorPartID = 7;
+	rnicp->attr.hwVersion = 3;
+	rnicp->attr.addl_vendor_info = NULL;
+	rnicp->attr.addl_vendor_info_length = 0;
+	rnicp->attr.maxQPs = T3_MAX_NUM_QP - 32;
+	rnicp->attr.maxWRs = (1UL << 24) - 1;
+	rnicp->attr.maxSGEperWR = T3_MAX_SGE;
+	rnicp->attr.maxSGEperRDMAWWR = T3_MAX_SGE;
+	rnicp->attr.maxCQs = T3_MAX_NUM_CQ - 1;
+	rnicp->attr.maxCQEsPerCQ = (1UL << 24) - 1;
+	rnicp->attr.max_cq_event_handlers = T3_MAX_NUM_CQ - 1;
+	rnicp->attr.maxMemRegs = T3_MAX_NUM_STAG;
+	rnicp->attr.max_phys_buf_entries = T3_MAX_PBL_SIZE;
+	rnicp->attr.maxPDs = T3_MAX_NUM_PD - 1;
+	rnicp->attr.memPgSizesBitMask = 0x7FFF;	/* 4KB-128MB */
+	rnicp->attr.canResizeWQ = 0;
+	rnicp->attr.maxRDMAreadsPerQP = 8;
+	rnicp->attr.maxRDMAreadResources =
+	    rnicp->attr.maxRDMAreadsPerQP * rnicp->attr.maxQPs;
+	rnicp->attr.maxRDMAreadQPdepth = 8;	/* IRD */
+	rnicp->attr.maxRDMAreaddepth =
+	    rnicp->attr.maxRDMAreadQPdepth * rnicp->attr.maxQPs;
+	rnicp->attr.rq_overflow_handled = 0;
+	rnicp->attr.can_modify_ird = 0;
+	rnicp->attr.can_modify_ord = 0;
+	rnicp->attr.maxMemWindows = T3_MAX_NUM_STAG - 1;/* Shared with MR */
+	rnicp->attr.stag0_value = 1;
+	rnicp->attr.zbva_support = 1;
+	rnicp->attr.local_invalidate_fence = 1;
+	rnicp->attr.cq_overflow_detection = 1;
+	return 0;
+
+stag_err:
+	kfree(rnicp->qpid2hlp);
+qpid_err:
+	kfree(rnicp->cqid2hlp);
+cqid_err:
+	kfree(rnicp->pdid2hlp);
+pdid_err:
+	return -ENOMEM;
+}
+
+static void open_rnic_toe(struct t3cdev *tdev)
+{
+	struct iwch_dev *rnicp;
+
+	PDBG("%s line %d\n", __FUNCTION__,  __LINE__);
+	if (!(rnicp = (struct iwch_dev *)ib_alloc_device(sizeof(*rnicp)))) {
+		printk(KERN_ERR PFX "cannot allocate ib device!\n");
+	}
+	rnicp->rdev.ulp = rnicp;
+	rnicp->rdev.t3cdev_p = tdev;
+
+	if (cxio_rdev_open(&rnicp->rdev)) {
+		printk(KERN_ERR PFX "Unable to register with RDMA Core\n");
+		ib_dealloc_device(&rnicp->ibdev);
+		return;
+	}
+
+	if (open_rnic_init(rnicp)) {
+		printk(KERN_ERR PFX "Unable to initialize iwch_dev!\n");
+		cxio_rdev_close(&rnicp->rdev);
+		ib_dealloc_device(&rnicp->ibdev);
+		return;
+	}
+
+	down(&dev_mutex);
+	list_add_tail(&rnicp->entry, &dev_list);
+	up(&dev_mutex);
+
+	if (iwch_register_device(rnicp)) {
+		printk(KERN_ERR PFX "Unable to register with openib\n");
+		close_rnic_toe(tdev);
+	}
+	return;
+}
+
+static void close_rnic_toe(struct t3cdev *tdev)
+{
+	struct iwch_dev *dev;
+	PDBG("%s line %d\n", __FUNCTION__,  __LINE__);
+	down(&dev_mutex);
+	list_for_each_entry(dev, &dev_list, entry) {
+		if (dev->rdev.t3cdev_p == tdev) {
+			list_del(&dev->entry);
+			iwch_unregister_device(dev);
+			cxio_rdev_close(&dev->rdev);
+			kfree(dev->pdid2hlp);
+			kfree(dev->cqid2hlp);
+			kfree(dev->stag2hlp);
+			kfree(dev->qpid2hlp);
+			ib_dealloc_device(&dev->ibdev);
+			break;
+		}
+	}
+	up(&dev_mutex);
+}
+
+extern void iwch_ev_dispatch(struct cxio_rdev *rdev_p, struct sk_buff *skb);
+
+static int __init iwch_init_module(void)
+{
+	iwch_cm_init();
+	cxio_register_ev_cb(iwch_ev_dispatch);
+	t3c_register_client(&t3c_client);
+	return 0;
+}
+
+static void __exit iwch_exit_module(void)
+{
+	t3c_unregister_client(&t3c_client);
+	cxio_unregister_ev_cb(iwch_ev_dispatch);
+}
+
+module_init(iwch_init_module);
+module_exit(iwch_exit_module);
--- old/src/linux-kernel/infiniband/hw/cxgb3/iwch.h	1969-12-31 18:00:00.000000000 -0600
+++ new/src/linux-kernel/infiniband/hw/cxgb3/iwch.h	2006-03-06 09:26:21.000000000 -0600
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2006 Chelsio, Inc. All rights reserved.
+ * Copyright (c) 2006 Open Grid Computing, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef __IWCH_H__
+#define __IWCH_H__
+
+#include <linux/list.h>
+#include <linux/spinlock.h>
+
+#include <rdma/ib_verbs.h>
+
+#include "cxio_hal.h"
+#include "common.h"
+#include "t3c.h"
+#include "iwch_provider.h"
+
+struct iwch_dev {
+	struct ib_device ibdev;
+	struct cxio_rdev rdev;
+	u32 device_cap_flags;
+	struct iwch_rnic_attributes attr;
+	struct iwch_pd **pdid2hlp;
+	struct iwch_cq **cqid2hlp;
+	struct iwch_qp **qpid2hlp;
+	struct iwch_mr **stag2hlp;
+	spinlock_t lock;
+	struct list_head entry;
+};
+
+static inline struct iwch_dev *to_iwch_dev(struct ib_device *ibdev)
+{
+	return container_of(ibdev, struct iwch_dev, ibdev);
+}
+
+extern struct t3c_client t3c_client;
+extern t3c_cpl_handler_t t3c_handlers[NUM_CPL_CMDS];
+#endif




More information about the general mailing list