4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.gnu.org/licenses/gpl-2.0.html
23 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
26 * Copyright (c) 2012, Intel Corporation.
29 * This file is part of Lustre, http://www.lustre.org/
30 * Lustre is a trademark of Sun Microsystems, Inc.
33 #define DEBUG_SUBSYSTEM S_LNET
47 static int lst_init_step = LST_INIT_NONE;
49 struct cfs_wi_sched *lst_sched_serial;
50 struct cfs_wi_sched **lst_sched_test;
53 lnet_selftest_exit(void)
57 switch (lst_init_step) {
58 case LST_INIT_CONSOLE:
59 lstcon_console_fini();
64 case LST_INIT_WI_TEST:
66 i < cfs_cpt_number(lnet_cpt_table()); i++) {
67 if (!lst_sched_test[i])
69 cfs_wi_sched_destroy(lst_sched_test[i]);
71 LIBCFS_FREE(lst_sched_test,
72 sizeof(lst_sched_test[0]) *
73 cfs_cpt_number(lnet_cpt_table()));
74 lst_sched_test = NULL;
76 case LST_INIT_WI_SERIAL:
77 cfs_wi_sched_destroy(lst_sched_serial);
78 lst_sched_serial = NULL;
87 lnet_selftest_init(void)
93 rc = cfs_wi_sched_create("lst_s", lnet_cpt_table(), CFS_CPT_ANY,
94 1, &lst_sched_serial);
96 CERROR("Failed to create serial WI scheduler for LST\n");
99 lst_init_step = LST_INIT_WI_SERIAL;
101 nscheds = cfs_cpt_number(lnet_cpt_table());
102 LIBCFS_ALLOC(lst_sched_test, sizeof(lst_sched_test[0]) * nscheds);
106 lst_init_step = LST_INIT_WI_TEST;
107 for (i = 0; i < nscheds; i++) {
108 int nthrs = cfs_cpt_weight(lnet_cpt_table(), i);
110 /* reserve at least one CPU for LND */
111 nthrs = max(nthrs - 1, 1);
112 rc = cfs_wi_sched_create("lst_t", lnet_cpt_table(), i,
113 nthrs, &lst_sched_test[i]);
115 CERROR("Failed to create CPT affinity WI scheduler %d for LST\n", i);
122 CERROR("LST can't startup rpc\n");
125 lst_init_step = LST_INIT_RPC;
129 CERROR("LST can't startup framework\n");
132 lst_init_step = LST_INIT_FW;
134 rc = lstcon_console_init();
136 CERROR("LST can't startup console\n");
139 lst_init_step = LST_INIT_CONSOLE;
142 lnet_selftest_exit();
146 MODULE_AUTHOR("OpenSFS, Inc. <http://www.lustre.org/>");
147 MODULE_DESCRIPTION("LNet Selftest");
148 MODULE_VERSION("2.7.0");
149 MODULE_LICENSE("GPL");
151 module_init(lnet_selftest_init);
152 module_exit(lnet_selftest_exit);