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.
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.
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]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
28 * This module provides the dacf functions to be called after a device
29 * of "ddi_network" node type has attached and before it detaches.
30 * Specifically, net_postattach() will be called during the post-attach
31 * process of each "ddi_network" device, and net_predetach() will be
32 * called during the pre-detach process of each device.
34 #include <sys/modctl.h>
35 #include <sys/sunddi.h>
38 #include <sys/softmac.h>
43 static int net_postattach(dacf_infohdl_t
, dacf_arghdl_t
, int);
44 static int net_predetach(dacf_infohdl_t
, dacf_arghdl_t
, int);
46 static dacf_op_t net_config_op
[] = {
47 { DACF_OPID_POSTATTACH
, net_postattach
},
48 { DACF_OPID_PREDETACH
, net_predetach
},
49 { DACF_OPID_END
, NULL
},
52 static dacf_opset_t opsets
[] = {
53 { "net_config", net_config_op
},
57 static struct dacfsw dacfsw
= {
62 static struct modldacf modldacf
= {
68 static struct modlinkage modlinkage
= {
69 MODREV_1
, &modldacf
, NULL
75 return (mod_install(&modlinkage
));
81 return (mod_remove(&modlinkage
));
85 _info(struct modinfo
*modinfop
)
87 return (mod_info(&modlinkage
, modinfop
));
91 * Post-attach routine invoked for DDI_NT_NET drivers by DACF framework
95 net_postattach(dacf_infohdl_t info_hdl
, dacf_arghdl_t arg_hdl
, int flags
)
101 dip
= dacf_devinfo_node(info_hdl
);
102 dev
= dacf_get_dev(info_hdl
);
104 if ((err
= softmac_create(dip
, dev
)) != 0) {
108 drvname
= ddi_driver_name(dip
);
109 ppa
= i_ddi_devi_get_ppa(dip
);
110 cmn_err(CE_WARN
, "net_postattach: cannot create softmac "
111 "for device %s%d (%d)", drvname
, ppa
, err
);
112 return (DACF_FAILURE
);
115 return (DACF_SUCCESS
);
119 * Pre-detach routine invoked for DDI_NT_NET drivers by DACF framework
123 net_predetach(dacf_infohdl_t info_hdl
, dacf_arghdl_t arg_hdl
, int flags
)
128 dip
= dacf_devinfo_node(info_hdl
);
129 dev
= dacf_get_dev(info_hdl
);
131 if (softmac_destroy(dip
, dev
) != 0)
132 return (DACF_FAILURE
);
134 return (DACF_SUCCESS
);