[ewg] [PATCH 2/9] [RFC] Add sysfs support for xsigo IB
Hal Rosenstock
hrosenstock at xsigo.com
Fri Apr 4 06:13:00 PDT 2008
This patch adds sysfs support for xsigo IB
Signed-off-by: Hal Rosenstock <hal at xsigo.com>
---
.../infiniband/ulp/xsigo/xscore/xsigoib_stats.c | 105 ++++++++++++++++++++
.../infiniband/ulp/xsigo/xscore/xsigoib_stats.h | 40 ++++++++
2 files changed, 145 insertions(+), 0 deletions(-)
create mode 100644 drivers/infiniband/ulp/xsigo/xscore/xsigoib_stats.c
create mode 100644 drivers/infiniband/ulp/xsigo/xscore/xsigoib_stats.h
diff --git a/drivers/infiniband/ulp/xsigo/xscore/xsigoib_stats.c b/drivers/infiniband/ulp/xsigo/xscore/xsigoib_stats.c
new file mode 100644
index 0000000..be5e24f
--- /dev/null
+++ b/drivers/infiniband/ulp/xsigo/xscore/xsigoib_stats.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2006-2008 Xsigo Systems 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/kernel.h>
+#include <linux/module.h>
+#include <linux/version.h>
+
+#include "xsigoib.h"
+#include "xs_core.h"
+
+#define PFX "xscore/xsigoib: "
+
+extern u32 num_connects;
+extern u32 num_disconnects;
+
+static ssize_t show_num_connects(struct class_device *class_dev, char *buf)
+{
+ return sprintf(buf, "%d", num_connects);
+}
+
+static CLASS_DEVICE_ATTR(num_connects, S_IRUGO, show_num_connects, NULL);
+
+static ssize_t show_num_disconnects(struct class_device *class_dev, char *buf)
+{
+ return sprintf(buf, "%d", num_disconnects);
+}
+
+static CLASS_DEVICE_ATTR(num_disconnects, S_IRUGO, show_num_disconnects, NULL);
+
+static struct attribute *xsigo_ib_dev_attrs[] = {
+ &class_device_attr_num_connects.attr,
+ &class_device_attr_num_disconnects.attr,
+ NULL
+};
+
+static struct attribute_group xsigo_ib_dev_attr_group = {
+ .attrs = xsigo_ib_dev_attrs,
+};
+
+extern struct class xscore_class;
+
+static struct class_device xsigoib_class_dev;
+
+int xsigo_ib_register_sysfs(void)
+{
+ int ret;
+
+ xsigoib_class_dev.class = &xscore_class;
+ xsigoib_class_dev.parent = NULL;
+ snprintf(xsigoib_class_dev.class_id, BUS_ID_SIZE, "xsigoib");
+
+ ret = class_device_register(&xsigoib_class_dev);
+ if (ret) {
+ printk(KERN_ERR PFX "xsigo_ib_register_sysfs: error %d in registering"
+ " xsigoib class dev\n", ret);
+ goto out;
+ }
+
+ ret = sysfs_create_group(&xsigoib_class_dev.kobj,
+ &xsigo_ib_dev_attr_group);
+ if (!ret)
+ goto out;
+ printk(KERN_ERR PFX "xsigo_ib_register_sysfs: error %d in creating"
+ "xsigoib attr group\n", ret);
+ class_device_unregister(&xsigoib_class_dev);
+
+out:
+ return ret;
+}
+
+void xsigo_ib_unregister_sysfs(void)
+{
+ sysfs_remove_group(&xsigoib_class_dev.kobj, &xsigo_ib_dev_attr_group);
+ class_device_unregister(&xsigoib_class_dev);
+}
diff --git a/drivers/infiniband/ulp/xsigo/xscore/xsigoib_stats.h b/drivers/infiniband/ulp/xsigo/xscore/xsigoib_stats.h
new file mode 100644
index 0000000..1866233
--- /dev/null
+++ b/drivers/infiniband/ulp/xsigo/xscore/xsigoib_stats.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2006-2008 Xsigo Systems 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 __XSIGOIB_STATS_H__
+#define __XSIGOIB_STATS_H__
+
+int xsigo_ib_register_sysfs(void);
+void xsigo_ib_unregister_sysfs(void);
+
+#endif /* __XSIGOIB_STATS_H__ */
--
1.5.2
More information about the ewg
mailing list