1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2003 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 /* 28 * This file implements the _init(9e), _info(9e) and _fini(9e) functions. 29 */ 30 31 #include <sys/ib/mgt/ibmf/ibmf_impl.h> 32 33 /* Module Info */ 34 static struct modlmisc ibmf_modlmisc = { 35 &mod_miscops, 36 "IB Agent Interfaces 2.0" 37 }; 38 39 /* Module linkage */ 40 static struct modlinkage ibmf_modlinkage = { 41 MODREV_1, 42 &ibmf_modlmisc, 43 NULL 44 }; 45 46 static ibmf_state_t ibmf_state; 47 ibmf_state_t *ibmf_statep; 48 49 extern int ibmf_init(); 50 extern int ibmf_fini(); 51 extern int ibmf_saa_impl_init(); 52 extern int ibmf_saa_impl_fini(); 53 54 int 55 _init() 56 { 57 int status; 58 59 /* CONSTCOND */ 60 ASSERT(NO_COMPETING_THREADS); 61 62 ibmf_statep = &ibmf_state; 63 64 /* 65 * call ibmf_saa_init first so it can set up subnet list before being 66 * contacted with ibt_async events 67 */ 68 status = ibmf_saa_impl_init(); 69 if (status != IBMF_SUCCESS) { 70 return (EACCES); 71 } 72 73 status = ibmf_init(); 74 if (status != 0) { 75 (void) ibmf_saa_impl_fini(); 76 77 return (EACCES); 78 } 79 80 status = mod_install(&ibmf_modlinkage); 81 if (status != 0) { 82 (void) ibmf_fini(); 83 ibmf_statep = NULL; 84 } 85 86 return (status); 87 } 88 89 int 90 _info(struct modinfo *modinfop) 91 { 92 return (mod_info(&ibmf_modlinkage, modinfop)); 93 } 94 95 int 96 _fini() 97 { 98 int status; 99 status = mod_remove(&ibmf_modlinkage); 100 if (status != 0) { 101 return (status); 102 } 103 104 status = ibmf_saa_impl_fini(); 105 if (status != 0) { 106 return (status); 107 } 108 109 (void) ibmf_fini(); 110 ibmf_statep = NULL; 111 return (status); 112 } 113