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 (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 /*
  27  * Data-Link Services Module
  28  */
  29 
  30 #include        <sys/modctl.h>
  31 #include        <sys/dld_impl.h>
  32 
  33 static struct modlmisc          i_dls_modlmisc = {
  34         &mod_miscops,
  35         DLS_INFO
  36 };
  37 
  38 static struct modlinkage        i_dls_modlinkage = {
  39         MODREV_1,
  40         { &i_dls_modlmisc, NULL }
  41 };
  42 
  43 /*
  44  * Module initialization functions.
  45  */
  46 
  47 static void
  48 i_dls_mod_init(void)
  49 {
  50         dls_link_init();
  51         dls_mgmt_init();
  52 }
  53 
  54 static int
  55 i_dls_mod_fini(void)
  56 {
  57         int     err;
  58 
  59         if ((err = dls_link_fini()) != 0)
  60                 return (err);
  61 
  62         dls_mgmt_fini();
  63         return (0);
  64 }
  65 
  66 /*
  67  * modlinkage functions.
  68  */
  69 
  70 int
  71 _init(void)
  72 {
  73         int     err;
  74 
  75         i_dls_mod_init();
  76 
  77         if ((err = mod_install(&i_dls_modlinkage)) != 0) {
  78                 (void) i_dls_mod_fini();
  79                 return (err);
  80         }
  81 
  82 #ifdef  DEBUG
  83         cmn_err(CE_NOTE, "!%s loaded", DLS_INFO);
  84 #endif  /* DEBUG */
  85 
  86         return (0);
  87 }
  88 
  89 int
  90 _fini(void)
  91 {
  92         int     err;
  93 
  94         if ((err = i_dls_mod_fini()) != 0)
  95                 return (err);
  96 
  97         if ((err = mod_remove(&i_dls_modlinkage)) != 0)
  98                 return (err);
  99 
 100 #ifdef  DEBUG
 101         cmn_err(CE_NOTE, "!%s unloaded", DLS_INFO);
 102 #endif  /* DEBUG */
 103 
 104         return (0);
 105 }
 106 
 107 int
 108 _info(struct modinfo *modinfop)
 109 {
 110         return (mod_info(&i_dls_modlinkage, modinfop));
 111 }