api.h \
lib-lnet.h \
lib-types.h \
+ lnet-sysfs.h \
socklnd.h
--- /dev/null
+/*
+ * GPL HEADER START
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see
+ * http://www.gnu.org/licenses/gpl-2.0.html
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Use is subject to license terms.
+ *
+ * Copyright (c) 2011, 2017, Intel Corporation.
+ *
+ * Author:
+ * Sonia Sharma <sonia.sharma@intel.com>
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
+ *
+ * lnet/include/lnet/lnet-sysfs.h
+ *
+ */
+
+#ifndef __LNET_LNET_SYSFS_H__
+#define __LNET_LNET_SYSFS_H__
+
+#ifndef __KERNEL__
+# error This include is only for kernel use.
+#endif
+
+#include <libcfs/libcfs.h>
+#include <lnet/api.h>
+#include <lnet/lib-types.h>
+#include <uapi/linux/lnet/lnet-dlc.h>
+#include <uapi/linux/lnet/lnet-types.h>
+
+
+extern struct kobject *lnet_kobj; /* Sysfs lnet kobject */
+
+struct lnet_attr {
+ struct attribute attr;
+ ssize_t (*show)(struct kobject *kobj, struct attribute *attr,
+ char *buf);
+ ssize_t (*store)(struct kobject *kobj, struct attribute *attr,
+ const char *buf, size_t len);
+};
+
+#define LNET_ATTR(name, mode, show, store) \
+static struct lnet_attr lnet_attr_##name = __ATTR(name, mode, show, store)
+
+#define LNET_RO_ATTR(name) LNET_ATTR(name, 0444, name##_show, NULL)
+#define LNET_RW_ATTR(name) LNET_ATTR(name, 0644, name##_show, name##_store)
+
+ssize_t lnet_attr_show(struct kobject *kobj, struct attribute *attr,
+ char *buf);
+
+ssize_t lnet_attr_store(struct kobject *kobj, struct attribute *attr,
+ const char *buf, size_t len);
+
+extern const struct sysfs_ops lnet_sysfs_ops;
+
+#endif
MODULES := lnet
-lnet-objs := api-ni.o config.o nidstrings.o
+lnet-objs := api-ni.o config.o nidstrings.o lnet-sysfs.o
lnet-objs += lib-me.o lib-msg.o lib-eq.o lib-md.o lib-ptl.o
lnet-objs += lib-socket.o lib-move.o module.o lo.o
lnet-objs += router.o router_proc.o acceptor.o peer.o net_fault.o
--- /dev/null
+/*
+ * GPL HEADER START
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see
+ * http://www.gnu.org/licenses/gpl-2.0.html
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Use is subject to license terms.
+ *
+ * Copyright (c) 2011, 2017, Intel Corporation.
+ *
+ * Author:
+ * Sonia Sharma <sonia.sharma@intel.com>
+ */
+
+
+#include <lnet/lib-lnet.h>
+#include <lnet/lnet-sysfs.h>
+
+struct kobject *lnet_kobj;
+EXPORT_SYMBOL_GPL(lnet_kobj);
+
+/*
+ * Helper functions for sysfs callbacks implementation
+ */
+ssize_t lnet_attr_show(struct kobject *kobj,
+ struct attribute *attr, char *buf)
+{
+ struct lnet_attr *a = container_of(attr, struct lnet_attr, attr);
+
+ return a->show ? a->show(kobj, attr, buf) : 0;
+}
+EXPORT_SYMBOL_GPL(lnet_attr_show);
+
+ssize_t lnet_attr_store(struct kobject *kobj, struct attribute *attr,
+ const char *buf, size_t len)
+{
+ struct lnet_attr *a = container_of(attr, struct lnet_attr, attr);
+
+ return a->store ? a->store(kobj, attr, buf, len) : len;
+}
+EXPORT_SYMBOL_GPL(lnet_attr_store);
+
+const struct sysfs_ops lnet_sysfs_ops = {
+ .show = lnet_attr_show,
+ .store = lnet_attr_store,
+};
+EXPORT_SYMBOL_GPL(lnet_sysfs_ops);
#define DEBUG_SUBSYSTEM S_LNET
#include <lnet/lib-lnet.h>
+#include <lnet/lnet-sysfs.h>
#include <uapi/linux/lnet/lnet-dlc.h>
static int config_on_load = 0;
mutex_init(&lnet_config_mutex);
+ /* Create sysfs base directories for LNet statistics */
+ lnet_kobj = kobject_create_and_add("lnet", fs_kobj);
+ if (!lnet_kobj) {
+ CERROR("Sysfs kobject for lnet could not be created\n");
+ RETURN(-ENOMEM);
+ }
+
rc = lnet_lib_init();
if (rc != 0) {
CERROR("lnet_lib_init: error %d\n", rc);
+ kobject_put(lnet_kobj);
RETURN(rc);
}
LASSERT(rc == 0);
lnet_lib_exit();
+
+ /* cleanup the base sysfs directories */
+ kobject_put(lnet_kobj);
}
MODULE_AUTHOR("OpenSFS, Inc. <http://www.lustre.org/>");