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, 2015, Intel Corporation.
29 * This file is part of Lustre, http://www.lustre.org/
32 #define DEBUG_SUBSYSTEM S_LNET
46 static int lst_init_step = LST_INIT_NONE;
48 struct workqueue_struct *lst_serial_wq;
49 struct workqueue_struct **lst_test_wq;
52 lnet_selftest_exit(void)
56 switch (lst_init_step) {
57 case LST_INIT_CONSOLE:
58 lstcon_console_fini();
66 case LST_INIT_WI_TEST:
68 i < cfs_cpt_number(lnet_cpt_table()); i++) {
71 destroy_workqueue(lst_test_wq[i]);
73 CFS_FREE_PTR_ARRAY(lst_test_wq,
74 cfs_cpt_number(lnet_cpt_table()));
77 case LST_INIT_WI_SERIAL:
78 destroy_workqueue(lst_serial_wq);
89 lnet_selftest_structure_assertion(void)
91 BUILD_BUG_ON(sizeof(struct srpc_msg) != 160);
92 BUILD_BUG_ON(sizeof(struct srpc_test_reqst) != 70);
93 BUILD_BUG_ON(offsetof(struct srpc_msg, msg_body.tes_reqst.tsr_concur) !=
95 BUILD_BUG_ON(offsetof(struct srpc_msg, msg_body.tes_reqst.tsr_ndest) !=
97 BUILD_BUG_ON(sizeof(struct srpc_stat_reply) != 136);
98 BUILD_BUG_ON(sizeof(struct srpc_stat_reqst) != 28);
102 lnet_selftest_init(void)
108 lst_serial_wq = alloc_ordered_workqueue("lst_s", 0);
109 if (!lst_serial_wq) {
110 CERROR("Failed to create serial WI scheduler for LST\n");
113 lst_init_step = LST_INIT_WI_SERIAL;
115 nscheds = cfs_cpt_number(lnet_cpt_table());
116 CFS_ALLOC_PTR_ARRAY(lst_test_wq, nscheds);
122 lst_init_step = LST_INIT_WI_TEST;
123 for (i = 0; i < nscheds; i++) {
124 int nthrs = cfs_cpt_weight(lnet_cpt_table(), i);
126 /* reserve at least one CPU for LND */
127 nthrs = max(nthrs - 1, 1);
128 lst_test_wq[i] = cfs_cpt_bind_workqueue("lst_t",
131 if (IS_ERR(lst_test_wq[i])) {
132 rc = PTR_ERR(lst_test_wq[i]);
133 CERROR("Failed to create CPU partition affinity WI scheduler %d for LST: rc = %d\n",
135 lst_test_wq[i] = NULL;
142 CERROR("LST can't startup rpc\n");
145 lst_init_step = LST_INIT_RPC;
149 CERROR("LST can't startup framework\n");
152 lst_init_step = LST_INIT_FW;
154 rc = lstcon_console_init();
156 CERROR("LST can't startup console\n");
159 lst_init_step = LST_INIT_CONSOLE;
162 lnet_selftest_exit();
166 MODULE_AUTHOR("OpenSFS, Inc. <http://www.lustre.org/>");
167 MODULE_DESCRIPTION("LNet Selftest");
168 MODULE_VERSION("2.8.0");
169 MODULE_LICENSE("GPL");
171 module_init(lnet_selftest_init);
172 module_exit(lnet_selftest_exit);