summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/sys
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/uts/common/sys')
-rw-r--r--usr/src/uts/common/sys/Makefile4
-rw-r--r--usr/src/uts/common/sys/autoconf.h24
-rw-r--r--usr/src/uts/common/sys/contract.h8
-rw-r--r--usr/src/uts/common/sys/contract/device.h76
-rw-r--r--usr/src/uts/common/sys/contract/device_impl.h93
-rw-r--r--usr/src/uts/common/sys/contract_impl.h50
-rw-r--r--usr/src/uts/common/sys/ctfs.h8
-rw-r--r--usr/src/uts/common/sys/ddi_impldefs.h24
-rw-r--r--usr/src/uts/common/sys/ddi_implfuncs.h11
-rw-r--r--usr/src/uts/common/sys/ddi_obsolete.h12
-rw-r--r--usr/src/uts/common/sys/fs/snode.h9
-rw-r--r--usr/src/uts/common/sys/modctl.h6
-rw-r--r--usr/src/uts/common/sys/sunldi.h48
-rw-r--r--usr/src/uts/common/sys/sunldi_impl.h52
-rw-r--r--usr/src/uts/common/sys/sunmdi.h10
15 files changed, 398 insertions, 37 deletions
diff --git a/usr/src/uts/common/sys/Makefile b/usr/src/uts/common/sys/Makefile
index 2c4defc38d..b4591f05d9 100644
--- a/usr/src/uts/common/sys/Makefile
+++ b/usr/src/uts/common/sys/Makefile
@@ -845,7 +845,9 @@ SYSEVENTHDRS= \
CONTRACTHDRS= \
process.h \
- process_impl.h
+ process_impl.h \
+ device.h \
+ device_impl.h
USBHDRS= \
usba.h \
diff --git a/usr/src/uts/common/sys/autoconf.h b/usr/src/uts/common/sys/autoconf.h
index 3b10e97c89..e7fbd33267 100644
--- a/usr/src/uts/common/sys/autoconf.h
+++ b/usr/src/uts/common/sys/autoconf.h
@@ -104,6 +104,11 @@ struct devnames {
#define DDI_INTR_API 0x0200 /* interrupt interface messages */
#define DDI_INTR_IMPL 0x0400 /* interrupt implementation msgs */
#define DDI_INTR_NEXUS 0x0800 /* interrupt messages from nexuses */
+#define DDI_DBG_RETIRE 0x1000 /* Retire related messages */
+#define DDI_DBG_RTR_VRBOSE 0x2000 /* Verbose Retire messages */
+#define DDI_DBG_RTR_TRACE 0x4000 /* Trace Retire messages */
+#define LDI_EV_DEBUG 0x8000 /* LDI events debug messages */
+#define LDI_EV_TRACE 0x10000 /* LDI events trace messages */
extern int ddidebug;
@@ -118,6 +123,11 @@ extern int ddidebug;
#define DDI_INTR_APIDBG(args) if (ddidebug & DDI_INTR_API) cmn_err args
#define DDI_INTR_IMPLDBG(args) if (ddidebug & DDI_INTR_IMPL) cmn_err args
#define DDI_INTR_NEXDBG(args) if (ddidebug & DDI_INTR_NEXUS) cmn_err args
+#define RIO_DEBUG(args) if (ddidebug & DDI_DBG_RETIRE) cmn_err args
+#define RIO_VERBOSE(args) if (ddidebug & DDI_DBG_RTR_VRBOSE) cmn_err args
+#define RIO_TRACE(args) if (ddidebug & DDI_DBG_RTR_TRACE) cmn_err args
+#define LDI_EVDBG(args) if (ddidebug & LDI_EV_DEBUG) cmn_err args
+#define LDI_EVTRC(args) if (ddidebug & LDI_EV_TRACE) cmn_err args
#else
#define NDI_CONFIG_DEBUG(args)
#define BMDPRINTF(args)
@@ -129,6 +139,11 @@ extern int ddidebug;
#define DDI_INTR_APIDBG(args)
#define DDI_INTR_IMPLDBG(args)
#define DDI_INTR_NEXDBG(args)
+#define RIO_DEBUG(args) if (ddidebug & DDI_DBG_RETIRE) cmn_err args
+#define RIO_VERBOSE(args) if (ddidebug & DDI_DBG_RTR_VRBOSE) cmn_err args
+#define RIO_TRACE(args) if (ddidebug & DDI_DBG_RTR_TRACE) cmn_err args
+#define LDI_EVDBG(args) if (ddidebug & LDI_EV_DEBUG) cmn_err args
+#define LDI_EVTRC(args) if (ddidebug & LDI_EV_TRACE) cmn_err args
#endif
@@ -256,6 +271,15 @@ extern int i_ddi_reconfig(void);
extern void i_ddi_set_sysavail(void);
extern void i_ddi_set_reconfig(void);
+/* I/O retire related */
+extern int e_ddi_retire_device(char *path, char **cons_array);
+extern int e_ddi_unretire_device(char *path);
+extern int e_ddi_mark_retiring(dev_info_t *dip, void *arg);
+extern int e_ddi_retire_notify(dev_info_t *dip, void *arg);
+extern int e_ddi_retire_finalize(dev_info_t *dip, void *arg);
+extern void e_ddi_degrade_finalize(dev_info_t *dip);
+extern void e_ddi_undegrade_finalize(dev_info_t *dip);
+
#endif /* _KERNEL */
#ifdef __cplusplus
diff --git a/usr/src/uts/common/sys/contract.h b/usr/src/uts/common/sys/contract.h
index 163f90cbfa..0bef407b98 100644
--- a/usr/src/uts/common/sys/contract.h
+++ b/usr/src/uts/common/sys/contract.h
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -72,6 +71,7 @@ typedef enum ctstate {
typedef enum ct_typeid {
CTT_PROCESS, /* process contract */
+ CTT_DEVICE, /* device contract */
CTT_MAXTYPE
} ct_typeid_t;
diff --git a/usr/src/uts/common/sys/contract/device.h b/usr/src/uts/common/sys/contract/device.h
new file mode 100644
index 0000000000..252cce3165
--- /dev/null
+++ b/usr/src/uts/common/sys/contract/device.h
@@ -0,0 +1,76 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _SYS_CONTRACT_DEVICE_H
+#define _SYS_CONTRACT_DEVICE_H
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/contract.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct ctmpl_device ctmpl_device_t;
+typedef struct cont_device cont_device_t;
+
+/*
+ * ct_ev_* flags
+ */
+#define CT_DEV_EV_ONLINE 0x1 /* device is moving to online state */
+#define CT_DEV_EV_DEGRADED 0x2 /* device is moving to degraded state */
+#define CT_DEV_EV_OFFLINE 0x4 /* device is moving to offline state */
+#define CT_DEV_ALLEVENT 0x7
+
+/*
+ * ctp_id values
+ */
+#define CTDP_ACCEPT 0x1 /* the acceptable set term */
+#define CTDP_NONEG 0x2 /* the non-negotiable term */
+#define CTDP_MINOR 0x4 /* the minor path term */
+#define CTDP_ALLPARAMS 0x7
+
+#define CTDP_NONEG_CLEAR 0x0 /* clear the noneg flag */
+#define CTDP_NONEG_SET 0x1 /* set noneg */
+
+/*
+ * Status fields
+ */
+#define CTDS_STATE "ctds_state"
+#define CTDS_ASET "ctds_aset"
+#define CTDS_NONEG "ctds_noneg"
+#define CTDS_MINOR "ctds_minor"
+
+/*
+ * Max Time allowed for synchronous acknowledgement of a negotiation event
+ */
+#define CT_DEV_ACKTIME 60 /* 60 seconds */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SYS_CONTRACT_DEVICE_H */
diff --git a/usr/src/uts/common/sys/contract/device_impl.h b/usr/src/uts/common/sys/contract/device_impl.h
new file mode 100644
index 0000000000..1bc27c454d
--- /dev/null
+++ b/usr/src/uts/common/sys/contract/device_impl.h
@@ -0,0 +1,93 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _SYS_CONTRACT_DEVICE_IMPL_H
+#define _SYS_CONTRACT_DEVICE_IMPL_H
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/contract_impl.h>
+#include <sys/dditypes.h>
+#include <sys/contract/device.h>
+#include <sys/fs/snode.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Result of negotiation end: event successfully occurred or not
+ */
+#define CT_EV_SUCCESS 150
+#define CT_EV_FAILURE 151
+
+struct ctmpl_device {
+ ct_template_t ctd_ctmpl;
+ uint_t ctd_aset;
+ uint_t ctd_noneg;
+ char *ctd_minor;
+};
+
+struct cont_device {
+ contract_t cond_contract; /* common contract data */
+ char *cond_minor; /* minor node resource in contract */
+ dev_info_t *cond_dip; /* dip for minor node */
+ dev_t cond_devt; /* dev_t of minor node */
+ uint_t cond_spec; /* spec type of minor node */
+ uint_t cond_aset; /* acceptable state set */
+ uint_t cond_noneg; /* no negotiation if set */
+ uint_t cond_state; /* current state of device */
+ uint_t cond_neg; /* contract undergoing negotiation */
+ uint64_t cond_currev_id; /* id of event being negotiated */
+ uint_t cond_currev_type; /* type of event being negotiated */
+ uint_t cond_currev_ack; /* ack/nack status of ev negotiation */
+ list_node_t cond_next; /* linkage - devinfo's contracts */
+};
+
+/*
+ * Kernel APIs
+ */
+extern ct_type_t *device_type;
+/*
+ * struct proc;
+ */
+void contract_device_init(void);
+ct_ack_t contract_device_offline(dev_info_t *dip, dev_t dev, int spec_type);
+void contract_device_degrade(dev_info_t *dip, dev_t dev, int spec_type);
+void contract_device_undegrade(dev_info_t *dip, dev_t dev, int spec_type);
+int contract_device_open(dev_t dev, int spec_type, contract_t **ctpp);
+void contract_device_remove_dip(dev_info_t *dip);
+ct_ack_t contract_device_negotiate(dev_info_t *dip, dev_t dev, int spec_type,
+ uint_t evtype);
+void contract_device_finalize(dev_info_t *dip, dev_t dev, int spec_type,
+ uint_t evtype, int ct_result);
+void contract_device_negend(dev_info_t *dip, dev_t dev, int spec_type,
+ int result);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SYS_CONTRACT_DEVICE_IMPL_H */
diff --git a/usr/src/uts/common/sys/contract_impl.h b/usr/src/uts/common/sys/contract_impl.h
index c45cf06e60..7523de5bf0 100644
--- a/usr/src/uts/common/sys/contract_impl.h
+++ b/usr/src/uts/common/sys/contract_impl.h
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -50,6 +49,10 @@
extern "C" {
#endif
+extern int ct_debug;
+
+#define CT_DEBUG(args) if (ct_debug) cmn_err args
+
#ifdef _SYSCALL32
/*
@@ -110,7 +113,7 @@ typedef struct ctmplops {
int (*ctop_set)(struct ct_template *, ct_param_t *,
const cred_t *);
int (*ctop_get)(struct ct_template *, ct_param_t *);
- int (*ctop_create)(struct ct_template *);
+ int (*ctop_create)(struct ct_template *, ctid_t *);
uint_t allevents;
} ctmplops_t;
@@ -127,6 +130,7 @@ typedef struct ct_template {
uint_t ctmpl_ev_info; /* term: informative events */
} ct_template_t;
+
typedef enum ct_listnum {
CTEL_CONTRACT, /* ../contracts/type/<id>/events */
CTEL_BUNDLE, /* ../contracts/type/bundle */
@@ -139,6 +143,12 @@ typedef enum ctqflags {
CTQ_REFFED = 2 /* queue is reference counted */
} ctqflags_t;
+typedef enum ct_ack {
+ CT_ACK = 1, /* accept break */
+ CT_NACK, /* disallow break */
+ CT_NONE /* no matching contracts */
+} ct_ack_t;
+
/*
* Contract event queue
*/
@@ -198,6 +208,12 @@ typedef struct contops {
void (*contop_destroy)(struct contract *);
void (*contop_status)(struct contract *, zone_t *, int, nvlist_t *,
void *, model_t);
+ int (*contop_ack)(struct contract *, uint_t evtype,
+ uint64_t evid);
+ int (*contop_nack)(struct contract *, uint_t evtype,
+ uint64_t evid);
+ int (*contop_qack)(struct contract *, uint_t, uint64_t);
+ int (*contop_newct)(struct contract *);
} contops_t;
typedef ct_template_t *(ct_f_default_t)(void);
@@ -221,6 +237,11 @@ typedef enum ctflags {
CTF_INHERIT = 0x1
} ctflags_t;
+typedef struct ct_time {
+ long ctm_total; /* Total time allowed for event */
+ clock_t ctm_start; /* starting lbolt for event */
+} ct_time_t;
+
/*
* Contract
*/
@@ -257,6 +278,8 @@ typedef struct contract {
struct contract *ct_regent; /* [prospective] regent contract */
int ct_evcnt; /* number of critical events */
ct_kevent_t *ct_nevent; /* negotiation event */
+ ct_time_t ct_ntime; /* negotiation time tracker */
+ ct_time_t ct_qtime; /* quantum time tracker */
} contract_t;
#define CTLF_COPYOUT 0x1 /* performing copyout */
@@ -284,7 +307,7 @@ int ctmpl_get(ct_template_t *, ct_param_t *);
ct_template_t *ctmpl_dup(ct_template_t *);
void ctmpl_activate(ct_template_t *);
void ctmpl_clear(ct_template_t *);
-int ctmpl_create(ct_template_t *);
+int ctmpl_create(ct_template_t *, ctid_t *);
/*
* Contract functions
@@ -294,12 +317,14 @@ int contract_abandon(contract_t *, struct proc *, int);
int contract_adopt(contract_t *, struct proc *);
void contract_destroy(contract_t *);
void contract_exit(struct proc *);
-int contract_ack(contract_t *, uint64_t);
+int contract_ack(contract_t *ct, uint64_t evid, int cmd);
+int contract_qack(contract_t *ct, uint64_t evid);
+int contract_newct(contract_t *ct);
/*
* Event interfaces
*/
-void cte_publish_all(contract_t *, ct_kevent_t *, nvlist_t *, nvlist_t *);
+uint64_t cte_publish_all(contract_t *, ct_kevent_t *, nvlist_t *, nvlist_t *);
void cte_add_listener(ct_equeue_t *, ct_listener_t *);
void cte_remove_listener(ct_listener_t *);
void cte_reset_listener(ct_listener_t *);
@@ -313,7 +338,7 @@ int cte_set_reliable(ct_listener_t *, const cred_t *);
int contract_compar(const void *, const void *);
void ctmpl_init(ct_template_t *, ctmplops_t *, ct_type_t *, void *);
void ctmpl_copy(ct_template_t *, ct_template_t *);
-int ctmpl_create_inval(ct_template_t *);
+int ctmpl_create_inval(ct_template_t *, ctid_t *);
int contract_ctor(contract_t *, ct_type_t *, ct_template_t *, void *, ctflags_t,
struct proc *, int);
void contract_hold(contract_t *);
@@ -352,6 +377,13 @@ vnode_t *contract_vnode_get(contract_t *, vfs_t *);
void contract_vnode_set(contract_t *, contract_vnode_t *, vnode_t *);
int contract_vnode_clear(contract_t *, contract_vnode_t *);
+/*
+ * Negotiation stubs
+ */
+int contract_ack_inval(contract_t *, uint_t, uint64_t);
+int contract_qack_inval(contract_t *, uint_t, uint64_t);
+int contract_qack_notsup(contract_t *, uint_t, uint64_t);
+
#ifdef __cplusplus
}
#endif
diff --git a/usr/src/uts/common/sys/ctfs.h b/usr/src/uts/common/sys/ctfs.h
index e6702044d1..b46a517f2c 100644
--- a/usr/src/uts/common/sys/ctfs.h
+++ b/usr/src/uts/common/sys/ctfs.h
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -65,6 +64,7 @@ extern "C" {
#define CT_CQREQ CTFS_CTL(2) /* Request an additional quantum */
#define CT_CADOPT CTFS_CTL(3) /* Adopt a contract */
#define CT_CNEWCT CTFS_CTL(4) /* Define new contract */
+#define CT_CNACK CTFS_CTL(5) /* nack a negotiation */
/*
* Control codes for messages written to status files.
diff --git a/usr/src/uts/common/sys/ddi_impldefs.h b/usr/src/uts/common/sys/ddi_impldefs.h
index 3b99c60997..f5c227e5aa 100644
--- a/usr/src/uts/common/sys/ddi_impldefs.h
+++ b/usr/src/uts/common/sys/ddi_impldefs.h
@@ -194,6 +194,12 @@ struct dev_info {
char *devi_addr_buf; /* buffer for devi_addr */
char *devi_rebinding_name; /* binding_name of rebind */
+ /* For device contracts that have this dip's minor node as resource */
+ kmutex_t devi_ct_lock; /* contract lock */
+ kcondvar_t devi_ct_cv; /* contract cv */
+ int devi_ct_count; /* # of outstanding responses */
+ int devi_ct_neg; /* neg. occurred on dip */
+ list_t devi_ct;
};
#define DEVI(dev_info_type) ((struct dev_info *)(dev_info_type))
@@ -271,6 +277,11 @@ struct dev_info {
#define DEVI_SET_DEVICE_ONLINE(dip) { \
ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \
+ if (DEVI(dip)->devi_state & DEVI_DEVICE_DEGRADED) { \
+ mutex_exit(&DEVI(dip)->devi_lock); \
+ e_ddi_undegrade_finalize(dip); \
+ mutex_enter(&DEVI(dip)->devi_lock); \
+ } \
/* setting ONLINE clears DOWN, DEGRADED, OFFLINE */ \
DEVI(dip)->devi_state &= ~(DEVI_DEVICE_DOWN | \
DEVI_DEVICE_DEGRADED | DEVI_DEVICE_OFFLINE); \
@@ -297,12 +308,20 @@ struct dev_info {
#define DEVI_SET_DEVICE_DEGRADED(dip) { \
ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \
ASSERT(!DEVI_IS_DEVICE_OFFLINE(dip)); \
+ mutex_exit(&DEVI(dip)->devi_lock); \
+ e_ddi_degrade_finalize(dip); \
+ mutex_enter(&DEVI(dip)->devi_lock); \
DEVI(dip)->devi_state |= (DEVI_DEVICE_DEGRADED | DEVI_S_REPORT); \
}
#define DEVI_SET_DEVICE_UP(dip) { \
ASSERT(mutex_owned(&DEVI(dip)->devi_lock)); \
ASSERT(!DEVI_IS_DEVICE_OFFLINE(dip)); \
+ if (DEVI(dip)->devi_state & DEVI_DEVICE_DEGRADED) { \
+ mutex_exit(&DEVI(dip)->devi_lock); \
+ e_ddi_undegrade_finalize(dip); \
+ mutex_enter(&DEVI(dip)->devi_lock); \
+ } \
DEVI(dip)->devi_state &= ~(DEVI_DEVICE_DEGRADED | DEVI_DEVICE_DOWN); \
DEVI(dip)->devi_state |= DEVI_S_REPORT; \
}
@@ -503,6 +522,11 @@ void i_devi_exit(dev_info_t *, uint_t c_mask, int has_lock);
#define DEVI_REGISTERED_DEVID 0x00000020 /* device registered a devid */
#define DEVI_PHCI_SIGNALS_VHCI 0x00000040 /* pHCI ndi_devi_exit signals vHCI */
#define DEVI_REBIND 0x00000080 /* post initchild driver rebind */
+#define DEVI_RETIRED 0x00000100 /* device is retired */
+#define DEVI_RETIRING 0x00000200 /* being evaluated for retire */
+#define DEVI_R_CONSTRAINT 0x00000400 /* constraints have been applied */
+#define DEVI_R_BLOCKED 0x00000800 /* constraints block retire */
+#define DEVI_CT_NOP 0x00001000 /* NOP contract event occurred */
#define DEVI_BUSY_CHANGING(dip) (DEVI(dip)->devi_flags & DEVI_BUSY)
#define DEVI_BUSY_OWNED(dip) (DEVI_BUSY_CHANGING(dip) && \
diff --git a/usr/src/uts/common/sys/ddi_implfuncs.h b/usr/src/uts/common/sys/ddi_implfuncs.h
index 5105c4ce18..4aa213c1b2 100644
--- a/usr/src/uts/common/sys/ddi_implfuncs.h
+++ b/usr/src/uts/common/sys/ddi_implfuncs.h
@@ -20,7 +20,7 @@
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -274,6 +274,15 @@ int e_devid_cache_to_devt_list(ddi_devid_t, char *, int *, dev_t **);
void e_devid_cache_free_devt_list(int, dev_t *);
/*
+ * I/O retire persistent store
+ */
+void retire_store_init(void);
+void retire_store_read(void);
+int e_ddi_retire_persist(char *devpath);
+int e_ddi_retire_unpersist(char *devpath);
+int e_ddi_device_retired(char *devpath);
+
+/*
* Resource control functions to lock down device memory.
*/
extern int i_ddi_incr_locked_memory(proc_t *, rctl_qty_t);
diff --git a/usr/src/uts/common/sys/ddi_obsolete.h b/usr/src/uts/common/sys/ddi_obsolete.h
index c6a44c78de..84970dbb54 100644
--- a/usr/src/uts/common/sys/ddi_obsolete.h
+++ b/usr/src/uts/common/sys/ddi_obsolete.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -14,6 +14,7 @@
#include <sys/types.h>
#include <sys/dditypes.h>
+#include <sys/sunldi.h>
#ifdef __cplusplus
@@ -192,6 +193,15 @@ extern void repoutsw(int port, uint16_t *addr, int count);
extern void repoutsd(int port, uint32_t *addr, int count);
#endif
+/* Obsolete LDI event interfaces */
+extern int ldi_get_eventcookie(ldi_handle_t, char *,
+ ddi_eventcookie_t *);
+extern int ldi_add_event_handler(ldi_handle_t, ddi_eventcookie_t,
+ void (*handler)(ldi_handle_t, ddi_eventcookie_t, void *, void *),
+ void *, ldi_callback_id_t *);
+extern int ldi_remove_event_handler(ldi_handle_t, ldi_callback_id_t);
+
+
#endif /* not _DDI_STRICT */
#ifdef __cplusplus
diff --git a/usr/src/uts/common/sys/fs/snode.h b/usr/src/uts/common/sys/fs/snode.h
index ecef85390c..cd572d545c 100644
--- a/usr/src/uts/common/sys/fs/snode.h
+++ b/usr/src/uts/common/sys/fs/snode.h
@@ -119,6 +119,7 @@ struct snode {
#define SSELFCLONE 0x2000 /* represents a self cloning device */
#define SNOFLUSH 0x4000 /* do not flush device on fsync */
#define SCLOSING 0x8000 /* in last close(9E) */
+#define SFENCED 0x10000 /* snode fenced off for I/O retire */
#ifdef _KERNEL
/*
@@ -128,6 +129,12 @@ struct snode {
#define VTOCS(vp) (VTOS(VTOS(vp)->s_commonvp))
#define STOV(sp) ((sp)->s_vnode)
+extern int spec_debug;
+
+#define SPEC_FENCE_DEBUG 0x0001 /* emit fence related debug messages */
+
+#define FENDBG(args) if (spec_debug & SPEC_FENCE_DEBUG) cmn_err args
+
/*
* Forward declarations
@@ -167,6 +174,8 @@ void spec_snode_walk(int (*callback)(struct snode *, void *), void *);
int spec_devi_open_count(struct snode *, dev_info_t **);
int spec_is_clone(struct vnode *);
int spec_is_selfclone(struct vnode *);
+int spec_fence_snode(dev_info_t *dip, struct vnode *vp);
+int spec_unfence_snode(dev_info_t *dip);
/*
diff --git a/usr/src/uts/common/sys/modctl.h b/usr/src/uts/common/sys/modctl.h
index 255d02d7b2..9eab8025da 100644
--- a/usr/src/uts/common/sys/modctl.h
+++ b/usr/src/uts/common/sys/modctl.h
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -258,6 +258,9 @@ struct modlinkage {
#define MODDEVNAME 37
#define MODGETDEVFSPATH_MI_LEN 38
#define MODGETDEVFSPATH_MI 39
+#define MODRETIRE 40
+#define MODUNRETIRE 41
+#define MODISRETIRED 42
/*
* sub cmds for MODEVENTS
@@ -641,6 +644,7 @@ extern int modctl(int, ...);
#define MODDEBUG_LOADMSG 0x80000000 /* print "[un]loading..." msg */
#define MODDEBUG_ERRMSG 0x40000000 /* print detailed error msgs */
#define MODDEBUG_LOADMSG2 0x20000000 /* print 2nd level msgs */
+#define MODDEBUG_RETIRE 0x10000000 /* print retire msgs */
#define MODDEBUG_FINI_EBUSY 0x00020000 /* pretend fini returns EBUSY */
#define MODDEBUG_NOAUL_IPP 0x00010000 /* no Autounloading ipp mods */
#define MODDEBUG_NOAUL_DACF 0x00008000 /* no Autounloading dacf mods */
diff --git a/usr/src/uts/common/sys/sunldi.h b/usr/src/uts/common/sys/sunldi.h
index f80cc44f8f..71e9d9a7da 100644
--- a/usr/src/uts/common/sys/sunldi.h
+++ b/usr/src/uts/common/sys/sunldi.h
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -60,6 +59,26 @@ typedef struct __ldi_handle *ldi_handle_t;
typedef struct __ldi_callback_id *ldi_callback_id_t;
+typedef struct __ldi_ev_cookie *ldi_ev_cookie_t;
+
+/*
+ * LDI event interface related
+ */
+#define LDI_EV_SUCCESS 0
+#define LDI_EV_FAILURE (-1)
+#define LDI_EV_NONE (-2) /* no matching callbacks registered */
+#define LDI_EV_OFFLINE "LDI:EVENT:OFFLINE"
+#define LDI_EV_DEGRADE "LDI:EVENT:DEGRADE"
+
+#define LDI_EV_CB_VERS_1 1
+#define LDI_EV_CB_VERS LDI_EV_CB_VERS_1
+
+typedef struct ldi_ev_callback {
+ uint_t cb_vers;
+ int (*cb_notify)(ldi_handle_t, ldi_ev_cookie_t, void *, void *);
+ void (*cb_finalize)(ldi_handle_t, ldi_ev_cookie_t, int, void *, void *);
+} ldi_ev_callback_t;
+
/*
* LDI Ident manipulation functions
*/
@@ -93,13 +112,6 @@ extern int ldi_get_size(ldi_handle_t, uint64_t *);
extern int ldi_prop_op(ldi_handle_t, ddi_prop_op_t, int,
char *, caddr_t, int *);
-extern int ldi_get_eventcookie(ldi_handle_t, char *,
- ddi_eventcookie_t *);
-extern int ldi_add_event_handler(ldi_handle_t, ddi_eventcookie_t,
- void (*handler)(ldi_handle_t, ddi_eventcookie_t, void *, void *),
- void *, ldi_callback_id_t *);
-extern int ldi_remove_event_handler(ldi_handle_t, ldi_callback_id_t);
-
extern int ldi_strategy(ldi_handle_t, struct buf *);
extern int ldi_dump(ldi_handle_t, caddr_t, daddr_t, int);
extern int ldi_devmap(ldi_handle_t, devmap_cookie_t, offset_t,
@@ -132,6 +144,20 @@ extern int ldi_get_otyp(ldi_handle_t, int *);
extern int ldi_get_devid(ldi_handle_t, ddi_devid_t *);
extern int ldi_get_minor_name(ldi_handle_t, char **);
+/*
+ * LDI events related declarations
+ */
+extern int ldi_ev_get_cookie(ldi_handle_t lh, char *evname,
+ ldi_ev_cookie_t *cookiep);
+extern char *ldi_ev_get_type(ldi_ev_cookie_t cookie);
+extern int ldi_ev_register_callbacks(ldi_handle_t lh,
+ ldi_ev_cookie_t cookie, ldi_ev_callback_t *callb,
+ void *arg, ldi_callback_id_t *id);
+extern int ldi_ev_notify(dev_info_t *dip, minor_t minor, int spec_type,
+ ldi_ev_cookie_t cookie, void *ev_data);
+extern void ldi_ev_finalize(dev_info_t *dip, minor_t minor, int spec_type,
+ int ldi_result, ldi_ev_cookie_t cookie, void *ev_data);
+extern int ldi_ev_remove_callbacks(ldi_callback_id_t id);
#endif /* _KERNEL */
diff --git a/usr/src/uts/common/sys/sunldi_impl.h b/usr/src/uts/common/sys/sunldi_impl.h
index 9cbffc3ed2..1156fe2c41 100644
--- a/usr/src/uts/common/sys/sunldi_impl.h
+++ b/usr/src/uts/common/sys/sunldi_impl.h
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -53,6 +52,17 @@ extern "C" {
#define LI_HASH_SZ 32
/*
+ * Obsolete LDI event interfaces are available for now but are deprecated and a
+ * warning will be issued to consumers.
+ */
+#define LDI_OBSOLETE_EVENT 1
+
+/*
+ * Flag for LDI handle's lh_flags field
+ */
+#define LH_FLAGS_NOTIFY 0x0001 /* invoked in context of a notify */
+
+/*
* LDI initialization function
*/
void ldi_init(void);
@@ -87,20 +97,24 @@ struct ldi_handle {
/* protected by ldi_handle_hash_lock */
struct ldi_handle *lh_next;
uint_t lh_ref;
+ uint_t lh_flags;
/* unique/static fields in the handle */
uint_t lh_type;
struct ldi_ident *lh_ident;
vnode_t *lh_vp;
+#ifdef LDI_OBSOLETE_EVENT
/* fields protected by lh_lock */
kmutex_t lh_lock[1];
struct ldi_event *lh_events;
+#endif
};
/*
* LDI event information
*/
+#ifdef LDI_OBSOLETE_EVENT
typedef struct ldi_event {
/* fields protected by le_lhp->lh_lock */
struct ldi_event *le_next;
@@ -112,6 +126,36 @@ typedef struct ldi_event {
void *le_arg;
ddi_callback_id_t le_id;
} ldi_event_t;
+#endif
+
+typedef struct ldi_ev_callback_impl {
+ struct ldi_handle *lec_lhp;
+ dev_info_t *lec_dip;
+ dev_t lec_dev;
+ int lec_spec;
+ int (*lec_notify)();
+ void (*lec_finalize)();
+ void *lec_arg;
+ void *lec_cookie;
+ void *lec_id;
+ list_node_t lec_list;
+} ldi_ev_callback_impl_t;
+
+struct ldi_ev_callback_list {
+ kmutex_t le_lock;
+ kcondvar_t le_cv;
+ int le_busy;
+ void *le_thread;
+ list_t le_head;
+};
+
+int ldi_invoke_notify(dev_info_t *dip, dev_t dev, int spec_type, char *event,
+ void *ev_data);
+void ldi_invoke_finalize(dev_info_t *dip, dev_t dev, int spec_type, char *event,
+ int ldi_result, void *ev_data);
+int e_ddi_offline_notify(dev_info_t *dip);
+void e_ddi_offline_finalize(dev_info_t *dip, int result);
+
/*
* LDI device usage interfaces
diff --git a/usr/src/uts/common/sys/sunmdi.h b/usr/src/uts/common/sys/sunmdi.h
index 75b4f83ef7..c4a42633be 100644
--- a/usr/src/uts/common/sys/sunmdi.h
+++ b/usr/src/uts/common/sys/sunmdi.h
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -133,6 +133,14 @@ int mdi_devi_online(dev_info_t *, uint_t);
int mdi_devi_offline(dev_info_t *, uint_t);
/*
+ * MDI path retire interfaces
+ */
+void mdi_phci_mark_retiring(dev_info_t *dip, char **cons_array);
+void mdi_phci_retire_notify(dev_info_t *dip, int *constraint);
+void mdi_phci_retire_finalize(dev_info_t *dip, int phci_only);
+void mdi_phci_unretire(dev_info_t *dip);
+
+/*
* MDI devinfo locking functions.
*/
void mdi_devi_enter(dev_info_t *, int *);