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 2005 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #pragma ident "%Z%%M% %I% %E% SMI" 28 29 /* 30 * Data-Link Services Module 31 */ 32 33 #include <sys/types.h> 34 #include <sys/modctl.h> 35 #include <sys/ght.h> 36 #include <sys/mac.h> 37 38 #include <sys/dls.h> 39 #include <sys/dls_impl.h> 40 41 static struct modlmisc i_dls_modlmisc = { 42 &mod_miscops, 43 DLS_INFO 44 }; 45 46 static struct modlinkage i_dls_modlinkage = { 47 MODREV_1, 48 &i_dls_modlmisc, 49 NULL 50 }; 51 52 /* 53 * Module initialization functions. 54 */ 55 56 static void 57 i_dls_mod_init(void) 58 { 59 dls_init(); 60 dls_vlan_init(); 61 dls_link_init(); 62 } 63 64 static int 65 i_dls_mod_fini(void) 66 { 67 int err; 68 69 if ((err = dls_link_fini()) != 0) 70 return (err); 71 72 err = dls_vlan_fini(); 73 ASSERT(err == 0); 74 75 err = dls_fini(); 76 ASSERT(err == 0); 77 78 return (0); 79 } 80 81 /* 82 * modlinkage functions. 83 */ 84 85 int 86 _init(void) 87 { 88 int err; 89 90 i_dls_mod_init(); 91 92 if ((err = mod_install(&i_dls_modlinkage)) != 0) { 93 (void) i_dls_mod_fini(); 94 return (err); 95 } 96 97 #ifdef DEBUG 98 cmn_err(CE_NOTE, "!%s loaded", DLS_INFO); 99 #endif /* DEBUG */ 100 101 return (0); 102 } 103 104 int 105 _fini(void) 106 { 107 int err; 108 109 if ((err = i_dls_mod_fini()) != 0) 110 return (err); 111 112 if ((err = mod_remove(&i_dls_modlinkage)) != 0) 113 return (err); 114 115 #ifdef DEBUG 116 cmn_err(CE_NOTE, "!%s unloaded", DLS_INFO); 117 #endif /* DEBUG */ 118 119 return (0); 120 } 121 122 int 123 _info(struct modinfo *modinfop) 124 { 125 return (mod_info(&i_dls_modlinkage, modinfop)); 126 } 127