Re: [openib-general] [PATCH 02/13] Device Discovery and ULLD Linkage

2006-11-17 Thread Steve Wise
On Fri, 2006-11-17 at 09:53 -0800, Bryan O'Sullivan wrote:
> Steve Wise wrote:
> 
> > +static inline void *vzmalloc(int size)
> > +{
> > +   void *p = vmalloc(size);
> > +   memset(p, 0, size);
> > +   return p;
> > +}
> 
> This isn't checking the return value from vmalloc.
> 

Oops...


> Also, we could do with a generic vzalloc and vcalloc, just as we now 
> have kzalloc and kcalloc.  There are lots of routines like this sitting 
> around.
> 
>   http://vger.kernel.org/majordomo-info.html


Re: [openib-general] [PATCH 02/13] Device Discovery and ULLD Linkage

2006-11-17 Thread Bryan O'Sullivan

Steve Wise wrote:


+static inline void *vzmalloc(int size)
+{
+   void *p = vmalloc(size);
+   memset(p, 0, size);
+   return p;
+}


This isn't checking the return value from vmalloc.

Also, we could do with a generic vzalloc and vcalloc, just as we now 
have kzalloc and kcalloc.  There are lots of routines like this sitting 
around.


http://vger.kernel.org/majordomo-info.html


[PATCH 02/13] Device Discovery and ULLD Linkage

2006-11-15 Thread Steve Wise

Code to discover all the T3 devices and register them 
with the T3 RDMA Core and the Linux RDMA Core.

Signed-off-by: Steve Wise <[EMAIL PROTECTED]>
---

 drivers/infiniband/hw/cxgb3/iwch.c |  222 
 drivers/infiniband/hw/cxgb3/iwch.h |  134 ++
 2 files changed, 356 insertions(+), 0 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb3/iwch.c 
b/drivers/infiniband/hw/cxgb3/iwch.c
new file mode 100644
index 000..f45f005
--- /dev/null
+++ b/drivers/infiniband/hw/cxgb3/iwch.c
@@ -0,0 +1,222 @@
+/*
+ * 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 
+#include 
+
+#include 
+
+#include "cxgb3_offload.h"
+#include "iwch_provider.h"
+#include "iwch_user.h"
+#include "iwch.h"
+#include "iwch_cm.h"
+
+#define DRV_VERSION "1.1"
+
+MODULE_AUTHOR("Boyd Faulkner, Steve Wise");
+MODULE_DESCRIPTION("Chelsio T3 RDMA Driver");
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_VERSION(DRV_VERSION);
+
+cxgb3_cpl_handler_func t3c_handlers[NUM_CPL_CMDS];
+
+static void open_rnic_dev(struct t3cdev *);
+static void close_rnic_dev(struct t3cdev *);
+
+struct cxgb3_client t3c_client = {
+   .name = "iw_cxgb3",
+   .add = open_rnic_dev,
+   .remove = close_rnic_dev,
+   .handlers = t3c_handlers,
+   .redirect = iwch_ep_redirect
+};
+
+static LIST_HEAD(dev_list);
+static DEFINE_MUTEX(dev_mutex);
+
+static inline void *vzmalloc(int size)
+{
+   void *p = vmalloc(size);
+   memset(p, 0, size);
+   return p;
+}
+
+static int open_rnic_init(struct iwch_dev *rnicp)
+{
+   PDBG("%s iwch_dev %p\n", __FUNCTION__,  rnicp);
+   rnicp->pdid2ptr = vzmalloc(sizeof(void*) * T3_MAX_NUM_PD);
+   if (!rnicp->pdid2ptr)
+   goto pdid_err;
+   rnicp->cqid2ptr = vzmalloc(sizeof(void*) * T3_MAX_NUM_CQ);
+   if (!rnicp->cqid2ptr)
+   goto cqid_err;
+   rnicp->qpid2ptr = vzmalloc(sizeof(void*) * T3_MAX_NUM_QP);
+   if (!rnicp->qpid2ptr)
+   goto qpid_err;
+   rnicp->mmid2ptr = vzmalloc(sizeof(void*) * 
+  cxio_num_stags(&rnicp->rdev));
+   if (!rnicp->mmid2ptr)
+   goto stag_err;
+
+   spin_lock_init(&rnicp->lock);
+
+   rnicp->attr.vendor_id = 0x168;
+   rnicp->attr.vendor_part_id = 7;
+   rnicp->attr.max_qps = T3_MAX_NUM_QP - 32;
+   rnicp->attr.max_wrs = (1UL << 24) - 1;
+   rnicp->attr.max_sge_per_wr = T3_MAX_SGE;
+   rnicp->attr.max_sge_per_rdma_write_wr = T3_MAX_SGE;
+   rnicp->attr.max_cqs = T3_MAX_NUM_CQ - 1;
+   rnicp->attr.max_cqes_per_cq = (1UL << 24) - 1;
+   rnicp->attr.max_mem_regs = cxio_num_stags(&rnicp->rdev);
+   rnicp->attr.max_phys_buf_entries = T3_MAX_PBL_SIZE;
+   rnicp->attr.max_pds = T3_MAX_NUM_PD - 1;
+   rnicp->attr.mem_pgsizes_bitmask = 0x7FFF;   /* 4KB-128MB */
+   rnicp->attr.can_resize_wq = 0;
+   rnicp->attr.max_rdma_reads_per_qp = 8;
+   rnicp->attr.max_rdma_read_resources =
+   rnicp->attr.max_rdma_reads_per_qp * rnicp->attr.max_qps;
+   rnicp->attr.max_rdma_read_qp_depth = 8; /* IRD */
+   rnicp->attr.max_rdma_read_depth =
+   rnicp->attr.max_rdma_read_qp_depth * rnicp->attr.max_qps;
+   rnicp->attr.rq_overflow_handled = 0;
+   rnicp->attr.can_modify_ird = 0;
+   rnicp->attr.can_modify_ord = 0;
+   rnicp->attr.max_mem_windows = rnicp->attr.max_mem_regs - 1;
+   rnicp->attr.stag0_value = 1;
+   rnicp->attr.zbva_support = 1;
+   rnicp->attr.local_invalidate_fe