Re: [PATCH v2 13/51] IB/qib: Add qib_driver.c

2010-04-07 Thread John A. Gregor
Roland Dreier  wrote:
>  > Where can I find information on trace events?  Something in 
> Documentation/*?
>
> Yep, Documentation/trace/events.txt.

LWN just did a really good writeup on using the TRACE_EVENT macro:

http://lwn.net/Articles/379903/

Part 2 is still behind the paywall.

-John Gregor
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 13/51] IB/qib: Add qib_driver.c

2010-04-07 Thread Roland Dreier
 > Where can I find information on trace events?  Something in Documentation/*?

Yep, Documentation/trace/events.txt.

Also look at eg include/trace/events/ext4.h and how the trace_ext4_{xxx}
functions are used in fs/ext4/*.

It's much better than anything you're going to hack up for a single
driver to use.

 - R.
-- 
Roland Dreier  || For corporate legal information go to:
http://www.cisco.com/web/about/doing_business/legal/cri/index.html
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 13/51] IB/qib: Add qib_driver.c

2010-04-07 Thread Steve Wise

Roland Dreier wrote:

 > +unsigned qib_debug;
 > +module_param_named(debug, qib_debug, uint, S_IWUSR | S_IRUGO);
 > +MODULE_PARM_DESC(debug, "mask for debug prints");

Did you look at using trace events for this stuff?  That gives you
extremely low overhead when tracing is turned off (dynamic patching to
NOP out the tracing when it's disabled) and also very fine-grained (per
trace site) control over what gets printed; plus you get dumping of the
trace buffer on crash, etc.

 - R.
  


Where can I find information on trace events?  Something in Documentation/*?

Thanks,


Steve.


--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 13/51] IB/qib: Add qib_driver.c

2010-04-07 Thread Roland Dreier
 > +DEFINE_MUTEX(qib_mutex);/* general driver use */

Rather than having this ill-defined mutex that I think is going to make
it hard to understand the locking and get the lock ordering right, would
it be better to have well-defined locking rules?  AFAICT this mutex is
used in only two places, qib_diag.c and qib_file_op.c.  Are those two
uses protecting the same thing?  Or could we have two static mutexes,
one in each file, that protects what each file needs protected?
-- 
Roland Dreier  || For corporate legal information go to:
http://www.cisco.com/web/about/doing_business/legal/cri/index.html
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 13/51] IB/qib: Add qib_driver.c

2010-04-07 Thread Roland Dreier
 > +unsigned qib_debug;
 > +module_param_named(debug, qib_debug, uint, S_IWUSR | S_IRUGO);
 > +MODULE_PARM_DESC(debug, "mask for debug prints");

Did you look at using trace events for this stuff?  That gives you
extremely low overhead when tracing is turned off (dynamic patching to
NOP out the tracing when it's disabled) and also very fine-grained (per
trace site) control over what gets printed; plus you get dumping of the
trace buffer on crash, etc.

 - R.
-- 
Roland Dreier  || For corporate legal information go to:
http://www.cisco.com/web/about/doing_business/legal/cri/index.html
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 13/51] IB/qib: Add qib_driver.c

2009-12-03 Thread Ralph Campbell
creates the qib_driver.c file.

Signed-off-by: Ralph Campbell 
---

 drivers/infiniband/hw/qib/qib_driver.c |  793 
 1 files changed, 793 insertions(+), 0 deletions(-)
 create mode 100644 drivers/infiniband/hw/qib/qib_driver.c

diff --git a/drivers/infiniband/hw/qib/qib_driver.c 
b/drivers/infiniband/hw/qib/qib_driver.c
new file mode 100644
index 000..a9a9896
--- /dev/null
+++ b/drivers/infiniband/hw/qib/qib_driver.c
@@ -0,0 +1,793 @@
+/*
+ * Copyright (c) 2006, 2007, 2008, 2009 QLogic Corporation. All rights 
reserved.
+ * Copyright (c) 2003, 2004, 2005, 2006 PathScale, 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 
+#include 
+#include 
+
+#include "qib.h"
+
+/*
+ * The size has to be longer than this string, so we can append
+ * board/chip information to it in the init code.
+ */
+const char ib_qib_version[] = QIB_IDSTR "\n";
+
+DEFINE_SPINLOCK(qib_devs_lock);
+LIST_HEAD(qib_dev_list);
+DEFINE_MUTEX(qib_mutex);   /* general driver use */
+
+unsigned qib_debug;
+module_param_named(debug, qib_debug, uint, S_IWUSR | S_IRUGO);
+MODULE_PARM_DESC(debug, "mask for debug prints");
+
+unsigned qib_ibmtu;
+module_param_named(ibmtu, qib_ibmtu, uint, S_IRUGO);
+MODULE_PARM_DESC(ibmtu, "Set max IB MTU (0=2KB, 1=256, 2=512, ... 5=4096");
+
+unsigned qib_compat_ddr_negotiate = 1;
+module_param_named(compat_ddr_negotiate, qib_compat_ddr_negotiate, uint,
+  S_IWUSR | S_IRUGO);
+MODULE_PARM_DESC(compat_ddr_negotiate,
+"Attempt pre-IBTA 1.2 DDR speed negotiation");
+
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_AUTHOR("QLogic ");
+MODULE_DESCRIPTION("QLogic IB driver");
+
+/*
+ * QIB_PIO_MAXIBHDR is the max IB header size allowed for in our
+ * PIO send buffers.  This is well beyond anything currently
+ * defined in the InfiniBand spec.
+ */
+#define QIB_PIO_MAXIBHDR 128
+
+struct qlogic_ib_stats qib_stats;
+
+const char *qib_get_unit_name(int unit)
+{
+   static char iname[16];
+
+   snprintf(iname, sizeof iname, "infinipath%u", unit);
+   return iname;
+}
+
+/*
+ * Return count of units with at least one port ACTIVE.
+ */
+int qib_count_active_units(void)
+{
+   struct qib_devdata *dd;
+   struct qib_pportdata *ppd;
+   unsigned long flags;
+   int pidx, nunits_active = 0;
+
+   spin_lock_irqsave(&qib_devs_lock, flags);
+   list_for_each_entry(dd, &qib_dev_list, list) {
+   if (!(dd->flags & QIB_PRESENT) || !dd->kregbase)
+   continue;
+   for (pidx = 0; pidx < dd->num_pports; ++pidx) {
+   ppd = dd->pport + pidx;
+   if (ppd->lid && (ppd->lflags & (QIBL_LINKINIT |
+QIBL_LINKARMED | QIBL_LINKACTIVE))) {
+   nunits_active++;
+   break;
+   }
+   }
+   }
+   spin_unlock_irqrestore(&qib_devs_lock, flags);
+   return nunits_active;
+}
+
+/*
+ * Return count of all units, optionally return in arguments
+ * the number of usable (present) units, and the number of
+ * ports that are up.
+ */
+int qib_count_units(int *npresentp, int *nupp)
+{
+   int nunits = 0, npresent = 0, nup = 0;
+   struct qib_devdata *dd;
+   unsigned long flags;
+   int pidx;
+   struct qib_pportdata *ppd;
+
+   spin_lock_irqsave(&qib_devs_lock, flags);
+
+   list_for_each_entry(dd, &qib_dev_list, list) {
+   nunits++;
+   if ((dd->flags & QIB_PRESENT) && dd->kregbase)
+