17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5d62bc4baSyz * Common Development and Distribution License (the "License").
6d62bc4baSyz * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate *
87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate * and limitations under the License.
127c478bd9Sstevel@tonic-gate *
137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate *
197c478bd9Sstevel@tonic-gate * CDDL HEADER END
207c478bd9Sstevel@tonic-gate */
217c478bd9Sstevel@tonic-gate /*
22d62bc4baSyz * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23d62bc4baSyz * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate */
257c478bd9Sstevel@tonic-gate
267c478bd9Sstevel@tonic-gate /*
277c478bd9Sstevel@tonic-gate * DACF (Device Autoconfiguration Framework) client code.
287c478bd9Sstevel@tonic-gate *
297c478bd9Sstevel@tonic-gate * DACF has two clients. the first is dacf modules which implement
307c478bd9Sstevel@tonic-gate * configuration operations; the second is the set of hooks in the kernel
317c478bd9Sstevel@tonic-gate * which do rule matching and invoke configuration operations.
327c478bd9Sstevel@tonic-gate *
337c478bd9Sstevel@tonic-gate * This file implements the second part, the kernel hooks.
347c478bd9Sstevel@tonic-gate *
357c478bd9Sstevel@tonic-gate * Currently implemented are post-attach and pre-detach handlers, and the hook
367c478bd9Sstevel@tonic-gate * for ddi_create_minor_common() which sets up post-attach and pre-detach
377c478bd9Sstevel@tonic-gate * reservations.
387c478bd9Sstevel@tonic-gate *
397c478bd9Sstevel@tonic-gate * This code depends on the core dacf code (in dacf.c) but the converse should
407c478bd9Sstevel@tonic-gate * never be true.
417c478bd9Sstevel@tonic-gate *
427c478bd9Sstevel@tonic-gate * This file also implements '__kernel', the kernel-supplied dacf module.
437c478bd9Sstevel@tonic-gate * For now, this is pretty much empty, except under DEBUG, in which case it
447c478bd9Sstevel@tonic-gate * contains some debugging code.
457c478bd9Sstevel@tonic-gate */
467c478bd9Sstevel@tonic-gate
477c478bd9Sstevel@tonic-gate #include <sys/param.h>
487c478bd9Sstevel@tonic-gate #include <sys/modctl.h>
497c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h>
507c478bd9Sstevel@tonic-gate #include <sys/kmem.h>
517c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h>
527c478bd9Sstevel@tonic-gate #include <sys/pathname.h>
537c478bd9Sstevel@tonic-gate #include <sys/ddi_impldefs.h>
547c478bd9Sstevel@tonic-gate #include <sys/sunddi.h>
557c478bd9Sstevel@tonic-gate #include <sys/autoconf.h>
567c478bd9Sstevel@tonic-gate #include <sys/modhash.h>
577c478bd9Sstevel@tonic-gate #include <sys/dacf_impl.h>
587c478bd9Sstevel@tonic-gate #include <sys/systm.h>
597c478bd9Sstevel@tonic-gate #include <sys/debug.h>
607c478bd9Sstevel@tonic-gate
617c478bd9Sstevel@tonic-gate /*
627c478bd9Sstevel@tonic-gate * dacfc_match_create_minor()
637c478bd9Sstevel@tonic-gate * Check to see if this minor node creation sequence matches a dacf
647c478bd9Sstevel@tonic-gate * (device autoconfiguration framework) rule. If so make a reservation
657c478bd9Sstevel@tonic-gate * for the operation to be invoked at post-attach and/or pre-detach time.
667c478bd9Sstevel@tonic-gate */
677c478bd9Sstevel@tonic-gate void
dacfc_match_create_minor(const char * name,const char * node_type,dev_info_t * dip,struct ddi_minor_data * dmdp,int flag)68*7bcaeddbSRobert Mustacchi dacfc_match_create_minor(const char *name, const char *node_type,
69*7bcaeddbSRobert Mustacchi dev_info_t *dip, struct ddi_minor_data *dmdp, int flag)
707c478bd9Sstevel@tonic-gate {
717c478bd9Sstevel@tonic-gate dacf_rule_t *r;
727c478bd9Sstevel@tonic-gate char *dev_path, *dev_pathp, *drv_mname = NULL;
737c478bd9Sstevel@tonic-gate dacf_rsrvlist_t *pa_rsrv, *pd_rsrv;
747c478bd9Sstevel@tonic-gate
75d62bc4baSyz /*
76d62bc4baSyz * Check the dacf rule for non-clone devices or for network devices.
77d62bc4baSyz */
78d62bc4baSyz if ((flag & CLONE_DEV) && (strcmp(node_type, DDI_NT_NET) != 0)) {
797c478bd9Sstevel@tonic-gate return;
807c478bd9Sstevel@tonic-gate }
817c478bd9Sstevel@tonic-gate
827c478bd9Sstevel@tonic-gate /*
837c478bd9Sstevel@tonic-gate * Because dacf currently only implements post-attach and pre-detach
847c478bd9Sstevel@tonic-gate * processing, we only care about minor nodes created during attach.
857c478bd9Sstevel@tonic-gate * However, there is no restriction on drivers about when to create
867c478bd9Sstevel@tonic-gate * minor nodes.
877c478bd9Sstevel@tonic-gate */
887c478bd9Sstevel@tonic-gate if (!DEVI_IS_ATTACHING(dmdp->dip)) {
897c478bd9Sstevel@tonic-gate return;
907c478bd9Sstevel@tonic-gate }
917c478bd9Sstevel@tonic-gate
927c478bd9Sstevel@tonic-gate dev_path = kmem_alloc(MAXPATHLEN, KM_SLEEP);
937c478bd9Sstevel@tonic-gate dev_pathp = ddi_pathname(dip, dev_path);
947c478bd9Sstevel@tonic-gate pa_rsrv = kmem_alloc(sizeof (dacf_rsrvlist_t), KM_SLEEP);
957c478bd9Sstevel@tonic-gate pd_rsrv = kmem_alloc(sizeof (dacf_rsrvlist_t), KM_SLEEP);
967c478bd9Sstevel@tonic-gate
977c478bd9Sstevel@tonic-gate if (name) {
987c478bd9Sstevel@tonic-gate const char *drv_name = ddi_driver_name(dip);
997c478bd9Sstevel@tonic-gate if (drv_name == NULL)
1007c478bd9Sstevel@tonic-gate drv_name = "???";
1017c478bd9Sstevel@tonic-gate drv_mname = kmem_alloc(MAXPATHLEN, KM_SLEEP);
1027c478bd9Sstevel@tonic-gate (void) snprintf(drv_mname, MAXPATHLEN, "%s:%s", drv_name, name);
1037c478bd9Sstevel@tonic-gate }
1047c478bd9Sstevel@tonic-gate
1057c478bd9Sstevel@tonic-gate mutex_enter(&dacf_lock);
1067c478bd9Sstevel@tonic-gate
1077c478bd9Sstevel@tonic-gate /*
1087c478bd9Sstevel@tonic-gate * Ensure that we don't wind up in a 'matching loop' against a devinfo
1097c478bd9Sstevel@tonic-gate * node, which could cause deadlock. This could happen as follows:
1107c478bd9Sstevel@tonic-gate *
1117c478bd9Sstevel@tonic-gate * We match (just below)
1127c478bd9Sstevel@tonic-gate * We invoke a task (later, at the end of devi_attach)
1137c478bd9Sstevel@tonic-gate * this means we have taken the per-devinfo lock
1147c478bd9Sstevel@tonic-gate * The task invoke winds up causing the same driver (that has
1157c478bd9Sstevel@tonic-gate * just finished attaching) to create another minor node.
1167c478bd9Sstevel@tonic-gate * We try to re-acquire the per-devinfo list lock again in the
1177c478bd9Sstevel@tonic-gate * process of making another reservation
1187c478bd9Sstevel@tonic-gate */
1197c478bd9Sstevel@tonic-gate mutex_enter(&(DEVI(dip)->devi_lock));
1207c478bd9Sstevel@tonic-gate if (DEVI_IS_INVOKING_DACF(dip)) {
1217c478bd9Sstevel@tonic-gate mutex_exit(&(DEVI(dip)->devi_lock));
1227c478bd9Sstevel@tonic-gate cmn_err(CE_WARN,
1237c478bd9Sstevel@tonic-gate "!dacf detected deadlock, aborting matching procedure\n");
1247c478bd9Sstevel@tonic-gate mutex_exit(&dacf_lock);
1257c478bd9Sstevel@tonic-gate kmem_free(pa_rsrv, sizeof (dacf_rsrvlist_t));
1267c478bd9Sstevel@tonic-gate kmem_free(pd_rsrv, sizeof (dacf_rsrvlist_t));
1277c478bd9Sstevel@tonic-gate kmem_free(dev_path, MAXPATHLEN);
1287c478bd9Sstevel@tonic-gate if (drv_mname) {
1297c478bd9Sstevel@tonic-gate kmem_free(drv_mname, MAXPATHLEN);
1307c478bd9Sstevel@tonic-gate }
1317c478bd9Sstevel@tonic-gate return;
1327c478bd9Sstevel@tonic-gate }
1337c478bd9Sstevel@tonic-gate mutex_exit(&(DEVI(dip)->devi_lock));
1347c478bd9Sstevel@tonic-gate
1357c478bd9Sstevel@tonic-gate /*
1367c478bd9Sstevel@tonic-gate * Do rule matching. It's possible to construct two rules that would
1377c478bd9Sstevel@tonic-gate * match against the same minor node, so we match from most to least
1387c478bd9Sstevel@tonic-gate * specific:
1397c478bd9Sstevel@tonic-gate * device path
1407c478bd9Sstevel@tonic-gate * minor node name (concatenation of drv_name:name
1417c478bd9Sstevel@tonic-gate * node type
1427c478bd9Sstevel@tonic-gate *
1437c478bd9Sstevel@tonic-gate * Future additions to the set of device-specifiers should be
1447c478bd9Sstevel@tonic-gate * sensitive to this ordering.
1457c478bd9Sstevel@tonic-gate */
1467c478bd9Sstevel@tonic-gate
1477c478bd9Sstevel@tonic-gate /*
1487c478bd9Sstevel@tonic-gate * post-attach matching
1497c478bd9Sstevel@tonic-gate */
1507c478bd9Sstevel@tonic-gate r = NULL;
1517c478bd9Sstevel@tonic-gate if (dev_pathp) {
1527c478bd9Sstevel@tonic-gate r = dacf_match(DACF_OPID_POSTATTACH, DACF_DS_DEV_PATH,
1537c478bd9Sstevel@tonic-gate dev_pathp);
1547c478bd9Sstevel@tonic-gate }
1557c478bd9Sstevel@tonic-gate if (!r && drv_mname) {
1567c478bd9Sstevel@tonic-gate r = dacf_match(DACF_OPID_POSTATTACH, DACF_DS_DRV_MNAME,
1577c478bd9Sstevel@tonic-gate drv_mname);
1587c478bd9Sstevel@tonic-gate }
1597c478bd9Sstevel@tonic-gate if (!r && node_type) {
1607c478bd9Sstevel@tonic-gate r = dacf_match(DACF_OPID_POSTATTACH, DACF_DS_MIN_NT, node_type);
1617c478bd9Sstevel@tonic-gate }
1627c478bd9Sstevel@tonic-gate if (r) {
1637c478bd9Sstevel@tonic-gate dacf_rsrv_make(pa_rsrv, r, dmdp, &(DEVI(dip)->devi_dacf_tasks));
1647c478bd9Sstevel@tonic-gate
1657c478bd9Sstevel@tonic-gate if (dacfdebug & DACF_DBG_MSGS)
1667c478bd9Sstevel@tonic-gate printf("dacf: made 'post-attach' reservation for "
1677c478bd9Sstevel@tonic-gate "%s, %s, %s\n", name, node_type, dev_pathp);
1687c478bd9Sstevel@tonic-gate } else {
1697c478bd9Sstevel@tonic-gate kmem_free(pa_rsrv, sizeof (dacf_rsrvlist_t));
1707c478bd9Sstevel@tonic-gate }
1717c478bd9Sstevel@tonic-gate
1727c478bd9Sstevel@tonic-gate /*
1737c478bd9Sstevel@tonic-gate * pre-detach matching
1747c478bd9Sstevel@tonic-gate */
1757c478bd9Sstevel@tonic-gate r = NULL;
1767c478bd9Sstevel@tonic-gate if (dev_pathp) {
1777c478bd9Sstevel@tonic-gate r = dacf_match(DACF_OPID_PREDETACH, DACF_DS_DEV_PATH,
1787c478bd9Sstevel@tonic-gate dev_pathp);
1797c478bd9Sstevel@tonic-gate }
1807c478bd9Sstevel@tonic-gate if (!r && drv_mname) {
1817c478bd9Sstevel@tonic-gate r = dacf_match(DACF_OPID_PREDETACH, DACF_DS_DRV_MNAME,
1827c478bd9Sstevel@tonic-gate drv_mname);
1837c478bd9Sstevel@tonic-gate }
1847c478bd9Sstevel@tonic-gate if (!r && node_type) {
1857c478bd9Sstevel@tonic-gate r = dacf_match(DACF_OPID_PREDETACH, DACF_DS_MIN_NT, node_type);
1867c478bd9Sstevel@tonic-gate }
1877c478bd9Sstevel@tonic-gate if (r) {
1887c478bd9Sstevel@tonic-gate dacf_rsrv_make(pd_rsrv, r, dmdp, &(DEVI(dip)->devi_dacf_tasks));
1897c478bd9Sstevel@tonic-gate
1907c478bd9Sstevel@tonic-gate if (dacfdebug & DACF_DBG_MSGS) {
1917c478bd9Sstevel@tonic-gate printf("dacf: made 'pre-detach' reservation for "
1927c478bd9Sstevel@tonic-gate "%s, %s, %s\n", name, node_type, dev_pathp);
1937c478bd9Sstevel@tonic-gate }
1947c478bd9Sstevel@tonic-gate } else {
1957c478bd9Sstevel@tonic-gate kmem_free(pd_rsrv, sizeof (dacf_rsrvlist_t));
1967c478bd9Sstevel@tonic-gate }
1977c478bd9Sstevel@tonic-gate
1987c478bd9Sstevel@tonic-gate mutex_exit(&dacf_lock);
1997c478bd9Sstevel@tonic-gate kmem_free(dev_path, MAXPATHLEN);
2007c478bd9Sstevel@tonic-gate if (drv_mname) {
2017c478bd9Sstevel@tonic-gate kmem_free(drv_mname, MAXPATHLEN);
2027c478bd9Sstevel@tonic-gate }
2037c478bd9Sstevel@tonic-gate }
2047c478bd9Sstevel@tonic-gate
2057c478bd9Sstevel@tonic-gate /*
2067c478bd9Sstevel@tonic-gate * dacfc_postattach()
2077c478bd9Sstevel@tonic-gate * autoconfiguration for post-attach events.
2087c478bd9Sstevel@tonic-gate *
2097c478bd9Sstevel@tonic-gate * strategy: try to configure. If some of the configuration operations
2107c478bd9Sstevel@tonic-gate * fail, emit a warning.
2117c478bd9Sstevel@tonic-gate */
2127c478bd9Sstevel@tonic-gate int
dacfc_postattach(dev_info_t * devi)2137c478bd9Sstevel@tonic-gate dacfc_postattach(dev_info_t *devi)
2147c478bd9Sstevel@tonic-gate {
2157c478bd9Sstevel@tonic-gate int err = DACF_SUCCESS;
2167c478bd9Sstevel@tonic-gate char *path, *pathp;
2177c478bd9Sstevel@tonic-gate dacf_rsrvlist_t **opsp, *op;
2187c478bd9Sstevel@tonic-gate ASSERT(MUTEX_HELD(&dacf_lock));
2197c478bd9Sstevel@tonic-gate
2207c478bd9Sstevel@tonic-gate /*
2217c478bd9Sstevel@tonic-gate * Instruct dacf_process_rsrvs() to invoke each POSTATTACH op.
2227c478bd9Sstevel@tonic-gate */
2237c478bd9Sstevel@tonic-gate opsp = &DEVI(devi)->devi_dacf_tasks;
2247c478bd9Sstevel@tonic-gate dacf_process_rsrvs(opsp, DACF_OPID_POSTATTACH, DACF_PROC_INVOKE);
2257c478bd9Sstevel@tonic-gate
2267c478bd9Sstevel@tonic-gate /*
2277c478bd9Sstevel@tonic-gate * Check to see that all POSTATTACH's succeeded.
2287c478bd9Sstevel@tonic-gate */
2297c478bd9Sstevel@tonic-gate for (op = *opsp; op != NULL; op = op->rsrv_next) {
2307c478bd9Sstevel@tonic-gate if (op->rsrv_rule->r_opid != DACF_OPID_POSTATTACH)
2317c478bd9Sstevel@tonic-gate continue;
2327c478bd9Sstevel@tonic-gate if (op->rsrv_result == DACF_SUCCESS)
2337c478bd9Sstevel@tonic-gate continue;
2347c478bd9Sstevel@tonic-gate if (dacfdebug & DACF_DBG_DEVI) {
2357c478bd9Sstevel@tonic-gate cmn_err(CE_WARN, "op failed, err = %d\n",
2367c478bd9Sstevel@tonic-gate op->rsrv_result);
2377c478bd9Sstevel@tonic-gate }
2387c478bd9Sstevel@tonic-gate err = DACF_FAILURE;
2397c478bd9Sstevel@tonic-gate break;
2407c478bd9Sstevel@tonic-gate }
2417c478bd9Sstevel@tonic-gate
2427c478bd9Sstevel@tonic-gate /*
2437c478bd9Sstevel@tonic-gate * If one or more postattach's failed, give up.
2447c478bd9Sstevel@tonic-gate */
2457c478bd9Sstevel@tonic-gate if ((err == DACF_FAILURE) && (dacfdebug & DACF_DBG_DEVI)) {
2467c478bd9Sstevel@tonic-gate path = kmem_alloc(MAXPATHLEN, KM_SLEEP);
2477c478bd9Sstevel@tonic-gate if ((pathp = ddi_pathname(devi, path)) == NULL)
2487c478bd9Sstevel@tonic-gate pathp = "<unknown>";
2497c478bd9Sstevel@tonic-gate cmn_err(CE_WARN, "%s attached, but failed to auto-configure",
2507c478bd9Sstevel@tonic-gate pathp);
2517c478bd9Sstevel@tonic-gate kmem_free(path, MAXPATHLEN);
2527c478bd9Sstevel@tonic-gate }
2537c478bd9Sstevel@tonic-gate
2547c478bd9Sstevel@tonic-gate return (err);
2557c478bd9Sstevel@tonic-gate }
2567c478bd9Sstevel@tonic-gate
2577c478bd9Sstevel@tonic-gate /*
2587c478bd9Sstevel@tonic-gate * dacfc_predetach()
2597c478bd9Sstevel@tonic-gate * auto-unconfiguration for pre-detach events.
2607c478bd9Sstevel@tonic-gate *
2617c478bd9Sstevel@tonic-gate * strategy: call the pre-detach operation for all matching reservations.
2627c478bd9Sstevel@tonic-gate * If any of these fail, make (one) attempt to reconfigure things back
2637c478bd9Sstevel@tonic-gate * into a sane state. if that fails, our state is uncertain.
2647c478bd9Sstevel@tonic-gate */
2657c478bd9Sstevel@tonic-gate int
dacfc_predetach(dev_info_t * devi)2667c478bd9Sstevel@tonic-gate dacfc_predetach(dev_info_t *devi)
2677c478bd9Sstevel@tonic-gate {
2687c478bd9Sstevel@tonic-gate int err = DDI_SUCCESS;
2697c478bd9Sstevel@tonic-gate char *path, *pathp;
2707c478bd9Sstevel@tonic-gate dacf_rsrvlist_t **opsp, *op;
2717c478bd9Sstevel@tonic-gate ASSERT(MUTEX_HELD(&dacf_lock));
2727c478bd9Sstevel@tonic-gate
2737c478bd9Sstevel@tonic-gate /*
2747c478bd9Sstevel@tonic-gate * Instruct dacf_process_rsrvs() to invoke each PREDETACH op.
2757c478bd9Sstevel@tonic-gate */
2767c478bd9Sstevel@tonic-gate opsp = &DEVI(devi)->devi_dacf_tasks;
2777c478bd9Sstevel@tonic-gate dacf_process_rsrvs(opsp, DACF_OPID_PREDETACH, DACF_PROC_INVOKE);
2787c478bd9Sstevel@tonic-gate
2797c478bd9Sstevel@tonic-gate /*
2807c478bd9Sstevel@tonic-gate * Check to see that all PREDETACH's succeeded.
2817c478bd9Sstevel@tonic-gate */
2827c478bd9Sstevel@tonic-gate for (op = *opsp; op != NULL; op = op->rsrv_next) {
2837c478bd9Sstevel@tonic-gate if (op->rsrv_rule->r_opid != DACF_OPID_PREDETACH)
2847c478bd9Sstevel@tonic-gate continue;
2857c478bd9Sstevel@tonic-gate if (op->rsrv_result == 0)
2867c478bd9Sstevel@tonic-gate continue;
2877c478bd9Sstevel@tonic-gate err = DDI_FAILURE;
2887c478bd9Sstevel@tonic-gate break;
2897c478bd9Sstevel@tonic-gate }
2907c478bd9Sstevel@tonic-gate
2917c478bd9Sstevel@tonic-gate /*
2927c478bd9Sstevel@tonic-gate * If one or more predetach's failed, make one attempt to fix things
2937c478bd9Sstevel@tonic-gate * by re-running all of the POST-ATTACH operations. If any of those
2947c478bd9Sstevel@tonic-gate * fail, give up.
2957c478bd9Sstevel@tonic-gate */
2967c478bd9Sstevel@tonic-gate if (err == DDI_FAILURE) {
2977c478bd9Sstevel@tonic-gate int pa_err;
2987c478bd9Sstevel@tonic-gate
2997c478bd9Sstevel@tonic-gate if (dacfdebug & DACF_DBG_DEVI) {
3007c478bd9Sstevel@tonic-gate path = kmem_alloc(MAXPATHLEN, KM_SLEEP);
3017c478bd9Sstevel@tonic-gate if ((pathp = ddi_pathname(devi, path)) == NULL)
3027c478bd9Sstevel@tonic-gate pathp = "<unknown>";
3037c478bd9Sstevel@tonic-gate cmn_err(CE_WARN, "%s failed to auto-unconfigure, "
3047c478bd9Sstevel@tonic-gate "attempting to reconfigure...", pathp);
3057c478bd9Sstevel@tonic-gate kmem_free(path, MAXPATHLEN);
3067c478bd9Sstevel@tonic-gate }
3077c478bd9Sstevel@tonic-gate
3087c478bd9Sstevel@tonic-gate pa_err = dacfc_postattach(devi);
3097c478bd9Sstevel@tonic-gate
3107c478bd9Sstevel@tonic-gate if (dacfdebug & DACF_DBG_DEVI) {
3117c478bd9Sstevel@tonic-gate path = kmem_alloc(MAXPATHLEN, KM_SLEEP);
3127c478bd9Sstevel@tonic-gate if ((pathp = ddi_pathname(devi, path)) == NULL)
3137c478bd9Sstevel@tonic-gate pathp = "<unknown>";
3147c478bd9Sstevel@tonic-gate
3157c478bd9Sstevel@tonic-gate if (pa_err == DDI_FAILURE) {
3167c478bd9Sstevel@tonic-gate cmn_err(CE_WARN, "%s failed to "
3177c478bd9Sstevel@tonic-gate "auto-unconfigure, and could not be "
3187c478bd9Sstevel@tonic-gate "re-autoconfigured.", pathp);
3197c478bd9Sstevel@tonic-gate } else {
3207c478bd9Sstevel@tonic-gate cmn_err(CE_WARN, "%s failed to "
3217c478bd9Sstevel@tonic-gate "auto-unconfigure, but was successfully "
3227c478bd9Sstevel@tonic-gate "re-autoconfigured.", pathp);
3237c478bd9Sstevel@tonic-gate }
3247c478bd9Sstevel@tonic-gate kmem_free(path, MAXPATHLEN);
3257c478bd9Sstevel@tonic-gate }
3267c478bd9Sstevel@tonic-gate }
3277c478bd9Sstevel@tonic-gate
3287c478bd9Sstevel@tonic-gate return (err);
3297c478bd9Sstevel@tonic-gate }
3307c478bd9Sstevel@tonic-gate
3317c478bd9Sstevel@tonic-gate /*
3327c478bd9Sstevel@tonic-gate * kmod_dacfsw:
3337c478bd9Sstevel@tonic-gate * This is the declaration for the kernel-supplied '__kernel' dacf module.
3347c478bd9Sstevel@tonic-gate * DACF supplies a framework based around loadable modules. However, it
3357c478bd9Sstevel@tonic-gate * may be convenient (in the future) to have a module provided by the
3367c478bd9Sstevel@tonic-gate * kernel. This is useful in cases when a module can't be loaded (early in
3377c478bd9Sstevel@tonic-gate * boot), or for code that would never get unloaded anyway.
3387c478bd9Sstevel@tonic-gate */
3397c478bd9Sstevel@tonic-gate #ifdef DEBUG
3407c478bd9Sstevel@tonic-gate /*ARGSUSED*/
3417c478bd9Sstevel@tonic-gate static int
kmod_test_postattach(dacf_infohdl_t info_hdl,dacf_arghdl_t arg_hdl,int flags)3427c478bd9Sstevel@tonic-gate kmod_test_postattach(dacf_infohdl_t info_hdl, dacf_arghdl_t arg_hdl, int flags)
3437c478bd9Sstevel@tonic-gate {
3447c478bd9Sstevel@tonic-gate const char *verbose = dacf_get_arg(arg_hdl, "verbose");
3457c478bd9Sstevel@tonic-gate if (verbose && (strcmp(verbose, "true") == 0)) {
3467c478bd9Sstevel@tonic-gate cmn_err(CE_WARN, "got kmod_test_postattach\n");
3477c478bd9Sstevel@tonic-gate }
3487c478bd9Sstevel@tonic-gate return (0);
3497c478bd9Sstevel@tonic-gate }
3507c478bd9Sstevel@tonic-gate #endif
3517c478bd9Sstevel@tonic-gate
3527c478bd9Sstevel@tonic-gate static dacf_op_t kmod_op_test[] = {
3537c478bd9Sstevel@tonic-gate #ifdef DEBUG
3547c478bd9Sstevel@tonic-gate { DACF_OPID_POSTATTACH, kmod_test_postattach },
3557c478bd9Sstevel@tonic-gate #endif
3567c478bd9Sstevel@tonic-gate { DACF_OPID_END, NULL },
3577c478bd9Sstevel@tonic-gate };
3587c478bd9Sstevel@tonic-gate
3597c478bd9Sstevel@tonic-gate static dacf_opset_t kmod_opsets[] = {
3607c478bd9Sstevel@tonic-gate #ifdef DEBUG
3617c478bd9Sstevel@tonic-gate { "kmod_test", kmod_op_test },
3627c478bd9Sstevel@tonic-gate #endif
3637c478bd9Sstevel@tonic-gate { NULL, NULL },
3647c478bd9Sstevel@tonic-gate };
3657c478bd9Sstevel@tonic-gate
3667c478bd9Sstevel@tonic-gate struct dacfsw kmod_dacfsw = {
3677c478bd9Sstevel@tonic-gate DACF_MODREV_1, kmod_opsets
3687c478bd9Sstevel@tonic-gate };
369