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 (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
23 */
24
25 #include <sys/mutex.h>
26 #include <sys/debug.h>
27 #include <sys/types.h>
28 #include <sys/param.h>
29 #include <sys/kmem.h>
30 #include <sys/thread.h>
31 #include <sys/id_space.h>
32 #include <sys/avl.h>
33 #include <sys/list.h>
34 #include <sys/sysmacros.h>
35 #include <sys/proc.h>
36 #include <sys/contract.h>
37 #include <sys/contract_impl.h>
38 #include <sys/contract/device.h>
39 #include <sys/contract/device_impl.h>
40 #include <sys/cmn_err.h>
41 #include <sys/nvpair.h>
42 #include <sys/policy.h>
2036 ct_ack_t
2037 contract_device_negotiate(dev_info_t *dip, dev_t dev, int spec_type,
2038 uint_t evtype)
2039 {
2040 int result;
2041
2042 ASSERT(dip);
2043 ASSERT(dev != NODEV);
2044 ASSERT(dev != DDI_DEV_T_ANY);
2045 ASSERT(dev != DDI_DEV_T_NONE);
2046 ASSERT(spec_type == S_IFBLK || spec_type == S_IFCHR);
2047
2048 switch (evtype) {
2049 case CT_DEV_EV_OFFLINE:
2050 result = contract_device_offline(dip, dev, spec_type);
2051 break;
2052 default:
2053 cmn_err(CE_PANIC, "contract_device_negotiate(): Negotiation "
2054 "not supported: event (%d) for dev_t (%lu) and spec (%d), "
2055 "dip (%p)", evtype, dev, spec_type, (void *)dip);
2056 result = CT_NACK;
2057 break;
2058 }
2059
2060 return (result);
2061 }
2062
2063 /*
2064 * A wrapper routine called by other subsystems (such as the LDI) to
2065 * finalize event processing for a state change event. For synchronous
2066 * state changes, this publishes NEGEND events. For asynchronous i.e.
2067 * non-negotiable events this publishes the event.
2068 */
2069 void
2070 contract_device_finalize(dev_info_t *dip, dev_t dev, int spec_type,
2071 uint_t evtype, int ct_result)
2072 {
2073 ASSERT(dip);
2074 ASSERT(dev != NODEV);
2075 ASSERT(dev != DDI_DEV_T_ANY);
2076 ASSERT(dev != DDI_DEV_T_NONE);
|
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 (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2019 Joyent, Inc.
24 */
25
26 #include <sys/mutex.h>
27 #include <sys/debug.h>
28 #include <sys/types.h>
29 #include <sys/param.h>
30 #include <sys/kmem.h>
31 #include <sys/thread.h>
32 #include <sys/id_space.h>
33 #include <sys/avl.h>
34 #include <sys/list.h>
35 #include <sys/sysmacros.h>
36 #include <sys/proc.h>
37 #include <sys/contract.h>
38 #include <sys/contract_impl.h>
39 #include <sys/contract/device.h>
40 #include <sys/contract/device_impl.h>
41 #include <sys/cmn_err.h>
42 #include <sys/nvpair.h>
43 #include <sys/policy.h>
2037 ct_ack_t
2038 contract_device_negotiate(dev_info_t *dip, dev_t dev, int spec_type,
2039 uint_t evtype)
2040 {
2041 int result;
2042
2043 ASSERT(dip);
2044 ASSERT(dev != NODEV);
2045 ASSERT(dev != DDI_DEV_T_ANY);
2046 ASSERT(dev != DDI_DEV_T_NONE);
2047 ASSERT(spec_type == S_IFBLK || spec_type == S_IFCHR);
2048
2049 switch (evtype) {
2050 case CT_DEV_EV_OFFLINE:
2051 result = contract_device_offline(dip, dev, spec_type);
2052 break;
2053 default:
2054 cmn_err(CE_PANIC, "contract_device_negotiate(): Negotiation "
2055 "not supported: event (%d) for dev_t (%lu) and spec (%d), "
2056 "dip (%p)", evtype, dev, spec_type, (void *)dip);
2057 break;
2058 }
2059
2060 return (result);
2061 }
2062
2063 /*
2064 * A wrapper routine called by other subsystems (such as the LDI) to
2065 * finalize event processing for a state change event. For synchronous
2066 * state changes, this publishes NEGEND events. For asynchronous i.e.
2067 * non-negotiable events this publishes the event.
2068 */
2069 void
2070 contract_device_finalize(dev_info_t *dip, dev_t dev, int spec_type,
2071 uint_t evtype, int ct_result)
2072 {
2073 ASSERT(dip);
2074 ASSERT(dev != NODEV);
2075 ASSERT(dev != DDI_DEV_T_ANY);
2076 ASSERT(dev != DDI_DEV_T_NONE);
|