10Sstevel@tonic-gate /*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
55895Syz147064 * Common Development and Distribution License (the "License").
65895Syz147064 * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
210Sstevel@tonic-gate /*
225895Syz147064 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
230Sstevel@tonic-gate * Use is subject to license terms.
240Sstevel@tonic-gate */
250Sstevel@tonic-gate
260Sstevel@tonic-gate /*
270Sstevel@tonic-gate * Data-Link Services Module
280Sstevel@tonic-gate */
290Sstevel@tonic-gate
300Sstevel@tonic-gate #include <sys/modctl.h>
31*8275SEric Cheng #include <sys/dld_impl.h>
320Sstevel@tonic-gate
330Sstevel@tonic-gate static struct modlmisc i_dls_modlmisc = {
340Sstevel@tonic-gate &mod_miscops,
350Sstevel@tonic-gate DLS_INFO
360Sstevel@tonic-gate };
370Sstevel@tonic-gate
380Sstevel@tonic-gate static struct modlinkage i_dls_modlinkage = {
390Sstevel@tonic-gate MODREV_1,
400Sstevel@tonic-gate &i_dls_modlmisc,
410Sstevel@tonic-gate NULL
420Sstevel@tonic-gate };
430Sstevel@tonic-gate
440Sstevel@tonic-gate /*
450Sstevel@tonic-gate * Module initialization functions.
460Sstevel@tonic-gate */
470Sstevel@tonic-gate
480Sstevel@tonic-gate static void
i_dls_mod_init(void)490Sstevel@tonic-gate i_dls_mod_init(void)
500Sstevel@tonic-gate {
510Sstevel@tonic-gate dls_link_init();
525895Syz147064 dls_mgmt_init();
530Sstevel@tonic-gate }
540Sstevel@tonic-gate
550Sstevel@tonic-gate static int
i_dls_mod_fini(void)560Sstevel@tonic-gate i_dls_mod_fini(void)
570Sstevel@tonic-gate {
580Sstevel@tonic-gate int err;
590Sstevel@tonic-gate
600Sstevel@tonic-gate if ((err = dls_link_fini()) != 0)
610Sstevel@tonic-gate return (err);
620Sstevel@tonic-gate
635895Syz147064 dls_mgmt_fini();
640Sstevel@tonic-gate return (0);
650Sstevel@tonic-gate }
660Sstevel@tonic-gate
670Sstevel@tonic-gate /*
680Sstevel@tonic-gate * modlinkage functions.
690Sstevel@tonic-gate */
700Sstevel@tonic-gate
710Sstevel@tonic-gate int
_init(void)720Sstevel@tonic-gate _init(void)
730Sstevel@tonic-gate {
740Sstevel@tonic-gate int err;
750Sstevel@tonic-gate
760Sstevel@tonic-gate i_dls_mod_init();
770Sstevel@tonic-gate
780Sstevel@tonic-gate if ((err = mod_install(&i_dls_modlinkage)) != 0) {
790Sstevel@tonic-gate (void) i_dls_mod_fini();
800Sstevel@tonic-gate return (err);
810Sstevel@tonic-gate }
820Sstevel@tonic-gate
830Sstevel@tonic-gate #ifdef DEBUG
840Sstevel@tonic-gate cmn_err(CE_NOTE, "!%s loaded", DLS_INFO);
850Sstevel@tonic-gate #endif /* DEBUG */
860Sstevel@tonic-gate
870Sstevel@tonic-gate return (0);
880Sstevel@tonic-gate }
890Sstevel@tonic-gate
900Sstevel@tonic-gate int
_fini(void)910Sstevel@tonic-gate _fini(void)
920Sstevel@tonic-gate {
930Sstevel@tonic-gate int err;
940Sstevel@tonic-gate
950Sstevel@tonic-gate if ((err = i_dls_mod_fini()) != 0)
960Sstevel@tonic-gate return (err);
970Sstevel@tonic-gate
980Sstevel@tonic-gate if ((err = mod_remove(&i_dls_modlinkage)) != 0)
990Sstevel@tonic-gate return (err);
1000Sstevel@tonic-gate
1010Sstevel@tonic-gate #ifdef DEBUG
1020Sstevel@tonic-gate cmn_err(CE_NOTE, "!%s unloaded", DLS_INFO);
1030Sstevel@tonic-gate #endif /* DEBUG */
1040Sstevel@tonic-gate
1050Sstevel@tonic-gate return (0);
1060Sstevel@tonic-gate }
1070Sstevel@tonic-gate
1080Sstevel@tonic-gate int
_info(struct modinfo * modinfop)1090Sstevel@tonic-gate _info(struct modinfo *modinfop)
1100Sstevel@tonic-gate {
1110Sstevel@tonic-gate return (mod_info(&i_dls_modlinkage, modinfop));
1120Sstevel@tonic-gate }
113